From c9a81e52412b99b6ea73b9d691e0e5648e02314e Mon Sep 17 00:00:00 2001 From: Serhii Smirnov Date: Fri, 23 Apr 2021 19:31:40 +0300 Subject: [PATCH 001/475] #8462: Removed EntityManagerInterface::copy() --- .../ORM/Decorator/EntityManagerDecorator.php | 8 -------- lib/Doctrine/ORM/EntityManager.php | 15 --------------- lib/Doctrine/ORM/EntityManagerInterface.php | 14 -------------- .../Mock/NonProxyLoadingEntityManager.php | 8 -------- 4 files changed, 45 deletions(-) diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index b1d11f3c6f9..6bfecef9364 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -149,14 +149,6 @@ public function close() $this->wrapped->close(); } - /** - * {@inheritdoc} - */ - public function copy($entity, $deep = false) - { - return $this->wrapped->copy($entity, $deep); - } - /** * {@inheritdoc} */ diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 66216dda028..77d82b44bb8 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -727,21 +727,6 @@ public function merge($entity) return $this->unitOfWork->merge($entity); } - /** - * {@inheritDoc} - */ - public function copy($entity, $deep = false) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8462', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0.', - __METHOD__ - ); - - throw new BadMethodCallException('Not implemented.'); - } - /** * {@inheritDoc} */ diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index 5f34f6fe49e..7909ad7cade 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -206,20 +206,6 @@ public function getPartialReference($entityName, $identifier); */ public function close(); - /** - * Creates a copy of the given entity. Can create a shallow or a deep copy. - * - * @deprecated 2.7 This method is being removed from the ORM and won't have any replacement - * - * @param object $entity The entity to copy. - * @param bool $deep FALSE for a shallow copy, TRUE for a deep copy. - * - * @return object The new entity. - * - * @throws BadMethodCallException - */ - public function copy($entity, $deep = false); - /** * Acquire a lock on the given entity. * diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 092a181f0d8..4c3ca5e8c1e 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -180,14 +180,6 @@ public function close() $this->realEntityManager->close(); } - /** - * {@inheritDoc} - */ - public function copy($entity, $deep = false) - { - return $this->realEntityManager->copy($entity, $deep); - } - /** * {@inheritDoc} */ From cf8adfe5d372436839e9894354692dd343d689c0 Mon Sep 17 00:00:00 2001 From: Serhii Smirnov Date: Sat, 24 Apr 2021 15:05:25 +0300 Subject: [PATCH 002/475] Updated UPGRADE.md --- UPGRADE.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 063bb69647f..45519b93de0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,9 @@ +# Upgrade to 3.0 + +## Minor BC BREAK: removed `Doctrine\ORM\EntityManagerInterface#copy()` + +Method `Doctrine\ORM\EntityManagerInterface#copy()` never got its implementation and is removed in 3.0. + # Upgrade to 2.8 ## Minor BC BREAK: Failed commit now throw OptimisticLockException @@ -12,12 +18,12 @@ Note that `toIterable()` yields results of the query, unlike `iterator()` which # Upgrade to 2.7 -## Added `Doctrine\ORM\AbstractQuery#enableResultCache()` and `Doctrine\ORM\AbstractQuery#disableResultCache()` methods +## Added `Doctrine\ORM\AbstractQuery#enableResultCache()` and `Doctrine\ORM\AbstractQuery#disableResultCache()` methods Method `Doctrine\ORM\AbstractQuery#useResultCache()` which could be used for both enabling and disabling the cache -(depending on passed flag) was split into two. +(depending on passed flag) was split into two. -## Minor BC BREAK: paginator output walkers aren't be called anymore on sub-queries for queries without max results +## Minor BC BREAK: paginator output walkers aren't be called anymore on sub-queries for queries without max results To optimize DB interaction, `Doctrine\ORM\Tools\Pagination\Paginator` no longer fetches identifiers to be able to perform the pagination with join collections when max results isn't set in the query. @@ -36,7 +42,7 @@ In the last patch of the `v2.6.x` series, we fixed a bug that was not converting In order to not break BC we've introduced a way to enable the fixed behavior using a boolean constructor argument. This argument will be removed in 3.0 and the default behavior will be the fixed one. -## Deprecated: `Doctrine\ORM\AbstractQuery#useResultCache()` +## Deprecated: `Doctrine\ORM\AbstractQuery#useResultCache()` Method `Doctrine\ORM\AbstractQuery#useResultCache()` is deprecated because it is split into `enableResultCache()` and `disableResultCache()`. It will be removed in 3.0. @@ -66,7 +72,7 @@ These related classes have been deprecated: * `Doctrine\ORM\Proxy\ProxyFactory` * `Doctrine\ORM\Proxy\Autoloader` - we suggest using the composer autoloader instead - + These methods have been deprecated: * `Doctrine\ORM\Configuration#getAutoGenerateProxyClasses()` @@ -124,7 +130,7 @@ If your code relies on single entity flushing optimisations via Said API was affected by multiple data integrity bugs due to the fact that change tracking was being restricted upon a subset of the managed -entities. The ORM cannot support committing subsets of the managed +entities. The ORM cannot support committing subsets of the managed entities while also guaranteeing data integrity, therefore this utility was removed. @@ -225,8 +231,8 @@ either: - map those classes as `MappedSuperclass` ## Minor BC BREAK: ``EntityManagerInterface`` instead of ``EntityManager`` in type-hints - -As of 2.5, classes requiring the ``EntityManager`` in any method signature will now require + +As of 2.5, classes requiring the ``EntityManager`` in any method signature will now require an ``EntityManagerInterface`` instead. If you are extending any of the following classes, then you need to check following signatures: @@ -319,7 +325,7 @@ the `Doctrine\ORM\Repository\DefaultRepositoryFactory`. When executing DQL queries with new object expressions, instead of returning DTOs numerically indexes, it will now respect user provided aliases. Consider the following query: SELECT new UserDTO(u.id,u.name) as user,new AddressDTO(a.street,a.postalCode) as address, a.id as addressId FROM User u INNER JOIN u.addresses a WITH a.isPrimary = true - + Previously, your result would be similar to this: array( From 77c73e880131de3cd75de3b0c60b8f5276562e14 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 26 Oct 2020 08:02:49 +0100 Subject: [PATCH 003/475] Fix variadic args in Expr --- UPGRADE.md | 17 +++++ lib/Doctrine/ORM/Query/Expr.php | 26 +++---- lib/Doctrine/ORM/QueryBuilder.php | 119 ++++++++++++++---------------- phpstan-baseline.neon | 5 -- 4 files changed, 82 insertions(+), 85 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 100be03e9bb..fd15e6331e0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,22 @@ # Upgrade to 3.0 +## Variadic methods now use native variadics +The following methods were using `func_get_args()` to simulate a variadic argument: +- `Doctrine\ORM\Query\Expr#andX()` +- `Doctrine\ORM\Query\Expr#orX()` +- `Doctrine\ORM\QueryBuilder#select()` +- `Doctrine\ORM\QueryBuilder#addSelect()` +- `Doctrine\ORM\QueryBuilder#where()` +- `Doctrine\ORM\QueryBuilder#andWhere()` +- `Doctrine\ORM\QueryBuilder#orWhere()` +- `Doctrine\ORM\QueryBuilder#groupBy()` +- `Doctrine\ORM\QueryBuilder#andGroupBy()` +- `Doctrine\ORM\QueryBuilder#having()` +- `Doctrine\ORM\QueryBuilder#andHaving()` +- `Doctrine\ORM\QueryBuilder#orHaving()` +A variadic argument is now actually used in their signatures signature (`...$x`). +Signatures of overridden methods should be changed accordingly + ## Minor BC BREAK: removed `Doctrine\ORM\EntityManagerInterface#copy()` Method `Doctrine\ORM\EntityManagerInterface#copy()` never got its implementation and is removed in 3.0. diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index c10fd6c879c..be8a51b3619 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -31,16 +31,13 @@ class Expr * // (u.type = ?1) AND (u.role = ?2) * $expr->andX($expr->eq('u.type', ':1'), $expr->eq('u.role', ':2')); * - * @param Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string $x Optional clause. Defaults to null, - * but requires at least one defined - * when converting to string. - * @psalm-param Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x - * - * @return Expr\Andx + * @param Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x Optional clause. Defaults to null, + * but requires at least one defined + * when converting to string. */ - public function andX($x = null) + public function andX(...$x): Expr\Andx { - return new Expr\Andx(func_get_args()); + return new Expr\Andx($x); } /** @@ -52,16 +49,13 @@ public function andX($x = null) * // (u.type = ?1) OR (u.role = ?2) * $q->where($q->expr()->orX('u.type = ?1', 'u.role = ?2')); * - * @param Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string $x Optional clause. Defaults to null, - * but requires at least one defined - * when converting to string. - * @psalm-param Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x - * - * @return Expr\Orx + * @param Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x Optional clause. Defaults to null, + * but requires at least one defined + * when converting to string. */ - public function orX($x = null) + public function orX(...$x): Expr\Orx { - return new Expr\Orx(func_get_args()); + return new Expr\Orx($x); } /** diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 251b4b9ee81..afde1888aa9 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -14,8 +14,7 @@ use function array_merge; use function array_unshift; use function assert; -use function func_get_args; -use function func_num_args; +use function count; use function implode; use function in_array; use function is_array; @@ -740,21 +739,19 @@ public function add($dqlPartName, $dqlPart, $append = false) * ->leftJoin('u.Phonenumbers', 'p'); * * - * @param mixed $select The selection expressions. + * @param mixed ...$select The selection expressions. * * @return static */ - public function select($select = null) + public function select(...$select) { $this->_type = self::SELECT; - if (empty($select)) { + if ($select === []) { return $this; } - $selects = is_array($select) ? $select : func_get_args(); - - return $this->add('select', new Expr\Select($selects), false); + return $this->add('select', new Expr\Select($select), false); } /** @@ -789,21 +786,19 @@ public function distinct($flag = true) * ->leftJoin('u.Phonenumbers', 'p'); * * - * @param mixed $select The selection expression. + * @param mixed ...$select The selection expression. * * @return static */ - public function addSelect($select = null) + public function addSelect(...$select) { $this->_type = self::SELECT; - if (empty($select)) { + if ($select === []) { return $this; } - $selects = is_array($select) ? $select : func_get_args(); - - return $this->add('select', new Expr\Select($selects), true); + return $this->add('select', new Expr\Select($select), true); } /** @@ -1074,14 +1069,14 @@ public function set($key, $value) * ->where($or); * * - * @param mixed $predicates The restriction predicates. + * @param mixed ...$predicates The restriction predicates. * * @return static */ - public function where($predicates) + public function where(...$predicates) { - if (! (func_num_args() === 1 && $predicates instanceof Expr\Composite)) { - $predicates = new Expr\Andx(func_get_args()); + if (! (count($predicates) === 1 && $predicates[0] instanceof Expr\Composite)) { + $predicates = new Expr\Andx($predicates); } return $this->add('where', $predicates); @@ -1101,23 +1096,22 @@ public function where($predicates) * * @see where() * - * @param mixed $where The query restrictions. + * @param mixed ...$where The query restrictions. * * @return static */ - public function andWhere() + public function andWhere(...$where) { - $args = func_get_args(); - $where = $this->getDQLPart('where'); + $dql = $this->getDQLPart('where'); - if ($where instanceof Expr\Andx) { - $where->addMultiple($args); + if ($dql instanceof Expr\Andx) { + $dql->addMultiple($where); } else { - array_unshift($args, $where); - $where = new Expr\Andx($args); + array_unshift($where, $dql); + $dql = new Expr\Andx($where); } - return $this->add('where', $where); + return $this->add('where', $dql); } /** @@ -1134,23 +1128,22 @@ public function andWhere() * * @see where() * - * @param mixed $where The WHERE statement. + * @param mixed ...$where The WHERE statement. * * @return static */ - public function orWhere() + public function orWhere(...$where) { - $args = func_get_args(); - $where = $this->getDQLPart('where'); + $dql = $this->getDQLPart('where'); - if ($where instanceof Expr\Orx) { - $where->addMultiple($args); + if ($dql instanceof Expr\Orx) { + $dql->addMultiple($where); } else { - array_unshift($args, $where); - $where = new Expr\Orx($args); + array_unshift($where, $dql); + $dql = new Expr\Orx($where); } - return $this->add('where', $where); + return $this->add('where', $dql); } /** @@ -1164,13 +1157,13 @@ public function orWhere() * ->groupBy('u.id'); * * - * @param string $groupBy The grouping expression. + * @param string ...$groupBy The grouping expression. * * @return static */ - public function groupBy($groupBy) + public function groupBy(string ...$groupBy) { - return $this->add('groupBy', new Expr\GroupBy(func_get_args())); + return $this->add('groupBy', new Expr\GroupBy($groupBy)); } /** @@ -1184,27 +1177,27 @@ public function groupBy($groupBy) * ->addGroupBy('u.createdAt'); * * - * @param string $groupBy The grouping expression. + * @param string ...$groupBy The grouping expression. * * @return static */ - public function addGroupBy($groupBy) + public function addGroupBy(string ...$groupBy) { - return $this->add('groupBy', new Expr\GroupBy(func_get_args()), true); + return $this->add('groupBy', new Expr\GroupBy($groupBy), true); } /** * Specifies a restriction over the groups of the query. * Replaces any previous having restrictions, if any. * - * @param mixed $having The restriction over the groups. + * @param mixed ...$having The restriction over the groups. * * @return static */ - public function having($having) + public function having(...$having) { - if (! (func_num_args() === 1 && ($having instanceof Expr\Andx || $having instanceof Expr\Orx))) { - $having = new Expr\Andx(func_get_args()); + if (! (count($having) === 1 && ($having[0] instanceof Expr\Andx || $having[0] instanceof Expr\Orx))) { + $having = new Expr\Andx($having); } return $this->add('having', $having); @@ -1214,46 +1207,44 @@ public function having($having) * Adds a restriction over the groups of the query, forming a logical * conjunction with any existing having restrictions. * - * @param mixed $having The restriction to append. + * @param mixed ...$having The restriction to append. * * @return static */ - public function andHaving($having) + public function andHaving(...$having) { - $args = func_get_args(); - $having = $this->getDQLPart('having'); + $dql = $this->getDQLPart('having'); - if ($having instanceof Expr\Andx) { - $having->addMultiple($args); + if ($dql instanceof Expr\Andx) { + $dql->addMultiple($having); } else { - array_unshift($args, $having); - $having = new Expr\Andx($args); + array_unshift($having, $dql); + $dql = new Expr\Andx($having); } - return $this->add('having', $having); + return $this->add('having', $dql); } /** * Adds a restriction over the groups of the query, forming a logical * disjunction with any existing having restrictions. * - * @param mixed $having The restriction to add. + * @param mixed ...$having The restriction to add. * * @return static */ - public function orHaving($having) + public function orHaving(...$having) { - $args = func_get_args(); - $having = $this->getDQLPart('having'); + $dql = $this->getDQLPart('having'); - if ($having instanceof Expr\Orx) { - $having->addMultiple($args); + if ($dql instanceof Expr\Orx) { + $dql->addMultiple($having); } else { - array_unshift($args, $having); - $having = new Expr\Orx($args); + array_unshift($having, $dql); + $dql = new Expr\Orx($having); } - return $this->add('having', $having); + return $this->add('having', $dql); } /** diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 38d4c8d2dd4..23d78128400 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1991,11 +1991,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$where$#" - count: 2 - path: lib/Doctrine/ORM/QueryBuilder.php - - message: "#^Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:add\\(\\) expects array\\<'join'\\|int, array\\\\|string\\>\\|object\\|string, array\\&nonEmpty given\\.$#" count: 2 From c6f8dc248276fb9a6b45c5fc4b49ceac5dfe7849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 3 Aug 2021 12:41:53 +0200 Subject: [PATCH 004/475] Change ->assert* to self::assert* --- .../Mapping/UnderscoreNamingStrategyTest.php | 2 +- .../Tests/ORM/Cache/AbstractRegionTest.php | 20 +- .../Tests/ORM/Cache/CacheConfigTest.php | 16 +- .../Doctrine/Tests/ORM/Cache/CacheKeyTest.php | 14 +- .../Tests/ORM/Cache/CacheLoggerChainTest.php | 44 +- .../ORM/Cache/DefaultCacheFactoryTest.php | 90 +- .../Tests/ORM/Cache/DefaultCacheTest.php | 64 +- .../Cache/DefaultCollectionHydratorTest.php | 32 +- .../ORM/Cache/DefaultEntityHydratorTest.php | 68 +- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 188 ++-- .../Tests/ORM/Cache/DefaultRegionTest.php | 32 +- .../Tests/ORM/Cache/FileLockRegionTest.php | 162 ++-- .../Tests/ORM/Cache/MultiGetRegionTest.php | 12 +- .../AbstractCollectionPersisterTest.php | 58 +- ...ReadWriteCachedCollectionPersisterTest.php | 114 +-- .../Entity/AbstractEntityPersisterTest.php | 184 ++-- ...rictReadWriteCachedEntityPersisterTest.php | 46 +- .../ReadWriteCachedEntityPersisterTest.php | 86 +- .../ORM/Cache/StatisticsCacheLoggerTest.php | 78 +- .../Tests/ORM/CommitOrderCalculatorTest.php | 6 +- .../Doctrine/Tests/ORM/ConfigurationTest.php | 116 +-- .../Decorator/EntityManagerDecoratorTest.php | 4 +- .../Tests/ORM/Entity/ConstructorTest.php | 2 +- .../Doctrine/Tests/ORM/EntityManagerTest.php | 58 +- .../Tests/ORM/EntityNotFoundExceptionTest.php | 12 +- .../OnClassMetadataNotFoundEventArgsTest.php | 10 +- .../AbstractManyToManyAssociationTestCase.php | 4 +- .../Functional/AdvancedAssociationTest.php | 30 +- .../ORM/Functional/AdvancedDqlQueryTest.php | 66 +- .../ORM/Functional/BasicFunctionalTest.php | 272 +++--- .../ClassTableInheritanceSecondTest.php | 16 +- .../Functional/ClassTableInheritanceTest.php | 134 +-- .../Tests/ORM/Functional/ClearEventTest.php | 2 +- .../Functional/CompositePrimaryKeyTest.php | 26 +- ...ompositePrimaryKeyWithAssociationsTest.php | 10 +- .../ORM/Functional/CustomFunctionsTest.php | 6 +- .../ORM/Functional/CustomIdObjectTypeTest.php | 10 +- .../ORM/Functional/DatabaseDriverTest.php | 104 +-- .../ORM/Functional/DatabaseDriverTestCase.php | 2 +- .../ORM/Functional/DefaultValuesTest.php | 14 +- .../ORM/Functional/DetachedEntityTest.php | 62 +- .../ORM/Functional/EntityListenersTest.php | 64 +- .../EntityRepositoryCriteriaTest.php | 30 +- .../ORM/Functional/EntityRepositoryTest.php | 220 ++--- .../Functional/ExtraLazyCollectionTest.php | 264 +++--- .../Tests/ORM/Functional/FlushEventTest.php | 18 +- .../ORM/Functional/HydrationCacheTest.php | 12 +- .../Tests/ORM/Functional/IdentityMapTest.php | 56 +- .../ORM/Functional/IndexByAssociationTest.php | 46 +- .../JoinedTableCompositeKeyTest.php | 4 +- .../ORM/Functional/LifecycleCallbackTest.php | 90 +- .../Functional/Locking/GearmanLockTest.php | 8 +- .../Tests/ORM/Functional/Locking/LockTest.php | 8 +- .../ORM/Functional/Locking/OptimisticTest.php | 34 +- .../ManyToManyBasicAssociationTest.php | 120 +-- ...ManyToManyBidirectionalAssociationTest.php | 96 +- .../ORM/Functional/ManyToManyEventTest.php | 4 +- ...nyToManySelfReferentialAssociationTest.php | 16 +- ...anyToManyUnidirectionalAssociationTest.php | 8 +- .../Functional/ManyToOneOrphanRemovalTest.php | 4 +- .../ORM/Functional/MappedSuperclassTest.php | 10 +- .../Functional/MergeCompositeToOneKeyTest.php | 8 +- .../Tests/ORM/Functional/MergeProxiesTest.php | 56 +- .../Functional/MergeSharedEntitiesTest.php | 10 +- .../MergeVersionedManyToOneTest.php | 2 +- .../Tests/ORM/Functional/NativeQueryTest.php | 278 +++--- .../Tests/ORM/Functional/NewOperatorTest.php | 620 ++++++------- .../Tests/ORM/Functional/NotifyPolicyTest.php | 28 +- .../OneToManyBidirectionalAssociationTest.php | 74 +- .../Functional/OneToManyOrphanRemovalTest.php | 12 +- ...neToManySelfReferentialAssociationTest.php | 30 +- ...OneToManyUnidirectionalAssociationTest.php | 8 +- .../OneToOneBidirectionalAssociationTest.php | 28 +- .../Functional/OneToOneEagerLoadingTest.php | 34 +- .../Functional/OneToOneOrphanRemovalTest.php | 6 +- ...OneToOneSelfReferentialAssociationTest.php | 20 +- .../OneToOneSingleTableInheritanceTest.php | 8 +- .../OneToOneUnidirectionalAssociationTest.php | 14 +- .../ORM/Functional/OrderedCollectionTest.php | 18 +- ...edJoinedTableInheritanceCollectionTest.php | 10 +- .../Tests/ORM/Functional/PaginationTest.php | 70 +- .../PersistentCollectionCriteriaTest.php | 16 +- .../Functional/PersistentCollectionTest.php | 18 +- .../ORM/Functional/PersistentObjectTest.php | 6 +- .../ORM/Functional/PostFlushEventTest.php | 8 +- .../ORM/Functional/PostLoadEventTest.php | 44 +- .../Functional/ProxiesLikeEntitiesTest.php | 22 +- .../QueryBuilderParenthesisTest.php | 8 +- .../Tests/ORM/Functional/QueryCacheTest.php | 32 +- .../ORM/Functional/QueryDqlFunctionTest.php | 228 ++--- .../ORM/Functional/QueryIterableTest.php | 4 +- .../Tests/ORM/Functional/QueryTest.php | 158 ++-- .../Tests/ORM/Functional/ReadOnlyTest.php | 14 +- .../ORM/Functional/ReferenceProxyTest.php | 68 +- .../Tests/ORM/Functional/ResultCacheTest.php | 64 +- .../Tests/ORM/Functional/SQLFilterTest.php | 326 +++---- .../SchemaTool/CompanySchemaTest.php | 22 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 2 +- .../ORM/Functional/SchemaTool/DDC214Test.php | 4 +- .../SchemaTool/MySqlSchemaToolTest.php | 46 +- .../SchemaTool/PostgreSqlSchemaToolTest.php | 72 +- .../ORM/Functional/SchemaValidatorTest.php | 2 +- ...econdLevelCacheCompositePrimaryKeyTest.php | 88 +- ...ompositePrimaryKeyWithAssociationsTest.php | 12 +- .../SecondLevelCacheConcurrentTest.php | 44 +- .../SecondLevelCacheCriteriaTest.php | 72 +- ...econdLevelCacheExtraLazyCollectionTest.php | 22 +- ...condLevelCacheJoinTableInheritanceTest.php | 116 +-- .../SecondLevelCacheManyToManyTest.php | 164 ++-- .../SecondLevelCacheManyToOneTest.php | 178 ++-- .../SecondLevelCacheOneToManyTest.php | 264 +++--- .../SecondLevelCacheOneToOneTest.php | 222 ++--- .../SecondLevelCacheQueryCacheTest.php | 822 +++++++++--------- .../SecondLevelCacheRepositoryTest.php | 160 ++-- ...ndLevelCacheSingleTableInheritanceTest.php | 128 +-- .../ORM/Functional/SecondLevelCacheTest.php | 198 ++--- .../SequenceEmulatedIdentityStrategyTest.php | 8 +- .../ORM/Functional/SequenceGeneratorTest.php | 2 +- .../SingleTableCompositeKeyTest.php | 4 +- .../Functional/SingleTableInheritanceTest.php | 94 +- .../StandardEntityPersisterTest.php | 16 +- .../ORM/Functional/Ticket/DDC1040Test.php | 4 +- .../ORM/Functional/Ticket/DDC1041Test.php | 6 +- .../ORM/Functional/Ticket/DDC1043Test.php | 2 +- .../ORM/Functional/Ticket/DDC1080Test.php | 2 +- .../ORM/Functional/Ticket/DDC1129Test.php | 8 +- .../ORM/Functional/Ticket/DDC1151Test.php | 20 +- .../ORM/Functional/Ticket/DDC1163Test.php | 8 +- .../ORM/Functional/Ticket/DDC117Test.php | 122 +-- .../ORM/Functional/Ticket/DDC1193Test.php | 8 +- .../ORM/Functional/Ticket/DDC1225Test.php | 2 +- .../ORM/Functional/Ticket/DDC1228Test.php | 12 +- .../ORM/Functional/Ticket/DDC1238Test.php | 4 +- .../ORM/Functional/Ticket/DDC1250Test.php | 2 +- .../ORM/Functional/Ticket/DDC1276Test.php | 6 +- .../ORM/Functional/Ticket/DDC1300Test.php | 2 +- .../ORM/Functional/Ticket/DDC1301Test.php | 24 +- .../ORM/Functional/Ticket/DDC1335Test.php | 94 +- .../ORM/Functional/Ticket/DDC1360Test.php | 4 +- .../ORM/Functional/Ticket/DDC1392Test.php | 4 +- .../ORM/Functional/Ticket/DDC1404Test.php | 12 +- .../ORM/Functional/Ticket/DDC142Test.php | 18 +- .../ORM/Functional/Ticket/DDC1430Test.php | 46 +- .../ORM/Functional/Ticket/DDC1436Test.php | 8 +- .../ORM/Functional/Ticket/DDC1452Test.php | 10 +- .../ORM/Functional/Ticket/DDC1458Test.php | 8 +- .../ORM/Functional/Ticket/DDC1461Test.php | 6 +- .../ORM/Functional/Ticket/DDC1509Test.php | 4 +- .../ORM/Functional/Ticket/DDC1514Test.php | 8 +- .../ORM/Functional/Ticket/DDC1515Test.php | 2 +- .../ORM/Functional/Ticket/DDC1526Test.php | 2 +- .../ORM/Functional/Ticket/DDC1545Test.php | 20 +- .../ORM/Functional/Ticket/DDC1548Test.php | 2 +- .../ORM/Functional/Ticket/DDC1594Test.php | 6 +- .../ORM/Functional/Ticket/DDC1595Test.php | 2 +- .../ORM/Functional/Ticket/DDC163Test.php | 6 +- .../ORM/Functional/Ticket/DDC1643Test.php | 16 +- .../ORM/Functional/Ticket/DDC1654Test.php | 10 +- .../ORM/Functional/Ticket/DDC1655Test.php | 22 +- .../ORM/Functional/Ticket/DDC1666Test.php | 4 +- .../ORM/Functional/Ticket/DDC1685Test.php | 8 +- .../ORM/Functional/Ticket/DDC168Test.php | 10 +- .../ORM/Functional/Ticket/DDC1690Test.php | 24 +- .../ORM/Functional/Ticket/DDC1695Test.php | 4 +- .../ORM/Functional/Ticket/DDC1707Test.php | 2 +- .../ORM/Functional/Ticket/DDC1719Test.php | 32 +- .../ORM/Functional/Ticket/DDC1734Test.php | 12 +- .../ORM/Functional/Ticket/DDC1778Test.php | 6 +- .../ORM/Functional/Ticket/DDC1787Test.php | 2 +- .../ORM/Functional/Ticket/DDC1843Test.php | 72 +- .../ORM/Functional/Ticket/DDC1884Test.php | 18 +- .../ORM/Functional/Ticket/DDC1885Test.php | 76 +- .../ORM/Functional/Ticket/DDC1918Test.php | 6 +- .../ORM/Functional/Ticket/DDC1995Test.php | 12 +- .../ORM/Functional/Ticket/DDC1998Test.php | 6 +- .../ORM/Functional/Ticket/DDC199Test.php | 12 +- .../ORM/Functional/Ticket/DDC2012Test.php | 26 +- .../ORM/Functional/Ticket/DDC2074Test.php | 8 +- .../ORM/Functional/Ticket/DDC2084Test.php | 6 +- .../ORM/Functional/Ticket/DDC2090Test.php | 16 +- .../ORM/Functional/Ticket/DDC211Test.php | 2 +- .../ORM/Functional/Ticket/DDC2138Test.php | 14 +- .../ORM/Functional/Ticket/DDC2175Test.php | 6 +- .../ORM/Functional/Ticket/DDC2182Test.php | 8 +- .../ORM/Functional/Ticket/DDC2214Test.php | 2 +- .../ORM/Functional/Ticket/DDC2224Test.php | 4 +- .../ORM/Functional/Ticket/DDC2230Test.php | 10 +- .../ORM/Functional/Ticket/DDC2231Test.php | 8 +- .../ORM/Functional/Ticket/DDC2252Test.php | 16 +- .../ORM/Functional/Ticket/DDC2306Test.php | 8 +- .../ORM/Functional/Ticket/DDC2346Test.php | 4 +- .../ORM/Functional/Ticket/DDC2350Test.php | 6 +- .../ORM/Functional/Ticket/DDC2359Test.php | 18 +- .../ORM/Functional/Ticket/DDC237Test.php | 20 +- .../ORM/Functional/Ticket/DDC2387Test.php | 4 +- .../ORM/Functional/Ticket/DDC2409Test.php | 24 +- .../ORM/Functional/Ticket/DDC2415Test.php | 10 +- .../ORM/Functional/Ticket/DDC2494Test.php | 32 +- .../ORM/Functional/Ticket/DDC2519Test.php | 46 +- .../ORM/Functional/Ticket/DDC2575Test.php | 26 +- .../ORM/Functional/Ticket/DDC2579Test.php | 8 +- .../ORM/Functional/Ticket/DDC258Test.php | 26 +- .../ORM/Functional/Ticket/DDC2645Test.php | 4 +- .../ORM/Functional/Ticket/DDC2655Test.php | 2 +- .../ORM/Functional/Ticket/DDC2660Test.php | 12 +- .../ORM/Functional/Ticket/DDC2692Test.php | 2 +- .../ORM/Functional/Ticket/DDC2759Test.php | 2 +- .../ORM/Functional/Ticket/DDC2780Test.php | 2 +- .../ORM/Functional/Ticket/DDC2790Test.php | 2 +- .../ORM/Functional/Ticket/DDC279Test.php | 6 +- .../ORM/Functional/Ticket/DDC2825Test.php | 12 +- .../ORM/Functional/Ticket/DDC2862Test.php | 58 +- .../ORM/Functional/Ticket/DDC2895Test.php | 4 +- .../ORM/Functional/Ticket/DDC2931Test.php | 10 +- .../ORM/Functional/Ticket/DDC2943Test.php | 24 +- .../ORM/Functional/Ticket/DDC2984Test.php | 6 +- .../ORM/Functional/Ticket/DDC2996Test.php | 4 +- .../ORM/Functional/Ticket/DDC3033Test.php | 2 +- .../ORM/Functional/Ticket/DDC3042Test.php | 2 +- .../ORM/Functional/Ticket/DDC3068Test.php | 6 +- .../ORM/Functional/Ticket/DDC309Test.php | 8 +- .../ORM/Functional/Ticket/DDC3103Test.php | 4 +- .../ORM/Functional/Ticket/DDC3123Test.php | 4 +- .../ORM/Functional/Ticket/DDC3160Test.php | 6 +- .../ORM/Functional/Ticket/DDC3192Test.php | 6 +- .../ORM/Functional/Ticket/DDC3223Test.php | 2 +- .../ORM/Functional/Ticket/DDC3300Test.php | 4 +- .../ORM/Functional/Ticket/DDC331Test.php | 2 +- .../ORM/Functional/Ticket/DDC3330Test.php | 2 +- .../ORM/Functional/Ticket/DDC3346Test.php | 10 +- .../ORM/Functional/Ticket/DDC345Test.php | 6 +- .../ORM/Functional/Ticket/DDC353Test.php | 10 +- .../ORM/Functional/Ticket/DDC3582Test.php | 6 +- .../ORM/Functional/Ticket/DDC3597Test.php | 4 +- .../ORM/Functional/Ticket/DDC3634Test.php | 8 +- .../ORM/Functional/Ticket/DDC3644Test.php | 8 +- .../ORM/Functional/Ticket/DDC3699Test.php | 8 +- .../ORM/Functional/Ticket/DDC3711Test.php | 4 +- .../ORM/Functional/Ticket/DDC3719Test.php | 4 +- .../ORM/Functional/Ticket/DDC371Test.php | 8 +- .../ORM/Functional/Ticket/DDC381Test.php | 2 +- .../ORM/Functional/Ticket/DDC3967Test.php | 2 +- .../ORM/Functional/Ticket/DDC4003Test.php | 2 +- .../ORM/Functional/Ticket/DDC422Test.php | 10 +- .../ORM/Functional/Ticket/DDC425Test.php | 2 +- .../ORM/Functional/Ticket/DDC440Test.php | 8 +- .../ORM/Functional/Ticket/DDC444Test.php | 6 +- .../ORM/Functional/Ticket/DDC448Test.php | 2 +- .../ORM/Functional/Ticket/DDC493Test.php | 2 +- .../ORM/Functional/Ticket/DDC501Test.php | 28 +- .../ORM/Functional/Ticket/DDC512Test.php | 16 +- .../ORM/Functional/Ticket/DDC513Test.php | 2 +- .../ORM/Functional/Ticket/DDC518Test.php | 2 +- .../ORM/Functional/Ticket/DDC522Test.php | 14 +- .../ORM/Functional/Ticket/DDC531Test.php | 10 +- .../ORM/Functional/Ticket/DDC5684Test.php | 6 +- .../ORM/Functional/Ticket/DDC599Test.php | 12 +- .../ORM/Functional/Ticket/DDC618Test.php | 46 +- .../ORM/Functional/Ticket/DDC633Test.php | 8 +- .../ORM/Functional/Ticket/DDC6460Test.php | 12 +- .../ORM/Functional/Ticket/DDC656Test.php | 6 +- .../ORM/Functional/Ticket/DDC657Test.php | 62 +- .../ORM/Functional/Ticket/DDC698Test.php | 2 +- .../Tests/ORM/Functional/Ticket/DDC69Test.php | 8 +- .../ORM/Functional/Ticket/DDC719Test.php | 2 +- .../ORM/Functional/Ticket/DDC729Test.php | 16 +- .../ORM/Functional/Ticket/DDC735Test.php | 8 +- .../ORM/Functional/Ticket/DDC736Test.php | 10 +- .../ORM/Functional/Ticket/DDC742Test.php | 2 +- .../ORM/Functional/Ticket/DDC748Test.php | 10 +- .../ORM/Functional/Ticket/DDC758Test.php | 32 +- .../ORM/Functional/Ticket/DDC767Test.php | 2 +- .../ORM/Functional/Ticket/DDC7969Test.php | 8 +- .../ORM/Functional/Ticket/DDC809Test.php | 4 +- .../ORM/Functional/Ticket/DDC812Test.php | 4 +- .../ORM/Functional/Ticket/DDC832Test.php | 2 +- .../ORM/Functional/Ticket/DDC837Test.php | 40 +- .../ORM/Functional/Ticket/DDC849Test.php | 22 +- .../ORM/Functional/Ticket/DDC881Test.php | 12 +- .../ORM/Functional/Ticket/DDC949Test.php | 8 +- .../ORM/Functional/Ticket/DDC960Test.php | 2 +- .../ORM/Functional/Ticket/DDC992Test.php | 14 +- .../ORM/Functional/Ticket/GH5887Test.php | 2 +- .../ORM/Functional/Ticket/GH6362Test.php | 4 +- .../ORM/Functional/Ticket/GH6464Test.php | 4 +- .../Ticket/GH7496WithToIterableTest.php | 16 +- .../ORM/Functional/Ticket/GH7684Test.php | 4 +- .../ORM/Functional/Ticket/GH7829Test.php | 4 +- .../ORM/Functional/Ticket/GH7864Test.php | 2 +- .../ORM/Functional/Ticket/GH7869Test.php | 2 +- .../ORM/Functional/Ticket/Issue5989Test.php | 4 +- .../ORM/Functional/Ticket/Ticket2481Test.php | 2 +- .../Tests/ORM/Functional/TypeTest.php | 34 +- .../Tests/ORM/Functional/TypeValueSqlTest.php | 30 +- .../ORM/Functional/UUIDGeneratorTest.php | 6 +- .../ManyToManyCompositeIdForeignKeyTest.php | 36 +- .../ManyToManyCompositeIdTest.php | 28 +- .../ManyToManyExtraLazyTest.php | 16 +- .../ValueConversionType/ManyToManyTest.php | 22 +- .../OneToManyCompositeIdForeignKeyTest.php | 34 +- .../OneToManyCompositeIdTest.php | 24 +- .../OneToManyExtraLazyTest.php | 8 +- .../ValueConversionType/OneToManyTest.php | 18 +- .../OneToOneCompositeIdForeignKeyTest.php | 32 +- .../OneToOneCompositeIdTest.php | 24 +- .../ValueConversionType/OneToOneTest.php | 18 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 112 +-- .../ORM/Functional/VersionedOneToOneTest.php | 6 +- .../Tests/ORM/Hydration/ArrayHydratorTest.php | 418 ++++----- .../ORM/Hydration/CustomHydratorTest.php | 4 +- .../ORM/Hydration/ObjectHydratorTest.php | 566 ++++++------ .../ORM/Hydration/ResultSetMappingTest.php | 104 +-- .../ORM/Hydration/ScalarHydratorTest.php | 12 +- .../Hydration/SimpleObjectHydratorTest.php | 6 +- .../Hydration/SingleScalarHydratorTest.php | 4 +- .../Tests/ORM/Id/AssignedGeneratorTest.php | 4 +- .../Internal/HydrationCompleteHandlerTest.php | 34 +- .../Tests/ORM/LazyCriteriaCollectionTest.php | 54 +- .../ORM/Mapping/AbstractMappingDriverTest.php | 716 +++++++-------- .../ORM/Mapping/AnnotationDriverTest.php | 26 +- .../ORM/Mapping/AnsiQuoteStrategyTest.php | 18 +- .../Tests/ORM/Mapping/AttributeDriverTest.php | 28 +- .../Mapping/BasicInheritanceMappingTest.php | 84 +- .../ORM/Mapping/ClassMetadataBuilderTest.php | 86 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 142 +-- .../Mapping/ClassMetadataLoadEventTest.php | 6 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 226 ++--- .../ORM/Mapping/DefaultQuoteStrategyTest.php | 2 +- .../Mapping/EntityListenerResolverTest.php | 38 +- .../Tests/ORM/Mapping/FieldBuilderTest.php | 4 +- .../Tests/ORM/Mapping/QuoteStrategyTest.php | 38 +- .../ReflectionPropertiesGetterTest.php | 36 +- .../ReflectionEmbeddedPropertyTest.php | 6 +- .../Mapping/StaticPHPMappingDriverTest.php | 4 +- .../Mapping/Symfony/AbstractDriverTest.php | 4 +- .../ORM/Mapping/XmlMappingDriverTest.php | 24 +- .../ORM/Mapping/YamlMappingDriverTest.php | 18 +- .../ORM/Performance/SecondLevelCacheTest.php | 18 +- .../Tests/ORM/PersistentCollectionTest.php | 26 +- ...tyPersisterCompositeTypeParametersTest.php | 8 +- ...sicEntityPersisterCompositeTypeSqlTest.php | 6 +- .../BasicEntityPersisterTypeValueSqlTest.php | 26 +- .../JoinedSubclassPersisterTest.php | 2 +- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 34 +- .../ORM/Query/CustomTreeWalkersJoinTest.php | 4 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 4 +- .../ORM/Query/DeleteSqlGenerationTest.php | 2 +- tests/Doctrine/Tests/ORM/Query/ExprTest.php | 156 ++-- .../Tests/ORM/Query/FilterCollectionTest.php | 18 +- .../ORM/Query/LanguageRecognitionTest.php | 4 +- tests/Doctrine/Tests/ORM/Query/LexerTest.php | 68 +- .../ORM/Query/ParameterTypeInfererTest.php | 2 +- .../Tests/ORM/Query/ParserResultTest.php | 12 +- tests/Doctrine/Tests/ORM/Query/ParserTest.php | 10 +- .../ORM/Query/QueryExpressionVisitorTest.php | 16 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 46 +- .../ORM/Query/SelectSqlGenerationTest.php | 28 +- .../Tests/ORM/Query/SqlWalkerTest.php | 4 +- .../ORM/Query/UpdateSqlGenerationTest.php | 2 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 194 ++--- .../DefaultRepositoryFactoryTest.php | 42 +- .../AttachEntityListenersListenerTest.php | 32 +- .../ConvertDoctrine1SchemaCommandTest.php | 4 +- .../EnsureProductionSettingsCommandTest.php | 24 +- .../ORM/Tools/Console/MetadataFilterTest.php | 62 +- .../ORM/Tools/ConvertDoctrine1SchemaTest.php | 28 +- .../Tests/ORM/Tools/EntityGeneratorTest.php | 384 ++++---- .../Tools/EntityRepositoryGeneratorTest.php | 36 +- .../AbstractClassMetadataExporterTest.php | 200 ++--- .../Export/XmlClassMetadataExporterTest.php | 4 +- .../Export/YamlClassMetadataExporterTest.php | 2 +- .../Pagination/CountOutputWalkerTest.php | 12 +- .../ORM/Tools/Pagination/CountWalkerTest.php | 12 +- .../LimitSubqueryOutputWalkerTest.php | 12 +- .../Pagination/LimitSubqueryWalkerTest.php | 12 +- .../ORM/Tools/Pagination/PaginatorTest.php | 14 +- .../Tools/Pagination/WhereInWalkerTest.php | 20 +- .../Tools/ResolveTargetEntityListenerTest.php | 18 +- .../Tests/ORM/Tools/SchemaToolTest.php | 36 +- .../Tests/ORM/Tools/SchemaValidatorTest.php | 18 +- tests/Doctrine/Tests/ORM/Tools/SetupTest.php | 42 +- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 106 +-- .../HierarchyDiscriminatorResolverTest.php | 14 +- .../ORM/Utility/IdentifierFlattenerTest.php | 32 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 2 +- .../Doctrine/Tests/OrmPerformanceTestCase.php | 2 +- 386 files changed, 7756 insertions(+), 7756 deletions(-) diff --git a/tests/Doctrine/Tests/Mapping/UnderscoreNamingStrategyTest.php b/tests/Doctrine/Tests/Mapping/UnderscoreNamingStrategyTest.php index 6b8f81ff4fa..e585ff01582 100644 --- a/tests/Doctrine/Tests/Mapping/UnderscoreNamingStrategyTest.php +++ b/tests/Doctrine/Tests/Mapping/UnderscoreNamingStrategyTest.php @@ -32,6 +32,6 @@ public function checkNoDeprecationMessageWhenNumberAwareEnabled(): void $after = Deprecation::getTriggeredDeprecations()['https://github.com/doctrine/orm/pull/7908'] ?? 0; - $this->assertSame($before, $after); + self::assertSame($before, $after); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php index 41a25befe49..4e357d24862 100644 --- a/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php @@ -46,19 +46,19 @@ public static function dataProviderCacheValues(): array */ public function testPutGetContainsEvict($key, $value): void { - $this->assertFalse($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); $this->region->put($key, $value); - $this->assertTrue($this->region->contains($key)); + self::assertTrue($this->region->contains($key)); $actual = $this->region->get($key); - $this->assertEquals($value, $actual); + self::assertEquals($value, $actual); $this->region->evict($key); - $this->assertFalse($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); } public function testEvictAll(): void @@ -66,18 +66,18 @@ public function testEvictAll(): void $key1 = new CacheKeyMock('key.1'); $key2 = new CacheKeyMock('key.2'); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); $this->region->put($key1, new CacheEntryMock(['value' => 'foo'])); $this->region->put($key2, new CacheEntryMock(['value' => 'bar'])); - $this->assertTrue($this->region->contains($key1)); - $this->assertTrue($this->region->contains($key2)); + self::assertTrue($this->region->contains($key1)); + self::assertTrue($this->region->contains($key2)); $this->region->evictAll(); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php index d160e544553..041da75629a 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php @@ -34,33 +34,33 @@ public function testSetGetRegionLifetime(): void $config->setDefaultLifetime(111); - $this->assertEquals($config->getDefaultLifetime(), $config->getLifetime('foo_region')); + self::assertEquals($config->getDefaultLifetime(), $config->getLifetime('foo_region')); $config->setLifetime('foo_region', 222); - $this->assertEquals(222, $config->getLifetime('foo_region')); + self::assertEquals(222, $config->getLifetime('foo_region')); } public function testSetGetCacheLogger(): void { $logger = $this->createMock(CacheLogger::class); - $this->assertNull($this->config->getCacheLogger()); + self::assertNull($this->config->getCacheLogger()); $this->config->setCacheLogger($logger); - $this->assertEquals($logger, $this->config->getCacheLogger()); + self::assertEquals($logger, $this->config->getCacheLogger()); } public function testSetGetCacheFactory(): void { $factory = $this->createMock(CacheFactory::class); - $this->assertNull($this->config->getCacheFactory()); + self::assertNull($this->config->getCacheFactory()); $this->config->setCacheFactory($factory); - $this->assertEquals($factory, $this->config->getCacheFactory()); + self::assertEquals($factory, $this->config->getCacheFactory()); } public function testSetGetQueryValidator(): void @@ -72,10 +72,10 @@ public function testSetGetQueryValidator(): void $validator = $this->createMock(QueryCacheValidator::class); - $this->assertInstanceOf(TimestampQueryCacheValidator::class, $this->config->getQueryValidator()); + self::assertInstanceOf(TimestampQueryCacheValidator::class, $this->config->getQueryValidator()); $this->config->setQueryValidator($validator); - $this->assertEquals($validator, $this->config->getQueryValidator()); + self::assertEquals($validator, $this->config->getQueryValidator()); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php index 7e30ca5aa74..90c576ac4d7 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php @@ -18,7 +18,7 @@ public function testEntityCacheKeyIdentifierCollision(): void $key1 = new EntityCacheKey('Foo', ['id' => 1]); $key2 = new EntityCacheKey('Bar', ['id' => 1]); - $this->assertNotEquals($key1->hash, $key2->hash); + self::assertNotEquals($key1->hash, $key2->hash); } public function testEntityCacheKeyIdentifierType(): void @@ -26,7 +26,7 @@ public function testEntityCacheKeyIdentifierType(): void $key1 = new EntityCacheKey('Foo', ['id' => 1]); $key2 = new EntityCacheKey('Foo', ['id' => '1']); - $this->assertEquals($key1->hash, $key2->hash); + self::assertEquals($key1->hash, $key2->hash); } public function testEntityCacheKeyIdentifierOrder(): void @@ -34,7 +34,7 @@ public function testEntityCacheKeyIdentifierOrder(): void $key1 = new EntityCacheKey('Foo', ['foo_bar' => 1, 'bar_foo' => 2]); $key2 = new EntityCacheKey('Foo', ['bar_foo' => 2, 'foo_bar' => 1]); - $this->assertEquals($key1->hash, $key2->hash); + self::assertEquals($key1->hash, $key2->hash); } public function testCollectionCacheKeyIdentifierType(): void @@ -42,7 +42,7 @@ public function testCollectionCacheKeyIdentifierType(): void $key1 = new CollectionCacheKey('Foo', 'assoc', ['id' => 1]); $key2 = new CollectionCacheKey('Foo', 'assoc', ['id' => '1']); - $this->assertEquals($key1->hash, $key2->hash); + self::assertEquals($key1->hash, $key2->hash); } public function testCollectionCacheKeyIdentifierOrder(): void @@ -50,7 +50,7 @@ public function testCollectionCacheKeyIdentifierOrder(): void $key1 = new CollectionCacheKey('Foo', 'assoc', ['foo_bar' => 1, 'bar_foo' => 2]); $key2 = new CollectionCacheKey('Foo', 'assoc', ['bar_foo' => 2, 'foo_bar' => 1]); - $this->assertEquals($key1->hash, $key2->hash); + self::assertEquals($key1->hash, $key2->hash); } public function testCollectionCacheKeyIdentifierCollision(): void @@ -58,7 +58,7 @@ public function testCollectionCacheKeyIdentifierCollision(): void $key1 = new CollectionCacheKey('Foo', 'assoc', ['id' => 1]); $key2 = new CollectionCacheKey('Bar', 'assoc', ['id' => 1]); - $this->assertNotEquals($key1->hash, $key2->hash); + self::assertNotEquals($key1->hash, $key2->hash); } public function testCollectionCacheKeyAssociationCollision(): void @@ -66,6 +66,6 @@ public function testCollectionCacheKeyAssociationCollision(): void $key1 = new CollectionCacheKey('Foo', 'assoc1', ['id' => 1]); $key2 = new CollectionCacheKey('Foo', 'assoc2', ['id' => 1]); - $this->assertNotEquals($key1->hash, $key2->hash); + self::assertNotEquals($key1->hash, $key2->hash); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index 42d21819164..3ee350e15a0 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -34,14 +34,14 @@ protected function setUp(): void public function testGetAndSetLogger(): void { - $this->assertEmpty($this->logger->getLoggers()); + self::assertEmpty($this->logger->getLoggers()); - $this->assertNull($this->logger->getLogger('mock')); + self::assertNull($this->logger->getLogger('mock')); $this->logger->setLogger('mock', $this->mock); - $this->assertSame($this->mock, $this->logger->getLogger('mock')); - $this->assertEquals(['mock' => $this->mock], $this->logger->getLoggers()); + self::assertSame($this->mock, $this->logger->getLogger('mock')); + self::assertEquals(['mock' => $this->mock], $this->logger->getLoggers()); } public function testEntityCacheChain(): void @@ -51,17 +51,17 @@ public function testEntityCacheChain(): void $this->logger->setLogger('mock', $this->mock); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('entityCacheHit') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('entityCachePut') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('entityCacheMiss') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); $this->logger->entityCacheHit($name, $key); $this->logger->entityCachePut($name, $key); @@ -75,17 +75,17 @@ public function testCollectionCacheChain(): void $this->logger->setLogger('mock', $this->mock); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('collectionCacheHit') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('collectionCachePut') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('collectionCacheMiss') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); $this->logger->collectionCacheHit($name, $key); $this->logger->collectionCachePut($name, $key); @@ -99,17 +99,17 @@ public function testQueryCacheChain(): void $this->logger->setLogger('mock', $this->mock); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('queryCacheHit') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('queryCachePut') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); - $this->mock->expects($this->once()) + $this->mock->expects(self::once()) ->method('queryCacheMiss') - ->with($this->equalTo($name), $this->equalTo($key)); + ->with(self::equalTo($name), self::equalTo($key)); $this->logger->queryCacheHit($name, $key); $this->logger->queryCachePut($name, $key); diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 8dfd025206c..accad3ce3f3 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -64,7 +64,7 @@ protected function setUp(): void public function testImplementsCacheFactory(): void { - $this->assertInstanceOf(CacheFactory::class, $this->factory); + self::assertInstanceOf(CacheFactory::class, $this->factory); } public function testBuildCachedEntityPersisterReadOnly(): void @@ -76,15 +76,15 @@ public function testBuildCachedEntityPersisterReadOnly(): void $metadata->cache['usage'] = ClassMetadata::CACHE_USAGE_READ_ONLY; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($metadata->cache)) - ->will($this->returnValue($region)); + ->with(self::equalTo($metadata->cache)) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister); - $this->assertInstanceOf(ReadOnlyCachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(ReadOnlyCachedEntityPersister::class, $cachedPersister); } public function testBuildCachedEntityPersisterReadWrite(): void @@ -96,15 +96,15 @@ public function testBuildCachedEntityPersisterReadWrite(): void $metadata->cache['usage'] = ClassMetadata::CACHE_USAGE_READ_WRITE; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($metadata->cache)) - ->will($this->returnValue($region)); + ->with(self::equalTo($metadata->cache)) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister); - $this->assertInstanceOf(ReadWriteCachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(ReadWriteCachedEntityPersister::class, $cachedPersister); } public function testBuildCachedEntityPersisterNonStrictReadWrite(): void @@ -116,15 +116,15 @@ public function testBuildCachedEntityPersisterNonStrictReadWrite(): void $metadata->cache['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($metadata->cache)) - ->will($this->returnValue($region)); + ->with(self::equalTo($metadata->cache)) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister); - $this->assertInstanceOf(NonStrictReadWriteCachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister); + self::assertInstanceOf(NonStrictReadWriteCachedEntityPersister::class, $cachedPersister); } public function testBuildCachedCollectionPersisterReadOnly(): void @@ -137,15 +137,15 @@ public function testBuildCachedCollectionPersisterReadOnly(): void $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_READ_ONLY; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($mapping['cache'])) - ->will($this->returnValue($region)); + ->with(self::equalTo($mapping['cache'])) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); - $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); - $this->assertInstanceOf(ReadOnlyCachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(ReadOnlyCachedCollectionPersister::class, $cachedPersister); } public function testBuildCachedCollectionPersisterReadWrite(): void @@ -158,15 +158,15 @@ public function testBuildCachedCollectionPersisterReadWrite(): void $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_READ_WRITE; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($mapping['cache'])) - ->will($this->returnValue($region)); + ->with(self::equalTo($mapping['cache'])) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); - $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); - $this->assertInstanceOf(ReadWriteCachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(ReadWriteCachedCollectionPersister::class, $cachedPersister); } public function testBuildCachedCollectionPersisterNonStrictReadWrite(): void @@ -179,15 +179,15 @@ public function testBuildCachedCollectionPersisterNonStrictReadWrite(): void $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE; - $this->factory->expects($this->once()) + $this->factory->expects(self::once()) ->method('getRegion') - ->with($this->equalTo($mapping['cache'])) - ->will($this->returnValue($region)); + ->with(self::equalTo($mapping['cache'])) + ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); - $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); - $this->assertInstanceOf(NonStrictReadWriteCachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(CachedCollectionPersister::class, $cachedPersister); + self::assertInstanceOf(NonStrictReadWriteCachedCollectionPersister::class, $cachedPersister); } public function testInheritedEntityCacheRegion(): void @@ -202,11 +202,11 @@ public function testInheritedEntityCacheRegion(): void $cachedPersister1 = $factory->buildCachedEntityPersister($em, $persister1, $metadata1); $cachedPersister2 = $factory->buildCachedEntityPersister($em, $persister2, $metadata2); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister1); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister2); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister1); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister2); - $this->assertNotSame($cachedPersister1, $cachedPersister2); - $this->assertSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); + self::assertNotSame($cachedPersister1, $cachedPersister2); + self::assertSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); } public function testCreateNewCacheDriver(): void @@ -221,11 +221,11 @@ public function testCreateNewCacheDriver(): void $cachedPersister1 = $factory->buildCachedEntityPersister($em, $persister1, $metadata1); $cachedPersister2 = $factory->buildCachedEntityPersister($em, $persister2, $metadata2); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister1); - $this->assertInstanceOf(CachedEntityPersister::class, $cachedPersister2); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister1); + self::assertInstanceOf(CachedEntityPersister::class, $cachedPersister2); - $this->assertNotSame($cachedPersister1, $cachedPersister2); - $this->assertNotSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); + self::assertNotSame($cachedPersister1, $cachedPersister2); + self::assertNotSame($cachedPersister1->getCacheRegion(), $cachedPersister2->getCacheRegion()); } public function testBuildCachedEntityPersisterNonStrictException(): void @@ -314,8 +314,8 @@ public function testBuildsNewNamespacedCacheInstancePerRegionInstance(): void ] ); - $this->assertSame('foo', $fooRegion->getCache()->getNamespace()); - $this->assertSame('bar', $barRegion->getCache()->getNamespace()); + self::assertSame('foo', $fooRegion->getCache()->getNamespace()); + self::assertSame('bar', $barRegion->getCache()->getNamespace()); } public function testAppendsNamespacedCacheInstancePerRegionInstanceWhenItsAlreadySet(): void @@ -338,8 +338,8 @@ public function testAppendsNamespacedCacheInstancePerRegionInstanceWhenItsAlread ] ); - $this->assertSame('testing:foo', $fooRegion->getCache()->getNamespace()); - $this->assertSame('testing:bar', $barRegion->getCache()->getNamespace()); + self::assertSame('testing:foo', $fooRegion->getCache()->getNamespace()); + self::assertSame('testing:bar', $barRegion->getCache()->getNamespace()); } public function testBuildsDefaultCacheRegionFromGenericCacheRegion(): void @@ -349,7 +349,7 @@ public function testBuildsDefaultCacheRegionFromGenericCacheRegion(): void $factory = new DefaultCacheFactory($this->regionsConfig, $cache); - $this->assertInstanceOf( + self::assertInstanceOf( DefaultRegion::class, $factory->getRegion( [ @@ -367,7 +367,7 @@ public function testBuildsMultiGetCacheRegionFromGenericCacheRegion(): void $factory = new DefaultCacheFactory($this->regionsConfig, $cache); - $this->assertInstanceOf( + self::assertInstanceOf( DefaultMultiGetRegion::class, $factory->getRegion( [ diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index 5a8b509e744..3fc8a2b2422 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -62,19 +62,19 @@ private function putCollectionCacheEntry(string $className, string $association, public function testImplementsCache(): void { - $this->assertInstanceOf(Cache::class, $this->cache); + self::assertInstanceOf(Cache::class, $this->cache); } public function testGetEntityCacheRegionAccess(): void { - $this->assertInstanceOf(Cache\Region::class, $this->cache->getEntityCacheRegion(State::class)); - $this->assertNull($this->cache->getEntityCacheRegion(CmsUser::class)); + self::assertInstanceOf(Cache\Region::class, $this->cache->getEntityCacheRegion(State::class)); + self::assertNull($this->cache->getEntityCacheRegion(CmsUser::class)); } public function testGetCollectionCacheRegionAccess(): void { - $this->assertInstanceOf(Cache\Region::class, $this->cache->getCollectionCacheRegion(State::class, 'cities')); - $this->assertNull($this->cache->getCollectionCacheRegion(CmsUser::class, 'phonenumbers')); + self::assertInstanceOf(Cache\Region::class, $this->cache->getCollectionCacheRegion(State::class, 'cities')); + self::assertNull($this->cache->getCollectionCacheRegion(CmsUser::class, 'phonenumbers')); } public function testContainsEntity(): void @@ -83,12 +83,12 @@ public function testContainsEntity(): void $className = Country::class; $cacheEntry = array_merge($identifier, ['name' => 'Brazil']); - $this->assertFalse($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(Country::class, 1)); $this->putEntityCacheEntry($className, $identifier, $cacheEntry); - $this->assertTrue($this->cache->containsEntity(Country::class, 1)); - $this->assertFalse($this->cache->containsEntity(CmsUser::class, 1)); + self::assertTrue($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(CmsUser::class, 1)); } public function testEvictEntity(): void @@ -99,12 +99,12 @@ public function testEvictEntity(): void $this->putEntityCacheEntry($className, $identifier, $cacheEntry); - $this->assertTrue($this->cache->containsEntity(Country::class, 1)); + self::assertTrue($this->cache->containsEntity(Country::class, 1)); $this->cache->evictEntity(Country::class, 1); $this->cache->evictEntity(CmsUser::class, 1); - $this->assertFalse($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(Country::class, 1)); } public function testEvictEntityRegion(): void @@ -115,12 +115,12 @@ public function testEvictEntityRegion(): void $this->putEntityCacheEntry($className, $identifier, $cacheEntry); - $this->assertTrue($this->cache->containsEntity(Country::class, 1)); + self::assertTrue($this->cache->containsEntity(Country::class, 1)); $this->cache->evictEntityRegion(Country::class); $this->cache->evictEntityRegion(CmsUser::class); - $this->assertFalse($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(Country::class, 1)); } public function testEvictEntityRegions(): void @@ -131,11 +131,11 @@ public function testEvictEntityRegions(): void $this->putEntityCacheEntry($className, $identifier, $cacheEntry); - $this->assertTrue($this->cache->containsEntity(Country::class, 1)); + self::assertTrue($this->cache->containsEntity(Country::class, 1)); $this->cache->evictEntityRegions(); - $this->assertFalse($this->cache->containsEntity(Country::class, 1)); + self::assertFalse($this->cache->containsEntity(Country::class, 1)); } public function testContainsCollection(): void @@ -148,12 +148,12 @@ public function testContainsCollection(): void ['id' => 12], ]; - $this->assertFalse($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(State::class, $association, 1)); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); - $this->assertTrue($this->cache->containsCollection(State::class, $association, 1)); - $this->assertFalse($this->cache->containsCollection(CmsUser::class, 'phonenumbers', 1)); + self::assertTrue($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(CmsUser::class, 'phonenumbers', 1)); } public function testEvictCollection(): void @@ -168,12 +168,12 @@ public function testEvictCollection(): void $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); - $this->assertTrue($this->cache->containsCollection(State::class, $association, 1)); + self::assertTrue($this->cache->containsCollection(State::class, $association, 1)); $this->cache->evictCollection($className, $association, $ownerId); $this->cache->evictCollection(CmsUser::class, 'phonenumbers', 1); - $this->assertFalse($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(State::class, $association, 1)); } public function testEvictCollectionRegion(): void @@ -188,12 +188,12 @@ public function testEvictCollectionRegion(): void $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); - $this->assertTrue($this->cache->containsCollection(State::class, $association, 1)); + self::assertTrue($this->cache->containsCollection(State::class, $association, 1)); $this->cache->evictCollectionRegion($className, $association); $this->cache->evictCollectionRegion(CmsUser::class, 'phonenumbers'); - $this->assertFalse($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(State::class, $association, 1)); } public function testEvictCollectionRegions(): void @@ -208,33 +208,33 @@ public function testEvictCollectionRegions(): void $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); - $this->assertTrue($this->cache->containsCollection(State::class, $association, 1)); + self::assertTrue($this->cache->containsCollection(State::class, $association, 1)); $this->cache->evictCollectionRegions(); - $this->assertFalse($this->cache->containsCollection(State::class, $association, 1)); + self::assertFalse($this->cache->containsCollection(State::class, $association, 1)); } public function testQueryCache(): void { - $this->assertFalse($this->cache->containsQuery('foo')); + self::assertFalse($this->cache->containsQuery('foo')); $defaultQueryCache = $this->cache->getQueryCache(); $fooQueryCache = $this->cache->getQueryCache('foo'); - $this->assertInstanceOf(Cache\QueryCache::class, $defaultQueryCache); - $this->assertInstanceOf(Cache\QueryCache::class, $fooQueryCache); - $this->assertSame($defaultQueryCache, $this->cache->getQueryCache()); - $this->assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); + self::assertInstanceOf(Cache\QueryCache::class, $defaultQueryCache); + self::assertInstanceOf(Cache\QueryCache::class, $fooQueryCache); + self::assertSame($defaultQueryCache, $this->cache->getQueryCache()); + self::assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); $this->cache->evictQueryRegion(); $this->cache->evictQueryRegion('foo'); $this->cache->evictQueryRegions(); - $this->assertTrue($this->cache->containsQuery('foo')); + self::assertTrue($this->cache->containsQuery('foo')); - $this->assertSame($defaultQueryCache, $this->cache->getQueryCache()); - $this->assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); + self::assertSame($defaultQueryCache, $this->cache->getQueryCache()); + self::assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); } public function testToIdentifierArrayShouldLookupForEntityIdentifier(): void @@ -249,6 +249,6 @@ public function testToIdentifierArrayShouldLookupForEntityIdentifier(): void $method->setAccessible(true); $property->setValue($entity, $identifier); - $this->assertEquals(['id' => $identifier], $method->invoke($this->cache, $metadata, $identifier)); + self::assertEquals(['id' => $identifier], $method->invoke($this->cache, $metadata, $identifier)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php index 164dd09c599..4c366f280be 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php @@ -36,7 +36,7 @@ protected function setUp(): void public function testImplementsCollectionEntryStructure(): void { - $this->assertInstanceOf(DefaultCollectionHydrator::class, $this->structure); + self::assertInstanceOf(DefaultCollectionHydrator::class, $this->structure); } public function testLoadCacheCollection(): void @@ -58,23 +58,23 @@ public function testLoadCacheCollection(): void $collection = new PersistentCollection($this->_em, $targetClass, new ArrayCollection()); $list = $this->structure->loadCacheEntry($sourceClass, $key, $entry, $collection); - $this->assertNotNull($list); - $this->assertCount(2, $list); - $this->assertCount(2, $collection); + self::assertNotNull($list); + self::assertCount(2, $list); + self::assertCount(2, $collection); - $this->assertInstanceOf($targetClass->name, $list[0]); - $this->assertInstanceOf($targetClass->name, $list[1]); - $this->assertInstanceOf($targetClass->name, $collection[0]); - $this->assertInstanceOf($targetClass->name, $collection[1]); + self::assertInstanceOf($targetClass->name, $list[0]); + self::assertInstanceOf($targetClass->name, $list[1]); + self::assertInstanceOf($targetClass->name, $collection[0]); + self::assertInstanceOf($targetClass->name, $collection[1]); - $this->assertSame($list[0], $collection[0]); - $this->assertSame($list[1], $collection[1]); + self::assertSame($list[0], $collection[0]); + self::assertSame($list[1], $collection[1]); - $this->assertEquals(31, $list[0]->getId()); - $this->assertEquals(32, $list[1]->getId()); - $this->assertEquals($list[0]->getId(), $collection[0]->getId()); - $this->assertEquals($list[1]->getId(), $collection[1]->getId()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[0])); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[1])); + self::assertEquals(31, $list[0]->getId()); + self::assertEquals(32, $list[1]->getId()); + self::assertEquals($list[0]->getId(), $collection[0]->getId()); + self::assertEquals($list[1]->getId(), $collection[1]->getId()); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[0])); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[1])); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php index 144bec3db15..bd5eaeac4dd 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php @@ -37,7 +37,7 @@ protected function setUp(): void public function testImplementsEntityEntryStructure(): void { - $this->assertInstanceOf('\Doctrine\ORM\Cache\EntityHydrator', $this->structure); + self::assertInstanceOf('\Doctrine\ORM\Cache\EntityHydrator', $this->structure); } public function testCreateEntity(): void @@ -47,11 +47,11 @@ public function testCreateEntity(): void $entry = new EntityCacheEntry($metadata->name, ['id' => 1, 'name' => 'Foo']); $entity = $this->structure->loadCacheEntry($metadata, $key, $entry); - $this->assertInstanceOf($metadata->name, $entity); + self::assertInstanceOf($metadata->name, $entity); - $this->assertEquals(1, $entity->getId()); - $this->assertEquals('Foo', $entity->getName()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->em->getUnitOfWork()->getEntityState($entity)); + self::assertEquals(1, $entity->getId()); + self::assertEquals('Foo', $entity->getName()); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->em->getUnitOfWork()->getEntityState($entity)); } public function testLoadProxy(): void @@ -62,12 +62,12 @@ public function testLoadProxy(): void $proxy = $this->em->getReference($metadata->name, $key->identifier); $entity = $this->structure->loadCacheEntry($metadata, $key, $entry, $proxy); - $this->assertInstanceOf($metadata->name, $entity); - $this->assertSame($proxy, $entity); + self::assertInstanceOf($metadata->name, $entity); + self::assertSame($proxy, $entity); - $this->assertEquals(1, $entity->getId()); - $this->assertEquals('Foo', $entity->getName()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->em->getUnitOfWork()->getEntityState($proxy)); + self::assertEquals(1, $entity->getId()); + self::assertEquals('Foo', $entity->getName()); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->em->getUnitOfWork()->getEntityState($proxy)); } public function testBuildCacheEntry(): void @@ -83,12 +83,12 @@ public function testBuildCacheEntry(): void $cache = $this->structure->buildCacheEntry($metadata, $key, $entity); - $this->assertInstanceOf(CacheEntry::class, $cache); - $this->assertInstanceOf(EntityCacheEntry::class, $cache); + self::assertInstanceOf(CacheEntry::class, $cache); + self::assertInstanceOf(EntityCacheEntry::class, $cache); - $this->assertArrayHasKey('id', $cache->data); - $this->assertArrayHasKey('name', $cache->data); - $this->assertEquals( + self::assertArrayHasKey('id', $cache->data); + self::assertArrayHasKey('name', $cache->data); + self::assertEquals( [ 'id' => 1, 'name' => 'Foo', @@ -115,13 +115,13 @@ public function testBuildCacheEntryAssociation(): void $cache = $this->structure->buildCacheEntry($metadata, $key, $state); - $this->assertInstanceOf(CacheEntry::class, $cache); - $this->assertInstanceOf(EntityCacheEntry::class, $cache); + self::assertInstanceOf(CacheEntry::class, $cache); + self::assertInstanceOf(EntityCacheEntry::class, $cache); - $this->assertArrayHasKey('id', $cache->data); - $this->assertArrayHasKey('name', $cache->data); - $this->assertArrayHasKey('country', $cache->data); - $this->assertEquals( + self::assertArrayHasKey('id', $cache->data); + self::assertArrayHasKey('name', $cache->data); + self::assertArrayHasKey('country', $cache->data); + self::assertEquals( [ 'id' => 12, 'name' => 'Bar', @@ -146,13 +146,13 @@ public function testBuildCacheEntryNonInitializedAssocProxy(): void $cache = $this->structure->buildCacheEntry($metadata, $key, $entity); - $this->assertInstanceOf(CacheEntry::class, $cache); - $this->assertInstanceOf(EntityCacheEntry::class, $cache); + self::assertInstanceOf(CacheEntry::class, $cache); + self::assertInstanceOf(EntityCacheEntry::class, $cache); - $this->assertArrayHasKey('id', $cache->data); - $this->assertArrayHasKey('name', $cache->data); - $this->assertArrayHasKey('country', $cache->data); - $this->assertEquals( + self::assertArrayHasKey('id', $cache->data); + self::assertArrayHasKey('name', $cache->data); + self::assertArrayHasKey('country', $cache->data); + self::assertEquals( [ 'id' => 12, 'name' => 'Bar', @@ -177,14 +177,14 @@ public function testCacheEntryWithWrongIdentifierType(): void $cache = $this->structure->buildCacheEntry($metadata, $key, $entity); - $this->assertInstanceOf(CacheEntry::class, $cache); - $this->assertInstanceOf(EntityCacheEntry::class, $cache); + self::assertInstanceOf(CacheEntry::class, $cache); + self::assertInstanceOf(EntityCacheEntry::class, $cache); - $this->assertArrayHasKey('id', $cache->data); - $this->assertArrayHasKey('name', $cache->data); - $this->assertArrayHasKey('country', $cache->data); - $this->assertSame($entity->getId(), $cache->data['id']); - $this->assertEquals( + self::assertArrayHasKey('id', $cache->data); + self::assertArrayHasKey('name', $cache->data); + self::assertArrayHasKey('country', $cache->data); + self::assertSame($entity->getId(), $cache->data['id']); + self::assertEquals( [ 'id' => 12, 'name' => 'Bar', diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 8e8b2989ed7..1768a181e03 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -65,20 +65,20 @@ protected function setUp(): void public function testImplementQueryCache(): void { - $this->assertInstanceOf(QueryCache::class, $this->queryCache); + self::assertInstanceOf(QueryCache::class, $this->queryCache); } public function testGetRegion(): void { - $this->assertSame($this->region, $this->queryCache->getRegion()); + self::assertSame($this->region, $this->queryCache->getRegion()); } public function testClearShouldEvictRegion(): void { $this->queryCache->clear(); - $this->assertArrayHasKey('evictAll', $this->region->calls); - $this->assertCount(1, $this->region->calls['evictAll']); + self::assertArrayHasKey('evictAll', $this->region->calls); + self::assertCount(1, $this->region->calls['evictAll']); } public function testPutBasicQueryResult(): void @@ -99,21 +99,21 @@ public function testPutBasicQueryResult(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['name' => $name]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(5, $this->region->calls['put']); - - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); - $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']); - - $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][0]['entry']); - $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][1]['entry']); - $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][2]['entry']); - $this->assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][3]['entry']); - $this->assertInstanceOf(QueryCacheEntry::class, $this->region->calls['put'][4]['entry']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(5, $this->region->calls['put']); + + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); + self::assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']); + + self::assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][0]['entry']); + self::assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][1]['entry']); + self::assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][2]['entry']); + self::assertInstanceOf(EntityCacheEntry::class, $this->region->calls['put'][3]['entry']); + self::assertInstanceOf(QueryCacheEntry::class, $this->region->calls['put'][4]['entry']); } public function testPutToOneAssociationQueryResult(): void @@ -140,19 +140,19 @@ public function testPutToOneAssociationQueryResult(): void $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => $state]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(9, $this->region->calls['put']); - - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']); - $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][8]['key']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(9, $this->region->calls['put']); + + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']); + self::assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][8]['key']); } public function testPutToOneAssociation2LevelsQueryResult(): void @@ -185,23 +185,23 @@ public function testPutToOneAssociation2LevelsQueryResult(): void $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => $state]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(13, $this->region->calls['put']); - - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][8]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][9]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][10]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][11]['key']); - $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][12]['key']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(13, $this->region->calls['put']); + + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][4]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][5]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][6]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][7]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][8]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][9]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][10]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][11]['key']); + self::assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][12]['key']); } public function testPutToOneAssociationNullQueryResult(): void @@ -224,15 +224,15 @@ public function testPutToOneAssociationNullQueryResult(): void $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => null]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(5, $this->region->calls['put']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(5, $this->region->calls['put']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); - $this->assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); - $this->assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][0]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][1]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][2]['key']); + self::assertInstanceOf(EntityCacheKey::class, $this->region->calls['put'][3]['key']); + self::assertInstanceOf(QueryCacheKey::class, $this->region->calls['put'][4]['key']); } public function testPutToManyAssociationQueryResult(): void @@ -265,9 +265,9 @@ public function testPutToManyAssociationQueryResult(): void $uow->registerManaged($state, ['id' => $state->getId()], ['name' => $state->getName(), 'cities' => $state->getCities()]); } - $this->assertTrue($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(13, $this->region->calls['put']); + self::assertTrue($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(13, $this->region->calls['put']); } public function testGetBasicQueryResult(): void @@ -300,13 +300,13 @@ public function testGetBasicQueryResult(): void $result = $this->queryCache->get($key, $rsm); - $this->assertCount(2, $result); - $this->assertInstanceOf(Country::class, $result[0]); - $this->assertInstanceOf(Country::class, $result[1]); - $this->assertEquals(1, $result[0]->getId()); - $this->assertEquals(2, $result[1]->getId()); - $this->assertEquals('Foo', $result[0]->getName()); - $this->assertEquals('Bar', $result[1]->getName()); + self::assertCount(2, $result); + self::assertInstanceOf(Country::class, $result[0]); + self::assertInstanceOf(Country::class, $result[1]); + self::assertEquals(1, $result[0]->getId()); + self::assertEquals(2, $result[1]->getId()); + self::assertEquals('Foo', $result[0]->getName()); + self::assertEquals('Bar', $result[1]->getName()); } public function testGetWithAssociation(): void @@ -339,13 +339,13 @@ public function testGetWithAssociation(): void $result = $this->queryCache->get($key, $rsm); - $this->assertCount(2, $result); - $this->assertInstanceOf(Country::class, $result[0]); - $this->assertInstanceOf(Country::class, $result[1]); - $this->assertEquals(1, $result[0]->getId()); - $this->assertEquals(2, $result[1]->getId()); - $this->assertEquals('Foo', $result[0]->getName()); - $this->assertEquals('Bar', $result[1]->getName()); + self::assertCount(2, $result); + self::assertInstanceOf(Country::class, $result[0]); + self::assertInstanceOf(Country::class, $result[1]); + self::assertEquals(1, $result[0]->getId()); + self::assertEquals(2, $result[1]->getId()); + self::assertEquals('Foo', $result[0]->getName()); + self::assertEquals('Bar', $result[1]->getName()); } public function testGetWithAssociationCacheMiss(): void @@ -396,9 +396,9 @@ public function testCancelPutResultIfEntityPutFails(): void $this->region->addReturn('put', false); - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(1, $this->region->calls['put']); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(1, $this->region->calls['put']); } public function testCancelPutResultIfAssociationEntityPutFails(): void @@ -426,7 +426,7 @@ public function testCancelPutResultIfAssociationEntityPutFails(): void $this->region->addReturn('put', true); // put root entity $this->region->addReturn('put', false); // association fails - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); } public function testCancelPutToManyAssociationQueryResult(): void @@ -460,9 +460,9 @@ public function testCancelPutToManyAssociationQueryResult(): void $this->region->addReturn('put', true); // put root entity $this->region->addReturn('put', false); // collection association fails - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); - $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(2, $this->region->calls['put']); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertArrayHasKey('put', $this->region->calls); + self::assertCount(2, $this->region->calls['put']); } public function testIgnoreCacheNonGetMode(): void @@ -480,7 +480,7 @@ public function testIgnoreCacheNonGetMode(): void $this->region->addReturn('get', $entry); - $this->assertNull($this->queryCache->get($key, $rsm)); + self::assertNull($this->queryCache->get($key, $rsm)); } public function testIgnoreCacheNonPutMode(): void @@ -501,7 +501,7 @@ public function testIgnoreCacheNonPutMode(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['name' => $name]); } - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); } public function testGetShouldIgnoreOldQueryCacheEntryResult(): void @@ -533,7 +533,7 @@ public function testGetShouldIgnoreOldQueryCacheEntryResult(): void $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); - $this->assertNull($this->queryCache->get($key, $rsm)); + self::assertNull($this->queryCache->get($key, $rsm)); } public function testGetShouldIgnoreNonQueryCacheEntryResult(): void @@ -564,7 +564,7 @@ public function testGetShouldIgnoreNonQueryCacheEntryResult(): void $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); - $this->assertNull($this->queryCache->get($key, $rsm)); + self::assertNull($this->queryCache->get($key, $rsm)); } public function testGetShouldIgnoreMissingEntityQueryCacheEntry(): void @@ -583,7 +583,7 @@ public function testGetShouldIgnoreMissingEntityQueryCacheEntry(): void $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); - $this->assertNull($this->queryCache->get($key, $rsm)); + self::assertNull($this->queryCache->get($key, $rsm)); } public function testGetAssociationValue(): void @@ -619,15 +619,15 @@ public function testGetAssociationValue(): void $cities = $reflection->invoke($this->queryCache, $rsm, 'c', $bavaria); $attractions = $reflection->invoke($this->queryCache, $rsm, 'a', $bavaria); - $this->assertCount(2, $cities); - $this->assertCount(2, $attractions); + self::assertCount(2, $cities); + self::assertCount(2, $attractions); - $this->assertInstanceOf(Collection::class, $cities); - $this->assertInstanceOf(Collection::class, $attractions[0]); - $this->assertInstanceOf(Collection::class, $attractions[1]); + self::assertInstanceOf(Collection::class, $cities); + self::assertInstanceOf(Collection::class, $attractions[0]); + self::assertInstanceOf(Collection::class, $attractions[1]); - $this->assertCount(2, $attractions[0]); - $this->assertCount(1, $attractions[1]); + self::assertCount(2, $attractions[0]); + self::assertCount(1, $attractions[1]); } public function testScalarResultException(): void @@ -677,7 +677,7 @@ public function testNotCacheableEntityException(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['booleanField' => $boolean]); } - $this->assertFalse($this->queryCache->put($key, $rsm, $result)); + self::assertFalse($this->queryCache->put($key, $rsm, $result)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index a30d2a54c81..cb43e08ae54 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -30,14 +30,14 @@ protected function createRegion(): Region public function testGetters(): void { - $this->assertEquals('default.region.test', $this->region->getName()); - $this->assertSame($this->cache, $this->region->getCache()); + self::assertEquals('default.region.test', $this->region->getName()); + self::assertSame($this->cache, $this->region->getCache()); } public function testSharedRegion(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $cache = new SharedArrayCache(); @@ -46,19 +46,19 @@ public function testSharedRegion(): void $region1 = new DefaultRegion('region1', $cache->createChild()); $region2 = new DefaultRegion('region2', $cache->createChild()); - $this->assertFalse($region1->contains($key)); - $this->assertFalse($region2->contains($key)); + self::assertFalse($region1->contains($key)); + self::assertFalse($region2->contains($key)); $region1->put($key, $entry); $region2->put($key, $entry); - $this->assertTrue($region1->contains($key)); - $this->assertTrue($region2->contains($key)); + self::assertTrue($region1->contains($key)); + self::assertTrue($region2->contains($key)); $region1->evictAll(); - $this->assertFalse($region1->contains($key)); - $this->assertTrue($region2->contains($key)); + self::assertFalse($region1->contains($key)); + self::assertTrue($region2->contains($key)); } public function testDoesNotModifyCacheNamespace(): void @@ -70,7 +70,7 @@ public function testDoesNotModifyCacheNamespace(): void new DefaultRegion('bar', $cache); new DefaultRegion('baz', $cache); - $this->assertSame('foo', $cache->getNamespace()); + self::assertSame('foo', $cache->getNamespace()); } public function testEvictAllWithGenericCacheThrowsUnsupportedException(): void @@ -93,19 +93,19 @@ public function testGetMulti(): void $key2 = new CacheKeyMock('key.2'); $value2 = new CacheEntryMock(['id' => 2, 'name' => 'bar']); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); $this->region->put($key1, $value1); $this->region->put($key2, $value2); - $this->assertTrue($this->region->contains($key1)); - $this->assertTrue($this->region->contains($key2)); + self::assertTrue($this->region->contains($key1)); + self::assertTrue($this->region->contains($key2)); $actual = $this->region->getMultiple(new CollectionCacheEntry([$key1, $key2])); - $this->assertEquals($value1, $actual[0]); - $this->assertEquals($value2, $actual[1]); + self::assertEquals($value1, $actual[0]); + self::assertEquals($value2, $actual[1]); } /** diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index 17e28209cdc..d6f2e7998a9 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -66,7 +66,7 @@ protected function createRegion(): Region public function testGetRegionName(): void { - $this->assertEquals('concurren_region_test', $this->region->getName()); + self::assertEquals('concurren_region_test', $this->region->getName()); } public function testLockAndUnlock(): void @@ -75,22 +75,22 @@ public function testLockAndUnlock(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); $lock = $this->region->lock($key); - $this->assertFileExists($file); - $this->assertInstanceOf(Lock::class, $lock); - $this->assertEquals($lock->value, file_get_contents($file)); + self::assertFileExists($file); + self::assertInstanceOf(Lock::class, $lock); + self::assertEquals($lock->value, file_get_contents($file)); // should be not available after lock - $this->assertFalse($this->region->contains($key)); - $this->assertNull($this->region->get($key)); + self::assertFalse($this->region->contains($key)); + self::assertNull($this->region->get($key)); - $this->assertTrue($this->region->unlock($key, $lock)); - $this->assertFileDoesNotExist($file); + self::assertTrue($this->region->unlock($key, $lock)); + self::assertFileDoesNotExist($file); } public function testLockWithExistingLock(): void @@ -99,21 +99,21 @@ public function testLockWithExistingLock(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); file_put_contents($file, 'foo'); - $this->assertFileExists($file); - $this->assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); + self::assertEquals('foo', file_get_contents($file)); - $this->assertNull($this->region->lock($key)); - $this->assertEquals('foo', file_get_contents($file)); - $this->assertFileExists($file); + self::assertNull($this->region->lock($key)); + self::assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); // should be not available - $this->assertFalse($this->region->contains($key)); - $this->assertNull($this->region->get($key)); + self::assertFalse($this->region->contains($key)); + self::assertNull($this->region->get($key)); } public function testUnlockWithExistingLock(): void @@ -122,27 +122,27 @@ public function testUnlockWithExistingLock(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); - $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); - $this->assertEquals($lock->value, file_get_contents($file)); - $this->assertFileExists($file); + self::assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); + self::assertEquals($lock->value, file_get_contents($file)); + self::assertFileExists($file); // change the lock file_put_contents($file, 'foo'); - $this->assertFileExists($file); - $this->assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); + self::assertEquals('foo', file_get_contents($file)); //try to unlock - $this->assertFalse($this->region->unlock($key, $lock)); - $this->assertEquals('foo', file_get_contents($file)); - $this->assertFileExists($file); + self::assertFalse($this->region->unlock($key, $lock)); + self::assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); // should be not available - $this->assertFalse($this->region->contains($key)); - $this->assertNull($this->region->get($key)); + self::assertFalse($this->region->contains($key)); + self::assertNull($this->region->get($key)); } public function testPutWithExistingLock(): void @@ -151,21 +151,21 @@ public function testPutWithExistingLock(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); // create lock file_put_contents($file, 'foo'); - $this->assertFileExists($file); - $this->assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); + self::assertEquals('foo', file_get_contents($file)); - $this->assertFalse($this->region->contains($key)); - $this->assertFalse($this->region->put($key, $entry)); - $this->assertFalse($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertFalse($this->region->put($key, $entry)); + self::assertFalse($this->region->contains($key)); - $this->assertFileExists($file); - $this->assertEquals('foo', file_get_contents($file)); + self::assertFileExists($file); + self::assertEquals('foo', file_get_contents($file)); } public function testLockedEvict(): void @@ -174,18 +174,18 @@ public function testLockedEvict(): void $entry = new CacheEntryMock(['foo' => 'bar']); $file = $this->getFileName($this->region, $key); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); - $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); - $this->assertEquals($lock->value, file_get_contents($file)); - $this->assertFileExists($file); + self::assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); + self::assertEquals($lock->value, file_get_contents($file)); + self::assertFileExists($file); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->evict($key)); - $this->assertFalse($this->region->contains($key)); - $this->assertFileDoesNotExist($file); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->evict($key)); + self::assertFalse($this->region->contains($key)); + self::assertFileDoesNotExist($file); } public function testLockedEvictAll(): void @@ -198,30 +198,30 @@ public function testLockedEvictAll(): void $entry2 = new CacheEntryMock(['foo2' => 'bar2']); $file2 = $this->getFileName($this->region, $key2); - $this->assertFalse($this->region->contains($key1)); - $this->assertTrue($this->region->put($key1, $entry1)); - $this->assertTrue($this->region->contains($key1)); + self::assertFalse($this->region->contains($key1)); + self::assertTrue($this->region->put($key1, $entry1)); + self::assertTrue($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); - $this->assertTrue($this->region->put($key2, $entry2)); - $this->assertTrue($this->region->contains($key2)); + self::assertFalse($this->region->contains($key2)); + self::assertTrue($this->region->put($key2, $entry2)); + self::assertTrue($this->region->contains($key2)); - $this->assertInstanceOf(Lock::class, $lock1 = $this->region->lock($key1)); - $this->assertInstanceOf(Lock::class, $lock2 = $this->region->lock($key2)); + self::assertInstanceOf(Lock::class, $lock1 = $this->region->lock($key1)); + self::assertInstanceOf(Lock::class, $lock2 = $this->region->lock($key2)); - $this->assertEquals($lock2->value, file_get_contents($file2)); - $this->assertEquals($lock1->value, file_get_contents($file1)); + self::assertEquals($lock2->value, file_get_contents($file2)); + self::assertEquals($lock1->value, file_get_contents($file1)); - $this->assertFileExists($file1); - $this->assertFileExists($file2); + self::assertFileExists($file1); + self::assertFileExists($file2); - $this->assertTrue($this->region->evictAll()); + self::assertTrue($this->region->evictAll()); - $this->assertFileDoesNotExist($file1); - $this->assertFileDoesNotExist($file2); + self::assertFileDoesNotExist($file1); + self::assertFileDoesNotExist($file2); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); } public function testLockLifetime(): void @@ -234,18 +234,18 @@ public function testLockLifetime(): void $property->setAccessible(true); $property->setValue($this->region, -10); - $this->assertFalse($this->region->contains($key)); - $this->assertTrue($this->region->put($key, $entry)); - $this->assertTrue($this->region->contains($key)); + self::assertFalse($this->region->contains($key)); + self::assertTrue($this->region->put($key, $entry)); + self::assertTrue($this->region->contains($key)); - $this->assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); - $this->assertEquals($lock->value, file_get_contents($file)); - $this->assertFileExists($file); + self::assertInstanceOf(Lock::class, $lock = $this->region->lock($key)); + self::assertEquals($lock->value, file_get_contents($file)); + self::assertFileExists($file); // outdated lock should be removed - $this->assertTrue($this->region->contains($key)); - $this->assertNotNull($this->region->get($key)); - $this->assertFileDoesNotExist($file); + self::assertTrue($this->region->contains($key)); + self::assertNotNull($this->region->get($key)); + self::assertFileDoesNotExist($file); } /** @@ -262,7 +262,7 @@ public function testHandlesScanErrorsGracefullyOnEvictAll(): void set_error_handler(static function (): void { }, E_WARNING); - $this->assertTrue($region->evictAll()); + self::assertTrue($region->evictAll()); restore_error_handler(); } diff --git a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php index 0228ce6b846..3f10d9652c8 100644 --- a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php @@ -25,19 +25,19 @@ public function testGetMulti(): void $key2 = new CacheKeyMock('key.2'); $value2 = new CacheEntryMock(['id' => 2, 'name' => 'bar']); - $this->assertFalse($this->region->contains($key1)); - $this->assertFalse($this->region->contains($key2)); + self::assertFalse($this->region->contains($key1)); + self::assertFalse($this->region->contains($key2)); $this->region->put($key1, $value1); $this->region->put($key2, $value2); - $this->assertTrue($this->region->contains($key1)); - $this->assertTrue($this->region->contains($key2)); + self::assertTrue($this->region->contains($key1)); + self::assertTrue($this->region->contains($key2)); $actual = $this->region->getMultiple(new CollectionCacheEntry([$key1, $key2])); - $this->assertEquals($value1, $actual[0]); - $this->assertEquals($value2, $actual[1]); + self::assertEquals($value1, $actual[0]); + self::assertEquals($value2, $actual[1]); } /** diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php index 92120834df3..59d8178cd06 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php @@ -101,9 +101,9 @@ public function testImplementsEntityPersister(): void { $persister = $this->createPersisterDefault(); - $this->assertInstanceOf(CollectionPersister::class, $persister); - $this->assertInstanceOf(CachedPersister::class, $persister); - $this->assertInstanceOf(CachedCollectionPersister::class, $persister); + self::assertInstanceOf(CollectionPersister::class, $persister); + self::assertInstanceOf(CachedPersister::class, $persister); + self::assertInstanceOf(CachedCollectionPersister::class, $persister); } public function testInvokeDelete(): void @@ -114,11 +114,11 @@ public function testInvokeDelete(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($collection)); + ->with(self::equalTo($collection)); - $this->assertNull($persister->delete($collection)); + self::assertNull($persister->delete($collection)); } public function testInvokeUpdate(): void @@ -131,11 +131,11 @@ public function testInvokeUpdate(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($collection)); + ->with(self::equalTo($collection)); - $this->assertNull($persister->update($collection)); + self::assertNull($persister->update($collection)); } public function testInvokeCount(): void @@ -146,12 +146,12 @@ public function testInvokeCount(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('count') - ->with($this->equalTo($collection)) - ->will($this->returnValue(0)); + ->with(self::equalTo($collection)) + ->will(self::returnValue(0)); - $this->assertEquals(0, $persister->count($collection)); + self::assertEquals(0, $persister->count($collection)); } public function testInvokeSlice(): void @@ -163,12 +163,12 @@ public function testInvokeSlice(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('slice') - ->with($this->equalTo($collection), $this->equalTo(1), $this->equalTo(2)) - ->will($this->returnValue($slice)); + ->with(self::equalTo($collection), self::equalTo(1), self::equalTo(2)) + ->will(self::returnValue($slice)); - $this->assertEquals($slice, $persister->slice($collection, 1, 2)); + self::assertEquals($slice, $persister->slice($collection, 1, 2)); } public function testInvokeContains(): void @@ -180,12 +180,12 @@ public function testInvokeContains(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('contains') - ->with($this->equalTo($collection), $this->equalTo($element)) - ->will($this->returnValue(false)); + ->with(self::equalTo($collection), self::equalTo($element)) + ->will(self::returnValue(false)); - $this->assertFalse($persister->contains($collection, $element)); + self::assertFalse($persister->contains($collection, $element)); } public function testInvokeContainsKey(): void @@ -196,12 +196,12 @@ public function testInvokeContainsKey(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('containsKey') - ->with($this->equalTo($collection), $this->equalTo(0)) - ->will($this->returnValue(false)); + ->with(self::equalTo($collection), self::equalTo(0)) + ->will(self::returnValue(false)); - $this->assertFalse($persister->containsKey($collection, 0)); + self::assertFalse($persister->containsKey($collection, 0)); } public function testInvokeGet(): void @@ -213,11 +213,11 @@ public function testInvokeGet(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('get') - ->with($this->equalTo($collection), $this->equalTo(0)) - ->will($this->returnValue($element)); + ->with(self::equalTo($collection), self::equalTo(0)) + ->will(self::returnValue($element)); - $this->assertEquals($element, $persister->get($collection, 0)); + self::assertEquals($element, $persister->get($collection, 0)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index d839107c907..60a95fa0297 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -53,10 +53,10 @@ public function testDeleteShouldLockItem(): void $collection = $this->createCollection($entity); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -71,10 +71,10 @@ public function testUpdateShouldLockItem(): void $collection = $this->createCollection($entity); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -89,15 +89,15 @@ public function testUpdateTransactionRollBackShouldEvictItem(): void $collection = $this->createCollection($entity); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -113,14 +113,14 @@ public function testDeleteTransactionRollBackShouldEvictItem(): void $collection = $this->createCollection($entity); $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -139,24 +139,24 @@ public function testTransactionRollBackDeleteShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($collection); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionRolledBack(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testTransactionRollBackUpdateShouldClearQueue(): void @@ -170,24 +170,24 @@ public function testTransactionRollBackUpdateShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($collection); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionRolledBack(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testTransactionRollCommitDeleteShouldClearQueue(): void @@ -201,24 +201,24 @@ public function testTransactionRollCommitDeleteShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($collection); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testTransactionRollCommitUpdateShouldClearQueue(): void @@ -232,24 +232,24 @@ public function testTransactionRollCommitUpdateShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($collection); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testDeleteLockFailureShouldIgnoreQueue(): void @@ -262,19 +262,19 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue(null)); + ->with(self::equalTo($key)) + ->will(self::returnValue(null)); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($collection)); + ->with(self::equalTo($collection)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($collection); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testUpdateLockFailureShouldIgnoreQueue(): void @@ -287,18 +287,18 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue(null)); + ->with(self::equalTo($key)) + ->will(self::returnValue(null)); - $this->collectionPersister->expects($this->once()) + $this->collectionPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($collection)); + ->with(self::equalTo($collection)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($collection); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php index f6069ab9f4d..44c20d30489 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php @@ -59,9 +59,9 @@ public function testImplementsEntityPersister(): void { $persister = $this->createPersisterDefault(); - $this->assertInstanceOf(EntityPersister::class, $persister); - $this->assertInstanceOf(CachedPersister::class, $persister); - $this->assertInstanceOf(CachedEntityPersister::class, $persister); + self::assertInstanceOf(EntityPersister::class, $persister); + self::assertInstanceOf(CachedPersister::class, $persister); + self::assertInstanceOf(CachedEntityPersister::class, $persister); } public function testInvokeAddInsert(): void @@ -69,11 +69,11 @@ public function testInvokeAddInsert(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('addInsert') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); - $this->assertNull($persister->addInsert($entity)); + self::assertNull($persister->addInsert($entity)); } public function testInvokeGetInserts(): void @@ -81,25 +81,25 @@ public function testInvokeGetInserts(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getInserts') - ->will($this->returnValue([$entity])); + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->getInserts()); + self::assertEquals([$entity], $persister->getInserts()); } public function testInvokeGetSelectSQL(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getSelectSQL') - ->with($this->equalTo(['name' => 'Foo']), $this->equalTo([0]), $this->equalTo(1), $this->equalTo(2), $this->equalTo(3), $this->equalTo( + ->with(self::equalTo(['name' => 'Foo']), self::equalTo([0]), self::equalTo(1), self::equalTo(2), self::equalTo(3), self::equalTo( [4] )) - ->will($this->returnValue('SELECT * FROM foo WERE name = ?')); + ->will(self::returnValue('SELECT * FROM foo WERE name = ?')); - $this->assertEquals('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL( + self::assertEquals('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL( ['name' => 'Foo'], [0], 1, @@ -113,23 +113,23 @@ public function testInvokeGetInsertSQL(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getInsertSQL') - ->will($this->returnValue('INSERT INTO foo (?)')); + ->will(self::returnValue('INSERT INTO foo (?)')); - $this->assertEquals('INSERT INTO foo (?)', $persister->getInsertSQL()); + self::assertEquals('INSERT INTO foo (?)', $persister->getInsertSQL()); } public function testInvokeExpandParameters(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('expandParameters') - ->with($this->equalTo(['name' => 'Foo'])) - ->will($this->returnValue(['name' => 'Foo'])); + ->with(self::equalTo(['name' => 'Foo'])) + ->will(self::returnValue(['name' => 'Foo'])); - $this->assertEquals(['name' => 'Foo'], $persister->expandParameters(['name' => 'Foo'])); + self::assertEquals(['name' => 'Foo'], $persister->expandParameters(['name' => 'Foo'])); } public function testInvokeExpandCriteriaParameters(): void @@ -137,35 +137,35 @@ public function testInvokeExpandCriteriaParameters(): void $persister = $this->createPersisterDefault(); $criteria = new Criteria(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('expandCriteriaParameters') - ->with($this->equalTo($criteria)) - ->will($this->returnValue(['name' => 'Foo'])); + ->with(self::equalTo($criteria)) + ->will(self::returnValue(['name' => 'Foo'])); - $this->assertEquals(['name' => 'Foo'], $persister->expandCriteriaParameters($criteria)); + self::assertEquals(['name' => 'Foo'], $persister->expandCriteriaParameters($criteria)); } public function testInvokeSelectConditionStatementSQL(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getSelectConditionStatementSQL') - ->with($this->equalTo('id'), $this->equalTo(1), $this->equalTo([]), $this->equalTo('=')) - ->will($this->returnValue('name = 1')); + ->with(self::equalTo('id'), self::equalTo(1), self::equalTo([]), self::equalTo('=')) + ->will(self::returnValue('name = 1')); - $this->assertEquals('name = 1', $persister->getSelectConditionStatementSQL('id', 1, [], '=')); + self::assertEquals('name = 1', $persister->getSelectConditionStatementSQL('id', 1, [], '=')); } public function testInvokeExecuteInserts(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('executeInserts') - ->will($this->returnValue(['id' => 1])); + ->will(self::returnValue(['id' => 1])); - $this->assertEquals(['id' => 1], $persister->executeInserts()); + self::assertEquals(['id' => 1], $persister->executeInserts()); } public function testInvokeUpdate(): void @@ -173,13 +173,13 @@ public function testInvokeUpdate(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->assertNull($persister->update($entity)); + self::assertNull($persister->update($entity)); } public function testInvokeDelete(): void @@ -187,25 +187,25 @@ public function testInvokeDelete(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->assertNull($persister->delete($entity)); + self::assertNull($persister->delete($entity)); } public function testInvokeGetOwningTable(): void { $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getOwningTable') - ->with($this->equalTo('name')) - ->will($this->returnValue('t')); + ->with(self::equalTo('name')) + ->will(self::returnValue('t')); - $this->assertEquals('t', $persister->getOwningTable('name')); + self::assertEquals('t', $persister->getOwningTable('name')); } public function testInvokeLoad(): void @@ -213,16 +213,16 @@ public function testInvokeLoad(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('load') - ->with($this->equalTo(['id' => 1]), $this->equalTo($entity), $this->equalTo([0]), $this->equalTo( + ->with(self::equalTo(['id' => 1]), self::equalTo($entity), self::equalTo([0]), self::equalTo( [1] - ), $this->equalTo(2), $this->equalTo(3), $this->equalTo( + ), self::equalTo(2), self::equalTo(3), self::equalTo( [4] )) - ->will($this->returnValue($entity)); + ->will(self::returnValue($entity)); - $this->assertEquals($entity, $persister->load(['id' => 1], $entity, [0], [1], 2, 3, [4])); + self::assertEquals($entity, $persister->load(['id' => 1], $entity, [0], [1], 2, 3, [4])); } public function testInvokeLoadAll(): void @@ -235,16 +235,16 @@ public function testInvokeLoadAll(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadAll') - ->with($this->equalTo(['id' => 1]), $this->equalTo([0]), $this->equalTo(1), $this->equalTo(2)) - ->will($this->returnValue([$entity])); + ->with(self::equalTo(['id' => 1]), self::equalTo([0]), self::equalTo(1), self::equalTo(2)) + ->will(self::returnValue([$entity])); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getResultSetMapping') - ->will($this->returnValue($rsm)); + ->will(self::returnValue($rsm)); - $this->assertEquals([$entity], $persister->loadAll(['id' => 1], [0], 1, 2)); + self::assertEquals([$entity], $persister->loadAll(['id' => 1], [0], 1, 2)); } public function testInvokeLoadById(): void @@ -252,12 +252,12 @@ public function testInvokeLoadById(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadById') - ->with($this->equalTo(['id' => 1]), $this->equalTo($entity)) - ->will($this->returnValue($entity)); + ->with(self::equalTo(['id' => 1]), self::equalTo($entity)) + ->will(self::returnValue($entity)); - $this->assertEquals($entity, $persister->loadById(['id' => 1], $entity)); + self::assertEquals($entity, $persister->loadById(['id' => 1], $entity)); } public function testInvokeLoadOneToOneEntity(): void @@ -265,12 +265,12 @@ public function testInvokeLoadOneToOneEntity(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadOneToOneEntity') - ->with($this->equalTo([]), $this->equalTo('foo'), $this->equalTo(['id' => 11])) - ->will($this->returnValue($entity)); + ->with(self::equalTo([]), self::equalTo('foo'), self::equalTo(['id' => 11])) + ->will(self::returnValue($entity)); - $this->assertEquals($entity, $persister->loadOneToOneEntity([], 'foo', ['id' => 11])); + self::assertEquals($entity, $persister->loadOneToOneEntity([], 'foo', ['id' => 11])); } public function testInvokeRefresh(): void @@ -278,12 +278,12 @@ public function testInvokeRefresh(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('refresh') - ->with($this->equalTo(['id' => 1]), $this->equalTo($entity), $this->equalTo(0)) - ->will($this->returnValue($entity)); + ->with(self::equalTo(['id' => 1]), self::equalTo($entity), self::equalTo(0)) + ->will(self::returnValue($entity)); - $this->assertNull($persister->refresh(['id' => 1], $entity)); + self::assertNull($persister->refresh(['id' => 1], $entity)); } public function testInvokeLoadCriteria(): void @@ -296,16 +296,16 @@ public function testInvokeLoadCriteria(): void $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $rsm->addEntityResult(Country::class, 'c'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getResultSetMapping') - ->will($this->returnValue($rsm)); + ->will(self::returnValue($rsm)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadCriteria') - ->with($this->equalTo($criteria)) - ->will($this->returnValue([$entity])); + ->with(self::equalTo($criteria)) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->loadCriteria($criteria)); + self::assertEquals([$entity], $persister->loadCriteria($criteria)); } public function testInvokeGetManyToManyCollection(): void @@ -313,12 +313,12 @@ public function testInvokeGetManyToManyCollection(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getManyToManyCollection') - ->with($this->equalTo([]), $this->equalTo('Foo'), $this->equalTo(1), $this->equalTo(2)) - ->will($this->returnValue([$entity])); + ->with(self::equalTo([]), self::equalTo('Foo'), self::equalTo(1), self::equalTo(2)) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->getManyToManyCollection([], 'Foo', 1, 2)); + self::assertEquals([$entity], $persister->getManyToManyCollection([], 'Foo', 1, 2)); } public function testInvokeGetOneToManyCollection(): void @@ -326,12 +326,12 @@ public function testInvokeGetOneToManyCollection(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getOneToManyCollection') - ->with($this->equalTo([]), $this->equalTo('Foo'), $this->equalTo(1), $this->equalTo(2)) - ->will($this->returnValue([$entity])); + ->with(self::equalTo([]), self::equalTo('Foo'), self::equalTo(1), self::equalTo(2)) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->getOneToManyCollection([], 'Foo', 1, 2)); + self::assertEquals([$entity], $persister->getOneToManyCollection([], 'Foo', 1, 2)); } public function testInvokeLoadManyToManyCollection(): void @@ -342,12 +342,12 @@ public function testInvokeLoadManyToManyCollection(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadManyToManyCollection') - ->with($this->equalTo($assoc), $this->equalTo('Foo'), $coll) - ->will($this->returnValue([$entity])); + ->with(self::equalTo($assoc), self::equalTo('Foo'), $coll) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->loadManyToManyCollection($assoc, 'Foo', $coll)); + self::assertEquals([$entity], $persister->loadManyToManyCollection($assoc, 'Foo', $coll)); } public function testInvokeLoadOneToManyCollection(): void @@ -358,12 +358,12 @@ public function testInvokeLoadOneToManyCollection(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('loadOneToManyCollection') - ->with($this->equalTo($assoc), $this->equalTo('Foo'), $coll) - ->will($this->returnValue([$entity])); + ->with(self::equalTo($assoc), self::equalTo('Foo'), $coll) + ->will(self::returnValue([$entity])); - $this->assertEquals([$entity], $persister->loadOneToManyCollection($assoc, 'Foo', $coll)); + self::assertEquals([$entity], $persister->loadOneToManyCollection($assoc, 'Foo', $coll)); } public function testInvokeLock(): void @@ -371,11 +371,11 @@ public function testInvokeLock(): void $identifier = ['id' => 1]; $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('lock') - ->with($this->equalTo($identifier), $this->equalTo(1)); + ->with(self::equalTo($identifier), self::equalTo(1)); - $this->assertNull($persister->lock($identifier, 1)); + self::assertNull($persister->lock($identifier, 1)); } public function testInvokeExists(): void @@ -383,10 +383,10 @@ public function testInvokeExists(): void $entity = new Country('Foo'); $persister = $this->createPersisterDefault(); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('exists') - ->with($this->equalTo($entity), $this->equalTo(null)); + ->with(self::equalTo($entity), self::equalTo(null)); - $this->assertNull($persister->exists($entity)); + self::assertNull($persister->exists($entity)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php index 4dc5c7c0e6f..24ae0390abe 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php @@ -38,11 +38,11 @@ public function testTransactionRollBackShouldClearQueue(): void $persister->update($entity); $persister->delete($entity); - $this->assertCount(2, $property->getValue($persister)); + self::assertCount(2, $property->getValue($persister)); $persister->afterTransactionRolledBack(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testInsertTransactionCommitShouldPutCache(): void @@ -55,19 +55,19 @@ public function testInsertTransactionCommitShouldPutCache(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('put') - ->with($this->equalTo($key), $this->equalTo($entry)); + ->with(self::equalTo($key), self::equalTo($entry)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('addInsert') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('getInserts') - ->will($this->returnValue([$entity])); + ->will(self::returnValue([$entity])); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('executeInserts'); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -75,11 +75,11 @@ public function testInsertTransactionCommitShouldPutCache(): void $persister->addInsert($entity); $persister->executeInserts(); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testUpdateTransactionCommitShouldPutCache(): void @@ -92,23 +92,23 @@ public function testUpdateTransactionCommitShouldPutCache(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('put') - ->with($this->equalTo($key), $this->equalTo($entry)); + ->with(self::equalTo($key), self::equalTo($entry)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testDeleteTransactionCommitShouldEvictCache(): void @@ -120,22 +120,22 @@ public function testDeleteTransactionCommitShouldEvictCache(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($entity); - $this->assertCount(1, $property->getValue($persister)); + self::assertCount(1, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 3cb28c5604f..34c0f273665 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -38,10 +38,10 @@ public function testDeleteShouldLockItem(): void $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::class, ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -55,10 +55,10 @@ public function testUpdateShouldLockItem(): void $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::class, ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -72,15 +72,15 @@ public function testUpdateTransactionRollBackShouldEvictItem(): void $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::class, ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -95,14 +95,14 @@ public function testDeleteTransactionRollBackShouldEvictItem(): void $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::class, ['id' => 1]); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -120,25 +120,25 @@ public function testTransactionRollBackShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->exactly(2)) + $this->region->expects(self::exactly(2)) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->exactly(2)) + $this->region->expects(self::exactly(2)) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); $persister->delete($entity); - $this->assertCount(2, $property->getValue($persister)); + self::assertCount(2, $property->getValue($persister)); $persister->afterTransactionRolledBack(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testTransactionCommitShouldClearQueue(): void @@ -151,25 +151,25 @@ public function testTransactionCommitShouldClearQueue(): void $property->setAccessible(true); - $this->region->expects($this->exactly(2)) + $this->region->expects(self::exactly(2)) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue($lock)); + ->with(self::equalTo($key)) + ->will(self::returnValue($lock)); - $this->region->expects($this->exactly(2)) + $this->region->expects(self::exactly(2)) ->method('evict') - ->with($this->equalTo($key)); + ->with(self::equalTo($key)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); $persister->delete($entity); - $this->assertCount(2, $property->getValue($persister)); + self::assertCount(2, $property->getValue($persister)); $persister->afterTransactionComplete(); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testDeleteLockFailureShouldIgnoreQueue(): void @@ -181,19 +181,19 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue(null)); + ->with(self::equalTo($key)) + ->will(self::returnValue(null)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('delete') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->delete($entity); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } public function testUpdateLockFailureShouldIgnoreQueue(): void @@ -205,18 +205,18 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void $property->setAccessible(true); - $this->region->expects($this->once()) + $this->region->expects(self::once()) ->method('lock') - ->with($this->equalTo($key)) - ->will($this->returnValue(null)); + ->with(self::equalTo($key)) + ->will(self::returnValue(null)); - $this->entityPersister->expects($this->once()) + $this->entityPersister->expects(self::once()) ->method('update') - ->with($this->equalTo($entity)); + ->with(self::equalTo($entity)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); - $this->assertCount(0, $property->getValue($persister)); + self::assertCount(0, $property->getValue($persister)); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php index cfa8a3b4010..8d89a4ad3ee 100644 --- a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php @@ -35,12 +35,12 @@ public function testEntityCache(): void $this->logger->entityCachePut($name, $key); $this->logger->entityCacheMiss($name, $key); - $this->assertEquals(1, $this->logger->getHitCount()); - $this->assertEquals(1, $this->logger->getPutCount()); - $this->assertEquals(1, $this->logger->getMissCount()); - $this->assertEquals(1, $this->logger->getRegionHitCount($name)); - $this->assertEquals(1, $this->logger->getRegionPutCount($name)); - $this->assertEquals(1, $this->logger->getRegionMissCount($name)); + self::assertEquals(1, $this->logger->getHitCount()); + self::assertEquals(1, $this->logger->getPutCount()); + self::assertEquals(1, $this->logger->getMissCount()); + self::assertEquals(1, $this->logger->getRegionHitCount($name)); + self::assertEquals(1, $this->logger->getRegionPutCount($name)); + self::assertEquals(1, $this->logger->getRegionMissCount($name)); } public function testCollectionCache(): void @@ -52,12 +52,12 @@ public function testCollectionCache(): void $this->logger->collectionCachePut($name, $key); $this->logger->collectionCacheMiss($name, $key); - $this->assertEquals(1, $this->logger->getHitCount()); - $this->assertEquals(1, $this->logger->getPutCount()); - $this->assertEquals(1, $this->logger->getMissCount()); - $this->assertEquals(1, $this->logger->getRegionHitCount($name)); - $this->assertEquals(1, $this->logger->getRegionPutCount($name)); - $this->assertEquals(1, $this->logger->getRegionMissCount($name)); + self::assertEquals(1, $this->logger->getHitCount()); + self::assertEquals(1, $this->logger->getPutCount()); + self::assertEquals(1, $this->logger->getMissCount()); + self::assertEquals(1, $this->logger->getRegionHitCount($name)); + self::assertEquals(1, $this->logger->getRegionPutCount($name)); + self::assertEquals(1, $this->logger->getRegionMissCount($name)); } public function testQueryCache(): void @@ -69,12 +69,12 @@ public function testQueryCache(): void $this->logger->queryCachePut($name, $key); $this->logger->queryCacheMiss($name, $key); - $this->assertEquals(1, $this->logger->getHitCount()); - $this->assertEquals(1, $this->logger->getPutCount()); - $this->assertEquals(1, $this->logger->getMissCount()); - $this->assertEquals(1, $this->logger->getRegionHitCount($name)); - $this->assertEquals(1, $this->logger->getRegionPutCount($name)); - $this->assertEquals(1, $this->logger->getRegionMissCount($name)); + self::assertEquals(1, $this->logger->getHitCount()); + self::assertEquals(1, $this->logger->getPutCount()); + self::assertEquals(1, $this->logger->getMissCount()); + self::assertEquals(1, $this->logger->getRegionHitCount($name)); + self::assertEquals(1, $this->logger->getRegionPutCount($name)); + self::assertEquals(1, $this->logger->getRegionMissCount($name)); } public function testMultipleCaches(): void @@ -99,36 +99,36 @@ public function testMultipleCaches(): void $this->logger->collectionCachePut($coolRegion, $coolKey); $this->logger->collectionCacheMiss($coolRegion, $coolKey); - $this->assertEquals(3, $this->logger->getHitCount()); - $this->assertEquals(3, $this->logger->getPutCount()); - $this->assertEquals(3, $this->logger->getMissCount()); + self::assertEquals(3, $this->logger->getHitCount()); + self::assertEquals(3, $this->logger->getPutCount()); + self::assertEquals(3, $this->logger->getMissCount()); - $this->assertEquals(1, $this->logger->getRegionHitCount($queryRegion)); - $this->assertEquals(1, $this->logger->getRegionPutCount($queryRegion)); - $this->assertEquals(1, $this->logger->getRegionMissCount($queryRegion)); + self::assertEquals(1, $this->logger->getRegionHitCount($queryRegion)); + self::assertEquals(1, $this->logger->getRegionPutCount($queryRegion)); + self::assertEquals(1, $this->logger->getRegionMissCount($queryRegion)); - $this->assertEquals(1, $this->logger->getRegionHitCount($coolRegion)); - $this->assertEquals(1, $this->logger->getRegionPutCount($coolRegion)); - $this->assertEquals(1, $this->logger->getRegionMissCount($coolRegion)); + self::assertEquals(1, $this->logger->getRegionHitCount($coolRegion)); + self::assertEquals(1, $this->logger->getRegionPutCount($coolRegion)); + self::assertEquals(1, $this->logger->getRegionMissCount($coolRegion)); - $this->assertEquals(1, $this->logger->getRegionHitCount($entityRegion)); - $this->assertEquals(1, $this->logger->getRegionPutCount($entityRegion)); - $this->assertEquals(1, $this->logger->getRegionMissCount($entityRegion)); + self::assertEquals(1, $this->logger->getRegionHitCount($entityRegion)); + self::assertEquals(1, $this->logger->getRegionPutCount($entityRegion)); + self::assertEquals(1, $this->logger->getRegionMissCount($entityRegion)); $miss = $this->logger->getRegionsMiss(); $hit = $this->logger->getRegionsHit(); $put = $this->logger->getRegionsPut(); - $this->assertArrayHasKey($coolRegion, $miss); - $this->assertArrayHasKey($queryRegion, $miss); - $this->assertArrayHasKey($entityRegion, $miss); + self::assertArrayHasKey($coolRegion, $miss); + self::assertArrayHasKey($queryRegion, $miss); + self::assertArrayHasKey($entityRegion, $miss); - $this->assertArrayHasKey($coolRegion, $put); - $this->assertArrayHasKey($queryRegion, $put); - $this->assertArrayHasKey($entityRegion, $put); + self::assertArrayHasKey($coolRegion, $put); + self::assertArrayHasKey($queryRegion, $put); + self::assertArrayHasKey($entityRegion, $put); - $this->assertArrayHasKey($coolRegion, $hit); - $this->assertArrayHasKey($queryRegion, $hit); - $this->assertArrayHasKey($entityRegion, $hit); + self::assertArrayHasKey($coolRegion, $hit); + self::assertArrayHasKey($queryRegion, $hit); + self::assertArrayHasKey($entityRegion, $hit); } } diff --git a/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php b/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php index 605e3af93aa..a9d3004683a 100644 --- a/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php +++ b/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php @@ -49,7 +49,7 @@ public function testCommitOrdering1(): void // There is only 1 valid ordering for this constellation $correctOrder = [$class5, $class1, $class2, $class3, $class4]; - $this->assertSame($correctOrder, $sorted); + self::assertSame($correctOrder, $sorted); } public function testCommitOrdering2(): void @@ -68,7 +68,7 @@ public function testCommitOrdering2(): void // There is only 1 valid ordering for this constellation $correctOrder = [$class2, $class1]; - $this->assertSame($correctOrder, $sorted); + self::assertSame($correctOrder, $sorted); } public function testCommitOrdering3(): void @@ -101,7 +101,7 @@ public function testCommitOrdering3(): void ]; // We want to perform a strict comparison of the array - $this->assertContains($sorted, $correctOrders, '', false, true); + self::assertContains($sorted, $correctOrders, '', false, true); } } diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 71bb203d7a1..666d0bfcb40 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -50,41 +50,41 @@ protected function setUp(): void public function testSetGetProxyDir(): void { - $this->assertSame(null, $this->configuration->getProxyDir()); // defaults + self::assertSame(null, $this->configuration->getProxyDir()); // defaults $this->configuration->setProxyDir(__DIR__); - $this->assertSame(__DIR__, $this->configuration->getProxyDir()); + self::assertSame(__DIR__, $this->configuration->getProxyDir()); } public function testSetGetAutoGenerateProxyClasses(): void { - $this->assertSame(AbstractProxyFactory::AUTOGENERATE_ALWAYS, $this->configuration->getAutoGenerateProxyClasses()); // defaults + self::assertSame(AbstractProxyFactory::AUTOGENERATE_ALWAYS, $this->configuration->getAutoGenerateProxyClasses()); // defaults $this->configuration->setAutoGenerateProxyClasses(false); - $this->assertSame(AbstractProxyFactory::AUTOGENERATE_NEVER, $this->configuration->getAutoGenerateProxyClasses()); + self::assertSame(AbstractProxyFactory::AUTOGENERATE_NEVER, $this->configuration->getAutoGenerateProxyClasses()); $this->configuration->setAutoGenerateProxyClasses(true); - $this->assertSame(AbstractProxyFactory::AUTOGENERATE_ALWAYS, $this->configuration->getAutoGenerateProxyClasses()); + self::assertSame(AbstractProxyFactory::AUTOGENERATE_ALWAYS, $this->configuration->getAutoGenerateProxyClasses()); $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS); - $this->assertSame(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS, $this->configuration->getAutoGenerateProxyClasses()); + self::assertSame(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS, $this->configuration->getAutoGenerateProxyClasses()); } public function testSetGetProxyNamespace(): void { - $this->assertSame(null, $this->configuration->getProxyNamespace()); // defaults + self::assertSame(null, $this->configuration->getProxyNamespace()); // defaults $this->configuration->setProxyNamespace(__NAMESPACE__); - $this->assertSame(__NAMESPACE__, $this->configuration->getProxyNamespace()); + self::assertSame(__NAMESPACE__, $this->configuration->getProxyNamespace()); } public function testSetGetMetadataDriverImpl(): void { - $this->assertSame(null, $this->configuration->getMetadataDriverImpl()); // defaults + self::assertSame(null, $this->configuration->getMetadataDriverImpl()); // defaults $metadataDriver = $this->createMock(MappingDriver::class); $this->configuration->setMetadataDriverImpl($metadataDriver); - $this->assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl()); + self::assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl()); } public function testNewDefaultAnnotationDriver(): void @@ -98,7 +98,7 @@ public function testNewDefaultAnnotationDriver(): void $reflectionClass->getMethod('namespacedAnnotationMethod'), AnnotationNamespace\PrePersist::class ); - $this->assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); + self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths); $reader = $annotationDriver->getReader(); @@ -106,59 +106,59 @@ public function testNewDefaultAnnotationDriver(): void $reflectionClass->getMethod('simpleAnnotationMethod'), AnnotationNamespace\PrePersist::class ); - $this->assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); + self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); } public function testSetGetEntityNamespace(): void { $this->configuration->addEntityNamespace('TestNamespace', __NAMESPACE__); - $this->assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace')); + self::assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace')); $namespaces = ['OtherNamespace' => __NAMESPACE__]; $this->configuration->setEntityNamespaces($namespaces); - $this->assertSame($namespaces, $this->configuration->getEntityNamespaces()); + self::assertSame($namespaces, $this->configuration->getEntityNamespaces()); $this->expectException(ORMException::class); $this->configuration->getEntityNamespace('NonExistingNamespace'); } public function testSetGetQueryCacheImpl(): void { - $this->assertSame(null, $this->configuration->getQueryCacheImpl()); // defaults + self::assertSame(null, $this->configuration->getQueryCacheImpl()); // defaults $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setQueryCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getQueryCacheImpl()); + self::assertSame($queryCacheImpl, $this->configuration->getQueryCacheImpl()); } public function testSetGetHydrationCacheImpl(): void { - $this->assertSame(null, $this->configuration->getHydrationCacheImpl()); // defaults + self::assertSame(null, $this->configuration->getHydrationCacheImpl()); // defaults $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setHydrationCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getHydrationCacheImpl()); + self::assertSame($queryCacheImpl, $this->configuration->getHydrationCacheImpl()); } public function testSetGetMetadataCacheImpl(): void { - $this->assertSame(null, $this->configuration->getMetadataCacheImpl()); // defaults + self::assertSame(null, $this->configuration->getMetadataCacheImpl()); // defaults $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setMetadataCacheImpl($queryCacheImpl); - $this->assertSame($queryCacheImpl, $this->configuration->getMetadataCacheImpl()); - $this->assertNotNull($this->configuration->getMetadataCache()); + self::assertSame($queryCacheImpl, $this->configuration->getMetadataCacheImpl()); + self::assertNotNull($this->configuration->getMetadataCache()); } public function testSetGetMetadataCache(): void { - $this->assertNull($this->configuration->getMetadataCache()); + self::assertNull($this->configuration->getMetadataCache()); $cache = $this->createStub(CacheItemPoolInterface::class); $this->configuration->setMetadataCache($cache); - $this->assertSame($cache, $this->configuration->getMetadataCache()); - $this->assertNotNull($this->configuration->getMetadataCacheImpl()); + self::assertSame($cache, $this->configuration->getMetadataCache()); + self::assertNotNull($this->configuration->getMetadataCacheImpl()); } public function testAddGetNamedQuery(): void { $dql = 'SELECT u FROM User u'; $this->configuration->addNamedQuery('QueryName', $dql); - $this->assertSame($dql, $this->configuration->getNamedQuery('QueryName')); + self::assertSame($dql, $this->configuration->getNamedQuery('QueryName')); $this->expectException(ORMException::class); $this->expectExceptionMessage('a named query'); $this->configuration->getNamedQuery('NonExistingQuery'); @@ -170,8 +170,8 @@ public function testAddGetNamedNativeQuery(): void $rsm = $this->createMock(ResultSetMapping::class); $this->configuration->addNamedNativeQuery('QueryName', $sql, $rsm); $fetched = $this->configuration->getNamedNativeQuery('QueryName'); - $this->assertSame($sql, $fetched[0]); - $this->assertSame($rsm, $fetched[1]); + self::assertSame($sql, $fetched[0]); + self::assertSame($rsm, $fetched[1]); $this->expectException(ORMException::class); $this->expectExceptionMessage('a named native query'); $this->configuration->getNamedNativeQuery('NonExistingQuery'); @@ -238,7 +238,7 @@ public function testEnsureProductionSettingsMissingMetadataCache(): void public function testEnsureProductionSettingsQueryArrayCache(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $this->setProductionSettings(); @@ -253,7 +253,7 @@ public function testEnsureProductionSettingsQueryArrayCache(): void public function testEnsureProductionSettingsLegacyMetadataArrayCache(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $this->setProductionSettings(); @@ -301,87 +301,87 @@ public function testEnsureProductionSettingsAutoGenerateProxyClassesEval(): void public function testAddGetCustomStringFunction(): void { $this->configuration->addCustomStringFunction('FunctionName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomStringFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction')); + self::assertSame(self::class, $this->configuration->getCustomStringFunction('FunctionName')); + self::assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction')); $this->configuration->setCustomStringFunctions(['OtherFunctionName' => self::class]); - $this->assertSame(self::class, $this->configuration->getCustomStringFunction('OtherFunctionName')); + self::assertSame(self::class, $this->configuration->getCustomStringFunction('OtherFunctionName')); } public function testAddGetCustomNumericFunction(): void { $this->configuration->addCustomNumericFunction('FunctionName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomNumericFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction')); + self::assertSame(self::class, $this->configuration->getCustomNumericFunction('FunctionName')); + self::assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction')); $this->configuration->setCustomNumericFunctions(['OtherFunctionName' => self::class]); - $this->assertSame(self::class, $this->configuration->getCustomNumericFunction('OtherFunctionName')); + self::assertSame(self::class, $this->configuration->getCustomNumericFunction('OtherFunctionName')); } public function testAddGetCustomDatetimeFunction(): void { $this->configuration->addCustomDatetimeFunction('FunctionName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomDatetimeFunction('FunctionName')); - $this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction')); + self::assertSame(self::class, $this->configuration->getCustomDatetimeFunction('FunctionName')); + self::assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction')); $this->configuration->setCustomDatetimeFunctions(['OtherFunctionName' => self::class]); - $this->assertSame(self::class, $this->configuration->getCustomDatetimeFunction('OtherFunctionName')); + self::assertSame(self::class, $this->configuration->getCustomDatetimeFunction('OtherFunctionName')); } public function testAddGetCustomHydrationMode(): void { - $this->assertSame(null, $this->configuration->getCustomHydrationMode('NonExisting')); + self::assertSame(null, $this->configuration->getCustomHydrationMode('NonExisting')); $this->configuration->addCustomHydrationMode('HydrationModeName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); + self::assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); } public function testSetCustomHydrationModes(): void { $this->configuration->addCustomHydrationMode('HydrationModeName', self::class); - $this->assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); + self::assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); $this->configuration->setCustomHydrationModes( ['AnotherHydrationModeName' => self::class] ); - $this->assertNull($this->configuration->getCustomHydrationMode('HydrationModeName')); - $this->assertSame(self::class, $this->configuration->getCustomHydrationMode('AnotherHydrationModeName')); + self::assertNull($this->configuration->getCustomHydrationMode('HydrationModeName')); + self::assertSame(self::class, $this->configuration->getCustomHydrationMode('AnotherHydrationModeName')); } public function testSetGetClassMetadataFactoryName(): void { - $this->assertSame(AnnotationNamespace\ClassMetadataFactory::class, $this->configuration->getClassMetadataFactoryName()); + self::assertSame(AnnotationNamespace\ClassMetadataFactory::class, $this->configuration->getClassMetadataFactoryName()); $this->configuration->setClassMetadataFactoryName(self::class); - $this->assertSame(self::class, $this->configuration->getClassMetadataFactoryName()); + self::assertSame(self::class, $this->configuration->getClassMetadataFactoryName()); } public function testAddGetFilters(): void { - $this->assertSame(null, $this->configuration->getFilterClassName('NonExistingFilter')); + self::assertSame(null, $this->configuration->getFilterClassName('NonExistingFilter')); $this->configuration->addFilter('FilterName', self::class); - $this->assertSame(self::class, $this->configuration->getFilterClassName('FilterName')); + self::assertSame(self::class, $this->configuration->getFilterClassName('FilterName')); } public function setDefaultRepositoryClassName(): void { - $this->assertSame(EntityRepository::class, $this->configuration->getDefaultRepositoryClassName()); + self::assertSame(EntityRepository::class, $this->configuration->getDefaultRepositoryClassName()); $this->configuration->setDefaultRepositoryClassName(DDC753CustomRepository::class); - $this->assertSame(DDC753CustomRepository::class, $this->configuration->getDefaultRepositoryClassName()); + self::assertSame(DDC753CustomRepository::class, $this->configuration->getDefaultRepositoryClassName()); $this->expectException(ORMException::class); $this->configuration->setDefaultRepositoryClassName(self::class); } public function testSetGetNamingStrategy(): void { - $this->assertInstanceOf(NamingStrategy::class, $this->configuration->getNamingStrategy()); + self::assertInstanceOf(NamingStrategy::class, $this->configuration->getNamingStrategy()); $namingStrategy = $this->createMock(NamingStrategy::class); $this->configuration->setNamingStrategy($namingStrategy); - $this->assertSame($namingStrategy, $this->configuration->getNamingStrategy()); + self::assertSame($namingStrategy, $this->configuration->getNamingStrategy()); } public function testSetGetQuoteStrategy(): void { - $this->assertInstanceOf(QuoteStrategy::class, $this->configuration->getQuoteStrategy()); + self::assertInstanceOf(QuoteStrategy::class, $this->configuration->getQuoteStrategy()); $quoteStrategy = $this->createMock(QuoteStrategy::class); $this->configuration->setQuoteStrategy($quoteStrategy); - $this->assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); + self::assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); } /** @@ -389,11 +389,11 @@ public function testSetGetQuoteStrategy(): void */ public function testSetGetEntityListenerResolver(): void { - $this->assertInstanceOf(EntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); - $this->assertInstanceOf(AnnotationNamespace\DefaultEntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); + self::assertInstanceOf(EntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); + self::assertInstanceOf(AnnotationNamespace\DefaultEntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); $resolver = $this->createMock(EntityListenerResolver::class); $this->configuration->setEntityListenerResolver($resolver); - $this->assertSame($resolver, $this->configuration->getEntityListenerResolver()); + self::assertSame($resolver, $this->configuration->getEntityListenerResolver()); } /** @@ -403,9 +403,9 @@ public function testSetGetSecondLevelCacheConfig(): void { $mockClass = $this->createMock(CacheConfiguration::class); - $this->assertNull($this->configuration->getSecondLevelCacheConfiguration()); + self::assertNull($this->configuration->getSecondLevelCacheConfiguration()); $this->configuration->setSecondLevelCacheConfiguration($mockClass); - $this->assertEquals($mockClass, $this->configuration->getSecondLevelCacheConfiguration()); + self::assertEquals($mockClass, $this->configuration->getSecondLevelCacheConfiguration()); } } diff --git a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php index 375caf9a85d..05e72becc44 100644 --- a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php +++ b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php @@ -90,7 +90,7 @@ public function testAllMethodCallsAreDelegatedToTheWrappedInstance($method, arra { $return = ! in_array($method, self::VOID_METHODS, true) ? 'INNER VALUE FROM ' . $method : null; - $this->wrapped->expects($this->once()) + $this->wrapped->expects(self::once()) ->method($method) ->with(...$parameters) ->willReturn($return); @@ -98,6 +98,6 @@ public function testAllMethodCallsAreDelegatedToTheWrappedInstance($method, arra $decorator = new class ($this->wrapped) extends EntityManagerDecorator { }; - $this->assertSame($return, $decorator->$method(...$parameters)); + self::assertSame($return, $decorator->$method(...$parameters)); } } diff --git a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php index a6e3637802f..d39071c37ec 100644 --- a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php +++ b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php @@ -11,7 +11,7 @@ class ConstructorTest extends OrmTestCase public function testFieldInitializationInConstructor(): void { $entity = new ConstructorTestEntity1('romanb'); - $this->assertEquals('romanb', $entity->username); + self::assertEquals('romanb', $entity->username); } } diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 82f169e871d..8b054b81d2c 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -50,39 +50,39 @@ protected function setUp(): void */ public function testIsOpen(): void { - $this->assertTrue($this->entityManager->isOpen()); + self::assertTrue($this->entityManager->isOpen()); $this->entityManager->close(); - $this->assertFalse($this->entityManager->isOpen()); + self::assertFalse($this->entityManager->isOpen()); } public function testGetConnection(): void { - $this->assertInstanceOf(Connection::class, $this->entityManager->getConnection()); + self::assertInstanceOf(Connection::class, $this->entityManager->getConnection()); } public function testGetMetadataFactory(): void { - $this->assertInstanceOf(ClassMetadataFactory::class, $this->entityManager->getMetadataFactory()); + self::assertInstanceOf(ClassMetadataFactory::class, $this->entityManager->getMetadataFactory()); } public function testGetConfiguration(): void { - $this->assertInstanceOf(Configuration::class, $this->entityManager->getConfiguration()); + self::assertInstanceOf(Configuration::class, $this->entityManager->getConfiguration()); } public function testGetUnitOfWork(): void { - $this->assertInstanceOf(UnitOfWork::class, $this->entityManager->getUnitOfWork()); + self::assertInstanceOf(UnitOfWork::class, $this->entityManager->getUnitOfWork()); } public function testGetProxyFactory(): void { - $this->assertInstanceOf(ProxyFactory::class, $this->entityManager->getProxyFactory()); + self::assertInstanceOf(ProxyFactory::class, $this->entityManager->getProxyFactory()); } public function testGetEventManager(): void { - $this->assertInstanceOf(EventManager::class, $this->entityManager->getEventManager()); + self::assertInstanceOf(EventManager::class, $this->entityManager->getEventManager()); } public function testCreateNativeQuery(): void @@ -90,7 +90,7 @@ public function testCreateNativeQuery(): void $rsm = new ResultSetMapping(); $query = $this->entityManager->createNativeQuery('SELECT foo', $rsm); - $this->assertSame('SELECT foo', $query->getSql()); + self::assertSame('SELECT foo', $query->getSql()); } /** @@ -103,12 +103,12 @@ public function testCreateNamedNativeQuery(): void $query = $this->entityManager->createNamedNativeQuery('foo'); - $this->assertInstanceOf(NativeQuery::class, $query); + self::assertInstanceOf(NativeQuery::class, $query); } public function testCreateQueryBuilder(): void { - $this->assertInstanceOf(QueryBuilder::class, $this->entityManager->createQueryBuilder()); + self::assertInstanceOf(QueryBuilder::class, $this->entityManager->createQueryBuilder()); } public function testCreateQueryBuilderAliasValid(): void @@ -117,32 +117,32 @@ public function testCreateQueryBuilderAliasValid(): void ->select('u')->from(CmsUser::class, 'u'); $q2 = clone $q; - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q->getQuery()->getDql()); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q2->getQuery()->getDql()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q->getQuery()->getDql()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q2->getQuery()->getDql()); $q3 = clone $q; - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q3->getQuery()->getDql()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q3->getQuery()->getDql()); } public function testCreateQueryDqlIsOptional(): void { - $this->assertInstanceOf(Query::class, $this->entityManager->createQuery()); + self::assertInstanceOf(Query::class, $this->entityManager->createQuery()); } public function testGetPartialReference(): void { $user = $this->entityManager->getPartialReference(CmsUser::class, 42); - $this->assertTrue($this->entityManager->contains($user)); - $this->assertEquals(42, $user->id); - $this->assertNull($user->getName()); + self::assertTrue($this->entityManager->contains($user)); + self::assertEquals(42, $user->id); + self::assertNull($user->getName()); } public function testCreateQuery(): void { $q = $this->entityManager->createQuery('SELECT 1'); - $this->assertInstanceOf(Query::class, $q); - $this->assertEquals('SELECT 1', $q->getDql()); + self::assertInstanceOf(Query::class, $q); + self::assertEquals('SELECT 1', $q->getDql()); } /** @@ -153,8 +153,8 @@ public function testCreateNamedQuery(): void $this->entityManager->getConfiguration()->addNamedQuery('foo', 'SELECT 1'); $query = $this->entityManager->createNamedQuery('foo'); - $this->assertInstanceOf(Query::class, $query); - $this->assertEquals('SELECT 1', $query->getDql()); + self::assertInstanceOf(Query::class, $query); + self::assertEquals('SELECT 1', $query->getDql()); } /** @@ -217,12 +217,12 @@ public function testTransactionalAcceptsReturn(): void return 'foo'; }); - $this->assertEquals('foo', $return); + self::assertEquals('foo', $return); } public function testTransactionalAcceptsVariousCallables(): void { - $this->assertSame('callback', $this->entityManager->transactional([$this, 'transactionalCallback'])); + self::assertSame('callback', $this->entityManager->transactional([$this, 'transactionalCallback'])); } public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed(): void @@ -235,7 +235,7 @@ public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePass public function transactionalCallback($em): string { - $this->assertSame($this->entityManager, $em); + self::assertSame($this->entityManager, $em); return 'callback'; } @@ -301,11 +301,11 @@ public function testClearManagerWithProxyClassName(): void $this->entityManager->persist($entity); - $this->assertTrue($this->entityManager->contains($entity)); + self::assertTrue($this->entityManager->contains($entity)); $this->entityManager->clear(get_class($proxy)); - $this->assertFalse($this->entityManager->contains($entity)); + self::assertFalse($this->entityManager->contains($entity)); } /** @@ -317,11 +317,11 @@ public function testClearManagerWithNullValue(): void $this->entityManager->persist($entity); - $this->assertTrue($this->entityManager->contains($entity)); + self::assertTrue($this->entityManager->contains($entity)); $this->entityManager->clear(null); - $this->assertFalse($this->entityManager->contains($entity)); + self::assertFalse($this->entityManager->contains($entity)); } public function testDeprecatedClearWithArguments(): void diff --git a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php b/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php index 49784ca7403..8cb401c8a57 100644 --- a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php @@ -21,23 +21,23 @@ public function testFromClassNameAndIdentifier(): void ['foo' => 'bar'] ); - $this->assertInstanceOf(EntityNotFoundException::class, $exception); - $this->assertSame('Entity of type \'foo\' for IDs foo(bar) was not found', $exception->getMessage()); + self::assertInstanceOf(EntityNotFoundException::class, $exception); + self::assertSame('Entity of type \'foo\' for IDs foo(bar) was not found', $exception->getMessage()); $exception = EntityNotFoundException::fromClassNameAndIdentifier( 'foo', [] ); - $this->assertInstanceOf(EntityNotFoundException::class, $exception); - $this->assertSame('Entity of type \'foo\' was not found', $exception->getMessage()); + self::assertInstanceOf(EntityNotFoundException::class, $exception); + self::assertSame('Entity of type \'foo\' was not found', $exception->getMessage()); } public function testNoIdentifierFound(): void { $exception = EntityNotFoundException::noIdentifierFound('foo'); - $this->assertInstanceOf(EntityNotFoundException::class, $exception); - $this->assertSame('Unable to find "foo" entity identifier associated with the UnitOfWork', $exception->getMessage()); + self::assertInstanceOf(EntityNotFoundException::class, $exception); + self::assertSame('Unable to find "foo" entity identifier associated with the UnitOfWork', $exception->getMessage()); } } diff --git a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php b/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php index 5646c93433a..e80ba2ff75f 100644 --- a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php +++ b/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php @@ -25,20 +25,20 @@ public function testEventArgsMutability(): void $args = new OnClassMetadataNotFoundEventArgs('foo', $objectManager); - $this->assertSame('foo', $args->getClassName()); - $this->assertSame($objectManager, $args->getObjectManager()); + self::assertSame('foo', $args->getClassName()); + self::assertSame($objectManager, $args->getObjectManager()); - $this->assertNull($args->getFoundMetadata()); + self::assertNull($args->getFoundMetadata()); $metadata = $this->createMock(ClassMetadata::class); assert($metadata instanceof ClassMetadata); $args->setFoundMetadata($metadata); - $this->assertSame($metadata, $args->getFoundMetadata()); + self::assertSame($metadata, $args->getFoundMetadata()); $args->setFoundMetadata(null); - $this->assertNull($args->getFoundMetadata()); + self::assertNull($args->getFoundMetadata()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php index 78adbf46546..fb497deea6a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php @@ -26,12 +26,12 @@ class AbstractManyToManyAssociationTestCase extends OrmFunctionalTestCase public function assertForeignKeysContain($firstId, $secondId): void { - $this->assertEquals(1, $this->countForeignKeys($firstId, $secondId)); + self::assertEquals(1, $this->countForeignKeys($firstId, $secondId)); } public function assertForeignKeysNotContain($firstId, $secondId): void { - $this->assertEquals(0, $this->countForeignKeys($firstId, $secondId)); + self::assertEquals(0, $this->countForeignKeys($firstId, $secondId)); } protected function countForeignKeys($firstId, $secondId): int diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php index b77d9e86c7b..64a627ab8df 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -82,17 +82,17 @@ public function testIssue(): void // test1 - lazy-loading many-to-one after find() $phrase2 = $this->_em->find(Phrase::class, $phrase->getId()); - $this->assertTrue(is_numeric($phrase2->getType()->getId())); + self::assertTrue(is_numeric($phrase2->getType()->getId())); $this->_em->clear(); // test2 - eager load in DQL query $query = $this->_em->createQuery('SELECT p,t FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t'); $res = $query->getResult(); - $this->assertEquals(1, count($res)); - $this->assertInstanceOf(PhraseType::class, $res[0]->getType()); - $this->assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases()); - $this->assertFalse($res[0]->getType()->getPhrases()->isInitialized()); + self::assertEquals(1, count($res)); + self::assertInstanceOf(PhraseType::class, $res[0]->getType()); + self::assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases()); + self::assertFalse($res[0]->getType()->getPhrases()->isInitialized()); $this->_em->clear(); @@ -103,18 +103,18 @@ public function testIssue(): void // test2 - eager load in DQL query with double-join back and forth $query = $this->_em->createQuery('SELECT p,t,pp FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t JOIN t.phrases pp'); $res = $query->getResult(); - $this->assertEquals(1, count($res)); - $this->assertInstanceOf(PhraseType::class, $res[0]->getType()); - $this->assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases()); - $this->assertTrue($res[0]->getType()->getPhrases()->isInitialized()); + self::assertEquals(1, count($res)); + self::assertInstanceOf(PhraseType::class, $res[0]->getType()); + self::assertInstanceOf(PersistentCollection::class, $res[0]->getType()->getPhrases()); + self::assertTrue($res[0]->getType()->getPhrases()->isInitialized()); $this->_em->clear(); // test3 - lazy-loading one-to-many after find() $phrase3 = $this->_em->find(Phrase::class, $phrase->getId()); $definitions = $phrase3->getDefinitions(); - $this->assertInstanceOf(PersistentCollection::class, $definitions); - $this->assertInstanceOf(Definition::class, $definitions[0]); + self::assertInstanceOf(PersistentCollection::class, $definitions); + self::assertInstanceOf(Definition::class, $definitions[0]); $this->_em->clear(); @@ -123,10 +123,10 @@ public function testIssue(): void $res = $query->getResult(); $definitions = $res[0]->getDefinitions(); - $this->assertEquals(1, count($res)); + self::assertEquals(1, count($res)); - $this->assertInstanceOf(Definition::class, $definitions[0]); - $this->assertEquals(2, $definitions->count()); + self::assertInstanceOf(Definition::class, $definitions[0]); + self::assertEquals(2, $definitions->count()); $this->_em->clear(); @@ -153,7 +153,7 @@ public function testManyToMany(): void $res = $query->getResult(); $types = $res[0]->getTypes(); - $this->assertInstanceOf(Type::class, $types[0]); + self::assertInstanceOf(Type::class, $types[0]); $this->_em->clear(); diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php index ad816381dab..e95e1e08d89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php @@ -33,11 +33,11 @@ public function testAggregateWithHavingClause(): void $result = $this->_em->createQuery($dql)->getScalarResult(); - $this->assertEquals(2, count($result)); - $this->assertEquals('IT', $result[0]['department']); - $this->assertEquals(150000, $result[0]['avgSalary']); - $this->assertEquals('IT2', $result[1]['department']); - $this->assertEquals(600000, $result[1]['avgSalary']); + self::assertEquals(2, count($result)); + self::assertEquals('IT', $result[0]['department']); + self::assertEquals(150000, $result[0]['avgSalary']); + self::assertEquals('IT2', $result[1]['department']); + self::assertEquals(600000, $result[1]['avgSalary']); } public function testCommentsInDQL(): void @@ -51,11 +51,11 @@ public function testCommentsInDQL(): void $result = $this->_em->createQuery($dql)->getScalarResult(); - $this->assertEquals(2, count($result)); - $this->assertEquals('IT', $result[0]['department']); - $this->assertEquals(150000, $result[0]['avgSalary']); - $this->assertEquals('IT2', $result[1]['department']); - $this->assertEquals(600000, $result[1]['avgSalary']); + self::assertEquals(2, count($result)); + self::assertEquals('IT', $result[0]['department']); + self::assertEquals(150000, $result[0]['avgSalary']); + self::assertEquals('IT2', $result[1]['department']); + self::assertEquals(600000, $result[1]['avgSalary']); } public function testUnnamedScalarResultsAreOneBased(): void @@ -66,9 +66,9 @@ public function testUnnamedScalarResultsAreOneBased(): void $result = $this->_em->createQuery($dql)->getScalarResult(); - $this->assertEquals(2, count($result)); - $this->assertEquals(150000, $result[0][1]); - $this->assertEquals(600000, $result[1][1]); + self::assertEquals(2, count($result)); + self::assertEquals(150000, $result[0][1]); + self::assertEquals(600000, $result[1][1]); } public function testOrderByResultVariableCollectionSize(): void @@ -80,19 +80,19 @@ public function testOrderByResultVariableCollectionSize(): void $result = $this->_em->createQuery($dql)->getScalarResult(); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertEquals('Jonathan W.', $result[0]['name']); - $this->assertEquals(3, $result[0]['friends']); + self::assertEquals('Jonathan W.', $result[0]['name']); + self::assertEquals(3, $result[0]['friends']); - $this->assertEquals('Guilherme B.', $result[1]['name']); - $this->assertEquals(2, $result[1]['friends']); + self::assertEquals('Guilherme B.', $result[1]['name']); + self::assertEquals(2, $result[1]['friends']); - $this->assertEquals('Benjamin E.', $result[2]['name']); - $this->assertEquals(2, $result[2]['friends']); + self::assertEquals('Benjamin E.', $result[2]['name']); + self::assertEquals(2, $result[2]['friends']); - $this->assertEquals('Roman B.', $result[3]['name']); - $this->assertEquals(1, $result[3]['friends']); + self::assertEquals('Roman B.', $result[3]['name']); + self::assertEquals(1, $result[3]['friends']); } public function testOrderBySimpleCaseExpression(): void @@ -148,12 +148,12 @@ public function testIsNullAssociation(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertEquals(2, count($result)); - $this->assertTrue($result[0]->getId() > 0); - $this->assertNull($result[0]->getSpouse()); + self::assertEquals(2, count($result)); + self::assertTrue($result[0]->getId() > 0); + self::assertNull($result[0]->getSpouse()); - $this->assertTrue($result[1]->getId() > 0); - $this->assertNull($result[1]->getSpouse()); + self::assertTrue($result[1]->getId() > 0); + self::assertNull($result[1]->getSpouse()); $this->_em->clear(); @@ -167,8 +167,8 @@ public function testSelectSubselect(): void $query = $this->_em->createQuery($dql); $result = $query->getArrayResult(); - $this->assertEquals(1, count($result)); - $this->assertEquals('Caramba', $result[0]['brandName']); + self::assertEquals(1, count($result)); + self::assertEquals('Caramba', $result[0]['brandName']); $this->_em->clear(); } @@ -182,8 +182,8 @@ public function testInSubselect(): void $query = $this->_em->createQuery($dql); $result = $query->getScalarResult(); - $this->assertEquals(1, count($result)); - $this->assertEquals('Roman B.', $result[0]['name']); + self::assertEquals(1, count($result)); + self::assertEquals('Roman B.', $result[0]['name']); $this->_em->clear(); @@ -197,7 +197,7 @@ public function testGroupByMultipleFields(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); $this->_em->clear(); @@ -227,7 +227,7 @@ public function testDeleteAs(): void $dql = 'SELECT count(p) FROM Doctrine\Tests\Models\Company\CompanyEmployee p'; $result = $this->_em->createQuery($dql)->getSingleScalarResult(); - $this->assertEquals(0, $result); + self::assertEquals(0, $result); } public function generateFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 24bb66da0f9..addb7f3fdd6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -45,45 +45,45 @@ public function testBasicUnitsOfWorkWithOneToManyAssociation(): void $this->_em->flush(); - $this->assertTrue(is_numeric($user->id)); - $this->assertTrue($this->_em->contains($user)); + self::assertTrue(is_numeric($user->id)); + self::assertTrue($this->_em->contains($user)); // Read $user2 = $this->_em->find(CmsUser::class, $user->id); - $this->assertTrue($user === $user2); + self::assertTrue($user === $user2); // Add a phonenumber $ph = new CmsPhonenumber(); $ph->phonenumber = '12345'; $user->addPhonenumber($ph); $this->_em->flush(); - $this->assertTrue($this->_em->contains($ph)); - $this->assertTrue($this->_em->contains($user)); + self::assertTrue($this->_em->contains($ph)); + self::assertTrue($this->_em->contains($user)); // Update name $user->name = 'guilherme'; $this->_em->flush(); - $this->assertEquals('guilherme', $user->name); + self::assertEquals('guilherme', $user->name); // Add another phonenumber $ph2 = new CmsPhonenumber(); $ph2->phonenumber = '6789'; $user->addPhonenumber($ph2); $this->_em->flush(); - $this->assertTrue($this->_em->contains($ph2)); + self::assertTrue($this->_em->contains($ph2)); // Delete $this->_em->remove($user); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($user)); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); - $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); + self::assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($user)); + self::assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); + self::assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); $this->_em->flush(); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($user)); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); - $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user)); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph)); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph2)); + self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($user)); + self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); + self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user)); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph)); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph2)); } public function testOneToManyAssociationModification(): void @@ -110,8 +110,8 @@ public function testOneToManyAssociationModification(): void $this->_em->flush(); - $this->assertEquals(1, count($user->phonenumbers)); - $this->assertNull($ph1->user); + self::assertEquals(1, count($user->phonenumbers)); + self::assertNull($ph1->user); } public function testBasicOneToOne(): void @@ -138,7 +138,7 @@ public function testBasicOneToOne(): void 'SELECT user_id FROM cms_addresses WHERE id=?', [$address->id] )->fetchColumn(); - $this->assertTrue(is_numeric($userId)); + self::assertTrue(is_numeric($userId)); $this->_em->clear(); @@ -147,8 +147,8 @@ public function testBasicOneToOne(): void ->getSingleResult(); // Address has been eager-loaded because it cant be lazy - $this->assertInstanceOf(CmsAddress::class, $user2->address); - $this->assertNotInstanceOf(Proxy::class, $user2->address); + self::assertInstanceOf(CmsAddress::class, $user2->address); + self::assertNotInstanceOf(Proxy::class, $user2->address); } /** @@ -161,15 +161,15 @@ public function testRemove(): void $user->username = 'gblanco'; $user->status = 'developer'; - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); $this->_em->persist($user); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_MANAGED'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_MANAGED'); $this->_em->remove($user); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); $this->_em->persist($user); $this->_em->flush(); @@ -177,12 +177,12 @@ public function testRemove(): void $this->_em->remove($user); - $this->assertEquals(UnitOfWork::STATE_REMOVED, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_REMOVED'); + self::assertEquals(UnitOfWork::STATE_REMOVED, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_REMOVED'); $this->_em->flush(); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), 'State should be UnitOfWork::STATE_NEW'); - $this->assertNull($this->_em->find(CmsUser::class, $id)); + self::assertNull($this->_em->find(CmsUser::class, $id)); } public function testOneToManyOrphanRemoval(): void @@ -203,18 +203,18 @@ public function testOneToManyOrphanRemoval(): void $this->_em->flush(); $user->getPhonenumbers()->remove(0); - $this->assertEquals(2, count($user->getPhonenumbers())); + self::assertEquals(2, count($user->getPhonenumbers())); $this->_em->flush(); // Check that there are just 2 phonenumbers left $count = $this->_em->getConnection()->fetchColumn('SELECT COUNT(*) FROM cms_phonenumbers'); - $this->assertEquals(2, $count); // only 2 remaining + self::assertEquals(2, $count); // only 2 remaining // check that clear() removes the others via orphan removal $user->getPhonenumbers()->clear(); $this->_em->flush(); - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_phonenumbers')); + self::assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_phonenumbers')); } public function testBasicQuery(): void @@ -230,10 +230,10 @@ public function testBasicQuery(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('gblanco', $users[0]->username); - $this->assertEquals('developer', $users[0]->status); + self::assertEquals(1, count($users)); + self::assertEquals('Guilherme', $users[0]->name); + self::assertEquals('gblanco', $users[0]->username); + self::assertEquals('developer', $users[0]->status); //$this->assertNull($users[0]->phonenumbers); //$this->assertNull($users[0]->articles); @@ -243,19 +243,19 @@ public function testBasicQuery(): void $usersArray = $query->getArrayResult(); - $this->assertTrue(is_array($usersArray)); - $this->assertEquals(1, count($usersArray)); - $this->assertEquals('Guilherme', $usersArray[0]['name']); - $this->assertEquals('gblanco', $usersArray[0]['username']); - $this->assertEquals('developer', $usersArray[0]['status']); + self::assertTrue(is_array($usersArray)); + self::assertEquals(1, count($usersArray)); + self::assertEquals('Guilherme', $usersArray[0]['name']); + self::assertEquals('gblanco', $usersArray[0]['username']); + self::assertEquals('developer', $usersArray[0]['status']); $usersScalar = $query->getScalarResult(); - $this->assertTrue(is_array($usersScalar)); - $this->assertEquals(1, count($usersScalar)); - $this->assertEquals('Guilherme', $usersScalar[0]['u_name']); - $this->assertEquals('gblanco', $usersScalar[0]['u_username']); - $this->assertEquals('developer', $usersScalar[0]['u_status']); + self::assertTrue(is_array($usersScalar)); + self::assertEquals(1, count($usersScalar)); + self::assertEquals('Guilherme', $usersScalar[0]['u_name']); + self::assertEquals('gblanco', $usersScalar[0]['u_username']); + self::assertEquals('developer', $usersScalar[0]['u_status']); } public function testBasicOneToManyInnerJoin(): void @@ -271,7 +271,7 @@ public function testBasicOneToManyInnerJoin(): void $users = $query->getResult(); - $this->assertEquals(0, count($users)); + self::assertEquals(0, count($users)); } public function testBasicOneToManyLeftJoin(): void @@ -287,13 +287,13 @@ public function testBasicOneToManyLeftJoin(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('gblanco', $users[0]->username); - $this->assertEquals('developer', $users[0]->status); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->phonenumbers); - $this->assertTrue($users[0]->phonenumbers->isInitialized()); - $this->assertEquals(0, $users[0]->phonenumbers->count()); + self::assertEquals(1, count($users)); + self::assertEquals('Guilherme', $users[0]->name); + self::assertEquals('gblanco', $users[0]->username); + self::assertEquals('developer', $users[0]->status); + self::assertInstanceOf(PersistentCollection::class, $users[0]->phonenumbers); + self::assertTrue($users[0]->phonenumbers->isInitialized()); + self::assertEquals(0, $users[0]->phonenumbers->count()); } public function testBasicRefresh(): void @@ -308,9 +308,9 @@ public function testBasicRefresh(): void $user->status = 'mascot'; - $this->assertEquals('mascot', $user->status); + self::assertEquals('mascot', $user->status); $this->_em->refresh($user); - $this->assertEquals('developer', $user->status); + self::assertEquals('developer', $user->status); } /** @@ -339,10 +339,10 @@ public function testRefreshResetsCollection(): void $user->addPhonenumber($ph2); - $this->assertEquals(2, count($user->phonenumbers)); + self::assertEquals(2, count($user->phonenumbers)); $this->_em->refresh($user); - $this->assertEquals(1, count($user->phonenumbers)); + self::assertEquals(1, count($user->phonenumbers)); } /** @@ -371,14 +371,14 @@ public function testDqlRefreshResetsCollection(): void $user->addPhonenumber($ph2); - $this->assertEquals(2, count($user->phonenumbers)); + self::assertEquals(2, count($user->phonenumbers)); $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1'; $user = $this->_em->createQuery($dql) ->setParameter(1, $user->id) ->setHint(Query::HINT_REFRESH, true) ->getSingleResult(); - $this->assertEquals(1, count($user->phonenumbers)); + self::assertEquals(1, count($user->phonenumbers)); } /** @@ -414,7 +414,7 @@ public function testCreateEntityOfProxy(): void ->setParameter(1, $userId) ->getSingleResult(); - $this->assertEquals(1, count($user->phonenumbers)); + self::assertEquals(1, count($user->phonenumbers)); } public function testAddToCollectionDoesNotInitialize(): void @@ -434,19 +434,19 @@ public function testAddToCollectionDoesNotInitialize(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(3, $user->getPhonenumbers()->count()); + self::assertEquals(3, $user->getPhonenumbers()->count()); $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); $gblanco = $query->getSingleResult(); - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + self::assertFalse($gblanco->getPhonenumbers()->isInitialized()); $newPhone = new CmsPhonenumber(); $newPhone->phonenumber = 555; $gblanco->addPhonenumber($newPhone); - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + self::assertFalse($gblanco->getPhonenumbers()->isInitialized()); $this->_em->persist($gblanco); $this->_em->flush(); @@ -454,7 +454,7 @@ public function testAddToCollectionDoesNotInitialize(): void $query = $this->_em->createQuery("select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"); $gblanco2 = $query->getSingleResult(); - $this->assertEquals(4, $gblanco2->getPhonenumbers()->count()); + self::assertEquals(4, $gblanco2->getPhonenumbers()->count()); } public function testInitializeCollectionWithNewObjectsRetainsNewObjects(): void @@ -474,28 +474,28 @@ public function testInitializeCollectionWithNewObjectsRetainsNewObjects(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(3, $user->getPhonenumbers()->count()); + self::assertEquals(3, $user->getPhonenumbers()->count()); $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); $gblanco = $query->getSingleResult(); - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + self::assertFalse($gblanco->getPhonenumbers()->isInitialized()); $newPhone = new CmsPhonenumber(); $newPhone->phonenumber = 555; $gblanco->addPhonenumber($newPhone); - $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); - $this->assertEquals(4, $gblanco->getPhonenumbers()->count()); - $this->assertTrue($gblanco->getPhonenumbers()->isInitialized()); + self::assertFalse($gblanco->getPhonenumbers()->isInitialized()); + self::assertEquals(4, $gblanco->getPhonenumbers()->count()); + self::assertTrue($gblanco->getPhonenumbers()->isInitialized()); $this->_em->flush(); $this->_em->clear(); $query = $this->_em->createQuery("select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"); $gblanco2 = $query->getSingleResult(); - $this->assertEquals(4, $gblanco2->getPhonenumbers()->count()); + self::assertEquals(4, $gblanco2->getPhonenumbers()->count()); } public function testSetSetAssociationWithGetReference(): void @@ -515,8 +515,8 @@ public function testSetSetAssociationWithGetReference(): void $this->_em->flush(); $this->_em->clear(CmsAddress::class); - $this->assertFalse($this->_em->contains($address)); - $this->assertTrue($this->_em->contains($user)); + self::assertFalse($this->_em->contains($address)); + self::assertTrue($this->_em->contains($user)); // Assume we only got the identifier of the address and now want to attach // that address to the user without actually loading it, using getReference(). @@ -531,9 +531,9 @@ public function testSetSetAssociationWithGetReference(): void $query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a where u.username='gblanco'"); $gblanco = $query->getSingleResult(); - $this->assertInstanceOf(CmsUser::class, $gblanco); - $this->assertInstanceOf(CmsAddress::class, $gblanco->getAddress()); - $this->assertEquals('Berlin', $gblanco->getAddress()->getCity()); + self::assertInstanceOf(CmsUser::class, $gblanco); + self::assertInstanceOf(CmsAddress::class, $gblanco->getAddress()); + self::assertEquals('Berlin', $gblanco->getAddress()->getCity()); } public function testOneToManyCascadeRemove(): void @@ -561,12 +561,12 @@ public function testOneToManyCascadeRemove(): void $this->_em->clear(); - $this->assertEquals(0, $this->_em->createQuery( + self::assertEquals(0, $this->_em->createQuery( 'select count(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p' ) ->getSingleScalarResult()); - $this->assertEquals(0, $this->_em->createQuery( + self::assertEquals(0, $this->_em->createQuery( 'select count(u.id) from Doctrine\Tests\Models\CMS\CmsUser u' ) ->getSingleScalarResult()); @@ -594,10 +594,10 @@ public function testTextColumnSaveAndRetrieve(): void // test find() with leading backslash at the same time $articleNew = $this->_em->find('\Doctrine\Tests\Models\CMS\CmsArticle', $articleId); - $this->assertTrue($this->_em->contains($articleNew)); - $this->assertEquals('Lorem ipsum dolor sunt.', $articleNew->text); + self::assertTrue($this->_em->contains($articleNew)); + self::assertEquals('Lorem ipsum dolor sunt.', $articleNew->text); - $this->assertNotSame($article, $articleNew); + self::assertNotSame($article, $articleNew); $articleNew->text = 'Lorem ipsum dolor sunt. And stuff!'; @@ -605,8 +605,8 @@ public function testTextColumnSaveAndRetrieve(): void $this->_em->clear(); $articleNew = $this->_em->find(CmsArticle::class, $articleId); - $this->assertEquals('Lorem ipsum dolor sunt. And stuff!', $articleNew->text); - $this->assertTrue($this->_em->contains($articleNew)); + self::assertEquals('Lorem ipsum dolor sunt. And stuff!', $articleNew->text); + self::assertTrue($this->_em->contains($articleNew)); } public function testFlushDoesNotIssueUnnecessaryUpdates(): void @@ -640,15 +640,15 @@ public function testFlushDoesNotIssueUnnecessaryUpdates(): void $query = $this->_em->createQuery('select u,a,ad from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a join u.address ad'); $user2 = $query->getSingleResult(); - $this->assertEquals(1, count($user2->articles)); - $this->assertInstanceOf(CmsAddress::class, $user2->address); + self::assertEquals(1, count($user2->articles)); + self::assertInstanceOf(CmsAddress::class, $user2->address); $oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); $debugStack = new DebugStack(); $this->_em->getConnection()->getConfiguration()->setSQLLogger($debugStack); $this->_em->flush(); - $this->assertEquals(0, count($debugStack->queries)); + self::assertEquals(0, count($debugStack->queries)); $this->_em->getConnection()->getConfiguration()->setSQLLogger($oldLogger); } @@ -671,7 +671,7 @@ public function testRemoveEntityByReference(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_users')); + self::assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_users')); //$this->_em->getConnection()->getConfiguration()->setSQLLogger(null); } @@ -702,12 +702,12 @@ public function testQueryEntityByReference(): void ->setParameter('user', $userRef) ->getSingleResult(); - $this->assertInstanceOf(Proxy::class, $address2->getUser()); - $this->assertTrue($userRef === $address2->getUser()); - $this->assertFalse($userRef->__isInitialized__); - $this->assertEquals('Germany', $address2->country); - $this->assertEquals('Berlin', $address2->city); - $this->assertEquals('12345', $address2->zip); + self::assertInstanceOf(Proxy::class, $address2->getUser()); + self::assertTrue($userRef === $address2->getUser()); + self::assertFalse($userRef->__isInitialized__); + self::assertEquals('Germany', $address2->country); + self::assertEquals('Berlin', $address2->city); + self::assertEquals('12345', $address2->zip); } public function testOneToOneNullUpdate(): void @@ -728,12 +728,12 @@ public function testOneToOneNullUpdate(): void $this->_em->persist($user); $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select 1 from cms_addresses where user_id = ' . $user->id)); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select 1 from cms_addresses where user_id = ' . $user->id)); $address->user = null; $this->_em->flush(); - $this->assertNotEquals(1, $this->_em->getConnection()->fetchColumn('select 1 from cms_addresses where user_id = ' . $user->id)); + self::assertNotEquals(1, $this->_em->getConnection()->fetchColumn('select 1 from cms_addresses where user_id = ' . $user->id)); } /** @@ -840,14 +840,14 @@ public function testOneToOneOrphanRemoval(): void $this->_em->flush(); - $this->assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); + self::assertEquals(0, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); // check orphan removal through replacement $user->address = $address; $address->user = $user; $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); // remove $address to free up unique key id $this->_em->remove($address); @@ -862,7 +862,7 @@ public function testOneToOneOrphanRemoval(): void $user->address = $newAddress; $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from cms_addresses')); } public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void @@ -877,15 +877,15 @@ public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void $this->_em->clear(); $user = $this->_em->getPartialReference(CmsUser::class, $userId); - $this->assertTrue($this->_em->contains($user)); - $this->assertNull($user->getName()); - $this->assertEquals($userId, $user->id); + self::assertTrue($this->_em->contains($user)); + self::assertNull($user->getName()); + self::assertEquals($userId, $user->id); $user->name = 'Stephan'; $this->_em->flush(); $this->_em->clear(); - $this->assertEquals('Benjamin E.', $this->_em->find(get_class($user), $userId)->name); + self::assertEquals('Benjamin E.', $this->_em->find(get_class($user), $userId)->name); } public function testMergePersistsNewEntities(): void @@ -896,19 +896,19 @@ public function testMergePersistsNewEntities(): void $user->status = 'active'; $managedUser = $this->_em->merge($user); - $this->assertEquals('beberlei', $managedUser->username); - $this->assertEquals('Benjamin E.', $managedUser->name); - $this->assertEquals('active', $managedUser->status); + self::assertEquals('beberlei', $managedUser->username); + self::assertEquals('Benjamin E.', $managedUser->name); + self::assertEquals('active', $managedUser->status); - $this->assertTrue($user !== $managedUser); - $this->assertTrue($this->_em->contains($managedUser)); + self::assertTrue($user !== $managedUser); + self::assertTrue($this->_em->contains($managedUser)); $this->_em->flush(); $userId = $managedUser->id; $this->_em->clear(); $user2 = $this->_em->find(get_class($managedUser), $userId); - $this->assertInstanceOf(CmsUser::class, $user2); + self::assertInstanceOf(CmsUser::class, $user2); } public function testMergeNonPersistedProperties(): void @@ -921,21 +921,21 @@ public function testMergeNonPersistedProperties(): void $user->nonPersistedPropertyObject = new CmsPhonenumber(); $managedUser = $this->_em->merge($user); - $this->assertEquals('test', $managedUser->nonPersistedProperty); - $this->assertSame($user->nonPersistedProperty, $managedUser->nonPersistedProperty); - $this->assertSame($user->nonPersistedPropertyObject, $managedUser->nonPersistedPropertyObject); + self::assertEquals('test', $managedUser->nonPersistedProperty); + self::assertSame($user->nonPersistedProperty, $managedUser->nonPersistedProperty); + self::assertSame($user->nonPersistedPropertyObject, $managedUser->nonPersistedPropertyObject); - $this->assertTrue($user !== $managedUser); - $this->assertTrue($this->_em->contains($managedUser)); + self::assertTrue($user !== $managedUser); + self::assertTrue($this->_em->contains($managedUser)); $this->_em->flush(); $userId = $managedUser->id; $this->_em->clear(); $user2 = $this->_em->find(get_class($managedUser), $userId); - $this->assertNull($user2->nonPersistedProperty); - $this->assertNull($user2->nonPersistedPropertyObject); - $this->assertEquals('active', $user2->status); + self::assertNull($user2->nonPersistedProperty); + self::assertNull($user2->nonPersistedPropertyObject); + self::assertEquals('active', $user2->status); } public function testMergeThrowsExceptionIfEntityWithGeneratedIdentifierDoesNotExist(): void @@ -976,7 +976,7 @@ public function testOneToOneMergeSetNull(): void $this->_em->flush(); $this->_em->clear(); - $this->assertNull($this->_em->find(get_class($ph), $ph->phonenumber)->getUser()); + self::assertNull($this->_em->find(get_class($ph), $ph->phonenumber)->getUser()); } /** @@ -1005,9 +1005,9 @@ public function testManyToOneFetchModeQuery(): void ->setParameter(1, $article->id) ->setFetchMode(CmsArticle::class, 'user', ClassMetadata::FETCH_EAGER) ->getSingleResult(); - $this->assertInstanceOf(Proxy::class, $article->user, 'It IS a proxy, ...'); - $this->assertTrue($article->user->__isInitialized__, '...but its initialized!'); - $this->assertEquals($qc + 2, $this->getCurrentQueryCount()); + self::assertInstanceOf(Proxy::class, $article->user, 'It IS a proxy, ...'); + self::assertTrue($article->user->__isInitialized__, '...but its initialized!'); + self::assertEquals($qc + 2, $this->getCurrentQueryCount()); } /** @@ -1049,14 +1049,14 @@ public function testClearWithEntityName(): void $this->_em->clear(CmsUser::class); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article2)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article2)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); $this->_em->clear(); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); } public function testFlushManyExplicitEntities(): void @@ -1084,10 +1084,10 @@ public function testFlushManyExplicitEntities(): void $this->_em->flush([$userA, $userB]); $this->_em->refresh($userC); - $this->assertTrue($userA->id > 0, 'user a has an id'); - $this->assertTrue($userB->id > 0, 'user b has an id'); - $this->assertTrue($userC->id > 0, 'user c has an id'); - $this->assertEquals('UserC', $userC->name, 'name has not changed because we did not flush it'); + self::assertTrue($userA->id > 0, 'user a has an id'); + self::assertTrue($userB->id > 0, 'user b has an id'); + self::assertTrue($userC->id > 0, 'user c has an id'); + self::assertEquals('UserC', $userC->name, 'name has not changed because we did not flush it'); } /** @@ -1108,7 +1108,7 @@ public function testFlushSingleManagedEntity(): void $this->_em->clear(); $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals('administrator', $user->status); + self::assertEquals('administrator', $user->status); } /** @@ -1150,8 +1150,8 @@ public function testFlushSingleAndNewEntity(): void $this->_em->persist($otherUser); $this->_em->flush($user); - $this->assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); - $this->assertTrue($otherUser->id > 0, 'other user has an id'); + self::assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); + self::assertTrue($otherUser->id > 0, 'other user has an id'); } /** @@ -1177,8 +1177,8 @@ public function testFlushAndCascadePersist(): void $this->_em->flush($user); - $this->assertTrue($this->_em->contains($address), 'Other user is contained in EntityManager'); - $this->assertTrue($address->id > 0, 'other user has an id'); + self::assertTrue($this->_em->contains($address), 'Other user is contained in EntityManager'); + self::assertTrue($address->id > 0, 'other user has an id'); } /** @@ -1227,7 +1227,7 @@ public function testFlushSingleNewEntityThenRemove(): void $this->_em->flush($user); $this->_em->clear(); - $this->assertNull($this->_em->find(get_class($user), $userId)); + self::assertNull($this->_em->find(get_class($user), $userId)); } /** @@ -1254,8 +1254,8 @@ public function testProxyIsIgnored(): void $this->_em->persist($otherUser); $this->_em->flush($user); - $this->assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); - $this->assertTrue($otherUser->id > 0, 'other user has an id'); + self::assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); + self::assertTrue($otherUser->id > 0, 'other user has an id'); } /** @@ -1284,7 +1284,7 @@ public function testFlushSingleSaveOnlySingle(): void $this->_em->clear(); $user2 = $this->_em->find(get_class($user2), $user2->id); - $this->assertEquals('developer', $user2->status); + self::assertEquals('developer', $user2->status); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php index 580eeb1f698..1bf30b98862 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php @@ -67,11 +67,11 @@ public function testOneToOneAssocToBaseTypeBidirectional(): void $related2 = $this->_em->find(CTIRelated::class, $relatedId); - $this->assertInstanceOf(CTIRelated::class, $related2); - $this->assertInstanceOf(CTIChild::class, $related2->getCTIParent()); - $this->assertEquals('hello', $related2->getCTIParent()->getData()); + self::assertInstanceOf(CTIRelated::class, $related2); + self::assertInstanceOf(CTIChild::class, $related2->getCTIParent()); + self::assertEquals('hello', $related2->getCTIParent()->getData()); - $this->assertSame($related2, $related2->getCTIParent()->getRelated()); + self::assertSame($related2, $related2->getCTIParent()->getRelated()); } public function testManyToManyToCTIHierarchy(): void @@ -89,10 +89,10 @@ public function testManyToManyToCTIHierarchy(): void $this->_em->clear(); $mmrel2 = $this->_em->find(get_class($mmrel), $mmrel->getId()); - $this->assertFalse($mmrel2->getCTIChildren()->isInitialized()); - $this->assertEquals(1, count($mmrel2->getCTIChildren())); - $this->assertTrue($mmrel2->getCTIChildren()->isInitialized()); - $this->assertInstanceOf(CTIChild::class, $mmrel2->getCTIChildren()->get(0)); + self::assertFalse($mmrel2->getCTIChildren()->isInitialized()); + self::assertEquals(1, count($mmrel2->getCTIChildren())); + self::assertTrue($mmrel2->getCTIChildren()->isInitialized()); + self::assertInstanceOf(CTIChild::class, $mmrel2->getCTIChildren()->get(0)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index 660a1a02006..4e7c2ace36d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -58,14 +58,14 @@ public function testCRUD(): void $entities = $query->getResult(); - $this->assertCount(2, $entities); - $this->assertInstanceOf(CompanyPerson::class, $entities[0]); - $this->assertInstanceOf(CompanyEmployee::class, $entities[1]); - $this->assertTrue(is_numeric($entities[0]->getId())); - $this->assertTrue(is_numeric($entities[1]->getId())); - $this->assertEquals('Roman S. Borschel', $entities[0]->getName()); - $this->assertEquals('Guilherme Blanco', $entities[1]->getName()); - $this->assertEquals(100000, $entities[1]->getSalary()); + self::assertCount(2, $entities); + self::assertInstanceOf(CompanyPerson::class, $entities[0]); + self::assertInstanceOf(CompanyEmployee::class, $entities[1]); + self::assertTrue(is_numeric($entities[0]->getId())); + self::assertTrue(is_numeric($entities[1]->getId())); + self::assertEquals('Roman S. Borschel', $entities[0]->getName()); + self::assertEquals('Guilherme Blanco', $entities[1]->getName()); + self::assertEquals(100000, $entities[1]->getSalary()); $this->_em->clear(); @@ -79,7 +79,7 @@ public function testCRUD(): void self::assertCount(1, $entities); self::assertInstanceOf(CompanyEmployee::class, $entities[0]); - $this->assertTrue(is_numeric($entities[0]->getId())); + self::assertTrue(is_numeric($entities[0]->getId())); self::assertEquals('Guilherme Blanco', $entities[0]->getName()); self::assertEquals(100000, $entities[0]->getSalary()); @@ -90,8 +90,8 @@ public function testCRUD(): void $this->_em->clear(); $guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(['name' => 'Guilherme Blanco']); - $this->assertInstanceOf(CompanyEmployee::class, $guilherme); - $this->assertEquals('Guilherme Blanco', $guilherme->getName()); + self::assertInstanceOf(CompanyEmployee::class, $guilherme); + self::assertEquals('Guilherme Blanco', $guilherme->getName()); $this->_em->clear(); @@ -101,11 +101,11 @@ public function testCRUD(): void $query->setParameter(3, 100000); $query->getSQL(); $numUpdated = $query->execute(); - $this->assertEquals(1, $numUpdated); + self::assertEquals(1, $numUpdated); $query = $this->_em->createQuery('delete from ' . CompanyPerson::class . ' p'); $numDeleted = $query->execute(); - $this->assertEquals(2, $numDeleted); + self::assertEquals(2, $numDeleted); } public function testMultiLevelUpdateAndFind(): void @@ -128,11 +128,11 @@ public function testMultiLevelUpdateAndFind(): void $manager = $this->_em->find(CompanyManager::class, $manager->getId()); - $this->assertInstanceOf(CompanyManager::class, $manager); - $this->assertEquals('Roman B.', $manager->getName()); - $this->assertEquals(119000, $manager->getSalary()); - $this->assertEquals('CEO', $manager->getTitle()); - $this->assertTrue(is_numeric($manager->getId())); + self::assertInstanceOf(CompanyManager::class, $manager); + self::assertEquals('Roman B.', $manager->getName()); + self::assertEquals(119000, $manager->getSalary()); + self::assertEquals('CEO', $manager->getTitle()); + self::assertTrue(is_numeric($manager->getId())); } public function testFindOnBaseClass(): void @@ -149,11 +149,11 @@ public function testFindOnBaseClass(): void $person = $this->_em->find(CompanyPerson::class, $manager->getId()); - $this->assertInstanceOf(CompanyManager::class, $person); - $this->assertEquals('Roman S. Borschel', $person->getName()); - $this->assertEquals(100000, $person->getSalary()); - $this->assertEquals('CTO', $person->getTitle()); - $this->assertTrue(is_numeric($person->getId())); + self::assertInstanceOf(CompanyManager::class, $person); + self::assertEquals('Roman S. Borschel', $person->getName()); + self::assertEquals(100000, $person->getSalary()); + self::assertEquals('CTO', $person->getTitle()); + self::assertTrue(is_numeric($person->getId())); } public function testSelfReferencingOneToOne(): void @@ -168,8 +168,8 @@ public function testSelfReferencingOneToOne(): void $wife->setName('Mary Smith'); $wife->setSpouse($manager); - $this->assertSame($manager, $wife->getSpouse()); - $this->assertSame($wife, $manager->getSpouse()); + self::assertSame($manager, $wife->getSpouse()); + self::assertSame($wife, $manager->getSpouse()); $this->_em->persist($manager); $this->_em->persist($wife); @@ -179,12 +179,12 @@ public function testSelfReferencingOneToOne(): void $query = $this->_em->createQuery('select p, s from ' . CompanyPerson::class . ' p join p.spouse s where p.name=\'Mary Smith\''); $result = $query->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyPerson::class, $result[0]); - $this->assertEquals('Mary Smith', $result[0]->getName()); - $this->assertInstanceOf(CompanyEmployee::class, $result[0]->getSpouse()); - $this->assertEquals('John Smith', $result[0]->getSpouse()->getName()); - $this->assertSame($result[0], $result[0]->getSpouse()->getSpouse()); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyPerson::class, $result[0]); + self::assertEquals('Mary Smith', $result[0]->getName()); + self::assertInstanceOf(CompanyEmployee::class, $result[0]->getSpouse()); + self::assertEquals('John Smith', $result[0]->getSpouse()->getName()); + self::assertSame($result[0], $result[0]->getSpouse()->getSpouse()); $this->_em->clear(); @@ -201,8 +201,8 @@ public function testSelfReferencingManyToMany(): void $person1->addFriend($person2); - $this->assertCount(1, $person1->getFriends()); - $this->assertCount(1, $person2->getFriends()); + self::assertCount(1, $person1->getFriends()); + self::assertCount(1, $person2->getFriends()); $this->_em->persist($person1); $this->_em->persist($person2); @@ -215,12 +215,12 @@ public function testSelfReferencingManyToMany(): void $query->setParameter(1, 'Roman'); $result = $query->getResult(); - $this->assertCount(1, $result); - $this->assertCount(1, $result[0]->getFriends()); - $this->assertEquals('Roman', $result[0]->getName()); + self::assertCount(1, $result); + self::assertCount(1, $result[0]->getFriends()); + self::assertEquals('Roman', $result[0]->getName()); $friends = $result[0]->getFriends(); - $this->assertEquals('Jonathan', $friends[0]->getName()); + self::assertEquals('Jonathan', $friends[0]->getName()); } public function testLazyLoading1(): void @@ -244,21 +244,21 @@ public function testLazyLoading1(): void $result = $q->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyOrganization::class, $result[0]); - $this->assertNull($result[0]->getMainEvent()); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyOrganization::class, $result[0]); + self::assertNull($result[0]->getMainEvent()); $events = $result[0]->getEvents(); - $this->assertInstanceOf(PersistentCollection::class, $events); - $this->assertFalse($events->isInitialized()); + self::assertInstanceOf(PersistentCollection::class, $events); + self::assertFalse($events->isInitialized()); - $this->assertCount(2, $events); + self::assertCount(2, $events); if ($events[0] instanceof CompanyAuction) { - $this->assertInstanceOf(CompanyRaffle::class, $events[1]); + self::assertInstanceOf(CompanyRaffle::class, $events[1]); } else { - $this->assertInstanceOf(CompanyRaffle::class, $events[0]); - $this->assertInstanceOf(CompanyAuction::class, $events[1]); + self::assertInstanceOf(CompanyRaffle::class, $events[0]); + self::assertInstanceOf(CompanyAuction::class, $events[1]); } $this->_em->clear(); @@ -281,8 +281,8 @@ public function testLazyLoading2(): void $q->setParameter(1, $event1->getId()); $result = $q->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyAuction::class, $result[0], sprintf('Is of class %s', get_class($result[0]))); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyAuction::class, $result[0], sprintf('Is of class %s', get_class($result[0]))); $this->_em->clear(); @@ -295,13 +295,13 @@ public function testLazyLoading2(): void $result = $q->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyOrganization::class, $result[0]); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyOrganization::class, $result[0]); $mainEvent = $result[0]->getMainEvent(); // mainEvent should have been loaded because it can't be lazy - $this->assertInstanceOf(CompanyAuction::class, $mainEvent); - $this->assertNotInstanceOf(Proxy::class, $mainEvent); + self::assertInstanceOf(CompanyAuction::class, $mainEvent); + self::assertNotInstanceOf(Proxy::class, $mainEvent); $this->_em->clear(); @@ -319,7 +319,7 @@ public function testBulkUpdateIssueDDC368(): void $query = $this->_em->createQuery('SELECT count(p.id) FROM ' . CompanyEmployee::class . ' p WHERE p.salary = 1'); $result = $query->getResult(); - $this->assertGreaterThan(0, count($result)); + self::assertGreaterThan(0, count($result)); $this->_em->clear(); @@ -365,7 +365,7 @@ public function testDeleteJoinTableRecords(): void $this->_em->remove($employee1); $this->_em->flush(); - $this->assertNull($this->_em->find(get_class($employee1), $employee1Id)); + self::assertNull($this->_em->find(get_class($employee1), $employee1Id)); } /** @@ -393,8 +393,8 @@ public function testQueryForInheritedSingleValuedAssociation(): void ->setParameter(1, $person->getId()) ->getSingleResult(); - $this->assertEquals($manager->getId(), $dqlManager->getId()); - $this->assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); + self::assertEquals($manager->getId(), $dqlManager->getId()); + self::assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); } /** @@ -421,12 +421,12 @@ public function testFindByAssociation(): void $repos = $this->_em->getRepository(CompanyManager::class); $pmanager = $repos->findOneBy(['spouse' => $person->getId()]); - $this->assertEquals($manager->getId(), $pmanager->getId()); + self::assertEquals($manager->getId(), $pmanager->getId()); $repos = $this->_em->getRepository(CompanyPerson::class); $pmanager = $repos->findOneBy(['spouse' => $person->getId()]); - $this->assertEquals($manager->getId(), $pmanager->getId()); + self::assertEquals($manager->getId(), $pmanager->getId()); } /** @@ -445,13 +445,13 @@ public function testGetReferenceEntityWithSubclasses(): void $this->_em->clear(); $ref = $this->_em->getReference(CompanyPerson::class, $manager->getId()); - $this->assertNotInstanceOf(Proxy::class, $ref, 'Cannot Request a proxy from a class that has subclasses.'); - $this->assertInstanceOf(CompanyPerson::class, $ref); - $this->assertInstanceOf(CompanyEmployee::class, $ref, 'Direct fetch of the reference has to load the child class Employee directly.'); + self::assertNotInstanceOf(Proxy::class, $ref, 'Cannot Request a proxy from a class that has subclasses.'); + self::assertInstanceOf(CompanyPerson::class, $ref); + self::assertInstanceOf(CompanyEmployee::class, $ref, 'Direct fetch of the reference has to load the child class Employee directly.'); $this->_em->clear(); $ref = $this->_em->getReference(CompanyManager::class, $manager->getId()); - $this->assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); + self::assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); } /** @@ -477,7 +477,7 @@ public function testGetSubClassManyToManyCollection(): void $manager = $this->_em->find(CompanyManager::class, $manager->getId()); - $this->assertCount(1, $manager->getFriends()); + self::assertCount(1, $manager->getFriends()); } /** @@ -491,12 +491,12 @@ public function testExistsSubclass(): void $manager->setTitle('Awesome!'); $manager->setDepartment('IT'); - $this->assertFalse($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); + self::assertFalse($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); $this->_em->persist($manager); $this->_em->flush(); - $this->assertTrue($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); + self::assertTrue($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); } /** @@ -517,12 +517,12 @@ public function testMatching(): void $users = $repository->matching(new Criteria( Criteria::expr()->eq('department', 'IT') )); - $this->assertCount(1, $users); + self::assertCount(1, $users); $repository = $this->_em->getRepository(CompanyManager::class); $users = $repository->matching(new Criteria( Criteria::expr()->eq('department', 'IT') )); - $this->assertCount(1, $users); + self::assertCount(1, $users); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php b/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php index 41eda5658ab..ff6880853a4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php @@ -20,7 +20,7 @@ public function testEventIsCalledOnClear(): void $this->_em->clear(); - $this->assertTrue($listener->called); + self::assertTrue($listener->called); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php index 53740b304a7..1bd16890d0a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -55,10 +55,10 @@ public function testPersistCompositePkEntity(): void $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]); - $this->assertInstanceOf(NavPointOfInterest::class, $poi); - $this->assertEquals(100, $poi->getLat()); - $this->assertEquals(200, $poi->getLong()); - $this->assertEquals('Brandenburger Tor', $poi->getName()); + self::assertInstanceOf(NavPointOfInterest::class, $poi); + self::assertEquals(100, $poi->getLat()); + self::assertEquals(200, $poi->getLong()); + self::assertEquals('Brandenburger Tor', $poi->getName()); } /** @@ -96,9 +96,9 @@ public function testIdentityFunctionWithCompositePrimaryKey(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(1, $result); - $this->assertEquals(200, $result[0]['long']); - $this->assertEquals(100, $result[0]['lat']); + self::assertCount(1, $result); + self::assertEquals(200, $result[0]['long']); + self::assertEquals(100, $result[0]['lat']); $this->_em->clear(); @@ -112,7 +112,7 @@ public function testManyToManyCompositeRelation(): void $tour = $this->_em->find(NavTour::class, $tour->getId()); - $this->assertEquals(1, count($tour->getPointOfInterests())); + self::assertEquals(1, count($tour->getPointOfInterests())); } public function testCompositeDqlEagerFetching(): void @@ -131,13 +131,13 @@ public function testCompositeDqlEagerFetching(): void $pois = $tours[0]->getPointOfInterests(); - $this->assertEquals(1, count($pois)); - $this->assertEquals('Brandenburger Tor', $pois[0]->getName()); + self::assertEquals(1, count($pois)); + self::assertEquals('Brandenburger Tor', $pois[0]->getName()); } public function testCompositeCollectionMemberExpression(): void { - $this->markTestSkipped('How to test this?'); + self::markTestSkipped('How to test this?'); $this->putGermanysBrandenburderTor(); $this->putTripAroundEurope(); @@ -147,7 +147,7 @@ public function testCompositeCollectionMemberExpression(): void $tours = $this->_em->createQuery($dql) ->getResult(); - $this->assertEquals(1, count($tours)); + self::assertEquals(1, count($tours)); $this->_em->clear(); @@ -189,6 +189,6 @@ public function testDeleteCompositePersistentCollection(): void $this->_em->clear(); $poi = $this->_em->find(NavPointOfInterest::class, ['lat' => 100, 'long' => 200]); - $this->assertEquals(0, count($poi->getVisitors())); + self::assertEquals(0, count($poi->getVisitors())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php index 9a14da279e6..d143f97c6d2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php @@ -49,15 +49,15 @@ public function testFindByAbleToGetCompositeEntitiesWithMixedTypeIdentifiers(): $admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]); $names = $admin1NamesRepo->findBy(['admin1' => $admin1Rome]); - $this->assertCount(2, $names); + self::assertCount(2, $names); $name1 = $admin1NamesRepo->findOneBy(['admin1' => $admin1Rome, 'id' => 1]); $name2 = $admin1NamesRepo->findOneBy(['admin1' => $admin1Rome, 'id' => 2]); - $this->assertEquals(1, $name1->id); - $this->assertEquals('Roma', $name1->name); + self::assertEquals(1, $name1->id); + self::assertEquals('Roma', $name1->name); - $this->assertEquals(2, $name2->id); - $this->assertEquals('Rome', $name2->name); + self::assertEquals(2, $name2->id); + self::assertEquals('Rome', $name2->name); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php index 674da3cf899..11bde255131 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php @@ -48,8 +48,8 @@ public function testCustomFunctionDefinedWithCallback(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertSame($user, $users[0]); + self::assertEquals(1, count($users)); + self::assertSame($user, $users[0]); } public function testCustomFunctionOverride(): void @@ -66,7 +66,7 @@ public function testCustomFunctionOverride(): void $usersCount = $query->getSingleScalarResult(); - $this->assertEquals(1, $usersCount); + self::assertEquals(1, $usersCount); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php index 5ecf7448072..7cc731b81b5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php @@ -35,7 +35,7 @@ public function testFindByCustomIdObject(): void $result = $this->_em->find(CustomIdObjectTypeParent::class, $parent->id); - $this->assertSame($parent, $result); + self::assertSame($parent, $result); } /** @@ -60,8 +60,8 @@ public function testFetchJoinCustomIdObject(): void ) ->getResult(); - $this->assertCount(1, $result); - $this->assertSame($parent, $result[0]); + self::assertCount(1, $result); + self::assertSame($parent, $result[0]); } /** @@ -89,7 +89,7 @@ public function testFetchJoinWhereCustomIdObject(): void ->setParameter(1, $parent->children->first()->id) ->getResult(); - $this->assertCount(1, $result); - $this->assertSame($parent, $result[0]); + self::assertCount(1, $result); + self::assertSame($parent, $result[0]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index 4115db466d4..78ffda293ea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -35,7 +35,7 @@ protected function setUp(): void public function testIssue2059(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $user = new Table('ddc2059_user'); @@ -50,14 +50,14 @@ public function testIssue2059(): void $metadata = $this->convertToClassMetadata([$project, $user], []); - $this->assertTrue(isset($metadata['Ddc2059Project']->fieldMappings['user'])); - $this->assertTrue(isset($metadata['Ddc2059Project']->associationMappings['user2'])); + self::assertTrue(isset($metadata['Ddc2059Project']->fieldMappings['user'])); + self::assertTrue(isset($metadata['Ddc2059Project']->associationMappings['user2'])); } public function testLoadMetadataFromDatabase(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $table = new Table('dbdriver_foo'); @@ -69,26 +69,26 @@ public function testLoadMetadataFromDatabase(): void $metadatas = $this->extractClassMetadata(['DbdriverFoo']); - $this->assertArrayHasKey('DbdriverFoo', $metadatas); + self::assertArrayHasKey('DbdriverFoo', $metadatas); $metadata = $metadatas['DbdriverFoo']; - $this->assertArrayHasKey('id', $metadata->fieldMappings); - $this->assertEquals('id', $metadata->fieldMappings['id']['fieldName']); - $this->assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); - $this->assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); - - $this->assertArrayHasKey('bar', $metadata->fieldMappings); - $this->assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']); - $this->assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName'])); - $this->assertEquals('string', (string) $metadata->fieldMappings['bar']['type']); - $this->assertEquals(200, $metadata->fieldMappings['bar']['length']); - $this->assertTrue($metadata->fieldMappings['bar']['nullable']); + self::assertArrayHasKey('id', $metadata->fieldMappings); + self::assertEquals('id', $metadata->fieldMappings['id']['fieldName']); + self::assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); + self::assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); + + self::assertArrayHasKey('bar', $metadata->fieldMappings); + self::assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']); + self::assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName'])); + self::assertEquals('string', (string) $metadata->fieldMappings['bar']['type']); + self::assertEquals(200, $metadata->fieldMappings['bar']['length']); + self::assertTrue($metadata->fieldMappings['bar']['nullable']); } public function testLoadMetadataWithForeignKeyFromDatabase(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $tableB = new Table('dbdriver_bar'); @@ -107,36 +107,36 @@ public function testLoadMetadataWithForeignKeyFromDatabase(): void $metadatas = $this->extractClassMetadata(['DbdriverBar', 'DbdriverBaz']); - $this->assertArrayHasKey('DbdriverBaz', $metadatas); + self::assertArrayHasKey('DbdriverBaz', $metadatas); $bazMetadata = $metadatas['DbdriverBaz']; - $this->assertArrayNotHasKey('barId', $bazMetadata->fieldMappings, "The foreign Key field should not be inflected as 'barId' field, its an association."); - $this->assertArrayHasKey('id', $bazMetadata->fieldMappings); + self::assertArrayNotHasKey('barId', $bazMetadata->fieldMappings, "The foreign Key field should not be inflected as 'barId' field, its an association."); + self::assertArrayHasKey('id', $bazMetadata->fieldMappings); $bazMetadata->associationMappings = array_change_key_case($bazMetadata->associationMappings, CASE_LOWER); - $this->assertArrayHasKey('bar', $bazMetadata->associationMappings); - $this->assertEquals(ClassMetadataInfo::MANY_TO_ONE, $bazMetadata->associationMappings['bar']['type']); + self::assertArrayHasKey('bar', $bazMetadata->associationMappings); + self::assertEquals(ClassMetadataInfo::MANY_TO_ONE, $bazMetadata->associationMappings['bar']['type']); } public function testDetectManyToManyTables(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $metadatas = $this->extractClassMetadata(['CmsUsers', 'CmsGroups', 'CmsTags']); - $this->assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.'); - $this->assertArrayHasKey('CmsGroups', $metadatas, 'CmsGroups entity was not detected.'); - $this->assertArrayHasKey('CmsTags', $metadatas, 'CmsTags entity was not detected.'); + self::assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.'); + self::assertArrayHasKey('CmsGroups', $metadatas, 'CmsGroups entity was not detected.'); + self::assertArrayHasKey('CmsTags', $metadatas, 'CmsTags entity was not detected.'); - $this->assertEquals(3, count($metadatas['CmsUsers']->associationMappings)); - $this->assertArrayHasKey('group', $metadatas['CmsUsers']->associationMappings); - $this->assertEquals(1, count($metadatas['CmsGroups']->associationMappings)); - $this->assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); - $this->assertEquals(1, count($metadatas['CmsTags']->associationMappings)); - $this->assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); + self::assertEquals(3, count($metadatas['CmsUsers']->associationMappings)); + self::assertArrayHasKey('group', $metadatas['CmsUsers']->associationMappings); + self::assertEquals(1, count($metadatas['CmsGroups']->associationMappings)); + self::assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); + self::assertEquals(1, count($metadatas['CmsTags']->associationMappings)); + self::assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); } public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails(): void @@ -156,13 +156,13 @@ public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails(): void $metadatas = $this->convertToClassMetadata([$tableA, $tableB], [$tableMany]); - $this->assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), 'no association mappings should be detected.'); + self::assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), 'no association mappings should be detected.'); } public function testLoadMetadataFromDatabaseDetail(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $table = new Table('dbdriver_foo'); @@ -186,14 +186,14 @@ public function testLoadMetadataFromDatabaseDetail(): void $metadatas = $this->extractClassMetadata(['DbdriverFoo']); - $this->assertArrayHasKey('DbdriverFoo', $metadatas); + self::assertArrayHasKey('DbdriverFoo', $metadatas); $metadata = $metadatas['DbdriverFoo']; - $this->assertArrayHasKey('id', $metadata->fieldMappings); - $this->assertEquals('id', $metadata->fieldMappings['id']['fieldName']); - $this->assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); - $this->assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); + self::assertArrayHasKey('id', $metadata->fieldMappings); + self::assertEquals('id', $metadata->fieldMappings['id']['fieldName']); + self::assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); + self::assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); // FIXME: Condition here is fugly. // NOTE: PostgreSQL and SQL SERVER do not support UNSIGNED integer @@ -201,28 +201,28 @@ public function testLoadMetadataFromDatabaseDetail(): void ! $this->_em->getConnection()->getDatabasePlatform() instanceof PostgreSqlPlatform && ! $this->_em->getConnection()->getDatabasePlatform() instanceof SQLServerPlatform ) { - $this->assertArrayHasKey('columnUnsigned', $metadata->fieldMappings); - $this->assertTrue($metadata->fieldMappings['columnUnsigned']['options']['unsigned']); + self::assertArrayHasKey('columnUnsigned', $metadata->fieldMappings); + self::assertTrue($metadata->fieldMappings['columnUnsigned']['options']['unsigned']); } - $this->assertArrayHasKey('columnComment', $metadata->fieldMappings); - $this->assertEquals('test_comment', $metadata->fieldMappings['columnComment']['options']['comment']); + self::assertArrayHasKey('columnComment', $metadata->fieldMappings); + self::assertEquals('test_comment', $metadata->fieldMappings['columnComment']['options']['comment']); - $this->assertArrayHasKey('columnDefault', $metadata->fieldMappings); - $this->assertEquals('test_default', $metadata->fieldMappings['columnDefault']['options']['default']); + self::assertArrayHasKey('columnDefault', $metadata->fieldMappings); + self::assertEquals('test_default', $metadata->fieldMappings['columnDefault']['options']['default']); - $this->assertArrayHasKey('columnDecimal', $metadata->fieldMappings); - $this->assertEquals(4, $metadata->fieldMappings['columnDecimal']['precision']); - $this->assertEquals(3, $metadata->fieldMappings['columnDecimal']['scale']); + self::assertArrayHasKey('columnDecimal', $metadata->fieldMappings); + self::assertEquals(4, $metadata->fieldMappings['columnDecimal']['precision']); + self::assertEquals(3, $metadata->fieldMappings['columnDecimal']['scale']); - $this->assertTrue(! empty($metadata->table['indexes']['index1']['columns'])); - $this->assertEquals( + self::assertTrue(! empty($metadata->table['indexes']['index1']['columns'])); + self::assertEquals( ['column_index1', 'column_index2'], $metadata->table['indexes']['index1']['columns'] ); - $this->assertTrue(! empty($metadata->table['uniqueConstraints']['unique_index1']['columns'])); - $this->assertEquals( + self::assertTrue(! empty($metadata->table['uniqueConstraints']['unique_index1']['columns'])); + self::assertEquals( ['column_unique_index1', 'column_unique_index2'], $metadata->table['uniqueConstraints']['unique_index1']['columns'] ); diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php index bd8a44cbcb8..3e55ae9c179 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php @@ -63,7 +63,7 @@ protected function extractClassMetadata(array $classNames): array } if (count($metadatas) !== count($classNames)) { - $this->fail("Have not found all classes matching the names '" . implode(', ', $classNames) . "' only tables " . implode(', ', array_keys($metadatas))); + self::fail("Have not found all classes matching the names '" . implode(', ', $classNames) . "' only tables " . implode(', ', array_keys($metadatas))); } return $metadatas; diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index 26f474b1846..d2fd2794427 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -51,7 +51,7 @@ public function testSimpleDetachMerge(): void $user2 = $this->_em->getReference(get_class($user), $userId); $this->_em->flush(); - $this->assertFalse($user2->__isInitialized__); + self::assertFalse($user2->__isInitialized__); $a = new DefaultValueAddress(); $a->country = 'de'; @@ -63,13 +63,13 @@ public function testSimpleDetachMerge(): void $this->_em->persist($a); $this->_em->flush(); - $this->assertFalse($user2->__isInitialized__); + self::assertFalse($user2->__isInitialized__); $this->_em->clear(); $a2 = $this->_em->find(get_class($a), $a->id); - $this->assertInstanceOf(DefaultValueUser::class, $a2->getUser()); - $this->assertEquals($userId, $a2->getUser()->getId()); - $this->assertEquals('Poweruser', $a2->getUser()->type); + self::assertInstanceOf(DefaultValueUser::class, $a2->getUser()); + self::assertEquals($userId, $a2->getUser()->getId()); + self::assertEquals('Poweruser', $a2->getUser()->type); } /** @@ -86,14 +86,14 @@ public function testGetPartialReferenceWithDefaultValueNotEvaluatedInFlush(): vo $this->_em->clear(); $user = $this->_em->getPartialReference(DefaultValueUser::class, $user->id); - $this->assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); + self::assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); $this->_em->flush(); $this->_em->clear(); $user = $this->_em->find(DefaultValueUser::class, $user->id); - $this->assertEquals('Normaluser', $user->type); + self::assertEquals('Normaluser', $user->type); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index 03e9fcff7fa..a34c109fb58 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -40,15 +40,15 @@ public function testSimpleDetachMerge(): void $this->_em->clear(); // $user is now detached - $this->assertFalse($this->_em->contains($user)); + self::assertFalse($this->_em->contains($user)); $user->name = 'Roman B.'; $user2 = $this->_em->merge($user); - $this->assertFalse($user === $user2); - $this->assertTrue($this->_em->contains($user2)); - $this->assertEquals('Roman B.', $user2->name); + self::assertFalse($user === $user2); + self::assertTrue($this->_em->contains($user2)); + self::assertEquals('Roman B.', $user2->name); } public function testSerializeUnserializeModifyMerge(): void @@ -65,20 +65,20 @@ public function testSerializeUnserializeModifyMerge(): void $this->_em->persist($user); $this->_em->flush(); - $this->assertTrue($this->_em->contains($user)); - $this->assertTrue($user->phonenumbers->isInitialized()); + self::assertTrue($this->_em->contains($user)); + self::assertTrue($user->phonenumbers->isInitialized()); $serialized = serialize($user); $this->_em->clear(); - $this->assertFalse($this->_em->contains($user)); + self::assertFalse($this->_em->contains($user)); unset($user); $user = unserialize($serialized); - $this->assertEquals(1, count($user->getPhonenumbers()), 'Pre-Condition: 1 Phonenumber'); + self::assertEquals(1, count($user->getPhonenumbers()), 'Pre-Condition: 1 Phonenumber'); $ph2 = new CmsPhonenumber(); @@ -87,29 +87,29 @@ public function testSerializeUnserializeModifyMerge(): void $oldPhonenumbers = $user->getPhonenumbers(); - $this->assertEquals(2, count($oldPhonenumbers), 'Pre-Condition: 2 Phonenumbers'); - $this->assertFalse($this->_em->contains($user)); + self::assertEquals(2, count($oldPhonenumbers), 'Pre-Condition: 2 Phonenumbers'); + self::assertFalse($this->_em->contains($user)); $this->_em->persist($ph2); // Merge back in $user = $this->_em->merge($user); // merge cascaded to phonenumbers - $this->assertInstanceOf(CmsUser::class, $user->phonenumbers[0]->user); - $this->assertInstanceOf(CmsUser::class, $user->phonenumbers[1]->user); + self::assertInstanceOf(CmsUser::class, $user->phonenumbers[0]->user); + self::assertInstanceOf(CmsUser::class, $user->phonenumbers[1]->user); $im = $this->_em->getUnitOfWork()->getIdentityMap(); $this->_em->flush(); - $this->assertTrue($this->_em->contains($user), 'Failed to assert that merged user is contained inside EntityManager persistence context.'); + self::assertTrue($this->_em->contains($user), 'Failed to assert that merged user is contained inside EntityManager persistence context.'); $phonenumbers = $user->getPhonenumbers(); - $this->assertNotSame($oldPhonenumbers, $phonenumbers, 'Merge should replace the Detached Collection with a new PersistentCollection.'); - $this->assertEquals(2, count($phonenumbers), 'Failed to assert that two phonenumbers are contained in the merged users phonenumber collection.'); + self::assertNotSame($oldPhonenumbers, $phonenumbers, 'Merge should replace the Detached Collection with a new PersistentCollection.'); + self::assertEquals(2, count($phonenumbers), 'Failed to assert that two phonenumbers are contained in the merged users phonenumber collection.'); - $this->assertInstanceOf(CmsPhonenumber::class, $phonenumbers[1]); - $this->assertTrue($this->_em->contains($phonenumbers[1]), 'Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context.'); + self::assertInstanceOf(CmsPhonenumber::class, $phonenumbers[1]); + self::assertTrue($this->_em->contains($phonenumbers[1]), 'Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context.'); - $this->assertInstanceOf(CmsPhonenumber::class, $phonenumbers[0]); - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($phonenumbers[0])); - $this->assertTrue($this->_em->contains($phonenumbers[0]), 'Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context.'); + self::assertInstanceOf(CmsPhonenumber::class, $phonenumbers[0]); + self::assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($phonenumbers[0])); + self::assertTrue($this->_em->contains($phonenumbers[0]), 'Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context.'); } /** @@ -151,16 +151,16 @@ public function testUninitializedLazyAssociationsAreIgnoredOnMerge(): void $this->_em->clear(); $address2 = $this->_em->find(get_class($address), $address->id); - $this->assertInstanceOf(Proxy::class, $address2->user); - $this->assertFalse($address2->user->__isInitialized__); + self::assertInstanceOf(Proxy::class, $address2->user); + self::assertFalse($address2->user->__isInitialized__); $detachedAddress2 = unserialize(serialize($address2)); - $this->assertInstanceOf(Proxy::class, $detachedAddress2->user); - $this->assertFalse($detachedAddress2->user->__isInitialized__); + self::assertInstanceOf(Proxy::class, $detachedAddress2->user); + self::assertFalse($detachedAddress2->user->__isInitialized__); $managedAddress2 = $this->_em->merge($detachedAddress2); - $this->assertInstanceOf(Proxy::class, $managedAddress2->user); - $this->assertFalse($managedAddress2->user === $detachedAddress2->user); - $this->assertFalse($managedAddress2->user->__isInitialized__); + self::assertInstanceOf(Proxy::class, $managedAddress2->user); + self::assertFalse($managedAddress2->user === $detachedAddress2->user); + self::assertFalse($managedAddress2->user->__isInitialized__); } /** @@ -184,8 +184,8 @@ public function testUseDetachedEntityAsQueryParameter(): void $newUser = $query->getSingleResult(); - $this->assertInstanceOf(CmsUser::class, $newUser); - $this->assertEquals('gblanco', $newUser->username); + self::assertInstanceOf(CmsUser::class, $newUser); + self::assertEquals('gblanco', $newUser->username); } /** @@ -203,8 +203,8 @@ public function testDetachManagedUnpersistedEntity(): void $this->_em->flush(); - $this->assertFalse($this->_em->contains($user)); - $this->assertFalse($this->_em->getUnitOfWork()->isInIdentityMap($user)); + self::assertFalse($this->_em->contains($user)); + self::assertFalse($this->_em->getUnitOfWork()->isInIdentityMap($user)); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php index 234d8ce486d..7bb67ae7370 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php @@ -39,10 +39,10 @@ public function testPreFlushListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->preFlushCalls); - $this->assertSame($fix, $this->listener->preFlushCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->preFlushCalls[0][0]); - $this->assertInstanceOf(PreFlushEventArgs::class, $this->listener->preFlushCalls[0][1]); + self::assertCount(1, $this->listener->preFlushCalls); + self::assertSame($fix, $this->listener->preFlushCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->preFlushCalls[0][0]); + self::assertInstanceOf(PreFlushEventArgs::class, $this->listener->preFlushCalls[0][1]); } public function testPostLoadListeners(): void @@ -59,10 +59,10 @@ public function testPostLoadListeners(): void $dql = 'SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1'; $fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult(); - $this->assertCount(1, $this->listener->postLoadCalls); - $this->assertSame($fix, $this->listener->postLoadCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->postLoadCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postLoadCalls[0][1]); + self::assertCount(1, $this->listener->postLoadCalls); + self::assertSame($fix, $this->listener->postLoadCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->postLoadCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->postLoadCalls[0][1]); } public function testPrePersistListeners(): void @@ -75,10 +75,10 @@ public function testPrePersistListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->prePersistCalls); - $this->assertSame($fix, $this->listener->prePersistCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->prePersistCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->prePersistCalls[0][1]); + self::assertCount(1, $this->listener->prePersistCalls); + self::assertSame($fix, $this->listener->prePersistCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->prePersistCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->prePersistCalls[0][1]); } public function testPostPersistListeners(): void @@ -91,10 +91,10 @@ public function testPostPersistListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->postPersistCalls); - $this->assertSame($fix, $this->listener->postPersistCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->postPersistCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postPersistCalls[0][1]); + self::assertCount(1, $this->listener->postPersistCalls); + self::assertSame($fix, $this->listener->postPersistCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->postPersistCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->postPersistCalls[0][1]); } public function testPreUpdateListeners(): void @@ -112,10 +112,10 @@ public function testPreUpdateListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->preUpdateCalls); - $this->assertSame($fix, $this->listener->preUpdateCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->preUpdateCalls[0][0]); - $this->assertInstanceOf(PreUpdateEventArgs::class, $this->listener->preUpdateCalls[0][1]); + self::assertCount(1, $this->listener->preUpdateCalls); + self::assertSame($fix, $this->listener->preUpdateCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->preUpdateCalls[0][0]); + self::assertInstanceOf(PreUpdateEventArgs::class, $this->listener->preUpdateCalls[0][1]); } public function testPostUpdateListeners(): void @@ -133,10 +133,10 @@ public function testPostUpdateListeners(): void $this->_em->persist($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->postUpdateCalls); - $this->assertSame($fix, $this->listener->postUpdateCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->postUpdateCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postUpdateCalls[0][1]); + self::assertCount(1, $this->listener->postUpdateCalls); + self::assertSame($fix, $this->listener->postUpdateCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->postUpdateCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->postUpdateCalls[0][1]); } public function testPreRemoveListeners(): void @@ -152,10 +152,10 @@ public function testPreRemoveListeners(): void $this->_em->remove($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->preRemoveCalls); - $this->assertSame($fix, $this->listener->preRemoveCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->preRemoveCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->preRemoveCalls[0][1]); + self::assertCount(1, $this->listener->preRemoveCalls); + self::assertSame($fix, $this->listener->preRemoveCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->preRemoveCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->preRemoveCalls[0][1]); } public function testPostRemoveListeners(): void @@ -171,9 +171,9 @@ public function testPostRemoveListeners(): void $this->_em->remove($fix); $this->_em->flush(); - $this->assertCount(1, $this->listener->postRemoveCalls); - $this->assertSame($fix, $this->listener->postRemoveCalls[0][0]); - $this->assertInstanceOf(CompanyFixContract::class, $this->listener->postRemoveCalls[0][0]); - $this->assertInstanceOf(LifecycleEventArgs::class, $this->listener->postRemoveCalls[0][1]); + self::assertCount(1, $this->listener->postRemoveCalls); + self::assertSame($fix, $this->listener->postRemoveCalls[0][0]); + self::assertInstanceOf(CompanyFixContract::class, $this->listener->postRemoveCalls[0][0]); + self::assertInstanceOf(LifecycleEventArgs::class, $this->listener->postRemoveCalls[0][1]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php index 8964db57bef..ea1d9f3e996 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php @@ -71,7 +71,7 @@ public function testLteDateComparison(): void Criteria::expr()->lte('datetime', new DateTime('today')) )); - $this->assertEquals(2, count($dates)); + self::assertEquals(2, count($dates)); } private function loadNullFieldFixtures(): void @@ -103,7 +103,7 @@ public function testIsNullComparison(): void Criteria::expr()->isNull('time') )); - $this->assertEquals(1, count($dates)); + self::assertEquals(1, count($dates)); } public function testEqNullComparison(): void @@ -115,7 +115,7 @@ public function testEqNullComparison(): void Criteria::expr()->eq('time', null) )); - $this->assertEquals(1, count($dates)); + self::assertEquals(1, count($dates)); } public function testNotEqNullComparison(): void @@ -127,7 +127,7 @@ public function testNotEqNullComparison(): void Criteria::expr()->neq('time', null) )); - $this->assertEquals(1, count($dates)); + self::assertEquals(1, count($dates)); } public function testCanCountWithoutLoadingCollection(): void @@ -137,22 +137,22 @@ public function testCanCountWithoutLoadingCollection(): void $dates = $repository->matching(new Criteria()); - $this->assertFalse($dates->isInitialized()); - $this->assertCount(3, $dates); - $this->assertFalse($dates->isInitialized()); + self::assertFalse($dates->isInitialized()); + self::assertCount(3, $dates); + self::assertFalse($dates->isInitialized()); // Test it can work even with a constraint $dates = $repository->matching(new Criteria( Criteria::expr()->lte('datetime', new DateTime('today')) )); - $this->assertFalse($dates->isInitialized()); - $this->assertCount(2, $dates); - $this->assertFalse($dates->isInitialized()); + self::assertFalse($dates->isInitialized()); + self::assertCount(2, $dates); + self::assertFalse($dates->isInitialized()); // Trigger a loading, to make sure collection is initialized $date = $dates[0]; - $this->assertTrue($dates->isInitialized()); + self::assertTrue($dates->isInitialized()); } public function testCanContainsWithoutLoadingCollection(): void @@ -176,12 +176,12 @@ public function testCanContainsWithoutLoadingCollection(): void $user = $this->_em->find(User::class, $user->id); $tweets = $user->tweets->matching($criteria); - $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets); - $this->assertFalse($tweets->isInitialized()); + self::assertInstanceOf(LazyCriteriaCollection::class, $tweets); + self::assertFalse($tweets->isInitialized()); $tweets->contains($tweet); - $this->assertTrue($tweets->contains($tweet)); + self::assertTrue($tweets->contains($tweet)); - $this->assertFalse($tweets->isInitialized()); + self::assertFalse($tweets->isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index e5ee4a16658..ade62607eff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -199,9 +199,9 @@ public function testBasicFind(): void $repos = $this->_em->getRepository(CmsUser::class); $user = $repos->find($user1Id); - $this->assertInstanceOf(CmsUser::class, $user); - $this->assertEquals('Roman', $user->name); - $this->assertEquals('freak', $user->status); + self::assertInstanceOf(CmsUser::class, $user); + self::assertEquals('Roman', $user->name); + self::assertEquals('freak', $user->status); } public function testFindByField(): void @@ -210,10 +210,10 @@ public function testFindByField(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findBy(['status' => 'dev']); - $this->assertEquals(2, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('dev', $users[0]->status); + self::assertEquals(2, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Guilherme', $users[0]->name); + self::assertEquals('dev', $users[0]->status); } public function testFindByAssociationWithIntegerAsParameter(): void @@ -234,8 +234,8 @@ public function testFindByAssociationWithIntegerAsParameter(): void $repository = $this->_em->getRepository(CmsAddress::class); $addresses = $repository->findBy(['user' => [$user1->getId(), $user2->getId()]]); - $this->assertEquals(2, count($addresses)); - $this->assertInstanceOf(CmsAddress::class, $addresses[0]); + self::assertEquals(2, count($addresses)); + self::assertInstanceOf(CmsAddress::class, $addresses[0]); } public function testFindByAssociationWithObjectAsParameter(): void @@ -256,8 +256,8 @@ public function testFindByAssociationWithObjectAsParameter(): void $repository = $this->_em->getRepository(CmsAddress::class); $addresses = $repository->findBy(['user' => [$user1, $user2]]); - $this->assertEquals(2, count($addresses)); - $this->assertInstanceOf(CmsAddress::class, $addresses[0]); + self::assertEquals(2, count($addresses)); + self::assertInstanceOf(CmsAddress::class, $addresses[0]); } public function testFindFieldByMagicCall(): void @@ -266,10 +266,10 @@ public function testFindFieldByMagicCall(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findByStatus('dev'); - $this->assertEquals(2, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Guilherme', $users[0]->name); - $this->assertEquals('dev', $users[0]->status); + self::assertEquals(2, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Guilherme', $users[0]->name); + self::assertEquals('dev', $users[0]->status); } public function testFindAll(): void @@ -278,7 +278,7 @@ public function testFindAll(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findAll(); - $this->assertEquals(4, count($users)); + self::assertEquals(4, count($users)); } public function testFindByAlias(): void @@ -291,7 +291,7 @@ public function testFindByAlias(): void $repos = $this->_em->getRepository('CMS:CmsUser'); $users = $repos->findAll(); - $this->assertEquals(4, count($users)); + self::assertEquals(4, count($users)); } public function testCount(): void @@ -300,13 +300,13 @@ public function testCount(): void $repos = $this->_em->getRepository(CmsUser::class); $userCount = $repos->count([]); - $this->assertSame(4, $userCount); + self::assertSame(4, $userCount); $userCount = $repos->count(['status' => 'dev']); - $this->assertSame(2, $userCount); + self::assertSame(2, $userCount); $userCount = $repos->count(['status' => 'nonexistent']); - $this->assertSame(0, $userCount); + self::assertSame(0, $userCount); } public function testCountBy(): void @@ -315,7 +315,7 @@ public function testCountBy(): void $repos = $this->_em->getRepository(CmsUser::class); $userCount = $repos->countByStatus('dev'); - $this->assertSame(2, $userCount); + self::assertSame(2, $userCount); } public function testExceptionIsThrownWhenCallingFindByWithoutParameter(): void @@ -400,7 +400,7 @@ public function testFindMagicCallByNullValue(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findByStatus(null); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -437,8 +437,8 @@ public function testFindOneByAssociationKey(): void $repos = $this->_em->getRepository(CmsAddress::class); $address = $repos->findOneBy(['user' => $userId]); - $this->assertInstanceOf(CmsAddress::class, $address); - $this->assertEquals($addressId, $address->id); + self::assertInstanceOf(CmsAddress::class, $address); + self::assertEquals($addressId, $address->id); } /** @@ -452,7 +452,7 @@ public function testFindOneByOrderBy(): void $userAsc = $repos->findOneBy([], ['username' => 'ASC']); $userDesc = $repos->findOneBy([], ['username' => 'DESC']); - $this->assertNotSame($userAsc, $userDesc); + self::assertNotSame($userAsc, $userDesc); } /** @@ -464,9 +464,9 @@ public function testFindByAssociationKey(): void $repos = $this->_em->getRepository(CmsAddress::class); $addresses = $repos->findBy(['user' => $userId]); - $this->assertContainsOnly(CmsAddress::class, $addresses); - $this->assertEquals(1, count($addresses)); - $this->assertEquals($addressId, $addresses[0]->id); + self::assertContainsOnly(CmsAddress::class, $addresses); + self::assertEquals(1, count($addresses)); + self::assertEquals($addressId, $addresses[0]->id); } /** @@ -478,9 +478,9 @@ public function testFindAssociationByMagicCall(): void $repos = $this->_em->getRepository(CmsAddress::class); $addresses = $repos->findByUser($userId); - $this->assertContainsOnly(CmsAddress::class, $addresses); - $this->assertEquals(1, count($addresses)); - $this->assertEquals($addressId, $addresses[0]->id); + self::assertContainsOnly(CmsAddress::class, $addresses); + self::assertEquals(1, count($addresses)); + self::assertEquals($addressId, $addresses[0]->id); } /** @@ -492,8 +492,8 @@ public function testFindOneAssociationByMagicCall(): void $repos = $this->_em->getRepository(CmsAddress::class); $address = $repos->findOneByUser($userId); - $this->assertInstanceOf(CmsAddress::class, $address); - $this->assertEquals($addressId, $address->id); + self::assertInstanceOf(CmsAddress::class, $address); + self::assertEquals($addressId, $address->id); } public function testValidNamedQueryRetrieval(): void @@ -504,8 +504,8 @@ public function testValidNamedQueryRetrieval(): void $query = $repos->createNamedQuery('all'); - $this->assertInstanceOf(Query::class, $query); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL()); + self::assertInstanceOf(Query::class, $query); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL()); } public function testInvalidNamedQueryRetrieval(): void @@ -526,8 +526,8 @@ public function testIsNullCriteriaDoesNotGenerateAParameter(): void $users = $repos->findBy(['status' => null, 'username' => 'romanb']); $params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params']; - $this->assertEquals(1, count($params), 'Should only execute with one parameter.'); - $this->assertEquals(['romanb'], $params); + self::assertEquals(1, count($params), 'Should only execute with one parameter.'); + self::assertEquals(['romanb'], $params); } public function testIsNullCriteria(): void @@ -537,7 +537,7 @@ public function testIsNullCriteria(): void $repos = $this->_em->getRepository(CmsUser::class); $users = $repos->findBy(['status' => null]); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -552,10 +552,10 @@ public function testFindByLimitOffset(): void $users1 = $repos->findBy([], null, 1, 0); $users2 = $repos->findBy([], null, 1, 1); - $this->assertEquals(4, count($repos->findBy([]))); - $this->assertEquals(1, count($users1)); - $this->assertEquals(1, count($users2)); - $this->assertNotSame($users1[0], $users2[0]); + self::assertEquals(4, count($repos->findBy([]))); + self::assertEquals(1, count($users1)); + self::assertEquals(1, count($users2)); + self::assertNotSame($users1[0], $users2[0]); } /** @@ -569,10 +569,10 @@ public function testFindByOrderBy(): void $usersAsc = $repos->findBy([], ['username' => 'ASC']); $usersDesc = $repos->findBy([], ['username' => 'DESC']); - $this->assertEquals(4, count($usersAsc), 'Pre-condition: only four users in fixture'); - $this->assertEquals(4, count($usersDesc), 'Pre-condition: only four users in fixture'); - $this->assertSame($usersAsc[0], $usersDesc[3]); - $this->assertSame($usersAsc[3], $usersDesc[0]); + self::assertEquals(4, count($usersAsc), 'Pre-condition: only four users in fixture'); + self::assertEquals(4, count($usersDesc), 'Pre-condition: only four users in fixture'); + self::assertSame($usersAsc[0], $usersDesc[3]); + self::assertSame($usersAsc[3], $usersDesc[0]); } /** @@ -586,11 +586,11 @@ public function testFindByOrderByAssociation(): void $resultAsc = $repository->findBy([], ['email' => 'ASC']); $resultDesc = $repository->findBy([], ['email' => 'DESC']); - $this->assertCount(3, $resultAsc); - $this->assertCount(3, $resultDesc); + self::assertCount(3, $resultAsc); + self::assertCount(3, $resultDesc); - $this->assertEquals($resultAsc[0]->getEmail()->getId(), $resultDesc[2]->getEmail()->getId()); - $this->assertEquals($resultAsc[2]->getEmail()->getId(), $resultDesc[0]->getEmail()->getId()); + self::assertEquals($resultAsc[0]->getEmail()->getId(), $resultDesc[2]->getEmail()->getId()); + self::assertEquals($resultAsc[2]->getEmail()->getId(), $resultDesc[0]->getEmail()->getId()); } /** @@ -604,15 +604,15 @@ public function testFindFieldByMagicCallOrderBy(): void $usersAsc = $repos->findByStatus('dev', ['username' => 'ASC']); $usersDesc = $repos->findByStatus('dev', ['username' => 'DESC']); - $this->assertEquals(2, count($usersAsc)); - $this->assertEquals(2, count($usersDesc)); + self::assertEquals(2, count($usersAsc)); + self::assertEquals(2, count($usersDesc)); - $this->assertInstanceOf(CmsUser::class, $usersAsc[0]); - $this->assertEquals('Alexander', $usersAsc[0]->name); - $this->assertEquals('dev', $usersAsc[0]->status); + self::assertInstanceOf(CmsUser::class, $usersAsc[0]); + self::assertEquals('Alexander', $usersAsc[0]->name); + self::assertEquals('dev', $usersAsc[0]->status); - $this->assertSame($usersAsc[0], $usersDesc[1]); - $this->assertSame($usersAsc[1], $usersDesc[0]); + self::assertSame($usersAsc[0], $usersDesc[1]); + self::assertSame($usersAsc[1], $usersDesc[0]); } /** @@ -626,9 +626,9 @@ public function testFindFieldByMagicCallLimitOffset(): void $users1 = $repos->findByStatus('dev', [], 1, 0); $users2 = $repos->findByStatus('dev', [], 1, 1); - $this->assertEquals(1, count($users1)); - $this->assertEquals(1, count($users2)); - $this->assertNotSame($users1[0], $users2[0]); + self::assertEquals(1, count($users1)); + self::assertEquals(1, count($users2)); + self::assertNotSame($users1[0], $users2[0]); } /** @@ -636,21 +636,21 @@ public function testFindFieldByMagicCallLimitOffset(): void */ public function testDefaultRepositoryClassName(): void { - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); $this->_em->getConfiguration()->setDefaultRepositoryClassName(DDC753DefaultRepository::class); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class); $repos = $this->_em->getRepository(DDC753EntityWithDefaultCustomRepository::class); - $this->assertInstanceOf(DDC753DefaultRepository::class, $repos); - $this->assertTrue($repos->isDefaultRepository()); + self::assertInstanceOf(DDC753DefaultRepository::class, $repos); + self::assertTrue($repos->isDefaultRepository()); $repos = $this->_em->getRepository(DDC753EntityWithCustomRepository::class); - $this->assertInstanceOf(DDC753CustomRepository::class, $repos); - $this->assertTrue($repos->isCustomRepository()); + self::assertInstanceOf(DDC753CustomRepository::class, $repos); + self::assertTrue($repos->isCustomRepository()); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), DDC753DefaultRepository::class); $this->_em->getConfiguration()->setDefaultRepositoryClassName(EntityRepository::class); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); } /** @@ -660,7 +660,7 @@ public function testSetDefaultRepositoryInvalidClassError(): void { $this->expectException(InvalidEntityRepository::class); $this->expectExceptionMessage('Invalid repository class \'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository\'. It must be a Doctrine\Persistence\ObjectRepository.'); - $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); + self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); $this->_em->getConfiguration()->setDefaultRepositoryClassName(DDC753InvalidRepository::class); } @@ -676,8 +676,8 @@ public function testSingleRepositoryInstanceForDifferentEntityAliases(): void $repository = $this->_em->getRepository(CmsUser::class); - $this->assertSame($repository, $this->_em->getRepository('Aliased:CmsUser')); - $this->assertSame($repository, $this->_em->getRepository('AliasedAgain:CmsUser')); + self::assertSame($repository, $this->_em->getRepository('Aliased:CmsUser')); + self::assertSame($repository, $this->_em->getRepository('AliasedAgain:CmsUser')); } /** @@ -685,7 +685,7 @@ public function testSingleRepositoryInstanceForDifferentEntityAliases(): void */ public function testCanRetrieveRepositoryFromClassNameWithLeadingBackslash(): void { - $this->assertSame( + self::assertSame( $this->_em->getRepository('\\' . CmsUser::class), $this->_em->getRepository(CmsUser::class) ); @@ -723,8 +723,8 @@ public function testFindByAssociationArray(): void $data = $repo->findBy(['user' => [1, 2, 3]]); $query = array_pop($this->_sqlLoggerStack->queries); - $this->assertEquals([1, 2, 3], $query['params'][0]); - $this->assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); + self::assertEquals([1, 2, 3], $query['params'][0]); + self::assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); } /** @@ -737,7 +737,7 @@ public function testMatchingEmptyCriteria(): void $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria()); - $this->assertEquals(4, count($users)); + self::assertEquals(4, count($users)); } /** @@ -752,7 +752,7 @@ public function testMatchingCriteriaEqComparison(): void Criteria::expr()->eq('username', 'beberlei') )); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -767,7 +767,7 @@ public function testMatchingCriteriaNeqComparison(): void Criteria::expr()->neq('username', 'beberlei') )); - $this->assertEquals(3, count($users)); + self::assertEquals(3, count($users)); } /** @@ -782,7 +782,7 @@ public function testMatchingCriteriaInComparison(): void Criteria::expr()->in('username', ['beberlei', 'gblanco']) )); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } /** @@ -797,7 +797,7 @@ public function testMatchingCriteriaNotInComparison(): void Criteria::expr()->notIn('username', ['beberlei', 'gblanco', 'asm89']) )); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -812,7 +812,7 @@ public function testMatchingCriteriaLtComparison(): void Criteria::expr()->lt('id', $firstUserId + 1) )); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); } /** @@ -827,7 +827,7 @@ public function testMatchingCriteriaLeComparison(): void Criteria::expr()->lte('id', $firstUserId + 1) )); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } /** @@ -842,7 +842,7 @@ public function testMatchingCriteriaGtComparison(): void Criteria::expr()->gt('id', $firstUserId) )); - $this->assertEquals(3, count($users)); + self::assertEquals(3, count($users)); } /** @@ -857,7 +857,7 @@ public function testMatchingCriteriaGteComparison(): void Criteria::expr()->gte('id', $firstUserId) )); - $this->assertEquals(4, count($users)); + self::assertEquals(4, count($users)); } /** @@ -876,11 +876,11 @@ public function testMatchingCriteriaAssocationByObjectInMemory(): void $repository = $this->_em->getRepository(CmsAddress::class); $addresses = $repository->matching($criteria); - $this->assertEquals(1, count($addresses)); + self::assertEquals(1, count($addresses)); $addresses = new ArrayCollection($repository->findAll()); - $this->assertEquals(1, count($addresses->matching($criteria))); + self::assertEquals(1, count($addresses->matching($criteria))); } /** @@ -899,11 +899,11 @@ public function testMatchingCriteriaAssocationInWithArray(): void $repository = $this->_em->getRepository(CmsAddress::class); $addresses = $repository->matching($criteria); - $this->assertEquals(1, count($addresses)); + self::assertEquals(1, count($addresses)); $addresses = new ArrayCollection($repository->findAll()); - $this->assertEquals(1, count($addresses->matching($criteria))); + self::assertEquals(1, count($addresses->matching($criteria))); } public function testMatchingCriteriaContainsComparison(): void @@ -913,13 +913,13 @@ public function testMatchingCriteriaContainsComparison(): void $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria(Criteria::expr()->contains('name', 'Foobar'))); - $this->assertEquals(0, count($users)); + self::assertEquals(0, count($users)); $users = $repository->matching(new Criteria(Criteria::expr()->contains('name', 'Rom'))); - $this->assertEquals(1, count($users)); + self::assertEquals(1, count($users)); $users = $repository->matching(new Criteria(Criteria::expr()->contains('status', 'dev'))); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } public function testMatchingCriteriaStartsWithComparison(): void @@ -929,13 +929,13 @@ public function testMatchingCriteriaStartsWithComparison(): void $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('name', 'Foo'))); - $this->assertCount(0, $users); + self::assertCount(0, $users); $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('name', 'R'))); - $this->assertCount(1, $users); + self::assertCount(1, $users); $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('status', 'de'))); - $this->assertCount(2, $users); + self::assertCount(2, $users); } public function testMatchingCriteriaEndsWithComparison(): void @@ -945,13 +945,13 @@ public function testMatchingCriteriaEndsWithComparison(): void $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('name', 'foo'))); - $this->assertCount(0, $users); + self::assertCount(0, $users); $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('name', 'oman'))); - $this->assertCount(1, $users); + self::assertCount(1, $users); $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('status', 'ev'))); - $this->assertCount(2, $users); + self::assertCount(2, $users); } /** @@ -973,14 +973,14 @@ public function testMatchingCriteriaNullAssocComparison(): void $usersIsNull = $repository->matching($criteriaIsNull); $usersEqNull = $repository->matching($criteriaEqNull); - $this->assertCount(1, $usersIsNull); - $this->assertCount(1, $usersEqNull); + self::assertCount(1, $usersIsNull); + self::assertCount(1, $usersEqNull); - $this->assertInstanceOf(CmsUser::class, $usersIsNull[0]); - $this->assertInstanceOf(CmsUser::class, $usersEqNull[0]); + self::assertInstanceOf(CmsUser::class, $usersIsNull[0]); + self::assertInstanceOf(CmsUser::class, $usersEqNull[0]); - $this->assertNull($usersIsNull[0]->getEmail()); - $this->assertNull($usersEqNull[0]->getEmail()); + self::assertNull($usersIsNull[0]->getEmail()); + self::assertNull($usersEqNull[0]->getEmail()); } /** @@ -991,8 +991,8 @@ public function testCreateResultSetMappingBuilder(): void $repository = $this->_em->getRepository(CmsUser::class); $rsm = $repository->createResultSetMappingBuilder('u'); - $this->assertInstanceOf(Query\ResultSetMappingBuilder::class, $rsm); - $this->assertEquals(['u' => CmsUser::class], $rsm->aliasMap); + self::assertInstanceOf(Query\ResultSetMappingBuilder::class, $rsm); + self::assertEquals(['u' => CmsUser::class], $rsm->aliasMap); } /** @@ -1069,8 +1069,8 @@ public function testFindByNullValueInInCondition(): void $users = $this->_em->getRepository(CmsUser::class)->findBy(['status' => [null]]); - $this->assertCount(1, $users); - $this->assertSame($user1, reset($users)); + self::assertCount(1, $users); + self::assertSame($user1, reset($users)); } /** @@ -1097,8 +1097,8 @@ public function testFindByNullValueInMultipleInCriteriaValues(): void ->getRepository(CmsUser::class) ->findBy(['status' => ['foo', null]]); - $this->assertCount(1, $users); - $this->assertSame($user1, reset($users)); + self::assertCount(1, $users); + self::assertSame($user1, reset($users)); } /** @@ -1125,10 +1125,10 @@ public function testFindMultipleByNullValueInMultipleInCriteriaValues(): void ->getRepository(CmsUser::class) ->findBy(['status' => ['dbal maintainer', null]]); - $this->assertCount(2, $users); + self::assertCount(2, $users); foreach ($users as $user) { - $this->assertTrue(in_array($user, [$user1, $user2], true)); + self::assertTrue(in_array($user, [$user1, $user2], true)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index 64baa99e71e..6ebc0d04823 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -117,14 +117,14 @@ public function testCountNotInitializesCollection(): void $user = $this->_em->find(CmsUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(3, count($user->groups)); + self::assertFalse($user->groups->isInitialized()); foreach ($user->groups as $group) { } - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); } /** @@ -140,9 +140,9 @@ public function testCountWhenNewEntityPresent(): void $user->addGroup($newGroup); $this->_em->persist($newGroup); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(4, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(4, count($user->groups)); + self::assertFalse($user->groups->isInitialized()); } /** @@ -157,9 +157,9 @@ public function testCountWhenInitialized(): void foreach ($user->groups as $group) { } - $this->assertTrue($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Should only execute one query to initialize collection, no extra query for count() more.'); + self::assertTrue($user->groups->isInitialized()); + self::assertEquals(3, count($user->groups)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Should only execute one query to initialize collection, no extra query for count() more.'); } /** @@ -168,10 +168,10 @@ public function testCountWhenInitialized(): void public function testCountInverseCollection(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); - $this->assertFalse($group->users->isInitialized(), 'Pre-Condition'); + self::assertFalse($group->users->isInitialized(), 'Pre-Condition'); - $this->assertEquals(4, count($group->users)); - $this->assertFalse($group->users->isInitialized(), 'Extra Lazy collection should not be initialized by counting the collection.'); + self::assertEquals(4, count($group->users)); + self::assertFalse($group->users->isInitialized(), 'Extra Lazy collection should not be initialized by counting the collection.'); } /** @@ -180,9 +180,9 @@ public function testCountInverseCollection(): void public function testCountOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->groups->isInitialized(), 'Pre-Condition'); + self::assertFalse($user->groups->isInitialized(), 'Pre-Condition'); - $this->assertEquals(2, count($user->articles)); + self::assertEquals(2, count($user->articles)); } /** @@ -192,8 +192,8 @@ public function testCountOneToManyJoinedInheritance(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Pre-Condition'); - $this->assertEquals(2, count($otherClass->childClasses)); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Pre-Condition'); + self::assertEquals(2, count($otherClass->childClasses)); } /** @@ -202,10 +202,10 @@ public function testCountOneToManyJoinedInheritance(): void public function testFullSlice(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); $someGroups = $user->groups->slice(null); - $this->assertEquals(3, count($someGroups)); + self::assertEquals(3, count($someGroups)); } /** @@ -215,29 +215,29 @@ public function testFullSlice(): void public function testSlice(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); $queryCount = $this->getCurrentQueryCount(); $someGroups = $user->groups->slice(0, 2); - $this->assertContainsOnly(CmsGroup::class, $someGroups); - $this->assertEquals(2, count($someGroups)); - $this->assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!"); + self::assertContainsOnly(CmsGroup::class, $someGroups); + self::assertEquals(2, count($someGroups)); + self::assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!"); $otherGroup = $user->groups->slice(2, 1); - $this->assertContainsOnly(CmsGroup::class, $otherGroup); - $this->assertEquals(1, count($otherGroup)); - $this->assertFalse($user->groups->isInitialized()); + self::assertContainsOnly(CmsGroup::class, $otherGroup); + self::assertEquals(1, count($otherGroup)); + self::assertFalse($user->groups->isInitialized()); foreach ($user->groups as $group) { } - $this->assertTrue($user->groups->isInitialized()); - $this->assertEquals(3, count($user->groups)); + self::assertTrue($user->groups->isInitialized()); + self::assertEquals(3, count($user->groups)); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); } /** @@ -254,11 +254,11 @@ public function testSliceInitializedCollection(): void $someGroups = $user->groups->slice(0, 2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals(2, count($someGroups)); - $this->assertTrue($user->groups->contains(array_shift($someGroups))); - $this->assertTrue($user->groups->contains(array_shift($someGroups))); + self::assertEquals(2, count($someGroups)); + self::assertTrue($user->groups->contains(array_shift($someGroups))); + self::assertTrue($user->groups->contains(array_shift($someGroups))); } /** @@ -267,19 +267,19 @@ public function testSliceInitializedCollection(): void public function testSliceInverseCollection(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); - $this->assertFalse($group->users->isInitialized(), 'Pre-Condition'); + self::assertFalse($group->users->isInitialized(), 'Pre-Condition'); $queryCount = $this->getCurrentQueryCount(); $someUsers = $group->users->slice(0, 2); $otherUsers = $group->users->slice(2, 2); - $this->assertContainsOnly(CmsUser::class, $someUsers); - $this->assertContainsOnly(CmsUser::class, $otherUsers); - $this->assertEquals(2, count($someUsers)); - $this->assertEquals(2, count($otherUsers)); + self::assertContainsOnly(CmsUser::class, $someUsers); + self::assertContainsOnly(CmsUser::class, $otherUsers); + self::assertEquals(2, count($someUsers)); + self::assertEquals(2, count($otherUsers)); // +2 queries executed by slice - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Slicing two parts should only execute two additional queries.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Slicing two parts should only execute two additional queries.'); } /** @@ -288,14 +288,14 @@ public function testSliceInverseCollection(): void public function testSliceOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->articles->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->articles->isInitialized(), 'Pre-Condition: Collection is not initialized.'); $queryCount = $this->getCurrentQueryCount(); $someArticle = $user->articles->slice(0, 1); $otherArticle = $user->articles->slice(1, 1); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } /** @@ -304,15 +304,15 @@ public function testSliceOneToMany(): void public function testContainsOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->articles->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->articles->isInitialized(), 'Pre-Condition: Collection is not initialized.'); // Test One to Many existence retrieved from DB $article = $this->_em->find(CmsArticle::class, $this->articleId); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($user->articles->contains($article)); - $this->assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($user->articles->contains($article)); + self::assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); // Test One to Many existence with state new $article = new CmsArticle(); @@ -320,17 +320,17 @@ public function testContainsOneToMany(): void $article->text = 'blub'; $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); + self::assertFalse($user->articles->contains($article)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); // Test One to Many existence with state clear $this->_em->persist($article); $this->_em->flush(); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); - $this->assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->articles->contains($article)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); + self::assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); // Test One to Many existence with state managed $article = new CmsArticle(); @@ -341,9 +341,9 @@ public function testContainsOneToMany(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->contains($article)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); - $this->assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->articles->contains($article)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); + self::assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -353,7 +353,7 @@ public function testLazyOneToManyJoinedInheritanceIsLazilyInitialized(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); } /** @@ -367,9 +367,9 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect $childClass = $this->_em->find(DDC2504ChildClass::class, $this->ddc2504ChildClassId); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($otherClass->childClasses->contains($childClass)); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Search operation was performed via SQL'); + self::assertTrue($otherClass->childClasses->contains($childClass)); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Search operation was performed via SQL'); } /** @@ -380,8 +380,8 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotCauseQueriesWhenN $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($otherClass->childClasses->contains(new DDC2504ChildClass())); - $this->assertEquals( + self::assertFalse($otherClass->childClasses->contains(new DDC2504ChildClass())); + self::assertEquals( $queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.' @@ -401,9 +401,9 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect $this->_em->flush(); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($otherClass->childClasses->contains($childClass)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($otherClass->childClasses->contains($childClass)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -418,9 +418,9 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($otherClass->childClasses->contains($childClass)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); - $this->assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($otherClass->childClasses->contains($childClass)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); + self::assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -430,9 +430,9 @@ public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollect { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); - $this->assertEquals(2, count($otherClass->childClasses)); + self::assertEquals(2, count($otherClass->childClasses)); - $this->assertFalse($otherClass->childClasses->isInitialized()); + self::assertFalse($otherClass->childClasses->isInitialized()); } /** @@ -441,15 +441,15 @@ public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollect public function testContainsManyToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->isInitialized(), 'Pre-Condition: Collection is not initialized.'); // Test Many to Many existence retrieved from DB $group = $this->_em->find(CmsGroup::class, $this->groupId); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($user->groups->contains($group)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of managed entity should cause one query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertTrue($user->groups->contains($group)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of managed entity should cause one query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); // Test Many to Many existence with state new $group = new CmsGroup(); @@ -457,9 +457,9 @@ public function testContainsManyToMany(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->contains($group)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); // Test Many to Many existence with state clear $this->_em->persist($group); @@ -467,9 +467,9 @@ public function testContainsManyToMany(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->contains($group)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of persisted entity should cause one query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); // Test Many to Many existence with state managed $group = new CmsGroup(); @@ -479,9 +479,9 @@ public function testContainsManyToMany(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->groups->contains($group)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($user->groups->contains($group)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of managed entity (but not persisted) should cause no query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -490,22 +490,22 @@ public function testContainsManyToMany(): void public function testContainsManyToManyInverse(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); - $this->assertFalse($group->users->isInitialized(), 'Pre-Condition: Collection is not initialized.'); + self::assertFalse($group->users->isInitialized(), 'Pre-Condition: Collection is not initialized.'); $user = $this->_em->find(CmsUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($group->users->contains($user)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of managed entity should cause one query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertTrue($group->users->contains($user)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Checking for contains of managed entity should cause one query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); $newUser = new CmsUser(); $newUser->name = 'A New group!'; $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($group->users->contains($newUser)); - $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); - $this->assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); + self::assertFalse($group->users->contains($newUser)); + self::assertEquals($queryCount, $this->getCurrentQueryCount(), 'Checking for contains of new entity should cause no query to be executed.'); + self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); } /** @@ -521,13 +521,13 @@ public function testCountAfterAddThenFlush(): void $user->addGroup($newGroup); $this->_em->persist($newGroup); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(4, count($user->groups)); - $this->assertFalse($user->groups->isInitialized()); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(4, count($user->groups)); + self::assertFalse($user->groups->isInitialized()); $this->_em->flush(); - $this->assertEquals(4, count($user->groups)); + self::assertEquals(4, count($user->groups)); } /** @@ -548,8 +548,8 @@ public function testSliceOnDirtyCollection(): void $qc = $this->getCurrentQueryCount(); $groups = $user->groups->slice(0, 10); - $this->assertEquals(4, count($groups)); - $this->assertEquals($qc + 1, $this->getCurrentQueryCount()); + self::assertEquals(4, count($groups)); + self::assertEquals($qc + 1, $this->getCurrentQueryCount()); } /** @@ -564,12 +564,12 @@ public function testGetIndexByIdentifier(): void $queryCount = $this->getCurrentQueryCount(); $phonenumber = $user->phonenumbers->get($this->phonenumber); - $this->assertFalse($user->phonenumbers->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertSame($phonenumber, $this->_em->find(CmsPhonenumber::class, $this->phonenumber)); + self::assertFalse($user->phonenumbers->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertSame($phonenumber, $this->_em->find(CmsPhonenumber::class, $this->phonenumber)); $article = $user->phonenumbers->get($this->phonenumber); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Getting the same entity should not cause an extra query to be executed'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Getting the same entity should not cause an extra query to be executed'); } /** @@ -584,9 +584,9 @@ public function testGetIndexByOneToMany(): void $article = $user->articles->get($this->topic); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertSame($article, $this->_em->find(CmsArticle::class, $this->articleId)); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertSame($article, $this->_em->find(CmsArticle::class, $this->articleId)); } /** @@ -601,9 +601,9 @@ public function testGetIndexByManyToManyInverseSide(): void $user = $group->users->get($this->username); - $this->assertFalse($group->users->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertSame($user, $this->_em->find(CmsUser::class, $this->userId)); + self::assertFalse($group->users->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertSame($user, $this->_em->find(CmsUser::class, $this->userId)); } /** @@ -618,9 +618,9 @@ public function testGetIndexByManyToManyOwningSide(): void $group = $user->groups->get($this->groupname); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertSame($group, $this->_em->find(CmsGroup::class, $this->groupId)); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertSame($group, $this->_em->find(CmsGroup::class, $this->groupId)); } /** @@ -629,8 +629,8 @@ public function testGetIndexByManyToManyOwningSide(): void public function testGetNonExistentIndexBy(): void { $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertNull($user->articles->get(-1)); - $this->assertNull($user->groups->get(-1)); + self::assertNull($user->articles->get(-1)); + self::assertNull($user->groups->get(-1)); } public function testContainsKeyIndexByOneToMany(): void @@ -642,9 +642,9 @@ public function testContainsKeyIndexByOneToMany(): void $contains = $user->articles->containsKey($this->topic); - $this->assertTrue($contains); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByOneToManyJoinedInheritance(): void @@ -658,9 +658,9 @@ public function testContainsKeyIndexByOneToManyJoinedInheritance(): void $contains = $otherClass->childClasses->containsKey($this->ddc2504ChildClassId); - $this->assertTrue($contains); - $this->assertFalse($otherClass->childClasses->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains); + self::assertFalse($otherClass->childClasses->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByManyToMany(): void @@ -673,9 +673,9 @@ public function testContainsKeyIndexByManyToMany(): void $contains = $user->groups->containsKey($group->name); - $this->assertTrue($contains, 'The item is not into collection'); - $this->assertFalse($user->groups->isInitialized(), 'The collection must not be initialized'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains, 'The item is not into collection'); + self::assertFalse($user->groups->isInitialized(), 'The collection must not be initialized'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByManyToManyNonOwning(): void @@ -687,9 +687,9 @@ public function testContainsKeyIndexByManyToManyNonOwning(): void $contains = $group->users->containsKey($user->username); - $this->assertTrue($contains, 'The item is not into collection'); - $this->assertFalse($group->users->isInitialized(), 'The collection must not be initialized'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains, 'The item is not into collection'); + self::assertFalse($group->users->isInitialized(), 'The collection must not be initialized'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByWithPkManyToMany(): void @@ -703,9 +703,9 @@ public function testContainsKeyIndexByWithPkManyToMany(): void $contains = $user->groups->containsKey($this->groupId); - $this->assertTrue($contains, 'The item is not into collection'); - $this->assertFalse($user->groups->isInitialized(), 'The collection must not be initialized'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains, 'The item is not into collection'); + self::assertFalse($user->groups->isInitialized(), 'The collection must not be initialized'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyIndexByWithPkManyToManyNonOwning(): void @@ -719,9 +719,9 @@ public function testContainsKeyIndexByWithPkManyToManyNonOwning(): void $contains = $group->users->containsKey($this->userId2); - $this->assertTrue($contains, 'The item is not into collection'); - $this->assertFalse($group->users->isInitialized(), 'The collection must not be initialized'); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($contains, 'The item is not into collection'); + self::assertFalse($group->users->isInitialized(), 'The collection must not be initialized'); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyNonExistentIndexByOneToMany(): void @@ -732,9 +732,9 @@ public function testContainsKeyNonExistentIndexByOneToMany(): void $contains = $user->articles->containsKey('NonExistentTopic'); - $this->assertFalse($contains); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertFalse($contains); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testContainsKeyNonExistentIndexByManyToMany(): void @@ -745,9 +745,9 @@ public function testContainsKeyNonExistentIndexByManyToMany(): void $contains = $user->groups->containsKey('NonExistentTopic'); - $this->assertFalse($contains); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertFalse($contains); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } private function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php index 4e66b8e42d8..532f85f5034 100644 --- a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -35,15 +35,15 @@ public function testPersistNewEntitiesOnPreFlush(): void $this->_em->persist($user); - $this->assertEquals(0, $user->phonenumbers->count()); + self::assertEquals(0, $user->phonenumbers->count()); $this->_em->flush(); - $this->assertEquals(1, $user->phonenumbers->count()); - $this->assertTrue($this->_em->contains($user->phonenumbers->get(0))); - $this->assertTrue($user->phonenumbers->get(0)->getUser() === $user); + self::assertEquals(1, $user->phonenumbers->count()); + self::assertTrue($this->_em->contains($user->phonenumbers->get(0))); + self::assertTrue($user->phonenumbers->get(0)->getUser() === $user); - $this->assertFalse($user->phonenumbers->isDirty()); + self::assertFalse($user->phonenumbers->isDirty()); // Can be used together with SQL Logging to check that a subsequent flush has // nothing to do. This proofs the correctness of the changes that happened in onFlush. @@ -63,13 +63,13 @@ public function testPreAndOnFlushCalledAlways(): void $this->_em->flush(); - $this->assertEquals(1, $listener->preFlush); - $this->assertEquals(1, $listener->onFlush); + self::assertEquals(1, $listener->preFlush); + self::assertEquals(1, $listener->onFlush); $this->_em->flush(); - $this->assertEquals(2, $listener->preFlush); - $this->assertEquals(2, $listener->onFlush); + self::assertEquals(2, $listener->preFlush); + self::assertEquals(2, $listener->onFlush); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php index 1bebd3801e8..b08f2213553 100644 --- a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php @@ -45,30 +45,30 @@ public function testHydrationCache(): void ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) ->getResult(); - $this->assertEquals($c, $this->getCurrentQueryCount(), 'Should not execute query. Its cached!'); + self::assertEquals($c, $this->getCurrentQueryCount(), 'Should not execute query. Its cached!'); $users = $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) ->getArrayResult(); - $this->assertEquals($c + 1, $this->getCurrentQueryCount(), 'Hydration is part of cache key.'); + self::assertEquals($c + 1, $this->getCurrentQueryCount(), 'Hydration is part of cache key.'); $users = $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) ->getArrayResult(); - $this->assertEquals($c + 1, $this->getCurrentQueryCount(), 'Hydration now cached'); + self::assertEquals($c + 1, $this->getCurrentQueryCount(), 'Hydration now cached'); $users = $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(null, 'cachekey', $cache)) ->getArrayResult(); - $this->assertTrue($cache->contains('cachekey'), 'Explicit cache key'); + self::assertTrue($cache->contains('cachekey'), 'Explicit cache key'); $users = $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(null, 'cachekey', $cache)) ->getArrayResult(); - $this->assertEquals($c + 2, $this->getCurrentQueryCount(), 'Hydration now cached'); + self::assertEquals($c + 2, $this->getCurrentQueryCount(), 'Hydration now cached'); } public function testHydrationParametersSerialization(): void @@ -86,6 +86,6 @@ public function testHydrationParametersSerialization(): void $query->getResult(); - $this->assertEquals($c, $this->getCurrentQueryCount(), 'Should not execute query. Its cached!'); + self::assertEquals($c, $this->getCurrentQueryCount(), 'Should not execute query. Its cached!'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php index ad673e361d9..0c3166b7ef0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php @@ -46,16 +46,16 @@ public function testBasicIdentityManagement(): void $this->_em->clear(); $user2 = $this->_em->find(get_class($user), $user->getId()); - $this->assertTrue($user2 !== $user); + self::assertTrue($user2 !== $user); $user3 = $this->_em->find(get_class($user), $user->getId()); - $this->assertTrue($user2 === $user3); + self::assertTrue($user2 === $user3); $address2 = $this->_em->find(get_class($address), $address->getId()); - $this->assertTrue($address2 !== $address); + self::assertTrue($address2 !== $address); $address3 = $this->_em->find(get_class($address), $address->getId()); - $this->assertTrue($address2 === $address3); + self::assertTrue($address2 === $address3); - $this->assertTrue($user2->getAddress() === $address2); // !!! + self::assertTrue($user2->getAddress() === $address2); // !!! } public function testSingleValuedAssociationIdentityMapBehaviorWithRefresh(): void @@ -82,7 +82,7 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefresh(): voi $this->_em->persist($user2); $this->_em->flush(); - $this->assertSame($user1, $address->user); + self::assertSame($user1, $address->user); //external update to CmsAddress $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', [$user2->getId()]); @@ -92,12 +92,12 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefresh(): voi $this->_em->refresh($address); // Now the association should be "correct", referencing $user2 - $this->assertSame($user2, $address->user); - $this->assertSame($user2->address, $address); // check back reference also + self::assertSame($user2, $address->user); + self::assertSame($user2->address, $address); // check back reference also // Attention! refreshes can result in broken bidirectional associations! this is currently expected! // $user1 still points to $address! - $this->assertSame($user1->address, $address); + self::assertSame($user1->address, $address); } public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery(): void @@ -124,7 +124,7 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery() $this->_em->persist($user2); $this->_em->flush(); - $this->assertSame($user1, $address->user); + self::assertSame($user1, $address->user); //external update to CmsAddress $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', [$user2->getId()]); @@ -133,11 +133,11 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery() $q = $this->_em->createQuery('select a, u from Doctrine\Tests\Models\CMS\CmsAddress a join a.user u'); $address2 = $q->getSingleResult(); - $this->assertSame($address, $address2); + self::assertSame($address, $address2); // Should still be $user1 - $this->assertSame($user1, $address2->user); - $this->assertTrue($user2->address === null); + self::assertSame($user1, $address2->user); + self::assertTrue($user2->address === null); // But we want to have this external change! // Solution 2: Alternatively, a refresh query should work @@ -145,15 +145,15 @@ public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery() $q->setHint(Query::HINT_REFRESH, true); $address3 = $q->getSingleResult(); - $this->assertSame($address, $address3); // should still be the same, always from identity map + self::assertSame($address, $address3); // should still be the same, always from identity map // Now the association should be "correct", referencing $user2 - $this->assertSame($user2, $address2->user); - $this->assertSame($user2->address, $address2); // check back reference also + self::assertSame($user2, $address2->user); + self::assertSame($user2->address, $address2); // check back reference also // Attention! refreshes can result in broken bidirectional associations! this is currently expected! // $user1 still points to $address2! - $this->assertSame($user1->address, $address2); + self::assertSame($user1->address, $address2); } public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQuery(): void @@ -179,8 +179,8 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQue $this->_em->persist($user); // cascaded to phone numbers $this->_em->flush(); - $this->assertEquals(3, count($user->getPhonenumbers())); - $this->assertFalse($user->getPhonenumbers()->isDirty()); + self::assertEquals(3, count($user->getPhonenumbers())); + self::assertFalse($user->getPhonenumbers()->isDirty()); //external update to CmsAddress $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', [999, $user->getId()]); @@ -189,10 +189,10 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQue $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); $user2 = $q->getSingleResult(); - $this->assertSame($user, $user2); + self::assertSame($user, $user2); // Should still be the same 3 phonenumbers - $this->assertEquals(3, count($user2->getPhonenumbers())); + self::assertEquals(3, count($user2->getPhonenumbers())); // But we want to have this external change! // Solution 1: refresh(). @@ -202,10 +202,10 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQue $q->setHint(Query::HINT_REFRESH, true); $user3 = $q->getSingleResult(); - $this->assertSame($user, $user3); // should still be the same, always from identity map + self::assertSame($user, $user3); // should still be the same, always from identity map // Now the collection should be refreshed with correct count - $this->assertEquals(4, count($user3->getPhonenumbers())); + self::assertEquals(4, count($user3->getPhonenumbers())); } /** @@ -234,7 +234,7 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefresh(): $this->_em->persist($user); // cascaded to phone numbers $this->_em->flush(); - $this->assertEquals(3, count($user->getPhonenumbers())); + self::assertEquals(3, count($user->getPhonenumbers())); //external update to CmsAddress $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', [999, $user->getId()]); @@ -243,18 +243,18 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefresh(): $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); $user2 = $q->getSingleResult(); - $this->assertSame($user, $user2); + self::assertSame($user, $user2); // Should still be the same 3 phonenumbers - $this->assertEquals(3, count($user2->getPhonenumbers())); + self::assertEquals(3, count($user2->getPhonenumbers())); // But we want to have this external change! // Solution 1: refresh(). $this->_em->refresh($user2); - $this->assertSame($user, $user2); // should still be the same, always from identity map + self::assertSame($user, $user2); // should still be the same, always from identity map // Now the collection should be refreshed with correct count - $this->assertEquals(4, count($user2->getPhonenumbers())); + self::assertEquals(4, count($user2->getPhonenumbers())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php index 7a7a2eca665..e349f9d3d43 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php @@ -53,11 +53,11 @@ public function testManyToOneFinder(): void $market = $this->_em->find(Market::class, $this->market->getId()); assert($market instanceof Market); - $this->assertEquals(2, count($market->stocks)); - $this->assertTrue(isset($market->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); - $this->assertTrue(isset($market->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); - $this->assertEquals('AAPL', $market->stocks['AAPL']->getSymbol()); - $this->assertEquals('GOOG', $market->stocks['GOOG']->getSymbol()); + self::assertEquals(2, count($market->stocks)); + self::assertTrue(isset($market->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); + self::assertTrue(isset($market->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); + self::assertEquals('AAPL', $market->stocks['AAPL']->getSymbol()); + self::assertEquals('GOOG', $market->stocks['GOOG']->getSymbol()); } public function testManyToOneDQL(): void @@ -65,22 +65,22 @@ public function testManyToOneDQL(): void $dql = 'SELECT m, s FROM Doctrine\Tests\Models\StockExchange\Market m JOIN m.stocks s WHERE m.id = ?1'; $market = $this->_em->createQuery($dql)->setParameter(1, $this->market->getId())->getSingleResult(); - $this->assertEquals(2, count($market->stocks)); - $this->assertTrue(isset($market->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); - $this->assertTrue(isset($market->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); - $this->assertEquals('AAPL', $market->stocks['AAPL']->getSymbol()); - $this->assertEquals('GOOG', $market->stocks['GOOG']->getSymbol()); + self::assertEquals(2, count($market->stocks)); + self::assertTrue(isset($market->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); + self::assertTrue(isset($market->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); + self::assertEquals('AAPL', $market->stocks['AAPL']->getSymbol()); + self::assertEquals('GOOG', $market->stocks['GOOG']->getSymbol()); } public function testManyToMany(): void { $bond = $this->_em->find(Bond::class, $this->bond->getId()); - $this->assertEquals(2, count($bond->stocks)); - $this->assertTrue(isset($bond->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); - $this->assertTrue(isset($bond->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); - $this->assertEquals('AAPL', $bond->stocks['AAPL']->getSymbol()); - $this->assertEquals('GOOG', $bond->stocks['GOOG']->getSymbol()); + self::assertEquals(2, count($bond->stocks)); + self::assertTrue(isset($bond->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); + self::assertTrue(isset($bond->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); + self::assertEquals('AAPL', $bond->stocks['AAPL']->getSymbol()); + self::assertEquals('GOOG', $bond->stocks['GOOG']->getSymbol()); } public function testManytoManyDQL(): void @@ -88,11 +88,11 @@ public function testManytoManyDQL(): void $dql = 'SELECT b, s FROM Doctrine\Tests\Models\StockExchange\Bond b JOIN b.stocks s WHERE b.id = ?1'; $bond = $this->_em->createQuery($dql)->setParameter(1, $this->bond->getId())->getSingleResult(); - $this->assertEquals(2, count($bond->stocks)); - $this->assertTrue(isset($bond->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); - $this->assertTrue(isset($bond->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); - $this->assertEquals('AAPL', $bond->stocks['AAPL']->getSymbol()); - $this->assertEquals('GOOG', $bond->stocks['GOOG']->getSymbol()); + self::assertEquals(2, count($bond->stocks)); + self::assertTrue(isset($bond->stocks['AAPL']), 'AAPL symbol has to be key in indexed association.'); + self::assertTrue(isset($bond->stocks['GOOG']), 'GOOG symbol has to be key in indexed association.'); + self::assertEquals('AAPL', $bond->stocks['AAPL']->getSymbol()); + self::assertEquals('GOOG', $bond->stocks['GOOG']->getSymbol()); } public function testDqlOverrideIndexBy(): void @@ -100,8 +100,8 @@ public function testDqlOverrideIndexBy(): void $dql = 'SELECT b, s FROM Doctrine\Tests\Models\StockExchange\Bond b JOIN b.stocks s INDEX BY s.id WHERE b.id = ?1'; $bond = $this->_em->createQuery($dql)->setParameter(1, $this->bond->getId())->getSingleResult(); - $this->assertEquals(2, count($bond->stocks)); - $this->assertFalse(isset($bond->stocks['AAPL']), 'AAPL symbol not exists in re-indexed association.'); - $this->assertFalse(isset($bond->stocks['GOOG']), 'GOOG symbol not exists in re-indexed association.'); + self::assertEquals(2, count($bond->stocks)); + self::assertFalse(isset($bond->stocks['AAPL']), 'AAPL symbol not exists in re-indexed association.'); + self::assertFalse(isset($bond->stocks['GOOG']), 'GOOG symbol not exists in re-indexed association.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php index 779e23c35ef..cdb427f5d25 100644 --- a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php @@ -25,7 +25,7 @@ public function testInsertWithCompositeKey(): void $this->_em->clear(); $entity = $this->findEntity(); - $this->assertEquals($childEntity, $entity); + self::assertEquals($childEntity, $entity); } /** @@ -47,7 +47,7 @@ public function testUpdateWithCompositeKey(): void $this->_em->clear(); $persistedEntity = $this->findEntity(); - $this->assertEquals($entity, $persistedEntity); + self::assertEquals($entity, $persistedEntity); } private function findEntity(): JoinedChildClass diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index e9fbd3ffae8..2eecdff0076 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -62,20 +62,20 @@ public function testPreSavePostSaveCallbacksAreInvoked(): void $this->_em->persist($entity); $this->_em->flush(); - $this->assertTrue($entity->prePersistCallbackInvoked); - $this->assertTrue($entity->postPersistCallbackInvoked); + self::assertTrue($entity->prePersistCallbackInvoked); + self::assertTrue($entity->postPersistCallbackInvoked); $this->_em->clear(); $query = $this->_em->createQuery('select e from Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity e'); $result = $query->getResult(); - $this->assertTrue($result[0]->postLoadCallbackInvoked); + self::assertTrue($result[0]->postLoadCallbackInvoked); $result[0]->value = 'hello again'; $this->_em->flush(); - $this->assertEquals('changed from preUpdate callback!', $result[0]->value); + self::assertEquals('changed from preUpdate callback!', $result[0]->value); } public function testPreFlushCallbacksAreInvoked(): void @@ -86,19 +86,19 @@ public function testPreFlushCallbacksAreInvoked(): void $this->_em->flush(); - $this->assertTrue($entity->prePersistCallbackInvoked); - $this->assertTrue($entity->preFlushCallbackInvoked); + self::assertTrue($entity->prePersistCallbackInvoked); + self::assertTrue($entity->preFlushCallbackInvoked); $entity->preFlushCallbackInvoked = false; $this->_em->flush(); - $this->assertTrue($entity->preFlushCallbackInvoked); + self::assertTrue($entity->preFlushCallbackInvoked); $entity->value = 'bye'; $entity->preFlushCallbackInvoked = false; $this->_em->flush(); - $this->assertTrue($entity->preFlushCallbackInvoked); + self::assertTrue($entity->preFlushCallbackInvoked); } public function testChangesDontGetLost(): void @@ -116,8 +116,8 @@ public function testChangesDontGetLost(): void $user2 = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals('Alice', $user2->getName()); - $this->assertEquals('Hello World', $user2->getValue()); + self::assertEquals('Alice', $user2->getName()); + self::assertEquals('Hello World', $user2->getValue()); } /** @@ -134,10 +134,10 @@ public function testGetReferenceWithPostLoadEventIsDelayedUntilProxyTrigger(): v $this->_em->clear(); $reference = $this->_em->getReference(LifecycleCallbackTestEntity::class, $id); - $this->assertFalse($reference->postLoadCallbackInvoked); + self::assertFalse($reference->postLoadCallbackInvoked); $reference->getValue(); // trigger proxy load - $this->assertTrue($reference->postLoadCallbackInvoked); + self::assertTrue($reference->postLoadCallbackInvoked); } /** @@ -154,11 +154,11 @@ public function testPostLoadTriggeredOnRefresh(): void $this->_em->clear(); $reference = $this->_em->find(LifecycleCallbackTestEntity::class, $id); - $this->assertTrue($reference->postLoadCallbackInvoked); + self::assertTrue($reference->postLoadCallbackInvoked); $reference->postLoadCallbackInvoked = false; $this->_em->refresh($reference); - $this->assertTrue($reference->postLoadCallbackInvoked, 'postLoad should be invoked when refresh() is called.'); + self::assertTrue($reference->postLoadCallbackInvoked, 'postLoad should be invoked when refresh() is called.'); } /** @@ -182,8 +182,8 @@ public function testCascadedEntitiesCallsPrePersist(): void //$this->_em->persist($c); $this->_em->flush(); - $this->assertTrue($e1->prePersistCallbackInvoked); - $this->assertTrue($e2->prePersistCallbackInvoked); + self::assertTrue($e1->prePersistCallbackInvoked); + self::assertTrue($e2->prePersistCallbackInvoked); } /** @@ -222,10 +222,10 @@ public function testCascadedEntitiesLoadedInPostLoad(): void ->createQuery(sprintf($dql, $e1->getId(), $e2->getId())) ->getResult(); - $this->assertTrue(current($entities)->postLoadCallbackInvoked); - $this->assertTrue(current($entities)->postLoadCascaderNotNull); - $this->assertTrue(current($entities)->cascader->postLoadCallbackInvoked); - $this->assertEquals(current($entities)->cascader->postLoadEntitiesCount, 2); + self::assertTrue(current($entities)->postLoadCallbackInvoked); + self::assertTrue(current($entities)->postLoadCascaderNotNull); + self::assertTrue(current($entities)->cascader->postLoadCallbackInvoked); + self::assertEquals(current($entities)->cascader->postLoadEntitiesCount, 2); } /** @@ -264,8 +264,8 @@ public function testCascadedEntitiesNotLoadedInPostLoadDuringIteration(): void $result = $query->iterate(); foreach ($result as $entity) { - $this->assertTrue($entity[0]->postLoadCallbackInvoked); - $this->assertFalse($entity[0]->postLoadCascaderNotNull); + self::assertTrue($entity[0]->postLoadCallbackInvoked); + self::assertFalse($entity[0]->postLoadCascaderNotNull); break; } @@ -299,8 +299,8 @@ public function testCascadedEntitiesNotLoadedInPostLoadDuringIterationWithSimple $result = $query->iterate(null, Query::HYDRATE_SIMPLEOBJECT); foreach ($result as $entity) { - $this->assertTrue($entity[0]->postLoadCallbackInvoked); - $this->assertFalse($entity[0]->postLoadCascaderNotNull); + self::assertTrue($entity[0]->postLoadCallbackInvoked); + self::assertFalse($entity[0]->postLoadCascaderNotNull); break; } @@ -350,16 +350,16 @@ public function testPostLoadIsInvokedOnFetchJoinedEntities(): void ->createQuery($dql)->setParameter('entA_id', $entA->getId()) ->getOneOrNullResult(); - $this->assertTrue($fetchedA->postLoadCallbackInvoked); + self::assertTrue($fetchedA->postLoadCallbackInvoked); foreach ($fetchedA->entities as $fetchJoinedEntB) { - $this->assertTrue($fetchJoinedEntB->postLoadCallbackInvoked); + self::assertTrue($fetchJoinedEntB->postLoadCallbackInvoked); } } public function testLifecycleCallbacksGetInherited(): void { $childMeta = $this->_em->getClassMetadata(LifecycleCallbackChildEntity::class); - $this->assertEquals(['prePersist' => [0 => 'doStuff']], $childMeta->lifecycleCallbacks); + self::assertEquals(['prePersist' => [0 => 'doStuff']], $childMeta->lifecycleCallbacks); } public function testLifecycleListenerChangeUpdateChangeSet(): void @@ -385,7 +385,7 @@ public function testLifecycleListenerChangeUpdateChangeSet(): void $bob = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertEquals('Bob', $bob->getName()); + self::assertEquals('Bob', $bob->getName()); } /** @@ -408,23 +408,23 @@ public function testLifecycleCallbackEventArgs(): void $this->_em->remove($e); $this->_em->flush(); - $this->assertArrayHasKey('preFlushHandler', $e->calls); - $this->assertArrayHasKey('postLoadHandler', $e->calls); - $this->assertArrayHasKey('prePersistHandler', $e->calls); - $this->assertArrayHasKey('postPersistHandler', $e->calls); - $this->assertArrayHasKey('preUpdateHandler', $e->calls); - $this->assertArrayHasKey('postUpdateHandler', $e->calls); - $this->assertArrayHasKey('preRemoveHandler', $e->calls); - $this->assertArrayHasKey('postRemoveHandler', $e->calls); - - $this->assertInstanceOf(PreFlushEventArgs::class, $e->calls['preFlushHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postLoadHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['prePersistHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postPersistHandler']); - $this->assertInstanceOf(PreUpdateEventArgs::class, $e->calls['preUpdateHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postUpdateHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['preRemoveHandler']); - $this->assertInstanceOf(LifecycleEventArgs::class, $e->calls['postRemoveHandler']); + self::assertArrayHasKey('preFlushHandler', $e->calls); + self::assertArrayHasKey('postLoadHandler', $e->calls); + self::assertArrayHasKey('prePersistHandler', $e->calls); + self::assertArrayHasKey('postPersistHandler', $e->calls); + self::assertArrayHasKey('preUpdateHandler', $e->calls); + self::assertArrayHasKey('postUpdateHandler', $e->calls); + self::assertArrayHasKey('preRemoveHandler', $e->calls); + self::assertArrayHasKey('postRemoveHandler', $e->calls); + + self::assertInstanceOf(PreFlushEventArgs::class, $e->calls['preFlushHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['postLoadHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['prePersistHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['postPersistHandler']); + self::assertInstanceOf(PreUpdateEventArgs::class, $e->calls['preUpdateHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['postUpdateHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['preRemoveHandler']); + self::assertInstanceOf(LifecycleEventArgs::class, $e->calls['postRemoveHandler']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php index 068ac09ee1d..84d71ec4921 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php @@ -30,7 +30,7 @@ class GearmanLockTest extends OrmFunctionalTestCase protected function setUp(): void { if (! class_exists('GearmanClient', false)) { - $this->markTestSkipped('pecl/gearman is required for this test to run.'); + self::markTestSkipped('pecl/gearman is required for this test to run.'); } $this->useModelSet('cms'); @@ -144,12 +144,12 @@ protected function assertLockWorked($forTime = 2, $notLongerThan = null): void $this->gearman->runTasks(); - $this->assertTrue( + self::assertTrue( $this->maxRunTime > $forTime, 'Because of locking this tests should have run at least ' . $forTime . ' seconds, ' . 'but only did for ' . $this->maxRunTime . ' seconds.' ); - $this->assertTrue( + self::assertTrue( $this->maxRunTime < $notLongerThan, 'The longest task should not run longer than ' . $notLongerThan . ' seconds, ' . 'but did for ' . $this->maxRunTime . ' seconds.' @@ -192,6 +192,6 @@ protected function startJob($fn, $fixture): void ] )); - $this->assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode()); + self::assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index 82a3db78cc4..98ce0543097 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -159,7 +159,7 @@ public function testLockPessimisticWrite(): void $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSQL(); if (! $writeLockSql) { - $this->markTestSkipped('Database Driver has no Write Lock support.'); + self::markTestSkipped('Database Driver has no Write Lock support.'); } $article = new CmsArticle(); @@ -181,7 +181,7 @@ public function testLockPessimisticWrite(): void $query = array_pop($this->_sqlLoggerStack->queries); $query = array_pop($this->_sqlLoggerStack->queries); - $this->assertStringContainsString($writeLockSql, $query['sql']); + self::assertStringContainsString($writeLockSql, $query['sql']); } /** @@ -192,7 +192,7 @@ public function testLockPessimisticRead(): void $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSQL(); if (! $readLockSql) { - $this->markTestSkipped('Database Driver has no Write Lock support.'); + self::markTestSkipped('Database Driver has no Write Lock support.'); } $article = new CmsArticle(); @@ -216,7 +216,7 @@ public function testLockPessimisticRead(): void array_pop($this->_sqlLoggerStack->queries); $query = array_pop($this->_sqlLoggerStack->queries); - $this->assertStringContainsString($readLockSql, $query['sql']); + self::assertStringContainsString($readLockSql, $query['sql']); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index 4d540c9107b..aed039e5ee5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -53,7 +53,7 @@ public function testJoinedChildInsertSetsInitialVersionValue(): OptimisticJoined $this->_em->persist($test); $this->_em->flush(); - $this->assertEquals(1, $test->version); + self::assertEquals(1, $test->version); return $test; } @@ -80,7 +80,7 @@ public function testJoinedChildFailureThrowsException(OptimisticJoinedChild $chi try { $this->_em->flush(); } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); + self::assertSame($test, $e->getEntity()); } } @@ -93,7 +93,7 @@ public function testJoinedParentInsertSetsInitialVersionValue(): OptimisticJoine $this->_em->persist($test); $this->_em->flush(); - $this->assertEquals(1, $test->version); + self::assertEquals(1, $test->version); return $test; } @@ -120,7 +120,7 @@ public function testJoinedParentFailureThrowsException(OptimisticJoinedParent $p try { $this->_em->flush(); } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); + self::assertSame($test, $e->getEntity()); } } @@ -134,8 +134,8 @@ public function testMultipleFlushesDoIncrementalUpdates(): void $this->_em->persist($test); $this->_em->flush(); - $this->assertIsInt($test->getVersion()); - $this->assertEquals($i + 1, $test->getVersion()); + self::assertIsInt($test->getVersion()); + self::assertEquals($i + 1, $test->getVersion()); } } @@ -148,8 +148,8 @@ public function testStandardInsertSetsInitialVersionValue(): OptimisticStandard $this->_em->persist($test); $this->_em->flush(); - $this->assertIsInt($test->getVersion()); - $this->assertEquals(1, $test->getVersion()); + self::assertIsInt($test->getVersion()); + self::assertEquals(1, $test->getVersion()); return $test; } @@ -176,7 +176,7 @@ public function testStandardFailureThrowsException(OptimisticStandard $entity): try { $this->_em->flush(); } catch (OptimisticLockException $e) { - $this->assertSame($test, $e->getEntity()); + self::assertSame($test, $e->getEntity()); } } @@ -202,12 +202,12 @@ public function testOptimisticTimestampSetsDefaultValue(): OptimisticTimestamp $test->name = 'Testing'; - $this->assertNull($test->version, 'Pre-Condition'); + self::assertNull($test->version, 'Pre-Condition'); $this->_em->persist($test); $this->_em->flush(); - $this->assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf('DateTime', $test->version); return $test; } @@ -223,7 +223,7 @@ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestam $test = $q->getSingleResult(); - $this->assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf('DateTime', $test->version); // Manually increment the version datetime column $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); @@ -240,8 +240,8 @@ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestam $caughtException = $e; } - $this->assertNotNull($caughtException, 'No OptimisticLockingException was thrown'); - $this->assertSame($test, $caughtException->getEntity()); + self::assertNotNull($caughtException, 'No OptimisticLockingException was thrown'); + self::assertSame($test, $caughtException->getEntity()); } /** @@ -255,7 +255,7 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime $test = $q->getSingleResult(); - $this->assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf('DateTime', $test->version); // Try to lock the record with an older timestamp and it should throw an exception $caughtException = null; @@ -271,8 +271,8 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime $caughtException = $e; } - $this->assertNotNull($caughtException, 'No OptimisticLockingException was thrown'); - $this->assertSame($test, $caughtException->getEntity()); + self::assertNotNull($caughtException, 'No OptimisticLockingException was thrown'); + self::assertSame($test, $caughtException->getEntity()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php index ae555120ac1..0e0dcb4bbc7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -48,24 +48,24 @@ public function testBasicManyToManyJoin(): void $user = $this->addCmsUserGblancoWithGroups(1); $this->_em->clear(); - $this->assertEquals(0, $this->_em->getUnitOfWork()->size()); + self::assertEquals(0, $this->_em->getUnitOfWork()->size()); $query = $this->_em->createQuery('select u, g from Doctrine\Tests\Models\CMS\CmsUser u join u.groups g'); $result = $query->getResult(); - $this->assertEquals(2, $this->_em->getUnitOfWork()->size()); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertEquals('Guilherme', $result[0]->name); - $this->assertEquals(1, $result[0]->getGroups()->count()); + self::assertEquals(2, $this->_em->getUnitOfWork()->size()); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals('Guilherme', $result[0]->name); + self::assertEquals(1, $result[0]->getGroups()->count()); $groups = $result[0]->getGroups(); - $this->assertEquals('Developers_0', $groups[0]->getName()); + self::assertEquals('Developers_0', $groups[0]->getName()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0])); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0])); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0])); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0])); - $this->assertInstanceOf(PersistentCollection::class, $groups); - $this->assertInstanceOf(PersistentCollection::class, $groups[0]->getUsers()); + self::assertInstanceOf(PersistentCollection::class, $groups); + self::assertInstanceOf(PersistentCollection::class, $groups[0]->getUsers()); $groups[0]->getUsers()->clear(); $groups->clear(); @@ -74,7 +74,7 @@ public function testBasicManyToManyJoin(): void $this->_em->clear(); $query = $this->_em->createQuery('select u, g from Doctrine\Tests\Models\CMS\CmsUser u join u.groups g'); - $this->assertEquals(0, count($query->getResult())); + self::assertEquals(0, count($query->getResult())); } public function testManyToManyAddRemove(): void @@ -87,14 +87,14 @@ public function testManyToManyAddRemove(): void // Get user $user = $uRep->findOneById($user->getId()); - $this->assertNotNull($user, 'Has to return exactly one entry.'); + self::assertNotNull($user, 'Has to return exactly one entry.'); - $this->assertFalse($user->getGroups()->isInitialized()); + self::assertFalse($user->getGroups()->isInitialized()); // Check groups - $this->assertEquals(2, $user->getGroups()->count()); + self::assertEquals(2, $user->getGroups()->count()); - $this->assertTrue($user->getGroups()->isInitialized()); + self::assertTrue($user->getGroups()->isInitialized()); // Remove first group unset($user->groups[0]); @@ -107,7 +107,7 @@ public function testManyToManyAddRemove(): void $user2 = $uRep->findOneById($user->getId()); // Check groups - $this->assertEquals(1, $user2->getGroups()->count()); + self::assertEquals(1, $user2->getGroups()->count()); } public function testManyToManyInverseSideIgnored(): void @@ -128,8 +128,8 @@ public function testManyToManyInverseSideIgnored(): void // Association should not exist $user2 = $this->_em->find(get_class($user), $user->getId()); - $this->assertNotNull($user2, 'Has to return exactly one entry.'); - $this->assertEquals(0, $user2->getGroups()->count()); + self::assertNotNull($user2, 'Has to return exactly one entry.'); + self::assertEquals(0, $user2->getGroups()->count()); } public function testManyToManyCollectionClearing(): void @@ -158,10 +158,10 @@ public function testManyToManyCollectionClearAndAdd(): void $user->groups[] = $group; } - $this->assertInstanceOf(PersistentCollection::class, $user->groups); - $this->assertTrue($user->groups->isDirty()); + self::assertInstanceOf(PersistentCollection::class, $user->groups); + self::assertTrue($user->groups->isDirty()); - $this->assertEquals($groupCount, count($user->groups), 'There should be 10 groups in the collection.'); + self::assertEquals($groupCount, count($user->groups), 'There should be 10 groups in the collection.'); $this->_em->flush(); @@ -171,7 +171,7 @@ public function testManyToManyCollectionClearAndAdd(): void public function assertGblancoGroupCountIs(int $expectedGroupCount): void { $countDql = "SELECT count(g.id) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g WHERE u.username = 'gblanco'"; - $this->assertEquals( + self::assertEquals( $expectedGroupCount, $this->_em->createQuery($countDql)->getSingleScalarResult(), "Failed to verify that CmsUser with username 'gblanco' has a group count of 10 with a DQL count query." @@ -195,18 +195,18 @@ public function testRetrieveManyToManyAndAddMore(): void $newGroup->setName('12Monkeys'); $freshUser->addGroup($newGroup); - $this->assertFalse($freshUser->groups->isInitialized(), 'CmsUser::groups Collection has to be uninitialized for this test.'); + self::assertFalse($freshUser->groups->isInitialized(), 'CmsUser::groups Collection has to be uninitialized for this test.'); $this->_em->flush(); - $this->assertFalse($freshUser->groups->isInitialized(), 'CmsUser::groups Collection has to be uninitialized for this test.'); - $this->assertEquals(3, count($freshUser->getGroups())); - $this->assertEquals(3, count($freshUser->getGroups()->getSnapshot()), 'Snapshot of CmsUser::groups should contain 3 entries.'); + self::assertFalse($freshUser->groups->isInitialized(), 'CmsUser::groups Collection has to be uninitialized for this test.'); + self::assertEquals(3, count($freshUser->getGroups())); + self::assertEquals(3, count($freshUser->getGroups()->getSnapshot()), 'Snapshot of CmsUser::groups should contain 3 entries.'); $this->_em->clear(); $freshUser = $this->_em->find(CmsUser::class, $user->getId()); - $this->assertEquals(3, count($freshUser->getGroups())); + self::assertEquals(3, count($freshUser->getGroups())); } /** @@ -221,7 +221,7 @@ public function testRemoveUserWithManyGroups(): void $this->_em->flush(); $newUser = $this->_em->find(get_class($user), $userId); - $this->assertNull($newUser); + self::assertNull($newUser); } /** @@ -239,7 +239,7 @@ public function testRemoveGroupWithUser(): void $this->_em->clear(); $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(0, count($newUser->getGroups())); + self::assertEquals(0, count($newUser->getGroups())); } public function testDereferenceCollectionDelete(): void @@ -251,7 +251,7 @@ public function testDereferenceCollectionDelete(): void $this->_em->clear(); $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(0, count($newUser->getGroups())); + self::assertEquals(0, count($newUser->getGroups())); } /** @@ -270,8 +270,8 @@ public function testWorkWithDqlHydratedEmptyCollection(): void $newUser = $this->_em->createQuery('SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.groups g WHERE u.id = ?1') ->setParameter(1, $user->getId()) ->getSingleResult(); - $this->assertEquals(0, count($newUser->groups)); - $this->assertIsArray($newUser->groups->getMapping()); + self::assertEquals(0, count($newUser->groups)); + self::assertIsArray($newUser->groups->getMapping()); $newUser->addGroup($group); @@ -279,7 +279,7 @@ public function testWorkWithDqlHydratedEmptyCollection(): void $this->_em->clear(); $newUser = $this->_em->find(get_class($user), $user->getId()); - $this->assertEquals(1, count($newUser->groups)); + self::assertEquals(1, count($newUser->groups)); } public function addCmsUserGblancoWithGroups(int $groupCount = 1): CmsUser @@ -298,7 +298,7 @@ public function addCmsUserGblancoWithGroups(int $groupCount = 1): CmsUser $this->_em->persist($user); $this->_em->flush(); - $this->assertNotNull($user->getId(), "User 'gblanco' should have an ID assigned after the persist()/flush() operation."); + self::assertNotNull($user->getId(), "User 'gblanco' should have an ID assigned after the persist()/flush() operation."); return $user; } @@ -324,7 +324,7 @@ public function testClearAndResetCollection(): void $coll = new ArrayCollection([$group1, $group2]); $user->groups = $coll; $this->_em->flush(); - $this->assertInstanceOf( + self::assertInstanceOf( PersistentCollection::class, $user->groups, 'UnitOfWork should have replaced ArrayCollection with PersistentCollection.' @@ -334,9 +334,9 @@ public function testClearAndResetCollection(): void $this->_em->clear(); $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals(2, count($user->groups)); - $this->assertEquals('Developers_New1', $user->groups[0]->name); - $this->assertEquals('Developers_New2', $user->groups[1]->name); + self::assertEquals(2, count($user->groups)); + self::assertEquals('Developers_New1', $user->groups[0]->name); + self::assertEquals('Developers_New2', $user->groups[1]->name); } /** @@ -349,9 +349,9 @@ public function testInitializePersistentCollection(): void $user = $this->_em->find(get_class($user), $user->id); - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $this->_em->getUnitOfWork()->initializeObject($user->groups); - $this->assertTrue($user->groups->isInitialized(), 'Collection should be initialized after calling UnitOfWork::initializeObject()'); + self::assertTrue($user->groups->isInitialized(), 'Collection should be initialized after calling UnitOfWork::initializeObject()'); } /** @@ -366,12 +366,12 @@ public function testClearBeforeLazyLoad(): void $user = $this->_em->find(get_class($user), $user->id); $user->groups->clear(); - $this->assertEquals(0, count($user->groups)); + self::assertEquals(0, count($user->groups)); $this->_em->flush(); $user = $this->_em->find(get_class($user), $user->id); - $this->assertEquals(0, count($user->groups)); + self::assertEquals(0, count($user->groups)); } /** @@ -403,7 +403,7 @@ public function testManyToManyOrderByIsNotIgnored(): void $criteria = Criteria::create() ->orderBy(['name' => Criteria::ASC]); - $this->assertEquals( + self::assertEquals( ['A', 'B', 'C', 'Developers_0'], $user ->getGroups() @@ -447,7 +447,7 @@ public function testManyToManyOrderByHonorsFieldNameColumnNameAliases(): void $criteria = Criteria::create() ->orderBy(['name' => Criteria::ASC]); - $this->assertEquals( + self::assertEquals( ['A', 'B', 'C'], $user ->getTags() @@ -467,14 +467,14 @@ public function testMatchingWithLimit(): void $user = $this->_em->find(get_class($user), $user->id); $groups = $user->groups; - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $criteria = Criteria::create()->setMaxResults(1); $result = $groups->matching($criteria); - $this->assertCount(1, $result); + self::assertCount(1, $result); - $this->assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); + self::assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); } public function testMatchingWithOffset(): void @@ -485,17 +485,17 @@ public function testMatchingWithOffset(): void $user = $this->_em->find(get_class($user), $user->id); $groups = $user->groups; - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $criteria = Criteria::create()->setFirstResult(1); $result = $groups->matching($criteria); - $this->assertCount(1, $result); + self::assertCount(1, $result); $firstGroup = $result->first(); - $this->assertEquals('Developers_1', $firstGroup->name); + self::assertEquals('Developers_1', $firstGroup->name); - $this->assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); + self::assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); } public function testMatchingWithLimitAndOffset(): void @@ -506,20 +506,20 @@ public function testMatchingWithLimitAndOffset(): void $user = $this->_em->find(get_class($user), $user->id); $groups = $user->groups; - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $criteria = Criteria::create()->setFirstResult(1)->setMaxResults(3); $result = $groups->matching($criteria); - $this->assertCount(3, $result); + self::assertCount(3, $result); $firstGroup = $result->first(); - $this->assertEquals('Developers_1', $firstGroup->name); + self::assertEquals('Developers_1', $firstGroup->name); $lastGroup = $result->last(); - $this->assertEquals('Developers_3', $lastGroup->name); + self::assertEquals('Developers_3', $lastGroup->name); - $this->assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); + self::assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); } public function testMatching(): void @@ -530,16 +530,16 @@ public function testMatching(): void $user = $this->_em->find(get_class($user), $user->id); $groups = $user->groups; - $this->assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); + self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $criteria = Criteria::create()->where(Criteria::expr()->eq('name', (string) 'Developers_0')); $result = $groups->matching($criteria); - $this->assertCount(1, $result); + self::assertCount(1, $result); $firstGroup = $result->first(); - $this->assertEquals('Developers_0', $firstGroup->name); + self::assertEquals('Developers_0', $firstGroup->name); - $this->assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); + self::assertFalse($user->groups->isInitialized(), 'Post-condition: matching does not initialize collection'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php index ed0399b26b0..7bc291bd99a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php @@ -116,13 +116,13 @@ protected function findProducts(): array $query = $this->_em->createQuery('SELECT p, c FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p LEFT JOIN p.categories c ORDER BY p.id, c.id'); //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); $result = $query->getResult(); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); $cats1 = $result[0]->getCategories(); $cats2 = $result[1]->getCategories(); - $this->assertTrue($cats1->isInitialized()); - $this->assertTrue($cats2->isInitialized()); - $this->assertFalse($cats1[0]->getProducts()->isInitialized()); - $this->assertFalse($cats2[0]->getProducts()->isInitialized()); + self::assertTrue($cats1->isInitialized()); + self::assertTrue($cats2->isInitialized()); + self::assertFalse($cats1[0]->getProducts()->isInitialized()); + self::assertFalse($cats2[0]->getProducts()->isInitialized()); return $result; } @@ -135,16 +135,16 @@ protected function findCategories(): array $query = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\ECommerce\ECommerceCategory c LEFT JOIN c.products p ORDER BY c.id, p.id'); //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); $result = $query->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(ECommerceCategory::class, $result[0]); - $this->assertInstanceOf(ECommerceCategory::class, $result[1]); + self::assertEquals(2, count($result)); + self::assertInstanceOf(ECommerceCategory::class, $result[0]); + self::assertInstanceOf(ECommerceCategory::class, $result[1]); $prods1 = $result[0]->getProducts(); $prods2 = $result[1]->getProducts(); - $this->assertTrue($prods1->isInitialized()); - $this->assertTrue($prods2->isInitialized()); + self::assertTrue($prods1->isInitialized()); + self::assertTrue($prods2->isInitialized()); - $this->assertFalse($prods1[0]->getCategories()->isInitialized()); - $this->assertFalse($prods2[0]->getCategories()->isInitialized()); + self::assertFalse($prods1[0]->getCategories()->isInitialized()); + self::assertFalse($prods2[0]->getCategories()->isInitialized()); return $result; } @@ -159,30 +159,30 @@ public function assertLazyLoadFromInverseSide(array $products): void $firstProductCategories = $firstProduct->getCategories(); $secondProductCategories = $secondProduct->getCategories(); - $this->assertEquals(2, count($firstProductCategories)); - $this->assertEquals(2, count($secondProductCategories)); + self::assertEquals(2, count($firstProductCategories)); + self::assertEquals(2, count($secondProductCategories)); - $this->assertTrue($firstProductCategories[0] === $secondProductCategories[0]); - $this->assertTrue($firstProductCategories[1] === $secondProductCategories[1]); + self::assertTrue($firstProductCategories[0] === $secondProductCategories[0]); + self::assertTrue($firstProductCategories[1] === $secondProductCategories[1]); $firstCategoryProducts = $firstProductCategories[0]->getProducts(); $secondCategoryProducts = $firstProductCategories[1]->getProducts(); - $this->assertFalse($firstCategoryProducts->isInitialized()); - $this->assertFalse($secondCategoryProducts->isInitialized()); - $this->assertEquals(0, $firstCategoryProducts->unwrap()->count()); - $this->assertEquals(0, $secondCategoryProducts->unwrap()->count()); + self::assertFalse($firstCategoryProducts->isInitialized()); + self::assertFalse($secondCategoryProducts->isInitialized()); + self::assertEquals(0, $firstCategoryProducts->unwrap()->count()); + self::assertEquals(0, $secondCategoryProducts->unwrap()->count()); - $this->assertEquals(2, count($firstCategoryProducts)); // lazy-load - $this->assertTrue($firstCategoryProducts->isInitialized()); - $this->assertFalse($secondCategoryProducts->isInitialized()); - $this->assertEquals(2, count($secondCategoryProducts)); // lazy-load - $this->assertTrue($secondCategoryProducts->isInitialized()); + self::assertEquals(2, count($firstCategoryProducts)); // lazy-load + self::assertTrue($firstCategoryProducts->isInitialized()); + self::assertFalse($secondCategoryProducts->isInitialized()); + self::assertEquals(2, count($secondCategoryProducts)); // lazy-load + self::assertTrue($secondCategoryProducts->isInitialized()); - $this->assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[0]); - $this->assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[1]); - $this->assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[0]); - $this->assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[1]); + self::assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[0]); + self::assertInstanceOf(ECommerceProduct::class, $firstCategoryProducts[1]); + self::assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[0]); + self::assertInstanceOf(ECommerceProduct::class, $secondCategoryProducts[1]); $this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts); } @@ -197,30 +197,30 @@ public function assertLazyLoadFromOwningSide(array $categories): void $firstCategoryProducts = $firstCategory->getProducts(); $secondCategoryProducts = $secondCategory->getProducts(); - $this->assertEquals(2, count($firstCategoryProducts)); - $this->assertEquals(2, count($secondCategoryProducts)); + self::assertEquals(2, count($firstCategoryProducts)); + self::assertEquals(2, count($secondCategoryProducts)); - $this->assertTrue($firstCategoryProducts[0] === $secondCategoryProducts[0]); - $this->assertTrue($firstCategoryProducts[1] === $secondCategoryProducts[1]); + self::assertTrue($firstCategoryProducts[0] === $secondCategoryProducts[0]); + self::assertTrue($firstCategoryProducts[1] === $secondCategoryProducts[1]); $firstProductCategories = $firstCategoryProducts[0]->getCategories(); $secondProductCategories = $firstCategoryProducts[1]->getCategories(); - $this->assertFalse($firstProductCategories->isInitialized()); - $this->assertFalse($secondProductCategories->isInitialized()); - $this->assertEquals(0, $firstProductCategories->unwrap()->count()); - $this->assertEquals(0, $secondProductCategories->unwrap()->count()); - - $this->assertEquals(2, count($firstProductCategories)); // lazy-load - $this->assertTrue($firstProductCategories->isInitialized()); - $this->assertFalse($secondProductCategories->isInitialized()); - $this->assertEquals(2, count($secondProductCategories)); // lazy-load - $this->assertTrue($secondProductCategories->isInitialized()); - - $this->assertInstanceOf(ECommerceCategory::class, $firstProductCategories[0]); - $this->assertInstanceOf(ECommerceCategory::class, $firstProductCategories[1]); - $this->assertInstanceOf(ECommerceCategory::class, $secondProductCategories[0]); - $this->assertInstanceOf(ECommerceCategory::class, $secondProductCategories[1]); + self::assertFalse($firstProductCategories->isInitialized()); + self::assertFalse($secondProductCategories->isInitialized()); + self::assertEquals(0, $firstProductCategories->unwrap()->count()); + self::assertEquals(0, $secondProductCategories->unwrap()->count()); + + self::assertEquals(2, count($firstProductCategories)); // lazy-load + self::assertTrue($firstProductCategories->isInitialized()); + self::assertFalse($secondProductCategories->isInitialized()); + self::assertEquals(2, count($secondProductCategories)); // lazy-load + self::assertTrue($secondProductCategories->isInitialized()); + + self::assertInstanceOf(ECommerceCategory::class, $firstProductCategories[0]); + self::assertInstanceOf(ECommerceCategory::class, $firstProductCategories[1]); + self::assertInstanceOf(ECommerceCategory::class, $secondProductCategories[0]); + self::assertInstanceOf(ECommerceCategory::class, $secondProductCategories[1]); $this->assertCollectionEquals($firstProductCategories, $secondProductCategories); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php index 7893d655410..20f3427ec99 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php @@ -31,7 +31,7 @@ public function testListenerShouldBeNotifiedOnlyWhenUpdating(): void $user = $this->createNewValidUser(); $this->_em->persist($user); $this->_em->flush(); - $this->assertFalse($this->listener->wasNotified); + self::assertFalse($this->listener->wasNotified); $group = new CmsGroup(); $group->name = 'admins'; @@ -39,7 +39,7 @@ public function testListenerShouldBeNotifiedOnlyWhenUpdating(): void $this->_em->persist($user); $this->_em->flush(); - $this->assertTrue($this->listener->wasNotified); + self::assertTrue($this->listener->wasNotified); } private function createNewValidUser(): CmsUser diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php index ec8eff8e8d5..6b78c356dc5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php @@ -110,20 +110,20 @@ public function testLazyLoadsOwningSide(): void public function assertLoadingOfOwningSide(array $products): void { [$firstProduct, $secondProduct] = $products; - $this->assertEquals(2, count($firstProduct->getRelated())); - $this->assertEquals(2, count($secondProduct->getRelated())); + self::assertEquals(2, count($firstProduct->getRelated())); + self::assertEquals(2, count($secondProduct->getRelated())); $categories = $firstProduct->getRelated(); $firstRelatedBy = $categories[0]->getRelated(); $secondRelatedBy = $categories[1]->getRelated(); - $this->assertEquals(2, count($firstRelatedBy)); - $this->assertEquals(2, count($secondRelatedBy)); + self::assertEquals(2, count($firstRelatedBy)); + self::assertEquals(2, count($secondRelatedBy)); - $this->assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[0]); - $this->assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[1]); - $this->assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[0]); - $this->assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[1]); + self::assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[0]); + self::assertInstanceOf(ECommerceProduct::class, $firstRelatedBy[1]); + self::assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[0]); + self::assertInstanceOf(ECommerceProduct::class, $secondRelatedBy[1]); $this->assertCollectionEquals($firstRelatedBy, $secondRelatedBy); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php index c279bd615eb..515d281abe3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php @@ -81,8 +81,8 @@ public function testEagerLoad(): void $products = $firstCart->getProducts(); $secondCart = $result[1]; - $this->assertInstanceOf(ECommerceProduct::class, $products[0]); - $this->assertInstanceOf(ECommerceProduct::class, $products[1]); + self::assertInstanceOf(ECommerceProduct::class, $products[0]); + self::assertInstanceOf(ECommerceProduct::class, $products[1]); $this->assertCollectionEquals($products, $secondCart->getProducts()); //$this->assertEquals("Doctrine 1.x Manual", $products[0]->getName()); //$this->assertEquals("Doctrine 2.x Manual", $products[1]->getName()); @@ -100,8 +100,8 @@ public function testLazyLoadsCollection(): void $products = $firstCart->getProducts(); $secondCart = $result[1]; - $this->assertInstanceOf(ECommerceProduct::class, $products[0]); - $this->assertInstanceOf(ECommerceProduct::class, $products[1]); + self::assertInstanceOf(ECommerceProduct::class, $products[0]); + self::assertInstanceOf(ECommerceProduct::class, $products[1]); $this->assertCollectionEquals($products, $secondCart->getProducts()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php index b7016df3f05..b3ae14a870b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php @@ -74,14 +74,14 @@ public function testOrphanRemovalIsPurelyOrnemental(): void ); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'Person should be removed by EntityManager'); + self::assertEquals(0, count($result), 'Person should be removed by EntityManager'); $query = $this->_em->createQuery( 'SELECT p FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\PhoneNumber p' ); $result = $query->getResult(); - $this->assertEquals(2, count($result), 'Orphan removal should not kick in'); + self::assertEquals(2, count($result), 'Orphan removal should not kick in'); } protected function getEntityManager( diff --git a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php index 7c6da7d46c6..0e19921739e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php @@ -44,10 +44,10 @@ public function testCRUD(): void $cleanFile = $this->_em->find(get_class($file), $file->getId()); - $this->assertInstanceOf(Directory::class, $cleanFile->getParent()); - $this->assertInstanceOf(Proxy::class, $cleanFile->getParent()); - $this->assertEquals($directory->getId(), $cleanFile->getParent()->getId()); - $this->assertInstanceOf(Directory::class, $cleanFile->getParent()->getParent()); - $this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId()); + self::assertInstanceOf(Directory::class, $cleanFile->getParent()); + self::assertInstanceOf(Proxy::class, $cleanFile->getParent()); + self::assertEquals($directory->getId(), $cleanFile->getParent()->getId()); + self::assertInstanceOf(Directory::class, $cleanFile->getParent()->getParent()); + self::assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php index a7362e424aa..e4672d9ffe1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php @@ -40,9 +40,9 @@ public function testMergingOfEntityWithCompositeIdentifierContainingToOneAssocia $merged = $this->_em->merge($state); assert($merged instanceof CompositeToOneKeyState); - $this->assertInstanceOf(CompositeToOneKeyState::class, $state); - $this->assertNotSame($state, $merged); - $this->assertInstanceOf(Country::class, $merged->country); - $this->assertNotSame($country, $merged->country); + self::assertInstanceOf(CompositeToOneKeyState::class, $state); + self::assertNotSame($state, $merged); + self::assertInstanceOf(Country::class, $merged->country); + self::assertNotSame($country, $merged->country); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php index 8b2623dc676..f668441cbbb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php @@ -43,10 +43,10 @@ public function testMergeDetachedUnInitializedProxy(): void $managed = $this->_em->getReference(DateTimeModel::class, 123); - $this->assertSame($managed, $this->_em->merge($detachedUninitialized)); + self::assertSame($managed, $this->_em->merge($detachedUninitialized)); - $this->assertFalse($managed->__isInitialized()); - $this->assertFalse($detachedUninitialized->__isInitialized()); + self::assertFalse($managed->__isInitialized()); + self::assertFalse($detachedUninitialized->__isInitialized()); } /** @@ -63,13 +63,13 @@ public function testMergeUnserializedUnInitializedProxy(): void $managed = $this->_em->getReference(DateTimeModel::class, 123); - $this->assertSame( + self::assertSame( $managed, $this->_em->merge(unserialize(serialize($this->_em->merge($detachedUninitialized)))) ); - $this->assertFalse($managed->__isInitialized()); - $this->assertFalse($detachedUninitialized->__isInitialized()); + self::assertFalse($managed->__isInitialized()); + self::assertFalse($detachedUninitialized->__isInitialized()); } /** @@ -82,9 +82,9 @@ public function testMergeManagedProxy(): void { $managed = $this->_em->getReference(DateTimeModel::class, 123); - $this->assertSame($managed, $this->_em->merge($managed)); + self::assertSame($managed, $this->_em->merge($managed)); - $this->assertFalse($managed->__isInitialized()); + self::assertFalse($managed->__isInitialized()); } /** @@ -106,14 +106,14 @@ public function testMergeWithExistingUninitializedManagedProxy(): void $managed = $this->_em->getReference(DateTimeModel::class, $date->id); - $this->assertInstanceOf(Proxy::class, $managed); - $this->assertFalse($managed->__isInitialized()); + self::assertInstanceOf(Proxy::class, $managed); + self::assertFalse($managed->__isInitialized()); $date->date = $dateTime = new DateTime(); - $this->assertSame($managed, $this->_em->merge($date)); - $this->assertTrue($managed->__isInitialized()); - $this->assertSame($dateTime, $managed->date, 'Data was merged into the proxy after initialization'); + self::assertSame($managed, $this->_em->merge($date)); + self::assertTrue($managed->__isInitialized()); + self::assertSame($dateTime, $managed->date, 'Data was merged into the proxy after initialization'); } /** @@ -144,20 +144,20 @@ public function testMergingProxyFromDifferentEntityManagerWithExistingManagedIns $proxy2 = $em2->getReference(DateTimeModel::class, $file1->id); $merged2 = $em2->merge($proxy1); - $this->assertNotSame($proxy1, $merged2); - $this->assertSame($proxy2, $merged2); + self::assertNotSame($proxy1, $merged2); + self::assertSame($proxy2, $merged2); - $this->assertFalse($proxy1->__isInitialized()); - $this->assertFalse($proxy2->__isInitialized()); + self::assertFalse($proxy1->__isInitialized()); + self::assertFalse($proxy2->__isInitialized()); $proxy1->__load(); - $this->assertCount( + self::assertCount( $queryCount1 + 1, $logger1->queries, 'Loading the first proxy was done through the first entity manager' ); - $this->assertCount( + self::assertCount( $queryCount2, $logger2->queries, 'No queries were executed on the second entity manager, as it is unrelated with the first proxy' @@ -165,12 +165,12 @@ public function testMergingProxyFromDifferentEntityManagerWithExistingManagedIns $proxy2->__load(); - $this->assertCount( + self::assertCount( $queryCount1 + 1, $logger1->queries, 'Loading the second proxy does not affect the first entity manager' ); - $this->assertCount( + self::assertCount( $queryCount2 + 1, $logger2->queries, 'Loading of the second proxy instance was done through the second entity manager' @@ -204,16 +204,16 @@ public function testMergingUnInitializedProxyDoesNotInitializeIt(): void $unManagedProxy = $em1->getReference(DateTimeModel::class, $file1->id); $mergedInstance = $em2->merge($unManagedProxy); - $this->assertNotInstanceOf(Proxy::class, $mergedInstance); - $this->assertNotSame($unManagedProxy, $mergedInstance); - $this->assertFalse($unManagedProxy->__isInitialized()); + self::assertNotInstanceOf(Proxy::class, $mergedInstance); + self::assertNotSame($unManagedProxy, $mergedInstance); + self::assertFalse($unManagedProxy->__isInitialized()); - $this->assertCount( + self::assertCount( $queryCount1, $logger1->queries, 'Loading the merged instance affected only the first entity manager' ); - $this->assertCount( + self::assertCount( $queryCount1 + 1, $logger2->queries, 'Loading the merged instance was done via the second entity manager' @@ -221,12 +221,12 @@ public function testMergingUnInitializedProxyDoesNotInitializeIt(): void $unManagedProxy->__load(); - $this->assertCount( + self::assertCount( $queryCount1 + 1, $logger1->queries, 'Loading the first proxy was done through the first entity manager' ); - $this->assertCount( + self::assertCount( $queryCount2 + 1, $logger2->queries, 'No queries were executed on the second entity manager, as it is unrelated with the first proxy' diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php index 74266741941..e5b5705c12e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php @@ -43,7 +43,7 @@ public function testMergeSharedNewEntities(): void $picture = $this->_em->merge($picture); - $this->assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); + self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); } public function testMergeSharedManagedEntities(): void @@ -61,7 +61,7 @@ public function testMergeSharedManagedEntities(): void $picture = $this->_em->merge($picture); - $this->assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); + self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); } public function testMergeSharedDetachedSerializedEntities(): void @@ -81,7 +81,7 @@ public function testMergeSharedDetachedSerializedEntities(): void $picture = $this->_em->merge(unserialize($serializedPicture)); - $this->assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); + self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); } /** @@ -99,8 +99,8 @@ public function testMergeInheritedTransientPrivateProperties(): void $admin2->setSession('zeh current session data'); - $this->assertSame($admin1, $this->_em->merge($admin2)); - $this->assertSame('zeh current session data', $admin1->getSession()); + self::assertSame($admin1, $this->_em->merge($admin2)); + self::assertSame('zeh current session data', $admin1->getSession()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php index b648e614235..ae1ea0786b9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php @@ -41,6 +41,6 @@ public function testSetVersionOnCreate(): void $articleMerged->name = 'Article Merged'; $this->_em->flush(); - $this->assertEquals(2, $articleMerged->version); + self::assertEquals(2, $articleMerged->version); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 592ca42c9b3..18e89210d40 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -69,9 +69,9 @@ public function testBasicNativeQuery(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); } public function testBasicNativeQueryWithMetaResult(): void @@ -106,13 +106,13 @@ public function testBasicNativeQueryWithMetaResult(): void $addresses = $query->getResult(); - $this->assertEquals(1, count($addresses)); - $this->assertTrue($addresses[0] instanceof CmsAddress); - $this->assertEquals($addr->country, $addresses[0]->country); - $this->assertEquals($addr->zip, $addresses[0]->zip); - $this->assertEquals($addr->city, $addresses[0]->city); - $this->assertEquals($addr->street, $addresses[0]->street); - $this->assertTrue($addresses[0]->user instanceof CmsUser); + self::assertEquals(1, count($addresses)); + self::assertTrue($addresses[0] instanceof CmsAddress); + self::assertEquals($addr->country, $addresses[0]->country); + self::assertEquals($addr->zip, $addresses[0]->zip); + self::assertEquals($addr->city, $addresses[0]->city); + self::assertEquals($addr->street, $addresses[0]->street); + self::assertTrue($addresses[0]->user instanceof CmsUser); } public function testJoinedOneToManyNativeQuery(): void @@ -144,15 +144,15 @@ public function testJoinedOneToManyNativeQuery(): void $query->setParameter(1, 'romanb'); $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); - $this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($users[0]->getPhonenumbers())); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); + self::assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); + self::assertTrue($users[0]->getPhonenumbers()->isInitialized()); + self::assertEquals(1, count($users[0]->getPhonenumbers())); $phones = $users[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $users[0]); + self::assertEquals(424242, $phones[0]->phonenumber); + self::assertTrue($phones[0]->getUser() === $users[0]); } public function testJoinedOneToOneNativeQuery(): void @@ -190,16 +190,16 @@ public function testJoinedOneToOneNativeQuery(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); - $this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf(CmsAddress::class, $users[0]->getAddress()); - $this->assertTrue($users[0]->getAddress()->getUser() === $users[0]); - $this->assertEquals('germany', $users[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); - $this->assertEquals('Berlin', $users[0]->getAddress()->getCity()); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); + self::assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); + self::assertFalse($users[0]->getPhonenumbers()->isInitialized()); + self::assertInstanceOf(CmsAddress::class, $users[0]->getAddress()); + self::assertTrue($users[0]->getAddress()->getUser() === $users[0]); + self::assertEquals('germany', $users[0]->getAddress()->getCountry()); + self::assertEquals(10827, $users[0]->getAddress()->getZipCode()); + self::assertEquals('Berlin', $users[0]->getAddress()->getCity()); } public function testFluentInterface(): void @@ -220,7 +220,7 @@ public function testFluentInterface(): void ->setResultCacheDriver(null) ->setResultCacheLifetime(3500); - $this->assertSame($q, $q2); + self::assertSame($q, $q2); } public function testJoinedOneToManyNativeQueryWithRSMBuilder(): void @@ -247,15 +247,15 @@ public function testJoinedOneToManyNativeQueryWithRSMBuilder(): void $query->setParameter(1, 'romanb'); $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); - $this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($users[0]->getPhonenumbers())); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); + self::assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); + self::assertTrue($users[0]->getPhonenumbers()->isInitialized()); + self::assertEquals(1, count($users[0]->getPhonenumbers())); $phones = $users[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $users[0]); + self::assertEquals(424242, $phones[0]->phonenumber); + self::assertTrue($phones[0]->getUser() === $users[0]); $this->_em->clear(); @@ -265,8 +265,8 @@ public function testJoinedOneToManyNativeQueryWithRSMBuilder(): void $query->setParameter(1, $phone->phonenumber); $phone = $query->getSingleResult(); - $this->assertNotNull($phone->getUser()); - $this->assertEquals($user->name, $phone->getUser()->getName()); + self::assertNotNull($phone->getUser()); + self::assertEquals($user->name, $phone->getUser()->getName()); } public function testJoinedOneToOneNativeQueryWithRSMBuilder(): void @@ -297,16 +297,16 @@ public function testJoinedOneToOneNativeQueryWithRSMBuilder(): void $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals('Roman', $users[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); - $this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf(CmsAddress::class, $users[0]->getAddress()); - $this->assertTrue($users[0]->getAddress()->getUser() === $users[0]); - $this->assertEquals('germany', $users[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); - $this->assertEquals('Berlin', $users[0]->getAddress()->getCity()); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Roman', $users[0]->name); + self::assertInstanceOf(PersistentCollection::class, $users[0]->getPhonenumbers()); + self::assertFalse($users[0]->getPhonenumbers()->isInitialized()); + self::assertInstanceOf(CmsAddress::class, $users[0]->getAddress()); + self::assertTrue($users[0]->getAddress()->getUser() === $users[0]); + self::assertEquals('germany', $users[0]->getAddress()->getCountry()); + self::assertEquals(10827, $users[0]->getAddress()->getZipCode()); + self::assertEquals('Berlin', $users[0]->getAddress()->getCity()); $this->_em->clear(); @@ -316,8 +316,8 @@ public function testJoinedOneToOneNativeQueryWithRSMBuilder(): void $query->setParameter(1, $addr->getId()); $address = $query->getSingleResult(); - $this->assertNotNull($address->getUser()); - $this->assertEquals($user->name, $address->getUser()->getName()); + self::assertNotNull($address->getUser()); + self::assertEquals($user->name, $address->getUser()->getName()); } /** @@ -396,11 +396,11 @@ public function testBasicNativeNamedQueryWithSqlResultSetMapping(): void $query = $repository->createNativeNamedQuery('find-all'); $result = $query->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CmsAddress::class, $result[0]); - $this->assertEquals($addr->id, $result[0]->id); - $this->assertEquals($addr->city, $result[0]->city); - $this->assertEquals($addr->country, $result[0]->country); + self::assertCount(1, $result); + self::assertInstanceOf(CmsAddress::class, $result[0]); + self::assertEquals($addr->id, $result[0]->id); + self::assertEquals($addr->city, $result[0]->city); + self::assertEquals($addr->country, $result[0]->country); } /** @@ -432,12 +432,12 @@ public function testBasicNativeNamedQueryWithResultClass(): void ->setParameter(1, 'FabioBatSilva') ->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertNull($result[0]->name); - $this->assertNull($result[0]->email); - $this->assertEquals($user->id, $result[0]->id); - $this->assertEquals('FabioBatSilva', $result[0]->username); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertNull($result[0]->name); + self::assertNull($result[0]->email); + self::assertEquals($user->id, $result[0]->id); + self::assertEquals('FabioBatSilva', $result[0]->username); $this->_em->clear(); @@ -445,13 +445,13 @@ public function testBasicNativeNamedQueryWithResultClass(): void ->setParameter(1, 'FabioBatSilva') ->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertEquals($user->id, $result[0]->id); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertEquals('FabioBatSilva', $result[0]->username); - $this->assertEquals('dev', $result[0]->status); - $this->assertInstanceOf(CmsEmail::class, $result[0]->email); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals($user->id, $result[0]->id); + self::assertEquals('Fabio B. Silva', $result[0]->name); + self::assertEquals('FabioBatSilva', $result[0]->username); + self::assertEquals('dev', $result[0]->status); + self::assertInstanceOf(CmsEmail::class, $result[0]->email); } /** @@ -480,16 +480,16 @@ public function testJoinedOneToOneNativeNamedQueryWithResultSetMapping(): void ->setParameter(1, 'FabioBatSilva') ->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); - $this->assertFalse($result[0]->getPhonenumbers()->isInitialized()); - $this->assertInstanceOf(CmsAddress::class, $result[0]->getAddress()); - $this->assertTrue($result[0]->getAddress()->getUser() === $result[0]); - $this->assertEquals('Brazil', $result[0]->getAddress()->getCountry()); - $this->assertEquals(10827, $result[0]->getAddress()->getZipCode()); - $this->assertEquals('São Paulo', $result[0]->getAddress()->getCity()); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals('Fabio B. Silva', $result[0]->name); + self::assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); + self::assertFalse($result[0]->getPhonenumbers()->isInitialized()); + self::assertInstanceOf(CmsAddress::class, $result[0]->getAddress()); + self::assertTrue($result[0]->getAddress()->getUser() === $result[0]); + self::assertEquals('Brazil', $result[0]->getAddress()->getCountry()); + self::assertEquals(10827, $result[0]->getAddress()->getZipCode()); + self::assertEquals('São Paulo', $result[0]->getAddress()->getCity()); } /** @@ -517,15 +517,15 @@ public function testJoinedOneToManyNativeNamedQueryWithResultSetMapping(): void $result = $repository->createNativeNamedQuery('fetchJoinedPhonenumber') ->setParameter(1, 'FabioBatSilva')->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertEquals('Fabio B. Silva', $result[0]->name); - $this->assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); - $this->assertTrue($result[0]->getPhonenumbers()->isInitialized()); - $this->assertEquals(1, count($result[0]->getPhonenumbers())); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals('Fabio B. Silva', $result[0]->name); + self::assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); + self::assertTrue($result[0]->getPhonenumbers()->isInitialized()); + self::assertEquals(1, count($result[0]->getPhonenumbers())); $phones = $result[0]->getPhonenumbers(); - $this->assertEquals(424242, $phones[0]->phonenumber); - $this->assertTrue($phones[0]->getUser() === $result[0]); + self::assertEquals(424242, $phones[0]->phonenumber); + self::assertTrue($phones[0]->getUser() === $result[0]); } /** @@ -565,19 +565,19 @@ public function testMixedNativeNamedQueryNormalJoin(): void $result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount') ->setParameter(1, ['test', 'FabioBatSilva'])->getResult(); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers - $this->assertInstanceOf(CmsUser::class, $result[0][0]); - $this->assertEquals('Fabio B. Silva', $result[0][0]->name); - $this->assertEquals(2, $result[0]['numphones']); + self::assertInstanceOf(CmsUser::class, $result[0][0]); + self::assertEquals('Fabio B. Silva', $result[0][0]->name); + self::assertEquals(2, $result[0]['numphones']); // second user => 1 phonenumbers - $this->assertInstanceOf(CmsUser::class, $result[1][0]); - $this->assertEquals('test tester', $result[1][0]->name); - $this->assertEquals(1, $result[1]['numphones']); + self::assertInstanceOf(CmsUser::class, $result[1][0]); + self::assertEquals('test tester', $result[1][0]->name); + self::assertEquals(1, $result[1]['numphones']); } /** @@ -604,26 +604,26 @@ public function testNativeNamedQueryInheritance(): void $result = $repository->createNativeNamedQuery('fetchAllWithSqlResultSetMapping') ->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(CompanyPerson::class, $result[0]); - $this->assertInstanceOf(CompanyEmployee::class, $result[1]); - $this->assertTrue(is_numeric($result[0]->getId())); - $this->assertTrue(is_numeric($result[1]->getId())); - $this->assertEquals('Fabio B. Silva', $result[0]->getName()); - $this->assertEquals('Fabio Silva', $result[1]->getName()); + self::assertEquals(2, count($result)); + self::assertInstanceOf(CompanyPerson::class, $result[0]); + self::assertInstanceOf(CompanyEmployee::class, $result[1]); + self::assertTrue(is_numeric($result[0]->getId())); + self::assertTrue(is_numeric($result[1]->getId())); + self::assertEquals('Fabio B. Silva', $result[0]->getName()); + self::assertEquals('Fabio Silva', $result[1]->getName()); $this->_em->clear(); $result = $repository->createNativeNamedQuery('fetchAllWithResultClass') ->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(CompanyPerson::class, $result[0]); - $this->assertInstanceOf(CompanyEmployee::class, $result[1]); - $this->assertTrue(is_numeric($result[0]->getId())); - $this->assertTrue(is_numeric($result[1]->getId())); - $this->assertEquals('Fabio B. Silva', $result[0]->getName()); - $this->assertEquals('Fabio Silva', $result[1]->getName()); + self::assertEquals(2, count($result)); + self::assertInstanceOf(CompanyPerson::class, $result[0]); + self::assertInstanceOf(CompanyEmployee::class, $result[1]); + self::assertTrue(is_numeric($result[0]->getId())); + self::assertTrue(is_numeric($result[1]->getId())); + self::assertEquals('Fabio B. Silva', $result[0]->getName()); + self::assertEquals('Fabio Silva', $result[1]->getName()); } /** @@ -658,17 +658,17 @@ public function testMultipleEntityResults(): void $query = $repository->createNativeNamedQuery('fetchMultipleJoinsEntityResults'); $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertTrue(is_array($result[0])); + self::assertEquals(1, count($result)); + self::assertTrue(is_array($result[0])); - $this->assertInstanceOf(CmsUser::class, $result[0][0]); - $this->assertEquals('Fabio B. Silva', $result[0][0]->name); - $this->assertInstanceOf(CmsAddress::class, $result[0][0]->getAddress()); - $this->assertTrue($result[0][0]->getAddress()->getUser() === $result[0][0]); - $this->assertEquals('Brazil', $result[0][0]->getAddress()->getCountry()); - $this->assertEquals(10827, $result[0][0]->getAddress()->getZipCode()); + self::assertInstanceOf(CmsUser::class, $result[0][0]); + self::assertEquals('Fabio B. Silva', $result[0][0]->name); + self::assertInstanceOf(CmsAddress::class, $result[0][0]->getAddress()); + self::assertTrue($result[0][0]->getAddress()->getUser() === $result[0][0]); + self::assertEquals('Brazil', $result[0][0]->getAddress()->getCountry()); + self::assertEquals(10827, $result[0][0]->getAddress()->getZipCode()); - $this->assertEquals(1, $result[0]['numphones']); + self::assertEquals(1, $result[0]['numphones']); } /** @@ -686,38 +686,38 @@ public function testNamedNativeQueryInheritance(): void $flexMappings = $flexMetadata->getSqlResultSetMappings(); // contract queries - $this->assertEquals('all-contracts', $contractQueries['all-contracts']['name']); - $this->assertEquals(CompanyContract::class, $contractQueries['all-contracts']['resultClass']); + self::assertEquals('all-contracts', $contractQueries['all-contracts']['name']); + self::assertEquals(CompanyContract::class, $contractQueries['all-contracts']['resultClass']); - $this->assertEquals('all', $contractQueries['all']['name']); - $this->assertEquals(CompanyContract::class, $contractQueries['all']['resultClass']); + self::assertEquals('all', $contractQueries['all']['name']); + self::assertEquals(CompanyContract::class, $contractQueries['all']['resultClass']); // flex contract queries - $this->assertEquals('all-contracts', $flexQueries['all-contracts']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexQueries['all-contracts']['resultClass']); + self::assertEquals('all-contracts', $flexQueries['all-contracts']['name']); + self::assertEquals(CompanyFlexContract::class, $flexQueries['all-contracts']['resultClass']); - $this->assertEquals('all-flex', $flexQueries['all-flex']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexQueries['all-flex']['resultClass']); + self::assertEquals('all-flex', $flexQueries['all-flex']['name']); + self::assertEquals(CompanyFlexContract::class, $flexQueries['all-flex']['resultClass']); - $this->assertEquals('all', $flexQueries['all']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexQueries['all']['resultClass']); + self::assertEquals('all', $flexQueries['all']['name']); + self::assertEquals(CompanyFlexContract::class, $flexQueries['all']['resultClass']); // contract result mapping - $this->assertEquals('mapping-all-contracts', $contractMappings['mapping-all-contracts']['name']); - $this->assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); + self::assertEquals('mapping-all-contracts', $contractMappings['mapping-all-contracts']['name']); + self::assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); - $this->assertEquals('mapping-all', $contractMappings['mapping-all']['name']); - $this->assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); + self::assertEquals('mapping-all', $contractMappings['mapping-all']['name']); + self::assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); // flex contract result mapping - $this->assertEquals('mapping-all-contracts', $flexMappings['mapping-all-contracts']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-contracts']['entities'][0]['entityClass']); + self::assertEquals('mapping-all-contracts', $flexMappings['mapping-all-contracts']['name']); + self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-contracts']['entities'][0]['entityClass']); - $this->assertEquals('mapping-all', $flexMappings['mapping-all']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all']['entities'][0]['entityClass']); + self::assertEquals('mapping-all', $flexMappings['mapping-all']['name']); + self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all']['entities'][0]['entityClass']); - $this->assertEquals('mapping-all-flex', $flexMappings['mapping-all-flex']['name']); - $this->assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-flex']['entities'][0]['entityClass']); + self::assertEquals('mapping-all-flex', $flexMappings['mapping-all-flex']['name']); + self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-flex']['entities'][0]['entityClass']); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php index a7a1ea5e418..66593d8903d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php @@ -127,23 +127,23 @@ public function testShouldSupportsBasicUsage($hydrationMode): void $query = $this->_em->createQuery($dql); $result = $query->getResult($hydrationMode); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); } /** @@ -170,23 +170,23 @@ public function testShouldIgnoreAliasesForSingleObject($hydrationMode): void $query = $this->_em->createQuery($dql); $result = $query->getResult($hydrationMode); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); } public function testShouldAssumeFromEntityNamespaceWhenNotGiven(): void @@ -206,11 +206,11 @@ public function testShouldAssumeFromEntityNamespaceWhenNotGiven(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); } public function testShouldSupportFromEntityNamespaceAlias(): void @@ -233,11 +233,11 @@ public function testShouldSupportFromEntityNamespaceAlias(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); } public function testShouldSupportValueObjectNamespaceAlias(): void @@ -260,11 +260,11 @@ public function testShouldSupportValueObjectNamespaceAlias(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); } public function testShouldSupportLiteralExpression(): void @@ -293,27 +293,27 @@ public function testShouldSupportLiteralExpression(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals('fabio.bat.silva@gmail.com', $result[0]->email); - $this->assertEquals('fabio.bat.silva@gmail.com', $result[1]->email); - $this->assertEquals('fabio.bat.silva@gmail.com', $result[2]->email); + self::assertEquals('fabio.bat.silva@gmail.com', $result[0]->email); + self::assertEquals('fabio.bat.silva@gmail.com', $result[1]->email); + self::assertEquals('fabio.bat.silva@gmail.com', $result[2]->email); - $this->assertEquals(false, $result[0]->address); - $this->assertEquals(false, $result[1]->address); - $this->assertEquals(false, $result[2]->address); + self::assertEquals(false, $result[0]->address); + self::assertEquals(false, $result[1]->address); + self::assertEquals(false, $result[2]->address); - $this->assertEquals(123, $result[0]->phonenumbers); - $this->assertEquals(123, $result[1]->phonenumbers); - $this->assertEquals(123, $result[2]->phonenumbers); + self::assertEquals(123, $result[0]->phonenumbers); + self::assertEquals(123, $result[1]->phonenumbers); + self::assertEquals(123, $result[2]->phonenumbers); } public function testShouldSupportCaseExpression(): void @@ -340,19 +340,19 @@ public function testShouldSupportCaseExpression(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals('TEST1', $result[0]->email); - $this->assertEquals('OTHER_TEST', $result[1]->email); - $this->assertEquals('OTHER_TEST', $result[2]->email); + self::assertEquals('TEST1', $result[0]->email); + self::assertEquals('OTHER_TEST', $result[1]->email); + self::assertEquals('OTHER_TEST', $result[2]->email); } public function testShouldSupportSimpleArithmeticExpression(): void @@ -381,35 +381,35 @@ public function testShouldSupportSimpleArithmeticExpression(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); - $this->assertEquals( + self::assertEquals( $this->fixtures[0]->address->id + $this->fixtures[0]->id, $result[0]->phonenumbers ); - $this->assertEquals( + self::assertEquals( $this->fixtures[1]->address->id + $this->fixtures[1]->id, $result[1]->phonenumbers ); - $this->assertEquals( + self::assertEquals( $this->fixtures[2]->address->id + $this->fixtures[2]->id, $result[2]->phonenumbers ); @@ -441,35 +441,35 @@ public function testShouldSupportAggregateFunctions(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); - $this->assertEquals( + self::assertEquals( count($this->fixtures[0]->phonenumbers), $result[0]->phonenumbers ); - $this->assertEquals( + self::assertEquals( count($this->fixtures[1]->phonenumbers), $result[1]->phonenumbers ); - $this->assertEquals( + self::assertEquals( count($this->fixtures[2]->phonenumbers), $result[2]->phonenumbers ); @@ -501,35 +501,35 @@ public function testShouldSupportArithmeticExpression(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]); + self::assertInstanceOf(CmsUserDTO::class, $result[0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1]); + self::assertInstanceOf(CmsUserDTO::class, $result[2]); - $this->assertEquals($this->fixtures[0]->name, $result[0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]->name); + self::assertEquals($this->fixtures[0]->name, $result[0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1]->name); + self::assertEquals($this->fixtures[2]->name, $result[2]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]->address); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]->address); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]->address); + self::assertEquals($this->fixtures[0]->address->city, $result[0]->address); + self::assertEquals($this->fixtures[1]->address->city, $result[1]->address); + self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); - $this->assertEquals( + self::assertEquals( count($this->fixtures[0]->phonenumbers) + $this->fixtures[0]->id, $result[0]->phonenumbers ); - $this->assertEquals( + self::assertEquals( count($this->fixtures[1]->phonenumbers) + $this->fixtures[1]->id, $result[1]->phonenumbers ); - $this->assertEquals( + self::assertEquals( count($this->fixtures[2]->phonenumbers) + $this->fixtures[2]->id, $result[2]->phonenumbers ); @@ -559,31 +559,31 @@ public function testShouldSupportMultipleNewOperators(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[0][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[2][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][1]); - $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2][0]->name); + self::assertEquals($this->fixtures[0]->name, $result[0][0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1][0]->name); + self::assertEquals($this->fixtures[2]->name, $result[2][0]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); } public function testShouldSupportMultipleNewOperatorsWithAliases(): void @@ -610,31 +610,31 @@ public function testShouldSupportMultipleNewOperatorsWithAliases(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); } public function testShouldSupportMultipleNewOperatorsWithAndWithoutAliases(): void @@ -661,31 +661,31 @@ public function testShouldSupportMultipleNewOperatorsWithAndWithoutAliases(): vo $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][0]); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); } public function testShouldSupportMultipleNewOperatorsAndSingleScalar(): void @@ -713,35 +713,35 @@ public function testShouldSupportMultipleNewOperatorsAndSingleScalar(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[0][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[2][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][1]); - $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2][0]->name); + self::assertEquals($this->fixtures[0]->name, $result[0][0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1][0]->name); + self::assertEquals($this->fixtures[2]->name, $result[2][0]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['status']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['status']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['status']); + self::assertEquals($this->fixtures[0]->status, $result[0]['status']); + self::assertEquals($this->fixtures[1]->status, $result[1]['status']); + self::assertEquals($this->fixtures[2]->status, $result[2]['status']); } public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAliases(): void @@ -769,35 +769,35 @@ public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAliases( $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['cmsUserStatus']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['cmsUserStatus']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['cmsUserStatus']); + self::assertEquals($this->fixtures[0]->status, $result[0]['cmsUserStatus']); + self::assertEquals($this->fixtures[1]->status, $result[1]['cmsUserStatus']); + self::assertEquals($this->fixtures[2]->status, $result[2]['cmsUserStatus']); } public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAndWithoutAliases(): void @@ -825,35 +825,35 @@ public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAndWitho $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][0]); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['status']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['status']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['status']); + self::assertEquals($this->fixtures[0]->status, $result[0]['status']); + self::assertEquals($this->fixtures[1]->status, $result[1]['status']); + self::assertEquals($this->fixtures[2]->status, $result[2]['status']); } public function testShouldSupportMultipleNewOperatorsAndMultipleScalars(): void @@ -882,39 +882,39 @@ public function testShouldSupportMultipleNewOperatorsAndMultipleScalars(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsUserDTO::class, $result[2][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[0][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[1][0]); + self::assertInstanceOf(CmsUserDTO::class, $result[2][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][1]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][1]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][1]); - $this->assertEquals($this->fixtures[0]->name, $result[0][0]->name); - $this->assertEquals($this->fixtures[1]->name, $result[1][0]->name); - $this->assertEquals($this->fixtures[2]->name, $result[2][0]->name); + self::assertEquals($this->fixtures[0]->name, $result[0][0]->name); + self::assertEquals($this->fixtures[1]->name, $result[1][0]->name); + self::assertEquals($this->fixtures[2]->name, $result[2][0]->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['status']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['status']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['status']); + self::assertEquals($this->fixtures[0]->status, $result[0]['status']); + self::assertEquals($this->fixtures[1]->status, $result[1]['status']); + self::assertEquals($this->fixtures[2]->status, $result[2]['status']); - $this->assertEquals($this->fixtures[0]->username, $result[0]['username']); - $this->assertEquals($this->fixtures[1]->username, $result[1]['username']); - $this->assertEquals($this->fixtures[2]->username, $result[2]['username']); + self::assertEquals($this->fixtures[0]->username, $result[0]['username']); + self::assertEquals($this->fixtures[1]->username, $result[1]['username']); + self::assertEquals($this->fixtures[2]->username, $result[2]['username']); } public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAliases(): void @@ -943,39 +943,39 @@ public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAlias $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['cmsUserStatus']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['cmsUserStatus']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['cmsUserStatus']); + self::assertEquals($this->fixtures[0]->status, $result[0]['cmsUserStatus']); + self::assertEquals($this->fixtures[1]->status, $result[1]['cmsUserStatus']); + self::assertEquals($this->fixtures[2]->status, $result[2]['cmsUserStatus']); - $this->assertEquals($this->fixtures[0]->username, $result[0]['cmsUserUsername']); - $this->assertEquals($this->fixtures[1]->username, $result[1]['cmsUserUsername']); - $this->assertEquals($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + self::assertEquals($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertEquals($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertEquals($this->fixtures[2]->username, $result[2]['cmsUserUsername']); } public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAndWithoutAliases(): void @@ -1004,39 +1004,39 @@ public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAndWi $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertCount(3, $result); + self::assertCount(3, $result); - $this->assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); - $this->assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); - $this->assertInstanceOf(CmsAddressDTO::class, $result[0][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[1][0]); - $this->assertInstanceOf(CmsAddressDTO::class, $result[2][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[0][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[1][0]); + self::assertInstanceOf(CmsAddressDTO::class, $result[2][0]); - $this->assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); - $this->assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); - $this->assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); + self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); + self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); + self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); - $this->assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); - $this->assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); - $this->assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); + self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); + self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); + self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); - $this->assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); - $this->assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); - $this->assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); + self::assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); + self::assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); + self::assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); - $this->assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); - $this->assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); - $this->assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); + self::assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); + self::assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); + self::assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); - $this->assertEquals($this->fixtures[0]->status, $result[0]['status']); - $this->assertEquals($this->fixtures[1]->status, $result[1]['status']); - $this->assertEquals($this->fixtures[2]->status, $result[2]['status']); + self::assertEquals($this->fixtures[0]->status, $result[0]['status']); + self::assertEquals($this->fixtures[1]->status, $result[1]['status']); + self::assertEquals($this->fixtures[2]->status, $result[2]['status']); - $this->assertEquals($this->fixtures[0]->username, $result[0]['cmsUserUsername']); - $this->assertEquals($this->fixtures[1]->username, $result[1]['cmsUserUsername']); - $this->assertEquals($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + self::assertEquals($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertEquals($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertEquals($this->fixtures[2]->username, $result[2]['cmsUserUsername']); } public function testInvalidClassException(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index dc4fd1d3d5a..8a852a97336 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -58,26 +58,26 @@ public function testChangeTracking(): void $this->_em->persist($user); $this->_em->persist($group); - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); + self::assertEquals(1, count($user->listeners)); + self::assertEquals(1, count($group->listeners)); $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); + self::assertEquals(1, count($user->listeners)); + self::assertEquals(1, count($group->listeners)); $userId = $user->getId(); $groupId = $group->getId(); unset($user, $group); $user = $this->_em->find(NotifyUser::class, $userId); - $this->assertEquals(1, $user->getGroups()->count()); + self::assertEquals(1, $user->getGroups()->count()); $group = $this->_em->find(NotifyGroup::class, $groupId); - $this->assertEquals(1, $group->getUsers()->count()); + self::assertEquals(1, $group->getUsers()->count()); - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); + self::assertEquals(1, count($user->listeners)); + self::assertEquals(1, count($group->listeners)); $group2 = new NotifyGroup(); $group2->setName('nerds'); @@ -90,19 +90,19 @@ public function testChangeTracking(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(1, count($user->listeners)); - $this->assertEquals(1, count($group->listeners)); + self::assertEquals(1, count($user->listeners)); + self::assertEquals(1, count($group->listeners)); $group2Id = $group2->getId(); unset($group2, $user); $user = $this->_em->find(NotifyUser::class, $userId); - $this->assertEquals(2, $user->getGroups()->count()); + self::assertEquals(2, $user->getGroups()->count()); $group2 = $this->_em->find(NotifyGroup::class, $group2Id); - $this->assertEquals(1, $group2->getUsers()->count()); + self::assertEquals(1, $group2->getUsers()->count()); $group = $this->_em->find(NotifyGroup::class, $groupId); - $this->assertEquals(1, $group->getUsers()->count()); - $this->assertEquals('geeks', $group->getName()); + self::assertEquals(1, $group->getUsers()->count()); + self::assertEquals('geeks', $group->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index bd5e3edb172..60c639668c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -55,7 +55,7 @@ public function testSavesAnEmptyCollection(): void $this->_em->persist($this->product); $this->_em->flush(); - $this->assertEquals(0, count($this->product->getFeatures())); + self::assertEquals(0, count($this->product->getFeatures())); } public function testDoesNotSaveAnInverseSideSet(): void @@ -89,14 +89,14 @@ public function testEagerLoadsOneToManyAssociation(): void $features = $product->getFeatures(); - $this->assertInstanceOf(ECommerceFeature::class, $features[0]); - $this->assertNotInstanceOf(Proxy::class, $features[0]->getProduct()); - $this->assertSame($product, $features[0]->getProduct()); - $this->assertEquals('Model writing tutorial', $features[0]->getDescription()); - $this->assertInstanceOf(ECommerceFeature::class, $features[1]); - $this->assertSame($product, $features[1]->getProduct()); - $this->assertNotInstanceOf(Proxy::class, $features[1]->getProduct()); - $this->assertEquals('Annotations examples', $features[1]->getDescription()); + self::assertInstanceOf(ECommerceFeature::class, $features[0]); + self::assertNotInstanceOf(Proxy::class, $features[0]->getProduct()); + self::assertSame($product, $features[0]->getProduct()); + self::assertEquals('Model writing tutorial', $features[0]->getDescription()); + self::assertInstanceOf(ECommerceFeature::class, $features[1]); + self::assertSame($product, $features[1]->getProduct()); + self::assertNotInstanceOf(Proxy::class, $features[1]->getProduct()); + self::assertEquals('Annotations examples', $features[1]->getDescription()); } public function testLazyLoadsObjectsOnTheOwningSide(): void @@ -108,14 +108,14 @@ public function testLazyLoadsObjectsOnTheOwningSide(): void $product = $result[0]; $features = $product->getFeatures(); - $this->assertFalse($features->isInitialized()); - $this->assertInstanceOf(ECommerceFeature::class, $features[0]); - $this->assertTrue($features->isInitialized()); - $this->assertSame($product, $features[0]->getProduct()); - $this->assertEquals('Model writing tutorial', $features[0]->getDescription()); - $this->assertInstanceOf(ECommerceFeature::class, $features[1]); - $this->assertSame($product, $features[1]->getProduct()); - $this->assertEquals('Annotations examples', $features[1]->getDescription()); + self::assertFalse($features->isInitialized()); + self::assertInstanceOf(ECommerceFeature::class, $features[0]); + self::assertTrue($features->isInitialized()); + self::assertSame($product, $features[0]->getProduct()); + self::assertEquals('Model writing tutorial', $features[0]->getDescription()); + self::assertInstanceOf(ECommerceFeature::class, $features[1]); + self::assertSame($product, $features[1]->getProduct()); + self::assertEquals('Annotations examples', $features[1]->getDescription()); } public function testLazyLoadsObjectsOnTheInverseSide(): void @@ -126,11 +126,11 @@ public function testLazyLoadsObjectsOnTheInverseSide(): void $features = $query->getResult(); $product = $features[0]->getProduct(); - $this->assertInstanceOf(Proxy::class, $product); - $this->assertInstanceOf(ECommerceProduct::class, $product); - $this->assertFalse($product->__isInitialized__); - $this->assertSame('Doctrine Cookbook', $product->getName()); - $this->assertTrue($product->__isInitialized__); + self::assertInstanceOf(Proxy::class, $product); + self::assertInstanceOf(ECommerceProduct::class, $product); + self::assertFalse($product->__isInitialized__); + self::assertSame('Doctrine Cookbook', $product->getName()); + self::assertTrue($product->__isInitialized__); } public function testLazyLoadsObjectsOnTheInverseSide2(): void @@ -142,11 +142,11 @@ public function testLazyLoadsObjectsOnTheInverseSide2(): void $features = $query->getResult(); $product = $features[0]->getProduct(); - $this->assertNotInstanceOf(Proxy::class, $product); - $this->assertInstanceOf(ECommerceProduct::class, $product); - $this->assertSame('Doctrine Cookbook', $product->getName()); + self::assertNotInstanceOf(Proxy::class, $product); + self::assertInstanceOf(ECommerceProduct::class, $product); + self::assertSame('Doctrine Cookbook', $product->getName()); - $this->assertFalse($product->getFeatures()->isInitialized()); + self::assertFalse($product->getFeatures()->isInitialized()); // This would trigger lazy-load //$this->assertEquals(2, $product->getFeatures()->count()); @@ -160,7 +160,7 @@ public function testJoinFromOwningSide(): void { $query = $this->_em->createQuery('select f,p from Doctrine\Tests\Models\ECommerce\ECommerceFeature f join f.product p'); $features = $query->getResult(); - $this->assertEquals(0, count($features)); + self::assertEquals(0, count($features)); } /** @@ -177,13 +177,13 @@ public function testMatching(): void Criteria::expr()->eq('description', 'Model writing tutorial') )); - $this->assertInstanceOf(Collection::class, $results); - $this->assertEquals(1, count($results)); + self::assertInstanceOf(Collection::class, $results); + self::assertEquals(1, count($results)); $results = $features->matching(new Criteria()); - $this->assertInstanceOf(Collection::class, $results); - $this->assertEquals(2, count($results)); + self::assertInstanceOf(Collection::class, $results); + self::assertEquals(2, count($results)); } /** @@ -205,7 +205,7 @@ public function testMatchingOnDirtyCollection(): void Criteria::expr()->eq('description', 'Model writing tutorial') )); - $this->assertEquals(2, count($results)); + self::assertEquals(2, count($results)); } public function testMatchingBis(): void @@ -223,13 +223,13 @@ public function testMatchingBis(): void Criteria::expr()->eq('description', 'Third feature') )); - $this->assertInstanceOf(Collection::class, $results); - $this->assertCount(1, $results); + self::assertInstanceOf(Collection::class, $results); + self::assertCount(1, $results); $results = $features->matching(new Criteria()); - $this->assertInstanceOf(Collection::class, $results); - $this->assertCount(3, $results); + self::assertInstanceOf(Collection::class, $results); + self::assertCount(3, $results); } private function createFixture(): void @@ -248,6 +248,6 @@ public function assertFeatureForeignKeyIs($value, ECommerceFeature $feature): vo 'SELECT product_id FROM ecommerce_features WHERE id=?', [$feature->getId()] )->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php index 220928d9383..1d807be45ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php @@ -56,12 +56,12 @@ public function testOrphanRemoval(): void $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); + self::assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + self::assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); } /** @@ -79,7 +79,7 @@ public function testOrphanRemovalRemoveFromCollection(): void $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(1, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + self::assertEquals(1, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); } /** @@ -99,7 +99,7 @@ public function testOrphanRemovalClearCollectionAndReAdd(): void $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(1, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + self::assertEquals(1, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); } /** @@ -120,7 +120,7 @@ public function testOrphanRemovalClearCollectionAndAddNew(): void $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(1, count($result), 'Old CmsPhonenumbers should be removed by orphanRemoval and new one added'); + self::assertEquals(1, count($result), 'Old CmsPhonenumbers should be removed by orphanRemoval and new one added'); } /** @@ -136,6 +136,6 @@ public function testOrphanRemovalUnitializedCollection(): void $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + self::assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php index 72261d8ef5e..5ed920b44c7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php @@ -54,7 +54,7 @@ public function testSavesAnEmptyCollection(): void $this->_em->persist($this->parent); $this->_em->flush(); - $this->assertEquals(0, count($this->parent->getChildren())); + self::assertEquals(0, count($this->parent->getChildren())); } public function testDoesNotSaveAnInverseSideSet(): void @@ -85,16 +85,16 @@ public function testEagerLoadsOneToManyAssociation(): void $query = $this->_em->createQuery('select c1, c2 from Doctrine\Tests\Models\ECommerce\ECommerceCategory c1 join c1.children c2'); $result = $query->getResult(); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); $parent = $result[0]; $children = $parent->getChildren(); - $this->assertInstanceOf(ECommerceCategory::class, $children[0]); - $this->assertSame($parent, $children[0]->getParent()); - $this->assertEquals(' books', strstr($children[0]->getName(), ' books')); - $this->assertInstanceOf(ECommerceCategory::class, $children[1]); - $this->assertSame($parent, $children[1]->getParent()); - $this->assertEquals(' books', strstr($children[1]->getName(), ' books')); + self::assertInstanceOf(ECommerceCategory::class, $children[0]); + self::assertSame($parent, $children[0]->getParent()); + self::assertEquals(' books', strstr($children[0]->getName(), ' books')); + self::assertInstanceOf(ECommerceCategory::class, $children[1]); + self::assertSame($parent, $children[1]->getParent()); + self::assertEquals(' books', strstr($children[1]->getName(), ' books')); } public function testLazyLoadsOneToManyAssociation(): void @@ -108,12 +108,12 @@ public function testLazyLoadsOneToManyAssociation(): void $parent = $result[0]; $children = $parent->getChildren(); - $this->assertInstanceOf(ECommerceCategory::class, $children[0]); - $this->assertSame($parent, $children[0]->getParent()); - $this->assertEquals(' books', strstr($children[0]->getName(), ' books')); - $this->assertInstanceOf(ECommerceCategory::class, $children[1]); - $this->assertSame($parent, $children[1]->getParent()); - $this->assertEquals(' books', strstr($children[1]->getName(), ' books')); + self::assertInstanceOf(ECommerceCategory::class, $children[0]); + self::assertSame($parent, $children[0]->getParent()); + self::assertEquals(' books', strstr($children[0]->getName(), ' books')); + self::assertInstanceOf(ECommerceCategory::class, $children[1]); + self::assertSame($parent, $children[1]->getParent()); + self::assertEquals(' books', strstr($children[1]->getName(), ' books')); } private function createFixture(): void @@ -129,6 +129,6 @@ private function createFixture(): void public function assertForeignKeyIs($value, ECommerceCategory $child): void { $foreignKey = $this->_em->getConnection()->executeQuery('SELECT parent_id FROM ecommerce_categories WHERE id=?', [$child->getId()])->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php index bbdfc44c2c9..a937597fbf2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php @@ -58,9 +58,9 @@ public function testPersistOwningInverseCascade(): void 'JOIN r.legs l JOIN l.fromLocation f JOIN l.toLocation t' )->getSingleResult(); - $this->assertEquals(1, count($routes->legs)); - $this->assertEquals('Berlin', $routes->legs[0]->fromLocation->name); - $this->assertEquals('Bonn', $routes->legs[0]->toLocation->name); + self::assertEquals(1, count($routes->legs)); + self::assertEquals('Berlin', $routes->legs[0]->fromLocation->name); + self::assertEquals('Bonn', $routes->legs[0]->toLocation->name); } public function testLegsAreUniqueToRoutes(): void @@ -88,6 +88,6 @@ public function testLegsAreUniqueToRoutes(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown, 'The underlying database driver throws an exception.'); + self::assertTrue($exceptionThrown, 'The underlying database driver throws an exception.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php index 66e37746a53..962e5bd48a2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php @@ -68,8 +68,8 @@ public function testEagerLoad(): void $result = $query->getResult(); $customer = $result[0]; - $this->assertInstanceOf(ECommerceCart::class, $customer->getCart()); - $this->assertEquals('paypal', $customer->getCart()->getPayment()); + self::assertInstanceOf(ECommerceCart::class, $customer->getCart()); + self::assertEquals('paypal', $customer->getCart()->getPayment()); } public function testLazyLoadsObjectsOnTheOwningSide(): void @@ -82,8 +82,8 @@ public function testLazyLoadsObjectsOnTheOwningSide(): void $result = $query->getResult(); $cart = $result[0]; - $this->assertInstanceOf(ECommerceCustomer::class, $cart->getCustomer()); - $this->assertEquals('Giorgio', $cart->getCustomer()->getName()); + self::assertInstanceOf(ECommerceCustomer::class, $cart->getCustomer()); + self::assertEquals('Giorgio', $cart->getCustomer()->getName()); } public function testInverseSideIsNeverLazy(): void @@ -96,10 +96,10 @@ public function testInverseSideIsNeverLazy(): void $result = $query->getResult(); $customer = $result[0]; - $this->assertNull($customer->getMentor()); - $this->assertInstanceOf(ECommerceCart::class, $customer->getCart()); - $this->assertNotInstanceOf(Proxy::class, $customer->getCart()); - $this->assertEquals('paypal', $customer->getCart()->getPayment()); + self::assertNull($customer->getMentor()); + self::assertInstanceOf(ECommerceCart::class, $customer->getCart()); + self::assertNotInstanceOf(Proxy::class, $customer->getCart()); + self::assertEquals('paypal', $customer->getCart()->getPayment()); } public function testUpdateWithProxyObject(): void @@ -114,9 +114,9 @@ public function testUpdateWithProxyObject(): void $this->_em->flush(); $this->_em->clear(); - $this->assertInstanceOf(ECommerceCart::class, $cust->getCart()); - $this->assertEquals('Roman', $cust->getName()); - $this->assertSame($cust, $cart->getCustomer()); + self::assertInstanceOf(ECommerceCart::class, $cust->getCart()); + self::assertEquals('Roman', $cust->getName()); + self::assertSame($cust, $cart->getCustomer()); $query = $this->_em->createQuery('select ca from Doctrine\Tests\Models\ECommerce\ECommerceCart ca where ca.id =?1'); $query->setParameter(1, $cart->getId()); @@ -133,8 +133,8 @@ public function testUpdateWithProxyObject(): void $cart3 = $query2->getSingleResult(); - $this->assertInstanceOf(ECommerceCustomer::class, $cart3->getCustomer()); - $this->assertEquals('Roman', $cart3->getCustomer()->getName()); + self::assertInstanceOf(ECommerceCustomer::class, $cart3->getCustomer()); + self::assertEquals('Roman', $cart3->getCustomer()->getName()); } protected function createFixture(): void @@ -154,6 +154,6 @@ protected function createFixture(): void public function assertCartForeignKeyIs($value): void { $foreignKey = $this->_em->getConnection()->executeQuery('SELECT customer_id FROM ecommerce_carts WHERE id=?', [$this->cart->getId()])->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 39ce7b3a4f1..1ba259486de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -64,10 +64,10 @@ public function testEagerLoadOneToOneOwningSide(): void $sqlCount = count($this->_sqlLoggerStack->queries); $train = $this->_em->find(get_class($train), $train->id); - $this->assertNotInstanceOf(Proxy::class, $train->driver); - $this->assertEquals('Benjamin', $train->driver->name); + self::assertNotInstanceOf(Proxy::class, $train->driver); + self::assertEquals('Benjamin', $train->driver->name); - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + self::assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); } /** @@ -84,10 +84,10 @@ public function testEagerLoadOneToOneNullOwningSide(): void $sqlCount = count($this->_sqlLoggerStack->queries); $train = $this->_em->find(get_class($train), $train->id); - $this->assertNotInstanceOf(Proxy::class, $train->driver); - $this->assertNull($train->driver); + self::assertNotInstanceOf(Proxy::class, $train->driver); + self::assertNull($train->driver); - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + self::assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); } /** @@ -105,10 +105,10 @@ public function testEagerLoadOneToOneInverseSide(): void $sqlCount = count($this->_sqlLoggerStack->queries); $driver = $this->_em->find(get_class($owner), $owner->id); - $this->assertNotInstanceOf(Proxy::class, $owner->train); - $this->assertNotNull($owner->train); + self::assertNotInstanceOf(Proxy::class, $owner->train); + self::assertNotNull($owner->train); - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + self::assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); } /** @@ -122,15 +122,15 @@ public function testEagerLoadOneToOneNullInverseSide(): void $this->_em->flush(); $this->_em->clear(); - $this->assertNull($driver->train); + self::assertNull($driver->train); $sqlCount = count($this->_sqlLoggerStack->queries); $driver = $this->_em->find(get_class($driver), $driver->id); - $this->assertNotInstanceOf(Proxy::class, $driver->train); - $this->assertNull($driver->train); + self::assertNotInstanceOf(Proxy::class, $driver->train); + self::assertNull($driver->train); - $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + self::assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); } public function testEagerLoadManyToOne(): void @@ -144,8 +144,8 @@ public function testEagerLoadManyToOne(): void $this->_em->clear(); $waggon = $this->_em->find(get_class($waggon), $waggon->id); - $this->assertNotInstanceOf(Proxy::class, $waggon->train); - $this->assertNotNull($waggon->train); + self::assertNotInstanceOf(Proxy::class, $waggon->train); + self::assertNotNull($waggon->train); } /** @@ -236,9 +236,9 @@ public function testEagerLoadingDoesNotBreakRefresh(): void $this->_em->getConnection()->exec('UPDATE TrainOrder SET train_id = NULL'); - $this->assertSame($train, $order->train); + self::assertSame($train, $order->train); $this->_em->refresh($order); - $this->assertTrue($order->train === null, 'Train reference was not refreshed to NULL.'); + self::assertTrue($order->train === null, 'Train reference was not refreshed to NULL.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php index 35caf365ede..fd353ecf34a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php @@ -53,12 +53,12 @@ public function testOrphanRemoval(): void $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); + self::assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); $query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsAddress should be removed by orphanRemoval'); + self::assertEquals(0, count($result), 'CmsAddress should be removed by orphanRemoval'); } public function testOrphanRemovalWhenUnlink(): void @@ -91,6 +91,6 @@ public function testOrphanRemovalWhenUnlink(): void $query = $this->_em->createQuery('SELECT e FROM Doctrine\Tests\Models\CMS\CmsEmail e'); $result = $query->getResult(); - $this->assertEquals(0, count($result), 'CmsEmail should be removed by orphanRemoval'); + self::assertEquals(0, count($result), 'CmsEmail should be removed by orphanRemoval'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index de43452ba5e..7028a497045 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -68,7 +68,7 @@ public function testFind(): void $id = $this->createFixture(); $customer = $this->_em->find(ECommerceCustomer::class, $id); - $this->assertNotInstanceOf(Proxy::class, $customer->getMentor()); + self::assertNotInstanceOf(Proxy::class, $customer->getMentor()); } public function testEagerLoadsAssociation(): void @@ -119,24 +119,24 @@ public function testMultiSelfReference(): void $entity2 = $this->_em->find(get_class($entity1), $entity1->getId()); - $this->assertInstanceOf(MultiSelfReference::class, $entity2->getOther1()); - $this->assertInstanceOf(MultiSelfReference::class, $entity2->getOther2()); - $this->assertNull($entity2->getOther1()->getOther1()); - $this->assertNull($entity2->getOther1()->getOther2()); - $this->assertNull($entity2->getOther2()->getOther1()); - $this->assertNull($entity2->getOther2()->getOther2()); + self::assertInstanceOf(MultiSelfReference::class, $entity2->getOther1()); + self::assertInstanceOf(MultiSelfReference::class, $entity2->getOther2()); + self::assertNull($entity2->getOther1()->getOther1()); + self::assertNull($entity2->getOther1()->getOther2()); + self::assertNull($entity2->getOther2()->getOther1()); + self::assertNull($entity2->getOther2()->getOther2()); } public function assertLoadingOfAssociation($customer): void { - $this->assertInstanceOf(ECommerceCustomer::class, $customer->getMentor()); - $this->assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName()); + self::assertInstanceOf(ECommerceCustomer::class, $customer->getMentor()); + self::assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName()); } public function assertForeignKeyIs($value): void { $foreignKey = $this->_em->getConnection()->executeQuery('SELECT mentor_id FROM ecommerce_customers WHERE id=?', [$this->customer->getId()])->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } private function createFixture(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php index b871e688148..e3b4ed621bf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php @@ -43,9 +43,9 @@ public function testFindFromOneToOneOwningSideJoinedTableInheritance(): void $foundCat = $this->_em->find(Pet::class, $cat->id); assert($foundCat instanceof Cat); - $this->assertInstanceOf(Cat::class, $foundCat); - $this->assertSame($cat->id, $foundCat->id); - $this->assertInstanceOf(LitterBox::class, $foundCat->litterBox); - $this->assertSame($cat->litterBox->id, $foundCat->litterBox->id); + self::assertInstanceOf(Cat::class, $foundCat); + self::assertSame($cat->id, $foundCat->id); + self::assertInstanceOf(LitterBox::class, $foundCat->litterBox); + self::assertSame($cat->litterBox->id, $foundCat->litterBox->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index 03d7a14a411..18deaf3f4c7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -62,8 +62,8 @@ public function testEagerLoad(): void $result = $query->getResult(); $product = $result[0]; - $this->assertInstanceOf(ECommerceShipping::class, $product->getShipping()); - $this->assertEquals(1, $product->getShipping()->getDays()); + self::assertInstanceOf(ECommerceShipping::class, $product->getShipping()); + self::assertEquals(1, $product->getShipping()->getDays()); } public function testLazyLoadsObjects(): void @@ -76,8 +76,8 @@ public function testLazyLoadsObjects(): void $result = $query->getResult(); $product = $result[0]; - $this->assertInstanceOf(ECommerceShipping::class, $product->getShipping()); - $this->assertEquals(1, $product->getShipping()->getDays()); + self::assertInstanceOf(ECommerceShipping::class, $product->getShipping()); + self::assertEquals(1, $product->getShipping()->getDays()); } public function testDoesNotLazyLoadObjectsIfConfigurationDoesNotAllowIt(): void @@ -90,7 +90,7 @@ public function testDoesNotLazyLoadObjectsIfConfigurationDoesNotAllowIt(): void $result = $query->getResult(); $product = $result[0]; - $this->assertNull($product->getShipping()); + self::assertNull($product->getShipping()); } protected function createFixture(): void @@ -113,7 +113,7 @@ public function assertForeignKeyIs($value): void 'SELECT shipping_id FROM ecommerce_products WHERE id=?', [$this->product->getId()] )->fetchColumn(); - $this->assertEquals($value, $foreignKey); + self::assertEquals($value, $foreignKey); } /** @@ -129,6 +129,6 @@ public function testNullForeignKey(): void $product = $this->_em->find(get_class($product), $product->getId()); - $this->assertNull($product->getShipping()); + self::assertNull($product->getShipping()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php index 0d494630cd1..62a655321f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php @@ -68,9 +68,9 @@ public function testLazyManyToManyCollectionIsRetrievedWithOrderByClause(): void $route = $this->_em->find(RoutingRoute::class, $routeId); - $this->assertEquals(2, count($route->legs)); - $this->assertEquals('Berlin', $route->legs[0]->fromLocation->getName()); - $this->assertEquals('Bonn', $route->legs[1]->fromLocation->getName()); + self::assertEquals(2, count($route->legs)); + self::assertEquals('Berlin', $route->legs[0]->fromLocation->getName()); + self::assertEquals('Bonn', $route->legs[1]->fromLocation->getName()); } public function testLazyOneToManyCollectionIsRetrievedWithOrderByClause(): void @@ -99,9 +99,9 @@ public function testLazyOneToManyCollectionIsRetrievedWithOrderByClause(): void $route = $this->_em->find(RoutingRoute::class, $routeId); - $this->assertEquals(2, count($route->bookings)); - $this->assertEquals('Benjamin', $route->bookings[0]->getPassengerName()); - $this->assertEquals('Guilherme', $route->bookings[1]->getPassengerName()); + self::assertEquals(2, count($route->bookings)); + self::assertEquals('Benjamin', $route->bookings[0]->getPassengerName()); + self::assertEquals('Guilherme', $route->bookings[1]->getPassengerName()); } public function testOrderedResultFromDqlQuery(): void @@ -112,8 +112,8 @@ public function testOrderedResultFromDqlQuery(): void ->setParameter(1, $routeId) ->getSingleResult(); - $this->assertEquals(2, count($route->legs)); - $this->assertEquals('Berlin', $route->legs[0]->fromLocation->getName()); - $this->assertEquals('Bonn', $route->legs[1]->fromLocation->getName()); + self::assertEquals(2, count($route->legs)); + self::assertEquals('Berlin', $route->legs[0]->fromLocation->getName()); + self::assertEquals('Bonn', $route->legs[1]->fromLocation->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php index 3f52c952420..42949373652 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php @@ -66,8 +66,8 @@ public function testOrderdOneToManyCollection(): void { $poofy = $this->_em->createQuery("SELECT p FROM Doctrine\Tests\ORM\Functional\OJTICPet p WHERE p.name = 'Poofy'")->getSingleResult(); - $this->assertEquals('Aari', $poofy->children[0]->getName()); - $this->assertEquals('Zampa', $poofy->children[1]->getName()); + self::assertEquals('Aari', $poofy->children[0]->getName()); + self::assertEquals('Zampa', $poofy->children[1]->getName()); $this->_em->clear(); @@ -76,11 +76,11 @@ public function testOrderdOneToManyCollection(): void ) ->getResult(); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); $poofy = $result[0]; - $this->assertEquals('Aari', $poofy->children[0]->getName()); - $this->assertEquals('Zampa', $poofy->children[1]->getName()); + self::assertEquals('Aari', $poofy->children[0]->getName()); + self::assertEquals('Zampa', $poofy->children[1]->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index af9db728735..7bdfa16cdbe 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -59,7 +59,7 @@ public function testCountSimpleWithoutJoin($useOutputWalkers): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator); + self::assertCount(9, $paginator); } /** @@ -72,7 +72,7 @@ public function testCountWithFetchJoin($useOutputWalkers): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator); + self::assertCount(9, $paginator); } public function testCountComplexWithOutputWalker(): void @@ -82,7 +82,7 @@ public function testCountComplexWithOutputWalker(): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers(true); - $this->assertCount(3, $paginator); + self::assertCount(3, $paginator); } public function testCountComplexWithoutOutputWalker(): void @@ -96,7 +96,7 @@ public function testCountComplexWithoutOutputWalker(): void $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); - $this->assertCount(3, $paginator); + self::assertCount(3, $paginator); } /** @@ -109,7 +109,7 @@ public function testCountWithComplexScalarOrderBy($useOutputWalkers): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator); + self::assertCount(9, $paginator); } /** @@ -122,19 +122,19 @@ public function testIterateSimpleWithoutJoin($useOutputWalkers, $fetchJoinCollec $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator->getIterator()); + self::assertCount(9, $paginator->getIterator()); // Test with limit $query->setMaxResults(3); $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator->getIterator()); + self::assertCount(3, $paginator->getIterator()); // Test with limit and offset $query->setMaxResults(3)->setFirstResult(4); $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(3, $paginator->getIterator()); + self::assertCount(3, $paginator->getIterator()); } private function iterateWithOrderAsc($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -146,9 +146,9 @@ private function iterateWithOrderAsc($useOutputWalkers, $fetchJoinCollection, $b $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(9, $iter); + self::assertCount(9, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '0', $result[0]->$checkField); + self::assertEquals($checkField . '0', $result[0]->$checkField); } private function iterateWithOrderAscWithLimit($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -162,9 +162,9 @@ private function iterateWithOrderAscWithLimit($useOutputWalkers, $fetchJoinColle $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(3, $iter); + self::assertCount(3, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '0', $result[0]->$checkField); + self::assertEquals($checkField . '0', $result[0]->$checkField); } private function iterateWithOrderAscWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -178,9 +178,9 @@ private function iterateWithOrderAscWithLimitAndOffset($useOutputWalkers, $fetch $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(3, $iter); + self::assertCount(3, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '3', $result[0]->$checkField); + self::assertEquals($checkField . '3', $result[0]->$checkField); } private function iterateWithOrderDesc($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -191,9 +191,9 @@ private function iterateWithOrderDesc($useOutputWalkers, $fetchJoinCollection, $ $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(9, $iter); + self::assertCount(9, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '8', $result[0]->$checkField); + self::assertEquals($checkField . '8', $result[0]->$checkField); } private function iterateWithOrderDescWithLimit($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -206,9 +206,9 @@ private function iterateWithOrderDescWithLimit($useOutputWalkers, $fetchJoinColl $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(3, $iter); + self::assertCount(3, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '8', $result[0]->$checkField); + self::assertEquals($checkField . '8', $result[0]->$checkField); } private function iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection, $baseDql, $checkField): void @@ -221,9 +221,9 @@ private function iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetc $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalkers); $iter = $paginator->getIterator(); - $this->assertCount(3, $iter); + self::assertCount(3, $iter); $result = iterator_to_array($iter); - $this->assertEquals($checkField . '5', $result[0]->$checkField); + self::assertEquals($checkField . '5', $result[0]->$checkField); } /** @@ -302,7 +302,7 @@ public function testIterateWithFetchJoin($useOutputWalkers): void $paginator = new Paginator($query, true); $paginator->setUseOutputWalkers($useOutputWalkers); - $this->assertCount(9, $paginator->getIterator()); + self::assertCount(9, $paginator->getIterator()); } /** @@ -478,7 +478,7 @@ public function testIterateComplexWithOutputWalker(): void $paginator = new Paginator($query); $paginator->setUseOutputWalkers(true); - $this->assertCount(3, $paginator->getIterator()); + self::assertCount(3, $paginator->getIterator()); } public function testJoinedClassTableInheritance(): void @@ -487,7 +487,7 @@ public function testJoinedClassTableInheritance(): void $query = $this->_em->createQuery($dql); $paginator = new Paginator($query); - $this->assertCount(1, $paginator->getIterator()); + self::assertCount(1, $paginator->getIterator()); } /** @@ -588,7 +588,7 @@ public function testCountWithCountSubqueryInWhereClauseWithOutputWalker(): void $paginator = new Paginator($query, true); $paginator->setUseOutputWalkers(true); - $this->assertCount(9, $paginator); + self::assertCount(9, $paginator); } public function testIterateWithCountSubqueryInWhereClause(): void @@ -600,9 +600,9 @@ public function testIterateWithCountSubqueryInWhereClause(): void $paginator->setUseOutputWalkers(true); $users = iterator_to_array($paginator->getIterator()); - $this->assertCount(9, $users); + self::assertCount(9, $users); foreach ($users as $i => $user) { - $this->assertEquals('username' . (8 - $i), $user->username); + self::assertEquals('username' . (8 - $i), $user->username); } } @@ -634,7 +634,7 @@ public function testPaginationWithColumnAttributeNameDifference(): void $paginator = new Paginator($query); $paginator->getIterator(); - $this->assertCount(9, $paginator->getIterator()); + self::assertCount(9, $paginator->getIterator()); } public function testCloneQuery(): void @@ -645,7 +645,7 @@ public function testCloneQuery(): void $paginator = new Paginator($query); $paginator->getIterator(); - $this->assertTrue($query->getParameters()->isEmpty()); + self::assertTrue($query->getParameters()->isEmpty()); } public function testQueryWalkerIsKept(): void @@ -656,8 +656,8 @@ public function testQueryWalkerIsKept(): void $paginator = new Paginator($query, true); $paginator->setUseOutputWalkers(false); - $this->assertCount(1, $paginator->getIterator()); - $this->assertEquals(1, $paginator->count()); + self::assertCount(1, $paginator->getIterator()); + self::assertEquals(1, $paginator->count()); } /** @@ -698,8 +698,8 @@ public function testCountQueryStripsParametersInSelect(): void $getCountQuery->setAccessible(true); - $this->assertCount(2, $getCountQuery->invoke($paginator)->getParameters()); - $this->assertCount(9, $paginator); + self::assertCount(2, $getCountQuery->invoke($paginator)->getParameters()); + self::assertCount(9, $paginator); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, Query\SqlWalker::class); @@ -707,8 +707,8 @@ public function testCountQueryStripsParametersInSelect(): void // if select part of query is replaced with count(...) paginator should remove // parameters from query object not used in new query. - $this->assertCount(1, $getCountQuery->invoke($paginator)->getParameters()); - $this->assertCount(9, $paginator); + self::assertCount(1, $getCountQuery->invoke($paginator)->getParameters()); + self::assertCount(9, $paginator); } /** @@ -732,7 +732,7 @@ public function testPaginationWithSubSelectOrderByExpression($useOutputWalker, $ $paginator = new Paginator($query, $fetchJoinCollection); $paginator->setUseOutputWalkers($useOutputWalker); - $this->assertCount(9, $paginator->getIterator()); + self::assertCount(9, $paginator->getIterator()); } public function populate(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php index 0b2febce3e5..f324e78981a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php @@ -78,19 +78,19 @@ public function testCanCountWithoutLoadingPersistentCollection(): void $user = $repository->findOneBy(['name' => 'ngal']); $tweets = $user->tweets->matching(new Criteria()); - $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets); - $this->assertFalse($tweets->isInitialized()); - $this->assertCount(2, $tweets); - $this->assertFalse($tweets->isInitialized()); + self::assertInstanceOf(LazyCriteriaCollection::class, $tweets); + self::assertFalse($tweets->isInitialized()); + self::assertCount(2, $tweets); + self::assertFalse($tweets->isInitialized()); // Make sure it works with constraints $tweets = $user->tweets->matching(new Criteria( Criteria::expr()->eq('content', 'Foo') )); - $this->assertInstanceOf(LazyCriteriaCollection::class, $tweets); - $this->assertFalse($tweets->isInitialized()); - $this->assertCount(1, $tweets); - $this->assertFalse($tweets->isInitialized()); + self::assertInstanceOf(LazyCriteriaCollection::class, $tweets); + self::assertFalse($tweets->isInitialized()); + self::assertCount(1, $tweets); + self::assertFalse($tweets->isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php index a6727a1ae45..82da5a0f2e5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php @@ -50,7 +50,7 @@ public function testPersist(): void $content = new PersistentCollectionContent('second element'); $collectionHolder->addElement($content); - $this->assertEquals(2, $collectionHolder->getCollection()->count()); + self::assertEquals(2, $collectionHolder->getCollection()->count()); } /** @@ -67,8 +67,8 @@ public function testExtraLazyIsEmptyDoesNotInitializeCollection(): void $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId()); $collection = $collectionHolder->getRawCollection(); - $this->assertTrue($collection->isEmpty()); - $this->assertFalse($collection->isInitialized()); + self::assertTrue($collection->isEmpty()); + self::assertFalse($collection->isInitialized()); $collectionHolder->addElement(new PersistentCollectionContent()); @@ -78,8 +78,8 @@ public function testExtraLazyIsEmptyDoesNotInitializeCollection(): void $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId()); $collection = $collectionHolder->getRawCollection(); - $this->assertFalse($collection->isEmpty()); - $this->assertFalse($collection->isInitialized()); + self::assertFalse($collection->isEmpty()); + self::assertFalse($collection->isInitialized()); } /** @@ -99,10 +99,10 @@ public function testMatchingDoesNotModifyTheGivenCriteria(): void $collectionHolder = $this->_em->find(PersistentCollectionHolder::class, $collectionHolder->getId()); $collectionHolder->getCollection()->matching($criteria); - $this->assertEmpty($criteria->getWhereExpression()); - $this->assertEmpty($criteria->getFirstResult()); - $this->assertEmpty($criteria->getMaxResults()); - $this->assertEmpty($criteria->getOrderings()); + self::assertEmpty($criteria->getWhereExpression()); + self::assertEmpty($criteria->getFirstResult()); + self::assertEmpty($criteria->getMaxResults()); + self::assertEmpty($criteria->getOrderings()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php index 1b50aa5db94..7892603be37 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php @@ -59,7 +59,7 @@ public function testFind(): void $entity = $this->_em->find(PersistentEntity::class, $entity->getId()); - $this->assertEquals('test', $entity->getName()); + self::assertEquals('test', $entity->getName()); $entity->setName('foobar'); $this->_em->flush(); @@ -76,7 +76,7 @@ public function testGetReference(): void $entity = $this->_em->getReference(PersistentEntity::class, $entity->getId()); - $this->assertEquals('test', $entity->getName()); + self::assertEquals('test', $entity->getName()); } public function testSetAssociation(): void @@ -90,7 +90,7 @@ public function testSetAssociation(): void $this->_em->clear(); $entity = $this->_em->getReference(PersistentEntity::class, $entity->getId()); - $this->assertSame($entity, $entity->getParent()); + self::assertSame($entity, $entity->getParent()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php index 3bf1a13c526..2dc289314b5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php @@ -31,7 +31,7 @@ public function testListenerShouldBeNotified(): void { $this->_em->persist($this->createNewValidUser()); $this->_em->flush(); - $this->assertTrue($this->listener->wasNotified); + self::assertTrue($this->listener->wasNotified); } public function testListenerShouldNotBeNotifiedWhenFlushThrowsException(): void @@ -47,8 +47,8 @@ public function testListenerShouldNotBeNotifiedWhenFlushThrowsException(): void $exceptionRaised = true; } - $this->assertTrue($exceptionRaised); - $this->assertFalse($this->listener->wasNotified); + self::assertTrue($exceptionRaised); + self::assertFalse($this->listener->wasNotified); } public function testListenerShouldReceiveEntityManagerThroughArgs(): void @@ -56,7 +56,7 @@ public function testListenerShouldReceiveEntityManagerThroughArgs(): void $this->_em->persist($this->createNewValidUser()); $this->_em->flush(); $receivedEm = $this->listener->receivedArgs->getEntityManager(); - $this->assertSame($this->_em, $receivedEm); + self::assertSame($this->_em, $receivedEm); } private function createNewValidUser(): CmsUser diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php index c1be08c5558..0bf84cbe68c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php @@ -34,9 +34,9 @@ public function testLoadedEntityUsingFindShouldTriggerEvent(): void // CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser $mockListener - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -51,9 +51,9 @@ public function testLoadedEntityUsingQueryShouldTriggerEvent(): void // CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser $mockListener - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -71,9 +71,9 @@ public function testLoadedAssociationToOneShouldTriggerEvent(): void // CmsUser (root), CmsAddress (ToOne inverse side), CmsEmail (joined association) $mockListener - ->expects($this->exactly(3)) + ->expects(self::exactly(3)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -91,9 +91,9 @@ public function testLoadedAssociationToManyShouldTriggerEvent(): void // CmsUser (root), CmsAddress (ToOne inverse side), 2 CmsPhonenumber (joined association) $mockListener - ->expects($this->exactly(4)) + ->expects(self::exactly(4)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -113,9 +113,9 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void $mockListener = $this->createMock(PostLoadListener::class); $mockListener - ->expects($this->never()) + ->expects(self::never()) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager->addEventListener([Events::postLoad], $mockListener); @@ -127,9 +127,9 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void $mockListener2 = $this->createMock(PostLoadListener::class); $mockListener2 - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager->addEventListener([Events::postLoad], $mockListener2); @@ -145,9 +145,9 @@ public function testLoadedProxyPartialShouldTriggerEvent(): void // CmsUser (partially loaded), CmsAddress (inverse ToOne), 2 CmsPhonenumber $mockListener - ->expects($this->exactly(4)) + ->expects(self::exactly(4)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager->addEventListener([Events::postLoad], $mockListener); @@ -165,9 +165,9 @@ public function testLoadedProxyAssociationToOneShouldTriggerEvent(): void // CmsEmail (proxy) $mockListener - ->expects($this->exactly(1)) + ->expects(self::exactly(1)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -186,9 +186,9 @@ public function testLoadedProxyAssociationToManyShouldTriggerEvent(): void // 2 CmsPhonenumber (proxy) $mockListener - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('postLoad') - ->will($this->returnValue(true)); + ->will(self::returnValue(true)); $eventManager = $this->_em->getEventManager(); @@ -212,8 +212,8 @@ public function testAssociationsArePopulatedWhenEventIsFired(): void $qb->addSelect('email'); $qb->getQuery()->getSingleResult(); - $this->assertTrue($checkerListener->checked, 'postLoad event is not invoked'); - $this->assertTrue($checkerListener->populated, 'Association of email is not populated in postLoad event'); + self::assertTrue($checkerListener->checked, 'postLoad event is not invoked'); + self::assertTrue($checkerListener->populated, 'Association of email is not populated in postLoad event'); } /** @@ -226,8 +226,8 @@ public function testEventRaisedCorrectTimesWhenOtherEntityLoadedInEventHandler() $eventManager->addEventListener([Events::postLoad], $listener); $this->_em->find(CmsUser::class, $this->userId); - $this->assertSame(1, $listener->countHandledEvents(CmsUser::class), CmsUser::class . ' should be handled once!'); - $this->assertSame(1, $listener->countHandledEvents(CmsEmail::class), CmsEmail::class . ' should be handled once!'); + self::assertSame(1, $listener->countHandledEvents(CmsUser::class), CmsUser::class . ' should be handled once!'); + self::assertSame(1, $listener->countHandledEvents(CmsEmail::class), CmsEmail::class . ' should be handled once!'); } private function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php index 1178523cead..e7bc792a6d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php @@ -70,12 +70,12 @@ public function testPersistUpdate(): void $proxy->name = 'Marco'; $this->_em->persist($proxy); $this->_em->flush(); - $this->assertNotNull($proxy->getId()); + self::assertNotNull($proxy->getId()); $proxy->name = 'Marco Pivetta'; $this->_em->getUnitOfWork() ->computeChangeSet($this->_em->getClassMetadata(CmsUser::class), $proxy); - $this->assertNotEmpty($this->_em->getUnitOfWork()->getEntityChangeSet($proxy)); - $this->assertEquals('Marco Pivetta', $this->_em->find(CmsUser::class, $proxy->getId())->name); + self::assertNotEmpty($this->_em->getUnitOfWork()->getEntityChangeSet($proxy)); + self::assertEquals('Marco Pivetta', $this->_em->find(CmsUser::class, $proxy->getId())->name); $this->_em->remove($proxy); $this->_em->flush(); } @@ -85,12 +85,12 @@ public function testEntityWithIdentifier(): void $userId = $this->user->getId(); $uninitializedProxy = $this->_em->getReference(CmsUser::class, $userId); assert($uninitializedProxy instanceof CmsUserProxy); - $this->assertInstanceOf(CmsUserProxy::class, $uninitializedProxy); + self::assertInstanceOf(CmsUserProxy::class, $uninitializedProxy); $this->_em->persist($uninitializedProxy); $this->_em->flush(); - $this->assertFalse($uninitializedProxy->__isInitialized(), 'Proxy didn\'t get initialized during flush operations'); - $this->assertEquals($userId, $uninitializedProxy->getId()); + self::assertFalse($uninitializedProxy->__isInitialized(), 'Proxy didn\'t get initialized during flush operations'); + self::assertEquals($userId, $uninitializedProxy->getId()); $this->_em->remove($uninitializedProxy); $this->_em->flush(); } @@ -107,7 +107,7 @@ public function testProxyAsDqlParameterPersist(): void ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u = ?1') ->setParameter(1, $proxy) ->getSingleResult(); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->remove($proxy); $this->_em->flush(); } @@ -118,15 +118,15 @@ public function testProxyAsDqlParameterPersist(): void public function testFindWithProxyName(): void { $result = $this->_em->find(CmsUserProxy::class, $this->user->getId()); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->clear(); $result = $this->_em->getReference(CmsUserProxy::class, $this->user->getId()); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->clear(); $result = $this->_em->getRepository(CmsUserProxy::class)->findOneBy(['username' => $this->user->username]); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->clear(); $result = $this->_em @@ -134,7 +134,7 @@ public function testFindWithProxyName(): void ->setParameter(1, $this->user->getId()) ->getSingleResult(); - $this->assertSame($this->user->getId(), $result->getId()); + self::assertSame($this->user->getId(), $result->getId()); $this->_em->clear(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php index 4d02714f932..d142a9760e8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php @@ -46,11 +46,11 @@ public function testParenthesisOnSingleLine(): void $query = $queryBuilder->getQuery(); $results = $query->getResult(); - $this->assertCount(0, $results); + self::assertCount(0, $results); $dql = $query->getDQL(); - $this->assertSame( + self::assertSame( 'SELECT o FROM ' . QueryBuilderParenthesisEntity::class . ' o WHERE o.property3 = :value3 AND (o.property1 = :value1 OR o.property2 = :value2) AND (o.property1 = :value1 or o.property2 = :value2)', $dql ); @@ -71,11 +71,11 @@ public function testParenthesisOnMultiLine(): void $query = $queryBuilder->getQuery(); $results = $query->getResult(); - $this->assertCount(0, $results); + self::assertCount(0, $results); $dql = $query->getDQL(); - $this->assertSame( + self::assertSame( 'SELECT o FROM ' . QueryBuilderParenthesisEntity::class . ' o WHERE o.property3 = :value3 AND (o.property1 = :value1 OR o.property2 = :value2)', $dql diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php index 6ac78023fda..a564086b20e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php @@ -27,7 +27,7 @@ class QueryCacheTest extends OrmFunctionalTestCase protected function setUp(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $this->cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data'); @@ -51,12 +51,12 @@ public function testQueryCacheDependsOnHints(): Query $query->setQueryCacheDriver($cache); $query->getResult(); - $this->assertEquals(1, $this->getCacheSize($cache)); + self::assertEquals(1, $this->getCacheSize($cache)); $query->setHint('foo', 'bar'); $query->getResult(); - $this->assertEquals(2, $this->getCacheSize($cache)); + self::assertEquals(2, $this->getCacheSize($cache)); return $query; } @@ -75,7 +75,7 @@ public function testQueryCacheDependsOnFirstResult($query): void $query->setMaxResults(9999); $query->getResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + self::assertEquals($cacheCount + 1, $this->getCacheSize($cache)); } /** @@ -91,7 +91,7 @@ public function testQueryCacheDependsOnMaxResults($query): void $query->setMaxResults(10); $query->getResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + self::assertEquals($cacheCount + 1, $this->getCacheSize($cache)); } /** @@ -105,7 +105,7 @@ public function testQueryCacheDependsOnHydrationMode($query): void $cacheCount = $this->getCacheSize($cache); $query->getArrayResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + self::assertEquals($cacheCount + 1, $this->getCacheSize($cache)); } public function testQueryCacheNoHitSaveParserResult(): void @@ -136,33 +136,33 @@ public function testQueryCacheHitDoesNotSaveParserResult(): void ->setMethods(['execute']) ->getMock(); - $sqlExecMock->expects($this->once()) + $sqlExecMock->expects(self::once()) ->method('execute') - ->will($this->returnValue(10)); + ->will(self::returnValue(10)); $parserResultMock = $this->getMockBuilder(ParserResult::class) ->setMethods(['getSqlExecutor']) ->getMock(); - $parserResultMock->expects($this->once()) + $parserResultMock->expects(self::once()) ->method('getSqlExecutor') - ->will($this->returnValue($sqlExecMock)); + ->will(self::returnValue($sqlExecMock)); $cache = $this->getMockBuilder(CacheProvider::class) ->setMethods(['doFetch', 'doContains', 'doSave', 'doDelete', 'doFlush', 'doGetStats']) ->getMock(); - $cache->expects($this->exactly(2)) + $cache->expects(self::exactly(2)) ->method('doFetch') ->withConsecutive( - [$this->isType('string')], - [$this->isType('string')] + [self::isType('string')], + [self::isType('string')] ) ->willReturnOnConsecutiveCalls( - $this->returnValue(1), - $this->returnValue($parserResultMock) + self::returnValue(1), + self::returnValue($parserResultMock) ); - $cache->expects($this->never()) + $cache->expects(self::never()) ->method('doSave'); $query->setQueryCacheDriver($cache); diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index 228a474b434..8a188e3a5ad 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -32,7 +32,7 @@ public function testAggregateSum(): void $salarySum = $this->_em->createQuery('SELECT SUM(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(1500000, $salarySum['salary']); + self::assertEquals(1500000, $salarySum['salary']); } public function testAggregateAvg(): void @@ -40,7 +40,7 @@ public function testAggregateAvg(): void $salaryAvg = $this->_em->createQuery('SELECT AVG(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(375000, round((float) $salaryAvg['salary'], 0)); + self::assertEquals(375000, round((float) $salaryAvg['salary'], 0)); } public function testAggregateMin(): void @@ -48,7 +48,7 @@ public function testAggregateMin(): void $salary = $this->_em->createQuery('SELECT MIN(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(100000, $salary['salary']); + self::assertEquals(100000, $salary['salary']); } public function testAggregateMax(): void @@ -56,7 +56,7 @@ public function testAggregateMax(): void $salary = $this->_em->createQuery('SELECT MAX(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(800000, $salary['salary']); + self::assertEquals(800000, $salary['salary']); } public function testAggregateCount(): void @@ -64,7 +64,7 @@ public function testAggregateCount(): void $managerCount = $this->_em->createQuery('SELECT COUNT(m.id) AS managers FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - $this->assertEquals(4, $managerCount['managers']); + self::assertEquals(4, $managerCount['managers']); } public function testFunctionAbs(): void @@ -72,11 +72,11 @@ public function testFunctionAbs(): void $result = $this->_em->createQuery('SELECT m, ABS(m.salary * -1) AS abs FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(100000, $result[0]['abs']); - $this->assertEquals(200000, $result[1]['abs']); - $this->assertEquals(400000, $result[2]['abs']); - $this->assertEquals(800000, $result[3]['abs']); + self::assertEquals(4, count($result)); + self::assertEquals(100000, $result[0]['abs']); + self::assertEquals(200000, $result[1]['abs']); + self::assertEquals(400000, $result[2]['abs']); + self::assertEquals(800000, $result[3]['abs']); } public function testFunctionConcat(): void @@ -84,11 +84,11 @@ public function testFunctionConcat(): void $arg = $this->_em->createQuery('SELECT m, CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($arg)); - $this->assertEquals('Roman B.IT', $arg[0]['namedep']); - $this->assertEquals('Benjamin E.HR', $arg[1]['namedep']); - $this->assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); - $this->assertEquals('Jonathan W.Administration', $arg[3]['namedep']); + self::assertEquals(4, count($arg)); + self::assertEquals('Roman B.IT', $arg[0]['namedep']); + self::assertEquals('Benjamin E.HR', $arg[1]['namedep']); + self::assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); + self::assertEquals('Jonathan W.Administration', $arg[3]['namedep']); } public function testFunctionLength(): void @@ -96,11 +96,11 @@ public function testFunctionLength(): void $result = $this->_em->createQuery('SELECT m, LENGTH(CONCAT(m.name, m.department)) AS namedeplength FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(10, $result[0]['namedeplength']); - $this->assertEquals(13, $result[1]['namedeplength']); - $this->assertEquals(32, $result[2]['namedeplength']); - $this->assertEquals(25, $result[3]['namedeplength']); + self::assertEquals(4, count($result)); + self::assertEquals(10, $result[0]['namedeplength']); + self::assertEquals(13, $result[1]['namedeplength']); + self::assertEquals(32, $result[2]['namedeplength']); + self::assertEquals(25, $result[3]['namedeplength']); } public function testFunctionLocate(): void @@ -111,15 +111,15 @@ public function testFunctionLocate(): void $result = $this->_em->createQuery($dql) ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(0, $result[0]['loc']); - $this->assertEquals(2, $result[1]['loc']); - $this->assertEquals(6, $result[2]['loc']); - $this->assertEquals(0, $result[3]['loc']); - $this->assertEquals(0, $result[0]['loc2']); - $this->assertEquals(10, $result[1]['loc2']); - $this->assertEquals(9, $result[2]['loc2']); - $this->assertEquals(0, $result[3]['loc2']); + self::assertEquals(4, count($result)); + self::assertEquals(0, $result[0]['loc']); + self::assertEquals(2, $result[1]['loc']); + self::assertEquals(6, $result[2]['loc']); + self::assertEquals(0, $result[3]['loc']); + self::assertEquals(0, $result[0]['loc2']); + self::assertEquals(10, $result[1]['loc2']); + self::assertEquals(9, $result[2]['loc2']); + self::assertEquals(0, $result[3]['loc2']); } public function testFunctionLower(): void @@ -127,11 +127,11 @@ public function testFunctionLower(): void $result = $this->_em->createQuery('SELECT m, LOWER(m.name) AS lowername FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals('roman b.', $result[0]['lowername']); - $this->assertEquals('benjamin e.', $result[1]['lowername']); - $this->assertEquals('guilherme b.', $result[2]['lowername']); - $this->assertEquals('jonathan w.', $result[3]['lowername']); + self::assertEquals(4, count($result)); + self::assertEquals('roman b.', $result[0]['lowername']); + self::assertEquals('benjamin e.', $result[1]['lowername']); + self::assertEquals('guilherme b.', $result[2]['lowername']); + self::assertEquals('jonathan w.', $result[3]['lowername']); } public function testFunctionMod(): void @@ -139,11 +139,11 @@ public function testFunctionMod(): void $result = $this->_em->createQuery('SELECT m, MOD(m.salary, 3500) AS amod FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(2000, $result[0]['amod']); - $this->assertEquals(500, $result[1]['amod']); - $this->assertEquals(1000, $result[2]['amod']); - $this->assertEquals(2000, $result[3]['amod']); + self::assertEquals(4, count($result)); + self::assertEquals(2000, $result[0]['amod']); + self::assertEquals(500, $result[1]['amod']); + self::assertEquals(1000, $result[2]['amod']); + self::assertEquals(2000, $result[3]['amod']); } public function testFunctionSqrt(): void @@ -151,11 +151,11 @@ public function testFunctionSqrt(): void $result = $this->_em->createQuery('SELECT m, SQRT(m.salary) AS sqrtsalary FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(316, round((float) $result[0]['sqrtsalary'])); - $this->assertEquals(447, round((float) $result[1]['sqrtsalary'])); - $this->assertEquals(632, round((float) $result[2]['sqrtsalary'])); - $this->assertEquals(894, round((float) $result[3]['sqrtsalary'])); + self::assertEquals(4, count($result)); + self::assertEquals(316, round((float) $result[0]['sqrtsalary'])); + self::assertEquals(447, round((float) $result[1]['sqrtsalary'])); + self::assertEquals(632, round((float) $result[2]['sqrtsalary'])); + self::assertEquals(894, round((float) $result[3]['sqrtsalary'])); } public function testFunctionUpper(): void @@ -163,11 +163,11 @@ public function testFunctionUpper(): void $result = $this->_em->createQuery('SELECT m, UPPER(m.name) AS uppername FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals('ROMAN B.', $result[0]['uppername']); - $this->assertEquals('BENJAMIN E.', $result[1]['uppername']); - $this->assertEquals('GUILHERME B.', $result[2]['uppername']); - $this->assertEquals('JONATHAN W.', $result[3]['uppername']); + self::assertEquals(4, count($result)); + self::assertEquals('ROMAN B.', $result[0]['uppername']); + self::assertEquals('BENJAMIN E.', $result[1]['uppername']); + self::assertEquals('GUILHERME B.', $result[2]['uppername']); + self::assertEquals('JONATHAN W.', $result[3]['uppername']); } public function testFunctionSubstring(): void @@ -178,16 +178,16 @@ public function testFunctionSubstring(): void $result = $this->_em->createQuery($dql) ->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals('Ben', $result[0]['str1']); - $this->assertEquals('Gui', $result[1]['str1']); - $this->assertEquals('Jon', $result[2]['str1']); - $this->assertEquals('Rom', $result[3]['str1']); + self::assertEquals(4, count($result)); + self::assertEquals('Ben', $result[0]['str1']); + self::assertEquals('Gui', $result[1]['str1']); + self::assertEquals('Jon', $result[2]['str1']); + self::assertEquals('Rom', $result[3]['str1']); - $this->assertEquals('amin E.', $result[0]['str2']); - $this->assertEquals('herme B.', $result[1]['str2']); - $this->assertEquals('than W.', $result[2]['str2']); - $this->assertEquals('n B.', $result[3]['str2']); + self::assertEquals('amin E.', $result[0]['str2']); + self::assertEquals('herme B.', $result[1]['str2']); + self::assertEquals('than W.', $result[2]['str2']); + self::assertEquals('n B.', $result[3]['str2']); } public function testFunctionTrim(): void @@ -198,19 +198,19 @@ public function testFunctionTrim(): void $result = $this->_em->createQuery($dql)->getArrayResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals('Roman B', $result[0]['str1']); - $this->assertEquals('Benjamin E', $result[1]['str1']); - $this->assertEquals('Guilherme B', $result[2]['str1']); - $this->assertEquals('Jonathan W', $result[3]['str1']); - $this->assertEquals('Roman B.', $result[0]['str2']); - $this->assertEquals('Benjamin E.', $result[1]['str2']); - $this->assertEquals('Guilherme B.', $result[2]['str2']); - $this->assertEquals('Jonathan W.', $result[3]['str2']); - $this->assertEquals('Roman B.', $result[0]['str3']); - $this->assertEquals('Benjamin E.', $result[1]['str3']); - $this->assertEquals('Guilherme B.', $result[2]['str3']); - $this->assertEquals('Jonathan W.', $result[3]['str3']); + self::assertEquals(4, count($result)); + self::assertEquals('Roman B', $result[0]['str1']); + self::assertEquals('Benjamin E', $result[1]['str1']); + self::assertEquals('Guilherme B', $result[2]['str1']); + self::assertEquals('Jonathan W', $result[3]['str1']); + self::assertEquals('Roman B.', $result[0]['str2']); + self::assertEquals('Benjamin E.', $result[1]['str2']); + self::assertEquals('Guilherme B.', $result[2]['str2']); + self::assertEquals('Jonathan W.', $result[3]['str2']); + self::assertEquals('Roman B.', $result[0]['str3']); + self::assertEquals('Benjamin E.', $result[1]['str3']); + self::assertEquals('Guilherme B.', $result[2]['str3']); + self::assertEquals('Jonathan W.', $result[3]['str3']); } public function testOperatorAdd(): void @@ -218,11 +218,11 @@ public function testOperatorAdd(): void $result = $this->_em->createQuery('SELECT m, m.salary+2500 AS add FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(102500, $result[0]['add']); - $this->assertEquals(202500, $result[1]['add']); - $this->assertEquals(402500, $result[2]['add']); - $this->assertEquals(802500, $result[3]['add']); + self::assertEquals(4, count($result)); + self::assertEquals(102500, $result[0]['add']); + self::assertEquals(202500, $result[1]['add']); + self::assertEquals(402500, $result[2]['add']); + self::assertEquals(802500, $result[3]['add']); } public function testOperatorSub(): void @@ -230,11 +230,11 @@ public function testOperatorSub(): void $result = $this->_em->createQuery('SELECT m, m.salary-2500 AS sub FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(97500, $result[0]['sub']); - $this->assertEquals(197500, $result[1]['sub']); - $this->assertEquals(397500, $result[2]['sub']); - $this->assertEquals(797500, $result[3]['sub']); + self::assertEquals(4, count($result)); + self::assertEquals(97500, $result[0]['sub']); + self::assertEquals(197500, $result[1]['sub']); + self::assertEquals(397500, $result[2]['sub']); + self::assertEquals(797500, $result[3]['sub']); } public function testOperatorMultiply(): void @@ -242,11 +242,11 @@ public function testOperatorMultiply(): void $result = $this->_em->createQuery('SELECT m, m.salary*2 AS op FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(200000, $result[0]['op']); - $this->assertEquals(400000, $result[1]['op']); - $this->assertEquals(800000, $result[2]['op']); - $this->assertEquals(1600000, $result[3]['op']); + self::assertEquals(4, count($result)); + self::assertEquals(200000, $result[0]['op']); + self::assertEquals(400000, $result[1]['op']); + self::assertEquals(800000, $result[2]['op']); + self::assertEquals(1600000, $result[3]['op']); } /** @@ -257,11 +257,11 @@ public function testOperatorDiv(): void $result = $this->_em->createQuery('SELECT m, (m.salary/0.5) AS op FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') ->getResult(); - $this->assertEquals(4, count($result)); - $this->assertEquals(200000, $result[0]['op']); - $this->assertEquals(400000, $result[1]['op']); - $this->assertEquals(800000, $result[2]['op']); - $this->assertEquals(1600000, $result[3]['op']); + self::assertEquals(4, count($result)); + self::assertEquals(200000, $result[0]['op']); + self::assertEquals(400000, $result[1]['op']); + self::assertEquals(800000, $result[2]['op']); + self::assertEquals(1600000, $result[3]['op']); } public function testConcatFunction(): void @@ -269,11 +269,11 @@ public function testConcatFunction(): void $arg = $this->_em->createQuery('SELECT CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m order by namedep desc') ->getArrayResult(); - $this->assertEquals(4, count($arg)); - $this->assertEquals('Roman B.IT', $arg[0]['namedep']); - $this->assertEquals('Jonathan W.Administration', $arg[1]['namedep']); - $this->assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); - $this->assertEquals('Benjamin E.HR', $arg[3]['namedep']); + self::assertEquals(4, count($arg)); + self::assertEquals('Roman B.IT', $arg[0]['namedep']); + self::assertEquals('Jonathan W.Administration', $arg[1]['namedep']); + self::assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); + self::assertEquals('Benjamin E.HR', $arg[3]['namedep']); } /** @@ -284,12 +284,12 @@ public function testDateDiff(): void $query = $this->_em->createQuery("SELECT DATE_DIFF(CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day')) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); $arg = $query->getArrayResult(); - $this->assertEqualsWithDelta(-10, $arg[0]['diff'], 1, 'Should be roughly -10 (or -9)'); + self::assertEqualsWithDelta(-10, $arg[0]['diff'], 1, 'Should be roughly -10 (or -9)'); $query = $this->_em->createQuery("SELECT DATE_DIFF(DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day'), CURRENT_TIMESTAMP()) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); $arg = $query->getArrayResult(); - $this->assertEqualsWithDelta(10, $arg[0]['diff'], 1, 'Should be roughly 10 (or 9)'); + self::assertEqualsWithDelta(10, $arg[0]['diff'], 1, 'Should be roughly 10 (or 9)'); } /** @@ -386,15 +386,15 @@ public function testBitOrComparison(): void 'm.id '; $result = $this->_em->createQuery($dql)->getArrayResult(); - $this->assertEquals(4 | 2, $result[0]['bit_or']); - $this->assertEquals(4 | 2, $result[1]['bit_or']); - $this->assertEquals(4 | 2, $result[2]['bit_or']); - $this->assertEquals(4 | 2, $result[3]['bit_or']); + self::assertEquals(4 | 2, $result[0]['bit_or']); + self::assertEquals(4 | 2, $result[1]['bit_or']); + self::assertEquals(4 | 2, $result[2]['bit_or']); + self::assertEquals(4 | 2, $result[3]['bit_or']); - $this->assertEquals($result[0][0]['salary'] / 100000 | 2, $result[0]['salary_bit_or']); - $this->assertEquals($result[1][0]['salary'] / 100000 | 2, $result[1]['salary_bit_or']); - $this->assertEquals($result[2][0]['salary'] / 100000 | 2, $result[2]['salary_bit_or']); - $this->assertEquals($result[3][0]['salary'] / 100000 | 2, $result[3]['salary_bit_or']); + self::assertEquals($result[0][0]['salary'] / 100000 | 2, $result[0]['salary_bit_or']); + self::assertEquals($result[1][0]['salary'] / 100000 | 2, $result[1]['salary_bit_or']); + self::assertEquals($result[2][0]['salary'] / 100000 | 2, $result[2]['salary_bit_or']); + self::assertEquals($result[3][0]['salary'] / 100000 | 2, $result[3]['salary_bit_or']); } /** @@ -410,15 +410,15 @@ public function testBitAndComparison(): void 'm.id '; $result = $this->_em->createQuery($dql)->getArrayResult(); - $this->assertEquals(4 & 2, $result[0]['bit_and']); - $this->assertEquals(4 & 2, $result[1]['bit_and']); - $this->assertEquals(4 & 2, $result[2]['bit_and']); - $this->assertEquals(4 & 2, $result[3]['bit_and']); + self::assertEquals(4 & 2, $result[0]['bit_and']); + self::assertEquals(4 & 2, $result[1]['bit_and']); + self::assertEquals(4 & 2, $result[2]['bit_and']); + self::assertEquals(4 & 2, $result[3]['bit_and']); - $this->assertEquals($result[0][0]['salary'] / 100000 & 2, $result[0]['salary_bit_and']); - $this->assertEquals($result[1][0]['salary'] / 100000 & 2, $result[1]['salary_bit_and']); - $this->assertEquals($result[2][0]['salary'] / 100000 & 2, $result[2]['salary_bit_and']); - $this->assertEquals($result[3][0]['salary'] / 100000 & 2, $result[3]['salary_bit_and']); + self::assertEquals($result[0][0]['salary'] / 100000 & 2, $result[0]['salary_bit_and']); + self::assertEquals($result[1][0]['salary'] / 100000 & 2, $result[1]['salary_bit_and']); + self::assertEquals($result[2][0]['salary'] / 100000 & 2, $result[2]['salary_bit_and']); + self::assertEquals($result[3][0]['salary'] / 100000 & 2, $result[3]['salary_bit_and']); } protected function generateFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php index 62b86ae2508..db218882dd0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php @@ -32,7 +32,7 @@ public function testAlias(): void $users = $query->getResult(); self::assertCount(1, $users); - $this->assertEquals('gblanco', $users[0]['user']->username); + self::assertEquals('gblanco', $users[0]['user']->username); $this->_em->clear(); @@ -62,7 +62,7 @@ public function testAliasInnerJoin(): void $users = $query->getResult(); self::assertCount(1, $users); - $this->assertEquals('gblanco', $users[0]['user']->username); + self::assertEquals('gblanco', $users[0]['user']->username); $this->_em->clear(); diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 9a5215b5af5..4475ec0a1ba 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -50,30 +50,30 @@ public function testSimpleQueries(): void $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0][0]); - $this->assertEquals('Guilherme', $result[0][0]->name); - $this->assertEquals('gblanco', $result[0][0]->username); - $this->assertEquals('developer', $result[0][0]->status); - $this->assertEquals('GUILHERME', $result[0][1]); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0][0]); + self::assertEquals('Guilherme', $result[0][0]->name); + self::assertEquals('gblanco', $result[0][0]->username); + self::assertEquals('developer', $result[0][0]->status); + self::assertEquals('GUILHERME', $result[0][1]); $resultArray = $query->getArrayResult(); - $this->assertEquals(1, count($resultArray)); - $this->assertTrue(is_array($resultArray[0][0])); - $this->assertEquals('Guilherme', $resultArray[0][0]['name']); - $this->assertEquals('gblanco', $resultArray[0][0]['username']); - $this->assertEquals('developer', $resultArray[0][0]['status']); - $this->assertEquals('GUILHERME', $resultArray[0][1]); + self::assertEquals(1, count($resultArray)); + self::assertTrue(is_array($resultArray[0][0])); + self::assertEquals('Guilherme', $resultArray[0][0]['name']); + self::assertEquals('gblanco', $resultArray[0][0]['username']); + self::assertEquals('developer', $resultArray[0][0]['status']); + self::assertEquals('GUILHERME', $resultArray[0][1]); $scalarResult = $query->getScalarResult(); - $this->assertEquals(1, count($scalarResult)); - $this->assertEquals('Guilherme', $scalarResult[0]['u_name']); - $this->assertEquals('gblanco', $scalarResult[0]['u_username']); - $this->assertEquals('developer', $scalarResult[0]['u_status']); - $this->assertEquals('GUILHERME', $scalarResult[0][1]); + self::assertEquals(1, count($scalarResult)); + self::assertEquals('Guilherme', $scalarResult[0]['u_name']); + self::assertEquals('gblanco', $scalarResult[0]['u_username']); + self::assertEquals('developer', $scalarResult[0]['u_status']); + self::assertEquals('GUILHERME', $scalarResult[0][1]); $query = $this->_em->createQuery("select upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - $this->assertEquals('GUILHERME', $query->getSingleScalarResult()); + self::assertEquals('GUILHERME', $query->getSingleScalarResult()); } public function testJoinQueries(): void @@ -102,11 +102,11 @@ public function testJoinQueries(): void $query = $this->_em->createQuery('select u, a from ' . CmsUser::class . ' u join u.articles a ORDER BY a.topic'); $users = $query->getResult(); - $this->assertEquals(1, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertEquals(2, count($users[0]->articles)); - $this->assertEquals('Doctrine 2', $users[0]->articles[0]->topic); - $this->assertEquals('Symfony 2', $users[0]->articles[1]->topic); + self::assertEquals(1, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals(2, count($users[0]->articles)); + self::assertEquals('Doctrine 2', $users[0]->articles[0]->topic); + self::assertEquals('Symfony 2', $users[0]->articles[1]->topic); } public function testUsingZeroBasedQueryParameterShouldWork(): void @@ -123,7 +123,7 @@ public function testUsingZeroBasedQueryParameterShouldWork(): void $q->setParameter(0, 'jwage'); $user = $q->getSingleResult(); - $this->assertNotNull($user); + self::assertNotNull($user); } public function testUsingUnknownQueryParameterShouldThrowException(): void @@ -274,13 +274,13 @@ public function testIterateResultIterativelyBuildUpUnitOfWork(): void $identityMap = $this->_em->getUnitOfWork()->getIdentityMap(); $identityMapCount = count($identityMap[CmsArticle::class]); - $this->assertTrue($identityMapCount > $iteratedCount); + self::assertTrue($identityMapCount > $iteratedCount); $iteratedCount++; } - $this->assertSame(['Doctrine 2', 'Symfony 2'], $topics); - $this->assertSame(2, $iteratedCount); + self::assertSame(['Doctrine 2', 'Symfony 2'], $topics); + self::assertSame(2, $iteratedCount); $articles = $query->toIterable(); @@ -328,12 +328,12 @@ public function testToIterableWithMultipleSelectElements(): void $result = iterator_to_array($query->toIterable()); - $this->assertCount(2, $result); + self::assertCount(2, $result); foreach ($result as $row) { - $this->assertCount(2, $row); - $this->assertInstanceOf(CmsArticle::class, $row[0]); - $this->assertInstanceOf(CmsUser::class, $row[1]); + self::assertCount(2, $row); + self::assertInstanceOf(CmsArticle::class, $row[0]); + self::assertInstanceOf(CmsUser::class, $row[1]); } } @@ -390,8 +390,8 @@ public function testIterateResultClearEveryCycle(): void $iteratedCount++; } - $this->assertSame(['Doctrine 2', 'Symfony 2'], $topics); - $this->assertSame(2, $iteratedCount); + self::assertSame(['Doctrine 2', 'Symfony 2'], $topics); + self::assertSame(2, $iteratedCount); $this->_em->flush(); } @@ -472,18 +472,18 @@ public function testModifiedLimitQuery(): void ->setMaxResults(2) ->getResult(); - $this->assertEquals(2, count($data)); - $this->assertEquals('gblanco1', $data[0]->username); - $this->assertEquals('gblanco2', $data[1]->username); + self::assertEquals(2, count($data)); + self::assertEquals('gblanco1', $data[0]->username); + self::assertEquals('gblanco2', $data[1]->username); $data = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u') ->setFirstResult(3) ->setMaxResults(2) ->getResult(); - $this->assertEquals(2, count($data)); - $this->assertEquals('gblanco3', $data[0]->username); - $this->assertEquals('gblanco4', $data[1]->username); + self::assertEquals(2, count($data)); + self::assertEquals('gblanco3', $data[0]->username); + self::assertEquals('gblanco4', $data[1]->username); $data = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u') ->setFirstResult(3) @@ -497,10 +497,10 @@ public function testSupportsQueriesWithEntityNamespaces(): void try { $query = $this->_em->createQuery('UPDATE CMS:CmsUser u SET u.name = ?1'); - $this->assertEquals('UPDATE cms_users SET name = ?', $query->getSQL()); + self::assertEquals('UPDATE cms_users SET name = ?', $query->getSQL()); $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage()); + self::fail($e->getMessage()); } $this->_em->getConfiguration()->setEntityNamespaces([]); @@ -529,11 +529,11 @@ public function testEntityParameters(): void ->setParameter('topic', 'dr. dolittle'); $result = $q->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsArticle::class, $result[0]); - $this->assertEquals('dr. dolittle', $result[0]->topic); - $this->assertInstanceOf(Proxy::class, $result[0]->user); - $this->assertFalse($result[0]->user->__isInitialized__); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsArticle::class, $result[0]); + self::assertEquals('dr. dolittle', $result[0]->topic); + self::assertInstanceOf(Proxy::class, $result[0]->user); + self::assertFalse($result[0]->user->__isInitialized__); } /** @@ -561,9 +561,9 @@ public function testEnableFetchEagerMode(): void ->setFetchMode(CmsArticle::class, 'user', ClassMetadata::FETCH_EAGER) ->getResult(); - $this->assertEquals(10, count($articles)); + self::assertEquals(10, count($articles)); foreach ($articles as $article) { - $this->assertNotInstanceOf(Proxy::class, $article); + self::assertNotInstanceOf(Proxy::class, $article); } } @@ -583,12 +583,12 @@ public function testgetOneOrNullResult(): void $query = $this->_em->createQuery('select u from ' . CmsUser::class . " u where u.username = 'gblanco'"); $fetchedUser = $query->getOneOrNullResult(); - $this->assertInstanceOf(CmsUser::class, $fetchedUser); - $this->assertEquals('gblanco', $fetchedUser->username); + self::assertInstanceOf(CmsUser::class, $fetchedUser); + self::assertEquals('gblanco', $fetchedUser->username); $query = $this->_em->createQuery('select u.username from ' . CmsUser::class . " u where u.username = 'gblanco'"); $fetchedUsername = $query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR); - $this->assertEquals('gblanco', $fetchedUsername); + self::assertEquals('gblanco', $fetchedUsername); } /** @@ -622,10 +622,10 @@ public function testgetOneOrNullResultSeveralRows(): void public function testgetOneOrNullResultNoRows(): void { $query = $this->_em->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u'); - $this->assertNull($query->getOneOrNullResult()); + self::assertNull($query->getOneOrNullResult()); $query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); - $this->assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR)); + self::assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR)); } /** @@ -663,7 +663,7 @@ public function testParameterOrder(): void )); $result = $query->getResult(); - $this->assertEquals(3, count($result)); + self::assertEquals(3, count($result)); } public function testDqlWithAutoInferOfParameters(): void @@ -694,7 +694,7 @@ public function testDqlWithAutoInferOfParameters(): void $users = $query->execute(); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } public function testQueryBuilderWithStringWhereClauseContainingOrAndConditionalPrimary(): void @@ -708,7 +708,7 @@ public function testQueryBuilderWithStringWhereClauseContainingOrAndConditionalP $query = $qb->getQuery(); $users = $query->execute(); - $this->assertEquals(0, count($users)); + self::assertEquals(0, count($users)); } public function testQueryWithArrayOfEntitiesAsParameter(): void @@ -740,7 +740,7 @@ public function testQueryWithArrayOfEntitiesAsParameter(): void $users = $query->execute(); - $this->assertEquals(2, count($users)); + self::assertEquals(2, count($users)); } public function testQueryWithHiddenAsSelectExpression(): void @@ -769,8 +769,8 @@ public function testQueryWithHiddenAsSelectExpression(): void $query = $this->_em->createQuery('SELECT u, (SELECT COUNT(u2.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) AS HIDDEN total FROM Doctrine\Tests\Models\CMS\CmsUser u'); $users = $query->execute(); - $this->assertEquals(3, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals(3, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); } /** @@ -790,7 +790,7 @@ public function testSetParameterBindingSingleIdentifierObject(): void $q = $this->_em->createQuery('SELECT DISTINCT u from Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1'); $q->setParameter(1, $userC); - $this->assertEquals($userC, $q->getParameter(1)->getValue()); + self::assertEquals($userC, $q->getParameter(1)->getValue()); // Parameter is not converted before, but it should be converted during execution. Test should not fail here $q->getResult(); @@ -832,18 +832,18 @@ public function testSetCollectionParameterBindingSingleIdentifierObject(): void $q->setParameter('users', $userCollection); $users = $q->execute(); - $this->assertEquals(3, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertInstanceOf(CmsUser::class, $users[1]); - $this->assertInstanceOf(CmsUser::class, $users[2]); + self::assertEquals(3, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertInstanceOf(CmsUser::class, $users[1]); + self::assertInstanceOf(CmsUser::class, $users[2]); $resultUser1 = $users[0]; $resultUser2 = $users[1]; $resultUser3 = $users[2]; - $this->assertEquals($u1->username, $resultUser1->username); - $this->assertEquals($u2->username, $resultUser2->username); - $this->assertEquals($u3->username, $resultUser3->username); + self::assertEquals($u1->username, $resultUser1->username); + self::assertEquals($u2->username, $resultUser2->username); + self::assertEquals($u3->username, $resultUser3->username); } /** @@ -863,9 +863,9 @@ public function testUnexpectedResultException(): void try { $this->_em->createQuery($dql)->getSingleResult(); - $this->fail('Expected exception "\Doctrine\ORM\NoResultException".'); + self::fail('Expected exception "\Doctrine\ORM\NoResultException".'); } catch (UnexpectedResultException $exc) { - $this->assertInstanceOf('\Doctrine\ORM\NoResultException', $exc); + self::assertInstanceOf('\Doctrine\ORM\NoResultException', $exc); } $this->_em->persist($u1); @@ -875,9 +875,9 @@ public function testUnexpectedResultException(): void try { $this->_em->createQuery($dql)->getSingleResult(); - $this->fail('Expected exception "\Doctrine\ORM\NonUniqueResultException".'); + self::fail('Expected exception "\Doctrine\ORM\NonUniqueResultException".'); } catch (UnexpectedResultException $exc) { - $this->assertInstanceOf('\Doctrine\ORM\NonUniqueResultException', $exc); + self::assertInstanceOf('\Doctrine\ORM\NonUniqueResultException', $exc); } } @@ -909,9 +909,9 @@ public function testMultipleJoinComponentsUsingInnerJoin(): void '); $users = $query->execute(); - $this->assertEquals(2, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertInstanceOf(CmsPhonenumber::class, $users[1]); + self::assertEquals(2, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertInstanceOf(CmsPhonenumber::class, $users[1]); } public function testMultipleJoinComponentsUsingLeftJoin(): void @@ -942,10 +942,10 @@ public function testMultipleJoinComponentsUsingLeftJoin(): void '); $users = $query->execute(); - $this->assertEquals(4, count($users)); - $this->assertInstanceOf(CmsUser::class, $users[0]); - $this->assertInstanceOf(CmsPhonenumber::class, $users[1]); - $this->assertInstanceOf(CmsUser::class, $users[2]); - $this->assertNull($users[3]); + self::assertEquals(4, count($users)); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertInstanceOf(CmsPhonenumber::class, $users[1]); + self::assertInstanceOf(CmsUser::class, $users[2]); + self::assertNull($users[3]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 834b37d3e22..5743e40f61e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -48,8 +48,8 @@ public function testReadOnlyEntityNeverChangeTracked(): void $this->_em->clear(); $dbReadOnly = $this->_em->find(ReadOnlyEntity::class, $readOnly->id); - $this->assertEquals('Test1', $dbReadOnly->name); - $this->assertEquals(1234, $dbReadOnly->numericValue); + self::assertEquals('Test1', $dbReadOnly->name); + self::assertEquals(1234, $dbReadOnly->numericValue); } /** @@ -64,7 +64,7 @@ public function testClearReadOnly(): void $this->_em->clear(); - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); } /** @@ -79,7 +79,7 @@ public function testClearEntitiesReadOnly(): void $this->_em->clear(get_class($readOnly)); - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); } public function testReadOnlyQueryHint(): void @@ -99,7 +99,7 @@ public function testReadOnlyQueryHint(): void $user = $query->getSingleResult(); - $this->assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); + self::assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); } public function testNotReadOnlyIfObjectWasProxyBefore(): void @@ -121,7 +121,7 @@ public function testNotReadOnlyIfObjectWasProxyBefore(): void $user = $query->getSingleResult(); - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); } public function testNotReadOnlyIfObjectWasKnownBefore(): void @@ -143,7 +143,7 @@ public function testNotReadOnlyIfObjectWasKnownBefore(): void $user = $query->getSingleResult(); - $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); + self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($user)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php index 97a58c512e6..2a852c34eea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php @@ -68,7 +68,7 @@ public function testLazyLoadsFieldValuesFromDatabase(): void $id = $this->createProduct(); $productProxy = $this->_em->getReference(ECommerceProduct::class, ['id' => $id]); - $this->assertEquals('Doctrine Cookbook', $productProxy->getName()); + self::assertEquals('Doctrine Cookbook', $productProxy->getName()); } /** @@ -81,7 +81,7 @@ public function testAccessMetatadaForProxy(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); $class = $this->_em->getClassMetadata(get_class($entity)); - $this->assertEquals(ECommerceProduct::class, $class->name); + self::assertEquals(ECommerceProduct::class, $class->name); } /** @@ -94,8 +94,8 @@ public function testReferenceFind(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); $entity2 = $this->_em->find(ECommerceProduct::class, $id); - $this->assertSame($entity, $entity2); - $this->assertEquals('Doctrine Cookbook', $entity2->getName()); + self::assertSame($entity, $entity2); + self::assertEquals('Doctrine Cookbook', $entity2->getName()); } /** @@ -111,16 +111,16 @@ public function testCloneProxy(): void $clone = clone $entity; assert($clone instanceof ECommerceProduct); - $this->assertEquals($id, $entity->getId()); - $this->assertEquals('Doctrine Cookbook', $entity->getName()); + self::assertEquals($id, $entity->getId()); + self::assertEquals('Doctrine Cookbook', $entity->getName()); - $this->assertFalse($this->_em->contains($clone), 'Cloning a reference proxy should return an unmanaged/detached entity.'); - $this->assertEquals($id, $clone->getId(), 'Cloning a reference proxy should return same id.'); - $this->assertEquals('Doctrine Cookbook', $clone->getName(), 'Cloning a reference proxy should return same product name.'); + self::assertFalse($this->_em->contains($clone), 'Cloning a reference proxy should return an unmanaged/detached entity.'); + self::assertEquals($id, $clone->getId(), 'Cloning a reference proxy should return same id.'); + self::assertEquals('Doctrine Cookbook', $clone->getName(), 'Cloning a reference proxy should return same product name.'); // domain logic, Product::__clone sets isCloned public property - $this->assertTrue($clone->isCloned); - $this->assertFalse($entity->isCloned); + self::assertTrue($clone->isCloned); + self::assertFalse($entity->isCloned); } /** @@ -133,9 +133,9 @@ public function testInitializeProxy(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); assert($entity instanceof ECommerceProduct); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); $this->_em->getUnitOfWork()->initializeObject($entity); - $this->assertTrue($entity->__isInitialized__, 'Should be initialized after called UnitOfWork::initializeObject()'); + self::assertTrue($entity->__isInitialized__, 'Should be initialized after called UnitOfWork::initializeObject()'); } /** @@ -153,7 +153,7 @@ public function testInitializeChangeAndFlushProxy(): void $this->_em->clear(); $entity = $this->_em->getReference(ECommerceProduct::class, $id); - $this->assertEquals('Doctrine 2 Cookbook', $entity->getName()); + self::assertEquals('Doctrine 2 Cookbook', $entity->getName()); } /** @@ -166,11 +166,11 @@ public function testWakeupCalledOnProxy(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); assert($entity instanceof ECommerceProduct); - $this->assertFalse($entity->wakeUp); + self::assertFalse($entity->wakeUp); $entity->setName('Doctrine 2 Cookbook'); - $this->assertTrue($entity->wakeUp, 'Loading the proxy should call __wakeup().'); + self::assertTrue($entity->wakeUp, 'Loading the proxy should call __wakeup().'); } public function testDoNotInitializeProxyOnGettingTheIdentifier(): void @@ -180,9 +180,9 @@ public function testDoNotInitializeProxyOnGettingTheIdentifier(): void $entity = $this->_em->getReference(ECommerceProduct::class, $id); assert($entity instanceof ECommerceProduct); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); - $this->assertEquals($id, $entity->getId()); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertEquals($id, $entity->getId()); + self::assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); } /** @@ -195,9 +195,9 @@ public function testDoNotInitializeProxyOnGettingTheIdentifierDDC1625(): void $entity = $this->_em->getReference(CompanyAuction::class, $id); assert($entity instanceof CompanyAuction); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); - $this->assertEquals($id, $entity->getId()); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy when extending."); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertEquals($id, $entity->getId()); + self::assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy when extending."); } public function testDoNotInitializeProxyOnGettingTheIdentifierAndReturnTheRightType(): void @@ -217,10 +217,10 @@ public function testDoNotInitializeProxyOnGettingTheIdentifierAndReturnTheRightT $product = $this->_em->getRepository(ECommerceProduct::class)->find($product->getId()); $entity = $product->getShipping(); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); - $this->assertEquals($id, $entity->getId()); - $this->assertSame($id, $entity->getId(), "Check that the id's are the same value, and type."); - $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertEquals($id, $entity->getId()); + self::assertSame($id, $entity->getId(), "Check that the id's are the same value, and type."); + self::assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); } public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier(): void @@ -230,9 +230,9 @@ public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier(): v $entity = $this->_em->getReference(ECommerceProduct::class, $id); assert($entity instanceof ECommerceProduct); - $this->assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); - $this->assertEquals('Doctrine Cookbook', $entity->getName()); - $this->assertTrue($entity->__isInitialized__, 'Getting something other than the identifier initializes the proxy.'); + self::assertFalse($entity->__isInitialized__, 'Pre-Condition: Object is unitialized proxy.'); + self::assertEquals('Doctrine Cookbook', $entity->getName()); + self::assertTrue($entity->__isInitialized__, 'Getting something other than the identifier initializes the proxy.'); } /** @@ -246,16 +246,16 @@ public function testCommonPersistenceProxy(): void assert($entity instanceof ECommerceProduct); $className = ClassUtils::getClass($entity); - $this->assertInstanceOf(Proxy::class, $entity); - $this->assertFalse($entity->__isInitialized()); - $this->assertEquals(ECommerceProduct::class, $className); + self::assertInstanceOf(Proxy::class, $entity); + self::assertFalse($entity->__isInitialized()); + self::assertEquals(ECommerceProduct::class, $className); $restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), '', get_class($entity)); $restName = substr(get_class($entity), strlen($this->_em->getConfiguration()->getProxyNamespace()) + 1); $proxyFileName = $this->_em->getConfiguration()->getProxyDir() . DIRECTORY_SEPARATOR . str_replace('\\', '', $restName) . '.php'; - $this->assertTrue(file_exists($proxyFileName), 'Proxy file name cannot be found generically.'); + self::assertTrue(file_exists($proxyFileName), 'Proxy file name cannot be found generically.'); $entity->__load(); - $this->assertTrue($entity->__isInitialized()); + self::assertTrue($entity->__isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php index 7ba80b9c482..375b1baa363 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php @@ -30,7 +30,7 @@ class ResultCacheTest extends OrmFunctionalTestCase protected function setUp(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $this->cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data'); @@ -61,13 +61,13 @@ public function testResultCache(): void $query->setResultCacheDriver($cache)->setResultCacheId('my_cache_id'); - $this->assertFalse($cache->contains('my_cache_id')); + self::assertFalse($cache->contains('my_cache_id')); $users = $query->getResult(); - $this->assertTrue($cache->contains('my_cache_id')); - $this->assertEquals(1, count($users)); - $this->assertEquals('Roman', $users[0]->name); + self::assertTrue($cache->contains('my_cache_id')); + self::assertEquals(1, count($users)); + self::assertEquals('Roman', $users[0]->name); $this->_em->clear(); @@ -76,9 +76,9 @@ public function testResultCache(): void $users = $query2->getResult(); - $this->assertTrue($cache->contains('my_cache_id')); - $this->assertEquals(1, count($users)); - $this->assertEquals('Roman', $users[0]->name); + self::assertTrue($cache->contains('my_cache_id')); + self::assertEquals(1, count($users)); + self::assertEquals('Roman', $users[0]->name); } public function testSetResultCacheId(): void @@ -89,11 +89,11 @@ public function testSetResultCacheId(): void $query->setResultCacheDriver($cache); $query->setResultCacheId('testing_result_cache_id'); - $this->assertFalse($cache->contains('testing_result_cache_id')); + self::assertFalse($cache->contains('testing_result_cache_id')); $users = $query->getResult(); - $this->assertTrue($cache->contains('testing_result_cache_id')); + self::assertTrue($cache->contains('testing_result_cache_id')); } public function testUseResultCacheTrue(): void @@ -106,7 +106,7 @@ public function testUseResultCacheTrue(): void $query->setResultCacheId('testing_result_cache_id'); $users = $query->getResult(); - $this->assertTrue($cache->contains('testing_result_cache_id')); + self::assertTrue($cache->contains('testing_result_cache_id')); $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); } @@ -121,7 +121,7 @@ public function testUseResultCacheFalse(): void $query->useResultCache(false); $query->getResult(); - $this->assertFalse($cache->contains('testing_result_cache_id')); + self::assertFalse($cache->contains('testing_result_cache_id')); $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); } @@ -144,7 +144,7 @@ public function testUseResultCacheParams(): void $query->setParameter(1, 2); $query->getResult(); - $this->assertCount( + self::assertCount( $sqlCount + 2, $this->_sqlLoggerStack->queries, 'Two non-cached queries.' @@ -156,7 +156,7 @@ public function testUseResultCacheParams(): void $query->setParameter(1, 2); $query->getResult(); - $this->assertCount( + self::assertCount( $sqlCount + 2, $this->_sqlLoggerStack->queries, 'The next two sql queries should have been cached, but were not.' @@ -173,7 +173,7 @@ public function testEnableResultCache(): void $query->setResultCacheId('testing_result_cache_id'); $query->getResult(); - $this->assertTrue($cache->contains('testing_result_cache_id')); + self::assertTrue($cache->contains('testing_result_cache_id')); $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); } @@ -191,11 +191,11 @@ public function testEnableResultCacheWithIterable(): void $this->_em->clear(); - $this->assertCount( + self::assertCount( $expectedSQLCount, $this->_sqlLoggerStack->queries ); - $this->assertTrue($cache->contains('testing_iterable_result_cache_id')); + self::assertTrue($cache->contains('testing_iterable_result_cache_id')); $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); $query->enableResultCache(); @@ -203,7 +203,7 @@ public function testEnableResultCacheWithIterable(): void $query->setResultCacheId('testing_iterable_result_cache_id'); iterator_to_array($query->toIterable()); - $this->assertCount( + self::assertCount( $expectedSQLCount, $this->_sqlLoggerStack->queries, 'Expected query to be cached' @@ -230,7 +230,7 @@ public function testEnableResultCacheParams(): void $query->setParameter(1, 2); $query->getResult(); - $this->assertCount( + self::assertCount( $sqlCount + 2, $this->_sqlLoggerStack->queries, 'Two non-cached queries.' @@ -242,7 +242,7 @@ public function testEnableResultCacheParams(): void $query->setParameter(1, 2); $query->getResult(); - $this->assertCount( + self::assertCount( $sqlCount + 2, $this->_sqlLoggerStack->queries, 'The next two sql queries should have been cached, but were not.' @@ -259,7 +259,7 @@ public function testDisableResultCache(): void $query->disableResultCache(); $query->getResult(); - $this->assertFalse($cache->contains('testing_result_cache_id')); + self::assertFalse($cache->contains('testing_result_cache_id')); $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); } @@ -276,11 +276,11 @@ public function testNativeQueryResultCaching(): NativeQuery $query->setParameter(1, 10); $query->setResultCacheDriver($cache)->enableResultCache(); - $this->assertEquals(0, $this->getCacheSize($cache)); + self::assertEquals(0, $this->getCacheSize($cache)); $query->getResult(); - $this->assertEquals(1, $this->getCacheSize($cache)); + self::assertEquals(1, $this->getCacheSize($cache)); return $query; } @@ -296,7 +296,7 @@ public function testResultCacheNotDependsOnQueryHints(NativeQuery $query): void $query->setHint('foo', 'bar'); $query->getResult(); - $this->assertEquals($cacheCount, $this->getCacheSize($cache)); + self::assertEquals($cacheCount, $this->getCacheSize($cache)); } /** @@ -310,7 +310,7 @@ public function testResultCacheDependsOnParameters(NativeQuery $query): void $query->setParameter(1, 50); $query->getResult(); - $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + self::assertEquals($cacheCount + 1, $this->getCacheSize($cache)); } /** @@ -321,10 +321,10 @@ public function testResultCacheNotDependsOnHydrationMode(NativeQuery $query): vo $cache = $query->getResultCacheDriver(); $cacheCount = $this->getCacheSize($cache); - $this->assertNotEquals(Query::HYDRATE_ARRAY, $query->getHydrationMode()); + self::assertNotEquals(Query::HYDRATE_ARRAY, $query->getHydrationMode()); $query->getArrayResult(); - $this->assertEquals($cacheCount, $this->getCacheSize($cache)); + self::assertEquals($cacheCount, $this->getCacheSize($cache)); } /** @@ -361,8 +361,8 @@ public function testResultCacheWithObjectParameter(): void $articles = $query->getResult(); - $this->assertEquals(1, count($articles)); - $this->assertEquals('baz', $articles[0]->topic); + self::assertEquals(1, count($articles)); + self::assertEquals('baz', $articles[0]->topic); $this->_em->clear(); @@ -373,8 +373,8 @@ public function testResultCacheWithObjectParameter(): void $articles = $query2->getResult(); - $this->assertEquals(1, count($articles)); - $this->assertEquals('baz', $articles[0]->topic); + self::assertEquals(1, count($articles)); + self::assertEquals('baz', $articles[0]->topic); $query3 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1'); $query3->setParameter(1, $user2); @@ -383,6 +383,6 @@ public function testResultCacheWithObjectParameter(): void $articles = $query3->getResult(); - $this->assertEquals(0, count($articles)); + self::assertEquals(0, count($articles)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index c720d4ece20..31aae12fa07 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -105,8 +105,8 @@ public function testConfigureFilter(): void $config->addFilter('locale', '\Doctrine\Tests\ORM\Functional\MyLocaleFilter'); - $this->assertEquals('\Doctrine\Tests\ORM\Functional\MyLocaleFilter', $config->getFilterClassName('locale')); - $this->assertNull($config->getFilterClassName('foo')); + self::assertEquals('\Doctrine\Tests\ORM\Functional\MyLocaleFilter', $config->getFilterClassName('locale')); + self::assertNull($config->getFilterClassName('foo')); } public function testEntityManagerEnableFilter(): void @@ -116,11 +116,11 @@ public function testEntityManagerEnableFilter(): void // Enable an existing filter $filter = $em->getFilters()->enable('locale'); - $this->assertTrue($filter instanceof MyLocaleFilter); + self::assertTrue($filter instanceof MyLocaleFilter); // Enable the filter again $filter2 = $em->getFilters()->enable('locale'); - $this->assertEquals($filter, $filter2); + self::assertEquals($filter, $filter2); // Enable a non-existing filter $exceptionThrown = false; @@ -130,7 +130,7 @@ public function testEntityManagerEnableFilter(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); } public function testEntityManagerEnabledFilters(): void @@ -138,14 +138,14 @@ public function testEntityManagerEnabledFilters(): void $em = $this->getEntityManager(); // No enabled filters - $this->assertEquals([], $em->getFilters()->getEnabledFilters()); + self::assertEquals([], $em->getFilters()->getEnabledFilters()); $this->configureFilters($em); $filter = $em->getFilters()->enable('locale'); $filter = $em->getFilters()->enable('soft_delete'); // Two enabled filters - $this->assertEquals(2, count($em->getFilters()->getEnabledFilters())); + self::assertEquals(2, count($em->getFilters()->getEnabledFilters())); } public function testEntityManagerDisableFilter(): void @@ -157,8 +157,8 @@ public function testEntityManagerDisableFilter(): void $filter = $em->getFilters()->enable('locale'); // Disable it - $this->assertEquals($filter, $em->getFilters()->disable('locale')); - $this->assertEquals(0, count($em->getFilters()->getEnabledFilters())); + self::assertEquals($filter, $em->getFilters()->disable('locale')); + self::assertEquals(0, count($em->getFilters()->getEnabledFilters())); // Disable a non-existing filter $exceptionThrown = false; @@ -168,7 +168,7 @@ public function testEntityManagerDisableFilter(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); // Disable a non-enabled filter $exceptionThrown = false; @@ -178,7 +178,7 @@ public function testEntityManagerDisableFilter(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); } public function testEntityManagerGetFilter(): void @@ -190,7 +190,7 @@ public function testEntityManagerGetFilter(): void $filter = $em->getFilters()->enable('locale'); // Get the filter - $this->assertEquals($filter, $em->getFilters()->getFilter('locale')); + self::assertEquals($filter, $em->getFilters()->getFilter('locale')); // Get a non-enabled filter $exceptionThrown = false; @@ -200,7 +200,7 @@ public function testEntityManagerGetFilter(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); } /** @@ -213,14 +213,14 @@ public function testEntityManagerIsFilterEnabled(): void // Check for an enabled filter $em->getFilters()->enable('locale'); - $this->assertTrue($em->getFilters()->isEnabled('locale')); + self::assertTrue($em->getFilters()->isEnabled('locale')); // Check for a disabled filter $em->getFilters()->disable('locale'); - $this->assertFalse($em->getFilters()->isEnabled('locale')); + self::assertFalse($em->getFilters()->isEnabled('locale')); // Check a non-existing filter - $this->assertFalse($em->getFilters()->isEnabled('foo_filter')); + self::assertFalse($em->getFilters()->isEnabled('foo_filter')); } protected function configureFilters($em): void @@ -249,9 +249,9 @@ protected function addMockFilterCollection(EntityManagerInterface $em): FilterCo ->disableOriginalConstructor() ->getMock(); - $em->expects($this->any()) + $em->expects(self::any()) ->method('getFilters') - ->will($this->returnValue($filterCollection)); + ->will(self::returnValue($filterCollection)); return $filterCollection; } @@ -260,26 +260,26 @@ public function testSQLFilterGetSetParameter(): void { // Setup mock connection $conn = $this->getMockConnection(); - $conn->expects($this->once()) + $conn->expects(self::once()) ->method('quote') - ->with($this->equalTo('en')) - ->will($this->returnValue("'en'")); + ->with(self::equalTo('en')) + ->will(self::returnValue("'en'")); $em = $this->getMockEntityManager(); - $em->expects($this->once()) + $em->expects(self::once()) ->method('getConnection') - ->will($this->returnValue($conn)); + ->will(self::returnValue($conn)); $filterCollection = $this->addMockFilterCollection($em); $filterCollection - ->expects($this->once()) + ->expects(self::once()) ->method('setFiltersStateDirty'); $filter = new MyLocaleFilter($em); $filter->setParameter('locale', 'en', Types::STRING); - $this->assertEquals("'en'", $filter->getParameter('locale')); + self::assertEquals("'en'", $filter->getParameter('locale')); } /** @@ -292,42 +292,42 @@ public function testSQLFilterGetConnection(): void $conn = $this->getMockConnection(); $em = $this->getMockEntityManager(); - $em->expects($this->once()) + $em->expects(self::once()) ->method('getConnection') - ->will($this->returnValue($conn)); + ->will(self::returnValue($conn)); $filter = new MyLocaleFilter($em); $reflMethod = new ReflectionMethod(SQLFilter::class, 'getConnection'); $reflMethod->setAccessible(true); - $this->assertSame($conn, $reflMethod->invoke($filter)); + self::assertSame($conn, $reflMethod->invoke($filter)); } public function testSQLFilterSetParameterInfersType(): void { // Setup mock connection $conn = $this->getMockConnection(); - $conn->expects($this->once()) + $conn->expects(self::once()) ->method('quote') - ->with($this->equalTo('en')) - ->will($this->returnValue("'en'")); + ->with(self::equalTo('en')) + ->will(self::returnValue("'en'")); $em = $this->getMockEntityManager(); - $em->expects($this->once()) + $em->expects(self::once()) ->method('getConnection') - ->will($this->returnValue($conn)); + ->will(self::returnValue($conn)); $filterCollection = $this->addMockFilterCollection($em); $filterCollection - ->expects($this->once()) + ->expects(self::once()) ->method('setFiltersStateDirty'); $filter = new MyLocaleFilter($em); $filter->setParameter('locale', 'en'); - $this->assertEquals("'en'", $filter->getParameter('locale')); + self::assertEquals("'en'", $filter->getParameter('locale')); } public function testSQLFilterSetArrayParameterInfersType(): void @@ -335,24 +335,24 @@ public function testSQLFilterSetArrayParameterInfersType(): void // Setup mock connection $conn = $this->getMockConnection(); $conn->method('quote') - ->will($this->returnCallback(static function ($value) { + ->will(self::returnCallback(static function ($value) { return "'" . $value . "'"; })); $em = $this->getMockEntityManager(); $em->method('getConnection') - ->will($this->returnValue($conn)); + ->will(self::returnValue($conn)); $filterCollection = $this->addMockFilterCollection($em); $filterCollection - ->expects($this->once()) + ->expects(self::once()) ->method('setFiltersStateDirty'); $filter = new MyLocaleFilter($em); $filter->setParameterList('locale', ['en', 'es']); - $this->assertEquals("'en','es'", $filter->getParameterList('locale')); + self::assertEquals("'en','es'", $filter->getParameterList('locale')); } public function testSQLFilterAddConstraint(): void @@ -366,11 +366,11 @@ public function testSQLFilterAddConstraint(): void // Test for an entity that gets extra filter data $targetEntity->name = 'MyEntity\SoftDeleteNewsItem'; - $this->assertEquals('t1_.deleted = 0', $filter->addFilterConstraint($targetEntity, 't1_')); + self::assertEquals('t1_.deleted = 0', $filter->addFilterConstraint($targetEntity, 't1_')); // Test for an entity that doesn't get extra filter data $targetEntity->name = 'MyEntity\NoSoftDeleteNewsItem'; - $this->assertEquals('', $filter->addFilterConstraint($targetEntity, 't1_')); + self::assertEquals('', $filter->addFilterConstraint($targetEntity, 't1_')); } public function testSQLFilterToString(): void @@ -391,14 +391,14 @@ public function testSQLFilterToString(): void 'locale' => ['value' => 'en', 'type' => Types::STRING, 'is_list' => false], ]; - $this->assertEquals(serialize($parameters), '' . $filter); - $this->assertEquals('' . $filter, '' . $filter2); + self::assertEquals(serialize($parameters), '' . $filter); + self::assertEquals('' . $filter, '' . $filter2); } public function testQueryCacheDependsOnFilters(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } $cacheDataReflection = new ReflectionProperty(ArrayCache::class, 'data'); @@ -410,18 +410,18 @@ public function testQueryCacheDependsOnFilters(): void $query->setQueryCacheDriver($cache); $query->getResult(); - $this->assertEquals(1, count($cacheDataReflection->getValue($cache))); + self::assertEquals(1, count($cacheDataReflection->getValue($cache))); $conf = $this->_em->getConfiguration(); $conf->addFilter('locale', '\Doctrine\Tests\ORM\Functional\MyLocaleFilter'); $this->_em->getFilters()->enable('locale'); $query->getResult(); - $this->assertEquals(2, count($cacheDataReflection->getValue($cache))); + self::assertEquals(2, count($cacheDataReflection->getValue($cache))); // Another time doesn't add another cache entry $query->getResult(); - $this->assertEquals(2, count($cacheDataReflection->getValue($cache))); + self::assertEquals(2, count($cacheDataReflection->getValue($cache))); } public function testQueryGenerationDependsOnFilters(): void @@ -434,47 +434,47 @@ public function testQueryGenerationDependsOnFilters(): void $this->_em->getFilters()->enable('country') ->setParameterList('country', ['en'], Types::STRING); - $this->assertNotEquals($firstSQLQuery, $query->getSQL()); + self::assertNotEquals($firstSQLQuery, $query->getSQL()); } public function testRepositoryFind(): void { $this->loadFixtureData(); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId)); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2)); + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId)); + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2)); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId)); - $this->assertNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2)); + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId)); + self::assertNull($this->_em->getRepository(CmsGroup::class)->find($this->groupId2)); } public function testRepositoryFindAll(): void { $this->loadFixtureData(); - $this->assertCount(2, $this->_em->getRepository(CmsGroup::class)->findAll()); + self::assertCount(2, $this->_em->getRepository(CmsGroup::class)->findAll()); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findAll()); + self::assertCount(1, $this->_em->getRepository(CmsGroup::class)->findAll()); } public function testRepositoryFindBy(): void { $this->loadFixtureData(); - $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findBy( + self::assertCount(1, $this->_em->getRepository(CmsGroup::class)->findBy( ['id' => $this->groupId2] )); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertCount(0, $this->_em->getRepository(CmsGroup::class)->findBy( + self::assertCount(0, $this->_em->getRepository(CmsGroup::class)->findBy( ['id' => $this->groupId2] )); } @@ -483,26 +483,26 @@ public function testRepositoryFindByX(): void { $this->loadFixtureData(); - $this->assertCount(1, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2)); + self::assertCount(1, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2)); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertCount(0, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2)); + self::assertCount(0, $this->_em->getRepository(CmsGroup::class)->findById($this->groupId2)); } public function testRepositoryFindOneBy(): void { $this->loadFixtureData(); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneBy( + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneBy( ['id' => $this->groupId2] )); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertNull($this->_em->getRepository(CmsGroup::class)->findOneBy( + self::assertNull($this->_em->getRepository(CmsGroup::class)->findOneBy( ['id' => $this->groupId2] )); } @@ -511,12 +511,12 @@ public function testRepositoryFindOneByX(): void { $this->loadFixtureData(); - $this->assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2)); + self::assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2)); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); - $this->assertNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2)); + self::assertNull($this->_em->getRepository(CmsGroup::class)->findOneById($this->groupId2)); } public function testToOneFilter(): void @@ -527,18 +527,18 @@ public function testToOneFilter(): void $query = $this->_em->createQuery('select ux, ua from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.address ua'); // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); $conf = $this->_em->getConfiguration(); $conf->addFilter('country', '\Doctrine\Tests\ORM\Functional\CMSCountryFilter'); $this->_em->getFilters()->enable('country')->setParameterList('country', ['Germany'], Types::STRING); // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); + self::assertEquals(1, count($query->getResult())); $this->_em->getFilters()->enable('country')->setParameterList('country', ['Germany', 'France'], Types::STRING); - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); } public function testManyToManyFilter(): void @@ -547,14 +547,14 @@ public function testManyToManyFilter(): void $query = $this->_em->createQuery('select ux, ug from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.groups ug'); // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); $conf = $this->_em->getConfiguration(); $conf->addFilter('group_prefix', '\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter'); $this->_em->getFilters()->enable('group_prefix')->setParameter('prefix', 'bar_%', Types::STRING); // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); + self::assertEquals(1, count($query->getResult())); } public function testWhereFilter(): void @@ -563,14 +563,14 @@ public function testWhereFilter(): void $query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1'); // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); $conf = $this->_em->getConfiguration(); $conf->addFilter('group_prefix', '\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter'); $this->_em->getFilters()->enable('group_prefix')->setParameter('prefix', 'bar_%', Types::STRING); // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); + self::assertEquals(1, count($query->getResult())); } public function testWhereOrFilter(): void @@ -579,14 +579,14 @@ public function testWhereOrFilter(): void $query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1 OR 1=1'); // We get two users before enabling the filter - $this->assertEquals(2, count($query->getResult())); + self::assertEquals(2, count($query->getResult())); $conf = $this->_em->getConfiguration(); $conf->addFilter('group_prefix', '\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter'); $this->_em->getFilters()->enable('group_prefix')->setParameter('prefix', 'bar_%', Types::STRING); // We get one user after enabling the filter - $this->assertEquals(1, count($query->getResult())); + self::assertEquals(1, count($query->getResult())); } private function loadLazyFixtureData(): void @@ -609,12 +609,12 @@ public function testOneToManyExtraLazyCountWithFilter(): void $this->loadLazyFixtureData(); $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals(2, count($user->articles)); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals(2, count($user->articles)); $this->useCMSArticleTopicFilter(); - $this->assertEquals(1, count($user->articles)); + self::assertEquals(1, count($user->articles)); } public function testOneToManyExtraLazyContainsWithFilter(): void @@ -623,12 +623,12 @@ public function testOneToManyExtraLazyContainsWithFilter(): void $user = $this->_em->find(CmsUser::class, $this->userId); $filteredArticle = $this->_em->find(CmsArticle::class, $this->articleId2); - $this->assertFalse($user->articles->isInitialized()); - $this->assertTrue($user->articles->contains($filteredArticle)); + self::assertFalse($user->articles->isInitialized()); + self::assertTrue($user->articles->contains($filteredArticle)); $this->useCMSArticleTopicFilter(); - $this->assertFalse($user->articles->contains($filteredArticle)); + self::assertFalse($user->articles->contains($filteredArticle)); } public function testOneToManyExtraLazySliceWithFilter(): void @@ -636,12 +636,12 @@ public function testOneToManyExtraLazySliceWithFilter(): void $this->loadLazyFixtureData(); $user = $this->_em->find(CmsUser::class, $this->userId); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals(2, count($user->articles->slice(0, 10))); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals(2, count($user->articles->slice(0, 10))); $this->useCMSArticleTopicFilter(); - $this->assertEquals(1, count($user->articles->slice(0, 10))); + self::assertEquals(1, count($user->articles->slice(0, 10))); } private function useCMSGroupPrefixFilter(): void @@ -657,12 +657,12 @@ public function testManyToManyExtraLazyCountWithFilter(): void $user = $this->_em->find(CmsUser::class, $this->userId2); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(2, count($user->groups)); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(2, count($user->groups)); $this->useCMSGroupPrefixFilter(); - $this->assertEquals(1, count($user->groups)); + self::assertEquals(1, count($user->groups)); } public function testManyToManyExtraLazyContainsWithFilter(): void @@ -671,12 +671,12 @@ public function testManyToManyExtraLazyContainsWithFilter(): void $user = $this->_em->find(CmsUser::class, $this->userId2); $filteredArticle = $this->_em->find(CmsGroup::class, $this->groupId2); - $this->assertFalse($user->groups->isInitialized()); - $this->assertTrue($user->groups->contains($filteredArticle)); + self::assertFalse($user->groups->isInitialized()); + self::assertTrue($user->groups->contains($filteredArticle)); $this->useCMSGroupPrefixFilter(); - $this->assertFalse($user->groups->contains($filteredArticle)); + self::assertFalse($user->groups->contains($filteredArticle)); } public function testManyToManyExtraLazySliceWithFilter(): void @@ -684,12 +684,12 @@ public function testManyToManyExtraLazySliceWithFilter(): void $this->loadLazyFixtureData(); $user = $this->_em->find(CmsUser::class, $this->userId2); - $this->assertFalse($user->groups->isInitialized()); - $this->assertEquals(2, count($user->groups->slice(0, 10))); + self::assertFalse($user->groups->isInitialized()); + self::assertEquals(2, count($user->groups->slice(0, 10))); $this->useCMSGroupPrefixFilter(); - $this->assertEquals(1, count($user->groups->slice(0, 10))); + self::assertEquals(1, count($user->groups->slice(0, 10))); } private function loadFixtureData(): void @@ -760,34 +760,34 @@ public function testJoinSubclassPersisterFilterOnlyOnRootTableWhenFetchingSubEnt { $this->loadCompanyJoinedSubclassFixtureData(); // Persister - $this->assertEquals(2, count($this->_em->getRepository(CompanyManager::class)->findAll())); + self::assertEquals(2, count($this->_em->getRepository(CompanyManager::class)->findAll())); // SQLWalker - $this->assertEquals(2, count($this->_em->createQuery('SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm')->getResult())); + self::assertEquals(2, count($this->_em->createQuery('SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm')->getResult())); // Enable the filter $this->usePersonNameFilter('Guilh%'); $managers = $this->_em->getRepository(CompanyManager::class)->findAll(); - $this->assertEquals(1, count($managers)); - $this->assertEquals('Guilherme', $managers[0]->getName()); + self::assertEquals(1, count($managers)); + self::assertEquals('Guilherme', $managers[0]->getName()); - $this->assertEquals(1, count($this->_em->createQuery('SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm')->getResult())); + self::assertEquals(1, count($this->_em->createQuery('SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm')->getResult())); } public function testJoinSubclassPersisterFilterOnlyOnRootTableWhenFetchingRootEntity(): void { $this->loadCompanyJoinedSubclassFixtureData(); - $this->assertEquals(3, count($this->_em->getRepository(CompanyPerson::class)->findAll())); - $this->assertEquals(3, count($this->_em->createQuery('SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp')->getResult())); + self::assertEquals(3, count($this->_em->getRepository(CompanyPerson::class)->findAll())); + self::assertEquals(3, count($this->_em->createQuery('SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp')->getResult())); // Enable the filter $this->usePersonNameFilter('Guilh%'); $persons = $this->_em->getRepository(CompanyPerson::class)->findAll(); - $this->assertEquals(1, count($persons)); - $this->assertEquals('Guilherme', $persons[0]->getName()); + self::assertEquals(1, count($persons)); + self::assertEquals('Guilherme', $persons[0]->getName()); - $this->assertEquals(1, count($this->_em->createQuery('SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp')->getResult())); + self::assertEquals(1, count($this->_em->createQuery('SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp')->getResult())); } private function loadCompanyJoinedSubclassFixtureData(): void @@ -818,9 +818,9 @@ public function testSingleTableInheritanceFilterOnlyOnRootTableWhenFetchingSubEn { $this->loadCompanySingleTableInheritanceFixtureData(); // Persister - $this->assertEquals(2, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); + self::assertEquals(2, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); // SQLWalker - $this->assertEquals(2, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc')->getResult())); + self::assertEquals(2, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc')->getResult())); // Enable the filter $conf = $this->_em->getConfiguration(); @@ -829,15 +829,15 @@ public function testSingleTableInheritanceFilterOnlyOnRootTableWhenFetchingSubEn ->enable('completed_contract') ->setParameter('completed', true, Types::BOOLEAN); - $this->assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); - $this->assertEquals(1, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc')->getResult())); + self::assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); + self::assertEquals(1, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc')->getResult())); } public function testSingleTableInheritanceFilterOnlyOnRootTableWhenFetchingRootEntity(): void { $this->loadCompanySingleTableInheritanceFixtureData(); - $this->assertEquals(4, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); - $this->assertEquals(4, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc')->getResult())); + self::assertEquals(4, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); + self::assertEquals(4, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc')->getResult())); // Enable the filter $conf = $this->_em->getConfiguration(); @@ -846,8 +846,8 @@ public function testSingleTableInheritanceFilterOnlyOnRootTableWhenFetchingRootE ->enable('completed_contract') ->setParameter('completed', true, Types::BOOLEAN); - $this->assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); - $this->assertEquals(2, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc')->getResult())); + self::assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); + self::assertEquals(2, count($this->_em->createQuery('SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc')->getResult())); } private function loadCompanySingleTableInheritanceFixtureData(): void @@ -912,14 +912,14 @@ public function testManyToManyExtraLazyCountWithFilterOnSTI(): void $manager = $this->_em->find(CompanyManager::class, $this->managerId); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(4, count($manager->managedContracts)); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertEquals(4, count($manager->managedContracts)); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(2, count($manager->managedContracts)); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertEquals(2, count($manager->managedContracts)); } public function testManyToManyExtraLazyContainsWithFilterOnSTI(): void @@ -930,16 +930,16 @@ public function testManyToManyExtraLazyContainsWithFilterOnSTI(): void $contract1 = $this->_em->find(CompanyContract::class, $this->contractId1); $contract2 = $this->_em->find(CompanyContract::class, $this->contractId2); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertTrue($manager->managedContracts->contains($contract1)); - $this->assertTrue($manager->managedContracts->contains($contract2)); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertTrue($manager->managedContracts->contains($contract1)); + self::assertTrue($manager->managedContracts->contains($contract2)); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertFalse($manager->managedContracts->contains($contract1)); - $this->assertTrue($manager->managedContracts->contains($contract2)); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertFalse($manager->managedContracts->contains($contract1)); + self::assertTrue($manager->managedContracts->contains($contract2)); } public function testManyToManyExtraLazySliceWithFilterOnSTI(): void @@ -948,14 +948,14 @@ public function testManyToManyExtraLazySliceWithFilterOnSTI(): void $manager = $this->_em->find(CompanyManager::class, $this->managerId); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(4, count($manager->managedContracts->slice(0, 10))); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertEquals(4, count($manager->managedContracts->slice(0, 10))); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->managedContracts->isInitialized()); - $this->assertEquals(2, count($manager->managedContracts->slice(0, 10))); + self::assertFalse($manager->managedContracts->isInitialized()); + self::assertEquals(2, count($manager->managedContracts->slice(0, 10))); } private function usePersonNameFilter($name): void @@ -974,14 +974,14 @@ public function testManyToManyExtraLazyCountWithFilterOnCTI(): void $contract = $this->_em->find(CompanyFlexUltraContract::class, $this->contractId1); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(2, count($contract->managers)); + self::assertFalse($contract->managers->isInitialized()); + self::assertEquals(2, count($contract->managers)); // Enable the filter $this->usePersonNameFilter('Benjamin'); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(1, count($contract->managers)); + self::assertFalse($contract->managers->isInitialized()); + self::assertEquals(1, count($contract->managers)); } public function testManyToManyExtraLazyContainsWithFilterOnCTI(): void @@ -992,16 +992,16 @@ public function testManyToManyExtraLazyContainsWithFilterOnCTI(): void $manager1 = $this->_em->find(CompanyManager::class, $this->managerId); $manager2 = $this->_em->find(CompanyManager::class, $this->managerId2); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertTrue($contract->managers->contains($manager1)); - $this->assertTrue($contract->managers->contains($manager2)); + self::assertFalse($contract->managers->isInitialized()); + self::assertTrue($contract->managers->contains($manager1)); + self::assertTrue($contract->managers->contains($manager2)); // Enable the filter $this->usePersonNameFilter('Benjamin'); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertFalse($contract->managers->contains($manager1)); - $this->assertTrue($contract->managers->contains($manager2)); + self::assertFalse($contract->managers->isInitialized()); + self::assertFalse($contract->managers->contains($manager1)); + self::assertTrue($contract->managers->contains($manager2)); } public function testManyToManyExtraLazySliceWithFilterOnCTI(): void @@ -1010,14 +1010,14 @@ public function testManyToManyExtraLazySliceWithFilterOnCTI(): void $contract = $this->_em->find(CompanyFlexUltraContract::class, $this->contractId1); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(2, count($contract->managers->slice(0, 10))); + self::assertFalse($contract->managers->isInitialized()); + self::assertEquals(2, count($contract->managers->slice(0, 10))); // Enable the filter $this->usePersonNameFilter('Benjamin'); - $this->assertFalse($contract->managers->isInitialized()); - $this->assertEquals(1, count($contract->managers->slice(0, 10))); + self::assertFalse($contract->managers->isInitialized()); + self::assertEquals(1, count($contract->managers->slice(0, 10))); } public function testOneToManyExtraLazyCountWithFilterOnSTI(): void @@ -1026,14 +1026,14 @@ public function testOneToManyExtraLazyCountWithFilterOnSTI(): void $manager = $this->_em->find(CompanyManager::class, $this->managerId); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(2, count($manager->soldContracts)); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertEquals(2, count($manager->soldContracts)); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(1, count($manager->soldContracts)); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertEquals(1, count($manager->soldContracts)); } public function testOneToManyExtraLazyContainsWithFilterOnSTI(): void @@ -1044,16 +1044,16 @@ public function testOneToManyExtraLazyContainsWithFilterOnSTI(): void $contract1 = $this->_em->find(CompanyContract::class, $this->contractId1); $contract2 = $this->_em->find(CompanyContract::class, $this->contractId2); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertTrue($manager->soldContracts->contains($contract1)); - $this->assertTrue($manager->soldContracts->contains($contract2)); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertTrue($manager->soldContracts->contains($contract1)); + self::assertTrue($manager->soldContracts->contains($contract2)); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertFalse($manager->soldContracts->contains($contract1)); - $this->assertTrue($manager->soldContracts->contains($contract2)); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertFalse($manager->soldContracts->contains($contract1)); + self::assertTrue($manager->soldContracts->contains($contract2)); } public function testOneToManyExtraLazySliceWithFilterOnSTI(): void @@ -1062,14 +1062,14 @@ public function testOneToManyExtraLazySliceWithFilterOnSTI(): void $manager = $this->_em->find(CompanyManager::class, $this->managerId); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(2, count($manager->soldContracts->slice(0, 10))); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertEquals(2, count($manager->soldContracts->slice(0, 10))); // Enable the filter $this->useCompletedContractFilter(); - $this->assertFalse($manager->soldContracts->isInitialized()); - $this->assertEquals(1, count($manager->soldContracts->slice(0, 10))); + self::assertFalse($manager->soldContracts->isInitialized()); + self::assertEquals(1, count($manager->soldContracts->slice(0, 10))); } private function loadCompanyOrganizationEventJoinedSubclassFixtureData(): void @@ -1110,14 +1110,14 @@ public function testOneToManyExtraLazyCountWithFilterOnCTI(): void $organization = $this->_em->find(CompanyOrganization::class, $this->organizationId); - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(2, count($organization->events)); + self::assertFalse($organization->events->isInitialized()); + self::assertEquals(2, count($organization->events)); // Enable the filter $this->useCompanyEventIdFilter(); - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(1, count($organization->events)); + self::assertFalse($organization->events->isInitialized()); + self::assertEquals(1, count($organization->events)); } public function testOneToManyExtraLazyContainsWithFilterOnCTI(): void @@ -1129,16 +1129,16 @@ public function testOneToManyExtraLazyContainsWithFilterOnCTI(): void $event1 = $this->_em->find(CompanyEvent::class, $this->eventId1); $event2 = $this->_em->find(CompanyEvent::class, $this->eventId2); - $this->assertFalse($organization->events->isInitialized()); - $this->assertTrue($organization->events->contains($event1)); - $this->assertTrue($organization->events->contains($event2)); + self::assertFalse($organization->events->isInitialized()); + self::assertTrue($organization->events->contains($event1)); + self::assertTrue($organization->events->contains($event2)); // Enable the filter $this->useCompanyEventIdFilter(); - $this->assertFalse($organization->events->isInitialized()); - $this->assertFalse($organization->events->contains($event1)); - $this->assertTrue($organization->events->contains($event2)); + self::assertFalse($organization->events->isInitialized()); + self::assertFalse($organization->events->contains($event1)); + self::assertTrue($organization->events->contains($event2)); } public function testOneToManyExtraLazySliceWithFilterOnCTI(): void @@ -1147,14 +1147,14 @@ public function testOneToManyExtraLazySliceWithFilterOnCTI(): void $organization = $this->_em->find(CompanyOrganization::class, $this->organizationId); - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(2, count($organization->events->slice(0, 10))); + self::assertFalse($organization->events->isInitialized()); + self::assertEquals(2, count($organization->events->slice(0, 10))); // Enable the filter $this->useCompanyEventIdFilter(); - $this->assertFalse($organization->events->isInitialized()); - $this->assertEquals(1, count($organization->events->slice(0, 10))); + self::assertFalse($organization->events->isInitialized()); + self::assertEquals(1, count($organization->events->slice(0, 10))); } public function testRetrieveSingleAsListThrowsException(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php index 018c2d8b39e..bea3c843bff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php @@ -28,7 +28,7 @@ public function testGeneratedSchema(): Schema { $schema = $this->_em->getConnection()->getSchemaManager()->createSchema(); - $this->assertTrue($schema->hasTable('company_contracts')); + self::assertTrue($schema->hasTable('company_contracts')); return $schema; } @@ -42,14 +42,14 @@ public function testSingleTableInheritance(Schema $schema): void $table = $schema->getTable('company_contracts'); // Check nullability constraints - $this->assertTrue($table->getColumn('id')->getNotnull()); - $this->assertTrue($table->getColumn('completed')->getNotnull()); - $this->assertFalse($table->getColumn('salesPerson_id')->getNotnull()); - $this->assertTrue($table->getColumn('discr')->getNotnull()); - $this->assertFalse($table->getColumn('fixPrice')->getNotnull()); - $this->assertFalse($table->getColumn('hoursWorked')->getNotnull()); - $this->assertFalse($table->getColumn('pricePerHour')->getNotnull()); - $this->assertFalse($table->getColumn('maxPrice')->getNotnull()); + self::assertTrue($table->getColumn('id')->getNotnull()); + self::assertTrue($table->getColumn('completed')->getNotnull()); + self::assertFalse($table->getColumn('salesPerson_id')->getNotnull()); + self::assertTrue($table->getColumn('discr')->getNotnull()); + self::assertFalse($table->getColumn('fixPrice')->getNotnull()); + self::assertFalse($table->getColumn('hoursWorked')->getNotnull()); + self::assertFalse($table->getColumn('pricePerHour')->getNotnull()); + self::assertFalse($table->getColumn('maxPrice')->getNotnull()); } /** @@ -58,7 +58,7 @@ public function testSingleTableInheritance(Schema $schema): void public function testDropPartSchemaWithForeignKeys(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Foreign Key test'); + self::markTestSkipped('Foreign Key test'); } $sql = $this->_schemaTool->getDropSchemaSQL( @@ -66,6 +66,6 @@ public function testDropPartSchemaWithForeignKeys(): void $this->_em->getClassMetadata(CompanyManager::class), ] ); - $this->assertEquals(4, count($sql)); + self::assertEquals(4, count($sql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 10bc5dbce8e..5d954c7f83f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -41,7 +41,7 @@ public function testDefaultValueIsComparedCorrectly(): void return strpos($sql, 'DBAL483') !== false; }); - $this->assertEquals(0, count($updateSql)); + self::assertEquals(0, count($updateSql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 103b1d8bc20..1442784a795 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -35,7 +35,7 @@ protected function setUp(): void $conn = $this->_em->getConnection(); if (strpos($conn->getDriver()->getName(), 'sqlite') !== false) { - $this->markTestSkipped('SQLite does not support ALTER TABLE statements.'); + self::markTestSkipped('SQLite does not support ALTER TABLE statements.'); } $this->schemaTool = new Tools\SchemaTool($this->_em); @@ -103,6 +103,6 @@ public function assertCreatedSchemaNeedsNoUpdates($classes): void return strpos($sql, 'DROP') === false; }); - $this->assertEquals(0, count($sql), 'SQL: ' . implode(PHP_EOL, $sql)); + self::assertEquals(0, count($sql), 'SQL: ' . implode(PHP_EOL, $sql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 6d5e400ead0..d738ae7c021 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -23,7 +23,7 @@ protected function setUp(): void { parent::setUp(); if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - $this->markTestSkipped('The ' . self::class . ' requires the use of mysql.'); + self::markTestSkipped('The ' . self::class . ' requires the use of mysql.'); } } @@ -42,23 +42,23 @@ public function testGetCreateSchemaSql(): void $sql = $tool->getCreateSchemaSql($classes); $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - $this->assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); - $this->assertEquals('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); - $this->assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[2]); - $this->assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[3]); - $this->assertEquals('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[4]); - $this->assertEquals('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[5]); - $this->assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[6]); - $this->assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[7]); - $this->assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)', $sql[8]); - $this->assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[9]); - $this->assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id)', $sql[10]); - $this->assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[11]); - $this->assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES cms_tags (id)', $sql[12]); - $this->assertEquals('ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[13]); - $this->assertEquals('ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[14]); - - $this->assertEquals(15, count($sql)); + self::assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); + self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[2]); + self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[3]); + self::assertEquals('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[4]); + self::assertEquals('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[5]); + self::assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[6]); + self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[7]); + self::assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)', $sql[8]); + self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[9]); + self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id)', $sql[10]); + self::assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[11]); + self::assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES cms_tags (id)', $sql[12]); + self::assertEquals('ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[13]); + self::assertEquals('ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[14]); + + self::assertEquals(15, count($sql)); } private function getColumnCollationDeclarationSQL(string $collation): string @@ -78,8 +78,8 @@ public function testGetCreateSchemaSql2(): void $sql = $tool->getCreateSchemaSql($classes); $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - $this->assertEquals(1, count($sql)); - $this->assertEquals('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals(1, count($sql)); + self::assertEquals('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); } public function testGetCreateSchemaSql3(): void @@ -90,8 +90,8 @@ public function testGetCreateSchemaSql3(): void $sql = $tool->getCreateSchemaSql($classes); $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - $this->assertEquals(1, count($sql)); - $this->assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals(1, count($sql)); + self::assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); } /** @@ -104,7 +104,7 @@ public function testGetCreateSchemaSql4(): void $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); - $this->assertEquals(0, count($sql)); + self::assertEquals(0, count($sql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index 6a4569ef2f5..3e400ce7cd0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -28,7 +28,7 @@ protected function setUp(): void parent::setUp(); if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { - $this->markTestSkipped('The ' . self::class . ' requires the use of postgresql.'); + self::markTestSkipped('The ' . self::class . ' requires the use of postgresql.'); } } @@ -36,7 +36,7 @@ public function testPostgresMetadataSequenceIncrementedBy10(): void { $address = $this->_em->getClassMetadata(Models\CMS\CmsAddress::class); - $this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); + self::assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); } public function testGetCreateSchemaSql(): void @@ -51,31 +51,31 @@ public function testGetCreateSchemaSql(): void $sql = $tool->getCreateSchemaSql($classes); $sqlCount = count($sql); - $this->assertEquals('CREATE TABLE cms_addresses (id INT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); - $this->assertEquals('CREATE UNIQUE INDEX UNIQ_ACAC157BA76ED395 ON cms_addresses (user_id)', array_shift($sql)); - $this->assertEquals('CREATE TABLE cms_users (id INT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); - $this->assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5F85E0677 ON cms_users (username)', array_shift($sql)); - $this->assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 ON cms_users (email_id)', array_shift($sql)); - $this->assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_7EA9409AA76ED395 ON cms_users_groups (user_id)', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_7EA9409AFE54D947 ON cms_users_groups (group_id)', array_shift($sql)); - $this->assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY(user_id, tag_id))', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_93F5A1ADA76ED395 ON cms_users_tags (user_id)', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_93F5A1ADBAD26311 ON cms_users_tags (tag_id)', array_shift($sql)); - $this->assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))', array_shift($sql)); - $this->assertEquals('CREATE INDEX IDX_F21F790FA76ED395 ON cms_phonenumbers (user_id)', array_shift($sql)); - $this->assertEquals('CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 1 MINVALUE 1 START 1', array_shift($sql)); - $this->assertEquals('CREATE SEQUENCE cms_users_id_seq INCREMENT BY 1 MINVALUE 1 START 1', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES cms_tags (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - $this->assertEquals('ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); - - $this->assertEquals([], $sql, 'SQL Array should be empty now.'); - $this->assertEquals(22, $sqlCount, 'Total of 22 queries should be executed'); + self::assertEquals('CREATE TABLE cms_addresses (id INT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); + self::assertEquals('CREATE UNIQUE INDEX UNIQ_ACAC157BA76ED395 ON cms_addresses (user_id)', array_shift($sql)); + self::assertEquals('CREATE TABLE cms_users (id INT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); + self::assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5F85E0677 ON cms_users (username)', array_shift($sql)); + self::assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 ON cms_users (email_id)', array_shift($sql)); + self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_7EA9409AA76ED395 ON cms_users_groups (user_id)', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_7EA9409AFE54D947 ON cms_users_groups (group_id)', array_shift($sql)); + self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY(user_id, tag_id))', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_93F5A1ADA76ED395 ON cms_users_tags (user_id)', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_93F5A1ADBAD26311 ON cms_users_tags (tag_id)', array_shift($sql)); + self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))', array_shift($sql)); + self::assertEquals('CREATE INDEX IDX_F21F790FA76ED395 ON cms_phonenumbers (user_id)', array_shift($sql)); + self::assertEquals('CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 1 MINVALUE 1 START 1', array_shift($sql)); + self::assertEquals('CREATE SEQUENCE cms_users_id_seq INCREMENT BY 1 MINVALUE 1 START 1', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_users_tags ADD CONSTRAINT FK_93F5A1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES cms_tags (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + self::assertEquals('ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE', array_shift($sql)); + + self::assertEquals([], $sql, 'SQL Array should be empty now.'); + self::assertEquals(22, $sqlCount, 'Total of 22 queries should be executed'); } public function testGetCreateSchemaSql2(): void @@ -85,10 +85,10 @@ public function testGetCreateSchemaSql2(): void $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); - $this->assertEquals(2, count($sql)); + self::assertEquals(2, count($sql)); - $this->assertEquals('CREATE TABLE decimal_model (id INT NOT NULL, "decimal" NUMERIC(5, 2) NOT NULL, "high_scale" NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id))', $sql[0]); - $this->assertEquals('CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1', $sql[1]); + self::assertEquals('CREATE TABLE decimal_model (id INT NOT NULL, "decimal" NUMERIC(5, 2) NOT NULL, "high_scale" NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id))', $sql[0]); + self::assertEquals('CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1', $sql[1]); } public function testGetCreateSchemaSql3(): void @@ -98,9 +98,9 @@ public function testGetCreateSchemaSql3(): void $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); - $this->assertEquals(2, count($sql)); - $this->assertEquals('CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))', $sql[0]); - $this->assertEquals('CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1', $sql[1]); + self::assertEquals(2, count($sql)); + self::assertEquals('CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))', $sql[0]); + self::assertEquals('CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1', $sql[1]); } public function testGetDropSchemaSql(): void @@ -114,7 +114,7 @@ public function testGetDropSchemaSql(): void $tool = new SchemaTool($this->_em); $sql = $tool->getDropSchemaSQL($classes); - $this->assertEquals(17, count($sql)); + self::assertEquals(17, count($sql)); $dropSequenceSQLs = 0; @@ -124,7 +124,7 @@ public function testGetDropSchemaSql(): void } } - $this->assertEquals(4, $dropSequenceSQLs, 'Expect 4 sequences to be dropped.'); + self::assertEquals(4, $dropSequenceSQLs, 'Expect 4 sequences to be dropped.'); } /** @@ -145,7 +145,7 @@ public function testUpdateSchemaWithPostgreSQLSchema(): void return strpos($sql, 'DROP SEQUENCE stonewood.') === 0; }); - $this->assertCount(0, $sql, implode("\n", $sql)); + self::assertCount(0, $sql, implode("\n", $sql)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php index 2cd6f4c5f24..7ca51439525 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php @@ -74,7 +74,7 @@ public function testValidateModelSets(string $modelSet): void foreach ($classes as $class) { $ce = $validator->validateClass($class); - $this->assertEmpty($ce, 'Invalid Modelset: ' . $modelSet . ' class ' . $class->name . ': ' . implode("\n", $ce)); + self::assertEmpty($ce, 'Invalid Modelset: ' . $modelSet . ' class ' . $class->name . ': ' . implode("\n", $ce)); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php index 95855ff499c..b1b7118523c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php @@ -34,29 +34,29 @@ public function testPutAndLoadCompositPrimaryKeyEntities(): void $flight->setDeparture(new DateTime('tomorrow')); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $this->_em->persist($flight); $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $flight = $this->_em->find(Flight::class, $id); $leavingFrom = $flight->getLeavingFrom(); $goingTo = $flight->getGoingTo(); - $this->assertInstanceOf(Flight::class, $flight); - $this->assertInstanceOf(City::class, $goingTo); - $this->assertInstanceOf(City::class, $leavingFrom); + self::assertInstanceOf(Flight::class, $flight); + self::assertInstanceOf(City::class, $goingTo); + self::assertInstanceOf(City::class, $leavingFrom); - $this->assertEquals($goingTo->getId(), $goingToId); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($goingTo->getId(), $goingToId); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testRemoveCompositPrimaryKeyEntities(): void @@ -80,25 +80,25 @@ public function testRemoveCompositPrimaryKeyEntities(): void $flight->setDeparture(new DateTime('tomorrow')); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $this->_em->persist($flight); $this->_em->flush(); - $this->assertTrue($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $this->_em->remove($flight); $this->_em->flush(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertFalse($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertNull($this->_em->find(Flight::class, $id)); + self::assertNull($this->_em->find(Flight::class, $id)); } public function testUpdateCompositPrimaryKeyEntities(): void @@ -124,31 +124,31 @@ public function testUpdateCompositPrimaryKeyEntities(): void $flight->setDeparture($now); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $this->_em->persist($flight); $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $flight = $this->_em->find(Flight::class, $id); $leavingFrom = $flight->getLeavingFrom(); $goingTo = $flight->getGoingTo(); - $this->assertInstanceOf(Flight::class, $flight); - $this->assertInstanceOf(City::class, $goingTo); - $this->assertInstanceOf(City::class, $leavingFrom); + self::assertInstanceOf(Flight::class, $flight); + self::assertInstanceOf(City::class, $goingTo); + self::assertInstanceOf(City::class, $leavingFrom); - $this->assertEquals($goingTo->getId(), $goingToId); - $this->assertEquals($flight->getDeparture(), $now); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($goingTo->getId(), $goingToId); + self::assertEquals($flight->getDeparture(), $now); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $flight->setDeparture($tomorrow); @@ -156,23 +156,23 @@ public function testUpdateCompositPrimaryKeyEntities(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Flight::class, $id)); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(Flight::class, $id)); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $flight = $this->_em->find(Flight::class, $id); $leavingFrom = $flight->getLeavingFrom(); $goingTo = $flight->getGoingTo(); - $this->assertInstanceOf(Flight::class, $flight); - $this->assertInstanceOf(City::class, $goingTo); - $this->assertInstanceOf(City::class, $leavingFrom); + self::assertInstanceOf(Flight::class, $flight); + self::assertInstanceOf(City::class, $goingTo); + self::assertInstanceOf(City::class, $leavingFrom); - $this->assertEquals($goingTo->getId(), $goingToId); - $this->assertEquals($flight->getDeparture(), $tomorrow); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($leavingFrom->getId(), $leavingFromId); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($goingTo->getId(), $goingToId); + self::assertEquals($flight->getDeparture(), $tomorrow); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($leavingFrom->getId(), $leavingFromId); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php index c8ce9e725b7..00262bf5276 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php @@ -58,9 +58,9 @@ public function testFindByReturnsCachedEntity(): void $admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]); - $this->assertEquals('Italy', $admin1Rome->country->name); - $this->assertEquals(2, count($admin1Rome->names)); - $this->assertEquals($queries + 3, $this->getCurrentQueryCount()); + self::assertEquals('Italy', $admin1Rome->country->name); + self::assertEquals(2, count($admin1Rome->names)); + self::assertEquals($queries + 3, $this->getCurrentQueryCount()); $this->_em->clear(); @@ -68,9 +68,9 @@ public function testFindByReturnsCachedEntity(): void $admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]); - $this->assertEquals('Italy', $admin1Rome->country->name); - $this->assertEquals(2, count($admin1Rome->names)); - $this->assertEquals($queries, $this->getCurrentQueryCount()); + self::assertEquals('Italy', $admin1Rome->country->name); + self::assertEquals(2, count($admin1Rome->names)); + self::assertEquals($queries, $this->getCurrentQueryCount()); } private function evictRegions(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php index df8ce56d95b..53619538ecb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php @@ -65,18 +65,18 @@ public function testBasicConcurrentEntityReadLock(): void $region = $this->_em->getCache()->getEntityCacheRegion(Country::class); assert($region instanceof ConcurrentRegionMock); - $this->assertTrue($this->cache->containsEntity(Country::class, $countryId)); + self::assertTrue($this->cache->containsEntity(Country::class, $countryId)); $region->setLock($cacheId, Lock::createLockRead()); // another proc lock the entity cache - $this->assertFalse($this->cache->containsEntity(Country::class, $countryId)); + self::assertFalse($this->cache->containsEntity(Country::class, $countryId)); $queryCount = $this->getCurrentQueryCount(); $country = $this->_em->find(Country::class, $countryId); - $this->assertInstanceOf(Country::class, $country); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertFalse($this->cache->containsEntity(Country::class, $countryId)); + self::assertInstanceOf(Country::class, $country); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertFalse($this->cache->containsEntity(Country::class, $countryId)); } public function testBasicConcurrentCollectionReadLock(): void @@ -91,10 +91,10 @@ public function testBasicConcurrentCollectionReadLock(): void $stateId = $this->states[0]->getId(); $state = $this->_em->find(State::class, $stateId); - $this->assertInstanceOf(State::class, $state); - $this->assertInstanceOf(Country::class, $state->getCountry()); - $this->assertNotNull($state->getCountry()->getName()); - $this->assertCount(2, $state->getCities()); + self::assertInstanceOf(State::class, $state); + self::assertInstanceOf(Country::class, $state->getCountry()); + self::assertNotNull($state->getCountry()->getName()); + self::assertCount(2, $state->getCities()); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -104,30 +104,30 @@ public function testBasicConcurrentCollectionReadLock(): void $region = $this->_em->getCache()->getCollectionCacheRegion(State::class, 'cities'); assert($region instanceof ConcurrentRegionMock); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId)); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId)); $region->setLock($cacheId, Lock::createLockRead()); // another proc lock the entity cache - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId)); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId)); $queryCount = $this->getCurrentQueryCount(); $state = $this->_em->find(State::class, $stateId); - $this->assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertInstanceOf(State::class, $state); - $this->assertCount(2, $state->getCities()); + self::assertInstanceOf(State::class, $state); + self::assertCount(2, $state->getCities()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $stateId)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php index 8eb498c5900..763d80027a8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php @@ -22,7 +22,7 @@ public function testMatchingPut(): void $this->evictRegions(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); @@ -34,11 +34,11 @@ public function testMatchingPut(): void // Because matching returns lazy collection, we force initialization $result1->toArray(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $this->_em->clear(); @@ -46,13 +46,13 @@ public function testMatchingPut(): void Criteria::expr()->eq('name', $name) )); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(1, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(1, $result2); - $this->assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[0]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); } public function testRepositoryMatching(): void @@ -62,7 +62,7 @@ public function testRepositoryMatching(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); @@ -73,10 +73,10 @@ public function testRepositoryMatching(): void // Because matching returns lazy collection, we force initialization $result1->toArray(); - $this->assertCount(1, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertCount(1, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); $this->_em->clear(); @@ -87,13 +87,13 @@ public function testRepositoryMatching(): void // Because matching returns lazy collection, we force initialization $result2->toArray(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(1, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(1, $result2); - $this->assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[0]); - $this->assertEquals($this->countries[0]->getId(), $result2[0]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result2[0]->getName()); + self::assertEquals($this->countries[0]->getId(), $result2[0]->getId()); + self::assertEquals($this->countries[0]->getName(), $result2[0]->getName()); $result3 = $repository->matching(new Criteria( Criteria::expr()->eq('name', $this->countries[1]->getName()) @@ -102,25 +102,25 @@ public function testRepositoryMatching(): void // Because matching returns lazy collection, we force initialization $result3->toArray(); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertCount(1, $result3); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(1, $result3); - $this->assertInstanceOf(Country::class, $result3[0]); + self::assertInstanceOf(Country::class, $result3[0]); - $this->assertEquals($this->countries[1]->getId(), $result3[0]->getId()); - $this->assertEquals($this->countries[1]->getName(), $result3[0]->getName()); + self::assertEquals($this->countries[1]->getId(), $result3[0]->getId()); + self::assertEquals($this->countries[1]->getName(), $result3[0]->getName()); $result4 = $repository->matching(new Criteria( Criteria::expr()->eq('name', $this->countries[1]->getName()) )); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertCount(1, $result4); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(1, $result4); - $this->assertInstanceOf(Country::class, $result4[0]); + self::assertInstanceOf(Country::class, $result4[0]); - $this->assertEquals($this->countries[1]->getId(), $result4[0]->getId()); - $this->assertEquals($this->countries[1]->getName(), $result4[0]->getName()); + self::assertEquals($this->countries[1]->getId(), $result4[0]->getId()); + self::assertEquals($this->countries[1]->getName(), $result4[0]->getName()); } public function testCollectionMatching(): void @@ -139,9 +139,9 @@ public function testCollectionMatching(): void Criteria::expr()->eq('name', $itemName) )); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Collection::class, $matching); - $this->assertCount(1, $matching); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(Collection::class, $matching); + self::assertCount(1, $matching); $this->_em->clear(); @@ -152,8 +152,8 @@ public function testCollectionMatching(): void Criteria::expr()->eq('name', $itemName) )); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Collection::class, $matching); - $this->assertCount(1, $matching); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(Collection::class, $matching); + self::assertCount(1, $matching); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php index 1c634a266df..198311ba8f7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php @@ -50,8 +50,8 @@ public function testCacheCountAfterAddThenFlush(): void $owner = $this->_em->find(Travel::class, $ownerId); $ref = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertTrue($this->cache->containsEntity(Travel::class, $ownerId)); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId)); + self::assertTrue($this->cache->containsEntity(Travel::class, $ownerId)); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId)); $newItem = new City('New City', $ref); $owner->getVisitedCities()->add($newItem); @@ -61,23 +61,23 @@ public function testCacheCountAfterAddThenFlush(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($owner->getVisitedCities()->isInitialized()); - $this->assertEquals(4, $owner->getVisitedCities()->count()); - $this->assertFalse($owner->getVisitedCities()->isInitialized()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertFalse($owner->getVisitedCities()->isInitialized()); + self::assertEquals(4, $owner->getVisitedCities()->count()); + self::assertFalse($owner->getVisitedCities()->isInitialized()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $this->_em->flush(); - $this->assertFalse($owner->getVisitedCities()->isInitialized()); - $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId)); + self::assertFalse($owner->getVisitedCities()->isInitialized()); + self::assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $ownerId)); $this->_em->clear(); $queryCount = $this->getCurrentQueryCount(); $owner = $this->_em->find(Travel::class, $ownerId); - $this->assertEquals(4, $owner->getVisitedCities()->count()); - $this->assertFalse($owner->getVisitedCities()->isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals(4, $owner->getVisitedCities()->count()); + self::assertFalse($owner->getVisitedCities()->isInitialized()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php index 3bb2093d85f..0a79f16e91b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php @@ -24,8 +24,8 @@ public function testUseSameRegion(): void $contactRegion = $this->cache->getEntityCacheRegion(AttractionContactInfo::class); $locationRegion = $this->cache->getEntityCacheRegion(AttractionLocationInfo::class); - $this->assertEquals($infoRegion->getName(), $contactRegion->getName()); - $this->assertEquals($infoRegion->getName(), $locationRegion->getName()); + self::assertEquals($infoRegion->getName(), $contactRegion->getName()); + self::assertEquals($infoRegion->getName(), $locationRegion->getName()); } public function testPutOnPersistJoinTableInheritance(): void @@ -38,10 +38,10 @@ public function testPutOnPersistJoinTableInheritance(): void $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[0]->getId())); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[1]->getId())); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[2]->getId())); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[3]->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[0]->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[1]->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[2]->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $this->attractionsInfo[3]->getId())); } public function testJoinTableCountaisRootClass(): void @@ -55,8 +55,8 @@ public function testJoinTableCountaisRootClass(): void $this->_em->clear(); foreach ($this->attractionsInfo as $info) { - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $info->getId())); - $this->assertTrue($this->cache->containsEntity(get_class($info), $info->getId())); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $info->getId())); + self::assertTrue($this->cache->containsEntity(get_class($info), $info->getId())); } } @@ -75,33 +75,33 @@ public function testPutAndLoadJoinTableEntities(): void $entityId1 = $this->attractionsInfo[0]->getId(); $entityId2 = $this->attractionsInfo[1]->getId(); - $this->assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId1)); - $this->assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId2)); - $this->assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId1)); - $this->assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId2)); + self::assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId1)); + self::assertFalse($this->cache->containsEntity(AttractionInfo::class, $entityId2)); + self::assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId1)); + self::assertFalse($this->cache->containsEntity(AttractionContactInfo::class, $entityId2)); $queryCount = $this->getCurrentQueryCount(); $entity1 = $this->_em->find(AttractionInfo::class, $entityId1); $entity2 = $this->_em->find(AttractionInfo::class, $entityId2); //load entity and relation whit sub classes - $this->assertEquals($queryCount + 4, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 4, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId1)); - $this->assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId2)); - $this->assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId1)); - $this->assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId2)); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId1)); + self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $entityId2)); + self::assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId1)); + self::assertTrue($this->cache->containsEntity(AttractionContactInfo::class, $entityId2)); - $this->assertInstanceOf(AttractionInfo::class, $entity1); - $this->assertInstanceOf(AttractionInfo::class, $entity2); - $this->assertInstanceOf(AttractionContactInfo::class, $entity1); - $this->assertInstanceOf(AttractionContactInfo::class, $entity2); + self::assertInstanceOf(AttractionInfo::class, $entity1); + self::assertInstanceOf(AttractionInfo::class, $entity2); + self::assertInstanceOf(AttractionContactInfo::class, $entity1); + self::assertInstanceOf(AttractionContactInfo::class, $entity2); - $this->assertEquals($this->attractionsInfo[0]->getId(), $entity1->getId()); - $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity1->getFone()); + self::assertEquals($this->attractionsInfo[0]->getId(), $entity1->getId()); + self::assertEquals($this->attractionsInfo[0]->getFone(), $entity1->getFone()); - $this->assertEquals($this->attractionsInfo[1]->getId(), $entity2->getId()); - $this->assertEquals($this->attractionsInfo[1]->getFone(), $entity2->getFone()); + self::assertEquals($this->attractionsInfo[1]->getId(), $entity2->getId()); + self::assertEquals($this->attractionsInfo[1]->getFone(), $entity2->getFone()); $this->_em->clear(); @@ -109,20 +109,20 @@ public function testPutAndLoadJoinTableEntities(): void $entity3 = $this->_em->find(AttractionInfo::class, $entityId1); $entity4 = $this->_em->find(AttractionInfo::class, $entityId2); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(AttractionInfo::class, $entity3); - $this->assertInstanceOf(AttractionInfo::class, $entity4); - $this->assertInstanceOf(AttractionContactInfo::class, $entity3); - $this->assertInstanceOf(AttractionContactInfo::class, $entity4); + self::assertInstanceOf(AttractionInfo::class, $entity3); + self::assertInstanceOf(AttractionInfo::class, $entity4); + self::assertInstanceOf(AttractionContactInfo::class, $entity3); + self::assertInstanceOf(AttractionContactInfo::class, $entity4); - $this->assertNotSame($entity1, $entity3); - $this->assertEquals($entity1->getId(), $entity3->getId()); - $this->assertEquals($entity1->getFone(), $entity3->getFone()); + self::assertNotSame($entity1, $entity3); + self::assertEquals($entity1->getId(), $entity3->getId()); + self::assertEquals($entity1->getFone(), $entity3->getFone()); - $this->assertNotSame($entity2, $entity4); - $this->assertEquals($entity2->getId(), $entity4->getId()); - $this->assertEquals($entity2->getFone(), $entity4->getFone()); + self::assertNotSame($entity2, $entity4); + self::assertEquals($entity2->getId(), $entity4->getId()); + self::assertEquals($entity2->getFone(), $entity4->getFone()); } public function testQueryCacheFindAllJoinTableEntities(): void @@ -141,8 +141,8 @@ public function testQueryCacheFindAllJoinTableEntities(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractionsInfo), $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractionsInfo), $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); @@ -150,11 +150,11 @@ public function testQueryCacheFindAllJoinTableEntities(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractionsInfo), $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractionsInfo), $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(AttractionInfo::class, $entity); + self::assertInstanceOf(AttractionInfo::class, $entity); } } @@ -170,29 +170,29 @@ public function testOneToManyRelationJoinTable(): void $entity = $this->_em->find(Attraction::class, $this->attractions[0]->getId()); - $this->assertInstanceOf(Attraction::class, $entity); - $this->assertInstanceOf(PersistentCollection::class, $entity->getInfos()); - $this->assertCount(1, $entity->getInfos()); + self::assertInstanceOf(Attraction::class, $entity); + self::assertInstanceOf(PersistentCollection::class, $entity->getInfos()); + self::assertCount(1, $entity->getInfos()); $ownerId = $this->attractions[0]->getId(); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $ownerId)); - $this->assertTrue($this->cache->containsCollection(Attraction::class, 'infos', $ownerId)); + self::assertTrue($this->cache->containsEntity(Attraction::class, $ownerId)); + self::assertTrue($this->cache->containsCollection(Attraction::class, 'infos', $ownerId)); - $this->assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0)); - $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); + self::assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0)); + self::assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); $this->_em->clear(); $entity = $this->_em->find(Attraction::class, $this->attractions[0]->getId()); - $this->assertInstanceOf(Attraction::class, $entity); - $this->assertInstanceOf(PersistentCollection::class, $entity->getInfos()); - $this->assertCount(1, $entity->getInfos()); + self::assertInstanceOf(Attraction::class, $entity); + self::assertInstanceOf(PersistentCollection::class, $entity->getInfos()); + self::assertCount(1, $entity->getInfos()); - $this->assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0)); - $this->assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); + self::assertInstanceOf(AttractionContactInfo::class, $entity->getInfos()->get(0)); + self::assertEquals($this->attractionsInfo[0]->getFone(), $entity->getInfos()->get(0)->getFone()); } public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void @@ -212,8 +212,8 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractionsInfo), $result1); - $this->assertEquals($queryCount + 5, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractionsInfo), $result1); + self::assertEquals($queryCount + 5, $this->getCurrentQueryCount()); $contact = new AttractionContactInfo( '1234-1234', @@ -230,11 +230,11 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractionsInfo) + 1, $result2); - $this->assertEquals($queryCount + 6, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractionsInfo) + 1, $result2); + self::assertEquals($queryCount + 6, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(AttractionInfo::class, $entity); + self::assertInstanceOf(AttractionInfo::class, $entity); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php index 61a6eaa4301..2cbf5403207 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php @@ -26,16 +26,16 @@ public function testShouldPutManyToManyCollectionOwningSideOnPersist(): void $this->loadFixturesTravels(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); } public function testPutAndLoadManyToManyRelation(): void @@ -55,51 +55,51 @@ public function testPutAndLoadManyToManyRelation(): void $this->secondLevelCacheLogger->clearStats(); - $this->assertFalse($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); + self::assertFalse($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); + self::assertFalse($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); - $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); - $this->assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); + self::assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); + self::assertFalse($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[2]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->cities[2]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->cities[3]->getId())); $t1 = $this->_em->find(Travel::class, $this->travels[0]->getId()); $t2 = $this->_em->find(Travel::class, $this->travels[1]->getId()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Travel::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(Travel::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Travel::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(Travel::class))); //trigger lazy load - $this->assertCount(3, $t1->getVisitedCities()); - $this->assertCount(2, $t2->getVisitedCities()); + self::assertCount(3, $t1->getVisitedCities()); + self::assertCount(2, $t2->getVisitedCities()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); + self::assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); - $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(0)); - $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(1)); - $this->assertInstanceOf(City::class, $t1->getVisitedCities()->get(2)); + self::assertInstanceOf(City::class, $t1->getVisitedCities()->get(0)); + self::assertInstanceOf(City::class, $t1->getVisitedCities()->get(1)); + self::assertInstanceOf(City::class, $t1->getVisitedCities()->get(2)); - $this->assertInstanceOf(City::class, $t2->getVisitedCities()->get(0)); - $this->assertInstanceOf(City::class, $t2->getVisitedCities()->get(1)); + self::assertInstanceOf(City::class, $t2->getVisitedCities()->get(0)); + self::assertInstanceOf(City::class, $t2->getVisitedCities()->get(1)); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[1]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -110,42 +110,42 @@ public function testPutAndLoadManyToManyRelation(): void $t4 = $this->_em->find(Travel::class, $this->travels[1]->getId()); //trigger lazy load from cache - $this->assertCount(3, $t3->getVisitedCities()); - $this->assertCount(2, $t4->getVisitedCities()); + self::assertCount(3, $t3->getVisitedCities()); + self::assertCount(2, $t4->getVisitedCities()); - $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(0)); - $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(1)); - $this->assertInstanceOf(City::class, $t3->getVisitedCities()->get(2)); + self::assertInstanceOf(City::class, $t3->getVisitedCities()->get(0)); + self::assertInstanceOf(City::class, $t3->getVisitedCities()->get(1)); + self::assertInstanceOf(City::class, $t3->getVisitedCities()->get(2)); - $this->assertInstanceOf(City::class, $t4->getVisitedCities()->get(0)); - $this->assertInstanceOf(City::class, $t4->getVisitedCities()->get(1)); + self::assertInstanceOf(City::class, $t4->getVisitedCities()->get(0)); + self::assertInstanceOf(City::class, $t4->getVisitedCities()->get(1)); - $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Travel::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); + self::assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Travel::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(Travel::class, 'visitedCities'))); - $this->assertNotSame($t1->getVisitedCities()->get(0), $t3->getVisitedCities()->get(0)); - $this->assertEquals($t1->getVisitedCities()->get(0)->getId(), $t3->getVisitedCities()->get(0)->getId()); - $this->assertEquals($t1->getVisitedCities()->get(0)->getName(), $t3->getVisitedCities()->get(0)->getName()); + self::assertNotSame($t1->getVisitedCities()->get(0), $t3->getVisitedCities()->get(0)); + self::assertEquals($t1->getVisitedCities()->get(0)->getId(), $t3->getVisitedCities()->get(0)->getId()); + self::assertEquals($t1->getVisitedCities()->get(0)->getName(), $t3->getVisitedCities()->get(0)->getName()); - $this->assertNotSame($t1->getVisitedCities()->get(1), $t3->getVisitedCities()->get(1)); - $this->assertEquals($t1->getVisitedCities()->get(1)->getId(), $t3->getVisitedCities()->get(1)->getId()); - $this->assertEquals($t1->getVisitedCities()->get(1)->getName(), $t3->getVisitedCities()->get(1)->getName()); + self::assertNotSame($t1->getVisitedCities()->get(1), $t3->getVisitedCities()->get(1)); + self::assertEquals($t1->getVisitedCities()->get(1)->getId(), $t3->getVisitedCities()->get(1)->getId()); + self::assertEquals($t1->getVisitedCities()->get(1)->getName(), $t3->getVisitedCities()->get(1)->getName()); - $this->assertNotSame($t1->getVisitedCities()->get(2), $t3->getVisitedCities()->get(2)); - $this->assertEquals($t1->getVisitedCities()->get(2)->getId(), $t3->getVisitedCities()->get(2)->getId()); - $this->assertEquals($t1->getVisitedCities()->get(2)->getName(), $t3->getVisitedCities()->get(2)->getName()); + self::assertNotSame($t1->getVisitedCities()->get(2), $t3->getVisitedCities()->get(2)); + self::assertEquals($t1->getVisitedCities()->get(2)->getId(), $t3->getVisitedCities()->get(2)->getId()); + self::assertEquals($t1->getVisitedCities()->get(2)->getName(), $t3->getVisitedCities()->get(2)->getName()); - $this->assertNotSame($t2->getVisitedCities()->get(0), $t4->getVisitedCities()->get(0)); - $this->assertEquals($t2->getVisitedCities()->get(0)->getId(), $t4->getVisitedCities()->get(0)->getId()); - $this->assertEquals($t2->getVisitedCities()->get(0)->getName(), $t4->getVisitedCities()->get(0)->getName()); + self::assertNotSame($t2->getVisitedCities()->get(0), $t4->getVisitedCities()->get(0)); + self::assertEquals($t2->getVisitedCities()->get(0)->getId(), $t4->getVisitedCities()->get(0)->getId()); + self::assertEquals($t2->getVisitedCities()->get(0)->getName(), $t4->getVisitedCities()->get(0)->getName()); - $this->assertNotSame($t2->getVisitedCities()->get(1), $t4->getVisitedCities()->get(1)); - $this->assertEquals($t2->getVisitedCities()->get(1)->getId(), $t4->getVisitedCities()->get(1)->getId()); - $this->assertEquals($t2->getVisitedCities()->get(1)->getName(), $t4->getVisitedCities()->get(1)->getName()); + self::assertNotSame($t2->getVisitedCities()->get(1), $t4->getVisitedCities()->get(1)); + self::assertEquals($t2->getVisitedCities()->get(1)->getId(), $t4->getVisitedCities()->get(1)->getId()); + self::assertEquals($t2->getVisitedCities()->get(1)->getName(), $t4->getVisitedCities()->get(1)->getName()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testStoreManyToManyAssociationWhitCascade(): void @@ -174,19 +174,19 @@ public function testStoreManyToManyAssociationWhitCascade(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Travel::class, $travel->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $traveler->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $travel->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $travel->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $traveler->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $travel->getId())); $queryCount1 = $this->getCurrentQueryCount(); $t1 = $this->_em->find(Travel::class, $travel->getId()); - $this->assertInstanceOf(Travel::class, $t1); - $this->assertCount(3, $t1->getVisitedCities()); - $this->assertEquals($queryCount1, $this->getCurrentQueryCount()); + self::assertInstanceOf(Travel::class, $t1); + self::assertCount(3, $t1->getVisitedCities()); + self::assertEquals($queryCount1, $this->getCurrentQueryCount()); } public function testReadOnlyCollection(): void @@ -204,12 +204,12 @@ public function testReadOnlyCollection(): void $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); - $this->assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); + self::assertTrue($this->cache->containsEntity(Travel::class, $this->travels[0]->getId())); + self::assertTrue($this->cache->containsCollection(Travel::class, 'visitedCities', $this->travels[0]->getId())); $travel = $this->_em->find(Travel::class, $this->travels[0]->getId()); - $this->assertCount(3, $travel->getVisitedCities()); + self::assertCount(3, $travel->getVisitedCities()); $travel->getVisitedCities()->remove(0); @@ -233,15 +233,15 @@ public function testManyToManyWithEmptyRelation(): void $entitiId = $this->travels[2]->getId(); //empty travel $entity = $this->_em->find(Travel::class, $entitiId); - $this->assertEquals(0, $entity->getVisitedCities()->count()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(0, $entity->getVisitedCities()->count()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->_em->clear(); $entity = $this->_em->find(Travel::class, $entitiId); $queryCount = $this->getCurrentQueryCount(); - $this->assertEquals(0, $entity->getVisitedCities()->count()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(0, $entity->getVisitedCities()->count()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php index 3a0aec32660..0424dcc2d9e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php @@ -23,10 +23,10 @@ public function testPutOnPersist(): void $this->loadFixturesStates(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); } public function testPutAndLoadManyToOneRelation(): void @@ -38,37 +38,37 @@ public function testPutAndLoadManyToOneRelation(): void $this->cache->evictEntityRegion(State::class); $this->cache->evictEntityRegion(Country::class); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); $c1 = $this->_em->find(State::class, $this->states[0]->getId()); $c2 = $this->_em->find(State::class, $this->states[1]->getId()); //trigger lazy load - $this->assertNotNull($c1->getCountry()->getName()); - $this->assertNotNull($c2->getCountry()->getName()); + self::assertNotNull($c1->getCountry()->getName()); + self::assertNotNull($c2->getCountry()->getName()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertInstanceOf(State::class, $c1); - $this->assertInstanceOf(State::class, $c2); - $this->assertInstanceOf(Country::class, $c1->getCountry()); - $this->assertInstanceOf(Country::class, $c2->getCountry()); + self::assertInstanceOf(State::class, $c1); + self::assertInstanceOf(State::class, $c2); + self::assertInstanceOf(Country::class, $c1->getCountry()); + self::assertInstanceOf(Country::class, $c2->getCountry()); - $this->assertEquals($this->states[0]->getId(), $c1->getId()); - $this->assertEquals($this->states[0]->getName(), $c1->getName()); - $this->assertEquals($this->states[0]->getCountry()->getId(), $c1->getCountry()->getId()); - $this->assertEquals($this->states[0]->getCountry()->getName(), $c1->getCountry()->getName()); + self::assertEquals($this->states[0]->getId(), $c1->getId()); + self::assertEquals($this->states[0]->getName(), $c1->getName()); + self::assertEquals($this->states[0]->getCountry()->getId(), $c1->getCountry()->getId()); + self::assertEquals($this->states[0]->getCountry()->getName(), $c1->getCountry()->getName()); - $this->assertEquals($this->states[1]->getId(), $c2->getId()); - $this->assertEquals($this->states[1]->getName(), $c2->getName()); - $this->assertEquals($this->states[1]->getCountry()->getId(), $c2->getCountry()->getId()); - $this->assertEquals($this->states[1]->getCountry()->getName(), $c2->getCountry()->getName()); + self::assertEquals($this->states[1]->getId(), $c2->getId()); + self::assertEquals($this->states[1]->getName(), $c2->getName()); + self::assertEquals($this->states[1]->getCountry()->getId(), $c2->getCountry()->getId()); + self::assertEquals($this->states[1]->getCountry()->getName(), $c2->getCountry()->getName()); $this->_em->clear(); @@ -77,28 +77,28 @@ public function testPutAndLoadManyToOneRelation(): void $c3 = $this->_em->find(State::class, $this->states[0]->getId()); $c4 = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); //trigger lazy load from cache - $this->assertNotNull($c3->getCountry()->getName()); - $this->assertNotNull($c4->getCountry()->getName()); + self::assertNotNull($c3->getCountry()->getName()); + self::assertNotNull($c4->getCountry()->getName()); - $this->assertInstanceOf(State::class, $c3); - $this->assertInstanceOf(State::class, $c4); - $this->assertInstanceOf(Country::class, $c3->getCountry()); - $this->assertInstanceOf(Country::class, $c4->getCountry()); + self::assertInstanceOf(State::class, $c3); + self::assertInstanceOf(State::class, $c4); + self::assertInstanceOf(Country::class, $c3->getCountry()); + self::assertInstanceOf(Country::class, $c4->getCountry()); - $this->assertEquals($c1->getId(), $c3->getId()); - $this->assertEquals($c1->getName(), $c3->getName()); + self::assertEquals($c1->getId(), $c3->getId()); + self::assertEquals($c1->getName(), $c3->getName()); - $this->assertEquals($c2->getId(), $c4->getId()); - $this->assertEquals($c2->getName(), $c4->getName()); + self::assertEquals($c2->getId(), $c4->getId()); + self::assertEquals($c2->getName(), $c4->getName()); - $this->assertEquals($this->states[0]->getCountry()->getId(), $c3->getCountry()->getId()); - $this->assertEquals($this->states[0]->getCountry()->getName(), $c3->getCountry()->getName()); + self::assertEquals($this->states[0]->getCountry()->getId(), $c3->getCountry()->getId()); + self::assertEquals($this->states[0]->getCountry()->getName(), $c3->getCountry()->getName()); - $this->assertEquals($this->states[1]->getCountry()->getId(), $c4->getCountry()->getId()); - $this->assertEquals($this->states[1]->getCountry()->getName(), $c4->getCountry()->getName()); + self::assertEquals($this->states[1]->getCountry()->getId(), $c4->getCountry()->getId()); + self::assertEquals($this->states[1]->getCountry()->getName(), $c4->getCountry()->getName()); } public function testInverseSidePutShouldEvictCollection(): void @@ -128,11 +128,11 @@ public function testInverseSidePutShouldEvictCollection(): void $queryCount = $this->getCurrentQueryCount(); // Association was cleared from EM - $this->assertNotEquals($prev, $state->getCities()); + self::assertNotEquals($prev, $state->getCities()); // New association has one more item (cache was evicted) - $this->assertEquals($count + 1, $state->getCities()->count()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($count + 1, $state->getCities()->count()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testShouldNotReloadWhenAssociationIsMissing(): void @@ -147,15 +147,15 @@ public function testShouldNotReloadWhenAssociationIsMissing(): void $countryId1 = $this->states[0]->getCountry()->getId(); $countryId2 = $this->states[3]->getCountry()->getId(); - $this->assertTrue($this->cache->containsEntity(Country::class, $countryId1)); - $this->assertTrue($this->cache->containsEntity(Country::class, $countryId2)); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId1)); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId2)); + self::assertTrue($this->cache->containsEntity(Country::class, $countryId1)); + self::assertTrue($this->cache->containsEntity(Country::class, $countryId2)); + self::assertTrue($this->cache->containsEntity(State::class, $stateId1)); + self::assertTrue($this->cache->containsEntity(State::class, $stateId2)); $this->cache->evictEntityRegion(Country::class); - $this->assertFalse($this->cache->containsEntity(Country::class, $countryId1)); - $this->assertFalse($this->cache->containsEntity(Country::class, $countryId2)); + self::assertFalse($this->cache->containsEntity(Country::class, $countryId1)); + self::assertFalse($this->cache->containsEntity(Country::class, $countryId2)); $this->_em->clear(); @@ -164,27 +164,27 @@ public function testShouldNotReloadWhenAssociationIsMissing(): void $state1 = $this->_em->find(State::class, $stateId1); $state2 = $this->_em->find(State::class, $stateId2); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state1); - $this->assertInstanceOf(State::class, $state2); - $this->assertInstanceOf(Country::class, $state1->getCountry()); - $this->assertInstanceOf(Country::class, $state2->getCountry()); + self::assertInstanceOf(State::class, $state1); + self::assertInstanceOf(State::class, $state2); + self::assertInstanceOf(Country::class, $state1->getCountry()); + self::assertInstanceOf(Country::class, $state2->getCountry()); $queryCount = $this->getCurrentQueryCount(); - $this->assertNotNull($state1->getCountry()->getName()); - $this->assertNotNull($state2->getCountry()->getName()); - $this->assertEquals($countryId1, $state1->getCountry()->getId()); - $this->assertEquals($countryId2, $state2->getCountry()->getId()); + self::assertNotNull($state1->getCountry()->getName()); + self::assertNotNull($state2->getCountry()->getName()); + self::assertEquals($countryId1, $state1->getCountry()->getId()); + self::assertEquals($countryId2, $state2->getCountry()->getId()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testPutAndLoadNonCacheableManyToOne(): void { - $this->assertNull($this->cache->getEntityCacheRegion(Action::class)); - $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); + self::assertNull($this->cache->getEntityCacheRegion(Action::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); $token = new Token('token-hash'); $action = new Action('exec'); @@ -195,26 +195,26 @@ public function testPutAndLoadNonCacheableManyToOne(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Token::class, $token->token)); - $this->assertFalse($this->cache->containsEntity(Token::class, $action->name)); + self::assertTrue($this->cache->containsEntity(Token::class, $token->token)); + self::assertFalse($this->cache->containsEntity(Token::class, $action->name)); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(Token::class, $token->token); - $this->assertInstanceOf(Token::class, $entity); - $this->assertEquals('token-hash', $entity->token); + self::assertInstanceOf(Token::class, $entity); + self::assertEquals('token-hash', $entity->token); - $this->assertInstanceOf(Action::class, $entity->getAction()); - $this->assertEquals('exec', $entity->getAction()->name); + self::assertInstanceOf(Action::class, $entity->getAction()); + self::assertEquals('exec', $entity->getAction()->name); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testPutAndLoadNonCacheableCompositeManyToOne(): void { - $this->assertNull($this->cache->getEntityCacheRegion(Action::class)); - $this->assertNull($this->cache->getEntityCacheRegion(ComplexAction::class)); - $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); + self::assertNull($this->cache->getEntityCacheRegion(Action::class)); + self::assertNull($this->cache->getEntityCacheRegion(ComplexAction::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); $token = new Token('token-hash'); @@ -233,10 +233,10 @@ public function testPutAndLoadNonCacheableCompositeManyToOne(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Token::class, $token->token)); - $this->assertFalse($this->cache->containsEntity(Action::class, $action1->name)); - $this->assertFalse($this->cache->containsEntity(Action::class, $action2->name)); - $this->assertFalse($this->cache->containsEntity(Action::class, $action3->name)); + self::assertTrue($this->cache->containsEntity(Token::class, $token->token)); + self::assertFalse($this->cache->containsEntity(Action::class, $action1->name)); + self::assertFalse($this->cache->containsEntity(Action::class, $action2->name)); + self::assertFalse($this->cache->containsEntity(Action::class, $action3->name)); $queryCount = $this->getCurrentQueryCount(); /** @@ -244,22 +244,22 @@ public function testPutAndLoadNonCacheableCompositeManyToOne(): void */ $entity = $this->_em->find(Token::class, $token->token); - $this->assertInstanceOf(Token::class, $entity); - $this->assertEquals('token-hash', $entity->token); + self::assertInstanceOf(Token::class, $entity); + self::assertEquals('token-hash', $entity->token); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Action::class, $entity->getAction()); - $this->assertInstanceOf(ComplexAction::class, $entity->getComplexAction()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(Action::class, $entity->getAction()); + self::assertInstanceOf(ComplexAction::class, $entity->getComplexAction()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Action::class, $entity->getComplexAction()->getAction1()); - $this->assertInstanceOf(Action::class, $entity->getComplexAction()->getAction2()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(Action::class, $entity->getComplexAction()->getAction1()); + self::assertInstanceOf(Action::class, $entity->getComplexAction()->getAction2()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals('login', $entity->getComplexAction()->getAction1()->name); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals('rememberme', $entity->getComplexAction()->getAction2()->name); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals('login', $entity->getComplexAction()->getAction1()->name); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals('rememberme', $entity->getComplexAction()->getAction2()->name); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php index 732d17b99ba..f5cf5b5fefd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php @@ -27,10 +27,10 @@ public function testShouldPutCollectionInverseSideOnPersist(): void $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); } public function testPutAndLoadOneToManyRelation(): void @@ -45,50 +45,50 @@ public function testPutAndLoadOneToManyRelation(): void $this->cache->evictEntityRegion(City::class); $this->cache->evictCollectionRegion(State::class, 'cities'); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId())); $s1 = $this->_em->find(State::class, $this->states[0]->getId()); $s2 = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); //trigger lazy load - $this->assertCount(2, $s1->getCities()); - $this->assertCount(2, $s2->getCities()); + self::assertCount(2, $s1->getCities()); + self::assertCount(2, $s2->getCities()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(4, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertInstanceOf(City::class, $s1->getCities()->get(0)); - $this->assertInstanceOf(City::class, $s1->getCities()->get(1)); + self::assertInstanceOf(City::class, $s1->getCities()->get(0)); + self::assertInstanceOf(City::class, $s1->getCities()->get(1)); - $this->assertInstanceOf(City::class, $s2->getCities()->get(0)); - $this->assertInstanceOf(City::class, $s2->getCities()->get(1)); + self::assertInstanceOf(City::class, $s2->getCities()->get(0)); + self::assertInstanceOf(City::class, $s2->getCities()->get(1)); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(0)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[1]->getCities()->get(1)->getId())); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -99,36 +99,36 @@ public function testPutAndLoadOneToManyRelation(): void $s4 = $this->_em->find(State::class, $this->states[1]->getId()); //trigger lazy load from cache - $this->assertCount(2, $s3->getCities()); - $this->assertCount(2, $s4->getCities()); + self::assertCount(2, $s3->getCities()); + self::assertCount(2, $s4->getCities()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertInstanceOf(City::class, $s3->getCities()->get(0)); - $this->assertInstanceOf(City::class, $s3->getCities()->get(1)); - $this->assertInstanceOf(City::class, $s4->getCities()->get(0)); - $this->assertInstanceOf(City::class, $s4->getCities()->get(1)); + self::assertInstanceOf(City::class, $s3->getCities()->get(0)); + self::assertInstanceOf(City::class, $s3->getCities()->get(1)); + self::assertInstanceOf(City::class, $s4->getCities()->get(0)); + self::assertInstanceOf(City::class, $s4->getCities()->get(1)); - $this->assertNotSame($s1->getCities()->get(0), $s3->getCities()->get(0)); - $this->assertEquals($s1->getCities()->get(0)->getId(), $s3->getCities()->get(0)->getId()); - $this->assertEquals($s1->getCities()->get(0)->getName(), $s3->getCities()->get(0)->getName()); + self::assertNotSame($s1->getCities()->get(0), $s3->getCities()->get(0)); + self::assertEquals($s1->getCities()->get(0)->getId(), $s3->getCities()->get(0)->getId()); + self::assertEquals($s1->getCities()->get(0)->getName(), $s3->getCities()->get(0)->getName()); - $this->assertNotSame($s1->getCities()->get(1), $s3->getCities()->get(1)); - $this->assertEquals($s1->getCities()->get(1)->getId(), $s3->getCities()->get(1)->getId()); - $this->assertEquals($s1->getCities()->get(1)->getName(), $s3->getCities()->get(1)->getName()); + self::assertNotSame($s1->getCities()->get(1), $s3->getCities()->get(1)); + self::assertEquals($s1->getCities()->get(1)->getId(), $s3->getCities()->get(1)->getId()); + self::assertEquals($s1->getCities()->get(1)->getName(), $s3->getCities()->get(1)->getName()); - $this->assertNotSame($s2->getCities()->get(0), $s4->getCities()->get(0)); - $this->assertEquals($s2->getCities()->get(0)->getId(), $s4->getCities()->get(0)->getId()); - $this->assertEquals($s2->getCities()->get(0)->getName(), $s4->getCities()->get(0)->getName()); + self::assertNotSame($s2->getCities()->get(0), $s4->getCities()->get(0)); + self::assertEquals($s2->getCities()->get(0)->getId(), $s4->getCities()->get(0)->getId()); + self::assertEquals($s2->getCities()->get(0)->getName(), $s4->getCities()->get(0)->getName()); - $this->assertNotSame($s2->getCities()->get(1), $s4->getCities()->get(1)); - $this->assertEquals($s2->getCities()->get(1)->getId(), $s4->getCities()->get(1)->getId()); - $this->assertEquals($s2->getCities()->get(1)->getName(), $s4->getCities()->get(1)->getName()); + self::assertNotSame($s2->getCities()->get(1), $s4->getCities()->get(1)); + self::assertEquals($s2->getCities()->get(1)->getId(), $s4->getCities()->get(1)->getId()); + self::assertEquals($s2->getCities()->get(1)->getName(), $s4->getCities()->get(1)->getName()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(4, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testLoadOneToManyCollectionFromDatabaseWhenEntityMissing(): void @@ -139,12 +139,12 @@ public function testLoadOneToManyCollectionFromDatabaseWhenEntityMissing(): void $this->_em->clear(); //trigger lazy load from database - $this->assertCount(2, $this->_em->find(State::class, $this->states[0]->getId())->getCities()); + self::assertCount(2, $this->_em->find(State::class, $this->states[0]->getId())->getCities()); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); $queryCount = $this->getCurrentQueryCount(); $stateId = $this->states[0]->getId(); @@ -152,23 +152,23 @@ public function testLoadOneToManyCollectionFromDatabaseWhenEntityMissing(): void $cityId = $this->states[0]->getCities()->get(1)->getId(); //trigger lazy load from cache - $this->assertCount(2, $state->getCities()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(City::class, $cityId)); + self::assertCount(2, $state->getCities()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertTrue($this->cache->containsEntity(City::class, $cityId)); $this->cache->evictEntity(City::class, $cityId); - $this->assertFalse($this->cache->containsEntity(City::class, $cityId)); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId)); - $this->assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId)); + self::assertFalse($this->cache->containsEntity(City::class, $cityId)); + self::assertTrue($this->cache->containsEntity(State::class, $stateId)); + self::assertTrue($this->cache->containsCollection(State::class, 'cities', $stateId)); $this->_em->clear(); $state = $this->_em->find(State::class, $stateId); //trigger lazy load from database - $this->assertCount(2, $state->getCities()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $state->getCities()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testShoudNotPutOneToManyRelationOnPersist(): void @@ -182,8 +182,8 @@ public function testShoudNotPutOneToManyRelationOnPersist(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(State::class, $state->getId())); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $state->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $state->getId())); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $state->getId())); } public function testOneToManyRemove(): void @@ -199,28 +199,28 @@ public function testOneToManyRemove(): void $this->cache->evictEntityRegion(City::class); $this->cache->evictCollectionRegion(State::class, 'cities'); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); - $this->assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertFalse($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(0)->getId())); + self::assertFalse($this->cache->containsEntity(City::class, $this->states[0]->getCities()->get(1)->getId())); $entity = $this->_em->find(State::class, $this->states[0]->getId()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getEntityRegion(State::class))); //trigger lazy load - $this->assertCount(2, $entity->getCities()); + self::assertCount(2, $entity->getCities()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertInstanceOf(City::class, $entity->getCities()->get(0)); - $this->assertInstanceOf(City::class, $entity->getCities()->get(1)); + self::assertInstanceOf(City::class, $entity->getCities()->get(0)); + self::assertInstanceOf(City::class, $entity->getCities()->get(1)); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -229,23 +229,23 @@ public function testOneToManyRemove(): void $state = $this->_em->find(State::class, $this->states[0]->getId()); //trigger lazy load from cache - $this->assertCount(2, $state->getCities()); + self::assertCount(2, $state->getCities()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); $city0 = $state->getCities()->get(0); $city1 = $state->getCities()->get(1); - $this->assertInstanceOf(City::class, $city0); - $this->assertInstanceOf(City::class, $city1); + self::assertInstanceOf(City::class, $city0); + self::assertInstanceOf(City::class, $city1); - $this->assertEquals($entity->getCities()->get(0)->getName(), $city0->getName()); - $this->assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); + self::assertEquals($entity->getCities()->get(0)->getName(), $city0->getName()); + self::assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $state->getCities()->removeElement($city0); @@ -260,17 +260,17 @@ public function testOneToManyRemove(): void $state = $this->_em->find(State::class, $this->states[0]->getId()); //trigger lazy load from cache - $this->assertCount(1, $state->getCities()); + self::assertCount(1, $state->getCities()); $city1 = $state->getCities()->get(0); - $this->assertInstanceOf(City::class, $city1); - $this->assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); + self::assertInstanceOf(City::class, $city1); + self::assertEquals($entity->getCities()->get(1)->getName(), $city1->getName()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $state->getCities()->remove(0); @@ -284,11 +284,11 @@ public function testOneToManyRemove(): void $queryCount = $this->getCurrentQueryCount(); $state = $this->_em->find(State::class, $this->states[0]->getId()); - $this->assertCount(0, $state->getCities()); + self::assertCount(0, $state->getCities()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getCollectionRegion(State::class, 'cities'))); } public function testOneToManyWithEmptyRelation(): void @@ -307,16 +307,16 @@ public function testOneToManyWithEmptyRelation(): void $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(State::class, $entitiId); - $this->assertEquals(0, $entity->getCities()->count()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(0, $entity->getCities()->count()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->_em->clear(); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(State::class, $entitiId); - $this->assertEquals(0, $entity->getCities()->count()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(0, $entity->getCities()->count()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testOneToManyCount(): void @@ -335,16 +335,16 @@ public function testOneToManyCount(): void $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(State::class, $entityId); - $this->assertEquals(2, $entity->getCities()->count()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(2, $entity->getCities()->count()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->_em->clear(); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(State::class, $entityId); - $this->assertEquals(2, $entity->getCities()->count()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(2, $entity->getCities()->count()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testCacheInitializeCollectionWithNewObjects(): void @@ -363,22 +363,22 @@ public function testCacheInitializeCollectionWithNewObjects(): void $this->_em->flush(); $this->_em->clear(); - $this->assertCount(3, $traveler->getTravels()); + self::assertCount(3, $traveler->getTravels()); $travelerId = $traveler->getId(); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(Traveler::class, $travelerId); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertFalse($entity->getTravels()->isInitialized()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertFalse($entity->getTravels()->isInitialized()); $newItem = new Travel($entity); $entity->getTravels()->add($newItem); - $this->assertFalse($entity->getTravels()->isInitialized()); - $this->assertCount(4, $entity->getTravels()); - $this->assertTrue($entity->getTravels()->isInitialized()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertFalse($entity->getTravels()->isInitialized()); + self::assertCount(4, $entity->getTravels()); + self::assertTrue($entity->getTravels()->isInitialized()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); $this->_em->flush(); $this->_em->clear(); @@ -389,13 +389,13 @@ public function testCacheInitializeCollectionWithNewObjects(): void ); $result = $this->_em->createQuery($query)->getSingleResult(); - $this->assertEquals(4, $result->getTravels()->count()); + self::assertEquals(4, $result->getTravels()->count()); } public function testPutAndLoadNonCacheableOneToMany(): void { - $this->assertNull($this->cache->getEntityCacheRegion(Login::class)); - $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); + self::assertNull($this->cache->getEntityCacheRegion(Login::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); $l1 = new Login('session1'); $l2 = new Login('session2'); @@ -407,17 +407,17 @@ public function testPutAndLoadNonCacheableOneToMany(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Token::class, $token->token)); + self::assertTrue($this->cache->containsEntity(Token::class, $token->token)); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(Token::class, $token->token); - $this->assertInstanceOf(Token::class, $entity); - $this->assertEquals('token-hash', $entity->token); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(Token::class, $entity); + self::assertEquals('token-hash', $entity->token); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertCount(2, $entity->logins); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $entity->logins); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php index 68d270f99a7..7d177d4385b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php @@ -30,10 +30,10 @@ public function testPutOneToOneOnUnidirectionalPersist(): void $entity1 = $this->travelersWithProfile[0]; $entity2 = $this->travelersWithProfile[1]; - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); } public function testPutOneToOneOnBidirectionalPersist(): void @@ -49,12 +49,12 @@ public function testPutOneToOneOnBidirectionalPersist(): void $entity1 = $this->travelersWithProfile[0]; $entity2 = $this->travelersWithProfile[1]; - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getProfile()->getInfo()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getProfile()->getInfo()->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getProfile()->getInfo()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getProfile()->getInfo()->getId())); } public function testPutAndLoadOneToOneUnidirectionalRelation(): void @@ -73,40 +73,40 @@ public function testPutAndLoadOneToOneUnidirectionalRelation(): void $entity1 = $this->travelersWithProfile[0]; $entity2 = $this->travelersWithProfile[1]; - $this->assertFalse($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertFalse($this->cache->containsEntity(Traveler::class, $entity2->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); + self::assertFalse($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertFalse($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); $t1 = $this->_em->find(Traveler::class, $entity1->getId()); $t2 = $this->_em->find(Traveler::class, $entity2->getId()); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); // The inverse side its not cached - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getProfile()->getId())); - $this->assertInstanceOf(Traveler::class, $t1); - $this->assertInstanceOf(Traveler::class, $t2); - $this->assertInstanceOf(TravelerProfile::class, $t1->getProfile()); - $this->assertInstanceOf(TravelerProfile::class, $t2->getProfile()); + self::assertInstanceOf(Traveler::class, $t1); + self::assertInstanceOf(Traveler::class, $t2); + self::assertInstanceOf(TravelerProfile::class, $t1->getProfile()); + self::assertInstanceOf(TravelerProfile::class, $t2->getProfile()); - $this->assertEquals($entity1->getId(), $t1->getId()); - $this->assertEquals($entity1->getName(), $t1->getName()); - $this->assertEquals($entity1->getProfile()->getId(), $t1->getProfile()->getId()); - $this->assertEquals($entity1->getProfile()->getName(), $t1->getProfile()->getName()); + self::assertEquals($entity1->getId(), $t1->getId()); + self::assertEquals($entity1->getName(), $t1->getName()); + self::assertEquals($entity1->getProfile()->getId(), $t1->getProfile()->getId()); + self::assertEquals($entity1->getProfile()->getName(), $t1->getProfile()->getName()); - $this->assertEquals($entity2->getId(), $t2->getId()); - $this->assertEquals($entity2->getName(), $t2->getName()); - $this->assertEquals($entity2->getProfile()->getId(), $t2->getProfile()->getId()); - $this->assertEquals($entity2->getProfile()->getName(), $t2->getProfile()->getName()); + self::assertEquals($entity2->getId(), $t2->getId()); + self::assertEquals($entity2->getName(), $t2->getName()); + self::assertEquals($entity2->getProfile()->getId(), $t2->getProfile()->getId()); + self::assertEquals($entity2->getProfile()->getName(), $t2->getProfile()->getName()); // its all cached now - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(Traveler::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getProfile()->getId())); $this->_em->clear(); @@ -115,18 +115,18 @@ public function testPutAndLoadOneToOneUnidirectionalRelation(): void $t3 = $this->_em->find(Traveler::class, $entity1->getId()); $t4 = $this->_em->find(Traveler::class, $entity2->getId()); - $this->assertInstanceOf(Traveler::class, $t3); - $this->assertInstanceOf(Traveler::class, $t4); - $this->assertInstanceOf(TravelerProfile::class, $t3->getProfile()); - $this->assertInstanceOf(TravelerProfile::class, $t4->getProfile()); + self::assertInstanceOf(Traveler::class, $t3); + self::assertInstanceOf(Traveler::class, $t4); + self::assertInstanceOf(TravelerProfile::class, $t3->getProfile()); + self::assertInstanceOf(TravelerProfile::class, $t4->getProfile()); - $this->assertEquals($entity1->getProfile()->getId(), $t3->getProfile()->getId()); - $this->assertEquals($entity2->getProfile()->getId(), $t4->getProfile()->getId()); + self::assertEquals($entity1->getProfile()->getId(), $t3->getProfile()->getId()); + self::assertEquals($entity2->getProfile()->getId(), $t4->getProfile()->getId()); - $this->assertEquals($entity1->getProfile()->getName(), $t3->getProfile()->getName()); - $this->assertEquals($entity2->getProfile()->getName(), $t4->getProfile()->getName()); + self::assertEquals($entity1->getProfile()->getName(), $t3->getProfile()->getName()); + self::assertEquals($entity2->getProfile()->getName(), $t4->getProfile()->getName()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testPutAndLoadOneToOneBidirectionalRelation(): void @@ -146,28 +146,28 @@ public function testPutAndLoadOneToOneBidirectionalRelation(): void $entity1 = $this->travelersWithProfile[0]->getProfile(); $entity2 = $this->travelersWithProfile[1]->getProfile(); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId())); - $this->assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity1->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfile::class, $entity2->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId())); + self::assertFalse($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId())); $p1 = $this->_em->find(TravelerProfile::class, $entity1->getId()); $p2 = $this->_em->find(TravelerProfile::class, $entity2->getId()); - $this->assertEquals($entity1->getId(), $p1->getId()); - $this->assertEquals($entity1->getName(), $p1->getName()); - $this->assertEquals($entity1->getInfo()->getId(), $p1->getInfo()->getId()); - $this->assertEquals($entity1->getInfo()->getDescription(), $p1->getInfo()->getDescription()); + self::assertEquals($entity1->getId(), $p1->getId()); + self::assertEquals($entity1->getName(), $p1->getName()); + self::assertEquals($entity1->getInfo()->getId(), $p1->getInfo()->getId()); + self::assertEquals($entity1->getInfo()->getDescription(), $p1->getInfo()->getDescription()); - $this->assertEquals($entity2->getId(), $p2->getId()); - $this->assertEquals($entity2->getName(), $p2->getName()); - $this->assertEquals($entity2->getInfo()->getId(), $p2->getInfo()->getId()); - $this->assertEquals($entity2->getInfo()->getDescription(), $p2->getInfo()->getDescription()); + self::assertEquals($entity2->getId(), $p2->getId()); + self::assertEquals($entity2->getName(), $p2->getName()); + self::assertEquals($entity2->getInfo()->getId(), $p2->getInfo()->getId()); + self::assertEquals($entity2->getInfo()->getDescription(), $p2->getInfo()->getDescription()); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId())); - $this->assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity1->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfile::class, $entity2->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity1->getInfo()->getId())); + self::assertTrue($this->cache->containsEntity(TravelerProfileInfo::class, $entity2->getInfo()->getId())); $this->_em->clear(); @@ -176,22 +176,22 @@ public function testPutAndLoadOneToOneBidirectionalRelation(): void $p3 = $this->_em->find(TravelerProfile::class, $entity1->getId()); $p4 = $this->_em->find(TravelerProfile::class, $entity2->getId()); - $this->assertInstanceOf(TravelerProfile::class, $p3); - $this->assertInstanceOf(TravelerProfile::class, $p4); - $this->assertInstanceOf(TravelerProfileInfo::class, $p3->getInfo()); - $this->assertInstanceOf(TravelerProfileInfo::class, $p4->getInfo()); + self::assertInstanceOf(TravelerProfile::class, $p3); + self::assertInstanceOf(TravelerProfile::class, $p4); + self::assertInstanceOf(TravelerProfileInfo::class, $p3->getInfo()); + self::assertInstanceOf(TravelerProfileInfo::class, $p4->getInfo()); - $this->assertEquals($entity1->getId(), $p3->getId()); - $this->assertEquals($entity1->getName(), $p3->getName()); - $this->assertEquals($entity1->getInfo()->getId(), $p3->getInfo()->getId()); - $this->assertEquals($entity1->getInfo()->getDescription(), $p3->getInfo()->getDescription()); + self::assertEquals($entity1->getId(), $p3->getId()); + self::assertEquals($entity1->getName(), $p3->getName()); + self::assertEquals($entity1->getInfo()->getId(), $p3->getInfo()->getId()); + self::assertEquals($entity1->getInfo()->getDescription(), $p3->getInfo()->getDescription()); - $this->assertEquals($entity2->getId(), $p4->getId()); - $this->assertEquals($entity2->getName(), $p4->getName()); - $this->assertEquals($entity2->getInfo()->getId(), $p4->getInfo()->getId()); - $this->assertEquals($entity2->getInfo()->getDescription(), $p4->getInfo()->getDescription()); + self::assertEquals($entity2->getId(), $p4->getId()); + self::assertEquals($entity2->getName(), $p4->getName()); + self::assertEquals($entity2->getInfo()->getId(), $p4->getInfo()->getId()); + self::assertEquals($entity2->getInfo()->getDescription(), $p4->getInfo()->getDescription()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testInverseSidePutAndLoadOneToOneBidirectionalRelation(): void @@ -206,29 +206,29 @@ public function testInverseSidePutAndLoadOneToOneBidirectionalRelation(): void $entity1 = $this->addresses[0]->person; $entity2 = $this->addresses[1]->person; - $this->assertFalse($this->cache->containsEntity(Person::class, $entity1->id)); - $this->assertFalse($this->cache->containsEntity(Person::class, $entity2->id)); - $this->assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id)); - $this->assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id)); + self::assertFalse($this->cache->containsEntity(Person::class, $entity1->id)); + self::assertFalse($this->cache->containsEntity(Person::class, $entity2->id)); + self::assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id)); + self::assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id)); $p1 = $this->_em->find(Person::class, $entity1->id); $p2 = $this->_em->find(Person::class, $entity2->id); - $this->assertEquals($entity1->id, $p1->id); - $this->assertEquals($entity1->name, $p1->name); - $this->assertEquals($entity1->address->id, $p1->address->id); - $this->assertEquals($entity1->address->location, $p1->address->location); + self::assertEquals($entity1->id, $p1->id); + self::assertEquals($entity1->name, $p1->name); + self::assertEquals($entity1->address->id, $p1->address->id); + self::assertEquals($entity1->address->location, $p1->address->location); - $this->assertEquals($entity2->id, $p2->id); - $this->assertEquals($entity2->name, $p2->name); - $this->assertEquals($entity2->address->id, $p2->address->id); - $this->assertEquals($entity2->address->location, $p2->address->location); + self::assertEquals($entity2->id, $p2->id); + self::assertEquals($entity2->name, $p2->name); + self::assertEquals($entity2->address->id, $p2->address->id); + self::assertEquals($entity2->address->location, $p2->address->location); - $this->assertTrue($this->cache->containsEntity(Person::class, $entity1->id)); - $this->assertTrue($this->cache->containsEntity(Person::class, $entity2->id)); + self::assertTrue($this->cache->containsEntity(Person::class, $entity1->id)); + self::assertTrue($this->cache->containsEntity(Person::class, $entity2->id)); // The inverse side its not cached - $this->assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id)); - $this->assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id)); + self::assertFalse($this->cache->containsEntity(Address::class, $entity1->address->id)); + self::assertFalse($this->cache->containsEntity(Address::class, $entity2->address->id)); $this->_em->clear(); @@ -237,28 +237,28 @@ public function testInverseSidePutAndLoadOneToOneBidirectionalRelation(): void $p3 = $this->_em->find(Person::class, $entity1->id); $p4 = $this->_em->find(Person::class, $entity2->id); - $this->assertInstanceOf(Person::class, $p3); - $this->assertInstanceOf(Person::class, $p4); - $this->assertInstanceOf(Address::class, $p3->address); - $this->assertInstanceOf(Address::class, $p4->address); + self::assertInstanceOf(Person::class, $p3); + self::assertInstanceOf(Person::class, $p4); + self::assertInstanceOf(Address::class, $p3->address); + self::assertInstanceOf(Address::class, $p4->address); - $this->assertEquals($entity1->id, $p3->id); - $this->assertEquals($entity1->name, $p3->name); - $this->assertEquals($entity1->address->id, $p3->address->id); - $this->assertEquals($entity1->address->location, $p3->address->location); + self::assertEquals($entity1->id, $p3->id); + self::assertEquals($entity1->name, $p3->name); + self::assertEquals($entity1->address->id, $p3->address->id); + self::assertEquals($entity1->address->location, $p3->address->location); - $this->assertEquals($entity2->id, $p4->id); - $this->assertEquals($entity2->name, $p4->name); - $this->assertEquals($entity2->address->id, $p4->address->id); - $this->assertEquals($entity2->address->location, $p4->address->location); + self::assertEquals($entity2->id, $p4->id); + self::assertEquals($entity2->name, $p4->name); + self::assertEquals($entity2->address->id, $p4->address->id); + self::assertEquals($entity2->address->location, $p4->address->location); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testPutAndLoadNonCacheableOneToOne(): void { - $this->assertNull($this->cache->getEntityCacheRegion(Client::class)); - $this->assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); + self::assertNull($this->cache->getEntityCacheRegion(Client::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(Token::class)); $client = new Client('FabioBatSilva'); $token = new Token('token-hash', $client); @@ -270,17 +270,17 @@ public function testPutAndLoadNonCacheableOneToOne(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($this->cache->containsEntity(Token::class, $token->token)); - $this->assertFalse($this->cache->containsEntity(Client::class, $client->id)); + self::assertTrue($this->cache->containsEntity(Token::class, $token->token)); + self::assertFalse($this->cache->containsEntity(Client::class, $client->id)); $entity = $this->_em->find(Token::class, $token->token); - $this->assertInstanceOf(Token::class, $entity); - $this->assertInstanceOf(Client::class, $entity->getClient()); - $this->assertEquals('token-hash', $entity->token); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(Token::class, $entity); + self::assertInstanceOf(Client::class, $entity->getClient()); + self::assertEquals('token-hash', $entity->token); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertEquals('FabioBatSilva', $entity->getClient()->name); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals('FabioBatSilva', $entity->getClient()->name); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 970eefb8b93..6a320330467 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -32,24 +32,24 @@ public function testBasicQueryCache(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $result1 = $this->_em->createQuery($dql)->setCacheable(true)->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[1]->getId(), $result1[1]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->_em->clear(); @@ -57,33 +57,33 @@ public function testBasicQueryCache(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(2, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertInstanceOf(Country::class, $result2[0]); - $this->assertInstanceOf(Country::class, $result2[1]); + self::assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[1]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[1]->getId(), $result2[1]->getId()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[1]->getId(), $result2[1]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } public function testQueryCacheModeGet(): void @@ -95,8 +95,8 @@ public function testQueryCacheModeGet(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; @@ -105,25 +105,25 @@ public function testQueryCacheModeGet(): void ->setCacheable(true); // MODE_GET should never add items to the cache. - $this->assertCount(2, $queryGet->getResult()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $queryGet->getResult()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(2, $queryGet->getResult()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(2, $queryGet->getResult()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $result = $this->_em->createQuery($dql) ->setCacheable(true) ->getResult(); - $this->assertCount(2, $result); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertCount(2, $result); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); // MODE_GET should read items if exists. - $this->assertCount(2, $queryGet->getResult()); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertCount(2, $queryGet->getResult()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); } public function testQueryCacheModePut(): void @@ -135,8 +135,8 @@ public function testQueryCacheModePut(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; @@ -144,26 +144,26 @@ public function testQueryCacheModePut(): void ->setCacheable(true) ->getResult(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertCount(2, $result); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryPut = $this->_em->createQuery($dql) ->setCacheMode(Cache::MODE_PUT) ->setCacheable(true); // MODE_PUT should never read itens from cache. - $this->assertCount(2, $queryPut->getResult()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - - $this->assertCount(2, $queryPut->getResult()); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertCount(2, $queryPut->getResult()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + + self::assertCount(2, $queryPut->getResult()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } public function testQueryCacheModeRefresh(): void @@ -175,8 +175,8 @@ public function testQueryCacheModeRefresh(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $region = $this->cache->getEntityCacheRegion(Country::class); $queryCount = $this->getCurrentQueryCount(); @@ -185,11 +185,11 @@ public function testQueryCacheModeRefresh(): void ->setCacheable(true) ->getResult(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertCount(2, $result); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $countryId1 = $this->countries[0]->getId(); $countryId2 = $this->countries[1]->getId(); @@ -211,18 +211,18 @@ public function testQueryCacheModeRefresh(): void // MODE_REFRESH should never read itens from cache. $result1 = $queryRefresh->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($countryName1, $result1[0]->getName()); - $this->assertEquals($countryName2, $result1[1]->getName()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(2, $result1); + self::assertEquals($countryName1, $result1[0]->getName()); + self::assertEquals($countryName2, $result1[1]->getName()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); $this->_em->clear(); $result2 = $queryRefresh->getResult(); - $this->assertCount(2, $result2); - $this->assertEquals($countryName1, $result2[0]->getName()); - $this->assertEquals($countryName2, $result2[1]->getName()); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); + self::assertEquals($countryName1, $result2[0]->getName()); + self::assertEquals($countryName2, $result2[1]->getName()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); } public function testBasicQueryCachePutEntityCache(): void @@ -238,21 +238,21 @@ public function testBasicQueryCachePutEntityCache(): void $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $result1 = $this->_em->createQuery($dql)->setCacheable(true)->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[1]->getId(), $result1[1]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); $this->_em->clear(); @@ -260,33 +260,33 @@ public function testBasicQueryCachePutEntityCache(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(2, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertInstanceOf(Country::class, $result2[0]); - $this->assertInstanceOf(Country::class, $result2[1]); + self::assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[1]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[1]->getId(), $result2[1]->getId()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[1]->getId(), $result2[1]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } /** @@ -314,37 +314,37 @@ public function testMultipleNestedDQLAliases(): void ->setCacheable(true) ->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[1]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[2]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $this->cities[3]->getId())); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[1]->getId())); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[2]->getId())); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[3]->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[0]->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[1]->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[2]->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $this->attractions[3]->getId())); - $this->assertInstanceOf(State::class, $result1[0]); - $this->assertInstanceOf(State::class, $result1[1]); + self::assertInstanceOf(State::class, $result1[0]); + self::assertInstanceOf(State::class, $result1[1]); - $this->assertCount(2, $result1[0]->getCities()); - $this->assertCount(2, $result1[1]->getCities()); + self::assertCount(2, $result1[0]->getCities()); + self::assertCount(2, $result1[1]->getCities()); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); - $this->assertCount(2, $result1[0]->getCities()->get(0)->getAttractions()); - $this->assertCount(2, $result1[0]->getCities()->get(1)->getAttractions()); - $this->assertCount(2, $result1[1]->getCities()->get(0)->getAttractions()); - $this->assertCount(1, $result1[1]->getCities()->get(1)->getAttractions()); + self::assertCount(2, $result1[0]->getCities()->get(0)->getAttractions()); + self::assertCount(2, $result1[0]->getCities()->get(1)->getAttractions()); + self::assertCount(2, $result1[1]->getCities()->get(0)->getAttractions()); + self::assertCount(1, $result1[1]->getCities()->get(1)->getAttractions()); $this->_em->clear(); @@ -352,24 +352,24 @@ public function testMultipleNestedDQLAliases(): void ->setCacheable(true) ->getResult(); - $this->assertCount(2, $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $result2[0]); - $this->assertInstanceOf(State::class, $result2[1]); + self::assertInstanceOf(State::class, $result2[0]); + self::assertInstanceOf(State::class, $result2[1]); - $this->assertCount(2, $result2[0]->getCities()); - $this->assertCount(2, $result2[1]->getCities()); + self::assertCount(2, $result2[0]->getCities()); + self::assertCount(2, $result2[1]->getCities()); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); - $this->assertCount(2, $result2[0]->getCities()->get(0)->getAttractions()); - $this->assertCount(2, $result2[0]->getCities()->get(1)->getAttractions()); - $this->assertCount(2, $result2[1]->getCities()->get(0)->getAttractions()); - $this->assertCount(1, $result2[1]->getCities()->get(1)->getAttractions()); + self::assertCount(2, $result2[0]->getCities()->get(0)->getAttractions()); + self::assertCount(2, $result2[0]->getCities()->get(1)->getAttractions()); + self::assertCount(2, $result2[1]->getCities()->get(0)->getAttractions()); + self::assertCount(1, $result2[1]->getCities()->get(1)->getAttractions()); } public function testBasicQueryParams(): void @@ -379,8 +379,8 @@ public function testBasicQueryParams(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $name = $this->countries[0]->getName(); @@ -390,9 +390,9 @@ public function testBasicQueryParams(): void ->setParameter('name', $name) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); $this->_em->clear(); @@ -400,13 +400,13 @@ public function testBasicQueryParams(): void ->setParameter('name', $name) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(1, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(1, $result2); - $this->assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[0]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); } public function testLoadFromDatabaseWhenEntityMissing(): void @@ -416,27 +416,27 @@ public function testLoadFromDatabaseWhenEntityMissing(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $dql = 'SELECT c FROM Doctrine\Tests\Models\Cache\Country c'; $result1 = $this->_em->createQuery($dql)->setCacheable(true)->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[1]->getId(), $result1[1]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->cache->evictEntity(Country::class, $result1[0]->getId()); - $this->assertFalse($this->cache->containsEntity(Country::class, $result1[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $result1[0]->getId())); $this->_em->clear(); @@ -444,24 +444,24 @@ public function testLoadFromDatabaseWhenEntityMissing(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertCount(2, $result2); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); - $this->assertEquals(5, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(5, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertInstanceOf(Country::class, $result2[0]); - $this->assertInstanceOf(Country::class, $result2[1]); + self::assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[1]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[1]->getId(), $result2[1]->getId()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[1]->getId(), $result2[1]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testBasicQueryFetchJoinsOneToMany(): void @@ -479,26 +479,26 @@ public function testBasicQueryFetchJoinsOneToMany(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $result1[0]); - $this->assertInstanceOf(State::class, $result1[1]); - $this->assertCount(2, $result1[0]->getCities()); - $this->assertCount(2, $result1[1]->getCities()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $result1[0]); + self::assertInstanceOf(State::class, $result1[1]); + self::assertCount(2, $result1[0]->getCities()); + self::assertCount(2, $result1[1]->getCities()); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); - $this->assertNotNull($result1[0]->getCities()->get(0)->getId()); - $this->assertNotNull($result1[0]->getCities()->get(1)->getId()); - $this->assertNotNull($result1[1]->getCities()->get(0)->getId()); - $this->assertNotNull($result1[1]->getCities()->get(1)->getId()); + self::assertNotNull($result1[0]->getCities()->get(0)->getId()); + self::assertNotNull($result1[0]->getCities()->get(1)->getId()); + self::assertNotNull($result1[1]->getCities()->get(0)->getId()); + self::assertNotNull($result1[1]->getCities()->get(1)->getId()); - $this->assertNotNull($result1[0]->getCities()->get(0)->getName()); - $this->assertNotNull($result1[0]->getCities()->get(1)->getName()); - $this->assertNotNull($result1[1]->getCities()->get(0)->getName()); - $this->assertNotNull($result1[1]->getCities()->get(1)->getName()); + self::assertNotNull($result1[0]->getCities()->get(0)->getName()); + self::assertNotNull($result1[0]->getCities()->get(1)->getName()); + self::assertNotNull($result1[1]->getCities()->get(0)->getName()); + self::assertNotNull($result1[1]->getCities()->get(1)->getName()); $this->_em->clear(); @@ -506,27 +506,27 @@ public function testBasicQueryFetchJoinsOneToMany(): void ->setCacheable(true) ->getResult(); - $this->assertInstanceOf(State::class, $result2[0]); - $this->assertInstanceOf(State::class, $result2[1]); - $this->assertCount(2, $result2[0]->getCities()); - $this->assertCount(2, $result2[1]->getCities()); + self::assertInstanceOf(State::class, $result2[0]); + self::assertInstanceOf(State::class, $result2[1]); + self::assertCount(2, $result2[0]->getCities()); + self::assertCount(2, $result2[1]->getCities()); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); - $this->assertNotNull($result2[0]->getCities()->get(0)->getId()); - $this->assertNotNull($result2[0]->getCities()->get(1)->getId()); - $this->assertNotNull($result2[1]->getCities()->get(0)->getId()); - $this->assertNotNull($result2[1]->getCities()->get(1)->getId()); + self::assertNotNull($result2[0]->getCities()->get(0)->getId()); + self::assertNotNull($result2[0]->getCities()->get(1)->getId()); + self::assertNotNull($result2[1]->getCities()->get(0)->getId()); + self::assertNotNull($result2[1]->getCities()->get(1)->getId()); - $this->assertNotNull($result2[0]->getCities()->get(0)->getName()); - $this->assertNotNull($result2[0]->getCities()->get(1)->getName()); - $this->assertNotNull($result2[1]->getCities()->get(0)->getName()); - $this->assertNotNull($result2[1]->getCities()->get(1)->getName()); + self::assertNotNull($result2[0]->getCities()->get(0)->getName()); + self::assertNotNull($result2[0]->getCities()->get(1)->getName()); + self::assertNotNull($result2[1]->getCities()->get(0)->getName()); + self::assertNotNull($result2[1]->getCities()->get(1)->getName()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testBasicQueryFetchJoinsManyToOne(): void @@ -545,25 +545,25 @@ public function testBasicQueryFetchJoinsManyToOne(): void ->setCacheable(true) ->getResult(); - $this->assertCount(4, $result1); - $this->assertInstanceOf(City::class, $result1[0]); - $this->assertInstanceOf(City::class, $result1[1]); - $this->assertInstanceOf(State::class, $result1[0]->getState()); - $this->assertInstanceOf(State::class, $result1[1]->getState()); + self::assertCount(4, $result1); + self::assertInstanceOf(City::class, $result1[0]); + self::assertInstanceOf(City::class, $result1[1]); + self::assertInstanceOf(State::class, $result1[0]->getState()); + self::assertInstanceOf(State::class, $result1[1]->getState()); - $this->assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId())); - $this->assertEquals(7, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); - $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(City::class))); + self::assertEquals(7, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(City::class))); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); $this->secondLevelCacheLogger->clearStats(); @@ -572,28 +572,28 @@ public function testBasicQueryFetchJoinsManyToOne(): void ->setCacheable(true) ->getResult(); - $this->assertCount(4, $result1); - $this->assertInstanceOf(City::class, $result2[0]); - $this->assertInstanceOf(City::class, $result2[1]); - $this->assertInstanceOf(State::class, $result2[0]->getState()); - $this->assertInstanceOf(State::class, $result2[1]->getState()); + self::assertCount(4, $result1); + self::assertInstanceOf(City::class, $result2[0]); + self::assertInstanceOf(City::class, $result2[1]); + self::assertInstanceOf(State::class, $result2[0]->getState()); + self::assertInstanceOf(State::class, $result2[1]->getState()); - $this->assertNotNull($result2[0]->getId()); - $this->assertNotNull($result2[0]->getId()); - $this->assertNotNull($result2[1]->getState()->getId()); - $this->assertNotNull($result2[1]->getState()->getId()); + self::assertNotNull($result2[0]->getId()); + self::assertNotNull($result2[0]->getId()); + self::assertNotNull($result2[1]->getState()->getId()); + self::assertNotNull($result2[1]->getState()->getId()); - $this->assertNotNull($result2[0]->getName()); - $this->assertNotNull($result2[0]->getName()); - $this->assertNotNull($result2[1]->getState()->getName()); - $this->assertNotNull($result2[1]->getState()->getName()); + self::assertNotNull($result2[0]->getName()); + self::assertNotNull($result2[0]->getName()); + self::assertNotNull($result2[1]->getState()->getName()); + self::assertNotNull($result2[1]->getState()->getName()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals($result1[0]->getState()->getName(), $result2[0]->getState()->getName()); - $this->assertEquals($result1[1]->getState()->getName(), $result2[1]->getState()->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getState()->getName(), $result2[0]->getState()->getName()); + self::assertEquals($result1[1]->getState()->getName(), $result2[1]->getState()->getName()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testReloadQueryIfToOneIsNotFound(): void @@ -612,17 +612,17 @@ public function testReloadQueryIfToOneIsNotFound(): void ->setCacheable(true) ->getResult(); - $this->assertCount(4, $result1); - $this->assertInstanceOf(City::class, $result1[0]); - $this->assertInstanceOf(City::class, $result1[1]); - $this->assertInstanceOf(State::class, $result1[0]->getState()); - $this->assertInstanceOf(State::class, $result1[1]->getState()); + self::assertCount(4, $result1); + self::assertInstanceOf(City::class, $result1[0]); + self::assertInstanceOf(City::class, $result1[1]); + self::assertInstanceOf(State::class, $result1[0]->getState()); + self::assertInstanceOf(State::class, $result1[1]->getState()); - $this->assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId())); - $this->assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId())); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertTrue($this->cache->containsEntity(City::class, $result1[0]->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $result1[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $result1[0]->getState()->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $result1[1]->getState()->getId())); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); @@ -632,13 +632,13 @@ public function testReloadQueryIfToOneIsNotFound(): void ->setCacheable(true) ->getResult(); - $this->assertCount(4, $result1); - $this->assertInstanceOf(City::class, $result2[0]); - $this->assertInstanceOf(City::class, $result2[1]); - $this->assertInstanceOf(State::class, $result2[0]->getState()); - $this->assertInstanceOf(State::class, $result2[1]->getState()); + self::assertCount(4, $result1); + self::assertInstanceOf(City::class, $result2[0]); + self::assertInstanceOf(City::class, $result2[1]); + self::assertInstanceOf(State::class, $result2[0]->getState()); + self::assertInstanceOf(State::class, $result2[1]->getState()); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testReloadQueryIfToManyAssociationItemIsNotFound(): void @@ -656,16 +656,16 @@ public function testReloadQueryIfToManyAssociationItemIsNotFound(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $result1[0]); - $this->assertInstanceOf(State::class, $result1[1]); - $this->assertCount(2, $result1[0]->getCities()); - $this->assertCount(2, $result1[1]->getCities()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $result1[0]); + self::assertInstanceOf(State::class, $result1[1]); + self::assertCount(2, $result1[0]->getCities()); + self::assertCount(2, $result1[1]->getCities()); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result1[1]->getCities()->get(1)); $this->_em->clear(); @@ -675,17 +675,17 @@ public function testReloadQueryIfToManyAssociationItemIsNotFound(): void ->setCacheable(true) ->getResult(); - $this->assertInstanceOf(State::class, $result2[0]); - $this->assertInstanceOf(State::class, $result2[1]); - $this->assertCount(2, $result2[0]->getCities()); - $this->assertCount(2, $result2[1]->getCities()); + self::assertInstanceOf(State::class, $result2[0]); + self::assertInstanceOf(State::class, $result2[1]); + self::assertCount(2, $result2[0]->getCities()); + self::assertCount(2, $result2[1]->getCities()); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); - $this->assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[0]->getCities()->get(1)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(0)); + self::assertInstanceOf(City::class, $result2[1]->getCities()->get(1)); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); } public function testBasicNativeQueryCache(): void @@ -696,8 +696,8 @@ public function testBasicNativeQueryCache(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $rsm = new ResultSetMapping(); $rsm->addEntityResult(Country::class, 'c'); @@ -708,17 +708,17 @@ public function testBasicNativeQueryCache(): void $sql = 'SELECT id, name FROM cache_country'; $result1 = $this->_em->createNativeQuery($sql, $rsm)->setCacheable(true)->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals($this->countries[0]->getId(), $result1[0]->getId()); - $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); - $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); - $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($this->countries[0]->getId(), $result1[0]->getId()); + self::assertEquals($this->countries[1]->getId(), $result1[1]->getId()); + self::assertEquals($this->countries[0]->getName(), $result1[0]->getName()); + self::assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); $this->_em->clear(); @@ -726,33 +726,33 @@ public function testBasicNativeQueryCache(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertCount(2, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result2); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); - $this->assertInstanceOf(Country::class, $result2[0]); - $this->assertInstanceOf(Country::class, $result2[1]); + self::assertInstanceOf(Country::class, $result2[0]); + self::assertInstanceOf(Country::class, $result2[1]); - $this->assertEquals($result1[0]->getId(), $result2[0]->getId()); - $this->assertEquals($result1[1]->getId(), $result2[1]->getId()); + self::assertEquals($result1[0]->getId(), $result2[0]->getId()); + self::assertEquals($result1[1]->getId(), $result2[1]->getId()); - $this->assertEquals($result1[0]->getName(), $result2[0]->getName()); - $this->assertEquals($result1[1]->getName(), $result2[1]->getName()); + self::assertEquals($result1[0]->getName(), $result2[0]->getName()); + self::assertEquals($result1[1]->getName(), $result2[1]->getName()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount($this->getDefaultQueryRegionName())); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } public function testQueryDependsOnFirstAndMaxResultResult(): void @@ -771,9 +771,9 @@ public function testQueryDependsOnFirstAndMaxResultResult(): void ->setMaxResults(1) ->getResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->_em->clear(); @@ -783,9 +783,9 @@ public function testQueryDependsOnFirstAndMaxResultResult(): void ->setMaxResults(1) ->getResult(); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); $this->_em->clear(); @@ -793,9 +793,9 @@ public function testQueryDependsOnFirstAndMaxResultResult(): void ->setCacheable(true) ->getResult(); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getMissCount()); } public function testQueryCacheLifetime(): void @@ -820,10 +820,10 @@ public function testQueryCacheLifetime(): void ->setLifetime(3600) ->getResult(); - $this->assertNotEmpty($result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertNotEmpty($result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->_em->clear(); @@ -832,7 +832,7 @@ public function testQueryCacheLifetime(): void ->getRegion() ->get($key); - $this->assertInstanceOf(Cache\QueryCacheEntry::class, $entry); + self::assertInstanceOf(Cache\QueryCacheEntry::class, $entry); $entry->time /= 2; $this->cache->getQueryCache() @@ -844,10 +844,10 @@ public function testQueryCacheLifetime(): void ->setLifetime(3600) ->getResult(); - $this->assertNotEmpty($result2); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertNotEmpty($result2); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); } public function testQueryCacheRegion(): void @@ -867,54 +867,54 @@ public function testQueryCacheRegion(): void ->setCacheRegion('foo_region') ->getResult(); - $this->assertNotEmpty($result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('foo_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('foo_region')); + self::assertNotEmpty($result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals(0, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('foo_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('foo_region')); $query2 = clone $query; $result2 = $query2->setCacheable(true) ->setCacheRegion('bar_region') ->getResult(); - $this->assertNotEmpty($result2); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('bar_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('bar_region')); + self::assertNotEmpty($result2); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(0, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('bar_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('bar_region')); $query3 = clone $query; $result3 = $query3->setCacheable(true) ->setCacheRegion('foo_region') ->getResult(); - $this->assertNotEmpty($result3); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount('foo_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('foo_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('foo_region')); + self::assertNotEmpty($result3); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount('foo_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('foo_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('foo_region')); $query4 = clone $query; $result4 = $query4->setCacheable(true) ->setCacheRegion('bar_region') ->getResult(); - $this->assertNotEmpty($result3); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); - $this->assertEquals(6, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount('bar_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('bar_region')); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('bar_region')); + self::assertNotEmpty($result3); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + self::assertEquals(6, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount('bar_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount('bar_region')); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount('bar_region')); } public function testResolveAssociationCacheEntry(): void @@ -938,13 +938,13 @@ public function testResolveAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertNotNull($state1); - $this->assertNotNull($state1->getCountry()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state1); - $this->assertInstanceOf(Proxy::class, $state1->getCountry()); - $this->assertEquals($countryName, $state1->getCountry()->getName()); - $this->assertEquals($stateId, $state1->getId()); + self::assertNotNull($state1); + self::assertNotNull($state1->getCountry()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $state1); + self::assertInstanceOf(Proxy::class, $state1->getCountry()); + self::assertEquals($countryName, $state1->getCountry()->getName()); + self::assertEquals($stateId, $state1->getId()); $this->_em->clear(); @@ -956,13 +956,13 @@ public function testResolveAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertNotNull($state2); - $this->assertNotNull($state2->getCountry()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state2); - $this->assertInstanceOf(Proxy::class, $state2->getCountry()); - $this->assertEquals($countryName, $state2->getCountry()->getName()); - $this->assertEquals($stateId, $state2->getId()); + self::assertNotNull($state2); + self::assertNotNull($state2->getCountry()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $state2); + self::assertInstanceOf(Proxy::class, $state2->getCountry()); + self::assertEquals($countryName, $state2->getCountry()->getName()); + self::assertEquals($stateId, $state2->getId()); } public function testResolveToOneAssociationCacheEntry(): void @@ -987,11 +987,11 @@ public function testResolveToOneAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(City::class, $city1); - $this->assertInstanceOf(State::class, $city1->getState()); - $this->assertInstanceOf(City::class, $city1->getState()->getCities()->get(0)); - $this->assertInstanceOf(State::class, $city1->getState()->getCities()->get(0)->getState()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(City::class, $city1); + self::assertInstanceOf(State::class, $city1->getState()); + self::assertInstanceOf(City::class, $city1->getState()->getCities()->get(0)); + self::assertInstanceOf(State::class, $city1->getState()->getCities()->get(0)->getState()); $this->_em->clear(); @@ -1003,11 +1003,11 @@ public function testResolveToOneAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(City::class, $city2); - $this->assertInstanceOf(State::class, $city2->getState()); - $this->assertInstanceOf(City::class, $city2->getState()->getCities()->get(0)); - $this->assertInstanceOf(State::class, $city2->getState()->getCities()->get(0)->getState()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(City::class, $city2); + self::assertInstanceOf(State::class, $city2->getState()); + self::assertInstanceOf(City::class, $city2->getState()->getCities()->get(0)); + self::assertInstanceOf(State::class, $city2->getState()->getCities()->get(0)->getState()); } public function testResolveToManyAssociationCacheEntry(): void @@ -1032,12 +1032,12 @@ public function testResolveToManyAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state1); - $this->assertInstanceOf(Proxy::class, $state1->getCountry()); - $this->assertInstanceOf(City::class, $state1->getCities()->get(0)); - $this->assertInstanceOf(State::class, $state1->getCities()->get(0)->getState()); - $this->assertSame($state1, $state1->getCities()->get(0)->getState()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $state1); + self::assertInstanceOf(Proxy::class, $state1->getCountry()); + self::assertInstanceOf(City::class, $state1->getCities()->get(0)); + self::assertInstanceOf(State::class, $state1->getCities()->get(0)->getState()); + self::assertSame($state1, $state1->getCities()->get(0)->getState()); $this->_em->clear(); @@ -1049,12 +1049,12 @@ public function testResolveToManyAssociationCacheEntry(): void ->setMaxResults(1) ->getSingleResult(); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $state2); - $this->assertInstanceOf(Proxy::class, $state2->getCountry()); - $this->assertInstanceOf(City::class, $state2->getCities()->get(0)); - $this->assertInstanceOf(State::class, $state2->getCities()->get(0)->getState()); - $this->assertSame($state2, $state2->getCities()->get(0)->getState()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(State::class, $state2); + self::assertInstanceOf(Proxy::class, $state2->getCountry()); + self::assertInstanceOf(City::class, $state2->getCities()->get(0)); + self::assertInstanceOf(State::class, $state2->getCities()->get(0)->getState()); + self::assertSame($state2, $state2->getCities()->get(0)->getState()); } public function testHintClearEntityRegionUpdateStatement(): void @@ -1062,15 +1062,15 @@ public function testHintClearEntityRegionUpdateStatement(): void $this->evictRegions(); $this->loadFixturesCountries(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $this->_em->createQuery('DELETE Doctrine\Tests\Models\Cache\Country u WHERE u.id = 4') ->setHint(Query::HINT_CACHE_EVICT, true) ->execute(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } public function testHintClearEntityRegionDeleteStatement(): void @@ -1078,15 +1078,15 @@ public function testHintClearEntityRegionDeleteStatement(): void $this->evictRegions(); $this->loadFixturesCountries(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $this->_em->createQuery("UPDATE Doctrine\Tests\Models\Cache\Country u SET u.name = 'foo' WHERE u.id = 1") ->setHint(Query::HINT_CACHE_EVICT, true) ->execute(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } public function testCacheablePartialQueryException(): void @@ -1144,8 +1144,8 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(2, $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->persist(new Country('France')); $this->_em->flush(); @@ -1157,11 +1157,11 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(3, $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(3, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(Country::class, $entity); + self::assertInstanceOf(Country::class, $entity); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php index 7bd11f974a9..426866459ad 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php @@ -21,22 +21,22 @@ public function testRepositoryCacheFind(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $queryCount = $this->getCurrentQueryCount(); $repository = $this->_em->getRepository(Country::class); $country1 = $repository->find($this->countries[0]->getId()); $country2 = $repository->find($this->countries[1]->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Country::class, $country1); - $this->assertInstanceOf(Country::class, $country2); + self::assertInstanceOf(Country::class, $country1); + self::assertInstanceOf(Country::class, $country2); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(0, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class))); } public function testRepositoryCacheFindAll(): void @@ -46,28 +46,28 @@ public function testRepositoryCacheFindAll(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(2, $repository->findAll()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $repository->findAll()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $countries = $repository->findAll(); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Country::class, $countries[0]); - $this->assertInstanceOf(Country::class, $countries[1]); + self::assertInstanceOf(Country::class, $countries[0]); + self::assertInstanceOf(Country::class, $countries[1]); - $this->assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(3, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } public function testRepositoryCacheFindAllInvalidation(): void @@ -77,23 +77,23 @@ public function testRepositoryCacheFindAllInvalidation(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(2, $repository->findAll()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $repository->findAll()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $countries = $repository->findAll(); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertCount(2, $countries); - $this->assertInstanceOf(Country::class, $countries[0]); - $this->assertInstanceOf(Country::class, $countries[1]); + self::assertCount(2, $countries); + self::assertInstanceOf(Country::class, $countries[0]); + self::assertInstanceOf(Country::class, $countries[1]); $country = new Country('foo'); @@ -103,8 +103,8 @@ public function testRepositoryCacheFindAllInvalidation(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(3, $repository->findAll()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(3, $repository->findAll()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $country = $repository->find($country->getId()); @@ -114,8 +114,8 @@ public function testRepositoryCacheFindAllInvalidation(): void $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(2, $repository->findAll()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(2, $repository->findAll()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } public function testRepositoryCacheFindBy(): void @@ -125,27 +125,27 @@ public function testRepositoryCacheFindBy(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $criteria = ['name' => $this->countries[0]->getName()]; $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertCount(1, $repository->findBy($criteria)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(1, $repository->findBy($criteria)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $countries = $repository->findBy($criteria); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertCount(1, $countries); - $this->assertInstanceOf(Country::class, $countries[0]); + self::assertCount(1, $countries); + self::assertInstanceOf(Country::class, $countries[0]); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); } public function testRepositoryCacheFindOneBy(): void @@ -155,26 +155,26 @@ public function testRepositoryCacheFindOneBy(): void $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); $criteria = ['name' => $this->countries[0]->getName()]; $repository = $this->_em->getRepository(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertNotNull($repository->findOneBy($criteria)); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertNotNull($repository->findOneBy($criteria)); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $country = $repository->findOneBy($criteria); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Country::class, $country); + self::assertInstanceOf(Country::class, $country); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); } public function testRepositoryCacheFindAllToOneAssociation(): void @@ -192,29 +192,29 @@ public function testRepositoryCacheFindAllToOneAssociation(): void $queryCount = $this->getCurrentQueryCount(); $entities = $repository->findAll(); - $this->assertCount(4, $entities); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(4, $entities); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $entities[0]); - $this->assertInstanceOf(State::class, $entities[1]); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry()); + self::assertInstanceOf(State::class, $entities[0]); + self::assertInstanceOf(State::class, $entities[1]); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[1]->getCountry()); // load from cache $queryCount = $this->getCurrentQueryCount(); $entities = $repository->findAll(); - $this->assertCount(4, $entities); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertCount(4, $entities); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $entities[0]); - $this->assertInstanceOf(State::class, $entities[1]); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Country::class, $entities[1]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry()); + self::assertInstanceOf(State::class, $entities[0]); + self::assertInstanceOf(State::class, $entities[1]); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Country::class, $entities[1]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[1]->getCountry()); // invalidate cache $this->_em->persist(new State('foo', $this->_em->find(Country::class, $this->countries[0]->getId()))); @@ -225,28 +225,28 @@ public function testRepositoryCacheFindAllToOneAssociation(): void $queryCount = $this->getCurrentQueryCount(); $entities = $repository->findAll(); - $this->assertCount(5, $entities); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(5, $entities); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $entities[0]); - $this->assertInstanceOf(State::class, $entities[1]); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Country::class, $entities[1]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry()); + self::assertInstanceOf(State::class, $entities[0]); + self::assertInstanceOf(State::class, $entities[1]); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Country::class, $entities[1]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[1]->getCountry()); // load from cache $queryCount = $this->getCurrentQueryCount(); $entities = $repository->findAll(); - $this->assertCount(5, $entities); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertCount(5, $entities); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(State::class, $entities[0]); - $this->assertInstanceOf(State::class, $entities[1]); - $this->assertInstanceOf(Country::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Country::class, $entities[1]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[0]->getCountry()); - $this->assertInstanceOf(Proxy::class, $entities[1]->getCountry()); + self::assertInstanceOf(State::class, $entities[0]); + self::assertInstanceOf(State::class, $entities[1]); + self::assertInstanceOf(Country::class, $entities[0]->getCountry()); + self::assertInstanceOf(Country::class, $entities[1]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[0]->getCountry()); + self::assertInstanceOf(Proxy::class, $entities[1]->getCountry()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php index 841621eca5d..836be9ad746 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php @@ -26,9 +26,9 @@ public function testUseSameRegion(): void $beachRegion = $this->cache->getEntityCacheRegion(Beach::class); $barRegion = $this->cache->getEntityCacheRegion(Bar::class); - $this->assertEquals($attractionRegion->getName(), $restaurantRegion->getName()); - $this->assertEquals($attractionRegion->getName(), $beachRegion->getName()); - $this->assertEquals($attractionRegion->getName(), $barRegion->getName()); + self::assertEquals($attractionRegion->getName(), $restaurantRegion->getName()); + self::assertEquals($attractionRegion->getName(), $beachRegion->getName()); + self::assertEquals($attractionRegion->getName(), $barRegion->getName()); } public function testPutOnPersistSingleTableInheritance(): void @@ -40,8 +40,8 @@ public function testPutOnPersistSingleTableInheritance(): void $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[1]->getId())); + self::assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[0]->getId())); + self::assertTrue($this->cache->containsEntity(Bar::class, $this->attractions[1]->getId())); } public function testCountaisRootClass(): void @@ -54,8 +54,8 @@ public function testCountaisRootClass(): void $this->_em->clear(); foreach ($this->attractions as $attraction) { - $this->assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); - $this->assertTrue($this->cache->containsEntity(get_class($attraction), $attraction->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); + self::assertTrue($this->cache->containsEntity(get_class($attraction), $attraction->getId())); } } @@ -73,29 +73,29 @@ public function testPutAndLoadEntities(): void $entityId1 = $this->attractions[0]->getId(); $entityId2 = $this->attractions[1]->getId(); - $this->assertFalse($this->cache->containsEntity(Attraction::class, $entityId1)); - $this->assertFalse($this->cache->containsEntity(Attraction::class, $entityId2)); - $this->assertFalse($this->cache->containsEntity(Bar::class, $entityId1)); - $this->assertFalse($this->cache->containsEntity(Bar::class, $entityId2)); + self::assertFalse($this->cache->containsEntity(Attraction::class, $entityId1)); + self::assertFalse($this->cache->containsEntity(Attraction::class, $entityId2)); + self::assertFalse($this->cache->containsEntity(Bar::class, $entityId1)); + self::assertFalse($this->cache->containsEntity(Bar::class, $entityId2)); $entity1 = $this->_em->find(Attraction::class, $entityId1); $entity2 = $this->_em->find(Attraction::class, $entityId2); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $entityId1)); - $this->assertTrue($this->cache->containsEntity(Attraction::class, $entityId2)); - $this->assertTrue($this->cache->containsEntity(Bar::class, $entityId1)); - $this->assertTrue($this->cache->containsEntity(Bar::class, $entityId2)); + self::assertTrue($this->cache->containsEntity(Attraction::class, $entityId1)); + self::assertTrue($this->cache->containsEntity(Attraction::class, $entityId2)); + self::assertTrue($this->cache->containsEntity(Bar::class, $entityId1)); + self::assertTrue($this->cache->containsEntity(Bar::class, $entityId2)); - $this->assertInstanceOf(Attraction::class, $entity1); - $this->assertInstanceOf(Attraction::class, $entity2); - $this->assertInstanceOf(Bar::class, $entity1); - $this->assertInstanceOf(Bar::class, $entity2); + self::assertInstanceOf(Attraction::class, $entity1); + self::assertInstanceOf(Attraction::class, $entity2); + self::assertInstanceOf(Bar::class, $entity1); + self::assertInstanceOf(Bar::class, $entity2); - $this->assertEquals($this->attractions[0]->getId(), $entity1->getId()); - $this->assertEquals($this->attractions[0]->getName(), $entity1->getName()); + self::assertEquals($this->attractions[0]->getId(), $entity1->getId()); + self::assertEquals($this->attractions[0]->getName(), $entity1->getName()); - $this->assertEquals($this->attractions[1]->getId(), $entity2->getId()); - $this->assertEquals($this->attractions[1]->getName(), $entity2->getName()); + self::assertEquals($this->attractions[1]->getId(), $entity2->getId()); + self::assertEquals($this->attractions[1]->getName(), $entity2->getName()); $this->_em->clear(); @@ -104,20 +104,20 @@ public function testPutAndLoadEntities(): void $entity3 = $this->_em->find(Attraction::class, $entityId1); $entity4 = $this->_em->find(Attraction::class, $entityId2); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Attraction::class, $entity3); - $this->assertInstanceOf(Attraction::class, $entity4); - $this->assertInstanceOf(Bar::class, $entity3); - $this->assertInstanceOf(Bar::class, $entity4); + self::assertInstanceOf(Attraction::class, $entity3); + self::assertInstanceOf(Attraction::class, $entity4); + self::assertInstanceOf(Bar::class, $entity3); + self::assertInstanceOf(Bar::class, $entity4); - $this->assertNotSame($entity1, $entity3); - $this->assertEquals($entity1->getId(), $entity3->getId()); - $this->assertEquals($entity1->getName(), $entity3->getName()); + self::assertNotSame($entity1, $entity3); + self::assertEquals($entity1->getId(), $entity3->getId()); + self::assertEquals($entity1->getName(), $entity3->getName()); - $this->assertNotSame($entity2, $entity4); - $this->assertEquals($entity2->getId(), $entity4->getId()); - $this->assertEquals($entity2->getName(), $entity4->getName()); + self::assertNotSame($entity2, $entity4); + self::assertEquals($entity2->getId(), $entity4->getId()); + self::assertEquals($entity2->getName(), $entity4->getName()); } public function testQueryCacheFindAll(): void @@ -135,8 +135,8 @@ public function testQueryCacheFindAll(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractions), $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractions), $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); @@ -144,11 +144,11 @@ public function testQueryCacheFindAll(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractions), $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractions), $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(Attraction::class, $entity); + self::assertInstanceOf(Attraction::class, $entity); } } @@ -162,12 +162,12 @@ public function testShouldNotPutOneToManyRelationOnPersist(): void $this->_em->clear(); foreach ($this->cities as $city) { - $this->assertTrue($this->cache->containsEntity(City::class, $city->getId())); - $this->assertFalse($this->cache->containsCollection(City::class, 'attractions', $city->getId())); + self::assertTrue($this->cache->containsEntity(City::class, $city->getId())); + self::assertFalse($this->cache->containsCollection(City::class, 'attractions', $city->getId())); } foreach ($this->attractions as $attraction) { - $this->assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); + self::assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); } } @@ -186,35 +186,35 @@ public function testOneToManyRelationSingleTable(): void $entity = $this->_em->find(City::class, $this->cities[0]->getId()); - $this->assertInstanceOf(City::class, $entity); - $this->assertInstanceOf(PersistentCollection::class, $entity->getAttractions()); - $this->assertCount(2, $entity->getAttractions()); + self::assertInstanceOf(City::class, $entity); + self::assertInstanceOf(PersistentCollection::class, $entity->getAttractions()); + self::assertCount(2, $entity->getAttractions()); $ownerId = $this->cities[0]->getId(); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($this->cache->containsEntity(City::class, $ownerId)); - $this->assertTrue($this->cache->containsCollection(City::class, 'attractions', $ownerId)); + self::assertTrue($this->cache->containsEntity(City::class, $ownerId)); + self::assertTrue($this->cache->containsCollection(City::class, 'attractions', $ownerId)); - $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(0)); - $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(1)); - $this->assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); - $this->assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); + self::assertInstanceOf(Bar::class, $entity->getAttractions()->get(0)); + self::assertInstanceOf(Bar::class, $entity->getAttractions()->get(1)); + self::assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); + self::assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); $this->_em->clear(); $entity = $this->_em->find(City::class, $ownerId); - $this->assertInstanceOf(City::class, $entity); - $this->assertInstanceOf(PersistentCollection::class, $entity->getAttractions()); - $this->assertCount(2, $entity->getAttractions()); + self::assertInstanceOf(City::class, $entity); + self::assertInstanceOf(PersistentCollection::class, $entity->getAttractions()); + self::assertCount(2, $entity->getAttractions()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(0)); - $this->assertInstanceOf(Bar::class, $entity->getAttractions()->get(1)); - $this->assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); - $this->assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); + self::assertInstanceOf(Bar::class, $entity->getAttractions()->get(0)); + self::assertInstanceOf(Bar::class, $entity->getAttractions()->get(1)); + self::assertEquals($this->attractions[0]->getName(), $entity->getAttractions()->get(0)->getName()); + self::assertEquals($this->attractions[1]->getName(), $entity->getAttractions()->get(1)->getName()); } public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void @@ -232,8 +232,8 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractions), $result1); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractions), $result1); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $contact = new Beach( 'Botafogo', @@ -250,11 +250,11 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void ->setCacheable(true) ->getResult(); - $this->assertCount(count($this->attractions) + 1, $result2); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertCount(count($this->attractions) + 1, $result2); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); foreach ($result2 as $entity) { - $this->assertInstanceOf(Attraction::class, $entity); + self::assertInstanceOf(Attraction::class, $entity); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php index f686f4c8734..e454e0379ed 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php @@ -26,10 +26,10 @@ public function testPutOnPersist(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); } public function testPutAndLoadEntities(): void @@ -37,28 +37,28 @@ public function testPutAndLoadEntities(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); $this->cache->evictEntityRegion(Country::class); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $c1 = $this->_em->find(Country::class, $this->countries[0]->getId()); $c2 = $this->_em->find(Country::class, $this->countries[1]->getId()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertInstanceOf(Country::class, $c1); - $this->assertInstanceOf(Country::class, $c2); + self::assertInstanceOf(Country::class, $c1); + self::assertInstanceOf(Country::class, $c2); - $this->assertEquals($this->countries[0]->getId(), $c1->getId()); - $this->assertEquals($this->countries[0]->getName(), $c1->getName()); + self::assertEquals($this->countries[0]->getId(), $c1->getId()); + self::assertEquals($this->countries[0]->getName(), $c1->getName()); - $this->assertEquals($this->countries[1]->getId(), $c2->getId()); - $this->assertEquals($this->countries[1]->getName(), $c2->getName()); + self::assertEquals($this->countries[1]->getId(), $c2->getId()); + self::assertEquals($this->countries[1]->getName(), $c2->getName()); $this->_em->clear(); @@ -67,18 +67,18 @@ public function testPutAndLoadEntities(): void $c3 = $this->_em->find(Country::class, $this->countries[0]->getId()); $c4 = $this->_em->find(Country::class, $this->countries[1]->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class))); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(Country::class))); - $this->assertInstanceOf(Country::class, $c3); - $this->assertInstanceOf(Country::class, $c4); + self::assertInstanceOf(Country::class, $c3); + self::assertInstanceOf(Country::class, $c4); - $this->assertEquals($c1->getId(), $c3->getId()); - $this->assertEquals($c1->getName(), $c3->getName()); + self::assertEquals($c1->getId(), $c3->getId()); + self::assertEquals($c1->getName(), $c3->getName()); - $this->assertEquals($c2->getId(), $c4->getId()); - $this->assertEquals($c2->getName(), $c4->getName()); + self::assertEquals($c2->getId(), $c4->getId()); + self::assertEquals($c2->getName(), $c4->getName()); } public function testRemoveEntities(): void @@ -86,45 +86,45 @@ public function testRemoveEntities(): void $this->loadFixturesCountries(); $this->_em->clear(); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); $this->cache->evictEntityRegion(Country::class); $this->secondLevelCacheLogger->clearRegionStats($this->getEntityRegion(Country::class)); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); $c1 = $this->_em->find(Country::class, $this->countries[0]->getId()); $c2 = $this->_em->find(Country::class, $this->countries[1]->getId()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertInstanceOf(Country::class, $c1); - $this->assertInstanceOf(Country::class, $c2); + self::assertInstanceOf(Country::class, $c1); + self::assertInstanceOf(Country::class, $c2); - $this->assertEquals($this->countries[0]->getId(), $c1->getId()); - $this->assertEquals($this->countries[0]->getName(), $c1->getName()); + self::assertEquals($this->countries[0]->getId(), $c1->getId()); + self::assertEquals($this->countries[0]->getName(), $c1->getName()); - $this->assertEquals($this->countries[1]->getId(), $c2->getId()); - $this->assertEquals($this->countries[1]->getName(), $c2->getName()); + self::assertEquals($this->countries[1]->getId(), $c2->getId()); + self::assertEquals($this->countries[1]->getName(), $c2->getName()); $this->_em->remove($c1); $this->_em->remove($c2); $this->_em->flush(); $this->_em->clear(); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); - $this->assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId())); + self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); - $this->assertNull($this->_em->find(Country::class, $this->countries[0]->getId())); - $this->assertNull($this->_em->find(Country::class, $this->countries[1]->getId())); + self::assertNull($this->_em->find(Country::class, $this->countries[0]->getId())); + self::assertNull($this->_em->find(Country::class, $this->countries[1]->getId())); - $this->assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getMissCount()); } public function testUpdateEntities(): void @@ -133,34 +133,34 @@ public function testUpdateEntities(): void $this->loadFixturesStates(); $this->_em->clear(); - $this->assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); - $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); $this->cache->evictEntityRegion(State::class); $this->secondLevelCacheLogger->clearRegionStats($this->getEntityRegion(State::class)); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertFalse($this->cache->containsEntity(State::class, $this->states[1]->getId())); $s1 = $this->_em->find(State::class, $this->states[0]->getId()); $s2 = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(4, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertInstanceOf(State::class, $s1); - $this->assertInstanceOf(State::class, $s2); + self::assertInstanceOf(State::class, $s1); + self::assertInstanceOf(State::class, $s2); - $this->assertEquals($this->states[0]->getId(), $s1->getId()); - $this->assertEquals($this->states[0]->getName(), $s1->getName()); + self::assertEquals($this->states[0]->getId(), $s1->getId()); + self::assertEquals($this->states[0]->getName(), $s1->getName()); - $this->assertEquals($this->states[1]->getId(), $s2->getId()); - $this->assertEquals($this->states[1]->getName(), $s2->getName()); + self::assertEquals($this->states[1]->getId(), $s2->getId()); + self::assertEquals($this->states[1]->getName(), $s2->getName()); $s1->setName('NEW NAME 1'); $s2->setName('NEW NAME 2'); @@ -170,37 +170,37 @@ public function testUpdateEntities(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); - $this->assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); + self::assertEquals(6, $this->secondLevelCacheLogger->getPutCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(Country::class))); + self::assertEquals(4, $this->secondLevelCacheLogger->getRegionPutCount($this->getEntityRegion(State::class))); $queryCount = $this->getCurrentQueryCount(); $c3 = $this->_em->find(State::class, $this->states[0]->getId()); $c4 = $this->_em->find(State::class, $this->states[1]->getId()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); - $this->assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId())); + self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId())); - $this->assertInstanceOf(State::class, $c3); - $this->assertInstanceOf(State::class, $c4); + self::assertInstanceOf(State::class, $c3); + self::assertInstanceOf(State::class, $c4); - $this->assertEquals($s1->getId(), $c3->getId()); - $this->assertEquals('NEW NAME 1', $c3->getName()); + self::assertEquals($s1->getId(), $c3->getId()); + self::assertEquals('NEW NAME 1', $c3->getName()); - $this->assertEquals($s2->getId(), $c4->getId()); - $this->assertEquals('NEW NAME 2', $c4->getName()); + self::assertEquals($s2->getId(), $c4->getId()); + self::assertEquals('NEW NAME 2', $c4->getName()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); - $this->assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getRegionHitCount($this->getEntityRegion(State::class))); } public function testPostFlushFailure(): void @@ -223,11 +223,11 @@ public function testPostFlushFailure(): void try { $this->_em->persist($country); $this->_em->flush(); - $this->fail('Should throw exception'); + self::fail('Should throw exception'); } catch (RuntimeException $exc) { - $this->assertNotNull($country->getId()); - $this->assertEquals('post flush failure', $exc->getMessage()); - $this->assertTrue($this->cache->containsEntity(Country::class, $country->getId())); + self::assertNotNull($country->getId()); + self::assertEquals('post flush failure', $exc->getMessage()); + self::assertTrue($this->cache->containsEntity(Country::class, $country->getId())); } } @@ -254,9 +254,9 @@ public function testPostUpdateFailure(): void $stateName = $this->states[0]->getName(); $state = $this->_em->find(State::class, $stateId); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId)); - $this->assertInstanceOf(State::class, $state); - $this->assertEquals($stateName, $state->getName()); + self::assertTrue($this->cache->containsEntity(State::class, $stateId)); + self::assertInstanceOf(State::class, $state); + self::assertEquals($stateName, $state->getName()); $state->setName($stateName . uniqid()); @@ -264,19 +264,19 @@ public function testPostUpdateFailure(): void try { $this->_em->flush(); - $this->fail('Should throw exception'); + self::fail('Should throw exception'); } catch (Exception $exc) { - $this->assertEquals('post update failure', $exc->getMessage()); + self::assertEquals('post update failure', $exc->getMessage()); } $this->_em->clear(); - $this->assertTrue($this->cache->containsEntity(State::class, $stateId)); + self::assertTrue($this->cache->containsEntity(State::class, $stateId)); $state = $this->_em->find(State::class, $stateId); - $this->assertInstanceOf(State::class, $state); - $this->assertEquals($stateName, $state->getName()); + self::assertInstanceOf(State::class, $state); + self::assertEquals($stateName, $state->getName()); } public function testPostRemoveFailure(): void @@ -300,26 +300,26 @@ public function testPostRemoveFailure(): void $countryId = $this->countries[0]->getId(); $country = $this->_em->find(Country::class, $countryId); - $this->assertTrue($this->cache->containsEntity(Country::class, $countryId)); - $this->assertInstanceOf(Country::class, $country); + self::assertTrue($this->cache->containsEntity(Country::class, $countryId)); + self::assertInstanceOf(Country::class, $country); $this->_em->remove($country); try { $this->_em->flush(); - $this->fail('Should throw exception'); + self::fail('Should throw exception'); } catch (Exception $exc) { - $this->assertEquals('post remove failure', $exc->getMessage()); + self::assertEquals('post remove failure', $exc->getMessage()); } $this->_em->clear(); - $this->assertFalse( + self::assertFalse( $this->cache->containsEntity(Country::class, $countryId), 'Removal attempts should clear the cache entry corresponding to the entity' ); - $this->assertInstanceOf(Country::class, $this->_em->find(Country::class, $countryId)); + self::assertInstanceOf(Country::class, $this->_em->find(Country::class, $countryId)); } public function testCachedNewEntityExists(): void @@ -329,11 +329,11 @@ public function testCachedNewEntityExists(): void $persister = $this->_em->getUnitOfWork()->getEntityPersister(Country::class); $queryCount = $this->getCurrentQueryCount(); - $this->assertTrue($persister->exists($this->countries[0])); + self::assertTrue($persister->exists($this->countries[0])); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertFalse($persister->exists(new Country('Foo'))); + self::assertFalse($persister->exists(new Country('Foo'))); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php index b9e1e1f917a..4817a60e8e9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php @@ -22,7 +22,7 @@ protected function setUp(): void parent::setUp(); if (! $this->_em->getConnection()->getDatabasePlatform()->usesSequenceEmulatedIdentityColumns()) { - $this->markTestSkipped( + self::markTestSkipped( 'This test is special to platforms emulating IDENTITY key generation strategy through sequences.' ); } else { @@ -57,9 +57,9 @@ public function testPreSavePostSaveCallbacksAreInvoked(): void $entity->setValue('hello'); $this->_em->persist($entity); $this->_em->flush(); - $this->assertTrue(is_numeric($entity->getId())); - $this->assertTrue($entity->getId() > 0); - $this->assertTrue($this->_em->contains($entity)); + self::assertTrue(is_numeric($entity->getId())); + self::assertTrue($entity->getId() > 0); + self::assertTrue($this->_em->contains($entity)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php index c2b95f94a43..287b18775af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php @@ -21,7 +21,7 @@ protected function setUp(): void parent::setUp(); if (! $this->_em->getConnection()->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped('Only working for Databases that support sequences.'); + self::markTestSkipped('Only working for Databases that support sequences.'); } try { diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php index 821b7f1d8e1..1c7a4d95611 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php @@ -25,7 +25,7 @@ public function testInsertWithCompositeKey(): void $this->_em->clear(); $entity = $this->findEntity(); - $this->assertEquals($childEntity, $entity); + self::assertEquals($childEntity, $entity); } /** @@ -47,7 +47,7 @@ public function testUpdateWithCompositeKey(): void $this->_em->clear(); $persistedEntity = $this->findEntity(); - $this->assertEquals($entity, $persistedEntity); + self::assertEquals($entity, $persistedEntity); } private function findEntity(): SingleChildClass diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php index ac003f7f250..4365bb830cd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -131,9 +131,9 @@ public function testPersistChildOfBaseClass(): void $contract = $this->_em->find(CompanyFixContract::class, $fixContract->getId()); - $this->assertInstanceOf(CompanyFixContract::class, $contract); - $this->assertEquals(1000, $contract->getFixPrice()); - $this->assertEquals($this->salesPerson->getId(), $contract->getSalesPerson()->getId()); + self::assertInstanceOf(CompanyFixContract::class, $contract); + self::assertEquals(1000, $contract->getFixPrice()); + self::assertEquals($this->salesPerson->getId(), $contract->getSalesPerson()->getId()); } public function testPersistDeepChildOfBaseClass(): void @@ -152,10 +152,10 @@ public function testPersistDeepChildOfBaseClass(): void $contract = $this->_em->find(CompanyFlexUltraContract::class, $ultraContract->getId()); - $this->assertInstanceOf(CompanyFlexUltraContract::class, $contract); - $this->assertEquals(7000, $contract->getMaxPrice()); - $this->assertEquals(100, $contract->getHoursWorked()); - $this->assertEquals(50, $contract->getPricePerHour()); + self::assertInstanceOf(CompanyFlexUltraContract::class, $contract); + self::assertEquals(7000, $contract->getMaxPrice()); + self::assertEquals(100, $contract->getHoursWorked()); + self::assertEquals(50, $contract->getPricePerHour()); } public function testChildClassLifecycleUpdate(): void @@ -169,7 +169,7 @@ public function testChildClassLifecycleUpdate(): void $this->_em->clear(); $newFix = $this->_em->find(CompanyContract::class, $this->fix->getId()); - $this->assertEquals(2500, $newFix->getFixPrice()); + self::assertEquals(2500, $newFix->getFixPrice()); } public function testChildClassLifecycleRemove(): void @@ -180,7 +180,7 @@ public function testChildClassLifecycleRemove(): void $this->_em->remove($fix); $this->_em->flush(); - $this->assertNull($this->_em->find(CompanyContract::class, $this->fix->getId())); + self::assertNull($this->_em->find(CompanyContract::class, $this->fix->getId())); } public function testFindAllForAbstractBaseClass(): void @@ -188,17 +188,17 @@ public function testFindAllForAbstractBaseClass(): void $this->loadFullFixture(); $contracts = $this->_em->getRepository(CompanyContract::class)->findAll(); - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly(CompanyContract::class, $contracts); + self::assertEquals(3, count($contracts)); + self::assertContainsOnly(CompanyContract::class, $contracts); } public function testFindAllForChildClass(): void { $this->loadFullFixture(); - $this->assertEquals(1, count($this->_em->getRepository(CompanyFixContract::class)->findAll())); - $this->assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); - $this->assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); + self::assertEquals(1, count($this->_em->getRepository(CompanyFixContract::class)->findAll())); + self::assertEquals(2, count($this->_em->getRepository(CompanyFlexContract::class)->findAll())); + self::assertEquals(1, count($this->_em->getRepository(CompanyFlexUltraContract::class)->findAll())); } public function testFindForAbstractBaseClass(): void @@ -207,8 +207,8 @@ public function testFindForAbstractBaseClass(): void $contract = $this->_em->find(CompanyContract::class, $this->fix->getId()); - $this->assertInstanceOf(CompanyFixContract::class, $contract); - $this->assertEquals(1000, $contract->getFixPrice()); + self::assertInstanceOf(CompanyFixContract::class, $contract); + self::assertEquals(1000, $contract->getFixPrice()); } public function testQueryForAbstractBaseClass(): void @@ -217,17 +217,17 @@ public function testQueryForAbstractBaseClass(): void $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly(CompanyContract::class, $contracts); + self::assertEquals(3, count($contracts)); + self::assertContainsOnly(CompanyContract::class, $contracts); } public function testQueryForChildClass(): void { $this->loadFullFixture(); - $this->assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c')->getResult())); - $this->assertEquals(2, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexContract c')->getResult())); - $this->assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract c')->getResult())); + self::assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c')->getResult())); + self::assertEquals(2, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexContract c')->getResult())); + self::assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract c')->getResult())); } public function testQueryBaseClassWithJoin(): void @@ -235,8 +235,8 @@ public function testQueryBaseClassWithJoin(): void $this->loadFullFixture(); $contracts = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN c.salesPerson p')->getResult(); - $this->assertEquals(3, count($contracts)); - $this->assertContainsOnly(CompanyContract::class, $contracts); + self::assertEquals(3, count($contracts)); + self::assertContainsOnly(CompanyContract::class, $contracts); } public function testQueryScalarWithDiscriminatorValue(): void @@ -251,7 +251,7 @@ public function testQueryScalarWithDiscriminatorValue(): void sort($discrValues); - $this->assertEquals(['fix', 'flexible', 'flexultra'], $discrValues); + self::assertEquals(['fix', 'flexible', 'flexultra'], $discrValues); } public function testQueryChildClassWithCondition(): void @@ -261,8 +261,8 @@ public function testQueryChildClassWithCondition(): void $dql = 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c WHERE c.fixPrice = ?1'; $contract = $this->_em->createQuery($dql)->setParameter(1, 1000)->getSingleResult(); - $this->assertInstanceOf(CompanyFixContract::class, $contract); - $this->assertEquals(1000, $contract->getFixPrice()); + self::assertInstanceOf(CompanyFixContract::class, $contract); + self::assertEquals(1000, $contract->getFixPrice()); } /** @@ -275,13 +275,13 @@ public function testUpdateChildClassWithCondition(): void $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyFlexContract c SET c.hoursWorked = c.hoursWorked * 2 WHERE c.hoursWorked = 150'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(1, $affected); + self::assertEquals(1, $affected); $flexContract = $this->_em->find(CompanyContract::class, $this->flex->getId()); $ultraContract = $this->_em->find(CompanyContract::class, $this->ultra->getId()); - $this->assertEquals(300, $ultraContract->getHoursWorked()); - $this->assertEquals(100, $flexContract->getHoursWorked()); + self::assertEquals(300, $ultraContract->getHoursWorked()); + self::assertEquals(100, $flexContract->getHoursWorked()); } public function testUpdateBaseClassWithCondition(): void @@ -291,12 +291,12 @@ public function testUpdateBaseClassWithCondition(): void $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyContract c SET c.completed = true WHERE c.completed = false'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(1, $affected); + self::assertEquals(1, $affected); $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyContract c SET c.completed = false'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(3, $affected); + self::assertEquals(3, $affected); } public function testDeleteByChildClassCondition(): void @@ -306,7 +306,7 @@ public function testDeleteByChildClassCondition(): void $dql = 'DELETE Doctrine\Tests\Models\Company\CompanyFlexContract c'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(2, $affected); + self::assertEquals(2, $affected); } public function testDeleteByBaseClassCondition(): void @@ -316,12 +316,12 @@ public function testDeleteByBaseClassCondition(): void $dql = 'DELETE Doctrine\Tests\Models\Company\CompanyContract c WHERE c.completed = true'; $affected = $this->_em->createQuery($dql)->execute(); - $this->assertEquals(2, $affected); + self::assertEquals(2, $affected); $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); - $this->assertEquals(1, count($contracts)); + self::assertEquals(1, count($contracts)); - $this->assertFalse($contracts[0]->isCompleted(), 'Only non completed contracts should be left.'); + self::assertFalse($contracts[0]->isCompleted(), 'Only non completed contracts should be left.'); } /** @@ -335,7 +335,7 @@ public function testDeleteJoinTableRecords(): void $this->_em->remove($this->_em->find(get_class($this->fix), $this->fix->getId())); $this->_em->flush(); - $this->assertNull($this->_em->find(get_class($this->fix), $this->fix->getId()), 'Contract should not be present in the database anymore.'); + self::assertNull($this->_em->find(get_class($this->fix), $this->fix->getId()), 'Contract should not be present in the database anymore.'); } /** @@ -347,19 +347,19 @@ public function testFindByAssociation(): void $repos = $this->_em->getRepository(CompanyContract::class); $contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); - $this->assertEquals(3, count($contracts), 'There should be 3 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyContract'"); + self::assertEquals(3, count($contracts), 'There should be 3 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyContract'"); $repos = $this->_em->getRepository(CompanyFixContract::class); $contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); - $this->assertEquals(1, count($contracts), 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFixContract'"); + self::assertEquals(1, count($contracts), 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFixContract'"); $repos = $this->_em->getRepository(CompanyFlexContract::class); $contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); - $this->assertEquals(2, count($contracts), 'There should be 2 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexContract'"); + self::assertEquals(2, count($contracts), 'There should be 2 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexContract'"); $repos = $this->_em->getRepository(CompanyFlexUltraContract::class); $contracts = $repos->findBy(['salesPerson' => $this->salesPerson->getId()]); - $this->assertEquals(1, count($contracts), 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'"); + self::assertEquals(1, count($contracts), 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'"); } /** @@ -373,13 +373,13 @@ public function testInheritanceMatching(): void $contracts = $repository->matching(new Criteria( Criteria::expr()->eq('salesPerson', $this->salesPerson) )); - $this->assertEquals(3, count($contracts)); + self::assertEquals(3, count($contracts)); $repository = $this->_em->getRepository(CompanyFixContract::class); $contracts = $repository->matching(new Criteria( Criteria::expr()->eq('salesPerson', $this->salesPerson) )); - $this->assertEquals(1, count($contracts)); + self::assertEquals(1, count($contracts)); } /** @@ -410,13 +410,13 @@ public function testGetReferenceEntityWithSubclasses(): void $this->loadFullFixture(); $ref = $this->_em->getReference(CompanyContract::class, $this->fix->getId()); - $this->assertNotInstanceOf(Proxy::class, $ref, 'Cannot Request a proxy from a class that has subclasses.'); - $this->assertInstanceOf(CompanyContract::class, $ref); - $this->assertInstanceOf(CompanyFixContract::class, $ref, 'Direct fetch of the reference has to load the child class Employee directly.'); + self::assertNotInstanceOf(Proxy::class, $ref, 'Cannot Request a proxy from a class that has subclasses.'); + self::assertInstanceOf(CompanyContract::class, $ref); + self::assertInstanceOf(CompanyFixContract::class, $ref, 'Direct fetch of the reference has to load the child class Employee directly.'); $this->_em->clear(); $ref = $this->_em->getReference(CompanyFixContract::class, $this->fix->getId()); - $this->assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); + self::assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); } /** @@ -432,6 +432,6 @@ public function testEagerLoadInheritanceHierarchy(): void ->setParameter(1, $this->fix->getId()) ->getSingleResult(); - $this->assertNotInstanceOf(Proxy::class, $contract->getSalesPerson()); + self::assertNotInstanceOf(Proxy::class, $contract->getSalesPerson()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php index 401e06fa078..04fc0439e40 100644 --- a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php @@ -43,7 +43,7 @@ public function testAcceptsForeignKeysAsCriteria(): void $newCart = new ECommerceCart(); $this->_em->getUnitOfWork()->registerManaged($newCart, ['id' => $cardId], []); $persister->load(['customer_id' => $customer->getId()], $newCart, $class->associationMappings['customer']); - $this->assertEquals('Credit card', $newCart->getPayment()); + self::assertEquals('Credit card', $newCart->getPayment()); } /** @@ -64,8 +64,8 @@ public function testAddPersistRetrieve(): void $this->_em->flush(); - $this->assertEquals(2, count($p->getFeatures())); - $this->assertInstanceOf(PersistentCollection::class, $p->getFeatures()); + self::assertEquals(2, count($p->getFeatures())); + self::assertInstanceOf(PersistentCollection::class, $p->getFeatures()); $q = $this->_em->createQuery( 'SELECT p, f @@ -75,15 +75,15 @@ public function testAddPersistRetrieve(): void $res = $q->getResult(); - $this->assertEquals(2, count($p->getFeatures())); - $this->assertInstanceOf(PersistentCollection::class, $p->getFeatures()); + self::assertEquals(2, count($p->getFeatures())); + self::assertInstanceOf(PersistentCollection::class, $p->getFeatures()); // Check that the features are the same instances still foreach ($p->getFeatures() as $feature) { if ($feature->getDescription() === 'AC-3') { - $this->assertTrue($feature === $f1); + self::assertTrue($feature === $f1); } else { - $this->assertTrue($feature === $f2); + self::assertTrue($feature === $f2); } } @@ -106,6 +106,6 @@ public function testAddPersistRetrieve(): void $res = $q->getResult(); // Persisted Product now must have 3 Feature items - $this->assertEquals(3, count($res[0]->getFeatures())); + self::assertEquals(3, count($res[0]->getFeatures())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php index 84e6010e3ec..6230702185f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php @@ -51,7 +51,7 @@ public function testReuseNamedEntityParameter(): void ->setParameter('topic', 'This is John Galt speaking!') ->getSingleResult(); - $this->assertSame($article, $farticle); + self::assertSame($article, $farticle); } public function testUseMultiplePositionalParameters(): void @@ -77,6 +77,6 @@ public function testUseMultiplePositionalParameters(): void ->setParameter(3, $user) ->getSingleResult(); - $this->assertSame($article, $farticle); + self::assertSame($article, $farticle); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php index 14642a657c9..7769a883882 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -28,8 +28,8 @@ public function testGrabWrongSubtypeReturnsNull(): void $id = $fix->getId(); - $this->assertNull($this->_em->find(Models\Company\CompanyFlexContract::class, $id)); - $this->assertNull($this->_em->getReference(Models\Company\CompanyFlexContract::class, $id)); - $this->assertNull($this->_em->getPartialReference(Models\Company\CompanyFlexContract::class, $id)); + self::assertNull($this->_em->find(Models\Company\CompanyFlexContract::class, $id)); + self::assertNull($this->_em->getReference(Models\Company\CompanyFlexContract::class, $id)); + self::assertNull($this->_em->getPartialReference(Models\Company\CompanyFlexContract::class, $id)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php index 815e243caf4..54f6e75bdfc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php @@ -33,6 +33,6 @@ public function testChangeSetPlusWeirdPHPCastingIntCastingRule(): void $this->_em->clear(); $user = $this->_em->find(CmsUser::class, $user->id); - $this->assertSame('44', $user->status); + self::assertSame('44', $user->status); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index 17e8abb7d4c..f3b55b00a58 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -77,7 +77,7 @@ public function testHydration(): void $foo = $this->_em->find(DDC1080Foo::class, $foo1->getFooID()); $fooBars = $foo->getFooBars(); - $this->assertEquals(3, count($fooBars), 'Should return three foobars.'); + self::assertEquals(3, count($fooBars), 'Should return three foobars.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php index 4086715537e..a38509a9a89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php @@ -29,22 +29,22 @@ public function testVersionFieldIgnoredInChangesetComputation(): void $this->_em->persist($article); $this->_em->flush(); - $this->assertEquals(1, $article->version); + self::assertEquals(1, $article->version); $class = $this->_em->getClassMetadata(CmsArticle::class); $uow = $this->_em->getUnitOfWork(); $uow->computeChangeSet($class, $article); $changeSet = $uow->getEntityChangeSet($article); - $this->assertEquals(0, count($changeSet), 'No changesets should be computed.'); + self::assertEquals(0, count($changeSet), 'No changesets should be computed.'); $article->text = 'This is John Galt speaking.'; $this->_em->flush(); - $this->assertEquals(2, $article->version); + self::assertEquals(2, $article->version); $uow->computeChangeSet($class, $article); $changeSet = $uow->getEntityChangeSet($article); - $this->assertEquals(0, count($changeSet), 'No changesets should be computed.'); + self::assertEquals(0, count($changeSet), 'No changesets should be computed.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php index 67707a4c0cb..ac4f015ea12 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php @@ -21,7 +21,7 @@ class DDC1151Test extends OrmFunctionalTestCase public function testQuoteForeignKey(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { - $this->markTestSkipped('This test is useful for all databases, but designed only for postgresql.'); + self::markTestSkipped('This test is useful for all databases, but designed only for postgresql.'); } $sql = $this->_schemaTool->getCreateSchemaSql( @@ -31,15 +31,15 @@ public function testQuoteForeignKey(): void ] ); - $this->assertEquals('CREATE TABLE "User" (id INT NOT NULL, PRIMARY KEY(id))', $sql[0]); - $this->assertEquals('CREATE TABLE ddc1151user_ddc1151group (ddc1151user_id INT NOT NULL, ddc1151group_id INT NOT NULL, PRIMARY KEY(ddc1151user_id, ddc1151group_id))', $sql[1]); - $this->assertEquals('CREATE INDEX IDX_88A3259AC5AD08A ON ddc1151user_ddc1151group (ddc1151user_id)', $sql[2]); - $this->assertEquals('CREATE INDEX IDX_88A32597357E0B1 ON ddc1151user_ddc1151group (ddc1151group_id)', $sql[3]); - $this->assertEquals('CREATE TABLE "Group" (id INT NOT NULL, PRIMARY KEY(id))', $sql[4]); - $this->assertEquals('CREATE SEQUENCE "User_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', $sql[5]); - $this->assertEquals('CREATE SEQUENCE "Group_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', $sql[6]); - $this->assertEquals('ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A3259AC5AD08A FOREIGN KEY (ddc1151user_id) REFERENCES "User" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', $sql[7]); - $this->assertEquals('ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A32597357E0B1 FOREIGN KEY (ddc1151group_id) REFERENCES "Group" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', $sql[8]); + self::assertEquals('CREATE TABLE "User" (id INT NOT NULL, PRIMARY KEY(id))', $sql[0]); + self::assertEquals('CREATE TABLE ddc1151user_ddc1151group (ddc1151user_id INT NOT NULL, ddc1151group_id INT NOT NULL, PRIMARY KEY(ddc1151user_id, ddc1151group_id))', $sql[1]); + self::assertEquals('CREATE INDEX IDX_88A3259AC5AD08A ON ddc1151user_ddc1151group (ddc1151user_id)', $sql[2]); + self::assertEquals('CREATE INDEX IDX_88A32597357E0B1 ON ddc1151user_ddc1151group (ddc1151group_id)', $sql[3]); + self::assertEquals('CREATE TABLE "Group" (id INT NOT NULL, PRIMARY KEY(id))', $sql[4]); + self::assertEquals('CREATE SEQUENCE "User_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', $sql[5]); + self::assertEquals('CREATE SEQUENCE "Group_id_seq" INCREMENT BY 1 MINVALUE 1 START 1', $sql[6]); + self::assertEquals('ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A3259AC5AD08A FOREIGN KEY (ddc1151user_id) REFERENCES "User" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', $sql[7]); + self::assertEquals('ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A32597357E0B1 FOREIGN KEY (ddc1151group_id) REFERENCES "Group" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', $sql[8]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index 71daa538b8c..bb8c6ca17ca 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -81,7 +81,7 @@ private function createProxyForSpecialProduct(): void $proxyHolder = $this->_em->find(DDC1163ProxyHolder::class, $this->proxyHolderId); assert($proxyHolder instanceof DDC1163ProxyHolder); - $this->assertInstanceOf(DDC1163SpecialProduct::class, $proxyHolder->getSpecialProduct()); + self::assertInstanceOf(DDC1163SpecialProduct::class, $proxyHolder->getSpecialProduct()); } private function setPropertyAndAssignTagToSpecialProduct(): void @@ -89,13 +89,13 @@ private function setPropertyAndAssignTagToSpecialProduct(): void $specialProduct = $this->_em->find(DDC1163SpecialProduct::class, $this->productId); assert($specialProduct instanceof DDC1163SpecialProduct); - $this->assertInstanceOf(DDC1163SpecialProduct::class, $specialProduct); - $this->assertInstanceOf(Proxy::class, $specialProduct); + self::assertInstanceOf(DDC1163SpecialProduct::class, $specialProduct); + self::assertInstanceOf(Proxy::class, $specialProduct); $specialProduct->setSubclassProperty('foobar'); // this screams violation of law of demeter ;) - $this->assertEquals( + self::assertEquals( DDC1163SpecialProduct::class, $this->_em->getUnitOfWork()->getEntityPersister(get_class($specialProduct))->getClassMetadata()->name ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php index 7f28fc54a61..2791a9fc877 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -78,30 +78,30 @@ public function testAssociationOnlyCompositeKey(): void $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; $mapRef = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->assertInstanceOf(DDC117Reference::class, $mapRef); - $this->assertInstanceOf(DDC117Article::class, $mapRef->target()); - $this->assertInstanceOf(DDC117Article::class, $mapRef->source()); - $this->assertSame($mapRef, $this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertInstanceOf(DDC117Reference::class, $mapRef); + self::assertInstanceOf(DDC117Article::class, $mapRef->target()); + self::assertInstanceOf(DDC117Article::class, $mapRef->source()); + self::assertSame($mapRef, $this->_em->find(DDC117Reference::class, $idCriteria)); $this->_em->clear(); $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE r.source = ?1'; $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 1)->getSingleResult(); - $this->assertInstanceOf(DDC117Reference::class, $mapRef); - $this->assertInstanceOf(DDC117Article::class, $mapRef->target()); - $this->assertInstanceOf(DDC117Article::class, $mapRef->source()); - $this->assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertInstanceOf(DDC117Reference::class, $mapRef); + self::assertInstanceOf(DDC117Article::class, $mapRef->target()); + self::assertInstanceOf(DDC117Article::class, $mapRef->source()); + self::assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); $this->_em->clear(); $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE s.title = ?1'; $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); - $this->assertInstanceOf(DDC117Reference::class, $dqlRef); - $this->assertInstanceOf(DDC117Article::class, $dqlRef->target()); - $this->assertInstanceOf(DDC117Article::class, $dqlRef->source()); - $this->assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertInstanceOf(DDC117Reference::class, $dqlRef); + self::assertInstanceOf(DDC117Article::class, $dqlRef->target()); + self::assertInstanceOf(DDC117Article::class, $dqlRef->source()); + self::assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE s.title = ?1'; $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); @@ -117,14 +117,14 @@ public function testUpdateAssociationEntity(): void $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; $mapRef = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->assertNotNull($mapRef); + self::assertNotNull($mapRef); $mapRef->setDescription('New Description!!'); $this->_em->flush(); $this->_em->clear(); $mapRef = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->assertEquals('New Description!!', $mapRef->getDescription()); + self::assertEquals('New Description!!', $mapRef->getDescription()); } /** @@ -135,11 +135,11 @@ public function testFetchDql(): void $dql = 'SELECT r, s FROM Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1'; $refs = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getResult(); - $this->assertTrue(count($refs) > 0, 'Has to contain at least one Reference.'); + self::assertTrue(count($refs) > 0, 'Has to contain at least one Reference.'); foreach ($refs as $ref) { - $this->assertInstanceOf(DDC117Reference::class, $ref, 'Contains only Reference instances.'); - $this->assertTrue($this->_em->contains($ref), 'Contains Reference in the IdentityMap.'); + self::assertInstanceOf(DDC117Reference::class, $ref, 'Contains only Reference instances.'); + self::assertTrue($this->_em->contains($ref), 'Contains Reference in the IdentityMap.'); } } @@ -156,7 +156,7 @@ public function testRemoveCompositeElement(): void $this->_em->flush(); $this->_em->clear(); - $this->assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); } /** @@ -173,7 +173,7 @@ public function testDqlRemoveCompositeElement(): void ->setParameter(2, $this->article2->id()) ->execute(); - $this->assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); + self::assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); } /** @@ -183,11 +183,11 @@ public function testInverseSideAccess(): void { $this->article1 = $this->_em->find(DDC117Article::class, $this->article1->id()); - $this->assertEquals(1, count($this->article1->references())); + self::assertEquals(1, count($this->article1->references())); foreach ($this->article1->references() as $this->reference) { - $this->assertInstanceOf(DDC117Reference::class, $this->reference); - $this->assertSame($this->article1, $this->reference->source()); + self::assertInstanceOf(DDC117Reference::class, $this->reference); + self::assertSame($this->article1, $this->reference->source()); } $this->_em->clear(); @@ -197,11 +197,11 @@ public function testInverseSideAccess(): void ->setParameter(1, $this->article1->id()) ->getSingleResult(); - $this->assertEquals(1, count($this->article1->references())); + self::assertEquals(1, count($this->article1->references())); foreach ($this->article1->references() as $this->reference) { - $this->assertInstanceOf(DDC117Reference::class, $this->reference); - $this->assertSame($this->article1, $this->reference->source()); + self::assertInstanceOf(DDC117Reference::class, $this->reference); + self::assertSame($this->article1, $this->reference->source()); } } @@ -213,9 +213,9 @@ public function testMixedCompositeKey(): void $idCriteria = ['article' => $this->article1->id(), 'language' => 'en']; $this->translation = $this->_em->find(DDC117Translation::class, $idCriteria); - $this->assertInstanceOf(DDC117Translation::class, $this->translation); + self::assertInstanceOf(DDC117Translation::class, $this->translation); - $this->assertSame($this->translation, $this->_em->find(DDC117Translation::class, $idCriteria)); + self::assertSame($this->translation, $this->_em->find(DDC117Translation::class, $idCriteria)); $this->_em->clear(); @@ -225,7 +225,7 @@ public function testMixedCompositeKey(): void ->setParameter(2, 'en') ->getSingleResult(); - $this->assertInstanceOf(DDC117Translation::class, $this->translation); + self::assertInstanceOf(DDC117Translation::class, $this->translation); } /** @@ -245,7 +245,7 @@ public function testMixedCompositeKeyViolateUniqueness(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown, 'The underlying database driver throws an exception.'); + self::assertTrue($exceptionThrown, 'The underlying database driver throws an exception.'); } /** @@ -267,7 +267,7 @@ public function testOneToOneForeignObjectId(): void $article = $this->_em->find(get_class($this->article1), $this->article1->id()); assert($article instanceof DDC117Article); - $this->assertEquals('not so very long text!', $article->getText()); + self::assertEquals('not so very long text!', $article->getText()); } /** @@ -279,7 +279,7 @@ public function testOneToOneCascadeRemove(): void $this->_em->remove($article); $this->_em->flush(); - $this->assertFalse($this->_em->contains($article->getDetails())); + self::assertFalse($this->_em->contains($article->getDetails())); } /** @@ -288,7 +288,7 @@ public function testOneToOneCascadeRemove(): void public function testOneToOneCascadePersist(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->prefersSequences()) { - $this->markTestSkipped('Test only works with databases that prefer sequences as ID strategy.'); + self::markTestSkipped('Test only works with databases that prefer sequences as ID strategy.'); } $this->article1 = new DDC117Article('Foo'); @@ -318,9 +318,9 @@ public function testReferencesToForeignKeyEntities(): void $approveChanges = $this->_em->find(DDC117ApproveChanges::class, $approveChanges->getId()); - $this->assertInstanceOf(DDC117ArticleDetails::class, $approveChanges->getArticleDetails()); - $this->assertInstanceOf(DDC117Reference::class, $approveChanges->getReference()); - $this->assertInstanceOf(DDC117Translation::class, $approveChanges->getTranslation()); + self::assertInstanceOf(DDC117ArticleDetails::class, $approveChanges->getArticleDetails()); + self::assertInstanceOf(DDC117Reference::class, $approveChanges->getReference()); + self::assertInstanceOf(DDC117Translation::class, $approveChanges->getTranslation()); } /** @@ -332,9 +332,9 @@ public function testLoadOneToManyCollectionOfForeignKeyEntities(): void assert($article instanceof DDC117Article); $translations = $article->getTranslations(); - $this->assertFalse($translations->isInitialized()); - $this->assertContainsOnly(DDC117Translation::class, $translations); - $this->assertTrue($translations->isInitialized()); + self::assertFalse($translations->isInitialized()); + self::assertContainsOnly(DDC117Translation::class, $translations); + self::assertTrue($translations->isInitialized()); } /** @@ -344,16 +344,16 @@ public function testLoadManyToManyCollectionOfForeignKeyEntities(): void { $editor = $this->loadEditorFixture(); - $this->assertFalse($editor->reviewingTranslations->isInitialized()); - $this->assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); - $this->assertTrue($editor->reviewingTranslations->isInitialized()); + self::assertFalse($editor->reviewingTranslations->isInitialized()); + self::assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); + self::assertTrue($editor->reviewingTranslations->isInitialized()); $this->_em->clear(); $dql = 'SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE e.id = ?1'; $editor = $this->_em->createQuery($dql)->setParameter(1, $editor->id)->getSingleResult(); - $this->assertTrue($editor->reviewingTranslations->isInitialized()); - $this->assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); + self::assertTrue($editor->reviewingTranslations->isInitialized()); + self::assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); } /** @@ -362,14 +362,14 @@ public function testLoadManyToManyCollectionOfForeignKeyEntities(): void public function testClearManyToManyCollectionOfForeignKeyEntities(): void { $editor = $this->loadEditorFixture(); - $this->assertEquals(3, count($editor->reviewingTranslations)); + self::assertEquals(3, count($editor->reviewingTranslations)); $editor->reviewingTranslations->clear(); $this->_em->flush(); $this->_em->clear(); $editor = $this->_em->find(get_class($editor), $editor->id); - $this->assertEquals(0, count($editor->reviewingTranslations)); + self::assertEquals(0, count($editor->reviewingTranslations)); } /** @@ -379,11 +379,11 @@ public function testLoadInverseManyToManyCollection(): void { $editor = $this->loadEditorFixture(); - $this->assertInstanceOf(DDC117Translation::class, $editor->reviewingTranslations[0]); + self::assertInstanceOf(DDC117Translation::class, $editor->reviewingTranslations[0]); $reviewedBy = $editor->reviewingTranslations[0]->getReviewedByEditors(); - $this->assertEquals(1, count($reviewedBy)); - $this->assertSame($editor, $reviewedBy[0]); + self::assertEquals(1, count($reviewedBy)); + self::assertSame($editor, $reviewedBy[0]); $this->_em->clear(); @@ -394,9 +394,9 @@ public function testLoadInverseManyToManyCollection(): void ->setParameter(2, $this->translation->getLanguage()) ->getSingleResult(); - $this->assertInstanceOf(DDC117Translation::class, $trans); - $this->assertContainsOnly(DDC117Editor::class, $trans->reviewedByEditors); - $this->assertEquals(1, count($trans->reviewedByEditors)); + self::assertInstanceOf(DDC117Translation::class, $trans); + self::assertContainsOnly(DDC117Editor::class, $trans->reviewedByEditors); + self::assertEquals(1, count($trans->reviewedByEditors)); } /** @@ -414,7 +414,7 @@ public function testLoadOneToManyOfSourceEntityWithAssociationIdentifier(): void $lastTranslatedBy = $editor->reviewingTranslations[0]->getLastTranslatedBy(); $lastTranslatedBy->count(); - $this->assertEquals(1, count($lastTranslatedBy)); + self::assertEquals(1, count($lastTranslatedBy)); } private function loadEditorFixture(): DDC117Editor @@ -456,8 +456,8 @@ public function testMergeForeignKeyIdentifierEntity(): void $this->_em->clear(DDC117Reference::class); $refRep = $this->_em->merge($refRep); - $this->assertEquals($this->article1->id(), $refRep->source()->id()); - $this->assertEquals($this->article2->id(), $refRep->target()->id()); + self::assertEquals($this->article1->id(), $refRep->source()->id()); + self::assertEquals($this->article2->id(), $refRep->target()->id()); } /** @@ -485,7 +485,7 @@ public function testArrayHydrationWithCompositeKey(): void $dql = 'SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t'; $data = $this->_em->createQuery($dql)->getArrayResult(); - $this->assertEquals($before + 3, count($data)); + self::assertEquals($before + 3, count($data)); } /** @@ -494,7 +494,7 @@ public function testArrayHydrationWithCompositeKey(): void public function testGetEntityState(): void { if ($this->isSecondLevelCacheEnabled) { - $this->markTestIncomplete('Second level cache - not supported yet'); + self::markTestIncomplete('Second level cache - not supported yet'); } $this->article1 = $this->_em->find(DDC117Article::class, $this->article1->id()); @@ -502,12 +502,12 @@ public function testGetEntityState(): void $this->reference = new DDC117Reference($this->article2, $this->article1, 'Test-Description'); - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($this->reference)); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($this->reference)); $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; $reference = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($reference)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($reference)); } /** @@ -517,8 +517,8 @@ public function testIndexByOnCompositeKeyField(): void { $article = $this->_em->find(DDC117Article::class, $this->article1->id()); - $this->assertInstanceOf(DDC117Article::class, $article); - $this->assertEquals(1, count($article->getLinks())); - $this->assertTrue($article->getLinks()->offsetExists($this->article2->id())); + self::assertInstanceOf(DDC117Article::class, $article); + self::assertEquals(1, count($article->getLinks())); + self::assertTrue($article->getLinks()->offsetExists($this->article2->id())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index 9620dc0a491..785db21088b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -53,14 +53,14 @@ public function testIssue(): void $company = $this->_em->find(get_class($company), $companyId); - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), 'Company is in identity map.'); - $this->assertFalse($company->member->__isInitialized__, 'Pre-Condition'); - $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), 'Member is in identity map.'); + self::assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), 'Company is in identity map.'); + self::assertFalse($company->member->__isInitialized__, 'Pre-Condition'); + self::assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), 'Member is in identity map.'); $this->_em->remove($company); $this->_em->flush(); - $this->assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0); + self::assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index c9790db09eb..8ef5af902e4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -40,7 +40,7 @@ public function testIssue(): void ->where('te1.testEntity2 = ?1') ->setParameter(1, 0); - $this->assertEquals( + self::assertEquals( strtolower('SELECT t0_.test_entity2_id AS test_entity2_id_0 FROM te1 t0_ WHERE t0_.test_entity2_id = ?'), strtolower($qb->getQuery()->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php index c4fec217d30..010e3ba4e23 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php @@ -46,18 +46,18 @@ public function testOneToOnePersist(): void $user = $this->_em->find(DDC1228User::class, $user->id); - $this->assertFalse($user->getProfile()->__isInitialized__, 'Proxy is not initialized'); + self::assertFalse($user->getProfile()->__isInitialized__, 'Proxy is not initialized'); $user->getProfile()->setName('Bar'); - $this->assertTrue($user->getProfile()->__isInitialized__, 'Proxy is not initialized'); + self::assertTrue($user->getProfile()->__isInitialized__, 'Proxy is not initialized'); - $this->assertEquals('Bar', $user->getProfile()->getName()); - $this->assertEquals(['id' => 1, 'name' => 'Foo'], $this->_em->getUnitOfWork()->getOriginalEntityData($user->getProfile())); + self::assertEquals('Bar', $user->getProfile()->getName()); + self::assertEquals(['id' => 1, 'name' => 'Foo'], $this->_em->getUnitOfWork()->getOriginalEntityData($user->getProfile())); $this->_em->flush(); $this->_em->clear(); $user = $this->_em->find(DDC1228User::class, $user->id); - $this->assertEquals('Bar', $user->getProfile()->getName()); + self::assertEquals('Bar', $user->getProfile()->getName()); } public function testRefresh(): void @@ -80,7 +80,7 @@ public function testRefresh(): void $this->_em->clear(); $user = $this->_em->find(DDC1228User::class, $user->id); - $this->assertEquals('Baz', $user->name); + self::assertEquals('Baz', $user->name); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php index 6c434b2fc5f..81f3d9c1009 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -45,7 +45,7 @@ public function testIssue(): void $this->_em->clear(); $userId2 = $user->getId(); - $this->assertEquals($userId, $userId2, 'This proxy can still be initialized.'); + self::assertEquals($userId, $userId2, 'This proxy can still be initialized.'); } public function testIssueProxyClear(): void @@ -69,7 +69,7 @@ public function testIssueProxyClear(): void // force proxy load, getId() doesn't work anymore $user->getName(); - $this->assertNull($user->getId(), 'Now this is null, we already have a user instance of that type'); + self::assertNull($user->getId(), 'Now this is null, we already have a user instance of that type'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php index 561e8b2e838..cf31db6c7d5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -43,7 +43,7 @@ public function testIssue(): void $history = $this->_em->createQuery('SELECT h FROM ' . __NAMESPACE__ . '\\DDC1250ClientHistory h WHERE h.id = ?1') ->setParameter(1, $c2->id)->getSingleResult(); - $this->assertInstanceOf(DDC1250ClientHistory::class, $history); + self::assertInstanceOf(DDC1250ClientHistory::class, $history); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php index cfe5dcd9c14..600b49ca5f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php @@ -42,11 +42,11 @@ public function testIssue(): void $user = $this->_em->find(CmsUser::class, $user->id); $cloned = clone $user; - $this->assertSame($user->groups, $cloned->groups); - $this->assertEquals(2, count($user->groups)); + self::assertSame($user->groups, $cloned->groups); + self::assertEquals(2, count($user->groups)); $this->_em->merge($cloned); - $this->assertEquals(2, count($user->groups)); + self::assertEquals(2, count($user->groups)); $this->_em->flush(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php index 2c71a1a01ac..6dec4ac6a96 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php @@ -51,7 +51,7 @@ public function testIssue(): void $query = $this->_em->createQuery('SELECT f, fl FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1300Foo f JOIN f.fooLocaleRefFoo fl'); $result = $query->getResult(); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php index b58f71f4502..75720169f18 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php @@ -47,14 +47,14 @@ public function testCountNotInitializesLegacyCollection(): void $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->articles->isInitialized()); - $this->assertEquals(2, count($user->articles)); - $this->assertFalse($user->articles->isInitialized()); + self::assertFalse($user->articles->isInitialized()); + self::assertEquals(2, count($user->articles)); + self::assertFalse($user->articles->isInitialized()); foreach ($user->articles as $article) { } - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); } public function testCountNotInitializesLegacyCollectionWithForeignIdentifier(): void @@ -62,14 +62,14 @@ public function testCountNotInitializesLegacyCollectionWithForeignIdentifier(): $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->references->isInitialized()); - $this->assertEquals(2, count($user->references)); - $this->assertFalse($user->references->isInitialized()); + self::assertFalse($user->references->isInitialized()); + self::assertEquals(2, count($user->references)); + self::assertFalse($user->references->isInitialized()); foreach ($user->references as $reference) { } - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); } public function testCountNotInitializesLegacyManyToManyCollection(): void @@ -77,14 +77,14 @@ public function testCountNotInitializesLegacyManyToManyCollection(): void $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); $queryCount = $this->getCurrentQueryCount(); - $this->assertFalse($user->cars->isInitialized()); - $this->assertEquals(3, count($user->cars)); - $this->assertFalse($user->cars->isInitialized()); + self::assertFalse($user->cars->isInitialized()); + self::assertEquals(3, count($user->cars)); + self::assertFalse($user->cars->isInitialized()); foreach ($user->cars as $reference) { } - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); + self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), 'Expecting two queries to be fired for count, then iteration.'); } public function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index fae2f7f2e87..62ce120c827 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -44,39 +44,39 @@ public function testDql(): void $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey(1, $result); - $this->assertArrayHasKey(2, $result); - $this->assertArrayHasKey(3, $result); + self::assertEquals(count($result), 3); + self::assertArrayHasKey(1, $result); + self::assertArrayHasKey(2, $result); + self::assertArrayHasKey(3, $result); $dql = 'SELECT u, p FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id'; $query = $this->_em->createQuery($dql); $result = $query->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); + self::assertEquals(count($result), 3); + self::assertArrayHasKey('foo@foo.com', $result); + self::assertArrayHasKey('bar@bar.com', $result); + self::assertArrayHasKey('foobar@foobar.com', $result); - $this->assertEquals(count($result['foo@foo.com']->phones), 3); - $this->assertEquals(count($result['bar@bar.com']->phones), 3); - $this->assertEquals(count($result['foobar@foobar.com']->phones), 3); + self::assertEquals(count($result['foo@foo.com']->phones), 3); + self::assertEquals(count($result['bar@bar.com']->phones), 3); + self::assertEquals(count($result['foobar@foobar.com']->phones), 3); $foo = $result['foo@foo.com']->phones->toArray(); $bar = $result['bar@bar.com']->phones->toArray(); $foobar = $result['foobar@foobar.com']->phones->toArray(); - $this->assertArrayHasKey(1, $foo); - $this->assertArrayHasKey(2, $foo); - $this->assertArrayHasKey(3, $foo); + self::assertArrayHasKey(1, $foo); + self::assertArrayHasKey(2, $foo); + self::assertArrayHasKey(3, $foo); - $this->assertArrayHasKey(4, $bar); - $this->assertArrayHasKey(5, $bar); - $this->assertArrayHasKey(6, $bar); + self::assertArrayHasKey(4, $bar); + self::assertArrayHasKey(5, $bar); + self::assertArrayHasKey(6, $bar); - $this->assertArrayHasKey(7, $foobar); - $this->assertArrayHasKey(8, $foobar); - $this->assertArrayHasKey(9, $foobar); + self::assertArrayHasKey(7, $foobar); + self::assertArrayHasKey(8, $foobar); + self::assertArrayHasKey(9, $foobar); } public function testTicket(): void @@ -87,11 +87,11 @@ public function testTicket(): void $dql = $builder->getQuery()->getDQL(); $result = $builder->getQuery()->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey(1, $result); - $this->assertArrayHasKey(2, $result); - $this->assertArrayHasKey(3, $result); - $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id', $dql); + self::assertEquals(count($result), 3); + self::assertArrayHasKey(1, $result); + self::assertArrayHasKey(2, $result); + self::assertArrayHasKey(3, $result); + self::assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id', $dql); } public function testIndexByUnique(): void @@ -102,11 +102,11 @@ public function testIndexByUnique(): void $dql = $builder->getQuery()->getDQL(); $result = $builder->getQuery()->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); - $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email', $dql); + self::assertEquals(count($result), 3); + self::assertArrayHasKey('foo@foo.com', $result); + self::assertArrayHasKey('bar@bar.com', $result); + self::assertArrayHasKey('foobar@foobar.com', $result); + self::assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email', $dql); } public function testIndexWithJoin(): void @@ -119,28 +119,28 @@ public function testIndexWithJoin(): void $dql = $builder->getQuery()->getDQL(); $result = $builder->getQuery()->getResult(); - $this->assertEquals(count($result), 3); - $this->assertArrayHasKey('foo@foo.com', $result); - $this->assertArrayHasKey('bar@bar.com', $result); - $this->assertArrayHasKey('foobar@foobar.com', $result); + self::assertEquals(count($result), 3); + self::assertArrayHasKey('foo@foo.com', $result); + self::assertArrayHasKey('bar@bar.com', $result); + self::assertArrayHasKey('foobar@foobar.com', $result); - $this->assertEquals(count($result['foo@foo.com']->phones), 3); - $this->assertEquals(count($result['bar@bar.com']->phones), 3); - $this->assertEquals(count($result['foobar@foobar.com']->phones), 3); + self::assertEquals(count($result['foo@foo.com']->phones), 3); + self::assertEquals(count($result['bar@bar.com']->phones), 3); + self::assertEquals(count($result['foobar@foobar.com']->phones), 3); - $this->assertArrayHasKey(1, $result['foo@foo.com']->phones->toArray()); - $this->assertArrayHasKey(2, $result['foo@foo.com']->phones->toArray()); - $this->assertArrayHasKey(3, $result['foo@foo.com']->phones->toArray()); + self::assertArrayHasKey(1, $result['foo@foo.com']->phones->toArray()); + self::assertArrayHasKey(2, $result['foo@foo.com']->phones->toArray()); + self::assertArrayHasKey(3, $result['foo@foo.com']->phones->toArray()); - $this->assertArrayHasKey(4, $result['bar@bar.com']->phones->toArray()); - $this->assertArrayHasKey(5, $result['bar@bar.com']->phones->toArray()); - $this->assertArrayHasKey(6, $result['bar@bar.com']->phones->toArray()); + self::assertArrayHasKey(4, $result['bar@bar.com']->phones->toArray()); + self::assertArrayHasKey(5, $result['bar@bar.com']->phones->toArray()); + self::assertArrayHasKey(6, $result['bar@bar.com']->phones->toArray()); - $this->assertArrayHasKey(7, $result['foobar@foobar.com']->phones->toArray()); - $this->assertArrayHasKey(8, $result['foobar@foobar.com']->phones->toArray()); - $this->assertArrayHasKey(9, $result['foobar@foobar.com']->phones->toArray()); + self::assertArrayHasKey(7, $result['foobar@foobar.com']->phones->toArray()); + self::assertArrayHasKey(8, $result['foobar@foobar.com']->phones->toArray()); + self::assertArrayHasKey(9, $result['foobar@foobar.com']->phones->toArray()); - $this->assertEquals('SELECT u, p FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id', $dql); + self::assertEquals('SELECT u, p FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id', $dql); } private function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php index 63828451a80..29db8ae1026 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php @@ -19,7 +19,7 @@ class DDC1360Test extends OrmFunctionalTestCase public function testSchemaDoubleQuotedCreate(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { - $this->markTestSkipped('PostgreSQL only test.'); + self::markTestSkipped('PostgreSQL only test.'); } $sql = $this->_schemaTool->getCreateSchemaSql( @@ -28,7 +28,7 @@ public function testSchemaDoubleQuotedCreate(): void ] ); - $this->assertEquals( + self::assertEquals( [ 'CREATE SCHEMA user', 'CREATE TABLE "user"."user" (id INT NOT NULL, PRIMARY KEY(id))', diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php index eefedfc5707..05744bc93ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php @@ -49,10 +49,10 @@ public function testFailingCase(): void $fileId = $file->getFileId(); $pictureId = $picture->getPictureId(); - $this->assertTrue($fileId > 0); + self::assertTrue($fileId > 0); $picture = $em->find(DDC1392Picture::class, $pictureId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); $file = $picture->getFile(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php index 37ca6796527..3a18b029913 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php @@ -49,13 +49,13 @@ public function testTicket(): void $queryFirst = $repository->createNamedQuery('first'); $querySecond = $repository->createNamedQuery('second'); - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p', $queryAll->getDQL()); - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 1', $queryFirst->getDQL()); - $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 2', $querySecond->getDQL()); + self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p', $queryAll->getDQL()); + self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 1', $queryFirst->getDQL()); + self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 2', $querySecond->getDQL()); - $this->assertEquals(count($queryAll->getResult()), 2); - $this->assertEquals(count($queryFirst->getResult()), 1); - $this->assertEquals(count($querySecond->getResult()), 1); + self::assertEquals(count($queryAll->getResult()), 2); + self::assertEquals(count($queryFirst->getResult()), 1); + self::assertEquals(count($querySecond->getResult()), 1); } public function loadFixtures(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php index 0bd6ea7bf64..16806987ace 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php @@ -41,16 +41,16 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->clear(); $id = $user->id; - $this->assertNotNull($id); + self::assertNotNull($id); $user = $this->_em->find(User::class, $id); $address = $user->getAddress(); - $this->assertInstanceOf(User::class, $user); - $this->assertInstanceOf(Address::class, $user->getAddress()); + self::assertInstanceOf(User::class, $user); + self::assertInstanceOf(Address::class, $user->getAddress()); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals('12345', $address->zip); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals('12345', $address->zip); $user->name = 'FabioBatSilva1'; $user->address = null; @@ -61,15 +61,15 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->clear(); $user = $this->_em->find(User::class, $id); - $this->assertInstanceOf(User::class, $user); - $this->assertNull($user->getAddress()); + self::assertInstanceOf(User::class, $user); + self::assertNull($user->getAddress()); - $this->assertEquals('FabioBatSilva1', $user->name); + self::assertEquals('FabioBatSilva1', $user->name); $this->_em->remove($user); $this->_em->flush(); $this->_em->clear(); - $this->assertNull($this->_em->find(User::class, $id)); + self::assertNull($this->_em->find(User::class, $id)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index 1cc4e941cda..ee6b7e82697 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -54,19 +54,19 @@ public function testOrderByFields(): void $result = $query->getResult(); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertArrayHasKey('id', $result[0]); - $this->assertArrayHasKey('id', $result[1]); + self::assertArrayHasKey('id', $result[0]); + self::assertArrayHasKey('id', $result[1]); - $this->assertArrayHasKey('p_count', $result[0]); - $this->assertArrayHasKey('p_count', $result[1]); + self::assertArrayHasKey('p_count', $result[0]); + self::assertArrayHasKey('p_count', $result[1]); - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals(2, $result[1]['id']); + self::assertEquals(1, $result[0]['id']); + self::assertEquals(2, $result[1]['id']); - $this->assertEquals(2, $result[0]['p_count']); - $this->assertEquals(3, $result[1]['p_count']); + self::assertEquals(2, $result[0]['p_count']); + self::assertEquals(3, $result[1]['p_count']); } public function testOrderByAllObjectFields(): void @@ -84,16 +84,16 @@ public function testOrderByAllObjectFields(): void $result = $query->getResult(); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue($result[0][0] instanceof DDC1430Order); - $this->assertTrue($result[1][0] instanceof DDC1430Order); + self::assertTrue($result[0][0] instanceof DDC1430Order); + self::assertTrue($result[1][0] instanceof DDC1430Order); - $this->assertEquals($result[0][0]->getId(), 1); - $this->assertEquals($result[1][0]->getId(), 2); + self::assertEquals($result[0][0]->getId(), 1); + self::assertEquals($result[1][0]->getId(), 2); - $this->assertEquals($result[0]['p_count'], 2); - $this->assertEquals($result[1]['p_count'], 3); + self::assertEquals($result[0]['p_count'], 2); + self::assertEquals($result[1]['p_count'], 3); } public function testTicket(): void @@ -111,16 +111,16 @@ public function testTicket(): void $result = $query->getResult(); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue($result[0][0] instanceof DDC1430Order); - $this->assertTrue($result[1][0] instanceof DDC1430Order); + self::assertTrue($result[0][0] instanceof DDC1430Order); + self::assertTrue($result[1][0] instanceof DDC1430Order); - $this->assertEquals($result[0][0]->getId(), 1); - $this->assertEquals($result[1][0]->getId(), 2); + self::assertEquals($result[0][0]->getId(), 1); + self::assertEquals($result[1][0]->getId(), 2); - $this->assertEquals($result[0]['p_count'], 2); - $this->assertEquals($result[1]['p_count'], 3); + self::assertEquals($result[0]['p_count'], 2); + self::assertEquals($result[1]['p_count'], 3); } public function loadFixtures(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php index acbfdcb6610..8b62c7a4a7a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -54,13 +54,13 @@ public function testIdentityMap(): void ->setParameter('id', $id) ->getOneOrNullResult(); - $this->assertInstanceOf(DDC1436Page::class, $page); + self::assertInstanceOf(DDC1436Page::class, $page); // step 2 $page = $this->_em->find(DDC1436Page::class, $id); - $this->assertInstanceOf(DDC1436Page::class, $page); - $this->assertInstanceOf(DDC1436Page::class, $page->getParent()); - $this->assertInstanceOf(DDC1436Page::class, $page->getParent()->getParent()); + self::assertInstanceOf(DDC1436Page::class, $page); + self::assertInstanceOf(DDC1436Page::class, $page->getParent()); + self::assertInstanceOf(DDC1436Page::class, $page->getParent()->getParent()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php index 24e206d92ae..29ee1f119bf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -60,9 +60,9 @@ public function testIssue(): void $dql = 'SELECT a, b, ba FROM ' . __NAMESPACE__ . '\DDC1452EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba'; $results = $this->_em->createQuery($dql)->setMaxResults(1)->getResult(); - $this->assertSame($results[0], $results[0]->entitiesB[0]->entityAFrom); - $this->assertNotInstanceOf(Proxy::class, $results[0]->entitiesB[0]->entityATo); - $this->assertInstanceOf(Collection::class, $results[0]->entitiesB[0]->entityATo->getEntitiesB()); + self::assertSame($results[0], $results[0]->entitiesB[0]->entityAFrom); + self::assertNotInstanceOf(Proxy::class, $results[0]->entitiesB[0]->entityATo); + self::assertInstanceOf(Collection::class, $results[0]->entitiesB[0]->entityATo->getEntitiesB()); } public function testFetchJoinOneToOneFromInverse(): void @@ -89,12 +89,12 @@ public function testFetchJoinOneToOneFromInverse(): void $data = $this->_em->createQuery($dql)->getResult(); $this->_em->clear(); - $this->assertNotInstanceOf(Proxy::class, $data[0]->user); + self::assertNotInstanceOf(Proxy::class, $data[0]->user); $dql = 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.address a'; $data = $this->_em->createQuery($dql)->getResult(); - $this->assertNotInstanceOf(Proxy::class, $data[0]->address); + self::assertNotInstanceOf(Proxy::class, $data[0]->address); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php index eeafbb06b1c..3b9596ad71b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php @@ -34,7 +34,7 @@ public function testIssue(): void $this->_em->clear(); // So here the value is 3 - $this->assertEquals(3, $testEntity->getValue()); + self::assertEquals(3, $testEntity->getValue()); $test = $this->_em->getRepository(TestEntity::class)->find(1); @@ -42,19 +42,19 @@ public function testIssue(): void $test->setValue(5); // So here the value is 5 - $this->assertEquals(5, $test->getValue()); + self::assertEquals(5, $test->getValue()); // Get the additional entity $additional = $test->getAdditional(); // Still 5.. - $this->assertEquals(5, $test->getValue()); + self::assertEquals(5, $test->getValue()); // Force the proxy to load $additional->getBool(); // The value should still be 5 - $this->assertEquals(5, $test->getValue()); + self::assertEquals(5, $test->getValue()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index a13a4b4eae2..7e668d942bf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -42,8 +42,8 @@ public function testChangeDetectionDeferredExplicit(): void $this->_em->persist($user); $this->_em->flush(); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user, UnitOfWork::STATE_NEW), 'Entity should be managed.'); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), 'Entity should be managed.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user, UnitOfWork::STATE_NEW), 'Entity should be managed.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), 'Entity should be managed.'); $acc = new DDC1461TwitterAccount(); $user->twitterAccount = $acc; @@ -52,7 +52,7 @@ public function testChangeDetectionDeferredExplicit(): void $this->_em->flush(); $user = $this->_em->find(get_class($user), $user->id); - $this->assertNotNull($user->twitterAccount); + self::assertNotNull($user->twitterAccount); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php index 5667c8799af..10ba0c85bae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php @@ -59,8 +59,8 @@ public function testFailingCase(): void $pic = $em->merge($picture); assert($pic instanceof DDC1509Picture); - $this->assertNotNull($pic->getThumbnail()); - $this->assertNotNull($pic->getFile()); + self::assertNotNull($pic->getThumbnail()); + self::assertNotNull($pic->getFile()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php index c266d32ad71..41cf8418aa1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -67,11 +67,11 @@ public function testIssue(): void $dql = 'SELECT a, b, ba, c FROM ' . __NAMESPACE__ . '\DDC1514EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba LEFT JOIN a.entityC AS c ORDER BY a.title'; $results = $this->_em->createQuery($dql)->getResult(); - $this->assertEquals($a1->id, $results[0]->id); - $this->assertNull($results[0]->entityC); + self::assertEquals($a1->id, $results[0]->id); + self::assertNull($results[0]->entityC); - $this->assertEquals($a2->id, $results[1]->id); - $this->assertEquals($c->title, $results[1]->entityC->title); + self::assertEquals($a2->id, $results[1]->id); + self::assertEquals($c->title, $results[1]->entityC->title); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php index 9d75494ae2b..ddee8ea3d9d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -40,7 +40,7 @@ public function testIssue(): void $this->_em->clear(); $bar = $this->_em->find(DDC1515Bar::class, $bar->id); - $this->assertInstanceOf(DDC1515Foo::class, $bar->foo); + self::assertInstanceOf(DDC1515Foo::class, $bar->foo); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php index 69f5caffb27..9c0cdfea0ce 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php @@ -52,7 +52,7 @@ public function testIssue(): void // All Children collection now have to be initialized foreach ($menus as $menu) { - $this->assertTrue($menu->children->isInitialized()); + self::assertTrue($menu->children->isInitialized()); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php index 72ab55c9f94..43039d69d25 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php @@ -78,8 +78,8 @@ public function testLinkObjects(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNotNull($article->user); - $this->assertEquals($user->id, $article->user->id); + self::assertNotNull($article->user); + self::assertEquals($user->id, $article->user->id); } public function testLinkObjectsWithAssociationLoaded(): void @@ -104,8 +104,8 @@ public function testLinkObjectsWithAssociationLoaded(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNotNull($article->user); - $this->assertEquals($user->id, $article->user->id); + self::assertNotNull($article->user); + self::assertEquals($user->id, $article->user->id); } public function testUnlinkObjects(): void @@ -125,7 +125,7 @@ public function testUnlinkObjects(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNull($article->user); + self::assertNull($article->user); } public function testUnlinkObjectsWithAssociationLoaded(): void @@ -148,7 +148,7 @@ public function testUnlinkObjectsWithAssociationLoaded(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNull($article->user); + self::assertNull($article->user); } public function testChangeLink(): void @@ -170,8 +170,8 @@ public function testChangeLink(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNotNull($article->user); - $this->assertEquals($user2->id, $article->user->id); + self::assertNotNull($article->user); + self::assertEquals($user2->id, $article->user->id); } public function testChangeLinkWithAssociationLoaded(): void @@ -196,7 +196,7 @@ public function testChangeLinkWithAssociationLoaded(): void ->setParameter('id', $this->articleId) ->getOneOrNullResult(); - $this->assertNotNull($article->user); - $this->assertEquals($user2->id, $article->user->id); + self::assertNotNull($article->user); + self::assertEquals($user2->id, $article->user->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php index 54e924f6ac0..79aa61f7f4e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -42,7 +42,7 @@ public function testIssue(): void $obt = $this->_em->find(DDC1548Rel::class, $rel->id); - $this->assertNull($obt->e2); + self::assertNull($obt->e2); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php index e1e4da1e1bc..d8e6fed7f0b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php @@ -39,8 +39,8 @@ public function testIssue(): void $mergedUser = $this->_em->merge($detachedUser); - $this->assertNotSame($mergedUser, $detachedUser); - $this->assertEquals('bar', $detachedUser->getName()); - $this->assertEquals('bar', $mergedUser->getName()); + self::assertNotSame($mergedUser, $detachedUser); + self::assertEquals('bar', $detachedUser->getName()); + self::assertEquals('bar', $mergedUser->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php index 34e15054b45..12b28ded7a3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php @@ -64,7 +64,7 @@ public function testIssue(): void $entities = $entity1->getEntities()->getValues(); - $this->assertEquals( + self::assertEquals( "SELECT t0.id AS id_1, t0.type FROM base t0 INNER JOIN entity1_entity2 ON t0.id = entity1_entity2.item WHERE entity1_entity2.parent = ? AND t0.type IN ('Entity2')", $sqlLogger->queries[count($sqlLogger->queries)]['sql'] ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php index 5f6560dec34..c758eb04093 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php @@ -59,8 +59,8 @@ public function testQueryWithOrConditionUsingTwoRelationOnSameEntity(): void $q->setParameter('name2', 'p4'); $result = $q->getScalarResult(); - $this->assertEquals('p3', $result[0]['spouse_name']); - $this->assertEquals('p1', $result[0]['person_name']); - $this->assertEquals('p2', $result[0]['friend_name']); + self::assertEquals('p3', $result[0]['spouse_name']); + self::assertEquals('p1', $result[0]['person_name']); + self::assertEquals('p2', $result[0]['friend_name']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php index f335e3838df..424917753c9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php @@ -64,7 +64,7 @@ public function testClonePersistentCollectionAndReuse(): void $user1 = $this->_em->find(get_class($user1), $user1->id); - $this->assertEquals(2, count($user1->groups)); + self::assertEquals(2, count($user1->groups)); } public function testClonePersistentCollectionAndShare(): void @@ -80,8 +80,8 @@ public function testClonePersistentCollectionAndShare(): void $user1 = $this->_em->find(get_class($user1), $user1->id); $user2 = $this->_em->find(get_class($user1), $user2->id); - $this->assertEquals(2, count($user1->groups)); - $this->assertEquals(2, count($user2->groups)); + self::assertEquals(2, count($user1->groups)); + self::assertEquals(2, count($user2->groups)); } public function testCloneThenDirtyPersistentCollection(): void @@ -101,8 +101,8 @@ public function testCloneThenDirtyPersistentCollection(): void $user1 = $this->_em->find(get_class($user1), $user1->id); $user2 = $this->_em->find(get_class($user1), $user2->id); - $this->assertEquals(3, count($user2->groups)); - $this->assertEquals(2, count($user1->groups)); + self::assertEquals(3, count($user2->groups)); + self::assertEquals(2, count($user1->groups)); } public function testNotCloneAndPassAroundFlush(): void @@ -115,7 +115,7 @@ public function testNotCloneAndPassAroundFlush(): void $user2->groups = $user1->groups; $user2->groups->add($group3); - $this->assertCount(1, $user1->groups->getInsertDiff()); + self::assertCount(1, $user1->groups->getInsertDiff()); $this->_em->persist($group3); $this->_em->flush(); @@ -124,7 +124,7 @@ public function testNotCloneAndPassAroundFlush(): void $user1 = $this->_em->find(get_class($user1), $user1->id); $user2 = $this->_em->find(get_class($user1), $user2->id); - $this->assertEquals(3, count($user2->groups)); - $this->assertEquals(3, count($user1->groups)); + self::assertEquals(3, count($user2->groups)); + self::assertEquals(3, count($user1->groups)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php index eed59143409..b0760740389 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php @@ -54,7 +54,7 @@ public function testManyToManyRemoveFromCollectionOrphanRemoval(): void $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(0, count($comments)); + self::assertEquals(0, count($comments)); } public function testManyToManyRemoveElementFromCollectionOrphanRemoval(): void @@ -73,7 +73,7 @@ public function testManyToManyRemoveElementFromCollectionOrphanRemoval(): void $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(0, count($comments)); + self::assertEquals(0, count($comments)); } /** @@ -96,7 +96,7 @@ public function testManyToManyRemoveElementFromReAddToCollectionOrphanRemoval(): $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(2, count($comments)); + self::assertEquals(2, count($comments)); } public function testManyToManyClearCollectionOrphanRemoval(): void @@ -114,7 +114,7 @@ public function testManyToManyClearCollectionOrphanRemoval(): void $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(0, count($comments)); + self::assertEquals(0, count($comments)); } /** @@ -137,7 +137,7 @@ public function testManyToManyClearCollectionReAddOrphanRemoval(): void $this->_em->clear(); $comments = $this->_em->getRepository(DDC1654Comment::class)->findAll(); - $this->assertEquals(1, count($comments)); + self::assertEquals(1, count($comments)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index 93e287fd9c9..599c28ab0fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -46,10 +46,10 @@ protected function setUp(): void public function testPostLoadOneToManyInheritance(): void { $cm = $this->_em->getClassMetadata(DDC1655Foo::class); - $this->assertEquals(['postLoad' => ['postLoad']], $cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['postLoad']], $cm->lifecycleCallbacks); $cm = $this->_em->getClassMetadata(DDC1655Bar::class); - $this->assertEquals(['postLoad' => ['postLoad', 'postSubLoaded']], $cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['postLoad', 'postSubLoaded']], $cm->lifecycleCallbacks); $baz = new DDC1655Baz(); $foo = new DDC1655Foo(); @@ -65,7 +65,7 @@ public function testPostLoadOneToManyInheritance(): void $baz = $this->_em->find(get_class($baz), $baz->id); foreach ($baz->foos as $foo) { - $this->assertEquals(1, $foo->loaded, 'should have loaded callback counter incremented for ' . get_class($foo)); + self::assertEquals(1, $foo->loaded, 'should have loaded callback counter incremented for ' . get_class($foo)); } } @@ -82,23 +82,23 @@ public function testPostLoadInheritanceChild(): void $this->_em->clear(); $bar = $this->_em->find(get_class($bar), $bar->id); - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); + self::assertEquals(1, $bar->loaded); + self::assertEquals(1, $bar->subLoaded); $bar = $this->_em->find(get_class($bar), $bar->id); - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); + self::assertEquals(1, $bar->loaded); + self::assertEquals(1, $bar->subLoaded); $dql = 'SELECT b FROM ' . __NAMESPACE__ . '\DDC1655Bar b WHERE b.id = ?1'; $bar = $this->_em->createQuery($dql)->setParameter(1, $bar->id)->getSingleResult(); - $this->assertEquals(1, $bar->loaded); - $this->assertEquals(1, $bar->subLoaded); + self::assertEquals(1, $bar->loaded); + self::assertEquals(1, $bar->subLoaded); $this->_em->refresh($bar); - $this->assertEquals(2, $bar->loaded); - $this->assertEquals(2, $bar->subLoaded); + self::assertEquals(2, $bar->loaded); + self::assertEquals(2, $bar->subLoaded); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php index aba16f27ca4..9fd6311bd01 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php @@ -31,13 +31,13 @@ public function testGivenOrphanRemovalOneToOneWhenReplacingThenNoUniqueConstrain $this->_em->persist($user); $this->_em->flush(); - $this->assertTrue($this->_em->contains($email)); + self::assertTrue($this->_em->contains($email)); $user->setEmail($newEmail = new CmsEmail()); $newEmail->setEmail('benjamin.eberlei@googlemail.com'); $this->_em->flush(); - $this->assertFalse($this->_em->contains($email)); + self::assertFalse($this->_em->contains($email)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php index e9d956b910f..17a200b5712 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php @@ -44,20 +44,20 @@ protected function setUp(): void public function testPaginateCount(): void { - $this->assertEquals(1, count($this->paginator)); + self::assertEquals(1, count($this->paginator)); } public function testPaginateIterate(): void { foreach ($this->paginator as $ad) { - $this->assertInstanceOf(DDC117ArticleDetails::class, $ad); + self::assertInstanceOf(DDC117ArticleDetails::class, $ad); } } public function testPaginateCountNoOutputWalkers(): void { $this->paginator->setUseOutputWalkers(false); - $this->assertEquals(1, count($this->paginator)); + self::assertEquals(1, count($this->paginator)); } public function testPaginateIterateNoOutputWalkers(): void @@ -68,7 +68,7 @@ public function testPaginateIterateNoOutputWalkers(): void $this->expectExceptionMessage('Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator.'); foreach ($this->paginator as $ad) { - $this->assertInstanceOf(DDC117ArticleDetails::class, $ad); + self::assertInstanceOf(DDC117ArticleDetails::class, $ad); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php index 4640fadcd7a..a8a279cf52a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php @@ -61,10 +61,10 @@ public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFi $q->setParameter(1, 'Foo'); $theEmployee = $q->getSingleResult(); - $this->assertEquals('bar', $theEmployee->getDepartment()); - $this->assertEquals('Foo', $theEmployee->getName()); - $this->assertEquals(1000, $theEmployee->getSalary()); - $this->assertInstanceOf(CompanyEmployee::class, $theEmployee); - $this->assertInstanceOf(CompanyEmployee::class, $theEmployee->getSpouse()); + self::assertEquals('bar', $theEmployee->getDepartment()); + self::assertEquals('Foo', $theEmployee->getName()); + self::assertEquals(1000, $theEmployee->getSalary()); + self::assertInstanceOf(CompanyEmployee::class, $theEmployee); + self::assertInstanceOf(CompanyEmployee::class, $theEmployee->getSpouse()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php index a186057c072..f3eaddf8de3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php @@ -49,14 +49,14 @@ public function testChangeTracking(): void $this->_em->persist($parent); $this->_em->persist($child); - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); + self::assertEquals(1, count($parent->listeners)); + self::assertEquals(1, count($child->listeners)); $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); + self::assertEquals(1, count($parent->listeners)); + self::assertEquals(1, count($child->listeners)); $parentId = $parent->getId(); $childId = $child->getId(); @@ -65,25 +65,25 @@ public function testChangeTracking(): void $parent = $this->_em->find(DDC1690Parent::class, $parentId); $child = $this->_em->find(DDC1690Child::class, $childId); - $this->assertEquals(1, count($parent->listeners)); - $this->assertInstanceOf(Proxy::class, $child, 'Verifying that $child is a proxy before using proxy API'); - $this->assertCount(0, $child->listeners); + self::assertEquals(1, count($parent->listeners)); + self::assertInstanceOf(Proxy::class, $child, 'Verifying that $child is a proxy before using proxy API'); + self::assertCount(0, $child->listeners); $child->__load(); - $this->assertCount(1, $child->listeners); + self::assertCount(1, $child->listeners); unset($parent, $child); $parent = $this->_em->find(DDC1690Parent::class, $parentId); $child = $parent->getChild(); - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); + self::assertEquals(1, count($parent->listeners)); + self::assertEquals(1, count($child->listeners)); unset($parent, $child); $child = $this->_em->find(DDC1690Child::class, $childId); $parent = $child->getParent(); - $this->assertEquals(1, count($parent->listeners)); - $this->assertEquals(1, count($child->listeners)); + self::assertEquals(1, count($parent->listeners)); + self::assertEquals(1, count($child->listeners)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php index e2e74754911..91b157d3499 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -19,13 +19,13 @@ class DDC1695Test extends OrmFunctionalTestCase public function testIssue(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'sqlite') { - $this->markTestSkipped('Only with sqlite'); + self::markTestSkipped('Only with sqlite'); } $dql = 'SELECT n.smallText, n.publishDate FROM ' . __NAMESPACE__ . '\\DDC1695News n'; $sql = $this->_em->createQuery($dql)->getSQL(); - $this->assertEquals( + self::assertEquals( 'SELECT d0_."SmallText" AS SmallText_0, d0_."PublishDate" AS PublishDate_1 FROM "DDC1695News" d0_', $sql ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index 94006c888bf..3db0472597b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -43,7 +43,7 @@ public function testPostLoadOnChild(): void $class->invokeLifecycleCallbacks(Events::postLoad, $entity); - $this->assertTrue($entity->postLoad); + self::assertTrue($entity->postLoad); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php index 188cb87a1d2..da036428d89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php @@ -56,14 +56,14 @@ public function testCreateRetrieveUpdateDelete(): void $e1 = $this->_em->find(DDC1719SimpleEntity::class, $e1Id); $e2 = $this->_em->find(DDC1719SimpleEntity::class, $e2Id); - $this->assertInstanceOf(DDC1719SimpleEntity::class, $e1); - $this->assertInstanceOf(DDC1719SimpleEntity::class, $e2); + self::assertInstanceOf(DDC1719SimpleEntity::class, $e1); + self::assertInstanceOf(DDC1719SimpleEntity::class, $e2); - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); + self::assertEquals($e1Id, $e1->id); + self::assertEquals($e2Id, $e2->id); - $this->assertEquals('Bar 1', $e1->value); - $this->assertEquals('Foo 1', $e2->value); + self::assertEquals('Bar 1', $e1->value); + self::assertEquals('Foo 1', $e2->value); $e1->value = 'Bar 2'; $e2->value = 'Foo 2'; @@ -73,17 +73,17 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->persist($e2); $this->_em->flush(); - $this->assertEquals('Bar 2', $e1->value); - $this->assertEquals('Foo 2', $e2->value); + self::assertEquals('Bar 2', $e1->value); + self::assertEquals('Foo 2', $e2->value); - $this->assertInstanceOf(DDC1719SimpleEntity::class, $e1); - $this->assertInstanceOf(DDC1719SimpleEntity::class, $e2); + self::assertInstanceOf(DDC1719SimpleEntity::class, $e1); + self::assertInstanceOf(DDC1719SimpleEntity::class, $e2); - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); + self::assertEquals($e1Id, $e1->id); + self::assertEquals($e2Id, $e2->id); - $this->assertEquals('Bar 2', $e1->value); - $this->assertEquals('Foo 2', $e2->value); + self::assertEquals('Bar 2', $e1->value); + self::assertEquals('Foo 2', $e2->value); // Delete $this->_em->remove($e1); @@ -93,8 +93,8 @@ public function testCreateRetrieveUpdateDelete(): void $e1 = $this->_em->find(DDC1719SimpleEntity::class, $e1Id); $e2 = $this->_em->find(DDC1719SimpleEntity::class, $e2Id); - $this->assertNull($e1); - $this->assertNull($e2); + self::assertNull($e1); + self::assertNull($e2); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php index fa262d8e21a..3757fa3c941 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php @@ -36,15 +36,15 @@ public function testMergeWorksOnNonSerializedProxies(): void $proxy = $this->getProxy($group); - $this->assertInstanceOf(Proxy::class, $proxy); - $this->assertFalse($proxy->__isInitialized()); + self::assertInstanceOf(Proxy::class, $proxy); + self::assertFalse($proxy->__isInitialized()); $this->_em->detach($proxy); $this->_em->clear(); $proxy = $this->_em->merge($proxy); - $this->assertEquals('Foo', $proxy->getName(), 'The entity is broken'); + self::assertEquals('Foo', $proxy->getName(), 'The entity is broken'); } /** @@ -66,15 +66,15 @@ public function testMergeWorksOnSerializedProxies(): void $proxy = $this->getProxy($group); - $this->assertInstanceOf(Proxy::class, $proxy); - $this->assertFalse($proxy->__isInitialized()); + self::assertInstanceOf(Proxy::class, $proxy); + self::assertFalse($proxy->__isInitialized()); $this->_em->detach($proxy); $serializedProxy = serialize($proxy); $this->_em->clear(); $unserializedProxy = $this->_em->merge(unserialize($serializedProxy)); - $this->assertEquals('Foo', $unserializedProxy->getName(), 'The entity is broken'); + self::assertEquals('Foo', $unserializedProxy->getName(), 'The entity is broken'); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php index b87aec97f3b..23e4eeb3777 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php @@ -51,7 +51,7 @@ public function testClear(): void $this->user = $this->_em->find(CmsUser::class, $this->user->getId()); - $this->assertCount(1, $this->user->getPhonenumbers()); + self::assertCount(1, $this->user->getPhonenumbers()); } public function testRemove(): void @@ -63,7 +63,7 @@ public function testRemove(): void $this->user = $this->_em->find(CmsUser::class, $this->user->getId()); - $this->assertCount(1, $this->user->getPhonenumbers()); + self::assertCount(1, $this->user->getPhonenumbers()); } public function testRemoveElement(): void @@ -75,6 +75,6 @@ public function testRemoveElement(): void $this->user = $this->_em->find(CmsUser::class, $this->user->getId()); - $this->assertCount(1, $this->user->getPhonenumbers()); + self::assertCount(1, $this->user->getPhonenumbers()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php index 55afff72ab6..877aeb3f7cc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php @@ -38,7 +38,7 @@ public function testIssue(): void $this->_em->persist($bar2); $this->_em->flush(); - $this->assertSame(1, $bar->getVersion()); + self::assertSame(1, $bar->getVersion()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php index 571c818902e..cd037335bf2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php @@ -49,20 +49,20 @@ public function testCreateRetrieveUpdateDelete(): void $e3 = $this->_em->find(Group::class, $e3Id); $e4 = $this->_em->find(Group::class, $e4Id); - $this->assertInstanceOf(Group::class, $e1); - $this->assertInstanceOf(Group::class, $e2); - $this->assertInstanceOf(Group::class, $e3); - $this->assertInstanceOf(Group::class, $e4); + self::assertInstanceOf(Group::class, $e1); + self::assertInstanceOf(Group::class, $e2); + self::assertInstanceOf(Group::class, $e3); + self::assertInstanceOf(Group::class, $e4); - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); - $this->assertEquals($e3Id, $e3->id); - $this->assertEquals($e4Id, $e4->id); + self::assertEquals($e1Id, $e1->id); + self::assertEquals($e2Id, $e2->id); + self::assertEquals($e3Id, $e3->id); + self::assertEquals($e4Id, $e4->id); - $this->assertEquals('Parent Bar 1', $e1->name); - $this->assertEquals('Parent Foo 2', $e2->name); - $this->assertEquals('Bar 3', $e3->name); - $this->assertEquals('Foo 4', $e4->name); + self::assertEquals('Parent Bar 1', $e1->name); + self::assertEquals('Parent Foo 2', $e2->name); + self::assertEquals('Bar 3', $e3->name); + self::assertEquals('Foo 4', $e4->name); $e1->name = 'Parent Bar 11'; $e2->name = 'Parent Foo 22'; @@ -76,25 +76,25 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->persist($e4); $this->_em->flush(); - $this->assertEquals('Parent Bar 11', $e1->name); - $this->assertEquals('Parent Foo 22', $e2->name); - $this->assertEquals('Bar 33', $e3->name); - $this->assertEquals('Foo 44', $e4->name); + self::assertEquals('Parent Bar 11', $e1->name); + self::assertEquals('Parent Foo 22', $e2->name); + self::assertEquals('Bar 33', $e3->name); + self::assertEquals('Foo 44', $e4->name); - $this->assertInstanceOf(Group::class, $e1); - $this->assertInstanceOf(Group::class, $e2); - $this->assertInstanceOf(Group::class, $e3); - $this->assertInstanceOf(Group::class, $e4); + self::assertInstanceOf(Group::class, $e1); + self::assertInstanceOf(Group::class, $e2); + self::assertInstanceOf(Group::class, $e3); + self::assertInstanceOf(Group::class, $e4); - $this->assertEquals($e1Id, $e1->id); - $this->assertEquals($e2Id, $e2->id); - $this->assertEquals($e3Id, $e3->id); - $this->assertEquals($e4Id, $e4->id); + self::assertEquals($e1Id, $e1->id); + self::assertEquals($e2Id, $e2->id); + self::assertEquals($e3Id, $e3->id); + self::assertEquals($e4Id, $e4->id); - $this->assertEquals('Parent Bar 11', $e1->name); - $this->assertEquals('Parent Foo 22', $e2->name); - $this->assertEquals('Bar 33', $e3->name); - $this->assertEquals('Foo 44', $e4->name); + self::assertEquals('Parent Bar 11', $e1->name); + self::assertEquals('Parent Foo 22', $e2->name); + self::assertEquals('Bar 33', $e3->name); + self::assertEquals('Foo 44', $e4->name); // Delete $this->_em->remove($e4); @@ -105,10 +105,10 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->flush(); $this->_em->clear(); - $this->assertInstanceOf(Group::class, $e1); - $this->assertInstanceOf(Group::class, $e2); - $this->assertInstanceOf(Group::class, $e3); - $this->assertInstanceOf(Group::class, $e4); + self::assertInstanceOf(Group::class, $e1); + self::assertInstanceOf(Group::class, $e2); + self::assertInstanceOf(Group::class, $e3); + self::assertInstanceOf(Group::class, $e4); // Retrieve $e1 = $this->_em->find(Group::class, $e1Id); @@ -116,9 +116,9 @@ public function testCreateRetrieveUpdateDelete(): void $e3 = $this->_em->find(Group::class, $e3Id); $e4 = $this->_em->find(Group::class, $e4Id); - $this->assertNull($e1); - $this->assertNull($e2); - $this->assertNull($e3); - $this->assertNull($e4); + self::assertNull($e1); + self::assertNull($e2); + self::assertNull($e3); + self::assertNull($e4); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php index 0b8d1b63b1c..c31acf44e5e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php @@ -121,9 +121,9 @@ public function testSelectFromInverseSideWithCompositePkAndSolelyIdentifierColum ->getQuery() ->getArrayResult(); - $this->assertCount(1, $result); - $this->assertArrayHasKey('freeDriverRides', $result[0]); - $this->assertCount(3, $result[0]['freeDriverRides']); + self::assertCount(1, $result); + self::assertArrayHasKey('freeDriverRides', $result[0]); + self::assertCount(3, $result[0]['freeDriverRides']); } /** @@ -142,9 +142,9 @@ public function testSelectFromInverseSideWithCompositePkUsingFetchJoins(): void ->setParameter(1, 'John Doe') ->getQuery()->getArrayResult(); - $this->assertCount(1, $result); - $this->assertArrayHasKey('driverRides', $result[0]); - $this->assertCount(3, $result[0]['driverRides']); + self::assertCount(1, $result); + self::assertArrayHasKey('driverRides', $result[0]); + self::assertCount(3, $result[0]['driverRides']); } /** @@ -162,8 +162,8 @@ public function testSelectFromOwningSideUsingFetchJoins(): void ->setParameter(1, 'John Doe') ->getQuery()->getArrayResult(); - $this->assertCount(3, $result); - $this->assertArrayHasKey('driver', $result[0]); - $this->assertArrayHasKey('car', $result[0]); + self::assertCount(3, $result); + self::assertArrayHasKey('driver', $result[0]); + self::assertArrayHasKey('car', $result[0]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php index 54ae8f538f3..8ee1d7b7110 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php @@ -49,17 +49,17 @@ public function testCreateRetrieveUpdateDelete(): void // Retrieve $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(2, $user->groups); + self::assertCount(2, $user->groups); $g1 = $user->getGroups()->get(0); $g2 = $user->getGroups()->get(1); - $this->assertInstanceOf(Group::class, $g1); - $this->assertInstanceOf(Group::class, $g2); + self::assertInstanceOf(Group::class, $g1); + self::assertInstanceOf(Group::class, $g2); $g1->name = 'Bar 11'; $g2->name = 'Foo 22'; @@ -71,9 +71,9 @@ public function testCreateRetrieveUpdateDelete(): void $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); // Delete $this->_em->remove($user); @@ -81,9 +81,9 @@ public function testCreateRetrieveUpdateDelete(): void $this->_em->flush(); $this->_em->clear(); - $this->assertNull($this->_em->find(User::class, $u1Id)); - $this->assertNull($this->_em->find(Group::class, $g1Id)); - $this->assertNull($this->_em->find(Group::class, $g2Id)); + self::assertNull($this->_em->find(User::class, $u1Id)); + self::assertNull($this->_em->find(Group::class, $g1Id)); + self::assertNull($this->_em->find(Group::class, $g2Id)); } public function testRemoveItem(): void @@ -92,13 +92,13 @@ public function testRemoveItem(): void $u1Id = $user->id; $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(2, $user->groups); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(0)); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(1)); + self::assertCount(2, $user->groups); + self::assertInstanceOf(Group::class, $user->getGroups()->get(0)); + self::assertInstanceOf(Group::class, $user->getGroups()->get(1)); $user->getGroups()->remove(0); @@ -109,11 +109,11 @@ public function testRemoveItem(): void $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(1, $user->getGroups()); + self::assertCount(1, $user->getGroups()); } public function testClearAll(): void @@ -122,13 +122,13 @@ public function testClearAll(): void $u1Id = $user->id; $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(2, $user->groups); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(0)); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(1)); + self::assertCount(2, $user->groups); + self::assertInstanceOf(Group::class, $user->getGroups()->get(0)); + self::assertInstanceOf(Group::class, $user->getGroups()->get(1)); $user->getGroups()->clear(); @@ -139,11 +139,11 @@ public function testClearAll(): void $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(0, $user->getGroups()); + self::assertCount(0, $user->getGroups()); } public function testCountExtraLazy(): void @@ -152,12 +152,12 @@ public function testCountExtraLazy(): void $u1Id = $user->id; $user = $this->_em->find(User::class, $u1Id); - $this->assertInstanceOf(User::class, $user); - $this->assertEquals('FabioBatSilva', $user->name); - $this->assertEquals($u1Id, $user->id); + self::assertInstanceOf(User::class, $user); + self::assertEquals('FabioBatSilva', $user->name); + self::assertEquals($u1Id, $user->id); - $this->assertCount(2, $user->groups); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(0)); - $this->assertInstanceOf(Group::class, $user->getGroups()->get(1)); + self::assertCount(2, $user->groups); + self::assertInstanceOf(Group::class, $user->getGroups()->get(0)); + self::assertInstanceOf(Group::class, $user->getGroups()->get(1)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php index 15a1d0c9996..95cd33a4fa4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php @@ -51,18 +51,18 @@ public function testLastPageCorrect(): void $query->setMaxResults(3); $paginator = new Paginator($query, true); - $this->assertEquals(3, count(iterator_to_array($paginator))); + self::assertEquals(3, count(iterator_to_array($paginator))); $query->setFirstResult(8); $query->setMaxResults(3); $paginator = new Paginator($query, true); - $this->assertEquals(2, count(iterator_to_array($paginator))); + self::assertEquals(2, count(iterator_to_array($paginator))); $query->setFirstResult(10); $query->setMaxResults(3); $paginator = new Paginator($query, true); - $this->assertEquals(0, count(iterator_to_array($paginator))); + self::assertEquals(0, count(iterator_to_array($paginator))); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php index 84a5ff94c67..2e2cb0a5350 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php @@ -41,8 +41,8 @@ public function testIssue(): void ->setParameter(1, $class) ->getResult(); - $this->assertCount(1, $result); - $this->assertInstanceOf(CompanyEmployee::class, $result[0]); + self::assertCount(1, $result); + self::assertInstanceOf(CompanyEmployee::class, $result[0]); } public function testQueryCache(): void @@ -74,10 +74,10 @@ public function testQueryCache(): void ->useQueryCache(true) ->getResult(); - $this->assertCount(1, $result1); - $this->assertCount(2, $result2); + self::assertCount(1, $result1); + self::assertCount(2, $result2); - $this->assertInstanceOf(CompanyEmployee::class, $result1[0]); - $this->assertContainsOnlyInstancesOf(CompanyPerson::class, $result2); + self::assertInstanceOf(CompanyEmployee::class, $result1[0]); + self::assertContainsOnlyInstancesOf(CompanyPerson::class, $result2); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index c8485185d87..3ea25b78858 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -44,12 +44,12 @@ public function testSqlConversionAsIdentifier(): void $this->_em->clear(); $found = $this->_em->find(DDC1998Entity::class, $entity->id); - $this->assertNull($found); + self::assertNull($found); $found = $this->_em->find(DDC1998Entity::class, 'foo'); - $this->assertNull($found); + self::assertNull($found); - $this->assertEquals(0, count($this->_em->getRepository(DDC1998Entity::class)->findAll())); + self::assertEquals(0, count($this->_em->getRepository(DDC1998Entity::class)->findAll())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php index 74008a78952..59ac8d50e3b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php @@ -57,12 +57,12 @@ public function testPolymorphicLoading(): void $query = $this->_em->createQuery('select e,r from Doctrine\Tests\ORM\Functional\Ticket\DDC199ParentClass e join e.relatedEntities r'); $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(DDC199ParentClass::class, $result[0]); - $this->assertTrue($result[0]->relatedEntities->isInitialized()); - $this->assertEquals(2, $result[0]->relatedEntities->count()); - $this->assertInstanceOf(DDC199RelatedClass::class, $result[0]->relatedEntities[0]); - $this->assertInstanceOf(DDC199RelatedClass::class, $result[0]->relatedEntities[1]); + self::assertEquals(1, count($result)); + self::assertInstanceOf(DDC199ParentClass::class, $result[0]); + self::assertTrue($result[0]->relatedEntities->isInitialized()); + self::assertEquals(2, $result[0]->relatedEntities->count()); + self::assertInstanceOf(DDC199RelatedClass::class, $result[0]->relatedEntities[0]); + self::assertInstanceOf(DDC199RelatedClass::class, $result[0]->relatedEntities[1]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index e1c86841e14..860792f645d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -55,16 +55,16 @@ public function testIssue(): void $item = $this->_em->find(get_class($item), $item->id); - $this->assertArrayHasKey('convertToDatabaseValueSQL', DDC2012TsVectorType::$calls); - $this->assertArrayHasKey('convertToDatabaseValue', DDC2012TsVectorType::$calls); - $this->assertArrayHasKey('convertToPHPValue', DDC2012TsVectorType::$calls); + self::assertArrayHasKey('convertToDatabaseValueSQL', DDC2012TsVectorType::$calls); + self::assertArrayHasKey('convertToDatabaseValue', DDC2012TsVectorType::$calls); + self::assertArrayHasKey('convertToPHPValue', DDC2012TsVectorType::$calls); - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValue']); - $this->assertCount(1, DDC2012TsVectorType::$calls['convertToPHPValue']); + self::assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); + self::assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValue']); + self::assertCount(1, DDC2012TsVectorType::$calls['convertToPHPValue']); - $this->assertInstanceOf(DDC2012Item::class, $item); - $this->assertEquals(['word1', 'word2', 'word3'], $item->tsv); + self::assertInstanceOf(DDC2012Item::class, $item); + self::assertEquals(['word1', 'word2', 'word3'], $item->tsv); $item->tsv = ['word1', 'word2']; @@ -74,12 +74,12 @@ public function testIssue(): void $item = $this->_em->find(get_class($item), $item->id); - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValue']); - $this->assertCount(2, DDC2012TsVectorType::$calls['convertToPHPValue']); + self::assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); + self::assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValue']); + self::assertCount(2, DDC2012TsVectorType::$calls['convertToPHPValue']); - $this->assertInstanceOf(DDC2012Item::class, $item); - $this->assertEquals(['word1', 'word2'], $item->tsv); + self::assertInstanceOf(DDC2012Item::class, $item); + self::assertEquals(['word1', 'word2'], $item->tsv); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php index 19c45c3a963..cbb8f1c8d32 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php @@ -35,7 +35,7 @@ public function testShouldNotScheduleDeletionOnClonedInstances(): void $clonedCollection = clone $collection; $clonedCollection->clear(); - $this->assertEquals(0, count($uow->getScheduledCollectionDeletions())); + self::assertEquals(0, count($uow->getScheduledCollectionDeletions())); } public function testSavingClonedPersistentCollection(): void @@ -58,9 +58,9 @@ public function testSavingClonedPersistentCollection(): void $product1 = $this->_em->find(ECommerceProduct::class, $product->getId()); $product2 = $this->_em->find(ECommerceProduct::class, $newProduct->getId()); - $this->assertCount(1, $product1->getCategories()); - $this->assertCount(1, $product2->getCategories()); + self::assertCount(1, $product1->getCategories()); + self::assertCount(1, $product2->getCategories()); - $this->assertSame($product1->getCategories()->get(0), $product2->getCategories()->get(0)); + self::assertSame($product1->getCategories()->get(0), $product2->getCategories()->get(0)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php index 435f141752a..18e70e21a21 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php @@ -56,9 +56,9 @@ public function testIssue(): void $e2 = $e1->getMyEntity2(); $e = $this->_em->find(__NAMESPACE__ . '\DDC2084\MyEntity1', $e2); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC2084\MyEntity1', $e); - $this->assertInstanceOf(__NAMESPACE__ . '\DDC2084\MyEntity2', $e->getMyEntity2()); - $this->assertEquals('Foo', $e->getMyEntity2()->getValue()); + self::assertInstanceOf(__NAMESPACE__ . '\DDC2084\MyEntity1', $e); + self::assertInstanceOf(__NAMESPACE__ . '\DDC2084\MyEntity2', $e->getMyEntity2()); + self::assertEquals('Foo', $e->getMyEntity2()->getValue()); } public function testinvalidIdentifierBindingEntityException(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php index 124f66965a8..9cce7861ded 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php @@ -79,10 +79,10 @@ public function testIssue(): void $e1 = $this->_em->find(CompanyEmployee::class, $employee1->getId()); $e2 = $this->_em->find(CompanyEmployee::class, $employee2->getId()); - $this->assertEquals(101, $e1->getSalary()); - $this->assertEquals(102, $e2->getSalary()); - $this->assertEquals($date1, $e1->getStartDate()); - $this->assertEquals($date2, $e2->getStartDate()); + self::assertEquals(101, $e1->getSalary()); + self::assertEquals(102, $e2->getSalary()); + self::assertEquals($date1, $e1->getStartDate()); + self::assertEquals($date2, $e2->getStartDate()); $this->_em->createQueryBuilder() ->update(CompanyEmployee::class, 'e') @@ -109,9 +109,9 @@ public function testIssue(): void $e1 = $this->_em->find(CompanyEmployee::class, $employee1->getId()); $e2 = $this->_em->find(CompanyEmployee::class, $employee2->getId()); - $this->assertEquals(101, $e1->getSalary()); - $this->assertEquals(102, $e2->getSalary()); - $this->assertEquals($date1, $e1->getStartDate()); - $this->assertEquals($date2, $e2->getStartDate()); + self::assertEquals(101, $e1->getSalary()); + self::assertEquals(102, $e2->getSalary()); + self::assertEquals($date1, $e1->getStartDate()); + self::assertEquals($date2, $e2->getStartDate()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php index c9fc4b434a8..771812d6271 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php @@ -53,7 +53,7 @@ public function testIssue(): void } } - $this->assertEquals(4, $user->getGroups()->count()); + self::assertEquals(4, $user->getGroups()->count()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index 90ae4769293..098b9c78a3f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -43,22 +43,22 @@ public function testForeignKeyOnSTIWithMultipleMapping(): void ]; $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('users_followed_objects'), 'Table users_followed_objects should exist.'); + self::assertTrue($schema->hasTable('users_followed_objects'), 'Table users_followed_objects should exist.'); $table = $schema->getTable('users_followed_objects'); assert($table instanceof DbalTable); - $this->assertTrue($table->columnsAreIndexed(['object_id'])); - $this->assertTrue($table->columnsAreIndexed(['user_id'])); + self::assertTrue($table->columnsAreIndexed(['object_id'])); + self::assertTrue($table->columnsAreIndexed(['user_id'])); $foreignKeys = $table->getForeignKeys(); - $this->assertCount(1, $foreignKeys, 'user_id column has to have FK, but not object_id'); + self::assertCount(1, $foreignKeys, 'user_id column has to have FK, but not object_id'); $fk = reset($foreignKeys); assert($fk instanceof ForeignKeyConstraint); - $this->assertEquals('users', $fk->getForeignTableName()); + self::assertEquals('users', $fk->getForeignTableName()); $localColumns = $fk->getLocalColumns(); - $this->assertContains('user_id', $localColumns); - $this->assertCount(1, $localColumns); + self::assertContains('user_id', $localColumns); + self::assertCount(1, $localColumns); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php index 711fa39ff16..b6240a60ead 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php @@ -35,17 +35,17 @@ public function testIssue(): void $this->_em->persist($entity); $this->_em->flush(); - $this->assertEquals(1, $entity->version); + self::assertEquals(1, $entity->version); $entity->field = 'bar'; $this->_em->flush(); - $this->assertEquals(2, $entity->version); + self::assertEquals(2, $entity->version); $entity->field = 'baz'; $this->_em->flush(); - $this->assertEquals(3, $entity->version); + self::assertEquals(3, $entity->version); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php index 79f9d54d8b5..c3b471f1361 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -20,7 +20,7 @@ class DDC2182Test extends OrmFunctionalTestCase public function testPassColumnOptionsToJoinColumns(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - $this->markTestSkipped('This test is useful for all databases, but designed only for mysql.'); + self::markTestSkipped('This test is useful for all databases, but designed only for mysql.'); } $sql = $this->_schemaTool->getCreateSchemaSql( @@ -31,9 +31,9 @@ public function testPassColumnOptionsToJoinColumns(): void ); $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - $this->assertEquals('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); - $this->assertEquals('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); - $this->assertEquals('ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)', $sql[2]); + self::assertEquals('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); + self::assertEquals('ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)', $sql[2]); } private function getColumnCollationDeclarationSQL(string $collation): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php index 5cd0dcb60cc..24f2d427f9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php @@ -62,7 +62,7 @@ public function testIssue(): void $query = end($logger->queries); - $this->assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); + self::assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index ee1dbcfb4f9..77e311d4c37 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -34,7 +34,7 @@ public function testIssue(): Query $query->setQueryCacheDriver(DoctrineProvider::wrap(new ArrayAdapter())); $query->setParameter('field', 'test', 'DDC2224Type'); - $this->assertStringEndsWith('.field = FUNCTION(?)', $query->getSQL()); + self::assertStringEndsWith('.field = FUNCTION(?)', $query->getSQL()); return $query; } @@ -45,7 +45,7 @@ public function testIssue(): Query public function testCacheMissWhenTypeChanges(Query $query): void { $query->setParameter('field', 'test', 'string'); - $this->assertStringEndsWith('.field = ?', $query->getSQL()); + self::assertStringEndsWith('.field = ?', $query->getSQL()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index 17025923fd8..c8025dc6dc6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -57,8 +57,8 @@ public function testNotifyTrackingNotCalledOnUninitializedProxies(): void $address = $mergedUser->address; assert($address instanceof Proxy); - $this->assertInstanceOf(Proxy::class, $address); - $this->assertFalse($address->__isInitialized()); + self::assertInstanceOf(Proxy::class, $address); + self::assertFalse($address->__isInitialized()); } public function testNotifyTrackingCalledOnProxyInitialization(): void @@ -72,12 +72,12 @@ public function testNotifyTrackingCalledOnProxyInitialization(): void $addressProxy = $this->_em->getReference(DDC2230Address::class, $insertedAddress->id); assert($addressProxy instanceof Proxy || $addressProxy instanceof DDC2230Address); - $this->assertFalse($addressProxy->__isInitialized()); - $this->assertNull($addressProxy->listener); + self::assertFalse($addressProxy->__isInitialized()); + self::assertNull($addressProxy->listener); $addressProxy->__load(); - $this->assertSame($this->_em->getUnitOfWork(), $addressProxy->listener); + self::assertSame($this->_em->getUnitOfWork(), $addressProxy->listener); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php index 6cf8b76504e..d1037adee2b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php @@ -43,13 +43,13 @@ public function testInjectObjectManagerInProxyIfInitializedInUow(): void $y1ref = $this->_em->getReference(get_class($y1), $y1->id); - $this->assertInstanceOf(Proxy::class, $y1ref); - $this->assertFalse($y1ref->__isInitialized__); + self::assertInstanceOf(Proxy::class, $y1ref); + self::assertFalse($y1ref->__isInitialized__); $id = $y1ref->doSomething(); - $this->assertTrue($y1ref->__isInitialized__); - $this->assertEquals($this->_em, $y1ref->om); + self::assertTrue($y1ref->__isInitialized__); + self::assertEquals($this->_em, $y1ref->om); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index 56b7d3e80b7..3fa9b6488ef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -87,8 +87,8 @@ public function testIssue(): void $membership = $this->_em->find(DDC2252Membership::class, $identifier); - $this->assertInstanceOf(DDC2252Membership::class, $membership); - $this->assertCount(3, $membership->getPrivileges()); + self::assertInstanceOf(DDC2252Membership::class, $membership); + self::assertCount(3, $membership->getPrivileges()); $membership->getPrivileges()->remove(2); $this->_em->persist($membership); @@ -97,8 +97,8 @@ public function testIssue(): void $membership = $this->_em->find(DDC2252Membership::class, $identifier); - $this->assertInstanceOf(DDC2252Membership::class, $membership); - $this->assertCount(2, $membership->getPrivileges()); + self::assertInstanceOf(DDC2252Membership::class, $membership); + self::assertCount(2, $membership->getPrivileges()); $membership->getPrivileges()->clear(); $this->_em->persist($membership); @@ -107,8 +107,8 @@ public function testIssue(): void $membership = $this->_em->find(DDC2252Membership::class, $identifier); - $this->assertInstanceOf(DDC2252Membership::class, $membership); - $this->assertCount(0, $membership->getPrivileges()); + self::assertInstanceOf(DDC2252Membership::class, $membership); + self::assertCount(0, $membership->getPrivileges()); $membership->addPrivilege($privilege3 = new DDC2252Privilege()); $this->_em->persist($privilege3); @@ -118,8 +118,8 @@ public function testIssue(): void $membership = $this->_em->find(DDC2252Membership::class, $identifier); - $this->assertInstanceOf(DDC2252Membership::class, $membership); - $this->assertCount(1, $membership->getPrivileges()); + self::assertInstanceOf(DDC2252Membership::class, $membership); + self::assertCount(1, $membership->getPrivileges()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index 43c81aa5803..53b51bebde6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -69,16 +69,16 @@ public function testIssue(): void $user = $address->users->first()->user; assert($user instanceof DDC2306User || $user instanceof Proxy); - $this->assertInstanceOf(Proxy::class, $user); - $this->assertInstanceOf(DDC2306User::class, $user); + self::assertInstanceOf(Proxy::class, $user); + self::assertInstanceOf(DDC2306User::class, $user); $userId = $user->id; - $this->assertNotNull($userId); + self::assertNotNull($userId); $user->__load(); - $this->assertEquals( + self::assertEquals( $userId, $user->id, 'As of DDC-1734, the identifier is NULL for un-managed proxies. The identifier should be an integer here' diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index 43e1d41ef1c..9b3402c0b1d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -70,8 +70,8 @@ public function testIssue(): void $fetchedBazs = $this->_em->getRepository(DDC2346Baz::class)->findAll(); - $this->assertCount(2, $fetchedBazs); - $this->assertCount(2, $this->logger->queries, 'The total number of executed queries is 2, and not n+1'); + self::assertCount(2, $fetchedBazs); + self::assertCount(2, $this->logger->queries, 'The total number of executed queries is 2, and not n+1'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php index e4e337700b9..44e32d5553b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php @@ -51,11 +51,11 @@ public function testEagerCollectionsAreOnlyRetrievedOnce(): void $cnt = $this->getCurrentQueryCount(); $user = $this->_em->find(DDC2350User::class, $user->id); - $this->assertEquals($cnt + 1, $this->getCurrentQueryCount()); + self::assertEquals($cnt + 1, $this->getCurrentQueryCount()); - $this->assertEquals(2, count($user->reportedBugs)); + self::assertEquals(2, count($user->reportedBugs)); - $this->assertEquals($cnt + 1, $this->getCurrentQueryCount()); + self::assertEquals($cnt + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index 8ec7fd05391..db23318b16e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -47,23 +47,23 @@ public function testIssue(): void $connection = $this->createMock(Connection::class); $configuration - ->expects($this->any()) + ->expects(self::any()) ->method('getMetadataDriverImpl') - ->will($this->returnValue($mockDriver)); + ->will(self::returnValue($mockDriver)); - $entityManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($configuration)); - $entityManager->expects($this->any())->method('getConnection')->will($this->returnValue($connection)); + $entityManager->expects(self::any())->method('getConfiguration')->will(self::returnValue($configuration)); + $entityManager->expects(self::any())->method('getConnection')->will(self::returnValue($connection)); $entityManager - ->expects($this->any()) + ->expects(self::any()) ->method('getEventManager') - ->will($this->returnValue($this->createMock(EventManager::class))); + ->will(self::returnValue($this->createMock(EventManager::class))); - $metadataFactory->expects($this->any())->method('newClassMetadataInstance')->will($this->returnValue($mockMetadata)); - $metadataFactory->expects($this->once())->method('wakeupReflection'); + $metadataFactory->expects(self::any())->method('newClassMetadataInstance')->will(self::returnValue($mockMetadata)); + $metadataFactory->expects(self::once())->method('wakeupReflection'); $metadataFactory->setEntityManager($entityManager); - $this->assertSame($mockMetadata, $metadataFactory->getMetadataFor(DDC2359Foo::class)); + self::assertSame($mockMetadata, $metadataFactory->getMetadataFor(DDC2359Foo::class)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php index 5a5799241a8..d11ed2d0b42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -51,26 +51,26 @@ public function testUninitializedProxyIsInitializedOnFetchJoin(): void $this->_em->clear(); $x2 = $this->_em->find(get_class($x), $x->id); // proxy injected for Y - $this->assertInstanceOf(Proxy::class, $x2->y); - $this->assertFalse($x2->y->__isInitialized__); + self::assertInstanceOf(Proxy::class, $x2->y); + self::assertFalse($x2->y->__isInitialized__); // proxy for Y is in identity map $z2 = $this->_em->createQuery('select z,y from ' . get_class($z) . ' z join z.y y where z.id = ?1') ->setParameter(1, $z->id) ->getSingleResult(); - $this->assertInstanceOf(Proxy::class, $z2->y); - $this->assertTrue($z2->y->__isInitialized__); - $this->assertEquals('Y', $z2->y->data); - $this->assertEquals($y->id, $z2->y->id); + self::assertInstanceOf(Proxy::class, $z2->y); + self::assertTrue($z2->y->__isInitialized__); + self::assertEquals('Y', $z2->y->data); + self::assertEquals($y->id, $z2->y->id); // since the Y is the same, the instance from the identity map is // used, even if it is a proxy. - $this->assertNotSame($x, $x2); - $this->assertNotSame($z, $z2); - $this->assertSame($z2->y, $x2->y); - $this->assertInstanceOf(Proxy::class, $z2->y); + self::assertNotSame($x, $x2); + self::assertNotSame($z, $z2); + self::assertSame($z2->y, $x2->y); + self::assertInstanceOf(Proxy::class, $z2->y); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php index 719ed49e14a..8ac3c3c4f31 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php @@ -27,7 +27,7 @@ public function testCompositeAssociationKeyDetection(): void $metadata = $this->convertToClassMetadata([$product, $attributes], []); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $metadata['Ddc2387Attributes']->generatorType); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_AUTO, $metadata['Ddc2387Product']->generatorType); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $metadata['Ddc2387Attributes']->generatorType); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_AUTO, $metadata['Ddc2387Product']->generatorType); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php index f8443b7c189..ee9b654fcd1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php @@ -51,10 +51,10 @@ public function testIssue(): void $article->setAuthor($user); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalArticle)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalUser)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($article)); - $this->assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalArticle)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalUser)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($article)); + self::assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); $em->clear(CmsUser::class); $em->clear(CmsArticle::class); @@ -62,14 +62,14 @@ public function testIssue(): void $userMerged = $em->merge($user); $articleMerged = $em->merge($article); - $this->assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); - $this->assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($article)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($userMerged)); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($articleMerged)); + self::assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); + self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($article)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($userMerged)); + self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($articleMerged)); - $this->assertNotSame($user, $userMerged); - $this->assertNotSame($article, $articleMerged); - $this->assertNotSame($userMerged, $articleMerged->user); - $this->assertSame($user, $articleMerged->user); + self::assertNotSame($user, $userMerged); + self::assertNotSame($article, $articleMerged); + self::assertNotSame($userMerged, $articleMerged->user); + self::assertSame($user, $articleMerged->user); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php index 6773ed4c3b5..0c74c1fe92c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php @@ -36,9 +36,9 @@ public function testTicket(): void $parentMetadata = $this->_em->getClassMetadata(DDC2415ParentEntity::class); $childMetadata = $this->_em->getClassMetadata(DDC2415ChildEntity::class); - $this->assertEquals($parentMetadata->generatorType, $childMetadata->generatorType); - $this->assertEquals($parentMetadata->customGeneratorDefinition, $childMetadata->customGeneratorDefinition); - $this->assertEquals(DDC2415Generator::class, $parentMetadata->customGeneratorDefinition['class']); + self::assertEquals($parentMetadata->generatorType, $childMetadata->generatorType); + self::assertEquals($parentMetadata->customGeneratorDefinition, $childMetadata->customGeneratorDefinition); + self::assertEquals(DDC2415Generator::class, $parentMetadata->customGeneratorDefinition['class']); $e1 = new DDC2415ChildEntity('ChildEntity 1'); $e2 = new DDC2415ChildEntity('ChildEntity 2'); @@ -48,8 +48,8 @@ public function testTicket(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals(md5($e1->getName()), $e1->getId()); - $this->assertEquals(md5($e2->getName()), $e2->getId()); + self::assertEquals(md5($e1->getName()), $e1->getId()); + self::assertEquals(md5($e2->getName()), $e2->getId()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index b0e1f244139..ecf0c9b4408 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -52,33 +52,33 @@ public function testIssue(): void $this->_em->flush(); $this->_em->close(); - $this->assertArrayHasKey('convertToDatabaseValue', DDC2494TinyIntType::$calls); - $this->assertCount(3, DDC2494TinyIntType::$calls['convertToDatabaseValue']); + self::assertArrayHasKey('convertToDatabaseValue', DDC2494TinyIntType::$calls); + self::assertCount(3, DDC2494TinyIntType::$calls['convertToDatabaseValue']); $item = $this->_em->find(DDC2494Campaign::class, $campaign->getId()); - $this->assertInstanceOf(DDC2494Campaign::class, $item); - $this->assertInstanceOf(DDC2494Currency::class, $item->getCurrency()); + self::assertInstanceOf(DDC2494Campaign::class, $item); + self::assertInstanceOf(DDC2494Currency::class, $item->getCurrency()); $queryCount = $this->getCurrentQueryCount(); - $this->assertInstanceOf('\Doctrine\Common\Proxy\Proxy', $item->getCurrency()); - $this->assertFalse($item->getCurrency()->__isInitialized()); + self::assertInstanceOf('\Doctrine\Common\Proxy\Proxy', $item->getCurrency()); + self::assertFalse($item->getCurrency()->__isInitialized()); - $this->assertArrayHasKey('convertToPHPValue', DDC2494TinyIntType::$calls); - $this->assertCount(1, DDC2494TinyIntType::$calls['convertToPHPValue']); + self::assertArrayHasKey('convertToPHPValue', DDC2494TinyIntType::$calls); + self::assertCount(1, DDC2494TinyIntType::$calls['convertToPHPValue']); - $this->assertIsInt($item->getCurrency()->getId()); - $this->assertCount(1, DDC2494TinyIntType::$calls['convertToPHPValue']); - $this->assertFalse($item->getCurrency()->__isInitialized()); + self::assertIsInt($item->getCurrency()->getId()); + self::assertCount(1, DDC2494TinyIntType::$calls['convertToPHPValue']); + self::assertFalse($item->getCurrency()->__isInitialized()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertIsInt($item->getCurrency()->getTemp()); - $this->assertCount(3, DDC2494TinyIntType::$calls['convertToPHPValue']); - $this->assertTrue($item->getCurrency()->__isInitialized()); + self::assertIsInt($item->getCurrency()->getTemp()); + self::assertCount(3, DDC2494TinyIntType::$calls['convertToPHPValue']); + self::assertTrue($item->getCurrency()->__isInitialized()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php index 1fddd12bb9b..0af5d161883 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php @@ -30,29 +30,29 @@ public function testIssue(): void $dql = 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l'; $result = $this->_em->createQuery($dql)->getResult(); - $this->assertCount(2, $result); - $this->assertInstanceOf(LegacyUserReference::class, $result[0]); - $this->assertInstanceOf(LegacyUserReference::class, $result[1]); - - $this->assertInstanceOf(LegacyUser::class, $result[0]->source()); - $this->assertInstanceOf(LegacyUser::class, $result[0]->target()); - $this->assertInstanceOf(LegacyUser::class, $result[1]->source()); - $this->assertInstanceOf(LegacyUser::class, $result[1]->target()); - - $this->assertInstanceOf(Proxy::class, $result[0]->source()); - $this->assertInstanceOf(Proxy::class, $result[0]->target()); - $this->assertInstanceOf(Proxy::class, $result[1]->source()); - $this->assertInstanceOf(Proxy::class, $result[1]->target()); - - $this->assertFalse($result[0]->target()->__isInitialized()); - $this->assertFalse($result[0]->source()->__isInitialized()); - $this->assertFalse($result[1]->target()->__isInitialized()); - $this->assertFalse($result[1]->source()->__isInitialized()); - - $this->assertNotNull($result[0]->source()->getId()); - $this->assertNotNull($result[0]->target()->getId()); - $this->assertNotNull($result[1]->source()->getId()); - $this->assertNotNull($result[1]->target()->getId()); + self::assertCount(2, $result); + self::assertInstanceOf(LegacyUserReference::class, $result[0]); + self::assertInstanceOf(LegacyUserReference::class, $result[1]); + + self::assertInstanceOf(LegacyUser::class, $result[0]->source()); + self::assertInstanceOf(LegacyUser::class, $result[0]->target()); + self::assertInstanceOf(LegacyUser::class, $result[1]->source()); + self::assertInstanceOf(LegacyUser::class, $result[1]->target()); + + self::assertInstanceOf(Proxy::class, $result[0]->source()); + self::assertInstanceOf(Proxy::class, $result[0]->target()); + self::assertInstanceOf(Proxy::class, $result[1]->source()); + self::assertInstanceOf(Proxy::class, $result[1]->target()); + + self::assertFalse($result[0]->target()->__isInitialized()); + self::assertFalse($result[0]->source()->__isInitialized()); + self::assertFalse($result[1]->target()->__isInitialized()); + self::assertFalse($result[1]->source()->__isInitialized()); + + self::assertNotNull($result[0]->source()->getId()); + self::assertNotNull($result[0]->target()->getId()); + self::assertNotNull($result[1]->source()->getId()); + self::assertNotNull($result[1]->target()->getId()); } public function loadFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index b6b46c05d6b..762704d232b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -79,23 +79,23 @@ public function testHydrationIssue(): void $query = $qb->getQuery(); $result = $query->getResult(); - $this->assertCount(2, $result); + self::assertCount(2, $result); $row = $result[0]; - $this->assertNotNull($row->aRelation); - $this->assertEquals(1, $row->id); - $this->assertNotNull($row->aRelation->rootRelation); - $this->assertSame($row, $row->aRelation->rootRelation); - $this->assertNotNull($row->aRelation->bRelation); - $this->assertEquals(2, $row->aRelation->bRelation->id); + self::assertNotNull($row->aRelation); + self::assertEquals(1, $row->id); + self::assertNotNull($row->aRelation->rootRelation); + self::assertSame($row, $row->aRelation->rootRelation); + self::assertNotNull($row->aRelation->bRelation); + self::assertEquals(2, $row->aRelation->bRelation->id); $row = $result[1]; - $this->assertNotNull($row->aRelation); - $this->assertEquals(3, $row->id); - $this->assertNotNull($row->aRelation->rootRelation); - $this->assertSame($row, $row->aRelation->rootRelation); - $this->assertNotNull($row->aRelation->bRelation); - $this->assertEquals(4, $row->aRelation->bRelation->id); + self::assertNotNull($row->aRelation); + self::assertEquals(3, $row->id); + self::assertNotNull($row->aRelation->rootRelation); + self::assertSame($row, $row->aRelation->rootRelation); + self::assertNotNull($row->aRelation->bRelation); + self::assertEquals(4, $row->aRelation->bRelation->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index 209c87bda11..053680fbe86 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -58,15 +58,15 @@ public function testIssue(): void $criteria = ['assoc' => $assoc, 'id' => $id]; $entity = $repository->findOneBy($criteria); - $this->assertInstanceOf(DDC2579Entity::class, $entity); - $this->assertEquals($value, $entity->value); + self::assertInstanceOf(DDC2579Entity::class, $entity); + self::assertEquals($value, $entity->value); $this->_em->remove($entity); $this->_em->flush(); $this->_em->clear(); - $this->assertNull($repository->findOneBy($criteria)); - $this->assertCount(0, $repository->findAll()); + self::assertNull($repository->findOneBy($criteria)); + self::assertCount(0, $repository->findAll()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php index 753f090fabf..2159d6aeeb8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -57,27 +57,27 @@ public function testIssue(): void $e2 = $this->_em->find(DDC258Super::class, $c2->id); - $this->assertInstanceOf(DDC258Class2::class, $e2); - $this->assertEquals('Bar', $e2->title); - $this->assertEquals('Bar', $e2->description); - $this->assertEquals('Bar', $e2->text); + self::assertInstanceOf(DDC258Class2::class, $e2); + self::assertEquals('Bar', $e2->title); + self::assertEquals('Bar', $e2->description); + self::assertEquals('Bar', $e2->text); $all = $this->_em->getRepository(DDC258Super::class)->findAll(); foreach ($all as $obj) { if ($obj instanceof DDC258Class1) { - $this->assertEquals('Foo', $obj->title); - $this->assertEquals('Foo', $obj->description); + self::assertEquals('Foo', $obj->title); + self::assertEquals('Foo', $obj->description); } elseif ($obj instanceof DDC258Class2) { - $this->assertTrue($e2 === $obj); - $this->assertEquals('Bar', $obj->title); - $this->assertEquals('Bar', $obj->description); - $this->assertEquals('Bar', $obj->text); + self::assertTrue($e2 === $obj); + self::assertEquals('Bar', $obj->title); + self::assertEquals('Bar', $obj->description); + self::assertEquals('Bar', $obj->text); } elseif ($obj instanceof DDC258Class3) { - $this->assertEquals('Baz', $obj->apples); - $this->assertEquals('Baz', $obj->bananas); + self::assertEquals('Baz', $obj->apples); + self::assertEquals('Baz', $obj->bananas); } else { - $this->fail('Instance of DDC258Class1, DDC258Class2 or DDC258Class3 expected.'); + self::fail('Instance of DDC258Class1, DDC258Class2 or DDC258Class3 expected.'); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php index 992d8c648f4..4e12ee95fe5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php @@ -29,8 +29,8 @@ public function testIssue(): void $foo3 = $this->_em->merge($foo2); - $this->assertSame($foo, $foo3); - $this->assertEquals('Bar', $foo->name); + self::assertSame($foo, $foo3); + self::assertEquals('Bar', $foo->name); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php index 382aec669f0..05d0e8e7c42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php @@ -21,6 +21,6 @@ protected function setUp(): void public function testSingleScalarOneOrNullResult(): void { $query = $this->_em->createQuery("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'happy_doctrine_user'"); - $this->assertNull($query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR)); + self::assertNull($query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php index af632081b46..fd7a162fd01 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php @@ -61,11 +61,11 @@ public function testIssueWithExtraColumn(): void $query = $this->_em->createNativeQuery($sql, $rsm); $result = $query->getResult(); - $this->assertCount(5, $result); + self::assertCount(5, $result); foreach ($result as $order) { - $this->assertNotNull($order); - $this->assertInstanceOf(DDC2660CustomerOrder::class, $order); + self::assertNotNull($order); + self::assertInstanceOf(DDC2660CustomerOrder::class, $order); } } @@ -79,11 +79,11 @@ public function testIssueWithoutExtraColumn(): void $query = $this->_em->createNativeQuery($sql, $rsm); $result = $query->getResult(); - $this->assertCount(5, $result); + self::assertCount(5, $result); foreach ($result as $order) { - $this->assertNotNull($order); - $this->assertInstanceOf(DDC2660CustomerOrder::class, $order); + self::assertNotNull($order); + self::assertInstanceOf(DDC2660CustomerOrder::class, $order); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index 2dcc7ff2254..75a2a8526a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -43,7 +43,7 @@ public function testIsListenerCalledOnlyOnceOnPreFlush(): void ->setMethods(['preFlush']) ->getMock(); - $listener->expects($this->once())->method('preFlush'); + $listener->expects(self::once())->method('preFlush'); $this->_em->getEventManager()->addEventSubscriber($listener); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index 23437afa791..9582cd6c10f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -72,7 +72,7 @@ public function testCorrectNumberOfAssociationsIsReturned(): void $result = $builder->getQuery() ->getArrayResult(); - $this->assertCount(2, $result[0]['metadata']['metadataCategories']); + self::assertCount(2, $result[0]['metadata']['metadataCategories']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php index 3ff6eda8911..0c8a2166489 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php @@ -53,7 +53,7 @@ public function testIssue(): void ->getQuery() ->getOneOrNullResult(); - $this->assertInstanceOf(DDC2780User::class, $result); + self::assertInstanceOf(DDC2780User::class, $result); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php index e6a358429f7..abf958b1e99 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php @@ -55,7 +55,7 @@ public function testIssue(): void $qb->from(get_class($entity), 'c'); $qb->select('count(c)'); $count = intval($qb->getQuery()->getSingleScalarResult()); - $this->assertEquals($initial, $count); + self::assertEquals($initial, $count); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php index 50713d453a4..298b076edee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php @@ -65,10 +65,10 @@ public function testDDC279(): void $expected1 = 'Y'; $expected2 = 'Z'; - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); - $this->assertEquals($expected1, $result[0]->y->data); - $this->assertEquals($expected2, $result[0]->y->z->data); + self::assertEquals($expected1, $result[0]->y->data); + self::assertEquals($expected2, $result[0]->y->z->data); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index c1679020df0..e1b1f079630 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -31,7 +31,7 @@ protected function setUp(): void $platform = $this->_em->getConnection()->getDatabasePlatform(); if (! $platform->supportsSchemas() && ! $platform->canEmulateSchemas()) { - $this->markTestSkipped('This test is only useful for databases that support schemas or can emulate them.'); + self::markTestSkipped('This test is only useful for databases that support schemas or can emulate them.'); } } @@ -45,8 +45,8 @@ public function testClassSchemaMappingsValidity(string $className, string $expec $quotedTableName = $this->_em->getConfiguration()->getQuoteStrategy()->getTableName($classMetadata, $platform); // Check if table name and schema properties are defined in the class metadata - $this->assertEquals($expectedTableName, $classMetadata->table['name']); - $this->assertEquals($expectedSchemaName, $classMetadata->table['schema']); + self::assertEquals($expectedTableName, $classMetadata->table['name']); + self::assertEquals($expectedSchemaName, $classMetadata->table['schema']); if ($this->_em->getConnection()->getDatabasePlatform()->supportsSchemas()) { $fullTableName = sprintf('%s.%s', $expectedSchemaName, $expectedTableName); @@ -54,10 +54,10 @@ public function testClassSchemaMappingsValidity(string $className, string $expec $fullTableName = sprintf('%s__%s', $expectedSchemaName, $expectedTableName); } - $this->assertEquals($fullTableName, $quotedTableName); + self::assertEquals($fullTableName, $quotedTableName); // Checks sequence name validity - $this->assertEquals( + self::assertEquals( $fullTableName . '_' . $classMetadata->getSingleIdentifierColumnName() . '_seq', $classMetadata->getSequenceName($platform) ); @@ -78,7 +78,7 @@ public function testPersistenceOfEntityWithSchemaMapping(string $className): voi $this->_em->flush(); $this->_em->clear(); - $this->assertCount(1, $this->_em->getRepository($className)->findAll()); + self::assertCount(1, $this->_em->getRepository($className)->findAll()); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index 9d48289b3c1..12ad31c2966 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -46,32 +46,32 @@ public function testIssue(): void $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); $queryCount = $this->getCurrentQueryCount(); $driver2 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(DDC2862Driver::class, $driver2); - $this->assertInstanceOf(DDC2862User::class, $driver2->getUserProfile()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver2); + self::assertInstanceOf(DDC2862User::class, $driver2->getUserProfile()); $driver2->setName('Franta'); $this->_em->flush(); $this->_em->clear(); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); $queryCount = $this->getCurrentQueryCount(); $driver3 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertInstanceOf(DDC2862Driver::class, $driver3); - $this->assertInstanceOf(DDC2862User::class, $driver3->getUserProfile()); - $this->assertEquals('Franta', $driver3->getName()); - $this->assertEquals('Foo', $driver3->getUserProfile()->getName()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver3); + self::assertInstanceOf(DDC2862User::class, $driver3->getUserProfile()); + self::assertEquals('Franta', $driver3->getName()); + self::assertEquals('Foo', $driver3->getUserProfile()->getName()); } public function testIssueReopened(): void @@ -87,38 +87,38 @@ public function testIssueReopened(): void $this->_em->getCache()->evictEntityRegion(DDC2862User::class); $this->_em->getCache()->evictEntityRegion(DDC2862Driver::class); - $this->assertFalse($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); - $this->assertFalse($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); + self::assertFalse($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); + self::assertFalse($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); $queryCount = $this->getCurrentQueryCount(); $driver2 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertInstanceOf(DDC2862Driver::class, $driver2); - $this->assertInstanceOf(DDC2862User::class, $driver2->getUserProfile()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver2); + self::assertInstanceOf(DDC2862User::class, $driver2->getUserProfile()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->_em->clear(); - $this->assertFalse($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); - $this->assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); + self::assertFalse($this->_em->getCache()->containsEntity(DDC2862User::class, ['id' => $user1->getId()])); + self::assertTrue($this->_em->getCache()->containsEntity(DDC2862Driver::class, ['id' => $driver1->getId()])); $queryCount = $this->getCurrentQueryCount(); $driver3 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertInstanceOf(DDC2862Driver::class, $driver3); - $this->assertInstanceOf(DDC2862User::class, $driver3->getUserProfile()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertEquals('Foo', $driver3->getUserProfile()->getName()); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver3); + self::assertInstanceOf(DDC2862User::class, $driver3->getUserProfile()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals('Foo', $driver3->getUserProfile()->getName()); + self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $queryCount = $this->getCurrentQueryCount(); $driver4 = $this->_em->find(DDC2862Driver::class, $driver1->getId()); - $this->assertInstanceOf(DDC2862Driver::class, $driver4); - $this->assertInstanceOf(DDC2862User::class, $driver4->getUserProfile()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); - $this->assertEquals('Foo', $driver4->getUserProfile()->getName()); - $this->assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertInstanceOf(DDC2862Driver::class, $driver4); + self::assertInstanceOf(DDC2862User::class, $driver4->getUserProfile()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); + self::assertEquals('Foo', $driver4->getUserProfile()->getName()); + self::assertEquals($queryCount, $this->getCurrentQueryCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index 6095750f6c9..e6c3d0a296e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -38,7 +38,7 @@ public function testPostLoadOneToManyInheritance(): void { $cm = $this->_em->getClassMetadata(DDC2895::class); - $this->assertEquals( + self::assertEquals( [ 'prePersist' => ['setLastModifiedPreUpdate'], 'preUpdate' => ['setLastModifiedPreUpdate'], @@ -55,7 +55,7 @@ public function testPostLoadOneToManyInheritance(): void $ddc2895 = $this->_em->find(get_class($ddc2895), $ddc2895->id); assert($ddc2895 instanceof DDC2895); - $this->assertNotNull($ddc2895->getLastModified()); + self::assertNotNull($ddc2895->getLastModified()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index fd51d97fb45..9d198a42aac 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -51,7 +51,7 @@ public function testIssue(): void $second = $this->_em->find(DDC2931User::class, $second->id); - $this->assertSame(2, $second->getRank()); + self::assertSame(2, $second->getRank()); } public function testFetchJoinedEntitiesCanBeRefreshed(): void @@ -87,10 +87,10 @@ public function testFetchJoinedEntitiesCanBeRefreshed(): void ->setHint(Query::HINT_REFRESH, true) ->getResult(); - $this->assertCount(1, $refreshedSecond); - $this->assertSame(1, $first->value); - $this->assertSame(2, $second->value); - $this->assertSame(3, $third->value); + self::assertCount(1, $refreshedSecond); + self::assertSame(1, $first->value); + self::assertSame(2, $second->value); + self::assertSame(3, $third->value); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php index 65c87ea68c1..0d37fd55d2d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php @@ -71,23 +71,23 @@ public function testIssueNonFetchJoin(): void public function assertPaginatorQueryPut(Paginator $paginator, $regionName, $count, $pageSize): void { - $this->assertCount($count, $paginator); - $this->assertCount($pageSize, $paginator->getIterator()); + self::assertCount($count, $paginator); + self::assertCount($pageSize, $paginator->getIterator()); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionHitCount(Cache::DEFAULT_QUERY_REGION_NAME)); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount(Cache::DEFAULT_QUERY_REGION_NAME)); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionHitCount($regionName)); - $this->assertEquals($count, $this->secondLevelCacheLogger->getRegionPutCount($regionName)); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionHitCount(Cache::DEFAULT_QUERY_REGION_NAME)); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount(Cache::DEFAULT_QUERY_REGION_NAME)); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionHitCount($regionName)); + self::assertEquals($count, $this->secondLevelCacheLogger->getRegionPutCount($regionName)); } public function assertPaginatorQueryHit(Paginator $paginator, $regionName, $count, $pageSize): void { - $this->assertCount($count, $paginator); - $this->assertCount($pageSize, $paginator->getIterator()); + self::assertCount($count, $paginator); + self::assertCount($pageSize, $paginator->getIterator()); - $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount(Cache::DEFAULT_QUERY_REGION_NAME)); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionPutCount(Cache::DEFAULT_QUERY_REGION_NAME)); - $this->assertEquals($pageSize, $this->secondLevelCacheLogger->getRegionHitCount($regionName)); - $this->assertEquals(0, $this->secondLevelCacheLogger->getRegionPutCount($regionName)); + self::assertEquals(1, $this->secondLevelCacheLogger->getRegionHitCount(Cache::DEFAULT_QUERY_REGION_NAME)); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionPutCount(Cache::DEFAULT_QUERY_REGION_NAME)); + self::assertEquals($pageSize, $this->secondLevelCacheLogger->getRegionHitCount($regionName)); + self::assertEquals(0, $this->secondLevelCacheLogger->getRegionPutCount($regionName)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 49c2262f06b..517dabfc565 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -58,15 +58,15 @@ public function testIssue(): void $sameUser = $repository->find(new DDC2984DomainUserId('unique_id_within_a_vo')); //Until know, everything works as expected - $this->assertTrue($user->sameIdentityAs($sameUser)); + self::assertTrue($user->sameIdentityAs($sameUser)); $this->_em->clear(); //After clearing the identity map, the UnitOfWork produces the warning described in DDC-2984 $equalUser = $repository->find(new DDC2984DomainUserId('unique_id_within_a_vo')); - $this->assertNotSame($user, $equalUser); - $this->assertTrue($user->sameIdentityAs($equalUser)); + self::assertNotSame($user, $equalUser); + self::assertTrue($user->sameIdentityAs($equalUser)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index 1f6ddf90d59..2b4029b8cec 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -40,12 +40,12 @@ public function testIssue(): void $pref->value = 'bar'; $this->_em->flush(); - $this->assertEquals(1, $pref->user->counter); + self::assertEquals(1, $pref->user->counter); $this->_em->clear(); $pref = $this->_em->find(DDC2996UserPreference::class, $pref->id); - $this->assertEquals(1, $pref->user->counter); + self::assertEquals(1, $pref->user->counter); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index a9f50263f53..be272389fe2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -65,7 +65,7 @@ public function testIssue(): void ], ]; - $this->assertEquals($expect, $product->changeSet); + self::assertEquals($expect, $product->changeSet); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php index e835a30a67a..99597727105 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php @@ -29,7 +29,7 @@ protected function setUp(): void public function testSQLGenerationDoesNotProvokeAliasCollisions(): void { - $this->assertStringNotMatchesFormat( + self::assertStringNotMatchesFormat( '%sfield11%sfield11%s', $this ->_em diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php index 3587100d186..cfa5570f626 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php @@ -49,14 +49,14 @@ public function testFindUsingAnArrayOfObjectAsPrimaryKey(): void 'car' => $this->merc->getBrand(), ]); - $this->assertInstanceOf(Ride::class, $ride1); + self::assertInstanceOf(Ride::class, $ride1); $ride2 = $this->_em->find(Ride::class, [ 'driver' => $this->foo, 'car' => $this->merc, ]); - $this->assertInstanceOf(Ride::class, $ride2); - $this->assertSame($ride1, $ride2); + self::assertInstanceOf(Ride::class, $ride2); + self::assertSame($ride1, $ride2); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php index 7292d2b31fa..5d5b0ef0c4c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php @@ -40,18 +40,18 @@ public function testTwoIterateHydrations(): void $q = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309Country c')->iterate(); $c = $q->next(); - $this->assertEquals(1, $c[0]->id); + self::assertEquals(1, $c[0]->id); $r = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309User u')->iterate(); $u = $r->next(); // This line breaks - $this->assertEquals(1, $u[0]->id); + self::assertEquals(1, $u[0]->id); $c = $q->next(); $u = $r->next(); - $this->assertEquals(2, $c[0]->id); - $this->assertEquals(2, $u[0]->id); + self::assertEquals(2, $c[0]->id); + self::assertEquals(2, $u[0]->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php index 02e80565259..4906cdb44ba 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php @@ -26,12 +26,12 @@ public function testIssue(): void $this->createAnnotationDriver()->loadMetadataForClass(DDC3103ArticleId::class, $classMetadata); - $this->assertTrue( + self::assertTrue( $classMetadata->isEmbeddedClass, 'The isEmbeddedClass property should be true from the mapping data.' ); - $this->assertTrue( + self::assertTrue( unserialize(serialize($classMetadata))->isEmbeddedClass, 'The isEmbeddedClass property should still be true after serialization and unserialization.' ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php index fc9c1f8d929..d9eb0ec223b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php @@ -37,9 +37,9 @@ public function testIssue(): void ->getMock(); $listener - ->expects($this->once()) + ->expects(self::once()) ->method(Events::postFlush) - ->will($this->returnCallback(function () use ($uow): void { + ->will(self::returnCallback(function () use ($uow): void { $reflection = new ReflectionObject($uow); $property = $reflection->getProperty('extraUpdates'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php index 2283a634e77..91a57bedd90 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php @@ -40,9 +40,9 @@ public function testNoUpdateOnInsert(): void $this->_em->refresh($user); - $this->assertEquals('romanc', $user->username); - $this->assertEquals(1, $listener->inserts); - $this->assertEquals(0, $listener->updates); + self::assertEquals('romanc', $user->username); + self::assertEquals(1, $listener->inserts); + self::assertEquals(0, $listener->updates); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index 88271adb796..d8f8a30efd8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -30,7 +30,7 @@ protected function setUp(): void parent::setUp(); if (Type::hasType('ddc3192_currency_code')) { - $this->fail( + self::fail( 'Type ddc3192_currency_code exists for testing DDC-3192 only, ' . 'but it has already been registered for some reason' ); @@ -63,7 +63,7 @@ public function testIssue(): void $resultByPersister = $this->_em->find(DDC3192Transaction::class, $transaction->id); // This works: DDC2494 makes persister set type mapping info to ResultSetMapping - $this->assertEquals('BYR', $resultByPersister->currency->code); + self::assertEquals('BYR', $resultByPersister->currency->code); $this->_em->close(); @@ -75,7 +75,7 @@ public function testIssue(): void // This is fixed here: before the fix it used to return 974. // because unlike the BasicEntityPersister, SQLWalker doesn't set type info - $this->assertEquals('BYR', $resultByQuery->currency->code); + self::assertEquals('BYR', $resultByQuery->currency->code); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php index 147392390f3..4445f53547e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php @@ -50,7 +50,7 @@ public function testIssueGetId(): void $profileStatus = clone $participant->profileStatus; - $this->assertSame(1, $profileStatus->getId(), 'The identifier on the cloned instance is an integer'); + self::assertSame(1, $profileStatus->getId(), 'The identifier on the cloned instance is an integer'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index 23b97f93947..8cc3a11b4c6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -52,8 +52,8 @@ public function testResolveTargetEntitiesChangesDiscriminatorMapValues(): void $this->_em->flush(); $this->_em->clear(); - $this->assertEquals($boss, $this->_em->find(DDC3300Boss::class, $boss->id)); - $this->assertEquals($employee, $this->_em->find(DDC3300Employee::class, $employee->id)); + self::assertEquals($boss, $this->_em->find(DDC3300Boss::class, $boss->id)); + self::assertEquals($employee, $this->_em->find(DDC3300Employee::class, $employee->id)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php index 4e81129a714..128245576b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php @@ -25,7 +25,7 @@ protected function setUp(): void public function testSelectFieldOnRootEntity(): void { $q = $this->_em->createQuery('SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e'); - $this->assertEquals( + self::assertEquals( strtolower('SELECT c0_.name AS name_0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id'), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php index d65d4e55656..6ae31c53c68 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php @@ -53,7 +53,7 @@ public function testIssueCollectionOrderWithPaginator(): void $paginator = new Paginator($query, true); - $this->assertEquals(3, count(iterator_to_array($paginator)), 'Count is not correct for pagination'); + self::assertEquals(3, count(iterator_to_array($paginator)), 'Count is not correct for pagination'); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php index c3575abfc65..a3ddde88e88 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php @@ -31,7 +31,7 @@ public function testFindOneWithEagerFetchWillNotHydrateLimitedCollection(): void ); assert($author instanceof DDC3346Author); - $this->assertCount(2, $author->articles); + self::assertCount(2, $author->articles); } public function testFindLimitedWithEagerFetchWillNotHydrateLimitedCollection(): void @@ -43,8 +43,8 @@ public function testFindLimitedWithEagerFetchWillNotHydrateLimitedCollection(): 1 ); - $this->assertCount(1, $authors); - $this->assertCount(2, $authors[0]->articles); + self::assertCount(1, $authors); + self::assertCount(2, $authors[0]->articles); } public function testFindWithEagerFetchAndOffsetWillNotHydrateLimitedCollection(): void @@ -57,8 +57,8 @@ public function testFindWithEagerFetchAndOffsetWillNotHydrateLimitedCollection() 0 // using an explicitly defined offset ); - $this->assertCount(1, $authors); - $this->assertCount(2, $authors[0]->articles); + self::assertCount(1, $authors); + self::assertCount(2, $authors[0]->articles); } private function loadAuthorFixture(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php index d39fc5d23e0..2a37cbfd401 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -65,9 +65,9 @@ public function testTwoIterateHydrations(): void $this->_em->flush(); - $this->assertEquals(1, $membership->prePersistCallCount); - $this->assertEquals(0, $membership->preUpdateCallCount); - $this->assertInstanceOf('DateTime', $membership->updated); + self::assertEquals(1, $membership->prePersistCallCount); + self::assertEquals(0, $membership->preUpdateCallCount); + self::assertInstanceOf('DateTime', $membership->updated); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index f4295a89e55..589561d9d29 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -44,13 +44,13 @@ public function testWorkingCase(): void $em->clear(); $fileId = $file->getFileId(); - $this->assertTrue($fileId > 0); + self::assertTrue($fileId > 0); $file = $em->getReference(DDC353File::class, $fileId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($file), 'Reference Proxy should be marked MANAGED.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($file), 'Reference Proxy should be marked MANAGED.'); $picture = $em->find(DDC353Picture::class, $picture->getPictureId()); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); $em->remove($picture); $em->flush(); @@ -71,10 +71,10 @@ public function testFailingCase(): void $fileId = $file->getFileId(); $pictureId = $picture->getPictureId(); - $this->assertTrue($fileId > 0); + self::assertTrue($fileId > 0); $picture = $em->find(DDC353Picture::class, $pictureId); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); + self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); $em->remove($picture); $em->flush(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php index cece720af60..a301b2fbf26 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php @@ -25,9 +25,9 @@ public function testNestedEmbeddablesAreHydratedWithProperClass(): void $entity = $this->_em->find(DDC3582Entity::class, 'foo'); assert($entity instanceof DDC3582Entity); - $this->assertInstanceOf(DDC3582Embeddable1::class, $entity->embeddable1); - $this->assertInstanceOf(DDC3582Embeddable2::class, $entity->embeddable1->embeddable2); - $this->assertInstanceOf(DDC3582Embeddable3::class, $entity->embeddable1->embeddable2->embeddable3); + self::assertInstanceOf(DDC3582Embeddable1::class, $entity->embeddable1); + self::assertInstanceOf(DDC3582Embeddable2::class, $entity->embeddable1->embeddable2); + self::assertInstanceOf(DDC3582Embeddable3::class, $entity->embeddable1->embeddable2->embeddable3); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php index 41334f3f573..d7f200166c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php @@ -44,7 +44,7 @@ public function testSaveImageEntity(): void //request entity $imageEntity = $this->_em->find(DDC3597Image::class, $imageEntity->getId()); - $this->assertInstanceOf(DDC3597Image::class, $imageEntity); + self::assertInstanceOf(DDC3597Image::class, $imageEntity); //cleanup $this->_em->remove($imageEntity); @@ -53,6 +53,6 @@ public function testSaveImageEntity(): void //check delete $imageEntity = $this->_em->find(DDC3597Image::class, $imageEntity->getId()); - $this->assertNull($imageEntity); + self::assertNull($imageEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index aca44cdf4e4..63e8804d7de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -34,7 +34,7 @@ protected function setUp(): void $metadata = $this->_em->getClassMetadata(DDC3634Entity::class); if (! $metadata->idGenerator->isPostInsertGenerator()) { - $this->markTestSkipped('Need a post-insert ID generator in order to make this test work correctly'); + self::markTestSkipped('Need a post-insert ID generator in order to make this test work correctly'); } try { @@ -62,7 +62,7 @@ public function testSavesVeryLargeIntegerAutoGeneratedValue(): void $entityManager->persist($entity); $entityManager->flush(); - $this->assertSame($veryLargeId, $entity->id); + self::assertSame($veryLargeId, $entity->id); } public function testSavesIntegerAutoGeneratedValueAsString(): void @@ -72,7 +72,7 @@ public function testSavesIntegerAutoGeneratedValueAsString(): void $this->_em->persist($entity); $this->_em->flush(); - $this->assertIsString($entity->id); + self::assertIsString($entity->id); } public function testSavesIntegerAutoGeneratedValueAsStringWithJoinedInheritance(): void @@ -82,7 +82,7 @@ public function testSavesIntegerAutoGeneratedValueAsStringWithJoinedInheritance( $this->_em->persist($entity); $this->_em->flush(); - $this->assertIsString($entity->id); + self::assertIsString($entity->id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php index 0174d86755d..d1217ec7010 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php @@ -80,13 +80,13 @@ public function testIssueWithRegularEntity(): void // We should only have 1 item in the collection list now $user = $this->_em->find(DDC3644User::class, $userId); - $this->assertCount(1, $user->addresses); + self::assertCount(1, $user->addresses); // We should only have 1 item in the addresses table too $repository = $this->_em->getRepository(DDC3644Address::class); $addresses = $repository->findAll(); - $this->assertCount(1, $addresses); + self::assertCount(1, $addresses); } /** @@ -130,13 +130,13 @@ public function testIssueWithJoinedEntity(): void // We should only have 1 item in the collection list now $user = $this->_em->find(DDC3644User::class, $userId); - $this->assertCount(1, $user->pets); + self::assertCount(1, $user->pets); // We should only have 1 item in the pets table too $repository = $this->_em->getRepository(DDC3644Pet::class); $pets = $repository->findAll(); - $this->assertCount(1, $pets); + self::assertCount(1, $pets); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php index 424ee126ed8..5d002ef01a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php @@ -61,8 +61,8 @@ public function testMergingParentClassFieldsDoesNotStopMergingScalarFieldsForToO $mergedChild = $this->_em->merge($unManagedChild); assert($mergedChild instanceof DDC3699Child); - $this->assertSame($mergedChild->childField, 'modifiedChildValue'); - $this->assertSame($mergedChild->parentField, 'modifiedParentValue'); + self::assertSame($mergedChild->childField, 'modifiedChildValue'); + self::assertSame($mergedChild->parentField, 'modifiedParentValue'); } /** @@ -102,7 +102,7 @@ public function testMergingParentClassFieldsDoesNotStopMergingScalarFieldsForToM $mergedChild = $this->_em->merge($unmanagedChild); assert($mergedChild instanceof DDC3699Child); - $this->assertSame($mergedChild->childField, 'modifiedChildValue'); - $this->assertSame($mergedChild->parentField, 'modifiedParentValue'); + self::assertSame($mergedChild->childField, 'modifiedChildValue'); + self::assertSame($mergedChild->parentField, 'modifiedParentValue'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php index 1202464ec3d..599e2162c71 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php @@ -23,7 +23,7 @@ public function testCompositeKeyForJoinTableInManyToManyCreation(): void $entityA = new ClassMetadata(DDC3711EntityA::class); $entityA = $factory->getMetadataFor(DDC3711EntityA::class); - $this->assertEquals(['link_a_id1' => 'id1', 'link_a_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToSourceKeyColumns']); - $this->assertEquals(['link_b_id1' => 'id1', 'link_b_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToTargetKeyColumns']); + self::assertEquals(['link_a_id1' => 'id1', 'link_a_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToSourceKeyColumns']); + self::assertEquals(['link_b_id1' => 'id1', 'link_b_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToTargetKeyColumns']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php index dbaf68e42af..d6a3c48c3e5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php @@ -42,12 +42,12 @@ public function testCriteriaOnNotOwningSide(): void $this->_em->refresh($manager); $contracts = $manager->managedContracts; - static::assertCount(2, $contracts); + self::assertCount(2, $contracts); $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('completed', true)); $completedContracts = $contracts->matching($criteria); - static::assertCount(1, $completedContracts); + self::assertCount(1, $completedContracts); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index 2030c9e5da8..cd9c998aa4a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -59,10 +59,10 @@ public function testIssue(): void ->setHint(Query::HINT_REFRESH, true) ->getResult(); - $this->assertEquals(1, count($children)); - $this->assertNotInstanceOf(Proxy::class, $children[0]->parent); - $this->assertFalse($children[0]->parent->children->isInitialized()); - $this->assertEquals(0, $children[0]->parent->children->unwrap()->count()); + self::assertEquals(1, count($children)); + self::assertNotInstanceOf(Proxy::class, $children[0]->parent); + self::assertFalse($children[0]->parent->children->isInitialized()); + self::assertEquals(0, $children[0]->parent->children->unwrap()->count()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php index e9030836d04..439b8388a03 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php @@ -47,7 +47,7 @@ public function testCallUnserializedProxyMethods(): void $data = serialize($entity); $entity = unserialize($data); - $this->assertEquals($persistedId, $entity->getId()); + self::assertEquals($persistedId, $entity->getId()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php index c66b4b8e61e..1a0597bd5d3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php @@ -34,6 +34,6 @@ public function testIdentifierCachedWithProperType(): void assert($country instanceof Country); // Identifier type should be integer - $this->assertSame($country->getId(), $id); + self::assertSame($country->getId(), $id); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php index 3adc65619d4..7e6cfe5883b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php @@ -59,6 +59,6 @@ public function testReadsThroughRepositorySameDataThatItWroteInCache(): void $cached = $repository->findOneBy(['id' => $id]); assert($cached instanceof Bar); - $this->assertEquals($newName, $cached->getName()); + self::assertEquals($newName, $cached->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index 391d49667e6..905271161b6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -48,15 +48,15 @@ public function testIssue(): void $customer = $this->_em->find(get_class($customer), $customer->id); - $this->assertInstanceOf(PersistentCollection::class, $customer->contacts); - $this->assertFalse($customer->contacts->isInitialized()); + self::assertInstanceOf(PersistentCollection::class, $customer->contacts); + self::assertFalse($customer->contacts->isInitialized()); $contact = new DDC422Contact(); $customer->contacts->add($contact); - $this->assertTrue($customer->contacts->isDirty()); - $this->assertFalse($customer->contacts->isInitialized()); + self::assertTrue($customer->contacts->isDirty()); + self::assertFalse($customer->contacts->isInitialized()); $this->_em->flush(); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from ddc422_customers_contacts')); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select count(*) from ddc422_customers_contacts')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php index 0c6f4f72569..5c4605935d8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php @@ -34,7 +34,7 @@ public function testIssue(): void $num = $this->_em->createQuery('DELETE ' . __NAMESPACE__ . '\DDC425Entity e WHERE e.someDatetimeField > ?1') ->setParameter(1, new DateTime(), Type::DATETIME) ->getResult(); - $this->assertEquals(0, $num); + self::assertEquals(0, $num); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php index a3534c3a4af..91a3955e0d0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -81,14 +81,14 @@ public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations(): // Test the first phone. The assertion actually failed because original entity data is not set properly. // This was because it is also set as MainPhone and that one is created as a proxy, not the // original object when the find on Client is called. However loading proxies did not work correctly. - $this->assertInstanceOf(DDC440Phone::class, $p1); + self::assertInstanceOf(DDC440Phone::class, $p1); $originalData = $uw->getOriginalEntityData($p1); - $this->assertEquals($phone->getNumber(), $originalData['number']); + self::assertEquals($phone->getNumber(), $originalData['number']); //If you comment out previous test, this one should pass - $this->assertInstanceOf(DDC440Phone::class, $p2); + self::assertInstanceOf(DDC440Phone::class, $p2); $originalData = $uw->getOriginalEntityData($p2); - $this->assertEquals($phone2->getNumber(), $originalData['number']); + self::assertEquals($phone2->getNumber(), $originalData['number']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php index a4b6fa158cf..b53c9ada9c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php @@ -40,7 +40,7 @@ public function testExplicitPolicy(): void $q = $this->_em->createQuery(sprintf('SELECT u FROM %s u', $classname)); $u = $q->getSingleResult(); - $this->assertEquals('Initial value', $u->name); + self::assertEquals('Initial value', $u->name); $u->name = 'Modified value'; @@ -51,7 +51,7 @@ public function testExplicitPolicy(): void $u = $this->_em->createQuery(sprintf('SELECT u FROM %s u', $classname)); $u = $q->getSingleResult(); - $this->assertEquals('Initial value', $u->name); + self::assertEquals('Initial value', $u->name); $u->name = 'Modified value'; $this->_em->persist($u); @@ -61,7 +61,7 @@ public function testExplicitPolicy(): void $q = $this->_em->createQuery(sprintf('SELECT u FROM %s u', $classname)); $u = $q->getSingleResult(); - $this->assertEquals('Modified value', $u->name); + self::assertEquals('Modified value', $u->name); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php index d5c2694a6b0..8b30908b87b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -36,7 +36,7 @@ protected function setUp(): void public function testIssue(): void { $q = $this->_em->createQuery('select b from ' . __NAMESPACE__ . '\\DDC448SubTable b where b.connectedClassId = ?1'); - $this->assertEquals( + self::assertEquals( strtolower('SELECT d0_.id AS id_0, d0_.discr AS discr_1, d0_.connectedClassId AS connectedClassId_2 FROM SubTable s1_ INNER JOIN DDC448MainTable d0_ ON s1_.id = d0_.id WHERE d0_.connectedClassId = ?'), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php index a09d6bd90a2..fd99cc6d5c8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php @@ -34,7 +34,7 @@ protected function setUp(): void public function testIssue(): void { $q = $this->_em->createQuery('select u, c.data from ' . __NAMESPACE__ . '\\DDC493Distributor u JOIN u.contact c'); - $this->assertEquals( + self::assertEquals( strtolower('SELECT d0_.id AS id_0, d1_.data AS data_1, d0_.discr AS discr_2, d0_.contact AS contact_3 FROM DDC493Distributor d2_ INNER JOIN DDC493Customer d0_ ON d2_.id = d0_.id INNER JOIN DDC493Contact d1_ ON d0_.contact = d1_.id'), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php index 952c8656f89..7abdfcaafbc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php @@ -27,55 +27,55 @@ public function testMergeUnitializedManyToManyAndOneToManyCollections(): void $user = $this->createAndPersistUser(); $this->_em->flush(); - $this->assertTrue($this->_em->contains($user)); + self::assertTrue($this->_em->contains($user)); $this->_em->clear(); - $this->assertFalse($this->_em->contains($user)); + self::assertFalse($this->_em->contains($user)); unset($user); // Reload User from DB *without* any associations (i.e. an uninitialized PersistantCollection) $userReloaded = $this->loadUserFromEntityManager(); - $this->assertTrue($this->_em->contains($userReloaded)); + self::assertTrue($this->_em->contains($userReloaded)); $this->_em->clear(); - $this->assertFalse($this->_em->contains($userReloaded)); + self::assertFalse($this->_em->contains($userReloaded)); // freeze and unfreeze $userClone = unserialize(serialize($userReloaded)); - $this->assertInstanceOf(CmsUser::class, $userClone); + self::assertInstanceOf(CmsUser::class, $userClone); // detached user can't know about his phonenumbers - $this->assertEquals(0, count($userClone->getPhonenumbers())); - $this->assertFalse($userClone->getPhonenumbers()->isInitialized(), 'User::phonenumbers should not be marked initialized.'); + self::assertEquals(0, count($userClone->getPhonenumbers())); + self::assertFalse($userClone->getPhonenumbers()->isInitialized(), 'User::phonenumbers should not be marked initialized.'); // detached user can't know about his groups either - $this->assertEquals(0, count($userClone->getGroups())); - $this->assertFalse($userClone->getGroups()->isInitialized(), 'User::groups should not be marked initialized.'); + self::assertEquals(0, count($userClone->getGroups())); + self::assertFalse($userClone->getGroups()->isInitialized(), 'User::groups should not be marked initialized.'); // Merge back and flush $userClone = $this->_em->merge($userClone); // Back in managed world I would expect to have my phonenumbers back but they aren't! // Remember I didn't touch (and probably didn't need) them at all while in detached mode. - $this->assertEquals(4, count($userClone->getPhonenumbers()), 'Phonenumbers are not available anymore'); + self::assertEquals(4, count($userClone->getPhonenumbers()), 'Phonenumbers are not available anymore'); // This works fine as long as cmUser::groups doesn't cascade "merge" - $this->assertEquals(2, count($userClone->getGroups())); + self::assertEquals(2, count($userClone->getGroups())); $this->_em->flush(); $this->_em->clear(); - $this->assertFalse($this->_em->contains($userClone)); + self::assertFalse($this->_em->contains($userClone)); // Reload user from DB $userFromEntityManager = $this->loadUserFromEntityManager(); //Strange: Now the phonenumbers are back again - $this->assertEquals(4, count($userFromEntityManager->getPhonenumbers())); + self::assertEquals(4, count($userFromEntityManager->getPhonenumbers())); // This works fine as long as cmUser::groups doesn't cascade "merge" // Otherwise group memberships are physically deleted now! - $this->assertEquals(2, count($userClone->getGroups())); + self::assertEquals(2, count($userClone->getGroups())); } protected function createAndPersistUser(): CmsUser diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php index c456e62f978..4aa787293b2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php @@ -47,16 +47,16 @@ public function testIssue(): void $q = $this->_em->createQuery('select u,i from ' . __NAMESPACE__ . '\\DDC512Customer u left join u.item i'); $result = $q->getResult(); - $this->assertEquals(2, count($result)); - $this->assertInstanceOf(DDC512Customer::class, $result[0]); - $this->assertInstanceOf(DDC512Customer::class, $result[1]); + self::assertEquals(2, count($result)); + self::assertInstanceOf(DDC512Customer::class, $result[0]); + self::assertInstanceOf(DDC512Customer::class, $result[1]); if ($result[0]->id === $customer1->id) { - $this->assertInstanceOf(DDC512OfferItem::class, $result[0]->item); - $this->assertEquals($item->id, $result[0]->item->id); - $this->assertNull($result[1]->item); + self::assertInstanceOf(DDC512OfferItem::class, $result[0]->item); + self::assertEquals($item->id, $result[0]->item->id); + self::assertNull($result[1]->item); } else { - $this->assertInstanceOf(DDC512OfferItem::class, $result[1]->item); - $this->assertNull($result[0]->item); + self::assertInstanceOf(DDC512OfferItem::class, $result[1]->item); + self::assertNull($result[0]->item); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php index d55f55fb7b4..ef0856f5078 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php @@ -34,7 +34,7 @@ protected function setUp(): void public function testIssue(): void { $q = $this->_em->createQuery('select u from ' . __NAMESPACE__ . '\\DDC513OfferItem u left join u.price p'); - $this->assertEquals( + self::assertEquals( strtolower('SELECT d0_.id AS id_0, d0_.discr AS discr_1, d0_.price AS price_2 FROM DDC513OfferItem d1_ INNER JOIN DDC513Item d0_ ON d1_.id = d0_.id LEFT JOIN DDC513Price d2_ ON d0_.price = d2_.id'), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php index d0b12a42e3f..f1ef8b0e6f8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php @@ -36,6 +36,6 @@ public function testMergeWithRelatedNew(): void $this->_em->persist($user); $managedArticle = $this->_em->merge($article); - $this->assertSame($article->user, $managedArticle->user); + self::assertSame($article->user, $managedArticle->user); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index b5d39887ad8..be563e2fbfd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -58,10 +58,10 @@ public function testJoinColumnWithSameNameAsAssociationField(): void $r = $this->_em->createQuery('select ca,c from ' . DDC522Cart::class . ' ca join ca.customer c') ->getResult(); - $this->assertInstanceOf(DDC522Cart::class, $r[0]); - $this->assertInstanceOf(DDC522Customer::class, $r[0]->customer); - $this->assertNotInstanceOf(Proxy::class, $r[0]->customer); - $this->assertEquals('name', $r[0]->customer->name); + self::assertInstanceOf(DDC522Cart::class, $r[0]); + self::assertInstanceOf(DDC522Customer::class, $r[0]->customer); + self::assertNotInstanceOf(Proxy::class, $r[0]->customer); + self::assertEquals('name', $r[0]->customer->name); $fkt = new DDC522ForeignKeyTest(); $fkt->cartId = $r[0]->id; // ignored for persistence @@ -71,9 +71,9 @@ public function testJoinColumnWithSameNameAsAssociationField(): void $this->_em->clear(); $fkt2 = $this->_em->find(get_class($fkt), $fkt->id); - $this->assertEquals($fkt->cart->id, $fkt2->cartId); - $this->assertInstanceOf(Proxy::class, $fkt2->cart); - $this->assertFalse($fkt2->cart->__isInitialized__); + self::assertEquals($fkt->cart->id, $fkt2->cartId); + self::assertInstanceOf(Proxy::class, $fkt2->cart); + self::assertFalse($fkt2->cart->__isInitialized__); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php index 91bdba5c50a..d6d0ada4276 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php @@ -46,12 +46,12 @@ public function testIssue(): void $item3 = $this->_em->find(DDC531Item::class, $item2->id); // Load child item first (id 2) // parent will already be loaded, cannot be lazy because it has mapped subclasses and we would not // know which proxy type to put in. - $this->assertInstanceOf(DDC531Item::class, $item3->parent); - $this->assertNotInstanceOf(Proxy::class, $item3->parent); + self::assertInstanceOf(DDC531Item::class, $item3->parent); + self::assertNotInstanceOf(Proxy::class, $item3->parent); $item4 = $this->_em->find(DDC531Item::class, $item1->id); // Load parent item (id 1) - $this->assertNull($item4->parent); - $this->assertNotNull($item4->getChildren()); - $this->assertTrue($item4->getChildren()->contains($item3)); // lazy-loads children + self::assertNull($item4->parent); + self::assertNotNull($item4->getChildren()); + self::assertTrue($item4->getChildren()->contains($item3)); // lazy-loads children } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index 964b8a5f5e0..08493f32f2f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -48,7 +48,7 @@ public function testAutoIncrementIdWithCustomType(): void $this->_em->persist($object); $this->_em->flush(); - $this->assertInstanceOf(DDC5684ObjectId::class, $object->id); + self::assertInstanceOf(DDC5684ObjectId::class, $object->id); } public function testFetchObjectWithAutoIncrementedCustomType(): void @@ -61,8 +61,8 @@ public function testFetchObjectWithAutoIncrementedCustomType(): void $rawId = $object->id->value; $object = $this->_em->find(DDC5684Object::class, new DDC5684ObjectId($rawId)); - $this->assertInstanceOf(DDC5684ObjectId::class, $object->id); - $this->assertEquals($rawId, $object->id->value); + self::assertInstanceOf(DDC5684ObjectId::class, $object->id); + self::assertEquals($rawId, $object->id->value); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php index 54e1c34485f..ab586df9f7e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -54,9 +54,9 @@ public function testCascadeRemoveOnInheritanceHierarchy(): void $this->_em->remove($item); $this->_em->flush(); // Should not fail - $this->assertFalse($this->_em->contains($item)); + self::assertFalse($this->_em->contains($item)); $children = $item->getChildren(); - $this->assertFalse($this->_em->contains($children[0])); + self::assertFalse($this->_em->contains($children[0])); $this->_em->clear(); @@ -74,17 +74,17 @@ public function testCascadeRemoveOnInheritanceHierarchy(): void $this->_em->remove($item2); $this->_em->flush(); // should not fail - $this->assertFalse($this->_em->contains($item)); + self::assertFalse($this->_em->contains($item)); $children = $item->getChildren(); - $this->assertFalse($this->_em->contains($children[0])); + self::assertFalse($this->_em->contains($children[0])); } public function testCascadeRemoveOnChildren(): void { $class = $this->_em->getClassMetadata(DDC599Subitem::class); - $this->assertArrayHasKey('children', $class->associationMappings); - $this->assertTrue($class->associationMappings['children']['isCascadeRemove']); + self::assertArrayHasKey('children', $class->associationMappings); + self::assertTrue($class->associationMappings['children']['isCascadeRemove']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index b8933917908..ff17ab2d6ae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -64,8 +64,8 @@ public function testIndexByHydrateObject(): void $joe = $this->_em->find(DDC618Author::class, 10); $alice = $this->_em->find(DDC618Author::class, 11); - $this->assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); - $this->assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); + self::assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); + self::assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); } public function testIndexByHydrateArray(): void @@ -76,8 +76,8 @@ public function testIndexByHydrateArray(): void $joe = $this->_em->find(DDC618Author::class, 10); $alice = $this->_em->find(DDC618Author::class, 11); - $this->assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); - $this->assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); + self::assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); + self::assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); } /** @@ -89,19 +89,19 @@ public function testIndexByJoin(): void 'INNER JOIN A.books B INDEX BY B.title ORDER BY A.name ASC'; $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_OBJECT); - $this->assertEquals(3, count($result[0]->books)); // Alice, Joe doesn't appear because he has no books. - $this->assertEquals('Alice', $result[0]->name); - $this->assertTrue(isset($result[0]->books['In Wonderland']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[0]->books['Reloaded']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[0]->books['Test']), 'Indexing by title should have books by title.'); + self::assertEquals(3, count($result[0]->books)); // Alice, Joe doesn't appear because he has no books. + self::assertEquals('Alice', $result[0]->name); + self::assertTrue(isset($result[0]->books['In Wonderland']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[0]->books['Reloaded']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[0]->books['Test']), 'Indexing by title should have books by title.'); $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_ARRAY); - $this->assertEquals(3, count($result[0]['books'])); // Alice, Joe doesn't appear because he has no books. - $this->assertEquals('Alice', $result[0]['name']); - $this->assertTrue(isset($result[0]['books']['In Wonderland']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[0]['books']['Reloaded']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[0]['books']['Test']), 'Indexing by title should have books by title.'); + self::assertEquals(3, count($result[0]['books'])); // Alice, Joe doesn't appear because he has no books. + self::assertEquals('Alice', $result[0]['name']); + self::assertTrue(isset($result[0]['books']['In Wonderland']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[0]['books']['Reloaded']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[0]['books']['Test']), 'Indexing by title should have books by title.'); } /** @@ -113,14 +113,14 @@ public function testIndexByToOneJoinSilentlyIgnored(): void 'INNER JOIN B.author A INDEX BY A.name ORDER BY A.name ASC'; $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_OBJECT); - $this->assertInstanceOf(DDC618Book::class, $result[0]); - $this->assertInstanceOf(DDC618Author::class, $result[0]->author); + self::assertInstanceOf(DDC618Book::class, $result[0]); + self::assertInstanceOf(DDC618Author::class, $result[0]->author); $dql = 'SELECT B, A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Book B ' . 'INNER JOIN B.author A INDEX BY A.name ORDER BY A.name ASC'; $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_ARRAY); - $this->assertEquals('Alice', $result[0]['author']['name']); + self::assertEquals('Alice', $result[0]['author']['name']); } /** @@ -132,13 +132,13 @@ public function testCombineIndexBy(): void 'INNER JOIN A.books B INDEX BY B.title ORDER BY A.name ASC'; $result = $this->_em->createQuery($dql)->getResult(Query::HYDRATE_OBJECT); - $this->assertArrayHasKey(11, $result); // Alice + self::assertArrayHasKey(11, $result); // Alice - $this->assertEquals(3, count($result[11]->books)); // Alice, Joe doesn't appear because he has no books. - $this->assertEquals('Alice', $result[11]->name); - $this->assertTrue(isset($result[11]->books['In Wonderland']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[11]->books['Reloaded']), 'Indexing by title should have books by title.'); - $this->assertTrue(isset($result[11]->books['Test']), 'Indexing by title should have books by title.'); + self::assertEquals(3, count($result[11]->books)); // Alice, Joe doesn't appear because he has no books. + self::assertEquals('Alice', $result[11]->name); + self::assertTrue(isset($result[11]->books['In Wonderland']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[11]->books['Reloaded']), 'Indexing by title should have books by title.'); + self::assertTrue(isset($result[11]->books['Test']), 'Indexing by title should have books by title.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php index 1fe2e6514e8..78750bcd71d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php @@ -49,8 +49,8 @@ public function testOneToOneEager(): void $eagerAppointment = $this->_em->find(DDC633Appointment::class, $app->id); // Eager loading of one to one leads to fetch-join - $this->assertNotInstanceOf(Proxy::class, $eagerAppointment->patient); - $this->assertTrue($this->_em->contains($eagerAppointment->patient)); + self::assertNotInstanceOf(Proxy::class, $eagerAppointment->patient); + self::assertTrue($this->_em->contains($eagerAppointment->patient)); } /** @@ -75,8 +75,8 @@ public function testDQLDeferredEagerLoad(): void $appointments = $this->_em->createQuery('SELECT a FROM ' . __NAMESPACE__ . '\DDC633Appointment a')->getResult(); foreach ($appointments as $eagerAppointment) { - $this->assertInstanceOf(Proxy::class, $eagerAppointment->patient); - $this->assertTrue($eagerAppointment->patient->__isInitialized__, 'Proxy should already be initialized due to eager loading!'); + self::assertInstanceOf(Proxy::class, $eagerAppointment->patient); + self::assertTrue($eagerAppointment->patient->__isInitialized__, 'Proxy should already be initialized due to eager loading!'); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php index 06a20f089a3..90a9a55d5d2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php @@ -41,7 +41,7 @@ public function testInlineEmbeddable(): void ->getClassMetadata(DDC6460Entity::class) ->hasField('embedded'); - $this->assertTrue($isFieldMapped); + self::assertTrue($isFieldMapped); } /** @@ -65,11 +65,11 @@ public function testInlineEmbeddableProxyInitialization(): void $secondEntityWithLazyParameter = $this->_em->getRepository(DDC6460ParentEntity::class)->findOneById(1); - $this->assertInstanceOf(Proxy::class, $secondEntityWithLazyParameter->lazyLoaded); - $this->assertInstanceOf(DDC6460Entity::class, $secondEntityWithLazyParameter->lazyLoaded); - $this->assertFalse($secondEntityWithLazyParameter->lazyLoaded->__isInitialized()); - $this->assertEquals($secondEntityWithLazyParameter->lazyLoaded->embedded, $entity->embedded); - $this->assertTrue($secondEntityWithLazyParameter->lazyLoaded->__isInitialized()); + self::assertInstanceOf(Proxy::class, $secondEntityWithLazyParameter->lazyLoaded); + self::assertInstanceOf(DDC6460Entity::class, $secondEntityWithLazyParameter->lazyLoaded); + self::assertFalse($secondEntityWithLazyParameter->lazyLoaded->__isInitialized()); + self::assertEquals($secondEntityWithLazyParameter->lazyLoaded->embedded, $entity->embedded); + self::assertTrue($secondEntityWithLazyParameter->lazyLoaded->__isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index e2121d8b93a..30e5920a60e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -42,14 +42,14 @@ public function testRecomputeSingleEntityChangeSetPreservesFieldOrder(): void $this->_em->getUnitOfWork()->recomputeSingleEntityChangeSet($this->_em->getClassMetadata(get_class($entity)), $entity); $data2 = $this->_em->getUnitOfWork()->getEntityChangeSet($entity); - $this->assertEquals(array_keys($data1), array_keys($data2)); + self::assertEquals(array_keys($data1), array_keys($data2)); $this->_em->flush(); $this->_em->clear(); $persistedEntity = $this->_em->find(get_class($entity), $entity->specificationId); - $this->assertEquals('type2', $persistedEntity->getType()); - $this->assertEquals('test1', $persistedEntity->getName()); + self::assertEquals('type2', $persistedEntity->getType()); + self::assertEquals('test1', $persistedEntity->getName()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php index 788ff9e0915..91d8a3f0b01 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php @@ -29,11 +29,11 @@ public function testEntitySingleResult(): void $query = $this->_em->createQuery('SELECT d FROM ' . DateTimeModel::class . ' d'); $datetime = $query->setMaxResults(1)->getSingleResult(); - $this->assertInstanceOf(DateTimeModel::class, $datetime); + self::assertInstanceOf(DateTimeModel::class, $datetime); - $this->assertInstanceOf('DateTime', $datetime->datetime); - $this->assertInstanceOf('DateTime', $datetime->time); - $this->assertInstanceOf('DateTime', $datetime->date); + self::assertInstanceOf('DateTime', $datetime->datetime); + self::assertInstanceOf('DateTime', $datetime->time); + self::assertInstanceOf('DateTime', $datetime->date); } public function testScalarResult(): void @@ -41,15 +41,15 @@ public function testScalarResult(): void $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . DateTimeModel::class . ' d ORDER BY d.date ASC'); $result = $query->getScalarResult(); - $this->assertCount(2, $result); + self::assertCount(2, $result); - $this->assertStringContainsString('11:11:11', $result[0]['time']); - $this->assertStringContainsString('2010-01-01', $result[0]['date']); - $this->assertStringContainsString('2010-01-01 11:11:11', $result[0]['datetime']); + self::assertStringContainsString('11:11:11', $result[0]['time']); + self::assertStringContainsString('2010-01-01', $result[0]['date']); + self::assertStringContainsString('2010-01-01 11:11:11', $result[0]['datetime']); - $this->assertStringContainsString('12:12:12', $result[1]['time']); - $this->assertStringContainsString('2010-02-02', $result[1]['date']); - $this->assertStringContainsString('2010-02-02 12:12:12', $result[1]['datetime']); + self::assertStringContainsString('12:12:12', $result[1]['time']); + self::assertStringContainsString('2010-02-02', $result[1]['date']); + self::assertStringContainsString('2010-02-02 12:12:12', $result[1]['datetime']); } public function testaTicketEntityArrayResult(): void @@ -57,15 +57,15 @@ public function testaTicketEntityArrayResult(): void $query = $this->_em->createQuery('SELECT d FROM ' . DateTimeModel::class . ' d ORDER BY d.date ASC'); $result = $query->getArrayResult(); - $this->assertCount(2, $result); + self::assertCount(2, $result); - $this->assertInstanceOf('DateTime', $result[0]['datetime']); - $this->assertInstanceOf('DateTime', $result[0]['time']); - $this->assertInstanceOf('DateTime', $result[0]['date']); + self::assertInstanceOf('DateTime', $result[0]['datetime']); + self::assertInstanceOf('DateTime', $result[0]['time']); + self::assertInstanceOf('DateTime', $result[0]['date']); - $this->assertInstanceOf('DateTime', $result[1]['datetime']); - $this->assertInstanceOf('DateTime', $result[1]['time']); - $this->assertInstanceOf('DateTime', $result[1]['date']); + self::assertInstanceOf('DateTime', $result[1]['datetime']); + self::assertInstanceOf('DateTime', $result[1]['time']); + self::assertInstanceOf('DateTime', $result[1]['date']); } public function testTicketSingleResult(): void @@ -73,11 +73,11 @@ public function testTicketSingleResult(): void $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . DateTimeModel::class . ' d ORDER BY d.date ASC'); $datetime = $query->setMaxResults(1)->getSingleResult(); - $this->assertTrue(is_array($datetime)); + self::assertTrue(is_array($datetime)); - $this->assertInstanceOf('DateTime', $datetime['datetime']); - $this->assertInstanceOf('DateTime', $datetime['time']); - $this->assertInstanceOf('DateTime', $datetime['date']); + self::assertInstanceOf('DateTime', $datetime['datetime']); + self::assertInstanceOf('DateTime', $datetime['time']); + self::assertInstanceOf('DateTime', $datetime['date']); } public function testTicketResult(): void @@ -85,19 +85,19 @@ public function testTicketResult(): void $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . DateTimeModel::class . ' d ORDER BY d.date ASC'); $result = $query->getResult(); - $this->assertCount(2, $result); + self::assertCount(2, $result); - $this->assertInstanceOf('DateTime', $result[0]['time']); - $this->assertInstanceOf('DateTime', $result[0]['date']); - $this->assertInstanceOf('DateTime', $result[0]['datetime']); + self::assertInstanceOf('DateTime', $result[0]['time']); + self::assertInstanceOf('DateTime', $result[0]['date']); + self::assertInstanceOf('DateTime', $result[0]['datetime']); - $this->assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d G:i:s')); + self::assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d G:i:s')); - $this->assertInstanceOf('DateTime', $result[1]['time']); - $this->assertInstanceOf('DateTime', $result[1]['date']); - $this->assertInstanceOf('DateTime', $result[1]['datetime']); + self::assertInstanceOf('DateTime', $result[1]['time']); + self::assertInstanceOf('DateTime', $result[1]['date']); + self::assertInstanceOf('DateTime', $result[1]['datetime']); - $this->assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d G:i:s')); + self::assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d G:i:s')); } public function loadFixtures(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php index a9d3329562c..f03ef002355 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php @@ -43,7 +43,7 @@ public function testTicket(): void $sql = $qb->getQuery()->getSQL(); - $this->assertEquals( + self::assertEquals( strtolower('SELECT p0_.privilegeID AS privilegeID_0, p0_.name AS name_1, r1_.roleID AS roleID_2, r1_.name AS name_3, r1_.shortName AS shortName_4 FROM Privileges p0_ LEFT JOIN RolePrivileges r2_ ON p0_.privilegeID = r2_.privilegeID LEFT JOIN Roles r1_ ON r1_.roleID = r2_.roleID'), strtolower($sql) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php index dd8dd4a1433..ebaf105bfac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php @@ -102,13 +102,13 @@ public function testIssue(): void $res = $query->getResult(); $lemma = $res[0]; - $this->assertEquals('foo', $lemma->getLemma()); - $this->assertInstanceOf(Lemma::class, $lemma); + self::assertEquals('foo', $lemma->getLemma()); + self::assertInstanceOf(Lemma::class, $lemma); $relations = $lemma->getRelations(); foreach ($relations as $relation) { - $this->assertInstanceOf(Relation::class, $relation); - $this->assertTrue($relation->getType()->getType() !== ''); + self::assertInstanceOf(Relation::class, $relation); + self::assertTrue($relation->getType()->getType() !== ''); } $this->_em->clear(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php index 42f9502aed6..559ff9c99c2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -37,7 +37,7 @@ public function testIsEmptySqlGeneration(): void $referenceSQL = 'SELECT g0_.name AS name_0, g0_.description AS description_1, g0_.id AS id_2, g1_.name AS name_3, g1_.description AS description_4, g1_.id AS id_5 FROM groups g0_ LEFT JOIN groups_groups g2_ ON g0_.id = g2_.parent_id LEFT JOIN groups g1_ ON g1_.id = g2_.child_id WHERE (SELECT COUNT(*) FROM groups_groups g3_ WHERE g3_.child_id = g0_.id) = 0'; - $this->assertEquals( + self::assertEquals( strtolower($referenceSQL), strtolower($q->getSQL()) ); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php index f0a86f8426c..3754508b175 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php @@ -51,20 +51,20 @@ public function testMergeManyToMany(): void $a = new DDC729A(); $a->id = $aId; - $this->assertInstanceOf(ArrayCollection::class, $a->related); + self::assertInstanceOf(ArrayCollection::class, $a->related); $a = $this->_em->merge($a); - $this->assertInstanceOf(PersistentCollection::class, $a->related); + self::assertInstanceOf(PersistentCollection::class, $a->related); - $this->assertFalse($a->related->isInitialized(), 'Collection should not be marked initialized.'); - $this->assertFalse($a->related->isDirty(), 'Collection should not be marked as dirty.'); + self::assertFalse($a->related->isInitialized(), 'Collection should not be marked initialized.'); + self::assertFalse($a->related->isDirty(), 'Collection should not be marked as dirty.'); $this->_em->flush(); $this->_em->clear(); $a = $this->_em->find(DDC729A::class, $aId); - $this->assertEquals(1, count($a->related)); + self::assertEquals(1, count($a->related)); } public function testUnidirectionalMergeManyToMany(): void @@ -94,7 +94,7 @@ public function testUnidirectionalMergeManyToMany(): void $this->_em->clear(); $a = $this->_em->find(DDC729A::class, $aId); - $this->assertEquals(2, count($a->related)); + self::assertEquals(2, count($a->related)); } public function testBidirectionalMergeManyToMany(): void @@ -126,7 +126,7 @@ public function testBidirectionalMergeManyToMany(): void $this->_em->clear(); $a = $this->_em->find(DDC729A::class, $aId); - $this->assertEquals(2, count($a->related)); + self::assertEquals(2, count($a->related)); } public function testBidirectionalMultiMergeManyToMany(): void @@ -158,7 +158,7 @@ public function testBidirectionalMultiMergeManyToMany(): void $this->_em->clear(); $a = $this->_em->find(DDC729A::class, $aId); - $this->assertEquals(2, count($a->related)); + self::assertEquals(2, count($a->related)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php index ae0b0e77057..68b62145243 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -44,7 +44,7 @@ public function testRemoveElementAppliesOrphanRemoval(): void $this->_em->flush(); // Now you see it - $this->assertEquals(1, count($product->getReviews())); + self::assertEquals(1, count($product->getReviews())); // Remove the review $reviewId = $review->getId(); @@ -52,16 +52,16 @@ public function testRemoveElementAppliesOrphanRemoval(): void $this->_em->flush(); // Now you don't - $this->assertEquals(0, count($product->getReviews()), 'count($reviews) should be 0 after removing its only Review'); + self::assertEquals(0, count($product->getReviews()), 'count($reviews) should be 0 after removing its only Review'); // Refresh $this->_em->refresh($product); // It should still be 0 - $this->assertEquals(0, count($product->getReviews()), 'count($reviews) should still be 0 after the refresh'); + self::assertEquals(0, count($product->getReviews()), 'count($reviews) should still be 0 after the refresh'); // Review should also not be available anymore - $this->assertNull($this->_em->find(DDC735Review::class, $reviewId)); + self::assertNull($this->_em->find(DDC735Review::class, $reviewId)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php index aff73ffde13..a025cce1198 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php @@ -47,10 +47,10 @@ public function testReorderEntityFetchJoinForHydration(): void $cart2 = $result[0]; unset($result[0]); - $this->assertInstanceOf(ECommerceCart::class, $cart2); - $this->assertNotInstanceOf(Proxy::class, $cart2->getCustomer()); - $this->assertInstanceOf(ECommerceCustomer::class, $cart2->getCustomer()); - $this->assertEquals(['name' => 'roman', 'payment' => 'cash'], $result); + self::assertInstanceOf(ECommerceCart::class, $cart2); + self::assertNotInstanceOf(Proxy::class, $cart2->getCustomer()); + self::assertInstanceOf(ECommerceCustomer::class, $cart2->getCustomer()); + self::assertEquals(['name' => 'roman', 'payment' => 'cash'], $result); } /** @@ -79,7 +79,7 @@ public function testDqlTreeWalkerReordering(): void $cart2 = $result[0][0]; assert($cart2 instanceof ECommerceCart); - $this->assertInstanceOf(Proxy::class, $cart2->getCustomer()); + self::assertInstanceOf(Proxy::class, $cart2->getCustomer()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php index a447897fd96..68188621cd9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php @@ -31,7 +31,7 @@ class DDC742Test extends OrmFunctionalTestCase protected function setUp(): void { if (! class_exists(FilesystemCache::class)) { - $this->markTestSkipped('Test only applies with doctrine/cache 1.x'); + self::markTestSkipped('Test only applies with doctrine/cache 1.x'); } parent::setUp(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php index ede9a604a00..e24b9f3d3cf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php @@ -34,10 +34,10 @@ public function testRefreshWithManyToOne(): void $this->_em->persist($article); $this->_em->flush(); - $this->assertInstanceOf(Collection::class, $user->articles); + self::assertInstanceOf(Collection::class, $user->articles); $this->_em->refresh($article); - $this->assertTrue($article !== $user->articles, 'The article should not be replaced on the inverse side of the relation.'); - $this->assertInstanceOf(Collection::class, $user->articles); + self::assertTrue($article !== $user->articles, 'The article should not be replaced on the inverse side of the relation.'); + self::assertInstanceOf(Collection::class, $user->articles); } public function testRefreshOneToOne(): void @@ -59,7 +59,7 @@ public function testRefreshOneToOne(): void $this->_em->flush(); $this->_em->refresh($address); - $this->assertSame($user, $address->user); - $this->assertSame($user->address, $address); + self::assertSame($user, $address->user); + self::assertSame($user->address, $address); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php index 8c4cc9315dd..461cf116d90 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php @@ -15,7 +15,7 @@ class DDC758Test extends OrmFunctionalTestCase { protected function setUp(): void { - $this->markTestSkipped('Destroys testsuite'); + self::markTestSkipped('Destroys testsuite'); $this->useModelSet('cms'); parent::setUp(); @@ -99,18 +99,18 @@ public function testManyToManyMergeAssociationAdds(): void $cmsGroups = $this->_em->getRepository(CmsGroup::class)->findAll(); // Check the entities are in the database - $this->assertEquals(1, count($cmsUsers)); - $this->assertEquals(2, count($cmsGroups)); + self::assertEquals(1, count($cmsUsers)); + self::assertEquals(2, count($cmsGroups)); // Check the associations between the entities are now in the database - $this->assertEquals(2, count($cmsUsers[0]->groups)); - $this->assertEquals(1, count($cmsGroups[0]->users)); - $this->assertEquals(1, count($cmsGroups[1]->users)); - - $this->assertSame($cmsUsers[0]->groups[0], $cmsGroups[0]); - $this->assertSame($cmsUsers[0]->groups[1], $cmsGroups[1]); - $this->assertSame($cmsGroups[0]->users[0], $cmsUsers[0]); - $this->assertSame($cmsGroups[1]->users[0], $cmsUsers[0]); + self::assertEquals(2, count($cmsUsers[0]->groups)); + self::assertEquals(1, count($cmsGroups[0]->users)); + self::assertEquals(1, count($cmsGroups[1]->users)); + + self::assertSame($cmsUsers[0]->groups[0], $cmsGroups[0]); + self::assertSame($cmsUsers[0]->groups[1], $cmsGroups[1]); + self::assertSame($cmsGroups[0]->users[0], $cmsUsers[0]); + self::assertSame($cmsGroups[1]->users[0], $cmsUsers[0]); } /** @@ -175,12 +175,12 @@ public function testManyToManyMergeAssociationRemoves(): void $cmsGroups = $this->_em->getRepository(CmsGroup::class)->findAll(); // Check the entities are in the database - $this->assertEquals(1, count($cmsUsers)); - $this->assertEquals(2, count($cmsGroups)); + self::assertEquals(1, count($cmsUsers)); + self::assertEquals(2, count($cmsGroups)); // Check the associations between the entities are now in the database - $this->assertEquals(0, count($cmsUsers[0]->groups)); - $this->assertEquals(0, count($cmsGroups[0]->users)); - $this->assertEquals(0, count($cmsGroups[1]->users)); + self::assertEquals(0, count($cmsUsers[0]->groups)); + self::assertEquals(0, count($cmsGroups[0]->users)); + self::assertEquals(0, count($cmsGroups[1]->users)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php index f90deb45914..0767866ab89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php @@ -53,7 +53,7 @@ public function testCollectionChangesInsideTransaction(): void $pUser = $this->_em->find(get_class($user), $user->id); assert($pUser instanceof CmsUser); - $this->assertNotNull($pUser, 'User not retrieved from database.'); + self::assertNotNull($pUser, 'User not retrieved from database.'); $groups = [$group2->id, $group3->id]; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php index ecfce0d7482..507b0a979ab 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php @@ -32,20 +32,20 @@ public function testChildEntityRetrievedFromCache(): void $repository = $this->_em->getRepository(Bar::class); - $this->assertFalse($this->cache->containsEntity(Bar::class, $bar->getId())); - $this->assertFalse($this->cache->containsEntity(Attraction::class, $bar->getId())); + self::assertFalse($this->cache->containsEntity(Bar::class, $bar->getId())); + self::assertFalse($this->cache->containsEntity(Attraction::class, $bar->getId())); $repository->findOneBy([ 'name' => $bar->getName(), ]); - $this->assertTrue($this->cache->containsEntity(Bar::class, $bar->getId())); + self::assertTrue($this->cache->containsEntity(Bar::class, $bar->getId())); $repository->findOneBy([ 'name' => $bar->getName(), ]); // One hit for entity cache, one hit for query cache - $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); + self::assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php index 6acde91b616..f132d8f0d20 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php @@ -62,8 +62,8 @@ public function testIssue(): void ->getQuery() ->getResult(); - $this->assertEquals(4, count($result[0]->getSpecificationValues()), 'Works in test-setup.'); - $this->assertEquals(4, count($result[1]->getSpecificationValues()), 'Only returns 2 in the case of the hydration bug.'); + self::assertEquals(4, count($result[0]->getSpecificationValues()), 'Works in test-setup.'); + self::assertEquals(4, count($result[1]->getSpecificationValues()), 'Only returns 2 in the case of the hydration bug.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php index d34e043edc3..c3fee0942af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php @@ -46,7 +46,7 @@ public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManag ->setParameter(1, $article->id) ->getSingleResult(); - $this->assertTrue($article2Again === $article2); - $this->assertTrue($article2Again->comments->isInitialized()); + self::assertTrue($article2Again === $article2); + self::assertTrue($article2Again->comments->isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index 30dbb659d6f..a938ce82879 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -25,7 +25,7 @@ protected function setUp(): void $platform = $this->_em->getConnection()->getDatabasePlatform(); if ($platform->getName() === 'oracle') { - $this->markTestSkipped('Doesnt run on Oracle.'); + self::markTestSkipped('Doesnt run on Oracle.'); } $this->_em->getConfiguration()->setSQLLogger(new EchoSQLLogger()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index 27f0646dd69..0cde48e344c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -66,38 +66,38 @@ public function testIssue(): void // Test Class1 $e1 = $this->_em->find(DDC837Super::class, $c1->id); - $this->assertInstanceOf(DDC837Class1::class, $e1); - $this->assertEquals('Foo', $e1->title); - $this->assertEquals('Foo', $e1->description); - $this->assertInstanceOf(DDC837Aggregate::class, $e1->aggregate); - $this->assertEquals('test1', $e1->aggregate->getSysname()); + self::assertInstanceOf(DDC837Class1::class, $e1); + self::assertEquals('Foo', $e1->title); + self::assertEquals('Foo', $e1->description); + self::assertInstanceOf(DDC837Aggregate::class, $e1->aggregate); + self::assertEquals('test1', $e1->aggregate->getSysname()); // Test Class 2 $e2 = $this->_em->find(DDC837Super::class, $c2->id); - $this->assertInstanceOf(DDC837Class2::class, $e2); - $this->assertEquals('Bar', $e2->title); - $this->assertEquals('Bar', $e2->description); - $this->assertEquals('Bar', $e2->text); - $this->assertInstanceOf(DDC837Aggregate::class, $e2->aggregate); - $this->assertEquals('test2', $e2->aggregate->getSysname()); + self::assertInstanceOf(DDC837Class2::class, $e2); + self::assertEquals('Bar', $e2->title); + self::assertEquals('Bar', $e2->description); + self::assertEquals('Bar', $e2->text); + self::assertInstanceOf(DDC837Aggregate::class, $e2->aggregate); + self::assertEquals('test2', $e2->aggregate->getSysname()); $all = $this->_em->getRepository(DDC837Super::class)->findAll(); foreach ($all as $obj) { if ($obj instanceof DDC837Class1) { - $this->assertEquals('Foo', $obj->title); - $this->assertEquals('Foo', $obj->description); + self::assertEquals('Foo', $obj->title); + self::assertEquals('Foo', $obj->description); } elseif ($obj instanceof DDC837Class2) { - $this->assertTrue($e2 === $obj); - $this->assertEquals('Bar', $obj->title); - $this->assertEquals('Bar', $obj->description); - $this->assertEquals('Bar', $obj->text); + self::assertTrue($e2 === $obj); + self::assertEquals('Bar', $obj->title); + self::assertEquals('Bar', $obj->description); + self::assertEquals('Bar', $obj->text); } elseif ($obj instanceof DDC837Class3) { - $this->assertEquals('Baz', $obj->apples); - $this->assertEquals('Baz', $obj->bananas); + self::assertEquals('Baz', $obj->apples); + self::assertEquals('Baz', $obj->bananas); } else { - $this->fail('Instance of DDC837Class1, DDC837Class2 or DDC837Class3 expected.'); + self::fail('Instance of DDC837Class1, DDC837Class2 or DDC837Class3 expected.'); } } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php index 3fbbcd3c9a5..a8cfadd7b32 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php @@ -54,25 +54,25 @@ public function testRemoveContains(): void $group1 = $this->user->groups[0]; $group2 = $this->user->groups[1]; - $this->assertTrue($this->user->groups->contains($group1)); - $this->assertTrue($this->user->groups->contains($group2)); + self::assertTrue($this->user->groups->contains($group1)); + self::assertTrue($this->user->groups->contains($group2)); $this->user->groups->removeElement($group1); $this->user->groups->remove(1); - $this->assertFalse($this->user->groups->contains($group1)); - $this->assertFalse($this->user->groups->contains($group2)); + self::assertFalse($this->user->groups->contains($group1)); + self::assertFalse($this->user->groups->contains($group2)); } public function testClearCount(): void { $this->user->addGroup(new CmsGroup()); - $this->assertEquals(3, count($this->user->groups)); + self::assertEquals(3, count($this->user->groups)); $this->user->groups->clear(); - $this->assertEquals(0, $this->user->groups->count()); - $this->assertEquals(0, count($this->user->groups)); + self::assertEquals(0, $this->user->groups->count()); + self::assertEquals(0, count($this->user->groups)); } public function testClearContains(): void @@ -80,12 +80,12 @@ public function testClearContains(): void $group1 = $this->user->groups[0]; $group2 = $this->user->groups[1]; - $this->assertTrue($this->user->groups->contains($group1)); - $this->assertTrue($this->user->groups->contains($group2)); + self::assertTrue($this->user->groups->contains($group1)); + self::assertTrue($this->user->groups->contains($group2)); $this->user->groups->clear(); - $this->assertFalse($this->user->groups->contains($group1)); - $this->assertFalse($this->user->groups->contains($group2)); + self::assertFalse($this->user->groups->contains($group1)); + self::assertFalse($this->user->groups->contains($group2)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index e650907f3d5..a52537ff4de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -97,16 +97,16 @@ public function testIssue(): void $dql = 'SELECT c, p FROM ' . DDC881PhoneCall::class . ' c JOIN c.phonenumber p'; $calls = $this->_em->createQuery($dql)->getResult(); - $this->assertEquals(2, count($calls)); - $this->assertNotInstanceOf(Proxy::class, $calls[0]->getPhoneNumber()); - $this->assertNotInstanceOf(Proxy::class, $calls[1]->getPhoneNumber()); + self::assertEquals(2, count($calls)); + self::assertNotInstanceOf(Proxy::class, $calls[0]->getPhoneNumber()); + self::assertNotInstanceOf(Proxy::class, $calls[1]->getPhoneNumber()); $dql = 'SELECT p, c FROM ' . DDC881PhoneNumber::class . ' p JOIN p.calls c'; $numbers = $this->_em->createQuery($dql)->getResult(); - $this->assertEquals(2, count($numbers)); - $this->assertInstanceOf(PersistentCollection::class, $numbers[0]->getCalls()); - $this->assertTrue($numbers[0]->getCalls()->isInitialized()); + self::assertEquals(2, count($numbers)); + self::assertInstanceOf(PersistentCollection::class, $numbers[0]->getCalls()); + self::assertTrue($numbers[0]->getCalls()->isInitialized()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php index ab5ff8965db..d7101851405 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php @@ -34,10 +34,10 @@ public function testBooleanThroughRepository(): void $true = $this->_em->getRepository(BooleanModel::class)->findOneBy(['booleanField' => true]); $false = $this->_em->getRepository(BooleanModel::class)->findOneBy(['booleanField' => false]); - $this->assertInstanceOf(BooleanModel::class, $true, 'True model not found'); - $this->assertTrue($true->booleanField, 'True Boolean Model should be true.'); + self::assertInstanceOf(BooleanModel::class, $true, 'True model not found'); + self::assertTrue($true->booleanField, 'True Boolean Model should be true.'); - $this->assertInstanceOf(BooleanModel::class, $false, 'False model not found'); - $this->assertFalse($false->booleanField, 'False Boolean Model should be false.'); + self::assertInstanceOf(BooleanModel::class, $false, 'False model not found'); + self::assertFalse($false->booleanField, 'False Boolean Model should be false.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php index 54df850abcf..eea7a7fb994 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -42,7 +42,7 @@ public function testUpdateRootVersion(): void $this->_em->flush(); - $this->assertEquals(2, $child->getVersion()); + self::assertEquals(2, $child->getVersion()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index ffec514f49a..38002f1d8ff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -60,9 +60,9 @@ public function testIssue(): void $child = $this->_em->getRepository(get_class($role))->find($child->roleID); $parents = count($child->extends); - $this->assertEquals(1, $parents); + self::assertEquals(1, $parents); foreach ($child->extends as $parent) { - $this->assertEquals($role->getRoleID(), $parent->getRoleID()); + self::assertEquals($role->getRoleID(), $parent->getRoleID()); } } @@ -82,21 +82,21 @@ public function testOneToManyChild(): void $childRepository = $this->_em->getRepository(get_class($child)); $parent = $parentRepository->find($parent->id); - $this->assertEquals(1, count($parent->childs)); - $this->assertEquals(0, count($parent->childs[0]->childs())); + self::assertEquals(1, count($parent->childs)); + self::assertEquals(0, count($parent->childs[0]->childs())); $child = $parentRepository->findOneBy(['id' => $child->id]); - $this->assertSame($parent->childs[0], $child); + self::assertSame($parent->childs[0], $child); $this->_em->clear(); $child = $parentRepository->find($child->id); - $this->assertEquals(0, count($child->childs)); + self::assertEquals(0, count($child->childs)); $this->_em->clear(); $child = $childRepository->find($child->id); - $this->assertEquals(0, count($child->childs)); + self::assertEquals(0, count($child->childs)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index c8ded4f1ed5..845f35ef0bb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -62,7 +62,7 @@ public function testLazyLoadsForeignEntitiesInOneToOneRelationWhileHavingCustomI ->getOneOrNullResult(); assert($customer instanceof GH5887Customer); - $this->assertInstanceOf(GH5887Cart::class, $customer->getCart()); + self::assertInstanceOf(GH5887Cart::class, $customer->getCart()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index 869c275ec18..5116d6b268a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -83,8 +83,8 @@ public function testInheritanceJoinAlias(): void $hydrator = new ObjectHydrator($this->_em); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertInstanceOf(GH6362Start::class, $result[0]['base']); - $this->assertInstanceOf(GH6362Child::class, $result[1][0]); + self::assertInstanceOf(GH6362Start::class, $result[0]['base']); + self::assertInstanceOf(GH6362Child::class, $result[1][0]); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php index 3e401b9e11b..062d932c344 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php @@ -43,14 +43,14 @@ public function testIssue(): void ->innerJoin(GH6464Author::class, 'a', 'WITH', 'p.authorId = a.id') ->getQuery(); - $this->assertDoesNotMatchRegularExpression( + self::assertDoesNotMatchRegularExpression( '/INNER JOIN \w+ \w+ INNER JOIN/', $query->getSQL(), 'As of GH-6464, every INNER JOIN should have an ON clause, which is missing here' ); // Query shouldn't yield a result, yet it shouldn't crash (anymore) - $this->assertEquals([], $query->getResult()); + self::assertEquals([], $query->getResult()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php index ee6801f85ae..92937baef95 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php @@ -47,19 +47,19 @@ public function testNonUniqueObjectHydrationDuringIteration(): void $q->toIterable([], AbstractQuery::HYDRATE_OBJECT) ); - $this->assertCount(2, $bs); - $this->assertInstanceOf(GH7496EntityB::class, $bs[0]); - $this->assertInstanceOf(GH7496EntityB::class, $bs[1]); - $this->assertEquals(1, $bs[0]->id); - $this->assertEquals(1, $bs[1]->id); + self::assertCount(2, $bs); + self::assertInstanceOf(GH7496EntityB::class, $bs[0]); + self::assertInstanceOf(GH7496EntityB::class, $bs[1]); + self::assertEquals(1, $bs[0]->id); + self::assertEquals(1, $bs[1]->id); $bs = IterableTester::iterableToArray( $q->toIterable([], AbstractQuery::HYDRATE_ARRAY) ); - $this->assertCount(2, $bs); - $this->assertEquals(1, $bs[0]['id']); - $this->assertEquals(1, $bs[1]['id']); + self::assertCount(2, $bs); + self::assertEquals(1, $bs[0]['id']); + self::assertEquals(1, $bs[1]['id']); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php index 70eeac9f7e1..b5bda3261f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php @@ -17,7 +17,7 @@ class GH7684 extends DatabaseDriverTestCase public function testIssue(): void { if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); + self::markTestSkipped('Platform does not support foreign keys.'); } $table1 = new Table('GH7684_identity_test_table'); @@ -33,6 +33,6 @@ public function testIssue(): void $metadatas = $this->convertToClassMetadata([$table1, $table2]); $metadata = $metadatas['Gh7684IdentityTestAssocTable']; - $this->assertArrayHasKey('gh7684IdentityTest', $metadata->associationMappings); + self::assertArrayHasKey('gh7684IdentityTest', $metadata->associationMappings); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php index c3f9d7bec90..c7a5862fa63 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php @@ -45,7 +45,7 @@ public function testPaginatorWithLimitSubquery(): void $paginator->count(); $paginator->getIterator(); - $this->assertCount(3, $this->logger->queries); + self::assertCount(3, $this->logger->queries); } public function testPaginatorWithLimitSubquerySkipped(): void @@ -58,6 +58,6 @@ public function testPaginatorWithLimitSubquerySkipped(): void $paginator->count(); $paginator->getIterator(); - $this->assertCount(2, $this->logger->queries); + self::assertCount(2, $this->logger->queries); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php index 26e359842d0..b0d130c44a4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php @@ -61,7 +61,7 @@ public function testExtraLazyRemoveElement(): void return $tweet->content; }); - $this->assertEquals(['Goodbye, and thanks for all the fish'], array_values($tweets->toArray())); + self::assertEquals(['Goodbye, and thanks for all the fish'], array_values($tweets->toArray())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php index c098d5d4b51..5ff4820a266 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php @@ -31,7 +31,7 @@ public function testDQLDeferredEagerLoad(): void ->setMethods(['getClassMetadata']) ->getMock(); - $em->expects($this->exactly(2)) + $em->expects(self::exactly(2)) ->method('getClassMetadata') ->willReturnCallback([$decoratedEm, 'getClassMetadata']); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php index b00cd680f75..0c2b6b06d2a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php @@ -48,7 +48,7 @@ public function testSimpleArrayTypeHydratedCorrectlyInJoinedInheritance(): void $manager = $repository->find($managerId); $employee = $repository->find($employeeId); - static::assertEquals($managerTags, $manager->tags); - static::assertEquals($employeeTags, $employee->tags); + self::assertEquals($managerTags, $manager->tags); + self::assertEquals($employeeTags, $employee->tags); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php index df82949713d..2a5c66e19ba 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php @@ -37,7 +37,7 @@ public function testEmptyInsert(): void $this->_em->persist($test); $this->_em->flush(); - $this->assertTrue($test->id > 0); + self::assertTrue($test->id > 0); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index b06675e013e..3c7c6207a2e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -36,8 +36,8 @@ public function testDecimal(): void $dql = 'SELECT d FROM ' . DecimalModel::class . ' d'; $decimal = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertSame('0.15', $decimal->decimal); - $this->assertSame('0.1515', $decimal->highScale); + self::assertSame('0.15', $decimal->decimal); + self::assertSame('0.1515', $decimal->highScale); } /** @@ -55,7 +55,7 @@ public function testBoolean(): void $dql = 'SELECT b FROM ' . BooleanModel::class . ' b WHERE b.booleanField = true'; $bool = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertTrue($bool->booleanField); + self::assertTrue($bool->booleanField); $bool->booleanField = false; @@ -65,7 +65,7 @@ public function testBoolean(): void $dql = 'SELECT b FROM ' . BooleanModel::class . ' b WHERE b.booleanField = false'; $bool = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertFalse($bool->booleanField); + self::assertFalse($bool->booleanField); } public function testArray(): void @@ -81,7 +81,7 @@ public function testArray(): void $dql = 'SELECT s FROM ' . SerializationModel::class . ' s'; $serialize = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertSame(['foo' => 'bar', 'bar' => 'baz'], $serialize->array); + self::assertSame(['foo' => 'bar', 'bar' => 'baz'], $serialize->array); } public function testObject(): void @@ -96,7 +96,7 @@ public function testObject(): void $dql = 'SELECT s FROM ' . SerializationModel::class . ' s'; $serialize = $this->_em->createQuery($dql)->getSingleResult(); - $this->assertInstanceOf('stdClass', $serialize->object); + self::assertInstanceOf('stdClass', $serialize->object); } public function testDate(): void @@ -110,8 +110,8 @@ public function testDate(): void $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->date); - $this->assertSame('2009-10-01', $dateTimeDb->date->format('Y-m-d')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->date); + self::assertSame('2009-10-01', $dateTimeDb->date->format('Y-m-d')); } public function testDateTime(): void @@ -125,13 +125,13 @@ public function testDateTime(): void $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->datetime); - $this->assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->datetime); + self::assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); $articles = $this->_em->getRepository(DateTimeModel::class) ->findBy(['datetime' => new DateTime()]); - $this->assertEmpty($articles); + self::assertEmpty($articles); } public function testDqlQueryBindDateTimeInstance(): void @@ -149,8 +149,8 @@ public function testDqlQueryBindDateTimeInstance(): void ->setParameter(1, $date, DBALType::DATETIME) ->getSingleResult(); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->datetime); - $this->assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->datetime); + self::assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); } public function testDqlQueryBuilderBindDateTimeInstance(): void @@ -171,8 +171,8 @@ public function testDqlQueryBuilderBindDateTimeInstance(): void ->setParameter(1, $date, DBALType::DATETIME) ->getQuery()->getSingleResult(); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->datetime); - $this->assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->datetime); + self::assertSame('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); } public function testTime(): void @@ -186,7 +186,7 @@ public function testTime(): void $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); - $this->assertInstanceOf(DateTime::class, $dateTimeDb->time); - $this->assertSame('19:27:20', $dateTimeDb->time->format('H:i:s')); + self::assertInstanceOf(DateTime::class, $dateTimeDb->time); + self::assertSame('19:27:20', $dateTimeDb->time->format('H:i:s')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php index 086cbe79ab2..2bcfb552a8a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php @@ -48,8 +48,8 @@ public function testUpperCaseStringType(): void $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - $this->assertEquals('foo', $entity->lowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn('select lowerCaseString from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); + self::assertEquals('foo', $entity->lowerCaseString, 'Entity holds lowercase string'); + self::assertEquals('FOO', $this->_em->getConnection()->fetchColumn('select lowerCaseString from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); } /** @@ -69,8 +69,8 @@ public function testUpperCaseStringTypeWhenColumnNameIsDefined(): void $this->_em->clear(); $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - $this->assertEquals('foo', $entity->namedLowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); + self::assertEquals('foo', $entity->namedLowerCaseString, 'Entity holds lowercase string'); + self::assertEquals('FOO', $this->_em->getConnection()->fetchColumn('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); $entity->namedLowerCaseString = 'bar'; @@ -82,8 +82,8 @@ public function testUpperCaseStringTypeWhenColumnNameIsDefined(): void $this->_em->clear(); $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); - $this->assertEquals('bar', $entity->namedLowerCaseString, 'Entity holds lowercase string'); - $this->assertEquals('BAR', $this->_em->getConnection()->fetchColumn('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); + self::assertEquals('bar', $entity->namedLowerCaseString, 'Entity holds lowercase string'); + self::assertEquals('BAR', $this->_em->getConnection()->fetchColumn('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); } public function testTypeValueSqlWithAssociations(): void @@ -109,11 +109,11 @@ public function testTypeValueSqlWithAssociations(): void $entity = $this->_em->find(CustomTypeParent::class, $parentId); - $this->assertTrue($entity->customInteger < 0, 'Fetched customInteger negative'); - $this->assertEquals(1, $this->_em->getConnection()->fetchColumn('select customInteger from customtype_parents where id=' . $entity->id . ''), 'Database has stored customInteger positive'); + self::assertTrue($entity->customInteger < 0, 'Fetched customInteger negative'); + self::assertEquals(1, $this->_em->getConnection()->fetchColumn('select customInteger from customtype_parents where id=' . $entity->id . ''), 'Database has stored customInteger positive'); - $this->assertNotNull($parent->child, 'Child attached'); - $this->assertCount(2, $entity->getMyFriends(), '2 friends attached'); + self::assertNotNull($parent->child, 'Child attached'); + self::assertCount(2, $entity->getMyFriends(), '2 friends attached'); } public function testSelectDQL(): void @@ -133,12 +133,12 @@ public function testSelectDQL(): void $result = $query->getResult(); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CustomTypeParent::class, $result[0][0]); - $this->assertEquals(-1, $result[0][0]->customInteger); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CustomTypeParent::class, $result[0][0]); + self::assertEquals(-1, $result[0][0]->customInteger); - $this->assertEquals(-1, $result[0]['customInteger']); + self::assertEquals(-1, $result[0]['customInteger']); - $this->assertEquals('foo', $result[0][0]->child->lowerCaseString); + self::assertEquals('foo', $result[0][0]->child->lowerCaseString); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php index 5a4a009a59f..e7bfbcffdf8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php @@ -29,7 +29,7 @@ public function testItIsDeprecated(): void public function testGenerateUUID(): void { if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - $this->markTestSkipped('Currently restricted to MySQL platform.'); + self::markTestSkipped('Currently restricted to MySQL platform.'); } $this->_schemaTool->createSchema([ @@ -38,8 +38,8 @@ public function testGenerateUUID(): void $entity = new UUIDEntity(); $this->_em->persist($entity); - $this->assertNotNull($entity->getId()); - $this->assertTrue(strlen($entity->getId()) > 0); + self::assertNotNull($entity->getId()); + self::assertTrue(strlen($entity->getId()) > 0); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php index 0acf8a9be58..024303cab26 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php @@ -60,16 +60,16 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); } /** @@ -92,9 +92,9 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - $this->assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, $owning); } /** @@ -117,10 +117,10 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $auxiliary->id4); - $this->assertEquals('def', $inversed->id1); - $this->assertEquals('abc', $inversed->foreignEntity->id4); - $this->assertEquals('ghi', $owning->id2); + self::assertEquals('abc', $auxiliary->id4); + self::assertEquals('def', $inversed->id1); + self::assertEquals('abc', $inversed->foreignEntity->id4); + self::assertEquals('ghi', $owning->id2); } /** @@ -138,7 +138,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - $this->assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -151,7 +151,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void 'ghi' ); - $this->assertCount(1, $owning->associatedEntities); + self::assertCount(1, $owning->associatedEntities); } /** @@ -164,7 +164,7 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void ['id1' => 'def', 'foreignEntity' => 'abc'] ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } /** @@ -192,6 +192,6 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // test association is removed - $this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid_foreignkey')); + self::assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid_foreignkey')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php index 9d7460b38f8..2715909af42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php @@ -54,14 +54,14 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_manytomany_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_manytomany_compositeid LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_manytomany_compositeid LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_manytomany_compositeid LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT inversed_id1 FROM vct_xref_manytomany_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT inversed_id2 FROM vct_xref_manytomany_compositeid LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT inversed_id1 FROM vct_xref_manytomany_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT inversed_id2 FROM vct_xref_manytomany_compositeid LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany_compositeid LIMIT 1')); } /** @@ -79,8 +79,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, $owning); } /** @@ -98,9 +98,9 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $inversed->id2); - $this->assertEquals('ghi', $owning->id3); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $inversed->id2); + self::assertEquals('ghi', $owning->id3); } /** @@ -113,7 +113,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void 'ghi' ); - $this->assertCount(1, $owning->associatedEntities); + self::assertCount(1, $owning->associatedEntities); } /** @@ -126,7 +126,7 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void ['id1' => 'abc', 'id2' => 'def'] ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } /** @@ -154,6 +154,6 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // test association is removed - $this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid')); + self::assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany_compositeid')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php index 6096b48a997..79f6beebc23 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php @@ -71,7 +71,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedIsCounted(): v 'ghi' ); - $this->assertEquals(2, $owning->associatedEntities->count()); + self::assertEquals(2, $owning->associatedEntities->count()); } public function testThatTheExtraLazyCollectionFromInversedToOwningIsCounted(): void @@ -81,7 +81,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningIsCounted(): v 'abc' ); - $this->assertEquals(2, $inversed->associatedEntities->count()); + self::assertEquals(2, $inversed->associatedEntities->count()); } public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnEntity(): void @@ -96,7 +96,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnEnti 'abc' ); - $this->assertTrue($owning->associatedEntities->contains($inversed)); + self::assertTrue($owning->associatedEntities->contains($inversed)); } public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnEntity(): void @@ -111,7 +111,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnEnti 'ghi' ); - $this->assertTrue($inversed->associatedEntities->contains($owning)); + self::assertTrue($inversed->associatedEntities->contains($owning)); } public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnIndexByKey(): void @@ -121,7 +121,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnInde 'ghi' ); - $this->assertTrue($owning->associatedEntities->containsKey('abc')); + self::assertTrue($owning->associatedEntities->containsKey('abc')); } public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnIndexByKey(): void @@ -131,7 +131,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnInde 'abc' ); - $this->assertTrue($inversed->associatedEntities->containsKey('ghi')); + self::assertTrue($inversed->associatedEntities->containsKey('ghi')); } public function testThatASliceOfTheExtraLazyCollectionFromOwningToInversedIsLoaded(): void @@ -141,7 +141,7 @@ public function testThatASliceOfTheExtraLazyCollectionFromOwningToInversedIsLoad 'ghi' ); - $this->assertCount(1, $owning->associatedEntities->slice(0, 1)); + self::assertCount(1, $owning->associatedEntities->slice(0, 1)); } public function testThatASliceOfTheExtraLazyCollectionFromInversedToOwningIsLoaded(): void @@ -151,6 +151,6 @@ public function testThatASliceOfTheExtraLazyCollectionFromInversedToOwningIsLoad 'abc' ); - $this->assertCount(1, $inversed->associatedEntities->slice(1, 1)); + self::assertCount(1, $inversed->associatedEntities->slice(1, 1)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php index 67cb2107e00..f4dc1be9c9d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php @@ -53,12 +53,12 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_manytomany LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytomany LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytomany LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT inversed_id FROM vct_xref_manytomany LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT inversed_id FROM vct_xref_manytomany LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT owning_id FROM vct_xref_manytomany LIMIT 1')); } /** @@ -76,8 +76,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'def' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedManyToManyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToManyEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyEntity::class, $owning); } /** @@ -95,8 +95,8 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'def' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $owning->id2); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $owning->id2); } /** @@ -109,7 +109,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void 'def' ); - $this->assertCount(1, $owning->associatedEntities); + self::assertCount(1, $owning->associatedEntities); } /** @@ -122,7 +122,7 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void 'abc' ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } /** @@ -150,6 +150,6 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // test association is removed - $this->assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany')); + self::assertEquals(0, $conn->fetchColumn('SELECT COUNT(*) FROM vct_xref_manytomany')); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php index fb9d11c6a8d..422f1b960fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php @@ -60,14 +60,14 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetomany_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); } /** @@ -90,9 +90,9 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, $owning); } /** @@ -115,10 +115,10 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $auxiliary->id4); - $this->assertEquals('def', $inversed->id1); - $this->assertEquals('abc', $inversed->foreignEntity->id4); - $this->assertEquals('ghi', $owning->id2); + self::assertEquals('abc', $auxiliary->id4); + self::assertEquals('def', $inversed->id1); + self::assertEquals('abc', $inversed->foreignEntity->id4); + self::assertEquals('ghi', $owning->id2); } /** @@ -136,7 +136,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -151,9 +151,9 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertSame('def', $inversedProxy->id1, 'Proxy identifier is converted'); + self::assertSame('def', $inversedProxy->id1, 'Proxy identifier is converted'); - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -166,6 +166,6 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void ['id1' => 'def', 'foreignEntity' => 'abc'] ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php index e0a323b6b5d..0ec1e7aa54b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php @@ -54,12 +54,12 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetomany_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetomany_compositeid LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_manytoone_compositeid LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_manytoone_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_manytoone_compositeid LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_manytoone_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_manytoone_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_manytoone_compositeid LIMIT 1')); } /** @@ -77,8 +77,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, $owning); } /** @@ -96,9 +96,9 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $inversed->id2); - $this->assertEquals('ghi', $owning->id3); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $inversed->id2); + self::assertEquals('ghi', $owning->id3); } /** @@ -113,7 +113,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -126,6 +126,6 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void ['id1' => 'abc', 'id2' => 'def'] ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php index 512cbdfa11b..b8a417fb901 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php @@ -68,7 +68,7 @@ public function testThatExtraLazyCollectionIsCounted(): void 'abc' ); - $this->assertEquals(3, $inversed->associatedEntities->count()); + self::assertEquals(3, $inversed->associatedEntities->count()); } public function testThatExtraLazyCollectionContainsAnEntity(): void @@ -83,7 +83,7 @@ public function testThatExtraLazyCollectionContainsAnEntity(): void 'def' ); - $this->assertTrue($inversed->associatedEntities->contains($owning)); + self::assertTrue($inversed->associatedEntities->contains($owning)); } public function testThatExtraLazyCollectionContainsAnIndexbyKey(): void @@ -93,7 +93,7 @@ public function testThatExtraLazyCollectionContainsAnIndexbyKey(): void 'abc' ); - $this->assertTrue($inversed->associatedEntities->containsKey('def')); + self::assertTrue($inversed->associatedEntities->containsKey('def')); } public function testThatASliceOfTheExtraLazyCollectionIsLoaded(): void @@ -103,6 +103,6 @@ public function testThatASliceOfTheExtraLazyCollectionIsLoaded(): void 'abc' ); - $this->assertCount(2, $inversed->associatedEntities->slice(0, 2)); + self::assertCount(2, $inversed->associatedEntities->slice(0, 2)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php index 9e65c899467..c69ca285bfd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php @@ -53,10 +53,10 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetomany LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_manytoone LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_manytoone LIMIT 1')); } /** @@ -74,8 +74,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'def' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToManyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningManyToOneEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneEntity::class, $owning); } /** @@ -93,8 +93,8 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'def' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $owning->id2); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $owning->id2); } /** @@ -109,7 +109,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -122,6 +122,6 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void 'abc' ); - $this->assertCount(1, $inversed->associatedEntities); + self::assertCount(1, $inversed->associatedEntities); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php index a5467be8b14..6155b09ef9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php @@ -59,14 +59,14 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id4 FROM vct_auxiliary LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT foreign_id FROM vct_inversed_onetoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_foreign_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); } /** @@ -89,9 +89,9 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $owning); } /** @@ -114,10 +114,10 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $auxiliary->id4); - $this->assertEquals('def', $inversed->id1); - $this->assertEquals('abc', $inversed->foreignEntity->id4); - $this->assertEquals('ghi', $owning->id2); + self::assertEquals('abc', $auxiliary->id4); + self::assertEquals('def', $inversed->id1); + self::assertEquals('abc', $inversed->foreignEntity->id4); + self::assertEquals('ghi', $owning->id2); } /** @@ -135,7 +135,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -150,7 +150,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -163,6 +163,6 @@ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void ['id1' => 'def', 'foreignEntity' => 'abc'] ); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php index f4fdb05b8d1..5011f58f36f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php @@ -53,12 +53,12 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetoone_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_inversed_onetoone_compositeid LIMIT 1')); - $this->assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_onetoone_compositeid LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_onetoone_compositeid LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_onetoone_compositeid LIMIT 1')); + self::assertEquals('tuv', $conn->fetchColumn('SELECT id3 FROM vct_owning_onetoone_compositeid LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_id1 FROM vct_owning_onetoone_compositeid LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT associated_id2 FROM vct_owning_onetoone_compositeid LIMIT 1')); } /** @@ -76,8 +76,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'ghi' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $owning); } /** @@ -95,9 +95,9 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'ghi' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $inversed->id2); - $this->assertEquals('ghi', $owning->id3); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $inversed->id2); + self::assertEquals('ghi', $owning->id3); } /** @@ -112,7 +112,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -125,6 +125,6 @@ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void ['id1' => 'abc', 'id2' => 'def'] ); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php index 8143a478fb9..55b359fc1c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php @@ -53,10 +53,10 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void { $conn = $this->_em->getConnection(); - $this->assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT id1 FROM vct_inversed_onetoone LIMIT 1')); - $this->assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone LIMIT 1')); - $this->assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone LIMIT 1')); + self::assertEquals('qrs', $conn->fetchColumn('SELECT id2 FROM vct_owning_onetoone LIMIT 1')); + self::assertEquals('nop', $conn->fetchColumn('SELECT associated_id FROM vct_owning_onetoone LIMIT 1')); } /** @@ -74,8 +74,8 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void 'def' ); - $this->assertInstanceOf(Models\ValueConversionType\InversedOneToOneEntity::class, $inversed); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $owning); + self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneEntity::class, $inversed); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $owning); } /** @@ -93,8 +93,8 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr 'def' ); - $this->assertEquals('abc', $inversed->id1); - $this->assertEquals('def', $owning->id2); + self::assertEquals('abc', $inversed->id1); + self::assertEquals('def', $owning->id2); } /** @@ -109,7 +109,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void $inversedProxy = $owning->associatedEntity; - $this->assertEquals('some value to be loaded', $inversedProxy->someProperty); + self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } /** @@ -122,6 +122,6 @@ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void 'abc' ); - $this->assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 6fc42a0f20a..78845c1f9db 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -55,18 +55,18 @@ public function testMetadataHasReflectionEmbeddablesAccessible(): void $classMetadata = $this->_em->getClassMetadata(DDC93Person::class); if (class_exists(CommonRuntimePublicReflectionProperty::class)) { - $this->assertInstanceOf( + self::assertInstanceOf( CommonRuntimePublicReflectionProperty::class, $classMetadata->getReflectionProperty('address') ); } else { - $this->assertInstanceOf( + self::assertInstanceOf( RuntimePublicReflectionProperty::class, $classMetadata->getReflectionProperty('address') ); } - $this->assertInstanceOf(ReflectionEmbeddedProperty::class, $classMetadata->getReflectionProperty('address.street')); + self::assertInstanceOf(ReflectionEmbeddedProperty::class, $classMetadata->getReflectionProperty('address.street')); } public function testCRUD(): void @@ -88,12 +88,12 @@ public function testCRUD(): void // 2. check loading value objects works $person = $this->_em->find(DDC93Person::class, $person->id); - $this->assertInstanceOf(DDC93Address::class, $person->address); - $this->assertEquals('United States of Tara Street', $person->address->street); - $this->assertEquals('12345', $person->address->zip); - $this->assertEquals('funkytown', $person->address->city); - $this->assertInstanceOf(DDC93Country::class, $person->address->country); - $this->assertEquals('Germany', $person->address->country->name); + self::assertInstanceOf(DDC93Address::class, $person->address); + self::assertEquals('United States of Tara Street', $person->address->street); + self::assertEquals('12345', $person->address->zip); + self::assertEquals('funkytown', $person->address->city); + self::assertInstanceOf(DDC93Country::class, $person->address->country); + self::assertEquals('Germany', $person->address->country->name); // 3. check changing value objects works $person->address->street = 'Street'; @@ -106,10 +106,10 @@ public function testCRUD(): void $person = $this->_em->find(DDC93Person::class, $person->id); - $this->assertEquals('Street', $person->address->street); - $this->assertEquals('54321', $person->address->zip); - $this->assertEquals('another town', $person->address->city); - $this->assertEquals('United States of America', $person->address->country->name); + self::assertEquals('Street', $person->address->street); + self::assertEquals('54321', $person->address->zip); + self::assertEquals('another town', $person->address->city); + self::assertEquals('United States of America', $person->address->country->name); // 4. check deleting works $personId = $person->id; @@ -117,7 +117,7 @@ public function testCRUD(): void $this->_em->remove($person); $this->_em->flush(); - $this->assertNull($this->_em->find(DDC93Person::class, $personId)); + self::assertNull($this->_em->find(DDC93Person::class, $personId)); } public function testLoadDql(): void @@ -140,24 +140,24 @@ public function testLoadDql(): void $dql = 'SELECT p FROM ' . __NAMESPACE__ . '\DDC93Person p'; $persons = $this->_em->createQuery($dql)->getResult(); - $this->assertCount(3, $persons); + self::assertCount(3, $persons); foreach ($persons as $person) { - $this->assertInstanceOf(DDC93Address::class, $person->address); - $this->assertEquals('Tree', $person->address->street); - $this->assertEquals('12345', $person->address->zip); - $this->assertEquals('funkytown', $person->address->city); - $this->assertInstanceOf(DDC93Country::class, $person->address->country); - $this->assertEquals('United States of America', $person->address->country->name); + self::assertInstanceOf(DDC93Address::class, $person->address); + self::assertEquals('Tree', $person->address->street); + self::assertEquals('12345', $person->address->zip); + self::assertEquals('funkytown', $person->address->city); + self::assertInstanceOf(DDC93Country::class, $person->address->country); + self::assertEquals('United States of America', $person->address->country->name); } $dql = 'SELECT p FROM ' . __NAMESPACE__ . '\DDC93Person p'; $persons = $this->_em->createQuery($dql)->getArrayResult(); foreach ($persons as $person) { - $this->assertEquals('Tree', $person['address.street']); - $this->assertEquals('12345', $person['address.zip']); - $this->assertEquals('funkytown', $person['address.city']); - $this->assertEquals('United States of America', $person['address.country.name']); + self::assertEquals('Tree', $person['address.street']); + self::assertEquals('12345', $person['address.zip']); + self::assertEquals('funkytown', $person['address.city']); + self::assertEquals('United States of America', $person['address.country.name']); } } @@ -167,7 +167,7 @@ public function testLoadDql(): void public function testDqlOnEmbeddedObjectsField(): void { if ($this->isSecondLevelCacheEnabled) { - $this->markTestSkipped('SLC does not work with UPDATE/DELETE queries through EM.'); + self::markTestSkipped('SLC does not work with UPDATE/DELETE queries through EM.'); } $person = new DDC93Person('Johannes', new DDC93Address('Moo', '12345', 'Karlsruhe', new DDC93Country('Germany'))); @@ -180,9 +180,9 @@ public function testDqlOnEmbeddedObjectsField(): void ->setParameter('city', 'Karlsruhe') ->setParameter('country', 'Germany') ->getSingleResult(); - $this->assertEquals($person, $loadedPerson); + self::assertEquals($person, $loadedPerson); - $this->assertNull( + self::assertNull( $this->_em->createQuery($selectDql) ->setParameter('city', 'asdf') ->setParameter('country', 'Germany') @@ -198,8 +198,8 @@ public function testDqlOnEmbeddedObjectsField(): void ->execute(); $this->_em->refresh($person); - $this->assertEquals('Boo', $person->address->street); - $this->assertEquals('DE', $person->address->country->name); + self::assertEquals('Boo', $person->address->street); + self::assertEquals('DE', $person->address->country->name); // DELETE $this->_em->createQuery('DELETE ' . __NAMESPACE__ . '\\DDC93Person p WHERE p.address.city = :city AND p.address.country.name = :country') @@ -208,7 +208,7 @@ public function testDqlOnEmbeddedObjectsField(): void ->execute(); $this->_em->clear(); - $this->assertNull($this->_em->find(DDC93Person::class, $person->id)); + self::assertNull($this->_em->find(DDC93Person::class, $person->id)); } public function testPartialDqlOnEmbeddedObjectsField(): void @@ -225,10 +225,10 @@ public function testPartialDqlOnEmbeddedObjectsField(): void ->setParameter('name', 'Karl') ->getSingleResult(); - $this->assertEquals('Gosport', $person->address->city); - $this->assertEquals('Foo', $person->address->street); - $this->assertEquals('12345', $person->address->zip); - $this->assertEquals('England', $person->address->country->name); + self::assertEquals('Gosport', $person->address->city); + self::assertEquals('Foo', $person->address->street); + self::assertEquals('12345', $person->address->zip); + self::assertEquals('England', $person->address->country->name); // Clear the EM and prove that the embeddable can be the subject of a partial query. $this->_em->clear(); @@ -240,11 +240,11 @@ public function testPartialDqlOnEmbeddedObjectsField(): void ->getSingleResult(); // Selected field must be equal, all other fields must be null. - $this->assertEquals('Gosport', $person->address->city); - $this->assertNull($person->address->street); - $this->assertNull($person->address->zip); - $this->assertNull($person->address->country); - $this->assertNull($person->name); + self::assertEquals('Gosport', $person->address->city); + self::assertNull($person->address->street); + self::assertNull($person->address->zip); + self::assertNull($person->address->country); + self::assertNull($person->name); // Clear the EM and prove that the embeddable can be the subject of a partial query regardless of attributes positions. $this->_em->clear(); @@ -256,11 +256,11 @@ public function testPartialDqlOnEmbeddedObjectsField(): void ->getSingleResult(); // Selected field must be equal, all other fields must be null. - $this->assertEquals('Gosport', $person->address->city); - $this->assertNull($person->address->street); - $this->assertNull($person->address->zip); - $this->assertNull($person->address->country); - $this->assertNull($person->name); + self::assertEquals('Gosport', $person->address->city); + self::assertNull($person->address->street); + self::assertNull($person->address->zip); + self::assertNull($person->address->country); + self::assertNull($person->name); } public function testDqlWithNonExistentEmbeddableField(): void @@ -288,27 +288,27 @@ public function testEmbeddableWithInheritance(): void $this->_em->flush(); $reloadedCar = $this->_em->find(DDC93Car::class, $car->id); - $this->assertEquals($car, $reloadedCar); + self::assertEquals($car, $reloadedCar); } public function testInlineEmbeddableWithPrefix(): void { $metadata = $this->_em->getClassMetadata(DDC3028PersonWithPrefix::class); - $this->assertEquals('foobar_id', $metadata->getColumnName('id.id')); - $this->assertEquals('bloo_foo_id', $metadata->getColumnName('nested.nestedWithPrefix.id')); - $this->assertEquals('bloo_nestedWithEmptyPrefix_id', $metadata->getColumnName('nested.nestedWithEmptyPrefix.id')); - $this->assertEquals('bloo_id', $metadata->getColumnName('nested.nestedWithPrefixFalse.id')); + self::assertEquals('foobar_id', $metadata->getColumnName('id.id')); + self::assertEquals('bloo_foo_id', $metadata->getColumnName('nested.nestedWithPrefix.id')); + self::assertEquals('bloo_nestedWithEmptyPrefix_id', $metadata->getColumnName('nested.nestedWithEmptyPrefix.id')); + self::assertEquals('bloo_id', $metadata->getColumnName('nested.nestedWithPrefixFalse.id')); } public function testInlineEmbeddableEmptyPrefix(): void { $metadata = $this->_em->getClassMetadata(DDC3028PersonEmptyPrefix::class); - $this->assertEquals('id_id', $metadata->getColumnName('id.id')); - $this->assertEquals('nested_foo_id', $metadata->getColumnName('nested.nestedWithPrefix.id')); - $this->assertEquals('nested_nestedWithEmptyPrefix_id', $metadata->getColumnName('nested.nestedWithEmptyPrefix.id')); - $this->assertEquals('nested_id', $metadata->getColumnName('nested.nestedWithPrefixFalse.id')); + self::assertEquals('id_id', $metadata->getColumnName('id.id')); + self::assertEquals('nested_foo_id', $metadata->getColumnName('nested.nestedWithPrefix.id')); + self::assertEquals('nested_nestedWithEmptyPrefix_id', $metadata->getColumnName('nested.nestedWithEmptyPrefix.id')); + self::assertEquals('nested_id', $metadata->getColumnName('nested.nestedWithPrefixFalse.id')); } public function testInlineEmbeddablePrefixFalse(): void @@ -319,7 +319,7 @@ public function testInlineEmbeddablePrefixFalse(): void ->getClassMetadata(DDC3028PersonPrefixFalse::class) ->getColumnName('id.id'); - $this->assertEquals($expectedColumnName, $actualColumnName); + self::assertEquals($expectedColumnName, $actualColumnName); } public function testInlineEmbeddableInMappedSuperClass(): void @@ -328,7 +328,7 @@ public function testInlineEmbeddableInMappedSuperClass(): void ->getClassMetadata(DDC3027Dog::class) ->hasField('address.street'); - $this->assertTrue($isFieldMapped); + self::assertTrue($isFieldMapped); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php index f970f965752..483d2e587b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php @@ -56,8 +56,8 @@ public function testSetVersionOnCreate(): void $secondEntity = $this->_em->getRepository(SecondRelatedEntity::class) ->findOneBy(['name' => 'Bob']); - $this->assertSame($firstRelatedEntity, $firstEntity); - $this->assertSame($secondRelatedEntity, $secondEntity); - $this->assertSame($firstEntity->secondEntity, $secondEntity); + self::assertSame($firstRelatedEntity, $firstEntity); + self::assertSame($secondRelatedEntity, $secondEntity); + self::assertSame($firstEntity->secondEntity, $secondEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php index 201614953c2..23219fdd97c 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php @@ -60,14 +60,14 @@ public function testSimpleEntityQuery(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); + self::assertEquals(1, $result[0]['id']); + self::assertEquals('romanb', $result[0]['name']); - $this->assertEquals(2, $result[1]['id']); - $this->assertEquals('jwage', $result[1]['name']); + self::assertEquals(2, $result[1]['id']); + self::assertEquals('jwage', $result[1]['name']); } /** @@ -104,24 +104,24 @@ public function testSimpleEntityWithScalarQuery($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); - $this->assertArrayHasKey('nameUpper', $result[0]); - $this->assertArrayNotHasKey('id', $result[0]); - $this->assertArrayNotHasKey('name', $result[0]); + self::assertArrayHasKey('nameUpper', $result[0]); + self::assertArrayNotHasKey('id', $result[0]); + self::assertArrayNotHasKey('name', $result[0]); - $this->assertArrayHasKey(0, $result[0]); - $this->assertArrayHasKey('id', $result[0][0]); - $this->assertArrayHasKey('name', $result[0][0]); + self::assertArrayHasKey(0, $result[0]); + self::assertArrayHasKey('id', $result[0][0]); + self::assertArrayHasKey('name', $result[0][0]); - $this->assertArrayHasKey('nameUpper', $result[1]); - $this->assertArrayNotHasKey('id', $result[1]); - $this->assertArrayNotHasKey('name', $result[1]); + self::assertArrayHasKey('nameUpper', $result[1]); + self::assertArrayNotHasKey('id', $result[1]); + self::assertArrayNotHasKey('name', $result[1]); - $this->assertArrayHasKey(0, $result[1]); - $this->assertArrayHasKey('id', $result[1][0]); - $this->assertArrayHasKey('name', $result[1][0]); + self::assertArrayHasKey(0, $result[1]); + self::assertArrayHasKey('id', $result[1][0]); + self::assertArrayHasKey('name', $result[1][0]); } /** @@ -152,16 +152,16 @@ public function testSimpleEntityQueryWithAliasedUserEntity(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); + self::assertArrayHasKey('user', $result[0]); + self::assertEquals(1, $result[0]['user']['id']); + self::assertEquals('romanb', $result[0]['user']['name']); - $this->assertArrayHasKey('user', $result[1]); - $this->assertEquals(2, $result[1]['user']['id']); - $this->assertEquals('jwage', $result[1]['user']['name']); + self::assertArrayHasKey('user', $result[1]); + self::assertEquals(2, $result[1]['user']['id']); + self::assertEquals('jwage', $result[1]['user']['name']); } /** @@ -199,19 +199,19 @@ public function testSimpleMultipleRootEntityQuery(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); + self::assertEquals(1, $result[0]['id']); + self::assertEquals('romanb', $result[0]['name']); - $this->assertEquals(1, $result[1]['id']); - $this->assertEquals('Cool things.', $result[1]['topic']); + self::assertEquals(1, $result[1]['id']); + self::assertEquals('Cool things.', $result[1]['topic']); - $this->assertEquals(2, $result[2]['id']); - $this->assertEquals('jwage', $result[2]['name']); + self::assertEquals(2, $result[2]['id']); + self::assertEquals('jwage', $result[2]['name']); - $this->assertEquals(2, $result[3]['id']); - $this->assertEquals('Cool things II.', $result[3]['topic']); + self::assertEquals(2, $result[3]['id']); + self::assertEquals('Cool things II.', $result[3]['topic']); } /** @@ -249,23 +249,23 @@ public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); + self::assertArrayHasKey('user', $result[0]); + self::assertEquals(1, $result[0]['user']['id']); + self::assertEquals('romanb', $result[0]['user']['name']); - $this->assertArrayHasKey(0, $result[1]); - $this->assertEquals(1, $result[1][0]['id']); - $this->assertEquals('Cool things.', $result[1][0]['topic']); + self::assertArrayHasKey(0, $result[1]); + self::assertEquals(1, $result[1][0]['id']); + self::assertEquals('Cool things.', $result[1][0]['topic']); - $this->assertArrayHasKey('user', $result[2]); - $this->assertEquals(2, $result[2]['user']['id']); - $this->assertEquals('jwage', $result[2]['user']['name']); + self::assertArrayHasKey('user', $result[2]); + self::assertEquals(2, $result[2]['user']['id']); + self::assertEquals('jwage', $result[2]['user']['name']); - $this->assertArrayHasKey(0, $result[3]); - $this->assertEquals(2, $result[3][0]['id']); - $this->assertEquals('Cool things II.', $result[3][0]['topic']); + self::assertArrayHasKey(0, $result[3]); + self::assertEquals(2, $result[3][0]['id']); + self::assertEquals('Cool things II.', $result[3][0]['topic']); } /** @@ -303,23 +303,23 @@ public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity(): voi $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertArrayHasKey(0, $result[0]); - $this->assertEquals(1, $result[0][0]['id']); - $this->assertEquals('romanb', $result[0][0]['name']); + self::assertArrayHasKey(0, $result[0]); + self::assertEquals(1, $result[0][0]['id']); + self::assertEquals('romanb', $result[0][0]['name']); - $this->assertArrayHasKey('article', $result[1]); - $this->assertEquals(1, $result[1]['article']['id']); - $this->assertEquals('Cool things.', $result[1]['article']['topic']); + self::assertArrayHasKey('article', $result[1]); + self::assertEquals(1, $result[1]['article']['id']); + self::assertEquals('Cool things.', $result[1]['article']['topic']); - $this->assertArrayHasKey(0, $result[2]); - $this->assertEquals(2, $result[2][0]['id']); - $this->assertEquals('jwage', $result[2][0]['name']); + self::assertArrayHasKey(0, $result[2]); + self::assertEquals(2, $result[2][0]['id']); + self::assertEquals('jwage', $result[2][0]['name']); - $this->assertArrayHasKey('article', $result[3]); - $this->assertEquals(2, $result[3]['article']['id']); - $this->assertEquals('Cool things II.', $result[3]['article']['topic']); + self::assertArrayHasKey('article', $result[3]); + self::assertEquals(2, $result[3]['article']['id']); + self::assertEquals('Cool things II.', $result[3]['article']['topic']); } /** @@ -357,23 +357,23 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertArrayHasKey('user', $result[0]); - $this->assertEquals(1, $result[0]['user']['id']); - $this->assertEquals('romanb', $result[0]['user']['name']); + self::assertArrayHasKey('user', $result[0]); + self::assertEquals(1, $result[0]['user']['id']); + self::assertEquals('romanb', $result[0]['user']['name']); - $this->assertArrayHasKey('article', $result[1]); - $this->assertEquals(1, $result[1]['article']['id']); - $this->assertEquals('Cool things.', $result[1]['article']['topic']); + self::assertArrayHasKey('article', $result[1]); + self::assertEquals(1, $result[1]['article']['id']); + self::assertEquals('Cool things.', $result[1]['article']['topic']); - $this->assertArrayHasKey('user', $result[2]); - $this->assertEquals(2, $result[2]['user']['id']); - $this->assertEquals('jwage', $result[2]['user']['name']); + self::assertArrayHasKey('user', $result[2]); + self::assertEquals(2, $result[2]['user']['id']); + self::assertEquals('jwage', $result[2]['user']['name']); - $this->assertArrayHasKey('article', $result[3]); - $this->assertEquals(2, $result[3]['article']['id']); - $this->assertEquals('Cool things II.', $result[3]['article']['topic']); + self::assertArrayHasKey('article', $result[3]); + self::assertEquals(2, $result[3]['article']['id']); + self::assertEquals('Cool things II.', $result[3]['article']['topic']); } /** @@ -412,18 +412,18 @@ public function testMixedQueryNormalJoin($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers - $this->assertArrayHasKey($userEntityKey, $result[0]); - $this->assertEquals(2, $result[0]['numPhones']); + self::assertArrayHasKey($userEntityKey, $result[0]); + self::assertEquals(2, $result[0]['numPhones']); // second user => 1 phonenumber - $this->assertArrayHasKey($userEntityKey, $result[1]); - $this->assertEquals(1, $result[1]['numPhones']); + self::assertArrayHasKey($userEntityKey, $result[1]); + self::assertEquals(1, $result[1]['numPhones']); } /** @@ -476,23 +476,23 @@ public function testMixedQueryFetchJoin($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers - $this->assertEquals(2, count($result[0][$userEntityKey]['phonenumbers'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals(2, count($result[0][$userEntityKey]['phonenumbers'])); + self::assertEquals('ROMANB', $result[0]['nameUpper']); // second user => 1 phonenumber - $this->assertEquals(1, count($result[1][$userEntityKey]['phonenumbers'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); + self::assertEquals(1, count($result[1][$userEntityKey]['phonenumbers'])); + self::assertEquals('JWAGE', $result[1]['nameUpper']); - $this->assertEquals(42, $result[0][$userEntityKey]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][$userEntityKey]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][$userEntityKey]['phonenumbers'][0]['phonenumber']); + self::assertEquals(42, $result[0][$userEntityKey]['phonenumbers'][0]['phonenumber']); + self::assertEquals(43, $result[0][$userEntityKey]['phonenumbers'][1]['phonenumber']); + self::assertEquals(91, $result[1][$userEntityKey]['phonenumbers'][0]['phonenumber']); } /** @@ -549,26 +549,26 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[1])); - $this->assertTrue(is_array($result[2])); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[1])); + self::assertTrue(is_array($result[2])); // test the scalar values - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); + self::assertEquals('ROMANB', $result[1]['nameUpper']); + self::assertEquals('JWAGE', $result[2]['nameUpper']); // first user => 2 phonenumbers. notice the custom indexing by user id - $this->assertEquals(2, count($result[1][$userEntityKey]['phonenumbers'])); + self::assertEquals(2, count($result[1][$userEntityKey]['phonenumbers'])); // second user => 1 phonenumber. notice the custom indexing by user id - $this->assertEquals(1, count($result[2][$userEntityKey]['phonenumbers'])); + self::assertEquals(1, count($result[2][$userEntityKey]['phonenumbers'])); // test the custom indexing of the phonenumbers - $this->assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['42'])); - $this->assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['43'])); - $this->assertTrue(isset($result[2][$userEntityKey]['phonenumbers']['91'])); + self::assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['42'])); + self::assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['43'])); + self::assertTrue(isset($result[2][$userEntityKey]['phonenumbers']['91'])); } /** @@ -663,27 +663,27 @@ public function testMixedQueryMultipleFetchJoin(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers, 2 articles - $this->assertEquals(2, count($result[0][0]['phonenumbers'])); - $this->assertEquals(2, count($result[0][0]['articles'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals(2, count($result[0][0]['phonenumbers'])); + self::assertEquals(2, count($result[0][0]['articles'])); + self::assertEquals('ROMANB', $result[0]['nameUpper']); // second user => 1 phonenumber, 2 articles - $this->assertEquals(1, count($result[1][0]['phonenumbers'])); - $this->assertEquals(2, count($result[1][0]['articles'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); - - $this->assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); - - $this->assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); - $this->assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); - $this->assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); - $this->assertEquals('PHP7', $result[1][0]['articles'][1]['topic']); + self::assertEquals(1, count($result[1][0]['phonenumbers'])); + self::assertEquals(2, count($result[1][0]['articles'])); + self::assertEquals('JWAGE', $result[1]['nameUpper']); + + self::assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); + self::assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); + self::assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); + + self::assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); + self::assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); + self::assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); + self::assertEquals('PHP7', $result[1][0]['articles'][1]['topic']); } /** @@ -802,41 +802,41 @@ public function testMixedQueryMultipleDeepMixedFetchJoin(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); // first user => 2 phonenumbers, 2 articles, 1 comment on first article - $this->assertEquals(2, count($result[0][0]['phonenumbers'])); - $this->assertEquals(2, count($result[0][0]['articles'])); - $this->assertEquals(1, count($result[0][0]['articles'][0]['comments'])); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals(2, count($result[0][0]['phonenumbers'])); + self::assertEquals(2, count($result[0][0]['articles'])); + self::assertEquals(1, count($result[0][0]['articles'][0]['comments'])); + self::assertEquals('ROMANB', $result[0]['nameUpper']); // second user => 1 phonenumber, 2 articles, no comments - $this->assertEquals(1, count($result[1][0]['phonenumbers'])); - $this->assertEquals(2, count($result[1][0]['articles'])); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); + self::assertEquals(1, count($result[1][0]['phonenumbers'])); + self::assertEquals(2, count($result[1][0]['articles'])); + self::assertEquals('JWAGE', $result[1]['nameUpper']); - $this->assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); - $this->assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); - $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); + self::assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); + self::assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); + self::assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); - $this->assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); - $this->assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); - $this->assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); - $this->assertEquals('PHP7', $result[1][0]['articles'][1]['topic']); + self::assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); + self::assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); + self::assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); + self::assertEquals('PHP7', $result[1][0]['articles'][1]['topic']); - $this->assertEquals('First!', $result[0][0]['articles'][0]['comments'][0]['topic']); + self::assertEquals('First!', $result[0][0]['articles'][0]['comments'][0]['topic']); - $this->assertTrue(isset($result[0][0]['articles'][0]['comments'])); + self::assertTrue(isset($result[0][0]['articles'][0]['comments'])); // empty comment collections - $this->assertTrue(is_array($result[0][0]['articles'][1]['comments'])); - $this->assertEquals(0, count($result[0][0]['articles'][1]['comments'])); - $this->assertTrue(is_array($result[1][0]['articles'][0]['comments'])); - $this->assertEquals(0, count($result[1][0]['articles'][0]['comments'])); - $this->assertTrue(is_array($result[1][0]['articles'][1]['comments'])); - $this->assertEquals(0, count($result[1][0]['articles'][1]['comments'])); + self::assertTrue(is_array($result[0][0]['articles'][1]['comments'])); + self::assertEquals(0, count($result[0][0]['articles'][1]['comments'])); + self::assertTrue(is_array($result[1][0]['articles'][0]['comments'])); + self::assertEquals(0, count($result[1][0]['articles'][0]['comments'])); + self::assertTrue(is_array($result[1][0]['articles'][1]['comments'])); + self::assertEquals(0, count($result[1][0]['articles'][1]['comments'])); } /** @@ -916,14 +916,14 @@ public function testEntityQueryCustomResultSetOrder(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - $this->assertTrue(isset($result[0]['boards'])); - $this->assertEquals(3, count($result[0]['boards'])); - $this->assertTrue(isset($result[1]['boards'])); - $this->assertEquals(1, count($result[1]['boards'])); + self::assertEquals(2, count($result)); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); + self::assertTrue(isset($result[0]['boards'])); + self::assertEquals(3, count($result[0]['boards'])); + self::assertTrue(isset($result[1]['boards'])); + self::assertEquals(1, count($result[1]['boards'])); } /** @@ -979,25 +979,25 @@ public function testChainedJoinWithScalars($entityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(3, count($result)); - - $this->assertEquals(2, count($result[0][$entityKey])); // User array - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('The First', $result[0]['topic']); - $this->assertEquals(1, $result[0]['cid']); - $this->assertEquals('First Comment', $result[0]['ctopic']); - - $this->assertEquals(2, count($result[1][$entityKey])); // User array, duplicated - $this->assertEquals(1, $result[1]['id']); // duplicated - $this->assertEquals('The First', $result[1]['topic']); // duplicated - $this->assertEquals(2, $result[1]['cid']); - $this->assertEquals('Second Comment', $result[1]['ctopic']); - - $this->assertEquals(2, count($result[2][$entityKey])); // User array, duplicated - $this->assertEquals(42, $result[2]['id']); - $this->assertEquals('The Answer', $result[2]['topic']); - $this->assertNull($result[2]['cid']); - $this->assertNull($result[2]['ctopic']); + self::assertEquals(3, count($result)); + + self::assertEquals(2, count($result[0][$entityKey])); // User array + self::assertEquals(1, $result[0]['id']); + self::assertEquals('The First', $result[0]['topic']); + self::assertEquals(1, $result[0]['cid']); + self::assertEquals('First Comment', $result[0]['ctopic']); + + self::assertEquals(2, count($result[1][$entityKey])); // User array, duplicated + self::assertEquals(1, $result[1]['id']); // duplicated + self::assertEquals('The First', $result[1]['topic']); // duplicated + self::assertEquals(2, $result[1]['cid']); + self::assertEquals('Second Comment', $result[1]['ctopic']); + + self::assertEquals(2, count($result[2][$entityKey])); // User array, duplicated + self::assertEquals(42, $result[2]['id']); + self::assertEquals('The Answer', $result[2]['topic']); + self::assertNull($result[2]['cid']); + self::assertNull($result[2]['ctopic']); } /** @@ -1030,15 +1030,15 @@ public function testResultIteration(): void $rowNum = 0; while (($row = $iterator->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertTrue(is_array($row[0])); + self::assertEquals(1, count($row)); + self::assertTrue(is_array($row[0])); if ($rowNum === 0) { - $this->assertEquals(1, $row[0]['id']); - $this->assertEquals('romanb', $row[0]['name']); + self::assertEquals(1, $row[0]['id']); + self::assertEquals('romanb', $row[0]['name']); } elseif ($rowNum === 1) { - $this->assertEquals(2, $row[0]['id']); - $this->assertEquals('jwage', $row[0]['name']); + self::assertEquals(2, $row[0]['id']); + self::assertEquals('jwage', $row[0]['name']); } ++$rowNum; @@ -1075,16 +1075,16 @@ public function testResultIterationWithAliasedUserEntity(): void $rowNum = 0; while (($row = $iterator->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertArrayHasKey(0, $row); - $this->assertArrayHasKey('user', $row[0]); + self::assertEquals(1, count($row)); + self::assertArrayHasKey(0, $row); + self::assertArrayHasKey('user', $row[0]); if ($rowNum === 0) { - $this->assertEquals(1, $row[0]['user']['id']); - $this->assertEquals('romanb', $row[0]['user']['name']); + self::assertEquals(1, $row[0]['user']['id']); + self::assertEquals('romanb', $row[0]['user']['name']); } elseif ($rowNum === 1) { - $this->assertEquals(2, $row[0]['user']['id']); - $this->assertEquals('jwage', $row[0]['user']['name']); + self::assertEquals(2, $row[0]['user']['id']); + self::assertEquals('jwage', $row[0]['user']['name']); } ++$rowNum; @@ -1118,10 +1118,10 @@ public function testSkipUnknownColumns(): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, count($result)); - $this->assertArrayHasKey('id', $result[0]); - $this->assertArrayHasKey('name', $result[0]); - $this->assertArrayNotHasKey('foo', $result[0]); + self::assertEquals(1, count($result)); + self::assertArrayHasKey('id', $result[0]); + self::assertArrayHasKey('name', $result[0]); + self::assertArrayNotHasKey('foo', $result[0]); } /** @@ -1169,17 +1169,17 @@ public function testMissingIdForRootEntity($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(4, count($result), 'Should hydrate four results.'); + self::assertEquals(4, count($result), 'Should hydrate four results.'); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); - $this->assertEquals('JWAGE', $result[3]['nameUpper']); + self::assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals('ROMANB', $result[1]['nameUpper']); + self::assertEquals('JWAGE', $result[2]['nameUpper']); + self::assertEquals('JWAGE', $result[3]['nameUpper']); - $this->assertEquals(['id' => 1, 'status' => 'developer'], $result[0][$userEntityKey]); - $this->assertNull($result[1][$userEntityKey]); - $this->assertEquals(['id' => 2, 'status' => 'developer'], $result[2][$userEntityKey]); - $this->assertNull($result[3][$userEntityKey]); + self::assertEquals(['id' => 1, 'status' => 'developer'], $result[0][$userEntityKey]); + self::assertNull($result[1][$userEntityKey]); + self::assertEquals(['id' => 2, 'status' => 'developer'], $result[2][$userEntityKey]); + self::assertNull($result[3][$userEntityKey]); } /** @@ -1219,12 +1219,12 @@ public function testIndexByAndMixedResult($userEntityKey): void $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(isset($result[1])); - $this->assertEquals(1, $result[1][$userEntityKey]['id']); + self::assertTrue(isset($result[1])); + self::assertEquals(1, $result[1][$userEntityKey]['id']); - $this->assertTrue(isset($result[2])); - $this->assertEquals(2, $result[2][$userEntityKey]['id']); + self::assertTrue(isset($result[2])); + self::assertEquals(2, $result[2][$userEntityKey]['id']); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php index 1fd09f7e765..d5e9ad7d96f 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php @@ -15,8 +15,8 @@ public function testCustomHydrator(): void $config->addCustomHydrationMode('CustomHydrator', CustomHydrator::class); $hydrator = $em->newHydrator('CustomHydrator'); - $this->assertInstanceOf(CustomHydrator::class, $hydrator); - $this->assertNull($config->getCustomHydrationMode('does not exist')); + self::assertInstanceOf(CustomHydrator::class, $hydrator); + self::assertNull($config->getCustomHydrationMode('does not exist')); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index 4869d9337f2..ebf4046f9a1 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -94,16 +94,16 @@ public function testSimpleEntityQuery(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[1]); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertInstanceOf(CmsUser::class, $result[1]); - $this->assertEquals(1, $result[0]->id); - $this->assertEquals('romanb', $result[0]->name); + self::assertEquals(1, $result[0]->id); + self::assertEquals('romanb', $result[0]->name); - $this->assertEquals(2, $result[1]->id); - $this->assertEquals('jwage', $result[1]->name); + self::assertEquals(2, $result[1]->id); + self::assertEquals('jwage', $result[1]->name); } /** @@ -133,19 +133,19 @@ public function testSimpleEntityQueryWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertArrayHasKey('user', $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertArrayHasKey('user', $result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertArrayHasKey('user', $result[1]); - $this->assertInstanceOf(CmsUser::class, $result[1]['user']); + self::assertArrayHasKey('user', $result[1]); + self::assertInstanceOf(CmsUser::class, $result[1]['user']); - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); + self::assertEquals(1, $result[0]['user']->id); + self::assertEquals('romanb', $result[0]['user']->name); - $this->assertEquals(2, $result[1]['user']->id); - $this->assertEquals('jwage', $result[1]['user']->name); + self::assertEquals(2, $result[1]['user']->id); + self::assertEquals('jwage', $result[1]['user']->name); } /** @@ -182,24 +182,24 @@ public function testSimpleMultipleRootEntityQuery(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result)); + self::assertEquals(4, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertInstanceOf(CmsArticle::class, $result[1]); - $this->assertInstanceOf(CmsUser::class, $result[2]); - $this->assertInstanceOf(CmsArticle::class, $result[3]); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertInstanceOf(CmsArticle::class, $result[1]); + self::assertInstanceOf(CmsUser::class, $result[2]); + self::assertInstanceOf(CmsArticle::class, $result[3]); - $this->assertEquals(1, $result[0]->id); - $this->assertEquals('romanb', $result[0]->name); + self::assertEquals(1, $result[0]->id); + self::assertEquals('romanb', $result[0]->name); - $this->assertEquals(1, $result[1]->id); - $this->assertEquals('Cool things.', $result[1]->topic); + self::assertEquals(1, $result[1]->id); + self::assertEquals('Cool things.', $result[1]->topic); - $this->assertEquals(2, $result[2]->id); - $this->assertEquals('jwage', $result[2]->name); + self::assertEquals(2, $result[2]->id); + self::assertEquals('jwage', $result[2]->name); - $this->assertEquals(2, $result[3]->id); - $this->assertEquals('Cool things II.', $result[3]->topic); + self::assertEquals(2, $result[3]->id); + self::assertEquals('Cool things II.', $result[3]->topic); } /** @@ -236,31 +236,31 @@ public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertArrayNotHasKey(0, $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); - - $this->assertArrayHasKey(0, $result[1]); - $this->assertArrayNotHasKey('user', $result[1]); - $this->assertInstanceOf(CmsArticle::class, $result[1][0]); - $this->assertEquals(1, $result[1][0]->id); - $this->assertEquals('Cool things.', $result[1][0]->topic); - - $this->assertArrayHasKey('user', $result[2]); - $this->assertArrayNotHasKey(0, $result[2]); - $this->assertInstanceOf(CmsUser::class, $result[2]['user']); - $this->assertEquals(2, $result[2]['user']->id); - $this->assertEquals('jwage', $result[2]['user']->name); - - $this->assertArrayHasKey(0, $result[3]); - $this->assertArrayNotHasKey('user', $result[3]); - $this->assertInstanceOf(CmsArticle::class, $result[3][0]); - $this->assertEquals(2, $result[3][0]->id); - $this->assertEquals('Cool things II.', $result[3][0]->topic); + self::assertEquals(4, count($result)); + + self::assertArrayHasKey('user', $result[0]); + self::assertArrayNotHasKey(0, $result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertEquals(1, $result[0]['user']->id); + self::assertEquals('romanb', $result[0]['user']->name); + + self::assertArrayHasKey(0, $result[1]); + self::assertArrayNotHasKey('user', $result[1]); + self::assertInstanceOf(CmsArticle::class, $result[1][0]); + self::assertEquals(1, $result[1][0]->id); + self::assertEquals('Cool things.', $result[1][0]->topic); + + self::assertArrayHasKey('user', $result[2]); + self::assertArrayNotHasKey(0, $result[2]); + self::assertInstanceOf(CmsUser::class, $result[2]['user']); + self::assertEquals(2, $result[2]['user']->id); + self::assertEquals('jwage', $result[2]['user']->name); + + self::assertArrayHasKey(0, $result[3]); + self::assertArrayNotHasKey('user', $result[3]); + self::assertInstanceOf(CmsArticle::class, $result[3][0]); + self::assertEquals(2, $result[3][0]->id); + self::assertEquals('Cool things II.', $result[3][0]->topic); } /** @@ -297,31 +297,31 @@ public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity(): voi $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey(0, $result[0]); - $this->assertArrayNotHasKey('article', $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0][0]); - $this->assertEquals(1, $result[0][0]->id); - $this->assertEquals('romanb', $result[0][0]->name); - - $this->assertArrayHasKey('article', $result[1]); - $this->assertArrayNotHasKey(0, $result[1]); - $this->assertInstanceOf(CmsArticle::class, $result[1]['article']); - $this->assertEquals(1, $result[1]['article']->id); - $this->assertEquals('Cool things.', $result[1]['article']->topic); - - $this->assertArrayHasKey(0, $result[2]); - $this->assertArrayNotHasKey('article', $result[2]); - $this->assertInstanceOf(CmsUser::class, $result[2][0]); - $this->assertEquals(2, $result[2][0]->id); - $this->assertEquals('jwage', $result[2][0]->name); - - $this->assertArrayHasKey('article', $result[3]); - $this->assertArrayNotHasKey(0, $result[3]); - $this->assertInstanceOf(CmsArticle::class, $result[3]['article']); - $this->assertEquals(2, $result[3]['article']->id); - $this->assertEquals('Cool things II.', $result[3]['article']->topic); + self::assertEquals(4, count($result)); + + self::assertArrayHasKey(0, $result[0]); + self::assertArrayNotHasKey('article', $result[0]); + self::assertInstanceOf(CmsUser::class, $result[0][0]); + self::assertEquals(1, $result[0][0]->id); + self::assertEquals('romanb', $result[0][0]->name); + + self::assertArrayHasKey('article', $result[1]); + self::assertArrayNotHasKey(0, $result[1]); + self::assertInstanceOf(CmsArticle::class, $result[1]['article']); + self::assertEquals(1, $result[1]['article']->id); + self::assertEquals('Cool things.', $result[1]['article']->topic); + + self::assertArrayHasKey(0, $result[2]); + self::assertArrayNotHasKey('article', $result[2]); + self::assertInstanceOf(CmsUser::class, $result[2][0]); + self::assertEquals(2, $result[2][0]->id); + self::assertEquals('jwage', $result[2][0]->name); + + self::assertArrayHasKey('article', $result[3]); + self::assertArrayNotHasKey(0, $result[3]); + self::assertInstanceOf(CmsArticle::class, $result[3]['article']); + self::assertEquals(2, $result[3]['article']->id); + self::assertEquals('Cool things II.', $result[3]['article']->topic); } /** @@ -358,31 +358,31 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result)); - - $this->assertArrayHasKey('user', $result[0]); - $this->assertArrayNotHasKey('article', $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertEquals(1, $result[0]['user']->id); - $this->assertEquals('romanb', $result[0]['user']->name); - - $this->assertArrayHasKey('article', $result[1]); - $this->assertArrayNotHasKey('user', $result[1]); - $this->assertInstanceOf(CmsArticle::class, $result[1]['article']); - $this->assertEquals(1, $result[1]['article']->id); - $this->assertEquals('Cool things.', $result[1]['article']->topic); - - $this->assertArrayHasKey('user', $result[2]); - $this->assertArrayNotHasKey('article', $result[2]); - $this->assertInstanceOf(CmsUser::class, $result[2]['user']); - $this->assertEquals(2, $result[2]['user']->id); - $this->assertEquals('jwage', $result[2]['user']->name); - - $this->assertArrayHasKey('article', $result[3]); - $this->assertArrayNotHasKey('user', $result[3]); - $this->assertInstanceOf(CmsArticle::class, $result[3]['article']); - $this->assertEquals(2, $result[3]['article']->id); - $this->assertEquals('Cool things II.', $result[3]['article']->topic); + self::assertEquals(4, count($result)); + + self::assertArrayHasKey('user', $result[0]); + self::assertArrayNotHasKey('article', $result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertEquals(1, $result[0]['user']->id); + self::assertEquals('romanb', $result[0]['user']->name); + + self::assertArrayHasKey('article', $result[1]); + self::assertArrayNotHasKey('user', $result[1]); + self::assertInstanceOf(CmsArticle::class, $result[1]['article']); + self::assertEquals(1, $result[1]['article']->id); + self::assertEquals('Cool things.', $result[1]['article']->topic); + + self::assertArrayHasKey('user', $result[2]); + self::assertArrayNotHasKey('article', $result[2]); + self::assertInstanceOf(CmsUser::class, $result[2]['user']); + self::assertEquals(2, $result[2]['user']->id); + self::assertEquals('jwage', $result[2]['user']->name); + + self::assertArrayHasKey('article', $result[3]); + self::assertArrayNotHasKey('user', $result[3]); + self::assertInstanceOf(CmsArticle::class, $result[3]['article']); + self::assertEquals(2, $result[3]['article']->id); + self::assertEquals('Cool things II.', $result[3]['article']->topic); } /** @@ -420,19 +420,19 @@ public function testMixedQueryNormalJoin($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result); - $this->assertIsArray($result[0]); - $this->assertIsArray($result[1]); + self::assertIsArray($result); + self::assertIsArray($result[0]); + self::assertIsArray($result[1]); // first user => 2 phonenumbers - $this->assertEquals(2, $result[0]['numPhones']); - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertEquals(2, $result[0]['numPhones']); + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); // second user => 1 phonenumber - $this->assertEquals(1, $result[1]['numPhones']); - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertEquals(1, $result[1]['numPhones']); + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); } /** @@ -484,31 +484,31 @@ public function testMixedQueryFetchJoin($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result); - $this->assertIsArray($result[0]); - $this->assertIsArray($result[1]); + self::assertIsArray($result); + self::assertIsArray($result[0]); + self::assertIsArray($result[1]); - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); // first user => 2 phonenumbers - $this->assertEquals(2, count($result[0][$userEntityKey]->phonenumbers)); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals(2, count($result[0][$userEntityKey]->phonenumbers)); + self::assertEquals('ROMANB', $result[0]['nameUpper']); // second user => 1 phonenumber - $this->assertEquals(1, count($result[1][$userEntityKey]->phonenumbers)); - $this->assertEquals('JWAGE', $result[1]['nameUpper']); + self::assertEquals(1, count($result[1][$userEntityKey]->phonenumbers)); + self::assertEquals('JWAGE', $result[1]['nameUpper']); - $this->assertEquals(42, $result[0][$userEntityKey]->phonenumbers[0]->phonenumber); - $this->assertEquals(43, $result[0][$userEntityKey]->phonenumbers[1]->phonenumber); - $this->assertEquals(91, $result[1][$userEntityKey]->phonenumbers[0]->phonenumber); + self::assertEquals(42, $result[0][$userEntityKey]->phonenumbers[0]->phonenumber); + self::assertEquals(43, $result[0][$userEntityKey]->phonenumbers[1]->phonenumber); + self::assertEquals(91, $result[1][$userEntityKey]->phonenumbers[0]->phonenumber); } /** @@ -564,30 +564,30 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result); - $this->assertIsArray($result[1]); - $this->assertIsArray($result[2]); + self::assertIsArray($result); + self::assertIsArray($result[1]); + self::assertIsArray($result[2]); // test the scalar values - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); + self::assertEquals('ROMANB', $result[1]['nameUpper']); + self::assertEquals('JWAGE', $result[2]['nameUpper']); - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); - $this->assertInstanceOf(CmsUser::class, $result[2][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[2][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); // first user => 2 phonenumbers. notice the custom indexing by user id - $this->assertEquals(2, count($result[1][$userEntityKey]->phonenumbers)); + self::assertEquals(2, count($result[1][$userEntityKey]->phonenumbers)); // second user => 1 phonenumber. notice the custom indexing by user id - $this->assertEquals(1, count($result[2][$userEntityKey]->phonenumbers)); + self::assertEquals(1, count($result[2][$userEntityKey]->phonenumbers)); // test the custom indexing of the phonenumbers - $this->assertTrue(isset($result[1][$userEntityKey]->phonenumbers['42'])); - $this->assertTrue(isset($result[1][$userEntityKey]->phonenumbers['43'])); - $this->assertTrue(isset($result[2][$userEntityKey]->phonenumbers['91'])); + self::assertTrue(isset($result[1][$userEntityKey]->phonenumbers['42'])); + self::assertTrue(isset($result[1][$userEntityKey]->phonenumbers['43'])); + self::assertTrue(isset($result[2][$userEntityKey]->phonenumbers['91'])); } /** @@ -678,25 +678,25 @@ public function testMixedQueryMultipleFetchJoin($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); - - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); - - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles); - $this->assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[0]); - $this->assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[1]); - - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[1][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[0]); - $this->assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[1]); + self::assertEquals(2, count($result)); + + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); + + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles); + self::assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[0]); + self::assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[1]); + + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[1][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[0]); + self::assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[1]); } /** @@ -808,43 +808,43 @@ public function testMixedQueryMultipleDeepMixedFetchJoin($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(is_array($result)); - $this->assertTrue(is_array($result[0])); - $this->assertTrue(is_array($result[1])); + self::assertTrue(is_array($result)); + self::assertTrue(is_array($result[0])); + self::assertTrue(is_array($result[1])); - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); - $this->assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[1][$userEntityKey]); // phonenumbers - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); - $this->assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(CmsPhonenumber::class, $result[0][$userEntityKey]->phonenumbers[1]); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); - $this->assertInstanceOf(CmsPhonenumber::class, $result[1][$userEntityKey]->phonenumbers[0]); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->phonenumbers); + self::assertInstanceOf(CmsPhonenumber::class, $result[1][$userEntityKey]->phonenumbers[0]); // articles - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles); - $this->assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[0]); - $this->assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[1]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles); + self::assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[0]); + self::assertInstanceOf(CmsArticle::class, $result[0][$userEntityKey]->articles[1]); - $this->assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[0]); - $this->assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[1]); + self::assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[0]); + self::assertInstanceOf(CmsArticle::class, $result[1][$userEntityKey]->articles[1]); // article comments - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles[0]->comments); - $this->assertInstanceOf(CmsComment::class, $result[0][$userEntityKey]->articles[0]->comments[0]); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles[0]->comments); + self::assertInstanceOf(CmsComment::class, $result[0][$userEntityKey]->articles[0]->comments[0]); // empty comment collections - $this->assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles[1]->comments); - $this->assertEquals(0, count($result[0][$userEntityKey]->articles[1]->comments)); + self::assertInstanceOf(PersistentCollection::class, $result[0][$userEntityKey]->articles[1]->comments); + self::assertEquals(0, count($result[0][$userEntityKey]->articles[1]->comments)); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->articles[0]->comments); - $this->assertEquals(0, count($result[1][$userEntityKey]->articles[0]->comments)); - $this->assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->articles[1]->comments); - $this->assertEquals(0, count($result[1][$userEntityKey]->articles[1]->comments)); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->articles[0]->comments); + self::assertEquals(0, count($result[1][$userEntityKey]->articles[0]->comments)); + self::assertInstanceOf(PersistentCollection::class, $result[1][$userEntityKey]->articles[1]->comments); + self::assertEquals(0, count($result[1][$userEntityKey]->articles[1]->comments)); } /** @@ -921,21 +921,21 @@ public function testEntityQueryCustomResultSetOrder(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertInstanceOf(ForumCategory::class, $result[0]); - $this->assertInstanceOf(ForumCategory::class, $result[1]); + self::assertInstanceOf(ForumCategory::class, $result[0]); + self::assertInstanceOf(ForumCategory::class, $result[1]); - $this->assertTrue($result[0] !== $result[1]); + self::assertTrue($result[0] !== $result[1]); - $this->assertEquals(1, $result[0]->getId()); - $this->assertEquals(2, $result[1]->getId()); + self::assertEquals(1, $result[0]->getId()); + self::assertEquals(2, $result[1]->getId()); - $this->assertTrue(isset($result[0]->boards)); - $this->assertEquals(3, count($result[0]->boards)); + self::assertTrue(isset($result[0]->boards)); + self::assertEquals(3, count($result[0]->boards)); - $this->assertTrue(isset($result[1]->boards)); - $this->assertEquals(1, count($result[1]->boards)); + self::assertTrue(isset($result[1]->boards)); + self::assertEquals(1, count($result[1]->boards)); } /** @@ -964,8 +964,8 @@ public function testSkipUnknownColumns(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(1, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); + self::assertEquals(1, count($result)); + self::assertInstanceOf(CmsUser::class, $result[0]); } /** @@ -997,16 +997,16 @@ public function testScalarQueryWithoutResultVariables($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result[0]); - $this->assertIsArray($result[1]); + self::assertIsArray($result[0]); + self::assertIsArray($result[1]); - $this->assertEquals(1, $result[0]['id']); - $this->assertEquals('romanb', $result[0]['name']); + self::assertEquals(1, $result[0]['id']); + self::assertEquals('romanb', $result[0]['name']); - $this->assertEquals(2, $result[1]['id']); - $this->assertEquals('jwage', $result[1]['name']); + self::assertEquals(2, $result[1]['id']); + self::assertEquals('jwage', $result[1]['name']); } /** @@ -1038,10 +1038,10 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void ->disableOriginalConstructor() ->getMock(); - $proxyFactory->expects($this->once()) + $proxyFactory->expects(self::once()) ->method('getProxy') - ->with($this->equalTo(ECommerceShipping::class), ['id' => 42]) - ->will($this->returnValue($proxyInstance)); + ->with(self::equalTo(ECommerceShipping::class), ['id' => 42]) + ->will(self::returnValue($proxyInstance)); $this->entityManager->setProxyFactory($proxyFactory); @@ -1053,9 +1053,9 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); - $this->assertInstanceOf(ECommerceProduct::class, $result[0]); + self::assertInstanceOf(ECommerceProduct::class, $result[0]); } /** @@ -1087,10 +1087,10 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE ->disableOriginalConstructor() ->getMock(); - $proxyFactory->expects($this->once()) + $proxyFactory->expects(self::once()) ->method('getProxy') - ->with($this->equalTo(ECommerceShipping::class), ['id' => 42]) - ->will($this->returnValue($proxyInstance)); + ->with(self::equalTo(ECommerceShipping::class), ['id' => 42]) + ->will(self::returnValue($proxyInstance)); $this->entityManager->setProxyFactory($proxyFactory); @@ -1102,10 +1102,10 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, count($result)); + self::assertEquals(1, count($result)); - $this->assertIsArray($result[0]); - $this->assertInstanceOf(ECommerceProduct::class, $result[0]['product']); + self::assertIsArray($result[0]); + self::assertInstanceOf(ECommerceProduct::class, $result[0]['product']); } /** @@ -1162,13 +1162,13 @@ public function testChainedJoinWithEmptyCollections(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertInstanceOf(CmsUser::class, $result[0]); - $this->assertInstanceOf(CmsUser::class, $result[1]); + self::assertInstanceOf(CmsUser::class, $result[0]); + self::assertInstanceOf(CmsUser::class, $result[1]); - $this->assertEquals(0, $result[0]->articles->count()); - $this->assertEquals(0, $result[1]->articles->count()); + self::assertEquals(0, $result[0]->articles->count()); + self::assertEquals(0, $result[1]->articles->count()); } /** @@ -1225,16 +1225,16 @@ public function testChainedJoinWithEmptyCollectionsWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertIsArray($result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertIsArray($result[1]); - $this->assertInstanceOf(CmsUser::class, $result[1]['user']); + self::assertIsArray($result[1]); + self::assertInstanceOf(CmsUser::class, $result[1]['user']); - $this->assertEquals(0, $result[0]['user']->articles->count()); - $this->assertEquals(0, $result[1]['user']->articles->count()); + self::assertEquals(0, $result[0]['user']->articles->count()); + self::assertEquals(0, $result[1]['user']->articles->count()); } /** @@ -1270,15 +1270,15 @@ public function testResultIteration(): void $rowNum = 0; while (($row = $iterableResult->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertInstanceOf(CmsUser::class, $row[0]); + self::assertEquals(1, count($row)); + self::assertInstanceOf(CmsUser::class, $row[0]); if ($rowNum === 0) { - $this->assertEquals(1, $row[0]->id); - $this->assertEquals('romanb', $row[0]->name); + self::assertEquals(1, $row[0]->id); + self::assertEquals('romanb', $row[0]->name); } elseif ($rowNum === 1) { - $this->assertEquals(2, $row[0]->id); - $this->assertEquals('jwage', $row[0]->name); + self::assertEquals(2, $row[0]->id); + self::assertEquals('jwage', $row[0]->name); } ++$rowNum; @@ -1344,17 +1344,17 @@ public function testResultIterationWithAliasedUserEntity(): void ); while (($row = $iterableResult->next()) !== false) { - $this->assertEquals(1, count($row)); - $this->assertArrayHasKey(0, $row); - $this->assertArrayHasKey('user', $row[0]); - $this->assertInstanceOf(CmsUser::class, $row[0]['user']); + self::assertEquals(1, count($row)); + self::assertArrayHasKey(0, $row); + self::assertArrayHasKey('user', $row[0]); + self::assertInstanceOf(CmsUser::class, $row[0]['user']); if ($rowNum === 0) { - $this->assertEquals(1, $row[0]['user']->id); - $this->assertEquals('romanb', $row[0]['user']->name); + self::assertEquals(1, $row[0]['user']->id); + self::assertEquals('romanb', $row[0]['user']->name); } elseif ($rowNum === 1) { - $this->assertEquals(2, $row[0]['user']->id); - $this->assertEquals('jwage', $row[0]['user']->name); + self::assertEquals(2, $row[0]['user']->id); + self::assertEquals('jwage', $row[0]['user']->name); } ++$rowNum; @@ -1502,15 +1502,15 @@ public function testManyToManyHydration(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertContainsOnly(CmsUser::class, $result); + self::assertContainsOnly(CmsUser::class, $result); - $this->assertEquals(2, count($result[0]->groups)); - $this->assertEquals(2, count($result[0]->phonenumbers)); + self::assertEquals(2, count($result[0]->groups)); + self::assertEquals(2, count($result[0]->phonenumbers)); - $this->assertEquals(4, count($result[1]->groups)); - $this->assertEquals(2, count($result[1]->phonenumbers)); + self::assertEquals(4, count($result[1]->groups)); + self::assertEquals(2, count($result[1]->phonenumbers)); } /** @@ -1625,18 +1625,18 @@ public function testManyToManyHydrationWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertIsArray($result[0]); - $this->assertInstanceOf(CmsUser::class, $result[0]['user']); - $this->assertIsArray($result[1]); - $this->assertInstanceOf(CmsUser::class, $result[1]['user']); + self::assertIsArray($result[0]); + self::assertInstanceOf(CmsUser::class, $result[0]['user']); + self::assertIsArray($result[1]); + self::assertInstanceOf(CmsUser::class, $result[1]['user']); - $this->assertEquals(2, count($result[0]['user']->groups)); - $this->assertEquals(2, count($result[0]['user']->phonenumbers)); + self::assertEquals(2, count($result[0]['user']->groups)); + self::assertEquals(2, count($result[0]['user']->phonenumbers)); - $this->assertEquals(4, count($result[1]['user']->groups)); - $this->assertEquals(2, count($result[1]['user']->phonenumbers)); + self::assertEquals(4, count($result[1]['user']->groups)); + self::assertEquals(2, count($result[1]['user']->phonenumbers)); } /** @@ -1683,18 +1683,18 @@ public function testMissingIdForRootEntity($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(4, count($result), 'Should hydrate four results.'); + self::assertEquals(4, count($result), 'Should hydrate four results.'); - $this->assertEquals('ROMANB', $result[0]['nameUpper']); - $this->assertEquals('ROMANB', $result[1]['nameUpper']); - $this->assertEquals('JWAGE', $result[2]['nameUpper']); - $this->assertEquals('JWAGE', $result[3]['nameUpper']); + self::assertEquals('ROMANB', $result[0]['nameUpper']); + self::assertEquals('ROMANB', $result[1]['nameUpper']); + self::assertEquals('JWAGE', $result[2]['nameUpper']); + self::assertEquals('JWAGE', $result[3]['nameUpper']); - $this->assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); - $this->assertNull($result[1][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[0][$userEntityKey]); + self::assertNull($result[1][$userEntityKey]); - $this->assertInstanceOf(CmsUser::class, $result[2][$userEntityKey]); - $this->assertNull($result[3][$userEntityKey]); + self::assertInstanceOf(CmsUser::class, $result[2][$userEntityKey]); + self::assertNull($result[3][$userEntityKey]); } /** @@ -1753,10 +1753,10 @@ public function testMissingIdForCollectionValuedChildEntity($userEntityKey): voi $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertEquals(1, $result[0][$userEntityKey]->phonenumbers->count()); - $this->assertEquals(1, $result[1][$userEntityKey]->phonenumbers->count()); + self::assertEquals(1, $result[0][$userEntityKey]->phonenumbers->count()); + self::assertEquals(1, $result[1][$userEntityKey]->phonenumbers->count()); } /** @@ -1807,10 +1807,10 @@ public function testMissingIdForSingleValuedChildEntity($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertInstanceOf(CmsAddress::class, $result[0][$userEntityKey]->address); - $this->assertNull($result[1][$userEntityKey]->address); + self::assertInstanceOf(CmsAddress::class, $result[0][$userEntityKey]->address); + self::assertNull($result[1][$userEntityKey]->address); } /** @@ -1849,13 +1849,13 @@ public function testIndexByAndMixedResult($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals(2, count($result)); + self::assertEquals(2, count($result)); - $this->assertTrue(isset($result[1])); - $this->assertEquals(1, $result[1][$userEntityKey]->id); + self::assertTrue(isset($result[1])); + self::assertEquals(1, $result[1][$userEntityKey]->id); - $this->assertTrue(isset($result[2])); - $this->assertEquals(2, $result[2][$userEntityKey]->id); + self::assertTrue(isset($result[2])); + self::assertEquals(2, $result[2][$userEntityKey]->id); } /** @@ -1883,7 +1883,7 @@ public function testIndexByScalarsOnly($userEntityKey): void $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - $this->assertEquals( + self::assertEquals( [ 'ROMANB' => ['nameUpper' => 'ROMANB'], 'JWAGE' => ['nameUpper' => 'JWAGE'], @@ -1999,10 +1999,10 @@ public function testFetchJoinCollectionValuedAssociationWithDefaultArrayValue(): $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertCount(1, $result); - $this->assertInstanceOf(EntityWithArrayDefaultArrayValueM2M::class, $result[0]); - $this->assertInstanceOf(PersistentCollection::class, $result[0]->collection); - $this->assertCount(1, $result[0]->collection); - $this->assertInstanceOf(SimpleEntity::class, $result[0]->collection[0]); + self::assertCount(1, $result); + self::assertInstanceOf(EntityWithArrayDefaultArrayValueM2M::class, $result[0]); + self::assertInstanceOf(PersistentCollection::class, $result[0]->collection); + self::assertCount(1, $result[0]->collection); + self::assertInstanceOf(SimpleEntity::class, $result[0]->collection[0]); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php index a33375fff89..27e240f2336 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -48,24 +48,24 @@ public function testBasicResultSetMapping(): void $this->_rsm->addFieldResult('u', 'username', 'username'); $this->_rsm->addFieldResult('u', 'name', 'name'); - $this->assertFalse($this->_rsm->isScalarResult('id')); - $this->assertFalse($this->_rsm->isScalarResult('status')); - $this->assertFalse($this->_rsm->isScalarResult('username')); - $this->assertFalse($this->_rsm->isScalarResult('name')); + self::assertFalse($this->_rsm->isScalarResult('id')); + self::assertFalse($this->_rsm->isScalarResult('status')); + self::assertFalse($this->_rsm->isScalarResult('username')); + self::assertFalse($this->_rsm->isScalarResult('name')); - $this->assertTrue($this->_rsm->getClassName('u') === CmsUser::class); + self::assertTrue($this->_rsm->getClassName('u') === CmsUser::class); $class = $this->_rsm->getDeclaringClass('id'); - $this->assertTrue($class === CmsUser::class); + self::assertTrue($class === CmsUser::class); - $this->assertEquals('u', $this->_rsm->getEntityAlias('id')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('status')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('username')); - $this->assertEquals('u', $this->_rsm->getEntityAlias('name')); + self::assertEquals('u', $this->_rsm->getEntityAlias('id')); + self::assertEquals('u', $this->_rsm->getEntityAlias('status')); + self::assertEquals('u', $this->_rsm->getEntityAlias('username')); + self::assertEquals('u', $this->_rsm->getEntityAlias('name')); - $this->assertEquals('id', $this->_rsm->getFieldName('id')); - $this->assertEquals('status', $this->_rsm->getFieldName('status')); - $this->assertEquals('username', $this->_rsm->getFieldName('username')); - $this->assertEquals('name', $this->_rsm->getFieldName('name')); + self::assertEquals('id', $this->_rsm->getFieldName('id')); + self::assertEquals('status', $this->_rsm->getFieldName('status')); + self::assertEquals('username', $this->_rsm->getFieldName('username')); + self::assertEquals('name', $this->_rsm->getFieldName('name')); } /** @@ -88,13 +88,13 @@ public function testFluentInterface(): void $this->_rsm->addScalarResult('sclr0', 'numPhones'); $this->_rsm->addMetaResult('a', 'user_id', 'user_id'); - $this->assertTrue($rms->hasIndexBy('id')); - $this->assertTrue($rms->isFieldResult('id')); - $this->assertTrue($rms->isFieldResult('name')); - $this->assertTrue($rms->isScalarResult('sclr0')); - $this->assertTrue($rms->isRelation('p')); - $this->assertTrue($rms->hasParentAlias('p')); - $this->assertTrue($rms->isMixedResult()); + self::assertTrue($rms->hasIndexBy('id')); + self::assertTrue($rms->isFieldResult('id')); + self::assertTrue($rms->isFieldResult('name')); + self::assertTrue($rms->isScalarResult('sclr0')); + self::assertTrue($rms->isRelation('p')); + self::assertTrue($rms->hasParentAlias('p')); + self::assertTrue($rms->isMixedResult()); } /** @@ -171,19 +171,19 @@ public function testAddNamedNativeQueryResultSetMapping(): void $rsm = new ResultSetMappingBuilder($this->entityManager); $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - $this->assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); + self::assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); - $this->assertEquals('c0', $rsm->getEntityAlias('user_id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals(CmsUser::class, $rsm->getClassName('c0')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('user_id')); + self::assertEquals('c0', $rsm->getEntityAlias('user_id')); + self::assertEquals('c0', $rsm->getEntityAlias('name')); + self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('user_id')); - $this->assertEquals('c1', $rsm->getEntityAlias('email_id')); - $this->assertEquals('c1', $rsm->getEntityAlias('email')); - $this->assertEquals(CmsEmail::class, $rsm->getClassName('c1')); - $this->assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email')); - $this->assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email_id')); + self::assertEquals('c1', $rsm->getEntityAlias('email_id')); + self::assertEquals('c1', $rsm->getEntityAlias('email')); + self::assertEquals(CmsEmail::class, $rsm->getClassName('c1')); + self::assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email')); + self::assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email_id')); } /** @@ -219,16 +219,16 @@ public function testAddNamedNativeQueryResultSetMappingWithoutFields(): void $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - $this->assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); - $this->assertEquals('c0', $rsm->getEntityAlias('id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals('c0', $rsm->getEntityAlias('status')); - $this->assertEquals('c0', $rsm->getEntityAlias('username')); - $this->assertEquals(CmsUser::class, $rsm->getClassName('c0')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); + self::assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); + self::assertEquals('c0', $rsm->getEntityAlias('id')); + self::assertEquals('c0', $rsm->getEntityAlias('name')); + self::assertEquals('c0', $rsm->getEntityAlias('status')); + self::assertEquals('c0', $rsm->getEntityAlias('username')); + self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); } /** @@ -253,15 +253,15 @@ public function testAddNamedNativeQueryResultClass(): void $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - $this->assertEquals('c0', $rsm->getEntityAlias('id')); - $this->assertEquals('c0', $rsm->getEntityAlias('name')); - $this->assertEquals('c0', $rsm->getEntityAlias('status')); - $this->assertEquals('c0', $rsm->getEntityAlias('username')); - $this->assertEquals(CmsUser::class, $rsm->getClassName('c0')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); - $this->assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); + self::assertEquals('c0', $rsm->getEntityAlias('id')); + self::assertEquals('c0', $rsm->getEntityAlias('name')); + self::assertEquals('c0', $rsm->getEntityAlias('status')); + self::assertEquals('c0', $rsm->getEntityAlias('username')); + self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); + self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); } /** @@ -275,6 +275,6 @@ public function testIndexByMetadataColumn(): void $this->_rsm->addMetaResult('lu', '_target', '_target', true, 'integer'); $this->_rsm->addIndexBy('lu', '_source'); - $this->assertTrue($this->_rsm->hasIndexBy('lu')); + self::assertTrue($this->_rsm->hasIndexBy('lu')); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php index 6f1404d5acc..3c8bf4f6178 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php @@ -38,12 +38,12 @@ public function testNewHydrationSimpleEntityQuery(): void $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertIsArray($result); - $this->assertCount(2, $result); - $this->assertEquals('romanb', $result[0]['u_name']); - $this->assertEquals(1, $result[0]['u_id']); - $this->assertEquals('jwage', $result[1]['u_name']); - $this->assertEquals(2, $result[1]['u_id']); + self::assertIsArray($result); + self::assertCount(2, $result); + self::assertEquals('romanb', $result[0]['u_name']); + self::assertEquals(1, $result[0]['u_id']); + self::assertEquals('jwage', $result[1]['u_name']); + self::assertEquals(2, $result[1]['u_id']); } /** diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php index de78568314a..ebed56e15bc 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php @@ -67,7 +67,7 @@ public function testExtraFieldInResultSetShouldBeIgnore(): void $stmt = new HydratorMockResult($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals($result[0], $expectedEntity); + self::assertEquals($result[0], $expectedEntity); } /** @@ -126,7 +126,7 @@ public function testNullValueShouldNotOverwriteFieldWithSameNameInJoinedInherita $stmt = new HydratorMockResult($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals($result[0], $expectedEntity); + self::assertEquals($result[0], $expectedEntity); } public function testWrongValuesShouldNotBeConvertedToPhpValue(): void @@ -158,6 +158,6 @@ public function testWrongValuesShouldNotBeConvertedToPhpValue(): void $stmt = new HydratorMockResult($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals($result[0], $expectedEntity); + self::assertEquals($result[0], $expectedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php index 9117289f61f..6d7d40d687b 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php @@ -70,14 +70,14 @@ public function testHydrateSingleScalar($name, $resultSet): void if ($name === 'result1') { $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals('romanb', $result); + self::assertEquals('romanb', $result); return; } if ($name === 'result2') { $result = $hydrator->hydrateAll($stmt, $rsm); - $this->assertEquals(1, $result); + self::assertEquals(1, $result); return; } diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php index 7ad28541565..54ec5668116 100644 --- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -51,13 +51,13 @@ public function testCorrectIdGeneration(): void $entity = new AssignedSingleIdEntity(); $entity->myId = 1; $id = $this->assignedGen->generate($this->entityManager, $entity); - $this->assertEquals(['myId' => 1], $id); + self::assertEquals(['myId' => 1], $id); $entity = new AssignedCompositeIdEntity(); $entity->myId2 = 2; $entity->myId1 = 4; $id = $this->assignedGen->generate($this->entityManager, $entity); - $this->assertEquals(['myId1' => 4, 'myId2' => 2], $id); + self::assertEquals(['myId1' => 4, 'myId2' => 2], $id); } } diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index 9b48d8888fb..e59122e422e 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -52,22 +52,22 @@ public function testDefersPostLoadOfEntity(int $listenersFlag): void $this ->listenersInvoker - ->expects($this->any()) + ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will($this->returnValue($listenersFlag)); + ->will(self::returnValue($listenersFlag)); $this->handler->deferPostLoadInvoking($metadata, $entity); $this ->listenersInvoker - ->expects($this->once()) + ->expects(self::once()) ->method('invoke') ->with( $metadata, Events::postLoad, $entity, - $this->callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity) { + self::callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity) { return $entity === $args->getEntity() && $entityManager === $args->getObjectManager(); }), $listenersFlag @@ -87,14 +87,14 @@ public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void $this ->listenersInvoker - ->expects($this->any()) + ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will($this->returnValue($listenersFlag)); + ->will(self::returnValue($listenersFlag)); $this->handler->deferPostLoadInvoking($metadata, $entity); - $this->listenersInvoker->expects($this->once())->method('invoke'); + $this->listenersInvoker->expects(self::once())->method('invoke'); $this->handler->hydrationComplete(); $this->handler->hydrationComplete(); @@ -113,23 +113,23 @@ public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void $this ->listenersInvoker - ->expects($this->any()) + ->expects(self::any()) ->method('getSubscribedSystems') - ->with($this->logicalOr($metadata1, $metadata2)) - ->will($this->returnValue($listenersFlag)); + ->with(self::logicalOr($metadata1, $metadata2)) + ->will(self::returnValue($listenersFlag)); $this->handler->deferPostLoadInvoking($metadata1, $entity1); $this->handler->deferPostLoadInvoking($metadata2, $entity2); $this ->listenersInvoker - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('invoke') ->with( - $this->logicalOr($metadata1, $metadata2), + self::logicalOr($metadata1, $metadata2), Events::postLoad, - $this->logicalOr($entity1, $entity2), - $this->callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity1, $entity2) { + self::logicalOr($entity1, $entity2), + self::callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity1, $entity2) { return in_array($args->getEntity(), [$entity1, $entity2], true) && $entityManager === $args->getObjectManager(); }), @@ -147,14 +147,14 @@ public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners(): voi $this ->listenersInvoker - ->expects($this->any()) + ->expects(self::any()) ->method('getSubscribedSystems') ->with($metadata) - ->will($this->returnValue(ListenersInvoker::INVOKE_NONE)); + ->will(self::returnValue(ListenersInvoker::INVOKE_NONE)); $this->handler->deferPostLoadInvoking($metadata, $entity); - $this->listenersInvoker->expects($this->never())->method('invoke'); + $this->listenersInvoker->expects(self::never())->method('invoke'); $this->handler->hydrationComplete(); } diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 412c4998d4a..7369b5165c8 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -35,37 +35,37 @@ protected function setUp(): void public function testCountIsCached(): void { - $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(10)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(10)); - $this->assertSame(10, $this->lazyCriteriaCollection->count()); - $this->assertSame(10, $this->lazyCriteriaCollection->count()); - $this->assertSame(10, $this->lazyCriteriaCollection->count()); + self::assertSame(10, $this->lazyCriteriaCollection->count()); + self::assertSame(10, $this->lazyCriteriaCollection->count()); + self::assertSame(10, $this->lazyCriteriaCollection->count()); } public function testCountIsCachedEvenWithZeroResult(): void { - $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(0)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(0)); - $this->assertSame(0, $this->lazyCriteriaCollection->count()); - $this->assertSame(0, $this->lazyCriteriaCollection->count()); - $this->assertSame(0, $this->lazyCriteriaCollection->count()); + self::assertSame(0, $this->lazyCriteriaCollection->count()); + self::assertSame(0, $this->lazyCriteriaCollection->count()); + self::assertSame(0, $this->lazyCriteriaCollection->count()); } public function testCountUsesWrappedCollectionWhenInitialized(): void { $this ->persister - ->expects($this->once()) + ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will($this->returnValue(['foo', 'bar', 'baz'])); + ->will(self::returnValue(['foo', 'bar', 'baz'])); // should never call the persister's count - $this->persister->expects($this->never())->method('count'); + $this->persister->expects(self::never())->method('count'); - $this->assertSame(['foo', 'bar', 'baz'], $this->lazyCriteriaCollection->toArray()); + self::assertSame(['foo', 'bar', 'baz'], $this->lazyCriteriaCollection->toArray()); - $this->assertSame(3, $this->lazyCriteriaCollection->count()); + self::assertSame(3, $this->lazyCriteriaCollection->count()); } public function testMatchingUsesThePersisterOnlyOnce(): void @@ -80,10 +80,10 @@ public function testMatchingUsesThePersisterOnlyOnce(): void $this ->persister - ->expects($this->once()) + ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will($this->returnValue([$foo, $bar, $baz])); + ->will(self::returnValue([$foo, $bar, $baz])); $criteria = new Criteria(); @@ -91,40 +91,40 @@ public function testMatchingUsesThePersisterOnlyOnce(): void $filtered = $this->lazyCriteriaCollection->matching($criteria); - $this->assertInstanceOf(Collection::class, $filtered); - $this->assertEquals([$foo], $filtered->toArray()); + self::assertInstanceOf(Collection::class, $filtered); + self::assertEquals([$foo], $filtered->toArray()); - $this->assertEquals([$foo], $this->lazyCriteriaCollection->matching($criteria)->toArray()); + self::assertEquals([$foo], $this->lazyCriteriaCollection->matching($criteria)->toArray()); } public function testIsEmptyUsesCountWhenNotInitialized(): void { - $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(0)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(0)); - $this->assertTrue($this->lazyCriteriaCollection->isEmpty()); + self::assertTrue($this->lazyCriteriaCollection->isEmpty()); } public function testIsEmptyIsFalseIfCountIsNotZero(): void { - $this->persister->expects($this->once())->method('count')->with($this->criteria)->will($this->returnValue(1)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(1)); - $this->assertFalse($this->lazyCriteriaCollection->isEmpty()); + self::assertFalse($this->lazyCriteriaCollection->isEmpty()); } public function testIsEmptyUsesWrappedCollectionWhenInitialized(): void { $this ->persister - ->expects($this->once()) + ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will($this->returnValue(['foo', 'bar', 'baz'])); + ->will(self::returnValue(['foo', 'bar', 'baz'])); // should never call the persister's count - $this->persister->expects($this->never())->method('count'); + $this->persister->expects(self::never())->method('count'); - $this->assertSame(['foo', 'bar', 'baz'], $this->lazyCriteriaCollection->toArray()); + self::assertSame(['foo', 'bar', 'baz'], $this->lazyCriteriaCollection->toArray()); - $this->assertFalse($this->lazyCriteriaCollection->isEmpty()); + self::assertFalse($this->lazyCriteriaCollection->isEmpty()); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 0d9038ae836..0031153d39f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -111,8 +111,8 @@ public function testEntityTableNameAndInheritance(): ClassMetadata { $class = $this->createClassMetadata(User::class); - $this->assertEquals('cms_users', $class->getTableName()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType); + self::assertEquals('cms_users', $class->getTableName()); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType); return $class; } @@ -122,8 +122,8 @@ public function testEntityTableNameAndInheritance(): ClassMetadata */ public function testEntityIndexes(ClassMetadata $class): ClassMetadata { - $this->assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.'); - $this->assertEquals( + self::assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.'); + self::assertEquals( [ 'name_idx' => ['columns' => ['name']], 0 => ['columns' => ['user_email']], @@ -145,7 +145,7 @@ public function testEntityIndexFlagsAndPartialIndexes(): void { $class = $this->createClassMetadata(Comment::class); - $this->assertEquals( + self::assertEquals( [ 0 => [ 'columns' => ['content'], @@ -162,13 +162,13 @@ public function testEntityIndexFlagsAndPartialIndexes(): void */ public function testEntityUniqueConstraints(ClassMetadata $class): ClassMetadata { - $this->assertArrayHasKey( + self::assertArrayHasKey( 'uniqueConstraints', $class->table, 'ClassMetadata should have uniqueConstraints key in table property when Unique Constraints are set.' ); - $this->assertEquals( + self::assertEquals( [ 'search_idx' => ['columns' => ['name', 'user_email'], 'options' => ['where' => 'name IS NOT NULL']], 'phone_idx' => ['fields' => ['name', 'phone']], @@ -190,9 +190,9 @@ public function testEntityIncorrectUniqueContraint(): void */ public function testEntityOptions(ClassMetadata $class): ClassMetadata { - $this->assertArrayHasKey('options', $class->table, 'ClassMetadata should have options key in table property.'); + self::assertArrayHasKey('options', $class->table, 'ClassMetadata should have options key in table property.'); - $this->assertEquals( + self::assertEquals( [ 'foo' => 'bar', 'baz' => ['key' => 'val'], @@ -208,8 +208,8 @@ public function testEntityOptions(ClassMetadata $class): ClassMetadata */ public function testEntitySequence(ClassMetadata $class): void { - $this->assertIsArray($class->sequenceGeneratorDefinition, 'No Sequence Definition set on this driver.'); - $this->assertEquals( + self::assertIsArray($class->sequenceGeneratorDefinition, 'No Sequence Definition set on this driver.'); + self::assertEquals( [ 'sequenceName' => 'tablename_seq', 'allocationSize' => 100, @@ -223,12 +223,12 @@ public function testEntityCustomGenerator(): void { $class = $this->createClassMetadata(Animal::class); - $this->assertEquals( + self::assertEquals( ClassMetadata::GENERATOR_TYPE_CUSTOM, $class->generatorType, 'Generator Type' ); - $this->assertEquals( + self::assertEquals( ['class' => 'stdClass'], $class->customGeneratorDefinition, 'Custom Generator Definition' @@ -240,11 +240,11 @@ public function testEntityCustomGenerator(): void */ public function testFieldMappings(ClassMetadata $class): ClassMetadata { - $this->assertEquals(4, count($class->fieldMappings)); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['name'])); - $this->assertTrue(isset($class->fieldMappings['email'])); - $this->assertTrue(isset($class->fieldMappings['version'])); + self::assertEquals(4, count($class->fieldMappings)); + self::assertTrue(isset($class->fieldMappings['id'])); + self::assertTrue(isset($class->fieldMappings['name'])); + self::assertTrue(isset($class->fieldMappings['email'])); + self::assertTrue(isset($class->fieldMappings['version'])); return $class; } @@ -254,10 +254,10 @@ public function testFieldMappings(ClassMetadata $class): ClassMetadata */ public function testVersionedField(ClassMetadata $class): void { - $this->assertTrue($class->isVersioned); - $this->assertEquals('version', $class->versionField); + self::assertTrue($class->isVersioned); + self::assertEquals('version', $class->versionField); - $this->assertFalse(isset($class->fieldMappings['version']['version'])); + self::assertFalse(isset($class->fieldMappings['version']['version'])); } /** @@ -265,9 +265,9 @@ public function testVersionedField(ClassMetadata $class): void */ public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadata { - $this->assertEquals('id', $class->fieldMappings['id']['columnName']); - $this->assertEquals('name', $class->fieldMappings['name']['columnName']); - $this->assertEquals('user_email', $class->fieldMappings['email']['columnName']); + self::assertEquals('id', $class->fieldMappings['id']['columnName']); + self::assertEquals('name', $class->fieldMappings['name']['columnName']); + self::assertEquals('user_email', $class->fieldMappings['email']['columnName']); return $class; } @@ -277,10 +277,10 @@ public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadat */ public function testStringFieldMappings(ClassMetadata $class): ClassMetadata { - $this->assertEquals('string', $class->fieldMappings['name']['type']); - $this->assertEquals(50, $class->fieldMappings['name']['length']); - $this->assertTrue($class->fieldMappings['name']['nullable']); - $this->assertTrue($class->fieldMappings['name']['unique']); + self::assertEquals('string', $class->fieldMappings['name']['type']); + self::assertEquals(50, $class->fieldMappings['name']['length']); + self::assertTrue($class->fieldMappings['name']['nullable']); + self::assertTrue($class->fieldMappings['name']['unique']); return $class; } @@ -288,23 +288,23 @@ public function testStringFieldMappings(ClassMetadata $class): ClassMetadata public function testFieldTypeFromReflection(): void { if (PHP_VERSION_ID < 70400) { - $this->markTestSkipped('requies PHP 7.4'); + self::markTestSkipped('requies PHP 7.4'); } $class = $this->createClassMetadata(UserTyped::class); - $this->assertEquals('integer', $class->getTypeOfField('id')); - $this->assertEquals('string', $class->getTypeOfField('username')); - $this->assertEquals('dateinterval', $class->getTypeOfField('dateInterval')); - $this->assertEquals('datetime', $class->getTypeOfField('dateTime')); - $this->assertEquals('datetime_immutable', $class->getTypeOfField('dateTimeImmutable')); - $this->assertEquals('json', $class->getTypeOfField('array')); - $this->assertEquals('boolean', $class->getTypeOfField('boolean')); - $this->assertEquals('float', $class->getTypeOfField('float')); + self::assertEquals('integer', $class->getTypeOfField('id')); + self::assertEquals('string', $class->getTypeOfField('username')); + self::assertEquals('dateinterval', $class->getTypeOfField('dateInterval')); + self::assertEquals('datetime', $class->getTypeOfField('dateTime')); + self::assertEquals('datetime_immutable', $class->getTypeOfField('dateTimeImmutable')); + self::assertEquals('json', $class->getTypeOfField('array')); + self::assertEquals('boolean', $class->getTypeOfField('boolean')); + self::assertEquals('float', $class->getTypeOfField('float')); - $this->assertEquals(CmsEmail::class, $class->getAssociationMapping('email')['targetEntity']); - $this->assertEquals(CmsEmail::class, $class->getAssociationMapping('mainEmail')['targetEntity']); - $this->assertEquals(Contact::class, $class->embeddedClasses['contact']['class']); + self::assertEquals(CmsEmail::class, $class->getAssociationMapping('email')['targetEntity']); + self::assertEquals(CmsEmail::class, $class->getAssociationMapping('mainEmail')['targetEntity']); + self::assertEquals(Contact::class, $class->embeddedClasses['contact']['class']); } /** @@ -313,7 +313,7 @@ public function testFieldTypeFromReflection(): void public function testFieldOptions(ClassMetadata $class): ClassMetadata { $expected = ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false]; - $this->assertEquals($expected, $class->fieldMappings['name']['options']); + self::assertEquals($expected, $class->fieldMappings['name']['options']); return $class; } @@ -323,7 +323,7 @@ public function testFieldOptions(ClassMetadata $class): ClassMetadata */ public function testIdFieldOptions(ClassMetadata $class): ClassMetadata { - $this->assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']['options']); + self::assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']['options']); return $class; } @@ -333,9 +333,9 @@ public function testIdFieldOptions(ClassMetadata $class): ClassMetadata */ public function testIdentifier(ClassMetadata $class): ClassMetadata { - $this->assertEquals(['id'], $class->identifier); - $this->assertEquals('integer', $class->fieldMappings['id']['type']); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, 'ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO'); + self::assertEquals(['id'], $class->identifier); + self::assertEquals('integer', $class->fieldMappings['id']['type']); + self::assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, 'ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO'); return $class; } @@ -347,11 +347,11 @@ public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata { $class = $this->createClassMetadata(User::class); - $this->assertIsBool($class->fieldMappings['id']['options']['unsigned']); - $this->assertFalse($class->fieldMappings['id']['options']['unsigned']); + self::assertIsBool($class->fieldMappings['id']['options']['unsigned']); + self::assertFalse($class->fieldMappings['id']['options']['unsigned']); - $this->assertIsBool($class->fieldMappings['name']['options']['fixed']); - $this->assertFalse($class->fieldMappings['name']['options']['fixed']); + self::assertIsBool($class->fieldMappings['name']['options']['fixed']); + self::assertFalse($class->fieldMappings['name']['options']['fixed']); return $class; } @@ -361,7 +361,7 @@ public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata */ public function testAssociations(ClassMetadata $class): ClassMetadata { - $this->assertEquals(3, count($class->associationMappings)); + self::assertEquals(3, count($class->associationMappings)); return $class; } @@ -371,15 +371,15 @@ public function testAssociations(ClassMetadata $class): ClassMetadata */ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetadata { - $this->assertTrue(isset($class->associationMappings['address'])); - $this->assertTrue($class->associationMappings['address']['isOwningSide']); - $this->assertEquals('user', $class->associationMappings['address']['inversedBy']); + self::assertTrue(isset($class->associationMappings['address'])); + self::assertTrue($class->associationMappings['address']['isOwningSide']); + self::assertEquals('user', $class->associationMappings['address']['inversedBy']); // Check cascading - $this->assertTrue($class->associationMappings['address']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['address']['isCascadePersist']); - $this->assertFalse($class->associationMappings['address']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['address']['isCascadeDetach']); - $this->assertFalse($class->associationMappings['address']['isCascadeMerge']); + self::assertTrue($class->associationMappings['address']['isCascadeRemove']); + self::assertFalse($class->associationMappings['address']['isCascadePersist']); + self::assertFalse($class->associationMappings['address']['isCascadeRefresh']); + self::assertFalse($class->associationMappings['address']['isCascadeDetach']); + self::assertFalse($class->associationMappings['address']['isCascadeMerge']); return $class; } @@ -389,17 +389,17 @@ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetada */ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMetadata { - $this->assertTrue(isset($class->associationMappings['phonenumbers'])); - $this->assertFalse($class->associationMappings['phonenumbers']['isOwningSide']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + self::assertTrue(isset($class->associationMappings['phonenumbers'])); + self::assertFalse($class->associationMappings['phonenumbers']['isOwningSide']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']); + self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); // Test Order By - $this->assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); + self::assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); return $class; } @@ -409,16 +409,16 @@ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMeta */ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): ClassMetadata { - $this->assertTrue(isset($class->associationMappings['groups'])); - $this->assertTrue($class->associationMappings['groups']['isOwningSide']); + self::assertTrue(isset($class->associationMappings['groups'])); + self::assertTrue($class->associationMappings['groups']['isOwningSide']); // Make sure that cascade-all works as expected - $this->assertTrue($class->associationMappings['groups']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['groups']['isCascadePersist']); - $this->assertTrue($class->associationMappings['groups']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['groups']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['groups']['isCascadeMerge']); + self::assertTrue($class->associationMappings['groups']['isCascadeRemove']); + self::assertTrue($class->associationMappings['groups']['isCascadePersist']); + self::assertTrue($class->associationMappings['groups']['isCascadeRefresh']); + self::assertTrue($class->associationMappings['groups']['isCascadeDetach']); + self::assertTrue($class->associationMappings['groups']['isCascadeMerge']); - $this->assertFalse(isset($class->associationMappings['groups']['orderBy'])); + self::assertFalse(isset($class->associationMappings['groups']['orderBy'])); return $class; } @@ -428,9 +428,9 @@ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): C */ public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata { - $this->assertEquals(count($class->lifecycleCallbacks), 2); - $this->assertEquals($class->lifecycleCallbacks['prePersist'][0], 'doStuffOnPrePersist'); - $this->assertEquals($class->lifecycleCallbacks['postPersist'][0], 'doStuffOnPostPersist'); + self::assertEquals(count($class->lifecycleCallbacks), 2); + self::assertEquals($class->lifecycleCallbacks['prePersist'][0], 'doStuffOnPrePersist'); + self::assertEquals($class->lifecycleCallbacks['postPersist'][0], 'doStuffOnPostPersist'); return $class; } @@ -440,8 +440,8 @@ public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata */ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $class): ClassMetadata { - $this->assertEquals(count($class->lifecycleCallbacks['prePersist']), 2); - $this->assertEquals($class->lifecycleCallbacks['prePersist'][1], 'doOtherStuffOnPrePersistToo'); + self::assertEquals(count($class->lifecycleCallbacks['prePersist']), 2); + self::assertEquals($class->lifecycleCallbacks['prePersist'][1], 'doOtherStuffOnPrePersistToo'); return $class; } @@ -452,8 +452,8 @@ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMetadata { // Non-Nullability of Join Column - $this->assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['nullable']); - $this->assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['unique']); + self::assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['nullable']); + self::assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['unique']); return $class; } @@ -463,8 +463,8 @@ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMeta */ public function testColumnDefinition(ClassMetadata $class): ClassMetadata { - $this->assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); - $this->assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); + self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); + self::assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); return $class; } @@ -474,7 +474,7 @@ public function testColumnDefinition(ClassMetadata $class): ClassMetadata */ public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata { - $this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); + self::assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); return $class; } @@ -485,12 +485,12 @@ public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata public function testDiscriminatorColumnDefaults(): void { if (strpos(static::class, 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + self::markTestSkipped('PHP Mapping Drivers have no defaults.'); } $class = $this->createClassMetadata(Animal::class); - $this->assertEquals( + self::assertEquals( ['name' => 'discr', 'type' => 'string', 'length' => '32', 'fieldName' => 'discr', 'columnDefinition' => null], $class->discriminatorColumn ); @@ -506,21 +506,21 @@ public function testMappedSuperclassWithRepository(): void $class = $factory->getMetadataFor(DDC869CreditCardPayment::class); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertTrue(isset($class->fieldMappings['creditCardNumber'])); - $this->assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); - $this->assertInstanceOf(DDC869PaymentRepository::class, $em->getRepository(DDC869CreditCardPayment::class)); - $this->assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); + self::assertTrue(isset($class->fieldMappings['id'])); + self::assertTrue(isset($class->fieldMappings['value'])); + self::assertTrue(isset($class->fieldMappings['creditCardNumber'])); + self::assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); + self::assertInstanceOf(DDC869PaymentRepository::class, $em->getRepository(DDC869CreditCardPayment::class)); + self::assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); $class = $factory->getMetadataFor(DDC869ChequePayment::class); - $this->assertTrue(isset($class->fieldMappings['id'])); - $this->assertTrue(isset($class->fieldMappings['value'])); - $this->assertTrue(isset($class->fieldMappings['serialNumber'])); - $this->assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); - $this->assertInstanceOf(DDC869PaymentRepository::class, $em->getRepository(DDC869ChequePayment::class)); - $this->assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); + self::assertTrue(isset($class->fieldMappings['id'])); + self::assertTrue(isset($class->fieldMappings['value'])); + self::assertTrue(isset($class->fieldMappings['serialNumber'])); + self::assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); + self::assertInstanceOf(DDC869PaymentRepository::class, $em->getRepository(DDC869ChequePayment::class)); + self::assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); } /** @@ -531,28 +531,28 @@ public function testDefaultFieldType(): void $factory = $this->createClassMetadataFactory(); $class = $factory->getMetadataFor(DDC1476EntityWithDefaultFieldType::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('name', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('name', $class->fieldMappings); - $this->assertArrayHasKey('type', $class->fieldMappings['id']); - $this->assertArrayHasKey('type', $class->fieldMappings['name']); + self::assertArrayHasKey('type', $class->fieldMappings['id']); + self::assertArrayHasKey('type', $class->fieldMappings['name']); - $this->assertEquals('string', $class->fieldMappings['id']['type']); - $this->assertEquals('string', $class->fieldMappings['name']['type']); + self::assertEquals('string', $class->fieldMappings['id']['type']); + self::assertEquals('string', $class->fieldMappings['name']['type']); - $this->assertArrayHasKey('fieldName', $class->fieldMappings['id']); - $this->assertArrayHasKey('fieldName', $class->fieldMappings['name']); + self::assertArrayHasKey('fieldName', $class->fieldMappings['id']); + self::assertArrayHasKey('fieldName', $class->fieldMappings['name']); - $this->assertEquals('id', $class->fieldMappings['id']['fieldName']); - $this->assertEquals('name', $class->fieldMappings['name']['fieldName']); + self::assertEquals('id', $class->fieldMappings['id']['fieldName']); + self::assertEquals('name', $class->fieldMappings['name']['fieldName']); - $this->assertArrayHasKey('columnName', $class->fieldMappings['id']); - $this->assertArrayHasKey('columnName', $class->fieldMappings['name']); + self::assertArrayHasKey('columnName', $class->fieldMappings['id']); + self::assertArrayHasKey('columnName', $class->fieldMappings['name']); - $this->assertEquals('id', $class->fieldMappings['id']['columnName']); - $this->assertEquals('name', $class->fieldMappings['name']['columnName']); + self::assertEquals('id', $class->fieldMappings['id']['columnName']); + self::assertEquals('name', $class->fieldMappings['name']['columnName']); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType); } /** @@ -562,14 +562,14 @@ public function testIdentifierColumnDefinition(): void { $class = $this->createClassMetadata(DDC1170Entity::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('value', $class->fieldMappings); - $this->assertArrayHasKey('columnDefinition', $class->fieldMappings['id']); - $this->assertArrayHasKey('columnDefinition', $class->fieldMappings['value']); + self::assertArrayHasKey('columnDefinition', $class->fieldMappings['id']); + self::assertArrayHasKey('columnDefinition', $class->fieldMappings['value']); - $this->assertEquals('int unsigned not null', strtolower($class->fieldMappings['id']['columnDefinition'])); - $this->assertEquals('varchar(255) not null', strtolower($class->fieldMappings['value']['columnDefinition'])); + self::assertEquals('int unsigned not null', strtolower($class->fieldMappings['id']['columnDefinition'])); + self::assertEquals('varchar(255) not null', strtolower($class->fieldMappings['value']['columnDefinition'])); } /** @@ -580,15 +580,15 @@ public function testNamingStrategy(): void $em = $this->getTestEntityManager(); $factory = $this->createClassMetadataFactory($em); - $this->assertInstanceOf(DefaultNamingStrategy::class, $em->getConfiguration()->getNamingStrategy()); + self::assertInstanceOf(DefaultNamingStrategy::class, $em->getConfiguration()->getNamingStrategy()); $em->getConfiguration()->setNamingStrategy(new UnderscoreNamingStrategy(CASE_UPPER)); - $this->assertInstanceOf(UnderscoreNamingStrategy::class, $em->getConfiguration()->getNamingStrategy()); + self::assertInstanceOf(UnderscoreNamingStrategy::class, $em->getConfiguration()->getNamingStrategy()); $class = $factory->getMetadataFor(DDC1476EntityWithDefaultFieldType::class); - $this->assertEquals('ID', $class->getColumnName('id')); - $this->assertEquals('NAME', $class->getColumnName('name')); - $this->assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); + self::assertEquals('ID', $class->getColumnName('id')); + self::assertEquals('NAME', $class->getColumnName('name')); + self::assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); } /** @@ -599,11 +599,11 @@ public function testDiscriminatorColumnDefinition(): void { $class = $this->createClassMetadata(DDC807Entity::class); - $this->assertArrayHasKey('columnDefinition', $class->discriminatorColumn); - $this->assertArrayHasKey('name', $class->discriminatorColumn); + self::assertArrayHasKey('columnDefinition', $class->discriminatorColumn); + self::assertArrayHasKey('name', $class->discriminatorColumn); - $this->assertEquals("ENUM('ONE','TWO')", $class->discriminatorColumn['columnDefinition']); - $this->assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals("ENUM('ONE','TWO')", $class->discriminatorColumn['columnDefinition']); + self::assertEquals('dtype', $class->discriminatorColumn['name']); } /** @@ -635,7 +635,7 @@ public function testNamedQuery(): void $driver = $this->loadDriver(); $class = $this->createClassMetadata(User::class); - $this->assertCount(1, $class->getNamedQueries(), sprintf('Named queries not processed correctly by driver %s', get_class($driver))); + self::assertCount(1, $class->getNamedQueries(), sprintf('Named queries not processed correctly by driver %s', get_class($driver))); } /** @@ -646,46 +646,46 @@ public function testNamedNativeQuery(): void $class = $this->createClassMetadata(CmsAddress::class); //named native query - $this->assertCount(3, $class->namedNativeQueries); - $this->assertArrayHasKey('find-all', $class->namedNativeQueries); - $this->assertArrayHasKey('find-by-id', $class->namedNativeQueries); + self::assertCount(3, $class->namedNativeQueries); + self::assertArrayHasKey('find-all', $class->namedNativeQueries); + self::assertArrayHasKey('find-by-id', $class->namedNativeQueries); $findAllQuery = $class->getNamedNativeQuery('find-all'); - $this->assertEquals('find-all', $findAllQuery['name']); - $this->assertEquals('mapping-find-all', $findAllQuery['resultSetMapping']); - $this->assertEquals('SELECT id, country, city FROM cms_addresses', $findAllQuery['query']); + self::assertEquals('find-all', $findAllQuery['name']); + self::assertEquals('mapping-find-all', $findAllQuery['resultSetMapping']); + self::assertEquals('SELECT id, country, city FROM cms_addresses', $findAllQuery['query']); $findByIdQuery = $class->getNamedNativeQuery('find-by-id'); - $this->assertEquals('find-by-id', $findByIdQuery['name']); - $this->assertEquals(CmsAddress::class, $findByIdQuery['resultClass']); - $this->assertEquals('SELECT * FROM cms_addresses WHERE id = ?', $findByIdQuery['query']); + self::assertEquals('find-by-id', $findByIdQuery['name']); + self::assertEquals(CmsAddress::class, $findByIdQuery['resultClass']); + self::assertEquals('SELECT * FROM cms_addresses WHERE id = ?', $findByIdQuery['query']); $countQuery = $class->getNamedNativeQuery('count'); - $this->assertEquals('count', $countQuery['name']); - $this->assertEquals('mapping-count', $countQuery['resultSetMapping']); - $this->assertEquals('SELECT COUNT(*) AS count FROM cms_addresses', $countQuery['query']); + self::assertEquals('count', $countQuery['name']); + self::assertEquals('mapping-count', $countQuery['resultSetMapping']); + self::assertEquals('SELECT COUNT(*) AS count FROM cms_addresses', $countQuery['query']); // result set mapping - $this->assertCount(3, $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-count', $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-find-all', $class->sqlResultSetMappings); - $this->assertArrayHasKey('mapping-without-fields', $class->sqlResultSetMappings); + self::assertCount(3, $class->sqlResultSetMappings); + self::assertArrayHasKey('mapping-count', $class->sqlResultSetMappings); + self::assertArrayHasKey('mapping-find-all', $class->sqlResultSetMappings); + self::assertArrayHasKey('mapping-without-fields', $class->sqlResultSetMappings); $findAllMapping = $class->getSqlResultSetMapping('mapping-find-all'); - $this->assertEquals('mapping-find-all', $findAllMapping['name']); - $this->assertEquals(CmsAddress::class, $findAllMapping['entities'][0]['entityClass']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $findAllMapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'city', 'column' => 'city'], $findAllMapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'country', 'column' => 'country'], $findAllMapping['entities'][0]['fields'][2]); + self::assertEquals('mapping-find-all', $findAllMapping['name']); + self::assertEquals(CmsAddress::class, $findAllMapping['entities'][0]['entityClass']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $findAllMapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'city', 'column' => 'city'], $findAllMapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'country', 'column' => 'country'], $findAllMapping['entities'][0]['fields'][2]); $withoutFieldsMapping = $class->getSqlResultSetMapping('mapping-without-fields'); - $this->assertEquals('mapping-without-fields', $withoutFieldsMapping['name']); - $this->assertEquals(CmsAddress::class, $withoutFieldsMapping['entities'][0]['entityClass']); - $this->assertEquals([], $withoutFieldsMapping['entities'][0]['fields']); + self::assertEquals('mapping-without-fields', $withoutFieldsMapping['name']); + self::assertEquals(CmsAddress::class, $withoutFieldsMapping['entities'][0]['entityClass']); + self::assertEquals([], $withoutFieldsMapping['entities'][0]['fields']); $countMapping = $class->getSqlResultSetMapping('mapping-count'); - $this->assertEquals('mapping-count', $countMapping['name']); - $this->assertEquals(['name' => 'count'], $countMapping['columns'][0]); + self::assertEquals('mapping-count', $countMapping['name']); + self::assertEquals(['name' => 'count'], $countMapping['columns'][0]); } /** @@ -697,64 +697,64 @@ public function testSqlResultSetMapping(): void $personMetadata = $this->createClassMetadata(CompanyPerson::class); // user asserts - $this->assertCount(4, $userMetadata->getSqlResultSetMappings()); + self::assertCount(4, $userMetadata->getSqlResultSetMappings()); $mapping = $userMetadata->getSqlResultSetMapping('mappingJoinedAddress'); - $this->assertEquals([], $mapping['columns']); - $this->assertEquals('mappingJoinedAddress', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - $this->assertEquals(['name' => 'address.zip', 'column' => 'zip'], $mapping['entities'][0]['fields'][3]); - $this->assertEquals(['name' => 'address.city', 'column' => 'city'], $mapping['entities'][0]['fields'][4]); - $this->assertEquals(['name' => 'address.country', 'column' => 'country'], $mapping['entities'][0]['fields'][5]); - $this->assertEquals(['name' => 'address.id', 'column' => 'a_id'], $mapping['entities'][0]['fields'][6]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertEquals([], $mapping['columns']); + self::assertEquals('mappingJoinedAddress', $mapping['name']); + self::assertNull($mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); + self::assertEquals(['name' => 'address.zip', 'column' => 'zip'], $mapping['entities'][0]['fields'][3]); + self::assertEquals(['name' => 'address.city', 'column' => 'city'], $mapping['entities'][0]['fields'][4]); + self::assertEquals(['name' => 'address.country', 'column' => 'country'], $mapping['entities'][0]['fields'][5]); + self::assertEquals(['name' => 'address.id', 'column' => 'a_id'], $mapping['entities'][0]['fields'][6]); + self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); $mapping = $userMetadata->getSqlResultSetMapping('mappingJoinedPhonenumber'); - $this->assertEquals([], $mapping['columns']); - $this->assertEquals('mappingJoinedPhonenumber', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - $this->assertEquals(['name' => 'phonenumbers.phonenumber', 'column' => 'number'], $mapping['entities'][0]['fields'][3]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertEquals([], $mapping['columns']); + self::assertEquals('mappingJoinedPhonenumber', $mapping['name']); + self::assertNull($mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); + self::assertEquals(['name' => 'phonenumbers.phonenumber', 'column' => 'number'], $mapping['entities'][0]['fields'][3]); + self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); $mapping = $userMetadata->getSqlResultSetMapping('mappingUserPhonenumberCount'); - $this->assertEquals(['name' => 'numphones'], $mapping['columns'][0]); - $this->assertEquals('mappingUserPhonenumberCount', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertEquals(['name' => 'numphones'], $mapping['columns'][0]); + self::assertEquals('mappingUserPhonenumberCount', $mapping['name']); + self::assertNull($mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); + self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); $mapping = $userMetadata->getSqlResultSetMapping('mappingMultipleJoinsEntityResults'); - $this->assertEquals(['name' => 'numphones'], $mapping['columns'][0]); - $this->assertEquals('mappingMultipleJoinsEntityResults', $mapping['name']); - $this->assertNull($mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'u_id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'u_name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(['name' => 'status', 'column' => 'u_status'], $mapping['entities'][0]['fields'][2]); - $this->assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - $this->assertNull($mapping['entities'][1]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'a_id'], $mapping['entities'][1]['fields'][0]); - $this->assertEquals(['name' => 'zip', 'column' => 'a_zip'], $mapping['entities'][1]['fields'][1]); - $this->assertEquals(['name' => 'country', 'column' => 'a_country'], $mapping['entities'][1]['fields'][2]); - $this->assertEquals(CmsAddress::class, $mapping['entities'][1]['entityClass']); + self::assertEquals(['name' => 'numphones'], $mapping['columns'][0]); + self::assertEquals('mappingMultipleJoinsEntityResults', $mapping['name']); + self::assertNull($mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'u_id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'u_name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(['name' => 'status', 'column' => 'u_status'], $mapping['entities'][0]['fields'][2]); + self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertNull($mapping['entities'][1]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'a_id'], $mapping['entities'][1]['fields'][0]); + self::assertEquals(['name' => 'zip', 'column' => 'a_zip'], $mapping['entities'][1]['fields'][1]); + self::assertEquals(['name' => 'country', 'column' => 'a_country'], $mapping['entities'][1]['fields'][2]); + self::assertEquals(CmsAddress::class, $mapping['entities'][1]['entityClass']); //person asserts - $this->assertCount(1, $personMetadata->getSqlResultSetMappings()); + self::assertCount(1, $personMetadata->getSqlResultSetMappings()); $mapping = $personMetadata->getSqlResultSetMapping('mappingFetchAll'); - $this->assertEquals([], $mapping['columns']); - $this->assertEquals('mappingFetchAll', $mapping['name']); - $this->assertEquals('discriminator', $mapping['entities'][0]['discriminatorColumn']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals($personMetadata->name, $mapping['entities'][0]['entityClass']); + self::assertEquals([], $mapping['columns']); + self::assertEquals('mappingFetchAll', $mapping['name']); + self::assertEquals('discriminator', $mapping['entities'][0]['discriminatorColumn']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals($personMetadata->name, $mapping['entities'][0]['entityClass']); } /** @@ -767,72 +767,72 @@ public function testAssociationOverridesMapping(): void $guestMetadata = $factory->getMetadataFor(DDC964Guest::class); // assert groups association mappings - $this->assertArrayHasKey('groups', $guestMetadata->associationMappings); - $this->assertArrayHasKey('groups', $adminMetadata->associationMappings); + self::assertArrayHasKey('groups', $guestMetadata->associationMappings); + self::assertArrayHasKey('groups', $adminMetadata->associationMappings); $guestGroups = $guestMetadata->associationMappings['groups']; $adminGroups = $adminMetadata->associationMappings['groups']; // assert not override attributes - $this->assertEquals($guestGroups['fieldName'], $adminGroups['fieldName']); - $this->assertEquals($guestGroups['type'], $adminGroups['type']); - $this->assertEquals($guestGroups['mappedBy'], $adminGroups['mappedBy']); - $this->assertEquals($guestGroups['inversedBy'], $adminGroups['inversedBy']); - $this->assertEquals($guestGroups['isOwningSide'], $adminGroups['isOwningSide']); - $this->assertEquals($guestGroups['fetch'], $adminGroups['fetch']); - $this->assertEquals($guestGroups['isCascadeRemove'], $adminGroups['isCascadeRemove']); - $this->assertEquals($guestGroups['isCascadePersist'], $adminGroups['isCascadePersist']); - $this->assertEquals($guestGroups['isCascadeRefresh'], $adminGroups['isCascadeRefresh']); - $this->assertEquals($guestGroups['isCascadeMerge'], $adminGroups['isCascadeMerge']); - $this->assertEquals($guestGroups['isCascadeDetach'], $adminGroups['isCascadeDetach']); + self::assertEquals($guestGroups['fieldName'], $adminGroups['fieldName']); + self::assertEquals($guestGroups['type'], $adminGroups['type']); + self::assertEquals($guestGroups['mappedBy'], $adminGroups['mappedBy']); + self::assertEquals($guestGroups['inversedBy'], $adminGroups['inversedBy']); + self::assertEquals($guestGroups['isOwningSide'], $adminGroups['isOwningSide']); + self::assertEquals($guestGroups['fetch'], $adminGroups['fetch']); + self::assertEquals($guestGroups['isCascadeRemove'], $adminGroups['isCascadeRemove']); + self::assertEquals($guestGroups['isCascadePersist'], $adminGroups['isCascadePersist']); + self::assertEquals($guestGroups['isCascadeRefresh'], $adminGroups['isCascadeRefresh']); + self::assertEquals($guestGroups['isCascadeMerge'], $adminGroups['isCascadeMerge']); + self::assertEquals($guestGroups['isCascadeDetach'], $adminGroups['isCascadeDetach']); // assert not override attributes - $this->assertEquals('ddc964_users_groups', $guestGroups['joinTable']['name']); - $this->assertEquals('user_id', $guestGroups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('group_id', $guestGroups['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('ddc964_users_groups', $guestGroups['joinTable']['name']); + self::assertEquals('user_id', $guestGroups['joinTable']['joinColumns'][0]['name']); + self::assertEquals('group_id', $guestGroups['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals(['user_id' => 'id'], $guestGroups['relationToSourceKeyColumns']); - $this->assertEquals(['group_id' => 'id'], $guestGroups['relationToTargetKeyColumns']); - $this->assertEquals(['user_id', 'group_id'], $guestGroups['joinTableColumns']); + self::assertEquals(['user_id' => 'id'], $guestGroups['relationToSourceKeyColumns']); + self::assertEquals(['group_id' => 'id'], $guestGroups['relationToTargetKeyColumns']); + self::assertEquals(['user_id', 'group_id'], $guestGroups['joinTableColumns']); - $this->assertEquals('ddc964_users_admingroups', $adminGroups['joinTable']['name']); - $this->assertEquals('adminuser_id', $adminGroups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('admingroup_id', $adminGroups['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('ddc964_users_admingroups', $adminGroups['joinTable']['name']); + self::assertEquals('adminuser_id', $adminGroups['joinTable']['joinColumns'][0]['name']); + self::assertEquals('admingroup_id', $adminGroups['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals(['adminuser_id' => 'id'], $adminGroups['relationToSourceKeyColumns']); - $this->assertEquals(['admingroup_id' => 'id'], $adminGroups['relationToTargetKeyColumns']); - $this->assertEquals(['adminuser_id', 'admingroup_id'], $adminGroups['joinTableColumns']); + self::assertEquals(['adminuser_id' => 'id'], $adminGroups['relationToSourceKeyColumns']); + self::assertEquals(['admingroup_id' => 'id'], $adminGroups['relationToTargetKeyColumns']); + self::assertEquals(['adminuser_id', 'admingroup_id'], $adminGroups['joinTableColumns']); // assert address association mappings - $this->assertArrayHasKey('address', $guestMetadata->associationMappings); - $this->assertArrayHasKey('address', $adminMetadata->associationMappings); + self::assertArrayHasKey('address', $guestMetadata->associationMappings); + self::assertArrayHasKey('address', $adminMetadata->associationMappings); $guestAddress = $guestMetadata->associationMappings['address']; $adminAddress = $adminMetadata->associationMappings['address']; // assert not override attributes - $this->assertEquals($guestAddress['fieldName'], $adminAddress['fieldName']); - $this->assertEquals($guestAddress['type'], $adminAddress['type']); - $this->assertEquals($guestAddress['mappedBy'], $adminAddress['mappedBy']); - $this->assertEquals($guestAddress['inversedBy'], $adminAddress['inversedBy']); - $this->assertEquals($guestAddress['isOwningSide'], $adminAddress['isOwningSide']); - $this->assertEquals($guestAddress['fetch'], $adminAddress['fetch']); - $this->assertEquals($guestAddress['isCascadeRemove'], $adminAddress['isCascadeRemove']); - $this->assertEquals($guestAddress['isCascadePersist'], $adminAddress['isCascadePersist']); - $this->assertEquals($guestAddress['isCascadeRefresh'], $adminAddress['isCascadeRefresh']); - $this->assertEquals($guestAddress['isCascadeMerge'], $adminAddress['isCascadeMerge']); - $this->assertEquals($guestAddress['isCascadeDetach'], $adminAddress['isCascadeDetach']); + self::assertEquals($guestAddress['fieldName'], $adminAddress['fieldName']); + self::assertEquals($guestAddress['type'], $adminAddress['type']); + self::assertEquals($guestAddress['mappedBy'], $adminAddress['mappedBy']); + self::assertEquals($guestAddress['inversedBy'], $adminAddress['inversedBy']); + self::assertEquals($guestAddress['isOwningSide'], $adminAddress['isOwningSide']); + self::assertEquals($guestAddress['fetch'], $adminAddress['fetch']); + self::assertEquals($guestAddress['isCascadeRemove'], $adminAddress['isCascadeRemove']); + self::assertEquals($guestAddress['isCascadePersist'], $adminAddress['isCascadePersist']); + self::assertEquals($guestAddress['isCascadeRefresh'], $adminAddress['isCascadeRefresh']); + self::assertEquals($guestAddress['isCascadeMerge'], $adminAddress['isCascadeMerge']); + self::assertEquals($guestAddress['isCascadeDetach'], $adminAddress['isCascadeDetach']); // assert override - $this->assertEquals('address_id', $guestAddress['joinColumns'][0]['name']); - $this->assertEquals(['address_id' => 'id'], $guestAddress['sourceToTargetKeyColumns']); - $this->assertEquals(['address_id' => 'address_id'], $guestAddress['joinColumnFieldNames']); - $this->assertEquals(['id' => 'address_id'], $guestAddress['targetToSourceKeyColumns']); + self::assertEquals('address_id', $guestAddress['joinColumns'][0]['name']); + self::assertEquals(['address_id' => 'id'], $guestAddress['sourceToTargetKeyColumns']); + self::assertEquals(['address_id' => 'address_id'], $guestAddress['joinColumnFieldNames']); + self::assertEquals(['id' => 'address_id'], $guestAddress['targetToSourceKeyColumns']); - $this->assertEquals('adminaddress_id', $adminAddress['joinColumns'][0]['name']); - $this->assertEquals(['adminaddress_id' => 'id'], $adminAddress['sourceToTargetKeyColumns']); - $this->assertEquals(['adminaddress_id' => 'adminaddress_id'], $adminAddress['joinColumnFieldNames']); - $this->assertEquals(['id' => 'adminaddress_id'], $adminAddress['targetToSourceKeyColumns']); + self::assertEquals('adminaddress_id', $adminAddress['joinColumns'][0]['name']); + self::assertEquals(['adminaddress_id' => 'id'], $adminAddress['sourceToTargetKeyColumns']); + self::assertEquals(['adminaddress_id' => 'adminaddress_id'], $adminAddress['joinColumnFieldNames']); + self::assertEquals(['id' => 'adminaddress_id'], $adminAddress['targetToSourceKeyColumns']); } /** @@ -844,11 +844,11 @@ public function testInversedByOverrideMapping(): void $adminMetadata = $factory->getMetadataFor(DDC3579Admin::class); // assert groups association mappings - $this->assertArrayHasKey('groups', $adminMetadata->associationMappings); + self::assertArrayHasKey('groups', $adminMetadata->associationMappings); $adminGroups = $adminMetadata->associationMappings['groups']; // assert override - $this->assertEquals('admins', $adminGroups['inversedBy']); + self::assertEquals('admins', $adminGroups['inversedBy']); } /** @@ -859,8 +859,8 @@ public function testFetchOverrideMapping(): void // check override metadata $contractMetadata = $this->createClassMetadataFactory()->getMetadataFor(DDC5934Contract::class); - $this->assertArrayHasKey('members', $contractMetadata->associationMappings); - $this->assertSame(ClassMetadata::FETCH_EXTRA_LAZY, $contractMetadata->associationMappings['members']['fetch']); + self::assertArrayHasKey('members', $contractMetadata->associationMappings); + self::assertSame(ClassMetadata::FETCH_EXTRA_LAZY, $contractMetadata->associationMappings['members']['fetch']); } /** @@ -872,31 +872,31 @@ public function testAttributeOverridesMapping(): void $guestMetadata = $factory->getMetadataFor(DDC964Guest::class); $adminMetadata = $factory->getMetadataFor(DDC964Admin::class); - $this->assertTrue($adminMetadata->fieldMappings['id']['id']); - $this->assertEquals('id', $adminMetadata->fieldMappings['id']['fieldName']); - $this->assertEquals('user_id', $adminMetadata->fieldMappings['id']['columnName']); - $this->assertEquals(['user_id' => 'id', 'user_name' => 'name'], $adminMetadata->fieldNames); - $this->assertEquals(['id' => 'user_id', 'name' => 'user_name'], $adminMetadata->columnNames); - $this->assertEquals(150, $adminMetadata->fieldMappings['id']['length']); + self::assertTrue($adminMetadata->fieldMappings['id']['id']); + self::assertEquals('id', $adminMetadata->fieldMappings['id']['fieldName']); + self::assertEquals('user_id', $adminMetadata->fieldMappings['id']['columnName']); + self::assertEquals(['user_id' => 'id', 'user_name' => 'name'], $adminMetadata->fieldNames); + self::assertEquals(['id' => 'user_id', 'name' => 'user_name'], $adminMetadata->columnNames); + self::assertEquals(150, $adminMetadata->fieldMappings['id']['length']); - $this->assertEquals('name', $adminMetadata->fieldMappings['name']['fieldName']); - $this->assertEquals('user_name', $adminMetadata->fieldMappings['name']['columnName']); - $this->assertEquals(250, $adminMetadata->fieldMappings['name']['length']); - $this->assertTrue($adminMetadata->fieldMappings['name']['nullable']); - $this->assertFalse($adminMetadata->fieldMappings['name']['unique']); + self::assertEquals('name', $adminMetadata->fieldMappings['name']['fieldName']); + self::assertEquals('user_name', $adminMetadata->fieldMappings['name']['columnName']); + self::assertEquals(250, $adminMetadata->fieldMappings['name']['length']); + self::assertTrue($adminMetadata->fieldMappings['name']['nullable']); + self::assertFalse($adminMetadata->fieldMappings['name']['unique']); - $this->assertTrue($guestMetadata->fieldMappings['id']['id']); - $this->assertEquals('guest_id', $guestMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('id', $guestMetadata->fieldMappings['id']['fieldName']); - $this->assertEquals(['guest_id' => 'id', 'guest_name' => 'name'], $guestMetadata->fieldNames); - $this->assertEquals(['id' => 'guest_id', 'name' => 'guest_name'], $guestMetadata->columnNames); - $this->assertEquals(140, $guestMetadata->fieldMappings['id']['length']); + self::assertTrue($guestMetadata->fieldMappings['id']['id']); + self::assertEquals('guest_id', $guestMetadata->fieldMappings['id']['columnName']); + self::assertEquals('id', $guestMetadata->fieldMappings['id']['fieldName']); + self::assertEquals(['guest_id' => 'id', 'guest_name' => 'name'], $guestMetadata->fieldNames); + self::assertEquals(['id' => 'guest_id', 'name' => 'guest_name'], $guestMetadata->columnNames); + self::assertEquals(140, $guestMetadata->fieldMappings['id']['length']); - $this->assertEquals('name', $guestMetadata->fieldMappings['name']['fieldName']); - $this->assertEquals('guest_name', $guestMetadata->fieldMappings['name']['columnName']); - $this->assertEquals(240, $guestMetadata->fieldMappings['name']['length']); - $this->assertFalse($guestMetadata->fieldMappings['name']['nullable']); - $this->assertTrue($guestMetadata->fieldMappings['name']['unique']); + self::assertEquals('name', $guestMetadata->fieldMappings['name']['fieldName']); + self::assertEquals('guest_name', $guestMetadata->fieldMappings['name']['columnName']); + self::assertEquals(240, $guestMetadata->fieldMappings['name']['length']); + self::assertFalse($guestMetadata->fieldMappings['name']['nullable']); + self::assertTrue($guestMetadata->fieldMappings['name']['unique']); } /** @@ -911,23 +911,23 @@ public function testEntityListeners(): void $fixClass = $factory->getMetadataFor(CompanyFlexContract::class); $ultraClass = $factory->getMetadataFor(CompanyFlexUltraContract::class); - $this->assertArrayHasKey(Events::prePersist, $superClass->entityListeners); - $this->assertArrayHasKey(Events::postPersist, $superClass->entityListeners); + self::assertArrayHasKey(Events::prePersist, $superClass->entityListeners); + self::assertArrayHasKey(Events::postPersist, $superClass->entityListeners); - $this->assertCount(1, $superClass->entityListeners[Events::prePersist]); - $this->assertCount(1, $superClass->entityListeners[Events::postPersist]); + self::assertCount(1, $superClass->entityListeners[Events::prePersist]); + self::assertCount(1, $superClass->entityListeners[Events::postPersist]); $postPersist = $superClass->entityListeners[Events::postPersist][0]; $prePersist = $superClass->entityListeners[Events::prePersist][0]; - $this->assertEquals(CompanyContractListener::class, $postPersist['class']); - $this->assertEquals(CompanyContractListener::class, $prePersist['class']); - $this->assertEquals('postPersistHandler', $postPersist['method']); - $this->assertEquals('prePersistHandler', $prePersist['method']); + self::assertEquals(CompanyContractListener::class, $postPersist['class']); + self::assertEquals(CompanyContractListener::class, $prePersist['class']); + self::assertEquals('postPersistHandler', $postPersist['method']); + self::assertEquals('prePersistHandler', $prePersist['method']); //Inherited listeners - $this->assertEquals($fixClass->entityListeners, $superClass->entityListeners); - $this->assertEquals($flexClass->entityListeners, $superClass->entityListeners); + self::assertEquals($fixClass->entityListeners, $superClass->entityListeners); + self::assertEquals($flexClass->entityListeners, $superClass->entityListeners); } /** @@ -940,27 +940,27 @@ public function testEntityListenersOverride(): void $ultraClass = $factory->getMetadataFor(CompanyFlexUltraContract::class); //overridden listeners - $this->assertArrayHasKey(Events::postPersist, $ultraClass->entityListeners); - $this->assertArrayHasKey(Events::prePersist, $ultraClass->entityListeners); + self::assertArrayHasKey(Events::postPersist, $ultraClass->entityListeners); + self::assertArrayHasKey(Events::prePersist, $ultraClass->entityListeners); - $this->assertCount(1, $ultraClass->entityListeners[Events::postPersist]); - $this->assertCount(3, $ultraClass->entityListeners[Events::prePersist]); + self::assertCount(1, $ultraClass->entityListeners[Events::postPersist]); + self::assertCount(3, $ultraClass->entityListeners[Events::prePersist]); $postPersist = $ultraClass->entityListeners[Events::postPersist][0]; $prePersist = $ultraClass->entityListeners[Events::prePersist][0]; - $this->assertEquals(CompanyContractListener::class, $postPersist['class']); - $this->assertEquals(CompanyContractListener::class, $prePersist['class']); - $this->assertEquals('postPersistHandler', $postPersist['method']); - $this->assertEquals('prePersistHandler', $prePersist['method']); + self::assertEquals(CompanyContractListener::class, $postPersist['class']); + self::assertEquals(CompanyContractListener::class, $prePersist['class']); + self::assertEquals('postPersistHandler', $postPersist['method']); + self::assertEquals('prePersistHandler', $prePersist['method']); $prePersist = $ultraClass->entityListeners[Events::prePersist][1]; - $this->assertEquals(CompanyFlexUltraContractListener::class, $prePersist['class']); - $this->assertEquals('prePersistHandler1', $prePersist['method']); + self::assertEquals(CompanyFlexUltraContractListener::class, $prePersist['class']); + self::assertEquals('prePersistHandler1', $prePersist['method']); $prePersist = $ultraClass->entityListeners[Events::prePersist][2]; - $this->assertEquals(CompanyFlexUltraContractListener::class, $prePersist['class']); - $this->assertEquals('prePersistHandler2', $prePersist['method']); + self::assertEquals(CompanyFlexUltraContractListener::class, $prePersist['class']); + self::assertEquals('prePersistHandler2', $prePersist['method']); } /** @@ -972,23 +972,23 @@ public function testEntityListenersNamingConvention(): void $factory = $this->createClassMetadataFactory($em); $metadata = $factory->getMetadataFor(CmsAddress::class); - $this->assertArrayHasKey(Events::postPersist, $metadata->entityListeners); - $this->assertArrayHasKey(Events::prePersist, $metadata->entityListeners); - $this->assertArrayHasKey(Events::postUpdate, $metadata->entityListeners); - $this->assertArrayHasKey(Events::preUpdate, $metadata->entityListeners); - $this->assertArrayHasKey(Events::postRemove, $metadata->entityListeners); - $this->assertArrayHasKey(Events::preRemove, $metadata->entityListeners); - $this->assertArrayHasKey(Events::postLoad, $metadata->entityListeners); - $this->assertArrayHasKey(Events::preFlush, $metadata->entityListeners); - - $this->assertCount(1, $metadata->entityListeners[Events::postPersist]); - $this->assertCount(1, $metadata->entityListeners[Events::prePersist]); - $this->assertCount(1, $metadata->entityListeners[Events::postUpdate]); - $this->assertCount(1, $metadata->entityListeners[Events::preUpdate]); - $this->assertCount(1, $metadata->entityListeners[Events::postRemove]); - $this->assertCount(1, $metadata->entityListeners[Events::preRemove]); - $this->assertCount(1, $metadata->entityListeners[Events::postLoad]); - $this->assertCount(1, $metadata->entityListeners[Events::preFlush]); + self::assertArrayHasKey(Events::postPersist, $metadata->entityListeners); + self::assertArrayHasKey(Events::prePersist, $metadata->entityListeners); + self::assertArrayHasKey(Events::postUpdate, $metadata->entityListeners); + self::assertArrayHasKey(Events::preUpdate, $metadata->entityListeners); + self::assertArrayHasKey(Events::postRemove, $metadata->entityListeners); + self::assertArrayHasKey(Events::preRemove, $metadata->entityListeners); + self::assertArrayHasKey(Events::postLoad, $metadata->entityListeners); + self::assertArrayHasKey(Events::preFlush, $metadata->entityListeners); + + self::assertCount(1, $metadata->entityListeners[Events::postPersist]); + self::assertCount(1, $metadata->entityListeners[Events::prePersist]); + self::assertCount(1, $metadata->entityListeners[Events::postUpdate]); + self::assertCount(1, $metadata->entityListeners[Events::preUpdate]); + self::assertCount(1, $metadata->entityListeners[Events::postRemove]); + self::assertCount(1, $metadata->entityListeners[Events::preRemove]); + self::assertCount(1, $metadata->entityListeners[Events::postLoad]); + self::assertCount(1, $metadata->entityListeners[Events::preFlush]); $postPersist = $metadata->entityListeners[Events::postPersist][0]; $prePersist = $metadata->entityListeners[Events::prePersist][0]; @@ -999,23 +999,23 @@ public function testEntityListenersNamingConvention(): void $postLoad = $metadata->entityListeners[Events::postLoad][0]; $preFlush = $metadata->entityListeners[Events::preFlush][0]; - $this->assertEquals(CmsAddressListener::class, $postPersist['class']); - $this->assertEquals(CmsAddressListener::class, $prePersist['class']); - $this->assertEquals(CmsAddressListener::class, $postUpdate['class']); - $this->assertEquals(CmsAddressListener::class, $preUpdate['class']); - $this->assertEquals(CmsAddressListener::class, $postRemove['class']); - $this->assertEquals(CmsAddressListener::class, $preRemove['class']); - $this->assertEquals(CmsAddressListener::class, $postLoad['class']); - $this->assertEquals(CmsAddressListener::class, $preFlush['class']); + self::assertEquals(CmsAddressListener::class, $postPersist['class']); + self::assertEquals(CmsAddressListener::class, $prePersist['class']); + self::assertEquals(CmsAddressListener::class, $postUpdate['class']); + self::assertEquals(CmsAddressListener::class, $preUpdate['class']); + self::assertEquals(CmsAddressListener::class, $postRemove['class']); + self::assertEquals(CmsAddressListener::class, $preRemove['class']); + self::assertEquals(CmsAddressListener::class, $postLoad['class']); + self::assertEquals(CmsAddressListener::class, $preFlush['class']); - $this->assertEquals(Events::postPersist, $postPersist['method']); - $this->assertEquals(Events::prePersist, $prePersist['method']); - $this->assertEquals(Events::postUpdate, $postUpdate['method']); - $this->assertEquals(Events::preUpdate, $preUpdate['method']); - $this->assertEquals(Events::postRemove, $postRemove['method']); - $this->assertEquals(Events::preRemove, $preRemove['method']); - $this->assertEquals(Events::postLoad, $postLoad['method']); - $this->assertEquals(Events::preFlush, $preFlush['method']); + self::assertEquals(Events::postPersist, $postPersist['method']); + self::assertEquals(Events::prePersist, $prePersist['method']); + self::assertEquals(Events::postUpdate, $postUpdate['method']); + self::assertEquals(Events::preUpdate, $preUpdate['method']); + self::assertEquals(Events::postRemove, $postRemove['method']); + self::assertEquals(Events::preRemove, $preRemove['method']); + self::assertEquals(Events::postLoad, $postLoad['method']); + self::assertEquals(Events::preFlush, $preFlush['method']); } /** @@ -1026,24 +1026,24 @@ public function testSecondLevelCacheMapping(): void $em = $this->getTestEntityManager(); $factory = $this->createClassMetadataFactory($em); $class = $factory->getMetadataFor(City::class); - $this->assertArrayHasKey('usage', $class->cache); - $this->assertArrayHasKey('region', $class->cache); - $this->assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->cache['usage']); - $this->assertEquals('doctrine_tests_models_cache_city', $class->cache['region']); + self::assertArrayHasKey('usage', $class->cache); + self::assertArrayHasKey('region', $class->cache); + self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->cache['usage']); + self::assertEquals('doctrine_tests_models_cache_city', $class->cache['region']); - $this->assertArrayHasKey('state', $class->associationMappings); - $this->assertArrayHasKey('cache', $class->associationMappings['state']); - $this->assertArrayHasKey('usage', $class->associationMappings['state']['cache']); - $this->assertArrayHasKey('region', $class->associationMappings['state']['cache']); - $this->assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['state']['cache']['usage']); - $this->assertEquals('doctrine_tests_models_cache_city__state', $class->associationMappings['state']['cache']['region']); + self::assertArrayHasKey('state', $class->associationMappings); + self::assertArrayHasKey('cache', $class->associationMappings['state']); + self::assertArrayHasKey('usage', $class->associationMappings['state']['cache']); + self::assertArrayHasKey('region', $class->associationMappings['state']['cache']); + self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['state']['cache']['usage']); + self::assertEquals('doctrine_tests_models_cache_city__state', $class->associationMappings['state']['cache']['region']); - $this->assertArrayHasKey('attractions', $class->associationMappings); - $this->assertArrayHasKey('cache', $class->associationMappings['attractions']); - $this->assertArrayHasKey('usage', $class->associationMappings['attractions']['cache']); - $this->assertArrayHasKey('region', $class->associationMappings['attractions']['cache']); - $this->assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']['cache']['usage']); - $this->assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']['cache']['region']); + self::assertArrayHasKey('attractions', $class->associationMappings); + self::assertArrayHasKey('cache', $class->associationMappings['attractions']); + self::assertArrayHasKey('usage', $class->associationMappings['attractions']['cache']); + self::assertArrayHasKey('region', $class->associationMappings['attractions']['cache']); + self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']['cache']['usage']); + self::assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']['cache']['region']); } /** @@ -1055,8 +1055,8 @@ public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): $metadata = $this->createClassMetadataFactory()->getMetadataFor(ExplicitSchemaAndTable::class); assert($metadata instanceof ClassMetadata); - $this->assertSame('explicit_schema', $metadata->getSchemaName()); - $this->assertSame('explicit_table', $metadata->getTableName()); + self::assertSame('explicit_schema', $metadata->getSchemaName()); + self::assertSame('explicit_table', $metadata->getTableName()); } /** @@ -1068,8 +1068,8 @@ public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotation $metadata = $this->createClassMetadataFactory()->getMetadataFor(SchemaAndTableInTableName::class); assert($metadata instanceof ClassMetadata); - $this->assertSame('implicit_schema', $metadata->getSchemaName()); - $this->assertSame('implicit_table', $metadata->getTableName()); + self::assertSame('implicit_schema', $metadata->getSchemaName()); + self::assertSame('implicit_table', $metadata->getTableName()); } /** @@ -1079,13 +1079,13 @@ public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotation public function testDiscriminatorColumnDefaultLength(): void { if (strpos(static::class, 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + self::markTestSkipped('PHP Mapping Drivers have no defaults.'); } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - $this->assertEquals(255, $class->discriminatorColumn['length']); + self::assertEquals(255, $class->discriminatorColumn['length']); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - $this->assertEquals(255, $class->discriminatorColumn['length']); + self::assertEquals(255, $class->discriminatorColumn['length']); } /** @@ -1095,13 +1095,13 @@ public function testDiscriminatorColumnDefaultLength(): void public function testDiscriminatorColumnDefaultType(): void { if (strpos(static::class, 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + self::markTestSkipped('PHP Mapping Drivers have no defaults.'); } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - $this->assertEquals('string', $class->discriminatorColumn['type']); + self::assertEquals('string', $class->discriminatorColumn['type']); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - $this->assertEquals('string', $class->discriminatorColumn['type']); + self::assertEquals('string', $class->discriminatorColumn['type']); } /** @@ -1111,13 +1111,13 @@ public function testDiscriminatorColumnDefaultType(): void public function testDiscriminatorColumnDefaultName(): void { if (strpos(static::class, 'PHPMappingDriver') !== false) { - $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + self::markTestSkipped('PHP Mapping Drivers have no defaults.'); } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - $this->assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals('dtype', $class->discriminatorColumn['name']); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - $this->assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals('dtype', $class->discriminatorColumn['name']); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index c06e5ed8753..00a9c6b127e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -71,7 +71,7 @@ public function testColumnWithMissingTypeDefaultsToString(): void $annotationDriver = $this->loadDriver(); $annotationDriver->loadMetadataForClass(Mapping\InvalidColumn::class, $cm); - $this->assertEquals('string', $cm->fieldMappings['id']['type']); + self::assertEquals('string', $cm->fieldMappings['id']['type']); } /** @@ -85,7 +85,7 @@ public function testGetAllClassNamesIsIdempotent(): void $annotationDriver = $this->loadDriverForCMSModels(); $afterTestReset = $annotationDriver->getAllClassNames(); - $this->assertEquals($original, $afterTestReset); + self::assertEquals($original, $afterTestReset); } /** @@ -99,7 +99,7 @@ public function testGetAllClassNamesIsIdempotentEvenWithDifferentDriverInstances $annotationDriver = $this->loadDriverForCMSModels(); $afterTestReset = $annotationDriver->getAllClassNames(); - $this->assertEquals($original, $afterTestReset); + self::assertEquals($original, $afterTestReset); } /** @@ -112,7 +112,7 @@ public function testGetAllClassNamesReturnsAlreadyLoadedClassesIfAppropriate(): $annotationDriver = $this->loadDriverForCMSModels(); $classes = $annotationDriver->getAllClassNames(); - $this->assertContains(CmsUser::class, $classes); + self::assertContains(CmsUser::class, $classes); } /** @@ -125,7 +125,7 @@ public function testGetClassNamesReturnsOnlyTheAppropriateClasses(): void $annotationDriver = $this->loadDriverForCMSModels(); $classes = $annotationDriver->getAllClassNames(); - $this->assertNotContains(ECommerceCart::class, $classes); + self::assertNotContains(ECommerceCart::class, $classes); } protected function loadDriverForCMSModels(): AnnotationDriver @@ -165,10 +165,10 @@ public function testJoinTablesWithMappedSuperclassForAnnotationDriver(): void $factory->setEntityManager($em); $classPage = $factory->getMetadataFor(File::class); - $this->assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); + self::assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); $classDirectory = $factory->getMetadataFor(Directory::class); - $this->assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); + self::assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); } /** @@ -226,10 +226,10 @@ public function testInheritanceSkipsParentLifecycleCallbacks(): void $factory->setEntityManager($em); $cm = $factory->getMetadataFor(AnnotationChild::class); - $this->assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); $cm = $factory->getMetadataFor(AnnotationParent::class); - $this->assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); } /** @@ -270,10 +270,10 @@ public function testAttributeOverridesMappingWithTrait(): void $metadataWithoutOverride = $factory->getMetadataFor(DDC1872ExampleEntityWithoutOverride::class); $metadataWithOverride = $factory->getMetadataFor(DDC1872ExampleEntityWithOverride::class); - $this->assertEquals('trait_foo', $metadataWithoutOverride->fieldMappings['foo']['columnName']); - $this->assertEquals('foo_overridden', $metadataWithOverride->fieldMappings['foo']['columnName']); - $this->assertArrayHasKey('example_trait_bar_id', $metadataWithoutOverride->associationMappings['bar']['joinColumnFieldNames']); - $this->assertArrayHasKey('example_entity_overridden_bar_id', $metadataWithOverride->associationMappings['bar']['joinColumnFieldNames']); + self::assertEquals('trait_foo', $metadataWithoutOverride->fieldMappings['foo']['columnName']); + self::assertEquals('foo_overridden', $metadataWithOverride->fieldMappings['foo']['columnName']); + self::assertArrayHasKey('example_trait_bar_id', $metadataWithoutOverride->associationMappings['bar']['joinColumnFieldNames']); + self::assertArrayHasKey('example_entity_overridden_bar_id', $metadataWithOverride->associationMappings['bar']['joinColumnFieldNames']); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index d162f8b3df2..683c8b09223 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -50,8 +50,8 @@ public function testGetColumnName(): void $class->mapField(['fieldName' => 'name', 'columnName' => 'name']); $class->mapField(['fieldName' => 'id', 'columnName' => 'id', 'id' => true]); - $this->assertEquals('id', $this->strategy->getColumnName('id', $class, $this->platform)); - $this->assertEquals('name', $this->strategy->getColumnName('name', $class, $this->platform)); + self::assertEquals('id', $this->strategy->getColumnName('id', $class, $this->platform)); + self::assertEquals('name', $this->strategy->getColumnName('name', $class, $this->platform)); } public function testGetTableName(): void @@ -59,7 +59,7 @@ public function testGetTableName(): void $class = $this->createClassMetadata(CmsUser::class); $class->setPrimaryTable(['name' => 'cms_user']); - $this->assertEquals('cms_user', $this->strategy->getTableName($class, $this->platform)); + self::assertEquals('cms_user', $this->strategy->getTableName($class, $this->platform)); } public function testJoinTableName(): void @@ -75,7 +75,7 @@ public function testJoinTableName(): void ] ); - $this->assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($class->associationMappings['user'], $class, $this->platform)); + self::assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($class->associationMappings['user'], $class, $this->platform)); } public function testIdentifierColumnNames(): void @@ -90,12 +90,12 @@ public function testIdentifierColumnNames(): void ] ); - $this->assertEquals(['id'], $this->strategy->getIdentifierColumnNames($class, $this->platform)); + self::assertEquals(['id'], $this->strategy->getIdentifierColumnNames($class, $this->platform)); } public function testColumnAlias(): void { - $this->assertEquals('columnName_1', $this->strategy->getColumnAlias('columnName', 1, $this->platform)); + self::assertEquals('columnName_1', $this->strategy->getColumnAlias('columnName', 1, $this->platform)); } public function testJoinColumnName(): void @@ -114,7 +114,7 @@ public function testJoinColumnName(): void ); $joinColumn = $class->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('article', $this->strategy->getJoinColumnName($joinColumn, $class, $this->platform)); + self::assertEquals('article', $this->strategy->getJoinColumnName($joinColumn, $class, $this->platform)); } public function testReferencedJoinColumnName(): void @@ -133,7 +133,7 @@ public function testReferencedJoinColumnName(): void ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('id', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); + self::assertEquals('id', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); } public function testGetSequenceName(): void @@ -147,6 +147,6 @@ public function testGetSequenceName(): void $class->setSequenceGeneratorDefinition($definition); - $this->assertEquals('user_id_seq', $this->strategy->getSequenceName($definition, $class, $this->platform)); + self::assertEquals('user_id_seq', $this->strategy->getSequenceName($definition, $class, $this->platform)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 8ba496a621c..01f6d365b18 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -19,7 +19,7 @@ class AttributeDriverTest extends AbstractMappingDriverTest public function requiresPhp8Assertion(): void { if (PHP_VERSION_ID < 80000) { - $this->markTestSkipped('requires PHP 8.0'); + self::markTestSkipped('requires PHP 8.0'); } } @@ -32,37 +32,37 @@ protected function loadDriver(): MappingDriver public function testNamedQuery(): void { - $this->markTestSkipped('AttributeDriver does not support named queries.'); + self::markTestSkipped('AttributeDriver does not support named queries.'); } public function testNamedNativeQuery(): void { - $this->markTestSkipped('AttributeDriver does not support named native queries.'); + self::markTestSkipped('AttributeDriver does not support named native queries.'); } public function testSqlResultSetMapping(): void { - $this->markTestSkipped('AttributeDriver does not support named sql resultset mapping.'); + self::markTestSkipped('AttributeDriver does not support named sql resultset mapping.'); } public function testAssociationOverridesMapping(): void { - $this->markTestSkipped('AttributeDriver does not support association overrides.'); + self::markTestSkipped('AttributeDriver does not support association overrides.'); } public function testInversedByOverrideMapping(): void { - $this->markTestSkipped('AttributeDriver does not support association overrides.'); + self::markTestSkipped('AttributeDriver does not support association overrides.'); } public function testFetchOverrideMapping(): void { - $this->markTestSkipped('AttributeDriver does not support association overrides.'); + self::markTestSkipped('AttributeDriver does not support association overrides.'); } public function testAttributeOverridesMapping(): void { - $this->markTestSkipped('AttributeDriver does not support association overrides.'); + self::markTestSkipped('AttributeDriver does not support association overrides.'); } public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): void @@ -71,7 +71,7 @@ public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): v $metadata = $factory->getMetadataFor(AttributeEntityWithoutOriginalParents::class); - $this->assertEquals( + self::assertEquals( [ 'name' => 'AttributeEntityWithoutOriginalParents', 'uniqueConstraints' => ['foo' => ['columns' => ['id']]], @@ -79,20 +79,20 @@ public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): v ], $metadata->table ); - $this->assertEquals(['assoz_id', 'assoz_id'], $metadata->associationMappings['assoc']['joinTableColumns']); + self::assertEquals(['assoz_id', 'assoz_id'], $metadata->associationMappings['assoc']['joinTableColumns']); } public function testIsTransient(): void { $driver = $this->loadDriver(); - $this->assertTrue($driver->isTransient(stdClass::class)); + self::assertTrue($driver->isTransient(stdClass::class)); - $this->assertTrue($driver->isTransient(AttributeTransientClass::class)); + self::assertTrue($driver->isTransient(AttributeTransientClass::class)); - $this->assertFalse($driver->isTransient(AttributeEntityWithoutOriginalParents::class)); + self::assertFalse($driver->isTransient(AttributeEntityWithoutOriginalParents::class)); - $this->assertFalse($driver->isTransient(AttributeEntityStartingWithRepeatableAttributes::class)); + self::assertFalse($driver->isTransient(AttributeEntityStartingWithRepeatableAttributes::class)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 0fa13a2b225..8c5560268b2 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -56,29 +56,29 @@ public function testGetMetadataForSubclassWithTransientBaseClass(): void { $class = $this->cmf->getMetadataFor(EntitySubClass::class); - $this->assertEmpty($class->subClasses); - $this->assertEmpty($class->parentClasses); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('name', $class->fieldMappings); + self::assertEmpty($class->subClasses); + self::assertEmpty($class->parentClasses); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('name', $class->fieldMappings); } public function testGetMetadataForSubclassWithMappedSuperclass(): void { $class = $this->cmf->getMetadataFor(EntitySubClass2::class); - $this->assertEmpty($class->subClasses); - $this->assertEmpty($class->parentClasses); + self::assertEmpty($class->subClasses); + self::assertEmpty($class->parentClasses); - $this->assertArrayHasKey('mapped1', $class->fieldMappings); - $this->assertArrayHasKey('mapped2', $class->fieldMappings); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('name', $class->fieldMappings); + self::assertArrayHasKey('mapped1', $class->fieldMappings); + self::assertArrayHasKey('mapped2', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('name', $class->fieldMappings); - $this->assertArrayNotHasKey('inherited', $class->fieldMappings['mapped1']); - $this->assertArrayNotHasKey('inherited', $class->fieldMappings['mapped2']); - $this->assertArrayNotHasKey('transient', $class->fieldMappings); + self::assertArrayNotHasKey('inherited', $class->fieldMappings['mapped1']); + self::assertArrayNotHasKey('inherited', $class->fieldMappings['mapped2']); + self::assertArrayNotHasKey('transient', $class->fieldMappings); - $this->assertArrayHasKey('mappedRelated1', $class->associationMappings); + self::assertArrayHasKey('mappedRelated1', $class->associationMappings); } /** @@ -88,24 +88,24 @@ public function testGetMetadataForSubclassWithMappedSuperclassWithRepository(): { $class = $this->cmf->getMetadataFor(DDC869CreditCardPayment::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); - $this->assertArrayHasKey('creditCardNumber', $class->fieldMappings); - $this->assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('value', $class->fieldMappings); + self::assertArrayHasKey('creditCardNumber', $class->fieldMappings); + self::assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); $class = $this->cmf->getMetadataFor(DDC869ChequePayment::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); - $this->assertArrayHasKey('serialNumber', $class->fieldMappings); - $this->assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('value', $class->fieldMappings); + self::assertArrayHasKey('serialNumber', $class->fieldMappings); + self::assertEquals($class->customRepositoryClassName, DDC869PaymentRepository::class); // override repositoryClass $class = $this->cmf->getMetadataFor(SubclassWithRepository::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('value', $class->fieldMappings); - $this->assertEquals($class->customRepositoryClassName, EntityRepository::class); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('value', $class->fieldMappings); + self::assertEquals($class->customRepositoryClassName, EntityRepository::class); } /** @@ -118,9 +118,9 @@ public function testSerializationWithPrivateFieldsFromMappedSuperclass(): void $class2 = unserialize(serialize($class)); $class2->wakeupReflection(new RuntimeReflectionService()); - $this->assertArrayHasKey('mapped1', $class2->reflFields); - $this->assertArrayHasKey('mapped2', $class2->reflFields); - $this->assertArrayHasKey('mappedRelated1', $class2->reflFields); + self::assertArrayHasKey('mapped1', $class2->reflFields); + self::assertArrayHasKey('mapped2', $class2->reflFields); + self::assertArrayHasKey('mappedRelated1', $class2->reflFields); } /** @@ -130,9 +130,9 @@ public function testUnmappedSuperclassInHierarchy(): void { $class = $this->cmf->getMetadataFor(HierarchyD::class); - $this->assertArrayHasKey('id', $class->fieldMappings); - $this->assertArrayHasKey('a', $class->fieldMappings); - $this->assertArrayHasKey('d', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('a', $class->fieldMappings); + self::assertArrayHasKey('d', $class->fieldMappings); } /** @@ -159,7 +159,7 @@ public function testMappedSuperclassWithId(): void { $class = $this->cmf->getMetadataFor(SuperclassEntity::class); - $this->assertArrayHasKey('id', $class->fieldMappings); + self::assertArrayHasKey('id', $class->fieldMappings); } /** @@ -171,8 +171,8 @@ public function testGeneratedValueFromMappedSuperclass(): void $class = $this->cmf->getMetadataFor(SuperclassEntity::class); assert($class instanceof ClassMetadata); - $this->assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); - $this->assertEquals( + self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); + self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], $class->sequenceGeneratorDefinition ); @@ -187,8 +187,8 @@ public function testSequenceDefinitionInHierarchyWithSandwichMappedSuperclass(): $class = $this->cmf->getMetadataFor(HierarchyD::class); assert($class instanceof ClassMetadata); - $this->assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); - $this->assertEquals( + self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); + self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], $class->sequenceGeneratorDefinition ); @@ -203,8 +203,8 @@ public function testMultipleMappedSuperclasses(): void $class = $this->cmf->getMetadataFor(MediumSuperclassEntity::class); assert($class instanceof ClassMetadata); - $this->assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); - $this->assertEquals( + self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); + self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], $class->sequenceGeneratorDefinition ); @@ -220,10 +220,10 @@ public function testMappedSuperclassIndex(): void $class = $this->cmf->getMetadataFor(EntityIndexSubClass::class); assert($class instanceof ClassMetadata); - $this->assertArrayHasKey('mapped1', $class->fieldMappings); - $this->assertArrayHasKey('IDX_NAME_INDEX', $class->table['uniqueConstraints']); - $this->assertArrayHasKey('IDX_MAPPED1_INDEX', $class->table['uniqueConstraints']); - $this->assertArrayHasKey('IDX_MAPPED2_INDEX', $class->table['indexes']); + self::assertArrayHasKey('mapped1', $class->fieldMappings); + self::assertArrayHasKey('IDX_NAME_INDEX', $class->table['uniqueConstraints']); + self::assertArrayHasKey('IDX_MAPPED1_INDEX', $class->table['uniqueConstraints']); + self::assertArrayHasKey('IDX_MAPPED2_INDEX', $class->table['indexes']); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index c2e690cc65f..c73f9503c84 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -35,22 +35,22 @@ protected function setUp(): void public function testSetMappedSuperClass(): void { $this->assertIsFluent($this->builder->setMappedSuperClass()); - $this->assertTrue($this->cm->isMappedSuperclass); - $this->assertFalse($this->cm->isEmbeddedClass); + self::assertTrue($this->cm->isMappedSuperclass); + self::assertFalse($this->cm->isEmbeddedClass); } public function testSetEmbedable(): void { $this->assertIsFluent($this->builder->setEmbeddable()); - $this->assertTrue($this->cm->isEmbeddedClass); - $this->assertFalse($this->cm->isMappedSuperclass); + self::assertTrue($this->cm->isEmbeddedClass); + self::assertFalse($this->cm->isMappedSuperclass); } public function testAddEmbeddedWithOnlyRequiredParams(): void { $this->assertIsFluent($this->builder->addEmbedded('name', Name::class)); - $this->assertEquals( + self::assertEquals( [ 'name' => [ 'class' => Name::class, @@ -73,7 +73,7 @@ public function testAddEmbeddedWithPrefix(): void ) ); - $this->assertEquals( + self::assertEquals( [ 'name' => [ 'class' => Name::class, @@ -89,12 +89,12 @@ public function testAddEmbeddedWithPrefix(): void public function testCreateEmbeddedWithoutExtraParams(): void { $embeddedBuilder = $this->builder->createEmbedded('name', Name::class); - $this->assertInstanceOf(EmbeddedBuilder::class, $embeddedBuilder); + self::assertInstanceOf(EmbeddedBuilder::class, $embeddedBuilder); - $this->assertFalse(isset($this->cm->embeddedClasses['name'])); + self::assertFalse(isset($this->cm->embeddedClasses['name'])); $this->assertIsFluent($embeddedBuilder->build()); - $this->assertEquals( + self::assertEquals( [ 'class' => Name::class, 'columnPrefix' => null, @@ -109,11 +109,11 @@ public function testCreateEmbeddedWithColumnPrefix(): void { $embeddedBuilder = $this->builder->createEmbedded('name', Name::class); - $this->assertEquals($embeddedBuilder, $embeddedBuilder->setColumnPrefix('nm_')); + self::assertEquals($embeddedBuilder, $embeddedBuilder->setColumnPrefix('nm_')); $this->assertIsFluent($embeddedBuilder->build()); - $this->assertEquals( + self::assertEquals( [ 'class' => Name::class, 'columnPrefix' => 'nm_', @@ -127,31 +127,31 @@ public function testCreateEmbeddedWithColumnPrefix(): void public function testSetCustomRepositoryClass(): void { $this->assertIsFluent($this->builder->setCustomRepositoryClass(CmsGroup::class)); - $this->assertEquals(CmsGroup::class, $this->cm->customRepositoryClassName); + self::assertEquals(CmsGroup::class, $this->cm->customRepositoryClassName); } public function testSetReadOnly(): void { $this->assertIsFluent($this->builder->setReadOnly()); - $this->assertTrue($this->cm->isReadOnly); + self::assertTrue($this->cm->isReadOnly); } public function testSetTable(): void { $this->assertIsFluent($this->builder->setTable('users')); - $this->assertEquals('users', $this->cm->table['name']); + self::assertEquals('users', $this->cm->table['name']); } public function testAddIndex(): void { $this->assertIsFluent($this->builder->addIndex(['username', 'name'], 'users_idx')); - $this->assertEquals(['users_idx' => ['columns' => ['username', 'name']]], $this->cm->table['indexes']); + self::assertEquals(['users_idx' => ['columns' => ['username', 'name']]], $this->cm->table['indexes']); } public function testAddUniqueConstraint(): void { $this->assertIsFluent($this->builder->addUniqueConstraint(['username', 'name'], 'users_idx')); - $this->assertEquals(['users_idx' => ['columns' => ['username', 'name']]], $this->cm->table['uniqueConstraints']); + self::assertEquals(['users_idx' => ['columns' => ['username', 'name']]], $this->cm->table['uniqueConstraints']); } public function testSetPrimaryTableRelated(): void @@ -160,7 +160,7 @@ public function testSetPrimaryTableRelated(): void $this->builder->addIndex(['username', 'name'], 'users_idx'); $this->builder->setTable('users'); - $this->assertEquals( + self::assertEquals( [ 'name' => 'users', 'indexes' => ['users_idx' => ['columns' => ['username', 'name']]], @@ -173,19 +173,19 @@ public function testSetPrimaryTableRelated(): void public function testSetInheritanceJoined(): void { $this->assertIsFluent($this->builder->setJoinedTableInheritance()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_JOINED, $this->cm->inheritanceType); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_JOINED, $this->cm->inheritanceType); } public function testSetInheritanceSingleTable(): void { $this->assertIsFluent($this->builder->setSingleTableInheritance()); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE, $this->cm->inheritanceType); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE, $this->cm->inheritanceType); } public function testSetDiscriminatorColumn(): void { $this->assertIsFluent($this->builder->setDiscriminatorColumn('discr', 'string', '124')); - $this->assertEquals(['fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => '124'], $this->cm->discriminatorColumn); + self::assertEquals(['fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => '124'], $this->cm->discriminatorColumn); } public function testAddDiscriminatorMapClass(): void @@ -193,45 +193,45 @@ public function testAddDiscriminatorMapClass(): void $this->assertIsFluent($this->builder->addDiscriminatorMapClass('test', CmsUser::class)); $this->assertIsFluent($this->builder->addDiscriminatorMapClass('test2', CmsGroup::class)); - $this->assertEquals( + self::assertEquals( ['test' => CmsUser::class, 'test2' => CmsGroup::class], $this->cm->discriminatorMap ); - $this->assertEquals('test', $this->cm->discriminatorValue); + self::assertEquals('test', $this->cm->discriminatorValue); } public function testChangeTrackingPolicyExplicit(): void { $this->assertIsFluent($this->builder->setChangeTrackingPolicyDeferredExplicit()); - $this->assertEquals(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT, $this->cm->changeTrackingPolicy); + self::assertEquals(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT, $this->cm->changeTrackingPolicy); } public function testChangeTrackingPolicyNotify(): void { $this->assertIsFluent($this->builder->setChangeTrackingPolicyNotify()); - $this->assertEquals(ClassMetadata::CHANGETRACKING_NOTIFY, $this->cm->changeTrackingPolicy); + self::assertEquals(ClassMetadata::CHANGETRACKING_NOTIFY, $this->cm->changeTrackingPolicy); } public function testAddField(): void { $this->assertIsFluent($this->builder->addField('name', 'string')); - $this->assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); + self::assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); } public function testCreateField(): void { $fieldBuilder = $this->builder->createField('name', 'string'); - $this->assertInstanceOf(FieldBuilder::class, $fieldBuilder); + self::assertInstanceOf(FieldBuilder::class, $fieldBuilder); - $this->assertFalse(isset($this->cm->fieldMappings['name'])); + self::assertFalse(isset($this->cm->fieldMappings['name'])); $this->assertIsFluent($fieldBuilder->build()); - $this->assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); + self::assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); } public function testCreateVersionedField(): void { $this->builder->createField('name', 'integer')->columnName('username')->length(124)->nullable()->columnDefinition('foobar')->unique()->isVersionField()->build(); - $this->assertEquals( + self::assertEquals( [ 'columnDefinition' => 'foobar', 'columnName' => 'username', @@ -250,15 +250,15 @@ public function testCreatePrimaryField(): void { $this->builder->createField('id', 'integer')->makePrimaryKey()->generatedValue()->build(); - $this->assertEquals(['id'], $this->cm->identifier); - $this->assertEquals(['columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'], $this->cm->fieldMappings['id']); + self::assertEquals(['id'], $this->cm->identifier); + self::assertEquals(['columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'], $this->cm->fieldMappings['id']); } public function testCreateUnsignedOptionField(): void { $this->builder->createField('state', 'integer')->option('unsigned', true)->build(); - $this->assertEquals( + self::assertEquals( ['fieldName' => 'state', 'type' => 'integer', 'options' => ['unsigned' => true], 'columnName' => 'state'], $this->cm->fieldMappings['state'] ); @@ -268,7 +268,7 @@ public function testAddLifecycleEvent(): void { $this->builder->addLifecycleEvent('getStatus', 'postLoad'); - $this->assertEquals(['postLoad' => ['getStatus']], $this->cm->lifecycleCallbacks); + self::assertEquals(['postLoad' => ['getStatus']], $this->cm->lifecycleCallbacks); } public function testCreateManyToOne(): void @@ -281,7 +281,7 @@ public function testCreateManyToOne(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -341,7 +341,7 @@ public function testCreateManyToOneWithIdentity(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -399,7 +399,7 @@ public function testCreateOneToOne(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -459,7 +459,7 @@ public function testCreateOneToOneWithIdentity(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -532,7 +532,7 @@ public function testCreateManyToMany(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ @@ -626,7 +626,7 @@ public function testCreateOneToMany(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ @@ -677,7 +677,7 @@ public function testOrphanRemovalOnCreateOneToOne(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -728,7 +728,7 @@ public function testOrphanRemovalOnCreateOneToMany(): void ->build() ); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ @@ -772,7 +772,7 @@ public function testOrphanRemovalOnManyToMany(): void ->orphanRemoval() ->build(); - $this->assertEquals( + self::assertEquals( [ 'groups' => [ 'fieldName' => 'groups', @@ -825,6 +825,6 @@ public function testOrphanRemovalOnManyToMany(): void public function assertIsFluent($ret): void { - $this->assertSame($this->builder, $ret, 'Return Value has to be same instance as used builder'); + self::assertSame($this->builder, $ret, 'Return Value has to be same instance as used builder'); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 28d3d6f5115..a1b6e756d63 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -70,21 +70,21 @@ public function testGetMetadataForSingleClass(): void $cmf->setMetadataFor($cm1->name, $cm1); // Prechecks - $this->assertEquals([], $cm1->parentClasses); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType); - $this->assertTrue($cm1->hasField('name')); - $this->assertEquals(2, count($cm1->associationMappings)); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType); - $this->assertEquals('group', $cm1->table['name']); + self::assertEquals([], $cm1->parentClasses); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType); + self::assertTrue($cm1->hasField('name')); + self::assertEquals(2, count($cm1->associationMappings)); + self::assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType); + self::assertEquals('group', $cm1->table['name']); // Go $cmMap1 = $cmf->getMetadataFor($cm1->name); - $this->assertSame($cm1, $cmMap1); - $this->assertEquals('group', $cmMap1->table['name']); - $this->assertTrue($cmMap1->table['quoted']); - $this->assertEquals([], $cmMap1->parentClasses); - $this->assertTrue($cmMap1->hasField('name')); + self::assertSame($cm1, $cmMap1); + self::assertEquals('group', $cmMap1->table['name']); + self::assertTrue($cmMap1->table['quoted']); + self::assertEquals([], $cmMap1->parentClasses); + self::assertTrue($cmMap1->hasField('name')); } public function testGetMetadataForReturnsLoadedCustomIdGenerator(): void @@ -97,8 +97,8 @@ public function testGetMetadataForReturnsLoadedCustomIdGenerator(): void $actual = $cmf->getMetadataFor($cm1->name); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $actual->generatorType); - $this->assertInstanceOf(CustomIdGenerator::class, $actual->idGenerator); + self::assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $actual->generatorType); + self::assertInstanceOf(CustomIdGenerator::class, $actual->idGenerator); } public function testGetMetadataForThrowsExceptionOnUnknownCustomGeneratorClass(): void @@ -138,9 +138,9 @@ public function testHasGetMetadataNamespaceSeparatorIsNotNormalized(): void $h2 = $mf->hasMetadataFor('\\' . DoctrineGlobalArticle::class); $m2 = $mf->getMetadataFor('\\' . DoctrineGlobalArticle::class); - $this->assertNotSame($m1, $m2); - $this->assertFalse($h2); - $this->assertTrue($h1); + self::assertNotSame($m1, $m2); + self::assertFalse($h2); + self::assertTrue($h1); } /** @@ -150,7 +150,7 @@ public function testIsTransient(): void { $cmf = new ClassMetadataFactory(); $driver = $this->createMock(MappingDriver::class); - $driver->expects($this->exactly(2)) + $driver->expects(self::exactly(2)) ->method('isTransient') ->withConsecutive( [CmsUser::class], @@ -165,8 +165,8 @@ public function testIsTransient(): void $em = $this->createEntityManager($driver); - $this->assertTrue($em->getMetadataFactory()->isTransient(CmsUser::class)); - $this->assertFalse($em->getMetadataFactory()->isTransient(CmsArticle::class)); + self::assertTrue($em->getMetadataFactory()->isTransient(CmsUser::class)); + self::assertFalse($em->getMetadataFactory()->isTransient(CmsArticle::class)); } /** @@ -176,7 +176,7 @@ public function testIsTransientEntityNamespace(): void { $cmf = new ClassMetadataFactory(); $driver = $this->createMock(MappingDriver::class); - $driver->expects($this->exactly(2)) + $driver->expects(self::exactly(2)) ->method('isTransient') ->withConsecutive( [CmsUser::class], @@ -192,8 +192,8 @@ public function testIsTransientEntityNamespace(): void $em = $this->createEntityManager($driver); $em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - $this->assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); - $this->assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); + self::assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); + self::assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); } public function testAddDefaultDiscriminatorMap(): void @@ -220,18 +220,18 @@ public function testAddDefaultDiscriminatorMap(): void $childClassKey = array_search($childClass, $rootDiscriminatorMap, true); $anotherChildClassKey = array_search($anotherChildClass, $rootDiscriminatorMap, true); - $this->assertEquals('rootclass', $rootClassKey); - $this->assertEquals('childclass', $childClassKey); - $this->assertEquals('anotherchildclass', $anotherChildClassKey); + self::assertEquals('rootclass', $rootClassKey); + self::assertEquals('childclass', $childClassKey); + self::assertEquals('anotherchildclass', $anotherChildClassKey); - $this->assertEquals($childDiscriminatorMap, $rootDiscriminatorMap); - $this->assertEquals($anotherChildDiscriminatorMap, $rootDiscriminatorMap); + self::assertEquals($childDiscriminatorMap, $rootDiscriminatorMap); + self::assertEquals($anotherChildDiscriminatorMap, $rootDiscriminatorMap); // ClassMetadataFactory::addDefaultDiscriminatorMap shouldn't be called again, because the // discriminator map is already cached $cmf = $this->getMockBuilder(ClassMetadataFactory::class)->setMethods(['addDefaultDiscriminatorMap'])->getMock(); $cmf->setEntityManager($em); - $cmf->expects($this->never()) + $cmf->expects(self::never()) ->method('addDefaultDiscriminatorMap'); $rootMetadata = $cmf->getMetadataFor(RootClass::class); @@ -244,9 +244,9 @@ public function testGetAllMetadataWorksWithBadConnection(): void $mockDriver = new MetadataDriverMock(); $em = $this->createEntityManager($mockDriver, $conn); - $conn->expects($this->any()) + $conn->expects(self::any()) ->method('getDatabasePlatform') - ->will($this->throwException(new Exception('Exception thrown in test when calling getDatabasePlatform'))); + ->will(self::throwException(new Exception('Exception thrown in test when calling getDatabasePlatform'))); $cmf = new ClassMetadataFactory(); $cmf->setEntityManager($em); @@ -254,7 +254,7 @@ public function testGetAllMetadataWorksWithBadConnection(): void // getting all the metadata should work, even if get DatabasePlatform blows up $metadata = $cmf->getAllMetadata(); // this will just be an empty array - there was no error - $this->assertEquals([], $metadata); + self::assertEquals([], $metadata); } protected function createEntityManager(MappingDriver $metadataDriver, $conn = null): EntityManagerMock @@ -324,60 +324,60 @@ public function testQuoteMetadata(): void $addressMetadata = $cmf->getMetadataFor(Quote\Address::class); // Phone Class Metadata - $this->assertTrue($phoneMetadata->fieldMappings['number']['quoted']); - $this->assertEquals('phone-number', $phoneMetadata->fieldMappings['number']['columnName']); + self::assertTrue($phoneMetadata->fieldMappings['number']['quoted']); + self::assertEquals('phone-number', $phoneMetadata->fieldMappings['number']['columnName']); $user = $phoneMetadata->associationMappings['user']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('user-id', $user['joinColumns'][0]['name']); - $this->assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user['joinColumns'][0]['quoted']); + self::assertEquals('user-id', $user['joinColumns'][0]['name']); + self::assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); // User Group Metadata - $this->assertTrue($groupMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($groupMetadata->fieldMappings['name']['quoted']); + self::assertTrue($groupMetadata->fieldMappings['id']['quoted']); + self::assertTrue($groupMetadata->fieldMappings['name']['quoted']); - $this->assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); + self::assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); + self::assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); $user = $groupMetadata->associationMappings['parent']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('parent-id', $user['joinColumns'][0]['name']); - $this->assertEquals('group-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user['joinColumns'][0]['quoted']); + self::assertEquals('parent-id', $user['joinColumns'][0]['name']); + self::assertEquals('group-id', $user['joinColumns'][0]['referencedColumnName']); // Address Class Metadata - $this->assertTrue($addressMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($addressMetadata->fieldMappings['zip']['quoted']); + self::assertTrue($addressMetadata->fieldMappings['id']['quoted']); + self::assertTrue($addressMetadata->fieldMappings['zip']['quoted']); - $this->assertEquals('address-id', $addressMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('address-zip', $addressMetadata->fieldMappings['zip']['columnName']); + self::assertEquals('address-id', $addressMetadata->fieldMappings['id']['columnName']); + self::assertEquals('address-zip', $addressMetadata->fieldMappings['zip']['columnName']); $user = $addressMetadata->associationMappings['user']; - $this->assertTrue($user['joinColumns'][0]['quoted']); - $this->assertEquals('user-id', $user['joinColumns'][0]['name']); - $this->assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user['joinColumns'][0]['quoted']); + self::assertEquals('user-id', $user['joinColumns'][0]['name']); + self::assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); // User Class Metadata - $this->assertTrue($userMetadata->fieldMappings['id']['quoted']); - $this->assertTrue($userMetadata->fieldMappings['name']['quoted']); + self::assertTrue($userMetadata->fieldMappings['id']['quoted']); + self::assertTrue($userMetadata->fieldMappings['name']['quoted']); - $this->assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); - $this->assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); + self::assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); + self::assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); $address = $userMetadata->associationMappings['address']; - $this->assertTrue($address['joinColumns'][0]['quoted']); - $this->assertEquals('address-id', $address['joinColumns'][0]['name']); - $this->assertEquals('address-id', $address['joinColumns'][0]['referencedColumnName']); + self::assertTrue($address['joinColumns'][0]['quoted']); + self::assertEquals('address-id', $address['joinColumns'][0]['name']); + self::assertEquals('address-id', $address['joinColumns'][0]['referencedColumnName']); $groups = $userMetadata->associationMappings['groups']; - $this->assertTrue($groups['joinTable']['quoted']); - $this->assertTrue($groups['joinTable']['joinColumns'][0]['quoted']); - $this->assertEquals('quote-users-groups', $groups['joinTable']['name']); - $this->assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['referencedColumnName']); - - $this->assertTrue($groups['joinTable']['inverseJoinColumns'][0]['quoted']); - $this->assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + self::assertTrue($groups['joinTable']['quoted']); + self::assertTrue($groups['joinTable']['joinColumns'][0]['quoted']); + self::assertEquals('quote-users-groups', $groups['joinTable']['name']); + self::assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['name']); + self::assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['referencedColumnName']); + + self::assertTrue($groups['joinTable']['inverseJoinColumns'][0]['quoted']); + self::assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); } /** @@ -399,9 +399,9 @@ public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMeta $cmf->setEntityManager($em); $listener - ->expects($this->any()) + ->expects(self::any()) ->method('onClassMetadataNotFound') - ->will($this->returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em): void { + ->will(self::returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em): void { self::assertNull($args->getFoundMetadata()); self::assertSame('Foo', $args->getClassName()); self::assertSame($em, $args->getObjectManager()); @@ -411,7 +411,7 @@ public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMeta $eventManager->addEventListener([Events::onClassMetadataNotFound], $listener); - $this->assertSame($metadata, $cmf->getMetadataFor('Foo')); + self::assertSame($metadata, $cmf->getMetadataFor('Foo')); } /** @@ -428,7 +428,7 @@ public function testAcceptsEntityManagerInterfaceInstances(): void $class = new ReflectionClass(ClassMetadataFactory::class); $property = $class->getProperty('em'); $property->setAccessible(true); - $this->assertSame($entityManager, $property->getValue($classMetadataFactory)); + self::assertSame($entityManager, $property->getValue($classMetadataFactory)); } /** @@ -468,7 +468,7 @@ public function testInheritsIdGeneratorMappingFromEmbeddable(): void $userMetadata = $cmf->getMetadataFor(DDC4006User::class); - $this->assertTrue($userMetadata->isIdGeneratorIdentity()); + self::assertTrue($userMetadata->isIdGeneratorIdentity()); } public function testInvalidSubClassCase(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index 5036981e95e..c3b3ec43bd9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -25,9 +25,9 @@ public function testEvent(): void $evm = $em->getEventManager(); $evm->addEventListener(Events::loadClassMetadata, $this); $classMetadata = $metadataFactory->getMetadataFor(LoadEventTestEntity::class); - $this->assertTrue($classMetadata->hasField('about')); - $this->assertArrayHasKey('about', $classMetadata->reflFields); - $this->assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); + self::assertTrue($classMetadata->hasField('about')); + self::assertArrayHasKey('about', $classMetadata->reflFields); + self::assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); } public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 900790fa182..309de6304bf 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -52,13 +52,13 @@ public function testClassMetadataInstanceSerialization(): void $cm->initializeReflection(new RuntimeReflectionService()); // Test initial state - $this->assertTrue(count($cm->getReflectionProperties()) === 0); - $this->assertInstanceOf('ReflectionClass', $cm->reflClass); - $this->assertEquals(CMS\CmsUser::class, $cm->name); - $this->assertEquals(CMS\CmsUser::class, $cm->rootEntityName); - $this->assertEquals([], $cm->subClasses); - $this->assertEquals([], $cm->parentClasses); - $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType); + self::assertTrue(count($cm->getReflectionProperties()) === 0); + self::assertInstanceOf('ReflectionClass', $cm->reflClass); + self::assertEquals(CMS\CmsUser::class, $cm->name); + self::assertEquals(CMS\CmsUser::class, $cm->rootEntityName); + self::assertEquals([], $cm->subClasses); + self::assertEquals([], $cm->parentClasses); + self::assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType); // Customize state $cm->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE); @@ -69,30 +69,30 @@ public function testClassMetadataInstanceSerialization(): void $cm->mapOneToOne(['fieldName' => 'phonenumbers', 'targetEntity' => 'CmsAddress', 'mappedBy' => 'foo']); $cm->markReadOnly(); $cm->addNamedQuery(['name' => 'dql', 'query' => 'foo']); - $this->assertEquals(1, count($cm->associationMappings)); + self::assertEquals(1, count($cm->associationMappings)); $serialized = serialize($cm); $cm = unserialize($serialized); $cm->wakeupReflection(new RuntimeReflectionService()); // Check state - $this->assertTrue(count($cm->getReflectionProperties()) > 0); - $this->assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace); - $this->assertInstanceOf(ReflectionClass::class, $cm->reflClass); - $this->assertEquals(CMS\CmsUser::class, $cm->name); - $this->assertEquals('UserParent', $cm->rootEntityName); - $this->assertEquals([CMS\One::class, CMS\Two::class, CMS\Three::class], $cm->subClasses); - $this->assertEquals(['UserParent'], $cm->parentClasses); - $this->assertEquals(CMS\UserRepository::class, $cm->customRepositoryClassName); - $this->assertEquals(['name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'], $cm->discriminatorColumn); - $this->assertTrue($cm->associationMappings['phonenumbers']['type'] === ClassMetadata::ONE_TO_ONE); - $this->assertEquals(1, count($cm->associationMappings)); + self::assertTrue(count($cm->getReflectionProperties()) > 0); + self::assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace); + self::assertInstanceOf(ReflectionClass::class, $cm->reflClass); + self::assertEquals(CMS\CmsUser::class, $cm->name); + self::assertEquals('UserParent', $cm->rootEntityName); + self::assertEquals([CMS\One::class, CMS\Two::class, CMS\Three::class], $cm->subClasses); + self::assertEquals(['UserParent'], $cm->parentClasses); + self::assertEquals(CMS\UserRepository::class, $cm->customRepositoryClassName); + self::assertEquals(['name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'], $cm->discriminatorColumn); + self::assertTrue($cm->associationMappings['phonenumbers']['type'] === ClassMetadata::ONE_TO_ONE); + self::assertEquals(1, count($cm->associationMappings)); $oneOneMapping = $cm->getAssociationMapping('phonenumbers'); - $this->assertTrue($oneOneMapping['fetch'] === ClassMetadata::FETCH_LAZY); - $this->assertEquals('phonenumbers', $oneOneMapping['fieldName']); - $this->assertEquals(CMS\CmsAddress::class, $oneOneMapping['targetEntity']); - $this->assertTrue($cm->isReadOnly); - $this->assertEquals(['dql' => ['name' => 'dql', 'query' => 'foo', 'dql' => 'foo']], $cm->namedQueries); + self::assertTrue($oneOneMapping['fetch'] === ClassMetadata::FETCH_LAZY); + self::assertEquals('phonenumbers', $oneOneMapping['fieldName']); + self::assertEquals(CMS\CmsAddress::class, $oneOneMapping['targetEntity']); + self::assertTrue($cm->isReadOnly); + self::assertEquals(['dql' => ['name' => 'dql', 'query' => 'foo', 'dql' => 'foo']], $cm->namedQueries); } public function testFieldIsNullable(): void @@ -102,40 +102,40 @@ public function testFieldIsNullable(): void // Explicit Nullable $cm->mapField(['fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50]); - $this->assertTrue($cm->isNullable('status')); + self::assertTrue($cm->isNullable('status')); // Explicit Not Nullable $cm->mapField(['fieldName' => 'username', 'nullable' => false, 'type' => 'string', 'length' => 50]); - $this->assertFalse($cm->isNullable('username')); + self::assertFalse($cm->isNullable('username')); // Implicit Not Nullable $cm->mapField(['fieldName' => 'name', 'type' => 'string', 'length' => 50]); - $this->assertFalse($cm->isNullable('name'), 'By default a field should not be nullable.'); + self::assertFalse($cm->isNullable('name'), 'By default a field should not be nullable.'); } public function testFieldIsNullableByType(): void { if (PHP_VERSION_ID < 70400) { - $this->markTestSkipped('requies PHP 7.4'); + self::markTestSkipped('requies PHP 7.4'); } $cm = new ClassMetadata(TypedProperties\UserTyped::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapOneToOne(['fieldName' => 'email', 'joinColumns' => [[]]]); - $this->assertEquals(CmsEmail::class, $cm->getAssociationMapping('email')['targetEntity']); + self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('email')['targetEntity']); $cm->mapManyToOne(['fieldName' => 'mainEmail']); - $this->assertEquals(CmsEmail::class, $cm->getAssociationMapping('mainEmail')['targetEntity']); + self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('mainEmail')['targetEntity']); $cm->mapEmbedded(['fieldName' => 'contact']); - $this->assertEquals(TypedProperties\Contact::class, $cm->embeddedClasses['contact']['class']); + self::assertEquals(TypedProperties\Contact::class, $cm->embeddedClasses['contact']['class']); } public function testFieldTypeFromReflection(): void { if (PHP_VERSION_ID < 70400) { - $this->markTestSkipped('requies PHP 7.4'); + self::markTestSkipped('requies PHP 7.4'); } $cm = new ClassMetadata(TypedProperties\UserTyped::class); @@ -143,35 +143,35 @@ public function testFieldTypeFromReflection(): void // Integer $cm->mapField(['fieldName' => 'id']); - $this->assertEquals('integer', $cm->getTypeOfField('id')); + self::assertEquals('integer', $cm->getTypeOfField('id')); // String $cm->mapField(['fieldName' => 'username', 'length' => 50]); - $this->assertEquals('string', $cm->getTypeOfField('username')); + self::assertEquals('string', $cm->getTypeOfField('username')); // DateInterval object $cm->mapField(['fieldName' => 'dateInterval']); - $this->assertEquals('dateinterval', $cm->getTypeOfField('dateInterval')); + self::assertEquals('dateinterval', $cm->getTypeOfField('dateInterval')); // DateTime object $cm->mapField(['fieldName' => 'dateTime']); - $this->assertEquals('datetime', $cm->getTypeOfField('dateTime')); + self::assertEquals('datetime', $cm->getTypeOfField('dateTime')); // DateTimeImmutable object $cm->mapField(['fieldName' => 'dateTimeImmutable']); - $this->assertEquals('datetime_immutable', $cm->getTypeOfField('dateTimeImmutable')); + self::assertEquals('datetime_immutable', $cm->getTypeOfField('dateTimeImmutable')); // array as JSON $cm->mapField(['fieldName' => 'array']); - $this->assertEquals('json', $cm->getTypeOfField('array')); + self::assertEquals('json', $cm->getTypeOfField('array')); // bool $cm->mapField(['fieldName' => 'boolean']); - $this->assertEquals('boolean', $cm->getTypeOfField('boolean')); + self::assertEquals('boolean', $cm->getTypeOfField('boolean')); // float $cm->mapField(['fieldName' => 'float']); - $this->assertEquals('float', $cm->getTypeOfField('float')); + self::assertEquals('float', $cm->getTypeOfField('float')); } /** @@ -195,7 +195,7 @@ public function testMapAssociationInGlobalNamespace(): void ] ); - $this->assertEquals('DoctrineGlobalUser', $cm->associationMappings['author']['targetEntity']); + self::assertEquals('DoctrineGlobalUser', $cm->associationMappings['author']['targetEntity']); } public function testMapManyToManyJoinTableDefaults(): void @@ -210,7 +210,7 @@ public function testMapManyToManyJoinTableDefaults(): void ); $assoc = $cm->associationMappings['groups']; - $this->assertEquals( + self::assertEquals( [ 'name' => 'cmsuser_cmsgroup', 'joinColumns' => [['name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], @@ -218,7 +218,7 @@ public function testMapManyToManyJoinTableDefaults(): void ], $assoc['joinTable'] ); - $this->assertTrue($assoc['isOnDeleteCascade']); + self::assertTrue($assoc['isOnDeleteCascade']); } public function testSerializeManyToManyJoinTableCascade(): void @@ -235,7 +235,7 @@ public function testSerializeManyToManyJoinTableCascade(): void $assoc = $cm->associationMappings['groups']; $assoc = unserialize(serialize($assoc)); - $this->assertTrue($assoc['isOnDeleteCascade']); + self::assertTrue($assoc['isOnDeleteCascade']); } /** @@ -249,8 +249,8 @@ public function testSetDiscriminatorMapInGlobalNamespace(): void $cm->initializeReflection(new RuntimeReflectionService()); $cm->setDiscriminatorMap(['descr' => 'DoctrineGlobalArticle', 'foo' => 'DoctrineGlobalUser']); - $this->assertEquals('DoctrineGlobalArticle', $cm->discriminatorMap['descr']); - $this->assertEquals('DoctrineGlobalUser', $cm->discriminatorMap['foo']); + self::assertEquals('DoctrineGlobalArticle', $cm->discriminatorMap['descr']); + self::assertEquals('DoctrineGlobalUser', $cm->discriminatorMap['foo']); } /** @@ -264,7 +264,7 @@ public function testSetSubClassesInGlobalNamespace(): void $cm->initializeReflection(new RuntimeReflectionService()); $cm->setSubclasses(['DoctrineGlobalArticle']); - $this->assertEquals('DoctrineGlobalArticle', $cm->subClasses[0]); + self::assertEquals('DoctrineGlobalArticle', $cm->subClasses[0]); } /** @@ -380,7 +380,7 @@ public function testGetTemporaryTableNameSchema(): void $cm->setTableName('foo.bar'); - $this->assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName()); + self::assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName()); } public function testDefaultTableName(): void @@ -392,8 +392,8 @@ public function testDefaultTableName(): void $primaryTable = []; $cm->setPrimaryTable($primaryTable); - $this->assertEquals('CmsUser', $cm->getTableName()); - $this->assertEquals('CmsUser', $cm->table['name']); + self::assertEquals('CmsUser', $cm->getTableName()); + self::assertEquals('CmsUser', $cm->table['name']); $cm = new ClassMetadata(CMS\CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -409,7 +409,7 @@ public function testDefaultTableName(): void ], ] ); - $this->assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']); + self::assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']); } public function testDefaultJoinColumnName(): void @@ -426,7 +426,7 @@ public function testDefaultJoinColumnName(): void 'joinColumns' => [['referencedColumnName' => 'id']], ] ); - $this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); + self::assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); $cm = new ClassMetadata(CMS\CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -442,8 +442,8 @@ public function testDefaultJoinColumnName(): void ], ] ); - $this->assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']); + self::assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); } /** @@ -469,28 +469,28 @@ public function testUnderscoreNamingStrategyDefaults(): void ] ); - $this->assertEquals(['USER_ID' => 'ID'], $oneToOneMetadata->associationMappings['user']['sourceToTargetKeyColumns']); - $this->assertEquals(['USER_ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['joinColumnFieldNames']); - $this->assertEquals(['ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['targetToSourceKeyColumns']); + self::assertEquals(['USER_ID' => 'ID'], $oneToOneMetadata->associationMappings['user']['sourceToTargetKeyColumns']); + self::assertEquals(['USER_ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['joinColumnFieldNames']); + self::assertEquals(['ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['targetToSourceKeyColumns']); - $this->assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['name']); - $this->assertEquals('ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['name']); + self::assertEquals('ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']['joinTable']['name']); + self::assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']['joinTable']['name']); - $this->assertEquals(['CMS_ADDRESS_ID', 'CMS_USER_ID'], $manyToManyMetadata->associationMappings['user']['joinTableColumns']); - $this->assertEquals(['CMS_ADDRESS_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToSourceKeyColumns']); - $this->assertEquals(['CMS_USER_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToTargetKeyColumns']); + self::assertEquals(['CMS_ADDRESS_ID', 'CMS_USER_ID'], $manyToManyMetadata->associationMappings['user']['joinTableColumns']); + self::assertEquals(['CMS_ADDRESS_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToSourceKeyColumns']); + self::assertEquals(['CMS_USER_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToTargetKeyColumns']); - $this->assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['name']); + self::assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); $cm = new ClassMetadata('DoctrineGlobalArticle', $namingStrategy); $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CMS\CmsUser::class]); - $this->assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); + self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); } /** @@ -505,7 +505,7 @@ public function testSetMultipleIdentifierSetsComposite(): void $cm->mapField(['fieldName' => 'username']); $cm->setIdentifier(['name', 'username']); - $this->assertTrue($cm->isIdentifierComposite); + self::assertTrue($cm->isIdentifierComposite); } /** @@ -532,7 +532,7 @@ public function testJoinTableMappingDefaults(): void $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CMS\CmsUser::class]); - $this->assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']['joinTable']['name']); + self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']['joinTable']['name']); } /** @@ -552,8 +552,8 @@ public function testMapIdentifierAssociation(): void ] ); - $this->assertTrue($cm->containsForeignIdentifier, "Identifier Association should set 'containsForeignIdentifier' boolean flag."); - $this->assertEquals(['article'], $cm->identifier); + self::assertTrue($cm->containsForeignIdentifier, "Identifier Association should set 'containsForeignIdentifier' boolean flag."); + self::assertEquals(['article'], $cm->identifier); } /** @@ -640,7 +640,7 @@ public function testRetrievalOfNamedQueries(): void $cm = new ClassMetadata(CMS\CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertEquals(0, count($cm->getNamedQueries())); + self::assertEquals(0, count($cm->getNamedQueries())); $cm->addNamedQuery( [ @@ -649,7 +649,7 @@ public function testRetrievalOfNamedQueries(): void ] ); - $this->assertEquals(1, count($cm->getNamedQueries())); + self::assertEquals(1, count($cm->getNamedQueries())); } /** @@ -660,7 +660,7 @@ public function testRetrievalOfResultSetMappings(): void $cm = new ClassMetadata(CMS\CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertEquals(0, count($cm->getSqlResultSetMappings())); + self::assertEquals(0, count($cm->getSqlResultSetMappings())); $cm->addSqlResultSetMapping( [ @@ -673,7 +673,7 @@ public function testRetrievalOfResultSetMappings(): void ] ); - $this->assertEquals(1, count($cm->getSqlResultSetMappings())); + self::assertEquals(1, count($cm->getSqlResultSetMappings())); } public function testExistanceOfNamedQuery(): void @@ -688,8 +688,8 @@ public function testExistanceOfNamedQuery(): void ] ); - $this->assertTrue($cm->hasNamedQuery('all')); - $this->assertFalse($cm->hasNamedQuery('userById')); + self::assertTrue($cm->hasNamedQuery('all')); + self::assertFalse($cm->hasNamedQuery('userById')); } /** @@ -719,14 +719,14 @@ public function testRetrieveOfNamedNativeQuery(): void ); $mapping = $cm->getNamedNativeQuery('find-all'); - $this->assertEquals('SELECT * FROM cms_users', $mapping['query']); - $this->assertEquals('result-mapping-name', $mapping['resultSetMapping']); - $this->assertEquals(CMS\CmsUser::class, $mapping['resultClass']); + self::assertEquals('SELECT * FROM cms_users', $mapping['query']); + self::assertEquals('result-mapping-name', $mapping['resultSetMapping']); + self::assertEquals(CMS\CmsUser::class, $mapping['resultClass']); $mapping = $cm->getNamedNativeQuery('find-by-id'); - $this->assertEquals('SELECT * FROM cms_users WHERE id = ?', $mapping['query']); - $this->assertEquals('result-mapping-name', $mapping['resultSetMapping']); - $this->assertEquals(CMS\CmsUser::class, $mapping['resultClass']); + self::assertEquals('SELECT * FROM cms_users WHERE id = ?', $mapping['query']); + self::assertEquals('result-mapping-name', $mapping['resultSetMapping']); + self::assertEquals(CMS\CmsUser::class, $mapping['resultClass']); } /** @@ -776,15 +776,15 @@ public function testRetrieveOfSqlResultSetMapping(): void $mapping = $cm->getSqlResultSetMapping('find-all'); - $this->assertEquals(CMS\CmsUser::class, $mapping['entities'][0]['entityClass']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - $this->assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); + self::assertEquals(CMS\CmsUser::class, $mapping['entities'][0]['entityClass']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); + self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - $this->assertEquals(CMS\CmsEmail::class, $mapping['entities'][1]['entityClass']); - $this->assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][1]['fields'][0]); - $this->assertEquals(['name' => 'email', 'column' => 'email'], $mapping['entities'][1]['fields'][1]); + self::assertEquals(CMS\CmsEmail::class, $mapping['entities'][1]['entityClass']); + self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][1]['fields'][0]); + self::assertEquals(['name' => 'email', 'column' => 'email'], $mapping['entities'][1]['fields'][1]); - $this->assertEquals('scalarColumn', $mapping['columns'][0]['name']); + self::assertEquals('scalarColumn', $mapping['columns'][0]['name']); } /** @@ -806,8 +806,8 @@ public function testExistanceOfSqlResultSetMapping(): void ] ); - $this->assertTrue($cm->hasSqlResultSetMapping('find-all')); - $this->assertFalse($cm->hasSqlResultSetMapping('find-by-id')); + self::assertTrue($cm->hasSqlResultSetMapping('find-all')); + self::assertFalse($cm->hasSqlResultSetMapping('find-by-id')); } /** @@ -827,8 +827,8 @@ public function testExistanceOfNamedNativeQuery(): void ] ); - $this->assertTrue($cm->hasNamedNativeQuery('find-all')); - $this->assertFalse($cm->hasNamedNativeQuery('find-by-id')); + self::assertTrue($cm->hasNamedNativeQuery('find-all')); + self::assertFalse($cm->hasNamedNativeQuery('find-by-id')); } public function testRetrieveOfNamedQuery(): void @@ -843,7 +843,7 @@ public function testRetrieveOfNamedQuery(): void ] ); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', $cm->getNamedQuery('userById')); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', $cm->getNamedQuery('userById')); } /** @@ -854,7 +854,7 @@ public function testRetrievalOfNamedNativeQueries(): void $cm = new ClassMetadata(CMS\CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertEquals(0, count($cm->getNamedNativeQueries())); + self::assertEquals(0, count($cm->getNamedNativeQueries())); $cm->addNamedNativeQuery( [ @@ -865,7 +865,7 @@ public function testRetrievalOfNamedNativeQueries(): void ] ); - $this->assertEquals(1, count($cm->getNamedNativeQueries())); + self::assertEquals(1, count($cm->getNamedNativeQueries())); } /** @@ -882,7 +882,7 @@ public function testSerializeEntityListeners(): void $serialize = serialize($metadata); $unserialize = unserialize($serialize); - $this->assertEquals($metadata->entityListeners, $unserialize->entityListeners); + self::assertEquals($metadata->entityListeners, $unserialize->entityListeners); } public function testNamingCollisionNamedQueryShouldThrowException(): void @@ -978,7 +978,7 @@ public function testClassCaseSensitivity(): void $cm = new ClassMetadata(strtoupper(CMS\CmsUser::class)); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertEquals(CMS\CmsUser::class, $cm->name); + self::assertEquals(CMS\CmsUser::class, $cm->name); } /** @@ -1103,9 +1103,9 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void ] ); - $this->assertEquals('routing_routingleg', $routingMetadata->table['name']); - $this->assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']['joinTable']['name']); - $this->assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']['joinTable']['name']); + self::assertEquals('routing_routingleg', $routingMetadata->table['name']); + self::assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']['joinTable']['name']); + self::assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']['joinTable']['name']); } /** @@ -1122,7 +1122,7 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategyProperty $metadata->mapField(['fieldName' => 'country']); $metadata->mapField(['fieldName' => 'city']); - $this->assertEquals($metadata->fieldNames, [ + self::assertEquals($metadata->fieldNames, [ 'cmsaddress_country' => 'country', 'cmsaddress_city' => 'city', ]); @@ -1221,7 +1221,7 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void ] ); - $this->assertEquals( + self::assertEquals( [ 'name' => 'customtypeparent_customtypeparent', 'joinColumns' => [['name' => 'customtypeparent_source', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], @@ -1229,9 +1229,9 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void ], $cm->associationMappings['friendsWithMe']['joinTable'] ); - $this->assertEquals(['customtypeparent_source', 'customtypeparent_target'], $cm->associationMappings['friendsWithMe']['joinTableColumns']); - $this->assertEquals(['customtypeparent_source' => 'id'], $cm->associationMappings['friendsWithMe']['relationToSourceKeyColumns']); - $this->assertEquals(['customtypeparent_target' => 'id'], $cm->associationMappings['friendsWithMe']['relationToTargetKeyColumns']); + self::assertEquals(['customtypeparent_source', 'customtypeparent_target'], $cm->associationMappings['friendsWithMe']['joinTableColumns']); + self::assertEquals(['customtypeparent_source' => 'id'], $cm->associationMappings['friendsWithMe']['relationToSourceKeyColumns']); + self::assertEquals(['customtypeparent_target' => 'id'], $cm->associationMappings['friendsWithMe']['relationToTargetKeyColumns']); } /** @@ -1270,7 +1270,7 @@ public function testIsIdentifierMappedSuperClass(): void { $class = new ClassMetadata(DDC2700MappedSuperClass::class); - $this->assertFalse($class->isIdentifier('foo')); + self::assertFalse($class->isIdentifier('foo')); } /** @@ -1280,7 +1280,7 @@ public function testCanInstantiateInternalPhpClassSubclass(): void { $classMetadata = new ClassMetadata(MyArrayObjectEntity::class); - $this->assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); + self::assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); } /** @@ -1293,7 +1293,7 @@ public function testCanInstantiateInternalPhpClassSubclassFromUnserializedMetada $classMetadata->wakeupReflection(new RuntimeReflectionService()); - $this->assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); + self::assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); } public function testWakeupReflectionWithEmbeddableAndStaticReflectionService(): void @@ -1319,7 +1319,7 @@ public function testWakeupReflectionWithEmbeddableAndStaticReflectionService(): $classMetadata->mapField($field); $classMetadata->wakeupReflection(new StaticReflectionService()); - $this->assertEquals(['test' => null, 'test.embeddedProperty' => null], $classMetadata->getReflectionProperties()); + self::assertEquals(['test' => null, 'test.embeddedProperty' => null], $classMetadata->getReflectionProperties()); } public function testGetColumnNamesWithGivenFieldNames(): void @@ -1349,7 +1349,7 @@ public function testInlineEmbeddable(): void ] ); - $this->assertTrue($classMetadata->hasField('test')); + self::assertTrue($classMetadata->hasField('test')); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php index 8d063c161ab..f42857f3cc6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php @@ -28,7 +28,7 @@ public function testGetJoinTableName(): void $platform = $this->getMockForAbstractClass(AbstractPlatform::class); assert($platform instanceof AbstractPlatform); - $this->assertSame( + self::assertSame( 'readers.author_reader', $strategy->getJoinTableName($metadata->associationMappings['readers'], $metadata, $platform) ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index 237f80dc9e7..135ac62a956 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -26,8 +26,8 @@ public function testResolve(): void $className = '\Doctrine\Tests\Models\Company\CompanyContractListener'; $object = $this->resolver->resolve($className); - $this->assertInstanceOf($className, $object); - $this->assertSame($object, $this->resolver->resolve($className)); + self::assertInstanceOf($className, $object); + self::assertSame($object, $this->resolver->resolve($className)); } public function testRegisterAndResolve(): void @@ -37,7 +37,7 @@ public function testRegisterAndResolve(): void $this->resolver->register($object); - $this->assertSame($object, $this->resolver->resolve($className)); + self::assertSame($object, $this->resolver->resolve($className)); } public function testClearOne(): void @@ -48,19 +48,19 @@ public function testClearOne(): void $obj1 = $this->resolver->resolve($className1); $obj2 = $this->resolver->resolve($className2); - $this->assertInstanceOf($className1, $obj1); - $this->assertInstanceOf($className2, $obj2); + self::assertInstanceOf($className1, $obj1); + self::assertInstanceOf($className2, $obj2); - $this->assertSame($obj1, $this->resolver->resolve($className1)); - $this->assertSame($obj2, $this->resolver->resolve($className2)); + self::assertSame($obj1, $this->resolver->resolve($className1)); + self::assertSame($obj2, $this->resolver->resolve($className2)); $this->resolver->clear($className1); - $this->assertInstanceOf($className1, $this->resolver->resolve($className1)); - $this->assertInstanceOf($className2, $this->resolver->resolve($className2)); + self::assertInstanceOf($className1, $this->resolver->resolve($className1)); + self::assertInstanceOf($className2, $this->resolver->resolve($className2)); - $this->assertNotSame($obj1, $this->resolver->resolve($className1)); - $this->assertSame($obj2, $this->resolver->resolve($className2)); + self::assertNotSame($obj1, $this->resolver->resolve($className1)); + self::assertSame($obj2, $this->resolver->resolve($className2)); } public function testClearAll(): void @@ -71,19 +71,19 @@ public function testClearAll(): void $obj1 = $this->resolver->resolve($className1); $obj2 = $this->resolver->resolve($className2); - $this->assertInstanceOf($className1, $obj1); - $this->assertInstanceOf($className2, $obj2); + self::assertInstanceOf($className1, $obj1); + self::assertInstanceOf($className2, $obj2); - $this->assertSame($obj1, $this->resolver->resolve($className1)); - $this->assertSame($obj2, $this->resolver->resolve($className2)); + self::assertSame($obj1, $this->resolver->resolve($className1)); + self::assertSame($obj2, $this->resolver->resolve($className2)); $this->resolver->clear(); - $this->assertInstanceOf($className1, $this->resolver->resolve($className1)); - $this->assertInstanceOf($className2, $this->resolver->resolve($className2)); + self::assertInstanceOf($className1, $this->resolver->resolve($className1)); + self::assertInstanceOf($className2, $this->resolver->resolve($className2)); - $this->assertNotSame($obj1, $this->resolver->resolve($className1)); - $this->assertNotSame($obj2, $this->resolver->resolve($className2)); + self::assertNotSame($obj1, $this->resolver->resolve($className1)); + self::assertNotSame($obj2, $this->resolver->resolve($className2)); } public function testRegisterStringException(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php index 88fd2c7624d..c73a287ed00 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php @@ -22,7 +22,7 @@ public function testCustomIdGeneratorCanBeSet(): void $fieldBuilder->build(); - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_CUSTOM, $cmBuilder->getClassMetadata()->generatorType); - $this->assertEquals(['class' => 'stdClass'], $cmBuilder->getClassMetadata()->customGeneratorDefinition); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_CUSTOM, $cmBuilder->getClassMetadata()->generatorType); + self::assertEquals(['class' => 'stdClass'], $cmBuilder->getClassMetadata()->customGeneratorDefinition); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php index 73ad972b334..bd0d5ab99d3 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php @@ -47,13 +47,13 @@ public function testConfiguration(): void $em = $this->getTestEntityManager(); $config = $em->getConfiguration(); - $this->assertInstanceOf(QuoteStrategy::class, $config->getQuoteStrategy()); - $this->assertInstanceOf(DefaultQuoteStrategy::class, $config->getQuoteStrategy()); + self::assertInstanceOf(QuoteStrategy::class, $config->getQuoteStrategy()); + self::assertInstanceOf(DefaultQuoteStrategy::class, $config->getQuoteStrategy()); $config->setQuoteStrategy(new MyQuoteStrategy()); - $this->assertInstanceOf(QuoteStrategy::class, $config->getQuoteStrategy()); - $this->assertInstanceOf(MyQuoteStrategy::class, $config->getQuoteStrategy()); + self::assertInstanceOf(QuoteStrategy::class, $config->getQuoteStrategy()); + self::assertInstanceOf(MyQuoteStrategy::class, $config->getQuoteStrategy()); } public function testGetColumnName(): void @@ -62,20 +62,20 @@ public function testGetColumnName(): void $cm->mapField(['fieldName' => 'name', 'columnName' => '`name`']); $cm->mapField(['fieldName' => 'id', 'columnName' => 'id']); - $this->assertEquals('id', $this->strategy->getColumnName('id', $cm, $this->platform)); - $this->assertEquals('"name"', $this->strategy->getColumnName('name', $cm, $this->platform)); + self::assertEquals('id', $this->strategy->getColumnName('id', $cm, $this->platform)); + self::assertEquals('"name"', $this->strategy->getColumnName('name', $cm, $this->platform)); } public function testGetTableName(): void { $cm = $this->createClassMetadata(CmsUser::class); $cm->setPrimaryTable(['name' => '`cms_user`']); - $this->assertEquals('"cms_user"', $this->strategy->getTableName($cm, $this->platform)); + self::assertEquals('"cms_user"', $this->strategy->getTableName($cm, $this->platform)); $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->setPrimaryTable(['name' => 'cms_user']); - $this->assertEquals('cms_user', $this->strategy->getTableName($cm, $this->platform)); + self::assertEquals('cms_user', $this->strategy->getTableName($cm, $this->platform)); } public function testJoinTableName(): void @@ -101,8 +101,8 @@ public function testJoinTableName(): void ] ); - $this->assertEquals('"cmsaddress_cmsuser"', $this->strategy->getJoinTableName($cm1->associationMappings['user'], $cm1, $this->platform)); - $this->assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($cm2->associationMappings['user'], $cm2, $this->platform)); + self::assertEquals('"cmsaddress_cmsuser"', $this->strategy->getJoinTableName($cm1->associationMappings['user'], $cm1, $this->platform)); + self::assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($cm2->associationMappings['user'], $cm2, $this->platform)); } public function testIdentifierColumnNames(): void @@ -126,17 +126,17 @@ public function testIdentifierColumnNames(): void ] ); - $this->assertEquals(['"id"'], $this->strategy->getIdentifierColumnNames($cm1, $this->platform)); - $this->assertEquals(['id'], $this->strategy->getIdentifierColumnNames($cm2, $this->platform)); + self::assertEquals(['"id"'], $this->strategy->getIdentifierColumnNames($cm1, $this->platform)); + self::assertEquals(['id'], $this->strategy->getIdentifierColumnNames($cm2, $this->platform)); } public function testColumnAlias(): void { $i = 0; - $this->assertEquals('columnName_0', $this->strategy->getColumnAlias('columnName', $i++, $this->platform)); - $this->assertEquals('column_name_1', $this->strategy->getColumnAlias('column_name', $i++, $this->platform)); - $this->assertEquals('COLUMN_NAME_2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++, $this->platform)); - $this->assertEquals('COLUMNNAME_3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++, $this->platform)); + self::assertEquals('columnName_0', $this->strategy->getColumnAlias('columnName', $i++, $this->platform)); + self::assertEquals('column_name_1', $this->strategy->getColumnAlias('column_name', $i++, $this->platform)); + self::assertEquals('COLUMN_NAME_2', $this->strategy->getColumnAlias('COLUMN_NAME', $i++, $this->platform)); + self::assertEquals('COLUMNNAME_3', $this->strategy->getColumnAlias('COLUMN-NAME-', $i++, $this->platform)); } public function testQuoteIdentifierJoinColumns(): void @@ -154,7 +154,7 @@ public function testQuoteIdentifierJoinColumns(): void ] ); - $this->assertEquals(['"article"'], $this->strategy->getIdentifierColumnNames($cm, $this->platform)); + self::assertEquals(['"article"'], $this->strategy->getIdentifierColumnNames($cm, $this->platform)); } public function testJoinColumnName(): void @@ -173,7 +173,7 @@ public function testJoinColumnName(): void ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('"article"', $this->strategy->getJoinColumnName($joinColumn, $cm, $this->platform)); + self::assertEquals('"article"', $this->strategy->getJoinColumnName($joinColumn, $cm, $this->platform)); } public function testReferencedJoinColumnName(): void @@ -192,7 +192,7 @@ public function testReferencedJoinColumnName(): void ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; - $this->assertEquals('"id"', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); + self::assertEquals('"id"', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php b/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php index 387c2ea32d0..d608b939efc 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php @@ -27,10 +27,10 @@ public function testRetrievesProperties(): void $properties = (new ReflectionPropertiesGetter(new RuntimeReflectionService())) ->getProperties(ClassWithMixedProperties::class); - $this->assertCount(5, $properties); + self::assertCount(5, $properties); foreach ($properties as $property) { - $this->assertInstanceOf('ReflectionProperty', $property); + self::assertInstanceOf('ReflectionProperty', $property); } } @@ -40,7 +40,7 @@ public function testRetrievedInstancesAreNotStatic(): void ->getProperties(ClassWithMixedProperties::class); foreach ($properties as $property) { - $this->assertFalse($property->isStatic()); + self::assertFalse($property->isStatic()); } } @@ -49,23 +49,23 @@ public function testExpectedKeys(): void $properties = (new ReflectionPropertiesGetter(new RuntimeReflectionService())) ->getProperties(ClassWithMixedProperties::class); - $this->assertArrayHasKey( + self::assertArrayHasKey( "\0" . ClassWithMixedProperties::class . "\0" . 'privateProperty', $properties ); - $this->assertArrayHasKey( + self::assertArrayHasKey( "\0" . ClassWithMixedProperties::class . "\0" . 'privatePropertyOverride', $properties ); - $this->assertArrayHasKey( + self::assertArrayHasKey( "\0" . ParentClass::class . "\0" . 'privatePropertyOverride', $properties ); - $this->assertArrayHasKey( + self::assertArrayHasKey( "\0*\0protectedProperty", $properties ); - $this->assertArrayHasKey( + self::assertArrayHasKey( 'publicProperty', $properties ); @@ -78,7 +78,7 @@ public function testPropertiesAreAccessible(): void ->getProperties(ClassWithMixedProperties::class); foreach ($properties as $property) { - $this->assertSame($property->getName(), $property->getValue($object)); + self::assertSame($property->getName(), $property->getValue($object)); } } @@ -86,7 +86,7 @@ public function testPropertyGetterIsIdempotent(): void { $getter = (new ReflectionPropertiesGetter(new RuntimeReflectionService())); - $this->assertSame( + self::assertSame( $getter->getProperties(ClassWithMixedProperties::class), $getter->getProperties(ClassWithMixedProperties::class) ); @@ -98,21 +98,21 @@ public function testPropertyGetterWillSkipPropertiesNotRetrievedByTheRuntimeRefl assert($reflectionService instanceof ReflectionService || $reflectionService instanceof MockObject); $reflectionService - ->expects($this->exactly(2)) + ->expects(self::exactly(2)) ->method('getClass') - ->with($this->logicalOr(ClassWithMixedProperties::class, ParentClass::class)) - ->will($this->returnValueMap([ + ->with(self::logicalOr(ClassWithMixedProperties::class, ParentClass::class)) + ->will(self::returnValueMap([ [ClassWithMixedProperties::class, new ReflectionClass(ClassWithMixedProperties::class)], [ParentClass::class, new ReflectionClass(ParentClass::class)], ])); $reflectionService - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('getAccessibleProperty'); $getter = (new ReflectionPropertiesGetter($reflectionService)); - $this->assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); + self::assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); } public function testPropertyGetterWillSkipClassesNotRetrievedByTheRuntimeReflectionService(): void @@ -121,14 +121,14 @@ public function testPropertyGetterWillSkipClassesNotRetrievedByTheRuntimeReflect assert($reflectionService instanceof ReflectionService || $reflectionService instanceof MockObject); $reflectionService - ->expects($this->once()) + ->expects(self::once()) ->method('getClass') ->with(ClassWithMixedProperties::class); - $reflectionService->expects($this->never())->method('getAccessibleProperty'); + $reflectionService->expects(self::never())->method('getAccessibleProperty'); $getter = (new ReflectionPropertiesGetter($reflectionService)); - $this->assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); + self::assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php index a5037ce901c..07ffb89463c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php @@ -40,11 +40,11 @@ public function testCanSetAndGetEmbeddedProperty( $embeddedPropertyReflection->setValue($object, 'newValue'); - $this->assertSame('newValue', $embeddedPropertyReflection->getValue($object)); + self::assertSame('newValue', $embeddedPropertyReflection->getValue($object)); $embeddedPropertyReflection->setValue($object, 'changedValue'); - $this->assertSame('changedValue', $embeddedPropertyReflection->getValue($object)); + self::assertSame('changedValue', $embeddedPropertyReflection->getValue($object)); } /** @@ -63,7 +63,7 @@ public function testWillSkipReadingPropertiesFromNullEmbeddable( $instantiator = new Instantiator(); - $this->assertNull($embeddedPropertyReflection->getValue( + self::assertNull($embeddedPropertyReflection->getValue( $instantiator->instantiate($parentProperty->getDeclaringClass()->getName()) )); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php index ffb752908b3..7b2660b2fb0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php @@ -34,7 +34,7 @@ public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses(): */ public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): void { - $this->markTestIncomplete(); + self::markTestIncomplete(); } /** @@ -43,7 +43,7 @@ public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): */ public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotationProperty(): void { - $this->markTestIncomplete(); + self::markTestIncomplete(); } public function testEntityIncorrectIndexes(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php index 8dccd62a5d4..cfc5ab1a913 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php @@ -31,7 +31,7 @@ public function testFindMappingFile(): void ); touch($filename = $this->dir . '/Foo' . $this->getFileExtension()); - $this->assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo')); + self::assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo')); } public function testFindMappingFileInSubnamespace(): void @@ -43,7 +43,7 @@ public function testFindMappingFileInSubnamespace(): void ); touch($filename = $this->dir . '/Foo.Bar' . $this->getFileExtension()); - $this->assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo\Bar')); + self::assertEquals($filename, $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo\Bar')); } public function testFindMappingFileNamespacedFoundFileNotFound(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index b6b2954a4e5..8ef6c2eacee 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -55,8 +55,8 @@ public function testClassTableInheritanceDiscriminatorMap(): void 'baz' => CTIBaz::class, ]; - $this->assertEquals(3, count($class->discriminatorMap)); - $this->assertEquals($expectedMap, $class->discriminatorMap); + self::assertEquals(3, count($class->discriminatorMap)); + self::assertEquals($expectedMap, $class->discriminatorMap); } public function testFailingSecondLevelCacheAssociation(): void @@ -80,18 +80,18 @@ public function testIdentifierWithAssociationKey(): void $class = $factory->getMetadataFor(DDC117Translation::class); - $this->assertEquals(['language', 'article'], $class->identifier); - $this->assertArrayHasKey('article', $class->associationMappings); + self::assertEquals(['language', 'article'], $class->identifier); + self::assertArrayHasKey('article', $class->associationMappings); - $this->assertArrayHasKey('id', $class->associationMappings['article']); - $this->assertTrue($class->associationMappings['article']['id']); + self::assertArrayHasKey('id', $class->associationMappings['article']); + self::assertTrue($class->associationMappings['article']['id']); } public function testEmbeddableMapping(): void { $class = $this->createClassMetadata(Name::class); - $this->assertEquals(true, $class->isEmbeddedClass); + self::assertEquals(true, $class->isEmbeddedClass); } /** @@ -107,7 +107,7 @@ public function testEmbeddedMappingsWithUseColumnPrefix(): void $em->getConfiguration()->setMetadataDriverImpl($this->loadDriver()); $factory->setEntityManager($em); - $this->assertEquals( + self::assertEquals( '__prefix__', $factory->getMetadataFor(DDC3293UserPrefixed::class) ->embeddedClasses['address']['columnPrefix'] @@ -127,7 +127,7 @@ public function testEmbeddedMappingsWithFalseUseColumnPrefix(): void $em->getConfiguration()->setMetadataDriverImpl($this->loadDriver()); $factory->setEntityManager($em); - $this->assertFalse( + self::assertFalse( $factory->getMetadataFor(DDC3293User::class) ->embeddedClasses['address']['columnPrefix'] ); @@ -137,7 +137,7 @@ public function testEmbeddedMapping(): void { $class = $this->createClassMetadata(Person::class); - $this->assertEquals( + self::assertEquals( [ 'name' => [ 'class' => Name::class, @@ -171,7 +171,7 @@ public function testValidateXmlSchema(string $xmlMappingFile): void $dom->load($xmlMappingFile); - $this->assertTrue($dom->schemaValidate($xsdSchemaFile)); + self::assertTrue($dom->schemaValidate($xsdSchemaFile)); } /** @@ -203,7 +203,7 @@ public function testOneToManyDefaultOrderByAsc(): void $class->initializeReflection(new RuntimeReflectionService()); $driver->loadMetadataForClass(GH7141Article::class, $class); - $this->assertEquals( + self::assertEquals( Criteria::ASC, $class->getMetadataValue('associationMappings')['tags']['orderBy']['position'] ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php index 72d217f3627..fa0b54d7d81 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -22,7 +22,7 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest protected function loadDriver(): MappingDriver { if (! class_exists(Yaml::class, true)) { - $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + self::markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); } return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'); @@ -45,11 +45,11 @@ public function testJoinTablesWithMappedSuperclassForYamlDriver(): void $classPage = new ClassMetadata(File::class); $classPage = $factory->getMetadataFor(File::class); - $this->assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); + self::assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); $classDirectory = new ClassMetadata(Directory::class); $classDirectory = $factory->getMetadataFor(Directory::class); - $this->assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); + self::assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); } /** @@ -74,14 +74,14 @@ public function testSpacesShouldBeIgnoredWhenUseExplode(): void $nameField = $metadata->fieldMappings['name']; $valueField = $metadata->fieldMappings['value']; - $this->assertEquals('name', $unique[0]); - $this->assertEquals('value', $unique[1]); + self::assertEquals('name', $unique[0]); + self::assertEquals('value', $unique[1]); - $this->assertEquals('value', $indexes[0]); - $this->assertEquals('name', $indexes[1]); + self::assertEquals('value', $indexes[0]); + self::assertEquals('name', $indexes[1]); - $this->assertEquals(255, $nameField['length']); - $this->assertEquals(255, $valueField['length']); + self::assertEquals(255, $nameField['length']); + self::assertEquals(255, $valueField['length']); } } diff --git a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php index 31efa95a281..db1e4a1aa03 100644 --- a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php @@ -54,7 +54,7 @@ public function testFindEntityWithoutCache(): void $this->findEntity($em, __FUNCTION__); - $this->assertEquals(6002, $this->countQuery($em)); + self::assertEquals(6002, $this->countQuery($em)); } public function testFindEntityWithCache(): void @@ -65,7 +65,7 @@ public function testFindEntityWithCache(): void $this->findEntity($em, __FUNCTION__); - $this->assertEquals(502, $this->countQuery($em)); + self::assertEquals(502, $this->countQuery($em)); } public function testFindAllEntityWithoutCache(): void @@ -74,7 +74,7 @@ public function testFindAllEntityWithoutCache(): void $this->findAllEntity($em, __FUNCTION__); - $this->assertEquals(153, $this->countQuery($em)); + self::assertEquals(153, $this->countQuery($em)); } public function testFindAllEntityWithCache(): void @@ -85,7 +85,7 @@ public function testFindAllEntityWithCache(): void $this->findAllEntity($em, __FUNCTION__); - $this->assertEquals(53, $this->countQuery($em)); + self::assertEquals(53, $this->countQuery($em)); } public function testFindEntityOneToManyWithoutCache(): void @@ -94,7 +94,7 @@ public function testFindEntityOneToManyWithoutCache(): void $this->findEntityOneToMany($em, __FUNCTION__); - $this->assertEquals(502, $this->countQuery($em)); + self::assertEquals(502, $this->countQuery($em)); } public function testFindEntityOneToManyWithCache(): void @@ -105,7 +105,7 @@ public function testFindEntityOneToManyWithCache(): void $this->findEntityOneToMany($em, __FUNCTION__); - $this->assertEquals(472, $this->countQuery($em)); + self::assertEquals(472, $this->countQuery($em)); } public function testQueryEntityWithoutCache(): void @@ -114,7 +114,7 @@ public function testQueryEntityWithoutCache(): void $this->queryEntity($em, __FUNCTION__); - $this->assertEquals(602, $this->countQuery($em)); + self::assertEquals(602, $this->countQuery($em)); } public function testQueryEntityWithCache(): void @@ -125,7 +125,7 @@ public function testQueryEntityWithCache(): void $this->queryEntity($em, __FUNCTION__); - $this->assertEquals(503, $this->countQuery($em)); + self::assertEquals(503, $this->countQuery($em)); } private function queryEntity(EntityManagerInterface $em, string $label): void @@ -275,7 +275,7 @@ private function findAllEntity(EntityManagerInterface $em, string $label): void $list = $rep->findAll(); $em->clear(); - $this->assertCount($size, $list); + self::assertCount($size, $list); } printf("\n[%s] find %s countries (%s times)", number_format(microtime(true) - $startFind, 6), $size, $times); diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index 990419f9fb9..5daff2d7ee3 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -55,7 +55,7 @@ public function testCanBePutInLazyLoadingMode(): void $class = $this->_emMock->getClassMetadata(ECommerceProduct::class); $collection = new PersistentCollection($this->_emMock, $class, new ArrayCollection()); $collection->setInitialized(false); - $this->assertFalse($collection->isInitialized()); + self::assertFalse($collection->isInitialized()); } /** @@ -64,7 +64,7 @@ public function testCanBePutInLazyLoadingMode(): void public function testCurrentInitializesCollection(): void { $this->collection->current(); - $this->assertTrue($this->collection->isInitialized()); + self::assertTrue($this->collection->isInitialized()); } /** @@ -73,7 +73,7 @@ public function testCurrentInitializesCollection(): void public function testKeyInitializesCollection(): void { $this->collection->key(); - $this->assertTrue($this->collection->isInitialized()); + self::assertTrue($this->collection->isInitialized()); } /** @@ -82,7 +82,7 @@ public function testKeyInitializesCollection(): void public function testNextInitializesCollection(): void { $this->collection->next(); - $this->assertTrue($this->collection->isInitialized()); + self::assertTrue($this->collection->isInitialized()); } /** @@ -90,11 +90,11 @@ public function testNextInitializesCollection(): void */ public function testNonObjects(): void { - $this->assertEmpty($this->collection); + self::assertEmpty($this->collection); $this->collection->add('dummy'); - $this->assertNotEmpty($this->collection); + self::assertNotEmpty($this->collection); $product = new ECommerceProduct(); @@ -102,9 +102,9 @@ public function testNonObjects(): void $this->collection->set(2, 'dummy'); $this->collection->set(3, null); - $this->assertSame($product, $this->collection->get(1)); - $this->assertSame('dummy', $this->collection->get(2)); - $this->assertSame(null, $this->collection->get(3)); + self::assertSame($product, $this->collection->get(1)); + self::assertSame('dummy', $this->collection->get(2)); + self::assertSame(null, $this->collection->get(3)); } /** @@ -115,10 +115,10 @@ public function testRemovingElementsAlsoRemovesKeys(): void $dummy = new stdClass(); $this->collection->add($dummy); - $this->assertEquals([0], array_keys($this->collection->toArray())); + self::assertEquals([0], array_keys($this->collection->toArray())); $this->collection->removeElement($dummy); - $this->assertEquals([], array_keys($this->collection->toArray())); + self::assertEquals([], array_keys($this->collection->toArray())); } /** @@ -128,7 +128,7 @@ public function testClearWillAlsoClearKeys(): void { $this->collection->add(new stdClass()); $this->collection->clear(); - $this->assertEquals([], array_keys($this->collection->toArray())); + self::assertEquals([], array_keys($this->collection->toArray())); } /** @@ -142,7 +142,7 @@ public function testClearWillAlsoResetKeyPositions(): void $this->collection->removeElement($dummy); $this->collection->clear(); $this->collection->add($dummy); - $this->assertEquals([0], array_keys($this->collection->toArray())); + self::assertEquals([0], array_keys($this->collection->toArray())); } /** diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php index 576a1abcfed..805d7483913 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php @@ -40,8 +40,8 @@ public function testExpandParametersWillExpandCompositeEntityKeys(): void [$values, $types] = $this->persister->expandParameters(['admin1' => $admin1]); - $this->assertEquals(['integer', 'string'], $types); - $this->assertEquals([10, 'IT'], $values); + self::assertEquals(['integer', 'string'], $types); + self::assertEquals([10, 'IT'], $values); } public function testExpandCriteriaParametersWillExpandCompositeEntityKeys(): void @@ -54,7 +54,7 @@ public function testExpandCriteriaParametersWillExpandCompositeEntityKeys(): voi [$values, $types] = $this->persister->expandCriteriaParameters($criteria); - $this->assertEquals(['integer', 'string'], $types); - $this->assertEquals([10, 'IT'], $values); + self::assertEquals(['integer', 'string'], $types); + self::assertEquals([10, 'IT'], $values); } } diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php index 9183d9f3916..e0a6b20be2b 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php @@ -32,19 +32,19 @@ protected function setUp(): void public function testSelectConditionStatementEq(): void { $statement = $this->persister->getSelectConditionStatementSQL('admin1', 1, [], Comparison::EQ); - $this->assertEquals('t0.admin1 = ? AND t0.country = ?', $statement); + self::assertEquals('t0.admin1 = ? AND t0.country = ?', $statement); } public function testSelectConditionStatementEqNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::IS); - $this->assertEquals('t0.admin1 IS NULL AND t0.country IS NULL', $statement); + self::assertEquals('t0.admin1 IS NULL AND t0.country IS NULL', $statement); } public function testSelectConditionStatementNeqNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::NEQ); - $this->assertEquals('t0.admin1 IS NOT NULL AND t0.country IS NOT NULL', $statement); + self::assertEquals('t0.admin1 IS NOT NULL AND t0.country IS NOT NULL', $statement); } public function testSelectConditionStatementIn(): void diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index bf5284f1964..647ed645172 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -53,7 +53,7 @@ public function testGetInsertSQLUsesTypeValuesSQL(): void $sql = $method->invoke($this->persister); - $this->assertEquals('INSERT INTO customtype_parents (customInteger, child_id) VALUES (ABS(?), ?)', $sql); + self::assertEquals('INSERT INTO customtype_parents (customInteger, child_id) VALUES (ABS(?), ?)', $sql); } public function testUpdateUsesTypeValuesSQL(): void @@ -74,7 +74,7 @@ public function testUpdateUsesTypeValuesSQL(): void $executeStatements = $this->entityManager->getConnection()->getExecuteStatements(); - $this->assertEquals('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?', $executeStatements[0]['sql']); + self::assertEquals('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?', $executeStatements[0]['sql']); } public function testGetSelectConditionSQLUsesTypeValuesSQL(): void @@ -84,7 +84,7 @@ public function testGetSelectConditionSQLUsesTypeValuesSQL(): void $sql = $method->invoke($this->persister, ['customInteger' => 1, 'child' => 1]); - $this->assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); + self::assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); } /** @@ -96,7 +96,7 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi $method = new ReflectionMethod($persister, 'getSelectColumnsSQL'); $method->setAccessible(true); - $this->assertEquals('t0."simple-entity-id" AS simpleentityid_1, t0."simple-entity-value" AS simpleentityvalue_2', $method->invoke($persister)); + self::assertEquals('t0."simple-entity-id" AS simpleentityid_1, t0."simple-entity-value" AS simpleentityvalue_2', $method->invoke($persister)); } /** @@ -105,19 +105,19 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi public function testSelectConditionStatementIsNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::IS); - $this->assertEquals('test IS NULL', $statement); + self::assertEquals('test IS NULL', $statement); } public function testSelectConditionStatementEqNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::EQ); - $this->assertEquals('test IS NULL', $statement); + self::assertEquals('test IS NULL', $statement); } public function testSelectConditionStatementNeqNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::NEQ); - $this->assertEquals('test IS NOT NULL', $statement); + self::assertEquals('test IS NOT NULL', $statement); } /** @@ -125,17 +125,17 @@ public function testSelectConditionStatementNeqNull(): void */ public function testSelectConditionStatementWithMultipleValuesContainingNull(): void { - $this->assertEquals( + self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', $this->persister->getSelectConditionStatementSQL('id', [null]) ); - $this->assertEquals( + self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', $this->persister->getSelectConditionStatementSQL('id', [null, 123]) ); - $this->assertEquals( + self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', $this->persister->getSelectConditionStatementSQL('id', [123, null]) ); @@ -147,17 +147,17 @@ public function testCountCondition(): void // Using a criteria as array $statement = $persister->getCountSQL(['value' => 'bar']); - $this->assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); + self::assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); // Using a criteria object $criteria = new Criteria(Criteria::expr()->eq('value', 'bar')); $statement = $persister->getCountSQL($criteria); - $this->assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); + self::assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); } public function testCountEntities(): void { - $this->assertEquals(0, $this->persister->count()); + self::assertEquals(0, $this->persister->count()); } public function testDeleteManyToManyUsesTypeValuesSQL(): void diff --git a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php index 81873272e1b..31411d306bf 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php @@ -35,6 +35,6 @@ protected function setUp(): void */ public function testExecuteInsertsWillReturnEmptySetWithNoQueuedInserts(): void { - $this->assertSame([], $this->persister->executeInserts()); + self::assertSame([], $this->persister->executeInserts()); } } diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index a1024fab0e6..309eb927fca 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -63,10 +63,10 @@ public function testReferenceProxyDelegatesLoadingToThePersister(): void $proxy = $this->proxyFactory->getProxy(ECommerceFeature::class, $identifier); $persister - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('load') - ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) - ->will($this->returnValue(new stdClass())); + ->with(self::equalTo($identifier), self::isInstanceOf($proxyClass)) + ->will(self::returnValue(new stdClass())); $proxy->getDescription(); } @@ -105,11 +105,11 @@ public function testSkipAbstractClassesOnGeneration(): void { $cm = new ClassMetadata(AbstractClass::class); $cm->initializeReflection(new RuntimeReflectionService()); - $this->assertNotNull($cm->reflClass); + self::assertNotNull($cm->reflClass); $num = $this->proxyFactory->generateProxyClasses([$cm]); - $this->assertEquals(0, $num, 'No proxies generated.'); + self::assertEquals(0, $num, 'No proxies generated.'); } /** @@ -124,19 +124,19 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void assert($proxy instanceof Proxy); $persister - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('load') - ->will($this->returnValue(null)); + ->will(self::returnValue(null)); try { $proxy->getDescription(); - $this->fail('An exception was expected to be raised'); + self::fail('An exception was expected to be raised'); } catch (EntityNotFoundException $exception) { } - $this->assertFalse($proxy->__isInitialized()); - $this->assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); - $this->assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); + self::assertFalse($proxy->__isInitialized()); + self::assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); + self::assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); } /** @@ -151,19 +151,19 @@ public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void assert($proxy instanceof Proxy); $persister - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('load') - ->will($this->returnValue(null)); + ->will(self::returnValue(null)); try { $cloned = clone $proxy; - $this->fail('An exception was expected to be raised'); + self::fail('An exception was expected to be raised'); } catch (EntityNotFoundException $exception) { } - $this->assertFalse($proxy->__isInitialized()); - $this->assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); - $this->assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); + self::assertFalse($proxy->__isInitialized()); + self::assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); + self::assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); } public function testProxyClonesParentFields(): void diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php index f4dd6a12e29..8816970874e 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php @@ -33,10 +33,10 @@ public function assertSqlGeneration(string $dqlToBeTested, string $sqlToBeConfir $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CustomTreeWalkerJoin::class]) ->useQueryCache(false); - $this->assertEquals($sqlToBeConfirmed, $query->getSql()); + self::assertEquals($sqlToBeConfirmed, $query->getSql()); $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); + self::fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index 95332788e6b..fb1028a727d 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -60,9 +60,9 @@ public function assertSqlGeneration( ?string $outputWalker = null ): void { try { - $this->assertEquals($sqlToBeConfirmed, $this->generateSql($dqlToBeTested, $treeWalkers, $outputWalker)); + self::assertEquals($sqlToBeConfirmed, $this->generateSql($dqlToBeTested, $treeWalkers, $outputWalker)); } catch (Exception $e) { - $this->fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); + self::fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php index d2b76a63717..002b64c4521 100644 --- a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php @@ -34,7 +34,7 @@ public function assertSqlGeneration(string $dqlToBeTested, string $sqlToBeConfir parent::assertEquals($sqlToBeConfirmed, $query->getSql()); $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage()); + self::fail($e->getMessage()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index e2614aa3f48..4cd6c43e2bc 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -32,32 +32,32 @@ protected function setUp(): void public function testAvgExpr(): void { - $this->assertEquals('AVG(u.id)', (string) $this->expr->avg('u.id')); + self::assertEquals('AVG(u.id)', (string) $this->expr->avg('u.id')); } public function testMaxExpr(): void { - $this->assertEquals('MAX(u.id)', (string) $this->expr->max('u.id')); + self::assertEquals('MAX(u.id)', (string) $this->expr->max('u.id')); } public function testMinExpr(): void { - $this->assertEquals('MIN(u.id)', (string) $this->expr->min('u.id')); + self::assertEquals('MIN(u.id)', (string) $this->expr->min('u.id')); } public function testCountExpr(): void { - $this->assertEquals('MAX(u.id)', (string) $this->expr->max('u.id')); + self::assertEquals('MAX(u.id)', (string) $this->expr->max('u.id')); } public function testCountDistinctExpr(): void { - $this->assertEquals('COUNT(DISTINCT u.id)', (string) $this->expr->countDistinct('u.id')); + self::assertEquals('COUNT(DISTINCT u.id)', (string) $this->expr->countDistinct('u.id')); } public function testCountDistinctExprMulti(): void { - $this->assertEquals('COUNT(DISTINCT u.id, u.name)', (string) $this->expr->countDistinct('u.id', 'u.name')); + self::assertEquals('COUNT(DISTINCT u.id, u.name)', (string) $this->expr->countDistinct('u.id', 'u.name')); } public function testExistsExpr(): void @@ -65,7 +65,7 @@ public function testExistsExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->exists($qb)); + self::assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->exists($qb)); } public function testAllExpr(): void @@ -73,7 +73,7 @@ public function testAllExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->all($qb)); + self::assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->all($qb)); } public function testSomeExpr(): void @@ -81,7 +81,7 @@ public function testSomeExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->some($qb)); + self::assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->some($qb)); } public function testAnyExpr(): void @@ -89,7 +89,7 @@ public function testAnyExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->any($qb)); + self::assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->any($qb)); } public function testNotExpr(): void @@ -97,17 +97,17 @@ public function testNotExpr(): void $qb = $this->entityManager->createQueryBuilder(); $qb->select('u')->from('User', 'u')->where('u.name = ?1'); - $this->assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->not($qb)); + self::assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->expr->not($qb)); } public function testAndExpr(): void { - $this->assertEquals('1 = 1 AND 2 = 2', (string) $this->expr->andX((string) $this->expr->eq(1, 1), (string) $this->expr->eq(2, 2))); + self::assertEquals('1 = 1 AND 2 = 2', (string) $this->expr->andX((string) $this->expr->eq(1, 1), (string) $this->expr->eq(2, 2))); } public function testIntelligentParenthesisPreventionAndExpr(): void { - $this->assertEquals( + self::assertEquals( '1 = 1 AND 2 = 2', (string) $this->expr->andX($this->expr->orX($this->expr->andX($this->expr->eq(1, 1))), (string) $this->expr->eq(2, 2)) ); @@ -115,69 +115,69 @@ public function testIntelligentParenthesisPreventionAndExpr(): void public function testOrExpr(): void { - $this->assertEquals('1 = 1 OR 2 = 2', (string) $this->expr->orX((string) $this->expr->eq(1, 1), (string) $this->expr->eq(2, 2))); + self::assertEquals('1 = 1 OR 2 = 2', (string) $this->expr->orX((string) $this->expr->eq(1, 1), (string) $this->expr->eq(2, 2))); } public function testAbsExpr(): void { - $this->assertEquals('ABS(1)', (string) $this->expr->abs(1)); + self::assertEquals('ABS(1)', (string) $this->expr->abs(1)); } public function testProdExpr(): void { - $this->assertEquals('1 * 2', (string) $this->expr->prod(1, 2)); + self::assertEquals('1 * 2', (string) $this->expr->prod(1, 2)); } public function testDiffExpr(): void { - $this->assertEquals('1 - 2', (string) $this->expr->diff(1, 2)); + self::assertEquals('1 - 2', (string) $this->expr->diff(1, 2)); } public function testSumExpr(): void { - $this->assertEquals('1 + 2', (string) $this->expr->sum(1, 2)); + self::assertEquals('1 + 2', (string) $this->expr->sum(1, 2)); } public function testQuotientExpr(): void { - $this->assertEquals('10 / 2', (string) $this->expr->quot(10, 2)); + self::assertEquals('10 / 2', (string) $this->expr->quot(10, 2)); } public function testScopeInArithmeticExpr(): void { - $this->assertEquals('(100 - 20) / 2', (string) $this->expr->quot($this->expr->diff(100, 20), 2)); - $this->assertEquals('100 - (20 / 2)', (string) $this->expr->diff(100, $this->expr->quot(20, 2))); + self::assertEquals('(100 - 20) / 2', (string) $this->expr->quot($this->expr->diff(100, 20), 2)); + self::assertEquals('100 - (20 / 2)', (string) $this->expr->diff(100, $this->expr->quot(20, 2))); } public function testSquareRootExpr(): void { - $this->assertEquals('SQRT(1)', (string) $this->expr->sqrt(1)); + self::assertEquals('SQRT(1)', (string) $this->expr->sqrt(1)); } public function testEqualExpr(): void { - $this->assertEquals('1 = 1', (string) $this->expr->eq(1, 1)); + self::assertEquals('1 = 1', (string) $this->expr->eq(1, 1)); } public function testLikeExpr(): void { - $this->assertEquals('a.description LIKE :description', (string) $this->expr->like('a.description', ':description')); + self::assertEquals('a.description LIKE :description', (string) $this->expr->like('a.description', ':description')); } public function testNotLikeExpr(): void { - $this->assertEquals('a.description NOT LIKE :description', (string) $this->expr->notLike('a.description', ':description')); + self::assertEquals('a.description NOT LIKE :description', (string) $this->expr->notLike('a.description', ':description')); } public function testConcatExpr(): void { - $this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->expr->concat('u.first_name', 'u.last_name')); - $this->assertEquals('CONCAT(u.first_name, u.middle_name, u.last_name)', (string) $this->expr->concat('u.first_name', 'u.middle_name', 'u.last_name')); + self::assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->expr->concat('u.first_name', 'u.last_name')); + self::assertEquals('CONCAT(u.first_name, u.middle_name, u.last_name)', (string) $this->expr->concat('u.first_name', 'u.middle_name', 'u.last_name')); } public function testSubstringExpr(): void { - $this->assertEquals('SUBSTRING(a.title, 0, 25)', (string) $this->expr->substring('a.title', 0, 25)); + self::assertEquals('SUBSTRING(a.title, 0, 25)', (string) $this->expr->substring('a.title', 0, 25)); } public function testModExpr(): void @@ -191,42 +191,42 @@ public function testModExpr(): void */ public function testSubstringExprAcceptsTwoArguments(): void { - $this->assertEquals('SUBSTRING(a.title, 5)', (string) $this->expr->substring('a.title', 5)); + self::assertEquals('SUBSTRING(a.title, 5)', (string) $this->expr->substring('a.title', 5)); } public function testLowerExpr(): void { - $this->assertEquals('LOWER(u.first_name)', (string) $this->expr->lower('u.first_name')); + self::assertEquals('LOWER(u.first_name)', (string) $this->expr->lower('u.first_name')); } public function testUpperExpr(): void { - $this->assertEquals('UPPER(u.first_name)', (string) $this->expr->upper('u.first_name')); + self::assertEquals('UPPER(u.first_name)', (string) $this->expr->upper('u.first_name')); } public function testLengthExpr(): void { - $this->assertEquals('LENGTH(u.first_name)', (string) $this->expr->length('u.first_name')); + self::assertEquals('LENGTH(u.first_name)', (string) $this->expr->length('u.first_name')); } public function testGreaterThanExpr(): void { - $this->assertEquals('5 > 2', (string) $this->expr->gt(5, 2)); + self::assertEquals('5 > 2', (string) $this->expr->gt(5, 2)); } public function testLessThanExpr(): void { - $this->assertEquals('2 < 5', (string) $this->expr->lt(2, 5)); + self::assertEquals('2 < 5', (string) $this->expr->lt(2, 5)); } public function testStringLiteralExpr(): void { - $this->assertEquals("'word'", (string) $this->expr->literal('word')); + self::assertEquals("'word'", (string) $this->expr->literal('word')); } public function testNumericLiteralExpr(): void { - $this->assertEquals(5, (string) $this->expr->literal(5)); + self::assertEquals(5, (string) $this->expr->literal(5)); } /** @@ -235,47 +235,47 @@ public function testNumericLiteralExpr(): void */ public function testLiteralExprProperlyQuotesStrings(): void { - $this->assertEquals("'00010001'", (string) $this->expr->literal('00010001')); + self::assertEquals("'00010001'", (string) $this->expr->literal('00010001')); } public function testGreaterThanOrEqualToExpr(): void { - $this->assertEquals('5 >= 2', (string) $this->expr->gte(5, 2)); + self::assertEquals('5 >= 2', (string) $this->expr->gte(5, 2)); } public function testLessThanOrEqualTo(): void { - $this->assertEquals('2 <= 5', (string) $this->expr->lte(2, 5)); + self::assertEquals('2 <= 5', (string) $this->expr->lte(2, 5)); } public function testBetweenExpr(): void { - $this->assertEquals('u.id BETWEEN 3 AND 6', (string) $this->expr->between('u.id', 3, 6)); + self::assertEquals('u.id BETWEEN 3 AND 6', (string) $this->expr->between('u.id', 3, 6)); } public function testTrimExpr(): void { - $this->assertEquals('TRIM(u.id)', (string) $this->expr->trim('u.id')); + self::assertEquals('TRIM(u.id)', (string) $this->expr->trim('u.id')); } public function testIsNullExpr(): void { - $this->assertEquals('u.id IS NULL', (string) $this->expr->isNull('u.id')); + self::assertEquals('u.id IS NULL', (string) $this->expr->isNull('u.id')); } public function testIsNotNullExpr(): void { - $this->assertEquals('u.id IS NOT NULL', (string) $this->expr->isNotNull('u.id')); + self::assertEquals('u.id IS NOT NULL', (string) $this->expr->isNotNull('u.id')); } public function testIsInstanceOfExpr(): void { - $this->assertEquals('u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee', (string) $this->expr->isInstanceOf('u', CompanyEmployee::class)); + self::assertEquals('u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee', (string) $this->expr->isInstanceOf('u', CompanyEmployee::class)); } public function testIsMemberOfExpr(): void { - $this->assertEquals(':groupId MEMBER OF u.groups', (string) $this->expr->isMemberOf(':groupId', 'u.groups')); + self::assertEquals(':groupId MEMBER OF u.groups', (string) $this->expr->isMemberOf(':groupId', 'u.groups')); } public function provideIterableValue(): Generator @@ -340,7 +340,7 @@ public function testAndxOrxExpr(): void $orExpr->add($andExpr); $orExpr->add($this->expr->eq(1, 1)); - $this->assertEquals('(1 = 1 AND 1 < 5) OR 1 = 1', (string) $orExpr); + self::assertEquals('(1 = 1 AND 1 < 5) OR 1 = 1', (string) $orExpr); } public function testOrxExpr(): void @@ -349,27 +349,27 @@ public function testOrxExpr(): void $orExpr->add($this->expr->eq(1, 1)); $orExpr->add($this->expr->lt(1, 5)); - $this->assertEquals('1 = 1 OR 1 < 5', (string) $orExpr); + self::assertEquals('1 = 1 OR 1 < 5', (string) $orExpr); } public function testOrderByCountExpr(): void { $orderExpr = $this->expr->desc('u.username'); - $this->assertEquals($orderExpr->count(), 1); - $this->assertEquals('u.username DESC', (string) $orderExpr); + self::assertEquals($orderExpr->count(), 1); + self::assertEquals('u.username DESC', (string) $orderExpr); } public function testOrderByOrder(): void { $orderExpr = $this->expr->desc('u.username'); - $this->assertEquals('u.username DESC', (string) $orderExpr); + self::assertEquals('u.username DESC', (string) $orderExpr); } public function testOrderByAsc(): void { $orderExpr = $this->expr->asc('u.username'); - $this->assertEquals('u.username ASC', (string) $orderExpr); + self::assertEquals('u.username ASC', (string) $orderExpr); } public function testAddThrowsException(): void @@ -384,8 +384,8 @@ public function testAddThrowsException(): void */ public function testBooleanLiteral(): void { - $this->assertEquals('true', $this->expr->literal(true)); - $this->assertEquals('false', $this->expr->literal(false)); + self::assertEquals('true', $this->expr->literal(true)); + self::assertEquals('false', $this->expr->literal(false)); } /** @@ -395,59 +395,59 @@ public function testExpressionGetter(): void { // Andx $andx = new Expr\Andx(['1 = 1', '2 = 2']); - $this->assertEquals(['1 = 1', '2 = 2'], $andx->getParts()); + self::assertEquals(['1 = 1', '2 = 2'], $andx->getParts()); // Comparison $comparison = new Expr\Comparison('foo', Expr\Comparison::EQ, 'bar'); - $this->assertEquals('foo', $comparison->getLeftExpr()); - $this->assertEquals('bar', $comparison->getRightExpr()); - $this->assertEquals(Expr\Comparison::EQ, $comparison->getOperator()); + self::assertEquals('foo', $comparison->getLeftExpr()); + self::assertEquals('bar', $comparison->getRightExpr()); + self::assertEquals(Expr\Comparison::EQ, $comparison->getOperator()); // From $from = new Expr\From('Foo', 'f', 'f.id'); - $this->assertEquals('f', $from->getAlias()); - $this->assertEquals('Foo', $from->getFrom()); - $this->assertEquals('f.id', $from->getIndexBy()); + self::assertEquals('f', $from->getAlias()); + self::assertEquals('Foo', $from->getFrom()); + self::assertEquals('f.id', $from->getIndexBy()); // Func $func = new Expr\Func('MAX', ['f.id']); - $this->assertEquals('MAX', $func->getName()); - $this->assertEquals(['f.id'], $func->getArguments()); + self::assertEquals('MAX', $func->getName()); + self::assertEquals(['f.id'], $func->getArguments()); // GroupBy $group = new Expr\GroupBy(['foo DESC', 'bar ASC']); - $this->assertEquals(['foo DESC', 'bar ASC'], $group->getParts()); + self::assertEquals(['foo DESC', 'bar ASC'], $group->getParts()); // Join $join = new Expr\Join(Expr\Join::INNER_JOIN, 'f.bar', 'b', Expr\Join::ON, 'b.bar_id = 1', 'b.bar_id'); - $this->assertEquals(Expr\Join::INNER_JOIN, $join->getJoinType()); - $this->assertEquals(Expr\Join::ON, $join->getConditionType()); - $this->assertEquals('b.bar_id = 1', $join->getCondition()); - $this->assertEquals('b.bar_id', $join->getIndexBy()); - $this->assertEquals('f.bar', $join->getJoin()); - $this->assertEquals('b', $join->getAlias()); + self::assertEquals(Expr\Join::INNER_JOIN, $join->getJoinType()); + self::assertEquals(Expr\Join::ON, $join->getConditionType()); + self::assertEquals('b.bar_id = 1', $join->getCondition()); + self::assertEquals('b.bar_id', $join->getIndexBy()); + self::assertEquals('f.bar', $join->getJoin()); + self::assertEquals('b', $join->getAlias()); // Literal $literal = new Expr\Literal(['foo']); - $this->assertEquals(['foo'], $literal->getParts()); + self::assertEquals(['foo'], $literal->getParts()); // Math $math = new Expr\Math(10, '+', 20); - $this->assertEquals(10, $math->getLeftExpr()); - $this->assertEquals(20, $math->getRightExpr()); - $this->assertEquals('+', $math->getOperator()); + self::assertEquals(10, $math->getLeftExpr()); + self::assertEquals(20, $math->getRightExpr()); + self::assertEquals('+', $math->getOperator()); // OrderBy $order = new Expr\OrderBy('foo', 'DESC'); - $this->assertEquals(['foo DESC'], $order->getParts()); + self::assertEquals(['foo DESC'], $order->getParts()); // Andx $orx = new Expr\Orx(['foo = 1', 'bar = 2']); - $this->assertEquals(['foo = 1', 'bar = 2'], $orx->getParts()); + self::assertEquals(['foo = 1', 'bar = 2'], $orx->getParts()); // Select $select = new Expr\Select(['foo', 'bar']); - $this->assertEquals(['foo', 'bar'], $select->getParts()); + self::assertEquals(['foo', 'bar'], $select->getParts()); } public function testAddEmpty(): void @@ -455,7 +455,7 @@ public function testAddEmpty(): void $andExpr = $this->expr->andX(); $andExpr->add($this->expr->andX()); - $this->assertEquals(0, $andExpr->count()); + self::assertEquals(0, $andExpr->count()); } public function testAddNull(): void @@ -463,6 +463,6 @@ public function testAddNull(): void $andExpr = $this->expr->andX(); $andExpr->add(null); - $this->assertEquals(0, $andExpr->count()); + self::assertEquals(0, $andExpr->count()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php index 4629b46566f..f8ff65f433f 100644 --- a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php @@ -27,25 +27,25 @@ public function testEnable(): void { $filterCollection = $this->em->getFilters(); - $this->assertCount(0, $filterCollection->getEnabledFilters()); + self::assertCount(0, $filterCollection->getEnabledFilters()); $filterCollection->enable('testFilter'); $enabledFilters = $filterCollection->getEnabledFilters(); - $this->assertCount(1, $enabledFilters); - $this->assertContainsOnly(MyFilter::class, $enabledFilters); + self::assertCount(1, $enabledFilters); + self::assertContainsOnly(MyFilter::class, $enabledFilters); $filterCollection->disable('testFilter'); - $this->assertCount(0, $filterCollection->getEnabledFilters()); + self::assertCount(0, $filterCollection->getEnabledFilters()); } public function testHasFilter(): void { $filterCollection = $this->em->getFilters(); - $this->assertTrue($filterCollection->has('testFilter')); - $this->assertFalse($filterCollection->has('fakeFilter')); + self::assertTrue($filterCollection->has('testFilter')); + self::assertFalse($filterCollection->has('fakeFilter')); } /** @@ -55,11 +55,11 @@ public function testIsEnabled(): void { $filterCollection = $this->em->getFilters(); - $this->assertFalse($filterCollection->isEnabled('testFilter')); + self::assertFalse($filterCollection->isEnabled('testFilter')); $filterCollection->enable('testFilter'); - $this->assertTrue($filterCollection->isEnabled('testFilter')); + self::assertTrue($filterCollection->isEnabled('testFilter')); } public function testGetFilterInvalidArgument(): void @@ -74,7 +74,7 @@ public function testGetFilter(): void $filterCollection = $this->em->getFilters(); $filterCollection->enable('testFilter'); - $this->assertInstanceOf(MyFilter::class, $filterCollection->getFilter('testFilter')); + self::assertInstanceOf(MyFilter::class, $filterCollection->getFilter('testFilter')); } } diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index 123feeed2ac..819ca683c11 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -38,7 +38,7 @@ public function assertValidDQL($dql, $debug = false): void echo $e->getTraceAsString() . PHP_EOL; } - $this->fail($e->getMessage()); + self::fail($e->getMessage()); } } @@ -47,7 +47,7 @@ public function assertInvalidDQL($dql, $debug = false): void try { $parserResult = $this->parseDql($dql); - $this->fail('No syntax errors were detected, when syntax errors were expected'); + self::fail('No syntax errors were detected, when syntax errors were expected'); } catch (QueryException $e) { if ($debug) { echo $e->getMessage() . PHP_EOL; diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index 585160c84fe..15afd69e320 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -19,8 +19,8 @@ public function testScannerRecognizesTokens($type, $value): void $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals($type, $token['type']); - $this->assertEquals($value, $token['value']); + self::assertEquals($type, $token['type']); + self::assertEquals($value, $token['value']); } public function testScannerRecognizesTerminalString(): void @@ -36,7 +36,7 @@ public function testScannerRecognizesTerminalString(): void $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_ALL, $token['type']); + self::assertEquals(Lexer::T_ALL, $token['type']); } public function testScannerRecognizesDecimalInteger(): void @@ -44,8 +44,8 @@ public function testScannerRecognizesDecimalInteger(): void $lexer = new Lexer('1234'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INTEGER, $token['type']); - $this->assertEquals(1234, $token['value']); + self::assertEquals(Lexer::T_INTEGER, $token['type']); + self::assertEquals(1234, $token['value']); } public function testScannerRecognizesFloat(): void @@ -53,8 +53,8 @@ public function testScannerRecognizesFloat(): void $lexer = new Lexer('1.234'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.234, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(1.234, $token['value']); } public function testScannerRecognizesFloatWithExponent(): void @@ -62,8 +62,8 @@ public function testScannerRecognizesFloatWithExponent(): void $lexer = new Lexer('1.2e3'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.2e3, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(1.2e3, $token['value']); } public function testScannerRecognizesFloatWithExponent2(): void @@ -71,8 +71,8 @@ public function testScannerRecognizesFloatWithExponent2(): void $lexer = new Lexer('0.2e3'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(.2e3, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(.2e3, $token['value']); } public function testScannerRecognizesFloatWithNegativeExponent(): void @@ -80,8 +80,8 @@ public function testScannerRecognizesFloatWithNegativeExponent(): void $lexer = new Lexer('7E-10'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(7E-10, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(7E-10, $token['value']); } public function testScannerRecognizesFloatBig(): void @@ -89,8 +89,8 @@ public function testScannerRecognizesFloatBig(): void $lexer = new Lexer('123456789.01'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertEquals(1.2345678901e8, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(1.2345678901e8, $token['value']); } public function testScannerRecognizesFloatContainingWhitespace(): void @@ -98,14 +98,14 @@ public function testScannerRecognizesFloatContainingWhitespace(): void $lexer = new Lexer('- 1.234e2'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_MINUS, $token['type']); - $this->assertEquals('-', $token['value']); + self::assertEquals(Lexer::T_MINUS, $token['type']); + self::assertEquals('-', $token['value']); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_FLOAT, $token['type']); - $this->assertNotEquals(-1.234e2, $token['value']); - $this->assertEquals(1.234e2, $token['value']); + self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertNotEquals(-1.234e2, $token['value']); + self::assertEquals(1.234e2, $token['value']); } public function testScannerRecognizesStringContainingWhitespace(): void @@ -113,8 +113,8 @@ public function testScannerRecognizesStringContainingWhitespace(): void $lexer = new Lexer("'This is a string.'"); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_STRING, $token['type']); - $this->assertEquals('This is a string.', $token['value']); + self::assertEquals(Lexer::T_STRING, $token['type']); + self::assertEquals('This is a string.', $token['value']); } public function testScannerRecognizesStringContainingSingleQuotes(): void @@ -122,8 +122,8 @@ public function testScannerRecognizesStringContainingSingleQuotes(): void $lexer = new Lexer("'abc''defg'''"); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_STRING, $token['type']); - $this->assertEquals("abc'defg'", $token['value']); + self::assertEquals(Lexer::T_STRING, $token['type']); + self::assertEquals("abc'defg'", $token['value']); } public function testScannerRecognizesInputParameter(): void @@ -131,8 +131,8 @@ public function testScannerRecognizesInputParameter(): void $lexer = new Lexer('?1'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); - $this->assertEquals('?1', $token['value']); + self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals('?1', $token['value']); } public function testScannerRecognizesNamedInputParameter(): void @@ -140,8 +140,8 @@ public function testScannerRecognizesNamedInputParameter(): void $lexer = new Lexer(':name'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); - $this->assertEquals(':name', $token['value']); + self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals(':name', $token['value']); } public function testScannerRecognizesNamedInputParameterStartingWithUnderscore(): void @@ -149,8 +149,8 @@ public function testScannerRecognizesNamedInputParameterStartingWithUnderscore() $lexer = new Lexer(':_name'); $lexer->moveNext(); $token = $lexer->lookahead; - $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); - $this->assertEquals(':_name', $token['value']); + self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals(':_name', $token['value']); } public function testScannerTokenizesASimpleQueryCorrectly(): void @@ -219,12 +219,12 @@ public function testScannerTokenizesASimpleQueryCorrectly(): void foreach ($tokens as $expected) { $lexer->moveNext(); $actual = $lexer->lookahead; - $this->assertEquals($expected['value'], $actual['value']); - $this->assertEquals($expected['type'], $actual['type']); - $this->assertEquals($expected['position'], $actual['position']); + self::assertEquals($expected['value'], $actual['value']); + self::assertEquals($expected['type'], $actual['type']); + self::assertEquals($expected['position'], $actual['position']); } - $this->assertFalse($lexer->moveNext()); + self::assertFalse($lexer->moveNext()); } /** @psalm-return list */ diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index df279c1a97d..5de9fca26b8 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -41,6 +41,6 @@ public function providerParameterTypeInferer(): array */ public function testParameterTypeInferer($value, $expected): void { - $this->assertEquals($expected, ParameterTypeInferer::inferType($value)); + self::assertEquals($expected, ParameterTypeInferer::inferType($value)); } } diff --git a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php index 2bfc593d606..506b499d60c 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php @@ -21,31 +21,31 @@ protected function setUp(): void public function testGetRsm(): void { - $this->assertInstanceOf(ResultSetMapping::class, $this->parserResult->getResultSetMapping()); + self::assertInstanceOf(ResultSetMapping::class, $this->parserResult->getResultSetMapping()); } public function testSetGetSqlExecutor(): void { - $this->assertNull($this->parserResult->getSqlExecutor()); + self::assertNull($this->parserResult->getSqlExecutor()); $executor = $this->getMockBuilder(AbstractSqlExecutor::class)->setMethods(['execute'])->getMock(); $this->parserResult->setSqlExecutor($executor); - $this->assertSame($executor, $this->parserResult->getSqlExecutor()); + self::assertSame($executor, $this->parserResult->getSqlExecutor()); } public function testGetSqlParameterPosition(): void { $this->parserResult->addParameterMapping(1, 1); $this->parserResult->addParameterMapping(1, 2); - $this->assertEquals([1, 2], $this->parserResult->getSqlParameterPositions(1)); + self::assertEquals([1, 2], $this->parserResult->getSqlParameterPositions(1)); } public function testGetParameterMappings(): void { - $this->assertIsArray($this->parserResult->getParameterMappings()); + self::assertIsArray($this->parserResult->getParameterMappings()); $this->parserResult->addParameterMapping(1, 1); $this->parserResult->addParameterMapping(1, 2); - $this->assertEquals([1 => [1, 2]], $this->parserResult->getParameterMappings()); + self::assertEquals([1 => [1, 2]], $this->parserResult->getParameterMappings()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/ParserTest.php b/tests/Doctrine/Tests/ORM/Query/ParserTest.php index 99e5fca3e00..f29065dd828 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserTest.php @@ -22,7 +22,7 @@ public function testAbstractSchemaNameSupportsFQCN(): void { $parser = $this->createParser(CmsUser::class); - $this->assertEquals(CmsUser::class, $parser->AbstractSchemaName()); + self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); } /** @@ -33,7 +33,7 @@ public function testAbstractSchemaNameSupportsClassnamesWithLeadingBackslash(): { $parser = $this->createParser('\\' . CmsUser::class); - $this->assertEquals('\\' . CmsUser::class, $parser->AbstractSchemaName()); + self::assertEquals('\\' . CmsUser::class, $parser->AbstractSchemaName()); } /** @@ -44,7 +44,7 @@ public function testAbstractSchemaNameSupportsIdentifier(): void { $parser = $this->createParser(stdClass::class); - $this->assertEquals(stdClass::class, $parser->AbstractSchemaName()); + self::assertEquals(stdClass::class, $parser->AbstractSchemaName()); } /** @@ -57,7 +57,7 @@ public function testAbstractSchemaNameSupportsNamespaceAlias(): void $parser->getEntityManager()->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - $this->assertEquals(CmsUser::class, $parser->AbstractSchemaName()); + self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); } /** @@ -70,7 +70,7 @@ public function testAbstractSchemaNameSupportsNamespaceAliasWithRelativeClassnam $parser->getEntityManager()->getConfiguration()->addEntityNamespace('Model', 'Doctrine\Tests\Models'); - $this->assertEquals(CmsUser::class, $parser->AbstractSchemaName()); + self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); } /** diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 45d5150b387..c06586fff20 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -33,9 +33,9 @@ protected function setUp(): void */ public function testWalkComparison(CriteriaComparison $criteriaExpr, $queryExpr, ?Parameter $parameter = null): void { - $this->assertEquals($queryExpr, $this->visitor->walkComparison($criteriaExpr)); + self::assertEquals($queryExpr, $this->visitor->walkComparison($criteriaExpr)); if ($parameter) { - $this->assertEquals(new ArrayCollection([$parameter]), $this->visitor->getParameters()); + self::assertEquals(new ArrayCollection([$parameter]), $this->visitor->getParameters()); } } @@ -85,8 +85,8 @@ public function testWalkAndCompositeExpression(): void ) ); - $this->assertInstanceOf(QueryBuilder\Andx::class, $expr); - $this->assertCount(2, $expr->getParts()); + self::assertInstanceOf(QueryBuilder\Andx::class, $expr); + self::assertCount(2, $expr->getParts()); } public function testWalkOrCompositeExpression(): void @@ -99,13 +99,13 @@ public function testWalkOrCompositeExpression(): void ) ); - $this->assertInstanceOf(QueryBuilder\Orx::class, $expr); - $this->assertCount(2, $expr->getParts()); + self::assertInstanceOf(QueryBuilder\Orx::class, $expr); + self::assertCount(2, $expr->getParts()); } public function testWalkValue(): void { - $this->assertEquals('value', $this->visitor->walkValue(new Value('value'))); + self::assertEquals('value', $this->visitor->walkValue(new Value('value'))); } public function testClearParameters(): void @@ -114,6 +114,6 @@ public function testClearParameters(): void $this->visitor->clearParameters(); - $this->assertCount(0, $this->visitor->getParameters()); + self::assertCount(0, $this->visitor->getParameters()); } } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 226490524e6..bcd234991c7 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -45,7 +45,7 @@ public function testGetParameters(): void $parameters = new ArrayCollection(); - $this->assertEquals($parameters, $query->getParameters()); + self::assertEquals($parameters, $query->getParameters()); } public function testGetParametersHasSomeAlready(): void @@ -56,7 +56,7 @@ public function testGetParametersHasSomeAlready(): void $parameters = new ArrayCollection(); $parameters->add(new Parameter(2, 84)); - $this->assertEquals($parameters, $query->getParameters()); + self::assertEquals($parameters, $query->getParameters()); } public function testSetParameters(): void @@ -69,7 +69,7 @@ public function testSetParameters(): void $query->setParameters($parameters); - $this->assertEquals($parameters, $query->getParameters()); + self::assertEquals($parameters, $query->getParameters()); } public function testFree(): void @@ -79,7 +79,7 @@ public function testFree(): void $query->free(); - $this->assertEquals(0, count($query->getParameters())); + self::assertEquals(0, count($query->getParameters())); } public function testClone(): void @@ -92,9 +92,9 @@ public function testClone(): void $cloned = clone $query; - $this->assertEquals($dql, $cloned->getDQL()); - $this->assertEquals(0, count($cloned->getParameters())); - $this->assertFalse($cloned->getHint('foo')); + self::assertEquals($dql, $cloned->getDQL()); + self::assertEquals(0, count($cloned->getParameters())); + self::assertFalse($cloned->getHint('foo')); } public function testFluentQueryInterface(): void @@ -114,7 +114,7 @@ public function testFluentQueryInterface(): void ->setFirstResult(10) ->setMaxResults(10); - $this->assertSame($q2, $q); + self::assertSame($q2, $q); } /** @@ -125,11 +125,11 @@ public function testHints(): void $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); $q->setHint('foo', 'bar')->setHint('bar', 'baz'); - $this->assertEquals('bar', $q->getHint('foo')); - $this->assertEquals('baz', $q->getHint('bar')); - $this->assertEquals(['foo' => 'bar', 'bar' => 'baz'], $q->getHints()); - $this->assertTrue($q->hasHint('foo')); - $this->assertFalse($q->hasHint('barFooBaz')); + self::assertEquals('bar', $q->getHint('foo')); + self::assertEquals('baz', $q->getHint('bar')); + self::assertEquals(['foo' => 'bar', 'bar' => 'baz'], $q->getHints()); + self::assertTrue($q->hasHint('foo')); + self::assertFalse($q->hasHint('barFooBaz')); } /** @@ -140,7 +140,7 @@ public function testQueryDefaultResultCache(): void $this->entityManager->getConfiguration()->setResultCacheImpl(DoctrineProvider::wrap(new ArrayAdapter())); $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); $q->enableResultCache(); - $this->assertSame($this->entityManager->getConfiguration()->getResultCacheImpl(), $q->getQueryCacheProfile()->getResultCacheDriver()); + self::assertSame($this->entityManager->getConfiguration()->getResultCacheImpl(), $q->getQueryCacheProfile()->getResultCacheDriver()); } public function testIterateWithNoDistinctAndWrongSelectClause(): void @@ -211,8 +211,8 @@ public function testCollectionParameters(): void $parameters = $query->getParameters(); $parameter = $parameters->first(); - $this->assertEquals('cities', $parameter->getName()); - $this->assertEquals($cities, $parameter->getValue()); + self::assertEquals('cities', $parameter->getName()); + self::assertEquals($cities, $parameter->getValue()); } public function provideProcessParameterValueIterable(): Generator @@ -263,7 +263,7 @@ public function testProcessParameterValueWithIterableEntityShouldNotBeTreatedAsI public function testProcessParameterValueClassMetadata(): void { $query = $this->entityManager->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)'); - $this->assertEquals( + self::assertEquals( CmsAddress::class, $query->processParameterValue($this->entityManager->getClassMetadata(CmsAddress::class)) ); @@ -312,11 +312,11 @@ public function testDefaultQueryHints(): void $config->setDefaultQueryHints($defaultHints); $query = $this->entityManager->createQuery(); - $this->assertSame($config->getDefaultQueryHints(), $query->getHints()); + self::assertSame($config->getDefaultQueryHints(), $query->getHints()); $this->entityManager->getConfiguration()->setDefaultQueryHint('hint_name_1', 'hint_another_value_1'); - $this->assertNotSame($config->getDefaultQueryHints(), $query->getHints()); + self::assertNotSame($config->getDefaultQueryHints(), $query->getHints()); $q2 = clone $query; - $this->assertSame($config->getDefaultQueryHints(), $q2->getHints()); + self::assertSame($config->getDefaultQueryHints(), $q2->getHints()); } /** @@ -338,7 +338,7 @@ public function testResultCacheCaching(): void //let it cache ->getResult(); - $this->assertCount(1, $res); + self::assertCount(1, $res); $driverConnectionMock->setStatementMock(null); @@ -346,7 +346,7 @@ public function testResultCacheCaching(): void ->useQueryCache(true) ->disableResultCache() ->getResult(); - $this->assertCount(0, $res); + self::assertCount(0, $res); } /** @@ -356,7 +356,7 @@ public function testSetHydrationCacheProfileNull(): void { $query = $this->entityManager->createQuery(); $query->setHydrationCacheProfile(null); - $this->assertNull($query->getHydrationCacheProfile()); + self::assertNull($query->getHydrationCacheProfile()); } /** diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 1b3ef50c846..b05fbfaeb9e 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -77,7 +77,7 @@ public function assertSqlGeneration( $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage() . "\n" . $e->getTraceAsString()); + self::fail($e->getMessage() . "\n" . $e->getTraceAsString()); } } @@ -109,7 +109,7 @@ public function assertInvalidSqlGeneration( $query->free(); // If we reached here, test failed - $this->fail($sql); + self::fail($sql); } /** @@ -696,7 +696,7 @@ public function testSupportsMemberOfExpressionOneToMany(): void $phone->phonenumber = 101; $q->setParameter('param', $phone); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id AND c1_.phonenumber = ?)', $q->getSql() ); @@ -712,7 +712,7 @@ public function testSupportsMemberOfExpressionManyToMany(): void $group->id = 101; $q->setParameter('param', $group); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (?))', $q->getSql() ); @@ -729,7 +729,7 @@ public function testSupportsMemberOfExpressionManyToManyParameterArray(): void $group2->id = 105; $q->setParameter('param', [$group, $group2]); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (?))', $q->getSql() ); @@ -743,7 +743,7 @@ public function testSupportsMemberOfExpressionSelfReferencing(): void $person = new CompanyPerson(); $this->entityManager->getClassMetadata(get_class($person))->setIdentifierValues($person, ['id' => 101]); $q->setParameter('param', $person); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c1_.car_id AS car_id_8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ WHERE c3_.person_id = c0_.id AND c3_.friend_id IN (?))', $q->getSql() ); @@ -754,7 +754,7 @@ public function testSupportsMemberOfWithSingleValuedAssociation(): void // Impossible example, but it illustrates the purpose $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.email MEMBER OF u.groups'); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (c0_.email_id))', $q->getSql() ); @@ -765,7 +765,7 @@ public function testSupportsMemberOfWithIdentificationVariable(): void // Impossible example, but it illustrates the purpose $q = $this->entityManager->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u MEMBER OF u.groups'); - $this->assertEquals( + self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (c0_.id))', $q->getSql() ); @@ -775,21 +775,21 @@ public function testSupportsCurrentDateFunction(): void { $q = $this->entityManager->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_date()'); $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_DATE', $q->getSql()); + self::assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_DATE', $q->getSql()); } public function testSupportsCurrentTimeFunction(): void { $q = $this->entityManager->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.time > current_time()'); $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_time > CURRENT_TIME', $q->getSql()); + self::assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_time > CURRENT_TIME', $q->getSql()); } public function testSupportsCurrentTimestampFunction(): void { $q = $this->entityManager->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_timestamp()'); $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_TIMESTAMP', $q->getSql()); + self::assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_TIMESTAMP', $q->getSql()); } public function testExistsExpressionInWhereCorrelatedSubqueryAssocCondition(): void @@ -834,7 +834,7 @@ public function testLimitFromQueryClass(): void ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') ->setMaxResults(10); - $this->assertEquals('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10', $q->getSql()); + self::assertEquals('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10', $q->getSql()); } public function testLimitAndOffsetFromQueryClass(): void @@ -1075,7 +1075,7 @@ public function testSubselectInSelect(): void public function testPessimisticWriteLockQueryHint(): void { if ($this->entityManager->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { - $this->markTestSkipped('SqLite does not support Row locking at all.'); + self::markTestSkipped('SqLite does not support Row locking at all.'); } $this->assertSqlGeneration( @@ -1247,7 +1247,7 @@ public function testIdVariableResultVariableReuse(): void $exceptionThrown = true; } - $this->assertTrue($exceptionThrown); + self::assertTrue($exceptionThrown); } public function testSubSelectAliasesFromOuterQuery(): void diff --git a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php index 1bbb397b11e..40fc7aa8dd6 100644 --- a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php @@ -29,7 +29,7 @@ protected function setUp(): void */ public function testGetSQLTableAlias($tableName, $expectedAlias): void { - $this->assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName)); + self::assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName)); } /** @@ -37,7 +37,7 @@ public function testGetSQLTableAlias($tableName, $expectedAlias): void */ public function testGetSQLTableAliasIsSameForMultipleCalls($tableName): void { - $this->assertSame( + self::assertSame( $this->sqlWalker->getSQLTableAlias($tableName), $this->sqlWalker->getSQLTableAlias($tableName) ); diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php index 193de786abb..da694ea1a16 100644 --- a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -42,7 +42,7 @@ public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed): void parent::assertEquals($sqlToBeConfirmed, $query->getSql()); $query->free(); } catch (Exception $e) { - $this->fail($e->getMessage()); + self::fail($e->getMessage()); } } diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 247349d9562..566c3ea34f8 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -42,7 +42,7 @@ protected function assertValidQueryBuilder(QueryBuilder $qb, $expectedDql): void $dql = $qb->getDQL(); $q = $qb->getQuery(); - $this->assertEquals($expectedDql, $dql); + self::assertEquals($expectedDql, $dql); } public function testSelectSetsType(): void @@ -51,7 +51,7 @@ public function testSelectSetsType(): void ->delete(CmsUser::class, 'u') ->select('u.id', 'u.username'); - $this->assertEquals($qb->getType(), QueryBuilder::SELECT); + self::assertEquals($qb->getType(), QueryBuilder::SELECT); } public function testEmptySelectSetsType(): void @@ -60,7 +60,7 @@ public function testEmptySelectSetsType(): void ->delete(CmsUser::class, 'u') ->select(); - $this->assertEquals($qb->getType(), QueryBuilder::SELECT); + self::assertEquals($qb->getType(), QueryBuilder::SELECT); } public function testDeleteSetsType(): void @@ -69,7 +69,7 @@ public function testDeleteSetsType(): void ->from(CmsUser::class, 'u') ->delete(); - $this->assertEquals($qb->getType(), QueryBuilder::DELETE); + self::assertEquals($qb->getType(), QueryBuilder::DELETE); } public function testUpdateSetsType(): void @@ -78,7 +78,7 @@ public function testUpdateSetsType(): void ->from(CmsUser::class, 'u') ->update(); - $this->assertEquals($qb->getType(), QueryBuilder::UPDATE); + self::assertEquals($qb->getType(), QueryBuilder::UPDATE); } public function testSimpleSelect(): void @@ -428,8 +428,8 @@ public function testAddCriteriaWhere(): void $qb->addCriteria($criteria); - $this->assertEquals('u.field = :field', (string) $qb->getDQLPart('where')); - $this->assertNotNull($qb->getParameter('field')); + self::assertEquals('u.field = :field', (string) $qb->getDQLPart('where')); + self::assertNotNull($qb->getParameter('field')); } public function testAddMultipleSameCriteriaWhere(): void @@ -445,9 +445,9 @@ public function testAddMultipleSameCriteriaWhere(): void $qb->addCriteria($criteria); - $this->assertEquals('alias1.field = :field AND alias1.field = :field_1', (string) $qb->getDQLPart('where')); - $this->assertNotNull($qb->getParameter('field')); - $this->assertNotNull($qb->getParameter('field_1')); + self::assertEquals('alias1.field = :field AND alias1.field = :field_1', (string) $qb->getDQLPart('where')); + self::assertNotNull($qb->getParameter('field')); + self::assertNotNull($qb->getParameter('field_1')); } /** @@ -464,9 +464,9 @@ public function testAddCriteriaWhereWithMultipleParametersWithSameField(): void $qb->addCriteria($criteria); - $this->assertEquals('alias1.field = :field AND alias1.field > :field_1', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field')->getValue()); - $this->assertSame('value2', $qb->getParameter('field_1')->getValue()); + self::assertEquals('alias1.field = :field AND alias1.field > :field_1', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field')->getValue()); + self::assertSame('value2', $qb->getParameter('field_1')->getValue()); } /** @@ -483,9 +483,9 @@ public function testAddCriteriaWhereWithMultipleParametersWithDifferentFields(): $qb->addCriteria($criteria); - $this->assertEquals('alias1.field1 = :field1 AND alias1.field2 > :field2', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field1')->getValue()); - $this->assertSame('value2', $qb->getParameter('field2')->getValue()); + self::assertEquals('alias1.field1 = :field1 AND alias1.field2 > :field2', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field1')->getValue()); + self::assertSame('value2', $qb->getParameter('field2')->getValue()); } /** @@ -502,9 +502,9 @@ public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndDiffere $qb->addCriteria($criteria); - $this->assertEquals('alias1.field1 = :field1 AND alias1.field2 > :field2', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field1')->getValue()); - $this->assertSame('value2', $qb->getParameter('field2')->getValue()); + self::assertEquals('alias1.field1 = :field1 AND alias1.field2 > :field2', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field1')->getValue()); + self::assertSame('value2', $qb->getParameter('field2')->getValue()); } /** @@ -521,9 +521,9 @@ public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndSamePro $qb->addCriteria($criteria); - $this->assertEquals('alias1.field1 = :field1 AND alias1.field1 > :field1_1', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field1')->getValue()); - $this->assertSame('value2', $qb->getParameter('field1_1')->getValue()); + self::assertEquals('alias1.field1 = :field1 AND alias1.field1 > :field1_1', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field1')->getValue()); + self::assertSame('value2', $qb->getParameter('field1_1')->getValue()); } public function testAddCriteriaOrder(): void @@ -537,8 +537,8 @@ public function testAddCriteriaOrder(): void $qb->addCriteria($criteria); - $this->assertCount(1, $orderBy = $qb->getDQLPart('orderBy')); - $this->assertEquals('u.field DESC', (string) $orderBy[0]); + self::assertCount(1, $orderBy = $qb->getDQLPart('orderBy')); + self::assertEquals('u.field DESC', (string) $orderBy[0]); } /** @@ -556,8 +556,8 @@ public function testAddCriteriaOrderOnJoinAlias(): void $qb->addCriteria($criteria); - $this->assertCount(1, $orderBy = $qb->getDQLPart('orderBy')); - $this->assertEquals('a.field DESC', (string) $orderBy[0]); + self::assertCount(1, $orderBy = $qb->getDQLPart('orderBy')); + self::assertEquals('a.field DESC', (string) $orderBy[0]); } public function testAddCriteriaLimit(): void @@ -572,8 +572,8 @@ public function testAddCriteriaLimit(): void $qb->addCriteria($criteria); - $this->assertEquals(2, $qb->getFirstResult()); - $this->assertEquals(10, $qb->getMaxResults()); + self::assertEquals(2, $qb->getFirstResult()); + self::assertEquals(10, $qb->getMaxResults()); } public function testAddCriteriaUndefinedLimit(): void @@ -588,8 +588,8 @@ public function testAddCriteriaUndefinedLimit(): void $qb->addCriteria($criteria); - $this->assertEquals(2, $qb->getFirstResult()); - $this->assertEquals(10, $qb->getMaxResults()); + self::assertEquals(2, $qb->getFirstResult()); + self::assertEquals(10, $qb->getMaxResults()); } public function testGetQuery(): void @@ -599,7 +599,7 @@ public function testGetQuery(): void ->from(CmsUser::class, 'u'); $q = $qb->getQuery(); - $this->assertEquals(Query::class, get_class($q)); + self::assertEquals(Query::class, get_class($q)); } public function testSetParameter(): void @@ -631,7 +631,7 @@ public function testSetParameters(): void $qb->setParameters($parameters); - $this->assertEquals($parameters, $qb->getQuery()->getParameters()); + self::assertEquals($parameters, $qb->getQuery()->getParameters()); } public function testGetParameters(): void @@ -646,7 +646,7 @@ public function testGetParameters(): void $qb->setParameters($parameters); - $this->assertEquals($parameters, $qb->getParameters()); + self::assertEquals($parameters, $qb->getParameters()); } public function testGetParameter(): void @@ -661,7 +661,7 @@ public function testGetParameter(): void $qb->setParameters($parameters); - $this->assertEquals($parameters->first(), $qb->getParameter('id')); + self::assertEquals($parameters->first(), $qb->getParameter('id')); } public function testMultipleWhere(): void @@ -775,8 +775,8 @@ public function testMultipleIsolatedQueryConstruction(): void $q1 = $qb->getQuery(); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name', $q1->getDQL()); - $this->assertEquals(1, count($q1->getParameters())); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name', $q1->getDQL()); + self::assertEquals(1, count($q1->getParameters())); // add another condition and construct a second query $qb->andWhere($expr->eq('u.id', ':id')); @@ -784,22 +784,22 @@ public function testMultipleIsolatedQueryConstruction(): void $q2 = $qb->getQuery(); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name AND u.id = :id', $q2->getDQL()); - $this->assertTrue($q1 !== $q2); // two different, independent queries - $this->assertEquals(2, count($q2->getParameters())); - $this->assertEquals(1, count($q1->getParameters())); // $q1 unaffected + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name AND u.id = :id', $q2->getDQL()); + self::assertTrue($q1 !== $q2); // two different, independent queries + self::assertEquals(2, count($q2->getParameters())); + self::assertEquals(1, count($q1->getParameters())); // $q1 unaffected } public function testGetEntityManager(): void { $qb = $this->entityManager->createQueryBuilder(); - $this->assertEquals($this->entityManager, $qb->getEntityManager()); + self::assertEquals($this->entityManager, $qb->getEntityManager()); } public function testInitialStateIsClean(): void { $qb = $this->entityManager->createQueryBuilder(); - $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); + self::assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); } public function testAlteringQueryChangesStateToDirty(): void @@ -808,7 +808,7 @@ public function testAlteringQueryChangesStateToDirty(): void ->select('u') ->from(CmsUser::class, 'u'); - $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); + self::assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); } public function testSelectWithFuncExpression(): void @@ -827,13 +827,13 @@ public function testResetDQLPart(): void ->from(CmsUser::class, 'u') ->where('u.username = ?1')->orderBy('u.username'); - $this->assertEquals('u.username = ?1', (string) $qb->getDQLPart('where')); - $this->assertEquals(1, count($qb->getDQLPart('orderBy'))); + self::assertEquals('u.username = ?1', (string) $qb->getDQLPart('where')); + self::assertEquals(1, count($qb->getDQLPart('orderBy'))); $qb->resetDQLPart('where')->resetDQLPart('orderBy'); - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + self::assertNull($qb->getDQLPart('where')); + self::assertEquals(0, count($qb->getDQLPart('orderBy'))); } public function testResetDQLParts(): void @@ -845,9 +845,9 @@ public function testResetDQLParts(): void $qb->resetDQLParts(['where', 'orderBy']); - $this->assertEquals(1, count($qb->getDQLPart('select'))); - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + self::assertEquals(1, count($qb->getDQLPart('select'))); + self::assertNull($qb->getDQLPart('where')); + self::assertEquals(0, count($qb->getDQLPart('orderBy'))); } public function testResetAllDQLParts(): void @@ -859,9 +859,9 @@ public function testResetAllDQLParts(): void $qb->resetDQLParts(); - $this->assertEquals(0, count($qb->getDQLPart('select'))); - $this->assertNull($qb->getDQLPart('where')); - $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + self::assertEquals(0, count($qb->getDQLPart('select'))); + self::assertNull($qb->getDQLPart('where')); + self::assertEquals(0, count($qb->getDQLPart('orderBy'))); } /** @@ -876,12 +876,12 @@ public function testDeepClone(): void ->andWhere('u.status = ?2'); $expr = $qb->getDQLPart('where'); - $this->assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); + self::assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); $qb2 = clone $qb; $qb2->andWhere('u.name = ?3'); - $this->assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); + self::assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); } /** @@ -899,9 +899,9 @@ public function testAddCriteriaWhereWithJoinAlias(): void $qb->addCriteria($criteria); - $this->assertEquals('alias1.field = :field AND alias2.field > :alias2_field', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('field')->getValue()); - $this->assertSame('value2', $qb->getParameter('alias2_field')->getValue()); + self::assertEquals('alias1.field = :field AND alias2.field > :alias2_field', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('field')->getValue()); + self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); } /** @@ -919,9 +919,9 @@ public function testAddCriteriaWhereWithDefaultAndJoinAlias(): void $qb->addCriteria($criteria); - $this->assertEquals('alias1.field = :alias1_field AND alias2.field > :alias2_field', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('alias1_field')->getValue()); - $this->assertSame('value2', $qb->getParameter('alias2_field')->getValue()); + self::assertEquals('alias1.field = :alias1_field AND alias2.field > :alias2_field', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('alias1_field')->getValue()); + self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); } /** @@ -940,10 +940,10 @@ public function testAddCriteriaWhereOnJoinAliasWithDuplicateFields(): void $qb->addCriteria($criteria); - $this->assertEquals('(alias1.field = :alias1_field AND alias2.field > :alias2_field) AND alias2.field < :alias2_field_2', (string) $qb->getDQLPart('where')); - $this->assertSame('value1', $qb->getParameter('alias1_field')->getValue()); - $this->assertSame('value2', $qb->getParameter('alias2_field')->getValue()); - $this->assertSame('value3', $qb->getParameter('alias2_field_2')->getValue()); + self::assertEquals('(alias1.field = :alias1_field AND alias2.field > :alias2_field) AND alias2.field < :alias2_field_2', (string) $qb->getDQLPart('where')); + self::assertSame('value1', $qb->getParameter('alias1_field')->getValue()); + self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); + self::assertSame('value3', $qb->getParameter('alias2_field_2')->getValue()); } /** @@ -958,9 +958,9 @@ public function testParametersAreCloned(): void $copy = clone $originalQb; $copy->setParameter('parameter2', 'value2'); - $this->assertCount(1, $originalQb->getParameters()); - $this->assertSame('value1', $copy->getParameter('parameter1')->getValue()); - $this->assertSame('value2', $copy->getParameter('parameter2')->getValue()); + self::assertCount(1, $originalQb->getParameters()); + self::assertSame('value1', $copy->getParameter('parameter1')->getValue()); + self::assertSame('value2', $copy->getParameter('parameter2')->getValue()); } public function testGetRootAlias(): void @@ -969,7 +969,7 @@ public function testGetRootAlias(): void ->select('u') ->from(CmsUser::class, 'u'); - $this->assertEquals('u', $qb->getRootAlias()); + self::assertEquals('u', $qb->getRootAlias()); } public function testGetRootAliases(): void @@ -978,7 +978,7 @@ public function testGetRootAliases(): void ->select('u') ->from(CmsUser::class, 'u'); - $this->assertEquals(['u'], $qb->getRootAliases()); + self::assertEquals(['u'], $qb->getRootAliases()); } public function testGetRootEntities(): void @@ -987,7 +987,7 @@ public function testGetRootEntities(): void ->select('u') ->from(CmsUser::class, 'u'); - $this->assertEquals([CmsUser::class], $qb->getRootEntities()); + self::assertEquals([CmsUser::class], $qb->getRootEntities()); } public function testGetSeveralRootAliases(): void @@ -997,8 +997,8 @@ public function testGetSeveralRootAliases(): void ->from(CmsUser::class, 'u') ->from(CmsUser::class, 'u2'); - $this->assertEquals(['u', 'u2'], $qb->getRootAliases()); - $this->assertEquals('u', $qb->getRootAlias()); + self::assertEquals(['u', 'u2'], $qb->getRootAliases()); + self::assertEquals('u', $qb->getRootAlias()); } public function testBCAddJoinWithoutRootAlias(): void @@ -1008,7 +1008,7 @@ public function testBCAddJoinWithoutRootAlias(): void ->from(CmsUser::class, 'u') ->add('join', ['INNER JOIN u.groups g'], true); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL()); } /** @@ -1022,7 +1022,7 @@ public function testEmptyStringLiteral(): void ->from(CmsUser::class, 'u') ->where($expr->eq('u.username', $expr->literal(''))); - $this->assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL()); + self::assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL()); } /** @@ -1036,7 +1036,7 @@ public function testEmptyNumericLiteral(): void ->from(CmsUser::class, 'u') ->where($expr->eq('u.username', $expr->literal(0))); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL()); } /** @@ -1048,7 +1048,7 @@ public function testAddFromString(): void ->add('select', 'u') ->add('from', CmsUser::class . ' u'); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); } /** @@ -1061,7 +1061,7 @@ public function testAddDistinct(): void ->distinct() ->from(CmsUser::class, 'u'); - $this->assertEquals('SELECT DISTINCT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); + self::assertEquals('SELECT DISTINCT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); } /** @@ -1083,17 +1083,17 @@ public function testSecondLevelCacheQueryBuilderOptions(): void ->select('s') ->from(State::class, 's'); - $this->assertFalse($defaultQueryBuilder->isCacheable()); - $this->assertEquals(0, $defaultQueryBuilder->getLifetime()); - $this->assertNull($defaultQueryBuilder->getCacheRegion()); - $this->assertNull($defaultQueryBuilder->getCacheMode()); + self::assertFalse($defaultQueryBuilder->isCacheable()); + self::assertEquals(0, $defaultQueryBuilder->getLifetime()); + self::assertNull($defaultQueryBuilder->getCacheRegion()); + self::assertNull($defaultQueryBuilder->getCacheMode()); $defaultQuery = $defaultQueryBuilder->getQuery(); - $this->assertFalse($defaultQuery->isCacheable()); - $this->assertEquals(0, $defaultQuery->getLifetime()); - $this->assertNull($defaultQuery->getCacheRegion()); - $this->assertNull($defaultQuery->getCacheMode()); + self::assertFalse($defaultQuery->isCacheable()); + self::assertEquals(0, $defaultQuery->getLifetime()); + self::assertNull($defaultQuery->getCacheRegion()); + self::assertNull($defaultQuery->getCacheMode()); $builder = $this->entityManager->createQueryBuilder() ->select('s') @@ -1103,17 +1103,17 @@ public function testSecondLevelCacheQueryBuilderOptions(): void ->setCacheMode(Cache::MODE_REFRESH) ->from(State::class, 's'); - $this->assertTrue($builder->isCacheable()); - $this->assertEquals(123, $builder->getLifetime()); - $this->assertEquals('foo_reg', $builder->getCacheRegion()); - $this->assertEquals(Cache::MODE_REFRESH, $builder->getCacheMode()); + self::assertTrue($builder->isCacheable()); + self::assertEquals(123, $builder->getLifetime()); + self::assertEquals('foo_reg', $builder->getCacheRegion()); + self::assertEquals(Cache::MODE_REFRESH, $builder->getCacheMode()); $query = $builder->getQuery(); - $this->assertTrue($query->isCacheable()); - $this->assertEquals(123, $query->getLifetime()); - $this->assertEquals('foo_reg', $query->getCacheRegion()); - $this->assertEquals(Cache::MODE_REFRESH, $query->getCacheMode()); + self::assertTrue($query->isCacheable()); + self::assertEquals(123, $query->getLifetime()); + self::assertEquals('foo_reg', $query->getCacheRegion()); + self::assertEquals(Cache::MODE_REFRESH, $query->getCacheMode()); } /** @@ -1136,7 +1136,7 @@ public function testRebuildsFromParts(): void $dql2 = $qb2->getDQL(); - $this->assertEquals($dql, $dql2); + self::assertEquals($dql, $dql2); } public function testGetAllAliasesWithNoJoins(): void @@ -1146,7 +1146,7 @@ public function testGetAllAliasesWithNoJoins(): void $aliases = $qb->getAllAliases(); - $this->assertEquals(['u'], $aliases); + self::assertEquals(['u'], $aliases); } public function testGetAllAliasesWithJoins(): void @@ -1158,7 +1158,7 @@ public function testGetAllAliasesWithJoins(): void $aliases = $qb->getAllAliases(); - $this->assertEquals(['u', 'g'], $aliases); + self::assertEquals(['u', 'g'], $aliases); } /** diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index 520dc40f755..649433e129e 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -38,19 +38,19 @@ protected function setUp(): void $this->repositoryFactory = new DefaultRepositoryFactory(); $this->configuration - ->expects($this->any()) + ->expects(self::any()) ->method('getDefaultRepositoryClassName') - ->will($this->returnValue(DDC869PaymentRepository::class)); + ->will(self::returnValue(DDC869PaymentRepository::class)); } public function testCreatesRepositoryFromDefaultRepositoryClass(): void { $this->entityManager - ->expects($this->any()) + ->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback([$this, 'buildClassMetadata'])); - $this->assertInstanceOf( + self::assertInstanceOf( DDC869PaymentRepository::class, $this->repositoryFactory->getRepository($this->entityManager, self::class) ); @@ -59,11 +59,11 @@ public function testCreatesRepositoryFromDefaultRepositoryClass(): void public function testCreatedRepositoriesAreCached(): void { $this->entityManager - ->expects($this->any()) + ->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback([$this, 'buildClassMetadata'])); - $this->assertSame( + self::assertSame( $this->repositoryFactory->getRepository($this->entityManager, self::class), $this->repositoryFactory->getRepository($this->entityManager, self::class) ); @@ -75,11 +75,11 @@ public function testCreatesRepositoryFromCustomClassMetadata(): void $customMetadata->customRepositoryClassName = DDC753DefaultRepository::class; $this->entityManager - ->expects($this->any()) + ->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnValue($customMetadata)); + ->will(self::returnValue($customMetadata)); - $this->assertInstanceOf( + self::assertInstanceOf( DDC753DefaultRepository::class, $this->repositoryFactory->getRepository($this->entityManager, self::class) ); @@ -90,21 +90,21 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void $em1 = $this->createEntityManager(); $em2 = $this->createEntityManager(); - $em1->expects($this->any()) + $em1->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback([$this, 'buildClassMetadata'])); - $em2->expects($this->any()) + $em2->expects(self::any()) ->method('getClassMetadata') - ->will($this->returnCallback([$this, 'buildClassMetadata'])); + ->will(self::returnCallback([$this, 'buildClassMetadata'])); $repo1 = $this->repositoryFactory->getRepository($em1, self::class); $repo2 = $this->repositoryFactory->getRepository($em2, self::class); - $this->assertSame($repo1, $this->repositoryFactory->getRepository($em1, self::class)); - $this->assertSame($repo2, $this->repositoryFactory->getRepository($em2, self::class)); + self::assertSame($repo1, $this->repositoryFactory->getRepository($em1, self::class)); + self::assertSame($repo2, $this->repositoryFactory->getRepository($em2, self::class)); - $this->assertNotSame($repo1, $repo2); + self::assertNotSame($repo1, $repo2); } /** @@ -117,7 +117,7 @@ public function buildClassMetadata(string $className) $metadata = $this->createMock(ClassMetadata::class); assert($metadata instanceof ClassMetadata || $metadata instanceof MockObject); - $metadata->expects($this->any())->method('getName')->will($this->returnValue($className)); + $metadata->expects(self::any())->method('getName')->will(self::returnValue($className)); $metadata->customRepositoryClassName = null; @@ -131,9 +131,9 @@ private function createEntityManager(): EntityManagerInterface { $entityManager = $this->createMock(EntityManagerInterface::class); - $entityManager->expects($this->any()) + $entityManager->expects(self::any()) ->method('getConfiguration') - ->will($this->returnValue($this->configuration)); + ->will(self::returnValue($this->configuration)); return $entityManager; } diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php index 0c68b556f3c..b5430ef7a67 100644 --- a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php @@ -52,10 +52,10 @@ public function testAttachEntityListeners(): void $metadata = $this->factory->getMetadataFor(AttachEntityListenersListenerTestFooEntity::class); - $this->assertArrayHasKey('postLoad', $metadata->entityListeners); - $this->assertCount(1, $metadata->entityListeners['postLoad']); - $this->assertEquals('postLoadHandler', $metadata->entityListeners['postLoad'][0]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['postLoad'][0]['class']); + self::assertArrayHasKey('postLoad', $metadata->entityListeners); + self::assertCount(1, $metadata->entityListeners['postLoad']); + self::assertEquals('postLoadHandler', $metadata->entityListeners['postLoad'][0]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['postLoad'][0]['class']); } public function testAttachToExistingEntityListeners(): void @@ -75,23 +75,23 @@ public function testAttachToExistingEntityListeners(): void $metadata = $this->factory->getMetadataFor(AttachEntityListenersListenerTestBarEntity::class); - $this->assertArrayHasKey('postPersist', $metadata->entityListeners); - $this->assertArrayHasKey('prePersist', $metadata->entityListeners); + self::assertArrayHasKey('postPersist', $metadata->entityListeners); + self::assertArrayHasKey('prePersist', $metadata->entityListeners); - $this->assertCount(2, $metadata->entityListeners['prePersist']); - $this->assertCount(2, $metadata->entityListeners['postPersist']); + self::assertCount(2, $metadata->entityListeners['prePersist']); + self::assertCount(2, $metadata->entityListeners['postPersist']); - $this->assertEquals('prePersist', $metadata->entityListeners['prePersist'][0]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['prePersist'][0]['class']); + self::assertEquals('prePersist', $metadata->entityListeners['prePersist'][0]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['prePersist'][0]['class']); - $this->assertEquals('prePersist', $metadata->entityListeners['prePersist'][1]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener2::class, $metadata->entityListeners['prePersist'][1]['class']); + self::assertEquals('prePersist', $metadata->entityListeners['prePersist'][1]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener2::class, $metadata->entityListeners['prePersist'][1]['class']); - $this->assertEquals('postPersist', $metadata->entityListeners['postPersist'][0]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['postPersist'][0]['class']); + self::assertEquals('postPersist', $metadata->entityListeners['postPersist'][0]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener::class, $metadata->entityListeners['postPersist'][0]['class']); - $this->assertEquals('postPersistHandler', $metadata->entityListeners['postPersist'][1]['method']); - $this->assertEquals(AttachEntityListenersListenerTestListener2::class, $metadata->entityListeners['postPersist'][1]['class']); + self::assertEquals('postPersistHandler', $metadata->entityListeners['postPersist'][1]['method']); + self::assertEquals(AttachEntityListenersListenerTestListener2::class, $metadata->entityListeners['postPersist'][1]['class']); } public function testDuplicateEntityListenerException(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php index ce05e3bb61e..5e2b96a6543 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php @@ -20,9 +20,9 @@ public function testExecution(): void $command->setEntityGenerator($entityGenerator); $output = $this->createMock(OutputInterface::class); - $output->expects($this->once()) + $output->expects(self::once()) ->method('writeln') - ->with($this->equalTo('No Metadata Classes to process.')); + ->with(self::equalTo('No Metadata Classes to process.')); $command->convertDoctrine1Schema([], sys_get_temp_dir(), 'annotation', 4, null, $output); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php index d61386c2b92..d11f0831df7 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php @@ -23,16 +23,16 @@ public function testExecute(): void $em = $this->createMock(EntityManagerInterface::class); $configuration = $this->createMock(Configuration::class); - $configuration->expects($this->once()) + $configuration->expects(self::once()) ->method('ensureProductionSettings'); $em->method('getConfiguration') ->willReturn($configuration); - $em->expects($this->never()) + $em->expects(self::never()) ->method('getConnection'); - $this->assertSame(0, $this->executeCommand($em)); + self::assertSame(0, $this->executeCommand($em)); } public function testExecuteFailed(): void @@ -40,17 +40,17 @@ public function testExecuteFailed(): void $em = $this->createMock(EntityManagerInterface::class); $configuration = $this->createMock(Configuration::class); - $configuration->expects($this->once()) + $configuration->expects(self::once()) ->method('ensureProductionSettings') ->willThrowException(new RuntimeException()); $em->method('getConfiguration') ->willReturn($configuration); - $em->expects($this->never()) + $em->expects(self::never()) ->method('getConnection'); - $this->assertSame(1, $this->executeCommand($em)); + self::assertSame(1, $this->executeCommand($em)); } public function testExecuteWithComplete(): void @@ -58,7 +58,7 @@ public function testExecuteWithComplete(): void $em = $this->createMock(EntityManagerInterface::class); $configuration = $this->createMock(Configuration::class); - $configuration->expects($this->once()) + $configuration->expects(self::once()) ->method('ensureProductionSettings'); $em->method('getConfiguration') @@ -66,13 +66,13 @@ public function testExecuteWithComplete(): void $connection = $this->createMock(Connection::class); - $connection->expects($this->once()) + $connection->expects(self::once()) ->method('connect'); $em->method('getConnection') ->willReturn($connection); - $this->assertSame(0, $this->executeCommand($em, ['--complete' => true])); + self::assertSame(0, $this->executeCommand($em, ['--complete' => true])); } public function testExecuteWithCompleteFailed(): void @@ -80,7 +80,7 @@ public function testExecuteWithCompleteFailed(): void $em = $this->createMock(EntityManagerInterface::class); $configuration = $this->createMock(Configuration::class); - $configuration->expects($this->once()) + $configuration->expects(self::once()) ->method('ensureProductionSettings'); $em->method('getConfiguration') @@ -88,14 +88,14 @@ public function testExecuteWithCompleteFailed(): void $connection = $this->createMock(Connection::class); - $connection->expects($this->once()) + $connection->expects(self::once()) ->method('connect') ->willThrowException(new RuntimeException()); $em->method('getConnection') ->willReturn($connection); - $this->assertSame(1, $this->executeCommand($em, ['--complete' => true])); + self::assertSame(1, $this->executeCommand($em, ['--complete' => true])); } private function executeCommand( diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php index a390610b52b..19f40eb34f6 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php @@ -46,9 +46,9 @@ public function testFilterWithEmptyArray(): void $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, []); - $this->assertContains($metadataAaa, $metadatas); - $this->assertContains($metadataBbb, $metadatas); - $this->assertCount(count($originalMetadatas), $metadatas); + self::assertContains($metadataAaa, $metadatas); + self::assertContains($metadataBbb, $metadatas); + self::assertCount(count($originalMetadatas), $metadatas); } public function testFilterWithString(): void @@ -62,26 +62,26 @@ public function testFilterWithString(): void $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'MetadataFilterTestEntityAaa'); - $this->assertContains($metadataAaa, $metadatas); - $this->assertNotContains($metadataBbb, $metadatas); - $this->assertNotContains($metadataCcc, $metadatas); - $this->assertCount(1, $metadatas); + self::assertContains($metadataAaa, $metadatas); + self::assertNotContains($metadataBbb, $metadatas); + self::assertNotContains($metadataCcc, $metadatas); + self::assertCount(1, $metadatas); $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'MetadataFilterTestEntityBbb'); - $this->assertNotContains($metadataAaa, $metadatas); - $this->assertContains($metadataBbb, $metadatas); - $this->assertNotContains($metadataCcc, $metadatas); - $this->assertCount(1, $metadatas); + self::assertNotContains($metadataAaa, $metadatas); + self::assertContains($metadataBbb, $metadatas); + self::assertNotContains($metadataCcc, $metadatas); + self::assertCount(1, $metadatas); $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'MetadataFilterTestEntityCcc'); - $this->assertNotContains($metadataAaa, $metadatas); - $this->assertNotContains($metadataBbb, $metadatas); - $this->assertContains($metadataCcc, $metadatas); - $this->assertCount(1, $metadatas); + self::assertNotContains($metadataAaa, $metadatas); + self::assertNotContains($metadataBbb, $metadatas); + self::assertContains($metadataCcc, $metadatas); + self::assertCount(1, $metadatas); } public function testFilterWithString2(): void @@ -95,10 +95,10 @@ public function testFilterWithString2(): void $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'MetadataFilterTestEntityFoo'); - $this->assertContains($metadataFoo, $metadatas); - $this->assertContains($metadataFooBar, $metadatas); - $this->assertNotContains($metadataBar, $metadatas); - $this->assertCount(2, $metadatas); + self::assertContains($metadataFoo, $metadatas); + self::assertContains($metadataFooBar, $metadatas); + self::assertNotContains($metadataBar, $metadatas); + self::assertCount(2, $metadatas); } public function testFilterWithArray(): void @@ -115,10 +115,10 @@ public function testFilterWithArray(): void 'MetadataFilterTestEntityCcc', ]); - $this->assertContains($metadataAaa, $metadatas); - $this->assertNotContains($metadataBbb, $metadatas); - $this->assertContains($metadataCcc, $metadatas); - $this->assertCount(2, $metadatas); + self::assertContains($metadataAaa, $metadatas); + self::assertNotContains($metadataBbb, $metadatas); + self::assertContains($metadataCcc, $metadatas); + self::assertCount(2, $metadatas); } public function testFilterWithRegex(): void @@ -132,18 +132,18 @@ public function testFilterWithRegex(): void $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'Foo$'); - $this->assertContains($metadataFoo, $metadatas); - $this->assertNotContains($metadataFooBar, $metadatas); - $this->assertNotContains($metadataBar, $metadatas); - $this->assertCount(1, $metadatas); + self::assertContains($metadataFoo, $metadatas); + self::assertNotContains($metadataFooBar, $metadatas); + self::assertNotContains($metadataBar, $metadatas); + self::assertCount(1, $metadatas); $metadatas = $originalMetadatas; $metadatas = MetadataFilter::filter($metadatas, 'Bar$'); - $this->assertNotContains($metadataFoo, $metadatas); - $this->assertContains($metadataFooBar, $metadatas); - $this->assertContains($metadataBar, $metadatas); - $this->assertCount(2, $metadatas); + self::assertNotContains($metadataFoo, $metadatas); + self::assertContains($metadataFooBar, $metadatas); + self::assertContains($metadataBar, $metadatas); + self::assertCount(2, $metadatas); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php index 621fbc2a2cd..41a44b651af 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php @@ -45,7 +45,7 @@ protected function createEntityManager(MappingDriver $metadataDriver): EntityMan public function testTest(): void { if (! class_exists('Symfony\Component\Yaml\Yaml', true)) { - $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + self::markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); } $cme = new ClassMetadataExporter(); @@ -56,8 +56,8 @@ public function testTest(): void $exporter->setMetadata($converter->getMetadata()); $exporter->export(); - $this->assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml')); - $this->assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml')); + self::assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml')); + self::assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml')); $metadataDriver = new YamlDriver(__DIR__ . '/convert'); $em = $this->createEntityManager($metadataDriver); @@ -67,19 +67,19 @@ public function testTest(): void $profileClass = $cmf->getMetadataFor('Profile'); $userClass = $cmf->getMetadataFor('User'); - $this->assertEquals(2, count($metadata)); - $this->assertEquals('Profile', $profileClass->name); - $this->assertEquals('User', $userClass->name); - $this->assertEquals(4, count($profileClass->fieldMappings)); - $this->assertEquals(5, count($userClass->fieldMappings)); - $this->assertEquals('text', $userClass->fieldMappings['clob']['type']); - $this->assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']); - $this->assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']); + self::assertEquals(2, count($metadata)); + self::assertEquals('Profile', $profileClass->name); + self::assertEquals('User', $userClass->name); + self::assertEquals(4, count($profileClass->fieldMappings)); + self::assertEquals(5, count($userClass->fieldMappings)); + self::assertEquals('text', $userClass->fieldMappings['clob']['type']); + self::assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']); + self::assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']); - $this->assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']); - $this->assertEquals('User', $profileClass->associationMappings['User']['targetEntity']); + self::assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']); + self::assertEquals('User', $profileClass->associationMappings['User']['targetEntity']); - $this->assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]); + self::assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]); } public function tearDown(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index 9242ee82893..de1c2415bff 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -223,7 +223,7 @@ private function loadEntityClass(ClassMetadataInfo $metadata): void $className = basename(str_replace('\\', '/', $metadata->name)); $path = $this->tmpDir . '/' . $this->namespace . '/' . $className . '.php'; - $this->assertFileExists($path); + self::assertFileExists($path); require_once $path; } @@ -278,59 +278,59 @@ public function testGeneratedEntityClass(): void $metadata = $this->generateBookEntityFixture(['isbn' => $isbnMetadata]); $book = $this->newInstance($metadata); - $this->assertTrue(class_exists($metadata->name), 'Class does not exist.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', '__construct'), 'EntityGeneratorBook::__construct() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getId'), 'EntityGeneratorBook::getId() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setName'), 'EntityGeneratorBook::setName() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getName'), 'EntityGeneratorBook::getName() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setStatus'), 'EntityGeneratorBook::setStatus() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getStatus'), 'EntityGeneratorBook::getStatus() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), 'EntityGeneratorBook::setAuthor() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), 'EntityGeneratorBook::getAuthor() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), 'EntityGeneratorBook::getComments() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addComment'), 'EntityGeneratorBook::addComment() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'removeComment'), 'EntityGeneratorBook::removeComment() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setIsbn'), 'EntityGeneratorBook::setIsbn() missing.'); - $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getIsbn'), 'EntityGeneratorBook::getIsbn() missing.'); + self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', '__construct'), 'EntityGeneratorBook::__construct() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getId'), 'EntityGeneratorBook::getId() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setName'), 'EntityGeneratorBook::setName() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getName'), 'EntityGeneratorBook::getName() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setStatus'), 'EntityGeneratorBook::setStatus() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getStatus'), 'EntityGeneratorBook::getStatus() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), 'EntityGeneratorBook::setAuthor() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), 'EntityGeneratorBook::getAuthor() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), 'EntityGeneratorBook::getComments() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addComment'), 'EntityGeneratorBook::addComment() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'removeComment'), 'EntityGeneratorBook::removeComment() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setIsbn'), 'EntityGeneratorBook::setIsbn() missing.'); + self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getIsbn'), 'EntityGeneratorBook::getIsbn() missing.'); $reflClass = new ReflectionClass($metadata->name); - $this->assertCount(6, $reflClass->getProperties()); - $this->assertCount(15, $reflClass->getMethods()); + self::assertCount(6, $reflClass->getProperties()); + self::assertCount(15, $reflClass->getMethods()); - $this->assertEquals('published', $book->getStatus()); + self::assertEquals('published', $book->getStatus()); $book->setName('Jonathan H. Wage'); - $this->assertEquals('Jonathan H. Wage', $book->getName()); + self::assertEquals('Jonathan H. Wage', $book->getName()); $reflMethod = new ReflectionMethod($metadata->name, 'addComment'); $addCommentParameters = $reflMethod->getParameters(); - $this->assertEquals('comment', $addCommentParameters[0]->getName()); + self::assertEquals('comment', $addCommentParameters[0]->getName()); $reflMethod = new ReflectionMethod($metadata->name, 'removeComment'); $removeCommentParameters = $reflMethod->getParameters(); - $this->assertEquals('comment', $removeCommentParameters[0]->getName()); + self::assertEquals('comment', $removeCommentParameters[0]->getName()); $author = new EntityGeneratorAuthor(); $book->setAuthor($author); - $this->assertEquals($author, $book->getAuthor()); + self::assertEquals($author, $book->getAuthor()); $comment = new EntityGeneratorComment(); - $this->assertInstanceOf($metadata->name, $book->addComment($comment)); - $this->assertInstanceOf(ArrayCollection::class, $book->getComments()); - $this->assertEquals(new ArrayCollection([$comment]), $book->getComments()); - $this->assertIsBool($book->removeComment($comment)); - $this->assertEquals(new ArrayCollection([]), $book->getComments()); + self::assertInstanceOf($metadata->name, $book->addComment($comment)); + self::assertInstanceOf(ArrayCollection::class, $book->getComments()); + self::assertEquals(new ArrayCollection([$comment]), $book->getComments()); + self::assertIsBool($book->removeComment($comment)); + self::assertEquals(new ArrayCollection([]), $book->getComments()); $this->newInstance($isbnMetadata); $isbn = new $isbnMetadata->name(); $book->setIsbn($isbn); - $this->assertSame($isbn, $book->getIsbn()); + self::assertSame($isbn, $book->getIsbn()); $reflMethod = new ReflectionMethod($metadata->name, 'setIsbn'); $reflParameters = $reflMethod->getParameters(); - $this->assertEquals($isbnMetadata->name, $reflParameters[0]->getType()->getName()); + self::assertEquals($isbnMetadata->name, $reflParameters[0]->getType()->getName()); } public function testBooleanDefaultValue(): void @@ -344,12 +344,12 @@ public function testBooleanDefaultValue(): void $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); $book = $this->newInstance($metadata); $reflClass = new ReflectionClass($metadata->name); - $this->assertTrue($book->getfoo()); + self::assertTrue($book->getfoo()); } public function testEntityUpdatingWorks(): void @@ -363,31 +363,31 @@ public function testEntityUpdatingWorks(): void $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); $book = $this->newInstance($metadata); $reflClass = new ReflectionClass($metadata->name); - $this->assertTrue($reflClass->hasProperty('name'), "Regenerating keeps property 'name'."); - $this->assertTrue($reflClass->hasProperty('status'), "Regenerating keeps property 'status'."); - $this->assertTrue($reflClass->hasProperty('id'), "Regenerating keeps property 'id'."); - $this->assertTrue($reflClass->hasProperty('isbn'), "Regenerating keeps property 'isbn'."); - - $this->assertTrue($reflClass->hasProperty('test'), 'Check for property test failed.'); - $this->assertTrue($reflClass->getProperty('test')->isProtected(), 'Check for protected property test failed.'); - $this->assertTrue($reflClass->hasProperty('testEmbedded'), 'Check for property testEmbedded failed.'); - $this->assertTrue($reflClass->getProperty('testEmbedded')->isProtected(), 'Check for protected property testEmbedded failed.'); - $this->assertTrue($reflClass->hasMethod('getTest'), "Check for method 'getTest' failed."); - $this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); - $this->assertTrue($reflClass->hasMethod('setTest'), "Check for method 'setTest' failed."); - $this->assertTrue($reflClass->getMethod('setTest')->isPublic(), "Check for public visibility of method 'setTest' failed."); - $this->assertTrue($reflClass->hasMethod('getTestEmbedded'), "Check for method 'getTestEmbedded' failed."); - $this->assertTrue( + self::assertTrue($reflClass->hasProperty('name'), "Regenerating keeps property 'name'."); + self::assertTrue($reflClass->hasProperty('status'), "Regenerating keeps property 'status'."); + self::assertTrue($reflClass->hasProperty('id'), "Regenerating keeps property 'id'."); + self::assertTrue($reflClass->hasProperty('isbn'), "Regenerating keeps property 'isbn'."); + + self::assertTrue($reflClass->hasProperty('test'), 'Check for property test failed.'); + self::assertTrue($reflClass->getProperty('test')->isProtected(), 'Check for protected property test failed.'); + self::assertTrue($reflClass->hasProperty('testEmbedded'), 'Check for property testEmbedded failed.'); + self::assertTrue($reflClass->getProperty('testEmbedded')->isProtected(), 'Check for protected property testEmbedded failed.'); + self::assertTrue($reflClass->hasMethod('getTest'), "Check for method 'getTest' failed."); + self::assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); + self::assertTrue($reflClass->hasMethod('setTest'), "Check for method 'setTest' failed."); + self::assertTrue($reflClass->getMethod('setTest')->isPublic(), "Check for public visibility of method 'setTest' failed."); + self::assertTrue($reflClass->hasMethod('getTestEmbedded'), "Check for method 'getTestEmbedded' failed."); + self::assertTrue( $reflClass->getMethod('getTestEmbedded')->isPublic(), "Check for public visibility of method 'getTestEmbedded' failed." ); - $this->assertTrue($reflClass->hasMethod('setTestEmbedded'), "Check for method 'setTestEmbedded' failed."); - $this->assertTrue( + self::assertTrue($reflClass->hasMethod('setTestEmbedded'), "Check for method 'setTestEmbedded' failed."); + self::assertTrue( $reflClass->getMethod('setTestEmbedded')->isPublic(), "Check for public visibility of method 'setTestEmbedded' failed." ); @@ -408,19 +408,19 @@ public function testDoesNotRegenerateExistingMethodsWithDifferentCase(): void // Should not throw a PHP fatal error $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); $this->newInstance($metadata); $reflClass = new ReflectionClass($metadata->name); - $this->assertTrue($reflClass->hasProperty('status')); - $this->assertTrue($reflClass->hasProperty('STATUS')); - $this->assertTrue($reflClass->hasProperty('isbn')); - $this->assertTrue($reflClass->hasProperty('ISBN')); - $this->assertTrue($reflClass->hasMethod('getStatus')); - $this->assertTrue($reflClass->hasMethod('setStatus')); - $this->assertTrue($reflClass->hasMethod('getIsbn')); - $this->assertTrue($reflClass->hasMethod('setIsbn')); + self::assertTrue($reflClass->hasProperty('status')); + self::assertTrue($reflClass->hasProperty('STATUS')); + self::assertTrue($reflClass->hasProperty('isbn')); + self::assertTrue($reflClass->hasProperty('ISBN')); + self::assertTrue($reflClass->hasMethod('getStatus')); + self::assertTrue($reflClass->hasMethod('setStatus')); + self::assertTrue($reflClass->hasMethod('getIsbn')); + self::assertTrue($reflClass->hasMethod('setIsbn')); } /** @@ -455,11 +455,11 @@ public function testEntityExtendsStdClass(): void $metadata = $this->generateBookEntityFixture(); $book = $this->newInstance($metadata); - $this->assertInstanceOf('stdClass', $book); + self::assertInstanceOf('stdClass', $book); $metadata = $this->generateIsbnEmbeddableFixture(); $isbn = $this->newInstance($metadata); - $this->assertInstanceOf('stdClass', $isbn); + self::assertInstanceOf('stdClass', $isbn); } public function testLifecycleCallbacks(): void @@ -469,8 +469,8 @@ public function testLifecycleCallbacks(): void $book = $this->newInstance($metadata); $reflClass = new ReflectionClass($metadata->name); - $this->assertTrue($reflClass->hasMethod('loading'), 'Check for postLoad lifecycle callback.'); - $this->assertTrue($reflClass->hasMethod('willBeRemoved'), 'Check for preRemove lifecycle callback.'); + self::assertTrue($reflClass->hasMethod('loading'), 'Check for postLoad lifecycle callback.'); + self::assertTrue($reflClass->hasMethod('willBeRemoved'), 'Check for preRemove lifecycle callback.'); } public function testLoadMetadata(): void @@ -488,16 +488,16 @@ public function testLoadMetadata(): void $driver = $this->createAnnotationDriver(); $driver->loadMetadataForClass($cm->name, $cm); - $this->assertEquals($cm->columnNames, $metadata->columnNames); - $this->assertEquals($cm->getTableName(), $metadata->getTableName()); - $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); - $this->assertEquals($cm->identifier, $metadata->identifier); - $this->assertEquals($cm->idGenerator, $metadata->idGenerator); - $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); - $this->assertEquals($cm->embeddedClasses, $metadata->embeddedClasses); - $this->assertEquals($cm->isEmbeddedClass, $metadata->isEmbeddedClass); + self::assertEquals($cm->columnNames, $metadata->columnNames); + self::assertEquals($cm->getTableName(), $metadata->getTableName()); + self::assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); + self::assertEquals($cm->identifier, $metadata->identifier); + self::assertEquals($cm->idGenerator, $metadata->idGenerator); + self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); + self::assertEquals($cm->embeddedClasses, $metadata->embeddedClasses); + self::assertEquals($cm->isEmbeddedClass, $metadata->isEmbeddedClass); - $this->assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']); + self::assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']); $isbn = $this->newInstance($embeddedMetadata); @@ -506,9 +506,9 @@ public function testLoadMetadata(): void $driver->loadMetadataForClass($cm->name, $cm); - $this->assertEquals($cm->columnNames, $embeddedMetadata->columnNames); - $this->assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); - $this->assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); + self::assertEquals($cm->columnNames, $embeddedMetadata->columnNames); + self::assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); + self::assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); } public function testLoadPrefixedMetadata(): void @@ -529,12 +529,12 @@ public function testLoadPrefixedMetadata(): void $driver->loadMetadataForClass($cm->name, $cm); - $this->assertEquals($cm->columnNames, $metadata->columnNames); - $this->assertEquals($cm->getTableName(), $metadata->getTableName()); - $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); - $this->assertEquals($cm->identifier, $metadata->identifier); - $this->assertEquals($cm->idGenerator, $metadata->idGenerator); - $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); + self::assertEquals($cm->columnNames, $metadata->columnNames); + self::assertEquals($cm->getTableName(), $metadata->getTableName()); + self::assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); + self::assertEquals($cm->identifier, $metadata->identifier); + self::assertEquals($cm->idGenerator, $metadata->idGenerator); + self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); $isbn = $this->newInstance($embeddedMetadata); @@ -543,9 +543,9 @@ public function testLoadPrefixedMetadata(): void $driver->loadMetadataForClass($cm->name, $cm); - $this->assertEquals($cm->columnNames, $embeddedMetadata->columnNames); - $this->assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); - $this->assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); + self::assertEquals($cm->columnNames, $embeddedMetadata->columnNames); + self::assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); + self::assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); } /** @@ -567,7 +567,7 @@ public function testMappedSuperclassAnnotationGeneration(): void $cm->initializeReflection(new RuntimeReflectionService()); $driver->loadMetadataForClass($cm->name, $cm); - $this->assertTrue($cm->isMappedSuperclass); + self::assertTrue($cm->isMappedSuperclass); } /** @@ -583,7 +583,7 @@ public function testParseTokensInEntityFile($php, $classes): void $p->setAccessible(true); $ret = $m->invoke($this->generator, $php); - $this->assertEquals($classes, array_keys($p->getValue($this->generator))); + self::assertEquals($classes, array_keys($p->getValue($this->generator))); } /** @@ -607,16 +607,16 @@ public function testGenerateEntityWithSequenceGenerator(): void $filename = $this->tmpDir . DIRECTORY_SEPARATOR . $this->namespace . DIRECTORY_SEPARATOR . 'DDC1784Entity.php'; - $this->assertFileExists($filename); + self::assertFileExists($filename); require_once $filename; $reflection = new ReflectionProperty($metadata->name, 'id'); $docComment = $reflection->getDocComment(); - $this->assertStringContainsString('@ORM\Id', $docComment); - $this->assertStringContainsString('@ORM\Column(name="id", type="integer")', $docComment); - $this->assertStringContainsString('@ORM\GeneratedValue(strategy="SEQUENCE")', $docComment); - $this->assertStringContainsString( + self::assertStringContainsString('@ORM\Id', $docComment); + self::assertStringContainsString('@ORM\Column(name="id", type="integer")', $docComment); + self::assertStringContainsString('@ORM\GeneratedValue(strategy="SEQUENCE")', $docComment); + self::assertStringContainsString( '@ORM\SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment ); @@ -653,27 +653,27 @@ public function testGenerateEntityWithMultipleInverseJoinColumns(): void $filename = $this->tmpDir . DIRECTORY_SEPARATOR . $this->namespace . DIRECTORY_SEPARATOR . 'DDC2079Entity.php'; - $this->assertFileExists($filename); + self::assertFileExists($filename); require_once $filename; $property = new ReflectionProperty($metadata->name, 'centroCustos'); $docComment = $property->getDocComment(); //joinColumns - $this->assertStringContainsString( + self::assertStringContainsString( '@ORM\JoinColumn(name="idorcamento", referencedColumnName="idorcamento"),', $docComment ); - $this->assertStringContainsString( + self::assertStringContainsString( '@ORM\JoinColumn(name="idunidade", referencedColumnName="idunidade")', $docComment ); //inverseJoinColumns - $this->assertStringContainsString( + self::assertStringContainsString( '@ORM\JoinColumn(name="idcentrocusto", referencedColumnName="idcentrocusto"),', $docComment ); - $this->assertStringContainsString( + self::assertStringContainsString( '@ORM\JoinColumn(name="idpais", referencedColumnName="idpais")', $docComment ); @@ -699,7 +699,7 @@ public function testGetInheritanceTypeString(): void $expected = preg_replace($pattern, '', $name); $actual = $method->invoke($this->generator, $value); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } $this->expectException(InvalidArgumentException::class); @@ -728,7 +728,7 @@ public function testGetChangeTrackingPolicyString(): void $expected = preg_replace($pattern, '', $name); $actual = $method->invoke($this->generator, $value); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } $this->expectException(InvalidArgumentException::class); @@ -757,7 +757,7 @@ public function testGetIdGeneratorTypeString(): void $expected = preg_replace($pattern, '', $name); $actual = $method->invoke($this->generator, $value); - $this->assertEquals($expected, $actual); + self::assertEquals($expected, $actual); } $this->expectException(InvalidArgumentException::class); @@ -775,7 +775,7 @@ public function testEntityTypeAlias(array $field): void $metadata = $this->generateEntityTypeFixture($field); $path = $this->tmpDir . '/' . $this->namespace . '/EntityType.php'; - $this->assertFileExists($path); + self::assertFileExists($path); require_once $path; $entity = new $metadata->name(); @@ -791,8 +791,8 @@ public function testEntityTypeAlias(array $field): void $this->assertPhpDocParamType($type, $reflClass->getMethod($setter)); $this->assertPhpDocReturnType($type, $reflClass->getMethod($getter)); - $this->assertSame($entity, $entity->{$setter}($value)); - $this->assertEquals($value, $entity->{$getter}()); + self::assertSame($entity, $entity->{$setter}($value)); + self::assertEquals($value, $entity->{$getter}()); } /** @@ -811,14 +811,14 @@ public function testTraitPropertiesAndMethodsAreNotDuplicated(): void $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372User.php'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372User.php'); require $this->tmpDir . '/' . $this->namespace . '/DDC2372User.php'; $reflClass = new ReflectionClass($metadata->name); - $this->assertSame($reflClass->hasProperty('address'), false); - $this->assertSame($reflClass->hasMethod('setAddress'), false); - $this->assertSame($reflClass->hasMethod('getAddress'), false); + self::assertSame($reflClass->hasProperty('address'), false); + self::assertSame($reflClass->hasMethod('setAddress'), false); + self::assertSame($reflClass->hasMethod('getAddress'), false); } /** @@ -837,14 +837,14 @@ public function testTraitPropertiesAndMethodsAreNotDuplicatedInChildClasses(): v $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372Admin.php'); + self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372Admin.php'); require $this->tmpDir . '/' . $this->namespace . '/DDC2372Admin.php'; $reflClass = new ReflectionClass($metadata->name); - $this->assertSame($reflClass->hasProperty('address'), false); - $this->assertSame($reflClass->hasMethod('setAddress'), false); - $this->assertSame($reflClass->hasMethod('getAddress'), false); + self::assertSame($reflClass->hasProperty('address'), false); + self::assertSame($reflClass->hasMethod('setAddress'), false); + self::assertSame($reflClass->hasMethod('getAddress'), false); } /** @@ -891,30 +891,30 @@ public function testMethodsAndPropertiesAreNotDuplicatedInChildClasses(): void // class _DDC1590User extends DDC1590Entity { ... } $rc2 = new ReflectionClass($ns . '\_DDC1590User'); - $this->assertTrue($rc2->hasProperty('name')); - $this->assertTrue($rc2->hasProperty('id')); - $this->assertTrue($rc2->hasProperty('createdAt')); + self::assertTrue($rc2->hasProperty('name')); + self::assertTrue($rc2->hasProperty('id')); + self::assertTrue($rc2->hasProperty('createdAt')); - $this->assertTrue($rc2->hasMethod('getName')); - $this->assertTrue($rc2->hasMethod('setName')); - $this->assertTrue($rc2->hasMethod('getId')); - $this->assertFalse($rc2->hasMethod('setId')); - $this->assertTrue($rc2->hasMethod('getCreatedAt')); - $this->assertTrue($rc2->hasMethod('setCreatedAt')); + self::assertTrue($rc2->hasMethod('getName')); + self::assertTrue($rc2->hasMethod('setName')); + self::assertTrue($rc2->hasMethod('getId')); + self::assertFalse($rc2->hasMethod('setId')); + self::assertTrue($rc2->hasMethod('getCreatedAt')); + self::assertTrue($rc2->hasMethod('setCreatedAt')); // class __DDC1590User { ... } $rc3 = new ReflectionClass($ns . '\__DDC1590User'); - $this->assertTrue($rc3->hasProperty('name')); - $this->assertFalse($rc3->hasProperty('id')); - $this->assertFalse($rc3->hasProperty('createdAt')); + self::assertTrue($rc3->hasProperty('name')); + self::assertFalse($rc3->hasProperty('id')); + self::assertFalse($rc3->hasProperty('createdAt')); - $this->assertTrue($rc3->hasMethod('getName')); - $this->assertTrue($rc3->hasMethod('setName')); - $this->assertFalse($rc3->hasMethod('getId')); - $this->assertFalse($rc3->hasMethod('setId')); - $this->assertFalse($rc3->hasMethod('getCreatedAt')); - $this->assertFalse($rc3->hasMethod('setCreatedAt')); + self::assertTrue($rc3->hasMethod('getName')); + self::assertTrue($rc3->hasMethod('setName')); + self::assertFalse($rc3->hasMethod('getId')); + self::assertFalse($rc3->hasMethod('setId')); + self::assertFalse($rc3->hasMethod('getCreatedAt')); + self::assertFalse($rc3->hasMethod('setCreatedAt')); } /** @@ -927,33 +927,33 @@ public function testGeneratedMutableEmbeddablesClass(): void $isbn = $this->newInstance($metadata); - $this->assertTrue(class_exists($metadata->name), 'Class does not exist.'); - $this->assertFalse(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct present.'); - $this->assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() missing.'); - $this->assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); - $this->assertTrue(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() missing.'); + self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); + self::assertFalse(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct present.'); + self::assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); + self::assertTrue(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() missing.'); + self::assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() missing.'); + self::assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); + self::assertTrue(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() missing.'); + self::assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); + self::assertTrue(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() missing.'); $isbn->setPrefix(978); - $this->assertSame(978, $isbn->getPrefix()); + self::assertSame(978, $isbn->getPrefix()); $this->newInstance($embeddedMetadata); $test = new $embeddedMetadata->name(); $isbn->setTest($test); - $this->assertSame($test, $isbn->getTest()); + self::assertSame($test, $isbn->getTest()); $reflMethod = new ReflectionMethod($metadata->name, 'setTest'); $reflParameters = $reflMethod->getParameters(); - $this->assertEquals($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); + self::assertEquals($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); } /** @@ -968,20 +968,20 @@ public function testGeneratedImmutableEmbeddablesClass(): void $this->loadEntityClass($embeddedMetadata); $this->loadEntityClass($metadata); - $this->assertTrue(class_exists($metadata->name), 'Class does not exist.'); - $this->assertTrue(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct missing.'); - $this->assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() present.'); - $this->assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() present.'); - $this->assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() present.'); - $this->assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() present.'); - $this->assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() present.'); - $this->assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); - $this->assertFalse(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() present.'); + self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); + self::assertTrue(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct missing.'); + self::assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); + self::assertFalse(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() present.'); + self::assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); + self::assertFalse(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() present.'); + self::assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); + self::assertFalse(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() present.'); + self::assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); + self::assertFalse(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() present.'); + self::assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); + self::assertFalse(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() present.'); + self::assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); + self::assertFalse(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() present.'); $test = new $embeddedMetadata->name(1, new DateTime()); $isbn = new $metadata->name($test, 978, 3, 12, 732320, 83); @@ -989,45 +989,45 @@ public function testGeneratedImmutableEmbeddablesClass(): void $reflMethod = new ReflectionMethod($isbn, '__construct'); $reflParameters = $reflMethod->getParameters(); - $this->assertCount(6, $reflParameters); + self::assertCount(6, $reflParameters); - $this->assertSame($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); - $this->assertSame('test', $reflParameters[0]->getName()); - $this->assertFalse($reflParameters[0]->isOptional()); + self::assertSame($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); + self::assertSame('test', $reflParameters[0]->getName()); + self::assertFalse($reflParameters[0]->isOptional()); - $this->assertSame('prefix', $reflParameters[1]->getName()); - $this->assertFalse($reflParameters[1]->isOptional()); + self::assertSame('prefix', $reflParameters[1]->getName()); + self::assertFalse($reflParameters[1]->isOptional()); - $this->assertSame('groupNumber', $reflParameters[2]->getName()); - $this->assertFalse($reflParameters[2]->isOptional()); + self::assertSame('groupNumber', $reflParameters[2]->getName()); + self::assertFalse($reflParameters[2]->isOptional()); - $this->assertSame('publisherNumber', $reflParameters[3]->getName()); - $this->assertFalse($reflParameters[3]->isOptional()); + self::assertSame('publisherNumber', $reflParameters[3]->getName()); + self::assertFalse($reflParameters[3]->isOptional()); - $this->assertSame('titleNumber', $reflParameters[4]->getName()); - $this->assertFalse($reflParameters[4]->isOptional()); + self::assertSame('titleNumber', $reflParameters[4]->getName()); + self::assertFalse($reflParameters[4]->isOptional()); - $this->assertSame('checkDigit', $reflParameters[5]->getName()); - $this->assertFalse($reflParameters[5]->isOptional()); + self::assertSame('checkDigit', $reflParameters[5]->getName()); + self::assertFalse($reflParameters[5]->isOptional()); $reflMethod = new ReflectionMethod($test, '__construct'); $reflParameters = $reflMethod->getParameters(); - $this->assertCount(4, $reflParameters); + self::assertCount(4, $reflParameters); - $this->assertSame('field1', $reflParameters[0]->getName()); - $this->assertFalse($reflParameters[0]->isOptional()); + self::assertSame('field1', $reflParameters[0]->getName()); + self::assertFalse($reflParameters[0]->isOptional()); - $this->assertSame('DateTime', $reflParameters[1]->getType()->getName()); - $this->assertSame('field3', $reflParameters[1]->getName()); - $this->assertFalse($reflParameters[1]->isOptional()); + self::assertSame('DateTime', $reflParameters[1]->getType()->getName()); + self::assertSame('field3', $reflParameters[1]->getName()); + self::assertFalse($reflParameters[1]->isOptional()); - $this->assertSame('field2', $reflParameters[2]->getName()); - $this->assertTrue($reflParameters[2]->isOptional()); + self::assertSame('field2', $reflParameters[2]->getName()); + self::assertTrue($reflParameters[2]->isOptional()); - $this->assertSame('DateTime', $reflParameters[3]->getType()->getName()); - $this->assertSame('field4', $reflParameters[3]->getName()); - $this->assertTrue($reflParameters[3]->isOptional()); + self::assertSame('DateTime', $reflParameters[3]->getType()->getName()); + self::assertSame('field4', $reflParameters[3]->getName()); + self::assertTrue($reflParameters[3]->isOptional()); } public function testRegenerateEntityClass(): void @@ -1045,7 +1045,7 @@ public function testRegenerateEntityClass(): void $this->generator->writeEntityClass($metadata, $this->tmpDir); $classNew = file_get_contents($path); - $this->assertSame($classTest, $classNew); + self::assertSame($classTest, $classNew); } /** @@ -1201,9 +1201,9 @@ private function assertPhpDocVarType(string $type, ReflectionProperty $property) $docComment = $property->getDocComment(); $regex = '/@var\s+([\S]+)$/m'; - $this->assertMatchesRegularExpression($regex, $docComment); - $this->assertEquals(1, preg_match($regex, $docComment, $matches)); - $this->assertEquals($type, $matches[1]); + self::assertMatchesRegularExpression($regex, $docComment); + self::assertEquals(1, preg_match($regex, $docComment, $matches)); + self::assertEquals($type, $matches[1]); } private function assertPhpDocReturnType(string $type, ReflectionMethod $method): void @@ -1211,15 +1211,15 @@ private function assertPhpDocReturnType(string $type, ReflectionMethod $method): $docComment = $method->getDocComment(); $regex = '/@return\s+([\S]+)(\s+.*)$/m'; - $this->assertMatchesRegularExpression($regex, $docComment); - $this->assertEquals(1, preg_match($regex, $docComment, $matches)); - $this->assertEquals($type, $matches[1]); + self::assertMatchesRegularExpression($regex, $docComment); + self::assertEquals(1, preg_match($regex, $docComment, $matches)); + self::assertEquals($type, $matches[1]); } private function assertPhpDocParamType(string $type, ReflectionMethod $method): void { - $this->assertEquals(1, preg_match('/@param\s+([^\s]+)/', $method->getDocComment(), $matches)); - $this->assertEquals($type, $matches[1]); + self::assertEquals(1, preg_match('/@param\s+([^\s]+)/', $method->getDocComment(), $matches)); + self::assertEquals($type, $matches[1]); } /** diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php index f249416c7e8..a4ef2f1edf2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php @@ -94,15 +94,15 @@ public function testGeneratedEntityRepositoryClass(): void $rpath = $this->writeRepositoryClass($className); - $this->assertFileExists($rpath); + self::assertFileExists($rpath); require $rpath; $repo = new ReflectionClass($em->getRepository($className)); - $this->assertTrue($repo->inNamespace()); - $this->assertSame($className . 'Repository', $repo->getName()); - $this->assertSame(EntityRepository::class, $repo->getParentClass()->getName()); + self::assertTrue($repo->inNamespace()); + self::assertSame($className . 'Repository', $repo->getName()); + self::assertSame(EntityRepository::class, $repo->getParentClass()->getName()); require_once __DIR__ . '/../../Models/DDC3231/DDC3231User1NoNamespace.php'; @@ -111,15 +111,15 @@ public function testGeneratedEntityRepositoryClass(): void $rpath2 = $this->writeRepositoryClass($className2); - $this->assertFileExists($rpath2); + self::assertFileExists($rpath2); require $rpath2; $repo2 = new ReflectionClass($em->getRepository($className2)); - $this->assertFalse($repo2->inNamespace()); - $this->assertSame($className2 . 'Repository', $repo2->getName()); - $this->assertSame(EntityRepository::class, $repo2->getParentClass()->getName()); + self::assertFalse($repo2->inNamespace()); + self::assertSame($className2 . 'Repository', $repo2->getName()); + self::assertSame(EntityRepository::class, $repo2->getParentClass()->getName()); } /** @@ -135,16 +135,16 @@ public function testGeneratedEntityRepositoryClassCustomDefaultRepository(): voi $rpath = $this->writeRepositoryClass($className, DDC3231EntityRepository::class); - $this->assertNotNull($rpath); - $this->assertFileExists($rpath); + self::assertNotNull($rpath); + self::assertFileExists($rpath); require $rpath; $repo = new ReflectionClass($em->getRepository($className)); - $this->assertTrue($repo->inNamespace()); - $this->assertSame($className . 'Repository', $repo->getName()); - $this->assertSame(DDC3231EntityRepository::class, $repo->getParentClass()->getName()); + self::assertTrue($repo->inNamespace()); + self::assertSame($className . 'Repository', $repo->getName()); + self::assertSame(DDC3231EntityRepository::class, $repo->getParentClass()->getName()); require_once __DIR__ . '/../../Models/DDC3231/DDC3231User2NoNamespace.php'; @@ -153,16 +153,16 @@ public function testGeneratedEntityRepositoryClassCustomDefaultRepository(): voi $rpath2 = $this->writeRepositoryClass($className2, DDC3231EntityRepository::class); - $this->assertNotNull($rpath2); - $this->assertFileExists($rpath2); + self::assertNotNull($rpath2); + self::assertFileExists($rpath2); require $rpath2; $repo2 = new ReflectionClass($em->getRepository($className2)); - $this->assertFalse($repo2->inNamespace()); - $this->assertSame($className2 . 'Repository', $repo2->getName()); - $this->assertSame(DDC3231EntityRepository::class, $repo2->getParentClass()->getName()); + self::assertFalse($repo2->inNamespace()); + self::assertSame($className2 . 'Repository', $repo2->getName()); + self::assertSame(DDC3231EntityRepository::class, $repo2->getParentClass()->getName()); } private function writeEntityClass(string $className, string $newClassName): void diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php index c863464746a..a2bc8a77675 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php @@ -73,7 +73,7 @@ protected function createMetadataDriver(string $type, string $path): MappingDriv 'yaml' => YamlDriver::class, ]; - $this->assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'."); + self::assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'."); $class = $mappingDriver[$type]; @@ -105,7 +105,7 @@ public function testExportDirectoryAndFilesAreCreated(): void $metadata[0]->name = ExportedUser::class; - $this->assertEquals(ExportedUser::class, $metadata[0]->name); + self::assertEquals(ExportedUser::class, $metadata[0]->name); $type = $this->getType(); $cme = new ClassMetadataExporter(); @@ -123,9 +123,9 @@ public function testExportDirectoryAndFilesAreCreated(): void $exporter->export(); if ($type === 'annotation') { - $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/' . str_replace('\\', '/', ExportedUser::class) . $this->extension)); + self::assertTrue(file_exists(__DIR__ . '/export/' . $type . '/' . str_replace('\\', '/', ExportedUser::class) . $this->extension)); } else { - $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser' . $this->extension)); + self::assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser' . $this->extension)); } } @@ -141,11 +141,11 @@ public function testExportedMetadataCanBeReadBackIn(): ClassMetadataInfo $cmf = $this->createClassMetadataFactory($em, $type); $metadata = $cmf->getAllMetadata(); - $this->assertEquals(1, count($metadata)); + self::assertEquals(1, count($metadata)); $class = current($metadata); - $this->assertEquals(ExportedUser::class, $class->name); + self::assertEquals(ExportedUser::class, $class->name); return $class; } @@ -155,8 +155,8 @@ public function testExportedMetadataCanBeReadBackIn(): ClassMetadataInfo */ public function testTableIsExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertEquals('cms_users', $class->table['name']); - $this->assertEquals( + self::assertEquals('cms_users', $class->table['name']); + self::assertEquals( ['engine' => 'MyISAM', 'foo' => ['bar' => 'baz']], $class->table['options'] ); @@ -169,7 +169,7 @@ public function testTableIsExported(ClassMetadataInfo $class): ClassMetadataInfo */ public function testTypeIsExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertFalse($class->isMappedSuperclass); + self::assertFalse($class->isMappedSuperclass); return $class; } @@ -179,9 +179,9 @@ public function testTypeIsExported(ClassMetadataInfo $class): ClassMetadataInfo */ public function testIdentifierIsExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY, $class->generatorType, 'Generator Type wrong'); - $this->assertEquals(['id'], $class->identifier); - $this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); + self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY, $class->generatorType, 'Generator Type wrong'); + self::assertEquals(['id'], $class->identifier); + self::assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); return $class; } @@ -191,22 +191,22 @@ public function testIdentifierIsExported(ClassMetadataInfo $class): ClassMetadat */ public function testFieldsAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); - $this->assertEquals('id', $class->fieldMappings['id']['fieldName']); - $this->assertEquals('integer', $class->fieldMappings['id']['type']); - $this->assertEquals('id', $class->fieldMappings['id']['columnName']); + self::assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); + self::assertEquals('id', $class->fieldMappings['id']['fieldName']); + self::assertEquals('integer', $class->fieldMappings['id']['type']); + self::assertEquals('id', $class->fieldMappings['id']['columnName']); - $this->assertEquals('name', $class->fieldMappings['name']['fieldName']); - $this->assertEquals('string', $class->fieldMappings['name']['type']); - $this->assertEquals(50, $class->fieldMappings['name']['length']); - $this->assertEquals('name', $class->fieldMappings['name']['columnName']); + self::assertEquals('name', $class->fieldMappings['name']['fieldName']); + self::assertEquals('string', $class->fieldMappings['name']['type']); + self::assertEquals(50, $class->fieldMappings['name']['length']); + self::assertEquals('name', $class->fieldMappings['name']['columnName']); - $this->assertEquals('email', $class->fieldMappings['email']['fieldName']); - $this->assertEquals('string', $class->fieldMappings['email']['type']); - $this->assertEquals('user_email', $class->fieldMappings['email']['columnName']); - $this->assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); + self::assertEquals('email', $class->fieldMappings['email']['fieldName']); + self::assertEquals('string', $class->fieldMappings['email']['type']); + self::assertEquals('user_email', $class->fieldMappings['email']['columnName']); + self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); - $this->assertEquals(true, $class->fieldMappings['age']['options']['unsigned']); + self::assertEquals(true, $class->fieldMappings['age']['options']['unsigned']); return $class; } @@ -223,12 +223,12 @@ public function testFieldsAreProperlySerialized(): void $xml->registerXPathNamespace('d', 'http://doctrine-project.org/schemas/orm/doctrine-mapping'); $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @nullable='true']"); - $this->assertEquals(1, count($nodes)); + self::assertEquals(1, count($nodes)); $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @unique='true']"); - $this->assertEquals(1, count($nodes)); + self::assertEquals(1, count($nodes)); } else { - $this->markTestSkipped('Test not available for ' . $type . ' driver'); + self::markTestSkipped('Test not available for ' . $type . ' driver'); } } @@ -237,19 +237,19 @@ public function testFieldsAreProperlySerialized(): void */ public function testOneToOneAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->associationMappings['address'])); - $this->assertEquals(Address::class, $class->associationMappings['address']['targetEntity']); - $this->assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); - - $this->assertTrue($class->associationMappings['address']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['address']['isCascadePersist']); - $this->assertFalse($class->associationMappings['address']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['address']['isCascadeMerge']); - $this->assertFalse($class->associationMappings['address']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['address']['orphanRemoval']); - $this->assertEquals(ClassMetadataInfo::FETCH_EAGER, $class->associationMappings['address']['fetch']); + self::assertTrue(isset($class->associationMappings['address'])); + self::assertEquals(Address::class, $class->associationMappings['address']['targetEntity']); + self::assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']); + self::assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); + + self::assertTrue($class->associationMappings['address']['isCascadeRemove']); + self::assertTrue($class->associationMappings['address']['isCascadePersist']); + self::assertFalse($class->associationMappings['address']['isCascadeRefresh']); + self::assertFalse($class->associationMappings['address']['isCascadeMerge']); + self::assertFalse($class->associationMappings['address']['isCascadeDetach']); + self::assertTrue($class->associationMappings['address']['orphanRemoval']); + self::assertEquals(ClassMetadataInfo::FETCH_EAGER, $class->associationMappings['address']['fetch']); return $class; } @@ -259,8 +259,8 @@ public function testOneToOneAssociationsAreExported(ClassMetadataInfo $class): C */ public function testManyToOneAssociationsAreExported($class): void { - $this->assertTrue(isset($class->associationMappings['mainGroup'])); - $this->assertEquals(Group::class, $class->associationMappings['mainGroup']['targetEntity']); + self::assertTrue(isset($class->associationMappings['mainGroup'])); + self::assertEquals(Group::class, $class->associationMappings['mainGroup']['targetEntity']); } /** @@ -268,18 +268,18 @@ public function testManyToOneAssociationsAreExported($class): void */ public function testOneToManyAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->associationMappings['phonenumbers'])); - $this->assertEquals(Phonenumber::class, $class->associationMappings['phonenumbers']['targetEntity']); - $this->assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']); - $this->assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); - - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); - $this->assertEquals(ClassMetadataInfo::FETCH_LAZY, $class->associationMappings['phonenumbers']['fetch']); + self::assertTrue(isset($class->associationMappings['phonenumbers'])); + self::assertEquals(Phonenumber::class, $class->associationMappings['phonenumbers']['targetEntity']); + self::assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']); + self::assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); + + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + self::assertEquals(ClassMetadataInfo::FETCH_LAZY, $class->associationMappings['phonenumbers']['fetch']); return $class; } @@ -289,23 +289,23 @@ public function testOneToManyAssociationsAreExported(ClassMetadataInfo $class): */ public function testManyToManyAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->associationMappings['groups'])); - $this->assertEquals(Group::class, $class->associationMappings['groups']['targetEntity']); - $this->assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']); + self::assertTrue(isset($class->associationMappings['groups'])); + self::assertEquals(Group::class, $class->associationMappings['groups']['targetEntity']); + self::assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']); - $this->assertEquals('user_id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('user_id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['name']); + self::assertEquals('id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['referencedColumnName']); - $this->assertEquals('group_id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['name']); - $this->assertEquals('id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); - $this->assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); + self::assertEquals('group_id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + self::assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); - $this->assertTrue($class->associationMappings['groups']['isCascadeRemove']); - $this->assertTrue($class->associationMappings['groups']['isCascadePersist']); - $this->assertTrue($class->associationMappings['groups']['isCascadeRefresh']); - $this->assertTrue($class->associationMappings['groups']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['groups']['isCascadeDetach']); - $this->assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $class->associationMappings['groups']['fetch']); + self::assertTrue($class->associationMappings['groups']['isCascadeRemove']); + self::assertTrue($class->associationMappings['groups']['isCascadePersist']); + self::assertTrue($class->associationMappings['groups']['isCascadeRefresh']); + self::assertTrue($class->associationMappings['groups']['isCascadeMerge']); + self::assertTrue($class->associationMappings['groups']['isCascadeDetach']); + self::assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $class->associationMappings['groups']['fetch']); return $class; } @@ -315,14 +315,14 @@ public function testManyToManyAssociationsAreExported(ClassMetadataInfo $class): */ public function testLifecycleCallbacksAreExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue(isset($class->lifecycleCallbacks['prePersist'])); - $this->assertEquals(2, count($class->lifecycleCallbacks['prePersist'])); - $this->assertEquals('doStuffOnPrePersist', $class->lifecycleCallbacks['prePersist'][0]); - $this->assertEquals('doOtherStuffOnPrePersistToo', $class->lifecycleCallbacks['prePersist'][1]); + self::assertTrue(isset($class->lifecycleCallbacks['prePersist'])); + self::assertEquals(2, count($class->lifecycleCallbacks['prePersist'])); + self::assertEquals('doStuffOnPrePersist', $class->lifecycleCallbacks['prePersist'][0]); + self::assertEquals('doOtherStuffOnPrePersistToo', $class->lifecycleCallbacks['prePersist'][1]); - $this->assertTrue(isset($class->lifecycleCallbacks['postPersist'])); - $this->assertEquals(1, count($class->lifecycleCallbacks['postPersist'])); - $this->assertEquals('doStuffOnPostPersist', $class->lifecycleCallbacks['postPersist'][0]); + self::assertTrue(isset($class->lifecycleCallbacks['postPersist'])); + self::assertEquals(1, count($class->lifecycleCallbacks['postPersist'])); + self::assertEquals('doStuffOnPostPersist', $class->lifecycleCallbacks['postPersist'][0]); return $class; } @@ -332,12 +332,12 @@ public function testLifecycleCallbacksAreExported(ClassMetadataInfo $class): Cla */ public function testCascadeIsExported(ClassMetadataInfo $class): ClassMetadataInfo { - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); - $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); + self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); return $class; } @@ -347,7 +347,7 @@ public function testCascadeIsExported(ClassMetadataInfo $class): ClassMetadataIn */ public function testInversedByIsExported(ClassMetadataInfo $class): void { - $this->assertEquals('user', $class->associationMappings['address']['inversedBy']); + self::assertEquals('user', $class->associationMappings['address']['inversedBy']); } /** @@ -362,18 +362,18 @@ public function testCascadeAllCollapsed(): void $xml->registerXPathNamespace('d', 'http://doctrine-project.org/schemas/orm/doctrine-mapping'); $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:one-to-many[@field='interests']/d:cascade/d:*"); - $this->assertEquals(1, count($nodes)); + self::assertEquals(1, count($nodes)); - $this->assertEquals('cascade-all', $nodes[0]->getName()); + self::assertEquals('cascade-all', $nodes[0]->getName()); } elseif ($type === 'yaml') { $yaml = new Parser(); $value = $yaml->parse(file_get_contents(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.yml')); - $this->assertTrue(isset($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); - $this->assertEquals(1, count($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); - $this->assertEquals('all', $value[ExportedUser::class]['oneToMany']['interests']['cascade'][0]); + self::assertTrue(isset($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); + self::assertEquals(1, count($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); + self::assertEquals('all', $value[ExportedUser::class]['oneToMany']['interests']['cascade'][0]); } else { - $this->markTestSkipped('Test not available for ' . $type . ' driver'); + self::markTestSkipped('Test not available for ' . $type . ' driver'); } } @@ -382,17 +382,17 @@ public function testCascadeAllCollapsed(): void */ public function testEntityListenersAreExported(ClassMetadata $class): void { - $this->assertNotEmpty($class->entityListeners); - $this->assertCount(2, $class->entityListeners[Events::prePersist]); - $this->assertCount(2, $class->entityListeners[Events::postPersist]); - $this->assertEquals(UserListener::class, $class->entityListeners[Events::prePersist][0]['class']); - $this->assertEquals('customPrePersist', $class->entityListeners[Events::prePersist][0]['method']); - $this->assertEquals(GroupListener::class, $class->entityListeners[Events::prePersist][1]['class']); - $this->assertEquals('prePersist', $class->entityListeners[Events::prePersist][1]['method']); - $this->assertEquals(UserListener::class, $class->entityListeners[Events::postPersist][0]['class']); - $this->assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][0]['method']); - $this->assertEquals(AddressListener::class, $class->entityListeners[Events::postPersist][1]['class']); - $this->assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][1]['method']); + self::assertNotEmpty($class->entityListeners); + self::assertCount(2, $class->entityListeners[Events::prePersist]); + self::assertCount(2, $class->entityListeners[Events::postPersist]); + self::assertEquals(UserListener::class, $class->entityListeners[Events::prePersist][0]['class']); + self::assertEquals('customPrePersist', $class->entityListeners[Events::prePersist][0]['method']); + self::assertEquals(GroupListener::class, $class->entityListeners[Events::prePersist][1]['class']); + self::assertEquals('prePersist', $class->entityListeners[Events::prePersist][1]['method']); + self::assertEquals(UserListener::class, $class->entityListeners[Events::postPersist][0]['class']); + self::assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][0]['method']); + self::assertEquals(AddressListener::class, $class->entityListeners[Events::postPersist][1]['class']); + self::assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][1]['method']); } protected function deleteDirectory(string $path): void diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php index 5586284fcdf..7d23defc749 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php @@ -62,7 +62,7 @@ public function testSequenceGenerator(): void XML; - $this->assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); + self::assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); } /** @@ -101,6 +101,6 @@ public function testFieldOptionsExport(): void XML; - $this->assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); + self::assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php index a031a3ea99f..c927ceca30b 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php @@ -16,7 +16,7 @@ class YamlClassMetadataExporterTest extends AbstractClassMetadataExporterTest protected function getType(): string { if (! class_exists('Symfony\Component\Yaml\Yaml', true)) { - $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + self::markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); } return 'yaml'; diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php index e6a8d9a218c..9c714174aaa 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php @@ -17,7 +17,7 @@ public function testCountQuery(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, c1_.id AS id_1, a2_.id AS id_2, a2_.name AS name_3, b0_.author_id AS author_id_4, b0_.category_id AS category_id_5 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id) dctrn_result) dctrn_table', $query->getSQL() ); @@ -31,7 +31,7 @@ public function testCountQueryMixedResultsWithName(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result) dctrn_table', $query->getSQL() ); @@ -45,7 +45,7 @@ public function testCountQueryGroupBy(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertSame( + self::assertSame( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT p0_.name AS name_0 FROM Person p0_ GROUP BY p0_.name) dctrn_table', $query->getSQL() ); @@ -59,7 +59,7 @@ public function testCountQueryHaving(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertSame( + self::assertSame( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT count(u0_.id) AS sclr_0, g1_.id AS id_1, u0_.id AS id_2 FROM groups g1_ LEFT JOIN user_group u2_ ON g1_.id = u2_.group_id LEFT JOIN User u0_ ON u0_.id = u2_.user_id GROUP BY g1_.id HAVING sclr_0 > 0) dctrn_table', $query->getSQL() ); @@ -68,7 +68,7 @@ public function testCountQueryHaving(): void public function testCountQueryOrderBySqlServer(): void { if ($this->entityManager->getConnection()->getDatabasePlatform()->getName() !== 'mssql') { - $this->markTestSkipped('SQLServer only test.'); + self::markTestSkipped('SQLServer only test.'); } $query = $this->entityManager->createQuery( @@ -77,7 +77,7 @@ public function testCountQueryOrderBySqlServer(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_) dctrn_result) dctrn_table', $query->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index 466ccafd05b..d384f6122a9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -22,7 +22,7 @@ public function testCountQuery(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', $query->getSQL() ); @@ -37,7 +37,7 @@ public function testCountQueryMixedResultsWithName(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT a0_.id) AS sclr_0 FROM Author a0_', $query->getSQL() ); @@ -52,7 +52,7 @@ public function testCountQueryKeepsGroupBy(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ GROUP BY b0_.id', $query->getSQL() ); @@ -67,7 +67,7 @@ public function testCountQueryRemovesOrderBy(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', $query->getSQL() ); @@ -82,7 +82,7 @@ public function testCountQueryRemovesLimits(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', $query->getSQL() ); @@ -114,7 +114,7 @@ public function testCountQueryWithArbitraryJoin(): void $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); - $this->assertEquals( + self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ LEFT JOIN Category c1_ ON (b0_.category_id = c1_.id)', $query->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 061d6c99f2d..696c2a92bd9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -219,7 +219,7 @@ public function testCountQueryWithArithmeticOrderByCondition(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, (1 - 1000) * 1 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1 FROM Author a0_) dctrn_result_inner ORDER BY (1 - 1000) * 1 DESC) dctrn_result', $query->getSQL() ); @@ -234,7 +234,7 @@ public function testCountQueryWithComplexScalarOrderByItem(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_2 * imageWidth_3 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageHeight_2 * imageWidth_3 DESC) dctrn_result', $query->getSQL() ); @@ -249,7 +249,7 @@ public function testCountQueryWithComplexScalarOrderByItemJoined(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_1 * imageWidth_2 FROM (SELECT u0_.id AS id_0, a1_.imageHeight AS imageHeight_1, a1_.imageWidth AS imageWidth_2, a1_.user_id AS user_id_3 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_1 * imageWidth_2 DESC) dctrn_result', $query->getSQL() ); @@ -264,7 +264,7 @@ public function testCountQueryWithComplexScalarOrderByItemJoinedWithPartial(): v $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_3 * imageWidth_4 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.imageAltDesc AS imageAltDesc_2, a1_.imageHeight AS imageHeight_3, a1_.imageWidth AS imageWidth_4, a1_.user_id AS user_id_5 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_3 * imageWidth_4 DESC) dctrn_result', $query->getSQL() ); @@ -279,7 +279,7 @@ public function testCountQueryWithComplexScalarOrderByItemOracle(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.image AS IMAGE_1, a0_.imageHeight AS IMAGEHEIGHT_2, a0_.imageWidth AS IMAGEWIDTH_3, a0_.imageAltDesc AS IMAGEALTDESC_4, ROW_NUMBER() OVER(ORDER BY a0_.imageHeight * a0_.imageWidth DESC) AS SCLR_5, a0_.user_id AS USER_ID_6 FROM Avatar a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', $query->getSQL() ); @@ -311,7 +311,7 @@ public function testLimitSubqueryWithColumnWithSortDirectionInName(): void $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - $this->assertSame( + self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageAltDesc_4 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageAltDesc_4 DESC) dctrn_result', $query->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php index e8c1e91b3e0..5893e01d258 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php @@ -20,7 +20,7 @@ public function testLimitSubquery(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id', $limitQuery->getSQL() ); @@ -34,7 +34,7 @@ public function testLimitSubqueryWithSort(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.title AS title_1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC', $limitQuery->getSQL() ); @@ -62,7 +62,7 @@ public function testCountQueryMixedResultsWithName(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT a0_.id AS id_0 FROM Author a0_', $limitQuery->getSQL() ); @@ -107,7 +107,7 @@ public function testLimitSubqueryWithSortOnAssociation(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.author_id AS sclr_1 FROM MyBlogPost m0_ ORDER BY m0_.author_id ASC', $limitQuery->getSQL() ); @@ -124,7 +124,7 @@ public function testLimitSubqueryWithArbitraryJoin(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON (m0_.category_id = c1_.id)', $limitQuery->getSQL() ); @@ -138,7 +138,7 @@ public function testLimitSubqueryWithSortWithArbitraryJoin(): void $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [LimitSubqueryWalker::class]); - $this->assertEquals( + self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.title AS title_1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON (m0_.category_id = c1_.id) ORDER BY m0_.title ASC', $limitQuery->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index 786839dda9f..2ce23abdd02 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -63,12 +63,12 @@ public function testExtraParametersAreStrippedWhenWalkerRemovingOriginalSelectEl $paginator = (new Paginator($query, true))->setUseOutputWalkers(false); $this->connection - ->expects($this->exactly(3)) + ->expects(self::exactly(3)) ->method('executeQuery') ->withConsecutive( - [$this->anything(), [$paramInWhere]], - [$this->anything(), [$paramInWhere]], - [$this->anything(), [$paramInSubSelect, $paramInWhere, $returnedIds]] + [self::anything(), [$paramInWhere]], + [self::anything(), [$paramInWhere]], + [self::anything(), [$paramInSubSelect, $paramInWhere, $returnedIds]] ); $paginator->count(); @@ -77,7 +77,7 @@ public function testExtraParametersAreStrippedWhenWalkerRemovingOriginalSelectEl public function testPaginatorNotCaringAboutExtraParametersWithoutOutputWalkers(): void { - $this->connection->expects($this->exactly(3))->method('executeQuery'); + $this->connection->expects(self::exactly(3))->method('executeQuery'); $this->createPaginatorWithExtraParametersWithoutOutputWalkers([])->count(); $this->createPaginatorWithExtraParametersWithoutOutputWalkers([[10]])->count(); @@ -86,7 +86,7 @@ public function testPaginatorNotCaringAboutExtraParametersWithoutOutputWalkers() public function testgetIteratorDoesCareAboutExtraParametersWithoutOutputWalkersWhenResultIsNotEmpty(): void { - $this->connection->expects($this->exactly(1))->method('executeQuery'); + $this->connection->expects(self::exactly(1))->method('executeQuery'); $this->expectException(Query\QueryException::class); $this->expectExceptionMessage('Too many parameters: the query defines 1 parameters and you bound 2'); @@ -99,7 +99,7 @@ public function testgetIteratorDoesCareAboutExtraParametersWithoutOutputWalkersW private function createPaginatorWithExtraParametersWithoutOutputWalkers(array $willReturnRows): Paginator { $this->hydrator->method('hydrateAll')->willReturn($willReturnRows); - $this->connection->method('executeQuery')->with($this->anything(), []); + $this->connection->method('executeQuery')->with(self::anything(), []); $query = new Query($this->em); $query->setDQL('SELECT u FROM Doctrine\\Tests\\Models\\CMS\\CmsUser u'); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php index c9a8cbaf32b..23e6d717607 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php @@ -35,7 +35,7 @@ public function testWhereInQueryNoWhere(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -56,7 +56,7 @@ public function testCountQueryMixedResultsWithName(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_ WHERE a0_.id IN (?)', $whereInQuery->getSQL() ); @@ -77,7 +77,7 @@ public function testWhereInQuerySingleWhere(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -98,7 +98,7 @@ public function testWhereInQueryMultipleWhereWithAnd(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND 2 = 2 AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -119,7 +119,7 @@ public function testWhereInQueryMultipleWhereWithOr(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -140,7 +140,7 @@ public function testWhereInQueryMultipleWhereWithMixed1(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND 3 = 3 AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -161,7 +161,7 @@ public function testWhereInQueryMultipleWhereWithMixed2(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 AND 2 = 2 OR 3 = 3) AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -182,7 +182,7 @@ public function testWhereInQueryWhereNot(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (NOT 1 = 2) AND u0_.id IN (?)', $whereInQuery->getSQL() ); @@ -205,7 +205,7 @@ public function testWhereInQueryWithArbitraryJoinNoWhere(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE b0_.id IN (?)', $whereInQuery->getSQL() ); @@ -225,7 +225,7 @@ public function testWhereInQueryWithArbitraryJoinSingleWhere(): void $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - $this->assertEquals( + self::assertEquals( 'SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE 1 = 1 AND b0_.id IN (?)', $whereInQuery->getSQL() ); diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index d8b0333a396..80d0957761d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -54,12 +54,12 @@ public function testResolveTargetEntityListenerCanResolveTargetEntity(): void $cm = $this->factory->getMetadataFor(ResolveTargetEntity::class); $meta = $cm->associationMappings; - $this->assertSame(TargetEntity::class, $meta['manyToMany']['targetEntity']); - $this->assertSame(ResolveTargetEntity::class, $meta['manyToOne']['targetEntity']); - $this->assertSame(ResolveTargetEntity::class, $meta['oneToMany']['targetEntity']); - $this->assertSame(TargetEntity::class, $meta['oneToOne']['targetEntity']); + self::assertSame(TargetEntity::class, $meta['manyToMany']['targetEntity']); + self::assertSame(ResolveTargetEntity::class, $meta['manyToOne']['targetEntity']); + self::assertSame(ResolveTargetEntity::class, $meta['oneToMany']['targetEntity']); + self::assertSame(TargetEntity::class, $meta['oneToOne']['targetEntity']); - $this->assertSame($cm, $this->factory->getMetadataFor(ResolveTarget::class)); + self::assertSame($cm, $this->factory->getMetadataFor(ResolveTarget::class)); } /** @@ -75,7 +75,7 @@ public function testResolveTargetEntityListenerCanRetrieveTargetEntityByInterfac $cm = $this->factory->getMetadataFor(ResolveTarget::class); - $this->assertSame($this->factory->getMetadataFor(ResolveTargetEntity::class), $cm); + self::assertSame($this->factory->getMetadataFor(ResolveTargetEntity::class), $cm); } /** @@ -91,8 +91,8 @@ public function testAssertTableColumnsAreNotAddedInManyToMany(): void $cm = $this->factory->getMetadataFor(ResolveTargetEntity::class); $meta = $cm->associationMappings['manyToMany']; - $this->assertSame(TargetEntity::class, $meta['targetEntity']); - $this->assertEquals(['resolvetargetentity_id', 'target_id'], $meta['joinTableColumns']); + self::assertSame(TargetEntity::class, $meta['targetEntity']); + self::assertEquals(['resolvetargetentity_id', 'target_id'], $meta['joinTableColumns']); } /** @@ -107,7 +107,7 @@ public function testDoesResolveTargetEntitiesInDQLAlsoWithInterfaces(): void $evm->addEventSubscriber($this->listener); - $this->assertStringMatchesFormat( + self::assertStringMatchesFormat( 'SELECT%AFROM ResolveTargetEntity%A', $this ->em diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index 0010d28817c..81968bfca5b 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -62,8 +62,8 @@ public function testAddUniqueIndexForUniqueFieldAnnotation(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('cms_users'), 'Table cms_users should exist.'); - $this->assertTrue($schema->getTable('cms_users')->columnsAreIndexed(['username']), 'username column should be indexed.'); + self::assertTrue($schema->hasTable('cms_users'), 'Table cms_users should exist.'); + self::assertTrue($schema->getTable('cms_users')->columnsAreIndexed(['username']), 'username column should be indexed.'); } public function testAnnotationOptionsAttribute(): void @@ -102,10 +102,10 @@ public function testPassColumnDefinitionToJoinColumn(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('forum_users')); + self::assertTrue($schema->hasTable('forum_users')); $table = $schema->getTable('forum_users'); - $this->assertTrue($table->hasColumn('avatar_id')); - $this->assertEquals($customColumnDef, $table->getColumn('avatar_id')->getColumnDefinition()); + self::assertTrue($table->hasColumn('avatar_id')); + self::assertEquals($customColumnDef, $table->getColumn('avatar_id')->getColumnDefinition()); } /** @@ -172,8 +172,8 @@ public function testPostGenerateEvents(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertEquals(count($classes), $listener->tableCalls); - $this->assertTrue($listener->schemaCalled); + self::assertEquals(count($classes), $listener->tableCalls); + self::assertTrue($listener->schemaCalled); } public function testNullDefaultNotAddedToCustomSchemaOptions(): void @@ -186,7 +186,7 @@ public function testNullDefaultNotAddedToCustomSchemaOptions(): void ->getColumn('nullDefault') ->getCustomSchemaOptions(); - $this->assertSame([], $customSchemaOptions); + self::assertSame([], $customSchemaOptions); } /** @@ -202,12 +202,12 @@ public function testSchemaHasProperIndexesFromUniqueConstraintAnnotation(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('unique_constraint_annotation_table')); + self::assertTrue($schema->hasTable('unique_constraint_annotation_table')); $table = $schema->getTable('unique_constraint_annotation_table'); - $this->assertEquals(2, count($table->getIndexes())); - $this->assertTrue($table->hasIndex('primary')); - $this->assertTrue($table->hasIndex('uniq_hash')); + self::assertEquals(2, count($table->getIndexes())); + self::assertTrue($table->hasIndex('primary')); + self::assertTrue($table->hasIndex('uniq_hash')); } public function testRemoveUniqueIndexOverruledByPrimaryKey(): void @@ -221,12 +221,12 @@ public function testRemoveUniqueIndexOverruledByPrimaryKey(): void $schema = $schemaTool->getSchemaFromMetadata($classes); - $this->assertTrue($schema->hasTable('first_entity'), 'Table first_entity should exist.'); + self::assertTrue($schema->hasTable('first_entity'), 'Table first_entity should exist.'); $indexes = $schema->getTable('first_entity')->getIndexes(); - $this->assertCount(1, $indexes, 'there should be only one index'); - $this->assertTrue(current($indexes)->isPrimary(), 'index should be primary'); + self::assertCount(1, $indexes, 'there should be only one index'); + self::assertTrue(current($indexes)->isPrimary(), 'index should be primary'); } public function testSetDiscriminatorColumnWithoutLength(): void @@ -240,13 +240,13 @@ public function testSetDiscriminatorColumnWithoutLength(): void $schema = $schemaTool->getSchemaFromMetadata([$metadata]); - $this->assertTrue($schema->hasTable('first_entity')); + self::assertTrue($schema->hasTable('first_entity')); $table = $schema->getTable('first_entity'); - $this->assertTrue($table->hasColumn('discriminator')); + self::assertTrue($table->hasColumn('discriminator')); $column = $table->getColumn('discriminator'); - $this->assertEquals(255, $column->getLength()); + self::assertEquals(255, $column->getLength()); } public function testDerivedCompositeKey(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index c7415396654..da32bee58e3 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -71,7 +71,7 @@ public function testInvalidManyToManyJoinColumnSchema(): void $ce = $this->validator->validateClass($class1); - $this->assertEquals( + self::assertEquals( [ "The inverse join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity2', however 'key4' are missing.", "The join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the source entity 'Doctrine\Tests\ORM\Tools\InvalidEntity1', however 'key2' are missing.", @@ -90,7 +90,7 @@ public function testInvalidToOneJoinColumnSchema(): void $ce = $this->validator->validateClass($class2); - $this->assertEquals( + self::assertEquals( [ "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\InvalidEntity1'.", "The join columns of the association 'assoc' have to match to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity1', however 'key1, key2' are missing.", @@ -109,7 +109,7 @@ public function testValidOneToOneAsIdentifierSchema(): void $ce = $this->validator->validateClass($class1); - $this->assertEquals([], $ce); + self::assertEquals([], $ce); } /** @@ -120,7 +120,7 @@ public function testInvalidTripleAssociationAsKeyMapping(): void $classThree = $this->em->getClassMetadata(DDC1649Three::class); $ce = $this->validator->validateClass($classThree); - $this->assertEquals( + self::assertEquals( [ "Cannot map association 'Doctrine\Tests\ORM\Tools\DDC1649Three#two as identifier, because the target entity 'Doctrine\Tests\ORM\Tools\DDC1649Two' also maps an association as identifier.", "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\DDC1649Two'.", @@ -137,7 +137,7 @@ public function testInvalidBiDirectionalRelationMappingMissingInversedByAttribut $class = $this->em->getClassMetadata(DDC3274One::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( [ 'The field Doctrine\Tests\ORM\Tools\DDC3274One#two is on the inverse side of a bi-directional ' . 'relationship, but the specified mappedBy association on the target-entity ' . @@ -155,7 +155,7 @@ public function testInvalidOrderByInvalidField(): void $class = $this->em->getClassMetadata(DDC3322One::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( [ 'The association Doctrine\Tests\ORM\Tools\DDC3322One#invalidAssoc is ordered by a foreign field ' . 'invalidField that is not a field on the target entity Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1.', @@ -172,7 +172,7 @@ public function testInvalidOrderByCollectionValuedAssociation(): void $class = $this->em->getClassMetadata(DDC3322Two::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( [ 'The association Doctrine\Tests\ORM\Tools\DDC3322Two#invalidAssoc is ordered by a field oneToMany ' . 'on Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 that is a collection-valued association.', @@ -189,7 +189,7 @@ public function testInvalidOrderByAssociationInverseSide(): void $class = $this->em->getClassMetadata(DDC3322Three::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( [ 'The association Doctrine\Tests\ORM\Tools\DDC3322Three#invalidAssoc is ordered by a field oneToOneInverse ' . 'on Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 that is the inverse side of an association.', @@ -206,7 +206,7 @@ public function testInvalidAssociationInsideEmbeddable(): void $class = $this->em->getClassMetadata(EmbeddableWithAssociation::class); $ce = $this->validator->validateClass($class); - $this->assertEquals( + self::assertEquals( ["Embeddable 'Doctrine\Tests\ORM\Tools\EmbeddableWithAssociation' does not support associations"], $ce ); diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php index adc4d7d5d25..6e5022e54fd 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -59,33 +59,33 @@ public function testDirectoryAutoload(): void { Setup::registerAutoloadDirectory(__DIR__ . '/../../../../../vendor/doctrine/common/lib'); - $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); + self::assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); } public function testAnnotationConfiguration(): void { $config = Setup::createAnnotationMetadataConfiguration([], true); - $this->assertInstanceOf(Configuration::class, $config); - $this->assertEquals(sys_get_temp_dir(), $config->getProxyDir()); - $this->assertEquals('DoctrineProxies', $config->getProxyNamespace()); - $this->assertInstanceOf(AnnotationDriver::class, $config->getMetadataDriverImpl()); + self::assertInstanceOf(Configuration::class, $config); + self::assertEquals(sys_get_temp_dir(), $config->getProxyDir()); + self::assertEquals('DoctrineProxies', $config->getProxyNamespace()); + self::assertInstanceOf(AnnotationDriver::class, $config->getMetadataDriverImpl()); } public function testXMLConfiguration(): void { $config = Setup::createXMLMetadataConfiguration([], true); - $this->assertInstanceOf(Configuration::class, $config); - $this->assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); + self::assertInstanceOf(Configuration::class, $config); + self::assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); } public function testYAMLConfiguration(): void { $config = Setup::createYAMLMetadataConfiguration([], true); - $this->assertInstanceOf(Configuration::class, $config); - $this->assertInstanceOf(YamlDriver::class, $config->getMetadataDriverImpl()); + self::assertInstanceOf(Configuration::class, $config); + self::assertInstanceOf(YamlDriver::class, $config->getMetadataDriverImpl()); } /** @@ -94,7 +94,7 @@ public function testYAMLConfiguration(): void public function testCacheNamespaceShouldBeGeneratedWhenCacheIsGivenButHasNoNamespace(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Only applies when using doctrine/cache directly'); + self::markTestSkipped('Only applies when using doctrine/cache directly'); } $config = Setup::createConfiguration(false, '/foo', new ArrayCache()); @@ -109,7 +109,7 @@ public function testCacheNamespaceShouldBeGeneratedWhenCacheIsGivenButHasNoNames public function testConfiguredCacheNamespaceShouldBeUsedAsPrefixOfGeneratedNamespace(): void { if (! class_exists(ArrayCache::class)) { - $this->markTestSkipped('Only applies when using doctrine/cache directly'); + self::markTestSkipped('Only applies when using doctrine/cache directly'); } $originalCache = new ArrayCache(); @@ -127,7 +127,7 @@ public function testConfiguredCacheNamespaceShouldBeUsedAsPrefixOfGeneratedNames public function testConfigureProxyDir(): void { $config = Setup::createAnnotationMetadataConfiguration([], true, '/foo'); - $this->assertEquals('/foo', $config->getProxyDir()); + self::assertEquals('/foo', $config->getProxyDir()); } /** @@ -139,13 +139,13 @@ public function testConfigureCache(): void $cache = DoctrineProvider::wrap($adapter); $config = Setup::createAnnotationMetadataConfiguration([], true, null, $cache); - $this->assertSame($cache, $config->getResultCacheImpl()); - $this->assertSame($cache, $config->getQueryCacheImpl()); + self::assertSame($cache, $config->getResultCacheImpl()); + self::assertSame($cache, $config->getQueryCacheImpl()); if (method_exists(Configuration::class, 'getMetadataCache')) { - $this->assertSame($adapter, $config->getMetadataCache()->getCache()->getPool()); + self::assertSame($adapter, $config->getMetadataCache()->getCache()->getPool()); } else { - $this->assertSame($cache, $config->getMetadataCacheImpl()); + self::assertSame($cache, $config->getMetadataCacheImpl()); } } @@ -157,14 +157,14 @@ public function testConfigureCacheCustomInstance(): void $cache = $this->createMock(Cache::class); $config = Setup::createConfiguration(true, null, $cache); - $this->assertSame($cache, $config->getResultCacheImpl()); - $this->assertSame($cache, $config->getQueryCacheImpl()); + self::assertSame($cache, $config->getResultCacheImpl()); + self::assertSame($cache, $config->getQueryCacheImpl()); if (method_exists(Configuration::class, 'getMetadataCache')) { - $this->assertInstanceOf(CacheAdapter::class, $config->getMetadataCache()); - $this->assertSame($cache, $config->getMetadataCache()->getCache()); + self::assertInstanceOf(CacheAdapter::class, $config->getMetadataCache()); + self::assertSame($cache, $config->getMetadataCache()->getCache()); } else { - $this->assertSame($cache, $config->getMetadataCacheImpl()); + self::assertSame($cache, $config->getMetadataCacheImpl()); } } } diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 1d236a1745d..bddaec9bbae 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -89,9 +89,9 @@ public function testRegisterRemovedOnNewEntityIsIgnored(): void { $user = new ForumUser(); $user->username = 'romanb'; - $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user)); + self::assertFalse($this->_unitOfWork->isScheduledForDelete($user)); $this->_unitOfWork->scheduleForDelete($user); - $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user)); + self::assertFalse($this->_unitOfWork->isScheduledForDelete($user)); } /* Operational tests */ @@ -109,12 +109,12 @@ public function testSavingSingleEntityWithIdentityColumnForcesInsert(): void $this->_unitOfWork->persist($user); // Check - $this->assertEquals(0, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); - $this->assertFalse($this->_unitOfWork->isInIdentityMap($user)); + self::assertEquals(0, count($userPersister->getInserts())); + self::assertEquals(0, count($userPersister->getUpdates())); + self::assertEquals(0, count($userPersister->getDeletes())); + self::assertFalse($this->_unitOfWork->isInIdentityMap($user)); // should no longer be scheduled for insert - $this->assertTrue($this->_unitOfWork->isScheduledForInsert($user)); + self::assertTrue($this->_unitOfWork->isScheduledForInsert($user)); // Now lets check whether a subsequent commit() does anything $userPersister->reset(); @@ -123,12 +123,12 @@ public function testSavingSingleEntityWithIdentityColumnForcesInsert(): void $this->_unitOfWork->commit(); // Check. - $this->assertEquals(1, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); + self::assertEquals(1, count($userPersister->getInserts())); + self::assertEquals(0, count($userPersister->getUpdates())); + self::assertEquals(0, count($userPersister->getDeletes())); // should have an id - $this->assertTrue(is_numeric($user->id)); + self::assertTrue(is_numeric($user->id)); } /** @@ -156,16 +156,16 @@ public function testCascadedIdentityColumnInsert(): void $this->_unitOfWork->commit(); - $this->assertTrue(is_numeric($user->id)); - $this->assertTrue(is_numeric($avatar->id)); + self::assertTrue(is_numeric($user->id)); + self::assertTrue(is_numeric($avatar->id)); - $this->assertEquals(1, count($userPersister->getInserts())); - $this->assertEquals(0, count($userPersister->getUpdates())); - $this->assertEquals(0, count($userPersister->getDeletes())); + self::assertEquals(1, count($userPersister->getInserts())); + self::assertEquals(0, count($userPersister->getUpdates())); + self::assertEquals(0, count($userPersister->getDeletes())); - $this->assertEquals(1, count($avatarPersister->getInserts())); - $this->assertEquals(0, count($avatarPersister->getUpdates())); - $this->assertEquals(0, count($avatarPersister->getDeletes())); + self::assertEquals(1, count($avatarPersister->getInserts())); + self::assertEquals(0, count($avatarPersister->getUpdates())); + self::assertEquals(0, count($avatarPersister->getDeletes())); } public function testChangeTrackingNotify(): void @@ -180,18 +180,18 @@ public function testChangeTrackingNotify(): void $this->_unitOfWork->persist($entity); $this->_unitOfWork->commit(); - $this->assertCount(1, $persister->getInserts()); + self::assertCount(1, $persister->getInserts()); $persister->reset(); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); $entity->setData('newdata'); $entity->setTransient('newtransientvalue'); - $this->assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity)); + self::assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity)); - $this->assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity)); + self::assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity)); $item = new NotifyChangedRelatedItem(); $entity->getItems()->add($item); @@ -199,17 +199,17 @@ public function testChangeTrackingNotify(): void $this->_unitOfWork->persist($item); $this->_unitOfWork->commit(); - $this->assertEquals(1, count($itemPersister->getInserts())); + self::assertEquals(1, count($itemPersister->getInserts())); $persister->reset(); $itemPersister->reset(); $entity->getItems()->removeElement($item); $item->setOwner(null); - $this->assertTrue($entity->getItems()->isDirty()); + self::assertTrue($entity->getItems()->isDirty()); $this->_unitOfWork->commit(); $updates = $itemPersister->getUpdates(); - $this->assertEquals(1, count($updates)); - $this->assertTrue($updates[0] === $item); + self::assertEquals(1, count($updates)); + self::assertTrue($updates[0] === $item); } public function testChangeTrackingNotifyIndividualCommit(): void @@ -230,21 +230,21 @@ public function testChangeTrackingNotifyIndividualCommit(): void $this->_unitOfWork->commit($entity); $this->_unitOfWork->commit(); - $this->assertEquals(2, count($persister->getInserts())); + self::assertEquals(2, count($persister->getInserts())); $persister->reset(); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); $entity->setData('newdata'); $entity2->setData('newdata'); $this->_unitOfWork->commit($entity); - $this->assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity2)); - $this->assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity2)); - $this->assertFalse($this->_unitOfWork->isScheduledForDirtyCheck($entity)); - $this->assertEquals([], $this->_unitOfWork->getEntityChangeSet($entity)); + self::assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity2)); + self::assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity2)); + self::assertFalse($this->_unitOfWork->isScheduledForDirtyCheck($entity)); + self::assertEquals([], $this->_unitOfWork->getEntityChangeSet($entity)); } public function testGetEntityStateOnVersionedEntityWithAssignedIdentifier(): void @@ -254,8 +254,8 @@ public function testGetEntityStateOnVersionedEntityWithAssignedIdentifier(): voi $e = new VersionedAssignedIdentifierEntity(); $e->id = 42; - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($e)); - $this->assertFalse($persister->isExistsCalled()); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($e)); + self::assertFalse($persister->isExistsCalled()); } public function testGetEntityStateWithAssignedIdentity(): void @@ -266,19 +266,19 @@ public function testGetEntityStateWithAssignedIdentity(): void $ph = new CmsPhonenumber(); $ph->phonenumber = '12345'; - $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($ph)); - $this->assertTrue($persister->isExistsCalled()); + self::assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($ph)); + self::assertTrue($persister->isExistsCalled()); $persister->reset(); // if the entity is already managed the exists() check should be skipped $this->_unitOfWork->registerManaged($ph, ['phonenumber' => '12345'], []); - $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_unitOfWork->getEntityState($ph)); - $this->assertFalse($persister->isExistsCalled()); + self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_unitOfWork->getEntityState($ph)); + self::assertFalse($persister->isExistsCalled()); $ph2 = new CmsPhonenumber(); $ph2->phonenumber = '12345'; - $this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); - $this->assertFalse($persister->isExistsCalled()); + self::assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); + self::assertFalse($persister->isExistsCalled()); } /** @@ -370,13 +370,13 @@ public function testRemovedAndRePersistedEntitiesAreInTheIdentityMapAndAreNotGar $entity->id = 123; $this->_unitOfWork->registerManaged($entity, ['id' => 123], []); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); $this->_unitOfWork->remove($entity); - $this->assertFalse($this->_unitOfWork->isInIdentityMap($entity)); + self::assertFalse($this->_unitOfWork->isInIdentityMap($entity)); $this->_unitOfWork->persist($entity); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); } /** @@ -389,16 +389,16 @@ public function testPersistedEntityAndClearManager(): void $entity2 = new Country(456, 'United Kingdom'); $this->_unitOfWork->persist($entity1); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); $this->_unitOfWork->persist($entity2); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); $this->_unitOfWork->clear(Country::class); - $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); - $this->assertFalse($this->_unitOfWork->isInIdentityMap($entity2)); - $this->assertTrue($this->_unitOfWork->isScheduledForInsert($entity1)); - $this->assertFalse($this->_unitOfWork->isScheduledForInsert($entity2)); + self::assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); + self::assertFalse($this->_unitOfWork->isInIdentityMap($entity2)); + self::assertTrue($this->_unitOfWork->isScheduledForInsert($entity1)); + self::assertFalse($this->_unitOfWork->isScheduledForInsert($entity2)); } /** @@ -697,9 +697,9 @@ public function testNewAssociatedEntityPersistenceOfNewEntitiesThroughCascadedAs $this->_unitOfWork->commit(); - $this->assertCount(1, $persister1->getInserts()); - $this->assertCount(1, $persister2->getInserts()); - $this->assertCount(1, $persister3->getInserts()); + self::assertCount(1, $persister1->getInserts()); + self::assertCount(1, $persister2->getInserts()); + self::assertCount(1, $persister3->getInserts()); } /** diff --git a/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php b/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php index fd9d68871db..be037861967 100644 --- a/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php @@ -23,7 +23,7 @@ public function testResolveDiscriminatorsForClass(): void $classMetadata->discriminatorValue = 'discriminator'; $em = $this->createMock(EntityManagerInterface::class); - $em->expects($this->exactly(2)) + $em->expects(self::exactly(2)) ->method('getClassMetadata') ->willReturnMap( [ @@ -34,9 +34,9 @@ public function testResolveDiscriminatorsForClass(): void $discriminators = HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($classMetadata, $em); - $this->assertCount(2, $discriminators); - $this->assertArrayHasKey($classMetadata->discriminatorValue, $discriminators); - $this->assertArrayHasKey($childClassMetadata->discriminatorValue, $discriminators); + self::assertCount(2, $discriminators); + self::assertArrayHasKey($classMetadata->discriminatorValue, $discriminators); + self::assertArrayHasKey($childClassMetadata->discriminatorValue, $discriminators); } public function testResolveDiscriminatorsForClassWithNoSubclasses(): void @@ -47,14 +47,14 @@ public function testResolveDiscriminatorsForClassWithNoSubclasses(): void $classMetadata->discriminatorValue = 'discriminator'; $em = $this->createMock(EntityManagerInterface::class); - $em->expects($this->exactly(1)) + $em->expects(self::exactly(1)) ->method('getClassMetadata') ->with($classMetadata->name) ->willReturn($classMetadata); $discriminators = HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($classMetadata, $em); - $this->assertCount(1, $discriminators); - $this->assertArrayHasKey($classMetadata->discriminatorValue, $discriminators); + self::assertCount(1, $discriminators); + self::assertArrayHasKey($classMetadata->discriminatorValue, $discriminators); } } diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php index 9c66ca12e9f..716b20f738a 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php @@ -73,11 +73,11 @@ public function testFlattenIdentifierWithOneToOneId(): void $id = $class->getIdentifierValues($firstEntity); - $this->assertCount(1, $id, 'We should have 1 identifier'); + self::assertCount(1, $id, 'We should have 1 identifier'); - $this->assertArrayHasKey('secondEntity', $id, 'It should be called secondEntity'); + self::assertArrayHasKey('secondEntity', $id, 'It should be called secondEntity'); - $this->assertInstanceOf( + self::assertInstanceOf( '\Doctrine\Tests\Models\VersionedOneToOne\SecondRelatedEntity', $id['secondEntity'], 'The entity should be an instance of SecondRelatedEntity' @@ -85,11 +85,11 @@ public function testFlattenIdentifierWithOneToOneId(): void $flatIds = $this->identifierFlattener->flattenIdentifier($class, $id); - $this->assertCount(1, $flatIds, 'We should have 1 flattened id'); + self::assertCount(1, $flatIds, 'We should have 1 flattened id'); - $this->assertArrayHasKey('secondEntity', $flatIds, 'It should be called secondEntity'); + self::assertArrayHasKey('secondEntity', $flatIds, 'It should be called secondEntity'); - $this->assertEquals($id['secondEntity']->id, $flatIds['secondEntity']); + self::assertEquals($id['secondEntity']->id, $flatIds['secondEntity']); } /** @@ -112,22 +112,22 @@ public function testFlattenIdentifierWithMutlipleIds(): void $class = $this->_em->getClassMetadata(Flight::class); $id = $class->getIdentifierValues($flight); - $this->assertCount(2, $id); + self::assertCount(2, $id); - $this->assertArrayHasKey('leavingFrom', $id); - $this->assertArrayHasKey('goingTo', $id); + self::assertArrayHasKey('leavingFrom', $id); + self::assertArrayHasKey('goingTo', $id); - $this->assertEquals($leeds, $id['leavingFrom']); - $this->assertEquals($london, $id['goingTo']); + self::assertEquals($leeds, $id['leavingFrom']); + self::assertEquals($london, $id['goingTo']); $flatIds = $this->identifierFlattener->flattenIdentifier($class, $id); - $this->assertCount(2, $flatIds); + self::assertCount(2, $flatIds); - $this->assertArrayHasKey('leavingFrom', $flatIds); - $this->assertArrayHasKey('goingTo', $flatIds); + self::assertArrayHasKey('leavingFrom', $flatIds); + self::assertArrayHasKey('goingTo', $flatIds); - $this->assertEquals($id['leavingFrom']->getId(), $flatIds['leavingFrom']); - $this->assertEquals($id['goingTo']->getId(), $flatIds['goingTo']); + self::assertEquals($id['leavingFrom']->getId(), $flatIds['leavingFrom']); + self::assertEquals($id['goingTo']->getId(), $flatIds['goingTo']); } } diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index efe99fad96a..6d3d892d5c6 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -839,7 +839,7 @@ protected function onNotSuccessfulTest(Throwable $e): void public function assertSQLEquals(string $expectedSql, string $actualSql): void { - $this->assertEquals( + self::assertEquals( strtolower($expectedSql), strtolower($actualSql), 'Lowercase comparison of SQL statements failed.' diff --git a/tests/Doctrine/Tests/OrmPerformanceTestCase.php b/tests/Doctrine/Tests/OrmPerformanceTestCase.php index e9e18c22456..c10fea12e4e 100644 --- a/tests/Doctrine/Tests/OrmPerformanceTestCase.php +++ b/tests/Doctrine/Tests/OrmPerformanceTestCase.php @@ -25,7 +25,7 @@ protected function runTest(): void $time = microtime(true) - $s; if ($this->maxRunningTime !== 0 && $time > $this->maxRunningTime) { - $this->fail( + self::fail( sprintf( 'expected running time: <= %s but was: %s', $this->maxRunningTime, From d95f304073393b539543c8ac601d8b4d3c2f4b42 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 2 Oct 2021 18:00:45 +0200 Subject: [PATCH 005/475] Remove TABLE and UUID strategies (#9045) --- UPGRADE.md | 8 ++ lib/Doctrine/ORM/Id/TableGenerator.php | 83 ----------------- lib/Doctrine/ORM/Id/UuidGenerator.php | 47 ---------- .../ORM/Mapping/ClassMetadataFactory.php | 12 --- .../ORM/Mapping/ClassMetadataInfo.php | 40 --------- .../ORM/Mapping/Driver/AnnotationDriver.php | 5 -- lib/Doctrine/ORM/Tools/EntityGenerator.php | 1 - .../Tools/Export/Driver/AbstractExporter.php | 3 - phpstan-baseline.neon | 16 +--- phpstan.neon | 3 - psalm-baseline.xml | 29 +----- psalm.xml | 7 -- .../ORM/Functional/UUIDGeneratorTest.php | 89 ------------------- .../Tests/ORM/Tools/EntityGeneratorTest.php | 4 - 14 files changed, 12 insertions(+), 335 deletions(-) delete mode 100644 lib/Doctrine/ORM/Id/TableGenerator.php delete mode 100644 lib/Doctrine/ORM/Id/UuidGenerator.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 768e133648f..488fda55a0f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -21,6 +21,14 @@ Signatures of overridden methods should be changed accordingly Method `Doctrine\ORM\EntityManagerInterface#copy()` never got its implementation and is removed in 3.0. +## BC BREAK: Removed classes related to UUID and TABLE generator strategies + +The following classes have been removed: +- `Doctrine\ORM\Id\TableGenerator` +- `Doctrine\ORM\Id\UuidGenerator` + +Using the `UUID` strategy for generating identifiers is not supported anymore. + # Upgrade to 2.10 ## BC Break: Removed `TABLE` id generator strategy diff --git a/lib/Doctrine/ORM/Id/TableGenerator.php b/lib/Doctrine/ORM/Id/TableGenerator.php deleted file mode 100644 index c65b5272617..00000000000 --- a/lib/Doctrine/ORM/Id/TableGenerator.php +++ /dev/null @@ -1,83 +0,0 @@ -_tableName = $tableName; - $this->_sequenceName = $sequenceName; - $this->_allocationSize = $allocationSize; - } - - /** - * {@inheritDoc} - */ - public function generate( - EntityManager $em, - $entity - ) { - if ($this->_maxValue === null || $this->_nextValue === $this->_maxValue) { - // Allocate new values - $conn = $em->getConnection(); - - if ($conn->getTransactionNestingLevel() === 0) { - // use select for update - $sql = $conn->getDatabasePlatform()->getTableHiLoCurrentValSql($this->_tableName, $this->_sequenceName); - $currentLevel = $conn->fetchOne($sql); - - if ($currentLevel !== null) { - $this->_nextValue = $currentLevel; - $this->_maxValue = $this->_nextValue + $this->_allocationSize; - - $updateSql = $conn->getDatabasePlatform()->getTableHiLoUpdateNextValSql( - $this->_tableName, - $this->_sequenceName, - $this->_allocationSize - ); - - if ($conn->executeStatement($updateSql, [1 => $currentLevel, 2 => $currentLevel + 1]) !== 1) { - // no affected rows, concurrency issue, throw exception - } - } else { - // no current level returned, TableGenerator seems to be broken, throw exception - } - } else { - // only table locks help here, implement this or throw exception? - // or do we want to work with table locks exclusively? - } - } - - return $this->_nextValue++; - } -} diff --git a/lib/Doctrine/ORM/Id/UuidGenerator.php b/lib/Doctrine/ORM/Id/UuidGenerator.php deleted file mode 100644 index f6b87589378..00000000000 --- a/lib/Doctrine/ORM/Id/UuidGenerator.php +++ /dev/null @@ -1,47 +0,0 @@ -getConnection(); - $sql = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression(); - - return $conn->executeQuery($sql)->fetchOne(); - } -} diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index c7fb339d453..f18f7cd7d37 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -17,10 +17,8 @@ use Doctrine\ORM\Id\BigIntegerIdentityGenerator; use Doctrine\ORM\Id\IdentityGenerator; use Doctrine\ORM\Id\SequenceGenerator; -use Doctrine\ORM\Id\UuidGenerator; use Doctrine\ORM\Mapping\Exception\CannotGenerateIds; use Doctrine\ORM\Mapping\Exception\InvalidCustomGenerator; -use Doctrine\ORM\Mapping\Exception\TableGeneratorNotImplementedYet; use Doctrine\ORM\Mapping\Exception\UnknownGeneratorType; use Doctrine\Persistence\Mapping\AbstractClassMetadataFactory; use Doctrine\Persistence\Mapping\ClassMetadata as ClassMetadataInterface; @@ -617,16 +615,6 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void $class->setIdGenerator(new AssignedGenerator()); break; - case ClassMetadata::GENERATOR_TYPE_UUID: - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/7312', - 'Mapping for %s: the "UUID" id generator strategy is deprecated with no replacement', - $class->name - ); - $class->setIdGenerator(new UuidGenerator()); - break; - case ClassMetadata::GENERATOR_TYPE_CUSTOM: $definition = $class->customGeneratorDefinition; if ($definition === null) { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index c4e1c9e3094..39f66bb2751 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -14,7 +14,6 @@ use Doctrine\Deprecations\Deprecation; use Doctrine\Instantiator\Instantiator; use Doctrine\Instantiator\InstantiatorInterface; -use Doctrine\ORM\Cache\Exception\CacheException; use Doctrine\ORM\Cache\Exception\NonCacheableEntityAssociation; use Doctrine\ORM\Id\AbstractIdGenerator; use Doctrine\Persistence\Mapping\ClassMetadata; @@ -111,15 +110,6 @@ class ClassMetadataInfo implements ClassMetadata */ public const GENERATOR_TYPE_SEQUENCE = 2; - /** - * TABLE means a separate table is used for id generation. - * Offers full portability (in that it results in an exception being thrown - * no matter the platform). - * - * @deprecated no replacement planned - */ - public const GENERATOR_TYPE_TABLE = 3; - /** * IDENTITY means an identity column is used for id generation. The database * will fill in the id column on insertion. Platforms that do not support @@ -134,14 +124,6 @@ class ClassMetadataInfo implements ClassMetadata */ public const GENERATOR_TYPE_NONE = 5; - /** - * UUID means that a UUID/GUID expression is used for id generation. Full - * portability is currently not guaranteed. - * - * @deprecated use an application-side generator instead - */ - public const GENERATOR_TYPE_UUID = 6; - /** * CUSTOM means that customer will use own ID generator that supposedly work */ @@ -2231,18 +2213,6 @@ public function isIdGeneratorSequence() return $this->generatorType === self::GENERATOR_TYPE_SEQUENCE; } - /** - * Checks whether the class uses a table for id generation. - * - * @deprecated - * - * @return false - */ - public function isIdGeneratorTable() - { - return false; - } - /** * Checks whether the class has a natural identifier/pk (which means it does * not use any Id generator. @@ -2254,16 +2224,6 @@ public function isIdentifierNatural() return $this->generatorType === self::GENERATOR_TYPE_NONE; } - /** - * Checks whether the class use a UUID for id generation. - * - * @return bool - */ - public function isIdentifierUuid() - { - return $this->generatorType === self::GENERATOR_TYPE_UUID; - } - /** * Gets the type of a field. * diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 086a3baf879..a65412dae7b 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -5,12 +5,7 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\Annotations\Reader; -use Doctrine\DBAL\Types\Type; -use Doctrine\ORM\Annotation; -use Doctrine\ORM\Cache\Exception\CacheException; use Doctrine\ORM\Events; -use Doctrine\ORM\Id\TableGenerator; use Doctrine\ORM\Mapping; use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; use Doctrine\ORM\Mapping\MappingException; diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index 06d6b0243c7..437c7fcdfd5 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -221,7 +221,6 @@ class EntityGenerator ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE => 'SEQUENCE', ClassMetadataInfo::GENERATOR_TYPE_IDENTITY => 'IDENTITY', ClassMetadataInfo::GENERATOR_TYPE_NONE => 'NONE', - ClassMetadataInfo::GENERATOR_TYPE_UUID => 'UUID', ClassMetadataInfo::GENERATOR_TYPE_CUSTOM => 'CUSTOM', ]; diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php index 1f59747f549..ea1cb540d44 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php @@ -253,9 +253,6 @@ protected function _getIdGeneratorTypeString($type) case ClassMetadataInfo::GENERATOR_TYPE_IDENTITY: return 'IDENTITY'; - case ClassMetadataInfo::GENERATOR_TYPE_UUID: - return 'UUID'; - case ClassMetadataInfo::GENERATOR_TYPE_CUSTOM: return 'CUSTOM'; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d74880cfddf..e8c0added82 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -215,16 +215,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Event/PreFlushEventArgs.php - - - message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getTableHiLoCurrentValSql\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Id/TableGenerator.php - - - - message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getTableHiLoUpdateNextValSql\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Id/TableGenerator.php - - message: "#^Parameter \\#2 \\$discrMap of static method Doctrine\\\\ORM\\\\Internal\\\\Hydration\\\\HydrationException\\:\\:invalidDiscriminatorValue\\(\\) expects array\\, array\\ given\\.$#" count: 1 @@ -2092,7 +2082,7 @@ parameters: path: lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" + message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" count: 1 path: lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php @@ -2102,7 +2092,7 @@ parameters: path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" + message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" count: 2 path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php @@ -2112,7 +2102,7 @@ parameters: path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" + message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" count: 1 path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php diff --git a/phpstan.neon b/phpstan.neon index 2ccd6581380..b43bc6e6af3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,9 +4,6 @@ includes: parameters: ignoreErrors: - # deprecations from doctrine/dbal:3.x - - '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getGuidExpression\(\).$/' - # Fallback logic for DBAL 2 - message: '/HelperSet constructor expects/' diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 2ab865d4dd2..8c68f21e0ff 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -415,8 +415,7 @@ - - copy + getHydrator transactional transactional @@ -610,17 +609,6 @@ (string) $em->getConnection()->lastInsertId($this->sequenceName) - - - $currentLevel - $this->_nextValue - $this->_nextValue - - - getTableHiLoCurrentValSql - getTableHiLoUpdateNextValSql - - $vertex->state !== self::VISITED @@ -817,12 +805,6 @@ $parent new $definition['class']() - - new UuidGenerator() - - - ClassMetadata::GENERATOR_TYPE_UUID - addNamedNativeQuery addNamedQuery @@ -922,9 +904,6 @@ $class $subclass - - self::GENERATOR_TYPE_UUID - $this->columnNames $this->columnNames @@ -3491,9 +3470,6 @@ $this->getClassToExtend() ?: $metadata->name array_map('strlen', $paramTypes) - - ClassMetadataInfo::GENERATOR_TYPE_UUID - $metadata->reflClass !== null class_exists($metadata->name) @@ -3575,9 +3551,6 @@ ExportException::attemptOverwriteExistingFile($path) - - ClassMetadataInfo::GENERATOR_TYPE_UUID - string diff --git a/psalm.xml b/psalm.xml index 71ab6838c82..24d8872268d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -31,7 +31,6 @@ - @@ -110,11 +109,5 @@ - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php deleted file mode 100644 index a10514c661d..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php +++ /dev/null @@ -1,89 +0,0 @@ -expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/7312'); - $this->_em->getClassMetadata(UUIDEntity::class); - } - - public function testGenerateUUID(): void - { - if (! method_exists(AbstractPlatform::class, 'getGuidExpression')) { - self::markTestSkipped('Test valid for doctrine/dbal:2.x only.'); - } - - if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - self::markTestSkipped('Currently restricted to MySQL platform.'); - } - - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(UUIDEntity::class), - ]); - $entity = new UUIDEntity(); - - $this->_em->persist($entity); - self::assertNotNull($entity->getId()); - self::assertGreaterThan(0, strlen($entity->getId())); - } - - public function testItCannotBeInitialised(): void - { - if (method_exists(AbstractPlatform::class, 'getGuidExpression')) { - self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); - } - - $this->expectException(NotSupported::class); - $this->_em->getClassMetadata(UUIDEntity::class); - } -} - -/** - * @Entity - */ -class UUIDEntity -{ - /** - * @var string - * @Id - * @Column(type="string") - * @GeneratedValue(strategy="UUID") - */ - private $id; - - /** - * Get id. - * - * @return string. - */ - public function getId(): string - { - return $this->id; - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index 9c243210a9e..23353fec799 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -754,10 +754,6 @@ public function testGetIdGeneratorTypeString(): void continue; } - if ($name === 'GENERATOR_TYPE_TABLE') { - continue; - } - $expected = preg_replace($pattern, '', $name); $actual = $method->invoke($this->generator, $value); From e13714e400d6741591aa5cd31b61ff045fde63f5 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 3 Oct 2021 22:59:44 +0200 Subject: [PATCH 006/475] Remote Query::iterate() (#9070) --- UPGRADE.md | 6 ++ lib/Doctrine/ORM/AbstractQuery.php | 36 ------- .../Internal/Hydration/AbstractHydrator.php | 39 +------- .../ORM/Internal/Hydration/IterableResult.php | 94 ------------------- lib/Doctrine/ORM/Query.php | 19 ---- psalm-baseline.xml | 40 +------- .../ORM/Functional/LifecycleCallbackTest.php | 19 ---- .../Tests/ORM/Functional/QueryTest.php | 50 +--------- .../ORM/Functional/Ticket/DDC309Test.php | 39 -------- .../ORM/Hydration/AbstractHydratorTest.php | 5 +- .../Tests/ORM/Hydration/ArrayHydratorTest.php | 31 +++--- .../ORM/Hydration/ObjectHydratorTest.php | 35 ++++--- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 19 +--- 13 files changed, 45 insertions(+), 387 deletions(-) delete mode 100644 lib/Doctrine/ORM/Internal/Hydration/IterableResult.php diff --git a/UPGRADE.md b/UPGRADE.md index 461ec2ba098..e5ba78538a4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -29,6 +29,12 @@ The following classes have been removed: Using the `UUID` strategy for generating identifiers is not supported anymore. +## BC BREAK: Removed `Query::iterate()` + +The deprecated methods `Query::iterate()` and `AbstractHydrator::iterate()` +have been removed along with the `IterableResult` class. Use `toIterable()` +instead. + # Upgrade to 2.10 ## BC Break: Removed `TABLE` id generator strategy diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index f23144810e0..7090f6b7664 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -11,12 +11,10 @@ use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Result; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\Exception\InvalidResultCacheDriver; use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\ORM\Cache\TimestampCacheKey; -use Doctrine\ORM\Internal\Hydration\IterableResult; use Doctrine\ORM\Mapping\MappingException as ORMMappingException; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\QueryException; @@ -1029,40 +1027,6 @@ public function getHints() return $this->_hints; } - /** - * Executes the query and returns an IterableResult that can be used to incrementally - * iterate over the result. - * - * @deprecated 2.8 Use {@see toIterable} instead. See https://github.com/doctrine/orm/issues/8463 - * - * @param ArrayCollection|mixed[]|null $parameters The query parameters. - * @param string|int|null $hydrationMode The hydration mode to use. - * - * @return IterableResult - */ - public function iterate($parameters = null, $hydrationMode = null) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8463', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use toIterable() instead.', - __METHOD__ - ); - - if ($hydrationMode !== null) { - $this->setHydrationMode($hydrationMode); - } - - if (! empty($parameters)) { - $this->setParameters($parameters); - } - - $rsm = $this->getResultSetMapping(); - $stmt = $this->_doExecute(); - - return $this->_em->newHydrator($this->_hydrationMode)->iterate($stmt, $rsm, $this->_hints); - } - /** * Executes the query and returns an iterable that can be used to incrementally * iterate over the result. diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 779f73cfd0e..8eb0628f9c8 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -103,39 +103,6 @@ public function __construct(EntityManagerInterface $em) $this->_uow = $em->getUnitOfWork(); } - /** - * Initiates a row-by-row hydration. - * - * @deprecated - * - * @param Result|ResultStatement $stmt - * @param ResultSetMapping $resultSetMapping - * @psalm-param array $hints - * - * @return IterableResult - */ - public function iterate($stmt, $resultSetMapping, array $hints = []) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8463', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use toIterable() instead.', - __METHOD__ - ); - - $this->_stmt = $stmt instanceof ResultStatement ? ForwardCompatibilityResult::ensure($stmt) : $stmt; - $this->_rsm = $resultSetMapping; - $this->_hints = $hints; - - $evm = $this->_em->getEventManager(); - - $evm->addEventListener([Events::onClear], $this); - - $this->prepare(); - - return new IterableResult($this); - } - /** * Initiates a row-by-row hydration. * @@ -272,7 +239,7 @@ public function hydrateAll($stmt, $resultSetMapping, array $hints = []) /** * Hydrates a single row returned by the current statement instance during - * row-by-row hydration with {@link iterate()} or {@link toIterable()}. + * row-by-row hydration with {@link toIterable()}. * * @return mixed[]|false */ @@ -307,7 +274,7 @@ public function onClear($eventArgs) /** * Executes one-time preparation tasks, once each time hydration is started - * through {@link hydrateAll} or {@link iterate()}. + * through {@link hydrateAll} or {@link toIterable()}. * * @return void */ @@ -317,7 +284,7 @@ protected function prepare() /** * Executes one-time cleanup tasks at the end of a hydration that was initiated - * through {@link hydrateAll} or {@link iterate()}. + * through {@link hydrateAll} or {@link toIterable()}. * * @return void */ diff --git a/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php b/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php deleted file mode 100644 index 4c5b0af137f..00000000000 --- a/lib/Doctrine/ORM/Internal/Hydration/IterableResult.php +++ /dev/null @@ -1,94 +0,0 @@ -_hydrator = $hydrator; - } - - /** - * @return void - * - * @throws HydrationException - */ - #[ReturnTypeWillChange] - public function rewind() - { - if ($this->_rewinded === true) { - throw new HydrationException('Can only iterate a Result once.'); - } - - $this->_current = $this->next(); - $this->_rewinded = true; - } - - /** - * Gets the next set of results. - * - * @return mixed[]|false - */ - #[ReturnTypeWillChange] - public function next() - { - $this->_current = $this->_hydrator->hydrateRow(); - $this->_key++; - - return $this->_current; - } - - /** - * @return mixed - */ - #[ReturnTypeWillChange] - public function current() - { - return $this->_current; - } - - /** - * @return int - */ - #[ReturnTypeWillChange] - public function key() - { - return $this->_key; - } - - /** - * @return bool - */ - #[ReturnTypeWillChange] - public function valid() - { - return $this->_current !== false; - } -} diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index fe4214195fe..de1f97c326b 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -7,12 +7,10 @@ use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\Cache\Psr6\DoctrineProvider; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Types\Type; use Doctrine\Deprecations\Deprecation; -use Doctrine\ORM\Internal\Hydration\IterableResult; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\AST\DeleteStatement; use Doctrine\ORM\Query\AST\SelectStatement; @@ -692,23 +690,6 @@ public function getMaxResults(): ?int return $this->maxResults; } - /** - * Executes the query and returns an IterableResult that can be used to incrementally - * iterated over the result. - * - * @deprecated - * - * @param ArrayCollection|mixed[]|null $parameters The query parameters. - * @param string|int $hydrationMode The hydration mode to use. - * @psalm-param ArrayCollection|array|null $parameters - */ - public function iterate($parameters = null, $hydrationMode = self::HYDRATE_OBJECT): IterableResult - { - $this->setHint(self::HINT_INTERNAL_ITERATION, true); - - return parent::iterate($parameters, $hydrationMode); - } - /** {@inheritDoc} */ public function toIterable(iterable $parameters = [], $hydrationMode = self::HYDRATE_OBJECT): iterable { diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8c68f21e0ff..97d14399f8a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,12 +1,6 @@ - - IterableResult - - - iterate - $resultCacheDriver !== null && ! ($resultCacheDriver instanceof \Doctrine\Common\Cache\Cache) @@ -33,7 +27,7 @@ $this->_queryCacheProfile->getResultCacheDriver() $this->cacheMode - + $stmt $stmt @@ -502,10 +496,9 @@ $entityName $entityName - + $config->getProxyDir() $config->getProxyNamespace() - $entity createCache @@ -616,10 +609,6 @@ - - IterableResult - new IterableResult($this) - $resultSetMapping @@ -642,18 +631,6 @@ $result - - - mixed[]|false - - - $this->_hydrator->hydrateRow() - $this->next() - - - $this->_current !== false - - array_keys($discrMap) @@ -1910,12 +1887,6 @@ - - IterableResult - - - parent::iterate($parameters, $hydrationMode) - $this->_resultSetMapping === null $this->_resultSetMapping === null @@ -1930,10 +1901,6 @@ parent::setHint($name, $value) parent::setHydrationMode($hydrationMode) - - $hydrationMode - $parameters - self self @@ -3218,10 +3185,9 @@ $this->cacheMode - + $spacePos $spacePos - strpos($join, '.') $spacePos diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index 404012295fe..1fbc995d110 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -29,7 +29,6 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; -use Exception; use function count; use function current; @@ -267,15 +266,6 @@ public function testCascadedEntitiesNotLoadedInPostLoadDuringIteration(): void $query = $this->_em->createQuery(sprintf($dql, $e1->getId(), $e2->getId())); - $result = iterator_to_array($query->iterate()); - - foreach ($result as $entity) { - self::assertTrue($entity[0]->postLoadCallbackInvoked); - self::assertFalse($entity[0]->postLoadCascaderNotNull); - - break; - } - $iterableResult = iterator_to_array($query->toIterable()); foreach ($iterableResult as $entity) { @@ -302,15 +292,6 @@ public function testCascadedEntitiesNotLoadedInPostLoadDuringIterationWithSimple 'SELECT e FROM Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity AS e' ); - $result = iterator_to_array($query->iterate(null, Query::HYDRATE_SIMPLEOBJECT)); - - foreach ($result as $entity) { - self::assertTrue($entity[0]->postLoadCallbackInvoked); - self::assertFalse($entity[0]->postLoadCascaderNotNull); - - break; - } - $result = iterator_to_array($query->toIterable([], Query::HYDRATE_SIMPLEOBJECT)); foreach ($result as $entity) { diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index c25fab0996a..3829df1cac3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -21,7 +21,6 @@ use function array_values; use function count; -use function is_array; use function iterator_to_array; /** @@ -220,8 +219,7 @@ public function testIterateResultAsArrayAndParams(): void $this->_em->clear(); $articleId = $article1->id; - $query = $this->_em->createQuery('select a from ' . CmsArticle::class . ' a WHERE a.topic = ?1'); - $articles = $query->iterate(new ArrayCollection([new Parameter(1, 'Doctrine 2')]), Query::HYDRATE_ARRAY); + $query = $this->_em->createQuery('select a from ' . CmsArticle::class . ' a WHERE a.topic = ?1'); $expectedArticle = [ 'id' => $articleId, @@ -230,11 +228,6 @@ public function testIterateResultAsArrayAndParams(): void 'version' => 1, ]; - $articles = iterator_to_array($articles, false); - - self::assertCount(1, $articles); - self::assertEquals([[$expectedArticle]], $articles); - $articles = $query->toIterable( new ArrayCollection([new Parameter(1, 'Doctrine 2')]), Query::HYDRATE_ARRAY @@ -263,25 +256,6 @@ public function testIterateResultIterativelyBuildUpUnitOfWork(): void $this->_em->clear(); $query = $this->_em->createQuery('select a from ' . CmsArticle::class . ' a'); - $articles = $query->iterate(); - - $iteratedCount = 0; - $topics = []; - - foreach ($articles as $row) { - $article = $row[0]; - $topics[] = $article->topic; - - $identityMap = $this->_em->getUnitOfWork()->getIdentityMap(); - $identityMapCount = count($identityMap[CmsArticle::class]); - self::assertGreaterThan($iteratedCount, $identityMapCount); - - $iteratedCount++; - } - - self::assertSame(['Doctrine 2', 'Symfony 2'], $topics); - self::assertSame(2, $iteratedCount); - $articles = $query->toIterable(); $iteratedCount = 0; @@ -364,21 +338,6 @@ public function testIterateResultClearEveryCycle(): void $query = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); - $articles = $query->iterate(); - $iteratedCount = 0; - $topics = []; - foreach ($articles as $row) { - $article = $row[0]; - $topics[] = $article->topic; - - $this->_em->clear(); - - $iteratedCount++; - } - - self::assertSame(['Doctrine 2', 'Symfony 2'], $topics); - self::assertSame(2, $iteratedCount); - $articles = $query->toIterable(); $iteratedCount = 0; $topics = []; @@ -396,13 +355,6 @@ public function testIterateResultClearEveryCycle(): void $this->_em->flush(); } - public function testIterateResultFetchJoinedCollectionThrowsException(): void - { - $this->expectException(QueryException::class); - $query = $this->_em->createQuery("SELECT u, a FROM ' . CmsUser::class . ' u JOIN u.articles a"); - $query->iterate(); - } - public function testToIterableResultFetchJoinedCollectionThrowsException(): void { $this->expectException(QueryException::class); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php index 37d61d7191a..be68891f06d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php @@ -37,45 +37,6 @@ protected function tearDown(): void parent::tearDown(); } - public function testTwoIterateHydrations(): void - { - $c1 = new DDC309Country(); - $c2 = new DDC309Country(); - $u1 = new DDC309User(); - $u2 = new DDC309User(); - - $this->_em->persist($c1); - $this->_em->persist($c2); - $this->_em->persist($u1); - $this->_em->persist($u2); - $this->_em->flush(); - $this->_em->clear(); - - $q = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309Country c')->iterate(); - $c = $q->next(); - - self::assertEquals(1, $c[0]->id); - - $r = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309User u')->iterate(); - $u = $r->next(); // This line breaks - - self::assertEquals(1, $u[0]->id); - - $c = $q->next(); - $u = $r->next(); - - self::assertEquals(2, $c[0]->id); - self::assertEquals(2, $u[0]->id); - - do { - $q->next(); - } while ($q->valid()); - - do { - $r->next(); - } while ($r->valid()); - } - public function testTwoToIterableHydrations(): void { $c1 = new DDC309Country(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php index 3ee79f473a6..a1dd5ec0589 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php @@ -6,7 +6,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Result; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Events; @@ -43,7 +42,7 @@ protected function setUp(): void $mockEntityManagerInterface = $this->createMock(EntityManagerInterface::class); $this->mockEventManager = $this->createMock(EventManager::class); $this->mockResult = $this->createMock(Result::class); - $this->mockResultMapping = $this->getMockBuilder(ResultSetMapping::class); + $this->mockResultMapping = $this->createMock(ResultSetMapping::class); $mockEntityManagerInterface ->expects(self::any()) @@ -95,7 +94,7 @@ public function testOnClearEventListenerIsDetachedOnCleanup(): void $this->assertTrue($eventListenerHasBeenRegistered); }); - iterator_to_array($this->hydrator->iterate($this->mockResult, $this->mockResultMapping)); + iterator_to_array($this->hydrator->toIterable($this->mockResult, $this->mockResultMapping)); } /** diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php index 5f70c7f2721..dba8093dff1 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php @@ -1023,19 +1023,16 @@ public function testResultIteration(): void $stmt = ArrayResultFactory::createFromArray($resultSet); $hydrator = new ArrayHydrator($this->entityManager); - $iterator = $hydrator->iterate($stmt, $rsm); + $iterator = $hydrator->toIterable($stmt, $rsm); $rowNum = 0; - while (($row = $iterator->next()) !== false) { - self::assertCount(1, $row); - self::assertIsArray($row[0]); - + foreach ($iterator as $row) { if ($rowNum === 0) { - self::assertEquals(1, $row[0]['id']); - self::assertEquals('romanb', $row[0]['name']); + self::assertEquals(1, $row['id']); + self::assertEquals('romanb', $row['name']); } elseif ($rowNum === 1) { - self::assertEquals(2, $row[0]['id']); - self::assertEquals('jwage', $row[0]['name']); + self::assertEquals(2, $row['id']); + self::assertEquals('jwage', $row['name']); } ++$rowNum; @@ -1068,20 +1065,18 @@ public function testResultIterationWithAliasedUserEntity(): void $stmt = ArrayResultFactory::createFromArray($resultSet); $hydrator = new ArrayHydrator($this->entityManager); - $iterator = $hydrator->iterate($stmt, $rsm); + $iterator = $hydrator->toIterable($stmt, $rsm); $rowNum = 0; - while (($row = $iterator->next()) !== false) { - self::assertCount(1, $row); - self::assertArrayHasKey(0, $row); - self::assertArrayHasKey('user', $row[0]); + foreach ($iterator as $row) { + self::assertArrayHasKey('user', $row); if ($rowNum === 0) { - self::assertEquals(1, $row[0]['user']['id']); - self::assertEquals('romanb', $row[0]['user']['name']); + self::assertEquals(1, $row['user']['id']); + self::assertEquals('romanb', $row['user']['name']); } elseif ($rowNum === 1) { - self::assertEquals(2, $row[0]['user']['id']); - self::assertEquals('jwage', $row[0]['user']['name']); + self::assertEquals(2, $row['user']['id']); + self::assertEquals('jwage', $row['user']['name']); } ++$rowNum; diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index 11b03b1a5c8..cceb3d82ef6 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -28,7 +28,6 @@ use Doctrine\Tests\Models\Hydration\SimpleEntity; use function count; -use function is_array; class ObjectHydratorTest extends HydrationTestCase { @@ -1262,23 +1261,22 @@ public function testResultIteration(): void $hydrator = new ObjectHydrator($this->entityManager); - $iterableResult = $hydrator->iterate( + $iterableResult = $hydrator->toIterable( ArrayResultFactory::createFromArray($resultSet), $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true] ); $rowNum = 0; - while (($row = $iterableResult->next()) !== false) { - self::assertEquals(1, count($row)); - self::assertInstanceOf(CmsUser::class, $row[0]); + foreach ($iterableResult as $row) { + self::assertInstanceOf(CmsUser::class, $row); if ($rowNum === 0) { - self::assertEquals(1, $row[0]->id); - self::assertEquals('romanb', $row[0]->name); + self::assertEquals(1, $row->id); + self::assertEquals('romanb', $row->name); } elseif ($rowNum === 1) { - self::assertEquals(2, $row[0]->id); - self::assertEquals('jwage', $row[0]->name); + self::assertEquals(2, $row->id); + self::assertEquals('jwage', $row->name); } ++$rowNum; @@ -1337,24 +1335,23 @@ public function testResultIterationWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $rowNum = 0; - $iterableResult = $hydrator->iterate( + $iterableResult = $hydrator->toIterable( ArrayResultFactory::createFromArray($resultSet), $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true] ); - while (($row = $iterableResult->next()) !== false) { - self::assertEquals(1, count($row)); - self::assertArrayHasKey(0, $row); - self::assertArrayHasKey('user', $row[0]); - self::assertInstanceOf(CmsUser::class, $row[0]['user']); + foreach ($iterableResult as $row) { + self::assertCount(1, $row); + self::assertArrayHasKey('user', $row); + self::assertInstanceOf(CmsUser::class, $row['user']); if ($rowNum === 0) { - self::assertEquals(1, $row[0]['user']->id); - self::assertEquals('romanb', $row[0]['user']->name); + self::assertEquals(1, $row['user']->id); + self::assertEquals('romanb', $row['user']->name); } elseif ($rowNum === 1) { - self::assertEquals(2, $row[0]['user']->id); - self::assertEquals('jwage', $row[0]['user']->name); + self::assertEquals(2, $row['user']->id); + self::assertEquals('jwage', $row['user']->name); } ++$rowNum; diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 31762caa486..67f04bcea38 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -13,7 +13,6 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Types; -use Doctrine\ORM\Internal\Hydration\IterableResult; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\UnitOfWork; @@ -164,14 +163,6 @@ public function testQueryDefaultResultCacheLegacy(): void self::assertSame($this->entityManager->getConfiguration()->getResultCache(), CacheAdapter::wrap($q->getQueryCacheProfile()->getResultCacheDriver())); } - public function testIterateWithNoDistinctAndWrongSelectClause(): void - { - $this->expectException(QueryException::class); - - $q = $this->entityManager->createQuery('select u, a from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a'); - $q->iterate(); - } - public function testToIterableWithNoDistinctAndWrongSelectClause(): void { $this->expectException(QueryException::class); @@ -180,14 +171,6 @@ public function testToIterableWithNoDistinctAndWrongSelectClause(): void $q->toIterable(); } - public function testIterateWithNoDistinctAndWithValidSelectClause(): void - { - $this->expectException(QueryException::class); - - $q = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a'); - $q->iterate(); - } - public function testToIterableWithNoDistinctAndWithValidSelectClause(): void { $this->expectException(QueryException::class); @@ -200,7 +183,7 @@ public function testIterateWithDistinct(): void { $q = $this->entityManager->createQuery('SELECT DISTINCT u from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a'); - self::assertInstanceOf(IterableResult::class, $q->iterate()); + self::assertInstanceOf(Generator::class, $q->toIterable()); } public function testIterateEmptyResult(): void From 413c33274d02ca4d320a6ec95dff8c3951c9ca5c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 3 Oct 2021 23:32:44 +0200 Subject: [PATCH 007/475] Remove support for DBAL 2 (#9069) --- .github/workflows/continuous-integration.yml | 50 ------- .github/workflows/static-analysis.yml | 6 - composer.json | 9 +- docs/en/reference/tools.rst | 2 +- .../Internal/Hydration/AbstractHydrator.php | 59 +------- lib/Doctrine/ORM/Internal/SQLResultCasing.php | 5 - .../ORM/Mapping/Driver/DatabaseDriver.php | 8 -- .../Console/Command/ConvertMappingCommand.php | 6 +- .../ORM/Tools/Console/ConsoleRunner.php | 12 +- .../Pagination/LimitSubqueryOutputWalker.php | 2 - lib/Doctrine/ORM/Tools/SchemaTool.php | 4 +- phpcs.xml.dist | 2 +- phpstan-dbal2.neon | 27 ---- phpstan.neon | 24 +--- psalm.xml | 16 --- .../Tests/Mocks/ArrayResultFactory.php | 7 - .../Doctrine/Tests/Mocks/CacheRegionMock.php | 2 +- tests/Doctrine/Tests/Mocks/ConnectionMock.php | 10 +- .../Tests/Mocks/DatabasePlatformMock.php | 5 - .../Tests/Mocks/DriverConnectionMock.php | 14 +- tests/Doctrine/Tests/Mocks/DriverMock.php | 25 +--- .../Doctrine/Tests/Mocks/DriverResultMock.php | 45 +----- tests/Doctrine/Tests/Mocks/ResultMock.php | 129 ------------------ .../Doctrine/Tests/Mocks/ResultStatement.php | 20 --- tests/Doctrine/Tests/Mocks/StatementMock.php | 62 --------- .../ORM/Functional/Ticket/DDC1734Test.php | 5 +- .../ORM/Functional/Ticket/GH7875Test.php | 32 +---- .../ORM/Query/SelectSqlGenerationTest.php | 4 - .../LimitSubqueryOutputWalkerTest.php | 5 - tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 7 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 5 +- tests/Doctrine/Tests/TestUtil.php | 13 +- 32 files changed, 32 insertions(+), 590 deletions(-) delete mode 100644 phpstan-dbal2.neon delete mode 100644 tests/Doctrine/Tests/Mocks/ResultMock.php delete mode 100644 tests/Doctrine/Tests/Mocks/ResultStatement.php diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9b7cbc4d0a9..cf02645b8c6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -23,7 +23,6 @@ jobs: strategy: matrix: php-version: - - "7.2" - "7.3" - "7.4" - "8.0" @@ -31,8 +30,6 @@ jobs: dbal-version: - "default" include: - - php-version: "8.0" - dbal-version: "2.13" - php-version: "8.1" dbal-version: "3.2@dev" @@ -88,10 +85,6 @@ jobs: postgres-version: - "9.6" - "13" - include: - - php-version: "8.0" - dbal-version: "2.13" - postgres-version: "13" services: postgres: @@ -151,11 +144,6 @@ jobs: extension: - "mysqli" - "pdo_mysql" - include: - - php-version: "8.0" - dbal-version: "2.13" - mariadb-version: "10.5" - extension: "pdo_mysql" services: mariadb: @@ -218,11 +206,6 @@ jobs: extension: - "mysqli" - "pdo_mysql" - include: - - php-version: "8.0" - dbal-version: "2.13" - mysql-version: "8.0" - extension: "pdo_mysql" services: mysql: @@ -274,39 +257,6 @@ jobs: path: "coverage*.xml" - phpunit-lower-php-versions: - name: "PHPUnit with SQLite" - runs-on: "ubuntu-20.04" - - strategy: - matrix: - php-version: - - "7.1" - deps: - - "highest" - - "lowest" - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - with: - fetch-depth: 2 - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - ini-values: "zend.assertions=1" - - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v1" - with: - dependency-versions: "${{ matrix.deps }}" - - - name: "Run PHPUnit" - run: "vendor/bin/phpunit -c ci/github/phpunit/sqlite.xml" - - upload_coverage: name: "Upload coverage to Codecov" runs-on: "ubuntu-20.04" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 7556eac641b..5d3f988c43c 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -21,7 +21,6 @@ jobs: - "8.0" dbal-version: - "default" - - "2.13" steps: - name: "Checkout code" @@ -46,10 +45,6 @@ jobs: run: "vendor/bin/phpstan analyse" if: "${{ matrix.dbal-version == 'default' }}" - - name: "Run a static analysis with phpstan/phpstan" - run: "vendor/bin/phpstan analyse -c phpstan-dbal2.neon" - if: "${{ matrix.dbal-version == '2.13' }}" - static-analysis-psalm: name: "Static Analysis with Psalm" runs-on: "ubuntu-20.04" @@ -61,7 +56,6 @@ jobs: - "8.0" dbal-version: - "default" - - "2.13" steps: - name: "Checkout code" diff --git a/composer.json b/composer.json index 2a6df9d2895..bee7e0921bd 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,14 @@ "sort-packages": true }, "require": { - "php": "^7.1 ||^8.0", + "php": "^7.3 || ^8.0", "ext-ctype": "*", "ext-pdo": "*", "composer/package-versions-deprecated": "^1.8", "doctrine/cache": "^1.12.1 || ^2.1.1", "doctrine/collections": "^1.5", "doctrine/common": "^3.0.3", - "doctrine/dbal": "^2.13.1 || ^3.1.1", + "doctrine/dbal": "^3.1.1", "doctrine/deprecations": "^0.5.3", "doctrine/event-manager": "^1.1", "doctrine/inflector": "^1.4 || ^2.0", @@ -32,15 +32,14 @@ "doctrine/persistence": "^2.2", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/polyfill-php72": "^1.23", "symfony/polyfill-php80": "^1.15" }, "require-dev": { "doctrine/annotations": "^1.13", "doctrine/coding-standard": "^9.0", - "phpbench/phpbench": "^0.16.10 || ^1.0", + "phpbench/phpbench": "^1.0", "phpstan/phpstan": "0.12.99", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.4", + "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "3.6.0", "symfony/cache": "^4.4 || ^5.2", "symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0", diff --git a/docs/en/reference/tools.rst b/docs/en/reference/tools.rst index ad60e5317f9..2a4ba042e5f 100644 --- a/docs/en/reference/tools.rst +++ b/docs/en/reference/tools.rst @@ -342,7 +342,7 @@ First you need to retrieve the metadata instances with the getConfiguration()->setMetadataDriverImpl( new \Doctrine\ORM\Mapping\Driver\DatabaseDriver( - $em->getConnection()->getSchemaManager() + $em->getConnection()->createSchemaManager() ) ); diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 8eb0628f9c8..14b00f85d36 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -4,12 +4,9 @@ namespace Doctrine\ORM\Internal\Hydration; -use Doctrine\DBAL\Driver\ResultStatement; -use Doctrine\DBAL\ForwardCompatibility\Result as ForwardCompatibilityResult; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Result; use Doctrine\DBAL\Types\Type; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadata; @@ -19,15 +16,12 @@ use Generator; use LogicException; use ReflectionClass; -use TypeError; use function array_map; use function array_merge; use function count; use function end; -use function get_debug_type; use function in_array; -use function sprintf; /** * Base class for all hydrators. A hydrator is a class that provides some form @@ -106,37 +100,12 @@ public function __construct(EntityManagerInterface $em) /** * Initiates a row-by-row hydration. * - * @param Result|ResultStatement $stmt * @psalm-param array $hints * * @return Generator - * - * @final */ - public function toIterable($stmt, ResultSetMapping $resultSetMapping, array $hints = []): iterable + final public function toIterable(Result $stmt, ResultSetMapping $resultSetMapping, array $hints = []): Generator { - if (! $stmt instanceof Result) { - if (! $stmt instanceof ResultStatement) { - throw new TypeError(sprintf( - '%s: Expected parameter $stmt to be an instance of %s or %s, got %s', - __METHOD__, - Result::class, - ResultStatement::class, - get_debug_type($stmt) - )); - } - - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/8796', - '%s: Passing a result as $stmt that does not implement %s is deprecated and will cause a TypeError on 3.0', - __METHOD__, - Result::class - ); - - $stmt = ForwardCompatibilityResult::ensure($stmt); - } - $this->_stmt = $stmt; $this->_rsm = $resultSetMapping; $this->_hints = $hints; @@ -191,36 +160,12 @@ final protected function resultSetMapping(): ResultSetMapping /** * Hydrates all rows returned by the passed statement instance at once. * - * @param Result|ResultStatement $stmt - * @param object $resultSetMapping * @psalm-param array $hints * * @return mixed[] */ - public function hydrateAll($stmt, $resultSetMapping, array $hints = []) + public function hydrateAll(Result $stmt, object $resultSetMapping, array $hints = []) { - if (! $stmt instanceof Result) { - if (! $stmt instanceof ResultStatement) { - throw new TypeError(sprintf( - '%s: Expected parameter $stmt to be an instance of %s or %s, got %s', - __METHOD__, - Result::class, - ResultStatement::class, - get_debug_type($stmt) - )); - } - - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/8796', - '%s: Passing a result as $stmt that does not implement %s is deprecated and will cause a TypeError on 3.0', - __METHOD__, - Result::class - ); - - $stmt = ForwardCompatibilityResult::ensure($stmt); - } - $this->_stmt = $stmt; $this->_rsm = $resultSetMapping; $this->_hints = $hints; diff --git a/lib/Doctrine/ORM/Internal/SQLResultCasing.php b/lib/Doctrine/ORM/Internal/SQLResultCasing.php index 8d1bd175690..612d15ace8d 100644 --- a/lib/Doctrine/ORM/Internal/SQLResultCasing.php +++ b/lib/Doctrine/ORM/Internal/SQLResultCasing.php @@ -10,7 +10,6 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use function method_exists; use function strtolower; use function strtoupper; @@ -29,10 +28,6 @@ private function getSQLResultCasing(AbstractPlatform $platform, string $column): return strtolower($column); } - if (method_exists(AbstractPlatform::class, 'getSQLResultCasing')) { - return $platform->getSQLResultCasing($column); - } - return $column; } } diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index bef8e1fe8e2..e3669e58836 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -35,13 +35,6 @@ */ class DatabaseDriver implements MappingDriver { - /** - * Replacement for {@see Types::JSON_ARRAY}. - * - * To be removed as soon as support for DBAL 2 is dropped. - */ - private const JSON_ARRAY = 'json_array'; - /** @var AbstractSchemaManager */ private $_sm; @@ -404,7 +397,6 @@ private function buildFieldMapping(string $tableName, Column $column): array case Types::ARRAY: case Types::BLOB: case Types::GUID: - case self::JSON_ARRAY: case Types::OBJECT: case Types::SIMPLE_ARRAY: case Types::STRING: diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php index fc22d2c7664..f7c32f1f0a0 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php @@ -90,11 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $em = $this->getEntityManager($input); if ($input->getOption('from-database') === true) { - $databaseDriver = new DatabaseDriver( - method_exists(Connection::class, 'createSchemaManager') - ? $em->getConnection()->createSchemaManager() - : $em->getConnection()->getSchemaManager() - ); + $databaseDriver = new DatabaseDriver($em->getConnection()->createSchemaManager()); $em->getConfiguration()->setMetadataDriverImpl( $databaseDriver diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index e9bc4bce6ab..504e86edc1a 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -27,13 +27,7 @@ final class ConsoleRunner */ public static function createHelperSet(EntityManagerInterface $entityManager): HelperSet { - $helpers = ['em' => new EntityManagerHelper($entityManager)]; - - if (class_exists(DBALConsole\Helper\ConnectionHelper::class)) { - $helpers['db'] = new DBALConsole\Helper\ConnectionHelper($entityManager->getConnection()); - } - - return new HelperSet($helpers); + return new HelperSet(['em' => new EntityManagerHelper($entityManager)]); } /** @@ -82,10 +76,6 @@ public static function addCommands(Application $cli, ?EntityManagerProvider $ent $connectionProvider = new ConnectionFromManagerProvider($entityManagerProvider); - if (class_exists(DBALConsole\Command\ImportCommand::class)) { - $cli->add(new DBALConsole\Command\ImportCommand()); - } - $cli->addCommands( [ // DBAL Commands diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 8e17376ad31..a93d78183ee 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -9,7 +9,6 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\ORM\EntityManagerInterface; @@ -122,7 +121,6 @@ private function platformSupportsRowNumber(): bool || $this->platform instanceof SQLServer2012Platform // DBAL 3.1 compatibility || $this->platform instanceof SQLServerPlatform || $this->platform instanceof OraclePlatform - || $this->platform instanceof SQLAnywherePlatform || $this->platform instanceof DB2Platform || (method_exists($this->platform, 'supportsRowNumberFunction') && $this->platform->supportsRowNumberFunction()); diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 1225946138a..a2e96080b8f 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -74,9 +74,7 @@ public function __construct(EntityManagerInterface $em) $this->em = $em; $this->platform = $em->getConnection()->getDatabasePlatform(); $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); - $this->schemaManager = method_exists(Connection::class, 'createSchemaManager') - ? $em->getConnection()->createSchemaManager() - : $em->getConnection()->getSchemaManager(); + $this->schemaManager = $em->getConnection()->createSchemaManager(); } /** diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 31665c0a396..e94dd80ebf9 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -9,7 +9,7 @@ - + lib tests diff --git a/phpstan-dbal2.neon b/phpstan-dbal2.neon deleted file mode 100644 index 6bf77b8c6d7..00000000000 --- a/phpstan-dbal2.neon +++ /dev/null @@ -1,27 +0,0 @@ -includes: - - phpstan-baseline.neon - - phpstan-params.neon - -parameters: - ignoreErrors: - # https://github.com/doctrine/collections/pull/282 - - '/Variable \$offset in isset\(\) always exists and is not nullable\./' - # PHPStan doesn't understand our method_exists() safeguards. - - '/Call to an undefined method Doctrine\\DBAL\\Connection::createSchemaManager\(\)\./' - # Class name will change in DBAL 3. - - '/Class Doctrine\\DBAL\\Platforms\\PostgreSqlPlatform referenced with incorrect case: Doctrine\\DBAL\\Platforms\\PostgreSQLPlatform\./' - - # Forward compatibility for DBAL 3.2 - - '/^Call to an undefined method Doctrine\\DBAL\\Cache\\QueryCacheProfile::[gs]etResultCache\(\)\.$/' - - - message: '/^Call to an undefined static method Doctrine\\DBAL\\Configuration::[gs]etResultCache\(\)\.$/' - path: lib/Doctrine/ORM/Configuration.php - - - message: '/^Parameter #3 \$resultCache of class Doctrine\\DBAL\\Cache\\QueryCacheProfile constructor/' - path: lib/Doctrine/ORM/AbstractQuery.php - - # False positive - - - message: '/^Call to an undefined method Doctrine\\Common\\Cache\\Cache::deleteAll\(\)\.$/' - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php diff --git a/phpstan.neon b/phpstan.neon index b43bc6e6af3..a5c409675d2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,30 +4,8 @@ includes: parameters: ignoreErrors: - # Fallback logic for DBAL 2 - - - message: '/HelperSet constructor expects/' - path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php - - - message: '/Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command/' - path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php - - - '/^Class Doctrine\\DBAL\\Platforms\\(PostgreSQL|SQLServer|SQLAnywhere)Platform not found\.$/' - - - - message: '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getSQLResultCasing\(\)\.$/' - path: lib/Doctrine/ORM/Internal/SQLResultCasing.php - - - message: '/^Parameter \$stmt of method .* has invalid typehint type Doctrine\\DBAL\\Driver\\ResultStatement\.$/' - path: lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php - - - message: '/^Class Doctrine\\DBAL\\Driver\\ResultStatement not found\.$/' - path: lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php - - - message: '/^Call to static method ensure\(\) on an unknown class Doctrine\\DBAL\\ForwardCompatibility\\Result\.$/' - path: lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php - # Forward compatibility for DBAL 3.2 + - '/^Class Doctrine\\DBAL\\Platforms\\(PostgreSQL|SQLServer)Platform not found\.$/' - '/^Call to an undefined method Doctrine\\DBAL\\Cache\\QueryCacheProfile::[gs]etResultCache\(\)\.$/' - message: '/^Call to an undefined static method Doctrine\\DBAL\\Configuration::[gs]etResultCache\(\)\.$/' diff --git a/psalm.xml b/psalm.xml index 24d8872268d..9c32583c97b 100644 --- a/psalm.xml +++ b/psalm.xml @@ -18,9 +18,6 @@ - - - @@ -29,8 +26,6 @@ - - @@ -93,21 +88,10 @@ - - - - - - - - - - - diff --git a/tests/Doctrine/Tests/Mocks/ArrayResultFactory.php b/tests/Doctrine/Tests/Mocks/ArrayResultFactory.php index 591f41bd3d8..a63eff1119f 100644 --- a/tests/Doctrine/Tests/Mocks/ArrayResultFactory.php +++ b/tests/Doctrine/Tests/Mocks/ArrayResultFactory.php @@ -7,17 +7,10 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Result; -use function interface_exists; - final class ArrayResultFactory { public static function createFromArray(array $resultSet): Result { - if (interface_exists(Result::class)) { - // DBAL 2 compatibility. - return new ResultMock($resultSet); - } - return new Result(new DriverResultMock($resultSet), new Connection([], new DriverMock())); } } diff --git a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php index c7e515a117c..943647633c8 100644 --- a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php @@ -24,7 +24,7 @@ class CacheRegionMock implements Region public $returns = []; /** @var string */ - public $name; + public $name = 'mock'; /** * Queue a return value for a specific method invocation diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php index f86f2dababf..7757607df6d 100644 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -31,7 +31,7 @@ class ConnectionMock extends Connection /** @var Result|null */ private $_queryResult; - /** @var DatabasePlatformMock */ + /** @var AbstractPlatform */ private $_platformMock; /** @var int */ @@ -123,14 +123,6 @@ public function fetchOne(string $sql, array $params = [], array $types = []) return $this->_fetchOneResult; } - /** - * {@inheritdoc} - */ - public function fetchColumn($statement, array $params = [], $colunm = 0, array $types = []) - { - throw new BadMethodCallException('Call to deprecated method.'); - } - public function query(?string $sql = null): Result { throw new BadMethodCallException('Call to deprecated method.'); diff --git a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php b/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php index 546fa96a4f3..4372de15cab 100644 --- a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php +++ b/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php @@ -29,11 +29,6 @@ public function supportsIdentityColumns(): bool return $this->supportsIdentityColumns; } - public function prefersSequences(): bool - { - throw new BadMethodCallException('Call to deprecated method.'); - } - public function supportsSequences(): bool { return $this->supportsSequences; diff --git a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php index 383feb9eba7..da72d8ba12d 100644 --- a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php @@ -22,15 +22,12 @@ public function setResultMock(?Result $resultMock): void $this->resultMock = $resultMock; } - /** - * {@inheritdoc} - */ - public function prepare($prepareString): Statement + public function prepare(string $sql): Statement { return new StatementMock(); } - public function query(?string $sql = null): Result + public function query(string $sql): Result { return $this->resultMock ?? new DriverResultMock(); } @@ -38,14 +35,11 @@ public function query(?string $sql = null): Result /** * {@inheritdoc} */ - public function quote($input, $type = ParameterType::STRING) + public function quote($value, $type = ParameterType::STRING) { } - /** - * {@inheritdoc} - */ - public function exec($statement): int + public function exec(string $sql): int { } diff --git a/tests/Doctrine/Tests/Mocks/DriverMock.php b/tests/Doctrine/Tests/Mocks/DriverMock.php index e11cd3c74a3..98944fe651e 100644 --- a/tests/Doctrine/Tests/Mocks/DriverMock.php +++ b/tests/Doctrine/Tests/Mocks/DriverMock.php @@ -43,9 +43,9 @@ public function getDatabasePlatform() return $this->_platformMock; } - public function getSchemaManager(Connection $conn, ?AbstractPlatform $platform = null): AbstractSchemaManager + public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager { - return $this->_schemaManagerMock ?? new SchemaManagerMock($conn, $platform ?? new DatabasePlatformMock()); + return $this->_schemaManagerMock ?? new SchemaManagerMock($conn, $platform); } public function getExceptionConverter(): ExceptionConverter @@ -64,25 +64,4 @@ public function setSchemaManager(AbstractSchemaManager $sm): void { $this->_schemaManagerMock = $sm; } - - /** - * {@inheritdoc} - */ - public function getName() - { - throw new BadMethodCallException('Call to deprecated method.'); - } - - /** - * {@inheritdoc} - */ - public function getDatabase(Connection $conn) - { - return 'not implemented'; - } - - public function convertExceptionCode(Exception $exception): int - { - return 0; - } } diff --git a/tests/Doctrine/Tests/Mocks/DriverResultMock.php b/tests/Doctrine/Tests/Mocks/DriverResultMock.php index 4c283a43f10..29b943df299 100644 --- a/tests/Doctrine/Tests/Mocks/DriverResultMock.php +++ b/tests/Doctrine/Tests/Mocks/DriverResultMock.php @@ -4,11 +4,8 @@ namespace Doctrine\Tests\Mocks; -use ArrayIterator; use BadMethodCallException; use Doctrine\DBAL\Driver\Result; -use PDO; -use Traversable; use function array_values; use function count; @@ -16,7 +13,7 @@ use function next; use function reset; -class DriverResultMock implements Result, ResultStatement +class DriverResultMock implements Result { /** @var list> */ private $resultSet; @@ -95,44 +92,4 @@ public function columnCount(): int public function free(): void { } - - public function closeCursor(): bool - { - $this->free(); - - return true; - } - - public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null): void - { - } - - /** - * {@inheritdoc} - */ - public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) - { - return $this->fetchAssociative(); - } - - /** - * {@inheritdoc} - */ - public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null): array - { - return $this->fetchAllAssociative(); - } - - /** - * {@inheritdoc} - */ - public function fetchColumn($columnIndex = 0) - { - return $this->fetchOne(); - } - - public function getIterator(): Traversable - { - return new ArrayIterator($this->fetchAllAssociative()); - } } diff --git a/tests/Doctrine/Tests/Mocks/ResultMock.php b/tests/Doctrine/Tests/Mocks/ResultMock.php deleted file mode 100644 index b7860180da8..00000000000 --- a/tests/Doctrine/Tests/Mocks/ResultMock.php +++ /dev/null @@ -1,129 +0,0 @@ -> $resultSet The faked SQL result set. - */ - public function __construct(array $resultSet) - { - $this->result = new DriverResultMock($resultSet); - } - - /** - * {@inheritdoc} - */ - public function fetchNumeric() - { - return $this->result->fetchNumeric(); - } - - /** - * {@inheritdoc} - */ - public function fetchAssociative() - { - return $this->result->fetchAssociative(); - } - - /** - * {@inheritdoc} - */ - public function fetchOne() - { - return $this->result->fetchOne(); - } - - /** - * {@inheritdoc} - */ - public function fetchAllAssociative(): array - { - return $this->result->fetchAllAssociative(); - } - - /** - * {@inheritdoc} - */ - public function fetchAllAssociativeIndexed(): array - { - throw new BadMethodCallException('Not implemented'); - } - - /** - * {@inheritdoc} - */ - public function fetchAllKeyValue(): array - { - throw new BadMethodCallException('Not implemented'); - } - - /** - * {@inheritdoc} - */ - public function fetchAllNumeric(): array - { - return $this->result->fetchAllNumeric(); - } - - /** - * {@inheritdoc} - */ - public function fetchFirstColumn(): array - { - return $this->result->fetchFirstColumn(); - } - - public function iterateKeyValue(): Traversable - { - throw new BadMethodCallException('Not implemented'); - } - - public function iterateColumn(): Traversable - { - throw new BadMethodCallException('Not implemented'); - } - - public function columnCount(): int - { - return $this->result->columnCount(); - } - - public function iterateNumeric(): Traversable - { - throw new BadMethodCallException('Not implemented'); - } - - public function iterateAssociative(): Traversable - { - throw new BadMethodCallException('Not implemented'); - } - - public function iterateAssociativeIndexed(): Traversable - { - throw new BadMethodCallException('Not implemented'); - } - - public function rowCount(): int - { - return $this->result->rowCount(); - } - - public function free(): void - { - } -} diff --git a/tests/Doctrine/Tests/Mocks/ResultStatement.php b/tests/Doctrine/Tests/Mocks/ResultStatement.php deleted file mode 100644 index 931262455e6..00000000000 --- a/tests/Doctrine/Tests/Mocks/ResultStatement.php +++ /dev/null @@ -1,20 +0,0 @@ -getName(), 'The entity is broken'); } - /** - * @param object $object - */ - private function getProxy($object): \Doctrine\Common\Proxy\Proxy + private function getProxy(object $object): \Doctrine\Common\Proxy\Proxy { $metadataFactory = $this->_em->getMetadataFactory(); $className = get_class($object); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php index 0c840f42b7d..170059d9b02 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php @@ -17,7 +17,6 @@ use function array_filter; use function current; -use function method_exists; use function sprintf; use function strpos; @@ -76,28 +75,11 @@ public function testUpdateSchemaSql(): void self::assertCount(1, $this->filterCreateTable($sqls, 'gh7875_my_other_entity')); } - /** - * @return array> - */ - public function provideUpdateSchemaSqlWithSchemaAssetFilter(): array + public function testUpdateSchemaSqlWithSchemaAssetFilter(): void { - return [ - ['/^(?!my_enti)/', null], - [ - null, - static function ($assetName): bool { - return $assetName !== 'gh7875_my_entity'; - }, - ], - ]; - } - - /** @dataProvider provideUpdateSchemaSqlWithSchemaAssetFilter */ - public function testUpdateSchemaSqlWithSchemaAssetFilter(?string $filterRegex, ?callable $filterCallback): void - { - if ($filterRegex && ! method_exists(Configuration::class, 'setFilterSchemaAssetsExpression')) { - self::markTestSkipped(sprintf('Test require %s::setFilterSchemaAssetsExpression method', Configuration::class)); - } + $filterCallback = static function ($assetName): bool { + return $assetName !== 'gh7875_my_entity'; + }; $classes = [$this->_em->getClassMetadata(GH7875MyEntity::class)]; @@ -105,11 +87,7 @@ public function testUpdateSchemaSqlWithSchemaAssetFilter(?string $filterRegex, ? $tool->createSchema($classes); $config = $this->_em->getConnection()->getConfiguration(); - if ($filterRegex) { - $config->setFilterSchemaAssetsExpression($filterRegex); - } else { - $config->setSchemaAssetsFilter($filterCallback); - } + $config->setSchemaAssetsFilter($filterCallback); $previousFilter = $config->getSchemaAssetsFilter(); diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index baabb66c7a8..1901d21a596 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -31,13 +31,9 @@ use Doctrine\Tests\OrmTestCase; use Exception; -use function class_exists; use function get_class; use function sprintf; -// DBAL 2 compatibility -class_exists('Doctrine\DBAL\Platforms\MySqlPlatform'); - class SelectSqlGenerationTest extends OrmTestCase { /** @var EntityManagerInterface */ diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 2b89f4d2d5e..f96d7937e2d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -10,11 +10,6 @@ use Doctrine\ORM\Query; use Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker; -use function class_exists; - -// DBAL 2 compatibility -class_exists('Doctrine\DBAL\Platforms\MySqlPlatform'); - final class LimitSubqueryOutputWalkerTest extends PaginationTestCase { public function testLimitSubquery(): void diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index f04068d3a35..c77bbc441c5 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -462,11 +462,9 @@ public function invalidAssociationValuesDataProvider(): array } /** - * @param object $entity - * * @dataProvider entitiesWithValidIdentifiersProvider */ - public function testAddToIdentityMapValidIdentifiers($entity, string $idHash): void + public function testAddToIdentityMapValidIdentifiers(object $entity, string $idHash): void { $this->_unitOfWork->persist($entity); $this->_unitOfWork->addToIdentityMap($entity); @@ -523,12 +521,11 @@ public function testRegisteringAManagedInstanceRequiresANonEmptyIdentifier(): vo } /** - * @param object $entity * @param array $identifier * * @dataProvider entitiesWithInvalidIdentifiersProvider */ - public function testAddToIdentityMapInvalidIdentifiers($entity, array $identifier): void + public function testAddToIdentityMapInvalidIdentifiers(object $entity, array $identifier): void { $this->expectException(ORMInvalidArgumentException::class); diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index d15dd58cc92..cb3fdb80bb0 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -41,7 +41,6 @@ use function getenv; use function implode; use function is_object; -use function method_exists; use function realpath; use function sprintf; use function strpos; @@ -806,9 +805,7 @@ protected function getEntityManager( final protected function createSchemaManager(): AbstractSchemaManager { - return method_exists(Connection::class, 'createSchemaManager') - ? $this->_em->getConnection()->createSchemaManager() - : $this->_em->getConnection()->getSchemaManager(); + return $this->_em->getConnection()->createSchemaManager(); } /** diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index cb72f0f373c..cbebe744037 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -7,13 +7,11 @@ use Doctrine\Common\EventSubscriber; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Schema\AbstractSchemaManager; use UnexpectedValueException; use function explode; use function fwrite; use function get_class; -use function method_exists; use function sprintf; use function strlen; use function strpos; @@ -89,11 +87,11 @@ private static function initializeDatabase(): void $dbname = $testConnParams['dbname'] ?? $testConn->getDatabase(); $testConn->close(); - self::createSchemaManager($privConn)->dropAndCreateDatabase($dbname); + $privConn->createSchemaManager()->dropAndCreateDatabase($dbname); $privConn->close(); } else { - $schema = self::createSchemaManager($testConn)->createSchema(); + $schema = $testConn->createSchemaManager()->createSchema(); $stmts = $schema->toDropSql($testConn->getDatabasePlatform()); foreach ($stmts as $stmt) { @@ -102,13 +100,6 @@ private static function initializeDatabase(): void } } - private static function createSchemaManager(Connection $connection): AbstractSchemaManager - { - return method_exists(Connection::class, 'createSchemaManager') - ? $connection->createSchemaManager() - : $connection->getSchemaManager(); - } - private static function addDbEventSubscribers(Connection $conn): void { if (! isset($GLOBALS['db_event_subscribers'])) { From 4fa65f3853f574980faf758516b00beafba39d9c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 4 Oct 2021 09:53:02 +0200 Subject: [PATCH 008/475] Remove AbstractHydrator::hydrateRow() --- UPGRADE.md | 11 +++++-- .../Internal/Hydration/AbstractHydrator.php | 33 ------------------- psalm.xml | 1 - 3 files changed, 8 insertions(+), 37 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 191c88539a5..8619b8a4dda 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -31,9 +31,14 @@ Using the `UUID` strategy for generating identifiers is not supported anymore. ## BC BREAK: Removed `Query::iterate()` -The deprecated methods `Query::iterate()` and `AbstractHydrator::iterate()` -have been removed along with the `IterableResult` class. Use `toIterable()` -instead. +The deprecated method `Query::iterate()` has been removed along with the +following classes and methods: + +- `AbstractHydrator::iterate()` +- `AbstractHydrator::hydrateRow()` +- `IterableResult` + +Use `toIterable()` instead. # Upgrade to 2.11 diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index cad38af51bb..1dd0665bbfc 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Result; use Doctrine\DBAL\Types\Type; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadata; @@ -183,38 +182,6 @@ public function hydrateAll(Result $stmt, object $resultSetMapping, array $hints return $result; } - /** - * Hydrates a single row returned by the current statement instance during - * row-by-row hydration with {@link toIterable()}. - * - * @deprecated - * - * @return mixed[]|false - */ - public function hydrateRow() - { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9072', - '%s is deprecated.', - __METHOD__ - ); - - $row = $this->statement()->fetchAssociative(); - - if ($row === false) { - $this->cleanup(); - - return false; - } - - $result = []; - - $this->hydrateRowData($row, $result); - - return $result; - } - /** * When executed in a hydrate() loop we have to clear internal state to * decrease memory consumption. diff --git a/psalm.xml b/psalm.xml index 7421cb4244a..7bdae8563f8 100644 --- a/psalm.xml +++ b/psalm.xml @@ -29,7 +29,6 @@ - From e9cd90f52e5622c6c5cfd3477bfe9cab411139db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 5 Oct 2021 15:15:40 +0200 Subject: [PATCH 009/475] Refactor ORMException into an interface (#9085) --- UPGRADE.md | 5 + lib/Doctrine/ORM/Cache/CacheException.php | 3 +- .../Exception/CannotUpdateReadOnlyEntity.php | 2 - .../Exception/InvalidResultCacheDriver.php | 2 + .../Exception/MetadataCacheNotConfigured.php | 2 - .../Cache/Exception/NonCacheableEntity.php | 2 - .../NonCacheableEntityAssociation.php | 2 + lib/Doctrine/ORM/EntityManager.php | 1 + lib/Doctrine/ORM/EntityManagerInterface.php | 1 + lib/Doctrine/ORM/EntityNotFoundException.php | 3 +- .../ORM/Exception/ConfigurationException.php | 2 +- .../ORM/Exception/EntityManagerClosed.php | 2 +- .../ORM/Exception/EntityMissingAssignedId.php | 4 +- .../ORM/Exception/InvalidEntityRepository.php | 2 +- .../ORM/Exception/InvalidHydrationMode.php | 4 +- .../ORM/Exception/MismatchedEventManager.php | 4 +- .../ORM/Exception/MissingIdentifierField.php | 2 +- .../MissingMappingDriverImplementation.php | 2 +- .../MultipleSelectorsFoundException.php | 4 +- .../Exception/NamedNativeQueryNotFound.php | 4 +- .../ORM/Exception/NamedQueryNotFound.php | 2 +- lib/Doctrine/ORM/Exception/NotSupported.php | 4 +- lib/Doctrine/ORM/Exception/ORMException.php | 4 +- .../ProxyClassesAlwaysRegenerating.php | 2 +- .../ORM/Exception/RepositoryException.php | 4 +- .../Exception/UnexpectedAssociationValue.php | 1 + .../ORM/Exception/UnknownEntityNamespace.php | 2 +- .../UnrecognizedIdentifierFields.php | 2 +- .../Internal/Hydration/HydrationException.php | 3 +- .../ORM/Mapping/ClassMetadataFactory.php | 1 + .../Mapping/Exception/CannotGenerateIds.php | 2 +- .../Exception/InvalidCustomGenerator.php | 2 +- .../Exception/UnknownGeneratorType.php | 2 +- lib/Doctrine/ORM/Mapping/MappingException.php | 3 +- lib/Doctrine/ORM/ORMException.php | 312 ------------------ lib/Doctrine/ORM/OptimisticLockException.php | 3 +- ...MatchingAssociationFieldRequiresObject.php | 1 - .../ORM/Persisters/PersisterException.php | 3 +- lib/Doctrine/ORM/PessimisticLockException.php | 3 +- .../ORM/Query/Filter/FilterException.php | 3 +- lib/Doctrine/ORM/Query/QueryException.php | 2 +- .../Exception/InvalidFindByCall.php | 3 +- .../Exception/InvalidMagicMethodCall.php | 3 +- .../Exception/MissingColumnException.php | 2 +- .../ORM/Tools/Exception/NotSupported.php | 3 +- .../ORM/Tools/Export/ExportException.php | 3 +- .../RowNumberOverFunctionNotEnabled.php | 2 +- lib/Doctrine/ORM/Tools/ToolsException.php | 2 +- .../ORM/TransactionRequiredException.php | 2 +- .../ORM/UnexpectedResultException.php | 2 +- lib/Doctrine/ORM/UnitOfWork.php | 1 + .../Doctrine/Tests/ORM/EntityManagerTest.php | 1 - .../ORM/Hydration/AbstractHydratorTest.php | 6 +- .../Tests/ORM/Id/AssignedGeneratorTest.php | 2 +- 54 files changed, 81 insertions(+), 365 deletions(-) delete mode 100644 lib/Doctrine/ORM/ORMException.php diff --git a/UPGRADE.md b/UPGRADE.md index 8619b8a4dda..48ce2bc36ab 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: changes in exception hierarchy + +- `Doctrine\ORM\ORMException` has been removed +- `Doctrine\ORM\Exception\ORMException` is now an interface + ## Variadic methods now use native variadics The following methods were using `func_get_args()` to simulate a variadic argument: - `Doctrine\ORM\Query\Expr#andX()` diff --git a/lib/Doctrine/ORM/Cache/CacheException.php b/lib/Doctrine/ORM/Cache/CacheException.php index 619f2662393..dc6dd459489 100644 --- a/lib/Doctrine/ORM/Cache/CacheException.php +++ b/lib/Doctrine/ORM/Cache/CacheException.php @@ -5,13 +5,14 @@ namespace Doctrine\ORM\Cache; use Doctrine\ORM\Exception\ORMException; +use LogicException; use function sprintf; /** * Exception for cache. */ -class CacheException extends ORMException +class CacheException extends LogicException implements ORMException { /** * @param string $sourceEntity diff --git a/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyEntity.php b/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyEntity.php index bf00b29b8ad..b9455140941 100644 --- a/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyEntity.php +++ b/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyEntity.php @@ -4,8 +4,6 @@ namespace Doctrine\ORM\Cache\Exception; -use LogicException; - use function sprintf; class CannotUpdateReadOnlyEntity extends CacheException diff --git a/lib/Doctrine/ORM/Cache/Exception/InvalidResultCacheDriver.php b/lib/Doctrine/ORM/Cache/Exception/InvalidResultCacheDriver.php index adfdc21601b..d466e000873 100644 --- a/lib/Doctrine/ORM/Cache/Exception/InvalidResultCacheDriver.php +++ b/lib/Doctrine/ORM/Cache/Exception/InvalidResultCacheDriver.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Cache\Exception; +use LogicException; + /** * @deprecated */ diff --git a/lib/Doctrine/ORM/Cache/Exception/MetadataCacheNotConfigured.php b/lib/Doctrine/ORM/Cache/Exception/MetadataCacheNotConfigured.php index c0103959df5..724c2e457b0 100644 --- a/lib/Doctrine/ORM/Cache/Exception/MetadataCacheNotConfigured.php +++ b/lib/Doctrine/ORM/Cache/Exception/MetadataCacheNotConfigured.php @@ -4,8 +4,6 @@ namespace Doctrine\ORM\Cache\Exception; -use LogicException; - final class MetadataCacheNotConfigured extends CacheException { public static function create(): self diff --git a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php b/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php index 491d2ef5d02..29e39473ef1 100644 --- a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php +++ b/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php @@ -4,8 +4,6 @@ namespace Doctrine\ORM\Cache\Exception; -use LogicException; - use function sprintf; class NonCacheableEntity extends CacheException diff --git a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php b/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php index 9315cd60a04..dba1d4de3a5 100644 --- a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php +++ b/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Cache\Exception; +use LogicException; + use function sprintf; class NonCacheableEntityAssociation extends CacheException diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 6a8c06fd8bf..bc39cfad8e2 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Exception\MismatchedEventManager; use Doctrine\ORM\Exception\MissingIdentifierField; use Doctrine\ORM\Exception\MissingMappingDriverImplementation; +use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Exception\UnrecognizedIdentifierFields; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index 71e734adc9c..36861153311 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -8,6 +8,7 @@ use DateTimeInterface; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; +use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Query\Expr; diff --git a/lib/Doctrine/ORM/EntityNotFoundException.php b/lib/Doctrine/ORM/EntityNotFoundException.php index ff59a3be7c0..d3a5b1582d3 100644 --- a/lib/Doctrine/ORM/EntityNotFoundException.php +++ b/lib/Doctrine/ORM/EntityNotFoundException.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM; use Doctrine\ORM\Exception\ORMException; +use RuntimeException; use function implode; use function sprintf; @@ -12,7 +13,7 @@ /** * Exception thrown when a Proxy fails to retrieve an Entity result. */ -class EntityNotFoundException extends ORMException +class EntityNotFoundException extends RuntimeException implements ORMException { /** * Static constructor. diff --git a/lib/Doctrine/ORM/Exception/ConfigurationException.php b/lib/Doctrine/ORM/Exception/ConfigurationException.php index 06437fde514..30200b07afa 100644 --- a/lib/Doctrine/ORM/Exception/ConfigurationException.php +++ b/lib/Doctrine/ORM/Exception/ConfigurationException.php @@ -6,6 +6,6 @@ use Throwable; -interface ConfigurationException extends Throwable +interface ConfigurationException extends ORMException { } diff --git a/lib/Doctrine/ORM/Exception/EntityManagerClosed.php b/lib/Doctrine/ORM/Exception/EntityManagerClosed.php index 478bbe7185b..a76920217f1 100644 --- a/lib/Doctrine/ORM/Exception/EntityManagerClosed.php +++ b/lib/Doctrine/ORM/Exception/EntityManagerClosed.php @@ -6,7 +6,7 @@ use RuntimeException; -final class EntityManagerClosed extends ORMException implements ManagerException +final class EntityManagerClosed extends RuntimeException implements ManagerException { public static function create(): self { diff --git a/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php b/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php index 194c76cabe5..652675b254e 100644 --- a/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php +++ b/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php @@ -4,9 +4,11 @@ namespace Doctrine\ORM\Exception; +use LogicException; + use function get_class; -final class EntityMissingAssignedId extends ORMException +final class EntityMissingAssignedId extends LogicException implements ORMException { /** * @param object $entity diff --git a/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php b/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php index 069cd6b9e36..d1584c77f26 100644 --- a/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php +++ b/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php @@ -7,7 +7,7 @@ use Doctrine\Persistence\ObjectRepository; use LogicException; -final class InvalidEntityRepository extends ORMException implements ConfigurationException +final class InvalidEntityRepository extends LogicException implements ConfigurationException { public static function fromClassName(string $className): self { diff --git a/lib/Doctrine/ORM/Exception/InvalidHydrationMode.php b/lib/Doctrine/ORM/Exception/InvalidHydrationMode.php index 510094e05be..d07d84c8462 100644 --- a/lib/Doctrine/ORM/Exception/InvalidHydrationMode.php +++ b/lib/Doctrine/ORM/Exception/InvalidHydrationMode.php @@ -4,9 +4,11 @@ namespace Doctrine\ORM\Exception; +use LogicException; + use function sprintf; -final class InvalidHydrationMode extends ORMException implements ManagerException +final class InvalidHydrationMode extends LogicException implements ManagerException { public static function fromMode(string $mode): self { diff --git a/lib/Doctrine/ORM/Exception/MismatchedEventManager.php b/lib/Doctrine/ORM/Exception/MismatchedEventManager.php index 2ae41da0a02..17725ad18ee 100644 --- a/lib/Doctrine/ORM/Exception/MismatchedEventManager.php +++ b/lib/Doctrine/ORM/Exception/MismatchedEventManager.php @@ -4,7 +4,9 @@ namespace Doctrine\ORM\Exception; -final class MismatchedEventManager extends ORMException implements ManagerException +use LogicException; + +final class MismatchedEventManager extends LogicException implements ManagerException { public static function create(): self { diff --git a/lib/Doctrine/ORM/Exception/MissingIdentifierField.php b/lib/Doctrine/ORM/Exception/MissingIdentifierField.php index b9f6ebef652..408b244096b 100644 --- a/lib/Doctrine/ORM/Exception/MissingIdentifierField.php +++ b/lib/Doctrine/ORM/Exception/MissingIdentifierField.php @@ -8,7 +8,7 @@ use function sprintf; -final class MissingIdentifierField extends ORMException implements ManagerException +final class MissingIdentifierField extends LogicException implements ManagerException { public static function fromFieldAndClass(string $fieldName, string $className): self { diff --git a/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php b/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php index 5af25286be7..9e3de5d79bd 100644 --- a/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php +++ b/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php @@ -6,7 +6,7 @@ use LogicException; -final class MissingMappingDriverImplementation extends ORMException implements ManagerException +final class MissingMappingDriverImplementation extends LogicException implements ManagerException { public static function create(): self { diff --git a/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php b/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php index 7eed8b7bc66..b9f3f8d6dd4 100644 --- a/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php +++ b/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php @@ -4,10 +4,12 @@ namespace Doctrine\ORM\Exception; +use LogicException; + use function implode; use function sprintf; -final class MultipleSelectorsFoundException extends ORMException +final class MultipleSelectorsFoundException extends LogicException implements ORMException { public const MULTIPLE_SELECTORS_FOUND_EXCEPTION = 'Multiple selectors found: %s. Please select only one.'; diff --git a/lib/Doctrine/ORM/Exception/NamedNativeQueryNotFound.php b/lib/Doctrine/ORM/Exception/NamedNativeQueryNotFound.php index 6c252cc6472..0f482f3f063 100644 --- a/lib/Doctrine/ORM/Exception/NamedNativeQueryNotFound.php +++ b/lib/Doctrine/ORM/Exception/NamedNativeQueryNotFound.php @@ -4,9 +4,11 @@ namespace Doctrine\ORM\Exception; +use LogicException; + use function sprintf; -final class NamedNativeQueryNotFound extends ORMException implements ConfigurationException +final class NamedNativeQueryNotFound extends LogicException implements ConfigurationException { public static function fromName(string $name): self { diff --git a/lib/Doctrine/ORM/Exception/NamedQueryNotFound.php b/lib/Doctrine/ORM/Exception/NamedQueryNotFound.php index af5d9fdc9d9..965baf66c54 100644 --- a/lib/Doctrine/ORM/Exception/NamedQueryNotFound.php +++ b/lib/Doctrine/ORM/Exception/NamedQueryNotFound.php @@ -8,7 +8,7 @@ use function sprintf; -final class NamedQueryNotFound extends ORMException implements ConfigurationException +final class NamedQueryNotFound extends LogicException implements ConfigurationException { public static function fromName(string $name): self { diff --git a/lib/Doctrine/ORM/Exception/NotSupported.php b/lib/Doctrine/ORM/Exception/NotSupported.php index 8669aa17a9d..59d03c1b85e 100644 --- a/lib/Doctrine/ORM/Exception/NotSupported.php +++ b/lib/Doctrine/ORM/Exception/NotSupported.php @@ -4,7 +4,9 @@ namespace Doctrine\ORM\Exception; -final class NotSupported extends ORMException +use LogicException; + +final class NotSupported extends LogicException implements ORMException { public static function create(): self { diff --git a/lib/Doctrine/ORM/Exception/ORMException.php b/lib/Doctrine/ORM/Exception/ORMException.php index 55962b515cd..4cd88eb9040 100644 --- a/lib/Doctrine/ORM/Exception/ORMException.php +++ b/lib/Doctrine/ORM/Exception/ORMException.php @@ -4,11 +4,11 @@ namespace Doctrine\ORM\Exception; -use Doctrine\ORM\ORMException as BaseORMException; +use Throwable; /** * Should become an interface in 3.0 */ -class ORMException extends BaseORMException +interface ORMException extends Throwable { } diff --git a/lib/Doctrine/ORM/Exception/ProxyClassesAlwaysRegenerating.php b/lib/Doctrine/ORM/Exception/ProxyClassesAlwaysRegenerating.php index 1e25a34754d..2829bdab01d 100644 --- a/lib/Doctrine/ORM/Exception/ProxyClassesAlwaysRegenerating.php +++ b/lib/Doctrine/ORM/Exception/ProxyClassesAlwaysRegenerating.php @@ -6,7 +6,7 @@ use LogicException; -final class ProxyClassesAlwaysRegenerating extends ORMException implements ConfigurationException +final class ProxyClassesAlwaysRegenerating extends LogicException implements ConfigurationException { public static function create(): self { diff --git a/lib/Doctrine/ORM/Exception/RepositoryException.php b/lib/Doctrine/ORM/Exception/RepositoryException.php index dc3e3098211..3b2d51bc5ce 100644 --- a/lib/Doctrine/ORM/Exception/RepositoryException.php +++ b/lib/Doctrine/ORM/Exception/RepositoryException.php @@ -4,12 +4,10 @@ namespace Doctrine\ORM\Exception; -use Throwable; - /** * This interface should be implemented by all exceptions in the Repository * namespace. */ -interface RepositoryException extends Throwable +interface RepositoryException extends ORMException { } diff --git a/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php b/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php index 900a74ed662..03d63d34fdb 100644 --- a/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php +++ b/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Exception; use Doctrine\ORM\Cache\Exception\CacheException; +use LogicException; use function sprintf; diff --git a/lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php b/lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php index 972d3c9ad64..efb2b976543 100644 --- a/lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php +++ b/lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php @@ -8,7 +8,7 @@ use function sprintf; -final class UnknownEntityNamespace extends ORMException implements ConfigurationException +final class UnknownEntityNamespace extends LogicException implements ConfigurationException { public static function fromNamespaceAlias(string $entityNamespaceAlias): self { diff --git a/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php b/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php index 828f0899766..3be4bdf3f66 100644 --- a/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php +++ b/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php @@ -9,7 +9,7 @@ use function implode; use function sprintf; -final class UnrecognizedIdentifierFields extends ORMException implements ManagerException +final class UnrecognizedIdentifierFields extends LogicException implements ManagerException { /** * @param string[] $fieldNames diff --git a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php b/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php index a50753e85ec..90b6d3ae954 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php +++ b/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php @@ -5,11 +5,12 @@ namespace Doctrine\ORM\Internal\Hydration; use Doctrine\ORM\Exception\ORMException; +use Exception; use function implode; use function sprintf; -class HydrationException extends ORMException +class HydrationException extends Exception implements ORMException { /** * @return HydrationException diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index f18f7cd7d37..c33516dd244 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -20,6 +20,7 @@ use Doctrine\ORM\Mapping\Exception\CannotGenerateIds; use Doctrine\ORM\Mapping\Exception\InvalidCustomGenerator; use Doctrine\ORM\Mapping\Exception\UnknownGeneratorType; +use Doctrine\ORM\NotImplementedYet; use Doctrine\Persistence\Mapping\AbstractClassMetadataFactory; use Doctrine\Persistence\Mapping\ClassMetadata as ClassMetadataInterface; use Doctrine\Persistence\Mapping\Driver\MappingDriver; diff --git a/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php b/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php index 63a845e12b8..974cf9c0607 100644 --- a/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php +++ b/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php @@ -11,7 +11,7 @@ use function get_class; use function sprintf; -final class CannotGenerateIds extends ORMException +final class CannotGenerateIds extends LogicException implements ORMException { public static function withPlatform(AbstractPlatform $platform): self { diff --git a/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php b/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php index 162ee239bef..e88e469c9d6 100644 --- a/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php +++ b/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php @@ -10,7 +10,7 @@ use function sprintf; use function var_export; -final class InvalidCustomGenerator extends ORMException +final class InvalidCustomGenerator extends LogicException implements ORMException { public static function onClassNotConfigured(): self { diff --git a/lib/Doctrine/ORM/Mapping/Exception/UnknownGeneratorType.php b/lib/Doctrine/ORM/Mapping/Exception/UnknownGeneratorType.php index 87bb205c103..c8970bf77a7 100644 --- a/lib/Doctrine/ORM/Mapping/Exception/UnknownGeneratorType.php +++ b/lib/Doctrine/ORM/Mapping/Exception/UnknownGeneratorType.php @@ -7,7 +7,7 @@ use Doctrine\ORM\Exception\ORMException; use LogicException; -final class UnknownGeneratorType extends ORMException +final class UnknownGeneratorType extends LogicException implements ORMException { public static function create(int $generatorType): self { diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index bec92116851..6f57879a46f 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Mapping; use Doctrine\ORM\Exception\ORMException; +use Exception; use LogicException; use ReflectionException; @@ -18,7 +19,7 @@ /** * A MappingException indicates that something is wrong with the mapping setup. */ -class MappingException extends ORMException +class MappingException extends Exception implements ORMException { /** * @return MappingException diff --git a/lib/Doctrine/ORM/ORMException.php b/lib/Doctrine/ORM/ORMException.php deleted file mode 100644 index a5232b03b96..00000000000 --- a/lib/Doctrine/ORM/ORMException.php +++ /dev/null @@ -1,312 +0,0 @@ -hydrator ->expects(self::once()) ->method('hydrateAllData') - ->willThrowException(new ORMException()); + ->willThrowException($this->createStub(ORMException::class)); $this->expectException(ORMException::class); $this->hydrator->hydrateAll($this->mockResult, $this->mockResultMapping); diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php index 54ec5668116..334cdc6b4da 100644 --- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -4,11 +4,11 @@ namespace Doctrine\Tests\ORM\Id; +use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Id\AssignedGenerator; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\ORMException; use Doctrine\Tests\OrmTestCase; /** From 2adc19342161b23fb79fe543a91e3459e1a15785 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 5 Oct 2021 20:14:12 +0200 Subject: [PATCH 010/475] Bump required PHP version to 7.4 (#9094) --- .github/workflows/continuous-integration.yml | 1 - composer.json | 2 +- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 13 +++++-------- phpcs.xml.dist | 2 +- .../Tests/ORM/Mapping/AbstractMappingDriverTest.php | 5 ----- .../Tests/ORM/Mapping/ClassMetadataTest.php | 10 ---------- 6 files changed, 7 insertions(+), 26 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3725abe087c..0e1f02873ee 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -19,7 +19,6 @@ jobs: strategy: matrix: php-version: - - "7.3" - "7.4" - "8.0" - "8.1" diff --git a/composer.json b/composer.json index bee7e0921bd..b57cf632c4d 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "sort-packages": true }, "require": { - "php": "^7.3 || ^8.0", + "php": "^7.4 || ^8.0", "ext-ctype": "*", "ext-pdo": "*", "composer/package-versions-deprecated": "^1.8", diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 39f66bb2751..a68b773aa78 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -50,8 +50,6 @@ use function trait_exists; use function trim; -use const PHP_VERSION_ID; - /** * A ClassMetadata instance holds all the object-relational mapping metadata * of an entity and its associations. @@ -1428,8 +1426,7 @@ public function getSqlResultSetMappings() */ private function isTypedProperty(string $name): bool { - return PHP_VERSION_ID >= 70400 - && isset($this->reflClass) + return isset($this->reflClass) && $this->reflClass->hasProperty($name) && $this->reflClass->getProperty($name)->hasType(); } @@ -3592,12 +3589,12 @@ public function mapEmbedded(array $mapping) public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) { foreach ($embeddable->fieldMappings as $fieldMapping) { - $fieldMapping['originalClass'] = $fieldMapping['originalClass'] ?? $embeddable->name; - $fieldMapping['declaredField'] = isset($fieldMapping['declaredField']) + $fieldMapping['originalClass'] ??= $embeddable->name; + $fieldMapping['declaredField'] = isset($fieldMapping['declaredField']) ? $property . '.' . $fieldMapping['declaredField'] : $property; - $fieldMapping['originalField'] = $fieldMapping['originalField'] ?? $fieldMapping['fieldName']; - $fieldMapping['fieldName'] = $property . '.' . $fieldMapping['fieldName']; + $fieldMapping['originalField'] ??= $fieldMapping['fieldName']; + $fieldMapping['fieldName'] = $property . '.' . $fieldMapping['fieldName']; if (! empty($this->embeddedClasses[$property]['columnPrefix'])) { $fieldMapping['columnName'] = $this->embeddedClasses[$property]['columnPrefix'] . $fieldMapping['columnName']; diff --git a/phpcs.xml.dist b/phpcs.xml.dist index e94dd80ebf9..61b9dd5fd58 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -9,7 +9,7 @@ - + lib tests diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index e47ea8b325a..dc98e9ac8eb 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -76,7 +76,6 @@ use function strtolower; use const CASE_UPPER; -use const PHP_VERSION_ID; abstract class AbstractMappingDriverTest extends OrmTestCase { @@ -287,10 +286,6 @@ public function testStringFieldMappings(ClassMetadata $class): ClassMetadata public function testFieldTypeFromReflection(): void { - if (PHP_VERSION_ID < 70400) { - self::markTestSkipped('requies PHP 7.4'); - } - $class = $this->createClassMetadata(UserTyped::class); self::assertEquals('integer', $class->getTypeOfField('id')); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index d452d778492..1d456646840 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -40,8 +40,6 @@ use const CASE_UPPER; -use const PHP_VERSION_ID; - require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; class ClassMetadataTest extends OrmTestCase @@ -115,10 +113,6 @@ public function testFieldIsNullable(): void public function testFieldIsNullableByType(): void { - if (PHP_VERSION_ID < 70400) { - self::markTestSkipped('requies PHP 7.4'); - } - $cm = new ClassMetadata(TypedProperties\UserTyped::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -134,10 +128,6 @@ public function testFieldIsNullableByType(): void public function testFieldTypeFromReflection(): void { - if (PHP_VERSION_ID < 70400) { - self::markTestSkipped('requies PHP 7.4'); - } - $cm = new ClassMetadata(TypedProperties\UserTyped::class); $cm->initializeReflection(new RuntimeReflectionService()); From 203cd6ecf256c43b4a9a7ca88a35ed7c87c585e1 Mon Sep 17 00:00:00 2001 From: Mariusz Soltys <14175459+soltmar@users.noreply.github.com> Date: Mon, 11 Oct 2021 16:42:13 +0100 Subject: [PATCH 011/475] Changed EntityRepository count method $criteria parameter to optional (#9104) Currently to get count of all items there is need to provide empty array to count() method as $criteria parameter is required. I believe there shouldn't be a need to provide it if I want to count all Entities without any criteria. --- UPGRADE.md | 5 +++++ lib/Doctrine/ORM/EntityRepository.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 48ce2bc36ab..afc97a944aa 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: EntityRepository::count() signature change + +The argument `$criteria` of `Doctrine\ORM\EntityRepository::count()` is now +optional. Overrides in child classes should be made compatible. + ## BC BREAK: changes in exception hierarchy - `Doctrine\ORM\ORMException` has been removed diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 3b821544168..8bbada8e2b9 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -227,7 +227,7 @@ public function findOneBy(array $criteria, ?array $orderBy = null) * * @todo Add this method to `ObjectRepository` interface in the next major release */ - public function count(array $criteria) + public function count(array $criteria = []) { return $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName)->count($criteria); } From 3d406e52134e536575d7f90a497169384da265a3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 6 Dec 2021 13:27:13 +0100 Subject: [PATCH 012/475] Remove the Version class (#9227) --- UPGRADE.md | 4 ++++ lib/Doctrine/ORM/Version.php | 40 ------------------------------------ 2 files changed, 4 insertions(+), 40 deletions(-) delete mode 100644 lib/Doctrine/ORM/Version.php diff --git a/UPGRADE.md b/UPGRADE.md index 58977e38096..2b2e403c302 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Removed `Doctrine\ORM\Version` + +Use Composer's runtime API if you _really_ need to check the version of the ORM package at runtime. + ## BC BREAK: EntityRepository::count() signature change The argument `$criteria` of `Doctrine\ORM\EntityRepository::count()` is now diff --git a/lib/Doctrine/ORM/Version.php b/lib/Doctrine/ORM/Version.php deleted file mode 100644 index 0b6758a8dc2..00000000000 --- a/lib/Doctrine/ORM/Version.php +++ /dev/null @@ -1,40 +0,0 @@ - Date: Sat, 11 Dec 2021 13:31:40 +0100 Subject: [PATCH 013/475] Remove code generators (#9226) --- UPGRADE.md | 17 + docs/en/reference/tools.rst | 171 +- .../Command/ConvertDoctrine1SchemaCommand.php | 202 -- .../Console/Command/ConvertMappingCommand.php | 187 -- .../Command/GenerateEntitiesCommand.php | 137 -- .../Command/GenerateRepositoriesCommand.php | 109 - .../ORM/Tools/Console/ConsoleRunner.php | 4 - .../ORM/Tools/ConvertDoctrine1Schema.php | 342 --- lib/Doctrine/ORM/Tools/EntityGenerator.php | 1953 ----------------- .../ORM/Tools/EntityRepositoryGenerator.php | 168 -- .../Tools/Export/ClassMetadataExporter.php | 71 - .../Tools/Export/Driver/AbstractExporter.php | 260 --- .../Export/Driver/AnnotationExporter.php | 60 - .../ORM/Tools/Export/Driver/PhpExporter.php | 203 -- .../ORM/Tools/Export/Driver/XmlExporter.php | 498 ----- .../ORM/Tools/Export/Driver/YamlExporter.php | 271 --- .../ORM/Tools/Export/ExportException.php | 52 - phpstan-baseline.neon | 175 -- psalm-baseline.xml | 244 -- psalm.xml | 4 - .../ORM/Functional/Ticket/DDC3711Test.php | 29 - .../ConvertDoctrine1SchemaCommandTest.php | 29 - .../GenerateRepositoriesCommandTest.php | 181 -- .../ORM/Tools/Console/ConsoleRunnerTest.php | 8 - .../ORM/Tools/ConvertDoctrine1SchemaTest.php | 91 - .../Tests/ORM/Tools/EntityGeneratorTest.php | 1327 ----------- .../Tools/EntityRepositoryGeneratorTest.php | 192 -- .../AbstractClassMetadataExporterTest.php | 458 ---- .../AnnotationClassMetadataExporterTest.php | 18 - .../Export/ClassMetadataExporterTest.php | 0 .../Export/PhpClassMetadataExporterTest.php | 18 - .../Export/XmlClassMetadataExporterTest.php | 106 - .../Export/YamlClassMetadataExporterTest.php | 24 - .../Doctrine.Tests.ORM.Tools.Export.User.php | 112 - .../Doctrine.Tests.ORM.Tools.Export.User.php | 155 -- ...ctrine.Tests.ORM.Tools.Export.User.dcm.xml | 94 - ...ctrine.Tests.ORM.Tools.Export.User.dcm.yml | 85 - .../ORM/Tools/doctrine1schema/schema.yml | 28 - 38 files changed, 18 insertions(+), 8065 deletions(-) delete mode 100644 lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php delete mode 100644 lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php delete mode 100644 lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php delete mode 100644 lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php delete mode 100644 lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php delete mode 100644 lib/Doctrine/ORM/Tools/EntityGenerator.php delete mode 100644 lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php delete mode 100644 lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php delete mode 100644 lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php delete mode 100644 lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php delete mode 100644 lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php delete mode 100644 lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php delete mode 100644 lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php delete mode 100644 lib/Doctrine/ORM/Tools/Export/ExportException.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Console/Command/GenerateRepositoriesCommandTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/ClassMetadataExporterTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/PhpClassMetadataExporterTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/annotation/Doctrine.Tests.ORM.Tools.Export.User.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml diff --git a/UPGRADE.md b/UPGRADE.md index 2b2e403c302..9298b62fc2b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,22 @@ # Upgrade to 3.0 +## BC BREAK: Remove code generators and related console commands + +These console commands have been removed: + +* `orm:convert-d1-schema` +* `orm:convert-mapping` +* `orm:generate:entities` +* `orm:generate-repositories` + +These classes have been deprecated: + +* `Doctrine\ORM\Tools\ConvertDoctrine1Schema` +* `Doctrine\ORM\Tools\EntityGenerator` +* `Doctrine\ORM\Tools\EntityRepositoryGenerator` + +The entire `Doctrine\ORM\Tools\Export` namespace has been removed as well. + ## BC BREAK: Removed `Doctrine\ORM\Version` Use Composer's runtime API if you _really_ need to check the version of the ORM package at runtime. diff --git a/docs/en/reference/tools.rst b/docs/en/reference/tools.rst index 2a4ba042e5f..04b682b145c 100644 --- a/docs/en/reference/tools.rst +++ b/docs/en/reference/tools.rst @@ -77,18 +77,10 @@ The following Commands are currently available: cache drivers. - ``orm:clear-cache:result`` Clear result cache of the various cache drivers. -- ``orm:convert-d1-schema`` Converts Doctrine 1.X schema into a - Doctrine 2.X schema. -- ``orm:convert-mapping`` Convert mapping information between - supported formats. - ``orm:ensure-production-settings`` Verify that Doctrine is properly configured for a production environment. -- ``orm:generate-entities`` Generate entity classes and method - stubs from your mapping information. - ``orm:generate-proxies`` Generates proxy classes for entity classes. -- ``orm:generate-repositories`` Generate repository classes from - your mapping information. - ``orm:run-dql`` Executes arbitrary DQL directly from the command line. - ``orm:schema-tool:create`` Processes the schema and either @@ -101,14 +93,10 @@ The following Commands are currently available: update the database schema of EntityManager Storage Connection or generate the SQL output. -For these commands are also available aliases: +The following alias is defined: -- ``orm:convert:d1-schema`` is alias for ``orm:convert-d1-schema``. -- ``orm:convert:mapping`` is alias for ``orm:convert-mapping``. -- ``orm:generate:entities`` is alias for ``orm:generate-entities``. - ``orm:generate:proxies`` is alias for ``orm:generate-proxies``. -- ``orm:generate:repositories`` is alias for ``orm:generate-repositories``. .. note:: @@ -222,163 +210,6 @@ will output the SQL for the ran operation. Before using the orm:schema-tool commands, remember to configure your cli-config.php properly. -Entity Generation ------------------ - -Generate entity classes and method stubs from your mapping information. - -.. code-block:: php - - $ php doctrine orm:generate-entities - $ php doctrine orm:generate-entities --update-entities - $ php doctrine orm:generate-entities --regenerate-entities - -This command is not suited for constant usage. It is a little helper and does -not support all the mapping edge cases very well. You still have to put work -in your entities after using this command. - -It is possible to use the EntityGenerator on code that you have already written. It will -not be lost. The EntityGenerator will only append new code to your -file and will not delete the old code. However this approach may still be prone -to error and we suggest you use code repositories such as GIT or SVN to make -backups of your code. - -It makes sense to generate the entity code if you are using entities as Data -Access Objects only and don't put much additional logic on them. If you are -however putting much more logic on the entities you should refrain from using -the entity-generator and code your entities manually. - -.. note:: - - Even if you specified Inheritance options in your - XML or YAML Mapping files the generator cannot generate the base and - child classes for you correctly, because it doesn't know which - class is supposed to extend which. You have to adjust the entity - code manually for inheritance to work! - - -Convert Mapping Information ---------------------------- - -Convert mapping information between supported formats. - -This is an **execute one-time** command. It should not be necessary for -you to call this method multiple times, especially when using the ``--from-database`` -flag. - -Converting an existing database schema into mapping files only solves about 70-80% -of the necessary mapping information. Additionally the detection from an existing -database cannot detect inverse associations, inheritance types, -entities with foreign keys as primary keys and many of the -semantical operations on associations such as cascade. - -.. note:: - - There is no need to convert YAML or XML mapping files to annotations - every time you make changes. All mapping drivers are first class citizens - in Doctrine 2 and can be used as runtime mapping for the ORM. See the - docs on XML and YAML Mapping for an example how to register this metadata - drivers as primary mapping source. - -To convert some mapping information between the various supported -formats you can use the ``ClassMetadataExporter`` to get exporter -instances for the different formats: - -.. code-block:: php - - getExporter('yml', '/path/to/export/yml'); - -Now you can export some ``ClassMetadata`` instances: - -.. code-block:: php - - getClassMetadata('Entities\User'), - $em->getClassMetadata('Entities\Profile') - ); - $exporter->setMetadata($classes); - $exporter->export(); - -This functionality is also available from the command line to -convert your loaded mapping information to another format. The -``orm:convert-mapping`` command accepts two arguments, the type to -convert to and the path to generate it: - -.. code-block:: php - - $ php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml - -Reverse Engineering -------------------- - -You can use the ``DatabaseDriver`` to reverse engineer a database -to an array of ``ClassMetadataInfo`` instances and generate YAML, -XML, etc. from them. - -.. note:: - - Reverse Engineering is a **one-time** process that can get you started with a project. - Converting an existing database schema into mapping files only detects about 70-80% - of the necessary mapping information. Additionally the detection from an existing - database cannot detect inverse associations, inheritance types, - entities with foreign keys as primary keys and many of the - semantical operations on associations such as cascade. - -First you need to retrieve the metadata instances with the -``DatabaseDriver``: - -.. code-block:: php - - getConfiguration()->setMetadataDriverImpl( - new \Doctrine\ORM\Mapping\Driver\DatabaseDriver( - $em->getConnection()->createSchemaManager() - ) - ); - - $cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory(); - $cmf->setEntityManager($em); - $metadata = $cmf->getAllMetadata(); - -Now you can get an exporter instance and export the loaded metadata -to yml: - -.. code-block:: php - - getExporter('yml', '/path/to/export/yml'); - $exporter->setMetadata($metadata); - $exporter->export(); - -You can also reverse engineer a database using the -``orm:convert-mapping`` command: - -.. code-block:: php - - $ php doctrine orm:convert-mapping --from-database yml /path/to/mapping-path-converted-to-yml - -.. note:: - - Reverse Engineering is not always working perfectly - depending on special cases. It will only detect Many-To-One - relations (even if they are One-To-One) and will try to create - entities from Many-To-Many tables. It also has problems with naming - of foreign keys that have multiple column names. Any Reverse - Engineered Database-Schema needs considerable manual work to become - a useful domain model. - - Runtime vs Development Mapping Validation ----------------------------------------- diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php deleted file mode 100644 index 67db44db785..00000000000 --- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php +++ /dev/null @@ -1,202 +0,0 @@ -entityGenerator === null) { - $this->entityGenerator = new EntityGenerator(); - } - - return $this->entityGenerator; - } - - /** - * @return void - */ - public function setEntityGenerator(EntityGenerator $entityGenerator) - { - $this->entityGenerator = $entityGenerator; - } - - /** - * @return ClassMetadataExporter - */ - public function getMetadataExporter() - { - if ($this->metadataExporter === null) { - $this->metadataExporter = new ClassMetadataExporter(); - } - - return $this->metadataExporter; - } - - /** - * @return void - */ - public function setMetadataExporter(ClassMetadataExporter $metadataExporter) - { - $this->metadataExporter = $metadataExporter; - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->setName('orm:convert-d1-schema') - ->setAliases(['orm:convert:d1-schema']) - ->setDescription('Converts Doctrine 1.x schema into a Doctrine 2.x schema') - ->addArgument('from-path', InputArgument::REQUIRED, 'The path of Doctrine 1.X schema information.') - ->addArgument('to-type', InputArgument::REQUIRED, 'The destination Doctrine 2.X mapping type.') - ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your Doctrine 2.X mapping information.') - ->addOption('from', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Optional paths of Doctrine 1.X schema information.', []) - ->addOption('extend', null, InputOption::VALUE_OPTIONAL, 'Defines a base class to be extended by generated entity classes.') - ->addOption('num-spaces', null, InputOption::VALUE_OPTIONAL, 'Defines the number of indentation spaces', 4) - ->setHelp('Converts Doctrine 1.x schema into a Doctrine 2.x schema.'); - } - - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $ui = new SymfonyStyle($input, $output); - $ui->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.'); - - // Process source directories - $fromPaths = array_merge([$input->getArgument('from-path')], $input->getOption('from')); - - // Process destination directory - $destPath = realpath($input->getArgument('dest-path')); - - $toType = $input->getArgument('to-type'); - $extend = $input->getOption('extend'); - $numSpaces = (int) $input->getOption('num-spaces'); - - $this->convertDoctrine1Schema($fromPaths, $destPath, $toType, $numSpaces, $extend, $output); - - return 0; - } - - /** - * @param mixed[] $fromPaths - * @param string $destPath - * @param string $toType - * @param int $numSpaces - * @param string|null $extend - * - * @return void - * - * @throws InvalidArgumentException - */ - public function convertDoctrine1Schema(array $fromPaths, $destPath, $toType, $numSpaces, $extend, OutputInterface $output) - { - foreach ($fromPaths as &$dirName) { - $dirName = realpath($dirName); - - if (! file_exists($dirName)) { - throw new InvalidArgumentException( - sprintf("Doctrine 1.X schema directory '%s' does not exist.", $dirName) - ); - } - - if (! is_readable($dirName)) { - throw new InvalidArgumentException( - sprintf("Doctrine 1.X schema directory '%s' does not have read permissions.", $dirName) - ); - } - } - - if (! file_exists($destPath)) { - throw new InvalidArgumentException( - sprintf("Doctrine 2.X mapping destination directory '%s' does not exist.", $destPath) - ); - } - - if (! is_writable($destPath)) { - throw new InvalidArgumentException( - sprintf("Doctrine 2.X mapping destination directory '%s' does not have write permissions.", $destPath) - ); - } - - $cme = $this->getMetadataExporter(); - $exporter = $cme->getExporter($toType, $destPath); - - if ($exporter instanceof AnnotationExporter) { - $entityGenerator = $this->getEntityGenerator(); - $exporter->setEntityGenerator($entityGenerator); - - $entityGenerator->setNumSpaces($numSpaces); - - if ($extend !== null) { - $entityGenerator->setClassToExtend($extend); - } - } - - $converter = new ConvertDoctrine1Schema($fromPaths); - $metadata = $converter->getMetadata(); - - if ($metadata) { - $output->writeln(''); - - foreach ($metadata as $class) { - $output->writeln(sprintf('Processing entity "%s"', $class->name)); - } - - $exporter->setMetadata($metadata); - $exporter->export(); - - $output->writeln(PHP_EOL . sprintf( - 'Converting Doctrine 1.X schema to "%s" mapping type in "%s"', - $toType, - $destPath - )); - } else { - $output->writeln('No Metadata Classes to process.'); - } - } -} diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php deleted file mode 100644 index 7347c79a2bc..00000000000 --- a/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php +++ /dev/null @@ -1,187 +0,0 @@ -setName('orm:convert-mapping') - ->setAliases(['orm:convert:mapping']) - ->setDescription('Convert mapping information between supported formats') - ->addArgument('to-type', InputArgument::REQUIRED, 'The mapping type to be converted.') - ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your entities classes.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') - ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.') - ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force to overwrite existing mapping files.') - ->addOption('from-database', null, null, 'Whether or not to convert mapping information from existing database.') - ->addOption('extend', null, InputOption::VALUE_OPTIONAL, 'Defines a base class to be extended by generated entity classes.') - ->addOption('num-spaces', null, InputOption::VALUE_OPTIONAL, 'Defines the number of indentation spaces', 4) - ->addOption('namespace', null, InputOption::VALUE_OPTIONAL, 'Defines a namespace for the generated entity classes, if converted from database.') - ->setHelp(<<one-time command. It should not be necessary for -you to call this method multiple times, especially when using the --from-database -flag. - -Converting an existing database schema into mapping files only solves about 70-80% -of the necessary mapping information. Additionally the detection from an existing -database cannot detect inverse associations, inheritance types, -entities with foreign keys as primary keys and many of the -semantical operations on associations such as cascade. - -Hint: There is no need to convert YAML or XML mapping files to annotations -every time you make changes. All mapping drivers are first class citizens -in Doctrine 2 and can be used as runtime mapping for the ORM. - -Hint: If you have a database with tables that should not be managed -by the ORM, you can use a DBAL functionality to filter the tables and sequences down -on a global level: - - \$config->setFilterSchemaAssetsExpression(\$regexp); -EOT - ); - } - - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $ui = new SymfonyStyle($input, $output); - $ui->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.'); - - $em = $this->getEntityManager($input); - - if ($input->getOption('from-database') === true) { - $databaseDriver = new DatabaseDriver($em->getConnection()->createSchemaManager()); - - $em->getConfiguration()->setMetadataDriverImpl( - $databaseDriver - ); - - $namespace = $input->getOption('namespace'); - if ($namespace !== null) { - $databaseDriver->setNamespace($namespace); - } - } - - $cmf = new DisconnectedClassMetadataFactory(); - $cmf->setEntityManager($em); - $metadata = $cmf->getAllMetadata(); - $metadata = MetadataFilter::filter($metadata, $input->getOption('filter')); - - // Process destination directory - $destPath = $input->getArgument('dest-path'); - if (! is_dir($destPath)) { - mkdir($destPath, 0775, true); - } - - $destPath = realpath($destPath); - - if (! file_exists($destPath)) { - throw new InvalidArgumentException( - sprintf("Mapping destination directory '%s' does not exist.", $input->getArgument('dest-path')) - ); - } - - if (! is_writable($destPath)) { - throw new InvalidArgumentException( - sprintf("Mapping destination directory '%s' does not have write permissions.", $destPath) - ); - } - - $toType = strtolower($input->getArgument('to-type')); - - $exporter = $this->getExporter($toType, $destPath); - $exporter->setOverwriteExistingFiles($input->getOption('force')); - - if ($exporter instanceof AnnotationExporter) { - $entityGenerator = new EntityGenerator(); - $exporter->setEntityGenerator($entityGenerator); - - $entityGenerator->setNumSpaces((int) $input->getOption('num-spaces')); - - $extend = $input->getOption('extend'); - if ($extend !== null) { - $entityGenerator->setClassToExtend($extend); - } - } - - if (empty($metadata)) { - $ui->success('No Metadata Classes to process.'); - - return 0; - } - - foreach ($metadata as $class) { - $ui->text(sprintf('Processing entity "%s"', $class->name)); - } - - $exporter->setMetadata($metadata); - $exporter->export(); - - $ui->newLine(); - $ui->text( - sprintf( - 'Exporting "%s" mapping information to "%s"', - $toType, - $destPath - ) - ); - - return 0; - } - - /** - * @param string $toType - * @param string $destPath - * - * @return AbstractExporter - */ - protected function getExporter($toType, $destPath) - { - $cme = new ClassMetadataExporter(); - - return $cme->getExporter($toType, $destPath); - } -} diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php deleted file mode 100644 index 70021ca4c74..00000000000 --- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php +++ /dev/null @@ -1,137 +0,0 @@ -setName('orm:generate-entities') - ->setAliases(['orm:generate:entities']) - ->setDescription('Generate entity classes and method stubs from your mapping information') - ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your entity classes.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') - ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.') - ->addOption('generate-annotations', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should generate annotation metadata on entities.', false) - ->addOption('generate-methods', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should generate stub methods on entities.', true) - ->addOption('regenerate-entities', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should regenerate entity if it exists.', false) - ->addOption('update-entities', null, InputOption::VALUE_OPTIONAL, 'Flag to define if generator should only update entity if it exists.', true) - ->addOption('extend', null, InputOption::VALUE_REQUIRED, 'Defines a base class to be extended by generated entity classes.') - ->addOption('num-spaces', null, InputOption::VALUE_REQUIRED, 'Defines the number of indentation spaces', 4) - ->addOption('no-backup', null, InputOption::VALUE_NONE, 'Flag to define if generator should avoid backuping existing entity file if it exists.') - ->setHelp(<<--update-entities or --regenerate-entities flags your existing -code gets overwritten. The EntityGenerator will only append new code to your -file and will not delete the old code. However this approach may still be prone -to error and we suggest you use code repositories such as GIT or SVN to make -backups of your code. - -It makes sense to generate the entity code if you are using entities as Data -Access Objects only and don't put much additional logic on them. If you are -however putting much more logic on the entities you should refrain from using -the entity-generator and code your entities manually. - -Important: Even if you specified Inheritance options in your -XML or YAML Mapping files the generator cannot generate the base and -child classes for you correctly, because it doesn't know which -class is supposed to extend which. You have to adjust the entity -code manually for inheritance to work! -EOT - ); - } - - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $ui = new SymfonyStyle($input, $output); - $ui->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.'); - - $em = $this->getEntityManager($input); - - $cmf = new DisconnectedClassMetadataFactory(); - $cmf->setEntityManager($em); - $metadatas = $cmf->getAllMetadata(); - $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter')); - - // Process destination directory - $destPath = realpath($input->getArgument('dest-path')); - - if (! file_exists($destPath)) { - throw new InvalidArgumentException( - sprintf("Entities destination directory '%s' does not exist.", $input->getArgument('dest-path')) - ); - } - - if (! is_writable($destPath)) { - throw new InvalidArgumentException( - sprintf("Entities destination directory '%s' does not have write permissions.", $destPath) - ); - } - - if (empty($metadatas)) { - $ui->success('No Metadata Classes to process.'); - - return 0; - } - - $entityGenerator = new EntityGenerator(); - - $entityGenerator->setGenerateAnnotations($input->getOption('generate-annotations')); - $entityGenerator->setGenerateStubMethods($input->getOption('generate-methods')); - $entityGenerator->setRegenerateEntityIfExists($input->getOption('regenerate-entities')); - $entityGenerator->setUpdateEntityIfExists($input->getOption('update-entities')); - $entityGenerator->setNumSpaces((int) $input->getOption('num-spaces')); - $entityGenerator->setBackupExisting(! $input->getOption('no-backup')); - - $extend = $input->getOption('extend'); - if ($extend !== null) { - $entityGenerator->setClassToExtend($extend); - } - - foreach ($metadatas as $metadata) { - $ui->text(sprintf('Processing entity "%s"', $metadata->name)); - } - - // Generating Entities - $entityGenerator->generate($metadatas, $destPath); - - // Outputting information message - $ui->newLine(); - $ui->success(sprintf('Entity classes generated to "%s"', $destPath)); - - return 0; - } -} diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php deleted file mode 100644 index 84cc3fe719b..00000000000 --- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php +++ /dev/null @@ -1,109 +0,0 @@ -setName('orm:generate-repositories') - ->setAliases(['orm:generate:repositories']) - ->setDescription('Generate repository classes from your mapping information') - ->addArgument('dest-path', InputArgument::REQUIRED, 'The path to generate your repository classes.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') - ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.') - ->setHelp('Generate repository classes from your mapping information.'); - } - - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $ui = new SymfonyStyle($input, $output); - $ui->warning('Command ' . $this->getName() . ' is deprecated and will be removed in Doctrine ORM 3.0.'); - - $em = $this->getEntityManager($input); - - $metadatas = $em->getMetadataFactory()->getAllMetadata(); - $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter')); - - $repositoryName = $em->getConfiguration()->getDefaultRepositoryClassName(); - - // Process destination directory - $destPath = realpath($input->getArgument('dest-path')); - - if (! file_exists($destPath)) { - throw new InvalidArgumentException( - sprintf("Entities destination directory '%s' does not exist.", $input->getArgument('dest-path')) - ); - } - - if (! is_writable($destPath)) { - throw new InvalidArgumentException( - sprintf("Entities destination directory '%s' does not have write permissions.", $destPath) - ); - } - - if (empty($metadatas)) { - $ui->success('No Metadata Classes to process.'); - - return 0; - } - - $numRepositories = 0; - $generator = new EntityRepositoryGenerator(); - - $generator->setDefaultRepositoryName($repositoryName); - - foreach ($metadatas as $metadata) { - if ($metadata->customRepositoryClassName) { - $ui->text(sprintf('Processing repository "%s"', $metadata->customRepositoryClassName)); - - $generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $destPath); - - ++$numRepositories; - } - } - - if ($numRepositories === 0) { - $ui->text('No Repository classes were found to be processed.'); - - return 0; - } - - // Outputting information message - $ui->newLine(); - $ui->text(sprintf('Repository classes generated to "%s"', $destPath)); - - return 0; - } -} diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index 504e86edc1a..01e54c9e285 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -93,11 +93,7 @@ public static function addCommands(Application $cli, ?EntityManagerProvider $ent new Command\SchemaTool\UpdateCommand($entityManagerProvider), new Command\SchemaTool\DropCommand($entityManagerProvider), new Command\EnsureProductionSettingsCommand($entityManagerProvider), - new Command\ConvertDoctrine1SchemaCommand(), - new Command\GenerateRepositoriesCommand($entityManagerProvider), - new Command\GenerateEntitiesCommand($entityManagerProvider), new Command\GenerateProxiesCommand($entityManagerProvider), - new Command\ConvertMappingCommand($entityManagerProvider), new Command\RunDqlCommand($entityManagerProvider), new Command\ValidateSchemaCommand($entityManagerProvider), new Command\InfoCommand($entityManagerProvider), diff --git a/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php b/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php deleted file mode 100644 index f45d5b6cbc0..00000000000 --- a/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php +++ /dev/null @@ -1,342 +0,0 @@ - */ - private $legacyTypeMap = [ - // TODO: This list may need to be updated - 'clob' => 'text', - 'timestamp' => 'datetime', - 'enum' => 'string', - ]; - - /** - * Constructor passes the directory or array of directories - * to convert the Doctrine 1 schema files from. - * - * @param string[]|string $from - * @psalm-param list|string $from - */ - public function __construct($from) - { - $this->from = (array) $from; - - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8458', - '%s is deprecated with no replacement', - self::class - ); - } - - /** - * Gets an array of ClassMetadataInfo instances from the passed - * Doctrine 1 schema. - * - * @return ClassMetadataInfo[] An array of ClassMetadataInfo instances - * @psalm-return list - */ - public function getMetadata() - { - $schema = []; - foreach ($this->from as $path) { - if (is_dir($path)) { - $files = glob($path . '/*.yml'); - foreach ($files as $file) { - $schema = array_merge($schema, (array) Yaml::parse(file_get_contents($file))); - } - } else { - $schema = array_merge($schema, (array) Yaml::parse(file_get_contents($path))); - } - } - - $metadatas = []; - foreach ($schema as $className => $mappingInformation) { - $metadatas[] = $this->convertToClassMetadataInfo($className, $mappingInformation); - } - - return $metadatas; - } - - /** - * @param mixed[] $mappingInformation - * @psalm-param class-string $className - */ - private function convertToClassMetadataInfo( - string $className, - array $mappingInformation - ): ClassMetadataInfo { - $metadata = new ClassMetadataInfo($className); - - $this->convertTableName($className, $mappingInformation, $metadata); - $this->convertColumns($className, $mappingInformation, $metadata); - $this->convertIndexes($className, $mappingInformation, $metadata); - $this->convertRelations($className, $mappingInformation, $metadata); - - return $metadata; - } - - /** - * @param mixed[] $model - */ - private function convertTableName(string $className, array $model, ClassMetadataInfo $metadata): void - { - if (isset($model['tableName']) && $model['tableName']) { - $e = explode('.', $model['tableName']); - - if (count($e) > 1) { - $metadata->table['schema'] = $e[0]; - $metadata->table['name'] = $e[1]; - } else { - $metadata->table['name'] = $e[0]; - } - } - } - - /** - * @param mixed[] $model - */ - private function convertColumns( - string $className, - array $model, - ClassMetadataInfo $metadata - ): void { - $id = false; - - if (isset($model['columns']) && $model['columns']) { - foreach ($model['columns'] as $name => $column) { - $fieldMapping = $this->convertColumn($className, $name, $column, $metadata); - - if (isset($fieldMapping['id']) && $fieldMapping['id']) { - $id = true; - } - } - } - - if (! $id) { - $fieldMapping = [ - 'fieldName' => 'id', - 'columnName' => 'id', - 'type' => 'integer', - 'id' => true, - ]; - $metadata->mapField($fieldMapping); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - } - } - - /** - * @param string|mixed[] $column - * - * @return mixed[] - * - * @throws ToolsException - */ - private function convertColumn( - string $className, - string $name, - $column, - ClassMetadataInfo $metadata - ): array { - if (is_string($column)) { - $string = $column; - $column = []; - $column['type'] = $string; - } - - if (! isset($column['name'])) { - $column['name'] = $name; - } - - // check if a column alias was used (column_name as field_name) - if (preg_match('/(\w+)\sas\s(\w+)/i', $column['name'], $matches)) { - $name = $matches[1]; - $column['name'] = $name; - $column['alias'] = $matches[2]; - } - - if (preg_match('/([a-zA-Z]+)\(([0-9]+)\)/', $column['type'], $matches)) { - $column['type'] = $matches[1]; - $column['length'] = $matches[2]; - } - - $column['type'] = strtolower($column['type']); - // check if legacy column type (1.x) needs to be mapped to a 2.0 one - if (isset($this->legacyTypeMap[$column['type']])) { - $column['type'] = $this->legacyTypeMap[$column['type']]; - } - - if (! Type::hasType($column['type'])) { - throw ToolsException::couldNotMapDoctrine1Type($column['type']); - } - - $fieldMapping = [ - 'nullable' => ! ($column['notnull'] ?? true), // Doctrine 1 columns are nullable by default - ]; - - if (isset($column['primary'])) { - $fieldMapping['id'] = true; - } - - $fieldMapping['fieldName'] = $column['alias'] ?? $name; - $fieldMapping['columnName'] = $column['name']; - $fieldMapping['type'] = $column['type']; - - if (isset($column['length'])) { - $fieldMapping['length'] = $column['length']; - } - - $allowed = ['precision', 'scale', 'unique', 'options', 'version']; - - foreach ($column as $key => $value) { - if (in_array($key, $allowed, true)) { - $fieldMapping[$key] = $value; - } - } - - $metadata->mapField($fieldMapping); - - if (isset($column['autoincrement'])) { - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - } elseif (isset($column['sequence'])) { - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); - - $definition = [ - 'sequenceName' => (string) (is_array($column['sequence']) ? $column['sequence']['name'] : $column['sequence']), - ]; - - if (isset($column['sequence']['size'])) { - $definition['allocationSize'] = (int) $column['sequence']['size']; - } - - if (isset($column['sequence']['value'])) { - $definition['initialValue'] = (int) $column['sequence']['value']; - } - - $metadata->setSequenceGeneratorDefinition($definition); - } - - return $fieldMapping; - } - - /** - * @param mixed[] $model - */ - private function convertIndexes( - string $className, - array $model, - ClassMetadataInfo $metadata - ): void { - if (empty($model['indexes'])) { - return; - } - - foreach ($model['indexes'] as $name => $index) { - $type = isset($index['type']) && $index['type'] === 'unique' - ? 'uniqueConstraints' : 'indexes'; - - $metadata->table[$type][$name] = [ - 'columns' => $index['fields'], - ]; - } - } - - /** - * @param mixed[] $model - */ - private function convertRelations( - string $className, - array $model, - ClassMetadataInfo $metadata - ): void { - if (empty($model['relations'])) { - return; - } - - $inflector = InflectorFactory::create()->build(); - - foreach ($model['relations'] as $name => $relation) { - if (! isset($relation['alias'])) { - $relation['alias'] = $name; - } - - if (! isset($relation['class'])) { - $relation['class'] = $name; - } - - if (! isset($relation['local'])) { - $relation['local'] = $inflector->tableize($relation['class']); - } - - if (! isset($relation['foreign'])) { - $relation['foreign'] = 'id'; - } - - if (! isset($relation['foreignAlias'])) { - $relation['foreignAlias'] = $className; - } - - if (isset($relation['refClass'])) { - $type = 'many'; - $foreignType = 'many'; - $joinColumns = []; - } else { - $type = $relation['type'] ?? 'one'; - $foreignType = $relation['foreignType'] ?? 'many'; - $joinColumns = [ - [ - 'name' => $relation['local'], - 'referencedColumnName' => $relation['foreign'], - 'onDelete' => $relation['onDelete'] ?? null, - ], - ]; - } - - if ($type === 'one' && $foreignType === 'one') { - $method = 'mapOneToOne'; - } elseif ($type === 'many' && $foreignType === 'many') { - $method = 'mapManyToMany'; - } else { - $method = 'mapOneToMany'; - } - - $associationMapping = []; - $associationMapping['fieldName'] = $relation['alias']; - $associationMapping['targetEntity'] = $relation['class']; - $associationMapping['mappedBy'] = $relation['foreignAlias']; - $associationMapping['joinColumns'] = $joinColumns; - - $metadata->$method($associationMapping); - } - } -} diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php deleted file mode 100644 index 918bc9d3287..00000000000 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ /dev/null @@ -1,1953 +0,0 @@ -getClassMetadataFactory()->getAllMetadata(); - * - * $generator = new \Doctrine\ORM\Tools\EntityGenerator(); - * $generator->setGenerateAnnotations(true); - * $generator->setGenerateStubMethods(true); - * $generator->setRegenerateEntityIfExists(false); - * $generator->setUpdateEntityIfExists(true); - * $generator->generate($classes, '/path/to/generate/entities'); - * - * @deprecated 2.7 This class is being removed from the ORM and won't have any replacement - * - * @link www.doctrine-project.org - */ -class EntityGenerator -{ - /** - * Specifies class fields should be protected. - */ - public const FIELD_VISIBLE_PROTECTED = 'protected'; - - /** - * Specifies class fields should be private. - */ - public const FIELD_VISIBLE_PRIVATE = 'private'; - - /** @var bool */ - protected $backupExisting = true; - - /** - * The extension to use for written php files. - * - * @var string - */ - protected $extension = '.php'; - - /** - * Whether or not the current ClassMetadataInfo instance is new or old. - * - * @var bool - */ - protected $isNew = true; - - /** @var mixed[] */ - protected $staticReflection = []; - - /** - * Number of spaces to use for indention in generated code. - * - * @var int - */ - protected $numSpaces = 4; - - /** - * The actual spaces to use for indention. - * - * @var string - */ - protected $spaces = ' '; - - /** - * The class all generated entities should extend. - * - * @var string - */ - protected $classToExtend; - - /** - * Whether or not to generation annotations. - * - * @var bool - */ - protected $generateAnnotations = false; - - /** @var string */ - protected $annotationsPrefix = ''; - - /** - * Whether or not to generate sub methods. - * - * @var bool - */ - protected $generateEntityStubMethods = false; - - /** - * Whether or not to update the entity class if it exists already. - * - * @var bool - */ - protected $updateEntityIfExists = false; - - /** - * Whether or not to re-generate entity class if it exists already. - * - * @var bool - */ - protected $regenerateEntityIfExists = false; - - /** - * Visibility of the field - * - * @var string - */ - protected $fieldVisibility = 'private'; - - /** - * Whether or not to make generated embeddables immutable. - * - * @var bool - */ - protected $embeddablesImmutable = false; - - /** - * Hash-map for handle types. - * - * @psalm-var array - */ - protected $typeAlias = [ - Types::DATETIMETZ_MUTABLE => '\DateTime', - Types::DATETIME_MUTABLE => '\DateTime', - Types::DATE_MUTABLE => '\DateTime', - Types::TIME_MUTABLE => '\DateTime', - Types::OBJECT => '\stdClass', - Types::INTEGER => 'int', - Types::BIGINT => 'int', - Types::SMALLINT => 'int', - Types::TEXT => 'string', - Types::BLOB => 'string', - Types::DECIMAL => 'string', - Types::GUID => 'string', - 'json_array' => 'array', - Types::JSON => 'array', - Types::SIMPLE_ARRAY => 'array', - Types::BOOLEAN => 'bool', - ]; - - /** - * Hash-map to handle generator types string. - * - * @psalm-var array - */ - protected static $generatorStrategyMap = [ - ClassMetadataInfo::GENERATOR_TYPE_AUTO => 'AUTO', - ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE => 'SEQUENCE', - ClassMetadataInfo::GENERATOR_TYPE_IDENTITY => 'IDENTITY', - ClassMetadataInfo::GENERATOR_TYPE_NONE => 'NONE', - ClassMetadataInfo::GENERATOR_TYPE_CUSTOM => 'CUSTOM', - ]; - - /** - * Hash-map to handle the change tracking policy string. - * - * @psalm-var array - */ - protected static $changeTrackingPolicyMap = [ - ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT => 'DEFERRED_IMPLICIT', - ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT => 'DEFERRED_EXPLICIT', - ClassMetadataInfo::CHANGETRACKING_NOTIFY => 'NOTIFY', - ]; - - /** - * Hash-map to handle the inheritance type string. - * - * @psalm-var array - */ - protected static $inheritanceTypeMap = [ - ClassMetadataInfo::INHERITANCE_TYPE_NONE => 'NONE', - ClassMetadataInfo::INHERITANCE_TYPE_JOINED => 'JOINED', - ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE => 'SINGLE_TABLE', - ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS => 'TABLE_PER_CLASS', - ]; - - /** @var string */ - protected static $classTemplate = - ' - - - -{ - -} -'; - - /** @var string */ - protected static $getMethodTemplate = - '/** - * - * - * @return - */ -public function () -{ -return $this->; -}'; - - /** @var string */ - protected static $setMethodTemplate = - '/** - * - * - * @param $ - * - * @return - */ -public function ($) -{ -$this-> = $; - -return $this; -}'; - - /** @var string */ - protected static $addMethodTemplate = - '/** - * - * - * @param $ - * - * @return - */ -public function ($) -{ -$this->[] = $; - -return $this; -}'; - - /** @var string */ - protected static $removeMethodTemplate = - '/** - * - * - * @param $ - * - * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. - */ -public function ($) -{ -return $this->->removeElement($); -}'; - - /** @var string */ - protected static $lifecycleCallbackMethodTemplate = - '/** - * @ - */ -public function () -{ -// Add your code here -}'; - - /** @var string */ - protected static $constructorMethodTemplate = - '/** - * Constructor - */ -public function __construct() -{ - -} -'; - - /** @var string */ - protected static $embeddableConstructorMethodTemplate = - '/** - * Constructor - * - * - */ -public function __construct() -{ - -} -'; - - /** @var Inflector */ - protected $inflector; - - public function __construct() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8458', - '%s is deprecated with no replacement', - self::class - ); - - $this->annotationsPrefix = 'ORM\\'; - $this->inflector = InflectorFactory::create()->build(); - } - - /** - * Generates and writes entity classes for the given array of ClassMetadataInfo instances. - * - * @param string $outputDirectory - * @psalm-param list $metadatas - * - * @return void - */ - public function generate(array $metadatas, $outputDirectory) - { - foreach ($metadatas as $metadata) { - $this->writeEntityClass($metadata, $outputDirectory); - } - } - - /** - * Generates and writes entity class to disk for the given ClassMetadataInfo instance. - * - * @param string $outputDirectory - * - * @return void - * - * @throws RuntimeException - */ - public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory) - { - $path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $metadata->name) . $this->extension; - $dir = dirname($path); - - if (! is_dir($dir)) { - mkdir($dir, 0775, true); - } - - $this->isNew = ! file_exists($path) || $this->regenerateEntityIfExists; - - if (! $this->isNew) { - $this->parseTokensInEntityFile(file_get_contents($path)); - } else { - $this->staticReflection[$metadata->name] = ['properties' => [], 'methods' => []]; - } - - if ($this->backupExisting && file_exists($path)) { - $backupPath = dirname($path) . DIRECTORY_SEPARATOR . basename($path) . '~'; - if (! copy($path, $backupPath)) { - throw new RuntimeException('Attempt to backup overwritten entity file but copy operation failed.'); - } - } - - // If entity doesn't exist or we're re-generating the entities entirely - if ($this->isNew) { - file_put_contents($path, $this->generateEntityClass($metadata)); - // If entity exists and we're allowed to update the entity class - } elseif ($this->updateEntityIfExists) { - file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path)); - } - - chmod($path, 0664); - } - - /** - * Generates a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance. - * - * @return string - */ - public function generateEntityClass(ClassMetadataInfo $metadata) - { - $placeHolders = [ - '', - '', - '', - '', - '', - ]; - - $replacements = [ - $this->generateEntityNamespace($metadata), - $this->generateEntityUse(), - $this->generateEntityDocBlock($metadata), - $this->generateEntityClassName($metadata), - $this->generateEntityBody($metadata), - ]; - - $code = str_replace($placeHolders, $replacements, static::$classTemplate); - - return str_replace('', $this->spaces, $code); - } - - /** - * Generates the updated code for the given ClassMetadataInfo and entity at path. - * - * @param string $path - * - * @return string - */ - public function generateUpdatedEntityClass(ClassMetadataInfo $metadata, $path) - { - $currentCode = file_get_contents($path); - - $body = $this->generateEntityBody($metadata); - $body = str_replace('', $this->spaces, $body); - $last = strrpos($currentCode, '}'); - - return substr($currentCode, 0, $last) . $body . ($body ? "\n" : '') . "}\n"; - } - - /** - * Sets the number of spaces the exported class should have. - * - * @param int $numSpaces - * - * @return void - */ - public function setNumSpaces($numSpaces) - { - $this->spaces = str_repeat(' ', $numSpaces); - $this->numSpaces = $numSpaces; - } - - /** - * Sets the extension to use when writing php files to disk. - * - * @param string $extension - * - * @return void - */ - public function setExtension($extension) - { - $this->extension = $extension; - } - - /** - * Sets the name of the class the generated classes should extend from. - * - * @param string $classToExtend - * - * @return void - */ - public function setClassToExtend($classToExtend) - { - $this->classToExtend = $classToExtend; - } - - /** - * Sets whether or not to generate annotations for the entity. - * - * @param bool $bool - * - * @return void - */ - public function setGenerateAnnotations($bool) - { - $this->generateAnnotations = $bool; - } - - /** - * Sets the class fields visibility for the entity (can either be private or protected). - * - * @param string $visibility - * @psalm-param self::FIELD_VISIBLE_* - * - * @return void - * - * @throws InvalidArgumentException - */ - public function setFieldVisibility($visibility) - { - if ($visibility !== self::FIELD_VISIBLE_PRIVATE && $visibility !== self::FIELD_VISIBLE_PROTECTED) { - throw new InvalidArgumentException('Invalid provided visibility (only private and protected are allowed): ' . $visibility); - } - - $this->fieldVisibility = $visibility; - } - - /** - * Sets whether or not to generate immutable embeddables. - * - * @param bool $embeddablesImmutable - * - * @return void - */ - public function setEmbeddablesImmutable($embeddablesImmutable) - { - $this->embeddablesImmutable = (bool) $embeddablesImmutable; - } - - /** - * Sets an annotation prefix. - * - * @param string $prefix - * - * @return void - */ - public function setAnnotationPrefix($prefix) - { - $this->annotationsPrefix = $prefix; - } - - /** - * Sets whether or not to try and update the entity if it already exists. - * - * @param bool $bool - * - * @return void - */ - public function setUpdateEntityIfExists($bool) - { - $this->updateEntityIfExists = $bool; - } - - /** - * Sets whether or not to regenerate the entity if it exists. - * - * @param bool $bool - * - * @return void - */ - public function setRegenerateEntityIfExists($bool) - { - $this->regenerateEntityIfExists = $bool; - } - - /** - * Sets whether or not to generate stub methods for the entity. - * - * @param bool $bool - * - * @return void - */ - public function setGenerateStubMethods($bool) - { - $this->generateEntityStubMethods = $bool; - } - - /** - * Should an existing entity be backed up if it already exists? - * - * @param bool $bool - * - * @return void - */ - public function setBackupExisting($bool) - { - $this->backupExisting = $bool; - } - - public function setInflector(Inflector $inflector): void - { - $this->inflector = $inflector; - } - - /** - * @param string $type - * - * @return string - */ - protected function getType($type) - { - if (isset($this->typeAlias[$type])) { - return $this->typeAlias[$type]; - } - - return $type; - } - - /** - * @return string - */ - protected function generateEntityNamespace(ClassMetadataInfo $metadata) - { - if (! $this->hasNamespace($metadata)) { - return ''; - } - - return 'namespace ' . $this->getNamespace($metadata) . ';'; - } - - /** - * @return string - */ - protected function generateEntityUse() - { - if (! $this->generateAnnotations) { - return ''; - } - - return "\n" . 'use Doctrine\ORM\Mapping as ORM;' . "\n"; - } - - /** - * @return string - */ - protected function generateEntityClassName(ClassMetadataInfo $metadata) - { - return 'class ' . $this->getClassName($metadata) . - ($this->extendsClass() ? ' extends ' . $this->getClassToExtendName() : null); - } - - /** - * @return string - */ - protected function generateEntityBody(ClassMetadataInfo $metadata) - { - $fieldMappingProperties = $this->generateEntityFieldMappingProperties($metadata); - $embeddedProperties = $this->generateEntityEmbeddedProperties($metadata); - $associationMappingProperties = $this->generateEntityAssociationMappingProperties($metadata); - $stubMethods = $this->generateEntityStubMethods ? $this->generateEntityStubMethods($metadata) : null; - $lifecycleCallbackMethods = $this->generateEntityLifecycleCallbackMethods($metadata); - - $code = []; - - if ($fieldMappingProperties) { - $code[] = $fieldMappingProperties; - } - - if ($embeddedProperties) { - $code[] = $embeddedProperties; - } - - if ($associationMappingProperties) { - $code[] = $associationMappingProperties; - } - - $code[] = $this->generateEntityConstructor($metadata); - - if ($stubMethods) { - $code[] = $stubMethods; - } - - if ($lifecycleCallbackMethods) { - $code[] = $lifecycleCallbackMethods; - } - - return implode("\n", $code); - } - - /** - * @return string - */ - protected function generateEntityConstructor(ClassMetadataInfo $metadata) - { - if ($this->hasMethod('__construct', $metadata)) { - return ''; - } - - if ($metadata->isEmbeddedClass && $this->embeddablesImmutable) { - return $this->generateEmbeddableConstructor($metadata); - } - - $collections = []; - - foreach ($metadata->associationMappings as $mapping) { - if ($mapping['type'] & ClassMetadataInfo::TO_MANY) { - $collections[] = '$this->' . $mapping['fieldName'] . ' = new \Doctrine\Common\Collections\ArrayCollection();'; - } - } - - if ($collections) { - return $this->prefixCodeWithSpaces(str_replace('', implode("\n" . $this->spaces, $collections), static::$constructorMethodTemplate)); - } - - return ''; - } - - private function generateEmbeddableConstructor(ClassMetadataInfo $metadata): string - { - $paramTypes = []; - $paramVariables = []; - $params = []; - $fields = []; - - // Resort fields to put optional fields at the end of the method signature. - $requiredFields = []; - $optionalFields = []; - - foreach ($metadata->fieldMappings as $fieldMapping) { - if (empty($fieldMapping['nullable'])) { - $requiredFields[] = $fieldMapping; - - continue; - } - - $optionalFields[] = $fieldMapping; - } - - $fieldMappings = array_merge($requiredFields, $optionalFields); - - foreach ($metadata->embeddedClasses as $fieldName => $embeddedClass) { - $paramType = '\\' . ltrim($embeddedClass['class'], '\\'); - $paramVariable = '$' . $fieldName; - - $paramTypes[] = $paramType; - $paramVariables[] = $paramVariable; - $params[] = $paramType . ' ' . $paramVariable; - $fields[] = '$this->' . $fieldName . ' = ' . $paramVariable . ';'; - } - - foreach ($fieldMappings as $fieldMapping) { - if (isset($fieldMapping['declaredField'], $metadata->embeddedClasses[$fieldMapping['declaredField']])) { - continue; - } - - $paramTypes[] = $this->getType($fieldMapping['type']) . (! empty($fieldMapping['nullable']) ? '|null' : ''); - $param = '$' . $fieldMapping['fieldName']; - $paramVariables[] = $param; - - if ($fieldMapping['type'] === 'datetime') { - $param = $this->getType($fieldMapping['type']) . ' ' . $param; - } - - if (! empty($fieldMapping['nullable'])) { - $param .= ' = null'; - } - - $params[] = $param; - - $fields[] = '$this->' . $fieldMapping['fieldName'] . ' = $' . $fieldMapping['fieldName'] . ';'; - } - - $maxParamTypeLength = max(array_map('strlen', $paramTypes)); - $paramTags = array_map( - static function ($type, $variable) use ($maxParamTypeLength) { - return '@param ' . $type . str_repeat(' ', $maxParamTypeLength - strlen($type) + 1) . $variable; - }, - $paramTypes, - $paramVariables - ); - - // Generate multi line constructor if the signature exceeds 120 characters. - if (array_sum(array_map('strlen', $params)) + count($params) * 2 + 29 > 120) { - $delimiter = "\n" . $this->spaces; - $params = $delimiter . implode(',' . $delimiter, $params) . "\n"; - } else { - $params = implode(', ', $params); - } - - $replacements = [ - '' => implode("\n * ", $paramTags), - '' => $params, - '' => implode("\n" . $this->spaces, $fields), - ]; - - $constructor = str_replace( - array_keys($replacements), - array_values($replacements), - static::$embeddableConstructorMethodTemplate - ); - - return $this->prefixCodeWithSpaces($constructor); - } - - /** - * @param string $src - * - * @return void - * - * @todo this won't work if there is a namespace in brackets and a class outside of it. - * @psalm-suppress UndefinedConstant - */ - protected function parseTokensInEntityFile($src) - { - $tokens = token_get_all($src); - $tokensCount = count($tokens); - $lastSeenNamespace = ''; - $lastSeenClass = false; - - $inNamespace = false; - $inClass = false; - - for ($i = 0; $i < $tokensCount; $i++) { - $token = $tokens[$i]; - if (in_array($token[0], [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT], true)) { - continue; - } - - if ($inNamespace) { - if (in_array($token[0], [T_NS_SEPARATOR, T_STRING], true)) { - $lastSeenNamespace .= $token[1]; - } elseif (PHP_VERSION_ID >= 80000 && ($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED)) { - $lastSeenNamespace .= $token[1]; - } elseif (is_string($token) && in_array($token, [';', '{'], true)) { - $inNamespace = false; - } - } - - if ($inClass) { - $inClass = false; - $lastSeenClass = $lastSeenNamespace . ($lastSeenNamespace ? '\\' : '') . $token[1]; - $this->staticReflection[$lastSeenClass]['properties'] = []; - $this->staticReflection[$lastSeenClass]['methods'] = []; - } - - if ($token[0] === T_NAMESPACE) { - $lastSeenNamespace = ''; - $inNamespace = true; - } elseif ($token[0] === T_CLASS && $tokens[$i - 1][0] !== T_DOUBLE_COLON) { - $inClass = true; - } elseif ($token[0] === T_FUNCTION) { - if ($tokens[$i + 2][0] === T_STRING) { - $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i + 2][1]); - } elseif ($tokens[$i + 2] === '&' && $tokens[$i + 3][0] === T_STRING) { - $this->staticReflection[$lastSeenClass]['methods'][] = strtolower($tokens[$i + 3][1]); - } - } elseif (in_array($token[0], [T_VAR, T_PUBLIC, T_PRIVATE, T_PROTECTED], true) && $tokens[$i + 2][0] !== T_FUNCTION) { - $this->staticReflection[$lastSeenClass]['properties'][] = substr($tokens[$i + 2][1], 1); - } - } - } - - /** - * @param string $property - * - * @return bool - */ - protected function hasProperty($property, ClassMetadataInfo $metadata) - { - if ($this->extendsClass() || (! $this->isNew && class_exists($metadata->name))) { - // don't generate property if its already on the base class. - $reflClass = new ReflectionClass($this->getClassToExtend() ?: $metadata->name); - if ($reflClass->hasProperty($property)) { - return true; - } - } - - // check traits for existing property - foreach ($this->getTraits($metadata) as $trait) { - if ($trait->hasProperty($property)) { - return true; - } - } - - return isset($this->staticReflection[$metadata->name]) && - in_array($property, $this->staticReflection[$metadata->name]['properties'], true); - } - - /** - * @param string $method - * - * @return bool - */ - protected function hasMethod($method, ClassMetadataInfo $metadata) - { - if ($this->extendsClass() || (! $this->isNew && class_exists($metadata->name))) { - // don't generate method if its already on the base class. - $reflClass = new ReflectionClass($this->getClassToExtend() ?: $metadata->name); - - if ($reflClass->hasMethod($method)) { - return true; - } - } - - // check traits for existing method - foreach ($this->getTraits($metadata) as $trait) { - if ($trait->hasMethod($method)) { - return true; - } - } - - return isset($this->staticReflection[$metadata->name]) && - in_array(strtolower($method), $this->staticReflection[$metadata->name]['methods'], true); - } - - /** - * @return ReflectionClass[] - * @psalm-return array> - * - * @throws ReflectionException - */ - protected function getTraits(ClassMetadataInfo $metadata) - { - if (! ($metadata->reflClass !== null || class_exists($metadata->name))) { - return []; - } - - $reflClass = $metadata->reflClass ?? new ReflectionClass($metadata->name); - - $traits = []; - - while ($reflClass !== false) { - $traits = array_merge($traits, $reflClass->getTraits()); - - $reflClass = $reflClass->getParentClass(); - } - - return $traits; - } - - /** - * @return bool - */ - protected function hasNamespace(ClassMetadataInfo $metadata) - { - return (bool) strpos($metadata->name, '\\'); - } - - /** - * @return bool - */ - protected function extendsClass() - { - return (bool) $this->classToExtend; - } - - /** - * @return string - */ - protected function getClassToExtend() - { - return $this->classToExtend; - } - - /** - * @return string - */ - protected function getClassToExtendName() - { - $refl = new ReflectionClass($this->getClassToExtend()); - - return '\\' . $refl->getName(); - } - - /** - * @return string - */ - protected function getClassName(ClassMetadataInfo $metadata) - { - return ($pos = strrpos($metadata->name, '\\')) - ? substr($metadata->name, $pos + 1, strlen($metadata->name)) : $metadata->name; - } - - /** - * @return string - */ - protected function getNamespace(ClassMetadataInfo $metadata) - { - return substr($metadata->name, 0, strrpos($metadata->name, '\\')); - } - - /** - * @return string - */ - protected function generateEntityDocBlock(ClassMetadataInfo $metadata) - { - $lines = []; - $lines[] = '/**'; - $lines[] = ' * ' . $this->getClassName($metadata); - - if ($this->generateAnnotations) { - $lines[] = ' *'; - - $methods = [ - 'generateTableAnnotation', - 'generateInheritanceAnnotation', - 'generateDiscriminatorColumnAnnotation', - 'generateDiscriminatorMapAnnotation', - 'generateEntityAnnotation', - 'generateEntityListenerAnnotation', - ]; - - foreach ($methods as $method) { - $code = $this->$method($metadata); - if ($code) { - $lines[] = ' * ' . $code; - } - } - - if (isset($metadata->lifecycleCallbacks) && $metadata->lifecycleCallbacks) { - $lines[] = ' * @' . $this->annotationsPrefix . 'HasLifecycleCallbacks'; - } - } - - $lines[] = ' */'; - - return implode("\n", $lines); - } - - /** - * @return string - */ - protected function generateEntityAnnotation(ClassMetadataInfo $metadata) - { - $prefix = '@' . $this->annotationsPrefix; - - if ($metadata->isEmbeddedClass) { - return $prefix . 'Embeddable'; - } - - $customRepository = $metadata->customRepositoryClassName - ? '(repositoryClass="' . $metadata->customRepositoryClassName . '")' - : ''; - - return $prefix . ($metadata->isMappedSuperclass ? 'MappedSuperclass' : 'Entity') . $customRepository; - } - - /** - * @return string - */ - protected function generateTableAnnotation(ClassMetadataInfo $metadata) - { - if ($metadata->isEmbeddedClass) { - return ''; - } - - $table = []; - - if (isset($metadata->table['schema'])) { - $table[] = 'schema="' . $metadata->table['schema'] . '"'; - } - - if (isset($metadata->table['name'])) { - $table[] = 'name="' . $metadata->table['name'] . '"'; - } - - if (isset($metadata->table['options']) && $metadata->table['options']) { - $table[] = 'options={' . $this->exportTableOptions((array) $metadata->table['options']) . '}'; - } - - if (isset($metadata->table['uniqueConstraints']) && $metadata->table['uniqueConstraints']) { - $constraints = $this->generateTableConstraints('UniqueConstraint', $metadata->table['uniqueConstraints']); - $table[] = 'uniqueConstraints={' . $constraints . '}'; - } - - if (isset($metadata->table['indexes']) && $metadata->table['indexes']) { - $constraints = $this->generateTableConstraints('Index', $metadata->table['indexes']); - $table[] = 'indexes={' . $constraints . '}'; - } - - return '@' . $this->annotationsPrefix . 'Table(' . implode(', ', $table) . ')'; - } - - /** - * @param string $constraintName - * @psalm-param array> $constraints - * - * @return string - */ - protected function generateTableConstraints($constraintName, array $constraints) - { - $annotations = []; - foreach ($constraints as $name => $constraint) { - $columns = []; - foreach ($constraint['columns'] as $column) { - $columns[] = '"' . $column . '"'; - } - - $annotations[] = '@' . $this->annotationsPrefix . $constraintName . '(name="' . $name . '", columns={' . implode(', ', $columns) . '})'; - } - - return implode(', ', $annotations); - } - - /** - * @return string - */ - protected function generateInheritanceAnnotation(ClassMetadataInfo $metadata) - { - if ($metadata->inheritanceType === ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - return ''; - } - - return '@' . $this->annotationsPrefix . 'InheritanceType("' . $this->getInheritanceTypeString($metadata->inheritanceType) . '")'; - } - - /** - * @return string - */ - protected function generateDiscriminatorColumnAnnotation(ClassMetadataInfo $metadata) - { - if ($metadata->inheritanceType === ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - return ''; - } - - $discrColumn = $metadata->discriminatorColumn; - if ($discrColumn === null) { - return ''; - } - - $columnDefinition = 'name="' . $discrColumn['name'] - . '", type="' . $discrColumn['type'] - . '", length=' . $discrColumn['length']; - - return '@' . $this->annotationsPrefix . 'DiscriminatorColumn(' . $columnDefinition . ')'; - } - - /** - * @return string|null - */ - protected function generateDiscriminatorMapAnnotation(ClassMetadataInfo $metadata) - { - if ($metadata->inheritanceType === ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - return null; - } - - $inheritanceClassMap = []; - - foreach ($metadata->discriminatorMap as $type => $class) { - $inheritanceClassMap[] = '"' . $type . '" = "' . $class . '"'; - } - - return '@' . $this->annotationsPrefix . 'DiscriminatorMap({' . implode(', ', $inheritanceClassMap) . '})'; - } - - /** - * @return string - */ - protected function generateEntityStubMethods(ClassMetadataInfo $metadata) - { - $methods = []; - - foreach ($metadata->fieldMappings as $fieldMapping) { - if (isset($fieldMapping['declaredField'], $metadata->embeddedClasses[$fieldMapping['declaredField']])) { - continue; - } - - $nullableField = $this->nullableFieldExpression($fieldMapping); - - if ( - (! $metadata->isEmbeddedClass || ! $this->embeddablesImmutable) - && (! isset($fieldMapping['id']) || ! $fieldMapping['id'] || $metadata->generatorType === ClassMetadataInfo::GENERATOR_TYPE_NONE) - ) { - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'set', - $fieldMapping['fieldName'], - $fieldMapping['type'], - $nullableField - ); - } - - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'get', - $fieldMapping['fieldName'], - $fieldMapping['type'], - $nullableField - ); - } - - foreach ($metadata->embeddedClasses as $fieldName => $embeddedClass) { - if (isset($embeddedClass['declaredField'])) { - continue; - } - - if (! $metadata->isEmbeddedClass || ! $this->embeddablesImmutable) { - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'set', - $fieldName, - $embeddedClass['class'] - ); - } - - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'get', - $fieldName, - $embeddedClass['class'] - ); - } - - foreach ($metadata->associationMappings as $associationMapping) { - if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { - $nullable = $this->isAssociationIsNullable($associationMapping) ? 'null' : null; - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'set', - $associationMapping['fieldName'], - $associationMapping['targetEntity'], - $nullable - ); - - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'get', - $associationMapping['fieldName'], - $associationMapping['targetEntity'], - $nullable - ); - } elseif ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) { - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'add', - $associationMapping['fieldName'], - $associationMapping['targetEntity'] - ); - - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'remove', - $associationMapping['fieldName'], - $associationMapping['targetEntity'] - ); - - $methods[] = $this->generateEntityStubMethod( - $metadata, - 'get', - $associationMapping['fieldName'], - Collection::class - ); - } - } - - return implode("\n\n", array_filter($methods)); - } - - /** - * @psalm-param array $associationMapping - * - * @return bool - */ - protected function isAssociationIsNullable(array $associationMapping) - { - if (isset($associationMapping['id']) && $associationMapping['id']) { - return false; - } - - if (isset($associationMapping['joinColumns'])) { - $joinColumns = $associationMapping['joinColumns']; - } else { - //@todo there is no way to retrieve targetEntity metadata - $joinColumns = []; - } - - foreach ($joinColumns as $joinColumn) { - if (isset($joinColumn['nullable']) && ! $joinColumn['nullable']) { - return false; - } - } - - return true; - } - - /** - * @return string - */ - protected function generateEntityLifecycleCallbackMethods(ClassMetadataInfo $metadata) - { - if (empty($metadata->lifecycleCallbacks)) { - return ''; - } - - $methods = []; - - foreach ($metadata->lifecycleCallbacks as $name => $callbacks) { - foreach ($callbacks as $callback) { - $methods[] = $this->generateLifecycleCallbackMethod($name, $callback, $metadata); - } - } - - return implode("\n\n", array_filter($methods)); - } - - /** - * @return string - */ - protected function generateEntityAssociationMappingProperties(ClassMetadataInfo $metadata) - { - $lines = []; - - foreach ($metadata->associationMappings as $associationMapping) { - if ($this->hasProperty($associationMapping['fieldName'], $metadata)) { - continue; - } - - $lines[] = $this->generateAssociationMappingPropertyDocBlock($associationMapping, $metadata); - $lines[] = $this->spaces . $this->fieldVisibility . ' $' . $associationMapping['fieldName'] - . ($associationMapping['type'] === 'manyToMany' ? ' = array()' : null) . ";\n"; - } - - return implode("\n", $lines); - } - - /** - * @return string - */ - protected function generateEntityFieldMappingProperties(ClassMetadataInfo $metadata) - { - $lines = []; - - foreach ($metadata->fieldMappings as $fieldMapping) { - if ( - isset($fieldMapping['declaredField'], $metadata->embeddedClasses[$fieldMapping['declaredField']]) || - $this->hasProperty($fieldMapping['fieldName'], $metadata) || - $metadata->isInheritedField($fieldMapping['fieldName']) - ) { - continue; - } - - $defaultValue = ''; - if (isset($fieldMapping['options']['default'])) { - if ($fieldMapping['type'] === 'boolean' && $fieldMapping['options']['default'] === '1') { - $defaultValue = ' = true'; - } elseif (($fieldMapping['type'] === 'integer' || $fieldMapping['type'] === 'float') && ! empty($fieldMapping['options']['default'])) { - $defaultValue = ' = ' . (string) $fieldMapping['options']['default']; - } else { - $defaultValue = ' = ' . var_export($fieldMapping['options']['default'], true); - } - } - - $lines[] = $this->generateFieldMappingPropertyDocBlock($fieldMapping, $metadata); - $lines[] = $this->spaces . $this->fieldVisibility . ' $' . $fieldMapping['fieldName'] . $defaultValue . ";\n"; - } - - return implode("\n", $lines); - } - - /** - * @return string - */ - protected function generateEntityEmbeddedProperties(ClassMetadataInfo $metadata) - { - $lines = []; - - foreach ($metadata->embeddedClasses as $fieldName => $embeddedClass) { - if (isset($embeddedClass['declaredField']) || $this->hasProperty($fieldName, $metadata)) { - continue; - } - - $lines[] = $this->generateEmbeddedPropertyDocBlock($embeddedClass); - $lines[] = $this->spaces . $this->fieldVisibility . ' $' . $fieldName . ";\n"; - } - - return implode("\n", $lines); - } - - /** - * @param string $type - * @param string $fieldName - * @param string|null $typeHint - * @param string|null $defaultValue - * - * @return string - */ - protected function generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null) - { - $methodName = $type . $this->inflector->classify($fieldName); - $variableName = $this->inflector->camelize($fieldName); - - if (in_array($type, ['add', 'remove'], true)) { - $methodName = $this->inflector->singularize($methodName); - $variableName = $this->inflector->singularize($variableName); - } - - if ($this->hasMethod($methodName, $metadata)) { - return ''; - } - - $this->staticReflection[$metadata->name]['methods'][] = strtolower($methodName); - - $var = sprintf('%sMethodTemplate', $type); - $template = static::$$var; - - $methodTypeHint = ''; - $types = Type::getTypesMap(); - $variableType = $typeHint ? $this->getType($typeHint) : null; - - if ($typeHint && ! isset($types[$typeHint])) { - $variableType = '\\' . ltrim($variableType, '\\'); - $methodTypeHint = '\\' . $typeHint . ' '; - } - - $replacements = [ - '' => ucfirst($type) . ' ' . $variableName . '.', - '' => $methodTypeHint, - '' => $variableType . ($defaultValue !== null ? '|' . $defaultValue : ''), - '' => $variableName, - '' => $methodName, - '' => $fieldName, - '' => $defaultValue !== null ? ' = ' . $defaultValue : '', - '' => $this->getClassName($metadata), - ]; - - $method = str_replace( - array_keys($replacements), - array_values($replacements), - $template - ); - - return $this->prefixCodeWithSpaces($method); - } - - /** - * @param string $name - * @param string $methodName - * - * @return string - */ - protected function generateLifecycleCallbackMethod($name, $methodName, ClassMetadataInfo $metadata) - { - if ($this->hasMethod($methodName, $metadata)) { - return ''; - } - - $this->staticReflection[$metadata->name]['methods'][] = $methodName; - - $replacements = [ - '' => $this->annotationsPrefix . ucfirst($name), - '' => $methodName, - ]; - - $method = str_replace( - array_keys($replacements), - array_values($replacements), - static::$lifecycleCallbackMethodTemplate - ); - - return $this->prefixCodeWithSpaces($method); - } - - /** - * @psalm-param array $joinColumn - * - * @return string - */ - protected function generateJoinColumnAnnotation(array $joinColumn) - { - $joinColumnAnnot = []; - - if (isset($joinColumn['name'])) { - $joinColumnAnnot[] = 'name="' . $joinColumn['name'] . '"'; - } - - if (isset($joinColumn['referencedColumnName'])) { - $joinColumnAnnot[] = 'referencedColumnName="' . $joinColumn['referencedColumnName'] . '"'; - } - - if (isset($joinColumn['unique']) && $joinColumn['unique']) { - $joinColumnAnnot[] = 'unique=true'; - } - - if (isset($joinColumn['nullable'])) { - $joinColumnAnnot[] = 'nullable=' . ($joinColumn['nullable'] ? 'true' : 'false'); - } - - if (isset($joinColumn['onDelete'])) { - $joinColumnAnnot[] = 'onDelete="' . $joinColumn['onDelete'] . '"'; - } - - if (isset($joinColumn['columnDefinition'])) { - $joinColumnAnnot[] = 'columnDefinition="' . $joinColumn['columnDefinition'] . '"'; - } - - return '@' . $this->annotationsPrefix . 'JoinColumn(' . implode(', ', $joinColumnAnnot) . ')'; - } - - /** - * @param mixed[] $associationMapping - * - * @return string - */ - protected function generateAssociationMappingPropertyDocBlock(array $associationMapping, ClassMetadataInfo $metadata) - { - $lines = []; - $lines[] = $this->spaces . '/**'; - - if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) { - $lines[] = $this->spaces . ' * @var \Doctrine\Common\Collections\Collection'; - } else { - $lines[] = $this->spaces . ' * @var \\' . ltrim($associationMapping['targetEntity'], '\\'); - } - - if ($this->generateAnnotations) { - $lines[] = $this->spaces . ' *'; - - if (isset($associationMapping['id']) && $associationMapping['id']) { - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'Id'; - - $generatorType = $this->getIdGeneratorTypeString($metadata->generatorType); - if ($generatorType) { - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'GeneratedValue(strategy="' . $generatorType . '")'; - } - } - - $type = null; - switch ($associationMapping['type']) { - case ClassMetadataInfo::ONE_TO_ONE: - $type = 'OneToOne'; - break; - case ClassMetadataInfo::MANY_TO_ONE: - $type = 'ManyToOne'; - break; - case ClassMetadataInfo::ONE_TO_MANY: - $type = 'OneToMany'; - break; - case ClassMetadataInfo::MANY_TO_MANY: - $type = 'ManyToMany'; - break; - } - - $typeOptions = []; - - if (isset($associationMapping['targetEntity'])) { - $typeOptions[] = 'targetEntity="' . $associationMapping['targetEntity'] . '"'; - } - - if (isset($associationMapping['inversedBy'])) { - $typeOptions[] = 'inversedBy="' . $associationMapping['inversedBy'] . '"'; - } - - if (isset($associationMapping['mappedBy'])) { - $typeOptions[] = 'mappedBy="' . $associationMapping['mappedBy'] . '"'; - } - - if ($associationMapping['cascade']) { - $cascades = []; - - if ($associationMapping['isCascadePersist']) { - $cascades[] = '"persist"'; - } - - if ($associationMapping['isCascadeRemove']) { - $cascades[] = '"remove"'; - } - - if ($associationMapping['isCascadeDetach']) { - $cascades[] = '"detach"'; - } - - if ($associationMapping['isCascadeMerge']) { - $cascades[] = '"merge"'; - } - - if ($associationMapping['isCascadeRefresh']) { - $cascades[] = '"refresh"'; - } - - if (count($cascades) === 5) { - $cascades = ['"all"']; - } - - $typeOptions[] = 'cascade={' . implode(',', $cascades) . '}'; - } - - if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval']) { - $typeOptions[] = 'orphanRemoval=true'; - } - - if (isset($associationMapping['fetch']) && $associationMapping['fetch'] !== ClassMetadataInfo::FETCH_LAZY) { - $fetchMap = [ - ClassMetadataInfo::FETCH_EXTRA_LAZY => 'EXTRA_LAZY', - ClassMetadataInfo::FETCH_EAGER => 'EAGER', - ]; - - $typeOptions[] = 'fetch="' . $fetchMap[$associationMapping['fetch']] . '"'; - } - - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . '' . $type . '(' . implode(', ', $typeOptions) . ')'; - - if (isset($associationMapping['joinColumns']) && $associationMapping['joinColumns']) { - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'JoinColumns({'; - - $joinColumnsLines = []; - - foreach ($associationMapping['joinColumns'] as $joinColumn) { - $joinColumnAnnot = $this->generateJoinColumnAnnotation($joinColumn); - if ($joinColumnAnnot) { - $joinColumnsLines[] = $this->spaces . ' * ' . $joinColumnAnnot; - } - } - - $lines[] = implode(",\n", $joinColumnsLines); - $lines[] = $this->spaces . ' * })'; - } - - if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) { - $joinTable = []; - $joinTable[] = 'name="' . $associationMapping['joinTable']['name'] . '"'; - - if (isset($associationMapping['joinTable']['schema'])) { - $joinTable[] = 'schema="' . $associationMapping['joinTable']['schema'] . '"'; - } - - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'JoinTable(' . implode(', ', $joinTable) . ','; - $lines[] = $this->spaces . ' * joinColumns={'; - - $joinColumnsLines = []; - - foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) { - $joinColumnsLines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn); - } - - $lines[] = implode(',' . PHP_EOL, $joinColumnsLines); - $lines[] = $this->spaces . ' * },'; - $lines[] = $this->spaces . ' * inverseJoinColumns={'; - - $inverseJoinColumnsLines = []; - - foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $joinColumn) { - $inverseJoinColumnsLines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn); - } - - $lines[] = implode(',' . PHP_EOL, $inverseJoinColumnsLines); - $lines[] = $this->spaces . ' * }'; - $lines[] = $this->spaces . ' * )'; - } - - if (isset($associationMapping['orderBy'])) { - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'OrderBy({'; - - foreach ($associationMapping['orderBy'] as $name => $direction) { - $lines[] = $this->spaces . ' * "' . $name . '"="' . $direction . '",'; - } - - $lines[count($lines) - 1] = substr($lines[count($lines) - 1], 0, strlen($lines[count($lines) - 1]) - 1); - $lines[] = $this->spaces . ' * })'; - } - } - - $lines[] = $this->spaces . ' */'; - - return implode("\n", $lines); - } - - /** - * @param mixed[] $fieldMapping - * - * @return string - */ - protected function generateFieldMappingPropertyDocBlock(array $fieldMapping, ClassMetadataInfo $metadata) - { - $lines = []; - $lines[] = $this->spaces . '/**'; - $lines[] = $this->spaces . ' * @var ' - . $this->getType($fieldMapping['type']) - . ($this->nullableFieldExpression($fieldMapping) ? '|null' : ''); - - if ($this->generateAnnotations) { - $lines[] = $this->spaces . ' *'; - - $column = []; - if (isset($fieldMapping['columnName'])) { - $column[] = 'name="' . $fieldMapping['columnName'] . '"'; - } - - if (isset($fieldMapping['type'])) { - $column[] = 'type="' . $fieldMapping['type'] . '"'; - } - - if (isset($fieldMapping['length'])) { - $column[] = 'length=' . $fieldMapping['length']; - } - - if (isset($fieldMapping['precision'])) { - $column[] = 'precision=' . $fieldMapping['precision']; - } - - if (isset($fieldMapping['scale'])) { - $column[] = 'scale=' . $fieldMapping['scale']; - } - - if (isset($fieldMapping['nullable'])) { - $column[] = 'nullable=' . var_export($fieldMapping['nullable'], true); - } - - $options = []; - - if (isset($fieldMapping['options']['default']) && $fieldMapping['options']['default']) { - $options[] = '"default"="' . $fieldMapping['options']['default'] . '"'; - } - - if (isset($fieldMapping['options']['unsigned']) && $fieldMapping['options']['unsigned']) { - $options[] = '"unsigned"=true'; - } - - if (isset($fieldMapping['options']['fixed']) && $fieldMapping['options']['fixed']) { - $options[] = '"fixed"=true'; - } - - if (isset($fieldMapping['options']['comment']) && $fieldMapping['options']['comment']) { - $options[] = '"comment"="' . str_replace('"', '""', $fieldMapping['options']['comment']) . '"'; - } - - if (isset($fieldMapping['options']['collation']) && $fieldMapping['options']['collation']) { - $options[] = '"collation"="' . $fieldMapping['options']['collation'] . '"'; - } - - if (isset($fieldMapping['options']['check']) && $fieldMapping['options']['check']) { - $options[] = '"check"="' . $fieldMapping['options']['check'] . '"'; - } - - if ($options) { - $column[] = 'options={' . implode(',', $options) . '}'; - } - - if (isset($fieldMapping['columnDefinition'])) { - $column[] = 'columnDefinition="' . $fieldMapping['columnDefinition'] . '"'; - } - - if (isset($fieldMapping['unique'])) { - $column[] = 'unique=' . var_export($fieldMapping['unique'], true); - } - - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'Column(' . implode(', ', $column) . ')'; - - if (isset($fieldMapping['id']) && $fieldMapping['id']) { - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'Id'; - - $generatorType = $this->getIdGeneratorTypeString($metadata->generatorType); - if ($generatorType) { - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'GeneratedValue(strategy="' . $generatorType . '")'; - } - - if ($metadata->sequenceGeneratorDefinition) { - $sequenceGenerator = []; - - if (isset($metadata->sequenceGeneratorDefinition['sequenceName'])) { - $sequenceGenerator[] = 'sequenceName="' . $metadata->sequenceGeneratorDefinition['sequenceName'] . '"'; - } - - if (isset($metadata->sequenceGeneratorDefinition['allocationSize'])) { - $sequenceGenerator[] = 'allocationSize=' . $metadata->sequenceGeneratorDefinition['allocationSize']; - } - - if (isset($metadata->sequenceGeneratorDefinition['initialValue'])) { - $sequenceGenerator[] = 'initialValue=' . $metadata->sequenceGeneratorDefinition['initialValue']; - } - - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'SequenceGenerator(' . implode(', ', $sequenceGenerator) . ')'; - } - } - - if (isset($fieldMapping['version']) && $fieldMapping['version']) { - $lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'Version'; - } - } - - $lines[] = $this->spaces . ' */'; - - return implode("\n", $lines); - } - - /** - * @psalm-param array $embeddedClass - * - * @return string - */ - protected function generateEmbeddedPropertyDocBlock(array $embeddedClass) - { - $lines = []; - $lines[] = $this->spaces . '/**'; - $lines[] = $this->spaces . ' * @var \\' . ltrim($embeddedClass['class'], '\\'); - - if ($this->generateAnnotations) { - $lines[] = $this->spaces . ' *'; - - $embedded = ['class="' . $embeddedClass['class'] . '"']; - - if (isset($embeddedClass['columnPrefix'])) { - if (is_string($embeddedClass['columnPrefix'])) { - $embedded[] = 'columnPrefix="' . $embeddedClass['columnPrefix'] . '"'; - } else { - $embedded[] = 'columnPrefix=' . var_export($embeddedClass['columnPrefix'], true); - } - } - - $lines[] = $this->spaces . ' * @' . - $this->annotationsPrefix . 'Embedded(' . implode(', ', $embedded) . ')'; - } - - $lines[] = $this->spaces . ' */'; - - return implode("\n", $lines); - } - - private function generateEntityListenerAnnotation(ClassMetadataInfo $metadata): string - { - if (count($metadata->entityListeners) === 0) { - return ''; - } - - $processedClasses = []; - foreach ($metadata->entityListeners as $event => $eventListeners) { - foreach ($eventListeners as $eventListener) { - $processedClasses[] = '"' . $eventListener['class'] . '"'; - } - } - - return sprintf( - '%s%s({%s})', - '@' . $this->annotationsPrefix, - 'EntityListeners', - implode(',', array_unique($processedClasses)) - ); - } - - /** - * @param string $code - * @param int $num - * - * @return string - */ - protected function prefixCodeWithSpaces($code, $num = 1) - { - $lines = explode("\n", $code); - - foreach ($lines as $key => $value) { - if ($value !== '') { - $lines[$key] = str_repeat($this->spaces, $num) . $lines[$key]; - } - } - - return implode("\n", $lines); - } - - /** - * @param int $type The inheritance type used by the class and its subclasses. - * - * @return string The literal string for the inheritance type. - * - * @throws InvalidArgumentException When the inheritance type does not exist. - */ - protected function getInheritanceTypeString($type) - { - if (! isset(static::$inheritanceTypeMap[$type])) { - throw new InvalidArgumentException(sprintf('Invalid provided InheritanceType: %s', $type)); - } - - return static::$inheritanceTypeMap[$type]; - } - - /** - * @param int $type The policy used for change-tracking for the mapped class. - * - * @return string The literal string for the change-tracking type. - * - * @throws InvalidArgumentException When the change-tracking type does not exist. - */ - protected function getChangeTrackingPolicyString($type) - { - if (! isset(static::$changeTrackingPolicyMap[$type])) { - throw new InvalidArgumentException(sprintf('Invalid provided ChangeTrackingPolicy: %s', $type)); - } - - return static::$changeTrackingPolicyMap[$type]; - } - - /** - * @param int $type The generator to use for the mapped class. - * - * @return string The literal string for the generator type. - * - * @throws InvalidArgumentException When the generator type does not exist. - */ - protected function getIdGeneratorTypeString($type) - { - if (! isset(static::$generatorStrategyMap[$type])) { - throw new InvalidArgumentException(sprintf('Invalid provided IdGeneratorType: %s', $type)); - } - - return static::$generatorStrategyMap[$type]; - } - - /** - * @psalm-param array $fieldMapping - */ - private function nullableFieldExpression(array $fieldMapping): ?string - { - if (isset($fieldMapping['nullable']) && $fieldMapping['nullable'] === true) { - return 'null'; - } - - return null; - } - - /** - * Exports (nested) option elements. - * - * @psalm-param array $options - */ - private function exportTableOptions(array $options): string - { - $optionsStr = []; - - foreach ($options as $name => $option) { - if (is_array($option)) { - $optionsStr[] = '"' . $name . '"={' . $this->exportTableOptions($option) . '}'; - } else { - $optionsStr[] = '"' . $name . '"="' . (string) $option . '"'; - } - } - - return implode(',', $optionsStr); - } -} diff --git a/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php b/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php deleted file mode 100644 index 97abdb3e7a6..00000000000 --- a/lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php +++ /dev/null @@ -1,168 +0,0 @@ - - -/** - * - * - * This class was generated by the Doctrine ORM. Add your own custom - * repository methods below. - */ -class extends -{ -} -'; - - public function __construct() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8458', - '%s is deprecated and will be removed in Doctrine ORM 3.0', - self::class - ); - } - - /** - * @param string $fullClassName - * - * @return string - */ - public function generateEntityRepositoryClass($fullClassName) - { - $variables = [ - '' => $this->generateEntityRepositoryNamespace($fullClassName), - '' => $this->generateEntityRepositoryName($fullClassName), - '' => $this->generateClassName($fullClassName), - ]; - - return str_replace(array_keys($variables), array_values($variables), self::$_template); - } - - /** - * Generates the namespace, if class do not have namespace, return empty string instead. - * - * @psalm-param class-string $fullClassName - */ - private function getClassNamespace(string $fullClassName): string - { - return substr($fullClassName, 0, (int) strrpos($fullClassName, '\\')); - } - - /** - * Generates the class name - * - * @psalm-param class-string $fullClassName - */ - private function generateClassName(string $fullClassName): string - { - $namespace = $this->getClassNamespace($fullClassName); - - $className = $fullClassName; - - if ($namespace) { - $className = substr($fullClassName, strrpos($fullClassName, '\\') + 1, strlen($fullClassName)); - } - - return $className; - } - - /** - * Generates the namespace statement, if class do not have namespace, return empty string instead. - * - * @psalm-param class-string $fullClassName The full repository class name. - */ - private function generateEntityRepositoryNamespace(string $fullClassName): string - { - $namespace = $this->getClassNamespace($fullClassName); - - return $namespace ? 'namespace ' . $namespace . ';' : ''; - } - - private function generateEntityRepositoryName(string $fullClassName): string - { - $namespace = $this->getClassNamespace($fullClassName); - - $repositoryName = $this->repositoryName ?: EntityRepository::class; - - if ($namespace && $repositoryName[0] !== '\\') { - $repositoryName = '\\' . $repositoryName; - } - - return $repositoryName; - } - - /** - * @param string $fullClassName - * @param string $outputDirectory - * - * @return void - */ - public function writeEntityRepositoryClass($fullClassName, $outputDirectory) - { - $code = $this->generateEntityRepositoryClass($fullClassName); - - $path = $outputDirectory . DIRECTORY_SEPARATOR - . str_replace('\\', DIRECTORY_SEPARATOR, $fullClassName) . '.php'; - $dir = dirname($path); - - if (! is_dir($dir)) { - mkdir($dir, 0775, true); - } - - if (! file_exists($path)) { - file_put_contents($path, $code); - chmod($path, 0664); - } - } - - /** - * @param string $repositoryName - * - * @return $this - */ - public function setDefaultRepositoryName($repositoryName) - { - $this->repositoryName = $repositoryName; - - return $this; - } -} diff --git a/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php b/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php deleted file mode 100644 index 6b73461a913..00000000000 --- a/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php +++ /dev/null @@ -1,71 +0,0 @@ - */ - private static $_exporterDrivers = [ - 'xml' => Driver\XmlExporter::class, - 'yaml' => Driver\YamlExporter::class, - 'yml' => Driver\YamlExporter::class, - 'php' => Driver\PhpExporter::class, - 'annotation' => Driver\AnnotationExporter::class, - ]; - - public function __construct() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8458', - '%s is deprecated with no replacement', - self::class - ); - } - - /** - * Registers a new exporter driver class under a specified name. - * - * @param string $name - * @param string $class - * - * @return void - */ - public static function registerExportDriver($name, $class) - { - self::$_exporterDrivers[$name] = $class; - } - - /** - * Gets an exporter driver instance. - * - * @param string $type The type to get (yml, xml, etc.). - * @param string|null $dest The directory where the exporter will export to. - * - * @return Driver\AbstractExporter - * - * @throws ExportException - */ - public function getExporter($type, $dest = null) - { - if (! isset(self::$_exporterDrivers[$type])) { - throw ExportException::invalidExporterDriverType($type); - } - - $class = self::$_exporterDrivers[$type]; - - return new $class($dest); - } -} diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php deleted file mode 100644 index ea1cb540d44..00000000000 --- a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php +++ /dev/null @@ -1,260 +0,0 @@ -_outputDir = $dir; - } - - /** - * @param bool $overwrite - * - * @return void - */ - public function setOverwriteExistingFiles($overwrite) - { - $this->_overwriteExistingFiles = $overwrite; - } - - /** - * Converts a single ClassMetadata instance to the exported format - * and returns it. - * - * @return string - */ - abstract public function exportClassMetadata(ClassMetadataInfo $metadata); - - /** - * Sets the array of ClassMetadata instances to export. - * - * @psalm-param list $metadata - * - * @return void - */ - public function setMetadata(array $metadata) - { - $this->_metadata = $metadata; - } - - /** - * Gets the extension used to generated the path to a class. - * - * @return string|null - */ - public function getExtension() - { - return $this->_extension; - } - - /** - * Sets the directory to output the mapping files to. - * - * [php] - * $exporter = new YamlExporter($metadata); - * $exporter->setOutputDir(__DIR__ . '/yaml'); - * $exporter->export(); - * - * @param string $dir - * - * @return void - */ - public function setOutputDir($dir) - { - $this->_outputDir = $dir; - } - - /** - * Exports each ClassMetadata instance to a single Doctrine Mapping file - * named after the entity. - * - * @return void - * - * @throws ExportException - */ - public function export() - { - if (! is_dir($this->_outputDir)) { - mkdir($this->_outputDir, 0775, true); - } - - foreach ($this->_metadata as $metadata) { - // In case output is returned, write it to a file, skip otherwise - $output = $this->exportClassMetadata($metadata); - if ($output) { - $path = $this->_generateOutputPath($metadata); - $dir = dirname($path); - if (! is_dir($dir)) { - mkdir($dir, 0775, true); - } - - if (file_exists($path) && ! $this->_overwriteExistingFiles) { - throw ExportException::attemptOverwriteExistingFile($path); - } - - file_put_contents($path, $output); - chmod($path, 0664); - } - } - } - - /** - * Generates the path to write the class for the given ClassMetadataInfo instance. - * - * @return string - */ - protected function _generateOutputPath(ClassMetadataInfo $metadata) - { - return $this->_outputDir . '/' . str_replace('\\', '.', $metadata->name) . $this->_extension; - } - - /** - * Sets the directory to output the mapping files to. - * - * [php] - * $exporter = new YamlExporter($metadata, __DIR__ . '/yaml'); - * $exporter->setExtension('.yml'); - * $exporter->export(); - * - * @param string $extension - * - * @return void - */ - public function setExtension($extension) - { - $this->_extension = $extension; - } - - /** - * @param int $type - * @psalm-param ClassMetadataInfo::INHERITANCE_TYPE_* $type - * - * @return string - */ - protected function _getInheritanceTypeString($type) - { - switch ($type) { - case ClassMetadataInfo::INHERITANCE_TYPE_NONE: - return 'NONE'; - - case ClassMetadataInfo::INHERITANCE_TYPE_JOINED: - return 'JOINED'; - - case ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE: - return 'SINGLE_TABLE'; - - case ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS: - return 'PER_CLASS'; - } - } - - /** - * @param int $mode - * @psalm-param ClassMetadataInfo::FETCH_* $mode - * - * @return string - */ - protected function _getFetchModeString($mode) - { - switch ($mode) { - case ClassMetadataInfo::FETCH_EAGER: - return 'EAGER'; - - case ClassMetadataInfo::FETCH_EXTRA_LAZY: - return 'EXTRA_LAZY'; - - case ClassMetadataInfo::FETCH_LAZY: - return 'LAZY'; - } - } - - /** - * @param int $policy - * @psalm-param ClassMetadataInfo::CHANGETRACKING_* $policy - * - * @return string - */ - protected function _getChangeTrackingPolicyString($policy) - { - switch ($policy) { - case ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT: - return 'DEFERRED_IMPLICIT'; - - case ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT: - return 'DEFERRED_EXPLICIT'; - - case ClassMetadataInfo::CHANGETRACKING_NOTIFY: - return 'NOTIFY'; - } - } - - /** - * @param int $type - * @psalm-param ClassMetadataInfo::GENERATOR_TYPE_* $type - * - * @return string - */ - protected function _getIdGeneratorTypeString($type) - { - switch ($type) { - case ClassMetadataInfo::GENERATOR_TYPE_AUTO: - return 'AUTO'; - - case ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE: - return 'SEQUENCE'; - - case ClassMetadataInfo::GENERATOR_TYPE_IDENTITY: - return 'IDENTITY'; - - case ClassMetadataInfo::GENERATOR_TYPE_CUSTOM: - return 'CUSTOM'; - } - } -} diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php deleted file mode 100644 index 81573d59adc..00000000000 --- a/lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php +++ /dev/null @@ -1,60 +0,0 @@ -_entityGenerator) { - throw new RuntimeException('For the AnnotationExporter you must set an EntityGenerator instance with the setEntityGenerator() method.'); - } - - $this->_entityGenerator->setGenerateAnnotations(true); - $this->_entityGenerator->setGenerateStubMethods(false); - $this->_entityGenerator->setRegenerateEntityIfExists(false); - $this->_entityGenerator->setUpdateEntityIfExists(false); - - return $this->_entityGenerator->generateEntityClass($metadata); - } - - /** - * @return string - */ - protected function _generateOutputPath(ClassMetadataInfo $metadata) - { - return $this->_outputDir . '/' . str_replace('\\', '/', $metadata->name) . $this->_extension; - } - - /** - * @return void - */ - public function setEntityGenerator(EntityGenerator $entityGenerator) - { - $this->_entityGenerator = $entityGenerator; - } -} diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php deleted file mode 100644 index 3474bfc5807..00000000000 --- a/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php +++ /dev/null @@ -1,203 +0,0 @@ -isMappedSuperclass) { - $lines[] = '$metadata->isMappedSuperclass = true;'; - } - - if ($metadata->inheritanceType) { - $lines[] = '$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_' . $this->_getInheritanceTypeString($metadata->inheritanceType) . ');'; - } - - if ($metadata->customRepositoryClassName) { - $lines[] = "\$metadata->customRepositoryClassName = '" . $metadata->customRepositoryClassName . "';"; - } - - if ($metadata->table) { - $lines[] = '$metadata->setPrimaryTable(' . $this->_varExport($metadata->table) . ');'; - } - - if ($metadata->discriminatorColumn) { - $lines[] = '$metadata->setDiscriminatorColumn(' . $this->_varExport($metadata->discriminatorColumn) . ');'; - } - - if ($metadata->discriminatorMap) { - $lines[] = '$metadata->setDiscriminatorMap(' . $this->_varExport($metadata->discriminatorMap) . ');'; - } - - if ($metadata->changeTrackingPolicy) { - $lines[] = '$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_' . $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy) . ');'; - } - - if ($metadata->lifecycleCallbacks) { - foreach ($metadata->lifecycleCallbacks as $event => $callbacks) { - foreach ($callbacks as $callback) { - $lines[] = sprintf("\$metadata->addLifecycleCallback('%s', '%s');", $callback, $event); - } - } - } - - $lines = array_merge($lines, $this->processEntityListeners($metadata)); - - foreach ($metadata->fieldMappings as $fieldMapping) { - $lines[] = '$metadata->mapField(' . $this->_varExport($fieldMapping) . ');'; - } - - if (! $metadata->isIdentifierComposite) { - $generatorType = $this->_getIdGeneratorTypeString($metadata->generatorType); - if ($generatorType) { - $lines[] = '$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_' . $generatorType . ');'; - } - } - - foreach ($metadata->associationMappings as $associationMapping) { - $cascade = ['remove', 'persist', 'refresh', 'merge', 'detach']; - foreach ($cascade as $key => $value) { - if (! $associationMapping['isCascade' . ucfirst($value)]) { - unset($cascade[$key]); - } - } - - if (count($cascade) === 5) { - $cascade = ['all']; - } - - $method = null; - $associationMappingArray = [ - 'fieldName' => $associationMapping['fieldName'], - 'targetEntity' => $associationMapping['targetEntity'], - 'cascade' => $cascade, - ]; - - if (isset($associationMapping['fetch'])) { - $associationMappingArray['fetch'] = $associationMapping['fetch']; - } - - if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { - $method = 'mapOneToOne'; - $oneToOneMappingArray = [ - 'mappedBy' => $associationMapping['mappedBy'], - 'inversedBy' => $associationMapping['inversedBy'], - 'joinColumns' => $associationMapping['isOwningSide'] ? $associationMapping['joinColumns'] : [], - 'orphanRemoval' => $associationMapping['orphanRemoval'], - ]; - - $associationMappingArray = array_merge($associationMappingArray, $oneToOneMappingArray); - } elseif ($associationMapping['type'] === ClassMetadataInfo::ONE_TO_MANY) { - $method = 'mapOneToMany'; - $potentialAssociationMappingIndexes = [ - 'mappedBy', - 'orphanRemoval', - 'orderBy', - ]; - $oneToManyMappingArray = []; - foreach ($potentialAssociationMappingIndexes as $index) { - if (isset($associationMapping[$index])) { - $oneToManyMappingArray[$index] = $associationMapping[$index]; - } - } - - $associationMappingArray = array_merge($associationMappingArray, $oneToManyMappingArray); - } elseif ($associationMapping['type'] === ClassMetadataInfo::MANY_TO_MANY) { - $method = 'mapManyToMany'; - $potentialAssociationMappingIndexes = [ - 'mappedBy', - 'joinTable', - 'orderBy', - ]; - $manyToManyMappingArray = []; - foreach ($potentialAssociationMappingIndexes as $index) { - if (isset($associationMapping[$index])) { - $manyToManyMappingArray[$index] = $associationMapping[$index]; - } - } - - $associationMappingArray = array_merge($associationMappingArray, $manyToManyMappingArray); - } - - $lines[] = '$metadata->' . $method . '(' . $this->_varExport($associationMappingArray) . ');'; - } - - return implode("\n", $lines); - } - - /** - * @param mixed $var - * - * @return string - */ - protected function _varExport($var) - { - $export = var_export($var, true); - $export = str_replace("\n", PHP_EOL . str_repeat(' ', 8), $export); - $export = str_replace(' ', ' ', $export); - $export = str_replace('array (', 'array(', $export); - $export = str_replace('array( ', 'array(', $export); - $export = str_replace(',)', ')', $export); - $export = str_replace(', )', ')', $export); - $export = str_replace(' ', ' ', $export); - - return $export; - } - - /** - * @return string[] - * @psalm-return list - */ - private function processEntityListeners(ClassMetadataInfo $metadata): array - { - $lines = []; - - foreach ($metadata->entityListeners as $event => $entityListenerConfig) { - foreach ($entityListenerConfig as $entityListener) { - $lines[] = sprintf( - '$metadata->addEntityListener(%s, %s, %s);', - var_export($event, true), - var_export($entityListener['class'], true), - var_export($entityListener['method'], true) - ); - } - } - - return $lines; - } -} diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php deleted file mode 100644 index 7510792ee98..00000000000 --- a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php +++ /dev/null @@ -1,498 +0,0 @@ -'); - - if ($metadata->isMappedSuperclass) { - $root = $xml->addChild('mapped-superclass'); - } else { - $root = $xml->addChild('entity'); - } - - if ($metadata->customRepositoryClassName) { - $root->addAttribute('repository-class', $metadata->customRepositoryClassName); - } - - $root->addAttribute('name', $metadata->name); - - if (isset($metadata->table['name'])) { - $root->addAttribute('table', $metadata->table['name']); - } - - if (isset($metadata->table['schema'])) { - $root->addAttribute('schema', $metadata->table['schema']); - } - - if ($metadata->inheritanceType && $metadata->inheritanceType !== ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - $root->addAttribute('inheritance-type', $this->_getInheritanceTypeString($metadata->inheritanceType)); - } - - if (isset($metadata->table['options'])) { - $optionsXml = $root->addChild('options'); - - $this->exportTableOptions($optionsXml, $metadata->table['options']); - } - - if ($metadata->discriminatorColumn) { - $discriminatorColumnXml = $root->addChild('discriminator-column'); - $discriminatorColumnXml->addAttribute('name', $metadata->discriminatorColumn['name']); - $discriminatorColumnXml->addAttribute('type', $metadata->discriminatorColumn['type']); - - if (isset($metadata->discriminatorColumn['length'])) { - $discriminatorColumnXml->addAttribute('length', $metadata->discriminatorColumn['length']); - } - } - - if ($metadata->discriminatorMap) { - $discriminatorMapXml = $root->addChild('discriminator-map'); - - foreach ($metadata->discriminatorMap as $value => $className) { - $discriminatorMappingXml = $discriminatorMapXml->addChild('discriminator-mapping'); - $discriminatorMappingXml->addAttribute('value', $value); - $discriminatorMappingXml->addAttribute('class', $className); - } - } - - $trackingPolicy = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy); - - if ($trackingPolicy !== 'DEFERRED_IMPLICIT') { - $root->addChild('change-tracking-policy', $trackingPolicy); - } - - if (isset($metadata->table['indexes'])) { - $indexesXml = $root->addChild('indexes'); - - foreach ($metadata->table['indexes'] as $name => $index) { - $indexXml = $indexesXml->addChild('index'); - $indexXml->addAttribute('name', $name); - $indexXml->addAttribute('columns', implode(',', $index['columns'])); - if (isset($index['flags'])) { - $indexXml->addAttribute('flags', implode(',', $index['flags'])); - } - } - } - - if (isset($metadata->table['uniqueConstraints'])) { - $uniqueConstraintsXml = $root->addChild('unique-constraints'); - - foreach ($metadata->table['uniqueConstraints'] as $name => $unique) { - $uniqueConstraintXml = $uniqueConstraintsXml->addChild('unique-constraint'); - $uniqueConstraintXml->addAttribute('name', $name); - $uniqueConstraintXml->addAttribute('columns', implode(',', $unique['columns'])); - } - } - - $fields = $metadata->fieldMappings; - - $id = []; - foreach ($fields as $name => $field) { - if (isset($field['id']) && $field['id']) { - $id[$name] = $field; - unset($fields[$name]); - } - } - - foreach ($metadata->associationMappings as $name => $assoc) { - if (isset($assoc['id']) && $assoc['id']) { - $id[$name] = [ - 'fieldName' => $name, - 'associationKey' => true, - ]; - } - } - - if (! $metadata->isIdentifierComposite) { - $idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType); - if ($idGeneratorType) { - $id[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $idGeneratorType; - } - } - - if ($id) { - foreach ($id as $field) { - $idXml = $root->addChild('id'); - $idXml->addAttribute('name', $field['fieldName']); - - if (isset($field['type'])) { - $idXml->addAttribute('type', $field['type']); - } - - if (isset($field['columnName'])) { - $idXml->addAttribute('column', $field['columnName']); - } - - if (isset($field['length'])) { - $idXml->addAttribute('length', (string) $field['length']); - } - - if (isset($field['associationKey']) && $field['associationKey']) { - $idXml->addAttribute('association-key', 'true'); - } - - $idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType); - if ($idGeneratorType) { - $generatorXml = $idXml->addChild('generator'); - $generatorXml->addAttribute('strategy', $idGeneratorType); - - $this->exportSequenceInformation($idXml, $metadata); - } - } - } - - if ($fields) { - foreach ($fields as $field) { - $fieldXml = $root->addChild('field'); - $fieldXml->addAttribute('name', $field['fieldName']); - $fieldXml->addAttribute('type', $field['type']); - - if (isset($field['columnName'])) { - $fieldXml->addAttribute('column', $field['columnName']); - } - - if (isset($field['length'])) { - $fieldXml->addAttribute('length', (string) $field['length']); - } - - if (isset($field['precision'])) { - $fieldXml->addAttribute('precision', (string) $field['precision']); - } - - if (isset($field['scale'])) { - $fieldXml->addAttribute('scale', (string) $field['scale']); - } - - if (isset($field['unique']) && $field['unique']) { - $fieldXml->addAttribute('unique', 'true'); - } - - if (isset($field['options'])) { - $optionsXml = $fieldXml->addChild('options'); - foreach ($field['options'] as $key => $value) { - $optionXml = $optionsXml->addChild('option', (string) $value); - $optionXml->addAttribute('name', $key); - } - } - - if (isset($field['version'])) { - $fieldXml->addAttribute('version', $field['version']); - } - - if (isset($field['columnDefinition'])) { - $fieldXml->addAttribute('column-definition', $field['columnDefinition']); - } - - if (isset($field['nullable'])) { - $fieldXml->addAttribute('nullable', $field['nullable'] ? 'true' : 'false'); - } - } - } - - $orderMap = [ - ClassMetadataInfo::ONE_TO_ONE, - ClassMetadataInfo::ONE_TO_MANY, - ClassMetadataInfo::MANY_TO_ONE, - ClassMetadataInfo::MANY_TO_MANY, - ]; - - uasort($metadata->associationMappings, static function ($m1, $m2) use (&$orderMap) { - $a1 = array_search($m1['type'], $orderMap, true); - $a2 = array_search($m2['type'], $orderMap, true); - - return strcmp((string) $a1, (string) $a2); - }); - - foreach ($metadata->associationMappings as $associationMapping) { - $associationMappingXml = null; - if ($associationMapping['type'] === ClassMetadataInfo::ONE_TO_ONE) { - $associationMappingXml = $root->addChild('one-to-one'); - } elseif ($associationMapping['type'] === ClassMetadataInfo::MANY_TO_ONE) { - $associationMappingXml = $root->addChild('many-to-one'); - } elseif ($associationMapping['type'] === ClassMetadataInfo::ONE_TO_MANY) { - $associationMappingXml = $root->addChild('one-to-many'); - } elseif ($associationMapping['type'] === ClassMetadataInfo::MANY_TO_MANY) { - $associationMappingXml = $root->addChild('many-to-many'); - } - - $associationMappingXml->addAttribute('field', $associationMapping['fieldName']); - $associationMappingXml->addAttribute('target-entity', $associationMapping['targetEntity']); - - if (isset($associationMapping['mappedBy'])) { - $associationMappingXml->addAttribute('mapped-by', $associationMapping['mappedBy']); - } - - if (isset($associationMapping['inversedBy'])) { - $associationMappingXml->addAttribute('inversed-by', $associationMapping['inversedBy']); - } - - if (isset($associationMapping['indexBy'])) { - $associationMappingXml->addAttribute('index-by', $associationMapping['indexBy']); - } - - if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval'] !== false) { - $associationMappingXml->addAttribute('orphan-removal', 'true'); - } - - if (isset($associationMapping['fetch'])) { - $associationMappingXml->addAttribute('fetch', $this->_getFetchModeString($associationMapping['fetch'])); - } - - $cascade = []; - if ($associationMapping['isCascadeRemove']) { - $cascade[] = 'cascade-remove'; - } - - if ($associationMapping['isCascadePersist']) { - $cascade[] = 'cascade-persist'; - } - - if ($associationMapping['isCascadeRefresh']) { - $cascade[] = 'cascade-refresh'; - } - - if ($associationMapping['isCascadeMerge']) { - $cascade[] = 'cascade-merge'; - } - - if ($associationMapping['isCascadeDetach']) { - $cascade[] = 'cascade-detach'; - } - - if (count($cascade) === 5) { - $cascade = ['cascade-all']; - } - - if ($cascade) { - $cascadeXml = $associationMappingXml->addChild('cascade'); - - foreach ($cascade as $type) { - $cascadeXml->addChild($type); - } - } - - if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) { - $joinTableXml = $associationMappingXml->addChild('join-table'); - $joinTableXml->addAttribute('name', $associationMapping['joinTable']['name']); - $joinColumnsXml = $joinTableXml->addChild('join-columns'); - - foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) { - $joinColumnXml = $joinColumnsXml->addChild('join-column'); - $joinColumnXml->addAttribute('name', $joinColumn['name']); - $joinColumnXml->addAttribute('referenced-column-name', $joinColumn['referencedColumnName']); - - if (isset($joinColumn['onDelete'])) { - $joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']); - } - } - - $inverseJoinColumnsXml = $joinTableXml->addChild('inverse-join-columns'); - - foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) { - $inverseJoinColumnXml = $inverseJoinColumnsXml->addChild('join-column'); - $inverseJoinColumnXml->addAttribute('name', $inverseJoinColumn['name']); - $inverseJoinColumnXml->addAttribute('referenced-column-name', $inverseJoinColumn['referencedColumnName']); - - if (isset($inverseJoinColumn['onDelete'])) { - $inverseJoinColumnXml->addAttribute('on-delete', $inverseJoinColumn['onDelete']); - } - - if (isset($inverseJoinColumn['columnDefinition'])) { - $inverseJoinColumnXml->addAttribute('column-definition', $inverseJoinColumn['columnDefinition']); - } - - if (isset($inverseJoinColumn['nullable'])) { - $inverseJoinColumnXml->addAttribute('nullable', $inverseJoinColumn['nullable']); - } - - if (isset($inverseJoinColumn['orderBy'])) { - $inverseJoinColumnXml->addAttribute('order-by', $inverseJoinColumn['orderBy']); - } - } - } - - if (isset($associationMapping['joinColumns'])) { - $joinColumnsXml = $associationMappingXml->addChild('join-columns'); - - foreach ($associationMapping['joinColumns'] as $joinColumn) { - $joinColumnXml = $joinColumnsXml->addChild('join-column'); - $joinColumnXml->addAttribute('name', $joinColumn['name']); - $joinColumnXml->addAttribute('referenced-column-name', $joinColumn['referencedColumnName']); - - if (isset($joinColumn['onDelete'])) { - $joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']); - } - - if (isset($joinColumn['columnDefinition'])) { - $joinColumnXml->addAttribute('column-definition', $joinColumn['columnDefinition']); - } - - if (isset($joinColumn['nullable'])) { - $joinColumnXml->addAttribute('nullable', $joinColumn['nullable']); - } - } - } - - if (isset($associationMapping['orderBy'])) { - $orderByXml = $associationMappingXml->addChild('order-by'); - - foreach ($associationMapping['orderBy'] as $name => $direction) { - $orderByFieldXml = $orderByXml->addChild('order-by-field'); - $orderByFieldXml->addAttribute('name', $name); - $orderByFieldXml->addAttribute('direction', $direction); - } - } - } - - if (isset($metadata->lifecycleCallbacks) && count($metadata->lifecycleCallbacks) > 0) { - $lifecycleCallbacksXml = $root->addChild('lifecycle-callbacks'); - - foreach ($metadata->lifecycleCallbacks as $name => $methods) { - foreach ($methods as $method) { - $lifecycleCallbackXml = $lifecycleCallbacksXml->addChild('lifecycle-callback'); - $lifecycleCallbackXml->addAttribute('type', $name); - $lifecycleCallbackXml->addAttribute('method', $method); - } - } - } - - $this->processEntityListeners($metadata, $root); - - return $this->asXml($xml); - } - - /** - * Exports (nested) option elements. - * - * @param mixed[] $options - */ - private function exportTableOptions(SimpleXMLElement $parentXml, array $options): void - { - foreach ($options as $name => $option) { - $isArray = is_array($option); - $optionXml = $isArray - ? $parentXml->addChild('option') - : $parentXml->addChild('option', (string) $option); - - $optionXml->addAttribute('name', (string) $name); - - if ($isArray) { - $this->exportTableOptions($optionXml, $option); - } - } - } - - /** - * Export sequence information (if available/configured) into the current identifier XML node - */ - private function exportSequenceInformation(SimpleXMLElement $identifierXmlNode, ClassMetadataInfo $metadata): void - { - $sequenceDefinition = $metadata->sequenceGeneratorDefinition; - - if (! ($metadata->generatorType === ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE && $sequenceDefinition)) { - return; - } - - $sequenceGeneratorXml = $identifierXmlNode->addChild('sequence-generator'); - - $sequenceGeneratorXml->addAttribute('sequence-name', $sequenceDefinition['sequenceName']); - $sequenceGeneratorXml->addAttribute('allocation-size', $sequenceDefinition['allocationSize']); - $sequenceGeneratorXml->addAttribute('initial-value', $sequenceDefinition['initialValue']); - } - - private function asXml(SimpleXMLElement $simpleXml): string - { - $dom = new DOMDocument('1.0', 'UTF-8'); - $dom->loadXML($simpleXml->asXML()); - $dom->formatOutput = true; - - return $dom->saveXML(); - } - - private function processEntityListeners(ClassMetadataInfo $metadata, SimpleXMLElement $root): void - { - if (count($metadata->entityListeners) === 0) { - return; - } - - $entityListenersXml = $root->addChild('entity-listeners'); - $entityListenersXmlMap = []; - - $this->generateEntityListenerXml($metadata, $entityListenersXmlMap, $entityListenersXml); - } - - /** - * @param mixed[] $entityListenersXmlMap - */ - private function generateEntityListenerXml( - ClassMetadataInfo $metadata, - array $entityListenersXmlMap, - SimpleXMLElement $entityListenersXml - ): void { - foreach ($metadata->entityListeners as $event => $entityListenerConfig) { - foreach ($entityListenerConfig as $entityListener) { - $entityListenerXml = $this->addClassToMapIfExists( - $entityListenersXmlMap, - $entityListener, - $entityListenersXml - ); - - $entityListenerCallbackXml = $entityListenerXml->addChild('lifecycle-callback'); - $entityListenerCallbackXml->addAttribute('type', $event); - $entityListenerCallbackXml->addAttribute('method', $entityListener['method']); - } - } - } - - /** - * @param mixed[] $entityListenersXmlMap - * @param mixed[] $entityListener - */ - private function addClassToMapIfExists( - array $entityListenersXmlMap, - array $entityListener, - SimpleXMLElement $entityListenersXml - ): SimpleXMLElement { - if (isset($entityListenersXmlMap[$entityListener['class']])) { - return $entityListenersXmlMap[$entityListener['class']]; - } - - $entityListenerXml = $entityListenersXml->addChild('entity-listener'); - $entityListenerXml->addAttribute('class', $entityListener['class']); - $entityListenersXmlMap[$entityListener['class']] = $entityListenerXml; - - return $entityListenerXml; - } -} diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php deleted file mode 100644 index 22ceeb8e1fd..00000000000 --- a/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php +++ /dev/null @@ -1,271 +0,0 @@ -isMappedSuperclass) { - $array['type'] = 'mappedSuperclass'; - } else { - $array['type'] = 'entity'; - } - - $metadataTable = $metadata->table ?? ['name' => null]; - - $array['table'] = $metadataTable['name']; - - if (isset($metadataTable['schema'])) { - $array['schema'] = $metadataTable['schema']; - } - - $inheritanceType = $metadata->inheritanceType; - - if ($inheritanceType !== ClassMetadataInfo::INHERITANCE_TYPE_NONE) { - $array['inheritanceType'] = $this->_getInheritanceTypeString($inheritanceType); - } - - $column = $metadata->discriminatorColumn; - if ($column) { - $array['discriminatorColumn'] = $column; - } - - $map = $metadata->discriminatorMap; - if ($map) { - $array['discriminatorMap'] = $map; - } - - if ($metadata->changeTrackingPolicy !== ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT) { - $array['changeTrackingPolicy'] = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy); - } - - if (isset($metadataTable['indexes'])) { - $array['indexes'] = $metadataTable['indexes']; - } - - if ($metadata->customRepositoryClassName) { - $array['repositoryClass'] = $metadata->customRepositoryClassName; - } - - if (isset($metadataTable['uniqueConstraints'])) { - $array['uniqueConstraints'] = $metadataTable['uniqueConstraints']; - } - - if (isset($metadataTable['options'])) { - $array['options'] = $metadataTable['options']; - } - - $fieldMappings = $metadata->fieldMappings; - - $ids = []; - foreach ($fieldMappings as $name => $fieldMapping) { - $fieldMapping['column'] = $fieldMapping['columnName']; - - unset($fieldMapping['columnName'], $fieldMapping['fieldName']); - - if ($fieldMapping['column'] === $name) { - unset($fieldMapping['column']); - } - - if (isset($fieldMapping['id']) && $fieldMapping['id']) { - $ids[$name] = $fieldMapping; - unset($fieldMappings[$name]); - continue; - } - - $fieldMappings[$name] = $fieldMapping; - } - - if (! $metadata->isIdentifierComposite) { - $idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType); - if ($idGeneratorType) { - $ids[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $idGeneratorType; - } - } - - $array['id'] = $ids; - - if ($fieldMappings) { - $array['fields'] = $fieldMappings; - } - - foreach ($metadata->associationMappings as $name => $associationMapping) { - $cascade = []; - - if ($associationMapping['isCascadeRemove']) { - $cascade[] = 'remove'; - } - - if ($associationMapping['isCascadePersist']) { - $cascade[] = 'persist'; - } - - if ($associationMapping['isCascadeRefresh']) { - $cascade[] = 'refresh'; - } - - if ($associationMapping['isCascadeMerge']) { - $cascade[] = 'merge'; - } - - if ($associationMapping['isCascadeDetach']) { - $cascade[] = 'detach'; - } - - if (count($cascade) === 5) { - $cascade = ['all']; - } - - $associationMappingArray = [ - 'targetEntity' => $associationMapping['targetEntity'], - 'cascade' => $cascade, - ]; - - if (isset($associationMapping['fetch'])) { - $associationMappingArray['fetch'] = $this->_getFetchModeString($associationMapping['fetch']); - } - - if (isset($associationMapping['id']) && $associationMapping['id'] === true) { - $array['id'][$name]['associationKey'] = true; - } - - if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { - $joinColumns = $associationMapping['isOwningSide'] ? $associationMapping['joinColumns'] : []; - $newJoinColumns = []; - - foreach ($joinColumns as $joinColumn) { - $newJoinColumns[$joinColumn['name']]['referencedColumnName'] = $joinColumn['referencedColumnName']; - - if (isset($joinColumn['onDelete'])) { - $newJoinColumns[$joinColumn['name']]['onDelete'] = $joinColumn['onDelete']; - } - } - - $oneToOneMappingArray = [ - 'mappedBy' => $associationMapping['mappedBy'], - 'inversedBy' => $associationMapping['inversedBy'], - 'joinColumns' => $newJoinColumns, - 'orphanRemoval' => $associationMapping['orphanRemoval'], - ]; - - $associationMappingArray = array_merge($associationMappingArray, $oneToOneMappingArray); - - if ($associationMapping['type'] & ClassMetadataInfo::ONE_TO_ONE) { - $array['oneToOne'][$name] = $associationMappingArray; - } else { - $array['manyToOne'][$name] = $associationMappingArray; - } - } elseif ($associationMapping['type'] === ClassMetadataInfo::ONE_TO_MANY) { - $oneToManyMappingArray = [ - 'mappedBy' => $associationMapping['mappedBy'], - 'inversedBy' => $associationMapping['inversedBy'], - 'orphanRemoval' => $associationMapping['orphanRemoval'], - 'orderBy' => $associationMapping['orderBy'] ?? null, - ]; - - $associationMappingArray = array_merge($associationMappingArray, $oneToManyMappingArray); - $array['oneToMany'][$name] = $associationMappingArray; - } elseif ($associationMapping['type'] === ClassMetadataInfo::MANY_TO_MANY) { - $manyToManyMappingArray = [ - 'mappedBy' => $associationMapping['mappedBy'], - 'inversedBy' => $associationMapping['inversedBy'], - 'joinTable' => $associationMapping['joinTable'] ?? null, - 'orderBy' => $associationMapping['orderBy'] ?? null, - ]; - - $associationMappingArray = array_merge($associationMappingArray, $manyToManyMappingArray); - $array['manyToMany'][$name] = $associationMappingArray; - } - } - - if (isset($metadata->lifecycleCallbacks)) { - $array['lifecycleCallbacks'] = $metadata->lifecycleCallbacks; - } - - $array = $this->processEntityListeners($metadata, $array); - - return $this->yamlDump([$metadata->name => $array], 10); - } - - /** - * Dumps a PHP array to a YAML string. - * - * The yamlDump method, when supplied with an array, will do its best - * to convert the array into friendly YAML. - * - * @param mixed[] $array PHP array - * @param int $inline [optional] The level where you switch to inline YAML - * - * @return string A YAML string representing the original PHP array - */ - protected function yamlDump($array, $inline = 2) - { - return Yaml::dump($array, $inline); - } - - /** - * @psalm-param array $array - * - * @psalm-return array&array{entityListeners: array>} - */ - private function processEntityListeners(ClassMetadataInfo $metadata, array $array): array - { - if (count($metadata->entityListeners) === 0) { - return $array; - } - - $array['entityListeners'] = []; - - foreach ($metadata->entityListeners as $event => $entityListenerConfig) { - $array = $this->processEntityListenerConfig($array, $entityListenerConfig, $event); - } - - return $array; - } - - /** - * @psalm-param array{entityListeners: array>} $array - * @psalm-param list $entityListenerConfig - * - * @psalm-return array{entityListeners: array>} - */ - private function processEntityListenerConfig( - array $array, - array $entityListenerConfig, - string $event - ): array { - foreach ($entityListenerConfig as $entityListener) { - if (! isset($array['entityListeners'][$entityListener['class']])) { - $array['entityListeners'][$entityListener['class']] = []; - } - - $array['entityListeners'][$entityListener['class']][$event] = [$entityListener['method']]; - } - - return $array; - } -} diff --git a/lib/Doctrine/ORM/Tools/Export/ExportException.php b/lib/Doctrine/ORM/Tools/Export/ExportException.php deleted file mode 100644 index d5af4568a18..00000000000 --- a/lib/Doctrine/ORM/Tools/Export/ExportException.php +++ /dev/null @@ -1,52 +0,0 @@ -, array\\ given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommand.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$name\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php - - - - message: "#^Parameter \\#1 \\$metadata of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:setMetadata\\(\\) expects array\\, array\\ given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$name\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php - - - - message: "#^Parameter \\#1 \\$metadatas of method Doctrine\\\\ORM\\\\Tools\\\\EntityGenerator\\:\\:generate\\(\\) expects array\\, array\\ given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$name\\.$#" count: 1 path: lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$customRepositoryClassName\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/GenerateRepositoriesCommand.php - - message: "#^Parameter \\#1 \\$entityListeners of method Doctrine\\\\ORM\\\\Tools\\\\Console\\\\Command\\\\MappingDescribeCommand\\:\\:formatEntityListeners\\(\\) expects array\\, array\\\\>\\> given\\.$#" count: 1 path: lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php - - - message: "#^If condition is always true\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Offset 'allocationSize' on array\\{sequenceName\\: string, allocationSize\\: string, initialValue\\: string, quoted\\?\\: mixed\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Offset 'indexes' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Offset 'initialValue' on array\\{sequenceName\\: string, allocationSize\\: string, initialValue\\: string, quoted\\?\\: mixed\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Offset 'name' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Offset 'options' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Offset 'schema' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Offset 'sequenceName' on array\\{sequenceName\\: string, allocationSize\\: string, initialValue\\: string, quoted\\?\\: mixed\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Offset 'uniqueConstraints' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\\\:\\:\\$lifecycleCallbacks \\(array\\\\>\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/EntityGenerator.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getChangeTrackingPolicyString\\(\\) should return string but return statement is missing\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getFetchModeString\\(\\) should return string but return statement is missing\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) should return string but return statement is missing\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getInheritanceTypeString\\(\\) should return string but return statement is missing\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php - - - - message: "#^If condition is always true\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php - - - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php - - - - message: "#^Offset 'indexes' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Offset 'name' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Offset 'options' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Offset 'schema' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Offset 'uniqueConstraints' on array\\{name\\: string, schema\\: string, indexes\\: array, uniqueConstraints\\: array, options\\: array\\, quoted\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Offset 'version' on array\\{type\\: string, fieldName\\: string, columnName\\?\\: string, length\\?\\: int, id\\?\\: bool, nullable\\?\\: bool, columnDefinition\\?\\: string, precision\\?\\: int, \\.\\.\\.\\} in isset\\(\\) does not exist\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Parameter \\#1 \\$policy of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getChangeTrackingPolicyString\\(\\) expects 1\\|2\\|3, int given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" - count: 2 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\\\:\\:\\$lifecycleCallbacks \\(array\\\\>\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Right side of && is always true\\.$#" - count: 2 - path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php - - - - message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\\\:\\:\\$lifecycleCallbacks \\(array\\\\>\\) in isset\\(\\) is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php - - - - message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\\\:\\:\\$table \\(array\\\\) on left side of \\?\\? is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php - - message: "#^Return type \\(void\\) of method Doctrine\\\\ORM\\\\Tools\\\\Pagination\\\\CountWalker\\:\\:walkSelectStatement\\(\\) should be compatible with return type \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\:\\:walkSelectStatement\\(\\)$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d3a21419217..7f7ff6ef957 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3245,61 +3245,11 @@ $cacheDriver - - - $metadata - - - ClassMetadataExporter - ClassMetadataExporter - ClassMetadataExporter|null - EntityGenerator - EntityGenerator - EntityGenerator|null - new ClassMetadataExporter() - new EntityGenerator() - private $entityGenerator = null; - private $metadataExporter = null; - - - configure - - - - - $metadata - - - AbstractExporter - new ClassMetadataExporter() - new EntityGenerator() - - - configure - - - $class->name - - configure - - - $metadatas - - - new EntityGenerator() - - - configure - - - $metadata->name - - getProxyDir @@ -3315,17 +3265,6 @@ $em->getConfiguration()->getProxyDir() - - - new EntityRepositoryGenerator() - - - configure - - - $metadata->customRepositoryClassName - - configure @@ -3400,189 +3339,6 @@ $entity - - - $this->getClassToExtend() - $this->getClassToExtend() ?: $metadata->name - $this->getClassToExtend() ?: $metadata->name - array_map('strlen', $paramTypes) - - - class_exists($metadata->name) - - - public function setFieldVisibility($visibility) - - - $visibility - - - $metadata->inheritanceType - $metadata->inheritanceType - $metadata->inheritanceType - - - setFieldVisibility - - - $last - strrpos($metadata->name, '\\') - - - $variableType - - - $classToExtend - - - (array) $metadata->table['options'] - (bool) $embeddablesImmutable - - - $metadata->sequenceGeneratorDefinition - $metadata->sequenceGeneratorDefinition - isset($metadata->lifecycleCallbacks) - - - - - $fullClassName - $fullClassName - $fullClassName - - - strrpos($fullClassName, '\\') - - - $repositoryName - - - - - Driver\AbstractExporter - Driver\AnnotationExporter::class - Driver\PhpExporter::class - Driver\XmlExporter::class - Driver\YamlExporter::class - Driver\YamlExporter::class - ExportException::invalidExporterDriverType($type) - - - new $class($dest) - - - new $class($dest) - - - Driver\AbstractExporter - - - - - ExportException::attemptOverwriteExistingFile($path) - - - string - - - $this->_outputDir - - - - - AbstractExporter - EntityGenerator - EntityGenerator|null - - - $_extension - - - - - $metadata->changeTrackingPolicy - $metadata->generatorType - - - AbstractExporter - - - $metadata->inheritanceType - - - $_extension - - - $metadata->table - $metadata->table - - - - - $metadata->changeTrackingPolicy - $metadata->generatorType - $metadata->generatorType - - - AbstractExporter - - - $m1 - $m2 - - - $metadata->inheritanceType - - - $_extension - - - $simpleXml->asXML() - - - addAttribute - - - $field['associationKey'] - isset($field['associationKey']) && $field['associationKey'] - - - $sequenceDefinition - isset($metadata->lifecycleCallbacks) - - - - - $array - $metadata->changeTrackingPolicy - $metadata->generatorType - - - AbstractExporter - - - ['name' => null] - - - $array - - - $metadata->inheritanceType - - - array<string, mixed>&array{entityListeners: array<class-string, array<string, array{string}>>} - - - $_extension - - - $fieldMapping['columnName'] - - - $metadata->table - isset($metadata->lifecycleCallbacks) - - $query diff --git a/psalm.xml b/psalm.xml index cdefb1165b4..bcc5f1f6ff2 100644 --- a/psalm.xml +++ b/psalm.xml @@ -21,11 +21,7 @@ - - - - diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php deleted file mode 100644 index 599e2162c71..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3711Test.php +++ /dev/null @@ -1,29 +0,0 @@ -loadDriver(); - - $em = $this->getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($yamlDriver); - $factory = new ClassMetadataFactory(); - $factory->setEntityManager($em); - - $entityA = new ClassMetadata(DDC3711EntityA::class); - $entityA = $factory->getMetadataFor(DDC3711EntityA::class); - - self::assertEquals(['link_a_id1' => 'id1', 'link_a_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToSourceKeyColumns']); - self::assertEquals(['link_b_id1' => 'id1', 'link_b_id2' => 'id2'], $entityA->associationMappings['entityB']['relationToTargetKeyColumns']); - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php deleted file mode 100644 index 5e2b96a6543..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php +++ /dev/null @@ -1,29 +0,0 @@ -createMock(EntityGenerator::class); - $command = new ConvertDoctrine1SchemaCommand(); - $command->setEntityGenerator($entityGenerator); - - $output = $this->createMock(OutputInterface::class); - $output->expects(self::once()) - ->method('writeln') - ->with(self::equalTo('No Metadata Classes to process.')); - - $command->convertDoctrine1Schema([], sys_get_temp_dir(), 'annotation', 4, null, $output); - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/GenerateRepositoriesCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/GenerateRepositoriesCommandTest.php deleted file mode 100644 index 961f7702236..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/GenerateRepositoriesCommandTest.php +++ /dev/null @@ -1,181 +0,0 @@ -path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('doctrine_'); - - mkdir($this->path); - - $metadataDriver = $this->_em->getConfiguration()->getMetadataDriverImpl(); - $metadataDriver->addPaths([__DIR__ . '/../../../../Models/DDC3231/']); - - $this->application = new Application(); - $this->application->add(new GenerateRepositoriesCommand(new SingleManagerProvider($this->_em))); - } - - public function tearDown(): void - { - $dirs = []; - - $ri = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path)); - foreach ($ri as $file) { - assert($file instanceof SplFileInfo); - if ($file->isFile()) { - unlink($file->getPathname()); - } elseif ($file->getBasename() === '.') { - $dirs[] = $file->getRealPath(); - } - } - - arsort($dirs); - - foreach ($dirs as $dir) { - rmdir($dir); - } - - parent::tearDown(); - } - - public function testGenerateRepositories(): void - { - $this->generateRepositories('DDC3231User1'); - - $cname = 'Doctrine\Tests\Models\DDC3231\DDC3231User1Repository'; - $fname = str_replace('\\', DIRECTORY_SEPARATOR, $cname) . '.php'; - - self::assertFileExists($this->path . DIRECTORY_SEPARATOR . $fname); - self::assertFileExists($this->path . DIRECTORY_SEPARATOR . 'DDC3231User1NoNamespaceRepository.php'); - - require $this->path . DIRECTORY_SEPARATOR . $fname; - require $this->path . DIRECTORY_SEPARATOR . 'DDC3231User1NoNamespaceRepository.php'; - - self::assertTrue(class_exists($cname)); - self::assertTrue(class_exists('DDC3231User1NoNamespaceRepository')); - - $repo1 = new ReflectionClass($cname); - $repo2 = new ReflectionClass('DDC3231User1NoNamespaceRepository'); - - self::assertSame(EntityRepository::class, $repo1->getParentClass()->getName()); - self::assertSame(EntityRepository::class, $repo2->getParentClass()->getName()); - } - - public function testGenerateRepositoriesCustomDefaultRepository(): void - { - $this->generateRepositories('DDC3231User2', DDC3231EntityRepository::class); - - $cname = 'Doctrine\Tests\Models\DDC3231\DDC3231User2Repository'; - $fname = str_replace('\\', DIRECTORY_SEPARATOR, $cname) . '.php'; - - self::assertFileExists($this->path . DIRECTORY_SEPARATOR . $fname); - self::assertFileExists($this->path . DIRECTORY_SEPARATOR . 'DDC3231User2NoNamespaceRepository.php'); - - require $this->path . DIRECTORY_SEPARATOR . $fname; - require $this->path . DIRECTORY_SEPARATOR . 'DDC3231User2NoNamespaceRepository.php'; - - self::assertTrue(class_exists($cname)); - self::assertTrue(class_exists('DDC3231User2NoNamespaceRepository')); - - $repo1 = new ReflectionClass($cname); - $repo2 = new ReflectionClass('DDC3231User2NoNamespaceRepository'); - - self::assertSame(DDC3231EntityRepository::class, $repo1->getParentClass()->getName()); - self::assertSame(DDC3231EntityRepository::class, $repo2->getParentClass()->getName()); - } - - private function generateRepositories(string $filter, ?string $defaultRepository = null): void - { - if ($defaultRepository) { - $this->_em->getConfiguration()->setDefaultRepositoryClassName($defaultRepository); - } - - $command = $this->application->find('orm:generate-repositories'); - $tester = new CommandTester($command); - - $tester->execute( - [ - 'command' => $command->getName(), - 'dest-path' => $this->path, - '--filter' => $filter, - ] - ); - } - - public function testNoMetadataClassesToProcess(): void - { - $configuration = $this->createMock(Configuration::class); - $metadataFactory = $this->createMock(ClassMetadataFactory::class); - $em = $this->createMock(EntityManagerInterface::class); - - $configuration->method('getDefaultRepositoryClassName') - ->willReturn('fooRepository'); - - $metadataFactory->method('getAllMetadata') - ->willReturn([]); - - $em->method('getMetadataFactory') - ->willReturn($metadataFactory); - - $em->method('getConfiguration') - ->willReturn($configuration); - - $application = new Application(); - $application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($em)])); - $application->add(new GenerateRepositoriesCommand()); - - $command = $application->find('orm:generate-repositories'); - $tester = new CommandTester($command); - - $tester->execute( - [ - 'command' => $command->getName(), - 'dest-path' => $this->path, - ] - ); - - self::assertStringContainsString('Command orm:generate-repositories is deprecated and will be removed in Doctrine ORM 3.0.', $tester->getDisplay()); - self::assertStringContainsString('[OK] No Metadata Classes to process.', $tester->getDisplay()); - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php index 9a0984b9b65..e6fa9df579f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php @@ -38,17 +38,9 @@ public function testCreateApplicationShouldReturnAnApplicationWithTheCorrectComm self::assertTrue($app->has('orm:clear-cache:metadata')); self::assertTrue($app->has('orm:clear-cache:query')); self::assertTrue($app->has('orm:clear-cache:result')); - self::assertTrue($app->has('orm:convert-d1-schema')); - self::assertTrue($app->has('orm:convert-mapping')); - self::assertTrue($app->has('orm:convert:d1-schema')); - self::assertTrue($app->has('orm:convert:mapping')); self::assertTrue($app->has('orm:ensure-production-settings')); - self::assertTrue($app->has('orm:generate-entities')); self::assertTrue($app->has('orm:generate-proxies')); - self::assertTrue($app->has('orm:generate-repositories')); - self::assertTrue($app->has('orm:generate:entities')); self::assertTrue($app->has('orm:generate:proxies')); - self::assertTrue($app->has('orm:generate:repositories')); self::assertTrue($app->has('orm:info')); self::assertTrue($app->has('orm:mapping:describe')); self::assertTrue($app->has('orm:run-dql')); diff --git a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php deleted file mode 100644 index 41a44b651af..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php +++ /dev/null @@ -1,91 +0,0 @@ -setProxyDir(__DIR__ . '/../../Proxies'); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $eventManager = new EventManager(); - $conn = new ConnectionMock([], $driverMock, $config, $eventManager); - $config->setMetadataDriverImpl($metadataDriver); - - return EntityManagerMock::create($conn, $config, $eventManager); - } - - public function testTest(): void - { - if (! class_exists('Symfony\Component\Yaml\Yaml', true)) { - self::markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); - } - - $cme = new ClassMetadataExporter(); - $converter = new ConvertDoctrine1Schema(__DIR__ . '/doctrine1schema'); - - $exporter = $cme->getExporter('yml', __DIR__ . '/convert'); - $exporter->setOverwriteExistingFiles(true); - $exporter->setMetadata($converter->getMetadata()); - $exporter->export(); - - self::assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml')); - self::assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml')); - - $metadataDriver = new YamlDriver(__DIR__ . '/convert'); - $em = $this->createEntityManager($metadataDriver); - $cmf = new DisconnectedClassMetadataFactory(); - $cmf->setEntityManager($em); - $metadata = $cmf->getAllMetadata(); - $profileClass = $cmf->getMetadataFor('Profile'); - $userClass = $cmf->getMetadataFor('User'); - - self::assertEquals(2, count($metadata)); - self::assertEquals('Profile', $profileClass->name); - self::assertEquals('User', $userClass->name); - self::assertEquals(4, count($profileClass->fieldMappings)); - self::assertEquals(5, count($userClass->fieldMappings)); - self::assertEquals('text', $userClass->fieldMappings['clob']['type']); - self::assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']); - self::assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']); - - self::assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']); - self::assertEquals('User', $profileClass->associationMappings['User']['targetEntity']); - - self::assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]); - } - - public function tearDown(): void - { - @unlink(__DIR__ . '/convert/User.dcm.yml'); - @unlink(__DIR__ . '/convert/Profile.dcm.yml'); - @rmdir(__DIR__ . '/convert'); - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php deleted file mode 100644 index 23353fec799..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ /dev/null @@ -1,1327 +0,0 @@ -namespace = uniqid('doctrine_'); - $this->tmpDir = sys_get_temp_dir(); - mkdir($this->tmpDir . DIRECTORY_SEPARATOR . $this->namespace); - $this->generator = new EntityGenerator(); - $this->generator->setGenerateAnnotations(true); - $this->generator->setGenerateStubMethods(true); - $this->generator->setRegenerateEntityIfExists(false); - $this->generator->setUpdateEntityIfExists(true); - $this->generator->setFieldVisibility(EntityGenerator::FIELD_VISIBLE_PROTECTED); - } - - public function tearDown(): void - { - $ri = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->tmpDir . '/' . $this->namespace)); - foreach ($ri as $file) { - assert($file instanceof SplFileInfo); - if ($file->isFile()) { - unlink($file->getPathname()); - } - } - - rmdir($this->tmpDir . '/' . $this->namespace); - } - - /** - * @param ClassMetadataInfo[] $embeddedClasses - */ - public function generateBookEntityFixture(array $embeddedClasses = []): ClassMetadataInfo - { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityGeneratorBook'); - $metadata->namespace = $this->namespace; - $metadata->customRepositoryClassName = $this->namespace . '\EntityGeneratorBookRepository'; - - $metadata->table['name'] = 'book'; - $metadata->table['uniqueConstraints']['name_uniq'] = ['columns' => ['name']]; - $metadata->table['indexes']['status_idx'] = ['columns' => ['status']]; - $metadata->mapField(['fieldName' => 'name', 'type' => 'string']); - $metadata->mapField(['fieldName' => 'status', 'type' => 'string', 'options' => ['default' => 'published']]); - $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); - $metadata->mapOneToOne( - ['fieldName' => 'author', 'targetEntity' => EntityGeneratorAuthor::class, 'mappedBy' => 'book'] - ); - $joinColumns = [ - ['name' => 'author_id', 'referencedColumnName' => 'id'], - ]; - $metadata->mapManyToMany( - [ - 'fieldName' => 'comments', - 'targetEntity' => EntityGeneratorComment::class, - 'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY, - 'joinTable' => [ - 'name' => 'book_comment', - 'joinColumns' => [['name' => 'book_id', 'referencedColumnName' => 'id']], - 'inverseJoinColumns' => [['name' => 'comment_id', 'referencedColumnName' => 'id']], - ], - ] - ); - $metadata->addLifecycleCallback('loading', 'postLoad'); - $metadata->addLifecycleCallback('willBeRemoved', 'preRemove'); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - - foreach ($embeddedClasses as $fieldName => $embeddedClass) { - $this->mapNestedEmbedded($fieldName, $metadata, $embeddedClass); - $this->mapEmbedded($fieldName, $metadata, $embeddedClass); - } - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - return $metadata; - } - - private function generateEntityTypeFixture(array $field): ClassMetadataInfo - { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityType'); - $metadata->namespace = $this->namespace; - - $metadata->table['name'] = 'entity_type'; - $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - - $name = $field['fieldName']; - $type = $field['dbType']; - $metadata->mapField(['fieldName' => $name, 'type' => $type]); - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - return $metadata; - } - - private function generateIsbnEmbeddableFixture(array $embeddedClasses = [], $columnPrefix = null): ClassMetadataInfo - { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityGeneratorIsbn'); - $metadata->namespace = $this->namespace; - $metadata->isEmbeddedClass = true; - $metadata->mapField(['fieldName' => 'prefix', 'type' => 'integer']); - $metadata->mapField(['fieldName' => 'groupNumber', 'type' => 'integer']); - $metadata->mapField(['fieldName' => 'publisherNumber', 'type' => 'integer']); - $metadata->mapField(['fieldName' => 'titleNumber', 'type' => 'integer']); - $metadata->mapField(['fieldName' => 'checkDigit', 'type' => 'integer']); - - foreach ($embeddedClasses as $fieldName => $embeddedClass) { - $this->mapEmbedded($fieldName, $metadata, $embeddedClass, $columnPrefix); - } - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - return $metadata; - } - - private function generateTestEmbeddableFixture(): ClassMetadataInfo - { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityGeneratorTestEmbeddable'); - $metadata->namespace = $this->namespace; - $metadata->isEmbeddedClass = true; - $metadata->mapField(['fieldName' => 'field1', 'type' => 'integer']); - $metadata->mapField(['fieldName' => 'field2', 'type' => 'integer', 'nullable' => true]); - $metadata->mapField(['fieldName' => 'field3', 'type' => 'datetime']); - $metadata->mapField(['fieldName' => 'field4', 'type' => 'datetime', 'nullable' => true]); - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - return $metadata; - } - - /** - * @param string|bool $columnPrefix - */ - private function mapEmbedded( - string $fieldName, - ClassMetadataInfo $classMetadata, - ClassMetadataInfo $embeddableMetadata, - $columnPrefix = false - ): void { - $classMetadata->mapEmbedded( - ['fieldName' => $fieldName, 'class' => $embeddableMetadata->name, 'columnPrefix' => $columnPrefix] - ); - } - - private function mapNestedEmbedded( - string $fieldName, - ClassMetadataInfo $classMetadata, - ClassMetadataInfo $embeddableMetadata - ): void { - foreach ($embeddableMetadata->embeddedClasses as $property => $embeddableClass) { - $classMetadata->mapEmbedded( - [ - 'fieldName' => $fieldName . '.' . $property, - 'class' => $embeddableClass['class'], - 'columnPrefix' => $embeddableClass['columnPrefix'], - 'declaredField' => $embeddableClass['declaredField'] - ? $fieldName . '.' . $embeddableClass['declaredField'] - : $fieldName, - 'originalField' => $embeddableClass['originalField'] ?: $property, - ] - ); - } - } - - private function loadEntityClass(ClassMetadataInfo $metadata): void - { - $className = basename(str_replace('\\', '/', $metadata->name)); - $path = $this->tmpDir . '/' . $this->namespace . '/' . $className . '.php'; - - self::assertFileExists($path); - - require_once $path; - } - - /** - * @return mixed An instance of the given metadata's class. - */ - public function newInstance(ClassMetadataInfo $metadata) - { - $this->loadEntityClass($metadata); - - return new $metadata->name(); - } - - /** - * @group GH-6314 - */ - public function testEmbeddedEntityWithNamedColumnPrefix(): void - { - $columnPrefix = 'GH6314Prefix_'; - $testMetadata = $this->generateTestEmbeddableFixture(); - $isbnMetadata = $this->generateIsbnEmbeddableFixture(['testEmbedded' => $testMetadata], $columnPrefix); - $isbnEntity = $this->newInstance($isbnMetadata); - $refClass = new ReflectionClass($isbnEntity); - self::assertTrue($refClass->hasProperty('testEmbedded')); - - $docComment = $refClass->getProperty('testEmbedded')->getDocComment(); - $needle = sprintf('@ORM\Embedded(class="%s", columnPrefix="%s")', $testMetadata->name, $columnPrefix); - self::assertStringContainsString($needle, $docComment); - } - - /** - * @group GH-6314 - */ - public function testEmbeddedEntityWithoutColumnPrefix(): void - { - $testMetadata = $this->generateTestEmbeddableFixture(); - $isbnMetadata = $this->generateIsbnEmbeddableFixture(['testEmbedded' => $testMetadata], false); - $isbnEntity = $this->newInstance($isbnMetadata); - $refClass = new ReflectionClass($isbnEntity); - self::assertTrue($refClass->hasProperty('testEmbedded')); - - $docComment = $refClass->getProperty('testEmbedded')->getDocComment(); - $needle = sprintf('@ORM\Embedded(class="%s", columnPrefix=false)', $testMetadata->name); - self::assertStringContainsString($needle, $docComment); - } - - public function testGeneratedEntityClass(): void - { - $testMetadata = $this->generateTestEmbeddableFixture(); - $isbnMetadata = $this->generateIsbnEmbeddableFixture(['test' => $testMetadata]); - $metadata = $this->generateBookEntityFixture(['isbn' => $isbnMetadata]); - - $book = $this->newInstance($metadata); - self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', '__construct'), 'EntityGeneratorBook::__construct() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getId'), 'EntityGeneratorBook::getId() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setName'), 'EntityGeneratorBook::setName() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getName'), 'EntityGeneratorBook::getName() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setStatus'), 'EntityGeneratorBook::setStatus() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getStatus'), 'EntityGeneratorBook::getStatus() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), 'EntityGeneratorBook::setAuthor() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), 'EntityGeneratorBook::getAuthor() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), 'EntityGeneratorBook::getComments() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addComment'), 'EntityGeneratorBook::addComment() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'removeComment'), 'EntityGeneratorBook::removeComment() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setIsbn'), 'EntityGeneratorBook::setIsbn() missing.'); - self::assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getIsbn'), 'EntityGeneratorBook::getIsbn() missing.'); - - $reflClass = new ReflectionClass($metadata->name); - - self::assertCount(6, $reflClass->getProperties()); - self::assertCount(15, $reflClass->getMethods()); - - self::assertEquals('published', $book->getStatus()); - - $book->setName('Jonathan H. Wage'); - self::assertEquals('Jonathan H. Wage', $book->getName()); - - $reflMethod = new ReflectionMethod($metadata->name, 'addComment'); - $addCommentParameters = $reflMethod->getParameters(); - self::assertEquals('comment', $addCommentParameters[0]->getName()); - - $reflMethod = new ReflectionMethod($metadata->name, 'removeComment'); - $removeCommentParameters = $reflMethod->getParameters(); - self::assertEquals('comment', $removeCommentParameters[0]->getName()); - - $author = new EntityGeneratorAuthor(); - $book->setAuthor($author); - self::assertEquals($author, $book->getAuthor()); - - $comment = new EntityGeneratorComment(); - self::assertInstanceOf($metadata->name, $book->addComment($comment)); - self::assertInstanceOf(ArrayCollection::class, $book->getComments()); - self::assertEquals(new ArrayCollection([$comment]), $book->getComments()); - self::assertIsBool($book->removeComment($comment)); - self::assertEquals(new ArrayCollection([]), $book->getComments()); - - $this->newInstance($isbnMetadata); - $isbn = new $isbnMetadata->name(); - - $book->setIsbn($isbn); - self::assertSame($isbn, $book->getIsbn()); - - $reflMethod = new ReflectionMethod($metadata->name, 'setIsbn'); - $reflParameters = $reflMethod->getParameters(); - self::assertEquals($isbnMetadata->name, $reflParameters[0]->getType()->getName()); - } - - public function testBooleanDefaultValue(): void - { - $metadata = $this->generateBookEntityFixture(['isbn' => $this->generateIsbnEmbeddableFixture()]); - - $metadata->mapField(['fieldName' => 'foo', 'type' => 'boolean', 'options' => ['default' => '1']]); - - $testEmbeddableMetadata = $this->generateTestEmbeddableFixture(); - $this->mapEmbedded('testEmbedded', $metadata, $testEmbeddableMetadata); - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); - - $book = $this->newInstance($metadata); - $reflClass = new ReflectionClass($metadata->name); - - self::assertTrue($book->getfoo()); - } - - public function testEntityUpdatingWorks(): void - { - $metadata = $this->generateBookEntityFixture(['isbn' => $this->generateIsbnEmbeddableFixture()]); - - $metadata->mapField(['fieldName' => 'test', 'type' => 'string']); - - $testEmbeddableMetadata = $this->generateTestEmbeddableFixture(); - $this->mapEmbedded('testEmbedded', $metadata, $testEmbeddableMetadata); - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); - - $book = $this->newInstance($metadata); - $reflClass = new ReflectionClass($metadata->name); - - self::assertTrue($reflClass->hasProperty('name'), "Regenerating keeps property 'name'."); - self::assertTrue($reflClass->hasProperty('status'), "Regenerating keeps property 'status'."); - self::assertTrue($reflClass->hasProperty('id'), "Regenerating keeps property 'id'."); - self::assertTrue($reflClass->hasProperty('isbn'), "Regenerating keeps property 'isbn'."); - - self::assertTrue($reflClass->hasProperty('test'), 'Check for property test failed.'); - self::assertTrue($reflClass->getProperty('test')->isProtected(), 'Check for protected property test failed.'); - self::assertTrue($reflClass->hasProperty('testEmbedded'), 'Check for property testEmbedded failed.'); - self::assertTrue($reflClass->getProperty('testEmbedded')->isProtected(), 'Check for protected property testEmbedded failed.'); - self::assertTrue($reflClass->hasMethod('getTest'), "Check for method 'getTest' failed."); - self::assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); - self::assertTrue($reflClass->hasMethod('setTest'), "Check for method 'setTest' failed."); - self::assertTrue($reflClass->getMethod('setTest')->isPublic(), "Check for public visibility of method 'setTest' failed."); - self::assertTrue($reflClass->hasMethod('getTestEmbedded'), "Check for method 'getTestEmbedded' failed."); - self::assertTrue( - $reflClass->getMethod('getTestEmbedded')->isPublic(), - "Check for public visibility of method 'getTestEmbedded' failed." - ); - self::assertTrue($reflClass->hasMethod('setTestEmbedded'), "Check for method 'setTestEmbedded' failed."); - self::assertTrue( - $reflClass->getMethod('setTestEmbedded')->isPublic(), - "Check for public visibility of method 'setTestEmbedded' failed." - ); - } - - /** - * @group DDC-3152 - */ - public function testDoesNotRegenerateExistingMethodsWithDifferentCase(): void - { - $metadata = $this->generateBookEntityFixture(['isbn' => $this->generateIsbnEmbeddableFixture()]); - - // Workaround to change existing fields case (just to simulate the use case) - $metadata->fieldMappings['status']['fieldName'] = 'STATUS'; - $metadata->embeddedClasses['ISBN'] = $metadata->embeddedClasses['isbn']; - unset($metadata->embeddedClasses['isbn']); - - // Should not throw a PHP fatal error - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/EntityGeneratorBook.php~'); - - $this->newInstance($metadata); - $reflClass = new ReflectionClass($metadata->name); - - self::assertTrue($reflClass->hasProperty('status')); - self::assertTrue($reflClass->hasProperty('STATUS')); - self::assertTrue($reflClass->hasProperty('isbn')); - self::assertTrue($reflClass->hasProperty('ISBN')); - self::assertTrue($reflClass->hasMethod('getStatus')); - self::assertTrue($reflClass->hasMethod('setStatus')); - self::assertTrue($reflClass->hasMethod('getIsbn')); - self::assertTrue($reflClass->hasMethod('setIsbn')); - } - - /** - * @group DDC-2121 - */ - public function testMethodDocBlockShouldStartWithBackSlash(): void - { - $embeddedMetadata = $this->generateIsbnEmbeddableFixture(); - $metadata = $this->generateBookEntityFixture(['isbn' => $embeddedMetadata]); - $book = $this->newInstance($metadata); - - $this->assertPhpDocVarType('\Doctrine\Common\Collections\Collection', new ReflectionProperty($book, 'comments')); - $this->assertPhpDocReturnType('\Doctrine\Common\Collections\Collection', new ReflectionMethod($book, 'getComments')); - $this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorComment', new ReflectionMethod($book, 'addComment')); - $this->assertPhpDocReturnType('EntityGeneratorBook', new ReflectionMethod($book, 'addComment')); - $this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorComment', new ReflectionMethod($book, 'removeComment')); - $this->assertPhpDocReturnType('boolean', new ReflectionMethod($book, 'removeComment')); - - $this->assertPhpDocVarType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new ReflectionProperty($book, 'author')); - $this->assertPhpDocReturnType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor|null', new ReflectionMethod($book, 'getAuthor')); - $this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor|null', new ReflectionMethod($book, 'setAuthor')); - - $expectedClassName = '\\' . $embeddedMetadata->name; - $this->assertPhpDocVarType($expectedClassName, new ReflectionProperty($book, 'isbn')); - $this->assertPhpDocReturnType($expectedClassName, new ReflectionMethod($book, 'getIsbn')); - $this->assertPhpDocParamType($expectedClassName, new ReflectionMethod($book, 'setIsbn')); - } - - public function testEntityExtendsStdClass(): void - { - $this->generator->setClassToExtend('stdClass'); - $metadata = $this->generateBookEntityFixture(); - - $book = $this->newInstance($metadata); - self::assertInstanceOf('stdClass', $book); - - $metadata = $this->generateIsbnEmbeddableFixture(); - $isbn = $this->newInstance($metadata); - self::assertInstanceOf('stdClass', $isbn); - } - - public function testLifecycleCallbacks(): void - { - $metadata = $this->generateBookEntityFixture(); - - $book = $this->newInstance($metadata); - $reflClass = new ReflectionClass($metadata->name); - - self::assertTrue($reflClass->hasMethod('loading'), 'Check for postLoad lifecycle callback.'); - self::assertTrue($reflClass->hasMethod('willBeRemoved'), 'Check for preRemove lifecycle callback.'); - } - - public function testLoadMetadata(): void - { - $embeddedMetadata = $this->generateIsbnEmbeddableFixture(); - $metadata = $this->generateBookEntityFixture(['isbn' => $embeddedMetadata]); - - $book = $this->newInstance($metadata); - - $reflectionService = new RuntimeReflectionService(); - - $cm = new ClassMetadataInfo($metadata->name); - $cm->initializeReflection($reflectionService); - - $driver = $this->createAnnotationDriver(); - $driver->loadMetadataForClass($cm->name, $cm); - - self::assertEquals($cm->columnNames, $metadata->columnNames); - self::assertEquals($cm->getTableName(), $metadata->getTableName()); - self::assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); - self::assertEquals($cm->identifier, $metadata->identifier); - self::assertEquals($cm->idGenerator, $metadata->idGenerator); - self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); - self::assertEquals($cm->embeddedClasses, $metadata->embeddedClasses); - self::assertEquals($cm->isEmbeddedClass, $metadata->isEmbeddedClass); - - self::assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $cm->associationMappings['comments']['fetch']); - - $isbn = $this->newInstance($embeddedMetadata); - - $cm = new ClassMetadataInfo($embeddedMetadata->name); - $cm->initializeReflection($reflectionService); - - $driver->loadMetadataForClass($cm->name, $cm); - - self::assertEquals($cm->columnNames, $embeddedMetadata->columnNames); - self::assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); - self::assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); - } - - public function testLoadPrefixedMetadata(): void - { - $this->generator->setAnnotationPrefix('ORM\\'); - $embeddedMetadata = $this->generateIsbnEmbeddableFixture(); - $metadata = $this->generateBookEntityFixture(['isbn' => $embeddedMetadata]); - - $reader = new AnnotationReader(); - $driver = new AnnotationDriver($reader, []); - - $book = $this->newInstance($metadata); - - $reflectionService = new RuntimeReflectionService(); - - $cm = new ClassMetadataInfo($metadata->name); - $cm->initializeReflection($reflectionService); - - $driver->loadMetadataForClass($cm->name, $cm); - - self::assertEquals($cm->columnNames, $metadata->columnNames); - self::assertEquals($cm->getTableName(), $metadata->getTableName()); - self::assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); - self::assertEquals($cm->identifier, $metadata->identifier); - self::assertEquals($cm->idGenerator, $metadata->idGenerator); - self::assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); - - $isbn = $this->newInstance($embeddedMetadata); - - $cm = new ClassMetadataInfo($embeddedMetadata->name); - $cm->initializeReflection($reflectionService); - - $driver->loadMetadataForClass($cm->name, $cm); - - self::assertEquals($cm->columnNames, $embeddedMetadata->columnNames); - self::assertEquals($cm->embeddedClasses, $embeddedMetadata->embeddedClasses); - self::assertEquals($cm->isEmbeddedClass, $embeddedMetadata->isEmbeddedClass); - } - - /** - * @group DDC-3272 - */ - public function testMappedSuperclassAnnotationGeneration(): void - { - $metadata = new ClassMetadataInfo($this->namespace . '\EntityGeneratorBook'); - $metadata->namespace = $this->namespace; - $metadata->isMappedSuperclass = true; - - $this->generator->setAnnotationPrefix('ORM\\'); - $this->generator->writeEntityClass($metadata, $this->tmpDir); - $this->newInstance($metadata); // force instantiation (causes autoloading to kick in) - - $driver = new AnnotationDriver(new AnnotationReader(), []); - $cm = new ClassMetadataInfo($metadata->name); - - $cm->initializeReflection(new RuntimeReflectionService()); - $driver->loadMetadataForClass($cm->name, $cm); - - self::assertTrue($cm->isMappedSuperclass); - } - - /** - * @dataProvider getParseTokensInEntityFileData - */ - public function testParseTokensInEntityFile($php, $classes): void - { - $r = new ReflectionObject($this->generator); - $m = $r->getMethod('parseTokensInEntityFile'); - $m->setAccessible(true); - - $p = $r->getProperty('staticReflection'); - $p->setAccessible(true); - - $ret = $m->invoke($this->generator, $php); - self::assertEquals($classes, array_keys($p->getValue($this->generator))); - } - - /** - * @group DDC-1784 - */ - public function testGenerateEntityWithSequenceGenerator(): void - { - $metadata = new ClassMetadataInfo($this->namespace . '\DDC1784Entity'); - $metadata->namespace = $this->namespace; - $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); - $metadata->setSequenceGeneratorDefinition( - [ - 'sequenceName' => 'DDC1784_ID_SEQ', - 'allocationSize' => 1, - 'initialValue' => 2, - ] - ); - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - $filename = $this->tmpDir . DIRECTORY_SEPARATOR - . $this->namespace . DIRECTORY_SEPARATOR . 'DDC1784Entity.php'; - - self::assertFileExists($filename); - require_once $filename; - - $reflection = new ReflectionProperty($metadata->name, 'id'); - $docComment = $reflection->getDocComment(); - - self::assertStringContainsString('@ORM\Id', $docComment); - self::assertStringContainsString('@ORM\Column(name="id", type="integer")', $docComment); - self::assertStringContainsString('@ORM\GeneratedValue(strategy="SEQUENCE")', $docComment); - self::assertStringContainsString( - '@ORM\SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', - $docComment - ); - } - - /** - * @group DDC-2079 - */ - public function testGenerateEntityWithMultipleInverseJoinColumns(): void - { - $metadata = new ClassMetadataInfo($this->namespace . '\DDC2079Entity'); - $metadata->namespace = $this->namespace; - $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); - $metadata->mapManyToMany( - [ - 'fieldName' => 'centroCustos', - 'targetEntity' => 'DDC2079CentroCusto', - 'joinTable' => [ - 'name' => 'unidade_centro_custo', - 'joinColumns' => [ - ['name' => 'idorcamento', 'referencedColumnName' => 'idorcamento'], - ['name' => 'idunidade', 'referencedColumnName' => 'idunidade'], - ], - 'inverseJoinColumns' => [ - ['name' => 'idcentrocusto', 'referencedColumnName' => 'idcentrocusto'], - ['name' => 'idpais', 'referencedColumnName' => 'idpais'], - ], - ], - ] - ); - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - $filename = $this->tmpDir . DIRECTORY_SEPARATOR - . $this->namespace . DIRECTORY_SEPARATOR . 'DDC2079Entity.php'; - - self::assertFileExists($filename); - require_once $filename; - - $property = new ReflectionProperty($metadata->name, 'centroCustos'); - $docComment = $property->getDocComment(); - - //joinColumns - self::assertStringContainsString( - '@ORM\JoinColumn(name="idorcamento", referencedColumnName="idorcamento"),', - $docComment - ); - self::assertStringContainsString( - '@ORM\JoinColumn(name="idunidade", referencedColumnName="idunidade")', - $docComment - ); - //inverseJoinColumns - self::assertStringContainsString( - '@ORM\JoinColumn(name="idcentrocusto", referencedColumnName="idcentrocusto"),', - $docComment - ); - self::assertStringContainsString( - '@ORM\JoinColumn(name="idpais", referencedColumnName="idpais")', - $docComment - ); - } - - /** - * @group DDC-2172 - */ - public function testGetInheritanceTypeString(): void - { - $reflection = new ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadataInfo'); - $method = new ReflectionMethod($this->generator, 'getInheritanceTypeString'); - $constants = $reflection->getConstants(); - $pattern = '/^INHERITANCE_TYPE_/'; - - $method->setAccessible(true); - - foreach ($constants as $name => $value) { - if (! preg_match($pattern, $name)) { - continue; - } - - $expected = preg_replace($pattern, '', $name); - $actual = $method->invoke($this->generator, $value); - - self::assertEquals($expected, $actual); - } - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid provided InheritanceType: INVALID'); - - $method->invoke($this->generator, 'INVALID'); - } - - /** - * @group DDC-2172 - */ - public function testGetChangeTrackingPolicyString(): void - { - $reflection = new ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata'); - $method = new ReflectionMethod($this->generator, 'getChangeTrackingPolicyString'); - $constants = $reflection->getConstants(); - $pattern = '/^CHANGETRACKING_/'; - - $method->setAccessible(true); - - foreach ($constants as $name => $value) { - if (! preg_match($pattern, $name)) { - continue; - } - - $expected = preg_replace($pattern, '', $name); - $actual = $method->invoke($this->generator, $value); - - self::assertEquals($expected, $actual); - } - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid provided ChangeTrackingPolicy: INVALID'); - - $method->invoke($this->generator, 'INVALID'); - } - - /** - * @group DDC-2172 - */ - public function testGetIdGeneratorTypeString(): void - { - $reflection = new ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadataInfo'); - $method = new ReflectionMethod($this->generator, 'getIdGeneratorTypeString'); - $constants = $reflection->getConstants(); - $pattern = '/^GENERATOR_TYPE_/'; - - $method->setAccessible(true); - - foreach ($constants as $name => $value) { - if (! preg_match($pattern, $name)) { - continue; - } - - $expected = preg_replace($pattern, '', $name); - $actual = $method->invoke($this->generator, $value); - - self::assertEquals($expected, $actual); - } - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid provided IdGeneratorType: INVALID'); - - $method->invoke($this->generator, 'INVALID'); - } - - /** - * @dataProvider getEntityTypeAliasDataProvider - * @group DDC-1694 - */ - public function testEntityTypeAlias(array $field): void - { - $metadata = $this->generateEntityTypeFixture($field); - $path = $this->tmpDir . '/' . $this->namespace . '/EntityType.php'; - - self::assertFileExists($path); - require_once $path; - - $entity = new $metadata->name(); - $reflClass = new ReflectionClass($metadata->name); - - $type = $field['phpType']; - $name = $field['fieldName']; - $value = $field['value']; - $getter = 'get' . ucfirst($name); - $setter = 'set' . ucfirst($name); - - $this->assertPhpDocVarType($type, $reflClass->getProperty($name)); - $this->assertPhpDocParamType($type, $reflClass->getMethod($setter)); - $this->assertPhpDocReturnType($type, $reflClass->getMethod($getter)); - - self::assertSame($entity, $entity->{$setter}($value)); - self::assertEquals($value, $entity->{$getter}()); - } - - /** - * @group DDC-2372 - */ - public function testTraitPropertiesAndMethodsAreNotDuplicated(): void - { - $cmf = new ClassMetadataFactory(); - $em = $this->getTestEntityManager(); - $cmf->setEntityManager($em); - - $user = new DDC2372User(); - $metadata = $cmf->getMetadataFor(get_class($user)); - $metadata->name = $this->namespace . '\DDC2372User'; - $metadata->namespace = $this->namespace; - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372User.php'); - require $this->tmpDir . '/' . $this->namespace . '/DDC2372User.php'; - - $reflClass = new ReflectionClass($metadata->name); - - self::assertFalse($reflClass->hasProperty('address')); - self::assertFalse($reflClass->hasMethod('setAddress')); - self::assertFalse($reflClass->hasMethod('getAddress')); - } - - /** - * @group DDC-2372 - */ - public function testTraitPropertiesAndMethodsAreNotDuplicatedInChildClasses(): void - { - $cmf = new ClassMetadataFactory(); - $em = $this->getTestEntityManager(); - $cmf->setEntityManager($em); - - $user = new DDC2372Admin(); - $metadata = $cmf->getMetadataFor(get_class($user)); - $metadata->name = $this->namespace . '\DDC2372Admin'; - $metadata->namespace = $this->namespace; - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - self::assertFileExists($this->tmpDir . '/' . $this->namespace . '/DDC2372Admin.php'); - require $this->tmpDir . '/' . $this->namespace . '/DDC2372Admin.php'; - - $reflClass = new ReflectionClass($metadata->name); - - self::assertFalse($reflClass->hasProperty('address')); - self::assertFalse($reflClass->hasMethod('setAddress')); - self::assertFalse($reflClass->hasMethod('getAddress')); - } - - /** - * @group DDC-1590 - */ - public function testMethodsAndPropertiesAreNotDuplicatedInChildClasses(): void - { - $cmf = new ClassMetadataFactory(); - $em = $this->getTestEntityManager(); - - $cmf->setEntityManager($em); - - $ns = $this->namespace; - $nsdir = $this->tmpDir . '/' . $ns; - - $content = str_replace( - 'namespace Doctrine\Tests\Models\DDC1590', - 'namespace ' . $ns, - file_get_contents(__DIR__ . '/../../Models/DDC1590/DDC1590User.php') - ); - - $fname = $nsdir . '/DDC1590User.php'; - file_put_contents($fname, $content); - require $fname; - - $metadata = $cmf->getMetadataFor($ns . '\DDC1590User'); - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - // class DDC1590User extends DDC1590Entity { ... } - $source = file_get_contents($fname); - - // class _DDC1590User extends DDC1590Entity { ... } - $source2 = str_replace('class DDC1590User', 'class _DDC1590User', $source); - $fname2 = $nsdir . '/_DDC1590User.php'; - file_put_contents($fname2, $source2); - require $fname2; - - // class __DDC1590User { ... } - $source3 = str_replace('class DDC1590User extends DDC1590Entity', 'class __DDC1590User', $source); - $fname3 = $nsdir . '/__DDC1590User.php'; - file_put_contents($fname3, $source3); - require $fname3; - - // class _DDC1590User extends DDC1590Entity { ... } - $rc2 = new ReflectionClass($ns . '\_DDC1590User'); - - self::assertTrue($rc2->hasProperty('name')); - self::assertTrue($rc2->hasProperty('id')); - self::assertTrue($rc2->hasProperty('createdAt')); - - self::assertTrue($rc2->hasMethod('getName')); - self::assertTrue($rc2->hasMethod('setName')); - self::assertTrue($rc2->hasMethod('getId')); - self::assertFalse($rc2->hasMethod('setId')); - self::assertTrue($rc2->hasMethod('getCreatedAt')); - self::assertTrue($rc2->hasMethod('setCreatedAt')); - - // class __DDC1590User { ... } - $rc3 = new ReflectionClass($ns . '\__DDC1590User'); - - self::assertTrue($rc3->hasProperty('name')); - self::assertFalse($rc3->hasProperty('id')); - self::assertFalse($rc3->hasProperty('createdAt')); - - self::assertTrue($rc3->hasMethod('getName')); - self::assertTrue($rc3->hasMethod('setName')); - self::assertFalse($rc3->hasMethod('getId')); - self::assertFalse($rc3->hasMethod('setId')); - self::assertFalse($rc3->hasMethod('getCreatedAt')); - self::assertFalse($rc3->hasMethod('setCreatedAt')); - } - - /** - * @group DDC-3304 - */ - public function testGeneratedMutableEmbeddablesClass(): void - { - $embeddedMetadata = $this->generateTestEmbeddableFixture(); - $metadata = $this->generateIsbnEmbeddableFixture(['test' => $embeddedMetadata]); - - $isbn = $this->newInstance($metadata); - - self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); - self::assertFalse(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct present.'); - self::assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); - self::assertTrue(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() missing.'); - self::assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); - self::assertTrue(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() missing.'); - self::assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); - self::assertTrue(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() missing.'); - self::assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); - self::assertTrue(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() missing.'); - self::assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); - self::assertTrue(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() missing.'); - self::assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); - self::assertTrue(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() missing.'); - - $isbn->setPrefix(978); - self::assertSame(978, $isbn->getPrefix()); - - $this->newInstance($embeddedMetadata); - $test = new $embeddedMetadata->name(); - - $isbn->setTest($test); - self::assertSame($test, $isbn->getTest()); - - $reflMethod = new ReflectionMethod($metadata->name, 'setTest'); - $reflParameters = $reflMethod->getParameters(); - self::assertEquals($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); - } - - /** - * @group DDC-3304 - */ - public function testGeneratedImmutableEmbeddablesClass(): void - { - $this->generator->setEmbeddablesImmutable(true); - $embeddedMetadata = $this->generateTestEmbeddableFixture(); - $metadata = $this->generateIsbnEmbeddableFixture(['test' => $embeddedMetadata]); - - $this->loadEntityClass($embeddedMetadata); - $this->loadEntityClass($metadata); - - self::assertTrue(class_exists($metadata->name), 'Class does not exist.'); - self::assertTrue(method_exists($metadata->name, '__construct'), 'EntityGeneratorIsbn::__construct missing.'); - self::assertTrue(method_exists($metadata->name, 'getPrefix'), 'EntityGeneratorIsbn::getPrefix() missing.'); - self::assertFalse(method_exists($metadata->name, 'setPrefix'), 'EntityGeneratorIsbn::setPrefix() present.'); - self::assertTrue(method_exists($metadata->name, 'getGroupNumber'), 'EntityGeneratorIsbn::getGroupNumber() missing.'); - self::assertFalse(method_exists($metadata->name, 'setGroupNumber'), 'EntityGeneratorIsbn::setGroupNumber() present.'); - self::assertTrue(method_exists($metadata->name, 'getPublisherNumber'), 'EntityGeneratorIsbn::getPublisherNumber() missing.'); - self::assertFalse(method_exists($metadata->name, 'setPublisherNumber'), 'EntityGeneratorIsbn::setPublisherNumber() present.'); - self::assertTrue(method_exists($metadata->name, 'getTitleNumber'), 'EntityGeneratorIsbn::getTitleNumber() missing.'); - self::assertFalse(method_exists($metadata->name, 'setTitleNumber'), 'EntityGeneratorIsbn::setTitleNumber() present.'); - self::assertTrue(method_exists($metadata->name, 'getCheckDigit'), 'EntityGeneratorIsbn::getCheckDigit() missing.'); - self::assertFalse(method_exists($metadata->name, 'setCheckDigit'), 'EntityGeneratorIsbn::setCheckDigit() present.'); - self::assertTrue(method_exists($metadata->name, 'getTest'), 'EntityGeneratorIsbn::getTest() missing.'); - self::assertFalse(method_exists($metadata->name, 'setTest'), 'EntityGeneratorIsbn::setTest() present.'); - - $test = new $embeddedMetadata->name(1, new DateTime()); - $isbn = new $metadata->name($test, 978, 3, 12, 732320, 83); - - $reflMethod = new ReflectionMethod($isbn, '__construct'); - $reflParameters = $reflMethod->getParameters(); - - self::assertCount(6, $reflParameters); - - self::assertSame($embeddedMetadata->name, $reflParameters[0]->getType()->getName()); - self::assertSame('test', $reflParameters[0]->getName()); - self::assertFalse($reflParameters[0]->isOptional()); - - self::assertSame('prefix', $reflParameters[1]->getName()); - self::assertFalse($reflParameters[1]->isOptional()); - - self::assertSame('groupNumber', $reflParameters[2]->getName()); - self::assertFalse($reflParameters[2]->isOptional()); - - self::assertSame('publisherNumber', $reflParameters[3]->getName()); - self::assertFalse($reflParameters[3]->isOptional()); - - self::assertSame('titleNumber', $reflParameters[4]->getName()); - self::assertFalse($reflParameters[4]->isOptional()); - - self::assertSame('checkDigit', $reflParameters[5]->getName()); - self::assertFalse($reflParameters[5]->isOptional()); - - $reflMethod = new ReflectionMethod($test, '__construct'); - $reflParameters = $reflMethod->getParameters(); - - self::assertCount(4, $reflParameters); - - self::assertSame('field1', $reflParameters[0]->getName()); - self::assertFalse($reflParameters[0]->isOptional()); - - self::assertSame('DateTime', $reflParameters[1]->getType()->getName()); - self::assertSame('field3', $reflParameters[1]->getName()); - self::assertFalse($reflParameters[1]->isOptional()); - - self::assertSame('field2', $reflParameters[2]->getName()); - self::assertTrue($reflParameters[2]->isOptional()); - - self::assertSame('DateTime', $reflParameters[3]->getType()->getName()); - self::assertSame('field4', $reflParameters[3]->getName()); - self::assertTrue($reflParameters[3]->isOptional()); - } - - public function testRegenerateEntityClass(): void - { - $metadata = $this->generateBookEntityFixture(); - $this->loadEntityClass($metadata); - - $className = basename(str_replace('\\', '/', $metadata->name)); - $path = $this->tmpDir . '/' . $this->namespace . '/' . $className . '.php'; - $classTest = file_get_contents($path); - - $this->generator->setRegenerateEntityIfExists(true); - $this->generator->setBackupExisting(false); - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - $classNew = file_get_contents($path); - - self::assertSame($classTest, $classNew); - } - - /** - * @return mixed[] - * @psalm-return list - */ - public function getEntityTypeAliasDataProvider(): array - { - return [ - [ - [ - 'fieldName' => 'datetimetz', - 'phpType' => '\\DateTime', - 'dbType' => 'datetimetz', - 'value' => new DateTime(), - ], - ], - [ - [ - 'fieldName' => 'datetime', - 'phpType' => '\\DateTime', - 'dbType' => 'datetime', - 'value' => new DateTime(), - ], - ], - [ - [ - 'fieldName' => 'date', - 'phpType' => '\\DateTime', - 'dbType' => 'date', - 'value' => new DateTime(), - ], - ], - [ - [ - 'fieldName' => 'time', - 'phpType' => '\DateTime', - 'dbType' => 'time', - 'value' => new DateTime(), - ], - ], - [ - [ - 'fieldName' => 'object', - 'phpType' => '\stdClass', - 'dbType' => 'object', - 'value' => new stdClass(), - ], - ], - [ - [ - 'fieldName' => 'bigint', - 'phpType' => 'int', - 'dbType' => 'bigint', - 'value' => 11, - ], - ], - [ - [ - 'fieldName' => 'smallint', - 'phpType' => 'int', - 'dbType' => 'smallint', - 'value' => 22, - ], - ], - [ - [ - 'fieldName' => 'text', - 'phpType' => 'string', - 'dbType' => 'text', - 'value' => 'text', - ], - ], - [ - [ - 'fieldName' => 'blob', - 'phpType' => 'string', - 'dbType' => 'blob', - 'value' => 'blob', - ], - ], - [ - [ - 'fieldName' => 'guid', - 'phpType' => 'string', - 'dbType' => 'guid', - 'value' => '00000000-0000-0000-0000-000000000001', - ], - ], - [ - [ - 'fieldName' => 'decimal', - 'phpType' => 'string', - 'dbType' => 'decimal', - 'value' => '12.34', - ], - ], - ]; - } - - /** - * @psalm-return list - */ - public function getParseTokensInEntityFileData(): array - { - return [ - [ - 'getDocComment(); - $regex = '/@var\s+([\S]+)$/m'; - - self::assertMatchesRegularExpression($regex, $docComment); - self::assertEquals(1, preg_match($regex, $docComment, $matches)); - self::assertEquals($type, $matches[1]); - } - - private function assertPhpDocReturnType(string $type, ReflectionMethod $method): void - { - $docComment = $method->getDocComment(); - $regex = '/@return\s+([\S]+)(\s+.*)$/m'; - - self::assertMatchesRegularExpression($regex, $docComment); - self::assertEquals(1, preg_match($regex, $docComment, $matches)); - self::assertEquals($type, $matches[1]); - } - - private function assertPhpDocParamType(string $type, ReflectionMethod $method): void - { - self::assertEquals(1, preg_match('/@param\s+([^\s]+)/', $method->getDocComment(), $matches)); - self::assertEquals($type, $matches[1]); - } - - /** - * @group 6703 - * @dataProvider columnOptionsProvider - */ - public function testOptionsAreGeneratedProperly(string $expectedAnnotation, array $fieldConfiguration): void - { - $metadata = new ClassMetadataInfo($this->namespace . '\GH6703Options'); - $metadata->namespace = $this->namespace; - $metadata->mapField(['fieldName' => 'id', 'type' => 'integer', 'id' => true]); - $metadata->mapField(['fieldName' => 'test'] + $fieldConfiguration); - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - $filename = $this->tmpDir . DIRECTORY_SEPARATOR . $this->namespace . DIRECTORY_SEPARATOR . 'GH6703Options.php'; - - self::assertFileExists($filename); - require_once $filename; - - $property = new ReflectionProperty($metadata->name, 'test'); - $docComment = $property->getDocComment(); - - self::assertStringContainsString($expectedAnnotation, $docComment); - } - - public function columnOptionsProvider(): array - { - return [ - 'string-default' => [ - '@ORM\Column(name="test", type="string", length=10, options={"default"="testing"})', - ['type' => 'string', 'length' => 10, 'options' => ['default' => 'testing']], - ], - 'string-fixed' => [ - '@ORM\Column(name="test", type="string", length=10, options={"fixed"=true})', - ['type' => 'string', 'length' => 10, 'options' => ['fixed' => true]], - ], - 'string-comment' => [ - '@ORM\Column(name="test", type="string", length=10, options={"comment"="testing"})', - ['type' => 'string', 'length' => 10, 'options' => ['comment' => 'testing']], - ], - 'string-comment-quote' => [ - '@ORM\Column(name="test", type="string", length=10, options={"comment"="testing ""quotes"""})', - ['type' => 'string', 'length' => 10, 'options' => ['comment' => 'testing "quotes"']], - ], - 'string-collation' => [ - '@ORM\Column(name="test", type="string", length=10, options={"collation"="utf8mb4_general_ci"})', - ['type' => 'string', 'length' => 10, 'options' => ['collation' => 'utf8mb4_general_ci']], - ], - 'string-check' => [ - '@ORM\Column(name="test", type="string", length=10, options={"check"="CHECK (test IN (""test""))"})', - ['type' => 'string', 'length' => 10, 'options' => ['check' => 'CHECK (test IN (""test""))']], - ], - 'string-all' => [ - '@ORM\Column(name="test", type="string", length=10, options={"default"="testing","fixed"=true,"comment"="testing","collation"="utf8mb4_general_ci","check"="CHECK (test IN (""test""))"})', - [ - 'type' => 'string', - 'length' => 10, - 'options' => [ - 'default' => 'testing', - 'fixed' => true, - 'comment' => 'testing', - 'collation' => 'utf8mb4_general_ci', - 'check' => 'CHECK (test IN (""test""))', - ], - ], - ], - 'int-default' => [ - '@ORM\Column(name="test", type="integer", options={"default"="10"})', - ['type' => 'integer', 'options' => ['default' => 10]], - ], - 'int-unsigned' => [ - '@ORM\Column(name="test", type="integer", options={"unsigned"=true})', - ['type' => 'integer', 'options' => ['unsigned' => true]], - ], - 'int-comment' => [ - '@ORM\Column(name="test", type="integer", options={"comment"="testing"})', - ['type' => 'integer', 'options' => ['comment' => 'testing']], - ], - 'int-check' => [ - '@ORM\Column(name="test", type="integer", options={"check"="CHECK (test > 5)"})', - ['type' => 'integer', 'options' => ['check' => 'CHECK (test > 5)']], - ], - 'int-all' => [ - '@ORM\Column(name="test", type="integer", options={"default"="10","unsigned"=true,"comment"="testing","check"="CHECK (test > 5)"})', - [ - 'type' => 'integer', - 'options' => [ - 'default' => 10, - 'unsigned' => true, - 'comment' => 'testing', - 'check' => 'CHECK (test > 5)', - ], - ], - ], - ]; - } -} - -class EntityGeneratorAuthor -{ -} -class EntityGeneratorComment -{ -} diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php deleted file mode 100644 index 3868a8a378a..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php +++ /dev/null @@ -1,192 +0,0 @@ -namespace = uniqid('doctrine_'); - $this->tmpDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $this->namespace; - mkdir($this->tmpDir); - - $this->generator = new EntityGenerator(); - $this->generator->setGenerateAnnotations(true); - $this->generator->setGenerateStubMethods(true); - $this->generator->setRegenerateEntityIfExists(false); - $this->generator->setUpdateEntityIfExists(true); - $this->generator->setFieldVisibility(EntityGenerator::FIELD_VISIBLE_PROTECTED); - - $this->repositoryGenerator = new EntityRepositoryGenerator(); - } - - public function tearDown(): void - { - $dirs = []; - - $ri = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->tmpDir)); - foreach ($ri as $file) { - assert($file instanceof SplFileInfo); - if ($file->isFile()) { - unlink($file->getPathname()); - } elseif ($file->getBasename() === '.') { - $dirs[] = $file->getRealPath(); - } - } - - arsort($dirs); - - foreach ($dirs as $dir) { - rmdir($dir); - } - } - - /** - * @group DDC-3231 - */ - public function testGeneratedEntityRepositoryClass(): void - { - $em = $this->getTestEntityManager(); - $ns = $this->namespace; - - $className = $ns . '\DDC3231User1Tmp'; - $this->writeEntityClass(DDC3231User1::class, $className); - - $rpath = $this->writeRepositoryClass($className); - - self::assertFileExists($rpath); - - require $rpath; - - $repo = new ReflectionClass($em->getRepository($className)); - - self::assertTrue($repo->inNamespace()); - self::assertSame($className . 'Repository', $repo->getName()); - self::assertSame(EntityRepository::class, $repo->getParentClass()->getName()); - - require_once __DIR__ . '/../../Models/DDC3231/DDC3231User1NoNamespace.php'; - - $className2 = 'DDC3231User1NoNamespaceTmp'; - $this->writeEntityClass(DDC3231User1NoNamespace::class, $className2); - - $rpath2 = $this->writeRepositoryClass($className2); - - self::assertFileExists($rpath2); - - require $rpath2; - - $repo2 = new ReflectionClass($em->getRepository($className2)); - - self::assertFalse($repo2->inNamespace()); - self::assertSame($className2 . 'Repository', $repo2->getName()); - self::assertSame(EntityRepository::class, $repo2->getParentClass()->getName()); - } - - /** - * @group DDC-3231 - */ - public function testGeneratedEntityRepositoryClassCustomDefaultRepository(): void - { - $em = $this->getTestEntityManager(); - $ns = $this->namespace; - - $className = $ns . '\DDC3231User2Tmp'; - $this->writeEntityClass(DDC3231User2::class, $className); - - $rpath = $this->writeRepositoryClass($className, DDC3231EntityRepository::class); - - self::assertNotNull($rpath); - self::assertFileExists($rpath); - - require $rpath; - - $repo = new ReflectionClass($em->getRepository($className)); - - self::assertTrue($repo->inNamespace()); - self::assertSame($className . 'Repository', $repo->getName()); - self::assertSame(DDC3231EntityRepository::class, $repo->getParentClass()->getName()); - - require_once __DIR__ . '/../../Models/DDC3231/DDC3231User2NoNamespace.php'; - - $className2 = 'DDC3231User2NoNamespaceTmp'; - $this->writeEntityClass('DDC3231User2NoNamespace', $className2); - - $rpath2 = $this->writeRepositoryClass($className2, DDC3231EntityRepository::class); - - self::assertNotNull($rpath2); - self::assertFileExists($rpath2); - - require $rpath2; - - $repo2 = new ReflectionClass($em->getRepository($className2)); - - self::assertFalse($repo2->inNamespace()); - self::assertSame($className2 . 'Repository', $repo2->getName()); - self::assertSame(DDC3231EntityRepository::class, $repo2->getParentClass()->getName()); - } - - private function writeEntityClass(string $className, string $newClassName): void - { - $cmf = new ClassMetadataFactory(); - $em = $this->getTestEntityManager(); - - $cmf->setEntityManager($em); - - $metadata = $cmf->getMetadataFor($className); - $metadata->namespace = $this->namespace; - $metadata->name = $newClassName; - $metadata->customRepositoryClassName = $newClassName . 'Repository'; - - $this->generator->writeEntityClass($metadata, $this->tmpDir); - - require $this->tmpDir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $newClassName) . '.php'; - } - - private function writeRepositoryClass(string $className, ?string $defaultRepository = null): string - { - $this->repositoryGenerator->setDefaultRepositoryName($defaultRepository); - - $this->repositoryGenerator->writeEntityRepositoryClass($className . 'Repository', $this->tmpDir); - - return $this->tmpDir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className) . 'Repository.php'; - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php deleted file mode 100644 index 6375ae209b3..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ /dev/null @@ -1,458 +0,0 @@ -setProxyDir(__DIR__ . '/../../Proxies'); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $eventManager = new EventManager(); - $conn = new ConnectionMock([], $driverMock, $config, $eventManager); - $config->setMetadataDriverImpl($metadataDriver); - - return EntityManagerMock::create($conn, $config, $eventManager); - } - - protected function createMetadataDriver(string $type, string $path): MappingDriver - { - $mappingDriver = [ - 'php' => PHPDriver::class, - 'annotation' => AnnotationDriver::class, - 'xml' => XmlDriver::class, - 'yaml' => YamlDriver::class, - ]; - - self::assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'."); - - $class = $mappingDriver[$type]; - - return $type === 'annotation' - ? $this->createAnnotationDriver([$path]) - : new $class($path); - } - - protected function createClassMetadataFactory(EntityManagerInterface $em, string $type): ClassMetadataFactory - { - $factory = $type === 'annotation' - ? new ClassMetadataFactory() - : new DisconnectedClassMetadataFactory(); - - $factory->setEntityManager($em); - - return $factory; - } - - public function testExportDirectoryAndFilesAreCreated(): void - { - $this->deleteDirectory(__DIR__ . '/export/' . $this->getType()); - - $type = $this->getType(); - $metadataDriver = $this->createMetadataDriver($type, __DIR__ . '/' . $type); - $em = $this->createEntityManager($metadataDriver); - $cmf = $this->createClassMetadataFactory($em, $type); - $metadata = $cmf->getAllMetadata(); - - $metadata[0]->name = ExportedUser::class; - - self::assertEquals(ExportedUser::class, $metadata[0]->name); - - $type = $this->getType(); - $cme = new ClassMetadataExporter(); - $exporter = $cme->getExporter($type, __DIR__ . '/export/' . $type); - - if ($type === 'annotation') { - $entityGenerator = new EntityGenerator(); - - $exporter->setEntityGenerator($entityGenerator); - } - - $this->extension = $exporter->getExtension(); - - $exporter->setMetadata($metadata); - $exporter->export(); - - if ($type === 'annotation') { - self::assertFileExists(__DIR__ . '/export/' . $type . '/' . str_replace('\\', '/', ExportedUser::class) . $this->extension); - } else { - self::assertFileExists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser' . $this->extension); - } - } - - /** - * @depends testExportDirectoryAndFilesAreCreated - */ - public function testExportedMetadataCanBeReadBackIn(): ClassMetadataInfo - { - $type = $this->getType(); - - $metadataDriver = $this->createMetadataDriver($type, __DIR__ . '/export/' . $type); - $em = $this->createEntityManager($metadataDriver); - $cmf = $this->createClassMetadataFactory($em, $type); - $metadata = $cmf->getAllMetadata(); - - self::assertCount(1, $metadata); - - $class = current($metadata); - - self::assertEquals(ExportedUser::class, $class->name); - - return $class; - } - - /** - * @depends testExportedMetadataCanBeReadBackIn - */ - public function testTableIsExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertEquals('cms_users', $class->table['name']); - self::assertEquals( - ['engine' => 'MyISAM', 'foo' => ['bar' => 'baz']], - $class->table['options'] - ); - - return $class; - } - - /** - * @depends testTableIsExported - */ - public function testTypeIsExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertFalse($class->isMappedSuperclass); - - return $class; - } - - /** - * @depends testTypeIsExported - */ - public function testIdentifierIsExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertEquals(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY, $class->generatorType, 'Generator Type wrong'); - self::assertEquals(['id'], $class->identifier); - self::assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); - - return $class; - } - - /** - * @depends testIdentifierIsExported - */ - public function testFieldsAreExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); - self::assertEquals('id', $class->fieldMappings['id']['fieldName']); - self::assertEquals('integer', $class->fieldMappings['id']['type']); - self::assertEquals('id', $class->fieldMappings['id']['columnName']); - - self::assertEquals('name', $class->fieldMappings['name']['fieldName']); - self::assertEquals('string', $class->fieldMappings['name']['type']); - self::assertEquals(50, $class->fieldMappings['name']['length']); - self::assertEquals('name', $class->fieldMappings['name']['columnName']); - - self::assertEquals('email', $class->fieldMappings['email']['fieldName']); - self::assertEquals('string', $class->fieldMappings['email']['type']); - self::assertEquals('user_email', $class->fieldMappings['email']['columnName']); - self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); - - self::assertTrue($class->fieldMappings['age']['options']['unsigned']); - - return $class; - } - - /** - * @depends testExportDirectoryAndFilesAreCreated - */ - public function testFieldsAreProperlySerialized(): void - { - $type = $this->getType(); - - if ($type === 'xml') { - $xml = simplexml_load_file(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml'); - - $xml->registerXPathNamespace('d', 'http://doctrine-project.org/schemas/orm/doctrine-mapping'); - $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @nullable='true']"); - self::assertEquals(1, count($nodes)); - - $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @unique='true']"); - self::assertEquals(1, count($nodes)); - } else { - self::markTestSkipped('Test not available for ' . $type . ' driver'); - } - } - - /** - * @depends testFieldsAreExported - */ - public function testOneToOneAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertTrue(isset($class->associationMappings['address'])); - self::assertEquals(Address::class, $class->associationMappings['address']['targetEntity']); - self::assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']); - self::assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']); - self::assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); - - self::assertTrue($class->associationMappings['address']['isCascadeRemove']); - self::assertTrue($class->associationMappings['address']['isCascadePersist']); - self::assertFalse($class->associationMappings['address']['isCascadeRefresh']); - self::assertFalse($class->associationMappings['address']['isCascadeMerge']); - self::assertFalse($class->associationMappings['address']['isCascadeDetach']); - self::assertTrue($class->associationMappings['address']['orphanRemoval']); - self::assertEquals(ClassMetadataInfo::FETCH_EAGER, $class->associationMappings['address']['fetch']); - - return $class; - } - - /** - * @depends testFieldsAreExported - */ - public function testManyToOneAssociationsAreExported($class): void - { - self::assertTrue(isset($class->associationMappings['mainGroup'])); - self::assertEquals(Group::class, $class->associationMappings['mainGroup']['targetEntity']); - } - - /** - * @depends testOneToOneAssociationsAreExported - */ - public function testOneToManyAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertTrue(isset($class->associationMappings['phonenumbers'])); - self::assertEquals(Phonenumber::class, $class->associationMappings['phonenumbers']['targetEntity']); - self::assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']); - self::assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); - - self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - self::assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); - self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); - self::assertEquals(ClassMetadataInfo::FETCH_LAZY, $class->associationMappings['phonenumbers']['fetch']); - - return $class; - } - - /** - * @depends testOneToManyAssociationsAreExported - */ - public function testManyToManyAssociationsAreExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertTrue(isset($class->associationMappings['groups'])); - self::assertEquals(Group::class, $class->associationMappings['groups']['targetEntity']); - self::assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']); - - self::assertEquals('user_id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['name']); - self::assertEquals('id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['referencedColumnName']); - - self::assertEquals('group_id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['name']); - self::assertEquals('id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); - self::assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); - - self::assertTrue($class->associationMappings['groups']['isCascadeRemove']); - self::assertTrue($class->associationMappings['groups']['isCascadePersist']); - self::assertTrue($class->associationMappings['groups']['isCascadeRefresh']); - self::assertTrue($class->associationMappings['groups']['isCascadeMerge']); - self::assertTrue($class->associationMappings['groups']['isCascadeDetach']); - self::assertEquals(ClassMetadataInfo::FETCH_EXTRA_LAZY, $class->associationMappings['groups']['fetch']); - - return $class; - } - - /** - * @depends testManyToManyAssociationsAreExported - */ - public function testLifecycleCallbacksAreExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertTrue(isset($class->lifecycleCallbacks['prePersist'])); - self::assertCount(2, $class->lifecycleCallbacks['prePersist']); - self::assertEquals('doStuffOnPrePersist', $class->lifecycleCallbacks['prePersist'][0]); - self::assertEquals('doOtherStuffOnPrePersistToo', $class->lifecycleCallbacks['prePersist'][1]); - - self::assertTrue(isset($class->lifecycleCallbacks['postPersist'])); - self::assertCount(1, $class->lifecycleCallbacks['postPersist']); - self::assertEquals('doStuffOnPostPersist', $class->lifecycleCallbacks['postPersist'][0]); - - return $class; - } - - /** - * @depends testLifecycleCallbacksAreExported - */ - public function testCascadeIsExported(ClassMetadataInfo $class): ClassMetadataInfo - { - self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - self::assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); - self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); - - return $class; - } - - /** - * @depends testCascadeIsExported - */ - public function testInversedByIsExported(ClassMetadataInfo $class): void - { - self::assertEquals('user', $class->associationMappings['address']['inversedBy']); - } - - /** - * @depends testExportDirectoryAndFilesAreCreated - */ - public function testCascadeAllCollapsed(): void - { - $type = $this->getType(); - - if ($type === 'xml') { - $xml = simplexml_load_file(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml'); - - $xml->registerXPathNamespace('d', 'http://doctrine-project.org/schemas/orm/doctrine-mapping'); - $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:one-to-many[@field='interests']/d:cascade/d:*"); - self::assertEquals(1, count($nodes)); - - self::assertEquals('cascade-all', $nodes[0]->getName()); - } elseif ($type === 'yaml') { - $yaml = new Parser(); - $value = $yaml->parse(file_get_contents(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.yml')); - - self::assertTrue(isset($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); - self::assertEquals(1, count($value[ExportedUser::class]['oneToMany']['interests']['cascade'])); - self::assertEquals('all', $value[ExportedUser::class]['oneToMany']['interests']['cascade'][0]); - } else { - self::markTestSkipped('Test not available for ' . $type . ' driver'); - } - } - - /** - * @depends testExportedMetadataCanBeReadBackIn - */ - public function testEntityListenersAreExported(ClassMetadata $class): void - { - self::assertNotEmpty($class->entityListeners); - self::assertCount(2, $class->entityListeners[Events::prePersist]); - self::assertCount(2, $class->entityListeners[Events::postPersist]); - self::assertEquals(UserListener::class, $class->entityListeners[Events::prePersist][0]['class']); - self::assertEquals('customPrePersist', $class->entityListeners[Events::prePersist][0]['method']); - self::assertEquals(GroupListener::class, $class->entityListeners[Events::prePersist][1]['class']); - self::assertEquals('prePersist', $class->entityListeners[Events::prePersist][1]['method']); - self::assertEquals(UserListener::class, $class->entityListeners[Events::postPersist][0]['class']); - self::assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][0]['method']); - self::assertEquals(AddressListener::class, $class->entityListeners[Events::postPersist][1]['class']); - self::assertEquals('customPostPersist', $class->entityListeners[Events::postPersist][1]['method']); - } - - protected function deleteDirectory(string $path): void - { - if (is_file($path)) { - unlink($path); - } elseif (is_dir($path)) { - $files = glob(rtrim($path, '/') . '/*'); - - if (is_array($files)) { - foreach ($files as $file) { - $this->deleteDirectory($file); - } - } - - rmdir($path); - } - } -} - -class Address -{ -} -class Phonenumber -{ -} -class Group -{ -} -class UserListener -{ - /** - * @\Doctrine\ORM\Mapping\PrePersist - */ - public function customPrePersist(): void - { - } - - /** - * @\Doctrine\ORM\Mapping\PostPersist - */ - public function customPostPersist(): void - { - } -} -class GroupListener -{ - /** - * @\Doctrine\ORM\Mapping\PrePersist - */ - public function prePersist(): void - { - } -} -class AddressListener -{ - /** - * @\Doctrine\ORM\Mapping\PostPersist - */ - public function customPostPersist(): void - { - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php deleted file mode 100644 index f9a4552356a..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php +++ /dev/null @@ -1,18 +0,0 @@ -mapField( - [ - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - 'id' => true, - ] - ); - - $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); - $metadata->setSequenceGeneratorDefinition( - [ - 'sequenceName' => 'seq_entity_test_id', - 'allocationSize' => 5, - 'initialValue' => 1, - ] - ); - - $expectedFileContent = <<<'XML' - - - - - - - - - -XML; - - self::assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); - } - - /** - * @group 1214 - * @group 1216 - * @group DDC-3439 - */ - public function testFieldOptionsExport(): void - { - $exporter = new XmlExporter(); - $metadata = new ClassMetadata('entityTest'); - - $metadata->mapField( - [ - 'fieldName' => 'myField', - 'type' => 'string', - 'columnName' => 'my_field', - 'options' => [ - 'default' => 'default_string', - 'comment' => 'The comment for the field', - ], - ] - ); - - $expectedFileContent = <<<'XML' - - - - - - - - - - - -XML; - - self::assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php deleted file mode 100644 index c927ceca30b..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @OneToMany(targetEntity="Doctrine\Tests\ORM\Tools\Export\Phonenumber", mappedBy="user", cascade={"persist", "merge"}, orphanRemoval=true) - * @OrderBy({"number"="ASC"}) - */ - public $phonenumbers; - - /** - * @psalm-var Collection - * @ManyToMany(targetEntity="Doctrine\Tests\ORM\Tools\Export\Group", cascade={"all"}, fetch="EXTRA_LAZY") - * @JoinTable(name="cms_users_groups", - * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id", nullable=false, unique=false)}, - * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id", columnDefinition="INT NULL")} - * ) - */ - public $groups; - - /** - * @PrePersist - */ - public function doStuffOnPrePersist(): void - { - } - - /** - * @PrePersist - */ - public function doOtherStuffOnPrePersistToo(): void - { - } - - /** - * @PostPersist - */ - public function doStuffOnPostPersist(): void - { - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php b/tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php deleted file mode 100644 index 5e4ebc17e18..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php +++ /dev/null @@ -1,155 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); -$metadata->setPrimaryTable( - [ - 'name' => 'cms_users', - 'options' => ['engine' => 'MyISAM', 'foo' => ['bar' => 'baz']], - ] -); -$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); -$metadata->addLifecycleCallback('doStuffOnPrePersist', Events::prePersist); -$metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', Events::prePersist); -$metadata->addLifecycleCallback('doStuffOnPostPersist', Events::postPersist); -$metadata->mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - ] -); -$metadata->mapField( - [ - 'fieldName' => 'name', - 'type' => 'string', - 'length' => 50, - 'unique' => true, - 'nullable' => true, - 'columnName' => 'name', - ] -); -$metadata->mapField( - [ - 'fieldName' => 'email', - 'type' => 'string', - 'columnName' => 'user_email', - 'columnDefinition' => 'CHAR(32) NOT NULL', - ] -); -$metadata->mapField( - [ - 'fieldName' => 'age', - 'type' => 'integer', - 'options' => ['unsigned' => true], - ] -); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); -$metadata->mapManyToOne( - [ - 'fieldName' => 'mainGroup', - 'targetEntity' => Export\Group::class, - ] -); -$metadata->mapOneToOne( - [ - 'fieldName' => 'address', - 'targetEntity' => Export\Address::class, - 'inversedBy' => 'user', - 'cascade' => - [0 => 'persist'], - 'mappedBy' => null, - 'joinColumns' => - [ - 0 => - [ - 'name' => 'address_id', - 'referencedColumnName' => 'id', - 'onDelete' => 'CASCADE', - ], - ], - 'orphanRemoval' => true, - 'fetch' => ClassMetadataInfo::FETCH_EAGER, - ] -); -$metadata->mapOneToOne( - [ - 'fieldName' => 'cart', - 'targetEntity' => Export\Cart::class, - 'mappedBy' => 'user', - 'cascade' => - [0 => 'persist'], - 'inversedBy' => null, - 'orphanRemoval' => false, - 'fetch' => ClassMetadataInfo::FETCH_EAGER, - ] -); -$metadata->mapOneToMany( - [ - 'fieldName' => 'phonenumbers', - 'targetEntity' => Export\Phonenumber::class, - 'cascade' => - [ - 1 => 'persist', - 2 => 'merge', - ], - 'mappedBy' => 'user', - 'orphanRemoval' => true, - 'fetch' => ClassMetadataInfo::FETCH_LAZY, - 'orderBy' => - ['number' => 'ASC'], - ] -); -$metadata->mapManyToMany( - [ - 'fieldName' => 'groups', - 'targetEntity' => Export\Group::class, - 'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY, - 'cascade' => - [ - 0 => 'remove', - 1 => 'persist', - 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', - ], - 'mappedBy' => null, - 'joinTable' => - [ - 'name' => 'cms_users_groups', - 'joinColumns' => - [ - 0 => - [ - 'name' => 'user_id', - 'referencedColumnName' => 'id', - 'unique' => false, - 'nullable' => false, - ], - ], - 'inverseJoinColumns' => - [ - 0 => - [ - 'name' => 'group_id', - 'referencedColumnName' => 'id', - 'columnDefinition' => 'INT NULL', - ], - ], - ], - 'orderBy' => null, - ] -); -$metadata->addEntityListener(Events::prePersist, UserListener::class, 'customPrePersist'); -$metadata->addEntityListener(Events::postPersist, UserListener::class, 'customPostPersist'); -$metadata->addEntityListener(Events::prePersist, GroupListener::class, 'prePersist'); -$metadata->addEntityListener(Events::postPersist, AddressListener::class, 'customPostPersist'); diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml b/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml deleted file mode 100644 index 4092c8574c5..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml b/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml deleted file mode 100644 index 23332e3db2f..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml +++ /dev/null @@ -1,85 +0,0 @@ -Doctrine\Tests\ORM\Tools\Export\User: - type: entity - table: cms_users - options: - engine: MyISAM - foo: { bar: baz } - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 50 - nullable: true - unique: true - email: - type: string - column: user_email - columnDefinition: CHAR(32) NOT NULL - age: - type: integer - options: - unsigned: true - oneToOne: - address: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Address - joinColumn: - name: address_id - referencedColumnName: id - onDelete: CASCADE - cascade: [ persist ] - inversedBy: user - orphanRemoval: true - fetch: EAGER - cart: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Cart - mappedBy: user - cascade: [ remove ] - manyToOne: - mainGroup: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Group - oneToMany: - phonenumbers: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Phonenumber - mappedBy: user - orderBy: - number: ASC - cascade: [ persist, merge ] - orphanRemoval: true - fetch: LAZY - interests: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Interests - mappedBy: user - cascade: [ persist, merge, remove, refresh, detach ] - orphanRemoval: true - manyToMany: - groups: - targetEntity: Doctrine\Tests\ORM\Tools\Export\Group - fetch: EXTRA_LAZY - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - nullable: false - unique: false - inverseJoinColumns: - group_id: - referencedColumnName: id - columnDefinition: INT NULL - cascade: - - all - lifecycleCallbacks: - prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] - postPersist: [ doStuffOnPostPersist ] - entityListeners: - Doctrine\Tests\ORM\Tools\Export\UserListener: - prePersist: [customPrePersist] - postPersist: [customPostPersist] - Doctrine\Tests\ORM\Tools\Export\GroupListener: - prePersist: [prePersist] - Doctrine\Tests\ORM\Tools\Export\AddressListener: - postPersist: [customPostPersist] diff --git a/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml b/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml deleted file mode 100644 index 65433d6ee81..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml +++ /dev/null @@ -1,28 +0,0 @@ -User: - tableName: users - columns: - username: - type: string(255) - length: 100 - notnull: true - unique: true - password: - type: string(255) - clob: clob - test_alias as theAlias: - type: string(255) - indexes: - username: - fields: [username] - type: unique - -Profile: - columns: - first_name: string(255) - last_name: string(255) - user_id: integer - relations: - User: - onDelete: CASCADE - foreignType: one - type: one From 36160a81fb573a65de3747451796cc28922a7fe3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 13 Dec 2021 19:43:11 +0100 Subject: [PATCH 014/475] Remove YAML metadata mapping (#9237) --- UPGRADE.md | 12 + composer.json | 4 +- docs/en/_exts/configurationblock.py | 1 - ...nting-the-notify-changetracking-policy.rst | 4 +- .../strategy-cookbook-introduction.rst | 4 +- docs/en/cookbook/validation-of-entities.rst | 3 - docs/en/index.rst | 1 - docs/en/reference/advanced-configuration.rst | 13 +- docs/en/reference/annotations-reference.rst | 3 +- docs/en/reference/association-mapping.rst | 190 ---- docs/en/reference/basic-mapping.rst | 53 -- docs/en/reference/caching.rst | 4 +- docs/en/reference/configuration.rst | 16 - docs/en/reference/events.rst | 38 +- docs/en/reference/inheritance-mapping.rst | 96 -- docs/en/reference/metadata-drivers.rst | 3 - docs/en/reference/native-sql.rst | 118 +-- docs/en/reference/second-level-cache.rst | 51 - .../transactions-and-concurrency.rst | 20 - docs/en/reference/working-with-objects.rst | 4 +- docs/en/reference/yaml-mapping.rst | 158 --- docs/en/sidebar.rst | 1 - docs/en/toc.rst | 2 - docs/en/tutorials/composite-primary-keys.rst | 49 - docs/en/tutorials/embeddables.rst | 35 - docs/en/tutorials/extra-lazy-associations.rst | 12 - docs/en/tutorials/getting-started.rst | 103 +- docs/en/tutorials/ordered-associations.rst | 19 - ...eld-association-mappings-in-subclasses.rst | 2 +- .../working-with-indexed-associations.rst | 36 - lib/Doctrine/ORM/Events.php | 2 +- .../Mapping/Driver/SimplifiedYamlDriver.php | 26 - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 2 +- .../ORM/Mapping/Driver/YamlDriver.php | 898 ------------------ lib/Doctrine/ORM/Tools/Setup.php | 27 - phpcs.xml.dist | 1 - phpstan-baseline.neon | 160 ---- psalm-baseline.xml | 98 +- .../ORM/Mapping/Symfony/YamlDriverTest.php | 26 - .../ORM/Mapping/YamlMappingDriverTest.php | 98 -- ...ctrine.Tests.Models.CMS.CmsAddress.dcm.yml | 64 -- .../Doctrine.Tests.Models.CMS.CmsUser.dcm.yml | 157 --- .../Doctrine.Tests.Models.Cache.City.dcm.yml | 36 - ...sts.Models.Company.CompanyContract.dcm.yml | 32 - ....Models.Company.CompanyFixContract.dcm.yml | 5 - ...Models.Company.CompanyFlexContract.dcm.yml | 7 - ...s.Company.CompanyFlexUltraContract.dcm.yml | 25 - ...Tests.Models.Company.CompanyPerson.dcm.yml | 74 -- ....DDC1476EntityWithDefaultFieldType.dcm.yml | 8 - ...els.DDC2825.ExplicitSchemaAndTable.dcm.yml | 8 - ....DDC2825.SchemaAndTableInTableName.dcm.yml | 7 - ....Tests.Models.DDC3579.DDC3579Admin.dcm.yml | 5 - ...e.Tests.Models.DDC3579.DDC3579User.dcm.yml | 19 - ...ests.Models.DDC3711.DDC3711EntityA.dcm.yml | 23 - ...ests.Models.DDC3711.DDC3711EntityB.dcm.yml | 8 - ...Models.DDC5934.DDC5934BaseContract.dcm.yml | 12 - ...sts.Models.DDC5934.DDC5934Contract.dcm.yml | 5 - ....Models.DDC869.DDC869ChequePayment.dcm.yml | 5 - ...els.DDC869.DDC869CreditCardPayment.dcm.yml | 5 - ....Tests.Models.DDC869.DDC869Payment.dcm.yml | 12 - ...ne.Tests.Models.DDC889.DDC889Class.dcm.yml | 8 - ...e.Tests.Models.DDC889.DDC889Entity.dcm.yml | 2 - ...sts.Models.DDC889.DDC889SuperClass.dcm.yml | 5 - ...ne.Tests.Models.DDC964.DDC964Admin.dcm.yml | 17 - ...ne.Tests.Models.DDC964.DDC964Guest.dcm.yml | 13 - ...ine.Tests.Models.DDC964.DDC964User.dcm.yml | 35 - ....DirectoryTree.AbstractContentItem.dcm.yml | 14 - ...sts.Models.DirectoryTree.Directory.dcm.yml | 6 - ...ne.Tests.Models.DirectoryTree.File.dcm.yml | 6 - ....Models.Generic.SerializationModel.dcm.yml | 13 - ...s.Models.TypedProperties.UserTyped.dcm.yml | 28 - .../Doctrine.Tests.ORM.Mapping.Animal.dcm.yml | 17 - ...Doctrine.Tests.ORM.Mapping.Comment.dcm.yml | 11 - ...ne.Tests.ORM.Mapping.DDC1170Entity.dcm.yml | 10 - ...ne.Tests.ORM.Mapping.DDC2069Entity.dcm.yml | 15 - ...ine.Tests.ORM.Mapping.DDC807Entity.dcm.yml | 13 - ....Mapping.ReservedWordInTableColumn.dcm.yml | 10 - ...completeDiscriminatorColumnMapping.dcm.yml | 12 - ...EntityNoDiscriminatorColumnMapping.dcm.yml | 10 - .../Doctrine.Tests.ORM.Mapping.User.dcm.yml | 89 -- ...sts.ORM.Mapping.UserIncorrectIndex.dcm.yml | 17 - ...ping.UserIncorrectUniqueConstraint.dcm.yml | 17 - tests/Doctrine/Tests/ORM/Tools/SetupTest.php | 9 - 83 files changed, 31 insertions(+), 3256 deletions(-) delete mode 100644 docs/en/reference/yaml-mapping.rst delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsUser.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Cache.City.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyContract.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3711.DDC3711EntityA.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3711.DDC3711EntityB.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Comment.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC2069Entity.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.yml diff --git a/UPGRADE.md b/UPGRADE.md index 9298b62fc2b..1c7074d7480 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,17 @@ # Upgrade to 3.0 +## BC BREAK: Remove YAML mapping drivers. + +If your code relies on `YamlDriver` or `SimpleYamlDriver`, you **MUST** migrate to +attribute, annotation or XML drivers instead. + +You can use the `orm:convert-mapping` command to convert your metadata mapping to XML +_before_ upgrading to 3.0: + +```sh +php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml +``` + ## BC BREAK: Remove code generators and related console commands These console commands have been removed: diff --git a/composer.json b/composer.json index dc6280dc90f..fc77adb2264 100644 --- a/composer.json +++ b/composer.json @@ -42,15 +42,13 @@ "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "3.6.1", "symfony/cache": "^4.4 || ^5.2", - "symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0", "vimeo/psalm": "4.13.1" }, "conflict": { "doctrine/annotations": "<1.13 || >= 2.0" }, "suggest": { - "symfony/cache": "Provides cache support for Setup Tool with doctrine/cache 2.0", - "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" + "symfony/cache": "Provides cache support for Setup Tool with doctrine/cache 2.0" }, "autoload": { "psr-4": { "Doctrine\\ORM\\": "lib/Doctrine/ORM" } diff --git a/docs/en/_exts/configurationblock.py b/docs/en/_exts/configurationblock.py index 36ca61f5b15..1046bcf84e5 100644 --- a/docs/en/_exts/configurationblock.py +++ b/docs/en/_exts/configurationblock.py @@ -35,7 +35,6 @@ class ConfigurationBlock(Directive): 'html': 'HTML', 'xml': 'XML', 'php': 'PHP', - 'yaml': 'YAML', 'jinja': 'Twig', 'html+jinja': 'Twig', 'jinja+html': 'Twig', diff --git a/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst b/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst index f2a8f19c196..3634a10c1bd 100644 --- a/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst +++ b/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst @@ -55,7 +55,7 @@ listeners: .. code-block:: php -YAML needs some little change yet, to allow multiple lifecycle -events for one method, this will happen before Beta 1 though. - Now validation is performed whenever you call ``EntityManager#persist($order)`` or when you call ``EntityManager#flush()`` and an order is about to be updated. Any diff --git a/docs/en/index.rst b/docs/en/index.rst index d0e16d22b3b..342034f512b 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -42,7 +42,6 @@ Mapping Objects onto a Database :doc:`Docblock Annotations ` | :doc:`Attributes ` | :doc:`XML ` | - :doc:`YAML ` | :doc:`PHP ` Working with Objects diff --git a/docs/en/reference/advanced-configuration.rst b/docs/en/reference/advanced-configuration.rst index 8e8442af98b..a48fca1971a 100644 --- a/docs/en/reference/advanced-configuration.rst +++ b/docs/en/reference/advanced-configuration.rst @@ -109,19 +109,17 @@ Gets or sets the metadata driver implementation that is used by Doctrine to acquire the object-relational metadata for your classes. -There are currently 5 available implementations: +There are currently 4 available implementations: - ``Doctrine\ORM\Mapping\Driver\AnnotationDriver`` - ``Doctrine\ORM\Mapping\Driver\AttributeDriver`` - ``Doctrine\ORM\Mapping\Driver\XmlDriver`` -- ``Doctrine\ORM\Mapping\Driver\YamlDriver`` - ``Doctrine\ORM\Mapping\Driver\DriverChain`` Throughout the most part of this manual the AnnotationDriver is used in the examples. For information on the usage of the XmlDriver -or YamlDriver please refer to the dedicated chapters -``XML Mapping`` and ``YAML Mapping``. +please refer to the dedicated chapter ``XML Mapping``. The annotation driver can be configured with a factory method on the ``Doctrine\ORM\Configuration``: @@ -150,7 +148,7 @@ Metadata Cache (***RECOMMENDED***) Gets or sets the cache adapter to use for caching metadata information, that is, all the information you supply via -annotations, xml or yaml, so that they do not need to be parsed and +annotations or xml, so that they do not need to be parsed and loaded from scratch on every single request which is a waste of resources. The cache implementation must implement the PSR-6 ``Psr\Cache\CacheItemPoolInterface`` interface. @@ -404,7 +402,7 @@ Multiple Metadata Sources When using different components using Doctrine ORM you may end up with them using two different metadata drivers, for example XML and -YAML. You can use the DriverChain Metadata implementations to +PHP. You can use the DriverChain Metadata implementations to aggregate these drivers based on namespaces: .. code-block:: php @@ -414,7 +412,7 @@ aggregate these drivers based on namespaces: $chain = new DriverChain(); $chain->addDriver($xmlDriver, 'Doctrine\Tests\Models\Company'); - $chain->addDriver($yamlDriver, 'Doctrine\Tests\ORM\Mapping'); + $chain->addDriver($phpDriver, 'Doctrine\Tests\ORM\Mapping'); Based on the namespace of the entity the loading of entities is delegated to the appropriate driver. The chain semantics come from @@ -458,4 +456,3 @@ In general the required code looks like this: $cli->setHelperSet($helperSet); Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli); $cli->run(); - diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index 226842d71a4..1c131039083 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -32,7 +32,7 @@ metadata. If you're not comfortable with the concept of docblock annotations, don't worry, as mentioned earlier Doctrine ORM provides - XML and YAML alternatives and you could easily implement your own + XML as alternative and you could easily implement your own favourite mechanism for defining ORM metadata. In this chapter a reference of every Doctrine ORM Annotation is given @@ -1363,4 +1363,3 @@ Example: * @Version */ protected $version; - diff --git a/docs/en/reference/association-mapping.rst b/docs/en/reference/association-mapping.rst index 8dbcd1f19a6..d5e9a674b74 100644 --- a/docs/en/reference/association-mapping.rst +++ b/docs/en/reference/association-mapping.rst @@ -68,18 +68,6 @@ A many-to-one association is the most common association between objects. Exampl - .. code-block:: yaml - - User: - type: entity - manyToOne: - address: - targetEntity: Address - joinColumn: - name: address_id - referencedColumnName: id - - .. note:: The above ``@JoinColumn`` is optional as it would default @@ -145,17 +133,6 @@ references one ``Shipment`` entity. - .. code-block:: yaml - - Product: - type: entity - oneToOne: - shipment: - targetEntity: Shipment - joinColumn: - name: shipment_id - referencedColumnName: id - Note that the @JoinColumn is not really necessary in this example, as the defaults would be the same. @@ -233,22 +210,6 @@ object. - .. code-block:: yaml - - Customer: - oneToOne: - cart: - targetEntity: Cart - mappedBy: customer - Cart: - oneToOne: - customer: - targetEntity: Customer - inversedBy: cart - joinColumn: - name: customer_id - referencedColumnName: id - Note that the @JoinColumn is not really necessary in this example, as the defaults would be the same. @@ -373,24 +334,6 @@ bidirectional many-to-one. - .. code-block:: yaml - - Product: - type: entity - oneToMany: - features: - targetEntity: Feature - mappedBy: product - Feature: - type: entity - manyToOne: - product: - targetEntity: Product - inversedBy: features - joinColumn: - name: product_id - referencedColumnName: id - Note that the @JoinColumn is not really necessary in this example, as the defaults would be the same. @@ -470,24 +413,6 @@ The following example sets up such a unidirectional one-to-many association: - .. code-block:: yaml - - User: - type: entity - manyToMany: - phonenumbers: - targetEntity: Phonenumber - joinTable: - name: users_phonenumbers - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - phonenumber_id: - referencedColumnName: id - unique: true - - Generates the following MySQL Schema: .. code-block:: sql @@ -558,19 +483,6 @@ database perspective is known as an adjacency list approach. - .. code-block:: yaml - - Category: - type: entity - oneToMany: - children: - targetEntity: Category - mappedBy: parent - manyToOne: - parent: - targetEntity: Category - inversedBy: children - Note that the @JoinColumn is not really necessary in this example, as the defaults would be the same. @@ -642,22 +554,6 @@ entities: - .. code-block:: yaml - - User: - type: entity - manyToMany: - groups: - targetEntity: Group - joinTable: - name: users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - Generated MySQL Schema: .. code-block:: sql @@ -755,30 +651,6 @@ one is bidirectional. - .. code-block:: yaml - - User: - type: entity - manyToMany: - groups: - targetEntity: Group - inversedBy: users - joinTable: - name: users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - - Group: - type: entity - manyToMany: - users: - targetEntity: User - mappedBy: groups - The MySQL schema is exactly the same as for the Many-To-Many uni-directional case above. @@ -924,14 +796,6 @@ As an example, consider this mapping: - .. code-block:: yaml - - Product: - type: entity - oneToOne: - shipment: - targetEntity: Shipment - This is essentially the same as the following, more verbose, mapping: @@ -957,17 +821,6 @@ mapping: - .. code-block:: yaml - - Product: - type: entity - oneToOne: - shipment: - targetEntity: Shipment - joinColumn: - name: shipment_id - referencedColumnName: id - The @JoinTable definition used for many-to-many mappings has similar defaults. As an example, consider this mapping: @@ -992,14 +845,6 @@ similar defaults. As an example, consider this mapping: - .. code-block:: yaml - - User: - type: entity - manyToMany: - groups: - targetEntity: Group - This is essentially the same as the following, more verbose, mapping: .. configuration-block:: @@ -1039,22 +884,6 @@ This is essentially the same as the following, more verbose, mapping: - .. code-block:: yaml - - User: - type: entity - manyToMany: - groups: - targetEntity: Group - joinTable: - name: User_Group - joinColumns: - User_id: - referencedColumnName: id - inverseJoinColumns: - Group_id: - referencedColumnName: id - In that case, the name of the join table defaults to a combination of the simple, unqualified class names of the participating classes, separated by an underscore character. The names of the @@ -1083,13 +912,6 @@ attribute on ``JoinColumn`` will be inherited from PHP type. So that: - .. code-block:: yaml - - Product: - type: entity - oneToOne: - shipment: ~ - Is essentially the same as following: .. configuration-block:: @@ -1114,18 +936,6 @@ Is essentially the same as following: - .. code-block:: yaml - - Product: - type: entity - oneToOne: - shipment: - targetEntity: Shipment - joinColumn: - name: shipment_id - referencedColumnName: id - nullable: false - If you accept these defaults, you can reduce the mapping code to a minimum. diff --git a/docs/en/reference/basic-mapping.rst b/docs/en/reference/basic-mapping.rst index 6304e52ea22..4d6e2cd91f8 100644 --- a/docs/en/reference/basic-mapping.rst +++ b/docs/en/reference/basic-mapping.rst @@ -53,7 +53,6 @@ mapping metadata: - :doc:`Docblock Annotations ` - :doc:`Attributes ` - :doc:`XML ` -- :doc:`YAML ` - :doc:`PHP code ` This manual will usually show mapping metadata via docblock annotations, though @@ -88,12 +87,6 @@ Marking our ``Message`` class as an entity for Doctrine is straightforward: - .. code-block:: yaml - - Message: - type: entity - # ... - With no additional information, Doctrine expects the entity to be saved into a table with the same name as the class in our case ``Message``. You can change this by configuring information about the table: @@ -120,13 +113,6 @@ You can change this by configuring information about the table: - .. code-block:: yaml - - Message: - type: entity - table: message - # ... - Now the class ``Message`` will be saved and fetched from the table ``message``. Property Mapping @@ -166,19 +152,6 @@ default. - .. code-block:: yaml - - Message: - type: entity - fields: - id: - type: integer - text: - length: 140 - postedAt: - type: datetime - column: posted_at - When we don't explicitly specify a column name via the ``name`` option, Doctrine assumes the field name is also the column name. This means that: @@ -336,18 +309,6 @@ annotation. - .. code-block:: yaml - - Message: - type: entity - id: - id: - type: integer - generator: - strategy: AUTO - fields: - # fields here - In most cases using the automatic generator strategy (``@GeneratedValue``) is what you want. It defaults to the identifier generation mechanism your current database vendor prefers: AUTO_INCREMENT with MySQL, sequences with PostgreSQL @@ -422,20 +383,6 @@ besides specifying the sequence's name: - .. code-block:: yaml - - Message: - type: entity - id: - id: - type: integer - generator: - strategy: SEQUENCE - sequenceGenerator: - sequenceName: message_seq - allocationSize: 100 - initialValue: 1 - The initial value specifies at which value the sequence should start. diff --git a/docs/en/reference/caching.rst b/docs/en/reference/caching.rst index ed13e1029cc..940ebf7e37b 100644 --- a/docs/en/reference/caching.rst +++ b/docs/en/reference/caching.rst @@ -109,7 +109,7 @@ Metadata Cache ~~~~~~~~~~~~~~ Your class metadata can be parsed from a few different sources like -YAML, XML, Annotations, etc. Instead of parsing this information on +XML, Annotations, etc. Instead of parsing this information on each request we should cache it using one of the cache drivers. Just like the query and result cache we need to configure it @@ -199,5 +199,3 @@ not letting your users' requests populate the cache. You can read more about cache slams `in this blog post `_. - - diff --git a/docs/en/reference/configuration.rst b/docs/en/reference/configuration.rst index 36cd5978818..4373baae422 100644 --- a/docs/en/reference/configuration.rst +++ b/docs/en/reference/configuration.rst @@ -67,22 +67,6 @@ Or if you prefer XML: $config = Setup::createXMLMetadataConfiguration($paths, $isDevMode); $entityManager = EntityManager::create($dbParams, $config); -Or if you prefer YAML: - -.. code-block:: php - - - .. code-block:: yaml - - User: - type: entity - fields: - # ... - value: - type: string(255) - lifecycleCallbacks: - prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersist ] - postLoad: [ doStuffOnPostLoad ] Lifecycle Callbacks Event Argument ---------------------------------- @@ -825,13 +814,6 @@ An entity listener is a lifecycle listener class used for an entity. - .. code-block:: yaml - - MyProject\Entity\User: - type: entity - entityListeners: - UserListener: - # .... .. _reference-entity-listeners: @@ -914,24 +896,6 @@ you need to map the listener method using the event type mapping: - .. code-block:: yaml - - MyProject\Entity\User: - type: entity - entityListeners: - UserListener: - preFlush: [preFlushHandler] - postLoad: [postLoadHandler] - - postPersist: [postPersistHandler] - prePersist: [prePersistHandler] - - postUpdate: [postUpdateHandler] - preUpdate: [preUpdateHandler] - - postRemove: [postRemoveHandler] - preRemove: [preRemoveHandler] - # .... .. note:: diff --git a/docs/en/reference/inheritance-mapping.rst b/docs/en/reference/inheritance-mapping.rst index 1b025fbc2e6..58a1e83f57f 100644 --- a/docs/en/reference/inheritance-mapping.rst +++ b/docs/en/reference/inheritance-mapping.rst @@ -123,21 +123,6 @@ Example: // ... } - .. code-block:: yaml - - MyProject\Model\Person: - type: entity - inheritanceType: SINGLE_TABLE - discriminatorColumn: - name: discr - type: string - discriminatorMap: - person: Person - employee: Employee - - MyProject\Model\Employee: - type: entity - Things to note: @@ -427,51 +412,6 @@ Example: - .. code-block:: yaml - - # user mapping - MyProject\Model\User: - type: mappedSuperclass - # other fields mapping - manyToOne: - address: - targetEntity: Address - joinColumn: - name: address_id - referencedColumnName: id - cascade: [ persist, merge ] - manyToMany: - groups: - targetEntity: Group - joinTable: - name: users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - cascade: [ persist, merge, detach ] - - # admin mapping - MyProject\Model\Admin: - type: entity - associationOverride: - address: - joinColumn: - adminaddress_id: - name: adminaddress_id - referencedColumnName: id - groups: - joinTable: - name: users_admingroups - joinColumns: - adminuser_id: - referencedColumnName: id - inverseJoinColumns: - admingroup_id: - referencedColumnName: id - Things to note: @@ -568,42 +508,6 @@ Could be used by an entity that extends a mapped superclass to override a field - .. code-block:: yaml - - # user mapping - MyProject\Model\User: - type: mappedSuperclass - id: - id: - type: integer - column: user_id - length: 150 - generator: - strategy: AUTO - fields: - name: - type: string - column: user_name - length: 250 - nullable: true - unique: false - #other fields mapping - - - # guest mapping - MyProject\Model\Guest: - type: entity - attributeOverride: - id: - column: guest_id - type: integer - length: 140 - name: - column: guest_name - type: string - length: 240 - nullable: false - unique: true Things to note: diff --git a/docs/en/reference/metadata-drivers.rst b/docs/en/reference/metadata-drivers.rst index 9b0d521db3a..6e0e4d4a698 100644 --- a/docs/en/reference/metadata-drivers.rst +++ b/docs/en/reference/metadata-drivers.rst @@ -15,7 +15,6 @@ metadata: - **XML files** (XmlDriver) - **Class DocBlock Annotations** (AnnotationDriver) - **Attributes** (AttributeDriver) -- **YAML files** (YamlDriver) - **PHP Code in files or static functions** (PhpDriver) Something important to note about the above drivers is they are all @@ -192,5 +191,3 @@ iterate over them: foreach ($class->fieldMappings as $fieldMapping) { echo $fieldMapping['fieldName'] . "\n"; } - - diff --git a/docs/en/reference/native-sql.rst b/docs/en/reference/native-sql.rst index 434423bf5b8..3f9095f8554 100644 --- a/docs/en/reference/native-sql.rst +++ b/docs/en/reference/native-sql.rst @@ -444,7 +444,7 @@ You can also map a native query using a named native query mapping. To achieve that, you must describe the SQL resultset structure using named native query (and sql resultset mappings if is a several resultset mappings). -Like named query, a named native query can be defined at class level or in a XML or YAML file. +Like named query, a named native query can be defined at class level or in an XML file. A resultSetMapping parameter is defined in @NamedNativeQuery, @@ -540,47 +540,6 @@ it represents the name of a defined @SqlResultSetMapping. - .. code-block:: yaml - - MyProject\Model\User: - type: entity - namedNativeQueries: - fetchMultipleJoinsEntityResults: - name: fetchMultipleJoinsEntityResults - resultSetMapping: mappingMultipleJoinsEntityResults - query: SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM users u INNER JOIN addresses a ON u.id = a.user_id INNER JOIN phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username - sqlResultSetMappings: - mappingMultipleJoinsEntityResults: - name: mappingMultipleJoinsEntityResults - columnResult: - 0: - name: numphones - entityResult: - 0: - entityClass: __CLASS__ - fieldResult: - 0: - name: id - column: u_id - 1: - name: name - column: u_name - 2: - name: status - column: u_status - 1: - entityClass: Address - fieldResult: - 0: - name: id - column: a_id - 1: - name: zip - column: a_zip - 2: - name: country - column: a_country - Things to note: - The resultset mapping declares the entities retrieved by this native query. @@ -657,21 +616,6 @@ Let's now see an implicit declaration of the property / column. - .. code-block:: yaml - - MyProject\Model\Address: - type: entity - namedNativeQueries: - findAll: - resultSetMapping: mappingFindAll - query: SELECT * FROM addresses - sqlResultSetMappings: - mappingFindAll: - name: mappingFindAll - entityResult: - address: - entityClass: Address - In this example, we only describe the entity member of the result set mapping. The property / column mappings is done using the entity mapping values. @@ -760,41 +704,6 @@ followed by a dot ("."), followed by the name or the field or property of the pr - .. code-block:: yaml - - MyProject\Model\User: - type: entity - namedNativeQueries: - fetchJoinedAddress: - name: fetchJoinedAddress - resultSetMapping: mappingJoinedAddress - query: SELECT u.id, u.name, u.status, a.id AS a_id, a.country AS a_country, a.zip AS a_zip, a.city AS a_city FROM users u INNER JOIN addresses a ON u.id = a.user_id WHERE u.username = ? - sqlResultSetMappings: - mappingJoinedAddress: - entityResult: - 0: - entityClass: __CLASS__ - fieldResult: - 0: - name: id - 1: - name: name - 2: - name: status - 3: - name: address.id - column: a_id - 4: - name: address.zip - column: a_zip - 5: - name: address.city - column: a_city - 6: - name: address.country - column: a_country - - If you retrieve a single entity and if you use the default mapping, you can use the resultClass attribute instead of resultSetMapping: @@ -830,16 +739,6 @@ you can use the resultClass attribute instead of resultSetMapping: - .. code-block:: yaml - - MyProject\Model\Address: - type: entity - namedNativeQueries: - findAll: - name: findAll - resultClass: Address - query: SELECT * FROM addresses - In some of your native queries, you'll have to return scalar values, for example when building report queries. @@ -890,18 +789,3 @@ You actually can even mix, entities and scalar returns in the same native query - .. code-block:: yaml - - MyProject\Model\Address: - type: entity - namedNativeQueries: - count: - name: count - resultSetMapping: mappingCount - query: SELECT COUNT(*) AS count FROM addresses - sqlResultSetMappings: - mappingCount: - name: mappingCount - columnResult: - count: - name: count diff --git a/docs/en/reference/second-level-cache.rst b/docs/en/reference/second-level-cache.rst index bf7153612bc..29327a9cd0f 100644 --- a/docs/en/reference/second-level-cache.rst +++ b/docs/en/reference/second-level-cache.rst @@ -325,24 +325,6 @@ level cache region. - .. code-block:: yaml - - Country: - type: entity - cache: - usage : READ_ONLY - region : my_entity_region - id: - id: - type: integer - id: true - generator: - strategy: IDENTITY - fields: - name: - type: string - - Association cache definition ---------------------------- The most common use case is to cache entities. But we can also cache relationships. @@ -416,39 +398,6 @@ It caches the primary keys of association and cache each element will be cached - .. code-block:: yaml - - State: - type: entity - cache: - usage : NONSTRICT_READ_WRITE - id: - id: - type: integer - id: true - generator: - strategy: IDENTITY - fields: - name: - type: string - - manyToOne: - state: - targetEntity: Country - joinColumns: - country_id: - referencedColumnName: id - cache: - usage : NONSTRICT_READ_WRITE - - oneToMany: - cities: - targetEntity:City - mappedBy: state - cache: - usage : NONSTRICT_READ_WRITE - - > Note: for this to work, the target entity must also be marked as cacheable. Cache usage diff --git a/docs/en/reference/transactions-and-concurrency.rst b/docs/en/reference/transactions-and-concurrency.rst index c32ea898982..95f6e73c3cd 100644 --- a/docs/en/reference/transactions-and-concurrency.rst +++ b/docs/en/reference/transactions-and-concurrency.rst @@ -208,15 +208,6 @@ example we'll use an integer. - .. code-block:: yaml - - User: - type: entity - fields: - version: - type: integer - version: true - Alternatively a datetime type can be used (which maps to a SQL timestamp or datetime): @@ -241,15 +232,6 @@ timestamp or datetime): - .. code-block:: yaml - - User: - type: entity - fields: - version: - type: datetime - version: true - Version numbers (not timestamps) should however be preferred as they can not potentially conflict in a highly concurrent environment, unlike timestamps where this is a possibility, @@ -405,5 +387,3 @@ You can use pessimistic locks in three different scenarios: ``Query#setLockMode(\Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE)`` or ``Query#setLockMode(\Doctrine\DBAL\LockMode::PESSIMISTIC_READ)`` - - diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index 2364530ec78..fecab1347a8 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -833,7 +833,7 @@ By default the EntityManager returns a default implementation of ``Doctrine\ORM\EntityRepository`` when you call ``EntityManager#getRepository($entityClass)``. You can overwrite this behaviour by specifying the class name of your own Entity -Repository in the Annotation, XML or YAML metadata. In large +Repository in the Annotation or XML metadata. In large applications that require lots of specialized DQL queries using a custom repository is one recommended way of grouping these queries in a central location. @@ -871,5 +871,3 @@ You can access your repository now by calling: // $em instanceof EntityManager $admins = $em->getRepository('MyDomain\Model\User')->getAllAdminUsers(); - - diff --git a/docs/en/reference/yaml-mapping.rst b/docs/en/reference/yaml-mapping.rst deleted file mode 100644 index 8199406ebe7..00000000000 --- a/docs/en/reference/yaml-mapping.rst +++ /dev/null @@ -1,158 +0,0 @@ -YAML Mapping -============ - -.. note:: - The YAML driver is deprecated and will be removed in version 3.0. - It is strongly recommended to switch to one of the other mappings. - -The YAML mapping driver enables you to provide the ORM metadata in -form of YAML documents. - -The YAML mapping document of a class is loaded on-demand the first -time it is requested and subsequently stored in the metadata cache. -In order to work, this requires certain conventions: - - -- Each entity/mapped superclass must get its own dedicated YAML - mapping document. -- The name of the mapping document must consist of the fully - qualified name of the class, where namespace separators are - replaced by dots (.). -- All mapping documents should get the extension ".dcm.yml" to - identify it as a Doctrine mapping file. This is more of a - convention and you are not forced to do this. You can change the - file extension easily enough. - -.. code-block:: php - - setFileExtension('.yml'); - -It is recommended to put all YAML mapping documents in a single -folder but you can spread the documents over several folders if you -want to. In order to tell the YamlDriver where to look for your -mapping documents, supply an array of paths as the first argument -of the constructor, like this: - -.. code-block:: php - - setMetadataDriverImpl($driver); - -Simplified YAML Driver -~~~~~~~~~~~~~~~~~~~~~~ - -The Symfony project sponsored a driver that simplifies usage of the YAML Driver. -The changes between the original driver are: - -- File Extension is .orm.yml -- Filenames are shortened, "MyProject\\Entities\\User" will become User.orm.yml -- You can add a global file and add multiple entities in this file. - -Configuration of this client works a little bit different: - -.. code-block:: php - - 'MyProject\Entities', - '/path/to/files2' => 'OtherProject\Entities' - ); - $driver = new \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver($namespaces); - $driver->setGlobalBasename('global'); // global.orm.yml - -Example -------- - -As a quick start, here is a small example document that makes use -of several common elements: - -.. code-block:: yaml - - # Doctrine.Tests.ORM.Mapping.User.dcm.yml - Doctrine\Tests\ORM\Mapping\User: - type: entity - repositoryClass: Doctrine\Tests\ORM\Mapping\UserRepository - table: cms_users - schema: schema_name # The schema the table lies in, for platforms that support schemas (Optional, >= 2.5) - readOnly: true - indexes: - name_index: - columns: [ name ] - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 50 - email: - type: string - length: 32 - column: user_email - unique: true - options: - fixed: true - comment: User's email address - loginCount: - type: integer - column: login_count - nullable: false - options: - unsigned: true - default: 0 - oneToOne: - address: - targetEntity: Address - joinColumn: - name: address_id - referencedColumnName: id - onDelete: CASCADE - oneToMany: - phonenumbers: - targetEntity: Phonenumber - mappedBy: user - cascade: ["persist", "merge"] - manyToMany: - groups: - targetEntity: Group - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - lifecycleCallbacks: - prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] - postPersist: [ doStuffOnPostPersist ] - -Be aware that class-names specified in the YAML files should be -fully qualified. - -Reference -~~~~~~~~~~~~~~~~~~~~~~ - -Unique Constraints ------------------- - -It is possible to define unique constraints by the following declaration: - -.. code-block:: yaml - - # ECommerceProduct.orm.yml - ECommerceProduct: - type: entity - fields: - # definition of some fields - uniqueConstraints: - search_idx: - columns: [ name, email ] - diff --git a/docs/en/sidebar.rst b/docs/en/sidebar.rst index 26c3a702d31..b2f8d219c79 100644 --- a/docs/en/sidebar.rst +++ b/docs/en/sidebar.rst @@ -44,7 +44,6 @@ reference/annotations-reference reference/attributes-reference reference/xml-mapping - reference/yaml-mapping reference/php-mapping reference/caching reference/improving-performance diff --git a/docs/en/toc.rst b/docs/en/toc.rst index f5e9330ad5b..ccacd8d40fe 100644 --- a/docs/en/toc.rst +++ b/docs/en/toc.rst @@ -46,7 +46,6 @@ Reference Guide reference/annotations-reference reference/attributes-reference reference/xml-mapping - reference/yaml-mapping reference/php-mapping reference/caching reference/improving-performance @@ -84,4 +83,3 @@ Cookbook cookbook/mysql-enums cookbook/advanced-field-value-conversion-using-custom-mapping-types cookbook/entities-in-session - diff --git a/docs/en/tutorials/composite-primary-keys.rst b/docs/en/tutorials/composite-primary-keys.rst index 12ad55e53bb..b031007679f 100644 --- a/docs/en/tutorials/composite-primary-keys.rst +++ b/docs/en/tutorials/composite-primary-keys.rst @@ -69,16 +69,6 @@ and year of production as primary keys: - .. code-block:: yaml - - VehicleCatalogue\Model\Car: - type: entity - id: - name: - type: string - year: - type: integer - Now you can use this entity: .. code-block:: php @@ -133,7 +123,6 @@ The semantics of mapping identity through foreign entities are easy: - Only allowed on Many-To-One or One-To-One associations. - Plug an ``@Id`` annotation onto every association. - Set an attribute ``association-key`` with the field name of the association in XML. -- Set a key ``associationKey:`` with the field name of the association in YAML. Use-Case 1: Dynamic Attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -210,24 +199,6 @@ We keep up the example of an Article with arbitrary attributes, the mapping look - .. code-block:: yaml - - Application\Model\ArticleAttribute: - type: entity - id: - article: - associationKey: true - attribute: - type: string - fields: - value: - type: string - manyToOne: - article: - targetEntity: Article - inversedBy: attributes - - Use-Case 2: Simple Derived Identity ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -258,26 +229,6 @@ One good example for this is a user-address relationship: private $user; } - .. code-block:: yaml - - User: - type: entity - id: - id: - type: integer - generator: - strategy: AUTO - - Address: - type: entity - id: - user: - associationKey: true - oneToOne: - user: - targetEntity: User - - Use-Case 3: Join-Table with Metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/en/tutorials/embeddables.rst b/docs/en/tutorials/embeddables.rst index 483e58d9da6..ea7a8f7b6e7 100644 --- a/docs/en/tutorials/embeddables.rst +++ b/docs/en/tutorials/embeddables.rst @@ -59,22 +59,6 @@ instead of simply adding the respective columns to the ``User`` class. - .. code-block:: yaml - - User: - type: entity - embedded: - address: - class: Address - - Address: - type: embeddable - fields: - street: { type: string } - postalCode: { type: string } - city: { type: string } - country: { type: string } - In terms of your database schema, Doctrine will automatically inline all columns from the ``Address`` class into the table of the ``User`` class, just as if you had declared them directly there. @@ -126,15 +110,6 @@ The following example shows you how to set your prefix to ``myPrefix_``: - .. code-block:: yaml - - User: - type: entity - embedded: - address: - class: Address - columnPrefix: myPrefix_ - To have Doctrine drop the prefix and use the value object's property name directly, set ``columnPrefix=false`` (``use-column-prefix="false"`` for XML): @@ -151,15 +126,6 @@ directly, set ``columnPrefix=false`` (``use-column-prefix="false"`` for XML): private $address; } - .. code-block:: yaml - - User: - type: entity - embedded: - address: - class: Address - columnPrefix: false - .. code-block:: xml @@ -176,4 +142,3 @@ as if they were declared in the ``User`` class: .. code-block:: sql SELECT u FROM User u WHERE u.address.city = :myCity - diff --git a/docs/en/tutorials/extra-lazy-associations.rst b/docs/en/tutorials/extra-lazy-associations.rst index 28fb479609c..63615ee1479 100644 --- a/docs/en/tutorials/extra-lazy-associations.rst +++ b/docs/en/tutorials/extra-lazy-associations.rst @@ -81,15 +81,3 @@ switch to extra lazy as shown in these examples: - - .. code-block:: yaml - - Doctrine\Tests\Models\CMS\CmsGroup: - type: entity - # ... - manyToMany: - users: - targetEntity: CmsUser - mappedBy: groups - fetch: EXTRA_LAZY - diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index 846264331e7..d9308141f19 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -83,7 +83,6 @@ that directory with the following contents: "require": { "doctrine/orm": "^2.10.2", "doctrine/dbal": "^3.1.1", - "symfony/yaml": "2.*", "symfony/cache": "^5.3" }, "autoload": { @@ -107,12 +106,8 @@ Add the following directories: doctrine2-tutorial |-- config | `-- xml - | `-- yaml `-- src -.. note:: - The YAML driver is deprecated and will be removed in version 3.0. - It is strongly recommended to switch to one of the other mappings. .. note:: It is strongly recommended that you require ``doctrine/dbal`` in your ``composer.json`` as well, because using the ORM means mapping objects @@ -147,9 +142,8 @@ step: $cache = null; $useSimpleAnnotationReader = false; $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode, $proxyDir, $cache, $useSimpleAnnotationReader); - // or if you prefer yaml or XML + // or if you prefer XML // $config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode); - // $config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode); // database configuration parameters $conn = array( @@ -160,10 +154,6 @@ step: // obtaining the entity manager $entityManager = EntityManager::create($conn, $config); -.. note:: - The YAML driver is deprecated and will be removed in version 3.0. - It is strongly recommended to switch to one of the other mappings. - .. note:: It is recommended not to use the SimpleAnnotationReader because its usage will be removed for version 3.0. @@ -487,7 +477,7 @@ language describes how entities, their properties and references should be persisted and what constraints should be applied to them. Metadata for an Entity can be configured using DocBlock annotations directly -in the Entity class itself, or in an external XML or YAML file. This Getting +in the Entity class itself, or in an external XML file. This Getting Started guide will demonstrate metadata mappings using all three methods, but you only need to choose one. @@ -537,25 +527,6 @@ but you only need to choose one. -.. note:: - The YAML driver is deprecated and will be removed in version 3.0. - It is strongly recommended to switch to one of the other mappings. - - .. code-block:: yaml - - # config/yaml/Product.dcm.yml - Product: - type: entity - table: products - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - The top-level ``entity`` definition specifies information about the class and table name. The primitive type ``Product#name`` is defined as a ``field`` attribute. The ``id`` property is defined with @@ -1109,40 +1080,6 @@ the ``Product`` before: -.. note:: - The YAML driver is deprecated and will be removed in version 3.0. - It is strongly recommended to switch to one of the other mappings. - - .. code-block:: yaml - - # config/yaml/Bug.dcm.yml - Bug: - type: entity - table: bugs - id: - id: - type: integer - generator: - strategy: AUTO - fields: - description: - type: text - created: - type: datetime - status: - type: string - manyToOne: - reporter: - targetEntity: User - inversedBy: reportedBugs - engineer: - targetEntity: User - inversedBy: assignedBugs - manyToMany: - products: - targetEntity: Product - - Here we have the entity, id and primitive type definitions. For the "created" field we have used the ``datetime`` type, which translates the YYYY-mm-dd HH:mm:ss database format @@ -1231,32 +1168,6 @@ Finally, we'll add metadata mappings for the ``User`` entity. -.. note:: - The YAML driver is deprecated and will be removed in version 3.0. - It is strongly recommended to switch to one of the other mappings. - - .. code-block:: yaml - - # config/yaml/User.dcm.yml - User: - type: entity - table: users - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - oneToMany: - reportedBugs: - targetEntity: Bug - mappedBy: reporter - assignedBugs: - targetEntity: Bug - mappedBy: engineer - Here are some new things to mention about the ``one-to-many`` tags. Remember that we discussed about the inverse and owning side. Now both reportedBugs and assignedBugs are inverse relations, which @@ -1767,16 +1678,6 @@ we have to adjust the metadata slightly. -.. note:: - The YAML driver is deprecated and will be removed in version 3.0. - It is strongly recommended to switch to one of the other mappings. - - .. code-block:: yaml - - Bug: - type: entity - repositoryClass: BugRepository - Now we can remove our query logic in all the places and instead use them through the EntityRepository. As an example here is the code of the first use case "List of Bugs": diff --git a/docs/en/tutorials/ordered-associations.rst b/docs/en/tutorials/ordered-associations.rst index cb0e64a498a..7945a72b73f 100644 --- a/docs/en/tutorials/ordered-associations.rst +++ b/docs/en/tutorials/ordered-associations.rst @@ -41,23 +41,6 @@ can specify the ``@OrderBy`` in the following way: - .. code-block:: yaml - - User: - type: entity - manyToMany: - groups: - orderBy: { 'name': 'ASC' } - targetEntity: Group - joinTable: - name: users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - The DQL Snippet in OrderBy is only allowed to consist of unqualified, unquoted field names and of an optional ASC/DESC positional statement. Multiple Fields are separated by a comma (,). @@ -106,5 +89,3 @@ You can reverse the order with an explicit DQL ORDER BY: .. code-block:: sql SELECT u, g FROM User u JOIN u.groups g WHERE u.id = 10 ORDER BY g.name DESC, g.name ASC - - diff --git a/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst b/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst index de9f0d993da..02c77e5e3da 100644 --- a/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst +++ b/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst @@ -89,4 +89,4 @@ The case for just extending a class would be just the same but: // ... } -Overriding is also supported via XML and YAML (:ref:`examples `). +Overriding is also supported via XML (:ref:`examples `). diff --git a/docs/en/tutorials/working-with-indexed-associations.rst b/docs/en/tutorials/working-with-indexed-associations.rst index c38b8c5cae6..a26892c7c29 100644 --- a/docs/en/tutorials/working-with-indexed-associations.rst +++ b/docs/en/tutorials/working-with-indexed-associations.rst @@ -25,7 +25,6 @@ You can map indexed associations by adding: * ``indexBy`` attribute to any ``@OneToMany`` or ``@ManyToMany`` annotation. * ``index-by`` attribute to any ```` or ```` xml element. - * ``indexBy:`` key-value pair to any association defined in ``manyToMany:`` or ``oneToMany:`` YAML mapping files. The code and mappings for the Market entity looks like this: @@ -116,24 +115,6 @@ The code and mappings for the Market entity looks like this: - .. 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)`` we pick a stock traded on the particular market by symbol. If this stock doesn't exist an exception is thrown. @@ -201,23 +182,6 @@ here are the code and mappings for it: - .. code-block:: yaml - - Doctrine\Tests\Models\StockExchange\Stock: - type: entity - id: - id: - type: integer - generator: - strategy: AUTO - fields: - symbol: - type: string - manyToOne: - market: - targetEntity: Market - inversedBy: stocks - Querying indexed associations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/Doctrine/ORM/Events.php b/lib/Doctrine/ORM/Events.php index d2339e97f81..89aadbd6ab4 100644 --- a/lib/Doctrine/ORM/Events.php +++ b/lib/Doctrine/ORM/Events.php @@ -82,7 +82,7 @@ private function __construct() /** * The loadClassMetadata event occurs after the mapping metadata for a class - * has been loaded from a mapping source (annotations/xml/yaml). + * has been loaded from a mapping source (annotations/xml). */ public const loadClassMetadata = 'loadClassMetadata'; diff --git a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php deleted file mode 100644 index 676bc1fb50a..00000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php +++ /dev/null @@ -1,26 +0,0 @@ -children() as $action) { // According to the JPA specifications, XML uses "cascade-persist" // instead of "persist". Here, both variations - // are supported because both YAML and Annotation use "persist" + // are supported because Annotation use "persist" // and we want to make sure that this driver doesn't need to know // anything about the supported cascading actions $cascades[] = str_replace('cascade-', '', $action->getName()); diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php deleted file mode 100644 index 28d69f2ac3e..00000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ /dev/null @@ -1,898 +0,0 @@ -getElement($className); - - if ($element['type'] === 'entity') { - if (isset($element['repositoryClass'])) { - $metadata->setCustomRepositoryClass($element['repositoryClass']); - } - - if (isset($element['readOnly']) && $element['readOnly'] === true) { - $metadata->markReadOnly(); - } - } elseif ($element['type'] === 'mappedSuperclass') { - $metadata->setCustomRepositoryClass( - $element['repositoryClass'] ?? null - ); - $metadata->isMappedSuperclass = true; - } elseif ($element['type'] === 'embeddable') { - $metadata->isEmbeddedClass = true; - } else { - throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className); - } - - // Evaluate root level properties - $primaryTable = []; - - if (isset($element['table'])) { - $primaryTable['name'] = $element['table']; - } - - if (isset($element['schema'])) { - $primaryTable['schema'] = $element['schema']; - } - - // Evaluate second level cache - if (isset($element['cache'])) { - $metadata->enableCache($this->cacheToArray($element['cache'])); - } - - $metadata->setPrimaryTable($primaryTable); - - // Evaluate named queries - if (isset($element['namedQueries'])) { - foreach ($element['namedQueries'] as $name => $queryMapping) { - if (is_string($queryMapping)) { - $queryMapping = ['query' => $queryMapping]; - } - - if (! isset($queryMapping['name'])) { - $queryMapping['name'] = $name; - } - - $metadata->addNamedQuery($queryMapping); - } - } - - // Evaluate named native queries - if (isset($element['namedNativeQueries'])) { - foreach ($element['namedNativeQueries'] as $name => $mappingElement) { - if (! isset($mappingElement['name'])) { - $mappingElement['name'] = $name; - } - - $metadata->addNamedNativeQuery( - [ - 'name' => $mappingElement['name'], - 'query' => $mappingElement['query'] ?? null, - 'resultClass' => $mappingElement['resultClass'] ?? null, - 'resultSetMapping' => $mappingElement['resultSetMapping'] ?? null, - ] - ); - } - } - - // Evaluate sql result set mappings - if (isset($element['sqlResultSetMappings'])) { - foreach ($element['sqlResultSetMappings'] as $name => $resultSetMapping) { - if (! isset($resultSetMapping['name'])) { - $resultSetMapping['name'] = $name; - } - - $entities = []; - $columns = []; - if (isset($resultSetMapping['entityResult'])) { - foreach ($resultSetMapping['entityResult'] as $entityResultElement) { - $entityResult = [ - 'fields' => [], - 'entityClass' => $entityResultElement['entityClass'] ?? null, - 'discriminatorColumn' => $entityResultElement['discriminatorColumn'] ?? null, - ]; - - if (isset($entityResultElement['fieldResult'])) { - foreach ($entityResultElement['fieldResult'] as $fieldResultElement) { - $entityResult['fields'][] = [ - 'name' => $fieldResultElement['name'] ?? null, - 'column' => $fieldResultElement['column'] ?? null, - ]; - } - } - - $entities[] = $entityResult; - } - } - - if (isset($resultSetMapping['columnResult'])) { - foreach ($resultSetMapping['columnResult'] as $columnResultAnnot) { - $columns[] = [ - 'name' => $columnResultAnnot['name'] ?? null, - ]; - } - } - - $metadata->addSqlResultSetMapping( - [ - 'name' => $resultSetMapping['name'], - 'entities' => $entities, - 'columns' => $columns, - ] - ); - } - } - - if (isset($element['inheritanceType'])) { - $metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType']))); - - if ($metadata->inheritanceType !== Metadata::INHERITANCE_TYPE_NONE) { - // Evaluate discriminatorColumn - if (isset($element['discriminatorColumn'])) { - $discrColumn = $element['discriminatorColumn']; - $metadata->setDiscriminatorColumn( - [ - 'name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, - 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string', - 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : 255, - 'columnDefinition' => isset($discrColumn['columnDefinition']) ? (string) $discrColumn['columnDefinition'] : null, - ] - ); - } else { - $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]); - } - - // Evaluate discriminatorMap - if (isset($element['discriminatorMap'])) { - $metadata->setDiscriminatorMap($element['discriminatorMap']); - } - } - } - - // Evaluate changeTrackingPolicy - if (isset($element['changeTrackingPolicy'])) { - $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' - . strtoupper($element['changeTrackingPolicy']))); - } - - // Evaluate indexes - if (isset($element['indexes'])) { - foreach ($element['indexes'] as $name => $indexYml) { - if (! isset($indexYml['name'])) { - $indexYml['name'] = $name; - } - - $index = []; - - if (isset($indexYml['columns'])) { - if (is_string($indexYml['columns'])) { - $index['columns'] = array_map('trim', explode(',', $indexYml['columns'])); - } else { - $index['columns'] = $indexYml['columns']; - } - } - - if (isset($indexYml['fields'])) { - if (is_string($indexYml['fields'])) { - $index['fields'] = array_map('trim', explode(',', $indexYml['fields'])); - } else { - $index['fields'] = $indexYml['fields']; - } - } - - if ( - isset($index['columns'], $index['fields']) - || ( - ! isset($index['columns']) - && ! isset($index['fields']) - ) - ) { - throw MappingException::invalidIndexConfiguration( - $className, - $indexYml['name'] - ); - } - - if (isset($indexYml['flags'])) { - if (is_string($indexYml['flags'])) { - $index['flags'] = array_map('trim', explode(',', $indexYml['flags'])); - } else { - $index['flags'] = $indexYml['flags']; - } - } - - if (isset($indexYml['options'])) { - $index['options'] = $indexYml['options']; - } - - $metadata->table['indexes'][$indexYml['name']] = $index; - } - } - - // Evaluate uniqueConstraints - if (isset($element['uniqueConstraints'])) { - foreach ($element['uniqueConstraints'] as $name => $uniqueYml) { - if (! isset($uniqueYml['name'])) { - $uniqueYml['name'] = $name; - } - - $unique = []; - - if (isset($uniqueYml['columns'])) { - if (is_string($uniqueYml['columns'])) { - $unique['columns'] = array_map('trim', explode(',', $uniqueYml['columns'])); - } else { - $unique['columns'] = $uniqueYml['columns']; - } - } - - if (isset($uniqueYml['fields'])) { - if (is_string($uniqueYml['fields'])) { - $unique['fields'] = array_map('trim', explode(',', $uniqueYml['fields'])); - } else { - $unique['fields'] = $uniqueYml['fields']; - } - } - - if ( - isset($unique['columns'], $unique['fields']) - || ( - ! isset($unique['columns']) - && ! isset($unique['fields']) - ) - ) { - throw MappingException::invalidUniqueConstraintConfiguration( - $className, - $uniqueYml['name'] - ); - } - - if (isset($uniqueYml['options'])) { - $unique['options'] = $uniqueYml['options']; - } - - $metadata->table['uniqueConstraints'][$uniqueYml['name']] = $unique; - } - } - - if (isset($element['options'])) { - $metadata->table['options'] = $element['options']; - } - - $associationIds = []; - if (isset($element['id'])) { - // Evaluate identifier settings - foreach ($element['id'] as $name => $idElement) { - if (isset($idElement['associationKey']) && $idElement['associationKey'] === true) { - $associationIds[$name] = true; - continue; - } - - $mapping = [ - 'id' => true, - 'fieldName' => $name, - ]; - - if (isset($idElement['type'])) { - $mapping['type'] = $idElement['type']; - } - - if (isset($idElement['column'])) { - $mapping['columnName'] = $idElement['column']; - } - - if (isset($idElement['length'])) { - $mapping['length'] = $idElement['length']; - } - - if (isset($idElement['columnDefinition'])) { - $mapping['columnDefinition'] = $idElement['columnDefinition']; - } - - if (isset($idElement['options'])) { - $mapping['options'] = $idElement['options']; - } - - $metadata->mapField($mapping); - - if (isset($idElement['generator'])) { - $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' - . strtoupper($idElement['generator']['strategy']))); - } - - // Check for SequenceGenerator definition - if (isset($idElement['sequenceGenerator'])) { - $metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']); - } elseif (isset($idElement['customIdGenerator'])) { - $customGenerator = $idElement['customIdGenerator']; - $metadata->setCustomGeneratorDefinition( - [ - 'class' => (string) $customGenerator['class'], - ] - ); - } - } - } - - // Evaluate fields - if (isset($element['fields'])) { - foreach ($element['fields'] as $name => $fieldMapping) { - $mapping = $this->columnToArray($name, $fieldMapping); - - if (isset($fieldMapping['id'])) { - $mapping['id'] = true; - if (isset($fieldMapping['generator']['strategy'])) { - $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' - . strtoupper($fieldMapping['generator']['strategy']))); - } - } - - if (isset($mapping['version'])) { - $metadata->setVersionMapping($mapping); - unset($mapping['version']); - } - - $metadata->mapField($mapping); - } - } - - if (isset($element['embedded'])) { - foreach ($element['embedded'] as $name => $embeddedMapping) { - $mapping = [ - 'fieldName' => $name, - 'class' => $embeddedMapping['class'] ?? null, - 'columnPrefix' => $embeddedMapping['columnPrefix'] ?? null, - ]; - $metadata->mapEmbedded($mapping); - } - } - - // Evaluate oneToOne relationships - if (isset($element['oneToOne'])) { - foreach ($element['oneToOne'] as $name => $oneToOneElement) { - $mapping = [ - 'fieldName' => $name, - 'targetEntity' => $oneToOneElement['targetEntity'] ?? null, - ]; - - if (isset($associationIds[$mapping['fieldName']])) { - $mapping['id'] = true; - } - - if (isset($oneToOneElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $oneToOneElement['fetch']); - } - - if (isset($oneToOneElement['mappedBy'])) { - $mapping['mappedBy'] = $oneToOneElement['mappedBy']; - } else { - if (isset($oneToOneElement['inversedBy'])) { - $mapping['inversedBy'] = $oneToOneElement['inversedBy']; - } - - $joinColumns = []; - - if (isset($oneToOneElement['joinColumn'])) { - $joinColumns[] = $this->joinColumnToArray($oneToOneElement['joinColumn']); - } elseif (isset($oneToOneElement['joinColumns'])) { - foreach ($oneToOneElement['joinColumns'] as $joinColumnName => $joinColumnElement) { - if (! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $joinColumnName; - } - - $joinColumns[] = $this->joinColumnToArray($joinColumnElement); - } - } - - $mapping['joinColumns'] = $joinColumns; - } - - if (isset($oneToOneElement['cascade'])) { - $mapping['cascade'] = $oneToOneElement['cascade']; - } - - if (isset($oneToOneElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool) $oneToOneElement['orphanRemoval']; - } - - // Evaluate second level cache - if (isset($oneToOneElement['cache'])) { - $mapping['cache'] = $metadata->getAssociationCacheDefaults($mapping['fieldName'], $this->cacheToArray($oneToOneElement['cache'])); - } - - $metadata->mapOneToOne($mapping); - } - } - - // Evaluate oneToMany relationships - if (isset($element['oneToMany'])) { - foreach ($element['oneToMany'] as $name => $oneToManyElement) { - $mapping = [ - 'fieldName' => $name, - 'targetEntity' => $oneToManyElement['targetEntity'], - 'mappedBy' => $oneToManyElement['mappedBy'], - ]; - - if (isset($oneToManyElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $oneToManyElement['fetch']); - } - - if (isset($oneToManyElement['cascade'])) { - $mapping['cascade'] = $oneToManyElement['cascade']; - } - - if (isset($oneToManyElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool) $oneToManyElement['orphanRemoval']; - } - - if (isset($oneToManyElement['orderBy'])) { - $mapping['orderBy'] = $oneToManyElement['orderBy']; - } - - if (isset($oneToManyElement['indexBy'])) { - $mapping['indexBy'] = $oneToManyElement['indexBy']; - } - - // Evaluate second level cache - if (isset($oneToManyElement['cache'])) { - $mapping['cache'] = $metadata->getAssociationCacheDefaults($mapping['fieldName'], $this->cacheToArray($oneToManyElement['cache'])); - } - - $metadata->mapOneToMany($mapping); - } - } - - // Evaluate manyToOne relationships - if (isset($element['manyToOne'])) { - foreach ($element['manyToOne'] as $name => $manyToOneElement) { - $mapping = [ - 'fieldName' => $name, - 'targetEntity' => $manyToOneElement['targetEntity'] ?? null, - ]; - - if (isset($associationIds[$mapping['fieldName']])) { - $mapping['id'] = true; - } - - if (isset($manyToOneElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $manyToOneElement['fetch']); - } - - if (isset($manyToOneElement['inversedBy'])) { - $mapping['inversedBy'] = $manyToOneElement['inversedBy']; - } - - $joinColumns = []; - - if (isset($manyToOneElement['joinColumn'])) { - $joinColumns[] = $this->joinColumnToArray($manyToOneElement['joinColumn']); - } elseif (isset($manyToOneElement['joinColumns'])) { - foreach ($manyToOneElement['joinColumns'] as $joinColumnName => $joinColumnElement) { - if (! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $joinColumnName; - } - - $joinColumns[] = $this->joinColumnToArray($joinColumnElement); - } - } - - $mapping['joinColumns'] = $joinColumns; - - if (isset($manyToOneElement['cascade'])) { - $mapping['cascade'] = $manyToOneElement['cascade']; - } - - // Evaluate second level cache - if (isset($manyToOneElement['cache'])) { - $mapping['cache'] = $metadata->getAssociationCacheDefaults($mapping['fieldName'], $this->cacheToArray($manyToOneElement['cache'])); - } - - $metadata->mapManyToOne($mapping); - } - } - - // Evaluate manyToMany relationships - if (isset($element['manyToMany'])) { - foreach ($element['manyToMany'] as $name => $manyToManyElement) { - $mapping = [ - 'fieldName' => $name, - 'targetEntity' => $manyToManyElement['targetEntity'], - ]; - - if (isset($manyToManyElement['fetch'])) { - $mapping['fetch'] = constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $manyToManyElement['fetch']); - } - - if (isset($manyToManyElement['mappedBy'])) { - $mapping['mappedBy'] = $manyToManyElement['mappedBy']; - } elseif (isset($manyToManyElement['joinTable'])) { - $joinTableElement = $manyToManyElement['joinTable']; - $joinTable = [ - 'name' => $joinTableElement['name'], - ]; - - if (isset($joinTableElement['schema'])) { - $joinTable['schema'] = $joinTableElement['schema']; - } - - if (isset($joinTableElement['joinColumns'])) { - foreach ($joinTableElement['joinColumns'] as $joinColumnName => $joinColumnElement) { - if (! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $joinColumnName; - } - - $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement); - } - } - - if (isset($joinTableElement['inverseJoinColumns'])) { - foreach ($joinTableElement['inverseJoinColumns'] as $joinColumnName => $joinColumnElement) { - if (! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $joinColumnName; - } - - $joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement); - } - } - - $mapping['joinTable'] = $joinTable; - } - - if (isset($manyToManyElement['inversedBy'])) { - $mapping['inversedBy'] = $manyToManyElement['inversedBy']; - } - - if (isset($manyToManyElement['cascade'])) { - $mapping['cascade'] = $manyToManyElement['cascade']; - } - - if (isset($manyToManyElement['orderBy'])) { - $mapping['orderBy'] = $manyToManyElement['orderBy']; - } - - if (isset($manyToManyElement['indexBy'])) { - $mapping['indexBy'] = $manyToManyElement['indexBy']; - } - - if (isset($manyToManyElement['orphanRemoval'])) { - $mapping['orphanRemoval'] = (bool) $manyToManyElement['orphanRemoval']; - } - - // Evaluate second level cache - if (isset($manyToManyElement['cache'])) { - $mapping['cache'] = $metadata->getAssociationCacheDefaults($mapping['fieldName'], $this->cacheToArray($manyToManyElement['cache'])); - } - - $metadata->mapManyToMany($mapping); - } - } - - // Evaluate associationOverride - if (isset($element['associationOverride']) && is_array($element['associationOverride'])) { - foreach ($element['associationOverride'] as $fieldName => $associationOverrideElement) { - $override = []; - - // Check for joinColumn - if (isset($associationOverrideElement['joinColumn'])) { - $joinColumns = []; - foreach ($associationOverrideElement['joinColumn'] as $name => $joinColumnElement) { - if (! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $name; - } - - $joinColumns[] = $this->joinColumnToArray($joinColumnElement); - } - - $override['joinColumns'] = $joinColumns; - } - - // Check for joinTable - if (isset($associationOverrideElement['joinTable'])) { - $joinTableElement = $associationOverrideElement['joinTable']; - $joinTable = [ - 'name' => $joinTableElement['name'], - ]; - - if (isset($joinTableElement['schema'])) { - $joinTable['schema'] = $joinTableElement['schema']; - } - - foreach ($joinTableElement['joinColumns'] as $name => $joinColumnElement) { - if (! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $name; - } - - $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement); - } - - foreach ($joinTableElement['inverseJoinColumns'] as $name => $joinColumnElement) { - if (! isset($joinColumnElement['name'])) { - $joinColumnElement['name'] = $name; - } - - $joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement); - } - - $override['joinTable'] = $joinTable; - } - - // Check for inversedBy - if (isset($associationOverrideElement['inversedBy'])) { - $override['inversedBy'] = (string) $associationOverrideElement['inversedBy']; - } - - // Check for `fetch` - if (isset($associationOverrideElement['fetch'])) { - $override['fetch'] = constant(Metadata::class . '::FETCH_' . $associationOverrideElement['fetch']); - } - - $metadata->setAssociationOverride($fieldName, $override); - } - } - - // Evaluate associationOverride - if (isset($element['attributeOverride']) && is_array($element['attributeOverride'])) { - foreach ($element['attributeOverride'] as $fieldName => $attributeOverrideElement) { - $mapping = $this->columnToArray($fieldName, $attributeOverrideElement); - $metadata->setAttributeOverride($fieldName, $mapping); - } - } - - // Evaluate lifeCycleCallbacks - if (isset($element['lifecycleCallbacks'])) { - foreach ($element['lifecycleCallbacks'] as $type => $methods) { - foreach ($methods as $method) { - $metadata->addLifecycleCallback($method, constant('Doctrine\ORM\Events::' . $type)); - } - } - } - - // Evaluate entityListeners - if (isset($element['entityListeners'])) { - foreach ($element['entityListeners'] as $className => $entityListener) { - // Evaluate the listener using naming convention. - if (empty($entityListener)) { - EntityListenerBuilder::bindEntityListener($metadata, $className); - - continue; - } - - foreach ($entityListener as $eventName => $callbackElement) { - foreach ($callbackElement as $methodName) { - $metadata->addEntityListener($eventName, $className, $methodName); - } - } - } - } - } - - /** - * Constructs a joinColumn mapping array based on the information - * found in the given join column element. - * - * @psalm-param array{ - * referencedColumnName?: mixed, - * name?: mixed, - * fieldName?: mixed, - * unique?: mixed, - * nullable?: mixed, - * onDelete?: mixed, - * columnDefinition?: mixed - * } $joinColumnElement The array join column element. - * - * @return mixed[] The mapping array. - * @psalm-return array{ - * referencedColumnName?: string, - * name?: string, - * fieldName?: string, - * unique?: bool, - * nullable?: bool, - * onDelete?: mixed, - * columnDefinition?: mixed - * } - */ - private function joinColumnToArray(array $joinColumnElement): array - { - $joinColumn = []; - if (isset($joinColumnElement['referencedColumnName'])) { - $joinColumn['referencedColumnName'] = (string) $joinColumnElement['referencedColumnName']; - } - - if (isset($joinColumnElement['name'])) { - $joinColumn['name'] = (string) $joinColumnElement['name']; - } - - if (isset($joinColumnElement['fieldName'])) { - $joinColumn['fieldName'] = (string) $joinColumnElement['fieldName']; - } - - if (isset($joinColumnElement['unique'])) { - $joinColumn['unique'] = (bool) $joinColumnElement['unique']; - } - - if (isset($joinColumnElement['nullable'])) { - $joinColumn['nullable'] = (bool) $joinColumnElement['nullable']; - } - - if (isset($joinColumnElement['onDelete'])) { - $joinColumn['onDelete'] = $joinColumnElement['onDelete']; - } - - if (isset($joinColumnElement['columnDefinition'])) { - $joinColumn['columnDefinition'] = $joinColumnElement['columnDefinition']; - } - - return $joinColumn; - } - - /** - * Parses the given column as array. - * - * @psalm-param array{ - * type?: string, - * column?: string, - * precision?: mixed, - * scale?: mixed, - * unique?: mixed, - * options?: mixed, - * nullable?: mixed, - * version?: mixed, - * columnDefinition?: mixed - * }|null $column - * - * @return mixed[] - * @psalm-return array{ - * fieldName: string, - * type?: string, - * columnName?: string, - * length?: int, - * precision?: mixed, - * scale?: mixed, - * unique?: bool, - * options?: mixed, - * nullable?: mixed, - * version?: mixed, - * columnDefinition?: mixed - * } - */ - private function columnToArray(string $fieldName, ?array $column): array - { - $mapping = ['fieldName' => $fieldName]; - - if (isset($column['type'])) { - $params = explode('(', $column['type']); - - $column['type'] = $params[0]; - $mapping['type'] = $column['type']; - - if (isset($params[1])) { - $column['length'] = (int) substr($params[1], 0, strlen($params[1]) - 1); - } - } - - if (isset($column['column'])) { - $mapping['columnName'] = $column['column']; - } - - if (isset($column['length'])) { - $mapping['length'] = $column['length']; - } - - if (isset($column['precision'])) { - $mapping['precision'] = $column['precision']; - } - - if (isset($column['scale'])) { - $mapping['scale'] = $column['scale']; - } - - if (isset($column['unique'])) { - $mapping['unique'] = (bool) $column['unique']; - } - - if (isset($column['options'])) { - $mapping['options'] = $column['options']; - } - - if (isset($column['nullable'])) { - $mapping['nullable'] = $column['nullable']; - } - - if (isset($column['version']) && $column['version']) { - $mapping['version'] = $column['version']; - } - - if (isset($column['columnDefinition'])) { - $mapping['columnDefinition'] = $column['columnDefinition']; - } - - return $mapping; - } - - /** - * Parse / Normalize the cache configuration - * - * @param mixed[] $cacheMapping - * @psalm-param array{usage: mixed, region: (string|null)} $cacheMapping - * @psalm-param array{usage: string, region?: string} $cacheMapping - * - * @return mixed[] - * @psalm-return array{usage: int, region: string|null} - */ - private function cacheToArray(array $cacheMapping): array - { - $region = isset($cacheMapping['region']) ? (string) $cacheMapping['region'] : null; - $usage = isset($cacheMapping['usage']) ? strtoupper($cacheMapping['usage']) : null; - - if ($usage && ! defined('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $usage)) { - throw new InvalidArgumentException(sprintf('Invalid cache usage "%s"', $usage)); - } - - if ($usage) { - $usage = (int) constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $usage); - } - - return [ - 'usage' => $usage, - 'region' => $region, - ]; - } - - /** - * {@inheritDoc} - */ - protected function loadMappingFile($file) - { - return Yaml::parse(file_get_contents($file)); - } -} diff --git a/lib/Doctrine/ORM/Tools/Setup.php b/lib/Doctrine/ORM/Tools/Setup.php index e7ed759bb12..142df9fc45d 100644 --- a/lib/Doctrine/ORM/Tools/Setup.php +++ b/lib/Doctrine/ORM/Tools/Setup.php @@ -13,11 +13,9 @@ use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\Common\Cache\RedisCache; use Doctrine\Common\ClassLoader; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; -use Doctrine\ORM\Mapping\Driver\YamlDriver; use Memcached; use Redis; use RuntimeException; @@ -111,31 +109,6 @@ public static function createXMLMetadataConfiguration(array $paths, $isDevMode = return $config; } - /** - * Creates a configuration with a yaml metadata driver. - * - * @deprecated YAML metadata mapping is deprecated and will be removed in 3.0 - * - * @param mixed[] $paths - * @param bool $isDevMode - * @param string $proxyDir - * - * @return Configuration - */ - public static function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, ?Cache $cache = null) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8465', - 'YAML mapping driver is deprecated and will be removed in Doctrine ORM 3.0, please migrate to attribute or XML driver.' - ); - - $config = self::createConfiguration($isDevMode, $proxyDir, $cache); - $config->setMetadataDriverImpl(new YamlDriver($paths)); - - return $config; - } - /** * Creates a configuration without a metadata driver. * diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 61b9dd5fd58..e02f6bf5257 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -243,7 +243,6 @@ lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php tests/Doctrine/Tests/OrmFunctionalTestCase.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f648bdfe97b..808cb6ac3ff 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -975,166 +975,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$inheritanceType\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$isEmbeddedClass\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$isMappedSuperclass\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$table\\.$#" - count: 3 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addEntityListener\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addLifecycleCallback\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addNamedNativeQuery\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addNamedQuery\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addSqlResultSetMapping\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:enableCache\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:getAssociationCacheDefaults\\(\\)\\.$#" - count: 4 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:mapEmbedded\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:mapField\\(\\)\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:mapManyToMany\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:mapManyToOne\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:mapOneToMany\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:mapOneToOne\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:markReadOnly\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setAssociationOverride\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setAttributeOverride\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setChangeTrackingPolicy\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setCustomGeneratorDefinition\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setCustomRepositoryClass\\(\\)\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setDiscriminatorColumn\\(\\)\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setDiscriminatorMap\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setIdGeneratorType\\(\\)\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setInheritanceType\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setPrimaryTable\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setSequenceGeneratorDefinition\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:setVersionMapping\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Offset 'usage' on array\\{usage\\: string, region\\?\\: string\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - - - message: "#^Parameter \\#1 \\$metadata of static method Doctrine\\\\ORM\\\\Mapping\\\\Builder\\\\EntityListenerBuilder\\:\\:bindEntityListener\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\ given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php - - message: "#^Call to function is_int\\(\\) with string will always evaluate to false\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7f7ff6ef957..81de9db035e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1202,16 +1202,6 @@ $prefixes - - - YamlDriver - parent::__construct($locator, $fileExtension) - - - $fileExtension - $prefixes - - $metadata @@ -1305,91 +1295,6 @@ setVersionMapping - - - $metadata - - - private function cacheToArray(array $cacheMapping): array - - - $fileExtension - $locator - - - $metadata->inheritanceType - $metadata->isEmbeddedClass - $metadata->isMappedSuperclass - $metadata->table - $metadata->table - $metadata->table - - - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - - - $element - $element - $element - $element - $element - $element - $element - $element - $element - $element - addEntityListener - addLifecycleCallback - addNamedNativeQuery - addNamedQuery - addSqlResultSetMapping - enableCache - getAssociationCacheDefaults - getAssociationCacheDefaults - getAssociationCacheDefaults - getAssociationCacheDefaults - mapEmbedded - mapField - mapField - mapManyToMany - mapManyToOne - mapOneToMany - mapOneToOne - markReadOnly - setAssociationOverride - setAttributeOverride - setChangeTrackingPolicy - setCustomGeneratorDefinition - setCustomRepositoryClass - setCustomRepositoryClass - setDiscriminatorColumn - setDiscriminatorColumn - setDiscriminatorMap - setIdGeneratorType - setIdGeneratorType - setInheritanceType - setPrimaryTable - setSequenceGeneratorDefinition - setVersionMapping - - $columnPrefix @@ -3447,10 +3352,9 @@ - + new ClassLoader('Doctrine', $directory) new ClassLoader('Symfony\Component', $directory . '/Doctrine') - new YamlDriver($paths) require_once $directory . '/Doctrine/Common/ClassLoader.php' diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php deleted file mode 100644 index 5cb0d3c5b80..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php +++ /dev/null @@ -1,26 +0,0 @@ -loadDriver(); - $yamlDriver->getLocator()->addPaths([__DIR__ . DIRECTORY_SEPARATOR . 'yaml']); - - $em = $this->getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($yamlDriver); - $factory = new ClassMetadataFactory(); - $factory->setEntityManager($em); - - $classPage = new ClassMetadata(File::class); - $classPage = $factory->getMetadataFor(File::class); - self::assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); - - $classDirectory = new ClassMetadata(Directory::class); - $classDirectory = $factory->getMetadataFor(Directory::class); - self::assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); - } - - /** - * @group DDC-1468 - */ - public function testInvalidMappingFileException(): void - { - $this->expectException('Doctrine\Persistence\Mapping\MappingException'); - $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml\' for class \'Doctrine\Tests\Models\Generic\SerializationModel\'.'); - $this->createClassMetadata(SerializationModel::class); - } - - /** - * @group DDC-2069 - */ - public function testSpacesShouldBeIgnoredWhenUseExplode(): void - { - $metadata = $this->createClassMetadata(DDC2069Entity::class); - $unique = $metadata->table['uniqueConstraints'][0]['columns']; - $indexes = $metadata->table['indexes'][0]['columns']; - - $nameField = $metadata->fieldMappings['name']; - $valueField = $metadata->fieldMappings['value']; - - self::assertEquals('name', $unique[0]); - self::assertEquals('value', $unique[1]); - - self::assertEquals('value', $indexes[0]); - self::assertEquals('name', $indexes[1]); - - self::assertEquals(255, $nameField['length']); - self::assertEquals(255, $valueField['length']); - } -} - -class DDC2069Entity -{ - /** @var int */ - public $id; - - /** @var string */ - public $name; - - /** @var mixed */ - public $value; -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml deleted file mode 100644 index 712f089da99..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.yml +++ /dev/null @@ -1,64 +0,0 @@ -Doctrine\Tests\Models\CMS\CmsAddress: - type: entity - table: cms_address - entityListeners: - CmsAddressListener: ~ - namedNativeQueries: - find-all: - resultSetMapping: mapping-find-all - query: SELECT id, country, city FROM cms_addresses - find-by-id: - name: find-by-id - resultClass: CmsAddress - query: SELECT * FROM cms_addresses WHERE id = ? - count: - name: count - resultSetMapping: mapping-count - query: SELECT COUNT(*) AS count FROM cms_addresses - - sqlResultSetMappings: - mapping-find-all: - entityResult: - address: - entityClass: CmsAddress - fieldResult: - 0: - name: id - column: id - 1: - name: city - column: city - 2: - name: country - column: country - mapping-without-fields: - name: mapping-without-fields - entityResult: - address: - entityClass: CmsAddress - mapping-count: - name: mapping-count - columnResult: - count: - name: count - id: - id: - type: integer - generator: - strategy: AUTO - fields: - country: - type: string - length: 50 - city: - type: string - length: 50 - zip: - type: string - length: 50 - oneToOne: - user: - targetEntity: CmsUser - inversedBy: address - joinColumn: - referencedColumnName: id diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsUser.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsUser.dcm.yml deleted file mode 100644 index 329e3d061dc..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.CMS.CmsUser.dcm.yml +++ /dev/null @@ -1,157 +0,0 @@ -Doctrine\Tests\Models\CMS\CmsUser: - type: entity - table: cms_users - namedQueries: - all: SELECT u FROM __CLASS__ u - namedNativeQueries: - fetchIdAndUsernameWithResultClass: - resultClass: CmsUser - query: SELECT id, username FROM cms_users WHERE username = ? - fetchAllColumns: - name: fetchAllColumns - resultClass: CmsUser - query: SELECT * FROM cms_users WHERE username = ? - fetchJoinedAddress: - name: fetchJoinedAddress - resultSetMapping: mappingJoinedAddress - query: SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ? - fetchJoinedPhonenumber: - name: fetchJoinedPhonenumber - resultSetMapping: mappingJoinedPhonenumber - query: SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ? - fetchUserPhonenumberCount: - name: fetchUserPhonenumberCount - resultSetMapping: mappingUserPhonenumberCount - query: SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username - fetchMultipleJoinsEntityResults: - name: fetchMultipleJoinsEntityResults - resultSetMapping: mappingMultipleJoinsEntityResults - query: SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username - - sqlResultSetMappings: - mappingJoinedAddress: - entityResult: - 0: - entityClass: __CLASS__ - fieldResult: - 0: - name: id - 1: - name: name - 2: - name: status - 3: - name: address.zip - 4: - name: address.city - 5: - name: address.country - 6: - name: address.id - column: a_id - mappingJoinedPhonenumber: - name: mappingJoinedPhonenumber - entityResult: - user: - entityClass: CmsUser - fieldResult: - 0: - name: id - 1: - name: name - 2: - name: status - 3: - name: phonenumbers.phonenumber - column: number - mappingUserPhonenumberCount: - name: mappingUserPhonenumberCount - columnResult: - 0: - name: numphones - entityResult: - user_0: - entityClass: CmsUser - fieldResult: - 0: - name: id - 1: - name: name - 2: - name: status - mappingMultipleJoinsEntityResults: - name: mappingMultipleJoinsEntityResults - columnResult: - 0: - name: numphones - entityResult: - 0: - entityClass: __CLASS__ - fieldResult: - 0: - name: id - column: u_id - 1: - name: name - column: u_name - 2: - name: status - column: u_status - 1: - entityClass: CmsAddress - fieldResult: - 0: - name: id - column: a_id - 1: - name: zip - column: a_zip - 2: - name: country - column: a_country - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 255 - username: - type: string - length: 255 - unique: true - status: - type: string - length: 50 - unique: true - oneToOne: - address: - targetEntity: CmsAddress - orphanRemoval: true - inversedBy: user - joinColumn: - name: address_id - referencedColumnName: id - cascade: [ persist ] - email: - targetEntity: CmsEmail - orphanRemoval: true - inversedBy: user - joinColumn: - nullable: true - referencedColumnName: id - cascade: [ persist ] - manyToMany: - groups: - targetEntity: CmsGroup - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - cascade: [ persist , detach, merge] diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Cache.City.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Cache.City.dcm.yml deleted file mode 100644 index 7bc5e7db171..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Cache.City.dcm.yml +++ /dev/null @@ -1,36 +0,0 @@ -Doctrine\Tests\Models\Cache\City: - type: entity - table: cache_city - cache: - usage : READ_ONLY - id: - id: - type: integer - id: true - generator: - strategy: IDENTITY - fields: - name: - type: string - manyToOne: - state: - targetEntity: Doctrine\Tests\Models\Cache\State - inversedBy: cities - joinColumns: - state_id: - referencedColumnName: id - cache: - usage : READ_ONLY - manyToMany: - travels: - targetEntity: Doctrine\Tests\Models\Cache\Travel - mappedBy: visitedCities - - oneToMany: - attractions: - targetEntity: Doctrine\Tests\Models\Cache\Attraction - mappedBy: city - cache: - usage : READ_ONLY - orderBy: - name: ASC diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyContract.dcm.yml deleted file mode 100644 index 34ea8a4611c..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyContract.dcm.yml +++ /dev/null @@ -1,32 +0,0 @@ -Doctrine\Tests\Models\Company\CompanyContract: - type: entity - table: company_contracts - inheritanceType: SINGLE_TABLE - discriminatorMap: - fix: CompanyFixContract - flexible: CompanyFlexContract - flexultra: CompanyFlexUltraContract - - entityListeners: - CompanyContractListener: - - preFlush: [preFlushHandler] - postLoad: [postLoadHandler] - - postPersist: [postPersistHandler] - prePersist: [prePersistHandler] - - postUpdate: [postUpdateHandler] - preUpdate: [preUpdateHandler] - - postRemove: [postRemoveHandler] - preRemove: [preRemoveHandler] - - id: - id: - type: integer - generator: - strategy: AUTO - fields: - completed: - type: boolean diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.yml deleted file mode 100644 index 99dc79d0501..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\Company\CompanyFixContract: - type: entity - fields: - fixPrice: - type: integer diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.yml deleted file mode 100644 index ada071a83ed..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.yml +++ /dev/null @@ -1,7 +0,0 @@ -Doctrine\Tests\Models\Company\CompanyFlexContract: - type: entity - fields: - hoursWorked: - type: integer - pricePerHour: - type: integer diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.yml deleted file mode 100644 index aecdafe5008..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.yml +++ /dev/null @@ -1,25 +0,0 @@ -Doctrine\Tests\Models\Company\CompanyFlexUltraContract: - type: entity - - entityListeners: - CompanyContractListener: - - preFlush: [preFlushHandler] - postLoad: [postLoadHandler] - - postPersist: [postPersistHandler] - prePersist: [prePersistHandler] - - postUpdate: [postUpdateHandler] - preUpdate: [preUpdateHandler] - - postRemove: [postRemoveHandler] - preRemove: [preRemoveHandler] - - CompanyFlexUltraContractListener: - - prePersist: [prePersistHandler1, prePersistHandler2] - - fields: - maxPrice: - type: integer diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.yml deleted file mode 100644 index 28eec43e391..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.yml +++ /dev/null @@ -1,74 +0,0 @@ -Doctrine\Tests\Models\Company\CompanyPerson: - type: entity - table: company_persons - inheritanceType: JOINED - discriminatorMap: - person: CompanyPerson - manager: CompanyManager - employee: CompanyEmployee - namedNativeQueries: - fetchAllWithResultClass: - resultClass: __CLASS__ - query: SELECT id, name, discr FROM company_persons ORDER BY name - fetchAllWithSqlResultSetMapping: - name: fetchAllWithSqlResultSetMapping - resultSetMapping: mappingFetchAll - query: SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name - - sqlResultSetMappings: - mappingFetchAll: - entityResult: - 0: - entityClass: __CLASS__ - discriminatorColumn: discriminator - fieldResult: - 0: - name: id - 1: - name: name - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 255 - username: - type: string - length: 255 - unique: true - status: - type: string - length: 50 - unique: true - oneToOne: - address: - targetEntity: CmsAddress - orphanRemoval: true - inversedBy: user - joinColumn: - name: address_id - referencedColumnName: id - cascade: [ persist ] - email: - targetEntity: CmsEmail - orphanRemoval: true - inversedBy: user - joinColumn: - nullable: true - referencedColumnName: id - cascade: [ persist ] - manyToMany: - groups: - targetEntity: CmsGroup - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - cascade: [ persist , detach, merge] diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml deleted file mode 100644 index 674328cd526..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml +++ /dev/null @@ -1,8 +0,0 @@ -Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType: - type: entity - id: - id: - generator: - strategy: NONE - fields: - name: ~ diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.yml deleted file mode 100644 index f28adbb61f4..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.yml +++ /dev/null @@ -1,8 +0,0 @@ -Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable: - type: entity - table: explicit_table - schema: explicit_schema - id: - id: - generator: - strategy: AUTO diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.yml deleted file mode 100644 index bf072816cd7..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.yml +++ /dev/null @@ -1,7 +0,0 @@ -Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName: - type: entity - table: implicit_schema.implicit_table - id: - id: - generator: - strategy: AUTO diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.yml deleted file mode 100644 index 7420b14e66d..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\DDC3579\DDC3579Admin: - type: entity - associationOverride: - groups: - inversedBy: admins diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.yml deleted file mode 100644 index 63d095035f3..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.yml +++ /dev/null @@ -1,19 +0,0 @@ -Doctrine\Tests\Models\DDC3579\DDC3579User: - type: mappedSuperclass - id: - id: - type: integer - column: user_id - length: 150 - generator: - strategy: AUTO - fields: - name: - type: string - column: user_name - length: 250 - nullable: true - unique: false - manyToMany: - groups: - targetEntity: DDC3579Group diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3711.DDC3711EntityA.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3711.DDC3711EntityA.dcm.yml deleted file mode 100644 index 1907bcc112a..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3711.DDC3711EntityA.dcm.yml +++ /dev/null @@ -1,23 +0,0 @@ -Doctrine\Tests\Models\DDC3711\DDC3711EntityA: - type: entity - table: ddc3711.entityA - id: - id1: - type: int - id2: - type: int - manyToMany: - entityB: - targetEntity: Doctrine\Tests\Models\DDC3711\DDC3711EntityB - joinTable: - name: link - joinColumns: - link_a_id1: - referencedColumnName: id1 - link_a_id2: - referencedColumnName: id2 - inverseJoinColumns: - link_b_id1: - referencedColumnName: id1 - link_b_id2: - referencedColumnName: id2 diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3711.DDC3711EntityB.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3711.DDC3711EntityB.dcm.yml deleted file mode 100644 index 24ec96932c6..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC3711.DDC3711EntityB.dcm.yml +++ /dev/null @@ -1,8 +0,0 @@ -Doctrine\Tests\Models\DDC3711\DDC3711EntityB: - type: entity - table: ddc3711.entityB - id: - id1: - type: int - id2: - type: int diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.yml deleted file mode 100644 index 2044c9be527..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.yml +++ /dev/null @@ -1,12 +0,0 @@ -Doctrine\Tests\Models\DDC5934\DDC5934BaseContract: - type: mappedSuperclass - id: - id: - type: integer - column: id - generator: - strategy: AUTO - manyToMany: - members: - targetEntity: DDC5934Member - inversedBy: contract diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.yml deleted file mode 100644 index 45ba145853e..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\DDC5934\DDC5934Contract: - type: entity - associationOverride: - members: - fetch: EXTRA_LAZY diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml deleted file mode 100644 index 04eca657401..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\DDC869\DDC869ChequePayment: - type: entity - fields: - serialNumber: - type: string diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml deleted file mode 100644 index 3da249e5c92..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment: - type: entity - fields: - creditCardNumber: - type: string diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml deleted file mode 100644 index fb219451b3e..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml +++ /dev/null @@ -1,12 +0,0 @@ -Doctrine\Tests\Models\DDC869\DDC869Payment: - type: mappedSuperclass - repositoryClass : Doctrine\Tests\Models\DDC869\DDC869PaymentRepository - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO - fields: - value: - type: float diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.yml deleted file mode 100644 index ed94b14c555..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.yml +++ /dev/null @@ -1,8 +0,0 @@ -Doctrine\Tests\Models\DDC889\DDC889Class: - type: class - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.yml deleted file mode 100644 index 404d4a538f1..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.yml +++ /dev/null @@ -1,2 +0,0 @@ -Doctrine\Tests\Models\DDC889\DDC889Entity: - type: entity diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.yml deleted file mode 100644 index aceada9a98f..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.yml +++ /dev/null @@ -1,5 +0,0 @@ -Doctrine\Tests\Models\DDC889\DDC889SuperClass: - type: mappedSuperclass - fields: - name: - type: string diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.yml deleted file mode 100644 index 77823f29224..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.yml +++ /dev/null @@ -1,17 +0,0 @@ -Doctrine\Tests\Models\DDC964\DDC964Admin: - type: entity - associationOverride: - address: - joinColumn: - adminaddress_id: - name: adminaddress_id - referencedColumnName: id - groups: - joinTable: - name: ddc964_users_admingroups - joinColumns: - adminuser_id: - referencedColumnName: id - inverseJoinColumns: - admingroup_id: - referencedColumnName: id diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.yml deleted file mode 100644 index 5c4130e6e59..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.yml +++ /dev/null @@ -1,13 +0,0 @@ -Doctrine\Tests\Models\DDC964\DDC964Guest: - type: entity - attributeOverride: - id: - column: guest_id - type: integer - length: 140 - name: - column: guest_name - type: string - length: 240 - nullable: false - unique: true diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.yml deleted file mode 100644 index 459b642928c..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.yml +++ /dev/null @@ -1,35 +0,0 @@ -Doctrine\Tests\Models\DDC964\DDC964User: - type: mappedSuperclass - id: - id: - type: integer - column: user_id - length: 150 - generator: - strategy: AUTO - fields: - name: - type: string - column: user_name - length: 250 - nullable: true - unique: false - manyToOne: - address: - targetEntity: DDC964Address - joinColumn: - name: address_id - referencedColumnName: id - cascade: [ persist, merge ] - manyToMany: - groups: - targetEntity: DDC964Group - joinTable: - name: ddc964_users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - cascade: [ persist, merge, detach ] diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml deleted file mode 100644 index 9c573a561d2..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml +++ /dev/null @@ -1,14 +0,0 @@ -Doctrine\Tests\Models\DirectoryTree\AbstractContentItem: - type: mappedSuperclass - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO - fields: - name: - type: string - manyToOne: - parentDirectory: - targetEntity: Doctrine\Tests\Models\DirectoryTree\Directory diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml deleted file mode 100644 index d2b93d4901c..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml +++ /dev/null @@ -1,6 +0,0 @@ -Doctrine\Tests\Models\DirectoryTree\Directory: - type: entity - fields: - path: - type: string - length: 255 diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml deleted file mode 100644 index cbc8edfec4f..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml +++ /dev/null @@ -1,6 +0,0 @@ -Doctrine\Tests\Models\DirectoryTree\File: - type: entity - fields: - extension: - type: string - length: 10 diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml deleted file mode 100644 index a20b5725934..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml +++ /dev/null @@ -1,13 +0,0 @@ -\stdClass: - type: entity - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO - fields: - array: - type: array - object: - type: object diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.yml deleted file mode 100644 index 7bc39f55804..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.yml +++ /dev/null @@ -1,28 +0,0 @@ -Doctrine\Tests\Models\TypedProperties\UserTyped: - type: entity - table: cms_users_typed - id: - id: - generator: - strategy: AUTO - fields: - status: - length: 50 - username: - length: 255 - unique: true - dateInterval: ~ - dateTime: ~ - dateTimeImmutable: ~ - array: ~ - boolean: ~ - float: ~ - oneToOne: - email: - cascade: [ persist ] - orphanRemoval: true - joinColumn: [] - manyToOne: - mainEmail: [] - embedded: - contact: ~ diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml deleted file mode 100644 index 7bdad824037..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml +++ /dev/null @@ -1,17 +0,0 @@ -Doctrine\Tests\ORM\Mapping\Animal: - type: entity - inheritanceType: SINGLE_TABLE - discriminatorMap: - cat: Cat - dog: Dog - discriminatorColumn: - type: string - name: discr - length: 32 - id: - id: - type: integer - generator: - strategy: CUSTOM - customIdGenerator: - class: stdClass diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Comment.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Comment.dcm.yml deleted file mode 100644 index f37bfdcc67b..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Comment.dcm.yml +++ /dev/null @@ -1,11 +0,0 @@ -Doctrine\Tests\ORM\Mapping\Comment: - type: entity - fields: - content: - type: text - indexes: - 0: - columns: content - flags: fulltext - options: - where: "content IS NOT NULL" diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml deleted file mode 100644 index e42305d4fdf..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml +++ /dev/null @@ -1,10 +0,0 @@ -Doctrine\Tests\ORM\Mapping\DDC1170Entity: - type: entity - id: - id: - columnDefinition: INT unsigned NOT NULL - generator: - strategy: NONE - fields: - value: - columnDefinition: VARCHAR(255) NOT NULL diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC2069Entity.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC2069Entity.dcm.yml deleted file mode 100644 index 5b16c12bc94..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC2069Entity.dcm.yml +++ /dev/null @@ -1,15 +0,0 @@ -Doctrine\Tests\ORM\Mapping\DDC2069Entity: - type: entity - id: - id: ~ - fields: - name: - type: string ( 255 ) - value: - type: string ( 255 ) - uniqueConstraints: - 0: - columns: name, value - indexes: - 0: - columns: value, name diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.yml deleted file mode 100644 index 624fb54a9bf..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.yml +++ /dev/null @@ -1,13 +0,0 @@ -Doctrine\Tests\ORM\Mapping\DDC807Entity: - type: entity - inheritanceType: SINGLE_TABLE - discriminatorMap: - ONE: DDC807SubClasse1 - TWO: DDC807SubClasse2 - discriminatorColumn: - name: dtype - columnDefinition: ENUM('ONE','TWO') - id: - id: - generator: - strategy: NONE diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.yml deleted file mode 100644 index a315310e4d1..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.yml +++ /dev/null @@ -1,10 +0,0 @@ -Doctrine\Tests\ORM\Mapping\ReservedWordInTableColumn: - type: entity - id: - id: - generator: - strategy: NONE - fields: - count: - type: integer - column: '`count`' diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.yml deleted file mode 100644 index d81bc7a6ae8..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.yml +++ /dev/null @@ -1,12 +0,0 @@ -Doctrine\Tests\ORM\Mapping\SingleTableEntityIncompleteDiscriminatorColumnMapping: - type: entity - inheritanceType: SINGLE_TABLE - discriminatorMap: - ONE: SingleTableEntityIncompleteDiscriminatorColumnMappingSub1 - TWO: SingleTableEntityIncompleteDiscriminatorColumnMappingSub2 - discriminatorColumn: - name: dtype - id: - id: - generator: - strategy: NONE diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.yml deleted file mode 100644 index 25ec79eb9dc..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.yml +++ /dev/null @@ -1,10 +0,0 @@ -Doctrine\Tests\ORM\Mapping\SingleTableEntityNoDiscriminatorColumnMapping: - type: entity - inheritanceType: SINGLE_TABLE - discriminatorMap: - ONE: SingleTableEntityNoDiscriminatorColumnMappingSub1 - TWO: SingleTableEntityNoDiscriminatorColumnMappingSub2 - id: - id: - generator: - strategy: NONE diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml deleted file mode 100644 index d3504ffbaa0..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml +++ /dev/null @@ -1,89 +0,0 @@ -Doctrine\Tests\ORM\Mapping\User: - type: entity - table: cms_users - options: - foo: bar - baz: - key: val - namedQueries: - all: SELECT u FROM __CLASS__ u - id: - id: - type: integer - generator: - strategy: AUTO - sequenceGenerator: - sequenceName: tablename_seq - allocationSize: 100 - initialValue: 1 - options: - foo: bar - unsigned: false - fields: - name: - type: string - length: 50 - nullable: true - unique: true - options: - foo: bar - baz: - key: val - fixed: false - email: - type: string - column: user_email - columnDefinition: CHAR(32) NOT NULL - version: - type: integer - version: true - oneToOne: - address: - targetEntity: Address - inversedBy: user - joinColumn: - name: address_id - referencedColumnName: id - onDelete: CASCADE - cascade: [ remove ] - oneToMany: - phonenumbers: - targetEntity: Phonenumber - orphanRemoval: true - mappedBy: user - orderBy: - number: ASC - cascade: [ persist ] - manyToMany: - groups: - targetEntity: Group - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - nullable: false - unique: false - inverseJoinColumns: - group_id: - referencedColumnName: id - columnDefinition: INT NULL - cascade: - - all - lifecycleCallbacks: - prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] - postPersist: [ doStuffOnPostPersist ] - uniqueConstraints: - search_idx: - columns: name,user_email - options: - where: name IS NOT NULL - phone_idx: - fields: name,phone - indexes: - name_idx: - columns: name - 0: - columns: user_email - fields: - fields: name,email diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.yml deleted file mode 100644 index 06855341204..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.yml +++ /dev/null @@ -1,17 +0,0 @@ -Doctrine\Tests\ORM\Mapping\UserIncorrectIndex: - type: entity - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - email: - type: string - column: user_email - indexes: - name_idx: - columns: name - fields: email diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.yml deleted file mode 100644 index 82f7e72a778..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.yml +++ /dev/null @@ -1,17 +0,0 @@ -Doctrine\Tests\ORM\Mapping\UserIncorrectUniqueConstraint: - type: entity - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - email: - type: string - column: user_email - uniqueConstraints: - name_idx: - columns: name - fields: email diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php index 3622a17816f..fedf9847fd1 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; -use Doctrine\ORM\Mapping\Driver\YamlDriver; use Doctrine\ORM\Tools\Setup; use Doctrine\Tests\OrmTestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -89,14 +88,6 @@ public function testXMLConfiguration(): void self::assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); } - public function testYAMLConfiguration(): void - { - $config = Setup::createYAMLMetadataConfiguration([], true); - - self::assertInstanceOf(Configuration::class, $config); - self::assertInstanceOf(YamlDriver::class, $config->getMetadataDriverImpl()); - } - /** * @group 5904 */ From ff44938f9f9d6dfb17e9f1e848ff2ba2fba8182a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 14 Dec 2021 10:06:46 +0100 Subject: [PATCH 015/475] Remove Setup::registerAutoloadDirectory() (#9251) --- UPGRADE.md | 4 ++++ lib/Doctrine/ORM/Tools/Setup.php | 24 -------------------- psalm-baseline.xml | 9 -------- tests/Doctrine/Tests/ORM/Tools/SetupTest.php | 7 ------ 4 files changed, 4 insertions(+), 40 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index d552004efcf..6f44c12f17c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Remove `Setup::registerAutoloadDirectory()` + +Use Composer's autoloader instead. + ## BC BREAK: Remove YAML mapping drivers. If your code relies on `YamlDriver` or `SimpleYamlDriver`, you **MUST** migrate to diff --git a/lib/Doctrine/ORM/Tools/Setup.php b/lib/Doctrine/ORM/Tools/Setup.php index 071157025df..dcd18618524 100644 --- a/lib/Doctrine/ORM/Tools/Setup.php +++ b/lib/Doctrine/ORM/Tools/Setup.php @@ -12,7 +12,6 @@ use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\Common\Cache\RedisCache; -use Doctrine\Common\ClassLoader; use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; @@ -34,29 +33,6 @@ */ class Setup { - /** - * Use this method to register all autoloads for a downloaded Doctrine library. - * Pick the directory the library was uncompressed into. - * - * @deprecated Use Composer's autoloader instead. - * - * @param string $directory - * - * @return void - */ - public static function registerAutoloadDirectory($directory) - { - if (! class_exists('Doctrine\Common\ClassLoader', false)) { - require_once $directory . '/Doctrine/Common/ClassLoader.php'; - } - - $loader = new ClassLoader('Doctrine', $directory); - $loader->register(); - - $loader = new ClassLoader('Symfony\Component', $directory . '/Doctrine'); - $loader->register(); - } - /** * Creates a configuration with an annotation metadata driver. * diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 0cc8a0371b6..e84d942ac4d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3354,15 +3354,6 @@ isAbstract - - - new ClassLoader('Doctrine', $directory) - new ClassLoader('Symfony\Component', $directory . '/Doctrine') - - - require_once $directory . '/Doctrine/Common/ClassLoader.php' - - $class diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php index fedf9847fd1..d2d3d7e8b84 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -50,13 +50,6 @@ public function tearDown(): void } } - public function testDirectoryAutoload(): void - { - Setup::registerAutoloadDirectory(__DIR__ . '/../../../../../vendor/doctrine/common/lib'); - - self::assertCount($this->originalAutoloaderCount + 2, spl_autoload_functions()); - } - public function testAnnotationConfiguration(): void { $config = Setup::createAnnotationMetadataConfiguration([], true); From f2e34bd17214740f8ad3dcf2367ff51722439ce8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 16 Dec 2021 23:31:08 +0100 Subject: [PATCH 016/475] Remove DBAL 2 compat code --- lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php | 2 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 11 +---------- psalm.xml | 6 ------ .../Tests/ORM/Functional/SchemaTool/DDC214Test.php | 11 +---------- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 37fb80bb99a..214f08ca1a4 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -655,7 +655,7 @@ private function determineIdGeneratorStrategy(AbstractPlatform $platform): int private function truncateSequenceName(string $schemaElementName): string { $platform = $this->getTargetPlatform(); - if (! $platform instanceof Platforms\OraclePlatform && ! $platform instanceof Platforms\SQLAnywherePlatform) { + if (! $platform instanceof Platforms\OraclePlatform) { return $schemaElementName; } diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index ee699199927..8d9cf1bc814 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -4,11 +4,9 @@ namespace Doctrine\ORM\Tools; -use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractAsset; use Doctrine\DBAL\Schema\AbstractSchemaManager; -use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; @@ -36,7 +34,6 @@ use function in_array; use function is_array; use function is_numeric; -use function method_exists; use function strtolower; /** @@ -927,13 +924,7 @@ public function getUpdateSchemaSql(array $classes, $saveMode = false) { $toSchema = $this->getSchemaFromMetadata($classes); $fromSchema = $this->createSchemaForComparison($toSchema); - - if (method_exists($this->schemaManager, 'createComparator')) { - $comparator = $this->schemaManager->createComparator(); - } else { - $comparator = new Comparator(); - } - + $comparator = $this->schemaManager->createComparator(); $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); if ($saveMode) { diff --git a/psalm.xml b/psalm.xml index 4f881008657..bcc5f1f6ff2 100644 --- a/psalm.xml +++ b/psalm.xml @@ -81,12 +81,6 @@ - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index bb673e2adb4..39b58ddf8c9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -5,16 +5,13 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; use Doctrine\DBAL\Platforms\SqlitePlatform; -use Doctrine\DBAL\Schema\Comparator; use Doctrine\ORM\Tools; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; use Exception; use function array_filter; -use function count; use function implode; -use function method_exists; use function strpos; use const PHP_EOL; @@ -96,13 +93,7 @@ public function assertCreatedSchemaNeedsNoUpdates($classes): void $fromSchema = $sm->createSchema(); $toSchema = $this->schemaTool->getSchemaFromMetadata($classMetadata); - - if (method_exists($sm, 'createComparator')) { - $comparator = $sm->createComparator(); - } else { - $comparator = new Comparator(); - } - + $comparator = $sm->createComparator(); $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); $sql = $schemaDiff->toSql($this->_em->getConnection()->getDatabasePlatform()); From a41c6d32c3e18e7e5c008a7b2c64d62acf24966f Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 16 Dec 2021 11:51:40 -0800 Subject: [PATCH 017/475] Do not use AbstractPlatform::canEmulateSchemas() --- UPGRADE.md | 4 ++++ lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 4 ---- lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php | 7 +------ lib/Doctrine/ORM/Tools/SchemaTool.php | 2 +- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php | 2 +- tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php | 7 +------ 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 6f44c12f17c..82ba1ffbe9f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Removed support for schema emulation. + +The ORM no longer attempts to emulate schemas on SQLite. + ## BC BREAK: Remove `Setup::registerAutoloadDirectory()` Use Composer's autoloader instead. diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 890ddcd0172..487b6af11f3 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -3668,10 +3668,6 @@ public function getSequencePrefix(AbstractPlatform $platform) $schemaName = $this->getSchemaName(); if ($schemaName) { $sequencePrefix = $schemaName . '.' . $tableName; - - if (! $platform->supportsSchemas() && $platform->canEmulateSchemas()) { - $sequencePrefix = $schemaName . '__' . $tableName; - } } return $sequencePrefix; diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index cb15aaa95c1..e02d029e508 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -41,10 +41,6 @@ public function getTableName(ClassMetadata $class, AbstractPlatform $platform) if (! empty($class->table['schema'])) { $tableName = $class->table['schema'] . '.' . $class->table['name']; - - if (! $platform->supportsSchemas() && $platform->canEmulateSchemas()) { - $tableName = $class->table['schema'] . '__' . $class->table['name']; - } } return isset($class->table['quoted']) @@ -90,8 +86,7 @@ public function getJoinTableName(array $association, ClassMetadata $class, Abstr $schema = ''; if (isset($association['joinTable']['schema'])) { - $schema = $association['joinTable']['schema']; - $schema .= ! $platform->supportsSchemas() && $platform->canEmulateSchemas() ? '__' : '.'; + $schema = $association['joinTable']['schema'] . '.'; } $tableName = $association['joinTable']['name']; diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 8d9cf1bc814..67885702bfe 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -393,7 +393,7 @@ static function (ClassMetadata $class) use ($idMapping): bool { } } - if (! $this->platform->supportsSchemas() && ! $this->platform->canEmulateSchemas()) { + if (! $this->platform->supportsSchemas()) { $schema->visit(new RemoveNamespacedAssets()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index e1b1f079630..d677a2e89de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -30,7 +30,7 @@ protected function setUp(): void $platform = $this->_em->getConnection()->getDatabasePlatform(); - if (! $platform->supportsSchemas() && ! $platform->canEmulateSchemas()) { + if (! $platform->supportsSchemas()) { self::markTestSkipped('This test is only useful for databases that support schemas or can emulate them.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php index 5f5af547547..c4e7c47756d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php @@ -74,12 +74,7 @@ public function testJoinTableName(): void private function getTableFullName(array $table): string { - $join = '.'; - if (! $this->platform->supportsSchemas() && $this->platform->canEmulateSchemas()) { - $join = '__'; - } - - return $table['schema'] . $join . $table['name']; + return $table['schema'] . '.' . $table['name']; } private function createClassMetadata(string $className): ClassMetadata From ad97969e9309f7128c4810971c6b9d48097852d6 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 18 Dec 2021 02:17:37 -0800 Subject: [PATCH 018/475] Remove the orm:ensure-production-settings console command (#9263) --- UPGRADE.md | 5 + docs/en/reference/tools.rst | 2 - .../EnsureProductionSettingsCommand.php | 62 ---------- .../ORM/Tools/Console/ConsoleRunner.php | 1 - psalm-baseline.xml | 5 - psalm.xml | 2 - .../EnsureProductionSettingsCommandTest.php | 117 ------------------ .../ORM/Tools/Console/ConsoleRunnerTest.php | 1 - 8 files changed, 5 insertions(+), 190 deletions(-) delete mode 100644 lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 82ba1ffbe9f..109618c18bf 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -20,6 +20,11 @@ _before_ upgrading to 3.0: php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml ``` +## BC BREAK: Remove the `orm:ensure-production-settings` console command + +The `orm:ensure-production-settings` console command and its implementation +`Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand` have been removed. + ## BC BREAK: Remove code generators and related console commands These console commands have been removed: diff --git a/docs/en/reference/tools.rst b/docs/en/reference/tools.rst index 04b682b145c..4bf31504b5a 100644 --- a/docs/en/reference/tools.rst +++ b/docs/en/reference/tools.rst @@ -77,8 +77,6 @@ The following Commands are currently available: cache drivers. - ``orm:clear-cache:result`` Clear result cache of the various cache drivers. -- ``orm:ensure-production-settings`` Verify that Doctrine is - properly configured for a production environment. - ``orm:generate-proxies`` Generates proxy classes for entity classes. - ``orm:run-dql`` Executes arbitrary DQL directly from the command diff --git a/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php deleted file mode 100644 index ced57647ec9..00000000000 --- a/lib/Doctrine/ORM/Tools/Console/Command/EnsureProductionSettingsCommand.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('orm:ensure-production-settings') - ->setDescription('Verify that Doctrine is properly configured for a production environment') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') - ->addOption('complete', null, InputOption::VALUE_NONE, 'Flag to also inspect database connection existence.') - ->setHelp('Verify that Doctrine is properly configured for a production environment.'); - } - - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $ui = new SymfonyStyle($input, $output); - $ui->warning('This console command has been deprecated and will be removed in a future version of Doctrine ORM.'); - - $em = $this->getEntityManager($input); - - try { - $em->getConfiguration()->ensureProductionSettings(); - - if ($input->getOption('complete') === true) { - $em->getConnection()->connect(); - } - } catch (Throwable $e) { - $ui->error($e->getMessage()); - - return 1; - } - - $ui->success('Environment is correctly configured for production.'); - - return 0; - } -} diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index 01e54c9e285..e2df79c461f 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -92,7 +92,6 @@ public static function addCommands(Application $cli, ?EntityManagerProvider $ent new Command\SchemaTool\CreateCommand($entityManagerProvider), new Command\SchemaTool\UpdateCommand($entityManagerProvider), new Command\SchemaTool\DropCommand($entityManagerProvider), - new Command\EnsureProductionSettingsCommand($entityManagerProvider), new Command\GenerateProxiesCommand($entityManagerProvider), new Command\RunDqlCommand($entityManagerProvider), new Command\ValidateSchemaCommand($entityManagerProvider), diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e84d942ac4d..38a6f37772c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3153,11 +3153,6 @@ $cacheDriver - - - configure - - getProxyDir diff --git a/psalm.xml b/psalm.xml index bcc5f1f6ff2..eba8107cc7e 100644 --- a/psalm.xml +++ b/psalm.xml @@ -20,8 +20,6 @@ - - diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php deleted file mode 100644 index d11f0831df7..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/EnsureProductionSettingsCommandTest.php +++ /dev/null @@ -1,117 +0,0 @@ -createMock(EntityManagerInterface::class); - - $configuration = $this->createMock(Configuration::class); - $configuration->expects(self::once()) - ->method('ensureProductionSettings'); - - $em->method('getConfiguration') - ->willReturn($configuration); - - $em->expects(self::never()) - ->method('getConnection'); - - self::assertSame(0, $this->executeCommand($em)); - } - - public function testExecuteFailed(): void - { - $em = $this->createMock(EntityManagerInterface::class); - - $configuration = $this->createMock(Configuration::class); - $configuration->expects(self::once()) - ->method('ensureProductionSettings') - ->willThrowException(new RuntimeException()); - - $em->method('getConfiguration') - ->willReturn($configuration); - - $em->expects(self::never()) - ->method('getConnection'); - - self::assertSame(1, $this->executeCommand($em)); - } - - public function testExecuteWithComplete(): void - { - $em = $this->createMock(EntityManagerInterface::class); - - $configuration = $this->createMock(Configuration::class); - $configuration->expects(self::once()) - ->method('ensureProductionSettings'); - - $em->method('getConfiguration') - ->willReturn($configuration); - - $connection = $this->createMock(Connection::class); - - $connection->expects(self::once()) - ->method('connect'); - - $em->method('getConnection') - ->willReturn($connection); - - self::assertSame(0, $this->executeCommand($em, ['--complete' => true])); - } - - public function testExecuteWithCompleteFailed(): void - { - $em = $this->createMock(EntityManagerInterface::class); - - $configuration = $this->createMock(Configuration::class); - $configuration->expects(self::once()) - ->method('ensureProductionSettings'); - - $em->method('getConfiguration') - ->willReturn($configuration); - - $connection = $this->createMock(Connection::class); - - $connection->expects(self::once()) - ->method('connect') - ->willThrowException(new RuntimeException()); - - $em->method('getConnection') - ->willReturn($connection); - - self::assertSame(1, $this->executeCommand($em, ['--complete' => true])); - } - - private function executeCommand( - EntityManagerInterface $em, - array $input = [] - ): int { - $application = new Application(); - $application->add(new EnsureProductionSettingsCommand(new SingleManagerProvider($em))); - - $command = $application->find('orm:ensure-production-settings'); - $tester = new CommandTester($command); - - return $tester->execute( - array_merge([ - 'command' => $command->getName(), - ], $input) - ); - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php index e6fa9df579f..9df576fbb3f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php @@ -38,7 +38,6 @@ public function testCreateApplicationShouldReturnAnApplicationWithTheCorrectComm self::assertTrue($app->has('orm:clear-cache:metadata')); self::assertTrue($app->has('orm:clear-cache:query')); self::assertTrue($app->has('orm:clear-cache:result')); - self::assertTrue($app->has('orm:ensure-production-settings')); self::assertTrue($app->has('orm:generate-proxies')); self::assertTrue($app->has('orm:generate:proxies')); self::assertTrue($app->has('orm:info')); From 61e2caf81855b6dfc16fb4fa3162284afa960df6 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 25 Dec 2021 23:06:29 +0100 Subject: [PATCH 019/475] Remove EntityManager::transactional() (#9278) --- UPGRADE.md | 4 ++ .../ORM/Decorator/EntityManagerDecorator.php | 24 --------- lib/Doctrine/ORM/EntityManager.php | 29 ----------- lib/Doctrine/ORM/EntityManagerInterface.php | 21 +------- psalm-baseline.xml | 23 +-------- .../Mock/NonProxyLoadingEntityManager.php | 8 --- .../Doctrine/Tests/ORM/EntityManagerTest.php | 50 ------------------- .../ORM/Functional/BasicFunctionalTest.php | 4 +- 8 files changed, 9 insertions(+), 154 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 109618c18bf..09992996a37 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Remove `Doctrine\ORM\EntityManagerInterface#transactional()` + +This method has been replaced by `Doctrine\ORM\EntityManagerInterface#wrapInTransaction()`. + ## BC BREAK: Removed support for schema emulation. The ORM no longer attempts to emulate schemas on SQLite. diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index c537e486775..0e8301e6b87 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -8,13 +8,6 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Persistence\ObjectManagerDecorator; -use function get_class; -use function method_exists; -use function sprintf; -use function trigger_error; - -use const E_USER_NOTICE; - /** * Base class for EntityManager decorators */ @@ -52,28 +45,11 @@ public function beginTransaction() $this->wrapped->beginTransaction(); } - /** - * {@inheritdoc} - */ - public function transactional($func) - { - return $this->wrapped->transactional($func); - } - /** * {@inheritdoc} */ public function wrapInTransaction(callable $func) { - if (! method_exists($this->wrapped, 'wrapInTransaction')) { - trigger_error( - sprintf('Calling `transactional()` instead of `wrapInTransaction()` which is not implemented on %s', get_class($this->wrapped)), - E_USER_NOTICE - ); - - return $this->wrapped->transactional($func); - } - return $this->wrapped->wrapInTransaction($func); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index bc39cfad8e2..0b5c6611c0a 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM; -use BadMethodCallException; use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\EventManager; use Doctrine\Common\Util\ClassUtils; @@ -32,11 +31,9 @@ use Throwable; use function array_keys; -use function call_user_func; use function get_class; use function gettype; use function is_array; -use function is_callable; use function is_object; use function is_string; use function ltrim; @@ -221,32 +218,6 @@ public function getCache() return $this->cache; } - /** - * {@inheritDoc} - */ - public function transactional($func) - { - if (! is_callable($func)) { - throw new InvalidArgumentException('Expected argument of type "callable", got "' . gettype($func) . '"'); - } - - $this->conn->beginTransaction(); - - try { - $return = call_user_func($func, $this); - - $this->flush(); - $this->conn->commit(); - - return $return ?: true; - } catch (Throwable $e) { - $this->close(); - $this->conn->rollBack(); - - throw $e; - } - } - /** * {@inheritDoc} */ diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index bd4df4e801f..5ae287bbcd1 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -20,7 +20,6 @@ * EntityManager interface * * @method Mapping\ClassMetadataFactory getMetadataFactory() - * @method mixed wrapInTransaction(callable $func) */ interface EntityManagerInterface extends ObjectManager { @@ -72,24 +71,6 @@ public function getExpressionBuilder(); */ public function beginTransaction(); - /** - * Executes a function in a transaction. - * - * The function gets passed this EntityManager instance as an (optional) parameter. - * - * {@link flush} is invoked prior to transaction commit. - * - * If an exception occurs during execution of the function or flushing or transaction commit, - * the transaction is rolled back, the EntityManager closed and the exception re-thrown. - * - * @deprecated 2.10 Use {@link wrapInTransaction} instead. - * - * @param callable $func The function to execute transactionally. - * - * @return mixed The non-empty value returned from the closure or true instead. - */ - public function transactional($func); - /** * Executes a function in a transaction. * @@ -106,7 +87,7 @@ public function transactional($func); * * @template T */ - // public function wrapInTransaction(callable $func); + public function wrapInTransaction(callable $func); /** * Commits a transaction on the underlying database connection. diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 38a6f37772c..2e9dcd43f61 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -409,19 +409,14 @@ - + getHydrator - transactional - transactional $entity $lockMode $lockVersion - - wrapInTransaction - $wrapped @@ -479,9 +474,6 @@ $this->repositoryFactory->getRepository($this, $entityName) new $class($this) - - wrapInTransaction - EntityRepository<T> newHydrator @@ -773,10 +765,9 @@ $parent new $definition['class']() - + addNamedNativeQuery addNamedQuery - getName ! $definition @@ -875,9 +866,6 @@ $class $subclass - - canEmulateSchemas - $this->columnNames $this->columnNames @@ -1040,10 +1028,6 @@ - - canEmulateSchemas - canEmulateSchemas - $joinColumn @@ -3312,9 +3296,6 @@ - - canEmulateSchemas - ! $definingClass $definingClass diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 021d6d3a403..8f101c416e4 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -92,14 +92,6 @@ public function beginTransaction() $this->realEntityManager->beginTransaction(); } - /** - * {@inheritDoc} - */ - public function transactional($func) - { - return $this->realEntityManager->transactional($func); - } - /** * {@inheritDoc} */ diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 0162f7d7d70..710e40e8a00 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -240,38 +240,6 @@ static function (EntityManagerInterface $em) use ($expectedValue) { $this->assertSame($expectedValue, $return); } - /** - * @group DDC-1125 - */ - public function testTransactionalAcceptsReturn(): void - { - $return = $this->entityManager->transactional(static function ($em) { - return 'foo'; - }); - - self::assertEquals('foo', $return); - } - - public function testTransactionalAcceptsVariousCallables(): void - { - self::assertSame('callback', $this->entityManager->transactional([$this, 'transactionalCallback'])); - } - - public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed(): void - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Expected argument of type "callable", got "object"'); - - $this->entityManager->transactional($this); - } - - public function transactionalCallback($em): string - { - self::assertSame($this->entityManager, $em); - - return 'callback'; - } - public function testCreateInvalidConnection(): void { $this->expectException(InvalidArgumentException::class); @@ -282,24 +250,6 @@ public function testCreateInvalidConnection(): void EntityManager::create(1, $config); } - /** - * @group #5796 - */ - public function testTransactionalReThrowsThrowables(): void - { - try { - $this->entityManager->transactional(static function (): void { - (static function (array $value): void { - // this only serves as an IIFE that throws a `TypeError` - })(null); - }); - - self::fail('TypeError expected to be thrown'); - } catch (TypeError $ignored) { - self::assertFalse($this->entityManager->isOpen()); - } - } - /** * @group #5796 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index e3e647c59a0..17981735dfd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Logging\DebugStack; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\ORMInvalidArgumentException; @@ -22,7 +23,6 @@ use InvalidArgumentException; use function get_class; -use function in_array; class BasicFunctionalTest extends OrmFunctionalTestCase { @@ -717,7 +717,7 @@ public function testQueryEntityByReference(): void $user->setAddress($address); - $this->_em->transactional(static function ($em) use ($user): void { + $this->_em->wrapInTransaction(static function (EntityManagerInterface $em) use ($user): void { $em->persist($user); }); $this->_em->clear(); From 9c0764928702a8a51b33c9301114871bf74e3f18 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 27 Dec 2021 19:57:51 +0100 Subject: [PATCH 020/475] Drop support for PHP 7.4 (#9290) --- .github/workflows/coding-standard.yml | 4 ++-- .github/workflows/continuous-integration.yml | 7 +++---- .github/workflows/phpbench.yml | 2 +- composer.json | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/coding-standard.yml b/.github/workflows/coding-standard.yml index 8e9b6a40c68..d0f9251732c 100644 --- a/.github/workflows/coding-standard.yml +++ b/.github/workflows/coding-standard.yml @@ -10,6 +10,6 @@ on: jobs: coding-standards: - uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.1.1" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.4.1" with: - php-version: "7.4" + php-version: "8.0" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 0e1f02873ee..e6e44dcb3e1 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -19,7 +19,6 @@ jobs: strategy: matrix: php-version: - - "7.4" - "8.0" - "8.1" dbal-version: @@ -74,7 +73,7 @@ jobs: strategy: matrix: php-version: - - "7.4" + - "8.0" dbal-version: - "default" postgres-version: @@ -131,7 +130,7 @@ jobs: strategy: matrix: php-version: - - "7.4" + - "8.0" dbal-version: - "default" mariadb-version: @@ -192,7 +191,7 @@ jobs: strategy: matrix: php-version: - - "7.4" + - "8.0" dbal-version: - "default" mysql-version: diff --git a/.github/workflows/phpbench.yml b/.github/workflows/phpbench.yml index 2c4872a8b53..df9c049d176 100644 --- a/.github/workflows/phpbench.yml +++ b/.github/workflows/phpbench.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: php-version: - - "7.4" + - "8.0" steps: - name: "Checkout" diff --git a/composer.json b/composer.json index 84ea47fbca1..b5fa4b28db9 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "sort-packages": true }, "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "ext-ctype": "*", "ext-pdo": "*", "composer/package-versions-deprecated": "^1.8", @@ -35,8 +35,7 @@ "doctrine/lexer": "^1.0", "doctrine/persistence": "^2.2", "psr/cache": "^1 || ^2 || ^3", - "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/polyfill-php80": "^1.15" + "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0" }, "require-dev": { "doctrine/annotations": "^1.13", From f151daa2f998608144c4c6ce9f19a740a7a57cb0 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 2 Jan 2022 13:04:19 +0100 Subject: [PATCH 021/475] Replace mocks with middlewares. (#9291) --- composer.json | 2 +- phpstan-baseline.neon | 10 - phpstan.neon | 5 - psalm-baseline.xml | 10 +- .../ORM/Functional/Ticket/DDC3634Test.php | 432 +++--------------- tests/Doctrine/Tests/TestUtil.php | 5 +- 6 files changed, 60 insertions(+), 404 deletions(-) diff --git a/composer.json b/composer.json index 447760c3dd7..43f7a70467e 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "doctrine/cache": "^1.12.1 || ^2.1.1", "doctrine/collections": "^1.5", "doctrine/common": "^3.0.3", - "doctrine/dbal": "^3.2", + "doctrine/dbal": "^3.3@dev", "doctrine/deprecations": "^0.5.3", "doctrine/event-manager": "^1.1", "doctrine/inflector": "^1.4 || ^2.0", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ba029b31a24..1a1d9b15177 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -735,16 +735,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php - - - message: "#^Parameter \\#2 \\$start of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getSubstringExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php - - - - message: "#^Parameter \\#3 \\$length of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getSubstringExpression\\(\\) expects int\\|null, string\\|null given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php - - message: "#^Parameter \\#1 \\$simpleArithmeticExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkSimpleArithmeticExpression\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index 3e26501f1c4..acd38a18634 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,8 +12,3 @@ parameters: message: '/^Call to an undefined method Doctrine\\Common\\Cache\\Cache::deleteAll\(\)\.$/' count: 1 path: lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php - # See https://github.com/doctrine/dbal/pull/5129 - - - message: '/^Parameter #3 \$startPos of method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getLocateExpression\(\) expects int\|false, string given\.$/' - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 50ef7d2c7b9..85c24c1edc1 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -713,6 +713,9 @@ + + canRequireSQLConversion + $this->columnNames $this->columnNames @@ -1805,9 +1808,6 @@ - - $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) - $this->simpleArithmeticExpression @@ -1854,10 +1854,6 @@ - - $optionalSecondSimpleArithmeticExpression - $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression) - $firstSimpleArithmeticExpression $stringPrimary diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index ae5b364eb73..2ef3f5fee52 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -4,24 +4,21 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use BadMethodCallException; -use Closure; -use Doctrine\DBAL\Cache\QueryCacheProfile; -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Result; -use Doctrine\DBAL\Statement; -use Doctrine\ORM\EntityManager; +use Doctrine\DBAL\Configuration; +use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\Connection as DriverConnection; +use Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware; +use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorMap; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\ToolsException; use Doctrine\Tests\OrmFunctionalTestCase; - -use function call_user_func_array; -use function debug_backtrace; +use Doctrine\Tests\TestUtil; use const PHP_INT_MAX; @@ -30,8 +27,17 @@ */ class DDC3634Test extends OrmFunctionalTestCase { + private LastInsertIdMocker $idMocker; + protected function setUp(): void { + $this->idMocker = new LastInsertIdMocker(); + $config = new Configuration(); + $config->setMiddlewares([new LastInsertIdMockMiddleware($this->idMocker)]); + + $this->_em = $this->getEntityManager(TestUtil::getConnection($config)); + $this->_schemaTool = new SchemaTool($this->_em); + parent::setUp(); $metadata = $this->_em->getClassMetadata(DDC3634Entity::class); @@ -53,17 +59,13 @@ protected function setUp(): void public function testSavesVeryLargeIntegerAutoGeneratedValue(): void { - $veryLargeId = PHP_INT_MAX . PHP_INT_MAX; - - $entityManager = EntityManager::create( - new DDC3634LastInsertIdMockingConnection($veryLargeId, $this->_em->getConnection()), - $this->_em->getConfiguration() - ); + $veryLargeId = PHP_INT_MAX . PHP_INT_MAX; + $this->idMocker->mockedId = $veryLargeId; $entity = new DDC3634Entity(); - $entityManager->persist($entity); - $entityManager->flush(); + $this->_em->persist($entity); + $this->_em->flush(); self::assertSame($veryLargeId, $entity->id); } @@ -125,390 +127,62 @@ class DDC3634JTIChildEntity extends DDC3634JTIBaseEntity { } -class DDC3634LastInsertIdMockingConnection extends Connection +class LastInsertIdMocker { - /** @var Connection */ - private $realConnection; + public ?string $mockedId = null; +} - /** @var int|string */ - private $identifier; +final class LastInsertIdMockConnection extends AbstractConnectionMiddleware +{ + private LastInsertIdMocker $idMocker; - /** - * @param int|string $identifier - */ - public function __construct($identifier, Connection $realConnection) + public function __construct(DriverConnection $wrappedConnection, LastInsertIdMocker $idMocker) { - $this->realConnection = $realConnection; - $this->identifier = $identifier; + $this->idMocker = $idMocker; + + parent::__construct($wrappedConnection); } /** - * @return mixed + * {@inheritdoc} */ - private function forwardCall() - { - $trace = debug_backtrace(0, 2)[1]; - - return call_user_func_array([$this->realConnection, $trace['function']], $trace['args']); - } - - /** {@inheritDoc} */ - public function getParams() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getDatabase() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getHost() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getPort() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getUsername() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getPassword() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getDriver() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getConfiguration() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getEventManager() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getDatabasePlatform() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getExpressionBuilder() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function connect() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function isAutoCommit() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function setAutoCommit($autoCommit) - { - $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function setFetchMode($fetchMode) - { - $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function fetchAssoc($statement, array $params = [], array $types = []) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function fetchArray($statement, array $params = [], array $types = []) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function fetchColumn($statement, array $params = [], $column = 0, array $types = []) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function isConnected() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function isTransactionActive() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function delete($tableExpression, array $identifier, array $types = []) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function close() - { - $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function setTransactionIsolation($level) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getTransactionIsolation() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function update($tableExpression, array $data, array $identifier, array $types = []) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function insert($tableExpression, array $data, array $types = []) + public function lastInsertId($name = null) { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function quoteIdentifier($str) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function quote($input, $type = null) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function fetchAll($sql, array $params = [], $types = []) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function prepare($statement): Statement - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function executeQuery($query, array $params = [], $types = [], ?QueryCacheProfile $qcp = null): Result - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp): Result - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function project($query, array $params, Closure $function) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function query($sql = null): Result - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function executeUpdate($query, array $params = [], array $types = []): int - { - throw new BadMethodCallException('Call to deprecated method.'); - } - - /** {@inheritDoc} */ - public function executeStatement($query, array $params = [], array $types = []): int - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function exec($statement): int - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getTransactionNestingLevel() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function errorCode() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function errorInfo() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function lastInsertId($seqName = null) - { - return $this->identifier; - } - - /** {@inheritDoc} */ - public function transactional(Closure $func) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoints) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getNestTransactionsWithSavepoints() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - protected function _getNestedTransactionSavePointName() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function beginTransaction() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function commit() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function rollBack() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function createSavepoint($savepoint) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function releaseSavepoint($savepoint) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function rollbackSavepoint($savepoint) - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getWrappedConnection() - { - return $this->forwardCall(); - } - - /** {@inheritDoc} */ - public function getSchemaManager() - { - return $this->forwardCall(); + return $this->idMocker->mockedId ?? parent::lastInsertId($name); } +} - /** {@inheritDoc} */ - public function setRollbackOnly() - { - $this->forwardCall(); - } +final class LastInsertIdMockDriver extends AbstractDriverMiddleware +{ + private LastInsertIdMocker $idMocker; - /** {@inheritDoc} */ - public function isRollbackOnly() + public function __construct(Driver $wrappedDriver, LastInsertIdMocker $idMocker) { - return $this->forwardCall(); - } + $this->idMocker = $idMocker; - /** {@inheritDoc} */ - public function convertToDatabaseValue($value, $type) - { - return $this->forwardCall(); + parent::__construct($wrappedDriver); } - /** {@inheritDoc} */ - public function convertToPHPValue($value, $type) + public function connect(array $params): LastInsertIdMockConnection { - return $this->forwardCall(); + return new LastInsertIdMockConnection( + parent::connect($params), + $this->idMocker + ); } +} - /** {@inheritDoc} */ - public function resolveParams(array $params, array $types) - { - return $this->forwardCall(); - } +final class LastInsertIdMockMiddleware implements Driver\Middleware +{ + private LastInsertIdMocker $idMocker; - /** {@inheritDoc} */ - public function createQueryBuilder() + public function __construct(LastInsertIdMocker $idMocker) { - return $this->forwardCall(); + $this->idMocker = $idMocker; } - /** {@inheritDoc} */ - public function ping() + public function wrap(Driver $driver): LastInsertIdMockDriver { - return $this->forwardCall(); + return new LastInsertIdMockDriver($driver, $this->idMocker); } } diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index 1f05ee995b3..5ba15e1403a 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests; use Doctrine\Common\EventSubscriber; +use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use UnexpectedValueException; @@ -48,14 +49,14 @@ class TestUtil * * @return Connection The database connection instance. */ - public static function getConnection(): Connection + public static function getConnection(?Configuration $config = null): Connection { if (! self::$initialized) { self::initializeDatabase(); self::$initialized = true; } - $conn = DriverManager::getConnection(self::getTestConnectionParameters()); + $conn = DriverManager::getConnection(self::getTestConnectionParameters(), $config); self::addDbEventSubscribers($conn); From 081f3e43c06e7251f1ec6c7a56b14ebcc447a018 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 2 Jan 2022 21:29:38 +0100 Subject: [PATCH 022/475] Enable PHPCS rules for PHP 8.0 (#9293) --- phpcs.xml.dist | 3 ++- .../Doctrine/StaticAnalysis/get-metadata.php | 3 +-- tests/Doctrine/Tests/DoctrineTestCase.php | 8 ++---- .../Doctrine/Tests/Mocks/CacheRegionMock.php | 10 ++------ tests/Doctrine/Tests/Mocks/ConnectionMock.php | 7 +----- .../Tests/Mocks/EntityPersisterMock.php | 5 +--- .../Tests/Models/DDC3711/DDC3711EntityA.php | 20 +++------------ .../Models/ECommerce/ECommerceShipping.php | 10 ++------ .../Doctrine/Tests/ORM/EntityManagerTest.php | 4 +-- .../ORM/Functional/Ticket/DDC2895Test.php | 10 ++------ .../ORM/Functional/Ticket/DDC5684Test.php | 3 +-- .../ORM/Functional/Ticket/DDC6303Test.php | 5 +--- .../ORM/Functional/Ticket/GH5762Test.php | 5 +--- .../Hydration/SingleScalarHydratorTest.php | 6 ++--- .../ORM/ORMInvalidArgumentExceptionTest.php | 4 +-- .../ORM/Query/ParameterTypeInfererTest.php | 5 +--- .../ORM/Query/QueryExpressionVisitorTest.php | 4 +-- .../Tools/Pagination/WhereInWalkerTest.php | 3 +-- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 25 ++++--------------- tests/Doctrine/Tests/OrmTestCase.php | 7 ++---- 20 files changed, 34 insertions(+), 113 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 052f96c4d50..bdd7b650631 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -9,7 +9,7 @@ - + lib tests @@ -26,6 +26,7 @@ + diff --git a/tests/Doctrine/StaticAnalysis/get-metadata.php b/tests/Doctrine/StaticAnalysis/get-metadata.php index c9b11036155..86e0cc92a16 100644 --- a/tests/Doctrine/StaticAnalysis/get-metadata.php +++ b/tests/Doctrine/StaticAnalysis/get-metadata.php @@ -16,10 +16,9 @@ abstract class GetMetadata { /** - * @param string|object $class * @psalm-param class-string|object $class */ - abstract public function getEntityManager($class): EntityManagerInterface; + abstract public function getEntityManager(string|object $class): EntityManagerInterface; /** * @psalm-param class-string $class diff --git a/tests/Doctrine/Tests/DoctrineTestCase.php b/tests/Doctrine/Tests/DoctrineTestCase.php index 3c286b7e6bd..1a7a1badcfd 100644 --- a/tests/Doctrine/Tests/DoctrineTestCase.php +++ b/tests/Doctrine/Tests/DoctrineTestCase.php @@ -25,10 +25,8 @@ abstract class DoctrineTestCase extends TestCase /** * @param array $arguments - * - * @return mixed */ - public static function __callStatic(string $method, array $arguments) + public static function __callStatic(string $method, array $arguments): mixed { if (isset(self::$phpunitMethodRenames[$method])) { $method = self::$phpunitMethodRenames[$method]; @@ -41,10 +39,8 @@ public static function __callStatic(string $method, array $arguments) /** * @param array $arguments - * - * @return mixed */ - public function __call(string $method, array $arguments) + public function __call(string $method, array $arguments): mixed { if ($method === 'createStub') { return $this->getMockBuilder(...$arguments) diff --git a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php index 781d4d9cf65..ab0af22e54d 100644 --- a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php @@ -28,22 +28,16 @@ class CacheRegionMock implements Region /** * Queue a return value for a specific method invocation - * - * @param mixed $value */ - public function addReturn(string $method, $value): void + public function addReturn(string $method, mixed $value): void { $this->returns[$method][] = $value; } /** * Dequeue a value for a specific method invocation - * - * @param mixed $default - * - * @return mixed */ - private function getReturn(string $method, $default) + private function getReturn(string $method, mixed $default): mixed { if (isset($this->returns[$method]) && ! empty($this->returns[$method])) { return array_shift($this->returns[$method]); diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php index 7757607df6d..fad5e28626f 100644 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -145,12 +145,7 @@ public function quote($input, $type = null) return $input; } - /* Mock API */ - - /** - * @param mixed $fetchOneResult - */ - public function setFetchOneResult($fetchOneResult): void + public function setFetchOneResult(mixed $fetchOneResult): void { $this->_fetchOneResult = $fetchOneResult; } diff --git a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php index a8402356a89..c3addc3a8f3 100644 --- a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php @@ -34,10 +34,7 @@ class EntityPersisterMock extends BasicEntityPersister /** @var bool */ private $existsCalled = false; - /** - * @return mixed - */ - public function addInsert($entity) + public function addInsert($entity): mixed { $this->inserts[] = $entity; if ( diff --git a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php index 984c40591a3..4ec4d05ece9 100644 --- a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php +++ b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php @@ -17,34 +17,22 @@ class DDC3711EntityA /** @var ArrayCollection */ private $entityB; - /** - * @return mixed - */ - public function getId1() + public function getId1(): mixed { return $this->id1; } - /** - * @param mixed $id1 - */ - public function setId1($id1): void + public function setId1(mixed $id1): void { $this->id1 = $id1; } - /** - * @return mixed - */ - public function getId2() + public function getId2(): mixed { return $this->id2; } - /** - * @param mixed $id2 - */ - public function setId2($id2): void + public function setId2(mixed $id2): void { $this->id2 = $id2; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php index 122daf5f477..70a571dff28 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php @@ -38,18 +38,12 @@ public function getId(): int return $this->id; } - /** - * @return int|string - */ - public function getDays() + public function getDays(): int|string { return $this->days; } - /** - * @param int|string $days - */ - public function setDays($days): void + public function setDays(int|string $days): void { $this->days = $days; } diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 3acc3855f59..715510a8a13 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -223,12 +223,10 @@ public function dataToBeReturnedByWrapInTransaction(): Generator } /** - * @param mixed $expectedValue - * * @dataProvider dataToBeReturnedByWrapInTransaction * @group DDC-1125 */ - public function testWrapInTransactionAcceptsReturn($expectedValue): void + public function testWrapInTransactionAcceptsReturn(mixed $expectedValue): void { $return = $this->entityManager->wrapInTransaction( /** @return mixed */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index e6c3d0a296e..a30711956a5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -105,18 +105,12 @@ class DDC2895 extends AbstractDDC2895 */ public $id; - /** - * @param mixed $id - */ - public function setId($id): void + public function setId(mixed $id): void { $this->id = $id; } - /** - * @return mixed - */ - public function getId() + public function getId(): mixed { return $this->id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index 08493f32f2f..eb8d789b424 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -106,8 +106,7 @@ class DDC5684ObjectId /** @var mixed */ public $value; - /** @param mixed $value */ - public function __construct($value) + public function __construct(mixed $value) { $this->value = $value; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php index 504edfa261f..dadce53c32e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php @@ -126,10 +126,7 @@ class DDC6303ChildA extends DDC6303BaseClass */ private $originalData; - /** - * @param mixed $originalData - */ - public function __construct(string $id, $originalData) + public function __construct(string $id, mixed $originalData) { $this->id = $id; $this->originalData = $originalData; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index c59a0c44c83..7a9771de416 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -61,10 +61,7 @@ public function testIssue(): void self::assertContains('Volvo', $cars); } - /** - * @return mixed - */ - private function fetchData() + private function fetchData(): mixed { $this->createData(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php index 91adbccb75b..b093839af09 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php @@ -52,11 +52,10 @@ public static function validResultSetProvider(): Generator /** * @param list> $resultSet - * @param mixed $expectedResult * * @dataProvider validResultSetProvider */ - public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array $resultSet, $expectedResult): void + public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array $resultSet, mixed $expectedResult): void { $rsm = new ResultSetMapping(); $rsm->addEntityResult(CmsUser::class, 'u'); @@ -72,11 +71,10 @@ public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array /** * @param list> $resultSet - * @param mixed $expectedResult * * @dataProvider validResultSetProvider */ - public function testHydrateSingleScalarFromScalarMappingWithValidResultSet(array $resultSet, $expectedResult): void + public function testHydrateSingleScalarFromScalarMappingWithValidResultSet(array $resultSet, mixed $expectedResult): void { $rsm = new ResultSetMapping(); $rsm->addScalarResult('u__id', 'id', 'string'); diff --git a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php index 2b55c3fc6e7..45fe31adec3 100644 --- a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php @@ -17,11 +17,9 @@ class ORMInvalidArgumentExceptionTest extends TestCase { /** - * @param mixed $value - * * @dataProvider invalidEntityNames */ - public function testInvalidEntityName($value, string $expectedMessage): void + public function testInvalidEntityName(mixed $value, string $expectedMessage): void { $exception = ORMInvalidArgumentException::invalidEntityName($value); diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index d3acdd827f7..71486da597b 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -34,12 +34,9 @@ public function providerParameterTypeInferer(): array } /** - * @param mixed $value - * @param int|string $expected - * * @dataProvider providerParameterTypeInferer */ - public function testParameterTypeInferer($value, $expected): void + public function testParameterTypeInferer(mixed $value, int|string $expected): void { self::assertEquals($expected, ParameterTypeInferer::inferType($value)); } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 054adcacede..9d0f5be158b 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -27,11 +27,9 @@ protected function setUp(): void } /** - * @param QueryBuilder\Comparison|QueryBuilder\Func|string $queryExpr - * * @dataProvider comparisonData */ - public function testWalkComparison(CriteriaComparison $criteriaExpr, $queryExpr, ?Parameter $parameter = null): void + public function testWalkComparison(CriteriaComparison $criteriaExpr, QueryBuilder\Comparison|QueryBuilder\Func|string $queryExpr, ?Parameter $parameter = null): void { self::assertEquals($queryExpr, $this->visitor->walkComparison($criteriaExpr)); if ($parameter) { diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php index 23e6d717607..76e39afb8b6 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php @@ -266,8 +266,7 @@ public function testWillReplaceBoundQueryIdentifiersWithConvertedTypesAsPerAssoc ); } - /** @param mixed $parameter */ - private function assertPaginatorWhereInParameterToBe(Query $query, $parameter): void + private function assertPaginatorWhereInParameterToBe(Query $query, mixed $parameter): void { $query->getSQL(); // forces walker to process the query diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 446bd79c3d8..f4e3bc1107a 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -308,12 +308,10 @@ public function testNoUndefinedIndexNoticeOnScheduleForUpdateWithoutChanges(): v } /** - * @param mixed $invalidValue - * * @group DDC-3490 * @dataProvider invalidAssociationValuesDataProvider */ - public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue($invalidValue): void + public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue(mixed $invalidValue): void { $this->_unitOfWork->setEntityPersister( ForumUser::class, @@ -333,12 +331,10 @@ public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue($inva } /** - * @param mixed $invalidValue - * * @group DDC-3490 * @dataProvider invalidAssociationValuesDataProvider */ - public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationValue($invalidValue): void + public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationValue(mixed $invalidValue): void { $metadata = $this->_emMock->getClassMetadata(ForumUser::class); @@ -880,18 +876,12 @@ public function setTransient($value): void } } - /** - * @return mixed - */ - public function getData() + public function getData(): mixed { return $this->data; } - /** - * @param mixed $data - */ - public function setData($data): void + public function setData(mixed $data): void { if ($data !== $this->data) { $this->onPropertyChanged('data', $this->data, $data); @@ -904,12 +894,7 @@ public function addPropertyChangedListener(PropertyChangedListener $listener): v $this->_listeners[] = $listener; } - /** - * @param mixed $propName - * @param mixed $oldValue - * @param mixed $newValue - */ - protected function onPropertyChanged($propName, $oldValue, $newValue): void + protected function onPropertyChanged(mixed $propName, mixed $oldValue, mixed $newValue): void { if ($this->_listeners) { foreach ($this->_listeners as $listener) { diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index a63afcfee59..b89a69e05d0 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -72,13 +72,10 @@ protected function createAnnotationDriver(array $paths = []): AnnotationDriver * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then * be configured in the tests to simulate the DBAL behavior that is desired * for a particular test, - * - * @param Connection|array $conn - * @param mixed $conf */ protected function getTestEntityManager( - $conn = null, - $conf = null, + Connection|array|null $conn = null, + mixed $conf = null, ?EventManager $eventManager = null, bool $withSharedMetadata = true ): EntityManagerMock { From ea97ea4c470f81f7944e4c8931f04c17eb86bee7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 5 Jan 2022 00:29:22 +0100 Subject: [PATCH 023/475] Add types to entity manager (#9292) --- .../ORM/Decorator/EntityManagerDecorator.php | 147 ++++------- lib/Doctrine/ORM/EntityManager.php | 244 ++++-------------- lib/Doctrine/ORM/EntityManagerInterface.php | 162 +++++------- phpstan-baseline.neon | 42 ++- psalm-baseline.xml | 52 ++-- .../Mock/NonProxyLoadingEntityManager.php | 167 ++++-------- .../Tests/Mocks/EntityManagerMock.php | 18 +- .../Decorator/EntityManagerDecoratorTest.php | 112 -------- 8 files changed, 293 insertions(+), 651 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index 0e8301e6b87..bf57450bf0d 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -4,8 +4,23 @@ namespace Doctrine\ORM\Decorator; +use Doctrine\Common\EventManager; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\Cache; +use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\Internal\Hydration\AbstractHydrator; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadataFactory; +use Doctrine\ORM\NativeQuery; +use Doctrine\ORM\Proxy\ProxyFactory; +use Doctrine\ORM\Query; +use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\FilterCollection; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\ORM\QueryBuilder; +use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\ObjectManagerDecorator; /** @@ -21,26 +36,35 @@ public function __construct(EntityManagerInterface $wrapped) $this->wrapped = $wrapped; } + public function getRepository($className): EntityRepository + { + return parent::getRepository($className); + } + + public function getMetadataFactory(): ClassMetadataFactory + { + return parent::getMetadataFactory(); + } + /** * {@inheritdoc} */ - public function getConnection() + public function getClassMetadata($className): ClassMetadata + { + return parent::getClassMetadata($className); + } + + public function getConnection(): Connection { return $this->wrapped->getConnection(); } - /** - * {@inheritdoc} - */ - public function getExpressionBuilder() + public function getExpressionBuilder(): Expr { return $this->wrapped->getExpressionBuilder(); } - /** - * {@inheritdoc} - */ - public function beginTransaction() + public function beginTransaction(): void { $this->wrapped->beginTransaction(); } @@ -53,58 +77,37 @@ public function wrapInTransaction(callable $func) return $this->wrapped->wrapInTransaction($func); } - /** - * {@inheritdoc} - */ - public function commit() + public function commit(): void { $this->wrapped->commit(); } - /** - * {@inheritdoc} - */ - public function rollback() + public function rollback(): void { $this->wrapped->rollback(); } - /** - * {@inheritdoc} - */ - public function createQuery($dql = '') + public function createQuery(string $dql = ''): Query { return $this->wrapped->createQuery($dql); } - /** - * {@inheritdoc} - */ - public function createNamedQuery($name) + public function createNamedQuery(string $name): Query { return $this->wrapped->createNamedQuery($name); } - /** - * {@inheritdoc} - */ - public function createNativeQuery($sql, ResultSetMapping $rsm) + public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery { return $this->wrapped->createNativeQuery($sql, $rsm); } - /** - * {@inheritdoc} - */ - public function createNamedNativeQuery($name) + public function createNamedNativeQuery(string $name): NativeQuery { return $this->wrapped->createNamedNativeQuery($name); } - /** - * {@inheritdoc} - */ - public function createQueryBuilder() + public function createQueryBuilder(): QueryBuilder { return $this->wrapped->createQueryBuilder(); } @@ -112,7 +115,7 @@ public function createQueryBuilder() /** * {@inheritdoc} */ - public function getReference($entityName, $id) + public function getReference(string $entityName, $id): ?object { return $this->wrapped->getReference($entityName, $id); } @@ -120,15 +123,12 @@ public function getReference($entityName, $id) /** * {@inheritdoc} */ - public function getPartialReference($entityName, $identifier) + public function getPartialReference(string $entityName, $identifier): ?object { return $this->wrapped->getPartialReference($entityName, $identifier); } - /** - * {@inheritdoc} - */ - public function close() + public function close(): void { $this->wrapped->close(); } @@ -136,7 +136,7 @@ public function close() /** * {@inheritdoc} */ - public function lock($entity, $lockMode, $lockVersion = null) + public function lock(object $entity, int $lockMode, $lockVersion = null): void { $this->wrapped->lock($entity, $lockMode, $lockVersion); } @@ -144,7 +144,7 @@ public function lock($entity, $lockMode, $lockVersion = null) /** * {@inheritdoc} */ - public function find($className, $id, $lockMode = null, $lockVersion = null) + public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object { return $this->wrapped->find($className, $id, $lockMode, $lockVersion); } @@ -152,39 +152,27 @@ public function find($className, $id, $lockMode = null, $lockVersion = null) /** * {@inheritdoc} */ - public function flush($entity = null) + public function flush($entity = null): void { $this->wrapped->flush($entity); } - /** - * {@inheritdoc} - */ - public function getEventManager() + public function getEventManager(): EventManager { return $this->wrapped->getEventManager(); } - /** - * {@inheritdoc} - */ - public function getConfiguration() + public function getConfiguration(): Configuration { return $this->wrapped->getConfiguration(); } - /** - * {@inheritdoc} - */ - public function isOpen() + public function isOpen(): bool { return $this->wrapped->isOpen(); } - /** - * {@inheritdoc} - */ - public function getUnitOfWork() + public function getUnitOfWork(): UnitOfWork { return $this->wrapped->getUnitOfWork(); } @@ -192,55 +180,32 @@ public function getUnitOfWork() /** * {@inheritdoc} */ - public function getHydrator($hydrationMode) - { - return $this->wrapped->getHydrator($hydrationMode); - } - - /** - * {@inheritdoc} - */ - public function newHydrator($hydrationMode) + public function newHydrator($hydrationMode): AbstractHydrator { return $this->wrapped->newHydrator($hydrationMode); } - /** - * {@inheritdoc} - */ - public function getProxyFactory() + public function getProxyFactory(): ProxyFactory { return $this->wrapped->getProxyFactory(); } - /** - * {@inheritdoc} - */ - public function getFilters() + public function getFilters(): FilterCollection { return $this->wrapped->getFilters(); } - /** - * {@inheritdoc} - */ - public function isFiltersStateClean() + public function isFiltersStateClean(): bool { return $this->wrapped->isFiltersStateClean(); } - /** - * {@inheritdoc} - */ - public function hasFilters() + public function hasFilters(): bool { return $this->wrapped->hasFilters(); } - /** - * {@inheritdoc} - */ - public function getCache() + public function getCache(): ?Cache { return $this->wrapped->getCache(); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index b13ea28393b..7ea7bead069 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -18,6 +18,7 @@ use Doctrine\ORM\Exception\MissingMappingDriverImplementation; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Exception\UnrecognizedIdentifierFields; +use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Proxy\ProxyFactory; @@ -67,80 +68,58 @@ { /** * The used Configuration. - * - * @var Configuration */ - private $config; + private Configuration $config; /** * The database connection used by the EntityManager. - * - * @var Connection */ - private $conn; + private Connection $conn; /** * The metadata factory, used to retrieve the ORM metadata of entity classes. - * - * @var ClassMetadataFactory */ - private $metadataFactory; + private ClassMetadataFactory $metadataFactory; /** * The UnitOfWork used to coordinate object-level transactions. - * - * @var UnitOfWork */ - private $unitOfWork; + private UnitOfWork $unitOfWork; /** * The event manager that is the central point of the event system. - * - * @var EventManager */ - private $eventManager; + private EventManager $eventManager; /** * The proxy factory used to create dynamic proxies. - * - * @var ProxyFactory */ - private $proxyFactory; + private ProxyFactory $proxyFactory; /** * The repository factory used to create dynamic repositories. - * - * @var RepositoryFactory */ - private $repositoryFactory; + private RepositoryFactory $repositoryFactory; /** * The expression builder instance used to generate query expressions. - * - * @var Expr|null */ - private $expressionBuilder; + private ?Expr $expressionBuilder = null; /** * Whether the EntityManager is closed or not. - * - * @var bool */ - private $closed = false; + private bool $closed = false; /** * Collection of query filters. - * - * @var FilterCollection|null */ - private $filterCollection; + private ?FilterCollection $filterCollection = null; /** * The second level cache regions API. - * - * @var Cache|null */ - private $cache; + private ?Cache $cache = null; /** * Creates a new EntityManager that operates on the given database connection @@ -175,48 +154,27 @@ protected function __construct(Connection $conn, Configuration $config, EventMan } } - /** - * {@inheritDoc} - */ - public function getConnection() + public function getConnection(): Connection { return $this->conn; } - /** - * Gets the metadata factory used to gather the metadata of classes. - * - * @return ClassMetadataFactory - */ - public function getMetadataFactory() + public function getMetadataFactory(): ClassMetadataFactory { return $this->metadataFactory; } - /** - * {@inheritDoc} - */ - public function getExpressionBuilder() + public function getExpressionBuilder(): Expr { - if ($this->expressionBuilder === null) { - $this->expressionBuilder = new Query\Expr(); - } - - return $this->expressionBuilder; + return $this->expressionBuilder ??= new Expr(); } - /** - * {@inheritDoc} - */ - public function beginTransaction() + public function beginTransaction(): void { $this->conn->beginTransaction(); } - /** - * {@inheritDoc} - */ - public function getCache() + public function getCache(): ?Cache { return $this->cache; } @@ -243,18 +201,12 @@ public function wrapInTransaction(callable $func) } } - /** - * {@inheritDoc} - */ - public function commit() + public function commit(): void { $this->conn->commit(); } - /** - * {@inheritDoc} - */ - public function rollback() + public function rollback(): void { $this->conn->rollBack(); } @@ -273,15 +225,12 @@ public function rollback() * * {@inheritDoc} */ - public function getClassMetadata($className) + public function getClassMetadata($className): Mapping\ClassMetadata { return $this->metadataFactory->getMetadataFor($className); } - /** - * {@inheritDoc} - */ - public function createQuery($dql = '') + public function createQuery(string $dql = ''): Query { $query = new Query($this); @@ -292,18 +241,12 @@ public function createQuery($dql = '') return $query; } - /** - * {@inheritDoc} - */ - public function createNamedQuery($name) + public function createNamedQuery(string $name): Query { return $this->createQuery($this->config->getNamedQuery($name)); } - /** - * {@inheritDoc} - */ - public function createNativeQuery($sql, ResultSetMapping $rsm) + public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery { $query = new NativeQuery($this); @@ -313,20 +256,14 @@ public function createNativeQuery($sql, ResultSetMapping $rsm) return $query; } - /** - * {@inheritDoc} - */ - public function createNamedNativeQuery($name) + public function createNamedNativeQuery(string $name): NativeQuery { [$sql, $rsm] = $this->config->getNamedNativeQuery($name); return $this->createNativeQuery($sql, $rsm); } - /** - * {@inheritDoc} - */ - public function createQueryBuilder() + public function createQueryBuilder(): QueryBuilder { return new QueryBuilder($this); } @@ -341,13 +278,11 @@ public function createQueryBuilder() * * @param object|mixed[]|null $entity * - * @return void - * * @throws OptimisticLockException If a version check on an entity that * makes use of optimistic locking fails. * @throws ORMException */ - public function flush($entity = null) + public function flush($entity = null): void { if ($entity !== null) { Deprecation::trigger( @@ -364,29 +299,9 @@ public function flush($entity = null) } /** - * Finds an Entity by its identifier. - * - * @param string $className The class name of the entity to find. - * @param mixed $id The identity of the entity to find. - * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants - * or NULL if no specific lock mode should be used - * during the search. - * @param int|null $lockVersion The version of the entity to find when using - * optimistic locking. - * @psalm-param class-string $className - * @psalm-param LockMode::*|null $lockMode - * - * @return object|null The entity instance or NULL if the entity can not be found. - * @psalm-return ?T - * - * @throws OptimisticLockException - * @throws ORMInvalidArgumentException - * @throws TransactionRequiredException - * @throws ORMException - * - * @template T + * {@inheritdoc} */ - public function find($className, $id, $lockMode = null, $lockVersion = null) + public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object { $class = $this->metadataFactory->getMetadataFor(ltrim($className, '\\')); @@ -477,7 +392,7 @@ public function find($className, $id, $lockMode = null, $lockVersion = null) /** * {@inheritDoc} */ - public function getReference($entityName, $id) + public function getReference(string $entityName, $id): ?object { $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); @@ -521,7 +436,7 @@ public function getReference($entityName, $id) /** * {@inheritDoc} */ - public function getPartialReference($entityName, $identifier) + public function getPartialReference(string $entityName, $identifier): ?object { $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); @@ -552,13 +467,11 @@ public function getPartialReference($entityName, $identifier) * * @param string|null $entityName if given, only entities of this type will get detached * - * @return void - * * @throws ORMInvalidArgumentException If a non-null non-string value is given. * @throws MappingException If a $entityName is given, but that entity is not * found in the mappings. */ - public function clear($entityName = null) + public function clear($entityName = null): void { if ($entityName !== null && ! is_string($entityName)) { throw ORMInvalidArgumentException::invalidEntityName($entityName); @@ -580,10 +493,7 @@ public function clear($entityName = null) ); } - /** - * {@inheritDoc} - */ - public function close() + public function close(): void { $this->clear(); @@ -601,12 +511,10 @@ public function close() * * @param object $entity The instance to make managed and persistent. * - * @return void - * * @throws ORMInvalidArgumentException * @throws ORMException */ - public function persist($entity) + public function persist($entity): void { if (! is_object($entity)) { throw ORMInvalidArgumentException::invalidObject('EntityManager#persist()', $entity); @@ -625,12 +533,10 @@ public function persist($entity) * * @param object $entity The entity instance to remove. * - * @return void - * * @throws ORMInvalidArgumentException * @throws ORMException */ - public function remove($entity) + public function remove($entity): void { if (! is_object($entity)) { throw ORMInvalidArgumentException::invalidObject('EntityManager#remove()', $entity); @@ -647,12 +553,10 @@ public function remove($entity) * * @param object $entity The entity to refresh. * - * @return void - * * @throws ORMInvalidArgumentException * @throws ORMException */ - public function refresh($entity) + public function refresh($entity): void { if (! is_object($entity)) { throw ORMInvalidArgumentException::invalidObject('EntityManager#refresh()', $entity); @@ -672,11 +576,9 @@ public function refresh($entity) * * @param object $entity The entity to detach. * - * @return void - * * @throws ORMInvalidArgumentException */ - public function detach($entity) + public function detach($entity): void { if (! is_object($entity)) { throw ORMInvalidArgumentException::invalidObject('EntityManager#detach()', $entity); @@ -699,7 +601,7 @@ public function detach($entity) * @throws ORMInvalidArgumentException * @throws ORMException */ - public function merge($entity) + public function merge($entity): object { Deprecation::trigger( 'doctrine/orm', @@ -720,7 +622,7 @@ public function merge($entity) /** * {@inheritDoc} */ - public function lock($entity, $lockMode, $lockVersion = null) + public function lock(object $entity, int $lockMode, $lockVersion = null): void { $this->unitOfWork->lock($entity, $lockMode, $lockVersion); } @@ -736,7 +638,7 @@ public function lock($entity, $lockMode, $lockVersion = null) * * @template T */ - public function getRepository($entityName) + public function getRepository($entityName): EntityRepository { return $this->repositoryFactory->getRepository($this, $entityName); } @@ -748,25 +650,19 @@ public function getRepository($entityName) * * @return bool TRUE if this EntityManager currently manages the given entity, FALSE otherwise. */ - public function contains($entity) + public function contains($entity): bool { return $this->unitOfWork->isScheduledForInsert($entity) || $this->unitOfWork->isInIdentityMap($entity) && ! $this->unitOfWork->isScheduledForDelete($entity); } - /** - * {@inheritDoc} - */ - public function getEventManager() + public function getEventManager(): EventManager { return $this->eventManager; } - /** - * {@inheritDoc} - */ - public function getConfiguration() + public function getConfiguration(): Configuration { return $this->config; } @@ -783,18 +679,12 @@ private function errorIfClosed(): void } } - /** - * {@inheritDoc} - */ - public function isOpen() + public function isOpen(): bool { return ! $this->closed; } - /** - * {@inheritDoc} - */ - public function getUnitOfWork() + public function getUnitOfWork(): UnitOfWork { return $this->unitOfWork; } @@ -802,15 +692,7 @@ public function getUnitOfWork() /** * {@inheritDoc} */ - public function getHydrator($hydrationMode) - { - return $this->newHydrator($hydrationMode); - } - - /** - * {@inheritDoc} - */ - public function newHydrator($hydrationMode) + public function newHydrator($hydrationMode): AbstractHydrator { switch ($hydrationMode) { case Query::HYDRATE_OBJECT: @@ -842,10 +724,7 @@ public function newHydrator($hydrationMode) throw InvalidHydrationMode::fromMode((string) $hydrationMode); } - /** - * {@inheritDoc} - */ - public function getProxyFactory() + public function getProxyFactory(): ProxyFactory { return $this->proxyFactory; } @@ -853,7 +732,7 @@ public function getProxyFactory() /** * {@inheritDoc} */ - public function initializeObject($obj) + public function initializeObject($obj): void { $this->unitOfWork->initializeObject($obj); } @@ -871,7 +750,7 @@ public function initializeObject($obj) * @throws InvalidArgumentException * @throws ORMException */ - public static function create($connection, Configuration $config, ?EventManager $eventManager = null) + public static function create($connection, Configuration $config, ?EventManager $eventManager = null): EntityManager { if (! $config->getMetadataDriverImpl()) { throw MissingMappingDriverImplementation::create(); @@ -890,12 +769,10 @@ public static function create($connection, Configuration $config, ?EventManager * @param EventManager|null $eventManager The EventManager instance to use. * @psalm-param array|Connection $connection * - * @return Connection - * * @throws InvalidArgumentException * @throws ORMException */ - protected static function createConnection($connection, Configuration $config, ?EventManager $eventManager = null) + protected static function createConnection($connection, Configuration $config, ?EventManager $eventManager = null): Connection { if (is_array($connection)) { return DriverManager::getConnection($connection, $config, $eventManager ?: new EventManager()); @@ -918,30 +795,17 @@ protected static function createConnection($connection, Configuration $config, ? return $connection; } - /** - * {@inheritDoc} - */ - public function getFilters() + public function getFilters(): FilterCollection { - if ($this->filterCollection === null) { - $this->filterCollection = new FilterCollection($this); - } - - return $this->filterCollection; + return $this->filterCollection ??= new FilterCollection($this); } - /** - * {@inheritDoc} - */ - public function isFiltersStateClean() + public function isFiltersStateClean(): bool { return $this->filterCollection === null || $this->filterCollection->isClean(); } - /** - * {@inheritDoc} - */ - public function hasFilters() + public function hasFilters(): bool { return $this->filterCollection !== null; } diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index bedef5e8a78..5a04fbd219e 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -10,17 +10,13 @@ use Doctrine\DBAL\LockMode; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; +use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\FilterCollection; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Persistence\ObjectManager; -/** - * EntityManager interface - * - * @method Mapping\ClassMetadataFactory getMetadataFactory() - */ interface EntityManagerInterface extends ObjectManager { /** @@ -32,21 +28,19 @@ interface EntityManagerInterface extends ObjectManager * * @template T */ - public function getRepository($className); + public function getRepository($className): EntityRepository; /** * Returns the cache API for managing the second level cache regions or NULL if the cache is not enabled. - * - * @return Cache|null */ - public function getCache(); + public function getCache(): ?Cache; /** * Gets the database connection object used by the EntityManager. - * - * @return Connection */ - public function getConnection(); + public function getConnection(): Connection; + + public function getMetadataFactory(): ClassMetadataFactory; /** * Gets an ExpressionBuilder used for object-oriented construction of query expressions. @@ -59,17 +53,13 @@ public function getConnection(); * $qb->select('u')->from('User', 'u') * ->where($expr->orX($expr->eq('u.id', 1), $expr->eq('u.id', 2))); * - * - * @return Expr */ - public function getExpressionBuilder(); + public function getExpressionBuilder(): Expr; /** * Starts a transaction on the underlying database connection. - * - * @return void */ - public function beginTransaction(); + public function beginTransaction(): void; /** * Executes a function in a transaction. @@ -81,9 +71,10 @@ public function beginTransaction(); * If an exception occurs during execution of the function or flushing or transaction commit, * the transaction is rolled back, the EntityManager closed and the exception re-thrown. * - * @param callable(self): T $func The function to execute transactionally. + * @psalm-param callable(self): T $func The function to execute transactionally. * - * @return T The value returned from the closure. + * @return mixed The value returned from the closure. + * @psalm-return T * * @template T */ @@ -91,61 +82,65 @@ public function wrapInTransaction(callable $func); /** * Commits a transaction on the underlying database connection. - * - * @return void */ - public function commit(); + public function commit(): void; /** * Performs a rollback on the underlying database connection. - * - * @return void */ - public function rollback(); + public function rollback(): void; /** * Creates a new Query object. * * @param string $dql The DQL string. - * - * @return Query */ - public function createQuery($dql = ''); + public function createQuery(string $dql = ''): Query; /** * Creates a Query from a named query. - * - * @param string $name - * - * @return Query */ - public function createNamedQuery($name); + public function createNamedQuery(string $name): Query; /** * Creates a native SQL query. - * - * @param string $sql - * @param ResultSetMapping $rsm The ResultSetMapping to use. - * - * @return NativeQuery */ - public function createNativeQuery($sql, ResultSetMapping $rsm); + public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery; /** * Creates a NativeQuery from a named native query. - * - * @param string $name - * - * @return NativeQuery */ - public function createNamedNativeQuery($name); + public function createNamedNativeQuery(string $name): NativeQuery; /** * Create a QueryBuilder instance + */ + public function createQueryBuilder(): QueryBuilder; + + /** + * Finds an Entity by its identifier. + * + * @param string $className The class name of the entity to find. + * @param mixed $id The identity of the entity to find. + * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * during the search. + * @param int|null $lockVersion The version of the entity to find when using + * optimistic locking. + * @psalm-param class-string $className + * @psalm-param LockMode::*|null $lockMode + * + * @return object|null The entity instance or NULL if the entity can not be found. + * @psalm-return T|null + * + * @throws OptimisticLockException + * @throws ORMInvalidArgumentException + * @throws TransactionRequiredException + * @throws ORMException * - * @return QueryBuilder + * @template T of object */ - public function createQueryBuilder(); + public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object; /** * Gets a reference to the entity identified by the given type and identifier @@ -155,14 +150,13 @@ public function createQueryBuilder(); * @param mixed $id The entity identifier. * @psalm-param class-string $entityName * - * @return object|null The entity reference. * @psalm-return T|null * * @throws ORMException * - * @template T + * @template T of object */ - public function getReference($entityName, $id); + public function getReference(string $entityName, $id): ?object; /** * Gets a partial reference to the entity identified by the given type and identifier @@ -183,127 +177,87 @@ public function getReference($entityName, $id); * @param mixed $identifier The entity identifier. * @psalm-param class-string $entityName * - * @return object|null The (partial) entity reference * @psalm-return T|null * - * @template T + * @template T of object */ - public function getPartialReference($entityName, $identifier); + public function getPartialReference(string $entityName, $identifier): ?object; /** * Closes the EntityManager. All entities that are currently managed * by this EntityManager become detached. The EntityManager may no longer * be used after it is closed. - * - * @return void */ - public function close(); + public function close(): void; /** * Acquire a lock on the given entity. * - * @param object $entity - * @param int $lockMode * @param int|DateTimeInterface|null $lockVersion * @psalm-param LockMode::* $lockMode * - * @return void - * * @throws OptimisticLockException * @throws PessimisticLockException */ - public function lock($entity, $lockMode, $lockVersion = null); + public function lock(object $entity, int $lockMode, $lockVersion = null): void; /** * Gets the EventManager used by the EntityManager. - * - * @return EventManager */ - public function getEventManager(); + public function getEventManager(): EventManager; /** * Gets the Configuration used by the EntityManager. - * - * @return Configuration */ - public function getConfiguration(); + public function getConfiguration(): Configuration; /** * Check if the Entity manager is open or closed. - * - * @return bool */ - public function isOpen(); + public function isOpen(): bool; /** * Gets the UnitOfWork used by the EntityManager to coordinate operations. - * - * @return UnitOfWork - */ - public function getUnitOfWork(); - - /** - * Gets a hydrator for the given hydration mode. - * - * This method caches the hydrator instances which is used for all queries that don't - * selectively iterate over the result. - * - * @deprecated - * - * @param string|int $hydrationMode - * - * @return AbstractHydrator */ - public function getHydrator($hydrationMode); + public function getUnitOfWork(): UnitOfWork; /** * Create a new instance for the given hydration mode. * * @param string|int $hydrationMode * - * @return AbstractHydrator - * * @throws ORMException */ - public function newHydrator($hydrationMode); + public function newHydrator($hydrationMode): AbstractHydrator; /** * Gets the proxy factory used by the EntityManager to create entity proxies. - * - * @return ProxyFactory */ - public function getProxyFactory(); + public function getProxyFactory(): ProxyFactory; /** * Gets the enabled filters. - * - * @return FilterCollection The active filter collection. */ - public function getFilters(); + public function getFilters(): FilterCollection; /** * Checks whether the state of the filter collection is clean. - * - * @return bool True, if the filter collection is clean. */ - public function isFiltersStateClean(); + public function isFiltersStateClean(): bool; /** * Checks whether the Entity Manager has filters. - * - * @return bool True, if the EM has a filter collection. */ - public function hasFilters(); + public function hasFilters(): bool; /** * {@inheritDoc} * * @psalm-param string|class-string $className * - * @return Mapping\ClassMetadata * @psalm-return Mapping\ClassMetadata * * @psalm-template T of object */ - public function getClassMetadata($className); + public function getClassMetadata($className): Mapping\ClassMetadata; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fcbe53514ff..7d1bf0276a3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -121,7 +121,17 @@ parameters: path: lib/Doctrine/ORM/Configuration.php - - message: "#^Method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:find\\(\\) invoked with 4 parameters, 2 required\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\Decorator\\\\EntityManagerDecorator\\:\\:getClassMetadata\\(\\) should return Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata but returns Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\.$#" + count: 1 + path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php + + - + message: "#^Method Doctrine\\\\ORM\\\\Decorator\\\\EntityManagerDecorator\\:\\:getMetadataFactory\\(\\) should return Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory but returns Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\.$#" + count: 1 + path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php + + - + message: "#^Method Doctrine\\\\ORM\\\\Decorator\\\\EntityManagerDecorator\\:\\:getRepository\\(\\) should return Doctrine\\\\ORM\\\\EntityRepository but returns Doctrine\\\\Persistence\\\\ObjectRepository\\\\.$#" count: 1 path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -130,38 +140,48 @@ parameters: count: 1 path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php + - + message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\Decorator\\\\EntityManagerDecorator\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getMetadataFactory\\(\\)$#" + count: 1 + path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php + + - + message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\Decorator\\\\EntityManagerDecorator\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManagerDecorator\\:\\:getMetadataFactory\\(\\)$#" + count: 1 + path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php + - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" count: 1 path: lib/Doctrine/ORM/EntityManager.php - - message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:find\\(\\) should return T\\|null but returns object\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:find\\(\\) should return T of object\\|null but returns object\\.$#" count: 1 path: lib/Doctrine/ORM/EntityManager.php - - message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:find\\(\\) should return T\\|null but returns object\\|null\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:find\\(\\) should return T of object\\|null but returns object\\|null\\.$#" count: 3 path: lib/Doctrine/ORM/EntityManager.php - - message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getPartialReference\\(\\) should return T\\|null but returns object\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getPartialReference\\(\\) should return T of object\\|null but returns object\\.$#" count: 1 path: lib/Doctrine/ORM/EntityManager.php - - message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getPartialReference\\(\\) should return T\\|null but returns object\\|null\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getPartialReference\\(\\) should return T of object\\|null but returns object\\|null\\.$#" count: 1 path: lib/Doctrine/ORM/EntityManager.php - - message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getReference\\(\\) should return T\\|null but returns Doctrine\\\\Common\\\\Proxy\\\\Proxy\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getReference\\(\\) should return T of object\\|null but returns Doctrine\\\\Common\\\\Proxy\\\\Proxy\\.$#" count: 1 path: lib/Doctrine/ORM/EntityManager.php - - message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getReference\\(\\) should return T\\|null but returns object\\|null\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getReference\\(\\) should return T of object\\|null but returns object\\|null\\.$#" count: 1 path: lib/Doctrine/ORM/EntityManager.php @@ -172,9 +192,14 @@ parameters: - message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\EntityManager\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getMetadataFactory\\(\\)$#" - count: 2 + count: 1 path: lib/Doctrine/ORM/EntityManager.php + - + message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\EntityManagerInterface\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getMetadataFactory\\(\\)$#" + count: 1 + path: lib/Doctrine/ORM/EntityManagerInterface.php + - message: "#^Template type T of method Doctrine\\\\ORM\\\\EntityManagerInterface\\:\\:getClassMetadata\\(\\) is not referenced in a parameter\\.$#" count: 1 @@ -1554,3 +1579,4 @@ parameters: message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#" count: 1 path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index abdeb61b299..fddb99638a2 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -369,19 +369,33 @@ - - getHydrator - - + + $className + + + ProxyFactory + + + parent::getMetadataFactory() + + + ClassMetadataFactory + + + parent::getClassMetadata($className) + parent::getRepository($className) + + $entity - $lockMode - $lockVersion + + ClassMetadata + EntityRepository + $wrapped - - find + flush @@ -389,7 +403,8 @@ $connection - + + ProxyFactory ProxyFactory @@ -407,10 +422,7 @@ is_object($entity) is_object($entity) - - ClassMetadataFactory - - + $entity $entity $entity @@ -419,13 +431,15 @@ $entity instanceof $class->name ? $entity : null $persister->load($sortedId, null, null, [], $lockMode) $persister->loadById($sortedId) + $this->metadataFactory $this->metadataFactory->getMetadataFor($className) - - ?T - getClassMetadata - getPartialReference - getReference + + ?object + ?object + ?object + ClassMetadataFactory + Mapping\ClassMetadata $hydrationMode @@ -435,8 +449,8 @@ new $class($this) + AbstractHydrator EntityRepository<T> - newHydrator $entity diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 8f101c416e4..40db66982e5 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -4,27 +4,37 @@ namespace Doctrine\Performance\Mock; +use Doctrine\Common\EventManager; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\Cache; +use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\Internal\Hydration\AbstractHydrator; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadataFactory; +use Doctrine\ORM\NativeQuery; use Doctrine\ORM\Proxy\ProxyFactory; +use Doctrine\ORM\Query; +use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\FilterCollection; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\ORM\QueryBuilder; +use Doctrine\ORM\UnitOfWork; /** * An entity manager mock that prevents lazy-loading of proxies */ class NonProxyLoadingEntityManager implements EntityManagerInterface { - /** @var EntityManagerInterface */ - private $realEntityManager; + private EntityManagerInterface $realEntityManager; public function __construct(EntityManagerInterface $realEntityManager) { $this->realEntityManager = $realEntityManager; } - /** - * {@inheritDoc} - */ - public function getProxyFactory() + public function getProxyFactory(): ProxyFactory { $config = $this->realEntityManager->getConfiguration(); @@ -36,10 +46,7 @@ public function getProxyFactory() ); } - /** - * {@inheritDoc} - */ - public function getMetadataFactory() + public function getMetadataFactory(): ClassMetadataFactory { return $this->realEntityManager->getMetadataFactory(); } @@ -47,47 +54,32 @@ public function getMetadataFactory() /** * {@inheritDoc} */ - public function getClassMetadata($className) + public function getClassMetadata($className): ClassMetadata { return $this->realEntityManager->getClassMetadata($className); } - /** - * {@inheritDoc} - */ - public function getUnitOfWork() + public function getUnitOfWork(): UnitOfWork { return new NonProxyLoadingUnitOfWork(); } - /** - * {@inheritDoc} - */ - public function getCache() + public function getCache(): ?Cache { return $this->realEntityManager->getCache(); } - /** - * {@inheritDoc} - */ - public function getConnection() + public function getConnection(): Connection { return $this->realEntityManager->getConnection(); } - /** - * {@inheritDoc} - */ - public function getExpressionBuilder() + public function getExpressionBuilder(): Expr { return $this->realEntityManager->getExpressionBuilder(); } - /** - * {@inheritDoc} - */ - public function beginTransaction() + public function beginTransaction(): void { $this->realEntityManager->beginTransaction(); } @@ -100,58 +92,37 @@ public function wrapInTransaction(callable $func) return $this->realEntityManager->wrapInTransaction($func); } - /** - * {@inheritDoc} - */ - public function commit() + public function commit(): void { $this->realEntityManager->commit(); } - /** - * {@inheritDoc} - */ - public function rollback() + public function rollback(): void { $this->realEntityManager->rollback(); } - /** - * {@inheritDoc} - */ - public function createQuery($dql = '') + public function createQuery(string $dql = ''): Query { return $this->realEntityManager->createQuery($dql); } - /** - * {@inheritDoc} - */ - public function createNamedQuery($name) + public function createNamedQuery(string $name): Query { return $this->realEntityManager->createNamedQuery($name); } - /** - * {@inheritDoc} - */ - public function createNativeQuery($sql, ResultSetMapping $rsm) + public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery { return $this->realEntityManager->createNativeQuery($sql, $rsm); } - /** - * {@inheritDoc} - */ - public function createNamedNativeQuery($name) + public function createNamedNativeQuery(string $name): NativeQuery { return $this->realEntityManager->createNamedNativeQuery($name); } - /** - * {@inheritDoc} - */ - public function createQueryBuilder() + public function createQueryBuilder(): QueryBuilder { return $this->realEntityManager->createQueryBuilder(); } @@ -159,7 +130,7 @@ public function createQueryBuilder() /** * {@inheritDoc} */ - public function getReference($entityName, $id) + public function getReference(string $entityName, $id): ?object { return $this->realEntityManager->getReference($entityName, $id); } @@ -167,15 +138,12 @@ public function getReference($entityName, $id) /** * {@inheritDoc} */ - public function getPartialReference($entityName, $identifier) + public function getPartialReference(string $entityName, $identifier): ?object { return $this->realEntityManager->getPartialReference($entityName, $identifier); } - /** - * {@inheritDoc} - */ - public function close() + public function close(): void { $this->realEntityManager->close(); } @@ -183,31 +151,22 @@ public function close() /** * {@inheritDoc} */ - public function lock($entity, $lockMode, $lockVersion = null) + public function lock(object $entity, int $lockMode, $lockVersion = null): void { $this->realEntityManager->lock($entity, $lockMode, $lockVersion); } - /** - * {@inheritDoc} - */ - public function getEventManager() + public function getEventManager(): EventManager { return $this->realEntityManager->getEventManager(); } - /** - * {@inheritDoc} - */ - public function getConfiguration() + public function getConfiguration(): Configuration { return $this->realEntityManager->getConfiguration(); } - /** - * {@inheritDoc} - */ - public function isOpen() + public function isOpen(): bool { return $this->realEntityManager->isOpen(); } @@ -215,39 +174,22 @@ public function isOpen() /** * {@inheritDoc} */ - public function getHydrator($hydrationMode) - { - return $this->realEntityManager->getHydrator($hydrationMode); - } - - /** - * {@inheritDoc} - */ - public function newHydrator($hydrationMode) + public function newHydrator($hydrationMode): AbstractHydrator { return $this->realEntityManager->newHydrator($hydrationMode); } - /** - * {@inheritDoc} - */ - public function getFilters() + public function getFilters(): FilterCollection { return $this->realEntityManager->getFilters(); } - /** - * {@inheritDoc} - */ - public function isFiltersStateClean() + public function isFiltersStateClean(): bool { return $this->realEntityManager->isFiltersStateClean(); } - /** - * {@inheritDoc} - */ - public function hasFilters() + public function hasFilters(): bool { return $this->realEntityManager->hasFilters(); } @@ -255,15 +197,15 @@ public function hasFilters() /** * {@inheritDoc} */ - public function find($className, $id) + public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object { - return $this->realEntityManager->find($className, $id); + return $this->realEntityManager->find($className, $id, $lockMode, $lockVersion); } /** * {@inheritDoc} */ - public function persist($object) + public function persist($object): void { $this->realEntityManager->persist($object); } @@ -271,7 +213,7 @@ public function persist($object) /** * {@inheritDoc} */ - public function remove($object) + public function remove($object): void { $this->realEntityManager->remove($object); } @@ -279,7 +221,7 @@ public function remove($object) /** * {@inheritDoc} */ - public function merge($object) + public function merge($object): object { return $this->realEntityManager->merge($object); } @@ -287,7 +229,7 @@ public function merge($object) /** * {@inheritDoc} */ - public function clear($objectName = null) + public function clear($objectName = null): void { $this->realEntityManager->clear($objectName); } @@ -295,7 +237,7 @@ public function clear($objectName = null) /** * {@inheritDoc} */ - public function detach($object) + public function detach($object): void { $this->realEntityManager->detach($object); } @@ -303,15 +245,12 @@ public function detach($object) /** * {@inheritDoc} */ - public function refresh($object) + public function refresh($object): void { $this->realEntityManager->refresh($object); } - /** - * {@inheritDoc} - */ - public function flush() + public function flush(): void { $this->realEntityManager->flush(); } @@ -319,7 +258,7 @@ public function flush() /** * {@inheritDoc} */ - public function getRepository($className) + public function getRepository($className): EntityRepository { return $this->realEntityManager->getRepository($className); } @@ -327,7 +266,7 @@ public function getRepository($className) /** * {@inheritDoc} */ - public function initializeObject($obj) + public function initializeObject($obj): void { $this->realEntityManager->initializeObject($obj); } @@ -335,7 +274,7 @@ public function initializeObject($obj) /** * {@inheritDoc} */ - public function contains($object) + public function contains($object): bool { return $this->realEntityManager->contains($object); } diff --git a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php index 51ca576ae32..33798a14a95 100644 --- a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php @@ -15,16 +15,10 @@ */ class EntityManagerMock extends EntityManager { - /** @var UnitOfWork|null */ - private $_uowMock; + private ?UnitOfWork $_uowMock = null; + private ?ProxyFactory $_proxyFactoryMock = null; - /** @var ProxyFactory|null */ - private $_proxyFactoryMock; - - /** - * {@inheritdoc} - */ - public function getUnitOfWork() + public function getUnitOfWork(): UnitOfWork { return $this->_uowMock ?? parent::getUnitOfWork(); } @@ -54,7 +48,7 @@ public function getProxyFactory(): ProxyFactory * * {@inheritdoc} */ - public static function create($conn, ?Configuration $config = null, ?EventManager $eventManager = null) + public static function create($conn, ?Configuration $config = null, ?EventManager $eventManager = null): self { if ($config === null) { $config = new Configuration(); @@ -63,9 +57,7 @@ public static function create($conn, ?Configuration $config = null, ?EventManage $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([], false)); } - if ($eventManager === null) { - $eventManager = new EventManager(); - } + $eventManager ??= new EventManager(); return new EntityManagerMock($conn, $config, $eventManager); } diff --git a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php deleted file mode 100644 index 4600871065d..00000000000 --- a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php +++ /dev/null @@ -1,112 +0,0 @@ -wrapped = $this->createMock(EntityManagerInterface::class); - } - - /** @psalm-return array */ - public function getMethodParameters(): array - { - $class = new ReflectionClass(EntityManagerInterface::class); - $methods = []; - - foreach ($class->getMethods() as $method) { - if ($method->isConstructor() || $method->isStatic() || ! $method->isPublic()) { - continue; - } - - $methods[$method->getName()] = $this->getParameters($method); - } - - return $methods; - } - - /** - * @return mixed[] - */ - private function getParameters(ReflectionMethod $method): array - { - /** Special case EntityManager::createNativeQuery() */ - if ($method->getName() === 'createNativeQuery') { - return [$method->getName(), ['name', new ResultSetMapping()]]; - } - - if ($method->getName() === 'wrapInTransaction') { - return [ - $method->getName(), - [ - static function (): void { - }, - ], - ]; - } - - if ($method->getNumberOfRequiredParameters() === 0) { - return [$method->getName(), []]; - } - - if ($method->getNumberOfRequiredParameters() > 0) { - return [$method->getName(), array_fill(0, $method->getNumberOfRequiredParameters(), 'req') ?: []]; - } - - if ($method->getNumberOfParameters() !== $method->getNumberOfRequiredParameters()) { - return [$method->getName(), array_fill(0, $method->getNumberOfParameters(), 'all') ?: []]; - } - - return []; - } - - /** - * @dataProvider getMethodParameters - */ - public function testAllMethodCallsAreDelegatedToTheWrappedInstance($method, array $parameters): void - { - $return = ! in_array($method, self::VOID_METHODS, true) ? 'INNER VALUE FROM ' . $method : null; - - $this->wrapped->expects(self::once()) - ->method($method) - ->with(...$parameters) - ->willReturn($return); - - $decorator = new class ($this->wrapped) extends EntityManagerDecorator { - }; - - self::assertSame($return, $decorator->$method(...$parameters)); - } -} From 2a0c73d0e586553a41f83c1ee38b50e74d51100e Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 5 Jan 2022 07:57:09 +0100 Subject: [PATCH 024/475] Add types to UnitOfWork (#9329) --- lib/Doctrine/ORM/UnitOfWork.php | 483 +++++------------- psalm-baseline.xml | 22 +- .../Mock/NonProxyLoadingUnitOfWork.php | 9 +- tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php | 25 +- 4 files changed, 144 insertions(+), 395 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index f059f3bde21..36ddb5fa17a 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -114,19 +114,17 @@ class UnitOfWork implements PropertyChangedListener * Since all classes in a hierarchy must share the same identifier set, * we always take the root class name of the hierarchy. * - * @var mixed[] * @psalm-var array> */ - private $identityMap = []; + private array $identityMap = []; /** * Map of all identifiers of managed entities. * Keys are object ids (spl_object_id). * - * @var mixed[] * @psalm-var array> */ - private $entityIdentifiers = []; + private array $entityIdentifiers = []; /** * Map of the original entity data of managed entities. @@ -139,7 +137,7 @@ class UnitOfWork implements PropertyChangedListener * * @psalm-var array> */ - private $originalEntityData = []; + private array $originalEntityData = []; /** * Map of entity changes. Keys are object ids (spl_object_id). @@ -147,7 +145,7 @@ class UnitOfWork implements PropertyChangedListener * * @psalm-var array> */ - private $entityChangeSets = []; + private array $entityChangeSets = []; /** * The (cached) states of any known entities. @@ -155,7 +153,7 @@ class UnitOfWork implements PropertyChangedListener * * @psalm-var array */ - private $entityStates = []; + private array $entityStates = []; /** * Map of entities that are scheduled for dirty checking at commit time. @@ -164,35 +162,35 @@ class UnitOfWork implements PropertyChangedListener * * @psalm-var array> */ - private $scheduledForSynchronization = []; + private array $scheduledForSynchronization = []; /** * A list of all pending entity insertions. * * @psalm-var array */ - private $entityInsertions = []; + private array $entityInsertions = []; /** * A list of all pending entity updates. * * @psalm-var array */ - private $entityUpdates = []; + private array $entityUpdates = []; /** * Any pending extra updates that have been scheduled by persisters. * * @psalm-var array}> */ - private $extraUpdates = []; + private array $extraUpdates = []; /** * A list of all pending entity deletions. * * @psalm-var array */ - private $entityDeletions = []; + private array $entityDeletions = []; /** * New entities that were discovered through relationships that were not @@ -205,21 +203,21 @@ class UnitOfWork implements PropertyChangedListener * * @var object[][]|array[][] indexed by respective object spl_object_id() */ - private $nonCascadedNewDetectedEntities = []; + private array $nonCascadedNewDetectedEntities = []; /** * All pending collection deletions. * * @psalm-var array> */ - private $collectionDeletions = []; + private array $collectionDeletions = []; /** * All pending collection updates. * * @psalm-var array> */ - private $collectionUpdates = []; + private array $collectionUpdates = []; /** * List of collections visited during changeset calculation on a commit-phase of a UnitOfWork. @@ -228,83 +226,71 @@ class UnitOfWork implements PropertyChangedListener * * @psalm-var array> */ - private $visitedCollections = []; + private array $visitedCollections = []; /** * The EntityManager that "owns" this UnitOfWork instance. - * - * @var EntityManagerInterface */ - private $em; + private EntityManagerInterface $em; /** * The entity persister instances used to persist entity instances. * * @psalm-var array */ - private $persisters = []; + private array $persisters = []; /** * The collection persister instances used to persist collections. * * @psalm-var array */ - private $collectionPersisters = []; + private array $collectionPersisters = []; /** * The EventManager used for dispatching events. - * - * @var EventManager */ - private $evm; + private EventManager $evm; /** * The ListenersInvoker used for dispatching events. - * - * @var ListenersInvoker */ - private $listenersInvoker; + private ListenersInvoker $listenersInvoker; /** * The IdentifierFlattener used for manipulating identifiers - * - * @var IdentifierFlattener */ - private $identifierFlattener; + private IdentifierFlattener $identifierFlattener; /** * Orphaned entities that are scheduled for removal. * * @psalm-var array */ - private $orphanRemovals = []; + private array $orphanRemovals = []; /** * Read-Only objects are never evaluated * * @var array */ - private $readOnlyObjects = []; + private array $readOnlyObjects = []; /** * Map of Entity Class-Names and corresponding IDs that should eager loaded when requested. * * @psalm-var array> */ - private $eagerLoadingEntities = []; + private array $eagerLoadingEntities = []; - /** @var bool */ - protected $hasCache = false; + protected bool $hasCache = false; /** * Helper for handling completion of hydration - * - * @var HydrationCompleteHandler */ - private $hydrationCompleteHandler; + private HydrationCompleteHandler $hydrationCompleteHandler; - /** @var ReflectionPropertiesGetter */ - private $reflectionPropertiesGetter; + private ReflectionPropertiesGetter $reflectionPropertiesGetter; /** * Initializes a new UnitOfWork instance, bound to the given EntityManager. @@ -335,11 +321,9 @@ public function __construct(EntityManagerInterface $em) * * @param object|mixed[]|null $entity * - * @return void - * * @throws Exception */ - public function commit($entity = null) + public function commit(object|array|null $entity = null): void { $connection = $this->em->getConnection(); @@ -357,7 +341,7 @@ public function commit($entity = null) $this->computeChangeSets(); } elseif (is_object($entity)) { $this->computeSingleEntityChangeSet($entity); - } elseif (is_array($entity)) { + } else { foreach ($entity as $object) { $this->computeSingleEntityChangeSet($object); } @@ -474,7 +458,7 @@ public function commit($entity = null) /** * @param object|object[]|null $entity */ - private function postCommitCleanup($entity): void + private function postCommitCleanup(object|array|null $entity): void { $this->entityInsertions = $this->entityUpdates = @@ -525,11 +509,9 @@ private function computeScheduleInsertsChangeSets(): void * 3. Proxies are skipped. * 4. Only if entity is properly managed. * - * @param object $entity - * * @throws InvalidArgumentException */ - private function computeSingleEntityChangeSet($entity): void + private function computeSingleEntityChangeSet(object $entity): void { $state = $this->getEntityState($entity); @@ -581,12 +563,10 @@ private function executeExtraUpdates(): void /** * Gets the changeset for an entity. * - * @param object $entity - * * @return mixed[][] * @psalm-return array */ - public function & getEntityChangeSet($entity) + public function & getEntityChangeSet(object $entity): array { $oid = spl_object_id($entity); $data = []; @@ -628,13 +608,11 @@ public function & getEntityChangeSet($entity) * @psalm-param ClassMetadata $class * @psalm-param T $entity * - * @return void - * * @template T of object * * @ignore */ - public function computeChangeSet(ClassMetadata $class, $entity) + public function computeChangeSet(ClassMetadata $class, object $entity): void { $oid = spl_object_id($entity); @@ -827,10 +805,8 @@ public function computeChangeSet(ClassMetadata $class, $entity) * Computes all the changes that have been done to entities and collections * since the last commit and stores these changes in the _entityChangeSet map * temporarily for access by the persisters, until the UoW commit is finished. - * - * @return void */ - public function computeChangeSets() + public function computeChangeSets(): void { // Compute changes for INSERTed entities first. This must always happen. $this->computeScheduleInsertsChangeSets(); @@ -884,7 +860,7 @@ public function computeChangeSets() * @throws ORMInvalidArgumentException * @throws ORMException */ - private function computeAssociationChanges(array $assoc, $value): void + private function computeAssociationChanges(array $assoc, mixed $value): void { if ($value instanceof Proxy && ! $value->__isInitialized()) { return; @@ -962,13 +938,12 @@ private function computeAssociationChanges(array $assoc, $value): void } /** - * @param object $entity * @psalm-param ClassMetadata $class * @psalm-param T $entity * * @template T of object */ - private function persistNew(ClassMetadata $class, $entity): void + private function persistNew(ClassMetadata $class, object $entity): void { $oid = spl_object_id($entity); $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::prePersist); @@ -1028,14 +1003,12 @@ private function hasMissingIdsWhichAreForeignKeys(ClassMetadata $class, array $i * @psalm-param ClassMetadata $class * @psalm-param T $entity * - * @return void - * * @throws ORMInvalidArgumentException If the passed entity is not MANAGED. * * @template T of object * @ignore */ - public function recomputeSingleEntityChangeSet(ClassMetadata $class, $entity) + public function recomputeSingleEntityChangeSet(ClassMetadata $class, object $entity): void { $oid = spl_object_id($entity); @@ -1154,7 +1127,6 @@ private function executeInserts(ClassMetadata $class): void } /** - * @param object $entity * @psalm-param ClassMetadata $class * @psalm-param T $entity * @@ -1163,7 +1135,7 @@ private function executeInserts(ClassMetadata $class): void private function addToEntityIdentifiersAndEntityMap( ClassMetadata $class, int $oid, - $entity + object $entity ): void { $identifier = []; @@ -1328,14 +1300,10 @@ private function getCommitOrder(): array * Schedules an entity for insertion into the database. * If the entity already has an identifier, it will be added to the identity map. * - * @param object $entity The entity to schedule for insertion. - * - * @return void - * * @throws ORMInvalidArgumentException * @throws InvalidArgumentException */ - public function scheduleForInsert($entity) + public function scheduleForInsert(object $entity): void { $oid = spl_object_id($entity); @@ -1368,12 +1336,8 @@ public function scheduleForInsert($entity) /** * Checks whether an entity is scheduled for insertion. - * - * @param object $entity - * - * @return bool */ - public function isScheduledForInsert($entity) + public function isScheduledForInsert(object $entity): bool { return isset($this->entityInsertions[spl_object_id($entity)]); } @@ -1381,13 +1345,9 @@ public function isScheduledForInsert($entity) /** * Schedules an entity for being updated. * - * @param object $entity The entity to schedule for being updated. - * - * @return void - * * @throws ORMInvalidArgumentException */ - public function scheduleForUpdate($entity) + public function scheduleForUpdate(object $entity): void { $oid = spl_object_id($entity); @@ -1411,14 +1371,11 @@ public function scheduleForUpdate($entity) * * Extra updates for entities are stored as (entity, changeset) tuples. * - * @param object $entity The entity for which to schedule an extra update. * @psalm-param array $changeset The changeset of the entity (what to update). * - * @return void - * * @ignore */ - public function scheduleExtraUpdate($entity, array $changeset) + public function scheduleExtraUpdate(object $entity, array $changeset): void { $oid = spl_object_id($entity); $extraUpdate = [$entity, $changeset]; @@ -1436,24 +1393,16 @@ public function scheduleExtraUpdate($entity, array $changeset) * Checks whether an entity is registered as dirty in the unit of work. * Note: Is not very useful currently as dirty entities are only registered * at commit time. - * - * @param object $entity - * - * @return bool */ - public function isScheduledForUpdate($entity) + public function isScheduledForUpdate(object $entity): bool { return isset($this->entityUpdates[spl_object_id($entity)]); } /** * Checks whether an entity is registered to be checked in the unit of work. - * - * @param object $entity - * - * @return bool */ - public function isScheduledForDirtyCheck($entity) + public function isScheduledForDirtyCheck(object $entity): bool { $rootEntityName = $this->em->getClassMetadata(get_class($entity))->rootEntityName; @@ -1463,12 +1412,8 @@ public function isScheduledForDirtyCheck($entity) /** * INTERNAL: * Schedules an entity for deletion. - * - * @param object $entity - * - * @return void */ - public function scheduleForDelete($entity) + public function scheduleForDelete(object $entity): void { $oid = spl_object_id($entity); @@ -1499,24 +1444,16 @@ public function scheduleForDelete($entity) /** * Checks whether an entity is registered as removed/deleted with the unit * of work. - * - * @param object $entity - * - * @return bool */ - public function isScheduledForDelete($entity) + public function isScheduledForDelete(object $entity): bool { return isset($this->entityDeletions[spl_object_id($entity)]); } /** * Checks whether an entity is scheduled for insertion, update or deletion. - * - * @param object $entity - * - * @return bool */ - public function isEntityScheduled($entity) + public function isEntityScheduled(object $entity): bool { $oid = spl_object_id($entity); @@ -1531,8 +1468,6 @@ public function isEntityScheduled($entity) * Note that entities in a hierarchy are registered with the class name of * the root entity. * - * @param object $entity The entity to register. - * * @return bool TRUE if the registration was successful, FALSE if the identity of * the entity in question is already managed. * @@ -1540,7 +1475,7 @@ public function isEntityScheduled($entity) * * @ignore */ - public function addToIdentityMap($entity) + public function addToIdentityMap(object $entity): bool { $classMetadata = $this->em->getClassMetadata(get_class($entity)); $identifier = $this->entityIdentifiers[spl_object_id($entity)]; @@ -1564,15 +1499,12 @@ public function addToIdentityMap($entity) /** * Gets the state of an entity with regard to the current unit of work. * - * @param object $entity * @param int|null $assume The state to assume if the state is not yet known (not MANAGED or REMOVED). * This parameter can be set to improve performance of entity state detection * by potentially avoiding a database lookup if the distinction between NEW and DETACHED * is either known or does not matter for the caller of the method. - * - * @return int The entity state. */ - public function getEntityState($entity, $assume = null) + public function getEntityState(object $entity, ?int $assume = null): int { $oid = spl_object_id($entity); @@ -1647,15 +1579,11 @@ public function getEntityState($entity, $assume = null) * Removes an entity from the identity map. This effectively detaches the * entity from the persistence management of Doctrine. * - * @param object $entity - * - * @return bool - * * @throws ORMInvalidArgumentException * * @ignore */ - public function removeFromIdentityMap($entity) + public function removeFromIdentityMap(object $entity): bool { $oid = spl_object_id($entity); $classMetadata = $this->em->getClassMetadata(get_class($entity)); @@ -1682,14 +1610,9 @@ public function removeFromIdentityMap($entity) * INTERNAL: * Gets an entity in the identity map by its identifier hash. * - * @param string $idHash - * @param string $rootClassName - * - * @return object - * * @ignore */ - public function getByIdHash($idHash, $rootClassName) + public function getByIdHash(string $idHash, string $rootClassName): object { return $this->identityMap[$rootClassName][$idHash]; } @@ -1699,14 +1622,13 @@ public function getByIdHash($idHash, $rootClassName) * Tries to get an entity by its identifier hash. If no entity is found for * the given hash, FALSE is returned. * - * @param mixed $idHash (must be possible to cast it to string) - * @param string $rootClassName + * @param mixed $idHash (must be possible to cast it to string) * * @return false|object The found entity or FALSE. * * @ignore */ - public function tryGetByIdHash($idHash, $rootClassName) + public function tryGetByIdHash(mixed $idHash, string $rootClassName): object|false { $stringIdHash = (string) $idHash; @@ -1715,12 +1637,8 @@ public function tryGetByIdHash($idHash, $rootClassName) /** * Checks whether an entity is registered in the identity map of this UnitOfWork. - * - * @param object $entity - * - * @return bool */ - public function isInIdentityMap($entity) + public function isInIdentityMap(object $entity): bool { $oid = spl_object_id($entity); @@ -1734,30 +1652,10 @@ public function isInIdentityMap($entity) return isset($this->identityMap[$classMetadata->rootEntityName][$idHash]); } - /** - * INTERNAL: - * Checks whether an identifier hash exists in the identity map. - * - * @param string $idHash - * @param string $rootClassName - * - * @return bool - * - * @ignore - */ - public function containsIdHash($idHash, $rootClassName) - { - return isset($this->identityMap[$rootClassName][$idHash]); - } - /** * Persists an entity as part of the current unit of work. - * - * @param object $entity The entity to persist. - * - * @return void */ - public function persist($entity) + public function persist(object $entity): void { $visited = []; @@ -1770,13 +1668,12 @@ public function persist($entity) * This method is internally called during persist() cascades as it tracks * the already visited entities to prevent infinite recursions. * - * @param object $entity The entity to persist. * @psalm-param array $visited The already visited entities. * * @throws ORMInvalidArgumentException * @throws UnexpectedValueException */ - private function doPersist($entity, array &$visited): void + private function doPersist(object $entity, array &$visited): void { $oid = spl_object_id($entity); @@ -1837,12 +1734,8 @@ private function doPersist($entity, array &$visited): void /** * Deletes an entity as part of the current unit of work. - * - * @param object $entity The entity to remove. - * - * @return void */ - public function remove($entity) + public function remove(object $entity): void { $visited = []; @@ -1855,13 +1748,12 @@ public function remove($entity) * This method is internally called during delete() cascades as it tracks * the already visited entities to prevent infinite recursions. * - * @param object $entity The entity to delete. * @psalm-param array $visited The map of the already visited entities. * * @throws ORMInvalidArgumentException If the instance is a detached entity. * @throws UnexpectedValueException */ - private function doRemove($entity, array &$visited): void + private function doRemove(object $entity, array &$visited): void { $oid = spl_object_id($entity); @@ -1911,14 +1803,12 @@ private function doRemove($entity, array &$visited): void * * @deprecated 2.7 This method is being removed from the ORM and won't have any replacement * - * @param object $entity - * * @return object The managed copy of the entity. * * @throws OptimisticLockException If the entity uses optimistic locking through a version * attribute and the version check against the managed copy fails. */ - public function merge($entity) + public function merge(object $entity): object { $visited = []; @@ -1928,7 +1818,6 @@ public function merge($entity) /** * Executes a merge operation on an entity. * - * @param object $entity * @param string[] $assoc * @psalm-param array $visited * @@ -1940,11 +1829,11 @@ public function merge($entity) * @throws EntityNotFoundException if an assigned identifier is used in the entity, but none is provided. */ private function doMerge( - $entity, + object $entity, array &$visited, - $prevManagedCopy = null, + ?object $prevManagedCopy = null, array $assoc = [] - ) { + ): object { $oid = spl_object_id($entity); if (isset($visited[$oid])) { @@ -2033,8 +1922,6 @@ private function doMerge( } /** - * @param object $entity - * @param object $managedCopy * @psalm-param ClassMetadata $class * @psalm-param T $entity * @psalm-param T $managedCopy @@ -2045,8 +1932,8 @@ private function doMerge( */ private function ensureVersionMatch( ClassMetadata $class, - $entity, - $managedCopy + object $entity, + object $managedCopy ): void { if (! ($class->isVersioned && $this->isLoaded($managedCopy) && $this->isLoaded($entity))) { return; @@ -2067,10 +1954,8 @@ private function ensureVersionMatch( /** * Tests if an entity is loaded - must either be a loaded proxy or not a proxy - * - * @param object $entity */ - private function isLoaded($entity): bool + private function isLoaded(object $entity): bool { return ! ($entity instanceof Proxy) || $entity->__isInitialized(); } @@ -2078,14 +1963,13 @@ private function isLoaded($entity): bool /** * Sets/adds associated managed copies into the previous entity's association field * - * @param object $entity * @param string[] $association */ private function updateAssociationWithMergedEntity( - $entity, + object $entity, array $association, - $previousManagedCopy, - $managedCopy + object $previousManagedCopy, + object $managedCopy ): void { $assocField = $association['fieldName']; $prevClass = $this->em->getClassMetadata(get_class($previousManagedCopy)); @@ -2109,12 +1993,8 @@ private function updateAssociationWithMergedEntity( /** * Detaches an entity from the persistence management. It's persistence will * no longer be managed by Doctrine. - * - * @param object $entity The entity to detach. - * - * @return void */ - public function detach($entity) + public function detach(object $entity): void { $visited = []; @@ -2124,12 +2004,11 @@ public function detach($entity) /** * Executes a detach operation on the given entity. * - * @param object $entity * @param mixed[] $visited * @param bool $noCascade if true, don't cascade detach operation. */ private function doDetach( - $entity, + object $entity, array &$visited, bool $noCascade = false ): void { @@ -2170,13 +2049,9 @@ private function doDetach( * Refreshes the state of the given entity from the database, overwriting * any local, unpersisted changes. * - * @param object $entity The entity to refresh. - * - * @return void - * * @throws InvalidArgumentException If the entity is not MANAGED. */ - public function refresh($entity) + public function refresh(object $entity): void { $visited = []; @@ -2186,12 +2061,11 @@ public function refresh($entity) /** * Executes a refresh operation on an entity. * - * @param object $entity The entity to refresh. * @psalm-param array $visited The already visited entities during cascades. * * @throws ORMInvalidArgumentException If the entity is not MANAGED. */ - private function doRefresh($entity, array &$visited): void + private function doRefresh(object $entity, array &$visited): void { $oid = spl_object_id($entity); @@ -2218,16 +2092,15 @@ private function doRefresh($entity, array &$visited): void /** * Cascades a refresh operation to associated entities. * - * @param object $entity * @psalm-param array $visited */ - private function cascadeRefresh($entity, array &$visited): void + private function cascadeRefresh(object $entity, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); $associationMappings = array_filter( $class->associationMappings, - static function ($assoc) { + static function (array $assoc) { return $assoc['isCascadeRefresh']; } ); @@ -2262,16 +2135,15 @@ static function ($assoc) { /** * Cascades a detach operation to associated entities. * - * @param object $entity * @param array $visited */ - private function cascadeDetach($entity, array &$visited): void + private function cascadeDetach(object $entity, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); $associationMappings = array_filter( $class->associationMappings, - static function ($assoc) { + static function (array $assoc) { return $assoc['isCascadeDetach']; } ); @@ -2306,17 +2178,15 @@ static function ($assoc) { /** * Cascades a merge operation to associated entities. * - * @param object $entity - * @param object $managedCopy * @psalm-param array $visited */ - private function cascadeMerge($entity, $managedCopy, array &$visited): void + private function cascadeMerge(object $entity, object $managedCopy, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); $associationMappings = array_filter( $class->associationMappings, - static function ($assoc) { + static function (array $assoc) { return $assoc['isCascadeMerge']; } ); @@ -2346,16 +2216,15 @@ static function ($assoc) { /** * Cascades the save operation to associated entities. * - * @param object $entity * @psalm-param array $visited */ - private function cascadePersist($entity, array &$visited): void + private function cascadePersist(object $entity, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); $associationMappings = array_filter( $class->associationMappings, - static function ($assoc) { + static function (array $assoc) { return $assoc['isCascadePersist']; } ); @@ -2406,16 +2275,15 @@ static function ($assoc) { /** * Cascades the delete operation to associated entities. * - * @param object $entity * @psalm-param array $visited */ - private function cascadeRemove($entity, array &$visited): void + private function cascadeRemove(object $entity, array &$visited): void { $class = $this->em->getClassMetadata(get_class($entity)); $associationMappings = array_filter( $class->associationMappings, - static function ($assoc) { + static function (array $assoc) { return $assoc['isCascadeRemove']; } ); @@ -2456,7 +2324,6 @@ static function ($assoc) { /** * Acquire a lock on the given entity. * - * @param object $entity * @param int|DateTimeInterface|null $lockVersion * @psalm-param LockMode::* $lockMode * @@ -2464,7 +2331,7 @@ static function ($assoc) { * @throws TransactionRequiredException * @throws OptimisticLockException */ - public function lock($entity, int $lockMode, $lockVersion = null): void + public function lock(object $entity, int $lockMode, $lockVersion = null): void { if ($this->getEntityState($entity, self::STATE_DETACHED) !== self::STATE_MANAGED) { throw ORMInvalidArgumentException::entityNotManaged($entity); @@ -2517,12 +2384,10 @@ public function lock($entity, int $lockMode, $lockVersion = null): void /** * Gets the CommitOrderCalculator used by the UnitOfWork to order commits. - * - * @return CommitOrderCalculator */ - public function getCommitOrderCalculator() + public function getCommitOrderCalculator(): CommitOrderCalculator { - return new Internal\CommitOrderCalculator(); + return new CommitOrderCalculator(); } /** @@ -2530,11 +2395,9 @@ public function getCommitOrderCalculator() * * @param string|null $entityName if given, only entities of this type will get detached. * - * @return void - * * @throws ORMInvalidArgumentException if an invalid entity name is given. */ - public function clear($entityName = null) + public function clear(?string $entityName = null): void { if ($entityName === null) { $this->identityMap = @@ -2570,13 +2433,9 @@ public function clear($entityName = null) * invoked on that entity at the beginning of the next commit of this * UnitOfWork. * - * @param object $entity - * - * @return void - * * @ignore */ - public function scheduleOrphanRemoval($entity) + public function scheduleOrphanRemoval(object $entity): void { $this->orphanRemovals[spl_object_id($entity)] = $entity; } @@ -2585,13 +2444,9 @@ public function scheduleOrphanRemoval($entity) * INTERNAL: * Cancels a previously scheduled orphan removal. * - * @param object $entity - * - * @return void - * * @ignore */ - public function cancelOrphanRemoval($entity) + public function cancelOrphanRemoval(object $entity): void { unset($this->orphanRemovals[spl_object_id($entity)]); } @@ -2599,10 +2454,8 @@ public function cancelOrphanRemoval($entity) /** * INTERNAL: * Schedules a complete collection for removal when this UnitOfWork commits. - * - * @return void */ - public function scheduleCollectionDeletion(PersistentCollection $coll) + public function scheduleCollectionDeletion(PersistentCollection $coll): void { $coid = spl_object_id($coll); @@ -2613,18 +2466,12 @@ public function scheduleCollectionDeletion(PersistentCollection $coll) $this->collectionDeletions[$coid] = $coll; } - /** - * @return bool - */ - public function isCollectionScheduledForDeletion(PersistentCollection $coll) + public function isCollectionScheduledForDeletion(PersistentCollection $coll): bool { return isset($this->collectionDeletions[spl_object_id($coll)]); } - /** - * @return object - */ - private function newInstance(ClassMetadata $class) + private function newInstance(ClassMetadata $class): object { $entity = $class->newInstance(); @@ -2652,7 +2499,7 @@ private function newInstance(ClassMetadata $class) * @ignore * @todo Rename: getOrCreateEntity */ - public function createEntity($className, array $data, &$hints = []) + public function createEntity(string $className, array $data, array &$hints = []): object { $class = $this->em->getClassMetadata($className); @@ -2942,10 +2789,7 @@ public function createEntity($className, array $data, &$hints = []) return $entity; } - /** - * @return void - */ - public function triggerEagerLoads() + public function triggerEagerLoads(): void { if (! $this->eagerLoadingEntities) { return; @@ -2971,13 +2815,9 @@ public function triggerEagerLoads() /** * Initializes (loads) an uninitialized persistent collection of an entity. * - * @param PersistentCollection $collection The collection to initialize. - * - * @return void - * * @todo Maybe later move to EntityManager#initialize($proxyOrCollection). See DDC-733. */ - public function loadCollection(PersistentCollection $collection) + public function loadCollection(PersistentCollection $collection): void { $assoc = $collection->getMapping(); $persister = $this->getEntityPersister($assoc['targetEntity']); @@ -3000,7 +2840,7 @@ public function loadCollection(PersistentCollection $collection) * * @psalm-return array> */ - public function getIdentityMap() + public function getIdentityMap(): array { return $this->identityMap; } @@ -3009,12 +2849,9 @@ public function getIdentityMap() * Gets the original data of an entity. The original data is the data that was * present at the time the entity was reconstituted from the database. * - * @param object $entity - * - * @return mixed[] * @psalm-return array */ - public function getOriginalEntityData($entity) + public function getOriginalEntityData(object $entity): array { $oid = spl_object_id($entity); @@ -3022,14 +2859,11 @@ public function getOriginalEntityData($entity) } /** - * @param object $entity * @param mixed[] $data * - * @return void - * * @ignore */ - public function setOriginalEntityData($entity, array $data) + public function setOriginalEntityData(object $entity, array $data): void { $this->originalEntityData[spl_object_id($entity)] = $data; } @@ -3038,15 +2872,9 @@ public function setOriginalEntityData($entity, array $data) * INTERNAL: * Sets a property value of the original data array of an entity. * - * @param int $oid - * @param string $property - * @param mixed $value - * - * @return void - * * @ignore */ - public function setOriginalEntityProperty($oid, $property, $value) + public function setOriginalEntityProperty(int $oid, string $property, mixed $value): void { $this->originalEntityData[$oid][$property] = $value; } @@ -3057,29 +2885,22 @@ public function setOriginalEntityProperty($oid, $property, $value) * has a composite identifier then the identifier values are in the same * order as the identifier field names as returned by ClassMetadata#getIdentifierFieldNames(). * - * @param object $entity - * * @return mixed[] The identifier values. */ - public function getEntityIdentifier($entity) + public function getEntityIdentifier(object $entity): array { - if (! isset($this->entityIdentifiers[spl_object_id($entity)])) { - throw EntityNotFoundException::noIdentifierFound(get_debug_type($entity)); - } - - return $this->entityIdentifiers[spl_object_id($entity)]; + return $this->entityIdentifiers[spl_object_id($entity)] + ?? throw EntityNotFoundException::noIdentifierFound(get_debug_type($entity)); } /** * Processes an entity instance to extract their identifier values. * - * @param object $entity The entity instance. - * * @return mixed A scalar value. * * @throws ORMInvalidArgumentException */ - public function getSingleIdentifierValue($entity) + public function getSingleIdentifierValue(object $entity): mixed { $class = $this->em->getClassMetadata(get_class($entity)); @@ -3105,7 +2926,7 @@ public function getSingleIdentifierValue($entity) * @return object|false Returns the entity with the specified identifier if it exists in * this UnitOfWork, FALSE otherwise. */ - public function tryGetById($id, $rootClassName) + public function tryGetById(mixed $id, string $rootClassName): object|false { $idHash = implode(' ', (array) $id); @@ -3115,13 +2936,9 @@ public function tryGetById($id, $rootClassName) /** * Schedules an entity for dirty-checking at commit-time. * - * @param object $entity The entity to schedule for dirty-checking. - * - * @return void - * * @todo Rename: scheduleForSynchronization */ - public function scheduleForDirtyCheck($entity) + public function scheduleForDirtyCheck(object $entity): void { $rootClassName = $this->em->getClassMetadata(get_class($entity))->rootEntityName; @@ -3130,10 +2947,8 @@ public function scheduleForDirtyCheck($entity) /** * Checks whether the UnitOfWork has any pending insertions. - * - * @return bool TRUE if this UnitOfWork has pending insertions, FALSE otherwise. */ - public function hasPendingInsertions() + public function hasPendingInsertions(): bool { return ! empty($this->entityInsertions); } @@ -3141,10 +2956,8 @@ public function hasPendingInsertions() /** * Calculates the size of the UnitOfWork. The size of the UnitOfWork is the * number of entities in the identity map. - * - * @return int */ - public function size() + public function size(): int { return array_sum(array_map('count', $this->identityMap)); } @@ -3152,12 +2965,9 @@ public function size() /** * Gets the EntityPersister for an Entity. * - * @param string $entityName The name of the Entity. * @psalm-param class-string $entityName - * - * @return EntityPersister */ - public function getEntityPersister($entityName) + public function getEntityPersister(string $entityName): EntityPersister { if (isset($this->persisters[$entityName])) { return $this->persisters[$entityName]; @@ -3198,10 +3008,8 @@ public function getEntityPersister($entityName) * Gets a collection persister for a collection-valued association. * * @psalm-param array $association - * - * @return CollectionPersister */ - public function getCollectionPersister(array $association) + public function getCollectionPersister(array $association): CollectionPersister { $role = isset($association['cache']) ? $association['sourceEntity'] . '::' . $association['fieldName'] @@ -3231,13 +3039,10 @@ public function getCollectionPersister(array $association) * INTERNAL: * Registers an entity as managed. * - * @param object $entity The entity. - * @param mixed[] $id The identifier values. - * @param mixed[] $data The original entity data. - * - * @return void + * @param mixed[] $id The identifier values. + * @param mixed[] $data The original entity data. */ - public function registerManaged($entity, array $id, array $data) + public function registerManaged(object $entity, array $id, array $data): void { $oid = spl_object_id($entity); @@ -3255,12 +3060,8 @@ public function registerManaged($entity, array $id, array $data) /** * INTERNAL: * Clears the property changeset of the entity with the given OID. - * - * @param int $oid The entity's OID. - * - * @return void */ - public function clearEntityChangeSet($oid) + public function clearEntityChangeSet(int $oid): void { unset($this->entityChangeSets[$oid]); } @@ -3274,10 +3075,8 @@ public function clearEntityChangeSet($oid) * @param string $propertyName The name of the property that changed. * @param mixed $oldValue The old value of the property. * @param mixed $newValue The new value of the property. - * - * @return void */ - public function propertyChanged($sender, $propertyName, $oldValue, $newValue) + public function propertyChanged($sender, $propertyName, mixed $oldValue, mixed $newValue): void { $oid = spl_object_id($sender); $class = $this->em->getClassMetadata(get_class($sender)); @@ -3301,7 +3100,7 @@ public function propertyChanged($sender, $propertyName, $oldValue, $newValue) * * @psalm-return array */ - public function getScheduledEntityInsertions() + public function getScheduledEntityInsertions(): array { return $this->entityInsertions; } @@ -3311,7 +3110,7 @@ public function getScheduledEntityInsertions() * * @psalm-return array */ - public function getScheduledEntityUpdates() + public function getScheduledEntityUpdates(): array { return $this->entityUpdates; } @@ -3321,7 +3120,7 @@ public function getScheduledEntityUpdates() * * @psalm-return array */ - public function getScheduledEntityDeletions() + public function getScheduledEntityDeletions(): array { return $this->entityDeletions; } @@ -3331,7 +3130,7 @@ public function getScheduledEntityDeletions() * * @psalm-return array> */ - public function getScheduledCollectionDeletions() + public function getScheduledCollectionDeletions(): array { return $this->collectionDeletions; } @@ -3341,19 +3140,15 @@ public function getScheduledCollectionDeletions() * * @psalm-return array> */ - public function getScheduledCollectionUpdates() + public function getScheduledCollectionUpdates(): array { return $this->collectionUpdates; } /** * Helper method to initialize a lazy loading proxy or persistent collection. - * - * @param object $obj - * - * @return void */ - public function initializeObject($obj) + public function initializeObject(object $obj): void { if ($obj instanceof Proxy) { $obj->__load(); @@ -3368,10 +3163,8 @@ public function initializeObject($obj) /** * Helper method to show an object as string. - * - * @param object $obj */ - private static function objToStr($obj): string + private static function objToStr(object $obj): string { return method_exists($obj, '__toString') ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj); } @@ -3382,15 +3175,11 @@ private static function objToStr($obj): string * This operation cannot be undone as some parts of the UnitOfWork now keep gathering information * on this object that might be necessary to perform a correct update. * - * @param object $object - * - * @return void - * * @throws ORMInvalidArgumentException */ - public function markReadOnly($object) + public function markReadOnly(object $object): void { - if (! is_object($object) || ! $this->isInIdentityMap($object)) { + if (! $this->isInIdentityMap($object)) { throw ORMInvalidArgumentException::readOnlyRequiresManagedEntity($object); } @@ -3400,18 +3189,10 @@ public function markReadOnly($object) /** * Is this entity read only? * - * @param object $object - * - * @return bool - * * @throws ORMInvalidArgumentException */ - public function isReadOnly($object) + public function isReadOnly(object $object): bool { - if (! is_object($object)) { - throw ORMInvalidArgumentException::readOnlyRequiresManagedEntity($object); - } - return isset($this->readOnlyObjects[spl_object_id($object)]); } @@ -3467,11 +3248,8 @@ private function dispatchPostFlushEvent(): void /** * Verifies if two given entities actually are the same based on identifier comparison - * - * @param object $entity1 - * @param object $entity2 */ - private function isIdentifierEquals($entity1, $entity2): bool + private function isIdentifierEquals(object $entity1, object $entity2): bool { if ($entity1 === $entity2) { return true; @@ -3509,14 +3287,11 @@ private function assertThatThereAreNoUnintentionallyNonPersistedAssociations(): } /** - * @param object $entity - * @param object $managedCopy - * * @throws ORMException * @throws OptimisticLockException * @throws TransactionRequiredException */ - private function mergeEntityStateIntoManagedCopy($entity, $managedCopy): void + private function mergeEntityStateIntoManagedCopy(object $entity, object $managedCopy): void { if (! $this->isLoaded($entity)) { return; @@ -3622,10 +3397,8 @@ private function mergeEntityStateIntoManagedCopy($entity, $managedCopy): void * Unit of work able to fire deferred events, related to loading events here. * * @internal should be called internally from object hydrators - * - * @return void */ - public function hydrationComplete() + public function hydrationComplete(): void { $this->hydrationCompleteHandler->hydrationComplete(); } @@ -3654,13 +3427,9 @@ private function clearEntityInsertionsForEntityName(string $entityName): void } /** - * @param mixed $identifierValue - * - * @return mixed the identifier after type conversion - * * @throws MappingException if the entity has more than a single identifier. */ - private function convertSingleFieldIdentifierToPHPValue(ClassMetadata $class, $identifierValue) + private function convertSingleFieldIdentifierToPHPValue(ClassMetadata $class, mixed $identifierValue): mixed { return $this->em->getConnection()->convertToPHPValue( $identifierValue, diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fddb99638a2..12092adc093 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3116,11 +3116,9 @@ $commitOrder[$i] $this->em - - ! is_object($object) + $association['type'] === ClassMetadata::ONE_TO_MANY $association['type'] === ClassMetadata::ONE_TO_MANY - is_object($object) $em->getMetadataFactory() @@ -3136,17 +3134,12 @@ $this->entityChangeSets - static function ($assoc) { - static function ($assoc) { - static function ($assoc) { - static function ($assoc) { - static function ($assoc) { + static function (array $assoc) { + static function (array $assoc) { + static function (array $assoc) { + static function (array $assoc) { + static function (array $assoc) { - - $managedCopy - $prevManagedCopy - $previousManagedCopy - $this->identityMap[$rootClassName][$idHash] @@ -3210,9 +3203,6 @@ unwrap unwrap - - is_array($entity) - $visited diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingUnitOfWork.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingUnitOfWork.php index aa1d10bfb0d..d9ca05c6879 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingUnitOfWork.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingUnitOfWork.php @@ -5,25 +5,20 @@ namespace Doctrine\Performance\Mock; use Doctrine\ORM\UnitOfWork; -use Doctrine\Tests\ORM\Performance\PersisterMock; /** * An unit of work mock that prevents lazy-loading of proxies */ class NonProxyLoadingUnitOfWork extends UnitOfWork { - /** @var PersisterMock */ - private $entityPersister; + private NonLoadingPersister $entityPersister; public function __construct() { $this->entityPersister = new NonLoadingPersister(); } - /** - * {@inheritDoc} - */ - public function getEntityPersister($entityName) + public function getEntityPersister(string $entityName): NonLoadingPersister { return $this->entityPersister; } diff --git a/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php b/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php index 656df1769b1..8381e7cc3a0 100644 --- a/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php +++ b/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\Mocks; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; +use Doctrine\ORM\Persisters\Entity\EntityPersister; use Doctrine\ORM\UnitOfWork; use function spl_object_id; @@ -14,29 +15,23 @@ */ class UnitOfWorkMock extends UnitOfWork { - /** @var array */ - private $_mockDataChangeSets = []; + private array $mockDataChangeSets = []; + private ?array $persisterMock = null; - /** @var array|null */ - private $_persisterMock; - - /** - * {@inheritdoc} - */ - public function getEntityPersister($entityName) + public function getEntityPersister(string $entityName): EntityPersister { - return $this->_persisterMock[$entityName] ?? parent::getEntityPersister($entityName); + return $this->persisterMock[$entityName] ?? parent::getEntityPersister($entityName); } /** * {@inheritdoc} */ - public function & getEntityChangeSet($entity) + public function & getEntityChangeSet(object $entity): array { $oid = spl_object_id($entity); - if (isset($this->_mockDataChangeSets[$oid])) { - return $this->_mockDataChangeSets[$oid]; + if (isset($this->mockDataChangeSets[$oid])) { + return $this->mockDataChangeSets[$oid]; } $data = parent::getEntityChangeSet($entity); @@ -52,13 +47,13 @@ public function & getEntityChangeSet($entity) */ public function setEntityPersister(string $entityName, BasicEntityPersister $persister): void { - $this->_persisterMock[$entityName] = $persister; + $this->persisterMock[$entityName] = $persister; } /** * {@inheritdoc} */ - public function setOriginalEntityData($entity, array $originalData) + public function setOriginalEntityData(object $entity, array $originalData): void { $this->_originalEntityData[spl_object_id($entity)] = $originalData; } From 2dce2d0d63c79d22dec44ea52194b80d0fd91a52 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 6 Jan 2022 10:24:05 +0100 Subject: [PATCH 025/475] [GH-9277] remove deprecated `PHPDriver` (#9308) * Remove deprecated PHPDriver mapping driver, use StaticPHPDriver instead. * Update docs * Housekeeping * Update UPGRADE.md --- UPGRADE.md | 5 + docs/en/reference/php-mapping.rst | 92 +------- lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php | 16 -- tests/Doctrine/Tests/Models/Cache/City.php | 64 +++++- .../ORM/Mapping/PHPMappingDriverTest.php | 63 ------ .../Doctrine.Tests.Models.CMS.CmsAddress.php | 125 ----------- .../php/Doctrine.Tests.Models.CMS.CmsUser.php | 209 ------------------ .../php/Doctrine.Tests.Models.Cache.City.php | 73 ------ ...e.Tests.Models.Company.CompanyContract.php | 51 ----- ...ests.Models.Company.CompanyFixContract.php | 11 - ...sts.Models.Company.CompanyFlexContract.php | 19 -- ...odels.Company.CompanyFlexUltraContract.php | 27 --- ...ine.Tests.Models.Company.CompanyPerson.php | 48 ---- ...1476.DDC1476EntityWithDefaultFieldType.php | 16 -- ....Models.DDC2825.ExplicitSchemaAndTable.php | 22 -- ...dels.DDC2825.SchemaAndTableInTableName.php | 19 -- ...rine.Tests.Models.DDC3579.DDC3579Admin.php | 5 - ...trine.Tests.Models.DDC3579.DDC3579User.php | 37 ---- ...sts.Models.DDC5934.DDC5934BaseContract.php | 19 -- ...e.Tests.Models.DDC5934.DDC5934Contract.php | 9 - ...ests.Models.DDC869.DDC869ChequePayment.php | 10 - ....Models.DDC869.DDC869CreditCardPayment.php | 10 - ...rine.Tests.Models.DDC869.DDC869Payment.php | 24 -- ...ctrine.Tests.Models.DDC889.DDC889Class.php | 14 -- ...trine.Tests.Models.DDC889.DDC889Entity.php | 3 - ...e.Tests.Models.DDC889.DDC889SuperClass.php | 16 -- ...ctrine.Tests.Models.DDC964.DDC964Admin.php | 31 --- ...ctrine.Tests.Models.DDC964.DDC964Guest.php | 19 -- ...octrine.Tests.Models.DDC964.DDC964User.php | 62 ------ ...Tests.Models.TypedProperties.UserTyped.php | 65 ------ .../php/Doctrine.Tests.ORM.Mapping.Animal.php | 40 ---- .../Doctrine.Tests.ORM.Mapping.Comment.php | 27 --- ...ctrine.Tests.ORM.Mapping.DDC1170Entity.php | 22 -- ...octrine.Tests.ORM.Mapping.DDC807Entity.php | 21 -- .../php/Doctrine.Tests.ORM.Mapping.PHPSLC.php | 18 -- ....ORM.Mapping.ReservedWordInTableColumn.php | 18 -- .../php/Doctrine.Tests.ORM.Mapping.User.php | 146 ------------ 37 files changed, 78 insertions(+), 1398 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsAddress.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsUser.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Cache.City.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyContract.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFixContract.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexContract.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyPerson.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC3579.DDC3579Admin.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC3579.DDC3579User.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC5934.DDC5934Contract.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Class.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Entity.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889SuperClass.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Admin.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Guest.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964User.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTyped.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Animal.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Comment.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC807Entity.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.PHPSLC.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php diff --git a/UPGRADE.md b/UPGRADE.md index 09992996a37..c3322a384b5 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC Break: Remove `Doctrine\ORM\Mapping\Driver\PHPDriver` + +Use `StaticPHPDriver` instead when you want to programmatically configure +entity metadata. + ## BC BREAK: Remove `Doctrine\ORM\EntityManagerInterface#transactional()` This method has been replaced by `Doctrine\ORM\EntityManagerInterface#wrapInTransaction()`. diff --git a/docs/en/reference/php-mapping.rst b/docs/en/reference/php-mapping.rst index 9118c6fdf6c..1b5416f983d 100644 --- a/docs/en/reference/php-mapping.rst +++ b/docs/en/reference/php-mapping.rst @@ -1,92 +1,20 @@ PHP Mapping =========== -Doctrine ORM also allows you to provide the ORM metadata in the form -of plain PHP code using the ``ClassMetadata`` API. You can write -the code in PHP files or inside of a static function named -``loadMetadata($class)`` on the entity class itself. - -PHP Files ---------- - -If you wish to write your mapping information inside PHP files that -are named after the entity and included to populate the metadata -for an entity you can do so by using the ``PHPDriver``: - -.. code-block:: php - - getConfiguration()->setMetadataDriverImpl($driver); - -Now imagine we had an entity named ``Entities\User`` and we wanted -to write a mapping file for it using the above configured -``PHPDriver`` instance: - -.. code-block:: php - - mapField(array( - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer' - )); - - $metadata->mapField(array( - 'fieldName' => 'username', - 'type' => 'string', - 'options' => array( - 'fixed' => true, - 'comment' => "User's login name" - ) - )); - - $metadata->mapField(array( - 'fieldName' => 'login_count', - 'type' => 'integer', - 'nullable' => false, - 'options' => array( - 'unsigned' => true, - 'default' => 0 - ) - )); - -Now we can easily retrieve the populated ``ClassMetadata`` instance -where the ``PHPDriver`` includes the file and the -``ClassMetadataFactory`` caches it for later retrieval: - -.. code-block:: php - - getClassMetadata('Entities\User'); - // or - $class = $em->getMetadataFactory()->getMetadataFor('Entities\User'); +Doctrine ORM also allows you to provide the ORM metadata in the form of plain +PHP code using the ``ClassMetadata`` API. You can write the code in inside of a +static function named ``loadMetadata($class)`` on the entity class itself. Static Function --------------- -In addition to the PHP files you can also specify your mapping -information inside of a static function defined on the entity class -itself. This is useful for cases where you want to keep your entity -and mapping information together but don't want to use annotations. -For this you just need to use the ``StaticPHPDriver``: +In addition to other drivers using configuration languages you can also +programatically specify your mapping information inside of a static function +defined on the entity class itself. + +This is useful for cases where you want to keep your entity and mapping +information together but don't want to use annotations. For this you just need +to use the ``StaticPHPDriver``: .. code-block:: php diff --git a/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php b/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php deleted file mode 100644 index d33c6fa85b8..00000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php +++ /dev/null @@ -1,16 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); + $metadata->setPrimaryTable(['name' => 'cache_city']); + $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY); + $metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); + + $metadata->enableCache( + [ + 'usage' => ClassMetadataInfo::CACHE_USAGE_READ_ONLY, + ] + ); + + $metadata->mapField( + [ + 'fieldName' => 'id', + 'type' => 'integer', + 'id' => true, + ] + ); + + $metadata->mapField( + [ + 'fieldName' => 'name', + 'type' => 'string', + ] + ); + + $metadata->mapOneToOne( + [ + 'fieldName' => 'state', + 'targetEntity' => State::class, + 'inversedBy' => 'cities', + 'joinColumns' => + [ + [ + 'name' => 'state_id', + 'referencedColumnName' => 'id', + ], + ], + ] + ); + $metadata->enableAssociationCache('state', [ + 'usage' => ClassMetadataInfo::CACHE_USAGE_READ_ONLY, + ]); + + $metadata->mapManyToMany( + [ + 'fieldName' => 'travels', + 'targetEntity' => Travel::class, + 'mappedBy' => 'visitedCities', + ] + ); + + $metadata->mapOneToMany( + [ + 'fieldName' => 'attractions', + 'targetEntity' => Attraction::class, + 'mappedBy' => 'city', + 'orderBy' => ['name' => 'ASC'], + ] + ); + $metadata->enableAssociationCache('attractions', [ + 'usage' => ClassMetadataInfo::CACHE_USAGE_READ_ONLY, + ]); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php deleted file mode 100644 index c29fa5e7c98..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php +++ /dev/null @@ -1,63 +0,0 @@ -createAnnotationDriver(); -// $driver->loadMetadataForClass("Doctrine\Tests\ORM\Mapping\Animal", $meta); -// $exporter = $cme->getExporter('php', $path); -// echo $exporter->exportClassMetadata($meta); - - return new PHPDriver($path); - } - - /** - * All class are entitier for php driver - * - * @group DDC-889 - */ - public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses(): void - { - self::assertInstanceOf(ClassMetadata::class, $this->createClassMetadata(DDC889Class::class)); - } - - public function testFailingSecondLevelCacheAssociation(): void - { - $this->expectException(CacheException::class); - $this->expectExceptionMessage('Entity association field "Doctrine\Tests\ORM\Mapping\PHPSLC#foo" not configured as part of the second-level cache.'); - $mappingDriver = $this->loadDriver(); - - $class = new ClassMetadata(Mapping\PHPSLC::class); - $mappingDriver->loadMetadataForClass(Mapping\PHPSLC::class, $class); - } - - public function testEntityIncorrectIndexes(): void - { - self::markTestSkipped('PHP driver does not ensure index correctness'); - } - - public function testEntityIncorrectUniqueContraint(): void - { - self::markTestSkipped('PHP driver does not ensure index correctness'); - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsAddress.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsAddress.php deleted file mode 100644 index 1907de9d866..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsAddress.php +++ /dev/null @@ -1,125 +0,0 @@ -setPrimaryTable( - ['name' => 'company_person'] -); - -$metadata->mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - ] -); - -$metadata->mapField( - [ - 'fieldName' => 'zip', - 'length' => 50, - ] -); - -$metadata->mapField( - [ - 'fieldName' => 'city', - 'length' => 50, - ] -); - -$metadata->mapOneToOne( - [ - 'fieldName' => 'user', - 'targetEntity' => 'CmsUser', - 'joinColumns' => [['referencedColumnName' => 'id']], - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT id, country, city FROM cms_addresses', - 'resultSetMapping' => 'mapping-find-all', - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'find-by-id', - 'query' => 'SELECT * FROM cms_addresses WHERE id = ?', - 'resultClass' => CmsAddress::class, - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'count', - 'query' => 'SELECT COUNT(*) AS count FROM cms_addresses', - 'resultSetMapping' => 'mapping-count', - ] -); - - -$metadata->addSqlResultSetMapping( - [ - 'name' => 'mapping-find-all', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'city', - 'column' => 'city', - ], - [ - 'name' => 'country', - 'column' => 'country', - ], - ], - 'entityClass' => CmsAddress::class, - ], - ], - ] -); - -$metadata->addSqlResultSetMapping( - [ - 'name' => 'mapping-without-fields', - 'columns' => [], - 'entities' => [ - [ - 'entityClass' => CmsAddress::class, - 'fields' => [], - ], - ], - ] -); - -$metadata->addSqlResultSetMapping( - [ - 'name' => 'mapping-count', - 'columns' => [ - ['name' => 'count'], - ], - ] -); - -$metadata->addEntityListener(Events::postPersist, 'CmsAddressListener', 'postPersist'); -$metadata->addEntityListener(Events::prePersist, 'CmsAddressListener', 'prePersist'); - -$metadata->addEntityListener(Events::postUpdate, 'CmsAddressListener', 'postUpdate'); -$metadata->addEntityListener(Events::preUpdate, 'CmsAddressListener', 'preUpdate'); - -$metadata->addEntityListener(Events::postRemove, 'CmsAddressListener', 'postRemove'); -$metadata->addEntityListener(Events::preRemove, 'CmsAddressListener', 'preRemove'); - -$metadata->addEntityListener(Events::preFlush, 'CmsAddressListener', 'preFlush'); -$metadata->addEntityListener(Events::postLoad, 'CmsAddressListener', 'postLoad'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsUser.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsUser.php deleted file mode 100644 index 7e4eb9852c9..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.CMS.CmsUser.php +++ /dev/null @@ -1,209 +0,0 @@ -setPrimaryTable( - ['name' => 'cms_users'] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'fetchIdAndUsernameWithResultClass', - 'query' => 'SELECT id, username FROM cms_users WHERE username = ?', - 'resultClass' => CmsUser::class, - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'fetchAllColumns', - 'query' => 'SELECT * FROM cms_users WHERE username = ?', - 'resultClass' => CmsUser::class, - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'fetchJoinedAddress', - 'query' => 'SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', - 'resultSetMapping' => 'mappingJoinedAddress', - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'fetchJoinedPhonenumber', - 'query' => 'SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', - 'resultSetMapping' => 'mappingJoinedPhonenumber', - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'fetchUserPhonenumberCount', - 'query' => 'SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username', - 'resultSetMapping' => 'mappingUserPhonenumberCount', - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'fetchMultipleJoinsEntityResults', - 'resultSetMapping' => 'mappingMultipleJoinsEntityResults', - 'query' => 'SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username', - ] -); - -$metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingJoinedAddress', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - [ - 'name' => 'status', - 'column' => 'status', - ], - [ - 'name' => 'address.zip', - 'column' => 'zip', - ], - [ - 'name' => 'address.city', - 'column' => 'city', - ], - [ - 'name' => 'address.country', - 'column' => 'country', - ], - [ - 'name' => 'address.id', - 'column' => 'a_id', - ], - ], - 'entityClass' => CmsUser::class, - 'discriminatorColumn' => null, - ], - ], - ] -); - -$metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingJoinedPhonenumber', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - [ - 'name' => 'status', - 'column' => 'status', - ], - [ - 'name' => 'phonenumbers.phonenumber', - 'column' => 'number', - ], - ], - 'entityClass' => CmsUser::class, - 'discriminatorColumn' => null, - ], - ], - ] -); - -$metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingUserPhonenumberCount', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - [ - 'name' => 'status', - 'column' => 'status', - ], - ], - 'entityClass' => CmsUser::class, - 'discriminatorColumn' => null, - ], - ], - 'columns' => [ - ['name' => 'numphones'], - ], - ] -); - -$metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingMultipleJoinsEntityResults', - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'u_id', - ], - [ - 'name' => 'name', - 'column' => 'u_name', - ], - [ - 'name' => 'status', - 'column' => 'u_status', - ], - ], - 'entityClass' => CmsUser::class, - 'discriminatorColumn' => null, - ], - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'a_id', - ], - [ - 'name' => 'zip', - 'column' => 'a_zip', - ], - [ - 'name' => 'country', - 'column' => 'a_country', - ], - ], - 'entityClass' => CmsAddress::class, - 'discriminatorColumn' => null, - ], - ], - 'columns' => [ - ['name' => 'numphones'], - ], - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Cache.City.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Cache.City.php deleted file mode 100644 index ef01fa46232..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Cache.City.php +++ /dev/null @@ -1,73 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); -$metadata->setPrimaryTable(['name' => 'cache_city']); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY); -$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); - -$metadata->enableCache( - [ - 'usage' => ClassMetadataInfo::CACHE_USAGE_READ_ONLY, - ] -); - -$metadata->mapField( - [ - 'fieldName' => 'id', - 'type' => 'integer', - 'id' => true, - ] -); - -$metadata->mapField( - [ - 'fieldName' => 'name', - 'type' => 'string', - ] -); - - -$metadata->mapOneToOne( - [ - 'fieldName' => 'state', - 'targetEntity' => State::class, - 'inversedBy' => 'cities', - 'joinColumns' => - [ - [ - 'name' => 'state_id', - 'referencedColumnName' => 'id', - ], - ], - ] -); -$metadata->enableAssociationCache('state', [ - 'usage' => ClassMetadataInfo::CACHE_USAGE_READ_ONLY, -]); - -$metadata->mapManyToMany( - [ - 'fieldName' => 'travels', - 'targetEntity' => Travel::class, - 'mappedBy' => 'visitedCities', - ] -); - -$metadata->mapOneToMany( - [ - 'fieldName' => 'attractions', - 'targetEntity' => Attraction::class, - 'mappedBy' => 'city', - 'orderBy' => ['name' => 'ASC'], - ] -); -$metadata->enableAssociationCache('attractions', [ - 'usage' => ClassMetadataInfo::CACHE_USAGE_READ_ONLY, -]); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyContract.php deleted file mode 100644 index 842980e2203..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyContract.php +++ /dev/null @@ -1,51 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_JOINED); -$metadata->setTableName('company_contracts'); -$metadata->setDiscriminatorColumn( - [ - 'name' => 'discr', - 'type' => 'string', - ] -); - -$metadata->mapField( - [ - 'id' => true, - 'name' => 'id', - 'fieldName' => 'id', - ] -); - -$metadata->mapField( - [ - 'type' => 'boolean', - 'name' => 'completed', - 'fieldName' => 'completed', - ] -); - -$metadata->setDiscriminatorMap( - [ - 'fix' => 'CompanyFixContract', - 'flexible' => 'CompanyFlexContract', - 'flexultra' => 'CompanyFlexUltraContract', - ] -); - -$metadata->addEntityListener(Events::postPersist, 'CompanyContractListener', 'postPersistHandler'); -$metadata->addEntityListener(Events::prePersist, 'CompanyContractListener', 'prePersistHandler'); - -$metadata->addEntityListener(Events::postUpdate, 'CompanyContractListener', 'postUpdateHandler'); -$metadata->addEntityListener(Events::preUpdate, 'CompanyContractListener', 'preUpdateHandler'); - -$metadata->addEntityListener(Events::postRemove, 'CompanyContractListener', 'postRemoveHandler'); -$metadata->addEntityListener(Events::preRemove, 'CompanyContractListener', 'preRemoveHandler'); - -$metadata->addEntityListener(Events::preFlush, 'CompanyContractListener', 'preFlushHandler'); -$metadata->addEntityListener(Events::postLoad, 'CompanyContractListener', 'postLoadHandler'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFixContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFixContract.php deleted file mode 100644 index 45cb4d631e2..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFixContract.php +++ /dev/null @@ -1,11 +0,0 @@ -mapField( - [ - 'type' => 'integer', - 'name' => 'fixPrice', - 'fieldName' => 'fixPrice', - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexContract.php deleted file mode 100644 index 76a7e05f420..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexContract.php +++ /dev/null @@ -1,19 +0,0 @@ -mapField( - [ - 'type' => 'integer', - 'name' => 'hoursWorked', - 'fieldName' => 'hoursWorked', - ] -); - -$metadata->mapField( - [ - 'type' => 'integer', - 'name' => 'pricePerHour', - 'fieldName' => 'pricePerHour', - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.php deleted file mode 100644 index 0d9a1b53c4e..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.php +++ /dev/null @@ -1,27 +0,0 @@ -mapField( - [ - 'type' => 'integer', - 'name' => 'maxPrice', - 'fieldName' => 'maxPrice', - ] -); -$metadata->addEntityListener(Events::postPersist, 'CompanyContractListener', 'postPersistHandler'); -$metadata->addEntityListener(Events::prePersist, 'CompanyContractListener', 'prePersistHandler'); - -$metadata->addEntityListener(Events::postUpdate, 'CompanyContractListener', 'postUpdateHandler'); -$metadata->addEntityListener(Events::preUpdate, 'CompanyContractListener', 'preUpdateHandler'); - -$metadata->addEntityListener(Events::postRemove, 'CompanyContractListener', 'postRemoveHandler'); -$metadata->addEntityListener(Events::preRemove, 'CompanyContractListener', 'preRemoveHandler'); - -$metadata->addEntityListener(Events::preFlush, 'CompanyContractListener', 'preFlushHandler'); -$metadata->addEntityListener(Events::postLoad, 'CompanyContractListener', 'postLoadHandler'); - -$metadata->addEntityListener(Events::prePersist, 'CompanyFlexUltraContractListener', 'prePersistHandler1'); -$metadata->addEntityListener(Events::prePersist, 'CompanyFlexUltraContractListener', 'prePersistHandler2'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyPerson.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyPerson.php deleted file mode 100644 index f7656ccd732..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Company.CompanyPerson.php +++ /dev/null @@ -1,48 +0,0 @@ -setPrimaryTable( - ['name' => 'company_person'] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'fetchAllWithResultClass', - 'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name', - 'resultClass' => CompanyPerson::class, - ] -); - -$metadata->addNamedNativeQuery( - [ - 'name' => 'fetchAllWithSqlResultSetMapping', - 'query' => 'SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name', - 'resultSetMapping' => 'mappingFetchAll', - ] -); - -$metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingFetchAll', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - ], - 'entityClass' => CompanyPerson::class, - 'discriminatorColumn' => 'discriminator', - ], - ], - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php deleted file mode 100644 index b7ff3b83491..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php +++ /dev/null @@ -1,16 +0,0 @@ -mapField( - [ - 'id' => true, - 'fieldName' => 'id', - ] -); -$metadata->mapField( - ['fieldName' => 'name'] -); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.php deleted file mode 100644 index 46d2a25a2db..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.php +++ /dev/null @@ -1,22 +0,0 @@ -setPrimaryTable( - [ - 'name' => 'explicit_table', - 'schema' => 'explicit_schema', - ] -); - -$metadata->mapField( - [ - 'id' => true, - 'fieldName' => 'id', - ] -); - -$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.php deleted file mode 100644 index ff318fd2079..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.php +++ /dev/null @@ -1,19 +0,0 @@ -setPrimaryTable( - ['name' => 'implicit_schema.implicit_table'] -); - -$metadata->mapField( - [ - 'id' => true, - 'fieldName' => 'id', - ] -); - -$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC3579.DDC3579Admin.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC3579.DDC3579Admin.php deleted file mode 100644 index 94ed4de9755..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC3579.DDC3579Admin.php +++ /dev/null @@ -1,5 +0,0 @@ -setAssociationOverride('groups', ['inversedBy' => 'admins']); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC3579.DDC3579User.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC3579.DDC3579User.php deleted file mode 100644 index cccc0e494d5..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC3579.DDC3579User.php +++ /dev/null @@ -1,37 +0,0 @@ -isMappedSuperclass = true; - -$metadata->mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'user_id', - 'length' => 150, - ] -); - -$metadata->mapField( - [ - 'fieldName' => 'name', - 'type' => 'string', - 'columnName' => 'user_name', - 'nullable' => true, - 'unique' => false, - 'length' => 250, - ] -); - -$metadata->mapManyToMany( - [ - 'fieldName' => 'groups', - 'targetEntity' => 'DDC3579Group', - ] -); - -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.php deleted file mode 100644 index 3680a69a4a5..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.php +++ /dev/null @@ -1,19 +0,0 @@ -mapField([ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', -]); - -$metadata->mapManyToMany([ - 'fieldName' => 'members', - 'targetEntity' => 'DDC5934Member', -]); - -$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC5934.DDC5934Contract.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC5934.DDC5934Contract.php deleted file mode 100644 index e46a32f26f1..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC5934.DDC5934Contract.php +++ /dev/null @@ -1,9 +0,0 @@ -setAssociationOverride('members', [ - 'fetch' => ClassMetadata::FETCH_EXTRA_LAZY, -]); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php deleted file mode 100644 index c7e5cae4ae4..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php +++ /dev/null @@ -1,10 +0,0 @@ -mapField( - [ - 'fieldName' => 'serialNumber', - 'type' => 'string', - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php deleted file mode 100644 index a9698997d59..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php +++ /dev/null @@ -1,10 +0,0 @@ -mapField( - [ - 'fieldName' => 'creditCardNumber', - 'type' => 'string', - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php deleted file mode 100644 index 803dcbc4cd6..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php +++ /dev/null @@ -1,24 +0,0 @@ -mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - ] -); -$metadata->mapField( - [ - 'fieldName' => 'value', - 'type' => 'float', - ] -); -$metadata->isMappedSuperclass = true; -$metadata->setCustomRepositoryClass(DDC869PaymentRepository::class); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Class.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Class.php deleted file mode 100644 index 0e0099321c3..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Class.php +++ /dev/null @@ -1,14 +0,0 @@ -mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - ] -); - -//$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Entity.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Entity.php deleted file mode 100644 index 174d7fd709f..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC889.DDC889Entity.php +++ /dev/null @@ -1,3 +0,0 @@ -mapField( - [ - 'fieldName' => 'name', - 'type' => 'string', - ] -); -$metadata->isMappedSuperclass = true; -$metadata->setCustomRepositoryClass(DDC889SuperClass::class); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Admin.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Admin.php deleted file mode 100644 index b76d5222907..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Admin.php +++ /dev/null @@ -1,31 +0,0 @@ -setAssociationOverride( - 'address', - [ - 'joinColumns' => [ - [ - 'name' => 'adminaddress_id', - 'referencedColumnName' => 'id', - ], - ], - ] -); - -$metadata->setAssociationOverride( - 'groups', - [ - 'joinTable' => [ - 'name' => 'ddc964_users_admingroups', - 'joinColumns' => [ - ['name' => 'adminuser_id'], - ], - - 'inverseJoinColumns' => [ - ['name' => 'admingroup_id'], - ], - ], - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Guest.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Guest.php deleted file mode 100644 index af20773f8ca..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964Guest.php +++ /dev/null @@ -1,19 +0,0 @@ -setAttributeOverride('id', [ - 'columnName' => 'guest_id', - 'type' => 'integer', - 'length' => 140, -]); - -$metadata->setAttributeOverride( - 'name', - [ - 'columnName' => 'guest_name', - 'nullable' => false, - 'unique' => true, - 'length' => 240, - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964User.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964User.php deleted file mode 100644 index 736ff5b569d..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC964.DDC964User.php +++ /dev/null @@ -1,62 +0,0 @@ -isMappedSuperclass = true; - -$metadata->mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'user_id', - 'length' => 150, - ] -); -$metadata->mapField( - [ - 'fieldName' => 'name', - 'type' => 'string', - 'columnName' => 'user_name', - 'nullable' => true, - 'unique' => false, - 'length' => 250, - ] -); - -$metadata->mapManyToOne( - [ - 'fieldName' => 'address', - 'targetEntity' => 'DDC964Address', - 'cascade' => ['persist','merge'], - 'joinColumn' => ['name' => 'address_id', 'referencedColumnMame' => 'id'], - ] -); - -$metadata->mapManyToMany( - [ - 'fieldName' => 'groups', - 'targetEntity' => 'DDC964Group', - 'inversedBy' => 'users', - 'cascade' => ['persist','merge','detach'], - 'joinTable' => [ - 'name' => 'ddc964_users_groups', - 'joinColumns' => [ - [ - 'name' => 'user_id', - 'referencedColumnName' => 'id', - ], - ], - 'inverseJoinColumns' => [ - [ - 'name' => 'group_id', - 'referencedColumnName' => 'id', - ], - ], - ], - ] -); - -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTyped.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTyped.php deleted file mode 100644 index 0888a78d07d..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTyped.php +++ /dev/null @@ -1,65 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); -$metadata->setPrimaryTable( - ['name' => 'cms_users_typed'] -); - -$metadata->mapField( - [ - 'id' => true, - 'fieldName' => 'id', - ] -); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); - -$metadata->mapField( - [ - 'fieldName' => 'status', - 'length' => 50, - ] -); -$metadata->mapField( - [ - 'fieldName' => 'username', - 'length' => 255, - 'unique' => true, - ] -); -$metadata->mapField( - ['fieldName' => 'dateInterval'] -); -$metadata->mapField( - ['fieldName' => 'dateTime'] -); -$metadata->mapField( - ['fieldName' => 'dateTimeImmutable'] -); -$metadata->mapField( - ['fieldName' => 'array'] -); -$metadata->mapField( - ['fieldName' => 'boolean'] -); -$metadata->mapField( - ['fieldName' => 'float'] -); - -$metadata->mapOneToOne( - [ - 'fieldName' => 'email', - 'cascade' => [0 => 'persist'], - 'joinColumns' => [[]], - 'orphanRemoval' => true, - ] -); - -$metadata->mapManyToOne( - ['fieldName' => 'mainEmail'] -); - -$metadata->mapEmbedded(['fieldName' => 'contact']); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Animal.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Animal.php deleted file mode 100644 index c40b9b42aef..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Animal.php +++ /dev/null @@ -1,40 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE); -$metadata->setDiscriminatorColumn( - [ - 'name' => 'dtype', - 'type' => 'string', - 'length' => 255, - 'fieldName' => 'dtype', - ] -); -$metadata->setDiscriminatorMap( - [ - 'cat' => Cat::class, - 'dog' => Dog::class, - ] -); -$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); -$metadata->mapField( - [ - 'fieldName' => 'id', - 'type' => 'string', - 'length' => null, - 'precision' => 0, - 'scale' => 0, - 'nullable' => false, - 'unique' => false, - 'id' => true, - 'columnName' => 'id', - ] -); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_CUSTOM); -$metadata->setCustomGeneratorDefinition(['class' => 'stdClass']); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Comment.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Comment.php deleted file mode 100644 index 4c3f733427a..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.Comment.php +++ /dev/null @@ -1,27 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); -$metadata->setPrimaryTable( - [ - 'indexes' => [ - ['columns' => ['content'], 'flags' => ['fulltext'], 'options' => ['where' => 'content IS NOT NULL']], - ], - ] -); - -$metadata->mapField( - [ - 'fieldName' => 'content', - 'type' => 'text', - 'scale' => 0, - 'length' => null, - 'unique' => false, - 'nullable' => false, - 'precision' => 0, - 'columnName' => 'content', - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php deleted file mode 100644 index 397c4c85f00..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php +++ /dev/null @@ -1,22 +0,0 @@ -mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'columnDefinition' => 'INT unsigned NOT NULL', - ] -); - -$metadata->mapField( - [ - 'fieldName' => 'value', - 'columnDefinition' => 'VARCHAR(255) NOT NULL', - ] -); - -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC807Entity.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC807Entity.php deleted file mode 100644 index ff2786400c8..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC807Entity.php +++ /dev/null @@ -1,21 +0,0 @@ -mapField( - [ - 'id' => true, - 'fieldName' => 'id', - ] -); - -$metadata->setDiscriminatorColumn( - [ - 'name' => 'dtype', - 'columnDefinition' => "ENUM('ONE','TWO')", - ] -); - -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.PHPSLC.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.PHPSLC.php deleted file mode 100644 index a19b2da1b2c..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.PHPSLC.php +++ /dev/null @@ -1,18 +0,0 @@ -enableCache( - [ - 'usage' => ClassMetadataInfo::CACHE_USAGE_READ_ONLY, - ] -); -$metadata->mapManyToOne( - [ - 'fieldName' => 'foo', - 'id' => true, - 'targetEntity' => 'PHPSLCFoo', - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.php deleted file mode 100644 index 03f5a86eb61..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.php +++ /dev/null @@ -1,18 +0,0 @@ -mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - ] -); -$metadata->mapField( - [ - 'fieldName' => 'count', - 'type' => 'integer', - 'columnName' => '`count`', - ] -); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php deleted file mode 100644 index 9c0a0fd2b27..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php +++ /dev/null @@ -1,146 +0,0 @@ -setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); -$metadata->setPrimaryTable( - ['name' => 'cms_users'] -); -$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); -$metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist'); -$metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist'); -$metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist'); -$metadata->addNamedQuery( - [ - 'name' => 'all', - 'query' => 'SELECT u FROM __CLASS__ u', - ] -); -$metadata->mapField( - [ - 'id' => true, - 'fieldName' => 'id', - 'type' => 'integer', - 'columnName' => 'id', - 'options' => ['foo' => 'bar', 'unsigned' => false], - ] -); -$metadata->mapField( - [ - 'fieldName' => 'name', - 'type' => 'string', - 'length' => 50, - 'unique' => true, - 'nullable' => true, - 'columnName' => 'name', - 'options' => ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false], - ] -); -$metadata->mapField( - [ - 'fieldName' => 'email', - 'type' => 'string', - 'columnName' => 'user_email', - 'columnDefinition' => 'CHAR(32) NOT NULL', - ] -); -$mapping = ['fieldName' => 'version', 'type' => 'integer']; -$metadata->setVersionMapping($mapping); -$metadata->mapField($mapping); -$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); -$metadata->mapOneToOne( - [ - 'fieldName' => 'address', - 'targetEntity' => Address::class, - 'cascade' => - [0 => 'remove'], - 'mappedBy' => null, - 'inversedBy' => 'user', - 'joinColumns' => - [ - 0 => - [ - 'name' => 'address_id', - 'referencedColumnName' => 'id', - 'onDelete' => 'CASCADE', - ], - ], - 'orphanRemoval' => false, - ] -); -$metadata->mapOneToMany( - [ - 'fieldName' => 'phonenumbers', - 'targetEntity' => Phonenumber::class, - 'cascade' => - [1 => 'persist'], - 'mappedBy' => 'user', - 'orphanRemoval' => true, - 'orderBy' => - ['number' => 'ASC'], - ] -); -$metadata->mapManyToMany( - [ - 'fieldName' => 'groups', - 'targetEntity' => Group::class, - 'cascade' => - [ - 0 => 'remove', - 1 => 'persist', - 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', - ], - 'mappedBy' => null, - 'joinTable' => - [ - 'name' => 'cms_users_groups', - 'joinColumns' => - [ - 0 => - [ - 'name' => 'user_id', - 'referencedColumnName' => 'id', - 'unique' => false, - 'nullable' => false, - ], - ], - 'inverseJoinColumns' => - [ - 0 => - [ - 'name' => 'group_id', - 'referencedColumnName' => 'id', - 'columnDefinition' => 'INT NULL', - ], - ], - ], - 'orderBy' => null, - ] -); -$metadata->table['options'] = [ - 'foo' => 'bar', - 'baz' => ['key' => 'val'], -]; -$metadata->table['uniqueConstraints'] = [ - 'search_idx' => ['columns' => ['name', 'user_email'], 'options' => ['where' => 'name IS NOT NULL']], - 'phone_idx' => ['fields' => ['name', 'phone']], -]; -$metadata->table['indexes'] = [ - 'name_idx' => ['columns' => ['name']], - 0 => ['columns' => ['user_email']], - 'fields' => ['fields' => ['name', 'email']], -]; -$metadata->setSequenceGeneratorDefinition( - [ - 'sequenceName' => 'tablename_seq', - 'allocationSize' => 100, - 'initialValue' => 1, - ] -); From 1af202bf10a1237b14aa00aead7a882af4b78396 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 9 Jan 2022 18:25:51 +0100 Subject: [PATCH 026/475] Remove support for Doctrine Cache in second level cache (#9348) --- UPGRADE.md | 17 ++++ .../ORM/Cache/DefaultCacheFactory.php | 49 ++-------- .../Cache/Region/DefaultMultiGetRegion.php | 14 --- .../ORM/Cache/Region/DefaultRegion.php | 92 ++----------------- phpstan-baseline.neon | 6 +- psalm-baseline.xml | 8 -- psalm.xml | 5 - .../ORM/Cache/DefaultRegionLegacyTest.php | 22 ----- .../Tests/ORM/Cache/DefaultRegionTest.php | 15 --- .../Tests/ORM/Cache/MultiGetRegionTest.php | 59 ------------ 10 files changed, 35 insertions(+), 252 deletions(-) delete mode 100644 lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php delete mode 100644 tests/Doctrine/Tests/ORM/Cache/DefaultRegionLegacyTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php diff --git a/UPGRADE.md b/UPGRADE.md index b7748c6157f..861c4c09bc9 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,22 @@ # Upgrade to 3.0 +## BC BREAK: PSR-6-based second level cache + +The second level cache has been reworked to consume a PSR-6 cache. Using a +Doctrine Cache instance is not supported anymore. + +* `DefaultCacheFactory`: The constructor expects a PSR-6 cache item pool as + second argument now. +* `DefaultMultiGetRegion`: This class has been removed. +* `DefaultRegion`: + * The constructor expects a PSR-6 cache item pool as second argument now. + * The protected `$cache` property is removed. + * The properties `$name` and `$lifetime` as well as the constant + `REGION_KEY_SEPARATOR` and the method `getCacheEntryKey()` are + `private` now. + * The method `getCache()` has been removed. + + ## BC Break: Remove `Doctrine\ORM\Mapping\Driver\PHPDriver` Use `StaticPHPDriver` instead when you want to programmatically configure diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index fee109bea3c..9ebc5a62bf9 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -4,9 +4,6 @@ namespace Doctrine\ORM\Cache; -use Doctrine\Common\Cache\Cache as LegacyCache; -use Doctrine\Common\Cache\Psr6\CacheAdapter; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache; use Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister; use Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister; @@ -24,58 +21,26 @@ use InvalidArgumentException; use LogicException; use Psr\Cache\CacheItemPoolInterface; -use TypeError; use function assert; -use function get_debug_type; use function sprintf; use const DIRECTORY_SEPARATOR; class DefaultCacheFactory implements CacheFactory { - /** @var CacheItemPoolInterface */ - private $cacheItemPool; - - /** @var RegionsConfiguration */ - private $regionsConfig; - - /** @var TimestampRegion|null */ - private $timestampRegion; + private CacheItemPoolInterface $cacheItemPool; + private RegionsConfiguration $regionsConfig; + private ?TimestampRegion $timestampRegion = null; /** @var Region[] */ - private $regions = []; + private array $regions = []; - /** @var string|null */ - private $fileLockRegionDirectory; + private ?string $fileLockRegionDirectory = null; - /** - * @param CacheItemPoolInterface $cacheItemPool - */ - public function __construct(RegionsConfiguration $cacheConfig, $cacheItemPool) + public function __construct(RegionsConfiguration $cacheConfig, CacheItemPoolInterface $cacheItemPool) { - if ($cacheItemPool instanceof LegacyCache) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9322', - 'Passing an instance of %s to %s is deprecated, pass a %s instead.', - get_debug_type($cacheItemPool), - __METHOD__, - CacheItemPoolInterface::class - ); - - $this->cacheItemPool = CacheAdapter::wrap($cacheItemPool); - } elseif (! $cacheItemPool instanceof CacheItemPoolInterface) { - throw new TypeError(sprintf( - '%s: Parameter #2 is expected to be an instance of %s, got %s.', - __METHOD__, - CacheItemPoolInterface::class, - get_debug_type($cacheItemPool) - )); - } else { - $this->cacheItemPool = $cacheItemPool; - } - + $this->cacheItemPool = $cacheItemPool; $this->regionsConfig = $cacheConfig; } diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php deleted file mode 100644 index 8fe5c7a9130..00000000000 --- a/lib/Doctrine/ORM/Cache/Region/DefaultMultiGetRegion.php +++ /dev/null @@ -1,14 +0,0 @@ -cache = $cacheItemPool; - $this->cacheItemPool = CacheAdapter::wrap($cacheItemPool); - } elseif (! $cacheItemPool instanceof CacheItemPoolInterface) { - throw new TypeError(sprintf( - '%s: Parameter #2 is expected to be an instance of %s, got %s.', - __METHOD__, - CacheItemPoolInterface::class, - get_debug_type($cacheItemPool) - )); - } else { - $this->cache = DoctrineProvider::wrap($cacheItemPool); - $this->cacheItemPool = $cacheItemPool; - } - - $this->name = $name; - $this->lifetime = $lifetime; + $this->cacheItemPool = $cacheItemPool; + $this->name = $name; + $this->lifetime = $lifetime; } /** @@ -102,16 +45,6 @@ public function getName() return $this->name; } - /** - * @deprecated - * - * @return CacheProvider - */ - public function getCache() - { - return $this->cache; - } - /** * {@inheritdoc} */ @@ -205,12 +138,7 @@ public function evictAll() return $this->cacheItemPool->clear(self::REGION_PREFIX . $this->name); } - /** - * @internal since 2.11, this method will be private in 3.0. - * - * @return string - */ - protected function getCacheEntryKey(CacheKey $key) + private function getCacheEntryKey(CacheKey $key): string { return self::REGION_PREFIX . $this->name . self::REGION_KEY_SEPARATOR . strtr($key->hash, '{}()/\@:', '________'); } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2403bd95555..02236aa6d5a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -95,11 +95,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php - - - message: "#^Method Doctrine\\\\ORM\\\\Cache\\\\Region\\\\DefaultRegion\\:\\:getCache\\(\\) should return Doctrine\\\\Common\\\\Cache\\\\CacheProvider but returns Doctrine\\\\Common\\\\Cache\\\\Cache\\.$#" - count: 1 - path: lib/Doctrine/ORM/Cache/Region/DefaultRegion.php - - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Cache\\\\CacheEntry\\:\\:\\$time\\.$#" count: 1 @@ -1569,3 +1564,4 @@ parameters: message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#" count: 1 path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index f8cff55c2f9..d7755f112ec 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -275,14 +275,6 @@ lock - - - $this->cache - - - CacheProvider - - update diff --git a/psalm.xml b/psalm.xml index 6d86d779e49..5182850c1e2 100644 --- a/psalm.xml +++ b/psalm.xml @@ -31,11 +31,6 @@ - - - - - diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionLegacyTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionLegacyTest.php deleted file mode 100644 index 54f07d4d652..00000000000 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionLegacyTest.php +++ /dev/null @@ -1,22 +0,0 @@ -expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9322'); - - return new DefaultRegion('default.region.test', DoctrineProvider::wrap($this->cacheItemPool)); - } -} diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index d54e4d92c88..d9dd1498f68 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -4,13 +4,11 @@ namespace Doctrine\Tests\ORM\Cache; -use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\Cache\Region\DefaultRegion; use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheKeyMock; -use Symfony\Component\Cache\Adapter\ArrayAdapter; use function array_map; @@ -27,7 +25,6 @@ protected function createRegion(): Region public function testGetters(): void { self::assertEquals('default.region.test', $this->region->getName()); - self::assertSame($this->cacheItemPool, $this->region->getCache()->getPool()); } public function testSharedRegion(): void @@ -52,18 +49,6 @@ public function testSharedRegion(): void self::assertTrue($region2->contains($key)); } - public function testDoesNotModifyCacheNamespace(): void - { - $cache = DoctrineProvider::wrap(new ArrayAdapter()); - - $cache->setNamespace('foo'); - - new DefaultRegion('bar', $cache); - new DefaultRegion('baz', $cache); - - self::assertSame('foo', $cache->getNamespace()); - } - public function testGetMulti(): void { $key1 = new CacheKeyMock('key.1'); diff --git a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php deleted file mode 100644 index 4ade1ec9c32..00000000000 --- a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php +++ /dev/null @@ -1,59 +0,0 @@ -cacheItemPool); - } - - public function testGetMulti(): void - { - $key1 = new CacheKeyMock('key.1'); - $value1 = new CacheEntryMock(['id' => 1, 'name' => 'bar']); - - $key2 = new CacheKeyMock('key.2'); - $value2 = new CacheEntryMock(['id' => 2, 'name' => 'bar']); - - self::assertFalse($this->region->contains($key1)); - self::assertFalse($this->region->contains($key2)); - - $this->region->put($key1, $value1); - $this->region->put($key2, $value2); - - self::assertTrue($this->region->contains($key1)); - self::assertTrue($this->region->contains($key2)); - - $actual = $this->region->getMultiple(new CollectionCacheEntry([$key1, $key2])); - - self::assertEquals($value1, $actual[0]); - self::assertEquals($value2, $actual[1]); - } - - /** - * @test - * @group GH7266 - */ - public function corruptedDataDoesNotLeakIntoApplication(): void - { - $key1 = new CacheKeyMock('key.1'); - $this->cacheItemPool->save( - $this->cacheItemPool - ->getItem('DC2_REGION_' . $this->region->getName() . '_' . $key1->hash) - ->set('a-very-invalid-value') - ); - - self::assertTrue($this->region->contains($key1)); - self::assertNull($this->region->getMultiple(new CollectionCacheEntry([$key1]))); - } -} From 9f85e2769cf70f2aaa8a5bfe59c93909e477185b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 11 Jan 2022 08:53:17 +0100 Subject: [PATCH 027/475] Add native types to command classes (#9359) --- .../Command/AbstractEntityManagerCommand.php | 7 +-- .../ClearCache/CollectionRegionCommand.php | 12 +--- .../ClearCache/EntityRegionCommand.php | 12 +--- .../Command/ClearCache/MetadataCommand.php | 12 +--- .../Command/ClearCache/QueryCommand.php | 12 +--- .../Command/ClearCache/QueryRegionCommand.php | 12 +--- .../Command/ClearCache/ResultCommand.php | 12 +--- .../Command/GenerateProxiesCommand.php | 12 +--- .../ORM/Tools/Console/Command/InfoCommand.php | 12 +--- .../Command/MappingDescribeCommand.php | 6 +- .../Tools/Console/Command/RunDqlCommand.php | 12 +--- .../Command/SchemaTool/AbstractCommand.php | 11 +--- .../Command/SchemaTool/CreateCommand.php | 7 +-- .../Command/SchemaTool/DropCommand.php | 7 +-- .../Command/SchemaTool/UpdateCommand.php | 7 +-- .../Console/Command/ValidateSchemaCommand.php | 12 +--- .../ORM/Tools/Console/ConsoleRunner.php | 14 ++--- .../ConnectionFromManagerProvider.php | 6 +- .../HelperSetManagerProvider.php | 7 +-- .../SingleManagerProvider.php | 14 ++--- .../Console/Helper/EntityManagerHelper.php | 15 +---- .../ORM/Tools/Console/MetadataFilter.php | 22 ++------ psalm-baseline.xml | 55 ------------------- 23 files changed, 53 insertions(+), 245 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php index 281fc761872..77256a4a528 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php @@ -12,14 +12,9 @@ abstract class AbstractEntityManagerCommand extends Command { - /** @var EntityManagerProvider|null */ - private $entityManagerProvider; - - public function __construct(?EntityManagerProvider $entityManagerProvider = null) + public function __construct(private ?EntityManagerProvider $entityManagerProvider = null) { parent::__construct(); - - $this->entityManagerProvider = $entityManagerProvider; } final protected function getEntityManager(InputInterface $input): EntityManagerInterface diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php index b31c3bec2e6..f1bcee8f1a6 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php @@ -20,10 +20,7 @@ */ class CollectionRegionCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:clear-cache:region:collection') ->setDescription('Clear a second-level cache collection region') @@ -60,12 +57,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php index 1a689b37c89..05c69a41180 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php @@ -20,10 +20,7 @@ */ class EntityRegionCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:clear-cache:region:entity') ->setDescription('Clear a second-level cache entity region') @@ -59,12 +56,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php index 25a76eadf1b..850cc89fce3 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php @@ -18,10 +18,7 @@ */ class MetadataCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:clear-cache:metadata') ->setDescription('Clear all metadata cache of the various cache drivers') @@ -33,12 +30,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php index b88e270609b..0e6917bdb74 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php @@ -27,10 +27,7 @@ */ class QueryCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:clear-cache:query') ->setDescription('Clear all query cache of the various cache drivers') @@ -56,12 +53,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php index 8b665760316..f9a07f736e1 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php @@ -20,10 +20,7 @@ */ class QueryRegionCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:clear-cache:region:query') ->setDescription('Clear a second-level cache query region') @@ -58,12 +55,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php index e9336965958..01c25414efa 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php @@ -29,10 +29,7 @@ */ class ResultCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:clear-cache:result') ->setDescription('Clear all result cache of the various cache drivers') @@ -58,12 +55,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php index 9e17bc00a2a..6b8d2a8b07e 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php @@ -26,10 +26,7 @@ */ class GenerateProxiesCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:generate-proxies') ->setAliases(['orm:generate:proxies']) @@ -40,12 +37,7 @@ protected function configure() ->setHelp('Generates proxy classes for entity classes.'); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php index e040b81d2e3..35a1ff2ec48 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php @@ -20,10 +20,7 @@ */ class InfoCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:info') ->setDescription('Show basic information about all mapped entities') @@ -36,12 +33,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 5481ea371ec..c43f3af424b 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -188,10 +188,8 @@ static function ($mappedEntity) use ($entityName) { /** * Format the given value for console output - * - * @param mixed $value */ - private function formatValue($value): string + private function formatValue(mixed $value): string { if ($value === '') { return ''; @@ -233,7 +231,7 @@ private function formatValue($value): string * @return string[] * @psalm-return array{0: string, 1: string} */ - private function formatField(string $label, $value): array + private function formatField(string $label, mixed $value): array { if ($value === null) { $value = 'None'; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php index 90801d1defb..78ac6b754e5 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php @@ -27,10 +27,7 @@ */ class RunDqlCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:run-dql') ->setDescription('Executes arbitrary DQL directly from the command line') @@ -44,12 +41,7 @@ protected function configure() ->setHelp('Executes arbitrary DQL directly from the command line.'); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php index ae4d0fb0f90..46c47a13faa 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php @@ -19,17 +19,10 @@ abstract class AbstractCommand extends AbstractEntityManagerCommand { /** * @param mixed[] $metadatas - * - * @return int|null Null or 0 if everything went fine, or an error code. */ - abstract protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui); + abstract protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui): int; - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php index e19de66f355..732d0733ddb 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php @@ -19,10 +19,7 @@ */ class CreateCommand extends AbstractCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:schema-tool:create') ->setDescription('Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output') @@ -43,7 +40,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui) + protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui): int { $dumpSql = $input->getOption('dump-sql') === true; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php index f766c090f63..1875d403ff6 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php @@ -20,10 +20,7 @@ */ class DropCommand extends AbstractCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:schema-tool:drop') ->setDescription('Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output') @@ -47,7 +44,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui) + protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui): int { $isFullDatabaseDrop = $input->getOption('full-database'); $dumpSql = $input->getOption('dump-sql') === true; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php index 6dffd12bbf2..7e97455aa3b 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -24,10 +24,7 @@ class UpdateCommand extends AbstractCommand /** @var string */ protected $name = 'orm:schema-tool:update'; - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName($this->name) ->setDescription('Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata') @@ -71,7 +68,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui) + protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui): int { // Defining if update is complete or not (--complete not defined means $saveMode = true) $saveMode = ! $input->getOption('complete'); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php index b7f3dccae19..e9197786491 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php @@ -19,10 +19,7 @@ */ class ValidateSchemaCommand extends AbstractEntityManagerCommand { - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this->setName('orm:validate-schema') ->setDescription('Validate the mapping files') @@ -32,12 +29,7 @@ protected function configure() ->setHelp('Validate that the mapping files are correct and in sync with the database.'); } - /** - * {@inheritdoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index 2adbba07978..79942631ba5 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -31,10 +31,9 @@ public static function createHelperSet(EntityManagerInterface $entityManager): H /** * Runs console with the given helper set. * - * @param HelperSet|EntityManagerProvider $helperSetOrProvider - * @param SymfonyCommand[] $commands + * @param SymfonyCommand[] $commands */ - public static function run($helperSetOrProvider, array $commands = []): void + public static function run(HelperSet|EntityManagerProvider $helperSetOrProvider, array $commands = []): void { $cli = self::createApplication($helperSetOrProvider, $commands); $cli->run(); @@ -44,13 +43,14 @@ public static function run($helperSetOrProvider, array $commands = []): void * Creates a console application with the given helperset and * optional commands. * - * @param HelperSet|EntityManagerProvider $helperSetOrProvider - * @param SymfonyCommand[] $commands + * @param SymfonyCommand[] $commands * * @throws OutOfBoundsException */ - public static function createApplication($helperSetOrProvider, array $commands = []): Application - { + public static function createApplication( + HelperSet|EntityManagerProvider $helperSetOrProvider, + array $commands = [] + ): Application { $cli = new Application('Doctrine Command Line Interface', Versions::getVersion('doctrine/orm')); $cli->setCatchExceptions(true); diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php index 332c24f2d13..8b677fddc40 100644 --- a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php +++ b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php @@ -10,12 +10,8 @@ final class ConnectionFromManagerProvider implements ConnectionProvider { - /** @var EntityManagerProvider */ - private $entityManagerProvider; - - public function __construct(EntityManagerProvider $entityManagerProvider) + public function __construct(private EntityManagerProvider $entityManagerProvider) { - $this->entityManagerProvider = $entityManagerProvider; } public function getDefaultConnection(): Connection diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/HelperSetManagerProvider.php b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/HelperSetManagerProvider.php index a11d48774b0..2e03e4997a8 100644 --- a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/HelperSetManagerProvider.php +++ b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/HelperSetManagerProvider.php @@ -14,13 +14,8 @@ final class HelperSetManagerProvider implements EntityManagerProvider { - /** @var HelperSet */ - private $helperSet; - - public function __construct(HelperSet $helperSet) + public function __construct(private HelperSet $helperSet) { - $this->helperSet = $helperSet; - Deprecation::trigger( 'doctrine/orm', 'https://github.com/doctrine/orm/issues/8327', diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php index 80da77f8664..3b8f5d8c0e0 100644 --- a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php +++ b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php @@ -9,16 +9,10 @@ final class SingleManagerProvider implements EntityManagerProvider { - /** @var EntityManagerInterface */ - private $entityManager; - - /** @var string */ - private $defaultManagerName; - - public function __construct(EntityManagerInterface $entityManager, string $defaultManagerName = 'default') - { - $this->entityManager = $entityManager; - $this->defaultManagerName = $defaultManagerName; + public function __construct( + private EntityManagerInterface $entityManager, + private string $defaultManagerName = 'default', + ) { } public function getDefaultManager(): EntityManagerInterface diff --git a/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php b/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php index 8c556b866d0..e20a7eca26c 100644 --- a/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php +++ b/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php @@ -16,10 +16,8 @@ class EntityManagerHelper extends Helper { /** * Doctrine ORM EntityManagerInterface. - * - * @var EntityManagerInterface */ - protected $_em; + protected EntityManagerInterface $_em; public function __construct(EntityManagerInterface $em) { @@ -28,20 +26,13 @@ public function __construct(EntityManagerInterface $em) /** * Retrieves Doctrine ORM EntityManager. - * - * @return EntityManagerInterface */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { return $this->_em; } - /** - * {@inheritdoc} - * - * @return string - */ - public function getName() + public function getName(): string { return 'entityManager'; } diff --git a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php b/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php index 0f43b4bfee5..4e43beec073 100644 --- a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php +++ b/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php @@ -8,7 +8,6 @@ use Countable; use Doctrine\Persistence\Mapping\ClassMetadata; use FilterIterator; -use ReturnTypeWillChange; use RuntimeException; use function assert; @@ -25,7 +24,7 @@ class MetadataFilter extends FilterIterator implements Countable { /** @var mixed[] */ - private $filter = []; + private array $filter = []; /** * Filter Metadatas by one or more filter options. @@ -35,7 +34,7 @@ class MetadataFilter extends FilterIterator implements Countable * * @return ClassMetadata[] */ - public static function filter(array $metadatas, $filter) + public static function filter(array $metadatas, array|string $filter) { $metadatas = new MetadataFilter(new ArrayIterator($metadatas), $filter); @@ -45,18 +44,14 @@ public static function filter(array $metadatas, $filter) /** * @param mixed[]|string $filter */ - public function __construct(ArrayIterator $metadata, $filter) + public function __construct(ArrayIterator $metadata, array|string $filter) { $this->filter = (array) $filter; parent::__construct($metadata); } - /** - * @return bool - */ - #[ReturnTypeWillChange] - public function accept() + public function accept(): bool { if (count($this->filter) === 0) { return true; @@ -85,8 +80,7 @@ public function accept() /** * @return ArrayIterator */ - #[ReturnTypeWillChange] - public function getInnerIterator() + public function getInnerIterator(): ArrayIterator { $innerIterator = parent::getInnerIterator(); @@ -95,11 +89,7 @@ public function getInnerIterator() return $innerIterator; } - /** - * @return int - */ - #[ReturnTypeWillChange] - public function count() + public function count(): int { return count($this->getInnerIterator()); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 16ddbf6c9a9..0521eaf3f6f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2775,55 +2775,30 @@ - - configure - evictAll - - configure - evictAll - - - configure - - getQueryCacheImpl - - configure - - - - - configure - getResultCacheImpl - - configure - getProxyDir getProxyDir - - configure - $metadata->name @@ -2832,9 +2807,6 @@ - - configure - getAllClassNames @@ -2851,46 +2823,19 @@ Debug::dump($resultSet, (int) $input->getOption('depth'), true, false) - - configure - - - - - int - - - $this->executeSchemaCommand($input, $output, new SchemaTool($em), $metadatas, $ui) - - - - - configure - - - configure - $this->getName() $this->getName() - - configure - $this->getName() $this->getName() - - - configure - - Versions::getVersion('doctrine/orm') From 96241294bb83838f92c9ed88971f9eeb29902288 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 12 Jan 2022 10:57:33 +0100 Subject: [PATCH 028/475] Add native types to AbstractHydrator and child classes (#9353) --- .../Internal/Hydration/AbstractHydrator.php | 71 +++++-------------- .../ORM/Internal/Hydration/ArrayHydrator.php | 31 ++++---- .../Internal/Hydration/HydrationException.php | 43 ++--------- .../ORM/Internal/Hydration/ObjectHydrator.php | 22 ++---- .../ORM/Internal/Hydration/ScalarHydrator.php | 4 +- .../Hydration/SimpleObjectHydrator.php | 19 ++--- .../Hydration/SingleScalarHydrator.php | 5 +- psalm-baseline.xml | 3 - .../ORM/Hydration/AbstractHydratorTest.php | 15 ++-- .../Tests/ORM/Hydration/ArrayHydratorTest.php | 16 ++--- .../ORM/Hydration/CustomHydratorTest.php | 2 +- .../Tests/ORM/Hydration/HydrationTestCase.php | 3 +- .../ORM/Hydration/ResultSetMappingTest.php | 9 +-- 13 files changed, 74 insertions(+), 169 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 27c590f635d..f6d987cff90 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -31,64 +31,52 @@ abstract class AbstractHydrator { /** * The ResultSetMapping. - * - * @var ResultSetMapping|null */ - protected $_rsm; + protected ?ResultSetMapping $_rsm = null; /** * The EntityManager instance. - * - * @var EntityManagerInterface */ - protected $_em; + protected EntityManagerInterface $_em; /** * The dbms Platform instance. - * - * @var AbstractPlatform */ - protected $_platform; + protected AbstractPlatform $_platform; /** * The UnitOfWork of the associated EntityManager. - * - * @var UnitOfWork */ - protected $_uow; + protected UnitOfWork $_uow; /** * Local ClassMetadata cache to avoid going to the EntityManager all the time. * * @var array> */ - protected $_metadataCache = []; + protected array $_metadataCache = []; /** * The cache used during row-by-row hydration. * * @var array */ - protected $_cache = []; + protected array $_cache = []; /** * The statement that provides the data to hydrate. - * - * @var Result|null */ - protected $_stmt; + protected ?Result $_stmt = null; /** * The query hints. * * @var array */ - protected $_hints = []; + protected array $_hints = []; /** * Initializes a new instance of a class derived from AbstractHydrator. - * - * @param EntityManagerInterface $em The EntityManager to use. */ public function __construct(EntityManagerInterface $em) { @@ -166,10 +154,8 @@ final protected function resultSetMapping(): ResultSetMapping * Hydrates all rows returned by the passed statement instance at once. * * @psalm-param array $hints - * - * @return mixed[] */ - public function hydrateAll(Result $stmt, ResultSetMapping $resultSetMapping, array $hints = []) + public function hydrateAll(Result $stmt, ResultSetMapping $resultSetMapping, array $hints = []): mixed { $this->_stmt = $stmt; $this->_rsm = $resultSetMapping; @@ -190,32 +176,24 @@ public function hydrateAll(Result $stmt, ResultSetMapping $resultSetMapping, arr /** * When executed in a hydrate() loop we have to clear internal state to * decrease memory consumption. - * - * @param mixed $eventArgs - * - * @return void */ - public function onClear($eventArgs) + public function onClear(mixed $eventArgs): void { } /** * Executes one-time preparation tasks, once each time hydration is started * through {@link hydrateAll} or {@link toIterable()}. - * - * @return void */ - protected function prepare() + protected function prepare(): void { } /** * Executes one-time cleanup tasks at the end of a hydration that was initiated * through {@link hydrateAll} or {@link toIterable()}. - * - * @return void */ - protected function cleanup() + protected function cleanup(): void { $this->statement()->free(); @@ -242,21 +220,17 @@ protected function cleanupAfterRowIteration(): void * @param mixed[] $row The row data. * @param mixed[] $result The result to fill. * - * @return void - * * @throws HydrationException */ - protected function hydrateRowData(array $row, array &$result) + protected function hydrateRowData(array $row, array &$result): void { throw new HydrationException('hydrateRowData() not implemented by this hydrator.'); } /** * Hydrates all rows from the current statement instance at once. - * - * @return mixed[] */ - abstract protected function hydrateAllData(); + abstract protected function hydrateAllData(): mixed; /** * Processes a row of the result set. @@ -284,7 +258,7 @@ abstract protected function hydrateAllData(); * scalars?: array * } */ - protected function gatherRowData(array $data, array &$id, array &$nonemptyComponents) + protected function gatherRowData(array $data, array &$id, array &$nonemptyComponents): array { $rowData = ['data' => []]; @@ -365,7 +339,7 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon * @return mixed[] The processed row. * @psalm-return array */ - protected function gatherScalarRowData(&$data) + protected function gatherScalarRowData(array &$data): array { $rowData = []; @@ -400,7 +374,7 @@ protected function gatherScalarRowData(&$data) * @return mixed[]|null * @psalm-return array|null */ - protected function hydrateColumnInfo($key) + protected function hydrateColumnInfo(string $key): ?array { if (isset($this->_cache[$key])) { return $this->_cache[$key]; @@ -508,12 +482,8 @@ function (string $subClass): string { /** * Retrieve ClassMetadata associated to entity class name. - * - * @param string $className - * - * @return ClassMetadata */ - protected function getClassMetadata($className) + protected function getClassMetadata(string $className): ClassMetadata { if (! isset($this->_metadataCache[$className])) { $this->_metadataCache[$className] = $this->_em->getClassMetadata($className); @@ -525,14 +495,11 @@ protected function getClassMetadata($className) /** * Register entity as managed in UnitOfWork. * - * @param object $entity * @param mixed[] $data * - * @return void - * * @todo The "$id" generation is the same of UnitOfWork#createEntity. Remove this duplication somehow */ - protected function registerManaged(ClassMetadata $class, $entity, array $data) + protected function registerManaged(ClassMetadata $class, object $entity, array $data): void { if ($class->isIdentifierComposite) { $id = []; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index 00748eaf5ce..7d71e826845 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -19,27 +19,22 @@ class ArrayHydrator extends AbstractHydrator { /** @var array */ - private $_rootAliases = []; + private array $_rootAliases = []; - /** @var bool */ - private $_isSimpleQuery = false; + private bool $_isSimpleQuery = false; /** @var mixed[] */ - private $_identifierMap = []; + private array $_identifierMap = []; /** @var mixed[] */ - private $_resultPointers = []; + private array $_resultPointers = []; /** @var array */ - private $_idTemplate = []; + private array $_idTemplate = []; - /** @var int */ - private $_resultCounter = 0; + private int $_resultCounter = 0; - /** - * {@inheritdoc} - */ - protected function prepare() + protected function prepare(): void { $this->_isSimpleQuery = count($this->resultSetMapping()->aliasMap) <= 1; @@ -53,7 +48,7 @@ protected function prepare() /** * {@inheritdoc} */ - protected function hydrateAllData() + protected function hydrateAllData(): array { $result = []; @@ -67,7 +62,7 @@ protected function hydrateAllData() /** * {@inheritdoc} */ - protected function hydrateRowData(array $row, array &$result) + protected function hydrateRowData(array $row, array &$result): void { // 1) Initialize $id = $this->_idTemplate; // initialize the id-memory @@ -242,13 +237,13 @@ protected function hydrateRowData(array $row, array &$result) * Updates the result pointer for an Entity. The result pointers point to the * last seen instance of each Entity type. This is used for graph construction. * - * @param mixed[]|null $coll The element. - * @param bool|int $index Index of the element in the collection. - * @param bool $oneToOne Whether it is a single-valued association or not. + * @param mixed[]|null $coll The element. + * @param string|int|false $index Index of the element in the collection. + * @param bool $oneToOne Whether it is a single-valued association or not. */ private function updateResultPointer( ?array &$coll, - $index, + string|int|false $index, string $dqlAlias, bool $oneToOne ): void { diff --git a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php b/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php index 90b6d3ae954..fa64d53ef9b 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php +++ b/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php @@ -12,21 +12,12 @@ class HydrationException extends Exception implements ORMException { - /** - * @return HydrationException - */ - public static function nonUniqueResult() + public static function nonUniqueResult(): self { return new self('The result returned by the query was not unique.'); } - /** - * @param string $alias - * @param string $parentAlias - * - * @return HydrationException - */ - public static function parentObjectOfRelationNotFound($alias, $parentAlias) + public static function parentObjectOfRelationNotFound(string $alias, string $parentAlias): self { return new self(sprintf( "The parent object of entity result with alias '%s' was not found." @@ -36,12 +27,7 @@ public static function parentObjectOfRelationNotFound($alias, $parentAlias) )); } - /** - * @param string $dqlAlias - * - * @return HydrationException - */ - public static function emptyDiscriminatorValue($dqlAlias) + public static function emptyDiscriminatorValue(string $dqlAlias): self { return new self("The DQL alias '" . $dqlAlias . "' contains an entity " . 'of an inheritance hierarchy with an empty discriminator value. This means ' . @@ -49,14 +35,7 @@ public static function emptyDiscriminatorValue($dqlAlias) 'discriminator value in a table row.'); } - /** - * @param string $entityName - * @param string $discrColumnName - * @param string $dqlAlias - * - * @return HydrationException - */ - public static function missingDiscriminatorColumn($entityName, $discrColumnName, $dqlAlias) + public static function missingDiscriminatorColumn(string $entityName, string $discrColumnName, string $dqlAlias): self { return new self(sprintf( 'The discriminator column "%s" is missing for "%s" using the DQL alias "%s".', @@ -66,14 +45,7 @@ public static function missingDiscriminatorColumn($entityName, $discrColumnName, )); } - /** - * @param string $entityName - * @param string $discrColumnName - * @param string $dqlAlias - * - * @return HydrationException - */ - public static function missingDiscriminatorMetaMappingColumn($entityName, $discrColumnName, $dqlAlias) + public static function missingDiscriminatorMetaMappingColumn(string $entityName, string $discrColumnName, string $dqlAlias): self { return new self(sprintf( 'The meta mapping for the discriminator column "%s" is missing for "%s" using the DQL alias "%s".', @@ -84,13 +56,10 @@ public static function missingDiscriminatorMetaMappingColumn($entityName, $discr } /** - * @param string $discrValue * @param string[] $discrMap * @psalm-param array $discrMap - * - * @return HydrationException */ - public static function invalidDiscriminatorValue($discrValue, $discrMap) + public static function invalidDiscriminatorValue(string $discrValue, array $discrMap): self { return new self(sprintf( 'The discriminator value "%s" is invalid. It must be one of "%s".', diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 019d1a24636..43a263e53f0 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -47,10 +47,7 @@ class ObjectHydrator extends AbstractHydrator /** @var mixed[] */ private $existingCollections = []; - /** - * {@inheritdoc} - */ - protected function prepare() + protected function prepare(): void { if (! isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD])) { $this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] = true; @@ -103,10 +100,7 @@ protected function prepare() } } - /** - * {@inheritdoc} - */ - protected function cleanup() + protected function cleanup(): void { $eagerLoad = isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD]) && $this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] === true; @@ -135,7 +129,7 @@ protected function cleanupAfterRowIteration(): void /** * {@inheritdoc} */ - protected function hydrateAllData() + protected function hydrateAllData(): array { $result = []; @@ -302,10 +296,8 @@ private function getEntityFromIdentityMap(string $className, array $data) * * @param mixed[] $row The data of the row to process. * @param mixed[] $result The result array to fill. - * - * @return void */ - protected function hydrateRowData(array $row, array &$result) + protected function hydrateRowData(array $row, array &$result): void { // Initialize $id = $this->idTemplate; // initialize the id-memory @@ -561,12 +553,8 @@ protected function hydrateRowData(array $row, array &$result) /** * When executed in a hydrate() loop we may have to clear internal state to * decrease memory consumption. - * - * @param mixed $eventArgs - * - * @return void */ - public function onClear($eventArgs) + public function onClear(mixed $eventArgs): void { parent::onClear($eventArgs); diff --git a/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php index b23cd3da94f..87fce42e8bc 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php @@ -14,7 +14,7 @@ class ScalarHydrator extends AbstractHydrator /** * {@inheritdoc} */ - protected function hydrateAllData() + protected function hydrateAllData(): array { $result = []; @@ -28,7 +28,7 @@ protected function hydrateAllData() /** * {@inheritdoc} */ - protected function hydrateRowData(array $row, array &$result) + protected function hydrateRowData(array $row, array &$result): void { $result[] = $this->gatherScalarRowData($row); } diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 454330290eb..cbbd42137da 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -12,6 +12,7 @@ use function array_keys; use function array_search; +use function assert; use function count; use function in_array; use function key; @@ -22,13 +23,9 @@ class SimpleObjectHydrator extends AbstractHydrator { use SQLResultCasing; - /** @var ClassMetadata */ - private $class; + private ?ClassMetadata $class = null; - /** - * {@inheritdoc} - */ - protected function prepare() + protected function prepare(): void { if (count($this->resultSetMapping()->aliasMap) !== 1) { throw new RuntimeException('Cannot use SimpleObjectHydrator with a ResultSetMapping that contains more than one object result.'); @@ -41,10 +38,7 @@ protected function prepare() $this->class = $this->getClassMetadata(reset($this->resultSetMapping()->aliasMap)); } - /** - * {@inheritdoc} - */ - protected function cleanup() + protected function cleanup(): void { parent::cleanup(); @@ -55,7 +49,7 @@ protected function cleanup() /** * {@inheritdoc} */ - protected function hydrateAllData() + protected function hydrateAllData(): array { $result = []; @@ -71,8 +65,9 @@ protected function hydrateAllData() /** * {@inheritdoc} */ - protected function hydrateRowData(array $row, array &$result) + protected function hydrateRowData(array $row, array &$result): void { + assert($this->class !== null); $entityName = $this->class->name; $data = []; $discrColumnValue = null; diff --git a/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php index b595909227f..2787bbcf21d 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php @@ -16,10 +16,7 @@ */ class SingleScalarHydrator extends AbstractHydrator { - /** - * {@inheritdoc} - */ - protected function hydrateAllData() + protected function hydrateAllData(): mixed { $data = $this->statement()->fetchAllAssociative(); $numRows = count($data); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 0521eaf3f6f..04a1035d5eb 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -557,9 +557,6 @@ array_keys($discrMap) - - $class - diff --git a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php index 786bda81f39..deeee2d0693 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php @@ -6,6 +6,7 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Result; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Events; @@ -23,16 +24,16 @@ class AbstractHydratorTest extends OrmFunctionalTestCase { /** @var EventManager&MockObject */ - private $mockEventManager; + private EventManager $mockEventManager; /** @var Result&MockObject */ - private $mockResult; + private Result $mockResult; /** @var ResultSetMapping&MockObject */ - private $mockResultMapping; + private ResultSetMapping $mockResultMapping; /** @var AbstractHydrator&MockObject */ - private $hydrator; + private AbstractHydrator $hydrator; protected function setUp(): void { @@ -44,16 +45,16 @@ protected function setUp(): void $this->mockResult = $this->createMock(Result::class); $this->mockResultMapping = $this->createMock(ResultSetMapping::class); + $mockConnection + ->method('getDatabasePlatform') + ->willReturn($this->createMock(AbstractPlatform::class)); $mockEntityManagerInterface - ->expects(self::any()) ->method('getEventManager') ->willReturn($this->mockEventManager); $mockEntityManagerInterface - ->expects(self::any()) ->method('getConnection') ->willReturn($mockConnection); $this->mockResult - ->expects(self::any()) ->method('fetchAssociative') ->willReturn(false); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php index dba8093dff1..301fae6021d 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php @@ -17,7 +17,7 @@ class ArrayHydratorTest extends HydrationTestCase { /** - * @psalm-return list + * @psalm-return list */ public function provideDataForUserEntityResult(): array { @@ -73,7 +73,7 @@ public function testSimpleEntityQuery(): void * * @dataProvider provideDataForUserEntityResult */ - public function testSimpleEntityWithScalarQuery($userEntityKey): void + public function testSimpleEntityWithScalarQuery(int|string $userEntityKey): void { $alias = $userEntityKey ?: 'u'; $rsm = new ResultSetMapping(); @@ -381,7 +381,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void * * @dataProvider provideDataForUserEntityResult */ - public function testMixedQueryNormalJoin($userEntityKey): void + public function testMixedQueryNormalJoin(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); @@ -430,7 +430,7 @@ public function testMixedQueryNormalJoin($userEntityKey): void * * @dataProvider provideDataForUserEntityResult */ - public function testMixedQueryFetchJoin($userEntityKey): void + public function testMixedQueryFetchJoin(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); @@ -501,7 +501,7 @@ public function testMixedQueryFetchJoin($userEntityKey): void * * @dataProvider provideDataForUserEntityResult */ - public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void + public function testMixedQueryFetchJoinCustomIndex(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); @@ -931,7 +931,7 @@ public function testEntityQueryCustomResultSetOrder(): void * * @dataProvider provideDataForUserEntityResult */ - public function testChainedJoinWithScalars($entityKey): void + public function testChainedJoinWithScalars(int|string $entityKey): void { $rsm = new ResultSetMapping(); @@ -1123,7 +1123,7 @@ public function testSkipUnknownColumns(): void * @group DDC-1358 * @dataProvider provideDataForUserEntityResult */ - public function testMissingIdForRootEntity($userEntityKey): void + public function testMissingIdForRootEntity(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); @@ -1182,7 +1182,7 @@ public function testMissingIdForRootEntity($userEntityKey): void * @group DDC-1385 * @dataProvider provideDataForUserEntityResult */ - public function testIndexByAndMixedResult($userEntityKey): void + public function testIndexByAndMixedResult(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php index d5e9ad7d96f..2e2dcf3eb10 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php @@ -25,7 +25,7 @@ class CustomHydrator extends AbstractHydrator /** * {@inheritDoc} */ - protected function hydrateAllData() + protected function hydrateAllData(): array { return $this->_stmt->fetchAllAssociative(); } diff --git a/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php b/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php index 0b3de7a1fe2..d711fbe2442 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php @@ -9,8 +9,7 @@ class HydrationTestCase extends OrmTestCase { - /** @var EntityManagerInterface */ - protected $entityManager; + protected EntityManagerInterface $entityManager; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php index 7ac96c37efd..61cfe8d1ba6 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Hydration; -use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMappingBuilder; @@ -21,11 +21,8 @@ */ class ResultSetMappingTest extends OrmTestCase { - /** @var ResultSetMapping */ - private $_rsm; - - /** @var EntityManager */ - private $entityManager; + private ResultSetMapping $_rsm; + private EntityManagerInterface $entityManager; protected function setUp(): void { From 4b1a419883a0d3d923ec79183d5458dc90e9ab8e Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 12 Jan 2022 14:29:07 +0100 Subject: [PATCH 029/475] Remove Configuration::ensureProductionSettings() (#9358) --- UPGRADE.md | 15 +- .../Exception/MetadataCacheNotConfigured.php | 13 -- .../MetadataCacheUsesNonPersistentCache.php | 19 --- .../Exception/QueryCacheNotConfigured.php | 13 -- .../QueryCacheUsesNonPersistentCache.php | 19 --- lib/Doctrine/ORM/Configuration.php | 52 ------- .../ProxyClassesAlwaysRegenerating.php | 15 -- phpstan-baseline.neon | 5 - psalm-baseline.xml | 5 +- psalm.xml | 1 - .../Doctrine/Tests/ORM/ConfigurationTest.php | 133 +----------------- 11 files changed, 12 insertions(+), 278 deletions(-) delete mode 100644 lib/Doctrine/ORM/Cache/Exception/MetadataCacheNotConfigured.php delete mode 100644 lib/Doctrine/ORM/Cache/Exception/MetadataCacheUsesNonPersistentCache.php delete mode 100644 lib/Doctrine/ORM/Cache/Exception/QueryCacheNotConfigured.php delete mode 100644 lib/Doctrine/ORM/Cache/Exception/QueryCacheUsesNonPersistentCache.php delete mode 100644 lib/Doctrine/ORM/Exception/ProxyClassesAlwaysRegenerating.php diff --git a/UPGRADE.md b/UPGRADE.md index c1e03c88935..0d948ac2056 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade to 3.0 +## BC BREAK: Remove cache settings inspection + +Doctrine does not provide its own cache implementation anymore and relies on +the PSR-6 standard instead. As a consequence, we cannot determine anymore +whether a given cache adapter is suitable for a production environment. +Because of that, functionality that aims to do so has been removed: + +* `Configuration::ensureProductionSettings()` +* the `orm:ensure-production-settings` console command + ## BC BREAK: PSR-6-based second level cache The second level cache has been reworked to consume a PSR-6 cache. Using a @@ -46,11 +56,6 @@ _before_ upgrading to 3.0: php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml ``` -## BC BREAK: Remove the `orm:ensure-production-settings` console command - -The `orm:ensure-production-settings` console command and its implementation -`Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand` have been removed. - ## BC BREAK: Remove code generators and related console commands These console commands have been removed: diff --git a/lib/Doctrine/ORM/Cache/Exception/MetadataCacheNotConfigured.php b/lib/Doctrine/ORM/Cache/Exception/MetadataCacheNotConfigured.php deleted file mode 100644 index 724c2e457b0..00000000000 --- a/lib/Doctrine/ORM/Cache/Exception/MetadataCacheNotConfigured.php +++ /dev/null @@ -1,13 +0,0 @@ -_attributes['namedNativeQueries'][$name]; } - /** - * Ensures that this Configuration instance contains settings that are - * suitable for a production environment. - * - * @deprecated - * - * @return void - * - * @throws ProxyClassesAlwaysRegenerating - * @throws CacheException If a configuration setting has a value that is not - * suitable for a production environment. - */ - public function ensureProductionSettings() - { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9074', - '%s is deprecated', - __METHOD__ - ); - - $queryCacheImpl = $this->getQueryCacheImpl(); - - if (! $queryCacheImpl) { - throw QueryCacheNotConfigured::create(); - } - - if ($queryCacheImpl instanceof ArrayCache) { - throw QueryCacheUsesNonPersistentCache::fromDriver($queryCacheImpl); - } - - if ($this->getAutoGenerateProxyClasses()) { - throw ProxyClassesAlwaysRegenerating::create(); - } - - if (! $this->getMetadataCache()) { - throw MetadataCacheNotConfigured::create(); - } - - $metadataCacheImpl = $this->getMetadataCacheImpl(); - - if ($metadataCacheImpl instanceof ArrayCache) { - throw MetadataCacheUsesNonPersistentCache::fromDriver($metadataCacheImpl); - } - } - /** * Registers a custom DQL function that produces a string value. * Such a function can then be used in any DQL statement in any place where string diff --git a/lib/Doctrine/ORM/Exception/ProxyClassesAlwaysRegenerating.php b/lib/Doctrine/ORM/Exception/ProxyClassesAlwaysRegenerating.php deleted file mode 100644 index 2829bdab01d..00000000000 --- a/lib/Doctrine/ORM/Exception/ProxyClassesAlwaysRegenerating.php +++ /dev/null @@ -1,15 +0,0 @@ -new CachedReader($reader, new ArrayCache()) new SimpleAnnotationReader() - + AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php') - getAutoGenerateProxyClasses - getMetadataCacheImpl - getQueryCacheImpl (bool) $flag diff --git a/psalm.xml b/psalm.xml index cdab6309897..fe78690d5f3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -28,7 +28,6 @@ - diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index ad0099c28b6..82dbe332f44 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -4,20 +4,14 @@ namespace Doctrine\Tests\ORM; -use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\Proxy\AbstractProxyFactory; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Cache\CacheConfiguration; -use Doctrine\ORM\Cache\Exception\MetadataCacheNotConfigured; -use Doctrine\ORM\Cache\Exception\MetadataCacheUsesNonPersistentCache; -use Doctrine\ORM\Cache\Exception\QueryCacheNotConfigured; -use Doctrine\ORM\Cache\Exception\QueryCacheUsesNonPersistentCache; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Exception\ORMException; -use Doctrine\ORM\Exception\ProxyClassesAlwaysRegenerating; use Doctrine\ORM\Mapping as AnnotationNamespace; use Doctrine\ORM\Mapping\EntityListenerResolver; use Doctrine\ORM\Mapping\NamingStrategy; @@ -29,9 +23,6 @@ use Doctrine\Tests\Models\DDC753\DDC753CustomRepository; use Psr\Cache\CacheItemPoolInterface; use ReflectionClass; -use Symfony\Component\Cache\Adapter\ArrayAdapter; - -use function class_exists; /** * Tests for the Configuration object @@ -40,8 +31,7 @@ class ConfigurationTest extends DoctrineTestCase { use VerifyDeprecations; - /** @var Configuration */ - private $configuration; + private Configuration $configuration; protected function setUp(): void { @@ -201,127 +191,6 @@ public function testAddGetNamedNativeQuery(): void $this->configuration->getNamedNativeQuery('NonExistingQuery'); } - /** - * Configures $this->configuration to use production settings. - * - * @param string|null $skipCache Do not configure a cache of this type, either "query" or "metadata". - */ - protected function setProductionSettings(?string $skipCache = null): void - { - $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_NEVER); - - $cache = $this->createMock(Cache::class); - - if ($skipCache !== 'query') { - $this->configuration->setQueryCacheImpl($cache); - } - - if ($skipCache !== 'metadata') { - $this->configuration->setMetadataCacheImpl($cache); - } - } - - public function testEnsureProductionSettings(): void - { - $this->setProductionSettings(); - $this->configuration->ensureProductionSettings(); - - $this->addToAssertionCount(1); - } - - public function testEnsureProductionSettingsWithNewMetadataCache(): void - { - $this->setProductionSettings('metadata'); - $this->configuration->setMetadataCache(new ArrayAdapter()); - - $this->configuration->ensureProductionSettings(); - - $this->addToAssertionCount(1); - } - - public function testEnsureProductionSettingsMissingQueryCache(): void - { - $this->setProductionSettings('query'); - - $this->expectException(QueryCacheNotConfigured::class); - $this->expectExceptionMessage('Query Cache is not configured.'); - - $this->configuration->ensureProductionSettings(); - } - - public function testEnsureProductionSettingsMissingMetadataCache(): void - { - $this->setProductionSettings('metadata'); - - $this->expectException(MetadataCacheNotConfigured::class); - $this->expectExceptionMessage('Metadata Cache is not configured.'); - - $this->configuration->ensureProductionSettings(); - } - - public function testEnsureProductionSettingsQueryArrayCache(): void - { - if (! class_exists(ArrayCache::class)) { - self::markTestSkipped('Test only applies with doctrine/cache 1.x'); - } - - $this->setProductionSettings(); - $this->configuration->setQueryCacheImpl(new ArrayCache()); - - $this->expectException(QueryCacheUsesNonPersistentCache::class); - $this->expectExceptionMessage('Query Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.'); - - $this->configuration->ensureProductionSettings(); - } - - public function testEnsureProductionSettingsLegacyMetadataArrayCache(): void - { - if (! class_exists(ArrayCache::class)) { - self::markTestSkipped('Test only applies with doctrine/cache 1.x'); - } - - $this->setProductionSettings(); - $this->configuration->setMetadataCacheImpl(new ArrayCache()); - - $this->expectException(MetadataCacheUsesNonPersistentCache::class); - $this->expectExceptionMessage('Metadata Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.'); - - $this->configuration->ensureProductionSettings(); - } - - public function testEnsureProductionSettingsAutoGenerateProxyClassesAlways(): void - { - $this->setProductionSettings(); - $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_ALWAYS); - - $this->expectException(ProxyClassesAlwaysRegenerating::class); - $this->expectExceptionMessage('Proxy Classes are always regenerating.'); - - $this->configuration->ensureProductionSettings(); - } - - public function testEnsureProductionSettingsAutoGenerateProxyClassesFileNotExists(): void - { - $this->setProductionSettings(); - $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS); - - $this->expectException(ORMException::class); - $this->expectExceptionMessage('Proxy Classes are always regenerating.'); - - $this->configuration->ensureProductionSettings(); - } - - public function testEnsureProductionSettingsAutoGenerateProxyClassesEval(): void - { - $this->setProductionSettings(); - $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_EVAL); - - $this->expectException(ORMException::class); - $this->expectExceptionMessage('Proxy Classes are always regenerating.'); - - $this->configuration->ensureProductionSettings(); - } - public function testAddGetCustomStringFunction(): void { $this->configuration->addCustomStringFunction('FunctionName', self::class); From a21843f974e92a061fc38de4bc8d72a8f97b474d Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 17 Jan 2022 23:19:58 +0100 Subject: [PATCH 030/475] Remove AbstractIdGenerator::generate() (#9367) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and add native types to ID generators --- UPGRADE.md | 6 ++ lib/Doctrine/ORM/Id/AbstractIdGenerator.php | 69 +--------------- lib/Doctrine/ORM/Id/AssignedGenerator.php | 2 +- .../ORM/Id/BigIntegerIdentityGenerator.php | 23 ++---- lib/Doctrine/ORM/Id/IdentityGenerator.php | 23 ++---- lib/Doctrine/ORM/Id/SequenceGenerator.php | 80 +++++-------------- psalm.xml | 2 - .../ORM/Functional/Ticket/DDC2415Test.php | 2 +- .../ORM/Functional/Ticket/GH5804Test.php | 5 +- .../Tests/ORM/Id/AbstractIdGeneratorTest.php | 72 ----------------- .../ORM/Mapping/ClassMetadataFactoryTest.php | 5 +- 11 files changed, 44 insertions(+), 245 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Id/AbstractIdGeneratorTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 0d948ac2056..0beb2f04cf8 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 3.0 +## BC BREAK: Rename `AbstractIdGenerator::generate()` to `generateId()` + +* Implementations of `AbstractIdGenerator` have to implement the method + `generateId()`. +* The method `generate()` has been removed from `AbstractIdGenerator`. + ## BC BREAK: Remove cache settings inspection Doctrine does not provide its own cache implementation anymore and relies on diff --git a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php b/lib/Doctrine/ORM/Id/AbstractIdGenerator.php index 2da3766f388..054fc21fd48 100644 --- a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php +++ b/lib/Doctrine/ORM/Id/AbstractIdGenerator.php @@ -4,77 +4,14 @@ namespace Doctrine\ORM\Id; -use Doctrine\Deprecations\Deprecation; -use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; -use InvalidArgumentException; -use LogicException; - -use function get_debug_type; -use function sprintf; abstract class AbstractIdGenerator { - /** @var bool */ - private $alreadyDelegatedToGenerateId = false; - /** * Generates an identifier for an entity. - * - * @deprecated Call {@see generateId()} instead. - * - * @param object|null $entity - * - * @return mixed */ - public function generate(EntityManager $em, $entity) - { - if ($this->alreadyDelegatedToGenerateId) { - throw new LogicException(sprintf( - 'Endless recursion detected in %s. Please implement generateId() without calling the parent implementation.', - get_debug_type($this) - )); - } - - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9325', - '%s::generate() is deprecated, call generateId() instead.', - get_debug_type($this) - ); - - $this->alreadyDelegatedToGenerateId = true; - - try { - return $this->generateId($em, $entity); - } finally { - $this->alreadyDelegatedToGenerateId = false; - } - } - - /** - * Generates an identifier for an entity. - * - * @param object|null $entity - * - * @return mixed - */ - public function generateId(EntityManagerInterface $em, $entity) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9325', - 'Not implementing %s in %s is deprecated.', - __FUNCTION__, - get_debug_type($this) - ); - - if (! $em instanceof EntityManager) { - throw new InvalidArgumentException('Unsupported entity manager implementation.'); - } - - return $this->generate($em, $entity); - } + abstract public function generateId(EntityManagerInterface $em, ?object $entity): mixed; /** * Gets whether this generator is a post-insert generator which means that @@ -83,10 +20,8 @@ public function generateId(EntityManagerInterface $em, $entity) * * By default, this method returns FALSE. Generators that have this requirement * must override this method and return TRUE. - * - * @return bool */ - public function isPostInsertGenerator() + public function isPostInsertGenerator(): bool { return false; } diff --git a/lib/Doctrine/ORM/Id/AssignedGenerator.php b/lib/Doctrine/ORM/Id/AssignedGenerator.php index a06cf6031ca..24d610bd118 100644 --- a/lib/Doctrine/ORM/Id/AssignedGenerator.php +++ b/lib/Doctrine/ORM/Id/AssignedGenerator.php @@ -21,7 +21,7 @@ class AssignedGenerator extends AbstractIdGenerator * * @throws EntityMissingAssignedId */ - public function generateId(EntityManagerInterface $em, $entity) + public function generateId(EntityManagerInterface $em, ?object $entity): array { $class = $em->getClassMetadata(get_class($entity)); $idFields = $class->getIdentifierFieldNames(); diff --git a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php b/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php index 4c5408ecc9c..56af5b4dab4 100644 --- a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php @@ -13,35 +13,22 @@ */ class BigIntegerIdentityGenerator extends AbstractIdGenerator { - /** - * The name of the sequence to pass to lastInsertId(), if any. - * - * @var string|null - */ - private $sequenceName; - /** * @param string|null $sequenceName The name of the sequence to pass to lastInsertId() * to obtain the last generated identifier within the current * database session/connection, if any. */ - public function __construct($sequenceName = null) - { - $this->sequenceName = $sequenceName; + public function __construct( + private ?string $sequenceName = null + ) { } - /** - * {@inheritDoc} - */ - public function generateId(EntityManagerInterface $em, $entity) + public function generateId(EntityManagerInterface $em, ?object $entity): string { return (string) $em->getConnection()->lastInsertId($this->sequenceName); } - /** - * {@inheritDoc} - */ - public function isPostInsertGenerator() + public function isPostInsertGenerator(): bool { return true; } diff --git a/lib/Doctrine/ORM/Id/IdentityGenerator.php b/lib/Doctrine/ORM/Id/IdentityGenerator.php index 1a003fc49ec..af55dda6bc1 100644 --- a/lib/Doctrine/ORM/Id/IdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/IdentityGenerator.php @@ -13,35 +13,22 @@ */ class IdentityGenerator extends AbstractIdGenerator { - /** - * The name of the sequence to pass to lastInsertId(), if any. - * - * @var string|null - */ - private $sequenceName; - /** * @param string|null $sequenceName The name of the sequence to pass to lastInsertId() * to obtain the last generated identifier within the current * database session/connection, if any. */ - public function __construct($sequenceName = null) - { - $this->sequenceName = $sequenceName; + public function __construct( + private ?string $sequenceName = null + ) { } - /** - * {@inheritDoc} - */ - public function generateId(EntityManagerInterface $em, $entity) + public function generateId(EntityManagerInterface $em, ?object $entity): int { return (int) $em->getConnection()->lastInsertId($this->sequenceName); } - /** - * {@inheritdoc} - */ - public function isPostInsertGenerator() + public function isPostInsertGenerator(): bool { return true; } diff --git a/lib/Doctrine/ORM/Id/SequenceGenerator.php b/lib/Doctrine/ORM/Id/SequenceGenerator.php index 4d009835860..5498e0f03f1 100644 --- a/lib/Doctrine/ORM/Id/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Id/SequenceGenerator.php @@ -16,25 +16,8 @@ */ class SequenceGenerator extends AbstractIdGenerator implements Serializable { - /** - * The allocation size of the sequence. - * - * @var int - */ - private $_allocationSize; - - /** - * The name of the sequence. - * - * @var string - */ - private $_sequenceName; - - /** @var int */ - private $_nextValue = 0; - - /** @var int|null */ - private $_maxValue = null; + private int $nextValue = 0; + private ?int $maxValue = null; /** * Initializes a new sequence generator. @@ -42,59 +25,47 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable * @param string $sequenceName The name of the sequence. * @param int $allocationSize The allocation size of the sequence. */ - public function __construct($sequenceName, $allocationSize) - { - $this->_sequenceName = $sequenceName; - $this->_allocationSize = $allocationSize; + public function __construct( + private string $sequenceName, + private int $allocationSize + ) { } - /** - * {@inheritDoc} - */ - public function generateId(EntityManagerInterface $em, $entity) + public function generateId(EntityManagerInterface $em, ?object $entity): int { - if ($this->_maxValue === null || $this->_nextValue === $this->_maxValue) { + if ($this->maxValue === null || $this->nextValue === $this->maxValue) { // Allocate new values $connection = $em->getConnection(); - $sql = $connection->getDatabasePlatform()->getSequenceNextValSQL($this->_sequenceName); + $sql = $connection->getDatabasePlatform()->getSequenceNextValSQL($this->sequenceName); if ($connection instanceof PrimaryReadReplicaConnection) { $connection->ensureConnectedToPrimary(); } - $this->_nextValue = (int) $connection->executeQuery($sql)->fetchOne(); - $this->_maxValue = $this->_nextValue + $this->_allocationSize; + $this->nextValue = (int) $connection->executeQuery($sql)->fetchOne(); + $this->maxValue = $this->nextValue + $this->allocationSize; } - return $this->_nextValue++; + return $this->nextValue++; } /** * Gets the maximum value of the currently allocated bag of values. - * - * @return int|null */ - public function getCurrentMaxValue() + public function getCurrentMaxValue(): ?int { - return $this->_maxValue; + return $this->maxValue; } /** * Gets the next value that will be returned by generate(). - * - * @return int */ - public function getNextValue() + public function getNextValue(): int { - return $this->_nextValue; + return $this->nextValue; } - /** - * @return string - * - * @final - */ - public function serialize() + final public function serialize(): string { return serialize($this->__serialize()); } @@ -105,19 +76,12 @@ public function serialize() public function __serialize(): array { return [ - 'allocationSize' => $this->_allocationSize, - 'sequenceName' => $this->_sequenceName, + 'allocationSize' => $this->allocationSize, + 'sequenceName' => $this->sequenceName, ]; } - /** - * @param string $serialized - * - * @return void - * - * @final - */ - public function unserialize($serialized) + final public function unserialize(string $serialized): void { $this->__unserialize(unserialize($serialized)); } @@ -127,7 +91,7 @@ public function unserialize($serialized) */ public function __unserialize(array $data): void { - $this->_sequenceName = $data['sequenceName']; - $this->_allocationSize = $data['allocationSize']; + $this->sequenceName = $data['sequenceName']; + $this->allocationSize = $data['allocationSize']; } } diff --git a/psalm.xml b/psalm.xml index 8c777ede456..7be14f27fa7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -27,8 +27,6 @@ - - diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php index e68dd582170..cb42eb82daa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php @@ -108,7 +108,7 @@ public static function loadMetadata(ClassMetadataInfo $metadata): void class DDC2415Generator extends AbstractIdGenerator { - public function generateId(EntityManagerInterface $em, $entity): string + public function generateId(EntityManagerInterface $em, ?object $entity): string { return md5($entity->getName()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index 3b4b1df8d9a..568d10ee4cf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -51,10 +51,7 @@ public function testTextColumnSaveAndRetrieve2(): void final class GH5804Generator extends AbstractIdGenerator { - /** - * {@inheritdoc} - */ - public function generateId(EntityManagerInterface $em, $entity) + public function generateId(EntityManagerInterface $em, ?object $entity): string { return 'test5804'; } diff --git a/tests/Doctrine/Tests/ORM/Id/AbstractIdGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AbstractIdGeneratorTest.php deleted file mode 100644 index 974a6047b63..00000000000 --- a/tests/Doctrine/Tests/ORM/Id/AbstractIdGeneratorTest.php +++ /dev/null @@ -1,72 +0,0 @@ -receivedEm = $em; - $this->receivedEntity = $entity; - - return '4711'; - } - }; - - $em = $this->createMock(EntityManager::class); - $entity = new stdClass(); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9325'); - - self::assertSame('4711', $generator->generateId($em, $entity)); - self::assertSame($em, $generator->receivedEm); - self::assertSame($entity, $generator->receivedEntity); - } - - public function testNoEndlessRecursionOnGenerateId(): void - { - $generator = new class extends AbstractIdGenerator - { - }; - - $this->expectException(LogicException::class); - $this->expectExceptionMessage('Endless recursion detected in Doctrine\ORM\Id\AbstractIdGenerator@anonymous. Please implement generateId() without calling the parent implementation.'); - - $generator->generateId($this->createMock(EntityManager::class), (object) []); - } - - public function testNoEndlessRecursionOnGenerate(): void - { - $generator = new class extends AbstractIdGenerator - { - }; - - $this->expectException(LogicException::class); - $this->expectExceptionMessage('Endless recursion detected in Doctrine\ORM\Id\AbstractIdGenerator@anonymous. Please implement generateId() without calling the parent implementation.'); - - $generator->generate($this->createMock(EntityManager::class), (object) []); - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index a1517f78f9d..25185dcfdea 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -588,10 +588,7 @@ class TestEntity1 class CustomIdGenerator extends AbstractIdGenerator { - /** - * {@inheritdoc} - */ - public function generateId(EntityManagerInterface $em, $entity): string + public function generateId(EntityManagerInterface $em, ?object $entity): string { return 'foo'; } From 9d3ad08a82104b136fd192a90775c3823bd18967 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 18 Jan 2022 10:39:40 +0100 Subject: [PATCH 031/475] Stabilize DBAL dependency (#9395) --- .github/workflows/continuous-integration.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e6e44dcb3e1..87413b8655d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -25,7 +25,7 @@ jobs: - "default" include: - php-version: "8.1" - dbal-version: "3.2@dev" + dbal-version: "3.4@dev" steps: - name: "Checkout" diff --git a/composer.json b/composer.json index 62a0fb1b7da..dd6a1f56776 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "doctrine/cache": "^1.12.1 || ^2.1.1", "doctrine/collections": "^1.5", "doctrine/common": "^3.0.3", - "doctrine/dbal": "^3.3@dev", + "doctrine/dbal": "^3.3", "doctrine/deprecations": "^0.5.3", "doctrine/event-manager": "^1.1", "doctrine/inflector": "^1.4 || ^2.0", From cb3f554e383db2356177e0e95f6ffda442f922dd Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 21 Dec 2021 12:40:22 -0800 Subject: [PATCH 032/475] Make test types compatible with Doctrine DBAL 4.0.x-dev --- .../Doctrine/Tests/DbalTypes/CustomIdObject.php | 5 ++--- .../Tests/DbalTypes/CustomIdObjectType.php | 13 +++++-------- .../Tests/DbalTypes/NegativeToPositiveType.php | 13 +++++-------- tests/Doctrine/Tests/DbalTypes/Rot13Type.php | 16 ++++++---------- .../Tests/DbalTypes/UpperCaseStringType.php | 9 +++------ .../Tests/ORM/Functional/GH5988Test.php | 13 +++++-------- .../Tests/ORM/Functional/Ticket/DDC1998Test.php | 9 +++------ .../Tests/ORM/Functional/Ticket/DDC2012Test.php | 17 ++++++++--------- .../Tests/ORM/Functional/Ticket/DDC2224Test.php | 6 +++--- .../Tests/ORM/Functional/Ticket/DDC2494Test.php | 13 +++++-------- .../Tests/ORM/Functional/Ticket/DDC2579Test.php | 9 +++------ .../Tests/ORM/Functional/Ticket/DDC2984Test.php | 4 ++-- .../Tests/ORM/Functional/Ticket/DDC3192Test.php | 13 +++++-------- .../Tests/ORM/Functional/Ticket/DDC3634Test.php | 2 +- .../Tests/ORM/Functional/Ticket/DDC3785Test.php | 13 +++++-------- .../Tests/ORM/Functional/Ticket/DDC5684Test.php | 16 +++++----------- .../Tests/ORM/Functional/Ticket/GH5804Test.php | 11 ++++------- .../Tests/ORM/Functional/Ticket/GH5887Test.php | 9 +++------ .../Tests/ORM/Functional/Ticket/GH6141Test.php | 9 +++------ .../Tests/ORM/Functional/Ticket/GH7820Test.php | 4 ++-- .../Tests/ORM/Functional/Ticket/GH8061Test.php | 4 ++-- 21 files changed, 80 insertions(+), 128 deletions(-) diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php b/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php index 3a24a512059..0c36e57eb6e 100644 --- a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php +++ b/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php @@ -6,12 +6,11 @@ class CustomIdObject { - /** @var string */ - public $id; + public string $id; public function __construct(string $id) { - $this->id = (string) $id; + $this->id = $id; } public function __toString(): string diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php b/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php index 538cbb634a1..89eb1c2efce 100644 --- a/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php +++ b/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php @@ -14,7 +14,7 @@ class CustomIdObjectType extends Type /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): string { return $value->id; } @@ -22,7 +22,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): CustomIdObject { return new CustomIdObject($value); } @@ -30,15 +30,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + return $platform->getVarcharTypeDeclarationSQL($column); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } diff --git a/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php b/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php index 64cf5ba439e..1fe03e4089e 100644 --- a/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php +++ b/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php @@ -11,10 +11,7 @@ class NegativeToPositiveType extends Type { public const NAME = 'negative_to_positive'; - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } @@ -22,9 +19,9 @@ public function getName() /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration); + return $platform->getIntegerTypeDeclarationSQL($column); } /** @@ -38,7 +35,7 @@ public function canRequireSQLConversion() /** * {@inheritdoc} */ - public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) + public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): string { return 'ABS(' . $sqlExpr . ')'; } @@ -46,7 +43,7 @@ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValueSQL($sqlExpr, $platform) + public function convertToPHPValueSQL($sqlExpr, $platform): string { return '-(' . $sqlExpr . ')'; } diff --git a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php index 21d46f6f9e1..38c54883735 100644 --- a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php +++ b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php @@ -19,10 +19,8 @@ class Rot13Type extends Type * * @param string|null $value * @param AbstractPlatform $platform - * - * @return string|null */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if ($value === null) { return null; @@ -36,10 +34,8 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) * * @param string|null $value * @param AbstractPlatform $platform - * - * @return string|null */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?string { if ($value === null) { return null; @@ -51,14 +47,14 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritdoc} * - * @param array $fieldDeclaration + * @param array $column * @param AbstractPlatform $platform * * @return string */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + return $platform->getVarcharTypeDeclarationSQL($column); } /** @@ -78,7 +74,7 @@ public function getDefaultLength(AbstractPlatform $platform) * * @return string */ - public function getName() + public function getName(): string { return 'rot13'; } diff --git a/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php b/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php index 23259dba62a..bb7979b6957 100644 --- a/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php +++ b/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php @@ -11,10 +11,7 @@ class UpperCaseStringType extends StringType { public const NAME = 'upper_case_string'; - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } @@ -30,7 +27,7 @@ public function canRequireSQLConversion() /** * {@inheritdoc} */ - public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) + public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): string { return 'UPPER(' . $sqlExpr . ')'; } @@ -38,7 +35,7 @@ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValueSQL($sqlExpr, $platform) + public function convertToPHPValueSQL($sqlExpr, $platform): string { return 'LOWER(' . $sqlExpr . ')'; } diff --git a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php index ba5f7b3a863..6b49e39b9d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php @@ -60,7 +60,7 @@ class GH5988CustomIdObjectHashType extends DBALType /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): string { return $value->id . '_test'; } @@ -68,7 +68,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): CustomIdObject { return new CustomIdObject(str_replace('_test', '', $value)); } @@ -76,15 +76,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + return $platform->getVarcharTypeDeclarationSQL($column); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::class; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index 9e1fda26b19..215701c9bfb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -77,7 +77,7 @@ class DDC1998Type extends StringType /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): string { return (string) $value; } @@ -85,15 +85,12 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritDoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DDC1998Id { return new DDC1998Id($value); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index 668e5e3d66a..3e6b609ea24 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -129,15 +129,15 @@ class DDC2012TsVectorType extends Type /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + return $platform->getVarcharTypeDeclarationSQL($column); } /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed { if (is_array($value)) { $value = implode(' ', $value); @@ -153,8 +153,10 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritdoc} + * + * @return list */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): array { self::$calls[__FUNCTION__][] = [ 'value' => $value, @@ -167,7 +169,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) + public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): string { self::$calls[__FUNCTION__][] = [ 'sqlExpr' => $sqlExpr, @@ -188,10 +190,7 @@ public function canRequireSQLConversion() return true; } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::MYTYPE; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index 999681d0672..40d0a77c1f6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -53,9 +53,9 @@ class DDC2224Type extends Type /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + return $platform->getVarcharTypeDeclarationSQL($column); } public function getName(): string @@ -74,7 +74,7 @@ public function canRequireSQLConversion() /** * {@inheritdoc} */ - public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) + public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): string { return sprintf('FUNCTION(%s)', $sqlExpr); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index ecf0c9b4408..26cf7c38b94 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -177,15 +177,15 @@ class DDC2494TinyIntType extends Type /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getSmallIntTypeDeclarationSQL($fieldDeclaration); + return $platform->getSmallIntTypeDeclarationSQL($column); } /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): string { $return = (string) $value; @@ -201,7 +201,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): int { $return = (int) $value; @@ -214,10 +214,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) return $return; } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return 'ddc2494_tinyint'; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index 053680fbe86..a91b917064c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -149,7 +149,7 @@ class DDC2579Type extends StringType /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): string { return (string) $value; } @@ -157,15 +157,12 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritDoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DDC2579Id { return new DDC2579Id($value); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 855611b1f68..e4d7968c8de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -155,7 +155,7 @@ public function getName(): string /** * {@inheritDoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): ?DDC2984DomainUserId { return ! empty($value) ? new DDC2984DomainUserId($value) @@ -165,7 +165,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritDoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed { if (empty($value)) { return null; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index d8f8a30efd8..bf9fdd97420 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -146,15 +146,15 @@ class DDC3192CurrencyCode extends Type /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getSmallIntTypeDeclarationSQL($fieldDeclaration); + return $platform->getSmallIntTypeDeclarationSQL($column); } /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): int { return self::$map[$value]; } @@ -162,15 +162,12 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): mixed { return array_search((int) $value, self::$map, true); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return 'ddc3192_currency_code'; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index 2ef3f5fee52..d8ae97a63fa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -146,7 +146,7 @@ public function __construct(DriverConnection $wrappedConnection, LastInsertIdMoc /** * {@inheritdoc} */ - public function lastInsertId($name = null) + public function lastInsertId($name = null): int|string { return $this->idMocker->mockedId ?? parent::lastInsertId($name); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php index 851c3771627..6d581083f70 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php @@ -177,15 +177,15 @@ class DDC3785AssetIdType extends Type /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getGuidTypeDeclarationSQL($fieldDeclaration); + return $platform->getGuidTypeDeclarationSQL($column); } /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): string { return (string) $value; } @@ -193,15 +193,12 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DDC3785AssetId { return new DDC3785AssetId($value); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return 'ddc3785_asset_id'; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index eb8d789b424..cbbe5aff498 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -66,12 +66,12 @@ public function testFetchObjectWithAutoIncrementedCustomType(): void } } -class DDC5684ObjectIdType extends DBALTypes\IntegerType +class DDC5684ObjectIdType extends DBALTypes\BigIntType { /** * {@inheritDoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): DDC5684ObjectId { return new DDC5684ObjectId($value); } @@ -79,23 +79,17 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritDoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed { return $value->value; } - /** - * {@inheritDoc} - */ - public function getName() + public function getName(): string { return self::class; } - /** - * {@inheritDoc} - */ - public function requiresSQLCommentHint(AbstractPlatform $platform) + public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index 568d10ee4cf..b59cace93b4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -61,10 +61,7 @@ final class GH5804Type extends Type { public const NAME = 'GH5804Type'; - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } @@ -72,15 +69,15 @@ public function getName() /** * {@inheritdoc} */ - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + return $platform->getVarcharTypeDeclarationSQL($column); } /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { if (empty($value)) { return null; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index 845f35ef0bb..62162fe5d27 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -185,7 +185,7 @@ class GH5887CustomIdObjectType extends StringType /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed { return $value->getId(); } @@ -193,15 +193,12 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): GH5887CustomIdObject { return new GH5887CustomIdObject((int) $value); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php index e4a4f2e5c58..28e5486c6a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php @@ -85,7 +85,7 @@ class GH6141PeopleType extends StringType /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): string { if (! $value instanceof GH6141People) { $value = GH6141People::get($value); @@ -97,15 +97,12 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): GH6141People { return GH6141People::get($value); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php index 60fd13befde..386e7b14b0c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php @@ -173,7 +173,7 @@ final class GH7820LineTextType extends StringType /** * {@inheritDoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform) + public function convertToPHPValue($value, AbstractPlatform $platform): mixed { $text = parent::convertToPHPValue($value, $platform); @@ -187,7 +187,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) /** * {@inheritDoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform) + public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed { if (! $value instanceof GH7820LineText) { return parent::convertToDatabaseValue($value, $platform); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php index 5e4bdaa402d..08fc943e0fb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php @@ -56,9 +56,9 @@ final class GH8061Entity final class GH8061Type extends Type { - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + return $platform->getVarcharTypeDeclarationSQL($column); } public function getName(): string From 6f150a343bb80e5e7e44fe2a409d46f5551a75c7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 19 Jan 2022 23:41:26 +0100 Subject: [PATCH 033/475] Remove MultiGetRegion and add native types to Region implementations (#9403) --- UPGRADE.md | 4 ++ lib/Doctrine/ORM/Cache/ConcurrentRegion.php | 6 +- lib/Doctrine/ORM/Cache/MultiGetRegion.php | 25 ------- lib/Doctrine/ORM/Cache/Region.php | 34 +++++----- .../ORM/Cache/Region/DefaultRegion.php | 38 ++--------- .../ORM/Cache/Region/FileLockRegion.php | 65 +++++-------------- .../ORM/Cache/Region/UpdateTimestampCache.php | 5 +- lib/Doctrine/ORM/Cache/TimestampRegion.php | 2 +- psalm-baseline.xml | 10 --- psalm.xml | 5 -- .../Doctrine/Tests/Mocks/CacheRegionMock.php | 7 +- .../Tests/Mocks/ConcurrentRegionMock.php | 15 ++--- ...ReadWriteCachedCollectionPersisterTest.php | 22 +++---- .../ReadWriteCachedEntityPersisterTest.php | 18 ++--- 14 files changed, 76 insertions(+), 180 deletions(-) delete mode 100644 lib/Doctrine/ORM/Cache/MultiGetRegion.php diff --git a/UPGRADE.md b/UPGRADE.md index abf46de4c9b..db9f5ce8058 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Remove `Doctrine\ORM\Cache\MultiGetRegion` + +The interface has been merged into `Doctrine\ORM\Cache\Region`. + ## BC BREAK: Rename `AbstractIdGenerator::generate()` to `generateId()` * Implementations of `AbstractIdGenerator` have to implement the method diff --git a/lib/Doctrine/ORM/Cache/ConcurrentRegion.php b/lib/Doctrine/ORM/Cache/ConcurrentRegion.php index 10935795296..3ea33ba45e6 100644 --- a/lib/Doctrine/ORM/Cache/ConcurrentRegion.php +++ b/lib/Doctrine/ORM/Cache/ConcurrentRegion.php @@ -22,7 +22,7 @@ interface ConcurrentRegion extends Region * * @throws LockException Indicates a problem accessing the region. */ - public function lock(CacheKey $key); + public function lock(CacheKey $key): ?Lock; /** * Attempts to read unlock the mapping for the given key. @@ -30,9 +30,7 @@ public function lock(CacheKey $key); * @param CacheKey $key The key of the item to unlock. * @param Lock $lock The lock previously obtained from {@link readLock} * - * @return bool - * * @throws LockException Indicates a problem accessing the region. */ - public function unlock(CacheKey $key, Lock $lock); + public function unlock(CacheKey $key, Lock $lock): bool; } diff --git a/lib/Doctrine/ORM/Cache/MultiGetRegion.php b/lib/Doctrine/ORM/Cache/MultiGetRegion.php deleted file mode 100644 index ded16f7adeb..00000000000 --- a/lib/Doctrine/ORM/Cache/MultiGetRegion.php +++ /dev/null @@ -1,25 +0,0 @@ -lifetime = $lifetime; } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return $this->name; } - /** - * {@inheritdoc} - */ - public function contains(CacheKey $key) + public function contains(CacheKey $key): bool { return $this->cacheItemPool->hasItem($this->getCacheEntryKey($key)); } - /** - * {@inheritdoc} - */ - public function get(CacheKey $key) + public function get(CacheKey $key): ?CacheEntry { $item = $this->cacheItemPool->getItem($this->getCacheEntryKey($key)); $entry = $item->isHit() ? $item->get() : null; @@ -71,7 +62,7 @@ public function get(CacheKey $key) /** * {@inheritdoc} */ - public function getMultiple(CollectionCacheEntry $collection) + public function getMultiple(CollectionCacheEntry $collection): ?array { $keys = array_map( Closure::fromCallable([$this, 'getCacheEntryKey']), @@ -100,12 +91,7 @@ public function getMultiple(CollectionCacheEntry $collection) return $result; } - /** - * {@inheritdoc} - * - * @return bool - */ - public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null) + public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null): bool { $item = $this->cacheItemPool ->getItem($this->getCacheEntryKey($key)) @@ -118,22 +104,12 @@ public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null) return $this->cacheItemPool->save($item); } - /** - * {@inheritdoc} - * - * @return bool - */ - public function evict(CacheKey $key) + public function evict(CacheKey $key): bool { return $this->cacheItemPool->deleteItem($this->getCacheEntryKey($key)); } - /** - * {@inheritdoc} - * - * @return bool - */ - public function evictAll() + public function evictAll(): bool { return $this->cacheItemPool->clear(self::REGION_PREFIX . $this->name); } diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index 44e7eaaa2c9..3171e03d88a 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -37,23 +37,16 @@ class FileLockRegion implements ConcurrentRegion { public const LOCK_EXTENSION = 'lock'; - /** @var Region */ - private $region; - - /** @var string */ - private $directory; - - /** @psalm-var numeric-string */ - private $lockLifetime; - /** - * @param string $directory - * @param numeric-string $lockLifetime + * @param numeric-string|int $lockLifetime * * @throws InvalidArgumentException */ - public function __construct(Region $region, $directory, $lockLifetime) - { + public function __construct( + private Region $region, + private string $directory, + private string|int $lockLifetime + ) { if (! is_dir($directory) && ! @mkdir($directory, 0775, true)) { throw new InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $directory)); } @@ -61,10 +54,6 @@ public function __construct(Region $region, $directory, $lockLifetime) if (! is_writable($directory)) { throw new InvalidArgumentException(sprintf('The directory "%s" is not writable.', $directory)); } - - $this->region = $region; - $this->directory = $directory; - $this->lockLifetime = $lockLifetime; } private function isLocked(CacheKey $key, ?Lock $lock = null): bool @@ -119,18 +108,12 @@ private function getLockTime(string $filename) return @fileatime($filename); } - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return $this->region->getName(); } - /** - * {@inheritdoc} - */ - public function contains(CacheKey $key) + public function contains(CacheKey $key): bool { if ($this->isLocked($key)) { return false; @@ -139,10 +122,7 @@ public function contains(CacheKey $key) return $this->region->contains($key); } - /** - * {@inheritdoc} - */ - public function get(CacheKey $key) + public function get(CacheKey $key): ?CacheEntry { if ($this->isLocked($key)) { return null; @@ -154,7 +134,7 @@ public function get(CacheKey $key) /** * {@inheritdoc} */ - public function getMultiple(CollectionCacheEntry $collection) + public function getMultiple(CollectionCacheEntry $collection): ?array { if (array_filter(array_map([$this, 'isLocked'], $collection->identifiers))) { return null; @@ -163,10 +143,7 @@ public function getMultiple(CollectionCacheEntry $collection) return $this->region->getMultiple($collection); } - /** - * {@inheritdoc} - */ - public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null) + public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null): bool { if ($this->isLocked($key, $lock)) { return false; @@ -175,10 +152,7 @@ public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null) return $this->region->put($key, $entry); } - /** - * {@inheritdoc} - */ - public function evict(CacheKey $key) + public function evict(CacheKey $key): bool { if ($this->isLocked($key)) { @unlink($this->getLockFileName($key)); @@ -187,10 +161,7 @@ public function evict(CacheKey $key) return $this->region->evict($key); } - /** - * {@inheritdoc} - */ - public function evictAll() + public function evictAll(): bool { // The check below is necessary because on some platforms glob returns false // when nothing matched (even though no errors occurred) @@ -205,10 +176,7 @@ public function evictAll() return $this->region->evictAll(); } - /** - * {@inheritdoc} - */ - public function lock(CacheKey $key) + public function lock(CacheKey $key): ?Lock { if ($this->isLocked($key)) { return null; @@ -226,10 +194,7 @@ public function lock(CacheKey $key) return $lock; } - /** - * {@inheritdoc} - */ - public function unlock(CacheKey $key, Lock $lock) + public function unlock(CacheKey $key, Lock $lock): bool { if ($this->isLocked($key, $lock)) { return false; diff --git a/lib/Doctrine/ORM/Cache/Region/UpdateTimestampCache.php b/lib/Doctrine/ORM/Cache/Region/UpdateTimestampCache.php index 75e1ef5f115..aa75a90360d 100644 --- a/lib/Doctrine/ORM/Cache/Region/UpdateTimestampCache.php +++ b/lib/Doctrine/ORM/Cache/Region/UpdateTimestampCache.php @@ -13,10 +13,7 @@ */ class UpdateTimestampCache extends DefaultRegion implements TimestampRegion { - /** - * {@inheritdoc} - */ - public function update(CacheKey $key) + public function update(CacheKey $key): void { $this->put($key, new TimestampCacheEntry()); } diff --git a/lib/Doctrine/ORM/Cache/TimestampRegion.php b/lib/Doctrine/ORM/Cache/TimestampRegion.php index cb7a17580eb..3654b8eafe4 100644 --- a/lib/Doctrine/ORM/Cache/TimestampRegion.php +++ b/lib/Doctrine/ORM/Cache/TimestampRegion.php @@ -16,5 +16,5 @@ interface TimestampRegion extends Region * * @throws LockException Indicates a problem accessing the region. */ - public function update(CacheKey $key); + public function update(CacheKey $key): void; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e6c56469043..8712acbf3c5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -275,11 +275,6 @@ lock - - - update - - (int) $defaultLifetime @@ -305,11 +300,6 @@ $timestamp->time - - - update - - $className diff --git a/psalm.xml b/psalm.xml index baa5d7673a4..7be14f27fa7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -23,11 +23,6 @@ - - - - - diff --git a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php index ab0af22e54d..9bcad7eb09f 100644 --- a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php @@ -18,13 +18,12 @@ class CacheRegionMock implements Region { /** @var array>> */ - public $calls = []; + public array $calls = []; /** @var array */ - public $returns = []; + public array $returns = []; - /** @var string */ - public $name = 'mock'; + public string $name = 'mock'; /** * Queue a return value for a specific method invocation diff --git a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php b/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php index 2b22dd21d71..8c29aa64db7 100644 --- a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php @@ -23,20 +23,17 @@ class ConcurrentRegionMock implements ConcurrentRegion { /** @psalm-var array>> */ - public $calls = []; + public array $calls = []; /** @psalm-var array> */ - public $exceptions = []; + public array $exceptions = []; /** @psalm-var array */ - public $locks = []; + public array $locks = []; - /** @var Region */ - private $region; - - public function __construct(Region $region) - { - $this->region = $region; + public function __construct( + private Region $region + ) { } /** diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index b7a0c662696..9a46c9fbfd8 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -56,7 +56,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']); @@ -74,7 +74,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']); @@ -92,12 +92,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(true); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -116,7 +116,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') @@ -142,7 +142,7 @@ public function testTransactionRollBackDeleteShouldClearQueue(): 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') @@ -173,7 +173,7 @@ public function testTransactionRollBackUpdateShouldClearQueue(): 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') @@ -204,7 +204,7 @@ public function testTransactionRollCommitDeleteShouldClearQueue(): 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') @@ -235,7 +235,7 @@ public function testTransactionRollCommitUpdateShouldClearQueue(): 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') @@ -265,7 +265,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') @@ -290,7 +290,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/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 9a25b959002..11996e6855b 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -41,7 +41,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']); @@ -58,7 +58,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']); @@ -75,12 +75,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(true); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); @@ -98,7 +98,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') @@ -123,7 +123,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') @@ -154,7 +154,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') @@ -184,7 +184,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') @@ -208,7 +208,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') From be4f88c811ae174747f69021a1a8f8a8431d91d8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 19 Jan 2022 23:41:57 +0100 Subject: [PATCH 034/475] Add native types to EntityHydrator (#9396) --- .../ORM/Cache/DefaultEntityHydrator.php | 35 +++++-------------- lib/Doctrine/ORM/Cache/EntityHydrator.php | 8 ++--- .../ORM/Cache/DefaultEntityHydratorTest.php | 11 +++--- 3 files changed, 14 insertions(+), 40 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 384664fa5e6..209ffd15915 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -21,36 +21,20 @@ */ class DefaultEntityHydrator implements EntityHydrator { - /** @var EntityManagerInterface */ - private $em; - - /** @var UnitOfWork */ - private $uow; - - /** - * The IdentifierFlattener used for manipulating identifiers - * - * @var IdentifierFlattener - */ - private $identifierFlattener; + private UnitOfWork $uow; + private IdentifierFlattener $identifierFlattener; /** @var array */ - private static $hints = [Query::HINT_CACHE_ENABLED => true]; + private static array $hints = [Query::HINT_CACHE_ENABLED => true]; - /** - * @param EntityManagerInterface $em The entity manager. - */ - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; + public function __construct( + private EntityManagerInterface $em + ) { $this->uow = $em->getUnitOfWork(); $this->identifierFlattener = new IdentifierFlattener($em->getUnitOfWork(), $em->getMetadataFactory()); } - /** - * {@inheritdoc} - */ - public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, $entity) + public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, object $entity): EntityCacheEntry { $data = $this->uow->getOriginalEntityData($entity); $data = array_merge($data, $metadata->getIdentifierValues($entity)); // why update has no identifier values ? @@ -139,10 +123,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, $e return new EntityCacheEntry($metadata->name, $data); } - /** - * {@inheritdoc} - */ - public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, $entity = null) + public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, ?object $entity = null): ?object { $data = $entry->data; $hints = self::$hints; diff --git a/lib/Doctrine/ORM/Cache/EntityHydrator.php b/lib/Doctrine/ORM/Cache/EntityHydrator.php index 9b3286264d7..8a64f290e43 100644 --- a/lib/Doctrine/ORM/Cache/EntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/EntityHydrator.php @@ -15,18 +15,14 @@ interface EntityHydrator * @param ClassMetadata $metadata The entity metadata. * @param EntityCacheKey $key The entity cache key. * @param object $entity The entity. - * - * @return EntityCacheEntry */ - public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, $entity); + public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, object $entity): EntityCacheEntry; /** * @param ClassMetadata $metadata The entity metadata. * @param EntityCacheKey $key The entity cache key. * @param EntityCacheEntry $entry The entity cache entry. * @param object|null $entity The entity to load the cache into. If not specified, a new entity is created. - * - * @return object|null */ - public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, $entity = null); + public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, ?object $entity = null): ?object; } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php index 702874eab7e..07e9cdc9a31 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php @@ -10,8 +10,8 @@ use Doctrine\ORM\Cache\EntityCacheEntry; use Doctrine\ORM\Cache\EntityCacheKey; use Doctrine\ORM\Cache\EntityHydrator; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\UnitOfWork; +use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmTestCase; @@ -21,11 +21,8 @@ */ class DefaultEntityHydratorTest extends OrmTestCase { - /** @var EntityHydrator */ - private $structure; - - /** @var EntityManagerInterface */ - private $em; + private DefaultEntityHydrator $structure; + private EntityManagerMock $em; protected function setUp(): void { @@ -37,7 +34,7 @@ protected function setUp(): void public function testImplementsEntityEntryStructure(): void { - self::assertInstanceOf('\Doctrine\ORM\Cache\EntityHydrator', $this->structure); + self::assertInstanceOf(EntityHydrator::class, $this->structure); } public function testCreateEntity(): void From d4f5db4b8a102121adac9428c7e974a548695444 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 20 Jan 2022 10:27:21 +0100 Subject: [PATCH 035/475] Add native types to CacheLogger implementations (#9400) --- .../ORM/Cache/Logging/CacheLogger.php | 45 ++---- .../ORM/Cache/Logging/CacheLoggerChain.php | 67 ++------- .../Cache/Logging/StatisticsCacheLogger.php | 140 ++++++------------ psalm-baseline.xml | 39 ----- .../Tests/ORM/Cache/CacheLoggerChainTest.php | 5 +- .../ORM/Cache/StatisticsCacheLoggerTest.php | 3 +- 6 files changed, 71 insertions(+), 228 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php b/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php index 9284092a2cf..64c97c1b0d1 100644 --- a/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php +++ b/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php @@ -15,73 +15,46 @@ interface CacheLogger { /** * Log an entity put into second level cache. - * - * @param string $regionName The name of the cache region. - * @param EntityCacheKey $key The cache key of the entity. */ - public function entityCachePut($regionName, EntityCacheKey $key); + public function entityCachePut(string $regionName, EntityCacheKey $key): void; /** * Log an entity get from second level cache resulted in a hit. - * - * @param string $regionName The name of the cache region. - * @param EntityCacheKey $key The cache key of the entity. */ - public function entityCacheHit($regionName, EntityCacheKey $key); + public function entityCacheHit(string $regionName, EntityCacheKey $key): void; /** * Log an entity get from second level cache resulted in a miss. - * - * @param string $regionName The name of the cache region. - * @param EntityCacheKey $key The cache key of the entity. */ - public function entityCacheMiss($regionName, EntityCacheKey $key); + public function entityCacheMiss(string $regionName, EntityCacheKey $key): void; /** * Log an entity put into second level cache. - * - * @param string $regionName The name of the cache region. - * @param CollectionCacheKey $key The cache key of the collection. */ - public function collectionCachePut($regionName, CollectionCacheKey $key); + public function collectionCachePut(string $regionName, CollectionCacheKey $key): void; /** * Log an entity get from second level cache resulted in a hit. - * - * @param string $regionName The name of the cache region. - * @param CollectionCacheKey $key The cache key of the collection. */ - public function collectionCacheHit($regionName, CollectionCacheKey $key); + public function collectionCacheHit(string $regionName, CollectionCacheKey $key): void; /** * Log an entity get from second level cache resulted in a miss. - * - * @param string $regionName The name of the cache region. - * @param CollectionCacheKey $key The cache key of the collection. */ - public function collectionCacheMiss($regionName, CollectionCacheKey $key); + public function collectionCacheMiss(string $regionName, CollectionCacheKey $key): void; /** * Log a query put into the query cache. - * - * @param string $regionName The name of the cache region. - * @param QueryCacheKey $key The cache key of the query. */ - public function queryCachePut($regionName, QueryCacheKey $key); + public function queryCachePut(string $regionName, QueryCacheKey $key): void; /** * Log a query get from the query cache resulted in a hit. - * - * @param string $regionName The name of the cache region. - * @param QueryCacheKey $key The cache key of the query. */ - public function queryCacheHit($regionName, QueryCacheKey $key); + public function queryCacheHit(string $regionName, QueryCacheKey $key): void; /** * Log a query get from the query cache resulted in a miss. - * - * @param string $regionName The name of the cache region. - * @param QueryCacheKey $key The cache key of the query. */ - public function queryCacheMiss($regionName, QueryCacheKey $key); + public function queryCacheMiss(string $regionName, QueryCacheKey $key): void; } diff --git a/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php b/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php index 071640b4b39..8b6eef01f67 100644 --- a/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php +++ b/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php @@ -10,121 +10,84 @@ class CacheLoggerChain implements CacheLogger { - /** @var array */ - private $loggers = []; + /** @var array */ + private array $loggers = []; - /** - * @param string $name - * - * @return void - */ - public function setLogger($name, CacheLogger $logger) + public function setLogger(string $name, CacheLogger $logger): void { $this->loggers[$name] = $logger; } - /** - * @param string $name - * - * @return CacheLogger|null - */ - public function getLogger($name) + public function getLogger(string $name): ?CacheLogger { return $this->loggers[$name] ?? null; } /** - * @return array + * @return array */ - public function getLoggers() + public function getLoggers(): array { return $this->loggers; } - /** - * {@inheritdoc} - */ - public function collectionCacheHit($regionName, CollectionCacheKey $key) + public function collectionCacheHit(string $regionName, CollectionCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->collectionCacheHit($regionName, $key); } } - /** - * {@inheritdoc} - */ - public function collectionCacheMiss($regionName, CollectionCacheKey $key) + public function collectionCacheMiss(string $regionName, CollectionCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->collectionCacheMiss($regionName, $key); } } - /** - * {@inheritdoc} - */ - public function collectionCachePut($regionName, CollectionCacheKey $key) + public function collectionCachePut(string $regionName, CollectionCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->collectionCachePut($regionName, $key); } } - /** - * {@inheritdoc} - */ - public function entityCacheHit($regionName, EntityCacheKey $key) + public function entityCacheHit(string $regionName, EntityCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->entityCacheHit($regionName, $key); } } - /** - * {@inheritdoc} - */ - public function entityCacheMiss($regionName, EntityCacheKey $key) + public function entityCacheMiss(string $regionName, EntityCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->entityCacheMiss($regionName, $key); } } - /** - * {@inheritdoc} - */ - public function entityCachePut($regionName, EntityCacheKey $key) + public function entityCachePut(string $regionName, EntityCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->entityCachePut($regionName, $key); } } - /** - * {@inheritdoc} - */ - public function queryCacheHit($regionName, QueryCacheKey $key) + public function queryCacheHit(string $regionName, QueryCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->queryCacheHit($regionName, $key); } } - /** - * {@inheritdoc} - */ - public function queryCacheMiss($regionName, QueryCacheKey $key) + public function queryCacheMiss(string $regionName, QueryCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->queryCacheMiss($regionName, $key); } } - /** - * {@inheritdoc} - */ - public function queryCachePut($regionName, QueryCacheKey $key) + public function queryCachePut(string $regionName, QueryCacheKey $key): void { foreach ($this->loggers as $logger) { $logger->queryCachePut($regionName, $key); diff --git a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php b/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php index e0e01461369..44de7d7e6db 100644 --- a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php +++ b/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php @@ -15,113 +15,75 @@ */ class StatisticsCacheLogger implements CacheLogger { - /** @var int[] */ - private $cacheMissCountMap = []; + /** @var array */ + private array $cacheMissCountMap = []; - /** @var int[] */ - private $cacheHitCountMap = []; + /** @var array */ + private array $cacheHitCountMap = []; - /** @var int[] */ - private $cachePutCountMap = []; + /** @var array */ + private array $cachePutCountMap = []; - /** - * {@inheritdoc} - */ - public function collectionCacheMiss($regionName, CollectionCacheKey $key) + public function collectionCacheMiss(string $regionName, CollectionCacheKey $key): void { - $this->cacheMissCountMap[$regionName] = isset($this->cacheMissCountMap[$regionName]) - ? $this->cacheMissCountMap[$regionName] + 1 - : 1; + $this->cacheMissCountMap[$regionName] + = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; } - /** - * {@inheritdoc} - */ - public function collectionCacheHit($regionName, CollectionCacheKey $key) + public function collectionCacheHit(string $regionName, CollectionCacheKey $key): void { - $this->cacheHitCountMap[$regionName] = isset($this->cacheHitCountMap[$regionName]) - ? $this->cacheHitCountMap[$regionName] + 1 - : 1; + $this->cacheHitCountMap[$regionName] + = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; } - /** - * {@inheritdoc} - */ - public function collectionCachePut($regionName, CollectionCacheKey $key) + public function collectionCachePut(string $regionName, CollectionCacheKey $key): void { - $this->cachePutCountMap[$regionName] = isset($this->cachePutCountMap[$regionName]) - ? $this->cachePutCountMap[$regionName] + 1 - : 1; + $this->cachePutCountMap[$regionName] + = ($this->cachePutCountMap[$regionName] ?? 0) + 1; } - /** - * {@inheritdoc} - */ - public function entityCacheMiss($regionName, EntityCacheKey $key) + public function entityCacheMiss(string $regionName, EntityCacheKey $key): void { - $this->cacheMissCountMap[$regionName] = isset($this->cacheMissCountMap[$regionName]) - ? $this->cacheMissCountMap[$regionName] + 1 - : 1; + $this->cacheMissCountMap[$regionName] + = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; } - /** - * {@inheritdoc} - */ - public function entityCacheHit($regionName, EntityCacheKey $key) + public function entityCacheHit(string $regionName, EntityCacheKey $key): void { - $this->cacheHitCountMap[$regionName] = isset($this->cacheHitCountMap[$regionName]) - ? $this->cacheHitCountMap[$regionName] + 1 - : 1; + $this->cacheHitCountMap[$regionName] + = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; } - /** - * {@inheritdoc} - */ - public function entityCachePut($regionName, EntityCacheKey $key) + public function entityCachePut(string $regionName, EntityCacheKey $key): void { - $this->cachePutCountMap[$regionName] = isset($this->cachePutCountMap[$regionName]) - ? $this->cachePutCountMap[$regionName] + 1 - : 1; + $this->cachePutCountMap[$regionName] + = ($this->cachePutCountMap[$regionName] ?? 0) + 1; } - /** - * {@inheritdoc} - */ - public function queryCacheHit($regionName, QueryCacheKey $key) + public function queryCacheHit(string $regionName, QueryCacheKey $key): void { - $this->cacheHitCountMap[$regionName] = isset($this->cacheHitCountMap[$regionName]) - ? $this->cacheHitCountMap[$regionName] + 1 - : 1; + $this->cacheHitCountMap[$regionName] + = ($this->cacheHitCountMap[$regionName] ?? 0) + 1; } - /** - * {@inheritdoc} - */ - public function queryCacheMiss($regionName, QueryCacheKey $key) + public function queryCacheMiss(string $regionName, QueryCacheKey $key): void { - $this->cacheMissCountMap[$regionName] = isset($this->cacheMissCountMap[$regionName]) - ? $this->cacheMissCountMap[$regionName] + 1 - : 1; + $this->cacheMissCountMap[$regionName] + = ($this->cacheMissCountMap[$regionName] ?? 0) + 1; } - /** - * {@inheritdoc} - */ - public function queryCachePut($regionName, QueryCacheKey $key) + public function queryCachePut(string $regionName, QueryCacheKey $key): void { - $this->cachePutCountMap[$regionName] = isset($this->cachePutCountMap[$regionName]) - ? $this->cachePutCountMap[$regionName] + 1 - : 1; + $this->cachePutCountMap[$regionName] + = ($this->cachePutCountMap[$regionName] ?? 0) + 1; } /** * Get the number of entries successfully retrieved from cache. * * @param string $regionName The name of the cache region. - * - * @return int */ - public function getRegionHitCount($regionName) + public function getRegionHitCount(string $regionName): int { return $this->cacheHitCountMap[$regionName] ?? 0; } @@ -130,10 +92,8 @@ public function getRegionHitCount($regionName) * Get the number of cached entries *not* found in cache. * * @param string $regionName The name of the cache region. - * - * @return int */ - public function getRegionMissCount($regionName) + public function getRegionMissCount(string $regionName): int { return $this->cacheMissCountMap[$regionName] ?? 0; } @@ -142,10 +102,8 @@ public function getRegionMissCount($regionName) * Get the number of cacheable entries put in cache. * * @param string $regionName The name of the cache region. - * - * @return int */ - public function getRegionPutCount($regionName) + public function getRegionPutCount(string $regionName): int { return $this->cachePutCountMap[$regionName] ?? 0; } @@ -153,7 +111,7 @@ public function getRegionPutCount($regionName) /** * @return array */ - public function getRegionsMiss() + public function getRegionsMiss(): array { return $this->cacheMissCountMap; } @@ -161,7 +119,7 @@ public function getRegionsMiss() /** * @return array */ - public function getRegionsHit() + public function getRegionsHit(): array { return $this->cacheHitCountMap; } @@ -169,7 +127,7 @@ public function getRegionsHit() /** * @return array */ - public function getRegionsPut() + public function getRegionsPut(): array { return $this->cachePutCountMap; } @@ -178,10 +136,8 @@ public function getRegionsPut() * Clear region statistics * * @param string $regionName The name of the cache region. - * - * @return void */ - public function clearRegionStats($regionName) + public function clearRegionStats(string $regionName): void { $this->cachePutCountMap[$regionName] = 0; $this->cacheHitCountMap[$regionName] = 0; @@ -190,10 +146,8 @@ public function clearRegionStats($regionName) /** * Clear all statistics - * - * @return void */ - public function clearStats() + public function clearStats(): void { $this->cachePutCountMap = []; $this->cacheHitCountMap = []; @@ -202,30 +156,24 @@ public function clearStats() /** * Get the total number of put in cache. - * - * @return int */ - public function getPutCount() + public function getPutCount(): int { return array_sum($this->cachePutCountMap); } /** * Get the total number of entries successfully retrieved from cache. - * - * @return int */ - public function getHitCount() + public function getHitCount(): int { return array_sum($this->cacheHitCountMap); } /** * Get the total number of cached entries *not* found in cache. - * - * @return int */ - public function getMissCount() + public function getMissCount(): int { return array_sum($this->cacheMissCountMap); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8712acbf3c5..23e80d21961 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -125,45 +125,6 @@ $value->class - - - collectionCacheHit - collectionCacheMiss - collectionCachePut - entityCacheHit - entityCacheMiss - entityCachePut - queryCacheHit - queryCacheMiss - queryCachePut - - - - - collectionCacheHit - collectionCacheMiss - collectionCachePut - entityCacheHit - entityCacheMiss - entityCachePut - queryCacheHit - queryCacheMiss - queryCachePut - - - - - collectionCacheHit - collectionCacheMiss - collectionCachePut - entityCacheHit - entityCacheMiss - entityCachePut - queryCacheHit - queryCacheMiss - queryCachePut - - afterTransactionComplete diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index 00c3e754ef9..aa3f83949ba 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -18,11 +18,10 @@ */ class CacheLoggerChainTest extends DoctrineTestCase { - /** @var CacheLoggerChain */ - private $logger; + private CacheLoggerChain $logger; /** @var CacheLogger&MockObject */ - private $mock; + private CacheLogger $mock; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php index 8d89a4ad3ee..08cb4b834d1 100644 --- a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php @@ -16,8 +16,7 @@ */ class StatisticsCacheLoggerTest extends DoctrineTestCase { - /** @var StatisticsCacheLogger */ - private $logger; + private StatisticsCacheLogger $logger; protected function setUp(): void { From f61d5c24acfaf47ec708cbe8ad71f93213678617 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 20 Jan 2022 16:46:37 +0100 Subject: [PATCH 036/475] Remove check for getSQLResultCasing() (#9413) --- tests/Doctrine/Tests/ORM/PersistentCollectionTest.php | 6 ------ tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 7 ------- 2 files changed, 13 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index 01cbc2116b9..528e2823afd 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -19,7 +19,6 @@ use function array_keys; use function assert; -use function method_exists; /** * Tests the lazy-loading capabilities of the PersistentCollection and the initialization of collections. @@ -40,11 +39,6 @@ protected function setUp(): void $platform->method('supportsIdentityColumns') ->willReturn(true); - if (method_exists($platform, 'getSQLResultCasing')) { - $platform->method('getSQLResultCasing') - ->willReturnArgument(0); - } - $connection = $this->createMock(Connection::class); $connection->method('getDatabasePlatform') ->willReturn($platform); diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index c4945e82e59..4169fa492f9 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -88,13 +88,6 @@ protected function setUp(): void $platform->method('supportsIdentityColumns') ->willReturn(true); - if (method_exists($platform, 'getSQLResultCasing')) { - $platform->method('getSQLResultCasing') - ->willReturnCallback(static function (string $column): string { - return $column; - }); - } - $driverStatement = $this->createMock(Driver\Statement::class); if (method_exists($driverStatement, 'rowCount')) { From 7375c8a05873706a6a01fa9725ff1e8de2c17ae6 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 23 Jan 2022 21:29:47 +0100 Subject: [PATCH 037/475] Remove old cache accessors and mutators from query classes (#9392) --- UPGRADE.md | 15 ++++ lib/Doctrine/ORM/AbstractQuery.php | 82 ------------------- .../Exception/InvalidResultCacheDriver.php | 18 ---- lib/Doctrine/ORM/Query.php | 60 +------------- phpcs.xml.dist | 1 + psalm-baseline.xml | 15 ---- psalm.xml | 6 -- .../Doctrine/Tests/ORM/AbstractQueryTest.php | 62 ++++++-------- .../ORM/Functional/HydrationCacheTest.php | 13 +-- .../Tests/ORM/Functional/NativeQueryTest.php | 1 - .../Tests/ORM/Functional/ResultCacheTest.php | 45 +--------- .../ORM/Functional/Ticket/GH2947Test.php | 2 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 51 ++++-------- 13 files changed, 66 insertions(+), 305 deletions(-) delete mode 100644 lib/Doctrine/ORM/Cache/Exception/InvalidResultCacheDriver.php diff --git a/UPGRADE.md b/UPGRADE.md index db9f5ce8058..3bd6e3a6778 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,20 @@ # Upgrade to 3.0 +## BC BREAK: Remove old cache accessors and mutators from query classes + +The following methods have been removed from `AbstractQuery`: + +* `setResultCacheDriver()` +* `getResultCacheDriver()` +* `useResultCache()` +* `getResultCacheLifetime()` +* `getResultCacheId()` + +The following methods have been removed from `Query`: + +* `setQueryCacheDriver()` +* `getQueryCacheDriver()` + ## BC BREAK: Remove `Doctrine\ORM\Cache\MultiGetRegion` The interface has been merged into `Doctrine\ORM\Cache\Region`. diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index a9e886cd50f..71adc8a3681 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -6,12 +6,10 @@ use BackedEnum; use Countable; -use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Result; -use Doctrine\ORM\Cache\Exception\InvalidResultCacheDriver; use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\ORM\Cache\TimestampCacheKey; @@ -594,27 +592,6 @@ public function setResultCacheProfile(?QueryCacheProfile $profile = null) return $this; } - /** - * Defines a cache driver to be used for caching result sets and implicitly enables caching. - * - * @deprecated Use {@see setResultCache()} instead. - * - * @param \Doctrine\Common\Cache\Cache|null $resultCacheDriver Cache driver - * - * @return $this - * - * @throws InvalidResultCacheDriver - */ - public function setResultCacheDriver($resultCacheDriver = null) - { - /** @phpstan-ignore-next-line */ - if ($resultCacheDriver !== null && ! ($resultCacheDriver instanceof \Doctrine\Common\Cache\Cache)) { - throw InvalidResultCacheDriver::create(); - } - - return $this->setResultCache($resultCacheDriver ? CacheAdapter::wrap($resultCacheDriver) : null); - } - /** * Defines a cache driver to be used for caching result sets and implicitly enables caching. * @@ -637,41 +614,6 @@ public function setResultCache(?CacheItemPoolInterface $resultCache = null) return $this; } - /** - * Returns the cache driver used for caching result sets. - * - * @deprecated - * - * @return \Doctrine\Common\Cache\Cache Cache driver - */ - public function getResultCacheDriver() - { - if ($this->_queryCacheProfile && $this->_queryCacheProfile->getResultCacheDriver()) { - return $this->_queryCacheProfile->getResultCacheDriver(); - } - - return $this->_em->getConfiguration()->getResultCacheImpl(); - } - - /** - * Set whether or not to cache the results of this query and if so, for - * how long and which ID to use for the cache entry. - * - * @deprecated 2.7 Use {@see enableResultCache} and {@see disableResultCache} instead. - * - * @param bool $useCache Whether or not to cache the results of this query. - * @param int $lifetime How long the cache entry is valid, in seconds. - * @param string $resultCacheId ID to use for the cache entry. - * - * @return $this - */ - public function useResultCache($useCache, $lifetime = null, $resultCacheId = null) - { - return $useCache - ? $this->enableResultCache($lifetime, $resultCacheId) - : $this->disableResultCache(); - } - /** * Enables caching of the results of this query, for given or default amount of seconds * and optionally specifies which ID to use for the cache entry. @@ -730,18 +672,6 @@ public function setResultCacheLifetime($lifetime) return $this; } - /** - * Retrieves the lifetime of resultset cache. - * - * @deprecated - * - * @return int - */ - public function getResultCacheLifetime() - { - return $this->_queryCacheProfile ? $this->_queryCacheProfile->getLifetime() : 0; - } - /** * Defines if the result cache is active or not. * @@ -1246,18 +1176,6 @@ public function setResultCacheId($id) return $this; } - /** - * Get the result cache id to use to store the result set cache entry if set. - * - * @deprecated - * - * @return string|null - */ - public function getResultCacheId() - { - return $this->_queryCacheProfile ? $this->_queryCacheProfile->getCacheKey() : null; - } - /** * Executes the query and returns a the resulting Statement object. * diff --git a/lib/Doctrine/ORM/Cache/Exception/InvalidResultCacheDriver.php b/lib/Doctrine/ORM/Cache/Exception/InvalidResultCacheDriver.php deleted file mode 100644 index adfdc21601b..00000000000 --- a/lib/Doctrine/ORM/Cache/Exception/InvalidResultCacheDriver.php +++ /dev/null @@ -1,18 +0,0 @@ -_queryCacheProfile->getResultCache() - : $this->_queryCacheProfile->getResultCacheDriver(); + $cache = $this->_queryCacheProfile->getResultCache(); assert($cache !== null); @@ -348,10 +340,7 @@ private function evictResultSetCache( foreach ($statements as $statement) { $cacheKeys = $this->_queryCacheProfile->generateCacheKeys($statement, $sqlParams, $types, $connectionParams); - - $cache instanceof CacheItemPoolInterface - ? $cache->deleteItem(reset($cacheKeys)) - : $cache->delete(reset($cacheKeys)); + $cache->deleteItem(reset($cacheKeys)); } } @@ -461,29 +450,6 @@ private function resolveParameterValue(Parameter $parameter): array ]; } - /** - * Defines a cache driver to be used for caching queries. - * - * @deprecated Call {@see setQueryCache()} instead. - * - * @param Cache|null $queryCache Cache driver. - * - * @return $this - */ - public function setQueryCacheDriver($queryCache): self - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9004', - '%s is deprecated and will be removed in Doctrine 3.0. Use setQueryCache() instead.', - __METHOD__ - ); - - $this->queryCache = $queryCache ? CacheAdapter::wrap($queryCache) : null; - - return $this; - } - /** * Defines a cache driver to be used for caching queries. * @@ -510,28 +476,6 @@ public function useQueryCache($bool): self return $this; } - /** - * Returns the cache driver used for query caching. - * - * @deprecated - * - * @return Cache|null The cache driver used for query caching or NULL, if - * this Query does not use query caching. - */ - public function getQueryCacheDriver(): ?Cache - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9004', - '%s is deprecated and will be removed in Doctrine 3.0 without replacement.', - __METHOD__ - ); - - $queryCache = $this->queryCache ?? $this->_em->getConfiguration()->getQueryCache(); - - return $queryCache ? DoctrineProvider::wrap($queryCache) : null; - } - /** * Defines how long the query cache will be active before expire. * diff --git a/phpcs.xml.dist b/phpcs.xml.dist index cef6489cba2..ef196875cd2 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -215,6 +215,7 @@ tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php tests/Doctrine/Tests/Mocks/SchemaManagerMock.php + tests/Doctrine/Tests/ORM/AbstractQueryTest.php tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 23e80d21961..d7f495f4a58 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,20 +1,12 @@ - - getResultCacheDriver - getResultCacheDriver - getResultCacheImpl - ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null Parameter|null - - \Doctrine\Common\Cache\Cache - $key @@ -23,10 +15,6 @@ $data $data - - $this->_em->getConfiguration()->getResultCacheImpl() - $this->_queryCacheProfile->getResultCacheDriver() - $stmt @@ -1398,9 +1386,6 @@ - - getResultCacheDriver - $sqlParams diff --git a/psalm.xml b/psalm.xml index 7be14f27fa7..9acc0ca773b 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,12 +17,6 @@ - - - - - - diff --git a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php index 1ed79fbddab..0f3738c0c6e 100644 --- a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php +++ b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php @@ -4,9 +4,8 @@ namespace Doctrine\Tests\ORM; -use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\DBAL\Cache\QueryCacheProfile; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; +use Doctrine\DBAL\Result; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; @@ -15,29 +14,6 @@ final class AbstractQueryTest extends TestCase { - use VerifyDeprecations; - - /** - * @requires function Doctrine\DBAL\Cache\QueryCacheProfile::getResultCacheDriver - */ - public function testItMakesHydrationCacheProfilesAwareOfTheResultCacheDriver(): void - { - $cache = $this->createMock(CacheItemPoolInterface::class); - - $configuration = new Configuration(); - $configuration->setHydrationCache($cache); - $entityManager = $this->createMock(EntityManagerInterface::class); - $entityManager->method('getConfiguration')->willReturn($configuration); - $query = $this->getMockForAbstractClass(AbstractQuery::class, [$entityManager]); - $cacheProfile = new QueryCacheProfile(); - - $query->setHydrationCacheProfile($cacheProfile); - self::assertSame($cache, CacheAdapter::wrap($query->getHydrationCacheProfile()->getResultCacheDriver())); - } - - /** - * @requires function Doctrine\DBAL\Cache\QueryCacheProfile::getResultCache - */ public function testItMakesHydrationCacheProfilesAwareOfTheResultCache(): void { $cache = $this->createMock(CacheItemPoolInterface::class); @@ -46,12 +22,11 @@ public function testItMakesHydrationCacheProfilesAwareOfTheResultCache(): void $configuration->setHydrationCache($cache); $entityManager = $this->createMock(EntityManagerInterface::class); $entityManager->method('getConfiguration')->willReturn($configuration); - $query = $this->getMockForAbstractClass(AbstractQuery::class, [$entityManager]); + $query = new TestQuery($entityManager); $cacheProfile = new QueryCacheProfile(); $query->setHydrationCacheProfile($cacheProfile); self::assertSame($cache, $query->getHydrationCacheProfile()->getResultCache()); - $this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4620'); } public function testItMakesResultCacheProfilesAwareOfTheResultCache(): void @@ -62,12 +37,10 @@ public function testItMakesResultCacheProfilesAwareOfTheResultCache(): void $configuration->setResultCache($cache); $entityManager = $this->createMock(EntityManagerInterface::class); $entityManager->method('getConfiguration')->willReturn($configuration); - $query = $this->getMockForAbstractClass(AbstractQuery::class, [$entityManager]); - $cacheProfile = new QueryCacheProfile(); + $query = new TestQuery($entityManager); + $query->setResultCacheProfile(new QueryCacheProfile()); - $query->setResultCacheProfile($cacheProfile); - self::assertSame($cache, CacheAdapter::wrap($query->getResultCacheDriver())); - $this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4620'); + self::assertSame($cache, $query->getResultCache()); } public function testSettingTheResultCacheIsPossibleWithoutCallingDeprecatedMethods(): void @@ -76,10 +49,27 @@ public function testSettingTheResultCacheIsPossibleWithoutCallingDeprecatedMetho $entityManager = $this->createMock(EntityManagerInterface::class); $entityManager->method('getConfiguration')->willReturn(new Configuration()); - $query = $this->getMockForAbstractClass(AbstractQuery::class, [$entityManager]); - + $query = new TestQuery($entityManager); $query->setResultCache($cache); - self::assertSame($cache, CacheAdapter::wrap($query->getResultCacheDriver())); - $this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/4620'); + + self::assertSame($cache, $query->getResultCache()); + } +} + +class TestQuery extends AbstractQuery +{ + public function getSQL(): string + { + return ''; + } + + protected function _doExecute(): Result|int + { + return 0; + } + + public function getResultCache(): ?CacheItemPoolInterface + { + return $this->_queryCacheProfile->getResultCache(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php index 6de9bee3966..1c83c6751bc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php @@ -4,14 +4,11 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\Tests\Models\Cms\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; -use function method_exists; - /** * @group DDC-1766 */ @@ -35,8 +32,7 @@ protected function setUp(): void public function testHydrationCache(): void { - $arrayAdapter = new ArrayAdapter(); - $cache = method_exists(QueryCacheProfile::class, 'getResultCache') ? $arrayAdapter : DoctrineProvider::wrap($arrayAdapter); + $cache = new ArrayAdapter(); $dql = 'SELECT u FROM Doctrine\Tests\Models\Cms\CmsUser u'; @@ -67,7 +63,7 @@ public function testHydrationCache(): void ->setHydrationCacheProfile(new QueryCacheProfile(0, 'cachekey', $cache)) ->getArrayResult(); - self::assertTrue($arrayAdapter->hasItem('cachekey'), 'Explicit cache key'); + self::assertTrue($cache->hasItem('cachekey'), 'Explicit cache key'); $this->_em->createQuery($dql) ->setHydrationCacheProfile(new QueryCacheProfile(0, 'cachekey', $cache)) @@ -78,13 +74,10 @@ public function testHydrationCache(): void public function testHydrationParametersSerialization(): void { $cache = new ArrayAdapter(); - if (! method_exists(QueryCacheProfile::class, 'getResultCache')) { - $cache = DoctrineProvider::wrap($cache); - } $dql = 'SELECT u FROM Doctrine\Tests\Models\Cms\CmsUser u WHERE u.id = ?1'; $query = $this->_em->createQuery($dql) - ->setParameter(1, $userId = 1) + ->setParameter(1, 1) ->setHydrationCacheProfile(new QueryCacheProfile(0, null, $cache)); $query->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index ff773413695..d7b6affa701 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -216,7 +216,6 @@ public function testFluentInterface(): void ->setHint('foo', 'bar') ->setParameter(1, 'foo') ->setParameters($parameters) - ->setResultCacheDriver(null) ->setResultCacheLifetime(3500); self::assertSame($q, $q2); diff --git a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php index 6c81adbd9b3..7c7a82b02f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php @@ -19,7 +19,6 @@ use function assert; use function count; use function iterator_to_array; -use function method_exists; use function sprintf; class ResultCacheTest extends OrmFunctionalTestCase @@ -85,36 +84,6 @@ public function testSetResultCacheId(): void self::assertCacheHasItem('testing_result_cache_id', $cache); } - public function testUseResultCacheTrue(): void - { - $cache = new ArrayAdapter(); - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - - $query->useResultCache(true); - $this->setResultCache($query, $cache); - $query->setResultCacheId('testing_result_cache_id'); - $query->getResult(); - - self::assertCacheHasItem('testing_result_cache_id', $cache); - - $this->resetCache(); - } - - public function testUseResultCacheFalse(): void - { - $cache = new ArrayAdapter(); - $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - - $this->setResultCache($query, $cache); - $query->setResultCacheId('testing_result_cache_id'); - $query->useResultCache(false); - $query->getResult(); - - self::assertFalse($cache->hasItem('testing_result_cache_id')); - - $this->resetCache(); - } - /** * @group DDC-1026 */ @@ -125,7 +94,6 @@ public function testUseResultCacheParams(): void $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux WHERE ux.id = ?1'); $this->setResultCache($query, $cache); - $query->useResultCache(true); // these queries should result in cache miss: $query->setParameter(1, 1); @@ -390,15 +358,10 @@ public function testResultCacheWithObjectParameter(): void private function setResultCache(AbstractQuery $query, CacheItemPoolInterface $cache): void { - $profile = new QueryCacheProfile(); - - if (method_exists($profile, 'setResultCache')) { - $profile = $profile->setResultCache($cache); - } else { - $profile = $profile->setResultCacheDriver(DoctrineProvider::wrap($cache)); - } - - $query->setResultCacheProfile($profile); + $query->setResultCacheProfile( + (new QueryCacheProfile()) + ->setResultCache($cache) + ); } private static function assertCacheHasItem(string $key, CacheItemPoolInterface $cache): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php index 045b082d328..ed9e4de86cd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php @@ -55,7 +55,7 @@ private function createQuery(): Query ->select('car') ->from(GH2947Car::class, 'car') ->getQuery() - ->useResultCache(true, 3600, 'foo-cache-id'); + ->enableResultCache(3600, 'foo-cache-id'); } private function createData(): void diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index bf949526c69..282fef4c98a 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -6,11 +6,9 @@ use DateTime; use DateTimeImmutable; -use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\Parameter; @@ -29,12 +27,12 @@ use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\OrmTestCase; use Generator; +use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use function array_map; use function assert; -use function method_exists; use const PHP_VERSION_ID; @@ -111,14 +109,12 @@ public function testFluentQueryInterface(): void $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); $q2 = $q->expireQueryCache(true) ->setQueryCacheLifetime(3600) - ->setQueryCacheDriver(null) ->setQueryCache(null) ->expireResultCache(true) ->setHint('foo', 'bar') ->setHint('bar', 'baz') ->setParameter(1, 'bar') ->setParameters(new ArrayCollection([new Parameter(2, 'baz')])) - ->setResultCacheDriver(null) ->setResultCache(null) ->setResultCacheId('foo') ->setDQL('foo') @@ -143,21 +139,6 @@ public function testHints(): void self::assertFalse($q->hasHint('barFooBaz')); } - /** - * @group DDC-1588 - */ - public function testQueryDefaultResultCache(): void - { - if (! method_exists(QueryCacheProfile::class, 'getResultCache')) { - self::markTestSkipped('This test requires DBAL 3.2 or newer.'); - } - - $this->entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); - $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); - $q->enableResultCache(); - self::assertSame($this->entityManager->getConfiguration()->getResultCache(), $q->getQueryCacheProfile()->getResultCache()); - } - /** * @group DDC-1588 */ @@ -576,32 +557,28 @@ public function testGetParameterColonNormalize(): void public function testGetQueryCacheDriverWithDefaults(): void { $cache = $this->createMock(CacheItemPoolInterface::class); + $cache + ->expects(self::atLeastOnce()) + ->method('getItem') + ->willReturn($this->createMock(CacheItemInterface::class)); $this->entityManager->getConfiguration()->setQueryCache($cache); - $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u'); - - self::assertSame($cache, CacheAdapter::wrap($query->getQueryCacheDriver())); - } - - public function testGetQueryCacheDriverWithCacheExplicitlySetLegacy(): void - { - $cache = $this->createMock(Cache::class); - - $query = $this->entityManager + $this->entityManager ->createQuery('select u from ' . CmsUser::class . ' u') - ->setQueryCacheDriver($cache); - - self::assertSame($cache, $query->getQueryCacheDriver()); + ->getSQL(); } public function testGetQueryCacheDriverWithCacheExplicitlySet(): void { $cache = $this->createMock(CacheItemPoolInterface::class); + $cache + ->expects(self::atLeastOnce()) + ->method('getItem') + ->willReturn($this->createMock(CacheItemInterface::class)); - $query = $this->entityManager + $this->entityManager ->createQuery('select u from ' . CmsUser::class . ' u') - ->setQueryCache($cache); - - self::assertSame($cache, CacheAdapter::wrap($query->getQueryCacheDriver())); + ->setQueryCache($cache) + ->getSQL(); } } From 56021c1af93dd0f984c5619ed547e3a93482e428 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 24 Jan 2022 08:09:53 +0100 Subject: [PATCH 038/475] Remove DBAL 2 compatible SQL logging (#9422) --- .../Tests/DbalExtensions/Connection.php | 14 ++------- .../Tests/DbalExtensions/LegacySqlLogger.php | 27 ---------------- .../Tests/DbalExtensions/QueryLog.php | 5 ++- .../ORM/Functional/EntityRepositoryTest.php | 31 +++++-------------- .../Tests/ORM/Functional/QueryTest.php | 24 +++----------- .../ORM/Functional/Ticket/DDC2214Test.php | 10 +----- 6 files changed, 19 insertions(+), 92 deletions(-) delete mode 100644 tests/Doctrine/Tests/DbalExtensions/LegacySqlLogger.php diff --git a/tests/Doctrine/Tests/DbalExtensions/Connection.php b/tests/Doctrine/Tests/DbalExtensions/Connection.php index 96f2f44b4d5..3531398b159 100644 --- a/tests/Doctrine/Tests/DbalExtensions/Connection.php +++ b/tests/Doctrine/Tests/DbalExtensions/Connection.php @@ -10,23 +10,15 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Logging\Middleware as LoggingMiddleware; -use function class_exists; - class Connection extends BaseConnection { - /** @var QueryLog */ - public $queryLog; + public QueryLog $queryLog; public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null) { $this->queryLog = new QueryLog(); - if (class_exists(LoggingMiddleware::class)) { - $logging = new LoggingMiddleware(new SqlLogger($this->queryLog)); - $driver = $logging->wrap($driver); - } else { - $config ??= new Configuration(); - $config->setSQLLogger(new LegacySqlLogger($this->queryLog)); - } + $logging = new LoggingMiddleware(new SqlLogger($this->queryLog)); + $driver = $logging->wrap($driver); parent::__construct($params, $driver, $config, $eventManager); } diff --git a/tests/Doctrine/Tests/DbalExtensions/LegacySqlLogger.php b/tests/Doctrine/Tests/DbalExtensions/LegacySqlLogger.php deleted file mode 100644 index b615b25f0a0..00000000000 --- a/tests/Doctrine/Tests/DbalExtensions/LegacySqlLogger.php +++ /dev/null @@ -1,27 +0,0 @@ -queryLog = $queryLog; - } - - public function startQuery($sql, ?array $params = null, ?array $types = null): void - { - $this->queryLog->logQuery($sql, $params, $types); - } - - public function stopQuery(): void - { - } -} diff --git a/tests/Doctrine/Tests/DbalExtensions/QueryLog.php b/tests/Doctrine/Tests/DbalExtensions/QueryLog.php index 906529c9c70..b3970a39f2b 100644 --- a/tests/Doctrine/Tests/DbalExtensions/QueryLog.php +++ b/tests/Doctrine/Tests/DbalExtensions/QueryLog.php @@ -6,11 +6,10 @@ final class QueryLog { - /** @var bool */ - public $enabled = false; + public bool $enabled = false; /** @var list */ - public $queries = []; + public array $queries = []; public function logQuery(string $sql, ?array $params = null, ?array $types = null): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index b792ba1efca..b9252e68353 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -7,9 +7,7 @@ use BadMethodCallException; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; -use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; -use Doctrine\DBAL\Logging\Middleware as LoggingMiddleware; use Doctrine\DBAL\ParameterType; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\EntityRepository; @@ -36,7 +34,6 @@ use function array_fill; use function array_values; -use function class_exists; use function reset; class EntityRepositoryTest extends OrmFunctionalTestCase @@ -724,26 +721,14 @@ public function testFindByAssociationArray(): void $repo = $this->_em->getRepository(CmsAddress::class); $repo->findBy(['user' => [1, 2, 3]]); - if (! class_exists(LoggingMiddleware::class)) { - // DBAL 2 logs queries before resolving parameter positions - self::assertSame( - [ - 'sql' => 'SELECT t0.id AS id_1, t0.country AS country_2, t0.zip AS zip_3, t0.city AS city_4, t0.user_id AS user_id_5 FROM cms_addresses t0 WHERE t0.user_id IN (?)', - 'params' => [[1, 2, 3]], - 'types' => [Connection::PARAM_INT_ARRAY], - ], - $this->getLastLoggedQuery() - ); - } else { - self::assertSame( - [ - 'sql' => 'SELECT t0.id AS id_1, t0.country AS country_2, t0.zip AS zip_3, t0.city AS city_4, t0.user_id AS user_id_5 FROM cms_addresses t0 WHERE t0.user_id IN (?, ?, ?)', - 'params' => [1 => 1, 2 => 2, 3 => 3], - 'types' => array_fill(1, 3, ParameterType::INTEGER), - ], - $this->getLastLoggedQuery() - ); - } + self::assertSame( + [ + 'sql' => 'SELECT t0.id AS id_1, t0.country AS country_2, t0.zip AS zip_3, t0.city AS city_4, t0.user_id AS user_id_5 FROM cms_addresses t0 WHERE t0.user_id IN (?, ?, ?)', + 'params' => [1 => 1, 2 => 2, 3 => 3], + 'types' => array_fill(1, 3, ParameterType::INTEGER), + ], + $this->getLastLoggedQuery() + ); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index d1735b313ff..c1240494d64 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\DBAL\Logging\Middleware as LoggingMiddleware; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\Proxy\Proxy; @@ -22,8 +21,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Exception; -use function array_values; -use function class_exists; use function count; use function iterator_to_array; @@ -239,18 +236,10 @@ public function testSetParameters(): void ->setParameters($parameters) ->getResult(); - if (! class_exists(LoggingMiddleware::class)) { - // DBAL 2 logs queries before resolving parameter positions - self::assertSame( - ['jwage', 'active'], - $this->getLastLoggedQuery()['params'] - ); - } else { - self::assertSame( - [1 => 'jwage', 2 => 'active'], - $this->getLastLoggedQuery()['params'] - ); - } + self::assertSame( + [1 => 'jwage', 2 => 'active'], + $this->getLastLoggedQuery()['params'] + ); } public function testSetParametersBackwardsCompatible(): void @@ -261,10 +250,7 @@ public function testSetParametersBackwardsCompatible(): void ->setParameters($parameters) ->getResult(); - self::assertSame( - class_exists(LoggingMiddleware::class) ? $parameters : array_values($parameters), - $this->getLastLoggedQuery()['params'] - ); + self::assertSame($parameters, $this->getLastLoggedQuery()['params']); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php index 5ba1d389a50..18326253225 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php @@ -4,8 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Logging\Middleware as LoggingMiddleware; use Doctrine\DBAL\ParameterType; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -15,7 +13,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function assert; -use function class_exists; /** * Verifies that the type of parameters being bound to an SQL query is the same @@ -60,12 +57,7 @@ public function testIssue(): void ->setParameter('ids', [$bar]) ->getResult(); - if (! class_exists(LoggingMiddleware::class)) { - // DBAL 2 logs queries before resolving parameter positions - self::assertEquals([Connection::PARAM_INT_ARRAY], $this->getLastLoggedQuery()['types']); - } else { - self::assertEquals([1 => ParameterType::INTEGER], $this->getLastLoggedQuery()['types']); - } + self::assertEquals([1 => ParameterType::INTEGER], $this->getLastLoggedQuery()['types']); } } From 31b7d785165614c341ec3644ab2b660bb94945c9 Mon Sep 17 00:00:00 2001 From: Ahmadou Waly NDIAYE Date: Sun, 30 Jan 2022 14:57:12 +0000 Subject: [PATCH 039/475] Removing the deprecated Named (Native) Queries in Metadata/EntityRepository (#9428) This feature has been deprecated. --- UPGRADE.md | 4 + docs/en/reference/annotations-reference.rst | 89 ----- docs/en/reference/native-sql.rst | 358 ------------------ docs/en/reference/php-mapping.rst | 1 - doctrine-mapping.xsd | 32 -- lib/Doctrine/ORM/Configuration.php | 68 ---- .../ORM/Decorator/EntityManagerDecorator.php | 10 - lib/Doctrine/ORM/EntityManager.php | 12 - lib/Doctrine/ORM/EntityManagerInterface.php | 10 - lib/Doctrine/ORM/EntityRepository.php | 48 --- .../Exception/NamedNativeQueryNotFound.php | 20 - .../ORM/Exception/NamedQueryNotFound.php | 20 - .../Mapping/Builder/ClassMetadataBuilder.php | 20 - .../ORM/Mapping/ClassMetadataFactory.php | 45 --- .../ORM/Mapping/ClassMetadataInfo.php | 228 ----------- .../ORM/Mapping/Driver/AnnotationDriver.php | 40 -- .../Mapping/Driver/DoctrineAnnotations.php | 4 - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 26 -- .../ORM/Mapping/NamedNativeQueries.php | 22 -- lib/Doctrine/ORM/Mapping/NamedNativeQuery.php | 43 --- lib/Doctrine/ORM/Mapping/NamedQueries.php | 15 - lib/Doctrine/ORM/Mapping/NamedQuery.php | 18 - .../ORM/Query/ResultSetMappingBuilder.php | 172 --------- .../Command/MappingDescribeCommand.php | 2 - phpcs.xml.dist | 4 - phpstan-baseline.neon | 25 -- psalm-baseline.xml | 34 -- .../Mock/NonProxyLoadingEntityManager.php | 10 - .../Doctrine/Tests/Models/CMS/CmsAddress.php | 43 --- tests/Doctrine/Tests/Models/CMS/CmsUser.php | 87 ----- .../Tests/Models/Company/CompanyContract.php | 14 - .../Models/Company/CompanyFlexContract.php | 14 - .../Tests/Models/Company/CompanyPerson.php | 30 -- .../Doctrine/Tests/ORM/ConfigurationTest.php | 24 -- .../Doctrine/Tests/ORM/EntityManagerTest.php | 26 -- .../ORM/Functional/EntityRepositoryTest.php | 22 -- .../Tests/ORM/Functional/NativeQueryTest.php | 354 ----------------- .../ORM/Functional/Ticket/DDC1404Test.php | 123 ------ .../ORM/Hydration/ResultSetMappingTest.php | 171 --------- .../ORM/Mapping/AbstractMappingDriverTest.php | 69 ---- .../Tests/ORM/Mapping/AttributeDriverTest.php | 10 - .../Tests/ORM/Mapping/ClassMetadataTest.php | 236 ------------ ...ctrine.Tests.Models.CMS.CmsAddress.dcm.xml | 14 - .../Doctrine.Tests.Models.CMS.CmsUser.dcm.xml | 31 -- ...Tests.Models.Company.CompanyPerson.dcm.xml | 10 - .../Doctrine.Tests.ORM.Mapping.User.dcm.xml | 4 - 46 files changed, 4 insertions(+), 2658 deletions(-) delete mode 100644 lib/Doctrine/ORM/Exception/NamedNativeQueryNotFound.php delete mode 100644 lib/Doctrine/ORM/Exception/NamedQueryNotFound.php delete mode 100644 lib/Doctrine/ORM/Mapping/NamedNativeQueries.php delete mode 100644 lib/Doctrine/ORM/Mapping/NamedNativeQuery.php delete mode 100644 lib/Doctrine/ORM/Mapping/NamedQueries.php delete mode 100644 lib/Doctrine/ORM/Mapping/NamedQuery.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php diff --git a/UPGRADE.md b/UPGRADE.md index 3bd6e3a6778..06061db185f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Removed named queries + +All APIs related to named queries have been removed. + ## BC BREAK: Remove old cache accessors and mutators from query classes The following methods have been removed from `AbstractQuery`: diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index 51c48e02dc9..f8b9efbd61d 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -64,7 +64,6 @@ Index - :ref:`@ManyToOne ` - :ref:`@ManyToMany ` - :ref:`@MappedSuperclass ` -- :ref:`@NamedNativeQuery ` - :ref:`@OneToOne ` - :ref:`@OneToMany ` - :ref:`@OrderBy ` @@ -879,82 +878,6 @@ Example: // ... fields and methods } -.. _annref_named_native_query: - -@NamedNativeQuery -~~~~~~~~~~~~~~~~~ - -.. note:: - - Named Native Queries are deprecated as of version 2.9 and will be removed in ORM 3.0 - -Is used to specify a native SQL named query. -The NamedNativeQuery annotation can be applied to an entity or mapped superclass. - -Required attributes: - -- **name**: The name used to refer to the query with the EntityManager methods that create query objects. -- **query**: The SQL query string. - - -Optional attributes: - -- **resultClass**: The class of the result. -- **resultSetMapping**: The name of a SqlResultSetMapping, as defined in metadata. - - -Example: - -.. code-block:: php - - - - - - SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM users u INNER JOIN addresses a ON u.id = a.user_id INNER JOIN phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username - - - - - - - - - - - - - - - - - - - - -Things to note: - - The resultset mapping declares the entities retrieved by this native query. - - Each field of the entity is bound to a SQL alias (or column name). - - All fields of the entity including the ones of subclasses - and the foreign key columns of related entities have to be present in the SQL query. - - Field definitions are optional provided that they map to the same - column name as the one declared on the class property. - - ``__CLASS__`` is an alias for the mapped class - - -In the above example, -the ``fetchJoinedAddress`` named query use the joinMapping result set mapping. -This mapping returns 2 entities, User and Address, each property is declared and associated to a column name, -actually the column name retrieved by the query. - -Let's now see an implicit declaration of the property / column. - -.. configuration-block:: - - .. code-block:: php - - - - - - SELECT * FROM addresses - - - - - - - - - - -In this example, we only describe the entity member of the result set mapping. -The property / column mappings is done using the entity mapping values. -In this case the model property is bound to the model_txt column. -If the association to a related entity involve a composite primary key, -a @FieldResult element should be used for each foreign key column. -The @FieldResult name is composed of the property name for the relationship, -followed by a dot ("."), followed by the name or the field or property of the primary key. - - -.. configuration-block:: - - .. code-block:: php - - - - - - SELECT u.id, u.name, u.status, a.id AS a_id, a.country AS a_country, a.zip AS a_zip, a.city AS a_city FROM users u INNER JOIN addresses a ON u.id = a.user_id WHERE u.username = ? - - - - - - - - - - - - - - - - - - -If you retrieve a single entity and if you use the default mapping, -you can use the resultClass attribute instead of resultSetMapping: - -.. configuration-block:: - - .. code-block:: php - - - - - - SELECT * FROM addresses WHERE id = ? - - - - - -In some of your native queries, you'll have to return scalar values, -for example when building report queries. -You can map them in the @SqlResultsetMapping through @ColumnResult. -You actually can even mix, entities and scalar returns in the same native query (this is probably not that common though). - -.. configuration-block:: - - .. code-block:: php - - - - - SELECT COUNT(*) AS count FROM addresses - - - - - - - - diff --git a/docs/en/reference/php-mapping.rst b/docs/en/reference/php-mapping.rst index aaa00e18d61..2b822802c40 100644 --- a/docs/en/reference/php-mapping.rst +++ b/docs/en/reference/php-mapping.rst @@ -85,7 +85,6 @@ The API of the ClassMetadataBuilder has the following methods with a fluent inte - ``setTable($name)`` - ``addIndex(array $columns, $indexName)`` - ``addUniqueConstraint(array $columns, $constraintName)`` -- ``addNamedQuery($name, $dqlQuery)`` - ``setJoinedTableInheritance()`` - ``setSingleTableInheritance()`` - ``setDiscriminatorColumn($name, $type = 'string', $length = 255)`` diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index db7f4311134..69ed55c4bab 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -82,36 +82,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -176,8 +146,6 @@ - - diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index c9009983a40..6d577b67e4e 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -16,8 +16,6 @@ use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Exception\InvalidEntityRepository; -use Doctrine\ORM\Exception\NamedNativeQueryNotFound; -use Doctrine\ORM\Exception\NamedQueryNotFound; use Doctrine\ORM\Exception\UnknownEntityNamespace; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Mapping\ClassMetadataFactory; @@ -28,7 +26,6 @@ use Doctrine\ORM\Mapping\EntityListenerResolver; use Doctrine\ORM\Mapping\NamingStrategy; use Doctrine\ORM\Mapping\QuoteStrategy; -use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Repository\DefaultRepositoryFactory; use Doctrine\ORM\Repository\RepositoryFactory; use Doctrine\Persistence\Mapping\Driver\MappingDriver; @@ -405,71 +402,6 @@ public function setMetadataCache(CacheItemPoolInterface $cache): void $this->_attributes['metadataCacheImpl'] = DoctrineProvider::wrap($cache); } - /** - * Adds a named DQL query to the configuration. - * - * @param string $name The name of the query. - * @param string $dql The DQL query string. - * - * @return void - */ - public function addNamedQuery($name, $dql) - { - $this->_attributes['namedQueries'][$name] = $dql; - } - - /** - * Gets a previously registered named DQL query. - * - * @param string $name The name of the query. - * - * @return string The DQL query. - * - * @throws NamedQueryNotFound - */ - public function getNamedQuery($name) - { - if (! isset($this->_attributes['namedQueries'][$name])) { - throw NamedQueryNotFound::fromName($name); - } - - return $this->_attributes['namedQueries'][$name]; - } - - /** - * Adds a named native query to the configuration. - * - * @param string $name The name of the query. - * @param string $sql The native SQL query string. - * @param Query\ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query. - * - * @return void - */ - public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm) - { - $this->_attributes['namedNativeQueries'][$name] = [$sql, $rsm]; - } - - /** - * Gets the components of a previously registered named native query. - * - * @param string $name The name of the query. - * - * @return mixed[] - * @psalm-return array{string, ResultSetMapping} A tuple with the first element being the SQL string and the second - * element being the ResultSetMapping. - * - * @throws NamedNativeQueryNotFound - */ - public function getNamedNativeQuery($name) - { - if (! isset($this->_attributes['namedNativeQueries'][$name])) { - throw NamedNativeQueryNotFound::fromName($name); - } - - return $this->_attributes['namedNativeQueries'][$name]; - } - /** * Registers a custom DQL function that produces a string value. * Such a function can then be used in any DQL statement in any place where string diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index 0b1f7b53391..ee27d4d2f54 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -91,21 +91,11 @@ public function createQuery(string $dql = ''): Query return $this->wrapped->createQuery($dql); } - public function createNamedQuery(string $name): Query - { - return $this->wrapped->createNamedQuery($name); - } - public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery { return $this->wrapped->createNativeQuery($sql, $rsm); } - public function createNamedNativeQuery(string $name): NativeQuery - { - return $this->wrapped->createNamedNativeQuery($name); - } - public function createQueryBuilder(): QueryBuilder { return $this->wrapped->createQueryBuilder(); diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 7ea7bead069..97babe24c6d 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -241,11 +241,6 @@ public function createQuery(string $dql = ''): Query return $query; } - public function createNamedQuery(string $name): Query - { - return $this->createQuery($this->config->getNamedQuery($name)); - } - public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery { $query = new NativeQuery($this); @@ -256,13 +251,6 @@ public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQue return $query; } - public function createNamedNativeQuery(string $name): NativeQuery - { - [$sql, $rsm] = $this->config->getNamedNativeQuery($name); - - return $this->createNativeQuery($sql, $rsm); - } - public function createQueryBuilder(): QueryBuilder { return new QueryBuilder($this); diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index ad59829f4e6..19c13b4e8e6 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -97,21 +97,11 @@ public function rollback(): void; */ public function createQuery(string $dql = ''): Query; - /** - * Creates a Query from a named query. - */ - public function createNamedQuery(string $name): Query; - /** * Creates a native SQL query. */ public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery; - /** - * Creates a NativeQuery from a named native query. - */ - public function createNamedNativeQuery(string $name): NativeQuery; - /** * Create a QueryBuilder instance */ diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index b19c895873b..af7cc49af77 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -90,54 +90,6 @@ public function createResultSetMappingBuilder($alias) return $rsm; } - /** - * Creates a new Query instance based on a predefined metadata named query. - * - * @deprecated - * - * @param string $queryName - * - * @return Query - */ - public function createNamedQuery($queryName) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8592', - 'Named Queries are deprecated, here "%s" on entity %s. Move the query logic into EntityRepository', - $queryName, - $this->_class->name - ); - - return $this->_em->createQuery($this->_class->getNamedQuery($queryName)); - } - - /** - * Creates a native SQL query. - * - * @deprecated - * - * @param string $queryName - * - * @return NativeQuery - */ - public function createNativeNamedQuery($queryName) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8592', - 'Named Native Queries are deprecated, here "%s" on entity %s. Move the query logic into EntityRepository', - $queryName, - $this->_class->name - ); - - $queryMapping = $this->_class->getNamedNativeQuery($queryName); - $rsm = new Query\ResultSetMappingBuilder($this->_em); - $rsm->addNamedNativeQueryMapping($this->_class, $queryMapping); - - return $this->_em->createNativeQuery($queryMapping['query'], $rsm); - } - /** * Clears the repository, causing all managed entities to become detached. * diff --git a/lib/Doctrine/ORM/Exception/NamedNativeQueryNotFound.php b/lib/Doctrine/ORM/Exception/NamedNativeQueryNotFound.php deleted file mode 100644 index 0f482f3f063..00000000000 --- a/lib/Doctrine/ORM/Exception/NamedNativeQueryNotFound.php +++ /dev/null @@ -1,20 +0,0 @@ -cm->addNamedQuery( - [ - 'name' => $name, - 'query' => $dqlQuery, - ] - ); - - return $this; - } - /** * Sets class as root of a joined table inheritance hierarchy. * diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 36d4205fa67..2c021511894 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -192,14 +192,6 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS $class->containsForeignIdentifier = true; } - if (! empty($parent->namedQueries)) { - $this->addInheritedNamedQueries($class, $parent); - } - - if (! empty($parent->namedNativeQueries)) { - $this->addInheritedNamedNativeQueries($class, $parent); - } - if (! empty($parent->sqlResultSetMappings)) { $this->addInheritedSqlResultSetMappings($class, $parent); } @@ -467,43 +459,6 @@ private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $par } } - /** - * Adds inherited named queries to the subclass mapping. - */ - private function addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata $parentClass): void - { - foreach ($parentClass->namedQueries as $name => $query) { - if (! isset($subClass->namedQueries[$name])) { - $subClass->addNamedQuery( - [ - 'name' => $query['name'], - 'query' => $query['query'], - ] - ); - } - } - } - - /** - * Adds inherited named native queries to the subclass mapping. - */ - private function addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMetadata $parentClass): void - { - foreach ($parentClass->namedNativeQueries as $name => $query) { - if (! isset($subClass->namedNativeQueries[$name])) { - $subClass->addNamedNativeQuery( - [ - 'name' => $query['name'], - 'query' => $query['query'], - 'isSelfClass' => $query['isSelfClass'], - 'resultSetMapping' => $query['resultSetMapping'], - 'resultClass' => $query['isSelfClass'] ? $subClass->name : $query['resultClass'], - ] - ); - } - } - } - /** * Adds inherited sql result set mappings to the subclass mapping. */ diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 75645abce0b..02db2ed366c 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -345,30 +345,6 @@ class ClassMetadataInfo implements ClassMetadata */ public $embeddedClasses = []; - /** - * READ-ONLY: The named queries allowed to be called directly from Repository. - * - * @psalm-var array> - */ - public $namedQueries = []; - - /** - * READ-ONLY: The named native queries allowed to be called directly from Repository. - * - * A native SQL named query definition has the following structure: - *
-     * array(
-     *     'name'               => ,
-     *     'query'              => ,
-     *     'resultClass'        => ,
-     *     'resultSetMapping'   => 
-     * )
-     * 
- * - * @psalm-var array> - */ - public $namedNativeQueries = []; - /** * READ-ONLY: The mappings of the results of native SQL queries. * @@ -954,14 +930,6 @@ public function __sleep() $serialized[] = 'entityListeners'; } - if ($this->namedQueries) { - $serialized[] = 'namedQueries'; - } - - if ($this->namedNativeQueries) { - $serialized[] = 'namedNativeQueries'; - } - if ($this->sqlResultSetMappings) { $serialized[] = 'sqlResultSetMappings'; } @@ -1387,68 +1355,6 @@ public function getFieldName($columnName) return $this->fieldNames[$columnName] ?? $columnName; } - /** - * Gets the named query. - * - * @see ClassMetadataInfo::$namedQueries - * - * @param string $queryName The query name. - * - * @return string - * - * @throws MappingException - */ - public function getNamedQuery($queryName) - { - if (! isset($this->namedQueries[$queryName])) { - throw MappingException::queryNotFound($this->name, $queryName); - } - - return $this->namedQueries[$queryName]['dql']; - } - - /** - * Gets all named queries of the class. - * - * @return mixed[][] - * @psalm-return array> - */ - public function getNamedQueries() - { - return $this->namedQueries; - } - - /** - * Gets the named native query. - * - * @see ClassMetadataInfo::$namedNativeQueries - * - * @param string $queryName The query name. - * - * @return mixed[] - * @psalm-return array - * - * @throws MappingException - */ - public function getNamedNativeQuery($queryName) - { - if (! isset($this->namedNativeQueries[$queryName])) { - throw MappingException::queryNotFound($this->name, $queryName); - } - - return $this->namedNativeQueries[$queryName]; - } - - /** - * Gets all named native queries of the class. - * - * @psalm-return array> - */ - public function getNamedNativeQueries() - { - return $this->namedNativeQueries; - } - /** * Gets the result set mapping. * @@ -2718,104 +2624,6 @@ public function addInheritedFieldMapping(array $fieldMapping) $this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName']; } - /** - * INTERNAL: - * Adds a named query to this class. - * - * @deprecated - * - * @psalm-param array $queryMapping - * - * @return void - * - * @throws MappingException - */ - public function addNamedQuery(array $queryMapping) - { - if (! isset($queryMapping['name'])) { - throw MappingException::nameIsMandatoryForQueryMapping($this->name); - } - - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8592', - 'Named Queries are deprecated, here "%s" on entity %s. Move the query logic into EntityRepository', - $queryMapping['name'], - $this->name - ); - - if (isset($this->namedQueries[$queryMapping['name']])) { - throw MappingException::duplicateQueryMapping($this->name, $queryMapping['name']); - } - - if (! isset($queryMapping['query'])) { - throw MappingException::emptyQueryMapping($this->name, $queryMapping['name']); - } - - $name = $queryMapping['name']; - $query = $queryMapping['query']; - $dql = str_replace('__CLASS__', $this->name, $query); - - $this->namedQueries[$name] = [ - 'name' => $name, - 'query' => $query, - 'dql' => $dql, - ]; - } - - /** - * INTERNAL: - * Adds a named native query to this class. - * - * @deprecated - * - * @psalm-param array $queryMapping - * - * @return void - * - * @throws MappingException - */ - public function addNamedNativeQuery(array $queryMapping) - { - if (! isset($queryMapping['name'])) { - throw MappingException::nameIsMandatoryForQueryMapping($this->name); - } - - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8592', - 'Named Native Queries are deprecated, here "%s" on entity %s. Move the query logic into EntityRepository', - $queryMapping['name'], - $this->name - ); - - if (isset($this->namedNativeQueries[$queryMapping['name']])) { - throw MappingException::duplicateQueryMapping($this->name, $queryMapping['name']); - } - - if (! isset($queryMapping['query'])) { - throw MappingException::emptyQueryMapping($this->name, $queryMapping['name']); - } - - if (! isset($queryMapping['resultClass']) && ! isset($queryMapping['resultSetMapping'])) { - throw MappingException::missingQueryMapping($this->name, $queryMapping['name']); - } - - $queryMapping['isSelfClass'] = false; - - if (isset($queryMapping['resultClass'])) { - if ($queryMapping['resultClass'] === '__CLASS__') { - $queryMapping['isSelfClass'] = true; - $queryMapping['resultClass'] = $this->name; - } - - $queryMapping['resultClass'] = $this->fullyQualifiedClassName($queryMapping['resultClass']); - $queryMapping['resultClass'] = ltrim($queryMapping['resultClass'], '\\'); - } - - $this->namedNativeQueries[$queryMapping['name']] = $queryMapping; - } - /** * INTERNAL: * Adds a sql result set mapping to this class. @@ -3188,42 +2996,6 @@ public function addDiscriminatorMapClass($name, $className) } } - /** - * Checks whether the class has a named query with the given query name. - * - * @param string $queryName - * - * @return bool - */ - public function hasNamedQuery($queryName) - { - return isset($this->namedQueries[$queryName]); - } - - /** - * Checks whether the class has a named native query with the given query name. - * - * @param string $queryName - * - * @return bool - */ - public function hasNamedNativeQuery($queryName) - { - return isset($this->namedNativeQueries[$queryName]); - } - - /** - * Checks whether the class has a named native query with the given query name. - * - * @param string $name - * - * @return bool - */ - public function hasSqlResultSetMapping($name) - { - return isset($this->sqlResultSetMappings[$name]); - } - /** * {@inheritDoc} */ diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index e9f09210ae2..e3c5a80b73c 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -15,7 +15,6 @@ use ReflectionClass; use ReflectionMethod; use ReflectionProperty; -use UnexpectedValueException; use function assert; use function class_exists; @@ -23,7 +22,6 @@ use function count; use function defined; use function get_class; -use function is_array; use function is_numeric; /** @@ -184,22 +182,6 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) $metadata->enableCache($cacheMap); } - // Evaluate NamedNativeQueries annotation - if (isset($classAnnotations[Mapping\NamedNativeQueries::class])) { - $namedNativeQueriesAnnot = $classAnnotations[Mapping\NamedNativeQueries::class]; - - foreach ($namedNativeQueriesAnnot->value as $namedNativeQuery) { - $metadata->addNamedNativeQuery( - [ - 'name' => $namedNativeQuery->name, - 'query' => $namedNativeQuery->query, - 'resultClass' => $namedNativeQuery->resultClass, - 'resultSetMapping' => $namedNativeQuery->resultSetMapping, - ] - ); - } - } - // Evaluate SqlResultSetMappings annotation if (isset($classAnnotations[Mapping\SqlResultSetMappings::class])) { $sqlResultSetMappingsAnnot = $classAnnotations[Mapping\SqlResultSetMappings::class]; @@ -240,28 +222,6 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) } } - // Evaluate NamedQueries annotation - if (isset($classAnnotations[Mapping\NamedQueries::class])) { - $namedQueriesAnnot = $classAnnotations[Mapping\NamedQueries::class]; - - if (! is_array($namedQueriesAnnot->value)) { - throw new UnexpectedValueException('@NamedQueries should contain an array of @NamedQuery annotations.'); - } - - foreach ($namedQueriesAnnot->value as $namedQuery) { - if (! ($namedQuery instanceof Mapping\NamedQuery)) { - throw new UnexpectedValueException('@NamedQueries should contain an array of @NamedQuery annotations.'); - } - - $metadata->addNamedQuery( - [ - 'name' => $namedQuery->name, - 'query' => $namedQuery->query, - ] - ); - } - } - // Evaluate InheritanceType annotation if (isset($classAnnotations[Mapping\InheritanceType::class])) { $inheritanceTypeAnnot = $classAnnotations[Mapping\InheritanceType::class]; diff --git a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php index ae5d78ba1da..f334b3883ce 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php @@ -28,8 +28,6 @@ require_once __DIR__ . '/../CustomIdGenerator.php'; require_once __DIR__ . '/../ChangeTrackingPolicy.php'; require_once __DIR__ . '/../OrderBy.php'; -require_once __DIR__ . '/../NamedQueries.php'; -require_once __DIR__ . '/../NamedQuery.php'; require_once __DIR__ . '/../HasLifecycleCallbacks.php'; require_once __DIR__ . '/../PrePersist.php'; require_once __DIR__ . '/../PostPersist.php'; @@ -42,8 +40,6 @@ require_once __DIR__ . '/../FieldResult.php'; require_once __DIR__ . '/../ColumnResult.php'; require_once __DIR__ . '/../EntityResult.php'; -require_once __DIR__ . '/../NamedNativeQuery.php'; -require_once __DIR__ . '/../NamedNativeQueries.php'; require_once __DIR__ . '/../SqlResultSetMapping.php'; require_once __DIR__ . '/../SqlResultSetMappings.php'; require_once __DIR__ . '/../AssociationOverride.php'; diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index db5d7b908d0..81a061ce1b3 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -87,32 +87,6 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) $metadata->enableCache($this->cacheToArray($xmlRoot->cache)); } - // Evaluate named queries - if (isset($xmlRoot->{'named-queries'})) { - foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) { - $metadata->addNamedQuery( - [ - 'name' => (string) $namedQueryElement['name'], - 'query' => (string) $namedQueryElement['query'], - ] - ); - } - } - - // Evaluate native named queries - if (isset($xmlRoot->{'named-native-queries'})) { - foreach ($xmlRoot->{'named-native-queries'}->{'named-native-query'} as $nativeQueryElement) { - $metadata->addNamedNativeQuery( - [ - 'name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null, - 'query' => isset($nativeQueryElement->query) ? (string) $nativeQueryElement->query : null, - 'resultClass' => isset($nativeQueryElement['result-class']) ? (string) $nativeQueryElement['result-class'] : null, - 'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string) $nativeQueryElement['result-set-mapping'] : null, - ] - ); - } - } - // Evaluate sql result set mapping if (isset($xmlRoot->{'sql-result-set-mappings'})) { foreach ($xmlRoot->{'sql-result-set-mappings'}->{'sql-result-set-mapping'} as $rsmElement) { diff --git a/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php b/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php deleted file mode 100644 index 05a194e4544..00000000000 --- a/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - public $value = []; -} diff --git a/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php b/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php deleted file mode 100644 index 86b5d4b726e..00000000000 --- a/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php +++ /dev/null @@ -1,43 +0,0 @@ - */ - public $value; -} diff --git a/lib/Doctrine/ORM/Mapping/NamedQuery.php b/lib/Doctrine/ORM/Mapping/NamedQuery.php deleted file mode 100644 index 382f70d3124..00000000000 --- a/lib/Doctrine/ORM/Mapping/NamedQuery.php +++ /dev/null @@ -1,18 +0,0 @@ -addNamedNativeQueryResultClassMapping($class, $queryMapping['resultClass']); - } - - return $this->addNamedNativeQueryResultSetMapping($class, $queryMapping['resultSetMapping']); - } - - /** - * Adds the class mapping of the results of native SQL queries to the result set. - * - * @param string $resultClassName - * - * @return $this - */ - public function addNamedNativeQueryResultClassMapping(ClassMetadataInfo $class, $resultClassName) - { - $classMetadata = $this->em->getClassMetadata($resultClassName); - $shortName = $classMetadata->reflClass->getShortName(); - $alias = strtolower($shortName[0]) . '0'; - - $this->addEntityResult($class->name, $alias); - - if ($classMetadata->discriminatorColumn) { - $discrColumn = $classMetadata->discriminatorColumn; - - $this->setDiscriminatorColumn($alias, $discrColumn['name']); - $this->addMetaResult($alias, $discrColumn['name'], $discrColumn['fieldName'], false, $discrColumn['type']); - } - - foreach ($classMetadata->getColumnNames() as $key => $columnName) { - $propertyName = $classMetadata->getFieldName($columnName); - - $this->addFieldResult($alias, $columnName, $propertyName); - } - - foreach ($classMetadata->associationMappings as $associationMapping) { - if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) { - $targetClass = $this->em->getClassMetadata($associationMapping['targetEntity']); - - foreach ($associationMapping['joinColumns'] as $joinColumn) { - $columnName = $joinColumn['name']; - $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); - - $this->addMetaResult($alias, $columnName, $columnName, $classMetadata->isIdentifier($columnName), $columnType); - } - } - } - - return $this; - } - - /** - * Adds the result set mapping of the results of native SQL queries to the result set. - * - * @param string $resultSetMappingName - * - * @return $this - */ - public function addNamedNativeQueryResultSetMapping(ClassMetadataInfo $class, $resultSetMappingName) - { - $counter = 0; - $resultMapping = $class->getSqlResultSetMapping($resultSetMappingName); - $rootShortName = $class->reflClass->getShortName(); - $rootAlias = strtolower($rootShortName[0]) . $counter; - - if (isset($resultMapping['entities'])) { - foreach ($resultMapping['entities'] as $key => $entityMapping) { - $classMetadata = $this->em->getClassMetadata($entityMapping['entityClass']); - - if ($class->reflClass->name === $classMetadata->reflClass->name) { - $this->addEntityResult($classMetadata->name, $rootAlias); - $this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $rootAlias); - } else { - $shortName = $classMetadata->reflClass->getShortName(); - $joinAlias = strtolower($shortName[0]) . ++$counter; - $associations = $class->getAssociationsByTargetClass($classMetadata->name); - - $this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $joinAlias); - - foreach ($associations as $relation => $mapping) { - $this->addJoinedEntityResult($mapping['targetEntity'], $joinAlias, $rootAlias, $relation); - } - } - } - } - - if (isset($resultMapping['columns'])) { - foreach ($resultMapping['columns'] as $entityMapping) { - $type = isset($class->fieldNames[$entityMapping['name']]) - ? PersisterHelper::getTypeOfColumn($entityMapping['name'], $class, $this->em) - : 'string'; - - $this->addScalarResult($entityMapping['name'], $entityMapping['name'], $type); - } - } - - return $this; - } - - /** - * Adds the entity result mapping of the results of native SQL queries to the result set. - * - * @param mixed[] $entityMapping - * @param string $alias - * - * @return $this - * - * @throws MappingException - * @throws InvalidArgumentException - */ - public function addNamedNativeQueryEntityResultMapping(ClassMetadataInfo $classMetadata, array $entityMapping, $alias) - { - if (isset($entityMapping['discriminatorColumn']) && $entityMapping['discriminatorColumn']) { - $discriminatorColumn = $entityMapping['discriminatorColumn']; - $discriminatorType = $classMetadata->getDiscriminatorColumn()['type']; - - $this->setDiscriminatorColumn($alias, $discriminatorColumn); - $this->addMetaResult($alias, $discriminatorColumn, $discriminatorColumn, false, $discriminatorType); - } - - if (isset($entityMapping['fields']) && ! empty($entityMapping['fields'])) { - foreach ($entityMapping['fields'] as $field) { - $fieldName = $field['name']; - $relation = null; - - if (strpos($fieldName, '.') !== false) { - [$relation, $fieldName] = explode('.', $fieldName); - } - - if (isset($classMetadata->associationMappings[$relation])) { - if ($relation) { - $associationMapping = $classMetadata->associationMappings[$relation]; - $joinAlias = $alias . $relation; - $parentAlias = $alias; - - $this->addJoinedEntityResult($associationMapping['targetEntity'], $joinAlias, $parentAlias, $relation); - $this->addFieldResult($joinAlias, $field['column'], $fieldName); - } else { - $this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name); - } - } else { - if (! isset($classMetadata->fieldMappings[$fieldName])) { - throw new InvalidArgumentException("Entity '" . $classMetadata->name . "' has no field '" . $fieldName . "'. "); - } - - $this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name); - } - } - } else { - foreach ($classMetadata->getColumnNames() as $columnName) { - $propertyName = $classMetadata->getFieldName($columnName); - - $this->addFieldResult($alias, $columnName, $propertyName); - } - } - - return $this; - } - /** * Generates the Select clause from this ResultSetMappingBuilder. * diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index c43f3af424b..fa812829fc4 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -96,8 +96,6 @@ private function displayEntity( $this->formatField('Parent classes', $metadata->parentClasses), $this->formatField('Sub classes', $metadata->subClasses), $this->formatField('Embedded classes', $metadata->subClasses), - $this->formatField('Named queries', $metadata->namedQueries), - $this->formatField('Named native queries', $metadata->namedNativeQueries), $this->formatField('SQL result set mappings', $metadata->sqlResultSetMappings), $this->formatField('Identifier', $metadata->identifier), $this->formatField('Inheritance type', $metadata->inheritanceType), diff --git a/phpcs.xml.dist b/phpcs.xml.dist index e6c42b118b4..39c267eadf2 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -101,10 +101,6 @@ lib/Doctrine/ORM/Mapping/ManyToMany.php lib/Doctrine/ORM/Mapping/ManyToOne.php lib/Doctrine/ORM/Mapping/MappedSuperclass.php - lib/Doctrine/ORM/Mapping/NamedNativeQueries.php - lib/Doctrine/ORM/Mapping/NamedNativeQuery.php - lib/Doctrine/ORM/Mapping/NamedQueries.php - lib/Doctrine/ORM/Mapping/NamedQuery.php lib/Doctrine/ORM/Mapping/OneToMany.php lib/Doctrine/ORM/Mapping/OneToOne.php lib/Doctrine/ORM/Mapping/OrderBy.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 72ea56c6ed1..c744442651d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -370,16 +370,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addNamedNativeQuery\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addNamedQuery\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\\\:\\:addSqlResultSetMapping\\(\\)\\.$#" count: 1 @@ -800,21 +790,6 @@ parameters: count: 3 path: lib/Doctrine/ORM/Query/Parser.php - - - message: "#^Offset 'columns' on array\\{name\\: string, entities\\: array, columns\\: array\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php - - - - message: "#^Offset 'entities' on array\\{name\\: string, entities\\: array, columns\\: array\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php - - - - message: "#^Parameter \\#2 \\$class of static method Doctrine\\\\ORM\\\\Utility\\\\PersisterHelper\\:\\:getTypeOfColumn\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php - - message: "#^Call to function is_string\\(\\) with Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node will always evaluate to false\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index dcafb076fe9..ca305c22e88 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -492,9 +492,6 @@ $class $repositoryClassName - - addNamedQuery -
@@ -529,10 +526,6 @@ $nonSuperclassParents new $definition['class']() - - addNamedNativeQuery - addNamedQuery - ! $definition $definition @@ -736,10 +729,6 @@ - - addNamedNativeQuery - addNamedQuery - new ReflectionClass($metadata->name) @@ -896,8 +885,6 @@ isset($xmlRoot->{'lifecycle-callbacks'}) isset($xmlRoot->{'many-to-many'}) isset($xmlRoot->{'many-to-one'}) - isset($xmlRoot->{'named-native-queries'}) - isset($xmlRoot->{'named-queries'}) isset($xmlRoot->{'one-to-many'}) isset($xmlRoot->{'one-to-one'}) isset($xmlRoot->{'sql-result-set-mappings'}) @@ -906,8 +893,6 @@ addEntityListener addLifecycleCallback - addNamedNativeQuery - addNamedQuery addSqlResultSetMapping enableCache getAssociationCacheDefaults @@ -991,25 +976,6 @@ $indexName - - - $name - $query - $resultClass - $resultSetMapping - - - - - $value - - - - - $name - $query - - $cascade diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 40db66982e5..c5612f34410 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -107,21 +107,11 @@ public function createQuery(string $dql = ''): Query return $this->realEntityManager->createQuery($dql); } - public function createNamedQuery(string $name): Query - { - return $this->realEntityManager->createNamedQuery($name); - } - public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery { return $this->realEntityManager->createNativeQuery($sql, $rsm); } - public function createNamedNativeQuery(string $name): NativeQuery - { - return $this->realEntityManager->createNamedNativeQuery($name); - } - public function createQueryBuilder(): QueryBuilder { return $this->realEntityManager->createQueryBuilder(); diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index d795725c127..9a60f6fb597 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -16,8 +16,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\NamedNativeQueries; -use Doctrine\ORM\Mapping\NamedNativeQuery; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\SqlResultSetMapping; use Doctrine\ORM\Mapping\SqlResultSetMappings; @@ -28,23 +26,6 @@ * * @Entity * @Table(name="cms_addresses") - * @NamedNativeQueries({ - * @NamedNativeQuery( - * name = "find-all", - * resultSetMapping = "mapping-find-all", - * query = "SELECT id, country, city FROM cms_addresses" - * ), - * @NamedNativeQuery( - * name = "find-by-id", - * resultClass = "CmsAddress", - * query = "SELECT * FROM cms_addresses WHERE id = ?" - * ), - * @NamedNativeQuery( - * name = "count", - * resultSetMapping= "mapping-count", - * query = "SELECT COUNT(*) AS count FROM cms_addresses" - * ) - * }) * @SqlResultSetMappings({ * @SqlResultSetMapping( * name = "mapping-find-all", @@ -193,30 +174,6 @@ public static function loadMetadata(ClassMetadataInfo $metadata): void ] ); - $metadata->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT id, country, city FROM cms_addresses', - 'resultSetMapping' => 'mapping-find-all', - ] - ); - - $metadata->addNamedNativeQuery( - [ - 'name' => 'find-by-id', - 'query' => 'SELECT * FROM cms_addresses WHERE id = ?', - 'resultClass' => self::class, - ] - ); - - $metadata->addNamedNativeQuery( - [ - 'name' => 'count', - 'query' => 'SELECT COUNT(*) AS count FROM cms_addresses', - 'resultSetMapping' => 'mapping-count', - ] - ); - $metadata->addSqlResultSetMapping( [ 'name' => 'mapping-find-all', diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Doctrine/Tests/Models/CMS/CmsUser.php index 549f6983000..c77928ef7c1 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -17,10 +17,6 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; -use Doctrine\ORM\Mapping\NamedNativeQueries; -use Doctrine\ORM\Mapping\NamedNativeQuery; -use Doctrine\ORM\Mapping\NamedQueries; -use Doctrine\ORM\Mapping\NamedQuery; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\SqlResultSetMapping; @@ -30,41 +26,6 @@ /** * @Entity * @Table(name="cms_users") - * @NamedQueries({ - * @NamedQuery(name="all", query="SELECT u FROM __CLASS__ u") - * }) - * @NamedNativeQueries({ - * @NamedNativeQuery( - * name = "fetchIdAndUsernameWithResultClass", - * resultClass = "CmsUser", - * query = "SELECT id, username FROM cms_users WHERE username = ?" - * ), - * @NamedNativeQuery( - * name = "fetchAllColumns", - * resultClass = "CmsUser", - * query = "SELECT * FROM cms_users WHERE username = ?" - * ), - * @NamedNativeQuery( - * name = "fetchJoinedAddress", - * resultSetMapping= "mappingJoinedAddress", - * query = "SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?" - * ), - * @NamedNativeQuery( - * name = "fetchJoinedPhonenumber", - * resultSetMapping= "mappingJoinedPhonenumber", - * query = "SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?" - * ), - * @NamedNativeQuery( - * name = "fetchUserPhonenumberCount", - * resultSetMapping= "mappingUserPhonenumberCount", - * query = "SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username" - * ), - * @NamedNativeQuery( - * name = "fetchMultipleJoinsEntityResults", - * resultSetMapping= "mappingMultipleJoinsEntityResults", - * query = "SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username" - * ), - * }) * @SqlResultSetMappings({ * @SqlResultSetMapping( * name = "mappingJoinedAddress", @@ -342,54 +303,6 @@ public static function loadMetadata(ClassMetadataInfo $metadata): void ['name' => 'cms_users'] ); - $metadata->addNamedNativeQuery( - [ - 'name' => 'fetchIdAndUsernameWithResultClass', - 'query' => 'SELECT id, username FROM cms_users WHERE username = ?', - 'resultClass' => self::class, - ] - ); - - $metadata->addNamedNativeQuery( - [ - 'name' => 'fetchAllColumns', - 'query' => 'SELECT * FROM cms_users WHERE username = ?', - 'resultClass' => self::class, - ] - ); - - $metadata->addNamedNativeQuery( - [ - 'name' => 'fetchJoinedAddress', - 'query' => 'SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', - 'resultSetMapping' => 'mappingJoinedAddress', - ] - ); - - $metadata->addNamedNativeQuery( - [ - 'name' => 'fetchJoinedPhonenumber', - 'query' => 'SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', - 'resultSetMapping' => 'mappingJoinedPhonenumber', - ] - ); - - $metadata->addNamedNativeQuery( - [ - 'name' => 'fetchUserPhonenumberCount', - 'query' => 'SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username', - 'resultSetMapping' => 'mappingUserPhonenumberCount', - ] - ); - - $metadata->addNamedNativeQuery( - [ - 'name' => 'fetchMultipleJoinsEntityResults', - 'resultSetMapping' => 'mappingMultipleJoinsEntityResults', - 'query' => 'SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username', - ] - ); - $metadata->addSqlResultSetMapping( [ 'name' => 'mappingJoinedAddress', diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index e7081f3a925..94bac17462c 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -24,8 +24,6 @@ use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; -use Doctrine\ORM\Mapping\NamedNativeQueries; -use Doctrine\ORM\Mapping\NamedNativeQuery; use Doctrine\ORM\Mapping\SqlResultSetMapping; use Doctrine\ORM\Mapping\SqlResultSetMappings; use Doctrine\ORM\Mapping\Table; @@ -41,18 +39,6 @@ * "flexible" = "CompanyFlexContract", * "flexultra" = "CompanyFlexUltraContract" * }) - * @NamedNativeQueries({ - * @NamedNativeQuery( - * name = "all-contracts", - * resultClass = "__CLASS__", - * query = "SELECT id, completed, discr FROM company_contracts" - * ), - * @NamedNativeQuery( - * name = "all", - * resultClass = "__CLASS__", - * query = "SELECT id, completed, discr FROM company_contracts" - * ), - * }) * @SqlResultSetMappings({ * @SqlResultSetMapping( * name = "mapping-all-contracts", diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index 61bb7e1ab5e..56245813493 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -14,25 +14,11 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; -use Doctrine\ORM\Mapping\NamedNativeQueries; -use Doctrine\ORM\Mapping\NamedNativeQuery; use Doctrine\ORM\Mapping\SqlResultSetMapping; use Doctrine\ORM\Mapping\SqlResultSetMappings; /** * @Entity - * @NamedNativeQueries({ - * @NamedNativeQuery( - * name = "all", - * resultClass = "__CLASS__", - * query = "SELECT id, hoursWorked, discr FROM company_contracts" - * ), - * @NamedNativeQuery( - * name = "all-flex", - * resultClass = "CompanyFlexContract", - * query = "SELECT id, hoursWorked, discr FROM company_contracts" - * ), - * }) * @SqlResultSetMappings({ * @SqlResultSetMapping( * name = "mapping-all-flex", diff --git a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php index 6f6eefaa9a1..a2891ff5057 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php @@ -19,8 +19,6 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; -use Doctrine\ORM\Mapping\NamedNativeQueries; -use Doctrine\ORM\Mapping\NamedNativeQuery; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\SqlResultSetMapping; use Doctrine\ORM\Mapping\SqlResultSetMappings; @@ -38,18 +36,6 @@ * "manager" = "CompanyManager", * "employee" = "CompanyEmployee" * }) - * @NamedNativeQueries({ - * @NamedNativeQuery( - * name = "fetchAllWithResultClass", - * resultClass = "__CLASS__", - * query = "SELECT id, name, discr FROM company_persons ORDER BY name" - * ), - * @NamedNativeQuery( - * name = "fetchAllWithSqlResultSetMapping", - * resultSetMapping= "mappingFetchAll", - * query = "SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name" - * ) - * }) * @SqlResultSetMappings({ * @SqlResultSetMapping( * name = "mappingFetchAll", @@ -159,22 +145,6 @@ public static function loadMetadata(ClassMetadataInfo $metadata): void ['name' => 'company_person'] ); - $metadata->addNamedNativeQuery( - [ - 'name' => 'fetchAllWithResultClass', - 'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name', - 'resultClass' => self::class, - ] - ); - - $metadata->addNamedNativeQuery( - [ - 'name' => 'fetchAllWithSqlResultSetMapping', - 'query' => 'SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name', - 'resultSetMapping' => 'mappingFetchAll', - ] - ); - $metadata->addSqlResultSetMapping( [ 'name' => 'mappingFetchAll', diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 82dbe332f44..a10522bd527 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -17,7 +17,6 @@ use Doctrine\ORM\Mapping\NamingStrategy; use Doctrine\ORM\Mapping\PrePersist; use Doctrine\ORM\Mapping\QuoteStrategy; -use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\DDC753\DDC753CustomRepository; @@ -168,29 +167,6 @@ public function testSetGetMetadataCache(): void self::assertSame($cache, CacheAdapter::wrap($this->configuration->getMetadataCacheImpl())); } - public function testAddGetNamedQuery(): void - { - $dql = 'SELECT u FROM User u'; - $this->configuration->addNamedQuery('QueryName', $dql); - self::assertSame($dql, $this->configuration->getNamedQuery('QueryName')); - $this->expectException(ORMException::class); - $this->expectExceptionMessage('a named query'); - $this->configuration->getNamedQuery('NonExistingQuery'); - } - - public function testAddGetNamedNativeQuery(): void - { - $sql = 'SELECT * FROM user'; - $rsm = $this->createMock(ResultSetMapping::class); - $this->configuration->addNamedNativeQuery('QueryName', $sql, $rsm); - $fetched = $this->configuration->getNamedNativeQuery('QueryName'); - self::assertSame($sql, $fetched[0]); - self::assertSame($rsm, $fetched[1]); - $this->expectException(ORMException::class); - $this->expectExceptionMessage('a named native query'); - $this->configuration->getNamedNativeQuery('NonExistingQuery'); - } - public function testAddGetCustomStringFunction(): void { $this->configuration->addCustomStringFunction('FunctionName', self::class); diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 715510a8a13..5a6e8c3726f 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -12,7 +12,6 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Mapping\ClassMetadataFactory; -use Doctrine\ORM\NativeQuery; use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Query; @@ -94,19 +93,6 @@ public function testCreateNativeQuery(): void self::assertSame('SELECT foo', $query->getSql()); } - /** - * @covers \Doctrine\ORM\EntityManager::createNamedNativeQuery - */ - public function testCreateNamedNativeQuery(): void - { - $rsm = new ResultSetMapping(); - $this->entityManager->getConfiguration()->addNamedNativeQuery('foo', 'SELECT foo', $rsm); - - $query = $this->entityManager->createNamedNativeQuery('foo'); - - self::assertInstanceOf(NativeQuery::class, $query); - } - public function testCreateQueryBuilder(): void { self::assertInstanceOf(QueryBuilder::class, $this->entityManager->createQueryBuilder()); @@ -146,18 +132,6 @@ public function testCreateQuery(): void self::assertEquals('SELECT 1', $q->getDql()); } - /** - * @covers Doctrine\ORM\EntityManager::createNamedQuery - */ - public function testCreateNamedQuery(): void - { - $this->entityManager->getConfiguration()->addNamedQuery('foo', 'SELECT 1'); - - $query = $this->entityManager->createNamedQuery('foo'); - self::assertInstanceOf(Query::class, $query); - self::assertEquals('SELECT 1', $query->getDql()); - } - /** * @psalm-return list */ diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index b9252e68353..45032cc0685 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Exception\InvalidEntityRepository; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Exception\UnrecognizedIdentifierFields; -use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\Persisters\Exception\InvalidOrientation; use Doctrine\ORM\Persisters\Exception\UnrecognizedField; @@ -495,27 +494,6 @@ public function testFindOneAssociationByMagicCall(): void self::assertEquals($addressId, $address->id); } - public function testValidNamedQueryRetrieval(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8592'); - - $repos = $this->_em->getRepository(CmsUser::class); - - $query = $repos->createNamedQuery('all'); - - self::assertInstanceOf(Query::class, $query); - self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL()); - } - - public function testInvalidNamedQueryRetrieval(): void - { - $repos = $this->_em->getRepository(CmsUser::class); - - $this->expectException(MappingException::class); - - $repos->createNamedQuery('invalidNamedQuery'); - } - /** * @group DDC-1087 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index d7b6affa701..7a98e6c9ad9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -16,14 +16,10 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\Tests\DbalTypes\UpperCaseStringType; use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\Company\CompanyContract; -use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\Models\Company\CompanyFixContract; -use Doctrine\Tests\Models\Company\CompanyFlexContract; -use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\CustomType\CustomTypeUpperCase; use Doctrine\Tests\Models\DDC3899\DDC3899FixContract; use Doctrine\Tests\Models\DDC3899\DDC3899User; @@ -367,356 +363,6 @@ public function testUnknownParentAliasThrowsException(): void $users = $query->getResult(); } - /** - * @group DDC-1663 - */ - public function testBasicNativeNamedQueryWithSqlResultSetMapping(): void - { - $user = new CmsUser(); - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $addr = new CmsAddress(); - $addr->country = 'Brazil'; - $addr->zip = 10827; - $addr->city = 'São Paulo'; - - $user->setAddress($addr); - - $this->_em->clear(); - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository(CmsAddress::class); - $query = $repository->createNativeNamedQuery('find-all'); - $result = $query->getResult(); - - self::assertCount(1, $result); - self::assertInstanceOf(CmsAddress::class, $result[0]); - self::assertEquals($addr->id, $result[0]->id); - self::assertEquals($addr->city, $result[0]->city); - self::assertEquals($addr->country, $result[0]->country); - } - - /** - * @group DDC-1663 - */ - public function testBasicNativeNamedQueryWithResultClass(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8592'); - - $user = new CmsUser(); - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $email = new CmsEmail(); - $email->email = 'fabio.bat.silva@gmail.com'; - - $user->setEmail($email); - - $this->_em->clear(); - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository(CmsUser::class); - - $result = $repository->createNativeNamedQuery('fetchIdAndUsernameWithResultClass') - ->setParameter(1, 'FabioBatSilva') - ->getResult(); - - self::assertCount(1, $result); - self::assertInstanceOf(CmsUser::class, $result[0]); - self::assertNull($result[0]->name); - self::assertNull($result[0]->email); - self::assertEquals($user->id, $result[0]->id); - self::assertEquals('FabioBatSilva', $result[0]->username); - - $this->_em->clear(); - - $result = $repository->createNativeNamedQuery('fetchAllColumns') - ->setParameter(1, 'FabioBatSilva') - ->getResult(); - - self::assertCount(1, $result); - self::assertInstanceOf(CmsUser::class, $result[0]); - self::assertEquals($user->id, $result[0]->id); - self::assertEquals('Fabio B. Silva', $result[0]->name); - self::assertEquals('FabioBatSilva', $result[0]->username); - self::assertEquals('dev', $result[0]->status); - self::assertInstanceOf(CmsEmail::class, $result[0]->email); - } - - /** - * @group DDC-1663 - */ - public function testJoinedOneToOneNativeNamedQueryWithResultSetMapping(): void - { - $user = new CmsUser(); - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $addr = new CmsAddress(); - $addr->country = 'Brazil'; - $addr->zip = 10827; - $addr->city = 'São Paulo'; - - $user->setAddress($addr); - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $result = $this->_em->getRepository(CmsUser::class) - ->createNativeNamedQuery('fetchJoinedAddress') - ->setParameter(1, 'FabioBatSilva') - ->getResult(); - - self::assertCount(1, $result); - self::assertInstanceOf(CmsUser::class, $result[0]); - self::assertEquals('Fabio B. Silva', $result[0]->name); - self::assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); - self::assertFalse($result[0]->getPhonenumbers()->isInitialized()); - self::assertInstanceOf(CmsAddress::class, $result[0]->getAddress()); - self::assertEquals($result[0]->getAddress()->getUser(), $result[0]); - self::assertEquals('Brazil', $result[0]->getAddress()->getCountry()); - self::assertEquals(10827, $result[0]->getAddress()->getZipCode()); - self::assertEquals('São Paulo', $result[0]->getAddress()->getCity()); - } - - /** - * @group DDC-1663 - */ - public function testJoinedOneToManyNativeNamedQueryWithResultSetMapping(): void - { - $user = new CmsUser(); - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $phone = new CmsPhonenumber(); - $phone->phonenumber = 424242; - - $user->addPhonenumber($phone); - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository(CmsUser::class); - - $result = $repository->createNativeNamedQuery('fetchJoinedPhonenumber') - ->setParameter(1, 'FabioBatSilva')->getResult(); - - self::assertCount(1, $result); - self::assertInstanceOf(CmsUser::class, $result[0]); - self::assertEquals('Fabio B. Silva', $result[0]->name); - self::assertInstanceOf(PersistentCollection::class, $result[0]->getPhonenumbers()); - self::assertTrue($result[0]->getPhonenumbers()->isInitialized()); - self::assertCount(1, $result[0]->getPhonenumbers()); - $phones = $result[0]->getPhonenumbers(); - self::assertEquals(424242, $phones[0]->phonenumber); - self::assertSame($phones[0]->getUser(), $result[0]); - } - - /** - * @group DDC-1663 - */ - public function testMixedNativeNamedQueryNormalJoin(): void - { - $user1 = new CmsUser(); - $user1->name = 'Fabio B. Silva'; - $user1->username = 'FabioBatSilva'; - $user1->status = 'dev'; - - $user2 = new CmsUser(); - $user2->name = 'test tester'; - $user2->username = 'test'; - $user2->status = 'tester'; - - $phone1 = new CmsPhonenumber(); - $phone2 = new CmsPhonenumber(); - $phone3 = new CmsPhonenumber(); - $phone1->phonenumber = 11111111; - $phone2->phonenumber = 22222222; - $phone3->phonenumber = 33333333; - - $user1->addPhonenumber($phone1); - $user1->addPhonenumber($phone2); - $user2->addPhonenumber($phone3); - - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository(CmsUser::class); - - $result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount') - ->setParameter(1, ['test', 'FabioBatSilva'])->getResult(); - - self::assertCount(2, $result); - self::assertIsArray($result[0]); - self::assertIsArray($result[1]); - - // first user => 2 phonenumbers - self::assertInstanceOf(CmsUser::class, $result[0][0]); - self::assertEquals('Fabio B. Silva', $result[0][0]->name); - self::assertEquals(2, $result[0]['numphones']); - - // second user => 1 phonenumbers - self::assertInstanceOf(CmsUser::class, $result[1][0]); - self::assertEquals('test tester', $result[1][0]->name); - self::assertEquals(1, $result[1]['numphones']); - } - - /** - * @group DDC-1663 - */ - public function testNativeNamedQueryInheritance(): void - { - $person = new CompanyPerson(); - $person->setName('Fabio B. Silva'); - - $employee = new CompanyEmployee(); - $employee->setName('Fabio Silva'); - $employee->setSalary(100000); - $employee->setDepartment('IT'); - - $this->_em->persist($person); - $this->_em->persist($employee); - - $this->_em->flush(); - $this->_em->clear(); - - $repository = $this->_em->getRepository(CompanyPerson::class); - - $result = $repository->createNativeNamedQuery('fetchAllWithSqlResultSetMapping') - ->getResult(); - - self::assertCount(2, $result); - self::assertInstanceOf(CompanyPerson::class, $result[0]); - self::assertInstanceOf(CompanyEmployee::class, $result[1]); - self::assertIsNumeric($result[0]->getId()); - self::assertIsNumeric($result[1]->getId()); - self::assertEquals('Fabio B. Silva', $result[0]->getName()); - self::assertEquals('Fabio Silva', $result[1]->getName()); - - $this->_em->clear(); - - $result = $repository->createNativeNamedQuery('fetchAllWithResultClass') - ->getResult(); - - self::assertCount(2, $result); - self::assertInstanceOf(CompanyPerson::class, $result[0]); - self::assertInstanceOf(CompanyEmployee::class, $result[1]); - self::assertIsNumeric($result[0]->getId()); - self::assertIsNumeric($result[1]->getId()); - self::assertEquals('Fabio B. Silva', $result[0]->getName()); - self::assertEquals('Fabio Silva', $result[1]->getName()); - } - - /** - * @group DDC-1663 - * DQL : SELECT u, a, COUNT(p) AS numphones FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.address a JOIN u.phonenumbers p - */ - public function testMultipleEntityResults(): void - { - $user = new CmsUser(); - $user->name = 'Fabio B. Silva'; - $user->username = 'FabioBatSilva'; - $user->status = 'dev'; - - $addr = new CmsAddress(); - $addr->country = 'Brazil'; - $addr->zip = 10827; - $addr->city = 'São Paulo'; - - $phone = new CmsPhonenumber(); - $phone->phonenumber = 424242; - - $user->setAddress($addr); - $user->addPhonenumber($phone); - - $this->_em->clear(); - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - - $repository = $this->_em->getRepository(CmsUser::class); - $query = $repository->createNativeNamedQuery('fetchMultipleJoinsEntityResults'); - $result = $query->getResult(); - - self::assertCount(1, $result); - self::assertIsArray($result[0]); - self::assertInstanceOf(CmsUser::class, $result[0][0]); - self::assertEquals('Fabio B. Silva', $result[0][0]->name); - self::assertInstanceOf(CmsAddress::class, $result[0][0]->getAddress()); - self::assertEquals($result[0][0]->getAddress()->getUser(), $result[0][0]); - self::assertEquals('Brazil', $result[0][0]->getAddress()->getCountry()); - self::assertEquals(10827, $result[0][0]->getAddress()->getZipCode()); - - self::assertEquals(1, $result[0]['numphones']); - } - - /** - * @group DDC-1663 - */ - public function testNamedNativeQueryInheritance(): void - { - $contractMetadata = $this->_em->getClassMetadata(CompanyContract::class); - $flexMetadata = $this->_em->getClassMetadata(CompanyFlexContract::class); - - $contractQueries = $contractMetadata->getNamedNativeQueries(); - $flexQueries = $flexMetadata->getNamedNativeQueries(); - - $contractMappings = $contractMetadata->getSqlResultSetMappings(); - $flexMappings = $flexMetadata->getSqlResultSetMappings(); - - // contract queries - self::assertEquals('all-contracts', $contractQueries['all-contracts']['name']); - self::assertEquals(CompanyContract::class, $contractQueries['all-contracts']['resultClass']); - - self::assertEquals('all', $contractQueries['all']['name']); - self::assertEquals(CompanyContract::class, $contractQueries['all']['resultClass']); - - // flex contract queries - self::assertEquals('all-contracts', $flexQueries['all-contracts']['name']); - self::assertEquals(CompanyFlexContract::class, $flexQueries['all-contracts']['resultClass']); - - self::assertEquals('all-flex', $flexQueries['all-flex']['name']); - self::assertEquals(CompanyFlexContract::class, $flexQueries['all-flex']['resultClass']); - - self::assertEquals('all', $flexQueries['all']['name']); - self::assertEquals(CompanyFlexContract::class, $flexQueries['all']['resultClass']); - - // contract result mapping - self::assertEquals('mapping-all-contracts', $contractMappings['mapping-all-contracts']['name']); - self::assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); - - self::assertEquals('mapping-all', $contractMappings['mapping-all']['name']); - self::assertEquals(CompanyContract::class, $contractMappings['mapping-all-contracts']['entities'][0]['entityClass']); - - // flex contract result mapping - self::assertEquals('mapping-all-contracts', $flexMappings['mapping-all-contracts']['name']); - self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-contracts']['entities'][0]['entityClass']); - - self::assertEquals('mapping-all', $flexMappings['mapping-all']['name']); - self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all']['entities'][0]['entityClass']); - - self::assertEquals('mapping-all-flex', $flexMappings['mapping-all-flex']['name']); - self::assertEquals(CompanyFlexContract::class, $flexMappings['mapping-all-flex']['entities'][0]['entityClass']); - } - /** * @group DDC-2055 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php deleted file mode 100644 index 90c24e6b341..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php +++ /dev/null @@ -1,123 +0,0 @@ -_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1404ParentEntity::class), - $this->_em->getClassMetadata(DDC1404ChildEntity::class), - ] - ); - - $this->loadFixtures(); - } catch (Exception $exc) { - } - } - - public function testTicket(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8592'); - - $repository = $this->_em->getRepository(DDC1404ChildEntity::class); - $queryAll = $repository->createNamedQuery('all'); - $queryFirst = $repository->createNamedQuery('first'); - $querySecond = $repository->createNamedQuery('second'); - - self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p', $queryAll->getDQL()); - self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 1', $queryFirst->getDQL()); - self::assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 2', $querySecond->getDQL()); - - self::assertCount(2, $queryAll->getResult()); - self::assertCount(1, $queryFirst->getResult()); - self::assertCount(1, $querySecond->getResult()); - } - - public function loadFixtures(): void - { - $c1 = new DDC1404ChildEntity('ChildEntity 1'); - $c2 = new DDC1404ChildEntity('ChildEntity 2'); - - $this->_em->persist($c1); - $this->_em->persist($c2); - - $this->_em->flush(); - } -} - -/** - * @MappedSuperclass - * @NamedQueries({ - * @NamedQuery(name="all", query="SELECT p FROM __CLASS__ p"), - * @NamedQuery(name="first", query="SELECT p FROM __CLASS__ p WHERE p.id = 1"), - * }) - */ -class DDC1404ParentEntity -{ - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue() - */ - protected $id; - - public function getId(): int - { - return $this->id; - } -} - -/** - * @Entity - * @NamedQueries({ - * @NamedQuery(name="first", query="SELECT p FROM __CLASS__ p WHERE p.id = 1"), - * @NamedQuery(name="second", query="SELECT p FROM __CLASS__ p WHERE p.id = 2") - * }) - */ -class DDC1404ChildEntity extends DDC1404ParentEntity -{ - /** - * @var string - * @Column(type="string") - */ - private $name; - - public function __construct(string $name) - { - $this->name = $name; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): void - { - $this->name = $name; - } -} diff --git a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php index 61cfe8d1ba6..198ac003429 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -5,11 +5,7 @@ namespace Doctrine\Tests\ORM\Hydration; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\ORM\Query\ResultSetMappingBuilder; -use Doctrine\Persistence\Mapping\RuntimeReflectionService; -use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\Legacy\LegacyUser; @@ -94,173 +90,6 @@ public function testFluentInterface(): void self::assertTrue($rms->isMixedResult()); } - /** - * @group DDC-1663 - */ - public function testAddNamedNativeQueryResultSetMapping(): void - { - $cm = new ClassMetadata(CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->mapOneToOne( - [ - 'fieldName' => 'email', - 'targetEntity' => CmsEmail::class, - 'cascade' => ['persist'], - 'inversedBy' => 'user', - 'orphanRemoval' => false, - 'joinColumns' => [ - [ - 'nullable' => true, - 'referencedColumnName' => 'id', - ], - ], - ] - ); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT u.id AS user_id, e.id AS email_id, u.name, e.email, u.id + e.id AS scalarColumn FROM cms_users u INNER JOIN cms_emails e ON e.id = u.email_id', - 'resultSetMapping' => 'find-all', - ] - ); - - $cm->addSqlResultSetMapping( - [ - 'name' => 'find-all', - 'entities' => [ - [ - 'entityClass' => '__CLASS__', - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'user_id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - ], - ], - [ - 'entityClass' => 'CmsEmail', - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'email_id', - ], - [ - 'name' => 'email', - 'column' => 'email', - ], - ], - ], - ], - 'columns' => [ - ['name' => 'scalarColumn'], - ], - ] - ); - - $queryMapping = $cm->getNamedNativeQuery('find-all'); - - $rsm = new ResultSetMappingBuilder($this->entityManager); - $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - - self::assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); - - self::assertEquals('c0', $rsm->getEntityAlias('user_id')); - self::assertEquals('c0', $rsm->getEntityAlias('name')); - self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('user_id')); - - self::assertEquals('c1', $rsm->getEntityAlias('email_id')); - self::assertEquals('c1', $rsm->getEntityAlias('email')); - self::assertEquals(CmsEmail::class, $rsm->getClassName('c1')); - self::assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email')); - self::assertEquals(CmsEmail::class, $rsm->getDeclaringClass('email_id')); - } - - /** - * @group DDC-1663 - */ - public function testAddNamedNativeQueryResultSetMappingWithoutFields(): void - { - $cm = new ClassMetadata(CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT u.id AS user_id, e.id AS email_id, u.name, e.email, u.id + e.id AS scalarColumn FROM cms_users u INNER JOIN cms_emails e ON e.id = u.email_id', - 'resultSetMapping' => 'find-all', - ] - ); - - $cm->addSqlResultSetMapping( - [ - 'name' => 'find-all', - 'entities' => [ - ['entityClass' => '__CLASS__'], - ], - 'columns' => [ - ['name' => 'scalarColumn'], - ], - ] - ); - - $queryMapping = $cm->getNamedNativeQuery('find-all'); - $rsm = new ResultSetMappingBuilder($this->entityManager); - - $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - - self::assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); - self::assertEquals('c0', $rsm->getEntityAlias('id')); - self::assertEquals('c0', $rsm->getEntityAlias('name')); - self::assertEquals('c0', $rsm->getEntityAlias('status')); - self::assertEquals('c0', $rsm->getEntityAlias('username')); - self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); - } - - /** - * @group DDC-1663 - */ - public function testAddNamedNativeQueryResultClass(): void - { - $cm = new ClassMetadata(CmsUser::class); - - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'resultClass' => '__CLASS__', - 'query' => 'SELECT * FROM cms_users', - ] - ); - - $queryMapping = $cm->getNamedNativeQuery('find-all'); - $rsm = new ResultSetMappingBuilder($this->entityManager); - - $rsm->addNamedNativeQueryMapping($cm, $queryMapping); - - self::assertEquals('c0', $rsm->getEntityAlias('id')); - self::assertEquals('c0', $rsm->getEntityAlias('name')); - self::assertEquals('c0', $rsm->getEntityAlias('status')); - self::assertEquals('c0', $rsm->getEntityAlias('username')); - self::assertEquals(CmsUser::class, $rsm->getClassName('c0')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('id')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('name')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('status')); - self::assertEquals(CmsUser::class, $rsm->getDeclaringClass('username')); - } - /** * @group DDC-117 */ diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 7c11c009811..77e4a73914b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -26,8 +26,6 @@ use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\MappingException; -use Doctrine\ORM\Mapping\NamedQueries; -use Doctrine\ORM\Mapping\NamedQuery; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\OrderBy; @@ -74,8 +72,6 @@ use function assert; use function count; -use function get_debug_type; -use function sprintf; use function strpos; use function strtolower; @@ -630,64 +626,6 @@ public function testIdentifierRequiredShouldMentionParentClasses(): void $factory->getMetadataFor(DDC889Entity::class); } - public function testNamedQuery(): void - { - $driver = $this->loadDriver(); - $class = $this->createClassMetadata(User::class); - - self::assertCount(1, $class->getNamedQueries(), sprintf('Named queries not processed correctly by driver %s', get_debug_type($driver))); - } - - /** - * @group DDC-1663 - */ - public function testNamedNativeQuery(): void - { - $class = $this->createClassMetadata(CmsAddress::class); - - //named native query - self::assertCount(3, $class->namedNativeQueries); - self::assertArrayHasKey('find-all', $class->namedNativeQueries); - self::assertArrayHasKey('find-by-id', $class->namedNativeQueries); - - $findAllQuery = $class->getNamedNativeQuery('find-all'); - self::assertEquals('find-all', $findAllQuery['name']); - self::assertEquals('mapping-find-all', $findAllQuery['resultSetMapping']); - self::assertEquals('SELECT id, country, city FROM cms_addresses', $findAllQuery['query']); - - $findByIdQuery = $class->getNamedNativeQuery('find-by-id'); - self::assertEquals('find-by-id', $findByIdQuery['name']); - self::assertEquals(CmsAddress::class, $findByIdQuery['resultClass']); - self::assertEquals('SELECT * FROM cms_addresses WHERE id = ?', $findByIdQuery['query']); - - $countQuery = $class->getNamedNativeQuery('count'); - self::assertEquals('count', $countQuery['name']); - self::assertEquals('mapping-count', $countQuery['resultSetMapping']); - self::assertEquals('SELECT COUNT(*) AS count FROM cms_addresses', $countQuery['query']); - - // result set mapping - self::assertCount(3, $class->sqlResultSetMappings); - self::assertArrayHasKey('mapping-count', $class->sqlResultSetMappings); - self::assertArrayHasKey('mapping-find-all', $class->sqlResultSetMappings); - self::assertArrayHasKey('mapping-without-fields', $class->sqlResultSetMappings); - - $findAllMapping = $class->getSqlResultSetMapping('mapping-find-all'); - self::assertEquals('mapping-find-all', $findAllMapping['name']); - self::assertEquals(CmsAddress::class, $findAllMapping['entities'][0]['entityClass']); - self::assertEquals(['name' => 'id', 'column' => 'id'], $findAllMapping['entities'][0]['fields'][0]); - self::assertEquals(['name' => 'city', 'column' => 'city'], $findAllMapping['entities'][0]['fields'][1]); - self::assertEquals(['name' => 'country', 'column' => 'country'], $findAllMapping['entities'][0]['fields'][2]); - - $withoutFieldsMapping = $class->getSqlResultSetMapping('mapping-without-fields'); - self::assertEquals('mapping-without-fields', $withoutFieldsMapping['name']); - self::assertEquals(CmsAddress::class, $withoutFieldsMapping['entities'][0]['entityClass']); - self::assertEquals([], $withoutFieldsMapping['entities'][0]['fields']); - - $countMapping = $class->getSqlResultSetMapping('mapping-count'); - self::assertEquals('mapping-count', $countMapping['name']); - self::assertEquals(['name' => 'count'], $countMapping['columns'][0]); - } - /** * @group DDC-1663 */ @@ -1187,7 +1125,6 @@ public function testEnumType(): void * indexes={@Index(name="name_idx", columns={"name"}), @Index(name="0", columns={"user_email"}), @index(name="fields", fields={"name", "email"})}, * options={"foo": "bar", "baz": {"key": "val"}} * ) - * @NamedQueries({@NamedQuery(name="all", query="SELECT u FROM __CLASS__ u")}) */ #[ORM\Entity(), ORM\HasLifecycleCallbacks()] #[ORM\Table(name: 'cms_users', options: ['foo' => 'bar', 'baz' => ['key' => 'val']])] @@ -1417,12 +1354,6 @@ public static function loadMetadata(ClassMetadataInfo $metadata): void 'initialValue' => 1, ] ); - $metadata->addNamedQuery( - [ - 'name' => 'all', - 'query' => 'SELECT u FROM __CLASS__ u', - ] - ); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 1ef6f60cc32..73e27ecc253 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -30,16 +30,6 @@ protected function loadDriver(): MappingDriver return new AttributeDriver($paths); } - public function testNamedQuery(): void - { - self::markTestSkipped('AttributeDriver does not support named queries.'); - } - - public function testNamedNativeQuery(): void - { - self::markTestSkipped('AttributeDriver does not support named native queries.'); - } - public function testSqlResultSetMapping(): void { self::markTestSkipped('AttributeDriver does not support named sql resultset mapping.'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index b75523ec57d..4e25cb7511a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -68,7 +68,6 @@ public function testClassMetadataInstanceSerialization(): void $cm->mapOneToOne(['fieldName' => 'phonenumbers', 'targetEntity' => 'CmsAddress', 'mappedBy' => 'foo']); $cm->markReadOnly(); $cm->mapField(['fieldName' => 'status', 'notInsertable' => true, 'generated' => ClassMetadata::GENERATED_ALWAYS]); - $cm->addNamedQuery(['name' => 'dql', 'query' => 'foo']); self::assertTrue($cm->requiresFetchAfterChange); self::assertEquals(1, count($cm->associationMappings)); @@ -94,7 +93,6 @@ public function testClassMetadataInstanceSerialization(): void self::assertEquals('phonenumbers', $oneOneMapping['fieldName']); self::assertEquals(CMS\CmsAddress::class, $oneOneMapping['targetEntity']); self::assertTrue($cm->isReadOnly); - self::assertEquals(['dql' => ['name' => 'dql', 'query' => 'foo', 'dql' => 'foo']], $cm->namedQueries); self::assertTrue($cm->requiresFetchAfterChange); } @@ -630,23 +628,6 @@ public function testEmptyFieldNameThrowsException(): void $cm->mapField(['fieldName' => '']); } - public function testRetrievalOfNamedQueries(): void - { - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - self::assertCount(0, $cm->getNamedQueries()); - - $cm->addNamedQuery( - [ - 'name' => 'userById', - 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1', - ] - ); - - self::assertCount(1, $cm->getNamedQueries()); - } - /** * @group DDC-1663 */ @@ -671,59 +652,6 @@ public function testRetrievalOfResultSetMappings(): void self::assertCount(1, $cm->getSqlResultSetMappings()); } - public function testExistanceOfNamedQuery(): void - { - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addNamedQuery( - [ - 'name' => 'all', - 'query' => 'SELECT u FROM __CLASS__ u', - ] - ); - - self::assertTrue($cm->hasNamedQuery('all')); - self::assertFalse($cm->hasNamedQuery('userById')); - } - - /** - * @group DDC-1663 - */ - public function testRetrieveOfNamedNativeQuery(): void - { - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultSetMapping' => 'result-mapping-name', - 'resultClass' => CMS\CmsUser::class, - ] - ); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-by-id', - 'query' => 'SELECT * FROM cms_users WHERE id = ?', - 'resultClass' => '__CLASS__', - 'resultSetMapping' => 'result-mapping-name', - ] - ); - - $mapping = $cm->getNamedNativeQuery('find-all'); - self::assertEquals('SELECT * FROM cms_users', $mapping['query']); - self::assertEquals('result-mapping-name', $mapping['resultSetMapping']); - self::assertEquals(CMS\CmsUser::class, $mapping['resultClass']); - - $mapping = $cm->getNamedNativeQuery('find-by-id'); - self::assertEquals('SELECT * FROM cms_users WHERE id = ?', $mapping['query']); - self::assertEquals('result-mapping-name', $mapping['resultSetMapping']); - self::assertEquals(CMS\CmsUser::class, $mapping['resultClass']); - } - /** * @group DDC-1663 */ @@ -782,87 +710,6 @@ public function testRetrieveOfSqlResultSetMapping(): void self::assertEquals('scalarColumn', $mapping['columns'][0]['name']); } - /** - * @group DDC-1663 - */ - public function testExistanceOfSqlResultSetMapping(): void - { - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addSqlResultSetMapping( - [ - 'name' => 'find-all', - 'entities' => [ - [ - 'entityClass' => CMS\CmsUser::class, - ], - ], - ] - ); - - self::assertTrue($cm->hasSqlResultSetMapping('find-all')); - self::assertFalse($cm->hasSqlResultSetMapping('find-by-id')); - } - - /** - * @group DDC-1663 - */ - public function testExistanceOfNamedNativeQuery(): void - { - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => CMS\CmsUser::class, - 'resultSetMapping' => 'result-mapping-name', - ] - ); - - self::assertTrue($cm->hasNamedNativeQuery('find-all')); - self::assertFalse($cm->hasNamedNativeQuery('find-by-id')); - } - - public function testRetrieveOfNamedQuery(): void - { - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addNamedQuery( - [ - 'name' => 'userById', - 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1', - ] - ); - - self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', $cm->getNamedQuery('userById')); - } - - /** - * @group DDC-1663 - */ - public function testRetrievalOfNamedNativeQueries(): void - { - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - self::assertCount(0, $cm->getNamedNativeQueries()); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => CMS\CmsUser::class, - 'resultSetMapping' => 'result-mapping-name', - ] - ); - - self::assertCount(1, $cm->getNamedNativeQueries()); - } - /** * @group DDC-2451 */ @@ -880,57 +727,6 @@ public function testSerializeEntityListeners(): void self::assertEquals($metadata->entityListeners, $unserialize->entityListeners); } - public function testNamingCollisionNamedQueryShouldThrowException(): void - { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); - $this->expectExceptionMessage('Query named "userById" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once'); - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addNamedQuery( - [ - 'name' => 'userById', - 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1', - ] - ); - - $cm->addNamedQuery( - [ - 'name' => 'userById', - 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1', - ] - ); - } - - /** - * @group DDC-1663 - */ - public function testNamingCollisionNamedNativeQueryShouldThrowException(): void - { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); - $this->expectExceptionMessage('Query named "find-all" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once'); - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => CMS\CmsUser::class, - 'resultSetMapping' => 'result-mapping-name', - ] - ); - - $cm->addNamedNativeQuery( - [ - 'name' => 'find-all', - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => CMS\CmsUser::class, - 'resultSetMapping' => 'result-mapping-name', - ] - ); - } - /** * @group DDC-1663 */ @@ -1006,38 +802,6 @@ public function testTargetEntityNotFound(): void $cm->validateAssociations(); } - /** - * @group DDC-1663 - */ - public function testNameIsMandatoryForNamedQueryMappingException(): void - { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); - $this->expectExceptionMessage('Query name on entity class \'Doctrine\Tests\Models\CMS\CmsUser\' is not defined.'); - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - $cm->addNamedQuery( - ['query' => 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'] - ); - } - - /** - * @group DDC-1663 - */ - public function testNameIsMandatoryForNameNativeQueryMappingException(): void - { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); - $this->expectExceptionMessage('Query name on entity class \'Doctrine\Tests\Models\CMS\CmsUser\' is not defined.'); - $cm = new ClassMetadata(CMS\CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - $cm->addNamedQuery( - [ - 'query' => 'SELECT * FROM cms_users', - 'resultClass' => CMS\CmsUser::class, - 'resultSetMapping' => 'result-mapping-name', - ] - ); - } - /** * @group DDC-1663 */ diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml index fb8bdb40491..1e61b508b0e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml @@ -9,20 +9,6 @@ - - - SELECT id, country, city FROM cms_addresses - - - - SELECT * FROM cms_addresses WHERE id = ? - - - - SELECT COUNT(*) AS count FROM cms_addresses - - - diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml index f91ed311512..8a8e6e1fc64 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml @@ -6,37 +6,6 @@ https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - - - - - - - - SELECT id, username FROM cms_users WHERE username = ? - - - - SELECT * FROM cms_users WHERE username = ? - - - - SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ? - - - - SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ? - - - - SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username - - - - SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username - - - diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml index daa94cd2cea..7ad91a9ebc0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml @@ -13,16 +13,6 @@ - - - SELECT id, name, discr FROM company_persons ORDER BY name - - - - SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name - - - diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml index 5343d040e16..6abbf8c52b6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml @@ -34,10 +34,6 @@ - - - - From e7e9db8cee89a2aac5f178ef87df9b16e4529485 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 31 Jan 2022 09:11:39 +0100 Subject: [PATCH 040/475] Remove deprecated Setup class (#9447) --- UPGRADE.md | 14 ++ docs/en/reference/configuration.rst | 5 - lib/Doctrine/ORM/Configuration.php | 50 ----- lib/Doctrine/ORM/Tools/Setup.php | 210 ------------------ phpstan-baseline.neon | 5 - psalm-baseline.xml | 7 - psalm.xml | 2 - .../Doctrine/Tests/ORM/ConfigurationTest.php | 23 -- tests/Doctrine/Tests/ORM/Tools/SetupTest.php | 151 ------------- 9 files changed, 14 insertions(+), 453 deletions(-) delete mode 100644 lib/Doctrine/ORM/Tools/Setup.php delete mode 100644 tests/Doctrine/Tests/ORM/Tools/SetupTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 64fcebe309d..75cdb7cf4e4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,19 @@ # Upgrade to 3.0 +## BC BREAK: Remove `Doctrine\ORM\Configuration::newDefaultAnnotationDriver` + +This functionality has been moved to the new `DoctrineSetup` class. Call +`Doctrine\ORM\Tools\DoctrineSetup::createDefaultAnnotationDriver()` to create +a new annotation driver. + +## BC BREAK: Remove `Doctrine\ORM\Tools\Setup` + +In our effort to migrate from Doctrine Cache to PSR-6, the `Setup` class which +accepted a Doctrine Cache instance in each method has been removed. + +The replacement is `Doctrine\ORM\Tools\DoctrineSetup` which accepts a PSR-6 +cache instead. + ## BC BREAK: Removed named queries All APIs related to named queries have been removed. diff --git a/docs/en/reference/configuration.rst b/docs/en/reference/configuration.rst index f0c8e6ed7c4..8b693a274fd 100644 --- a/docs/en/reference/configuration.rst +++ b/docs/en/reference/configuration.rst @@ -58,11 +58,6 @@ access point to ORM functionality provided by Doctrine. $config = DoctrineSetup::createAnnotationMetadataConfiguration($paths, $isDevMode); $entityManager = EntityManager::create($dbParams, $config); -.. note:: - - The ``DoctrineSetup`` class has been introduced with ORM 2.12. It's predecessor ``Setup`` is deprecated and will - be removed in version 3.0. - Or if you prefer XML: .. code-block:: php diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 9ceb460ca05..215093364a4 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -4,11 +4,6 @@ namespace Doctrine\ORM; -use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\Annotations\AnnotationRegistry; -use Doctrine\Common\Annotations\CachedReader; -use Doctrine\Common\Annotations\SimpleAnnotationReader; -use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\Cache as CacheDriver; use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\Cache\Psr6\DoctrineProvider; @@ -22,19 +17,16 @@ use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; use Doctrine\ORM\Mapping\DefaultNamingStrategy; use Doctrine\ORM\Mapping\DefaultQuoteStrategy; -use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\EntityListenerResolver; use Doctrine\ORM\Mapping\NamingStrategy; use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\ORM\Repository\DefaultRepositoryFactory; use Doctrine\ORM\Repository\RepositoryFactory; -use Doctrine\ORM\Tools\DoctrineSetup; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Persistence\ObjectRepository; use Psr\Cache\CacheItemPoolInterface; use ReflectionClass; -use function class_exists; use function strtolower; use function trim; @@ -141,48 +133,6 @@ public function setMetadataDriverImpl(MappingDriver $driverImpl) $this->_attributes['metadataDriverImpl'] = $driverImpl; } - /** - * Adds a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader - * is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported. - * - * @deprecated Use {@see DoctrineSetup::createDefaultAnnotationDriver()} instead. - * - * @param string|string[] $paths - * @param bool $useSimpleAnnotationReader - * @psalm-param string|list $paths - * - * @return AnnotationDriver - */ - public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9443', - '%s is deprecated, call %s::createDefaultAnnotationDriver() instead.', - __METHOD__, - DoctrineSetup::class - ); - - AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); - - if ($useSimpleAnnotationReader) { - // Register the ORM Annotations in the AnnotationRegistry - $reader = new SimpleAnnotationReader(); - $reader->addNamespace('Doctrine\ORM\Mapping'); - } else { - $reader = new AnnotationReader(); - } - - if (class_exists(ArrayCache::class)) { - $reader = new CachedReader($reader, new ArrayCache()); - } - - return new AnnotationDriver( - $reader, - (array) $paths - ); - } - /** * Adds a namespace under a certain alias. * diff --git a/lib/Doctrine/ORM/Tools/Setup.php b/lib/Doctrine/ORM/Tools/Setup.php deleted file mode 100644 index f53a76a42ae..00000000000 --- a/lib/Doctrine/ORM/Tools/Setup.php +++ /dev/null @@ -1,210 +0,0 @@ -setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths, $useSimpleAnnotationReader)); - - return $config; - } - - /** - * Creates a configuration with an attribute metadata driver. - * - * @param string[] $paths - * @param bool $isDevMode - * @param string|null $proxyDir - */ - public static function createAttributeMetadataConfiguration( - array $paths, - $isDevMode = false, - $proxyDir = null, - ?Cache $cache = null - ): Configuration { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9443', - '%s is deprecated and will be removed in Doctrine 3.0, please use %s instead.', - self::class, - DoctrineSetup::class - ); - - $config = self::createConfiguration($isDevMode, $proxyDir, $cache); - $config->setMetadataDriverImpl(new AttributeDriver($paths)); - - return $config; - } - - /** - * Creates a configuration with an XML metadata driver. - * - * @param string[] $paths - * @param bool $isDevMode - * @param string|null $proxyDir - * - * @return Configuration - */ - public static function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, ?Cache $cache = null) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9443', - '%s is deprecated and will be removed in Doctrine 3.0, please use %s instead.', - self::class, - DoctrineSetup::class - ); - - $config = self::createConfiguration($isDevMode, $proxyDir, $cache); - $config->setMetadataDriverImpl(new XmlDriver($paths)); - - return $config; - } - - /** - * Creates a configuration without a metadata driver. - * - * @param bool $isDevMode - * @param string|null $proxyDir - * - * @return Configuration - */ - public static function createConfiguration($isDevMode = false, $proxyDir = null, ?Cache $cache = null) - { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9443', - '%s is deprecated and will be removed in Doctrine 3.0, please use %s instead.', - self::class, - DoctrineSetup::class - ); - - $proxyDir = $proxyDir ?: sys_get_temp_dir(); - - $cache = self::createCacheConfiguration($isDevMode, $proxyDir, $cache); - - $config = new Configuration(); - - $config->setMetadataCache(CacheAdapter::wrap($cache)); - $config->setQueryCache(CacheAdapter::wrap($cache)); - $config->setResultCache(CacheAdapter::wrap($cache)); - $config->setProxyDir($proxyDir); - $config->setProxyNamespace('DoctrineProxies'); - $config->setAutoGenerateProxyClasses($isDevMode); - - return $config; - } - - private static function createCacheConfiguration(bool $isDevMode, string $proxyDir, ?Cache $cache): Cache - { - $cache = self::createCacheInstance($isDevMode, $cache); - - if (! $cache instanceof CacheProvider) { - return $cache; - } - - $namespace = $cache->getNamespace(); - - if ($namespace !== '') { - $namespace .= ':'; - } - - $cache->setNamespace($namespace . 'dc2_' . md5($proxyDir) . '_'); // to avoid collisions - - return $cache; - } - - private static function createCacheInstance(bool $isDevMode, ?Cache $cache): Cache - { - if ($cache !== null) { - return $cache; - } - - if (! class_exists(ArrayCache::class) && ! class_exists(ArrayAdapter::class)) { - throw new RuntimeException('Setup tool cannot configure caches without doctrine/cache 1.11 or symfony/cache. Please add an explicit dependency to either library.'); - } - - if ($isDevMode === true) { - $cache = class_exists(ArrayCache::class) ? new ArrayCache() : new ArrayAdapter(); - } elseif (extension_loaded('apcu')) { - $cache = class_exists(ApcuCache::class) ? new ApcuCache() : new ApcuAdapter(); - } elseif (extension_loaded('memcached')) { - $memcached = new Memcached(); - $memcached->addServer('127.0.0.1', 11211); - - if (class_exists(MemcachedCache::class)) { - $cache = new MemcachedCache(); - $cache->setMemcached($memcached); - } else { - $cache = new MemcachedAdapter($memcached); - } - } elseif (extension_loaded('redis')) { - $redis = new Redis(); - $redis->connect('127.0.0.1'); - - if (class_exists(RedisCache::class)) { - $cache = new RedisCache(); - $cache->setRedis($redis); - } else { - $cache = new RedisAdapter($redis); - } - } else { - $cache = class_exists(ArrayCache::class) ? new ArrayCache() : new ArrayAdapter(); - } - - return $cache instanceof Cache ? $cache : DoctrineProvider::wrap($cache); - } -} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c744442651d..a3c01197605 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -100,11 +100,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php - - - message: "#^Parameter \\#2 \\$cache of class Doctrine\\\\Common\\\\Annotations\\\\CachedReader constructor expects Doctrine\\\\Common\\\\Cache\\\\Cache, Doctrine\\\\Common\\\\Cache\\\\ArrayCache given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Configuration.php - - message: "#^Method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:flush\\(\\) invoked with 1 parameter, 0 required\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index db0468fa943..753f08b8f02 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -254,13 +254,6 @@ $className $className - - new CachedReader($reader, new ArrayCache()) - new SimpleAnnotationReader() - - - AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php') - (bool) $flag diff --git a/psalm.xml b/psalm.xml index 827e9c8fb2d..231b8546094 100644 --- a/psalm.xml +++ b/psalm.xml @@ -21,8 +21,6 @@ - - diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index a10522bd527..f9920f4d17b 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -21,7 +21,6 @@ use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\DDC753\DDC753CustomRepository; use Psr\Cache\CacheItemPoolInterface; -use ReflectionClass; /** * Tests for the Configuration object @@ -77,28 +76,6 @@ public function testSetGetMetadataDriverImpl(): void self::assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl()); } - public function testNewDefaultAnnotationDriver(): void - { - $paths = [__DIR__]; - $reflectionClass = new ReflectionClass(ConfigurationTestAnnotationReaderChecker::class); - - $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false); - $reader = $annotationDriver->getReader(); - $annotation = $reader->getMethodAnnotation( - $reflectionClass->getMethod('namespacedAnnotationMethod'), - AnnotationNamespace\PrePersist::class - ); - self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); - - $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths); - $reader = $annotationDriver->getReader(); - $annotation = $reader->getMethodAnnotation( - $reflectionClass->getMethod('simpleAnnotationMethod'), - AnnotationNamespace\PrePersist::class - ); - self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); - } - public function testSetGetEntityNamespace(): void { $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8818'); diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php deleted file mode 100644 index 4640fddaf57..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ /dev/null @@ -1,151 +0,0 @@ -originalAutoloaderCount = count(spl_autoload_functions()); - $this->originalIncludePath = get_include_path(); - } - - public function tearDown(): void - { - if (! $this->originalIncludePath) { - return; - } - - set_include_path($this->originalIncludePath); - $loaders = spl_autoload_functions(); - $numberOfLoaders = count($loaders); - for ($i = 0; $i < $numberOfLoaders; $i++) { - if ($i > $this->originalAutoloaderCount + 1) { - spl_autoload_unregister($loaders[$i]); - } - } - } - - public function testAnnotationConfiguration(): void - { - $config = Setup::createAnnotationMetadataConfiguration([], true); - - self::assertInstanceOf(Configuration::class, $config); - self::assertEquals(sys_get_temp_dir(), $config->getProxyDir()); - self::assertEquals('DoctrineProxies', $config->getProxyNamespace()); - self::assertInstanceOf(AnnotationDriver::class, $config->getMetadataDriverImpl()); - } - - /** - * @requires PHP >= 8.0 - */ - public function testAttributeConfiguration(): void - { - $config = Setup::createAttributeMetadataConfiguration([], true); - - self::assertInstanceOf(Configuration::class, $config); - self::assertEquals(sys_get_temp_dir(), $config->getProxyDir()); - self::assertEquals('DoctrineProxies', $config->getProxyNamespace()); - self::assertInstanceOf(AttributeDriver::class, $config->getMetadataDriverImpl()); - } - - public function testXMLConfiguration(): void - { - $config = Setup::createXMLMetadataConfiguration([], true); - - self::assertInstanceOf(Configuration::class, $config); - self::assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); - } - - /** - * @group 5904 - */ - public function testCacheNamespaceShouldBeGeneratedWhenCacheIsGivenButHasNoNamespace(): void - { - $config = Setup::createConfiguration(false, '/foo', DoctrineProvider::wrap(new ArrayAdapter())); - $cache = $config->getMetadataCacheImpl(); - - self::assertSame('dc2_1effb2475fcfba4f9e8b8a1dbc8f3caf_', $cache->getNamespace()); - } - - /** - * @group 5904 - */ - public function testConfiguredCacheNamespaceShouldBeUsedAsPrefixOfGeneratedNamespace(): void - { - $originalCache = DoctrineProvider::wrap(new ArrayAdapter()); - $originalCache->setNamespace('foo'); - - $config = Setup::createConfiguration(false, '/foo', $originalCache); - $cache = $config->getMetadataCacheImpl(); - self::assertSame($originalCache, $cache); - self::assertSame('foo:dc2_1effb2475fcfba4f9e8b8a1dbc8f3caf_', $cache->getNamespace()); - } - - /** - * @group DDC-1350 - */ - public function testConfigureProxyDir(): void - { - $config = Setup::createAnnotationMetadataConfiguration([], true, '/foo'); - self::assertEquals('/foo', $config->getProxyDir()); - } - - /** - * @group DDC-1350 - */ - public function testConfigureCache(): void - { - $adapter = new ArrayAdapter(); - $cache = DoctrineProvider::wrap($adapter); - $config = Setup::createAnnotationMetadataConfiguration([], true, null, $cache); - - self::assertSame($adapter, $config->getResultCache()->getCache()->getPool()); - self::assertSame($cache, $config->getResultCacheImpl()); - self::assertSame($adapter, $config->getQueryCache()->getCache()->getPool()); - self::assertSame($cache, $config->getQueryCacheImpl()); - - self::assertSame($adapter, $config->getMetadataCache()->getCache()->getPool()); - } - - /** - * @group DDC-3190 - */ - public function testConfigureCacheCustomInstance(): void - { - $adapter = new ArrayAdapter(); - $cache = DoctrineProvider::wrap($adapter); - $config = Setup::createConfiguration(true, null, $cache); - - self::assertSame($adapter, $config->getResultCache()->getCache()->getPool()); - self::assertSame($cache, $config->getResultCacheImpl()); - self::assertSame($adapter, $config->getQueryCache()->getCache()->getPool()); - self::assertSame($cache, $config->getQueryCacheImpl()); - - self::assertSame($adapter, $config->getMetadataCache()->getCache()->getPool()); - } -} From 4244dfe0a28da83d840393e73913aa9b0dbc51a8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 31 Jan 2022 22:42:21 +0100 Subject: [PATCH 041/475] Add more native types to entity manager implementations (#9450) --- .../ORM/Decorator/EntityManagerDecorator.php | 5 +-- lib/Doctrine/ORM/EntityManager.php | 44 +++++-------------- lib/Doctrine/ORM/EntityManagerInterface.php | 2 +- phpstan-baseline.neon | 5 --- psalm-baseline.xml | 6 --- .../Mock/NonProxyLoadingEntityManager.php | 5 +-- .../Doctrine/Tests/ORM/EntityManagerTest.php | 12 ----- 7 files changed, 15 insertions(+), 64 deletions(-) diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index ee27d4d2f54..d7b54dee7ba 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -68,10 +68,7 @@ public function beginTransaction(): void $this->wrapped->beginTransaction(); } - /** - * {@inheritdoc} - */ - public function wrapInTransaction(callable $func) + public function wrapInTransaction(callable $func): mixed { return $this->wrapped->wrapInTransaction($func); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 97babe24c6d..153b8e462d9 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -9,10 +9,12 @@ use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\LockMode; use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Exception\InvalidHydrationMode; +use Doctrine\ORM\Exception\ManagerException; use Doctrine\ORM\Exception\MismatchedEventManager; use Doctrine\ORM\Exception\MissingIdentifierField; use Doctrine\ORM\Exception\MissingMappingDriverImplementation; @@ -28,16 +30,13 @@ use Doctrine\ORM\Repository\RepositoryFactory; use Doctrine\Persistence\Mapping\MappingException; use Doctrine\Persistence\ObjectRepository; -use InvalidArgumentException; use Throwable; use function array_keys; -use function get_debug_type; use function is_array; use function is_object; use function is_string; use function ltrim; -use function sprintf; /** * The EntityManager is the central access point to ORM functionality. @@ -179,10 +178,7 @@ public function getCache(): ?Cache return $this->cache; } - /** - * {@inheritDoc} - */ - public function wrapInTransaction(callable $func) + public function wrapInTransaction(callable $func): mixed { $this->conn->beginTransaction(); @@ -728,17 +724,13 @@ public function initializeObject($obj): void /** * Factory method to create EntityManager instances. * - * @param mixed[]|Connection $connection An array with the connection parameters or an existing Connection instance. - * @param Configuration $config The Configuration instance to use. - * @param EventManager|null $eventManager The EventManager instance to use. + * @param mixed[]|Connection $connection An array with the connection parameters or an existing Connection instance. * @psalm-param array|Connection $connection * - * @return EntityManager The created EntityManager. - * - * @throws InvalidArgumentException - * @throws ORMException + * @throws DBALException + * @throws ManagerException */ - public static function create($connection, Configuration $config, ?EventManager $eventManager = null): EntityManager + public static function create(array|Connection $connection, Configuration $config, ?EventManager $eventManager = null): EntityManager { if (! $config->getMetadataDriverImpl()) { throw MissingMappingDriverImplementation::create(); @@ -752,28 +744,16 @@ public static function create($connection, Configuration $config, ?EventManager /** * Factory method to create Connection instances. * - * @param mixed[]|Connection $connection An array with the connection parameters or an existing Connection instance. - * @param Configuration $config The Configuration instance to use. - * @param EventManager|null $eventManager The EventManager instance to use. + * @param mixed[]|Connection $connection An array with the connection parameters or an existing Connection instance. * @psalm-param array|Connection $connection * - * @throws InvalidArgumentException - * @throws ORMException + * @throws DBALException + * @throws ManagerException */ - protected static function createConnection($connection, Configuration $config, ?EventManager $eventManager = null): Connection + protected static function createConnection(array|Connection $connection, Configuration $config, ?EventManager $eventManager = null): Connection { if (is_array($connection)) { - return DriverManager::getConnection($connection, $config, $eventManager ?: new EventManager()); - } - - if (! $connection instanceof Connection) { - throw new InvalidArgumentException( - sprintf( - 'Invalid $connection argument of type %s given%s.', - get_debug_type($connection), - is_object($connection) ? '' : ': "' . $connection . '"' - ) - ); + return DriverManager::getConnection($connection, $config, $eventManager ?? new EventManager()); } if ($eventManager !== null && $connection->getEventManager() !== $eventManager) { diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index 19c13b4e8e6..ee9fa2ca1a2 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -78,7 +78,7 @@ public function beginTransaction(): void; * * @template T */ - public function wrapInTransaction(callable $func); + public function wrapInTransaction(callable $func): mixed; /** * Commits a transaction on the underlying database connection. diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a3c01197605..0baafd0390a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -115,11 +115,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php - - - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" - count: 1 - path: lib/Doctrine/ORM/EntityManager.php - - message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:find\\(\\) should return T of object\\|null but returns object\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 753f08b8f02..05edeec2791 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -341,12 +341,6 @@ (string) $hydrationMode - - is_object($connection) - - - ': "' . $connection . '"' - new $class($this) diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index c5612f34410..a1f3b0a648b 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -84,10 +84,7 @@ public function beginTransaction(): void $this->realEntityManager->beginTransaction(); } - /** - * {@inheritDoc} - */ - public function wrapInTransaction(callable $func) + public function wrapInTransaction(callable $func): mixed { return $this->realEntityManager->wrapInTransaction($func); } diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 5a6e8c3726f..2d7fa4a61d0 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -18,13 +18,11 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\UnitOfWork; -use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Persistence\Mapping\MappingException; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\GeoNames\Country; use Doctrine\Tests\OrmTestCase; use Generator; -use InvalidArgumentException; use stdClass; use TypeError; @@ -212,16 +210,6 @@ static function (EntityManagerInterface $em) use ($expectedValue) { $this->assertSame($expectedValue, $return); } - public function testCreateInvalidConnection(): void - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid $connection argument of type int given: "1".'); - - $config = new Configuration(); - $config->setMetadataDriverImpl($this->createMock(MappingDriver::class)); - EntityManager::create(1, $config); - } - /** * @group #5796 */ From b0a351f55a01952fea327ccd983ea06dccef1246 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 1 Feb 2022 13:47:39 +0100 Subject: [PATCH 042/475] Remove support for Doctrine Cache (#9456) --- UPGRADE.md | 15 ++ composer.json | 1 - lib/Doctrine/ORM/Configuration.php | 133 +--------------- lib/Doctrine/ORM/EntityManager.php | 14 -- .../Command/ClearCache/QueryCommand.php | 62 +------- .../Command/ClearCache/ResultCommand.php | 48 +----- phpstan-baseline.neon | 20 --- phpstan.neon | 4 - psalm-baseline.xml | 13 +- .../Doctrine/Tests/ORM/ConfigurationTest.php | 33 ---- .../Tests/ORM/Functional/ResultCacheTest.php | 5 +- .../ORM/Functional/Ticket/DDC742Test.php | 149 ------------------ tests/Doctrine/Tests/ORM/Query/QueryTest.php | 13 -- .../Tests/ORM/Tools/DoctrineSetupTest.php | 6 - 14 files changed, 31 insertions(+), 485 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php diff --git a/UPGRADE.md b/UPGRADE.md index 75cdb7cf4e4..b7d7b336ec0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,20 @@ # Upgrade to 3.0 +## BC BREAK: Remove support for Doctrine Cache + +The Doctrine Cache library is not supported anymore. The following methods +have been removed from `Doctrine\ORM\Configuration`: + +* `getQueryCacheImpl()` +* `setQueryCacheImpl()` +* `getHydrationCacheImpl()` +* `setHydrationCacheImpl()` +* `getMetadataCacheImpl()` +* `setMetadataCacheImpl()` + +The methods have been replaced by PSR-6 compatible counterparts +(just strip the `Impl` suffix from the old name to get the new one). + ## BC BREAK: Remove `Doctrine\ORM\Configuration::newDefaultAnnotationDriver` This functionality has been moved to the new `DoctrineSetup` class. Call diff --git a/composer.json b/composer.json index b19c387d05b..1c7ffe79fdb 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,6 @@ "composer-runtime-api": "^2", "ext-ctype": "*", "ext-pdo": "*", - "doctrine/cache": "^1.12.1 || ^2.1.1", "doctrine/collections": "^1.5", "doctrine/common": "^3.0.3", "doctrine/dbal": "^3.3", diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 215093364a4..8575bf91cae 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -4,9 +4,6 @@ namespace Doctrine\ORM; -use Doctrine\Common\Cache\Cache as CacheDriver; -use Doctrine\Common\Cache\Psr6\CacheAdapter; -use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\Common\Proxy\AbstractProxyFactory; use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\CacheConfiguration; @@ -203,45 +200,6 @@ public function getMetadataDriverImpl() return $this->_attributes['metadataDriverImpl'] ?? null; } - /** - * Gets the cache driver implementation that is used for the query cache (SQL cache). - * - * @deprecated Call {@see getQueryCache()} instead. - * - * @return CacheDriver|null - */ - public function getQueryCacheImpl() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9002', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getQueryCache() instead.', - __METHOD__ - ); - - return $this->_attributes['queryCacheImpl'] ?? null; - } - - /** - * Sets the cache driver implementation that is used for the query cache (SQL cache). - * - * @deprecated Call {@see setQueryCache()} instead. - * - * @return void - */ - public function setQueryCacheImpl(CacheDriver $cacheImpl) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9002', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use setQueryCache() instead.', - __METHOD__ - ); - - $this->_attributes['queryCache'] = CacheAdapter::wrap($cacheImpl); - $this->_attributes['queryCacheImpl'] = $cacheImpl; - } - /** * Gets the cache driver implementation that is used for the query cache (SQL cache). */ @@ -255,47 +213,7 @@ public function getQueryCache(): ?CacheItemPoolInterface */ public function setQueryCache(CacheItemPoolInterface $cache): void { - $this->_attributes['queryCache'] = $cache; - $this->_attributes['queryCacheImpl'] = DoctrineProvider::wrap($cache); - } - - /** - * Gets the cache driver implementation that is used for the hydration cache (SQL cache). - * - * @deprecated Call {@see getHydrationCache()} instead. - * - * @return CacheDriver|null - */ - public function getHydrationCacheImpl() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9002', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getHydrationCache() instead.', - __METHOD__ - ); - - return $this->_attributes['hydrationCacheImpl'] ?? null; - } - - /** - * Sets the cache driver implementation that is used for the hydration cache (SQL cache). - * - * @deprecated Call {@see setHydrationCache()} instead. - * - * @return void - */ - public function setHydrationCacheImpl(CacheDriver $cacheImpl) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9002', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use setHydrationCache() instead.', - __METHOD__ - ); - - $this->_attributes['hydrationCache'] = CacheAdapter::wrap($cacheImpl); - $this->_attributes['hydrationCacheImpl'] = $cacheImpl; + $this->_attributes['queryCache'] = $cache; } public function getHydrationCache(): ?CacheItemPoolInterface @@ -305,51 +223,7 @@ public function getHydrationCache(): ?CacheItemPoolInterface public function setHydrationCache(CacheItemPoolInterface $cache): void { - $this->_attributes['hydrationCache'] = $cache; - $this->_attributes['hydrationCacheImpl'] = DoctrineProvider::wrap($cache); - } - - /** - * Gets the cache driver implementation that is used for metadata caching. - * - * @deprecated Deprecated in favor of getMetadataCache - * - * @return CacheDriver|null - */ - public function getMetadataCacheImpl() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8650', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getMetadataCache() instead.', - __METHOD__ - ); - - if (isset($this->_attributes['metadataCacheImpl'])) { - return $this->_attributes['metadataCacheImpl']; - } - - return isset($this->_attributes['metadataCache']) ? DoctrineProvider::wrap($this->_attributes['metadataCache']) : null; - } - - /** - * Sets the cache driver implementation that is used for metadata caching. - * - * @deprecated Deprecated in favor of setMetadataCache - * - * @return void - */ - public function setMetadataCacheImpl(CacheDriver $cacheImpl) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8650', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use setMetadataCache() instead.', - __METHOD__ - ); - - $this->_attributes['metadataCacheImpl'] = $cacheImpl; - $this->_attributes['metadataCache'] = CacheAdapter::wrap($cacheImpl); + $this->_attributes['hydrationCache'] = $cache; } public function getMetadataCache(): ?CacheItemPoolInterface @@ -359,8 +233,7 @@ public function getMetadataCache(): ?CacheItemPoolInterface public function setMetadataCache(CacheItemPoolInterface $cache): void { - $this->_attributes['metadataCache'] = $cache; - $this->_attributes['metadataCacheImpl'] = DoctrineProvider::wrap($cache); + $this->_attributes['metadataCache'] = $cache; } /** diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 153b8e462d9..f6072b82b52 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM; -use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\EventManager; use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; @@ -805,22 +804,9 @@ private function configureMetadataCache(): void { $metadataCache = $this->config->getMetadataCache(); if (! $metadataCache) { - $this->configureLegacyMetadataCache(); - return; } $this->metadataFactory->setCache($metadataCache); } - - private function configureLegacyMetadataCache(): void - { - $metadataCache = $this->config->getMetadataCacheImpl(); - if (! $metadataCache) { - return; - } - - // Wrap doctrine/cache to provide PSR-6 interface - $this->metadataFactory->setCache(CacheAdapter::wrap($metadataCache)); - } } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php index 0e6917bdb74..ad3367b2202 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php @@ -4,10 +4,6 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; -use Doctrine\Common\Cache\ApcCache; -use Doctrine\Common\Cache\ClearableCache; -use Doctrine\Common\Cache\FlushableCache; -use Doctrine\Common\Cache\XcacheCache; use Doctrine\ORM\Tools\Console\Command\AbstractEntityManagerCommand; use InvalidArgumentException; use LogicException; @@ -17,9 +13,6 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -use function get_debug_type; -use function sprintf; - /** * Command to clear the query cache of the various cache drivers. * @@ -32,70 +25,27 @@ protected function configure(): void $this->setName('orm:clear-cache:query') ->setDescription('Clear all query cache of the various cache drivers') ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') - ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, cache entries will be flushed instead of deleted/invalidated.') - ->setHelp(<<<'EOT' -The %command.name% command is meant to clear the query cache of associated Entity Manager. -It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider -instance completely. - -The execution type differ on how you execute the command. -If you want to invalidate the entries (and not delete from cache instance), this command would do the work: - -%command.name% - -Alternatively, if you want to flush the cache provider using this command: - -%command.name% --flush - -Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, -because of a limitation of its execution nature. -EOT - ); + ->setHelp('The %command.name% command is meant to clear the query cache of associated Entity Manager.'); } protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); - $em = $this->getEntityManager($input); - $cache = $em->getConfiguration()->getQueryCache(); - $cacheDriver = $em->getConfiguration()->getQueryCacheImpl(); + $em = $this->getEntityManager($input); + $cache = $em->getConfiguration()->getQueryCache(); - if (! $cacheDriver) { + if (! $cache) { throw new InvalidArgumentException('No Query cache driver is configured on given EntityManager.'); } - if ($cacheDriver instanceof ApcCache || $cache instanceof ApcuAdapter) { + if ($cache instanceof ApcuAdapter) { throw new LogicException('Cannot clear APCu Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); } - if ($cacheDriver instanceof XcacheCache) { - throw new LogicException('Cannot clear XCache Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); - } - - if (! ($cacheDriver instanceof ClearableCache)) { - throw new LogicException(sprintf( - 'Can only clear cache when ClearableCache interface is implemented, %s does not implement.', - get_debug_type($cacheDriver) - )); - } - $ui->comment('Clearing all Query cache entries'); - $result = $cache ? $cache->clear() : $cacheDriver->deleteAll(); - $message = $result ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; - - if ($input->getOption('flush') === true && ! $cache) { - if (! ($cacheDriver instanceof FlushableCache)) { - throw new LogicException(sprintf( - 'Can only clear cache when FlushableCache interface is implemented, %s does not implement.', - get_debug_type($cacheDriver) - )); - } - - $result = $cacheDriver->flushAll(); - $message = $result ? 'Successfully flushed cache entries.' : $message; - } + $message = $cache->clear() ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; $ui->success($message); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php index 01c25414efa..f2bc3f62ab2 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php @@ -4,24 +4,13 @@ namespace Doctrine\ORM\Tools\Console\Command\ClearCache; -use Doctrine\Common\Cache\ApcCache; -use Doctrine\Common\Cache\ClearableCache; -use Doctrine\Common\Cache\FlushableCache; -use Doctrine\Common\Cache\XcacheCache; -use Doctrine\ORM\Configuration; use Doctrine\ORM\Tools\Console\Command\AbstractEntityManagerCommand; use InvalidArgumentException; -use LogicException; -use Symfony\Component\Cache\Adapter\ApcuAdapter; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -use function get_debug_type; -use function method_exists; -use function sprintf; - /** * Command to clear the result cache of the various cache drivers. * @@ -59,45 +48,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); - $em = $this->getEntityManager($input); - $cache = $em->getConfiguration()->getResultCache(); - $cacheDriver = method_exists(Configuration::class, 'getResultCacheImpl') ? $em->getConfiguration()->getResultCacheImpl() : null; + $em = $this->getEntityManager($input); + $cache = $em->getConfiguration()->getResultCache(); - if (! $cacheDriver && ! $cache) { + if (! $cache) { throw new InvalidArgumentException('No Result cache driver is configured on given EntityManager.'); } - if ($cacheDriver instanceof ApcCache || $cache instanceof ApcuAdapter) { - throw new LogicException('Cannot clear APCu Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); - } - - if ($cacheDriver instanceof XcacheCache) { - throw new LogicException('Cannot clear XCache Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); - } - - if (! $cache && ! ($cacheDriver instanceof ClearableCache)) { - throw new LogicException(sprintf( - 'Can only clear cache when ClearableCache interface is implemented, %s does not implement.', - get_debug_type($cacheDriver) - )); - } - $ui->comment('Clearing all Result cache entries'); - $result = $cache ? $cache->clear() : $cacheDriver->deleteAll(); - $message = $result ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; - - if ($input->getOption('flush') === true && ! $cache) { - if (! ($cacheDriver instanceof FlushableCache)) { - throw new LogicException(sprintf( - 'Can only clear cache when FlushableCache interface is implemented, %s does not implement.', - get_debug_type($cacheDriver) - )); - } - - $result = $cacheDriver->flushAll(); - $message = $result ? 'Successfully flushed cache entries.' : $message; - } + $message = $cache->clear() ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; $ui->success($message); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0baafd0390a..5de56eea09b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1330,26 +1330,6 @@ parameters: count: 2 path: lib/Doctrine/ORM/QueryBuilder.php - - - message: "#^Class Doctrine\\\\Common\\\\Cache\\\\ApcCache not found\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php - - - - message: "#^Class Doctrine\\\\Common\\\\Cache\\\\XcacheCache not found\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php - - - - message: "#^Class Doctrine\\\\Common\\\\Cache\\\\ApcCache not found\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php - - - - message: "#^Class Doctrine\\\\Common\\\\Cache\\\\XcacheCache not found\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$name\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index c900c636731..4f9da1757a2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,10 +8,6 @@ parameters: - message: '/^Variable \$offset in isset\(\) always exists and is not nullable\.$/' path: lib/Doctrine/ORM/PersistentCollection.php - - - message: '/^Call to an undefined method Doctrine\\Common\\Cache\\Cache::deleteAll\(\)\.$/' - count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php # Symfony cache supports passing a key prefix to the clear method. - '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/' diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 05edeec2791..fd150db1dfa 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -277,9 +277,8 @@ ProxyFactory ProxyFactory - + getAutoGenerateProxyClasses - getMetadataCacheImpl getProxyDir getProxyNamespace merge @@ -2689,16 +2688,6 @@ evictAll - - - getQueryCacheImpl - - - - - getResultCacheImpl - - getProxyDir diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index f9920f4d17b..1514bf0f00a 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -4,8 +4,6 @@ namespace Doctrine\Tests\ORM; -use Doctrine\Common\Cache\Cache; -use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Common\Proxy\AbstractProxyFactory; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Cache\CacheConfiguration; @@ -89,32 +87,12 @@ public function testSetGetEntityNamespace(): void $this->configuration->getEntityNamespace('NonExistingNamespace'); } - public function testSetGetQueryCacheImpl(): void - { - self::assertNull($this->configuration->getQueryCacheImpl()); // defaults - self::assertNull($this->configuration->getQueryCache()); // defaults - $queryCacheImpl = $this->createMock(Cache::class); - $this->configuration->setQueryCacheImpl($queryCacheImpl); - self::assertSame($queryCacheImpl, $this->configuration->getQueryCacheImpl()); - self::assertNotNull($this->configuration->getQueryCache()); - } - public function testSetGetQueryCache(): void { self::assertNull($this->configuration->getQueryCache()); // defaults $queryCache = $this->createMock(CacheItemPoolInterface::class); $this->configuration->setQueryCache($queryCache); self::assertSame($queryCache, $this->configuration->getQueryCache()); - self::assertSame($queryCache, CacheAdapter::wrap($this->configuration->getQueryCacheImpl())); - } - - public function testSetGetHydrationCacheImpl(): void - { - self::assertNull($this->configuration->getHydrationCacheImpl()); // defaults - $hydrationCacheImpl = $this->createMock(Cache::class); - $this->configuration->setHydrationCacheImpl($hydrationCacheImpl); - self::assertSame($hydrationCacheImpl, $this->configuration->getHydrationCacheImpl()); - self::assertNotNull($this->configuration->getHydrationCache()); } public function testSetGetHydrationCache(): void @@ -123,16 +101,6 @@ public function testSetGetHydrationCache(): void $hydrationCache = $this->createStub(CacheItemPoolInterface::class); $this->configuration->setHydrationCache($hydrationCache); self::assertSame($hydrationCache, $this->configuration->getHydrationCache()); - self::assertSame($hydrationCache, CacheAdapter::wrap($this->configuration->getHydrationCacheImpl())); - } - - public function testSetGetMetadataCacheImpl(): void - { - self::assertNull($this->configuration->getMetadataCacheImpl()); // defaults - $queryCacheImpl = $this->createMock(Cache::class); - $this->configuration->setMetadataCacheImpl($queryCacheImpl); - self::assertSame($queryCacheImpl, $this->configuration->getMetadataCacheImpl()); - self::assertNotNull($this->configuration->getMetadataCache()); } public function testSetGetMetadataCache(): void @@ -141,7 +109,6 @@ public function testSetGetMetadataCache(): void $cache = $this->createStub(CacheItemPoolInterface::class); $this->configuration->setMetadataCache($cache); self::assertSame($cache, $this->configuration->getMetadataCache()); - self::assertSame($cache, CacheAdapter::wrap($this->configuration->getMetadataCacheImpl())); } public function testAddGetCustomStringFunction(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php index 28ad5ceda04..358da1f60d7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\NativeQuery; @@ -344,7 +343,7 @@ private function setResultCache(AbstractQuery $query, CacheItemPoolInterface $ca private static function assertCacheHasItem(string $key, CacheItemPoolInterface $cache): void { self::assertTrue( - $cache->hasItem($key) || DoctrineProvider::wrap($cache)->contains($key), + $cache->hasItem($key), sprintf('Failed asserting that a given cache contains the key "%s".', $key) ); } @@ -357,7 +356,7 @@ private function resetCache(): void private static function assertCacheDoesNotHaveItem(string $key, CacheItemPoolInterface $cache): void { self::assertFalse( - $cache->hasItem($key) || DoctrineProvider::wrap($cache)->contains($key), + $cache->hasItem($key), sprintf('Failed asserting that a given cache does not contain the key "%s".', $key) ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php deleted file mode 100644 index b331cd4d0f3..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php +++ /dev/null @@ -1,149 +0,0 @@ -_em->getMetadataFactory()->setCacheDriver(new FilesystemCache($testDir)); - - try { - $this->_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC742User::class), - $this->_em->getClassMetadata(DDC742Comment::class), - ] - ); - } catch (Exception $e) { - } - - // make sure classes will be deserialized from caches - $this->_em->getMetadataFactory()->setMetadataFor(DDC742User::class, null); - $this->_em->getMetadataFactory()->setMetadataFor(DDC742Comment::class, null); - } - - public function testIssue(): void - { - $user = new DDC742User(); - $user->title = 'Foo'; - $user->favoriteComments = new ArrayCollection(); - - $comment1 = new DDC742Comment(); - $comment1->content = 'foo'; - - $comment2 = new DDC742Comment(); - $comment2->content = 'bar'; - - $comment3 = new DDC742Comment(); - $comment3->content = 'baz'; - - $user->favoriteComments->add($comment1); - $user->favoriteComments->add($comment2); - - $this->_em->persist($user); - $this->_em->persist($comment1); - $this->_em->persist($comment2); - $this->_em->persist($comment3); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(DDC742User::class, $user->id); - $user->favoriteComments->add($this->_em->find(DDC742Comment::class, $comment3->id)); - - $this->_em->flush(); - $this->addToAssertionCount(1); - } -} - -/** - * @Entity - * @Table(name="ddc742_users") - */ -class DDC742User -{ - /** - * User Id - * - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - * @var int - */ - public $id; - - /** - * @Column(length=100, type="string") - * @var string - */ - public $title; - - /** - * @ManyToMany(targetEntity="DDC742Comment", cascade={"persist"}, fetch="EAGER") - * @JoinTable( - * name="user_comments", - * joinColumns={@JoinColumn(name="user_id",referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="comment_id", referencedColumnName="id")} - * ) - * @var PersistentCollection - */ - public $favoriteComments; -} - -/** - * @Entity - * @Table(name="ddc742_comments") - */ -class DDC742Comment -{ - /** - * User Id - * - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - * @var int - */ - public $id; - - /** - * @Column(length=100, type="string") - * @var string - */ - public $content; -} diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 282fef4c98a..7ac91c20cf7 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -6,8 +6,6 @@ use DateTime; use DateTimeImmutable; -use Doctrine\Common\Cache\Psr6\CacheAdapter; -use Doctrine\Common\Cache\Psr6\DoctrineProvider; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Types; @@ -139,17 +137,6 @@ public function testHints(): void self::assertFalse($q->hasHint('barFooBaz')); } - /** - * @group DDC-1588 - */ - public function testQueryDefaultResultCacheLegacy(): void - { - $this->entityManager->getConfiguration()->setResultCacheImpl(DoctrineProvider::wrap(new ArrayAdapter())); - $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); - $q->enableResultCache(); - self::assertSame($this->entityManager->getConfiguration()->getResultCache(), CacheAdapter::wrap($q->getQueryCacheProfile()->getResultCacheDriver())); - } - public function testToIterableWithNoDistinctAndWrongSelectClause(): void { $this->expectException(QueryException::class); diff --git a/tests/Doctrine/Tests/ORM/Tools/DoctrineSetupTest.php b/tests/Doctrine/Tests/ORM/Tools/DoctrineSetupTest.php index b87461c855e..3528c6fd983 100644 --- a/tests/Doctrine/Tests/ORM/Tools/DoctrineSetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/DoctrineSetupTest.php @@ -99,11 +99,8 @@ public function testConfigureCache(): void $config = DoctrineSetup::createAnnotationMetadataConfiguration([], true, null, $cache); self::assertSame($cache, $config->getResultCache()); - self::assertSame($cache, $config->getResultCacheImpl()->getPool()); self::assertSame($cache, $config->getQueryCache()); - self::assertSame($cache, $config->getQueryCacheImpl()->getPool()); self::assertSame($cache, $config->getMetadataCache()); - self::assertSame($cache, $config->getMetadataCacheImpl()->getPool()); } /** @@ -115,11 +112,8 @@ public function testConfigureCacheCustomInstance(): void $config = DoctrineSetup::createConfiguration(true, null, $cache); self::assertSame($cache, $config->getResultCache()); - self::assertSame($cache, $config->getResultCacheImpl()->getPool()); self::assertSame($cache, $config->getQueryCache()); - self::assertSame($cache, $config->getQueryCacheImpl()->getPool()); self::assertSame($cache, $config->getMetadataCache()); - self::assertSame($cache, $config->getMetadataCacheImpl()->getPool()); } } From 5efdff2a4fa6030952266cc9fd910785b52de0b7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 2 Feb 2022 22:53:48 +0100 Subject: [PATCH 043/475] Remove PHP 7 code (#9462) --- .../ORM/Mapping/Driver/AttributeDriver.php | 11 ---------- .../ORM/Mapping/AbstractMappingDriverTest.php | 21 ++++--------------- .../Tests/ORM/Mapping/AttributeDriverTest.php | 8 ------- .../Tests/ORM/Mapping/ClassMetadataTest.php | 16 +++----------- .../Tests/ORM/Tools/DoctrineSetupTest.php | 17 --------------- 5 files changed, 7 insertions(+), 66 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php index 992cd5862ac..3155fa753c9 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\Mapping\Driver\AnnotationDriver; -use LogicException; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; @@ -21,9 +20,6 @@ use function constant; use function defined; use function get_class; -use function sprintf; - -use const PHP_VERSION_ID; class AttributeDriver extends AnnotationDriver { @@ -39,13 +35,6 @@ class AttributeDriver extends AnnotationDriver */ public function __construct(array $paths) { - if (PHP_VERSION_ID < 80000) { - throw new LogicException(sprintf( - 'The attribute metadata driver cannot be enabled on PHP 7. Please upgrade to PHP 8 or choose a different' - . ' metadata driver.' - )); - } - parent::__construct(new AttributeReader(), $paths); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 77e4a73914b..db567e916d0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -76,7 +76,6 @@ use function strtolower; use const CASE_UPPER; -use const PHP_VERSION_ID; abstract class AbstractMappingDriverTest extends OrmTestCase { @@ -696,14 +695,11 @@ public function testSqlResultSetMapping(): void } /** + * @requires PHP 8.1 * @group DDC-964 */ public function testAssociationOverridesMapping(): void { - if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100) { - $this->markTestSkipped('Does not work on PHP 8.0.* due to nested attributes missing.'); - } - $factory = $this->createClassMetadataFactory(); $adminMetadata = $factory->getMetadataFor(DDC964Admin::class); $guestMetadata = $factory->getMetadataFor(DDC964Guest::class); @@ -778,14 +774,11 @@ public function testAssociationOverridesMapping(): void } /** + * @requires PHP 8.1 * @group DDC-3579 */ public function testInversedByOverrideMapping(): void { - if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100) { - $this->markTestSkipped('Does not work on PHP 8.0.* due to nested attributes missing.'); - } - $factory = $this->createClassMetadataFactory(); $adminMetadata = $factory->getMetadataFor(DDC3579Admin::class); @@ -798,14 +791,11 @@ public function testInversedByOverrideMapping(): void } /** + * @requires PHP 8.1 * @group DDC-5934 */ public function testFetchOverrideMapping(): void { - if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100) { - $this->markTestSkipped('Does not work on PHP 8.0.* due to nested attributes missing.'); - } - // check override metadata $contractMetadata = $this->createClassMetadataFactory()->getMetadataFor(DDC5934Contract::class); @@ -814,14 +804,11 @@ public function testFetchOverrideMapping(): void } /** + * @requires PHP 8.1 * @group DDC-964 */ public function testAttributeOverridesMapping(): void { - if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100) { - $this->markTestSkipped('Does not work on PHP 8.0.* due to nested attributes missing.'); - } - $factory = $this->createClassMetadataFactory(); $guestMetadata = $factory->getMetadataFor(DDC964Guest::class); $adminMetadata = $factory->getMetadataFor(DDC964Admin::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 73e27ecc253..df5d3727fa2 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -15,14 +15,6 @@ class AttributeDriverTest extends AbstractMappingDriverTest { - /** @before */ - public function requiresPhp8Assertion(): void - { - if (PHP_VERSION_ID < 80000) { - self::markTestSkipped('requires PHP 8.0'); - } - } - protected function loadDriver(): MappingDriver { $paths = []; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 4e25cb7511a..3bd996e4bb8 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -39,7 +39,6 @@ use function unserialize; use const CASE_UPPER; -use const PHP_VERSION_ID; require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; @@ -902,14 +901,11 @@ public function testInvalidCascade(): void } /** + * @requires PHP 8.1 * @group DDC-964 */ public function testInvalidPropertyAssociationOverrideNameException(): void { - if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100) { - $this->markTestSkipped('Does not work on PHP 8.0.* due to nested attributes missing.'); - } - $this->expectException('Doctrine\ORM\Mapping\MappingException'); $this->expectExceptionMessage('Invalid field override named \'invalidPropertyName\' for class \'Doctrine\Tests\Models\DDC964\DDC964Admin'); $cm = new ClassMetadata(DDC964Admin::class); @@ -920,14 +916,11 @@ public function testInvalidPropertyAssociationOverrideNameException(): void } /** + * @requires PHP 8.1 * @group DDC-964 */ public function testInvalidPropertyAttributeOverrideNameException(): void { - if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100) { - $this->markTestSkipped('Does not work on PHP 8.0.* due to nested attributes missing.'); - } - $this->expectException('Doctrine\ORM\Mapping\MappingException'); $this->expectExceptionMessage('Invalid field override named \'invalidPropertyName\' for class \'Doctrine\Tests\Models\DDC964\DDC964Guest\'.'); $cm = new ClassMetadata(DDC964Guest::class); @@ -938,14 +931,11 @@ public function testInvalidPropertyAttributeOverrideNameException(): void } /** + * @requires PHP 8.1 * @group DDC-964 */ public function testInvalidOverrideAttributeFieldTypeException(): void { - if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100) { - $this->markTestSkipped('Does not work on PHP 8.0.* due to nested attributes missing.'); - } - $this->expectException('Doctrine\ORM\Mapping\MappingException'); $this->expectExceptionMessage('The column type of attribute \'name\' on class \'Doctrine\Tests\Models\DDC964\DDC964Guest\' could not be changed.'); $cm = new ClassMetadata(DDC964Guest::class); diff --git a/tests/Doctrine/Tests/ORM/Tools/DoctrineSetupTest.php b/tests/Doctrine/Tests/ORM/Tools/DoctrineSetupTest.php index 0de14d29d90..9f15c001dab 100644 --- a/tests/Doctrine/Tests/ORM/Tools/DoctrineSetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/DoctrineSetupTest.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\Tools\DoctrineSetup; -use LogicException; use PHPUnit\Framework\TestCase; use ReflectionClass; use ReflectionProperty; @@ -46,9 +45,6 @@ public function testNewDefaultAnnotationDriver(): void self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); } - /** - * @requires PHP 8.0 - */ public function testAttributeConfiguration(): void { $config = DoctrineSetup::createAttributeMetadataConfiguration([], true); @@ -59,19 +55,6 @@ public function testAttributeConfiguration(): void self::assertInstanceOf(AttributeDriver::class, $config->getMetadataDriverImpl()); } - /** - * @requires PHP < 8 - */ - public function testAttributeConfigurationFailsOnPHP7(): void - { - self::expectException(LogicException::class); - self::expectExceptionMessage( - 'The attribute metadata driver cannot be enabled on PHP 7. Please upgrade to PHP 8 or choose a different metadata driver.' - ); - - DoctrineSetup::createAttributeMetadataConfiguration([], true); - } - public function testXMLConfiguration(): void { $config = DoctrineSetup::createXMLMetadataConfiguration([], true); From 1c67f4274b39c91e5b5b9527e96208baebd66880 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 5 Feb 2022 18:00:37 +0100 Subject: [PATCH 044/475] Remove ability to clear the UoW partially (#9471) --- UPGRADE.md | 11 +++ lib/Doctrine/ORM/EntityManager.php | 29 ++----- lib/Doctrine/ORM/EntityRepository.php | 20 ----- lib/Doctrine/ORM/Event/OnClearEventArgs.php | 40 +-------- .../ORM/ORMInvalidArgumentException.php | 12 --- lib/Doctrine/ORM/UnitOfWork.php | 81 +++++-------------- phpstan-baseline.neon | 5 -- psalm-baseline.xml | 9 +-- .../Doctrine/Tests/ORM/EntityManagerTest.php | 71 ---------------- .../ORM/Functional/BasicFunctionalTest.php | 56 +------------ .../ORM/Functional/EntityRepositoryTest.php | 12 --- .../Tests/ORM/Functional/ReadOnlyTest.php | 4 +- .../ORM/Functional/Ticket/DDC117Test.php | 2 +- .../ORM/Functional/Ticket/DDC2106Test.php | 2 +- .../ORM/Functional/Ticket/DDC2409Test.php | 3 +- .../ORM/ORMInvalidArgumentExceptionTest.php | 11 --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 26 ------ 17 files changed, 52 insertions(+), 342 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index b7d7b336ec0..e3bb48d08db 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,16 @@ # Upgrade to 3.0 +## BC BREAK: Removed ability to partially clear entity manager and unit of work + +* Passing an argument other than `null` to `EntityManager::clear()` will raise + an exception. +* The unit of work cannot be cleared partially anymore. Passing an argument to + `UnitOfWork::clear()` does not have any effect anymore; the unit of work is + cleared completely. +* The method `EntityRepository::clear()` has been removed. +* The methods `getEntityClass()` and `clearsAllEntities()` have been removed + from `OnClearEventArgs`. + ## BC BREAK: Remove support for Doctrine Cache The Doctrine Cache library is not supported anymore. The following methods diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index f6072b82b52..81f734538dc 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -27,14 +27,12 @@ use Doctrine\ORM\Query\FilterCollection; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Repository\RepositoryFactory; -use Doctrine\Persistence\Mapping\MappingException; use Doctrine\Persistence\ObjectRepository; use Throwable; use function array_keys; use function is_array; use function is_object; -use function is_string; use function ltrim; /** @@ -448,32 +446,17 @@ public function getPartialReference(string $entityName, $identifier): ?object * Clears the EntityManager. All entities that are currently managed * by this EntityManager become detached. * - * @param string|null $entityName if given, only entities of this type will get detached + * @param string|null $objectName The object name (not supported). * - * @throws ORMInvalidArgumentException If a non-null non-string value is given. - * @throws MappingException If a $entityName is given, but that entity is not - * found in the mappings. + * @throws ORMInvalidArgumentException If the caller attempted to clear the EM partially by passing an object name. */ - public function clear($entityName = null): void + public function clear($objectName = null): void { - if ($entityName !== null && ! is_string($entityName)) { - throw ORMInvalidArgumentException::invalidEntityName($entityName); + if ($objectName !== null) { + throw new ORMInvalidArgumentException('Clearing the entity manager partially if not supported.'); } - if ($entityName !== null) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8460', - 'Calling %s() with any arguments to clear specific entities is deprecated and will not be supported in Doctrine ORM 3.0.', - __METHOD__ - ); - } - - $this->unitOfWork->clear( - $entityName === null - ? null - : $this->metadataFactory->getMetadataFor($entityName)->getName() - ); + $this->unitOfWork->clear(); } public function close(): void diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index af7cc49af77..df1861f6012 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -9,7 +9,6 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\Inflector\Inflector; use Doctrine\Inflector\InflectorFactory; use Doctrine\ORM\Mapping\ClassMetadata; @@ -90,25 +89,6 @@ public function createResultSetMappingBuilder($alias) return $rsm; } - /** - * Clears the repository, causing all managed entities to become detached. - * - * @deprecated 2.8 This method is being removed from the ORM and won't have any replacement - * - * @return void - */ - public function clear() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8460', - 'Calling %s() is deprecated and will not be supported in Doctrine ORM 3.0.', - __METHOD__ - ); - - $this->_em->clear($this->_class->rootEntityName); - } - /** * Finds an entity by its primary key / identifier. * diff --git a/lib/Doctrine/ORM/Event/OnClearEventArgs.php b/lib/Doctrine/ORM/Event/OnClearEventArgs.php index 18665a8b125..c461023842c 100644 --- a/lib/Doctrine/ORM/Event/OnClearEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClearEventArgs.php @@ -14,48 +14,16 @@ */ class OnClearEventArgs extends EventArgs { - /** @var EntityManagerInterface */ - private $em; - - /** @var string|null */ - private $entityClass; - - /** - * @param string|null $entityClass Optional entity class. - */ - public function __construct(EntityManagerInterface $em, $entityClass = null) - { - $this->em = $em; - $this->entityClass = $entityClass; + public function __construct( + private EntityManagerInterface $em + ) { } /** * Retrieves associated EntityManager. - * - * @return EntityManagerInterface */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { return $this->em; } - - /** - * Name of the entity class that is cleared, or empty if all are cleared. - * - * @return string|null - */ - public function getEntityClass() - { - return $this->entityClass; - } - - /** - * Checks if event clears all entities. - * - * @return bool - */ - public function clearsAllEntities() - { - return $this->entityClass === null; - } } diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index cc61f056a20..31b8c99f1bb 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -221,18 +221,6 @@ public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $a )); } - /** - * Used when a given entityName hasn't the good type - * - * @param mixed $entityName The given entity (which shouldn't be a string) - * - * @return self - */ - public static function invalidEntityName($entityName) - { - return new self(sprintf('Entity name must be a string, %s given', get_debug_type($entityName))); - } - /** * Helper method to show an object as string. * diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 89a7bf99664..7e958c5c2a7 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2402,45 +2402,29 @@ public function getCommitOrderCalculator(): CommitOrderCalculator /** * Clears the UnitOfWork. - * - * @param string|null $entityName if given, only entities of this type will get detached. - * - * @throws ORMInvalidArgumentException if an invalid entity name is given. - */ - public function clear(?string $entityName = null): void - { - if ($entityName === null) { - $this->identityMap = - $this->entityIdentifiers = - $this->originalEntityData = - $this->entityChangeSets = - $this->entityStates = - $this->scheduledForSynchronization = - $this->entityInsertions = - $this->entityUpdates = - $this->entityDeletions = - $this->nonCascadedNewDetectedEntities = - $this->collectionDeletions = - $this->collectionUpdates = - $this->extraUpdates = - $this->readOnlyObjects = - $this->visitedCollections = - $this->eagerLoadingEntities = - $this->orphanRemovals = []; - } else { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8460', - 'Calling %s() with any arguments to clear specific entities is deprecated and will not be supported in Doctrine ORM 3.0.', - __METHOD__ - ); - - $this->clearIdentityMapForEntityName($entityName); - $this->clearEntityInsertionsForEntityName($entityName); - } + */ + public function clear(): void + { + $this->identityMap = + $this->entityIdentifiers = + $this->originalEntityData = + $this->entityChangeSets = + $this->entityStates = + $this->scheduledForSynchronization = + $this->entityInsertions = + $this->entityUpdates = + $this->entityDeletions = + $this->nonCascadedNewDetectedEntities = + $this->collectionDeletions = + $this->collectionUpdates = + $this->extraUpdates = + $this->readOnlyObjects = + $this->visitedCollections = + $this->eagerLoadingEntities = + $this->orphanRemovals = []; if ($this->evm->hasListeners(Events::onClear)) { - $this->evm->dispatchEvent(Events::onClear, new Event\OnClearEventArgs($this->em, $entityName)); + $this->evm->dispatchEvent(Events::onClear, new Event\OnClearEventArgs($this->em)); } } @@ -3420,29 +3404,6 @@ public function hydrationComplete(): void $this->hydrationCompleteHandler->hydrationComplete(); } - private function clearIdentityMapForEntityName(string $entityName): void - { - if (! isset($this->identityMap[$entityName])) { - return; - } - - $visited = []; - - foreach ($this->identityMap[$entityName] as $entity) { - $this->doDetach($entity, $visited, false); - } - } - - private function clearEntityInsertionsForEntityName(string $entityName): void - { - foreach ($this->entityInsertions as $hash => $entity) { - // note: performance optimization - `instanceof` is much faster than a function call - if ($entity instanceof $entityName && get_class($entity) === $entityName) { - unset($this->entityInsertions[$hash]); - } - } - } - /** * @throws MappingException if the entity has more than a single identifier. */ diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5de56eea09b..c5da37c23f7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -145,11 +145,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/EntityManager.php - - - message: "#^Result of && is always false\\.$#" - count: 1 - path: lib/Doctrine/ORM/EntityManager.php - - message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\EntityManager\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getMetadataFactory\\(\\)$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fd150db1dfa..c733b94a121 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -283,8 +283,7 @@ getProxyNamespace merge - - $entityName !== null && ! is_string($entityName) + is_object($entity) is_object($entity) is_object($entity) @@ -316,7 +315,7 @@ EntityRepository<T> - + $entity $entity $entity @@ -324,7 +323,6 @@ $entity $entity $entityName - $entityName $config->getProxyDir() @@ -2871,7 +2869,7 @@ $this->identityMap[$rootClassName] - + $assoc $assoc $assoc['targetEntity'] @@ -2880,7 +2878,6 @@ $collection->getOwner() $collectionToDelete->getMapping() $entity - $entity $owner diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 2d7fa4a61d0..4a55581082d 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -18,7 +18,6 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\UnitOfWork; -use Doctrine\Persistence\Mapping\MappingException; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\GeoNames\Country; use Doctrine\Tests\OrmTestCase; @@ -26,10 +25,6 @@ use stdClass; use TypeError; -use function get_class; -use function random_int; -use function uniqid; - class EntityManagerTest extends OrmTestCase { use VerifyDeprecations; @@ -228,72 +223,6 @@ public function testWrapInTransactionReThrowsThrowables(): void } } - /** - * @group 6017 - */ - public function testClearManagerWithObject(): void - { - $entity = new Country(456, 'United Kingdom'); - - $this->expectException(ORMInvalidArgumentException::class); - - $this->entityManager->clear($entity); - } - - /** - * @group 6017 - */ - public function testClearManagerWithUnknownEntityName(): void - { - $this->expectException(MappingException::class); - - $this->entityManager->clear(uniqid('nonExisting', true)); - } - - /** - * @group 6017 - */ - public function testClearManagerWithProxyClassName(): void - { - $proxy = $this->entityManager->getReference(Country::class, ['id' => random_int(457, 100000)]); - - $entity = new Country(456, 'United Kingdom'); - - $this->entityManager->persist($entity); - - self::assertTrue($this->entityManager->contains($entity)); - - $this->entityManager->clear(get_class($proxy)); - - self::assertFalse($this->entityManager->contains($entity)); - } - - /** - * @group 6017 - */ - public function testClearManagerWithNullValue(): void - { - $entity = new Country(456, 'United Kingdom'); - - $this->entityManager->persist($entity); - - self::assertTrue($this->entityManager->contains($entity)); - - $this->entityManager->clear(null); - - self::assertFalse($this->entityManager->contains($entity)); - } - - public function testDeprecatedClearWithArguments(): void - { - $entity = new Country(456, 'United Kingdom'); - $this->entityManager->persist($entity); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8460'); - - $this->entityManager->clear(Country::class); - } - public function testDeprecatedFlushWithArguments(): void { $entity = new Country(456, 'United Kingdom'); diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 490dbe98503..b044d12b21e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -538,10 +538,9 @@ public function testSetSetAssociationWithGetReference(): void $this->_em->persist($address); $this->_em->flush(); - $this->_em->clear(CmsAddress::class); - - self::assertFalse($this->_em->contains($address)); - self::assertTrue($this->_em->contains($user)); + $userId = $user->getId(); + $this->_em->clear(); + $user = $this->_em->find(CmsUser::class, $userId); // Assume we only got the identifier of the address and now want to attach // that address to the user without actually loading it, using getReference(). @@ -1023,55 +1022,6 @@ public function testManyToOneFetchModeQuery(): void $this->assertQueryCount(2); } - /** - * @group DDC-1278 - */ - public function testClearWithEntityName(): void - { - $user = new CmsUser(); - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $address = new CmsAddress(); - $address->city = 'Springfield'; - $address->zip = '12354'; - $address->country = 'Germany'; - $address->street = 'Foo Street'; - $address->user = $user; - $user->address = $address; - - $article1 = new CmsArticle(); - $article1->topic = 'Foo'; - $article1->text = 'Foo Text'; - - $article2 = new CmsArticle(); - $article2->topic = 'Bar'; - $article2->text = 'Bar Text'; - - $user->addArticle($article1); - $user->addArticle($article2); - - $this->_em->persist($article1); - $this->_em->persist($article2); - $this->_em->persist($address); - $this->_em->persist($user); - $this->_em->flush(); - - $unitOfWork = $this->_em->getUnitOfWork(); - - $this->_em->clear(CmsUser::class); - - self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); - self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1)); - self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article2)); - self::assertEquals(UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); - - $this->_em->clear(); - - self::assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); - } - public function testFlushManyExplicitEntities(): void { $userA = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 45032cc0685..3a125acc4fa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -9,7 +9,6 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Exception\InvalidEntityRepository; use Doctrine\ORM\Exception\ORMException; @@ -37,8 +36,6 @@ class EntityRepositoryTest extends OrmFunctionalTestCase { - use VerifyDeprecations; - protected function setUp(): void { $this->useModelSet('cms'); @@ -1113,13 +1110,4 @@ public function testFindMultipleByNullValueInMultipleInCriteriaValues(): void self::assertContains($user, [$user1, $user2]); } } - - public function testDeprecatedClear(): void - { - $repository = $this->_em->getRepository(CmsAddress::class); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8460'); - - $repository->clear(); - } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 8dd8b91846e..0cf726444e0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -12,8 +12,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Exception; -use function get_class; - /** * Functional Query tests. * @@ -77,7 +75,7 @@ public function testClearEntitiesReadOnly(): void $this->_em->flush(); $this->_em->getUnitOfWork()->markReadOnly($readOnly); - $this->_em->clear(get_class($readOnly)); + $this->_em->clear(); self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php index 79e565a5cab..41da7e96513 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -449,7 +449,7 @@ public function testMergeForeignKeyIdentifierEntity(): void $refRep = $this->_em->find(DDC117Reference::class, $idCriteria); - $this->_em->clear(DDC117Reference::class); + $this->_em->clear(); $refRep = $this->_em->merge($refRep); self::assertEquals($this->article1->id(), $refRep->source()->id()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php index c3acf8effe8..f3d8610def4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php @@ -37,7 +37,7 @@ public function testDetachedEntityAsId(): void $entity = new DDC2106Entity(); $this->_em->persist($entity); $this->_em->flush(); - $this->_em->clear(DDC2106Entity::class); + $this->_em->clear(); $entity = $this->_em->getRepository(DDC2106Entity::class)->findOneBy([]); // ... and a managed entity without id diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php index ee9b654fcd1..cbd075f78d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php @@ -56,8 +56,7 @@ public function testIssue(): void self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($article)); self::assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); - $em->clear(CmsUser::class); - $em->clear(CmsArticle::class); + $em->clear(); $userMerged = $em->merge($user); $articleMerged = $em->merge($article); diff --git a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php index 45fe31adec3..ea3e0129712 100644 --- a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php @@ -16,17 +16,6 @@ */ class ORMInvalidArgumentExceptionTest extends TestCase { - /** - * @dataProvider invalidEntityNames - */ - public function testInvalidEntityName(mixed $value, string $expectedMessage): void - { - $exception = ORMInvalidArgumentException::invalidEntityName($value); - - self::assertInstanceOf(ORMInvalidArgumentException::class, $exception); - self::assertSame($expectedMessage, $exception->getMessage()); - } - /** * @psalm-return list */ diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 4169fa492f9..801aca8f7cb 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -35,8 +35,6 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\Forum\ForumAvatar; use Doctrine\Tests\Models\Forum\ForumUser; -use Doctrine\Tests\Models\GeoNames\City; -use Doctrine\Tests\Models\GeoNames\Country; use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\MockObject\MockObject; use stdClass; @@ -407,30 +405,6 @@ public function testRemovedAndRePersistedEntitiesAreInTheIdentityMapAndAreNotGar self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); } - /** - * @group 5849 - * @group 5850 - */ - public function testPersistedEntityAndClearManager(): void - { - $entity1 = new City(123, 'London'); - $entity2 = new Country(456, 'United Kingdom'); - - $this->_unitOfWork->persist($entity1); - self::assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); - - $this->_unitOfWork->persist($entity2); - self::assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8460'); - - $this->_unitOfWork->clear(Country::class); - self::assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); - self::assertFalse($this->_unitOfWork->isInIdentityMap($entity2)); - self::assertTrue($this->_unitOfWork->isScheduledForInsert($entity1)); - self::assertFalse($this->_unitOfWork->isScheduledForInsert($entity2)); - } - /** * @group #5579 */ From fd83543026c9440d73b4928b9dc3cc74bfd170c2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 7 Feb 2022 22:29:51 +0100 Subject: [PATCH 045/475] Remove ability to flush the EM partially (#9485) --- UPGRADE.md | 12 ++ docs/en/reference/unitofwork.rst | 7 - .../ORM/Decorator/EntityManagerDecorator.php | 8 - lib/Doctrine/ORM/EntityManager.php | 16 +- lib/Doctrine/ORM/UnitOfWork.php | 111 ++------------ phpstan-baseline.neon | 5 - psalm-baseline.xml | 6 - .../Doctrine/Tests/ORM/EntityManagerTest.php | 14 -- .../ORM/Functional/BasicFunctionalTest.php | 141 +----------------- .../Tests/ORM/Functional/MergeProxiesTest.php | 2 +- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 89 ----------- 11 files changed, 29 insertions(+), 382 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 5b624231819..a7d7824c10b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,17 @@ # Upgrade to 3.0 +## BC BREAK: Removed ability to partially flush/commit entity manager and unit of work + +The following methods don't accept a single entity or an array of entities anymore: + +* `Doctrine\ORM\EntityManager::flush()` +* `Doctrine\ORM\Decorator\EntityManagerDecorator::flush()` +* `Doctrine\ORM\UnitOfWork::commit()` + +The semantics of `flush()` and `commit()` will remain the same, but the change +tracking will be performed on all entities managed by the unit of work, and not +just on the provided entities, as the parameter is now completely ignored. + ## BC BREAK: Removed ability to partially clear entity manager and unit of work * Passing an argument other than `null` to `EntityManager::clear()` will raise diff --git a/docs/en/reference/unitofwork.rst b/docs/en/reference/unitofwork.rst index 6955f334286..7b7f99d6fdb 100644 --- a/docs/en/reference/unitofwork.rst +++ b/docs/en/reference/unitofwork.rst @@ -129,16 +129,10 @@ optimize the performance of the Flush Operation: - Temporarily mark entities as read only. If you have a very large UnitOfWork but know that a large set of entities has not changed, just mark them as read only with ``$entityManager->getUnitOfWork()->markReadOnly($entity)``. -- Flush only a single entity with ``$entityManager->flush($entity)``. - Use :doc:`Change Tracking Policies ` to use more explicit strategies of notifying the UnitOfWork what objects/properties changed. -.. note:: - - Flush only a single entity with ``$entityManager->flush($entity)`` is deprecated and will be removed in ORM 3.0. - (`Details `_) - Query Internals --------------- @@ -202,4 +196,3 @@ ClassMetadataFactory ~~~~~~~~~~~~~~~~~~~~ tbr - diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index d7b54dee7ba..751464e58d7 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -135,14 +135,6 @@ public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVer return $this->wrapped->find($className, $id, $lockMode, $lockVersion); } - /** - * {@inheritdoc} - */ - public function flush($entity = null): void - { - $this->wrapped->flush($entity); - } - public function getEventManager(): EventManager { return $this->wrapped->getEventManager(); diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 81f734538dc..4b6cf01d825 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -257,26 +257,14 @@ public function createQueryBuilder(): QueryBuilder * If an entity is explicitly passed to this method only this entity and * the cascade-persist semantics + scheduled inserts/removals are synchronized. * - * @param object|mixed[]|null $entity - * * @throws OptimisticLockException If a version check on an entity that * makes use of optimistic locking fails. * @throws ORMException */ - public function flush($entity = null): void + public function flush(): void { - if ($entity !== null) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8459', - 'Calling %s() with any arguments to flush specific entities is deprecated and will not be supported in Doctrine ORM 3.0.', - __METHOD__ - ); - } - $this->errorIfClosed(); - - $this->unitOfWork->commit($entity); + $this->unitOfWork->commit(); } /** diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 7e958c5c2a7..19d2ab9e67c 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -319,21 +319,10 @@ public function __construct(EntityManagerInterface $em) * 4) All collection updates * 5) All entity deletions * - * @param object|mixed[]|null $entity - * * @throws Exception */ - public function commit(object|array|null $entity = null): void + public function commit(): void { - if ($entity !== null) { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8459', - 'Calling %s() with any arguments to commit specific entities is deprecated and will not be supported in Doctrine ORM 3.0.', - __METHOD__ - ); - } - $connection = $this->em->getConnection(); if ($connection instanceof PrimaryReadReplicaConnection) { @@ -346,15 +335,7 @@ public function commit(object|array|null $entity = null): void } // Compute changes done since last commit. - if ($entity === null) { - $this->computeChangeSets(); - } elseif (is_object($entity)) { - $this->computeSingleEntityChangeSet($entity); - } else { - foreach ($entity as $object) { - $this->computeSingleEntityChangeSet($object); - } - } + $this->computeChangeSets(); if ( ! ($this->entityInsertions || @@ -367,7 +348,7 @@ public function commit(object|array|null $entity = null): void $this->dispatchOnFlushEvent(); $this->dispatchPostFlushEvent(); - $this->postCommitCleanup($entity); + $this->postCommitCleanup(); return; // Nothing to do. } @@ -436,9 +417,7 @@ public function commit(object|array|null $entity = null): void // Commit failed silently if ($conn->commit() === false) { - $object = is_object($entity) ? $entity : null; - - throw new OptimisticLockException('Commit failed', $object); + throw new OptimisticLockException('Commit failed', null); } } catch (Throwable $e) { $this->em->close(); @@ -461,13 +440,10 @@ public function commit(object|array|null $entity = null): void $this->dispatchPostFlushEvent(); - $this->postCommitCleanup($entity); + $this->postCommitCleanup(); } - /** - * @param object|object[]|null $entity - */ - private function postCommitCleanup(object|array|null $entity): void + private function postCommitCleanup(): void { $this->entityInsertions = $this->entityUpdates = @@ -477,25 +453,9 @@ private function postCommitCleanup(object|array|null $entity): void $this->nonCascadedNewDetectedEntities = $this->collectionDeletions = $this->visitedCollections = - $this->orphanRemovals = []; - - if ($entity === null) { - $this->entityChangeSets = $this->scheduledForSynchronization = []; - - return; - } - - $entities = is_object($entity) - ? [$entity] - : $entity; - - foreach ($entities as $object) { - $oid = spl_object_id($object); - - $this->clearEntityChangeSet($oid); - - unset($this->scheduledForSynchronization[$this->em->getClassMetadata(get_class($object))->rootEntityName][$oid]); - } + $this->orphanRemovals = + $this->entityChangeSets = + $this->scheduledForSynchronization = []; } /** @@ -510,50 +470,6 @@ private function computeScheduleInsertsChangeSets(): void } } - /** - * Only flushes the given entity according to a ruleset that keeps the UoW consistent. - * - * 1. All entities scheduled for insertion, (orphan) removals and changes in collections are processed as well! - * 2. Read Only entities are skipped. - * 3. Proxies are skipped. - * 4. Only if entity is properly managed. - * - * @throws InvalidArgumentException - */ - private function computeSingleEntityChangeSet(object $entity): void - { - $state = $this->getEntityState($entity); - - if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) { - throw new InvalidArgumentException('Entity has to be managed or scheduled for removal for single computation ' . self::objToStr($entity)); - } - - $class = $this->em->getClassMetadata(get_class($entity)); - - if ($state === self::STATE_MANAGED && $class->isChangeTrackingDeferredImplicit()) { - $this->persist($entity); - } - - // Compute changes for INSERTed entities first. This must always happen even in this case. - $this->computeScheduleInsertsChangeSets(); - - if ($class->isReadOnly) { - return; - } - - // Ignore uninitialized proxy objects - if ($entity instanceof Proxy && ! $entity->__isInitialized()) { - return; - } - - // Only MANAGED entities that are NOT SCHEDULED FOR INSERTION OR DELETION are processed here. - $oid = spl_object_id($entity); - - if (! isset($this->entityInsertions[$oid]) && ! isset($this->entityDeletions[$oid]) && isset($this->entityStates[$oid])) { - $this->computeChangeSet($class, $entity); - } - } - /** * Executes any extra updates that have been scheduled. */ @@ -3058,15 +2974,6 @@ public function registerManaged(object $entity, array $id, array $data): void } } - /** - * INTERNAL: - * Clears the property changeset of the entity with the given OID. - */ - public function clearEntityChangeSet(int $oid): void - { - unset($this->entityChangeSets[$oid]); - } - /* PropertyChangedListener implementation */ /** diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3319c424084..e5f7b802fad 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -105,11 +105,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php - - - message: "#^Method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:flush\\(\\) invoked with 1 parameter, 0 required\\.$#" - count: 1 - path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php - - message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\Decorator\\\\EntityManagerDecorator\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getMetadataFactory\\(\\)$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b888ae046af..3b0c2b33c6d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -235,12 +235,6 @@ ProxyFactory - - $entity - - - flush - diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 4a55581082d..52883c64f2b 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -6,7 +6,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; @@ -19,7 +18,6 @@ use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\GeoNames\Country; use Doctrine\Tests\OrmTestCase; use Generator; use stdClass; @@ -27,8 +25,6 @@ class EntityManagerTest extends OrmTestCase { - use VerifyDeprecations; - /** @var EntityManager */ private $entityManager; @@ -222,14 +218,4 @@ public function testWrapInTransactionReThrowsThrowables(): void self::assertFalse($this->entityManager->isOpen()); } } - - public function testDeprecatedFlushWithArguments(): void - { - $entity = new Country(456, 'United Kingdom'); - $this->entityManager->persist($entity); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8459'); - - $this->entityManager->flush($entity); - } } diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index b044d12b21e..e71532de57b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -1022,37 +1022,6 @@ public function testManyToOneFetchModeQuery(): void $this->assertQueryCount(2); } - public function testFlushManyExplicitEntities(): void - { - $userA = new CmsUser(); - $userA->username = 'UserA'; - $userA->name = 'UserA'; - - $userB = new CmsUser(); - $userB->username = 'UserB'; - $userB->name = 'UserB'; - - $userC = new CmsUser(); - $userC->username = 'UserC'; - $userC->name = 'UserC'; - - $this->_em->persist($userA); - $this->_em->persist($userB); - $this->_em->persist($userC); - - $this->_em->flush([$userA, $userB, $userB]); - - $userC->name = 'changed name'; - - $this->_em->flush([$userA, $userB]); - $this->_em->refresh($userC); - - self::assertTrue($userA->id > 0, 'user a has an id'); - self::assertTrue($userB->id > 0, 'user b has an id'); - self::assertTrue($userC->id > 0, 'user c has an id'); - self::assertEquals('UserC', $userC->name, 'name has not changed because we did not flush it'); - } - /** * @group DDC-720 */ @@ -1067,56 +1036,13 @@ public function testFlushSingleManagedEntity(): void $this->_em->flush(); $user->status = 'administrator'; - $this->_em->flush($user); + $this->_em->flush(); $this->_em->clear(); $user = $this->_em->find(get_class($user), $user->id); self::assertEquals('administrator', $user->status); } - /** - * @group DDC-720 - */ - public function testFlushSingleUnmanagedEntity(): void - { - $user = new CmsUser(); - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Entity has to be managed or scheduled for removal for single computation'); - - $this->_em->flush($user); - } - - /** - * @group DDC-720 - */ - public function testFlushSingleAndNewEntity(): void - { - $user = new CmsUser(); - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->_em->persist($user); - $this->_em->flush(); - - $otherUser = new CmsUser(); - $otherUser->name = 'Dominik2'; - $otherUser->username = 'domnikl2'; - $otherUser->status = 'developer'; - - $user->status = 'administrator'; - - $this->_em->persist($otherUser); - $this->_em->flush($user); - - self::assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); - self::assertTrue($otherUser->id > 0, 'other user has an id'); - } - /** * @group DDC-720 */ @@ -1138,7 +1064,7 @@ public function testFlushAndCascadePersist(): void $address->user = $user; $user->address = $address; - $this->_em->flush($user); + $this->_em->flush(); self::assertTrue($this->_em->contains($address), 'Other user is contained in EntityManager'); self::assertTrue($address->id > 0, 'other user has an id'); @@ -1166,7 +1092,7 @@ public function testFlushSingleAndNoCascade(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("A new entity was found through the relationship 'Doctrine\Tests\Models\CMS\CmsUser#articles'"); - $this->_em->flush($user); + $this->_em->flush(); } /** @@ -1182,72 +1108,15 @@ public function testFlushSingleNewEntityThenRemove(): void $user->status = 'developer'; $this->_em->persist($user); - $this->_em->flush($user); + $this->_em->flush(); $userId = $user->id; $this->_em->remove($user); - $this->_em->flush($user); - $this->_em->clear(); - - self::assertNull($this->_em->find(get_class($user), $userId)); - } - - /** - * @group DDC-720 - */ - public function testProxyIsIgnored(): void - { - $user = new CmsUser(); - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - - $this->_em->persist($user); $this->_em->flush(); $this->_em->clear(); - $user = $this->_em->getReference(get_class($user), $user->id); - - $otherUser = new CmsUser(); - $otherUser->name = 'Dominik2'; - $otherUser->username = 'domnikl2'; - $otherUser->status = 'developer'; - - $this->_em->persist($otherUser); - $this->_em->flush($user); - - self::assertTrue($this->_em->contains($otherUser), 'Other user is contained in EntityManager'); - self::assertTrue($otherUser->id > 0, 'other user has an id'); - } - - /** - * @group DDC-720 - */ - public function testFlushSingleSaveOnlySingle(): void - { - $user = new CmsUser(); - $user->name = 'Dominik'; - $user->username = 'domnikl'; - $user->status = 'developer'; - $this->_em->persist($user); - - $user2 = new CmsUser(); - $user2->name = 'Dominik'; - $user2->username = 'domnikl2'; - $user2->status = 'developer'; - $this->_em->persist($user2); - - $this->_em->flush(); - - $user->status = 'admin'; - $user2->status = 'admin'; - - $this->_em->flush($user); - $this->_em->clear(); - - $user2 = $this->_em->find(get_class($user2), $user2->id); - self::assertEquals('developer', $user2->status); + self::assertNull($this->_em->find(get_class($user), $userId)); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php index 0f3edecaedd..5a7bc9bc805 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php @@ -103,7 +103,7 @@ public function testMergeWithExistingUninitializedManagedProxy(): void $date = new DateTimeModel(); $this->_em->persist($date); - $this->_em->flush($date); + $this->_em->flush(); $this->_em->clear(); $managed = $this->_em->getReference(DateTimeModel::class, $date->id); diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 801aca8f7cb..e8b07733d79 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -10,7 +10,6 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadata; @@ -40,7 +39,6 @@ use stdClass; use function assert; -use function count; use function gc_collect_cycles; use function get_class; use function method_exists; @@ -52,8 +50,6 @@ */ class UnitOfWorkTest extends OrmTestCase { - use VerifyDeprecations; - /** * SUT * @@ -239,44 +235,6 @@ public function testChangeTrackingNotify(): void self::assertSame($updates[0], $item); } - public function testChangeTrackingNotifyIndividualCommit(): void - { - $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata('Doctrine\Tests\ORM\NotifyChangedEntity')); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\ORM\NotifyChangedEntity', $persister); - $itemPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata('Doctrine\Tests\ORM\NotifyChangedRelatedItem')); - $this->_unitOfWork->setEntityPersister('Doctrine\Tests\ORM\NotifyChangedRelatedItem', $itemPersister); - - $entity = new NotifyChangedEntity(); - $entity->setData('thedata'); - - $entity2 = new NotifyChangedEntity(); - $entity2->setData('thedata'); - - $this->_unitOfWork->persist($entity); - $this->_unitOfWork->persist($entity2); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8459'); - - $this->_unitOfWork->commit($entity); - $this->_unitOfWork->commit(); - - self::assertEquals(2, count($persister->getInserts())); - - $persister->reset(); - - self::assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); - - $entity->setData('newdata'); - $entity2->setData('newdata'); - - $this->_unitOfWork->commit($entity); - - self::assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity2)); - self::assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity2)); - self::assertFalse($this->_unitOfWork->isScheduledForDirtyCheck($entity)); - self::assertEquals([], $this->_unitOfWork->getEntityChangeSet($entity)); - } - public function testGetEntityStateOnVersionedEntityWithAssignedIdentifier(): void { $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(VersionedAssignedIdentifierEntity::class)); @@ -405,53 +363,6 @@ public function testRemovedAndRePersistedEntitiesAreInTheIdentityMapAndAreNotGar self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); } - /** - * @group #5579 - */ - public function testEntityChangeSetIsNotClearedAfterFlushOnSingleEntity(): void - { - $entity1 = new NotifyChangedEntity(); - $entity2 = new NotifyChangedEntity(); - - $entity1->setData('thedata'); - $entity2->setData('thedata'); - - $this->_unitOfWork->persist($entity1); - $this->_unitOfWork->persist($entity2); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8459'); - - $this->_unitOfWork->commit($entity1); - self::assertEmpty($this->_unitOfWork->getEntityChangeSet($entity1)); - self::assertCount(1, $this->_unitOfWork->getEntityChangeSet($entity2)); - } - - /** - * @group #5579 - */ - public function testEntityChangeSetIsNotClearedAfterFlushOnArrayOfEntities(): void - { - $entity1 = new NotifyChangedEntity(); - $entity2 = new NotifyChangedEntity(); - $entity3 = new NotifyChangedEntity(); - - $entity1->setData('thedata'); - $entity2->setData('thedata'); - $entity3->setData('thedata'); - - $this->_unitOfWork->persist($entity1); - $this->_unitOfWork->persist($entity2); - $this->_unitOfWork->persist($entity3); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8459'); - - $this->_unitOfWork->commit([$entity1, $entity3]); - - self::assertEmpty($this->_unitOfWork->getEntityChangeSet($entity1)); - self::assertEmpty($this->_unitOfWork->getEntityChangeSet($entity3)); - self::assertCount(1, $this->_unitOfWork->getEntityChangeSet($entity2)); - } - /** * Data Provider * From d13d0f5848babfa71a485d0679a4f93c3ab101ad Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 9 Feb 2022 00:43:44 +0100 Subject: [PATCH 046/475] Remove ability to merge detached entities (#9488) --- UPGRADE.md | 10 + lib/Doctrine/ORM/EntityManager.php | 32 +- .../Reflection/ReflectionPropertiesGetter.php | 135 ------- lib/Doctrine/ORM/UnitOfWork.php | 364 +----------------- phpstan-baseline.neon | 10 - psalm-baseline.xml | 27 +- .../Doctrine/Tests/ORM/EntityManagerTest.php | 2 - .../ORM/Functional/BasicFunctionalTest.php | 92 ----- .../ORM/Functional/DetachedEntityTest.php | 147 ------- .../ORM/Functional/EntityRepositoryTest.php | 2 +- .../Functional/MergeCompositeToOneKeyTest.php | 48 --- .../Tests/ORM/Functional/MergeProxiesTest.php | 274 ------------- .../Functional/MergeSharedEntitiesTest.php | 170 -------- .../MergeVersionedManyToOneTest.php | 46 --- .../ORM/Functional/Ticket/DDC117Test.php | 16 - .../ORM/Functional/Ticket/DDC1276Test.php | 53 --- .../ORM/Functional/Ticket/DDC1383Test.php | 120 ------ .../ORM/Functional/Ticket/DDC1392Test.php | 130 ------- .../ORM/Functional/Ticket/DDC1509Test.php | 145 ------- .../ORM/Functional/Ticket/DDC1594Test.php | 46 --- .../ORM/Functional/Ticket/DDC1734Test.php | 88 ----- .../ORM/Functional/Ticket/DDC2230Test.php | 23 -- .../ORM/Functional/Ticket/DDC2409Test.php | 74 ---- .../ORM/Functional/Ticket/DDC2645Test.php | 78 ---- .../ORM/Functional/Ticket/DDC3699Test.php | 108 ------ .../ORM/Functional/Ticket/DDC501Test.php | 112 ------ .../ORM/Functional/Ticket/DDC518Test.php | 41 -- .../ORM/Functional/Ticket/DDC729Test.php | 213 ---------- .../ReflectionPropertiesGetterTest.php | 134 ------- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 114 ------ 30 files changed, 32 insertions(+), 2822 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Reflection/ReflectionPropertiesGetter.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php diff --git a/UPGRADE.md b/UPGRADE.md index a7d7824c10b..5b84d48a366 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade to 3.0 +## BC BREAK: Remove ability to merge detached entities + +Merge semantics was a poor fit for the PHP "share-nothing" architecture. +In addition to that, merging caused multiple issues with data integrity +in the managed entity graph, which was constantly spawning more edge-case +bugs/scenarios. + +The method `UnitOfWork::merge()` has been removed. The method +`EntityManager::merge()` will throw an exception on each call. + ## BC BREAK: Removed ability to partially flush/commit entity manager and unit of work The following methods don't accept a single entity or an array of entities anymore: diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 4b6cf01d825..32e1df09c3a 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -4,13 +4,13 @@ namespace Doctrine\ORM; +use BadMethodCallException; use Doctrine\Common\EventManager; use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Exception\InvalidHydrationMode; use Doctrine\ORM\Exception\ManagerException; @@ -542,35 +542,15 @@ public function detach($entity): void } /** - * Merges the state of a detached entity into the persistence context - * of this EntityManager and returns the managed copy of the entity. - * The entity passed to merge will not become associated/managed with this EntityManager. + * Not supported. * - * @deprecated 2.7 This method is being removed from the ORM and won't have any replacement + * @param object $object * - * @param object $entity The detached entity to merge into the persistence context. - * - * @return object The managed copy of the entity. - * - * @throws ORMInvalidArgumentException - * @throws ORMException + * @psalm-return never */ - public function merge($entity): object + public function merge($object): object { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8461', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0.', - __METHOD__ - ); - - if (! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#merge()', $entity); - } - - $this->errorIfClosed(); - - return $this->unitOfWork->merge($entity); + throw new BadMethodCallException('The merge operation is not supported.'); } /** diff --git a/lib/Doctrine/ORM/Mapping/Reflection/ReflectionPropertiesGetter.php b/lib/Doctrine/ORM/Mapping/Reflection/ReflectionPropertiesGetter.php deleted file mode 100644 index c1bfe8553a8..00000000000 --- a/lib/Doctrine/ORM/Mapping/Reflection/ReflectionPropertiesGetter.php +++ /dev/null @@ -1,135 +0,0 @@ -reflectionService = $reflectionService; - } - - /** - * @param string $className - * @psalm-param class-string $className - * - * @return ReflectionProperty[] indexed by property internal name - */ - public function getProperties($className): array - { - if (isset($this->properties[$className])) { - return $this->properties[$className]; - } - - return $this->properties[$className] = call_user_func_array( - 'array_merge', - // first merge because `array_merge` expects >= 1 params - array_merge( - [[]], - array_map( - [$this, 'getClassProperties'], - $this->getHierarchyClasses($className) - ) - ) - ); - } - - /** - * @psalm-param class-string $className - * - * @return ReflectionClass[] - * @psalm-return list> - */ - private function getHierarchyClasses(string $className): array - { - $classes = []; - $parentClassName = $className; - - while ($parentClassName && $currentClass = $this->reflectionService->getClass($parentClassName)) { - $classes[] = $currentClass; - $parentClassName = null; - - $parentClass = $currentClass->getParentClass(); - if ($parentClass) { - $parentClassName = $parentClass->getName(); - } - } - - return $classes; - } - - // phpcs:disable SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod - - /** - * @return ReflectionProperty[] - * @psalm-return array - */ - private function getClassProperties(ReflectionClass $reflectionClass): array - { - // phpcs:enable SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod - $properties = $reflectionClass->getProperties(); - - return array_filter( - array_filter(array_map( - [$this, 'getAccessibleProperty'], - array_combine( - array_map([$this, 'getLogicalName'], $properties), - $properties - ) - )), - [$this, 'isInstanceProperty'] - ); - } - - private function isInstanceProperty(ReflectionProperty $reflectionProperty): bool - { - return ! $reflectionProperty->isStatic(); - } - - private function getAccessibleProperty(ReflectionProperty $property): ?ReflectionProperty - { - return $this->reflectionService->getAccessibleProperty( - $property->getDeclaringClass()->getName(), - $property->getName() - ); - } - - private function getLogicalName(ReflectionProperty $property): string - { - $propertyName = $property->getName(); - - if ($property->isPublic()) { - return $propertyName; - } - - if ($property->isProtected()) { - return "\0*\0" . $propertyName; - } - - return "\0" . $property->getDeclaringClass()->getName() . "\0" . $propertyName; - } -} diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 19d2ab9e67c..b513639c342 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -26,7 +26,6 @@ use Doctrine\ORM\Internal\HydrationCompleteHandler; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; -use Doctrine\ORM\Mapping\Reflection\ReflectionPropertiesGetter; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\ORM\Persisters\Collection\ManyToManyPersister; use Doctrine\ORM\Persisters\Collection\OneToManyPersister; @@ -35,7 +34,6 @@ use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister; use Doctrine\ORM\Persisters\Entity\SingleTablePersister; use Doctrine\ORM\Utility\IdentifierFlattener; -use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Persistence\NotifyPropertyChanged; use Doctrine\Persistence\ObjectManagerAware; use Doctrine\Persistence\PropertyChangedListener; @@ -228,11 +226,6 @@ class UnitOfWork implements PropertyChangedListener */ private array $visitedCollections = []; - /** - * The EntityManager that "owns" this UnitOfWork instance. - */ - private EntityManagerInterface $em; - /** * The entity persister instances used to persist entity instances. * @@ -290,20 +283,19 @@ class UnitOfWork implements PropertyChangedListener */ private HydrationCompleteHandler $hydrationCompleteHandler; - private ReflectionPropertiesGetter $reflectionPropertiesGetter; - /** * Initializes a new UnitOfWork instance, bound to the given EntityManager. + * + * @param EntityManagerInterface $em The EntityManager that "owns" this UnitOfWork instance. */ - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; - $this->evm = $em->getEventManager(); - $this->listenersInvoker = new ListenersInvoker($em); - $this->hasCache = $em->getConfiguration()->isSecondLevelCacheEnabled(); - $this->identifierFlattener = new IdentifierFlattener($this, $em->getMetadataFactory()); - $this->hydrationCompleteHandler = new HydrationCompleteHandler($this->listenersInvoker, $em); - $this->reflectionPropertiesGetter = new ReflectionPropertiesGetter(new RuntimeReflectionService()); + public function __construct( + private EntityManagerInterface $em + ) { + $this->evm = $em->getEventManager(); + $this->listenersInvoker = new ListenersInvoker($em); + $this->hasCache = $em->getConfiguration()->isSecondLevelCacheEnabled(); + $this->identifierFlattener = new IdentifierFlattener($this, $em->getMetadataFactory()); + $this->hydrationCompleteHandler = new HydrationCompleteHandler($this->listenersInvoker, $em); } /** @@ -1724,198 +1716,6 @@ private function doRemove(object $entity, array &$visited): void } } - /** - * Merges the state of the given detached entity into this UnitOfWork. - * - * @deprecated 2.7 This method is being removed from the ORM and won't have any replacement - * - * @return object The managed copy of the entity. - * - * @throws OptimisticLockException If the entity uses optimistic locking through a version - * attribute and the version check against the managed copy fails. - */ - public function merge(object $entity): object - { - $visited = []; - - return $this->doMerge($entity, $visited); - } - - /** - * Executes a merge operation on an entity. - * - * @param string[] $assoc - * @psalm-param array $visited - * - * @return object The managed copy of the entity. - * - * @throws OptimisticLockException If the entity uses optimistic locking through a version - * attribute and the version check against the managed copy fails. - * @throws ORMInvalidArgumentException If the entity instance is NEW. - * @throws EntityNotFoundException if an assigned identifier is used in the entity, but none is provided. - */ - private function doMerge( - object $entity, - array &$visited, - ?object $prevManagedCopy = null, - array $assoc = [] - ): object { - $oid = spl_object_id($entity); - - if (isset($visited[$oid])) { - $managedCopy = $visited[$oid]; - - if ($prevManagedCopy !== null) { - $this->updateAssociationWithMergedEntity($entity, $assoc, $prevManagedCopy, $managedCopy); - } - - return $managedCopy; - } - - $class = $this->em->getClassMetadata(get_class($entity)); - - // First we assume DETACHED, although it can still be NEW but we can avoid - // an extra db-roundtrip this way. If it is not MANAGED but has an identity, - // we need to fetch it from the db anyway in order to merge. - // MANAGED entities are ignored by the merge operation. - $managedCopy = $entity; - - if ($this->getEntityState($entity, self::STATE_DETACHED) !== self::STATE_MANAGED) { - // Try to look the entity up in the identity map. - $id = $class->getIdentifierValues($entity); - - // If there is no ID, it is actually NEW. - if (! $id) { - $managedCopy = $this->newInstance($class); - - $this->mergeEntityStateIntoManagedCopy($entity, $managedCopy); - $this->persistNew($class, $managedCopy); - } else { - $flatId = $class->containsForeignIdentifier - ? $this->identifierFlattener->flattenIdentifier($class, $id) - : $id; - - $managedCopy = $this->tryGetById($flatId, $class->rootEntityName); - - if ($managedCopy) { - // We have the entity in-memory already, just make sure its not removed. - if ($this->getEntityState($managedCopy) === self::STATE_REMOVED) { - throw ORMInvalidArgumentException::entityIsRemoved($managedCopy, 'merge'); - } - } else { - // We need to fetch the managed copy in order to merge. - $managedCopy = $this->em->find($class->name, $flatId); - } - - if ($managedCopy === null) { - // If the identifier is ASSIGNED, it is NEW, otherwise an error - // since the managed entity was not found. - if (! $class->isIdentifierNatural()) { - throw EntityNotFoundException::fromClassNameAndIdentifier( - $class->getName(), - $this->identifierFlattener->flattenIdentifier($class, $id) - ); - } - - $managedCopy = $this->newInstance($class); - $class->setIdentifierValues($managedCopy, $id); - - $this->mergeEntityStateIntoManagedCopy($entity, $managedCopy); - $this->persistNew($class, $managedCopy); - } else { - $this->ensureVersionMatch($class, $entity, $managedCopy); - $this->mergeEntityStateIntoManagedCopy($entity, $managedCopy); - } - } - - $visited[$oid] = $managedCopy; // mark visited - - if ($class->isChangeTrackingDeferredExplicit()) { - $this->scheduleForDirtyCheck($entity); - } - } - - if ($prevManagedCopy !== null) { - $this->updateAssociationWithMergedEntity($entity, $assoc, $prevManagedCopy, $managedCopy); - } - - // Mark the managed copy visited as well - $visited[spl_object_id($managedCopy)] = $managedCopy; - - $this->cascadeMerge($entity, $managedCopy, $visited); - - return $managedCopy; - } - - /** - * @psalm-param ClassMetadata $class - * @psalm-param T $entity - * @psalm-param T $managedCopy - * - * @throws OptimisticLockException - * - * @template T of object - */ - private function ensureVersionMatch( - ClassMetadata $class, - object $entity, - object $managedCopy - ): void { - if (! ($class->isVersioned && $this->isLoaded($managedCopy) && $this->isLoaded($entity))) { - return; - } - - $reflField = $class->reflFields[$class->versionField]; - $managedCopyVersion = $reflField->getValue($managedCopy); - $entityVersion = $reflField->getValue($entity); - - // Throw exception if versions don't match. - // phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedEqualOperator - if ($managedCopyVersion == $entityVersion) { - return; - } - - throw OptimisticLockException::lockFailedVersionMismatch($entity, $entityVersion, $managedCopyVersion); - } - - /** - * Tests if an entity is loaded - must either be a loaded proxy or not a proxy - */ - private function isLoaded(object $entity): bool - { - return ! ($entity instanceof Proxy) || $entity->__isInitialized(); - } - - /** - * Sets/adds associated managed copies into the previous entity's association field - * - * @param string[] $association - */ - private function updateAssociationWithMergedEntity( - object $entity, - array $association, - object $previousManagedCopy, - object $managedCopy - ): void { - $assocField = $association['fieldName']; - $prevClass = $this->em->getClassMetadata(get_class($previousManagedCopy)); - - if ($association['type'] & ClassMetadata::TO_ONE) { - $prevClass->reflFields[$assocField]->setValue($previousManagedCopy, $managedCopy); - - return; - } - - $value = $prevClass->reflFields[$assocField]->getValue($previousManagedCopy); - $value[] = $managedCopy; - - if ($association['type'] === ClassMetadata::ONE_TO_MANY) { - $class = $this->em->getClassMetadata(get_class($entity)); - - $class->reflFields[$association['mappedBy']]->setValue($managedCopy, $previousManagedCopy); - } - } - /** * Detaches an entity from the persistence management. It's persistence will * no longer be managed by Doctrine. @@ -2101,44 +1901,6 @@ static function (array $assoc) { } } - /** - * Cascades a merge operation to associated entities. - * - * @psalm-param array $visited - */ - private function cascadeMerge(object $entity, object $managedCopy, array &$visited): void - { - $class = $this->em->getClassMetadata(get_class($entity)); - - $associationMappings = array_filter( - $class->associationMappings, - static function (array $assoc) { - return $assoc['isCascadeMerge']; - } - ); - - foreach ($associationMappings as $assoc) { - $relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); - - if ($relatedEntities instanceof Collection) { - if ($relatedEntities === $class->reflFields[$assoc['fieldName']]->getValue($managedCopy)) { - continue; - } - - if ($relatedEntities instanceof PersistentCollection) { - // Unwrap so that foreach() does not initialize - $relatedEntities = $relatedEntities->unwrap(); - } - - foreach ($relatedEntities as $relatedEntity) { - $this->doMerge($relatedEntity, $visited, $managedCopy, $assoc); - } - } elseif ($relatedEntities !== null) { - $this->doMerge($relatedEntities, $visited, $managedCopy, $assoc); - } - } - } - /** * Cascades the save operation to associated entities. * @@ -3194,112 +2956,6 @@ private function assertThatThereAreNoUnintentionallyNonPersistedAssociations(): } } - /** - * @throws ORMException - * @throws OptimisticLockException - * @throws TransactionRequiredException - */ - private function mergeEntityStateIntoManagedCopy(object $entity, object $managedCopy): void - { - if (! $this->isLoaded($entity)) { - return; - } - - if (! $this->isLoaded($managedCopy)) { - $managedCopy->__load(); - } - - $class = $this->em->getClassMetadata(get_class($entity)); - - foreach ($this->reflectionPropertiesGetter->getProperties($class->name) as $prop) { - $name = $prop->name; - - $prop->setAccessible(true); - - if (! isset($class->associationMappings[$name])) { - if (! $class->isIdentifier($name)) { - $prop->setValue($managedCopy, $prop->getValue($entity)); - } - } else { - $assoc2 = $class->associationMappings[$name]; - - if ($assoc2['type'] & ClassMetadata::TO_ONE) { - $other = $prop->getValue($entity); - if ($other === null) { - $prop->setValue($managedCopy, null); - } else { - if ($other instanceof Proxy && ! $other->__isInitialized()) { - // do not merge fields marked lazy that have not been fetched. - continue; - } - - if (! $assoc2['isCascadeMerge']) { - if ($this->getEntityState($other) === self::STATE_DETACHED) { - $targetClass = $this->em->getClassMetadata($assoc2['targetEntity']); - $relatedId = $targetClass->getIdentifierValues($other); - - if ($targetClass->subClasses) { - $other = $this->em->find($targetClass->name, $relatedId); - } else { - $other = $this->em->getProxyFactory()->getProxy( - $assoc2['targetEntity'], - $relatedId - ); - $this->registerManaged($other, $relatedId, []); - } - } - - $prop->setValue($managedCopy, $other); - } - } - } else { - $mergeCol = $prop->getValue($entity); - - if ($mergeCol instanceof PersistentCollection && ! $mergeCol->isInitialized()) { - // do not merge fields marked lazy that have not been fetched. - // keep the lazy persistent collection of the managed copy. - continue; - } - - $managedCol = $prop->getValue($managedCopy); - - if (! $managedCol) { - $managedCol = new PersistentCollection( - $this->em, - $this->em->getClassMetadata($assoc2['targetEntity']), - new ArrayCollection() - ); - $managedCol->setOwner($managedCopy, $assoc2); - $prop->setValue($managedCopy, $managedCol); - } - - if ($assoc2['isCascadeMerge']) { - $managedCol->initialize(); - - // clear and set dirty a managed collection if its not also the same collection to merge from. - if (! $managedCol->isEmpty() && $managedCol !== $mergeCol) { - $managedCol->unwrap()->clear(); - $managedCol->setDirty(true); - - if ( - $assoc2['isOwningSide'] - && $assoc2['type'] === ClassMetadata::MANY_TO_MANY - && $class->isChangeTrackingNotify() - ) { - $this->scheduleForDirtyCheck($managedCopy); - } - } - } - } - } - - if ($class->isChangeTrackingNotify()) { - // Just treat all properties as changed, there is no other choice. - $this->propertyChanged($managedCopy, $name, null, $prop->getValue($managedCopy)); - } - } - } - /** * This method called by hydrators, and indicates that hydrator totally completed current hydration cycle. * Unit of work able to fire deferred events, related to loading events here. diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e5f7b802fad..4d275f3b11d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1400,11 +1400,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Tools/SchemaTool.php - - - message: "#^Binary operation \"&\" between string and 3 results in an error\\.$#" - count: 1 - path: lib/Doctrine/ORM/UnitOfWork.php - - message: "#^Call to an undefined method Doctrine\\\\Common\\\\Collections\\\\Collection\\<\\(int\\|string\\), object\\>\\:\\:getMapping\\(\\)\\.$#" count: 2 @@ -1430,11 +1425,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/UnitOfWork.php - - - message: "#^Strict comparison using \\=\\=\\= between string and 4 will always evaluate to false\\.$#" - count: 1 - path: lib/Doctrine/ORM/UnitOfWork.php - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$name\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 3b0c2b33c6d..668f827b87a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -244,14 +244,12 @@ ProxyFactory ProxyFactory - + getAutoGenerateProxyClasses getProxyDir getProxyNamespace - merge - - is_object($entity) + is_object($entity) is_object($entity) is_object($entity) @@ -282,8 +280,7 @@ EntityRepository<T> - - $entity + $entity $entity $entity @@ -2800,25 +2797,17 @@ $collectionToUpdate $commitOrder[$i] - - $association['type'] === ClassMetadata::ONE_TO_MANY - $association['type'] === ClassMetadata::ONE_TO_MANY - $em->getMetadataFactory() object - - $association['type'] - $this->entityChangeSets $this->entityChangeSets - - static function (array $assoc) { + static function (array $assoc) { static function (array $assoc) { static function (array $assoc) { @@ -2845,7 +2834,7 @@ $assoc['targetEntity'] $assoc['type'] - + buildCachedCollectionPersister buildCachedEntityPersister getCacheFactory @@ -2858,12 +2847,6 @@ getValue getValue getValue - getValue - getValue - getValue - getValue - setValue - setValue setValue setValue setValue diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 52883c64f2b..4a63c50c951 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -129,7 +129,6 @@ public static function dataMethodsAffectedByNoObjectArguments(): array return [ ['persist'], ['remove'], - ['merge'], ['refresh'], ['detach'], ]; @@ -155,7 +154,6 @@ public static function dataAffectedByErrorIfClosedException(): array ['flush'], ['persist'], ['remove'], - ['merge'], ['refresh'], ]; } diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index e71532de57b..d264a635b34 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\PersistentCollection; @@ -900,97 +899,6 @@ public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void self::assertEquals('Benjamin E.', $this->_em->find(get_class($user), $userId)->name); } - public function testMergePersistsNewEntities(): void - { - $user = new CmsUser(); - $user->username = 'beberlei'; - $user->name = 'Benjamin E.'; - $user->status = 'active'; - - $managedUser = $this->_em->merge($user); - self::assertEquals('beberlei', $managedUser->username); - self::assertEquals('Benjamin E.', $managedUser->name); - self::assertEquals('active', $managedUser->status); - - self::assertTrue($user !== $managedUser); - self::assertTrue($this->_em->contains($managedUser)); - - $this->_em->flush(); - $userId = $managedUser->id; - $this->_em->clear(); - - $user2 = $this->_em->find(get_class($managedUser), $userId); - self::assertInstanceOf(CmsUser::class, $user2); - } - - public function testMergeNonPersistedProperties(): void - { - $user = new CmsUser(); - $user->username = 'beberlei'; - $user->name = 'Benjamin E.'; - $user->status = 'active'; - $user->nonPersistedProperty = 'test'; - $user->nonPersistedPropertyObject = new CmsPhonenumber(); - - $managedUser = $this->_em->merge($user); - self::assertEquals('test', $managedUser->nonPersistedProperty); - self::assertSame($user->nonPersistedProperty, $managedUser->nonPersistedProperty); - self::assertSame($user->nonPersistedPropertyObject, $managedUser->nonPersistedPropertyObject); - - self::assertTrue($user !== $managedUser); - self::assertTrue($this->_em->contains($managedUser)); - - $this->_em->flush(); - $userId = $managedUser->id; - $this->_em->clear(); - - $user2 = $this->_em->find(get_class($managedUser), $userId); - self::assertNull($user2->nonPersistedProperty); - self::assertNull($user2->nonPersistedPropertyObject); - self::assertEquals('active', $user2->status); - } - - public function testMergeThrowsExceptionIfEntityWithGeneratedIdentifierDoesNotExist(): void - { - $user = new CmsUser(); - $user->username = 'beberlei'; - $user->name = 'Benjamin E.'; - $user->status = 'active'; - $user->id = 42; - - $this->expectException(EntityNotFoundException::class); - $this->_em->merge($user); - } - - /** - * @group DDC-634 - */ - public function testOneToOneMergeSetNull(): void - { - $user = new CmsUser(); - $user->username = 'beberlei'; - $user->name = 'Benjamin E.'; - $user->status = 'active'; - - $ph = new CmsPhonenumber(); - $ph->phonenumber = '12345'; - $user->addPhonenumber($ph); - - $this->_em->persist($user); - $this->_em->persist($ph); - $this->_em->flush(); - - $this->_em->clear(); - - $ph->user = null; - $managedPh = $this->_em->merge($ph); - - $this->_em->flush(); - $this->_em->clear(); - - self::assertNull($this->_em->find(get_class($ph), $ph->phonenumber)->getUser()); - } - /** * @group DDC-952 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index 463eef39003..37461ed8f1c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -5,19 +5,10 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; -use Doctrine\ORM\OptimisticLockException; -use Doctrine\ORM\Proxy\Proxy; -use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -use function count; -use function get_class; -use function serialize; -use function unserialize; - /** * Description of DetachedEntityTest */ @@ -29,89 +20,6 @@ protected function setUp(): void parent::setUp(); } - public function testSimpleDetachMerge(): void - { - $user = new CmsUser(); - $user->name = 'Roman'; - $user->username = 'romanb'; - $user->status = 'dev'; - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - // $user is now detached - self::assertFalse($this->_em->contains($user)); - - $user->name = 'Roman B.'; - - $user2 = $this->_em->merge($user); - - self::assertFalse($user === $user2); - self::assertTrue($this->_em->contains($user2)); - self::assertEquals('Roman B.', $user2->name); - } - - public function testSerializeUnserializeModifyMerge(): void - { - $user = new CmsUser(); - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $ph1 = new CmsPhonenumber(); - $ph1->phonenumber = '1234'; - $user->addPhonenumber($ph1); - - $this->_em->persist($user); - $this->_em->flush(); - - self::assertTrue($this->_em->contains($user)); - self::assertTrue($user->phonenumbers->isInitialized()); - - $serialized = serialize($user); - - $this->_em->clear(); - - self::assertFalse($this->_em->contains($user)); - - unset($user); - - $user = unserialize($serialized); - - self::assertEquals(1, count($user->getPhonenumbers()), 'Pre-Condition: 1 Phonenumber'); - - $ph2 = new CmsPhonenumber(); - - $ph2->phonenumber = '56789'; - $user->addPhonenumber($ph2); - - $oldPhonenumbers = $user->getPhonenumbers(); - - self::assertEquals(2, count($oldPhonenumbers), 'Pre-Condition: 2 Phonenumbers'); - self::assertFalse($this->_em->contains($user)); - - $this->_em->persist($ph2); - - // Merge back in - $user = $this->_em->merge($user); // merge cascaded to phonenumbers - self::assertInstanceOf(CmsUser::class, $user->phonenumbers[0]->user); - self::assertInstanceOf(CmsUser::class, $user->phonenumbers[1]->user); - $im = $this->_em->getUnitOfWork()->getIdentityMap(); - $this->_em->flush(); - - self::assertTrue($this->_em->contains($user), 'Failed to assert that merged user is contained inside EntityManager persistence context.'); - $phonenumbers = $user->getPhonenumbers(); - self::assertNotSame($oldPhonenumbers, $phonenumbers, 'Merge should replace the Detached Collection with a new PersistentCollection.'); - self::assertEquals(2, count($phonenumbers), 'Failed to assert that two phonenumbers are contained in the merged users phonenumber collection.'); - - self::assertInstanceOf(CmsPhonenumber::class, $phonenumbers[1]); - self::assertTrue($this->_em->contains($phonenumbers[1]), 'Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context.'); - - self::assertInstanceOf(CmsPhonenumber::class, $phonenumbers[0]); - self::assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($phonenumbers[0])); - self::assertTrue($this->_em->contains($phonenumbers[0]), 'Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context.'); - } - /** * @group DDC-203 */ @@ -131,38 +39,6 @@ public function testDetachedEntityThrowsExceptionOnFlush(): void $this->_em->flush(); } - public function testUninitializedLazyAssociationsAreIgnoredOnMerge(): void - { - $user = new CmsUser(); - $user->name = 'Guilherme'; - $user->username = 'gblanco'; - $user->status = 'developer'; - - $address = new CmsAddress(); - $address->city = 'Berlin'; - $address->country = 'Germany'; - $address->street = 'Sesamestreet'; - $address->zip = 12345; - $address->setUser($user); - $this->_em->persist($address); - $this->_em->persist($user); - - $this->_em->flush(); - $this->_em->clear(); - - $address2 = $this->_em->find(get_class($address), $address->id); - self::assertInstanceOf(Proxy::class, $address2->user); - self::assertFalse($address2->user->__isInitialized__); - $detachedAddress2 = unserialize(serialize($address2)); - self::assertInstanceOf(Proxy::class, $detachedAddress2->user); - self::assertFalse($detachedAddress2->user->__isInitialized__); - - $managedAddress2 = $this->_em->merge($detachedAddress2); - self::assertInstanceOf(Proxy::class, $managedAddress2->user); - self::assertFalse($managedAddress2->user === $detachedAddress2->user); - self::assertFalse($managedAddress2->user->__isInitialized__); - } - /** * @group DDC-822 */ @@ -206,27 +82,4 @@ public function testDetachManagedUnpersistedEntity(): void self::assertFalse($this->_em->contains($user)); self::assertFalse($this->_em->getUnitOfWork()->isInIdentityMap($user)); } - - /** - * @group DDC-1340 - */ - public function testMergeArticleWrongVersion(): void - { - $article = new CmsArticle(); - $article->topic = 'test'; - $article->text = 'test'; - - $this->_em->persist($article); - $this->_em->flush(); - - $this->_em->detach($article); - - $sql = 'UPDATE cms_articles SET version = version + 1 WHERE id = ' . $article->id; - $this->_em->getConnection()->executeStatement($sql); - - $this->expectException(OptimisticLockException::class); - $this->expectExceptionMessage('The optimistic lock failed, version 1 was expected, but is actually 2'); - - $this->_em->merge($article); - } } diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 3a125acc4fa..a4237dfdb1c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -939,7 +939,7 @@ public function testMatchingCriteriaEndsWithComparison(): void public function testMatchingCriteriaNullAssocComparison(): void { $fixtures = $this->loadFixtureUserEmail(); - $user = $this->_em->merge($fixtures[0]); + $user = $this->_em->find(CmsUser::class, $fixtures[0]->id); $repository = $this->_em->getRepository(CmsUser::class); $criteriaIsNull = Criteria::create()->where(Criteria::expr()->isNull('email')); $criteriaEqNull = Criteria::create()->where(Criteria::expr()->eq('email', null)); diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php deleted file mode 100644 index e4672d9ffe1..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php +++ /dev/null @@ -1,48 +0,0 @@ -_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(Country::class), - $this->_em->getClassMetadata(CompositeToOneKeyState::class), - ] - ); - } - - /** - * @group DDC-3378 - * @group 1176 - */ - public function testMergingOfEntityWithCompositeIdentifierContainingToOneAssociation(): void - { - $country = new Country(); - $country->country = 'US'; - - $state = new CompositeToOneKeyState(); - $state->state = 'CA'; - $state->country = $country; - - $merged = $this->_em->merge($state); - assert($merged instanceof CompositeToOneKeyState); - - self::assertInstanceOf(CompositeToOneKeyState::class, $state); - self::assertNotSame($state, $merged); - self::assertInstanceOf(Country::class, $merged->country); - self::assertNotSame($country, $merged->country); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php deleted file mode 100644 index 5a7bc9bc805..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php +++ /dev/null @@ -1,274 +0,0 @@ -useModelSet('generic'); - - parent::setUp(); - } - - /** - * @group DDC-1392 - * @group DDC-1734 - * @group DDC-3368 - * @group #1172 - */ - public function testMergeDetachedUnInitializedProxy(): void - { - $detachedUninitialized = $this->_em->getReference(DateTimeModel::class, 123); - - $this->_em->clear(); - - $managed = $this->_em->getReference(DateTimeModel::class, 123); - - self::assertSame($managed, $this->_em->merge($detachedUninitialized)); - - self::assertFalse($managed->__isInitialized()); - self::assertFalse($detachedUninitialized->__isInitialized()); - } - - /** - * @group DDC-1392 - * @group DDC-1734 - * @group DDC-3368 - * @group #1172 - */ - public function testMergeUnserializedUnInitializedProxy(): void - { - $detachedUninitialized = $this->_em->getReference(DateTimeModel::class, 123); - - $this->_em->clear(); - - $managed = $this->_em->getReference(DateTimeModel::class, 123); - - self::assertSame( - $managed, - $this->_em->merge(unserialize(serialize($this->_em->merge($detachedUninitialized)))) - ); - - self::assertFalse($managed->__isInitialized()); - self::assertFalse($detachedUninitialized->__isInitialized()); - } - - /** - * @group DDC-1392 - * @group DDC-1734 - * @group DDC-3368 - * @group #1172 - */ - public function testMergeManagedProxy(): void - { - $managed = $this->_em->getReference(DateTimeModel::class, 123); - - self::assertSame($managed, $this->_em->merge($managed)); - - self::assertFalse($managed->__isInitialized()); - } - - /** - * @group DDC-1392 - * @group DDC-1734 - * @group DDC-3368 - * @group #1172 - * - * Bug discovered while working on DDC-2704 - merging towards un-initialized proxies does not initialize them, - * causing merged data to be lost when they are actually initialized - */ - public function testMergeWithExistingUninitializedManagedProxy(): void - { - $date = new DateTimeModel(); - - $this->_em->persist($date); - $this->_em->flush(); - $this->_em->clear(); - - $managed = $this->_em->getReference(DateTimeModel::class, $date->id); - - self::assertInstanceOf(Proxy::class, $managed); - self::assertFalse($managed->__isInitialized()); - - $date->date = $dateTime = new DateTime(); - - self::assertSame($managed, $this->_em->merge($date)); - self::assertTrue($managed->__isInitialized()); - self::assertSame($dateTime, $managed->date, 'Data was merged into the proxy after initialization'); - } - - /** - * @group DDC-1392 - * @group DDC-1734 - * @group DDC-3368 - * @group #1172 - */ - public function testMergingProxyFromDifferentEntityManagerWithExistingManagedInstanceDoesNotReplaceInitializer(): void - { - $em1 = $this->createEntityManager(); - $em2 = $this->createEntityManager(); - - $file1 = new DateTimeModel(); - $file2 = new DateTimeModel(); - - $em1->persist($file1); - $em2->persist($file2); - $em1->flush(); - $em2->flush(); - $em1->clear(); - $em2->clear(); - - $logger1 = $this->getResetQueryLogFromEntityManager($em1); - $logger2 = $this->getResetQueryLogFromEntityManager($em2); - - $proxy1 = $em1->getReference(DateTimeModel::class, $file1->id); - $proxy2 = $em2->getReference(DateTimeModel::class, $file1->id); - $merged2 = $em2->merge($proxy1); - - self::assertNotSame($proxy1, $merged2); - self::assertSame($proxy2, $merged2); - - self::assertFalse($proxy1->__isInitialized()); - self::assertFalse($proxy2->__isInitialized()); - - $proxy1->__load(); - - self::assertCount( - 1, - $logger1->queries, - 'Loading the first proxy was done through the first entity manager' - ); - self::assertCount( - 0, - $logger2->queries, - 'No queries were executed on the second entity manager, as it is unrelated with the first proxy' - ); - - $proxy2->__load(); - - self::assertCount( - 1, - $logger1->queries, - 'Loading the second proxy does not affect the first entity manager' - ); - self::assertCount( - 1, - $logger2->queries, - 'Loading of the second proxy instance was done through the second entity manager' - ); - } - - /** - * @group DDC-1392 - * @group DDC-1734 - * @group DDC-3368 - * @group #1172 - */ - public function testMergingUnInitializedProxyDoesNotInitializeIt(): void - { - $em1 = $this->createEntityManager(); - $em2 = $this->createEntityManager(); - - $file1 = new DateTimeModel(); - $file2 = new DateTimeModel(); - - $em1->persist($file1); - $em2->persist($file2); - $em1->flush(); - $em2->flush(); - $em1->clear(); - $em2->clear(); - - $logger1 = $this->getResetQueryLogFromEntityManager($em1); - $logger2 = $this->getResetQueryLogFromEntityManager($em2); - - $unManagedProxy = $em1->getReference(DateTimeModel::class, $file1->id); - $mergedInstance = $em2->merge($unManagedProxy); - - self::assertNotInstanceOf(Proxy::class, $mergedInstance); - self::assertNotSame($unManagedProxy, $mergedInstance); - self::assertFalse($unManagedProxy->__isInitialized()); - - self::assertCount( - 0, - $logger1->queries, - 'Loading the merged instance affected only the first entity manager' - ); - self::assertCount( - 1, - $logger2->queries, - 'Loading the merged instance was done via the second entity manager' - ); - - $unManagedProxy->__load(); - - self::assertCount( - 1, - $logger1->queries, - 'Loading the first proxy was done through the first entity manager' - ); - self::assertCount( - 1, - $logger2->queries, - 'No queries were executed on the second entity manager, as it is unrelated with the first proxy' - ); - } - - private function createEntityManager(): EntityManagerInterface - { - $config = new Configuration(); - - $config->setProxyDir(realpath(__DIR__ . '/../../Proxies')); - $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver( - [realpath(__DIR__ . '/../../Models/Cache')] - )); - - // always runs on sqlite to prevent multi-connection race-conditions with the test suite - // multi-connection is not relevant for the purpose of checking locking here, but merely - // to stub out DB-level access and intercept it - $connection = DriverManager::getConnection( - [ - 'driver' => 'pdo_sqlite', - 'memory' => true, - 'wrapperClass' => Connection::class, - ], - $config - ); - - $entityManager = EntityManager::create($connection, $config); - - (new SchemaTool($entityManager))->createSchema([$entityManager->getClassMetadata(DateTimeModel::class)]); - - return $entityManager; - } - - private function getResetQueryLogFromEntityManager(EntityManagerInterface $entityManager): QueryLog - { - $connection = $entityManager->getConnection(); - assert($connection instanceof Connection); - - return $connection->queryLog->reset()->enable(); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php deleted file mode 100644 index e5b5705c12e..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php +++ /dev/null @@ -1,170 +0,0 @@ -_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(MSEFile::class), - $this->_em->getClassMetadata(MSEPicture::class), - ] - ); - } catch (ToolsException $ignored) { - } - } - - public function testMergeSharedNewEntities(): void - { - $file = new MSEFile(); - $picture = new MSEPicture(); - - $picture->file = $file; - $picture->otherFile = $file; - - $picture = $this->_em->merge($picture); - - self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); - } - - public function testMergeSharedManagedEntities(): void - { - $file = new MSEFile(); - $picture = new MSEPicture(); - - $picture->file = $file; - $picture->otherFile = $file; - - $this->_em->persist($file); - $this->_em->persist($picture); - $this->_em->flush(); - $this->_em->clear(); - - $picture = $this->_em->merge($picture); - - self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); - } - - public function testMergeSharedDetachedSerializedEntities(): void - { - $file = new MSEFile(); - $picture = new MSEPicture(); - - $picture->file = $file; - $picture->otherFile = $file; - - $serializedPicture = serialize($picture); - - $this->_em->persist($file); - $this->_em->persist($picture); - $this->_em->flush(); - $this->_em->clear(); - - $picture = $this->_em->merge(unserialize($serializedPicture)); - - self::assertEquals($picture->file, $picture->otherFile, 'Identical entities must remain identical'); - } - - /** - * @group DDC-2704 - */ - public function testMergeInheritedTransientPrivateProperties(): void - { - $admin1 = new MSEAdmin(); - $admin2 = new MSEAdmin(); - - $admin1->id = 123; - $admin2->id = 123; - - $this->_em->persist($admin1); - - $admin2->setSession('zeh current session data'); - - self::assertSame($admin1, $this->_em->merge($admin2)); - self::assertSame('zeh current session data', $admin1->getSession()); - } -} - -/** @Entity */ -class MSEPicture -{ - /** - * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue - */ - public $id; - - /** - * @var MSEFile - * @ManyToOne(targetEntity="MSEFile", cascade={"merge"}) - */ - public $file; - - /** - * @var MSEFile - * @ManyToOne(targetEntity="MSEFile", cascade={"merge"}) - */ - public $otherFile; -} - -/** @Entity */ -class MSEFile -{ - /** - * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - public $id; -} - -/** @MappedSuperclass */ -abstract class MSEUser -{ - /** @var string */ - private $session; // intentionally transient property - - public function getSession(): string - { - return $this->session; - } - - public function setSession(string $session): void - { - $this->session = $session; - } -} - -/** @Entity */ -class MSEAdmin extends MSEUser -{ - /** - * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="NONE") - */ - public $id; -} diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php deleted file mode 100644 index ae1ea0786b9..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php +++ /dev/null @@ -1,46 +0,0 @@ -useModelSet('versioned_many_to_one'); - - parent::setUp(); - } - - /** - * This test case asserts that a detached and unmodified entity could be merge without firing - * OptimisticLockException. - */ - public function testSetVersionOnCreate(): void - { - $category = new Category(); - $article = new Article(); - - $article->name = 'Article'; - $article->category = $category; - - $this->_em->persist($article); - $this->_em->flush(); - $this->_em->clear(); - - $articleMerged = $this->_em->merge($article); - - $articleMerged->name = 'Article Merged'; - - $this->_em->flush(); - self::assertEquals(2, $articleMerged->version); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php index 9a91fe7dd94..883e8108eab 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -434,22 +434,6 @@ private function loadEditorFixture(): DDC117Editor return $this->_em->find(get_class($editor), $editor->id); } - /** - * @group DDC-1519 - */ - public function testMergeForeignKeyIdentifierEntity(): void - { - $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; - - $refRep = $this->_em->find(DDC117Reference::class, $idCriteria); - - $this->_em->clear(); - $refRep = $this->_em->merge($refRep); - - self::assertEquals($this->article1->id(), $refRep->source()->id()); - self::assertEquals($this->article2->id(), $refRep->target()->id()); - } - /** * @group DDC-1652 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php deleted file mode 100644 index 600b49ca5f3..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php +++ /dev/null @@ -1,53 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testIssue(): void - { - $user = new CmsUser(); - $user->name = 'Benjamin'; - $user->username = 'beberlei'; - $user->status = 'active'; - $this->_em->persist($user); - - for ($i = 0; $i < 2; $i++) { - $group = new CmsGroup(); - $group->name = 'group' . $i; - $user->groups[] = $group; - $this->_em->persist($group); - } - - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(CmsUser::class, $user->id); - $cloned = clone $user; - - self::assertSame($user->groups, $cloned->groups); - self::assertEquals(2, count($user->groups)); - $this->_em->merge($cloned); - - self::assertEquals(2, count($user->groups)); - - $this->_em->flush(); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php deleted file mode 100644 index 828d493d6d9..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php +++ /dev/null @@ -1,120 +0,0 @@ -_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1383AbstractEntity::class), - $this->_em->getClassMetadata(DDC1383Entity::class), - ] - ); - } catch (Exception $ignored) { - } - } - - public function testFailingCase(): void - { - $parent = new DDC1383Entity(); - $child = new DDC1383Entity(); - - $child->setReference($parent); - - $this->_em->persist($parent); - $this->_em->persist($child); - - $id = $child->getId(); - - $this->_em->flush(); - $this->_em->clear(); - - // Try merging the parent entity - $child = $this->_em->merge($child); - $parent = $child->getReference(); - - // Parent is not instance of the abstract class - self::assertTrue( - $parent instanceof DDC1383AbstractEntity, - 'Entity class is ' . get_debug_type($parent) . ', "DDC1383AbstractEntity" was expected' - ); - - // Parent is NOT instance of entity - self::assertTrue( - $parent instanceof DDC1383Entity, - 'Entity class is ' . get_debug_type($parent) . ', "DDC1383Entity" was expected' - ); - } -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="integer") - * @DiscriminatorMap({1 = "DDC1383Entity"}) - */ -abstract class DDC1383AbstractEntity -{ - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - protected $id; - - public function getId(): ?int - { - return $this->id; - } - - public function setId(int $id): void - { - $this->id = $id; - } -} - -/** - * @Entity - */ -class DDC1383Entity extends DDC1383AbstractEntity -{ - /** - * @var DDC1383AbstractEntity - * @ManyToOne(targetEntity="DDC1383AbstractEntity") - */ - protected $reference; - - public function getReference(): DDC1383AbstractEntity - { - return $this->reference; - } - - public function setReference(DDC1383AbstractEntity $reference): void - { - $this->reference = $reference; - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php deleted file mode 100644 index 05744bc93ac..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php +++ /dev/null @@ -1,130 +0,0 @@ -_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1392File::class), - $this->_em->getClassMetadata(DDC1392Picture::class), - ] - ); - } catch (Exception $ignored) { - } - } - - public function testFailingCase(): void - { - $file = new DDC1392File(); - - $picture = new DDC1392Picture(); - $picture->setFile($file); - - $em = $this->_em; - $em->persist($picture); - $em->flush(); - $em->clear(); - - $fileId = $file->getFileId(); - $pictureId = $picture->getPictureId(); - - self::assertTrue($fileId > 0); - - $picture = $em->find(DDC1392Picture::class, $pictureId); - self::assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), 'Lazy Proxy should be marked MANAGED.'); - - $file = $picture->getFile(); - - // With this activated there will be no problem - //$file->__load(); - - $picture->setFile(null); - - $em->clear(); - - $em->merge($file); - - $em->flush(); - - $q = $this->_em->createQuery('SELECT COUNT(e) FROM ' . __NAMESPACE__ . '\DDC1392File e'); - $result = $q->getSingleScalarResult(); - - self::assertEquals(1, $result); - } -} - -/** - * @Entity - */ -class DDC1392Picture -{ - /** - * @var int - * @Column(name="picture_id", type="integer") - * @Id - * @GeneratedValue - */ - private $pictureId; - - /** - * @var DDC1392File - * @ManyToOne(targetEntity="DDC1392File", cascade={"persist", "remove"}) - * @JoinColumn(name="file_id", referencedColumnName="file_id") - */ - private $file; - - public function getPictureId(): int - { - return $this->pictureId; - } - - public function setFile(?DDC1392File $value = null): void - { - $this->file = $value; - } - - public function getFile(): ?DDC1392File - { - return $this->file; - } -} - -/** - * @Entity - */ -class DDC1392File -{ - /** - * @var int - * @Column(name="file_id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - public $fileId; - - public function getFileId(): int - { - return $this->fileId; - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php deleted file mode 100644 index 10ba0c85bae..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php +++ /dev/null @@ -1,145 +0,0 @@ -_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC1509AbstractFile::class), - $this->_em->getClassMetadata(DDC1509File::class), - $this->_em->getClassMetadata(DDC1509Picture::class), - ] - ); - } catch (Exception $ignored) { - } - } - - public function testFailingCase(): void - { - $file = new DDC1509File(); - $thumbnail = new DDC1509File(); - - $picture = new DDC1509Picture(); - $picture->setFile($file); - $picture->setThumbnail($thumbnail); - - $em = $this->_em; - assert($em instanceof EntityManager); - $em->persist($picture); - $em->flush(); - $em->clear(); - - $id = $picture->getPictureId(); - - $pic = $em->merge($picture); - assert($pic instanceof DDC1509Picture); - - self::assertNotNull($pic->getThumbnail()); - self::assertNotNull($pic->getFile()); - } -} - -/** - * @Entity - */ -class DDC1509Picture -{ - /** - * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** - * @var DDC1509AbstractFile - * @ManyToOne(targetEntity="DDC1509AbstractFile", cascade={"persist", "remove"}) - */ - private $thumbnail; - - /** - * @var DDC1509AbstractFile|null - * @ManyToOne(targetEntity="DDC1509AbstractFile", cascade={"persist", "remove"}) - */ - private $file; - - public function getPictureId(): int - { - return $this->id; - } - - public function setFile(?DDC1509AbstractFile $value = null): void - { - $this->file = $value; - } - - public function getFile(): ?DDC1509AbstractFile - { - return $this->file; - } - - public function getThumbnail(): DDC1509AbstractFile - { - return $this->thumbnail; - } - - public function setThumbnail(DDC1509AbstractFile $thumbnail): void - { - $this->thumbnail = $thumbnail; - } -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"abstractFile" = "DDC1509AbstractFile", "file" = "DDC1509File"}) - */ -class DDC1509AbstractFile -{ - /** - * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - public function getFileId(): int - { - return $this->id; - } -} - -/** - * @Entity - */ -class DDC1509File extends DDC1509AbstractFile -{ -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php deleted file mode 100644 index d8e6fed7f0b..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php +++ /dev/null @@ -1,46 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testIssue(): void - { - $user = new CmsUser(); - $user->status = 'foo'; - $user->username = 'foo'; - $user->name = 'foo'; - - $this->_em->persist($user); - $this->_em->flush(); - - $this->_em->clear(); - $detachedUser = clone $user; - $detachedUser->name = 'bar'; - $detachedUser->status = 'bar'; - - $newUser = $this->_em->getReference(get_class($user), $user->id); - - $mergedUser = $this->_em->merge($detachedUser); - - self::assertNotSame($mergedUser, $detachedUser); - self::assertEquals('bar', $detachedUser->getName()); - self::assertEquals('bar', $mergedUser->getName()); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php deleted file mode 100644 index c5e776e1da0..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php +++ /dev/null @@ -1,88 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - /** - * This test is DDC-1734 minus the serialization, i.e. it works - * - * @group DDC-1734 - */ - public function testMergeWorksOnNonSerializedProxies(): void - { - $group = new CmsGroup(); - - $group->setName('Foo'); - $this->_em->persist($group); - $this->_em->flush(); - $this->_em->clear(); - - $proxy = $this->getProxy($group); - - self::assertInstanceOf(Proxy::class, $proxy); - self::assertFalse($proxy->__isInitialized()); - - $this->_em->detach($proxy); - $this->_em->clear(); - - $proxy = $this->_em->merge($proxy); - - self::assertEquals('Foo', $proxy->getName(), 'The entity is broken'); - } - - /** - * This test reproduces DDC-1734 which is: - * - A non-initialized proxy is detached and serialized (the identifier of the proxy is *not* serialized) - * - the object is deserialized and merged (to turn into an entity) - * - the entity is broken because it has no identifier and no field defined - * - * @group DDC-1734 - */ - public function testMergeWorksOnSerializedProxies(): void - { - $group = new CmsGroup(); - - $group->setName('Foo'); - $this->_em->persist($group); - $this->_em->flush(); - $this->_em->clear(); - - $proxy = $this->getProxy($group); - - self::assertInstanceOf(Proxy::class, $proxy); - self::assertFalse($proxy->__isInitialized()); - - $this->_em->detach($proxy); - $serializedProxy = serialize($proxy); - $this->_em->clear(); - - $unserializedProxy = $this->_em->merge(unserialize($serializedProxy)); - self::assertEquals('Foo', $unserializedProxy->getName(), 'The entity is broken'); - } - - private function getProxy(object $object): \Doctrine\Common\Proxy\Proxy - { - $metadataFactory = $this->_em->getMetadataFactory(); - $className = get_class($object); - $identifier = $metadataFactory->getMetadataFor($className)->getIdentifierValues($object); - - return $this->_em->getProxyFactory()->getProxy($className, $identifier); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index c8025dc6dc6..44d9155e020 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -38,29 +38,6 @@ protected function setUp(): void } } - public function testNotifyTrackingNotCalledOnUninitializedProxies(): void - { - $insertedUser = new DDC2230User(); - $insertedUser->address = new DDC2230Address(); - - $this->_em->persist($insertedUser); - $this->_em->persist($insertedUser->address); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(DDC2230User::class, $insertedUser->id); - - $this->_em->clear(); - - $mergedUser = $this->_em->merge($user); - - $address = $mergedUser->address; - assert($address instanceof Proxy); - - self::assertInstanceOf(Proxy::class, $address); - self::assertFalse($address->__isInitialized()); - } - public function testNotifyTrackingCalledOnProxyInitialization(): void { $insertedAddress = new DDC2230Address(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php deleted file mode 100644 index cbd075f78d6..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2409Test.php +++ /dev/null @@ -1,74 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testIssue(): void - { - $em = $this->_em; - $uow = $em->getUnitOfWork(); - - $originalArticle = new CmsArticle(); - $originalUser = new CmsUser(); - - $originalArticle->topic = 'Unit Test'; - $originalArticle->text = 'How to write a test'; - - $originalUser->name = 'Doctrine Bot'; - $originalUser->username = 'DoctrineBot'; - $originalUser->status = 'active'; - - $originalUser->addArticle($originalArticle); - - $em->persist($originalUser); - $em->persist($originalArticle); - $em->flush(); - $em->clear(); - - $article = $em->find(CmsArticle::class, $originalArticle->id); - $user = new CmsUser(); - - $user->name = 'Doctrine Bot 2.0'; - $user->username = 'BotDoctrine2'; - $user->status = 'new'; - - $article->setAuthor($user); - - self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalArticle)); - self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($originalUser)); - self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($article)); - self::assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); - - $em->clear(); - - $userMerged = $em->merge($user); - $articleMerged = $em->merge($article); - - self::assertEquals(UnitOfWork::STATE_NEW, $uow->getEntityState($user)); - self::assertEquals(UnitOfWork::STATE_DETACHED, $uow->getEntityState($article)); - self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($userMerged)); - self::assertEquals(UnitOfWork::STATE_MANAGED, $uow->getEntityState($articleMerged)); - - self::assertNotSame($user, $userMerged); - self::assertNotSame($article, $articleMerged); - self::assertNotSame($userMerged, $articleMerged->user); - self::assertSame($user, $articleMerged->user); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php deleted file mode 100644 index 4e12ee95fe5..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2645Test.php +++ /dev/null @@ -1,78 +0,0 @@ -id = 123; - - $foo = new DDC2645Foo(1, $bar, 'Foo'); - $foo2 = new DDC2645Foo(1, $bar, 'Bar'); - - $this->_em->persist($bar); - $this->_em->persist($foo); - - $foo3 = $this->_em->merge($foo2); - - self::assertSame($foo, $foo3); - self::assertEquals('Bar', $foo->name); - } -} - -/** @Entity */ -class DDC2645Foo -{ - /** - * @var int - * @Id - * @Column(type="integer") - */ - private $id; - - /** - * @var DDC2645Bar - * @Id - * @ManyToOne(targetEntity="DDC2645Bar") - */ - private $bar; - - /** - * @var string - * @Column - */ - public $name; - - public function __construct(int $id, DDC2645Bar $bar, string $name) - { - $this->id = $id; - $this->bar = $bar; - $this->name = $name; - } -} - -/** @Entity */ -class DDC2645Bar -{ - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - */ - public $id; -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php deleted file mode 100644 index 5d002ef01a9..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php +++ /dev/null @@ -1,108 +0,0 @@ -useModelSet('ddc3699'); - - parent::setUp(); - } - - /** - * @group DDC-3699 - */ - public function testMergingParentClassFieldsDoesNotStopMergingScalarFieldsForToOneUninitializedAssociations(): void - { - $id = 1; - - $child = new DDC3699Child(); - - $child->id = $id; - $child->childField = 'childValue'; - $child->parentField = 'parentValue'; - - $relation = new DDC3699RelationOne(); - - $relation->id = $id; - $relation->child = $child; - $child->oneRelation = $relation; - - $this->_em->persist($relation); - $this->_em->persist($child); - $this->_em->flush(); - $this->_em->clear(); - - $unManagedChild = $this->_em->find(DDC3699Child::class, $id); - assert($unManagedChild instanceof DDC3699Child); - - $this->_em->detach($unManagedChild); - - // make it managed again - $this->_em->find(DDC3699Child::class, $id); - - $unManagedChild->childField = 'modifiedChildValue'; - $unManagedChild->parentField = 'modifiedParentValue'; - - $mergedChild = $this->_em->merge($unManagedChild); - assert($mergedChild instanceof DDC3699Child); - - self::assertSame($mergedChild->childField, 'modifiedChildValue'); - self::assertSame($mergedChild->parentField, 'modifiedParentValue'); - } - - /** - * @group DDC-3699 - */ - public function testMergingParentClassFieldsDoesNotStopMergingScalarFieldsForToManyUninitializedAssociations(): void - { - $id = 2; - - $child = new DDC3699Child(); - - $child->id = $id; - $child->childField = 'childValue'; - $child->parentField = 'parentValue'; - - $relation = new DDC3699RelationMany(); - - $relation->id = $id; - $relation->child = $child; - $child->relations[] = $relation; - - $this->_em->persist($relation); - $this->_em->persist($child); - $this->_em->flush(); - $this->_em->clear(); - - $unmanagedChild = $this->_em->find(DDC3699Child::class, $id); - assert($unmanagedChild instanceof DDC3699Child); - $this->_em->detach($unmanagedChild); - - // make it managed again - $this->_em->find(DDC3699Child::class, $id); - - $unmanagedChild->childField = 'modifiedChildValue'; - $unmanagedChild->parentField = 'modifiedParentValue'; - - $mergedChild = $this->_em->merge($unmanagedChild); - assert($mergedChild instanceof DDC3699Child); - - self::assertSame($mergedChild->childField, 'modifiedChildValue'); - self::assertSame($mergedChild->parentField, 'modifiedParentValue'); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php deleted file mode 100644 index 7abdfcaafbc..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php +++ /dev/null @@ -1,112 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testMergeUnitializedManyToManyAndOneToManyCollections(): void - { - // Create User - $user = $this->createAndPersistUser(); - $this->_em->flush(); - - self::assertTrue($this->_em->contains($user)); - $this->_em->clear(); - self::assertFalse($this->_em->contains($user)); - - unset($user); - - // Reload User from DB *without* any associations (i.e. an uninitialized PersistantCollection) - $userReloaded = $this->loadUserFromEntityManager(); - - self::assertTrue($this->_em->contains($userReloaded)); - $this->_em->clear(); - self::assertFalse($this->_em->contains($userReloaded)); - - // freeze and unfreeze - $userClone = unserialize(serialize($userReloaded)); - self::assertInstanceOf(CmsUser::class, $userClone); - - // detached user can't know about his phonenumbers - self::assertEquals(0, count($userClone->getPhonenumbers())); - self::assertFalse($userClone->getPhonenumbers()->isInitialized(), 'User::phonenumbers should not be marked initialized.'); - - // detached user can't know about his groups either - self::assertEquals(0, count($userClone->getGroups())); - self::assertFalse($userClone->getGroups()->isInitialized(), 'User::groups should not be marked initialized.'); - - // Merge back and flush - $userClone = $this->_em->merge($userClone); - - // Back in managed world I would expect to have my phonenumbers back but they aren't! - // Remember I didn't touch (and probably didn't need) them at all while in detached mode. - self::assertEquals(4, count($userClone->getPhonenumbers()), 'Phonenumbers are not available anymore'); - - // This works fine as long as cmUser::groups doesn't cascade "merge" - self::assertEquals(2, count($userClone->getGroups())); - - $this->_em->flush(); - $this->_em->clear(); - - self::assertFalse($this->_em->contains($userClone)); - - // Reload user from DB - $userFromEntityManager = $this->loadUserFromEntityManager(); - - //Strange: Now the phonenumbers are back again - self::assertEquals(4, count($userFromEntityManager->getPhonenumbers())); - - // This works fine as long as cmUser::groups doesn't cascade "merge" - // Otherwise group memberships are physically deleted now! - self::assertEquals(2, count($userClone->getGroups())); - } - - protected function createAndPersistUser(): CmsUser - { - $user = new CmsUser(); - $user->name = 'Luka'; - $user->username = 'lukacho'; - $user->status = 'developer'; - - foreach ([1111, 2222, 3333, 4444] as $number) { - $phone = new CmsPhonenumber(); - $phone->phonenumber = $number; - $user->addPhonenumber($phone); - } - - foreach (['Moshers', 'Headbangers'] as $groupName) { - $group = new CmsGroup(); - $group->setName($groupName); - $user->addGroup($group); - } - - $this->_em->persist($user); - - return $user; - } - - protected function loadUserFromEntityManager(): CmsUser - { - return $this->_em - ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name like :name') - ->setParameter('name', 'Luka') - ->getSingleResult(); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php deleted file mode 100644 index f1ef8b0e6f8..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php +++ /dev/null @@ -1,41 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testMergeWithRelatedNew(): void - { - $article = new CmsArticle(); - $article->text = 'foo'; - $article->topic = 'bar'; - - $this->_em->persist($article); - $this->_em->flush(); - $this->_em->detach($article); - $this->_em->clear(); - - $user = new CmsUser(); - $user->username = 'beberlei'; - $user->name = 'Benjamin Eberlei'; - $user->status = 'active'; - $article->user = $user; - - $this->_em->persist($user); - $managedArticle = $this->_em->merge($article); - - self::assertSame($article->user, $managedArticle->user); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php deleted file mode 100644 index 3754508b175..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php +++ /dev/null @@ -1,213 +0,0 @@ -_em); - $schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC729A::class), - $this->_em->getClassMetadata(DDC729B::class), - ] - ); - } catch (Exception $e) { - } - } - - public function testMergeManyToMany(): void - { - $a = new DDC729A(); - $b = new DDC729B(); - $a->related[] = $b; - - $this->_em->persist($a); - $this->_em->persist($b); - $this->_em->flush(); - $this->_em->clear(); - $aId = $a->id; - - $a = new DDC729A(); - $a->id = $aId; - - self::assertInstanceOf(ArrayCollection::class, $a->related); - - $a = $this->_em->merge($a); - - self::assertInstanceOf(PersistentCollection::class, $a->related); - - self::assertFalse($a->related->isInitialized(), 'Collection should not be marked initialized.'); - self::assertFalse($a->related->isDirty(), 'Collection should not be marked as dirty.'); - - $this->_em->flush(); - $this->_em->clear(); - - $a = $this->_em->find(DDC729A::class, $aId); - self::assertEquals(1, count($a->related)); - } - - public function testUnidirectionalMergeManyToMany(): void - { - $a = new DDC729A(); - $b1 = new DDC729B(); - $b2 = new DDC729B(); - $a->related[] = $b1; - - $this->_em->persist($a); - $this->_em->persist($b1); - $this->_em->persist($b2); - $this->_em->flush(); - $this->_em->clear(); - $aId = $a->id; - - $a = new DDC729A(); - $a->id = $aId; - - $a = $this->_em->merge($a); - - $a->related->set(0, $this->_em->merge($b1)); - - $a->related->set(1, $this->_em->merge($b2)); - - $this->_em->flush(); - $this->_em->clear(); - - $a = $this->_em->find(DDC729A::class, $aId); - self::assertEquals(2, count($a->related)); - } - - public function testBidirectionalMergeManyToMany(): void - { - $a = new DDC729A(); - $b1 = new DDC729B(); - $b2 = new DDC729B(); - $a->related[] = $b1; - - $this->_em->persist($a); - $this->_em->persist($b1); - $this->_em->persist($b2); - $this->_em->flush(); - $this->_em->clear(); - $aId = $a->id; - - $a = new DDC729A(); - $a->id = $aId; - - $a = $this->_em->merge($a); - - $a->related->set(0, $this->_em->merge($b1)); - $b1->related->set(0, $a); - - $a->related->set(1, $this->_em->merge($b2)); - $b2->related->set(0, $a); - - $this->_em->flush(); - $this->_em->clear(); - - $a = $this->_em->find(DDC729A::class, $aId); - self::assertEquals(2, count($a->related)); - } - - public function testBidirectionalMultiMergeManyToMany(): void - { - $a = new DDC729A(); - $b1 = new DDC729B(); - $b2 = new DDC729B(); - $a->related[] = $b1; - - $this->_em->persist($a); - $this->_em->persist($b1); - $this->_em->persist($b2); - $this->_em->flush(); - $this->_em->clear(); - $aId = $a->id; - - $a = new DDC729A(); - $a->id = $aId; - - $a = $this->_em->merge($a); - - $a->related->set(0, $this->_em->merge($b1)); - $b1->related->set(0, $this->_em->merge($a)); - - $a->related->set(1, $this->_em->merge($b2)); - $b2->related->set(0, $this->_em->merge($a)); - - $this->_em->flush(); - $this->_em->clear(); - - $a = $this->_em->find(DDC729A::class, $aId); - self::assertEquals(2, count($a->related)); - } -} - -/** - * @Entity - */ -class DDC729A -{ - /** - * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") - */ - public $id; - - /** - * @psalm-var Collection - * @ManyToMany(targetEntity="DDC729B", inversedBy="related") - */ - public $related; - - public function __construct() - { - $this->related = new ArrayCollection(); - } -} - -/** - * @Entity - */ -class DDC729B -{ - /** - * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") - */ - public $id; - - /** - * @psalm-var Collection - * @ManyToMany(targetEntity="DDC729B", mappedBy="related") - */ - public $related; - - public function __construct() - { - $this->related = new ArrayCollection(); - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php b/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php deleted file mode 100644 index d608b939efc..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php +++ /dev/null @@ -1,134 +0,0 @@ -getProperties(ClassWithMixedProperties::class); - - self::assertCount(5, $properties); - - foreach ($properties as $property) { - self::assertInstanceOf('ReflectionProperty', $property); - } - } - - public function testRetrievedInstancesAreNotStatic(): void - { - $properties = (new ReflectionPropertiesGetter(new RuntimeReflectionService())) - ->getProperties(ClassWithMixedProperties::class); - - foreach ($properties as $property) { - self::assertFalse($property->isStatic()); - } - } - - public function testExpectedKeys(): void - { - $properties = (new ReflectionPropertiesGetter(new RuntimeReflectionService())) - ->getProperties(ClassWithMixedProperties::class); - - self::assertArrayHasKey( - "\0" . ClassWithMixedProperties::class . "\0" . 'privateProperty', - $properties - ); - self::assertArrayHasKey( - "\0" . ClassWithMixedProperties::class . "\0" . 'privatePropertyOverride', - $properties - ); - self::assertArrayHasKey( - "\0" . ParentClass::class . "\0" . 'privatePropertyOverride', - $properties - ); - self::assertArrayHasKey( - "\0*\0protectedProperty", - $properties - ); - self::assertArrayHasKey( - 'publicProperty', - $properties - ); - } - - public function testPropertiesAreAccessible(): void - { - $object = new ClassWithMixedProperties(); - $properties = (new ReflectionPropertiesGetter(new RuntimeReflectionService())) - ->getProperties(ClassWithMixedProperties::class); - - foreach ($properties as $property) { - self::assertSame($property->getName(), $property->getValue($object)); - } - } - - public function testPropertyGetterIsIdempotent(): void - { - $getter = (new ReflectionPropertiesGetter(new RuntimeReflectionService())); - - self::assertSame( - $getter->getProperties(ClassWithMixedProperties::class), - $getter->getProperties(ClassWithMixedProperties::class) - ); - } - - public function testPropertyGetterWillSkipPropertiesNotRetrievedByTheRuntimeReflectionService(): void - { - $reflectionService = $this->createMock(ReflectionService::class); - assert($reflectionService instanceof ReflectionService || $reflectionService instanceof MockObject); - - $reflectionService - ->expects(self::exactly(2)) - ->method('getClass') - ->with(self::logicalOr(ClassWithMixedProperties::class, ParentClass::class)) - ->will(self::returnValueMap([ - [ClassWithMixedProperties::class, new ReflectionClass(ClassWithMixedProperties::class)], - [ParentClass::class, new ReflectionClass(ParentClass::class)], - ])); - - $reflectionService - ->expects(self::atLeastOnce()) - ->method('getAccessibleProperty'); - - $getter = (new ReflectionPropertiesGetter($reflectionService)); - - self::assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); - } - - public function testPropertyGetterWillSkipClassesNotRetrievedByTheRuntimeReflectionService(): void - { - $reflectionService = $this->createMock(ReflectionService::class); - assert($reflectionService instanceof ReflectionService || $reflectionService instanceof MockObject); - - $reflectionService - ->expects(self::once()) - ->method('getClass') - ->with(ClassWithMixedProperties::class); - - $reflectionService->expects(self::never())->method('getAccessibleProperty'); - - $getter = (new ReflectionPropertiesGetter($reflectionService)); - - self::assertEmpty($getter->getProperties(ClassWithMixedProperties::class)); - } -} diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index e8b07733d79..84e9f064eb3 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -11,7 +11,6 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\EntityNotFoundException; -use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -23,7 +22,6 @@ use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\UnitOfWork; -use Doctrine\Persistence\Event\LifecycleEventArgs; use Doctrine\Persistence\NotifyPropertyChanged; use Doctrine\Persistence\PropertyChangedListener; use Doctrine\Tests\Mocks\ConnectionMock; @@ -31,15 +29,12 @@ use Doctrine\Tests\Mocks\EntityPersisterMock; use Doctrine\Tests\Mocks\UnitOfWorkMock; use Doctrine\Tests\Models\CMS\CmsPhonenumber; -use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\Forum\ForumAvatar; use Doctrine\Tests\Models\Forum\ForumUser; use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\MockObject\MockObject; use stdClass; -use function assert; -use function gc_collect_cycles; use function get_class; use function method_exists; use function random_int; @@ -472,115 +467,6 @@ public function entitiesWithInvalidIdentifiersProvider(): array ]; } - /** - * @group 5689 - * @group 1465 - */ - public function testObjectHashesOfMergedEntitiesAreNotUsedInOriginalEntityDataMap(): void - { - $user = new CmsUser(); - $user->name = 'ocramius'; - $mergedUser = $this->_unitOfWork->merge($user); - - self::assertSame([], $this->_unitOfWork->getOriginalEntityData($user), 'No original data was stored'); - self::assertSame([], $this->_unitOfWork->getOriginalEntityData($mergedUser), 'No original data was stored'); - - $user = null; - $mergedUser = null; - - // force garbage collection of $user (frees the used object hashes, which may be recycled) - gc_collect_cycles(); - - $newUser = new CmsUser(); - $newUser->name = 'ocramius'; - - $this->_unitOfWork->persist($newUser); - - self::assertSame([], $this->_unitOfWork->getOriginalEntityData($newUser), 'No original data was stored'); - } - - /** - * @group DDC-1955 - * @group 5570 - * @group 6174 - */ - public function testMergeWithNewEntityWillPersistItAndTriggerPrePersistListenersWithMergedEntityData(): void - { - $entity = new EntityWithRandomlyGeneratedField(); - - $generatedFieldValue = $entity->generatedField; - - $this - ->eventManager - ->expects(self::any()) - ->method('hasListeners') - ->willReturnCallback(static function ($eventName) { - return $eventName === Events::prePersist; - }); - $this - ->eventManager - ->expects(self::once()) - ->method('dispatchEvent') - ->with( - self::anything(), - self::callback(static function (LifecycleEventArgs $args) use ($entity, $generatedFieldValue) { - $object = $args->getObject(); - assert($object instanceof EntityWithRandomlyGeneratedField); - - self::assertInstanceOf(EntityWithRandomlyGeneratedField::class, $object); - self::assertNotSame($entity, $object); - self::assertSame($generatedFieldValue, $object->generatedField); - - return true; - }) - ); - - $object = $this->_unitOfWork->merge($entity); - assert($object instanceof EntityWithRandomlyGeneratedField); - - self::assertNotSame($object, $entity); - self::assertInstanceOf(EntityWithRandomlyGeneratedField::class, $object); - self::assertSame($object->generatedField, $entity->generatedField); - } - - /** - * @group DDC-1955 - * @group 5570 - * @group 6174 - */ - public function testMergeWithExistingEntityWillNotPersistItNorTriggerPrePersistListeners(): void - { - $persistedEntity = new EntityWithRandomlyGeneratedField(); - $mergedEntity = new EntityWithRandomlyGeneratedField(); - - $mergedEntity->id = $persistedEntity->id; - $mergedEntity->generatedField = random_int( - $persistedEntity->generatedField + 1, - $persistedEntity->generatedField + 1000 - ); - - $this - ->eventManager - ->expects(self::any()) - ->method('hasListeners') - ->willReturnCallback(static function ($eventName) { - return $eventName === Events::prePersist; - }); - $this->eventManager->expects(self::never())->method('dispatchEvent'); - - $this->_unitOfWork->registerManaged( - $persistedEntity, - ['id' => $persistedEntity->id], - ['generatedField' => $persistedEntity->generatedField] - ); - - $merged = $this->_unitOfWork->merge($mergedEntity); - assert($merged instanceof EntityWithRandomlyGeneratedField); - - self::assertSame($merged, $persistedEntity); - self::assertSame($persistedEntity->generatedField, $mergedEntity->generatedField); - } - /** * Unlike next test, this one demonstrates that the problem does * not necessarily reproduce if all the pieces are being flushed together. From 32214ddaa6708b66d2e7dffc7241a2aca4c5d393 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 10 Feb 2022 09:33:11 +0100 Subject: [PATCH 047/475] Remove various deprecated methods and properties (#9498) --- .../ORM/Mapping/Builder/FieldBuilder.php | 12 --------- .../ORM/Mapping/ClassMetadataInfo.php | 25 ------------------- lib/Doctrine/ORM/Mapping/MappingException.php | 17 ------------- lib/Doctrine/ORM/Query/AST/IndexBy.php | 9 +------ psalm-baseline.xml | 12 +++------ 5 files changed, 4 insertions(+), 71 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php index f6d2db6c70e..89e88b5bb5c 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php @@ -152,18 +152,6 @@ public function scale($s) return $this; } - /** - * Sets field as primary key. - * - * @deprecated Use makePrimaryKey() instead - * - * @return FieldBuilder - */ - public function isPrimaryKey() - { - return $this->makePrimaryKey(); - } - /** * Sets field as primary key. * diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index bfbb8e20498..bf7bf203e55 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -625,16 +625,6 @@ class ClassMetadataInfo implements ClassMetadata */ public $sequenceGeneratorDefinition; - /** - * READ-ONLY: The definition of the table generator of this class. Only used for the - * TABLE generation strategy. - * - * @deprecated - * - * @var array - */ - public $tableGeneratorDefinition; - /** * READ-ONLY: The policy used for change-tracking on entities of this class. * @@ -2235,21 +2225,6 @@ public function getTypeOfField($fieldName) : null; } - /** - * Gets the type of a column. - * - * @deprecated 3.0 remove this. this method is bogus and unreliable, since it cannot resolve the type of a column - * that is derived by a referenced field on a different entity. - * - * @param string $columnName - * - * @return string|null - */ - public function getTypeOfColumn($columnName) - { - return $this->getTypeOfField($this->getFieldName($columnName)); - } - /** * Gets the name of the primary table. * diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 41ffb78c38b..c7856d0381e 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -369,23 +369,6 @@ public static function classIsNotAValidEntityOrMappedSuperClass($className) )); } - /** - * @deprecated 2.9 no longer in use - * - * @param string $className - * @param string $propertyName - * - * @return MappingException - */ - public static function propertyTypeIsRequired($className, $propertyName) - { - return new self(sprintf( - "The attribute 'type' is required for the column description of property %s::\$%s.", - $className, - $propertyName - )); - } - /** * @param string $entity The entity's name. * @param string $fieldName The name of the field that was already declared. diff --git a/lib/Doctrine/ORM/Query/AST/IndexBy.php b/lib/Doctrine/ORM/Query/AST/IndexBy.php index e623d460bd1..a14b475316e 100644 --- a/lib/Doctrine/ORM/Query/AST/IndexBy.php +++ b/lib/Doctrine/ORM/Query/AST/IndexBy.php @@ -14,16 +14,9 @@ class IndexBy extends Node /** @var PathExpression */ public $singleValuedPathExpression = null; - /** - * @deprecated - * - * @var PathExpression - */ - public $simpleStateFieldPathExpression = null; - public function __construct(PathExpression $singleValuedPathExpression) { - $this->singleValuedPathExpression = $this->simpleStateFieldPathExpression = $singleValuedPathExpression; + $this->singleValuedPathExpression = $singleValuedPathExpression; } /** diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bde099a32a8..96f22e7fe2e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -447,8 +447,7 @@ - - ClassMetadata + ClassMetadata ClassMetadata ClassMetadata @@ -595,12 +594,11 @@ $mapping['originalField'] $mapping['targetEntity'] - + $idGenerator $namespace $sequenceGeneratorDefinition $table - $tableGeneratorDefinition $this->entityListeners @@ -1626,9 +1624,6 @@ - - $this->simpleStateFieldPathExpression - dispatch @@ -1638,8 +1633,7 @@ $sqlWalker - - null + null From 0d4281ddfa26c9d0ddaa7a0dbc2a828b159f85a6 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 10 Feb 2022 23:34:28 +0100 Subject: [PATCH 048/475] Add native types to QueryBuilder (#9490) --- lib/Doctrine/ORM/Query/Expr/Join.php | 77 +--- lib/Doctrine/ORM/Query/Parameter.php | 48 +- .../ORM/Query/ParameterTypeInferer.php | 12 +- lib/Doctrine/ORM/QueryBuilder.php | 426 ++++++------------ psalm-baseline.xml | 5 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 3 +- 6 files changed, 172 insertions(+), 399 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Expr/Join.php b/lib/Doctrine/ORM/Query/Expr/Join.php index fcda81e9381..27b34821369 100644 --- a/lib/Doctrine/ORM/Query/Expr/Join.php +++ b/lib/Doctrine/ORM/Query/Expr/Join.php @@ -20,103 +20,56 @@ class Join public const WITH = 'WITH'; /** - * @var string - * @psalm-var self::INNER_JOIN|self::LEFT_JOIN - */ - protected $joinType; - - /** @var string */ - protected $join; - - /** @var string|null */ - protected $alias; - - /** - * @var string|null - * @psalm-var self::ON|self::WITH|null - */ - protected $conditionType; - - /** @var string|Comparison|Composite|null */ - protected $condition; - - /** @var string|null */ - protected $indexBy; - - /** - * @param string $joinType The condition type constant. Either INNER_JOIN or LEFT_JOIN. - * @param string $join The relationship to join. - * @param string|null $alias The alias of the join. - * @param string|null $conditionType The condition type constant. Either ON or WITH. - * @param string|Comparison|Composite|null $condition The condition for the join. - * @param string|null $indexBy The index for the join. * @psalm-param self::INNER_JOIN|self::LEFT_JOIN $joinType * @psalm-param self::ON|self::WITH|null $conditionType */ - public function __construct($joinType, $join, $alias = null, $conditionType = null, $condition = null, $indexBy = null) - { - $this->joinType = $joinType; - $this->join = $join; - $this->alias = $alias; - $this->conditionType = $conditionType; - $this->condition = $condition; - $this->indexBy = $indexBy; + public function __construct( + protected string $joinType, + protected string $join, + protected ?string $alias = null, + protected ?string $conditionType = null, + protected string|Comparison|Composite|null $condition = null, + protected ?string $indexBy = null + ) { } /** - * @return string * @psalm-return self::INNER_JOIN|self::LEFT_JOIN */ - public function getJoinType() + public function getJoinType(): string { return $this->joinType; } - /** - * @return string - */ - public function getJoin() + public function getJoin(): string { return $this->join; } - /** - * @return string|null - */ - public function getAlias() + public function getAlias(): ?string { return $this->alias; } /** - * @return string|null * @psalm-return self::ON|self::WITH|null */ - public function getConditionType() + public function getConditionType(): ?string { return $this->conditionType; } - /** - * @return string|Comparison|Composite|null - */ - public function getCondition() + public function getCondition(): string|Comparison|Composite|null { return $this->condition; } - /** - * @return string|null - */ - public function getIndexBy() + public function getIndexBy(): ?string { return $this->indexBy; } - /** - * @return string - */ - public function __toString() + public function __toString(): string { return strtoupper($this->joinType) . ' JOIN ' . $this->join . ($this->alias ? ' ' . $this->alias : '') diff --git a/lib/Doctrine/ORM/Query/Parameter.php b/lib/Doctrine/ORM/Query/Parameter.php index 8fe083b6f8a..00b9bdf071b 100644 --- a/lib/Doctrine/ORM/Query/Parameter.php +++ b/lib/Doctrine/ORM/Query/Parameter.php @@ -15,50 +15,33 @@ class Parameter { /** * Returns the internal representation of a parameter name. - * - * @param string|int $name The parameter name or position. - * - * @return string The normalized parameter name. */ - public static function normalizeName($name) + public static function normalizeName(int|string $name): string { return trim((string) $name, ':'); } /** * The parameter name. - * - * @var string */ - private $name; + private string $name; /** * The parameter value. - * - * @var mixed */ - private $value; + private mixed $value; /** * The parameter type. - * - * @var mixed */ - private $type; + private mixed $type; /** * Whether the parameter type was explicitly specified or not - * - * @var bool */ - private $typeSpecified; + private bool $typeSpecified; - /** - * @param string|int $name Parameter name - * @param mixed $value Parameter value - * @param mixed $type Parameter type - */ - public function __construct($name, $value, $type = null) + public function __construct(int|string $name, mixed $value, mixed $type = null) { $this->name = self::normalizeName($name); $this->typeSpecified = $type !== null; @@ -68,43 +51,32 @@ public function __construct($name, $value, $type = null) /** * Retrieves the Parameter name. - * - * @return string */ - public function getName() + public function getName(): string { return $this->name; } /** * Retrieves the Parameter value. - * - * @return mixed */ - public function getValue() + public function getValue(): mixed { return $this->value; } /** * Retrieves the Parameter type. - * - * @return mixed */ - public function getType() + public function getType(): mixed { return $this->type; } /** * Defines the Parameter value. - * - * @param mixed $value Parameter value. - * @param mixed $type Parameter type. - * - * @return void */ - public function setValue($value, $type = null) + public function setValue(mixed $value, mixed $type = null): void { $this->value = $value; $this->type = $type ?: ParameterTypeInferer::inferType($value); diff --git a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php index 3f4dee00969..95b76a2133c 100644 --- a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php +++ b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php @@ -22,18 +22,14 @@ * * @link www.doctrine-project.org */ -class ParameterTypeInferer +final class ParameterTypeInferer { /** * Infers type of a given value, returning a compatible constant: * - Type (\Doctrine\DBAL\Types\Type::*) * - Connection (\Doctrine\DBAL\Connection::PARAM_*) - * - * @param mixed $value Parameter value. - * - * @return int|string Parameter type constant. */ - public static function inferType($value) + public static function inferType(mixed $value): int|string { if (is_int($value)) { return Types::INTEGER; @@ -74,4 +70,8 @@ public static function inferType($value) return ParameterType::STRING; } + + private function __construct() + { + } } diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 61b52fa0cb2..f9bf6e6fb82 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -46,19 +46,12 @@ class QueryBuilder public const STATE_DIRTY = 0; public const STATE_CLEAN = 1; - /** - * The EntityManager used by this QueryBuilder. - * - * @var EntityManagerInterface - */ - private $_em; - /** * The array of DQL parts collected. * * @psalm-var array */ - private $_dqlParts = [ + private array $dqlParts = [ 'distinct' => false, 'select' => [], 'from' => [], @@ -73,88 +66,73 @@ class QueryBuilder /** * The type of query this is. Can be select, update or delete. * - * @var int * @psalm-var self::SELECT|self::DELETE|self::UPDATE */ - private $_type = self::SELECT; + private int $type = self::SELECT; /** * The state of the query object. Can be dirty or clean. * - * @var int * @psalm-var self::STATE_* */ - private $_state = self::STATE_CLEAN; + private int $state = self::STATE_CLEAN; /** * The complete DQL string for this query. - * - * @var string|null */ - private $_dql; + private ?string $dql = null; /** * The query parameters. * - * @var ArrayCollection * @psalm-var ArrayCollection */ - private $parameters; + private ArrayCollection $parameters; /** * The index of the first result to retrieve. - * - * @var int|null */ - private $_firstResult = null; + private ?int $firstResult = null; /** * The maximum number of results to retrieve. - * - * @var int|null */ - private $_maxResults = null; + private ?int $maxResults = null; /** * Keeps root entity alias names for join entities. * * @psalm-var array */ - private $joinRootAliases = []; + private array $joinRootAliases = []; /** * Whether to use second level cache, if available. - * - * @var bool */ - protected $cacheable = false; + protected bool $cacheable = false; /** * Second level cache region name. - * - * @var string|null */ - protected $cacheRegion; + protected ?string $cacheRegion = null; /** * Second level query cache mode. * - * @var int|null * @psalm-var Cache::MODE_*|null */ - protected $cacheMode; + protected ?int $cacheMode = null; - /** @var int */ - protected $lifetime = 0; + protected int $lifetime = 0; /** * Initializes a new QueryBuilder that uses the given EntityManager. * * @param EntityManagerInterface $em The EntityManager to use. */ - public function __construct(EntityManagerInterface $em) - { - $this->_em = $em; + public function __construct( + private EntityManagerInterface $em + ) { $this->parameters = new ArrayCollection(); } @@ -172,46 +150,38 @@ public function __construct(EntityManagerInterface $em) * * For more complex expression construction, consider storing the expression * builder object in a local variable. - * - * @return Query\Expr */ - public function expr() + public function expr(): Expr { - return $this->_em->getExpressionBuilder(); + return $this->em->getExpressionBuilder(); } /** * Enable/disable second level query (result) caching for this query. * - * @param bool $cacheable - * * @return $this */ - public function setCacheable($cacheable) + public function setCacheable(bool $cacheable): static { - $this->cacheable = (bool) $cacheable; + $this->cacheable = $cacheable; return $this; } /** * Are the query results enabled for second level cache? - * - * @return bool */ - public function isCacheable() + public function isCacheable(): bool { return $this->cacheable; } /** - * @param string $cacheRegion - * * @return $this */ - public function setCacheRegion($cacheRegion) + public function setCacheRegion(string $cacheRegion): static { - $this->cacheRegion = (string) $cacheRegion; + $this->cacheRegion = $cacheRegion; return $this; } @@ -221,15 +191,12 @@ public function setCacheRegion($cacheRegion) * * @return string|null The cache region name; NULL indicates the default region. */ - public function getCacheRegion() + public function getCacheRegion(): ?string { return $this->cacheRegion; } - /** - * @return int - */ - public function getLifetime() + public function getLifetime(): int { return $this->lifetime; } @@ -237,35 +204,31 @@ public function getLifetime() /** * Sets the life-time for this query into second level cache. * - * @param int $lifetime - * * @return $this */ - public function setLifetime($lifetime) + public function setLifetime(int $lifetime): static { - $this->lifetime = (int) $lifetime; + $this->lifetime = $lifetime; return $this; } /** - * @return int|null * @psalm-return Cache::MODE_*|null */ - public function getCacheMode() + public function getCacheMode(): ?int { return $this->cacheMode; } /** - * @param int $cacheMode * @psalm-param Cache::MODE_* $cacheMode * * @return $this */ - public function setCacheMode($cacheMode) + public function setCacheMode(int $cacheMode): static { - $this->cacheMode = (int) $cacheMode; + $this->cacheMode = $cacheMode; return $this; } @@ -273,22 +236,19 @@ public function setCacheMode($cacheMode) /** * Gets the type of the currently built query. * - * @return int * @psalm-return self::SELECT|self::DELETE|self::UPDATE */ - public function getType() + public function getType(): int { - return $this->_type; + return $this->type; } /** * Gets the associated EntityManager for this query builder. - * - * @return EntityManagerInterface */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { - return $this->_em; + return $this->em; } /** @@ -297,9 +257,9 @@ public function getEntityManager() * @return int Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. * @psalm-return self::STATE_* */ - public function getState() + public function getState(): int { - return $this->_state; + return $this->state; } /** @@ -311,32 +271,21 @@ public function getState() * ->from('User', 'u'); * echo $qb->getDql(); // SELECT u FROM User u * - * - * @return string The DQL query string. */ - public function getDQL() + public function getDQL(): string { - if ($this->_dql !== null && $this->_state === self::STATE_CLEAN) { - return $this->_dql; + if ($this->dql !== null && $this->state === self::STATE_CLEAN) { + return $this->dql; } - switch ($this->_type) { - case self::DELETE: - $dql = $this->getDQLForDelete(); - break; - - case self::UPDATE: - $dql = $this->getDQLForUpdate(); - break; + $dql = match ($this->type) { + self::DELETE => $this->getDQLForDelete(), + self::UPDATE => $this->getDQLForUpdate(), + self::SELECT => $this->getDQLForSelect(), + }; - case self::SELECT: - default: - $dql = $this->getDQLForSelect(); - break; - } - - $this->_state = self::STATE_CLEAN; - $this->_dql = $dql; + $this->state = self::STATE_CLEAN; + $this->dql = $dql; return $dql; } @@ -351,16 +300,14 @@ public function getDQL() * $q = $qb->getQuery(); * $results = $q->execute(); * - * - * @return Query */ - public function getQuery() + public function getQuery(): Query { $parameters = clone $this->parameters; - $query = $this->_em->createQuery($this->getDQL()) + $query = $this->em->createQuery($this->getDQL()) ->setParameters($parameters) - ->setFirstResult($this->_firstResult) - ->setMaxResults($this->_maxResults); + ->setFirstResult($this->firstResult) + ->setMaxResults($this->maxResults); if ($this->lifetime) { $query->setLifetime($this->lifetime); @@ -418,11 +365,9 @@ private function findRootAlias(string $alias, string $parentAlias): string * * @deprecated Please use $qb->getRootAliases() instead. * - * @return string - * * @throws RuntimeException */ - public function getRootAlias() + public function getRootAlias(): string { $aliases = $this->getRootAliases(); @@ -448,11 +393,11 @@ public function getRootAlias() * @return string[] * @psalm-return list */ - public function getRootAliases() + public function getRootAliases(): array { $aliases = []; - foreach ($this->_dqlParts['from'] as &$fromClause) { + foreach ($this->dqlParts['from'] as &$fromClause) { if (is_string($fromClause)) { $spacePos = strrpos($fromClause, ' '); $from = substr($fromClause, 0, $spacePos); @@ -483,7 +428,7 @@ public function getRootAliases() * @return string[] * @psalm-return list */ - public function getAllAliases() + public function getAllAliases(): array { return array_merge($this->getRootAliases(), array_keys($this->joinRootAliases)); } @@ -503,11 +448,11 @@ public function getAllAliases() * @return string[] * @psalm-return list */ - public function getRootEntities() + public function getRootEntities(): array { $entities = []; - foreach ($this->_dqlParts['from'] as &$fromClause) { + foreach ($this->dqlParts['from'] as &$fromClause) { if (is_string($fromClause)) { $spacePos = strrpos($fromClause, ' '); $from = substr($fromClause, 0, $spacePos); @@ -533,13 +478,12 @@ public function getRootEntities() * ->setParameter('user_id', 1); * * - * @param string|int $key The parameter position or name. - * @param mixed $value The parameter value. - * @param string|int|null $type ParameterType::* or \Doctrine\DBAL\Types\Type::* constant + * @param string|int $key The parameter position or name. + * @param string|int|null $type ParameterType::* or \Doctrine\DBAL\Types\Type::* constant * * @return $this */ - public function setParameter($key, $value, $type = null) + public function setParameter(string|int $key, mixed $value, string|int|null $type = null): static { $existingParameter = $this->getParameter($key); @@ -568,27 +512,12 @@ public function setParameter($key, $value, $type = null) * ))); * * - * @param ArrayCollection|mixed[] $parameters The query parameters to set. - * @psalm-param ArrayCollection|mixed[] $parameters + * @psalm-param ArrayCollection $parameters * * @return $this */ - public function setParameters($parameters) + public function setParameters(ArrayCollection $parameters): static { - // BC compatibility with 2.3- - if (is_array($parameters)) { - /** @psalm-var ArrayCollection $parameterCollection */ - $parameterCollection = new ArrayCollection(); - - foreach ($parameters as $key => $value) { - $parameter = new Parameter($key, $value); - - $parameterCollection->add($parameter); - } - - $parameters = $parameterCollection; - } - $this->parameters = $parameters; return $this; @@ -597,31 +526,22 @@ public function setParameters($parameters) /** * Gets all defined query parameters for the query being constructed. * - * @return ArrayCollection The currently defined query parameters. * @psalm-return ArrayCollection */ - public function getParameters() + public function getParameters(): ArrayCollection { return $this->parameters; } /** * Gets a (previously set) query parameter of the query being constructed. - * - * @param string|int $key The key (index or name) of the bound parameter. - * - * @return Parameter|null The value of the bound parameter. */ - public function getParameter($key) + public function getParameter(string|int $key): ?Parameter { $key = Parameter::normalizeName($key); $filteredParameters = $this->parameters->filter( - static function (Parameter $parameter) use ($key): bool { - $parameterName = $parameter->getName(); - - return $key === $parameterName; - } + static fn (Parameter $parameter): bool => $key === $parameter->getName() ); return ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null; @@ -630,17 +550,11 @@ static function (Parameter $parameter) use ($key): bool { /** * Sets the position of the first result to retrieve (the "offset"). * - * @param int|null $firstResult The first result to return. - * * @return $this */ - public function setFirstResult($firstResult) + public function setFirstResult(?int $firstResult): static { - if ($firstResult !== null) { - $firstResult = (int) $firstResult; - } - - $this->_firstResult = $firstResult; + $this->firstResult = $firstResult; return $this; } @@ -648,28 +562,20 @@ public function setFirstResult($firstResult) /** * Gets the position of the first result the query object was set to retrieve (the "offset"). * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder. - * - * @return int|null The position of the first result. */ - public function getFirstResult() + public function getFirstResult(): ?int { - return $this->_firstResult; + return $this->firstResult; } /** * Sets the maximum number of results to retrieve (the "limit"). * - * @param int|null $maxResults The maximum number of results to retrieve. - * * @return $this */ - public function setMaxResults($maxResults) + public function setMaxResults(?int $maxResults): static { - if ($maxResults !== null) { - $maxResults = (int) $maxResults; - } - - $this->_maxResults = $maxResults; + $this->maxResults = $maxResults; return $this; } @@ -677,12 +583,10 @@ public function setMaxResults($maxResults) /** * Gets the maximum number of results the query object was set to retrieve (the "limit"). * Returns NULL if {@link setMaxResults} was not applied to this query builder. - * - * @return int|null Maximum number of results. */ - public function getMaxResults() + public function getMaxResults(): ?int { - return $this->_maxResults; + return $this->maxResults; } /** @@ -691,14 +595,11 @@ public function getMaxResults() * The available parts are: 'select', 'from', 'join', 'set', 'where', * 'groupBy', 'having' and 'orderBy'. * - * @param string $dqlPartName The DQL part name. - * @param string|object|array $dqlPart An Expr object. - * @param bool $append Whether to append (true) or replace (false). * @psalm-param string|object|list|array{join: array} $dqlPart * * @return $this */ - public function add($dqlPartName, $dqlPart, $append = false) + public function add(string $dqlPartName, string|object|array $dqlPart, bool $append = false): static { if ($append && ($dqlPartName === 'where' || $dqlPartName === 'having')) { throw new InvalidArgumentException( @@ -707,7 +608,7 @@ public function add($dqlPartName, $dqlPart, $append = false) ); } - $isMultiple = is_array($this->_dqlParts[$dqlPartName]) + $isMultiple = is_array($this->dqlParts[$dqlPartName]) && ! ($dqlPartName === 'join' && ! $append); // Allow adding any part retrieved from self::getDQLParts(). @@ -733,15 +634,15 @@ public function add($dqlPartName, $dqlPart, $append = false) if (is_array($dqlPart)) { $key = key($dqlPart); - $this->_dqlParts[$dqlPartName][$key][] = $dqlPart[$key]; + $this->dqlParts[$dqlPartName][$key][] = $dqlPart[$key]; } else { - $this->_dqlParts[$dqlPartName][] = $dqlPart; + $this->dqlParts[$dqlPartName][] = $dqlPart; } } else { - $this->_dqlParts[$dqlPartName] = $isMultiple ? [$dqlPart] : $dqlPart; + $this->dqlParts[$dqlPartName] = $isMultiple ? [$dqlPart] : $dqlPart; } - $this->_state = self::STATE_DIRTY; + $this->state = self::STATE_DIRTY; return $this; } @@ -757,13 +658,11 @@ public function add($dqlPartName, $dqlPart, $append = false) * ->leftJoin('u.Phonenumbers', 'p'); * * - * @param mixed ...$select The selection expressions. - * * @return $this */ - public function select(...$select) + public function select(mixed ...$select): static { - $this->_type = self::SELECT; + $this->type = self::SELECT; if ($select === []) { return $this; @@ -782,13 +681,11 @@ public function select(...$select) * ->from('User', 'u'); * * - * @param bool $flag - * * @return $this */ - public function distinct($flag = true) + public function distinct(bool $flag = true): static { - $this->_dqlParts['distinct'] = (bool) $flag; + $this->dqlParts['distinct'] = $flag; return $this; } @@ -804,13 +701,11 @@ public function distinct($flag = true) * ->leftJoin('u.Phonenumbers', 'p'); * * - * @param mixed ...$select The selection expression. - * * @return $this */ - public function addSelect(...$select) + public function addSelect(mixed ...$select): static { - $this->_type = self::SELECT; + $this->type = self::SELECT; if ($select === []) { return $this; @@ -835,9 +730,9 @@ public function addSelect(...$select) * * @return $this */ - public function delete($delete = null, $alias = null) + public function delete(?string $delete = null, ?string $alias = null): static { - $this->_type = self::DELETE; + $this->type = self::DELETE; if (! $delete) { return $this; @@ -857,14 +752,11 @@ public function delete($delete = null, $alias = null) * ->where('u.id = ?2'); * * - * @param string|null $update The class/type whose instances are subject to the update. - * @param string|null $alias The class/type alias used in the constructed query. - * * @return $this */ - public function update($update = null, $alias = null) + public function update(?string $update = null, ?string $alias = null): static { - $this->_type = self::UPDATE; + $this->type = self::UPDATE; if (! $update) { return $this; @@ -883,13 +775,9 @@ public function update($update = null, $alias = null) * ->from('User', 'u'); * * - * @param string $from The class name. - * @param string $alias The alias of the class. - * @param string|null $indexBy The index for the from. - * * @return $this */ - public function from($from, $alias, $indexBy = null) + public function from(string $from, string $alias, ?string $indexBy = null): static { return $this->add('from', new Expr\From($from, $alias, $indexBy), true); } @@ -910,14 +798,11 @@ public function from($from, $alias, $indexBy = null) * ->from('User', 'u', 'u.id'); * * - * @param string $alias The root alias of the class. - * @param string $indexBy The index for the from. - * * @return $this * * @throws Query\QueryException */ - public function indexBy($alias, $indexBy) + public function indexBy(string $alias, string $indexBy): static { $rootAliases = $this->getRootAliases(); @@ -927,7 +812,7 @@ public function indexBy($alias, $indexBy) ); } - foreach ($this->_dqlParts['from'] as &$fromClause) { + foreach ($this->dqlParts['from'] as &$fromClause) { assert($fromClause instanceof Expr\From); if ($fromClause->getAlias() !== $alias) { continue; @@ -953,17 +838,17 @@ public function indexBy($alias, $indexBy) * ->join('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1'); * * - * @param string $join The relationship to join. - * @param string $alias The alias of the join. - * @param string|null $conditionType The condition type constant. Either ON or WITH. - * @param string|Expr\Comparison|Expr\Composite|null $condition The condition for the join. - * @param string|null $indexBy The index for the join. * @psalm-param Expr\Join::ON|Expr\Join::WITH|null $conditionType * * @return $this */ - public function join($join, $alias, $conditionType = null, $condition = null, $indexBy = null) - { + public function join( + string $join, + string $alias, + ?string $conditionType = null, + string|Expr\Composite|Expr\Comparison|null $condition = null, + ?string $indexBy = null + ): static { return $this->innerJoin($join, $alias, $conditionType, $condition, $indexBy); } @@ -980,17 +865,17 @@ public function join($join, $alias, $conditionType = null, $condition = null, $i * ->from('User', 'u') * ->innerJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1'); * - * @param string $join The relationship to join. - * @param string $alias The alias of the join. - * @param string|null $conditionType The condition type constant. Either ON or WITH. - * @param string|Expr\Comparison|Expr\Composite|null $condition The condition for the join. - * @param string|null $indexBy The index for the join. * @psalm-param Expr\Join::ON|Expr\Join::WITH|null $conditionType * * @return $this */ - public function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null) - { + public function innerJoin( + string $join, + string $alias, + ?string $conditionType = null, + string|Expr\Composite|Expr\Comparison|null $condition = null, + ?string $indexBy = null + ): static { $parentAlias = substr($join, 0, (int) strpos($join, '.')); $rootAlias = $this->findRootAlias($alias, $parentAlias); @@ -1021,17 +906,17 @@ public function innerJoin($join, $alias, $conditionType = null, $condition = nul * ->leftJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1'); * * - * @param string $join The relationship to join. - * @param string $alias The alias of the join. - * @param string|null $conditionType The condition type constant. Either ON or WITH. - * @param string|Expr\Comparison|Expr\Composite|null $condition The condition for the join. - * @param string|null $indexBy The index for the join. * @psalm-param Expr\Join::ON|Expr\Join::WITH|null $conditionType * * @return $this */ - public function leftJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null) - { + public function leftJoin( + string $join, + string $alias, + ?string $conditionType = null, + string|Expr\Composite|Expr\Comparison|null $condition = null, + ?string $indexBy = null + ): static { $parentAlias = substr($join, 0, (int) strpos($join, '.')); $rootAlias = $this->findRootAlias($alias, $parentAlias); @@ -1058,12 +943,9 @@ public function leftJoin($join, $alias, $conditionType = null, $condition = null * ->where('u.id = ?2'); * * - * @param string $key The key/field to set. - * @param mixed $value The value, expression, placeholder, etc. - * * @return $this */ - public function set($key, $value) + public function set(string $key, mixed $value): static { return $this->add('set', new Expr\Comparison($key, Expr\Comparison::EQ, $value), true); } @@ -1090,11 +972,9 @@ public function set($key, $value) * ->where($or); * * - * @param mixed ...$predicates The restriction predicates. - * * @return $this */ - public function where(...$predicates) + public function where(mixed ...$predicates): static { if (! (count($predicates) === 1 && $predicates[0] instanceof Expr\Composite)) { $predicates = new Expr\Andx($predicates); @@ -1117,11 +997,9 @@ public function where(...$predicates) * * @see where() * - * @param mixed ...$where The query restrictions. - * * @return $this */ - public function andWhere(...$where) + public function andWhere(mixed ...$where): static { $dql = $this->getDQLPart('where'); @@ -1149,11 +1027,9 @@ public function andWhere(...$where) * * @see where() * - * @param mixed ...$where The WHERE statement. - * * @return $this */ - public function orWhere(...$where) + public function orWhere(mixed ...$where): static { $dql = $this->getDQLPart('where'); @@ -1178,11 +1054,9 @@ public function orWhere(...$where) * ->groupBy('u.id'); * * - * @param string ...$groupBy The grouping expression. - * * @return $this */ - public function groupBy(string ...$groupBy) + public function groupBy(string ...$groupBy): static { return $this->add('groupBy', new Expr\GroupBy($groupBy)); } @@ -1198,11 +1072,9 @@ public function groupBy(string ...$groupBy) * ->addGroupBy('u.createdAt'); * * - * @param string ...$groupBy The grouping expression. - * * @return $this */ - public function addGroupBy(string ...$groupBy) + public function addGroupBy(string ...$groupBy): static { return $this->add('groupBy', new Expr\GroupBy($groupBy), true); } @@ -1211,11 +1083,9 @@ public function addGroupBy(string ...$groupBy) * Specifies a restriction over the groups of the query. * Replaces any previous having restrictions, if any. * - * @param mixed ...$having The restriction over the groups. - * * @return $this */ - public function having(...$having) + public function having(mixed ...$having): static { if (! (count($having) === 1 && ($having[0] instanceof Expr\Andx || $having[0] instanceof Expr\Orx))) { $having = new Expr\Andx($having); @@ -1228,11 +1098,9 @@ public function having(...$having) * Adds a restriction over the groups of the query, forming a logical * conjunction with any existing having restrictions. * - * @param mixed ...$having The restriction to append. - * * @return $this */ - public function andHaving(...$having) + public function andHaving(mixed ...$having): static { $dql = $this->getDQLPart('having'); @@ -1250,11 +1118,9 @@ public function andHaving(...$having) * Adds a restriction over the groups of the query, forming a logical * disjunction with any existing having restrictions. * - * @param mixed ...$having The restriction to add. - * * @return $this */ - public function orHaving(...$having) + public function orHaving(mixed ...$having): static { $dql = $this->getDQLPart('having'); @@ -1272,12 +1138,9 @@ public function orHaving(...$having) * Specifies an ordering for the query results. * Replaces any previously specified orderings, if any. * - * @param string|Expr\OrderBy $sort The ordering expression. - * @param string|null $order The ordering direction. - * * @return $this */ - public function orderBy($sort, $order = null) + public function orderBy(string|Expr\OrderBy $sort, ?string $order = null): static { $orderBy = $sort instanceof Expr\OrderBy ? $sort : new Expr\OrderBy($sort, $order); @@ -1287,12 +1150,9 @@ public function orderBy($sort, $order = null) /** * Adds an ordering to the query results. * - * @param string|Expr\OrderBy $sort The ordering expression. - * @param string|null $order The ordering direction. - * * @return $this */ - public function addOrderBy($sort, $order = null) + public function addOrderBy(string|Expr\OrderBy $sort, ?string $order = null): static { $orderBy = $sort instanceof Expr\OrderBy ? $sort : new Expr\OrderBy($sort, $order); @@ -1310,7 +1170,7 @@ public function addOrderBy($sort, $order = null) * * @throws Query\QueryException */ - public function addCriteria(Criteria $criteria) + public function addCriteria(Criteria $criteria): static { $allAliases = $this->getAllAliases(); if (! isset($allAliases[0])) { @@ -1361,14 +1221,10 @@ public function addCriteria(Criteria $criteria) /** * Gets a query part by its name. - * - * @param string $queryPartName - * - * @return mixed $queryPart */ - public function getDQLPart($queryPartName) + public function getDQLPart(string $queryPartName): mixed { - return $this->_dqlParts[$queryPartName]; + return $this->dqlParts[$queryPartName]; } /** @@ -1376,9 +1232,9 @@ public function getDQLPart($queryPartName) * * @psalm-return array $dqlParts */ - public function getDQLParts() + public function getDQLParts(): array { - return $this->_dqlParts; + return $this->dqlParts; } private function getDQLForDelete(): string @@ -1401,7 +1257,7 @@ private function getDQLForUpdate(): string private function getDQLForSelect(): string { $dql = 'SELECT' - . ($this->_dqlParts['distinct'] === true ? ' DISTINCT' : '') + . ($this->dqlParts['distinct'] === true ? ' DISTINCT' : '') . $this->getReducedDQLQueryPart('select', ['pre' => ' ', 'separator' => ', ']); $fromParts = $this->getDQLPart('from'); @@ -1458,10 +1314,10 @@ private function getReducedDQLQueryPart(string $queryPartName, array $options = * * @return $this */ - public function resetDQLParts($parts = null) + public function resetDQLParts(?array $parts = null): static { if ($parts === null) { - $parts = array_keys($this->_dqlParts); + $parts = array_keys($this->dqlParts); } foreach ($parts as $part) { @@ -1474,14 +1330,12 @@ public function resetDQLParts($parts = null) /** * Resets single DQL part. * - * @param string $part - * * @return $this */ - public function resetDQLPart($part) + public function resetDQLPart(string $part): static { - $this->_dqlParts[$part] = is_array($this->_dqlParts[$part]) ? [] : null; - $this->_state = self::STATE_DIRTY; + $this->dqlParts[$part] = is_array($this->dqlParts[$part]) ? [] : null; + $this->state = self::STATE_DIRTY; return $this; } @@ -1489,10 +1343,8 @@ public function resetDQLPart($part) /** * Gets a string representation of this QueryBuilder which corresponds to * the final DQL query being constructed. - * - * @return string The string representation of this QueryBuilder. */ - public function __toString() + public function __toString(): string { return $this->getDQL(); } @@ -1504,15 +1356,15 @@ public function __toString() */ public function __clone() { - foreach ($this->_dqlParts as $part => $elements) { - if (is_array($this->_dqlParts[$part])) { - foreach ($this->_dqlParts[$part] as $idx => $element) { + foreach ($this->dqlParts as $part => $elements) { + if (is_array($this->dqlParts[$part])) { + foreach ($this->dqlParts[$part] as $idx => $element) { if (is_object($element)) { - $this->_dqlParts[$part][$idx] = clone $element; + $this->dqlParts[$part][$idx] = clone $element; } } } elseif (is_object($elements)) { - $this->_dqlParts[$part] = clone $elements; + $this->dqlParts[$part] = clone $elements; } } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 96f22e7fe2e..3cbd9031a0b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2535,7 +2535,7 @@ ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null - Parameter|null + ?Parameter $spacePos @@ -2552,9 +2552,6 @@ $alias $alias - - self::SELECT -
diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 950ce55941d..6d45a50ada1 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -29,8 +29,7 @@ */ class QueryBuilderTest extends OrmTestCase { - /** @var EntityManagerMock */ - private $entityManager; + private EntityManagerMock $entityManager; protected function setUp(): void { From a74807aa86239e73068ab8839422cbfdb3a46c86 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 11 Feb 2022 02:13:58 +0100 Subject: [PATCH 049/475] Add native types to persisters (#9469) --- .../ORM/Cache/Persister/CachedPersister.php | 15 +- .../AbstractCollectionPersister.php | 125 ++------ .../Collection/CachedCollectionPersister.php | 16 +- ...rictReadWriteCachedCollectionPersister.php | 20 +- .../ReadOnlyCachedCollectionPersister.php | 5 +- .../ReadWriteCachedCollectionPersister.php | 20 +- .../Entity/AbstractEntityPersister.php | 254 +++++----------- .../Entity/CachedEntityPersister.php | 12 +- ...onStrictReadWriteCachedEntityPersister.php | 29 +- .../Entity/ReadOnlyCachedEntityPersister.php | 5 +- .../Entity/ReadWriteCachedEntityPersister.php | 20 +- .../AbstractCollectionPersister.php | 34 +-- .../Collection/CollectionPersister.php | 37 +-- .../Collection/ManyToManyPersister.php | 68 ++--- .../Collection/OneToManyPersister.php | 38 +-- .../AbstractEntityInheritancePersister.php | 21 +- .../Entity/BasicEntityPersister.php | 274 +++++------------- .../ORM/Persisters/Entity/EntityPersister.php | 127 +++----- .../Entity/JoinedSubclassPersister.php | 70 ++--- .../Entity/SingleTablePersister.php | 34 +-- phpstan-baseline.neon | 10 - psalm-baseline.xml | 29 +- .../Performance/Mock/NonLoadingPersister.php | 10 +- .../Tests/Mocks/EntityPersisterMock.php | 41 +-- .../AbstractCollectionPersisterTest.php | 7 +- ...ReadWriteCachedCollectionPersisterTest.php | 3 - ...ReadWriteCachedCollectionPersisterTest.php | 6 +- .../Entity/AbstractEntityPersisterTest.php | 7 +- ...tyPersisterCompositeTypeParametersTest.php | 7 +- ...sicEntityPersisterCompositeTypeSqlTest.php | 7 +- .../BasicEntityPersisterTypeValueSqlTest.php | 7 +- .../JoinedSubclassPersisterTest.php | 7 +- 32 files changed, 365 insertions(+), 1000 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/Persister/CachedPersister.php b/lib/Doctrine/ORM/Cache/Persister/CachedPersister.php index b5c6f9653cf..223692c25d2 100644 --- a/lib/Doctrine/ORM/Cache/Persister/CachedPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/CachedPersister.php @@ -13,22 +13,13 @@ interface CachedPersister { /** * Perform whatever processing is encapsulated here after completion of the transaction. - * - * @return void */ - public function afterTransactionComplete(); + public function afterTransactionComplete(): void; /** * Perform whatever processing is encapsulated here after completion of the rolled-back. - * - * @return void */ - public function afterTransactionRolledBack(); + public function afterTransactionRolledBack(): void; - /** - * Gets the The region access. - * - * @return Region - */ - public function getCacheRegion(); + public function getCacheRegion(): Region; } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index e51deec7d4d..afc234a50ed 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -26,54 +26,31 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister { - /** @var UnitOfWork */ - protected $uow; - - /** @var ClassMetadataFactory */ - protected $metadataFactory; - - /** @var CollectionPersister */ - protected $persister; - - /** @var ClassMetadata */ - protected $sourceEntity; - - /** @var ClassMetadata */ - protected $targetEntity; - - /** @var mixed[] */ - protected $association; + protected UnitOfWork $uow; + protected ClassMetadataFactory $metadataFactory; + protected ClassMetadata $sourceEntity; + protected ClassMetadata $targetEntity; /** @var mixed[] */ - protected $queuedCache = []; - - /** @var Region */ - protected $region; - - /** @var string */ - protected $regionName; + protected array $queuedCache = []; - /** @var CollectionHydrator */ - protected $hydrator; - - /** @var CacheLogger|null */ - protected $cacheLogger; + protected string $regionName; + protected CollectionHydrator $hydrator; + protected ?CacheLogger $cacheLogger; /** - * @param CollectionPersister $persister The collection persister that will be cached. - * @param Region $region The collection region. - * @param EntityManagerInterface $em The entity manager. - * @param mixed[] $association The association mapping. + * @param mixed[] $association The association mapping. */ - public function __construct(CollectionPersister $persister, Region $region, EntityManagerInterface $em, array $association) - { + public function __construct( + protected CollectionPersister $persister, + protected Region $region, + EntityManagerInterface $em, + protected array $association + ) { $configuration = $em->getConfiguration(); $cacheConfig = $configuration->getSecondLevelCacheConfiguration(); $cacheFactory = $cacheConfig->getCacheFactory(); - $this->region = $region; - $this->persister = $persister; - $this->association = $association; $this->regionName = $region->getName(); $this->uow = $em->getUnitOfWork(); $this->metadataFactory = $em->getMetadataFactory(); @@ -83,26 +60,17 @@ public function __construct(CollectionPersister $persister, Region $region, Enti $this->targetEntity = $em->getClassMetadata($association['targetEntity']); } - /** - * {@inheritdoc} - */ - public function getCacheRegion() + public function getCacheRegion(): Region { return $this->region; } - /** - * {@inheritdoc} - */ - public function getSourceEntityMetadata() + public function getSourceEntityMetadata(): ClassMetadata { return $this->sourceEntity; } - /** - * {@inheritdoc} - */ - public function getTargetEntityMetadata() + public function getTargetEntityMetadata(): ClassMetadata { return $this->targetEntity; } @@ -110,7 +78,7 @@ public function getTargetEntityMetadata() /** * {@inheritdoc} */ - public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key) + public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key): ?array { $cache = $this->region->get($key); @@ -121,10 +89,7 @@ public function loadCollectionCache(PersistentCollection $collection, Collection return $this->hydrator->loadCacheEntry($this->sourceEntity, $key, $cache, $collection); } - /** - * {@inheritdoc} - */ - public function storeCollectionCache(CollectionCacheKey $key, $elements) + public function storeCollectionCache(CollectionCacheKey $key, Collection|array $elements): void { $associationMapping = $this->sourceEntity->associationMappings[$key->association]; $targetPersister = $this->uow->getEntityPersister($this->targetEntity->rootEntityName); @@ -158,33 +123,22 @@ public function storeCollectionCache(CollectionCacheKey $key, $elements) $targetRegion->put($entityKey, $entityEntry); } - $cached = $this->region->put($key, $entry); - - if ($this->cacheLogger && $cached) { - $this->cacheLogger->collectionCachePut($this->regionName, $key); + if ($this->region->put($key, $entry)) { + $this->cacheLogger?->collectionCachePut($this->regionName, $key); } } - /** - * {@inheritdoc} - */ - public function contains(PersistentCollection $collection, $element) + public function contains(PersistentCollection $collection, object $element): bool { return $this->persister->contains($collection, $element); } - /** - * {@inheritdoc} - */ - public function containsKey(PersistentCollection $collection, $key) + public function containsKey(PersistentCollection $collection, mixed $key): bool { return $this->persister->containsKey($collection, $key); } - /** - * {@inheritdoc} - */ - public function count(PersistentCollection $collection) + public function count(PersistentCollection $collection): int { $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); @@ -197,10 +151,7 @@ public function count(PersistentCollection $collection) return $this->persister->count($collection); } - /** - * {@inheritdoc} - */ - public function get(PersistentCollection $collection, $index) + public function get(PersistentCollection $collection, mixed $index): mixed { return $this->persister->get($collection, $index); } @@ -208,7 +159,7 @@ public function get(PersistentCollection $collection, $index) /** * {@inheritdoc} */ - public function slice(PersistentCollection $collection, $offset, $length = null) + public function slice(PersistentCollection $collection, int $offset, ?int $length = null): array { return $this->persister->slice($collection, $offset, $length); } @@ -216,17 +167,15 @@ public function slice(PersistentCollection $collection, $offset, $length = null) /** * {@inheritDoc} */ - public function loadCriteria(PersistentCollection $collection, Criteria $criteria) + public function loadCriteria(PersistentCollection $collection, Criteria $criteria): array { return $this->persister->loadCriteria($collection, $criteria); } /** * Clears cache entries related to the current collection - * - * @return void */ - protected function evictCollectionCache(PersistentCollection $collection) + protected function evictCollectionCache(PersistentCollection $collection): void { $key = new CollectionCacheKey( $this->sourceEntity->rootEntityName, @@ -236,18 +185,10 @@ protected function evictCollectionCache(PersistentCollection $collection) $this->region->evict($key); - if ($this->cacheLogger) { - $this->cacheLogger->collectionCachePut($this->regionName, $key); - } + $this->cacheLogger?->collectionCachePut($this->regionName, $key); } - /** - * @param string $targetEntity - * @param object $element - * - * @return void - */ - protected function evictElementCache($targetEntity, $element) + protected function evictElementCache(string $targetEntity, object $element): void { $targetPersister = $this->uow->getEntityPersister($targetEntity); assert($targetPersister instanceof CachedEntityPersister); @@ -256,8 +197,6 @@ protected function evictElementCache($targetEntity, $element) $targetRegion->evict($key); - if ($this->cacheLogger) { - $this->cacheLogger->entityCachePut($targetRegion->getName(), $key); - } + $this->cacheLogger?->entityCachePut($targetRegion->getName(), $key); } } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php index 191f87d6b56..20c626ea544 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php @@ -16,29 +16,21 @@ */ interface CachedCollectionPersister extends CachedPersister, CollectionPersister { - /** - * @return ClassMetadata - */ - public function getSourceEntityMetadata(); + public function getSourceEntityMetadata(): ClassMetadata; - /** - * @return ClassMetadata - */ - public function getTargetEntityMetadata(); + public function getTargetEntityMetadata(): ClassMetadata; /** * Loads a collection from cache * * @return mixed[]|null */ - public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key); + public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key): ?array; /** * Stores a collection into cache * * @param mixed[]|Collection $elements - * - * @return void */ - public function storeCollectionCache(CollectionCacheKey $key, $elements); + public function storeCollectionCache(CollectionCacheKey $key, Collection|array $elements): void; } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php index 1126c82c6db..261048bc0ba 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php @@ -11,10 +11,7 @@ class NonStrictReadWriteCachedCollectionPersister extends AbstractCollectionPersister { - /** - * {@inheritdoc} - */ - public function afterTransactionComplete() + public function afterTransactionComplete(): void { if (isset($this->queuedCache['update'])) { foreach ($this->queuedCache['update'] as $item) { @@ -31,18 +28,12 @@ public function afterTransactionComplete() $this->queuedCache = []; } - /** - * {@inheritdoc} - */ - public function afterTransactionRolledBack() + public function afterTransactionRolledBack(): void { $this->queuedCache = []; } - /** - * {@inheritdoc} - */ - public function delete(PersistentCollection $collection) + public function delete(PersistentCollection $collection): void { $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); @@ -52,10 +43,7 @@ public function delete(PersistentCollection $collection) $this->queuedCache['delete'][spl_object_id($collection)] = $key; } - /** - * {@inheritdoc} - */ - public function update(PersistentCollection $collection) + public function update(PersistentCollection $collection): void { $isInitialized = $collection->isInitialized(); $isDirty = $collection->isDirty(); diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php index d3b2bd463c1..cf140771a2a 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php @@ -10,10 +10,7 @@ class ReadOnlyCachedCollectionPersister extends NonStrictReadWriteCachedCollectionPersister { - /** - * {@inheritdoc} - */ - public function update(PersistentCollection $collection) + public function update(PersistentCollection $collection): void { if ($collection->isDirty() && $collection->getSnapshot()) { throw CannotUpdateReadOnlyCollection::fromEntityAndField( diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php index d751da03064..1c6fd98ca82 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php @@ -22,10 +22,7 @@ public function __construct(CollectionPersister $persister, ConcurrentRegion $re parent::__construct($persister, $region, $em, $association); } - /** - * {@inheritdoc} - */ - public function afterTransactionComplete() + public function afterTransactionComplete(): void { if (isset($this->queuedCache['update'])) { foreach ($this->queuedCache['update'] as $item) { @@ -42,10 +39,7 @@ public function afterTransactionComplete() $this->queuedCache = []; } - /** - * {@inheritdoc} - */ - public function afterTransactionRolledBack() + public function afterTransactionRolledBack(): void { if (isset($this->queuedCache['update'])) { foreach ($this->queuedCache['update'] as $item) { @@ -62,10 +56,7 @@ public function afterTransactionRolledBack() $this->queuedCache = []; } - /** - * {@inheritdoc} - */ - public function delete(PersistentCollection $collection) + public function delete(PersistentCollection $collection): void { $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); @@ -83,10 +74,7 @@ public function delete(PersistentCollection $collection) ]; } - /** - * {@inheritdoc} - */ - public function update(PersistentCollection $collection) + public function update(PersistentCollection $collection): void { $isInitialized = $collection->isInitialized(); $isDirty = $collection->isDirty(); diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 6fe5d7f4c2e..ecc41b50fbc 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -21,6 +21,7 @@ use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\Entity\EntityPersister; +use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\UnitOfWork; use function assert; @@ -29,64 +30,36 @@ abstract class AbstractEntityPersister implements CachedEntityPersister { - /** @var UnitOfWork */ - protected $uow; - - /** @var ClassMetadataFactory */ - protected $metadataFactory; - - /** @var EntityPersister */ - protected $persister; - - /** @var ClassMetadata */ - protected $class; + protected UnitOfWork $uow; + protected ClassMetadataFactory $metadataFactory; /** @var mixed[] */ - protected $queuedCache = []; - - /** @var Region */ - protected $region; - - /** @var TimestampRegion */ - protected $timestampRegion; - - /** @var TimestampCacheKey */ - protected $timestampKey; - - /** @var EntityHydrator */ - protected $hydrator; - - /** @var Cache */ - protected $cache; - - /** @var CacheLogger|null */ - protected $cacheLogger; + protected array $queuedCache = []; - /** @var string */ - protected $regionName; + protected TimestampRegion $timestampRegion; + protected TimestampCacheKey $timestampKey; + protected EntityHydrator $hydrator; + protected Cache $cache; + protected ?CacheLogger $cacheLogger = null; + protected string $regionName; /** * Associations configured as FETCH_EAGER, as well as all inverse one-to-one associations. * * @var array|null */ - protected $joinedAssociations; + protected ?array $joinedAssociations = null; - /** - * @param EntityPersister $persister The entity persister to cache. - * @param Region $region The entity cache region. - * @param EntityManagerInterface $em The entity manager. - * @param ClassMetadata $class The entity metadata. - */ - public function __construct(EntityPersister $persister, Region $region, EntityManagerInterface $em, ClassMetadata $class) - { + public function __construct( + protected EntityPersister $persister, + protected Region $region, + EntityManagerInterface $em, + protected ClassMetadata $class + ) { $configuration = $em->getConfiguration(); $cacheConfig = $configuration->getSecondLevelCacheConfiguration(); $cacheFactory = $cacheConfig->getCacheFactory(); - $this->class = $class; - $this->region = $region; - $this->persister = $persister; $this->cache = $em->getCache(); $this->regionName = $region->getName(); $this->uow = $em->getUnitOfWork(); @@ -97,10 +70,7 @@ public function __construct(EntityPersister $persister, Region $region, EntityMa $this->timestampKey = new TimestampCacheKey($this->class->rootEntityName); } - /** - * {@inheritdoc} - */ - public function addInsert($entity) + public function addInsert(object $entity): void { $this->persister->addInsert($entity); } @@ -108,55 +78,37 @@ public function addInsert($entity) /** * {@inheritdoc} */ - public function getInserts() + public function getInserts(): array { return $this->persister->getInserts(); } - /** - * {@inheritdoc} - */ - public function getSelectSQL($criteria, $assoc = null, $lockMode = null, $limit = null, $offset = null, ?array $orderBy = null) + public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string { return $this->persister->getSelectSQL($criteria, $assoc, $lockMode, $limit, $offset, $orderBy); } - /** - * {@inheritDoc} - */ - public function getCountSQL($criteria = []) + public function getCountSQL(array|Criteria $criteria = []): string { return $this->persister->getCountSQL($criteria); } - /** - * {@inheritdoc} - */ - public function getInsertSQL() + public function getInsertSQL(): string { return $this->persister->getInsertSQL(); } - /** - * {@inheritdoc} - */ - public function getResultSetMapping() + public function getResultSetMapping(): ResultSetMapping { return $this->persister->getResultSetMapping(); } - /** - * {@inheritdoc} - */ - public function getSelectConditionStatementSQL($field, $value, $assoc = null, $comparison = null) + public function getSelectConditionStatementSQL(string $field, mixed $value, ?array $assoc = null, ?string $comparison = null): string { return $this->persister->getSelectConditionStatementSQL($field, $value, $assoc, $comparison); } - /** - * {@inheritdoc} - */ - public function exists($entity, ?Criteria $extraConditions = null) + public function exists(object $entity, ?Criteria $extraConditions = null): bool { if ($extraConditions === null) { $key = new EntityCacheKey($this->class->rootEntityName, $this->class->getIdentifierValues($entity)); @@ -169,26 +121,17 @@ public function exists($entity, ?Criteria $extraConditions = null) return $this->persister->exists($entity, $extraConditions); } - /** - * {@inheritdoc} - */ - public function getCacheRegion() + public function getCacheRegion(): Region { return $this->region; } - /** - * @return EntityHydrator - */ - public function getEntityHydrator() + public function getEntityHydrator(): EntityHydrator { return $this->hydrator; } - /** - * {@inheritdoc} - */ - public function storeEntityCache($entity, EntityCacheKey $key) + public function storeEntityCache(object $entity, EntityCacheKey $key): bool { $class = $this->class; $className = ClassUtils::getClass($entity); @@ -200,17 +143,14 @@ public function storeEntityCache($entity, EntityCacheKey $key) $entry = $this->hydrator->buildCacheEntry($class, $key, $entity); $cached = $this->region->put($key, $entry); - if ($this->cacheLogger && $cached) { - $this->cacheLogger->entityCachePut($this->regionName, $key); + if ($cached) { + $this->cacheLogger?->entityCachePut($this->regionName, $key); } return $cached; } - /** - * @param object $entity - */ - private function storeJoinedAssociations($entity): void + private function storeJoinedAssociations(object $entity): void { if ($this->joinedAssociations === null) { $associations = []; @@ -248,15 +188,10 @@ private function storeJoinedAssociations($entity): void /** * Generates a string of currently query * - * @param string $query * @param string[]|Criteria $criteria * @param string[] $orderBy - * @param int|null $limit - * @param int|null $offset - * - * @return string */ - protected function getHash($query, $criteria, ?array $orderBy = null, $limit = null, $offset = null) + protected function getHash(string $query, array|Criteria $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): string { [$params] = $criteria instanceof Criteria ? $this->persister->expandCriteriaParameters($criteria) @@ -268,7 +203,7 @@ protected function getHash($query, $criteria, ?array $orderBy = null, $limit = n /** * {@inheritdoc} */ - public function expandParameters($criteria) + public function expandParameters(array $criteria): array { return $this->persister->expandParameters($criteria); } @@ -276,15 +211,12 @@ public function expandParameters($criteria) /** * {@inheritdoc} */ - public function expandCriteriaParameters(Criteria $criteria) + public function expandCriteriaParameters(Criteria $criteria): array { return $this->persister->expandCriteriaParameters($criteria); } - /** - * {@inheritdoc} - */ - public function getClassMetadata() + public function getClassMetadata(): ClassMetadata { return $this->persister->getClassMetadata(); } @@ -292,7 +224,7 @@ public function getClassMetadata() /** * {@inheritdoc} */ - public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = null, $limit = null) + public function getManyToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array { return $this->persister->getManyToManyCollection($assoc, $sourceEntity, $offset, $limit); } @@ -300,15 +232,12 @@ public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = n /** * {@inheritdoc} */ - public function getOneToManyCollection(array $assoc, $sourceEntity, $offset = null, $limit = null) + public function getOneToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array { return $this->persister->getOneToManyCollection($assoc, $sourceEntity, $offset, $limit); } - /** - * {@inheritdoc} - */ - public function getOwningTable($fieldName) + public function getOwningTable(string $fieldName): string { return $this->persister->getOwningTable($fieldName); } @@ -316,7 +245,7 @@ public function getOwningTable($fieldName) /** * {@inheritdoc} */ - public function executeInserts() + public function executeInserts(): array { $this->queuedCache['insert'] = $this->persister->getInserts(); @@ -326,7 +255,7 @@ public function executeInserts() /** * {@inheritdoc} */ - public function load(array $criteria, $entity = null, $assoc = null, array $hints = [], $lockMode = null, $limit = null, ?array $orderBy = null) + public function load(array $criteria, ?object $entity = null, ?array $assoc = null, array $hints = [], ?int $lockMode = null, ?int $limit = null, ?array $orderBy = null): ?object { if ($entity !== null || $assoc !== null || $hints !== [] || $lockMode !== null) { return $this->persister->load($criteria, $entity, $assoc, $hints, $lockMode, $limit, $orderBy); @@ -334,16 +263,14 @@ public function load(array $criteria, $entity = null, $assoc = null, array $hint //handle only EntityRepository#findOneBy $query = $this->persister->getSelectSQL($criteria, null, null, $limit, null, $orderBy); - $hash = $this->getHash($query, $criteria, null, null, null); + $hash = $this->getHash($query, $criteria); $rsm = $this->getResultSetMapping(); $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey); $queryCache = $this->cache->getQueryCache($this->regionName); $result = $queryCache->get($queryKey, $rsm); if ($result !== null) { - if ($this->cacheLogger) { - $this->cacheLogger->queryCacheHit($this->regionName, $queryKey); - } + $this->cacheLogger?->queryCacheHit($this->regionName, $queryKey); return $result[0]; } @@ -356,12 +283,10 @@ public function load(array $criteria, $entity = null, $assoc = null, array $hint $cached = $queryCache->put($queryKey, $rsm, [$result]); - if ($this->cacheLogger) { - $this->cacheLogger->queryCacheMiss($this->regionName, $queryKey); + $this->cacheLogger?->queryCacheMiss($this->regionName, $queryKey); - if ($cached) { - $this->cacheLogger->queryCachePut($this->regionName, $queryKey); - } + if ($cached) { + $this->cacheLogger?->queryCachePut($this->regionName, $queryKey); } return $result; @@ -370,19 +295,17 @@ public function load(array $criteria, $entity = null, $assoc = null, array $hint /** * {@inheritdoc} */ - public function loadAll(array $criteria = [], ?array $orderBy = null, $limit = null, $offset = null) + public function loadAll(array $criteria = [], ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array { $query = $this->persister->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy); - $hash = $this->getHash($query, $criteria, null, null, null); + $hash = $this->getHash($query, $criteria); $rsm = $this->getResultSetMapping(); $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey); $queryCache = $this->cache->getQueryCache($this->regionName); $result = $queryCache->get($queryKey, $rsm); if ($result !== null) { - if ($this->cacheLogger) { - $this->cacheLogger->queryCacheHit($this->regionName, $queryKey); - } + $this->cacheLogger?->queryCacheHit($this->regionName, $queryKey); return $result; } @@ -390,14 +313,12 @@ public function loadAll(array $criteria = [], ?array $orderBy = null, $limit = n $result = $this->persister->loadAll($criteria, $orderBy, $limit, $offset); $cached = $queryCache->put($queryKey, $rsm, $result); - if ($this->cacheLogger) { - if ($result) { - $this->cacheLogger->queryCacheMiss($this->regionName, $queryKey); - } + if ($result) { + $this->cacheLogger?->queryCacheMiss($this->regionName, $queryKey); + } - if ($cached) { - $this->cacheLogger->queryCachePut($this->regionName, $queryKey); - } + if ($cached) { + $this->cacheLogger?->queryCachePut($this->regionName, $queryKey); } return $result; @@ -406,7 +327,7 @@ public function loadAll(array $criteria = [], ?array $orderBy = null, $limit = n /** * {@inheritdoc} */ - public function loadById(array $identifier, $entity = null) + public function loadById(array $identifier, ?object $entity = null): ?object { $cacheKey = new EntityCacheKey($this->class->rootEntityName, $identifier); $cacheEntry = $this->region->get($cacheKey); @@ -420,9 +341,7 @@ public function loadById(array $identifier, $entity = null) $cachedEntity = $this->hydrator->loadCacheEntry($class, $cacheKey, $cacheEntry, $entity); if ($cachedEntity !== null) { - if ($this->cacheLogger) { - $this->cacheLogger->entityCacheHit($this->regionName, $cacheKey); - } + $this->cacheLogger?->entityCacheHit($this->regionName, $cacheKey); return $cachedEntity; } @@ -448,21 +367,16 @@ public function loadById(array $identifier, $entity = null) $this->storeJoinedAssociations($entity); } - if ($this->cacheLogger) { - if ($cached) { - $this->cacheLogger->entityCachePut($this->regionName, $cacheKey); - } - - $this->cacheLogger->entityCacheMiss($this->regionName, $cacheKey); + if ($cached) { + $this->cacheLogger?->entityCachePut($this->regionName, $cacheKey); } + $this->cacheLogger?->entityCacheMiss($this->regionName, $cacheKey); + return $entity; } - /** - * {@inheritDoc} - */ - public function count($criteria = []) + public function count(array|Criteria $criteria = []): int { return $this->persister->count($criteria); } @@ -470,7 +384,7 @@ public function count($criteria = []) /** * {@inheritdoc} */ - public function loadCriteria(Criteria $criteria) + public function loadCriteria(Criteria $criteria): array { $orderBy = $criteria->getOrderings(); $limit = $criteria->getMaxResults(); @@ -483,9 +397,7 @@ public function loadCriteria(Criteria $criteria) $cacheResult = $queryCache->get($queryKey, $rsm); if ($cacheResult !== null) { - if ($this->cacheLogger) { - $this->cacheLogger->queryCacheHit($this->regionName, $queryKey); - } + $this->cacheLogger?->queryCacheHit($this->regionName, $queryKey); return $cacheResult; } @@ -493,14 +405,12 @@ public function loadCriteria(Criteria $criteria) $result = $this->persister->loadCriteria($criteria); $cached = $queryCache->put($queryKey, $rsm, $result); - if ($this->cacheLogger) { - if ($result) { - $this->cacheLogger->queryCacheMiss($this->regionName, $queryKey); - } + if ($result) { + $this->cacheLogger?->queryCacheMiss($this->regionName, $queryKey); + } - if ($cached) { - $this->cacheLogger->queryCachePut($this->regionName, $queryKey); - } + if ($cached) { + $this->cacheLogger?->queryCachePut($this->regionName, $queryKey); } return $result; @@ -509,7 +419,7 @@ public function loadCriteria(Criteria $criteria) /** * {@inheritdoc} */ - public function loadManyToManyCollection(array $assoc, $sourceEntity, PersistentCollection $collection) + public function loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): array { $persister = $this->uow->getCollectionPersister($assoc); $hasCache = ($persister instanceof CachedPersister); @@ -523,9 +433,7 @@ public function loadManyToManyCollection(array $assoc, $sourceEntity, Persistent $list = $persister->loadCollectionCache($collection, $key); if ($list !== null) { - if ($this->cacheLogger) { - $this->cacheLogger->collectionCacheHit($persister->getCacheRegion()->getName(), $key); - } + $this->cacheLogger?->collectionCacheHit($persister->getCacheRegion()->getName(), $key); return $list; } @@ -534,9 +442,7 @@ public function loadManyToManyCollection(array $assoc, $sourceEntity, Persistent $persister->storeCollectionCache($key, $list); - if ($this->cacheLogger) { - $this->cacheLogger->collectionCacheMiss($persister->getCacheRegion()->getName(), $key); - } + $this->cacheLogger?->collectionCacheMiss($persister->getCacheRegion()->getName(), $key); return $list; } @@ -544,7 +450,7 @@ public function loadManyToManyCollection(array $assoc, $sourceEntity, Persistent /** * {@inheritdoc} */ - public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentCollection $collection) + public function loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): mixed { $persister = $this->uow->getCollectionPersister($assoc); $hasCache = ($persister instanceof CachedPersister); @@ -558,9 +464,7 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC $list = $persister->loadCollectionCache($collection, $key); if ($list !== null) { - if ($this->cacheLogger) { - $this->cacheLogger->collectionCacheHit($persister->getCacheRegion()->getName(), $key); - } + $this->cacheLogger?->collectionCacheHit($persister->getCacheRegion()->getName(), $key); return $list; } @@ -569,9 +473,7 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC $persister->storeCollectionCache($key, $list); - if ($this->cacheLogger) { - $this->cacheLogger->collectionCacheMiss($persister->getCacheRegion()->getName(), $key); - } + $this->cacheLogger?->collectionCacheMiss($persister->getCacheRegion()->getName(), $key); return $list; } @@ -579,7 +481,7 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC /** * {@inheritdoc} */ - public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = []) + public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): ?object { return $this->persister->loadOneToOneEntity($assoc, $sourceEntity, $identifier); } @@ -587,7 +489,7 @@ public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifie /** * {@inheritdoc} */ - public function lock(array $criteria, $lockMode) + public function lock(array $criteria, int $lockMode): void { $this->persister->lock($criteria, $lockMode); } @@ -595,7 +497,7 @@ public function lock(array $criteria, $lockMode) /** * {@inheritdoc} */ - public function refresh(array $id, $entity, $lockMode = null) + public function refresh(array $id, object $entity, ?int $lockMode = null): void { $this->persister->refresh($id, $entity, $lockMode); } @@ -603,10 +505,8 @@ public function refresh(array $id, $entity, $lockMode = null) /** * @param array $association * @param array $ownerId - * - * @return CollectionCacheKey */ - protected function buildCollectionCacheKey(array $association, $ownerId) + protected function buildCollectionCacheKey(array $association, array $ownerId): CollectionCacheKey { $metadata = $this->metadataFactory->getMetadataFor($association['sourceEntity']); assert($metadata instanceof ClassMetadata); diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php index e66a5414b2c..5fba56f2914 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php @@ -14,15 +14,7 @@ */ interface CachedEntityPersister extends CachedPersister, EntityPersister { - /** - * @return EntityHydrator - */ - public function getEntityHydrator(); + public function getEntityHydrator(): EntityHydrator; - /** - * @param object $entity - * - * @return bool - */ - public function storeEntityCache($entity, EntityCacheKey $key); + public function storeEntityCache(object $entity, EntityCacheKey $key): bool; } diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php index ee10159b2d9..febb187f72b 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php @@ -13,10 +13,7 @@ */ class NonStrictReadWriteCachedEntityPersister extends AbstractEntityPersister { - /** - * {@inheritdoc} - */ - public function afterTransactionComplete() + public function afterTransactionComplete(): void { $isChanged = false; @@ -47,18 +44,12 @@ public function afterTransactionComplete() $this->queuedCache = []; } - /** - * {@inheritdoc} - */ - public function afterTransactionRolledBack() + public function afterTransactionRolledBack(): void { $this->queuedCache = []; } - /** - * {@inheritdoc} - */ - public function delete($entity) + public function delete(object $entity): bool { $key = new EntityCacheKey($this->class->rootEntityName, $this->uow->getEntityIdentifier($entity)); $deleted = $this->persister->delete($entity); @@ -72,20 +63,14 @@ public function delete($entity) return $deleted; } - /** - * {@inheritdoc} - */ - public function update($entity) + public function update(object $entity): void { $this->persister->update($entity); $this->queuedCache['update'][] = $entity; } - /** - * @param object $entity - */ - private function updateCache($entity, bool $isChanged): bool + private function updateCache(object $entity, bool $isChanged): bool { $class = $this->metadataFactory->getMetadataFor(get_class($entity)); $key = new EntityCacheKey($class->rootEntityName, $this->uow->getEntityIdentifier($entity)); @@ -93,8 +78,8 @@ private function updateCache($entity, bool $isChanged): bool $cached = $this->region->put($key, $entry); $isChanged = $isChanged || $cached; - if ($this->cacheLogger && $cached) { - $this->cacheLogger->entityCachePut($this->regionName, $key); + if ($cached) { + $this->cacheLogger?->entityCachePut($this->regionName, $key); } return $isChanged; diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php index 657d53221d6..1d69c852416 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php @@ -12,10 +12,7 @@ */ class ReadOnlyCachedEntityPersister extends NonStrictReadWriteCachedEntityPersister { - /** - * {@inheritdoc} - */ - public function update($entity) + public function update(object $entity): void { throw CannotUpdateReadOnlyEntity::fromEntity(ClassUtils::getClass($entity)); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php index 398ac44bbd7..a1ea0dcf07e 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php @@ -20,10 +20,7 @@ public function __construct(EntityPersister $persister, ConcurrentRegion $region parent::__construct($persister, $region, $em, $class); } - /** - * {@inheritdoc} - */ - public function afterTransactionComplete() + public function afterTransactionComplete(): void { $isChanged = true; @@ -50,10 +47,7 @@ public function afterTransactionComplete() $this->queuedCache = []; } - /** - * {@inheritdoc} - */ - public function afterTransactionRolledBack() + public function afterTransactionRolledBack(): void { if (isset($this->queuedCache['update'])) { foreach ($this->queuedCache['update'] as $item) { @@ -70,10 +64,7 @@ public function afterTransactionRolledBack() $this->queuedCache = []; } - /** - * {@inheritdoc} - */ - public function delete($entity) + public function delete(object $entity): bool { $key = new EntityCacheKey($this->class->rootEntityName, $this->uow->getEntityIdentifier($entity)); $lock = $this->region->lock($key); @@ -95,10 +86,7 @@ public function delete($entity) return $deleted; } - /** - * {@inheritdoc} - */ - public function update($entity) + public function update(object $entity): void { $key = new EntityCacheKey($this->class->rootEntityName, $this->uow->getEntityIdentifier($entity)); $lock = $this->region->lock($key); diff --git a/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php index 452310e3645..68a62421430 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php @@ -15,31 +15,17 @@ */ abstract class AbstractCollectionPersister implements CollectionPersister { - /** @var EntityManagerInterface */ - protected $em; - - /** @var Connection */ - protected $conn; - - /** @var UnitOfWork */ - protected $uow; - - /** - * The database platform. - * - * @var AbstractPlatform - */ - protected $platform; - - /** @var QuoteStrategy */ - protected $quoteStrategy; + protected Connection $conn; + protected UnitOfWork $uow; + protected AbstractPlatform $platform; + protected QuoteStrategy $quoteStrategy; /** * Initializes a new instance of a class derived from AbstractCollectionPersister. */ - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; + public function __construct( + protected EntityManagerInterface $em + ) { $this->uow = $em->getUnitOfWork(); $this->conn = $em->getConnection(); $this->platform = $this->conn->getDatabasePlatform(); @@ -48,12 +34,8 @@ public function __construct(EntityManagerInterface $em) /** * Check if entity is in a valid state for operations. - * - * @param object $entity - * - * @return bool */ - protected function isValidEntityState($entity) + protected function isValidEntityState(object $entity): bool { $entityState = $this->uow->getEntityState($entity, UnitOfWork::STATE_NEW); diff --git a/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php b/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php index 5c27ad8b94b..8a959f7aa31 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php @@ -14,67 +14,46 @@ interface CollectionPersister { /** * Deletes the persistent state represented by the given collection. - * - * @return void */ - public function delete(PersistentCollection $collection); + public function delete(PersistentCollection $collection): void; /** * Updates the given collection, synchronizing its state with the database * by inserting, updating and deleting individual elements. - * - * @return void */ - public function update(PersistentCollection $collection); + public function update(PersistentCollection $collection): void; /** * Counts the size of this persistent collection. - * - * @return int */ - public function count(PersistentCollection $collection); + public function count(PersistentCollection $collection): int; /** * Slices elements. * - * @param int $offset - * @param int|null $length - * * @return mixed[] */ - public function slice(PersistentCollection $collection, $offset, $length = null); + public function slice(PersistentCollection $collection, int $offset, ?int $length = null): array; /** * Checks for existence of an element. - * - * @param object $element - * - * @return bool */ - public function contains(PersistentCollection $collection, $element); + public function contains(PersistentCollection $collection, object $element): bool; /** * Checks for existence of a key. - * - * @param mixed $key - * - * @return bool */ - public function containsKey(PersistentCollection $collection, $key); + public function containsKey(PersistentCollection $collection, mixed $key): bool; /** * Gets an element by key. - * - * @param mixed $index - * - * @return mixed */ - public function get(PersistentCollection $collection, $index); + public function get(PersistentCollection $collection, mixed $index): mixed; /** * Loads association entities matching the given Criteria object. * * @return mixed[] */ - public function loadCriteria(PersistentCollection $collection, Criteria $criteria); + public function loadCriteria(PersistentCollection $collection, Criteria $criteria): array; } diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 7bfba7b8889..9f32844d213 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -27,10 +27,7 @@ */ class ManyToManyPersister extends AbstractCollectionPersister { - /** - * {@inheritdoc} - */ - public function delete(PersistentCollection $collection) + public function delete(PersistentCollection $collection): void { $mapping = $collection->getMapping(); @@ -48,10 +45,7 @@ public function delete(PersistentCollection $collection) $this->conn->executeStatement($this->getDeleteSQL($collection), $this->getDeleteSQLParameters($collection), $types); } - /** - * {@inheritdoc} - */ - public function update(PersistentCollection $collection) + public function update(PersistentCollection $collection): void { $mapping = $collection->getMapping(); @@ -79,10 +73,7 @@ public function update(PersistentCollection $collection) } } - /** - * {@inheritdoc} - */ - public function get(PersistentCollection $collection, $index) + public function get(PersistentCollection $collection, mixed $index): mixed { $mapping = $collection->getMapping(); @@ -98,10 +89,7 @@ public function get(PersistentCollection $collection, $index) return $persister->load([$mappedKey => $collection->getOwner(), $mapping['indexBy'] => $index], null, $mapping, [], 0, 1); } - /** - * {@inheritdoc} - */ - public function count(PersistentCollection $collection) + public function count(PersistentCollection $collection): int { $conditions = []; $params = []; @@ -160,7 +148,7 @@ public function count(PersistentCollection $collection) /** * {@inheritDoc} */ - public function slice(PersistentCollection $collection, $offset, $length = null) + public function slice(PersistentCollection $collection, int $offset, ?int $length = null): array { $mapping = $collection->getMapping(); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); @@ -168,10 +156,7 @@ public function slice(PersistentCollection $collection, $offset, $length = null) return $persister->getManyToManyCollection($mapping, $collection->getOwner(), $offset, $length); } - /** - * {@inheritdoc} - */ - public function containsKey(PersistentCollection $collection, $key) + public function containsKey(PersistentCollection $collection, mixed $key): bool { $mapping = $collection->getMapping(); @@ -190,10 +175,7 @@ public function containsKey(PersistentCollection $collection, $key) return (bool) $this->conn->fetchOne($sql, $params, $types); } - /** - * {@inheritDoc} - */ - public function contains(PersistentCollection $collection, $element) + public function contains(PersistentCollection $collection, object $element): bool { if (! $this->isValidEntityState($element)) { return false; @@ -213,7 +195,7 @@ public function contains(PersistentCollection $collection, $element) /** * {@inheritDoc} */ - public function loadCriteria(PersistentCollection $collection, Criteria $criteria) + public function loadCriteria(PersistentCollection $collection, Criteria $criteria): array { $mapping = $collection->getMapping(); $owner = $collection->getOwner(); @@ -293,7 +275,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri * - WHERE condition to add to the SQL * @psalm-return array{0: string, 1: string} */ - public function getFilterSql($mapping) + public function getFilterSql(array $mapping): array { $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $rootClass = $this->em->getClassMetadata($targetClass->rootEntityName); @@ -319,7 +301,7 @@ public function getFilterSql($mapping) * * @return string The SQL query part to add to a query. */ - protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) + protected function generateFilterConditionSQL(ClassMetadata $targetEntity, string $targetTableAlias): string { $filterClauses = []; @@ -344,7 +326,7 @@ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targ * @return string[] * @psalm-return list */ - protected function getOnConditionSQL($mapping) + protected function getOnConditionSQL(array $mapping): array { $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $association = ! $mapping['isOwningSide'] @@ -367,10 +349,7 @@ protected function getOnConditionSQL($mapping) return $conditions; } - /** - * @return string - */ - protected function getDeleteSQL(PersistentCollection $collection) + protected function getDeleteSQL(PersistentCollection $collection): string { $columns = []; $mapping = $collection->getMapping(); @@ -390,7 +369,7 @@ protected function getDeleteSQL(PersistentCollection $collection) * * @return list */ - protected function getDeleteSQLParameters(PersistentCollection $collection) + protected function getDeleteSQLParameters(PersistentCollection $collection): array { $mapping = $collection->getMapping(); $identifier = $this->uow->getEntityIdentifier($collection->getOwner()); @@ -420,7 +399,7 @@ protected function getDeleteSQLParameters(PersistentCollection $collection) * of types for bound parameters * @psalm-return array{0: string, 1: list} */ - protected function getDeleteRowSQL(PersistentCollection $collection) + protected function getDeleteRowSQL(PersistentCollection $collection): array { $mapping = $collection->getMapping(); $class = $this->em->getClassMetadata($mapping['sourceEntity']); @@ -451,12 +430,10 @@ protected function getDeleteRowSQL(PersistentCollection $collection) * * Internal note: Order of the parameters must be the same as the order of the columns in getDeleteRowSql. * - * @param mixed $element - * * @return mixed[] * @psalm-return list */ - protected function getDeleteRowSQLParameters(PersistentCollection $collection, $element) + protected function getDeleteRowSQLParameters(PersistentCollection $collection, object $element) { return $this->collectJoinTableColumnParameters($collection, $element); } @@ -468,7 +445,7 @@ protected function getDeleteRowSQLParameters(PersistentCollection $collection, $ * of types for bound parameters * @psalm-return array{0: string, 1: list} */ - protected function getInsertRowSQL(PersistentCollection $collection) + protected function getInsertRowSQL(PersistentCollection $collection): array { $columns = []; $types = []; @@ -501,12 +478,10 @@ protected function getInsertRowSQL(PersistentCollection $collection) * * Internal note: Order of the parameters must be the same as the order of the columns in getInsertRowSql. * - * @param object $element - * * @return mixed[] * @psalm-return list */ - protected function getInsertRowSQLParameters(PersistentCollection $collection, $element) + protected function getInsertRowSQLParameters(PersistentCollection $collection, object $element): array { return $this->collectJoinTableColumnParameters($collection, $element); } @@ -515,14 +490,12 @@ protected function getInsertRowSQLParameters(PersistentCollection $collection, $ * Collects the parameters for inserting/deleting on the join table in the order * of the join table columns as specified in ManyToManyMapping#joinTableColumns. * - * @param object $element - * * @return mixed[] * @psalm-return list */ private function collectJoinTableColumnParameters( PersistentCollection $collection, - $element + object $element ): array { $params = []; $mapping = $collection->getMapping(); @@ -646,8 +619,7 @@ private function getJoinTableRestrictionsWithKey( } /** - * @param bool $addFilters Whether the filter SQL should be included or not. - * @param object $element + * @param bool $addFilters Whether the filter SQL should be included or not. * * @return mixed[] ordered vector: * - quoted join table name @@ -658,7 +630,7 @@ private function getJoinTableRestrictionsWithKey( */ private function getJoinTableRestrictions( PersistentCollection $collection, - $element, + object $element, bool $addFilters ): array { $filterMapping = $collection->getMapping(); diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 26dba715b6d..cbf0b5045e7 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -21,12 +21,7 @@ */ class OneToManyPersister extends AbstractCollectionPersister { - /** - * {@inheritdoc} - * - * @return int|null - */ - public function delete(PersistentCollection $collection) + public function delete(PersistentCollection $collection): void { // The only valid case here is when you have weak entities. In this // scenario, you have @OneToMany with orphanRemoval=true, and replacing @@ -42,15 +37,12 @@ public function delete(PersistentCollection $collection) $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); - return $targetClass->isInheritanceTypeJoined() + $targetClass->isInheritanceTypeJoined() ? $this->deleteJoinedEntityCollection($collection) : $this->deleteEntityCollection($collection); } - /** - * {@inheritdoc} - */ - public function update(PersistentCollection $collection) + public function update(PersistentCollection $collection): void { // This can never happen. One to many can only be inverse side. // For owning side one to many, it is required to have a join table, @@ -58,10 +50,7 @@ public function update(PersistentCollection $collection) return; } - /** - * {@inheritdoc} - */ - public function get(PersistentCollection $collection, $index) + public function get(PersistentCollection $collection, mixed $index): mixed { $mapping = $collection->getMapping(); @@ -84,10 +73,7 @@ public function get(PersistentCollection $collection, $index) ); } - /** - * {@inheritdoc} - */ - public function count(PersistentCollection $collection) + public function count(PersistentCollection $collection): int { $mapping = $collection->getMapping(); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); @@ -103,7 +89,7 @@ public function count(PersistentCollection $collection) /** * {@inheritdoc} */ - public function slice(PersistentCollection $collection, $offset, $length = null) + public function slice(PersistentCollection $collection, int $offset, ?int $length = null): array { $mapping = $collection->getMapping(); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); @@ -111,10 +97,7 @@ public function slice(PersistentCollection $collection, $offset, $length = null) return $persister->getOneToManyCollection($mapping, $collection->getOwner(), $offset, $length); } - /** - * {@inheritdoc} - */ - public function containsKey(PersistentCollection $collection, $key) + public function containsKey(PersistentCollection $collection, mixed $key): bool { $mapping = $collection->getMapping(); @@ -135,10 +118,7 @@ public function containsKey(PersistentCollection $collection, $key) return (bool) $persister->count($criteria); } - /** - * {@inheritdoc} - */ - public function contains(PersistentCollection $collection, $element) + public function contains(PersistentCollection $collection, object $element): bool { if (! $this->isValidEntityState($element)) { return false; @@ -158,7 +138,7 @@ public function contains(PersistentCollection $collection, $element) /** * {@inheritdoc} */ - public function loadCriteria(PersistentCollection $collection, Criteria $criteria) + public function loadCriteria(PersistentCollection $collection, Criteria $criteria): array { throw new BadMethodCallException('Filtering a collection by Criteria is not supported by this CollectionPersister.'); } diff --git a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php index c5f5e04f10e..4416d714dcf 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php @@ -19,7 +19,7 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister /** * {@inheritdoc} */ - protected function prepareInsertData($entity) + protected function prepareInsertData(object $entity): array { $data = parent::prepareInsertData($entity); @@ -33,15 +33,10 @@ protected function prepareInsertData($entity) /** * Gets the name of the table that contains the discriminator column. - * - * @return string The table name. */ - abstract protected function getDiscriminatorColumnTableName(); + abstract protected function getDiscriminatorColumnTableName(): string; - /** - * {@inheritdoc} - */ - protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') + protected function getSelectColumnSQL(string $field, ClassMetadata $class, string $alias = 'r'): string { $tableAlias = $alias === 'r' ? '' : $alias; $fieldMapping = $class->fieldMappings[$field]; @@ -62,15 +57,7 @@ protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r' return $sql . ' AS ' . $columnAlias; } - /** - * @param string $tableAlias - * @param string $joinColumnName - * @param string $quotedColumnName - * @param string $type - * - * @return string - */ - protected function getSelectJoinColumnSQL($tableAlias, $joinColumnName, $quotedColumnName, $type) + protected function getSelectJoinColumnSQL(string $tableAlias, string $joinColumnName, string $quotedColumnName, string $type): string { $columnAlias = $this->getSQLColumnAlias($joinColumnName); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 7b74ea8bf9c..abbc5e09e5b 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -14,7 +14,6 @@ use Doctrine\DBAL\Result; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; @@ -28,6 +27,7 @@ use Doctrine\ORM\Persisters\SqlValueVisitor; use Doctrine\ORM\Query; use Doctrine\ORM\Query\QueryException; +use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Repository\Exception\InvalidFindByCall; use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\Utility\IdentifierFlattener; @@ -91,7 +91,7 @@ class BasicEntityPersister implements EntityPersister { /** @var array */ - private static $comparisonMap = [ + private static array $comparisonMap = [ Comparison::EQ => '= %s', Comparison::NEQ => '!= %s', Comparison::GT => '> %s', @@ -105,40 +105,22 @@ class BasicEntityPersister implements EntityPersister Comparison::ENDS_WITH => 'LIKE %s', ]; - /** - * Metadata object that describes the mapping of the mapped entity class. - * - * @var ClassMetadata - */ - protected $class; - /** * The underlying DBAL Connection of the used EntityManager. - * - * @var Connection $conn */ - protected $conn; + protected Connection $conn; /** * The database platform. - * - * @var AbstractPlatform - */ - protected $platform; - - /** - * The EntityManager instance. - * - * @var EntityManagerInterface */ - protected $em; + protected AbstractPlatform $platform; /** * Queued inserts. * * @psalm-var array */ - protected $queuedInserts = []; + protected array $queuedInserts = []; /** * The map of column names to DBAL mapping types of all prepared columns used @@ -149,7 +131,7 @@ class BasicEntityPersister implements EntityPersister * * @var mixed[] */ - protected $columnTypes = []; + protected array $columnTypes = []; /** * The map of quoted column names. @@ -159,47 +141,38 @@ class BasicEntityPersister implements EntityPersister * * @var mixed[] */ - protected $quotedColumns = []; + protected array $quotedColumns = []; /** * The INSERT SQL statement used for entities handled by this persister. * This SQL is only generated once per request, if at all. - * - * @var string|null */ - private $insertSql; + private ?string $insertSql = null; /** * The quote strategy. - * - * @var QuoteStrategy */ - protected $quoteStrategy; + protected QuoteStrategy $quoteStrategy; /** * The IdentifierFlattener used for manipulating identifiers - * - * @var IdentifierFlattener */ - private $identifierFlattener; - - /** @var CachedPersisterContext */ - protected $currentPersisterContext; - - /** @var CachedPersisterContext */ - private $limitsHandlingContext; + private IdentifierFlattener $identifierFlattener; - /** @var CachedPersisterContext */ - private $noLimitsContext; + protected CachedPersisterContext $currentPersisterContext; + private CachedPersisterContext $limitsHandlingContext; + private CachedPersisterContext $noLimitsContext; /** * Initializes a new BasicEntityPersister that uses the given EntityManager * and persists instances of the class described by the given ClassMetadata descriptor. + * + * @param ClassMetadata $class Metadata object that describes the mapping of the mapped entity class. */ - public function __construct(EntityManagerInterface $em, ClassMetadata $class) - { - $this->em = $em; - $this->class = $class; + public function __construct( + protected EntityManagerInterface $em, + protected ClassMetadata $class, + ) { $this->conn = $em->getConnection(); $this->platform = $this->conn->getDatabasePlatform(); $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); @@ -216,26 +189,17 @@ public function __construct(EntityManagerInterface $em, ClassMetadata $class) ); } - /** - * {@inheritdoc} - */ - public function getClassMetadata() + public function getClassMetadata(): ClassMetadata { return $this->class; } - /** - * {@inheritdoc} - */ - public function getResultSetMapping() + public function getResultSetMapping(): ResultSetMapping { return $this->currentPersisterContext->rsm; } - /** - * {@inheritdoc} - */ - public function addInsert($entity) + public function addInsert(object $entity): void { $this->queuedInserts[spl_object_id($entity)] = $entity; } @@ -243,7 +207,7 @@ public function addInsert($entity) /** * {@inheritdoc} */ - public function getInserts() + public function getInserts(): array { return $this->queuedInserts; } @@ -251,7 +215,7 @@ public function getInserts() /** * {@inheritdoc} */ - public function executeInserts() + public function executeInserts(): array { if (! $this->queuedInserts) { return []; @@ -305,12 +269,9 @@ public function executeInserts() * Also retrieves values of columns marked as 'non insertable' and / or * 'not updatable' and assigns them back to the entities corresponding fields. * - * @param object $entity * @param mixed[] $id - * - * @return void */ - protected function assignDefaultVersionAndUpsertableValues($entity, array $id) + protected function assignDefaultVersionAndUpsertableValues(object $entity, array $id): void { $values = $this->fetchVersionAndNotUpsertableValues($this->class, $id); @@ -325,12 +286,9 @@ protected function assignDefaultVersionAndUpsertableValues($entity, array $id) * Fetches the current version value of a versioned entity and / or the values of fields * marked as 'not insertable' and / or 'not updatable'. * - * @param ClassMetadata $versionedClass - * @param mixed[] $id - * - * @return mixed + * @param mixed[] $id */ - protected function fetchVersionAndNotUpsertableValues($versionedClass, array $id) + protected function fetchVersionAndNotUpsertableValues(ClassMetadata $versionedClass, array $id): mixed { $columnNames = []; foreach ($this->class->fieldMappings as $key => $column) { @@ -385,10 +343,7 @@ private function extractIdentifierTypes(array $id, ClassMetadata $versionedClass return $types; } - /** - * {@inheritdoc} - */ - public function update($entity) + public function update(object $entity): void { $tableName = $this->class->getTableName(); $updateData = $this->prepareUpdateData($entity); @@ -428,10 +383,10 @@ public function update($entity) * @throws OptimisticLockException */ final protected function updateTable( - $entity, - $quotedTableName, + object $entity, + string $quotedTableName, array $updateData, - $versioned = false + bool $versioned = false ): void { $set = []; $types = []; @@ -585,10 +540,7 @@ protected function deleteJoinTableRecords(array $identifier, array $types): void } } - /** - * {@inheritdoc} - */ - public function delete($entity) + public function delete(object $entity): bool { $class = $this->class; $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); @@ -625,7 +577,7 @@ public function delete($entity) * @return mixed[][] The prepared data. * @psalm-return array> */ - protected function prepareUpdateData($entity, bool $isInsert = false) + protected function prepareUpdateData(object $entity, bool $isInsert = false): array { $versionField = null; $result = []; @@ -724,15 +676,12 @@ protected function prepareUpdateData($entity, bool $isInsert = false) * @return mixed[][] The prepared data for the tables to update. * @psalm-return array */ - protected function prepareInsertData($entity) + protected function prepareInsertData(object $entity): array { return $this->prepareUpdateData($entity, true); } - /** - * {@inheritdoc} - */ - public function getOwningTable($fieldName) + public function getOwningTable(string $fieldName): string { return $this->class->getTableName(); } @@ -740,7 +689,7 @@ public function getOwningTable($fieldName) /** * {@inheritdoc} */ - public function load(array $criteria, $entity = null, $assoc = null, array $hints = [], $lockMode = null, $limit = null, ?array $orderBy = null) + public function load(array $criteria, ?object $entity = null, ?array $assoc = null, array $hints = [], ?int $lockMode = null, ?int $limit = null, ?array $orderBy = null): ?object { $this->switchPersisterContext(null, $limit); @@ -762,7 +711,7 @@ public function load(array $criteria, $entity = null, $assoc = null, array $hint /** * {@inheritdoc} */ - public function loadById(array $identifier, $entity = null) + public function loadById(array $identifier, ?object $entity = null): ?object { return $this->load($identifier, $entity); } @@ -770,7 +719,7 @@ public function loadById(array $identifier, $entity = null) /** * {@inheritdoc} */ - public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = []) + public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): ?object { $foundEntity = $this->em->getUnitOfWork()->tryGetById($identifier, $assoc['targetEntity']); if ($foundEntity !== false) { @@ -830,7 +779,7 @@ public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifie /** * {@inheritdoc} */ - public function refresh(array $id, $entity, $lockMode = null) + public function refresh(array $id, object $entity, ?int $lockMode = null): void { $sql = $this->getSelectSQL($id, null, $lockMode); [$params, $types] = $this->expandParameters($id); @@ -840,10 +789,7 @@ public function refresh(array $id, $entity, $lockMode = null) $hydrator->hydrateAll($stmt, $this->currentPersisterContext->rsm, [Query::HINT_REFRESH => true]); } - /** - * {@inheritDoc} - */ - public function count($criteria = []) + public function count(array|Criteria $criteria = []): int { $sql = $this->getCountSQL($criteria); @@ -857,7 +803,7 @@ public function count($criteria = []) /** * {@inheritdoc} */ - public function loadCriteria(Criteria $criteria) + public function loadCriteria(Criteria $criteria): array { $orderBy = $criteria->getOrderings(); $limit = $criteria->getMaxResults(); @@ -875,7 +821,7 @@ public function loadCriteria(Criteria $criteria) /** * {@inheritdoc} */ - public function expandCriteriaParameters(Criteria $criteria) + public function expandCriteriaParameters(Criteria $criteria): array { $expression = $criteria->getWhereExpression(); $sqlParams = []; @@ -906,7 +852,7 @@ public function expandCriteriaParameters(Criteria $criteria) /** * {@inheritdoc} */ - public function loadAll(array $criteria = [], ?array $orderBy = null, $limit = null, $offset = null) + public function loadAll(array $criteria = [], ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array { $this->switchPersisterContext($offset, $limit); @@ -922,7 +868,7 @@ public function loadAll(array $criteria = [], ?array $orderBy = null, $limit = n /** * {@inheritdoc} */ - public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = null, $limit = null) + public function getManyToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array { $this->switchPersisterContext($offset, $limit); @@ -980,7 +926,7 @@ private function loadCollectionFromStatement( /** * {@inheritdoc} */ - public function loadManyToManyCollection(array $assoc, $sourceEntity, PersistentCollection $collection) + public function loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): array { $stmt = $this->getManyToManyStatement($assoc, $sourceEntity); @@ -988,19 +934,16 @@ public function loadManyToManyCollection(array $assoc, $sourceEntity, Persistent } /** - * @param object $sourceEntity * @psalm-param array $assoc * - * @return Result - * * @throws MappingException */ private function getManyToManyStatement( array $assoc, - $sourceEntity, + object $sourceEntity, ?int $offset = null, ?int $limit = null - ) { + ): Result { $this->switchPersisterContext($offset, $limit); $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); @@ -1063,10 +1006,7 @@ private function getManyToManyStatement( return $this->conn->executeQuery($sql, $params, $types); } - /** - * {@inheritdoc} - */ - public function getSelectSQL($criteria, $assoc = null, $lockMode = null, $limit = null, $offset = null, ?array $orderBy = null) + public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string { $this->switchPersisterContext($offset, $limit); @@ -1125,10 +1065,7 @@ public function getSelectSQL($criteria, $assoc = null, $lockMode = null, $limit return $this->platform->modifyLimitQuery($query, $limit, $offset ?? 0) . $lockSql; } - /** - * {@inheritDoc} - */ - public function getCountSQL($criteria = []) + public function getCountSQL(array|Criteria $criteria = []): string { $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); $tableAlias = $this->getSQLTableAlias($this->class->name); @@ -1212,10 +1149,8 @@ final protected function getOrderBySQL(array $orderBy, string $baseTableAlias): * list SQL fragment. Note that in the implementation of BasicEntityPersister * the resulting SQL fragment is generated only once and cached in {@link selectColumnListSql}. * Subclasses may or may not do the same. - * - * @return string The SQL fragment. */ - protected function getSelectColumnsSQL() + protected function getSelectColumnsSQL(): string { if ($this->currentPersisterContext->selectColumnListSql !== null) { return $this->currentPersisterContext->selectColumnListSql; @@ -1331,13 +1266,9 @@ protected function getSelectColumnsSQL() /** * Gets the SQL join fragment used when selecting entities from an association. * - * @param string $field * @param mixed[] $assoc - * @param string $alias - * - * @return string */ - protected function getSelectColumnAssociationSQL($field, $assoc, ClassMetadata $class, $alias = 'r') + protected function getSelectColumnAssociationSQL(string $field, array $assoc, ClassMetadata $class, string $alias = 'r'): string { if (! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) { return ''; @@ -1366,10 +1297,8 @@ protected function getSelectColumnAssociationSQL($field, $assoc, ClassMetadata $ * many-to-many association. * * @psalm-param array $manyToMany - * - * @return string */ - protected function getSelectManyToManyJoinSQL(array $manyToMany) + protected function getSelectManyToManyJoinSQL(array $manyToMany): string { $conditions = []; $association = $manyToMany; @@ -1394,10 +1323,7 @@ protected function getSelectManyToManyJoinSQL(array $manyToMany) return ' INNER JOIN ' . $joinTableName . ' ON ' . implode(' AND ', $conditions); } - /** - * {@inheritdoc} - */ - public function getInsertSQL() + public function getInsertSQL(): string { if ($this->insertSql !== null) { return $this->insertSql; @@ -1445,10 +1371,9 @@ public function getInsertSQL() * Subclasses should override this method to alter or change the list of * columns placed in the INSERT statements used by the persister. * - * @return string[] The list of columns. * @psalm-return list */ - protected function getInsertColumnList() + protected function getInsertColumnList(): array { $columns = []; @@ -1489,14 +1414,10 @@ protected function getInsertColumnList() /** * Gets the SQL snippet of a qualified column name for the given field name. * - * @param string $field The field name. * @param ClassMetadata $class The class that declares this field. The table this class is * mapped to must own the column for the given field. - * @param string $alias - * - * @return string */ - protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') + protected function getSelectColumnSQL(string $field, ClassMetadata $class, string $alias = 'r'): string { $root = $alias === 'r' ? '' : $alias; $tableAlias = $this->getSQLTableAlias($class->name, $root); @@ -1517,14 +1438,9 @@ protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r' /** * Gets the SQL table alias for the given class name. * - * @param string $className - * @param string $assocName - * - * @return string The SQL table alias. - * * @todo Reconsider. Binding table aliases to class names is not such a good idea. */ - protected function getSQLTableAlias($className, $assocName = '') + protected function getSQLTableAlias(string $className, string $assocName = ''): string { if ($assocName) { $className .= '#' . $assocName; @@ -1544,7 +1460,7 @@ protected function getSQLTableAlias($className, $assocName = '') /** * {@inheritdoc} */ - public function lock(array $criteria, $lockMode) + public function lock(array $criteria, int $lockMode): void { $lockSql = ''; $conditionSql = $this->getSelectConditionSQL($criteria); @@ -1574,24 +1490,10 @@ public function lock(array $criteria, $lockMode) /** * Gets the FROM and optionally JOIN conditions to lock the entity managed by this persister. * - * @param int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. - * @psalm-param LockMode::*|null $lockMode - * - * @return string + * @psalm-param LockMode::* $lockMode */ - protected function getLockTablesSql($lockMode) + protected function getLockTablesSql(int $lockMode): string { - if ($lockMode === null) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9466', - 'Passing null as argument to %s is deprecated, pass LockMode::NONE instead.', - __METHOD__ - ); - - $lockMode = LockMode::NONE; - } - return $this->platform->appendLockHint( 'FROM ' . $this->quoteStrategy->getTableName($this->class, $this->platform) . ' ' @@ -1602,10 +1504,8 @@ protected function getLockTablesSql($lockMode) /** * Gets the Select Where Condition from a Criteria object. - * - * @return string */ - protected function getSelectConditionCriteriaSQL(Criteria $criteria) + protected function getSelectConditionCriteriaSQL(Criteria $criteria): string { $expression = $criteria->getWhereExpression(); @@ -1618,10 +1518,7 @@ protected function getSelectConditionCriteriaSQL(Criteria $criteria) return $visitor->dispatch($expression); } - /** - * {@inheritdoc} - */ - public function getSelectConditionStatementSQL($field, $value, $assoc = null, $comparison = null) + public function getSelectConditionStatementSQL(string $field, mixed $value, ?array $assoc = null, ?string $comparison = null): string { $selectedColumns = []; $columns = $this->getSelectConditionStatementColumnSQL($field, $assoc); @@ -1763,13 +1660,10 @@ private function getSelectConditionStatementColumnSQL( * Subclasses are supposed to override this method if they intend to change * or alter the criteria by which entities are selected. * - * @param mixed[]|null $assoc * @psalm-param array $criteria * @psalm-param array|null $assoc - * - * @return string */ - protected function getSelectConditionSQL(array $criteria, $assoc = null) + protected function getSelectConditionSQL(array $criteria, ?array $assoc = null): string { $conditions = []; @@ -1783,7 +1677,7 @@ protected function getSelectConditionSQL(array $criteria, $assoc = null) /** * {@inheritdoc} */ - public function getOneToManyCollection(array $assoc, $sourceEntity, $offset = null, $limit = null) + public function getOneToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array { $this->switchPersisterContext($offset, $limit); @@ -1795,7 +1689,7 @@ public function getOneToManyCollection(array $assoc, $sourceEntity, $offset = nu /** * {@inheritdoc} */ - public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentCollection $collection) + public function loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): mixed { $stmt = $this->getOneToManyStatement($assoc, $sourceEntity); @@ -1805,12 +1699,11 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC /** * Builds criteria and execute SQL statement to fetch the one to many entities from. * - * @param object $sourceEntity * @psalm-param array $assoc */ private function getOneToManyStatement( array $assoc, - $sourceEntity, + object $sourceEntity, ?int $offset = null, ?int $limit = null ): Result { @@ -1862,7 +1755,7 @@ private function getOneToManyStatement( /** * {@inheritdoc} */ - public function expandParameters($criteria) + public function expandParameters(array $criteria): array { $params = []; $types = []; @@ -1911,14 +1804,12 @@ private function expandToManyParameters(array $criteria): array /** * Infers field types to be used by parameter type casting. * - * @param mixed $value - * * @return int[]|null[]|string[] * @psalm-return list * * @throws QueryException */ - private function getTypes(string $field, $value, ClassMetadata $class): array + private function getTypes(string $field, mixed $value, ClassMetadata $class): array { $types = []; @@ -1965,11 +1856,9 @@ private function getTypes(string $field, $value, ClassMetadata $class): array /** * Retrieves the parameters that identifies a value. * - * @param mixed $value - * * @return mixed[] */ - private function getValues($value): array + private function getValues(mixed $value): array { if (is_array($value)) { $newValue = []; @@ -1987,11 +1876,9 @@ private function getValues($value): array /** * Retrieves an individual parameter value. * - * @param mixed $value - * * @psalm-return list */ - private function getIndividualValue($value): array + private function getIndividualValue(mixed $value): array { if (! is_object($value)) { return [$value]; @@ -2022,10 +1909,7 @@ private function getIndividualValue($value): array return [$this->em->getUnitOfWork()->getSingleIdentifierValue($value)]; } - /** - * {@inheritdoc} - */ - public function exists($entity, ?Criteria $extraConditions = null) + public function exists(object $entity, ?Criteria $extraConditions = null): bool { $criteria = $this->class->getIdentifierValues($entity); @@ -2065,7 +1949,7 @@ public function exists($entity, ?Criteria $extraConditions = null) * * @return string LEFT JOIN if one of the columns is nullable, INNER JOIN otherwise. */ - protected function getJoinSQLForJoinColumns($joinColumns) + protected function getJoinSQLForJoinColumns(array $joinColumns): string { // if one of the join columns is nullable, return left join foreach ($joinColumns as $joinColumn) { @@ -2077,12 +1961,7 @@ protected function getJoinSQLForJoinColumns($joinColumns) return 'INNER JOIN'; } - /** - * @param string $columnName - * - * @return string - */ - public function getSQLColumnAlias($columnName) + public function getSQLColumnAlias(string $columnName): string { return $this->quoteStrategy->getColumnAlias($columnName, $this->currentPersisterContext->sqlAliasCounter++, $this->platform); } @@ -2095,7 +1974,7 @@ public function getSQLColumnAlias($columnName) * * @return string The SQL query part to add to a query. */ - protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) + protected function generateFilterConditionSQL(ClassMetadata $targetEntity, string $targetTableAlias): string { $filterClauses = []; @@ -2115,13 +1994,8 @@ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targ * Switches persister context according to current query offset/limits * * This is due to the fact that to-many associations cannot be fetch-joined when a limit is involved - * - * @param int|null $offset - * @param int|null $limit - * - * @return void */ - protected function switchPersisterContext($offset, $limit) + protected function switchPersisterContext(?int $offset, ?int $limit): void { if ($offset === null && $limit === null) { $this->currentPersisterContext = $this->noLimitsContext; diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index 5274bb10fbb..ae5ba7f30cf 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -17,58 +17,44 @@ */ interface EntityPersister { - /** - * @return ClassMetadata - */ - public function getClassMetadata(); + public function getClassMetadata(): ClassMetadata; /** * Gets the ResultSetMapping used for hydration. - * - * @return ResultSetMapping */ - public function getResultSetMapping(); + public function getResultSetMapping(): ResultSetMapping; /** * Get all queued inserts. * * @return object[] */ - public function getInserts(); + public function getInserts(): array; /** * Gets the INSERT SQL used by the persister to persist a new entity. * - * @return string - * * @TODO It should not be here. * But its necessary since JoinedSubclassPersister#executeInserts invoke the root persister. */ - public function getInsertSQL(); + public function getInsertSQL(): string; /** * Gets the SELECT SQL to select one or more entities by a set of field criteria. * * @param mixed[]|Criteria $criteria * @param mixed[]|null $assoc - * @param int|null $lockMode - * @param int|null $limit - * @param int|null $offset * @param mixed[]|null $orderBy * @psalm-param LockMode::*|null $lockMode - * - * @return string */ - public function getSelectSQL($criteria, $assoc = null, $lockMode = null, $limit = null, $offset = null, ?array $orderBy = null); + public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string; /** * Get the COUNT SQL to count entities (optionally based on a criteria) * * @param mixed[]|Criteria $criteria - * - * @return string */ - public function getCountSQL($criteria = []); + public function getCountSQL(array|Criteria $criteria = []): string; /** * Expands the parameters from the given criteria and use the correct binding types if found. @@ -77,37 +63,27 @@ public function getCountSQL($criteria = []); * * @psalm-return array{list, list} */ - public function expandParameters($criteria); + public function expandParameters(array $criteria): array; /** * Expands Criteria Parameters by walking the expressions and grabbing all parameters and types from it. * * @psalm-return array{list, list} */ - public function expandCriteriaParameters(Criteria $criteria); + public function expandCriteriaParameters(Criteria $criteria): array; /** * Gets the SQL WHERE condition for matching a field with a given value. * - * @param string $field - * @param mixed $value - * @param mixed[]|null $assoc - * @param string|null $comparison * @psalm-param array|null $assoc - * - * @return string */ - public function getSelectConditionStatementSQL($field, $value, $assoc = null, $comparison = null); + public function getSelectConditionStatementSQL(string $field, mixed $value, ?array $assoc = null, ?string $comparison = null): string; /** * Adds an entity to the queued insertions. * The entity remains queued until {@link executeInserts} is invoked. - * - * @param object $entity The entity to queue for insertion. - * - * @return void */ - public function addInsert($entity); + public function addInsert(object $entity): void; /** * Executes all queued entity insertions and returns any generated post-insert @@ -122,17 +98,13 @@ public function addInsert($entity); * an empty array if the entity class does not use the * IDENTITY generation strategy. */ - public function executeInserts(); + public function executeInserts(): array; /** * Updates a managed entity. The entity is updated according to its current changeset * in the running UnitOfWork. If there is no changeset, nothing is updated. - * - * @param object $entity The entity to update. - * - * @return void */ - public function update($entity); + public function update(object $entity): void; /** * Deletes a managed entity. @@ -142,20 +114,16 @@ public function update($entity); * * Subclasses may override this method to customize the semantics of entity deletion. * - * @param object $entity The entity to delete. - * * @return bool TRUE if the entity got deleted in the database, FALSE otherwise. */ - public function delete($entity); + public function delete(object $entity): bool; /** * Count entities (optionally filtered by a criteria) * - * @param mixed[]|Criteria $criteria - * - * @return int + * @param mixed[]|Criteria $criteria */ - public function count($criteria = []); + public function count(array|Criteria $criteria = []): int; /** * Gets the name of the table that owns the column the given field is mapped to. @@ -163,12 +131,8 @@ public function count($criteria = []); * The default implementation in BasicEntityPersister always returns the name * of the table the entity type of this persister is mapped to, since an entity * is always persisted to a single table with a BasicEntityPersister. - * - * @param string $fieldName The field name. - * - * @return string The table name. */ - public function getOwningTable($fieldName); + public function getOwningTable(string $fieldName): string; /** * Loads an entity by a list of field criteria. @@ -196,13 +160,13 @@ public function getOwningTable($fieldName); */ public function load( array $criteria, - $entity = null, - $assoc = null, + ?object $entity = null, + ?array $assoc = null, array $hints = [], - $lockMode = null, - $limit = null, + ?int $lockMode = null, + ?int $limit = null, ?array $orderBy = null - ); + ): ?object; /** * Loads an entity by identifier. @@ -214,7 +178,7 @@ public function load( * * @todo Check parameters */ - public function loadById(array $identifier, $entity = null); + public function loadById(array $identifier, ?object $entity = null): ?object; /** * Loads an entity of this persister's mapped class as part of a single-valued @@ -226,16 +190,15 @@ public function loadById(array $identifier, $entity = null); * the identifier is derived from the $sourceEntity. * @psalm-param array $assoc The association to load. * - * @return object The loaded and managed entity instance or NULL if the entity can not be found. + * @return object|null The loaded and managed entity instance or NULL if the entity can not be found. * * @throws MappingException */ - public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifier = []); + public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): ?object; /** * Refreshes a managed entity. * - * @param object $entity The entity to refresh. * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants * or NULL if no specific lock mode should be used * for refreshing the managed entity. @@ -243,39 +206,34 @@ public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifie * associative array from column or * field names to values. * @psalm-param LockMode::*|null $lockMode - * - * @return void */ - public function refresh(array $id, $entity, $lockMode = null); + public function refresh(array $id, object $entity, ?int $lockMode = null): void; /** * Loads Entities matching the given Criteria object. * * @return mixed[] */ - public function loadCriteria(Criteria $criteria); + public function loadCriteria(Criteria $criteria): array; /** * Loads a list of entities by a list of field criteria. * - * @param int|null $limit - * @param int|null $offset * @psalm-param array|null $orderBy * @psalm-param array $criteria + * + * @return mixed[] */ - public function loadAll(array $criteria = [], ?array $orderBy = null, $limit = null, $offset = null); + public function loadAll(array $criteria = [], ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array; /** * Gets (sliced or full) elements of the given collection. * - * @param object $sourceEntity - * @param int|null $offset - * @param int|null $limit * @psalm-param array $assoc * * @return mixed[] */ - public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = null, $limit = null); + public function getManyToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array; /** * Loads a collection of entities of a many-to-many association. @@ -286,48 +244,35 @@ public function getManyToManyCollection(array $assoc, $sourceEntity, $offset = n * * @return mixed[] */ - public function loadManyToManyCollection(array $assoc, $sourceEntity, PersistentCollection $collection); + public function loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): array; /** * Loads a collection of entities in a one-to-many association. * - * @param object $sourceEntity - * @param PersistentCollection $collection The collection to load/fill. + * @param PersistentCollection $collection The collection to load/fill. * @psalm-param array $assoc - * - * @return mixed */ - public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentCollection $collection); + public function loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): mixed; /** * Locks all rows of this entity matching the given criteria with the specified pessimistic lock mode. * - * @param int $lockMode One of the Doctrine\DBAL\LockMode::* constants. * @psalm-param array $criteria * @psalm-param LockMode::* $lockMode - * - * @return void */ - public function lock(array $criteria, $lockMode); + public function lock(array $criteria, int $lockMode): void; /** * Returns an array with (sliced or full list) of elements in the specified collection. * - * @param object $sourceEntity - * @param int|null $offset - * @param int|null $limit * @psalm-param array $assoc * * @return mixed[] */ - public function getOneToManyCollection(array $assoc, $sourceEntity, $offset = null, $limit = null); + public function getOneToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array; /** * Checks whether the given managed entity exists in the database. - * - * @param object $entity - * - * @return bool TRUE if the entity exists in the database, FALSE otherwise. */ - public function exists($entity, ?Criteria $extraConditions = null); + public function exists(object $entity, ?Criteria $extraConditions = null): bool; } diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index cba558216dc..71d3161089d 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -31,19 +31,16 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister * * @psalm-var array */ - private $owningTableMap = []; + private array $owningTableMap = []; /** * Map of table to quoted table names. * * @psalm-var array */ - private $quotedTableMap = []; + private array $quotedTableMap = []; - /** - * {@inheritdoc} - */ - protected function getDiscriminatorColumnTableName() + protected function getDiscriminatorColumnTableName(): string { $class = $this->class->name !== $this->class->rootEntityName ? $this->em->getClassMetadata($this->class->rootEntityName) @@ -70,31 +67,21 @@ private function getVersionedClassMetadata(): ClassMetadata /** * Gets the name of the table that owns the column the given field is mapped to. * - * @param string $fieldName - * - * @return string - * * @override */ - public function getOwningTable($fieldName) + public function getOwningTable(string $fieldName): string { if (isset($this->owningTableMap[$fieldName])) { return $this->owningTableMap[$fieldName]; } - switch (true) { - case isset($this->class->associationMappings[$fieldName]['inherited']): - $cm = $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']); - break; - - case isset($this->class->fieldMappings[$fieldName]['inherited']): - $cm = $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]['inherited']); - break; - - default: - $cm = $this->class; - break; - } + $cm = match (true) { + isset($this->class->associationMappings[$fieldName]['inherited']) + => $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']), + isset($this->class->fieldMappings[$fieldName]['inherited']) + => $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]['inherited']), + default => $this->class, + }; $tableName = $cm->getTableName(); $quotedTableName = $this->quoteStrategy->getTableName($cm, $this->platform); @@ -108,7 +95,7 @@ public function getOwningTable($fieldName) /** * {@inheritdoc} */ - public function executeInserts() + public function executeInserts(): array { if (! $this->queuedInserts) { return []; @@ -200,10 +187,7 @@ public function executeInserts() return $postInsertIds; } - /** - * {@inheritdoc} - */ - public function update($entity) + public function update(object $entity): void { $updateData = $this->prepareUpdateData($entity); @@ -238,10 +222,7 @@ public function update($entity) } } - /** - * {@inheritdoc} - */ - public function delete($entity) + public function delete(object $entity): bool { $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); $id = array_combine($this->class->getIdentifierColumnNames(), $identifier); @@ -276,10 +257,7 @@ public function delete($entity) return (bool) $affectedRows; } - /** - * {@inheritdoc} - */ - public function getSelectSQL($criteria, $assoc = null, $lockMode = null, $limit = null, $offset = null, ?array $orderBy = null) + public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string { $this->switchPersisterContext($offset, $limit); @@ -343,10 +321,7 @@ public function getSelectSQL($criteria, $assoc = null, $lockMode = null, $limit return $this->platform->modifyLimitQuery($query, $limit, $offset ?? 0) . $lockSql; } - /** - * {@inheritDoc} - */ - public function getCountSQL($criteria = []) + public function getCountSQL(array|Criteria $criteria = []): string { $tableName = $this->quoteStrategy->getTableName($this->class, $this->platform); $baseTableAlias = $this->getSQLTableAlias($this->class->name); @@ -370,10 +345,7 @@ public function getCountSQL($criteria = []) . (empty($conditionSql) ? '' : ' WHERE ' . $conditionSql); } - /** - * {@inheritdoc} - */ - protected function getLockTablesSql($lockMode) + protected function getLockTablesSql(int $lockMode): string { $joinSql = ''; $identifierColumns = $this->class->getIdentifierColumnNames(); @@ -398,10 +370,8 @@ protected function getLockTablesSql($lockMode) /** * Ensure this method is never called. This persister overrides getSelectEntitiesSQL directly. - * - * @return string */ - protected function getSelectColumnsSQL() + protected function getSelectColumnsSQL(): string { // Create the column list fragment only once if ($this->currentPersisterContext->selectColumnListSql !== null) { @@ -502,7 +472,7 @@ protected function getSelectColumnsSQL() /** * {@inheritdoc} */ - protected function getInsertColumnList() + protected function getInsertColumnList(): array { // Identifier columns must always come first in the column list of subclasses. $columns = $this->class->parentClasses @@ -547,7 +517,7 @@ protected function getInsertColumnList() /** * {@inheritdoc} */ - protected function assignDefaultVersionAndUpsertableValues($entity, array $id) + protected function assignDefaultVersionAndUpsertableValues(object $entity, array $id): void { $values = $this->fetchVersionAndNotUpsertableValues($this->getVersionedClassMetadata(), $id); diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index b9f95c58123..bc9becac1cb 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -22,18 +22,12 @@ class SingleTablePersister extends AbstractEntityInheritancePersister { use SQLResultCasing; - /** - * {@inheritdoc} - */ - protected function getDiscriminatorColumnTableName() + protected function getDiscriminatorColumnTableName(): string { return $this->class->getTableName(); } - /** - * {@inheritdoc} - */ - protected function getSelectColumnsSQL() + protected function getSelectColumnsSQL(): string { if ($this->currentPersisterContext->selectColumnListSql !== null) { return $this->currentPersisterContext->selectColumnListSql; @@ -96,7 +90,7 @@ protected function getSelectColumnsSQL() /** * {@inheritdoc} */ - protected function getInsertColumnList() + protected function getInsertColumnList(): array { $columns = parent::getInsertColumnList(); @@ -106,10 +100,7 @@ protected function getInsertColumnList() return $columns; } - /** - * {@inheritdoc} - */ - protected function getSQLTableAlias($className, $assocName = '') + protected function getSQLTableAlias(string $className, string $assocName = ''): string { return parent::getSQLTableAlias($this->class->rootEntityName, $assocName); } @@ -117,7 +108,7 @@ protected function getSQLTableAlias($className, $assocName = '') /** * {@inheritdoc} */ - protected function getSelectConditionSQL(array $criteria, $assoc = null) + protected function getSelectConditionSQL(array $criteria, ?array $assoc = null): string { $conditionSql = parent::getSelectConditionSQL($criteria, $assoc); @@ -128,10 +119,7 @@ protected function getSelectConditionSQL(array $criteria, $assoc = null) return $conditionSql . $this->getSelectConditionDiscriminatorValueSQL(); } - /** - * {@inheritdoc} - */ - protected function getSelectConditionCriteriaSQL(Criteria $criteria) + protected function getSelectConditionCriteriaSQL(Criteria $criteria): string { $conditionSql = parent::getSelectConditionCriteriaSQL($criteria); @@ -142,10 +130,7 @@ protected function getSelectConditionCriteriaSQL(Criteria $criteria) return $conditionSql . $this->getSelectConditionDiscriminatorValueSQL(); } - /** - * @return string - */ - protected function getSelectConditionDiscriminatorValueSQL() + protected function getSelectConditionDiscriminatorValueSQL(): string { $values = []; @@ -167,10 +152,7 @@ protected function getSelectConditionDiscriminatorValueSQL() return $tableAlias . '.' . $discColumnName . ' IN (' . $values . ')'; } - /** - * {@inheritdoc} - */ - protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) + protected function generateFilterConditionSQL(ClassMetadata $targetEntity, string $targetTableAlias): string { // Ensure that the filters are applied to the root entity of the inheritance tree $targetEntity = $this->em->getClassMetadata($targetEntity->rootEntityName); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0cc7a0f44d7..7b269f6e016 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -45,11 +45,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php - - - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" - count: 1 - path: lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php - - message: "#^Parameter \\#2 \\$key of method Doctrine\\\\ORM\\\\Cache\\\\EntityHydrator\\:\\:buildCacheEntry\\(\\) expects Doctrine\\\\ORM\\\\Cache\\\\EntityCacheKey, Doctrine\\\\ORM\\\\Cache\\\\CacheKey given\\.$#" count: 1 @@ -470,11 +465,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/PersistentCollection.php - - - message: "#^Method Doctrine\\\\ORM\\\\Persisters\\\\Collection\\\\OneToManyPersister\\:\\:delete\\(\\) should return int\\|null but empty return statement found\\.$#" - count: 1 - path: lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php - - message: "#^Parameter \\#3 \\$hints of method Doctrine\\\\ORM\\\\Internal\\\\Hydration\\\\AbstractHydrator\\:\\:hydrateAll\\(\\) expects array\\, array\\ given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 3cbd9031a0b..323a0ed4697 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -153,9 +153,6 @@ $cacheEntry - - loadAll - $cacheEntry->class @@ -1125,9 +1122,6 @@ - - int|null - $collection->getOwner() $collection->getOwner() @@ -1171,9 +1165,6 @@ $em->getMetadataFactory() $hints - - loadOneToOneEntity - $hints [Query::HINT_REFRESH => true] @@ -1185,18 +1176,11 @@ [$params, $types] [$sqlParams, $sqlTypes] - - loadAll - - executeInserts - expandCriteriaParameters - expandParameters + array + array + array - - $targetEntity - $targetEntity - $association $type @@ -1228,17 +1212,12 @@ (bool) $handlesLimits - - - loadAll - - $postInsertIds - executeInserts + array diff --git a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php b/tests/Doctrine/Performance/Mock/NonLoadingPersister.php index 55eef56bf27..2692be5a1a3 100644 --- a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php +++ b/tests/Doctrine/Performance/Mock/NonLoadingPersister.php @@ -20,13 +20,13 @@ public function __construct() */ public function load( array $criteria, - $entity = null, - $assoc = null, + ?object $entity = null, + ?array $assoc = null, array $hints = [], - $lockMode = null, - $limit = null, + ?int $lockMode = null, + ?int $limit = null, ?array $orderBy = null - ) { + ): ?object { return $entity; } } diff --git a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php index 990ca1a2b53..a4383f2936b 100644 --- a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php @@ -13,28 +13,18 @@ */ class EntityPersisterMock extends BasicEntityPersister { - /** @var array */ - private $inserts = []; - - /** @var array */ - private $updates = []; - - /** @var array */ - private $deletes = []; - - /** @var int */ - private $identityColumnValueCounter = 0; - - /** @var int|null */ - private $mockIdGeneratorType; + private array $inserts = []; + private array $updates = []; + private array $deletes = []; + private int $identityColumnValueCounter = 0; + private ?int $mockIdGeneratorType = null; /** @psalm-var list */ - private $postInsertIds = []; + private array $postInsertIds = []; - /** @var bool */ - private $existsCalled = false; + private bool $existsCalled = false; - public function addInsert($entity): void + public function addInsert(object $entity): void { $this->inserts[] = $entity; if ($this->mockIdGeneratorType !== ClassMetadata::GENERATOR_TYPE_IDENTITY && ! $this->class->isIdGeneratorIdentity()) { @@ -61,28 +51,19 @@ public function setMockIdGeneratorType(int $genType): void $this->mockIdGeneratorType = $genType; } - /** - * {@inheritdoc} - */ - public function update($entity): void + public function update(object $entity): void { $this->updates[] = $entity; } - /** - * {@inheritdoc} - */ - public function exists($entity, ?Criteria $extraConditions = null): bool + public function exists(object $entity, ?Criteria $extraConditions = null): bool { $this->existsCalled = true; return false; } - /** - * {@inheritdoc} - */ - public function delete($entity): bool + public function delete(object $entity): bool { $this->deletes[] = $entity; diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php index e3a828744eb..07acaf71427 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php @@ -23,13 +23,12 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase { /** @var Region&MockObject */ - protected $region; + protected Region $region; /** @var CollectionPersister&MockObject */ - protected $collectionPersister; + protected CollectionPersister $collectionPersister; - /** @var EntityManagerMock */ - protected $em; + protected EntityManagerMock $em; abstract protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister; diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php index 6e014627533..7c3a369d026 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php @@ -15,9 +15,6 @@ */ class NonStrictReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersisterTest { - /** - * {@inheritdoc} - */ protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister { return new NonStrictReadWriteCachedCollectionPersister($persister, $region, $em, $mapping); diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index 8097d94f073..104c208fe5b 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -13,6 +13,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\Tests\Models\Cache\State; +use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; /** @@ -25,7 +26,10 @@ protected function createPersister(EntityManagerInterface $em, CollectionPersist return new ReadWriteCachedCollectionPersister($persister, $region, $em, $mapping); } - protected function createRegion(): Region + /** + * @return ConcurrentRegion&MockObject + */ + protected function createRegion(): ConcurrentRegion { return $this->createMock(ConcurrentRegion::class); } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php index 9b02918e2d5..a1c32640dd3 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php @@ -26,13 +26,12 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase { /** @var Region&MockObject */ - protected $region; + protected Region $region; /** @var EntityPersister&MockObject */ - protected $entityPersister; + protected EntityPersister $entityPersister; - /** @var EntityManagerMock */ - protected $em; + protected EntityManagerMock $em; abstract protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister; diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php index 39ae6fa5ae3..3f2d0abd8c2 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php @@ -14,11 +14,8 @@ class BasicEntityPersisterCompositeTypeParametersTest extends OrmTestCase { - /** @var BasicEntityPersister */ - protected $persister; - - /** @var EntityManagerMock */ - protected $entityManager; + protected BasicEntityPersister $persister; + protected EntityManagerMock $entityManager; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php index c55fc26715c..4dafeda7f8d 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php @@ -13,11 +13,8 @@ class BasicEntityPersisterCompositeTypeSqlTest extends OrmTestCase { - /** @var BasicEntityPersister */ - protected $persister; - - /** @var EntityManagerMock */ - protected $entityManager; + protected BasicEntityPersister $persister; + protected EntityManagerMock $entityManager; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index 78440c83b01..402544af550 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -21,11 +21,8 @@ class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase { - /** @var BasicEntityPersister */ - protected $persister; - - /** @var EntityManagerMock */ - protected $entityManager; + protected BasicEntityPersister $persister; + protected EntityManagerMock $entityManager; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php index d0a6f99a322..11ea6b52872 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php @@ -16,11 +16,8 @@ */ class JoinedSubclassPersisterTest extends OrmTestCase { - /** @var JoinedSubclassPersister */ - protected $persister; - - /** @var EntityManagerMock */ - protected $em; + protected JoinedSubclassPersister $persister; + protected EntityManagerMock $em; protected function setUp(): void { From 954439af645c5f99d3ec9aa4b221d2c8cb049cc3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 11 Feb 2022 21:09:32 +0100 Subject: [PATCH 050/475] Remove quoting methods from ClassMetadata (#9500) --- UPGRADE.md | 10 +++ .../ORM/Mapping/ClassMetadataInfo.php | 90 ------------------- psalm-baseline.xml | 3 +- 3 files changed, 11 insertions(+), 92 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 5b84d48a366..d7c5d5b8949 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade to 3.0 +## BC BREAK: Remove quoting methods from `ClassMetadata` + +The following methods have been removed from the class metadata because +quoting is handled by implementations of `Doctrine\ORM\Mapping\QuoteStrategy`: + +* `getQuotedIdentifierColumnNames()` +* `getQuotedColumnName()` +* `getQuotedTableName()` +* `getQuotedJoinTableName()` + ## BC BREAK: Remove ability to merge detached entities Merge semantics was a poor fit for the PHP "share-nothing" architecture. diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index bf7bf203e55..475f92958a0 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -3253,96 +3253,6 @@ public function getName() return $this->name; } - /** - * Gets the (possibly quoted) identifier column names for safe use in an SQL statement. - * - * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy - * - * @param AbstractPlatform $platform - * - * @return string[] - * @psalm-return list - */ - public function getQuotedIdentifierColumnNames($platform) - { - $quotedColumnNames = []; - - foreach ($this->identifier as $idProperty) { - if (isset($this->fieldMappings[$idProperty])) { - $quotedColumnNames[] = isset($this->fieldMappings[$idProperty]['quoted']) - ? $platform->quoteIdentifier($this->fieldMappings[$idProperty]['columnName']) - : $this->fieldMappings[$idProperty]['columnName']; - - continue; - } - - // Association defined as Id field - $joinColumns = $this->associationMappings[$idProperty]['joinColumns']; - $assocQuotedColumnNames = array_map( - static function ($joinColumn) use ($platform) { - return isset($joinColumn['quoted']) - ? $platform->quoteIdentifier($joinColumn['name']) - : $joinColumn['name']; - }, - $joinColumns - ); - - $quotedColumnNames = array_merge($quotedColumnNames, $assocQuotedColumnNames); - } - - return $quotedColumnNames; - } - - /** - * Gets the (possibly quoted) column name of a mapped field for safe use in an SQL statement. - * - * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy - * - * @param string $field - * @param AbstractPlatform $platform - * - * @return string - */ - public function getQuotedColumnName($field, $platform) - { - return isset($this->fieldMappings[$field]['quoted']) - ? $platform->quoteIdentifier($this->fieldMappings[$field]['columnName']) - : $this->fieldMappings[$field]['columnName']; - } - - /** - * Gets the (possibly quoted) primary table name of this class for safe use in an SQL statement. - * - * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy - * - * @param AbstractPlatform $platform - * - * @return string - */ - public function getQuotedTableName($platform) - { - return isset($this->table['quoted']) - ? $platform->quoteIdentifier($this->table['name']) - : $this->table['name']; - } - - /** - * Gets the (possibly quoted) name of the join table. - * - * @deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy - * - * @param mixed[] $assoc - * @param AbstractPlatform $platform - * - * @return string - */ - public function getQuotedJoinTableName(array $assoc, $platform) - { - return isset($assoc['joinTable']['quoted']) - ? $platform->quoteIdentifier($assoc['joinTable']['name']) - : $assoc['joinTable']['name']; - } - /** * {@inheritDoc} */ diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 323a0ed4697..7df513250a9 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -536,8 +536,7 @@ $className $this->namespace . '\\' . $className - - $joinColumn + $joinColumn From 3a9cc3d2586ba464302365fe2dbc70c08a13d000 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 16 Feb 2022 09:19:54 +0100 Subject: [PATCH 051/475] Remove TreeWalkerChainIterator (#9520) --- UPGRADE.md | 4 + .../ORM/Query/TreeWalkerChainIterator.php | 165 ------------------ phpstan-baseline.neon | 5 - psalm-baseline.xml | 16 -- 4 files changed, 4 insertions(+), 186 deletions(-) delete mode 100644 lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php diff --git a/UPGRADE.md b/UPGRADE.md index 6145e8ecc79..f85e1af28de 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: `Doctrine\ORM\Query\TreeWalkerChainIterator` + +This class has been removed without replacement. + ## BC BREAK: Remove quoting methods from `ClassMetadata` The following methods have been removed from the class metadata because diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php b/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php deleted file mode 100644 index 117628724b6..00000000000 --- a/lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php +++ /dev/null @@ -1,165 +0,0 @@ - - * @template-implements ArrayAccess - */ -class TreeWalkerChainIterator implements Iterator, ArrayAccess -{ - /** @var class-string[] */ - private $walkers = []; - /** @var TreeWalkerChain */ - private $treeWalkerChain; - /** @var AbstractQuery */ - private $query; - /** @var ParserResult */ - private $parserResult; - - /** - * @param AbstractQuery $query - * @param ParserResult $parserResult - */ - public function __construct(TreeWalkerChain $treeWalkerChain, $query, $parserResult) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9511', - '%s is deprecated and will be removed without replacement.', - self::class - ); - - $this->treeWalkerChain = $treeWalkerChain; - $this->query = $query; - $this->parserResult = $parserResult; - } - - /** - * @return string|false - * @psalm-return class-string|false - */ - #[ReturnTypeWillChange] - public function rewind() - { - return reset($this->walkers); - } - - /** - * @return TreeWalker|null - */ - #[ReturnTypeWillChange] - public function current() - { - return $this->offsetGet(key($this->walkers)); - } - - /** - * @return int - */ - #[ReturnTypeWillChange] - public function key() - { - return key($this->walkers); - } - - /** - * @return TreeWalker|null - */ - #[ReturnTypeWillChange] - public function next() - { - next($this->walkers); - - return $this->offsetGet(key($this->walkers)); - } - - /** - * {@inheritdoc} - * - * @return bool - */ - #[ReturnTypeWillChange] - public function valid() - { - return key($this->walkers) !== null; - } - - /** - * @param mixed $offset - * @psalm-param array-key|null $offset - * - * @return bool - */ - #[ReturnTypeWillChange] - public function offsetExists($offset) - { - return isset($this->walkers[$offset ?? '']); - } - - /** - * @param mixed $offset - * @psalm-param array-key|null $offset - * - * @return TreeWalker|null - */ - #[ReturnTypeWillChange] - public function offsetGet($offset) - { - if ($this->offsetExists($offset)) { - return new $this->walkers[$offset]( - $this->query, - $this->parserResult, - $this->treeWalkerChain->getQueryComponents() - ); - } - - return null; - } - - /** - * {@inheritdoc} - * - * @param string $value - * @psalm-param array-key|null $offset - * - * @return void - */ - #[ReturnTypeWillChange] - public function offsetSet($offset, $value) - { - if ($offset === null) { - $this->walkers[] = $value; - } else { - $this->walkers[$offset] = $value; - } - } - - /** - * @param mixed $offset - * @psalm-param array-key|null $offset - * - * @return void - */ - #[ReturnTypeWillChange] - public function offsetUnset($offset) - { - if ($this->offsetExists($offset)) { - unset($this->walkers[$offset ?? '']); - } - } -} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5e41948272b..678c5281770 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1255,11 +1255,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - - message: "#^Parameter \\#2 \\$value \\(string\\) of method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChainIterator\\:\\:offsetSet\\(\\) should be compatible with parameter \\$value \\(Doctrine\\\\ORM\\\\Query\\\\TreeWalker\\) of method ArrayAccess\\\\:\\:offsetSet\\(\\)$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChainIterator.php - - message: "#^Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:add\\(\\) expects array\\<'join'\\|int, array\\\\|string\\>\\|object\\|string, non\\-empty\\-array\\ given\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ef45d3cc355..d1c4abb07fb 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2418,22 +2418,6 @@ $condPrimary - - - $value - - - TreeWalker|null - class-string<TreeWalker>|false - - - $this->walkers - - - $this->walkers - $this->walkers - - [$rootAlias => $join] From 6b33fa6ddd2e7006e2a16bbfe55f7c35ef0394c1 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 17 Feb 2022 23:38:31 +0100 Subject: [PATCH 052/475] Add native types to EntityRepository (#9515) --- lib/Doctrine/ORM/EntityRepository.php | 129 ++++++------------ phpstan-baseline.neon | 1 - psalm-baseline.xml | 16 +-- .../DefaultRepositoryFactoryTest.php | 16 ++- 4 files changed, 55 insertions(+), 107 deletions(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 2a2701ef1cc..40bfa52caaf 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -35,65 +35,39 @@ */ class EntityRepository implements ObjectRepository, Selectable { - /** - * @internal This property will be private in 3.0, call {@see getEntityName()} instead. - * - * @var string - */ - protected $_entityName; - - /** - * @internal This property will be private in 3.0, call {@see getEntityManager()} instead. - * - * @var EntityManagerInterface - */ - protected $_em; + /** @psalm-var class-string */ + private string $entityName; + private static ?Inflector $inflector = null; /** - * @internal This property will be private in 3.0, call {@see getClassMetadata()} instead. - * - * @var ClassMetadata + * @psalm-param ClassMetadata $class */ - protected $_class; - - /** @var Inflector|null */ - private static $inflector; - - public function __construct(EntityManagerInterface $em, ClassMetadata $class) - { - $this->_entityName = $class->name; - $this->_em = $em; - $this->_class = $class; + public function __construct( + private EntityManagerInterface $em, + private ClassMetadata $class + ) { + $this->entityName = $class->name; } /** * Creates a new QueryBuilder instance that is prepopulated for this entity name. - * - * @param string $alias - * @param string|null $indexBy The index for the from. - * - * @return QueryBuilder */ - public function createQueryBuilder($alias, $indexBy = null) + public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder { - return $this->_em->createQueryBuilder() + return $this->em->createQueryBuilder() ->select($alias) - ->from($this->_entityName, $alias, $indexBy); + ->from($this->entityName, $alias, $indexBy); } /** * Creates a new result set mapping builder for this entity. * * The column naming strategy is "INCREMENT". - * - * @param string $alias - * - * @return ResultSetMappingBuilder */ - public function createResultSetMappingBuilder($alias) + public function createResultSetMappingBuilder(string $alias): ResultSetMappingBuilder { - $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); - $rsm->addRootEntityFromClassMetadata($this->_entityName, $alias); + $rsm = new ResultSetMappingBuilder($this->em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); + $rsm->addRootEntityFromClassMetadata($this->entityName, $alias); return $rsm; } @@ -101,19 +75,17 @@ public function createResultSetMappingBuilder($alias) /** * Finds an entity by its primary key / identifier. * - * @param mixed $id The identifier. - * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants - * or NULL if no specific lock mode should be used - * during the search. - * @param int|null $lockVersion The lock version. + * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * during the search. * @psalm-param LockMode::*|null $lockMode * * @return object|null The entity instance or NULL if the entity can not be found. * @psalm-return ?T */ - public function find($id, $lockMode = null, $lockVersion = null) + public function find(mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object { - return $this->_em->find($this->_entityName, $id, $lockMode, $lockVersion); + return $this->em->find($this->entityName, $id, $lockMode, $lockVersion); } /** @@ -121,7 +93,7 @@ public function find($id, $lockMode = null, $lockVersion = null) * * @psalm-return list The entities. */ - public function findAll() + public function findAll(): array { return $this->findBy([]); } @@ -137,9 +109,9 @@ public function findAll() * @return object[] The objects. * @psalm-return list */ - public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array { - $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName); + $persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName); return $persister->loadAll($criteria, $orderBy, $limit, $offset); } @@ -153,9 +125,9 @@ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $ * @return object|null The entity instance or NULL if the entity can not be found. * @psalm-return ?T */ - public function findOneBy(array $criteria, ?array $orderBy = null) + public function findOneBy(array $criteria, ?array $orderBy = null): ?object { - $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName); + $persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName); return $persister->load($criteria, null, null, [], null, 1, $orderBy); } @@ -169,23 +141,20 @@ public function findOneBy(array $criteria, ?array $orderBy = null) * * @todo Add this method to `ObjectRepository` interface in the next major release */ - public function count(array $criteria = []) + public function count(array $criteria = []): int { - return $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName)->count($criteria); + return $this->em->getUnitOfWork()->getEntityPersister($this->entityName)->count($criteria); } /** * Adds support for magic method calls. * - * @param string $method * @param mixed[] $arguments * @psalm-param list $arguments * - * @return mixed The returned value from the resolved method. - * * @throws BadMethodCallException If the method called is invalid. */ - public function __call($method, $arguments) + public function __call(string $method, array $arguments): mixed { if (str_starts_with($method, 'findBy')) { return $this->resolveMagicCall('findBy', substr($method, 6), $arguments); @@ -207,47 +176,37 @@ public function __call($method, $arguments) } /** - * @return string + * @psalm-return class-string */ - protected function getEntityName() + protected function getEntityName(): string { - return $this->_entityName; + return $this->entityName; } - /** - * @return string - */ - public function getClassName() + public function getClassName(): string { return $this->getEntityName(); } - /** - * @return EntityManagerInterface - */ - protected function getEntityManager() + protected function getEntityManager(): EntityManagerInterface { - return $this->_em; + return $this->em; } - /** - * @return ClassMetadata - */ - protected function getClassMetadata() + protected function getClassMetadata(): ClassMetadata { - return $this->_class; + return $this->class; } /** * Select all elements from a selectable that match the expression and * return a new collection containing these elements. * - * @return AbstractLazyCollection * @psalm-return AbstractLazyCollection&Selectable */ - public function matching(Criteria $criteria) + public function matching(Criteria $criteria): AbstractLazyCollection { - $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName); + $persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName); return new LazyCriteriaCollection($persister, $criteria); } @@ -259,26 +218,22 @@ public function matching(Criteria $criteria) * @param string $by The property name used as condition * @psalm-param list $arguments The arguments to pass at method call * - * @return mixed - * * @throws InvalidMagicMethodCall If the method called is invalid or the * requested field/association does not exist. */ - private function resolveMagicCall(string $method, string $by, array $arguments) + private function resolveMagicCall(string $method, string $by, array $arguments): mixed { if (! $arguments) { throw InvalidMagicMethodCall::onMissingParameter($method . $by); } - if (self::$inflector === null) { - self::$inflector = InflectorFactory::create()->build(); - } + self::$inflector ??= InflectorFactory::create()->build(); $fieldName = lcfirst(self::$inflector->classify($by)); - if (! ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName))) { + if (! ($this->class->hasField($fieldName) || $this->class->hasAssociation($fieldName))) { throw InvalidMagicMethodCall::becauseFieldNotFoundIn( - $this->_entityName, + $this->entityName, $fieldName, $method . $by ); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 678c5281770..8ecb8e8c3ce 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1369,4 +1369,3 @@ parameters: message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#" count: 1 path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d1c4abb07fb..9e222a114ec 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -288,26 +288,14 @@ - - $this->_entityName - $this->_entityName - $this->_entityName - $this->_entityName - $this->_entityName - - + $persister->load($criteria, null, null, [], null, 1, $orderBy) - $this->_em->find($this->_entityName, $id, $lockMode, $lockVersion) new LazyCriteriaCollection($persister, $criteria) - - ?T + ?T AbstractLazyCollection<int, T>&Selectable<int, T> - - string - diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index 052d9b8511c..880a0f2dfed 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Repository\DefaultRepositoryFactory; use Doctrine\Tests\Models\DDC753\DDC753DefaultRepository; +use Doctrine\Tests\Models\DDC753\DDC753EntityWithDefaultCustomRepository; use Doctrine\Tests\Models\DDC869\DDC869PaymentRepository; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -22,13 +23,12 @@ class DefaultRepositoryFactoryTest extends TestCase { /** @var EntityManagerInterface&MockObject */ - private $entityManager; + private EntityManagerInterface $entityManager; /** @var Configuration&MockObject */ - private $configuration; + private Configuration $configuration; - /** @var DefaultRepositoryFactory */ - private $repositoryFactory; + private DefaultRepositoryFactory $repositoryFactory; protected function setUp(): void { @@ -70,7 +70,7 @@ public function testCreatedRepositoriesAreCached(): void public function testCreatesRepositoryFromCustomClassMetadata(): void { - $customMetadata = $this->buildClassMetadata(__DIR__); + $customMetadata = $this->buildClassMetadata(DDC753EntityWithDefaultCustomRepository::class); $customMetadata->customRepositoryClassName = DDC753DefaultRepository::class; $this->entityManager @@ -107,12 +107,18 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void } /** + * @psalm-param class-string $className + * * @return ClassMetadata&MockObject + * @psalm-return ClassMetadata&MockObject + * + * @template TEntity of object */ private function buildClassMetadata(string $className): ClassMetadata { $metadata = $this->createMock(ClassMetadata::class); $metadata->expects(self::any())->method('getName')->will(self::returnValue($className)); + $metadata->name = $className; $metadata->customRepositoryClassName = null; From 597460d5ea40989cf6b54cc0000d04b6b1f88f3c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 22 Feb 2022 00:47:00 +0100 Subject: [PATCH 053/475] Add native types to caches (#9508) --- UPGRADE.md | 9 ++ lib/Doctrine/ORM/Cache.php | 86 ++----------- .../ORM/Cache/AssociationCacheEntry.php | 12 +- lib/Doctrine/ORM/Cache/CacheConfiguration.php | 71 +++------- lib/Doctrine/ORM/Cache/CacheException.php | 40 +----- lib/Doctrine/ORM/Cache/CacheFactory.php | 38 ++---- lib/Doctrine/ORM/Cache/CacheKey.php | 3 +- .../ORM/Cache/CollectionCacheEntry.php | 6 +- lib/Doctrine/ORM/Cache/CollectionCacheKey.php | 16 +-- lib/Doctrine/ORM/Cache/CollectionHydrator.php | 8 +- lib/Doctrine/ORM/Cache/DefaultCache.php | 121 ++++-------------- .../ORM/Cache/DefaultCacheFactory.php | 57 +++------ .../ORM/Cache/DefaultCollectionHydrator.php | 25 ++-- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 83 ++++-------- lib/Doctrine/ORM/Cache/EntityCacheEntry.php | 16 +-- lib/Doctrine/ORM/Cache/EntityCacheKey.php | 7 +- lib/Doctrine/ORM/Cache/Lock.php | 20 +-- .../AbstractCollectionPersister.php | 49 ------- lib/Doctrine/ORM/Cache/QueryCache.php | 17 +-- lib/Doctrine/ORM/Cache/QueryCacheEntry.php | 12 +- lib/Doctrine/ORM/Cache/QueryCacheKey.php | 13 +- .../ORM/Cache/QueryCacheValidator.php | 4 +- .../ORM/Cache/Region/DefaultRegion.php | 14 +- .../ORM/Cache/Region/FileLockRegion.php | 10 +- .../ORM/Cache/RegionsConfiguration.php | 84 +++--------- .../ORM/Cache/TimestampCacheEntry.php | 18 +-- lib/Doctrine/ORM/Cache/TimestampCacheKey.php | 4 +- .../Cache/TimestampQueryCacheValidator.php | 8 +- psalm-baseline.xml | 32 +---- .../Tests/ORM/Cache/AbstractRegionTest.php | 11 +- .../Tests/ORM/Cache/CacheConfigTest.php | 3 +- .../ORM/Cache/DefaultCacheFactoryTest.php | 11 +- .../Tests/ORM/Cache/DefaultCacheTest.php | 7 +- .../Cache/DefaultCollectionHydratorTest.php | 3 +- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 27 ++-- .../Tests/ORM/Cache/DefaultRegionTest.php | 3 +- .../Tests/ORM/Cache/FileLockRegionTest.php | 7 +- .../SecondLevelCacheAbstractTest.php | 23 ++-- .../SecondLevelCacheConcurrentTest.php | 7 +- 39 files changed, 238 insertions(+), 747 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index f85e1af28de..31966567bde 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,14 @@ # Upgrade to 3.0 +## BC BREAK: Remove helper methods from `AbstractCollectionPersister` + +The following protected methods of +`Doctrine\ORM\Cache\Persister\Collection\AbstractCollectionPersister` +have been removed. + +* `evictCollectionCache()` +* `evictElementCache()` + ## BC BREAK: `Doctrine\ORM\Query\TreeWalkerChainIterator` This class has been removed without replacement. diff --git a/lib/Doctrine/ORM/Cache.php b/lib/Doctrine/ORM/Cache.php index 52c3903a0bb..6e34f747839 100644 --- a/lib/Doctrine/ORM/Cache.php +++ b/lib/Doctrine/ORM/Cache.php @@ -38,127 +38,69 @@ interface Cache */ public const MODE_REFRESH = 4; - /** - * @param string $className The entity class. - * - * @return Region|null - */ - public function getEntityCacheRegion($className); + public function getEntityCacheRegion(string $className): ?Region; - /** - * @param string $className The entity class. - * @param string $association The field name that represents the association. - * - * @return Region|null - */ - public function getCollectionCacheRegion($className, $association); + public function getCollectionCacheRegion(string $className, string $association): ?Region; /** * Determine whether the cache contains data for the given entity "instance". - * - * @param string $className The entity class. - * @param mixed $identifier The entity identifier - * - * @return bool true if the underlying cache contains corresponding data; false otherwise. */ - public function containsEntity($className, $identifier); + public function containsEntity(string $className, mixed $identifier): bool; /** * Evicts the entity data for a particular entity "instance". - * - * @param string $className The entity class. - * @param mixed $identifier The entity identifier. - * - * @return void */ - public function evictEntity($className, $identifier); + public function evictEntity(string $className, mixed $identifier): void; /** * Evicts all entity data from the given region. - * - * @param string $className The entity metadata. - * - * @return void */ - public function evictEntityRegion($className); + public function evictEntityRegion(string $className): void; /** * Evict data from all entity regions. - * - * @return void */ - public function evictEntityRegions(); + public function evictEntityRegions(): void; /** * Determine whether the cache contains data for the given collection. - * - * @param string $className The entity class. - * @param string $association The field name that represents the association. - * @param mixed $ownerIdentifier The identifier of the owning entity. - * - * @return bool true if the underlying cache contains corresponding data; false otherwise. */ - public function containsCollection($className, $association, $ownerIdentifier); + public function containsCollection(string $className, string $association, mixed $ownerIdentifier): bool; /** * Evicts the cache data for the given identified collection instance. - * - * @param string $className The entity class. - * @param string $association The field name that represents the association. - * @param mixed $ownerIdentifier The identifier of the owning entity. - * - * @return void */ - public function evictCollection($className, $association, $ownerIdentifier); + public function evictCollection(string $className, string $association, mixed $ownerIdentifier): void; /** * Evicts all entity data from the given region. - * - * @param string $className The entity class. - * @param string $association The field name that represents the association. - * - * @return void */ - public function evictCollectionRegion($className, $association); + public function evictCollectionRegion(string $className, string $association): void; /** * Evict data from all collection regions. - * - * @return void */ - public function evictCollectionRegions(); + public function evictCollectionRegions(): void; /** * Determine whether the cache contains data for the given query. - * - * @param string $regionName The cache name given to the query. - * - * @return bool true if the underlying cache contains corresponding data; false otherwise. */ - public function containsQuery($regionName); + public function containsQuery(string $regionName): bool; /** * Evicts all cached query results under the given name, or default query cache if the region name is NULL. - * - * @param string|null $regionName The cache name associated to the queries being cached. - * - * @return void */ - public function evictQueryRegion($regionName = null); + public function evictQueryRegion(?string $regionName = null): void; /** * Evict data from all query regions. - * - * @return void */ - public function evictQueryRegions(); + public function evictQueryRegions(): void; /** * Get query cache by region name or create a new one if none exist. * * @param string|null $regionName Query cache region name, or default query cache if the region name is NULL. - * - * @return QueryCache The Query Cache associated with the region name. */ - public function getQueryCache($regionName = null); + public function getQueryCache(?string $regionName = null): QueryCache; } diff --git a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php index f10618fb2b9..810ecde1d3f 100644 --- a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php @@ -15,23 +15,21 @@ class AssociationCacheEntry implements CacheEntry * @readonly Public only for performance reasons, it should be considered immutable. * @var array */ - public $identifier; + public array $identifier; /** * The entity class name * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string * @psalm-var class-string */ - public $class; + public string $class; /** - * @param string $class The entity class. * @param array $identifier The entity identifier. * @psalm-param class-string $class */ - public function __construct($class, array $identifier) + public function __construct(string $class, array $identifier) { $this->class = $class; $this->identifier = $identifier; @@ -43,10 +41,8 @@ public function __construct($class, array $identifier) * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * * @param array $values array containing property values - * - * @return AssociationCacheEntry */ - public static function __set_state(array $values) + public static function __set_state(array $values): self { return new self($values['class'], $values['identifier']); } diff --git a/lib/Doctrine/ORM/Cache/CacheConfiguration.php b/lib/Doctrine/ORM/Cache/CacheConfiguration.php index f3ad9a937a4..99417792beb 100644 --- a/lib/Doctrine/ORM/Cache/CacheConfiguration.php +++ b/lib/Doctrine/ORM/Cache/CacheConfiguration.php @@ -11,88 +11,49 @@ */ class CacheConfiguration { - /** @var CacheFactory|null */ - private $cacheFactory; + private ?CacheFactory $cacheFactory = null; + private ?RegionsConfiguration $regionsConfig = null; + private ?CacheLogger $cacheLogger = null; + private ?QueryCacheValidator $queryValidator = null; - /** @var RegionsConfiguration|null */ - private $regionsConfig; - - /** @var CacheLogger|null */ - private $cacheLogger; - - /** @var QueryCacheValidator|null */ - private $queryValidator; - - /** - * @return CacheFactory|null - */ - public function getCacheFactory() + public function getCacheFactory(): ?CacheFactory { return $this->cacheFactory; } - /** - * @return void - */ - public function setCacheFactory(CacheFactory $factory) + public function setCacheFactory(CacheFactory $factory): void { $this->cacheFactory = $factory; } - /** - * @return CacheLogger|null - */ - public function getCacheLogger() + public function getCacheLogger(): ?CacheLogger { return $this->cacheLogger; } - /** - * @return void - */ - public function setCacheLogger(CacheLogger $logger) + public function setCacheLogger(CacheLogger $logger): void { $this->cacheLogger = $logger; } - /** - * @return RegionsConfiguration - */ - public function getRegionsConfiguration() + public function getRegionsConfiguration(): RegionsConfiguration { - if ($this->regionsConfig === null) { - $this->regionsConfig = new RegionsConfiguration(); - } - - return $this->regionsConfig; + return $this->regionsConfig ??= new RegionsConfiguration(); } - /** - * @return void - */ - public function setRegionsConfiguration(RegionsConfiguration $regionsConfig) + public function setRegionsConfiguration(RegionsConfiguration $regionsConfig): void { $this->regionsConfig = $regionsConfig; } - /** - * @return QueryCacheValidator - */ - public function getQueryValidator() + public function getQueryValidator(): QueryCacheValidator { - if ($this->queryValidator === null) { - $this->queryValidator = new TimestampQueryCacheValidator( - $this->cacheFactory->getTimestampRegion() - ); - } - - return $this->queryValidator; + return $this->queryValidator ??= new TimestampQueryCacheValidator( + $this->cacheFactory->getTimestampRegion() + ); } - /** - * @return void - */ - public function setQueryValidator(QueryCacheValidator $validator) + public function setQueryValidator(QueryCacheValidator $validator): void { $this->queryValidator = $validator; } diff --git a/lib/Doctrine/ORM/Cache/CacheException.php b/lib/Doctrine/ORM/Cache/CacheException.php index b4db89b9ed5..b42209580dc 100644 --- a/lib/Doctrine/ORM/Cache/CacheException.php +++ b/lib/Doctrine/ORM/Cache/CacheException.php @@ -14,49 +14,13 @@ */ class CacheException extends LogicException implements ORMException { - /** - * @param string $sourceEntity - * @param string $fieldName - * - * @return CacheException - */ - public static function updateReadOnlyCollection($sourceEntity, $fieldName) + public static function updateReadOnlyCollection(string $sourceEntity, string $fieldName): self { return new self(sprintf('Cannot update a readonly collection "%s#%s"', $sourceEntity, $fieldName)); } - /** - * @deprecated This method is not used anymore. - * - * @param string $entityName - * - * @return CacheException - */ - public static function updateReadOnlyEntity($entityName) - { - return new self(sprintf('Cannot update a readonly entity "%s"', $entityName)); - } - - /** - * @param string $entityName - * - * @return CacheException - */ - public static function nonCacheableEntity($entityName) + public static function nonCacheableEntity(string $entityName): self { return new self(sprintf('Entity "%s" not configured as part of the second-level cache.', $entityName)); } - - /** - * @deprecated This method is not used anymore. - * - * @param string $entityName - * @param string $field - * - * @return CacheException - */ - public static function nonCacheableEntityAssociation($entityName, $field) - { - return new self(sprintf('Entity association field "%s#%s" not configured as part of the second-level cache.', $entityName, $field)); - } } diff --git a/lib/Doctrine/ORM/Cache/CacheFactory.php b/lib/Doctrine/ORM/Cache/CacheFactory.php index 60bd582c1d9..405ad86b74c 100644 --- a/lib/Doctrine/ORM/Cache/CacheFactory.php +++ b/lib/Doctrine/ORM/Cache/CacheFactory.php @@ -19,69 +19,47 @@ interface CacheFactory { /** * Build an entity persister for the given entity metadata. - * - * @param EntityManagerInterface $em The entity manager. - * @param EntityPersister $persister The entity persister that will be cached. - * @param ClassMetadata $metadata The entity metadata. - * - * @return CachedEntityPersister */ - public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPersister $persister, ClassMetadata $metadata); + public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPersister $persister, ClassMetadata $metadata): CachedEntityPersister; /** * Build a collection persister for the given relation mapping. * * @param mixed[] $mapping The association mapping. - * - * @return CachedCollectionPersister */ - public function buildCachedCollectionPersister(EntityManagerInterface $em, CollectionPersister $persister, array $mapping); + public function buildCachedCollectionPersister(EntityManagerInterface $em, CollectionPersister $persister, array $mapping): CachedCollectionPersister; /** * Build a query cache based on the given region name - * - * @param string|null $regionName The region name. - * - * @return QueryCache The built query cache. */ - public function buildQueryCache(EntityManagerInterface $em, $regionName = null); + public function buildQueryCache(EntityManagerInterface $em, ?string $regionName = null): QueryCache; /** * Build an entity hydrator - * - * @return EntityHydrator The built entity hydrator. */ - public function buildEntityHydrator(EntityManagerInterface $em, ClassMetadata $metadata); + public function buildEntityHydrator(EntityManagerInterface $em, ClassMetadata $metadata): EntityHydrator; /** * Build a collection hydrator * * @param mixed[] $mapping The association mapping. - * - * @return CollectionHydrator The built collection hydrator. */ - public function buildCollectionHydrator(EntityManagerInterface $em, array $mapping); + public function buildCollectionHydrator(EntityManagerInterface $em, array $mapping): CollectionHydrator; /** * Build a cache region * * @param array $cache The cache configuration. - * - * @return Region The cache region. */ - public function getRegion(array $cache); + public function getRegion(array $cache): Region; /** * Build timestamp cache region - * - * @return TimestampRegion The timestamp region. */ - public function getTimestampRegion(); + public function getTimestampRegion(): TimestampRegion; /** * Build \Doctrine\ORM\Cache - * - * @return Cache */ - public function createCache(EntityManagerInterface $entityManager); + public function createCache(EntityManagerInterface $entityManager): Cache; } diff --git a/lib/Doctrine/ORM/Cache/CacheKey.php b/lib/Doctrine/ORM/Cache/CacheKey.php index 5f4305d6865..47466c063fa 100644 --- a/lib/Doctrine/ORM/Cache/CacheKey.php +++ b/lib/Doctrine/ORM/Cache/CacheKey.php @@ -14,7 +14,6 @@ abstract class CacheKey * Unique identifier * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string */ - public $hash; + public string $hash; } diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php index fe3eb3d5ae2..e5904bc44da 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php @@ -15,7 +15,7 @@ class CollectionCacheEntry implements CacheEntry * @readonly Public only for performance reasons, it should be considered immutable. * @var CacheKey[] */ - public $identifiers; + public array $identifiers; /** * @param CacheKey[] $identifiers List of entity identifiers hold by the collection @@ -31,10 +31,8 @@ public function __construct(array $identifiers) * This method allows for Doctrine\Common\Cache\PhpFileCache compatibility * * @param array $values array containing property values - * - * @return CollectionCacheEntry */ - public static function __set_state(array $values) + public static function __set_state(array $values): CollectionCacheEntry { return new self($values['identifiers']); } diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php b/lib/Doctrine/ORM/Cache/CollectionCacheKey.php index ec2c35db994..eb2414f83bd 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheKey.php @@ -20,38 +20,34 @@ class CollectionCacheKey extends CacheKey * @readonly Public only for performance reasons, it should be considered immutable. * @var array */ - public $ownerIdentifier; + public array $ownerIdentifier; /** * The owner entity class * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string * @psalm-var class-string */ - public $entityClass; + public string $entityClass; /** * The association name * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string */ - public $association; + public string $association; /** - * @param string $entityClass The entity class. - * @param string $association The field name that represents the association. * @param array $ownerIdentifier The identifier of the owning entity. * @psalm-param class-string $entityClass */ - public function __construct($entityClass, $association, array $ownerIdentifier) + public function __construct(string $entityClass, string $association, array $ownerIdentifier) { ksort($ownerIdentifier); $this->ownerIdentifier = $ownerIdentifier; - $this->entityClass = (string) $entityClass; - $this->association = (string) $association; + $this->entityClass = $entityClass; + $this->association = $association; $this->hash = str_replace('\\', '.', strtolower($entityClass)) . '_' . implode(' ', $ownerIdentifier) . '__' . $association; } } diff --git a/lib/Doctrine/ORM/Cache/CollectionHydrator.php b/lib/Doctrine/ORM/Cache/CollectionHydrator.php index 5d327a3198f..db8ba112542 100644 --- a/lib/Doctrine/ORM/Cache/CollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/CollectionHydrator.php @@ -14,14 +14,12 @@ interface CollectionHydrator { /** - * @param array|mixed[]|Collection $collection The collection. - * - * @return CollectionCacheEntry + * @param mixed[]|Collection $collection The collection. */ - public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, $collection); + public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, array|Collection $collection): CollectionCacheEntry; /** * @return mixed[]|null */ - public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection); + public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): ?array; } diff --git a/lib/Doctrine/ORM/Cache/DefaultCache.php b/lib/Doctrine/ORM/Cache/DefaultCache.php index 5ca9eab822e..2aaaa8e66ef 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultCache.php @@ -20,37 +20,27 @@ */ class DefaultCache implements Cache { - /** @var EntityManagerInterface */ - private $em; - - /** @var UnitOfWork */ - private $uow; - - /** @var CacheFactory */ - private $cacheFactory; + private UnitOfWork $uow; + private CacheFactory $cacheFactory; /** * @var QueryCache[] * @psalm-var array */ - private $queryCaches = []; + private array $queryCaches = []; - /** @var QueryCache|null */ - private $defaultQueryCache; + private ?QueryCache $defaultQueryCache = null; - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; + public function __construct( + private EntityManagerInterface $em + ) { $this->uow = $em->getUnitOfWork(); $this->cacheFactory = $em->getConfiguration() ->getSecondLevelCacheConfiguration() ->getCacheFactory(); } - /** - * {@inheritdoc} - */ - public function getEntityCacheRegion($className) + public function getEntityCacheRegion(string $className): ?Region { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getEntityPersister($metadata->rootEntityName); @@ -62,10 +52,7 @@ public function getEntityCacheRegion($className) return $persister->getCacheRegion(); } - /** - * {@inheritdoc} - */ - public function getCollectionCacheRegion($className, $association) + public function getCollectionCacheRegion(string $className, string $association): ?Region { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getCollectionPersister($metadata->getAssociationMapping($association)); @@ -77,10 +64,7 @@ public function getCollectionCacheRegion($className, $association) return $persister->getCacheRegion(); } - /** - * {@inheritdoc} - */ - public function containsEntity($className, $identifier) + public function containsEntity(string $className, mixed $identifier): bool { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getEntityPersister($metadata->rootEntityName); @@ -92,10 +76,7 @@ public function containsEntity($className, $identifier) return $persister->getCacheRegion()->contains($this->buildEntityCacheKey($metadata, $identifier)); } - /** - * {@inheritdoc} - */ - public function evictEntity($className, $identifier) + public function evictEntity(string $className, mixed $identifier): void { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getEntityPersister($metadata->rootEntityName); @@ -107,10 +88,7 @@ public function evictEntity($className, $identifier) $persister->getCacheRegion()->evict($this->buildEntityCacheKey($metadata, $identifier)); } - /** - * {@inheritdoc} - */ - public function evictEntityRegion($className) + public function evictEntityRegion(string $className): void { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getEntityPersister($metadata->rootEntityName); @@ -122,10 +100,7 @@ public function evictEntityRegion($className) $persister->getCacheRegion()->evictAll(); } - /** - * {@inheritdoc} - */ - public function evictEntityRegions() + public function evictEntityRegions(): void { $metadatas = $this->em->getMetadataFactory()->getAllMetadata(); @@ -140,10 +115,7 @@ public function evictEntityRegions() } } - /** - * {@inheritdoc} - */ - public function containsCollection($className, $association, $ownerIdentifier) + public function containsCollection(string $className, string $association, mixed $ownerIdentifier): bool { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getCollectionPersister($metadata->getAssociationMapping($association)); @@ -155,10 +127,7 @@ public function containsCollection($className, $association, $ownerIdentifier) return $persister->getCacheRegion()->contains($this->buildCollectionCacheKey($metadata, $association, $ownerIdentifier)); } - /** - * {@inheritdoc} - */ - public function evictCollection($className, $association, $ownerIdentifier) + public function evictCollection(string $className, string $association, mixed $ownerIdentifier): void { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getCollectionPersister($metadata->getAssociationMapping($association)); @@ -170,10 +139,7 @@ public function evictCollection($className, $association, $ownerIdentifier) $persister->getCacheRegion()->evict($this->buildCollectionCacheKey($metadata, $association, $ownerIdentifier)); } - /** - * {@inheritdoc} - */ - public function evictCollectionRegion($className, $association) + public function evictCollectionRegion(string $className, string $association): void { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getCollectionPersister($metadata->getAssociationMapping($association)); @@ -185,10 +151,7 @@ public function evictCollectionRegion($className, $association) $persister->getCacheRegion()->evictAll(); } - /** - * {@inheritdoc} - */ - public function evictCollectionRegions() + public function evictCollectionRegions(): void { $metadatas = $this->em->getMetadataFactory()->getAllMetadata(); @@ -209,18 +172,12 @@ public function evictCollectionRegions() } } - /** - * {@inheritdoc} - */ - public function containsQuery($regionName) + public function containsQuery(string $regionName): bool { return isset($this->queryCaches[$regionName]); } - /** - * {@inheritdoc} - */ - public function evictQueryRegion($regionName = null) + public function evictQueryRegion(?string $regionName = null): void { if ($regionName === null && $this->defaultQueryCache !== null) { $this->defaultQueryCache->clear(); @@ -233,10 +190,7 @@ public function evictQueryRegion($regionName = null) } } - /** - * {@inheritdoc} - */ - public function evictQueryRegions() + public function evictQueryRegions(): void { $this->getQueryCache()->clear(); @@ -245,27 +199,16 @@ public function evictQueryRegions() } } - /** - * {@inheritdoc} - */ - public function getQueryCache($regionName = null) + public function getQueryCache(?string $regionName = null): QueryCache { if ($regionName === null) { - return $this->defaultQueryCache ?: - $this->defaultQueryCache = $this->cacheFactory->buildQueryCache($this->em); - } - - if (! isset($this->queryCaches[$regionName])) { - $this->queryCaches[$regionName] = $this->cacheFactory->buildQueryCache($this->em, $regionName); + return $this->defaultQueryCache ??= $this->cacheFactory->buildQueryCache($this->em); } - return $this->queryCaches[$regionName]; + return $this->queryCaches[$regionName] ??= $this->cacheFactory->buildQueryCache($this->em, $regionName); } - /** - * @param mixed $identifier The entity identifier. - */ - private function buildEntityCacheKey(ClassMetadata $metadata, $identifier): EntityCacheKey + private function buildEntityCacheKey(ClassMetadata $metadata, mixed $identifier): EntityCacheKey { if (! is_array($identifier)) { $identifier = $this->toIdentifierArray($metadata, $identifier); @@ -274,13 +217,10 @@ private function buildEntityCacheKey(ClassMetadata $metadata, $identifier): Enti return new EntityCacheKey($metadata->rootEntityName, $identifier); } - /** - * @param mixed $ownerIdentifier The identifier of the owning entity. - */ private function buildCollectionCacheKey( ClassMetadata $metadata, string $association, - $ownerIdentifier + mixed $ownerIdentifier ): CollectionCacheKey { if (! is_array($ownerIdentifier)) { $ownerIdentifier = $this->toIdentifierArray($metadata, $ownerIdentifier); @@ -290,18 +230,13 @@ private function buildCollectionCacheKey( } /** - * @param mixed $identifier The entity identifier. - * * @return array */ - private function toIdentifierArray(ClassMetadata $metadata, $identifier): array + private function toIdentifierArray(ClassMetadata $metadata, mixed $identifier): array { if (is_object($identifier) && $this->em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($identifier))) { - $identifier = $this->uow->getSingleIdentifierValue($identifier); - - if ($identifier === null) { - throw ORMInvalidArgumentException::invalidIdentifierBindingEntity(); - } + $identifier = $this->uow->getSingleIdentifierValue($identifier) + ?? throw ORMInvalidArgumentException::invalidIdentifierBindingEntity(); } return [$metadata->identifier[0] => $identifier]; diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 9ebc5a62bf9..2ff5949cb10 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -5,9 +5,11 @@ namespace Doctrine\ORM\Cache; use Doctrine\ORM\Cache; +use Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister; use Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister; use Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister; use Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister; +use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister; use Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister; use Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister; use Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister; @@ -44,44 +46,27 @@ public function __construct(RegionsConfiguration $cacheConfig, CacheItemPoolInte $this->regionsConfig = $cacheConfig; } - /** - * @param string $fileLockRegionDirectory - * - * @return void - */ - public function setFileLockRegionDirectory($fileLockRegionDirectory) + public function setFileLockRegionDirectory(string $fileLockRegionDirectory): void { - $this->fileLockRegionDirectory = (string) $fileLockRegionDirectory; + $this->fileLockRegionDirectory = $fileLockRegionDirectory; } - /** - * @return string - */ - public function getFileLockRegionDirectory() + public function getFileLockRegionDirectory(): string { return $this->fileLockRegionDirectory; } - /** - * @return void - */ - public function setRegion(Region $region) + public function setRegion(Region $region): void { $this->regions[$region->getName()] = $region; } - /** - * @return void - */ - public function setTimestampRegion(TimestampRegion $region) + public function setTimestampRegion(TimestampRegion $region): void { $this->timestampRegion = $region; } - /** - * {@inheritdoc} - */ - public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPersister $persister, ClassMetadata $metadata) + public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPersister $persister, ClassMetadata $metadata): CachedEntityPersister { assert($metadata->cache !== null); $region = $this->getRegion($metadata->cache); @@ -109,7 +94,7 @@ public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPer /** * {@inheritdoc} */ - public function buildCachedCollectionPersister(EntityManagerInterface $em, CollectionPersister $persister, array $mapping) + public function buildCachedCollectionPersister(EntityManagerInterface $em, CollectionPersister $persister, array $mapping): CachedCollectionPersister { $usage = $mapping['cache']['usage']; $region = $this->getRegion($mapping['cache']); @@ -133,10 +118,7 @@ public function buildCachedCollectionPersister(EntityManagerInterface $em, Colle throw new InvalidArgumentException(sprintf('Unrecognized access strategy type [%s]', $usage)); } - /** - * {@inheritdoc} - */ - public function buildQueryCache(EntityManagerInterface $em, $regionName = null) + public function buildQueryCache(EntityManagerInterface $em, ?string $regionName = null): QueryCache { return new DefaultQueryCache( $em, @@ -152,15 +134,12 @@ public function buildQueryCache(EntityManagerInterface $em, $regionName = null) /** * {@inheritdoc} */ - public function buildCollectionHydrator(EntityManagerInterface $em, array $mapping) + public function buildCollectionHydrator(EntityManagerInterface $em, array $mapping): CollectionHydrator { return new DefaultCollectionHydrator($em); } - /** - * {@inheritdoc} - */ - public function buildEntityHydrator(EntityManagerInterface $em, ClassMetadata $metadata) + public function buildEntityHydrator(EntityManagerInterface $em, ClassMetadata $metadata): EntityHydrator { return new DefaultEntityHydrator($em); } @@ -168,7 +147,7 @@ public function buildEntityHydrator(EntityManagerInterface $em, ClassMetadata $m /** * {@inheritdoc} */ - public function getRegion(array $cache) + public function getRegion(array $cache): Region { if (isset($this->regions[$cache['region']])) { return $this->regions[$cache['region']]; @@ -196,10 +175,7 @@ public function getRegion(array $cache) return $this->regions[$cache['region']] = $region; } - /** - * {@inheritdoc} - */ - public function getTimestampRegion() + public function getTimestampRegion(): TimestampRegion { if ($this->timestampRegion === null) { $name = Cache::DEFAULT_TIMESTAMP_REGION_NAME; @@ -211,10 +187,7 @@ public function getTimestampRegion() return $this->timestampRegion; } - /** - * {@inheritdoc} - */ - public function createCache(EntityManagerInterface $entityManager) + public function createCache(EntityManagerInterface $entityManager): Cache { return new DefaultCache($entityManager); } diff --git a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php index 08924680f1f..9ea7729a74b 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Cache; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Cache\Persister\CachedPersister; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; @@ -18,28 +19,18 @@ */ class DefaultCollectionHydrator implements CollectionHydrator { - /** @var EntityManagerInterface */ - private $em; - - /** @var UnitOfWork */ - private $uow; + private UnitOfWork $uow; /** @var array */ - private static $hints = [Query::HINT_CACHE_ENABLED => true]; + private static array $hints = [Query::HINT_CACHE_ENABLED => true]; - /** - * @param EntityManagerInterface $em The entity manager. - */ - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; + public function __construct( + private EntityManagerInterface $em + ) { $this->uow = $em->getUnitOfWork(); } - /** - * {@inheritdoc} - */ - public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, $collection) + public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, array|Collection $collection): CollectionCacheEntry { $data = []; @@ -53,7 +44,7 @@ public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key /** * {@inheritdoc} */ - public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection) + public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): ?array { $assoc = $metadata->associationMappings[$key->association]; $targetPersister = $this->uow->getEntityPersister($assoc['targetEntity']); diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 2ca00cfe10f..3eff193d9fa 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -32,34 +32,19 @@ */ class DefaultQueryCache implements QueryCache { - /** @var EntityManagerInterface */ - private $em; - - /** @var UnitOfWork */ - private $uow; - - /** @var Region */ - private $region; - - /** @var QueryCacheValidator */ - private $validator; - - /** @var CacheLogger|null */ - protected $cacheLogger; + private UnitOfWork $uow; + private QueryCacheValidator $validator; + protected ?CacheLogger $cacheLogger = null; /** @var array */ - private static $hints = [Query::HINT_CACHE_ENABLED => true]; + private static array $hints = [Query::HINT_CACHE_ENABLED => true]; - /** - * @param EntityManagerInterface $em The entity manager. - * @param Region $region The query region. - */ - public function __construct(EntityManagerInterface $em, Region $region) - { + public function __construct( + private EntityManagerInterface $em, + private Region $region + ) { $cacheConfig = $em->getConfiguration()->getSecondLevelCacheConfiguration(); - $this->em = $em; - $this->region = $region; $this->uow = $em->getUnitOfWork(); $this->cacheLogger = $cacheConfig->getCacheLogger(); $this->validator = $cacheConfig->getQueryValidator(); @@ -68,7 +53,7 @@ public function __construct(EntityManagerInterface $em, Region $region) /** * {@inheritdoc} */ - public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []) + public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []): ?array { if (! ($key->cacheMode & Cache::MODE_GET)) { return null; @@ -109,16 +94,12 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] $entityEntry = $entries[$index] ?? null; if (! $entityEntry instanceof EntityCacheEntry) { - if ($this->cacheLogger !== null) { - $this->cacheLogger->entityCacheMiss($regionName, $cacheKeys->identifiers[$index]); - } + $this->cacheLogger?->entityCacheMiss($regionName, $cacheKeys->identifiers[$index]); return null; } - if ($this->cacheLogger !== null) { - $this->cacheLogger->entityCacheHit($regionName, $cacheKeys->identifiers[$index]); - } + $this->cacheLogger?->entityCacheHit($regionName, $cacheKeys->identifiers[$index]); if (! $hasRelation) { $result[$index] = $this->uow->createEntity($entityEntry->class, $entityEntry->resolveAssociationEntries($this->em), self::$hints); @@ -140,9 +121,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] $assocEntry = $assocRegion->get($assocKey); if ($assocEntry === null) { - if ($this->cacheLogger !== null) { - $this->cacheLogger->entityCacheMiss($assocRegion->getName(), $assocKey); - } + $this->cacheLogger?->entityCacheMiss($assocRegion->getName(), $assocKey); $this->uow->hydrationComplete(); @@ -151,9 +130,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] $data[$name] = $this->uow->createEntity($assocEntry->class, $assocEntry->resolveAssociationEntries($this->em), self::$hints); - if ($this->cacheLogger !== null) { - $this->cacheLogger->entityCacheHit($assocRegion->getName(), $assocKey); - } + $this->cacheLogger?->entityCacheHit($assocRegion->getName(), $assocKey); continue; } @@ -174,9 +151,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] $assocEntry = is_array($assocEntries) ? ($assocEntries[$assocIndex] ?? null) : null; if ($assocEntry === null) { - if ($this->cacheLogger !== null) { - $this->cacheLogger->entityCacheMiss($assocRegion->getName(), $assocKeys->identifiers[$assocIndex]); - } + $this->cacheLogger?->entityCacheMiss($assocRegion->getName(), $assocKeys->identifiers[$assocIndex]); $this->uow->hydrationComplete(); @@ -187,9 +162,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] $collection->hydrateSet($assocIndex, $element); - if ($this->cacheLogger !== null) { - $this->cacheLogger->entityCacheHit($assocRegion->getName(), $assocKeys->identifiers[$assocIndex]); - } + $this->cacheLogger?->entityCacheHit($assocRegion->getName(), $assocKeys->identifiers[$assocIndex]); } $data[$name] = $collection; @@ -227,7 +200,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] /** * {@inheritdoc} */ - public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $hints = []) + public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, array $hints = []): bool { if ($rsm->scalarMappings) { throw FeatureNotImplemented::scalarResults(); @@ -327,12 +300,11 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h /** * @param array $assoc - * @param mixed $assocValue * * @return mixed[]|null * @psalm-return array{targetEntity: class-string, type: mixed, list?: array[], identifier?: array}|null */ - private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue): ?array + private function storeAssociationCache(QueryCacheKey $key, array $assoc, mixed $assocValue): ?array { $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); $assocMetadata = $assocPersister->getClassMetadata(); @@ -382,16 +354,13 @@ private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocV } /** - * @param object $entity - * - * @return mixed[]|object|null * @psalm-return list|object|null */ private function getAssociationValue( ResultSetMapping $rsm, string $assocAlias, - $entity - ) { + object $entity + ): array|object|null { $path = []; $alias = $assocAlias; @@ -412,13 +381,11 @@ private function getAssociationValue( } /** - * @param mixed $value * @psalm-param array $path * - * @return mixed[]|object|null * @psalm-return list|object|null */ - private function getAssociationPathValue($value, array $path) + private function getAssociationPathValue(mixed $value, array $path): array|object|null { $mapping = array_shift($path); $metadata = $this->em->getClassMetadata($mapping['class']); @@ -447,18 +414,12 @@ private function getAssociationPathValue($value, array $path) return $values; } - /** - * {@inheritdoc} - */ - public function clear() + public function clear(): bool { return $this->region->evictAll(); } - /** - * {@inheritdoc} - */ - public function getRegion() + public function getRegion(): Region { return $this->region; } diff --git a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php index 6a769111c48..d8853545971 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php @@ -19,23 +19,21 @@ class EntityCacheEntry implements CacheEntry * @readonly Public only for performance reasons, it should be considered immutable. * @var array */ - public $data; + public array $data; /** * The entity class name * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string * @psalm-var class-string */ - public $class; + public string $class; /** - * @param string $class The entity class. - * @param array $data The entity data. + * @param array $data The entity data. * @psalm-param class-string $class */ - public function __construct($class, array $data) + public function __construct(string $class, array $data) { $this->class = $class; $this->data = $data; @@ -47,10 +45,8 @@ public function __construct($class, array $data) * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * * @param array $values array containing property values - * - * @return EntityCacheEntry */ - public static function __set_state(array $values) + public static function __set_state(array $values): self { return new self($values['class'], $values['data']); } @@ -60,7 +56,7 @@ public static function __set_state(array $values) * * @return array */ - public function resolveAssociationEntries(EntityManagerInterface $em) + public function resolveAssociationEntries(EntityManagerInterface $em): array { return array_map(static function ($value) use ($em) { if (! ($value instanceof AssociationCacheEntry)) { diff --git a/lib/Doctrine/ORM/Cache/EntityCacheKey.php b/lib/Doctrine/ORM/Cache/EntityCacheKey.php index 730914d6979..f6486969886 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheKey.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheKey.php @@ -20,23 +20,22 @@ class EntityCacheKey extends CacheKey * @readonly Public only for performance reasons, it should be considered immutable. * @var array */ - public $identifier; + public array $identifier; /** * The entity class name * * @readonly Public only for performance reasons, it should be considered immutable. - * @var string * @psalm-var class-string */ - public $entityClass; + public string $entityClass; /** * @param string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class. * @param array $identifier The entity identifier * @psalm-param class-string $entityClass */ - public function __construct($entityClass, array $identifier) + public function __construct(string $entityClass, array $identifier) { ksort($identifier); diff --git a/lib/Doctrine/ORM/Cache/Lock.php b/lib/Doctrine/ORM/Cache/Lock.php index a24ddb75555..928d56737ee 100644 --- a/lib/Doctrine/ORM/Cache/Lock.php +++ b/lib/Doctrine/ORM/Cache/Lock.php @@ -9,22 +9,16 @@ class Lock { - /** @var string */ - public $value; + public int $time; - /** @var int */ - public $time; - - public function __construct(string $value, ?int $time = null) - { - $this->value = $value; - $this->time = $time ?: time(); + public function __construct( + public string $value, + ?int $time = null + ) { + $this->time = $time ?? time(); } - /** - * @return Lock - */ - public static function createLockRead() + public static function createLockRead(): Lock { return new self(uniqid((string) time(), true)); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index 63d8179aa6e..96ff5112e54 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -7,10 +7,8 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Util\ClassUtils; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\CollectionHydrator; -use Doctrine\ORM\Cache\EntityCacheKey; use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister; use Doctrine\ORM\Cache\Region; @@ -172,51 +170,4 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri { return $this->persister->loadCriteria($collection, $criteria); } - - /** - * Clears cache entries related to the current collection - * - * @deprecated This method is not used anymore. - */ - protected function evictCollectionCache(PersistentCollection $collection): void - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9512', - 'The method %s() is deprecated and will be removed without replacement.' - ); - - $key = new CollectionCacheKey( - $this->sourceEntity->rootEntityName, - $this->association['fieldName'], - $this->uow->getEntityIdentifier($collection->getOwner()) - ); - - $this->region->evict($key); - - $this->cacheLogger?->collectionCachePut($this->regionName, $key); - } - - /** - * @deprecated This method is not used anymore. - * - * @psalm-param class-string $targetEntity - */ - protected function evictElementCache(string $targetEntity, object $element): void - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9512', - 'The method %s() is deprecated and will be removed without replacement.' - ); - - $targetPersister = $this->uow->getEntityPersister($targetEntity); - assert($targetPersister instanceof CachedEntityPersister); - $targetRegion = $targetPersister->getCacheRegion(); - $key = new EntityCacheKey($targetEntity, $this->uow->getEntityIdentifier($element)); - - $targetRegion->evict($key); - - $this->cacheLogger?->entityCachePut($targetRegion->getName(), $key); - } } diff --git a/lib/Doctrine/ORM/Cache/QueryCache.php b/lib/Doctrine/ORM/Cache/QueryCache.php index 890ee7a04c1..4e80a8040e4 100644 --- a/lib/Doctrine/ORM/Cache/QueryCache.php +++ b/lib/Doctrine/ORM/Cache/QueryCache.php @@ -12,28 +12,19 @@ */ interface QueryCache { - /** - * @return bool - */ - public function clear(); + public function clear(): bool; /** - * @param mixed $result * @param mixed[] $hints - * - * @return bool */ - public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $hints = []); + public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, array $hints = []): bool; /** * @param mixed[] $hints * * @return mixed[]|null */ - public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []); + public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []): ?array; - /** - * @return Region - */ - public function getRegion(); + public function getRegion(): Region; } diff --git a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php index 0bd18afc7b6..27e6e83c899 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php @@ -17,21 +17,19 @@ class QueryCacheEntry implements CacheEntry * @readonly Public only for performance reasons, it should be considered immutable. * @var array */ - public $result; + public array $result; /** * Time creation of this cache entry * * @readonly Public only for performance reasons, it should be considered immutable. - * @var float */ - public $time; + public float $time; /** * @param array $result - * @param float|null $time */ - public function __construct($result, $time = null) + public function __construct(array $result, ?float $time = null) { $this->result = $result; $this->time = $time ?: microtime(true); @@ -39,10 +37,8 @@ public function __construct($result, $time = null) /** * @param array $values - * - * @return QueryCacheEntry */ - public static function __set_state(array $values) + public static function __set_state(array $values): self { return new self($values['result'], $values['time']); } diff --git a/lib/Doctrine/ORM/Cache/QueryCacheKey.php b/lib/Doctrine/ORM/Cache/QueryCacheKey.php index a378c39c1c6..728ce3d5f43 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheKey.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheKey.php @@ -15,24 +15,19 @@ class QueryCacheKey extends CacheKey * Cache key lifetime * * @readonly Public only for performance reasons, it should be considered immutable. - * @var int */ - public $lifetime; + public int $lifetime; /** * Cache mode * * @readonly Public only for performance reasons, it should be considered immutable. - * @var int * @psalm-var Cache::MODE_* */ - public $cacheMode; + public int $cacheMode; - /** - * @readonly Public only for performance reasons, it should be considered immutable. - * @var TimestampCacheKey|null - */ - public $timestampKey; + /** @readonly Public only for performance reasons, it should be considered immutable. */ + public ?TimestampCacheKey $timestampKey = null; /** * @psalm-param Cache::MODE_* $cacheMode diff --git a/lib/Doctrine/ORM/Cache/QueryCacheValidator.php b/lib/Doctrine/ORM/Cache/QueryCacheValidator.php index 8ef61299a5b..8a0d39f6469 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheValidator.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheValidator.php @@ -11,8 +11,6 @@ interface QueryCacheValidator { /** * Checks if the query entry is valid - * - * @return bool */ - public function isValid(QueryCacheKey $key, QueryCacheEntry $entry); + public function isValid(QueryCacheKey $key, QueryCacheEntry $entry): bool; } diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php index b4706714949..baca09481a2 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php @@ -26,15 +26,11 @@ class DefaultRegion implements Region private const REGION_KEY_SEPARATOR = '_'; private const REGION_PREFIX = 'DC2_REGION_'; - private string $name; - private int $lifetime = 0; - private CacheItemPoolInterface $cacheItemPool; - - public function __construct(string $name, CacheItemPoolInterface $cacheItemPool, int $lifetime = 0) - { - $this->cacheItemPool = $cacheItemPool; - $this->name = $name; - $this->lifetime = $lifetime; + public function __construct( + private string $name, + private CacheItemPoolInterface $cacheItemPool, + private int $lifetime = 0 + ) { } public function getName(): string diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index 3171e03d88a..b9264796036 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -92,18 +92,12 @@ private function getLockFileName(CacheKey $key): string return $this->directory . DIRECTORY_SEPARATOR . $key->hash . '.' . self::LOCK_EXTENSION; } - /** - * @return string|false - */ - private function getLockContent(string $filename) + private function getLockContent(string $filename): string|false { return @file_get_contents($filename); } - /** - * @return int|false - */ - private function getLockTime(string $filename) + private function getLockTime(string $filename): int|false { return @fileatime($filename); } diff --git a/lib/Doctrine/ORM/Cache/RegionsConfiguration.php b/lib/Doctrine/ORM/Cache/RegionsConfiguration.php index b566e51f5b0..a7691f04ef5 100644 --- a/lib/Doctrine/ORM/Cache/RegionsConfiguration.php +++ b/lib/Doctrine/ORM/Cache/RegionsConfiguration.php @@ -10,102 +10,54 @@ class RegionsConfiguration { /** @var array */ - private $lifetimes = []; + private array $lifetimes = []; /** @var array */ - private $lockLifetimes = []; + private array $lockLifetimes = []; - /** @var int */ - private $defaultLifetime; - - /** @var int */ - private $defaultLockLifetime; - - /** - * @param int $defaultLifetime - * @param int $defaultLockLifetime - */ - public function __construct($defaultLifetime = 3600, $defaultLockLifetime = 60) - { - $this->defaultLifetime = (int) $defaultLifetime; - $this->defaultLockLifetime = (int) $defaultLockLifetime; + public function __construct( + private int $defaultLifetime = 3600, + private int $defaultLockLifetime = 60 + ) { } - /** - * @return int - */ - public function getDefaultLifetime() + public function getDefaultLifetime(): int { return $this->defaultLifetime; } - /** - * @param int $defaultLifetime - * - * @return void - */ - public function setDefaultLifetime($defaultLifetime) + public function setDefaultLifetime(int $defaultLifetime): void { - $this->defaultLifetime = (int) $defaultLifetime; + $this->defaultLifetime = $defaultLifetime; } - /** - * @return int - */ - public function getDefaultLockLifetime() + public function getDefaultLockLifetime(): int { return $this->defaultLockLifetime; } - /** - * @param int $defaultLockLifetime - * - * @return void - */ - public function setDefaultLockLifetime($defaultLockLifetime) + public function setDefaultLockLifetime(int $defaultLockLifetime): void { - $this->defaultLockLifetime = (int) $defaultLockLifetime; + $this->defaultLockLifetime = $defaultLockLifetime; } - /** - * @param string $regionName - * - * @return int - */ - public function getLifetime($regionName) + public function getLifetime(string $regionName): int { return $this->lifetimes[$regionName] ?? $this->defaultLifetime; } - /** - * @param string $name - * @param int $lifetime - * - * @return void - */ - public function setLifetime($name, $lifetime) + public function setLifetime(string $name, int $lifetime): void { - $this->lifetimes[$name] = (int) $lifetime; + $this->lifetimes[$name] = $lifetime; } - /** - * @param string $regionName - * - * @return int - */ - public function getLockLifetime($regionName) + public function getLockLifetime(string $regionName): int { return $this->lockLifetimes[$regionName] ?? $this->defaultLockLifetime; } - /** - * @param string $name - * @param int $lifetime - * - * @return void - */ - public function setLockLifetime($name, $lifetime) + public function setLockLifetime(string $name, int $lifetime): void { - $this->lockLifetimes[$name] = (int) $lifetime; + $this->lockLifetimes[$name] = $lifetime; } } diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php index cf67dd82248..f946de46ff2 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php @@ -11,18 +11,12 @@ */ class TimestampCacheEntry implements CacheEntry { - /** - * @readonly Public only for performance reasons, it should be considered immutable. - * @var float - */ - public $time; + /** @readonly Public only for performance reasons, it should be considered immutable. */ + public float $time; - /** - * @param float|null $time - */ - public function __construct($time = null) + public function __construct(?float $time = null) { - $this->time = $time ? (float) $time : microtime(true); + $this->time = $time ?? microtime(true); } /** @@ -31,10 +25,8 @@ public function __construct($time = null) * This method allow Doctrine\Common\Cache\PhpFileCache compatibility * * @param array $values array containing property values - * - * @return TimestampCacheEntry */ - public static function __set_state(array $values) + public static function __set_state(array $values): TimestampCacheEntry { return new self($values['time']); } diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheKey.php b/lib/Doctrine/ORM/Cache/TimestampCacheKey.php index fb8b44aa01f..7142b1a8512 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheKey.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheKey.php @@ -12,8 +12,8 @@ class TimestampCacheKey extends CacheKey /** * @param string $space Result cache id */ - public function __construct($space) + public function __construct(string $space) { - $this->hash = (string) $space; + $this->hash = $space; } } diff --git a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php index 133a17056fb..9ff50f86248 100644 --- a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php +++ b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php @@ -8,18 +8,14 @@ class TimestampQueryCacheValidator implements QueryCacheValidator { - /** @var TimestampRegion */ - private $timestampRegion; + private TimestampRegion $timestampRegion; public function __construct(TimestampRegion $timestampRegion) { $this->timestampRegion = $timestampRegion; } - /** - * {@inheritdoc} - */ - public function isValid(QueryCacheKey $key, QueryCacheEntry $entry) + public function isValid(QueryCacheKey $key, QueryCacheEntry $entry): bool { if ($this->regionUpdated($key, $entry)) { return false; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9e222a114ec..4eb1de50abd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -31,12 +31,6 @@ getTimestampRegion - - - (string) $association - (string) $entityClass - - ! $association['type'] @@ -53,9 +47,6 @@ $this->fileLockRegionDirectory - - (string) $fileLockRegionDirectory - @@ -101,8 +92,7 @@ $entry->identifiers - - $collection->getOwner() + $collection->getOwner() @@ -173,26 +163,6 @@ lock - - - (int) $defaultLifetime - (int) $defaultLifetime - (int) $defaultLockLifetime - (int) $defaultLockLifetime - (int) $lifetime - (int) $lifetime - - - - - (float) $time - - - - - (string) $space - - $timestamp->time diff --git a/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php index 140a4910ebb..5648b3b70a6 100644 --- a/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/AbstractRegionTest.php @@ -19,14 +19,9 @@ */ abstract class AbstractRegionTest extends OrmFunctionalTestCase { - /** - * @var Region - * @psalm-var TRegion - */ - protected $region; - - /** @var CacheItemPoolInterface */ - protected $cacheItemPool; + /** @psalm-var TRegion */ + protected Region $region; + protected CacheItemPoolInterface $cacheItemPool; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php index 041da75629a..8621e9349ce 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php @@ -18,8 +18,7 @@ */ class CacheConfigTest extends DoctrineTestCase { - /** @var CacheConfiguration */ - private $config; + private CacheConfiguration $config; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index d918aeaecd3..7437aab925d 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -37,13 +37,10 @@ class DefaultCacheFactoryTest extends OrmTestCase { /** @var CacheFactory&MockObject */ - private $factory; + private CacheFactory $factory; - /** @var EntityManagerMock */ - private $em; - - /** @var RegionsConfiguration */ - private $regionsConfig; + private EntityManagerMock $em; + private RegionsConfiguration $regionsConfig; protected function setUp(): void { @@ -54,7 +51,7 @@ protected function setUp(): void $this->regionsConfig = new RegionsConfiguration(); $arguments = [$this->regionsConfig, $this->getSharedSecondLevelCache()]; $this->factory = $this->getMockBuilder(DefaultCacheFactory::class) - ->setMethods(['getRegion']) + ->onlyMethods(['getRegion']) ->setConstructorArgs($arguments) ->getMock(); } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index 2c0a7cc9199..4c6c6d6f07f 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -25,11 +25,8 @@ */ class DefaultCacheTest extends OrmTestCase { - /** @var DefaultCache */ - private $cache; - - /** @var EntityManagerMock */ - private $em; + private DefaultCache $cache; + private EntityManagerMock $em; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php index ca188471a99..b134ba1568b 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php @@ -21,8 +21,7 @@ */ class DefaultCollectionHydratorTest extends OrmFunctionalTestCase { - /** @var DefaultCollectionHydrator */ - private $structure; + private DefaultCollectionHydrator $structure; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index eddbfd114e6..9025852a0bc 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -35,14 +35,9 @@ */ class DefaultQueryCacheTest extends OrmTestCase { - /** @var DefaultQueryCache */ - private $queryCache; - - /** @var EntityManagerMock */ - private $em; - - /** @var CacheRegionMock */ - private $region; + private DefaultQueryCache $queryCache; + private EntityManagerMock $em; + private CacheRegionMock $region; protected function setUp(): void { @@ -678,19 +673,13 @@ public function testNotCacheableEntityException(): void class CacheFactoryDefaultQueryCacheTest extends Cache\DefaultCacheFactory { - /** @var DefaultQueryCache */ - private $queryCache; - - /** @var CacheRegionMock */ - private $region; - - public function __construct(DefaultQueryCache $queryCache, CacheRegionMock $region) - { - $this->queryCache = $queryCache; - $this->region = $region; + public function __construct( + private DefaultQueryCache $queryCache, + private CacheRegionMock $region + ) { } - public function buildQueryCache(EntityManagerInterface $em, $regionName = null): DefaultQueryCache + public function buildQueryCache(EntityManagerInterface $em, ?string $regionName = null): DefaultQueryCache { return $this->queryCache; } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index 01f2d2212e8..d8a3eefd838 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Cache; use Doctrine\ORM\Cache\CollectionCacheEntry; -use Doctrine\ORM\Cache\Region; use Doctrine\ORM\Cache\Region\DefaultRegion; use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheKeyMock; @@ -18,7 +17,7 @@ */ class DefaultRegionTest extends AbstractRegionTest { - protected function createRegion(): Region + protected function createRegion(): DefaultRegion { return new DefaultRegion('default.region.test', $this->cacheItemPool); } diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index 944b03ff1df..ede2b193f33 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -6,7 +6,6 @@ use Doctrine\ORM\Cache\CacheKey; use Doctrine\ORM\Cache\Lock; -use Doctrine\ORM\Cache\Region; use Doctrine\ORM\Cache\Region\DefaultRegion; use Doctrine\ORM\Cache\Region\FileLockRegion; use Doctrine\Tests\Mocks\CacheEntryMock; @@ -31,11 +30,11 @@ /** * @extends AbstractRegionTest * @group DDC-2183 + * @extends AbstractRegionTest */ class FileLockRegionTest extends AbstractRegionTest { - /** @var string */ - protected $directory; + protected string $directory; public function tearDown(): void { @@ -51,7 +50,7 @@ private function getFileName(FileLockRegion $region, CacheKey $key): string return $reflection->invoke($region, $key); } - protected function createRegion(): Region + protected function createRegion(): FileLockRegion { $this->directory = sys_get_temp_dir() . '/doctrine_lock_' . uniqid(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheAbstractTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheAbstractTest.php index 5091e1b4bf1..3ef5a3c2064 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheAbstractTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheAbstractTest.php @@ -29,37 +29,36 @@ abstract class SecondLevelCacheAbstractTest extends OrmFunctionalTestCase { /** @psalm-var list */ - protected $people = []; + protected array $people = []; /** @psalm-var list
*/ - protected $addresses = []; + protected array $addresses = []; /** @psalm-var list */ - protected $countries = []; + protected array $countries = []; /** @psalm-var list */ - protected $states = []; + protected array $states = []; /** @psalm-var list */ - protected $cities = []; + protected array $cities = []; /** @psalm-var list */ - protected $travels = []; + protected array $travels = []; /** @psalm-var list */ - protected $travelers = []; + protected array $travelers = []; /** @psalm-var list */ - protected $attractions = []; + protected array $attractions = []; /** @psalm-var list */ - protected $attractionsInfo = []; + protected array $attractionsInfo = []; /** @psalm-var list */ - protected $travelersWithProfile = []; + protected array $travelersWithProfile = []; - /** @var Cache */ - protected $cache; + protected Cache $cache; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php index 4ddfd206b21..101bbfb7f42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php @@ -23,11 +23,8 @@ */ class SecondLevelCacheConcurrentTest extends SecondLevelCacheAbstractTest { - /** @var CacheFactorySecondLevelCacheConcurrentTest */ - private $cacheFactory; - - /** @var ClassMetadata */ - private $countryMetadata; + private CacheFactorySecondLevelCacheConcurrentTest $cacheFactory; + private ClassMetadata $countryMetadata; protected function setUp(): void { From 87b894ea221899330818a854a16fa515265ca128 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 22 Feb 2022 00:47:51 +0100 Subject: [PATCH 054/475] Leverage the Stringable interface (#9535) --- lib/Doctrine/ORM/ORMInvalidArgumentException.php | 13 +++++-------- lib/Doctrine/ORM/UnitOfWork.php | 4 ++-- .../Tests/ORM/ORMInvalidArgumentExceptionTest.php | 5 +++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index 31b8c99f1bb..ab0e6d412e9 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -6,13 +6,13 @@ use Doctrine\ORM\Mapping\ClassMetadata; use InvalidArgumentException; +use Stringable; use function array_map; use function count; use function get_debug_type; use function gettype; use function implode; -use function method_exists; use function reset; use function spl_object_id; use function sprintf; @@ -223,19 +223,16 @@ public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $a /** * Helper method to show an object as string. - * - * @param object $obj */ - private static function objToStr($obj): string + private static function objToStr(object $obj): string { - return method_exists($obj, '__toString') ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj); + return $obj instanceof Stringable ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj); } /** - * @param object $entity * @psalm-param array $associationMapping */ - private static function newEntityFoundThroughRelationshipMessage(array $associationMapping, $entity): string + private static function newEntityFoundThroughRelationshipMessage(array $associationMapping, object $entity): string { return 'A new entity was found through the relationship \'' . $associationMapping['sourceEntity'] . '#' . $associationMapping['fieldName'] . '\' that was not' @@ -243,7 +240,7 @@ private static function newEntityFoundThroughRelationshipMessage(array $associat . ' To solve this issue: Either explicitly call EntityManager#persist()' . ' on this unknown entity or configure cascade persist' . ' this association in the mapping for example @ManyToOne(..,cascade={"persist"}).' - . (method_exists($entity, '__toString') + . ($entity instanceof Stringable ? '' : ' If you cannot find out which entity causes the problem implement \'' . $associationMapping['targetEntity'] . '#__toString()\' to get a clue.' diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index b513639c342..13fe99c0360 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -40,6 +40,7 @@ use Exception; use InvalidArgumentException; use RuntimeException; +use Stringable; use Throwable; use UnexpectedValueException; @@ -60,7 +61,6 @@ use function in_array; use function is_array; use function is_object; -use function method_exists; use function reset; use function spl_object_id; use function sprintf; @@ -2836,7 +2836,7 @@ public function initializeObject(object $obj): void */ private static function objToStr(object $obj): string { - return method_exists($obj, '__toString') ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj); + return $obj instanceof Stringable ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj); } /** diff --git a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php index ea3e0129712..bd65e60edcb 100644 --- a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php @@ -7,6 +7,7 @@ use Doctrine\ORM\ORMInvalidArgumentException; use PHPUnit\Framework\TestCase; use stdClass; +use Stringable; use function spl_object_id; use function uniqid; @@ -46,7 +47,7 @@ public function newEntitiesFoundThroughRelationshipsErrorMessages(): array $stringEntity3 = uniqid('entity3', true); $entity1 = new stdClass(); $entity2 = new stdClass(); - $entity3 = $this->getMockBuilder(stdClass::class)->setMethods(['__toString'])->getMock(); + $entity3 = $this->createMock(Stringable::class); $association1 = [ 'sourceEntity' => 'foo1', 'fieldName' => 'bar1', @@ -63,7 +64,7 @@ public function newEntitiesFoundThroughRelationshipsErrorMessages(): array 'targetEntity' => 'baz3', ]; - $entity3->expects(self::any())->method('__toString')->willReturn($stringEntity3); + $entity3->method('__toString')->willReturn($stringEntity3); return [ 'one entity found' => [ From 5ebe984194403da101b89ddef3a7cd2132056685 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 24 Feb 2022 11:15:21 +0100 Subject: [PATCH 055/475] Add native types to SQLFilter (#9524) --- lib/Doctrine/ORM/Query/Filter/SQLFilter.php | 59 ++++--------- lib/Doctrine/ORM/Query/FilterCollection.php | 83 +++++-------------- psalm-baseline.xml | 6 -- .../Tests/ORM/Functional/SQLFilterTest.php | 75 +++++------------ .../Tests/ORM/Query/FilterCollectionTest.php | 5 +- 5 files changed, 58 insertions(+), 170 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index 583984f6c5c..260b539d6d0 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -25,39 +25,28 @@ */ abstract class SQLFilter { - /** - * The entity manager. - * - * @var EntityManagerInterface - */ - private $em; - /** * Parameters for the filter. * * @psalm-var array */ - private $parameters = []; + private array $parameters = []; - /** - * @param EntityManagerInterface $em The entity manager. - */ - final public function __construct(EntityManagerInterface $em) - { - $this->em = $em; + final public function __construct( + private EntityManagerInterface $em + ) { } /** * Sets a parameter list that can be used by the filter. * - * @param string $name Name of the parameter. * @param array $values List of parameter values. * @param string $type The parameter type. If specified, the given value will be run through * the type conversion of this type. * * @return $this */ - final public function setParameterList(string $name, array $values, string $type = Types::STRING): self + final public function setParameterList(string $name, array $values, string $type = Types::STRING): static { $this->parameters[$name] = ['value' => $values, 'type' => $type, 'is_list' => true]; @@ -73,15 +62,13 @@ final public function setParameterList(string $name, array $values, string $type /** * Sets a parameter that can be used by the filter. * - * @param string $name Name of the parameter. - * @param mixed $value Value of the parameter. - * @param string|null $type The parameter type. If specified, the given value will be run through - * the type conversion of this type. This is usually not needed for - * strings and numeric types. + * @param string|null $type The parameter type. If specified, the given value will be run through + * the type conversion of this type. This is usually not needed for + * strings and numeric types. * * @return $this */ - final public function setParameter($name, $value, $type = null): self + final public function setParameter(string $name, mixed $value, ?string $type = null): static { if ($type === null) { $type = ParameterTypeInferer::inferType($value); @@ -104,13 +91,11 @@ final public function setParameter($name, $value, $type = null): self * The function is responsible for the right output escaping to use the * value in a query. * - * @param string $name Name of the parameter. - * * @return string The SQL escaped parameter to use in a query. * * @throws InvalidArgumentException */ - final public function getParameter($name) + final public function getParameter(string $name): string { if (! isset($this->parameters[$name])) { throw new InvalidArgumentException("Parameter '" . $name . "' does not exist."); @@ -132,10 +117,6 @@ final public function getParameter($name) * value in a query, separating each entry by comma to inline it into * an IN() query part. * - * @param string $name Name of the parameter. - * - * @return string The SQL escaped parameter to use in a query. - * * @throws InvalidArgumentException */ final public function getParameterList(string $name): string @@ -151,31 +132,26 @@ final public function getParameterList(string $name): string $param = $this->parameters[$name]; $connection = $this->em->getConnection(); - $quoted = array_map(static function ($value) use ($connection, $param) { - return $connection->quote($value, $param['type']); - }, $param['value']); + $quoted = array_map( + static fn (mixed $value): string => (string) $connection->quote($value, $param['type']), + $param['value'] + ); return implode(',', $quoted); } /** * Checks if a parameter was set for the filter. - * - * @param string $name Name of the parameter. - * - * @return bool */ - final public function hasParameter($name) + final public function hasParameter(string $name): bool { return isset($this->parameters[$name]); } /** * Returns as string representation of the SQLFilter parameters (the state). - * - * @return string String representation of the SQLFilter. */ - final public function __toString() + final public function __toString(): string { return serialize($this->parameters); } @@ -191,10 +167,9 @@ final protected function getConnection(): Connection /** * Gets the SQL query part to add to a query. * - * @param string $targetTableAlias * @psalm-param ClassMetadata $targetEntity * * @return string The constraint SQL if there is available, empty string otherwise. */ - abstract public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias); + abstract public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string; } diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index 01c7e2c61c1..c0ec5ecb39d 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -29,56 +29,37 @@ class FilterCollection */ public const FILTERS_STATE_DIRTY = 2; - /** - * The used Configuration. - * - * @var Configuration - */ - private $config; - - /** - * The EntityManager that "owns" this FilterCollection instance. - * - * @var EntityManagerInterface - */ - private $em; + private Configuration $config; /** * Instances of enabled filters. * - * @var SQLFilter[] - * @psalm-var array + * @var array */ - private $enabledFilters = []; + private array $enabledFilters = []; - /** - * The filter hash from the last time the query was parsed. - * - * @var string - */ - private $filterHash = ''; + /** The filter hash from the last time the query was parsed. */ + private string $filterHash = ''; /** * The current state of this filter. * - * @var int * @psalm-var self::FILTERS_STATE_* */ - private $filtersState = self::FILTERS_STATE_CLEAN; + private int $filtersState = self::FILTERS_STATE_CLEAN; - public function __construct(EntityManagerInterface $em) - { - $this->em = $em; + public function __construct( + private EntityManagerInterface $em + ) { $this->config = $em->getConfiguration(); } /** * Gets all the enabled filters. * - * @return SQLFilter[] The enabled filters. - * @psalm-return array + * @return array The enabled filters. */ - public function getEnabledFilters() + public function getEnabledFilters(): array { return $this->enabledFilters; } @@ -86,13 +67,9 @@ public function getEnabledFilters() /** * Enables a filter from the collection. * - * @param string $name Name of the filter. - * - * @return SQLFilter The enabled filter. - * * @throws InvalidArgumentException If the filter does not exist. */ - public function enable($name) + public function enable(string $name): SQLFilter { if (! $this->has($name)) { throw new InvalidArgumentException("Filter '" . $name . "' does not exist."); @@ -117,13 +94,9 @@ public function enable($name) /** * Disables a filter. * - * @param string $name Name of the filter. - * - * @return SQLFilter The disabled filter. - * * @throws InvalidArgumentException If the filter does not exist. */ - public function disable($name) + public function disable(string $name): SQLFilter { // Get the filter to return it $filter = $this->getFilter($name); @@ -138,13 +111,9 @@ public function disable($name) /** * Gets an enabled filter from the collection. * - * @param string $name Name of the filter. - * - * @return SQLFilter The filter. - * * @throws InvalidArgumentException If the filter is not enabled. */ - public function getFilter($name) + public function getFilter(string $name): SQLFilter { if (! $this->isEnabled($name)) { throw new InvalidArgumentException("Filter '" . $name . "' is not enabled."); @@ -155,44 +124,32 @@ public function getFilter($name) /** * Checks whether filter with given name is defined. - * - * @param string $name Name of the filter. - * - * @return bool true if the filter exists, false if not. */ - public function has($name) + public function has(string $name): bool { return $this->config->getFilterClassName($name) !== null; } /** * Checks if a filter is enabled. - * - * @param string $name Name of the filter. - * - * @return bool True if the filter is enabled, false otherwise. */ - public function isEnabled($name) + public function isEnabled(string $name): bool { return isset($this->enabledFilters[$name]); } /** * Checks if the filter collection is clean. - * - * @return bool */ - public function isClean() + public function isClean(): bool { return $this->filtersState === self::FILTERS_STATE_CLEAN; } /** * Generates a string of currently enabled filters to use for the cache id. - * - * @return string */ - public function getHash() + public function getHash(): string { // If there are only clean filters, the previous hash can be returned if ($this->filtersState === self::FILTERS_STATE_CLEAN) { @@ -213,10 +170,8 @@ public function getHash() /** * Sets the filter state to dirty. - * - * @return void */ - public function setFiltersStateDirty() + public function setFiltersStateDirty(): void { $this->filtersState = self::FILTERS_STATE_DIRTY; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8b9405e26d7..8b5fa0adc44 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1837,12 +1837,6 @@ - - $value - - - static function ($value) use ($connection, $param) { - $this->parameters diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index c4ec569d290..4e8511682d3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -42,44 +42,19 @@ */ class SQLFilterTest extends OrmFunctionalTestCase { - /** @var int */ - private $userId; - - /** @var int */ - private $userId2; - - /** @var int */ - private $articleId; - - /** @var int */ - private $articleId2; - - /** @var int */ - private $groupId; - - /** @var int */ - private $groupId2; - - /** @var int */ - private $managerId; - - /** @var int */ - private $managerId2; - - /** @var int */ - private $contractId1; - - /** @var int */ - private $contractId2; - - /** @var int */ - private $organizationId; - - /** @var int */ - private $eventId1; - - /** @var int */ - private $eventId2; + private int $userId; + private int $userId2; + private int $articleId; + private int $articleId2; + private int $groupId; + private int $groupId2; + private int $managerId; + private int $managerId2; + private int $contractId1; + private int $contractId2; + private int $organizationId; + private int $eventId1; + private int $eventId2; protected function setUp(): void { @@ -1185,8 +1160,7 @@ public function testRetrieveListAsSingleThrowsException(): void class MySoftDeleteFilter extends SQLFilter { - /** {@inheritDoc} */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { if ($targetEntity->name !== 'MyEntity\SoftDeleteNewsItem') { return ''; @@ -1198,8 +1172,7 @@ public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAli class MyLocaleFilter extends SQLFilter { - /** {@inheritDoc} */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { if (! in_array('LocaleAware', $targetEntity->reflClass->getInterfaceNames(), true)) { return ''; @@ -1211,8 +1184,7 @@ public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAli class CMSCountryFilter extends SQLFilter { - /** {@inheritDoc} */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { if ($targetEntity->name !== CmsAddress::class) { return ''; @@ -1224,8 +1196,7 @@ public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAli class CMSGroupPrefixFilter extends SQLFilter { - /** {@inheritDoc} */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { if ($targetEntity->name !== CmsGroup::class) { return ''; @@ -1237,8 +1208,7 @@ public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAli class CMSArticleTopicFilter extends SQLFilter { - /** {@inheritDoc} */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { if ($targetEntity->name !== CmsArticle::class) { return ''; @@ -1250,8 +1220,7 @@ public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAli class CompanyPersonNameFilter extends SQLFilter { - /** {@inheritDoc} */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { if ($targetEntity->name !== CompanyPerson::class) { return ''; @@ -1263,8 +1232,7 @@ public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAli class CompletedContractFilter extends SQLFilter { - /** {@inheritDoc} */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { if ($targetEntity->name !== CompanyContract::class) { return ''; @@ -1276,8 +1244,7 @@ public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAli class CompanyEventFilter extends SQLFilter { - /** {@inheritDoc} */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { if ($targetEntity->name !== CompanyEvent::class) { return ''; diff --git a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php index 19b509b4e54..335937972cb 100644 --- a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php @@ -111,10 +111,7 @@ public function testHashing(): void class MyFilter extends SQLFilter { - /** - * {@inheritDoc} - */ - public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias): string + public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string { // getParameter applies quoting automatically return $targetTableAlias . '.id = ' . $this->getParameter('id'); From a02dad303c1fad18ec80dfb1fb2ac9bcaa1470df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 20 Mar 2022 13:08:35 +0100 Subject: [PATCH 056/475] Remove support for entity namespace aliases --- UPGRADE.md | 8 + .../reference/dql-doctrine-query-language.rst | 4 +- lib/Doctrine/ORM/Configuration.php | 62 -------- lib/Doctrine/ORM/EntityManager.php | 23 --- .../ORM/Exception/UnknownEntityNamespace.php | 23 --- .../ORM/Mapping/ClassMetadataFactory.php | 4 +- lib/Doctrine/ORM/Query/Lexer.php | 14 -- lib/Doctrine/ORM/Query/Parser.php | 22 +-- phpstan-baseline.neon | 2 +- psalm.xml | 13 -- .../Doctrine/Tests/ORM/ConfigurationTest.php | 13 -- .../ORM/Functional/EntityRepositoryTest.php | 41 ----- .../Tests/ORM/Functional/NewOperatorTest.php | 54 ------- .../Tests/ORM/Functional/QueryTest.php | 13 -- .../ORM/Functional/Ticket/DDC2256Test.php | 147 ------------------ .../ORM/Mapping/ClassMetadataFactoryTest.php | 35 ----- .../ORM/Query/LanguageRecognitionTest.php | 12 -- tests/Doctrine/Tests/ORM/Query/LexerTest.php | 2 - tests/Doctrine/Tests/ORM/Query/ParserTest.php | 27 ---- 19 files changed, 16 insertions(+), 503 deletions(-) delete mode 100644 lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php diff --git a/UPGRADE.md b/UPGRADE.md index 486462b53e2..b08ff40ce83 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,13 @@ # Upgrade to 3.0 +## Removed: support for entity namespace alias + +- `EntityManager::getRepository()` no longer accepts the entity namespace alias + notation. +- `Configuration::addEntityNamespace()` and + `Configuration::getEntityNamespace()` have been removed. + + ## BC BREAK: Remove helper methods from `AbstractCollectionPersister` The following protected methods of diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index 93abfb55723..289985514f5 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -1592,8 +1592,8 @@ Identifiers /* Alias Identification declaration (the "u" of "FROM User u") */ AliasIdentificationVariable :: = identifier - /* identifier that must be a class name (the "User" of "FROM User u"), possibly as a fully qualified class name or namespace-aliased */ - AbstractSchemaName ::= fully_qualified_name | aliased_name | identifier + /* identifier that must be a class name (the "User" of "FROM User u"), possibly as a fully qualified class name */ + AbstractSchemaName ::= fully_qualified_name | identifier /* Alias ResultVariable declaration (the "total" of "COUNT(*) AS total") */ AliasResultVariable = identifier diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 6aec6df4743..9021960e8f3 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -4,13 +4,9 @@ namespace Doctrine\ORM; -use Doctrine\Common\Persistence\PersistentObject; use Doctrine\Common\Proxy\AbstractProxyFactory; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Exception\InvalidEntityRepository; -use Doctrine\ORM\Exception\NotSupported; -use Doctrine\ORM\Exception\UnknownEntityNamespace; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; @@ -28,10 +24,7 @@ use Psr\Cache\CacheItemPoolInterface; use ReflectionClass; -use function class_exists; -use function sprintf; use function strtolower; -use function trim; /** * Configuration container for all configuration options of Doctrine. @@ -127,61 +120,6 @@ public function setMetadataDriverImpl(MappingDriver $driverImpl) $this->_attributes['metadataDriverImpl'] = $driverImpl; } - /** - * @deprecated No replacement planned. - * - * Adds a namespace under a certain alias. - * - * @param string $alias - * @param string $namespace - * - * @return void - */ - public function addEntityNamespace($alias, $namespace) - { - if (class_exists(PersistentObject::class)) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8818', - 'Short namespace aliases such as "%s" are deprecated and will be removed in Doctrine ORM 3.0.', - $alias - ); - } else { - NotSupported::createForPersistence3(sprintf( - 'Using short namespace alias "%s" by calling %s', - $alias, - __METHOD__ - )); - } - - $this->_attributes['entityNamespaces'][$alias] = $namespace; - } - - /** - * Resolves a registered namespace alias to the full namespace. - * - * @param string $entityNamespaceAlias - * - * @return string - * - * @throws UnknownEntityNamespace - */ - public function getEntityNamespace($entityNamespaceAlias) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8818', - 'Entity short namespace aliases such as "%s" are deprecated, use ::class constant instead.', - $entityNamespaceAlias - ); - - if (! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) { - throw UnknownEntityNamespace::fromNamespaceAlias($entityNamespaceAlias); - } - - return trim($this->_attributes['entityNamespaces'][$entityNamespaceAlias], '\\'); - } - /** * Sets the entity alias map. * diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 5d9ad4d183d..bb0e1e71a86 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -6,20 +6,17 @@ use BadMethodCallException; use Doctrine\Common\EventManager; -use Doctrine\Common\Persistence\PersistentObject; use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Exception\InvalidHydrationMode; use Doctrine\ORM\Exception\ManagerException; use Doctrine\ORM\Exception\MismatchedEventManager; use Doctrine\ORM\Exception\MissingIdentifierField; use Doctrine\ORM\Exception\MissingMappingDriverImplementation; -use Doctrine\ORM\Exception\NotSupported; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Exception\UnrecognizedIdentifierFields; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; @@ -34,12 +31,9 @@ use Throwable; use function array_keys; -use function class_exists; use function is_array; use function is_object; use function ltrim; -use function sprintf; -use function strpos; /** * The EntityManager is the central access point to ORM functionality. @@ -580,23 +574,6 @@ public function lock(object $entity, int $lockMode, $lockVersion = null): void */ public function getRepository($entityName): EntityRepository { - if (strpos($entityName, ':') !== false) { - if (class_exists(PersistentObject::class)) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8818', - 'Short namespace aliases such as "%s" are deprecated and will be removed in Doctrine ORM 3.0.', - $entityName - ); - } else { - NotSupported::createForPersistence3(sprintf( - 'Using short namespace alias "%s" when calling %s', - $entityName, - __METHOD__ - )); - } - } - return $this->repositoryFactory->getRepository($this, $entityName); } diff --git a/lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php b/lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php deleted file mode 100644 index ab1545f8211..00000000000 --- a/lib/Doctrine/ORM/Exception/UnknownEntityNamespace.php +++ /dev/null @@ -1,23 +0,0 @@ -em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; + throw new BadMethodCallException(__METHOD__ . ' is no longer supported by ' . self::class); } /** diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index 6a7108bad13..651c0d0dec7 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -5,7 +5,6 @@ namespace Doctrine\ORM\Query; use Doctrine\Common\Lexer\AbstractLexer; -use Doctrine\Deprecations\Deprecation; use function constant; use function ctype_alpha; @@ -45,8 +44,6 @@ class Lexer extends AbstractLexer public const T_CLOSE_CURLY_BRACE = 19; // All tokens that are identifiers or keywords that could be considered as identifiers should be >= 100 - /** @deprecated No Replacement planned. */ - public const T_ALIASED_NAME = 100; public const T_FULLY_QUALIFIED_NAME = 101; public const T_IDENTIFIER = 102; @@ -175,17 +172,6 @@ protected function getType(&$value) } } - if (str_contains($value, ':')) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8818', - 'Short namespace aliases such as "%s" are deprecated and will be removed in Doctrine ORM 3.0.', - $value - ); - - return self::T_ALIASED_NAME; - } - if (str_contains($value, '\\')) { return self::T_FULLY_QUALIFIED_NAME; } diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index d74010a088e..2ba319c3915 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -70,7 +70,6 @@ use function call_user_func; use function class_exists; use function count; -use function explode; use function implode; use function in_array; use function interface_exists; @@ -1007,7 +1006,7 @@ public function AliasIdentificationVariable() } /** - * AbstractSchemaName ::= fully_qualified_name | aliased_name | identifier + * AbstractSchemaName ::= fully_qualified_name | identifier * * @return string */ @@ -1019,24 +1018,9 @@ public function AbstractSchemaName() return $this->lexer->token['value']; } - if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER)) { - $this->match(Lexer::T_IDENTIFIER); - - return $this->lexer->token['value']; - } - - $this->match(Lexer::T_ALIASED_NAME); - - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8818', - 'Short namespace aliases such as "%s" are deprecated and will be removed in Doctrine ORM 3.0.', - $this->lexer->token['value'] - ); - - [$namespaceAlias, $simpleClassName] = explode(':', $this->lexer->token['value']); + $this->match(Lexer::T_IDENTIFIER); - return $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; + return $this->lexer->token['value']; } /** diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 25dba76d0a1..5b6b614a07c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -671,7 +671,7 @@ parameters: path: lib/Doctrine/ORM/Query/Parser.php - - message: "#^Parameter \\#1 \\$tokenType of method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:isAggregateFunction\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7\\|8\\|9\\|10\\|11\\|12\\|13\\|14\\|15\\|16\\|17\\|18\\|19\\|100\\|101\\|102\\|200\\|201\\|202\\|203\\|204\\|205\\|206\\|207\\|208\\|209\\|210\\|211\\|212\\|213\\|214\\|215\\|216\\|217\\|218\\|219\\|220\\|221\\|222\\|223\\|224\\|225\\|226\\|227\\|228\\|229\\|230\\|231\\|232\\|233\\|234\\|235\\|236\\|237\\|238\\|239\\|240\\|241\\|242\\|243\\|244\\|245\\|246\\|247\\|248\\|249\\|250\\|251\\|252\\|253\\|254\\|255\\|256, int\\|string\\|null given\\.$#" + message: "#^Parameter \\#1 \\$tokenType of method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:isAggregateFunction\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7\\|8\\|9\\|10\\|11\\|12\\|13\\|14\\|15\\|16\\|17\\|18\\|19\\|101\\|102\\|200\\|201\\|202\\|203\\|204\\|205\\|206\\|207\\|208\\|209\\|210\\|211\\|212\\|213\\|214\\|215\\|216\\|217\\|218\\|219\\|220\\|221\\|222\\|223\\|224\\|225\\|226\\|227\\|228\\|229\\|230\\|231\\|232\\|233\\|234\\|235\\|236\\|237\\|238\\|239\\|240\\|241\\|242\\|243\\|244\\|245\\|246\\|247\\|248\\|249\\|250\\|251\\|252\\|253\\|254\\|255\\|256, int\\|string\\|null given\\.$#" count: 2 path: lib/Doctrine/ORM/Query/Parser.php diff --git a/psalm.xml b/psalm.xml index 3e41a92c385..231b8546094 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,19 +17,6 @@ - - - - - - - - - - - - - diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 1514bf0f00a..a1fb3bf7a6d 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -74,19 +74,6 @@ public function testSetGetMetadataDriverImpl(): void self::assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl()); } - public function testSetGetEntityNamespace(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8818'); - - $this->configuration->addEntityNamespace('TestNamespace', __NAMESPACE__); - self::assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace')); - $namespaces = ['OtherNamespace' => __NAMESPACE__]; - $this->configuration->setEntityNamespaces($namespaces); - self::assertSame($namespaces, $this->configuration->getEntityNamespaces()); - $this->expectException(ORMException::class); - $this->configuration->getEntityNamespace('NonExistingNamespace'); - } - public function testSetGetQueryCache(): void { self::assertNull($this->configuration->getQueryCache()); // defaults diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 78a21fc3aee..2123a76b4b7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -32,7 +32,6 @@ use function array_fill; use function array_values; -use function class_exists; use function reset; class EntityRepositoryTest extends OrmFunctionalTestCase @@ -277,25 +276,6 @@ public function testFindAll(): void self::assertCount(4, $users); } - public function testFindByAlias(): void - { - if (! class_exists(PersistentObject::class)) { - $this->markTestSkipped('This test requires doctrine/persistence 2'); - } - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8818'); - - $user1Id = $this->loadFixture(); - $repos = $this->_em->getRepository(CmsUser::class); - - $this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - - $repos = $this->_em->getRepository('CMS:CmsUser'); - - $users = $repos->findAll(); - self::assertCount(4, $users); - } - public function testCount(): void { $this->loadFixture(); @@ -645,27 +625,6 @@ public function testSetDefaultRepositoryInvalidClassError(): void $this->_em->getConfiguration()->setDefaultRepositoryClassName(DDC753InvalidRepository::class); } - /** - * @group DDC-3257 - */ - public function testSingleRepositoryInstanceForDifferentEntityAliases(): void - { - if (! class_exists(PersistentObject::class)) { - $this->markTestSkipped('This test requires doctrine/persistence 2'); - } - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8818'); - $config = $this->_em->getConfiguration(); - - $config->addEntityNamespace('Aliased', 'Doctrine\Tests\Models\CMS'); - $config->addEntityNamespace('AliasedAgain', 'Doctrine\Tests\Models\CMS'); - - $repository = $this->_em->getRepository(CmsUser::class); - - self::assertSame($repository, $this->_em->getRepository('Aliased:CmsUser')); - self::assertSame($repository, $this->_em->getRepository('AliasedAgain:CmsUser')); - } - /** * @group DDC-3257 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php index e85c8190d3e..624ff5f25c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php @@ -213,60 +213,6 @@ public function testShouldAssumeFromEntityNamespaceWhenNotGiven(): void self::assertInstanceOf(CmsUserDTO::class, $result[2]); } - public function testShouldSupportFromEntityNamespaceAlias(): void - { - $dql = ' - SELECT - new CmsUserDTO(u.name, e.email, a.city) - FROM - cms:CmsUser u - JOIN - u.email e - JOIN - u.address a - ORDER BY - u.name'; - - $this->_em->getConfiguration() - ->addEntityNamespace('cms', 'Doctrine\Tests\Models\CMS'); - - $query = $this->_em->createQuery($dql); - $result = $query->getResult(); - - self::assertCount(3, $result); - - self::assertInstanceOf(CmsUserDTO::class, $result[0]); - self::assertInstanceOf(CmsUserDTO::class, $result[1]); - self::assertInstanceOf(CmsUserDTO::class, $result[2]); - } - - public function testShouldSupportValueObjectNamespaceAlias(): void - { - $dql = ' - SELECT - new cms:CmsUserDTO(u.name, e.email, a.city) - FROM - cms:CmsUser u - JOIN - u.email e - JOIN - u.address a - ORDER BY - u.name'; - - $this->_em->getConfiguration() - ->addEntityNamespace('cms', 'Doctrine\Tests\Models\CMS'); - - $query = $this->_em->createQuery($dql); - $result = $query->getResult(); - - self::assertCount(3, $result); - - self::assertInstanceOf(CmsUserDTO::class, $result[0]); - self::assertInstanceOf(CmsUserDTO::class, $result[1]); - self::assertInstanceOf(CmsUserDTO::class, $result[2]); - } - public function testShouldSupportLiteralExpression(): void { $dql = " diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index ea24261260c..9809d8931b2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -496,19 +496,6 @@ public function testModifiedLimitQuery(): void ->getScalarResult(); } - public function testSupportsQueriesWithEntityNamespaces(): void - { - $this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - - try { - $query = $this->_em->createQuery('UPDATE CMS:CmsUser u SET u.name = ?1'); - self::assertEquals('UPDATE cms_users SET name = ?', $query->getSQL()); - $query->free(); - } finally { - $this->_em->getConfiguration()->setEntityNamespaces([]); - } - } - /** * @group DDC-604 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php deleted file mode 100644 index 57a5712a2f5..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php +++ /dev/null @@ -1,147 +0,0 @@ -_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2256User::class), - $this->_em->getClassMetadata(DDC2256Group::class), - ] - ); - } - - public function testIssue(): void - { - if (! class_exists(PersistentObject::class)) { - $this->markTestSkipped('This test requires doctrine/persistence 2'); - } - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8818'); - $config = $this->_em->getConfiguration(); - $config->addEntityNamespace('MyNamespace', __NAMESPACE__); - - $user = new DDC2256User(); - $user->name = 'user'; - $group = new DDC2256Group(); - $group->name = 'group'; - $user->group = $group; - - $this->_em->persist($user); - $this->_em->persist($group); - $this->_em->flush(); - $this->_em->clear(); - - $sql = 'SELECT u.id, u.name, g.id as group_id, g.name as group_name FROM ddc2256_users u LEFT JOIN ddc2256_groups g ON u.group_id = g.id'; - - // Test ResultSetMapping. - $rsm = new ResultSetMapping(); - - $rsm->addEntityResult('MyNamespace:DDC2256User', 'u'); - $rsm->addFieldResult('u', 'id', 'id'); - $rsm->addFieldResult('u', 'name', 'name'); - - $rsm->addJoinedEntityResult('MyNamespace:DDC2256Group', 'g', 'u', 'group'); - $rsm->addFieldResult('g', 'group_id', 'id'); - $rsm->addFieldResult('g', 'group_name', 'name'); - - self::assertCount(1, $this->_em->createNativeQuery($sql, $rsm)->getResult()); - - // Test ResultSetMappingBuilder. - $rsm = new ResultSetMappingBuilder($this->_em); - $rsm->addRootEntityFromClassMetadata('MyNamespace:DDC2256User', 'u'); - $rsm->addJoinedEntityFromClassMetadata('MyNamespace:DDC2256Group', 'g', 'u', 'group', ['id' => 'group_id', 'name' => 'group_name']); - - self::assertCount(1, $this->_em->createNativeQuery($sql, $rsm)->getResult()); - } -} - -/** - * @Entity - * @Table(name="ddc2256_users") - */ -class DDC2256User -{ - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @var string - * @Column(type="string") - */ - public $name; - - /** - * @var DDC2256Group - * @ManyToOne(targetEntity="DDC2256Group", inversedBy="users")A - * @JoinColumn(name="group_id") - */ - public $group; -} - -/** - * @Entity - * @Table(name="ddc2256_groups") - */ -class DDC2256Group -{ - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - public $id; - - /** - * @var string - * @Column(type="string") - */ - public $name; - - /** - * @psalm-var Collection - * @OneToMany(targetEntity="DDC2256User", mappedBy="group") - */ - public $users; - - public function __construct() - { - $this->users = new ArrayCollection(); - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 43b3c228a4d..1d21994db67 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\Common\EventManager; -use Doctrine\Common\Persistence\PersistentObject; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -47,7 +46,6 @@ use function array_search; use function assert; -use function class_exists; use function count; use function sprintf; @@ -196,39 +194,6 @@ public function testIsTransient(): void self::assertFalse($em->getMetadataFactory()->isTransient(CmsArticle::class)); } - /** - * @group DDC-1512 - */ - public function testIsTransientEntityNamespace(): void - { - if (! class_exists(PersistentObject::class)) { - $this->markTestSkipped('This test requires doctrine/persistence 2'); - } - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8818'); - - $cmf = new ClassMetadataFactory(); - $driver = $this->createMock(MappingDriver::class); - $driver->expects(self::exactly(2)) - ->method('isTransient') - ->withConsecutive( - [CmsUser::class], - [CmsArticle::class] - ) - ->willReturnMap( - [ - [CmsUser::class, true], - [CmsArticle::class, false], - ] - ); - - $em = $this->createEntityManager($driver); - $em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - - self::assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); - self::assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); - } - public function testAddDefaultDiscriminatorMap(): void { self::markTestSkipped('This test is just incorrect and must be fixed'); diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index 819ca683c11..4a124c309b5 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -123,8 +123,6 @@ public function invalidDQL(): array ['SELECT \foo FROM Doctrine\Tests\Models\CMS\CmsUser \foo'], ['SELECT foo\ FROM Doctrine\Tests\Models\CMS\CmsUser foo\\'], ['SELECT foo\bar FROM Doctrine\Tests\Models\CMS\CmsUser foo\bar'], - ['SELECT foo:bar FROM Doctrine\Tests\Models\CMS\CmsUser foo:bar'], - ['SELECT foo: FROM Doctrine\Tests\Models\CMS\CmsUser foo:'], /* Checks for invalid AbstractSchemaName */ ['SELECT u FROM UnknownClass u'], // unknown @@ -132,23 +130,13 @@ public function invalidDQL(): array ['SELECT u FROM \Unknown\Class u'], // unknown, leading backslash ['SELECT u FROM Unknown\\\\Class u'], // unknown, syntactically bogus (duplicate \\) ['SELECT u FROM Unknown\Class\ u'], // unknown, syntactically bogus (trailing \) - ['SELECT u FROM Unknown:Class u'], // unknown, with namespace alias - ['SELECT u FROM Unknown::Class u'], // unknown, with PAAMAYIM_NEKUDOTAYIM - ['SELECT u FROM Unknown:Class:Name u'], // unknown, with invalid namespace alias - ['SELECT u FROM UnknownClass: u'], // unknown, with invalid namespace alias - ['SELECT u FROM Unknown:Class: u'], // unknown, with invalid namespace alias ['SELECT u FROM Doctrine\Tests\Models\CMS\\\\CmsUser u'], // syntactically bogus (duplicate \\)array('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser\ u'), // syntactically bogus (trailing \) - ['SELECT u FROM CMS::User u'], - ['SELECT u FROM CMS:User: u'], - ['SELECT u FROM CMS:User:Foo u'], /* Checks for invalid AliasResultVariable */ ['SELECT \'foo\' AS \foo FROM Doctrine\Tests\Models\CMS\CmsUser u'], ['SELECT \'foo\' AS \foo\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'], ['SELECT \'foo\' AS foo\ FROM Doctrine\Tests\Models\CMS\CmsUser u'], ['SELECT \'foo\' AS foo\\\\bar FROM Doctrine\Tests\Models\CMS\CmsUser u'], - ['SELECT \'foo\' AS foo: FROM Doctrine\Tests\Models\CMS\CmsUser u'], - ['SELECT \'foo\' AS foo:bar FROM Doctrine\Tests\Models\CMS\CmsUser u'], ['0'], ]; diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index 15afd69e320..58265b14b16 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -238,8 +238,6 @@ public function provideTokens(): array [Lexer::T_IDENTIFIER, '_some_identifier'], // starts with underscore [Lexer::T_IDENTIFIER, 'comma'], // name of a token class with value < 100 (whitebox test) [Lexer::T_FULLY_QUALIFIED_NAME, 'Some\Class'], // DQL class reference - [Lexer::T_ALIASED_NAME, 'Some:Name'], - [Lexer::T_ALIASED_NAME, 'Some:Subclassed\Name'], ]; } } diff --git a/tests/Doctrine/Tests/ORM/Query/ParserTest.php b/tests/Doctrine/Tests/ORM/Query/ParserTest.php index f29065dd828..2a2a15f9f62 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserTest.php @@ -47,32 +47,6 @@ public function testAbstractSchemaNameSupportsIdentifier(): void self::assertEquals(stdClass::class, $parser->AbstractSchemaName()); } - /** - * @covers \Doctrine\ORM\Query\Parser::AbstractSchemaName - * @group DDC-3715 - */ - public function testAbstractSchemaNameSupportsNamespaceAlias(): void - { - $parser = $this->createParser('CMS:CmsUser'); - - $parser->getEntityManager()->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); - - self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); - } - - /** - * @covers \Doctrine\ORM\Query\Parser::AbstractSchemaName - * @group DDC-3715 - */ - public function testAbstractSchemaNameSupportsNamespaceAliasWithRelativeClassname(): void - { - $parser = $this->createParser('Model:CMS\CmsUser'); - - $parser->getEntityManager()->getConfiguration()->addEntityNamespace('Model', 'Doctrine\Tests\Models'); - - self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); - } - /** * @dataProvider validMatches * @covers Doctrine\ORM\Query\Parser::match @@ -134,7 +108,6 @@ public function invalidMatches(): array // The following are qualified or aliased names and must not be accepted where only an Identifier is expected [Lexer::T_IDENTIFIER, '\\Some\\Class'], [Lexer::T_IDENTIFIER, 'Some\\Class'], - [Lexer::T_IDENTIFIER, 'Some:Name'], ]; } From 6a15af599cb1e0645d5c88d9721efdae72ebec1a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 28 Mar 2022 21:07:55 +0200 Subject: [PATCH 057/475] Remove support for ObjectManagerAware (#9614) --- lib/Doctrine/ORM/UnitOfWork.php | 19 +--- .../ORM/Functional/Ticket/DDC2231Test.php | 87 ------------------- 2 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index b6d88b91810..53513a7951a 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -35,7 +35,6 @@ use Doctrine\ORM\Persisters\Entity\SingleTablePersister; use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\Persistence\NotifyPropertyChanged; -use Doctrine\Persistence\ObjectManagerAware; use Doctrine\Persistence\PropertyChangedListener; use Exception; use InvalidArgumentException; @@ -2150,17 +2149,6 @@ public function isCollectionScheduledForDeletion(PersistentCollection $coll): bo return isset($this->collectionDeletions[spl_object_id($coll)]); } - private function newInstance(ClassMetadata $class): object - { - $entity = $class->newInstance(); - - if ($entity instanceof ObjectManagerAware) { - $entity->injectObjectManager($this->em, $class); - } - - return $entity; - } - /** * INTERNAL: * Creates an entity. Used for reconstitution of persistent entities. @@ -2225,14 +2213,9 @@ public function createEntity(string $className, array $data, array &$hints = []) } } - // inject ObjectManager upon refresh. - if ($entity instanceof ObjectManagerAware) { - $entity->injectObjectManager($this->em, $class); - } - $this->originalEntityData[$oid] = $data; } else { - $entity = $this->newInstance($class); + $entity = $class->newInstance(); $oid = spl_object_id($entity); $this->entityIdentifiers[$oid] = $id; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php deleted file mode 100644 index 92163f4a518..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2231Test.php +++ /dev/null @@ -1,87 +0,0 @@ -_schemaTool->createSchema( - [ - $this->_em->getClassMetadata(DDC2231EntityY::class), - ] - ); - } - - public function testInjectObjectManagerInProxyIfInitializedInUow(): void - { - $y1 = new DDC2231EntityY(); - - $this->_em->persist($y1); - - $this->_em->flush(); - $this->_em->clear(); - - $y1ref = $this->_em->getReference(get_class($y1), $y1->id); - - self::assertInstanceOf(Proxy::class, $y1ref); - self::assertFalse($y1ref->__isInitialized__); - - $id = $y1ref->doSomething(); - - self::assertTrue($y1ref->__isInitialized__); - self::assertEquals($this->_em, $y1ref->om); - } -} - - -/** - * @Entity - * @Table(name="ddc2231_y") - */ -class DDC2231EntityY implements ObjectManagerAware -{ - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - public $id; - - /** @var ObjectManager */ - public $om; - - public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata): void - { - $this->om = $objectManager; - } - - public function getId(): int - { - return $this->id; - } - - public function doSomething(): void - { - } -} From 30591eaf564eef1cc68f7b03e72c87f0c152dcc0 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 4 Apr 2022 17:36:54 +0200 Subject: [PATCH 058/475] Add native types to ResultSetMapping (#9620) --- lib/Doctrine/ORM/Query/ResultSetMapping.php | 174 +++++++----------- .../ORM/Query/ResultSetMappingBuilder.php | 90 ++++----- phpstan-baseline.neon | 6 +- psalm-baseline.xml | 21 +-- 4 files changed, 99 insertions(+), 192 deletions(-) diff --git a/lib/Doctrine/ORM/Query/ResultSetMapping.php b/lib/Doctrine/ORM/Query/ResultSetMapping.php index 66ea0c0aaea..a77b94466dc 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMapping.php +++ b/lib/Doctrine/ORM/Query/ResultSetMapping.php @@ -25,17 +25,15 @@ class ResultSetMapping * Whether the result is mixed (contains scalar values together with field values). * * @ignore - * @var bool */ - public $isMixed = false; + public bool $isMixed = false; /** * Whether the result is a select statement. * * @ignore - * @var bool */ - public $isSelect = true; + public bool $isSelect = true; /** * Maps alias names to class names. @@ -43,7 +41,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $aliasMap = []; + public array $aliasMap = []; /** * Maps alias names to related association field names. @@ -51,7 +49,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $relationMap = []; + public array $relationMap = []; /** * Maps alias names to parent alias names. @@ -59,7 +57,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $parentAliasMap = []; + public array $parentAliasMap = []; /** * Maps column names in the result set to field names for each class. @@ -67,15 +65,15 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $fieldMappings = []; + public array $fieldMappings = []; /** * Maps column names in the result set to the alias/field name to use in the mapped result. * * @ignore - * @psalm-var array + * @psalm-var array */ - public $scalarMappings = []; + public array $scalarMappings = []; /** * Maps column names in the result set to the alias/field type to use in the mapped result. @@ -83,7 +81,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $typeMappings = []; + public array $typeMappings = []; /** * Maps entities in the result set to the alias name to use in the mapped result. @@ -91,7 +89,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $entityMappings = []; + public array $entityMappings = []; /** * Maps column names of meta columns (foreign keys, discriminator columns, ...) to field names. @@ -99,7 +97,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $metaMappings = []; + public array $metaMappings = []; /** * Maps column names in the result set to the alias they belong to. @@ -107,7 +105,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $columnOwnerMap = []; + public array $columnOwnerMap = []; /** * List of columns in the result set that are used as discriminator columns. @@ -115,7 +113,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $discriminatorColumns = []; + public array $discriminatorColumns = []; /** * Maps alias names to field names that should be used for indexing. @@ -123,7 +121,7 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $indexByMap = []; + public array $indexByMap = []; /** * Map from column names to class names that declare the field the column is mapped to. @@ -131,35 +129,35 @@ class ResultSetMapping * @ignore * @psalm-var array */ - public $declaringClasses = []; + public array $declaringClasses = []; /** * This is necessary to hydrate derivate foreign keys correctly. * * @psalm-var array> */ - public $isIdentifierColumn = []; + public array $isIdentifierColumn = []; /** * Maps column names in the result set to field names for each new object expression. * * @psalm-var array> */ - public $newObjectMappings = []; + public array $newObjectMappings = []; /** * Maps metadata parameter names to the metadata attribute. * * @psalm-var array */ - public $metadataParameterMapping = []; + public array $metadataParameterMapping = []; /** * Contains query parameter names to be resolved as discriminator values * * @psalm-var array */ - public $discriminatorParameters = []; + public array $discriminatorParameters = []; /** * Adds an entity result to this ResultSetMapping. @@ -169,12 +167,13 @@ class ResultSetMapping * results or joined entity results within this ResultSetMapping. * @param string|null $resultAlias The result alias with which the entity result should be * placed in the result structure. + * @psalm-param class-string $class * * @return $this * * @todo Rename: addRootEntity */ - public function addEntityResult($class, $alias, $resultAlias = null) + public function addEntityResult(string $class, string $alias, ?string $resultAlias = null): static { $this->aliasMap[$alias] = $class; $this->entityMappings[$alias] = $resultAlias; @@ -199,7 +198,7 @@ public function addEntityResult($class, $alias, $resultAlias = null) * * @todo Rename: addDiscriminatorColumn */ - public function setDiscriminatorColumn($alias, $discrColumn) + public function setDiscriminatorColumn(string $alias, string $discrColumn): static { $this->discriminatorColumns[$alias] = $discrColumn; $this->columnOwnerMap[$discrColumn] = $alias; @@ -215,7 +214,7 @@ public function setDiscriminatorColumn($alias, $discrColumn) * * @return $this */ - public function addIndexBy($alias, $fieldName) + public function addIndexBy(string $alias, string $fieldName): static { $found = false; @@ -248,11 +247,9 @@ public function addIndexBy($alias, $fieldName) /** * Sets to index by a scalar result column name. * - * @param string $resultColumnName - * * @return $this */ - public function addIndexByScalar($resultColumnName) + public function addIndexByScalar(string $resultColumnName): static { $this->indexByMap['scalars'] = $resultColumnName; @@ -262,12 +259,9 @@ public function addIndexByScalar($resultColumnName) /** * Sets a column to use for indexing an entity or joined entity result by the given alias name. * - * @param string $alias - * @param string $resultColumnName - * * @return $this */ - public function addIndexByColumn($alias, $resultColumnName) + public function addIndexByColumn(string $alias, string $resultColumnName): static { $this->indexByMap[$alias] = $resultColumnName; @@ -278,13 +272,9 @@ public function addIndexByColumn($alias, $resultColumnName) * Checks whether an entity result or joined entity result with a given alias has * a field set for indexing. * - * @param string $alias - * - * @return bool - * * @todo Rename: isIndexed($alias) */ - public function hasIndexBy($alias) + public function hasIndexBy(string $alias): bool { return isset($this->indexByMap[$alias]); } @@ -295,11 +285,9 @@ public function hasIndexBy($alias) * * @param string $columnName The name of the column in the SQL result set. * - * @return bool - * * @todo Rename: isField */ - public function isFieldResult($columnName) + public function isFieldResult(string $columnName): bool { return isset($this->fieldMappings[$columnName]); } @@ -315,12 +303,13 @@ public function isFieldResult($columnName) * the field $fieldName is defined on a subclass, specify that here. * If not specified, the field is assumed to belong to the class * designated by $alias. + * @psalm-param class-string|null $declaringClass * * @return $this * * @todo Rename: addField */ - public function addFieldResult($alias, $columnName, $fieldName, $declaringClass = null) + public function addFieldResult(string $alias, string $columnName, string $fieldName, ?string $declaringClass = null): static { // column name (in result set) => field name $this->fieldMappings[$columnName] = $fieldName; @@ -344,12 +333,13 @@ public function addFieldResult($alias, $columnName, $fieldName, $declaringClass * @param string $parentAlias The alias of the entity result that is the parent of this joined result. * @param string $relation The association field that connects the parent entity result * with the joined entity result. + * @psalm-param class-string $class * * @return $this * * @todo Rename: addJoinedEntity */ - public function addJoinedEntityResult($class, $alias, $parentAlias, $relation) + public function addJoinedEntityResult(string $class, string $alias, string $parentAlias, string $relation): static { $this->aliasMap[$alias] = $class; $this->parentAliasMap[$alias] = $parentAlias; @@ -361,15 +351,15 @@ public function addJoinedEntityResult($class, $alias, $parentAlias, $relation) /** * Adds a scalar result mapping. * - * @param string $columnName The name of the column in the SQL result set. - * @param string $alias The result alias with which the scalar result should be placed in the result structure. - * @param string $type The column type + * @param string $columnName The name of the column in the SQL result set. + * @param string|int $alias The result alias with which the scalar result should be placed in the result structure. + * @param string $type The column type * * @return $this * * @todo Rename: addScalar */ - public function addScalarResult($columnName, $alias, $type = 'string') + public function addScalarResult(string $columnName, string|int $alias, string $type = 'string'): static { $this->scalarMappings[$columnName] = $alias; $this->typeMappings[$columnName] = $type; @@ -383,13 +373,8 @@ public function addScalarResult($columnName, $alias, $type = 'string') /** * Adds a metadata parameter mappings. - * - * @param mixed $parameter The parameter name in the SQL result set. - * @param string $attribute The metadata attribute. - * - * @return void */ - public function addMetadataParameterMapping($parameter, $attribute) + public function addMetadataParameterMapping(string|int $parameter, string $attribute): void { $this->metadataParameterMapping[$parameter] = $attribute; } @@ -397,13 +382,9 @@ public function addMetadataParameterMapping($parameter, $attribute) /** * Checks whether a column with a given name is mapped as a scalar result. * - * @param string $columnName The name of the column in the SQL result set. - * - * @return bool - * * @todo Rename: isScalar */ - public function isScalarResult($columnName) + public function isScalarResult(string $columnName): bool { return isset($this->scalarMappings[$columnName]); } @@ -412,11 +393,9 @@ public function isScalarResult($columnName) * Gets the name of the class of an entity result or joined entity result, * identified by the given unique alias. * - * @param string $alias - * - * @return class-string + * @psalm-return class-string */ - public function getClassName($alias) + public function getClassName(string $alias): string { return $this->aliasMap[$alias]; } @@ -425,10 +404,8 @@ public function getClassName($alias) * Gets the field alias for a column that is mapped as a scalar value. * * @param string $columnName The name of the column in the SQL result set. - * - * @return string */ - public function getScalarAlias($columnName) + public function getScalarAlias(string $columnName): string|int { return $this->scalarMappings[$columnName]; } @@ -436,79 +413,51 @@ public function getScalarAlias($columnName) /** * Gets the name of the class that owns a field mapping for the specified column. * - * @param string $columnName - * - * @return class-string + * @psalm-return class-string */ - public function getDeclaringClass($columnName) + public function getDeclaringClass(string $columnName): string { return $this->declaringClasses[$columnName]; } - /** - * @param string $alias - * - * @return string - */ - public function getRelation($alias) + public function getRelation(string $alias): string { return $this->relationMap[$alias]; } - /** - * @param string $alias - * - * @return bool - */ - public function isRelation($alias) + public function isRelation(string $alias): bool { return isset($this->relationMap[$alias]); } /** * Gets the alias of the class that owns a field mapping for the specified column. - * - * @param string $columnName - * - * @return string */ - public function getEntityAlias($columnName) + public function getEntityAlias(string $columnName): string { return $this->columnOwnerMap[$columnName]; } /** * Gets the parent alias of the given alias. - * - * @param string $alias - * - * @return string */ - public function getParentAlias($alias) + public function getParentAlias(string $alias): string { return $this->parentAliasMap[$alias]; } /** * Checks whether the given alias has a parent alias. - * - * @param string $alias - * - * @return bool */ - public function hasParentAlias($alias) + public function hasParentAlias(string $alias): bool { return isset($this->parentAliasMap[$alias]); } /** * Gets the field name for a column name. - * - * @param string $columnName - * - * @return string */ - public function getFieldName($columnName) + public function getFieldName(string $columnName): string { return $this->fieldMappings[$columnName]; } @@ -516,7 +465,7 @@ public function getFieldName($columnName) /** * @psalm-return array */ - public function getAliasMap() + public function getAliasMap(): array { return $this->aliasMap; } @@ -524,10 +473,9 @@ public function getAliasMap() /** * Gets the number of different entities that appear in the mapped result. * - * @return int * @psalm-return 0|positive-int */ - public function getEntityResultCount() + public function getEntityResultCount(): int { return count($this->aliasMap); } @@ -538,10 +486,8 @@ public function getEntityResultCount() * Mixed results can only occur in object and array (graph) hydration. In such a * case a mixed result means that scalar values are mixed with objects/array in * the result. - * - * @return bool */ - public function isMixedResult() + public function isMixedResult(): bool { return $this->isMixed; } @@ -549,18 +495,22 @@ public function isMixedResult() /** * Adds a meta column (foreign key or discriminator column) to the result set. * - * @param string $alias The result alias with which the meta result should be placed in the result structure. - * @param string $columnName The name of the column in the SQL result set. - * @param string $fieldName The name of the field on the declaring class. - * @param bool $isIdentifierColumn - * @param string $type The column type + * @param string $alias The result alias with which the meta result should be placed in the result structure. + * @param string $columnName The name of the column in the SQL result set. + * @param string $fieldName The name of the field on the declaring class. + * @param string|null $type The column type * * @return $this * * @todo Make all methods of this class require all parameters and not infer anything */ - public function addMetaResult($alias, $columnName, $fieldName, $isIdentifierColumn = false, $type = null) - { + public function addMetaResult( + string $alias, + string $columnName, + string $fieldName, + bool $isIdentifierColumn = false, + ?string $type = null + ): static { $this->metaMappings[$columnName] = $fieldName; $this->columnOwnerMap[$columnName] = $alias; diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 38bb5aefcf3..cce51d72559 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -43,26 +43,15 @@ class ResultSetMappingBuilder extends ResultSetMapping */ public const COLUMN_RENAMING_INCREMENT = 3; - /** @var int */ - private $sqlCounter = 0; - - /** @var EntityManagerInterface */ - private $em; - - /** - * Default column renaming mode. - * - * @var int - */ - private $defaultRenameMode; + private int $sqlCounter = 0; /** - * @param int $defaultRenameMode + * @psalm-param self::COLUMN_RENAMING_* $defaultRenameMode */ - public function __construct(EntityManagerInterface $em, $defaultRenameMode = self::COLUMN_RENAMING_NONE) - { - $this->em = $em; - $this->defaultRenameMode = $defaultRenameMode; + public function __construct( + private EntityManagerInterface $em, + private int $defaultRenameMode = self::COLUMN_RENAMING_NONE, + ) { } /** @@ -71,13 +60,16 @@ public function __construct(EntityManagerInterface $em, $defaultRenameMode = sel * @param string $class The class name of the root entity. * @param string $alias The unique alias to use for the root entity. * @param string[] $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). - * @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). + * @psalm-param class-string $class * @psalm-param array $renamedColumns - * - * @return void + * @psalm-param self::COLUMN_RENAMING_*|null $renameMode */ - public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = [], $renameMode = null) - { + public function addRootEntityFromClassMetadata( + string $class, + string $alias, + array $renamedColumns = [], + ?int $renameMode = null + ): void { $renameMode = $renameMode ?: $this->defaultRenameMode; $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); @@ -94,13 +86,18 @@ public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = * @param string $relation The association field that connects the parent entity result * with the joined entity result. * @param string[] $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). - * @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). + * @psalm-param class-string $class * @psalm-param array $renamedColumns - * - * @return void + * @psalm-param self::COLUMN_RENAMING_*|null $renameMode */ - public function addJoinedEntityFromClassMetadata($class, $alias, $parentAlias, $relation, $renamedColumns = [], $renameMode = null) - { + public function addJoinedEntityFromClassMetadata( + string $class, + string $alias, + string $parentAlias, + string $relation, + array $renamedColumns = [], + ?int $renameMode = null + ): void { $renameMode = $renameMode ?: $this->defaultRenameMode; $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); @@ -111,16 +108,12 @@ public function addJoinedEntityFromClassMetadata($class, $alias, $parentAlias, $ /** * Adds all fields of the given class to the result set mapping (columns and meta fields). * - * @param string $class - * @param string $alias * @param string[] $columnAliasMap * @psalm-param array $columnAliasMap * - * @return void - * * @throws InvalidArgumentException */ - protected function addAllClassFields($class, $alias, $columnAliasMap = []) + protected function addAllClassFields(string $class, string $alias, array $columnAliasMap = []): void { $classMetadata = $this->em->getClassMetadata($class); $platform = $this->em->getConnection()->getDatabasePlatform(); @@ -182,25 +175,17 @@ private function isInheritanceSupported(ClassMetadataInfo $classMetadata): bool * Gets column alias for a given column. * * @psalm-param array $customRenameColumns + * + * @psalm-assert self::COLUMN_RENAMING_* $mode */ private function getColumnAlias(string $columnName, int $mode, array $customRenameColumns): string { - switch ($mode) { - case self::COLUMN_RENAMING_INCREMENT: - return $columnName . $this->sqlCounter++; - - case self::COLUMN_RENAMING_CUSTOM: - return $customRenameColumns[$columnName] ?? $columnName; - - case self::COLUMN_RENAMING_NONE: - return $columnName; - - default: - throw new InvalidArgumentException(sprintf( - '%d is not a valid value for $mode', - $mode - )); - } + return match ($mode) { + self::COLUMN_RENAMING_INCREMENT => $columnName . $this->sqlCounter++, + self::COLUMN_RENAMING_CUSTOM => $customRenameColumns[$columnName] ?? $columnName, + self::COLUMN_RENAMING_NONE => $columnName, + default => throw new InvalidArgumentException(sprintf('%d is not a valid value for $mode', $mode)), + }; } /** @@ -251,10 +236,8 @@ private function getColumnAliasMap( * * @param string[] $tableAliases * @psalm-param array $tableAliases - * - * @return string */ - public function generateSelectClause($tableAliases = []) + public function generateSelectClause(array $tableAliases = []): string { $sql = ''; @@ -289,10 +272,7 @@ public function generateSelectClause($tableAliases = []) return $sql; } - /** - * @return string - */ - public function __toString() + public function __toString(): string { return $this->generateSelectClause([]); } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 60481e3ec8b..d75de9caa6d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -730,11 +730,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/SqlWalker.php - - - message: "#^Parameter \\#2 \\$alias of method Doctrine\\\\ORM\\\\Query\\\\ResultSetMapping\\:\\:addScalarResult\\(\\) expects string, int given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Result of && is always false\\.$#" count: 2 @@ -1314,3 +1309,4 @@ parameters: message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#" count: 1 path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9598b2193bd..5210129ad64 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2049,21 +2049,6 @@ Comparison::EQ - - - $this->aliasMap - $this->aliasMap - $this->declaringClasses - - - - - $class - $class - $renameMode - $renameMode - - $likeExpr->stringPattern instanceof AST\Functions\FunctionNode @@ -2093,11 +2078,7 @@ $this->scalarResultAliasMap $this->scalarResultAliasMap - - $resultAlias - $resultAlias - $resultAlias - $resultAlias + $this->queryComponents[$expr]['token']['value'] $this->queryComponents[$factor]['token']['value'] $this->queryComponents[$term]['token']['value'] From b7ff9db6e71244f2b21b37176cc7fc1501e1e2b7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 8 Apr 2022 01:25:27 +0200 Subject: [PATCH 059/475] Remove deprecated handling of custom ObjectRepository implementations (#9634) --- UPGRADE.md | 10 +++- lib/Doctrine/ORM/Configuration.php | 14 +---- .../Repository/DefaultRepositoryFactory.php | 31 ++-------- .../ORM/Repository/RepositoryFactory.php | 6 +- psalm-baseline.xml | 15 ++--- .../Doctrine/Tests/ORM/ConfigurationTest.php | 58 ------------------- 6 files changed, 24 insertions(+), 110 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index ec99ed100e0..d408bdc511f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,13 +1,19 @@ # Upgrade to 3.0 -## Removed: support for entity namespace alias +## BC BREAK: Repository classes have to extend `EntityRepository` + +Although undocumented, it was possible to configure a custom repository +class that implements `ObjectRepository` but does not extend the +`EntityRepository` base class. Repository classes have to extend +`EntityRepository` now. + +## BC BREAK: Removed support for entity namespace alias - `EntityManager::getRepository()` no longer accepts the entity namespace alias notation. - `Configuration::addEntityNamespace()` and `Configuration::getEntityNamespace()` have been removed. - ## BC BREAK: Remove helper methods from `AbstractCollectionPersister` The following protected methods of diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index ebf6e7278b9..872adff0c3d 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -5,7 +5,6 @@ namespace Doctrine\ORM; use Doctrine\Common\Proxy\AbstractProxyFactory; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Exception\InvalidEntityRepository; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; @@ -21,7 +20,6 @@ use Doctrine\ORM\Repository\DefaultRepositoryFactory; use Doctrine\ORM\Repository\RepositoryFactory; use Doctrine\Persistence\Mapping\Driver\MappingDriver; -use Doctrine\Persistence\ObjectRepository; use Psr\Cache\CacheItemPoolInterface; use function class_exists; @@ -456,20 +454,10 @@ public function getFilterClassName($name) */ public function setDefaultRepositoryClassName($className) { - if (! class_exists($className) || ! is_a($className, ObjectRepository::class, true)) { + if (! class_exists($className) || ! is_a($className, EntityRepository::class, true)) { throw InvalidEntityRepository::fromClassName($className); } - if (! is_a($className, EntityRepository::class, true)) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9533', - 'Configuring %s as default repository class is deprecated because it does not extend %s.', - $className, - EntityRepository::class - ); - } - $this->_attributes['defaultRepositoryClassName'] = $className; } diff --git a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php b/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php index 66f42470f43..c8c640d3785 100644 --- a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php +++ b/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Repository; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\Persistence\ObjectRepository; @@ -20,22 +19,15 @@ final class DefaultRepositoryFactory implements RepositoryFactory * The list of EntityRepository instances. * * @var ObjectRepository[] - * @psalm-var array + * @psalm-var array */ - private $repositoryList = []; + private array $repositoryList = []; - /** - * {@inheritdoc} - */ - public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository + public function getRepository(EntityManagerInterface $entityManager, string $entityName): EntityRepository { $repositoryHash = $entityManager->getClassMetadata($entityName)->getName() . spl_object_id($entityManager); - if (isset($this->repositoryList[$repositoryHash])) { - return $this->repositoryList[$repositoryHash]; - } - - return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName); + return $this->repositoryList[$repositoryHash] ??= $this->createRepository($entityManager, $entityName); } /** @@ -47,22 +39,11 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName private function createRepository( EntityManagerInterface $entityManager, string $entityName - ): ObjectRepository { + ): EntityRepository { $metadata = $entityManager->getClassMetadata($entityName); $repositoryClassName = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName(); - $repository = new $repositoryClassName($entityManager, $metadata); - if (! $repository instanceof EntityRepository) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9533', - 'Configuring %s as repository class is deprecated because it does not extend %s.', - $repositoryClassName, - EntityRepository::class - ); - } - - return $repository; + return new $repositoryClassName($entityManager, $metadata); } } diff --git a/lib/Doctrine/ORM/Repository/RepositoryFactory.php b/lib/Doctrine/ORM/Repository/RepositoryFactory.php index 5b00ca01d40..e066eae4e58 100644 --- a/lib/Doctrine/ORM/Repository/RepositoryFactory.php +++ b/lib/Doctrine/ORM/Repository/RepositoryFactory.php @@ -5,7 +5,7 @@ namespace Doctrine\ORM\Repository; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\Persistence\ObjectRepository; +use Doctrine\ORM\EntityRepository; /** * Interface for entity repository factory. @@ -18,9 +18,9 @@ interface RepositoryFactory * @param EntityManagerInterface $entityManager The EntityManager instance. * @param class-string $entityName The name of the entity. * - * @return ObjectRepository This type will change to {@see EntityRepository} in 3.0. + * @return EntityRepository * * @template T of object */ - public function getRepository(EntityManagerInterface $entityManager, $entityName); + public function getRepository(EntityManagerInterface $entityManager, string $entityName): EntityRepository; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4d5456ec23c..3b81c740366 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -205,12 +205,6 @@ ClassMetadataFactory Mapping\ClassMetadata - - $this->repositoryFactory->getRepository($this, $entityName) - - - EntityRepository<T> - $entity $entity @@ -2324,9 +2318,12 @@ - - $repository instanceof EntityRepository - + + $this->repositoryList[$repositoryHash] ??= $this->createRepository($entityManager, $entityName) + + + EntityRepository + new $repositoryClassName($entityManager, $metadata) diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 6423540dfa8..23d61c96163 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -13,14 +13,11 @@ use Doctrine\ORM\Mapping as AnnotationNamespace; use Doctrine\ORM\Mapping\EntityListenerResolver; use Doctrine\ORM\Mapping\NamingStrategy; -use Doctrine\ORM\Mapping\PrePersist; use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\Persistence\Mapping\Driver\MappingDriver; -use Doctrine\Persistence\ObjectRepository; use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\DDC753\DDC753CustomRepository; use Psr\Cache\CacheItemPoolInterface; -use stdClass; /** * Tests for the Configuration object @@ -171,14 +168,6 @@ public function setDefaultRepositoryClassName(): void $this->configuration->setDefaultRepositoryClassName(self::class); } - public function testSetDeprecatedDefaultRepositoryClassName(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9533'); - - $this->configuration->setDefaultRepositoryClassName(DeprecatedRepository::class); - self::assertSame(DeprecatedRepository::class, $this->configuration->getDefaultRepositoryClassName()); - } - public function testSetGetNamingStrategy(): void { self::assertInstanceOf(NamingStrategy::class, $this->configuration->getNamingStrategy()); @@ -219,50 +208,3 @@ public function testSetGetSecondLevelCacheConfig(): void self::assertEquals($mockClass, $this->configuration->getSecondLevelCacheConfiguration()); } } - -class ConfigurationTestAnnotationReaderChecker -{ - /** @PrePersist */ - public function simpleAnnotationMethod(): void - { - } - - /** @AnnotationNamespace\PrePersist */ - public function namespacedAnnotationMethod(): void - { - } -} - -class DeprecatedRepository implements ObjectRepository -{ - /** - * {@inheritdoc} - */ - public function find($id) - { - return null; - } - - public function findAll(): array - { - return []; - } - - public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array - { - return []; - } - - /** - * {@inheritdoc} - */ - public function findOneBy(array $criteria) - { - return null; - } - - public function getClassName(): string - { - return stdClass::class; - } -} From 7ef5f7004d85e2c18e127e40097b3811f984b26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 13 Apr 2018 23:34:46 +0200 Subject: [PATCH 060/475] Document exception-splitting-related BC-breaks Closes #7194 --- UPGRADE.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index d408bdc511f..2de7b0ab41b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,6 +1,42 @@ # Upgrade to 3.0 -## BC BREAK: Repository classes have to extend `EntityRepository` +## BC Break: `Exception\ORMException` is no longer a class, but an interface + +All methods in `Doctrine\ORM\ORMException` have been extracted to dedicated exceptions. + + * `missingMappingDriverImpl()` => `Exception\MissingMappingDriverImplementation::create()` + * `unrecognizedField()` => `Persisters\Exception\UnrecognizedField::byName()` + * `unexpectedAssociationValue()` => `Exception\UnexpectedAssociationValue::create()` + * `invalidOrientation()` => `Persisters\Exception\InvalidOrientation::fromClassNameAndField()` + * `entityManagerClosed()` => `Exception\EntityManagerClosed::create()` + * `invalidHydrationMode()` => `Exception\InvalidHydrationMode::fromMode()` + * `mismatchedEventManager()` => `Exception\MismatchedEventManager::create()` + * `findByRequiresParameter()` => `Repository\Exception\InvalidMagicMethodCall::onMissingParameter()` + * `invalidMagicCall()` => `Repository\Exception\InvalidMagicMethodCall::becauseFieldNotFoundIn()` + * `invalidFindByInverseAssociation()` => `Repository\Exception\InvalidFindByCall::fromInverseSideUsage()` + * `invalidResultCacheDriver()` => `Cache\Exception\InvalidResultCacheDriver::create()` + * `notSupported()` => `Exception\NotSupported::create()` + * `queryCacheNotConfigured()` => `QueryCacheNotConfigured::create()` + * `metadataCacheNotConfigured()` => `Cache\Exception\MetadataCacheNotConfigured::create()` + * `queryCacheUsesNonPersistentCache()` => `Cache\Exception\QueryCacheUsesNonPersistentCache::fromDriver()` + * `metadataCacheUsesNonPersistentCache()` => `Cache\Exception\MetadataCacheUsesNonPersistentCache::fromDriver()` + * `proxyClassesAlwaysRegenerating()` => `Exception\ProxyClassesAlwaysRegenerating::create()` + * `invalidEntityRepository()` => `Exception\InvalidEntityRepository::fromClassName()` + * `missingIdentifierField()` => `Exception\MissingIdentifierField::fromFieldAndClass()` + * `unrecognizedIdentifierFields()` => `Exception\UnrecognizedIdentifierFields::fromClassAndFieldNames()` + * `cantUseInOperatorOnCompositeKeys()` => `Persisters\Exception\CantUseInOperatorOnCompositeKeys::create()` + +## BC Break: `CacheException` is no longer a class, but an interface + +All methods in `Doctrine\ORM\Cache\CacheException` have been extracted to dedicated exceptions. + + * `updateReadOnlyCollection()` => `Cache\Exception\CannotUpdateReadOnlyCollection::fromEntityAndField()` + * `updateReadOnlyEntity()` => `Cache\Exception\CannotUpdateReadOnlyEntity::fromEntity()` + * `nonCacheableEntity()` => `Cache\Exception\NonCacheableEntity::fromEntity()` + * `nonCacheableEntityAssociation()` => `Cache\Exception\NonCacheableEntityAssociation::fromEntityAndField()` + + +## BC Break: Missing type declaration added for identifier generators Although undocumented, it was possible to configure a custom repository class that implements `ObjectRepository` but does not extend the From 29a3495c8b7b51313ab413b9cb0cf40353393d15 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 11 Apr 2022 12:43:41 +0200 Subject: [PATCH 061/475] Remove console helper (#9640) --- UPGRADE.md | 19 ++++++++ .../Command/AbstractEntityManagerCommand.php | 15 +----- .../ORM/Tools/Console/ConsoleRunner.php | 34 ++------------ .../HelperSetManagerProvider.php | 46 ------------------ .../Console/Helper/EntityManagerHelper.php | 47 ------------------- .../Tools/Console/Command/InfoCommandTest.php | 19 ++------ .../ORM/Tools/Console/ConsoleRunnerTest.php | 21 +-------- 7 files changed, 32 insertions(+), 169 deletions(-) delete mode 100644 lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/HelperSetManagerProvider.php delete mode 100644 lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php diff --git a/UPGRADE.md b/UPGRADE.md index 982fd25109a..77fd3284ab0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,24 @@ # Upgrade to 3.0 +## BC Break: Removed `EntityManagerHelper` and related logic + +All console commands require a `$entityManagerProvider` to be passed via the +constructor. Commands won't try to get the entity manager from a previously +registered `em` console helper. + +The following classes have been removed: + +* `Doctrine\ORM\Tools\Console\EntityManagerProvider\HelperSetManagerProvider` +* `Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper` + +The following breaking changes have been applied to `Doctrine\ORM\Tools\Console\ConsoleRunner`: + +* The method `createHelperSet()` has been removed. +* The methods `run()` and `createApplication()` don't accept an instance of + `HelperSet` as first argument anymore. +* The method `addCommands()` requires an instance of `EntityManagerProvider` + as second argument now. + ## BC Break: `Exception\ORMException` is no longer a class, but an interface All methods in `Doctrine\ORM\ORMException` have been extracted to dedicated exceptions. diff --git a/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php index 77256a4a528..1da54248d93 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Tools\Console\Command; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Tools\Console\EntityManagerProvider; use Symfony\Component\Console\Command\Command; @@ -12,25 +11,13 @@ abstract class AbstractEntityManagerCommand extends Command { - public function __construct(private ?EntityManagerProvider $entityManagerProvider = null) + public function __construct(private EntityManagerProvider $entityManagerProvider) { parent::__construct(); } final protected function getEntityManager(InputInterface $input): EntityManagerInterface { - // This is a backwards compatibility required check for commands extending Doctrine ORM commands - if (! $input->hasOption('em') || $this->entityManagerProvider === null) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8327', - 'Not passing EntityManagerProvider as a dependency to command class "%s" is deprecated', - $this->getName() - ); - - return $this->getHelper('em')->getEntityManager(); - } - return $input->getOption('em') === null ? $this->entityManagerProvider->getDefaultManager() : $this->entityManagerProvider->getManager($input->getOption('em')); diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index 821e70a9be2..c0ae650d3cc 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -6,14 +6,10 @@ use Composer\InstalledVersions; use Doctrine\DBAL\Tools\Console as DBALConsole; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Tools\Console\EntityManagerProvider\ConnectionFromManagerProvider; -use Doctrine\ORM\Tools\Console\EntityManagerProvider\HelperSetManagerProvider; -use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use OutOfBoundsException; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command as SymfonyCommand; -use Symfony\Component\Console\Helper\HelperSet; use function assert; @@ -22,24 +18,14 @@ */ final class ConsoleRunner { - /** - * Create a Symfony Console HelperSet - * - * @deprecated This method will be removed in ORM 3.0 without replacement. - */ - public static function createHelperSet(EntityManagerInterface $entityManager): HelperSet - { - return new HelperSet(['em' => new EntityManagerHelper($entityManager)]); - } - /** * Runs console with the given helper set. * * @param SymfonyCommand[] $commands */ - public static function run(HelperSet|EntityManagerProvider $helperSetOrProvider, array $commands = []): void + public static function run(EntityManagerProvider $entityManagerProvider, array $commands = []): void { - $cli = self::createApplication($helperSetOrProvider, $commands); + $cli = self::createApplication($entityManagerProvider, $commands); $cli->run(); } @@ -52,7 +38,7 @@ public static function run(HelperSet|EntityManagerProvider $helperSetOrProvider, * @throws OutOfBoundsException */ public static function createApplication( - HelperSet|EntityManagerProvider $helperSetOrProvider, + EntityManagerProvider $entityManagerProvider, array $commands = [] ): Application { $version = InstalledVersions::getVersion('doctrine/orm'); @@ -61,24 +47,14 @@ public static function createApplication( $cli = new Application('Doctrine Command Line Interface', $version); $cli->setCatchExceptions(true); - if ($helperSetOrProvider instanceof HelperSet) { - $cli->setHelperSet($helperSetOrProvider); - - $helperSetOrProvider = new HelperSetManagerProvider($helperSetOrProvider); - } - - self::addCommands($cli, $helperSetOrProvider); + self::addCommands($cli, $entityManagerProvider); $cli->addCommands($commands); return $cli; } - public static function addCommands(Application $cli, ?EntityManagerProvider $entityManagerProvider = null): void + public static function addCommands(Application $cli, EntityManagerProvider $entityManagerProvider): void { - if ($entityManagerProvider === null) { - $entityManagerProvider = new HelperSetManagerProvider($cli->getHelperSet()); - } - $connectionProvider = new ConnectionFromManagerProvider($entityManagerProvider); $cli->addCommands( diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/HelperSetManagerProvider.php b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/HelperSetManagerProvider.php deleted file mode 100644 index 41f43efe291..00000000000 --- a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/HelperSetManagerProvider.php +++ /dev/null @@ -1,46 +0,0 @@ -getDefaultManager(); - } - - public function getDefaultManager(): EntityManagerInterface - { - $helper = $this->helperSet->get('entityManager'); - - assert($helper instanceof EntityManagerHelper); - - return $helper->getEntityManager(); - } -} diff --git a/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php b/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php deleted file mode 100644 index f8c8744e6ca..00000000000 --- a/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php +++ /dev/null @@ -1,47 +0,0 @@ -_em = $em; - } - - /** - * Retrieves Doctrine ORM EntityManager. - */ - public function getEntityManager(): EntityManagerInterface - { - return $this->_em; - } - - public function getName(): string - { - return 'entityManager'; - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php index 021e77ec282..c1573a36d25 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php @@ -9,25 +9,18 @@ use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Tools\Console\Command\InfoCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; -use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Tests\Models\Cache\AttractionInfo; use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\OrmFunctionalTestCase; use Symfony\Component\Console\Application; -use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Tester\CommandTester; class InfoCommandTest extends OrmFunctionalTestCase { - /** @var Application */ - private $application; - - /** @var InfoCommand */ - private $command; - - /** @var CommandTester */ - private $tester; + private Application $application; + private InfoCommand $command; + private CommandTester $tester; protected function setUp(): void { @@ -65,8 +58,7 @@ public function testEmptyEntityClassNames(): void ->willReturn($configuration); $application = new Application(); - $application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($em)])); - $application->add(new InfoCommand()); + $application->add(new InfoCommand(new SingleManagerProvider($em))); $command = $application->find('orm:info'); $tester = new CommandTester($command); @@ -104,8 +96,7 @@ public function testInvalidEntityClassMetadata(): void ->willThrowException(new MappingException('exception message')); $application = new Application(); - $application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($em)])); - $application->add(new InfoCommand()); + $application->add(new InfoCommand(new SingleManagerProvider($em))); $command = $application->find('orm:info'); $tester = new CommandTester($command); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php index 3cfe53fb238..0a154649769 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php @@ -5,12 +5,10 @@ namespace Doctrine\Tests\ORM\Tools\Console; use Composer\InstalledVersions; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Tools\Console\ConsoleRunner; use Doctrine\ORM\Tools\Console\EntityManagerProvider; use Doctrine\Tests\DoctrineTestCase; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Helper\HelperSet; /** * @group DDC-3186 @@ -18,18 +16,11 @@ */ final class ConsoleRunnerTest extends DoctrineTestCase { - use VerifyDeprecations; - public function testCreateApplicationShouldReturnAnApplicationWithTheCorrectCommands(): void { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8327'); - - $helperSet = new HelperSet(); - $app = ConsoleRunner::createApplication($helperSet); + $app = ConsoleRunner::createApplication($this->createStub(EntityManagerProvider::class)); - self::assertSame($helperSet, $app->getHelperSet()); self::assertSame(InstalledVersions::getVersion('doctrine/orm'), $app->getVersion()); - self::assertTrue($app->has('dbal:reserved-words')); self::assertTrue($app->has('dbal:run-sql')); self::assertTrue($app->has('orm:clear-cache:region:collection')); @@ -52,16 +43,8 @@ public function testCreateApplicationShouldReturnAnApplicationWithTheCorrectComm public function testCreateApplicationShouldAppendGivenCommands(): void { $command = 'my:lovely-command'; - $app = ConsoleRunner::createApplication(new HelperSet(), [new Command($command)]); + $app = ConsoleRunner::createApplication($this->createStub(EntityManagerProvider::class), [new Command($command)]); self::assertTrue($app->has($command)); } - - public function testCreateApplicationWithProvider(): void - { - $provider = $this->createMock(EntityManagerProvider::class); - $app = ConsoleRunner::createApplication($provider, []); - - self::assertTrue($app->has('orm:info')); - } } From a5ad24c0fddccc3c731ccd0f94252a3a8861f2cb Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 Apr 2022 20:09:39 +0200 Subject: [PATCH 062/475] Drop support for persistence 2 (#9665) * Drop support for persistence 2 * Switch to the common static analysis job --- .github/workflows/static-analysis.yml | 76 +-------------- composer.json | 4 +- .../ORM/Decorator/EntityManagerDecorator.php | 17 +--- lib/Doctrine/ORM/EntityManager.php | 92 ++++-------------- lib/Doctrine/ORM/EntityManagerInterface.php | 9 +- lib/Doctrine/ORM/EntityRepository.php | 11 +-- .../ORM/Mapping/ClassMetadataFactory.php | 83 ++++------------- .../ORM/Mapping/ClassMetadataInfo.php | 93 ++++--------------- lib/Doctrine/ORM/UnitOfWork.php | 7 +- phpstan-baseline.neon | 1 + psalm-baseline.xml | 49 ++++------ .../Mock/NonProxyLoadingEntityManager.php | 60 +++--------- .../Doctrine/Tests/ORM/EntityManagerTest.php | 37 +------- .../ORM/Functional/PersistentObjectTest.php | 89 ------------------ .../ORM/Mapping/ClassMetadataFactoryTest.php | 21 +---- 15 files changed, 115 insertions(+), 534 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 1de0ed34082..0e2a253610e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,74 +10,8 @@ on: - "*.x" jobs: - static-analysis-phpstan: - name: "Static Analysis with PHPStan" - runs-on: "ubuntu-20.04" - - strategy: - fail-fast: false - matrix: - php-version: - - "8.1" - dbal-version: - - "default" - persistence-version: - - "default" - include: - - php-version: "8.1" - dbal-version: "default" - persistence-version: "2.5" - - steps: - - name: "Checkout code" - uses: "actions/checkout@v2" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "${{ matrix.php-version }}" - - - name: "Require specific DBAL version" - run: "composer require doctrine/dbal ^${{ matrix.dbal-version }} --no-update" - if: "${{ matrix.dbal-version != 'default' }}" - - - name: "Require specific persistence version" - run: "composer require doctrine/persistence ^${{ matrix.persistence-version }} --no-update" - if: "${{ matrix.persistence-version != 'default' }}" - - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v1" - with: - dependency-versions: "highest" - - - name: "Run a static analysis with phpstan/phpstan" - run: "vendor/bin/phpstan analyse" - - static-analysis-psalm: - name: "Static Analysis with Psalm" - runs-on: "ubuntu-20.04" - - strategy: - fail-fast: false - matrix: - php-version: - - "8.1" - - steps: - - name: "Checkout code" - uses: "actions/checkout@v2" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "${{ matrix.php-version }}" - - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v1" - with: - dependency-versions: "highest" - - - name: "Run a static analysis with vimeo/psalm" - run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)" + static-analysis: + name: "Static Analysis" + uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.4.1" + with: + php-version: "8.1" diff --git a/composer.json b/composer.json index c6c3ac9f904..e2d96df7c22 100644 --- a/composer.json +++ b/composer.json @@ -24,14 +24,14 @@ "composer-runtime-api": "^2", "ext-ctype": "*", "doctrine/collections": "^1.5", - "doctrine/common": "^3.0.3", + "doctrine/common": "^3.3", "doctrine/dbal": "^3.3", "doctrine/deprecations": "^0.5.3", "doctrine/event-manager": "^1.1", "doctrine/inflector": "^1.4 || ^2.0", "doctrine/instantiator": "^1.3", "doctrine/lexer": "^1.2.3", - "doctrine/persistence": "^2.4 || ^3", + "doctrine/persistence": "^3", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0" }, diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index 751464e58d7..3687505bb1c 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -35,7 +35,7 @@ public function __construct(EntityManagerInterface $wrapped) $this->wrapped = $wrapped; } - public function getRepository($className): EntityRepository + public function getRepository(string $className): EntityRepository { return $this->wrapped->getRepository($className); } @@ -45,10 +45,7 @@ public function getMetadataFactory(): ClassMetadataFactory return $this->wrapped->getMetadataFactory(); } - /** - * {@inheritdoc} - */ - public function getClassMetadata($className): ClassMetadata + public function getClassMetadata(string $className): ClassMetadata { return $this->wrapped->getClassMetadata($className); } @@ -127,10 +124,7 @@ public function lock(object $entity, int $lockMode, $lockVersion = null): void $this->wrapped->lock($entity, $lockMode, $lockVersion); } - /** - * {@inheritdoc} - */ - public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object + public function find(string $className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object { return $this->wrapped->find($className, $id, $lockMode, $lockVersion); } @@ -155,10 +149,7 @@ public function getUnitOfWork(): UnitOfWork return $this->wrapped->getUnitOfWork(); } - /** - * {@inheritdoc} - */ - public function newHydrator($hydrationMode): AbstractHydrator + public function newHydrator(string|int $hydrationMode): AbstractHydrator { return $this->wrapped->newHydrator($hydrationMode); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 03e6be3b71f..2f84fb31b58 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -5,7 +5,6 @@ namespace Doctrine\ORM; use BackedEnum; -use BadMethodCallException; use Doctrine\Common\EventManager; use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; @@ -219,7 +218,7 @@ public function rollback(): void * * {@inheritDoc} */ - public function getClassMetadata($className): Mapping\ClassMetadata + public function getClassMetadata(string $className): Mapping\ClassMetadata { return $this->metadataFactory->getMetadataFor($className); } @@ -442,17 +441,9 @@ public function getPartialReference(string $entityName, $identifier): ?object /** * Clears the EntityManager. All entities that are currently managed * by this EntityManager become detached. - * - * @param string|null $objectName The object name (not supported). - * - * @throws ORMInvalidArgumentException If the caller attempted to clear the EM partially by passing an object name. */ - public function clear($objectName = null): void + public function clear(): void { - if ($objectName !== null) { - throw new ORMInvalidArgumentException('Clearing the entity manager partially if not supported.'); - } - $this->unitOfWork->clear(); } @@ -472,20 +463,14 @@ public function close(): void * NOTE: The persist operation always considers entities that are not yet known to * this EntityManager as NEW. Do not pass detached entities to the persist operation. * - * @param object $entity The instance to make managed and persistent. - * * @throws ORMInvalidArgumentException * @throws ORMException */ - public function persist($entity): void + public function persist(object $object): void { - if (! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#persist()', $entity); - } - $this->errorIfClosed(); - $this->unitOfWork->persist($entity); + $this->unitOfWork->persist($object); } /** @@ -494,40 +479,28 @@ public function persist($entity): void * A removed entity will be removed from the database at or before transaction commit * or as a result of the flush operation. * - * @param object $entity The entity instance to remove. - * * @throws ORMInvalidArgumentException * @throws ORMException */ - public function remove($entity): void + public function remove(object $object): void { - if (! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#remove()', $entity); - } - $this->errorIfClosed(); - $this->unitOfWork->remove($entity); + $this->unitOfWork->remove($object); } /** * Refreshes the persistent state of an entity from the database, * overriding any local changes that have not yet been persisted. * - * @param object $entity The entity to refresh. - * * @throws ORMInvalidArgumentException * @throws ORMException */ - public function refresh($entity): void + public function refresh(object $object): void { - if (! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#refresh()', $entity); - } - $this->errorIfClosed(); - $this->unitOfWork->refresh($entity); + $this->unitOfWork->refresh($object); } /** @@ -537,29 +510,11 @@ public function refresh($entity): void * Entities which previously referenced the detached entity will continue to * reference it. * - * @param object $entity The entity to detach. - * * @throws ORMInvalidArgumentException */ - public function detach($entity): void - { - if (! is_object($entity)) { - throw ORMInvalidArgumentException::invalidObject('EntityManager#detach()', $entity); - } - - $this->unitOfWork->detach($entity); - } - - /** - * Not supported. - * - * @param object $object - * - * @psalm-return never - */ - public function merge($object): object + public function detach(object $object): void { - throw new BadMethodCallException('The merge operation is not supported.'); + $this->unitOfWork->detach($object); } /** @@ -573,31 +528,28 @@ public function lock(object $entity, int $lockMode, $lockVersion = null): void /** * Gets the repository for an entity class. * - * @param string $entityName The name of the entity. - * @psalm-param class-string $entityName + * @psalm-param class-string $className * * @return ObjectRepository|EntityRepository The repository class. * @psalm-return EntityRepository * * @template T of object */ - public function getRepository($entityName): EntityRepository + public function getRepository(string $className): EntityRepository { - return $this->repositoryFactory->getRepository($this, $entityName); + return $this->repositoryFactory->getRepository($this, $className); } /** * Determines whether an entity instance is managed in this EntityManager. * - * @param object $entity - * * @return bool TRUE if this EntityManager currently manages the given entity, FALSE otherwise. */ - public function contains($entity): bool + public function contains(object $object): bool { - return $this->unitOfWork->isScheduledForInsert($entity) - || $this->unitOfWork->isInIdentityMap($entity) - && ! $this->unitOfWork->isScheduledForDelete($entity); + return $this->unitOfWork->isScheduledForInsert($object) + || $this->unitOfWork->isInIdentityMap($object) + && ! $this->unitOfWork->isScheduledForDelete($object); } public function getEventManager(): EventManager @@ -632,10 +584,7 @@ public function getUnitOfWork(): UnitOfWork return $this->unitOfWork; } - /** - * {@inheritDoc} - */ - public function newHydrator($hydrationMode): AbstractHydrator + public function newHydrator(string|int $hydrationMode): AbstractHydrator { switch ($hydrationMode) { case Query::HYDRATE_OBJECT: @@ -672,10 +621,7 @@ public function getProxyFactory(): ProxyFactory return $this->proxyFactory; } - /** - * {@inheritDoc} - */ - public function initializeObject($obj): void + public function initializeObject(object $obj): void { $this->unitOfWork->initializeObject($obj); } diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index 2b4758f2036..2d4383b6553 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -28,7 +28,7 @@ interface EntityManagerInterface extends ObjectManager * * @template T of object */ - public function getRepository($className): EntityRepository; + public function getRepository(string $className): EntityRepository; /** * Returns the cache API for managing the second level cache regions or NULL if the cache is not enabled. @@ -130,7 +130,7 @@ public function createQueryBuilder(): QueryBuilder; * * @template T of object */ - public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object; + public function find(string $className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object; /** * Gets a reference to the entity identified by the given type and identifier @@ -214,12 +214,11 @@ public function getUnitOfWork(): UnitOfWork; /** * Create a new instance for the given hydration mode. * - * @param string|int $hydrationMode * @psalm-param string|AbstractQuery::HYDRATE_* $hydrationMode * * @throws ORMException */ - public function newHydrator($hydrationMode): AbstractHydrator; + public function newHydrator(string|int $hydrationMode): AbstractHydrator; /** * Gets the proxy factory used by the EntityManager to create entity proxies. @@ -250,5 +249,5 @@ public function hasFilters(): bool; * * @psalm-template T of object */ - public function getClassMetadata($className): Mapping\ClassMetadata; + public function getClassMetadata(string $className): Mapping\ClassMetadata; } diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index d5325e73986..3335fc0ccf2 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -101,15 +101,11 @@ public function findAll(): array /** * Finds entities by a set of criteria. * - * @param int|null $limit - * @param int|null $offset - * @psalm-param array $criteria - * @psalm-param array|null $orderBy + * {@inheritdoc} * - * @return object[] The objects. * @psalm-return list */ - public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array { $persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName); @@ -122,8 +118,7 @@ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $ * @psalm-param array $criteria * @psalm-param array|null $orderBy * - * @return object|null The entity instance or NULL if the entity can not be found. - * @psalm-return ?T + * @psalm-return T|null */ public function findOneBy(array $criteria, ?array $orderBy = null): ?object { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index c8369923a0e..86e55d023fb 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Mapping; -use BadMethodCallException; use Doctrine\Common\EventManager; use Doctrine\DBAL\Platforms; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -49,43 +48,27 @@ */ class ClassMetadataFactory extends AbstractClassMetadataFactory { - /** @var EntityManagerInterface|null */ - private $em; - - /** @var AbstractPlatform|null */ - private $targetPlatform; - - /** @var MappingDriver */ - private $driver; - - /** @var EventManager */ - private $evm; + private ?EntityManagerInterface $em = null; + private ?AbstractPlatform $targetPlatform = null; + private ?MappingDriver $driver = null; + private ?EventManager $evm = null; /** @var mixed[] */ - private $embeddablesActiveNesting = []; + private array $embeddablesActiveNesting = []; - /** - * @return void - */ - public function setEntityManager(EntityManagerInterface $em) + public function setEntityManager(EntityManagerInterface $em): void { $this->em = $em; } - /** - * {@inheritDoc} - */ - protected function initialize() + protected function initialize(): void { $this->driver = $this->em->getConfiguration()->getMetadataDriverImpl(); $this->evm = $this->em->getEventManager(); $this->initialized = true; } - /** - * {@inheritDoc} - */ - protected function onNotFoundMetadata($className) + protected function onNotFoundMetadata(string $className): ?ClassMetadata { if (! $this->evm->hasListeners(Events::onClassMetadataNotFound)) { return null; @@ -103,8 +86,12 @@ protected function onNotFoundMetadata($className) /** * {@inheritDoc} */ - protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents) - { + protected function doLoadMetadata( + ClassMetadataInterface $class, + ?ClassMetadataInterface $parent, + bool $rootEntityFound, + array $nonSuperclassParents + ): void { if ($parent) { $class->setInheritanceType($parent->inheritanceType); $class->setDiscriminatorColumn($parent->discriminatorColumn); @@ -232,14 +219,9 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS /** * Validate runtime metadata is correctly defined. * - * @param ClassMetadata $class - * @param ClassMetadataInterface|null $parent - * - * @return void - * * @throws MappingException */ - protected function validateRuntimeMetadata($class, $parent) + protected function validateRuntimeMetadata(ClassMetadata $class, ?ClassMetadataInterface $parent): void { if (! $class->reflClass) { // only validate if there is a reflection class instance @@ -281,10 +263,7 @@ protected function validateRuntimeMetadata($class, $parent) } } - /** - * {@inheritDoc} - */ - protected function newClassMetadataInstance($className) + protected function newClassMetadataInstance(string $className): ClassMetadata { return new ClassMetadata($className, $this->em->getConfiguration()->getNamingStrategy()); } @@ -648,44 +627,22 @@ private function inheritIdGeneratorMapping(ClassMetadataInfo $class, ClassMetada } } - /** - * {@inheritDoc} - */ - protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService) + protected function wakeupReflection(ClassMetadataInterface $class, ReflectionService $reflService): void { - assert($class instanceof ClassMetadata); $class->wakeupReflection($reflService); } - /** - * {@inheritDoc} - */ - protected function initializeReflection(ClassMetadataInterface $class, ReflectionService $reflService) + protected function initializeReflection(ClassMetadataInterface $class, ReflectionService $reflService): void { - assert($class instanceof ClassMetadata); $class->initializeReflection($reflService); } - /** - * @deprecated This method will be removed in ORM 3.0. - */ - protected function getFqcnFromAlias($namespaceAlias, $simpleClassName): string - { - throw new BadMethodCallException(__METHOD__ . ' is no longer supported by ' . self::class); - } - - /** - * {@inheritDoc} - */ - protected function getDriver() + protected function getDriver(): MappingDriver { return $this->driver; } - /** - * {@inheritDoc} - */ - protected function isEntity(ClassMetadataInterface $class) + protected function isEntity(ClassMetadataInterface $class): bool { return ! $class->isMappedSuperclass; } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index da490d180f3..42c96cb4c66 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1232,13 +1232,8 @@ public function isChangeTrackingNotify() /** * Checks whether a field is part of the identifier/primary key field(s). - * - * @param string $fieldName The field name. - * - * @return bool TRUE if the field is part of the table identifier/primary key field(s), - * FALSE otherwise. */ - public function isIdentifier($fieldName) + public function isIdentifier(string $fieldName): bool { if (! $this->identifier) { return false; @@ -2016,7 +2011,7 @@ protected function _validateAndCompleteManyToManyMapping(array $mapping) /** * {@inheritDoc} */ - public function getIdentifierFieldNames() + public function getIdentifierFieldNames(): array { return $this->identifier; } @@ -2073,15 +2068,12 @@ public function setIdentifier(array $identifier) /** * {@inheritDoc} */ - public function getIdentifier() + public function getIdentifier(): array { return $this->identifier; } - /** - * {@inheritDoc} - */ - public function hasField($fieldName) + public function hasField(string $fieldName): bool { return isset($this->fieldMappings[$fieldName]) || isset($this->embeddedClasses[$fieldName]); } @@ -2229,13 +2221,9 @@ public function isIdentifierNatural() /** * Gets the type of a field. * - * @param string $fieldName - * - * @return string|null - * * @todo 3.0 Remove this. PersisterHelper should fix it somehow */ - public function getTypeOfField($fieldName) + public function getTypeOfField(string $fieldName): ?string { return isset($this->fieldMappings[$fieldName]) ? $this->fieldMappings[$fieldName]['type'] @@ -2988,27 +2976,18 @@ public function addDiscriminatorMapClass($name, $className) } } - /** - * {@inheritDoc} - */ - public function hasAssociation($fieldName) + public function hasAssociation(string $fieldName): bool { return isset($this->associationMappings[$fieldName]); } - /** - * {@inheritDoc} - */ - public function isSingleValuedAssociation($fieldName) + public function isSingleValuedAssociation(string $fieldName): bool { return isset($this->associationMappings[$fieldName]) && ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); } - /** - * {@inheritDoc} - */ - public function isCollectionValuedAssociation($fieldName) + public function isCollectionValuedAssociation(string $fieldName): bool { return isset($this->associationMappings[$fieldName]) && ! ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); @@ -3230,7 +3209,7 @@ public function markReadOnly() /** * {@inheritDoc} */ - public function getFieldNames() + public function getFieldNames(): array { return array_keys($this->fieldMappings); } @@ -3238,7 +3217,7 @@ public function getFieldNames() /** * {@inheritDoc} */ - public function getAssociationNames() + public function getAssociationNames(): array { return array_keys($this->associationMappings); } @@ -3246,64 +3225,30 @@ public function getAssociationNames() /** * {@inheritDoc} * - * @param string $assocName - * - * @return string * @psalm-return class-string * * @throws InvalidArgumentException */ - public function getAssociationTargetClass($assocName) + public function getAssociationTargetClass(string $assocName): string { - if (! isset($this->associationMappings[$assocName])) { - throw new InvalidArgumentException("Association name expected, '" . $assocName . "' is not an association."); - } - - return $this->associationMappings[$assocName]['targetEntity']; + return $this->associationMappings[$assocName]['targetEntity'] + ?? throw new InvalidArgumentException("Association name expected, '" . $assocName . "' is not an association."); } - /** - * {@inheritDoc} - */ - public function getName() + public function getName(): string { return $this->name; } - /** - * {@inheritDoc} - */ - public function isAssociationInverseSide($fieldName) + public function isAssociationInverseSide(string $assocName): bool { - return isset($this->associationMappings[$fieldName]) - && ! $this->associationMappings[$fieldName]['isOwningSide']; + return isset($this->associationMappings[$assocName]) + && ! $this->associationMappings[$assocName]['isOwningSide']; } - /** - * {@inheritDoc} - */ - public function getAssociationMappedByTargetField($fieldName) + public function getAssociationMappedByTargetField(string $assocName): string { - return $this->associationMappings[$fieldName]['mappedBy']; - } - - /** - * @param string $targetClass - * - * @return mixed[][] - * @psalm-return array> - */ - public function getAssociationsByTargetClass($targetClass) - { - $relations = []; - - foreach ($this->associationMappings as $mapping) { - if ($mapping['targetEntity'] === $targetClass) { - $relations[$mapping['fieldName']] = $mapping; - } - } - - return $relations; + return $this->associationMappings[$assocName]['mappedBy']; } /** diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index e6c7189a1ef..2ffc928b3e6 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2724,12 +2724,9 @@ public function registerManaged(object $entity, array $id, array $data): void /** * Notifies this UnitOfWork of a property change in an entity. * - * @param object $sender The entity that owns the property. - * @param string $propertyName The name of the property that changed. - * @param mixed $oldValue The old value of the property. - * @param mixed $newValue The new value of the property. + * {@inheritdoc} */ - public function propertyChanged($sender, $propertyName, mixed $oldValue, mixed $newValue): void + public function propertyChanged(object $sender, string $propertyName, mixed $oldValue, mixed $newValue): void { $oid = spl_object_id($sender); $class = $this->em->getClassMetadata(get_class($sender)); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e3d76257e4f..d64e07b5320 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1279,3 +1279,4 @@ parameters: message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#" count: 1 path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ff9e99f5fda..0a1952a8eed 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -184,12 +184,6 @@ ltrim($entityName, '\\') ltrim($entityName, '\\') - - is_object($entity) - is_object($entity) - is_object($entity) - is_object($entity) - $entity $entity @@ -209,14 +203,6 @@ ClassMetadataFactory Mapping\ClassMetadata - - $entity - $entity - $entity - $entity - $entity - $entityName - $config->getProxyDir() $config->getProxyNamespace() @@ -241,8 +227,8 @@ new LazyCriteriaCollection($persister, $criteria) - ?T AbstractLazyCollection<int, T>&Selectable<int, T> + T|null @@ -367,10 +353,12 @@ $subClass->table[$indexType][$indexName] - - $driver - $evm - + + MappingDriver + + + $this->driver + $subClass->table[$indexType][$indexName] @@ -381,26 +369,25 @@ $this->em $this->em - - $this->em->getConfiguration()->getMetadataDriverImpl() - - + + getAllClassNames getConfiguration getConfiguration getConfiguration getConfiguration getConnection + hasListeners + hasListeners + loadMetadataForClass $subClass->table - + $parent->generatorType $parent->generatorType $parent->idGenerator $parent->idGenerator - assert($class instanceof ClassMetadata) - assert($class instanceof ClassMetadata) @@ -457,10 +444,8 @@ $this->reflFields[$name] $this->reflFields[$this->identifier[0]] - + $entity - $fieldName - $fieldName $class @@ -1133,6 +1118,9 @@ $metadata->isEmbeddedClass $metadata->isMappedSuperclass + + $property->name + $property->name @@ -1890,10 +1878,11 @@ strrpos($fromClassName, '\\') - + $AST $conditionalExpression $expr + $field $pathExp $this->ConditionalExpression() $this->ConditionalExpression() diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index a1f3b0a648b..4526f2dcba0 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -51,10 +51,7 @@ public function getMetadataFactory(): ClassMetadataFactory return $this->realEntityManager->getMetadataFactory(); } - /** - * {@inheritDoc} - */ - public function getClassMetadata($className): ClassMetadata + public function getClassMetadata(string $className): ClassMetadata { return $this->realEntityManager->getClassMetadata($className); } @@ -181,58 +178,32 @@ public function hasFilters(): bool return $this->realEntityManager->hasFilters(); } - /** - * {@inheritDoc} - */ - public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object + public function find(string $className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object { return $this->realEntityManager->find($className, $id, $lockMode, $lockVersion); } - /** - * {@inheritDoc} - */ - public function persist($object): void + public function persist(object $object): void { $this->realEntityManager->persist($object); } - /** - * {@inheritDoc} - */ - public function remove($object): void + public function remove(object $object): void { $this->realEntityManager->remove($object); } - /** - * {@inheritDoc} - */ - public function merge($object): object - { - return $this->realEntityManager->merge($object); - } - - /** - * {@inheritDoc} - */ - public function clear($objectName = null): void + public function clear(): void { - $this->realEntityManager->clear($objectName); + $this->realEntityManager->clear(); } - /** - * {@inheritDoc} - */ - public function detach($object): void + public function detach(object $object): void { $this->realEntityManager->detach($object); } - /** - * {@inheritDoc} - */ - public function refresh($object): void + public function refresh(object $object): void { $this->realEntityManager->refresh($object); } @@ -242,26 +213,17 @@ public function flush(): void $this->realEntityManager->flush(); } - /** - * {@inheritDoc} - */ - public function getRepository($className): EntityRepository + public function getRepository(string $className): EntityRepository { return $this->realEntityManager->getRepository($className); } - /** - * {@inheritDoc} - */ - public function initializeObject($obj): void + public function initializeObject(object $obj): void { $this->realEntityManager->initializeObject($obj); } - /** - * {@inheritDoc} - */ - public function contains($object): bool + public function contains(object $object): bool { return $this->realEntityManager->contains($object); } diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 4a63c50c951..692509b8687 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -7,16 +7,15 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\ORM\Configuration; -use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Mapping\ClassMetadataFactory; -use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\UnitOfWork; +use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmTestCase; use Generator; @@ -25,8 +24,7 @@ class EntityManagerTest extends OrmTestCase { - /** @var EntityManager */ - private $entityManager; + private EntityManagerMock $entityManager; protected function setUp(): void { @@ -121,30 +119,6 @@ public function testCreateQuery(): void self::assertEquals('SELECT 1', $q->getDql()); } - /** - * @psalm-return list - */ - public static function dataMethodsAffectedByNoObjectArguments(): array - { - return [ - ['persist'], - ['remove'], - ['refresh'], - ['detach'], - ]; - } - - /** - * @dataProvider dataMethodsAffectedByNoObjectArguments - */ - public function testThrowsExceptionOnNonObjectValues($methodName): void - { - $this->expectException(ORMInvalidArgumentException::class); - $this->expectExceptionMessage('EntityManager#' . $methodName . '() expects parameter 1 to be an entity object, NULL given.'); - - $this->entityManager->$methodName(null); - } - /** * @psalm-return list */ @@ -190,10 +164,7 @@ public function dataToBeReturnedByWrapInTransaction(): Generator public function testWrapInTransactionAcceptsReturn(mixed $expectedValue): void { $return = $this->entityManager->wrapInTransaction( - /** @return mixed */ - static function (EntityManagerInterface $em) use ($expectedValue) { - return $expectedValue; - } + static fn (EntityManagerInterface $em): mixed => $expectedValue ); $this->assertSame($expectedValue, $return); @@ -212,7 +183,7 @@ public function testWrapInTransactionReThrowsThrowables(): void }); self::fail('TypeError expected to be thrown'); - } catch (TypeError $ignored) { + } catch (TypeError) { self::assertFalse($this->entityManager->isOpen()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php deleted file mode 100644 index 33434839cec..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php +++ /dev/null @@ -1,89 +0,0 @@ -createSchemaForModels(PersistentEntity::class); - - PersistentObject::setObjectManager($this->_em); - } - - public function testPersist(): void - { - $entity = new PersistentEntity(); - $entity->setName('test'); - - $this->_em->persist($entity); - $this->_em->flush(); - - $this->addToAssertionCount(1); - } - - public function testFind(): void - { - $entity = new PersistentEntity(); - $entity->setName('test'); - - $this->_em->persist($entity); - $this->_em->flush(); - $this->_em->clear(); - - $entity = $this->_em->find(PersistentEntity::class, $entity->getId()); - - self::assertEquals('test', $entity->getName()); - $entity->setName('foobar'); - - $this->_em->flush(); - } - - public function testGetReference(): void - { - $entity = new PersistentEntity(); - $entity->setName('test'); - - $this->_em->persist($entity); - $this->_em->flush(); - $this->_em->clear(); - - $entity = $this->_em->getReference(PersistentEntity::class, $entity->getId()); - - self::assertEquals('test', $entity->getName()); - } - - public function testSetAssociation(): void - { - $entity = new PersistentEntity(); - $entity->setName('test'); - $entity->setParent($entity); - - $this->_em->persist($entity); - $this->_em->flush(); - $this->_em->clear(); - - $entity = $this->_em->getReference(PersistentEntity::class, $entity->getId()); - self::assertSame($entity, $entity->getParent()); - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 1d21994db67..6b24e615caf 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -515,19 +515,10 @@ final class Cube extends Shape class ClassMetadataFactoryTestSubject extends ClassMetadataFactory { /** @psalm-var array, ClassMetadata> */ - private $mockMetadata = []; + private array $mockMetadata = []; - /** @psalm-var list> */ - private $requestedClasses = []; - - /** - * @psalm-param class-string $className - * - * @override - */ - protected function newClassMetadataInstance($className): ClassMetadata + protected function newClassMetadataInstance(string $className): ClassMetadata { - $this->requestedClasses[] = $className; if (! isset($this->mockMetadata[$className])) { throw new InvalidArgumentException(sprintf( 'No mock metadata found for class %s.', @@ -545,14 +536,6 @@ public function setMetadataForClass(string $className, ClassMetadata $metadata): { $this->mockMetadata[$className] = $metadata; } - - /** - * @return list> - */ - public function getRequestedClasses(): array - { - return $this->requestedClasses; - } } class TestEntity1 From aebd3f30cbbe53f13bcad01fa92e85b376206f74 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 Apr 2022 22:46:50 +0200 Subject: [PATCH 063/475] Remove the doctrine binary (#9662) --- UPGRADE.md | 10 +++ bin/doctrine | 4 -- bin/doctrine-pear.php | 43 ------------- bin/doctrine.bat | 9 --- bin/doctrine.php | 62 ------------------- composer.json | 1 - .../ORM/Tools/Console/ConsoleRunner.php | 24 ------- 7 files changed, 10 insertions(+), 143 deletions(-) delete mode 100755 bin/doctrine delete mode 100644 bin/doctrine-pear.php delete mode 100644 bin/doctrine.bat delete mode 100644 bin/doctrine.php diff --git a/UPGRADE.md b/UPGRADE.md index 95c71ff57ad..c0a32aaab44 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade to 3.0 +## BC Break: Removed the `doctrine` binary. + +The documentation explains how the console tools can be bootstrapped for +standalone usage: + +https://www.doctrine-project.org/projects/doctrine-orm/en/stable/reference/tools.html + +The method `ConsoleRunner::printCliConfigTemplate()` has been removed as well +because it was only useful in the context of the `doctrine` binary. + ## BC Break: Removed `EntityManagerHelper` and related logic All console commands require a `$entityManagerProvider` to be passed via the diff --git a/bin/doctrine b/bin/doctrine deleted file mode 100755 index 83d38042920..00000000000 --- a/bin/doctrine +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env php -register(); - -$classLoader = new \Doctrine\Common\ClassLoader('Symfony'); -$classLoader->register(); - -$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; - -$helperSet = null; -if (file_exists($configFile)) { - if ( ! is_readable($configFile)) { - trigger_error( - 'Configuration file [' . $configFile . '] does not have read permission.', E_USER_ERROR - ); - } - - require $configFile; - - foreach ($GLOBALS as $helperSetCandidate) { - if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) { - $helperSet = $helperSetCandidate; - break; - } - } -} - -$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet(); - -\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet); diff --git a/bin/doctrine.bat b/bin/doctrine.bat deleted file mode 100644 index a91645cc457..00000000000 --- a/bin/doctrine.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off - -if "%PHPBIN%" == "" set PHPBIN=@php_bin@ -if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH -GOTO RUN -:USE_PEAR_PATH -set PHPBIN=%PHP_PEAR_PHP_BIN% -:RUN -"%PHPBIN%" "@bin_dir@\doctrine" %* diff --git a/bin/doctrine.php b/bin/doctrine.php deleted file mode 100644 index 2c11fd208da..00000000000 --- a/bin/doctrine.php +++ /dev/null @@ -1,62 +0,0 @@ - Date: Wed, 27 Apr 2022 11:47:40 +0200 Subject: [PATCH 064/475] Remove invalid mapping The named queries feature has been removed in 3.0 --- ...Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml index f486dd9aedd..31d6bafa728 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml @@ -21,10 +21,6 @@ - - - - From fa844b12744dc924ffc25938c5e75cb5d73ebb70 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 30 Apr 2022 11:23:52 -0700 Subject: [PATCH 065/475] Remove support for Type::canRequireSQLConversion() --- UPGRADE.md | 8 +++++++ ...-conversion-using-custom-mapping-types.rst | 5 ---- .../ORM/Mapping/ClassMetadataInfo.php | 10 -------- lib/Doctrine/ORM/Mapping/MappingException.php | 18 -------------- .../AbstractEntityInheritancePersister.php | 6 ++--- .../Entity/BasicEntityPersister.php | 12 ++++------ .../ORM/Query/ResultSetMappingBuilder.php | 6 ++--- lib/Doctrine/ORM/Query/SqlWalker.php | 24 +++++++------------ psalm-baseline.xml | 3 --- .../DbalTypes/NegativeToPositiveType.php | 8 ------- .../Tests/DbalTypes/UpperCaseStringType.php | 8 ------- .../ORM/Functional/Ticket/DDC2012Test.php | 8 ------- .../ORM/Functional/Ticket/DDC2224Test.php | 8 ------- .../ORM/Functional/Ticket/DDC5684Test.php | 5 ---- .../ORM/Functional/Ticket/GH8061Test.php | 5 ---- .../Tests/ORM/Functional/TypeValueSqlTest.php | 6 ++--- 16 files changed, 28 insertions(+), 112 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index c0a32aaab44..2f68cdf9161 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,13 @@ # Upgrade to 3.0 +## BC BREAK: Remove support for `Type::canRequireSQLConversion()` + +This feature was deprecated in DBAL 3.3.0 and will be removed in DBAL 4.0. +The value conversion methods are now called regardless of the type. + +The `MappingException::sqlConversionNotAllowedForIdentifiers()` method has been removed +as no longer relevant. + ## BC Break: Removed the `doctrine` binary. The documentation explains how the console tools can be bootstrapped for diff --git a/docs/en/cookbook/advanced-field-value-conversion-using-custom-mapping-types.rst b/docs/en/cookbook/advanced-field-value-conversion-using-custom-mapping-types.rst index ab9ae72c391..2a44f3725c7 100644 --- a/docs/en/cookbook/advanced-field-value-conversion-using-custom-mapping-types.rst +++ b/docs/en/cookbook/advanced-field-value-conversion-using-custom-mapping-types.rst @@ -171,11 +171,6 @@ Now we're going to create the ``point`` type and implement all required methods. return $value; } - public function canRequireSQLConversion() - { - return true; - } - public function convertToPHPValueSQL($sqlExpr, AbstractPlatform $platform) { return sprintf('AsText(%s)', $sqlExpr); diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index cb2e5ca11b3..a5a0baa09e0 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -10,7 +10,6 @@ use DateTime; use DateTimeImmutable; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use Doctrine\Deprecations\Deprecation; use Doctrine\Instantiator\Instantiator; @@ -92,7 +91,6 @@ * originalClass?: class-string, * originalField?: string, * quoted?: bool, - * requireSQLConversion?: bool, * declared?: class-string, * declaredField?: string, * options?: array @@ -1537,14 +1535,6 @@ protected function validateAndCompleteFieldMapping(array $mapping): array } } - if (Type::hasType($mapping['type']) && Type::getType($mapping['type'])->canRequireSQLConversion()) { - if (isset($mapping['id']) && $mapping['id'] === true) { - throw MappingException::sqlConversionNotAllowedForIdentifiers($this->name, $mapping['fieldName'], $mapping['type']); - } - - $mapping['requireSQLConversion'] = true; - } - if (isset($mapping['generated'])) { if (! in_array($mapping['generated'], [self::GENERATED_NEVER, self::GENERATED_INSERT, self::GENERATED_ALWAYS])) { throw MappingException::invalidGeneratedMode($mapping['generated']); diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index d1bea3fe443..1cae09e095a 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -593,24 +593,6 @@ public static function cannotVersionIdField($className, $fieldName) )); } - /** - * @param string $className - * @param string $fieldName - * @param string $type - * - * @return MappingException - */ - public static function sqlConversionNotAllowedForIdentifiers($className, $fieldName, $type) - { - return new self(sprintf( - "It is not possible to set id field '%s' to type '%s' in entity class '%s'. The type '%s' requires conversion SQL which is not allowed for identifiers.", - $fieldName, - $type, - $className, - $type - )); - } - /** * @param string $className * @param string $columnName diff --git a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php index 4416d714dcf..397fb1f6cd6 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php @@ -49,10 +49,8 @@ protected function getSelectColumnSQL(string $field, ClassMetadata $class, strin $this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field, $class->name); - if (isset($fieldMapping['requireSQLConversion'])) { - $type = Type::getType($fieldMapping['type']); - $sql = $type->convertToPHPValueSQL($sql, $this->platform); - } + $type = Type::getType($fieldMapping['type']); + $sql = $type->convertToPHPValueSQL($sql, $this->platform); return $sql . ' AS ' . $columnAlias; } diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index abbc5e09e5b..9a3de3a110c 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -401,7 +401,7 @@ final protected function updateTable( $fieldName = $this->class->fieldNames[$columnName]; $column = $this->quoteStrategy->getColumnName($fieldName, $this->class, $this->platform); - if (isset($this->class->fieldMappings[$fieldName]['requireSQLConversion'])) { + if (isset($this->class->fieldMappings[$fieldName])) { $type = Type::getType($this->columnTypes[$columnName]); $placeholder = $type->convertToDatabaseValueSQL('?', $this->platform); } @@ -1348,7 +1348,7 @@ public function getInsertSQL(): string if ( isset($this->class->fieldNames[$column]) && isset($this->columnTypes[$this->class->fieldNames[$column]]) - && isset($this->class->fieldMappings[$this->class->fieldNames[$column]]['requireSQLConversion']) + && isset($this->class->fieldMappings[$this->class->fieldNames[$column]]) ) { $type = Type::getType($this->columnTypes[$this->class->fieldNames[$column]]); $placeholder = $type->convertToDatabaseValueSQL('?', $this->platform); @@ -1427,10 +1427,8 @@ protected function getSelectColumnSQL(string $field, ClassMetadata $class, strin $this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field); - if (isset($fieldMapping['requireSQLConversion'])) { - $type = Type::getType($fieldMapping['type']); - $sql = $type->convertToPHPValueSQL($sql, $this->platform); - } + $type = Type::getType($fieldMapping['type']); + $sql = $type->convertToPHPValueSQL($sql, $this->platform); return $sql . ' AS ' . $columnAlias; } @@ -1534,7 +1532,7 @@ public function getSelectConditionStatementSQL(string $field, mixed $value, ?arr foreach ($columns as $column) { $placeholder = '?'; - if (isset($this->class->fieldMappings[$field]['requireSQLConversion'])) { + if (isset($this->class->fieldMappings[$field])) { $type = Type::getType($this->class->fieldMappings[$field]['type']); $placeholder = $type->convertToDatabaseValueSQL($placeholder, $this->platform); } diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index cce51d72559..4156e188c58 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -254,10 +254,8 @@ public function generateSelectClause(array $tableAliases = []): string $classFieldMapping = $class->fieldMappings[$fieldName]; $columnSql = $tableAlias . '.' . $classFieldMapping['columnName']; - if (isset($classFieldMapping['requireSQLConversion']) && $classFieldMapping['requireSQLConversion'] === true) { - $type = Type::getType($classFieldMapping['type']); - $columnSql = $type->convertToPHPValueSQL($columnSql, $this->em->getConnection()->getDatabasePlatform()); - } + $type = Type::getType($classFieldMapping['type']); + $columnSql = $type->convertToPHPValueSQL($columnSql, $this->em->getConnection()->getDatabasePlatform()); $sql .= $columnSql; } elseif (isset($this->metaMappings[$columnName])) { diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 7539b53ec91..35062f928b7 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1347,10 +1347,8 @@ public function walkSelectExpression($selectExpression) $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']); $col = $sqlTableAlias . '.' . $columnName; - if (isset($fieldMapping['requireSQLConversion'])) { - $type = Type::getType($fieldMapping['type']); - $col = $type->convertToPHPValueSQL($col, $this->conn->getDatabasePlatform()); - } + $type = Type::getType($fieldMapping['type']); + $col = $type->convertToPHPValueSQL($col, $this->conn->getDatabasePlatform()); $sql .= $col . ' AS ' . $columnAlias; @@ -1461,10 +1459,8 @@ public function walkSelectExpression($selectExpression) $col = $sqlTableAlias . '.' . $quotedColumnName; - if (isset($mapping['requireSQLConversion'])) { - $type = Type::getType($mapping['type']); - $col = $type->convertToPHPValueSQL($col, $this->platform); - } + $type = Type::getType($mapping['type']); + $col = $type->convertToPHPValueSQL($col, $this->platform); $sqlParts[] = $col . ' AS ' . $columnAlias; @@ -1492,10 +1488,8 @@ public function walkSelectExpression($selectExpression) $col = $sqlTableAlias . '.' . $quotedColumnName; - if (isset($mapping['requireSQLConversion'])) { - $type = Type::getType($mapping['type']); - $col = $type->convertToPHPValueSQL($col, $this->platform); - } + $type = Type::getType($mapping['type']); + $col = $type->convertToPHPValueSQL($col, $this->platform); $sqlParts[] = $col . ' AS ' . $columnAlias; @@ -1611,10 +1605,8 @@ public function walkNewObject($newObjectExpression, $newObjectResultAlias = null $fieldType = $fieldMapping['type']; $col = trim($e->dispatch($this)); - if (isset($fieldMapping['requireSQLConversion'])) { - $type = Type::getType($fieldType); - $col = $type->convertToPHPValueSQL($col, $this->platform); - } + $type = Type::getType($fieldType); + $col = $type->convertToPHPValueSQL($col, $this->platform); $sqlSelectExpressions[] = $col . ' AS ' . $columnAlias; break; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 6c277678859..60e44748421 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -383,9 +383,6 @@ - - canRequireSQLConversion - $this->columnNames $this->columnNames diff --git a/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php b/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php index 1fe03e4089e..a93942c6bdf 100644 --- a/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php +++ b/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php @@ -24,14 +24,6 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st return $platform->getIntegerTypeDeclarationSQL($column); } - /** - * {@inheritdoc} - */ - public function canRequireSQLConversion() - { - return true; - } - /** * {@inheritdoc} */ diff --git a/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php b/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php index bb7979b6957..b2224ad2139 100644 --- a/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php +++ b/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php @@ -16,14 +16,6 @@ public function getName(): string return self::NAME; } - /** - * {@inheritdoc} - */ - public function canRequireSQLConversion() - { - return true; - } - /** * {@inheritdoc} */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index 3e6b609ea24..3834651a8bc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -182,14 +182,6 @@ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): return sprintf('UPPER(%s)', $sqlExpr); } - /** - * {@inheritdoc} - */ - public function canRequireSQLConversion() - { - return true; - } - public function getName(): string { return self::MYTYPE; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index 40d0a77c1f6..829115d2710 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -63,14 +63,6 @@ public function getName(): string return 'DDC2224Type'; } - /** - * {@inheritdoc} - */ - public function canRequireSQLConversion() - { - return true; - } - /** * {@inheritdoc} */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index 199588920da..01d81bde48c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -81,11 +81,6 @@ public function getName(): string { return self::class; } - - public function requiresSQLCommentHint(AbstractPlatform $platform): bool - { - return true; - } } class DDC5684ObjectId diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php index 08fc943e0fb..3f2d264a0ae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php @@ -66,11 +66,6 @@ public function getName(): string return 'GH8061'; } - public function canRequireSQLConversion(): bool - { - return true; - } - public function convertToPHPValueSQL($sqlExpr, $platform): string { return sprintf('DatabaseFunction(%s)', $sqlExpr); diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php index a88b794ff8d..b03602fa3ef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php @@ -44,7 +44,7 @@ public function testUpperCaseStringType(): void $this->_em->clear(); - $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); + $entity = $this->_em->find(CustomTypeUpperCase::class, $id); self::assertEquals('foo', $entity->lowerCaseString, 'Entity holds lowercase string'); self::assertEquals('FOO', $this->_em->getConnection()->fetchOne('select lowerCaseString from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); @@ -66,7 +66,7 @@ public function testUpperCaseStringTypeWhenColumnNameIsDefined(): void $this->_em->clear(); - $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); + $entity = $this->_em->find(CustomTypeUpperCase::class, $id); self::assertEquals('foo', $entity->namedLowerCaseString, 'Entity holds lowercase string'); self::assertEquals('FOO', $this->_em->getConnection()->fetchOne('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); @@ -79,7 +79,7 @@ public function testUpperCaseStringTypeWhenColumnNameIsDefined(): void $this->_em->clear(); - $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); + $entity = $this->_em->find(CustomTypeUpperCase::class, $id); self::assertEquals('bar', $entity->namedLowerCaseString, 'Entity holds lowercase string'); self::assertEquals('BAR', $this->_em->getConnection()->fetchOne('select named_lower_case_string from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); } From 6fe69f16e2a5395840867033248fb0db375850da Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 1 May 2022 13:37:32 -0700 Subject: [PATCH 066/475] Remove non-API DriverConnectionMock methods (#9709) --- .../Tests/Mocks/DriverConnectionMock.php | 10 +-- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 77 ++++++++++++------- tests/Doctrine/Tests/OrmTestCase.php | 29 +++++-- 3 files changed, 72 insertions(+), 44 deletions(-) diff --git a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php index da72d8ba12d..c3609c673e3 100644 --- a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php @@ -14,14 +14,6 @@ */ class DriverConnectionMock implements Connection { - /** @var Result|null */ - private $resultMock; - - public function setResultMock(?Result $resultMock): void - { - $this->resultMock = $resultMock; - } - public function prepare(string $sql): Statement { return new StatementMock(); @@ -29,7 +21,7 @@ public function prepare(string $sql): Statement public function query(string $sql): Result { - return $this->resultMock ?? new DriverResultMock(); + return new DriverResultMock(); } /** diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 7ac91c20cf7..76a3fbc4682 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -7,14 +7,16 @@ use DateTime; use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\Cache\ArrayResult; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Driver; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; -use Doctrine\Tests\Mocks\DriverConnectionMock; -use Doctrine\Tests\Mocks\DriverResultMock; +use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsGroup; @@ -30,7 +32,6 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter; use function array_map; -use function assert; use const PHP_VERSION_ID; @@ -331,15 +332,19 @@ public function testDefaultQueryHints(): void */ public function testResultCacheCaching(): void { - $this->entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); - $this->entityManager->getConfiguration()->setQueryCache(new ArrayAdapter()); - $driverConnectionMock = $this->entityManager->getConnection()->getWrappedConnection(); - assert($driverConnectionMock instanceof DriverConnectionMock); - $result = new DriverResultMock([ - ['id_0' => 1], - ]); - $driverConnectionMock->setResultMock($result); - $res = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u') + $entityManager = $this->getTestEntityManager( + $this->createConnection( + new ArrayResult([ + ['id_0' => 1], + ]), + new ArrayResult([]) + ) + ); + + $entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); + $entityManager->getConfiguration()->setQueryCache(new ArrayAdapter()); + + $res = $entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u') ->useQueryCache(true) ->enableResultCache(60) //let it cache @@ -347,9 +352,7 @@ public function testResultCacheCaching(): void self::assertCount(1, $res); - $driverConnectionMock->setResultMock(null); - - $res = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u') + $res = $entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u') ->useQueryCache(true) ->disableResultCache() ->getResult(); @@ -371,29 +374,34 @@ public function testSetHydrationCacheProfileNull(): void */ public function testResultCacheEviction(): void { - $this->entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); - - $query = $this->entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') - ->enableResultCache(); + $entityManager = $this->getTestEntityManager( + $this->createConnection( + new ArrayResult([ + ['id_0' => 1], + ]), + new ArrayResult([ + ['id_0' => 1], + ['id_0' => 2], + ]), + new ArrayResult([ + ['id_0' => 1], + ]) + ) + ); - $driverConnectionMock = $this->entityManager->getConnection() - ->getWrappedConnection(); - assert($driverConnectionMock instanceof DriverConnectionMock); + $entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); - $driverConnectionMock->setResultMock(new DriverResultMock([['id_0' => 1]])); + $query = $entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') + ->enableResultCache(); // Performs the query and sets up the initial cache self::assertCount(1, $query->getResult()); - $driverConnectionMock->setResultMock(new DriverResultMock([['id_0' => 1], ['id_0' => 2]])); - // Retrieves cached data since expire flag is false and we have a cached result set self::assertCount(1, $query->getResult()); // Performs the query and caches the result set since expire flag is true - self::assertCount(2, $query->expireResultCache(true)->getResult()); - - $driverConnectionMock->setResultMock(new DriverResultMock([['id_0' => 1]])); + self::assertCount(2, $query->expireResultCache()->getResult()); // Retrieves cached data since expire flag is false and we have a cached result set self::assertCount(2, $query->expireResultCache(false)->getResult()); @@ -568,4 +576,17 @@ public function testGetQueryCacheDriverWithCacheExplicitlySet(): void ->setQueryCache($cache) ->getSQL(); } + + private function createConnection(Driver\Result ...$results): Connection + { + $driverConnection = $this->createMock(Driver\Connection::class); + $driverConnection->method('query') + ->will($this->onConsecutiveCalls(...$results)); + + $driver = $this->createMock(Driver::class); + $driver->method('connect') + ->willReturn($driverConnection); + + return new ConnectionMock([], $driver); + } } diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 2a99c60aa2d..c0bcc290b39 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -6,7 +6,8 @@ use Doctrine\Common\Annotations; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Cache\CacheFactory; use Doctrine\ORM\Cache\DefaultCacheFactory; @@ -99,12 +100,7 @@ protected function getTestEntityManager(?Connection $connection = null): EntityM } if ($connection === null) { - $connection = DriverManager::getConnection([ - 'driverClass' => Mocks\DriverMock::class, - 'wrapperClass' => Mocks\ConnectionMock::class, - 'user' => 'john', - 'password' => 'wayne', - ], $config); + $connection = new Mocks\ConnectionMock([], $this->createDriverMock()); } return EntityManagerMock::create($connection, $config); @@ -133,4 +129,23 @@ protected function getSharedSecondLevelCache(): CacheItemPoolInterface return $this->secondLevelCache ?? $this->secondLevelCache = new ArrayAdapter(); } + + private function createDriverMock(): Driver + { + $result = $this->createMock(Driver\Result::class); + $result->method('fetchAssociative') + ->willReturn(false); + + $connection = $this->createMock(Driver\Connection::class); + $connection->method('query') + ->willReturn($result); + + $driver = $this->createMock(Driver::class); + $driver->method('connect') + ->willReturn($connection); + $driver->method('getSchemaManager') + ->willReturn($this->createMock(AbstractSchemaManager::class)); + + return $driver; + } } From 11049b441eda9ab0df9ac99f70847b6f6d76e5f6 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 1 May 2022 14:28:30 -0700 Subject: [PATCH 067/475] Remove some mock classes (#9715) --- .../ArrayResultFactory.php | 6 +- ...etchJoinArrayHydrationPerformanceBench.php | 2 +- ...oinFullObjectHydrationPerformanceBench.php | 2 +- ...PartialObjectHydrationPerformanceBench.php | 2 +- ...pleQueryArrayHydrationPerformanceBench.php | 2 +- ...eryFullObjectHydrationPerformanceBench.php | 2 +- ...PartialObjectHydrationPerformanceBench.php | 2 +- ...leQueryScalarHydrationPerformanceBench.php | 2 +- tests/Doctrine/Tests/Mocks/ConnectionMock.php | 6 +- .../Tests/Mocks/DriverConnectionMock.php | 79 ------------------- tests/Doctrine/Tests/Mocks/DriverMock.php | 65 --------------- tests/Doctrine/Tests/Mocks/StatementMock.php | 44 ----------- .../ORM/Functional/Ticket/GH6362Test.php | 6 +- .../Tests/ORM/Hydration/ArrayHydratorTest.php | 39 +++++---- .../Tests/ORM/Hydration/HydrationTestCase.php | 7 ++ .../ORM/Hydration/ObjectHydratorTest.php | 70 ++++++++-------- .../Hydration/ScalarColumnHydratorTest.php | 9 +-- .../ORM/Hydration/ScalarHydratorTest.php | 7 +- .../Hydration/SimpleObjectHydratorTest.php | 11 ++- .../Hydration/SingleScalarHydratorTest.php | 9 +-- tests/Doctrine/Tests/OrmTestCase.php | 7 ++ 21 files changed, 102 insertions(+), 277 deletions(-) rename tests/Doctrine/{Tests/Mocks => Performance}/ArrayResultFactory.php (50%) delete mode 100644 tests/Doctrine/Tests/Mocks/DriverConnectionMock.php delete mode 100644 tests/Doctrine/Tests/Mocks/DriverMock.php delete mode 100644 tests/Doctrine/Tests/Mocks/StatementMock.php diff --git a/tests/Doctrine/Tests/Mocks/ArrayResultFactory.php b/tests/Doctrine/Performance/ArrayResultFactory.php similarity index 50% rename from tests/Doctrine/Tests/Mocks/ArrayResultFactory.php rename to tests/Doctrine/Performance/ArrayResultFactory.php index a63eff1119f..72a2fad7ea6 100644 --- a/tests/Doctrine/Tests/Mocks/ArrayResultFactory.php +++ b/tests/Doctrine/Performance/ArrayResultFactory.php @@ -2,15 +2,17 @@ declare(strict_types=1); -namespace Doctrine\Tests\Mocks; +namespace Doctrine\Performance; +use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Driver\PDO\SQLite\Driver; use Doctrine\DBAL\Result; final class ArrayResultFactory { public static function createFromArray(array $resultSet): Result { - return new Result(new DriverResultMock($resultSet), new Connection([], new DriverMock())); + return new Result(new ArrayResult($resultSet), new Connection([], new Driver())); } } diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php index 6bece84a318..77838d5675b 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ArrayHydrator; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php index fec96b63bfa..b6e807b3d48 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php index 508c62a06da..32401dda75f 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php @@ -8,8 +8,8 @@ use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php index c29919b9c97..fb5a9ab7df1 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ArrayHydrator; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php index 2fa6f03b7b0..a2f88bf417e 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php index 1cebdf0f07c..8ee4a83f6b2 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php @@ -8,8 +8,8 @@ use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php index e7e3b9ac037..e0eab3c0ded 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ScalarHydrator; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php index 02b1a04f4af..b117a039b82 100644 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -5,8 +5,6 @@ namespace Doctrine\Tests\Mocks; use BadMethodCallException; -use Doctrine\Common\EventManager; -use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -29,11 +27,11 @@ class ConnectionMock extends Connection /** @var array */ private $_deletes = []; - public function __construct(array $params = [], ?Driver $driver = null, ?Configuration $config = null, ?EventManager $eventManager = null) + public function __construct(array $params, Driver $driver) { $this->_platformMock = new DatabasePlatformMock(); - parent::__construct($params, $driver ?? new DriverMock(), $config, $eventManager); + parent::__construct($params, $driver); } public function getDatabase(): string diff --git a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php deleted file mode 100644 index c3609c673e3..00000000000 --- a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php +++ /dev/null @@ -1,79 +0,0 @@ -_platformMock) { - $this->_platformMock = new DatabasePlatformMock(); - } - - return $this->_platformMock; - } - - public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager - { - return $this->_schemaManagerMock ?? new SchemaManagerMock($conn, $platform); - } - - public function getExceptionConverter(): ExceptionConverter - { - return new ExceptionConverterMock(); - } - - /* MOCK API */ - - public function setDatabasePlatform(AbstractPlatform $platform): void - { - $this->_platformMock = $platform; - } - - public function setSchemaManager(AbstractSchemaManager $sm): void - { - $this->_schemaManagerMock = $sm; - } -} diff --git a/tests/Doctrine/Tests/Mocks/StatementMock.php b/tests/Doctrine/Tests/Mocks/StatementMock.php deleted file mode 100644 index 0c60997f3d5..00000000000 --- a/tests/Doctrine/Tests/Mocks/StatementMock.php +++ /dev/null @@ -1,44 +0,0 @@ -createMock(Connection::class)); $hydrator = new ObjectHydrator($this->_em); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php index 301fae6021d..c71db7dd9d8 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php @@ -6,7 +6,6 @@ use Doctrine\ORM\Internal\Hydration\ArrayHydrator; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\Tests\Models\CMS\CmsPhonenumber; @@ -53,7 +52,7 @@ public function testSimpleEntityQuery(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -97,7 +96,7 @@ public function testSimpleEntityWithScalarQuery(int|string $userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -145,7 +144,7 @@ public function testSimpleEntityQueryWithAliasedUserEntity(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -192,7 +191,7 @@ public function testSimpleMultipleRootEntityQuery(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -242,7 +241,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -296,7 +295,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity(): voi ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -350,7 +349,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -405,7 +404,7 @@ public function testMixedQueryNormalJoin(int|string $userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -469,7 +468,7 @@ public function testMixedQueryFetchJoin(int|string $userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -542,7 +541,7 @@ public function testMixedQueryFetchJoinCustomIndex(int|string $userEntityKey): v ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -656,7 +655,7 @@ public function testMixedQueryMultipleFetchJoin(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -795,7 +794,7 @@ public function testMixedQueryMultipleDeepMixedFetchJoin(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -909,7 +908,7 @@ public function testEntityQueryCustomResultSetOrder(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -972,7 +971,7 @@ public function testChainedJoinWithScalars(int|string $entityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -1021,7 +1020,7 @@ public function testResultIteration(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $iterator = $hydrator->toIterable($stmt, $rsm); $rowNum = 0; @@ -1063,7 +1062,7 @@ public function testResultIterationWithAliasedUserEntity(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $iterator = $hydrator->toIterable($stmt, $rsm); $rowNum = 0; @@ -1106,7 +1105,7 @@ public function testSkipUnknownColumns(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -1157,7 +1156,7 @@ public function testMissingIdForRootEntity(int|string $userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -1207,7 +1206,7 @@ public function testIndexByAndMixedResult(int|string $userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ArrayHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); diff --git a/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php b/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php index d711fbe2442..f2c0cb61620 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Hydration; +use Doctrine\DBAL\Cache\ArrayResult; +use Doctrine\DBAL\Result; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Tests\OrmTestCase; @@ -16,4 +18,9 @@ protected function setUp(): void parent::setUp(); $this->entityManager = $this->getTestEntityManager(); } + + protected function createResultMock(array $resultSet): Result + { + return new Result(new ArrayResult($resultSet), $this->entityManager->getConnection()); + } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index cceb3d82ef6..635f65f309e 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -4,13 +4,15 @@ namespace Doctrine\Tests\ORM\Hydration; +use Doctrine\DBAL\Cache\ArrayResult; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsComment; @@ -89,7 +91,7 @@ public function testSimpleEntityQuery(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -128,7 +130,7 @@ public function testSimpleEntityQueryWithAliasedUserEntity(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -177,7 +179,7 @@ public function testSimpleMultipleRootEntityQuery(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -231,7 +233,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -292,7 +294,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity(): voi ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -353,7 +355,7 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -415,7 +417,7 @@ public function testMixedQueryNormalJoin($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -479,7 +481,7 @@ public function testMixedQueryFetchJoin($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -559,7 +561,7 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -673,7 +675,7 @@ public function testMixedQueryMultipleFetchJoin($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -803,7 +805,7 @@ public function testMixedQueryMultipleDeepMixedFetchJoin($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -916,7 +918,7 @@ public function testEntityQueryCustomResultSetOrder(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -959,7 +961,7 @@ public function testSkipUnknownColumns(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -992,7 +994,7 @@ public function testScalarQueryWithoutResultVariables($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1048,7 +1050,7 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void $metadata = $this->entityManager->getClassMetadata(ECommerceProduct::class); $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -1097,7 +1099,7 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE $metadata = $this->entityManager->getClassMetadata(ECommerceProduct::class); $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -1157,7 +1159,7 @@ public function testChainedJoinWithEmptyCollections(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1220,7 +1222,7 @@ public function testChainedJoinWithEmptyCollectionsWithAliasedUserEntity(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1262,7 +1264,7 @@ public function testResultIteration(): void $hydrator = new ObjectHydrator($this->entityManager); $iterableResult = $hydrator->toIterable( - ArrayResultFactory::createFromArray($resultSet), + $this->createResultMock($resultSet), $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true] ); @@ -1285,7 +1287,7 @@ public function testResultIteration(): void self::assertSame(2, $rowNum); $iterableResult = $hydrator->toIterable( - ArrayResultFactory::createFromArray($resultSet), + $this->createResultMock($resultSet), $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true] ); @@ -1336,7 +1338,7 @@ public function testResultIterationWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $rowNum = 0; $iterableResult = $hydrator->toIterable( - ArrayResultFactory::createFromArray($resultSet), + new Result(new ArrayResult($resultSet), $this->createMock(Connection::class)), $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true] ); @@ -1361,7 +1363,7 @@ public function testResultIterationWithAliasedUserEntity(): void $rowNum = 0; $iterableResult = $hydrator->toIterable( - ArrayResultFactory::createFromArray($resultSet), + $this->createResultMock($resultSet), $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true] ); @@ -1495,7 +1497,7 @@ public function testManyToManyHydration(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1618,7 +1620,7 @@ public function testManyToManyHydrationWithAliasedUserEntity(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1676,7 +1678,7 @@ public function testMissingIdForRootEntity($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1746,7 +1748,7 @@ public function testMissingIdForCollectionValuedChildEntity($userEntityKey): voi ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1800,7 +1802,7 @@ public function testMissingIdForSingleValuedChildEntity($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1842,7 +1844,7 @@ public function testIndexByAndMixedResult($userEntityKey): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1876,7 +1878,7 @@ public function testIndexByScalarsOnly($userEntityKey): void ['sclr0' => 'JWAGE'], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); @@ -1910,7 +1912,7 @@ public function testMissingMetaMappingException(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $hydrator->hydrateAll($stmt, $rsm); } @@ -1943,7 +1945,7 @@ public function testMissingDiscriminatorColumnException(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $hydrator->hydrateAll($stmt, $rsm); } @@ -1971,7 +1973,7 @@ public function testInvalidDiscriminatorValueException(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $hydrator->hydrateAll($stmt, $rsm); } @@ -1992,7 +1994,7 @@ public function testFetchJoinCollectionValuedAssociationWithDefaultArrayValue(): ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php index 0e82b58213f..3d617e7603f 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php @@ -7,7 +7,6 @@ use Doctrine\ORM\Exception\MultipleSelectorsFoundException; use Doctrine\ORM\Internal\Hydration\ScalarColumnHydrator; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; use function sprintf; @@ -24,7 +23,7 @@ public function testEmptyResultTest(): void $rsm->addEntityResult(CmsUser::class, 'u'); $rsm->addFieldResult('u', 'u__id', 'id'); - $stmt = ArrayResultFactory::createFromArray($emptyResultSet = []); + $stmt = $this->createResultMock([]); $hydrator = new ScalarColumnHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -47,7 +46,7 @@ public function testSingleColumnEntityQueryWithoutScalarMap(): void ['u__id' => '2'], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ScalarColumnHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -75,7 +74,7 @@ public function testSingleColumnEntityQueryWithScalarMap(): void ['u__id' => '2'], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ScalarColumnHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -108,7 +107,7 @@ public function testMultipleColumnEntityQueryThrowsException(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ScalarColumnHydrator($this->entityManager); $this->expectException(MultipleSelectorsFoundException::class); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php index be088038565..6073846e4a0 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php @@ -6,7 +6,6 @@ use Doctrine\ORM\Internal\Hydration\ScalarHydrator; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; class ScalarHydratorTest extends HydrationTestCase @@ -33,7 +32,7 @@ public function testNewHydrationSimpleEntityQuery(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ScalarHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -64,7 +63,7 @@ public function testHydrateScalarResults(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ScalarHydrator($this->entityManager); self::assertCount(1, $hydrator->hydrateAll($stmt, $rsm)); @@ -94,7 +93,7 @@ public function testSkipUnknownColumns(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new ScalarHydrator($this->entityManager); self::assertCount(1, $hydrator->hydrateAll($stmt, $rsm)); diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php index 0264e334d8a..af351504691 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\DbalTypes\GH8565EmployeePayloadType; use Doctrine\Tests\DbalTypes\GH8565ManagerPayloadType; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\GH8565\GH8565Employee; @@ -42,7 +41,7 @@ public function testMissingDiscriminatorColumnException(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $hydrator->hydrateAll($stmt, $rsm); } @@ -65,7 +64,7 @@ public function testExtraFieldInResultSetShouldBeIgnore(): void $expectedEntity->id = 1; $expectedEntity->city = 'Cracow'; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); self::assertEquals($result[0], $expectedEntity); @@ -95,7 +94,7 @@ public function testInvalidDiscriminatorValueException(): void ], ]; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $hydrator->hydrateAll($stmt, $rsm); } @@ -124,7 +123,7 @@ public function testNullValueShouldNotOverwriteFieldWithSameNameInJoinedInherita $expectedEntity->id = 1; $expectedEntity->tags = ['tag1', 'tag2']; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); self::assertEquals($result[0], $expectedEntity); @@ -156,7 +155,7 @@ public function testWrongValuesShouldNotBeConvertedToPhpValue(): void $expectedEntity->id = 1; $expectedEntity->type = 'type field'; - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SimpleObjectHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); self::assertEquals($result[0], $expectedEntity); diff --git a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php index b093839af09..792b5c5ed22 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php @@ -7,7 +7,6 @@ use Doctrine\ORM\Internal\Hydration\SingleScalarHydrator; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; use Generator; @@ -62,7 +61,7 @@ public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__name', 'name'); - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SingleScalarHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -80,7 +79,7 @@ public function testHydrateSingleScalarFromScalarMappingWithValidResultSet(array $rsm->addScalarResult('u__id', 'id', 'string'); $rsm->addScalarResult('u__name', 'name', 'string'); - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SingleScalarHydrator($this->entityManager); $result = $hydrator->hydrateAll($stmt, $rsm); @@ -152,7 +151,7 @@ public function testHydrateSingleScalarFromFieldMappingWithInvalidResultSet(arra $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__name', 'name'); - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SingleScalarHydrator($this->entityManager); $this->expectException(NonUniqueResultException::class); @@ -170,7 +169,7 @@ public function testHydrateSingleScalarFromScalarMappingWithInvalidResultSet(arr $rsm->addScalarResult('u__id', 'id', 'string'); $rsm->addScalarResult('u__name', 'name', 'string'); - $stmt = ArrayResultFactory::createFromArray($resultSet); + $stmt = $this->createResultMock($resultSet); $hydrator = new SingleScalarHydrator($this->entityManager); $this->expectException(NonUniqueResultException::class); diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index c0bcc290b39..7e9224aac31 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -7,6 +7,7 @@ use Doctrine\Common\Annotations; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Cache\CacheFactory; @@ -140,11 +141,17 @@ private function createDriverMock(): Driver $connection->method('query') ->willReturn($result); + $platform = $this->createMock(AbstractPlatform::class); + $platform->method('supportsIdentityColumns') + ->willReturn(true); + $driver = $this->createMock(Driver::class); $driver->method('connect') ->willReturn($connection); $driver->method('getSchemaManager') ->willReturn($this->createMock(AbstractSchemaManager::class)); + $driver->method('getDatabasePlatform') + ->willReturn($platform); return $driver; } From f671fa8477dfa40199f2191199c6a98ecba6183b Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 2 May 2022 07:56:16 -0700 Subject: [PATCH 068/475] Remove DatabasePlatformMock (#9716) --- tests/Doctrine/Tests/Mocks/ConnectionMock.php | 25 ---- .../Tests/Mocks/DatabasePlatformMock.php | 114 ----------------- .../Tests/ORM/Id/SequenceGeneratorTest.php | 2 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 13 +- .../ORM/Query/SelectSqlGenerationTest.php | 39 ++---- .../LimitSubqueryOutputWalkerTest.php | 115 +++++++----------- .../ORM/Tools/Pagination/PaginatorTest.php | 15 ++- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 8 ++ tests/Doctrine/Tests/OrmTestCase.php | 48 ++++++-- 9 files changed, 127 insertions(+), 252 deletions(-) delete mode 100644 tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php index b117a039b82..81a3351e18b 100644 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -6,8 +6,6 @@ use BadMethodCallException; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Result; use function is_string; @@ -18,35 +16,17 @@ */ class ConnectionMock extends Connection { - /** @var AbstractPlatform */ - private $_platformMock; - /** @var array */ private $_executeStatements = []; /** @var array */ private $_deletes = []; - public function __construct(array $params, Driver $driver) - { - $this->_platformMock = new DatabasePlatformMock(); - - parent::__construct($params, $driver); - } - public function getDatabase(): string { return 'mock'; } - /** - * {@inheritdoc} - */ - public function getDatabasePlatform() - { - return $this->_platformMock; - } - /** * {@inheritdoc} */ @@ -97,11 +77,6 @@ public function quote($input, $type = null) return $input; } - public function setDatabasePlatform(AbstractPlatform $platform): void - { - $this->_platformMock = $platform; - } - /** * @return array */ diff --git a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php b/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php deleted file mode 100644 index 2b945b5c070..00000000000 --- a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php +++ /dev/null @@ -1,114 +0,0 @@ -getTestEntityManager($connection); + $entityManager = $this->createTestEntityManagerWithConnection($connection); for ($i = 0; $i < 42; ++$i) { $id = $sequenceGenerator->generateId($entityManager, null); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 76a3fbc4682..b8839c67698 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\ParameterType; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\QueryException; @@ -332,7 +333,7 @@ public function testDefaultQueryHints(): void */ public function testResultCacheCaching(): void { - $entityManager = $this->getTestEntityManager( + $entityManager = $this->createTestEntityManagerWithConnection( $this->createConnection( new ArrayResult([ ['id_0' => 1], @@ -374,7 +375,7 @@ public function testSetHydrationCacheProfileNull(): void */ public function testResultCacheEviction(): void { - $entityManager = $this->getTestEntityManager( + $entityManager = $this->createTestEntityManagerWithConnection( $this->createConnection( new ArrayResult([ ['id_0' => 1], @@ -583,9 +584,17 @@ private function createConnection(Driver\Result ...$results): Connection $driverConnection->method('query') ->will($this->onConsecutiveCalls(...$results)); + $platform = $this->getMockBuilder(AbstractPlatform::class) + ->onlyMethods(['supportsIdentityColumns']) + ->getMockForAbstractClass(); + $platform->method('supportsIdentityColumns') + ->willReturn(true); + $driver = $this->createMock(Driver::class); $driver->method('connect') ->willReturn($driverConnection); + $driver->method('getDatabasePlatform') + ->willReturn($platform); return new ConnectionMock([], $driver); } diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index c649c133ee1..68cda5eb2ec 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -333,17 +333,12 @@ public function testSupportsAggregateFunctionWithSimpleArithmetic(): void */ public function testSupportsAggregateCountFunctionWithSimpleArithmetic(): void { - $connMock = $this->entityManager->getConnection(); - $orgPlatform = $connMock->getDatabasePlatform(); - - $connMock->setDatabasePlatform(new MySQLPlatform()); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $this->assertSqlGeneration( 'SELECT COUNT(CONCAT(u.id, u.name)) FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id', 'SELECT COUNT(CONCAT(c0_.id, c0_.name)) AS sclr_0 FROM cms_users c0_ GROUP BY c0_.id' ); - - $connMock->setDatabasePlatform($orgPlatform); } public function testSupportsWhereClauseWithPositionalParameter(): void @@ -650,10 +645,8 @@ public function testInExpressionWithArithmeticExpression(): void public function testSupportsConcatFunctionForMysqlAndPostgresql(): void { - $connMock = $this->entityManager->getConnection(); - $orgPlatform = $connMock->getDatabasePlatform(); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $connMock->setDatabasePlatform(new MySQLPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE CONCAT(c0_.name, 's') = ?" @@ -663,7 +656,7 @@ public function testSupportsConcatFunctionForMysqlAndPostgresql(): void 'SELECT CONCAT(c0_.id, c0_.name) AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?' ); - $connMock->setDatabasePlatform(new PostgreSQLPlatform()); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE c0_.name || 's' = ?" @@ -672,8 +665,6 @@ public function testSupportsConcatFunctionForMysqlAndPostgresql(): void 'SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', 'SELECT c0_.id || c0_.name AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?' ); - - $connMock->setDatabasePlatform($orgPlatform); } public function testSupportsExistsExpressionInWherePartWithCorrelatedSubquery(): void @@ -940,9 +931,7 @@ public function testOrderBySupportsSingleValuedPathExpressionInverseSide(): void public function testBooleanLiteralInWhereOnSqlite(): void { - $oldPlat = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new SqlitePlatform()); - + $this->entityManager = $this->createTestEntityManagerWithPlatform(new SqlitePlatform()); $this->assertSqlGeneration( 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true', 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanField_1 FROM boolean_model b0_ WHERE b0_.booleanField = 1' @@ -952,15 +941,11 @@ public function testBooleanLiteralInWhereOnSqlite(): void 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false', 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanField_1 FROM boolean_model b0_ WHERE b0_.booleanField = 0' ); - - $this->entityManager->getConnection()->setDatabasePlatform($oldPlat); } public function testBooleanLiteralInWhereOnPostgres(): void { - $oldPlat = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); - + $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $this->assertSqlGeneration( 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true', 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanfield_1 FROM boolean_model b0_ WHERE b0_.booleanField = true' @@ -970,8 +955,6 @@ public function testBooleanLiteralInWhereOnPostgres(): void 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false', 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanfield_1 FROM boolean_model b0_ WHERE b0_.booleanField = false' ); - - $this->entityManager->getConnection()->setDatabasePlatform($oldPlat); } public function testSingleValuedAssociationFieldInWhere(): void @@ -1101,7 +1084,7 @@ public function testPessimisticWriteLockQueryHint(): void */ public function testPessimisticReadLockQueryHintPostgreSql(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", @@ -1142,7 +1125,7 @@ public function testSupportSelectWithMoreThan10InputParameters(): void */ public function testPessimisticReadLockQueryHintMySql(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", @@ -1158,7 +1141,7 @@ public function testPessimisticReadLockQueryHintMySql(): void */ public function testPessimisticReadLockQueryHintOracle(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new OraclePlatform()); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", @@ -2108,10 +2091,8 @@ public function testCaseThenFunction(): void */ public function testSupportsMoreThanTwoParametersInConcatFunction(): void { - $connMock = $this->entityManager->getConnection(); - $orgPlatform = $connMock->getDatabasePlatform(); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $connMock->setDatabasePlatform(new MySQLPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1", "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE CONCAT(c0_.name, c0_.status, 's') = ?" @@ -2120,8 +2101,6 @@ public function testSupportsMoreThanTwoParametersInConcatFunction(): void 'SELECT CONCAT(u.id, u.name, u.status) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', 'SELECT CONCAT(c0_.id, c0_.name, c0_.status) AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?' ); - - $connMock->setDatabasePlatform($orgPlatform); } /** diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index e6759094ae8..22db3ea66de 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -29,10 +29,9 @@ public function testLimitSubquery(): void public function testLimitSubqueryWithSortPg(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title' ); $limitQuery = clone $query; @@ -42,16 +41,13 @@ public function testLimitSubqueryWithSortPg(): void 'SELECT DISTINCT id_0, MIN(sclr_5) AS dctrn_minrownum FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS sclr_5, m0_.author_id AS author_id_6, m0_.category_id AS category_id_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', $limitQuery->getSQL() ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testLimitSubqueryWithScalarSortPg(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity' ); $limitQuery = clone $query; @@ -61,16 +57,13 @@ public function testLimitSubqueryWithScalarSortPg(): void 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', $limitQuery->getSQL() ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testLimitSubqueryWithMixedSortPg(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC' ); $limitQuery = clone $query; @@ -80,16 +73,13 @@ public function testLimitSubqueryWithMixedSortPg(): void 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', $limitQuery->getSQL() ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testLimitSubqueryWithHiddenScalarSortPg(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT u, g, COUNT(g.id) AS hidden g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC' ); $limitQuery = clone $query; @@ -99,26 +89,20 @@ public function testLimitSubqueryWithHiddenScalarSortPg(): void 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', $limitQuery->getSQL() ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testLimitSubqueryPg(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $this->testLimitSubquery(); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testLimitSubqueryWithSortOracle(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new OraclePlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title' ); $query->expireQueryCache(true); @@ -129,16 +113,13 @@ public function testLimitSubqueryWithSortOracle(): void 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS SCLR_5, m0_.author_id AS AUTHOR_ID_6, m0_.category_id AS CATEGORY_ID_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', $limitQuery->getSQL() ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testLimitSubqueryWithScalarSortOracle(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new OraclePlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity' ); $query->expireQueryCache(true); @@ -149,16 +130,13 @@ public function testLimitSubqueryWithScalarSortOracle(): void 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC', $limitQuery->getSQL() ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testLimitSubqueryWithMixedSortOracle(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new OraclePlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC' ); $query->expireQueryCache(true); @@ -169,16 +147,13 @@ public function testLimitSubqueryWithMixedSortOracle(): void 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC', $limitQuery->getSQL() ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testLimitSubqueryOracle(): void { - $odp = $this->entityManager->getConnection()->getDatabasePlatform(); - $this->entityManager->getConnection()->setDatabasePlatform(new OraclePlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a' ); $query->expireQueryCache(true); @@ -189,8 +164,6 @@ public function testLimitSubqueryOracle(): void 'SELECT DISTINCT ID_0 FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, m0_.author_id AS AUTHOR_ID_5, m0_.category_id AS CATEGORY_ID_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result', $limitQuery->getSQL() ); - - $this->entityManager->getConnection()->setDatabasePlatform($odp); } public function testCountQueryMixedResultsWithName(): void @@ -212,10 +185,11 @@ public function testCountQueryMixedResultsWithName(): void */ public function testCountQueryWithArithmeticOrderByCondition(): void { - $query = $this->entityManager->createQuery( + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); + + $query = $entityManager->createQuery( 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY (1 - 1000) * 1 DESC' ); - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); @@ -227,10 +201,11 @@ public function testCountQueryWithArithmeticOrderByCondition(): void public function testCountQueryWithComplexScalarOrderByItem(): void { - $query = $this->entityManager->createQuery( + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); + + $query = $entityManager->createQuery( 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC' ); - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); @@ -242,10 +217,11 @@ public function testCountQueryWithComplexScalarOrderByItem(): void public function testCountQueryWithComplexScalarOrderByItemJoined(): void { - $query = $this->entityManager->createQuery( + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); + + $query = $entityManager->createQuery( 'SELECT u FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC' ); - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); @@ -257,10 +233,11 @@ public function testCountQueryWithComplexScalarOrderByItemJoined(): void public function testCountQueryWithComplexScalarOrderByItemJoinedWithPartial(): void { - $query = $this->entityManager->createQuery( + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); + + $query = $entityManager->createQuery( 'SELECT u, partial a.{id, imageAltDesc} FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC' ); - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); @@ -272,10 +249,11 @@ public function testCountQueryWithComplexScalarOrderByItemJoinedWithPartial(): v public function testCountQueryWithComplexScalarOrderByItemOracle(): void { - $query = $this->entityManager->createQuery( + $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); + + $query = $entityManager->createQuery( 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC' ); - $this->entityManager->getConnection()->setDatabasePlatform(new OraclePlatform()); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); @@ -304,10 +282,11 @@ public function testLimitSubqueryWithHiddenSelectionInOrderBy(): void public function testLimitSubqueryWithColumnWithSortDirectionInName(): void { - $query = $this->entityManager->createQuery( + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); + + $query = $entityManager->createQuery( 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageAltDesc DESC' ); - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); @@ -333,8 +312,8 @@ public function testLimitSubqueryWithOrderByInnerJoined(): void public function testLimitSubqueryWithOrderByAndSubSelectInWhereClauseMySql(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); - $query = $this->entityManager->createQuery( + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); + $query = $entityManager->createQuery( 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b WHERE ((SELECT COUNT(simple.id) FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost simple) = 1) ORDER BY b.id DESC' @@ -349,8 +328,8 @@ public function testLimitSubqueryWithOrderByAndSubSelectInWhereClauseMySql(): vo public function testLimitSubqueryWithOrderByAndSubSelectInWhereClausePgSql(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); - $query = $this->entityManager->createQuery( + $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); + $query = $entityManager->createQuery( 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b WHERE ((SELECT COUNT(simple.id) FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost simple) = 1) ORDER BY b.id DESC' @@ -368,10 +347,10 @@ public function testLimitSubqueryWithOrderByAndSubSelectInWhereClausePgSql(): vo */ public function testLimitSubqueryOrderByFieldFromMappedSuperclass(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); // now use the third one in query - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC' ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); @@ -387,9 +366,9 @@ public function testLimitSubqueryOrderByFieldFromMappedSuperclass(): void */ public function testLimitSubqueryOrderBySubSelectOrderByExpression(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new MySQLPlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT a, ( SELECT MIN(bp.title) @@ -412,9 +391,9 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpression(): void */ public function testLimitSubqueryOrderBySubSelectOrderByExpressionPg(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new PostgreSQLPlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT a, ( SELECT MIN(bp.title) @@ -437,9 +416,9 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpressionPg(): void */ public function testLimitSubqueryOrderBySubSelectOrderByExpressionOracle(): void { - $this->entityManager->getConnection()->setDatabasePlatform(new OraclePlatform()); + $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->entityManager->createQuery( + $query = $entityManager->createQuery( 'SELECT a, ( SELECT MIN(bp.title) diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index 22381ac98df..766bacd0f6e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\Decorator\EntityManagerDecorator; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; @@ -26,13 +27,23 @@ class PaginatorTest extends OrmTestCase protected function setUp(): void { + $platform = $this->getMockBuilder(AbstractPlatform::class) + ->onlyMethods(['supportsIdentityColumns']) + ->getMockForAbstractClass(); + $platform->method('supportsIdentityColumns') + ->willReturn(true); + + $driver = $this->createMock(Driver::class); + $driver->method('getDatabasePlatform') + ->willReturn($platform); + $this->connection = $this->getMockBuilder(ConnectionMock::class) - ->setConstructorArgs([[], $this->createMock(Driver::class)]) + ->setConstructorArgs([[], $driver]) ->setMethods(['executeQuery']) ->getMock(); $this->em = $this->getMockBuilder(EntityManagerDecorator::class) - ->setConstructorArgs([$this->getTestEntityManager($this->connection)]) + ->setConstructorArgs([$this->createTestEntityManagerWithConnection($this->connection)]) ->setMethods(['newHydrator']) ->getMock(); diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index a180b26d3bc..68062ede804 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -600,9 +600,17 @@ public function testPreviousDetectedIllegalNewNonCascadedEntitiesAreCleanedUpOnS */ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitReturnFalse(): void { + $platform = $this->getMockBuilder(AbstractPlatform::class) + ->onlyMethods(['supportsIdentityColumns']) + ->getMockForAbstractClass(); + $platform->method('supportsIdentityColumns') + ->willReturn(true); + $driver = $this->createMock(Driver::class); $driver->method('connect') ->willReturn($this->createMock(Driver\Connection::class)); + $driver->method('getDatabasePlatform') + ->willReturn($platform); // Set another connection mock that fail on commit $this->_connectionMock = $this->getMockBuilder(ConnectionMock::class) diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 7e9224aac31..a8a0807b004 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\ORMSetup; +use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -72,7 +73,26 @@ protected function createAnnotationDriver(array $paths = []): AnnotationDriver * be configured in the tests to simulate the DBAL behavior that is desired * for a particular test, */ - protected function getTestEntityManager(?Connection $connection = null): EntityManagerMock + protected function getTestEntityManager(): EntityManagerMock + { + return $this->buildTestEntityManagerWithPlatform( + $this->createConnectionMock($this->createPlatformMock()) + ); + } + + protected function createTestEntityManagerWithConnection(Connection $connection): EntityManagerMock + { + return $this->buildTestEntityManagerWithPlatform($connection); + } + + protected function createTestEntityManagerWithPlatform(AbstractPlatform $platform): EntityManagerMock + { + return $this->buildTestEntityManagerWithPlatform( + $this->createConnectionMock($platform) + ); + } + + private function buildTestEntityManagerWithPlatform(Connection $connection): EntityManagerMock { $metadataCache = self::getSharedMetadataCacheImpl(); @@ -100,10 +120,6 @@ protected function getTestEntityManager(?Connection $connection = null): EntityM $config->setSecondLevelCacheConfiguration($cacheConfig); } - if ($connection === null) { - $connection = new Mocks\ConnectionMock([], $this->createDriverMock()); - } - return EntityManagerMock::create($connection, $config); } @@ -131,7 +147,23 @@ protected function getSharedSecondLevelCache(): CacheItemPoolInterface ?? $this->secondLevelCache = new ArrayAdapter(); } - private function createDriverMock(): Driver + private function createConnectionMock(AbstractPlatform $platform): ConnectionMock + { + return new ConnectionMock([], $this->createDriverMock($platform)); + } + + private function createPlatformMock(): AbstractPlatform + { + $platform = $this->getMockBuilder(AbstractPlatform::class) + ->onlyMethods(['supportsIdentityColumns']) + ->getMockForAbstractClass(); + $platform->method('supportsIdentityColumns') + ->willReturn(true); + + return $platform; + } + + private function createDriverMock(AbstractPlatform $platform): Driver { $result = $this->createMock(Driver\Result::class); $result->method('fetchAssociative') @@ -141,10 +173,6 @@ private function createDriverMock(): Driver $connection->method('query') ->willReturn($result); - $platform = $this->createMock(AbstractPlatform::class); - $platform->method('supportsIdentityColumns') - ->willReturn(true); - $driver = $this->createMock(Driver::class); $driver->method('connect') ->willReturn($connection); From a8b4f0541804d6d6bbf364f1966d8873c7d22571 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 2 May 2022 08:14:18 -0700 Subject: [PATCH 069/475] Remove ConnectionMock::delete() (#9717) --- tests/Doctrine/Tests/Mocks/ConnectionMock.php | 19 ------- .../BasicEntityPersisterTypeValueSqlTest.php | 52 ++++++++++++------- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php index 81a3351e18b..b0635b2782c 100644 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -19,9 +19,6 @@ class ConnectionMock extends Connection /** @var array */ private $_executeStatements = []; - /** @var array */ - private $_deletes = []; - public function getDatabase(): string { return 'mock'; @@ -52,14 +49,6 @@ public function executeStatement($sql, array $params = [], array $types = []): i return 1; } - /** - * {@inheritdoc} - */ - public function delete($table, array $criteria, array $types = []) - { - $this->_deletes[] = ['table' => $table, 'criteria' => $criteria, 'types' => $types]; - } - public function query(?string $sql = null): Result { throw new BadMethodCallException('Call to deprecated method.'); @@ -84,12 +73,4 @@ public function getExecuteStatements(): array { return $this->_executeStatements; } - - /** - * @return array - */ - public function getDeletes(): array - { - return $this->_deletes; - } } diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index 402544af550..d6f418a8070 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -6,6 +6,9 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Expr\Comparison; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; use Doctrine\Tests\DbalTypes\NegativeToPositiveType; @@ -17,8 +20,6 @@ use Doctrine\Tests\OrmTestCase; use ReflectionMethod; -use function array_shift; - class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase { protected BasicEntityPersister $persister; @@ -161,26 +162,39 @@ public function testCountEntities(): void public function testDeleteManyToManyUsesTypeValuesSQL(): void { - $friend = new CustomTypeParent(); - $parent = new CustomTypeParent(); - $parent->addMyFriend($friend); + $connection = $this->getMockBuilder(Connection::class) + ->setConstructorArgs([[], $this->createMock(Driver::class)]) + ->onlyMethods(['delete', 'getDatabasePlatform']) + ->getMock(); + $connection->method('getDatabasePlatform') + ->willReturn($this->createMock(AbstractPlatform::class)); - $this->entityManager->getUnitOfWork()->registerManaged($parent, ['id' => 1], []); - $this->entityManager->getUnitOfWork()->registerManaged($friend, ['id' => 2], []); + $entityManager = $this->createTestEntityManagerWithConnection($connection); - $this->persister->delete($parent); + $persister = new BasicEntityPersister($entityManager, $this->entityManager->getClassMetadata(CustomTypeParent::class)); - $deletes = $this->entityManager->getConnection()->getDeletes(); + $friend = new CustomTypeParent(); + $parent = new CustomTypeParent(); + $parent->addMyFriend($friend); - self::assertEquals([ - 'table' => 'customtype_parent_friends', - 'criteria' => ['friend_customtypeparent_id' => 1], - 'types' => ['integer'], - ], array_shift($deletes)); - self::assertEquals([ - 'table' => 'customtype_parent_friends', - 'criteria' => ['customtypeparent_id' => 1], - 'types' => ['integer'], - ], array_shift($deletes)); + $entityManager->getUnitOfWork()->registerManaged($parent, ['id' => 1], []); + $entityManager->getUnitOfWork()->registerManaged($friend, ['id' => 2], []); + + $connection->expects($this->atLeast(2)) + ->method('delete') + ->will($this->onConsecutiveCalls( + [ + 'customtype_parent_friends', + ['friend_customtypeparent_id' => 1], + ['integer'], + ], + [ + 'customtype_parent_friends', + ['customtypeparent_id' => 1], + ['integer'], + ] + )); + + $persister->delete($parent); } } From b8d3929dce4a56c3374ed47813358a5325913ab6 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 2 May 2022 09:31:33 -0700 Subject: [PATCH 070/475] Remove DriverResultMock (#9722) --- .../Performance/EntityManagerFactory.php | 4 +- .../Doctrine/Tests/Mocks/DriverResultMock.php | 100 ------------------ 2 files changed, 2 insertions(+), 102 deletions(-) delete mode 100644 tests/Doctrine/Tests/Mocks/DriverResultMock.php diff --git a/tests/Doctrine/Performance/EntityManagerFactory.php b/tests/Doctrine/Performance/EntityManagerFactory.php index e3bc443ca7c..74416b2f33d 100644 --- a/tests/Doctrine/Performance/EntityManagerFactory.php +++ b/tests/Doctrine/Performance/EntityManagerFactory.php @@ -5,6 +5,7 @@ namespace Doctrine\Performance; use Doctrine\Common\EventManager; +use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\PDO\SQLite\Driver; @@ -15,7 +16,6 @@ use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Tools\SchemaTool; -use Doctrine\Tests\Mocks\DriverResultMock; use function array_map; use function realpath; @@ -67,7 +67,7 @@ public static function makeEntityManagerWithNoResultsConnection(): EntityManager /** {@inheritdoc} */ public function executeQuery(string $sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null): Result { - return new Result(new DriverResultMock(), $this); + return new Result(new ArrayResult([]), $this); } }; diff --git a/tests/Doctrine/Tests/Mocks/DriverResultMock.php b/tests/Doctrine/Tests/Mocks/DriverResultMock.php deleted file mode 100644 index b5f25d0c5b6..00000000000 --- a/tests/Doctrine/Tests/Mocks/DriverResultMock.php +++ /dev/null @@ -1,100 +0,0 @@ -> */ - private $resultSet; - - /** - * Creates a new mock statement that will serve the provided fake result set to clients. - * - * @param list> $resultSet The faked SQL result set. - */ - public function __construct(array $resultSet = []) - { - $this->resultSet = $resultSet; - } - - /** - * {@inheritdoc} - */ - public function fetchNumeric() - { - $row = $this->fetchAssociative(); - - return $row === false ? false : array_values($row); - } - - /** - * {@inheritdoc} - */ - public function fetchAssociative() - { - $current = current($this->resultSet); - next($this->resultSet); - - return $current; - } - - /** - * {@inheritdoc} - */ - public function fetchOne() - { - $row = $this->fetchNumeric(); - - return $row ? $row[0] : false; - } - - public function fetchAllNumeric(): array - { - $values = []; - while (($row = $this->fetchNumeric()) !== false) { - $values[] = $row; - } - - return $values; - } - - public function fetchAllAssociative(): array - { - $resultSet = $this->resultSet; - reset($resultSet); - - return $resultSet; - } - - public function fetchFirstColumn(): array - { - throw new BadMethodCallException('Not implemented'); - } - - public function rowCount(): int - { - return 0; - } - - public function columnCount(): int - { - $resultSet = $this->resultSet; - - return count(reset($resultSet) ?: []); - } - - public function free(): void - { - } -} From 4c2950a9da631a6f5b201f595ae31b968a995365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 2 May 2022 19:55:42 +0200 Subject: [PATCH 071/475] Remove last references to ClassMetadataInfo (#9713) * Remove disconnected class metadata factory It is unused apart from a tests where it is easily replaced. * Remove ClassMetadataInfo It has been deprecated for a long, long time. --- UPGRADE.md | 4 +++ .../Mapping/Builder/ClassMetadataBuilder.php | 24 ++------------- .../ORM/Mapping/ClassMetadataFactory.php | 6 ++-- .../ORM/Mapping/Driver/DatabaseDriver.php | 7 ++--- lib/Doctrine/ORM/PersistentCollection.php | 5 +--- .../DisconnectedClassMetadataFactory.php | 29 ------------------- lib/Doctrine/ORM/Tools/SchemaValidator.php | 16 +--------- phpstan-baseline.neon | 5 ---- .../ORM/Tools/Console/MetadataFilterTest.php | 6 ++-- 9 files changed, 18 insertions(+), 84 deletions(-) delete mode 100644 lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php diff --git a/UPGRADE.md b/UPGRADE.md index 566160c68c4..95641778e1f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Remove `Doctrine\ORM\Tools\DisconnectedClassMetadataFactory` + +No replacement is provided. + ## BC BREAK: Remove support for `Type::canRequireSQLConversion()` This feature was deprecated in DBAL 3.3.0 and will be removed in DBAL 4.0. diff --git a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php index 3af7f3036da..4647bebab3c 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php @@ -4,11 +4,7 @@ namespace Doctrine\ORM\Mapping\Builder; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\ClassMetadataInfo; - -use function get_class; /** * Builder Object for ClassMetadata @@ -17,29 +13,15 @@ */ class ClassMetadataBuilder { - /** @var ClassMetadataInfo */ + /** @var ClassMetadata */ private $cm; - public function __construct(ClassMetadataInfo $cm) + public function __construct(ClassMetadata $cm) { - if (! $cm instanceof ClassMetadata) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/249', - 'Passing an instance of %s to %s is deprecated, please pass a ClassMetadata instance instead.', - get_class($cm), - __METHOD__, - ClassMetadata::class - ); - } - $this->cm = $cm; } - /** - * @return ClassMetadataInfo - */ - public function getClassMetadata() + public function getClassMetadata(): ClassMetadata { return $this->cm; } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 11c156ba7b0..17077acdd88 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -249,7 +249,7 @@ protected function validateRuntimeMetadata(ClassMetadata $class, ?ClassMetadataI } } } else { - assert($parent instanceof ClassMetadataInfo); // https://github.com/doctrine/orm/issues/8746 + assert($parent instanceof ClassMetadata); // https://github.com/doctrine/orm/issues/8746 if ( ! $class->reflClass->isAbstract() && ! in_array($class->name, $class->discriminatorMap, true) @@ -477,7 +477,7 @@ private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, Class * * @throws ORMException */ - private function completeIdGeneratorMapping(ClassMetadataInfo $class): void + private function completeIdGeneratorMapping(ClassMetadata $class): void { $idGenType = $class->generatorType; if ($idGenType === ClassMetadata::GENERATOR_TYPE_AUTO) { @@ -612,7 +612,7 @@ private function truncateSequenceName(string $schemaElementName): string /** * Inherits the ID generator mapping from a parent class. */ - private function inheritIdGeneratorMapping(ClassMetadataInfo $class, ClassMetadataInfo $parent): void + private function inheritIdGeneratorMapping(ClassMetadata $class, ClassMetadata $parent): void { if ($parent->isIdGeneratorSequence()) { $class->setSequenceGeneratorDefinition($parent->sequenceGeneratorDefinition); diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index 9b9799dc448..e6c3232f2b1 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -14,7 +14,6 @@ use Doctrine\Inflector\Inflector; use Doctrine\Inflector\InflectorFactory; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; use Doctrine\Persistence\Mapping\Driver\MappingDriver; @@ -319,7 +318,7 @@ private function reverseEngineerMappingFromDatabase(): void /** * Build indexes from a class metadata. */ - private function buildIndexes(ClassMetadataInfo $metadata): void + private function buildIndexes(ClassMetadata $metadata): void { $tableName = $metadata->table['name']; $indexes = $this->tables[$tableName]->getIndexes(); @@ -342,7 +341,7 @@ private function buildIndexes(ClassMetadataInfo $metadata): void /** * Build field mapping from class metadata. */ - private function buildFieldMappings(ClassMetadataInfo $metadata): void + private function buildFieldMappings(ClassMetadata $metadata): void { $tableName = $metadata->table['name']; $columns = $this->tables[$tableName]->getColumns(); @@ -457,7 +456,7 @@ private function buildFieldMapping(string $tableName, Column $column): array * * @return void */ - private function buildToOneAssociationMappings(ClassMetadataInfo $metadata) + private function buildToOneAssociationMappings(ClassMetadata $metadata) { $tableName = $metadata->table['name']; $primaryKeys = $this->getTablePrimaryKeys($this->tables[$tableName]); diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index aa8cb92b65a..8b3db0a7c9a 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -131,10 +131,7 @@ public function getOwner() return $this->owner; } - /** - * @return Mapping\ClassMetadata - */ - public function getTypeClass(): Mapping\ClassMetadataInfo + public function getTypeClass(): Mapping\ClassMetadata { return $this->typeClass; } diff --git a/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php b/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php deleted file mode 100644 index ee29b112831..00000000000 --- a/lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php +++ /dev/null @@ -1,29 +0,0 @@ - */ - public function validateClass(ClassMetadataInfo $class) + public function validateClass(ClassMetadata $class) { - if (! $class instanceof ClassMetadata) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/249', - 'Passing an instance of %s to %s is deprecated, please pass a ClassMetadata instance instead.', - get_class($class), - __METHOD__, - ClassMetadata::class - ); - } - $ce = []; $cmf = $this->em->getMetadataFactory(); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1248b7147e5..35527c844e9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -140,11 +140,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - message: "#^Parameter \\#2 \\$class of method Doctrine\\\\ORM\\\\Mapping\\\\QuoteStrategy\\:\\:getSequenceName\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo given\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\NamingStrategy\\:\\:joinColumnName\\(\\) invoked with 2 parameters, 1 required\\.$#" count: 2 diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php index 19f40eb34f6..b04215ae4e5 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php @@ -4,11 +4,11 @@ namespace Doctrine\Tests\ORM\Tools\Console; +use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Tools\Console\MetadataFilter; -use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; use Doctrine\Tests\OrmTestCase; use function count; @@ -20,7 +20,7 @@ */ class MetadataFilterTest extends OrmTestCase { - /** @var DisconnectedClassMetadataFactory */ + /** @var ClassMetadataFactory */ private $cmf; protected function setUp(): void @@ -32,7 +32,7 @@ protected function setUp(): void $em->getConfiguration()->setMetadataDriverImpl($driver); - $this->cmf = new DisconnectedClassMetadataFactory(); + $this->cmf = new ClassMetadataFactory(); $this->cmf->setEntityManager($em); } From 3c41e421deeace614ddd38ba52765f64b95f85fc Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 2 May 2022 14:30:40 -0700 Subject: [PATCH 072/475] Remove ConnectionMock (#9724) * Remove ConnectionMock::getExecuteStatements() * Remove ConnectionMock::quote() * Remove ConnectionMock --- tests/Doctrine/Tests/Mocks/ConnectionMock.php | 76 ------------------- .../BasicEntityPersisterTypeValueSqlTest.php | 35 +++++++-- .../Persisters/ManyToManyPersisterTest.php | 35 +++++---- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 3 +- .../ORM/Tools/Pagination/PaginatorTest.php | 3 +- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 21 +++-- tests/Doctrine/Tests/OrmTestCase.php | 14 +++- 7 files changed, 69 insertions(+), 118 deletions(-) delete mode 100644 tests/Doctrine/Tests/Mocks/ConnectionMock.php diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php deleted file mode 100644 index b0635b2782c..00000000000 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ /dev/null @@ -1,76 +0,0 @@ -_executeStatements[] = ['sql' => $sql, 'params' => $params, 'types' => $types]; - - return 1; - } - - public function query(?string $sql = null): Result - { - throw new BadMethodCallException('Call to deprecated method.'); - } - - /** - * {@inheritdoc} - */ - public function quote($input, $type = null) - { - if (is_string($input)) { - return "'" . $input . "'"; - } - - return $input; - } - - /** - * @return array - */ - public function getExecuteStatements(): array - { - return $this->_executeStatements; - } -} diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index d6f418a8070..9d70cbe0f7a 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -58,23 +58,44 @@ public function testGetInsertSQLUsesTypeValuesSQL(): void public function testUpdateUsesTypeValuesSQL(): void { + $driver = $this->createMock(Driver::class); + $driver->method('connect') + ->willReturn($this->createMock(Driver\Connection::class)); + + $platform = $this->getMockBuilder(AbstractPlatform::class) + ->onlyMethods(['supportsIdentityColumns']) + ->getMockForAbstractClass(); + $platform->method('supportsIdentityColumns') + ->willReturn(true); + + $connection = $this->getMockBuilder(Connection::class) + ->setConstructorArgs([[], $driver]) + ->onlyMethods(['executeStatement', 'getDatabasePlatform']) + ->getMock(); + $connection->method('getDatabasePlatform') + ->willReturn($platform); + $child = new CustomTypeChild(); $parent = new CustomTypeParent(); $parent->customInteger = 1; $parent->child = $child; - $this->entityManager->getUnitOfWork()->registerManaged($parent, ['id' => 1], ['customInteger' => 0, 'child' => null]); - $this->entityManager->getUnitOfWork()->registerManaged($child, ['id' => 1], []); + $entityManager = $this->createTestEntityManagerWithConnection($connection); + + $entityManager->getUnitOfWork()->registerManaged($parent, ['id' => 1], ['customInteger' => 0, 'child' => null]); + $entityManager->getUnitOfWork()->registerManaged($child, ['id' => 1], []); - $this->entityManager->getUnitOfWork()->propertyChanged($parent, 'customInteger', 0, 1); - $this->entityManager->getUnitOfWork()->propertyChanged($parent, 'child', null, $child); + $entityManager->getUnitOfWork()->propertyChanged($parent, 'customInteger', 0, 1); + $entityManager->getUnitOfWork()->propertyChanged($parent, 'child', null, $child); - $this->persister->update($parent); + $persister = new BasicEntityPersister($entityManager, $entityManager->getClassMetadata(CustomTypeParent::class)); - $executeStatements = $this->entityManager->getConnection()->getExecuteStatements(); + $connection->expects($this->once()) + ->method('executeStatement') + ->with('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?'); - self::assertEquals('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?', $executeStatements[0]['sql']); + $persister->update($parent); } public function testGetSelectConditionSQLUsesTypeValuesSQL(): void diff --git a/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php index 7c9591c93d8..02046cd3149 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php @@ -4,16 +4,15 @@ namespace Doctrine\Tests\ORM\Persisters; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\Persisters\Collection\ManyToManyPersister; -use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Models\ManyToManyPersister\ChildClass; use Doctrine\Tests\Models\ManyToManyPersister\OtherParentClass; use Doctrine\Tests\Models\ManyToManyPersister\ParentClass; use Doctrine\Tests\OrmTestCase; -use function array_pop; -use function assert; - /** * @covers \Doctrine\ORM\Persisters\Collection\ManyToManyPersister */ @@ -25,6 +24,17 @@ final class ManyToManyPersisterTest extends OrmTestCase */ public function testDeleteManyToManyCollection(): void { + $driver = $this->createMock(Driver::class); + $driver->method('connect') + ->willReturn($this->createMock(Driver\Connection::class)); + + $connection = $this->getMockBuilder(Connection::class) + ->setConstructorArgs([[], $driver]) + ->onlyMethods(['executeStatement', 'getDatabasePlatform']) + ->getMock(); + $connection->method('getDatabasePlatform') + ->willReturn($this->getMockForAbstractClass(AbstractPlatform::class)); + $parent = new ParentClass(1); $otherParent = new OtherParentClass(42); $child = new ChildClass(1, $otherParent); @@ -32,25 +42,18 @@ public function testDeleteManyToManyCollection(): void $parent->children->add($child); $child->parents->add($parent); - $em = $this->getTestEntityManager(); + $em = $this->createTestEntityManagerWithConnection($connection); $em->persist($parent); $em->flush(); $childReloaded = $em->find(ChildClass::class, ['id1' => 1, 'otherParent' => $otherParent]); - assert($childReloaded instanceof ChildClass || $childReloaded === null); + self::assertInstanceOf(ChildClass::class, $childReloaded); - self::assertNotNull($childReloaded); + $connection->expects($this->once()) + ->method('executeStatement') + ->with('DELETE FROM parent_child WHERE child_id1 = ? AND child_id2 = ?', [1, 42]); $persister = new ManyToManyPersister($em); $persister->delete($childReloaded->parents); - - $conn = $em->getConnection(); - assert($conn instanceof ConnectionMock); - - $updates = $conn->getExecuteStatements(); - $lastStatement = array_pop($updates); - - self::assertEquals('DELETE FROM parent_child WHERE child_id1 = ? AND child_id2 = ?', $lastStatement['sql']); - self::assertEquals([1, 42], $lastStatement['params']); } } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index b8839c67698..7c560292283 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -17,7 +17,6 @@ use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; -use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsGroup; @@ -596,6 +595,6 @@ private function createConnection(Driver\Result ...$results): Connection $driver->method('getDatabasePlatform') ->willReturn($platform); - return new ConnectionMock([], $driver); + return new Connection([], $driver); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index 766bacd0f6e..435d5119058 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Query; use Doctrine\ORM\Tools\Pagination\Paginator; -use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\MockObject\MockObject; @@ -37,7 +36,7 @@ protected function setUp(): void $driver->method('getDatabasePlatform') ->willReturn($platform); - $this->connection = $this->getMockBuilder(ConnectionMock::class) + $this->connection = $this->getMockBuilder(Connection::class) ->setConstructorArgs([[], $driver]) ->setMethods(['executeQuery']) ->getMock(); diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 68062ede804..b4619a3b4f8 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -24,7 +24,6 @@ use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\NotifyPropertyChanged; use Doctrine\Persistence\PropertyChangedListener; -use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\EntityPersisterMock; use Doctrine\Tests\Mocks\UnitOfWorkMock; @@ -55,9 +54,9 @@ class UnitOfWorkTest extends OrmTestCase /** * Provides a sequence mock to the UnitOfWork * - * @var ConnectionMock&MockObject + * @var Connection&MockObject */ - private $_connectionMock; + private $connection; /** * The EntityManager mock that provides the mock persisters @@ -94,11 +93,9 @@ protected function setUp(): void $driver->method('connect') ->willReturn($driverConnection); - $connection = new Connection([], $driver); - - $this->_connectionMock = $connection; - $this->eventManager = $this->getMockBuilder(EventManager::class)->getMock(); - $this->_emMock = EntityManagerMock::create($connection, null, $this->eventManager); + $this->connection = new Connection([], $driver); + $this->eventManager = $this->getMockBuilder(EventManager::class)->getMock(); + $this->_emMock = EntityManagerMock::create($this->connection, null, $this->eventManager); // SUT $this->_unitOfWork = new UnitOfWorkMock($this->_emMock); $this->_emMock->setUnitOfWork($this->_unitOfWork); @@ -613,15 +610,15 @@ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitReturn ->willReturn($platform); // Set another connection mock that fail on commit - $this->_connectionMock = $this->getMockBuilder(ConnectionMock::class) + $this->connection = $this->getMockBuilder(Connection::class) ->setConstructorArgs([[], $driver]) ->setMethods(['commit']) ->getMock(); - $this->_emMock = EntityManagerMock::create($this->_connectionMock, null, $this->eventManager); - $this->_unitOfWork = new UnitOfWorkMock($this->_emMock); + $this->_emMock = EntityManagerMock::create($this->connection, null, $this->eventManager); + $this->_unitOfWork = new UnitOfWorkMock($this->_emMock); $this->_emMock->setUnitOfWork($this->_unitOfWork); - $this->_connectionMock->method('commit')->willReturn(false); + $this->connection->method('commit')->willReturn(false); // Setup fake persister and id generator $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(ForumUser::class)); diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index a8a0807b004..8400574597d 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -16,12 +16,12 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\ORMSetup; -use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use function realpath; +use function sprintf; /** * Base testcase class for all ORM testcases. @@ -147,9 +147,17 @@ protected function getSharedSecondLevelCache(): CacheItemPoolInterface ?? $this->secondLevelCache = new ArrayAdapter(); } - private function createConnectionMock(AbstractPlatform $platform): ConnectionMock + private function createConnectionMock(AbstractPlatform $platform): Connection { - return new ConnectionMock([], $this->createDriverMock($platform)); + $connection = $this->getMockBuilder(Connection::class) + ->setConstructorArgs([[], $this->createDriverMock($platform)]) + ->onlyMethods(['quote']) + ->getMockForAbstractClass(); + $connection->method('quote')->willReturnCallback(static function (string $input) { + return sprintf("'%s'", $input); + }); + + return $connection; } private function createPlatformMock(): AbstractPlatform From f5e922ed9268997128e7254915d998276c901bff Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 4 May 2022 09:05:40 -0700 Subject: [PATCH 073/475] Test MySQL DDL using explicit table options --- ci/github/phpunit/mysqli.xml | 3 ++ ci/github/phpunit/pdo_mysql.xml | 3 ++ .../SchemaTool/MySqlSchemaToolTest.php | 49 +++++++------------ .../ORM/Functional/Ticket/DDC2182Test.php | 20 ++------ tests/Doctrine/Tests/TestUtil.php | 8 ++- 5 files changed, 32 insertions(+), 51 deletions(-) diff --git a/ci/github/phpunit/mysqli.xml b/ci/github/phpunit/mysqli.xml index b0605067dfd..81ad363497e 100644 --- a/ci/github/phpunit/mysqli.xml +++ b/ci/github/phpunit/mysqli.xml @@ -14,6 +14,9 @@ + + + diff --git a/ci/github/phpunit/pdo_mysql.xml b/ci/github/phpunit/pdo_mysql.xml index b74b05555eb..6f0c786d483 100644 --- a/ci/github/phpunit/pdo_mysql.xml +++ b/ci/github/phpunit/pdo_mysql.xml @@ -14,6 +14,9 @@ + + + diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 52fcd1d7ead..d44c329c176 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -14,9 +14,6 @@ use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; -use function method_exists; -use function sprintf; - class MySqlSchemaToolTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -38,18 +35,17 @@ public function testGetCreateSchemaSql(): void $this->_em->getClassMetadata(Models\CMS\CmsPhonenumber::class), ]; - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - - self::assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); - self::assertEquals('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); - self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[2]); - self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[3]); - self::assertEquals('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[4]); - self::assertEquals('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[5]); - self::assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[6]); - self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[7]); + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + self::assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); + self::assertEquals('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[1]); + self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[2]); + self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[3]); + self::assertEquals('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[4]); + self::assertEquals('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[5]); + self::assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[6]); + self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[7]); self::assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)', $sql[8]); self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[9]); self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id)', $sql[10]); @@ -61,37 +57,26 @@ public function testGetCreateSchemaSql(): void self::assertCount(15, $sql); } - private function getColumnCollationDeclarationSQL(string $collation): string - { - if (method_exists($this->_em->getConnection()->getDatabasePlatform(), 'getColumnCollationDeclarationSQL')) { - return $this->_em->getConnection()->getDatabasePlatform()->getColumnCollationDeclarationSQL($collation); - } - - return sprintf('COLLATE %s', $collation); - } - public function testGetCreateSchemaSql2(): void { $classes = [$this->_em->getClassMetadata(Models\Generic\DecimalModel::class)]; - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); self::assertCount(1, $sql); - self::assertEquals('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); } public function testGetCreateSchemaSql3(): void { $classes = [$this->_em->getClassMetadata(Models\Generic\BooleanModel::class)]; - $tool = new SchemaTool($this->_em); - $sql = $tool->getCreateSchemaSql($classes); - $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); self::assertCount(1, $sql); - self::assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); + self::assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php index b3e9cafc707..90bfc1ad7ae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -13,9 +13,6 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use function method_exists; -use function sprintf; - class DDC2182Test extends OrmFunctionalTestCase { public function testPassColumnOptionsToJoinColumns(): void @@ -24,27 +21,16 @@ public function testPassColumnOptionsToJoinColumns(): void self::markTestSkipped('This test is useful for all databases, but designed only for mysql.'); } - $sql = $this->_schemaTool->getCreateSchemaSql( + $sql = $this->_schemaTool->getCreateSchemaSql( [ $this->_em->getClassMetadata(DDC2182OptionParent::class), $this->_em->getClassMetadata(DDC2182OptionChild::class), ] ); - $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); - - self::assertEquals('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[0]); - self::assertEquals('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 ' . $collation . ' ENGINE = InnoDB', $sql[1]); + self::assertEquals('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); + self::assertEquals('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[1]); self::assertEquals('ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)', $sql[2]); } - - private function getColumnCollationDeclarationSQL(string $collation): string - { - if (method_exists($this->_em->getConnection()->getDatabasePlatform(), 'getColumnCollationDeclarationSQL')) { - return $this->_em->getConnection()->getDatabasePlatform()->getColumnCollationDeclarationSQL($collation); - } - - return sprintf('COLLATE %s', $collation); - } } /** diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index ea2f752d71e..9c5a4d8367a 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -182,11 +182,15 @@ private static function mapConnectionParameters(array $configuration, string $pr } foreach ($configuration as $param => $value) { - if (! str_starts_with($param, $prefix . 'driver_option_')) { + if (str_starts_with($param, $prefix . 'driver_option_')) { + $parameters['driverOptions'][substr($param, strlen($prefix . 'driver_option_'))] = $value; + } + + if (! str_starts_with($param, $prefix . 'default_table_option_')) { continue; } - $parameters['driverOptions'][substr($param, strlen($prefix . 'driver_option_'))] = $value; + $parameters['defaultTableOptions'][substr($param, strlen($prefix . 'default_table_option_'))] = $value; } $parameters['wrapperClass'] = DbalExtensions\Connection::class; From 0c745d9021c7a9d65157948b53c85c28b102fd17 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 3 May 2022 07:35:10 -0700 Subject: [PATCH 074/475] Pass column name as part of the definition See https://github.com/doctrine/dbal/pull/3583 --- lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php | 1 + lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php | 1 + lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index cbf0b5045e7..1caa418908b 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -189,6 +189,7 @@ private function deleteJoinedEntityCollection(PersistentCollection $collection): foreach ($idColumnNames as $idColumnName) { $columnDefinitions[$idColumnName] = [ + 'name' => $idColumnName, 'notnull' => true, 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $this->em)), ]; diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php index 72a0cca3aa1..99b34cefcce 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php @@ -92,6 +92,7 @@ public function __construct(AST\Node $AST, $sqlWalker) $columnDefinitions = []; foreach ($idColumnNames as $idColumnName) { $columnDefinitions[$idColumnName] = [ + 'name' => $idColumnName, 'notnull' => true, 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)), ]; diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php index f5a2e53772b..31e6b4ebe15 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -133,6 +133,7 @@ public function __construct(AST\Node $AST, $sqlWalker) foreach ($idColumnNames as $idColumnName) { $columnDefinitions[$idColumnName] = [ + 'name' => $idColumnName, 'notnull' => true, 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)), ]; From d4a9015c2bee8767717db3d50c071a825ac942be Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 3 May 2022 07:35:17 -0700 Subject: [PATCH 075/475] Look up only string parameter types See https://github.com/doctrine/dbal/pull/3569 --- lib/Doctrine/ORM/Query/SqlWalker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index b42929b5a8c..9e8f1c08840 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -2225,7 +2225,7 @@ public function walkInputParameter($inputParam) if ($parameter) { $type = $parameter->getType(); - if (Type::hasType($type)) { + if (is_string($type) && Type::hasType($type)) { return Type::getType($type)->convertToDatabaseValueSQL('?', $this->platform); } } From 6c64f7db347f39c497126afcaa03348d5df91d67 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 3 May 2022 07:35:25 -0700 Subject: [PATCH 076/475] Quote only strings See https://github.com/doctrine/dbal/pull/3488 --- lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php | 1 + lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php | 4 ++-- lib/Doctrine/ORM/Query/Filter/SQLFilter.php | 6 ++---- lib/Doctrine/ORM/Query/SqlWalker.php | 4 ++-- psalm-baseline.xml | 3 +++ 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 9230a17bdd0..71e1bd2b99a 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -87,6 +87,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad continue; } + unset($classAnnotations[$key]); $classAnnotations[get_class($annot)] = $annot; } diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index bc9becac1cb..af454b666bd 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -135,13 +135,13 @@ protected function getSelectConditionDiscriminatorValueSQL(): string $values = []; if ($this->class->discriminatorValue !== null) { // discriminators can be 0 - $values[] = $this->conn->quote($this->class->discriminatorValue); + $values[] = $this->conn->quote((string) $this->class->discriminatorValue); } $discrValues = array_flip($this->class->discriminatorMap); foreach ($this->class->subClasses as $subclassName) { - $values[] = $this->conn->quote($discrValues[$subclassName]); + $values[] = $this->conn->quote((string) $discrValues[$subclassName]); } $discColumnName = $this->class->getDiscriminatorColumn()['name']; diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index 260b539d6d0..5c41fba8d7f 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -105,9 +105,7 @@ final public function getParameter(string $name): string throw FilterException::cannotConvertListParameterIntoSingleValue($name); } - $param = $this->parameters[$name]; - - return $this->em->getConnection()->quote($param['value'], $param['type']); + return $this->em->getConnection()->quote((string) $this->parameters[$name]['value']); } /** @@ -133,7 +131,7 @@ final public function getParameterList(string $name): string $connection = $this->em->getConnection(); $quoted = array_map( - static fn (mixed $value): string => (string) $connection->quote($value, $param['type']), + static fn (mixed $value): string => $connection->quote((string) $value), $param['value'] ); diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 9e8f1c08840..4dd07526263 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -461,7 +461,7 @@ private function generateDiscriminatorColumnConditionSQL(array $dqlAliases): str } foreach ($class->subClasses as $subclassName) { - $values[] = $conn->quote($this->em->getClassMetadata($subclassName)->discriminatorValue); + $values[] = $conn->quote((string) $this->em->getClassMetadata($subclassName)->discriminatorValue); } $sqlTableAlias = $this->useSqlTableAliases @@ -1812,7 +1812,7 @@ public function walkUpdateItem($updateItem) break; default: - $sql .= $this->conn->quote($newValue); + $sql .= $this->conn->quote((string) $newValue); break; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8bda3a7e50b..230c1ff886e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1063,6 +1063,9 @@ $columnList + + (string) $discrValues[$subclassName] + From 38e954248cfc27b44746f66af293b2e484f2324d Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 3 May 2022 07:35:30 -0700 Subject: [PATCH 077/475] Improve mocks --- .../Persisters/BasicEntityPersisterTypeValueSqlTest.php | 4 ++-- tests/Doctrine/Tests/OrmTestCase.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index 9d70cbe0f7a..49eaf5f9159 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -203,7 +203,7 @@ public function testDeleteManyToManyUsesTypeValuesSQL(): void $connection->expects($this->atLeast(2)) ->method('delete') - ->will($this->onConsecutiveCalls( + ->withConsecutive( [ 'customtype_parent_friends', ['friend_customtypeparent_id' => 1], @@ -214,7 +214,7 @@ public function testDeleteManyToManyUsesTypeValuesSQL(): void ['customtypeparent_id' => 1], ['integer'], ] - )); + ); $persister->delete($parent); } diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 8400574597d..e7f7a1e9039 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\SchemaConfig; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Cache\CacheFactory; use Doctrine\ORM\Cache\DefaultCacheFactory; @@ -181,11 +182,15 @@ private function createDriverMock(AbstractPlatform $platform): Driver $connection->method('query') ->willReturn($result); + $schemaManager = $this->createMock(AbstractSchemaManager::class); + $schemaManager->method('createSchemaConfig') + ->willReturn(new SchemaConfig()); + $driver = $this->createMock(Driver::class); $driver->method('connect') ->willReturn($connection); $driver->method('getSchemaManager') - ->willReturn($this->createMock(AbstractSchemaManager::class)); + ->willReturn($schemaManager); $driver->method('getDatabasePlatform') ->willReturn($platform); From aa8c2937d70b660218ad456f8f3cc6ea66f4c66d Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 3 May 2022 07:35:33 -0700 Subject: [PATCH 078/475] Catch exception from Connection::commit() --- lib/Doctrine/ORM/OptimisticLockException.php | 5 +++-- lib/Doctrine/ORM/UnitOfWork.php | 15 ++++++++++++--- psalm.xml | 2 ++ tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 6 ++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/OptimisticLockException.php b/lib/Doctrine/ORM/OptimisticLockException.php index d151c8732be..91a9e91b1de 100644 --- a/lib/Doctrine/ORM/OptimisticLockException.php +++ b/lib/Doctrine/ORM/OptimisticLockException.php @@ -7,6 +7,7 @@ use DateTimeInterface; use Doctrine\ORM\Exception\ORMException; use Exception; +use Throwable; /** * An OptimisticLockException is thrown when a version check on an object @@ -21,9 +22,9 @@ class OptimisticLockException extends Exception implements ORMException * @param string $msg * @param object|null $entity */ - public function __construct($msg, $entity) + public function __construct($msg, $entity, ?Throwable $previous = null) { - parent::__construct($msg); + parent::__construct($msg, 0, $previous); $this->entity = $entity; } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 2ffc928b3e6..51bef411acb 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -9,6 +9,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\EventManager; use Doctrine\Common\Proxy\Proxy; +use Doctrine\DBAL; use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; use Doctrine\DBAL\LockMode; use Doctrine\Deprecations\Deprecation; @@ -406,9 +407,17 @@ public function commit(): void } } - // Commit failed silently - if ($conn->commit() === false) { - throw new OptimisticLockException('Commit failed', null); + $commitFailed = false; + try { + if ($conn->commit() === false) { + $commitFailed = true; + } + } catch (DBAL\Exception $e) { + $commitFailed = true; + } + + if ($commitFailed) { + throw new OptimisticLockException('Commit failed', null, $e ?? null); } } catch (Throwable $e) { $this->em->close(); diff --git a/psalm.xml b/psalm.xml index 52abbef79b1..9cafaf741e2 100644 --- a/psalm.xml +++ b/psalm.xml @@ -94,6 +94,8 @@ + + diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index b4619a3b4f8..56de6aedcfa 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -7,6 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\EventManager; +use Doctrine\DBAL; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -595,7 +596,7 @@ public function testPreviousDetectedIllegalNewNonCascadedEntitiesAreCleanedUpOnS /** * @group #7946 Throw OptimisticLockException when connection::commit() returns false. */ - public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitReturnFalse(): void + public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails(): void { $platform = $this->getMockBuilder(AbstractPlatform::class) ->onlyMethods(['supportsIdentityColumns']) @@ -618,7 +619,8 @@ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitReturn $this->_unitOfWork = new UnitOfWorkMock($this->_emMock); $this->_emMock->setUnitOfWork($this->_unitOfWork); - $this->connection->method('commit')->willReturn(false); + $this->connection->method('commit') + ->willThrowException(new DBAL\Exception()); // Setup fake persister and id generator $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(ForumUser::class)); From f3113f1a2ffc4706061f0b6d0286040fcb316174 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 3 May 2022 07:34:47 -0700 Subject: [PATCH 079/475] Build with DBAL 4@dev on SQLite --- .github/workflows/continuous-integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b9c09f8397f..e12baef5a3f 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -26,6 +26,8 @@ jobs: include: - php-version: "8.1" dbal-version: "3@dev" + - php-version: "8.1" + dbal-version: "4@dev" steps: - name: "Checkout" From 3f5a1054a812a4a233cdd3fb12d089aa93ef3cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 May 2022 15:11:23 +0200 Subject: [PATCH 080/475] Remove remnants of UuidGeneratorStrategy --- docs/en/reference/annotations-reference.rst | 2 +- docs/en/reference/attributes-reference.rst | 5 ++--- docs/en/reference/basic-mapping.rst | 2 -- doctrine-mapping.xsd | 1 - lib/Doctrine/ORM/Mapping/GeneratedValue.php | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index f8b9efbd61d..f8108e4da2b 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -481,7 +481,7 @@ Optional attributes: - **strategy**: Set the name of the identifier generation strategy. - Valid values are ``AUTO``, ``SEQUENCE``, ``IDENTITY``, ``UUID`` (deprecated), ``CUSTOM`` and ``NONE``, explained + Valid values are ``AUTO``, ``SEQUENCE``, ``IDENTITY``, ``CUSTOM`` and ``NONE``, explained in the :ref:`Identifier Generation Strategies ` section. If not specified, default value is AUTO. diff --git a/docs/en/reference/attributes-reference.rst b/docs/en/reference/attributes-reference.rst index e7e015d4acd..6cc529c1868 100644 --- a/docs/en/reference/attributes-reference.rst +++ b/docs/en/reference/attributes-reference.rst @@ -483,9 +483,8 @@ used as default. Optional parameters: - **strategy**: Set the name of the identifier generation strategy. - Valid values are ``AUTO``, ``SEQUENCE``, ``IDENTITY``, ``UUID`` - (deprecated), ``CUSTOM`` and ``NONE``. - If not specified, the default value is ``AUTO``. + Valid values are ``AUTO``, ``SEQUENCE``, ``IDENTITY``, ``CUSTOM`` and + ``NONE``. If not specified, the default value is ``AUTO``. Example: diff --git a/docs/en/reference/basic-mapping.rst b/docs/en/reference/basic-mapping.rst index 75872dd036b..2b11b2a1b19 100644 --- a/docs/en/reference/basic-mapping.rst +++ b/docs/en/reference/basic-mapping.rst @@ -395,8 +395,6 @@ Here is the list of possible generation strategies: strategy does currently not provide full portability and is supported by the following platforms: MySQL/SQLite/SQL Anywhere (AUTO\_INCREMENT), MSSQL (IDENTITY) and PostgreSQL (SERIAL). -- ``UUID`` (deprecated): Tells Doctrine to use the built-in Universally - Unique Identifier generator. This strategy provides full portability. - ``NONE``: Tells Doctrine that the identifiers are assigned (and thus generated) by your code. The assignment must take place before a new entity is passed to ``EntityManager#persist``. NONE is the diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index 69ed55c4bab..37461e5f82d 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -235,7 +235,6 @@ - diff --git a/lib/Doctrine/ORM/Mapping/GeneratedValue.php b/lib/Doctrine/ORM/Mapping/GeneratedValue.php index 7b82999519a..fff7c59afee 100644 --- a/lib/Doctrine/ORM/Mapping/GeneratedValue.php +++ b/lib/Doctrine/ORM/Mapping/GeneratedValue.php @@ -19,7 +19,7 @@ final class GeneratedValue implements Annotation * The type of Id generator. * * @var string - * @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "UUID", "CUSTOM"}) + * @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "CUSTOM"}) */ public $strategy = 'AUTO'; From 72d88a2d69691b28ccdb386fb698a05d4c82aef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 May 2022 15:41:11 +0200 Subject: [PATCH 081/475] Address deprecations --- .../ORM/ORMInvalidArgumentException.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index 8f42d9422b4..248136f3fd6 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -4,15 +4,12 @@ namespace Doctrine\ORM; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Mapping\ClassMetadata; use InvalidArgumentException; use Stringable; use function array_map; use function count; -use function func_get_arg; -use function func_num_args; use function get_debug_type; use function gettype; use function implode; @@ -200,26 +197,15 @@ public static function invalidCompositeIdentifier() /** * @return ORMInvalidArgumentException */ - public static function invalidIdentifierBindingEntity(/* string $class */) + public static function invalidIdentifierBindingEntity(string $class) { - if (func_num_args() === 0) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9642', - 'Omitting the class name in the exception method %s is deprecated.', - __METHOD__ - ); - - return new self('Binding entities to query parameters only allowed for entities that have an identifier.'); - } - return new self(sprintf( <<<'EXCEPTION' Binding entities to query parameters only allowed for entities that have an identifier. Class "%s" does not have an identifier. EXCEPTION , - func_get_arg(0) + $class )); } From e1586ea6cb4775b6f2bf335c1234869c0670c82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 May 2022 15:44:30 +0200 Subject: [PATCH 082/475] Remove deprecated class --- UPGRADE.md | 4 ++++ lib/Doctrine/ORM/Proxy/Autoloader.php | 14 -------------- 2 files changed, 4 insertions(+), 14 deletions(-) delete mode 100644 lib/Doctrine/ORM/Proxy/Autoloader.php diff --git a/UPGRADE.md b/UPGRADE.md index 95641778e1f..42cb24631d0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Remove `Doctrine\ORM\Proxy\Autoloader` + +Use `Doctrine\Common\Proxy\Autoloader` instead. + ## BC BREAK: Remove `Doctrine\ORM\Tools\DisconnectedClassMetadataFactory` No replacement is provided. diff --git a/lib/Doctrine/ORM/Proxy/Autoloader.php b/lib/Doctrine/ORM/Proxy/Autoloader.php deleted file mode 100644 index d9793fceb8e..00000000000 --- a/lib/Doctrine/ORM/Proxy/Autoloader.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Sat, 7 May 2022 15:47:05 +0200 Subject: [PATCH 083/475] Make targetEntity mandatory --- lib/Doctrine/ORM/Mapping/ManyToMany.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/lib/Doctrine/ORM/Mapping/ManyToMany.php index 349ab872f5e..99767eedae3 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -6,7 +6,6 @@ use Attribute; use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -use Doctrine\Deprecations\Deprecation; /** * @Annotation @@ -43,11 +42,11 @@ final class ManyToMany implements Annotation public $indexBy; /** - * @param class-string|null $targetEntity - * @param string[]|null $cascade + * @param class-string $targetEntity + * @param string[]|null $cascade */ public function __construct( - ?string $targetEntity = null, + string $targetEntity, ?string $mappedBy = null, ?string $inversedBy = null, ?array $cascade = null, @@ -55,14 +54,6 @@ public function __construct( bool $orphanRemoval = false, ?string $indexBy = null ) { - if ($targetEntity === null) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8753', - 'Passing no target entity is deprecated.' - ); - } - $this->targetEntity = $targetEntity; $this->mappedBy = $mappedBy; $this->inversedBy = $inversedBy; From 44207c1628594cf854d49eec098e15093cffd9a8 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 6 May 2022 08:38:22 -0700 Subject: [PATCH 084/475] Cast port in PHPUnit configuration to int See https://github.com/doctrine/dbal/pull/2854 --- tests/Doctrine/Tests/TestUtil.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index e919565bb43..52419d9c2b4 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -189,6 +189,10 @@ private static function mapConnectionParameters(array $configuration, string $pr $parameters[$parameter] = $configuration[$prefix . $parameter]; } + if (isset($parameters['port'])) { + $parameters['port'] = (int) $parameters['port']; + } + foreach ($configuration as $param => $value) { if (str_starts_with($param, $prefix . 'driver_option_')) { $parameters['driverOptions'][substr($param, strlen($prefix . 'driver_option_'))] = $value; From 702b491981f192e732814c3bf0e1675787975ee8 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 4 May 2022 11:16:52 -0700 Subject: [PATCH 085/475] Account for DBAL 4 no longer reordering table columns See https://github.com/doctrine/dbal/pull/4777 --- .../Functional/SchemaTool/MySqlSchemaToolTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index d44c329c176..e9a21d06dab 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -39,11 +39,21 @@ public function testGetCreateSchemaSql(): void $sql = $tool->getCreateSchemaSql($classes); self::assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); - self::assertEquals('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[1]); + self::assertThat($sql[1], self::logicalOr( + // DBAL 3 + self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) + self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB') + )); self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[2]); self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[3]); self::assertEquals('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[4]); - self::assertEquals('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[5]); + self::assertThat($sql[5], self::logicalOr( + // DBAL 3 + self::equalTo('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) + self::equalTo('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB') + )); self::assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[6]); self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[7]); self::assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)', $sql[8]); From dfb7c1cc38fed531b72b25dc44d851371341a432 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 6 May 2022 07:05:27 -0700 Subject: [PATCH 086/475] Build with DBAL 4@dev on MySQL and MariaDB --- .github/workflows/continuous-integration.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e12baef5a3f..03f6f3fb6fe 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -135,6 +135,7 @@ jobs: - "8.1" dbal-version: - "default" + - "4@dev" mariadb-version: - "10.6" extension: @@ -202,6 +203,15 @@ jobs: extension: - "mysqli" - "pdo_mysql" + include: + - php-version: "8.1" + dbal-version: "4@dev" + mysql-version: "8.0" + extension: "mysqli" + - php-version: "8.1" + dbal-version: "4@dev" + mysql-version: "8.0" + extension: "pdo_mysql" services: mysql: From 9acdac02cf31a00aa96fc38cb7de51310e654c22 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 6 May 2022 12:01:22 -0700 Subject: [PATCH 087/475] Account for DBAL 4 no longer reordering table columns See https://github.com/doctrine/dbal/pull/4777 --- .../SchemaTool/PostgreSqlSchemaToolTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index ade162de211..7fcb198c310 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -53,9 +53,19 @@ public function testGetCreateSchemaSql(): void self::assertCount(22, $sql, 'Total of 22 queries should be executed'); - self::assertEquals('CREATE TABLE cms_addresses (id INT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); + self::assertThat(array_shift($sql), self::logicalOr( + // DBAL 3 + self::equalTo('CREATE TABLE cms_addresses (id INT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id))'), + // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) + self::equalTo('CREATE TABLE cms_addresses (id INT NOT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(id))') + )); self::assertEquals('CREATE UNIQUE INDEX UNIQ_ACAC157BA76ED395 ON cms_addresses (user_id)', array_shift($sql)); - self::assertEquals('CREATE TABLE cms_users (id INT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))', array_shift($sql)); + self::assertThat(array_shift($sql), self::logicalOr( + // DBAL 3 + self::equalTo('CREATE TABLE cms_users (id INT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))'), + // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) + self::equalTo('CREATE TABLE cms_users (id INT NOT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, PRIMARY KEY(id))') + )); self::assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5F85E0677 ON cms_users (username)', array_shift($sql)); self::assertEquals('CREATE UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 ON cms_users (email_id)', array_shift($sql)); self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))', array_shift($sql)); From 9eba533f7cf4c38603104987d5836e8f5060a3a0 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 7 May 2022 12:47:26 -0700 Subject: [PATCH 088/475] Build with DBAL 4@dev on PostgreSQL --- .github/workflows/continuous-integration.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e12baef5a3f..a901ba5c61a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -81,6 +81,10 @@ jobs: postgres-version: - "9.6" - "14" + include: + - php-version: "8.1" + dbal-version: "4@dev" + postgres-version: "14" services: postgres: From 413e2a79fb1aef888d264ed0d3f389eaf2996c76 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 8 May 2022 11:34:21 -0700 Subject: [PATCH 089/475] Separate PHPStan configuration for DBAL 4 See https://github.com/doctrine/dbal/pull/3480 --- phpstan-dbal4.neon | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 phpstan-dbal4.neon diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon new file mode 100644 index 00000000000..e7e618c9019 --- /dev/null +++ b/phpstan-dbal4.neon @@ -0,0 +1,16 @@ +includes: + - phpstan.neon + +parameters: + ignoreErrors: + # Compatibility with DBAL 3 + # See https://github.com/doctrine/dbal/pull/3480 + - + message: '~^Result of method Doctrine\\DBAL\\Connection::commit\(\) \(void\) is used\.$~' + path: lib/Doctrine/ORM/UnitOfWork.php + - + message: '~^Strict comparison using === between void and false will always evaluate to false\.$~' + path: lib/Doctrine/ORM/UnitOfWork.php + - + message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~' + path: lib/Doctrine/ORM/UnitOfWork.php From 10442a7b4ee021d9f71e0a5f634279d02b3f021d Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 8 May 2022 10:40:26 -0700 Subject: [PATCH 090/475] Assert that date interval expressions are numeric strings See https://github.com/doctrine/dbal/pull/3498 --- .../Query/AST/Functions/DateAddFunction.php | 30 ++++++-- .../Query/AST/Functions/DateSubFunction.php | 30 ++++++-- phpstan-baseline.neon | 70 ------------------- 3 files changed, 46 insertions(+), 84 deletions(-) diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php index 7fa28fdc850..efc0f4b5ec3 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php @@ -4,12 +4,15 @@ namespace Doctrine\ORM\Query\AST\Functions; +use Doctrine\ORM\Query\AST\ASTException; use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use function assert; +use function is_numeric; use function strtolower; /** @@ -38,43 +41,43 @@ public function getSql(SqlWalker $sqlWalker) case 'second': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddSecondsExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'minute': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMinutesExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'hour': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'day': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'week': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddWeeksExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'month': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'year': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddYearsExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); default: @@ -84,6 +87,19 @@ public function getSql(SqlWalker $sqlWalker) } } + /** + * @return numeric-string + * + * @throws ASTException + */ + private function dispatchIntervalExpression(SqlWalker $sqlWalker) + { + $sql = $this->intervalExpression->dispatch($sqlWalker); + assert(is_numeric($sql)); + + return $sql; + } + /** * @override * @inheritdoc diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php index a6ae22523a3..8aa2a43919b 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php @@ -4,9 +4,12 @@ namespace Doctrine\ORM\Query\AST\Functions; +use Doctrine\ORM\Query\AST\ASTException; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use function assert; +use function is_numeric; use function strtolower; /** @@ -26,43 +29,43 @@ public function getSql(SqlWalker $sqlWalker) case 'second': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubSecondsExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'minute': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMinutesExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'hour': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'day': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'week': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubWeeksExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'month': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMonthExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); case 'year': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubYearsExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->intervalExpression->dispatch($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker) ); default: @@ -71,4 +74,17 @@ public function getSql(SqlWalker $sqlWalker) ); } } + + /** + * @return numeric-string + * + * @throws ASTException + */ + private function dispatchIntervalExpression(SqlWalker $sqlWalker) + { + $sql = $this->intervalExpression->dispatch($sqlWalker); + assert(is_numeric($sql)); + + return $sql; + } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 35527c844e9..e53c16fbb0b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -270,81 +270,11 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php - - - message: "#^Parameter \\#2 \\$days of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddDaysExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php - - - - message: "#^Parameter \\#2 \\$hours of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddHourExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php - - - - message: "#^Parameter \\#2 \\$minutes of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddMinutesExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php - - - - message: "#^Parameter \\#2 \\$months of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddMonthExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php - - - - message: "#^Parameter \\#2 \\$seconds of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddSecondsExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php - - - - message: "#^Parameter \\#2 \\$weeks of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddWeeksExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php - - - - message: "#^Parameter \\#2 \\$years of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateAddYearsExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php - - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\:\\:\\$value\\.$#" count: 1 path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - message: "#^Parameter \\#2 \\$days of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubDaysExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - - message: "#^Parameter \\#2 \\$hours of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubHourExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - - message: "#^Parameter \\#2 \\$minutes of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubMinutesExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - - message: "#^Parameter \\#2 \\$months of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubMonthExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - - message: "#^Parameter \\#2 \\$seconds of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubSecondsExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - - message: "#^Parameter \\#2 \\$weeks of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubWeeksExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - - message: "#^Parameter \\#2 \\$years of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getDateSubYearsExpression\\(\\) expects int, string given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - message: "#^Parameter \\#1 \\$simpleArithmeticExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkSimpleArithmeticExpression\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" count: 1 From d8159b8be27e0c89a28bd88aa078aa06e780d7c5 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 8 May 2022 11:27:08 -0700 Subject: [PATCH 091/475] Suppress known issues related to sequence-based identity generation See https://github.com/doctrine/orm/issues/8850 --- phpstan-dbal4.neon | 7 +++++++ psalm.xml | 3 +++ 2 files changed, 10 insertions(+) diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon index e7e618c9019..83b83b0f4e6 100644 --- a/phpstan-dbal4.neon +++ b/phpstan-dbal4.neon @@ -14,3 +14,10 @@ parameters: - message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~' path: lib/Doctrine/ORM/UnitOfWork.php + + # See https://github.com/doctrine/orm/issues/8850 + - + message: '~^Method Doctrine\\DBAL\\Connection::lastInsertId\(\) invoked with 1 parameter, 0 required\.$~' + paths: + - lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php + - lib/Doctrine/ORM/Id/IdentityGenerator.php diff --git a/psalm.xml b/psalm.xml index 9cafaf741e2..a19ffbb23a4 100644 --- a/psalm.xml +++ b/psalm.xml @@ -88,6 +88,9 @@ + + + From 0119d8cbbc06cedc044b68903ac7357c439ad088 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 8 May 2022 11:46:59 -0700 Subject: [PATCH 092/475] Accommodate API changes in the Column class See https://github.com/doctrine/dbal/pull/3511 --- .../ORM/Mapping/Driver/DatabaseDriver.php | 15 ++++++--------- psalm.xml | 12 ++++++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index cfd5c46e4b6..886714b49ea 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -391,11 +391,11 @@ private function buildFieldMappings(ClassMetadata $metadata): void * columnName: string, * type: string, * nullable: bool, - * options?: array{ + * options: array{ * unsigned?: bool, * fixed?: bool, - * comment?: string, - * default?: string + * comment: string|null, + * default?: mixed * }, * precision?: int, * scale?: int, @@ -409,6 +409,9 @@ private function buildFieldMapping(string $tableName, Column $column): array 'columnName' => $column->getName(), 'type' => Type::getTypeRegistry()->lookupName($column->getType()), 'nullable' => ! $column->getNotnull(), + 'options' => [ + 'comment' => $column->getComment(), + ], ]; // Type specific elements @@ -437,12 +440,6 @@ private function buildFieldMapping(string $tableName, Column $column): array break; } - // Comment - $comment = $column->getComment(); - if ($comment !== null) { - $fieldMapping['options']['comment'] = $comment; - } - // Default $default = $column->getDefault(); if ($default !== null) { diff --git a/psalm.xml b/psalm.xml index a19ffbb23a4..3a4f0e04eae 100644 --- a/psalm.xml +++ b/psalm.xml @@ -52,6 +52,18 @@ + + + + + + + + + + + + From 2e856599b36293c60cc3208422721bf01734acb8 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 7 May 2022 19:44:18 -0700 Subject: [PATCH 093/475] Run static analysis with DBAL 4@dev --- .github/workflows/static-analysis.yml | 71 ++++++++++++++++++++++++--- composer.json | 2 +- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 0e2a253610e..f46c5505b5b 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,5 +1,4 @@ - -name: "Static Analysis" +name: Static Analysis on: pull_request: @@ -10,8 +9,66 @@ on: - "*.x" jobs: - static-analysis: - name: "Static Analysis" - uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.4.1" - with: - php-version: "8.1" + static-analysis-phpstan: + name: Static Analysis with PHPStan + runs-on: ubuntu-20.04 + + strategy: + matrix: + include: + - dbal-version: default + config: phpstan.neon + - dbal-version: 4@dev + config: phpstan-dbal4.neon + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + coverage: none + php-version: "8.1" + tools: cs2pr + + - name: Require specific DBAL version + run: "composer require doctrine/dbal ^${{ matrix.dbal-version }} --no-update" + if: "${{ matrix.dbal-version != 'default' }}" + + - name: Install dependencies with Composer + uses: ramsey/composer-install@v1 + + - name: Run static analysis with phpstan/phpstan + run: "vendor/bin/phpstan analyse -c ${{ matrix.config }} --error-format=checkstyle | cs2pr" + + static-analysis-psalm: + name: Static Analysis with Psalm + runs-on: ubuntu-20.04 + + strategy: + matrix: + dbal-version: + - default + - 4@dev + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + coverage: none + php-version: "8.1" + tools: cs2pr + + - name: Require specific DBAL version + run: "composer require doctrine/dbal ^${{ matrix.dbal-version }} --no-update" + if: "${{ matrix.dbal-version != 'default' }}" + + - name: Install dependencies with Composer + uses: ramsey/composer-install@v1 + + - name: Run static analysis with Vimeo Psalm + run: vendor/bin/psalm --shepherd diff --git a/composer.json b/composer.json index 19765e18ede..715ec89876f 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-ctype": "*", "doctrine/collections": "^1.5", "doctrine/common": "^3.3", - "doctrine/dbal": "^3.3", + "doctrine/dbal": "^3.4@dev", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.1", "doctrine/inflector": "^1.4 || ^2.0", From e83404e57dba03b64e3ae6490921306c53da17e9 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 11 May 2022 12:31:17 +0200 Subject: [PATCH 094/475] Update Psalm baseline --- psalm-baseline.xml | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index df5bce62196..e3d1cfd8dcd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -332,9 +332,7 @@ - - $class - $class + $nonSuperclassParents new $definition['class']() @@ -589,16 +587,9 @@ $metadata instanceof ClassMetadata - - $this->namespace . $this->classNamesForTables[$tableName] - $this->namespace . $this->inflector->classify(strtolower($tableName)) - $metadata - - class-string - $this->tables[$tableName] $this->tables[$tableName] @@ -1253,15 +1244,6 @@ - - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $parser->ArithmeticPrimary() $parser->ArithmeticPrimary() @@ -1286,15 +1268,6 @@ - - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->intervalExpression->dispatch($sqlWalker) - $this->unit->value From 8117f42634a6a4fd6a02d55b95460c7a3cd410bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 8 May 2022 16:55:10 +0200 Subject: [PATCH 095/475] Make UnderscoreNamingStrategy number-aware only --- UPGRADE.md | 5 + .../ORM/Mapping/UnderscoreNamingStrategy.php | 24 +---- .../ORM/Mapping/AbstractMappingDriverTest.php | 2 +- .../Tests/ORM/Mapping/NamingStrategyTest.php | 92 ++++--------------- .../Mapping/UnderscoreNamingStrategyTest.php | 35 ------- 5 files changed, 26 insertions(+), 132 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/UnderscoreNamingStrategyTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 9e0eb15e8ca..3dc1fdb7f73 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: `UnderscoreNamingStrategy` is number aware only + +The second argument to `UnderscoreNamingStrategy::__construct()` was dropped, +the strategy can no longer be unaware of numbers. + ## BC BREAK: Remove `Doctrine\ORM\Proxy\Autoloader` Use `Doctrine\Common\Proxy\Autoloader` instead. diff --git a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php b/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php index 83ffa5ff9ad..29bb41c05cb 100644 --- a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php @@ -4,8 +4,6 @@ namespace Doctrine\ORM\Mapping; -use Doctrine\Deprecations\Deprecation; - use function preg_replace; use function str_contains; use function strrpos; @@ -24,33 +22,17 @@ */ class UnderscoreNamingStrategy implements NamingStrategy { - private const DEFAULT_PATTERN = '/(?<=[a-z])([A-Z])/'; - private const NUMBER_AWARE_PATTERN = '/(?<=[a-z0-9])([A-Z])/'; - /** @var int */ private $case; - /** @var string */ - private $pattern; - /** * Underscore naming strategy construct. * * @param int $case CASE_LOWER | CASE_UPPER */ - public function __construct($case = CASE_LOWER, bool $numberAware = false) + public function __construct($case = CASE_LOWER) { - if (! $numberAware) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/7908', - 'Creating %s without setting second argument $numberAware=true is deprecated and will be removed in Doctrine ORM 3.0.', - self::class - ); - } - - $this->case = $case; - $this->pattern = $numberAware ? self::NUMBER_AWARE_PATTERN : self::DEFAULT_PATTERN; + $this->case = $case; } /** @@ -140,7 +122,7 @@ public function joinKeyColumnName($entityName, $referencedColumnName = null) private function underscore(string $string): string { - $string = preg_replace($this->pattern, '_$1', $string); + $string = preg_replace('/(?<=[a-z0-9])([A-Z])/', '_$1', $string); if ($this->case === CASE_UPPER) { return strtoupper($string); diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 02a894c2dff..8d8e17665d9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -582,7 +582,7 @@ public function testNamingStrategy(): void self::assertEquals('ID', $class->getColumnName('id')); self::assertEquals('NAME', $class->getColumnName('name')); - self::assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); + self::assertEquals('DDC1476_ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); } /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php index d8a4db15b8b..df5bdd19aaf 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php @@ -33,16 +33,6 @@ private static function underscoreNamingUpper(): UnderscoreNamingStrategy return new UnderscoreNamingStrategy(CASE_UPPER); } - private static function numberAwareUnderscoreNamingLower(): UnderscoreNamingStrategy - { - return new UnderscoreNamingStrategy(CASE_LOWER, true); - } - - private static function numberAwareUnderscoreNamingUpper(): UnderscoreNamingStrategy - { - return new UnderscoreNamingStrategy(CASE_UPPER, true); - } - /** * Data Provider for NamingStrategy#classToTableName * @@ -60,20 +50,12 @@ public static function dataClassToTableName(): array // UnderscoreNamingStrategy [self::underscoreNamingLower(), 'some_class_name', '\Name\Space\SomeClassName'], [self::underscoreNamingLower(), 'name', '\Some\Class\Name'], - [self::underscoreNamingLower(), 'name2test', '\Some\Class\Name2Test'], + [self::underscoreNamingLower(), 'name2_test', '\Some\Class\Name2Test'], + [self::underscoreNamingLower(), 'name2test', '\Some\Class\Name2test'], [self::underscoreNamingUpper(), 'SOME_CLASS_NAME', '\Name\Space\SomeClassName'], [self::underscoreNamingUpper(), 'NAME', '\Some\Class\Name'], - [self::underscoreNamingUpper(), 'NAME2TEST', '\Some\Class\Name2Test'], - - // NumberAwareUnderscoreNamingStrategy - [self::numberAwareUnderscoreNamingLower(), 'some_class_name', '\Name\Space\SomeClassName'], - [self::numberAwareUnderscoreNamingLower(), 'name', '\Some\Class\Name'], - [self::numberAwareUnderscoreNamingLower(), 'name2_test', '\Some\Class\Name2Test'], - [self::numberAwareUnderscoreNamingLower(), 'name2test', '\Some\Class\Name2test'], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_CLASS_NAME', '\Name\Space\SomeClassName'], - [self::numberAwareUnderscoreNamingUpper(), 'NAME', '\Some\Class\Name'], - [self::numberAwareUnderscoreNamingUpper(), 'NAME2_TEST', '\Some\Class\Name2Test'], - [self::numberAwareUnderscoreNamingUpper(), 'NAME2TEST', '\Some\Class\Name2test'], + [self::underscoreNamingUpper(), 'NAME2_TEST', '\Some\Class\Name2Test'], + [self::underscoreNamingUpper(), 'NAME2TEST', '\Some\Class\Name2test'], ]; } @@ -102,23 +84,13 @@ public static function dataPropertyToColumnName(): array // UnderscoreNamingStrategy [self::underscoreNamingLower(), 'some_property', 'someProperty'], - [self::underscoreNamingLower(), 'base64encoded', 'base64Encoded'], + [self::underscoreNamingLower(), 'base64_encoded', 'base64Encoded'], [self::underscoreNamingLower(), 'base64encoded', 'base64encoded'], [self::underscoreNamingUpper(), 'SOME_PROPERTY', 'someProperty'], [self::underscoreNamingUpper(), 'SOME_PROPERTY', 'some_property'], [self::underscoreNamingUpper(), 'SOME_PROPERTY', 'SOME_PROPERTY'], - [self::underscoreNamingUpper(), 'BASE64ENCODED', 'base64Encoded'], + [self::underscoreNamingUpper(), 'BASE64_ENCODED', 'base64Encoded'], [self::underscoreNamingUpper(), 'BASE64ENCODED', 'base64encoded'], - - // NumberAwareUnderscoreNamingStrategy - [self::numberAwareUnderscoreNamingLower(), 'some_property', 'someProperty'], - [self::numberAwareUnderscoreNamingLower(), 'base64_encoded', 'base64Encoded'], - [self::numberAwareUnderscoreNamingLower(), 'base64encoded', 'base64encoded'], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_PROPERTY', 'someProperty'], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_PROPERTY', 'some_property'], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_PROPERTY', 'SOME_PROPERTY'], - [self::numberAwareUnderscoreNamingUpper(), 'BASE64_ENCODED', 'base64Encoded'], - [self::numberAwareUnderscoreNamingUpper(), 'BASE64ENCODED', 'base64encoded'], ]; } @@ -144,10 +116,6 @@ public static function dataReferenceColumnName(): array // UnderscoreNamingStrategy [self::underscoreNamingLower(), 'id'], [self::underscoreNamingUpper(), 'ID'], - - // NumberAwareUnderscoreNamingStrategy - [self::numberAwareUnderscoreNamingLower(), 'id'], - [self::numberAwareUnderscoreNamingUpper(), 'ID'], ]; } @@ -175,17 +143,11 @@ public static function dataJoinColumnName(): array // UnderscoreNamingStrategy [self::underscoreNamingLower(), 'some_column_id', 'someColumn', null], - [self::underscoreNamingLower(), 'base64encoded_id', 'base64Encoded', null], + [self::underscoreNamingLower(), 'base64_encoded_id', 'base64Encoded', null], + [self::underscoreNamingLower(), 'base64encoded_id', 'base64encoded', null], [self::underscoreNamingUpper(), 'SOME_COLUMN_ID', 'someColumn', null], - [self::underscoreNamingUpper(), 'BASE64ENCODED_ID', 'base64Encoded', null], - - // NumberAwareUnderscoreNamingStrategy - [self::numberAwareUnderscoreNamingLower(), 'some_column_id', 'someColumn', null], - [self::numberAwareUnderscoreNamingLower(), 'base64_encoded_id', 'base64Encoded', null], - [self::numberAwareUnderscoreNamingLower(), 'base64encoded_id', 'base64encoded', null], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_COLUMN_ID', 'someColumn', null], - [self::numberAwareUnderscoreNamingUpper(), 'BASE64_ENCODED_ID', 'base64Encoded', null], - [self::numberAwareUnderscoreNamingUpper(), 'BASE64ENCODED_ID', 'base64encoded', null], + [self::underscoreNamingUpper(), 'BASE64_ENCODED_ID', 'base64Encoded', null], + [self::underscoreNamingUpper(), 'BASE64ENCODED_ID', 'base64encoded', null], // JoinColumnClassNamingStrategy [new JoinColumnClassNamingStrategy(), 'classname_someColumn_id', 'someColumn', 'Some\ClassName'], @@ -222,23 +184,13 @@ public static function dataJoinTableName(): array // UnderscoreNamingStrategy [self::underscoreNamingLower(), 'some_class_name_class_name', 'SomeClassName', 'Some\ClassName', null], - [self::underscoreNamingLower(), 'class1test_class2test', 'Class1Test', 'Some\Class2Test', null], + [self::underscoreNamingLower(), 'class1_test_class2_test', 'Class1Test', 'Some\Class2Test', null], [self::underscoreNamingLower(), 'some_class_name_class_name', '\SomeClassName', 'ClassName', null], [self::underscoreNamingLower(), 'name_class_name', '\Some\Class\Name', 'ClassName', null], [self::underscoreNamingUpper(), 'SOME_CLASS_NAME_CLASS_NAME', 'SomeClassName', 'Some\ClassName', null], - [self::underscoreNamingUpper(), 'CLASS1TEST_CLASS2TEST', 'Class1Test', 'Some\Class2Test', null], + [self::underscoreNamingUpper(), 'CLASS1_TEST_CLASS2_TEST', 'Class1Test', 'Some\Class2Test', null], [self::underscoreNamingUpper(), 'SOME_CLASS_NAME_CLASS_NAME', '\SomeClassName', 'ClassName', null], [self::underscoreNamingUpper(), 'NAME_CLASS_NAME', '\Some\Class\Name', 'ClassName', null], - - // NumberAwareUnderscoreNamingStrategy - [self::numberAwareUnderscoreNamingLower(), 'some_class_name_class_name', 'SomeClassName', 'Some\ClassName', null], - [self::numberAwareUnderscoreNamingLower(), 'class1_test_class2_test', 'Class1Test', 'Some\Class2Test', null], - [self::numberAwareUnderscoreNamingLower(), 'some_class_name_class_name', '\SomeClassName', 'ClassName', null], - [self::numberAwareUnderscoreNamingLower(), 'name_class_name', '\Some\Class\Name', 'ClassName', null], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_CLASS_NAME_CLASS_NAME', 'SomeClassName', 'Some\ClassName', null], - [self::numberAwareUnderscoreNamingUpper(), 'CLASS1_TEST_CLASS2_TEST', 'Class1Test', 'Some\Class2Test', null], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_CLASS_NAME_CLASS_NAME', '\SomeClassName', 'ClassName', null], - [self::numberAwareUnderscoreNamingUpper(), 'NAME_CLASS_NAME', '\Some\Class\Name', 'ClassName', null], ]; } @@ -268,24 +220,14 @@ public static function dataJoinKeyColumnName(): array [self::defaultNaming(), 'name_identifier', '\Some\Class\Name', 'identifier'], // UnderscoreNamingStrategy - [self::underscoreNamingLower(), 'some_class_name2test_id', 'SomeClassName2Test', null], - [self::underscoreNamingLower(), 'some_class_name_id', 'SomeClassName', null], + [self::underscoreNamingLower(), 'some_class_name2_test_id', 'SomeClassName2Test', null], + [self::underscoreNamingLower(), 'some_class_name_id', 'SomeClassName', null, null], [self::underscoreNamingLower(), 'class_name_identifier', '\Some\Class\ClassName', 'identifier'], - [self::underscoreNamingLower(), 'name2test_identifier', '\Some\Class\Name2Test', 'identifier'], + [self::underscoreNamingLower(), 'name2_test_identifier', '\Some\Class\Name2Test', 'identifier'], [self::underscoreNamingUpper(), 'SOME_CLASS_NAME_ID', 'SomeClassName', null], - [self::underscoreNamingUpper(), 'SOME_CLASS_NAME2TEST_ID', 'SomeClassName2Test', null], + [self::underscoreNamingUpper(), 'SOME_CLASS_NAME2_TEST_ID', 'SomeClassName2Test', null], [self::underscoreNamingUpper(), 'CLASS_NAME_IDENTIFIER', '\Some\Class\ClassName', 'IDENTIFIER'], - [self::underscoreNamingUpper(), 'NAME2TEST_IDENTIFIER', '\Some\Class\Name2Test', 'IDENTIFIER'], - - // NumberAwareUnderscoreNamingStrategy - [self::numberAwareUnderscoreNamingLower(), 'some_class_name2_test_id', 'SomeClassName2Test', null], - [self::numberAwareUnderscoreNamingLower(), 'some_class_name_id', 'SomeClassName', null], - [self::numberAwareUnderscoreNamingLower(), 'class_name_identifier', '\Some\Class\ClassName', 'identifier'], - [self::numberAwareUnderscoreNamingLower(), 'name2_test_identifier', '\Some\Class\Name2Test', 'identifier'], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_CLASS_NAME_ID', 'SomeClassName', null], - [self::numberAwareUnderscoreNamingUpper(), 'SOME_CLASS_NAME2_TEST_ID', 'SomeClassName2Test', null], - [self::numberAwareUnderscoreNamingUpper(), 'CLASS_NAME_IDENTIFIER', '\Some\Class\ClassName', 'IDENTIFIER'], - [self::numberAwareUnderscoreNamingUpper(), 'NAME2_TEST_IDENTIFIER', '\Some\Class\Name2Test', 'IDENTIFIER'], + [self::underscoreNamingUpper(), 'NAME2_TEST_IDENTIFIER', '\Some\Class\Name2Test', 'IDENTIFIER'], ]; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/UnderscoreNamingStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/UnderscoreNamingStrategyTest.php deleted file mode 100644 index 0c3f30af730..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/UnderscoreNamingStrategyTest.php +++ /dev/null @@ -1,35 +0,0 @@ -expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/7908'); - - new UnderscoreNamingStrategy(CASE_LOWER, false); - } - - public function testNoDeprecationMessageWhenNumberAwareEnabled(): void - { - $before = Deprecation::getTriggeredDeprecations()['https://github.com/doctrine/orm/pull/7908'] ?? 0; - - new UnderscoreNamingStrategy(CASE_LOWER, true); - - $after = Deprecation::getTriggeredDeprecations()['https://github.com/doctrine/orm/pull/7908'] ?? 0; - - self::assertSame($before, $after); - } -} From d294e1d453d5ecbec70f72a4f88674685723f6ac Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 11 May 2022 20:34:49 +0200 Subject: [PATCH 096/475] Add native types to reflection property classes (#9631) --- .../Mapping/ReflectionEmbeddedProperty.php | 48 +++++-------------- .../ORM/Mapping/ReflectionEnumProperty.php | 43 +++++------------ psalm-baseline.xml | 21 ++++---- 3 files changed, 36 insertions(+), 76 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php index 9e6a4a2bd96..b38ddfecc0c 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php @@ -6,7 +6,6 @@ use Doctrine\Instantiator\Instantiator; use ReflectionProperty; -use ReturnTypeWillChange; /** * Acts as a proxy to a nested Property structure, making it look like @@ -17,39 +16,24 @@ * * TODO: Move this class into Common\Reflection */ -class ReflectionEmbeddedProperty extends ReflectionProperty +final class ReflectionEmbeddedProperty extends ReflectionProperty { - /** @var ReflectionProperty reflection property of the class where the embedded object has to be put */ - private $parentProperty; - - /** @var ReflectionProperty reflection property of the embedded object */ - private $childProperty; - - /** @var string name of the embedded class to be eventually instantiated */ - private $embeddedClass; - - /** @var Instantiator|null */ - private $instantiator; + private ?Instantiator $instantiator = null; /** - * @param string $embeddedClass + * @param ReflectionProperty $parentProperty reflection property of the class where the embedded object has to be put + * @param ReflectionProperty $childProperty reflection property of the embedded object + * @psalm-param class-string $embeddedClass */ - public function __construct(ReflectionProperty $parentProperty, ReflectionProperty $childProperty, $embeddedClass) - { - $this->parentProperty = $parentProperty; - $this->childProperty = $childProperty; - $this->embeddedClass = (string) $embeddedClass; - + public function __construct( + private ReflectionProperty $parentProperty, + private ReflectionProperty $childProperty, + private string $embeddedClass + ) { parent::__construct($childProperty->getDeclaringClass()->getName(), $childProperty->getName()); } - /** - * {@inheritDoc} - * - * @return mixed - */ - #[ReturnTypeWillChange] - public function getValue($object = null) + public function getValue(?object $object = null): mixed { $embeddedObject = $this->parentProperty->getValue($object); @@ -60,18 +44,12 @@ public function getValue($object = null) return $this->childProperty->getValue($embeddedObject); } - /** - * {@inheritDoc} - * - * @return void - */ - #[ReturnTypeWillChange] - public function setValue($object, $value = null) + public function setValue(mixed $object, mixed $value = null): void { $embeddedObject = $this->parentProperty->getValue($object); if ($embeddedObject === null) { - $this->instantiator = $this->instantiator ?: new Instantiator(); + $this->instantiator ??= new Instantiator(); $embeddedObject = $this->instantiator->instantiate($this->embeddedClass); diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php index c58e77d6a4f..0645a9ba35f 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php @@ -6,44 +6,28 @@ use BackedEnum; use ReflectionProperty; -use ReturnTypeWillChange; use ValueError; use function array_map; use function get_class; use function is_array; -class ReflectionEnumProperty extends ReflectionProperty +final class ReflectionEnumProperty extends ReflectionProperty { - /** @var ReflectionProperty */ - private $originalReflectionProperty; - - /** @var class-string */ - private $enumType; - /** * @param class-string $enumType */ - public function __construct(ReflectionProperty $originalReflectionProperty, string $enumType) - { - $this->originalReflectionProperty = $originalReflectionProperty; - $this->enumType = $enumType; - + public function __construct( + private ReflectionProperty $originalReflectionProperty, + private string $enumType + ) { parent::__construct( $originalReflectionProperty->getDeclaringClass()->getName(), $originalReflectionProperty->getName() ); } - /** - * {@inheritDoc} - * - * @param object|null $object - * - * @return int|string|int[]|string[]|null - */ - #[ReturnTypeWillChange] - public function getValue($object = null) + public function getValue(?object $object = null): int|string|array|null { if ($object === null) { return null; @@ -56,9 +40,10 @@ public function getValue($object = null) } if (is_array($enum)) { - return array_map(static function (BackedEnum $item): mixed { - return $item->value; - }, $enum); + return array_map( + static fn (BackedEnum $item): int|string => $item->value, + $enum + ); } return $enum->value; @@ -68,7 +53,7 @@ public function getValue($object = null) * @param object $object * @param int|string|int[]|string[]|null $value */ - public function setValue($object, $value = null): void + public function setValue(mixed $object, mixed $value = null): void { if ($value !== null) { if (is_array($value)) { @@ -83,11 +68,7 @@ public function setValue($object, $value = null): void $this->originalReflectionProperty->setValue($object, $value); } - /** - * @param object $object - * @param int|string $value - */ - private function initializeEnumValue($object, $value): BackedEnum + private function initializeEnumValue(object $object, int|string $value): BackedEnum { $enumType = $this->enumType; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e3d1cfd8dcd..da1dbae4a91 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -367,7 +367,6 @@ getConfiguration getConfiguration getConfiguration - getConfiguration getConnection hasListeners hasListeners @@ -733,17 +732,19 @@ - - $this->embeddedClass - - + $object $object - $value - - - (string) $embeddedClass - + + + $object + + + + + $object + $object + From 72810e9c05ea849d8c3ec2c1c4e70c674edf306b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 16 May 2022 22:28:49 +0200 Subject: [PATCH 097/475] Use createSchemaForModels() This allows to get rid of tearDown(), which contained a special handling that is no longer necessary since we switched away from explicitely managed sequences, and caused the test suite to fail. --- .../SequenceEmulatedIdentityStrategyTest.php | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php index b21153e1a5d..af7e22d2982 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php @@ -22,27 +22,10 @@ protected function setUp(): void 'This test is special to platforms emulating IDENTITY key generation strategy through sequences.' ); } else { - $this->_schemaTool->createSchema( - [$this->_em->getClassMetadata(SequenceEmulatedIdentityEntity::class)] - ); + $this->createSchemaForModels(SequenceEmulatedIdentityEntity::class); } } - protected function tearDown(): void - { - parent::tearDown(); - - $connection = $this->_em->getConnection(); - $platform = $connection->getDatabasePlatform(); - - // drop sequence manually due to dependency - $connection->executeStatement( - $platform->getDropSequenceSQL( - $platform->getIdentitySequenceName('seq_identity', 'id') - ) - ); - } - public function testPreSavePostSaveCallbacksAreInvoked(): void { $entity = new SequenceEmulatedIdentityEntity(); From 98cf5836fd50cc6e9f12288ca126970e82da316e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 12 May 2022 09:35:57 +0200 Subject: [PATCH 098/475] Use native type declarations for naming strategies --- docs/en/reference/namingstrategy.rst | 12 ++-- .../ORM/Mapping/ClassMetadataInfo.php | 2 + .../ORM/Mapping/DefaultNamingStrategy.php | 48 ++++++--------- lib/Doctrine/ORM/Mapping/NamingStrategy.php | 48 +++++---------- .../ORM/Mapping/UnderscoreNamingStrategy.php | 61 +++++++------------ .../Tests/ORM/Mapping/ClassMetadataTest.php | 10 +-- .../JoinColumnClassNamingStrategy.php | 5 +- .../Tests/ORM/Mapping/NamingStrategyTest.php | 2 +- 8 files changed, 68 insertions(+), 120 deletions(-) diff --git a/docs/en/reference/namingstrategy.rst b/docs/en/reference/namingstrategy.rst index c48f84f443d..3379448b0fc 100644 --- a/docs/en/reference/namingstrategy.rst +++ b/docs/en/reference/namingstrategy.rst @@ -110,28 +110,28 @@ You need to create a class which implements ``Doctrine\ORM\Mapping\NamingStrateg referenceColumnName(); } - public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) + public function joinTableName(string $sourceEntity, string $targetEntity, string $propertyName): string { return strtolower($this->classToTableName($sourceEntity) . '_' . $this->classToTableName($targetEntity)); } - public function joinKeyColumnName($entityName, $referencedColumnName = null) + public function joinKeyColumnName(string $entityName, ?string $referencedColumnName): string { return strtolower($this->classToTableName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName())); diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index a35285b1601..bcdbf6c12eb 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -3325,6 +3325,8 @@ public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) if (! empty($this->embeddedClasses[$property]['columnPrefix'])) { $fieldMapping['columnName'] = $this->embeddedClasses[$property]['columnPrefix'] . $fieldMapping['columnName']; } elseif ($this->embeddedClasses[$property]['columnPrefix'] !== false) { + assert($this->reflClass !== null); + assert($embeddable->reflClass !== null); $fieldMapping['columnName'] = $this->namingStrategy ->embeddedFieldToColumnName( $property, diff --git a/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php index a0f17f83028..4943160b200 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php @@ -16,10 +16,7 @@ */ class DefaultNamingStrategy implements NamingStrategy { - /** - * {@inheritdoc} - */ - public function classToTableName($className) + public function classToTableName(string $className): string { if (str_contains($className, '\\')) { return substr($className, strrpos($className, '\\') + 1); @@ -28,26 +25,21 @@ public function classToTableName($className) return $className; } - /** - * {@inheritdoc} - */ - public function propertyToColumnName($propertyName, $className = null) + public function propertyToColumnName(string $propertyName, string $className): string { return $propertyName; } - /** - * {@inheritdoc} - */ - public function embeddedFieldToColumnName($propertyName, $embeddedColumnName, $className = null, $embeddedClassName = null) - { + public function embeddedFieldToColumnName( + string $propertyName, + string $embeddedColumnName, + string $className, + string $embeddedClassName, + ): string { return $propertyName . '_' . $embeddedColumnName; } - /** - * {@inheritdoc} - */ - public function referenceColumnName() + public function referenceColumnName(): string { return 'id'; } @@ -55,28 +47,26 @@ public function referenceColumnName() /** * {@inheritdoc} * - * @param string $propertyName * @param class-string $className */ - public function joinColumnName($propertyName, $className = null) + public function joinColumnName(string $propertyName, ?string $className = null): string { return $propertyName . '_' . $this->referenceColumnName(); } - /** - * {@inheritdoc} - */ - public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) - { + public function joinTableName( + string $sourceEntity, + string $targetEntity, + string $propertyName, + ): string { return strtolower($this->classToTableName($sourceEntity) . '_' . $this->classToTableName($targetEntity)); } - /** - * {@inheritdoc} - */ - public function joinKeyColumnName($entityName, $referencedColumnName = null) - { + public function joinKeyColumnName( + string $entityName, + ?string $referencedColumnName, + ): string { return strtolower($this->classToTableName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName())); } diff --git a/lib/Doctrine/ORM/Mapping/NamingStrategy.php b/lib/Doctrine/ORM/Mapping/NamingStrategy.php index 7142f377d12..45eaa402d1b 100644 --- a/lib/Doctrine/ORM/Mapping/NamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/NamingStrategy.php @@ -15,64 +15,46 @@ interface NamingStrategy * Returns a table name for an entity class. * * @param class-string $className - * - * @return string A table name. */ - public function classToTableName($className); + public function classToTableName(string $className): string; /** * Returns a column name for a property. * - * @param string $propertyName A property name. - * @param class-string $className The fully-qualified class name. - * - * @return string A column name. + * @param class-string $className */ - public function propertyToColumnName($propertyName, $className = null); + public function propertyToColumnName(string $propertyName, string $className): string; /** * Returns a column name for an embedded property. * - * @param string $propertyName - * @param string $embeddedColumnName * @param class-string $className * @param class-string $embeddedClassName - * - * @return string */ public function embeddedFieldToColumnName( - $propertyName, - $embeddedColumnName, - $className = null, - $embeddedClassName = null - ); + string $propertyName, + string $embeddedColumnName, + string $className, + string $embeddedClassName, + ): string; /** * Returns the default reference column name. - * - * @return string A column name. */ - public function referenceColumnName(); + public function referenceColumnName(): string; /** * Returns a join column name for a property. - * - * @param string $propertyName A property name. - * - * @return string A join column name. */ - public function joinColumnName($propertyName/*, $className = null */); + public function joinColumnName(string $propertyName/*, $className = null */): string; /** * Returns a join table name. * - * @param class-string $sourceEntity The source entity. - * @param class-string $targetEntity The target entity. - * @param string $propertyName A property name. - * - * @return string A join table name. + * @param class-string $sourceEntity + * @param class-string $targetEntity */ - public function joinTableName($sourceEntity, $targetEntity, $propertyName = null); + public function joinTableName(string $sourceEntity, string $targetEntity, string $propertyName): string; /** * Returns the foreign key column name for the given parameters. @@ -82,8 +64,6 @@ public function joinTableName($sourceEntity, $targetEntity, $propertyName = null * case of a self-referencing * entity with join columns * defined in the mapping - * - * @return string A join column name. */ - public function joinKeyColumnName($entityName, $referencedColumnName = null); + public function joinKeyColumnName(string $entityName, ?string $referencedColumnName): string; } diff --git a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php b/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php index 29bb41c05cb..16c92ee6cd6 100644 --- a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php @@ -22,15 +22,14 @@ */ class UnderscoreNamingStrategy implements NamingStrategy { - /** @var int */ - private $case; + private int $case; /** * Underscore naming strategy construct. * * @param int $case CASE_LOWER | CASE_UPPER */ - public function __construct($case = CASE_LOWER) + public function __construct(int $case = CASE_LOWER) { $this->case = $case; } @@ -38,7 +37,7 @@ public function __construct($case = CASE_LOWER) /** * @return int CASE_LOWER | CASE_UPPER */ - public function getCase() + public function getCase(): int { return $this->case; } @@ -46,20 +45,13 @@ public function getCase() /** * Sets string case CASE_LOWER | CASE_UPPER. * Alphabetic characters converted to lowercase or uppercase. - * - * @param int $case - * - * @return void */ - public function setCase($case) + public function setCase(int $case): void { $this->case = $case; } - /** - * {@inheritdoc} - */ - public function classToTableName($className) + public function classToTableName(string $className): string { if (str_contains($className, '\\')) { $className = substr($className, strrpos($className, '\\') + 1); @@ -68,26 +60,21 @@ public function classToTableName($className) return $this->underscore($className); } - /** - * {@inheritdoc} - */ - public function propertyToColumnName($propertyName, $className = null) + public function propertyToColumnName(string $propertyName, string $className): string { return $this->underscore($propertyName); } - /** - * {@inheritdoc} - */ - public function embeddedFieldToColumnName($propertyName, $embeddedColumnName, $className = null, $embeddedClassName = null) - { + public function embeddedFieldToColumnName( + string $propertyName, + string $embeddedColumnName, + string $className, + string $embeddedClassName, + ): string { return $this->underscore($propertyName) . '_' . $embeddedColumnName; } - /** - * {@inheritdoc} - */ - public function referenceColumnName() + public function referenceColumnName(): string { return $this->case === CASE_UPPER ? 'ID' : 'id'; } @@ -95,27 +82,25 @@ public function referenceColumnName() /** * {@inheritdoc} * - * @param string $propertyName * @param class-string $className */ - public function joinColumnName($propertyName, $className = null) + public function joinColumnName(string $propertyName, ?string $className = null): string { return $this->underscore($propertyName) . '_' . $this->referenceColumnName(); } - /** - * {@inheritdoc} - */ - public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) - { + public function joinTableName( + string $sourceEntity, + string $targetEntity, + string $propertyName, + ): string { return $this->classToTableName($sourceEntity) . '_' . $this->classToTableName($targetEntity); } - /** - * {@inheritdoc} - */ - public function joinKeyColumnName($entityName, $referencedColumnName = null) - { + public function joinKeyColumnName( + string $entityName, + ?string $referencedColumnName + ): string { return $this->classToTableName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName()); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 9e7bd1bd947..bf753754676 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -1128,10 +1128,7 @@ class DDC2700MappedSuperClass class MyNamespacedNamingStrategy extends DefaultNamingStrategy { - /** - * {@inheritdoc} - */ - public function classToTableName($className) + public function classToTableName(string $className): string { if (str_contains($className, '\\')) { $className = str_replace('\\', '_', str_replace('Doctrine\Tests\Models\\', '', $className)); @@ -1143,10 +1140,7 @@ public function classToTableName($className) class MyPrefixNamingStrategy extends DefaultNamingStrategy { - /** - * {@inheritdoc} - */ - public function propertyToColumnName($propertyName, $className = null) + public function propertyToColumnName(string $propertyName, string $className): string { return strtolower($this->classToTableName($className)) . '_' . $propertyName; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php index 9588f527497..18dc5e0184e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php @@ -13,10 +13,7 @@ */ class JoinColumnClassNamingStrategy extends DefaultNamingStrategy { - /** - * {@inheritdoc} - */ - public function joinColumnName($propertyName, $className = null) + public function joinColumnName(string $propertyName, ?string $className = null): string { return strtolower($this->classToTableName($className)) . '_' . $propertyName diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php index 43f56a76cbe..1bc03f7f7a6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php @@ -176,7 +176,7 @@ public function testJoinColumnName( /** * Data Provider for NamingStrategy#joinTableName * - * @return array + * @return array */ public static function dataJoinTableName(): array { From b91825bc73004adab48e25c3b125778c105f460e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 18 May 2022 20:58:46 +0200 Subject: [PATCH 099/475] Remove static PHP driver It is deprecated in favor of its parent class. --- UPGRADE.md | 5 +++++ .../ORM/Mapping/Driver/StaticPHPDriver.php | 16 ---------------- .../Tests/ORM/Functional/Ticket/DDC2415Test.php | 2 +- 3 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php diff --git a/UPGRADE.md b/UPGRADE.md index 3dc1fdb7f73..a082697c879 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: Remove StaticPHPDriver + +Use `Doctrine\Persistence\Mapping\Driver\StaticPHPDriver` from +`doctrine/persistence` instead. + ## BC BREAK: `UnderscoreNamingStrategy` is number aware only The second argument to `UnderscoreNamingStrategy::__construct()` was dropped, diff --git a/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php b/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php deleted file mode 100644 index 3321ee0e51a..00000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Mon, 9 May 2022 23:04:06 +0200 Subject: [PATCH 100/475] Require new argument to joinColumnName() --- UPGRADE.md | 37 +++++++++++++++++++ .../ORM/Mapping/DefaultNamingStrategy.php | 7 +--- lib/Doctrine/ORM/Mapping/NamingStrategy.php | 4 +- .../ORM/Mapping/UnderscoreNamingStrategy.php | 7 +--- phpstan-baseline.neon | 5 --- psalm-baseline.xml | 4 -- 6 files changed, 42 insertions(+), 22 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index a082697c879..87164e9c262 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,42 @@ # Upgrade to 3.0 +## BC BREAK: New argument to `NamingStrategy::joinColumnName()` + +### Before + +```php +referenceColumnName(); } diff --git a/lib/Doctrine/ORM/Mapping/NamingStrategy.php b/lib/Doctrine/ORM/Mapping/NamingStrategy.php index 02351caee68..26401cb9e3a 100644 --- a/lib/Doctrine/ORM/Mapping/NamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/NamingStrategy.php @@ -45,8 +45,10 @@ public function referenceColumnName(): string; /** * Returns a join column name for a property. + * + * @param class-string $className */ - public function joinColumnName(string $propertyName/*, string $className */): string; + public function joinColumnName(string $propertyName, string $className): string; /** * Returns a join table name. diff --git a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php b/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php index 16c92ee6cd6..eafbafd5f69 100644 --- a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php @@ -79,12 +79,7 @@ public function referenceColumnName(): string return $this->case === CASE_UPPER ? 'ID' : 'id'; } - /** - * {@inheritdoc} - * - * @param class-string $className - */ - public function joinColumnName(string $propertyName, ?string $className = null): string + public function joinColumnName(string $propertyName, string $className): string { return $this->underscore($propertyName) . '_' . $this->referenceColumnName(); } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e53c16fbb0b..3fc23468501 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -140,11 +140,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\NamingStrategy\\:\\:joinColumnName\\(\\) invoked with 2 parameters, 1 required\\.$#" - count: 2 - path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php - - message: "#^Negated boolean expression is always false\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index da1dbae4a91..ada29d6089d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -488,10 +488,6 @@ array_values - - joinColumnName - joinColumnName - From e5fe46a051b60228b87dd07f5057c4d4cf9f7693 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 30 May 2022 20:43:24 +0200 Subject: [PATCH 101/475] Precise phpdoc of getRootEntities (#9778) * Precise phpdoc of getRootEntities * Restrict from param * Prefer phpdoc --- lib/Doctrine/ORM/Query/Expr/From.php | 10 +++++----- lib/Doctrine/ORM/QueryBuilder.php | 27 +++++++++++++++++++-------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Expr/From.php b/lib/Doctrine/ORM/Query/Expr/From.php index 29fd13be49c..f6162c77617 100644 --- a/lib/Doctrine/ORM/Query/Expr/From.php +++ b/lib/Doctrine/ORM/Query/Expr/From.php @@ -11,7 +11,7 @@ */ class From { - /** @var string */ + /** @var class-string */ protected $from; /** @var string */ @@ -21,9 +21,9 @@ class From protected $indexBy; /** - * @param string $from The class name. - * @param string $alias The alias of the class. - * @param string $indexBy The index for the from. + * @param class-string $from The class name. + * @param string $alias The alias of the class. + * @param string $indexBy The index for the from. */ public function __construct($from, $alias, $indexBy = null) { @@ -33,7 +33,7 @@ public function __construct($from, $alias, $indexBy = null) } /** - * @return string + * @return class-string */ public function getFrom() { diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 147e42ab109..d28528920d4 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -400,8 +400,10 @@ public function getRootAliases(): array foreach ($this->dqlParts['from'] as &$fromClause) { if (is_string($fromClause)) { $spacePos = strrpos($fromClause, ' '); - $from = substr($fromClause, 0, $spacePos); - $alias = substr($fromClause, $spacePos + 1); + + /** @psalm-var class-string $from */ + $from = substr($fromClause, 0, $spacePos); + $alias = substr($fromClause, $spacePos + 1); $fromClause = new Query\Expr\From($from, $alias); } @@ -434,7 +436,7 @@ public function getAllAliases(): array } /** - * Gets the root entities of the query. This is the entity aliases involved + * Gets the root entities of the query. This is the entity classes involved * in the construction of the query. * * @@ -446,7 +448,7 @@ public function getAllAliases(): array * * * @return string[] - * @psalm-return list + * @psalm-return list */ public function getRootEntities(): array { @@ -455,8 +457,10 @@ public function getRootEntities(): array foreach ($this->dqlParts['from'] as &$fromClause) { if (is_string($fromClause)) { $spacePos = strrpos($fromClause, ' '); - $from = substr($fromClause, 0, $spacePos); - $alias = substr($fromClause, $spacePos + 1); + + /** @psalm-var class-string $from */ + $from = substr($fromClause, 0, $spacePos); + $alias = substr($fromClause, $spacePos + 1); $fromClause = new Query\Expr\From($from, $alias); } @@ -725,8 +729,8 @@ public function addSelect(mixed ...$select): static * ->setParameter('user_id', 1); * * - * @param string|null $delete The class/type whose instances are subject to the deletion. - * @param string|null $alias The class/type alias used in the constructed query. + * @param class-string|null $delete The class/type whose instances are subject to the deletion. + * @param string|null $alias The class/type alias used in the constructed query. * * @return $this */ @@ -752,6 +756,9 @@ public function delete(?string $delete = null, ?string $alias = null): static * ->where('u.id = ?2'); * * + * @param class-string|null $update The class/type whose instances are subject to the update. + * @param string|null $alias The class/type alias used in the constructed query. + * * @return $this */ public function update(?string $update = null, ?string $alias = null): static @@ -775,6 +782,10 @@ public function update(?string $update = null, ?string $alias = null): static * ->from('User', 'u'); * * + * @param class-string $from The class name. + * @param string $alias The alias of the class. + * @param string|null $indexBy The index for the from. + * * @return $this */ public function from(string $from, string $alias, ?string $indexBy = null): static From 62892dc4e4c29b4dcf55b4cd6592e66a356362d0 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 31 May 2022 07:58:35 +0200 Subject: [PATCH 102/475] Made setters parameters mandatory (#9798) --- UPGRADE.md | 10 ++++++ lib/Doctrine/ORM/AbstractQuery.php | 34 ++----------------- .../OnClassMetadataNotFoundEventArgs.php | 14 +------- .../Doctrine/Tests/ORM/AbstractQueryTest.php | 25 -------------- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 2 +- 5 files changed, 15 insertions(+), 70 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index f30e1f9e545..b0ceb9235d6 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade to 3.0 +## BC BREAK: Made setters parameters mandatory + +The following methods require an argument when being called. Pass `null` +instead of omitting the argument. + +* `Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs::setFoundMetadata()` +* `Doctrine\ORM\AbstractQuery::setHydrationCacheProfile()` +* `Doctrine\ORM\AbstractQuery::setResultCache()` +* `Doctrine\ORM\AbstractQuery::setResultCacheProfile()` + ## BC BREAK: New argument to `NamingStrategy::joinColumnName()` ### Before diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 7b81f5db647..da9c3590786 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -28,7 +28,6 @@ use function array_shift; use function assert; use function count; -use function func_num_args; use function in_array; use function is_array; use function is_numeric; @@ -541,18 +540,9 @@ private function translateNamespaces(Query\ResultSetMapping $rsm): void * $query->setHydrationCacheProfile(new QueryCacheProfile()); * $query->setHydrationCacheProfile(new QueryCacheProfile($lifetime, $resultKey)); */ - public function setHydrationCacheProfile(?QueryCacheProfile $profile = null) + public function setHydrationCacheProfile(?QueryCacheProfile $profile) { if ($profile === null) { - if (func_num_args() < 1) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9791', - 'Calling %s without arguments is deprecated, pass null instead.', - __METHOD__ - ); - } - $this->_hydrationCacheProfile = null; return $this; @@ -586,18 +576,9 @@ public function getHydrationCacheProfile() * * @return $this */ - public function setResultCacheProfile(?QueryCacheProfile $profile = null) + public function setResultCacheProfile(?QueryCacheProfile $profile) { if ($profile === null) { - if (func_num_args() < 1) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9791', - 'Calling %s without arguments is deprecated, pass null instead.', - __METHOD__ - ); - } - $this->_queryCacheProfile = null; return $this; @@ -620,18 +601,9 @@ public function setResultCacheProfile(?QueryCacheProfile $profile = null) * * @return $this */ - public function setResultCache(?CacheItemPoolInterface $resultCache = null) + public function setResultCache(?CacheItemPoolInterface $resultCache) { if ($resultCache === null) { - if (func_num_args() < 1) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9791', - 'Calling %s without arguments is deprecated, pass null instead.', - __METHOD__ - ); - } - if ($this->_queryCacheProfile) { $this->_queryCacheProfile = new QueryCacheProfile($this->_queryCacheProfile->getLifetime(), $this->_queryCacheProfile->getCacheKey()); } diff --git a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php b/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php index e3585cc9c30..c1121f940c5 100644 --- a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php @@ -4,14 +4,11 @@ namespace Doctrine\ORM\Event; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\Event\ManagerEventArgs; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\ObjectManager; -use function func_num_args; - /** * Class that holds event arguments for a `onClassMetadataNotFound` event. * @@ -42,17 +39,8 @@ public function __construct($className, ObjectManager $objectManager) /** * @return void */ - public function setFoundMetadata(?ClassMetadata $classMetadata = null) + public function setFoundMetadata(?ClassMetadata $classMetadata) { - if (func_num_args() < 1) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9791', - 'Calling %s without arguments is deprecated, pass null instead.', - __METHOD__ - ); - } - $this->foundMetadata = $classMetadata; } diff --git a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php index 65ff2e345a0..93adc309636 100644 --- a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php +++ b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php @@ -47,31 +47,6 @@ public function testItMakesResultCacheProfilesAwareOfTheResultCache(): void self::assertSame($cache, $query->getResultCache()); } - /** - * @dataProvider provideSettersWithDeprecatedDefault - */ - public function testCallingSettersWithoutArgumentsIsDeprecated(string $setter): void - { - $entityManager = $this->createMock(EntityManagerInterface::class); - $entityManager->method('getConfiguration')->willReturn(new Configuration()); - $query = $this->getMockForAbstractClass(AbstractQuery::class, [$entityManager]); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9791'); - $query->$setter(); - } - - /** - * @return array - */ - public function provideSettersWithDeprecatedDefault(): array - { - return [ - 'setHydrationCacheProfile' => ['setHydrationCacheProfile'], - 'setResultCache' => ['setResultCache'], - 'setResultCacheProfile' => ['setResultCacheProfile'], - ]; - } - public function testSettingTheResultCacheIsPossibleWithoutCallingDeprecatedMethods(): void { $cache = $this->createMock(CacheItemPoolInterface::class); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 5df843c8001..79147093f9c 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -512,7 +512,7 @@ public function testResultCacheProfileCanBeRemovedViaSetter(): void $query = $this->entityManager->createQuery('SELECT u FROM ' . CmsUser::class . ' u'); $query->enableResultCache(); - $query->setResultCacheProfile(); + $query->setResultCacheProfile(null); self::assertNull($query->getQueryCacheProfile()); } From d212e52a20a63ed3d1b183fafff279d5bfa78d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 1 Jun 2022 20:04:37 +0200 Subject: [PATCH 103/475] Migrate tests to PHP 8 --- .../UnitOfWorkComputeChangesBench.php | 5 +- ...etchJoinArrayHydrationPerformanceBench.php | 9 +- ...oinFullObjectHydrationPerformanceBench.php | 9 +- ...PartialObjectHydrationPerformanceBench.php | 9 +- .../Hydration/SimpleHydrationBench.php | 34 +- .../SimpleInsertPerformanceBench.php | 36 +- ...pleQueryArrayHydrationPerformanceBench.php | 9 +- ...eryFullObjectHydrationPerformanceBench.php | 9 +- ...PartialObjectHydrationPerformanceBench.php | 9 +- ...leQueryScalarHydrationPerformanceBench.php | 9 +- ...leInheritanceHydrationPerformanceBench.php | 58 ++- ...TableInheritanceInsertPerformanceBench.php | 47 +- .../ProxyInitializationTimeBench.php | 8 +- .../Mock/NonProxyLoadingEntityManager.php | 5 +- .../QueryBoundParameterProcessingBench.php | 6 +- .../Tests/DbalExtensions/SqlLogger.php | 6 +- .../Tests/DbalTypes/CustomIdObject.php | 7 +- tests/Doctrine/Tests/DbalTypes/Rot13Type.php | 8 - tests/Doctrine/Tests/DoctrineTestCase.php | 2 +- tests/Doctrine/Tests/Mocks/NullSqlWalker.php | 9 +- .../Tests/Models/CMS/CmsAddressDTO.php | 19 +- .../Doctrine/Tests/Models/CMS/CmsComment.php | 2 +- .../Doctrine/Tests/Models/CMS/CmsEmployee.php | 9 +- .../Doctrine/Tests/Models/CMS/CmsUserDTO.php | 24 +- tests/Doctrine/Tests/Models/Cache/Action.php | 19 +- tests/Doctrine/Tests/Models/Cache/Address.php | 14 +- .../Tests/Models/Cache/Attraction.php | 26 +- tests/Doctrine/Tests/Models/Cache/City.php | 30 +- tests/Doctrine/Tests/Models/Cache/Client.php | 13 +- .../Tests/Models/Cache/ComplexAction.php | 28 +- tests/Doctrine/Tests/Models/Cache/Country.php | 14 +- tests/Doctrine/Tests/Models/Cache/Flight.php | 24 +- tests/Doctrine/Tests/Models/Cache/Login.php | 14 +- tests/Doctrine/Tests/Models/Cache/Person.php | 14 +- tests/Doctrine/Tests/Models/Cache/State.php | 26 +- tests/Doctrine/Tests/Models/Cache/Token.php | 24 +- tests/Doctrine/Tests/Models/Cache/Travel.php | 16 +- .../Doctrine/Tests/Models/Cache/Traveler.php | 12 +- .../Tests/Models/Cache/TravelerProfile.php | 17 +- .../Models/Cache/TravelerProfileInfo.php | 29 +- .../Tests/Models/Company/CompanyAuction.php | 3 +- .../Tests/Models/Company/CompanyCar.php | 19 +- .../Tests/Models/Company/CompanyContract.php | 9 +- .../Tests/Models/Company/CompanyEmployee.php | 9 +- .../Tests/Models/Company/CompanyEvent.php | 12 +- .../Models/Company/CompanyFixContract.php | 3 +- .../Models/Company/CompanyFlexContract.php | 6 +- .../Company/CompanyFlexUltraContract.php | 3 +- .../Tests/Models/Company/CompanyManager.php | 6 +- .../Models/Company/CompanyOrganization.php | 6 +- .../Tests/Models/Company/CompanyPerson.php | 9 +- .../Tests/Models/Company/CompanyRaffle.php | 3 +- .../JoinedChildClass.php | 3 +- .../JoinedDerivedChildClass.php | 3 +- .../SingleChildClass.php | 3 +- .../CustomType/CustomIdObjectTypeChild.php | 27 +- .../CustomType/CustomIdObjectTypeParent.php | 14 +- .../Models/DDC117/DDC117ApproveChanges.php | 60 +-- .../Tests/Models/DDC117/DDC117Article.php | 20 +- .../Models/DDC117/DDC117ArticleDetails.php | 17 +- .../Tests/Models/DDC117/DDC117Editor.php | 12 +- .../Tests/Models/DDC117/DDC117Link.php | 34 +- .../Tests/Models/DDC117/DDC117Reference.php | 21 +- .../Tests/Models/DDC117/DDC117Translation.php | 38 +- .../Tests/Models/DDC1872/DDC1872Bar.php | 3 +- .../Tests/Models/DDC2372/DDC2372Address.php | 6 +- .../Tests/Models/DDC2372/DDC2372User.php | 6 +- .../Tests/Models/DDC3579/DDC3579Group.php | 16 +- .../Tests/Models/DDC3579/DDC3579User.php | 13 +- .../Tests/Models/DDC3597/DDC3597Image.php | 3 +- .../Tests/Models/DDC3597/DDC3597Media.php | 19 +- .../DDC3597/Embeddable/DDC3597Dimension.php | 6 +- .../Tests/Models/DDC3711/DDC3711EntityB.php | 6 +- .../Tests/Models/DDC4006/DDC4006User.php | 3 +- .../Tests/Models/DDC4006/DDC4006UserId.php | 3 +- .../Tests/Models/DDC964/DDC964Address.php | 54 +-- .../Tests/Models/DDC964/DDC964Group.php | 18 +- .../Tests/Models/DDC964/DDC964User.php | 13 +- .../DirectoryTree/AbstractContentItem.php | 21 +- .../Tests/Models/ECommerce/ECommerceCart.php | 9 +- .../Models/ECommerce/ECommerceCategory.php | 9 +- .../Models/ECommerce/ECommerceCustomer.php | 12 +- .../Models/ECommerce/ECommerceFeature.php | 9 +- .../Models/ECommerce/ECommerceProduct.php | 9 +- .../Models/ECommerce/ECommerceShipping.php | 6 +- .../Tests/Models/Forum/ForumCategory.php | 3 +- .../Models/Generic/NonAlphaColumnsEntity.php | 14 +- .../Doctrine/Tests/Models/GeoNames/Admin1.php | 46 +- .../Models/GeoNames/Admin1AlternateName.php | 50 +- tests/Doctrine/Tests/Models/GeoNames/City.php | 29 +- .../Tests/Models/GeoNames/Country.php | 29 +- .../Models/Global/GlobalNamespaceModel.php | 9 +- .../Models/Legacy/LegacyUserReference.php | 21 +- .../Models/ManyToManyPersister/ChildClass.php | 28 +- .../ManyToManyPersister/OtherParentClass.php | 16 +- .../ManyToManyPersister/ParentClass.php | 14 +- .../Tests/Models/Navigation/NavCountry.php | 17 +- .../Tests/Models/Navigation/NavPhotos.php | 38 +- .../Models/Navigation/NavPointOfInterest.php | 46 +- .../Tests/Models/Navigation/NavTour.php | 17 +- .../Tests/Models/Navigation/NavUser.php | 17 +- .../Doctrine/Tests/Models/Pagination/User.php | 3 +- .../PersistentCollectionHolder.php | 6 - tests/Doctrine/Tests/Models/Quote/City.php | 14 +- tests/Doctrine/Tests/Models/Quote/Group.php | 27 +- .../Tests/Models/Quote/NumericEntity.php | 14 +- .../Models/Reflection/AbstractEmbeddable.php | 3 +- .../Reflection/ClassWithMixedProperties.php | 6 +- .../Models/Reflection/ConcreteEmbeddable.php | 3 +- .../Tests/Models/Reflection/ParentClass.php | 3 +- .../Tests/Models/StockExchange/Bond.php | 17 +- .../Tests/Models/StockExchange/Market.php | 15 +- .../Tests/Models/StockExchange/Stock.php | 23 +- tests/Doctrine/Tests/Models/Taxi/Car.php | 6 +- tests/Doctrine/Tests/Models/Taxi/Driver.php | 6 +- tests/Doctrine/Tests/Models/Taxi/PaidRide.php | 33 +- tests/Doctrine/Tests/Models/Taxi/Ride.php | 33 +- .../Models/TypedProperties/UserTyped.php | 4 +- .../Tests/Models/ValueObjects/Name.php | 6 +- .../Tests/Models/ValueObjects/Person.php | 6 +- .../Tests/ORM/Cache/DefaultCacheTest.php | 10 +- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 3 +- .../Tests/ORM/Cache/FileLockRegionTest.php | 4 +- .../Tests/ORM/CommitOrderCalculatorTest.php | 5 +- .../Tests/ORM/Entity/ConstructorTest.php | 3 +- .../AbstractManyToManyAssociationTestCase.php | 4 +- .../Functional/AdvancedAssociationTest.php | 48 +- .../ORM/Functional/BasicFunctionalTest.php | 8 +- .../ORM/Functional/CascadeRemoveOrderTest.php | 22 +- .../ClassTableInheritanceSecondTest.php | 20 +- .../Functional/ClassTableInheritanceTest.php | 8 +- .../ORM/Functional/CustomFunctionsTest.php | 12 +- .../ORM/Functional/DefaultValuesTest.php | 4 +- .../ORM/Functional/EntityListenersTest.php | 3 +- .../ORM/Functional/EntityRepositoryTest.php | 3 +- .../Functional/ExtraLazyCollectionTest.php | 27 +- .../Tests/ORM/Functional/FlushEventTest.php | 2 +- .../Tests/ORM/Functional/GH5988Test.php | 6 +- .../Tests/ORM/Functional/IdentityMapTest.php | 8 +- .../ORM/Functional/IndexByAssociationTest.php | 6 +- .../Functional/InsertableUpdatableTest.php | 2 +- .../ORM/Functional/LifecycleCallbackTest.php | 20 +- .../Functional/Locking/GearmanLockTest.php | 9 +- .../Functional/Locking/LockAgentWorker.php | 6 +- .../Tests/ORM/Functional/Locking/LockTest.php | 4 +- .../ORM/Functional/Locking/OptimisticTest.php | 12 +- .../ManyToManyBasicAssociationTest.php | 42 +- ...ManyToManyBidirectionalAssociationTest.php | 12 +- .../ORM/Functional/ManyToManyEventTest.php | 3 +- ...nyToManySelfReferentialAssociationTest.php | 12 +- ...anyToManyUnidirectionalAssociationTest.php | 12 +- .../Functional/ManyToOneOrphanRemovalTest.php | 3 +- .../ORM/Functional/MappedSuperclassTest.php | 2 +- .../Tests/ORM/Functional/NativeQueryTest.php | 5 +- .../Tests/ORM/Functional/NewOperatorTest.php | 9 +- .../Tests/ORM/Functional/NotifyPolicyTest.php | 12 +- .../OneToManyBidirectionalAssociationTest.php | 9 +- ...neToManySelfReferentialAssociationTest.php | 9 +- .../OneToOneBidirectionalAssociationTest.php | 6 +- .../Functional/OneToOneEagerLoadingTest.php | 63 ++- ...eToOneInverseSideLoadAfterDqlQueryTest.php | 2 +- ...OneToOneSelfReferentialAssociationTest.php | 17 +- .../OneToOneUnidirectionalAssociationTest.php | 8 +- .../Tests/ORM/Functional/PaginationTest.php | 28 +- .../ORM/Functional/PostFlushEventTest.php | 5 +- .../ORM/Functional/PostLoadEventTest.php | 5 +- .../ORM/Functional/QueryDqlFunctionTest.php | 6 +- .../Tests/ORM/Functional/QueryTest.php | 11 +- .../Tests/ORM/Functional/ReadOnlyTest.php | 25 +- .../ORM/Functional/ReferenceProxyTest.php | 6 +- .../Tests/ORM/Functional/SQLFilterTest.php | 12 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 10 +- .../ORM/Functional/SchemaTool/DDC214Test.php | 56 ++- .../SchemaTool/MySqlSchemaToolTest.php | 24 +- .../SchemaTool/PostgreSqlSchemaToolTest.php | 23 +- .../SecondLevelCacheConcurrentTest.php | 6 +- ...condLevelCacheJoinTableInheritanceTest.php | 2 +- .../SecondLevelCacheQueryCacheTest.php | 3 +- ...ndLevelCacheSingleTableInheritanceTest.php | 2 +- .../ORM/Functional/SecondLevelCacheTest.php | 7 +- .../SequenceEmulatedIdentityStrategyTest.php | 6 +- .../Functional/SingleTableInheritanceTest.php | 22 +- .../ORM/Functional/Ticket/DDC1041Test.php | 10 +- .../ORM/Functional/Ticket/DDC1163Test.php | 33 +- .../ORM/Functional/Ticket/DDC117Test.php | 31 +- .../ORM/Functional/Ticket/DDC1193Test.php | 4 +- .../ORM/Functional/Ticket/DDC1209Test.php | 21 +- .../ORM/Functional/Ticket/DDC1225Test.php | 6 +- .../ORM/Functional/Ticket/DDC1238Test.php | 6 +- .../ORM/Functional/Ticket/DDC1301Test.php | 37 +- .../ORM/Functional/Ticket/DDC1335Test.php | 55 +-- .../ORM/Functional/Ticket/DDC1400Test.php | 2 +- .../ORM/Functional/Ticket/DDC1430Test.php | 39 +- .../ORM/Functional/Ticket/DDC1436Test.php | 2 +- .../ORM/Functional/Ticket/DDC1452Test.php | 2 +- .../ORM/Functional/Ticket/DDC1454Test.php | 4 +- .../ORM/Functional/Ticket/DDC1461Test.php | 2 +- .../ORM/Functional/Ticket/DDC1514Test.php | 2 +- .../ORM/Functional/Ticket/DDC1545Test.php | 9 +- .../ORM/Functional/Ticket/DDC1643Test.php | 24 +- .../ORM/Functional/Ticket/DDC1655Test.php | 6 +- .../ORM/Functional/Ticket/DDC1685Test.php | 3 +- .../ORM/Functional/Ticket/DDC1690Test.php | 18 +- .../ORM/Functional/Ticket/DDC1695Test.php | 54 +-- .../ORM/Functional/Ticket/DDC1707Test.php | 2 +- .../ORM/Functional/Ticket/DDC1719Test.php | 14 +- .../ORM/Functional/Ticket/DDC1757Test.php | 12 +- .../ORM/Functional/Ticket/DDC1778Test.php | 6 +- .../ORM/Functional/Ticket/DDC1787Test.php | 6 +- .../ORM/Functional/Ticket/DDC1885Test.php | 3 +- .../ORM/Functional/Ticket/DDC1925Test.php | 12 +- .../ORM/Functional/Ticket/DDC1998Test.php | 8 +- .../ORM/Functional/Ticket/DDC2012Test.php | 4 +- .../ORM/Functional/Ticket/DDC2084Test.php | 52 +-- .../ORM/Functional/Ticket/DDC2138Test.php | 63 ++- .../ORM/Functional/Ticket/DDC2182Test.php | 9 +- .../ORM/Functional/Ticket/DDC2230Test.php | 2 +- .../ORM/Functional/Ticket/DDC2252Test.php | 32 +- .../ORM/Functional/Ticket/DDC2306Test.php | 17 +- .../ORM/Functional/Ticket/DDC237Test.php | 4 +- .../ORM/Functional/Ticket/DDC2415Test.php | 6 +- .../ORM/Functional/Ticket/DDC2494Test.php | 46 +- .../ORM/Functional/Ticket/DDC2575Test.php | 91 ++-- .../ORM/Functional/Ticket/DDC2579Test.php | 50 +- .../ORM/Functional/Ticket/DDC2602Test.php | 6 +- .../ORM/Functional/Ticket/DDC2660Test.php | 41 +- .../ORM/Functional/Ticket/DDC2692Test.php | 2 +- .../ORM/Functional/Ticket/DDC2759Test.php | 41 +- .../ORM/Functional/Ticket/DDC2790Test.php | 4 +- .../ORM/Functional/Ticket/DDC2825Test.php | 2 +- .../ORM/Functional/Ticket/DDC2862Test.php | 42 +- .../ORM/Functional/Ticket/DDC2895Test.php | 2 +- .../ORM/Functional/Ticket/DDC2931Test.php | 2 +- .../ORM/Functional/Ticket/DDC2984Test.php | 33 +- .../ORM/Functional/Ticket/DDC2996Test.php | 2 +- .../ORM/Functional/Ticket/DDC3033Test.php | 2 +- .../ORM/Functional/Ticket/DDC3068Test.php | 6 +- .../ORM/Functional/Ticket/DDC3160Test.php | 2 +- .../ORM/Functional/Ticket/DDC3192Test.php | 45 +- .../ORM/Functional/Ticket/DDC3223Test.php | 3 +- .../ORM/Functional/Ticket/DDC3300Test.php | 26 +- .../ORM/Functional/Ticket/DDC3303Test.php | 75 ++- .../ORM/Functional/Ticket/DDC345Test.php | 2 +- .../ORM/Functional/Ticket/DDC353Test.php | 8 +- .../ORM/Functional/Ticket/DDC3582Test.php | 14 +- .../ORM/Functional/Ticket/DDC3634Test.php | 22 +- .../ORM/Functional/Ticket/DDC3644Test.php | 26 +- .../ORM/Functional/Ticket/DDC371Test.php | 6 +- .../ORM/Functional/Ticket/DDC3785Test.php | 57 +-- .../ORM/Functional/Ticket/DDC422Test.php | 2 +- .../ORM/Functional/Ticket/DDC448Test.php | 6 +- .../ORM/Functional/Ticket/DDC522Test.php | 2 +- .../ORM/Functional/Ticket/DDC5684Test.php | 8 +- .../ORM/Functional/Ticket/DDC588Test.php | 13 +- .../ORM/Functional/Ticket/DDC599Test.php | 2 +- .../ORM/Functional/Ticket/DDC618Test.php | 27 +- .../ORM/Functional/Ticket/DDC6303Test.php | 22 +- .../ORM/Functional/Ticket/DDC6460Test.php | 2 +- .../ORM/Functional/Ticket/DDC656Test.php | 6 +- .../ORM/Functional/Ticket/DDC657Test.php | 36 +- .../Tests/ORM/Functional/Ticket/DDC69Test.php | 29 +- .../ORM/Functional/Ticket/DDC719Test.php | 2 - .../ORM/Functional/Ticket/DDC735Test.php | 8 +- .../ORM/Functional/Ticket/DDC736Test.php | 3 +- .../ORM/Functional/Ticket/DDC767Test.php | 6 +- .../ORM/Functional/Ticket/DDC812Test.php | 2 +- .../ORM/Functional/Ticket/DDC832Test.php | 42 +- .../ORM/Functional/Ticket/DDC837Test.php | 14 +- .../ORM/Functional/Ticket/DDC849Test.php | 9 +- .../ORM/Functional/Ticket/DDC881Test.php | 24 +- .../ORM/Functional/Ticket/DDC960Test.php | 19 +- .../ORM/Functional/Ticket/DDC992Test.php | 6 +- .../ORM/Functional/Ticket/GH2947Test.php | 20 +- .../ORM/Functional/Ticket/GH5562Test.php | 2 +- .../ORM/Functional/Ticket/GH5762Test.php | 67 +-- .../ORM/Functional/Ticket/GH5887Test.php | 20 +- .../ORM/Functional/Ticket/GH6141Test.php | 22 +- .../ORM/Functional/Ticket/GH6217Test.php | 33 +- .../ORM/Functional/Ticket/GH6362Test.php | 9 +- .../ORM/Functional/Ticket/GH6394Test.php | 45 +- .../ORM/Functional/Ticket/GH6531Test.php | 80 ++-- .../ORM/Functional/Ticket/GH6740Test.php | 9 +- .../ORM/Functional/Ticket/GH7012Test.php | 29 +- .../ORM/Functional/Ticket/GH7062Test.php | 72 ++- .../ORM/Functional/Ticket/GH7079Test.php | 6 +- .../ORM/Functional/Ticket/GH7286Test.php | 31 +- .../ORM/Functional/Ticket/GH7366Test.php | 16 +- .../Ticket/GH7496WithToIterableTest.php | 95 ++-- .../ORM/Functional/Ticket/GH7661Test.php | 23 +- .../ORM/Functional/Ticket/GH7735Test.php | 77 ++- .../ORM/Functional/Ticket/GH7737Test.php | 41 +- .../ORM/Functional/Ticket/GH7767Test.php | 33 +- .../ORM/Functional/Ticket/GH7820Test.php | 47 +- .../ORM/Functional/Ticket/GH7836Test.php | 44 +- .../ORM/Functional/Ticket/GH7864Test.php | 4 +- .../ORM/Functional/Ticket/GH7875Test.php | 16 +- .../ORM/Functional/Ticket/GH7941Test.php | 22 +- .../ORM/Functional/Ticket/GH8061Test.php | 6 +- .../ORM/Functional/Ticket/GH8217Test.php | 31 +- .../ORM/Functional/Ticket/GH8443Test.php | 17 +- .../ORM/Functional/Ticket/GH9109Test.php | 15 +- .../Ticket4646InstanceOfAbstractTest.php | 3 +- .../Ticket4646InstanceOfMultiLevelTest.php | 3 +- .../Ticket4646InstanceOfParametricTest.php | 3 +- .../Ticket/Ticket4646InstanceOfTest.php | 3 +- ...46InstanceOfWithMultipleParametersTest.php | 3 +- .../Tests/ORM/Functional/TypeTest.php | 2 +- .../ManyToManyCompositeIdForeignKeyTest.php | 33 +- .../ManyToManyCompositeIdTest.php | 20 +- .../ManyToManyExtraLazyTest.php | 22 +- .../ValueConversionType/ManyToManyTest.php | 20 +- .../OneToManyCompositeIdForeignKeyTest.php | 31 +- .../OneToManyCompositeIdTest.php | 18 +- .../OneToManyExtraLazyTest.php | 12 +- .../ValueConversionType/OneToManyTest.php | 18 +- .../OneToOneCompositeIdForeignKeyTest.php | 33 +- .../OneToOneCompositeIdTest.php | 20 +- .../ValueConversionType/OneToOneTest.php | 20 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 240 ++++------ .../ORM/Functional/VersionedOneToOneTest.php | 2 +- .../ORM/Hydration/ObjectHydratorTest.php | 7 +- .../Hydration/SimpleObjectHydratorTest.php | 2 +- .../Tests/ORM/Id/AssignedGeneratorTest.php | 6 +- .../Internal/HydrationCompleteHandlerTest.php | 13 +- .../Tests/ORM/LazyCriteriaCollectionTest.php | 6 +- .../ORM/Mapping/AbstractMappingDriverTest.php | 28 +- .../ORM/Mapping/AnnotationDriverTest.php | 25 +- .../ORM/Mapping/AnsiQuoteStrategyTest.php | 6 +- .../Mapping/BasicInheritanceMappingTest.php | 36 +- .../ORM/Mapping/ClassMetadataBuilderTest.php | 6 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 18 +- .../Mapping/ClassMetadataLoadEventTest.php | 8 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 159 ++++--- .../Mapping/EntityListenerResolverTest.php | 19 +- .../Tests/ORM/Mapping/FieldBuilderTest.php | 4 +- .../Tests/ORM/Mapping/NamingStrategyTest.php | 4 +- .../Tests/ORM/Mapping/QuoteStrategyTest.php | 6 +- .../Mapping/Symfony/AbstractDriverTest.php | 3 +- .../ORM/Mapping/XmlMappingDriverTest.php | 2 +- .../Tests/ORM/PersistentCollectionTest.php | 3 +- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 13 +- .../ORM/Query/CustomTreeWalkersJoinTest.php | 3 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 52 ++- .../ORM/Query/DeleteSqlGenerationTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/ExprTest.php | 47 +- .../Tests/ORM/Query/FilterCollectionTest.php | 3 +- .../ORM/Query/LanguageRecognitionTest.php | 21 +- .../ORM/Query/QueryExpressionVisitorTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 3 +- .../ORM/Query/SelectSqlGenerationTest.php | 23 +- .../Tests/ORM/Query/SqlWalkerTest.php | 3 +- .../ORM/Query/UpdateSqlGenerationTest.php | 3 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 2 +- .../AttachEntityListenersListenerTest.php | 12 +- .../ClearCacheCollectionRegionCommandTest.php | 6 +- .../ClearCacheEntityRegionCommandTest.php | 6 +- .../ClearCacheQueryRegionCommandTest.php | 6 +- .../Command/MappingDescribeCommandTest.php | 13 +- .../Console/Command/RunDqlCommandTest.php | 9 +- .../Command/ValidateSchemaCommandTest.php | 6 +- .../ORM/Tools/Console/MetadataFilterTest.php | 3 +- .../Tools/Pagination/PaginationTestCase.php | 3 +- .../ORM/Tools/Pagination/PaginatorTest.php | 3 +- .../Tools/ResolveTargetEntityListenerTest.php | 21 +- .../Tests/ORM/Tools/SchemaToolTest.php | 12 +- .../Tests/ORM/Tools/SchemaValidatorTest.php | 93 ++-- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 41 +- .../Utility/IdentifierFlattenerEnumIdTest.php | 2 +- .../ORM/Utility/IdentifierFlattenerTest.php | 8 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 439 ++++++++++++------ tests/Doctrine/Tests/OrmTestCase.php | 22 +- tests/Doctrine/Tests/TestUtil.php | 4 +- 372 files changed, 2936 insertions(+), 3939 deletions(-) diff --git a/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php b/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php index fecadc98ad7..1e042772932 100644 --- a/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php +++ b/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php @@ -18,10 +18,9 @@ final class UnitOfWorkComputeChangesBench { /** @var CmsUser[] */ - private $users; + private ?array $users = null; - /** @var UnitOfWork */ - private $unitOfWork; + private ?UnitOfWork $unitOfWork = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php index 77838d5675b..a9831d309dd 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php @@ -18,14 +18,11 @@ */ final class MixedQueryFetchJoinArrayHydrationPerformanceBench { - /** @var ArrayHydrator */ - private $hydrator; + private ?ArrayHydrator $hydrator = null; - /** @var ResultSetMapping */ - private $rsm; + private ?ResultSetMapping $rsm = null; - /** @var Result */ - private $result; + private ?Result $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php index b6e807b3d48..7ce3d2cdd4c 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php @@ -19,14 +19,11 @@ */ final class MixedQueryFetchJoinFullObjectHydrationPerformanceBench { - /** @var ObjectHydrator */ - private $hydrator; + private ?ObjectHydrator $hydrator = null; - /** @var ResultSetMapping */ - private $rsm; + private ?ResultSetMapping $rsm = null; - /** @var Result */ - private $result; + private ?Result $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php index 32401dda75f..7cc9b5e0944 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php @@ -19,14 +19,11 @@ */ final class MixedQueryFetchJoinPartialObjectHydrationPerformanceBench { - /** @var ObjectHydrator */ - private $hydrator; + private ?ObjectHydrator $hydrator = null; - /** @var ResultSetMapping */ - private $rsm; + private ?ResultSetMapping $rsm = null; - /** @var Result */ - private $result; + private ?Result $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php b/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php index 5d67ac1d762..dabb1236122 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php @@ -4,6 +4,14 @@ namespace Doctrine\Performance\Hydration; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsEmail; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsTag; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\Performance\EntityManagerFactory; @@ -14,27 +22,25 @@ */ final class SimpleHydrationBench { - /** @var EntityManagerInterface */ - private $entityManager; + private ?EntityManagerInterface $entityManager = null; - /** @var EntityRepository */ - private $repository; + private ?EntityRepository $repository = null; public function init(): void { $this->entityManager = EntityManagerFactory::getEntityManager([ - CMS\CmsUser::class, - CMS\CmsPhonenumber::class, - CMS\CmsAddress::class, - CMS\CmsEmail::class, - CMS\CmsGroup::class, - CMS\CmsTag::class, - CMS\CmsArticle::class, - CMS\CmsComment::class, + CmsUser::class, + CmsPhonenumber::class, + CmsAddress::class, + CmsEmail::class, + CmsGroup::class, + CmsTag::class, + CmsArticle::class, + CmsComment::class, ]); for ($i = 2; $i < 10000; ++$i) { - $user = new CMS\CmsUser(); + $user = new CmsUser(); $user->status = 'developer'; $user->username = 'jwage' . $i; @@ -46,7 +52,7 @@ public function init(): void $this->entityManager->flush(); $this->entityManager->clear(); - $this->repository = $this->entityManager->getRepository(CMS\CmsUser::class); + $this->repository = $this->entityManager->getRepository(CmsUser::class); } public function benchHydration(): void diff --git a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php index 4ac02011ce3..189bc0f8f42 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php @@ -4,6 +4,14 @@ namespace Doctrine\Performance\Hydration; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsEmail; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsTag; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Performance\EntityManagerFactory; use Doctrine\Tests\Models\CMS; @@ -14,30 +22,28 @@ */ final class SimpleInsertPerformanceBench { - /** @var EntityManagerInterface */ - private $entityManager; + private ?EntityManagerInterface $entityManager = null; /** @var CMS\CmsUser[] */ - private $users; + private ?array $users = null; - /** @var string */ - private $tableName; + private ?string $tableName = null; public function init(): void { $this->entityManager = EntityManagerFactory::getEntityManager([ - CMS\CmsUser::class, - CMS\CmsPhonenumber::class, - CMS\CmsAddress::class, - CMS\CmsEmail::class, - CMS\CmsGroup::class, - CMS\CmsTag::class, - CMS\CmsArticle::class, - CMS\CmsComment::class, + CmsUser::class, + CmsPhonenumber::class, + CmsAddress::class, + CmsEmail::class, + CmsGroup::class, + CmsTag::class, + CmsArticle::class, + CmsComment::class, ]); for ($i = 1; $i <= 10000; ++$i) { - $user = new CMS\CmsUser(); + $user = new CmsUser(); $user->status = 'user'; $user->username = 'user' . $i; $user->name = 'Mr.Smith-' . $i; @@ -45,7 +51,7 @@ public function init(): void $this->users[$i] = $user; } - $this->tableName = $this->entityManager->getClassMetadata(CMS\CmsUser::class)->getTableName(); + $this->tableName = $this->entityManager->getClassMetadata(CmsUser::class)->getTableName(); } public function benchHydration(): void diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php index fb5a9ab7df1..f6999e25333 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php @@ -17,14 +17,11 @@ */ final class SimpleQueryArrayHydrationPerformanceBench { - /** @var ArrayHydrator */ - private $hydrator; + private ?ArrayHydrator $hydrator = null; - /** @var ResultSetMapping */ - private $rsm; + private ?ResultSetMapping $rsm = null; - /** @var Result */ - private $result; + private ?Result $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php index a2f88bf417e..7cfc9e38bae 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php @@ -18,14 +18,11 @@ */ final class SimpleQueryFullObjectHydrationPerformanceBench { - /** @var ObjectHydrator */ - private $hydrator; + private ?ObjectHydrator $hydrator = null; - /** @var ResultSetMapping */ - private $rsm; + private ?ResultSetMapping $rsm = null; - /** @var Result */ - private $result; + private ?Result $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php index 8ee4a83f6b2..819cca579c2 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php @@ -18,14 +18,11 @@ */ final class SimpleQueryPartialObjectHydrationPerformanceBench { - /** @var ObjectHydrator */ - private $hydrator; + private ?ObjectHydrator $hydrator = null; - /** @var ResultSetMapping */ - private $rsm; + private ?ResultSetMapping $rsm = null; - /** @var Result */ - private $result; + private ?Result $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php index e0eab3c0ded..9d11c42388b 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php @@ -17,14 +17,11 @@ */ final class SimpleQueryScalarHydrationPerformanceBench { - /** @var ScalarHydrator */ - private $hydrator; + private ?ScalarHydrator $hydrator = null; - /** @var ResultSetMapping */ - private $rsm; + private ?ResultSetMapping $rsm = null; - /** @var Result */ - private $result; + private ?Result $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php index a816117f110..ab1076f6c3f 100644 --- a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php @@ -4,6 +4,18 @@ namespace Doctrine\Performance\Hydration; +use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyManager; +use Doctrine\Tests\Models\Company\CompanyOrganization; +use Doctrine\Tests\Models\Company\CompanyEvent; +use Doctrine\Tests\Models\Company\CompanyAuction; +use Doctrine\Tests\Models\Company\CompanyRaffle; +use Doctrine\Tests\Models\Company\CompanyCar; +use Doctrine\Tests\Models\Company\CompanyContract; +use Doctrine\Tests\Models\Company\CompanyFixContract; +use Doctrine\Tests\Models\Company\CompanyFlexContract; +use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; use Doctrine\ORM\EntityRepository; use Doctrine\Performance\EntityManagerFactory; use Doctrine\Tests\Models\Company; @@ -14,47 +26,43 @@ */ final class SingleTableInheritanceHydrationPerformanceBench { - /** @var EntityRepository */ - private $contractsRepository; + private ?EntityRepository $contractsRepository = null; - /** @var EntityRepository */ - private $fixContractsRepository; + private ?EntityRepository $fixContractsRepository = null; - /** @var EntityRepository */ - private $flexContractRepository; + private ?EntityRepository $flexContractRepository = null; - /** @var EntityRepository */ - private $ultraContractRepository; + private ?EntityRepository $ultraContractRepository = null; public function init(): void { $entityManager = EntityManagerFactory::getEntityManager([ - Company\CompanyPerson::class, - Company\CompanyEmployee::class, - Company\CompanyManager::class, - Company\CompanyOrganization::class, - Company\CompanyEvent::class, - Company\CompanyAuction::class, - Company\CompanyRaffle::class, - Company\CompanyCar::class, - Company\CompanyContract::class, + CompanyPerson::class, + CompanyEmployee::class, + CompanyManager::class, + CompanyOrganization::class, + CompanyEvent::class, + CompanyAuction::class, + CompanyRaffle::class, + CompanyCar::class, + CompanyContract::class, ]); - $this->contractsRepository = $entityManager->getRepository(Company\CompanyContract::class); - $this->fixContractsRepository = $entityManager->getRepository(Company\CompanyFixContract::class); - $this->flexContractRepository = $entityManager->getRepository(Company\CompanyFlexContract::class); - $this->ultraContractRepository = $entityManager->getRepository(Company\CompanyFlexUltraContract::class); + $this->contractsRepository = $entityManager->getRepository(CompanyContract::class); + $this->fixContractsRepository = $entityManager->getRepository(CompanyFixContract::class); + $this->flexContractRepository = $entityManager->getRepository(CompanyFlexContract::class); + $this->ultraContractRepository = $entityManager->getRepository(CompanyFlexUltraContract::class); - $person = new Company\CompanyEmployee(); + $person = new CompanyEmployee(); $person->setName('Poor Sales Guy'); $person->setDepartment('Sales'); $person->setSalary(100); $entityManager->persist($person); for ($i = 0; $i < 33; $i++) { - $fixContract = new Company\CompanyFixContract(); - $flexContract = new Company\CompanyFlexContract(); - $ultraContract = new Company\CompanyFlexUltraContract(); + $fixContract = new CompanyFixContract(); + $flexContract = new CompanyFlexContract(); + $ultraContract = new CompanyFlexUltraContract(); $fixContract->setFixPrice(1000); $fixContract->setSalesPerson($person); diff --git a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php index 4e244d25987..09feefc63bc 100644 --- a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php @@ -4,6 +4,18 @@ namespace Doctrine\Performance\Hydration; +use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyManager; +use Doctrine\Tests\Models\Company\CompanyOrganization; +use Doctrine\Tests\Models\Company\CompanyEvent; +use Doctrine\Tests\Models\Company\CompanyAuction; +use Doctrine\Tests\Models\Company\CompanyRaffle; +use Doctrine\Tests\Models\Company\CompanyCar; +use Doctrine\Tests\Models\Company\CompanyContract; +use Doctrine\Tests\Models\Company\CompanyFixContract; +use Doctrine\Tests\Models\Company\CompanyFlexContract; +use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Performance\EntityManagerFactory; use Doctrine\Tests\Models\Company; @@ -16,51 +28,50 @@ */ final class SingleTableInheritanceInsertPerformanceBench { - /** @var EntityManagerInterface */ - private $entityManager; + private ?EntityManagerInterface $entityManager = null; /** @var Company\CompanyFixContract[] */ - private $fixContracts = []; + private array $fixContracts = []; /** @var Company\CompanyFlexContract[] */ - private $flexContracts = []; + private array $flexContracts = []; /** @var Company\CompanyFlexUltraContract[] */ - private $ultraContracts = []; + private array $ultraContracts = []; public function init(): void { $this->entityManager = EntityManagerFactory::getEntityManager([ - Company\CompanyPerson::class, - Company\CompanyEmployee::class, - Company\CompanyManager::class, - Company\CompanyOrganization::class, - Company\CompanyEvent::class, - Company\CompanyAuction::class, - Company\CompanyRaffle::class, - Company\CompanyCar::class, - Company\CompanyContract::class, + CompanyPerson::class, + CompanyEmployee::class, + CompanyManager::class, + CompanyOrganization::class, + CompanyEvent::class, + CompanyAuction::class, + CompanyRaffle::class, + CompanyCar::class, + CompanyContract::class, ]); - $person = new Company\CompanyEmployee(); + $person = new CompanyEmployee(); $person->setName('Poor Sales Guy'); $person->setDepartment('Sales'); $person->setSalary(100); $this->entityManager->persist($person); for ($i = 0; $i < 33; $i++) { - $this->fixContracts[$i] = new Company\CompanyFixContract(); + $this->fixContracts[$i] = new CompanyFixContract(); $this->fixContracts[$i]->setFixPrice(1000); $this->fixContracts[$i]->setSalesPerson($person); $this->fixContracts[$i]->markCompleted(); - $this->flexContracts[$i] = new Company\CompanyFlexContract(); + $this->flexContracts[$i] = new CompanyFlexContract(); $this->flexContracts[$i]->setSalesPerson($person); $this->flexContracts[$i]->setHoursWorked(100); $this->flexContracts[$i]->setPricePerHour(100); $this->flexContracts[$i]->markCompleted(); - $this->ultraContracts[$i] = new Company\CompanyFlexUltraContract(); + $this->ultraContracts[$i] = new CompanyFlexUltraContract(); $this->ultraContracts[$i]->setSalesPerson($person); $this->ultraContracts[$i]->setHoursWorked(150); $this->ultraContracts[$i]->setPricePerHour(150); diff --git a/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php b/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php index e9bf3342b6a..d8007af7a4c 100644 --- a/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php +++ b/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php @@ -16,16 +16,16 @@ final class ProxyInitializationTimeBench { /** @var Proxy[] */ - private $cmsUsers; + private ?array $cmsUsers = null; /** @var Proxy[] */ - private $cmsEmployees; + private ?array $cmsEmployees = null; /** @var Proxy[] */ - private $initializedUsers; + private ?array $initializedUsers = null; /** @var Proxy[] */ - private $initializedEmployees; + private ?array $initializedEmployees = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 4526f2dcba0..2b93530aac3 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -27,11 +27,8 @@ */ class NonProxyLoadingEntityManager implements EntityManagerInterface { - private EntityManagerInterface $realEntityManager; - - public function __construct(EntityManagerInterface $realEntityManager) + public function __construct(private EntityManagerInterface $realEntityManager) { - $this->realEntityManager = $realEntityManager; } public function getProxyFactory(): ProxyFactory diff --git a/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php b/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php index 7ce041f817f..b67a5c045f0 100644 --- a/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php +++ b/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php @@ -17,11 +17,9 @@ */ final class QueryBoundParameterProcessingBench { - /** @var Query */ - private $parsedQueryWithInferredParameterType; + private ?Query $parsedQueryWithInferredParameterType = null; - /** @var Query */ - private $parsedQueryWithDeclaredParameterType; + private ?Query $parsedQueryWithDeclaredParameterType = null; public function init(): void { diff --git a/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php b/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php index 3bbfd67b2dd..17270a707af 100644 --- a/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php +++ b/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php @@ -8,12 +8,8 @@ final class SqlLogger extends AbstractLogger { - /** @var QueryLog */ - private $queryLog; - - public function __construct(QueryLog $queryLog) + public function __construct(private QueryLog $queryLog) { - $this->queryLog = $queryLog; } public function log($level, $message, array $context = []): void diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php b/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php index 0c36e57eb6e..f246a9d1fd6 100644 --- a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php +++ b/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php @@ -4,13 +4,10 @@ namespace Doctrine\Tests\DbalTypes; -class CustomIdObject +class CustomIdObject implements \Stringable { - public string $id; - - public function __construct(string $id) + public function __construct(public string $id) { - $this->id = $id; } public function __toString(): string diff --git a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php index f767f09e6f8..e4fe9378a12 100644 --- a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php +++ b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php @@ -19,7 +19,6 @@ class Rot13Type extends Type * {@inheritdoc} * * @param string|null $value - * @param AbstractPlatform $platform */ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { @@ -34,7 +33,6 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str * {@inheritdoc} * * @param string|null $value - * @param AbstractPlatform $platform */ public function convertToPHPValue($value, AbstractPlatform $platform): ?string { @@ -48,10 +46,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?string /** * {@inheritdoc} * - * @param array $column - * @param AbstractPlatform $platform * - * @return string */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { @@ -65,7 +60,6 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st /** * {@inheritdoc} * - * @param AbstractPlatform $platform * * @return int|null */ @@ -76,8 +70,6 @@ public function getDefaultLength(AbstractPlatform $platform) /** * {@inheritdoc} - * - * @return string */ public function getName(): string { diff --git a/tests/Doctrine/Tests/DoctrineTestCase.php b/tests/Doctrine/Tests/DoctrineTestCase.php index 1a7a1badcfd..4fdf5d65c7d 100644 --- a/tests/Doctrine/Tests/DoctrineTestCase.php +++ b/tests/Doctrine/Tests/DoctrineTestCase.php @@ -17,7 +17,7 @@ abstract class DoctrineTestCase extends TestCase { /** @var array */ - private static $phpunitMethodRenames = [ + private static array $phpunitMethodRenames = [ 'assertMatchesRegularExpression' => 'assertRegExp', // can be removed when PHPUnit 9 is minimum 'assertDoesNotMatchRegularExpression' => 'assertNotRegExp', // can be removed when PHPUnit 9 is minimum 'assertFileDoesNotExist' => 'assertFileNotExists', // can be removed PHPUnit 9 is minimum diff --git a/tests/Doctrine/Tests/Mocks/NullSqlWalker.php b/tests/Doctrine/Tests/Mocks/NullSqlWalker.php index 9d54e703547..6ad9486e5f2 100644 --- a/tests/Doctrine/Tests/Mocks/NullSqlWalker.php +++ b/tests/Doctrine/Tests/Mocks/NullSqlWalker.php @@ -4,6 +4,9 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\AST\UpdateStatement; +use Doctrine\ORM\Query\AST\DeleteStatement; use Doctrine\DBAL\Connection; use Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; @@ -14,17 +17,17 @@ */ class NullSqlWalker extends SqlWalker { - public function walkSelectStatement(AST\SelectStatement $AST): string + public function walkSelectStatement(SelectStatement $AST): string { return ''; } - public function walkUpdateStatement(AST\UpdateStatement $AST): string + public function walkUpdateStatement(UpdateStatement $AST): string { return ''; } - public function walkDeleteStatement(AST\DeleteStatement $AST): string + public function walkDeleteStatement(DeleteStatement $AST): string { return ''; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php b/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php index a2bdce4e308..f8c45522ac5 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php @@ -6,22 +6,7 @@ class CmsAddressDTO { - /** @var string|null */ - public $country; - - /** @var string|null */ - public $city; - - /** @var string|null */ - public $zip; - - public function __construct( - ?string $country = null, - ?string $city = null, - ?string $zip = null - ) { - $this->country = $country; - $this->city = $city; - $this->zip = $zip; + public function __construct(public ?string $country = null, public ?string $city = null, public ?string $zip = null) + { } } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsComment.php b/tests/Doctrine/Tests/Models/CMS/CmsComment.php index cce79925ada..3d1eb331904 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsComment.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsComment.php @@ -16,7 +16,7 @@ * @Entity * @Table(name="cms_comments") */ -class CmsComment +class CmsComment implements \Stringable { /** * @var int diff --git a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php b/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php index e79fd075b8f..536231b1f1b 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php @@ -21,25 +21,22 @@ class CmsEmployee { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column */ - private $name; + private string $name; /** - * @var CmsEmployee * @OneToOne(targetEntity="CmsEmployee") * @JoinColumn(name="spouse_id", referencedColumnName="id") */ - private $spouse; + private \Doctrine\Tests\Models\CMS\CmsEmployee $spouse; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php b/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php index 41d171407a1..341a6bb70c1 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php @@ -6,27 +6,7 @@ class CmsUserDTO { - /** @var string|null */ - public $name; - - /** @var string|null */ - public $email; - - /** @var string|null */ - public $address; - - /** @var int|null */ - public $phonenumbers; - - public function __construct( - ?string $name = null, - ?string $email = null, - ?string $address = null, - ?int $phonenumbers = null - ) { - $this->name = $name; - $this->email = $email; - $this->address = $address; - $this->phonenumbers = $phonenumbers; + public function __construct(public ?string $name = null, public ?string $email = null, public ?string $address = null, public ?int $phonenumbers = null) + { } } diff --git a/tests/Doctrine/Tests/Models/Cache/Action.php b/tests/Doctrine/Tests/Models/Cache/Action.php index 1ea4eb91538..8e350cd94d4 100644 --- a/tests/Doctrine/Tests/Models/Cache/Action.php +++ b/tests/Doctrine/Tests/Models/Cache/Action.php @@ -19,23 +19,22 @@ */ class Action { - /** - * @var string - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") - */ - public $name; - /** * @psalm-var Collection * @OneToMany(targetEntity="Token", cascade={"persist", "remove"}, mappedBy="action") */ public $tokens; - public function __construct($name) + /** + * @param string $name + */ + public function __construct(/** + * @Id + * @Column(type="string", length=255) + * @GeneratedValue(strategy="NONE") + */ + public $name) { - $this->name = $name; $this->tokens = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Address.php b/tests/Doctrine/Tests/Models/Cache/Address.php index bfd8cbce90a..29049224e6f 100644 --- a/tests/Doctrine/Tests/Models/Cache/Address.php +++ b/tests/Doctrine/Tests/Models/Cache/Address.php @@ -33,14 +33,12 @@ class Address */ public $person; - /** - * @var string - * @Column - */ - public $location; - - public function __construct(string $location) + public function __construct( + /** + * @Column + */ + public string $location + ) { - $this->location = $location; } } diff --git a/tests/Doctrine/Tests/Models/Cache/Attraction.php b/tests/Doctrine/Tests/Models/Cache/Attraction.php index 737af6ac8c2..5ca2bbb7b30 100644 --- a/tests/Doctrine/Tests/Models/Cache/Attraction.php +++ b/tests/Doctrine/Tests/Models/Cache/Attraction.php @@ -39,20 +39,6 @@ abstract class Attraction */ protected $id; - /** - * @var string - * @Column(unique=true) - */ - protected $name; - - /** - * @var City - * @Cache - * @ManyToOne(targetEntity="City", inversedBy="attractions") - * @JoinColumn(name="city_id", referencedColumnName="id") - */ - protected $city; - /** * @psalm-var Collection * @Cache @@ -60,10 +46,16 @@ abstract class Attraction */ protected $infos; - public function __construct(string $name, City $city) + public function __construct(/** + * @Column(unique=true) + */ + protected string $name, /** + * @Cache + * @ManyToOne(targetEntity="City", inversedBy="attractions") + * @JoinColumn(name="city_id", referencedColumnName="id") + */ + protected City $city) { - $this->name = $name; - $this->city = $city; $this->infos = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/City.php b/tests/Doctrine/Tests/Models/Cache/City.php index 1734aca1a49..61f76126e69 100644 --- a/tests/Doctrine/Tests/Models/Cache/City.php +++ b/tests/Doctrine/Tests/Models/Cache/City.php @@ -37,24 +37,6 @@ class City #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')] protected $id; - /** - * @var string - * @Column(unique=true) - */ - #[ORM\Column(unique: true)] - protected $name; - - /** - * @var State|null - * @Cache - * @ManyToOne(targetEntity="State", inversedBy="cities") - * @JoinColumn(name="state_id", referencedColumnName="id") - */ - #[ORM\Cache] - #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'citities')] - #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] - protected $state; - /** * @var Collection * @ManyToMany(targetEntity="Travel", mappedBy="visitedCities") @@ -72,10 +54,16 @@ class City #[ORM\OneToMany(targetEntity: 'Attraction', mappedBy: 'city')] public $attractions; - public function __construct(string $name, ?State $state = null) + public function __construct(/** + * @Column(unique=true) + */ + #[ORM\Column(unique: true)] protected string $name, /** + * @Cache + * @ManyToOne(targetEntity="State", inversedBy="cities") + * @JoinColumn(name="state_id", referencedColumnName="id") + */ + #[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'citities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] protected ?State $state = null) { - $this->name = $name; - $this->state = $state; $this->travels = new ArrayCollection(); $this->attractions = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Client.php b/tests/Doctrine/Tests/Models/Cache/Client.php index 1e763eadd2a..5c947a3afae 100644 --- a/tests/Doctrine/Tests/Models/Cache/Client.php +++ b/tests/Doctrine/Tests/Models/Cache/Client.php @@ -25,13 +25,14 @@ class Client public $id; /** - * @var string - * @Column(unique=true) + * @param string $name */ - public $name; - - public function __construct($name) + public function __construct( + /** + * @Column(unique=true) + */ + public $name + ) { - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php index 1999dacec83..795e058abfe 100644 --- a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php +++ b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php @@ -21,38 +21,26 @@ class ComplexAction { /** - * @var string - * @Column + * @psalm-var Collection + * @OneToMany(targetEntity="Token", cascade={"persist", "remove"}, mappedBy="complexAction") */ - public $name; + public $tokens; - /** - * @var Action + public function __construct(/** * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) * @JoinColumn(name="action1_name", referencedColumnName="name") */ - public $action1; - - /** - * @var Action + public Action $action1, /** * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) * @JoinColumn(name="action2_name", referencedColumnName="name") */ - public $action2; - - /** - * @psalm-var Collection - * @OneToMany(targetEntity="Token", cascade={"persist", "remove"}, mappedBy="complexAction") + public Action $action2, /** + * @Column */ - public $tokens; - - public function __construct(Action $action1, Action $action2, string $name) + public string $name) { - $this->name = $name; - $this->action1 = $action1; - $this->action2 = $action2; $this->tokens = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Country.php b/tests/Doctrine/Tests/Models/Cache/Country.php index 0a28060b69a..5235b3b9bb6 100644 --- a/tests/Doctrine/Tests/Models/Cache/Country.php +++ b/tests/Doctrine/Tests/Models/Cache/Country.php @@ -26,15 +26,13 @@ class Country */ protected $id; - /** - * @var string - * @Column(unique=true) - */ - protected $name; - - public function __construct(string $name) + public function __construct( + /** + * @Column(unique=true) + */ + protected string $name + ) { - $this->name = $name; } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Cache/Flight.php b/tests/Doctrine/Tests/Models/Cache/Flight.php index fcdd9675ca0..95afffe7b4d 100644 --- a/tests/Doctrine/Tests/Models/Cache/Flight.php +++ b/tests/Doctrine/Tests/Models/Cache/Flight.php @@ -21,33 +21,25 @@ class Flight { /** - * @var City + * @var DateTime + * @Column(type="date") + */ + protected $departure; + + public function __construct(/** * @Id * @Cache * @ManyToOne(targetEntity="City") * @JoinColumn(name="leaving_from_city_id", referencedColumnName="id") */ - protected $leavingFrom; - - /** - * @var City + protected City $leavingFrom, /** * @Id * @Cache * @ManyToOne(targetEntity="City") * @JoinColumn(name="going_to_city_id", referencedColumnName="id") */ - protected $goingTo; - - /** - * @var DateTime - * @Column(type="date") - */ - protected $departure; - - public function __construct(City $leavingFrom, City $goingTo) + protected City $goingTo) { - $this->goingTo = $goingTo; - $this->leavingFrom = $leavingFrom; $this->departure = new DateTime(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Login.php b/tests/Doctrine/Tests/Models/Cache/Login.php index 4c0fc375b6c..5ccde755320 100644 --- a/tests/Doctrine/Tests/Models/Cache/Login.php +++ b/tests/Doctrine/Tests/Models/Cache/Login.php @@ -26,12 +26,6 @@ class Login */ public $id; - /** - * @var string - * @Column - */ - public $name; - /** * @var Token * @ManyToOne(targetEntity="Token", cascade={"persist", "remove"}, inversedBy="logins") @@ -39,9 +33,13 @@ class Login */ public $token; - public function __construct(string $name) + public function __construct( + /** + * @Column + */ + public string $name + ) { - $this->name = $name; } public function getToken(): Token diff --git a/tests/Doctrine/Tests/Models/Cache/Person.php b/tests/Doctrine/Tests/Models/Cache/Person.php index a31be87e057..26241e4dff6 100644 --- a/tests/Doctrine/Tests/Models/Cache/Person.php +++ b/tests/Doctrine/Tests/Models/Cache/Person.php @@ -27,20 +27,18 @@ class Person */ public $id; - /** - * @var string - * @Column(unique=true) - */ - public $name; - /** * @var Address * @OneToOne(targetEntity="Address", mappedBy="person") */ public $address; - public function __construct(string $name) + public function __construct( + /** + * @Column(unique=true) + */ + public string $name + ) { - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/Models/Cache/State.php b/tests/Doctrine/Tests/Models/Cache/State.php index 1e63407c22c..1d9549ffadf 100644 --- a/tests/Doctrine/Tests/Models/Cache/State.php +++ b/tests/Doctrine/Tests/Models/Cache/State.php @@ -31,20 +31,6 @@ class State */ protected $id; - /** - * @var string - * @Column(unique=true) - */ - protected $name; - - /** - * @var Country|null - * @Cache - * @ManyToOne(targetEntity="Country") - * @JoinColumn(name="country_id", referencedColumnName="id") - */ - protected $country; - /** * @psalm-var Collection * @Cache("NONSTRICT_READ_WRITE") @@ -52,10 +38,16 @@ class State */ protected $cities; - public function __construct(string $name, ?Country $country = null) + public function __construct(/** + * @Column(unique=true) + */ + protected string $name, /** + * @Cache + * @ManyToOne(targetEntity="Country") + * @JoinColumn(name="country_id", referencedColumnName="id") + */ + protected ?Country $country = null) { - $this->name = $name; - $this->country = $country; $this->cities = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Token.php b/tests/Doctrine/Tests/Models/Cache/Token.php index 048ebfeaba6..3fcaec6e1b1 100644 --- a/tests/Doctrine/Tests/Models/Cache/Token.php +++ b/tests/Doctrine/Tests/Models/Cache/Token.php @@ -28,25 +28,12 @@ */ class Token { - /** - * @var string - * @Id - * @Column(type="string", length=255) - */ - public $token; - /** * @var DateTime * @Column(type="date") */ public $expiresAt; - /** - * @var Client|null - * @OneToOne(targetEntity="Client") - */ - public $client; - /** * @psalm-var Collection * @OneToMany(targetEntity="Login", cascade={"persist", "remove"}, mappedBy="token") @@ -70,11 +57,16 @@ class Token */ public $complexAction; - public function __construct(string $token, ?Client $client = null) + public function __construct(/** + * @Id + * @Column(type="string", length=255) + */ + public string $token, /** + * @OneToOne(targetEntity="Client") + */ + public ?Client $client = null) { $this->logins = new ArrayCollection(); - $this->token = $token; - $this->client = $client; $this->expiresAt = new DateTime(date('Y-m-d H:i:s', strtotime('+7 day'))); } diff --git a/tests/Doctrine/Tests/Models/Cache/Travel.php b/tests/Doctrine/Tests/Models/Cache/Travel.php index ce14324ec34..17a70ea05b4 100644 --- a/tests/Doctrine/Tests/Models/Cache/Travel.php +++ b/tests/Doctrine/Tests/Models/Cache/Travel.php @@ -39,14 +39,6 @@ class Travel */ protected $createdAt; - /** - * @var Traveler - * @Cache - * @ManyToOne(targetEntity="Traveler", inversedBy="travels") - * @JoinColumn(name="traveler_id", referencedColumnName="id") - */ - protected $traveler; - /** * @psalm-var Collection * @Cache @@ -62,9 +54,13 @@ class Travel */ public $visitedCities; - public function __construct(Traveler $traveler) + public function __construct(/** + * @Cache + * @ManyToOne(targetEntity="Traveler", inversedBy="travels") + * @JoinColumn(name="traveler_id", referencedColumnName="id") + */ + protected Traveler $traveler) { - $this->traveler = $traveler; $this->createdAt = new DateTime('now'); $this->visitedCities = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Traveler.php b/tests/Doctrine/Tests/Models/Cache/Traveler.php index 8d44f59e9e9..5d3e92dabcb 100644 --- a/tests/Doctrine/Tests/Models/Cache/Traveler.php +++ b/tests/Doctrine/Tests/Models/Cache/Traveler.php @@ -30,12 +30,6 @@ class Traveler */ protected $id; - /** - * @var string - * @Column - */ - protected $name; - /** * @psalm-var Collection * @Cache("NONSTRICT_READ_WRITE") @@ -50,9 +44,11 @@ class Traveler */ protected $profile; - public function __construct(string $name) + public function __construct(/** + * @Column + */ + protected string $name) { - $this->name = $name; $this->travels = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php index 0ea8719a7cd..2044582d65b 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php @@ -28,21 +28,18 @@ class TravelerProfile protected $id; /** - * @var string - * @Column(unique=true) - */ - private $name; - - /** - * @var TravelerProfileInfo * @OneToOne(targetEntity="TravelerProfileInfo", mappedBy="profile") * @Cache() */ - private $info; + private ?TravelerProfileInfo $info = null; - public function __construct(string $name) + public function __construct( + /** + * @Column(unique=true) + */ + private string $name + ) { - $this->name = $name; } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php index 6cec9795930..73feb4c7a3c 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php @@ -28,24 +28,19 @@ class TravelerProfileInfo */ protected $id; - /** - * @var string - * @Column(unique=true) - */ - private $description; - - /** - * @var TravelerProfile - * @Cache() - * @JoinColumn(name="profile_id", referencedColumnName="id") - * @OneToOne(targetEntity="TravelerProfile", inversedBy="info") - */ - private $profile; - - public function __construct(TravelerProfile $profile, string $description) + public function __construct( + /** + * @Cache() + * @JoinColumn(name="profile_id", referencedColumnName="id") + * @OneToOne(targetEntity="TravelerProfile", inversedBy="info") + */ + private TravelerProfile $profile, + /** + * @Column(unique=true) + */ + private string $description + ) { - $this->profile = $profile; - $this->description = $description; } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php b/tests/Doctrine/Tests/Models/Company/CompanyAuction.php index 10766f79710..131fbc26f99 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyAuction.php @@ -15,10 +15,9 @@ class CompanyAuction extends CompanyEvent { /** - * @var string * @Column(type="string", length=255) */ - private $data; + private ?string $data = null; public function setData(string $data): void { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyCar.php b/tests/Doctrine/Tests/Models/Company/CompanyCar.php index 2fb0f1e7b57..ed44fddb165 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyCar.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyCar.php @@ -17,22 +17,19 @@ class CompanyCar { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; - - /** - * @var string|null - * @Column(type="string", length=50) - */ - private $brand; - - public function __construct(?string $brand = null) + private int $id; + + public function __construct( + /** + * @Column(type="string", length=50) + */ + private ?string $brand = null + ) { - $this->brand = $brand; } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index aae6e88acc5..3a6c0e3486c 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -75,25 +75,22 @@ abstract class CompanyContract { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue] - private $id; + private int $id; /** - * @var CompanyEmployee * @ManyToOne(targetEntity="CompanyEmployee", inversedBy="soldContracts") */ - private $salesPerson; + private ?CompanyEmployee $salesPerson = null; /** * @Column(type="boolean") - * @var bool */ - private $completed = false; + private bool $completed = false; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php index c1d1d87690a..67eb5aba83f 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php @@ -19,22 +19,19 @@ class CompanyEmployee extends CompanyPerson { /** - * @var int * @Column(type="integer") */ - private $salary; + private ?int $salary = null; /** - * @var string * @Column(type="string", length=255) */ - private $department; + private ?string $department = null; /** - * @var DateTime|null * @Column(type="datetime", nullable=true) */ - private $startDate; + private ?\DateTime $startDate = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php b/tests/Doctrine/Tests/Models/Company/CompanyEvent.php index e107a0eccbe..9e0e892c266 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEvent.php @@ -25,19 +25,17 @@ abstract class CompanyEvent { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var CompanyOrganization - * @ManyToOne(targetEntity="CompanyOrganization", inversedBy="events", cascade={"persist"}) - * @JoinColumn(name="org_id", referencedColumnName="id") - */ - private $organization; + * @ManyToOne(targetEntity="CompanyOrganization", inversedBy="events", cascade={"persist"}) + * @JoinColumn(name="org_id", referencedColumnName="id") + */ + private ?CompanyOrganization $organization = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php index 13ef3b53f8d..fd8b1a3f1e8 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php @@ -17,9 +17,8 @@ class CompanyFixContract extends CompanyContract { /** * @Column(type="integer") - * @var int */ - private $fixPrice = 0; + private int $fixPrice = 0; public function calculatePrice(): int { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index d258fff0bd2..a054b4f1f42 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -63,15 +63,13 @@ class CompanyFlexContract extends CompanyContract /** * @Column(type="integer") - * @var int */ - private $hoursWorked = 0; + private int $hoursWorked = 0; /** - * @var int * @Column(type="integer") */ - private $pricePerHour = 0; + private int $pricePerHour = 0; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php index 53e8595c179..f655a483094 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -23,9 +23,8 @@ class CompanyFlexUltraContract extends CompanyFlexContract { /** * @Column(type="integer") - * @var int */ - private $maxPrice = 0; + private int $maxPrice = 0; public function calculatePrice(): int { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/tests/Doctrine/Tests/Models/Company/CompanyManager.php index c617e9ab3b2..ba45a5be73e 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyManager.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyManager.php @@ -19,17 +19,15 @@ class CompanyManager extends CompanyEmployee { /** - * @var string * @Column(type="string", length=250) */ - private $title; + private ?string $title = null; /** - * @var CompanyCar * @OneToOne(targetEntity="CompanyCar", cascade={"persist"}) * @JoinColumn(name="car_id", referencedColumnName="id") */ - private $car; + private ?CompanyCar $car = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php b/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php index 610326fac7f..dcf24ea2497 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php @@ -21,12 +21,11 @@ class CompanyOrganization { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** * @psalm-var Collection @@ -54,11 +53,10 @@ public function addEvent(CompanyEvent $event): void } /** - * @var CompanyEvent|null * @OneToOne(targetEntity="CompanyEvent", cascade={"persist"}) * @JoinColumn(name="main_event_id", referencedColumnName="id", nullable=true) */ - private $mainevent; + private ?CompanyEvent $mainevent = null; public function getMainEvent(): ?CompanyEvent { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php index 870547e1f6f..37d64a8d3a6 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php @@ -55,25 +55,22 @@ class CompanyPerson { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column */ - private $name; + private ?string $name = null; /** - * @var CompanyPerson|null * @OneToOne(targetEntity="CompanyPerson") * @JoinColumn(name="spouse_id", referencedColumnName="id", onDelete="CASCADE") */ - private $spouse; + private ?\Doctrine\Tests\Models\Company\CompanyPerson $spouse = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php index 105f841cc12..20893eabbea 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php @@ -15,10 +15,9 @@ class CompanyRaffle extends CompanyEvent { /** - * @var string * @Column */ - private $data; + private ?string $data = null; public function setData(string $data): void { diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php index 64faca06ee0..a0be32bab79 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php @@ -20,9 +20,8 @@ class JoinedChildClass extends JoinedRootClass public $extension = 'ext'; /** - * @var string * @Column(type="string", length=255) * @Id */ - private $additionalId = 'additional'; + private string $additionalId = 'additional'; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php index 2696191bcec..bbfcc43b5f3 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php @@ -22,9 +22,8 @@ class JoinedDerivedChildClass extends JoinedDerivedRootClass public $extension = 'ext'; /** - * @var string * @Column(type="string", length=255) * @Id */ - private $additionalId = 'additional'; + private string $additionalId = 'additional'; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php index 4670d8fffc5..3d8fca8a588 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php @@ -20,9 +20,8 @@ class SingleChildClass extends SingleRootClass public $extension = 'ext'; /** - * @var string * @Column(type="string", length=255) * @Id */ - private $additionalId = 'additional'; + private string $additionalId = 'additional'; } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php index 3c3f89ce4f4..046460b3d8f 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php @@ -17,22 +17,17 @@ */ class CustomIdObjectTypeChild { - /** - * @Id - * @Column(type="CustomIdObject", length=255) - * @var CustomIdObject - */ - public $id; - - /** - * @var CustomIdObjectTypeParent - * @ManyToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent", inversedBy="children") - */ - public $parent; - - public function __construct(CustomIdObject $id, CustomIdObjectTypeParent $parent) + public function __construct( + /** + * @Id + * @Column(type="CustomIdObject", length=255) + */ + public CustomIdObject $id, + /** + * @ManyToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent", inversedBy="children") + */ + public CustomIdObjectTypeParent $parent + ) { - $this->id = $id; - $this->parent = $parent; } } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php index 2e32f5e714d..270c9a0c3c1 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php @@ -19,22 +19,18 @@ */ class CustomIdObjectTypeParent { - /** - * @Id - * @Column(type="CustomIdObject", length=255) - * @var CustomIdObject - */ - public $id; - /** * @psalm-var Collection * @OneToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild", cascade={"persist", "remove"}, mappedBy="parent") */ public $children; - public function __construct(CustomIdObject $id) + public function __construct(/** + * @Id + * @Column(type="CustomIdObject", length=255) + */ + public CustomIdObject $id) { - $this->id = $id; $this->children = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php index 3759c097f03..eea09467ad5 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php @@ -18,48 +18,36 @@ class DDC117ApproveChanges { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; - - /** - * @var DDC117ArticleDetails - * @ManyToOne(targetEntity="DDC117ArticleDetails") - * @JoinColumn(name="details_id", referencedColumnName="article_id") - */ - private $articleDetails; - - /** - * @var DDC117Reference - * @ManyToOne(targetEntity="DDC117Reference") - * @JoinColumns({ - * @JoinColumn(name="source_id", referencedColumnName="source_id"), - * @JoinColumn(name="target_id", referencedColumnName="target_id") - * }) - */ - private $reference; - - /** - * @var DDC117Translation - * @ManyToOne(targetEntity="DDC117Translation") - * @JoinColumns({ - * @JoinColumn(name="trans_article_id", referencedColumnName="article_id"), - * @JoinColumn(name="trans_language", referencedColumnName="language") - * }) - */ - private $translation; + private int $id; public function __construct( - DDC117ArticleDetails $details, - DDC117Reference $reference, - DDC117Translation $translation - ) { - $this->articleDetails = $details; - $this->reference = $reference; - $this->translation = $translation; + /** + * @ManyToOne(targetEntity="DDC117ArticleDetails") + * @JoinColumn(name="details_id", referencedColumnName="article_id") + */ + private DDC117ArticleDetails $articleDetails, + /** + * @ManyToOne(targetEntity="DDC117Reference") + * @JoinColumns({ + * @JoinColumn(name="source_id", referencedColumnName="source_id"), + * @JoinColumn(name="target_id", referencedColumnName="target_id") + * }) + */ + private DDC117Reference $reference, + /** + * @ManyToOne(targetEntity="DDC117Translation") + * @JoinColumns({ + * @JoinColumn(name="trans_article_id", referencedColumnName="article_id"), + * @JoinColumn(name="trans_language", referencedColumnName="language") + * }) + */ + private DDC117Translation $translation + ) + { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php index 64751b08e41..bb82d99dc6d 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php @@ -19,18 +19,11 @@ class DDC117Article { /** - * @var int * @Id * @Column(type="integer", name="article_id") * @GeneratedValue */ - private $id; - - /** - * @var string - * @Column - */ - private $title; + private int $id; /** * @psalm-var Collection @@ -39,10 +32,9 @@ class DDC117Article private $references; /** - * @var DDC117ArticleDetails * @OneToOne(targetEntity="DDC117ArticleDetails", mappedBy="article", cascade={"persist", "remove"}) */ - private $details; + private ?DDC117ArticleDetails $details = null; /** * @psalm-var Collection @@ -54,11 +46,13 @@ class DDC117Article * @var Collection * @OneToMany(targetEntity="DDC117Link", mappedBy="source", indexBy="target_id", cascade={"persist", "remove"}) */ - private $links; + private Collection $links; - public function __construct(string $title) + public function __construct(/** + * @Column + */ + private string $title) { - $this->title = $title; $this->references = new ArrayCollection(); $this->translations = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php index 1de568511a1..dc1ee40bc47 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php @@ -16,22 +16,17 @@ class DDC117ArticleDetails { /** - * @var DDC117Article + * @Column(type="text") + */ + private string $text; + + public function __construct(/** * @Id * @OneToOne(targetEntity="DDC117Article", inversedBy="details") * @JoinColumn(name="article_id", referencedColumnName="article_id") */ - private $article; - - /** - * @var string - * @Column(type="text") - */ - private $text; - - public function __construct(DDC117Article $article, string $text) + private DDC117Article $article, string $text) { - $this->article = $article; $article->setDetails($this); $this->update($text); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php index 94c4709f05b..4db9f284ffb 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php @@ -29,12 +29,6 @@ class DDC117Editor */ public $id; - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $name; - /** * @psalm-var Collection * @ManyToMany(targetEntity="DDC117Translation", inversedBy="reviewedByEditors") @@ -60,9 +54,11 @@ class DDC117Editor */ public $lastTranslation; - public function __construct(?string $name = '') + public function __construct(/** + * @Column(type="string", length=255) + */ + public ?string $name = '') { - $this->name = $name; $this->reviewingTranslations = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php index 7e7fb65f4c6..200a3294ac1 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php @@ -17,24 +17,24 @@ class DDC117Link { /** - * @var DDC117Article - * @Id - * @ManyToOne(targetEntity="DDC117Article", inversedBy="links") - * @JoinColumn(name="source_id", referencedColumnName="article_id") + * @param DDC117Article $source + * @param DDC117Article $target */ - public $source; - - /** - * @var DDC117Article - * @Id - * @ManyToOne(targetEntity="DDC117Article") - * @JoinColumn(name="target_id", referencedColumnName="article_id") - */ - public $target; - - public function __construct($source, $target, $description) + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="DDC117Article", inversedBy="links") + * @JoinColumn(name="source_id", referencedColumnName="article_id") + */ + public $source, + /** + * @Id + * @ManyToOne(targetEntity="DDC117Article") + * @JoinColumn(name="target_id", referencedColumnName="article_id") + */ + public $target, + $description + ) { - $this->source = $source; - $this->target = $target; } } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php index 7bbf89a480f..928cebe5c8f 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php @@ -17,41 +17,34 @@ class DDC117Reference { /** - * @var DDC117Article * @Id * @ManyToOne(targetEntity="DDC117Article", inversedBy="references") * @JoinColumn(name="source_id", referencedColumnName="article_id") */ - private $source; + private DDC117Article $source; /** - * @var DDC117Article * @Id * @ManyToOne(targetEntity="DDC117Article") * @JoinColumn(name="target_id", referencedColumnName="article_id") */ - private $target; + private DDC117Article $target; /** - * @var string - * @Column(type="string", length=255) - */ - private $description; - - /** - * @var DateTime * @Column(type="datetime") */ - private $created; + private \DateTime $created; - public function __construct(DDC117Article $source, DDC117Article $target, string $description) + public function __construct(DDC117Article $source, DDC117Article $target, /** + * @Column(type="string", length=255) + */ + private string $description) { $source->addReference($this); $target->addReference($this); $this->source = $source; $this->target = $target; - $this->description = $description; $this->created = new DateTime('now'); } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php index 7e9a40090dd..1d20221c0b3 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php @@ -19,27 +19,6 @@ */ class DDC117Translation { - /** - * @var DDC117Article - * @Id - * @ManyToOne(targetEntity="DDC117Article", inversedBy="translations") - * @JoinColumn(name="article_id", referencedColumnName="article_id") - */ - private $article; - - /** - * @var string - * @Id - * @Column(type="string", length=255) - */ - private $language; - - /** - * @var string - * @Column(type="string", length=255) - */ - private $title; - /** * @var Collection * @ManyToMany(targetEntity="DDC117Editor", mappedBy="reviewingTranslations") @@ -52,11 +31,20 @@ class DDC117Translation */ public $lastTranslatedBy; - public function __construct(DDC117Article $article, string $language, string $title) + public function __construct(/** + * @Id + * @ManyToOne(targetEntity="DDC117Article", inversedBy="translations") + * @JoinColumn(name="article_id", referencedColumnName="article_id") + */ + private DDC117Article $article, /** + * @Id + * @Column(type="string", length=255) + */ + private string $language, /** + * @Column(type="string", length=255) + */ + private string $title) { - $this->article = $article; - $this->language = $language; - $this->title = $title; $this->reviewedByEditors = new ArrayCollection(); $this->lastTranslatedBy = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php index 63c8217d2c4..1743aba292b 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php @@ -14,9 +14,8 @@ class DDC1872Bar { /** - * @var string * @Id * @Column(type="string", length=255) */ - private $id; + private string $id; } diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php index 2b7515bcbdd..52b5d35cbc3 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php @@ -18,18 +18,16 @@ class DDC2372Address { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255) */ - private $street; + private ?string $street = null; /** * @var User diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php index c2ec10e6a47..e640bd7c061 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php @@ -20,18 +20,16 @@ class DDC2372User use DDC2372AddressAndAccessors; /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=50) */ - private $name; + private ?string $name = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php index 5f5bf866bfe..808462793c1 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php @@ -19,20 +19,12 @@ class DDC3579Group { /** - * @var int * @GeneratedValue * @Id * @Column(type="integer") */ #[Id, GeneratedValue, Column(type: 'integer')] - private $id; - - /** - * @var string|null - * @Column - */ - #[Column] - private $name; + private int $id; /** * @psalm-var Collection @@ -41,9 +33,11 @@ class DDC3579Group #[ManyToMany(targetEntity: DDC3579Admin::class, mappedBy: 'groups')] private $admins; - public function __construct(?string $name = null) + public function __construct(/** + * @Column + */ + #[Column] private ?string $name = null) { - $this->name = $name; $this->admins = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php index 4d6c86a5b6e..46beb2dbe72 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php @@ -27,13 +27,6 @@ class DDC3579User #[Id, GeneratedValue, Column(type: 'integer', name: 'user_id', length: 150)] protected $id; - /** - * @var string - * @Column(name="user_name", nullable=true, unique=false, length=250) - */ - #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] - protected $name; - /** * @var ArrayCollection * @ManyToMany(targetEntity="DDC3579Group") @@ -41,9 +34,11 @@ class DDC3579User #[ManyToMany(targetEntity: DDC3579Group::class)] protected $groups; - public function __construct(?string $name = null) + public function __construct(/** + * @Column(name="user_name", nullable=true, unique=false, length=250) + */ + #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected ?string $name = null) { - $this->name = $name; $this->groups = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php index 7e3916d05e2..1ff4fcbf1da 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php @@ -16,10 +16,9 @@ class DDC3597Image extends DDC3597Media { /** - * @var DDC3597Dimension * @Embedded(class = "Doctrine\Tests\Models\DDC3597\Embeddable\DDC3597Dimension", columnPrefix = false) */ - private $dimension; + private DDC3597Dimension $dimension; public function __construct(string $distributionHash) { diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php index 437cf869f3d..9c571cd642f 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php @@ -15,26 +15,25 @@ abstract class DDC3597Media extends DDC3597Root { /** - * @var string * @Column */ - private $distributionHash; + private int $size = 0; /** - * @var int * @Column */ - private $size = 0; + private ?string $format = null; /** - * @var string - * @Column + * @param string $distributionHash */ - private $format; - - public function __construct($distributionHash) + public function __construct( + /** + * @Column + */ + private $distributionHash + ) { - $this->distributionHash = $distributionHash; } public function getDistributionHash(): string diff --git a/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php b/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php index d5f36c9e268..76484786138 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php +++ b/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php @@ -15,16 +15,14 @@ class DDC3597Dimension { /** - * @var int * @Column(type="integer", name="width") */ - private $width; + private int $width; /** - * @var int * @Column(type="integer", name="height") */ - private $height; + private int $height; public function __construct($width = 0, $height = 0) { diff --git a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php index cdca9cd2fe4..e45e36ba9a1 100644 --- a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php +++ b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php @@ -8,11 +8,9 @@ class DDC3711EntityB { - /** @var int */ - private $id1; + private ?int $id1 = null; - /** @var int */ - private $id2; + private ?int $id2 = null; /** @var ArrayCollection */ private $entityA; diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php index 57d06c417e1..248f905b95b 100644 --- a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php +++ b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php @@ -13,8 +13,7 @@ class DDC4006User { /** - * @var DDC4006UserId * @Embedded(class="DDC4006UserId") */ - private $id; + private DDC4006UserId $id; } diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php b/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php index e9d85626cc8..82bf3acecc7 100644 --- a/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php +++ b/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php @@ -15,10 +15,9 @@ class DDC4006UserId { /** - * @var int * @Id * @GeneratedValue("IDENTITY") * @Column(type="integer") */ - private $id; + private int $id; } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php index e0faf5079e4..a1b8fa2b726 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php @@ -15,47 +15,31 @@ class DDC964Address { /** - * @var int * @GeneratedValue * @Id * @Column(type="integer") */ - private $id; - - /** - * @var string|null - * @Column - */ - private $country; - - /** - * @var string|null - * @Column - */ - private $zip; - - /** - * @var string|null - * @Column - */ - private $city; - - /** - * @var string|null - * @Column - */ - private $street; + private int $id; public function __construct( - ?string $zip = null, - ?string $country = null, - ?string $city = null, - ?string $street = null - ) { - $this->zip = $zip; - $this->country = $country; - $this->city = $city; - $this->street = $street; + /** + * @Column + */ + private ?string $zip = null, + /** + * @Column + */ + private ?string $country = null, + /** + * @Column + */ + private ?string $city = null, + /** + * @Column + */ + private ?string $street = null + ) + { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php index 154d834a5d1..bf76c006d7b 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php @@ -17,18 +17,11 @@ class DDC964Group { /** - * @var int * @GeneratedValue * @Id * @Column(type="integer") */ - private $id; - - /** - * @var string|null - * @Column - */ - private $name; + private int $id; /** * @psalm-var ArrayCollection @@ -36,9 +29,14 @@ class DDC964Group */ private $users; - public function __construct($name = null) + /** + * @param string|null $name + */ + public function __construct(/** + * @Column + */ + private ?string $name = null) { - $this->name = $name; $this->users = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php index f3b477c96ca..3a41af3925a 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php @@ -32,13 +32,6 @@ class DDC964User #[Id, GeneratedValue, Column(type: 'integer', name: 'user_id', length: 150)] protected $id; - /** - * @var string|null - * @Column(name="user_name", nullable=true, unique=false, length=250) - */ - #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] - protected $name; - /** * @psalm-var Collection * @ManyToMany(targetEntity="DDC964Group", inversedBy="users", cascade={"persist", "merge", "detach"}) @@ -62,9 +55,11 @@ class DDC964User #[JoinColumn(name: 'address_id', referencedColumnName: 'id')] protected $address; - public function __construct(?string $name = null) + public function __construct(/** + * @Column(name="user_name", nullable=true, unique=false, length=250) + */ + #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected ?string $name = null) { - $this->name = $name; $this->groups = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php index 9aa09b76e84..2f4b664bbc8 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php @@ -16,18 +16,11 @@ abstract class AbstractContentItem { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; - - /** - * @var Directory - * @ManyToOne(targetEntity="Directory") - */ - protected $parentDirectory; + private int $id; /** * @var string @@ -37,10 +30,8 @@ abstract class AbstractContentItem /** * This field is transient and private on purpose - * - * @var bool */ - private $nodeIsLoaded = false; + private bool $nodeIsLoaded = false; /** * This field is transient on purpose @@ -49,9 +40,13 @@ abstract class AbstractContentItem */ public static $fileSystem; - public function __construct(?Directory $parentDir = null) + public function __construct( + /** + * @ManyToOne(targetEntity="Directory") + */ + protected ?Directory $parentDirectory = null + ) { - $this->parentDirectory = $parentDir; } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php index 2e328770e05..25b442d3943 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php @@ -26,25 +26,22 @@ class ECommerceCart { /** - * @var int * @Column(type="integer") * @Id * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column(length=50, nullable=true) */ - private $payment; + private ?string $payment = null; /** - * @var ECommerceCustomer|null * @OneToOne(targetEntity="ECommerceCustomer", inversedBy="cart") * @JoinColumn(name="customer_id", referencedColumnName="id") */ - private $customer; + private ?ECommerceCustomer $customer = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php index 9bbaa68ea52..ad8538ead17 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php @@ -26,18 +26,16 @@ class ECommerceCategory { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=50) */ - private $name; + private ?string $name = null; /** * @psalm-var Collection @@ -52,11 +50,10 @@ class ECommerceCategory private $children; /** - * @var ECommerceCategory * @ManyToOne(targetEntity="ECommerceCategory", inversedBy="children") * @JoinColumn(name="parent_id", referencedColumnName="id") */ - private $parent; + private ?\Doctrine\Tests\Models\ECommerce\ECommerceCategory $parent = null; public function __construct() { diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php index b40284083af..14031d8cf03 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php @@ -22,35 +22,31 @@ class ECommerceCustomer { /** - * @var int * @Column(type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=50) */ - private $name; + private ?string $name = null; /** - * @var ECommerceCart|null * @OneToOne(targetEntity="ECommerceCart", mappedBy="customer", cascade={"persist"}) */ - private $cart; + private ?ECommerceCart $cart = null; /** * Example of a one-one self referential association. A mentor can follow * only one customer at the time, while a customer can choose only one * mentor. Not properly appropriate but it works. * - * @var ECommerceCustomer|null * @OneToOne(targetEntity="ECommerceCustomer", cascade={"persist"}, fetch="EAGER") * @JoinColumn(name="mentor_id", referencedColumnName="id") */ - private $mentor; + private ?\Doctrine\Tests\Models\ECommerce\ECommerceCustomer $mentor = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php index 7c6624b4f72..454d177e642 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php @@ -21,25 +21,22 @@ class ECommerceFeature { /** - * @var int * @Column(type="integer") * @Id * @GeneratedValue */ - private $id; + private int $id; /** - * @var string|null * @Column(length=50) */ - private $description; + private ?string $description = null; /** - * @var ECommerceProduct|null * @ManyToOne(targetEntity="ECommerceProduct", inversedBy="features") * @JoinColumn(name="product_id", referencedColumnName="id") */ - private $product; + private ?ECommerceProduct $product = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php index e0bfb5be76e..d697776c186 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php @@ -28,25 +28,22 @@ class ECommerceProduct { /** - * @var int * @Column(type="integer") * @Id * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=50, nullable=true) */ - private $name; + private ?string $name = null; /** - * @var ECommerceShipping|null * @OneToOne(targetEntity="ECommerceShipping", cascade={"persist"}) * @JoinColumn(name="shipping_id", referencedColumnName="id") */ - private $shipping; + private ?ECommerceShipping $shipping = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php index 70a571dff28..371668bccda 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php @@ -20,18 +20,16 @@ class ECommerceShipping { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var int|string * @Column(type="integer") */ - private $days; + private int|string|null $days = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php b/tests/Doctrine/Tests/Models/Forum/ForumCategory.php index 781fd65cb2d..41871f1fe91 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumCategory.php @@ -18,11 +18,10 @@ class ForumCategory { /** - * @var int * @Column(type="integer") * @Id */ - private $id; + private int $id; /** * @var int diff --git a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php index 906a7a64355..591fa909a87 100644 --- a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php +++ b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php @@ -24,14 +24,12 @@ class NonAlphaColumnsEntity */ public $id; - /** - * @var string - * @Column(type="string", length=255, name="`simple-entity-value`") - */ - public $value; - - public function __construct(string $value) + public function __construct( + /** + * @Column(type="string", length=255, name="`simple-entity-value`") + */ + public string $value + ) { - $this->value = $value; } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php index 633e312ac95..1ace996d3f4 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php @@ -21,23 +21,6 @@ */ class Admin1 { - /** - * @var int - * @Id - * @Column(type="integer", length=25) - * @GeneratedValue(strategy="NONE") - */ - public $id; - - /** - * @var Country - * @Id - * @ManyToOne(targetEntity="Country") - * @JoinColumn(name="country", referencedColumnName="id") - * @Cache - */ - public $country; - /** * @psalm-var Collection * @OneToMany(targetEntity="Admin1AlternateName", mappedBy="admin1") @@ -45,16 +28,25 @@ class Admin1 */ public $names = []; - /** - * @var string - * @Column(type="string", length=255); - */ - public $name; - - public function __construct(int $id, string $name, Country $country) + public function __construct( + /** + * @Id + * @Column(type="integer", length=25) + * @GeneratedValue(strategy="NONE") + */ + public int $id, + /** + * @Column(type="string", length=255); + */ + public string $name, + /** + * @Id + * @ManyToOne(targetEntity="Country") + * @JoinColumn(name="country", referencedColumnName="id") + * @Cache + */ + public Country $country + ) { - $this->id = $id; - $this->name = $name; - $this->country = $country; } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php index 5f93aa677a5..9e56ab0ef0b 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php @@ -21,35 +21,27 @@ */ class Admin1AlternateName { - /** - * @var int - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ - public $id; - - /** - * @var Admin1 - * @ManyToOne(targetEntity="Admin1", inversedBy="names") - * @JoinColumns({ - * @JoinColumn(name="admin1", referencedColumnName="id"), - * @JoinColumn(name="country", referencedColumnName="country") - * }) - * @Cache - */ - public $admin1; - - /** - * @var string - * @Column(type="string", length=255); - */ - public $name; - - public function __construct(int $id, string $name, Admin1 $admin1) + public function __construct( + /** + * @Id + * @Column(type="string", length=25) + * @GeneratedValue(strategy="NONE") + */ + public int $id, + /** + * @Column(type="string", length=255); + */ + public string $name, + /** + * @ManyToOne(targetEntity="Admin1", inversedBy="names") + * @JoinColumns({ + * @JoinColumn(name="admin1", referencedColumnName="id"), + * @JoinColumn(name="country", referencedColumnName="country") + * }) + * @Cache + */ + public Admin1 $admin1 + ) { - $this->id = $id; - $this->name = $name; - $this->admin1 = $admin1; } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/City.php b/tests/Doctrine/Tests/Models/GeoNames/City.php index 2fbc34edbc7..d7557fe0a89 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/City.php +++ b/tests/Doctrine/Tests/Models/GeoNames/City.php @@ -21,14 +21,6 @@ */ class City { - /** - * @var string - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ - public $id; - /** * @var Country * @ManyToOne(targetEntity="Country") @@ -48,15 +40,18 @@ class City */ public $admin1; - /** - * @var string - * @Column(type="string", length=255); - */ - public $name; - - public function __construct(int $id, string $name) + public function __construct( + /** + * @Id + * @Column(type="string", length=25) + * @GeneratedValue(strategy="NONE") + */ + public int $id, + /** + * @Column(type="string", length=255); + */ + public string $name + ) { - $this->id = $id; - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Country.php b/tests/Doctrine/Tests/Models/GeoNames/Country.php index c441ab12ca9..4f038d47590 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Country.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Country.php @@ -19,22 +19,21 @@ class Country { /** - * @var string - * @Id - * @Column(type="string", length=2) - * @GeneratedValue(strategy="NONE") + * @param string $id + * @param string $name */ - public $id; - - /** - * @var string - * @Column(type="string", length=255); - */ - public $name; - - public function __construct($id, $name) + public function __construct( + /** + * @Id + * @Column(type="string", length=2) + * @GeneratedValue(strategy="NONE") + */ + public $id, + /** + * @Column(type="string", length=255); + */ + public $name + ) { - $this->id = $id; - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php b/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php index 5c2d651aa08..a42be8dbb5e 100644 --- a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php +++ b/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php @@ -66,19 +66,16 @@ class DoctrineGlobalUser /** * @Id * @Column(type="integer") - * @var int */ - private $id; + private int $id; /** * @Column(type="string", length=64) - * @var string */ - private $username; + private string $username; /** * @Column(type="string", length=128) - * @var string */ - private $email; + private string $email; } diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php b/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php index 506661af37a..3a232805176 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php @@ -19,41 +19,34 @@ class LegacyUserReference { /** - * @var LegacyUser * @Id * @ManyToOne(targetEntity="LegacyUser", inversedBy="references") * @JoinColumn(name="iUserIdSource", referencedColumnName="iUserId") */ - private $_source; + private LegacyUser $_source; /** - * @var LegacyUser * @Id * @ManyToOne(targetEntity="LegacyUser") * @JoinColumn(name="iUserIdTarget", referencedColumnName="iUserId") */ - private $_target; + private LegacyUser $_target; /** - * @var string - * @Column(type="string", length=255, name="description") - */ - private $_description; - - /** - * @var DateTime * @Column(type="datetime", name="created") */ - private $created; + private \DateTime $created; - public function __construct(LegacyUser $source, LegacyUser $target, string $description) + public function __construct(LegacyUser $source, LegacyUser $target, /** + * @Column(type="string", length=255, name="description") + */ + private string $_description) { $source->addReference($this); $target->addReference($this); $this->_source = $source; $this->_target = $target; - $this->_description = $description; $this->created = new DateTime('now'); } diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php index f8d9a560a0f..2058e397a7a 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php @@ -21,21 +21,6 @@ */ class ChildClass { - /** - * @Id - * @Column(name="id1", type="integer") - * @var int - */ - public $id1; - - /** - * @Id - * @ManyToOne(targetEntity=OtherParentClass::class, cascade={"persist"}) - * @JoinColumn(name="other_parent_id", referencedColumnName="id") - * @var OtherParentClass - */ - public $otherParent; - /** * @ManyToMany(targetEntity=ParentClass::class, inversedBy="children") * @JoinTable( @@ -51,10 +36,17 @@ class ChildClass */ public $parents; - public function __construct(int $id1, OtherParentClass $otherParent) + public function __construct(/** + * @Id + * @Column(name="id1", type="integer") + */ + public int $id1, /** + * @Id + * @ManyToOne(targetEntity=OtherParentClass::class, cascade={"persist"}) + * @JoinColumn(name="other_parent_id", referencedColumnName="id") + */ + public OtherParentClass $otherParent) { - $this->id1 = $id1; - $this->otherParent = $otherParent; $this->parents = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php index 68e311e5423..79247bfaa11 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php @@ -15,15 +15,13 @@ */ class OtherParentClass { - /** - * @Id - * @Column(name="id", type="integer") - * @var int - */ - public $id; - - public function __construct(int $id) + public function __construct( + /** + * @Id + * @Column(name="id", type="integer") + */ + public int $id + ) { - $this->id = $id; } } diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php index 8600710efcd..64f1324a3ac 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php @@ -18,13 +18,6 @@ */ class ParentClass { - /** - * @Id - * @Column(name="id", type="integer") - * @var int - */ - public $id; - /** * @ManyToMany(targetEntity=ChildClass::class, mappedBy="parents", orphanRemoval=true, cascade={"persist"}) * @var Collection|ChildClass[] @@ -32,9 +25,12 @@ class ParentClass */ public $children; - public function __construct(int $id) + public function __construct(/** + * @Id + * @Column(name="id", type="integer") + */ + public int $id) { - $this->id = $id; $this->children = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php index 47476e015cc..d4afbebc8e0 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php @@ -19,18 +19,11 @@ class NavCountry { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; - - /** - * @var string - * @Column(type="string", length=255) - */ - private $name; + private int $id; /** * @psalm-var Collection @@ -38,9 +31,13 @@ class NavCountry */ private $pois; - public function __construct(string $name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + private string $name + ) { - $this->name = $name; } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php index f8bc4f9186b..4ef27a368cc 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php @@ -20,33 +20,27 @@ class NavPhotos { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; - - /** - * @var NavPointOfInterest - * @ManyToOne(targetEntity="NavPointOfInterest") - * @JoinColumns({ - * @JoinColumn(name="poi_long", referencedColumnName="nav_long"), - * @JoinColumn(name="poi_lat", referencedColumnName="nav_lat") - * }) - */ - private $poi; - - /** - * @var string - * @Column(type="string", length=255, name="file_name") - */ - private $file; - - public function __construct(NavPointOfInterest $poi, string $file) + private int $id; + + public function __construct( + /** + * @ManyToOne(targetEntity="NavPointOfInterest") + * @JoinColumns({ + * @JoinColumn(name="poi_long", referencedColumnName="nav_long"), + * @JoinColumn(name="poi_lat", referencedColumnName="nav_lat") + * }) + */ + private NavPointOfInterest $poi, + /** + * @Column(type="string", length=255, name="file_name") + */ + private string $file + ) { - $this->poi = $poi; - $this->file = $file; } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php index 1fce7c7f72e..5ce4ef51deb 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php @@ -21,32 +21,6 @@ */ class NavPointOfInterest { - /** - * @var int - * @Id - * @Column(type="integer", name="nav_long") - */ - private $long; - - /** - * @var int - * @Id - * @Column(type="integer", name="nav_lat") - */ - private $lat; - - /** - * @var string - * @Column(type="string", length=255) - */ - private $name; - - /** - * @var NavCountry - * @ManyToOne(targetEntity="NavCountry", inversedBy="pois") - */ - private $country; - /** * @psalm-var Collection * @ManyToMany(targetEntity="NavUser", cascade={"persist"}) @@ -60,12 +34,22 @@ class NavPointOfInterest */ private $visitors; - public function __construct(int $lat, int $long, string $name, NavCountry $country) + public function __construct(/** + * @Id + * @Column(type="integer", name="nav_lat") + */ + private int $lat, /** + * @Id + * @Column(type="integer", name="nav_long") + */ + private int $long, /** + * @Column(type="string", length=255) + */ + private string $name, /** + * @ManyToOne(targetEntity="NavCountry", inversedBy="pois") + */ + private NavCountry $country) { - $this->lat = $lat; - $this->long = $long; - $this->name = $name; - $this->country = $country; $this->visitors = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavTour.php b/tests/Doctrine/Tests/Models/Navigation/NavTour.php index 9aa3d42fae6..c3ac1662584 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavTour.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavTour.php @@ -22,18 +22,11 @@ class NavTour { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; - - /** - * @var string - * @Column(type="string", length=255) - */ - private $name; + private int $id; /** * @var Collection @@ -46,11 +39,13 @@ class NavTour * } * ) */ - private $pois; + private Collection $pois; - public function __construct(string $name) + public function __construct(/** + * @Column(type="string", length=255) + */ + private string $name) { - $this->name = $name; $this->pois = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavUser.php b/tests/Doctrine/Tests/Models/Navigation/NavUser.php index 0b179ba6876..ed8d7a60420 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavUser.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavUser.php @@ -17,21 +17,18 @@ class NavUser { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; - /** - * @var string - * @Column(type="string", length=255) - */ - private $name; - - public function __construct(string $name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + private string $name + ) { - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/Models/Pagination/User.php b/tests/Doctrine/Tests/Models/Pagination/User.php index 450c4728ad2..231cc635e21 100644 --- a/tests/Doctrine/Tests/Models/Pagination/User.php +++ b/tests/Doctrine/Tests/Models/Pagination/User.php @@ -23,12 +23,11 @@ abstract class User { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** * @var string diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php index 5a5ebe595e0..071361ff0f6 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php @@ -42,17 +42,11 @@ public function addElement(PersistentCollectionContent $element): void $this->collection->add($element); } - /** - * @return Collection - */ public function getCollection(): Collection { return clone $this->collection; } - /** - * @return Collection - */ public function getRawCollection(): Collection { return $this->collection; diff --git a/tests/Doctrine/Tests/Models/Quote/City.php b/tests/Doctrine/Tests/Models/Quote/City.php index 79f48d3f63a..37887481497 100644 --- a/tests/Doctrine/Tests/Models/Quote/City.php +++ b/tests/Doctrine/Tests/Models/Quote/City.php @@ -24,14 +24,12 @@ class City */ public $id; - /** - * @var string - * @Column(name="`city-name`") - */ - public $name; - - public function __construct(string $name) + public function __construct( + /** + * @Column(name="`city-name`") + */ + public string $name + ) { - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/Models/Quote/Group.php b/tests/Doctrine/Tests/Models/Quote/Group.php index 4e2dd6d2602..e09de1d1e46 100644 --- a/tests/Doctrine/Tests/Models/Quote/Group.php +++ b/tests/Doctrine/Tests/Models/Quote/Group.php @@ -28,28 +28,23 @@ class Group */ public $id; - /** - * @var string|null - * @Column(name="`group-name`") - */ - public $name; - - /** - * @var Group|null - * @ManyToOne(targetEntity="Group", cascade={"persist"}) - * @JoinColumn(name="`parent-id`", referencedColumnName="`group-id`") - */ - public $parent; - /** * @psalm-var Collection * @ManyToMany(targetEntity="User", mappedBy="groups") */ public $users; - public function __construct(?string $name = null, ?Group $parent = null) + public function __construct( + /** + * @Column(name="`group-name`") + */ + public ?string $name = null, + /** + * @ManyToOne(targetEntity="Group", cascade={"persist"}) + * @JoinColumn(name="`parent-id`", referencedColumnName="`group-id`") + */ + public ?\Doctrine\Tests\Models\Quote\Group $parent = null + ) { - $this->name = $name; - $this->parent = $parent; } } diff --git a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php index 86bdf8d14fb..c32e5b4a3e7 100644 --- a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php +++ b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php @@ -24,14 +24,12 @@ class NumericEntity */ public $id; - /** - * @var string - * @Column(type="string", length=255, name="`2:2`") - */ - public $value; - - public function __construct(string $value) + public function __construct( + /** + * @Column(type="string", length=255, name="`2:2`") + */ + public string $value + ) { - $this->value = $value; } } diff --git a/tests/Doctrine/Tests/Models/Reflection/AbstractEmbeddable.php b/tests/Doctrine/Tests/Models/Reflection/AbstractEmbeddable.php index 670baa00086..2240c6fcb9f 100644 --- a/tests/Doctrine/Tests/Models/Reflection/AbstractEmbeddable.php +++ b/tests/Doctrine/Tests/Models/Reflection/AbstractEmbeddable.php @@ -9,6 +9,5 @@ */ abstract class AbstractEmbeddable { - /** @var string */ - private $propertyInAbstractClass; + private string $propertyInAbstractClass; } diff --git a/tests/Doctrine/Tests/Models/Reflection/ClassWithMixedProperties.php b/tests/Doctrine/Tests/Models/Reflection/ClassWithMixedProperties.php index 346f095a43e..307eeba22e6 100644 --- a/tests/Doctrine/Tests/Models/Reflection/ClassWithMixedProperties.php +++ b/tests/Doctrine/Tests/Models/Reflection/ClassWithMixedProperties.php @@ -15,9 +15,7 @@ class ClassWithMixedProperties extends ParentClass /** @var string */ protected $protectedProperty = 'protectedProperty'; - /** @var string */ - private $privateProperty = 'privateProperty'; + private string $privateProperty = 'privateProperty'; - /** @var string */ - private $privatePropertyOverride = 'privatePropertyOverride'; + private string $privatePropertyOverride = 'privatePropertyOverride'; } diff --git a/tests/Doctrine/Tests/Models/Reflection/ConcreteEmbeddable.php b/tests/Doctrine/Tests/Models/Reflection/ConcreteEmbeddable.php index 76c0ceea7f9..63c38dbefa8 100644 --- a/tests/Doctrine/Tests/Models/Reflection/ConcreteEmbeddable.php +++ b/tests/Doctrine/Tests/Models/Reflection/ConcreteEmbeddable.php @@ -9,6 +9,5 @@ */ class ConcreteEmbeddable extends AbstractEmbeddable { - /** @var string */ - private $propertyInConcreteClass; + private string $propertyInConcreteClass; } diff --git a/tests/Doctrine/Tests/Models/Reflection/ParentClass.php b/tests/Doctrine/Tests/Models/Reflection/ParentClass.php index da95ee61503..7bd063b6058 100644 --- a/tests/Doctrine/Tests/Models/Reflection/ParentClass.php +++ b/tests/Doctrine/Tests/Models/Reflection/ParentClass.php @@ -6,6 +6,5 @@ class ParentClass { - /** @var string */ - private $privatePropertyOverride = 'privatePropertyOverride'; + private string $privatePropertyOverride = 'privatePropertyOverride'; } diff --git a/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/tests/Doctrine/Tests/Models/StockExchange/Bond.php index 601aa9348eb..28963ced076 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Bond.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Bond.php @@ -25,15 +25,8 @@ class Bond * @Id * @GeneratedValue * @Column(type="integer") - * @var int */ - private $id; - - /** - * @Column(type="string", length=255) - * @var string - */ - private $name; + private int $id; /** * @ManyToMany(targetEntity="Stock", indexBy="symbol") @@ -42,9 +35,13 @@ class Bond */ public $stocks; - public function __construct(string $name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + private string $name + ) { - $this->name = $name; } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/StockExchange/Market.php b/tests/Doctrine/Tests/Models/StockExchange/Market.php index d43a4de3c90..ceb6d5a3093 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Market.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Market.php @@ -22,15 +22,8 @@ class Market * @Id * @Column(type="integer") * @GeneratedValue - * @var int */ - private $id; - - /** - * @Column(type="string", length=255) - * @var string - */ - private $name; + private int $id; /** * @OneToMany(targetEntity="Stock", mappedBy="market", indexBy="symbol") @@ -38,9 +31,11 @@ class Market */ public $stocks; - public function __construct(string $name) + public function __construct(/** + * @Column(type="string", length=255) + */ + private string $name) { - $this->name = $name; $this->stocks = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/StockExchange/Stock.php b/tests/Doctrine/Tests/Models/StockExchange/Stock.php index 680aa4c7079..a7e17bc21e1 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Stock.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Stock.php @@ -21,34 +21,21 @@ class Stock * @Id * @GeneratedValue * @Column(type="integer") - * @var int */ - private $id; + private int $id; - /** - * @var string + public function __construct(/** * For real this column would have to be unique=true. But I want to test behavior of non-unique overrides. * @Column(type="string", length=255) */ - private $symbol; - - /** - * @var float + private string $symbol, /** * @Column(type="decimal") */ - private $price; - - /** + private float $price, /** * @ManyToOne(targetEntity="Market", inversedBy="stocks") - * @var Market */ - private $market; - - public function __construct(string $symbol, float $initialOfferingPrice, Market $market) + private Market $market) { - $this->symbol = $symbol; - $this->price = $initialOfferingPrice; - $this->market = $market; $market->addStock($this); } diff --git a/tests/Doctrine/Tests/Models/Taxi/Car.php b/tests/Doctrine/Tests/Models/Taxi/Car.php index 0539c5faa7f..62ae8419d99 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Car.php +++ b/tests/Doctrine/Tests/Models/Taxi/Car.php @@ -19,18 +19,16 @@ class Car { /** - * @var string * @Id * @Column(type="string", length=25) * @GeneratedValue(strategy="NONE") */ - private $brand; + private ?string $brand = null; /** - * @var string * @Column(type="string", length=255); */ - private $model; + private ?string $model = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Taxi/Driver.php b/tests/Doctrine/Tests/Models/Taxi/Driver.php index 123616580ba..d900acd8706 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Driver.php +++ b/tests/Doctrine/Tests/Models/Taxi/Driver.php @@ -19,18 +19,16 @@ class Driver { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255); */ - private $name; + private ?string $name = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php index a66008a3426..81b0ea9f276 100644 --- a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php +++ b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php @@ -19,32 +19,27 @@ */ class PaidRide { - /** - * @var Driver - * @Id - * @ManyToOne(targetEntity="Driver", inversedBy="driverRides") - * @JoinColumn(name="driver_id", referencedColumnName="id") - */ - private $driver; - - /** - * @var Car - * @Id - * @ManyToOne(targetEntity="Car", inversedBy="carRides") - * @JoinColumn(name="car", referencedColumnName="brand") - */ - private $car; - /** * @var float * @Column(type="decimal", precision=6, scale=2) */ private $fare; - public function __construct(Driver $driver, Car $car) + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="Driver", inversedBy="driverRides") + * @JoinColumn(name="driver_id", referencedColumnName="id") + */ + private Driver $driver, + /** + * @Id + * @ManyToOne(targetEntity="Car", inversedBy="carRides") + * @JoinColumn(name="car", referencedColumnName="brand") + */ + private Car $car + ) { - $this->driver = $driver; - $this->car = $car; } public function setFare($fare): void diff --git a/tests/Doctrine/Tests/Models/Taxi/Ride.php b/tests/Doctrine/Tests/Models/Taxi/Ride.php index cbbb5360995..50767cae4d4 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Ride.php +++ b/tests/Doctrine/Tests/Models/Taxi/Ride.php @@ -18,25 +18,20 @@ */ class Ride { - /** - * @var Driver - * @Id - * @ManyToOne(targetEntity="Driver", inversedBy="freeDriverRides") - * @JoinColumn(name="driver_id", referencedColumnName="id") - */ - private $driver; - - /** - * @var Car - * @Id - * @ManyToOne(targetEntity="Car", inversedBy="freeCarRides") - * @JoinColumn(name="car", referencedColumnName="brand") - */ - private $car; - - public function __construct(Driver $driver, Car $car) + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="Driver", inversedBy="freeDriverRides") + * @JoinColumn(name="driver_id", referencedColumnName="id") + */ + private Driver $driver, + /** + * @Id + * @ManyToOne(targetEntity="Car", inversedBy="freeCarRides") + * @JoinColumn(name="car", referencedColumnName="brand") + */ + private Car $car + ) { - $this->driver = $driver; - $this->car = $car; } } diff --git a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php index ad5af325cf6..b1030bb9053 100644 --- a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php +++ b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php @@ -37,7 +37,7 @@ class UserTyped /** @Column(length=50) */ #[ORM\Column(length: 50)] - public ?string $status; + public ?string $status = null; /** @Column(length=255, unique=true) */ #[ORM\Column(length: 255, unique: true)] @@ -76,7 +76,7 @@ class UserTyped /** @ManyToOne */ #[ORM\ManyToOne] - public ?CmsEmail $mainEmail; + public ?CmsEmail $mainEmail = null; /** @Embedded */ #[ORM\Embedded] diff --git a/tests/Doctrine/Tests/Models/ValueObjects/Name.php b/tests/Doctrine/Tests/Models/ValueObjects/Name.php index dddd7d6c194..63bf85a88a7 100644 --- a/tests/Doctrine/Tests/Models/ValueObjects/Name.php +++ b/tests/Doctrine/Tests/Models/ValueObjects/Name.php @@ -6,9 +6,7 @@ class Name { - /** @var string */ - private $firstName; + private string $firstName; - /** @var string */ - private $lastName; + private string $lastName; } diff --git a/tests/Doctrine/Tests/Models/ValueObjects/Person.php b/tests/Doctrine/Tests/Models/ValueObjects/Person.php index 01060c9cf3a..92d5e281b38 100644 --- a/tests/Doctrine/Tests/Models/ValueObjects/Person.php +++ b/tests/Doctrine/Tests/Models/ValueObjects/Person.php @@ -6,9 +6,7 @@ class Person { - /** @var int */ - private $id; + private int $id; - /** @var string */ - private $name; + private string $name; } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index 4c6c6d6f07f..b4fc3ff00e8 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Cache; +use Doctrine\ORM\Cache\Region; +use Doctrine\ORM\Cache\QueryCache; use Doctrine\ORM\Cache; use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\CollectionCacheKey; @@ -64,13 +66,13 @@ public function testImplementsCache(): void public function testGetEntityCacheRegionAccess(): void { - self::assertInstanceOf(Cache\Region::class, $this->cache->getEntityCacheRegion(State::class)); + self::assertInstanceOf(Region::class, $this->cache->getEntityCacheRegion(State::class)); self::assertNull($this->cache->getEntityCacheRegion(CmsUser::class)); } public function testGetCollectionCacheRegionAccess(): void { - self::assertInstanceOf(Cache\Region::class, $this->cache->getCollectionCacheRegion(State::class, 'cities')); + self::assertInstanceOf(Region::class, $this->cache->getCollectionCacheRegion(State::class, 'cities')); self::assertNull($this->cache->getCollectionCacheRegion(CmsUser::class, 'phonenumbers')); } @@ -219,8 +221,8 @@ public function testQueryCache(): void $defaultQueryCache = $this->cache->getQueryCache(); $fooQueryCache = $this->cache->getQueryCache('foo'); - self::assertInstanceOf(Cache\QueryCache::class, $defaultQueryCache); - self::assertInstanceOf(Cache\QueryCache::class, $fooQueryCache); + self::assertInstanceOf(QueryCache::class, $defaultQueryCache); + self::assertInstanceOf(QueryCache::class, $fooQueryCache); self::assertSame($defaultQueryCache, $this->cache->getQueryCache()); self::assertSame($fooQueryCache, $this->cache->getQueryCache('foo')); diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 9025852a0bc..8df12142ba3 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Cache; +use Doctrine\ORM\Cache\DefaultCacheFactory; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Cache; use Doctrine\ORM\Cache\DefaultQueryCache; @@ -671,7 +672,7 @@ public function testNotCacheableEntityException(): void } } -class CacheFactoryDefaultQueryCacheTest extends Cache\DefaultCacheFactory +class CacheFactoryDefaultQueryCacheTest extends DefaultCacheFactory { public function __construct( private DefaultQueryCache $queryCache, diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index ede2b193f33..46cd848df4a 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -255,9 +255,7 @@ public function testHandlesScanErrorsGracefullyOnEvictAll(): void $reflectionDirectory->setAccessible(true); $reflectionDirectory->setValue($region, str_repeat('a', 10000)); - set_error_handler(static function (): bool { - return true; - }, E_WARNING); + set_error_handler(static fn(): bool => true, E_WARNING); try { self::assertTrue($region->evictAll()); } finally { diff --git a/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php b/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php index a9d3004683a..b600d222340 100644 --- a/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php +++ b/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php @@ -17,8 +17,7 @@ */ class CommitOrderCalculatorTest extends OrmTestCase { - /** @var CommitOrderCalculator */ - private $_calc; + private CommitOrderCalculator $_calc; protected function setUp(): void { @@ -101,7 +100,7 @@ public function testCommitOrdering3(): void ]; // We want to perform a strict comparison of the array - self::assertContains($sorted, $correctOrders, '', false, true); + self::assertContains($sorted, $correctOrders, ''); } } diff --git a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php index d39071c37ec..a206fe536d7 100644 --- a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php +++ b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php @@ -17,8 +17,7 @@ public function testFieldInitializationInConstructor(): void class ConstructorTestEntity1 { - /** @var int */ - private $id; + private int $id; /** @var string|null */ public $username; diff --git a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php index fb497deea6a..e8490765a47 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php @@ -53,8 +53,6 @@ protected function countForeignKeys($firstId, $secondId): int public function assertCollectionEquals(Collection $first, Collection $second): bool { - return $first->forAll(static function ($k, $e) use ($second): bool { - return $second->contains($e); - }); + return $first->forAll(static fn($k, $e): bool => $second->contains($e)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php index 101652daa85..4a9e9cc00e5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -157,24 +157,21 @@ class Lemma public const CLASS_NAME = self::class; /** - * @var int * @Id * @Column(type="integer", name="lemma_id") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", name="lemma_name", unique=true, length=255) */ - private $lemma; + private ?string $lemma = null; /** - * @var Collection * @ManyToMany(targetEntity="Type", mappedBy="lemmas", cascade={"persist"}) */ - private $types; + private Collection $types; public function __construct() { @@ -227,34 +224,30 @@ class Type public const CLASS_NAME = self::class; /** - * @var int * @Id * @Column(type="integer", name="type_id") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", name="type_name", unique=true) */ - private $type; + private ?string $type = null; /** - * @var string * @Column(type="string", name="type_abbreviation", unique=true) */ - private $abbreviation; + private ?string $abbreviation = null; /** - * @var Collection * @ManyToMany(targetEntity="Lemma") * @JoinTable(name="lemma_type", * joinColumns={@JoinColumn(name="type_id", referencedColumnName="type_id")}, * inverseJoinColumns={@JoinColumn(name="lemma_id", referencedColumnName="lemma_id")} * ) */ - private $lemmas; + private Collection $lemmas; public function __construct() { @@ -318,25 +311,22 @@ class Phrase public const CLASS_NAME = self::class; /** - * @var int * @Id * @Column(type="integer", name="phrase_id") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", name="phrase_name", unique=true, length=255) */ - private $phrase; + private ?string $phrase = null; /** - * @var PhraseType * @ManyToOne(targetEntity="PhraseType") * @JoinColumn(name="phrase_type_id", referencedColumnName="phrase_type_id") */ - private $type; + private ?\Doctrine\Tests\ORM\Functional\PhraseType $type = null; /** * @psalm-var Collection @@ -395,24 +385,21 @@ class PhraseType public const CLASS_NAME = self::class; /** - * @var int * @Id * @Column(type="integer", name="phrase_type_id") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", name="phrase_type_name", unique=true) */ - private $type; + private ?string $type = null; /** - * @var string * @Column(type="string", name="phrase_type_abbreviation", unique=true) */ - private $abbreviation; + private ?string $abbreviation = null; /** * @psalm-var Collection @@ -470,25 +457,22 @@ class Definition public const CLASS_NAME = self::class; /** - * @var int * @Id * @Column(type="integer", name="definition_id") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var Phrase * @ManyToOne(targetEntity="Phrase") * @JoinColumn(name="definition_phrase_id", referencedColumnName="phrase_id") */ - private $phrase; + private ?\Doctrine\Tests\ORM\Functional\Phrase $phrase = null; /** - * @var string * @Column(type="text", name="definition_text") */ - private $definition; + private ?string $definition = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 23aa589ca53..f6ee94ff41a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -616,7 +616,7 @@ public function testTextColumnSaveAndRetrieve(): void $this->_em->clear(); // test find() with leading backslash at the same time - $articleNew = $this->_em->find('\Doctrine\Tests\Models\CMS\CmsArticle', $articleId); + $articleNew = $this->_em->find(CmsArticle::class, $articleId); self::assertTrue($this->_em->contains($articleNew)); self::assertEquals('Lorem ipsum dolor sunt.', $articleNew->text); @@ -896,7 +896,7 @@ public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void $this->_em->flush(); $this->_em->clear(); - self::assertEquals('Benjamin E.', $this->_em->find(get_class($user), $userId)->name); + self::assertEquals('Benjamin E.', $this->_em->find($user::class, $userId)->name); } /** @@ -947,7 +947,7 @@ public function testFlushSingleManagedEntity(): void $this->_em->flush(); $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); self::assertEquals('administrator', $user->status); } @@ -1024,7 +1024,7 @@ public function testFlushSingleNewEntityThenRemove(): void $this->_em->flush(); $this->_em->clear(); - self::assertNull($this->_em->find(get_class($user), $userId)); + self::assertNull($this->_em->find($user::class, $userId)); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php index e2a6d43bb19..05c1367563b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php @@ -77,19 +77,17 @@ public function testMany(): void class CascadeRemoveOrderEntityO { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var CascadeRemoveOrderEntityG * @OneToOne(targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG") * @JoinColumn(nullable=true, onDelete="SET NULL") */ - private $oneToOneG; + private ?\Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG $oneToOneG = null; /** * @psalm-var Collection @@ -141,29 +139,23 @@ public function getOneToManyGs(): array class CascadeRemoveOrderEntityG { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var CascadeRemoveOrderEntityO + * @param int $position + */ + public function __construct(/** * @ManyToOne( * targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityO", * inversedBy="oneToMany" * ) */ - private $ownerO; - - /** @var int */ - private $position; - - public function __construct(CascadeRemoveOrderEntityO $eO, $position = 1) + private CascadeRemoveOrderEntityO $ownerO, private $position = 1) { - $this->position = $position; - $this->ownerO = $eO; $this->ownerO->addOneToManyG($this); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php index f257afa54dd..541fb11cd60 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php @@ -76,7 +76,7 @@ public function testManyToManyToCTIHierarchy(): void $this->_em->flush(); $this->_em->clear(); - $mmrel2 = $this->_em->find(get_class($mmrel), $mmrel->getId()); + $mmrel2 = $this->_em->find($mmrel::class, $mmrel->getId()); self::assertFalse($mmrel2->getCTIChildren()->isInitialized()); self::assertEquals(1, count($mmrel2->getCTIChildren())); self::assertTrue($mmrel2->getCTIChildren()->isInitialized()); @@ -94,18 +94,16 @@ public function testManyToManyToCTIHierarchy(): void class CTIParent { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var CTIRelated * @OneToOne(targetEntity="CTIRelated", mappedBy="ctiParent") */ - private $related; + private ?\Doctrine\Tests\ORM\Functional\CTIRelated $related = null; public function getId(): int { @@ -131,10 +129,9 @@ public function setRelated(CTIRelated $related): void class CTIChild extends CTIParent { /** - * @var string * @Column(type="string", length=255) */ - private $data; + private ?string $data = null; public function getData(): string { @@ -151,19 +148,17 @@ public function setData(string $data): void class CTIRelated { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var CTIParent * @OneToOne(targetEntity="CTIParent") * @JoinColumn(name="ctiparent_id", referencedColumnName="id") */ - private $ctiParent; + private ?\Doctrine\Tests\ORM\Functional\CTIParent $ctiParent = null; public function getId(): int { @@ -185,12 +180,11 @@ public function setCTIParent(CTIParent $ctiParent): void class CTIRelated2 { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index cd2bcae877a..dcd5de24b67 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -88,7 +88,7 @@ public function testCRUD(): void $this->_em->clear(); - $guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(['name' => 'Guilherme Blanco']); + $guilherme = $this->_em->getRepository($employee::class)->findOneBy(['name' => 'Guilherme Blanco']); self::assertInstanceOf(CompanyEmployee::class, $guilherme); self::assertEquals('Guilherme Blanco', $guilherme->getName()); @@ -364,7 +364,7 @@ public function testDeleteJoinTableRecords(): void $this->_em->remove($employee1); $this->_em->flush(); - self::assertNull($this->_em->find(get_class($employee1), $employee1Id)); + self::assertNull($this->_em->find($employee1::class, $employee1Id)); } /** @@ -490,12 +490,12 @@ public function testExistsSubclass(): void $manager->setTitle('Awesome!'); $manager->setDepartment('IT'); - self::assertFalse($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); + self::assertFalse($this->_em->getUnitOfWork()->getEntityPersister($manager::class)->exists($manager)); $this->_em->persist($manager); $this->_em->flush(); - self::assertTrue($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); + self::assertTrue($this->_em->getUnitOfWork()->getEntityPersister($manager::class)->exists($manager)); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php index f4027d7dc83..f2e191ba52b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Query\AST\AggregateExpression; use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\PathExpression; @@ -33,12 +34,8 @@ public function testCustomFunctionDefinedWithCallback(): void $this->_em->flush(); // Instead of defining the function with the class name, we use a callback - $this->_em->getConfiguration()->addCustomStringFunction('FOO', static function ($funcName) { - return new NoOp($funcName); - }); - $this->_em->getConfiguration()->addCustomNumericFunction('BAR', static function ($funcName) { - return new NoOp($funcName); - }); + $this->_em->getConfiguration()->addCustomStringFunction('FOO', static fn($funcName) => new NoOp($funcName)); + $this->_em->getConfiguration()->addCustomNumericFunction('BAR', static fn($funcName) => new NoOp($funcName)); $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u' . ' WHERE FOO(u.name) = \'Bob\'' @@ -89,8 +86,7 @@ public function getSql(SqlWalker $sqlWalker): string class CustomCount extends FunctionNode { - /** @var Query\AST\AggregateExpression */ - private $aggregateExpression; + private ?AggregateExpression $aggregateExpression = null; public function parse(Parser $parser): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index 7cae6340aef..1ca9fdc7d6f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -41,7 +41,7 @@ public function testSimpleDetachMerge(): void $this->_em->clear(); $userId = $user->id; // e.g. from $_REQUEST - $user2 = $this->_em->getReference(get_class($user), $userId); + $user2 = $this->_em->getReference($user::class, $userId); $this->_em->flush(); self::assertFalse($user2->__isInitialized__); @@ -59,7 +59,7 @@ public function testSimpleDetachMerge(): void self::assertFalse($user2->__isInitialized__); $this->_em->clear(); - $a2 = $this->_em->find(get_class($a), $a->id); + $a2 = $this->_em->find($a::class, $a->id); self::assertInstanceOf(DefaultValueUser::class, $a2->getUser()); self::assertEquals($userId, $a2->getUser()->getId()); self::assertEquals('Poweruser', $a2->getUser()->type); diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php index 7bb67ae7370..869eb261196 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php @@ -16,8 +16,7 @@ */ class EntityListenersTest extends OrmFunctionalTestCase { - /** @var CompanyContractListener */ - private $listener; + private CompanyContractListener $listener; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 06b208edaf7..9a19c3d7dbd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Query\ResultSetMappingBuilder; use BadMethodCallException; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; @@ -928,7 +929,7 @@ public function testCreateResultSetMappingBuilder(): void $repository = $this->_em->getRepository(CmsUser::class); $rsm = $repository->createResultSetMappingBuilder('u'); - self::assertInstanceOf(Query\ResultSetMappingBuilder::class, $rsm); + self::assertInstanceOf(ResultSetMappingBuilder::class, $rsm); self::assertEquals(['u' => CmsUser::class], $rsm->aliasMap); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index bf39db8ca20..b301b0e592a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -21,32 +21,23 @@ */ class ExtraLazyCollectionTest extends OrmFunctionalTestCase { - /** @var int */ - private $userId; + private ?int $userId = null; - /** @var int */ - private $userId2; + private ?int $userId2 = null; - /** @var int */ - private $groupId; + private ?int $groupId = null; - /** @var int */ - private $articleId; + private ?int $articleId = null; - /** @var int */ - private $ddc2504OtherClassId; + private ?int $ddc2504OtherClassId = null; - /** @var int */ - private $ddc2504ChildClassId; + private ?int $ddc2504ChildClassId = null; - /** @var string */ - private $username; + private ?string $username = null; - /** @var string */ - private $groupname; + private ?string $groupname = null; - /** @var string */ - private $topic; + private ?string $topic = null; /** @var CmsPhonenumber */ private $phonenumber; diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php index 608a8ae851e..b6fd2e809b8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -93,7 +93,7 @@ public function onFlush(OnFlushEventArgs $args): void $em->persist($phone); // Explicitly calculate the changeset since onFlush is raised // after changeset calculation! - $uow->computeChangeSet($em->getClassMetadata(get_class($phone)), $phone); + $uow->computeChangeSet($em->getClassMetadata($phone::class), $phone); // Take a snapshot because the UoW wont do this for us, because // the UoW did not visit this collection. diff --git a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php index 6174d0ac18b..86cf8531426 100644 --- a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php @@ -116,12 +116,8 @@ abstract class GH5988CustomIdObjectTypeParent */ class GH5988CustomIdObjectTypeChild extends GH5988CustomIdObjectTypeParent { - /** @var string */ - public $name; - - public function __construct(CustomIdObject $id, string $name) + public function __construct(CustomIdObject $id, public string $name) { $this->id = $id; - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php index 94a632baf75..131ee133f77 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php @@ -44,14 +44,14 @@ public function testBasicIdentityManagement(): void $this->_em->flush(); $this->_em->clear(); - $user2 = $this->_em->find(get_class($user), $user->getId()); + $user2 = $this->_em->find($user::class, $user->getId()); self::assertNotSame($user2, $user); - $user3 = $this->_em->find(get_class($user), $user->getId()); + $user3 = $this->_em->find($user::class, $user->getId()); self::assertSame($user2, $user3); - $address2 = $this->_em->find(get_class($address), $address->getId()); + $address2 = $this->_em->find($address::class, $address->getId()); self::assertNotSame($address2, $address); - $address3 = $this->_em->find(get_class($address), $address->getId()); + $address3 = $this->_em->find($address::class, $address->getId()); self::assertSame($address2, $address3); self::assertSame($user2->getAddress(), $address2); // !!! diff --git a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php index f8675486e0e..f03abb5dd7c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php @@ -16,11 +16,9 @@ */ class IndexByAssociationTest extends OrmFunctionalTestCase { - /** @var Market */ - private $market; + private ?Market $market = null; - /** @var Bond */ - private $bond; + private ?Bond $bond = null; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php b/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php index 3c9d20d40b1..c59425e6d81 100644 --- a/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php @@ -22,7 +22,7 @@ protected function setUp(): void $this->_em->getClassMetadata(Insertable::class), ] ); - } catch (ToolsException $e) { + } catch (ToolsException) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index e2a893d7c6e..d20db704b5d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -108,7 +108,7 @@ public function testChangesDontGetLost(): void $this->_em->clear(); - $user2 = $this->_em->find(get_class($user), $user->getId()); + $user2 = $this->_em->find($user::class, $user->getId()); self::assertEquals('Alice', $user2->getName()); self::assertEquals('Hello World', $user2->getValue()); @@ -409,24 +409,21 @@ public function testLifecycleCallbackEventArgs(): void class LifecycleCallbackTestUser { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255) */ - private $value; + private ?string $value = null; /** - * @var string * @Column(type="string", length=255) */ - private $name; + private ?string $name = null; public function getId(): int { @@ -485,12 +482,11 @@ class LifecycleCallbackTestEntity public $preFlushCallbackInvoked = false; /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** * @var string @@ -562,12 +558,11 @@ class LifecycleCallbackCascader public $postLoadEntitiesCount = 0; /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** * @psalm-var Collection @@ -612,12 +607,11 @@ public function doStuff(): void class LifecycleCallbackChildEntity extends LifecycleCallbackParentEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; } class LifecycleListenerPreUpdate diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php index 84d71ec4921..490eb3fa6ff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php @@ -18,14 +18,11 @@ */ class GearmanLockTest extends OrmFunctionalTestCase { - /** @var GearmanClient */ - private $gearman = null; + private ?\GearmanClient $gearman = null; - /** @var int $maxRunTime */ - private $maxRunTime = 0; + private int $maxRunTime = 0; - /** @var int */ - private $articleId; + private int $articleId; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php index b933bc647d0..c4cc8f35047 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Locking; +use Doctrine\Tests\ORM\Functional\Locking\Doctrine\ORM\Query; use Closure; use Doctrine\DBAL\Connection; use Doctrine\ORM\Configuration; @@ -22,8 +23,7 @@ class LockAgentWorker { - /** @var EntityManagerInterface */ - private $em; + private ?EntityManagerInterface $em = null; public static function run(): void { @@ -74,7 +74,7 @@ public function dqlWithLock($job): float { return $this->process($job, static function ($fixture, $em): void { $query = $em->createQuery($fixture['dql']); - assert($query instanceof Doctrine\ORM\Query); + assert($query instanceof Query); $query->setLockMode($fixture['lockMode']); $query->setParameters($fixture['dqlParams']); $result = $query->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index c9fd63344c9..1cc0ec5b3e9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -169,7 +169,7 @@ public function testLockPessimisticWrite(): void try { $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); $this->_em->commit(); - } catch (Exception $e) { + } catch (Exception) { $this->_em->rollback(); } @@ -205,7 +205,7 @@ public function testLockPessimisticRead(): void try { $this->_em->lock($article, LockMode::PESSIMISTIC_READ); $this->_em->commit(); - } catch (Exception $e) { + } catch (Exception) { $this->_em->rollback(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index d4f45ec05a4..006fb454b24 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -24,8 +24,7 @@ class OptimisticTest extends OrmFunctionalTestCase { - /** @var Connection */ - private $_conn; + private Connection $_conn; protected function setUp(): void { @@ -215,7 +214,7 @@ public function testOptimisticTimestampSetsDefaultValue(): OptimisticTimestamp $this->_em->persist($test); $this->_em->flush(); - self::assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf(\DateTime::class, $test->version); return $test; } @@ -231,7 +230,7 @@ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestam $test = $q->getSingleResult(); - self::assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf(\DateTime::class, $test->version); // Manually increment the version datetime column $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); @@ -263,7 +262,7 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime $test = $q->getSingleResult(); - self::assertInstanceOf('DateTime', $test->version); + self::assertInstanceOf(\DateTime::class, $test->version); // Try to lock the record with an older timestamp and it should throw an exception $caughtException = null; @@ -350,11 +349,10 @@ class OptimisticStandard public $name; /** - * @var int * @Version * @Column(type="integer") */ - private $version; + private int $version; public function getVersion(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php index 64cc29d7bd6..7fcf5bea47f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -81,7 +81,7 @@ public function testManyToManyAddRemove(): void $user = $this->addCmsUserGblancoWithGroups(2); $this->_em->clear(); - $uRep = $this->_em->getRepository(get_class($user)); + $uRep = $this->_em->getRepository($user::class); // Get user $user = $uRep->findOneById($user->getId()); @@ -125,7 +125,7 @@ public function testManyToManyInverseSideIgnored(): void $this->_em->clear(); // Association should not exist - $user2 = $this->_em->find(get_class($user), $user->getId()); + $user2 = $this->_em->find($user::class, $user->getId()); self::assertNotNull($user2, 'Has to return exactly one entry.'); self::assertEquals(0, $user2->getGroups()->count()); @@ -219,7 +219,7 @@ public function testRemoveUserWithManyGroups(): void $this->_em->remove($user); $this->_em->flush(); - $newUser = $this->_em->find(get_class($user), $userId); + $newUser = $this->_em->find($user::class, $userId); self::assertNull($newUser); } @@ -237,7 +237,7 @@ public function testRemoveGroupWithUser(): void $this->_em->flush(); $this->_em->clear(); - $newUser = $this->_em->find(get_class($user), $user->getId()); + $newUser = $this->_em->find($user::class, $user->getId()); self::assertCount(0, $newUser->getGroups()); } @@ -249,7 +249,7 @@ public function testDereferenceCollectionDelete(): void $this->_em->flush(); $this->_em->clear(); - $newUser = $this->_em->find(get_class($user), $user->getId()); + $newUser = $this->_em->find($user::class, $user->getId()); self::assertCount(0, $newUser->getGroups()); } @@ -277,7 +277,7 @@ public function testWorkWithDqlHydratedEmptyCollection(): void $this->_em->flush(); $this->_em->clear(); - $newUser = $this->_em->find(get_class($user), $user->getId()); + $newUser = $this->_em->find($user::class, $user->getId()); self::assertCount(1, $newUser->groups); } @@ -318,7 +318,7 @@ public function testClearAndResetCollection(): void $this->_em->flush(); $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); $coll = new ArrayCollection([$group1, $group2]); $user->groups = $coll; @@ -332,7 +332,7 @@ public function testClearAndResetCollection(): void $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); self::assertCount(2, $user->groups); self::assertEquals('Developers_New1', $user->groups[0]->name); self::assertEquals('Developers_New2', $user->groups[1]->name); @@ -346,7 +346,7 @@ public function testInitializePersistentCollection(): void $user = $this->addCmsUserGblancoWithGroups(2); $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); $this->_em->getUnitOfWork()->initializeObject($user->groups); @@ -363,13 +363,13 @@ public function testClearBeforeLazyLoad(): void $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); $user->groups->clear(); self::assertCount(0, $user->groups); $this->_em->flush(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); self::assertCount(0, $user->groups); } @@ -397,7 +397,7 @@ public function testManyToManyOrderByIsNotIgnored(): void $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); $criteria = Criteria::create() ->orderBy(['name' => Criteria::ASC]); @@ -407,9 +407,7 @@ public function testManyToManyOrderByIsNotIgnored(): void $user ->getGroups() ->matching($criteria) - ->map(static function (CmsGroup $group) { - return $group->getName(); - }) + ->map(static fn(CmsGroup $group) => $group->getName()) ->toArray() ); } @@ -441,7 +439,7 @@ public function testManyToManyOrderByHonorsFieldNameColumnNameAliases(): void $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); $criteria = Criteria::create() ->orderBy(['name' => Criteria::ASC]); @@ -451,9 +449,7 @@ public function testManyToManyOrderByHonorsFieldNameColumnNameAliases(): void $user ->getTags() ->matching($criteria) - ->map(static function (CmsTag $tag) { - return $tag->getName(); - }) + ->map(static fn(CmsTag $tag) => $tag->getName()) ->toArray() ); } @@ -463,7 +459,7 @@ public function testMatchingWithLimit(): void $user = $this->addCmsUserGblancoWithGroups(2); $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); $groups = $user->groups; self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); @@ -481,7 +477,7 @@ public function testMatchingWithOffset(): void $user = $this->addCmsUserGblancoWithGroups(2); $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); $groups = $user->groups; self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); @@ -502,7 +498,7 @@ public function testMatchingWithLimitAndOffset(): void $user = $this->addCmsUserGblancoWithGroups(5); $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); $groups = $user->groups; self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); @@ -526,7 +522,7 @@ public function testMatching(): void $user = $this->addCmsUserGblancoWithGroups(2); $this->_em->clear(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); $groups = $user->groups; self::assertFalse($user->groups->isInitialized(), 'Pre-condition: lazy collection'); diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php index 34ce3ad3630..0fe632e6e05 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php @@ -22,17 +22,13 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati /** @var string */ protected $table = 'ecommerce_products_categories'; - /** @var ECommerceProduct */ - private $firstProduct; + private ECommerceProduct $firstProduct; - /** @var ECommerceProduct */ - private $secondProduct; + private ECommerceProduct $secondProduct; - /** @var ECommerceCategory */ - private $firstCategory; + private ECommerceCategory $firstCategory; - /** @var ECommerceCategory */ - private $secondCategory; + private ECommerceCategory $secondCategory; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php index 20f3427ec99..775d0c4c01b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php @@ -14,8 +14,7 @@ */ class ManyToManyEventTest extends OrmFunctionalTestCase { - /** @var PostUpdateListener */ - private $listener; + private \Doctrine\Tests\ORM\Functional\PostUpdateListener $listener; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php index 9af5d6f4f56..2131d705273 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php @@ -23,17 +23,13 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia /** @var string */ protected $table = 'ecommerce_products_related'; - /** @var ECommerceProduct */ - private $firstProduct; + private ECommerceProduct $firstProduct; - /** @var ECommerceProduct */ - private $secondProduct; + private ECommerceProduct $secondProduct; - /** @var ECommerceProduct */ - private $firstRelated; + private ECommerceProduct $firstRelated; - /** @var ECommerceProduct */ - private $secondRelated; + private ECommerceProduct $secondRelated; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php index 515d281abe3..653b4e0d1f2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php @@ -23,17 +23,13 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat /** @var string */ protected $table = 'ecommerce_carts_products'; - /** @var ECommerceProduct */ - private $firstProduct; + private ECommerceProduct $firstProduct; - /** @var ECommerceProduct */ - private $secondProduct; + private ECommerceProduct $secondProduct; - /** @var ECommerceCart */ - private $firstCart; + private ECommerceCart $firstCart; - /** @var ECommerceCart */ - private $secondCart; + private ECommerceCart $secondCart; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php index 5b66f934ee5..d6bbda236dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php @@ -21,8 +21,7 @@ */ class ManyToOneOrphanRemovalTest extends OrmFunctionalTestCase { - /** @var int */ - private $personId; + private int $personId; /** @var array> */ protected static $modelSets = [ diff --git a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php index 0e19921739e..8e56d4d0d70 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php @@ -42,7 +42,7 @@ public function testCRUD(): void $this->_em->flush(); $this->_em->clear(); - $cleanFile = $this->_em->find(get_class($file), $file->getId()); + $cleanFile = $this->_em->find($file::class, $file->getId()); self::assertInstanceOf(Directory::class, $cleanFile->getParent()); self::assertInstanceOf(Proxy::class, $cleanFile->getParent()); diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 7a98e6c9ad9..04fd120957a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -31,8 +31,7 @@ class NativeQueryTest extends OrmFunctionalTestCase use SQLResultCasing; use VerifyDeprecations; - /** @var AbstractPlatform */ - private $platform = null; + private ?AbstractPlatform $platform = null; protected function setUp(): void { @@ -339,7 +338,7 @@ public function testAbstractClassInSingleTableInheritanceSchemaWithRSMBuilderThr public function testRSMBuilderThrowsExceptionOnColumnConflict(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $rsm = new ResultSetMappingBuilder($this->_em); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u'); $rsm->addJoinedEntityFromClassMetadata(CmsAddress::class, 'a', 'u', 'address'); diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php index 624ff5f25c4..a8a54679600 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddressDTO; @@ -988,7 +989,7 @@ public function testShouldSupportMultipleNewOperatorsAndMultipleScalarsWithAndWi public function testInvalidClassException(): void { - $this->expectException('Doctrine\ORM\Query\QueryException'); + $this->expectException(QueryException::class); $this->expectExceptionMessage('[Semantical Error] line 0, col 11 near \'\InvalidClass(u.name)\': Error: Class "\InvalidClass" is not defined.'); $dql = 'SELECT new \InvalidClass(u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u'; $this->_em->createQuery($dql)->getResult(); @@ -996,7 +997,7 @@ public function testInvalidClassException(): void public function testInvalidClassConstructorException(): void { - $this->expectException('Doctrine\ORM\Query\QueryException'); + $this->expectException(QueryException::class); $this->expectExceptionMessage('[Semantical Error] line 0, col 11 near \'\stdClass(u.name)\': Error: Class "\stdClass" has not a valid constructor.'); $dql = 'SELECT new \stdClass(u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u'; $this->_em->createQuery($dql)->getResult(); @@ -1004,7 +1005,7 @@ public function testInvalidClassConstructorException(): void public function testInvalidClassWithoutConstructorException(): void { - $this->expectException('Doctrine\ORM\Query\QueryException'); + $this->expectException(QueryException::class); $this->expectExceptionMessage('[Semantical Error] line 0, col 11 near \'Doctrine\Tests\ORM\Functional\ClassWithTooMuchArgs(u.name)\': Error: Number of arguments does not match with "Doctrine\Tests\ORM\Functional\ClassWithTooMuchArgs" constructor declaration.'); $dql = 'SELECT new Doctrine\Tests\ORM\Functional\ClassWithTooMuchArgs(u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u'; $this->_em->createQuery($dql)->getResult(); @@ -1012,7 +1013,7 @@ public function testInvalidClassWithoutConstructorException(): void public function testClassCantBeInstantiatedException(): void { - $this->expectException('Doctrine\ORM\Query\QueryException'); + $this->expectException(QueryException::class); $this->expectExceptionMessage('[Semantical Error] line 0, col 11 near \'Doctrine\Tests\ORM\Functional\ClassWithPrivateConstructor(u.name)\': Error: Class "Doctrine\Tests\ORM\Functional\ClassWithPrivateConstructor" can not be instantiated.'); $dql = 'SELECT new Doctrine\Tests\ORM\Functional\ClassWithPrivateConstructor(u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u'; $this->_em->createQuery($dql)->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index 2cba6c02a71..7f56bf2929d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -124,18 +124,16 @@ protected function onPropertyChanged($propName, $oldValue, $newValue): void class NotifyUser extends NotifyBaseEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column */ - private $name; + private ?string $name = null; /** * @psalm-var Collection @@ -177,18 +175,16 @@ public function getGroups(): Collection class NotifyGroup extends NotifyBaseEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column */ - private $name; + private ?string $name = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index dc3dd0991bd..447d3baa661 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -16,14 +16,11 @@ */ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase { - /** @var ECommerceProduct */ - private $product; + private ECommerceProduct $product; - /** @var ECommerceFeature */ - private $firstFeature; + private ECommerceFeature $firstFeature; - /** @var ECommerceFeature */ - private $secondFeature; + private ECommerceFeature $secondFeature; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php index dec20df94c9..a4ae5628bc6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php @@ -15,14 +15,11 @@ */ class OneToManySelfReferentialAssociationTest extends OrmFunctionalTestCase { - /** @var ECommerceCategory */ - private $parent; + private ECommerceCategory $parent; - /** @var ECommerceCategory */ - private $firstChild; + private ECommerceCategory $firstChild; - /** @var ECommerceCategory */ - private $secondChild; + private ECommerceCategory $secondChild; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php index 7ee8836e9ef..450292bcdc3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php @@ -15,11 +15,9 @@ */ class OneToOneBidirectionalAssociationTest extends OrmFunctionalTestCase { - /** @var ECommerceCustomer */ - private $customer; + private ECommerceCustomer $customer; - /** @var ECommerceCart */ - private $cart; + private ECommerceCart $cart; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 6473b02ff99..12d20dcbd16 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -54,7 +54,7 @@ public function testEagerLoadOneToOneOwningSide(): void $this->getQueryLog()->reset()->enable(); - $train = $this->_em->find(get_class($train), $train->id); + $train = $this->_em->find($train::class, $train->id); self::assertNotInstanceOf(Proxy::class, $train->driver); self::assertEquals('Benjamin', $train->driver->name); @@ -74,7 +74,7 @@ public function testEagerLoadOneToOneNullOwningSide(): void $this->getQueryLog()->reset()->enable(); - $train = $this->_em->find(get_class($train), $train->id); + $train = $this->_em->find($train::class, $train->id); self::assertNotInstanceOf(Proxy::class, $train->driver); self::assertNull($train->driver); @@ -95,7 +95,7 @@ public function testEagerLoadOneToOneInverseSide(): void $this->getQueryLog()->reset()->enable(); - $driver = $this->_em->find(get_class($owner), $owner->id); + $driver = $this->_em->find($owner::class, $owner->id); self::assertNotInstanceOf(Proxy::class, $owner->train); self::assertNotNull($owner->train); @@ -117,7 +117,7 @@ public function testEagerLoadOneToOneNullInverseSide(): void $this->getQueryLog()->reset()->enable(); - $driver = $this->_em->find(get_class($driver), $driver->id); + $driver = $this->_em->find($driver::class, $driver->id); self::assertNotInstanceOf(Proxy::class, $driver->train); self::assertNull($driver->train); @@ -134,7 +134,7 @@ public function testEagerLoadManyToOne(): void $this->_em->flush(); $this->_em->clear(); - $waggon = $this->_em->find(get_class($waggon), $waggon->id); + $waggon = $this->_em->find($waggon::class, $waggon->id); self::assertNotInstanceOf(Proxy::class, $waggon->train); self::assertNotNull($waggon->train); } @@ -152,14 +152,14 @@ public function testEagerLoadWithNullableColumnsGeneratesLeftJoinOnBothSides(): $this->_em->flush(); $this->_em->clear(); - $train = $this->_em->find(get_class($train), $train->id); + $train = $this->_em->find($train::class, $train->id); $this->assertSQLEquals( 'SELECT t0.id AS id_1, t0.driver_id AS driver_id_2, t3.id AS id_4, t3.name AS name_5, t0.owner_id AS owner_id_6, t7.id AS id_8, t7.name AS name_9 FROM Train t0 LEFT JOIN TrainDriver t3 ON t0.driver_id = t3.id INNER JOIN TrainOwner t7 ON t0.owner_id = t7.id WHERE t0.id = ?', $this->getLastLoggedQuery()['sql'] ); $this->_em->clear(); - $driver = $this->_em->find(get_class($driver), $driver->id); + $driver = $this->_em->find($driver::class, $driver->id); $this->assertSQLEquals( 'SELECT t0.id AS id_1, t0.name AS name_2, t3.id AS id_4, t3.driver_id AS driver_id_5, t3.owner_id AS owner_id_6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id IN (?)', $this->getLastLoggedQuery()['sql'] @@ -181,7 +181,7 @@ public function testEagerLoadWithNonNullableColumnsGeneratesInnerJoinOnOwningSid $this->_em->flush(); $this->_em->clear(); - $waggon = $this->_em->find(get_class($waggon), $waggon->id); + $waggon = $this->_em->find($waggon::class, $waggon->id); // The last query is the eager loading of the owner of the train $this->assertSQLEquals( @@ -207,7 +207,7 @@ public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningS $this->_em->flush(); $this->_em->clear(); - $waggon = $this->_em->find(get_class($owner), $owner->id); + $waggon = $this->_em->find($owner::class, $owner->id); $this->assertSQLEquals( 'SELECT t0.id AS id_1, t0.name AS name_2, t3.id AS id_4, t3.driver_id AS driver_id_5, t3.owner_id AS owner_id_6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id = ?', $this->getLastLoggedQuery()['sql'] @@ -308,12 +308,6 @@ class TrainDriver */ public $id; - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - /** * Inverse side * @@ -322,9 +316,16 @@ class TrainDriver */ public $train; - public function __construct($name) + /** + * @param string $name + */ + public function __construct( + /** + * @Column(type="string", length=255) + */ + public $name + ) { - $this->name = $name; } public function setTrain(Train $t): void @@ -346,12 +347,6 @@ class TrainOwner */ public $id; - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - /** * Inverse side * @@ -360,9 +355,13 @@ class TrainOwner */ public $train; - public function __construct(string $name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public string $name + ) { - $this->name = $name; } public function setTrain(Train $t): void @@ -409,14 +408,12 @@ class TrainOrder */ public $id; - /** - * @var Train - * @OneToOne(targetEntity="Train", fetch="EAGER") - */ - public $train; - - public function __construct(Train $train) + public function __construct( + /** + * @OneToOne(targetEntity="Train", fetch="EAGER") + */ + public Train $train + ) { - $this->train = $train; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php index 7b1fec871af..88773b804cd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php @@ -22,7 +22,7 @@ protected function setUp(): void $this->_em->getClassMetadata(OwningSide::class), $this->_em->getClassMetadata(InverseSide::class), ]); - } catch (ToolsException $e) { + } catch (ToolsException) { // ignored } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index f82d81a596b..654229314c5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -26,11 +26,9 @@ */ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase { - /** @var ECommerceCustomer */ - private $customer; + private ECommerceCustomer $customer; - /** @var ECommerceCustomer */ - private $mentor; + private ECommerceCustomer $mentor; protected function setUp(): void { @@ -110,7 +108,7 @@ public function testMultiSelfReference(): void $this->_em->clear(); - $entity2 = $this->_em->find(get_class($entity1), $entity1->getId()); + $entity2 = $this->_em->find($entity1::class, $entity1->getId()); self::assertInstanceOf(MultiSelfReference::class, $entity2->getOther1()); self::assertInstanceOf(MultiSelfReference::class, $entity2->getOther2()); @@ -155,26 +153,23 @@ private function createFixture(): int class MultiSelfReference { /** - * @var int * @Id * @GeneratedValue(strategy="AUTO") * @Column(type="integer") */ - private $id; + private int $id; /** - * @var MultiSelfReference|null * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) * @JoinColumn(name="other1", referencedColumnName="id") */ - private $other1; + private ?\Doctrine\Tests\ORM\Functional\MultiSelfReference $other1 = null; /** - * @var MultiSelfReference|null * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) * @JoinColumn(name="other2", referencedColumnName="id") */ - private $other2; + private ?\Doctrine\Tests\ORM\Functional\MultiSelfReference $other2 = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index f9eb49724c2..ccc72f81b8c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -18,11 +18,9 @@ */ class OneToOneUnidirectionalAssociationTest extends OrmFunctionalTestCase { - /** @var ECommerceProduct */ - private $product; + private ECommerceProduct $product; - /** @var ECommerceShipping */ - private $shipping; + private ECommerceShipping $shipping; protected function setUp(): void { @@ -127,7 +125,7 @@ public function testNullForeignKey(): void $this->_em->persist($product); $this->_em->flush(); - $product = $this->_em->find(get_class($product), $product->getId()); + $product = $this->_em->find($product::class, $product->getId()); self::assertNull($product->getShipping()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index 571ad0a12ce..8efca51826e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -4,6 +4,14 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TreeWalkerAdapter; +use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\AST\ConditionalPrimary; +use Doctrine\ORM\Query\AST\PathExpression; +use Doctrine\ORM\Query\AST\ComparisonExpression; +use Doctrine\ORM\Query\AST\Literal; +use Doctrine\ORM\Query\AST\WhereClause; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\Query; use Doctrine\ORM\Tools\Pagination\Paginator; @@ -614,7 +622,7 @@ public function testDetectOutputWalker(): void // If the Paginator detects the custom output walker it should fall back to using the // Tree walkers for pagination, which leads to an exception. If the query works, the output walkers were used - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, Query\SqlWalker::class); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, SqlWalker::class); $paginator = new Paginator($query); $this->expectException(RuntimeException::class); @@ -702,7 +710,7 @@ public function testCountQueryStripsParametersInSelect(): void self::assertCount(2, $getCountQuery->invoke($paginator)->getParameters()); self::assertCount(9, $paginator); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, Query\SqlWalker::class); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, SqlWalker::class); $paginator = new Paginator($query); @@ -835,21 +843,21 @@ public function useOutputWalkersAndFetchJoinCollection(): array } } -class CustomPaginationTestTreeWalker extends Query\TreeWalkerAdapter +class CustomPaginationTestTreeWalker extends TreeWalkerAdapter { - public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): void + public function walkSelectStatement(SelectStatement $selectStatement): void { - $condition = new Query\AST\ConditionalPrimary(); + $condition = new ConditionalPrimary(); - $path = new Query\AST\PathExpression(Query\AST\PathExpression::TYPE_STATE_FIELD, 'u', 'name'); - $path->type = Query\AST\PathExpression::TYPE_STATE_FIELD; + $path = new PathExpression(PathExpression::TYPE_STATE_FIELD, 'u', 'name'); + $path->type = PathExpression::TYPE_STATE_FIELD; - $condition->simpleConditionalExpression = new Query\AST\ComparisonExpression( + $condition->simpleConditionalExpression = new ComparisonExpression( $path, '=', - new Query\AST\Literal(Query\AST\Literal::STRING, 'Name1') + new Literal(Literal::STRING, 'Name1') ); - $selectStatement->whereClause = new Query\AST\WhereClause($condition); + $selectStatement->whereClause = new WhereClause($condition); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php index 2dc289314b5..4cc6a623ef3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php @@ -15,8 +15,7 @@ */ class PostFlushEventTest extends OrmFunctionalTestCase { - /** @var PostFlushListener */ - private $listener; + private \Doctrine\Tests\ORM\Functional\PostFlushListener $listener; protected function setUp(): void { @@ -43,7 +42,7 @@ public function testListenerShouldNotBeNotifiedWhenFlushThrowsException(): void try { $this->_em->flush(); - } catch (Exception $ex) { + } catch (Exception) { $exceptionRaised = true; } diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php index 0bf84cbe68c..637d52df197 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php @@ -16,8 +16,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase { - /** @var int */ - private $userId; + private ?int $userId = null; protected function setUp(): void { @@ -301,7 +300,7 @@ public function postLoad(LifecycleEventArgs $event): void class PostLoadListenerLoadEntityInEventHandler { /** @psalm-var array */ - private $firedByClasses = []; + private array $firedByClasses = []; public function postLoad(LifecycleEventArgs $event): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index 1d6654ac02d..b4e08ba47cf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -31,7 +31,7 @@ public function testAggregateSum(): void $salarySum = $this->_em->createQuery('SELECT SUM(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getSingleResult(); - self::assertEquals(1500000, $salarySum['salary']); + self::assertEquals(1_500_000, $salarySum['salary']); } public function testAggregateAvg(): void @@ -245,7 +245,7 @@ public function testOperatorMultiply(): void self::assertEquals(200000, $result[0]['op']); self::assertEquals(400000, $result[1]['op']); self::assertEquals(800000, $result[2]['op']); - self::assertEquals(1600000, $result[3]['op']); + self::assertEquals(1_600_000, $result[3]['op']); } /** @@ -260,7 +260,7 @@ public function testOperatorDiv(): void self::assertEquals(200000, $result[0]['op']); self::assertEquals(400000, $result[1]['op']); self::assertEquals(800000, $result[2]['op']); - self::assertEquals(1600000, $result[3]['op']); + self::assertEquals(1_600_000, $result[3]['op']); } public function testConcatFunction(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 9809d8931b2..01a1951ab24 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\NoResultException; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\NonUniqueResultException; @@ -418,21 +419,21 @@ public function testToIterableResultFetchJoinedCollectionThrowsException(): void public function testGetSingleResultThrowsExceptionOnNoResult(): void { - $this->expectException('Doctrine\ORM\NoResultException'); + $this->expectException(NoResultException::class); $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a') ->getSingleResult(); } public function testGetSingleScalarResultThrowsExceptionOnNoResult(): void { - $this->expectException('Doctrine\ORM\NoResultException'); + $this->expectException(NoResultException::class); $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a') ->getSingleScalarResult(); } public function testGetSingleScalarResultThrowsExceptionOnNonUniqueResult(): void { - $this->expectException('Doctrine\ORM\NonUniqueResultException'); + $this->expectException(NonUniqueResultException::class); $user = new CmsUser(); $user->name = 'Guilherme'; $user->username = 'gblanco'; @@ -855,7 +856,7 @@ public function testUnexpectedResultException(): void $this->_em->createQuery($dql)->getSingleResult(); self::fail('Expected exception "\Doctrine\ORM\NoResultException".'); } catch (UnexpectedResultException $exc) { - self::assertInstanceOf('\Doctrine\ORM\NoResultException', $exc); + self::assertInstanceOf(NoResultException::class, $exc); } $this->_em->persist($u1); @@ -867,7 +868,7 @@ public function testUnexpectedResultException(): void $this->_em->createQuery($dql)->getSingleResult(); self::fail('Expected exception "\Doctrine\ORM\NonUniqueResultException".'); } catch (UnexpectedResultException $exc) { - self::assertInstanceOf('\Doctrine\ORM\NonUniqueResultException', $exc); + self::assertInstanceOf(NonUniqueResultException::class, $exc); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 27c7f1ff5ea..5ab92cba2ae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -149,20 +149,21 @@ class ReadOnlyEntity * @var int */ public $id; + /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - /** - * @var int - * @Column(type="integer") + * @param string $name + * @param int $number */ - public $numericValue; - - public function __construct($name, $number) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public $name, + /** + * @Column(type="integer") + */ + public $numericValue + ) { - $this->name = $name; - $this->numericValue = $number; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php index 604c432b2af..0fa89e2cb93 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php @@ -72,7 +72,7 @@ public function testAccessMetatadaForProxy(): void $id = $this->createProduct(); $entity = $this->_em->getReference(ECommerceProduct::class, $id); - $class = $this->_em->getClassMetadata(get_class($entity)); + $class = $this->_em->getClassMetadata($entity::class); self::assertEquals(ECommerceProduct::class, $class->name); } @@ -243,8 +243,8 @@ public function testCommonPersistenceProxy(): void self::assertFalse($entity->__isInitialized()); self::assertEquals(ECommerceProduct::class, $className); - $restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), '', get_class($entity)); - $restName = substr(get_class($entity), strlen($this->_em->getConfiguration()->getProxyNamespace()) + 1); + $restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), '', $entity::class); + $restName = substr($entity::class, strlen($this->_em->getConfiguration()->getProxyNamespace()) + 1); $proxyFileName = $this->_em->getConfiguration()->getProxyDir() . DIRECTORY_SEPARATOR . str_replace('\\', '', $restName) . '.php'; self::assertTrue(file_exists($proxyFileName), 'Proxy file name cannot be found generically.'); diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 8687074bd07..2c3e3efb718 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -98,7 +98,7 @@ public function testEntityManagerEnableFilter(): void $exceptionThrown = false; try { $filter = $em->getFilters()->enable('foo'); - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { $exceptionThrown = true; } @@ -136,7 +136,7 @@ public function testEntityManagerDisableFilter(): void $exceptionThrown = false; try { $filter = $em->getFilters()->disable('foo'); - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { $exceptionThrown = true; } @@ -146,7 +146,7 @@ public function testEntityManagerDisableFilter(): void $exceptionThrown = false; try { $filter = $em->getFilters()->disable('locale'); - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { $exceptionThrown = true; } @@ -168,7 +168,7 @@ public function testEntityManagerGetFilter(): void $exceptionThrown = false; try { $filter = $em->getFilters()->getFilter('soft_delete'); - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { $exceptionThrown = true; } @@ -314,9 +314,7 @@ public function testSQLFilterSetArrayParameterInfersType(): void // Setup mock connection $conn = $this->getMockConnection(); $conn->method('quote') - ->will(self::returnCallback(static function ($value) { - return "'" . $value . "'"; - })); + ->will(self::returnCallback(static fn($value) => "'" . $value . "'")); $em = $this->getMockEntityManager(); $em->method('getConnection') diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 908ca790298..0f84bd6e050 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; +use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; @@ -16,8 +17,7 @@ class DBAL483Test extends OrmFunctionalTestCase { - /** @var Tools\SchemaTool */ - private $schemaTool; + private SchemaTool $schemaTool; protected function setUp(): void { @@ -25,7 +25,7 @@ protected function setUp(): void $this->_em->getConnection(); - $this->schemaTool = new Tools\SchemaTool($this->_em); + $this->schemaTool = new SchemaTool($this->_em); } /** @@ -39,9 +39,7 @@ public function testDefaultValueIsComparedCorrectly(): void $updateSql = $this->schemaTool->getUpdateSchemaSql([$class]); - $updateSql = array_filter($updateSql, static function ($sql) { - return str_contains($sql, 'DBAL483'); - }); + $updateSql = array_filter($updateSql, static fn($sql) => str_contains($sql, 'DBAL483')); self::assertCount(0, $updateSql); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 32c3cad6956..eea653c65d8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -4,6 +4,21 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; +use Doctrine\ORM\Tools\SchemaTool; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsEmail; +use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyManager; +use Doctrine\Tests\Models\Company\CompanyOrganization; +use Doctrine\Tests\Models\Company\CompanyEvent; +use Doctrine\Tests\Models\Company\CompanyAuction; +use Doctrine\Tests\Models\Company\CompanyRaffle; +use Doctrine\Tests\Models\Company\CompanyCar; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\ORM\Tools; use Doctrine\Tests\Models; @@ -22,10 +37,9 @@ class DDC214Test extends OrmFunctionalTestCase { /** @psalm-var list */ - private $classes = []; + private array $classes = []; - /** @var Tools\SchemaTool */ - private $schemaTool = null; + private ?SchemaTool $schemaTool = null; protected function setUp(): void { @@ -37,7 +51,7 @@ protected function setUp(): void self::markTestSkipped('SQLite does not support ALTER TABLE statements.'); } - $this->schemaTool = new Tools\SchemaTool($this->_em); + $this->schemaTool = new SchemaTool($this->_em); } /** @@ -46,12 +60,12 @@ protected function setUp(): void public function testCmsAddressModel(): void { $this->classes = [ - Models\CMS\CmsUser::class, - Models\CMS\CmsPhonenumber::class, - Models\CMS\CmsAddress::class, - Models\CMS\CmsGroup::class, - Models\CMS\CmsArticle::class, - Models\CMS\CmsEmail::class, + CmsUser::class, + CmsPhonenumber::class, + CmsAddress::class, + CmsGroup::class, + CmsArticle::class, + CmsEmail::class, ]; $this->assertCreatedSchemaNeedsNoUpdates($this->classes); @@ -63,14 +77,14 @@ public function testCmsAddressModel(): void public function testCompanyModel(): void { $this->classes = [ - Models\Company\CompanyPerson::class, - Models\Company\CompanyEmployee::class, - Models\Company\CompanyManager::class, - Models\Company\CompanyOrganization::class, - Models\Company\CompanyEvent::class, - Models\Company\CompanyAuction::class, - Models\Company\CompanyRaffle::class, - Models\Company\CompanyCar::class, + CompanyPerson::class, + CompanyEmployee::class, + CompanyManager::class, + CompanyOrganization::class, + CompanyEvent::class, + CompanyAuction::class, + CompanyRaffle::class, + CompanyCar::class, ]; $this->assertCreatedSchemaNeedsNoUpdates($this->classes); @@ -85,7 +99,7 @@ public function assertCreatedSchemaNeedsNoUpdates($classes): void try { $this->schemaTool->createSchema($classMetadata); - } catch (Exception $e) { + } catch (Exception) { // was already created } @@ -97,9 +111,7 @@ public function assertCreatedSchemaNeedsNoUpdates($classes): void $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); $sql = $schemaDiff->toSql($this->_em->getConnection()->getDatabasePlatform()); - $sql = array_filter($sql, static function ($sql) { - return ! str_contains($sql, 'DROP'); - }); + $sql = array_filter($sql, static fn($sql) => ! str_contains($sql, 'DROP')); self::assertCount(0, $sql, 'SQL: ' . implode(PHP_EOL, $sql)); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index e9a21d06dab..a664d363697 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -4,6 +4,14 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\CMS\CmsTag; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsEmail; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\Generic\DecimalModel; +use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -27,12 +35,12 @@ protected function setUp(): void public function testGetCreateSchemaSql(): void { $classes = [ - $this->_em->getClassMetadata(Models\CMS\CmsGroup::class), - $this->_em->getClassMetadata(Models\CMS\CmsUser::class), - $this->_em->getClassMetadata(Models\CMS\CmsTag::class), - $this->_em->getClassMetadata(Models\CMS\CmsAddress::class), - $this->_em->getClassMetadata(Models\CMS\CmsEmail::class), - $this->_em->getClassMetadata(Models\CMS\CmsPhonenumber::class), + $this->_em->getClassMetadata(CmsGroup::class), + $this->_em->getClassMetadata(CmsUser::class), + $this->_em->getClassMetadata(CmsTag::class), + $this->_em->getClassMetadata(CmsAddress::class), + $this->_em->getClassMetadata(CmsEmail::class), + $this->_em->getClassMetadata(CmsPhonenumber::class), ]; $tool = new SchemaTool($this->_em); @@ -69,7 +77,7 @@ public function testGetCreateSchemaSql(): void public function testGetCreateSchemaSql2(): void { - $classes = [$this->_em->getClassMetadata(Models\Generic\DecimalModel::class)]; + $classes = [$this->_em->getClassMetadata(DecimalModel::class)]; $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); @@ -80,7 +88,7 @@ public function testGetCreateSchemaSql2(): void public function testGetCreateSchemaSql3(): void { - $classes = [$this->_em->getClassMetadata(Models\Generic\BooleanModel::class)]; + $classes = [$this->_em->getClassMetadata(BooleanModel::class)]; $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index 0e5dec78d24..7b114b7a6e5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -4,6 +4,11 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\Generic\DecimalModel; +use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -34,7 +39,7 @@ protected function setUp(): void public function testPostgresMetadataSequenceIncrementedBy10(): void { - $address = $this->_em->getClassMetadata(Models\CMS\CmsAddress::class); + $address = $this->_em->getClassMetadata(CmsAddress::class); self::assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); } @@ -53,9 +58,7 @@ public function testUpdateSchemaWithPostgreSQLSchema(): void $tool->createSchema($classes); $sql = $tool->getUpdateSchemaSql($classes); - $sql = array_filter($sql, static function ($sql) { - return str_starts_with($sql, 'DROP SEQUENCE stonewood.'); - }); + $sql = array_filter($sql, static fn($sql) => str_starts_with($sql, 'DROP SEQUENCE stonewood.')); self::assertCount(0, $sql, implode("\n", $sql)); } @@ -70,28 +73,25 @@ class DDC1657Screen /** * Identifier * - * @var int * @Id * @GeneratedValue(strategy="IDENTITY") * @Column(name="pk", type="integer", nullable=false) */ - private $pk; + private int $pk; /** * Title * - * @var string * @Column(name="title", type="string", length=255, nullable=false) */ - private $title; + private string $title; /** * Path * - * @var string * @Column(name="path", type="string", length=255, nullable=false) */ - private $path; + private string $path; /** * Register date @@ -120,10 +120,9 @@ class DDC1657Avatar /** * Identifier * - * @var int * @Id * @GeneratedValue(strategy="IDENTITY") * @Column(name="pk", type="integer", nullable=false) */ - private $pk; + private int $pk; } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php index 101bbfb7f42..dd0291f61ff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php @@ -130,12 +130,8 @@ public function testBasicConcurrentCollectionReadLock(): void class CacheFactorySecondLevelCacheConcurrentTest extends DefaultCacheFactory { - /** @var CacheItemPoolInterface */ - private $cache; - - public function __construct(CacheItemPoolInterface $cache) + public function __construct(private CacheItemPoolInterface $cache) { - $this->cache = $cache; } public function getRegion(array $cache): ConcurrentRegionMock diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php index 5dcd8ae2eef..5aa864086d7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php @@ -56,7 +56,7 @@ public function testJoinTableCountaisRootClass(): void foreach ($this->attractionsInfo as $info) { self::assertTrue($this->cache->containsEntity(AttractionInfo::class, $info->getId())); - self::assertTrue($this->cache->containsEntity(get_class($info), $info->getId())); + self::assertTrue($this->cache->containsEntity($info::class, $info->getId())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index f66de809285..616c1d3ac02 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Cache\QueryCacheEntry; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Cache; use Doctrine\ORM\Cache\EntityCacheEntry; @@ -832,7 +833,7 @@ public function testQueryCacheLifetime(): void ->getRegion() ->get($key); - self::assertInstanceOf(Cache\QueryCacheEntry::class, $entry); + self::assertInstanceOf(QueryCacheEntry::class, $entry); $entry->time /= 2; $this->cache->getQueryCache() diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php index 5f8c8e94bb0..ee1492b586e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php @@ -55,7 +55,7 @@ public function testCountaisRootClass(): void foreach ($this->attractions as $attraction) { self::assertTrue($this->cache->containsEntity(Attraction::class, $attraction->getId())); - self::assertTrue($this->cache->containsEntity(get_class($attraction), $attraction->getId())); + self::assertTrue($this->cache->containsEntity($attraction::class, $attraction->getId())); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php index f956fbbcc9a..c987c54abd3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php @@ -339,15 +339,12 @@ public function testCachedNewEntityExists(): void class ListenerSecondLevelCacheTest { - /** @var array */ - public $callbacks; - /** * @psalm-param array $callbacks + * @param array $callbacks */ - public function __construct(array $callbacks = []) + public function __construct(public array $callbacks = []) { - $this->callbacks = $callbacks; } private function dispatch(string $eventName, EventArgs $args): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php index af7e22d2982..07d13b6ea4c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php @@ -45,18 +45,16 @@ public function testPreSavePostSaveCallbacksAreInvoked(): void class SequenceEmulatedIdentityEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="IDENTITY") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255) */ - private $value; + private ?string $value = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php index 61357a4c6fe..3fdeecd70f5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -21,20 +21,16 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase { - /** @var CompanyEmployee */ - private $salesPerson; + private ?CompanyEmployee $salesPerson = null; /** @var list */ - private $engineers = []; + private array $engineers = []; - /** @var CompanyFixContract */ - private $fix; + private ?CompanyFixContract $fix = null; - /** @var CompanyFlexContract */ - private $flex; + private ?CompanyFlexContract $flex = null; - /** @var CompanyFlexUltraContract */ - private $ultra; + private ?CompanyFlexUltraContract $ultra = null; protected function setUp(): void { @@ -243,9 +239,7 @@ public function testQueryScalarWithDiscriminatorValue(): void $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c ORDER BY c.id')->getScalarResult(); - $discrValues = array_map(static function ($a) { - return $a['c_discr']; - }, $contracts); + $discrValues = array_map(static fn($a) => $a['c_discr'], $contracts); sort($discrValues); @@ -330,10 +324,10 @@ public function testDeleteJoinTableRecords(): void $this->loadFullFixture(); // remove managed copy of the fix contract - $this->_em->remove($this->_em->find(get_class($this->fix), $this->fix->getId())); + $this->_em->remove($this->_em->find($this->fix::class, $this->fix->getId())); $this->_em->flush(); - self::assertNull($this->_em->find(get_class($this->fix), $this->fix->getId()), 'Contract should not be present in the database anymore.'); + self::assertNull($this->_em->find($this->fix::class, $this->fix->getId()), 'Contract should not be present in the database anymore.'); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php index 7769a883882..e805faff06f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\Tests\Models\Company\CompanyFixContract; +use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; @@ -20,7 +22,7 @@ protected function setUp(): void public function testGrabWrongSubtypeReturnsNull(): void { - $fix = new Models\Company\CompanyFixContract(); + $fix = new CompanyFixContract(); $fix->setFixPrice(2000); $this->_em->persist($fix); @@ -28,8 +30,8 @@ public function testGrabWrongSubtypeReturnsNull(): void $id = $fix->getId(); - self::assertNull($this->_em->find(Models\Company\CompanyFlexContract::class, $id)); - self::assertNull($this->_em->getReference(Models\Company\CompanyFlexContract::class, $id)); - self::assertNull($this->_em->getPartialReference(Models\Company\CompanyFlexContract::class, $id)); + self::assertNull($this->_em->find(CompanyFlexContract::class, $id)); + self::assertNull($this->_em->getReference(CompanyFlexContract::class, $id)); + self::assertNull($this->_em->getPartialReference(CompanyFlexContract::class, $id)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index affdf532590..2bcdfa500f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -26,11 +26,9 @@ */ class DDC1163Test extends OrmFunctionalTestCase { - /** @var int|null */ - private $productId; + private ?int $productId = null; - /** @var int|null */ - private $proxyHolderId; + private ?int $proxyHolderId = null; protected function setUp(): void { @@ -103,7 +101,7 @@ private function setPropertyAndAssignTagToSpecialProduct(): void // this screams violation of law of demeter ;) self::assertEquals( DDC1163SpecialProduct::class, - $this->_em->getUnitOfWork()->getEntityPersister(get_class($specialProduct))->getClassMetadata()->name + $this->_em->getUnitOfWork()->getEntityPersister($specialProduct::class)->getClassMetadata()->name ); $tag = new DDC1163Tag('Foo'); @@ -118,18 +116,16 @@ private function setPropertyAndAssignTagToSpecialProduct(): void class DDC1163ProxyHolder { /** - * @var int * @Column(name="id", type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var DDC1163SpecialProduct * @OneToOne(targetEntity="DDC1163SpecialProduct") */ - private $specialProduct; + private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1163SpecialProduct $specialProduct = null; public function getId(): int { @@ -175,10 +171,9 @@ public function getId(): int class DDC1163SpecialProduct extends DDC1163Product { /** - * @var string * @Column(name="subclass_property", type="string", nullable=true) */ - private $subclassProperty; + private ?string $subclassProperty = null; public function setSubclassProperty(string $value): void { @@ -192,17 +187,11 @@ public function setSubclassProperty(string $value): void class DDC1163Tag { /** - * @var int * @Column(name="id", type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; - /** - * @var string - * @Column(name="name", type="string", length=255) - */ - private $name; + private int $id; /** * @var Product * @ManyToOne(targetEntity="DDC1163Product", inversedBy="tags") @@ -212,9 +201,13 @@ class DDC1163Tag */ private $product; - public function __construct(string $name) + public function __construct( + /** + * @Column(name="name", type="string", length=255) + */ + private string $name + ) { - $this->name = $name; } public function setProduct(DDC1163Product $product): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php index 883e8108eab..d6dd01b0cc1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -27,20 +27,15 @@ class DDC117Test extends OrmFunctionalTestCase { use VerifyDeprecations; - /** @var DDC117Article */ - private $article1; + private ?DDC117Article $article1; - /** @var DDC117Article */ - private $article2; + private ?DDC117Article $article2; - /** @var DDC117Reference */ - private $reference; + private DDC117Reference $reference; - /** @var DDC117Translation */ - private $translation; + private ?DDC117Translation $translation; - /** @var DDC117ArticleDetails */ - private $articleDetails; + private DDC117ArticleDetails $articleDetails; protected function setUp(): void { @@ -259,7 +254,7 @@ public function testOneToOneForeignObjectId(): void $this->_em->flush(); $this->_em->clear(); - $article = $this->_em->find(get_class($this->article1), $this->article1->id()); + $article = $this->_em->find($this->article1::class, $this->article1->id()); assert($article instanceof DDC117Article); self::assertEquals('not so very long text!', $article->getText()); } @@ -269,7 +264,7 @@ public function testOneToOneForeignObjectId(): void */ public function testOneToOneCascadeRemove(): void { - $article = $this->_em->find(get_class($this->article1), $this->article1->id()); + $article = $this->_em->find($this->article1::class, $this->article1->id()); $this->_em->remove($article); $this->_em->flush(); @@ -318,7 +313,7 @@ public function testReferencesToForeignKeyEntities(): void */ public function testLoadOneToManyCollectionOfForeignKeyEntities(): void { - $article = $this->_em->find(get_class($this->article1), $this->article1->id()); + $article = $this->_em->find($this->article1::class, $this->article1->id()); assert($article instanceof DDC117Article); $translations = $article->getTranslations(); @@ -358,7 +353,7 @@ public function testClearManyToManyCollectionOfForeignKeyEntities(): void $this->_em->flush(); $this->_em->clear(); - $editor = $this->_em->find(get_class($editor), $editor->id); + $editor = $this->_em->find($editor::class, $editor->id); self::assertCount(0, $editor->reviewingTranslations); } @@ -400,7 +395,7 @@ public function testLoadOneToManyOfSourceEntityWithAssociationIdentifier(): void $this->_em->flush(); $this->_em->clear(); - $editor = $this->_em->find(get_class($editor), $editor->id); + $editor = $this->_em->find($editor::class, $editor->id); $lastTranslatedBy = $editor->reviewingTranslations[0]->getLastTranslatedBy(); $lastTranslatedBy->count(); @@ -411,13 +406,13 @@ private function loadEditorFixture(): DDC117Editor { $editor = new DDC117Editor('beberlei'); - $article1 = $this->_em->find(get_class($this->article1), $this->article1->id()); + $article1 = $this->_em->find($this->article1::class, $this->article1->id()); assert($article1 instanceof DDC117Article); foreach ($article1->getTranslations() as $translation) { $editor->reviewingTranslations[] = $translation; } - $article2 = $this->_em->find(get_class($this->article2), $this->article2->id()); + $article2 = $this->_em->find($this->article2::class, $this->article2->id()); assert($article2 instanceof DDC117Article); $article2->addTranslation('de', 'Vanille-Krapferl'); // omnomnom $article2->addTranslation('fr', "Sorry can't speak french!"); @@ -431,7 +426,7 @@ private function loadEditorFixture(): DDC117Editor $this->_em->flush(); $this->_em->clear(); - return $this->_em->find(get_class($editor), $editor->id); + return $this->_em->find($editor::class, $editor->id); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index fb8fa3b1a94..eb0e4795f5f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -46,7 +46,7 @@ public function testIssue(): void $companyId = $company->id; $this->_em->clear(); - $company = $this->_em->find(get_class($company), $companyId); + $company = $this->_em->find($company::class, $companyId); self::assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), 'Company is in identity map.'); self::assertFalse($company->member->__isInitialized__, 'Pre-Condition'); @@ -55,7 +55,7 @@ public function testIssue(): void $this->_em->remove($company); $this->_em->flush(); - self::assertCount(0, $this->_em->getRepository(get_class($account))->findAll()); + self::assertCount(0, $this->_em->getRepository($account::class)->findAll()); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php index 0b6916d908b..65b080ac8dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php @@ -74,12 +74,11 @@ public function testCompositeIdentifierCanHaveCustomType(): void class DDC1209One { /** - * @var int * @Id * @GeneratedValue * @Column(type="integer") */ - private $id; + private int $id; public function getId(): int { @@ -92,14 +91,6 @@ public function getId(): int */ class DDC1209Two { - /** - * @var DDC1209One - * @Id - * @ManyToOne(targetEntity="DDC1209One") - * @JoinColumn(referencedColumnName="id", nullable=false) - */ - private $future1; - /** * @var DateTime2 * @Id @@ -121,9 +112,13 @@ class DDC1209Two */ public $endingDatetime; - public function __construct(DDC1209One $future1) + public function __construct(/** + * @Id + * @ManyToOne(targetEntity="DDC1209One") + * @JoinColumn(referencedColumnName="id", nullable=false) + */ + private DDC1209One $future1) { - $this->future1 = $future1; $this->startingDatetime = new DateTime2(); $this->duringDatetime = new DateTime2(); $this->endingDatetime = new DateTime2(); @@ -148,7 +143,7 @@ public function __construct() } } -class DateTime2 extends DateTime +class DateTime2 extends DateTime implements \Stringable { public function __toString(): string { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index 0912bf28e9e..4fdb1aa03ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -53,12 +53,11 @@ public function testIssue(): void class DDC1225TestEntity1 { /** - * @var DDC1225TestEntity2 * @Id * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225TestEntity2") * @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false) */ - private $testEntity2; + private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1225TestEntity2 $testEntity2 = null; public function setTestEntity2(DDC1225TestEntity2 $testEntity2): void { @@ -78,10 +77,9 @@ public function getTestEntity2(): DDC1225TestEntity2 class DDC1225TestEntity2 { /** - * @var int * @Id * @GeneratedValue(strategy="AUTO") * @Column(type="integer") */ - private $id; + private int $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php index 7b97a1963b1..5998a5ca6fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -71,18 +71,16 @@ public function testIssueProxyClear(): void class DDC1238User { /** - * @var int|null * @Id * @GeneratedValue * @Column(type="integer") */ - private $id; + private ?int $id = null; /** * @Column - * @var string|null */ - private $name; + private ?string $name = null; public function getId(): ?int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php index f3049476bcb..87e04a11349 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php @@ -4,6 +4,10 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\Tests\Models\Legacy\LegacyUser; +use Doctrine\Tests\Models\Legacy\LegacyArticle; +use Doctrine\Tests\Models\Legacy\LegacyCar; +use Doctrine\Tests\Models\Legacy\LegacyUserReference; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; @@ -14,15 +18,14 @@ */ class DDC1301Test extends OrmFunctionalTestCase { - /** @var int */ - private $userId; + private ?int $userId = null; protected function setUp(): void { $this->useModelSet('legacy'); parent::setUp(); - $class = $this->_em->getClassMetadata(Models\Legacy\LegacyUser::class); + $class = $this->_em->getClassMetadata(LegacyUser::class); $class->associationMappings['articles']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; $class->associationMappings['references']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; $class->associationMappings['cars']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; @@ -34,7 +37,7 @@ public function tearDown(): void { parent::tearDown(); - $class = $this->_em->getClassMetadata(Models\Legacy\LegacyUser::class); + $class = $this->_em->getClassMetadata(LegacyUser::class); $class->associationMappings['articles']['fetch'] = ClassMetadata::FETCH_LAZY; $class->associationMappings['references']['fetch'] = ClassMetadata::FETCH_LAZY; $class->associationMappings['cars']['fetch'] = ClassMetadata::FETCH_LAZY; @@ -42,7 +45,7 @@ public function tearDown(): void public function testCountNotInitializesLegacyCollection(): void { - $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); + $user = $this->_em->find(LegacyUser::class, $this->userId); $this->getQueryLog()->reset()->enable(); self::assertFalse($user->articles->isInitialized()); @@ -57,7 +60,7 @@ public function testCountNotInitializesLegacyCollection(): void public function testCountNotInitializesLegacyCollectionWithForeignIdentifier(): void { - $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); + $user = $this->_em->find(LegacyUser::class, $this->userId); $this->getQueryLog()->reset()->enable(); self::assertFalse($user->references->isInitialized()); @@ -72,7 +75,7 @@ public function testCountNotInitializesLegacyCollectionWithForeignIdentifier(): public function testCountNotInitializesLegacyManyToManyCollection(): void { - $user = $this->_em->find(Models\Legacy\LegacyUser::class, $this->userId); + $user = $this->_em->find(LegacyUser::class, $this->userId); $this->getQueryLog()->reset()->enable(); self::assertFalse($user->cars->isInitialized()); @@ -87,15 +90,15 @@ public function testCountNotInitializesLegacyManyToManyCollection(): void public function loadFixture(): void { - $user1 = new Models\Legacy\LegacyUser(); + $user1 = new LegacyUser(); $user1->username = 'beberlei'; $user1->name = 'Benjamin'; - $user2 = new Models\Legacy\LegacyUser(); + $user2 = new LegacyUser(); $user2->username = 'jwage'; $user2->name = 'Jonathan'; - $user3 = new Models\Legacy\LegacyUser(); + $user3 = new LegacyUser(); $user3->username = 'romanb'; $user3->name = 'Roman'; @@ -103,12 +106,12 @@ public function loadFixture(): void $this->_em->persist($user2); $this->_em->persist($user3); - $article1 = new Models\Legacy\LegacyArticle(); + $article1 = new LegacyArticle(); $article1->topic = 'Test'; $article1->text = 'Test'; $article1->setAuthor($user1); - $article2 = new Models\Legacy\LegacyArticle(); + $article2 = new LegacyArticle(); $article2->topic = 'Test'; $article2->text = 'Test'; $article2->setAuthor($user1); @@ -116,13 +119,13 @@ public function loadFixture(): void $this->_em->persist($article1); $this->_em->persist($article2); - $car1 = new Models\Legacy\LegacyCar(); + $car1 = new LegacyCar(); $car1->description = 'Test1'; - $car2 = new Models\Legacy\LegacyCar(); + $car2 = new LegacyCar(); $car2->description = 'Test2'; - $car3 = new Models\Legacy\LegacyCar(); + $car3 = new LegacyCar(); $car3->description = 'Test3'; $user1->addCar($car1); @@ -138,8 +141,8 @@ public function loadFixture(): void $this->_em->flush(); - $detail1 = new Models\Legacy\LegacyUserReference($user1, $user2, 'foo'); - $detail2 = new Models\Legacy\LegacyUserReference($user1, $user3, 'bar'); + $detail1 = new LegacyUserReference($user1, $user2, 'foo'); + $detail2 = new LegacyUserReference($user1, $user3, 'bar'); $this->_em->persist($detail1); $this->_em->persist($detail2); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index 30cda7fae7e..b14d170cfa6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->createSchemaForModels(DDC1335User::class, DDC1335Phone::class); try { $this->loadFixture(); - } catch (UniqueConstraintViolationException $e) { + } catch (UniqueConstraintViolationException) { } } @@ -167,28 +167,24 @@ class DDC1335User */ public $id; - /** - * @var string - * @Column(type="string", length=255, unique=true) - */ - public $email; - - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - /** * @psalm-var Collection * @OneToMany(targetEntity="DDC1335Phone", mappedBy="user", cascade={"persist", "remove"}) */ public $phones; - public function __construct($email, $name, array $numbers = []) + /** + * @param string $email + * @param string $name + */ + public function __construct(/** + * @Column(type="string", length=255, unique=true) + */ + public $email, /** + * @Column(type="string", length=255) + */ + public $name, array $numbers = []) { - $this->name = $name; - $this->email = $email; $this->phones = new ArrayCollection(); foreach ($numbers as $number) { @@ -211,21 +207,20 @@ class DDC1335Phone public $id; /** - * @var string - * @Column(name="numericalValue", type="string", nullable = false) + * @param string $number + * @param \Doctrine\Tests\ORM\Functional\Ticket\DDC1335User $user */ - public $numericalValue; - - /** - * @var DDC1335User - * @ManyToOne(targetEntity="DDC1335User", inversedBy="phones") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable = false) - */ - public $user; - - public function __construct($user, $number) + public function __construct( + /** + * @ManyToOne(targetEntity="DDC1335User", inversedBy="phones") + * @JoinColumn(name="user_id", referencedColumnName="id", nullable = false) + */ + public $user, + /** + * @Column(name="numericalValue", type="string", nullable = false) + */ + public $numericalValue + ) { - $this->user = $user; - $this->numericalValue = $number; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php index abc8ab68d65..e1ff3073f35 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php @@ -31,7 +31,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC1400UserState::class), ] ); - } catch (Exception $ignored) { + } catch (Exception) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index 3eae1f5c534..5a5eda00f86 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -33,7 +33,7 @@ protected function setUp(): void ] ); $this->loadFixtures(); - } catch (Exception $exc) { + } catch (Exception) { } } @@ -154,31 +154,25 @@ class DDC1430Order protected $id; /** - * @var DateTime * @Column(name="created_at", type="datetime") */ - private $date; - - /** - * @var string - * @Column(name="order_status", type="string", length=255) - */ - private $status; + private \DateTime $date; /** * @OneToMany(targetEntity="DDC1430OrderProduct", mappedBy="order", cascade={"persist", "remove"}) - * @var ArrayCollection $products */ - private $products; + private ArrayCollection $products; public function getId(): int { return $this->id; } - public function __construct(string $status) + public function __construct(/** + * @Column(name="order_status", type="string", length=255) + */ + private string $status) { - $this->status = $status; $this->date = new DateTime(); $this->products = new ArrayCollection(); } @@ -224,21 +218,18 @@ class DDC1430OrderProduct protected $id; /** - * @var DDC1430Order $order * @ManyToOne(targetEntity="DDC1430Order", inversedBy="products") * @JoinColumn(name="order_id", referencedColumnName="order_id", nullable = false) */ - private $order; - - /** - * @var float - * @Column(type="float") - */ - private $value; - - public function __construct(float $value) + private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1430Order $order = null; + + public function __construct( + /** + * @Column(type="float") + */ + private float $value + ) { - $this->value = $value; } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php index 8b62c7a4a7a..1939c84dde4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -28,7 +28,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC1436Page::class), ] ); - } catch (Exception $ignored) { + } catch (Exception) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php index 29ee1f119bf..9bd1eb08e58 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -35,7 +35,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC1452EntityB::class), ] ); - } catch (Exception $ignored) { + } catch (Exception) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php index a15259b875a..b5e4dda877f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -33,7 +33,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC1454Picture::class), ] ); - } catch (Exception $ignored) { + } catch (Exception) { } } @@ -69,7 +69,7 @@ class DDC1454File public function __construct() { - $this->fileId = random_int(0, getrandmax()); + $this->fileId = random_int(0, mt_getrandmax()); } public function getFileId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index 3f59313c25a..8177d611e22 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -45,7 +45,7 @@ public function testChangeDetectionDeferredExplicit(): void $this->_em->persist($user); $this->_em->flush(); - $user = $this->_em->find(get_class($user), $user->id); + $user = $this->_em->find($user::class, $user->id); self::assertNotNull($user->twitterAccount); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php index 41cf8418aa1..62746a2e23c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC1514EntityC::class), ] ); - } catch (Exception $ignored) { + } catch (Exception) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php index 43039d69d25..3255f3ac7bc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php @@ -13,14 +13,11 @@ */ class DDC1545Test extends OrmFunctionalTestCase { - /** @var int */ - private $articleId; + private ?int $articleId = null; - /** @var int */ - private $userId; + private ?int $userId = null; - /** @var int */ - private $user2Id; + private ?int $user2Id = null; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php index b20e03a7ef0..660fdd99573 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php @@ -15,11 +15,9 @@ */ class DDC1643Test extends OrmFunctionalTestCase { - /** @var CmsUser */ - private $user1; + private ?CmsUser $user1; - /** @var CmsUser */ - private $user2; + private ?CmsUser $user2; protected function setUp(): void { @@ -48,8 +46,8 @@ protected function setUp(): void $this->_em->flush(); $this->_em->clear(); - $this->user1 = $this->_em->find(get_class($user1), $user1->id); - $this->user2 = $this->_em->find(get_class($user1), $user2->id); + $this->user1 = $this->_em->find($user1::class, $user1->id); + $this->user2 = $this->_em->find($user1::class, $user2->id); } public function testClonePersistentCollectionAndReuse(): void @@ -61,7 +59,7 @@ public function testClonePersistentCollectionAndReuse(): void $this->_em->flush(); $this->_em->clear(); - $user1 = $this->_em->find(get_class($user1), $user1->id); + $user1 = $this->_em->find($user1::class, $user1->id); self::assertCount(2, $user1->groups); } @@ -76,8 +74,8 @@ public function testClonePersistentCollectionAndShare(): void $this->_em->flush(); $this->_em->clear(); - $user1 = $this->_em->find(get_class($user1), $user1->id); - $user2 = $this->_em->find(get_class($user1), $user2->id); + $user1 = $this->_em->find($user1::class, $user1->id); + $user2 = $this->_em->find($user1::class, $user2->id); self::assertCount(2, $user1->groups); self::assertCount(2, $user2->groups); @@ -97,8 +95,8 @@ public function testCloneThenDirtyPersistentCollection(): void $this->_em->flush(); $this->_em->clear(); - $user1 = $this->_em->find(get_class($user1), $user1->id); - $user2 = $this->_em->find(get_class($user1), $user2->id); + $user1 = $this->_em->find($user1::class, $user1->id); + $user2 = $this->_em->find($user1::class, $user2->id); self::assertCount(3, $user2->groups); self::assertCount(2, $user1->groups); @@ -120,8 +118,8 @@ public function testNotCloneAndPassAroundFlush(): void $this->_em->flush(); $this->_em->clear(); - $user1 = $this->_em->find(get_class($user1), $user1->id); - $user2 = $this->_em->find(get_class($user1), $user2->id); + $user1 = $this->_em->find($user1::class, $user1->id); + $user2 = $this->_em->find($user1::class, $user2->id); self::assertCount(3, $user2->groups); self::assertCount(3, $user1->groups); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index bb423ded1b4..4dd4c917ac0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -58,7 +58,7 @@ public function testPostLoadOneToManyInheritance(): void $this->_em->flush(); $this->_em->clear(); - $baz = $this->_em->find(get_class($baz), $baz->id); + $baz = $this->_em->find($baz::class, $baz->id); foreach ($baz->foos as $foo) { self::assertEquals(1, $foo->loaded, 'should have loaded callback counter incremented for ' . get_debug_type($foo)); } @@ -76,11 +76,11 @@ public function testPostLoadInheritanceChild(): void $this->_em->flush(); $this->_em->clear(); - $bar = $this->_em->find(get_class($bar), $bar->id); + $bar = $this->_em->find($bar::class, $bar->id); self::assertEquals(1, $bar->loaded); self::assertEquals(1, $bar->subLoaded); - $bar = $this->_em->find(get_class($bar), $bar->id); + $bar = $this->_em->find($bar::class, $bar->id); self::assertEquals(1, $bar->loaded); self::assertEquals(1, $bar->subLoaded); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php index e8c763c26f5..c013e42845b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php @@ -15,8 +15,7 @@ */ class DDC1685Test extends OrmFunctionalTestCase { - /** @var Paginator */ - private $paginator; + private Paginator $paginator; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php index 5a3bceb3c91..934fae9149a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php @@ -109,24 +109,21 @@ protected function onPropertyChanged($propName, $oldValue, $newValue): void class DDC1690Parent extends NotifyBaseEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column */ - private $name; + private ?string $name = null; /** - * @var DDC1690Child * @OneToOne(targetEntity="DDC1690Child") */ - private $child; + private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1690Child $child = null; public function getId(): int { @@ -159,24 +156,21 @@ public function getChild(): DDC1690Child class DDC1690Child extends NotifyBaseEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column */ - private $name; + private ?string $name = null; /** - * @var DDC1690Parent * @OneToOne(targetEntity="DDC1690Parent", mappedBy="child") */ - private $parent; + private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1690Parent $parent = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php index cfee59f3936..5bb110fc27a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -40,112 +40,94 @@ public function testIssue(): void class DDC1695News { /** - * @var int * @Column(name="`IdNews`", type="integer", nullable=false) * @Id * @GeneratedValue */ - private $idNews; + private int $idNews; /** - * @var int * @Column(name="`IdUser`", type="bigint", nullable=false) */ - private $idUser; + private int $idUser; /** - * @var int * @Column(name="`IdLanguage`", type="integer", nullable=false) */ - private $idLanguage; + private int $idLanguage; /** - * @var int * @Column(name="`IdCondition`", type="integer", nullable=true) */ - private $idCondition; + private int $idCondition; /** - * @var int * @Column(name="`IdHealthProvider`", type="integer", nullable=true) */ - private $idHealthProvider; + private int $idHealthProvider; /** - * @var int * @Column(name="`IdSpeciality`", type="integer", nullable=true) */ - private $idSpeciality; + private int $idSpeciality; /** - * @var int * @Column(name="`IdMedicineType`", type="integer", nullable=true) */ - private $idMedicineType; + private int $idMedicineType; /** - * @var int * @Column(name="`IdTreatment`", type="integer", nullable=true) */ - private $idTreatment; + private int $idTreatment; /** - * @var string * @Column(name="`Title`", type="string", nullable=true) */ - private $title; + private string $title; /** - * @var string * @Column(name="`SmallText`", type="string", nullable=true) */ - private $smallText; + private string $smallText; /** - * @var string * @Column(name="`LongText`", type="string", nullable=true) */ - private $longText; + private string $longText; /** - * @var DateTimeZone * @Column(name="`PublishDate`", type="datetimetz", nullable=true) */ - private $publishDate; + private \DateTimeZone $publishDate; /** - * @var array * @Column(name="`IdxNews`", type="json_array", nullable=true) */ - private $idxNews; + private array $idxNews; /** - * @var bool * @Column(name="`Highlight`", type="boolean", nullable=false) */ - private $highlight; + private bool $highlight; /** - * @var int * @Column(name="`Order`", type="integer", nullable=false) */ - private $order; + private int $order; /** - * @var bool * @Column(name="`Deleted`", type="boolean", nullable=false) */ - private $deleted; + private bool $deleted; /** - * @var bool * @Column(name="`Active`", type="boolean", nullable=false) */ - private $active; + private bool $active; /** - * @var bool * @Column(name="`UpdateToHighlighted`", type="boolean", nullable=true) */ - private $updateToHighlighted; + private bool $updateToHighlighted; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index 3db0472597b..a0beecb8ab9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC1509Picture::class), ] ); - } catch (Exception $ignored) { + } catch (Exception) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php index d0194f11f5e..19450e513cd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php @@ -97,14 +97,12 @@ class DDC1719SimpleEntity */ public $id; - /** - * @var string - * @Column(type="string", name="`simple-entity-value`") - */ - public $value; - - public function __construct(string $value) + public function __construct( + /** + * @Column(type="string", name="`simple-entity-value`") + */ + public string $value + ) { - $this->value = $value; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php index 51c4989c630..2a9fe6ae0f0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php @@ -45,12 +45,11 @@ public function testFailingCase(): void class DDC1757A { /** - * @var int * @Column(type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; } /** @@ -59,18 +58,16 @@ class DDC1757A class DDC1757B { /** - * @var int * @Column(type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var DDC1757C * @OneToOne(targetEntity="DDC1757C") */ - private $c; + private \Doctrine\Tests\ORM\Functional\Ticket\DDC1757C $c; } /** @@ -87,10 +84,9 @@ class DDC1757C public $id; /** - * @var DDC1757D * @OneToOne(targetEntity="DDC1757D") */ - private $d; + private \Doctrine\Tests\ORM\Functional\Ticket\DDC1757D $d; } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php index 23e4eeb3777..55eef0b56d5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php @@ -13,11 +13,9 @@ */ class DDC1778Test extends OrmFunctionalTestCase { - /** @var CmsUser */ - private $user; + private ?CmsUser $user; - /** @var CmsPhonenumber */ - private $phone; + private ?CmsPhonenumber $phone; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php index 8392c5ce19b..2e0de1db09a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php @@ -52,19 +52,17 @@ public function testIssue(): void class DDC1787Foo { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var int * @Version * @Column(type="integer") */ - private $version; + private int $version; public function getVersion(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php index 678783188de..e859963d8eb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php @@ -14,8 +14,7 @@ */ class DDC1885Test extends OrmFunctionalTestCase { - /** @var User */ - private $user; + private \Doctrine\Tests\ORM\Functional\Ticket\User $user; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php index 85dda67e718..a2b169aa46e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php @@ -66,18 +66,16 @@ public function testIssue(): void class DDC1925Product { /** - * @var int $id * @Column(name="id", type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string $title * @Column(name="title", type="string", length=255) */ - private $title; + private ?string $title = null; /** * @psalm-var Collection @@ -134,18 +132,16 @@ public function addBuyer(DDC1925User $buyer): void class DDC1925User { /** - * @var int * @Column(name="id", type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(name="title", type="string", length=255) */ - private $title; + private ?string $title = null; /** * Get id diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index c9d112c4e37..90675536c8b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -96,14 +96,10 @@ public function getName(): string } } -class DDC1998Id +class DDC1998Id implements \Stringable { - /** @var string */ - private $val; - - public function __construct(string $val) + public function __construct(private string $val) { - $this->val = $val; } public function __toString(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index fb1304bc26d..cd3ca819384 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -55,7 +55,7 @@ public function testIssue(): void $this->_em->flush(); $this->_em->clear(); - $item = $this->_em->find(get_class($item), $item->id); + $item = $this->_em->find($item::class, $item->id); self::assertArrayHasKey('convertToDatabaseValueSQL', DDC2012TsVectorType::$calls); self::assertArrayHasKey('convertToDatabaseValue', DDC2012TsVectorType::$calls); @@ -74,7 +74,7 @@ public function testIssue(): void $this->_em->flush(); $this->_em->clear(); - $item = $this->_em->find(get_class($item), $item->id); + $item = $this->_em->find($item::class, $item->id); self::assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']); self::assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValue']); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php index 672ec19b61d..c798e5b762b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php @@ -4,6 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\Tests\ORM\Functional\Ticket\DDC2084\MyEntity1; +use Doctrine\Tests\ORM\Functional\Ticket\DDC2084\MyEntity2; +use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\Tests\OrmFunctionalTestCase; use Exception; @@ -23,14 +26,14 @@ protected function setUp(): void $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2084\MyEntity2'), ] ); - } catch (Exception $exc) { + } catch (Exception) { } } - public function loadFixture(): DDC2084\MyEntity1 + public function loadFixture(): MyEntity1 { - $e2 = new DDC2084\MyEntity2('Foo'); - $e1 = new DDC2084\MyEntity1($e2); + $e2 = new MyEntity2('Foo'); + $e1 = new MyEntity1($e2); $this->_em->persist($e2); $this->_em->flush(); @@ -56,14 +59,14 @@ public function testIssue(): void public function testInvalidIdentifierBindingEntityException(): void { - $this->expectException('Doctrine\ORM\ORMInvalidArgumentException'); + $this->expectException(ORMInvalidArgumentException::class); $this->expectExceptionMessage( <<<'EXCEPTION' Binding entities to query parameters only allowed for entities that have an identifier. Class "Doctrine\Tests\ORM\Functional\Ticket\DDC2084\MyEntity2" does not have an identifier. EXCEPTION ); - $this->_em->find(__NAMESPACE__ . '\DDC2084\MyEntity1', new DDC2084\MyEntity2('Foo')); + $this->_em->find(__NAMESPACE__ . '\DDC2084\MyEntity1', new MyEntity2('Foo')); } } @@ -83,17 +86,15 @@ public function testInvalidIdentifierBindingEntityException(): void */ class MyEntity1 { - /** - * @var MyEntity2 - * @Id - * @OneToOne(targetEntity="MyEntity2") - * @JoinColumn(name="entity2_id", referencedColumnName="id", nullable=false) - */ - private $entity2; - - public function __construct(MyEntity2 $myEntity2) + public function __construct( + /** + * @Id + * @OneToOne(targetEntity="MyEntity2") + * @JoinColumn(name="entity2_id", referencedColumnName="id", nullable=false) + */ + private MyEntity2 $entity2 + ) { - $this->entity2 = $myEntity2; } public function setMyEntity2(MyEntity2 $myEntity2): void @@ -114,22 +115,19 @@ public function getMyEntity2(): MyEntity2 class MyEntity2 { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; - - /** - * @var string - * @Column - */ - private $value; - - public function __construct(string $value) + private int $id; + + public function __construct( + /** + * @Column + */ + private string $value + ) { - $this->value = $value; } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index 098b9c78a3f..5cec6e9347a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\Tests\ORM\Functional\Ticket\Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Table as DbalTable; @@ -116,27 +117,22 @@ public function getId(): int */ class DDC2138UserFollowedStructure extends DDC2138UserFollowedObject { - /** - * @ManyToOne(targetEntity="DDC2138User", inversedBy="followedStructures") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) - * @var User $user - */ - protected $user; - - /** - * @ManyToOne(targetEntity="DDC2138Structure") - * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) - * @var Structure $followedStructure - */ - private $followedStructure; - /** * Construct a UserFollowedStructure entity */ - public function __construct(User $user, Structure $followedStructure) + public function __construct( + /** + * @ManyToOne(targetEntity="DDC2138User", inversedBy="followedStructures") + * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) + */ + protected User $user, + /** + * @ManyToOne(targetEntity="DDC2138Structure") + * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) + */ + private Structure $followedStructure + ) { - $this->user = $user; - $this->followedStructure = $followedStructure; } public function getUser(): User @@ -158,27 +154,22 @@ public function getFollowedStructure(): Structure */ class DDC2138UserFollowedUser extends DDC2138UserFollowedObject { - /** - * @ManyToOne(targetEntity="DDC2138User", inversedBy="followedUsers") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) - * @var User $user - */ - protected $user; - - /** - * @ManyToOne(targetEntity="DDC2138User") - * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) - * @var User $user - */ - private $followedUser; - /** * Construct a UserFollowedUser entity */ - public function __construct(User $user, User $followedUser) + public function __construct( + /** + * @ManyToOne(targetEntity="DDC2138User", inversedBy="followedUsers") + * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) + */ + protected User $user, + /** + * @ManyToOne(targetEntity="DDC2138User") + * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) + */ + private User $followedUser + ) { - $this->user = $user; - $this->followedUser = $followedUser; } public function getUser(): User @@ -247,7 +238,7 @@ public function removeFollowedUser(UserFollowedUser $followedUsers): User return $this; } - public function getFollowedUsers(): Doctrine\Common\Collections\Collection + public function getFollowedUsers(): Collection { return $this->followedUsers; } @@ -266,7 +257,7 @@ public function removeFollowedStructure(UserFollowedStructure $followedStructure return $this; } - public function getFollowedStructures(): Doctrine\Common\Collections\Collection + public function getFollowedStructures(): Collection { return $this->followedStructures; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php index 90bfc1ad7ae..bafc3860732 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -40,11 +40,10 @@ public function testPassColumnOptionsToJoinColumns(): void class DDC2182OptionParent { /** - * @var int * @Id * @Column(type="integer", options={"unsigned": true}) */ - private $id; + private int $id; } /** @@ -54,16 +53,14 @@ class DDC2182OptionParent class DDC2182OptionChild { /** - * @var string * @Id * @Column */ - private $id; + private string $id; /** - * @var DDC2182OptionParent * @ManyToOne(targetEntity="DDC2182OptionParent") * @JoinColumn(referencedColumnName="id") */ - private $parent; + private \Doctrine\Tests\ORM\Functional\Ticket\DDC2182OptionParent $parent; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index 44d9155e020..0a1d94845e2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -34,7 +34,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC2230Address::class), ] ); - } catch (ToolsException $e) { + } catch (ToolsException) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index 3fa9b6488ef..b46fe970c59 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -34,7 +34,7 @@ class DDC2252Test extends OrmFunctionalTestCase private $membership; /** @psalm-var list */ - private $privileges = []; + private array $privileges = []; protected function setUp(): void { @@ -213,22 +213,6 @@ public function addMembership(DDC2252Membership $membership): void */ class DDC2252Membership { - /** - * @var DDC2252User - * @Id - * @ManyToOne(targetEntity="DDC2252User", inversedBy="memberships") - * @JoinColumn(name="uid", referencedColumnName="uid") - */ - protected $userAccount; - - /** - * @var DDC2252MerchantAccount - * @Id - * @ManyToOne(targetEntity="DDC2252MerchantAccount") - * @JoinColumn(name="mch_accountid", referencedColumnName="accountid") - */ - protected $merchantAccount; - /** * @psalm-var Collection * @ManyToMany(targetEntity="DDC2252Privilege", indexBy="privilegeid") @@ -244,10 +228,18 @@ class DDC2252Membership */ protected $privileges; - public function __construct(DDC2252User $user, DDC2252MerchantAccount $merchantAccount) + public function __construct(/** + * @Id + * @ManyToOne(targetEntity="DDC2252User", inversedBy="memberships") + * @JoinColumn(name="uid", referencedColumnName="uid") + */ + protected DDC2252User $userAccount, /** + * @Id + * @ManyToOne(targetEntity="DDC2252MerchantAccount") + * @JoinColumn(name="mch_accountid", referencedColumnName="accountid") + */ + protected DDC2252MerchantAccount $merchantAccount) { - $this->userAccount = $user; - $this->merchantAccount = $merchantAccount; $this->privileges = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index 53b51bebde6..ccb4c5aa8b8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -171,24 +171,15 @@ class DDC2306UserAddress */ public $id; - /** - * @var DDC2306User + /** Constructor */ + public function __construct(/** * @ManyToOne(targetEntity="DDC2306User") */ - public $user; - - /** - * @var DDC2306Address + public DDC2306User $user, /** * @ManyToOne(targetEntity="DDC2306Address", fetch="LAZY") */ - public $address; - - /** Constructor */ - public function __construct(DDC2306User $user, DDC2306Address $address) + public DDC2306Address $address) { - $this->user = $user; - $this->address = $address; - $user->addresses->add($this); $address->users->add($this); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php index 068769ee1d6..7d8bd9eedd2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -50,13 +50,13 @@ public function testUninitializedProxyIsInitializedOnFetchJoin(): void $this->_em->flush(); $this->_em->clear(); - $x2 = $this->_em->find(get_class($x), $x->id); // proxy injected for Y + $x2 = $this->_em->find($x::class, $x->id); // proxy injected for Y self::assertInstanceOf(Proxy::class, $x2->y); self::assertFalse($x2->y->__isInitialized__); // proxy for Y is in identity map - $z2 = $this->_em->createQuery('select z,y from ' . get_class($z) . ' z join z.y y where z.id = ?1') + $z2 = $this->_em->createQuery('select z,y from ' . $z::class . ' z join z.y y where z.id = ?1') ->setParameter(1, $z->id) ->getSingleResult(); self::assertInstanceOf(Proxy::class, $z2->y); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php index 40f61874a4b..bef58d8926c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php @@ -82,12 +82,8 @@ public static function loadMetadata(ClassMetadata $metadata): void class DDC2415ChildEntity extends DDC2415ParentEntity { - /** @var string */ - protected $name; - - public function __construct(string $name) + public function __construct(protected string $name) { - $this->name = $name; } public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index 6ea802ef358..3bacbb053d5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\Common\Proxy\Proxy; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; @@ -62,7 +63,7 @@ public function testIssue(): void $this->getQueryLog()->reset()->enable(); - self::assertInstanceOf('\Doctrine\Common\Proxy\Proxy', $item->getCurrency()); + self::assertInstanceOf(Proxy::class, $item->getCurrency()); self::assertFalse($item->getCurrency()->__isInitialized()); self::assertArrayHasKey('convertToPHPValue', DDC2494TinyIntType::$calls); @@ -88,29 +89,24 @@ public function testIssue(): void */ class DDC2494Currency { - /** - * @var int - * @Id - * @Column(type="ddc2494_tinyint") - */ - protected $id; - - /** - * @var int - * @Column(name="temp", type="ddc2494_tinyint", nullable=false) - */ - protected $temp; - /** * @psalm-var Collection * @OneToMany(targetEntity="DDC2494Campaign", mappedBy="currency") */ protected $campaigns; - public function __construct(int $id, int $temp) + public function __construct( + /** + * @Id + * @Column(type="ddc2494_tinyint") + */ + protected int $id, + /** + * @Column(name="temp", type="ddc2494_tinyint", nullable=false) + */ + protected int $temp + ) { - $this->id = $id; - $this->temp = $temp; } public function getId(): int @@ -146,16 +142,14 @@ class DDC2494Campaign */ protected $id; - /** - * @var DDC2494Currency - * @ManyToOne(targetEntity="DDC2494Currency", inversedBy="campaigns") - * @JoinColumn(name="currency_id", referencedColumnName="id", nullable=false) - */ - protected $currency; - - public function __construct(DDC2494Currency $currency) + public function __construct( + /** + * @ManyToOne(targetEntity="DDC2494Currency", inversedBy="campaigns") + * @JoinColumn(name="currency_id", referencedColumnName="id", nullable=false) + */ + protected DDC2494Currency $currency + ) { - $this->currency = $currency; } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index 762704d232b..93ff4dda38d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -18,13 +18,13 @@ class DDC2575Test extends OrmFunctionalTestCase { /** @psalm-var list */ - private $rootsEntities = []; + private array $rootsEntities = []; /** @psalm-var list */ - private $aEntities = []; + private array $aEntities = []; /** @psalm-var list */ - private $bEntities = []; + private array $bEntities = []; protected function setUp(): void { @@ -104,29 +104,24 @@ public function testHydrationIssue(): void */ class DDC2575Root { - /** - * @var int - * @Id - * @Column(type="integer") - */ - public $id; - - /** - * @var int - * @Column(type="integer") - */ - public $sampleField; - /** * @var DDC2575A * @OneToOne(targetEntity="DDC2575A", mappedBy="rootRelation") */ public $aRelation; - public function __construct(int $id, int $value = 0) + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + public int $id, + /** + * @Column(type="integer") + */ + public int $sampleField = 0 + ) { - $this->id = $id; - $this->sampleField = $value; } } @@ -135,25 +130,20 @@ public function __construct(int $id, int $value = 0) */ class DDC2575A { - /** - * @var DDC2575Root - * @Id - * @OneToOne(targetEntity="DDC2575Root", inversedBy="aRelation") - * @JoinColumn(name="root_id", referencedColumnName="id", nullable=FALSE, onDelete="CASCADE") - */ - public $rootRelation; - - /** - * @var DDC2575B - * @ManyToOne(targetEntity="DDC2575B") - * @JoinColumn(name="b_id", referencedColumnName="id", nullable=FALSE, onDelete="CASCADE") - */ - public $bRelation; - - public function __construct(DDC2575Root $rootRelation, DDC2575B $bRelation) + public function __construct( + /** + * @Id + * @OneToOne(targetEntity="DDC2575Root", inversedBy="aRelation") + * @JoinColumn(name="root_id", referencedColumnName="id", nullable=FALSE, onDelete="CASCADE") + */ + public DDC2575Root $rootRelation, + /** + * @ManyToOne(targetEntity="DDC2575B") + * @JoinColumn(name="b_id", referencedColumnName="id", nullable=FALSE, onDelete="CASCADE") + */ + public DDC2575B $bRelation + ) { - $this->rootRelation = $rootRelation; - $this->bRelation = $bRelation; } } @@ -162,22 +152,17 @@ public function __construct(DDC2575Root $rootRelation, DDC2575B $bRelation) */ class DDC2575B { - /** - * @var int - * @Id - * @Column(type="integer") - */ - public $id; - - /** - * @var int - * @Column(type="integer") - */ - public $sampleField; - - public function __construct(int $id, int $value = 0) + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + public int $id, + /** + * @Column(type="integer") + */ + public int $sampleField = 0 + ) { - $this->id = $id; - $this->sampleField = $value; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index 5341d95857e..e3e92416862 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -90,17 +90,13 @@ class DDC2579Entity */ public $assoc; - /** - * @var int + public function __construct(DDC2579EntityAssoc $assoc, /** * @Column(type="integer") */ - public $value; - - public function __construct(DDC2579EntityAssoc $assoc, int $value = 0) + public int $value = 0) { $this->id = $assoc->assocAssoc->associationId; $this->assoc = $assoc; - $this->value = $value; } } @@ -109,17 +105,15 @@ public function __construct(DDC2579EntityAssoc $assoc, int $value = 0) */ class DDC2579EntityAssoc { - /** - * @var DDC2579AssocAssoc - * @Id - * @ManyToOne(targetEntity="DDC2579AssocAssoc") - * @JoinColumn(name="association_id", referencedColumnName="associationId") - */ - public $assocAssoc; - - public function __construct(DDC2579AssocAssoc $assocAssoc) + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="DDC2579AssocAssoc") + * @JoinColumn(name="association_id", referencedColumnName="associationId") + */ + public DDC2579AssocAssoc $assocAssoc + ) { - $this->assocAssoc = $assocAssoc; } } @@ -128,16 +122,14 @@ public function __construct(DDC2579AssocAssoc $assocAssoc) */ class DDC2579AssocAssoc { - /** - * @var DDC2579Id - * @Id - * @Column(type="ddc2579", length=255) - */ - public $associationId; - - public function __construct(DDC2579Id $id) + public function __construct( + /** + * @Id + * @Column(type="ddc2579", length=255) + */ + public DDC2579Id $associationId + ) { - $this->associationId = $id; } } @@ -168,14 +160,10 @@ public function getName(): string } } -class DDC2579Id +class DDC2579Id implements \Stringable { - /** @var string */ - private $val; - - public function __construct(string $val) + public function __construct(private string $val) { - $this->val = $val; } public function __toString(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php index 841a8ad39c0..01f70efbed4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php @@ -139,7 +139,7 @@ public function postLoad(LifecycleEventArgs $event): void '); $result = $query->getResult(); - $content = json_decode($entity->content); + $content = json_decode($entity->content, null, 512, JSON_THROW_ON_ERROR); $fieldList = new ArrayCollection(); foreach ($content as $selection) { @@ -148,9 +148,7 @@ public function postLoad(LifecycleEventArgs $event): void $fieldSelection = new DDC2602FieldSelection(); $fieldSelection->field = $field; - $fieldSelection->choiceList = $field->choiceList->filter(static function ($choice) use ($choiceList) { - return in_array($choice->id, $choiceList, true); - }); + $fieldSelection->choiceList = $field->choiceList->filter(static fn($choice) => in_array($choice->id, $choiceList, true)); $fieldList->add($fieldSelection); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php index 69910383c69..b88fdc8145b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php @@ -31,7 +31,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC2660CustomerOrder::class), ] ); - } catch (Exception $e) { + } catch (Exception) { return; } @@ -124,29 +124,24 @@ class DDC2660Customer class DDC2660CustomerOrder { /** - * @var DDC2660Product - * @Id - * @ManyToOne(targetEntity="DDC2660Product") - */ - public $product; - - /** - * @var DDC2660Customer - * @Id - * @ManyToOne(targetEntity="DDC2660Customer") + * @param string $name */ - public $customer; - - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - - public function __construct(DDC2660Product $product, DDC2660Customer $customer, $name) + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="DDC2660Product") + */ + public DDC2660Product $product, + /** + * @Id + * @ManyToOne(targetEntity="DDC2660Customer") + */ + public DDC2660Customer $customer, + /** + * @Column(type="string", length=255) + */ + public $name + ) { - $this->product = $product; - $this->customer = $customer; - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index 018eb97c6db..2b917fe12e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -30,7 +30,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC2692Foo::class), ] ); - } catch (Exception $e) { + } catch (Exception) { return; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index e4ad9f7861d..e3374d77bf8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -34,7 +34,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC2759MetadataCategory::class), ] ); - } catch (Exception $e) { + } catch (Exception) { return; } @@ -132,21 +132,19 @@ class DDC2759QualificationMetadata */ public $id; - /** - * @var DDC2759Qualification - * @OneToOne(targetEntity="DDC2759Qualification", inversedBy="metadata") - */ - public $content; - /** * @psalm-var Collection * @OneToMany(targetEntity="DDC2759MetadataCategory", mappedBy="metadata") */ protected $metadataCategories; - public function __construct(DDC2759Qualification $content) + public function __construct( + /** + * @OneToOne(targetEntity="DDC2759Qualification", inversedBy="metadata") + */ + public DDC2759Qualification $content + ) { - $this->content = $content; } } @@ -164,21 +162,16 @@ class DDC2759MetadataCategory */ public $id; - /** - * @var DDC2759QualificationMetadata - * @ManyToOne(targetEntity="DDC2759QualificationMetadata", inversedBy="metadataCategories") - */ - public $metadata; - - /** - * @var DDC2759Category - * @ManyToOne(targetEntity="DDC2759Category", inversedBy="metadataCategories") - */ - public $category; - - public function __construct(DDC2759QualificationMetadata $metadata, DDC2759Category $category) + public function __construct( + /** + * @ManyToOne(targetEntity="DDC2759QualificationMetadata", inversedBy="metadataCategories") + */ + public DDC2759QualificationMetadata $metadata, + /** + * @ManyToOne(targetEntity="DDC2759Category", inversedBy="metadataCategories") + */ + public DDC2759Category $category + ) { - $this->metadata = $metadata; - $this->category = $category; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php index abf958b1e99..802933e6bf7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php @@ -37,7 +37,7 @@ public function testIssue(): void $entity->name = 'Roman'; $qb = $this->_em->createQueryBuilder(); - $qb->from(get_class($entity), 'c'); + $qb->from($entity::class, 'c'); $qb->select('count(c)'); $initial = intval($qb->getQuery()->getSingleScalarResult()); @@ -52,7 +52,7 @@ public function testIssue(): void $this->_em->flush(); $qb = $this->_em->createQueryBuilder(); - $qb->from(get_class($entity), 'c'); + $qb->from($entity::class, 'c'); $qb->select('count(c)'); $count = intval($qb->getQuery()->getSingleScalarResult()); self::assertEquals($initial, $count); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index 0e47a5dd1ad..236667dc6fa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -70,7 +70,7 @@ public function testPersistenceOfEntityWithSchemaMapping(string $className): voi { try { $this->_schemaTool->createSchema([$this->_em->getClassMetadata($className)]); - } catch (ToolsException $e) { + } catch (ToolsException) { // table already exists } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index b6ad0845c8b..5d2057bd13e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC2862Driver::class), ] ); - } catch (ToolsException $exc) { + } catch (ToolsException) { } } @@ -138,22 +138,21 @@ class DDC2862Driver protected $id; /** - * @Column(type="string", length=255) - * @var string + * @param string $name + * @param \Doctrine\Tests\ORM\Functional\Ticket\DDC2862User $userProfile */ - protected $name; - - /** - * @Cache() - * @OneToOne(targetEntity="DDC2862User") - * @var DDC2862User - */ - protected $userProfile; - - public function __construct($name, $userProfile = null) + public function __construct( + /** + * @Column(type="string", length=255) + */ + protected $name, + /** + * @Cache() + * @OneToOne(targetEntity="DDC2862User") + */ + protected $userProfile = null + ) { - $this->name = $name; - $this->userProfile = $userProfile; } public function getId(): int @@ -198,14 +197,15 @@ class DDC2862User protected $id; /** - * @Column(type="string", length=255) - * @var string + * @param string $name */ - protected $name; - - public function __construct($name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + protected $name + ) { - $this->name = $name; } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index d29f04a7211..49b8cfc6a6e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -44,7 +44,7 @@ public function testPostLoadOneToManyInheritance(): void $this->_em->flush(); $this->_em->clear(); - $ddc2895 = $this->_em->find(get_class($ddc2895), $ddc2895->id); + $ddc2895 = $this->_em->find($ddc2895::class, $ddc2895->id); assert($ddc2895 instanceof DDC2895); self::assertNotNull($ddc2895->getLastModified()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index 9d198a42aac..e7b848e193c 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -28,7 +28,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC2931User::class), ] ); - } catch (Exception $e) { + } catch (Exception) { // no action needed - schema seems to be already in place } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 1f1dadf0b2d..958937ff6a7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -40,7 +40,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC2984User::class), ] ); - } catch (Exception $e) { + } catch (Exception) { // no action needed - schema seems to be already in place } } @@ -77,22 +77,19 @@ public function testIssue(): void class DDC2984User { /** - * @Id - * @Column(type="ddc2984_domain_user_id", length=255) - * @GeneratedValue(strategy="NONE") - * @var DDC2984DomainUserId - */ - private $userId; - - /** - * @var string * @Column(type="string", length=50) */ - private $name; - - public function __construct(DDC2984DomainUserId $aUserId) + private ?string $name = null; + + public function __construct( + /** + * @Id + * @Column(type="ddc2984_domain_user_id", length=255) + * @GeneratedValue(strategy="NONE") + */ + private DDC2984DomainUserId $userId + ) { - $this->userId = $aUserId; } public function userId(): DDC2984DomainUserId @@ -119,14 +116,10 @@ public function sameIdentityAs(DDC2984User $other): bool /** * DDC2984DomainUserId ValueObject */ -class DDC2984DomainUserId +class DDC2984DomainUserId implements \Stringable { - /** @var string */ - private $userIdString; - - public function __construct(string $aUserIdString) + public function __construct(private string $userIdString) { - $this->userIdString = $aUserIdString; } public function toString(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index bef1d13737b..a47981a8dae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -104,7 +104,7 @@ public function preFlush($event): void if ($uow->getOriginalEntityData($this->user)) { $this->user->counter++; $uow->recomputeSingleEntityChangeSet( - $em->getClassMetadata(get_class($this->user)), + $em->getClassMetadata($this->user::class), $this->user ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index b646e7fcf1a..12dce800c66 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -126,7 +126,7 @@ public function postUpdate(LifecycleEventArgs $eventArgs): void $em = $eventArgs->getEntityManager(); $uow = $em->getUnitOfWork(); $entity = $eventArgs->getEntity(); - $classMetadata = $em->getClassMetadata(get_class($entity)); + $classMetadata = $em->getClassMetadata($entity::class); $uow->computeChangeSet($classMetadata, $entity); $this->changeSet = $uow->getEntityChangeSet($entity); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php index cfa5570f626..8d19f4d8a88 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php @@ -14,11 +14,9 @@ */ class DDC3068Test extends OrmFunctionalTestCase { - /** @var Driver */ - private $foo; + private Driver $foo; - /** @var Car */ - private $merc; + private Car $merc; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php index 91a57bedd90..2af5c66942e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php @@ -63,7 +63,7 @@ public function onFlush(OnFlushEventArgs $args): void $this->inserts++; if ($entity instanceof CmsUser) { $entity->username = 'romanc'; - $cm = $em->getClassMetadata(get_class($entity)); + $cm = $em->getClassMetadata($entity::class); $uow->recomputeSingleEntityChangeSet($cm, $entity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index bf9fdd97420..e7ce115c2c5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -85,22 +85,20 @@ public function testIssue(): void */ class DDC3192Currency { - /** - * @var string - * @Id - * @Column(type="ddc3192_currency_code") - */ - public $code; - /** * @var Collection * @OneToMany(targetEntity="DDC3192Transaction", mappedBy="currency") */ public $transactions; - public function __construct(string $code) + public function __construct( + /** + * @Id + * @Column(type="ddc3192_currency_code") + */ + public string $code + ) { - $this->code = $code; } } @@ -118,30 +116,25 @@ class DDC3192Transaction */ public $id; - /** - * @var int - * @Column(type="integer") - */ - public $amount; - - /** - * @var DDC3192Currency - * @ManyToOne(targetEntity="DDC3192Currency", inversedBy="transactions") - * @JoinColumn(name="currency_id", referencedColumnName="code", nullable=false) - */ - public $currency; - - public function __construct(int $amount, DDC3192Currency $currency) + public function __construct( + /** + * @Column(type="integer") + */ + public int $amount, + /** + * @ManyToOne(targetEntity="DDC3192Currency", inversedBy="transactions") + * @JoinColumn(name="currency_id", referencedColumnName="code", nullable=false) + */ + public DDC3192Currency $currency + ) { - $this->amount = $amount; - $this->currency = $currency; } } class DDC3192CurrencyCode extends Type { /** @psalm-var array */ - private static $map = ['BYR' => 974]; + private static array $map = ['BYR' => 974]; /** * {@inheritdoc} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php index 26c0f72f402..43709878ee3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php @@ -102,12 +102,11 @@ class Participant class Status { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index c05646ee878..fcb724c64ff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -85,14 +85,15 @@ interface DDC3300Boss class DDC3300HumanBoss extends DDC3300Person implements DDC3300Boss { /** - * @var string - * @Column(type="string", length=255) + * @param string $bossCol */ - public $bossCol; - - public function __construct($bossCol) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public $bossCol + ) { - $this->bossCol = $bossCol; } } @@ -104,13 +105,14 @@ interface DDC3300Employee class DDC3300HumanEmployee extends DDC3300Person implements DDC3300Employee { /** - * @var string - * @Column(type="string", length=255) + * @param string $employeeCol */ - public $employeeCol; - - public function __construct($employeeCol) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public $employeeCol + ) { - $this->employeeCol = $employeeCol; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php index 4732bfb1f47..535e8205383 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -49,24 +49,19 @@ public function testEmbeddedObjectsAreAlsoInherited(): void /** @MappedSuperclass */ abstract class DDC3303Person { - /** - * @var string - * @Id - * @GeneratedValue(strategy="NONE") - * @Column(type="string", length=255) - */ - private $name; - - /** - * @var DDC3303Address - * @Embedded(class="DDC3303Address") - */ - private $address; - - public function __construct(string $name, DDC3303Address $address) + public function __construct( + /** + * @Id + * @GeneratedValue(strategy="NONE") + * @Column(type="string", length=255) + */ + private string $name, + /** + * @Embedded(class="DDC3303Address") + */ + private DDC3303Address $address + ) { - $this->name = $name; - $this->address = $address; } } @@ -75,29 +70,21 @@ public function __construct(string $name, DDC3303Address $address) */ class DDC3303Address { - /** - * @var string - * @Column(type="string", length=255) - */ - private $street; - - /** - * @var int - * @Column(type="integer") - */ - private $number; - - /** - * @var string - * @Column(type="string", length=255) - */ - private $city; - - public function __construct(string $street, int $number, string $city) + public function __construct( + /** + * @Column(type="string", length=255) + */ + private string $street, + /** + * @Column(type="integer") + */ + private int $number, + /** + * @Column(type="string", length=255) + */ + private string $city + ) { - $this->street = $street; - $this->number = $number; - $this->city = $city; } } @@ -108,15 +95,13 @@ public function __construct(string $street, int $number, string $city) class DDC3303Employee extends DDC3303Person { /** - * @var string + * @param string $company + */ + public function __construct(string $name, DDC3303Address $address, /** * @Column(type="string", length=255) */ - private $company; - - public function __construct(string $name, DDC3303Address $address, $company) + private $company) { parent::__construct($name, $address); - - $this->company = $company; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php index 94f9c354742..ef3fdef9772 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -67,7 +67,7 @@ public function testTwoIterateHydrations(): void self::assertEquals(1, $membership->prePersistCallCount); self::assertEquals(0, $membership->preUpdateCallCount); - self::assertInstanceOf('DateTime', $membership->updated); + self::assertInstanceOf(\DateTime::class, $membership->updated); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index c209ca1b945..d5551d28adb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC353Picture::class), ] ); - } catch (Exception $ignored) { + } catch (Exception) { } } @@ -87,21 +87,19 @@ public function testFailingCase(): void class DDC353Picture { /** - * @var int * @Column(name="picture_id", type="integer") * @Id * @GeneratedValue */ - private $pictureId; + private int $pictureId; /** - * @var DDC353File * @ManyToOne(targetEntity="DDC353File", cascade={"persist", "remove"}) * @JoinColumns({ * @JoinColumn(name="file_id", referencedColumnName="file_id") * }) */ - private $file; + private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC353File $file = null; public function getPictureId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php index a301b2fbf26..c37b1a177de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php @@ -34,22 +34,18 @@ public function testNestedEmbeddablesAreHydratedWithProperClass(): void /** @Entity */ class DDC3582Entity { - /** - * @var string - * @Column - * @Id - */ - private $id; - /** * @var DDC3582Embeddable1 * @Embedded(class="DDC3582Embeddable1") */ public $embeddable1; - public function __construct(string $id) + public function __construct(/** + * @Column + * @Id + */ + private string $id) { - $this->id = $id; $this->embeddable1 = new DDC3582Embeddable1(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index d8ae97a63fa..66de564ff05 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\DBAL\Driver\Middleware; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; @@ -52,7 +53,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC3634JTIBaseEntity::class), $this->_em->getClassMetadata(DDC3634JTIChildEntity::class), ]); - } catch (ToolsException $e) { + } catch (ToolsException) { // schema already in place } } @@ -134,12 +135,8 @@ class LastInsertIdMocker final class LastInsertIdMockConnection extends AbstractConnectionMiddleware { - private LastInsertIdMocker $idMocker; - - public function __construct(DriverConnection $wrappedConnection, LastInsertIdMocker $idMocker) + public function __construct(DriverConnection $wrappedConnection, private LastInsertIdMocker $idMocker) { - $this->idMocker = $idMocker; - parent::__construct($wrappedConnection); } @@ -154,12 +151,8 @@ public function lastInsertId($name = null): int|string final class LastInsertIdMockDriver extends AbstractDriverMiddleware { - private LastInsertIdMocker $idMocker; - - public function __construct(Driver $wrappedDriver, LastInsertIdMocker $idMocker) + public function __construct(Driver $wrappedDriver, private LastInsertIdMocker $idMocker) { - $this->idMocker = $idMocker; - parent::__construct($wrappedDriver); } @@ -172,13 +165,10 @@ public function connect(array $params): LastInsertIdMockConnection } } -final class LastInsertIdMockMiddleware implements Driver\Middleware +final class LastInsertIdMockMiddleware implements Middleware { - private LastInsertIdMocker $idMocker; - - public function __construct(LastInsertIdMocker $idMocker) + public function __construct(private LastInsertIdMocker $idMocker) { - $this->idMocker = $idMocker; } public function wrap(Driver $driver): LastInsertIdMockDriver diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php index 857b864a3e4..14c5909dcc3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php @@ -211,14 +211,15 @@ class DDC3644Address public $user; /** - * @var string - * @Column(type="string", length=255) + * @param string $address */ - public $address; - - public function __construct($address) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public $address + ) { - $this->address = $address; } } @@ -239,14 +240,15 @@ abstract class DDC3644Animal public $id; /** - * @var string - * @Column(type="string", length=255) + * @param string $name */ - public $name; - - public function __construct($name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public $name + ) { - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index 51be9743e7a..75c9c25ffd7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -68,12 +68,11 @@ public function testIssue(): void class DDC371Child { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** * @var string * @Column(type="string", length=255) @@ -91,12 +90,11 @@ class DDC371Child class DDC371Parent { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** * @var string * @Column(type="string", length=255) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php index 1f8acc8bb6d..f3c36ae29c2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php @@ -68,14 +68,6 @@ public function testOwningValueObjectIdIsCorrectlyTransformedWhenRemovingOrphane */ class DDC3785Asset { - /** - * @var DDC3785AssetId - * @Id - * @GeneratedValue(strategy="NONE") - * @Column(type="ddc3785_asset_id") - */ - private $id; - /** * @psalm-var Collection * @ManyToMany(targetEntity="DDC3785Attribute", cascade={"persist"}, orphanRemoval=true) @@ -89,9 +81,13 @@ class DDC3785Asset /** * @psalm-param list $attributes */ - public function __construct(DDC3785AssetId $id, $attributes = []) + public function __construct(/** + * @Id + * @GeneratedValue(strategy="NONE") + * @Column(type="ddc3785_asset_id") + */ + private DDC3785AssetId $id, $attributes = []) { - $this->id = $id; $this->attributes = new ArrayCollection(); foreach ($attributes as $attribute) { @@ -127,37 +123,30 @@ class DDC3785Attribute */ public $id; - /** - * @var string - * @Column(type="string", length=255) - */ - private $name; - - /** - * @var string - * @Column(type="string", length=255) - */ - private $value; - - public function __construct(string $name, string $value) + public function __construct( + /** + * @Column(type="string", length=255) + */ + private string $name, + /** + * @Column(type="string", length=255) + */ + private string $value + ) { - $this->name = $name; - $this->value = $value; } } /** @Embeddable */ -class DDC3785AssetId +class DDC3785AssetId implements \Stringable { - /** - * @var string - * @Column(type = "guid") - */ - private $id; - - public function __construct(string $id) + public function __construct( + /** + * @Column(type = "guid") + */ + private string $id + ) { - $this->id = $id; } public function __toString(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index 849cd85602c..bbb72b9a463 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -46,7 +46,7 @@ public function testIssue(): void $this->_em->flush(); $this->_em->clear(); - $customer = $this->_em->find(get_class($customer), $customer->id); + $customer = $this->_em->find($customer::class, $customer->id); self::assertInstanceOf(PersistentCollection::class, $customer->contacts); self::assertFalse($customer->contacts->isInitialized()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php index 8b30908b87b..a3114b14ee1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -55,19 +55,17 @@ public function testIssue(): void class DDC448MainTable { /** - * @var int * @Id * @Column(name="id", type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var DDC448ConnectedClass * @ManyToOne(targetEntity="DDC448ConnectedClass", cascade={"all"}, fetch="EAGER") * @JoinColumn(name="connectedClassId", referencedColumnName="id", onDelete="CASCADE", nullable=true) */ - private $connectedClassId; + private \Doctrine\Tests\ORM\Functional\Ticket\DDC448ConnectedClass $connectedClassId; } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index 8fb713ecb4d..b0ccedff8bd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -64,7 +64,7 @@ public function testJoinColumnWithSameNameAsAssociationField(): void $this->_em->flush(); $this->_em->clear(); - $fkt2 = $this->_em->find(get_class($fkt), $fkt->id); + $fkt2 = $this->_em->find($fkt::class, $fkt->id); self::assertEquals($fkt->cart->id, $fkt2->cartId); self::assertInstanceOf(Proxy::class, $fkt2->cart); self::assertFalse($fkt2->cart->__isInitialized__); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index be7fbdc43e2..c70c29c4d10 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -88,14 +88,10 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st } } -class DDC5684ObjectId +class DDC5684ObjectId implements \Stringable { - /** @var mixed */ - public $value; - - public function __construct(mixed $value) + public function __construct(public mixed $value) { - $this->value = $value; } public function __toString(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php index e09a0f4bd80..8efeee74ecd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -50,13 +50,14 @@ class DDC588Site public $id; /** - * @var string - * @Column(type="string", length=45) + * @param string $name */ - protected $name = null; - - public function __construct($name = '') + public function __construct( + /** + * @Column(type="string", length=45) + */ + protected $name = '' + ) { - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php index 3e467abb8ba..fef1aa0d4c8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -33,7 +33,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC599Child::class), ] ); - } catch (Exception $ignored) { + } catch (Exception) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index ff095dd2d0e..623a9e98840 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -45,7 +45,7 @@ protected function setUp(): void $this->_em->flush(); $this->_em->clear(); - } catch (UniqueConstraintViolationException $e) { + } catch (UniqueConstraintViolationException) { } } @@ -185,20 +185,19 @@ class DDC618Book public $id; /** - * @var string - * @Column(type="string", length=255) - */ - public $title; - - /** - * @var DDC618Author - * @ManyToOne(targetEntity="DDC618Author", inversedBy="books") + * @param string $title + * @param \Doctrine\Tests\ORM\Functional\Ticket\DDC618Author $author */ - public $author; - - public function __construct($title, $author) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public $title, + /** + * @ManyToOne(targetEntity="DDC618Author", inversedBy="books") + */ + public $author + ) { - $this->title = $title; - $this->author = $author; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php index 7b50a35b845..9222021f76f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php @@ -37,7 +37,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC6303ChildA::class), $this->_em->getClassMetadata(DDC6303ChildB::class), ]); - } catch (ToolsException $ignored) { + } catch (ToolsException) { } } @@ -120,16 +120,12 @@ abstract class DDC6303BaseClass */ class DDC6303ChildA extends DDC6303BaseClass { - /** - * @var mixed + public function __construct(string $id, /** * @Column(type="string", length=255) */ - private $originalData; - - public function __construct(string $id, mixed $originalData) + private mixed $originalData) { $this->id = $id; - $this->originalData = $originalData; } } @@ -139,18 +135,14 @@ public function __construct(string $id, mixed $originalData) */ class DDC6303ChildB extends DDC6303BaseClass { - /** - * @var mixed[] - * @Column(type="simple_array", nullable=true) - */ - private $originalData; - /** * @param mixed[] $originalData */ - public function __construct(string $id, array $originalData) + public function __construct(string $id, /** + * @Column(type="simple_array", nullable=true) + */ + private array $originalData) { $this->id = $id; - $this->originalData = $originalData; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php index 11eeabef3d7..fffc1ff34f9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php @@ -28,7 +28,7 @@ protected function setUp(): void DDC6460ParentEntity::class, ] ); - } catch (SchemaException $e) { + } catch (SchemaException) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index 7e035b15fbd..fa104a486be 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -28,10 +28,10 @@ public function testRecomputeSingleEntityChangeSetPreservesFieldOrder(): void $entity->setType('type1'); $this->_em->persist($entity); - $this->_em->getUnitOfWork()->computeChangeSet($this->_em->getClassMetadata(get_class($entity)), $entity); + $this->_em->getUnitOfWork()->computeChangeSet($this->_em->getClassMetadata($entity::class), $entity); $data1 = $this->_em->getUnitOfWork()->getEntityChangeSet($entity); $entity->setType('type2'); - $this->_em->getUnitOfWork()->recomputeSingleEntityChangeSet($this->_em->getClassMetadata(get_class($entity)), $entity); + $this->_em->getUnitOfWork()->recomputeSingleEntityChangeSet($this->_em->getClassMetadata($entity::class), $entity); $data2 = $this->_em->getUnitOfWork()->getEntityChangeSet($entity); self::assertEquals(array_keys($data1), array_keys($data2)); @@ -39,7 +39,7 @@ public function testRecomputeSingleEntityChangeSetPreservesFieldOrder(): void $this->_em->flush(); $this->_em->clear(); - $persistedEntity = $this->_em->find(get_class($entity), $entity->specificationId); + $persistedEntity = $this->_em->find($entity::class, $entity->specificationId); self::assertEquals('type2', $persistedEntity->getType()); self::assertEquals('test1', $persistedEntity->getName()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php index e998244c36d..012e28c6a21 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php @@ -29,9 +29,9 @@ public function testEntitySingleResult(): void self::assertInstanceOf(DateTimeModel::class, $datetime); - self::assertInstanceOf('DateTime', $datetime->datetime); - self::assertInstanceOf('DateTime', $datetime->time); - self::assertInstanceOf('DateTime', $datetime->date); + self::assertInstanceOf(\DateTime::class, $datetime->datetime); + self::assertInstanceOf(\DateTime::class, $datetime->time); + self::assertInstanceOf(\DateTime::class, $datetime->date); } public function testScalarResult(): void @@ -57,13 +57,13 @@ public function testaTicketEntityArrayResult(): void self::assertCount(2, $result); - self::assertInstanceOf('DateTime', $result[0]['datetime']); - self::assertInstanceOf('DateTime', $result[0]['time']); - self::assertInstanceOf('DateTime', $result[0]['date']); + self::assertInstanceOf(\DateTime::class, $result[0]['datetime']); + self::assertInstanceOf(\DateTime::class, $result[0]['time']); + self::assertInstanceOf(\DateTime::class, $result[0]['date']); - self::assertInstanceOf('DateTime', $result[1]['datetime']); - self::assertInstanceOf('DateTime', $result[1]['time']); - self::assertInstanceOf('DateTime', $result[1]['date']); + self::assertInstanceOf(\DateTime::class, $result[1]['datetime']); + self::assertInstanceOf(\DateTime::class, $result[1]['time']); + self::assertInstanceOf(\DateTime::class, $result[1]['date']); } public function testTicketSingleResult(): void @@ -73,9 +73,9 @@ public function testTicketSingleResult(): void self::assertIsArray($datetime); - self::assertInstanceOf('DateTime', $datetime['datetime']); - self::assertInstanceOf('DateTime', $datetime['time']); - self::assertInstanceOf('DateTime', $datetime['date']); + self::assertInstanceOf(\DateTime::class, $datetime['datetime']); + self::assertInstanceOf(\DateTime::class, $datetime['time']); + self::assertInstanceOf(\DateTime::class, $datetime['date']); } public function testTicketResult(): void @@ -85,15 +85,15 @@ public function testTicketResult(): void self::assertCount(2, $result); - self::assertInstanceOf('DateTime', $result[0]['time']); - self::assertInstanceOf('DateTime', $result[0]['date']); - self::assertInstanceOf('DateTime', $result[0]['datetime']); + self::assertInstanceOf(\DateTime::class, $result[0]['time']); + self::assertInstanceOf(\DateTime::class, $result[0]['date']); + self::assertInstanceOf(\DateTime::class, $result[0]['datetime']); self::assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d G:i:s')); - self::assertInstanceOf('DateTime', $result[1]['time']); - self::assertInstanceOf('DateTime', $result[1]['date']); - self::assertInstanceOf('DateTime', $result[1]['datetime']); + self::assertInstanceOf(\DateTime::class, $result[1]['time']); + self::assertInstanceOf(\DateTime::class, $result[1]['date']); + self::assertInstanceOf(\DateTime::class, $result[1]['datetime']); self::assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d G:i:s')); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php index 52f0cf6c55e..dcc78406e27 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php @@ -114,24 +114,22 @@ class Lemma public const CLASS_NAME = self::class; /** - * @var int * @Id * @Column(type="integer", name="lemma_id") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", name="lemma_name", unique=true, length=255) */ - private $lemma; + private ?string $lemma = null; /** * @var Collection * @OneToMany(targetEntity="Relation", mappedBy="parent", cascade={"persist"}) */ - private $relations; + private Collection $relations; public function __construct() { @@ -186,33 +184,29 @@ class Relation public const CLASS_NAME = self::class; /** - * @var int * @Id * @Column(type="integer", name="relation_id") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var Lemma|null * @ManyToOne(targetEntity="Lemma", inversedBy="relations") * @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id") */ - private $parent; + private ?\Doctrine\Tests\ORM\Functional\Ticket\Lemma $parent = null; /** - * @var Lemma * @OneToOne(targetEntity="Lemma") * @JoinColumn(name="relation_child_id", referencedColumnName="lemma_id") */ - private $child; + private ?\Doctrine\Tests\ORM\Functional\Ticket\Lemma $child = null; /** - * @var RelationType * @ManyToOne(targetEntity="RelationType", inversedBy="relations") * @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id") */ - private $type; + private ?\Doctrine\Tests\ORM\Functional\Ticket\RelationType $type = null; public function setParent(Lemma $parent): void { @@ -272,24 +266,21 @@ class RelationType public const CLASS_NAME = self::class; /** - * @var int * @Id * @Column(type="integer", name="relation_type_id") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", name="relation_type_name", unique=true, length=255) */ - private $type; + private ?string $type = null; /** - * @var string * @Column(type="string", name="relation_type_abbreviation", unique=true, length=255) */ - private $abbreviation; + private ?string $abbreviation = null; /** * @var Collection diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php index 71dbf66510c..f0c1d0e9814 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -99,8 +99,6 @@ class DDC719Group extends MyEntity public function __construct() { - parent::__construct(); - $this->channels = new ArrayCollection(); $this->children = new ArrayCollection(); $this->parents = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php index ff1f23e176a..5e3eff09f09 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -115,15 +115,11 @@ class DDC735Review */ protected $id; - /** - * @var DDC735Product + public function __construct(/** * @ManyToOne(targetEntity="DDC735Product", inversedBy="reviews") */ - protected $product; - - public function __construct(DDC735Product $product) + protected DDC735Product $product) { - $this->product = $product; $product->addReview($this); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php index 1869a0c3db6..508353a24cc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Query\AST\SelectStatement; use Doctrine\ORM\Proxy\Proxy; use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST; @@ -84,7 +85,7 @@ public function testDqlTreeWalkerReordering(): void class DisableFetchJoinTreeWalker extends TreeWalkerAdapter { - public function walkSelectStatement(AST\SelectStatement $AST): void + public function walkSelectStatement(SelectStatement $AST): void { foreach ($AST->selectClause->selectExpressions as $key => $selectExpr) { assert($selectExpr instanceof SelectExpression); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php index 0767866ab89..948a967201d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php @@ -50,7 +50,7 @@ public function testCollectionChangesInsideTransaction(): void $this->_em->flush(); $this->_em->clear(); - $pUser = $this->_em->find(get_class($user), $user->id); + $pUser = $this->_em->find($user::class, $user->id); assert($pUser instanceof CmsUser); self::assertNotNull($pUser, 'User not retrieved from database.'); @@ -66,12 +66,12 @@ public function testCollectionChangesInsideTransaction(): void // Add new foreach ($groups as $groupId) { - $pUser->addGroup($this->_em->find(get_class($group1), $groupId)); + $pUser->addGroup($this->_em->find($group1::class, $groupId)); } $this->_em->flush(); $this->_em->commit(); - } catch (Exception $e) { + } catch (Exception) { $this->_em->rollback(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php index d927ff5b6ba..ee405c46d34 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php @@ -37,7 +37,7 @@ public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManag $this->_em->flush(); $this->_em->clear(); - $article2 = $this->_em->find(get_class($article), $article->id); + $article2 = $this->_em->find($article::class, $article->id); $article2Again = $this->_em->createQuery( 'select a, c from Doctrine\Tests\Models\CMS\CmsArticle a join a.comments c where a.id = ?1' diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index 15c601f4990..e3a5edea93f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -166,12 +166,6 @@ class DDC832Like */ public $id; - /** - * @var string - * @Column(type="string", length=255) - */ - public $word; - /** * @var int * @Version @@ -179,9 +173,13 @@ class DDC832Like */ public $version; - public function __construct(string $word) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public string $word + ) { - $this->word = $word; } } @@ -202,12 +200,6 @@ class DDC832JoinedIndex */ public $id; - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - /** * @var int * @Version @@ -215,9 +207,13 @@ class DDC832JoinedIndex */ public $version; - public function __construct(string $name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public string $name + ) { - $this->name = $name; } } @@ -227,22 +223,14 @@ public function __construct(string $name) */ class DDC832JoinedTreeIndex extends DDC832JoinedIndex { - /** - * @var int + public function __construct(string $name, /** * @Column(type="integer") */ - public $lft; - - /** - * @var int + public int $lft, /** * @Column(type="integer") */ - public $rgt; - - public function __construct(string $name, int $lft, int $rgt) + public int $rgt) { $this->name = $name; - $this->lft = $lft; - $this->rgt = $rgt; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index f96290654f9..aacd2cc032c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -206,15 +206,13 @@ class DDC837Aggregate */ public $id; - /** - * @var string - * @Column(name="sysname", type="string", length=255) - */ - protected $sysname; - - public function __construct(string $sysname) + public function __construct( + /** + * @Column(name="sysname", type="string", length=255) + */ + protected string $sysname + ) { - $this->sysname = $sysname; } public function getSysname(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php index 6aceb9fa7f0..a84af634a33 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php @@ -10,14 +10,11 @@ class DDC849Test extends OrmFunctionalTestCase { - /** @var CmsUser */ - private $user; + private ?CmsUser $user; - /** @var CmsGroup */ - private $group1; + private CmsGroup $group1; - /** @var CmsGroup */ - private $group2; + private CmsGroup $group2; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index 8c95c98db70..1a288b79b77 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -108,18 +108,16 @@ public function testIssue(): void class DDC881User { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255) */ - private $name; + private ?string $name = null; /** * @psalm-var Collection @@ -144,24 +142,21 @@ public function setName(string $name): void class DDC881PhoneNumber { /** - * @var int * @Id * @Column(type="integer") */ - private $id; + private ?int $id = null; /** - * @var DDC881User * @Id * @ManyToOne(targetEntity="DDC881User",cascade={"all"}) */ - private $user; + private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC881User $user = null; /** - * @var string * @Column(type="string", length=255) */ - private $phonenumber; + private ?string $phonenumber = null; /** * @psalm-var Collection @@ -204,28 +199,25 @@ public function getCalls(): Collection class DDC881PhoneCall { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var DDC881PhoneNumber * @ManyToOne(targetEntity="DDC881PhoneNumber", inversedBy="calls", cascade={"all"}) * @JoinColumns({ * @JoinColumn(name="phonenumber_id", referencedColumnName="id"), * @JoinColumn(name="user_id", referencedColumnName="user_id") * }) */ - private $phonenumber; + private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC881PhoneNumber $phonenumber = null; /** - * @var string * @Column(type="string",nullable=true) */ - private $callDate; + private string $callDate; public function setPhoneNumber(DDC881PhoneNumber $phoneNumber): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php index c731b484ba4..cbd55248143 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -49,19 +49,17 @@ public function testUpdateRootVersion(): void class DDC960Root { /** - * @var int * @Id * @GeneratedValue * @Column(type="integer") */ - private $id; + private int $id; /** - * @var int * @Column(type="integer") * @Version */ - private $version; + private int $version; public function getId(): int { @@ -80,14 +78,15 @@ public function getVersion(): int class DDC960Child extends DDC960Root { /** - * @Column(type="string", length=255) - * @var string + * @param string $name */ - private $name; - - public function __construct($name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + private $name + ) { - $this->name = $name; } public function setName($name): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index 47d12315ddd..cb042a0d48e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -51,7 +51,7 @@ public function testIssue(): void $this->_em->flush(); $this->_em->clear(); - $child = $this->_em->getRepository(get_class($role))->find($child->roleID); + $child = $this->_em->getRepository($role::class)->find($child->roleID); self::assertCount(1, $child->extends); foreach ($child->extends as $parent) { self::assertEquals($role->getRoleID(), $parent->getRoleID()); @@ -70,8 +70,8 @@ public function testOneToManyChild(): void $this->_em->flush(); $this->_em->clear(); - $parentRepository = $this->_em->getRepository(get_class($parent)); - $childRepository = $this->_em->getRepository(get_class($child)); + $parentRepository = $this->_em->getRepository($parent::class); + $childRepository = $this->_em->getRepository($child::class); $parent = $parentRepository->find($parent->id); self::assertCount(1, $parent->childs); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php index 419be99c240..61b8d120536 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php @@ -82,19 +82,17 @@ private function updateData(): void * @Entity * @Table(name="GH2947_car") */ -class GH2947Car +class GH2947Car implements \Stringable { - /** - * @var string - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ - public $brand; - - public function __construct(string $brand) + public function __construct( + /** + * @Id + * @Column(type="string", length=25) + * @GeneratedValue(strategy="NONE") + */ + public string $brand + ) { - $this->brand = $brand; } public function __toString(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php index 849b0ab77ec..56acf865eac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php @@ -54,7 +54,7 @@ public function testCacheShouldBeUpdatedWhenAssociationChanges(): void $merchant = $this->_em->find(GH5562Merchant::class, $merchant->id); - $merchant->name = mt_rand(); + $merchant->name = random_int(0, mt_getrandmax()); $merchant->manager->username = 'usernameUPDATE'; $this->_em->flush(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index 7a9771de416..01335accf2d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -117,30 +117,22 @@ private function createData(): void class GH5762Driver { /** - * @var int + * @psalm-var Collection + * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="driver") + */ + public $driverRides; + + public function __construct(/** * @Id * @Column(type="integer") * @GeneratedValue(strategy="NONE") */ - public $id; - - /** - * @var string + public int $id, /** * @Column(type="string", length=255) */ - public $name; - - /** - * @psalm-var Collection - * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="driver") - */ - public $driverRides; - - public function __construct(int $id, string $name) + public string $name) { $this->driverRides = new ArrayCollection(); - $this->id = $id; - $this->name = $name; } } @@ -150,27 +142,18 @@ public function __construct(int $id, string $name) */ class GH5762DriverRide { - /** - * @var GH5762Driver + public function __construct(/** * @Id * @ManyToOne(targetEntity="GH5762Driver", inversedBy="driverRides") * @JoinColumn(name="driver_id", referencedColumnName="id") */ - public $driver; - - /** - * @var GH5762Car + public GH5762Driver $driver, /** * @Id * @ManyToOne(targetEntity="GH5762Car", inversedBy="carRides") * @JoinColumn(name="car", referencedColumnName="brand") */ - public $car; - - public function __construct(GH5762Driver $driver, GH5762Car $car) + public GH5762Car $car) { - $this->driver = $driver; - $this->car = $car; - $this->driver->driverRides->add($this); $this->car->carRides->add($this); } @@ -183,29 +166,25 @@ public function __construct(GH5762Driver $driver, GH5762Car $car) class GH5762Car { /** - * @var string + * @psalm-var Collection + * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="car") + */ + public $carRides; + + /** + * @param string $brand + * @param string $model + */ + public function __construct(/** * @Id * @Column(type="string", length=25) * @GeneratedValue(strategy="NONE") */ - public $brand; - - /** - * @var string + public $brand, /** * @Column(type="string", length=255) */ - public $model; - - /** - * @psalm-var Collection - * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="car") - */ - public $carRides; - - public function __construct($brand, $model) + public $model) { $this->carRides = new ArrayCollection(); - $this->brand = $brand; - $this->model = $model; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index 08d32498db9..c42d331a357 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -72,21 +72,19 @@ public function testLazyLoadsForeignEntitiesInOneToOneRelationWhileHavingCustomI class GH5887Cart { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="NONE") */ - private $id; + private ?int $id = null; /** * One Cart has One Customer. * - * @var GH5887Customer * @OneToOne(targetEntity="GH5887Customer", inversedBy="cart") * @JoinColumn(name="customer_id", referencedColumnName="id") */ - private $customer; + private ?\Doctrine\Tests\ORM\Functional\Ticket\GH5887Customer $customer = null; public function getId(): int { @@ -118,20 +116,18 @@ public function setCustomer(GH5887Customer $customer): void class GH5887Customer { /** - * @var GH5887CustomIdObject * @Id * @Column(type="GH5887CustomIdObject", length=255) * @GeneratedValue(strategy="NONE") */ - private $id; + private ?\Doctrine\Tests\ORM\Functional\Ticket\GH5887CustomIdObject $id = null; /** * One Customer has One Cart. * - * @var GH5887Cart * @OneToOne(targetEntity="GH5887Cart", mappedBy="customer") */ - private $cart; + private ?\Doctrine\Tests\ORM\Functional\Ticket\GH5887Cart $cart = null; public function getId(): GH5887CustomIdObject { @@ -157,14 +153,10 @@ public function setCart(GH5887Cart $cart): void } } -class GH5887CustomIdObject +class GH5887CustomIdObject implements \Stringable { - /** @var int */ - private $id; - - public function __construct(int $id) + public function __construct(private int $id) { - $this->id = $id; } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php index 82f2f453b92..e52281a6cfb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php @@ -108,14 +108,11 @@ public function getName(): string } } -class GH6141People +class GH6141People implements \Stringable { public const BOSS = 'boss'; public const EMPLOYEE = 'employee'; - /** @var string */ - private $value; - /** * @throws InvalidArgumentException */ @@ -133,9 +130,8 @@ private static function isValid(string $valid): bool return in_array($valid, [self::BOSS, self::EMPLOYEE], true); } - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } public function getValue(): string @@ -168,15 +164,13 @@ abstract class GH6141Person */ public $id; - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - - public function __construct(string $name) + public function __construct( + /** + * @Column(type="string", length=255) + */ + public string $name + ) { - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php index 27a16fc6ef0..38b3af9b220 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php @@ -86,25 +86,20 @@ public function __construct() */ class GH6217FetchedEntity { - /** - * @var GH6217AssociatedEntity - * @Id - * @Cache("NONSTRICT_READ_WRITE") - * @ManyToOne(targetEntity=GH6217AssociatedEntity::class) - */ - public $lazy; - - /** - * @var GH6217AssociatedEntity - * @Id - * @Cache("NONSTRICT_READ_WRITE") - * @ManyToOne(targetEntity=GH6217AssociatedEntity::class, fetch="EAGER") - */ - public $eager; - - public function __construct(GH6217AssociatedEntity $lazy, GH6217AssociatedEntity $eager) + public function __construct( + /** + * @Id + * @Cache("NONSTRICT_READ_WRITE") + * @ManyToOne(targetEntity=GH6217AssociatedEntity::class) + */ + public GH6217AssociatedEntity $lazy, + /** + * @Id + * @Cache("NONSTRICT_READ_WRITE") + * @ManyToOne(targetEntity=GH6217AssociatedEntity::class, fetch="EAGER") + */ + public GH6217AssociatedEntity $eager + ) { - $this->lazy = $lazy; - $this->eager = $eager; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index e6246e6bbb5..af772bed531 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -104,10 +104,9 @@ class GH6362Start protected $id; /** - * @var GH6362Base * @ManyToOne(targetEntity="GH6362Base", inversedBy="starts") */ - private $bases; + private \Doctrine\Tests\ORM\Functional\Ticket\GH6362Base $bases; } /** @@ -151,16 +150,14 @@ class GH6362Child extends GH6362Base class GH6362Join { /** - * @var int * @Column(type="integer") * @Id * @GeneratedValue */ - private $id; + private int $id; /** - * @var GH6362Child * @ManyToOne(targetEntity="GH6362Child", inversedBy="joins") */ - private $child; + private \Doctrine\Tests\ORM\Functional\Ticket\GH6362Child $child; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php index b3757dc7484..2e244587130 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php @@ -55,13 +55,6 @@ public function testFetchVersionValueForDifferentIdFieldAndColumn(): void */ class A { - /** - * @Id - * @Column(type="integer") - * @var int - */ - public $id; - /** * @Version * @Column(type="integer") @@ -69,9 +62,14 @@ class A */ public $version; - public function __construct(int $id) + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + public int $id + ) { - $this->id = $id; } } @@ -80,20 +78,6 @@ public function __construct(int $id) */ class B { - /** - * @Id - * @ManyToOne(targetEntity="A") - * @JoinColumn(name="aid", referencedColumnName="id") - * @var A - */ - public $a; - - /** - * @Column(type="string", length=255) - * @var string - */ - public $something; - /** * @Version * @Column(type="integer") @@ -101,9 +85,18 @@ class B */ public $version; - public function __construct(A $a, string $something) + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="A") + * @JoinColumn(name="aid", referencedColumnName="id") + */ + public A $a, + /** + * @Column(type="string", length=255) + */ + public string $something + ) { - $this->a = $a; - $this->something = $something; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php index a4e3137f34f..bdc23cd2068 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php @@ -147,31 +147,23 @@ public function addAttribute(string $name, string $value): void */ class GH6531ArticleAttribute { - /** - * @var GH6531Article - * @Id - * @ManyToOne(targetEntity=GH6531Article::class, inversedBy="attributes") - */ - public $article; - - /** - * @var string - * @Id - * @Column(type="string", length=255) - */ - public $attribute; - - /** - * @var string - * @Column(type="string", length=255) - */ - public $value; - - public function __construct(string $name, string $value, GH6531Article $article) + public function __construct( + /** + * @Id + * @Column(type="string", length=255) + */ + public string $attribute, + /** + * @Column(type="string", length=255) + */ + public string $value, + /** + * @Id + * @ManyToOne(targetEntity=GH6531Article::class, inversedBy="attributes") + */ + public GH6531Article $article + ) { - $this->attribute = $name; - $this->value = $value; - $this->article = $article; } } @@ -224,30 +216,22 @@ class GH6531Product */ class GH6531OrderItem { - /** - * @var GH6531Order - * @Id - * @ManyToOne(targetEntity=GH6531Order::class) - */ - public $order; - - /** - * @var GH6531Product - * @Id - * @ManyToOne(targetEntity=GH6531Product::class) - */ - public $product; - - /** - * @var int - * @Column(type="integer") - */ - public $amount = 1; - - public function __construct(GH6531Order $order, GH6531Product $product, int $amount = 1) + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity=GH6531Order::class) + */ + public GH6531Order $order, + /** + * @Id + * @ManyToOne(targetEntity=GH6531Product::class) + */ + public GH6531Product $product, + /** + * @Column(type="integer") + */ + public int $amount = 1 + ) { - $this->order = $order; - $this->product = $product; - $this->amount = $amount; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php index 9ebe631f330..7079ccccfc2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php @@ -11,14 +11,11 @@ final class GH6740Test extends OrmFunctionalTestCase { - /** @var int */ - private $productId; + private int $productId; - /** @var int */ - private $firstCategoryId; + private int $firstCategoryId; - /** @var int */ - private $secondCategoryId; + private int $secondCategoryId; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php index cb682151770..e2f4530ea85 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php @@ -74,23 +74,18 @@ public function testUpdateEntityWithIdentifierAssociationWithQuotedJoinColumn(): */ class GH7012UserData { - /** - * @var QuotedUser - * @Id - * @OneToOne(targetEntity=Doctrine\Tests\Models\Quote\User::class) - * @JoinColumn(name="`user-id`", referencedColumnName="`user-id`", onDelete="CASCADE") - */ - public $user; - - /** - * @var string - * @Column(type="string", name="`name`") - */ - public $name; - - public function __construct(QuotedUser $user, string $name) + public function __construct( + /** + * @Id + * @OneToOne(targetEntity=Doctrine\Tests\Models\Quote\User::class) + * @JoinColumn(name="`user-id`", referencedColumnName="`user-id`", onDelete="CASCADE") + */ + public QuotedUser $user, + /** + * @Column(type="string", name="`name`") + */ + public string $name + ) { - $this->user = $user; - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php index 133e092bc09..d99792d263f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php @@ -100,14 +100,6 @@ private function verifyRanking(): void */ class GH7062Ranking { - /** - * @Id - * @OneToOne(targetEntity=GH7062Season::class, inversedBy="ranking") - * @JoinColumn(name="season", referencedColumnName="id") - * @var GH7062Season - */ - public $season; - /** * @OneToMany(targetEntity=GH7062RankingPosition::class, mappedBy="ranking", cascade={"all"}) * @var Collection|GH7062RankingPosition[] @@ -118,9 +110,13 @@ class GH7062Ranking /** * @param GH7062Team[] $teams */ - public function __construct(GH7062Season $season, array $teams) + public function __construct(/** + * @Id + * @OneToOne(targetEntity=GH7062Season::class, inversedBy="ranking") + * @JoinColumn(name="season", referencedColumnName="id") + */ + public GH7062Season $season, array $teams) { - $this->season = $season; $this->positions = new ArrayCollection(); foreach ($teams as $team) { @@ -137,22 +133,20 @@ public function __construct(GH7062Season $season, array $teams) */ class GH7062Season { - /** - * @Id - * @Column(type="string", length=255) - * @var string - */ - public $id; - /** * @var GH7062Ranking|null * @OneToOne(targetEntity=GH7062Ranking::class, mappedBy="season", cascade={"all"}) */ public $ranking; - public function __construct(string $id) + public function __construct( + /** + * @Id + * @Column(type="string", length=255) + */ + public string $id + ) { - $this->id = $id; } } @@ -164,16 +158,14 @@ public function __construct(string $id) */ class GH7062Team { - /** - * @Id - * @Column(type="string", length=255) - * @var string - */ - public $id; - - public function __construct(string $id) + public function __construct( + /** + * @Id + * @Column(type="string", length=255) + */ + public string $id + ) { - $this->id = $id; } } @@ -186,31 +178,23 @@ public function __construct(string $id) class GH7062RankingPosition { /** + * @Column(type="integer") + * @var int + */ + public $points; + + public function __construct(/** * @Id * @ManyToOne(targetEntity=GH7062Ranking::class, inversedBy="positions") * @JoinColumn(name="season", referencedColumnName="season") - * @var GH7062Ranking */ - public $ranking; - - /** + public GH7062Ranking $ranking, /** * @Id * @ManyToOne(targetEntity=GH7062Team::class) * @JoinColumn(name="team_id", referencedColumnName="id") - * @var GH7062Team - */ - public $team; - - /** - * @Column(type="integer") - * @var int */ - public $points; - - public function __construct(GH7062Ranking $ranking, GH7062Team $team) + public GH7062Team $team) { - $this->ranking = $ranking; - $this->team = $team; $this->points = 0; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php index 1df4dfbc9a1..7f82d59bb7e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php @@ -22,11 +22,9 @@ */ final class GH7079Test extends OrmFunctionalTestCase { - /** @var DefaultQuoteStrategy */ - private $strategy; + private DefaultQuoteStrategy $strategy; - /** @var AbstractPlatform */ - private $platform; + private AbstractPlatform $platform; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php index f4727baa7df..985e3453ea6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php @@ -89,32 +89,25 @@ class GH7286Entity */ public $id; - /** - * @Column(nullable=true) - * @var string|null - */ - public $type; - - /** - * @Column(type="integer") - * @var int - */ - public $version; - - public function __construct(?string $type, int $version) + public function __construct( + /** + * @Column(nullable=true) + */ + public ?string $type, + /** + * @Column(type="integer") + */ + public int $version + ) { - $this->type = $type; - $this->version = $version; } } class GH7286CustomConcat extends FunctionNode { - /** @var Node */ - private $first; + private ?Node $first = null; - /** @var Node */ - private $second; + private ?Node $second = null; public function parse(Parser $parser): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php index 46a7206d66a..669d5a8b3cb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php @@ -34,7 +34,7 @@ public function testOptimisticLockNoExceptionOnFind(): void { try { $entity = $this->_em->find(GH7366Entity::class, 1, LockMode::OPTIMISTIC); - } catch (TransactionRequiredException $e) { + } catch (TransactionRequiredException) { self::fail('EntityManager::find() threw TransactionRequiredException with LockMode::OPTIMISTIC'); } @@ -62,15 +62,13 @@ class GH7366Entity */ protected $lockVersion = 1; - /** - * @Column(length=32) - * @var string - */ - protected $name; - - public function __construct(string $name) + public function __construct( + /** + * @Column(length=32) + */ + protected string $name + ) { - $this->name = $name; } public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php index ef5817e4132..fce1c67a9cd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php @@ -68,23 +68,18 @@ public function testNonUniqueObjectHydrationDuringIteration(): void */ class GH7496EntityA { - /** - * @var int - * @Id - * @Column(type="integer", name="a_id") - */ - public $id; - - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - - public function __construct(int $id, string $name) + public function __construct( + /** + * @Id + * @Column(type="integer", name="a_id") + */ + public int $id, + /** + * @Column(type="string", length=255) + */ + public string $name + ) { - $this->id = $id; - $this->name = $name; } } @@ -94,22 +89,20 @@ public function __construct(int $id, string $name) class GH7496EntityB { /** - * @var int - * @Id - * @Column(type="integer", name="b_id") - */ - public $id; - - /** - * @var string - * @Column(type="string", length=255) + * @param string $name */ - public $name; - - public function __construct(int $id, $name) + public function __construct( + /** + * @Id + * @Column(type="integer", name="b_id") + */ + public int $id, + /** + * @Column(type="string", length=255) + */ + public $name + ) { - $this->id = $id; - $this->name = $name; } } @@ -119,30 +112,26 @@ public function __construct(int $id, $name) class GH7496EntityAinB { /** - * @var int - * @Id - * @Column(type="integer") - */ - public $id; - - /** - * @var GH7496EntityA - * @ManyToOne(targetEntity=GH7496EntityA::class) - * @JoinColumn(name="a_id", referencedColumnName="a_id", nullable=false) + * @param \Doctrine\Tests\ORM\Functional\Ticket\GH7496EntityA $a + * @param \Doctrine\Tests\ORM\Functional\Ticket\GH7496EntityB $b */ - public $eA; - - /** - * @var GH7496EntityB - * @ManyToOne(targetEntity=GH7496EntityB::class) - * @JoinColumn(name="b_id", referencedColumnName="b_id", nullable=false) - */ - public $eB; - - public function __construct(int $id, $a, $b) + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + public int $id, + /** + * @ManyToOne(targetEntity=GH7496EntityA::class) + * @JoinColumn(name="a_id", referencedColumnName="a_id", nullable=false) + */ + public $eA, + /** + * @ManyToOne(targetEntity=GH7496EntityB::class) + * @JoinColumn(name="b_id", referencedColumnName="b_id", nullable=false) + */ + public $eB + ) { - $this->id = $id; - $this->eA = $a; - $this->eB = $b; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php index bf4fcd4135a..8c3cac705af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php @@ -98,20 +98,17 @@ class GH7661Participant * @GeneratedValue */ public $id; - /** - * @var GH7661User - * @ManyToOne(targetEntity=GH7661User::class) - */ - public $user; - /** - * @var GH7661Event - * @ManyToOne(targetEntity=GH7661Event::class) - */ - public $event; - public function __construct(GH7661User $user, GH7661Event $event) + public function __construct( + /** + * @ManyToOne(targetEntity=GH7661User::class) + */ + public GH7661User $user, + /** + * @ManyToOne(targetEntity=GH7661Event::class) + */ + public GH7661Event $event + ) { - $this->user = $user; - $this->event = $event; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php index 82d1282b974..c1df03ef674 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php @@ -57,25 +57,20 @@ public function findByReturnsCachedEntity(): void */ class GH7735Car { - /** - * @Id - * @Column(type="integer") - * @var int - */ - private $id; - - /** - * @ManyToOne(targetEntity=GH7735Engine::class, cascade={"all"}) - * @JoinColumn(nullable=false) - * @Cache("READ_ONLY") - * @var GH7735Engine - */ - private $engine; - - public function __construct(int $id, GH7735Engine $engine) + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + private int $id, + /** + * @ManyToOne(targetEntity=GH7735Engine::class, cascade={"all"}) + * @JoinColumn(nullable=false) + * @Cache("READ_ONLY") + */ + private GH7735Engine $engine + ) { - $this->id = $id; - $this->engine = $engine; } public function getId(): int @@ -95,32 +90,19 @@ public function getEngine(): GH7735Engine */ class GH7735Engine { - /** + public function __construct(/** * @Id * @Column(type="integer") - * @var int */ - private $id; - - /** - * @var GH7735Power + private int $id, /** + * @Column + */ + private string $model, /** * @OneToOne(targetEntity=GH7735Power::class, mappedBy="engine", cascade={"all"}) * @Cache("READ_ONLY") */ - private $power; - - /** - * @Column - * @var string - */ - private $model; - - public function __construct(int $id, string $model, GH7735Power $power) + private GH7735Power $power) { - $this->id = $id; - $this->model = $model; - $this->power = $power; - $power->setEngine($this); } @@ -147,22 +129,19 @@ public function getModel(): string class GH7735Power { /** - * @var int - * @Id - * @Column(type="integer") - */ - private $id; - - /** - * @var GH7735Engine * @OneToOne(targetEntity=GH7735Engine::class, inversedBy="power") * @Cache("READ_ONLY") */ - private $engine; - - public function __construct(int $id) + private ?\Doctrine\Tests\ORM\Functional\Ticket\GH7735Engine $engine = null; + + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + private int $id + ) { - $this->id = $id; } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php index 527a91da901..e5bb3a09cb0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php @@ -66,23 +66,18 @@ public function memberOfCriteriaShouldBeCompatibleWithQueryBuilder(): void */ class GH7737Group { - /** - * @var int - * @Id - * @Column(type="integer") - */ - public $id; - - /** - * @var string - * @Column - */ - public $name; - - public function __construct(int $id, string $name) + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + public int $id, + /** + * @Column + */ + public string $name + ) { - $this->id = $id; - $this->name = $name; } } @@ -91,13 +86,6 @@ public function __construct(int $id, string $name) */ class GH7737Person { - /** - * @var int - * @Id - * @Column(type="integer") - */ - public $id; - /** * @var Collection * @ManyToMany(targetEntity=GH7737Group::class) @@ -105,9 +93,12 @@ class GH7737Person */ public $groups; - public function __construct(int $id) + public function __construct(/** + * @Id + * @Column(type="integer") + */ + public int $id) { - $this->id = $id; $this->groups = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php index ffbc3333d5c..d816095ce39 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php @@ -69,12 +69,11 @@ public function testMatchingOverrulesCollectionOrdering(): void class GH7767ParentEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** * @psalm-var Collection @@ -103,28 +102,22 @@ public function getChildren(): Collection class GH7767ChildEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; - - /** - * @var int - * @Column(type="integer") - */ - public $position; - - /** - * @var GH7767ParentEntity - * @ManyToOne(targetEntity=GH7767ParentEntity::class, inversedBy="children") - */ - private $parent; - - public function __construct(GH7767ParentEntity $parent, int $position) + private int $id; + + public function __construct( + /** + * @ManyToOne(targetEntity=GH7767ParentEntity::class, inversedBy="children") + */ + private GH7767ParentEntity $parent, + /** + * @Column(type="integer") + */ + public int $position + ) { - $this->parent = $parent; - $this->position = $position; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php index bc5861d8860..c1f5902be22 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php @@ -75,9 +75,7 @@ public function testWillFindSongsInPaginator(): void self::assertSame( self::SONG, - array_map(static function (GH7820Line $line): string { - return $line->toString(); - }, iterator_to_array(new Paginator($query))) + array_map(static fn(GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))) ); } @@ -94,9 +92,7 @@ public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void self::assertSame( self::SONG, - array_map(static function (GH7820Line $line): string { - return $line->toString(); - }, iterator_to_array(new Paginator($query))), + array_map(static fn(GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), 'Expected to return expected data before query cache is populated with DQL -> SQL translation. Were SQL parameters translated?' ); @@ -106,9 +102,7 @@ public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void self::assertSame( self::SONG, - array_map(static function (GH7820Line $line): string { - return $line->toString(); - }, iterator_to_array(new Paginator($query))), + array_map(static fn(GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), 'Expected to return expected data even when DQL -> SQL translation is present in cache. Were SQL parameters translated again?' ); } @@ -117,23 +111,18 @@ public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void /** @Entity */ class GH7820Line { - /** - * @var GH7820LineText - * @Id() - * @Column(type="Doctrine\Tests\ORM\Functional\Ticket\GH7820LineTextType", length=255) - */ - private $text; - - /** - * @var int - * @Column(type="integer") - */ - private $lineNumber; - - public function __construct(GH7820LineText $text, int $index) + public function __construct( + /** + * @Id() + * @Column(type="Doctrine\Tests\ORM\Functional\Ticket\GH7820LineTextType", length=255) + */ + private GH7820LineText $text, + /** + * @Column(type="integer") + */ + private int $lineNumber + ) { - $this->text = $text; - $this->lineNumber = $index; } public function toString(): string @@ -142,14 +131,10 @@ public function toString(): string } } -final class GH7820LineText +final class GH7820LineText implements \Stringable { - /** @var string */ - private $text; - - private function __construct(string $text) + private function __construct(private string $text) { - $this->text = $text; } public static function fromText(string $text): self diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php index c367a337232..edba496b98b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php @@ -90,12 +90,11 @@ public function testMatchingKeepsOrderOfCriteriaOrderingKeys(): void class GH7836ParentEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** * @var Collection @@ -124,35 +123,26 @@ public function getChildren(): Collection class GH7836ChildEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; - - /** - * @var int - * @Column(type="integer") - */ - public $position; - - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - - /** - * @var GH7836ParentEntity - * @ManyToOne(targetEntity=GH7836ParentEntity::class, inversedBy="children") - */ - private $parent; - - public function __construct(GH7836ParentEntity $parent, int $position, string $name) + private int $id; + + public function __construct( + /** + * @ManyToOne(targetEntity=GH7836ParentEntity::class, inversedBy="children") + */ + private GH7836ParentEntity $parent, + /** + * @Column(type="integer") + */ + public int $position, + /** + * @Column(type="string", length=255) + */ + public string $name + ) { - $this->parent = $parent; - $this->position = $position; - $this->name = $name; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php index 5ac414fabc6..ac10ec1f954 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php @@ -57,9 +57,7 @@ public function testExtraLazyRemoveElement(): void $user->tweets->removeElement($tweet); - $tweets = $user->tweets->map(static function (GH7864Tweet $tweet) { - return $tweet->content; - }); + $tweets = $user->tweets->map(static fn(GH7864Tweet $tweet) => $tweet->content); self::assertEquals(['Goodbye, and thanks for all the fish'], array_values($tweets->toArray())); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php index 1eb4240a854..dc26fe7e8c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php @@ -44,9 +44,7 @@ public function cleanUpSchema(): void */ private function filterCreateTable(array $sqls, string $tableName): array { - return array_filter($sqls, static function (string $sql) use ($tableName): bool { - return str_starts_with($sql, sprintf('CREATE TABLE %s (', $tableName)); - }); + return array_filter($sqls, static fn(string $sql): bool => str_starts_with($sql, sprintf('CREATE TABLE %s (', $tableName))); } public function testUpdateSchemaSql(): void @@ -60,9 +58,7 @@ public function testUpdateSchemaSql(): void $this->_em->getConnection()->executeStatement(current($sqls)); - $sqls = array_filter($tool->getUpdateSchemaSql($classes), static function (string $sql): bool { - return str_contains($sql, ' gh7875_my_entity '); - }); + $sqls = array_filter($tool->getUpdateSchemaSql($classes), static fn(string $sql): bool => str_contains($sql, ' gh7875_my_entity ')); self::assertSame([], $sqls); @@ -76,9 +72,7 @@ public function testUpdateSchemaSql(): void public function testUpdateSchemaSqlWithSchemaAssetFilter(): void { - $filterCallback = static function ($assetName): bool { - return $assetName !== 'gh7875_my_entity'; - }; + $filterCallback = static fn($assetName): bool => $assetName !== 'gh7875_my_entity'; $classes = [$this->_em->getClassMetadata(GH7875MyEntity::class)]; @@ -91,9 +85,7 @@ public function testUpdateSchemaSqlWithSchemaAssetFilter(): void $previousFilter = $config->getSchemaAssetsFilter(); $sqls = $tool->getUpdateSchemaSql($classes); - $sqls = array_filter($sqls, static function (string $sql): bool { - return str_contains($sql, ' gh7875_my_entity '); - }); + $sqls = array_filter($sqls, static fn(string $sql): bool => str_contains($sql, ' gh7875_my_entity ')); self::assertCount(0, $sqls); self::assertSame($previousFilter, $config->getSchemaAssetsFilter()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php index 0bc14dc3ea6..b2331d6bf27 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php @@ -100,28 +100,20 @@ class GH7941Product */ public $id; - /** - * @var string - * @Column(type="string", length=255) - */ - public $name; - - /** - * @var string - * @Column(type="decimal") - */ - public $price; - /** * @var DateTimeImmutable * @Column(type="datetime_immutable") */ public $createdAt; - public function __construct(string $name, string $price) + public function __construct(/** + * @Column(type="string", length=255) + */ + public string $name, /** + * @Column(type="decimal") + */ + public string $price) { - $this->name = $name; - $this->price = $price; $this->createdAt = new DateTimeImmutable(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php index 48d5d3e215f..e024276e75a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php @@ -79,11 +79,7 @@ public function convertToPHPValueSQL($sqlExpr, $platform): string final class GH8061Class { - /** @var string */ - public $field; - - public function __construct(string $field) + public function __construct(public string $field) { - $this->field = $field; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php index 94e26165350..ff60ce827fd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php @@ -81,24 +81,19 @@ public function addItem(GH8217CollectionItem $item): void */ class GH8217CollectionItem { - /** - * @var GH8217Collection - * @Id - * @ManyToOne(targetEntity="GH8217Collection", inversedBy="items") - * @JoinColumn(name="id", referencedColumnName="id") - */ - public $collection; - - /** - * @var int - * @Id - * @Column(type="integer", options={"unsigned": true}) - */ - public $collectionIndex; - - public function __construct(GH8217Collection $collection, int $collectionIndex) + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="GH8217Collection", inversedBy="items") + * @JoinColumn(name="id", referencedColumnName="id") + */ + public GH8217Collection $collection, + /** + * @Id + * @Column(type="integer", options={"unsigned": true}) + */ + public int $collectionIndex + ) { - $this->collection = $collection; - $this->collectionIndex = $collectionIndex; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php index 3d3047eb145..6ab1b10f7d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php @@ -98,18 +98,11 @@ public function testJoinRootEntityWithOnlyOneEntityInHierarchy(): void class GH8443Foo { /** - * @var int|null * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; - - /** - * @var string - * @Column - */ - private $name; + private ?int $id = null; /** * @var GH8443Foo|null @@ -118,9 +111,13 @@ class GH8443Foo */ private $bar; - public function __construct(string $name) + public function __construct( + /** + * @Column + */ + private string $name + ) { - $this->name = $name; } public function getName(): ?string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php index 422fa62e0e2..12ecb8d4ecd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php @@ -94,18 +94,16 @@ public function testIssue(): void class GH9109Product { /** - * @var int $id * @Column(name="`id`", type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string $title * @Column(name="`title`", type="string", length=255) */ - private $title; + private ?string $title = null; /** * @var Collection|GH9109User[] @@ -154,24 +152,21 @@ public function addBuyer(GH9109User $buyer): void class GH9109User { /** - * @var int * @Column(name="`id`", type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(name="`first_name`", type="string", length=255) */ - private $firstName; + private ?string $firstName = null; /** - * @var string * @Column(name="last_name", type="string", length=255) */ - private $lastName; + private ?string $lastName = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php index ecfecf7b7df..c3259c58875 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php @@ -53,12 +53,11 @@ public function testInstanceOf(): void abstract class PersonTicket4646Abstract { /** - * @var int * @Id() * @GeneratedValue() * @Column(type="integer") */ - private $id; + private int $id; public function getId(): ?int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php index 3ed6574c4da..8ae9987426e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php @@ -58,12 +58,11 @@ public function testInstanceOf(): void class PersonTicket4646MultiLevel { /** - * @var int * @Id() * @GeneratedValue() * @Column(type="integer") */ - private $id; + private int $id; public function getId(): ?int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php index 38b938ce02f..3f384fff0d4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php @@ -56,12 +56,11 @@ public function testInstanceOf(): void class PersonTicket4646Parametric { /** - * @var int * @Id() * @GeneratedValue() * @Column(type="integer") */ - private $id; + private int $id; public function getId(): ?int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php index 643f286a487..83aeef6f0fa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php @@ -55,12 +55,11 @@ public function testInstanceOf(): void class PersonTicket4646 { /** - * @var int * @Id() * @GeneratedValue() * @Column(type="integer") */ - private $id; + private int $id; public function getId(): ?int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php index 702d2e8a3f3..6a0a8dae215 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php @@ -61,12 +61,11 @@ public function testInstanceOf(): void class PersonTicket4646Multiple { /** - * @var int * @Id() * @GeneratedValue() * @Column(type="integer") */ - private $id; + private int $id; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index c4fc6b44658..ff3da0ca040 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -96,7 +96,7 @@ public function testObject(): void $dql = 'SELECT s FROM ' . SerializationModel::class . ' s'; $serialize = $this->_em->createQuery($dql)->getSingleResult(); - self::assertInstanceOf('stdClass', $serialize->object); + self::assertInstanceOf(\stdClass::class, $serialize->object); } public function testDate(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php index 3b338c9252c..3e5c3351696 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php @@ -4,6 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -78,23 +81,23 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, + InversedManyToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, + OwningManyToManyCompositeIdForeignKeyEntity::class, 'ghi' ); - self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(OwningManyToManyCompositeIdForeignKeyEntity::class, $owning); } /** @@ -103,17 +106,17 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, + InversedManyToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, + OwningManyToManyCompositeIdForeignKeyEntity::class, 'ghi' ); @@ -129,16 +132,16 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, + InversedManyToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -147,7 +150,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, + OwningManyToManyCompositeIdForeignKeyEntity::class, 'ghi' ); @@ -160,7 +163,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, + InversedManyToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); @@ -178,7 +181,7 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // remove association $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, + InversedManyToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php index 50d48efe7d8..2bbbbf5987d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -70,17 +72,17 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, + InversedManyToManyCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, + OwningManyToManyCompositeIdEntity::class, 'ghi' ); - self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, $owning); + self::assertInstanceOf(InversedManyToManyCompositeIdEntity::class, $inversed); + self::assertInstanceOf(OwningManyToManyCompositeIdEntity::class, $owning); } /** @@ -89,12 +91,12 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, + InversedManyToManyCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, + OwningManyToManyCompositeIdEntity::class, 'ghi' ); @@ -109,7 +111,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, + OwningManyToManyCompositeIdEntity::class, 'ghi' ); @@ -122,7 +124,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, + InversedManyToManyCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); @@ -140,7 +142,7 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // remove association $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, + InversedManyToManyCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php index 4a1ce8b020b..4b57f4be9a3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyExtraLazyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyExtraLazyEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -67,7 +69,7 @@ public static function tearDownAfterClass(): void public function testThatTheExtraLazyCollectionFromOwningToInversedIsCounted(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyExtraLazyEntity::class, + OwningManyToManyExtraLazyEntity::class, 'ghi' ); @@ -77,7 +79,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedIsCounted(): v public function testThatTheExtraLazyCollectionFromInversedToOwningIsCounted(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyExtraLazyEntity::class, + InversedManyToManyExtraLazyEntity::class, 'abc' ); @@ -87,12 +89,12 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningIsCounted(): v public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnEntity(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyExtraLazyEntity::class, + OwningManyToManyExtraLazyEntity::class, 'ghi' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyExtraLazyEntity::class, + InversedManyToManyExtraLazyEntity::class, 'abc' ); @@ -102,12 +104,12 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnEnti public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnEntity(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyExtraLazyEntity::class, + InversedManyToManyExtraLazyEntity::class, 'abc' ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyExtraLazyEntity::class, + OwningManyToManyExtraLazyEntity::class, 'ghi' ); @@ -117,7 +119,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnEnti public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnIndexByKey(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyExtraLazyEntity::class, + OwningManyToManyExtraLazyEntity::class, 'ghi' ); @@ -127,7 +129,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnInde public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnIndexByKey(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyExtraLazyEntity::class, + InversedManyToManyExtraLazyEntity::class, 'abc' ); @@ -137,7 +139,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnInde public function testThatASliceOfTheExtraLazyCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyExtraLazyEntity::class, + OwningManyToManyExtraLazyEntity::class, 'ghi' ); @@ -147,7 +149,7 @@ public function testThatASliceOfTheExtraLazyCollectionFromOwningToInversedIsLoad public function testThatASliceOfTheExtraLazyCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyExtraLazyEntity::class, + InversedManyToManyExtraLazyEntity::class, 'abc' ); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php index 7440c3cf32a..be74346e09c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -67,17 +69,17 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyEntity::class, + InversedManyToManyEntity::class, 'abc' ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyEntity::class, + OwningManyToManyEntity::class, 'def' ); - self::assertInstanceOf(Models\ValueConversionType\InversedManyToManyEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningManyToManyEntity::class, $owning); + self::assertInstanceOf(InversedManyToManyEntity::class, $inversed); + self::assertInstanceOf(OwningManyToManyEntity::class, $owning); } /** @@ -86,12 +88,12 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyEntity::class, + InversedManyToManyEntity::class, 'abc' ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyEntity::class, + OwningManyToManyEntity::class, 'def' ); @@ -105,7 +107,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToManyEntity::class, + OwningManyToManyEntity::class, 'def' ); @@ -118,7 +120,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyEntity::class, + InversedManyToManyEntity::class, 'abc' ); @@ -136,7 +138,7 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): // remove association $inversed = $this->_em->find( - Models\ValueConversionType\InversedManyToManyEntity::class, + InversedManyToManyEntity::class, 'abc' ); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php index 4f7d92513aa..d882711d459 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php @@ -4,6 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -76,23 +79,23 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, + InversedOneToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, + OwningManyToOneCompositeIdForeignKeyEntity::class, 'ghi' ); - self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(OwningManyToOneCompositeIdForeignKeyEntity::class, $owning); } /** @@ -101,17 +104,17 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, + InversedOneToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, + OwningManyToOneCompositeIdForeignKeyEntity::class, 'ghi' ); @@ -127,16 +130,16 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, + InversedOneToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -145,7 +148,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, + OwningManyToOneCompositeIdForeignKeyEntity::class, 'ghi' ); @@ -162,7 +165,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, + InversedOneToManyCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php index d7acf4ee3e0..33d533dcc38 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -68,17 +70,17 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, + InversedOneToManyCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, + OwningManyToOneCompositeIdEntity::class, 'ghi' ); - self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, $owning); + self::assertInstanceOf(InversedOneToManyCompositeIdEntity::class, $inversed); + self::assertInstanceOf(OwningManyToOneCompositeIdEntity::class, $owning); } /** @@ -87,12 +89,12 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, + InversedOneToManyCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, + OwningManyToOneCompositeIdEntity::class, 'ghi' ); @@ -107,7 +109,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, + OwningManyToOneCompositeIdEntity::class, 'ghi' ); @@ -122,7 +124,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, + InversedOneToManyCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php index 72833ea6d60..ef851d7b4f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -64,7 +66,7 @@ public static function tearDownAfterClass(): void public function testThatExtraLazyCollectionIsCounted(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyExtraLazyEntity::class, + InversedOneToManyExtraLazyEntity::class, 'abc' ); @@ -74,12 +76,12 @@ public function testThatExtraLazyCollectionIsCounted(): void public function testThatExtraLazyCollectionContainsAnEntity(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyExtraLazyEntity::class, + InversedOneToManyExtraLazyEntity::class, 'abc' ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneExtraLazyEntity::class, + OwningManyToOneExtraLazyEntity::class, 'def' ); @@ -89,7 +91,7 @@ public function testThatExtraLazyCollectionContainsAnEntity(): void public function testThatExtraLazyCollectionContainsAnIndexbyKey(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyExtraLazyEntity::class, + InversedOneToManyExtraLazyEntity::class, 'abc' ); @@ -99,7 +101,7 @@ public function testThatExtraLazyCollectionContainsAnIndexbyKey(): void public function testThatASliceOfTheExtraLazyCollectionIsLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyExtraLazyEntity::class, + InversedOneToManyExtraLazyEntity::class, 'abc' ); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php index 22d21551c83..edfdfbcafdf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -65,17 +67,17 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyEntity::class, + InversedOneToManyEntity::class, 'abc' ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneEntity::class, + OwningManyToOneEntity::class, 'def' ); - self::assertInstanceOf(Models\ValueConversionType\InversedOneToManyEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningManyToOneEntity::class, $owning); + self::assertInstanceOf(InversedOneToManyEntity::class, $inversed); + self::assertInstanceOf(OwningManyToOneEntity::class, $owning); } /** @@ -84,12 +86,12 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyEntity::class, + InversedOneToManyEntity::class, 'abc' ); $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneEntity::class, + OwningManyToOneEntity::class, 'def' ); @@ -103,7 +105,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningManyToOneEntity::class, + OwningManyToOneEntity::class, 'def' ); @@ -118,7 +120,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToManyEntity::class, + InversedOneToManyEntity::class, 'abc' ); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php index b81c87a3cad..59683cade64 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php @@ -4,6 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -75,23 +78,23 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, + InversedOneToOneCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, + OwningOneToOneCompositeIdForeignKeyEntity::class, 'ghi' ); - self::assertInstanceOf(Models\ValueConversionType\AuxiliaryEntity::class, $auxiliary); - self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $owning); + self::assertInstanceOf(AuxiliaryEntity::class, $auxiliary); + self::assertInstanceOf(InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(OwningOneToOneCompositeIdForeignKeyEntity::class, $owning); } /** @@ -100,17 +103,17 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, + InversedOneToOneCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, + OwningOneToOneCompositeIdForeignKeyEntity::class, 'ghi' ); @@ -126,16 +129,16 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( - Models\ValueConversionType\AuxiliaryEntity::class, + AuxiliaryEntity::class, 'abc' ); $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, + InversedOneToOneCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => $auxiliary] ); - self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); + self::assertInstanceOf(InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); } /** @@ -144,7 +147,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, + OwningOneToOneCompositeIdForeignKeyEntity::class, 'ghi' ); @@ -159,10 +162,10 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, + InversedOneToOneCompositeIdForeignKeyEntity::class, ['id1' => 'def', 'foreignEntity' => 'abc'] ); - self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(OwningOneToOneCompositeIdForeignKeyEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php index 377eda727e8..bb762c1e9e7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -67,17 +69,17 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, + InversedOneToOneCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, + OwningOneToOneCompositeIdEntity::class, 'ghi' ); - self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $owning); + self::assertInstanceOf(InversedOneToOneCompositeIdEntity::class, $inversed); + self::assertInstanceOf(OwningOneToOneCompositeIdEntity::class, $owning); } /** @@ -86,12 +88,12 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, + InversedOneToOneCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, + OwningOneToOneCompositeIdEntity::class, 'ghi' ); @@ -106,7 +108,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, + OwningOneToOneCompositeIdEntity::class, 'ghi' ); @@ -121,10 +123,10 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, + InversedOneToOneCompositeIdEntity::class, ['id1' => 'abc', 'id2' => 'def'] ); - self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(OwningOneToOneCompositeIdEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php index dca86e9c891..eb7a01f1e6e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity; use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; @@ -65,17 +67,17 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneEntity::class, + InversedOneToOneEntity::class, 'abc' ); $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneEntity::class, + OwningOneToOneEntity::class, 'def' ); - self::assertInstanceOf(Models\ValueConversionType\InversedOneToOneEntity::class, $inversed); - self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $owning); + self::assertInstanceOf(InversedOneToOneEntity::class, $inversed); + self::assertInstanceOf(OwningOneToOneEntity::class, $owning); } /** @@ -84,12 +86,12 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneEntity::class, + InversedOneToOneEntity::class, 'abc' ); $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneEntity::class, + OwningOneToOneEntity::class, 'def' ); @@ -103,7 +105,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( - Models\ValueConversionType\OwningOneToOneEntity::class, + OwningOneToOneEntity::class, 'def' ); @@ -118,10 +120,10 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( - Models\ValueConversionType\InversedOneToOneEntity::class, + InversedOneToOneEntity::class, 'abc' ); - self::assertInstanceOf(Models\ValueConversionType\OwningOneToOneEntity::class, $inversed->associatedEntity); + self::assertInstanceOf(OwningOneToOneEntity::class, $inversed->associatedEntity); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 3436e2660b5..c55006b5f19 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -374,28 +374,20 @@ class DDC93Person */ public $id; - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $name; - - /** - * @var DDC93Address|null - * @Embedded(class="DDC93Address") - */ - public $address; - /** * @var DDC93Timestamps * @Embedded(class = "DDC93Timestamps") */ public $timestamps; - public function __construct(?string $name = null, ?DDC93Address $address = null) + public function __construct(/** + * @Column(type="string", length=255) + */ + public ?string $name = null, /** + * @Embedded(class="DDC93Address") + */ + public ?\Doctrine\Tests\ORM\Functional\DDC93Address $address = null) { - $this->name = $name; - $this->address = $address; $this->timestamps = new DDC93Timestamps(new DateTime()); } } @@ -405,15 +397,13 @@ public function __construct(?string $name = null, ?DDC93Address $address = null) */ class DDC93Timestamps { - /** - * @var DateTime - * @Column(type = "datetime") - */ - public $createdAt; - - public function __construct(DateTime $createdAt) + public function __construct( + /** + * @Column(type = "datetime") + */ + public DateTime $createdAt + ) { - $this->createdAt = $createdAt; } } @@ -435,15 +425,13 @@ abstract class DDC93Vehicle */ public $id; - /** - * @var DDC93Address - * @Embedded(class = "DDC93Address") - */ - public $address; - - public function __construct(DDC93Address $address) + public function __construct( + /** + * @Embedded(class = "DDC93Address") + */ + public DDC93Address $address + ) { - $this->address = $address; } } @@ -459,15 +447,13 @@ class DDC93Car extends DDC93Vehicle */ class DDC93Country { - /** - * @var string|null - * @Column(type="string", nullable=true) - */ - public $name; - - public function __construct(?string $name = null) + public function __construct( + /** + * @Column(type="string", nullable=true) + */ + public ?string $name = null + ) { - $this->name = $name; } } @@ -476,40 +462,25 @@ public function __construct(?string $name = null) */ class DDC93Address { - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $street; - - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $zip; - - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $city; - - /** - * @var DDC93Country|null - * @Embedded(class = "DDC93Country") - */ - public $country; - public function __construct( - ?string $street = null, - ?string $zip = null, - ?string $city = null, - ?DDC93Country $country = null - ) { - $this->street = $street; - $this->zip = $zip; - $this->city = $city; - $this->country = $country; + /** + * @Column(type="string", length=255) + */ + public ?string $street = null, + /** + * @Column(type="string", length=255) + */ + public ?string $zip = null, + /** + * @Column(type="string", length=255) + */ + public ?string $city = null, + /** + * @Embedded(class = "DDC93Country") + */ + public ?\Doctrine\Tests\ORM\Functional\DDC93Country $country = null + ) + { } } @@ -517,18 +488,16 @@ public function __construct( class DDC93Customer { /** - * @var int * @Id * @GeneratedValue * @Column(type="integer") */ - private $id; + private int $id; /** - * @var DDC93ContactInfo * @Embedded(class = "DDC93ContactInfo", columnPrefix = "contact_info_") */ - private $contactInfo; + private \Doctrine\Tests\ORM\Functional\DDC93ContactInfo $contactInfo; } /** @Embeddable */ @@ -552,22 +521,17 @@ class DDC93ContactInfo */ class DDC3028PersonWithPrefix { - /** - * @var DDC3028Id|null - * @Embedded(class="DDC3028Id", columnPrefix = "foobar_") - */ - public $id; - - /** - * @var DDC3028NestedEmbeddable|null - * @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "bloo_") - */ - public $nested; - - public function __construct(?DDC3028Id $id = null, ?DDC3028NestedEmbeddable $nested = null) + public function __construct( + /** + * @Embedded(class="DDC3028Id", columnPrefix = "foobar_") + */ + public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $id = null, + /** + * @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "bloo_") + */ + public ?\Doctrine\Tests\ORM\Functional\DDC3028NestedEmbeddable $nested = null + ) { - $this->id = $id; - $this->nested = $nested; } } @@ -576,22 +540,17 @@ public function __construct(?DDC3028Id $id = null, ?DDC3028NestedEmbeddable $nes */ class DDC3028PersonEmptyPrefix { - /** - * @var DDC3028Id|null - * @Embedded(class="DDC3028Id", columnPrefix = "") - */ - public $id; - - /** - * @var DDC3028NestedEmbeddable|null - * @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "") - */ - public $nested; - - public function __construct(?DDC3028Id $id = null, ?DDC3028NestedEmbeddable $nested = null) + public function __construct( + /** + * @Embedded(class="DDC3028Id", columnPrefix = "") + */ + public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $id = null, + /** + * @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "") + */ + public ?\Doctrine\Tests\ORM\Functional\DDC3028NestedEmbeddable $nested = null + ) { - $this->id = $id; - $this->nested = $nested; } } @@ -600,15 +559,13 @@ public function __construct(?DDC3028Id $id = null, ?DDC3028NestedEmbeddable $nes */ class DDC3028PersonPrefixFalse { - /** - * @var DDC3028Id|null - * @Embedded(class="DDC3028Id", columnPrefix = false) - */ - public $id; - - public function __construct(?DDC3028Id $id = null) + public function __construct( + /** + * @Embedded(class="DDC3028Id", columnPrefix = false) + */ + public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $id = null + ) { - $this->id = $id; } } @@ -617,16 +574,14 @@ public function __construct(?DDC3028Id $id = null) */ class DDC3028Id { - /** - * @var string|null - * @Id - * @Column(type="string", length=255) - */ - public $id; - - public function __construct(?string $id = null) + public function __construct( + /** + * @Id + * @Column(type="string", length=255) + */ + public ?string $id = null + ) { - $this->id = $id; } } @@ -635,32 +590,21 @@ public function __construct(?string $id = null) */ class DDC3028NestedEmbeddable { - /** - * @var DDC3028Id|null - * @Embedded(class="DDC3028Id", columnPrefix = "foo_") - */ - public $nestedWithPrefix; - - /** - * @var DDC3028Id|null - * @Embedded(class="DDC3028Id", columnPrefix = "") - */ - public $nestedWithEmptyPrefix; - - /** - * @var DDC3028Id|null - * @Embedded(class="DDC3028Id", columnPrefix = false) - */ - public $nestedWithPrefixFalse; - public function __construct( - ?DDC3028Id $nestedWithPrefix = null, - ?DDC3028Id $nestedWithEmptyPrefix = null, - ?DDC3028Id $nestedWithPrefixFalse = null - ) { - $this->nestedWithPrefix = $nestedWithPrefix; - $this->nestedWithEmptyPrefix = $nestedWithEmptyPrefix; - $this->nestedWithPrefixFalse = $nestedWithPrefixFalse; + /** + * @Embedded(class="DDC3028Id", columnPrefix = "foo_") + */ + public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $nestedWithPrefix = null, + /** + * @Embedded(class="DDC3028Id", columnPrefix = "") + */ + public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $nestedWithEmptyPrefix = null, + /** + * @Embedded(class="DDC3028Id", columnPrefix = false) + */ + public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $nestedWithPrefixFalse = null + ) + { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php index 483d2e587b0..344d9913920 100644 --- a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->_em->getClassMetadata(SecondRelatedEntity::class), ] ); - } catch (ORMException $e) { + } catch (ORMException) { } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index 635f65f309e..f5814aa64a4 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Hydration; +use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Result; @@ -1896,7 +1897,7 @@ public function testIndexByScalarsOnly($userEntityKey): void */ public function testMissingMetaMappingException(): void { - $this->expectException('Doctrine\ORM\Internal\Hydration\HydrationException'); + $this->expectException(HydrationException::class); $this->expectExceptionMessage('The meta mapping for the discriminator column "c_discr" is missing for "Doctrine\Tests\Models\Company\CompanyFixContract" using the DQL alias "c".'); $rsm = new ResultSetMapping(); @@ -1922,7 +1923,7 @@ public function testMissingMetaMappingException(): void */ public function testMissingDiscriminatorColumnException(): void { - $this->expectException('Doctrine\ORM\Internal\Hydration\HydrationException'); + $this->expectException(HydrationException::class); $this->expectExceptionMessage('The discriminator column "discr" is missing for "Doctrine\Tests\Models\Company\CompanyEmployee" using the DQL alias "e".'); $rsm = new ResultSetMapping(); @@ -1955,7 +1956,7 @@ public function testMissingDiscriminatorColumnException(): void */ public function testInvalidDiscriminatorValueException(): void { - $this->expectException('Doctrine\ORM\Internal\Hydration\HydrationException'); + $this->expectException(HydrationException::class); $this->expectExceptionMessage('The discriminator value "subworker" is invalid. It must be one of "person", "manager", "employee".'); $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php index af351504691..e4c46a530de 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php @@ -75,7 +75,7 @@ public function testExtraFieldInResultSetShouldBeIgnore(): void */ public function testInvalidDiscriminatorValueException(): void { - $this->expectException('Doctrine\ORM\Internal\Hydration\HydrationException'); + $this->expectException(HydrationException::class); $this->expectExceptionMessage('The discriminator value "subworker" is invalid. It must be one of "person", "manager", "employee".'); $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php index f26ebdc8123..7c9a2560840 100644 --- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -17,11 +17,9 @@ */ class AssignedGeneratorTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerInterface $entityManager; - /** @var AssignedGenerator */ - private $assignedGen; + private AssignedGenerator $assignedGen; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index e3b0b2e1aca..7fc532ecc59 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -30,8 +30,7 @@ class HydrationCompleteHandlerTest extends TestCase /** @var EntityManagerInterface&MockObject */ private $entityManager; - /** @var HydrationCompleteHandler */ - private $handler; + private HydrationCompleteHandler $handler; protected function setUp(): void { @@ -67,9 +66,7 @@ public function testDefersPostLoadOfEntity(int $listenersFlag): void $metadata, Events::postLoad, $entity, - self::callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity) { - return $entity === $args->getEntity() && $entityManager === $args->getObjectManager(); - }), + self::callback(static fn(LifecycleEventArgs $args) => $entity === $args->getEntity() && $entityManager === $args->getObjectManager()), $listenersFlag ); @@ -129,10 +126,8 @@ public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void self::logicalOr($metadata1, $metadata2), Events::postLoad, self::logicalOr($entity1, $entity2), - self::callback(static function (LifecycleEventArgs $args) use ($entityManager, $entity1, $entity2) { - return in_array($args->getEntity(), [$entity1, $entity2], true) - && $entityManager === $args->getObjectManager(); - }), + self::callback(static fn(LifecycleEventArgs $args) => in_array($args->getEntity(), [$entity1, $entity2], true) + && $entityManager === $args->getObjectManager()), $listenersFlag ); diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 3aff55b38b1..50a8703e8e5 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -20,11 +20,9 @@ class LazyCriteriaCollectionTest extends TestCase /** @var EntityPersister&MockObject */ private $persister; - /** @var Criteria */ - private $criteria; + private Criteria $criteria; - /** @var LazyCriteriaCollection */ - private $lazyCriteriaCollection; + private LazyCriteriaCollection $lazyCriteriaCollection; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 8d8e17665d9..fbddab2827f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -227,7 +227,7 @@ public function testEntityCustomGenerator(): void 'Generator Type' ); self::assertEquals( - ['class' => 'stdClass'], + ['class' => \stdClass::class], $class->customGeneratorDefinition, 'Custom Generator Definition' ); @@ -1479,13 +1479,13 @@ abstract class Animal * @CustomIdGenerator(class="stdClass") */ #[ORM\Id, ORM\Column(type: 'string'), ORM\GeneratedValue(strategy: 'CUSTOM')] - #[ORM\CustomIdGenerator(class: 'stdClass')] + #[ORM\CustomIdGenerator(class: \stdClass::class)] public $id; public static function loadMetadata(ClassMetadata $metadata): void { $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); - $metadata->setCustomGeneratorDefinition(['class' => 'stdClass']); + $metadata->setCustomGeneratorDefinition(['class' => \stdClass::class]); } } @@ -1513,27 +1513,22 @@ public static function loadMetadata(ClassMetadata $metadata): void #[ORM\Entity] class DDC1170Entity { - public function __construct(?string $value = null) + public function __construct( + /** + * @Column(columnDefinition = "VARCHAR(255) NOT NULL") + */ + #[ORM\Column(columnDefinition: 'VARCHAR(255) NOT NULL')] private ?string $value = null + ) { - $this->value = $value; } /** - * @var int * @Id * @GeneratedValue(strategy="NONE") * @Column(type="integer", columnDefinition = "INT unsigned NOT NULL") **/ #[ORM\Id, ORM\GeneratedValue(strategy: 'NONE'), ORM\Column(type: 'integer', columnDefinition: 'INT UNSIGNED NOT NULL')] - private $id; - - - /** - * @var string|null - * @Column(columnDefinition = "VARCHAR(255) NOT NULL") - */ - #[ORM\Column(columnDefinition: 'VARCHAR(255) NOT NULL')] - private $value; + private int $id; public function getId(): int { @@ -1633,11 +1628,10 @@ class Group class Comment { /** - * @var string * @Column(type="text") */ #[ORM\Column(type: 'text')] - private $content; + private string $content; public static function loadMetadata(ClassMetadata $metadata): void { diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index d5ba6782fe0..6b68c1f9c11 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\ORM\Mapping\InvalidColumn; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\ORM\Cache\Exception\CacheException; use Doctrine\ORM\Mapping; @@ -43,13 +44,13 @@ class AnnotationDriverTest extends AbstractMappingDriverTest */ public function testLoadMetadataForNonEntityThrowsException(): void { - $cm = new ClassMetadata('stdClass'); + $cm = new ClassMetadata(\stdClass::class); $cm->initializeReflection(new RuntimeReflectionService()); $reader = new AnnotationReader(); $annotationDriver = new AnnotationDriver($reader); $this->expectException(MappingException::class); - $annotationDriver->loadMetadataForClass('stdClass', $cm); + $annotationDriver->loadMetadataForClass(\stdClass::class, $cm); } public function testFailingSecondLevelCacheAssociation(): void @@ -71,7 +72,7 @@ public function testColumnWithMissingTypeDefaultsToString(): void $cm->initializeReflection(new RuntimeReflectionService()); $annotationDriver = $this->loadDriver(); - $annotationDriver->loadMetadataForClass(Mapping\InvalidColumn::class, $cm); + $annotationDriver->loadMetadataForClass(InvalidColumn::class, $cm); self::assertEquals('string', $cm->fieldMappings['id']['type']); } @@ -336,12 +337,11 @@ class InvalidMappedSuperClass class UsingInvalidMappedSuperClass extends InvalidMappedSuperClass { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; } /** @@ -362,12 +362,11 @@ class MappedSuperClassInheritence class AnnotationParent { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** * @PostLoad @@ -400,11 +399,10 @@ class AnnotationChild extends AnnotationParent class SuperEntity { /** - * @var string * @Id * @Column(type="string", length=255) */ - private $id; + private string $id; } /** @@ -413,10 +411,9 @@ class SuperEntity class MiddleMappedSuperclass extends SuperEntity { /** - * @var string * @Column(type="string", length=255) */ - private $name; + private string $name; } /** @@ -425,10 +422,9 @@ class MiddleMappedSuperclass extends SuperEntity class ChildEntity extends MiddleMappedSuperclass { /** - * @var string * @Column(type="string", length=255) */ - private $text; + private string $text; } /** @@ -437,10 +433,9 @@ class ChildEntity extends MiddleMappedSuperclass class InvalidFetchOption { /** - * @var CmsUser * @OneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", fetch="eager") */ - private $collection; + private CmsUser $collection; } /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index 683c8b09223..591b83014a3 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -21,11 +21,9 @@ */ class AnsiQuoteStrategyTest extends OrmTestCase { - /** @var DefaultQuoteStrategy */ - private $strategy; + private DefaultQuoteStrategy $strategy; - /** @var AbstractPlatform */ - private $platform; + private AbstractPlatform $platform; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index cf95fab31f7..03d5f6f1233 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -36,8 +36,7 @@ class BasicInheritanceMappingTest extends OrmTestCase { - /** @var ClassMetadataFactory */ - private $cmf; + private ClassMetadataFactory $cmf; protected function setUp(): void { @@ -241,40 +240,35 @@ class TransientBaseClass class EntitySubClass extends TransientBaseClass { /** - * @var int * @Id * @Column(type="integer") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255) */ - private $name; + private string $name; } /** @MappedSuperclass */ class MappedSuperclassBase { /** - * @var int * @Column(type="integer") */ - private $mapped1; + private int $mapped1; /** - * @var string * @Column(type="string", length=255) */ - private $mapped2; + private string $mapped2; /** - * @var MappedSuperclassRelated1 * @OneToOne(targetEntity="MappedSuperclassRelated1") * @JoinColumn(name="related1_id", referencedColumnName="id") */ - private $mappedRelated1; + private \Doctrine\Tests\ORM\Mapping\MappedSuperclassRelated1 $mappedRelated1; /** @var mixed */ private $transient; @@ -288,17 +282,15 @@ class MappedSuperclassRelated1 class EntitySubClass2 extends MappedSuperclassBase { /** - * @var int * @Id * @Column(type="integer") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255) */ - private $name; + private string $name; } /** @@ -311,15 +303,13 @@ class EntitySubClass2 extends MappedSuperclassBase class MappedSuperclassBaseIndex { /** - * @var string * @Column(type="string", length=255) */ - private $mapped1; + private string $mapped1; /** - * @var string * @Column(type="string", length=255) */ - private $mapped2; + private string $mapped2; } /** @@ -329,17 +319,15 @@ class MappedSuperclassBaseIndex class EntityIndexSubClass extends MappedSuperclassBaseIndex { /** - * @var int * @Id * @Column(type="integer") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255) */ - private $name; + private string $name; } /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index c73f9503c84..86138158f7b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -20,10 +20,8 @@ */ class ClassMetadataBuilderTest extends OrmTestCase { - /** @var ClassMetadata */ - private $cm; - /** @var ClassMetadataBuilder */ - private $builder; + private ClassMetadata $cm; + private ClassMetadataBuilder $builder; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 6af4de96287..34375a2c6a5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -4,6 +4,10 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Tests\Models\Quote\User; +use Doctrine\Tests\Models\Quote\Phone; +use Doctrine\Tests\Models\Quote\Group; +use Doctrine\Tests\Models\Quote\Address; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; @@ -323,10 +327,10 @@ public function testQuoteMetadata(): void $em = $this->createEntityManager($driver); $cmf->setEntityManager($em); - $userMetadata = $cmf->getMetadataFor(Quote\User::class); - $phoneMetadata = $cmf->getMetadataFor(Quote\Phone::class); - $groupMetadata = $cmf->getMetadataFor(Quote\Group::class); - $addressMetadata = $cmf->getMetadataFor(Quote\Address::class); + $userMetadata = $cmf->getMetadataFor(User::class); + $phoneMetadata = $cmf->getMetadataFor(Phone::class); + $groupMetadata = $cmf->getMetadataFor(Group::class); + $addressMetadata = $cmf->getMetadataFor(Address::class); // Phone Class Metadata self::assertTrue($phoneMetadata->fieldMappings['number']['quoted']); @@ -540,11 +544,9 @@ public function setMetadataForClass(string $className, ClassMetadata $metadata): class TestEntity1 { - /** @var int */ - private $id; + private int $id; - /** @var string */ - private $name; + private string $name; /** @var mixed */ private $other; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index d029e53a221..acb88a8358a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -27,7 +27,7 @@ public function testEvent(): void $classMetadata = $metadataFactory->getMetadataFor(LoadEventTestEntity::class); self::assertTrue($classMetadata->hasField('about')); self::assertArrayHasKey('about', $classMetadata->reflFields); - self::assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); + self::assertInstanceOf(\ReflectionProperty::class, $classMetadata->reflFields['about']); } public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void @@ -49,18 +49,16 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void class LoadEventTestEntity { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** - * @var string * @Column(type="string", length=255) */ - private $name; + private string $name; /** @var mixed */ private $about; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index bf753754676..bcbb0e04326 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -4,6 +4,15 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\CMS\One; +use Doctrine\Tests\Models\CMS\Two; +use Doctrine\Tests\Models\CMS\Three; +use Doctrine\Tests\Models\CMS\UserRepository; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\TypedProperties\UserTyped; +use Doctrine\Tests\Models\TypedProperties\Contact; +use Doctrine\Tests\Models\Company\CompanyContractListener; use ArrayObject; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadata; @@ -46,14 +55,14 @@ class ClassMetadataTest extends OrmTestCase { public function testClassMetadataInstanceSerialization(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); // Test initial state self::assertTrue(count($cm->getReflectionProperties()) === 0); - self::assertInstanceOf('ReflectionClass', $cm->reflClass); - self::assertEquals(CMS\CmsUser::class, $cm->name); - self::assertEquals(CMS\CmsUser::class, $cm->rootEntityName); + self::assertInstanceOf(\ReflectionClass::class, $cm->reflClass); + self::assertEquals(CmsUser::class, $cm->name); + self::assertEquals(CmsUser::class, $cm->rootEntityName); self::assertEquals([], $cm->subClasses); self::assertEquals([], $cm->parentClasses); self::assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType); @@ -79,25 +88,25 @@ public function testClassMetadataInstanceSerialization(): void self::assertTrue(count($cm->getReflectionProperties()) > 0); self::assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace); self::assertInstanceOf(ReflectionClass::class, $cm->reflClass); - self::assertEquals(CMS\CmsUser::class, $cm->name); + self::assertEquals(CmsUser::class, $cm->name); self::assertEquals('UserParent', $cm->rootEntityName); - self::assertEquals([CMS\One::class, CMS\Two::class, CMS\Three::class], $cm->subClasses); + self::assertEquals([One::class, Two::class, Three::class], $cm->subClasses); self::assertEquals(['UserParent'], $cm->parentClasses); - self::assertEquals(CMS\UserRepository::class, $cm->customRepositoryClassName); + self::assertEquals(UserRepository::class, $cm->customRepositoryClassName); self::assertEquals(['name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'], $cm->discriminatorColumn); self::assertTrue($cm->associationMappings['phonenumbers']['type'] === ClassMetadata::ONE_TO_ONE); self::assertEquals(1, count($cm->associationMappings)); $oneOneMapping = $cm->getAssociationMapping('phonenumbers'); self::assertTrue($oneOneMapping['fetch'] === ClassMetadata::FETCH_LAZY); self::assertEquals('phonenumbers', $oneOneMapping['fieldName']); - self::assertEquals(CMS\CmsAddress::class, $oneOneMapping['targetEntity']); + self::assertEquals(CmsAddress::class, $oneOneMapping['targetEntity']); self::assertTrue($cm->isReadOnly); self::assertTrue($cm->requiresFetchAfterChange); } public function testFieldIsNullable(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); // Explicit Nullable @@ -115,7 +124,7 @@ public function testFieldIsNullable(): void public function testFieldIsNullableByType(): void { - $cm = new ClassMetadata(TypedProperties\UserTyped::class); + $cm = new ClassMetadata(UserTyped::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapOneToOne(['fieldName' => 'email', 'joinColumns' => [[]]]); @@ -125,12 +134,12 @@ public function testFieldIsNullableByType(): void self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('mainEmail')['targetEntity']); $cm->mapEmbedded(['fieldName' => 'contact']); - self::assertEquals(TypedProperties\Contact::class, $cm->embeddedClasses['contact']['class']); + self::assertEquals(Contact::class, $cm->embeddedClasses['contact']['class']); } public function testFieldTypeFromReflection(): void { - $cm = new ClassMetadata(TypedProperties\UserTyped::class); + $cm = new ClassMetadata(UserTyped::class); $cm->initializeReflection(new RuntimeReflectionService()); // Integer @@ -192,7 +201,7 @@ public function testMapAssociationInGlobalNamespace(): void public function testMapManyToManyJoinTableDefaults(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapManyToMany( [ @@ -215,7 +224,7 @@ public function testMapManyToManyJoinTableDefaults(): void public function testSerializeManyToManyJoinTableCascade(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapManyToMany( [ @@ -268,7 +277,7 @@ public function testSetInvalidVersionMappingThrowsException(): void $field['fieldName'] = 'foo'; $field['type'] = 'string'; - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $this->expectException(MappingException::class); @@ -277,7 +286,7 @@ public function testSetInvalidVersionMappingThrowsException(): void public function testGetSingleIdentifierFieldNameMultipleIdentifierEntityThrowsException(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->isIdentifierComposite = true; @@ -296,11 +305,11 @@ public function testGetSingleIdentifierFieldNameNoIdEntityThrowsException(): voi public function testDuplicateAssociationMappingException(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $a1 = ['fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo']; - $a2 = ['fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo']; + $a1 = ['fieldName' => 'foo', 'sourceEntity' => \stdClass::class, 'targetEntity' => \stdClass::class, 'mappedBy' => 'foo']; + $a2 = ['fieldName' => 'foo', 'sourceEntity' => \stdClass::class, 'targetEntity' => \stdClass::class, 'mappedBy' => 'foo']; $cm->addInheritedAssociationMapping($a1); $this->expectException(MappingException::class); @@ -309,7 +318,7 @@ public function testDuplicateAssociationMappingException(): void public function testDuplicateColumnNameThrowsMappingException(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapField(['fieldName' => 'name', 'columnName' => 'name']); @@ -320,7 +329,7 @@ public function testDuplicateColumnNameThrowsMappingException(): void public function testDuplicateColumnNameDiscriminatorColumnThrowsMappingException(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapField(['fieldName' => 'name', 'columnName' => 'name']); @@ -331,7 +340,7 @@ public function testDuplicateColumnNameDiscriminatorColumnThrowsMappingException public function testDuplicateColumnNameDiscriminatorColumn2ThrowsMappingException(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->setDiscriminatorColumn(['name' => 'name']); @@ -342,7 +351,7 @@ public function testDuplicateColumnNameDiscriminatorColumn2ThrowsMappingExceptio public function testDuplicateFieldAndAssociationMapping1ThrowsException(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapField(['fieldName' => 'name', 'columnName' => 'name']); @@ -353,7 +362,7 @@ public function testDuplicateFieldAndAssociationMapping1ThrowsException(): void public function testDuplicateFieldAndAssociationMapping2ThrowsException(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapOneToOne(['fieldName' => 'name', 'targetEntity' => 'CmsUser']); @@ -367,7 +376,7 @@ public function testDuplicateFieldAndAssociationMapping2ThrowsException(): void */ public function testGetTemporaryTableNameSchema(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->setTableName('foo.bar'); @@ -377,7 +386,7 @@ public function testGetTemporaryTableNameSchema(): void public function testDefaultTableName(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); // When table's name is not given @@ -387,7 +396,7 @@ public function testDefaultTableName(): void self::assertEquals('CmsUser', $cm->getTableName()); self::assertEquals('CmsUser', $cm->table['name']); - $cm = new ClassMetadata(CMS\CmsAddress::class); + $cm = new ClassMetadata(CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); // When joinTable's name is not given $cm->mapManyToMany( @@ -406,7 +415,7 @@ public function testDefaultTableName(): void public function testDefaultJoinColumnName(): void { - $cm = new ClassMetadata(CMS\CmsAddress::class); + $cm = new ClassMetadata(CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); // this is really dirty, but it's the simplest way to test whether @@ -420,7 +429,7 @@ public function testDefaultJoinColumnName(): void ); self::assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); - $cm = new ClassMetadata(CMS\CmsAddress::class); + $cm = new ClassMetadata(CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapManyToMany( [ @@ -444,8 +453,8 @@ public function testDefaultJoinColumnName(): void public function testUnderscoreNamingStrategyDefaults(): void { $namingStrategy = new UnderscoreNamingStrategy(CASE_UPPER); - $oneToOneMetadata = new ClassMetadata(CMS\CmsAddress::class, $namingStrategy); - $manyToManyMetadata = new ClassMetadata(CMS\CmsAddress::class, $namingStrategy); + $oneToOneMetadata = new ClassMetadata(CmsAddress::class, $namingStrategy); + $manyToManyMetadata = new ClassMetadata(CmsAddress::class, $namingStrategy); $oneToOneMetadata->mapOneToOne( [ @@ -481,7 +490,7 @@ public function testUnderscoreNamingStrategyDefaults(): void self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); $cm = new ClassMetadata('DoctrineGlobalArticle', $namingStrategy); - $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CMS\CmsUser::class]); + $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CmsUser::class]); self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); } @@ -490,7 +499,7 @@ public function testUnderscoreNamingStrategyDefaults(): void */ public function testSetMultipleIdentifierSetsComposite(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapField(['fieldName' => 'name']); @@ -505,11 +514,11 @@ public function testSetMultipleIdentifierSetsComposite(): void */ public function testMappingNotFound(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $this->expectException(MappingException::class); - $this->expectExceptionMessage("No mapping found for field 'foo' on class '" . CMS\CmsUser::class . "'."); + $this->expectExceptionMessage("No mapping found for field 'foo' on class '" . CmsUser::class . "'."); $cm->getFieldMapping('foo'); } @@ -522,7 +531,7 @@ public function testJoinTableMappingDefaults(): void $cm = new ClassMetadata('DoctrineGlobalArticle'); $cm->initializeReflection(new RuntimeReflectionService()); - $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CMS\CmsUser::class]); + $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CmsUser::class]); self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']['joinTable']['name']); } @@ -619,9 +628,9 @@ public function testIdentifierAssociationManyToMany(): void public function testEmptyFieldNameThrowsException(): void { $this->expectException(MappingException::class); - $this->expectExceptionMessage("The field or association mapping misses the 'fieldName' attribute in entity '" . CMS\CmsUser::class . "'."); + $this->expectExceptionMessage("The field or association mapping misses the 'fieldName' attribute in entity '" . CmsUser::class . "'."); - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapField(['fieldName' => '']); @@ -632,7 +641,7 @@ public function testEmptyFieldNameThrowsException(): void */ public function testRetrievalOfResultSetMappings(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); self::assertCount(0, $cm->getSqlResultSetMappings()); @@ -642,7 +651,7 @@ public function testRetrievalOfResultSetMappings(): void 'name' => 'find-all', 'entities' => [ [ - 'entityClass' => CMS\CmsUser::class, + 'entityClass' => CmsUser::class, ], ], ] @@ -656,7 +665,7 @@ public function testRetrievalOfResultSetMappings(): void */ public function testRetrieveOfSqlResultSetMapping(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->addSqlResultSetMapping( @@ -677,7 +686,7 @@ public function testRetrieveOfSqlResultSetMapping(): void ], ], [ - 'entityClass' => CMS\CmsEmail::class, + 'entityClass' => CmsEmail::class, 'fields' => [ [ 'name' => 'id', @@ -698,11 +707,11 @@ public function testRetrieveOfSqlResultSetMapping(): void $mapping = $cm->getSqlResultSetMapping('find-all'); - self::assertEquals(CMS\CmsUser::class, $mapping['entities'][0]['entityClass']); + self::assertEquals(CmsUser::class, $mapping['entities'][0]['entityClass']); self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - self::assertEquals(CMS\CmsEmail::class, $mapping['entities'][1]['entityClass']); + self::assertEquals(CmsEmail::class, $mapping['entities'][1]['entityClass']); self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][1]['fields'][0]); self::assertEquals(['name' => 'email', 'column' => 'email'], $mapping['entities'][1]['fields'][1]); @@ -731,9 +740,9 @@ public function testSerializeEntityListeners(): void */ public function testNamingCollisionSqlResultSetMappingShouldThrowException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Result set mapping named "find-all" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once'); - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->addSqlResultSetMapping( @@ -741,7 +750,7 @@ public function testNamingCollisionSqlResultSetMappingShouldThrowException(): vo 'name' => 'find-all', 'entities' => [ [ - 'entityClass' => CMS\CmsUser::class, + 'entityClass' => CmsUser::class, ], ], ] @@ -752,7 +761,7 @@ public function testNamingCollisionSqlResultSetMappingShouldThrowException(): vo 'name' => 'find-all', 'entities' => [ [ - 'entityClass' => CMS\CmsUser::class, + 'entityClass' => CmsUser::class, ], ], ] @@ -764,11 +773,11 @@ public function testNamingCollisionSqlResultSetMappingShouldThrowException(): vo */ public function testClassCaseSensitivity(): void { - $user = new CMS\CmsUser(); - $cm = new ClassMetadata(strtoupper(CMS\CmsUser::class)); + $user = new CmsUser(); + $cm = new ClassMetadata(strtoupper(CmsUser::class)); $cm->initializeReflection(new RuntimeReflectionService()); - self::assertEquals(CMS\CmsUser::class, $cm->name); + self::assertEquals(CmsUser::class, $cm->name); } /** @@ -776,12 +785,12 @@ public function testClassCaseSensitivity(): void */ public function testLifecycleCallbackNotFound(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->addLifecycleCallback('notfound', 'postLoad'); $this->expectException(MappingException::class); - $this->expectExceptionMessage("Entity '" . CMS\CmsUser::class . "' has no method 'notfound' to be registered as lifecycle callback."); + $this->expectExceptionMessage("Entity '" . CmsUser::class . "' has no method 'notfound' to be registered as lifecycle callback."); $cm->validateLifecycleCallbacks(new RuntimeReflectionService()); } @@ -791,12 +800,12 @@ public function testLifecycleCallbackNotFound(): void */ public function testTargetEntityNotFound(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapManyToOne(['fieldName' => 'address', 'targetEntity' => 'UnknownClass']); $this->expectException(MappingException::class); - $this->expectExceptionMessage("The target-entity Doctrine\\Tests\\Models\\CMS\\UnknownClass cannot be found in '" . CMS\CmsUser::class . "#address'."); + $this->expectExceptionMessage("The target-entity Doctrine\\Tests\\Models\\CMS\\UnknownClass cannot be found in '" . CmsUser::class . "#address'."); $cm->validateAssociations(); } @@ -806,9 +815,9 @@ public function testTargetEntityNotFound(): void */ public function testNameIsMandatoryForEntityNameSqlResultSetMappingException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Result set mapping named "find-all" in "Doctrine\Tests\Models\CMS\CmsUser requires a entity class name.'); - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->addSqlResultSetMapping( [ @@ -824,9 +833,9 @@ public function testNameIsMandatoryForEntityNameSqlResultSetMappingException(): public function testNameIsMandatoryForDiscriminatorColumnsMappingException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Discriminator column name on entity class \'Doctrine\Tests\Models\CMS\CmsUser\' is not defined.'); - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->setDiscriminatorColumn([]); } @@ -839,7 +848,7 @@ public function testNameIsMandatoryForDiscriminatorColumnsMappingException(): vo public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void { $namingStrategy = new MyNamespacedNamingStrategy(); - $addressMetadata = new ClassMetadata(CMS\CmsAddress::class, $namingStrategy); + $addressMetadata = new ClassMetadata(CmsAddress::class, $namingStrategy); $articleMetadata = new ClassMetadata(DoctrineGlobalArticle::class, $namingStrategy); $routingMetadata = new ClassMetadata(RoutingLeg::class, $namingStrategy); @@ -857,7 +866,7 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void $articleMetadata->mapManyToMany( [ 'fieldName' => 'author', - 'targetEntity' => CMS\CmsUser::class, + 'targetEntity' => CmsUser::class, ] ); @@ -873,7 +882,7 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategyPropertyToColumnName(): void { $namingStrategy = new MyPrefixNamingStrategy(); - $metadata = new ClassMetadata(CMS\CmsAddress::class, $namingStrategy); + $metadata = new ClassMetadata(CmsAddress::class, $namingStrategy); $metadata->initializeReflection(new RuntimeReflectionService()); @@ -891,11 +900,11 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategyProperty */ public function testInvalidCascade(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $this->expectException(MappingException::class); - $this->expectExceptionMessage('You have specified invalid cascade options for ' . CMS\CmsUser::class . "::\$address: 'invalid'; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'"); + $this->expectExceptionMessage('You have specified invalid cascade options for ' . CmsUser::class . "::\$address: 'invalid'; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'"); $cm->mapManyToOne(['fieldName' => 'address', 'targetEntity' => 'UnknownClass', 'cascade' => ['invalid']]); } @@ -906,7 +915,7 @@ public function testInvalidCascade(): void */ public function testInvalidPropertyAssociationOverrideNameException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Invalid field override named \'invalidPropertyName\' for class \'Doctrine\Tests\Models\DDC964\DDC964Admin'); $cm = new ClassMetadata(DDC964Admin::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -921,7 +930,7 @@ public function testInvalidPropertyAssociationOverrideNameException(): void */ public function testInvalidPropertyAttributeOverrideNameException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Invalid field override named \'invalidPropertyName\' for class \'Doctrine\Tests\Models\DDC964\DDC964Guest\'.'); $cm = new ClassMetadata(DDC964Guest::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -936,7 +945,7 @@ public function testInvalidPropertyAttributeOverrideNameException(): void */ public function testInvalidOverrideAttributeFieldTypeException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('The column type of attribute \'name\' on class \'Doctrine\Tests\Models\DDC964\DDC964Guest\' could not be changed.'); $cm = new ClassMetadata(DDC964Guest::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -950,9 +959,9 @@ public function testInvalidOverrideAttributeFieldTypeException(): void */ public function testInvalidEntityListenerClassException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Entity Listener "\InvalidClassName" declared on "Doctrine\Tests\Models\CMS\CmsUser" not found.'); - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->addEntityListener(Events::postLoad, '\InvalidClassName', 'postLoadHandler'); @@ -963,12 +972,12 @@ public function testInvalidEntityListenerClassException(): void */ public function testInvalidEntityListenerMethodException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Entity Listener "\Doctrine\Tests\Models\Company\CompanyContractListener" declared on "Doctrine\Tests\Models\CMS\CmsUser" has no method "invalidMethod".'); - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $cm->addEntityListener(Events::postLoad, '\Doctrine\Tests\Models\Company\CompanyContractListener', 'invalidMethod'); + $cm->addEntityListener(Events::postLoad, CompanyContractListener::class, 'invalidMethod'); } public function testManyToManySelfReferencingNamingStrategyDefaults(): void @@ -1000,7 +1009,7 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void */ public function testSetSequenceGeneratorThrowsExceptionWhenSequenceNameIsMissing(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $this->expectException(MappingException::class); @@ -1013,7 +1022,7 @@ public function testSetSequenceGeneratorThrowsExceptionWhenSequenceNameIsMissing */ public function testQuotedSequenceName(): void { - $cm = new ClassMetadata(CMS\CmsUser::class); + $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); $cm->setSequenceGeneratorDefinition(['sequenceName' => '`foo`']); @@ -1085,7 +1094,7 @@ public function testWakeupReflectionWithEmbeddableAndStaticReflectionService(): public function testGetColumnNamesWithGivenFieldNames(): void { - $metadata = new ClassMetadata(CMS\CmsUser::class); + $metadata = new ClassMetadata(CmsUser::class); $metadata->initializeReflection(new RuntimeReflectionService()); $metadata->mapField(['fieldName' => 'status', 'type' => 'string', 'columnName' => 'foo']); diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index 135ac62a956..feb3b3af060 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Tests\Models\Company\CompanyContractListener; +use Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener; use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; use Doctrine\Tests\OrmTestCase; @@ -12,8 +14,7 @@ */ class EntityListenerResolverTest extends OrmTestCase { - /** @var DefaultEntityListenerResolver */ - private $resolver; + private DefaultEntityListenerResolver $resolver; protected function setUp(): void { @@ -23,7 +24,7 @@ protected function setUp(): void public function testResolve(): void { - $className = '\Doctrine\Tests\Models\Company\CompanyContractListener'; + $className = CompanyContractListener::class; $object = $this->resolver->resolve($className); self::assertInstanceOf($className, $object); @@ -32,7 +33,7 @@ public function testResolve(): void public function testRegisterAndResolve(): void { - $className = '\Doctrine\Tests\Models\Company\CompanyContractListener'; + $className = CompanyContractListener::class; $object = new $className(); $this->resolver->register($object); @@ -42,8 +43,8 @@ public function testRegisterAndResolve(): void public function testClearOne(): void { - $className1 = '\Doctrine\Tests\Models\Company\CompanyContractListener'; - $className2 = '\Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener'; + $className1 = CompanyContractListener::class; + $className2 = CompanyFlexUltraContractListener::class; $obj1 = $this->resolver->resolve($className1); $obj2 = $this->resolver->resolve($className2); @@ -65,8 +66,8 @@ public function testClearOne(): void public function testClearAll(): void { - $className1 = '\Doctrine\Tests\Models\Company\CompanyContractListener'; - $className2 = '\Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener'; + $className1 = CompanyContractListener::class; + $className2 = CompanyFlexUltraContractListener::class; $obj1 = $this->resolver->resolve($className1); $obj2 = $this->resolver->resolve($className2); @@ -88,7 +89,7 @@ public function testClearAll(): void public function testRegisterStringException(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('An object was expected, but got "string".'); $this->resolver->register('CompanyContractListener'); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php index cef9bbc723e..185364fcfad 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php @@ -18,11 +18,11 @@ public function testCustomIdGeneratorCanBeSet(): void $fieldBuilder = $cmBuilder->createField('aField', 'string'); $fieldBuilder->generatedValue('CUSTOM'); - $fieldBuilder->setCustomIdGenerator('stdClass'); + $fieldBuilder->setCustomIdGenerator(\stdClass::class); $fieldBuilder->build(); self::assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $cmBuilder->getClassMetadata()->generatorType); - self::assertEquals(['class' => 'stdClass'], $cmBuilder->getClassMetadata()->customGeneratorDefinition); + self::assertEquals(['class' => \stdClass::class], $cmBuilder->getClassMetadata()->customGeneratorDefinition); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php index 16b0f67ed94..85a027469a4 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php @@ -160,12 +160,10 @@ public static function dataJoinColumnName(): array } /** - * @param UnderscoreNamingStrategy|DefaultNamingStrategy $strategy - * * @dataProvider dataJoinColumnName */ public function testJoinColumnName( - NamingStrategy $strategy, + UnderscoreNamingStrategy|DefaultNamingStrategy $strategy, string $expected, string $propertyName, ?string $className = null diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php index bd0d5ab99d3..58a1654e1af 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php @@ -20,11 +20,9 @@ */ class QuoteStrategyTest extends OrmTestCase { - /** @var DefaultQuoteStrategy */ - private $strategy; + private DefaultQuoteStrategy $strategy; - /** @var AbstractPlatform */ - private $platform; + private AbstractPlatform $platform; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php index 774cd80d482..c6d72cfb7de 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php @@ -21,8 +21,7 @@ */ abstract class AbstractDriverTest extends TestCase { - /** @var string */ - private $dir; + private string $dir; public function testFindMappingFile(): void { diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index a9da33e1e49..a82eddce744 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -153,7 +153,7 @@ public function testEmbeddedMapping(): void */ public function testInvalidMappingFileException(): void { - $this->expectException('Doctrine\Persistence\Mapping\MappingException'); + $this->expectException(\Doctrine\Persistence\Mapping\MappingException::class); $this->expectExceptionMessage('Invalid mapping file \'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml\' for class \'Doctrine\Tests\Models\Generic\SerializationModel\'.'); $this->createClassMetadata(SerializationModel::class); } diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index 528e2823afd..f4d82b265e1 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -28,8 +28,7 @@ class PersistentCollectionTest extends OrmTestCase /** @var PersistentCollection */ protected $collection; - /** @var EntityManagerMock */ - private $_emMock; + private EntityManagerMock $_emMock; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index 99d9c70bec7..ed5e202fbfb 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -31,14 +31,11 @@ */ class ProxyFactoryTest extends OrmTestCase { - /** @var UnitOfWorkMock */ - private $uowMock; + private UnitOfWorkMock $uowMock; - /** @var EntityManagerMock */ - private $emMock; + private EntityManagerMock $emMock; - /** @var ProxyFactory */ - private $proxyFactory; + private ProxyFactory $proxyFactory; protected function setUp(): void { @@ -139,7 +136,7 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void try { $proxy->getDescription(); self::fail('An exception was expected to be raised'); - } catch (EntityNotFoundException $exception) { + } catch (EntityNotFoundException) { } self::assertFalse($proxy->__isInitialized()); @@ -170,7 +167,7 @@ public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void try { $cloned = clone $proxy; self::fail('An exception was expected to be raised'); - } catch (EntityNotFoundException $exception) { + } catch (EntityNotFoundException) { } self::assertFalse($proxy->__isInitialized()); diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php index 75a9d9dec5e..f9ca3d300de 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php @@ -16,8 +16,7 @@ */ class CustomTreeWalkersJoinTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $em; + private EntityManagerInterface $em; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index b2267078ff5..c3fab8a4dd8 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -4,6 +4,15 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\TreeWalkerAdapter; +use Doctrine\ORM\Query\AST\PathExpression; +use Doctrine\ORM\Query\AST\ComparisonExpression; +use Doctrine\ORM\Query\AST\ConditionalPrimary; +use Doctrine\ORM\Query\AST\ConditionalFactor; +use Doctrine\ORM\Query\AST\ConditionalExpression; +use Doctrine\ORM\Query\AST\ConditionalTerm; +use Doctrine\ORM\Query\AST\WhereClause; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query; use Doctrine\ORM\Query\QueryException; @@ -23,8 +32,7 @@ */ class CustomTreeWalkersTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerInterface $entityManager; protected function setUp(): void { @@ -110,9 +118,9 @@ public function testSupportsSeveralHintsQueries(): void } } -class AddUnknownQueryComponentWalker extends Query\SqlWalker +class AddUnknownQueryComponentWalker extends SqlWalker { - public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): void + public function walkSelectStatement(SelectStatement $selectStatement): void { parent::walkSelectStatement($selectStatement); @@ -120,9 +128,9 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): } } -class CustomTreeWalker extends Query\TreeWalkerAdapter +class CustomTreeWalker extends TreeWalkerAdapter { - public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): void + public function walkSelectStatement(SelectStatement $selectStatement): void { // Get the DQL aliases of all the classes we want to modify $dqlAliases = []; @@ -138,14 +146,14 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): // Create our conditions for all involved classes $factors = []; foreach ($dqlAliases as $alias) { - $pathExpr = new Query\AST\PathExpression(Query\AST\PathExpression::TYPE_STATE_FIELD, $alias, 'id'); - $pathExpr->type = Query\AST\PathExpression::TYPE_STATE_FIELD; - $comparisonExpr = new Query\AST\ComparisonExpression($pathExpr, '=', 1); + $pathExpr = new PathExpression(PathExpression::TYPE_STATE_FIELD, $alias, 'id'); + $pathExpr->type = PathExpression::TYPE_STATE_FIELD; + $comparisonExpr = new ComparisonExpression($pathExpr, '=', 1); - $condPrimary = new Query\AST\ConditionalPrimary(); + $condPrimary = new ConditionalPrimary(); $condPrimary->simpleConditionalExpression = $comparisonExpr; - $factor = new Query\AST\ConditionalFactor($condPrimary); + $factor = new ConditionalFactor($condPrimary); $factors[] = $factor; } @@ -155,8 +163,8 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): $condExpr = $whereClause->conditionalExpression; // Since Phase 1 AST optimizations were included, we need to re-add the ConditionalExpression - if (! ($condExpr instanceof Query\AST\ConditionalExpression)) { - $condExpr = new Query\AST\ConditionalExpression([$condExpr]); + if (! ($condExpr instanceof ConditionalExpression)) { + $condExpr = new ConditionalExpression([$condExpr]); $whereClause->conditionalExpression = $condExpr; } @@ -167,10 +175,10 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): // More than one term, so we need to wrap all these terms in a single root term // i.e: "WHERE u.name = :foo or u.other = :bar" => "WHERE (u.name = :foo or u.other = :bar) AND " - $primary = new Query\AST\ConditionalPrimary(); - $primary->conditionalExpression = new Query\AST\ConditionalExpression($existingTerms); - $existingFactor = new Query\AST\ConditionalFactor($primary); - $term = new Query\AST\ConditionalTerm(array_merge([$existingFactor], $factors)); + $primary = new ConditionalPrimary(); + $primary->conditionalExpression = new ConditionalExpression($existingTerms); + $existingFactor = new ConditionalFactor($primary); + $term = new ConditionalTerm([...[$existingFactor], ...$factors]); $selectStatement->whereClause->conditionalExpression->conditionalTerms = [$term]; } else { @@ -178,8 +186,8 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): $singleTerm = $selectStatement->whereClause->conditionalExpression->conditionalTerms[0]; // Since Phase 1 AST optimizations were included, we need to re-add the ConditionalExpression - if (! ($singleTerm instanceof Query\AST\ConditionalTerm)) { - $singleTerm = new Query\AST\ConditionalTerm([$singleTerm]); + if (! ($singleTerm instanceof ConditionalTerm)) { + $singleTerm = new ConditionalTerm([$singleTerm]); $selectStatement->whereClause->conditionalExpression->conditionalTerms[0] = $singleTerm; } @@ -189,9 +197,9 @@ public function walkSelectStatement(Query\AST\SelectStatement $selectStatement): } } else { // Create a new WHERE clause with our factors - $term = new Query\AST\ConditionalTerm($factors); - $condExpr = new Query\AST\ConditionalExpression([$term]); - $whereClause = new Query\AST\WhereClause($condExpr); + $term = new ConditionalTerm($factors); + $condExpr = new ConditionalExpression([$term]); + $whereClause = new WhereClause($condExpr); $selectStatement->whereClause = $whereClause; } } diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php index 2d9fff77757..1e954ceb294 100644 --- a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php @@ -18,8 +18,7 @@ */ class DeleteSqlGenerationTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerInterface $entityManager; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index 4cd6c43e2bc..33e08889ccb 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -4,6 +4,17 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\ORM\Query\Expr\Andx; +use Doctrine\ORM\Query\Expr\Comparison; +use Doctrine\ORM\Query\Expr\From; +use Doctrine\ORM\Query\Expr\Func; +use Doctrine\ORM\Query\Expr\GroupBy; +use Doctrine\ORM\Query\Expr\Join; +use Doctrine\ORM\Query\Expr\Literal; +use Doctrine\ORM\Query\Expr\Math; +use Doctrine\ORM\Query\Expr\OrderBy; +use Doctrine\ORM\Query\Expr\Orx; +use Doctrine\ORM\Query\Expr\Select; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr; use Doctrine\Tests\Models\Company\CompanyEmployee; @@ -18,11 +29,9 @@ */ class ExprTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerInterface $entityManager; - /** @var Expr */ - private $expr; + private Expr $expr; protected function setUp(): void { @@ -374,7 +383,7 @@ public function testOrderByAsc(): void public function testAddThrowsException(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $orExpr = $this->expr->orX(); $orExpr->add($this->expr->quot(5, 2)); } @@ -394,59 +403,59 @@ public function testBooleanLiteral(): void public function testExpressionGetter(): void { // Andx - $andx = new Expr\Andx(['1 = 1', '2 = 2']); + $andx = new Andx(['1 = 1', '2 = 2']); self::assertEquals(['1 = 1', '2 = 2'], $andx->getParts()); // Comparison - $comparison = new Expr\Comparison('foo', Expr\Comparison::EQ, 'bar'); + $comparison = new Comparison('foo', Comparison::EQ, 'bar'); self::assertEquals('foo', $comparison->getLeftExpr()); self::assertEquals('bar', $comparison->getRightExpr()); - self::assertEquals(Expr\Comparison::EQ, $comparison->getOperator()); + self::assertEquals(Comparison::EQ, $comparison->getOperator()); // From - $from = new Expr\From('Foo', 'f', 'f.id'); + $from = new From('Foo', 'f', 'f.id'); self::assertEquals('f', $from->getAlias()); self::assertEquals('Foo', $from->getFrom()); self::assertEquals('f.id', $from->getIndexBy()); // Func - $func = new Expr\Func('MAX', ['f.id']); + $func = new Func('MAX', ['f.id']); self::assertEquals('MAX', $func->getName()); self::assertEquals(['f.id'], $func->getArguments()); // GroupBy - $group = new Expr\GroupBy(['foo DESC', 'bar ASC']); + $group = new GroupBy(['foo DESC', 'bar ASC']); self::assertEquals(['foo DESC', 'bar ASC'], $group->getParts()); // Join - $join = new Expr\Join(Expr\Join::INNER_JOIN, 'f.bar', 'b', Expr\Join::ON, 'b.bar_id = 1', 'b.bar_id'); - self::assertEquals(Expr\Join::INNER_JOIN, $join->getJoinType()); - self::assertEquals(Expr\Join::ON, $join->getConditionType()); + $join = new Join(Join::INNER_JOIN, 'f.bar', 'b', Join::ON, 'b.bar_id = 1', 'b.bar_id'); + self::assertEquals(Join::INNER_JOIN, $join->getJoinType()); + self::assertEquals(Join::ON, $join->getConditionType()); self::assertEquals('b.bar_id = 1', $join->getCondition()); self::assertEquals('b.bar_id', $join->getIndexBy()); self::assertEquals('f.bar', $join->getJoin()); self::assertEquals('b', $join->getAlias()); // Literal - $literal = new Expr\Literal(['foo']); + $literal = new Literal(['foo']); self::assertEquals(['foo'], $literal->getParts()); // Math - $math = new Expr\Math(10, '+', 20); + $math = new Math(10, '+', 20); self::assertEquals(10, $math->getLeftExpr()); self::assertEquals(20, $math->getRightExpr()); self::assertEquals('+', $math->getOperator()); // OrderBy - $order = new Expr\OrderBy('foo', 'DESC'); + $order = new OrderBy('foo', 'DESC'); self::assertEquals(['foo DESC'], $order->getParts()); // Andx - $orx = new Expr\Orx(['foo = 1', 'bar = 2']); + $orx = new Orx(['foo = 1', 'bar = 2']); self::assertEquals(['foo = 1', 'bar = 2'], $orx->getParts()); // Select - $select = new Expr\Select(['foo', 'bar']); + $select = new Select(['foo', 'bar']); self::assertEquals(['foo', 'bar'], $select->getParts()); } diff --git a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php index 335937972cb..0a5ee1cb9f8 100644 --- a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php @@ -15,8 +15,7 @@ */ class FilterCollectionTest extends OrmTestCase { - /** @var EntityManagerMock */ - private $em; + private EntityManagerMock $em; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index 32b2f6f8531..7f01d3449a8 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\AST\Functions\ConcatFunction; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -20,8 +22,7 @@ class LanguageRecognitionTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerInterface $entityManager; protected function setUp(): void { @@ -71,7 +72,7 @@ public function parseDql(string $dql, array $hints = []): ParserResult $query->setHint($key, $value); } - $parser = new Query\Parser($query); + $parser = new Parser($query); // We do NOT test SQL output here. That only unnecessarily slows down the tests! $parser->setCustomOutputTreeWalker(NullSqlWalker::class); @@ -580,7 +581,7 @@ public function testInputParameterInSelect(): void */ public function testCustomFunctionsReturningStringInStringPrimary(): void { - $this->entityManager->getConfiguration()->addCustomStringFunction('CC', Query\AST\Functions\ConcatFunction::class); + $this->entityManager->getConfiguration()->addCustomStringFunction('CC', ConcatFunction::class); $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'", true); } @@ -726,36 +727,32 @@ public function testStringPrimaryAcceptsAggregateExpression(): void class DQLKeywordsModelUser { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var DQLKeywordsModelGroup * @OneToOne(targetEntity="DQLKeywordsModelGroup") */ - private $group; + private \Doctrine\Tests\ORM\Query\DQLKeywordsModelGroup $group; } /** @Entity */ class DQLKeywordsModelGroup { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var string * @Column */ - private $from; + private string $from; } class DummyStruct diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 9d0f5be158b..966a0793132 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -18,8 +18,7 @@ */ class QueryExpressionVisitorTest extends TestCase { - /** @var QueryExpressionVisitor */ - private $visitor; + private QueryExpressionVisitor $visitor; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 79147093f9c..d1ea3e835c5 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\DBAL\Driver\Result; use DateTime; use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; @@ -587,7 +588,7 @@ public function testGetQueryCacheDriverWithCacheExplicitlySet(): void ->getSQL(); } - private function createConnection(Driver\Result ...$results): Connection + private function createConnection(Result ...$results): Connection { $driverConnection = $this->createMock(Driver\Connection::class); $driverConnection->method('query') diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index ea8cc2d8f8f..345f4999ec0 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -35,8 +35,7 @@ class SelectSqlGenerationTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerInterface $entityManager; protected function setUp(): void { @@ -741,7 +740,7 @@ public function testSupportsMemberOfExpressionSelfReferencing(): void // Tough one: Many-many self-referencing ("friends") with class table inheritance $q = $this->entityManager->createQuery('SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p WHERE :param MEMBER OF p.friends'); $person = new CompanyPerson(); - $this->entityManager->getClassMetadata(get_class($person))->setIdentifierValues($person, ['id' => 101]); + $this->entityManager->getClassMetadata($person::class)->setIdentifierValues($person, ['id' => 101]); $q->setParameter('param', $person); self::assertEquals( 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c1_.car_id AS car_id_8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ WHERE c3_.person_id = c0_.id AND c3_.friend_id IN (?))', @@ -924,7 +923,7 @@ public function testOrderBySupportsSingleValuedPathExpressionOwningSide(): void public function testOrderBySupportsSingleValuedPathExpressionInverseSide(): void { - $this->expectException('\Doctrine\ORM\Query\QueryException'); + $this->expectException(QueryException::class); $q = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u order by u.address'); $q->getSQL(); } @@ -1235,7 +1234,7 @@ public function testIdVariableResultVariableReuse(): void $query->getSql(); $query->free(); - } catch (Exception $e) { + } catch (Exception) { $exceptionThrown = true; } @@ -2364,15 +2363,13 @@ class DDC1474Entity */ protected $id; - /** - * @var float - * @Column(type="float") - */ - private $value; - - public function __construct(string $float) + public function __construct( + /** + * @Column(type="float") + */ + private string $value + ) { - $this->value = $float; } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php index 40fc7aa8dd6..a66f9811e73 100644 --- a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php @@ -16,8 +16,7 @@ */ class SqlWalkerTest extends OrmTestCase { - /** @var SqlWalker */ - private $sqlWalker; + private SqlWalker $sqlWalker; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php index 99e179336b0..470dd727711 100644 --- a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -20,8 +20,7 @@ */ class UpdateSqlGenerationTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $entityManager; + private EntityManagerInterface $entityManager; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 6d45a50ada1..5b583799328 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -629,7 +629,7 @@ public function testGetQuery(): void ->from(CmsUser::class, 'u'); $q = $qb->getQuery(); - self::assertEquals(Query::class, get_class($q)); + self::assertEquals(Query::class, $q::class); } public function testSetParameter(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php index 6761f1a219e..9bb041713dd 100644 --- a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Tools; +use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadataFactory; @@ -19,14 +20,11 @@ class AttachEntityListenersListenerTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $em; + private EntityManagerInterface $em; - /** @var AttachEntityListenersListener */ - private $listener; + private AttachEntityListenersListener $listener; - /** @var ClassMetadataFactory */ - private $factory; + private ClassMetadataFactory $factory; protected function setUp(): void { @@ -96,7 +94,7 @@ public function testAttachToExistingEntityListeners(): void public function testDuplicateEntityListenerException(): void { - $this->expectException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(MappingException::class); $this->expectExceptionMessage('Entity Listener "Doctrine\Tests\ORM\Tools\AttachEntityListenersListenerTestListener#postPersist()" in "Doctrine\Tests\ORM\Tools\AttachEntityListenersListenerTestFooEntity" was already declared, but it must be declared only once.'); $this->listener->addEntityListener( AttachEntityListenersListenerTestFooEntity::class, diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php index edd8a4cdb84..887b1fbad62 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php @@ -16,11 +16,9 @@ */ class ClearCacheCollectionRegionCommandTest extends OrmFunctionalTestCase { - /** @var Application */ - private $application; + private Application $application; - /** @var CollectionRegionCommand */ - private $command; + private CollectionRegionCommand $command; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php index e5c3a8d278e..91ef097ebba 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php @@ -16,11 +16,9 @@ */ class ClearCacheEntityRegionCommandTest extends OrmFunctionalTestCase { - /** @var Application */ - private $application; + private Application $application; - /** @var EntityRegionCommand */ - private $command; + private EntityRegionCommand $command; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php index bf860d9549c..c00b4eaa4f2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php @@ -15,11 +15,9 @@ */ class ClearCacheQueryRegionCommandTest extends OrmFunctionalTestCase { - /** @var Application */ - private $application; + private Application $application; - /** @var QueryRegionCommand */ - private $command; + private QueryRegionCommand $command; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php index ec9feda2cc5..b55f5099d97 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php @@ -19,14 +19,11 @@ */ class MappingDescribeCommandTest extends OrmFunctionalTestCase { - /** @var Application */ - private $application; + private Application $application; - /** @var InfoCommand */ - private $command; + private InfoCommand $command; - /** @var CommandTester */ - private $tester; + private CommandTester $tester; protected function setUp(): void { @@ -56,7 +53,7 @@ public function testShowSpecificFuzzySingle(): void public function testShowSpecificFuzzyAmbiguous(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('possible matches'); $this->tester->execute( [ @@ -68,7 +65,7 @@ public function testShowSpecificFuzzyAmbiguous(): void public function testShowSpecificNotFound(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Could not find any mapped Entity classes matching "AttractionFooBar"'); $this->tester->execute( [ diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php index 045a0a5a362..4098cfa92a4 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php @@ -20,14 +20,11 @@ */ class RunDqlCommandTest extends OrmFunctionalTestCase { - /** @var Application */ - private $application; + private Application $application; - /** @var RunDqlCommand */ - private $command; + private RunDqlCommand $command; - /** @var CommandTester */ - private $tester; + private CommandTester $tester; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php index 82f1aa4b455..c482a3f4bfe 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php @@ -20,11 +20,9 @@ */ class ValidateSchemaCommandTest extends OrmFunctionalTestCase { - /** @var InfoCommand */ - private $command; + private InfoCommand $command; - /** @var CommandTester */ - private $tester; + private CommandTester $tester; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php index b04215ae4e5..9c403e8bca5 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php @@ -20,8 +20,7 @@ */ class MetadataFilterTest extends OrmTestCase { - /** @var ClassMetadataFactory */ - private $cmf; + private ClassMetadataFactory $cmf; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php index 0aa4b522ba6..f2b6ed84004 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php @@ -276,12 +276,11 @@ class Avatar abstract class Identified { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index 435d5119058..240d4b0d794 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Tools\Pagination; +use Doctrine\ORM\Query\QueryException; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -98,7 +99,7 @@ public function testPaginatorNotCaringAboutExtraParametersWithoutOutputWalkers() public function testgetIteratorDoesCareAboutExtraParametersWithoutOutputWalkersWhenResultIsNotEmpty(): void { $this->connection->expects(self::exactly(1))->method('executeQuery'); - $this->expectException(Query\QueryException::class); + $this->expectException(QueryException::class); $this->expectExceptionMessage('Too many parameters: the query defines 1 parameters and you bound 2'); $this->createPaginatorWithExtraParametersWithoutOutputWalkers([[10]])->getIterator(); diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index 64f0438ecf3..f4ff03ea70c 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -22,14 +22,11 @@ class ResolveTargetEntityListenerTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $em; + private EntityManagerInterface $em; - /** @var ResolveTargetEntityListener */ - private $listener; + private ResolveTargetEntityListener $listener; - /** @var ClassMetadataFactory */ - private $factory; + private ClassMetadataFactory $factory; protected function setUp(): void { @@ -132,12 +129,11 @@ interface Target extends ResolveTarget class ResolveTargetEntity implements ResolveTarget { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; /** * @psalm-var Collection @@ -146,10 +142,9 @@ class ResolveTargetEntity implements ResolveTarget private $manyToMany; /** - * @var ResolveTarget * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTarget", inversedBy="oneToMany") */ - private $manyToOne; + private \Doctrine\Tests\ORM\Tools\ResolveTarget $manyToOne; /** * @psalm-var Collection @@ -158,11 +153,10 @@ class ResolveTargetEntity implements ResolveTarget private $oneToMany; /** - * @var Target * @OneToOne(targetEntity="Doctrine\Tests\ORM\Tools\Target") * @JoinColumn(name="target_entity_id", referencedColumnName="id") */ - private $oneToOne; + private \Doctrine\Tests\ORM\Tools\Target $oneToOne; public function getId(): int { @@ -176,12 +170,11 @@ public function getId(): int class TargetEntity implements Target { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ - private $id; + private int $id; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index 9c1763748d0..a3c829f6581 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -393,17 +393,15 @@ public function testConfigurationSchemaIgnoredEntity(): void class TestEntityWithAnnotationOptionsAttribute { /** - * @var int * @Id * @Column */ - private $id; + private int $id; /** - * @var string * @Column(type="string", options={"foo": "bar", "baz": {"key": "val"}}) */ - private $test; + private string $test; } class GenerateSchemaEventListener @@ -434,17 +432,15 @@ public function postGenerateSchema(GenerateSchemaEventArgs $eventArgs): void class UniqueConstraintAnnotationModel { /** - * @var int * @Id * @Column */ - private $id; + private int $id; /** - * @var string * @Column(name="hash", type="string", length=8, nullable=false, unique=true) */ - private $hash; + private string $hash; } /** diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 653cd4f3575..b6e51fb066a 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -29,11 +29,9 @@ class SchemaValidatorTest extends OrmTestCase { - /** @var EntityManagerInterface */ - private $em = null; + private ?EntityManagerInterface $em = null; - /** @var SchemaValidator */ - private $validator = null; + private ?SchemaValidator $validator = null; protected function setUp(): void { @@ -339,18 +337,16 @@ class InvalidEntity2 class DDC1587ValidEntity1 { /** - * @var int * @Id * @GeneratedValue * @Column(name="pk", type="integer") */ - private $pk; + private int $pk; /** - * @var string * @Column(name="name", type="string", length=32) */ - private $name; + private string $name; /** * @var Identifier @@ -367,18 +363,16 @@ class DDC1587ValidEntity1 class DDC1587ValidEntity2 { /** - * @var DDC1587ValidEntity1 * @Id * @OneToOne(targetEntity="DDC1587ValidEntity1", inversedBy="identifier") * @JoinColumn(name="pk_agent", referencedColumnName="pk", nullable=false) */ - private $agent; + private \Doctrine\Tests\ORM\Tools\DDC1587ValidEntity1 $agent; /** - * @var string * @Column(name="num", type="string", length=16, nullable=true) */ - private $num; + private string $num; } /** @@ -413,12 +407,11 @@ class DDC1649Two class DDC1649Three { /** - * @var DDC1649Two * @Id * @ManyToOne(targetEntity="DDC1649Two") * @JoinColumn(name="id", referencedColumnName="id") */ - private $two; + private \Doctrine\Tests\ORM\Tools\DDC1649Two $two; } /** @@ -435,10 +428,9 @@ class DDC3274One private $id; /** - * @var ArrayCollection * @OneToMany(targetEntity="DDC3274Two", mappedBy="one") */ - private $two; + private ArrayCollection $two; } /** @@ -447,11 +439,10 @@ class DDC3274One class DDC3274Two { /** - * @var DDC3274One * @Id * @ManyToOne(targetEntity="DDC3274One") */ - private $one; + private \Doctrine\Tests\ORM\Tools\DDC3274One $one; } /** @@ -468,10 +459,9 @@ class Issue9536Target private $id; /** - * @var Issue9536Owner * @OneToOne(targetEntity="Issue9536Owner") */ - private $two; + private \Doctrine\Tests\ORM\Tools\Issue9536Owner $two; } /** @@ -488,10 +478,9 @@ class Issue9536Owner private $id; /** - * @var Issue9536Target * @OneToOne(targetEntity="Issue9536Target", inversedBy="two") */ - private $one; + private \Doctrine\Tests\ORM\Tools\Issue9536Target $one; } /** @@ -508,64 +497,54 @@ class DDC3322ValidEntity1 private $id; /** - * @var DDC3322One * @ManyToOne(targetEntity="DDC3322One", inversedBy="validAssoc") */ - private $oneValid; + private \Doctrine\Tests\ORM\Tools\DDC3322One $oneValid; /** - * @var DDC3322One * @ManyToOne(targetEntity="DDC3322One", inversedBy="invalidAssoc") */ - private $oneInvalid; + private \Doctrine\Tests\ORM\Tools\DDC3322One $oneInvalid; /** - * @var DDC3322Two * @ManyToOne(targetEntity="DDC3322Two", inversedBy="validAssoc") */ - private $twoValid; + private \Doctrine\Tests\ORM\Tools\DDC3322Two $twoValid; /** - * @var DDC3322Two * @ManyToOne(targetEntity="DDC3322Two", inversedBy="invalidAssoc") */ - private $twoInvalid; + private \Doctrine\Tests\ORM\Tools\DDC3322Two $twoInvalid; /** - * @var DDC3322Three * @ManyToOne(targetEntity="DDC3322Three", inversedBy="validAssoc") */ - private $threeValid; + private \Doctrine\Tests\ORM\Tools\DDC3322Three $threeValid; /** - * @var DDC3322Three * @ManyToOne(targetEntity="DDC3322Three", inversedBy="invalidAssoc") */ - private $threeInvalid; + private \Doctrine\Tests\ORM\Tools\DDC3322Three $threeInvalid; /** - * @var DDC3322ValidEntity2 * @OneToMany(targetEntity="DDC3322ValidEntity2", mappedBy="manyToOne") */ - private $oneToMany; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity2 $oneToMany; /** - * @var DDC3322ValidEntity2 * @ManyToOne(targetEntity="DDC3322ValidEntity2", inversedBy="oneToMany") */ - private $manyToOne; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity2 $manyToOne; /** - * @var DDC3322ValidEntity2 * @OneToOne(targetEntity="DDC3322ValidEntity2", mappedBy="oneToOneOwning") */ - private $oneToOneInverse; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity2 $oneToOneInverse; /** - * @var DDC3322ValidEntity2 * @OneToOne(targetEntity="DDC3322ValidEntity2", inversedBy="oneToOneInverse") */ - private $oneToOneOwning; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity2 $oneToOneOwning; } /** @@ -574,36 +553,31 @@ class DDC3322ValidEntity1 class DDC3322ValidEntity2 { /** - * @var int * @Id * @Column * @GeneratedValue */ - private $id; + private int $id; /** - * @var DDC3322ValidEntity1 * @ManyToOne(targetEntity="DDC3322ValidEntity1", inversedBy="oneToMany") */ - private $manyToOne; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $manyToOne; /** - * @var DDC3322ValidEntity1 * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="manyToOne") */ - private $oneToMany; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $oneToMany; /** - * @var DDC3322ValidEntity1 * @OneToOne(targetEntity="DDC3322ValidEntity1", inversedBy="oneToOneInverse") */ - private $oneToOneOwning; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $oneToOneOwning; /** - * @var DDC3322ValidEntity1 * @OneToOne(targetEntity="DDC3322ValidEntity1", mappedBy="oneToOneOwning") */ - private $oneToOneInverse; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $oneToOneInverse; } /** @@ -612,12 +586,11 @@ class DDC3322ValidEntity2 class DDC3322One { /** - * @var int * @Id * @Column * @GeneratedValue */ - private $id; + private int $id; /** * @psalm-var Collection @@ -640,12 +613,11 @@ class DDC3322One class DDC3322Two { /** - * @var int * @Id * @Column * @GeneratedValue */ - private $id; + private int $id; /** * @psalm-var Collection @@ -668,19 +640,17 @@ class DDC3322Two class DDC3322Three { /** - * @var int * @Id * @Column * @GeneratedValue */ - private $id; + private int $id; /** - * @var DDC3322ValidEntity1 * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="threeValid") * @OrderBy({"oneToOneOwning" = "ASC"}) */ - private $validAssoc; + private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $validAssoc; /** * @psalm-var Collection @@ -696,8 +666,7 @@ class DDC3322Three class EmbeddableWithAssociation { /** - * @var ECommerceCart * @OneToOne(targetEntity="Doctrine\Tests\Models\ECommerce\ECommerceCart") */ - private $cart; + private ECommerceCart $cart; } diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 3577e5763e9..8538a972711 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM; +use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Exception; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\EventManager; @@ -47,10 +49,8 @@ class UnitOfWorkTest extends OrmTestCase { /** * SUT - * - * @var UnitOfWorkMock */ - private $_unitOfWork; + private UnitOfWorkMock $_unitOfWork; /** * Provides a sequence mock to the UnitOfWork @@ -61,10 +61,8 @@ class UnitOfWorkTest extends OrmTestCase /** * The EntityManager mock that provides the mock persisters - * - * @var EntityManagerMock */ - private $_emMock; + private EntityManagerMock $_emMock; /** @var EventManager&MockObject */ private $eventManager; @@ -77,7 +75,7 @@ protected function setUp(): void $platform->method('supportsIdentityColumns') ->willReturn(true); - $driverStatement = $this->createMock(Driver\Statement::class); + $driverStatement = $this->createMock(Statement::class); if (method_exists($driverStatement, 'rowCount')) { $driverStatement->method('rowCount') @@ -381,7 +379,7 @@ public function testAddToIdentityMapValidIdentifiers(object $entity, string $idH $this->_unitOfWork->persist($entity); $this->_unitOfWork->addToIdentityMap($entity); - self::assertSame($entity, $this->_unitOfWork->getByIdHash($idHash, get_class($entity))); + self::assertSame($entity, $this->_unitOfWork->getByIdHash($idHash, $entity::class)); } /** @@ -579,7 +577,7 @@ public function testPreviousDetectedIllegalNewNonCascadedEntitiesAreCleanedUpOnS $this->_unitOfWork->commit(); self::fail('An exception was supposed to be raised'); - } catch (ORMInvalidArgumentException $ignored) { + } catch (ORMInvalidArgumentException) { self::assertEmpty($persister1->getInserts()); self::assertEmpty($persister2->getInserts()); } @@ -620,7 +618,7 @@ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails( $this->_emMock->setUnitOfWork($this->_unitOfWork); $this->connection->method('commit') - ->willThrowException(new DBAL\Exception()); + ->willThrowException(new Exception()); // Setup fake persister and id generator $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(ForumUser::class)); @@ -649,15 +647,14 @@ public function testItThrowsWhenLookingUpIdentifierForUnknownEntity(): void class NotifyChangedEntity implements NotifyPropertyChanged { /** @psalm-var list */ - private $_listeners = []; + private array $_listeners = []; /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** * @var string @@ -665,8 +662,7 @@ class NotifyChangedEntity implements NotifyPropertyChanged */ private $data; - /** @var mixed */ - private $transient; // not persisted + private mixed $transient = null; // not persisted /** * @psalm-var Collection @@ -729,18 +725,16 @@ protected function onPropertyChanged(mixed $propName, mixed $oldValue, mixed $ne class NotifyChangedRelatedItem { /** - * @var int * @Id * @Column(type="integer") * @GeneratedValue */ - private $id; + private int $id; /** - * @var NotifyChangedEntity|null * @ManyToOne(targetEntity="NotifyChangedEntity", inversedBy="items") */ - private $owner; + private ?\Doctrine\Tests\ORM\NotifyChangedEntity $owner = null; public function getId(): int { @@ -843,12 +837,11 @@ public function __construct() class CascadePersistedEntity { /** - * @var string * @Id * @Column(type="string", length=255) * @GeneratedValue(strategy="NONE") */ - private $id; + private string $id; public function __construct() { @@ -860,12 +853,11 @@ public function __construct() class EntityWithCascadingAssociation { /** - * @var string * @Id * @Column(type="string", length=255) * @GeneratedValue(strategy="NONE") */ - private $id; + private string $id; /** * @var CascadePersistedEntity|null @@ -883,12 +875,11 @@ public function __construct() class EntityWithNonCascadingAssociation { /** - * @var string * @Id * @Column(type="string", length=255) * @GeneratedValue(strategy="NONE") */ - private $id; + private string $id; /** * @var CascadePersistedEntity|null diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php index 2099fd157b8..0ee426124f4 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php @@ -30,7 +30,7 @@ protected function setUp(): void $this->_em->getClassMetadata(TypedCardEnumCompositeId::class), ] ); - } catch (ORMException $e) { + } catch (ORMException) { } } diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php index 716b20f738a..f1452be2ec5 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php @@ -21,10 +21,8 @@ class IdentifierFlattenerTest extends OrmFunctionalTestCase { /** * Identifier flattener - * - * @var IdentifierFlattener */ - private $identifierFlattener; + private IdentifierFlattener $identifierFlattener; protected function setUp(): void { @@ -44,7 +42,7 @@ protected function setUp(): void $this->_em->getClassMetadata(City::class), ] ); - } catch (ORMException $e) { + } catch (ORMException) { } } @@ -78,7 +76,7 @@ public function testFlattenIdentifierWithOneToOneId(): void self::assertArrayHasKey('secondEntity', $id, 'It should be called secondEntity'); self::assertInstanceOf( - '\Doctrine\Tests\Models\VersionedOneToOne\SecondRelatedEntity', + SecondRelatedEntity::class, $id['secondEntity'], 'The entity should be an instance of SecondRelatedEntity' ); diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index a5a1a0b62e1..2b13248eb53 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -4,6 +4,145 @@ namespace Doctrine\Tests; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsEmail; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsTag; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsComment; +use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyManager; +use Doctrine\Tests\Models\Company\CompanyOrganization; +use Doctrine\Tests\Models\Company\CompanyEvent; +use Doctrine\Tests\Models\Company\CompanyAuction; +use Doctrine\Tests\Models\Company\CompanyRaffle; +use Doctrine\Tests\Models\Company\CompanyCar; +use Doctrine\Tests\Models\Company\CompanyContract; +use Doctrine\Tests\Models\ECommerce\ECommerceCart; +use Doctrine\Tests\Models\ECommerce\ECommerceCustomer; +use Doctrine\Tests\Models\ECommerce\ECommerceProduct; +use Doctrine\Tests\Models\ECommerce\ECommerceShipping; +use Doctrine\Tests\Models\ECommerce\ECommerceFeature; +use Doctrine\Tests\Models\ECommerce\ECommerceCategory; +use Doctrine\Tests\Models\Generic\BooleanModel; +use Doctrine\Tests\Models\Generic\DateTimeModel; +use Doctrine\Tests\Models\Generic\DecimalModel; +use Doctrine\Tests\Models\Generic\SerializationModel; +use Doctrine\Tests\Models\Routing\RoutingLeg; +use Doctrine\Tests\Models\Routing\RoutingLocation; +use Doctrine\Tests\Models\Routing\RoutingRoute; +use Doctrine\Tests\Models\Routing\RoutingRouteBooking; +use Doctrine\Tests\Models\Navigation\NavUser; +use Doctrine\Tests\Models\Navigation\NavCountry; +use Doctrine\Tests\Models\Navigation\NavPhotos; +use Doctrine\Tests\Models\Navigation\NavTour; +use Doctrine\Tests\Models\Navigation\NavPointOfInterest; +use Doctrine\Tests\Models\DirectoryTree\AbstractContentItem; +use Doctrine\Tests\Models\DirectoryTree\File; +use Doctrine\Tests\Models\DirectoryTree\Directory; +use Doctrine\Tests\Models\DDC117\DDC117Article; +use Doctrine\Tests\Models\DDC117\DDC117Reference; +use Doctrine\Tests\Models\DDC117\DDC117Translation; +use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails; +use Doctrine\Tests\Models\DDC117\DDC117ApproveChanges; +use Doctrine\Tests\Models\DDC117\DDC117Editor; +use Doctrine\Tests\Models\DDC117\DDC117Link; +use Doctrine\Tests\Models\DDC3699\DDC3699Parent; +use Doctrine\Tests\Models\DDC3699\DDC3699RelationOne; +use Doctrine\Tests\Models\DDC3699\DDC3699RelationMany; +use Doctrine\Tests\Models\DDC3699\DDC3699Child; +use Doctrine\Tests\Models\StockExchange\Bond; +use Doctrine\Tests\Models\StockExchange\Stock; +use Doctrine\Tests\Models\StockExchange\Market; +use Doctrine\Tests\Models\Legacy\LegacyUser; +use Doctrine\Tests\Models\Legacy\LegacyUserReference; +use Doctrine\Tests\Models\Legacy\LegacyArticle; +use Doctrine\Tests\Models\Legacy\LegacyCar; +use Doctrine\Tests\Models\CustomType\CustomTypeChild; +use Doctrine\Tests\Models\CustomType\CustomTypeParent; +use Doctrine\Tests\Models\CustomType\CustomTypeUpperCase; +use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass; +use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedChildClass; +use Doctrine\Tests\Models\CompositeKeyInheritance\SingleRootClass; +use Doctrine\Tests\Models\CompositeKeyInheritance\SingleChildClass; +use Doctrine\Tests\Models\Taxi\PaidRide; +use Doctrine\Tests\Models\Taxi\Ride; +use Doctrine\Tests\Models\Taxi\Car; +use Doctrine\Tests\Models\Taxi\Driver; +use Doctrine\Tests\Models\Cache\Country; +use Doctrine\Tests\Models\Cache\State; +use Doctrine\Tests\Models\Cache\City; +use Doctrine\Tests\Models\Cache\Traveler; +use Doctrine\Tests\Models\Cache\TravelerProfileInfo; +use Doctrine\Tests\Models\Cache\TravelerProfile; +use Doctrine\Tests\Models\Cache\Travel; +use Doctrine\Tests\Models\Cache\Attraction; +use Doctrine\Tests\Models\Cache\Restaurant; +use Doctrine\Tests\Models\Cache\Beach; +use Doctrine\Tests\Models\Cache\Bar; +use Doctrine\Tests\Models\Cache\Flight; +use Doctrine\Tests\Models\Cache\Token; +use Doctrine\Tests\Models\Cache\Login; +use Doctrine\Tests\Models\Cache\Client; +use Doctrine\Tests\Models\Cache\Person; +use Doctrine\Tests\Models\Cache\Address; +use Doctrine\Tests\Models\Cache\Action; +use Doctrine\Tests\Models\Cache\ComplexAction; +use Doctrine\Tests\Models\Cache\AttractionInfo; +use Doctrine\Tests\Models\Cache\AttractionContactInfo; +use Doctrine\Tests\Models\Cache\AttractionLocationInfo; +use Doctrine\Tests\Models\Tweet\User; +use Doctrine\Tests\Models\Tweet\Tweet; +use Doctrine\Tests\Models\Tweet\UserList; +use Doctrine\Tests\Models\DDC2504\DDC2504RootClass; +use Doctrine\Tests\Models\DDC2504\DDC2504ChildClass; +use Doctrine\Tests\Models\DDC2504\DDC2504OtherClass; +use Doctrine\Tests\Models\DDC3346\DDC3346Author; +use Doctrine\Tests\Models\DDC3346\DDC3346Article; +use Doctrine\Tests\Models\Quote\FullAddress; +use Doctrine\Tests\Models\Quote\Group; +use Doctrine\Tests\Models\Quote\NumericEntity; +use Doctrine\Tests\Models\Quote\Phone; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyExtraLazyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyExtraLazyEntity; +use Doctrine\Tests\Models\GeoNames\Admin1; +use Doctrine\Tests\Models\GeoNames\Admin1AlternateName; +use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent; +use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild; +use Doctrine\Tests\Models\Pagination\Company; +use Doctrine\Tests\Models\Pagination\Logo; +use Doctrine\Tests\Models\Pagination\Department; +use Doctrine\Tests\Models\Pagination\User1; +use Doctrine\Tests\Models\VersionedManyToOne\Category; +use Doctrine\Tests\Models\VersionedManyToOne\Article; +use Doctrine\Tests\Models\Issue5989\Issue5989Person; +use Doctrine\Tests\Models\Issue5989\Issue5989Employee; +use Doctrine\Tests\Models\Issue5989\Issue5989Manager; +use Doctrine\Tests\DbalExtensions\Connection; use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; @@ -121,220 +260,220 @@ abstract class OrmFunctionalTestCase extends OrmTestCase */ protected static $modelSets = [ 'cms' => [ - Models\CMS\CmsUser::class, - Models\CMS\CmsPhonenumber::class, - Models\CMS\CmsAddress::class, - Models\CMS\CmsEmail::class, - Models\CMS\CmsGroup::class, - Models\CMS\CmsTag::class, - Models\CMS\CmsArticle::class, - Models\CMS\CmsComment::class, + CmsUser::class, + CmsPhonenumber::class, + CmsAddress::class, + CmsEmail::class, + CmsGroup::class, + CmsTag::class, + CmsArticle::class, + CmsComment::class, ], 'company' => [ - Models\Company\CompanyPerson::class, - Models\Company\CompanyEmployee::class, - Models\Company\CompanyManager::class, - Models\Company\CompanyOrganization::class, - Models\Company\CompanyEvent::class, - Models\Company\CompanyAuction::class, - Models\Company\CompanyRaffle::class, - Models\Company\CompanyCar::class, - Models\Company\CompanyContract::class, + CompanyPerson::class, + CompanyEmployee::class, + CompanyManager::class, + CompanyOrganization::class, + CompanyEvent::class, + CompanyAuction::class, + CompanyRaffle::class, + CompanyCar::class, + CompanyContract::class, ], 'ecommerce' => [ - Models\ECommerce\ECommerceCart::class, - Models\ECommerce\ECommerceCustomer::class, - Models\ECommerce\ECommerceProduct::class, - Models\ECommerce\ECommerceShipping::class, - Models\ECommerce\ECommerceFeature::class, - Models\ECommerce\ECommerceCategory::class, + ECommerceCart::class, + ECommerceCustomer::class, + ECommerceProduct::class, + ECommerceShipping::class, + ECommerceFeature::class, + ECommerceCategory::class, ], 'generic' => [ - Models\Generic\BooleanModel::class, - Models\Generic\DateTimeModel::class, - Models\Generic\DecimalModel::class, - Models\Generic\SerializationModel::class, + BooleanModel::class, + DateTimeModel::class, + DecimalModel::class, + SerializationModel::class, ], 'routing' => [ - Models\Routing\RoutingLeg::class, - Models\Routing\RoutingLocation::class, - Models\Routing\RoutingRoute::class, - Models\Routing\RoutingRouteBooking::class, + RoutingLeg::class, + RoutingLocation::class, + RoutingRoute::class, + RoutingRouteBooking::class, ], 'navigation' => [ - Models\Navigation\NavUser::class, - Models\Navigation\NavCountry::class, - Models\Navigation\NavPhotos::class, - Models\Navigation\NavTour::class, - Models\Navigation\NavPointOfInterest::class, + NavUser::class, + NavCountry::class, + NavPhotos::class, + NavTour::class, + NavPointOfInterest::class, ], 'directorytree' => [ - Models\DirectoryTree\AbstractContentItem::class, - Models\DirectoryTree\File::class, - Models\DirectoryTree\Directory::class, + AbstractContentItem::class, + File::class, + Directory::class, ], 'ddc117' => [ - Models\DDC117\DDC117Article::class, - Models\DDC117\DDC117Reference::class, - Models\DDC117\DDC117Translation::class, - Models\DDC117\DDC117ArticleDetails::class, - Models\DDC117\DDC117ApproveChanges::class, - Models\DDC117\DDC117Editor::class, - Models\DDC117\DDC117Link::class, + DDC117Article::class, + DDC117Reference::class, + DDC117Translation::class, + DDC117ArticleDetails::class, + DDC117ApproveChanges::class, + DDC117Editor::class, + DDC117Link::class, ], 'ddc3699' => [ - Models\DDC3699\DDC3699Parent::class, - Models\DDC3699\DDC3699RelationOne::class, - Models\DDC3699\DDC3699RelationMany::class, - Models\DDC3699\DDC3699Child::class, + DDC3699Parent::class, + DDC3699RelationOne::class, + DDC3699RelationMany::class, + DDC3699Child::class, ], 'stockexchange' => [ - Models\StockExchange\Bond::class, - Models\StockExchange\Stock::class, - Models\StockExchange\Market::class, + Bond::class, + Stock::class, + Market::class, ], 'legacy' => [ - Models\Legacy\LegacyUser::class, - Models\Legacy\LegacyUserReference::class, - Models\Legacy\LegacyArticle::class, - Models\Legacy\LegacyCar::class, + LegacyUser::class, + LegacyUserReference::class, + LegacyArticle::class, + LegacyCar::class, ], 'customtype' => [ - Models\CustomType\CustomTypeChild::class, - Models\CustomType\CustomTypeParent::class, - Models\CustomType\CustomTypeUpperCase::class, + CustomTypeChild::class, + CustomTypeParent::class, + CustomTypeUpperCase::class, ], 'compositekeyinheritance' => [ - Models\CompositeKeyInheritance\JoinedRootClass::class, - Models\CompositeKeyInheritance\JoinedChildClass::class, - Models\CompositeKeyInheritance\SingleRootClass::class, - Models\CompositeKeyInheritance\SingleChildClass::class, + JoinedRootClass::class, + JoinedChildClass::class, + SingleRootClass::class, + SingleChildClass::class, ], 'taxi' => [ - Models\Taxi\PaidRide::class, - Models\Taxi\Ride::class, - Models\Taxi\Car::class, - Models\Taxi\Driver::class, + PaidRide::class, + Ride::class, + Car::class, + Driver::class, ], 'cache' => [ - Models\Cache\Country::class, - Models\Cache\State::class, - Models\Cache\City::class, - Models\Cache\Traveler::class, - Models\Cache\TravelerProfileInfo::class, - Models\Cache\TravelerProfile::class, - Models\Cache\Travel::class, - Models\Cache\Attraction::class, - Models\Cache\Restaurant::class, - Models\Cache\Beach::class, - Models\Cache\Bar::class, - Models\Cache\Flight::class, - Models\Cache\Token::class, - Models\Cache\Login::class, - Models\Cache\Client::class, - Models\Cache\Person::class, - Models\Cache\Address::class, - Models\Cache\Action::class, - Models\Cache\ComplexAction::class, - Models\Cache\AttractionInfo::class, - Models\Cache\AttractionContactInfo::class, - Models\Cache\AttractionLocationInfo::class, + Country::class, + State::class, + City::class, + Traveler::class, + TravelerProfileInfo::class, + TravelerProfile::class, + Travel::class, + Attraction::class, + Restaurant::class, + Beach::class, + Bar::class, + Flight::class, + Token::class, + Login::class, + Client::class, + Person::class, + Address::class, + Action::class, + ComplexAction::class, + AttractionInfo::class, + AttractionContactInfo::class, + AttractionLocationInfo::class, ], 'tweet' => [ - Models\Tweet\User::class, - Models\Tweet\Tweet::class, - Models\Tweet\UserList::class, + User::class, + Tweet::class, + UserList::class, ], 'ddc2504' => [ - Models\DDC2504\DDC2504RootClass::class, - Models\DDC2504\DDC2504ChildClass::class, - Models\DDC2504\DDC2504OtherClass::class, + DDC2504RootClass::class, + DDC2504ChildClass::class, + DDC2504OtherClass::class, ], 'ddc3346' => [ - Models\DDC3346\DDC3346Author::class, - Models\DDC3346\DDC3346Article::class, + DDC3346Author::class, + DDC3346Article::class, ], 'quote' => [ Models\Quote\Address::class, Models\Quote\City::class, - Models\Quote\FullAddress::class, - Models\Quote\Group::class, - Models\Quote\NumericEntity::class, - Models\Quote\Phone::class, + FullAddress::class, + Group::class, + NumericEntity::class, + Phone::class, Models\Quote\User::class, ], 'vct_onetoone' => [ - Models\ValueConversionType\InversedOneToOneEntity::class, - Models\ValueConversionType\OwningOneToOneEntity::class, + InversedOneToOneEntity::class, + OwningOneToOneEntity::class, ], 'vct_onetoone_compositeid' => [ - Models\ValueConversionType\InversedOneToOneCompositeIdEntity::class, - Models\ValueConversionType\OwningOneToOneCompositeIdEntity::class, + InversedOneToOneCompositeIdEntity::class, + OwningOneToOneCompositeIdEntity::class, ], 'vct_onetoone_compositeid_foreignkey' => [ - Models\ValueConversionType\AuxiliaryEntity::class, - Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity::class, - Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity::class, + AuxiliaryEntity::class, + InversedOneToOneCompositeIdForeignKeyEntity::class, + OwningOneToOneCompositeIdForeignKeyEntity::class, ], 'vct_onetomany' => [ - Models\ValueConversionType\InversedOneToManyEntity::class, - Models\ValueConversionType\OwningManyToOneEntity::class, + InversedOneToManyEntity::class, + OwningManyToOneEntity::class, ], 'vct_onetomany_compositeid' => [ - Models\ValueConversionType\InversedOneToManyCompositeIdEntity::class, - Models\ValueConversionType\OwningManyToOneCompositeIdEntity::class, + InversedOneToManyCompositeIdEntity::class, + OwningManyToOneCompositeIdEntity::class, ], 'vct_onetomany_compositeid_foreignkey' => [ - Models\ValueConversionType\AuxiliaryEntity::class, - Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity::class, - Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity::class, + AuxiliaryEntity::class, + InversedOneToManyCompositeIdForeignKeyEntity::class, + OwningManyToOneCompositeIdForeignKeyEntity::class, ], 'vct_onetomany_extralazy' => [ - Models\ValueConversionType\InversedOneToManyExtraLazyEntity::class, - Models\ValueConversionType\OwningManyToOneExtraLazyEntity::class, + InversedOneToManyExtraLazyEntity::class, + OwningManyToOneExtraLazyEntity::class, ], 'vct_manytomany' => [ - Models\ValueConversionType\InversedManyToManyEntity::class, - Models\ValueConversionType\OwningManyToManyEntity::class, + InversedManyToManyEntity::class, + OwningManyToManyEntity::class, ], 'vct_manytomany_compositeid' => [ - Models\ValueConversionType\InversedManyToManyCompositeIdEntity::class, - Models\ValueConversionType\OwningManyToManyCompositeIdEntity::class, + InversedManyToManyCompositeIdEntity::class, + OwningManyToManyCompositeIdEntity::class, ], 'vct_manytomany_compositeid_foreignkey' => [ - Models\ValueConversionType\AuxiliaryEntity::class, - Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity::class, - Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity::class, + AuxiliaryEntity::class, + InversedManyToManyCompositeIdForeignKeyEntity::class, + OwningManyToManyCompositeIdForeignKeyEntity::class, ], 'vct_manytomany_extralazy' => [ - Models\ValueConversionType\InversedManyToManyExtraLazyEntity::class, - Models\ValueConversionType\OwningManyToManyExtraLazyEntity::class, + InversedManyToManyExtraLazyEntity::class, + OwningManyToManyExtraLazyEntity::class, ], 'geonames' => [ Models\GeoNames\Country::class, - Models\GeoNames\Admin1::class, - Models\GeoNames\Admin1AlternateName::class, + Admin1::class, + Admin1AlternateName::class, Models\GeoNames\City::class, ], 'custom_id_object_type' => [ - Models\CustomType\CustomIdObjectTypeParent::class, - Models\CustomType\CustomIdObjectTypeChild::class, + CustomIdObjectTypeParent::class, + CustomIdObjectTypeChild::class, ], 'pagination' => [ - Models\Pagination\Company::class, - Models\Pagination\Logo::class, - Models\Pagination\Department::class, + Company::class, + Logo::class, + Department::class, Models\Pagination\User::class, - Models\Pagination\User1::class, + User1::class, ], 'versioned_many_to_one' => [ - Models\VersionedManyToOne\Category::class, - Models\VersionedManyToOne\Article::class, + Category::class, + Article::class, ], 'issue5989' => [ - Models\Issue5989\Issue5989Person::class, - Models\Issue5989\Issue5989Employee::class, - Models\Issue5989\Issue5989Manager::class, + Issue5989Person::class, + Issue5989Employee::class, + Issue5989Manager::class, ], ]; @@ -345,12 +484,10 @@ final protected function createSchemaForModels(string ...$models): void { try { $this->_schemaTool->createSchema(array_map( - function (string $className): ClassMetadata { - return $this->_em->getClassMetadata($className); - }, + fn(string $className): ClassMetadata => $this->_em->getClassMetadata($className), $models )); - } catch (ToolsException $e) { + } catch (ToolsException) { } } @@ -722,7 +859,7 @@ protected function setUp(): void * @throws ORMException */ protected function getEntityManager( - ?DbalExtensions\Connection $connection = null, + ?Connection $connection = null, ?MappingDriver $mappingDriver = null ): EntityManagerInterface { // NOTE: Functional tests use their own shared metadata cache, because @@ -826,9 +963,7 @@ protected function onNotSuccessfulTest(Throwable $e): void $queries = ''; $last25queries = array_slice(array_reverse($this->getQueryLog()->queries, true), 0, 25, true); foreach ($last25queries as $i => $query) { - $params = array_map(static function ($p) { - return is_object($p) ? get_debug_type($p) : var_export($p, true); - }, $query['params'] ?: []); + $params = array_map(static fn($p) => is_object($p) ? get_debug_type($p) : var_export($p, true), $query['params'] ?: []); $queries .= $i . ". SQL: '" . $query['sql'] . "' Params: " . implode(', ', $params) . PHP_EOL; } @@ -876,16 +1011,16 @@ protected function setUpDBALTypes(): void final protected function isQueryLogAvailable(): bool { - return $this->_em->getConnection() instanceof DbalExtensions\Connection; + return $this->_em->getConnection() instanceof Connection; } final protected function getQueryLog(): QueryLog { $connection = $this->_em->getConnection(); - if (! $connection instanceof DbalExtensions\Connection) { + if (! $connection instanceof Connection) { throw new RuntimeException(sprintf( 'The query log is only available if %s is used as wrapper class. Got %s.', - DbalExtensions\Connection::class, + Connection::class, get_debug_type($connection) )); } @@ -927,7 +1062,7 @@ protected function dropTableIfExists(string $name): void try { $schemaManager->dropTable($name); - } catch (DatabaseObjectNotFoundException $e) { + } catch (DatabaseObjectNotFoundException) { } } diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index e7f7a1e9039..9042b3c9ad4 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -4,6 +4,9 @@ namespace Doctrine\Tests; +use Doctrine\Common\Annotations\PsrCachedReader; +use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\DBAL\Driver\Result; use Doctrine\Common\Annotations; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; @@ -31,17 +34,13 @@ abstract class OrmTestCase extends DoctrineTestCase { /** * The metadata cache that is shared between all ORM tests (except functional tests). - * - * @var CacheItemPoolInterface|null */ - private static $metadataCache = null; + private static ?CacheItemPoolInterface $metadataCache = null; /** * The query cache that is shared between all ORM tests (except functional tests). - * - * @var CacheItemPoolInterface|null */ - private static $queryCache = null; + private static ?CacheItemPoolInterface $queryCache = null; /** @var bool */ protected $isSecondLevelCacheEnabled = false; @@ -55,13 +54,12 @@ abstract class OrmTestCase extends DoctrineTestCase /** @var StatisticsCacheLogger */ protected $secondLevelCacheLogger; - /** @var CacheItemPoolInterface|null */ - private $secondLevelCache = null; + private ?CacheItemPoolInterface $secondLevelCache = null; protected function createAnnotationDriver(array $paths = []): AnnotationDriver { return new AnnotationDriver( - new Annotations\PsrCachedReader(new Annotations\AnnotationReader(), new ArrayAdapter()), + new PsrCachedReader(new AnnotationReader(), new ArrayAdapter()), $paths ); } @@ -154,9 +152,7 @@ private function createConnectionMock(AbstractPlatform $platform): Connection ->setConstructorArgs([[], $this->createDriverMock($platform)]) ->onlyMethods(['quote']) ->getMockForAbstractClass(); - $connection->method('quote')->willReturnCallback(static function (string $input) { - return sprintf("'%s'", $input); - }); + $connection->method('quote')->willReturnCallback(static fn(string $input) => sprintf("'%s'", $input)); return $connection; } @@ -174,7 +170,7 @@ private function createPlatformMock(): AbstractPlatform private function createDriverMock(AbstractPlatform $platform): Driver { - $result = $this->createMock(Driver\Result::class); + $result = $this->createMock(Result::class); $result->method('fetchAssociative') ->willReturn(false); diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index 52419d9c2b4..65ed9cd6ee4 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -28,7 +28,7 @@ class TestUtil { /** @var bool Whether the database schema is initialized. */ - private static $initialized = false; + private static bool $initialized = false; /** * Gets a real database connection using the following parameters @@ -96,7 +96,7 @@ private static function initializeDatabase(): void try { $schemaManager->dropDatabase($dbname); - } catch (DatabaseObjectNotFoundException $e) { + } catch (DatabaseObjectNotFoundException) { } $schemaManager->createDatabase($dbname); From 8d4c3d3a34fa3ef681cf7f0236e9feef8b1d6bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 1 Jun 2022 20:07:14 +0200 Subject: [PATCH 104/475] Fix wrong types --- .../Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php | 2 +- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php | 3 ++- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php | 2 +- tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php | 3 +-- .../ORM/Tools/Console/Command/MappingDescribeCommandTest.php | 3 +-- .../ORM/Tools/Console/Command/ValidateSchemaCommandTest.php | 3 +-- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php index d6bbda236dd..1e9ed4a0049 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php @@ -21,7 +21,7 @@ */ class ManyToOneOrphanRemovalTest extends OrmFunctionalTestCase { - private int $personId; + private string $personId; /** @var array> */ protected static $modelSets = [ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index 5a5eda00f86..437a15f6ff1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -6,6 +6,7 @@ use DateTime; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; @@ -161,7 +162,7 @@ class DDC1430Order /** * @OneToMany(targetEntity="DDC1430OrderProduct", mappedBy="order", cascade={"persist", "remove"}) */ - private ArrayCollection $products; + private Collection $products; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php index e859963d8eb..f4cf9ce698f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php @@ -14,7 +14,7 @@ */ class DDC1885Test extends OrmFunctionalTestCase { - private \Doctrine\Tests\ORM\Functional\Ticket\User $user; + private User $user; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index 591b83014a3..10ef06baf2b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\Mapping\AnsiQuoteStrategy; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\DefaultQuoteStrategy; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsUser; @@ -21,7 +20,7 @@ */ class AnsiQuoteStrategyTest extends OrmTestCase { - private DefaultQuoteStrategy $strategy; + private AnsiQuoteStrategy $strategy; private AbstractPlatform $platform; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php index b55f5099d97..a04e046d3a3 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command; -use Doctrine\ORM\Tools\Console\Command\InfoCommand; use Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\Models\Cache\AttractionInfo; @@ -21,7 +20,7 @@ class MappingDescribeCommandTest extends OrmFunctionalTestCase { private Application $application; - private InfoCommand $command; + private MappingDescribeCommand $command; private CommandTester $tester; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php index c482a3f4bfe..99eb6a80f81 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command; use Doctrine\DBAL\Platforms\SqlitePlatform; -use Doctrine\ORM\Tools\Console\Command\InfoCommand; use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\OrmFunctionalTestCase; @@ -20,7 +19,7 @@ */ class ValidateSchemaCommandTest extends OrmFunctionalTestCase { - private InfoCommand $command; + private ValidateSchemaCommand $command; private CommandTester $tester; From 2f6303faefae2a6b1b73e1a733c6f087327ff178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 1 Jun 2022 20:48:53 +0200 Subject: [PATCH 105/475] Revert to untyped property This causes the following error for some reason: Typed property Doctrine\Tests\ORM\Functional\TrainOrder::$train must not be accessed before initialization --- .../ORM/Functional/OneToOneEagerLoadingTest.php | 7 ++++--- .../Tests/ORM/Functional/Ticket/DDC2579Test.php | 3 ++- .../Tests/ORM/Functional/ValueObjectsTest.php | 15 ++++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 12d20dcbd16..ec5cbb0733e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -408,12 +408,13 @@ class TrainOrder */ public $id; + public function __construct( /** + * @var Train * @OneToOne(targetEntity="Train", fetch="EAGER") */ - public Train $train - ) - { + public $train + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index e3e92416862..01988fe0396 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -107,11 +107,12 @@ class DDC2579EntityAssoc { public function __construct( /** + * @var DDC2579AssocAssoc * @Id * @ManyToOne(targetEntity="DDC2579AssocAssoc") * @JoinColumn(name="association_id", referencedColumnName="associationId") */ - public DDC2579AssocAssoc $assocAssoc + public $assocAssoc ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index c55006b5f19..205bcc9e32d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -381,9 +381,10 @@ class DDC93Person public $timestamps; public function __construct(/** + * @var string|null * @Column(type="string", length=255) */ - public ?string $name = null, /** + public $name = null, /** * @Embedded(class="DDC93Address") */ public ?\Doctrine\Tests\ORM\Functional\DDC93Address $address = null) @@ -464,21 +465,25 @@ class DDC93Address { public function __construct( /** + * @var string|null * @Column(type="string", length=255) */ - public ?string $street = null, + public $street = null, /** + * @var string|null * @Column(type="string", length=255) */ - public ?string $zip = null, + public $zip = null, /** + * @var string|null * @Column(type="string", length=255) */ - public ?string $city = null, + public $city = null, /** + * @var DDC93Country * @Embedded(class = "DDC93Country") */ - public ?\Doctrine\Tests\ORM\Functional\DDC93Country $country = null + public $country = null ) { } From c49636c9230cd83f4cad47e52fb831eb17b5a62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 1 Jun 2022 20:50:49 +0200 Subject: [PATCH 106/475] Revert to untyped property This causes "Cannot assign string to property Doctrine\Tests\Models\Cache\ComplexAction::$action2 of type Doctrine\Tests\Models\Cache\Action" for some reason. --- tests/Doctrine/Tests/Models/Cache/ComplexAction.php | 6 ++++-- tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php | 3 ++- tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php | 6 ++++-- tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php index 795e058abfe..7555a131726 100644 --- a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php +++ b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php @@ -27,16 +27,18 @@ class ComplexAction public $tokens; public function __construct(/** + * @var Action * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) * @JoinColumn(name="action1_name", referencedColumnName="name") */ - public Action $action1, /** + public $action1, /** + * @var Action * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) * @JoinColumn(name="action2_name", referencedColumnName="name") */ - public Action $action2, /** + public $action2, /** * @Column */ public string $name) diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php index dc1ee40bc47..1cd950e0e34 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php @@ -21,11 +21,12 @@ class DDC117ArticleDetails private string $text; public function __construct(/** + * @var DDC117Article * @Id * @OneToOne(targetEntity="DDC117Article", inversedBy="details") * @JoinColumn(name="article_id", referencedColumnName="article_id") */ - private DDC117Article $article, string $text) + private $article, string $text) { $article->setDetails($this); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php index 928cebe5c8f..502dc1b81e0 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php @@ -17,18 +17,20 @@ class DDC117Reference { /** + * @var DDC117Article * @Id * @ManyToOne(targetEntity="DDC117Article", inversedBy="references") * @JoinColumn(name="source_id", referencedColumnName="article_id") */ - private DDC117Article $source; + private $source; /** + * @var DDC117Article * @Id * @ManyToOne(targetEntity="DDC117Article") * @JoinColumn(name="target_id", referencedColumnName="article_id") */ - private DDC117Article $target; + private $target; /** * @Column(type="datetime") diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php index 1d20221c0b3..b4d4d8e914b 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php @@ -32,11 +32,12 @@ class DDC117Translation public $lastTranslatedBy; public function __construct(/** + * @var DDC117Article * @Id * @ManyToOne(targetEntity="DDC117Article", inversedBy="translations") * @JoinColumn(name="article_id", referencedColumnName="article_id") */ - private DDC117Article $article, /** + private $article, /** * @Id * @Column(type="string", length=255) */ From 66ae30085ba29e2894e24f308aadfa47ab0188a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 1 Jun 2022 21:20:52 +0200 Subject: [PATCH 107/475] Adjust expectations --- tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php | 2 +- tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php index 7a5f35bf5ce..986046b9a36 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -155,7 +155,7 @@ public function testCompositeCollectionMemberExpression(): void public function testSpecifyUnknownIdentifierPrimaryKeyFails(): void { $this->expectException(MissingIdentifierField::class); - $this->expectExceptionMessage('The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); + $this->expectExceptionMessage('The identifier lat is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); $poi = $this->_em->find(NavPointOfInterest::class, ['key1' => 100]); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index bcbb0e04326..332033043ec 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -973,7 +973,7 @@ public function testInvalidEntityListenerClassException(): void public function testInvalidEntityListenerMethodException(): void { $this->expectException(MappingException::class); - $this->expectExceptionMessage('Entity Listener "\Doctrine\Tests\Models\Company\CompanyContractListener" declared on "Doctrine\Tests\Models\CMS\CmsUser" has no method "invalidMethod".'); + $this->expectExceptionMessage('Entity Listener "Doctrine\Tests\Models\Company\CompanyContractListener" declared on "Doctrine\Tests\Models\CMS\CmsUser" has no method "invalidMethod".'); $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); From e7a466b70809090dc5bb00898714dccdb422a3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 1 Jun 2022 21:26:56 +0200 Subject: [PATCH 108/475] fix cs --- .../Hydration/SimpleHydrationBench.php | 15 +- .../SimpleInsertPerformanceBench.php | 14 +- ...leInheritanceHydrationPerformanceBench.php | 17 +- ...TableInheritanceInsertPerformanceBench.php | 18 +- .../Tests/DbalTypes/CustomIdObject.php | 4 +- tests/Doctrine/Tests/DbalTypes/Rot13Type.php | 10 +- tests/Doctrine/Tests/Mocks/NullSqlWalker.php | 5 +- .../Doctrine/Tests/Models/CMS/CmsComment.php | 3 +- .../Doctrine/Tests/Models/CMS/CmsEmployee.php | 6 +- tests/Doctrine/Tests/Models/Cache/Action.php | 18 +- tests/Doctrine/Tests/Models/Cache/Address.php | 3 +- .../Tests/Models/Cache/Attraction.php | 22 +- tests/Doctrine/Tests/Models/Cache/City.php | 22 +- tests/Doctrine/Tests/Models/Cache/Client.php | 8 +- .../Tests/Models/Cache/ComplexAction.php | 39 +-- tests/Doctrine/Tests/Models/Cache/Country.php | 3 +- tests/Doctrine/Tests/Models/Cache/Flight.php | 32 ++- tests/Doctrine/Tests/Models/Cache/Login.php | 3 +- tests/Doctrine/Tests/Models/Cache/Person.php | 3 +- tests/Doctrine/Tests/Models/Cache/State.php | 24 +- tests/Doctrine/Tests/Models/Cache/Token.php | 20 +- tests/Doctrine/Tests/Models/Cache/Travel.php | 15 +- .../Doctrine/Tests/Models/Cache/Traveler.php | 11 +- .../Tests/Models/Cache/TravelerProfile.php | 3 +- .../Models/Cache/TravelerProfileInfo.php | 3 +- .../Tests/Models/Company/CompanyAuction.php | 4 +- .../Tests/Models/Company/CompanyCar.php | 3 +- .../Tests/Models/Company/CompanyContract.php | 8 +- .../Tests/Models/Company/CompanyEmployee.php | 14 +- .../Tests/Models/Company/CompanyEvent.php | 8 +- .../Models/Company/CompanyFixContract.php | 4 +- .../Models/Company/CompanyFlexContract.php | 8 +- .../Company/CompanyFlexUltraContract.php | 4 +- .../Tests/Models/Company/CompanyManager.php | 4 +- .../Tests/Models/Company/CompanyPerson.php | 6 +- .../Tests/Models/Company/CompanyRaffle.php | 4 +- .../CustomType/CustomIdObjectTypeChild.php | 3 +- .../CustomType/CustomIdObjectTypeParent.php | 13 +- .../Models/DDC117/DDC117ApproveChanges.php | 3 +- .../Tests/Models/DDC117/DDC117Article.php | 15 +- .../Models/DDC117/DDC117ArticleDetails.php | 22 +- .../Tests/Models/DDC117/DDC117Editor.php | 11 +- .../Tests/Models/DDC117/DDC117Link.php | 11 +- .../Tests/Models/DDC117/DDC117Reference.php | 25 +- .../Tests/Models/DDC117/DDC117Translation.php | 33 ++- .../Tests/Models/DDC2372/DDC2372Address.php | 4 +- .../Tests/Models/DDC2372/DDC2372User.php | 4 +- .../Tests/Models/DDC3579/DDC3579Group.php | 11 +- .../Tests/Models/DDC3579/DDC3579User.php | 11 +- .../Tests/Models/DDC3597/DDC3597Image.php | 4 +- .../Tests/Models/DDC3597/DDC3597Media.php | 16 +- .../DDC3597/Embeddable/DDC3597Dimension.php | 8 +- .../Tests/Models/DDC4006/DDC4006User.php | 4 +- .../Tests/Models/DDC964/DDC964Address.php | 3 +- .../Tests/Models/DDC964/DDC964Group.php | 14 +- .../Tests/Models/DDC964/DDC964User.php | 11 +- .../DirectoryTree/AbstractContentItem.php | 3 +- .../Tests/Models/ECommerce/ECommerceCart.php | 4 +- .../Models/ECommerce/ECommerceCategory.php | 6 +- .../Models/ECommerce/ECommerceCustomer.php | 10 +- .../Models/ECommerce/ECommerceFeature.php | 4 +- .../Models/ECommerce/ECommerceProduct.php | 4 +- .../Models/ECommerce/ECommerceShipping.php | 4 +- .../Models/Generic/NonAlphaColumnsEntity.php | 3 +- .../Doctrine/Tests/Models/GeoNames/Admin1.php | 3 +- .../Models/GeoNames/Admin1AlternateName.php | 3 +- tests/Doctrine/Tests/Models/GeoNames/City.php | 3 +- .../Tests/Models/GeoNames/Country.php | 11 +- .../Models/Global/GlobalNamespaceModel.php | 8 +- .../Models/Legacy/LegacyUserReference.php | 25 +- .../Models/ManyToManyPersister/ChildClass.php | 26 +- .../ManyToManyPersister/OtherParentClass.php | 3 +- .../ManyToManyPersister/ParentClass.php | 13 +- .../Tests/Models/Navigation/NavCountry.php | 3 +- .../Tests/Models/Navigation/NavPhotos.php | 3 +- .../Models/Navigation/NavPointOfInterest.php | 36 +-- .../Tests/Models/Navigation/NavTour.php | 11 +- .../Tests/Models/Navigation/NavUser.php | 3 +- tests/Doctrine/Tests/Models/Quote/City.php | 3 +- tests/Doctrine/Tests/Models/Quote/Group.php | 5 +- .../Tests/Models/Quote/NumericEntity.php | 3 +- .../Tests/Models/StockExchange/Bond.php | 3 +- .../Tests/Models/StockExchange/Market.php | 11 +- .../Tests/Models/StockExchange/Stock.php | 28 +- tests/Doctrine/Tests/Models/Taxi/Car.php | 4 +- tests/Doctrine/Tests/Models/Taxi/Driver.php | 4 +- tests/Doctrine/Tests/Models/Taxi/PaidRide.php | 3 +- tests/Doctrine/Tests/Models/Taxi/Ride.php | 3 +- .../Tests/ORM/Cache/DefaultCacheTest.php | 4 +- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 2 +- .../Tests/ORM/Cache/FileLockRegionTest.php | 2 +- .../AbstractManyToManyAssociationTestCase.php | 2 +- .../Functional/AdvancedAssociationTest.php | 36 +-- .../ORM/Functional/BasicFunctionalTest.php | 2 - .../ORM/Functional/CascadeRemoveOrderTest.php | 23 +- .../ClassTableInheritanceSecondTest.php | 13 +- .../Functional/ClassTableInheritanceTest.php | 1 - .../ORM/Functional/CustomFunctionsTest.php | 5 +- .../ORM/Functional/DefaultValuesTest.php | 2 - .../ORM/Functional/EntityRepositoryTest.php | 3 +- .../Tests/ORM/Functional/FlushEventTest.php | 2 - .../Tests/ORM/Functional/GH5988Test.php | 2 +- .../Tests/ORM/Functional/IdentityMapTest.php | 2 - .../ORM/Functional/LifecycleCallbackTest.php | 9 +- .../Functional/Locking/GearmanLockTest.php | 2 +- .../Functional/Locking/LockAgentWorker.php | 2 +- .../ORM/Functional/Locking/OptimisticTest.php | 6 +- .../ManyToManyBasicAssociationTest.php | 5 +- .../ORM/Functional/ManyToManyEventTest.php | 2 +- .../ORM/Functional/MappedSuperclassTest.php | 2 - .../Tests/ORM/Functional/NativeQueryTest.php | 2 +- .../Tests/ORM/Functional/NewOperatorTest.php | 2 +- .../Tests/ORM/Functional/NotifyPolicyTest.php | 8 +- .../Functional/OneToOneEagerLoadingTest.php | 14 +- ...OneToOneSelfReferentialAssociationTest.php | 6 +- .../OneToOneUnidirectionalAssociationTest.php | 2 - .../Tests/ORM/Functional/PaginationTest.php | 14 +- .../ORM/Functional/PostFlushEventTest.php | 2 +- .../Tests/ORM/Functional/QueryTest.php | 2 +- .../Tests/ORM/Functional/ReadOnlyTest.php | 6 +- .../ORM/Functional/ReferenceProxyTest.php | 1 - .../Tests/ORM/Functional/SQLFilterTest.php | 2 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 5 +- .../ORM/Functional/SchemaTool/DDC214Test.php | 20 +- .../SchemaTool/MySqlSchemaToolTest.php | 17 +- .../SchemaTool/PostgreSqlSchemaToolTest.php | 9 +- ...condLevelCacheJoinTableInheritanceTest.php | 1 - .../SecondLevelCacheQueryCacheTest.php | 2 +- ...ndLevelCacheSingleTableInheritanceTest.php | 1 - .../ORM/Functional/SecondLevelCacheTest.php | 2 +- .../SequenceEmulatedIdentityStrategyTest.php | 4 +- .../Functional/SingleTableInheritanceTest.php | 3 +- .../ORM/Functional/Ticket/DDC1041Test.php | 1 - .../ORM/Functional/Ticket/DDC1163Test.php | 14 +- .../ORM/Functional/Ticket/DDC117Test.php | 1 - .../ORM/Functional/Ticket/DDC1193Test.php | 2 - .../ORM/Functional/Ticket/DDC1209Test.php | 18 +- .../ORM/Functional/Ticket/DDC1225Test.php | 2 +- .../ORM/Functional/Ticket/DDC1238Test.php | 4 +- .../ORM/Functional/Ticket/DDC1301Test.php | 5 +- .../ORM/Functional/Ticket/DDC1335Test.php | 29 +- .../ORM/Functional/Ticket/DDC1430Test.php | 26 +- .../ORM/Functional/Ticket/DDC1454Test.php | 2 +- .../ORM/Functional/Ticket/DDC1461Test.php | 2 - .../ORM/Functional/Ticket/DDC1643Test.php | 2 - .../ORM/Functional/Ticket/DDC1655Test.php | 1 - .../ORM/Functional/Ticket/DDC1690Test.php | 20 +- .../ORM/Functional/Ticket/DDC1695Test.php | 71 ++--- .../ORM/Functional/Ticket/DDC1719Test.php | 3 +- .../ORM/Functional/Ticket/DDC1757Test.php | 12 +- .../ORM/Functional/Ticket/DDC1925Test.php | 8 +- .../ORM/Functional/Ticket/DDC1998Test.php | 3 +- .../ORM/Functional/Ticket/DDC2012Test.php | 1 - .../ORM/Functional/Ticket/DDC2084Test.php | 6 +- .../ORM/Functional/Ticket/DDC2138Test.php | 8 +- .../ORM/Functional/Ticket/DDC2182Test.php | 2 +- .../ORM/Functional/Ticket/DDC2252Test.php | 28 +- .../ORM/Functional/Ticket/DDC2306Test.php | 18 +- .../ORM/Functional/Ticket/DDC237Test.php | 2 - .../ORM/Functional/Ticket/DDC2494Test.php | 8 +- .../ORM/Functional/Ticket/DDC2575Test.php | 9 +- .../ORM/Functional/Ticket/DDC2579Test.php | 21 +- .../ORM/Functional/Ticket/DDC2602Test.php | 4 +- .../ORM/Functional/Ticket/DDC2660Test.php | 8 +- .../ORM/Functional/Ticket/DDC2759Test.php | 6 +- .../ORM/Functional/Ticket/DDC2790Test.php | 1 - .../ORM/Functional/Ticket/DDC2862Test.php | 19 +- .../ORM/Functional/Ticket/DDC2895Test.php | 1 - .../ORM/Functional/Ticket/DDC2984Test.php | 10 +- .../ORM/Functional/Ticket/DDC2996Test.php | 2 - .../ORM/Functional/Ticket/DDC3033Test.php | 2 - .../ORM/Functional/Ticket/DDC3160Test.php | 2 - .../ORM/Functional/Ticket/DDC3192Test.php | 6 +- .../ORM/Functional/Ticket/DDC3300Test.php | 16 +- .../ORM/Functional/Ticket/DDC3303Test.php | 22 +- .../ORM/Functional/Ticket/DDC345Test.php | 2 +- .../ORM/Functional/Ticket/DDC353Test.php | 2 +- .../ORM/Functional/Ticket/DDC3582Test.php | 13 +- .../ORM/Functional/Ticket/DDC3634Test.php | 2 +- .../ORM/Functional/Ticket/DDC3644Test.php | 16 +- .../ORM/Functional/Ticket/DDC3785Test.php | 25 +- .../ORM/Functional/Ticket/DDC422Test.php | 2 - .../ORM/Functional/Ticket/DDC448Test.php | 2 +- .../ORM/Functional/Ticket/DDC522Test.php | 2 - .../ORM/Functional/Ticket/DDC5684Test.php | 3 +- .../ORM/Functional/Ticket/DDC588Test.php | 8 +- .../ORM/Functional/Ticket/DDC618Test.php | 11 +- .../ORM/Functional/Ticket/DDC6303Test.php | 28 +- .../ORM/Functional/Ticket/DDC656Test.php | 1 - .../ORM/Functional/Ticket/DDC657Test.php | 36 +-- .../Tests/ORM/Functional/Ticket/DDC69Test.php | 18 +- .../ORM/Functional/Ticket/DDC735Test.php | 11 +- .../ORM/Functional/Ticket/DDC736Test.php | 3 +- .../ORM/Functional/Ticket/DDC767Test.php | 1 - .../ORM/Functional/Ticket/DDC812Test.php | 2 - .../ORM/Functional/Ticket/DDC832Test.php | 25 +- .../ORM/Functional/Ticket/DDC837Test.php | 3 +- .../ORM/Functional/Ticket/DDC881Test.php | 16 +- .../ORM/Functional/Ticket/DDC960Test.php | 8 +- .../ORM/Functional/Ticket/DDC992Test.php | 2 - .../ORM/Functional/Ticket/GH2947Test.php | 6 +- .../ORM/Functional/Ticket/GH5562Test.php | 3 +- .../ORM/Functional/Ticket/GH5762Test.php | 74 ++--- .../ORM/Functional/Ticket/GH5887Test.php | 9 +- .../ORM/Functional/Ticket/GH6141Test.php | 6 +- .../ORM/Functional/Ticket/GH6217Test.php | 3 +- .../ORM/Functional/Ticket/GH6362Test.php | 12 +- .../ORM/Functional/Ticket/GH6394Test.php | 6 +- .../ORM/Functional/Ticket/GH6531Test.php | 6 +- .../ORM/Functional/Ticket/GH7012Test.php | 3 +- .../ORM/Functional/Ticket/GH7062Test.php | 50 ++-- .../ORM/Functional/Ticket/GH7286Test.php | 3 +- .../ORM/Functional/Ticket/GH7366Test.php | 3 +- .../Ticket/GH7496WithToIterableTest.php | 18 +- .../ORM/Functional/Ticket/GH7661Test.php | 3 +- .../ORM/Functional/Ticket/GH7735Test.php | 37 +-- .../ORM/Functional/Ticket/GH7737Test.php | 16 +- .../ORM/Functional/Ticket/GH7767Test.php | 3 +- .../ORM/Functional/Ticket/GH7820Test.php | 12 +- .../ORM/Functional/Ticket/GH7836Test.php | 3 +- .../ORM/Functional/Ticket/GH7864Test.php | 2 +- .../ORM/Functional/Ticket/GH7875Test.php | 8 +- .../ORM/Functional/Ticket/GH7941Test.php | 18 +- .../ORM/Functional/Ticket/GH8217Test.php | 3 +- .../ORM/Functional/Ticket/GH8443Test.php | 3 +- .../ORM/Functional/Ticket/GH9109Test.php | 12 +- .../Tests/ORM/Functional/TypeTest.php | 2 +- .../ManyToManyCompositeIdForeignKeyTest.php | 3 +- .../ManyToManyCompositeIdTest.php | 3 +- .../ManyToManyExtraLazyTest.php | 5 +- .../ValueConversionType/ManyToManyTest.php | 3 +- .../OneToManyCompositeIdForeignKeyTest.php | 3 +- .../OneToManyCompositeIdTest.php | 3 +- .../OneToManyExtraLazyTest.php | 3 +- .../ValueConversionType/OneToManyTest.php | 3 +- .../OneToOneCompositeIdForeignKeyTest.php | 3 +- .../OneToOneCompositeIdTest.php | 3 +- .../ValueConversionType/OneToOneTest.php | 3 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 69 ++--- .../ORM/Hydration/ObjectHydratorTest.php | 2 +- .../Internal/HydrationCompleteHandlerTest.php | 4 +- .../ORM/Mapping/AbstractMappingDriverTest.php | 14 +- .../ORM/Mapping/AnnotationDriverTest.php | 20 +- .../Mapping/BasicInheritanceMappingTest.php | 30 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 9 +- .../Mapping/ClassMetadataLoadEventTest.php | 7 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 27 +- .../Mapping/EntityListenerResolverTest.php | 5 +- .../Tests/ORM/Mapping/FieldBuilderTest.php | 5 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 14 +- tests/Doctrine/Tests/ORM/Query/ExprTest.php | 7 +- .../ORM/Query/LanguageRecognitionTest.php | 14 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 2 +- .../ORM/Query/SelectSqlGenerationTest.php | 4 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 1 - .../AttachEntityListenersListenerTest.php | 2 +- .../Command/MappingDescribeCommandTest.php | 5 +- .../ORM/Tools/Pagination/PaginatorTest.php | 2 +- .../Tools/ResolveTargetEntityListenerTest.php | 8 +- .../Tests/ORM/Tools/SchemaToolTest.php | 8 +- .../Tests/ORM/Tools/SchemaValidatorTest.php | 120 +++----- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 12 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 260 +++++++++--------- tests/Doctrine/Tests/OrmTestCase.php | 7 +- 264 files changed, 1193 insertions(+), 1618 deletions(-) diff --git a/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php b/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php index dabb1236122..bb1be9dccce 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php @@ -4,18 +4,17 @@ namespace Doctrine\Performance\Hydration; -use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; +use Doctrine\Performance\EntityManagerFactory; use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsTag; -use Doctrine\Tests\Models\CMS\CmsArticle; -use Doctrine\Tests\Models\CMS\CmsComment; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\EntityRepository; -use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Models\CMS; +use Doctrine\Tests\Models\CMS\CmsUser; /** * @BeforeMethods({"init"}) diff --git a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php index 189bc0f8f42..51bed946873 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php @@ -4,17 +4,17 @@ namespace Doctrine\Performance\Hydration; -use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Performance\EntityManagerFactory; +use Doctrine\Tests\Models\CMS; use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsTag; -use Doctrine\Tests\Models\CMS\CmsArticle; -use Doctrine\Tests\Models\CMS\CmsComment; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Models\CMS; +use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; /** diff --git a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php index ab1076f6c3f..757909979b1 100644 --- a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php @@ -4,21 +4,20 @@ namespace Doctrine\Performance\Hydration; -use Doctrine\Tests\Models\Company\CompanyPerson; -use Doctrine\Tests\Models\Company\CompanyEmployee; -use Doctrine\Tests\Models\Company\CompanyManager; -use Doctrine\Tests\Models\Company\CompanyOrganization; -use Doctrine\Tests\Models\Company\CompanyEvent; +use Doctrine\ORM\EntityRepository; +use Doctrine\Performance\EntityManagerFactory; use Doctrine\Tests\Models\Company\CompanyAuction; -use Doctrine\Tests\Models\Company\CompanyRaffle; use Doctrine\Tests\Models\Company\CompanyCar; use Doctrine\Tests\Models\Company\CompanyContract; +use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyEvent; use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; -use Doctrine\ORM\EntityRepository; -use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Models\Company; +use Doctrine\Tests\Models\Company\CompanyManager; +use Doctrine\Tests\Models\Company\CompanyOrganization; +use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\Models\Company\CompanyRaffle; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; /** diff --git a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php index 09feefc63bc..cc86027e465 100644 --- a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php @@ -4,21 +4,21 @@ namespace Doctrine\Performance\Hydration; -use Doctrine\Tests\Models\Company\CompanyPerson; -use Doctrine\Tests\Models\Company\CompanyEmployee; -use Doctrine\Tests\Models\Company\CompanyManager; -use Doctrine\Tests\Models\Company\CompanyOrganization; -use Doctrine\Tests\Models\Company\CompanyEvent; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Performance\EntityManagerFactory; +use Doctrine\Tests\Models\Company; use Doctrine\Tests\Models\Company\CompanyAuction; -use Doctrine\Tests\Models\Company\CompanyRaffle; use Doctrine\Tests\Models\Company\CompanyCar; use Doctrine\Tests\Models\Company\CompanyContract; +use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyEvent; use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\Performance\EntityManagerFactory; -use Doctrine\Tests\Models\Company; +use Doctrine\Tests\Models\Company\CompanyManager; +use Doctrine\Tests\Models\Company\CompanyOrganization; +use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\Models\Company\CompanyRaffle; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; use function array_map; diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php b/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php index f246a9d1fd6..8e7b6ddaa27 100644 --- a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php +++ b/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php @@ -4,7 +4,9 @@ namespace Doctrine\Tests\DbalTypes; -class CustomIdObject implements \Stringable +use Stringable; + +class CustomIdObject implements Stringable { public function __construct(public string $id) { diff --git a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php index e4fe9378a12..c364fd7d838 100644 --- a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php +++ b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php @@ -18,7 +18,7 @@ class Rot13Type extends Type /** * {@inheritdoc} * - * @param string|null $value + * @param string|null $value */ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string { @@ -32,7 +32,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str /** * {@inheritdoc} * - * @param string|null $value + * @param string|null $value */ public function convertToPHPValue($value, AbstractPlatform $platform): ?string { @@ -45,8 +45,6 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?string /** * {@inheritdoc} - * - * */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { @@ -60,7 +58,6 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st /** * {@inheritdoc} * - * * @return int|null */ public function getDefaultLength(AbstractPlatform $platform) @@ -68,9 +65,6 @@ public function getDefaultLength(AbstractPlatform $platform) return $platform->getVarcharDefaultLength(); } - /** - * {@inheritdoc} - */ public function getName(): string { return 'rot13'; diff --git a/tests/Doctrine/Tests/Mocks/NullSqlWalker.php b/tests/Doctrine/Tests/Mocks/NullSqlWalker.php index 6ad9486e5f2..21563583f6d 100644 --- a/tests/Doctrine/Tests/Mocks/NullSqlWalker.php +++ b/tests/Doctrine/Tests/Mocks/NullSqlWalker.php @@ -4,11 +4,10 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\Query\AST\DeleteStatement; use Doctrine\ORM\Query\AST\SelectStatement; use Doctrine\ORM\Query\AST\UpdateStatement; -use Doctrine\ORM\Query\AST\DeleteStatement; -use Doctrine\DBAL\Connection; -use Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; use Doctrine\ORM\Query\SqlWalker; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsComment.php b/tests/Doctrine/Tests/Models/CMS/CmsComment.php index 3d1eb331904..7c042173c45 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsComment.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsComment.php @@ -11,12 +11,13 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; +use Stringable; /** * @Entity * @Table(name="cms_comments") */ -class CmsComment implements \Stringable +class CmsComment implements Stringable { /** * @var int diff --git a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php b/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php index 536231b1f1b..fb4ad4e0042 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php @@ -27,16 +27,14 @@ class CmsEmployee */ private int $id; - /** - * @Column - */ + /** @Column */ private string $name; /** * @OneToOne(targetEntity="CmsEmployee") * @JoinColumn(name="spouse_id", referencedColumnName="id") */ - private \Doctrine\Tests\Models\CMS\CmsEmployee $spouse; + private CmsEmployee $spouse; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/Cache/Action.php b/tests/Doctrine/Tests/Models/Cache/Action.php index 8e350cd94d4..81c0e724cf5 100644 --- a/tests/Doctrine/Tests/Models/Cache/Action.php +++ b/tests/Doctrine/Tests/Models/Cache/Action.php @@ -25,16 +25,14 @@ class Action */ public $tokens; - /** - * @param string $name - */ - public function __construct(/** - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") - */ - public $name) - { + public function __construct( + /** + * @Id + * @Column(type="string", length=255) + * @GeneratedValue(strategy="NONE") + */ + public string $name + ) { $this->tokens = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Address.php b/tests/Doctrine/Tests/Models/Cache/Address.php index 29049224e6f..beabc0c9c18 100644 --- a/tests/Doctrine/Tests/Models/Cache/Address.php +++ b/tests/Doctrine/Tests/Models/Cache/Address.php @@ -38,7 +38,6 @@ public function __construct( * @Column */ public string $location - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/Cache/Attraction.php b/tests/Doctrine/Tests/Models/Cache/Attraction.php index 5ca2bbb7b30..1968cbac550 100644 --- a/tests/Doctrine/Tests/Models/Cache/Attraction.php +++ b/tests/Doctrine/Tests/Models/Cache/Attraction.php @@ -46,16 +46,18 @@ abstract class Attraction */ protected $infos; - public function __construct(/** - * @Column(unique=true) - */ - protected string $name, /** - * @Cache - * @ManyToOne(targetEntity="City", inversedBy="attractions") - * @JoinColumn(name="city_id", referencedColumnName="id") - */ - protected City $city) - { + public function __construct( + /** + * @Column(unique=true) + */ + protected string $name, + /** + * @Cache + * @ManyToOne(targetEntity="City", inversedBy="attractions") + * @JoinColumn(name="city_id", referencedColumnName="id") + */ + protected City $city + ) { $this->infos = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/City.php b/tests/Doctrine/Tests/Models/Cache/City.php index 61f76126e69..c10414fda23 100644 --- a/tests/Doctrine/Tests/Models/Cache/City.php +++ b/tests/Doctrine/Tests/Models/Cache/City.php @@ -54,16 +54,18 @@ class City #[ORM\OneToMany(targetEntity: 'Attraction', mappedBy: 'city')] public $attractions; - public function __construct(/** - * @Column(unique=true) - */ - #[ORM\Column(unique: true)] protected string $name, /** - * @Cache - * @ManyToOne(targetEntity="State", inversedBy="cities") - * @JoinColumn(name="state_id", referencedColumnName="id") - */ - #[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'citities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] protected ?State $state = null) - { + public function __construct( + /** + * @Column(unique=true) + */ + #[ORM\Column(unique: true)] protected string $name, + /** + * @Cache + * @ManyToOne(targetEntity="State", inversedBy="cities") + * @JoinColumn(name="state_id", referencedColumnName="id") + */ + #[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'citities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] protected ?State $state = null + ) { $this->travels = new ArrayCollection(); $this->attractions = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Client.php b/tests/Doctrine/Tests/Models/Cache/Client.php index 5c947a3afae..7b77968e228 100644 --- a/tests/Doctrine/Tests/Models/Cache/Client.php +++ b/tests/Doctrine/Tests/Models/Cache/Client.php @@ -24,15 +24,11 @@ class Client */ public $id; - /** - * @param string $name - */ public function __construct( /** * @Column(unique=true) */ - public $name - ) - { + public string $name + ) { } } diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php index 7555a131726..35421217758 100644 --- a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php +++ b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php @@ -26,24 +26,27 @@ class ComplexAction */ public $tokens; - public function __construct(/** - * @var Action - * @Id - * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) - * @JoinColumn(name="action1_name", referencedColumnName="name") - */ - public $action1, /** - * @var Action - * @Id - * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) - * @JoinColumn(name="action2_name", referencedColumnName="name") - */ - public $action2, /** - * @Column - */ - public string $name) - { - $this->tokens = new ArrayCollection(); + public function __construct( + /** + * @var Action + * @Id + * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) + * @JoinColumn(name="action1_name", referencedColumnName="name") + */ + public $action1, + /** + * @var Action + * @Id + * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) + * @JoinColumn(name="action2_name", referencedColumnName="name") + */ + public $action2, + /** + * @Column + */ + public string $name + ) { + $this->tokens = new ArrayCollection(); } public function addToken(Token $token): void diff --git a/tests/Doctrine/Tests/Models/Cache/Country.php b/tests/Doctrine/Tests/Models/Cache/Country.php index 5235b3b9bb6..a54fd13b1d8 100644 --- a/tests/Doctrine/Tests/Models/Cache/Country.php +++ b/tests/Doctrine/Tests/Models/Cache/Country.php @@ -31,8 +31,7 @@ public function __construct( * @Column(unique=true) */ protected string $name - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Cache/Flight.php b/tests/Doctrine/Tests/Models/Cache/Flight.php index 95afffe7b4d..7e65a80595f 100644 --- a/tests/Doctrine/Tests/Models/Cache/Flight.php +++ b/tests/Doctrine/Tests/Models/Cache/Flight.php @@ -26,21 +26,23 @@ class Flight */ protected $departure; - public function __construct(/** - * @Id - * @Cache - * @ManyToOne(targetEntity="City") - * @JoinColumn(name="leaving_from_city_id", referencedColumnName="id") - */ - protected City $leavingFrom, /** - * @Id - * @Cache - * @ManyToOne(targetEntity="City") - * @JoinColumn(name="going_to_city_id", referencedColumnName="id") - */ - protected City $goingTo) - { - $this->departure = new DateTime(); + public function __construct( + /** + * @Id + * @Cache + * @ManyToOne(targetEntity="City") + * @JoinColumn(name="leaving_from_city_id", referencedColumnName="id") + */ + protected City $leavingFrom, + /** + * @Id + * @Cache + * @ManyToOne(targetEntity="City") + * @JoinColumn(name="going_to_city_id", referencedColumnName="id") + */ + protected City $goingTo + ) { + $this->departure = new DateTime(); } public function getLeavingFrom(): City diff --git a/tests/Doctrine/Tests/Models/Cache/Login.php b/tests/Doctrine/Tests/Models/Cache/Login.php index 5ccde755320..1971cad1710 100644 --- a/tests/Doctrine/Tests/Models/Cache/Login.php +++ b/tests/Doctrine/Tests/Models/Cache/Login.php @@ -38,8 +38,7 @@ public function __construct( * @Column */ public string $name - ) - { + ) { } public function getToken(): Token diff --git a/tests/Doctrine/Tests/Models/Cache/Person.php b/tests/Doctrine/Tests/Models/Cache/Person.php index 26241e4dff6..ee1f62f5e14 100644 --- a/tests/Doctrine/Tests/Models/Cache/Person.php +++ b/tests/Doctrine/Tests/Models/Cache/Person.php @@ -38,7 +38,6 @@ public function __construct( * @Column(unique=true) */ public string $name - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/Cache/State.php b/tests/Doctrine/Tests/Models/Cache/State.php index 1d9549ffadf..5046caf1dd8 100644 --- a/tests/Doctrine/Tests/Models/Cache/State.php +++ b/tests/Doctrine/Tests/Models/Cache/State.php @@ -38,17 +38,19 @@ class State */ protected $cities; - public function __construct(/** - * @Column(unique=true) - */ - protected string $name, /** - * @Cache - * @ManyToOne(targetEntity="Country") - * @JoinColumn(name="country_id", referencedColumnName="id") - */ - protected ?Country $country = null) - { - $this->cities = new ArrayCollection(); + public function __construct( + /** + * @Column(unique=true) + */ + protected string $name, + /** + * @Cache + * @ManyToOne(targetEntity="Country") + * @JoinColumn(name="country_id", referencedColumnName="id") + */ + protected ?Country $country = null + ) { + $this->cities = new ArrayCollection(); } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Cache/Token.php b/tests/Doctrine/Tests/Models/Cache/Token.php index 3fcaec6e1b1..3e591609e84 100644 --- a/tests/Doctrine/Tests/Models/Cache/Token.php +++ b/tests/Doctrine/Tests/Models/Cache/Token.php @@ -57,15 +57,17 @@ class Token */ public $complexAction; - public function __construct(/** - * @Id - * @Column(type="string", length=255) - */ - public string $token, /** - * @OneToOne(targetEntity="Client") - */ - public ?Client $client = null) - { + public function __construct( + /** + * @Id + * @Column(type="string", length=255) + */ + public string $token, + /** + * @OneToOne(targetEntity="Client") + */ + public ?Client $client = null + ) { $this->logins = new ArrayCollection(); $this->expiresAt = new DateTime(date('Y-m-d H:i:s', strtotime('+7 day'))); } diff --git a/tests/Doctrine/Tests/Models/Cache/Travel.php b/tests/Doctrine/Tests/Models/Cache/Travel.php index 17a70ea05b4..f044f9783b0 100644 --- a/tests/Doctrine/Tests/Models/Cache/Travel.php +++ b/tests/Doctrine/Tests/Models/Cache/Travel.php @@ -54,13 +54,14 @@ class Travel */ public $visitedCities; - public function __construct(/** - * @Cache - * @ManyToOne(targetEntity="Traveler", inversedBy="travels") - * @JoinColumn(name="traveler_id", referencedColumnName="id") - */ - protected Traveler $traveler) - { + public function __construct( + /** + * @Cache + * @ManyToOne(targetEntity="Traveler", inversedBy="travels") + * @JoinColumn(name="traveler_id", referencedColumnName="id") + */ + protected Traveler $traveler + ) { $this->createdAt = new DateTime('now'); $this->visitedCities = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Traveler.php b/tests/Doctrine/Tests/Models/Cache/Traveler.php index 5d3e92dabcb..005678908e9 100644 --- a/tests/Doctrine/Tests/Models/Cache/Traveler.php +++ b/tests/Doctrine/Tests/Models/Cache/Traveler.php @@ -44,11 +44,12 @@ class Traveler */ protected $profile; - public function __construct(/** - * @Column - */ - protected string $name) - { + public function __construct( + /** + * @Column + */ + protected string $name + ) { $this->travels = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php index 2044582d65b..95319ee6768 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php @@ -38,8 +38,7 @@ public function __construct( * @Column(unique=true) */ private string $name - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php index 73feb4c7a3c..24d49544221 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php @@ -39,8 +39,7 @@ public function __construct( * @Column(unique=true) */ private string $description - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php b/tests/Doctrine/Tests/Models/Company/CompanyAuction.php index 131fbc26f99..adcc239a3f0 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyAuction.php @@ -14,9 +14,7 @@ */ class CompanyAuction extends CompanyEvent { - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $data = null; public function setData(string $data): void diff --git a/tests/Doctrine/Tests/Models/Company/CompanyCar.php b/tests/Doctrine/Tests/Models/Company/CompanyCar.php index ed44fddb165..7afaffed77b 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyCar.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyCar.php @@ -28,8 +28,7 @@ public function __construct( * @Column(type="string", length=50) */ private ?string $brand = null - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index 3a6c0e3486c..19e1373b632 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -82,14 +82,10 @@ abstract class CompanyContract #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue] private int $id; - /** - * @ManyToOne(targetEntity="CompanyEmployee", inversedBy="soldContracts") - */ + /** @ManyToOne(targetEntity="CompanyEmployee", inversedBy="soldContracts") */ private ?CompanyEmployee $salesPerson = null; - /** - * @Column(type="boolean") - */ + /** @Column(type="boolean") */ private bool $completed = false; /** diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php index 67eb5aba83f..ae1298c4e6e 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php @@ -18,20 +18,14 @@ */ class CompanyEmployee extends CompanyPerson { - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ private ?int $salary = null; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $department = null; - /** - * @Column(type="datetime", nullable=true) - */ - private ?\DateTime $startDate = null; + /** @Column(type="datetime", nullable=true) */ + private ?DateTime $startDate = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php b/tests/Doctrine/Tests/Models/Company/CompanyEvent.php index 9e0e892c266..41197283c26 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEvent.php @@ -32,10 +32,10 @@ abstract class CompanyEvent private int $id; /** - * @ManyToOne(targetEntity="CompanyOrganization", inversedBy="events", cascade={"persist"}) - * @JoinColumn(name="org_id", referencedColumnName="id") - */ - private ?CompanyOrganization $organization = null; + * @ManyToOne(targetEntity="CompanyOrganization", inversedBy="events", cascade={"persist"}) + * @JoinColumn(name="org_id", referencedColumnName="id") + */ + private ?CompanyOrganization $organization = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php index fd8b1a3f1e8..697bfda3539 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php @@ -15,9 +15,7 @@ #[ORM\Entity] class CompanyFixContract extends CompanyContract { - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ private int $fixPrice = 0; public function calculatePrice(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index a054b4f1f42..056959df1e5 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -61,14 +61,10 @@ class CompanyFlexContract extends CompanyContract */ public $id; - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ private int $hoursWorked = 0; - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ private int $pricePerHour = 0; /** diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php index f655a483094..cdd5d0e5028 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -21,9 +21,7 @@ #[ORM\EntityListeners(['CompanyContractListener', 'CompanyFlexUltraContractListener'])] class CompanyFlexUltraContract extends CompanyFlexContract { - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ private int $maxPrice = 0; public function calculatePrice(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/tests/Doctrine/Tests/Models/Company/CompanyManager.php index ba45a5be73e..40534fb6430 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyManager.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyManager.php @@ -18,9 +18,7 @@ */ class CompanyManager extends CompanyEmployee { - /** - * @Column(type="string", length=250) - */ + /** @Column(type="string", length=250) */ private ?string $title = null; /** diff --git a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php index 37d64a8d3a6..82156845878 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php @@ -61,16 +61,14 @@ class CompanyPerson */ private int $id; - /** - * @Column - */ + /** @Column */ private ?string $name = null; /** * @OneToOne(targetEntity="CompanyPerson") * @JoinColumn(name="spouse_id", referencedColumnName="id", onDelete="CASCADE") */ - private ?\Doctrine\Tests\Models\Company\CompanyPerson $spouse = null; + private ?CompanyPerson $spouse = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php index 20893eabbea..2beabff4277 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php @@ -14,9 +14,7 @@ */ class CompanyRaffle extends CompanyEvent { - /** - * @Column - */ + /** @Column */ private ?string $data = null; public function setData(string $data): void diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php index 046460b3d8f..698d3bf3eca 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php @@ -27,7 +27,6 @@ public function __construct( * @ManyToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent", inversedBy="children") */ public CustomIdObjectTypeParent $parent - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php index 270c9a0c3c1..466fd2454cb 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php @@ -25,12 +25,13 @@ class CustomIdObjectTypeParent */ public $children; - public function __construct(/** - * @Id - * @Column(type="CustomIdObject", length=255) - */ - public CustomIdObject $id) - { + public function __construct( + /** + * @Id + * @Column(type="CustomIdObject", length=255) + */ + public CustomIdObject $id + ) { $this->children = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php index eea09467ad5..b03eff8e092 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php @@ -46,8 +46,7 @@ public function __construct( * }) */ private DDC117Translation $translation - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php index bb82d99dc6d..56726e98756 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php @@ -31,9 +31,7 @@ class DDC117Article */ private $references; - /** - * @OneToOne(targetEntity="DDC117ArticleDetails", mappedBy="article", cascade={"persist", "remove"}) - */ + /** @OneToOne(targetEntity="DDC117ArticleDetails", mappedBy="article", cascade={"persist", "remove"}) */ private ?DDC117ArticleDetails $details = null; /** @@ -48,11 +46,12 @@ class DDC117Article */ private Collection $links; - public function __construct(/** - * @Column - */ - private string $title) - { + public function __construct( + /** + * @Column + */ + private string $title + ) { $this->references = new ArrayCollection(); $this->translations = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php index 1cd950e0e34..0e9b1c78e10 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php @@ -15,19 +15,19 @@ */ class DDC117ArticleDetails { - /** - * @Column(type="text") - */ + /** @Column(type="text") */ private string $text; - public function __construct(/** - * @var DDC117Article - * @Id - * @OneToOne(targetEntity="DDC117Article", inversedBy="details") - * @JoinColumn(name="article_id", referencedColumnName="article_id") - */ - private $article, string $text) - { + public function __construct( + /** + * @var DDC117Article + * @Id + * @OneToOne(targetEntity="DDC117Article", inversedBy="details") + * @JoinColumn(name="article_id", referencedColumnName="article_id") + */ + private $article, + string $text + ) { $article->setDetails($this); $this->update($text); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php index 4db9f284ffb..2bf51a2f873 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php @@ -54,11 +54,12 @@ class DDC117Editor */ public $lastTranslation; - public function __construct(/** - * @Column(type="string", length=255) - */ - public ?string $name = '') - { + public function __construct( + /** + * @Column(type="string", length=255) + */ + public ?string $name = '' + ) { $this->reviewingTranslations = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php index 200a3294ac1..976825ef54a 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php @@ -16,25 +16,20 @@ */ class DDC117Link { - /** - * @param DDC117Article $source - * @param DDC117Article $target - */ public function __construct( /** * @Id * @ManyToOne(targetEntity="DDC117Article", inversedBy="links") * @JoinColumn(name="source_id", referencedColumnName="article_id") */ - public $source, + public DDC117Article $source, /** * @Id * @ManyToOne(targetEntity="DDC117Article") * @JoinColumn(name="target_id", referencedColumnName="article_id") */ - public $target, + public DDC117Article $target, $description - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php index 502dc1b81e0..cd0ba64980d 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php @@ -32,22 +32,23 @@ class DDC117Reference */ private $target; - /** - * @Column(type="datetime") - */ - private \DateTime $created; + /** @Column(type="datetime") */ + private DateTime $created; - public function __construct(DDC117Article $source, DDC117Article $target, /** - * @Column(type="string", length=255) - */ - private string $description) - { + public function __construct( + DDC117Article $source, + DDC117Article $target, + /** + * @Column(type="string", length=255) + */ + private string $description + ) { $source->addReference($this); $target->addReference($this); - $this->source = $source; - $this->target = $target; - $this->created = new DateTime('now'); + $this->source = $source; + $this->target = $target; + $this->created = new DateTime('now'); } public function source(): DDC117Article diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php index b4d4d8e914b..d3d909047a6 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php @@ -31,21 +31,24 @@ class DDC117Translation */ public $lastTranslatedBy; - public function __construct(/** - * @var DDC117Article - * @Id - * @ManyToOne(targetEntity="DDC117Article", inversedBy="translations") - * @JoinColumn(name="article_id", referencedColumnName="article_id") - */ - private $article, /** - * @Id - * @Column(type="string", length=255) - */ - private string $language, /** - * @Column(type="string", length=255) - */ - private string $title) - { + public function __construct( + /** + * @var DDC117Article + * @Id + * @ManyToOne(targetEntity="DDC117Article", inversedBy="translations") + * @JoinColumn(name="article_id", referencedColumnName="article_id") + */ + private $article, + /** + * @Id + * @Column(type="string", length=255) + */ + private string $language, + /** + * @Column(type="string", length=255) + */ + private string $title + ) { $this->reviewedByEditors = new ArrayCollection(); $this->lastTranslatedBy = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php index 52b5d35cbc3..0229b9c9687 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php @@ -24,9 +24,7 @@ class DDC2372Address */ private int $id; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $street = null; /** diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php index e640bd7c061..961b15e5249 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php @@ -26,9 +26,7 @@ class DDC2372User */ private int $id; - /** - * @Column(type="string", length=50) - */ + /** @Column(type="string", length=50) */ private ?string $name = null; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php index 808462793c1..04af9f4175e 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php @@ -33,11 +33,12 @@ class DDC3579Group #[ManyToMany(targetEntity: DDC3579Admin::class, mappedBy: 'groups')] private $admins; - public function __construct(/** - * @Column - */ - #[Column] private ?string $name = null) - { + public function __construct( + /** + * @Column + */ + #[Column] private ?string $name = null + ) { $this->admins = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php index 46beb2dbe72..e53f009df60 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php @@ -34,11 +34,12 @@ class DDC3579User #[ManyToMany(targetEntity: DDC3579Group::class)] protected $groups; - public function __construct(/** - * @Column(name="user_name", nullable=true, unique=false, length=250) - */ - #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected ?string $name = null) - { + public function __construct( + /** + * @Column(name="user_name", nullable=true, unique=false, length=250) + */ + #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected ?string $name = null + ) { $this->groups = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php index 1ff4fcbf1da..6df59005710 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php @@ -15,9 +15,7 @@ */ class DDC3597Image extends DDC3597Media { - /** - * @Embedded(class = "Doctrine\Tests\Models\DDC3597\Embeddable\DDC3597Dimension", columnPrefix = false) - */ + /** @Embedded(class = "Doctrine\Tests\Models\DDC3597\Embeddable\DDC3597Dimension", columnPrefix = false) */ private DDC3597Dimension $dimension; public function __construct(string $distributionHash) diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php index 9c571cd642f..05503872c83 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php @@ -14,26 +14,18 @@ */ abstract class DDC3597Media extends DDC3597Root { - /** - * @Column - */ + /** @Column */ private int $size = 0; - /** - * @Column - */ + /** @Column */ private ?string $format = null; - /** - * @param string $distributionHash - */ public function __construct( /** * @Column */ - private $distributionHash - ) - { + private string $distributionHash + ) { } public function getDistributionHash(): string diff --git a/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php b/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php index 76484786138..680a98982f5 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php +++ b/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php @@ -14,14 +14,10 @@ */ class DDC3597Dimension { - /** - * @Column(type="integer", name="width") - */ + /** @Column(type="integer", name="width") */ private int $width; - /** - * @Column(type="integer", name="height") - */ + /** @Column(type="integer", name="height") */ private int $height; public function __construct($width = 0, $height = 0) diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php index 248f905b95b..5c027ed0192 100644 --- a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php +++ b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php @@ -12,8 +12,6 @@ */ class DDC4006User { - /** - * @Embedded(class="DDC4006UserId") - */ + /** @Embedded(class="DDC4006UserId") */ private DDC4006UserId $id; } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php index a1b8fa2b726..bd847bef934 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php @@ -38,8 +38,7 @@ public function __construct( * @Column */ private ?string $street = null - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php index bf76c006d7b..07f1a946b64 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php @@ -29,14 +29,12 @@ class DDC964Group */ private $users; - /** - * @param string|null $name - */ - public function __construct(/** - * @Column - */ - private ?string $name = null) - { + public function __construct( + /** + * @Column + */ + private ?string $name = null + ) { $this->users = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php index 3a41af3925a..291f965f42b 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php @@ -55,11 +55,12 @@ class DDC964User #[JoinColumn(name: 'address_id', referencedColumnName: 'id')] protected $address; - public function __construct(/** - * @Column(name="user_name", nullable=true, unique=false, length=250) - */ - #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected ?string $name = null) - { + public function __construct( + /** + * @Column(name="user_name", nullable=true, unique=false, length=250) + */ + #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected ?string $name = null + ) { $this->groups = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php index 2f4b664bbc8..cc15e2edc17 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php @@ -45,8 +45,7 @@ public function __construct( * @ManyToOne(targetEntity="Directory") */ protected ?Directory $parentDirectory = null - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php index 25b442d3943..823a75586f1 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php @@ -32,9 +32,7 @@ class ECommerceCart */ private int $id; - /** - * @Column(length=50, nullable=true) - */ + /** @Column(length=50, nullable=true) */ private ?string $payment = null; /** diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php index ad8538ead17..20d9487c976 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php @@ -32,9 +32,7 @@ class ECommerceCategory */ private int $id; - /** - * @Column(type="string", length=50) - */ + /** @Column(type="string", length=50) */ private ?string $name = null; /** @@ -53,7 +51,7 @@ class ECommerceCategory * @ManyToOne(targetEntity="ECommerceCategory", inversedBy="children") * @JoinColumn(name="parent_id", referencedColumnName="id") */ - private ?\Doctrine\Tests\Models\ECommerce\ECommerceCategory $parent = null; + private ?ECommerceCategory $parent = null; public function __construct() { diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php index 14031d8cf03..15cb7c4cfa5 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php @@ -28,14 +28,10 @@ class ECommerceCustomer */ private int $id; - /** - * @Column(type="string", length=50) - */ + /** @Column(type="string", length=50) */ private ?string $name = null; - /** - * @OneToOne(targetEntity="ECommerceCart", mappedBy="customer", cascade={"persist"}) - */ + /** @OneToOne(targetEntity="ECommerceCart", mappedBy="customer", cascade={"persist"}) */ private ?ECommerceCart $cart = null; /** @@ -46,7 +42,7 @@ class ECommerceCustomer * @OneToOne(targetEntity="ECommerceCustomer", cascade={"persist"}, fetch="EAGER") * @JoinColumn(name="mentor_id", referencedColumnName="id") */ - private ?\Doctrine\Tests\Models\ECommerce\ECommerceCustomer $mentor = null; + private ?ECommerceCustomer $mentor = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php index 454d177e642..a9b3873678d 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php @@ -27,9 +27,7 @@ class ECommerceFeature */ private int $id; - /** - * @Column(length=50) - */ + /** @Column(length=50) */ private ?string $description = null; /** diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php index d697776c186..be203cddefe 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php @@ -34,9 +34,7 @@ class ECommerceProduct */ private int $id; - /** - * @Column(type="string", length=50, nullable=true) - */ + /** @Column(type="string", length=50, nullable=true) */ private ?string $name = null; /** diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php index 371668bccda..45b0b82a995 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php @@ -26,9 +26,7 @@ class ECommerceShipping */ private int $id; - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ private int|string|null $days = null; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php index 591fa909a87..1585a84e506 100644 --- a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php +++ b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php @@ -29,7 +29,6 @@ public function __construct( * @Column(type="string", length=255, name="`simple-entity-value`") */ public string $value - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php index 1ace996d3f4..27273de8b4c 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php @@ -46,7 +46,6 @@ public function __construct( * @Cache */ public Country $country - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php index 9e56ab0ef0b..c70597a9ec7 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php @@ -41,7 +41,6 @@ public function __construct( * @Cache */ public Admin1 $admin1 - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/City.php b/tests/Doctrine/Tests/Models/GeoNames/City.php index d7557fe0a89..1ca55e7d279 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/City.php +++ b/tests/Doctrine/Tests/Models/GeoNames/City.php @@ -51,7 +51,6 @@ public function __construct( * @Column(type="string", length=255); */ public string $name - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Country.php b/tests/Doctrine/Tests/Models/GeoNames/Country.php index 4f038d47590..871fec6a4e2 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Country.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Country.php @@ -18,22 +18,17 @@ */ class Country { - /** - * @param string $id - * @param string $name - */ public function __construct( /** * @Id * @Column(type="string", length=2) * @GeneratedValue(strategy="NONE") */ - public $id, + public string $id, /** * @Column(type="string", length=255); */ - public $name - ) - { + public string $name + ) { } } diff --git a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php b/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php index a42be8dbb5e..345318649d7 100644 --- a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php +++ b/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php @@ -69,13 +69,9 @@ class DoctrineGlobalUser */ private int $id; - /** - * @Column(type="string", length=64) - */ + /** @Column(type="string", length=64) */ private string $username; - /** - * @Column(type="string", length=128) - */ + /** @Column(type="string", length=128) */ private string $email; } diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php b/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php index 3a232805176..ab54b759896 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php @@ -32,22 +32,23 @@ class LegacyUserReference */ private LegacyUser $_target; - /** - * @Column(type="datetime", name="created") - */ - private \DateTime $created; + /** @Column(type="datetime", name="created") */ + private DateTime $created; - public function __construct(LegacyUser $source, LegacyUser $target, /** - * @Column(type="string", length=255, name="description") - */ - private string $_description) - { + public function __construct( + LegacyUser $source, + LegacyUser $target, + /** + * @Column(type="string", length=255, name="description") + */ + private string $_description + ) { $source->addReference($this); $target->addReference($this); - $this->_source = $source; - $this->_target = $target; - $this->created = new DateTime('now'); + $this->_source = $source; + $this->_target = $target; + $this->created = new DateTime('now'); } public function source(): LegacyUser diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php index 2058e397a7a..14ccdc6a14a 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php @@ -36,17 +36,19 @@ class ChildClass */ public $parents; - public function __construct(/** - * @Id - * @Column(name="id1", type="integer") - */ - public int $id1, /** - * @Id - * @ManyToOne(targetEntity=OtherParentClass::class, cascade={"persist"}) - * @JoinColumn(name="other_parent_id", referencedColumnName="id") - */ - public OtherParentClass $otherParent) - { - $this->parents = new ArrayCollection(); + public function __construct( + /** + * @Id + * @Column(name="id1", type="integer") + */ + public int $id1, + /** + * @Id + * @ManyToOne(targetEntity=OtherParentClass::class, cascade={"persist"}) + * @JoinColumn(name="other_parent_id", referencedColumnName="id") + */ + public OtherParentClass $otherParent + ) { + $this->parents = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php index 79247bfaa11..98d34382b03 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php @@ -21,7 +21,6 @@ public function __construct( * @Column(name="id", type="integer") */ public int $id - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php index 64f1324a3ac..3ad07f298da 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php @@ -25,12 +25,13 @@ class ParentClass */ public $children; - public function __construct(/** - * @Id - * @Column(name="id", type="integer") - */ - public int $id) - { + public function __construct( + /** + * @Id + * @Column(name="id", type="integer") + */ + public int $id + ) { $this->children = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php index d4afbebc8e0..0ebac14188a 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php @@ -36,8 +36,7 @@ public function __construct( * @Column(type="string", length=255) */ private string $name - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php index 4ef27a368cc..c2667d518f8 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php @@ -39,8 +39,7 @@ public function __construct( * @Column(type="string", length=255, name="file_name") */ private string $file - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php index 5ce4ef51deb..33c7c52a252 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php @@ -34,22 +34,26 @@ class NavPointOfInterest */ private $visitors; - public function __construct(/** - * @Id - * @Column(type="integer", name="nav_lat") - */ - private int $lat, /** - * @Id - * @Column(type="integer", name="nav_long") - */ - private int $long, /** - * @Column(type="string", length=255) - */ - private string $name, /** - * @ManyToOne(targetEntity="NavCountry", inversedBy="pois") - */ - private NavCountry $country) - { + public function __construct( + /** + * @Id + * @Column(type="integer", name="nav_lat") + */ + private int $lat, + /** + * @Id + * @Column(type="integer", name="nav_long") + */ + private int $long, + /** + * @Column(type="string", length=255) + */ + private string $name, + /** + * @ManyToOne(targetEntity="NavCountry", inversedBy="pois") + */ + private NavCountry $country + ) { $this->visitors = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavTour.php b/tests/Doctrine/Tests/Models/Navigation/NavTour.php index c3ac1662584..3181ca7d2e4 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavTour.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavTour.php @@ -41,11 +41,12 @@ class NavTour */ private Collection $pois; - public function __construct(/** - * @Column(type="string", length=255) - */ - private string $name) - { + public function __construct( + /** + * @Column(type="string", length=255) + */ + private string $name + ) { $this->pois = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavUser.php b/tests/Doctrine/Tests/Models/Navigation/NavUser.php index ed8d7a60420..0b228faabc5 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavUser.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavUser.php @@ -28,7 +28,6 @@ public function __construct( * @Column(type="string", length=255) */ private string $name - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/Quote/City.php b/tests/Doctrine/Tests/Models/Quote/City.php index 37887481497..3a31b1f247f 100644 --- a/tests/Doctrine/Tests/Models/Quote/City.php +++ b/tests/Doctrine/Tests/Models/Quote/City.php @@ -29,7 +29,6 @@ public function __construct( * @Column(name="`city-name`") */ public string $name - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/Quote/Group.php b/tests/Doctrine/Tests/Models/Quote/Group.php index e09de1d1e46..b19063242a5 100644 --- a/tests/Doctrine/Tests/Models/Quote/Group.php +++ b/tests/Doctrine/Tests/Models/Quote/Group.php @@ -43,8 +43,7 @@ public function __construct( * @ManyToOne(targetEntity="Group", cascade={"persist"}) * @JoinColumn(name="`parent-id`", referencedColumnName="`group-id`") */ - public ?\Doctrine\Tests\Models\Quote\Group $parent = null - ) - { + public ?Group $parent = null + ) { } } diff --git a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php index c32e5b4a3e7..bbb2804b0f5 100644 --- a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php +++ b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php @@ -29,7 +29,6 @@ public function __construct( * @Column(type="string", length=255, name="`2:2`") */ public string $value - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/tests/Doctrine/Tests/Models/StockExchange/Bond.php index 28963ced076..20825007941 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Bond.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Bond.php @@ -40,8 +40,7 @@ public function __construct( * @Column(type="string", length=255) */ private string $name - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/Models/StockExchange/Market.php b/tests/Doctrine/Tests/Models/StockExchange/Market.php index ceb6d5a3093..26dbf8143bc 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Market.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Market.php @@ -31,11 +31,12 @@ class Market */ public $stocks; - public function __construct(/** - * @Column(type="string", length=255) - */ - private string $name) - { + public function __construct( + /** + * @Column(type="string", length=255) + */ + private string $name + ) { $this->stocks = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/StockExchange/Stock.php b/tests/Doctrine/Tests/Models/StockExchange/Stock.php index a7e17bc21e1..6c9c0b75594 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Stock.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Stock.php @@ -24,18 +24,22 @@ class Stock */ private int $id; - public function __construct(/** - * For real this column would have to be unique=true. But I want to test behavior of non-unique overrides. - * @Column(type="string", length=255) - */ - private string $symbol, /** - * @Column(type="decimal") - */ - private float $price, /** - * @ManyToOne(targetEntity="Market", inversedBy="stocks") - */ - private Market $market) - { + public function __construct( + /** + * For real this column would have to be unique=true. But I want to test behavior of non-unique overrides. + * + * @Column(type="string", length=255) + */ + private string $symbol, + /** + * @Column(type="decimal") + */ + private float $price, + /** + * @ManyToOne(targetEntity="Market", inversedBy="stocks") + */ + private Market $market + ) { $market->addStock($this); } diff --git a/tests/Doctrine/Tests/Models/Taxi/Car.php b/tests/Doctrine/Tests/Models/Taxi/Car.php index 62ae8419d99..49bd1de0407 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Car.php +++ b/tests/Doctrine/Tests/Models/Taxi/Car.php @@ -25,9 +25,7 @@ class Car */ private ?string $brand = null; - /** - * @Column(type="string", length=255); - */ + /** @Column(type="string", length=255); */ private ?string $model = null; /** diff --git a/tests/Doctrine/Tests/Models/Taxi/Driver.php b/tests/Doctrine/Tests/Models/Taxi/Driver.php index d900acd8706..5ce14d4fc48 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Driver.php +++ b/tests/Doctrine/Tests/Models/Taxi/Driver.php @@ -25,9 +25,7 @@ class Driver */ private int $id; - /** - * @Column(type="string", length=255); - */ + /** @Column(type="string", length=255); */ private ?string $name = null; /** diff --git a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php index 81b0ea9f276..6b2137352f8 100644 --- a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php +++ b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php @@ -38,8 +38,7 @@ public function __construct( * @JoinColumn(name="car", referencedColumnName="brand") */ private Car $car - ) - { + ) { } public function setFare($fare): void diff --git a/tests/Doctrine/Tests/Models/Taxi/Ride.php b/tests/Doctrine/Tests/Models/Taxi/Ride.php index 50767cae4d4..127ae45272f 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Ride.php +++ b/tests/Doctrine/Tests/Models/Taxi/Ride.php @@ -31,7 +31,6 @@ public function __construct( * @JoinColumn(name="car", referencedColumnName="brand") */ private Car $car - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index b4fc3ff00e8..579187794be 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -4,14 +4,14 @@ namespace Doctrine\Tests\ORM\Cache; -use Doctrine\ORM\Cache\Region; -use Doctrine\ORM\Cache\QueryCache; use Doctrine\ORM\Cache; use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\DefaultCache; use Doctrine\ORM\Cache\EntityCacheEntry; use Doctrine\ORM\Cache\EntityCacheKey; +use Doctrine\ORM\Cache\QueryCache; +use Doctrine\ORM\Cache\Region; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 8df12142ba3..57a4c28aef6 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -4,9 +4,9 @@ namespace Doctrine\Tests\ORM\Cache; -use Doctrine\ORM\Cache\DefaultCacheFactory; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Cache; +use Doctrine\ORM\Cache\DefaultCacheFactory; use Doctrine\ORM\Cache\DefaultQueryCache; use Doctrine\ORM\Cache\EntityCacheEntry; use Doctrine\ORM\Cache\EntityCacheKey; diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index 46cd848df4a..9dc2b687e10 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -255,7 +255,7 @@ public function testHandlesScanErrorsGracefullyOnEvictAll(): void $reflectionDirectory->setAccessible(true); $reflectionDirectory->setValue($region, str_repeat('a', 10000)); - set_error_handler(static fn(): bool => true, E_WARNING); + set_error_handler(static fn (): bool => true, E_WARNING); try { self::assertTrue($region->evictAll()); } finally { diff --git a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php index e8490765a47..e382bb5aca1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php @@ -53,6 +53,6 @@ protected function countForeignKeys($firstId, $secondId): int public function assertCollectionEquals(Collection $first, Collection $second): bool { - return $first->forAll(static fn($k, $e): bool => $second->contains($e)); + return $first->forAll(static fn ($k, $e): bool => $second->contains($e)); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php index 4a9e9cc00e5..70b05e4e7c7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -163,14 +163,10 @@ class Lemma */ private int $id; - /** - * @Column(type="string", name="lemma_name", unique=true, length=255) - */ + /** @Column(type="string", name="lemma_name", unique=true, length=255) */ private ?string $lemma = null; - /** - * @ManyToMany(targetEntity="Type", mappedBy="lemmas", cascade={"persist"}) - */ + /** @ManyToMany(targetEntity="Type", mappedBy="lemmas", cascade={"persist"}) */ private Collection $types; public function __construct() @@ -230,14 +226,10 @@ class Type */ private int $id; - /** - * @Column(type="string", name="type_name", unique=true) - */ + /** @Column(type="string", name="type_name", unique=true) */ private ?string $type = null; - /** - * @Column(type="string", name="type_abbreviation", unique=true) - */ + /** @Column(type="string", name="type_abbreviation", unique=true) */ private ?string $abbreviation = null; /** @@ -317,16 +309,14 @@ class Phrase */ private int $id; - /** - * @Column(type="string", name="phrase_name", unique=true, length=255) - */ + /** @Column(type="string", name="phrase_name", unique=true, length=255) */ private ?string $phrase = null; /** * @ManyToOne(targetEntity="PhraseType") * @JoinColumn(name="phrase_type_id", referencedColumnName="phrase_type_id") */ - private ?\Doctrine\Tests\ORM\Functional\PhraseType $type = null; + private ?PhraseType $type = null; /** * @psalm-var Collection @@ -391,14 +381,10 @@ class PhraseType */ private int $id; - /** - * @Column(type="string", name="phrase_type_name", unique=true) - */ + /** @Column(type="string", name="phrase_type_name", unique=true) */ private ?string $type = null; - /** - * @Column(type="string", name="phrase_type_abbreviation", unique=true) - */ + /** @Column(type="string", name="phrase_type_abbreviation", unique=true) */ private ?string $abbreviation = null; /** @@ -467,11 +453,9 @@ class Definition * @ManyToOne(targetEntity="Phrase") * @JoinColumn(name="definition_phrase_id", referencedColumnName="phrase_id") */ - private ?\Doctrine\Tests\ORM\Functional\Phrase $phrase = null; + private ?Phrase $phrase = null; - /** - * @Column(type="text", name="definition_text") - */ + /** @Column(type="text", name="definition_text") */ private ?string $definition = null; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index f6ee94ff41a..1141dbbfc57 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -20,8 +20,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use InvalidArgumentException; -use function get_class; - class BasicFunctionalTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php index 05c1367563b..a1369f1d091 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php @@ -87,7 +87,7 @@ class CascadeRemoveOrderEntityO * @OneToOne(targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG") * @JoinColumn(nullable=true, onDelete="SET NULL") */ - private ?\Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG $oneToOneG = null; + private ?CascadeRemoveOrderEntityG $oneToOneG = null; /** * @psalm-var Collection @@ -145,17 +145,16 @@ class CascadeRemoveOrderEntityG */ private int $id; - /** - * @param int $position - */ - public function __construct(/** - * @ManyToOne( - * targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityO", - * inversedBy="oneToMany" - * ) - */ - private CascadeRemoveOrderEntityO $ownerO, private $position = 1) - { + public function __construct( + /** + * @ManyToOne( + * targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityO", + * inversedBy="oneToMany" + * ) + */ + private CascadeRemoveOrderEntityO $ownerO, + private int $position = 1 + ) { $this->ownerO->addOneToManyG($this); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php index 541fb11cd60..ffd472e5198 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php @@ -20,7 +20,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function count; -use function get_class; /** * Functional tests for the Class Table Inheritance mapping strategy. @@ -100,10 +99,8 @@ class CTIParent */ private int $id; - /** - * @OneToOne(targetEntity="CTIRelated", mappedBy="ctiParent") - */ - private ?\Doctrine\Tests\ORM\Functional\CTIRelated $related = null; + /** @OneToOne(targetEntity="CTIRelated", mappedBy="ctiParent") */ + private ?CTIRelated $related = null; public function getId(): int { @@ -128,9 +125,7 @@ public function setRelated(CTIRelated $related): void */ class CTIChild extends CTIParent { - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $data = null; public function getData(): string @@ -158,7 +153,7 @@ class CTIRelated * @OneToOne(targetEntity="CTIParent") * @JoinColumn(name="ctiparent_id", referencedColumnName="id") */ - private ?\Doctrine\Tests\ORM\Functional\CTIParent $ctiParent = null; + private ?CTIParent $ctiParent = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index dcd5de24b67..f1deeebd316 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -18,7 +18,6 @@ use Doctrine\Tests\Models\Company\CompanyRaffle; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; use function get_debug_type; use function sprintf; diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php index f2e191ba52b..c3d59a43f25 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Query\AST\AggregateExpression; -use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\PathExpression; use Doctrine\ORM\Query\Lexer; @@ -34,8 +33,8 @@ public function testCustomFunctionDefinedWithCallback(): void $this->_em->flush(); // Instead of defining the function with the class name, we use a callback - $this->_em->getConfiguration()->addCustomStringFunction('FOO', static fn($funcName) => new NoOp($funcName)); - $this->_em->getConfiguration()->addCustomNumericFunction('BAR', static fn($funcName) => new NoOp($funcName)); + $this->_em->getConfiguration()->addCustomStringFunction('FOO', static fn ($funcName) => new NoOp($funcName)); + $this->_em->getConfiguration()->addCustomNumericFunction('BAR', static fn ($funcName) => new NoOp($funcName)); $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u' . ' WHERE FOO(u.name) = \'Bob\'' diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index 1ca9fdc7d6f..5899aeefe0c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -13,8 +13,6 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * Tests basic operations on entities with default values. */ diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 9a19c3d7dbd..6e4ffb4b47e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Query\ResultSetMappingBuilder; use BadMethodCallException; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; @@ -16,7 +15,7 @@ use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\Persisters\Exception\InvalidOrientation; use Doctrine\ORM\Persisters\Exception\UnrecognizedField; -use Doctrine\ORM\Query; +use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\ORM\Repository\Exception\InvalidFindByCall; use Doctrine\ORM\Repository\Exception\InvalidMagicMethodCall; use Doctrine\ORM\TransactionRequiredException; diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php index b6fd2e809b8..0d90c578a96 100644 --- a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -10,8 +10,6 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * FlushEventTest */ diff --git a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php index 86cf8531426..e0149e85105 100644 --- a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php @@ -118,6 +118,6 @@ class GH5988CustomIdObjectTypeChild extends GH5988CustomIdObjectTypeParent { public function __construct(CustomIdObject $id, public string $name) { - $this->id = $id; + $this->id = $id; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php index 131ee133f77..113604fa6f1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php @@ -10,8 +10,6 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * IdentityMapTest * diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index d20db704b5d..eac58462cee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -32,7 +32,6 @@ use function count; use function current; -use function get_class; use function iterator_to_array; use function sprintf; @@ -415,14 +414,10 @@ class LifecycleCallbackTestUser */ private int $id; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $value = null; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $name = null; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php index 490eb3fa6ff..482c769eec5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php @@ -18,7 +18,7 @@ */ class GearmanLockTest extends OrmFunctionalTestCase { - private ?\GearmanClient $gearman = null; + private ?GearmanClient $gearman = null; private int $maxRunTime = 0; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php index c4cc8f35047..9024466d9f0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\ORM\Functional\Locking; -use Doctrine\Tests\ORM\Functional\Locking\Doctrine\ORM\Query; use Closure; use Doctrine\DBAL\Connection; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\ORMSetup; +use Doctrine\Tests\ORM\Functional\Locking\Doctrine\ORM\Query; use GearmanWorker; use InvalidArgumentException; use Symfony\Component\Cache\Adapter\ArrayAdapter; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index 006fb454b24..072d2f6fb17 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -214,7 +214,7 @@ public function testOptimisticTimestampSetsDefaultValue(): OptimisticTimestamp $this->_em->persist($test); $this->_em->flush(); - self::assertInstanceOf(\DateTime::class, $test->version); + self::assertInstanceOf(DateTime::class, $test->version); return $test; } @@ -230,7 +230,7 @@ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestam $test = $q->getSingleResult(); - self::assertInstanceOf(\DateTime::class, $test->version); + self::assertInstanceOf(DateTime::class, $test->version); // Manually increment the version datetime column $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); @@ -262,7 +262,7 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime $test = $q->getSingleResult(); - self::assertInstanceOf(\DateTime::class, $test->version); + self::assertInstanceOf(DateTime::class, $test->version); // Try to lock the record with an older timestamp and it should throw an exception $caughtException = null; diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php index 7fcf5bea47f..30c2bc33be6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -14,7 +14,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function assert; -use function get_class; /** * Basic many-to-many association tests. @@ -407,7 +406,7 @@ public function testManyToManyOrderByIsNotIgnored(): void $user ->getGroups() ->matching($criteria) - ->map(static fn(CmsGroup $group) => $group->getName()) + ->map(static fn (CmsGroup $group) => $group->getName()) ->toArray() ); } @@ -449,7 +448,7 @@ public function testManyToManyOrderByHonorsFieldNameColumnNameAliases(): void $user ->getTags() ->matching($criteria) - ->map(static fn(CmsTag $tag) => $tag->getName()) + ->map(static fn (CmsTag $tag) => $tag->getName()) ->toArray() ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php index 775d0c4c01b..022906b48e0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php @@ -14,7 +14,7 @@ */ class ManyToManyEventTest extends OrmFunctionalTestCase { - private \Doctrine\Tests\ORM\Functional\PostUpdateListener $listener; + private PostUpdateListener $listener; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php index 8e56d4d0d70..b4ee12c298f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php @@ -9,8 +9,6 @@ use Doctrine\Tests\Models\DirectoryTree\File; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * MappedSuperclassTest */ diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 04fd120957a..8157eb30fc0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -338,7 +338,7 @@ public function testAbstractClassInSingleTableInheritanceSchemaWithRSMBuilderThr public function testRSMBuilderThrowsExceptionOnColumnConflict(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $rsm = new ResultSetMappingBuilder($this->_em); $rsm->addRootEntityFromClassMetadata(CmsUser::class, 'u'); $rsm->addJoinedEntityFromClassMetadata(CmsAddress::class, 'a', 'u', 'address'); diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php index a8a54679600..044542eede5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php @@ -4,8 +4,8 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query; +use Doctrine\ORM\Query\QueryException; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddressDTO; use Doctrine\Tests\Models\CMS\CmsEmail; diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index 7f56bf2929d..8d3b52a5610 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -130,9 +130,7 @@ class NotifyUser extends NotifyBaseEntity */ private int $id; - /** - * @Column - */ + /** @Column */ private ?string $name = null; /** @@ -181,9 +179,7 @@ class NotifyGroup extends NotifyBaseEntity */ private int $id; - /** - * @Column - */ + /** @Column */ private ?string $name = null; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index ec5cbb0733e..995867c67ce 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -17,8 +17,6 @@ use Doctrine\ORM\Proxy\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * @group DDC-952 */ @@ -316,16 +314,12 @@ class TrainDriver */ public $train; - /** - * @param string $name - */ public function __construct( /** * @Column(type="string", length=255) */ - public $name - ) - { + public string $name + ) { } public function setTrain(Train $t): void @@ -360,8 +354,7 @@ public function __construct( * @Column(type="string", length=255) */ public string $name - ) - { + ) { } public function setTrain(Train $t): void @@ -408,7 +401,6 @@ class TrainOrder */ public $id; - public function __construct( /** * @var Train diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index 654229314c5..f4ff04d3dc0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -15,8 +15,6 @@ use Doctrine\Tests\Models\ECommerce\ECommerceCustomer; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * Tests a self referential one-to-one association mapping (without inheritance). * Relation is defined as the mentor that a customer choose. The mentor could @@ -163,13 +161,13 @@ class MultiSelfReference * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) * @JoinColumn(name="other1", referencedColumnName="id") */ - private ?\Doctrine\Tests\ORM\Functional\MultiSelfReference $other1 = null; + private ?MultiSelfReference $other1 = null; /** * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) * @JoinColumn(name="other2", referencedColumnName="id") */ - private ?\Doctrine\Tests\ORM\Functional\MultiSelfReference $other2 = null; + private ?MultiSelfReference $other2 = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index ccc72f81b8c..527b7bf9109 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -10,8 +10,6 @@ use Doctrine\Tests\Models\ECommerce\ECommerceShipping; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * Tests a unidirectional one-to-one association mapping (without inheritance). * Inverse side is not present. diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index 8efca51826e..1aa0d4ccd42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -4,16 +4,16 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Query\SqlWalker; -use Doctrine\ORM\Query\TreeWalkerAdapter; -use Doctrine\ORM\Query\AST\SelectStatement; -use Doctrine\ORM\Query\AST\ConditionalPrimary; -use Doctrine\ORM\Query\AST\PathExpression; +use Doctrine\DBAL\Types\Type as DBALType; +use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST\ComparisonExpression; +use Doctrine\ORM\Query\AST\ConditionalPrimary; use Doctrine\ORM\Query\AST\Literal; +use Doctrine\ORM\Query\AST\PathExpression; +use Doctrine\ORM\Query\AST\SelectStatement; use Doctrine\ORM\Query\AST\WhereClause; -use Doctrine\DBAL\Types\Type as DBALType; -use Doctrine\ORM\Query; +use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TreeWalkerAdapter; use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\Tests\DbalTypes\CustomIdObject; use Doctrine\Tests\DbalTypes\CustomIdObjectType; diff --git a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php index 4cc6a623ef3..aede96e34be 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php @@ -15,7 +15,7 @@ */ class PostFlushEventTest extends OrmFunctionalTestCase { - private \Doctrine\Tests\ORM\Functional\PostFlushListener $listener; + private PostFlushListener $listener; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 01a1951ab24..8f21e62960b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -4,10 +4,10 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\NoResultException; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\NoResultException; use Doctrine\ORM\Proxy\Proxy; use Doctrine\ORM\Query; use Doctrine\ORM\Query\Parameter; diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 5ab92cba2ae..7472faded57 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -151,19 +151,17 @@ class ReadOnlyEntity public $id; /** - * @param string $name * @param int $number */ public function __construct( /** * @Column(type="string", length=255) */ - public $name, + public string $name, /** * @Column(type="integer") */ public $numericValue - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php index 0fa89e2cb93..e80bad46ac5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php @@ -13,7 +13,6 @@ use function assert; use function file_exists; -use function get_class; use function str_replace; use function strlen; use function substr; diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 2c3e3efb718..599e96b4d0b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -314,7 +314,7 @@ public function testSQLFilterSetArrayParameterInfersType(): void // Setup mock connection $conn = $this->getMockConnection(); $conn->method('quote') - ->will(self::returnCallback(static fn($value) => "'" . $value . "'")); + ->will(self::returnCallback(static fn ($value) => "'" . $value . "'")); $em = $this->getMockEntityManager(); $em->method('getConnection') diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 0f84bd6e050..0a49a3a791b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -4,12 +4,11 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Tools; +use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\OrmFunctionalTestCase; use function array_filter; @@ -39,7 +38,7 @@ public function testDefaultValueIsComparedCorrectly(): void $updateSql = $this->schemaTool->getUpdateSchemaSql([$class]); - $updateSql = array_filter($updateSql, static fn($sql) => str_contains($sql, 'DBAL483')); + $updateSql = array_filter($updateSql, static fn ($sql) => str_contains($sql, 'DBAL483')); self::assertCount(0, $updateSql); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index eea653c65d8..58c98da1a0f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -4,24 +4,22 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; +use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\ORM\Tools\SchemaTool; -use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsEmail; -use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\Company\CompanyAuction; +use Doctrine\Tests\Models\Company\CompanyCar; use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyEvent; use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\Models\Company\CompanyOrganization; -use Doctrine\Tests\Models\Company\CompanyEvent; -use Doctrine\Tests\Models\Company\CompanyAuction; +use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\Company\CompanyRaffle; -use Doctrine\Tests\Models\Company\CompanyCar; -use Doctrine\DBAL\Platforms\SqlitePlatform; -use Doctrine\ORM\Tools; -use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; use Exception; @@ -111,7 +109,7 @@ public function assertCreatedSchemaNeedsNoUpdates($classes): void $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); $sql = $schemaDiff->toSql($this->_em->getConnection()->getDatabasePlatform()); - $sql = array_filter($sql, static fn($sql) => ! str_contains($sql, 'DROP')); + $sql = array_filter($sql, static fn ($sql) => ! str_contains($sql, 'DROP')); self::assertCount(0, $sql, 'SQL: ' . implode(PHP_EOL, $sql)); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index a664d363697..9406c5a961d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -4,14 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; -use Doctrine\Tests\Models\CMS\CmsGroup; -use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\CMS\CmsTag; -use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsEmail; -use Doctrine\Tests\Models\CMS\CmsPhonenumber; -use Doctrine\Tests\Models\Generic\DecimalModel; -use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -19,7 +11,14 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Tools\SchemaTool; -use Doctrine\Tests\Models; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsEmail; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsTag; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\Generic\BooleanModel; +use Doctrine\Tests\Models\Generic\DecimalModel; use Doctrine\Tests\OrmFunctionalTestCase; class MySqlSchemaToolTest extends OrmFunctionalTestCase diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index 7b114b7a6e5..53c7c09dc54 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -4,11 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; -use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\CMS\CmsPhonenumber; -use Doctrine\Tests\Models\Generic\DecimalModel; -use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -18,7 +13,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Tools\SchemaTool; -use Doctrine\Tests\Models; +use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\OrmFunctionalTestCase; use function array_filter; @@ -58,7 +53,7 @@ public function testUpdateSchemaWithPostgreSQLSchema(): void $tool->createSchema($classes); $sql = $tool->getUpdateSchemaSql($classes); - $sql = array_filter($sql, static fn($sql) => str_starts_with($sql, 'DROP SEQUENCE stonewood.')); + $sql = array_filter($sql, static fn ($sql) => str_starts_with($sql, 'DROP SEQUENCE stonewood.')); self::assertCount(0, $sql, implode("\n", $sql)); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php index 5aa864086d7..ff6b06bf268 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php @@ -11,7 +11,6 @@ use Doctrine\Tests\Models\Cache\AttractionLocationInfo; use function count; -use function get_class; /** * @group DDC-2183 diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 616c1d3ac02..47a0e8567c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Cache\QueryCacheEntry; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Cache; use Doctrine\ORM\Cache\EntityCacheEntry; use Doctrine\ORM\Cache\EntityCacheKey; use Doctrine\ORM\Cache\Exception\CacheException; +use Doctrine\ORM\Cache\QueryCacheEntry; use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\ORM\Proxy\Proxy; use Doctrine\ORM\Query; diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php index ee1492b586e..5c10b4478bb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php @@ -12,7 +12,6 @@ use Doctrine\Tests\Models\Cache\Restaurant; use function count; -use function get_class; /** * @group DDC-2183 diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php index c987c54abd3..50aa74c0f5e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php @@ -340,8 +340,8 @@ public function testCachedNewEntityExists(): void class ListenerSecondLevelCacheTest { /** - * @psalm-param array $callbacks * @param array $callbacks + * @psalm-param array $callbacks */ public function __construct(public array $callbacks = []) { diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php index 07d13b6ea4c..3c5d178620c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php @@ -51,9 +51,7 @@ class SequenceEmulatedIdentityEntity */ private int $id; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $value = null; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php index 3fdeecd70f5..7e4a1afbd13 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -16,7 +16,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function array_map; -use function get_class; use function sort; class SingleTableInheritanceTest extends OrmFunctionalTestCase @@ -239,7 +238,7 @@ public function testQueryScalarWithDiscriminatorValue(): void $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c ORDER BY c.id')->getScalarResult(); - $discrValues = array_map(static fn($a) => $a['c_discr'], $contracts); + $discrValues = array_map(static fn ($a) => $a['c_discr'], $contracts); sort($discrValues); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php index e805faff06f..b79f3d1738f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -6,7 +6,6 @@ use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFlexContract; -use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index 2bcdfa500f4..0c856b3cf0a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -19,7 +19,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function assert; -use function get_class; /** * @group DDC-1163 @@ -122,10 +121,8 @@ class DDC1163ProxyHolder */ private int $id; - /** - * @OneToOne(targetEntity="DDC1163SpecialProduct") - */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1163SpecialProduct $specialProduct = null; + /** @OneToOne(targetEntity="DDC1163SpecialProduct") */ + private ?DDC1163SpecialProduct $specialProduct = null; public function getId(): int { @@ -170,9 +167,7 @@ public function getId(): int */ class DDC1163SpecialProduct extends DDC1163Product { - /** - * @Column(name="subclass_property", type="string", nullable=true) - */ + /** @Column(name="subclass_property", type="string", nullable=true) */ private ?string $subclassProperty = null; public function setSubclassProperty(string $value): void @@ -206,8 +201,7 @@ public function __construct( * @Column(name="name", type="string", length=255) */ private string $name - ) - { + ) { } public function setProduct(DDC1163Product $product): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php index d6dd01b0cc1..a34ccb1c1ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -18,7 +18,6 @@ use function assert; use function count; -use function get_class; /** * @group DDC-117 diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index eb0e4795f5f..6b6c0e58bc6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -11,8 +11,6 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - class DDC1193Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php index 65b080ac8dd..e69e824f6cb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use Stringable; class DDC1209Test extends OrmFunctionalTestCase { @@ -112,13 +113,14 @@ class DDC1209Two */ public $endingDatetime; - public function __construct(/** - * @Id - * @ManyToOne(targetEntity="DDC1209One") - * @JoinColumn(referencedColumnName="id", nullable=false) - */ - private DDC1209One $future1) - { + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="DDC1209One") + * @JoinColumn(referencedColumnName="id", nullable=false) + */ + private DDC1209One $future1 + ) { $this->startingDatetime = new DateTime2(); $this->duringDatetime = new DateTime2(); $this->endingDatetime = new DateTime2(); @@ -143,7 +145,7 @@ public function __construct() } } -class DateTime2 extends DateTime implements \Stringable +class DateTime2 extends DateTime implements Stringable { public function __toString(): string { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index 4fdb1aa03ac..4ff0840af45 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -57,7 +57,7 @@ class DDC1225TestEntity1 * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225TestEntity2") * @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false) */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1225TestEntity2 $testEntity2 = null; + private ?DDC1225TestEntity2 $testEntity2 = null; public function setTestEntity2(DDC1225TestEntity2 $testEntity2): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php index 5998a5ca6fc..d7e1845fa0a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -77,9 +77,7 @@ class DDC1238User */ private ?int $id = null; - /** - * @Column - */ + /** @Column */ private ?string $name = null; public function getId(): ?int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php index 87e04a11349..6485460372d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php @@ -4,12 +4,11 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Tests\Models\Legacy\LegacyUser; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\Models\Legacy\LegacyArticle; use Doctrine\Tests\Models\Legacy\LegacyCar; +use Doctrine\Tests\Models\Legacy\LegacyUser; use Doctrine\Tests\Models\Legacy\LegacyUserReference; -use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index b14d170cfa6..4c113882727 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -173,18 +173,17 @@ class DDC1335User */ public $phones; - /** - * @param string $email - * @param string $name - */ - public function __construct(/** - * @Column(type="string", length=255, unique=true) - */ - public $email, /** - * @Column(type="string", length=255) - */ - public $name, array $numbers = []) - { + public function __construct( + /** + * @Column(type="string", length=255, unique=true) + */ + public string $email, + /** + * @Column(type="string", length=255) + */ + public string $name, + array $numbers = [] + ) { $this->phones = new ArrayCollection(); foreach ($numbers as $number) { @@ -208,19 +207,17 @@ class DDC1335Phone /** * @param string $number - * @param \Doctrine\Tests\ORM\Functional\Ticket\DDC1335User $user */ public function __construct( /** * @ManyToOne(targetEntity="DDC1335User", inversedBy="phones") * @JoinColumn(name="user_id", referencedColumnName="id", nullable = false) */ - public $user, + public DDC1335User $user, /** * @Column(name="numericalValue", type="string", nullable = false) */ public $numericalValue - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index 437a15f6ff1..9be7d3dbd36 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -154,14 +154,10 @@ class DDC1430Order */ protected $id; - /** - * @Column(name="created_at", type="datetime") - */ - private \DateTime $date; + /** @Column(name="created_at", type="datetime") */ + private DateTime $date; - /** - * @OneToMany(targetEntity="DDC1430OrderProduct", mappedBy="order", cascade={"persist", "remove"}) - */ + /** @OneToMany(targetEntity="DDC1430OrderProduct", mappedBy="order", cascade={"persist", "remove"}) */ private Collection $products; public function getId(): int @@ -169,11 +165,12 @@ public function getId(): int return $this->id; } - public function __construct(/** - * @Column(name="order_status", type="string", length=255) - */ - private string $status) - { + public function __construct( + /** + * @Column(name="order_status", type="string", length=255) + */ + private string $status + ) { $this->date = new DateTime(); $this->products = new ArrayCollection(); } @@ -222,15 +219,14 @@ class DDC1430OrderProduct * @ManyToOne(targetEntity="DDC1430Order", inversedBy="products") * @JoinColumn(name="order_id", referencedColumnName="order_id", nullable = false) */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1430Order $order = null; + private ?DDC1430Order $order = null; public function __construct( /** * @Column(type="float") */ private float $value - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php index b5e4dda877f..d0cc7a74d7a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -14,7 +14,7 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Exception; -use function getrandmax; +use function mt_getrandmax; use function random_int; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index 8177d611e22..6bc2ebfea98 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -13,8 +13,6 @@ use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * @group DDC-1461 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php index 660fdd99573..e7967290e15 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php @@ -8,8 +8,6 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * @group DDC-1643 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index 4dd4c917ac0..370f0092e31 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -17,7 +17,6 @@ use Doctrine\ORM\Mapping\PostLoad; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; use function get_debug_type; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php index 934fae9149a..d7c80635d47 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php @@ -115,15 +115,11 @@ class DDC1690Parent extends NotifyBaseEntity */ private int $id; - /** - * @Column - */ + /** @Column */ private ?string $name = null; - /** - * @OneToOne(targetEntity="DDC1690Child") - */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1690Child $child = null; + /** @OneToOne(targetEntity="DDC1690Child") */ + private ?DDC1690Child $child = null; public function getId(): int { @@ -162,15 +158,11 @@ class DDC1690Child extends NotifyBaseEntity */ private int $id; - /** - * @Column - */ + /** @Column */ private ?string $name = null; - /** - * @OneToOne(targetEntity="DDC1690Parent", mappedBy="child") - */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC1690Parent $parent = null; + /** @OneToOne(targetEntity="DDC1690Parent", mappedBy="child") */ + private ?DDC1690Parent $parent = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php index 5bb110fc27a..c7435c78b55 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use DateTimeZone; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -46,88 +47,54 @@ class DDC1695News */ private int $idNews; - /** - * @Column(name="`IdUser`", type="bigint", nullable=false) - */ + /** @Column(name="`IdUser`", type="bigint", nullable=false) */ private int $idUser; - /** - * @Column(name="`IdLanguage`", type="integer", nullable=false) - */ + /** @Column(name="`IdLanguage`", type="integer", nullable=false) */ private int $idLanguage; - /** - * @Column(name="`IdCondition`", type="integer", nullable=true) - */ + /** @Column(name="`IdCondition`", type="integer", nullable=true) */ private int $idCondition; - /** - * @Column(name="`IdHealthProvider`", type="integer", nullable=true) - */ + /** @Column(name="`IdHealthProvider`", type="integer", nullable=true) */ private int $idHealthProvider; - /** - * @Column(name="`IdSpeciality`", type="integer", nullable=true) - */ + /** @Column(name="`IdSpeciality`", type="integer", nullable=true) */ private int $idSpeciality; - /** - * @Column(name="`IdMedicineType`", type="integer", nullable=true) - */ + /** @Column(name="`IdMedicineType`", type="integer", nullable=true) */ private int $idMedicineType; - /** - * @Column(name="`IdTreatment`", type="integer", nullable=true) - */ + /** @Column(name="`IdTreatment`", type="integer", nullable=true) */ private int $idTreatment; - /** - * @Column(name="`Title`", type="string", nullable=true) - */ + /** @Column(name="`Title`", type="string", nullable=true) */ private string $title; - /** - * @Column(name="`SmallText`", type="string", nullable=true) - */ + /** @Column(name="`SmallText`", type="string", nullable=true) */ private string $smallText; - /** - * @Column(name="`LongText`", type="string", nullable=true) - */ + /** @Column(name="`LongText`", type="string", nullable=true) */ private string $longText; - /** - * @Column(name="`PublishDate`", type="datetimetz", nullable=true) - */ - private \DateTimeZone $publishDate; + /** @Column(name="`PublishDate`", type="datetimetz", nullable=true) */ + private DateTimeZone $publishDate; - /** - * @Column(name="`IdxNews`", type="json_array", nullable=true) - */ + /** @Column(name="`IdxNews`", type="json_array", nullable=true) */ private array $idxNews; - /** - * @Column(name="`Highlight`", type="boolean", nullable=false) - */ + /** @Column(name="`Highlight`", type="boolean", nullable=false) */ private bool $highlight; - /** - * @Column(name="`Order`", type="integer", nullable=false) - */ + /** @Column(name="`Order`", type="integer", nullable=false) */ private int $order; - /** - * @Column(name="`Deleted`", type="boolean", nullable=false) - */ + /** @Column(name="`Deleted`", type="boolean", nullable=false) */ private bool $deleted; - /** - * @Column(name="`Active`", type="boolean", nullable=false) - */ + /** @Column(name="`Active`", type="boolean", nullable=false) */ private bool $active; - /** - * @Column(name="`UpdateToHighlighted`", type="boolean", nullable=true) - */ + /** @Column(name="`UpdateToHighlighted`", type="boolean", nullable=true) */ private bool $updateToHighlighted; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php index 19450e513cd..ccd7663d5af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php @@ -102,7 +102,6 @@ public function __construct( * @Column(type="string", name="`simple-entity-value`") */ public string $value - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php index 2a9fe6ae0f0..b20b511c1b7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php @@ -64,10 +64,8 @@ class DDC1757B */ private int $id; - /** - * @OneToOne(targetEntity="DDC1757C") - */ - private \Doctrine\Tests\ORM\Functional\Ticket\DDC1757C $c; + /** @OneToOne(targetEntity="DDC1757C") */ + private DDC1757C $c; } /** @@ -83,10 +81,8 @@ class DDC1757C */ public $id; - /** - * @OneToOne(targetEntity="DDC1757D") - */ - private \Doctrine\Tests\ORM\Functional\Ticket\DDC1757D $d; + /** @OneToOne(targetEntity="DDC1757D") */ + private DDC1757D $d; } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php index a2b169aa46e..32402b1407d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php @@ -72,9 +72,7 @@ class DDC1925Product */ private int $id; - /** - * @Column(name="title", type="string", length=255) - */ + /** @Column(name="title", type="string", length=255) */ private ?string $title = null; /** @@ -138,9 +136,7 @@ class DDC1925User */ private int $id; - /** - * @Column(name="title", type="string", length=255) - */ + /** @Column(name="title", type="string", length=255) */ private ?string $title = null; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index 90675536c8b..f38e1d61352 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use Stringable; /** * @group DDC-1998 @@ -96,7 +97,7 @@ public function getName(): string } } -class DDC1998Id implements \Stringable +class DDC1998Id implements Stringable { public function __construct(private string $val) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index cd3ca819384..300cd5bf4bb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -17,7 +17,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function explode; -use function get_class; use function implode; use function is_array; use function method_exists; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php index c798e5b762b..4842df2ada4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php @@ -93,8 +93,7 @@ public function __construct( * @JoinColumn(name="entity2_id", referencedColumnName="id", nullable=false) */ private MyEntity2 $entity2 - ) - { + ) { } public function setMyEntity2(MyEntity2 $myEntity2): void @@ -126,8 +125,7 @@ public function __construct( * @Column */ private string $value - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index 5cec6e9347a..a99c5f031d1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Tests\ORM\Functional\Ticket\Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Table as DbalTable; @@ -20,6 +19,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Tools\SchemaTool; +use Doctrine\Tests\ORM\Functional\Ticket\Doctrine\Common\Collections\Collection; use Doctrine\Tests\OrmFunctionalTestCase; use function assert; @@ -131,8 +131,7 @@ public function __construct( * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) */ private Structure $followedStructure - ) - { + ) { } public function getUser(): User @@ -168,8 +167,7 @@ public function __construct( * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) */ private User $followedUser - ) - { + ) { } public function getUser(): User diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php index bafc3860732..a785e43b03e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -62,5 +62,5 @@ class DDC2182OptionChild * @ManyToOne(targetEntity="DDC2182OptionParent") * @JoinColumn(referencedColumnName="id") */ - private \Doctrine\Tests\ORM\Functional\Ticket\DDC2182OptionParent $parent; + private DDC2182OptionParent $parent; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index b46fe970c59..dbd470b1a77 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -228,19 +228,21 @@ class DDC2252Membership */ protected $privileges; - public function __construct(/** - * @Id - * @ManyToOne(targetEntity="DDC2252User", inversedBy="memberships") - * @JoinColumn(name="uid", referencedColumnName="uid") - */ - protected DDC2252User $userAccount, /** - * @Id - * @ManyToOne(targetEntity="DDC2252MerchantAccount") - * @JoinColumn(name="mch_accountid", referencedColumnName="accountid") - */ - protected DDC2252MerchantAccount $merchantAccount) - { - $this->privileges = new ArrayCollection(); + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="DDC2252User", inversedBy="memberships") + * @JoinColumn(name="uid", referencedColumnName="uid") + */ + protected DDC2252User $userAccount, + /** + * @Id + * @ManyToOne(targetEntity="DDC2252MerchantAccount") + * @JoinColumn(name="mch_accountid", referencedColumnName="accountid") + */ + protected DDC2252MerchantAccount $merchantAccount + ) { + $this->privileges = new ArrayCollection(); } public function addPrivilege(DDC2252Privilege $privilege): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index ccb4c5aa8b8..959ffa3d111 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -172,14 +172,16 @@ class DDC2306UserAddress public $id; /** Constructor */ - public function __construct(/** - * @ManyToOne(targetEntity="DDC2306User") - */ - public DDC2306User $user, /** - * @ManyToOne(targetEntity="DDC2306Address", fetch="LAZY") - */ - public DDC2306Address $address) - { + public function __construct( + /** + * @ManyToOne(targetEntity="DDC2306User") + */ + public DDC2306User $user, + /** + * @ManyToOne(targetEntity="DDC2306Address", fetch="LAZY") + */ + public DDC2306Address $address + ) { $user->addresses->add($this); $address->users->add($this); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php index 7d8bd9eedd2..0010b15aeae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -14,8 +14,6 @@ use Doctrine\ORM\Proxy\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - class DDC237Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index 3bacbb053d5..d5ff4e2ac89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -4,8 +4,8 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Common\Proxy\Proxy; use Doctrine\Common\Collections\Collection; +use Doctrine\Common\Proxy\Proxy; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\Column; @@ -105,8 +105,7 @@ public function __construct( * @Column(name="temp", type="ddc2494_tinyint", nullable=false) */ protected int $temp - ) - { + ) { } public function getId(): int @@ -148,8 +147,7 @@ public function __construct( * @JoinColumn(name="currency_id", referencedColumnName="id", nullable=false) */ protected DDC2494Currency $currency - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index 93ff4dda38d..0215047eb75 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -120,8 +120,7 @@ public function __construct( * @Column(type="integer") */ public int $sampleField = 0 - ) - { + ) { } } @@ -142,8 +141,7 @@ public function __construct( * @JoinColumn(name="b_id", referencedColumnName="id", nullable=FALSE, onDelete="CASCADE") */ public DDC2575B $bRelation - ) - { + ) { } } @@ -162,7 +160,6 @@ public function __construct( * @Column(type="integer") */ public int $sampleField = 0 - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index 01988fe0396..a3c8098203c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use Stringable; /** * @group DDC-2579 @@ -90,11 +91,13 @@ class DDC2579Entity */ public $assoc; - public function __construct(DDC2579EntityAssoc $assoc, /** - * @Column(type="integer") - */ - public int $value = 0) - { + public function __construct( + DDC2579EntityAssoc $assoc, + /** + * @Column(type="integer") + */ + public int $value = 0 + ) { $this->id = $assoc->assocAssoc->associationId; $this->assoc = $assoc; } @@ -113,8 +116,7 @@ public function __construct( * @JoinColumn(name="association_id", referencedColumnName="associationId") */ public $assocAssoc - ) - { + ) { } } @@ -129,8 +131,7 @@ public function __construct( * @Column(type="ddc2579", length=255) */ public DDC2579Id $associationId - ) - { + ) { } } @@ -161,7 +162,7 @@ public function getName(): string } } -class DDC2579Id implements \Stringable +class DDC2579Id implements Stringable { public function __construct(private string $val) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php index 01f70efbed4..720fe0d19d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php @@ -20,6 +20,8 @@ use function in_array; use function json_decode; +use const JSON_THROW_ON_ERROR; + /** * @group DDC-2602 */ @@ -148,7 +150,7 @@ public function postLoad(LifecycleEventArgs $event): void $fieldSelection = new DDC2602FieldSelection(); $fieldSelection->field = $field; - $fieldSelection->choiceList = $field->choiceList->filter(static fn($choice) => in_array($choice->id, $choiceList, true)); + $fieldSelection->choiceList = $field->choiceList->filter(static fn ($choice) => in_array($choice->id, $choiceList, true)); $fieldList->add($fieldSelection); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php index b88fdc8145b..74c8a6d1c7f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php @@ -123,9 +123,6 @@ class DDC2660Customer */ class DDC2660CustomerOrder { - /** - * @param string $name - */ public function __construct( /** * @Id @@ -140,8 +137,7 @@ public function __construct( /** * @Column(type="string", length=255) */ - public $name - ) - { + public string $name + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index e3374d77bf8..85ae05c0ebd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -143,8 +143,7 @@ public function __construct( * @OneToOne(targetEntity="DDC2759Qualification", inversedBy="metadata") */ public DDC2759Qualification $content - ) - { + ) { } } @@ -171,7 +170,6 @@ public function __construct( * @ManyToOne(targetEntity="DDC2759Category", inversedBy="metadataCategories") */ public DDC2759Category $category - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php index 802933e6bf7..39d104d2c51 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php @@ -10,7 +10,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function array_intersect_key; -use function get_class; use function intval; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index 5d2057bd13e..d4e845abc19 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -137,22 +137,17 @@ class DDC2862Driver */ protected $id; - /** - * @param string $name - * @param \Doctrine\Tests\ORM\Functional\Ticket\DDC2862User $userProfile - */ public function __construct( /** * @Column(type="string", length=255) */ - protected $name, + protected string $name, /** * @Cache() * @OneToOne(targetEntity="DDC2862User") */ - protected $userProfile = null - ) - { + protected ?DDC2862User $userProfile = null + ) { } public function getId(): int @@ -196,16 +191,12 @@ class DDC2862User */ protected $id; - /** - * @param string $name - */ public function __construct( /** * @Column(type="string", length=255) */ - protected $name - ) - { + protected string $name + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index 49b8cfc6a6e..e15bc61fdbe 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -16,7 +16,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function assert; -use function get_class; class DDC2895Test extends OrmFunctionalTestCase { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 958937ff6a7..e5c0113fe0e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -15,6 +15,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; use Exception; +use Stringable; use function is_string; @@ -76,9 +77,7 @@ public function testIssue(): void */ class DDC2984User { - /** - * @Column(type="string", length=50) - */ + /** @Column(type="string", length=50) */ private ?string $name = null; public function __construct( @@ -88,8 +87,7 @@ public function __construct( * @GeneratedValue(strategy="NONE") */ private DDC2984DomainUserId $userId - ) - { + ) { } public function userId(): DDC2984DomainUserId @@ -116,7 +114,7 @@ public function sameIdentityAs(DDC2984User $other): bool /** * DDC2984DomainUserId ValueObject */ -class DDC2984DomainUserId implements \Stringable +class DDC2984DomainUserId implements Stringable { public function __construct(private string $userIdString) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index a47981a8dae..ba3f6abcd5f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -13,8 +13,6 @@ use Doctrine\ORM\Mapping\PreFlush; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * @group DDC-2996 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index 12dce800c66..5cef0d320cf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -20,8 +20,6 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * @group DDC-3033 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php index 2af5c66942e..6037f7e0fa3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php @@ -9,8 +9,6 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * FlushEventTest */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index e7ce115c2c5..3ccf471dfdb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -97,8 +97,7 @@ public function __construct( * @Column(type="ddc3192_currency_code") */ public string $code - ) - { + ) { } } @@ -126,8 +125,7 @@ public function __construct( * @JoinColumn(name="currency_id", referencedColumnName="code", nullable=false) */ public DDC3192Currency $currency - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index fcb724c64ff..c3e96ce6f44 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -84,16 +84,12 @@ interface DDC3300Boss /** @Entity */ class DDC3300HumanBoss extends DDC3300Person implements DDC3300Boss { - /** - * @param string $bossCol - */ public function __construct( /** * @Column(type="string", length=255) */ - public $bossCol - ) - { + public string $bossCol + ) { } } @@ -104,15 +100,11 @@ interface DDC3300Employee /** @Entity */ class DDC3300HumanEmployee extends DDC3300Person implements DDC3300Employee { - /** - * @param string $employeeCol - */ public function __construct( /** * @Column(type="string", length=255) */ - public $employeeCol - ) - { + public string $employeeCol + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php index 535e8205383..3e07b9804c6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -60,8 +60,7 @@ public function __construct( * @Embedded(class="DDC3303Address") */ private DDC3303Address $address - ) - { + ) { } } @@ -83,8 +82,7 @@ public function __construct( * @Column(type="string", length=255) */ private string $city - ) - { + ) { } } @@ -94,14 +92,14 @@ public function __construct( */ class DDC3303Employee extends DDC3303Person { - /** - * @param string $company - */ - public function __construct(string $name, DDC3303Address $address, /** - * @Column(type="string", length=255) - */ - private $company) - { + public function __construct( + string $name, + DDC3303Address $address, + /** + * @Column(type="string", length=255) + */ + private string $company + ) { parent::__construct($name, $address); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php index ef3fdef9772..4de7c54b2dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -67,7 +67,7 @@ public function testTwoIterateHydrations(): void self::assertEquals(1, $membership->prePersistCallCount); self::assertEquals(0, $membership->preUpdateCallCount); - self::assertInstanceOf(\DateTime::class, $membership->updated); + self::assertInstanceOf(DateTime::class, $membership->updated); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index d5551d28adb..c0e911559da 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -99,7 +99,7 @@ class DDC353Picture * @JoinColumn(name="file_id", referencedColumnName="file_id") * }) */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC353File $file = null; + private ?DDC353File $file = null; public function getPictureId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php index c37b1a177de..2dd2e16b723 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php @@ -40,12 +40,13 @@ class DDC3582Entity */ public $embeddable1; - public function __construct(/** - * @Column - * @Id - */ - private string $id) - { + public function __construct( + /** + * @Column + * @Id + */ + private string $id + ) { $this->embeddable1 = new DDC3582Embeddable1(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index 66de564ff05..c837372f575 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -4,10 +4,10 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\DBAL\Driver\Middleware; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; +use Doctrine\DBAL\Driver\Middleware; use Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware; use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware; use Doctrine\ORM\Mapping\Column; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php index 14c5909dcc3..dd8a7563a37 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php @@ -210,16 +210,12 @@ class DDC3644Address */ public $user; - /** - * @param string $address - */ public function __construct( /** * @Column(type="string", length=255) */ - public $address - ) - { + public string $address + ) { } } @@ -239,16 +235,12 @@ abstract class DDC3644Animal */ public $id; - /** - * @param string $name - */ public function __construct( /** * @Column(type="string", length=255) */ - public $name - ) - { + public string $name + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php index f3c36ae29c2..1aacd0b3222 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php @@ -18,6 +18,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use Stringable; class DDC3785Test extends OrmFunctionalTestCase { @@ -81,13 +82,15 @@ class DDC3785Asset /** * @psalm-param list $attributes */ - public function __construct(/** - * @Id - * @GeneratedValue(strategy="NONE") - * @Column(type="ddc3785_asset_id") - */ - private DDC3785AssetId $id, $attributes = []) - { + public function __construct( + /** + * @Id + * @GeneratedValue(strategy="NONE") + * @Column(type="ddc3785_asset_id") + */ + private DDC3785AssetId $id, + $attributes = [] + ) { $this->attributes = new ArrayCollection(); foreach ($attributes as $attribute) { @@ -132,21 +135,19 @@ public function __construct( * @Column(type="string", length=255) */ private string $value - ) - { + ) { } } /** @Embeddable */ -class DDC3785AssetId implements \Stringable +class DDC3785AssetId implements Stringable { public function __construct( /** * @Column(type = "guid") */ private string $id - ) - { + ) { } public function __toString(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index bbb72b9a463..1a0d0675622 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -19,8 +19,6 @@ use Doctrine\ORM\PersistentCollection; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - class DDC422Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php index a3114b14ee1..9ccd4c5ec20 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -65,7 +65,7 @@ class DDC448MainTable * @ManyToOne(targetEntity="DDC448ConnectedClass", cascade={"all"}, fetch="EAGER") * @JoinColumn(name="connectedClassId", referencedColumnName="id", onDelete="CASCADE", nullable=true) */ - private \Doctrine\Tests\ORM\Functional\Ticket\DDC448ConnectedClass $connectedClassId; + private DDC448ConnectedClass $connectedClassId; } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index b0ccedff8bd..f37e1dbdae6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -13,8 +13,6 @@ use Doctrine\ORM\Proxy\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * Tests that join columns (foreign keys) can be named the same as the association * fields they're used on without causing issues. diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index c70c29c4d10..5b9ddcc83c2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use Stringable; /** * This test verifies that custom post-insert identifiers respect type conversion semantics. @@ -88,7 +89,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st } } -class DDC5684ObjectId implements \Stringable +class DDC5684ObjectId implements Stringable { public function __construct(public mixed $value) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php index 8efeee74ecd..663c0282646 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -49,15 +49,11 @@ class DDC588Site */ public $id; - /** - * @param string $name - */ public function __construct( /** * @Column(type="string", length=45) */ - protected $name = '' - ) - { + protected string $name = '' + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index 623a9e98840..83339b3566f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -184,20 +184,15 @@ class DDC618Book */ public $id; - /** - * @param string $title - * @param \Doctrine\Tests\ORM\Functional\Ticket\DDC618Author $author - */ public function __construct( /** * @Column(type="string", length=255) */ - public $title, + public string $title, /** * @ManyToOne(targetEntity="DDC618Author", inversedBy="books") */ - public $author - ) - { + public DDC618Author $author + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php index 9222021f76f..cd6cce4825d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php @@ -120,12 +120,14 @@ abstract class DDC6303BaseClass */ class DDC6303ChildA extends DDC6303BaseClass { - public function __construct(string $id, /** - * @Column(type="string", length=255) - */ - private mixed $originalData) - { - $this->id = $id; + public function __construct( + string $id, + /** + * @Column(type="string", length=255) + */ + private mixed $originalData + ) { + $this->id = $id; } } @@ -138,11 +140,13 @@ class DDC6303ChildB extends DDC6303BaseClass /** * @param mixed[] $originalData */ - public function __construct(string $id, /** - * @Column(type="simple_array", nullable=true) - */ - private array $originalData) - { - $this->id = $id; + public function __construct( + string $id, + /** + * @Column(type="simple_array", nullable=true) + */ + private array $originalData + ) { + $this->id = $id; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index fa104a486be..5bf16c34d63 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -11,7 +11,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use function array_keys; -use function get_class; class DDC656Test extends OrmFunctionalTestCase { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php index 012e28c6a21..19ac140c5de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php @@ -29,9 +29,9 @@ public function testEntitySingleResult(): void self::assertInstanceOf(DateTimeModel::class, $datetime); - self::assertInstanceOf(\DateTime::class, $datetime->datetime); - self::assertInstanceOf(\DateTime::class, $datetime->time); - self::assertInstanceOf(\DateTime::class, $datetime->date); + self::assertInstanceOf(DateTime::class, $datetime->datetime); + self::assertInstanceOf(DateTime::class, $datetime->time); + self::assertInstanceOf(DateTime::class, $datetime->date); } public function testScalarResult(): void @@ -57,13 +57,13 @@ public function testaTicketEntityArrayResult(): void self::assertCount(2, $result); - self::assertInstanceOf(\DateTime::class, $result[0]['datetime']); - self::assertInstanceOf(\DateTime::class, $result[0]['time']); - self::assertInstanceOf(\DateTime::class, $result[0]['date']); + self::assertInstanceOf(DateTime::class, $result[0]['datetime']); + self::assertInstanceOf(DateTime::class, $result[0]['time']); + self::assertInstanceOf(DateTime::class, $result[0]['date']); - self::assertInstanceOf(\DateTime::class, $result[1]['datetime']); - self::assertInstanceOf(\DateTime::class, $result[1]['time']); - self::assertInstanceOf(\DateTime::class, $result[1]['date']); + self::assertInstanceOf(DateTime::class, $result[1]['datetime']); + self::assertInstanceOf(DateTime::class, $result[1]['time']); + self::assertInstanceOf(DateTime::class, $result[1]['date']); } public function testTicketSingleResult(): void @@ -73,9 +73,9 @@ public function testTicketSingleResult(): void self::assertIsArray($datetime); - self::assertInstanceOf(\DateTime::class, $datetime['datetime']); - self::assertInstanceOf(\DateTime::class, $datetime['time']); - self::assertInstanceOf(\DateTime::class, $datetime['date']); + self::assertInstanceOf(DateTime::class, $datetime['datetime']); + self::assertInstanceOf(DateTime::class, $datetime['time']); + self::assertInstanceOf(DateTime::class, $datetime['date']); } public function testTicketResult(): void @@ -85,15 +85,15 @@ public function testTicketResult(): void self::assertCount(2, $result); - self::assertInstanceOf(\DateTime::class, $result[0]['time']); - self::assertInstanceOf(\DateTime::class, $result[0]['date']); - self::assertInstanceOf(\DateTime::class, $result[0]['datetime']); + self::assertInstanceOf(DateTime::class, $result[0]['time']); + self::assertInstanceOf(DateTime::class, $result[0]['date']); + self::assertInstanceOf(DateTime::class, $result[0]['datetime']); self::assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d G:i:s')); - self::assertInstanceOf(\DateTime::class, $result[1]['time']); - self::assertInstanceOf(\DateTime::class, $result[1]['date']); - self::assertInstanceOf(\DateTime::class, $result[1]['datetime']); + self::assertInstanceOf(DateTime::class, $result[1]['time']); + self::assertInstanceOf(DateTime::class, $result[1]['date']); + self::assertInstanceOf(DateTime::class, $result[1]['datetime']); self::assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d G:i:s')); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php index dcc78406e27..dfee1bd5e62 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php @@ -120,9 +120,7 @@ class Lemma */ private int $id; - /** - * @Column(type="string", name="lemma_name", unique=true, length=255) - */ + /** @Column(type="string", name="lemma_name", unique=true, length=255) */ private ?string $lemma = null; /** @@ -194,19 +192,19 @@ class Relation * @ManyToOne(targetEntity="Lemma", inversedBy="relations") * @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id") */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\Lemma $parent = null; + private ?Lemma $parent = null; /** * @OneToOne(targetEntity="Lemma") * @JoinColumn(name="relation_child_id", referencedColumnName="lemma_id") */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\Lemma $child = null; + private ?Lemma $child = null; /** * @ManyToOne(targetEntity="RelationType", inversedBy="relations") * @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id") */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\RelationType $type = null; + private ?RelationType $type = null; public function setParent(Lemma $parent): void { @@ -272,14 +270,10 @@ class RelationType */ private int $id; - /** - * @Column(type="string", name="relation_type_name", unique=true, length=255) - */ + /** @Column(type="string", name="relation_type_name", unique=true, length=255) */ private ?string $type = null; - /** - * @Column(type="string", name="relation_type_abbreviation", unique=true, length=255) - */ + /** @Column(type="string", name="relation_type_abbreviation", unique=true, length=255) */ private ?string $abbreviation = null; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php index 5e3eff09f09..5694ff91b1e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -115,11 +115,12 @@ class DDC735Review */ protected $id; - public function __construct(/** - * @ManyToOne(targetEntity="DDC735Product", inversedBy="reviews") - */ - protected DDC735Product $product) - { + public function __construct( + /** + * @ManyToOne(targetEntity="DDC735Product", inversedBy="reviews") + */ + protected DDC735Product $product + ) { $product->addReview($this); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php index 508353a24cc..32e91ed8f89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php @@ -4,11 +4,10 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Query\AST\SelectStatement; use Doctrine\ORM\Proxy\Proxy; use Doctrine\ORM\Query; -use Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\AST\SelectExpression; +use Doctrine\ORM\Query\AST\SelectStatement; use Doctrine\ORM\Query\TreeWalkerAdapter; use Doctrine\Tests\Models\ECommerce\ECommerceCart; use Doctrine\Tests\Models\ECommerce\ECommerceCustomer; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php index 948a967201d..a79355a7301 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php @@ -10,7 +10,6 @@ use Exception; use function assert; -use function get_class; class DDC767Test extends OrmFunctionalTestCase { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php index ee405c46d34..a6e3c7926f9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php @@ -8,8 +8,6 @@ use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - class DDC812Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index e3a5edea93f..a83e8e76941 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -178,8 +178,7 @@ public function __construct( * @Column(type="string", length=255) */ public string $word - ) - { + ) { } } @@ -212,8 +211,7 @@ public function __construct( * @Column(type="string", length=255) */ public string $name - ) - { + ) { } } @@ -223,14 +221,17 @@ public function __construct( */ class DDC832JoinedTreeIndex extends DDC832JoinedIndex { - public function __construct(string $name, /** - * @Column(type="integer") - */ - public int $lft, /** - * @Column(type="integer") - */ - public int $rgt) - { + public function __construct( + string $name, + /** + * @Column(type="integer") + */ + public int $lft, + /** + * @Column(type="integer") + */ + public int $rgt + ) { $this->name = $name; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index aacd2cc032c..4f458229e14 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -211,8 +211,7 @@ public function __construct( * @Column(name="sysname", type="string", length=255) */ protected string $sysname - ) - { + ) { } public function getSysname(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index 1a288b79b77..ac142712f0f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -114,9 +114,7 @@ class DDC881User */ private int $id; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $name = null; /** @@ -151,11 +149,9 @@ class DDC881PhoneNumber * @Id * @ManyToOne(targetEntity="DDC881User",cascade={"all"}) */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC881User $user = null; + private ?DDC881User $user = null; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private ?string $phonenumber = null; /** @@ -212,11 +208,9 @@ class DDC881PhoneCall * @JoinColumn(name="user_id", referencedColumnName="user_id") * }) */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\DDC881PhoneNumber $phonenumber = null; + private ?DDC881PhoneNumber $phonenumber = null; - /** - * @Column(type="string",nullable=true) - */ + /** @Column(type="string",nullable=true) */ private string $callDate; public function setPhoneNumber(DDC881PhoneNumber $phoneNumber): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php index cbd55248143..0ae12000fef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -77,16 +77,12 @@ public function getVersion(): int */ class DDC960Child extends DDC960Root { - /** - * @param string $name - */ public function __construct( /** * @Column(type="string", length=255) */ - private $name - ) - { + private string $name + ) { } public function setName($name): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index cb042a0d48e..797538732eb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -19,8 +19,6 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -use function get_class; - /** * @group DDC-992 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php index 61b8d120536..907f7e14fb8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; +use Stringable; use Symfony\Component\Cache\Adapter\ArrayAdapter; /** @@ -82,7 +83,7 @@ private function updateData(): void * @Entity * @Table(name="GH2947_car") */ -class GH2947Car implements \Stringable +class GH2947Car implements Stringable { public function __construct( /** @@ -91,8 +92,7 @@ public function __construct( * @GeneratedValue(strategy="NONE") */ public string $brand - ) - { + ) { } public function __toString(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php index 56acf865eac..b15c7091535 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php @@ -14,7 +14,8 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -use function mt_rand; +use function mt_getrandmax; +use function random_int; final class GH5562Test extends OrmFunctionalTestCase { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index 01335accf2d..843be4b7348 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -122,16 +122,18 @@ class GH5762Driver */ public $driverRides; - public function __construct(/** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - */ - public int $id, /** - * @Column(type="string", length=255) - */ - public string $name) - { + public function __construct( + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="NONE") + */ + public int $id, + /** + * @Column(type="string", length=255) + */ + public string $name + ) { $this->driverRides = new ArrayCollection(); } } @@ -142,18 +144,20 @@ public function __construct(/** */ class GH5762DriverRide { - public function __construct(/** - * @Id - * @ManyToOne(targetEntity="GH5762Driver", inversedBy="driverRides") - * @JoinColumn(name="driver_id", referencedColumnName="id") - */ - public GH5762Driver $driver, /** - * @Id - * @ManyToOne(targetEntity="GH5762Car", inversedBy="carRides") - * @JoinColumn(name="car", referencedColumnName="brand") - */ - public GH5762Car $car) - { + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity="GH5762Driver", inversedBy="driverRides") + * @JoinColumn(name="driver_id", referencedColumnName="id") + */ + public GH5762Driver $driver, + /** + * @Id + * @ManyToOne(targetEntity="GH5762Car", inversedBy="carRides") + * @JoinColumn(name="car", referencedColumnName="brand") + */ + public GH5762Car $car + ) { $this->driver->driverRides->add($this); $this->car->carRides->add($this); } @@ -171,20 +175,18 @@ class GH5762Car */ public $carRides; - /** - * @param string $brand - * @param string $model - */ - public function __construct(/** - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ - public $brand, /** - * @Column(type="string", length=255) - */ - public $model) - { + public function __construct( + /** + * @Id + * @Column(type="string", length=25) + * @GeneratedValue(strategy="NONE") + */ + public string $brand, + /** + * @Column(type="string", length=255) + */ + public string $model + ) { $this->carRides = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index c42d331a357..b9424e25709 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use Stringable; use function assert; @@ -84,7 +85,7 @@ class GH5887Cart * @OneToOne(targetEntity="GH5887Customer", inversedBy="cart") * @JoinColumn(name="customer_id", referencedColumnName="id") */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\GH5887Customer $customer = null; + private ?GH5887Customer $customer = null; public function getId(): int { @@ -120,14 +121,14 @@ class GH5887Customer * @Column(type="GH5887CustomIdObject", length=255) * @GeneratedValue(strategy="NONE") */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\GH5887CustomIdObject $id = null; + private ?GH5887CustomIdObject $id = null; /** * One Customer has One Cart. * * @OneToOne(targetEntity="GH5887Cart", mappedBy="customer") */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\GH5887Cart $cart = null; + private ?GH5887Cart $cart = null; public function getId(): GH5887CustomIdObject { @@ -153,7 +154,7 @@ public function setCart(GH5887Cart $cart): void } } -class GH5887CustomIdObject implements \Stringable +class GH5887CustomIdObject implements Stringable { public function __construct(private int $id) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php index e52281a6cfb..7ba3ca017d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\OrmFunctionalTestCase; use InvalidArgumentException; +use Stringable; use function in_array; @@ -108,7 +109,7 @@ public function getName(): string } } -class GH6141People implements \Stringable +class GH6141People implements Stringable { public const BOSS = 'boss'; public const EMPLOYEE = 'employee'; @@ -169,8 +170,7 @@ public function __construct( * @Column(type="string", length=255) */ public string $name - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php index 38b3af9b220..037448810e3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php @@ -99,7 +99,6 @@ public function __construct( * @ManyToOne(targetEntity=GH6217AssociatedEntity::class, fetch="EAGER") */ public GH6217AssociatedEntity $eager - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index af772bed531..57dd8334635 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -103,10 +103,8 @@ class GH6362Start */ protected $id; - /** - * @ManyToOne(targetEntity="GH6362Base", inversedBy="starts") - */ - private \Doctrine\Tests\ORM\Functional\Ticket\GH6362Base $bases; + /** @ManyToOne(targetEntity="GH6362Base", inversedBy="starts") */ + private GH6362Base $bases; } /** @@ -156,8 +154,6 @@ class GH6362Join */ private int $id; - /** - * @ManyToOne(targetEntity="GH6362Child", inversedBy="joins") - */ - private \Doctrine\Tests\ORM\Functional\Ticket\GH6362Child $child; + /** @ManyToOne(targetEntity="GH6362Child", inversedBy="joins") */ + private GH6362Child $child; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php index 2e244587130..9f340691e24 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php @@ -68,8 +68,7 @@ public function __construct( * @Column(type="integer") */ public int $id - ) - { + ) { } } @@ -96,7 +95,6 @@ public function __construct( * @Column(type="string", length=255) */ public string $something - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php index bdc23cd2068..eae1b85a193 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php @@ -162,8 +162,7 @@ public function __construct( * @ManyToOne(targetEntity=GH6531Article::class, inversedBy="attributes") */ public GH6531Article $article - ) - { + ) { } } @@ -231,7 +230,6 @@ public function __construct( * @Column(type="integer") */ public int $amount = 1 - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php index e2f4530ea85..b0b2f494f3b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php @@ -85,7 +85,6 @@ public function __construct( * @Column(type="string", name="`name`") */ public string $name - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php index d99792d263f..401251cd5b5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php @@ -110,13 +110,15 @@ class GH7062Ranking /** * @param GH7062Team[] $teams */ - public function __construct(/** - * @Id - * @OneToOne(targetEntity=GH7062Season::class, inversedBy="ranking") - * @JoinColumn(name="season", referencedColumnName="id") - */ - public GH7062Season $season, array $teams) - { + public function __construct( + /** + * @Id + * @OneToOne(targetEntity=GH7062Season::class, inversedBy="ranking") + * @JoinColumn(name="season", referencedColumnName="id") + */ + public GH7062Season $season, + array $teams + ) { $this->positions = new ArrayCollection(); foreach ($teams as $team) { @@ -145,8 +147,7 @@ public function __construct( * @Column(type="string", length=255) */ public string $id - ) - { + ) { } } @@ -164,8 +165,7 @@ public function __construct( * @Column(type="string", length=255) */ public string $id - ) - { + ) { } } @@ -183,18 +183,20 @@ class GH7062RankingPosition */ public $points; - public function __construct(/** - * @Id - * @ManyToOne(targetEntity=GH7062Ranking::class, inversedBy="positions") - * @JoinColumn(name="season", referencedColumnName="season") - */ - public GH7062Ranking $ranking, /** - * @Id - * @ManyToOne(targetEntity=GH7062Team::class) - * @JoinColumn(name="team_id", referencedColumnName="id") - */ - public GH7062Team $team) - { - $this->points = 0; + public function __construct( + /** + * @Id + * @ManyToOne(targetEntity=GH7062Ranking::class, inversedBy="positions") + * @JoinColumn(name="season", referencedColumnName="season") + */ + public GH7062Ranking $ranking, + /** + * @Id + * @ManyToOne(targetEntity=GH7062Team::class) + * @JoinColumn(name="team_id", referencedColumnName="id") + */ + public GH7062Team $team + ) { + $this->points = 0; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php index 985e3453ea6..fd4a30220f5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php @@ -98,8 +98,7 @@ public function __construct( * @Column(type="integer") */ public int $version - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php index 669d5a8b3cb..5cf788d1229 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php @@ -67,8 +67,7 @@ public function __construct( * @Column(length=32) */ protected string $name - ) - { + ) { } public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php index fce1c67a9cd..05b86ed7bd2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php @@ -78,8 +78,7 @@ public function __construct( * @Column(type="string", length=255) */ public string $name - ) - { + ) { } } @@ -88,9 +87,6 @@ public function __construct( */ class GH7496EntityB { - /** - * @param string $name - */ public function __construct( /** * @Id @@ -100,9 +96,8 @@ public function __construct( /** * @Column(type="string", length=255) */ - public $name - ) - { + public string $name + ) { } } @@ -112,8 +107,8 @@ public function __construct( class GH7496EntityAinB { /** - * @param \Doctrine\Tests\ORM\Functional\Ticket\GH7496EntityA $a - * @param \Doctrine\Tests\ORM\Functional\Ticket\GH7496EntityB $b + * @param GH7496EntityA $a + * @param GH7496EntityB $b */ public function __construct( /** @@ -131,7 +126,6 @@ public function __construct( * @JoinColumn(name="b_id", referencedColumnName="b_id", nullable=false) */ public $eB - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php index 8c3cac705af..449021505e9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php @@ -108,7 +108,6 @@ public function __construct( * @ManyToOne(targetEntity=GH7661Event::class) */ public GH7661Event $event - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php index c1df03ef674..b99acbd9181 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php @@ -69,8 +69,7 @@ public function __construct( * @Cache("READ_ONLY") */ private GH7735Engine $engine - ) - { + ) { } public function getId(): int @@ -90,19 +89,22 @@ public function getEngine(): GH7735Engine */ class GH7735Engine { - public function __construct(/** - * @Id - * @Column(type="integer") - */ - private int $id, /** - * @Column - */ - private string $model, /** - * @OneToOne(targetEntity=GH7735Power::class, mappedBy="engine", cascade={"all"}) - * @Cache("READ_ONLY") - */ - private GH7735Power $power) - { + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + private int $id, + /** + * @Column + */ + private string $model, + /** + * @OneToOne(targetEntity=GH7735Power::class, mappedBy="engine", cascade={"all"}) + * @Cache("READ_ONLY") + */ + private GH7735Power $power + ) { $power->setEngine($this); } @@ -132,7 +134,7 @@ class GH7735Power * @OneToOne(targetEntity=GH7735Engine::class, inversedBy="power") * @Cache("READ_ONLY") */ - private ?\Doctrine\Tests\ORM\Functional\Ticket\GH7735Engine $engine = null; + private ?GH7735Engine $engine = null; public function __construct( /** @@ -140,8 +142,7 @@ public function __construct( * @Column(type="integer") */ private int $id - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php index e5bb3a09cb0..4f7dfb8276f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php @@ -76,8 +76,7 @@ public function __construct( * @Column */ public string $name - ) - { + ) { } } @@ -93,12 +92,13 @@ class GH7737Person */ public $groups; - public function __construct(/** - * @Id - * @Column(type="integer") - */ - public int $id) - { + public function __construct( + /** + * @Id + * @Column(type="integer") + */ + public int $id + ) { $this->groups = new ArrayCollection(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php index d816095ce39..91be2c75204 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php @@ -117,7 +117,6 @@ public function __construct( * @Column(type="integer") */ public int $position - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php index c1f5902be22..94b5d1505ee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\Tests\OrmFunctionalTestCase; +use Stringable; use function array_map; use function is_string; @@ -75,7 +76,7 @@ public function testWillFindSongsInPaginator(): void self::assertSame( self::SONG, - array_map(static fn(GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))) + array_map(static fn (GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))) ); } @@ -92,7 +93,7 @@ public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void self::assertSame( self::SONG, - array_map(static fn(GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), + array_map(static fn (GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), 'Expected to return expected data before query cache is populated with DQL -> SQL translation. Were SQL parameters translated?' ); @@ -102,7 +103,7 @@ public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void self::assertSame( self::SONG, - array_map(static fn(GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), + array_map(static fn (GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), 'Expected to return expected data even when DQL -> SQL translation is present in cache. Were SQL parameters translated again?' ); } @@ -121,8 +122,7 @@ public function __construct( * @Column(type="integer") */ private int $lineNumber - ) - { + ) { } public function toString(): string @@ -131,7 +131,7 @@ public function toString(): string } } -final class GH7820LineText implements \Stringable +final class GH7820LineText implements Stringable { private function __construct(private string $text) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php index edba496b98b..b96edce7e8b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php @@ -142,7 +142,6 @@ public function __construct( * @Column(type="string", length=255) */ public string $name - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php index ac10ec1f954..81c077a65db 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php @@ -57,7 +57,7 @@ public function testExtraLazyRemoveElement(): void $user->tweets->removeElement($tweet); - $tweets = $user->tweets->map(static fn(GH7864Tweet $tweet) => $tweet->content); + $tweets = $user->tweets->map(static fn (GH7864Tweet $tweet) => $tweet->content); self::assertEquals(['Goodbye, and thanks for all the fish'], array_values($tweets->toArray())); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php index dc26fe7e8c4..fbbc805e7ab 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php @@ -44,7 +44,7 @@ public function cleanUpSchema(): void */ private function filterCreateTable(array $sqls, string $tableName): array { - return array_filter($sqls, static fn(string $sql): bool => str_starts_with($sql, sprintf('CREATE TABLE %s (', $tableName))); + return array_filter($sqls, static fn (string $sql): bool => str_starts_with($sql, sprintf('CREATE TABLE %s (', $tableName))); } public function testUpdateSchemaSql(): void @@ -58,7 +58,7 @@ public function testUpdateSchemaSql(): void $this->_em->getConnection()->executeStatement(current($sqls)); - $sqls = array_filter($tool->getUpdateSchemaSql($classes), static fn(string $sql): bool => str_contains($sql, ' gh7875_my_entity ')); + $sqls = array_filter($tool->getUpdateSchemaSql($classes), static fn (string $sql): bool => str_contains($sql, ' gh7875_my_entity ')); self::assertSame([], $sqls); @@ -72,7 +72,7 @@ public function testUpdateSchemaSql(): void public function testUpdateSchemaSqlWithSchemaAssetFilter(): void { - $filterCallback = static fn($assetName): bool => $assetName !== 'gh7875_my_entity'; + $filterCallback = static fn ($assetName): bool => $assetName !== 'gh7875_my_entity'; $classes = [$this->_em->getClassMetadata(GH7875MyEntity::class)]; @@ -85,7 +85,7 @@ public function testUpdateSchemaSqlWithSchemaAssetFilter(): void $previousFilter = $config->getSchemaAssetsFilter(); $sqls = $tool->getUpdateSchemaSql($classes); - $sqls = array_filter($sqls, static fn(string $sql): bool => str_contains($sql, ' gh7875_my_entity ')); + $sqls = array_filter($sqls, static fn (string $sql): bool => str_contains($sql, ' gh7875_my_entity ')); self::assertCount(0, $sqls); self::assertSame($previousFilter, $config->getSchemaAssetsFilter()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php index b2331d6bf27..571ef57d01d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php @@ -106,14 +106,16 @@ class GH7941Product */ public $createdAt; - public function __construct(/** - * @Column(type="string", length=255) - */ - public string $name, /** - * @Column(type="decimal") - */ - public string $price) - { + public function __construct( + /** + * @Column(type="string", length=255) + */ + public string $name, + /** + * @Column(type="decimal") + */ + public string $price + ) { $this->createdAt = new DateTimeImmutable(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php index ff60ce827fd..f077da78dee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php @@ -93,7 +93,6 @@ public function __construct( * @Column(type="integer", options={"unsigned": true}) */ public int $collectionIndex - ) - { + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php index 6ab1b10f7d9..0f92a4bca21 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php @@ -116,8 +116,7 @@ public function __construct( * @Column */ private string $name - ) - { + ) { } public function getName(): ?string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php index 12ecb8d4ecd..6d9ab61faa6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php @@ -100,9 +100,7 @@ class GH9109Product */ private int $id; - /** - * @Column(name="`title`", type="string", length=255) - */ + /** @Column(name="`title`", type="string", length=255) */ private ?string $title = null; /** @@ -158,14 +156,10 @@ class GH9109User */ private int $id; - /** - * @Column(name="`first_name`", type="string", length=255) - */ + /** @Column(name="`first_name`", type="string", length=255) */ private ?string $firstName = null; - /** - * @Column(name="last_name", type="string", length=255) - */ + /** @Column(name="last_name", type="string", length=255) */ private ?string $lastName = null; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index ff3da0ca040..37f5e140f54 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -96,7 +96,7 @@ public function testObject(): void $dql = 'SELECT s FROM ' . SerializationModel::class . ' s'; $serialize = $this->_em->createQuery($dql)->getSingleResult(); - self::assertInstanceOf(\stdClass::class, $serialize->object); + self::assertInstanceOf(stdClass::class, $serialize->object); } public function testDate(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php index 3e5c3351696..208aaca61d0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php @@ -4,11 +4,10 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php index 2bbbbf5987d..81c6a5d4aff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php @@ -4,10 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php index 4b57f4be9a3..b6d9e798954 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php @@ -4,10 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; -use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyExtraLazyEntity; -use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyExtraLazyEntity; -use Doctrine\Tests\Models; use Doctrine\Tests\Models\ValueConversionType as Entity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyExtraLazyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyExtraLazyEntity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php index be74346e09c..f4a0eeee661 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php @@ -4,10 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php index d882711d459..3e30e273842 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php @@ -4,11 +4,10 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php index 33d533dcc38..f3e2c800de2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php @@ -4,10 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php index ef851d7b4f3..acb78c45c73 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php @@ -4,10 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php index edfdfbcafdf..8165f51cf2c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php @@ -4,10 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php index 59683cade64..2bfcf3148d1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php @@ -4,11 +4,10 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php index bb762c1e9e7..972ebfc574f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php @@ -4,10 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity; use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php index eb7a01f1e6e..657f077afca 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php @@ -4,10 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\ValueConversionType; +use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity; use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity; -use Doctrine\Tests\Models; -use Doctrine\Tests\Models\ValueConversionType as Entity; use Doctrine\Tests\OrmFunctionalTestCase; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 205bcc9e32d..a9388ca0215 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -380,15 +380,17 @@ class DDC93Person */ public $timestamps; - public function __construct(/** - * @var string|null - * @Column(type="string", length=255) - */ - public $name = null, /** - * @Embedded(class="DDC93Address") - */ - public ?\Doctrine\Tests\ORM\Functional\DDC93Address $address = null) - { + public function __construct( + /** + * @var string|null + * @Column(type="string", length=255) + */ + public $name = null, + /** + * @Embedded(class="DDC93Address") + */ + public ?DDC93Address $address = null + ) { $this->timestamps = new DDC93Timestamps(new DateTime()); } } @@ -403,8 +405,7 @@ public function __construct( * @Column(type = "datetime") */ public DateTime $createdAt - ) - { + ) { } } @@ -431,8 +432,7 @@ public function __construct( * @Embedded(class = "DDC93Address") */ public DDC93Address $address - ) - { + ) { } } @@ -453,8 +453,7 @@ public function __construct( * @Column(type="string", nullable=true) */ public ?string $name = null - ) - { + ) { } } @@ -484,8 +483,7 @@ public function __construct( * @Embedded(class = "DDC93Country") */ public $country = null - ) - { + ) { } } @@ -499,10 +497,8 @@ class DDC93Customer */ private int $id; - /** - * @Embedded(class = "DDC93ContactInfo", columnPrefix = "contact_info_") - */ - private \Doctrine\Tests\ORM\Functional\DDC93ContactInfo $contactInfo; + /** @Embedded(class = "DDC93ContactInfo", columnPrefix = "contact_info_") */ + private DDC93ContactInfo $contactInfo; } /** @Embeddable */ @@ -530,13 +526,12 @@ public function __construct( /** * @Embedded(class="DDC3028Id", columnPrefix = "foobar_") */ - public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $id = null, + public ?DDC3028Id $id = null, /** * @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "bloo_") */ - public ?\Doctrine\Tests\ORM\Functional\DDC3028NestedEmbeddable $nested = null - ) - { + public ?DDC3028NestedEmbeddable $nested = null + ) { } } @@ -549,13 +544,12 @@ public function __construct( /** * @Embedded(class="DDC3028Id", columnPrefix = "") */ - public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $id = null, + public ?DDC3028Id $id = null, /** * @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "") */ - public ?\Doctrine\Tests\ORM\Functional\DDC3028NestedEmbeddable $nested = null - ) - { + public ?DDC3028NestedEmbeddable $nested = null + ) { } } @@ -568,9 +562,8 @@ public function __construct( /** * @Embedded(class="DDC3028Id", columnPrefix = false) */ - public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $id = null - ) - { + public ?DDC3028Id $id = null + ) { } } @@ -585,8 +578,7 @@ public function __construct( * @Column(type="string", length=255) */ public ?string $id = null - ) - { + ) { } } @@ -599,17 +591,16 @@ public function __construct( /** * @Embedded(class="DDC3028Id", columnPrefix = "foo_") */ - public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $nestedWithPrefix = null, + public ?DDC3028Id $nestedWithPrefix = null, /** * @Embedded(class="DDC3028Id", columnPrefix = "") */ - public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $nestedWithEmptyPrefix = null, + public ?DDC3028Id $nestedWithEmptyPrefix = null, /** * @Embedded(class="DDC3028Id", columnPrefix = false) */ - public ?\Doctrine\Tests\ORM\Functional\DDC3028Id $nestedWithPrefixFalse = null - ) - { + public ?DDC3028Id $nestedWithPrefixFalse = null + ) { } } diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index f5814aa64a4..4b39c79a085 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -4,10 +4,10 @@ namespace Doctrine\Tests\ORM\Hydration; -use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Result; +use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index 7fc532ecc59..a20b44b2fbf 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -66,7 +66,7 @@ public function testDefersPostLoadOfEntity(int $listenersFlag): void $metadata, Events::postLoad, $entity, - self::callback(static fn(LifecycleEventArgs $args) => $entity === $args->getEntity() && $entityManager === $args->getObjectManager()), + self::callback(static fn (LifecycleEventArgs $args) => $entity === $args->getEntity() && $entityManager === $args->getObjectManager()), $listenersFlag ); @@ -126,7 +126,7 @@ public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void self::logicalOr($metadata1, $metadata2), Events::postLoad, self::logicalOr($entity1, $entity2), - self::callback(static fn(LifecycleEventArgs $args) => in_array($args->getEntity(), [$entity1, $entity2], true) + self::callback(static fn (LifecycleEventArgs $args) => in_array($args->getEntity(), [$entity1, $entity2], true) && $entityManager === $args->getObjectManager()), $listenersFlag ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index fbddab2827f..59f732033f7 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -68,6 +68,7 @@ use Doctrine\Tests\Models\Upsertable\Insertable; use Doctrine\Tests\Models\Upsertable\Updatable; use Doctrine\Tests\OrmTestCase; +use stdClass; use function assert; use function count; @@ -227,7 +228,7 @@ public function testEntityCustomGenerator(): void 'Generator Type' ); self::assertEquals( - ['class' => \stdClass::class], + ['class' => stdClass::class], $class->customGeneratorDefinition, 'Custom Generator Definition' ); @@ -1479,13 +1480,13 @@ abstract class Animal * @CustomIdGenerator(class="stdClass") */ #[ORM\Id, ORM\Column(type: 'string'), ORM\GeneratedValue(strategy: 'CUSTOM')] - #[ORM\CustomIdGenerator(class: \stdClass::class)] + #[ORM\CustomIdGenerator(class: stdClass::class)] public $id; public static function loadMetadata(ClassMetadata $metadata): void { $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); - $metadata->setCustomGeneratorDefinition(['class' => \stdClass::class]); + $metadata->setCustomGeneratorDefinition(['class' => stdClass::class]); } } @@ -1518,8 +1519,7 @@ public function __construct( * @Column(columnDefinition = "VARCHAR(255) NOT NULL") */ #[ORM\Column(columnDefinition: 'VARCHAR(255) NOT NULL')] private ?string $value = null - ) - { + ) { } /** @@ -1627,9 +1627,7 @@ class Group #[ORM\Index(columns: ['content'], flags: ['fulltext'], options: ['where' => 'content IS NOT NULL'])] class Comment { - /** - * @Column(type="text") - */ + /** @Column(type="text") */ #[ORM\Column(type: 'text')] private string $content; diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index 6b68c1f9c11..9e04a1b6ea8 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -4,10 +4,8 @@ namespace Doctrine\Tests\ORM\Mapping; -use Doctrine\ORM\Mapping\InvalidColumn; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\ORM\Cache\Exception\CacheException; -use Doctrine\ORM\Mapping; use Doctrine\ORM\Mapping\Cache; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; @@ -20,6 +18,7 @@ use Doctrine\ORM\Mapping\HasLifecycleCallbacks; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Mapping\InvalidColumn; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\MappedSuperclass; @@ -36,6 +35,7 @@ use Doctrine\Tests\Models\DirectoryTree\File; use Doctrine\Tests\Models\ECommerce\ECommerceCart; use Generator; +use stdClass; class AnnotationDriverTest extends AbstractMappingDriverTest { @@ -44,13 +44,13 @@ class AnnotationDriverTest extends AbstractMappingDriverTest */ public function testLoadMetadataForNonEntityThrowsException(): void { - $cm = new ClassMetadata(\stdClass::class); + $cm = new ClassMetadata(stdClass::class); $cm->initializeReflection(new RuntimeReflectionService()); $reader = new AnnotationReader(); $annotationDriver = new AnnotationDriver($reader); $this->expectException(MappingException::class); - $annotationDriver->loadMetadataForClass(\stdClass::class, $cm); + $annotationDriver->loadMetadataForClass(stdClass::class, $cm); } public function testFailingSecondLevelCacheAssociation(): void @@ -410,9 +410,7 @@ class SuperEntity */ class MiddleMappedSuperclass extends SuperEntity { - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $name; } @@ -421,9 +419,7 @@ class MiddleMappedSuperclass extends SuperEntity */ class ChildEntity extends MiddleMappedSuperclass { - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $text; } @@ -432,9 +428,7 @@ class ChildEntity extends MiddleMappedSuperclass */ class InvalidFetchOption { - /** - * @OneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", fetch="eager") - */ + /** @OneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", fetch="eager") */ private CmsUser $collection; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 03d5f6f1233..a19b3335a64 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -245,30 +245,24 @@ class EntitySubClass extends TransientBaseClass */ private int $id; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $name; } /** @MappedSuperclass */ class MappedSuperclassBase { - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ private int $mapped1; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $mapped2; /** * @OneToOne(targetEntity="MappedSuperclassRelated1") * @JoinColumn(name="related1_id", referencedColumnName="id") */ - private \Doctrine\Tests\ORM\Mapping\MappedSuperclassRelated1 $mappedRelated1; + private MappedSuperclassRelated1 $mappedRelated1; /** @var mixed */ private $transient; @@ -287,9 +281,7 @@ class EntitySubClass2 extends MappedSuperclassBase */ private int $id; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $name; } @@ -302,13 +294,9 @@ class EntitySubClass2 extends MappedSuperclassBase */ class MappedSuperclassBaseIndex { - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $mapped1; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $mapped2; } @@ -324,9 +312,7 @@ class EntityIndexSubClass extends MappedSuperclassBaseIndex */ private int $id; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $name; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 34375a2c6a5..bf468fd48de 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -4,10 +4,6 @@ namespace Doctrine\Tests\ORM\Mapping; -use Doctrine\Tests\Models\Quote\User; -use Doctrine\Tests\Models\Quote\Phone; -use Doctrine\Tests\Models\Quote\Group; -use Doctrine\Tests\Models\Quote\Address; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; @@ -40,7 +36,10 @@ use Doctrine\Tests\Models\JoinedInheritanceType\AnotherChildClass; use Doctrine\Tests\Models\JoinedInheritanceType\ChildClass; use Doctrine\Tests\Models\JoinedInheritanceType\RootClass; -use Doctrine\Tests\Models\Quote; +use Doctrine\Tests\Models\Quote\Address; +use Doctrine\Tests\Models\Quote\Group; +use Doctrine\Tests\Models\Quote\Phone; +use Doctrine\Tests\Models\Quote\User; use Doctrine\Tests\OrmTestCase; use DoctrineGlobalArticle; use Exception; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index acb88a8358a..7a80f2b399b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmTestCase; +use ReflectionProperty; class ClassMetadataLoadEventTest extends OrmTestCase { @@ -27,7 +28,7 @@ public function testEvent(): void $classMetadata = $metadataFactory->getMetadataFor(LoadEventTestEntity::class); self::assertTrue($classMetadata->hasField('about')); self::assertArrayHasKey('about', $classMetadata->reflFields); - self::assertInstanceOf(\ReflectionProperty::class, $classMetadata->reflFields['about']); + self::assertInstanceOf(ReflectionProperty::class, $classMetadata->reflFields['about']); } public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void @@ -55,9 +56,7 @@ class LoadEventTestEntity */ private int $id; - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $name; /** @var mixed */ diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 332033043ec..713fb1b7bc4 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -4,15 +4,6 @@ namespace Doctrine\Tests\ORM\Mapping; -use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\CMS\One; -use Doctrine\Tests\Models\CMS\Two; -use Doctrine\Tests\Models\CMS\Three; -use Doctrine\Tests\Models\CMS\UserRepository; -use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\TypedProperties\UserTyped; -use Doctrine\Tests\Models\TypedProperties\Contact; -use Doctrine\Tests\Models\Company\CompanyContractListener; use ArrayObject; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadata; @@ -23,9 +14,15 @@ use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Persistence\Mapping\StaticReflectionService; -use Doctrine\Tests\Models\CMS; +use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsEmail; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\CMS\One; +use Doctrine\Tests\Models\CMS\Three; +use Doctrine\Tests\Models\CMS\Two; +use Doctrine\Tests\Models\CMS\UserRepository; use Doctrine\Tests\Models\Company\CompanyContract; +use Doctrine\Tests\Models\Company\CompanyContractListener; use Doctrine\Tests\Models\CustomType\CustomTypeParent; use Doctrine\Tests\Models\DDC117\DDC117Article; use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails; @@ -33,10 +30,12 @@ use Doctrine\Tests\Models\DDC964\DDC964Admin; use Doctrine\Tests\Models\DDC964\DDC964Guest; use Doctrine\Tests\Models\Routing\RoutingLeg; -use Doctrine\Tests\Models\TypedProperties; +use Doctrine\Tests\Models\TypedProperties\Contact; +use Doctrine\Tests\Models\TypedProperties\UserTyped; use Doctrine\Tests\OrmTestCase; use DoctrineGlobalArticle; use ReflectionClass; +use stdClass; use function assert; use function count; @@ -60,7 +59,7 @@ public function testClassMetadataInstanceSerialization(): void // Test initial state self::assertTrue(count($cm->getReflectionProperties()) === 0); - self::assertInstanceOf(\ReflectionClass::class, $cm->reflClass); + self::assertInstanceOf(ReflectionClass::class, $cm->reflClass); self::assertEquals(CmsUser::class, $cm->name); self::assertEquals(CmsUser::class, $cm->rootEntityName); self::assertEquals([], $cm->subClasses); @@ -308,8 +307,8 @@ public function testDuplicateAssociationMappingException(): void $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $a1 = ['fieldName' => 'foo', 'sourceEntity' => \stdClass::class, 'targetEntity' => \stdClass::class, 'mappedBy' => 'foo']; - $a2 = ['fieldName' => 'foo', 'sourceEntity' => \stdClass::class, 'targetEntity' => \stdClass::class, 'mappedBy' => 'foo']; + $a1 = ['fieldName' => 'foo', 'sourceEntity' => stdClass::class, 'targetEntity' => stdClass::class, 'mappedBy' => 'foo']; + $a2 = ['fieldName' => 'foo', 'sourceEntity' => stdClass::class, 'targetEntity' => stdClass::class, 'mappedBy' => 'foo']; $cm->addInheritedAssociationMapping($a1); $this->expectException(MappingException::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index feb3b3af060..f1e20934feb 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -4,10 +4,11 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; use Doctrine\Tests\Models\Company\CompanyContractListener; use Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener; -use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; use Doctrine\Tests\OrmTestCase; +use InvalidArgumentException; /** * @group DDC-1955 @@ -89,7 +90,7 @@ public function testClearAll(): void public function testRegisterStringException(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('An object was expected, but got "string".'); $this->resolver->register('CompanyContractListener'); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php index 185364fcfad..5d47f6b3c36 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmTestCase; +use stdClass; class FieldBuilderTest extends OrmTestCase { @@ -18,11 +19,11 @@ public function testCustomIdGeneratorCanBeSet(): void $fieldBuilder = $cmBuilder->createField('aField', 'string'); $fieldBuilder->generatedValue('CUSTOM'); - $fieldBuilder->setCustomIdGenerator(\stdClass::class); + $fieldBuilder->setCustomIdGenerator(stdClass::class); $fieldBuilder->build(); self::assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $cmBuilder->getClassMetadata()->generatorType); - self::assertEquals(['class' => \stdClass::class], $cmBuilder->getClassMetadata()->customGeneratorDefinition); + self::assertEquals(['class' => stdClass::class], $cmBuilder->getClassMetadata()->customGeneratorDefinition); } } diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index c3fab8a4dd8..3249ce27dd8 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -4,20 +4,20 @@ namespace Doctrine\Tests\ORM\Query; -use Doctrine\ORM\Query\AST\SelectStatement; -use Doctrine\ORM\Query\TreeWalkerAdapter; -use Doctrine\ORM\Query\AST\PathExpression; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST\ComparisonExpression; -use Doctrine\ORM\Query\AST\ConditionalPrimary; -use Doctrine\ORM\Query\AST\ConditionalFactor; use Doctrine\ORM\Query\AST\ConditionalExpression; +use Doctrine\ORM\Query\AST\ConditionalFactor; +use Doctrine\ORM\Query\AST\ConditionalPrimary; use Doctrine\ORM\Query\AST\ConditionalTerm; +use Doctrine\ORM\Query\AST\PathExpression; +use Doctrine\ORM\Query\AST\SelectStatement; use Doctrine\ORM\Query\AST\WhereClause; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Query; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TreeWalker; +use Doctrine\ORM\Query\TreeWalkerAdapter; use Doctrine\Tests\Mocks\CustomTreeWalkerJoin; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmTestCase; diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index 33e08889ccb..cd6d679dfa3 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\Query\Expr\Comparison; use Doctrine\ORM\Query\Expr\From; @@ -15,11 +17,10 @@ use Doctrine\ORM\Query\Expr\OrderBy; use Doctrine\ORM\Query\Expr\Orx; use Doctrine\ORM\Query\Expr\Select; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Query\Expr; use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\OrmTestCase; use Generator; +use InvalidArgumentException; /** * Test case for the DQL Expr class used for generating DQL snippets through @@ -383,7 +384,7 @@ public function testOrderByAsc(): void public function testAddThrowsException(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $orExpr = $this->expr->orX(); $orExpr->add($this->expr->quot(5, 2)); } diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index 7f01d3449a8..0af1d5779a1 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -4,8 +4,6 @@ namespace Doctrine\Tests\ORM\Query; -use Doctrine\ORM\Query\Parser; -use Doctrine\ORM\Query\AST\Functions\ConcatFunction; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -13,6 +11,8 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Query; +use Doctrine\ORM\Query\AST\Functions\ConcatFunction; +use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\ParserResult; use Doctrine\ORM\Query\QueryException; use Doctrine\Tests\Mocks\NullSqlWalker; @@ -733,10 +733,8 @@ class DQLKeywordsModelUser */ private int $id; - /** - * @OneToOne(targetEntity="DQLKeywordsModelGroup") - */ - private \Doctrine\Tests\ORM\Query\DQLKeywordsModelGroup $group; + /** @OneToOne(targetEntity="DQLKeywordsModelGroup") */ + private DQLKeywordsModelGroup $group; } /** @Entity */ @@ -749,9 +747,7 @@ class DQLKeywordsModelGroup */ private int $id; - /** - * @Column - */ + /** @Column */ private string $from; } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index d1ea3e835c5..bf975b5d34c 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\ORM\Query; -use Doctrine\DBAL\Driver\Result; use DateTime; use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Types; diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 345f4999ec0..ba04c8753b7 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -30,7 +30,6 @@ use Doctrine\Tests\OrmTestCase; use Exception; -use function get_class; use function sprintf; class SelectSqlGenerationTest extends OrmTestCase @@ -2368,8 +2367,7 @@ public function __construct( * @Column(type="float") */ private string $value - ) - { + ) { } public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 5b583799328..8de1f8a56d7 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -21,7 +21,6 @@ use InvalidArgumentException; use function array_filter; -use function get_class; /** * Test case for the QueryBuilder class used to build DQL query string in a diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php index 9bb041713dd..909e3046ff2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Tools; -use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadataFactory; @@ -13,6 +12,7 @@ use Doctrine\ORM\Mapping\EntityListeners; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Tools\AttachEntityListenersListener; use Doctrine\Tests\OrmTestCase; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php index a04e046d3a3..8a173ddb51c 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\Models\Cache\AttractionInfo; use Doctrine\Tests\OrmFunctionalTestCase; +use InvalidArgumentException; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -52,7 +53,7 @@ public function testShowSpecificFuzzySingle(): void public function testShowSpecificFuzzyAmbiguous(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('possible matches'); $this->tester->execute( [ @@ -64,7 +65,7 @@ public function testShowSpecificFuzzyAmbiguous(): void public function testShowSpecificNotFound(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Could not find any mapped Entity classes matching "AttractionFooBar"'); $this->tester->execute( [ diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index 240d4b0d794..877643a05e9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Tools\Pagination; -use Doctrine\ORM\Query\QueryException; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -12,6 +11,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Query; +use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\MockObject\MockObject; diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index f4ff03ea70c..36acf92beb9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -141,10 +141,8 @@ class ResolveTargetEntity implements ResolveTarget */ private $manyToMany; - /** - * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTarget", inversedBy="oneToMany") - */ - private \Doctrine\Tests\ORM\Tools\ResolveTarget $manyToOne; + /** @ManyToOne(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTarget", inversedBy="oneToMany") */ + private ResolveTarget $manyToOne; /** * @psalm-var Collection @@ -156,7 +154,7 @@ class ResolveTargetEntity implements ResolveTarget * @OneToOne(targetEntity="Doctrine\Tests\ORM\Tools\Target") * @JoinColumn(name="target_entity_id", referencedColumnName="id") */ - private \Doctrine\Tests\ORM\Tools\Target $oneToOne; + private Target $oneToOne; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index a3c829f6581..fde54c86899 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -398,9 +398,7 @@ class TestEntityWithAnnotationOptionsAttribute */ private int $id; - /** - * @Column(type="string", options={"foo": "bar", "baz": {"key": "val"}}) - */ + /** @Column(type="string", options={"foo": "bar", "baz": {"key": "val"}}) */ private string $test; } @@ -437,9 +435,7 @@ class UniqueConstraintAnnotationModel */ private int $id; - /** - * @Column(name="hash", type="string", length=8, nullable=false, unique=true) - */ + /** @Column(name="hash", type="string", length=8, nullable=false, unique=true) */ private string $hash; } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index b6e51fb066a..4e6a0240a94 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -343,9 +343,7 @@ class DDC1587ValidEntity1 */ private int $pk; - /** - * @Column(name="name", type="string", length=32) - */ + /** @Column(name="name", type="string", length=32) */ private string $name; /** @@ -367,11 +365,9 @@ class DDC1587ValidEntity2 * @OneToOne(targetEntity="DDC1587ValidEntity1", inversedBy="identifier") * @JoinColumn(name="pk_agent", referencedColumnName="pk", nullable=false) */ - private \Doctrine\Tests\ORM\Tools\DDC1587ValidEntity1 $agent; + private DDC1587ValidEntity1 $agent; - /** - * @Column(name="num", type="string", length=16, nullable=true) - */ + /** @Column(name="num", type="string", length=16, nullable=true) */ private string $num; } @@ -411,7 +407,7 @@ class DDC1649Three * @ManyToOne(targetEntity="DDC1649Two") * @JoinColumn(name="id", referencedColumnName="id") */ - private \Doctrine\Tests\ORM\Tools\DDC1649Two $two; + private DDC1649Two $two; } /** @@ -427,9 +423,7 @@ class DDC3274One */ private $id; - /** - * @OneToMany(targetEntity="DDC3274Two", mappedBy="one") - */ + /** @OneToMany(targetEntity="DDC3274Two", mappedBy="one") */ private ArrayCollection $two; } @@ -442,7 +436,7 @@ class DDC3274Two * @Id * @ManyToOne(targetEntity="DDC3274One") */ - private \Doctrine\Tests\ORM\Tools\DDC3274One $one; + private DDC3274One $one; } /** @@ -458,10 +452,8 @@ class Issue9536Target */ private $id; - /** - * @OneToOne(targetEntity="Issue9536Owner") - */ - private \Doctrine\Tests\ORM\Tools\Issue9536Owner $two; + /** @OneToOne(targetEntity="Issue9536Owner") */ + private Issue9536Owner $two; } /** @@ -477,10 +469,8 @@ class Issue9536Owner */ private $id; - /** - * @OneToOne(targetEntity="Issue9536Target", inversedBy="two") - */ - private \Doctrine\Tests\ORM\Tools\Issue9536Target $one; + /** @OneToOne(targetEntity="Issue9536Target", inversedBy="two") */ + private Issue9536Target $one; } /** @@ -496,55 +486,35 @@ class DDC3322ValidEntity1 */ private $id; - /** - * @ManyToOne(targetEntity="DDC3322One", inversedBy="validAssoc") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322One $oneValid; + /** @ManyToOne(targetEntity="DDC3322One", inversedBy="validAssoc") */ + private DDC3322One $oneValid; - /** - * @ManyToOne(targetEntity="DDC3322One", inversedBy="invalidAssoc") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322One $oneInvalid; + /** @ManyToOne(targetEntity="DDC3322One", inversedBy="invalidAssoc") */ + private DDC3322One $oneInvalid; - /** - * @ManyToOne(targetEntity="DDC3322Two", inversedBy="validAssoc") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322Two $twoValid; + /** @ManyToOne(targetEntity="DDC3322Two", inversedBy="validAssoc") */ + private DDC3322Two $twoValid; - /** - * @ManyToOne(targetEntity="DDC3322Two", inversedBy="invalidAssoc") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322Two $twoInvalid; + /** @ManyToOne(targetEntity="DDC3322Two", inversedBy="invalidAssoc") */ + private DDC3322Two $twoInvalid; - /** - * @ManyToOne(targetEntity="DDC3322Three", inversedBy="validAssoc") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322Three $threeValid; + /** @ManyToOne(targetEntity="DDC3322Three", inversedBy="validAssoc") */ + private DDC3322Three $threeValid; - /** - * @ManyToOne(targetEntity="DDC3322Three", inversedBy="invalidAssoc") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322Three $threeInvalid; + /** @ManyToOne(targetEntity="DDC3322Three", inversedBy="invalidAssoc") */ + private DDC3322Three $threeInvalid; - /** - * @OneToMany(targetEntity="DDC3322ValidEntity2", mappedBy="manyToOne") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity2 $oneToMany; + /** @OneToMany(targetEntity="DDC3322ValidEntity2", mappedBy="manyToOne") */ + private DDC3322ValidEntity2 $oneToMany; - /** - * @ManyToOne(targetEntity="DDC3322ValidEntity2", inversedBy="oneToMany") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity2 $manyToOne; + /** @ManyToOne(targetEntity="DDC3322ValidEntity2", inversedBy="oneToMany") */ + private DDC3322ValidEntity2 $manyToOne; - /** - * @OneToOne(targetEntity="DDC3322ValidEntity2", mappedBy="oneToOneOwning") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity2 $oneToOneInverse; + /** @OneToOne(targetEntity="DDC3322ValidEntity2", mappedBy="oneToOneOwning") */ + private DDC3322ValidEntity2 $oneToOneInverse; - /** - * @OneToOne(targetEntity="DDC3322ValidEntity2", inversedBy="oneToOneInverse") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity2 $oneToOneOwning; + /** @OneToOne(targetEntity="DDC3322ValidEntity2", inversedBy="oneToOneInverse") */ + private DDC3322ValidEntity2 $oneToOneOwning; } /** @@ -559,25 +529,17 @@ class DDC3322ValidEntity2 */ private int $id; - /** - * @ManyToOne(targetEntity="DDC3322ValidEntity1", inversedBy="oneToMany") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $manyToOne; + /** @ManyToOne(targetEntity="DDC3322ValidEntity1", inversedBy="oneToMany") */ + private DDC3322ValidEntity1 $manyToOne; - /** - * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="manyToOne") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $oneToMany; + /** @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="manyToOne") */ + private DDC3322ValidEntity1 $oneToMany; - /** - * @OneToOne(targetEntity="DDC3322ValidEntity1", inversedBy="oneToOneInverse") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $oneToOneOwning; + /** @OneToOne(targetEntity="DDC3322ValidEntity1", inversedBy="oneToOneInverse") */ + private DDC3322ValidEntity1 $oneToOneOwning; - /** - * @OneToOne(targetEntity="DDC3322ValidEntity1", mappedBy="oneToOneOwning") - */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $oneToOneInverse; + /** @OneToOne(targetEntity="DDC3322ValidEntity1", mappedBy="oneToOneOwning") */ + private DDC3322ValidEntity1 $oneToOneInverse; } /** @@ -650,7 +612,7 @@ class DDC3322Three * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="threeValid") * @OrderBy({"oneToOneOwning" = "ASC"}) */ - private \Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 $validAssoc; + private DDC3322ValidEntity1 $validAssoc; /** * @psalm-var Collection @@ -665,8 +627,6 @@ class DDC3322Three */ class EmbeddableWithAssociation { - /** - * @OneToOne(targetEntity="Doctrine\Tests\Models\ECommerce\ECommerceCart") - */ + /** @OneToOne(targetEntity="Doctrine\Tests\Models\ECommerce\ECommerceCart") */ private ECommerceCart $cart; } diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 8538a972711..1aca9b3c457 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -4,14 +4,13 @@ namespace Doctrine\Tests\ORM; -use Doctrine\DBAL\Driver\Statement; -use Doctrine\DBAL\Exception; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\EventManager; -use Doctrine\DBAL; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Mapping\ClassMetadata; @@ -37,7 +36,6 @@ use PHPUnit\Framework\MockObject\MockObject; use stdClass; -use function get_class; use function method_exists; use function random_int; use function uniqid; @@ -731,10 +729,8 @@ class NotifyChangedRelatedItem */ private int $id; - /** - * @ManyToOne(targetEntity="NotifyChangedEntity", inversedBy="items") - */ - private ?\Doctrine\Tests\ORM\NotifyChangedEntity $owner = null; + /** @ManyToOne(targetEntity="NotifyChangedEntity", inversedBy="items") */ + private ?NotifyChangedEntity $owner = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 2b13248eb53..9a2c61ecd5c 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -4,168 +4,168 @@ namespace Doctrine\Tests; -use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; +use Doctrine\DBAL\Platforms\MySQLPlatform; +use Doctrine\DBAL\Platforms\OraclePlatform; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; +use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Cache\CacheConfiguration; +use Doctrine\ORM\Cache\DefaultCacheFactory; +use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Exception\ORMException; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\ORMSetup; +use Doctrine\ORM\Tools\DebugUnitOfWorkListener; +use Doctrine\ORM\Tools\SchemaTool; +use Doctrine\ORM\Tools\ToolsException; +use Doctrine\Persistence\Mapping\Driver\MappingDriver; +use Doctrine\Tests\DbalExtensions\Connection; +use Doctrine\Tests\DbalExtensions\QueryLog; +use Doctrine\Tests\DbalTypes\Rot13Type; +use Doctrine\Tests\EventListener\CacheMetadataListener; +use Doctrine\Tests\Models\Cache\Action; +use Doctrine\Tests\Models\Cache\Address; +use Doctrine\Tests\Models\Cache\Attraction; +use Doctrine\Tests\Models\Cache\AttractionContactInfo; +use Doctrine\Tests\Models\Cache\AttractionInfo; +use Doctrine\Tests\Models\Cache\AttractionLocationInfo; +use Doctrine\Tests\Models\Cache\Bar; +use Doctrine\Tests\Models\Cache\Beach; +use Doctrine\Tests\Models\Cache\City; +use Doctrine\Tests\Models\Cache\Client; +use Doctrine\Tests\Models\Cache\ComplexAction; +use Doctrine\Tests\Models\Cache\Country; +use Doctrine\Tests\Models\Cache\Flight; +use Doctrine\Tests\Models\Cache\Login; +use Doctrine\Tests\Models\Cache\Person; +use Doctrine\Tests\Models\Cache\Restaurant; +use Doctrine\Tests\Models\Cache\State; +use Doctrine\Tests\Models\Cache\Token; +use Doctrine\Tests\Models\Cache\Travel; +use Doctrine\Tests\Models\Cache\Traveler; +use Doctrine\Tests\Models\Cache\TravelerProfile; +use Doctrine\Tests\Models\Cache\TravelerProfileInfo; use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsTag; -use Doctrine\Tests\Models\CMS\CmsArticle; -use Doctrine\Tests\Models\CMS\CmsComment; -use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\Models\Company\CompanyAuction; +use Doctrine\Tests\Models\Company\CompanyCar; +use Doctrine\Tests\Models\Company\CompanyContract; use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyEvent; use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\Models\Company\CompanyOrganization; -use Doctrine\Tests\Models\Company\CompanyEvent; -use Doctrine\Tests\Models\Company\CompanyAuction; +use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\Company\CompanyRaffle; -use Doctrine\Tests\Models\Company\CompanyCar; -use Doctrine\Tests\Models\Company\CompanyContract; +use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedChildClass; +use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass; +use Doctrine\Tests\Models\CompositeKeyInheritance\SingleChildClass; +use Doctrine\Tests\Models\CompositeKeyInheritance\SingleRootClass; +use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild; +use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent; +use Doctrine\Tests\Models\CustomType\CustomTypeChild; +use Doctrine\Tests\Models\CustomType\CustomTypeParent; +use Doctrine\Tests\Models\CustomType\CustomTypeUpperCase; +use Doctrine\Tests\Models\DDC117\DDC117ApproveChanges; +use Doctrine\Tests\Models\DDC117\DDC117Article; +use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails; +use Doctrine\Tests\Models\DDC117\DDC117Editor; +use Doctrine\Tests\Models\DDC117\DDC117Link; +use Doctrine\Tests\Models\DDC117\DDC117Reference; +use Doctrine\Tests\Models\DDC117\DDC117Translation; +use Doctrine\Tests\Models\DDC2504\DDC2504ChildClass; +use Doctrine\Tests\Models\DDC2504\DDC2504OtherClass; +use Doctrine\Tests\Models\DDC2504\DDC2504RootClass; +use Doctrine\Tests\Models\DDC3346\DDC3346Article; +use Doctrine\Tests\Models\DDC3346\DDC3346Author; +use Doctrine\Tests\Models\DDC3699\DDC3699Child; +use Doctrine\Tests\Models\DDC3699\DDC3699Parent; +use Doctrine\Tests\Models\DDC3699\DDC3699RelationMany; +use Doctrine\Tests\Models\DDC3699\DDC3699RelationOne; +use Doctrine\Tests\Models\DirectoryTree\AbstractContentItem; +use Doctrine\Tests\Models\DirectoryTree\Directory; +use Doctrine\Tests\Models\DirectoryTree\File; use Doctrine\Tests\Models\ECommerce\ECommerceCart; +use Doctrine\Tests\Models\ECommerce\ECommerceCategory; use Doctrine\Tests\Models\ECommerce\ECommerceCustomer; +use Doctrine\Tests\Models\ECommerce\ECommerceFeature; use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\Models\ECommerce\ECommerceShipping; -use Doctrine\Tests\Models\ECommerce\ECommerceFeature; -use Doctrine\Tests\Models\ECommerce\ECommerceCategory; use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\Models\Generic\DecimalModel; use Doctrine\Tests\Models\Generic\SerializationModel; +use Doctrine\Tests\Models\GeoNames\Admin1; +use Doctrine\Tests\Models\GeoNames\Admin1AlternateName; +use Doctrine\Tests\Models\Issue5989\Issue5989Employee; +use Doctrine\Tests\Models\Issue5989\Issue5989Manager; +use Doctrine\Tests\Models\Issue5989\Issue5989Person; +use Doctrine\Tests\Models\Legacy\LegacyArticle; +use Doctrine\Tests\Models\Legacy\LegacyCar; +use Doctrine\Tests\Models\Legacy\LegacyUser; +use Doctrine\Tests\Models\Legacy\LegacyUserReference; +use Doctrine\Tests\Models\Navigation\NavCountry; +use Doctrine\Tests\Models\Navigation\NavPhotos; +use Doctrine\Tests\Models\Navigation\NavPointOfInterest; +use Doctrine\Tests\Models\Navigation\NavTour; +use Doctrine\Tests\Models\Navigation\NavUser; +use Doctrine\Tests\Models\Pagination\Company; +use Doctrine\Tests\Models\Pagination\Department; +use Doctrine\Tests\Models\Pagination\Logo; +use Doctrine\Tests\Models\Pagination\User1; +use Doctrine\Tests\Models\Quote\FullAddress; +use Doctrine\Tests\Models\Quote\Group; +use Doctrine\Tests\Models\Quote\NumericEntity; +use Doctrine\Tests\Models\Quote\Phone; use Doctrine\Tests\Models\Routing\RoutingLeg; use Doctrine\Tests\Models\Routing\RoutingLocation; use Doctrine\Tests\Models\Routing\RoutingRoute; use Doctrine\Tests\Models\Routing\RoutingRouteBooking; -use Doctrine\Tests\Models\Navigation\NavUser; -use Doctrine\Tests\Models\Navigation\NavCountry; -use Doctrine\Tests\Models\Navigation\NavPhotos; -use Doctrine\Tests\Models\Navigation\NavTour; -use Doctrine\Tests\Models\Navigation\NavPointOfInterest; -use Doctrine\Tests\Models\DirectoryTree\AbstractContentItem; -use Doctrine\Tests\Models\DirectoryTree\File; -use Doctrine\Tests\Models\DirectoryTree\Directory; -use Doctrine\Tests\Models\DDC117\DDC117Article; -use Doctrine\Tests\Models\DDC117\DDC117Reference; -use Doctrine\Tests\Models\DDC117\DDC117Translation; -use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails; -use Doctrine\Tests\Models\DDC117\DDC117ApproveChanges; -use Doctrine\Tests\Models\DDC117\DDC117Editor; -use Doctrine\Tests\Models\DDC117\DDC117Link; -use Doctrine\Tests\Models\DDC3699\DDC3699Parent; -use Doctrine\Tests\Models\DDC3699\DDC3699RelationOne; -use Doctrine\Tests\Models\DDC3699\DDC3699RelationMany; -use Doctrine\Tests\Models\DDC3699\DDC3699Child; use Doctrine\Tests\Models\StockExchange\Bond; -use Doctrine\Tests\Models\StockExchange\Stock; use Doctrine\Tests\Models\StockExchange\Market; -use Doctrine\Tests\Models\Legacy\LegacyUser; -use Doctrine\Tests\Models\Legacy\LegacyUserReference; -use Doctrine\Tests\Models\Legacy\LegacyArticle; -use Doctrine\Tests\Models\Legacy\LegacyCar; -use Doctrine\Tests\Models\CustomType\CustomTypeChild; -use Doctrine\Tests\Models\CustomType\CustomTypeParent; -use Doctrine\Tests\Models\CustomType\CustomTypeUpperCase; -use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass; -use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedChildClass; -use Doctrine\Tests\Models\CompositeKeyInheritance\SingleRootClass; -use Doctrine\Tests\Models\CompositeKeyInheritance\SingleChildClass; -use Doctrine\Tests\Models\Taxi\PaidRide; -use Doctrine\Tests\Models\Taxi\Ride; +use Doctrine\Tests\Models\StockExchange\Stock; use Doctrine\Tests\Models\Taxi\Car; use Doctrine\Tests\Models\Taxi\Driver; -use Doctrine\Tests\Models\Cache\Country; -use Doctrine\Tests\Models\Cache\State; -use Doctrine\Tests\Models\Cache\City; -use Doctrine\Tests\Models\Cache\Traveler; -use Doctrine\Tests\Models\Cache\TravelerProfileInfo; -use Doctrine\Tests\Models\Cache\TravelerProfile; -use Doctrine\Tests\Models\Cache\Travel; -use Doctrine\Tests\Models\Cache\Attraction; -use Doctrine\Tests\Models\Cache\Restaurant; -use Doctrine\Tests\Models\Cache\Beach; -use Doctrine\Tests\Models\Cache\Bar; -use Doctrine\Tests\Models\Cache\Flight; -use Doctrine\Tests\Models\Cache\Token; -use Doctrine\Tests\Models\Cache\Login; -use Doctrine\Tests\Models\Cache\Client; -use Doctrine\Tests\Models\Cache\Person; -use Doctrine\Tests\Models\Cache\Address; -use Doctrine\Tests\Models\Cache\Action; -use Doctrine\Tests\Models\Cache\ComplexAction; -use Doctrine\Tests\Models\Cache\AttractionInfo; -use Doctrine\Tests\Models\Cache\AttractionContactInfo; -use Doctrine\Tests\Models\Cache\AttractionLocationInfo; -use Doctrine\Tests\Models\Tweet\User; +use Doctrine\Tests\Models\Taxi\PaidRide; +use Doctrine\Tests\Models\Taxi\Ride; use Doctrine\Tests\Models\Tweet\Tweet; +use Doctrine\Tests\Models\Tweet\User; use Doctrine\Tests\Models\Tweet\UserList; -use Doctrine\Tests\Models\DDC2504\DDC2504RootClass; -use Doctrine\Tests\Models\DDC2504\DDC2504ChildClass; -use Doctrine\Tests\Models\DDC2504\DDC2504OtherClass; -use Doctrine\Tests\Models\DDC3346\DDC3346Author; -use Doctrine\Tests\Models\DDC3346\DDC3346Article; -use Doctrine\Tests\Models\Quote\FullAddress; -use Doctrine\Tests\Models\Quote\Group; -use Doctrine\Tests\Models\Quote\NumericEntity; -use Doctrine\Tests\Models\Quote\Phone; -use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity; -use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity; -use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity; -use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity; use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; -use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity; -use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity; -use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity; -use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyExtraLazyEntity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity; -use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity; -use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity; use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity; -use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity; -use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity; -use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity; -use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity; -use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity; -use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyExtraLazyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyExtraLazyEntity; -use Doctrine\Tests\Models\GeoNames\Admin1; -use Doctrine\Tests\Models\GeoNames\Admin1AlternateName; -use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent; -use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild; -use Doctrine\Tests\Models\Pagination\Company; -use Doctrine\Tests\Models\Pagination\Logo; -use Doctrine\Tests\Models\Pagination\Department; -use Doctrine\Tests\Models\Pagination\User1; -use Doctrine\Tests\Models\VersionedManyToOne\Category; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity; +use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity; use Doctrine\Tests\Models\VersionedManyToOne\Article; -use Doctrine\Tests\Models\Issue5989\Issue5989Person; -use Doctrine\Tests\Models\Issue5989\Issue5989Employee; -use Doctrine\Tests\Models\Issue5989\Issue5989Manager; -use Doctrine\Tests\DbalExtensions\Connection; -use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; -use Doctrine\DBAL\Platforms\MySQLPlatform; -use Doctrine\DBAL\Platforms\OraclePlatform; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\DBAL\Schema\AbstractSchemaManager; -use Doctrine\DBAL\Schema\Table; -use Doctrine\DBAL\Types\Type; -use Doctrine\ORM\Cache\CacheConfiguration; -use Doctrine\ORM\Cache\DefaultCacheFactory; -use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger; -use Doctrine\ORM\Configuration; -use Doctrine\ORM\EntityManager; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Exception\ORMException; -use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\ORMSetup; -use Doctrine\ORM\Tools\DebugUnitOfWorkListener; -use Doctrine\ORM\Tools\SchemaTool; -use Doctrine\ORM\Tools\ToolsException; -use Doctrine\Persistence\Mapping\Driver\MappingDriver; -use Doctrine\Tests\DbalExtensions\QueryLog; -use Doctrine\Tests\DbalTypes\Rot13Type; -use Doctrine\Tests\EventListener\CacheMetadataListener; +use Doctrine\Tests\Models\VersionedManyToOne\Category; use Exception; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\Constraint\Count; @@ -484,7 +484,7 @@ final protected function createSchemaForModels(string ...$models): void { try { $this->_schemaTool->createSchema(array_map( - fn(string $className): ClassMetadata => $this->_em->getClassMetadata($className), + fn (string $className): ClassMetadata => $this->_em->getClassMetadata($className), $models )); } catch (ToolsException) { @@ -963,7 +963,7 @@ protected function onNotSuccessfulTest(Throwable $e): void $queries = ''; $last25queries = array_slice(array_reverse($this->getQueryLog()->queries, true), 0, 25, true); foreach ($last25queries as $i => $query) { - $params = array_map(static fn($p) => is_object($p) ? get_debug_type($p) : var_export($p, true), $query['params'] ?: []); + $params = array_map(static fn ($p) => is_object($p) ? get_debug_type($p) : var_export($p, true), $query['params'] ?: []); $queries .= $i . ". SQL: '" . $query['sql'] . "' Params: " . implode(', ', $params) . PHP_EOL; } diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 9042b3c9ad4..998b877bcc2 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -4,12 +4,11 @@ namespace Doctrine\Tests; -use Doctrine\Common\Annotations\PsrCachedReader; use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\DBAL\Driver\Result; -use Doctrine\Common\Annotations; +use Doctrine\Common\Annotations\PsrCachedReader; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\SchemaConfig; @@ -152,7 +151,7 @@ private function createConnectionMock(AbstractPlatform $platform): Connection ->setConstructorArgs([[], $this->createDriverMock($platform)]) ->onlyMethods(['quote']) ->getMockForAbstractClass(); - $connection->method('quote')->willReturnCallback(static fn(string $input) => sprintf("'%s'", $input)); + $connection->method('quote')->willReturnCallback(static fn (string $input) => sprintf("'%s'", $input)); return $connection; } From a8702905750dd087a5a6ea36e656c77afce17a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 1 Jun 2022 21:37:33 +0200 Subject: [PATCH 109/475] Add test to exclude rule --- phpcs.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index a3610445083..f876d8420ce 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -248,6 +248,7 @@ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php + tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php From 4117209b69010bb6f2c163e47c15b19d406452c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 2 Jun 2022 07:23:11 +0200 Subject: [PATCH 110/475] Revert to normal properties The order is not the same as in the constructor, and that seems to matter. --- .../Models/Navigation/NavPointOfInterest.php | 26 ++++++++++++------- .../Functional/CompositePrimaryKeyTest.php | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php index 33c7c52a252..6cb9c496598 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php @@ -21,6 +21,18 @@ */ class NavPointOfInterest { + /** + * @Id + * @Column(type="integer", name="nav_long") + */ + private int $long; + + /** + * @Id + * @Column(type="integer", name="nav_lat") + */ + private int $lat; + /** * @psalm-var Collection * @ManyToMany(targetEntity="NavUser", cascade={"persist"}) @@ -35,16 +47,8 @@ class NavPointOfInterest private $visitors; public function __construct( - /** - * @Id - * @Column(type="integer", name="nav_lat") - */ - private int $lat, - /** - * @Id - * @Column(type="integer", name="nav_long") - */ - private int $long, + int $lat, + int $long, /** * @Column(type="string", length=255) */ @@ -54,6 +58,8 @@ public function __construct( */ private NavCountry $country ) { + $this->lat = $lat; + $this->long = $long; $this->visitors = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php index 986046b9a36..7a5f35bf5ce 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -155,7 +155,7 @@ public function testCompositeCollectionMemberExpression(): void public function testSpecifyUnknownIdentifierPrimaryKeyFails(): void { $this->expectException(MissingIdentifierField::class); - $this->expectExceptionMessage('The identifier lat is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); + $this->expectExceptionMessage('The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); $poi = $this->_em->find(NavPointOfInterest::class, ['key1' => 100]); } From 86d23f42db6b0be63cc8fad5bc9aebfaa4183da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 21 May 2022 14:53:28 +0200 Subject: [PATCH 111/475] Add native types to AbstractQuery --- lib/Doctrine/ORM/AbstractQuery.php | 259 +++++++++-------------------- lib/Doctrine/ORM/NativeQuery.php | 19 +-- lib/Doctrine/ORM/Query.php | 99 +++-------- 3 files changed, 112 insertions(+), 265 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index dee6e53eb25..e1f8e248a7e 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -86,80 +86,63 @@ abstract class AbstractQuery * @var ArrayCollection|Parameter[] * @psalm-var ArrayCollection */ - protected $parameters; + protected ArrayCollection $parameters; /** * The user-specified ResultSetMapping to use. - * - * @var ResultSetMapping|null */ - protected $_resultSetMapping; + protected ?ResultSetMapping $_resultSetMapping = null; /** * The entity manager used by this query object. - * - * @var EntityManagerInterface */ - protected $_em; + protected EntityManagerInterface $_em; /** * The map of query hints. * * @psalm-var array */ - protected $_hints = []; + protected array $_hints = []; /** * The hydration mode. * - * @var string|int * @psalm-var string|AbstractQuery::HYDRATE_* */ - protected $_hydrationMode = self::HYDRATE_OBJECT; + protected string|int $_hydrationMode = self::HYDRATE_OBJECT; - /** @var QueryCacheProfile|null */ - protected $_queryCacheProfile; + protected ?QueryCacheProfile $_queryCacheProfile = null; /** * Whether or not expire the result cache. - * - * @var bool */ - protected $_expireResultCache = false; + protected bool $_expireResultCache = false; - /** @var QueryCacheProfile|null */ - protected $_hydrationCacheProfile; + protected ?QueryCacheProfile $_hydrationCacheProfile = null; /** * Whether to use second level cache, if available. - * - * @var bool */ - protected $cacheable = false; + protected bool $cacheable = false; - /** @var bool */ - protected $hasCache = false; + protected bool $hasCache = false; /** * Second level cache region name. - * - * @var string|null */ - protected $cacheRegion; + protected ?string $cacheRegion = null; /** * Second level query cache mode. * - * @var int|null * @psalm-var Cache::MODE_*|null */ - protected $cacheMode; + protected ?int $cacheMode = null; - /** @var CacheLogger|null */ - protected $cacheLogger; + protected ?CacheLogger $cacheLogger = null; - /** @var int */ - protected $lifetime = 0; + protected int $lifetime = 0; /** * Initializes a new instance of a class derived from AbstractQuery. @@ -181,13 +164,11 @@ public function __construct(EntityManagerInterface $em) /** * Enable/disable second level query (result) caching for this query. * - * @param bool $cacheable - * * @return $this */ - public function setCacheable($cacheable) + public function setCacheable(bool $cacheable): static { - $this->cacheable = (bool) $cacheable; + $this->cacheable = $cacheable; return $this; } @@ -195,19 +176,17 @@ public function setCacheable($cacheable) /** * @return bool TRUE if the query results are enable for second level cache, FALSE otherwise. */ - public function isCacheable() + public function isCacheable(): bool { return $this->cacheable; } /** - * @param string $cacheRegion - * * @return $this */ - public function setCacheRegion($cacheRegion) + public function setCacheRegion(string $cacheRegion): static { - $this->cacheRegion = (string) $cacheRegion; + $this->cacheRegion = $cacheRegion; return $this; } @@ -217,7 +196,7 @@ public function setCacheRegion($cacheRegion) * * @return string|null The cache region name; NULL indicates the default region. */ - public function getCacheRegion() + public function getCacheRegion(): ?string { return $this->cacheRegion; } @@ -225,15 +204,12 @@ public function getCacheRegion() /** * @return bool TRUE if the query cache and second level cache are enabled, FALSE otherwise. */ - protected function isCacheEnabled() + protected function isCacheEnabled(): bool { return $this->cacheable && $this->hasCache; } - /** - * @return int - */ - public function getLifetime() + public function getLifetime(): int { return $this->lifetime; } @@ -241,35 +217,31 @@ public function getLifetime() /** * Sets the life-time for this query into second level cache. * - * @param int $lifetime - * * @return $this */ - public function setLifetime($lifetime) + public function setLifetime(int $lifetime): static { - $this->lifetime = (int) $lifetime; + $this->lifetime = $lifetime; return $this; } /** - * @return int|null * @psalm-return Cache::MODE_*|null */ - public function getCacheMode() + public function getCacheMode(): ?int { return $this->cacheMode; } /** - * @param int $cacheMode * @psalm-param Cache::MODE_* $cacheMode * * @return $this */ - public function setCacheMode($cacheMode) + public function setCacheMode(int $cacheMode): static { - $this->cacheMode = (int) $cacheMode; + $this->cacheMode = $cacheMode; return $this; } @@ -281,14 +253,12 @@ public function setCacheMode($cacheMode) * * @return list|string SQL query */ - abstract public function getSQL(); + abstract public function getSQL(): string|array; /** * Retrieves the associated EntityManager of this Query instance. - * - * @return EntityManagerInterface */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { return $this->_em; } @@ -297,10 +267,8 @@ public function getEntityManager() * Frees the resources used by the query object. * * Resets Parameters, Parameter Types and Query Hints. - * - * @return void */ - public function free() + public function free(): void { $this->parameters = new ArrayCollection(); @@ -310,10 +278,9 @@ public function free() /** * Get all defined parameters. * - * @return ArrayCollection The defined query parameters. * @psalm-return ArrayCollection */ - public function getParameters() + public function getParameters(): ArrayCollection { return $this->parameters; } @@ -325,7 +292,7 @@ public function getParameters() * * @return Parameter|null The value of the bound parameter, or NULL if not available. */ - public function getParameter($key) + public function getParameter($key): ?Parameter { $key = Query\Parameter::normalizeName($key); @@ -348,7 +315,7 @@ static function (Query\Parameter $parameter) use ($key): bool { * * @return $this */ - public function setParameters($parameters) + public function setParameters(ArrayCollection|array $parameters): static { if (is_array($parameters)) { /** @psalm-var ArrayCollection $parameterCollection */ @@ -377,7 +344,7 @@ public function setParameters($parameters) * * @return $this */ - public function setParameter($key, $value, $type = null) + public function setParameter(string|int $key, mixed $value, string|int|null $type = null): static { $existingParameter = $this->getParameter($key); @@ -395,13 +362,9 @@ public function setParameter($key, $value, $type = null) /** * Processes an individual parameter value. * - * @param mixed $value - * - * @return mixed - * * @throws ORMInvalidArgumentException */ - public function processParameterValue($value) + public function processParameterValue(mixed $value): mixed { if (is_scalar($value)) { return $value; @@ -451,12 +414,8 @@ public function processParameterValue($value) /** * If no mapping is detected, trying to resolve the value as a Traversable - * - * @param mixed $value - * - * @return mixed */ - private function potentiallyProcessIterable($value) + private function potentiallyProcessIterable(mixed $value): mixed { if ($value instanceof Traversable) { $value = iterator_to_array($value); @@ -488,7 +447,7 @@ private function processArrayParameterValue(array $value): array * * @return $this */ - public function setResultSetMapping(Query\ResultSetMapping $rsm) + public function setResultSetMapping(Query\ResultSetMapping $rsm): static { $this->translateNamespaces($rsm); $this->_resultSetMapping = $rsm; @@ -498,10 +457,8 @@ public function setResultSetMapping(Query\ResultSetMapping $rsm) /** * Gets the ResultSetMapping used for hydration. - * - * @return ResultSetMapping|null */ - protected function getResultSetMapping() + protected function getResultSetMapping(): ?ResultSetMapping { return $this->_resultSetMapping; } @@ -539,7 +496,7 @@ private function translateNamespaces(Query\ResultSetMapping $rsm): void * $query->setHydrationCacheProfile(new QueryCacheProfile()); * $query->setHydrationCacheProfile(new QueryCacheProfile($lifetime, $resultKey)); */ - public function setHydrationCacheProfile(?QueryCacheProfile $profile) + public function setHydrationCacheProfile(?QueryCacheProfile $profile): static { if ($profile === null) { $this->_hydrationCacheProfile = null; @@ -559,10 +516,7 @@ public function setHydrationCacheProfile(?QueryCacheProfile $profile) return $this; } - /** - * @return QueryCacheProfile|null - */ - public function getHydrationCacheProfile() + public function getHydrationCacheProfile(): ?QueryCacheProfile { return $this->_hydrationCacheProfile; } @@ -575,7 +529,7 @@ public function getHydrationCacheProfile() * * @return $this */ - public function setResultCacheProfile(?QueryCacheProfile $profile) + public function setResultCacheProfile(?QueryCacheProfile $profile): static { if ($profile === null) { $this->_queryCacheProfile = null; @@ -597,10 +551,8 @@ public function setResultCacheProfile(?QueryCacheProfile $profile) /** * Defines a cache driver to be used for caching result sets and implicitly enables caching. - * - * @return $this */ - public function setResultCache(?CacheItemPoolInterface $resultCache) + public function setResultCache(?CacheItemPoolInterface $resultCache): static { if ($resultCache === null) { if ($this->_queryCacheProfile) { @@ -626,7 +578,7 @@ public function setResultCache(?CacheItemPoolInterface $resultCache) * * @return $this */ - public function enableResultCache(?int $lifetime = null, ?string $resultCacheId = null): self + public function enableResultCache(?int $lifetime = null, ?string $resultCacheId = null): static { $this->setResultCacheLifetime($lifetime); $this->setResultCacheId($resultCacheId); @@ -639,7 +591,7 @@ public function enableResultCache(?int $lifetime = null, ?string $resultCacheId * * @return $this */ - public function disableResultCache(): self + public function disableResultCache(): static { $this->_queryCacheProfile = null; @@ -653,7 +605,7 @@ public function disableResultCache(): self * * @return $this */ - public function setResultCacheLifetime($lifetime) + public function setResultCacheLifetime(?int $lifetime): static { $lifetime = (int) $lifetime; @@ -682,7 +634,7 @@ public function setResultCacheLifetime($lifetime) * * @return $this */ - public function expireResultCache($expire = true) + public function expireResultCache(bool $expire = true): static { $this->_expireResultCache = $expire; @@ -691,18 +643,13 @@ public function expireResultCache($expire = true) /** * Retrieves if the resultset cache is active or not. - * - * @return bool */ - public function getExpireResultCache() + public function getExpireResultCache(): bool { return $this->_expireResultCache; } - /** - * @return QueryCacheProfile|null - */ - public function getQueryCacheProfile() + public function getQueryCacheProfile(): ?QueryCacheProfile { return $this->_queryCacheProfile; } @@ -711,13 +658,9 @@ public function getQueryCacheProfile() * Change the default fetch mode of an association for this query. * * @param class-string $class - * @param string $assocName - * @param int $fetchMode * @psalm-param Mapping\ClassMetadata::FETCH_EAGER|Mapping\ClassMetadata::FETCH_LAZY $fetchMode - * - * @return $this */ - public function setFetchMode($class, $assocName, $fetchMode) + public function setFetchMode(string $class, string $assocName, int $fetchMode): static { if (! in_array($fetchMode, [Mapping\ClassMetadata::FETCH_EAGER, Mapping\ClassMetadata::FETCH_LAZY], true)) { Deprecation::trigger( @@ -743,7 +686,7 @@ public function setFetchMode($class, $assocName, $fetchMode) * * @return $this */ - public function setHydrationMode($hydrationMode) + public function setHydrationMode(string|int $hydrationMode): static { $this->_hydrationMode = $hydrationMode; @@ -753,10 +696,9 @@ public function setHydrationMode($hydrationMode) /** * Gets the hydration mode currently used by the query. * - * @return string|int * @psalm-return string|AbstractQuery::HYDRATE_* */ - public function getHydrationMode() + public function getHydrationMode(): string|int { return $this->_hydrationMode; } @@ -766,12 +708,9 @@ public function getHydrationMode() * * Alias for execute(null, $hydrationMode = HYDRATE_OBJECT). * - * @param string|int $hydrationMode * @psalm-param string|AbstractQuery::HYDRATE_* $hydrationMode - * - * @return mixed */ - public function getResult($hydrationMode = self::HYDRATE_OBJECT) + public function getResult(string|int $hydrationMode = self::HYDRATE_OBJECT): mixed { return $this->execute(null, $hydrationMode); } @@ -783,7 +722,7 @@ public function getResult($hydrationMode = self::HYDRATE_OBJECT) * * @return mixed[] */ - public function getArrayResult() + public function getArrayResult(): array { return $this->execute(null, self::HYDRATE_ARRAY); } @@ -795,7 +734,7 @@ public function getArrayResult() * * @return mixed[] */ - public function getSingleColumnResult() + public function getSingleColumnResult(): array { return $this->execute(null, self::HYDRATE_SCALAR_COLUMN); } @@ -807,7 +746,7 @@ public function getSingleColumnResult() * * @return mixed[] */ - public function getScalarResult() + public function getScalarResult(): array { return $this->execute(null, self::HYDRATE_SCALAR); } @@ -815,14 +754,11 @@ public function getScalarResult() /** * Get exactly one result or null. * - * @param string|int|null $hydrationMode * @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode * - * @return mixed - * * @throws NonUniqueResultException */ - public function getOneOrNullResult($hydrationMode = null) + public function getOneOrNullResult(string|int|null $hydrationMode = null): mixed { try { $result = $this->execute(null, $hydrationMode); @@ -853,15 +789,12 @@ public function getOneOrNullResult($hydrationMode = null) * If the result is not unique, a NonUniqueResultException is thrown. * If there is no result, a NoResultException is thrown. * - * @param string|int|null $hydrationMode * @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode * - * @return mixed - * * @throws NonUniqueResultException If the query result is not unique. * @throws NoResultException If the query returned no result. */ - public function getSingleResult($hydrationMode = null) + public function getSingleResult(string|int|null $hydrationMode = null): mixed { $result = $this->execute(null, $hydrationMode); @@ -885,12 +818,10 @@ public function getSingleResult($hydrationMode = null) * * Alias for getSingleResult(HYDRATE_SINGLE_SCALAR). * - * @return mixed The scalar result. - * * @throws NoResultException If the query returned no result. * @throws NonUniqueResultException If the query result is not unique. */ - public function getSingleScalarResult() + public function getSingleScalarResult(): mixed { return $this->getSingleResult(self::HYDRATE_SINGLE_SCALAR); } @@ -898,12 +829,9 @@ public function getSingleScalarResult() /** * Sets a query hint. If the hint name is not recognized, it is silently ignored. * - * @param string $name The name of the hint. - * @param mixed $value The value of the hint. - * * @return $this */ - public function setHint($name, $value) + public function setHint(string $name, mixed $value): static { $this->_hints[$name] = $value; @@ -913,23 +841,14 @@ public function setHint($name, $value) /** * Gets the value of a query hint. If the hint name is not recognized, FALSE is returned. * - * @param string $name The name of the hint. - * * @return mixed The value of the hint or FALSE, if the hint name is not recognized. */ - public function getHint($name) + public function getHint(string $name): mixed { return $this->_hints[$name] ?? false; } - /** - * Check if the query has a hint - * - * @param string $name The name of the hint - * - * @return bool False if the query does not have any hint - */ - public function hasHint($name) + public function hasHint(string $name): bool { return isset($this->_hints[$name]); } @@ -939,7 +858,7 @@ public function hasHint($name) * * @return array */ - public function getHints() + public function getHints(): array { return $this->_hints; } @@ -948,15 +867,15 @@ public function getHints() * Executes the query and returns an iterable that can be used to incrementally * iterate over the result. * - * @param ArrayCollection|array|mixed[] $parameters The query parameters. - * @param string|int|null $hydrationMode The hydration mode to use. * @psalm-param ArrayCollection|mixed[] $parameters * @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode * * @return iterable */ - public function toIterable(iterable $parameters = [], $hydrationMode = null): iterable - { + public function toIterable( + ArrayCollection|array $parameters = [], + string|int|null $hydrationMode = null + ): iterable { if ($hydrationMode !== null) { $this->setHydrationMode($hydrationMode); } @@ -985,15 +904,13 @@ public function toIterable(iterable $parameters = [], $hydrationMode = null): it /** * Executes the query. * - * @param ArrayCollection|mixed[]|null $parameters Query parameters. - * @param string|int|null $hydrationMode Processing mode to be used during the hydration process. * @psalm-param ArrayCollection|mixed[]|null $parameters * @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode - * - * @return mixed */ - public function execute($parameters = null, $hydrationMode = null) - { + public function execute( + ArrayCollection|array|null $parameters = null, + string|int|null $hydrationMode = null + ): mixed { if ($this->cacheable && $this->isCacheEnabled()) { return $this->executeUsingQueryCache($parameters, $hydrationMode); } @@ -1004,15 +921,13 @@ public function execute($parameters = null, $hydrationMode = null) /** * Execute query ignoring second level cache. * - * @param ArrayCollection|mixed[]|null $parameters - * @param string|int|null $hydrationMode * @psalm-param ArrayCollection|mixed[]|null $parameters * @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode - * - * @return mixed */ - private function executeIgnoreQueryCache($parameters = null, $hydrationMode = null) - { + private function executeIgnoreQueryCache( + ArrayCollection|array|null $parameters = null, + string|int|null $hydrationMode = null + ): mixed { if ($hydrationMode !== null) { $this->setHydrationMode($hydrationMode); } @@ -1077,15 +992,13 @@ private function getHydrationCache(): CacheItemPoolInterface /** * Load from second level cache or executes the query and put into cache. * - * @param ArrayCollection|mixed[]|null $parameters - * @param string|int|null $hydrationMode * @psalm-param ArrayCollection|mixed[]|null $parameters * @psalm-param string|AbstractQuery::HYDRATE_*|null $hydrationMode - * - * @return mixed */ - private function executeUsingQueryCache($parameters = null, $hydrationMode = null) - { + private function executeUsingQueryCache( + ArrayCollection|array|null $parameters = null, + string|int|null $hydrationMode = null + ): mixed { $rsm = $this->getResultSetMapping(); if ($rsm === null) { throw new LogicException('Uninitialized result set mapping.'); @@ -1145,7 +1058,7 @@ private function getTimestampKey(): ?TimestampCacheKey * @return string[] ($key, $hash) * @psalm-return array{string, string} ($key, $hash) */ - protected function getHydrationCacheId() + protected function getHydrationCacheId(): array { $parameters = []; @@ -1169,12 +1082,8 @@ protected function getHydrationCacheId() * Set the result cache id to use to store the result set cache entry. * If this is not explicitly set by the developer then a hash is automatically * generated for you. - * - * @param string|null $id - * - * @return $this */ - public function setResultCacheId($id) + public function setResultCacheId(?string $id): static { if (! $this->_queryCacheProfile) { return $this->setResultCacheProfile(new QueryCacheProfile(0, $id)); @@ -1192,12 +1101,10 @@ public function setResultCacheId($id) * the results, or an integer indicating how * many rows were affected. */ - abstract protected function _doExecute(); + abstract protected function _doExecute(): Result|int; /** * Cleanup Query resource when clone is called. - * - * @return void */ public function __clone() { @@ -1209,10 +1116,8 @@ public function __clone() /** * Generates a string of currently query to use for the cache second level cache. - * - * @return string */ - protected function getHash() + protected function getHash(): string { $query = $this->getSQL(); assert(is_string($query)); diff --git a/lib/Doctrine/ORM/NativeQuery.php b/lib/Doctrine/ORM/NativeQuery.php index 65925cbe1e9..0d27d79bde2 100644 --- a/lib/Doctrine/ORM/NativeQuery.php +++ b/lib/Doctrine/ORM/NativeQuery.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM; +use Doctrine\DBAL\Result; + use function array_values; use function is_int; use function key; @@ -14,35 +16,24 @@ */ final class NativeQuery extends AbstractQuery { - /** @var string */ - private $sql; + private string $sql; /** - * Sets the SQL of the query. - * - * @param string $sql - * * @return $this */ - public function setSQL($sql): self + public function setSQL(string $sql): self { $this->sql = $sql; return $this; } - /** - * Gets the SQL query. - */ public function getSQL(): string { return $this->sql; } - /** - * {@inheritdoc} - */ - protected function _doExecute() + protected function _doExecute(): Result|int { $parameters = []; $types = []; diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 046257b599b..ce6f4426e4a 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM; use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\Result; use Doctrine\DBAL\Types\Type; use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Mapping\ClassMetadata; @@ -112,102 +113,78 @@ final class Query extends AbstractQuery /** * The current state of this query. * - * @var int * @psalm-var self::STATE_* */ - private $_state = self::STATE_DIRTY; + private int $_state = self::STATE_DIRTY; /** * A snapshot of the parameter types the query was parsed with. * * @var array */ - private $parsedTypes = []; + private array $parsedTypes = []; /** * Cached DQL query. - * - * @var string|null */ - private $dql = null; + private ?string $dql = null; /** * The parser result that holds DQL => SQL information. - * - * @var ParserResult */ - private $parserResult; + private ParserResult $parserResult; /** * The first result to return (the "offset"). - * - * @var int */ - private $firstResult = 0; + private int $firstResult = 0; /** * The maximum number of results to return (the "limit"). - * - * @var int|null */ - private $maxResults = null; + private ?int $maxResults = null; /** * The cache driver used for caching queries. - * - * @var CacheItemPoolInterface|null */ - private $queryCache; + private ?CacheItemPoolInterface $queryCache = null; /** * Whether or not expire the query cache. - * - * @var bool */ - private $expireQueryCache = false; + private bool $expireQueryCache = false; /** * The query cache lifetime. - * - * @var int|null */ - private $queryCacheTTL; + private ?int $queryCacheTTL = null; /** * Whether to use a query cache, if available. Defaults to TRUE. - * - * @var bool */ - private $useQueryCache = true; + private bool $useQueryCache = true; /** * Gets the SQL query/queries that correspond to this DQL query. * * @return list|string The built sql query or an array of all sql queries. */ - public function getSQL() + public function getSQL(): string|array { return $this->parse()->getSqlExecutor()->getSqlStatements(); } /** * Returns the corresponding AST for this DQL query. - * - * @return SelectStatement|UpdateStatement|DeleteStatement */ - public function getAST() + public function getAST(): SelectStatement|UpdateStatement|DeleteStatement { $parser = new Parser($this); return $parser->getAST(); } - /** - * {@inheritdoc} - * - * @return ResultSetMapping - */ - protected function getResultSetMapping() + protected function getResultSetMapping(): ResultSetMapping { // parse query or load from cache if ($this->_resultSetMapping === null) { @@ -271,10 +248,7 @@ private function parse(): ParserResult return $this->parserResult; } - /** - * {@inheritdoc} - */ - protected function _doExecute() + protected function _doExecute(): Result|int { $executor = $this->parse()->getSqlExecutor(); @@ -466,11 +440,9 @@ public function setQueryCache(?CacheItemPoolInterface $queryCache): self /** * Defines whether the query should make use of a query cache, if available. * - * @param bool $bool - * * @return $this */ - public function useQueryCache($bool): self + public function useQueryCache(bool $bool): self { $this->useQueryCache = $bool; @@ -484,12 +456,8 @@ public function useQueryCache($bool): self * * @return $this */ - public function setQueryCacheLifetime($timeToLive): self + public function setQueryCacheLifetime(?int $timeToLive): self { - if ($timeToLive !== null) { - $timeToLive = (int) $timeToLive; - } - $this->queryCacheTTL = $timeToLive; return $this; @@ -506,11 +474,9 @@ public function getQueryCacheLifetime(): ?int /** * Defines if the query cache is active or not. * - * @param bool $expire Whether or not to force query cache expiration. - * * @return $this */ - public function expireQueryCache($expire = true): self + public function expireQueryCache(bool $expire = true): self { $this->expireQueryCache = $expire; @@ -535,10 +501,8 @@ public function free(): void /** * Sets a DQL query string. - * - * @param string|null $dqlQuery DQL Query. */ - public function setDQL($dqlQuery): self + public function setDQL(?string $dqlQuery): self { if ($dqlQuery === null) { Deprecation::trigger( @@ -586,7 +550,7 @@ public function getState(): int * * @param string $dql Arbitrary piece of DQL to check for. */ - public function contains($dql): bool + public function contains(string $dql): bool { return stripos($this->getDQL(), $dql) !== false; } @@ -598,7 +562,7 @@ public function contains($dql): bool * * @return $this */ - public function setFirstResult($firstResult): self + public function setFirstResult(?int $firstResult): self { if (! is_int($firstResult)) { Deprecation::trigger( @@ -632,16 +596,10 @@ public function getFirstResult(): ?int /** * Sets the maximum number of results to retrieve (the "limit"). * - * @param int|null $maxResults - * * @return $this */ - public function setMaxResults($maxResults): self + public function setMaxResults(?int $maxResults): self { - if ($maxResults !== null) { - $maxResults = (int) $maxResults; - } - $this->maxResults = $maxResults; $this->_state = self::STATE_DIRTY; @@ -667,20 +625,14 @@ public function toIterable(iterable $parameters = [], $hydrationMode = self::HYD return parent::toIterable($parameters, $hydrationMode); } - /** - * {@inheritdoc} - */ - public function setHint($name, $value): self + public function setHint(string $name, mixed $value): static { $this->_state = self::STATE_DIRTY; return parent::setHint($name, $value); } - /** - * {@inheritdoc} - */ - public function setHydrationMode($hydrationMode): self + public function setHydrationMode(string|int $hydrationMode): static { $this->_state = self::STATE_DIRTY; @@ -692,12 +644,11 @@ public function setHydrationMode($hydrationMode): self * * @see \Doctrine\DBAL\LockMode * - * @param int $lockMode * @psalm-param LockMode::* $lockMode * * @throws TransactionRequiredException */ - public function setLockMode($lockMode): self + public function setLockMode(int $lockMode): self { if (in_array($lockMode, [LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE], true)) { if (! $this->_em->getConnection()->isTransactionActive()) { From 7e20e97ee02c571ed78ac8604b992964b88f2a28 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 3 Jun 2022 19:57:49 +0200 Subject: [PATCH 112/475] Remove MockBuilderCompatibilityTools (#9814) --- .../ORM/Functional/Ticket/DDC2359Test.php | 11 +++---- .../ORM/Hydration/ObjectHydratorTest.php | 9 +++--- .../Tests/ORM/Id/SequenceGeneratorTest.php | 6 ++-- .../ORM/Mapping/ClassMetadataFactoryTest.php | 2 -- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 18 +++++------- .../ORM/Tools/Pagination/PaginatorTest.php | 9 +++--- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 6 ++-- .../MockBuilderCompatibilityTools.php | 29 ------------------- 8 files changed, 24 insertions(+), 66 deletions(-) delete mode 100644 tests/Doctrine/Tests/PHPUnitCompatibility/MockBuilderCompatibilityTools.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index 393ca3c7df9..fbbaf820140 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -15,7 +15,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Persistence\Mapping\Driver\MappingDriver; -use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools; use PHPUnit\Framework\TestCase; /** @@ -23,8 +22,6 @@ */ class DDC2359Test extends TestCase { - use MockBuilderCompatibilityTools; - /** * Verifies that {@see \Doctrine\ORM\Mapping\ClassMetadataFactory::wakeupReflection} is * not called twice when loading metadata from a driver @@ -35,12 +32,12 @@ public function testIssue(): void $mockMetadata = $this->createMock(ClassMetadata::class); $entityManager = $this->createMock(EntityManager::class); - $metadataFactory = $this - ->getMockBuilderWithOnlyMethods(ClassMetadataFactory::class, ['newClassMetadataInstance', 'wakeupReflection']) + $metadataFactory = $this->getMockBuilder(ClassMetadataFactory::class) + ->onlyMethods(['newClassMetadataInstance', 'wakeupReflection']) ->getMock(); - $configuration = $this - ->getMockBuilderWithOnlyMethods(Configuration::class, ['getMetadataDriverImpl']) + $configuration = $this->getMockBuilder(Configuration::class) + ->onlyMethods(['getMetadataDriverImpl']) ->getMock(); $connection = $this->createMock(Connection::class); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index c0c74d52b2f..85771952f65 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -29,14 +29,11 @@ use Doctrine\Tests\Models\Forum\ForumCategory; use Doctrine\Tests\Models\Hydration\EntityWithArrayDefaultArrayValueM2M; use Doctrine\Tests\Models\Hydration\SimpleEntity; -use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools; use function count; class ObjectHydratorTest extends HydrationTestCase { - use MockBuilderCompatibilityTools; - /** * @psalm-return list */ @@ -1038,7 +1035,8 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void $proxyInstance = new ECommerceShipping(); // mocking the proxy factory - $proxyFactory = $this->getMockBuilderWithOnlyMethods(ProxyFactory::class, ['getProxy']) + $proxyFactory = $this->getMockBuilder(ProxyFactory::class) + ->onlyMethods(['getProxy']) ->disableOriginalConstructor() ->getMock(); @@ -1086,7 +1084,8 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE $proxyInstance = new ECommerceShipping(); // mocking the proxy factory - $proxyFactory = $this->getMockBuilderWithOnlyMethods(ProxyFactory::class, ['getProxy']) + $proxyFactory = $this->getMockBuilder(ProxyFactory::class) + ->onlyMethods(['getProxy']) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php index 2288ebf7ad3..6565423ba74 100644 --- a/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php @@ -9,12 +9,9 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\Id\SequenceGenerator; use Doctrine\Tests\OrmTestCase; -use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools; class SequenceGeneratorTest extends OrmTestCase { - use MockBuilderCompatibilityTools; - public function testGeneration(): void { $sequenceGenerator = new SequenceGenerator('seq', 10); @@ -23,7 +20,8 @@ public function testGeneration(): void $platform->method('getSequenceNextValSQL') ->willReturn(''); - $connection = $this->getMockBuilderWithOnlyMethods(Connection::class, ['fetchOne', 'getDatabasePlatform']) + $connection = $this->getMockBuilder(Connection::class) + ->onlyMethods(['fetchOne', 'getDatabasePlatform']) ->setConstructorArgs([[], $this->createMock(Driver::class)]) ->getMock(); $connection->method('getDatabasePlatform') diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 669e05f6e61..e0101867488 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -41,7 +41,6 @@ use Doctrine\Tests\Models\Quote\Phone; use Doctrine\Tests\Models\Quote\User; use Doctrine\Tests\OrmTestCase; -use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools; use DoctrineGlobalArticle; use Exception; use InvalidArgumentException; @@ -55,7 +54,6 @@ class ClassMetadataFactoryTest extends OrmTestCase { - use MockBuilderCompatibilityTools; use VerifyDeprecations; public function testGetMetadataForSingleClass(): void diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index f6469ad529f..d6bc52397c4 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -20,7 +20,6 @@ use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\ECommerce\ECommerceFeature; use Doctrine\Tests\OrmTestCase; -use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools; use ReflectionProperty; use stdClass; @@ -32,8 +31,6 @@ */ class ProxyFactoryTest extends OrmTestCase { - use MockBuilderCompatibilityTools; - private UnitOfWorkMock $uowMock; private EntityManagerMock $emMock; @@ -60,7 +57,8 @@ public function testReferenceProxyDelegatesLoadingToThePersister(): void { $identifier = ['id' => 42]; $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; - $persister = $this->getMockBuilderWithOnlyMethods(BasicEntityPersister::class, ['load']) + $persister = $this->getMockBuilder(BasicEntityPersister::class) + ->onlyMethods(['load']) ->disableOriginalConstructor() ->getMock(); @@ -123,8 +121,8 @@ public function testSkipAbstractClassesOnGeneration(): void */ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void { - $persister = $this - ->getMockBuilderWithOnlyMethods(BasicEntityPersister::class, ['load', 'getClassMetadata']) + $persister = $this->getMockBuilder(BasicEntityPersister::class) + ->onlyMethods(['load', 'getClassMetadata']) ->disableOriginalConstructor() ->getMock(); $this->uowMock->setEntityPersister(ECommerceFeature::class, $persister); @@ -153,8 +151,8 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void */ public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void { - $persister = $this - ->getMockBuilderWithOnlyMethods(BasicEntityPersister::class, ['load', 'getClassMetadata']) + $persister = $this->getMockBuilder(BasicEntityPersister::class) + ->onlyMethods(['load', 'getClassMetadata']) ->disableOriginalConstructor() ->getMock(); $this->uowMock->setEntityPersister(ECommerceFeature::class, $persister); @@ -192,8 +190,8 @@ public function testProxyClonesParentFields(): void $classMetaData = $this->emMock->getClassMetadata(CompanyEmployee::class); - $persister = $this - ->getMockBuilderWithOnlyMethods(BasicEntityPersister::class, ['load', 'getClassMetadata']) + $persister = $this->getMockBuilder(BasicEntityPersister::class) + ->onlyMethods(['load', 'getClassMetadata']) ->disableOriginalConstructor() ->getMock(); $this->uowMock->setEntityPersister(CompanyEmployee::class, $persister); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index ea841dfae31..29903fda23a 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -14,13 +14,10 @@ use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\Tests\OrmTestCase; -use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools; use PHPUnit\Framework\MockObject\MockObject; class PaginatorTest extends OrmTestCase { - use MockBuilderCompatibilityTools; - /** @var Connection&MockObject */ private $connection; /** @var EntityManagerInterface&MockObject */ @@ -40,11 +37,13 @@ protected function setUp(): void $driver->method('getDatabasePlatform') ->willReturn($platform); - $this->connection = $this->getMockBuilderWithOnlyMethods(Connection::class, ['executeQuery']) + $this->connection = $this->getMockBuilder(Connection::class) + ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driver]) ->getMock(); - $this->em = $this->getMockBuilderWithOnlyMethods(EntityManagerDecorator::class, ['newHydrator']) + $this->em = $this->getMockBuilder(EntityManagerDecorator::class) + ->onlyMethods(['newHydrator']) ->setConstructorArgs([$this->createTestEntityManagerWithConnection($this->connection)]) ->getMock(); diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index e4ab7bd8a60..0beb4d05add 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -33,7 +33,6 @@ use Doctrine\Tests\Models\Forum\ForumAvatar; use Doctrine\Tests\Models\Forum\ForumUser; use Doctrine\Tests\OrmTestCase; -use Doctrine\Tests\PHPUnitCompatibility\MockBuilderCompatibilityTools; use PHPUnit\Framework\MockObject\MockObject; use stdClass; @@ -46,8 +45,6 @@ */ class UnitOfWorkTest extends OrmTestCase { - use MockBuilderCompatibilityTools; - /** * SUT */ @@ -610,7 +607,8 @@ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails( ->willReturn($platform); // Set another connection mock that fail on commit - $this->connection = $this->getMockBuilderWithOnlyMethods(Connection::class, ['commit']) + $this->connection = $this->getMockBuilder(Connection::class) + ->onlyMethods(['commit']) ->setConstructorArgs([[], $driver]) ->getMock(); $this->_emMock = EntityManagerMock::create($this->connection, null, $this->eventManager); diff --git a/tests/Doctrine/Tests/PHPUnitCompatibility/MockBuilderCompatibilityTools.php b/tests/Doctrine/Tests/PHPUnitCompatibility/MockBuilderCompatibilityTools.php deleted file mode 100644 index 01cdbe650af..00000000000 --- a/tests/Doctrine/Tests/PHPUnitCompatibility/MockBuilderCompatibilityTools.php +++ /dev/null @@ -1,29 +0,0 @@ - $onlyMethods - * @psalm-param class-string $className - * - * @psalm-return MockBuilder - * - * @template TMockedType of object - */ - private function getMockBuilderWithOnlyMethods(string $className, array $onlyMethods): MockBuilder - { - $builder = $this->getMockBuilder($className); - - return method_exists($builder, 'onlyMethods') - ? $builder->onlyMethods($onlyMethods) // PHPUnit 8+ - : $builder->setMethods($onlyMethods); // PHPUnit 7 - } -} From 9f4339e7dc8ad31d82341eb6d0752b41fdeae7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 2 Jun 2022 23:02:58 +0200 Subject: [PATCH 113/475] Run rector --- lib/Doctrine/ORM/AbstractQuery.php | 79 +++++++++++++----------------- lib/Doctrine/ORM/NativeQuery.php | 5 +- lib/Doctrine/ORM/Query.php | 16 +++--- 3 files changed, 44 insertions(+), 56 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index e1f8e248a7e..2ced1415247 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -5,7 +5,6 @@ namespace Doctrine\ORM; use BackedEnum; -use Countable; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Util\ClassUtils; @@ -15,6 +14,7 @@ use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\ORM\Cache\TimestampCacheKey; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException as ORMMappingException; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\QueryException; @@ -30,6 +30,7 @@ use function count; use function in_array; use function is_array; +use function is_countable; use function is_numeric; use function is_object; use function is_scalar; @@ -93,11 +94,6 @@ abstract class AbstractQuery */ protected ?ResultSetMapping $_resultSetMapping = null; - /** - * The entity manager used by this query object. - */ - protected EntityManagerInterface $_em; - /** * The map of query hints. * @@ -147,12 +143,15 @@ abstract class AbstractQuery /** * Initializes a new instance of a class derived from AbstractQuery. */ - public function __construct(EntityManagerInterface $em) - { - $this->_em = $em; + public function __construct( + /** + * The entity manager used by this query object. + */ + protected EntityManagerInterface $em + ) { $this->parameters = new ArrayCollection(); $this->_hints = $em->getConfiguration()->getDefaultQueryHints(); - $this->hasCache = $this->_em->getConfiguration()->isSecondLevelCacheEnabled(); + $this->hasCache = $this->em->getConfiguration()->isSecondLevelCacheEnabled(); if ($this->hasCache) { $this->cacheLogger = $em->getConfiguration() @@ -260,7 +259,7 @@ abstract public function getSQL(): string|array; */ public function getEntityManager(): EntityManagerInterface { - return $this->_em; + return $this->em; } /** @@ -272,7 +271,7 @@ public function free(): void { $this->parameters = new ArrayCollection(); - $this->_hints = $this->_em->getConfiguration()->getDefaultQueryHints(); + $this->_hints = $this->em->getConfiguration()->getDefaultQueryHints(); } /** @@ -292,16 +291,12 @@ public function getParameters(): ArrayCollection * * @return Parameter|null The value of the bound parameter, or NULL if not available. */ - public function getParameter($key): ?Parameter + public function getParameter(int|string $key): ?Parameter { - $key = Query\Parameter::normalizeName($key); + $key = Parameter::normalizeName($key); $filteredParameters = $this->parameters->filter( - static function (Query\Parameter $parameter) use ($key): bool { - $parameterName = $parameter->getName(); - - return $key === $parameterName; - } + static fn (Parameter $parameter): bool => $parameter->getName() === $key ); return ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null; @@ -380,7 +375,7 @@ public function processParameterValue(mixed $value): mixed return $value; } - if ($value instanceof Mapping\ClassMetadata) { + if ($value instanceof ClassMetadata) { return $value->name; } @@ -394,12 +389,12 @@ public function processParameterValue(mixed $value): mixed try { $class = ClassUtils::getClass($value); - $value = $this->_em->getUnitOfWork()->getSingleIdentifierValue($value); + $value = $this->em->getUnitOfWork()->getSingleIdentifierValue($value); if ($value === null) { throw ORMInvalidArgumentException::invalidIdentifierBindingEntity($class); } - } catch (MappingException | ORMMappingException $e) { + } catch (MappingException | ORMMappingException) { /* Silence any mapping exceptions. These can occur if the object in question is not a mapped entity, in which case we just don't do any preparation on the value. @@ -447,7 +442,7 @@ private function processArrayParameterValue(array $value): array * * @return $this */ - public function setResultSetMapping(Query\ResultSetMapping $rsm): static + public function setResultSetMapping(ResultSetMapping $rsm): static { $this->translateNamespaces($rsm); $this->_resultSetMapping = $rsm; @@ -466,11 +461,9 @@ protected function getResultSetMapping(): ?ResultSetMapping /** * Allows to translate entity namespaces to full qualified names. */ - private function translateNamespaces(Query\ResultSetMapping $rsm): void + private function translateNamespaces(ResultSetMapping $rsm): void { - $translate = function ($alias): string { - return $this->_em->getClassMetadata($alias)->getName(); - }; + $translate = fn ($alias): string => $this->em->getClassMetadata($alias)->getName(); $rsm->aliasMap = array_map($translate, $rsm->aliasMap); $rsm->declaringClasses = array_map($translate, $rsm->declaringClasses); @@ -505,7 +498,7 @@ public function setHydrationCacheProfile(?QueryCacheProfile $profile): static } if (! $profile->getResultCache()) { - $defaultHydrationCacheImpl = $this->_em->getConfiguration()->getHydrationCache(); + $defaultHydrationCacheImpl = $this->em->getConfiguration()->getHydrationCache(); if ($defaultHydrationCacheImpl) { $profile = $profile->setResultCache($defaultHydrationCacheImpl); } @@ -538,7 +531,7 @@ public function setResultCacheProfile(?QueryCacheProfile $profile): static } if (! $profile->getResultCache()) { - $defaultResultCache = $this->_em->getConfiguration()->getResultCache(); + $defaultResultCache = $this->em->getConfiguration()->getResultCache(); if ($defaultResultCache) { $profile = $profile->setResultCache($defaultResultCache); } @@ -617,7 +610,7 @@ public function setResultCacheLifetime(?int $lifetime): static $this->_queryCacheProfile = new QueryCacheProfile($lifetime); - $cache = $this->_em->getConfiguration()->getResultCache(); + $cache = $this->em->getConfiguration()->getResultCache(); if (! $cache) { return $this; } @@ -662,14 +655,14 @@ public function getQueryCacheProfile(): ?QueryCacheProfile */ public function setFetchMode(string $class, string $assocName, int $fetchMode): static { - if (! in_array($fetchMode, [Mapping\ClassMetadata::FETCH_EAGER, Mapping\ClassMetadata::FETCH_LAZY], true)) { + if (! in_array($fetchMode, [ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY], true)) { Deprecation::trigger( 'doctrine/orm', 'https://github.com/doctrine/orm/pull/9777', 'Calling %s() with something else than ClassMetadata::FETCH_EAGER or ClassMetadata::FETCH_LAZY is deprecated.', __METHOD__ ); - $fetchMode = Mapping\ClassMetadata::FETCH_LAZY; + $fetchMode = ClassMetadata::FETCH_LAZY; } $this->_hints['fetchMode'][$class][$assocName] = $fetchMode; @@ -762,7 +755,7 @@ public function getOneOrNullResult(string|int|null $hydrationMode = null): mixed { try { $result = $this->execute(null, $hydrationMode); - } catch (NoResultException $e) { + } catch (NoResultException) { return null; } @@ -881,7 +874,7 @@ public function toIterable( } if ( - ($this->isCountable($parameters) && count($parameters) !== 0) + (is_countable($parameters) && count($parameters) !== 0) || ($parameters instanceof Traversable && iterator_count($parameters) !== 0) ) { $this->setParameters($parameters); @@ -898,7 +891,7 @@ public function toIterable( $stmt = $this->_doExecute(); - return $this->_em->newHydrator($this->_hydrationMode)->toIterable($stmt, $rsm, $this->_hints); + return $this->em->newHydrator($this->_hydrationMode)->toIterable($stmt, $rsm, $this->_hints); } /** @@ -972,7 +965,7 @@ private function executeIgnoreQueryCache( throw new LogicException('Uninitialized result set mapping.'); } - $data = $this->_em->newHydrator($this->_hydrationMode)->hydrateAll($stmt, $rsm, $this->_hints); + $data = $this->em->newHydrator($this->_hydrationMode)->hydrateAll($stmt, $rsm, $this->_hints); $setCacheEntry($data); @@ -1004,7 +997,7 @@ private function executeUsingQueryCache( throw new LogicException('Uninitialized result set mapping.'); } - $queryCache = $this->_em->getCache()->getQueryCache($this->cacheRegion); + $queryCache = $this->em->getCache()->getQueryCache($this->cacheRegion); $queryKey = new QueryCacheKey( $this->getHash(), $this->lifetime, @@ -1045,9 +1038,9 @@ private function getTimestampKey(): ?TimestampCacheKey return null; } - $metadata = $this->_em->getClassMetadata($entityName); + $metadata = $this->em->getClassMetadata($entityName); - return new Cache\TimestampCacheKey($metadata->rootEntityName); + return new TimestampCacheKey($metadata->rootEntityName); } /** @@ -1111,7 +1104,7 @@ public function __clone() $this->parameters = new ArrayCollection(); $this->_hints = []; - $this->_hints = $this->_em->getConfiguration()->getDefaultQueryHints(); + $this->_hints = $this->em->getConfiguration()->getDefaultQueryHints(); } /** @@ -1138,10 +1131,4 @@ protected function getHash(): string return sha1($query . '-' . serialize($params) . '-' . serialize($hints)); } - - /** @param iterable $subject */ - private function isCountable(iterable $subject): bool - { - return $subject instanceof Countable || is_array($subject); - } } diff --git a/lib/Doctrine/ORM/NativeQuery.php b/lib/Doctrine/ORM/NativeQuery.php index 0d27d79bde2..97ba4c87c33 100644 --- a/lib/Doctrine/ORM/NativeQuery.php +++ b/lib/Doctrine/ORM/NativeQuery.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM; use Doctrine\DBAL\Result; +use Doctrine\ORM\Query\ParameterTypeInferer; use function array_values; use function is_int; @@ -43,7 +44,7 @@ protected function _doExecute(): Result|int $value = $this->processParameterValue($parameter->getValue()); $type = $parameter->getValue() === $value ? $parameter->getType() - : Query\ParameterTypeInferer::inferType($value); + : ParameterTypeInferer::inferType($value); $parameters[$name] = $value; $types[$name] = $type; @@ -57,7 +58,7 @@ protected function _doExecute(): Result|int $types = array_values($types); } - return $this->_em->getConnection()->executeQuery( + return $this->em->getConnection()->executeQuery( $this->sql, $parameters, $types, diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index ce6f4426e4a..222308ae017 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -209,14 +209,14 @@ private function parse(): ParserResult } // Return previous parser result if the query and the filter collection are both clean - if ($this->_state === self::STATE_CLEAN && $this->parsedTypes === $types && $this->_em->isFiltersStateClean()) { + if ($this->_state === self::STATE_CLEAN && $this->parsedTypes === $types && $this->em->isFiltersStateClean()) { return $this->parserResult; } $this->_state = self::STATE_CLEAN; $this->parsedTypes = $types; - $queryCache = $this->queryCache ?? $this->_em->getConfiguration()->getQueryCache(); + $queryCache = $this->queryCache ?? $this->em->getConfiguration()->getQueryCache(); // Check query cache. if (! ($this->useQueryCache && $queryCache)) { $parser = new Parser($this); @@ -286,10 +286,10 @@ protected function _doExecute(): Result|int $executor, $sqlParams, $types, - $this->_em->getConnection()->getParams() + $this->em->getConnection()->getParams() ); - return $executor->execute($this->_em->getConnection(), $sqlParams, $types); + return $executor->execute($this->em->getConnection(), $sqlParams, $types); } /** @@ -334,7 +334,7 @@ private function evictEntityCacheRegion(): void ? $AST->deleteClause->abstractSchemaName : $AST->updateClause->abstractSchemaName; - $this->_em->getCache()->evictEntityRegion($className); + $this->em->getCache()->evictEntityRegion($className); } /** @@ -412,7 +412,7 @@ private function resolveParameterValue(Parameter $parameter): array } if ($value instanceof ClassMetadata && isset($rsm->discriminatorParameters[$key])) { - $value = array_keys(HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($value, $this->_em)); + $value = array_keys(HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($value, $this->em)); } $processedValue = $this->processParameterValue($value); @@ -651,7 +651,7 @@ public function setHydrationMode(string|int $hydrationMode): static public function setLockMode(int $lockMode): self { if (in_array($lockMode, [LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE], true)) { - if (! $this->_em->getConnection()->isTransactionActive()) { + if (! $this->em->getConnection()->isTransactionActive()) { throw TransactionRequiredException::transactionRequired(); } } @@ -687,7 +687,7 @@ protected function getQueryCacheId(): string return md5( $this->getDQL() . serialize($this->_hints) . '&platform=' . get_debug_type($this->getEntityManager()->getConnection()->getDatabasePlatform()) . - ($this->_em->hasFilters() ? $this->_em->getFilters()->getHash() : '') . + ($this->em->hasFilters() ? $this->em->getFilters()->getHash() : '') . '&firstResult=' . $this->firstResult . '&maxResult=' . $this->maxResults . '&hydrationMode=' . $this->_hydrationMode . '&types=' . serialize($this->parsedTypes) . 'DOCTRINE_QUERY_CACHE_SALT' ); From 2ee4482d00307408536e9fbba244facaf9603323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 2 Jun 2022 23:11:55 +0200 Subject: [PATCH 114/475] Remove deprecation when wrong fetch mode is used --- lib/Doctrine/ORM/AbstractQuery.php | 12 ------------ tests/Doctrine/Tests/ORM/AbstractQueryTest.php | 16 ---------------- 2 files changed, 28 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 2ced1415247..c5d5c17fa11 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -10,7 +10,6 @@ use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Result; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\ORM\Cache\TimestampCacheKey; @@ -28,7 +27,6 @@ use function array_shift; use function assert; use function count; -use function in_array; use function is_array; use function is_countable; use function is_numeric; @@ -655,16 +653,6 @@ public function getQueryCacheProfile(): ?QueryCacheProfile */ public function setFetchMode(string $class, string $assocName, int $fetchMode): static { - if (! in_array($fetchMode, [ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY], true)) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9777', - 'Calling %s() with something else than ClassMetadata::FETCH_EAGER or ClassMetadata::FETCH_LAZY is deprecated.', - __METHOD__ - ); - $fetchMode = ClassMetadata::FETCH_LAZY; - } - $this->_hints['fetchMode'][$class][$assocName] = $fetchMode; return $this; diff --git a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php index 93adc309636..0f3738c0c6e 100644 --- a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php +++ b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php @@ -6,18 +6,14 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Result; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemPoolInterface; -use stdClass; final class AbstractQueryTest extends TestCase { - use VerifyDeprecations; - public function testItMakesHydrationCacheProfilesAwareOfTheResultCache(): void { $cache = $this->createMock(CacheItemPoolInterface::class); @@ -58,18 +54,6 @@ public function testSettingTheResultCacheIsPossibleWithoutCallingDeprecatedMetho self::assertSame($cache, $query->getResultCache()); } - - public function testSettingTheFetchModeToRandomIntegersIsDeprecated(): void - { - $query = $this->getMockForAbstractClass( - AbstractQuery::class, - [], - '', - false // no need to call the constructor - ); - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9777'); - $query->setFetchMode(stdClass::class, 'foo', 42); - } } class TestQuery extends AbstractQuery From 4a02a79abbd9f9ed6c5fe966aa8c298ab4ee1e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 2 Jun 2022 23:12:21 +0200 Subject: [PATCH 115/475] Remove unneeded checks Both array and ArrayCollection are countable. --- lib/Doctrine/ORM/AbstractQuery.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index c5d5c17fa11..b0ed06879c7 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -28,12 +28,10 @@ use function assert; use function count; use function is_array; -use function is_countable; use function is_numeric; use function is_object; use function is_scalar; use function is_string; -use function iterator_count; use function iterator_to_array; use function ksort; use function reset; @@ -861,10 +859,7 @@ public function toIterable( $this->setHydrationMode($hydrationMode); } - if ( - (is_countable($parameters) && count($parameters) !== 0) - || ($parameters instanceof Traversable && iterator_count($parameters) !== 0) - ) { + if (count($parameters) !== 0) { $this->setParameters($parameters); } From d462ed3b4dd79a233fefc98868cd93a800dc89a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 2 Jun 2022 23:13:42 +0200 Subject: [PATCH 116/475] Update baseline --- psalm-baseline.xml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a142a56e010..3a222ab7f77 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,9 +1,6 @@ - - in_array($fetchMode, [Mapping\ClassMetadata::FETCH_EAGER, Mapping\ClassMetadata::FETCH_LAZY], true) - ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null @@ -22,12 +19,6 @@ getCacheLogger getQueryCache - - (bool) $cacheable - (int) $cacheMode - (int) $lifetime - (string) $cacheRegion - @@ -1168,14 +1159,6 @@ $sqlParams - - parent::setHint($name, $value) - parent::setHydrationMode($hydrationMode) - - - self - self - $this->getDQL() From 068da9d89f700919ab2d646237662003ced1464f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 3 Jun 2022 21:23:11 +0200 Subject: [PATCH 117/475] Address deprecation of supportsForeignKeyConstraints() All platforms are supposed to support foreign key constraints now. --- .../Entity/JoinedSubclassPersister.php | 29 ++++--------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 41f09da929e..ce3ce515051 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -228,31 +228,12 @@ public function delete(object $entity): bool $this->deleteJoinTableRecords($identifier, $types); - // If the database platform supports FKs, just - // delete the row from the root table. Cascades do the rest. - if ($this->platform->supportsForeignKeyConstraints()) { - $rootClass = $this->em->getClassMetadata($this->class->rootEntityName); - $rootTable = $this->quoteStrategy->getTableName($rootClass, $this->platform); - $rootTypes = $this->getClassIdentifiersTypes($rootClass); - - return (bool) $this->conn->delete($rootTable, $id, $rootTypes); - } - - // Delete from all tables individually, starting from this class' table up to the root table. - $rootTable = $this->quoteStrategy->getTableName($this->class, $this->platform); - $rootTypes = $this->getClassIdentifiersTypes($this->class); - - $affectedRows = $this->conn->delete($rootTable, $id, $rootTypes); - - foreach ($this->class->parentClasses as $parentClass) { - $parentMetadata = $this->em->getClassMetadata($parentClass); - $parentTable = $this->quoteStrategy->getTableName($parentMetadata, $this->platform); - $parentTypes = $this->getClassIdentifiersTypes($parentMetadata); - - $this->conn->delete($parentTable, $id, $parentTypes); - } + // Delete the row from the root table. Cascades do the rest. + $rootClass = $this->em->getClassMetadata($this->class->rootEntityName); + $rootTable = $this->quoteStrategy->getTableName($rootClass, $this->platform); + $rootTypes = $this->getClassIdentifiersTypes($rootClass); - return (bool) $affectedRows; + return (bool) $this->conn->delete($rootTable, $id, $rootTypes); } public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string From a91d208d10a72ed9ec11204d81e41e346942da6c Mon Sep 17 00:00:00 2001 From: Marc Brillault Date: Thu, 9 Jun 2022 16:46:59 +0200 Subject: [PATCH 118/475] Address removals of doctrine-dbal - Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets - Doctrine\DBAL\Schema\Schema::visit - Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand --- lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php | 6 +++++- lib/Doctrine/ORM/Tools/SchemaTool.php | 8 +++++++- phpstan-dbal4.neon | 4 ++++ psalm.xml | 6 ++++++ .../Tests/ORM/Tools/Console/ConsoleRunnerTest.php | 8 +++++++- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index 96aae227177..3d678a4e1a6 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -12,6 +12,7 @@ use Symfony\Component\Console\Command\Command as SymfonyCommand; use function assert; +use function class_exists; /** * Handles running the Console Tools inside Symfony Console context. @@ -57,10 +58,13 @@ public static function addCommands(Application $cli, EntityManagerProvider $enti { $connectionProvider = new ConnectionFromManagerProvider($entityManagerProvider); + if (class_exists(DBALConsole\Command\ReservedWordsCommand::class)) { + $cli->add(new DBALConsole\Command\ReservedWordsCommand($connectionProvider)); + } + $cli->addCommands( [ // DBAL Commands - new DBALConsole\Command\ReservedWordsCommand($connectionProvider), new DBALConsole\Command\RunSqlCommand($connectionProvider), // ORM Commands diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 83b75496752..b76d8f8fb28 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -28,12 +28,14 @@ use function array_flip; use function array_intersect_key; use function assert; +use function class_exists; use function count; use function current; use function implode; use function in_array; use function is_array; use function is_numeric; +use function method_exists; use function strtolower; /** @@ -393,7 +395,11 @@ static function (ClassMetadata $class) use ($idMapping): bool { } } - if (! $this->platform->supportsSchemas()) { + if ( + ! $this->platform->supportsSchemas() + && class_exists(RemoveNamespacedAssets::class) + && method_exists($schema, 'visit') + ) { $schema->visit(new RemoveNamespacedAssets()); } diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon index 83b83b0f4e6..9b9710ad85e 100644 --- a/phpstan-dbal4.neon +++ b/phpstan-dbal4.neon @@ -21,3 +21,7 @@ parameters: paths: - lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php - lib/Doctrine/ORM/Id/IdentityGenerator.php + + - + message: '~^Parameter #1 \$command of method Symfony\\Component\\Console\\Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command, Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand given\.$~' + path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php diff --git a/psalm.xml b/psalm.xml index 2e0b3a9f57d..0e34c912cf0 100644 --- a/psalm.xml +++ b/psalm.xml @@ -22,6 +22,8 @@ + + @@ -30,6 +32,7 @@ + @@ -128,6 +131,9 @@ + + + diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php index 0a154649769..2bc179345f0 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php @@ -5,11 +5,14 @@ namespace Doctrine\Tests\ORM\Tools\Console; use Composer\InstalledVersions; +use DBALConsole\Command\ReservedWordsCommand; use Doctrine\ORM\Tools\Console\ConsoleRunner; use Doctrine\ORM\Tools\Console\EntityManagerProvider; use Doctrine\Tests\DoctrineTestCase; use Symfony\Component\Console\Command\Command; +use function class_exists; + /** * @group DDC-3186 * @covers \Doctrine\ORM\Tools\Console\ConsoleRunner @@ -21,7 +24,10 @@ public function testCreateApplicationShouldReturnAnApplicationWithTheCorrectComm $app = ConsoleRunner::createApplication($this->createStub(EntityManagerProvider::class)); self::assertSame(InstalledVersions::getVersion('doctrine/orm'), $app->getVersion()); - self::assertTrue($app->has('dbal:reserved-words')); + if (class_exists(ReservedWordsCommand::class)) { + self::assertTrue($app->has('dbal:reserved-words')); + } + self::assertTrue($app->has('dbal:run-sql')); self::assertTrue($app->has('orm:clear-cache:region:collection')); self::assertTrue($app->has('orm:clear-cache:region:entity')); From 36b35f99a4791452c289f863942dfc5c26f2b93c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 9 Jun 2022 17:08:24 +0200 Subject: [PATCH 119/475] Run foreign key tests on all platforms SQLite now supports foreign keys. --- .../ORM/Functional/DatabaseDriverTest.php | 20 ------------------- .../ORM/Functional/Ticket/GH7684Test.php | 4 ---- 2 files changed, 24 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index ebc21f9ad6b..efaa3c44cad 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -35,10 +35,6 @@ protected function setUp(): void */ public function testIssue2059(): void { - if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - self::markTestSkipped('Platform does not support foreign keys.'); - } - $user = new Table('ddc2059_user'); $user->addColumn('id', 'integer'); $user->setPrimaryKey(['id']); @@ -57,10 +53,6 @@ public function testIssue2059(): void public function testLoadMetadataFromDatabase(): void { - if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - self::markTestSkipped('Platform does not support foreign keys.'); - } - $table = new Table('dbdriver_foo'); $table->addColumn('id', 'integer'); $table->setPrimaryKey(['id']); @@ -88,10 +80,6 @@ public function testLoadMetadataFromDatabase(): void public function testLoadMetadataWithForeignKeyFromDatabase(): void { - if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - self::markTestSkipped('Platform does not support foreign keys.'); - } - $tableB = new Table('dbdriver_bar'); $tableB->addColumn('id', 'integer'); $tableB->setPrimaryKey(['id']); @@ -122,10 +110,6 @@ public function testLoadMetadataWithForeignKeyFromDatabase(): void public function testDetectManyToManyTables(): void { - if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - self::markTestSkipped('Platform does not support foreign keys.'); - } - $metadatas = $this->extractClassMetadata(['CmsUsers', 'CmsGroups', 'CmsTags']); self::assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.'); @@ -162,10 +146,6 @@ public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails(): void public function testLoadMetadataFromDatabaseDetail(): void { - if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - self::markTestSkipped('Platform does not support foreign keys.'); - } - $table = new Table('dbdriver_foo'); $table->addColumn('id', 'integer', ['unsigned' => true]); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php index d0c0b824b69..654b1cd8655 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php @@ -16,10 +16,6 @@ class GH7684Test extends DatabaseDriverTestCase { public function testIssue(): void { - if (! $this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { - self::markTestSkipped('Platform does not support foreign keys.'); - } - $table1 = new Table('GH7684_identity_test_table'); $table1->addColumn('id', 'integer'); $table1->setPrimaryKey(['id']); From 69253bc083fbc45a693c4c770f921bc570193ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 9 Jun 2022 17:43:48 +0200 Subject: [PATCH 120/475] Use a better check for the DBAL version It seems AbstractPlatform::getGuidExpression() cannot do the trick, as it is missing from both branches. --- tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php index b2ea93e2511..afcf08d4773 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php @@ -5,8 +5,8 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\Common\Collections\Collection; -use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\MySQLPlatform; +use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; @@ -17,7 +17,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use function method_exists; +use function class_exists; class GH6823Test extends OrmFunctionalTestCase { @@ -27,7 +27,7 @@ public function testCharsetCollationWhenCreatingForeignRelations(): void self::markTestSkipped('This test is useful for all databases, but designed only for mysql.'); } - if (method_exists(AbstractPlatform::class, 'getGuidExpression')) { + if (! class_exists(RemoveNamespacedAssets::class)) { self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); } From e1ebd77811608a6523d5c64dba94ffde826ee0a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 9 Jun 2022 18:01:47 +0200 Subject: [PATCH 121/475] Run test only with DBAL 3 With DBAL 4, there is no longer a filtering of assets. --- .../ORM/Functional/SchemaTool/MySqlSchemaToolTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 9406c5a961d..f9652406c63 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; use Doctrine\DBAL\Platforms\MySQLPlatform; +use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; @@ -21,6 +22,8 @@ use Doctrine\Tests\Models\Generic\DecimalModel; use Doctrine\Tests\OrmFunctionalTestCase; +use function class_exists; + class MySqlSchemaToolTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -101,6 +104,10 @@ public function testGetCreateSchemaSql3(): void */ public function testGetCreateSchemaSql4(): void { + if (! class_exists(Visitor::class)) { + self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); + } + $classes = [$this->_em->getClassMetadata(MysqlSchemaNamespacedEntity::class)]; $tool = new SchemaTool($this->_em); From bf24177bfd92b5d55146f2c67b8ed7650529e609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 9 Jun 2022 21:16:36 +0200 Subject: [PATCH 122/475] Run test with DBAL 4 --- .../ORM/Functional/Ticket/GH6823Test.php | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php index afcf08d4773..e8c4c1cc922 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php @@ -27,23 +27,32 @@ public function testCharsetCollationWhenCreatingForeignRelations(): void self::markTestSkipped('This test is useful for all databases, but designed only for mysql.'); } - if (! class_exists(RemoveNamespacedAssets::class)) { - self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); - } - $this->createSchemaForModels( GH6823User::class, GH6823Group::class, GH6823Status::class ); - self::assertEquals('CREATE TABLE gh6823_user (id VARCHAR(255) NOT NULL, group_id VARCHAR(255) CHARACTER SET ascii DEFAULT NULL COLLATE `ascii_general_ci`, status_id VARCHAR(255) CHARACTER SET latin1 DEFAULT NULL COLLATE `latin1_bin`, INDEX IDX_70DD1774FE54D947 (group_id), INDEX IDX_70DD17746BF700BD (status_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_bin` ENGINE = InnoDB', $this->getLastLoggedQuery(6)['sql']); - self::assertEquals('CREATE TABLE gh6823_user_tags (user_id VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_bin`, tag_id VARCHAR(255) CHARACTER SET latin1 NOT NULL COLLATE `latin1_bin`, INDEX IDX_596B1281A76ED395 (user_id), INDEX IDX_596B1281BAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET ascii COLLATE `ascii_general_ci` ENGINE = InnoDB', $this->getLastLoggedQuery(5)['sql']); - self::assertEquals('CREATE TABLE gh6823_group (id VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET ascii COLLATE `ascii_general_ci` ENGINE = InnoDB', $this->getLastLoggedQuery(4)['sql']); - self::assertEquals('CREATE TABLE gh6823_status (id VARCHAR(255) CHARACTER SET latin1 NOT NULL COLLATE `latin1_bin`, PRIMARY KEY(id)) DEFAULT CHARACTER SET koi8r COLLATE `koi8r_bin` ENGINE = InnoDB', $this->getLastLoggedQuery(3)['sql']); - self::assertEquals('ALTER TABLE gh6823_user ADD CONSTRAINT FK_70DD1774FE54D947 FOREIGN KEY (group_id) REFERENCES gh6823_group (id)', $this->getLastLoggedQuery(2)['sql']); - self::assertEquals('ALTER TABLE gh6823_user ADD CONSTRAINT FK_70DD17746BF700BD FOREIGN KEY (status_id) REFERENCES gh6823_status (id)', $this->getLastLoggedQuery(1)['sql']); - self::assertEquals('ALTER TABLE gh6823_user_tags ADD CONSTRAINT FK_596B1281A76ED395 FOREIGN KEY (user_id) REFERENCES gh6823_user (id)', $this->getLastLoggedQuery(0)['sql']); + if (class_exists(RemoveNamespacedAssets::class)) { + self::assertEquals('CREATE TABLE gh6823_user (id VARCHAR(255) NOT NULL, group_id VARCHAR(255) CHARACTER SET ascii DEFAULT NULL COLLATE `ascii_general_ci`, status_id VARCHAR(255) CHARACTER SET latin1 DEFAULT NULL COLLATE `latin1_bin`, INDEX IDX_70DD1774FE54D947 (group_id), INDEX IDX_70DD17746BF700BD (status_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_bin` ENGINE = InnoDB', $this->getLastLoggedQuery(6)['sql']); + self::assertEquals('CREATE TABLE gh6823_user_tags (user_id VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_bin`, tag_id VARCHAR(255) CHARACTER SET latin1 NOT NULL COLLATE `latin1_bin`, INDEX IDX_596B1281A76ED395 (user_id), INDEX IDX_596B1281BAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET ascii COLLATE `ascii_general_ci` ENGINE = InnoDB', $this->getLastLoggedQuery(5)['sql']); + self::assertEquals('CREATE TABLE gh6823_group (id VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET ascii COLLATE `ascii_general_ci` ENGINE = InnoDB', $this->getLastLoggedQuery(4)['sql']); + self::assertEquals('CREATE TABLE gh6823_status (id VARCHAR(255) CHARACTER SET latin1 NOT NULL COLLATE `latin1_bin`, PRIMARY KEY(id)) DEFAULT CHARACTER SET koi8r COLLATE `koi8r_bin` ENGINE = InnoDB', $this->getLastLoggedQuery(3)['sql']); + self::assertEquals('ALTER TABLE gh6823_user ADD CONSTRAINT FK_70DD1774FE54D947 FOREIGN KEY (group_id) REFERENCES gh6823_group (id)', $this->getLastLoggedQuery(2)['sql']); + self::assertEquals('ALTER TABLE gh6823_user ADD CONSTRAINT FK_70DD17746BF700BD FOREIGN KEY (status_id) REFERENCES gh6823_status (id)', $this->getLastLoggedQuery(1)['sql']); + self::assertEquals('ALTER TABLE gh6823_user_tags ADD CONSTRAINT FK_596B1281A76ED395 FOREIGN KEY (user_id) REFERENCES gh6823_user (id)', $this->getLastLoggedQuery(0)['sql']); + + return; + } + + self::assertEquals('CREATE TABLE gh6823_user (id VARCHAR(255) NOT NULL, group_id VARCHAR(255) CHARACTER SET ascii DEFAULT NULL COLLATE `ascii_general_ci`, status_id VARCHAR(255) CHARACTER SET latin1 DEFAULT NULL COLLATE `latin1_bin`, INDEX IDX_70DD1774FE54D947 (group_id), INDEX IDX_70DD17746BF700BD (status_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_bin` ENGINE = InnoDB', $this->getLastLoggedQuery(7)['sql']); + self::assertEquals('CREATE TABLE gh6823_user_tags (user_id VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_bin`, tag_id VARCHAR(255) CHARACTER SET latin1 NOT NULL COLLATE `latin1_bin`, INDEX IDX_596B1281A76ED395 (user_id), INDEX IDX_596B1281BAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET ascii COLLATE `ascii_general_ci` ENGINE = InnoDB', $this->getLastLoggedQuery(6)['sql']); + self::assertEquals('CREATE TABLE gh6823_group (id VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET ascii COLLATE `ascii_general_ci` ENGINE = InnoDB', $this->getLastLoggedQuery(5)['sql']); + self::assertEquals('CREATE TABLE gh6823_status (id VARCHAR(255) CHARACTER SET latin1 NOT NULL COLLATE `latin1_bin`, PRIMARY KEY(id)) DEFAULT CHARACTER SET koi8r COLLATE `koi8r_bin` ENGINE = InnoDB', $this->getLastLoggedQuery(4)['sql']); + self::assertEquals('ALTER TABLE gh6823_user ADD CONSTRAINT FK_70DD1774FE54D947 FOREIGN KEY (group_id) REFERENCES gh6823_group (id)', $this->getLastLoggedQuery(3)['sql']); + self::assertEquals('ALTER TABLE gh6823_user ADD CONSTRAINT FK_70DD17746BF700BD FOREIGN KEY (status_id) REFERENCES gh6823_status (id)', $this->getLastLoggedQuery(2)['sql']); + self::assertEquals('ALTER TABLE gh6823_user_tags ADD CONSTRAINT FK_596B1281A76ED395 FOREIGN KEY (user_id) REFERENCES gh6823_user (id)', $this->getLastLoggedQuery(1)['sql']); + self::assertEquals('ALTER TABLE gh6823_user_tags ADD CONSTRAINT FK_596B1281BAD26311 FOREIGN KEY (tag_id) REFERENCES gh6823_tag (id)', $this->getLastLoggedQuery()['sql']); } } From e22bfec6b6634246f7f1d1c3d51f644c5763d91d Mon Sep 17 00:00:00 2001 From: Marc Brillault Date: Thu, 9 Jun 2022 15:47:01 +0200 Subject: [PATCH 123/475] migrate Tools/Schema* to php8.0 refs #9772 --- lib/Doctrine/ORM/Tools/SchemaTool.php | 55 ++++++---------------- lib/Doctrine/ORM/Tools/SchemaValidator.php | 14 ++---- 2 files changed, 19 insertions(+), 50 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 83b75496752..95fffc2a3c7 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -46,29 +46,16 @@ class SchemaTool { private const KNOWN_COLUMN_OPTIONS = ['comment', 'unsigned', 'fixed', 'default']; - /** @var EntityManagerInterface */ - private $em; - - /** @var AbstractPlatform */ - private $platform; - - /** - * The quote strategy. - * - * @var QuoteStrategy - */ - private $quoteStrategy; - - /** @var AbstractSchemaManager */ - private $schemaManager; + private AbstractPlatform $platform; + private QuoteStrategy $quoteStrategy; + private AbstractSchemaManager $schemaManager; /** * Initializes a new SchemaTool instance that uses the connection of the * provided EntityManager. */ - public function __construct(EntityManagerInterface $em) + public function __construct(private EntityManagerInterface $em) { - $this->em = $em; $this->platform = $em->getConnection()->getDatabasePlatform(); $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); $this->schemaManager = $em->getConnection()->createSchemaManager(); @@ -79,11 +66,9 @@ public function __construct(EntityManagerInterface $em) * * @psalm-param list $classes * - * @return void - * * @throws ToolsException */ - public function createSchema(array $classes) + public function createSchema(array $classes): void { $createSchemaSql = $this->getCreateSchemaSql($classes); $conn = $this->em->getConnection(); @@ -105,7 +90,7 @@ public function createSchema(array $classes) * * @return string[] The SQL statements needed to create the schema for the classes. */ - public function getCreateSchemaSql(array $classes) + public function getCreateSchemaSql(array $classes): array { $schema = $this->getSchemaFromMetadata($classes); @@ -176,11 +161,9 @@ private function getIndexColumns(ClassMetadata $class, array $indexData): array * * @psalm-param list $classes * - * @return Schema - * * @throws NotSupported */ - public function getSchemaFromMetadata(array $classes) + public function getSchemaFromMetadata(array $classes): Schema { // Reminder for processed classes, used for hierarchies $processedClasses = []; @@ -260,9 +243,7 @@ public function getSchemaFromMetadata(array $classes) $targetEntity = current( array_filter( $classes, - static function (ClassMetadata $class) use ($idMapping): bool { - return $class->name === $idMapping['targetEntity']; - } + static fn (ClassMetadata $class): bool => $class->name === $idMapping['targetEntity'] ) ); @@ -812,10 +793,8 @@ private function gatherColumnOptions(array $mapping): array * issued for all classes of the schema and some probably just don't exist. * * @psalm-param list $classes - * - * @return void */ - public function dropSchema(array $classes) + public function dropSchema(array $classes): void { $dropSchemaSql = $this->getDropSchemaSQL($classes); $conn = $this->em->getConnection(); @@ -823,7 +802,7 @@ public function dropSchema(array $classes) foreach ($dropSchemaSql as $sql) { try { $conn->executeQuery($sql); - } catch (Throwable $e) { + } catch (Throwable) { // ignored } } @@ -831,10 +810,8 @@ public function dropSchema(array $classes) /** * Drops all elements in the database of the current connection. - * - * @return void */ - public function dropDatabase() + public function dropDatabase(): void { $dropSchemaSql = $this->getDropDatabaseSQL(); $conn = $this->em->getConnection(); @@ -849,7 +826,7 @@ public function dropDatabase() * * @return string[] */ - public function getDropDatabaseSQL() + public function getDropDatabaseSQL(): array { return $this->schemaManager ->createSchema() @@ -863,7 +840,7 @@ public function getDropDatabaseSQL() * * @return string[] */ - public function getDropSchemaSQL(array $classes) + public function getDropSchemaSQL(array $classes): array { $schema = $this->getSchemaFromMetadata($classes); @@ -905,10 +882,8 @@ public function getDropSchemaSQL(array $classes) * @param mixed[] $classes * @param bool $saveMode If TRUE, only performs a partial update * without dropping assets which are scheduled for deletion. - * - * @return void */ - public function updateSchema(array $classes, $saveMode = false) + public function updateSchema(array $classes, $saveMode = false): void { $updateSchemaSql = $this->getUpdateSchemaSql($classes, $saveMode); $conn = $this->em->getConnection(); @@ -928,7 +903,7 @@ public function updateSchema(array $classes, $saveMode = false) * * @return string[] The sequence of SQL statements. */ - public function getUpdateSchemaSql(array $classes, $saveMode = false) + public function getUpdateSchemaSql(array $classes, $saveMode = false): array { $toSchema = $this->getSchemaFromMetadata($classes); $fromSchema = $this->createSchemaForComparison($toSchema); diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 1cc79e5d2a0..deb47a2ae35 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -25,12 +25,8 @@ */ class SchemaValidator { - /** @var EntityManagerInterface */ - private $em; - - public function __construct(EntityManagerInterface $em) + public function __construct(private EntityManagerInterface $em) { - $this->em = $em; } /** @@ -45,7 +41,7 @@ public function __construct(EntityManagerInterface $em) * * @psalm-return array> */ - public function validateMapping() + public function validateMapping(): array { $errors = []; $cmf = $this->em->getMetadataFactory(); @@ -67,7 +63,7 @@ public function validateMapping() * @return string[] * @psalm-return list */ - public function validateClass(ClassMetadata $class) + public function validateClass(ClassMetadata $class): array { $ce = []; $cmf = $this->em->getMetadataFactory(); @@ -257,10 +253,8 @@ public function validateClass(ClassMetadata $class) /** * Checks if the Database Schema is in sync with the current metadata state. - * - * @return bool */ - public function schemaInSyncWithMetadata() + public function schemaInSyncWithMetadata(): bool { return count($this->getUpdateSchemaList()) === 0; } From 2d230ce033f72519f3de9e681a07b26e7199ac7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 10 Jun 2022 21:09:37 +0200 Subject: [PATCH 124/475] Stop allowing identity columns emulation That feature has been deprecated. --- UPGRADE.md | 5 ++ .../ORM/Id/BigIntegerIdentityGenerator.php | 21 +----- lib/Doctrine/ORM/Id/IdentityGenerator.php | 21 +----- .../ORM/Mapping/ClassMetadataFactory.php | 38 +--------- phpstan-dbal4.neon | 7 -- psalm-baseline.xml | 2 +- .../SequenceEmulatedIdentityStrategyTest.php | 71 ------------------- .../ORM/Mapping/ClassMetadataFactoryTest.php | 21 ------ 8 files changed, 10 insertions(+), 176 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php diff --git a/UPGRADE.md b/UPGRADE.md index fba8e47aa2b..f849e309db6 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: Removed identity columns emulation through sequences + +If the platform you are using does not support identity columns, you should +switch to the `SEQUENCE` strategy. + ## BC BREAK: Made setters parameters mandatory The following methods require an argument when being called. Pass `null` diff --git a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php b/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php index 7a76286d898..79f8dd438d4 100644 --- a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Id; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; /** @@ -14,27 +13,9 @@ */ class BigIntegerIdentityGenerator extends AbstractIdGenerator { - /** - * @param string|null $sequenceName The name of the sequence to pass to lastInsertId() - * to obtain the last generated identifier within the current - * database session/connection, if any. - */ - public function __construct( - private ?string $sequenceName = null - ) { - if ($sequenceName !== null) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8850', - 'Passing a sequence name to the IdentityGenerator is deprecated in favor of using %s. $sequenceName will be removed in ORM 3.0', - SequenceGenerator::class - ); - } - } - public function generateId(EntityManagerInterface $em, ?object $entity): string { - return (string) $em->getConnection()->lastInsertId($this->sequenceName); + return (string) $em->getConnection()->lastInsertId(); } public function isPostInsertGenerator(): bool diff --git a/lib/Doctrine/ORM/Id/IdentityGenerator.php b/lib/Doctrine/ORM/Id/IdentityGenerator.php index aca008b8049..4d111dc6172 100644 --- a/lib/Doctrine/ORM/Id/IdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/IdentityGenerator.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Id; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; /** @@ -14,27 +13,9 @@ */ class IdentityGenerator extends AbstractIdGenerator { - /** - * @param string|null $sequenceName The name of the sequence to pass to lastInsertId() - * to obtain the last generated identifier within the current - * database session/connection, if any. - */ - public function __construct( - private ?string $sequenceName = null - ) { - if ($sequenceName !== null) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8850', - 'Passing a sequence name to the IdentityGenerator is deprecated in favor of using %s. $sequenceName will be removed in ORM 3.0', - SequenceGenerator::class - ); - } - } - public function generateId(EntityManagerInterface $em, ?object $entity): int { - return (int) $em->getConnection()->lastInsertId($this->sequenceName); + return (int) $em->getConnection()->lastInsertId(); } public function isPostInsertGenerator(): bool diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index aaf4eecde71..05139391278 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -32,7 +32,6 @@ use function count; use function end; use function explode; -use function get_class; use function in_array; use function is_subclass_of; use function str_contains; @@ -491,42 +490,9 @@ private function completeIdGeneratorMapping(ClassMetadata $class): void $sequenceName = null; $fieldName = $class->identifier ? $class->getSingleIdentifierFieldName() : null; - // Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour. - if ($this->getTargetPlatform()->usesSequenceEmulatedIdentityColumns()) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8850', - <<<'DEPRECATION' -Context: Loading metadata for class %s -Problem: Using the IDENTITY generator strategy with platform "%s" is deprecated and will not be possible in Doctrine ORM 3.0. -Solution: Use the SEQUENCE generator strategy instead. -DEPRECATION - , - $class->name, - get_class($this->getTargetPlatform()) - ); - $columnName = $class->getSingleIdentifierColumnName(); - $quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']); - $sequencePrefix = $class->getSequencePrefix($this->getTargetPlatform()); - $sequenceName = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName); - $definition = [ - 'sequenceName' => $this->truncateSequenceName($sequenceName), - ]; - - if ($quoted) { - $definition['quoted'] = true; - } - - $sequenceName = $this - ->em - ->getConfiguration() - ->getQuoteStrategy() - ->getSequenceName($definition, $class, $this->getTargetPlatform()); - } - $generator = $fieldName && $class->fieldMappings[$fieldName]['type'] === 'bigint' - ? new BigIntegerIdentityGenerator($sequenceName) - : new IdentityGenerator($sequenceName); + ? new BigIntegerIdentityGenerator() + : new IdentityGenerator(); $class->setIdGenerator($generator); diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon index 9b9710ad85e..b8c63ba0d5b 100644 --- a/phpstan-dbal4.neon +++ b/phpstan-dbal4.neon @@ -15,13 +15,6 @@ parameters: message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~' path: lib/Doctrine/ORM/UnitOfWork.php - # See https://github.com/doctrine/orm/issues/8850 - - - message: '~^Method Doctrine\\DBAL\\Connection::lastInsertId\(\) invoked with 1 parameter, 0 required\.$~' - paths: - - lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php - - lib/Doctrine/ORM/Id/IdentityGenerator.php - - message: '~^Parameter #1 \$command of method Symfony\\Component\\Console\\Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command, Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand given\.$~' path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c5e3922a4bf..b872bcda1dc 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -386,7 +386,7 @@ $this->em $this->em - + getAllClassNames getConfiguration getConfiguration diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php deleted file mode 100644 index 3c5d178620c..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php +++ /dev/null @@ -1,71 +0,0 @@ -_em->getConnection()->getDatabasePlatform()->usesSequenceEmulatedIdentityColumns()) { - self::markTestSkipped( - 'This test is special to platforms emulating IDENTITY key generation strategy through sequences.' - ); - } else { - $this->createSchemaForModels(SequenceEmulatedIdentityEntity::class); - } - } - - public function testPreSavePostSaveCallbacksAreInvoked(): void - { - $entity = new SequenceEmulatedIdentityEntity(); - $entity->setValue('hello'); - $this->_em->persist($entity); - $this->_em->flush(); - self::assertIsNumeric($entity->getId()); - self::assertGreaterThan(0, $entity->getId()); - self::assertTrue($this->_em->contains($entity)); - } -} - -/** - * @Entity - * @Table(name="seq_identity") - */ -class SequenceEmulatedIdentityEntity -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="IDENTITY") - */ - private int $id; - - /** @Column(type="string", length=255) */ - private ?string $value = null; - - public function getId(): int - { - return $this->id; - } - - public function getValue(): string - { - return $this->value; - } - - public function setValue(string $value): void - { - $this->value = $value; - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index c496f403e71..e0101867488 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -96,27 +96,6 @@ public function testGetMetadataForSingleClass(): void self::assertTrue($cmMap1->hasField('name')); } - public function testUsingIdentityWithAPlatformThatDoesNotSupportIdentityColumnsIsDeprecated(): void - { - $cm = $this->createValidClassMetadata(); - $cm->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_IDENTITY); - $cmf = new ClassMetadataFactoryTestSubject(); - $driver = $this->createMock(Driver::class); - $platform = $this->createStub(AbstractPlatform::class); - $platform->method('usesSequenceEmulatedIdentityColumns')->willReturn(true); - $platform->method('getIdentitySequenceName')->willReturn('whatever'); - $driver->method('getDatabasePlatform')->willReturn($platform); - $entityManager = $this->createEntityManager( - new MetadataDriverMock(), - new Connection([], $driver) - ); - $cmf->setEntityManager($entityManager); - $cmf->setMetadataForClass($cm->name, $cm); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8850'); - $cmf->getMetadataFor($cm->name); - } - public function testItThrowsWhenUsingAutoWithIncompatiblePlatform(): void { $cm1 = $this->createValidClassMetadata(); From d52f9ee87ed180c61bdfc2209fc5d74f56a4a26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 4 Jun 2022 17:59:50 +0200 Subject: [PATCH 125/475] Migrate Configuration to PHP 8 syntax --- lib/Doctrine/ORM/Configuration.php | 197 +++++++---------------------- lib/Doctrine/ORM/Query/Parser.php | 6 +- psalm-baseline.xml | 5 +- 3 files changed, 52 insertions(+), 156 deletions(-) diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index a8c8e133e33..fd904a31900 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -38,26 +38,20 @@ class Configuration extends \Doctrine\DBAL\Configuration { /** @var mixed[] */ - protected $_attributes = []; + protected array $_attributes = []; /** * Sets the directory where Doctrine generates any necessary proxy class files. - * - * @param string $dir - * - * @return void */ - public function setProxyDir($dir) + public function setProxyDir(string $dir): void { $this->_attributes['proxyDir'] = $dir; } /** * Gets the directory where Doctrine generates any necessary proxy class files. - * - * @return string|null */ - public function getProxyDir() + public function getProxyDir(): string|null { return $this->_attributes['proxyDir'] ?? null; } @@ -68,7 +62,7 @@ public function getProxyDir() * @return int Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory. * @psalm-return AutogenerateMode */ - public function getAutoGenerateProxyClasses() + public function getAutoGenerateProxyClasses(): int { return $this->_attributes['autoGenerateProxyClasses'] ?? AbstractProxyFactory::AUTOGENERATE_ALWAYS; } @@ -79,32 +73,24 @@ public function getAutoGenerateProxyClasses() * @param bool|int $autoGenerate Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory. * @psalm-param bool|AutogenerateMode $autoGenerate * True is converted to AUTOGENERATE_ALWAYS, false to AUTOGENERATE_NEVER. - * - * @return void */ - public function setAutoGenerateProxyClasses($autoGenerate) + public function setAutoGenerateProxyClasses(bool|int $autoGenerate): void { $this->_attributes['autoGenerateProxyClasses'] = (int) $autoGenerate; } /** * Gets the namespace where proxy classes reside. - * - * @return string|null */ - public function getProxyNamespace() + public function getProxyNamespace(): string|null { return $this->_attributes['proxyNamespace'] ?? null; } /** * Sets the namespace where proxy classes reside. - * - * @param string $ns - * - * @return void */ - public function setProxyNamespace($ns) + public function setProxyNamespace(string $ns): void { $this->_attributes['proxyNamespace'] = $ns; } @@ -112,12 +98,10 @@ public function setProxyNamespace($ns) /** * Sets the cache driver implementation that is used for metadata caching. * - * @return void - * * @todo Force parameter to be a Closure to ensure lazy evaluation * (as soon as a metadata cache is in effect, the driver never needs to initialize). */ - public function setMetadataDriverImpl(MappingDriver $driverImpl) + public function setMetadataDriverImpl(MappingDriver $driverImpl): void { $this->_attributes['metadataDriverImpl'] = $driverImpl; } @@ -126,10 +110,8 @@ public function setMetadataDriverImpl(MappingDriver $driverImpl) * Sets the entity alias map. * * @psalm-param array $entityNamespaces - * - * @return void */ - public function setEntityNamespaces(array $entityNamespaces) + public function setEntityNamespaces(array $entityNamespaces): void { $this->_attributes['entityNamespaces'] = $entityNamespaces; } @@ -139,17 +121,15 @@ public function setEntityNamespaces(array $entityNamespaces) * * @psalm-return array */ - public function getEntityNamespaces() + public function getEntityNamespaces(): array { return $this->_attributes['entityNamespaces']; } /** * Gets the cache driver implementation that is used for the mapping metadata. - * - * @return MappingDriver|null */ - public function getMetadataDriverImpl() + public function getMetadataDriverImpl(): ?MappingDriver { return $this->_attributes['metadataDriverImpl'] ?? null; } @@ -197,13 +177,10 @@ public function setMetadataCache(CacheItemPoolInterface $cache): void * * DQL function names are case-insensitive. * - * @param string $name Function name. * @param class-string|callable $className Class name or a callable that returns the function. * @psalm-param class-string|callable(string):FunctionNode $className - * - * @return void */ - public function addCustomStringFunction($name, $className) + public function addCustomStringFunction(string $name, string|callable $className): void { $this->_attributes['customStringFunctions'][strtolower($name)] = $className; } @@ -211,12 +188,9 @@ public function addCustomStringFunction($name, $className) /** * Gets the implementation class name of a registered custom string DQL function. * - * @param string $name - * - * @return string|callable|null * @psalm-return class-string|callable(string):FunctionNode|null */ - public function getCustomStringFunction($name) + public function getCustomStringFunction(string $name): string|callable|null { $name = strtolower($name); @@ -233,10 +207,8 @@ public function getCustomStringFunction($name) * * @psalm-param array|callable(string):FunctionNode> $functions The map of custom * DQL string functions. - * - * @return void */ - public function setCustomStringFunctions(array $functions) + public function setCustomStringFunctions(array $functions): void { foreach ($functions as $name => $className) { $this->addCustomStringFunction($name, $className); @@ -250,13 +222,10 @@ public function setCustomStringFunctions(array $functions) * * DQL function names are case-insensitive. * - * @param string $name Function name. * @param class-string|callable $className Class name or a callable that returns the function. * @psalm-param class-string|callable(string):FunctionNode $className - * - * @return void */ - public function addCustomNumericFunction($name, $className) + public function addCustomNumericFunction(string $name, string|callable $className): void { $this->_attributes['customNumericFunctions'][strtolower($name)] = $className; } @@ -264,12 +233,9 @@ public function addCustomNumericFunction($name, $className) /** * Gets the implementation class name of a registered custom numeric DQL function. * - * @param string $name - * - * @return string|callable|null - * @psalm-return class-string|callable|null + * @psalm-return ?class-string|callable(string):FunctionNode */ - public function getCustomNumericFunction($name) + public function getCustomNumericFunction(string $name): string|callable|null { $name = strtolower($name); @@ -286,10 +252,8 @@ public function getCustomNumericFunction($name) * * @psalm-param array $functions The map of custom * DQL numeric functions. - * - * @return void */ - public function setCustomNumericFunctions(array $functions) + public function setCustomNumericFunctions(array $functions): void { foreach ($functions as $name => $className) { $this->addCustomNumericFunction($name, $className); @@ -303,13 +267,10 @@ public function setCustomNumericFunctions(array $functions) * * DQL function names are case-insensitive. * - * @param string $name Function name. * @param string|callable $className Class name or a callable that returns the function. * @psalm-param class-string|callable(string):FunctionNode $className - * - * @return void */ - public function addCustomDatetimeFunction($name, $className) + public function addCustomDatetimeFunction(string $name, string|callable $className): void { $this->_attributes['customDatetimeFunctions'][strtolower($name)] = $className; } @@ -317,12 +278,9 @@ public function addCustomDatetimeFunction($name, $className) /** * Gets the implementation class name of a registered custom date/time DQL function. * - * @param string $name - * - * @return string|callable|null * @psalm-return class-string|callable|null $name */ - public function getCustomDatetimeFunction($name) + public function getCustomDatetimeFunction(string $name): string|callable|null { $name = strtolower($name); @@ -339,10 +297,8 @@ public function getCustomDatetimeFunction($name) * * @param array $functions The map of custom DQL date/time functions. * @psalm-param array|callable(string):FunctionNode> $functions - * - * @return void */ - public function setCustomDatetimeFunctions(array $functions) + public function setCustomDatetimeFunctions(array $functions): void { foreach ($functions as $name => $className) { $this->addCustomDatetimeFunction($name, $className); @@ -353,10 +309,8 @@ public function setCustomDatetimeFunctions(array $functions) * Sets the custom hydrator modes in one pass. * * @param array> $modes An array of ($modeName => $hydrator). - * - * @return void */ - public function setCustomHydrationModes($modes) + public function setCustomHydrationModes(array $modes): void { $this->_attributes['customHydrationModes'] = []; @@ -368,12 +322,9 @@ public function setCustomHydrationModes($modes) /** * Gets the hydrator class for the given hydration mode name. * - * @param string $modeName The hydration mode name. - * - * @return string|null The hydrator class name. * @psalm-return class-string|null */ - public function getCustomHydrationMode($modeName) + public function getCustomHydrationMode(string $modeName): ?string { return $this->_attributes['customHydrationModes'][$modeName] ?? null; } @@ -381,13 +332,9 @@ public function getCustomHydrationMode($modeName) /** * Adds a custom hydration mode. * - * @param string $modeName The hydration mode name. - * @param string $hydrator The hydrator class name. * @psalm-param class-string $hydrator - * - * @return void */ - public function addCustomHydrationMode($modeName, $hydrator) + public function addCustomHydrationMode(string $modeName, string $hydrator): void { $this->_attributes['customHydrationModes'][$modeName] = $hydrator; } @@ -395,21 +342,17 @@ public function addCustomHydrationMode($modeName, $hydrator) /** * Sets a class metadata factory. * - * @param string $cmfName * @psalm-param class-string $cmfName - * - * @return void */ - public function setClassMetadataFactoryName($cmfName) + public function setClassMetadataFactoryName(string $cmfName): void { $this->_attributes['classMetadataFactoryName'] = $cmfName; } /** - * @return string * @psalm-return class-string */ - public function getClassMetadataFactoryName() + public function getClassMetadataFactoryName(): string { if (! isset($this->_attributes['classMetadataFactoryName'])) { $this->_attributes['classMetadataFactoryName'] = ClassMetadataFactory::class; @@ -421,13 +364,12 @@ public function getClassMetadataFactoryName() /** * Adds a filter to the list of possible filters. * - * @param string $name The name of the filter. * @param string $className The class name of the filter. * @psalm-param class-string $className * * @return void */ - public function addFilter($name, $className) + public function addFilter(string $name, string $className) { $this->_attributes['filters'][$name] = $className; } @@ -435,13 +377,11 @@ public function addFilter($name, $className) /** * Gets the class name for a given filter name. * - * @param string $name The name of the filter. - * * @return string|null The class name of the filter, or null if it is not * defined. * @psalm-return class-string|null */ - public function getFilterClassName($name) + public function getFilterClassName(string $name): ?string { return $this->_attributes['filters'][$name] ?? null; } @@ -449,14 +389,11 @@ public function getFilterClassName($name) /** * Sets default repository class. * - * @param string $className * @psalm-param class-string $className * - * @return void - * * @throws InvalidEntityRepository If $classname is not an ObjectRepository. */ - public function setDefaultRepositoryClassName($className) + public function setDefaultRepositoryClassName(string $className): void { if (! class_exists($className) || ! is_a($className, EntityRepository::class, true)) { throw InvalidEntityRepository::fromClassName($className); @@ -468,30 +405,25 @@ public function setDefaultRepositoryClassName($className) /** * Get default repository class. * - * @return string * @psalm-return class-string */ - public function getDefaultRepositoryClassName() + public function getDefaultRepositoryClassName(): string { return $this->_attributes['defaultRepositoryClassName'] ?? EntityRepository::class; } /** * Sets naming strategy. - * - * @return void */ - public function setNamingStrategy(NamingStrategy $namingStrategy) + public function setNamingStrategy(NamingStrategy $namingStrategy): void { $this->_attributes['namingStrategy'] = $namingStrategy; } /** * Gets naming strategy.. - * - * @return NamingStrategy */ - public function getNamingStrategy() + public function getNamingStrategy(): NamingStrategy { if (! isset($this->_attributes['namingStrategy'])) { $this->_attributes['namingStrategy'] = new DefaultNamingStrategy(); @@ -502,20 +434,16 @@ public function getNamingStrategy() /** * Sets quote strategy. - * - * @return void */ - public function setQuoteStrategy(QuoteStrategy $quoteStrategy) + public function setQuoteStrategy(QuoteStrategy $quoteStrategy): void { $this->_attributes['quoteStrategy'] = $quoteStrategy; } /** * Gets quote strategy. - * - * @return QuoteStrategy */ - public function getQuoteStrategy() + public function getQuoteStrategy(): QuoteStrategy { if (! isset($this->_attributes['quoteStrategy'])) { $this->_attributes['quoteStrategy'] = new DefaultQuoteStrategy(); @@ -526,20 +454,16 @@ public function getQuoteStrategy() /** * Set the entity listener resolver. - * - * @return void */ - public function setEntityListenerResolver(EntityListenerResolver $resolver) + public function setEntityListenerResolver(EntityListenerResolver $resolver): void { $this->_attributes['entityListenerResolver'] = $resolver; } /** * Get the entity listener resolver. - * - * @return EntityListenerResolver */ - public function getEntityListenerResolver() + public function getEntityListenerResolver(): EntityListenerResolver { if (! isset($this->_attributes['entityListenerResolver'])) { $this->_attributes['entityListenerResolver'] = new DefaultEntityListenerResolver(); @@ -550,54 +474,36 @@ public function getEntityListenerResolver() /** * Set the entity repository factory. - * - * @return void */ - public function setRepositoryFactory(RepositoryFactory $repositoryFactory) + public function setRepositoryFactory(RepositoryFactory $repositoryFactory): void { $this->_attributes['repositoryFactory'] = $repositoryFactory; } /** * Get the entity repository factory. - * - * @return RepositoryFactory */ - public function getRepositoryFactory() + public function getRepositoryFactory(): RepositoryFactory { return $this->_attributes['repositoryFactory'] ?? new DefaultRepositoryFactory(); } - /** - * @return bool - */ - public function isSecondLevelCacheEnabled() + public function isSecondLevelCacheEnabled(): bool { return $this->_attributes['isSecondLevelCacheEnabled'] ?? false; } - /** - * @param bool $flag - * - * @return void - */ - public function setSecondLevelCacheEnabled($flag = true) + public function setSecondLevelCacheEnabled(bool $flag = true): void { - $this->_attributes['isSecondLevelCacheEnabled'] = (bool) $flag; + $this->_attributes['isSecondLevelCacheEnabled'] = $flag; } - /** - * @return void - */ - public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig) + public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig): void { $this->_attributes['secondLevelCacheConfiguration'] = $cacheConfig; } - /** - * @return CacheConfiguration|null - */ - public function getSecondLevelCacheConfiguration() + public function getSecondLevelCacheConfiguration(): ?CacheConfiguration { if (! isset($this->_attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) { $this->_attributes['secondLevelCacheConfiguration'] = new CacheConfiguration(); @@ -611,7 +517,7 @@ public function getSecondLevelCacheConfiguration() * * @psalm-return array */ - public function getDefaultQueryHints() + public function getDefaultQueryHints(): array { return $this->_attributes['defaultQueryHints'] ?? []; } @@ -620,10 +526,8 @@ public function getDefaultQueryHints() * Sets array of query hints, which will be applied to every query in application * * @psalm-param array $defaultQueryHints - * - * @return void */ - public function setDefaultQueryHints(array $defaultQueryHints) + public function setDefaultQueryHints(array $defaultQueryHints): void { $this->_attributes['defaultQueryHints'] = $defaultQueryHints; } @@ -631,24 +535,17 @@ public function setDefaultQueryHints(array $defaultQueryHints) /** * Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned. * - * @param string $name The name of the hint. - * * @return mixed The value of the hint or FALSE, if the hint name is not recognized. */ - public function getDefaultQueryHint($name) + public function getDefaultQueryHint(string $name): mixed { return $this->_attributes['defaultQueryHints'][$name] ?? false; } /** * Sets a default query hint. If the hint name is not recognized, it is silently ignored. - * - * @param string $name The name of the hint. - * @param mixed $value The value of the hint. - * - * @return void */ - public function setDefaultQueryHint($name, $value) + public function setDefaultQueryHint(string $name, mixed $value): void { $this->_attributes['defaultQueryHints'][$name] = $value; } diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index feed67e4fa0..418410f5de1 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -3580,7 +3580,8 @@ public function FunctionsReturningDatetime() public function CustomFunctionsReturningDatetime() { // getCustomDatetimeFunction is case-insensitive - $functionName = $this->lexer->lookahead['value']; + $functionName = $this->lexer->lookahead['value']; + assert(is_string($functionName)); $functionClass = $this->em->getConfiguration()->getCustomDatetimeFunction($functionName); assert($functionClass !== null); @@ -3622,7 +3623,8 @@ public function FunctionsReturningStrings() public function CustomFunctionsReturningStrings() { // getCustomStringFunction is case-insensitive - $functionName = $this->lexer->lookahead['value']; + $functionName = $this->lexer->lookahead['value']; + assert(is_string($functionName)); $functionClass = $this->em->getConfiguration()->getCustomStringFunction($functionName); assert($functionClass !== null); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b872bcda1dc..04a96ecc852 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -180,9 +180,6 @@ $className - - (bool) $flag - @@ -1834,7 +1831,7 @@ string string - + $field $field $functionName From 5ecf9e9202ab2192a6284d255023260acb7453da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 14 Jun 2022 15:03:06 +0200 Subject: [PATCH 126/475] update psalm baseline --- psalm-baseline.xml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 04a96ecc852..d39b0577456 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -219,9 +219,9 @@ new $metadataFactoryClassName() - + (string) $hydrationMode - + new $class($this) @@ -388,7 +388,6 @@ getConfiguration getConfiguration getConfiguration - getConfiguration getConnection hasListeners hasListeners @@ -425,6 +424,7 @@ ReflectionProperty ReflectionProperty getReflectionClass + string $definition @@ -449,6 +449,7 @@ class-string|null + $this->associationMappings[$assocName]['mappedBy'] $this->reflClass $this->reflFields[$name] $this->reflFields[$this->identifier[0]] @@ -480,11 +481,12 @@ $mapping['originalClass'] $mapping['originalField'] $mapping['targetEntity'] + $this->associationMappings[$assocName]['isOwningSide'] $this->associationMappings[$assocName]['joinColumns'] + $this->associationMappings[$assocName]['mappedBy'] $this->associationMappings[$fieldName]['joinColumns'] $this->associationMappings[$fieldName]['joinColumns'] $this->associationMappings[$idProperty]['joinColumns'] - $this->associationMappings[$idProperty]['joinColumns'] $idGenerator @@ -1835,8 +1837,6 @@ $field $field $functionName - $functionName - $functionName $this->lexer->getLiteral($token) $this->lexer->getLiteral($token) $this->lexer->getLiteral($token) @@ -2004,8 +2004,6 @@ $associationMapping['isOwningSide'] $associationMapping['isOwningSide'] - $associationMapping['isOwningSide'] - $associationMapping['joinColumns'] $associationMapping['joinColumns'] $associationMapping['joinColumns'] @@ -2390,8 +2388,6 @@ $this->identityMap[$rootClassName] - $assoc - $assoc $assoc $assoc $assoc['targetEntity'] From e22f02f198dee07807cc58236b7a8a756eef5315 Mon Sep 17 00:00:00 2001 From: Marc Brillault Date: Thu, 16 Jun 2022 17:14:50 +0200 Subject: [PATCH 127/475] Migrate Internal namespace to PHP8 --- .../ORM/Internal/CommitOrderCalculator.php | 27 +++++-------------- .../Internal/Hydration/AbstractHydrator.php | 17 ++++-------- .../ORM/Internal/Hydration/ArrayHydrator.php | 9 +++---- .../ORM/Internal/Hydration/ObjectHydrator.php | 26 +++++++----------- .../ORM/Internal/HydrationCompleteHandler.php | 19 +++---------- psalm-baseline.xml | 3 +++ 6 files changed, 30 insertions(+), 71 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php index b8f3b5e3b0f..cb0793e8cc6 100644 --- a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php +++ b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php @@ -38,36 +38,27 @@ class CommitOrderCalculator * * @var array */ - private $nodeList = []; + private array $nodeList = []; /** * Volatile variable holding calculated nodes during sorting process. * * @psalm-var list */ - private $sortedNodeList = []; + private array $sortedNodeList = []; /** * Checks for node (vertex) existence in graph. - * - * @param string $hash - * - * @return bool */ - public function hasNode($hash) + public function hasNode(string $hash): bool { return isset($this->nodeList[$hash]); } /** * Adds a new node (vertex) to the graph, assigning its hash and value. - * - * @param string $hash - * @param object $node - * - * @return void */ - public function addNode($hash, $node) + public function addNode(string $hash, object $node): void { $vertex = new stdClass(); @@ -81,14 +72,8 @@ public function addNode($hash, $node) /** * Adds a new dependency (edge) to the graph using their hashes. - * - * @param string $fromHash - * @param string $toHash - * @param int $weight - * - * @return void */ - public function addDependency($fromHash, $toHash, $weight) + public function addDependency(string $fromHash, string $toHash, int $weight): void { $vertex = $this->nodeList[$fromHash]; $edge = new stdClass(); @@ -108,7 +93,7 @@ public function addDependency($fromHash, $toHash, $weight) * * @psalm-return list */ - public function sort() + public function sort(): array { foreach ($this->nodeList as $vertex) { if ($vertex->state !== self::NOT_VISITED) { diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index acc2eaac4cb..4415a0c9514 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -36,11 +36,6 @@ abstract class AbstractHydrator */ protected ?ResultSetMapping $_rsm = null; - /** - * The EntityManager instance. - */ - protected EntityManagerInterface $_em; - /** * The dbms Platform instance. */ @@ -77,10 +72,12 @@ abstract class AbstractHydrator */ protected array $_hints = []; + protected EntityManagerInterface $_em; + /** * Initializes a new instance of a class derived from AbstractHydrator. */ - public function __construct(EntityManagerInterface $em) + public function __construct(protected EntityManagerInterface $em) { $this->_em = $em; $this->_platform = $em->getConnection()->getDatabasePlatform(); @@ -291,9 +288,7 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon if ($value !== null && isset($cacheKeyInfo['enumType'])) { $enumType = $cacheKeyInfo['enumType']; if (is_array($value)) { - $value = array_map(static function ($value) use ($enumType): BackedEnum { - return $enumType::from($value); - }, $value); + $value = array_map(static fn ($value): BackedEnum => $enumType::from($value), $value); } else { $value = $enumType::from($value); } @@ -486,9 +481,7 @@ protected function hydrateColumnInfo(string $key): ?array private function getDiscriminatorValues(ClassMetadata $classMetadata): array { $values = array_map( - function (string $subClass): string { - return (string) $this->getClassMetadata($subClass)->discriminatorValue; - }, + fn (string $subClass): string => (string) $this->getClassMetadata($subClass)->discriminatorValue, $classMetadata->subClasses ); diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index 7d71e826845..ea34ed573f4 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -6,8 +6,8 @@ use Doctrine\ORM\Mapping\ClassMetadata; +use function array_key_last; use function count; -use function end; use function is_array; use function key; use function reset; @@ -124,9 +124,7 @@ protected function hydrateRowData(array $row, array &$result): void $baseElement[$relationAlias][] = $element; } - end($baseElement[$relationAlias]); - - $this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = key($baseElement[$relationAlias]); + $this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = array_key_last($baseElement[$relationAlias]); } } } else { @@ -269,7 +267,6 @@ private function updateResultPointer( return; } - end($coll); - $this->_resultPointers[$dqlAlias] =& $coll[key($coll)]; + $this->_resultPointers[$dqlAlias] =& $coll[array_key_last($coll)]; } } diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index c05dcf974bf..c970610569c 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -27,25 +27,24 @@ class ObjectHydrator extends AbstractHydrator { /** @var mixed[] */ - private $identifierMap = []; + private array $identifierMap = []; /** @var mixed[] */ - private $resultPointers = []; + private array $resultPointers = []; /** @var mixed[] */ - private $idTemplate = []; + private array $idTemplate = []; - /** @var int */ - private $resultCounter = 0; + private int $resultCounter = 0; /** @var mixed[] */ - private $rootAliases = []; + private array $rootAliases = []; /** @var mixed[] */ - private $initializedCollections = []; + private array $initializedCollections = []; /** @var mixed[] */ - private $existingCollections = []; + private array $existingCollections = []; protected function prepare(): void { @@ -148,12 +147,11 @@ protected function hydrateAllData(): array /** * Initializes a related collection. * - * @param object $entity The entity to which the collection belongs. * @param string $fieldName The name of the field on the entity that holds the collection. * @param string $parentDqlAlias Alias of the parent fetch joining this collection. */ private function initRelatedCollection( - $entity, + object $entity, ClassMetadata $class, string $fieldName, string $parentDqlAlias @@ -203,11 +201,9 @@ private function initRelatedCollection( * @param string $dqlAlias The DQL alias of the entity's class. * @psalm-param array $data The instance data. * - * @return object - * * @throws HydrationException */ - private function getEntity(array $data, string $dqlAlias) + private function getEntity(array $data, string $dqlAlias): object { $className = $this->resultSetMapping()->aliasMap[$dqlAlias]; @@ -252,10 +248,8 @@ private function getEntity(array $data, string $dqlAlias) /** * @psalm-param class-string $className * @psalm-param array $data - * - * @return mixed */ - private function getEntityFromIdentityMap(string $className, array $data) + private function getEntityFromIdentityMap(string $className, array $data): object|bool { // TODO: Abstract this code and UnitOfWork::createEntity() equivalent? $class = $this->_metadataCache[$className]; diff --git a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php index 852f8dfa4a1..bd109686a68 100644 --- a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php +++ b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php @@ -16,30 +16,17 @@ */ final class HydrationCompleteHandler { - /** @var ListenersInvoker */ - private $listenersInvoker; - - /** @var EntityManagerInterface */ - private $em; - /** @var mixed[][] */ - private $deferredPostLoadInvocations = []; + private array $deferredPostLoadInvocations = []; - /** - * Constructor for this object - */ - public function __construct(ListenersInvoker $listenersInvoker, EntityManagerInterface $em) + public function __construct(private ListenersInvoker $listenersInvoker, private EntityManagerInterface $em) { - $this->listenersInvoker = $listenersInvoker; - $this->em = $em; } /** * Method schedules invoking of postLoad entity to the very end of current hydration cycle. - * - * @param object $entity */ - public function deferPostLoadInvoking(ClassMetadata $class, $entity): void + public function deferPostLoadInvoking(ClassMetadata $class, object $entity): void { $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postLoad); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d39b0577456..f22d66c1977 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -265,6 +265,9 @@ $index + + $index + $result[$resultKey] $result[$resultKey] From 07fa660a4752b4b9cb9361d5da5feb01737177a2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 28 Jun 2022 15:30:59 +0200 Subject: [PATCH 128/475] Fix broken mocks due to removal of Driver::getSchemaManager() (#9869) --- tests/Doctrine/Tests/OrmTestCase.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 998b877bcc2..1bd436ab9b9 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -23,6 +23,7 @@ use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; +use function method_exists; use function realpath; use function sprintf; @@ -158,11 +159,17 @@ private function createConnectionMock(AbstractPlatform $platform): Connection private function createPlatformMock(): AbstractPlatform { + $schemaManager = $this->createMock(AbstractSchemaManager::class); + $schemaManager->method('createSchemaConfig') + ->willReturn(new SchemaConfig()); + $platform = $this->getMockBuilder(AbstractPlatform::class) - ->onlyMethods(['supportsIdentityColumns']) + ->onlyMethods(['supportsIdentityColumns', 'createSchemaManager']) ->getMockForAbstractClass(); $platform->method('supportsIdentityColumns') ->willReturn(true); + $platform->method('createSchemaManager') + ->willReturn($schemaManager); return $platform; } @@ -177,18 +184,17 @@ private function createDriverMock(AbstractPlatform $platform): Driver $connection->method('query') ->willReturn($result); - $schemaManager = $this->createMock(AbstractSchemaManager::class); - $schemaManager->method('createSchemaConfig') - ->willReturn(new SchemaConfig()); - $driver = $this->createMock(Driver::class); $driver->method('connect') ->willReturn($connection); - $driver->method('getSchemaManager') - ->willReturn($schemaManager); $driver->method('getDatabasePlatform') ->willReturn($platform); + if (method_exists(Driver::class, 'getSchemaManager')) { + $driver->method('getSchemaManager') + ->willReturnCallback([$platform, 'createSchemaManager']); + } + return $driver; } } From 68dc5fe9019802981e934960726c43f54debcb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 7 Jul 2022 17:44:21 +0200 Subject: [PATCH 129/475] Rely on platform options Custom schema options have been removed in doctrine/dbal 4 --- lib/Doctrine/ORM/Tools/SchemaTool.php | 4 ++-- .../Tests/ORM/Tools/SchemaToolTest.php | 24 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 8d26133deaa..f357e856192 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -786,8 +786,8 @@ private function gatherColumnOptions(array $mapping): array return []; } - $options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS)); - $options['customSchemaOptions'] = array_diff_key($mappingOptions, $options); + $options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS)); + $options['platformOptions'] = array_diff_key($mappingOptions, $options); return $options; } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index fde54c86899..76c9a2cde5e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -77,7 +77,7 @@ public function testAnnotationOptionsAttribute(): void ); $table = $schema->getTable('TestEntityWithAnnotationOptionsAttribute'); - foreach ([$table->getOptions(), $table->getColumn('test')->getCustomSchemaOptions()] as $options) { + foreach ([$table->getOptions(), $table->getColumn('test')->getPlatformOptions()] as $options) { self::assertArrayHasKey('foo', $options); self::assertSame('bar', $options['foo']); self::assertArrayHasKey('baz', $options); @@ -136,14 +136,14 @@ public function testPassColumnOptionsToJoinColumn(): void ); self::assertEquals( - $tableCategory->getColumn('id')->getCustomSchemaOptions(), - $tableBoard->getColumn('category_id')->getCustomSchemaOptions(), + $tableCategory->getColumn('id')->getPlatformOptions(), + $tableBoard->getColumn('category_id')->getPlatformOptions(), 'Foreign key/join column should have the same custom options as the referenced column' ); self::assertEquals( ['collation' => 'latin1_bin', 'foo' => 'bar'], - $tableBoard->getColumn('category_id')->getCustomSchemaOptions() + $tableBoard->getColumn('category_id')->getPlatformOptions() ); } @@ -177,17 +177,15 @@ public function testPostGenerateEvents(): void self::assertTrue($listener->schemaCalled); } - public function testNullDefaultNotAddedToCustomSchemaOptions(): void + public function testNullDefaultNotAddedToPlatformOptions(): void { $em = $this->getTestEntityManager(); $schemaTool = new SchemaTool($em); - $customSchemaOptions = $schemaTool->getSchemaFromMetadata([$em->getClassMetadata(NullDefaultColumn::class)]) + self::assertSame([], $schemaTool->getSchemaFromMetadata([$em->getClassMetadata(NullDefaultColumn::class)]) ->getTable('NullDefaultColumn') ->getColumn('nullDefault') - ->getCustomSchemaOptions(); - - self::assertSame([], $customSchemaOptions); + ->getPlatformOptions()); } /** @@ -198,13 +196,13 @@ public function testEnumTypeAddedToCustomSchemaOptions(): void $em = $this->getTestEntityManager(); $schemaTool = new SchemaTool($em); - $customSchemaOptions = $schemaTool->getSchemaFromMetadata([$em->getClassMetadata(Card::class)]) + $platformOptions = $schemaTool->getSchemaFromMetadata([$em->getClassMetadata(Card::class)]) ->getTable('Card') ->getColumn('suit') - ->getCustomSchemaOptions(); + ->getPlatformOptions(); - self::assertArrayHasKey('enumType', $customSchemaOptions); - self::assertSame(Suit::class, $customSchemaOptions['enumType']); + self::assertArrayHasKey('enumType', $platformOptions); + self::assertSame(Suit::class, $platformOptions['enumType']); } /** From 1fa1e7072b59c1a325f00ce58c8e07670d8b8e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 12 Jul 2022 20:02:46 +0200 Subject: [PATCH 130/475] Address removal/deprecation of ArrayType/ObjectType --- psalm.xml | 5 +++++ tests/Doctrine/Tests/ORM/Functional/TypeTest.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/psalm.xml b/psalm.xml index 0e34c912cf0..84099bfb533 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,6 +17,11 @@ + + + + + diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index 18877e8cec1..bbaeb970079 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -6,6 +6,8 @@ use DateTime; use DateTimeZone; +use Doctrine\DBAL\Types\ArrayType; +use Doctrine\DBAL\Types\ObjectType; use Doctrine\DBAL\Types\Types; use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\Tests\Models\Generic\DateTimeModel; @@ -14,6 +16,8 @@ use Doctrine\Tests\OrmFunctionalTestCase; use stdClass; +use function class_exists; + class TypeTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -70,6 +74,10 @@ public function testBoolean(): void public function testArray(): void { + if (! class_exists(ArrayType::class)) { + self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); + } + $serialize = new SerializationModel(); $serialize->array['foo'] = 'bar'; $serialize->array['bar'] = 'baz'; @@ -88,6 +96,10 @@ public function testArray(): void public function testObject(): void { + if (! class_exists(ObjectType::class)) { + self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); + } + $serialize = new SerializationModel(); $serialize->object = new stdClass(); From 1ac9d5233279de62c25f5b08706745b985bf79b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 12 Jul 2022 20:14:15 +0200 Subject: [PATCH 131/475] Ignore errors caused by nullable assets filter --- phpstan-dbal4.neon | 4 ++++ psalm.xml | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon index b8c63ba0d5b..fa8291b8612 100644 --- a/phpstan-dbal4.neon +++ b/phpstan-dbal4.neon @@ -18,3 +18,7 @@ parameters: - message: '~^Parameter #1 \$command of method Symfony\\Component\\Console\\Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command, Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand given\.$~' path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php + + - + message: '~Strict comparison using \=\=\= between callable\(\)\: mixed and null will always evaluate to false\.~' + path: lib/Doctrine/ORM/Tools/SchemaTool.php diff --git a/psalm.xml b/psalm.xml index 84099bfb533..3f3b111cdb3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -116,6 +116,12 @@ + + + + + + From 214a912b37b6acbc686f64d22694e848816cc64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Jun 2022 08:57:25 +0200 Subject: [PATCH 132/475] Migrate more code to PHP8 --- .../Tools/AttachEntityListenersListener.php | 16 ++++----- .../ORM/Tools/DebugUnitOfWorkListener.php | 36 +++++-------------- .../ORM/Tools/ResolveTargetEntityListener.php | 18 +++------- .../ORM/Utility/IdentifierFlattener.php | 28 ++++++--------- 4 files changed, 31 insertions(+), 67 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php index d1657367eef..72908a86636 100644 --- a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php +++ b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php @@ -14,7 +14,7 @@ class AttachEntityListenersListener { /** @var mixed[][] */ - private $entityListeners = []; + private array $entityListeners = []; /** * Adds a entity listener for a specific entity. @@ -23,11 +23,13 @@ class AttachEntityListenersListener * @param string $listenerClass The listener class. * @param string $eventName The entity lifecycle event. * @param string|null $listenerCallback The listener callback method or NULL to use $eventName. - * - * @return void */ - public function addEntityListener($entityClass, $listenerClass, $eventName, $listenerCallback = null) - { + public function addEntityListener( + string $entityClass, + string $listenerClass, + string $eventName, + $listenerCallback = null + ): void { $this->entityListeners[ltrim($entityClass, '\\')][] = [ 'event' => $eventName, 'class' => $listenerClass, @@ -37,10 +39,8 @@ public function addEntityListener($entityClass, $listenerClass, $eventName, $lis /** * Processes event and attach the entity listener. - * - * @return void */ - public function loadClassMetadata(LoadClassMetadataEventArgs $event) + public function loadClassMetadata(LoadClassMetadataEventArgs $event): void { $metadata = $event->getClassMetadata(); diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index ab8b301c20f..092b865710f 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -26,40 +26,26 @@ */ class DebugUnitOfWorkListener { - /** @var string */ - private $file; - - /** @var string */ - private $context; - /** * Pass a stream and context information for the debugging session. * * The stream can be php://output to print to the screen. - * - * @param string $file - * @param string $context */ - public function __construct($file = 'php://output', $context = '') - { - $this->file = $file; - $this->context = $context; + public function __construct( + private string $file = 'php://output', + private string $context = '' + ) { } - /** - * @return void - */ - public function onFlush(OnFlushEventArgs $args) + public function onFlush(OnFlushEventArgs $args): void { $this->dumpIdentityMap($args->getEntityManager()); } /** * Dumps the contents of the identity map into a stream. - * - * @return void */ - public function dumpIdentityMap(EntityManagerInterface $em) + public function dumpIdentityMap(EntityManagerInterface $em): void { $uow = $em->getUnitOfWork(); $identityMap = $uow->getIdentityMap(); @@ -119,10 +105,7 @@ public function dumpIdentityMap(EntityManagerInterface $em) fclose($fh); } - /** - * @param mixed $var - */ - private function getType($var): string + private function getType(mixed $var): string { if (is_object($var)) { $refl = new ReflectionObject($var); @@ -133,10 +116,7 @@ private function getType($var): string return gettype($var); } - /** - * @param object $entity - */ - private function getIdString($entity, UnitOfWork $uow): string + private function getIdString(object $entity, UnitOfWork $uow): string { if ($uow->isInIdentityMap($entity)) { $ids = $uow->getEntityIdentifier($entity); diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php index e7f2fb3e469..663c4b681dc 100644 --- a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -23,12 +23,12 @@ class ResolveTargetEntityListener implements EventSubscriber { /** @var mixed[][] indexed by original entity name */ - private $resolveTargetEntities = []; + private array $resolveTargetEntities = []; /** * {@inheritDoc} */ - public function getSubscribedEvents() + public function getSubscribedEvents(): array { return [ Events::loadClassMetadata, @@ -39,13 +39,9 @@ public function getSubscribedEvents() /** * Adds a target-entity class name to resolve to a new class name. * - * @param string $originalEntity - * @param string $newEntity * @psalm-param array $mapping - * - * @return void */ - public function addResolveTargetEntity($originalEntity, $newEntity, array $mapping) + public function addResolveTargetEntity(string $originalEntity, string $newEntity, array $mapping): void { $mapping['targetEntity'] = ltrim($newEntity, '\\'); $this->resolveTargetEntities[ltrim($originalEntity, '\\')] = $mapping; @@ -53,10 +49,8 @@ public function addResolveTargetEntity($originalEntity, $newEntity, array $mappi /** * @internal this is an event callback, and should not be called directly - * - * @return void */ - public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args) + public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args): void { if (array_key_exists($args->getClassName(), $this->resolveTargetEntities)) { $args->setFoundMetadata( @@ -71,10 +65,8 @@ public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args) * Processes event and resolves new target entity names. * * @internal this is an event callback, and should not be called directly - * - * @return void */ - public function loadClassMetadata(LoadClassMetadataEventArgs $args) + public function loadClassMetadata(LoadClassMetadataEventArgs $args): void { $cm = $args->getClassMetadata(); diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index 837f2dc1d57..f8291c92396 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -19,27 +19,19 @@ */ final class IdentifierFlattener { - /** - * The UnitOfWork used to coordinate object-level transactions. - * - * @var UnitOfWork - */ - private $unitOfWork; - - /** - * The metadata factory, used to retrieve the ORM metadata of entity classes. - * - * @var ClassMetadataFactory - */ - private $metadataFactory; - /** * Initializes a new IdentifierFlattener instance, bound to the given EntityManager. */ - public function __construct(UnitOfWork $unitOfWork, ClassMetadataFactory $metadataFactory) - { - $this->unitOfWork = $unitOfWork; - $this->metadataFactory = $metadataFactory; + public function __construct( + /** + * The UnitOfWork used to coordinate object-level transactions. + */ + private UnitOfWork $unitOfWork, + /** + * The metadata factory, used to retrieve the ORM metadata of entity classes. + */ + private ClassMetadataFactory $metadataFactory + ) { } /** From 0f98b3d9f2473c1d5df614492ee6584e48915e7d Mon Sep 17 00:00:00 2001 From: Craig Francis Date: Mon, 18 Jul 2022 21:05:20 +0100 Subject: [PATCH 133/475] Update Expr::countDistinct() and Expr::concat() to variable-length argument lists --- lib/Doctrine/ORM/Query/Expr.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index 1760c7373af..3bb0f74eaa7 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -6,7 +6,6 @@ use Traversable; -use function func_get_args; use function implode; use function is_bool; use function is_iterable; @@ -250,13 +249,13 @@ public function count($x) /** * Creates an instance of COUNT(DISTINCT) function, with the given argument. * - * @param mixed $x Argument to be used in COUNT(DISTINCT) function. + * @param mixed ...$x Argument to be used in COUNT(DISTINCT) function. * * @return string */ - public function countDistinct($x) + public function countDistinct(mixed ...$x) { - return 'COUNT(DISTINCT ' . implode(', ', func_get_args()) . ')'; + return 'COUNT(DISTINCT ' . implode(', ', $x) . ')'; } /** @@ -534,14 +533,13 @@ public function notLike($x, $y) /** * Creates a CONCAT() function expression with the given arguments. * - * @param mixed $x First argument to be used in CONCAT() function. - * @param mixed $y,... Other arguments to be used in CONCAT() function. + * @param mixed ...$x Arguments to be used in CONCAT() function. * * @return Expr\Func */ - public function concat($x, $y) + public function concat(mixed ...$x) { - return new Expr\Func('CONCAT', func_get_args()); + return new Expr\Func('CONCAT', $x); } /** From b7ff742f848b33afc6e0cb1a72aa69ce30dc477d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 15 Jul 2022 12:31:50 +0200 Subject: [PATCH 134/475] Throw on error That way we have some level of error handling, and don't muddy the return type. --- .../ORM/Tools/Console/Command/MappingDescribeCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 38d198ea3eb..30914f3026c 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -32,6 +32,7 @@ use function sprintf; use const JSON_PRETTY_PRINT; +use const JSON_THROW_ON_ERROR; use const JSON_UNESCAPED_SLASHES; use const JSON_UNESCAPED_UNICODE; @@ -207,7 +208,10 @@ private function formatValue(mixed $value): string } if (is_array($value)) { - return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); + return json_encode( + $value, + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR + ); } if (is_object($value)) { From ad12df8fccd91e030612e7e7d691f1420b074806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 15 Jul 2022 12:59:35 +0200 Subject: [PATCH 135/475] Remove unused exception --- lib/Doctrine/ORM/Tools/ToolsException.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/ToolsException.php b/lib/Doctrine/ORM/Tools/ToolsException.php index ced823947fd..abb0dfb0f1a 100644 --- a/lib/Doctrine/ORM/Tools/ToolsException.php +++ b/lib/Doctrine/ORM/Tools/ToolsException.php @@ -8,8 +8,6 @@ use RuntimeException; use Throwable; -use function sprintf; - /** * Tools related Exceptions. */ @@ -23,14 +21,4 @@ public static function schemaToolFailure(string $sql, Throwable $e): self $e ); } - - /** - * @param string $type - * - * @return ToolsException - */ - public static function couldNotMapDoctrine1Type($type) - { - return new self(sprintf("Could not map doctrine 1 type '%s'!", $type)); - } } From 660cb3b6ac695a3d1ece3115f6a60d764a932711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 15 Jul 2022 17:17:09 +0200 Subject: [PATCH 136/475] Migrate part of the tools namespace to PHP 8 syntax --- .../Command/MappingDescribeCommand.php | 6 +- .../ORM/Tools/Console/MetadataFilter.php | 2 +- .../Tools/Event/GenerateSchemaEventArgs.php | 24 ++------ .../Event/GenerateSchemaTableEventArgs.php | 34 +++--------- .../ORM/Tools/Pagination/Paginator.php | 55 +++++-------------- lib/Doctrine/ORM/Tools/SchemaTool.php | 4 +- 6 files changed, 34 insertions(+), 91 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 30914f3026c..3cc57ff5f41 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -158,14 +158,12 @@ private function getClassMetadata( ): ClassMetadata { try { return $entityManager->getClassMetadata($entityName); - } catch (MappingException $e) { + } catch (MappingException) { } $matches = array_filter( $this->getMappedEntities($entityManager), - static function ($mappedEntity) use ($entityName) { - return preg_match('{' . preg_quote($entityName) . '}', $mappedEntity); - } + static fn ($mappedEntity) => preg_match('{' . preg_quote($entityName) . '}', $mappedEntity) ); if (! $matches) { diff --git a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php b/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php index 4e43beec073..4ecc4caa570 100644 --- a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php +++ b/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php @@ -34,7 +34,7 @@ class MetadataFilter extends FilterIterator implements Countable * * @return ClassMetadata[] */ - public static function filter(array $metadatas, array|string $filter) + public static function filter(array $metadatas, array|string $filter): array { $metadatas = new MetadataFilter(new ArrayIterator($metadatas), $filter); diff --git a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php index 45a2fc11036..0276534c85d 100644 --- a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php +++ b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php @@ -15,30 +15,18 @@ */ class GenerateSchemaEventArgs extends EventArgs { - /** @var EntityManagerInterface */ - private $em; - - /** @var Schema */ - private $schema; - - public function __construct(EntityManagerInterface $em, Schema $schema) - { - $this->em = $em; - $this->schema = $schema; + public function __construct( + private EntityManagerInterface $em, + private Schema $schema + ) { } - /** - * @return EntityManagerInterface - */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { return $this->em; } - /** - * @return Schema - */ - public function getSchema() + public function getSchema(): Schema { return $this->schema; } diff --git a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php index 81b3b026c61..ddb6ede0ce0 100644 --- a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php +++ b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php @@ -16,42 +16,24 @@ */ class GenerateSchemaTableEventArgs extends EventArgs { - /** @var ClassMetadata */ - private $classMetadata; - - /** @var Schema */ - private $schema; - - /** @var Table */ - private $classTable; - - public function __construct(ClassMetadata $classMetadata, Schema $schema, Table $classTable) - { - $this->classMetadata = $classMetadata; - $this->schema = $schema; - $this->classTable = $classTable; + public function __construct( + private ClassMetadata $classMetadata, + private Schema $schema, + private Table $classTable + ) { } - /** - * @return ClassMetadata - */ - public function getClassMetadata() + public function getClassMetadata(): ClassMetadata { return $this->classMetadata; } - /** - * @return Schema - */ - public function getSchema() + public function getSchema(): Schema { return $this->schema; } - /** - * @return Table - */ - public function getClassTable() + public function getClassTable(): Table { return $this->classTable; } diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index cf351949e9e..ca2684ebc14 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -14,8 +14,8 @@ use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\QueryBuilder; +use Iterator; use IteratorAggregate; -use ReturnTypeWillChange; use function array_key_exists; use function array_map; @@ -31,38 +31,26 @@ class Paginator implements Countable, IteratorAggregate { use SQLResultCasing; - /** @var Query */ - private $query; - - /** @var bool */ - private $fetchJoinCollection; - - /** @var bool|null */ - private $useOutputWalkers; - - /** @var int */ - private $count; + private Query $query; + private ?bool $useOutputWalkers = null; + private ?int $count = null; /** - * @param Query|QueryBuilder $query A Doctrine ORM query or query builder. - * @param bool $fetchJoinCollection Whether the query joins a collection (true by default). + * @param bool $fetchJoinCollection Whether the query joins a collection (true by default). */ - public function __construct($query, $fetchJoinCollection = true) + public function __construct(Query|QueryBuilder $query, private bool $fetchJoinCollection = true) { if ($query instanceof QueryBuilder) { $query = $query->getQuery(); } - $this->query = $query; - $this->fetchJoinCollection = (bool) $fetchJoinCollection; + $this->query = $query; } /** * Returns the query. - * - * @return Query */ - public function getQuery() + public function getQuery(): Query { return $this->query; } @@ -72,17 +60,15 @@ public function getQuery() * * @return bool Whether the query joins a collection. */ - public function getFetchJoinCollection() + public function getFetchJoinCollection(): bool { return $this->fetchJoinCollection; } /** * Returns whether the paginator will use an output walker. - * - * @return bool|null */ - public function getUseOutputWalkers() + public function getUseOutputWalkers(): ?bool { return $this->useOutputWalkers; } @@ -90,30 +76,21 @@ public function getUseOutputWalkers() /** * Sets whether the paginator will use an output walker. * - * @param bool|null $useOutputWalkers - * * @return $this - * @psalm-return static */ - public function setUseOutputWalkers($useOutputWalkers) + public function setUseOutputWalkers(?bool $useOutputWalkers): static { $this->useOutputWalkers = $useOutputWalkers; return $this; } - /** - * {@inheritdoc} - * - * @return int - */ - #[ReturnTypeWillChange] - public function count() + public function count(): int { if ($this->count === null) { try { $this->count = (int) array_sum(array_map('current', $this->getCountQuery()->getScalarResult())); - } catch (NoResultException $e) { + } catch (NoResultException) { $this->count = 0; } } @@ -124,11 +101,9 @@ public function count() /** * {@inheritdoc} * - * @return ArrayIterator - * @psalm-return ArrayIterator + * @psalm-return Iterator */ - #[ReturnTypeWillChange] - public function getIterator() + public function getIterator(): Iterator { $offset = $this->query->getFirstResult(); $length = $this->query->getMaxResults(); diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index f357e856192..6010743cc2f 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -889,7 +889,7 @@ public function getDropSchemaSQL(array $classes): array * @param bool $saveMode If TRUE, only performs a partial update * without dropping assets which are scheduled for deletion. */ - public function updateSchema(array $classes, $saveMode = false): void + public function updateSchema(array $classes, bool $saveMode = false): void { $updateSchemaSql = $this->getUpdateSchemaSql($classes, $saveMode); $conn = $this->em->getConnection(); @@ -909,7 +909,7 @@ public function updateSchema(array $classes, $saveMode = false): void * * @return string[] The sequence of SQL statements. */ - public function getUpdateSchemaSql(array $classes, $saveMode = false): array + public function getUpdateSchemaSql(array $classes, bool $saveMode = false): array { $toSchema = $this->getSchemaFromMetadata($classes); $fromSchema = $this->createSchemaForComparison($toSchema); From c44db2cc35e1dce6ffc9d951ea1fbf28a272fb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 19 Jul 2022 08:44:12 +0200 Subject: [PATCH 137/475] Fulfill ReturnTypeWillChange prophecy --- lib/Doctrine/ORM/LazyCriteriaCollection.php | 6 +----- lib/Doctrine/ORM/PersistentCollection.php | 11 +++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/Doctrine/ORM/LazyCriteriaCollection.php b/lib/Doctrine/ORM/LazyCriteriaCollection.php index 21261308401..2e7c6a75edc 100644 --- a/lib/Doctrine/ORM/LazyCriteriaCollection.php +++ b/lib/Doctrine/ORM/LazyCriteriaCollection.php @@ -9,7 +9,6 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Persisters\Entity\EntityPersister; -use ReturnTypeWillChange; use function assert; @@ -43,11 +42,8 @@ public function __construct(EntityPersister $entityPersister, Criteria $criteria /** * Do an efficient count on the collection - * - * @return int */ - #[ReturnTypeWillChange] - public function count() + public function count(): int { if ($this->isInitialized()) { return $this->collection->count(); diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 8b3db0a7c9a..cbc92c8985a 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -10,7 +10,6 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping\ClassMetadata; -use ReturnTypeWillChange; use RuntimeException; use function array_combine; @@ -478,8 +477,7 @@ public function offsetExists($offset): bool /** * {@inheritdoc} */ - #[ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->get($offset); } @@ -500,13 +498,10 @@ public function offsetSet($offset, $value): void /** * {@inheritdoc} - * - * @return object|null */ - #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { - return $this->remove($offset); + $this->remove($offset); } public function isEmpty(): bool From d41c4c6cc6216dafd0fea7382a9f791476cdb039 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 Jul 2022 00:14:27 +0200 Subject: [PATCH 138/475] Adjust casing of SQLitePlatform for DBAL 4 (#9924) --- .../Tests/ORM/Functional/QueryDqlFunctionTest.php | 6 +++--- .../Tests/ORM/Functional/SchemaTool/DDC214Test.php | 4 ++-- .../Tests/ORM/Functional/Ticket/DDC1695Test.php | 4 ++-- .../Tests/ORM/Functional/Ticket/DDC933Test.php | 4 ++-- .../Tests/ORM/Query/SelectSqlGenerationTest.php | 10 +++++++--- .../Console/Command/SchemaTool/AbstractCommandTest.php | 4 ++-- .../Console/Command/ValidateSchemaCommandTest.php | 4 ++-- tests/Doctrine/Tests/TestUtil.php | 4 ++-- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index b4e08ba47cf..c3a88353fbd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\ORM\Functional; use DateTimeImmutable; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\ORM\AbstractQuery; use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\OrmFunctionalTestCase; @@ -317,7 +317,7 @@ public function testDateAdd(string $unit, int $amount, int $delta = 0): void if ( $unit === 'month' && $inOneUnit->format('m') === $now->modify('+2 month')->format('m') - && ! $this->_em->getConnection()->getDatabasePlatform() instanceof SqlitePlatform + && ! $this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform ) { $inOneUnit = new DateTimeImmutable('last day of next month'); } @@ -355,7 +355,7 @@ public function testDateSub(string $unit, int $amount, int $delta = 0): void if ( $unit === 'month' && $oneUnitAgo->format('m') === $now->format('m') - && ! $this->_em->getConnection()->getDatabasePlatform() instanceof SqlitePlatform + && ! $this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform ) { $oneUnitAgo = new DateTimeImmutable('last day of previous month'); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 18e86bd896e..494a186ed71 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; @@ -25,7 +25,7 @@ protected function setUp(): void $conn = $this->_em->getConnection(); - if ($conn->getDatabasePlatform() instanceof SqlitePlatform) { + if ($conn->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('SQLite does not support ALTER TABLE statements.'); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php index c7435c78b55..7abeeefa233 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use DateTimeZone; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; @@ -20,7 +20,7 @@ class DDC1695Test extends OrmFunctionalTestCase { public function testIssue(): void { - if (! $this->_em->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { + if (! $this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('Only with sqlite'); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php index 3219f4247fc..2c198785914 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\DBAL\LockMode; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\TransactionRequiredException; @@ -30,7 +30,7 @@ protected function setUp(): void */ public function testLockCTIClass(): void { - if ($this->_em->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { + if ($this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('It should not run on in-memory databases'); } diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index ba04c8753b7..9e660fffb6a 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -8,7 +8,7 @@ use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; @@ -30,8 +30,12 @@ use Doctrine\Tests\OrmTestCase; use Exception; +use function class_exists; use function sprintf; +// DBAL 3 compatibility +class_exists('Doctrine\\DBAL\\Platforms\\SqlitePlatform'); + class SelectSqlGenerationTest extends OrmTestCase { private EntityManagerInterface $entityManager; @@ -929,7 +933,7 @@ public function testOrderBySupportsSingleValuedPathExpressionInverseSide(): void public function testBooleanLiteralInWhereOnSqlite(): void { - $this->entityManager = $this->createTestEntityManagerWithPlatform(new SqlitePlatform()); + $this->entityManager = $this->createTestEntityManagerWithPlatform(new SQLitePlatform()); $this->assertSqlGeneration( 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true', 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanField_1 FROM boolean_model b0_ WHERE b0_.booleanField = 1' @@ -1064,7 +1068,7 @@ public function testSubselectInSelect(): void */ public function testPessimisticWriteLockQueryHint(): void { - if ($this->entityManager->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { + if ($this->entityManager->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('SqLite does not support Row locking at all.'); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php index 558ff6b927d..79b0cff23c8 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command\SchemaTool; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; @@ -22,7 +22,7 @@ protected function getCommandTester(string $commandClass): CommandTester __DIR__ . '/Models', ])); - if (! $entityManager->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { + if (! $entityManager->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('We are testing the symfony/console integration'); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php index 99eb6a80f81..7e52ac1cd62 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\OrmFunctionalTestCase; @@ -27,7 +27,7 @@ protected function setUp(): void { parent::setUp(); - if (! $this->_em->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { + if (! $this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('Only with sqlite'); } diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index 5a7f0ab0028..225152cf2d1 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -9,7 +9,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use UnexpectedValueException; use function assert; @@ -89,7 +89,7 @@ private static function initializeDatabase(): void $platform = $privConn->getDatabasePlatform(); - if ($platform instanceof SqlitePlatform) { + if ($platform instanceof SQLitePlatform) { $schema = $testConn->createSchemaManager()->createSchema(); $stmts = $schema->toDropSql($testConn->getDatabasePlatform()); From 0bfdbe1e2c7ba51f6caf1383be9a9bead462b716 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 Jul 2022 10:16:31 +0200 Subject: [PATCH 139/475] Add native types to QuoteStrategy classes (#9923) --- .../ORM/Mapping/AnsiQuoteStrategy.php | 41 ++++++++--------- .../ORM/Mapping/DefaultQuoteStrategy.php | 33 +++++++------- lib/Doctrine/ORM/Mapping/QuoteStrategy.php | 44 +++++++------------ 3 files changed, 55 insertions(+), 63 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php index 2d8e36829d3..0778c86c23a 100644 --- a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php @@ -15,18 +15,15 @@ class AnsiQuoteStrategy implements QuoteStrategy { use SQLResultCasing; - /** - * {@inheritdoc} - */ - public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform) - { + public function getColumnName( + string $fieldName, + ClassMetadata $class, + AbstractPlatform $platform + ): string { return $class->fieldMappings[$fieldName]['columnName']; } - /** - * {@inheritdoc} - */ - public function getTableName(ClassMetadata $class, AbstractPlatform $platform) + public function getTableName(ClassMetadata $class, AbstractPlatform $platform): string { return $class->table['name']; } @@ -34,7 +31,7 @@ public function getTableName(ClassMetadata $class, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform) + public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform): string { return $definition['sequenceName']; } @@ -42,7 +39,7 @@ public function getSequenceName(array $definition, ClassMetadata $class, Abstrac /** * {@inheritdoc} */ - public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform) + public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string { return $joinColumn['name']; } @@ -50,15 +47,18 @@ public function getJoinColumnName(array $joinColumn, ClassMetadata $class, Abstr /** * {@inheritdoc} */ - public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform) - { + public function getReferencedJoinColumnName( + array $joinColumn, + ClassMetadata $class, + AbstractPlatform $platform + ): string { return $joinColumn['referencedColumnName']; } /** * {@inheritdoc} */ - public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform) + public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform): string { return $association['joinTable']['name']; } @@ -66,16 +66,17 @@ public function getJoinTableName(array $association, ClassMetadata $class, Abstr /** * {@inheritdoc} */ - public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform) + public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform): array { return $class->identifier; } - /** - * {@inheritdoc} - */ - public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ?ClassMetadata $class = null) - { + public function getColumnAlias( + string $columnName, + int $counter, + AbstractPlatform $platform, + ?ClassMetadata $class = null + ): string { return $this->getSQLResultCasing($platform, $columnName . '_' . $counter); } } diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index e02d029e508..49d14a4e44c 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -20,10 +20,7 @@ class DefaultQuoteStrategy implements QuoteStrategy { use SQLResultCasing; - /** - * {@inheritdoc} - */ - public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform) + public function getColumnName(string $fieldName, ClassMetadata $class, AbstractPlatform $platform): string { return isset($class->fieldMappings[$fieldName]['quoted']) ? $platform->quoteIdentifier($class->fieldMappings[$fieldName]['columnName']) @@ -35,7 +32,7 @@ public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform * * @todo Table names should be computed in DBAL depending on the platform */ - public function getTableName(ClassMetadata $class, AbstractPlatform $platform) + public function getTableName(ClassMetadata $class, AbstractPlatform $platform): string { $tableName = $class->table['name']; @@ -51,7 +48,7 @@ public function getTableName(ClassMetadata $class, AbstractPlatform $platform) /** * {@inheritdoc} */ - public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform) + public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform): string { return isset($definition['quoted']) ? $platform->quoteIdentifier($definition['sequenceName']) @@ -61,7 +58,7 @@ public function getSequenceName(array $definition, ClassMetadata $class, Abstrac /** * {@inheritdoc} */ - public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform) + public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string { return isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['name']) @@ -71,8 +68,11 @@ public function getJoinColumnName(array $joinColumn, ClassMetadata $class, Abstr /** * {@inheritdoc} */ - public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform) - { + public function getReferencedJoinColumnName( + array $joinColumn, + ClassMetadata $class, + AbstractPlatform $platform + ): string { return isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['referencedColumnName']) : $joinColumn['referencedColumnName']; @@ -81,7 +81,7 @@ public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $cl /** * {@inheritdoc} */ - public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform) + public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform): string { $schema = ''; @@ -101,7 +101,7 @@ public function getJoinTableName(array $association, ClassMetadata $class, Abstr /** * {@inheritdoc} */ - public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform) + public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform): array { $quotedColumnNames = []; @@ -129,11 +129,12 @@ static function ($joinColumn) use ($platform) { return $quotedColumnNames; } - /** - * {@inheritdoc} - */ - public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ?ClassMetadata $class = null) - { + public function getColumnAlias( + string $columnName, + int $counter, + AbstractPlatform $platform, + ?ClassMetadata $class = null + ): string { // 1 ) Concatenate column name and counter // 2 ) Trim the column alias to the maximum identifier length of the platform. // If the alias is to long, characters are cut off from the beginning. diff --git a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php index dcca9670c8c..395680fe3dd 100644 --- a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php @@ -13,70 +13,60 @@ interface QuoteStrategy { /** * Gets the (possibly quoted) column name for safe use in an SQL statement. - * - * @param string $fieldName - * - * @return string */ - public function getColumnName($fieldName, ClassMetadata $class, AbstractPlatform $platform); + public function getColumnName(string $fieldName, ClassMetadata $class, AbstractPlatform $platform): string; /** * Gets the (possibly quoted) primary table name for safe use in an SQL statement. - * - * @return string */ - public function getTableName(ClassMetadata $class, AbstractPlatform $platform); + public function getTableName(ClassMetadata $class, AbstractPlatform $platform): string; /** * Gets the (possibly quoted) sequence name for safe use in an SQL statement. * * @param mixed[] $definition - * - * @return string */ - public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform); + public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform): string; /** * Gets the (possibly quoted) name of the join table. * * @param mixed[] $association - * - * @return string */ - public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform); + public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform): string; /** * Gets the (possibly quoted) join column name. * * @param mixed[] $joinColumn - * - * @return string */ - public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform); + public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string; /** * Gets the (possibly quoted) join column name. * * @param mixed[] $joinColumn - * - * @return string */ - public function getReferencedJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform); + public function getReferencedJoinColumnName( + array $joinColumn, + ClassMetadata $class, + AbstractPlatform $platform + ): string; /** * Gets the (possibly quoted) identifier column names for safe use in an SQL statement. * * @psalm-return list */ - public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform); + public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform): array; /** * Gets the column alias. - * - * @param string $columnName - * @param int $counter - * - * @return string */ - public function getColumnAlias($columnName, $counter, AbstractPlatform $platform, ?ClassMetadata $class = null); + public function getColumnAlias( + string $columnName, + int $counter, + AbstractPlatform $platform, + ?ClassMetadata $class = null + ): string; } From a3a8caae516d8b88c025692159ce44f7ee7f1844 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 25 Jul 2022 22:27:45 +0200 Subject: [PATCH 140/475] Split TreeWalker and SqlWalker (#9551) --- UPGRADE.md | 60 ++ lib/Doctrine/ORM/Query/QueryException.php | 14 +- lib/Doctrine/ORM/Query/SqlWalker.php | 627 +++--------- lib/Doctrine/ORM/Query/TreeWalker.php | 517 +--------- lib/Doctrine/ORM/Query/TreeWalkerAdapter.php | 773 +-------------- lib/Doctrine/ORM/Query/TreeWalkerChain.php | 902 +----------------- .../Tools/Pagination/CountOutputWalker.php | 31 +- .../ORM/Tools/Pagination/CountWalker.php | 12 +- .../Pagination/LimitSubqueryOutputWalker.php | 81 +- .../Tools/Pagination/LimitSubqueryWalker.php | 26 +- .../ORM/Tools/Pagination/WhereInWalker.php | 28 +- phpstan-baseline.neon | 33 +- psalm-baseline.xml | 128 +-- tests/Doctrine/Tests/Mocks/NullSqlWalker.php | 14 +- .../ORM/Functional/Ticket/DDC736Test.php | 6 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 6 +- .../Tests/ORM/Query/TreeWalkerAdapterTest.php | 65 -- 17 files changed, 350 insertions(+), 2973 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Query/TreeWalkerAdapterTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 3a47cc83784..27dc3c7198d 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,65 @@ # Upgrade to 3.0 +## BC BREAK: Split output walkers and tree walkers + +`SqlWalker` and its child classes don't implement the `TreeWalker` interface +anymore. + +The following methods have been removed from the `TreeWalker` interface and +from the `TreeWalkerAdapter` and `TreeWalkerChain` classes: + +* `setQueryComponent()` +* `walkSelectClause()` +* `walkFromClause()` +* `walkFunction()` +* `walkOrderByClause()` +* `walkOrderByItem()` +* `walkHavingClause()` +* `walkJoin()` +* `walkSelectExpression()` +* `walkQuantifiedExpression()` +* `walkSubselect()` +* `walkSubselectFromClause()` +* `walkSimpleSelectClause()` +* `walkSimpleSelectExpression()` +* `walkAggregateExpression()` +* `walkGroupByClause()` +* `walkGroupByItem()` +* `walkDeleteClause()` +* `walkUpdateClause()` +* `walkUpdateItem()` +* `walkWhereClause()` +* `walkConditionalExpression()` +* `walkConditionalTerm()` +* `walkConditionalFactor()` +* `walkConditionalPrimary()` +* `walkExistsExpression()` +* `walkCollectionMemberExpression()` +* `walkEmptyCollectionComparisonExpression()` +* `walkNullComparisonExpression()` +* `walkInExpression()` +* `walkInstanceOfExpression()` +* `walkLiteral()` +* `walkBetweenExpression()` +* `walkLikeExpression()` +* `walkStateFieldPathExpression()` +* `walkComparisonExpression()` +* `walkInputParameter()` +* `walkArithmeticExpression()` +* `walkArithmeticTerm()` +* `walkStringPrimary()` +* `walkArithmeticFactor()` +* `walkSimpleArithmeticExpression()` +* `walkPathExpression()` +* `walkResultVariable()` +* `getExecutor()` + +The following changes have been made to the abstract `TreeWalkerAdapter` class: + +* The method `setQueryComponent()` is now protected. +* The method `_getQueryComponents()` has been removed in favor of + `getQueryComponents()`. + ## BC BREAK: Removed identity columns emulation through sequences If the platform you are using does not support identity columns, you should diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index 98bb54e9030..de3e7abce32 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -122,24 +122,14 @@ public static function parameterTypeMismatch() return new self('DQL Query parameter and type numbers mismatch, but have to be exactly equal.'); } - /** - * @param PathExpression $pathExpr - * - * @return QueryException - */ - public static function invalidPathExpression($pathExpr) + public static function invalidPathExpression(PathExpression $pathExpr): self { return new self( "Invalid PathExpression '" . $pathExpr->identificationVariable . '.' . $pathExpr->field . "'." ); } - /** - * @param string|Stringable $literal - * - * @return QueryException - */ - public static function invalidLiteral($literal) + public static function invalidLiteral(string|Stringable $literal): self { return new self("Invalid literal '" . $literal . "'"); } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index f1d07f6801d..0161545dbc5 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -45,7 +45,7 @@ * @psalm-import-type QueryComponent from Parser * @psalm-consistent-constructor */ -class SqlWalker implements TreeWalker +class SqlWalker { public const HINT_DISTINCT = 'doctrine.distinct'; @@ -54,166 +54,125 @@ class SqlWalker implements TreeWalker */ public const HINT_PARTIAL = 'doctrine.partial'; - /** @var ResultSetMapping */ - private $rsm; + private ResultSetMapping $rsm; /** * Counter for generating unique column aliases. - * - * @var int */ - private $aliasCounter = 0; + private int $aliasCounter = 0; /** * Counter for generating unique table aliases. - * - * @var int */ - private $tableAliasCounter = 0; + private int $tableAliasCounter = 0; /** * Counter for generating unique scalar result. - * - * @var int */ - private $scalarResultCounter = 1; + private int $scalarResultCounter = 1; /** * Counter for generating unique parameter indexes. - * - * @var int */ - private $sqlParamIndex = 0; + private int $sqlParamIndex = 0; /** * Counter for generating indexes. - * - * @var int */ - private $newObjectCounter = 0; - - /** @var ParserResult */ - private $parserResult; + private int $newObjectCounter = 0; - /** @var EntityManagerInterface */ - private $em; - - /** @var Connection */ - private $conn; - - /** @var Query */ - private $query; + private EntityManagerInterface $em; + private Connection $conn; /** @var mixed[] */ - private $tableAliasMap = []; + private array $tableAliasMap = []; /** * Map from result variable names to their SQL column alias names. * * @psalm-var array> */ - private $scalarResultAliasMap = []; + private array $scalarResultAliasMap = []; /** * Map from Table-Alias + Column-Name to OrderBy-Direction. * * @var array */ - private $orderedColumnsMap = []; + private array $orderedColumnsMap = []; /** * Map from DQL-Alias + Field-Name to SQL Column Alias. * * @var array> */ - private $scalarFields = []; - - /** - * Map of all components/classes that appear in the DQL query. - * - * @psalm-var array - */ - private $queryComponents; + private array $scalarFields = []; /** * A list of classes that appear in non-scalar SelectExpressions. * * @psalm-var array */ - private $selectedClasses = []; + private array $selectedClasses = []; /** * The DQL alias of the root class of the currently traversed query. * * @psalm-var list */ - private $rootAliases = []; + private array $rootAliases = []; /** * Flag that indicates whether to generate SQL table aliases in the SQL. * These should only be generated for SELECT queries, not for UPDATE/DELETE. - * - * @var bool */ - private $useSqlTableAliases = true; + private bool $useSqlTableAliases = true; /** * The database platform abstraction. - * - * @var AbstractPlatform */ - private $platform; + private AbstractPlatform $platform; /** * The quote strategy. - * - * @var QuoteStrategy */ - private $quoteStrategy; + private QuoteStrategy $quoteStrategy; /** - * @param Query $query The parsed Query. - * @param ParserResult $parserResult The result of the parsing process. * @psalm-param array $queryComponents The query components (symbol table). */ - public function __construct($query, $parserResult, array $queryComponents) - { - $this->query = $query; - $this->parserResult = $parserResult; - $this->queryComponents = $queryComponents; - $this->rsm = $parserResult->getResultSetMapping(); - $this->em = $query->getEntityManager(); - $this->conn = $this->em->getConnection(); - $this->platform = $this->conn->getDatabasePlatform(); - $this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy(); + public function __construct( + private Query $query, + private ParserResult $parserResult, + private array $queryComponents + ) { + $this->rsm = $parserResult->getResultSetMapping(); + $this->em = $query->getEntityManager(); + $this->conn = $this->em->getConnection(); + $this->platform = $this->conn->getDatabasePlatform(); + $this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy(); } /** * Gets the Query instance used by the walker. - * - * @return Query */ - public function getQuery() + public function getQuery(): Query { return $this->query; } /** * Gets the Connection used by the walker. - * - * @return Connection */ - public function getConnection() + public function getConnection(): Connection { return $this->conn; } /** * Gets the EntityManager used by the walker. - * - * @return EntityManagerInterface */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { return $this->em; } @@ -226,18 +185,15 @@ public function getEntityManager() * @return mixed[] * @psalm-return QueryComponent */ - public function getQueryComponent($dqlAlias) + public function getQueryComponent(string $dqlAlias): array { return $this->queryComponents[$dqlAlias]; } public function getMetadataForDqlAlias(string $dqlAlias): ClassMetadata { - if (! isset($this->queryComponents[$dqlAlias]['metadata'])) { - throw new LogicException(sprintf('No metadata for DQL alias: %s', $dqlAlias)); - } - - return $this->queryComponents[$dqlAlias]['metadata']; + return $this->queryComponents[$dqlAlias]['metadata'] + ?? throw new LogicException(sprintf('No metadata for DQL alias: %s', $dqlAlias)); } /** @@ -245,7 +201,7 @@ public function getMetadataForDqlAlias(string $dqlAlias): ClassMetadata * * @return array */ - public function getQueryComponents() + public function getQueryComponents(): array { return $this->queryComponents; } @@ -253,12 +209,9 @@ public function getQueryComponents() /** * Sets or overrides a query component for a given dql alias. * - * @param string $dqlAlias The DQL alias. * @psalm-param QueryComponent $queryComponent - * - * @return void */ - public function setQueryComponent($dqlAlias, array $queryComponent) + public function setQueryComponent(string $dqlAlias, array $queryComponent): void { $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; @@ -271,42 +224,27 @@ public function setQueryComponent($dqlAlias, array $queryComponent) /** * Gets an executor that can be used to execute the result of this walker. - * - * @param AST\DeleteStatement|AST\UpdateStatement|AST\SelectStatement $AST - * - * @return Exec\AbstractSqlExecutor */ - public function getExecutor($AST) + public function getExecutor(AST\SelectStatement|AST\UpdateStatement|AST\DeleteStatement $statement): Exec\AbstractSqlExecutor { - switch (true) { - case $AST instanceof AST\DeleteStatement: - $primaryClass = $this->em->getClassMetadata($AST->deleteClause->abstractSchemaName); - - return $primaryClass->isInheritanceTypeJoined() - ? new Exec\MultiTableDeleteExecutor($AST, $this) - : new Exec\SingleTableDeleteUpdateExecutor($AST, $this); - - case $AST instanceof AST\UpdateStatement: - $primaryClass = $this->em->getClassMetadata($AST->updateClause->abstractSchemaName); - - return $primaryClass->isInheritanceTypeJoined() - ? new Exec\MultiTableUpdateExecutor($AST, $this) - : new Exec\SingleTableDeleteUpdateExecutor($AST, $this); - - default: - return new Exec\SingleSelectExecutor($AST, $this); - } + return match (true) { + $statement instanceof AST\SelectStatement + => new Exec\SingleSelectExecutor($statement, $this), + $statement instanceof AST\UpdateStatement + => $this->em->getClassMetadata($statement->updateClause->abstractSchemaName)->isInheritanceTypeJoined() + ? new Exec\MultiTableUpdateExecutor($statement, $this) + : new Exec\SingleTableDeleteUpdateExecutor($statement, $this), + $statement instanceof AST\DeleteStatement + => $this->em->getClassMetadata($statement->deleteClause->abstractSchemaName)->isInheritanceTypeJoined() + ? new Exec\MultiTableDeleteExecutor($statement, $this) + : new Exec\SingleTableDeleteUpdateExecutor($statement, $this), + }; } /** * Generates a unique, short SQL table alias. - * - * @param string $tableName Table name - * @param string $dqlAlias The DQL alias. - * - * @return string Generated table alias. */ - public function getSQLTableAlias($tableName, $dqlAlias = '') + public function getSQLTableAlias(string $tableName, string $dqlAlias = ''): string { $tableName .= $dqlAlias ? '@[' . $dqlAlias . ']' : ''; @@ -321,14 +259,8 @@ public function getSQLTableAlias($tableName, $dqlAlias = '') /** * Forces the SqlWalker to use a specific alias for a table name, rather than * generating an alias on its own. - * - * @param string $tableName - * @param string $alias - * @param string $dqlAlias - * - * @return string */ - public function setSQLTableAlias($tableName, $alias, $dqlAlias = '') + public function setSQLTableAlias(string $tableName, string $alias, string $dqlAlias = ''): string { $tableName .= $dqlAlias ? '@[' . $dqlAlias . ']' : ''; @@ -339,12 +271,8 @@ public function setSQLTableAlias($tableName, $alias, $dqlAlias = '') /** * Gets an SQL column alias for a column name. - * - * @param string $columnName - * - * @return string */ - public function getSQLColumnAlias($columnName) + public function getSQLColumnAlias(string $columnName): string { return $this->quoteStrategy->getColumnAlias($columnName, $this->aliasCounter++, $this->platform); } @@ -352,11 +280,6 @@ public function getSQLColumnAlias($columnName) /** * Generates the SQL JOINs that are necessary for Class Table Inheritance * for the given class. - * - * @param ClassMetadata $class The class for which to generate the joins. - * @param string $dqlAlias The DQL alias of the class. - * - * @return string The SQL. */ private function generateClassTableInheritanceJoins( ClassMetadata $class, @@ -488,11 +411,6 @@ private function generateDiscriminatorColumnConditionSQL(array $dqlAliases): str /** * Generates the filter SQL for a given entity and table alias. - * - * @param ClassMetadata $targetEntity Metadata of the target entity. - * @param string $targetTableAlias The table alias of the joined/selected table. - * - * @return string The SQL query part to add to a query. */ private function generateFilterConditionSQL( ClassMetadata $targetEntity, @@ -536,32 +454,30 @@ private function generateFilterConditionSQL( /** * Walks down a SelectStatement AST node, thereby generating the appropriate SQL. - * - * @return string */ - public function walkSelectStatement(AST\SelectStatement $AST) + public function walkSelectStatement(AST\SelectStatement $selectStatement): string { $limit = $this->query->getMaxResults(); $offset = $this->query->getFirstResult(); $lockMode = $this->query->getHint(Query::HINT_LOCK_MODE) ?: LockMode::NONE; - $sql = $this->walkSelectClause($AST->selectClause) - . $this->walkFromClause($AST->fromClause) - . $this->walkWhereClause($AST->whereClause); + $sql = $this->walkSelectClause($selectStatement->selectClause) + . $this->walkFromClause($selectStatement->fromClause) + . $this->walkWhereClause($selectStatement->whereClause); - if ($AST->groupByClause) { - $sql .= $this->walkGroupByClause($AST->groupByClause); + if ($selectStatement->groupByClause) { + $sql .= $this->walkGroupByClause($selectStatement->groupByClause); } - if ($AST->havingClause) { - $sql .= $this->walkHavingClause($AST->havingClause); + if ($selectStatement->havingClause) { + $sql .= $this->walkHavingClause($selectStatement->havingClause); } - if ($AST->orderByClause) { - $sql .= $this->walkOrderByClause($AST->orderByClause); + if ($selectStatement->orderByClause) { + $sql .= $this->walkOrderByClause($selectStatement->orderByClause); } $orderBySql = $this->generateOrderedCollectionOrderByItems(); - if (! $AST->orderByClause && $orderBySql) { + if (! $selectStatement->orderByClause && $orderBySql) { $sql .= ' ORDER BY ' . $orderBySql; } @@ -593,42 +509,34 @@ public function walkSelectStatement(AST\SelectStatement $AST) } /** - * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL. - * - * @return string + * Walks down a UpdateStatement AST node, thereby generating the appropriate SQL. */ - public function walkUpdateStatement(AST\UpdateStatement $AST) + public function walkUpdateStatement(AST\UpdateStatement $updateStatement): string { $this->useSqlTableAliases = false; $this->rsm->isSelect = false; - return $this->walkUpdateClause($AST->updateClause) - . $this->walkWhereClause($AST->whereClause); + return $this->walkUpdateClause($updateStatement->updateClause) + . $this->walkWhereClause($updateStatement->whereClause); } /** * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. - * - * @return string */ - public function walkDeleteStatement(AST\DeleteStatement $AST) + public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): string { $this->useSqlTableAliases = false; $this->rsm->isSelect = false; - return $this->walkDeleteClause($AST->deleteClause) - . $this->walkWhereClause($AST->whereClause); + return $this->walkDeleteClause($deleteStatement->deleteClause) + . $this->walkWhereClause($deleteStatement->whereClause); } /** * Walks down an IdentificationVariable AST node, thereby generating the appropriate SQL. * This one differs of ->walkIdentificationVariable() because it generates the entity identifiers. - * - * @param string $identVariable - * - * @return string */ - public function walkEntityIdentificationVariable($identVariable) + public function walkEntityIdentificationVariable(string $identVariable): string { $class = $this->getMetadataForDqlAlias($identVariable); $tableAlias = $this->getSQLTableAlias($class->getTableName(), $identVariable); @@ -643,13 +551,8 @@ public function walkEntityIdentificationVariable($identVariable) /** * Walks down an IdentificationVariable (no AST node associated), thereby generating the SQL. - * - * @param string $identificationVariable - * @param string $fieldName - * - * @return string The SQL. */ - public function walkIdentificationVariable($identificationVariable, $fieldName = null) + public function walkIdentificationVariable(string $identificationVariable, ?string $fieldName = null): string { $class = $this->getMetadataForDqlAlias($identificationVariable); @@ -665,12 +568,8 @@ public function walkIdentificationVariable($identificationVariable, $fieldName = /** * Walks down a PathExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\PathExpression $pathExpr - * - * @return string */ - public function walkPathExpression($pathExpr) + public function walkPathExpression(AST\PathExpression $pathExpr): string { $sql = ''; assert($pathExpr->field !== null); @@ -726,12 +625,8 @@ public function walkPathExpression($pathExpr) /** * Walks down a SelectClause AST node, thereby generating the appropriate SQL. - * - * @param AST\SelectClause $selectClause - * - * @return string */ - public function walkSelectClause($selectClause) + public function walkSelectClause(AST\SelectClause $selectClause): string { $sql = 'SELECT ' . ($selectClause->isDistinct ? 'DISTINCT ' : ''); $sqlSelectExpressions = array_filter(array_map([$this, 'walkSelectExpression'], $selectClause->selectExpressions)); @@ -846,12 +741,8 @@ public function walkSelectClause($selectClause) /** * Walks down a FromClause AST node, thereby generating the appropriate SQL. - * - * @param AST\FromClause $fromClause - * - * @return string */ - public function walkFromClause($fromClause) + public function walkFromClause(AST\FromClause $fromClause): string { $identificationVarDecls = $fromClause->identificationVariableDeclarations; $sqlParts = []; @@ -865,12 +756,8 @@ public function walkFromClause($fromClause) /** * Walks down a IdentificationVariableDeclaration AST node, thereby generating the appropriate SQL. - * - * @param AST\IdentificationVariableDeclaration $identificationVariableDecl - * - * @return string */ - public function walkIdentificationVariableDeclaration($identificationVariableDecl) + public function walkIdentificationVariableDeclaration(AST\IdentificationVariableDeclaration $identificationVariableDecl): string { $sql = $this->walkRangeVariableDeclaration($identificationVariableDecl->rangeVariableDeclaration); @@ -887,12 +774,8 @@ public function walkIdentificationVariableDeclaration($identificationVariableDec /** * Walks down a IndexBy AST node. - * - * @param AST\IndexBy $indexBy - * - * @return void */ - public function walkIndexBy($indexBy) + public function walkIndexBy(AST\IndexBy $indexBy): void { $pathExpression = $indexBy->singleValuedPathExpression; $alias = $pathExpression->identificationVariable; @@ -940,12 +823,8 @@ public function walkIndexBy($indexBy) /** * Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL. - * - * @param AST\RangeVariableDeclaration $rangeVariableDeclaration - * - * @return string */ - public function walkRangeVariableDeclaration($rangeVariableDeclaration) + public function walkRangeVariableDeclaration(AST\RangeVariableDeclaration $rangeVariableDeclaration): string { return $this->generateRangeVariableDeclarationSQL($rangeVariableDeclaration, false); } @@ -986,17 +865,15 @@ private function generateRangeVariableDeclarationSQL( /** * Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL. * - * @param AST\JoinAssociationDeclaration $joinAssociationDeclaration - * @param int $joinType - * @param AST\ConditionalExpression $condExpr * @psalm-param AST\Join::JOIN_TYPE_* $joinType * - * @return string - * * @throws QueryException */ - public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joinType = AST\Join::JOIN_TYPE_INNER, $condExpr = null) - { + public function walkJoinAssociationDeclaration( + AST\JoinAssociationDeclaration $joinAssociationDeclaration, + int $joinType = AST\Join::JOIN_TYPE_INNER, + ?AST\ConditionalPrimary $condExpr = null + ): string { $sql = ''; $associationPathExpression = $joinAssociationDeclaration->joinAssociationPathExpression; @@ -1154,24 +1031,16 @@ public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joi /** * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. - * - * @param AST\Functions\FunctionNode $function - * - * @return string */ - public function walkFunction($function) + public function walkFunction(AST\Functions\FunctionNode $function): string { return $function->getSql($this); } /** * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. - * - * @param AST\OrderByClause $orderByClause - * - * @return string */ - public function walkOrderByClause($orderByClause) + public function walkOrderByClause(AST\OrderByClause $orderByClause): string { $orderByItems = array_map([$this, 'walkOrderByItem'], $orderByClause->orderByItems); @@ -1185,12 +1054,8 @@ public function walkOrderByClause($orderByClause) /** * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. - * - * @param AST\OrderByItem $orderByItem - * - * @return string */ - public function walkOrderByItem($orderByItem) + public function walkOrderByItem(AST\OrderByItem $orderByItem): string { $type = strtoupper($orderByItem->type); $expr = $orderByItem->expression; @@ -1209,24 +1074,16 @@ public function walkOrderByItem($orderByItem) /** * Walks down a HavingClause AST node, thereby generating the appropriate SQL. - * - * @param AST\HavingClause $havingClause - * - * @return string The SQL. */ - public function walkHavingClause($havingClause) + public function walkHavingClause(AST\HavingClause $havingClause): string { return ' HAVING ' . $this->walkConditionalExpression($havingClause->conditionalExpression); } /** * Walks down a Join AST node and creates the corresponding SQL. - * - * @param AST\Join $join - * - * @return string */ - public function walkJoin($join) + public function walkJoin(AST\Join $join): string { $joinType = $join->joinType; $joinDeclaration = $join->joinAssociationDeclaration; @@ -1283,12 +1140,8 @@ public function walkJoin($join) /** * Walks down a CoalesceExpression AST node and generates the corresponding SQL. - * - * @param AST\CoalesceExpression $coalesceExpression - * - * @return string The SQL. */ - public function walkCoalesceExpression($coalesceExpression) + public function walkCoalesceExpression(AST\CoalesceExpression $coalesceExpression): string { $sql = 'COALESCE('; @@ -1303,12 +1156,8 @@ public function walkCoalesceExpression($coalesceExpression) /** * Walks down a NullIfExpression AST node and generates the corresponding SQL. - * - * @param AST\NullIfExpression $nullIfExpression - * - * @return string The SQL. */ - public function walkNullIfExpression($nullIfExpression) + public function walkNullIfExpression(AST\NullIfExpression $nullIfExpression): string { $firstExpression = is_string($nullIfExpression->firstExpression) ? $this->conn->quote($nullIfExpression->firstExpression) @@ -1323,10 +1172,8 @@ public function walkNullIfExpression($nullIfExpression) /** * Walks down a GeneralCaseExpression AST node and generates the corresponding SQL. - * - * @return string The SQL. */ - public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCaseExpression) + public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCaseExpression): string { $sql = 'CASE'; @@ -1342,12 +1189,8 @@ public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCase /** * Walks down a SimpleCaseExpression AST node and generates the corresponding SQL. - * - * @param AST\SimpleCaseExpression $simpleCaseExpression - * - * @return string The SQL. */ - public function walkSimpleCaseExpression($simpleCaseExpression) + public function walkSimpleCaseExpression(AST\SimpleCaseExpression $simpleCaseExpression): string { $sql = 'CASE ' . $this->walkStateFieldPathExpression($simpleCaseExpression->caseOperand); @@ -1363,12 +1206,8 @@ public function walkSimpleCaseExpression($simpleCaseExpression) /** * Walks down a SelectExpression AST node and generates the corresponding SQL. - * - * @param AST\SelectExpression $selectExpression - * - * @return string */ - public function walkSelectExpression($selectExpression) + public function walkSelectExpression(AST\SelectExpression $selectExpression): string { $sql = ''; $expr = $selectExpression->expression; @@ -1555,26 +1394,15 @@ public function walkSelectExpression($selectExpression) return $sql; } - /** - * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\QuantifiedExpression $qExpr - * - * @return string - */ - public function walkQuantifiedExpression($qExpr) + public function walkQuantifiedExpression(AST\QuantifiedExpression $qExpr): string { return ' ' . strtoupper($qExpr->type) . '(' . $this->walkSubselect($qExpr->subselect) . ')'; } /** * Walks down a Subselect AST node, thereby generating the appropriate SQL. - * - * @param AST\Subselect $subselect - * - * @return string */ - public function walkSubselect($subselect) + public function walkSubselect(AST\Subselect $subselect): string { $useAliasesBefore = $this->useSqlTableAliases; $rootAliasesBefore = $this->rootAliases; @@ -1598,12 +1426,8 @@ public function walkSubselect($subselect) /** * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. - * - * @param AST\SubselectFromClause $subselectFromClause - * - * @return string */ - public function walkSubselectFromClause($subselectFromClause) + public function walkSubselectFromClause(AST\SubselectFromClause $subselectFromClause): string { $identificationVarDecls = $subselectFromClause->identificationVariableDeclarations; $sqlParts = []; @@ -1617,32 +1441,19 @@ public function walkSubselectFromClause($subselectFromClause) /** * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. - * - * @param AST\SimpleSelectClause $simpleSelectClause - * - * @return string */ - public function walkSimpleSelectClause($simpleSelectClause) + public function walkSimpleSelectClause(AST\SimpleSelectClause $simpleSelectClause): string { return 'SELECT' . ($simpleSelectClause->isDistinct ? ' DISTINCT' : '') . $this->walkSimpleSelectExpression($simpleSelectClause->simpleSelectExpression); } - /** - * @return string - */ - public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesisExpression) + public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesisExpression): string { return sprintf('(%s)', $parenthesisExpression->expression->dispatch($this)); } - /** - * @param AST\NewObjectExpression $newObjectExpression - * @param string|null $newObjectResultAlias - * - * @return string The SQL. - */ - public function walkNewObject($newObjectExpression, $newObjectResultAlias = null) + public function walkNewObject(AST\NewObjectExpression $newObjectExpression, ?string $newObjectResultAlias = null): string { $sqlSelectExpressions = []; $objIndex = $newObjectResultAlias ?: $this->newObjectCounter++; @@ -1710,12 +1521,8 @@ public function walkNewObject($newObjectExpression, $newObjectResultAlias = null /** * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\SimpleSelectExpression $simpleSelectExpression - * - * @return string */ - public function walkSimpleSelectExpression($simpleSelectExpression) + public function walkSimpleSelectExpression(AST\SimpleSelectExpression $simpleSelectExpression): string { $expr = $simpleSelectExpression->expression; $sql = ' '; @@ -1765,12 +1572,8 @@ public function walkSimpleSelectExpression($simpleSelectExpression) /** * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\AggregateExpression $aggExpression - * - * @return string */ - public function walkAggregateExpression($aggExpression) + public function walkAggregateExpression(AST\AggregateExpression $aggExpression): string { return $aggExpression->functionName . '(' . ($aggExpression->isDistinct ? 'DISTINCT ' : '') . $this->walkSimpleArithmeticExpression($aggExpression->pathExpression) . ')'; @@ -1778,12 +1581,8 @@ public function walkAggregateExpression($aggExpression) /** * Walks down a GroupByClause AST node, thereby generating the appropriate SQL. - * - * @param AST\GroupByClause $groupByClause - * - * @return string */ - public function walkGroupByClause($groupByClause) + public function walkGroupByClause(AST\GroupByClause $groupByClause): string { $sqlParts = []; @@ -1796,12 +1595,8 @@ public function walkGroupByClause($groupByClause) /** * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. - * - * @param AST\PathExpression|string $groupByItem - * - * @return string */ - public function walkGroupByItem($groupByItem) + public function walkGroupByItem(AST\PathExpression|string $groupByItem): string { // StateFieldPathExpression if (! is_string($groupByItem)) { @@ -1847,10 +1642,8 @@ public function walkGroupByItem($groupByItem) /** * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. - * - * @return string */ - public function walkDeleteClause(AST\DeleteClause $deleteClause) + public function walkDeleteClause(AST\DeleteClause $deleteClause): string { $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName); $tableName = $class->getTableName(); @@ -1864,12 +1657,8 @@ public function walkDeleteClause(AST\DeleteClause $deleteClause) /** * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. - * - * @param AST\UpdateClause $updateClause - * - * @return string */ - public function walkUpdateClause($updateClause) + public function walkUpdateClause(AST\UpdateClause $updateClause): string { $class = $this->em->getClassMetadata($updateClause->abstractSchemaName); $tableName = $class->getTableName(); @@ -1883,12 +1672,8 @@ public function walkUpdateClause($updateClause) /** * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. - * - * @param AST\UpdateItem $updateItem - * - * @return string */ - public function walkUpdateItem($updateItem) + public function walkUpdateItem(AST\UpdateItem $updateItem): string { $useTableAliasesBefore = $this->useSqlTableAliases; $this->useSqlTableAliases = false; @@ -1896,19 +1681,11 @@ public function walkUpdateItem($updateItem) $sql = $this->walkPathExpression($updateItem->pathExpression) . ' = '; $newValue = $updateItem->newValue; - switch (true) { - case $newValue instanceof AST\Node: - $sql .= $newValue->dispatch($this); - break; - - case $newValue === null: - $sql .= 'NULL'; - break; - - default: - $sql .= $this->conn->quote((string) $newValue); - break; - } + $sql .= match (true) { + $newValue instanceof AST\Node => $newValue->dispatch($this), + $newValue === null => 'NULL', + default => $this->conn->quote((string) $newValue), + }; $this->useSqlTableAliases = $useTableAliasesBefore; @@ -1917,13 +1694,10 @@ public function walkUpdateItem($updateItem) /** * Walks down a WhereClause AST node, thereby generating the appropriate SQL. - * WhereClause or not, the appropriate discriminator sql is added. - * - * @param AST\WhereClause $whereClause * - * @return string + * WhereClause or not, the appropriate discriminator sql is added. */ - public function walkWhereClause($whereClause) + public function walkWhereClause(?AST\WhereClause $whereClause): string { $condSql = $whereClause !== null ? $this->walkConditionalExpression($whereClause->conditionalExpression) : ''; $discrSql = $this->generateDiscriminatorColumnConditionSQL($this->rootAliases); @@ -1962,13 +1736,10 @@ public function walkWhereClause($whereClause) /** * Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\ConditionalExpression $condExpr - * - * @return string */ - public function walkConditionalExpression($condExpr) - { + public function walkConditionalExpression( + AST\ConditionalExpression|AST\ConditionalPrimary|AST\ConditionalTerm|AST\ConditionalFactor $condExpr + ): string { // Phase 2 AST optimization: Skip processing of ConditionalExpression // if only one ConditionalTerm is defined if (! ($condExpr instanceof AST\ConditionalExpression)) { @@ -1980,13 +1751,10 @@ public function walkConditionalExpression($condExpr) /** * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. - * - * @param AST\ConditionalTerm $condTerm - * - * @return string */ - public function walkConditionalTerm($condTerm) - { + public function walkConditionalTerm( + AST\ConditionalTerm|AST\ConditionalPrimary|AST\ConditionalFactor $condTerm + ): string { // Phase 2 AST optimization: Skip processing of ConditionalTerm // if only one ConditionalFactor is defined if (! ($condTerm instanceof AST\ConditionalTerm)) { @@ -1998,13 +1766,10 @@ public function walkConditionalTerm($condTerm) /** * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. - * - * @param AST\ConditionalFactor $factor - * - * @return string The SQL. */ - public function walkConditionalFactor($factor) - { + public function walkConditionalFactor( + AST\ConditionalFactor|AST\ConditionalPrimary $factor + ): string { // Phase 2 AST optimization: Skip processing of ConditionalFactor // if only one ConditionalPrimary is defined return ! ($factor instanceof AST\ConditionalFactor) @@ -2014,12 +1779,8 @@ public function walkConditionalFactor($factor) /** * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. - * - * @param AST\ConditionalPrimary $primary - * - * @return string */ - public function walkConditionalPrimary($primary) + public function walkConditionalPrimary(AST\ConditionalPrimary $primary): string { if ($primary->isSimpleConditionalExpression()) { return $primary->simpleConditionalExpression->dispatch($this); @@ -2030,16 +1791,14 @@ public function walkConditionalPrimary($primary) return '(' . $this->walkConditionalExpression($condExpr) . ')'; } + + throw new LogicException('Unexpected state of ConditionalPrimary node.'); } /** * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\ExistsExpression $existsExpr - * - * @return string */ - public function walkExistsExpression($existsExpr) + public function walkExistsExpression(AST\ExistsExpression $existsExpr): string { $sql = $existsExpr->not ? 'NOT ' : ''; @@ -2050,12 +1809,8 @@ public function walkExistsExpression($existsExpr) /** * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\CollectionMemberExpression $collMemberExpr - * - * @return string */ - public function walkCollectionMemberExpression($collMemberExpr) + public function walkCollectionMemberExpression(AST\CollectionMemberExpression $collMemberExpr): string { $sql = $collMemberExpr->not ? 'NOT ' : ''; $sql .= 'EXISTS (SELECT 1 FROM '; @@ -2151,12 +1906,8 @@ public function walkCollectionMemberExpression($collMemberExpr) /** * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\EmptyCollectionComparisonExpression $emptyCollCompExpr - * - * @return string */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) + public function walkEmptyCollectionComparisonExpression(AST\EmptyCollectionComparisonExpression $emptyCollCompExpr): string { $sizeFunc = new AST\Functions\SizeFunction('size'); $sizeFunc->collectionPathExpression = $emptyCollCompExpr->expression; @@ -2166,12 +1917,8 @@ public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) /** * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\NullComparisonExpression $nullCompExpr - * - * @return string */ - public function walkNullComparisonExpression($nullCompExpr) + public function walkNullComparisonExpression(AST\NullComparisonExpression $nullCompExpr): string { $expression = $nullCompExpr->expression; $comparison = ' IS' . ($nullCompExpr->not ? ' NOT' : '') . ' NULL'; @@ -2191,12 +1938,8 @@ public function walkNullComparisonExpression($nullCompExpr) /** * Walks down an InExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\InExpression $inExpr - * - * @return string */ - public function walkInExpression($inExpr) + public function walkInExpression(AST\InExpression $inExpr): string { $sql = $this->walkArithmeticExpression($inExpr->expression) . ($inExpr->not ? ' NOT' : '') . ' IN ('; @@ -2212,13 +1955,9 @@ public function walkInExpression($inExpr) /** * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. * - * @param AST\InstanceOfExpression $instanceOfExpr - * - * @return string - * * @throws QueryException */ - public function walkInstanceOfExpression($instanceOfExpr) + public function walkInstanceOfExpression(AST\InstanceOfExpression $instanceOfExpr): string { $sql = ''; @@ -2239,12 +1978,7 @@ public function walkInstanceOfExpression($instanceOfExpr) return $sql; } - /** - * @param mixed $inParam - * - * @return string - */ - public function walkInParameter($inParam) + public function walkInParameter(mixed $inParam): string { return $inParam instanceof AST\InputParameter ? $this->walkInputParameter($inParam) @@ -2253,36 +1987,21 @@ public function walkInParameter($inParam) /** * Walks down a literal that represents an AST node, thereby generating the appropriate SQL. - * - * @param AST\Literal $literal - * - * @return string */ - public function walkLiteral($literal) + public function walkLiteral(AST\Literal $literal): string { - switch ($literal->type) { - case AST\Literal::STRING: - return $this->conn->quote($literal->value); - - case AST\Literal::BOOLEAN: - return (string) $this->conn->getDatabasePlatform()->convertBooleans(strtolower($literal->value) === 'true'); - - case AST\Literal::NUMERIC: - return (string) $literal->value; - - default: - throw QueryException::invalidLiteral($literal); - } + return match ($literal->type) { + AST\Literal::STRING => $this->conn->quote($literal->value), + AST\Literal::BOOLEAN => (string) $this->conn->getDatabasePlatform()->convertBooleans(strtolower($literal->value) === 'true'), + AST\Literal::NUMERIC => (string) $literal->value, + default => throw QueryException::invalidLiteral($literal), + }; } /** * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\BetweenExpression $betweenExpr - * - * @return string */ - public function walkBetweenExpression($betweenExpr) + public function walkBetweenExpression(AST\BetweenExpression $betweenExpr): string { $sql = $this->walkArithmeticExpression($betweenExpr->expression); @@ -2298,12 +2017,8 @@ public function walkBetweenExpression($betweenExpr) /** * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\LikeExpression $likeExpr - * - * @return string */ - public function walkLikeExpression($likeExpr) + public function walkLikeExpression(AST\LikeExpression $likeExpr): string { $stringExpr = $likeExpr->stringExpression; if (is_string($stringExpr)) { @@ -2337,24 +2052,16 @@ public function walkLikeExpression($likeExpr) /** * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\PathExpression $stateFieldPathExpression - * - * @return string */ - public function walkStateFieldPathExpression($stateFieldPathExpression) + public function walkStateFieldPathExpression(AST\PathExpression $stateFieldPathExpression): string { return $this->walkPathExpression($stateFieldPathExpression); } /** * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\ComparisonExpression $compExpr - * - * @return string */ - public function walkComparisonExpression($compExpr) + public function walkComparisonExpression(AST\ComparisonExpression $compExpr): string { $leftExpr = $compExpr->leftExpression; $rightExpr = $compExpr->rightExpression; @@ -2375,12 +2082,8 @@ public function walkComparisonExpression($compExpr) /** * Walks down an InputParameter AST node, thereby generating the appropriate SQL. - * - * @param AST\InputParameter $inputParam - * - * @return string */ - public function walkInputParameter($inputParam) + public function walkInputParameter(AST\InputParameter $inputParam): string { $this->parserResult->addParameterMapping($inputParam->name, $this->sqlParamIndex++); @@ -2398,12 +2101,8 @@ public function walkInputParameter($inputParam) /** * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\ArithmeticExpression $arithmeticExpr - * - * @return string */ - public function walkArithmeticExpression($arithmeticExpr) + public function walkArithmeticExpression(AST\ArithmeticExpression $arithmeticExpr): string { return $arithmeticExpr->isSimpleArithmeticExpression() ? $this->walkSimpleArithmeticExpression($arithmeticExpr->simpleArithmeticExpression) @@ -2412,12 +2111,8 @@ public function walkArithmeticExpression($arithmeticExpr) /** * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. - * - * @param AST\SimpleArithmeticExpression $simpleArithmeticExpr - * - * @return string */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr) + public function walkSimpleArithmeticExpression(AST\Node|string $simpleArithmeticExpr): string { if (! ($simpleArithmeticExpr instanceof AST\SimpleArithmeticExpression)) { return $this->walkArithmeticTerm($simpleArithmeticExpr); @@ -2428,12 +2123,8 @@ public function walkSimpleArithmeticExpression($simpleArithmeticExpr) /** * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. - * - * @param mixed $term - * - * @return string */ - public function walkArithmeticTerm($term) + public function walkArithmeticTerm(AST\Node|string $term): string { if (is_string($term)) { return isset($this->queryComponents[$term]) @@ -2452,12 +2143,8 @@ public function walkArithmeticTerm($term) /** * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed $factor - * - * @return string */ - public function walkArithmeticFactor($factor) + public function walkArithmeticFactor(AST\Node|string $factor): string { if (is_string($factor)) { return isset($this->queryComponents[$factor]) @@ -2478,12 +2165,8 @@ public function walkArithmeticFactor($factor) /** * Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed $primary - * - * @return string The SQL. */ - public function walkArithmeticPrimary($primary) + public function walkArithmeticPrimary(AST\Node|string $primary): string { if ($primary instanceof AST\SimpleArithmeticExpression) { return '(' . $this->walkSimpleArithmeticExpression($primary) . ')'; @@ -2498,12 +2181,8 @@ public function walkArithmeticPrimary($primary) /** * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. - * - * @param mixed $stringPrimary - * - * @return string */ - public function walkStringPrimary($stringPrimary) + public function walkStringPrimary(AST\Node|string $stringPrimary): string { return is_string($stringPrimary) ? $this->conn->quote($stringPrimary) @@ -2512,12 +2191,8 @@ public function walkStringPrimary($stringPrimary) /** * Walks down a ResultVariable that represents an AST node, thereby generating the appropriate SQL. - * - * @param string $resultVariable - * - * @return string */ - public function walkResultVariable($resultVariable) + public function walkResultVariable(string $resultVariable): string { if (! isset($this->scalarResultAliasMap[$resultVariable])) { throw new InvalidArgumentException(sprintf('Unknown result variable: %s', $resultVariable)); diff --git a/lib/Doctrine/ORM/Query/TreeWalker.php b/lib/Doctrine/ORM/Query/TreeWalker.php index 00c3d52c498..6c215773d4f 100644 --- a/lib/Doctrine/ORM/Query/TreeWalker.php +++ b/lib/Doctrine/ORM/Query/TreeWalker.php @@ -16,536 +16,29 @@ interface TreeWalker /** * Initializes TreeWalker with important information about the ASTs to be walked. * - * @param AbstractQuery $query The parsed Query. - * @param ParserResult $parserResult The result of the parsing process. - * @param mixed[] $queryComponents The query components (symbol table). * @psalm-param array $queryComponents The query components (symbol table). */ - public function __construct($query, $parserResult, array $queryComponents); + public function __construct(AbstractQuery $query, ParserResult $parserResult, array $queryComponents); /** * Returns internal queryComponents array. * - * @return array> * @psalm-return array */ - public function getQueryComponents(); - - /** - * Sets or overrides a query component for a given dql alias. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param string $dqlAlias The DQL alias. - * @param array $queryComponent - * @psalm-param QueryComponent $queryComponent - * - * @return void - */ - public function setQueryComponent($dqlAlias, array $queryComponent); + public function getQueryComponents(): array; /** * Walks down a SelectStatement AST node. - * - * @return void - */ - public function walkSelectStatement(AST\SelectStatement $AST); - - /** - * Walks down a SelectClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\SelectClause $selectClause - * - * @return void */ - public function walkSelectClause($selectClause); - - /** - * Walks down a FromClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\FromClause $fromClause - * - * @return void - */ - public function walkFromClause($fromClause); - - /** - * Walks down a FunctionNode AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\Functions\FunctionNode $function - * - * @return void - */ - public function walkFunction($function); - - /** - * Walks down an OrderByClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\OrderByClause $orderByClause - * - * @return void - */ - public function walkOrderByClause($orderByClause); - - /** - * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\OrderByItem $orderByItem - * - * @return void - */ - public function walkOrderByItem($orderByItem); - - /** - * Walks down a HavingClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\HavingClause $havingClause - * - * @return void - */ - public function walkHavingClause($havingClause); - - /** - * Walks down a Join AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\Join $join - * - * @return void - */ - public function walkJoin($join); - - /** - * Walks down a SelectExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\SelectExpression $selectExpression - * - * @return void - */ - public function walkSelectExpression($selectExpression); - - /** - * Walks down a QuantifiedExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\QuantifiedExpression $qExpr - * - * @return void - */ - public function walkQuantifiedExpression($qExpr); - - /** - * Walks down a Subselect AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\Subselect $subselect - * - * @return void - */ - public function walkSubselect($subselect); - - /** - * Walks down a SubselectFromClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\SubselectFromClause $subselectFromClause - * - * @return void - */ - public function walkSubselectFromClause($subselectFromClause); - - /** - * Walks down a SimpleSelectClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\SimpleSelectClause $simpleSelectClause - * - * @return void - */ - public function walkSimpleSelectClause($simpleSelectClause); - - /** - * Walks down a SimpleSelectExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\SimpleSelectExpression $simpleSelectExpression - * - * @return void - */ - public function walkSimpleSelectExpression($simpleSelectExpression); - - /** - * Walks down an AggregateExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\AggregateExpression $aggExpression - * - * @return void - */ - public function walkAggregateExpression($aggExpression); - - /** - * Walks down a GroupByClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\GroupByClause $groupByClause - * - * @return void - */ - public function walkGroupByClause($groupByClause); - - /** - * Walks down a GroupByItem AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\PathExpression|string $groupByItem - * - * @return void - */ - public function walkGroupByItem($groupByItem); + public function walkSelectStatement(AST\SelectStatement $selectStatement): void; /** * Walks down an UpdateStatement AST node. - * - * @return void */ - public function walkUpdateStatement(AST\UpdateStatement $AST); + public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void; /** * Walks down a DeleteStatement AST node. - * - * @return void - */ - public function walkDeleteStatement(AST\DeleteStatement $AST); - - /** - * Walks down a DeleteClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @return void - */ - public function walkDeleteClause(AST\DeleteClause $deleteClause); - - /** - * Walks down an UpdateClause AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\UpdateClause $updateClause - * - * @return void - */ - public function walkUpdateClause($updateClause); - - /** - * Walks down an UpdateItem AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\UpdateItem $updateItem - * - * @return void - */ - public function walkUpdateItem($updateItem); - - /** - * Walks down a WhereClause AST node. - * - * WhereClause or not, the appropriate discriminator sql is added. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\WhereClause $whereClause - * - * @return void - */ - public function walkWhereClause($whereClause); - - /** - * Walk down a ConditionalExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\ConditionalExpression $condExpr - * - * @return void - */ - public function walkConditionalExpression($condExpr); - - /** - * Walks down a ConditionalTerm AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\ConditionalTerm $condTerm - * - * @return void - */ - public function walkConditionalTerm($condTerm); - - /** - * Walks down a ConditionalFactor AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\ConditionalFactor $factor - * - * @return void - */ - public function walkConditionalFactor($factor); - - /** - * Walks down a ConditionalPrimary AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\ConditionalPrimary $primary - * - * @return void - */ - public function walkConditionalPrimary($primary); - - /** - * Walks down an ExistsExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\ExistsExpression $existsExpr - * - * @return void - */ - public function walkExistsExpression($existsExpr); - - /** - * Walks down a CollectionMemberExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\CollectionMemberExpression $collMemberExpr - * - * @return void - */ - public function walkCollectionMemberExpression($collMemberExpr); - - /** - * Walks down an EmptyCollectionComparisonExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\EmptyCollectionComparisonExpression $emptyCollCompExpr - * - * @return void - */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr); - - /** - * Walks down a NullComparisonExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\NullComparisonExpression $nullCompExpr - * - * @return void - */ - public function walkNullComparisonExpression($nullCompExpr); - - /** - * Walks down an InExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\InExpression $inExpr - * - * @return void - */ - public function walkInExpression($inExpr); - - /** - * Walks down an InstanceOfExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\InstanceOfExpression $instanceOfExpr - * - * @return void - */ - public function walkInstanceOfExpression($instanceOfExpr); - - /** - * Walks down a literal that represents an AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\Literal $literal - * - * @return void - */ - public function walkLiteral($literal); - - /** - * Walks down a BetweenExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\BetweenExpression $betweenExpr - * - * @return void - */ - public function walkBetweenExpression($betweenExpr); - - /** - * Walks down a LikeExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\LikeExpression $likeExpr - * - * @return void - */ - public function walkLikeExpression($likeExpr); - - /** - * Walks down a StateFieldPathExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\PathExpression $stateFieldPathExpression - * - * @return void - */ - public function walkStateFieldPathExpression($stateFieldPathExpression); - - /** - * Walks down a ComparisonExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\ComparisonExpression $compExpr - * - * @return void - */ - public function walkComparisonExpression($compExpr); - - /** - * Walks down an InputParameter AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\InputParameter $inputParam - * - * @return void - */ - public function walkInputParameter($inputParam); - - /** - * Walks down an ArithmeticExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\ArithmeticExpression $arithmeticExpr - * - * @return void - */ - public function walkArithmeticExpression($arithmeticExpr); - - /** - * Walks down an ArithmeticTerm AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param mixed $term - * - * @return void - */ - public function walkArithmeticTerm($term); - - /** - * Walks down a StringPrimary that represents an AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param mixed $stringPrimary - * - * @return void - */ - public function walkStringPrimary($stringPrimary); - - /** - * Walks down an ArithmeticFactor that represents an AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param mixed $factor - * - * @return void - */ - public function walkArithmeticFactor($factor); - - /** - * Walks down an SimpleArithmeticExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\SimpleArithmeticExpression $simpleArithmeticExpr - * - * @return void - */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr); - - /** - * Walks down a PathExpression AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\PathExpression $pathExpr - * - * @return void - */ - public function walkPathExpression($pathExpr); - - /** - * Walks down a ResultVariable that represents an AST node. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param string $resultVariable - * - * @return void - */ - public function walkResultVariable($resultVariable); - - /** - * Gets an executor that can be used to execute the result of this walker. - * - * @deprecated This method will be removed from the interface in 3.0. - * - * @param AST\DeleteStatement|AST\UpdateStatement|AST\SelectStatement $AST - * - * @return Exec\AbstractSqlExecutor */ - public function getExecutor($AST); + public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void; } diff --git a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php index 9a46e554e6d..bdc3f353168 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php @@ -4,19 +4,14 @@ namespace Doctrine\ORM\Query; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Mapping\ClassMetadata; use LogicException; use function array_diff; use function array_keys; -use function debug_backtrace; -use function is_a; use function sprintf; -use const DEBUG_BACKTRACE_IGNORE_ARGS; - /** * An adapter implementation of the TreeWalker interface. The methods in this class * are empty. This class exists as convenience for creating tree walkers. @@ -26,67 +21,42 @@ abstract class TreeWalkerAdapter implements TreeWalker { /** - * The original Query. - * - * @var AbstractQuery + * {@inheritdoc} */ - private $query; + public function __construct( + private AbstractQuery $query, + private ParserResult $parserResult, + private array $queryComponents + ) { + } /** - * The ParserResult of the original query that was produced by the Parser. - * - * @var ParserResult + * {@inheritdoc} */ - private $parserResult; + public function getQueryComponents(): array + { + return $this->queryComponents; + } - /** - * The query components of the original query (the "symbol table") that was produced by the Parser. - * - * @psalm-var array - */ - private $queryComponents; + public function walkSelectStatement(AST\SelectStatement $selectStatement): void + { + } - /** - * {@inheritdoc} - */ - public function __construct($query, $parserResult, array $queryComponents) + public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void { - $this->query = $query; - $this->parserResult = $parserResult; - $this->queryComponents = $queryComponents; } - /** - * {@inheritdoc} - */ - public function getQueryComponents() + public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void { - return $this->queryComponents; } /** * Sets or overrides a query component for a given dql alias. * - * @internal This method will be protected in 3.0. - * - * @param string $dqlAlias The DQL alias. - * @param array $queryComponent * @psalm-param QueryComponent $queryComponent - * - * @return void */ - public function setQueryComponent($dqlAlias, array $queryComponent) + protected function setQueryComponent(string $dqlAlias, array $queryComponent): void { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - if (! isset($trace[1]['class']) || ! is_a($trace[1]['class'], self::class, true)) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method %s will be protected in 3.0. Calling it publicly is deprecated.', - __METHOD__ - ); - } - $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; if (array_diff($requiredKeys, array_keys($queryComponent))) { @@ -96,722 +66,25 @@ public function setQueryComponent($dqlAlias, array $queryComponent) $this->queryComponents[$dqlAlias] = $queryComponent; } - /** - * Returns internal queryComponents array. - * - * @deprecated Call {@see getQueryComponents()} instead. - * - * @return array> - * @psalm-return array - */ - protected function _getQueryComponents() - { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method %s is deprecated, call getQueryComponents() instead.', - __METHOD__ - ); - - return $this->queryComponents; - } - /** * Retrieves the Query Instance responsible for the current walkers execution. - * - * @return AbstractQuery */ - protected function _getQuery() + protected function _getQuery(): AbstractQuery { return $this->query; } /** * Retrieves the ParserResult. - * - * @return ParserResult */ - protected function _getParserResult() + protected function _getParserResult(): ParserResult { return $this->parserResult; } - public function walkSelectStatement(AST\SelectStatement $AST) - { - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSelectClause($selectClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkFromClause($fromClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkFunction($function) + protected function getMetadataForDqlAlias(string $dqlAlias): ClassMetadata { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkOrderByClause($orderByClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkOrderByItem($orderByItem) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkHavingClause($havingClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkJoin($join) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSelectExpression($selectExpression) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkQuantifiedExpression($qExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSubselect($subselect) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSubselectFromClause($subselectFromClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSimpleSelectClause($simpleSelectClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSimpleSelectExpression($simpleSelectExpression) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkAggregateExpression($aggExpression) - { - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkGroupByClause($groupByClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkGroupByItem($groupByItem) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - public function walkUpdateStatement(AST\UpdateStatement $AST) - { - } - - public function walkDeleteStatement(AST\DeleteStatement $AST) - { - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkDeleteClause(AST\DeleteClause $deleteClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkUpdateClause($updateClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkUpdateItem($updateItem) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkWhereClause($whereClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkConditionalExpression($condExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkConditionalTerm($condTerm) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkConditionalFactor($factor) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkConditionalPrimary($primary) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkExistsExpression($existsExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkCollectionMemberExpression($collMemberExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkNullComparisonExpression($nullCompExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkInExpression($inExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkInstanceOfExpression($instanceOfExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkLiteral($literal) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkBetweenExpression($betweenExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkLikeExpression($likeExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkStateFieldPathExpression($stateFieldPathExpression) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkComparisonExpression($compExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkInputParameter($inputParam) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkArithmeticExpression($arithmeticExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkArithmeticTerm($term) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkStringPrimary($stringPrimary) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkArithmeticFactor($factor) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkPathExpression($pathExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkResultVariable($resultVariable) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function getExecutor($AST) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - return null; - } - - final protected function getMetadataForDqlAlias(string $dqlAlias): ClassMetadata - { - $metadata = $this->_getQueryComponents()[$dqlAlias]['metadata'] ?? null; - - if ($metadata === null) { - throw new LogicException(sprintf('No metadata for DQL alias: %s', $dqlAlias)); - } - - return $metadata; + return $this->queryComponents[$dqlAlias]['metadata'] + ?? throw new LogicException(sprintf('No metadata for DQL alias: %s', $dqlAlias)); } } diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChain.php b/lib/Doctrine/ORM/Query/TreeWalkerChain.php index b2dec0fa1ef..4c4b34f7301 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerChain.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerChain.php @@ -4,13 +4,9 @@ namespace Doctrine\ORM\Query; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\AbstractQuery; use Generator; -use function array_diff; -use function array_keys; - /** * Represents a chain of tree walkers that modify an AST and finally emit output. * Only the last walker in the chain can emit output. Any previous walkers can modify @@ -26,928 +22,62 @@ class TreeWalkerChain implements TreeWalker * @var string[] * @psalm-var list> */ - private $walkers = []; - - /** @var AbstractQuery */ - private $query; - - /** @var ParserResult */ - private $parserResult; + private array $walkers = []; /** - * The query components of the original query (the "symbol table") that was produced by the Parser. - * - * @var array> - * @psalm-var array + * {@inheritdoc} */ - private $queryComponents; + public function __construct( + private AbstractQuery $query, + private ParserResult $parserResult, + private array $queryComponents + ) { + } /** * Returns the internal queryComponents array. * * {@inheritDoc} */ - public function getQueryComponents() + public function getQueryComponents(): array { return $this->queryComponents; } - /** - * {@inheritdoc} - * - * @return void - */ - public function setQueryComponent($dqlAlias, array $queryComponent) - { - $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; - - if (array_diff($requiredKeys, array_keys($queryComponent))) { - throw QueryException::invalidQueryComponent($dqlAlias); - } - - $this->queryComponents[$dqlAlias] = $queryComponent; - } - - /** - * {@inheritdoc} - */ - public function __construct($query, $parserResult, array $queryComponents) - { - $this->query = $query; - $this->parserResult = $parserResult; - $this->queryComponents = $queryComponents; - } - /** * Adds a tree walker to the chain. * * @param string $walkerClass The class of the walker to instantiate. * @psalm-param class-string $walkerClass - * - * @return void */ - public function addTreeWalker($walkerClass) + public function addTreeWalker(string $walkerClass): void { $this->walkers[] = $walkerClass; } - public function walkSelectStatement(AST\SelectStatement $AST) + public function walkSelectStatement(AST\SelectStatement $selectStatement): void { foreach ($this->getWalkers() as $walker) { - $walker->walkSelectStatement($AST); + $walker->walkSelectStatement($selectStatement); $this->queryComponents = $walker->getQueryComponents(); } } - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSelectClause($selectClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkSelectClause($selectClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkFromClause($fromClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkFromClause($fromClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkFunction($function) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkFunction($function); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkOrderByClause($orderByClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkOrderByClause($orderByClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkOrderByItem($orderByItem) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkOrderByItem($orderByItem); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkHavingClause($havingClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkHavingClause($havingClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkJoin($join) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkJoin($join); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSelectExpression($selectExpression) + public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - foreach ($this->getWalkers() as $walker) { - $walker->walkSelectExpression($selectExpression); + $walker->walkUpdateStatement($updateStatement); } } - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkQuantifiedExpression($qExpr) + public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkQuantifiedExpression($qExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSubselect($subselect) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - foreach ($this->getWalkers() as $walker) { - $walker->walkSubselect($subselect); + $walker->walkDeleteStatement($deleteStatement); } } - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSubselectFromClause($subselectFromClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkSubselectFromClause($subselectFromClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSimpleSelectClause($simpleSelectClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkSimpleSelectClause($simpleSelectClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSimpleSelectExpression($simpleSelectExpression) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkSimpleSelectExpression($simpleSelectExpression); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkAggregateExpression($aggExpression) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkAggregateExpression($aggExpression); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkGroupByClause($groupByClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkGroupByClause($groupByClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkGroupByItem($groupByItem) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkGroupByItem($groupByItem); - } - } - - public function walkUpdateStatement(AST\UpdateStatement $AST) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkUpdateStatement($AST); - } - } - - public function walkDeleteStatement(AST\DeleteStatement $AST) - { - foreach ($this->getWalkers() as $walker) { - $walker->walkDeleteStatement($AST); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkDeleteClause(AST\DeleteClause $deleteClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkDeleteClause($deleteClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkUpdateClause($updateClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkUpdateClause($updateClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkUpdateItem($updateItem) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkUpdateItem($updateItem); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkWhereClause($whereClause) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkWhereClause($whereClause); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkConditionalExpression($condExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkConditionalExpression($condExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkConditionalTerm($condTerm) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkConditionalTerm($condTerm); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkConditionalFactor($factor) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkConditionalFactor($factor); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkConditionalPrimary($condPrimary) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkConditionalPrimary($condPrimary); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkExistsExpression($existsExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkExistsExpression($existsExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkCollectionMemberExpression($collMemberExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkCollectionMemberExpression($collMemberExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkEmptyCollectionComparisonExpression($emptyCollCompExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkNullComparisonExpression($nullCompExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkNullComparisonExpression($nullCompExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkInExpression($inExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkInExpression($inExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkInstanceOfExpression($instanceOfExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkInstanceOfExpression($instanceOfExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkLiteral($literal) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkLiteral($literal); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkBetweenExpression($betweenExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkBetweenExpression($betweenExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkLikeExpression($likeExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkLikeExpression($likeExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkStateFieldPathExpression($stateFieldPathExpression) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkStateFieldPathExpression($stateFieldPathExpression); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkComparisonExpression($compExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkComparisonExpression($compExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkInputParameter($inputParam) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkInputParameter($inputParam); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkArithmeticExpression($arithmeticExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkArithmeticExpression($arithmeticExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkArithmeticTerm($term) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkArithmeticTerm($term); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkStringPrimary($stringPrimary) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkStringPrimary($stringPrimary); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkArithmeticFactor($factor) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkArithmeticFactor($factor); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkSimpleArithmeticExpression($simpleArithmeticExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkSimpleArithmeticExpression($simpleArithmeticExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkPathExpression($pathExpr) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkPathExpression($pathExpr); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function walkResultVariable($resultVariable) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - foreach ($this->getWalkers() as $walker) { - $walker->walkResultVariable($resultVariable); - } - } - - /** - * {@inheritdoc} - * - * @deprecated This method will be removed in 3.0. - */ - public function getExecutor($AST) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9551', - 'Method "%s" is deprecated and will be removed in ORM 3.0 without replacement.', - __METHOD__ - ); - - return null; - } - /** * @psalm-return Generator */ diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index 9a650ed93dd..3c6aae1b132 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -38,23 +38,13 @@ */ class CountOutputWalker extends SqlWalker { - /** @var AbstractPlatform */ - private $platform; - - /** @var ResultSetMapping */ - private $rsm; + private AbstractPlatform $platform; + private ResultSetMapping $rsm; /** - * Stores various parameters that are otherwise unavailable - * because Doctrine\ORM\Query\SqlWalker keeps everything private without - * accessors. - * - * @param Query $query - * @param ParserResult $parserResult - * @param mixed[] $queryComponents - * @psalm-param array $queryComponents + * {@inheritdoc} */ - public function __construct($query, $parserResult, array $queryComponents) + public function __construct(Query $query, ParserResult $parserResult, array $queryComponents) { $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform(); $this->rsm = $parserResult->getResultSetMapping(); @@ -62,18 +52,15 @@ public function __construct($query, $parserResult, array $queryComponents) parent::__construct($query, $parserResult, $queryComponents); } - /** - * {@inheritdoc} - */ - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $selectStatement): string { if ($this->platform instanceof SQLServerPlatform) { - $AST->orderByClause = null; + $selectStatement->orderByClause = null; } - $sql = parent::walkSelectStatement($AST); + $sql = parent::walkSelectStatement($selectStatement); - if ($AST->groupByClause) { + if ($selectStatement->groupByClause) { return sprintf( 'SELECT COUNT(*) AS dctrn_count FROM (%s) dctrn_table', $sql @@ -86,7 +73,7 @@ public function walkSelectStatement(SelectStatement $AST) // so for now, It's not supported. // Get the root entity and alias from the AST fromClause - $from = $AST->fromClause->identificationVariableDeclarations; + $from = $selectStatement->fromClause->identificationVariableDeclarations; if (count($from) > 1) { throw new RuntimeException('Cannot count query which selects two FROM components, cannot make distinction'); } diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php index 12c5efe32fb..754259f5a7c 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -24,14 +24,14 @@ class CountWalker extends TreeWalkerAdapter */ public const HINT_DISTINCT = 'doctrine_paginator.distinct'; - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $selectStatement): void { - if ($AST->havingClause) { + if ($selectStatement->havingClause) { throw new RuntimeException('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); } // Get the root entity and alias from the AST fromClause - $from = $AST->fromClause->identificationVariableDeclarations; + $from = $selectStatement->fromClause->identificationVariableDeclarations; if (count($from) > 1) { throw new RuntimeException('Cannot count query which selects two FROM components, cannot make distinction'); @@ -54,8 +54,8 @@ public function walkSelectStatement(SelectStatement $AST) ); $pathExpression->type = $pathType; - $distinct = $this->_getQuery()->getHint(self::HINT_DISTINCT); - $AST->selectClause->selectExpressions = [ + $distinct = $this->_getQuery()->getHint(self::HINT_DISTINCT); + $selectStatement->selectClause->selectExpressions = [ new SelectExpression( new AggregateExpression('count', $pathExpression, $distinct), null @@ -63,6 +63,6 @@ public function walkSelectStatement(SelectStatement $AST) ]; // ORDER BY is not needed, only increases query execution through unnecessary sorting. - $AST->orderByClause = null; + $selectStatement->orderByClause = null; } } diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 02a65f921c0..5e0cf0281f8 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -18,6 +18,7 @@ use Doctrine\ORM\Query\AST\PathExpression; use Doctrine\ORM\Query\AST\SelectExpression; use Doctrine\ORM\Query\AST\SelectStatement; +use Doctrine\ORM\Query\AST\Subselect; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\ParserResult; use Doctrine\ORM\Query\QueryException; @@ -54,54 +55,39 @@ class LimitSubqueryOutputWalker extends SqlWalker { private const ORDER_BY_PATH_EXPRESSION = '/(? */ - private $orderByPathExpressions = []; + private array $orderByPathExpressions = []; /** - * @var bool We don't want to add path expressions from sub-selects into the select clause of the containing query. - * This state flag simply keeps track on whether we are walking on a subquery or not + * We don't want to add path expressions from sub-selects into the select clause of the containing query. + * This state flag simply keeps track on whether we are walking on a subquery or not */ - private $inSubSelect = false; + private bool $inSubSelect = false; /** * Stores various parameters that are otherwise unavailable * because Doctrine\ORM\Query\SqlWalker keeps everything private without * accessors. * - * @param Query $query - * @param ParserResult $parserResult - * @param mixed[] $queryComponents - * @psalm-param array $queryComponents + * {@inheritdoc} */ - public function __construct($query, $parserResult, array $queryComponents) - { + public function __construct( + Query $query, + ParserResult $parserResult, + array $queryComponents + ) { $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform(); $this->rsm = $parserResult->getResultSetMapping(); // Reset limit and offset - $this->firstResult = $query->getFirstResult(); + $this->firstResult = $query->getFirstResult() ?? 0; $this->maxResults = $query->getMaxResults(); $query->setFirstResult(0)->setMaxResults(null); @@ -152,27 +138,22 @@ private function rebuildOrderByForRowNumber(SelectStatement $AST): void $AST->orderByClause = null; } - /** - * {@inheritdoc} - */ - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $selectStatement): string { if ($this->platformSupportsRowNumber()) { - return $this->walkSelectStatementWithRowNumber($AST); + return $this->walkSelectStatementWithRowNumber($selectStatement); } - return $this->walkSelectStatementWithoutRowNumber($AST); + return $this->walkSelectStatementWithoutRowNumber($selectStatement); } /** * Walks down a SelectStatement AST node, wrapping it in a SELECT DISTINCT. * This method is for use with platforms which support ROW_NUMBER. * - * @return string - * * @throws RuntimeException */ - public function walkSelectStatementWithRowNumber(SelectStatement $AST) + public function walkSelectStatementWithRowNumber(SelectStatement $AST): string { $hasOrderBy = false; $outerOrderBy = ' ORDER BY dctrn_minrownum ASC'; @@ -224,13 +205,9 @@ public function walkSelectStatementWithRowNumber(SelectStatement $AST) * Walks down a SelectStatement AST node, wrapping it in a SELECT DISTINCT. * This method is for platforms which DO NOT support ROW_NUMBER. * - * @param bool $addMissingItemsFromOrderByToSelect - * - * @return string - * * @throws RuntimeException */ - public function walkSelectStatementWithoutRowNumber(SelectStatement $AST, $addMissingItemsFromOrderByToSelect = true) + public function walkSelectStatementWithoutRowNumber(SelectStatement $AST, bool $addMissingItemsFromOrderByToSelect = true): string { // We don't want to call this recursively! if ($AST->orderByClause instanceof OrderByClause && $addMissingItemsFromOrderByToSelect) { @@ -459,7 +436,7 @@ private function generateSqlAliasReplacements(): array * * @return list */ - public function getOrderByPathExpressions() + public function getOrderByPathExpressions(): array { return $this->orderByPathExpressions; } @@ -547,10 +524,7 @@ private function getSQLIdentifier(SelectStatement $AST): array return $sqlIdentifier; } - /** - * {@inheritdoc} - */ - public function walkPathExpression($pathExpr) + public function walkPathExpression(PathExpression $pathExpr): string { if (! $this->inSubSelect && ! $this->platformSupportsRowNumber() && ! in_array($pathExpr, $this->orderByPathExpressions, true)) { $this->orderByPathExpressions[] = $pathExpr; @@ -559,10 +533,7 @@ public function walkPathExpression($pathExpr) return parent::walkPathExpression($pathExpr); } - /** - * {@inheritdoc} - */ - public function walkSubSelect($subselect) + public function walkSubSelect(Subselect $subselect): string { $this->inSubSelect = true; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index e0531fddac5..4230e1d036f 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -30,20 +30,18 @@ class LimitSubqueryWalker extends TreeWalkerAdapter /** * Counter for generating unique order column aliases. - * - * @var int */ - private $_aliasCounter = 0; + private int $aliasCounter = 0; - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $selectStatement): void { // Get the root entity and alias from the AST fromClause - $from = $AST->fromClause->identificationVariableDeclarations; + $from = $selectStatement->fromClause->identificationVariableDeclarations; $fromRoot = reset($from); $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $this->getMetadataForDqlAlias($rootAlias); - $this->validate($AST); + $this->validate($selectStatement); $identifier = $rootClass->getSingleIdentifierFieldName(); if (isset($rootClass->associationMappings[$identifier])) { @@ -65,19 +63,19 @@ public function walkSelectStatement(SelectStatement $AST) $pathExpression->type = PathExpression::TYPE_STATE_FIELD; - $AST->selectClause->selectExpressions = [new SelectExpression($pathExpression, '_dctrn_id')]; - $AST->selectClause->isDistinct = true; + $selectStatement->selectClause->selectExpressions = [new SelectExpression($pathExpression, '_dctrn_id')]; + $selectStatement->selectClause->isDistinct = true; - if (! isset($AST->orderByClause)) { + if (! isset($selectStatement->orderByClause)) { return; } - $queryComponents = $this->_getQueryComponents(); - foreach ($AST->orderByClause->orderByItems as $item) { + $queryComponents = $this->getQueryComponents(); + foreach ($selectStatement->orderByClause->orderByItems as $item) { if ($item->expression instanceof PathExpression) { - $AST->selectClause->selectExpressions[] = new SelectExpression( + $selectStatement->selectClause->selectExpressions[] = new SelectExpression( $this->createSelectExpressionItem($item->expression), - '_dctrn_ord' . $this->_aliasCounter++ + '_dctrn_ord' . $this->aliasCounter++ ); continue; @@ -87,7 +85,7 @@ public function walkSelectStatement(SelectStatement $AST) $qComp = $queryComponents[$item->expression]; if (isset($qComp['resultVariable'])) { - $AST->selectClause->selectExpressions[] = new SelectExpression( + $selectStatement->selectClause->selectExpressions[] = new SelectExpression( $qComp['resultVariable'], $item->expression ); diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php index e3d12bff870..c537a640fec 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -47,10 +47,10 @@ class WhereInWalker extends TreeWalkerAdapter */ public const PAGINATOR_ID_ALIAS = 'dpid'; - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $selectStatement): void { // Get the root entity and alias from the AST fromClause - $from = $AST->fromClause->identificationVariableDeclarations; + $from = $selectStatement->fromClause->identificationVariableDeclarations; if (count($from) > 1) { throw new RuntimeException('Cannot count query which selects two FROM components, cannot make distinction'); @@ -94,27 +94,27 @@ public function walkSelectStatement(SelectStatement $AST) $conditionalPrimary = new ConditionalPrimary(); $conditionalPrimary->simpleConditionalExpression = $expression; - if ($AST->whereClause) { - if ($AST->whereClause->conditionalExpression instanceof ConditionalTerm) { - $AST->whereClause->conditionalExpression->conditionalFactors[] = $conditionalPrimary; - } elseif ($AST->whereClause->conditionalExpression instanceof ConditionalPrimary) { - $AST->whereClause->conditionalExpression = new ConditionalExpression( + if ($selectStatement->whereClause) { + if ($selectStatement->whereClause->conditionalExpression instanceof ConditionalTerm) { + $selectStatement->whereClause->conditionalExpression->conditionalFactors[] = $conditionalPrimary; + } elseif ($selectStatement->whereClause->conditionalExpression instanceof ConditionalPrimary) { + $selectStatement->whereClause->conditionalExpression = new ConditionalExpression( [ new ConditionalTerm( [ - $AST->whereClause->conditionalExpression, + $selectStatement->whereClause->conditionalExpression, $conditionalPrimary, ] ), ] ); } elseif ( - $AST->whereClause->conditionalExpression instanceof ConditionalExpression - || $AST->whereClause->conditionalExpression instanceof ConditionalFactor + $selectStatement->whereClause->conditionalExpression instanceof ConditionalExpression + || $selectStatement->whereClause->conditionalExpression instanceof ConditionalFactor ) { - $tmpPrimary = new ConditionalPrimary(); - $tmpPrimary->conditionalExpression = $AST->whereClause->conditionalExpression; - $AST->whereClause->conditionalExpression = new ConditionalTerm( + $tmpPrimary = new ConditionalPrimary(); + $tmpPrimary->conditionalExpression = $selectStatement->whereClause->conditionalExpression; + $selectStatement->whereClause->conditionalExpression = new ConditionalTerm( [ $tmpPrimary, $conditionalPrimary, @@ -122,7 +122,7 @@ public function walkSelectStatement(SelectStatement $AST) ); } } else { - $AST->whereClause = new WhereClause( + $selectStatement->whereClause = new WhereClause( new ConditionalExpression( [new ConditionalTerm([$conditionalPrimary])] ) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 95a2934ca7a..8ed696bfd54 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -270,21 +270,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - message: "#^Parameter \\#1 \\$simpleArithmeticExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkSimpleArithmeticExpression\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php - - - - message: "#^Parameter \\#1 \\$simpleArithmeticExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkSimpleArithmeticExpression\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php - - - - message: "#^Parameter \\#1 \\$simpleArithmeticExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkSimpleArithmeticExpression\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\SimpleArithmeticExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\AST\\\\IndexBy\\:\\:dispatch\\(\\) should return string but returns void\\.$#" count: 1 @@ -391,17 +376,17 @@ parameters: path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" - count: 1 + message: "#^Match arm is unreachable because previous comparison is always true\\.$#" + count: 2 path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkConditionalPrimary\\(\\) should return string but return statement is missing\\.$#" + message: "#^Parameter \\#1 \\$entity of static method Doctrine\\\\ORM\\\\OptimisticLockException\\:\\:lockFailed\\(\\) expects object, class\\-string\\ given\\.$#" count: 1 path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Parameter \\#1 \\$entity of static method Doctrine\\\\ORM\\\\OptimisticLockException\\:\\:lockFailed\\(\\) expects object, class\\-string\\ given\\.$#" + message: "#^Parameter \\#3 \\$condExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkJoinAssociationDeclaration\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalPrimary\\|null, Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalExpression\\|null given\\.$#" count: 1 path: lib/Doctrine/ORM/Query/SqlWalker.php @@ -410,16 +395,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/SqlWalker.php - - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerAdapter\\:\\:getExecutor\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\Exec\\\\AbstractSqlExecutor but returns null\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\TreeWalkerChain\\:\\:getExecutor\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\Exec\\\\AbstractSqlExecutor but returns null\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/TreeWalkerChain.php - - message: "#^Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:add\\(\\) expects array\\<'join'\\|int, array\\\\|string\\>\\|object\\|string, non\\-empty\\-array\\ given\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ea4bead608c..3c753ce1f91 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1341,9 +1341,6 @@ - - $this->stringPrimary - $stringPrimary @@ -1361,9 +1358,6 @@ - - $this->stringPrimary - $stringPrimary @@ -1447,9 +1441,6 @@ - - $this->stringPrimary - $stringPrimary @@ -2002,90 +1993,23 @@ - '' is_string($expression) - - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - string - - - $expr - - - $condExpr - $condTerm - $factor + + $join->conditionalExpression $selectedClass['class']->name - - string - - + + $expr $this->queryComponents[$expr]['token']['value'] $this->queryComponents[$factor]['token']['value'] $this->queryComponents[$term]['token']['value'] - - - $query - - - $aggExpression->pathExpression - $whereClause->conditionalExpression - - $AST->whereClause - $AST->whereClause - $AST->whereClause + $arithmeticExpr->simpleArithmeticExpression $arithmeticExpr->subselect $condExpr $identificationVariableDecl->rangeVariableDeclaration - $subselect->whereClause $targetClass->associationMappings @@ -2111,32 +2035,6 @@ $mapping['isOwningSide'] $owningAssoc['joinTable'] - - $whereClause !== null - ($factor->not ? 'NOT ' : '') . $this->walkConditionalPrimary($factor->conditionalPrimary) - - - - - getExecutor - - - null - - - - - getExecutor - - - $dqlAlias - - - null - - - $condPrimary - @@ -2238,27 +2136,19 @@ - - $query - $rootClass->associationMappings[$property]['joinColumns'] - - $query - strrpos($orderByItemString, ' ') $orderByClause->orderByItems - + $AST->orderByClause - $query->getFirstResult() - $query->getMaxResults() $orderByClause->orderByItems @@ -2279,14 +2169,14 @@ - $AST->whereClause->conditionalExpression instanceof ConditionalFactor - $AST->whereClause->conditionalExpression instanceof ConditionalPrimary + $selectStatement->whereClause->conditionalExpression instanceof ConditionalFactor + $selectStatement->whereClause->conditionalExpression instanceof ConditionalPrimary static function ($id) use ($connection, $type) { - $AST->whereClause->conditionalExpression + $selectStatement->whereClause->conditionalExpression diff --git a/tests/Doctrine/Tests/Mocks/NullSqlWalker.php b/tests/Doctrine/Tests/Mocks/NullSqlWalker.php index 21563583f6d..3e940e08e59 100644 --- a/tests/Doctrine/Tests/Mocks/NullSqlWalker.php +++ b/tests/Doctrine/Tests/Mocks/NullSqlWalker.php @@ -5,33 +5,31 @@ namespace Doctrine\Tests\Mocks; use Doctrine\DBAL\Connection; -use Doctrine\ORM\Query\AST\DeleteStatement; -use Doctrine\ORM\Query\AST\SelectStatement; -use Doctrine\ORM\Query\AST\UpdateStatement; +use Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; use Doctrine\ORM\Query\SqlWalker; /** * SqlWalker implementation that does not produce SQL. */ -class NullSqlWalker extends SqlWalker +final class NullSqlWalker extends SqlWalker { - public function walkSelectStatement(SelectStatement $AST): string + public function walkSelectStatement(AST\SelectStatement $selectStatement): string { return ''; } - public function walkUpdateStatement(UpdateStatement $AST): string + public function walkUpdateStatement(AST\UpdateStatement $updateStatement): string { return ''; } - public function walkDeleteStatement(DeleteStatement $AST): string + public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): string { return ''; } - public function getExecutor($AST): AbstractSqlExecutor + public function getExecutor(AST\SelectStatement|AST\UpdateStatement|AST\DeleteStatement $statement): AbstractSqlExecutor { return new class extends AbstractSqlExecutor { public function execute(Connection $conn, array $params, array $types): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php index 32e91ed8f89..1219e4e6c79 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php @@ -84,12 +84,12 @@ public function testDqlTreeWalkerReordering(): void class DisableFetchJoinTreeWalker extends TreeWalkerAdapter { - public function walkSelectStatement(SelectStatement $AST): void + public function walkSelectStatement(SelectStatement $selectStatement): void { - foreach ($AST->selectClause->selectExpressions as $key => $selectExpr) { + foreach ($selectStatement->selectClause->selectExpressions as $key => $selectExpr) { assert($selectExpr instanceof SelectExpression); if ($selectExpr->expression === 'c') { - unset($AST->selectClause->selectExpressions[$key]); + unset($selectStatement->selectClause->selectExpressions[$key]); break; } } diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index 3249ce27dd8..733cb23da00 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -120,11 +120,13 @@ public function testSupportsSeveralHintsQueries(): void class AddUnknownQueryComponentWalker extends SqlWalker { - public function walkSelectStatement(SelectStatement $selectStatement): void + public function walkSelectStatement(SelectStatement $selectStatement): string { - parent::walkSelectStatement($selectStatement); + $sql = parent::walkSelectStatement($selectStatement); $this->setQueryComponent('x', []); + + return $sql; } } diff --git a/tests/Doctrine/Tests/ORM/Query/TreeWalkerAdapterTest.php b/tests/Doctrine/Tests/ORM/Query/TreeWalkerAdapterTest.php deleted file mode 100644 index d0915bde9b6..00000000000 --- a/tests/Doctrine/Tests/ORM/Query/TreeWalkerAdapterTest.php +++ /dev/null @@ -1,65 +0,0 @@ -createMock(AbstractQuery::class), - $this->createMock(ParserResult::class), - [] - ) extends TreeWalkerAdapter{ - }; - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9551'); - $walker->setQueryComponent('foo', [ - 'metadata' => new ClassMetadata(stdClass::class), - 'parent' => null, - 'relation' => null, - 'map' => null, - 'nestingLevel' => 0, - 'token' => ['value' => '', 'type' => Lexer::T_NONE, 'position' => 0], - ]); - } - - public function testSetQueryComponent(): void - { - $walker = new class ( - $this->createMock(AbstractQuery::class), - $this->createMock(ParserResult::class), - [] - ) extends TreeWalkerAdapter{ - public function doSetQueryComponent(): void - { - $this->setQueryComponent('foo', [ - 'metadata' => new ClassMetadata(stdClass::class), - 'parent' => null, - 'relation' => null, - 'map' => null, - 'nestingLevel' => 0, - 'token' => ['value' => '', 'type' => Lexer::T_NONE, 'position' => 0], - ]); - } - }; - - $this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9551'); - $walker->doSetQueryComponent(); - - self::assertArrayHasKey('foo', $walker->getQueryComponents()); - } -} From 35afdb1c840de1feedc60f5acda307ead04c5796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 28 Jul 2022 16:16:09 +0200 Subject: [PATCH 141/475] Migrate UnitOfWork to PHP 8 --- lib/Doctrine/ORM/UnitOfWork.php | 119 ++++++++++++-------------------- 1 file changed, 46 insertions(+), 73 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 2cff0b45469..0d06fb7c811 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Cache\Persister\CachedPersister; use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\ORM\Event\ListenersInvoker; +use Doctrine\ORM\Event\OnClearEventArgs; use Doctrine\ORM\Event\OnFlushEventArgs; use Doctrine\ORM\Event\PostFlushEventArgs; use Doctrine\ORM\Event\PreFlushEventArgs; @@ -56,7 +57,6 @@ use function array_values; use function count; use function current; -use function get_class; use function get_debug_type; use function implode; use function in_array; @@ -376,7 +376,7 @@ public function commit(): void // Deferred explicit tracked collections can be removed only when owning relation was persisted $owner = $collectionToDelete->getOwner(); - if ($this->em->getClassMetadata(get_class($owner))->isChangeTrackingDeferredImplicit() || $this->isScheduledForDirtyCheck($owner)) { + if ($this->em->getClassMetadata($owner::class)->isChangeTrackingDeferredImplicit() || $this->isScheduledForDirtyCheck($owner)) { $this->getCollectionPersister($collectionToDelete->getMapping())->delete($collectionToDelete); } } @@ -467,7 +467,7 @@ private function postCommitCleanup(): void private function computeScheduleInsertsChangeSets(): void { foreach ($this->entityInsertions as $entity) { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $this->computeChangeSet($class, $entity); } @@ -482,7 +482,7 @@ private function executeExtraUpdates(): void [$entity, $changeset] = $update; $this->entityChangeSets[$oid] = $changeset; - $this->getEntityPersister(get_class($entity))->update($entity); + $this->getEntityPersister($entity::class)->update($entity); } $this->extraUpdates = []; @@ -549,7 +549,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void } if (! $class->isInheritanceTypeNone()) { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); } $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preFlush) & ~ListenersInvoker::INVOKE_MANAGER; @@ -748,20 +748,11 @@ public function computeChangeSets(): void continue; } - // If change tracking is explicit or happens through notification, then only compute - // changes on entities of that type that are explicitly marked for synchronization. - switch (true) { - case $class->isChangeTrackingDeferredImplicit(): - $entitiesToProcess = $entities; - break; - - case isset($this->scheduledForSynchronization[$className]): - $entitiesToProcess = $this->scheduledForSynchronization[$className]; - break; - - default: - $entitiesToProcess = []; - } + $entitiesToProcess = match (true) { + $class->isChangeTrackingDeferredImplicit() => $entities, + isset($this->scheduledForSynchronization[$className]) => $this->scheduledForSynchronization[$className], + default => [], + }; foreach ($entitiesToProcess as $entity) { // Ignore uninitialized proxy objects @@ -948,7 +939,7 @@ public function recomputeSingleEntityChangeSet(ClassMetadata $class, object $ent } if (! $class->isInheritanceTypeNone()) { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); } $actualData = []; @@ -1003,7 +994,7 @@ private function executeInserts(ClassMetadata $class): void $insertionsForClass = []; foreach ($this->entityInsertions as $oid => $entity) { - if ($this->em->getClassMetadata(get_class($entity))->name !== $className) { + if ($this->em->getClassMetadata($entity::class)->name !== $className) { continue; } @@ -1095,7 +1086,7 @@ private function executeUpdates(ClassMetadata $class): void $postUpdateInvoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postUpdate); foreach ($this->entityUpdates as $oid => $entity) { - if ($this->em->getClassMetadata(get_class($entity))->name !== $className) { + if ($this->em->getClassMetadata($entity::class)->name !== $className) { continue; } @@ -1127,7 +1118,7 @@ private function executeDeletions(ClassMetadata $class): void $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postRemove); foreach ($this->entityDeletions as $oid => $entity) { - if ($this->em->getClassMetadata(get_class($entity))->name !== $className) { + if ($this->em->getClassMetadata($entity::class)->name !== $className) { continue; } @@ -1169,8 +1160,8 @@ private function getCommitOrder(): array // are not yet available. $newNodes = []; - foreach (array_merge($this->entityInsertions, $this->entityUpdates, $this->entityDeletions) as $entity) { - $class = $this->em->getClassMetadata(get_class($entity)); + foreach ([...$this->entityInsertions, ...$this->entityUpdates, ...$this->entityDeletions] as $entity) { + $class = $this->em->getClassMetadata($entity::class); if ($calc->hasNode($class->name)) { continue; @@ -1330,7 +1321,7 @@ public function isScheduledForUpdate(object $entity): bool */ public function isScheduledForDirtyCheck(object $entity): bool { - $rootEntityName = $this->em->getClassMetadata(get_class($entity))->rootEntityName; + $rootEntityName = $this->em->getClassMetadata($entity::class)->rootEntityName; return isset($this->scheduledForSynchronization[$rootEntityName][spl_object_id($entity)]); } @@ -1403,7 +1394,7 @@ public function isEntityScheduled(object $entity): bool */ public function addToIdentityMap(object $entity): bool { - $classMetadata = $this->em->getClassMetadata(get_class($entity)); + $classMetadata = $this->em->getClassMetadata($entity::class); $identifier = $this->entityIdentifiers[spl_object_id($entity)]; if (empty($identifier) || in_array(null, $identifier, true)) { @@ -1449,7 +1440,7 @@ public function getEntityState(object $entity, ?int $assume = null): int // Note that you can not remember the NEW or DETACHED state in _entityStates since // the UoW does not hold references to such objects and the object hash can be reused. // More generally because the state may "change" between NEW/DETACHED without the UoW being aware of it. - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $id = $class->getIdentifierValues($entity); if (! $id) { @@ -1515,7 +1506,7 @@ public function getEntityState(object $entity, ?int $assume = null): int public function removeFromIdentityMap(object $entity): bool { $oid = spl_object_id($entity); - $classMetadata = $this->em->getClassMetadata(get_class($entity)); + $classMetadata = $this->em->getClassMetadata($entity::class); $idHash = implode(' ', $this->entityIdentifiers[$oid]); if ($idHash === '') { @@ -1541,7 +1532,7 @@ public function removeFromIdentityMap(object $entity): bool * * @ignore */ - public function getByIdHash(string $idHash, string $rootClassName): object + public function getByIdHash(string $idHash, string $rootClassName): ?object { return $this->identityMap[$rootClassName][$idHash]; } @@ -1575,7 +1566,7 @@ public function isInIdentityMap(object $entity): bool return false; } - $classMetadata = $this->em->getClassMetadata(get_class($entity)); + $classMetadata = $this->em->getClassMetadata($entity::class); $idHash = implode(' ', $this->entityIdentifiers[$oid]); return isset($this->identityMap[$classMetadata->rootEntityName][$idHash]); @@ -1612,7 +1603,7 @@ private function doPersist(object $entity, array &$visited): void $visited[$oid] = $entity; // Mark visited - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); // We assume NEW, so DETACHED entities result in an exception on flush (constraint violation). // If we would detect DETACHED here we would throw an exception anyway with the same @@ -1696,7 +1687,7 @@ private function doRemove(object $entity, array &$visited): void // can cause problems when a lazy proxy has to be initialized for the cascade operation. $this->cascadeRemove($entity, $visited); - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $entityState = $this->getEntityState($entity); switch ($entityState) { @@ -1812,7 +1803,7 @@ private function doRefresh(object $entity, array &$visited): void $visited[$oid] = $entity; // mark visited - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); if ($this->getEntityState($entity) !== self::STATE_MANAGED) { throw ORMInvalidArgumentException::entityNotManaged($entity); @@ -1833,13 +1824,11 @@ private function doRefresh(object $entity, array &$visited): void */ private function cascadeRefresh(object $entity, array &$visited): void { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $associationMappings = array_filter( $class->associationMappings, - static function (array $assoc) { - return $assoc['isCascadeRefresh']; - } + static fn (array $assoc) => $assoc['isCascadeRefresh'] ); foreach ($associationMappings as $assoc) { @@ -1876,13 +1865,11 @@ static function (array $assoc) { */ private function cascadeDetach(object $entity, array &$visited): void { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $associationMappings = array_filter( $class->associationMappings, - static function (array $assoc) { - return $assoc['isCascadeDetach']; - } + static fn (array $assoc) => $assoc['isCascadeDetach'] ); foreach ($associationMappings as $assoc) { @@ -1919,13 +1906,11 @@ static function (array $assoc) { */ private function cascadePersist(object $entity, array &$visited): void { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $associationMappings = array_filter( $class->associationMappings, - static function (array $assoc) { - return $assoc['isCascadePersist']; - } + static fn (array $assoc) => $assoc['isCascadePersist'] ); foreach ($associationMappings as $assoc) { @@ -1978,13 +1963,11 @@ static function (array $assoc) { */ private function cascadeRemove(object $entity, array &$visited): void { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $associationMappings = array_filter( $class->associationMappings, - static function (array $assoc) { - return $assoc['isCascadeRemove']; - } + static fn (array $assoc) => $assoc['isCascadeRemove'] ); $entitiesToCascade = []; @@ -2036,7 +2019,7 @@ public function lock(object $entity, int $lockMode, $lockVersion = null): void throw ORMInvalidArgumentException::entityNotManaged($entity); } - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); switch (true) { case $lockMode === LockMode::OPTIMISTIC: @@ -2113,7 +2096,7 @@ public function clear(): void $this->orphanRemovals = []; if ($this->evm->hasListeners(Events::onClear)) { - $this->evm->dispatchEvent(Events::onClear, new Event\OnClearEventArgs($this->em)); + $this->evm->dispatchEvent(Events::onClear, new OnClearEventArgs($this->em)); } } @@ -2576,7 +2559,7 @@ public function getEntityIdentifier(object $entity): array */ public function getSingleIdentifierValue(object $entity): mixed { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); if ($class->isIdentifierComposite) { throw ORMInvalidArgumentException::invalidCompositeIdentifier(); @@ -2614,7 +2597,7 @@ public function tryGetById(mixed $id, string $rootClassName): object|false */ public function scheduleForDirtyCheck(object $entity): void { - $rootClassName = $this->em->getClassMetadata(get_class($entity))->rootEntityName; + $rootClassName = $this->em->getClassMetadata($entity::class)->rootEntityName; $this->scheduledForSynchronization[$rootClassName][spl_object_id($entity)] = $entity; } @@ -2649,22 +2632,12 @@ public function getEntityPersister(string $entityName): EntityPersister $class = $this->em->getClassMetadata($entityName); - switch (true) { - case $class->isInheritanceTypeNone(): - $persister = new BasicEntityPersister($this->em, $class); - break; - - case $class->isInheritanceTypeSingleTable(): - $persister = new SingleTablePersister($this->em, $class); - break; - - case $class->isInheritanceTypeJoined(): - $persister = new JoinedSubclassPersister($this->em, $class); - break; - - default: - throw new RuntimeException('No persister found for entity.'); - } + $persister = match (true) { + $class->isInheritanceTypeNone() => new BasicEntityPersister($this->em, $class), + $class->isInheritanceTypeSingleTable() => new SingleTablePersister($this->em, $class), + $class->isInheritanceTypeJoined() => new JoinedSubclassPersister($this->em, $class), + default => throw new RuntimeException('No persister found for entity.'), + }; if ($this->hasCache && $class->cache !== null) { $persister = $this->em->getConfiguration() @@ -2741,7 +2714,7 @@ public function registerManaged(object $entity, array $id, array $data): void public function propertyChanged(object $sender, string $propertyName, mixed $oldValue, mixed $newValue): void { $oid = spl_object_id($sender); - $class = $this->em->getClassMetadata(get_class($sender)); + $class = $this->em->getClassMetadata($sender::class); $isAssocField = isset($class->associationMappings[$propertyName]); @@ -2917,9 +2890,9 @@ private function isIdentifierEquals(object $entity1, object $entity2): bool return true; } - $class = $this->em->getClassMetadata(get_class($entity1)); + $class = $this->em->getClassMetadata($entity1::class); - if ($class !== $this->em->getClassMetadata(get_class($entity2))) { + if ($class !== $this->em->getClassMetadata($entity2::class)) { return false; } From 0c2d1df4249238ba2b9b977cf219269a27803260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 28 Jul 2022 17:06:29 +0200 Subject: [PATCH 142/475] Migrate Configuration class to PHP 8 again --- lib/Doctrine/ORM/Configuration.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index fd904a31900..8371e9e10d1 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -366,10 +366,8 @@ public function getClassMetadataFactoryName(): string * * @param string $className The class name of the filter. * @psalm-param class-string $className - * - * @return void */ - public function addFilter(string $name, string $className) + public function addFilter(string $name, string $className): void { $this->_attributes['filters'][$name] = $className; } From ef825677300f39baa7440682f0321e934e0bf42f Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 3 Aug 2022 17:05:42 +0200 Subject: [PATCH 143/475] Fix DBAL 4 compatibility (#9950) --- lib/Doctrine/ORM/AbstractQuery.php | 13 +- .../Entity/AbstractEntityPersister.php | 81 ++++++++--- .../ORM/Decorator/EntityManagerDecorator.php | 5 +- lib/Doctrine/ORM/EntityManager.php | 6 +- lib/Doctrine/ORM/EntityManagerInterface.php | 18 +-- lib/Doctrine/ORM/EntityRepository.php | 8 +- .../Collection/ManyToManyPersister.php | 10 +- .../Entity/BasicEntityPersister.php | 136 +++++++++++------- .../ORM/Persisters/Entity/EntityPersister.php | 88 ++++++++---- .../Entity/JoinedSubclassPersister.php | 4 +- lib/Doctrine/ORM/Query.php | 2 +- .../ORM/Query/AST/Functions/TrimFunction.php | 2 +- .../ORM/Query/ParameterTypeInferer.php | 2 +- lib/Doctrine/ORM/UnitOfWork.php | 2 +- phpstan.neon | 10 ++ psalm-baseline.xml | 9 +- psalm.xml | 6 + .../Performance/Mock/NonLoadingPersister.php | 3 +- .../Mock/NonProxyLoadingEntityManager.php | 5 +- .../Tests/Mocks/CompatibilityType.php | 39 +++++ .../ORM/Functional/Ticket/GH9335Test.php | 5 +- .../ORM/Query/ParameterTypeInfererTest.php | 2 +- 22 files changed, 316 insertions(+), 140 deletions(-) create mode 100644 tests/Doctrine/Tests/Mocks/CompatibilityType.php diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index efb77284d38..102190b0abd 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -9,6 +9,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Cache\QueryCacheProfile; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Result; use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\QueryCacheKey; @@ -327,15 +328,15 @@ public function setParameters(ArrayCollection|array $parameters): static /** * Sets a query parameter. * - * @param string|int $key The parameter position or name. - * @param mixed $value The parameter value. - * @param string|int|null $type The parameter type. If specified, the given value will be run through - * the type conversion of this type. This is usually not needed for - * strings and numeric types. + * @param string|int $key The parameter position or name. + * @param mixed $value The parameter value. + * @param ParameterType|string|int|null $type The parameter type. If specified, the given value will be run through + * the type conversion of this type. This is usually not needed for + * strings and numeric types. * * @return $this */ - public function setParameter(string|int $key, mixed $value, string|int|null $type = null): static + public function setParameter(string|int $key, mixed $value, ParameterType|string|int|null $type = null): static { $existingParameter = $this->getParameter($key); diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index ecc41b50fbc..64ffb368622 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Util\ClassUtils; +use Doctrine\DBAL\LockMode; use Doctrine\ORM\Cache; use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\EntityCacheKey; @@ -83,8 +84,14 @@ public function getInserts(): array return $this->persister->getInserts(); } - public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string - { + public function getSelectSQL( + array|Criteria $criteria, + ?array $assoc = null, + LockMode|int|null $lockMode = null, + ?int $limit = null, + ?int $offset = null, + ?array $orderBy = null + ): string { return $this->persister->getSelectSQL($criteria, $assoc, $lockMode, $limit, $offset, $orderBy); } @@ -103,8 +110,12 @@ public function getResultSetMapping(): ResultSetMapping return $this->persister->getResultSetMapping(); } - public function getSelectConditionStatementSQL(string $field, mixed $value, ?array $assoc = null, ?string $comparison = null): string - { + public function getSelectConditionStatementSQL( + string $field, + mixed $value, + ?array $assoc = null, + ?string $comparison = null + ): string { return $this->persister->getSelectConditionStatementSQL($field, $value, $assoc, $comparison); } @@ -191,8 +202,13 @@ private function storeJoinedAssociations(object $entity): void * @param string[]|Criteria $criteria * @param string[] $orderBy */ - protected function getHash(string $query, array|Criteria $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): string - { + protected function getHash( + string $query, + array|Criteria $criteria, + ?array $orderBy = null, + ?int $limit = null, + ?int $offset = null + ): string { [$params] = $criteria instanceof Criteria ? $this->persister->expandCriteriaParameters($criteria) : $this->persister->expandParameters($criteria); @@ -224,16 +240,24 @@ public function getClassMetadata(): ClassMetadata /** * {@inheritdoc} */ - public function getManyToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array - { + public function getManyToManyCollection( + array $assoc, + object $sourceEntity, + ?int $offset = null, + ?int $limit = null + ): array { return $this->persister->getManyToManyCollection($assoc, $sourceEntity, $offset, $limit); } /** * {@inheritdoc} */ - public function getOneToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array - { + public function getOneToManyCollection( + array $assoc, + object $sourceEntity, + ?int $offset = null, + ?int $limit = null + ): array { return $this->persister->getOneToManyCollection($assoc, $sourceEntity, $offset, $limit); } @@ -255,8 +279,15 @@ public function executeInserts(): array /** * {@inheritdoc} */ - public function load(array $criteria, ?object $entity = null, ?array $assoc = null, array $hints = [], ?int $lockMode = null, ?int $limit = null, ?array $orderBy = null): ?object - { + public function load( + array $criteria, + ?object $entity = null, + ?array $assoc = null, + array $hints = [], + LockMode|int|null $lockMode = null, + ?int $limit = null, + ?array $orderBy = null + ): ?object { if ($entity !== null || $assoc !== null || $hints !== [] || $lockMode !== null) { return $this->persister->load($criteria, $entity, $assoc, $hints, $lockMode, $limit, $orderBy); } @@ -295,8 +326,12 @@ public function load(array $criteria, ?object $entity = null, ?array $assoc = nu /** * {@inheritdoc} */ - public function loadAll(array $criteria = [], ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array - { + public function loadAll( + array $criteria = [], + ?array $orderBy = null, + ?int $limit = null, + ?int $offset = null + ): array { $query = $this->persister->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy); $hash = $this->getHash($query, $criteria); $rsm = $this->getResultSetMapping(); @@ -419,8 +454,11 @@ public function loadCriteria(Criteria $criteria): array /** * {@inheritdoc} */ - public function loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): array - { + public function loadManyToManyCollection( + array $assoc, + object $sourceEntity, + PersistentCollection $collection + ): array { $persister = $this->uow->getCollectionPersister($assoc); $hasCache = ($persister instanceof CachedPersister); @@ -450,8 +488,11 @@ public function loadManyToManyCollection(array $assoc, object $sourceEntity, Per /** * {@inheritdoc} */ - public function loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): mixed - { + public function loadOneToManyCollection( + array $assoc, + object $sourceEntity, + PersistentCollection $collection + ): mixed { $persister = $this->uow->getCollectionPersister($assoc); $hasCache = ($persister instanceof CachedPersister); @@ -489,7 +530,7 @@ public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $id /** * {@inheritdoc} */ - public function lock(array $criteria, int $lockMode): void + public function lock(array $criteria, LockMode|int $lockMode): void { $this->persister->lock($criteria, $lockMode); } @@ -497,7 +538,7 @@ public function lock(array $criteria, int $lockMode): void /** * {@inheritdoc} */ - public function refresh(array $id, object $entity, ?int $lockMode = null): void + public function refresh(array $id, object $entity, LockMode|int|null $lockMode = null): void { $this->persister->refresh($id, $entity, $lockMode); } diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index 3687505bb1c..d324429df4a 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -6,6 +6,7 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\LockMode; use Doctrine\ORM\Cache; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; @@ -119,12 +120,12 @@ public function close(): void /** * {@inheritdoc} */ - public function lock(object $entity, int $lockMode, $lockVersion = null): void + public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void { $this->wrapped->lock($entity, $lockMode, $lockVersion); } - public function find(string $className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object + public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object { return $this->wrapped->find($className, $id, $lockMode, $lockVersion); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 2f84fb31b58..122b8d92851 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -270,7 +270,7 @@ public function flush(): void /** * {@inheritdoc} */ - public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object + public function find($className, mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object { $class = $this->metadataFactory->getMetadataFor(ltrim($className, '\\')); @@ -520,7 +520,7 @@ public function detach(object $object): void /** * {@inheritDoc} */ - public function lock(object $entity, int $lockMode, $lockVersion = null): void + public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void { $this->unitOfWork->lock($entity, $lockMode, $lockVersion); } @@ -689,7 +689,7 @@ public function hasFilters(): bool * @throws OptimisticLockException * @throws TransactionRequiredException */ - private function checkLockRequirements(int $lockMode, ClassMetadata $class): void + private function checkLockRequirements(LockMode|int $lockMode, ClassMetadata $class): void { switch ($lockMode) { case LockMode::OPTIMISTIC: diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index 2d4383b6553..46d6bc87ceb 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -110,13 +110,13 @@ public function createQueryBuilder(): QueryBuilder; /** * Finds an Entity by its identifier. * - * @param string $className The class name of the entity to find. - * @param mixed $id The identity of the entity to find. - * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants - * or NULL if no specific lock mode should be used - * during the search. - * @param int|null $lockVersion The version of the entity to find when using - * optimistic locking. + * @param string $className The class name of the entity to find. + * @param mixed $id The identity of the entity to find. + * @param LockMode|int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * during the search. + * @param int|null $lockVersion The version of the entity to find when using + * optimistic locking. * @psalm-param class-string $className * @psalm-param LockMode::*|null $lockMode * @@ -130,7 +130,7 @@ public function createQueryBuilder(): QueryBuilder; * * @template T of object */ - public function find(string $className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object; + public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object; /** * Gets a reference to the entity identified by the given type and identifier @@ -189,7 +189,7 @@ public function close(): void; * @throws OptimisticLockException * @throws PessimisticLockException */ - public function lock(object $entity, int $lockMode, $lockVersion = null): void; + public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void; /** * Gets the EventManager used by the EntityManager. diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 3335fc0ccf2..42c0ab7d08d 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -75,15 +75,15 @@ public function createResultSetMappingBuilder(string $alias): ResultSetMappingBu /** * Finds an entity by its primary key / identifier. * - * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants - * or NULL if no specific lock mode should be used - * during the search. + * @param LockMode|int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * during the search. * @psalm-param LockMode::*|null $lockMode * * @return object|null The entity instance or NULL if the entity can not be found. * @psalm-return ?T */ - public function find(mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object + public function find(mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object { return $this->em->find($this->entityName, $id, $lockMode, $lockVersion); } diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 43acaccce84..7700fde3ac2 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -7,6 +7,7 @@ use BadMethodCallException; use Doctrine\Common\Collections\Criteria; use Doctrine\DBAL\Exception as DBALException; +use Doctrine\DBAL\LockMode; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\SqlValueVisitor; @@ -86,7 +87,14 @@ public function get(PersistentCollection $collection, mixed $index): mixed ? $mapping['inversedBy'] : $mapping['mappedBy']; - return $persister->load([$mappedKey => $collection->getOwner(), $mapping['indexBy'] => $index], null, $mapping, [], 0, 1); + return $persister->load( + [$mappedKey => $collection->getOwner(), $mapping['indexBy'] => $index], + null, + $mapping, + [], + LockMode::NONE, + 1 + ); } public function count(PersistentCollection $collection): int diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 9a3de3a110c..312d85e6fad 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -10,6 +10,7 @@ use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Result; use Doctrine\DBAL\Types\Type; @@ -329,8 +330,8 @@ protected function fetchVersionAndNotUpsertableValues(ClassMetadata $versionedCl /** * @param mixed[] $id * - * @return int[]|null[]|string[] - * @psalm-return list + * @return list + * @psalm-return list */ private function extractIdentifierTypes(array $id, ClassMetadata $versionedClass): array { @@ -689,8 +690,15 @@ public function getOwningTable(string $fieldName): string /** * {@inheritdoc} */ - public function load(array $criteria, ?object $entity = null, ?array $assoc = null, array $hints = [], ?int $lockMode = null, ?int $limit = null, ?array $orderBy = null): ?object - { + public function load( + array $criteria, + ?object $entity = null, + ?array $assoc = null, + array $hints = [], + LockMode|int|null $lockMode = null, + ?int $limit = null, + ?array $orderBy = null + ): ?object { $this->switchPersisterContext(null, $limit); $sql = $this->getSelectSQL($criteria, $assoc, $lockMode, $limit, null, $orderBy); @@ -779,7 +787,7 @@ public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $id /** * {@inheritdoc} */ - public function refresh(array $id, object $entity, ?int $lockMode = null): void + public function refresh(array $id, object $entity, LockMode|int|null $lockMode = null): void { $sql = $this->getSelectSQL($id, null, $lockMode); [$params, $types] = $this->expandParameters($id); @@ -852,8 +860,12 @@ public function expandCriteriaParameters(Criteria $criteria): array /** * {@inheritdoc} */ - public function loadAll(array $criteria = [], ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array - { + public function loadAll( + array $criteria = [], + ?array $orderBy = null, + ?int $limit = null, + ?int $offset = null + ): array { $this->switchPersisterContext($offset, $limit); $sql = $this->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy); @@ -868,8 +880,12 @@ public function loadAll(array $criteria = [], ?array $orderBy = null, ?int $limi /** * {@inheritdoc} */ - public function getManyToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array - { + public function getManyToManyCollection( + array $assoc, + object $sourceEntity, + ?int $offset = null, + ?int $limit = null + ): array { $this->switchPersisterContext($offset, $limit); $stmt = $this->getManyToManyStatement($assoc, $sourceEntity, $offset, $limit); @@ -1006,11 +1022,16 @@ private function getManyToManyStatement( return $this->conn->executeQuery($sql, $params, $types); } - public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string - { + public function getSelectSQL( + array|Criteria $criteria, + ?array $assoc = null, + LockMode|int|null $lockMode = null, + ?int $limit = null, + ?int $offset = null, + ?array $orderBy = null + ): string { $this->switchPersisterContext($offset, $limit); - $lockSql = ''; $joinSql = ''; $orderBySql = ''; @@ -1030,15 +1051,11 @@ public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?in ? $this->getSelectConditionCriteriaSQL($criteria) : $this->getSelectConditionSQL($criteria, $assoc); - switch ($lockMode) { - case LockMode::PESSIMISTIC_READ: - $lockSql = ' ' . $this->platform->getReadLockSQL(); - break; - - case LockMode::PESSIMISTIC_WRITE: - $lockSql = ' ' . $this->platform->getWriteLockSQL(); - break; - } + $lockSql = match ($lockMode) { + LockMode::PESSIMISTIC_READ => ' ' . $this->platform->getReadLockSQL(), + LockMode::PESSIMISTIC_WRITE => ' ' . $this->platform->getWriteLockSQL(), + default => '', + }; $columnList = $this->getSelectColumnsSQL(); $tableAlias = $this->getSQLTableAlias($this->class->name); @@ -1268,8 +1285,12 @@ protected function getSelectColumnsSQL(): string * * @param mixed[] $assoc */ - protected function getSelectColumnAssociationSQL(string $field, array $assoc, ClassMetadata $class, string $alias = 'r'): string - { + protected function getSelectColumnAssociationSQL( + string $field, + array $assoc, + ClassMetadata $class, + string $alias = 'r' + ): string { if (! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) { return ''; } @@ -1458,20 +1479,15 @@ protected function getSQLTableAlias(string $className, string $assocName = ''): /** * {@inheritdoc} */ - public function lock(array $criteria, int $lockMode): void + public function lock(array $criteria, LockMode|int $lockMode): void { - $lockSql = ''; $conditionSql = $this->getSelectConditionSQL($criteria); - switch ($lockMode) { - case LockMode::PESSIMISTIC_READ: - $lockSql = $this->platform->getReadLockSQL(); - - break; - case LockMode::PESSIMISTIC_WRITE: - $lockSql = $this->platform->getWriteLockSQL(); - break; - } + $lockSql = match ($lockMode) { + LockMode::PESSIMISTIC_READ => $this->platform->getReadLockSQL(), + LockMode::PESSIMISTIC_WRITE => $this->platform->getWriteLockSQL(), + default => '', + }; $lock = $this->getLockTablesSql($lockMode); $where = ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' '; @@ -1490,7 +1506,7 @@ public function lock(array $criteria, int $lockMode): void * * @psalm-param LockMode::* $lockMode */ - protected function getLockTablesSql(int $lockMode): string + protected function getLockTablesSql(LockMode|int $lockMode): string { return $this->platform->appendLockHint( 'FROM ' @@ -1516,8 +1532,12 @@ protected function getSelectConditionCriteriaSQL(Criteria $criteria): string return $visitor->dispatch($expression); } - public function getSelectConditionStatementSQL(string $field, mixed $value, ?array $assoc = null, ?string $comparison = null): string - { + public function getSelectConditionStatementSQL( + string $field, + mixed $value, + ?array $assoc = null, + ?string $comparison = null + ): string { $selectedColumns = []; $columns = $this->getSelectConditionStatementColumnSQL($field, $assoc); @@ -1675,8 +1695,12 @@ protected function getSelectConditionSQL(array $criteria, ?array $assoc = null): /** * {@inheritdoc} */ - public function getOneToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array - { + public function getOneToManyCollection( + array $assoc, + object $sourceEntity, + ?int $offset = null, + ?int $limit = null + ): array { $this->switchPersisterContext($offset, $limit); $stmt = $this->getOneToManyStatement($assoc, $sourceEntity, $offset, $limit); @@ -1687,8 +1711,11 @@ public function getOneToManyCollection(array $assoc, object $sourceEntity, ?int /** * {@inheritdoc} */ - public function loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): mixed - { + public function loadOneToManyCollection( + array $assoc, + object $sourceEntity, + PersistentCollection $collection + ): mixed { $stmt = $this->getOneToManyStatement($assoc, $sourceEntity); return $this->loadCollectionFromStatement($assoc, $stmt, $collection); @@ -1780,7 +1807,7 @@ public function expandParameters(array $criteria): array * - class to which the field belongs to * * @return mixed[][] - * @psalm-return array{0: array, 1: list} + * @psalm-return array{0: array, 1: list} */ private function expandToManyParameters(array $criteria): array { @@ -1802,8 +1829,8 @@ private function expandToManyParameters(array $criteria): array /** * Infers field types to be used by parameter type casting. * - * @return int[]|null[]|string[] - * @psalm-return list + * @return list + * @psalm-return list * * @throws QueryException */ @@ -1836,21 +1863,30 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar break; default: - $types[] = null; + $types[] = ParameterType::STRING; break; } if (is_array($value)) { - return array_map(static function ($type) { - $type = Type::getType($type); - - return $type->getBindingType() + Connection::ARRAY_PARAM_OFFSET; - }, $types); + return array_map([$this, 'getArrayBindingType'], $types); } return $types; } + private function getArrayBindingType(ParameterType|int|string $type): int + { + if (! $type instanceof ParameterType) { + $type = Type::getType((string) $type)->getBindingType(); + } + + return match ($type) { + ParameterType::STRING => Connection::PARAM_STR_ARRAY, + ParameterType::INTEGER => Connection::PARAM_INT_ARRAY, + ParameterType::ASCII => Connection::PARAM_ASCII_STR_ARRAY, + }; + } + /** * Retrieves the parameters that identifies a value. * diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index ae5ba7f30cf..6885ea0149d 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\ParameterType; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\PersistentCollection; @@ -47,7 +48,14 @@ public function getInsertSQL(): string; * @param mixed[]|null $orderBy * @psalm-param LockMode::*|null $lockMode */ - public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string; + public function getSelectSQL( + array|Criteria $criteria, + ?array $assoc = null, + LockMode|int|null $lockMode = null, + ?int $limit = null, + ?int $offset = null, + ?array $orderBy = null + ): string; /** * Get the COUNT SQL to count entities (optionally based on a criteria) @@ -61,14 +69,14 @@ public function getCountSQL(array|Criteria $criteria = []): string; * * @param string[] $criteria * - * @psalm-return array{list, list} + * @psalm-return array{list, list} */ public function expandParameters(array $criteria): array; /** * Expands Criteria Parameters by walking the expressions and grabbing all parameters and types from it. * - * @psalm-return array{list, list} + * @psalm-return array{list, list} */ public function expandCriteriaParameters(Criteria $criteria): array; @@ -77,7 +85,12 @@ public function expandCriteriaParameters(Criteria $criteria): array; * * @psalm-param array|null $assoc */ - public function getSelectConditionStatementSQL(string $field, mixed $value, ?array $assoc = null, ?string $comparison = null): string; + public function getSelectConditionStatementSQL( + string $field, + mixed $value, + ?array $assoc = null, + ?string $comparison = null + ): string; /** * Adds an entity to the queued insertions. @@ -137,17 +150,17 @@ public function getOwningTable(string $fieldName): string; /** * Loads an entity by a list of field criteria. * - * @param mixed[] $criteria The criteria by which to load the entity. - * @param object|null $entity The entity to load the data into. If not specified, - * a new entity is created. - * @param mixed[]|null $assoc The association that connects the entity - * to load to another entity, if any. - * @param mixed[] $hints Hints for entity creation. - * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants - * or NULL if no specific lock mode should be used - * for loading the entity. - * @param int|null $limit Limit number of results. - * @param string[]|null $orderBy Criteria to order by. + * @param mixed[] $criteria The criteria by which to load the entity. + * @param object|null $entity The entity to load the data into. If not specified, + * a new entity is created. + * @param mixed[]|null $assoc The association that connects the entity + * to load to another entity, if any. + * @param mixed[] $hints Hints for entity creation. + * @param LockMode|int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * for loading the entity. + * @param int|null $limit Limit number of results. + * @param string[]|null $orderBy Criteria to order by. * @psalm-param array $criteria * @psalm-param array|null $assoc * @psalm-param array $hints @@ -163,7 +176,7 @@ public function load( ?object $entity = null, ?array $assoc = null, array $hints = [], - ?int $lockMode = null, + LockMode|int|null $lockMode = null, ?int $limit = null, ?array $orderBy = null ): ?object; @@ -199,15 +212,15 @@ public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $id /** * Refreshes a managed entity. * - * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants - * or NULL if no specific lock mode should be used - * for refreshing the managed entity. + * @param LockMode|int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * for refreshing the managed entity. * @psalm-param array $id The identifier of the entity as an * associative array from column or * field names to values. * @psalm-param LockMode::*|null $lockMode */ - public function refresh(array $id, object $entity, ?int $lockMode = null): void; + public function refresh(array $id, object $entity, LockMode|int|null $lockMode = null): void; /** * Loads Entities matching the given Criteria object. @@ -224,7 +237,12 @@ public function loadCriteria(Criteria $criteria): array; * * @return mixed[] */ - public function loadAll(array $criteria = [], ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array; + public function loadAll( + array $criteria = [], + ?array $orderBy = null, + ?int $limit = null, + ?int $offset = null + ): array; /** * Gets (sliced or full) elements of the given collection. @@ -233,7 +251,12 @@ public function loadAll(array $criteria = [], ?array $orderBy = null, ?int $limi * * @return mixed[] */ - public function getManyToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array; + public function getManyToManyCollection( + array $assoc, + object $sourceEntity, + ?int $offset = null, + ?int $limit = null + ): array; /** * Loads a collection of entities of a many-to-many association. @@ -244,7 +267,11 @@ public function getManyToManyCollection(array $assoc, object $sourceEntity, ?int * * @return mixed[] */ - public function loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): array; + public function loadManyToManyCollection( + array $assoc, + object $sourceEntity, + PersistentCollection $collection + ): array; /** * Loads a collection of entities in a one-to-many association. @@ -252,7 +279,11 @@ public function loadManyToManyCollection(array $assoc, object $sourceEntity, Per * @param PersistentCollection $collection The collection to load/fill. * @psalm-param array $assoc */ - public function loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): mixed; + public function loadOneToManyCollection( + array $assoc, + object $sourceEntity, + PersistentCollection $collection + ): mixed; /** * Locks all rows of this entity matching the given criteria with the specified pessimistic lock mode. @@ -260,7 +291,7 @@ public function loadOneToManyCollection(array $assoc, object $sourceEntity, Pers * @psalm-param array $criteria * @psalm-param LockMode::* $lockMode */ - public function lock(array $criteria, int $lockMode): void; + public function lock(array $criteria, LockMode|int $lockMode): void; /** * Returns an array with (sliced or full list) of elements in the specified collection. @@ -269,7 +300,12 @@ public function lock(array $criteria, int $lockMode): void; * * @return mixed[] */ - public function getOneToManyCollection(array $assoc, object $sourceEntity, ?int $offset = null, ?int $limit = null): array; + public function getOneToManyCollection( + array $assoc, + object $sourceEntity, + ?int $offset = null, + ?int $limit = null + ): array; /** * Checks whether the given managed entity exists in the database. diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index ce3ce515051..8b3640a50fc 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -236,7 +236,7 @@ public function delete(object $entity): bool return (bool) $this->conn->delete($rootTable, $id, $rootTypes); } - public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, ?int $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string + public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, LockMode|int|null $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string { $this->switchPersisterContext($offset, $limit); @@ -324,7 +324,7 @@ public function getCountSQL(array|Criteria $criteria = []): string . (empty($conditionSql) ? '' : ' WHERE ' . $conditionSql); } - protected function getLockTablesSql(int $lockMode): string + protected function getLockTablesSql(LockMode|int $lockMode): string { $joinSql = ''; $identifierColumns = $this->class->getIdentifierColumnNames(); diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 222308ae017..6877e249b6e 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -648,7 +648,7 @@ public function setHydrationMode(string|int $hydrationMode): static * * @throws TransactionRequiredException */ - public function setLockMode(int $lockMode): self + public function setLockMode(LockMode|int $lockMode): self { if (in_array($lockMode, [LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE], true)) { if (! $this->em->getConnection()->isTransactionActive()) { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php index c26313efdcc..3a14d81c9d2 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -84,7 +84,7 @@ public function parse(Parser $parser) /** * @psalm-return TrimMode::* */ - private function getTrimMode(): int + private function getTrimMode(): TrimMode|int { if ($this->leading) { return TrimMode::LEADING; diff --git a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php index 95b76a2133c..1fe6cb03caa 100644 --- a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php +++ b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php @@ -29,7 +29,7 @@ final class ParameterTypeInferer * - Type (\Doctrine\DBAL\Types\Type::*) * - Connection (\Doctrine\DBAL\Connection::PARAM_*) */ - public static function inferType(mixed $value): int|string + public static function inferType(mixed $value): ParameterType|int|string { if (is_int($value)) { return Types::INTEGER; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 0d06fb7c811..8dcb54f165b 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2013,7 +2013,7 @@ private function cascadeRemove(object $entity, array &$visited): void * @throws TransactionRequiredException * @throws OptimisticLockException */ - public function lock(object $entity, int $lockMode, $lockVersion = null): void + public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void { if ($this->getEntityState($entity, self::STATE_DETACHED) !== self::STATE_MANAGED) { throw ORMInvalidArgumentException::entityNotManaged($entity); diff --git a/phpstan.neon b/phpstan.neon index 4f9da1757a2..c9ced268155 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -11,3 +11,13 @@ parameters: # Symfony cache supports passing a key prefix to the clear method. - '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/' + + # We can be certain that those values are not matched. + - + message: '~^Match expression does not handle remaining values:~' + path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + + # DBAL 4 compatibility + - + message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' + path: lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 3c753ce1f91..0787c8953dd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1030,10 +1030,9 @@ array array - + $assoc['mappedBy'] $association - $type $assoc['isOwningSide'] @@ -2244,16 +2243,10 @@ $collectionToUpdate $commitOrder[$i] - - object - $this->entityChangeSets $this->entityChangeSets - - $this->identityMap[$rootClassName][$idHash] - $this->identityMap[$rootClassName] diff --git a/psalm.xml b/psalm.xml index a056287efac..b6a1d02eaa7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -148,6 +148,12 @@ + + + + + + diff --git a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php b/tests/Doctrine/Performance/Mock/NonLoadingPersister.php index 2692be5a1a3..b240f417166 100644 --- a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php +++ b/tests/Doctrine/Performance/Mock/NonLoadingPersister.php @@ -4,6 +4,7 @@ namespace Doctrine\Performance\Mock; +use Doctrine\DBAL\LockMode; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; /** @@ -23,7 +24,7 @@ public function load( ?object $entity = null, ?array $assoc = null, array $hints = [], - ?int $lockMode = null, + LockMode|int|null $lockMode = null, ?int $limit = null, ?array $orderBy = null ): ?object { diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 2b93530aac3..fac993f7408 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -6,6 +6,7 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\LockMode; use Doctrine\ORM\Cache; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; @@ -132,7 +133,7 @@ public function close(): void /** * {@inheritDoc} */ - public function lock(object $entity, int $lockMode, $lockVersion = null): void + public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void { $this->realEntityManager->lock($entity, $lockMode, $lockVersion); } @@ -175,7 +176,7 @@ public function hasFilters(): bool return $this->realEntityManager->hasFilters(); } - public function find(string $className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object + public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object { return $this->realEntityManager->find($className, $id, $lockMode, $lockVersion); } diff --git a/tests/Doctrine/Tests/Mocks/CompatibilityType.php b/tests/Doctrine/Tests/Mocks/CompatibilityType.php new file mode 100644 index 00000000000..c70a498c034 --- /dev/null +++ b/tests/Doctrine/Tests/Mocks/CompatibilityType.php @@ -0,0 +1,39 @@ +doGetBindingType(); + } + + private function doGetBindingType(): int|ParameterType + { + return parent::getBindingType(); + } + } +} else { + trait CompatibilityType + { + public function getBindingType(): ParameterType + { + return $this->doGetBindingType(); + } + + private function doGetBindingType(): int|ParameterType + { + return parent::getBindingType(); + } + } +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php index cd1729902f7..eaf0263c18e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; +use Doctrine\Tests\Mocks\CompatibilityType; use Doctrine\Tests\OrmFunctionalTestCase; /** @@ -54,6 +55,8 @@ public function testFlattenIdentifierWithObjectId(): void class GH9335IntObjectType extends Type { + use CompatibilityType; + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { return $platform->getIntegerTypeDeclarationSQL($column); @@ -74,7 +77,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): GH9335Int return new GH9335IntObject((int) $value); } - public function getBindingType(): int + private function doGetBindingType(): ParameterType|int { return ParameterType::INTEGER; } diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index 54d379a5aeb..d1aa56894f5 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -46,7 +46,7 @@ public function providerParameterTypeInferer(): Generator /** * @dataProvider providerParameterTypeInferer */ - public function testParameterTypeInferer(mixed $value, int|string $expected): void + public function testParameterTypeInferer(mixed $value, ParameterType|int|string $expected): void { self::assertEquals($expected, ParameterTypeInferer::inferType($value)); } From 3c19eb6de2cba27b4dfd58bc5ac3191595399cdb Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 3 Aug 2022 23:01:41 +0200 Subject: [PATCH 144/475] Require PHP 8.1 (#9925) --- .github/workflows/continuous-integration.yml | 7 ++----- .github/workflows/phpbench.yml | 2 +- composer.json | 2 +- phpcs.xml.dist | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 51c3b897686..569cc2f0ff1 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -19,17 +19,14 @@ jobs: strategy: matrix: php-version: - - "8.0" - "8.1" dbal-version: - "default" + - "3@dev" + - "4@dev" include: - - php-version: "8.1" - dbal-version: "3@dev" - php-version: "8.2" dbal-version: "3@dev" - - php-version: "8.1" - dbal-version: "4@dev" steps: - name: "Checkout" diff --git a/.github/workflows/phpbench.yml b/.github/workflows/phpbench.yml index df9c049d176..f134dba863e 100644 --- a/.github/workflows/phpbench.yml +++ b/.github/workflows/phpbench.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: php-version: - - "8.0" + - "8.1" steps: - name: "Checkout" diff --git a/composer.json b/composer.json index 84dd72af332..297b4fde56c 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "sort-packages": true }, "require": { - "php": "^8.0", + "php": "^8.1", "composer-runtime-api": "^2", "ext-ctype": "*", "doctrine/collections": "^1.5", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 3479e897c9b..d4441c51c43 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -9,7 +9,7 @@ - + lib tests From 6e6b81dcdfe94c0de6ede7102cf295f69e137cc8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 4 Aug 2022 00:12:00 +0200 Subject: [PATCH 145/475] Remove obsolete PHP version checks (#9954) --- .../ORM/Mapping/ClassMetadataInfo.php | 10 +---- lib/Doctrine/ORM/Mapping/MappingException.php | 5 --- .../Tests/Mocks/CompatibilityType.php | 4 +- .../Tests/ORM/Mapping/AttributeDriverTest.php | 38 ------------------- .../ORM/Query/ParameterTypeInfererTest.php | 13 ++----- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 7 +--- 6 files changed, 8 insertions(+), 69 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 5d22a9643c5..e896b42c201 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -54,8 +54,6 @@ use function trait_exists; use function trim; -use const PHP_VERSION_ID; - /** * A ClassMetadata instance holds all the object-relational mapping metadata * of an entity and its associations. @@ -1448,7 +1446,7 @@ private function validateAndCompleteTypedFieldMapping(array $mapping): array ! isset($mapping['type']) && ($type instanceof ReflectionNamedType) ) { - if (PHP_VERSION_ID >= 80100 && ! $type->isBuiltin() && enum_exists($type->getName())) { + if (! $type->isBuiltin() && enum_exists($type->getName())) { $mapping['enumType'] = $type->getName(); $reflection = new ReflectionEnum($type->getName()); @@ -1581,10 +1579,6 @@ protected function validateAndCompleteFieldMapping(array $mapping): array } if (isset($mapping['enumType'])) { - if (PHP_VERSION_ID < 80100) { - throw MappingException::enumsRequirePhp81($this->name, $mapping['fieldName']); - } - if (! enum_exists($mapping['enumType'])) { throw MappingException::nonEnumTypeMapped($this->name, $mapping['fieldName'], $mapping['enumType']); } @@ -3439,7 +3433,7 @@ private function assertMappingOrderBy(array $mapping): void private function getAccessibleProperty(ReflectionService $reflService, string $class, string $field): ?ReflectionProperty { $reflectionProperty = $reflService->getAccessibleProperty($class, $field); - if ($reflectionProperty !== null && PHP_VERSION_ID >= 80100 && $reflectionProperty->isReadOnly()) { + if ($reflectionProperty?->isReadOnly()) { $reflectionProperty = new ReflectionReadonlyProperty($reflectionProperty); } diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 1cae09e095a..9400afa75e4 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -930,11 +930,6 @@ public static function invalidOverrideType(string $expectdType, $givenValue): se )); } - public static function enumsRequirePhp81(string $className, string $fieldName): self - { - return new self(sprintf('Enum types require PHP 8.1 in %s::$%s', $className, $fieldName)); - } - public static function nonEnumTypeMapped(string $className, string $fieldName, string $enumType): self { return new self(sprintf( diff --git a/tests/Doctrine/Tests/Mocks/CompatibilityType.php b/tests/Doctrine/Tests/Mocks/CompatibilityType.php index c70a498c034..41417068ab2 100644 --- a/tests/Doctrine/Tests/Mocks/CompatibilityType.php +++ b/tests/Doctrine/Tests/Mocks/CompatibilityType.php @@ -8,9 +8,7 @@ use function enum_exists; -use const PHP_VERSION_ID; - -if (PHP_VERSION_ID < 80100 || ! enum_exists(ParameterType::class)) { +if (! enum_exists(ParameterType::class)) { trait CompatibilityType { public function getBindingType(): int diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index dbed089fb9c..99652e1b19f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -11,8 +11,6 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriver; use stdClass; -use const PHP_VERSION_ID; - class AttributeDriverTest extends MappingDriverTestCase { protected function loadDriver(): MappingDriver @@ -27,42 +25,6 @@ public function testSqlResultSetMapping(): void self::markTestSkipped('AttributeDriver does not support named sql resultset mapping.'); } - public function testAssociationOverridesMapping(): void - { - if (PHP_VERSION_ID < 80100) { - self::markTestSkipped('AttributeDriver does not support association overrides.'); - } else { - parent::testAssociationOverridesMapping(); - } - } - - public function testInversedByOverrideMapping(): void - { - if (PHP_VERSION_ID < 80100) { - self::markTestSkipped('AttributeDriver does not support association overrides.'); - } else { - parent::testInversedByOverrideMapping(); - } - } - - public function testFetchOverrideMapping(): void - { - if (PHP_VERSION_ID < 80100) { - self::markTestSkipped('AttributeDriver does not support association overrides.'); - } else { - parent::testFetchOverrideMapping(); - } - } - - public function testAttributeOverridesMapping(): void - { - if (PHP_VERSION_ID < 80100) { - self::markTestSkipped('AttributeDriver does not support association overrides.'); - } else { - parent::testAttributeOverridesMapping(); - } - } - public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): void { $factory = $this->createClassMetadataFactory(); diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index d1aa56894f5..b26e08ea825 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -16,8 +16,6 @@ use Doctrine\Tests\OrmTestCase; use Generator; -use const PHP_VERSION_ID; - class ParameterTypeInfererTest extends OrmTestCase { /** @psalm-return Generator */ @@ -34,13 +32,10 @@ public function providerParameterTypeInferer(): Generator yield 'array_of_numeric_string' => [['1', '2'], Connection::PARAM_STR_ARRAY]; yield 'empty_array' => [[], Connection::PARAM_STR_ARRAY]; yield 'boolean' => [true, Types::BOOLEAN]; - - if (PHP_VERSION_ID >= 80100) { - yield 'int_backed_enum' => [AccessLevel::Admin, Types::INTEGER]; - yield 'string_backed_enum' => [UserStatus::Active, Types::STRING]; - yield 'array_of_int_backed_enum' => [[AccessLevel::Admin], Connection::PARAM_INT_ARRAY]; - yield 'array_of_string_backed_enum' => [[UserStatus::Active], Connection::PARAM_STR_ARRAY]; - } + yield 'int_backed_enum' => [AccessLevel::Admin, Types::INTEGER]; + yield 'string_backed_enum' => [UserStatus::Active, Types::STRING]; + yield 'array_of_int_backed_enum' => [[AccessLevel::Admin], Connection::PARAM_INT_ARRAY]; + yield 'array_of_string_backed_enum' => [[UserStatus::Active], Connection::PARAM_STR_ARRAY]; } /** diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index bedd40bd4f8..a384c9902f3 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -35,8 +35,6 @@ use function array_map; -use const PHP_VERSION_ID; - class QueryTest extends OrmTestCase { use VerifyDeprecations; @@ -230,10 +228,7 @@ public function provideProcessParameterValueIterable(): Generator yield 'simple_array' => [$baseArray]; yield 'doctrine_collection' => [new ArrayCollection($baseArray)]; yield 'generator' => [$gen()]; - - if (PHP_VERSION_ID >= 80100) { - yield 'array_of_enum' => [array_map([City::class, 'from'], $baseArray)]; - } + yield 'array_of_enum' => [array_map([City::class, 'from'], $baseArray)]; } /** From 6e5626bbff4858803a3ae2ca34dba8f716b83046 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 4 Aug 2022 08:27:02 +0200 Subject: [PATCH 146/475] Flag properties as readonly if possible (#9956) --- lib/Doctrine/ORM/Cache/DefaultCache.php | 6 +-- .../ORM/Cache/DefaultCollectionHydrator.php | 4 +- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 8 ++-- .../ORM/Cache/Region/DefaultRegion.php | 6 +-- .../ORM/Cache/Region/FileLockRegion.php | 6 +-- lib/Doctrine/ORM/EntityRepository.php | 6 +-- .../ORM/Internal/HydrationCompleteHandler.php | 6 ++- .../Mapping/ReflectionEmbeddedProperty.php | 6 +-- .../ORM/Mapping/ReflectionEnumProperty.php | 4 +- .../Mapping/ReflectionReadonlyProperty.php | 2 +- lib/Doctrine/ORM/Query/Filter/SQLFilter.php | 2 +- lib/Doctrine/ORM/Query/FilterCollection.php | 2 +- .../ORM/Query/ResultSetMappingBuilder.php | 4 +- lib/Doctrine/ORM/Query/SqlWalker.php | 14 +++--- lib/Doctrine/ORM/Query/TreeWalkerAdapter.php | 4 +- lib/Doctrine/ORM/Query/TreeWalkerChain.php | 4 +- lib/Doctrine/ORM/QueryBuilder.php | 2 +- .../Command/AbstractEntityManagerCommand.php | 2 +- .../ConnectionFromManagerProvider.php | 2 +- .../SingleManagerProvider.php | 4 +- .../ORM/Tools/DebugUnitOfWorkListener.php | 4 +- .../Tools/Event/GenerateSchemaEventArgs.php | 4 +- .../Event/GenerateSchemaTableEventArgs.php | 6 +-- .../ORM/Tools/Pagination/Paginator.php | 8 ++-- lib/Doctrine/ORM/Tools/SchemaTool.php | 8 ++-- lib/Doctrine/ORM/Tools/SchemaValidator.php | 2 +- lib/Doctrine/ORM/UnitOfWork.php | 10 ++--- .../ORM/Utility/IdentifierFlattener.php | 4 +- .../Mock/NonProxyLoadingEntityManager.php | 2 +- .../Tests/DbalExtensions/SqlLogger.php | 2 +- .../Tests/Mocks/ConcurrentRegionMock.php | 2 +- .../Tests/ORM/Cache/FileLockRegionTest.php | 44 +++---------------- 32 files changed, 81 insertions(+), 109 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultCache.php b/lib/Doctrine/ORM/Cache/DefaultCache.php index aa0f27e7a24..f46fb12a996 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultCache.php @@ -20,8 +20,8 @@ */ class DefaultCache implements Cache { - private UnitOfWork $uow; - private CacheFactory $cacheFactory; + private readonly UnitOfWork $uow; + private readonly CacheFactory $cacheFactory; /** * @var QueryCache[] @@ -32,7 +32,7 @@ class DefaultCache implements Cache private ?QueryCache $defaultQueryCache = null; public function __construct( - private EntityManagerInterface $em + private readonly EntityManagerInterface $em ) { $this->uow = $em->getUnitOfWork(); $this->cacheFactory = $em->getConfiguration() diff --git a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php index 9ea7729a74b..f5023f22be2 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php @@ -19,13 +19,13 @@ */ class DefaultCollectionHydrator implements CollectionHydrator { - private UnitOfWork $uow; + private readonly UnitOfWork $uow; /** @var array */ private static array $hints = [Query::HINT_CACHE_ENABLED => true]; public function __construct( - private EntityManagerInterface $em + private readonly EntityManagerInterface $em ) { $this->uow = $em->getUnitOfWork(); } diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 3eff193d9fa..67126f8234e 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -32,16 +32,16 @@ */ class DefaultQueryCache implements QueryCache { - private UnitOfWork $uow; - private QueryCacheValidator $validator; + private readonly UnitOfWork $uow; + private readonly QueryCacheValidator $validator; protected ?CacheLogger $cacheLogger = null; /** @var array */ private static array $hints = [Query::HINT_CACHE_ENABLED => true]; public function __construct( - private EntityManagerInterface $em, - private Region $region + private readonly EntityManagerInterface $em, + private readonly Region $region ) { $cacheConfig = $em->getConfiguration()->getSecondLevelCacheConfiguration(); diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php index baca09481a2..3d4d474d768 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php @@ -27,9 +27,9 @@ class DefaultRegion implements Region private const REGION_PREFIX = 'DC2_REGION_'; public function __construct( - private string $name, - private CacheItemPoolInterface $cacheItemPool, - private int $lifetime = 0 + private readonly string $name, + private readonly CacheItemPoolInterface $cacheItemPool, + private readonly int $lifetime = 0 ) { } diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index b9264796036..f30f404477f 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -43,9 +43,9 @@ class FileLockRegion implements ConcurrentRegion * @throws InvalidArgumentException */ public function __construct( - private Region $region, - private string $directory, - private string|int $lockLifetime + private readonly Region $region, + private readonly string $directory, + private readonly string|int $lockLifetime ) { if (! is_dir($directory) && ! @mkdir($directory, 0775, true)) { throw new InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $directory)); diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 42c0ab7d08d..245c0d02ade 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -36,15 +36,15 @@ class EntityRepository implements ObjectRepository, Selectable { /** @psalm-var class-string */ - private string $entityName; + private readonly string $entityName; private static ?Inflector $inflector = null; /** * @psalm-param ClassMetadata $class */ public function __construct( - private EntityManagerInterface $em, - private ClassMetadata $class + private readonly EntityManagerInterface $em, + private readonly ClassMetadata $class ) { $this->entityName = $class->name; } diff --git a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php index bd109686a68..8a97d398cd2 100644 --- a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php +++ b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php @@ -19,8 +19,10 @@ final class HydrationCompleteHandler /** @var mixed[][] */ private array $deferredPostLoadInvocations = []; - public function __construct(private ListenersInvoker $listenersInvoker, private EntityManagerInterface $em) - { + public function __construct( + private readonly ListenersInvoker $listenersInvoker, + private readonly EntityManagerInterface $em, + ) { } /** diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php index b38ddfecc0c..024b37a31d9 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php @@ -26,9 +26,9 @@ final class ReflectionEmbeddedProperty extends ReflectionProperty * @psalm-param class-string $embeddedClass */ public function __construct( - private ReflectionProperty $parentProperty, - private ReflectionProperty $childProperty, - private string $embeddedClass + private readonly ReflectionProperty $parentProperty, + private readonly ReflectionProperty $childProperty, + private readonly string $embeddedClass ) { parent::__construct($childProperty->getDeclaringClass()->getName(), $childProperty->getName()); } diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php index 0645a9ba35f..98448d519fd 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php @@ -18,8 +18,8 @@ final class ReflectionEnumProperty extends ReflectionProperty * @param class-string $enumType */ public function __construct( - private ReflectionProperty $originalReflectionProperty, - private string $enumType + private readonly ReflectionProperty $originalReflectionProperty, + private readonly string $enumType ) { parent::__construct( $originalReflectionProperty->getDeclaringClass()->getName(), diff --git a/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php index fba314be12e..c3697226abc 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php @@ -20,7 +20,7 @@ final class ReflectionReadonlyProperty extends ReflectionProperty { public function __construct( - private ReflectionProperty $wrappedProperty + private readonly ReflectionProperty $wrappedProperty ) { if (! $wrappedProperty->isReadOnly()) { throw new InvalidArgumentException('Given property is not readonly.'); diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index 5c41fba8d7f..5ced1fc61e8 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -33,7 +33,7 @@ abstract class SQLFilter private array $parameters = []; final public function __construct( - private EntityManagerInterface $em + private readonly EntityManagerInterface $em ) { } diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index c0ec5ecb39d..c226e59d961 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -49,7 +49,7 @@ class FilterCollection private int $filtersState = self::FILTERS_STATE_CLEAN; public function __construct( - private EntityManagerInterface $em + private readonly EntityManagerInterface $em ) { $this->config = $em->getConfiguration(); } diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index c687fc99d8e..213e7faa0f4 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -49,8 +49,8 @@ class ResultSetMappingBuilder extends ResultSetMapping * @psalm-param self::COLUMN_RENAMING_* $defaultRenameMode */ public function __construct( - private EntityManagerInterface $em, - private int $defaultRenameMode = self::COLUMN_RENAMING_NONE, + private readonly EntityManagerInterface $em, + private readonly int $defaultRenameMode = self::COLUMN_RENAMING_NONE, ) { } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 0161545dbc5..7d693e10ed1 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -54,7 +54,7 @@ class SqlWalker */ public const HINT_PARTIAL = 'doctrine.partial'; - private ResultSetMapping $rsm; + private readonly ResultSetMapping $rsm; /** * Counter for generating unique column aliases. @@ -81,8 +81,8 @@ class SqlWalker */ private int $newObjectCounter = 0; - private EntityManagerInterface $em; - private Connection $conn; + private readonly EntityManagerInterface $em; + private readonly Connection $conn; /** @var mixed[] */ private array $tableAliasMap = []; @@ -131,19 +131,19 @@ class SqlWalker /** * The database platform abstraction. */ - private AbstractPlatform $platform; + private readonly AbstractPlatform $platform; /** * The quote strategy. */ - private QuoteStrategy $quoteStrategy; + private readonly QuoteStrategy $quoteStrategy; /** * @psalm-param array $queryComponents The query components (symbol table). */ public function __construct( - private Query $query, - private ParserResult $parserResult, + private readonly Query $query, + private readonly ParserResult $parserResult, private array $queryComponents ) { $this->rsm = $parserResult->getResultSetMapping(); diff --git a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php index bdc3f353168..247ac02447f 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php @@ -24,8 +24,8 @@ abstract class TreeWalkerAdapter implements TreeWalker * {@inheritdoc} */ public function __construct( - private AbstractQuery $query, - private ParserResult $parserResult, + private readonly AbstractQuery $query, + private readonly ParserResult $parserResult, private array $queryComponents ) { } diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChain.php b/lib/Doctrine/ORM/Query/TreeWalkerChain.php index 4c4b34f7301..0c37e58e545 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerChain.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerChain.php @@ -28,8 +28,8 @@ class TreeWalkerChain implements TreeWalker * {@inheritdoc} */ public function __construct( - private AbstractQuery $query, - private ParserResult $parserResult, + private readonly AbstractQuery $query, + private readonly ParserResult $parserResult, private array $queryComponents ) { } diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 8c0e23709fe..3e37d88cccd 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -138,7 +138,7 @@ class QueryBuilder * @param EntityManagerInterface $em The EntityManager to use. */ public function __construct( - private EntityManagerInterface $em + private readonly EntityManagerInterface $em ) { $this->parameters = new ArrayCollection(); } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php index 1da54248d93..370f4fb6026 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php @@ -11,7 +11,7 @@ abstract class AbstractEntityManagerCommand extends Command { - public function __construct(private EntityManagerProvider $entityManagerProvider) + public function __construct(private readonly EntityManagerProvider $entityManagerProvider) { parent::__construct(); } diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php index 8b677fddc40..07766016054 100644 --- a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php +++ b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php @@ -10,7 +10,7 @@ final class ConnectionFromManagerProvider implements ConnectionProvider { - public function __construct(private EntityManagerProvider $entityManagerProvider) + public function __construct(private readonly EntityManagerProvider $entityManagerProvider) { } diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php index 3b8f5d8c0e0..ebe60c913cd 100644 --- a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php +++ b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php @@ -10,8 +10,8 @@ final class SingleManagerProvider implements EntityManagerProvider { public function __construct( - private EntityManagerInterface $entityManager, - private string $defaultManagerName = 'default', + private readonly EntityManagerInterface $entityManager, + private readonly string $defaultManagerName = 'default', ) { } diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index 6147572f997..36fccf9874a 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -32,8 +32,8 @@ class DebugUnitOfWorkListener * The stream can be php://output to print to the screen. */ public function __construct( - private string $file = 'php://output', - private string $context = '' + private readonly string $file = 'php://output', + private readonly string $context = '' ) { } diff --git a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php index 0276534c85d..7af3e775d2b 100644 --- a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php +++ b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php @@ -16,8 +16,8 @@ class GenerateSchemaEventArgs extends EventArgs { public function __construct( - private EntityManagerInterface $em, - private Schema $schema + private readonly EntityManagerInterface $em, + private readonly Schema $schema ) { } diff --git a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php index ddb6ede0ce0..f7da465bf19 100644 --- a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php +++ b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php @@ -17,9 +17,9 @@ class GenerateSchemaTableEventArgs extends EventArgs { public function __construct( - private ClassMetadata $classMetadata, - private Schema $schema, - private Table $classTable + private readonly ClassMetadata $classMetadata, + private readonly Schema $schema, + private readonly Table $classTable ) { } diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index ca2684ebc14..c24ac4c0350 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -31,15 +31,17 @@ class Paginator implements Countable, IteratorAggregate { use SQLResultCasing; - private Query $query; + private readonly Query $query; private ?bool $useOutputWalkers = null; private ?int $count = null; /** * @param bool $fetchJoinCollection Whether the query joins a collection (true by default). */ - public function __construct(Query|QueryBuilder $query, private bool $fetchJoinCollection = true) - { + public function __construct( + Query|QueryBuilder $query, + private readonly bool $fetchJoinCollection = true + ) { if ($query instanceof QueryBuilder) { $query = $query->getQuery(); } diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 6010743cc2f..6018e70209a 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -48,15 +48,15 @@ class SchemaTool { private const KNOWN_COLUMN_OPTIONS = ['comment', 'unsigned', 'fixed', 'default']; - private AbstractPlatform $platform; - private QuoteStrategy $quoteStrategy; - private AbstractSchemaManager $schemaManager; + private readonly AbstractPlatform $platform; + private readonly QuoteStrategy $quoteStrategy; + private readonly AbstractSchemaManager $schemaManager; /** * Initializes a new SchemaTool instance that uses the connection of the * provided EntityManager. */ - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { $this->platform = $em->getConnection()->getDatabasePlatform(); $this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index deb47a2ae35..7e56a0418aa 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -25,7 +25,7 @@ */ class SchemaValidator { - public function __construct(private EntityManagerInterface $em) + public function __construct(private readonly EntityManagerInterface $em) { } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 4ceddeb8406..69a85ade0fd 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -247,17 +247,17 @@ class UnitOfWork implements PropertyChangedListener /** * The EventManager used for dispatching events. */ - private EventManager $evm; + private readonly EventManager $evm; /** * The ListenersInvoker used for dispatching events. */ - private ListenersInvoker $listenersInvoker; + private readonly ListenersInvoker $listenersInvoker; /** * The IdentifierFlattener used for manipulating identifiers */ - private IdentifierFlattener $identifierFlattener; + private readonly IdentifierFlattener $identifierFlattener; /** * Orphaned entities that are scheduled for removal. @@ -285,7 +285,7 @@ class UnitOfWork implements PropertyChangedListener /** * Helper for handling completion of hydration */ - private HydrationCompleteHandler $hydrationCompleteHandler; + private readonly HydrationCompleteHandler $hydrationCompleteHandler; /** * Initializes a new UnitOfWork instance, bound to the given EntityManager. @@ -293,7 +293,7 @@ class UnitOfWork implements PropertyChangedListener * @param EntityManagerInterface $em The EntityManager that "owns" this UnitOfWork instance. */ public function __construct( - private EntityManagerInterface $em + private readonly EntityManagerInterface $em ) { $this->evm = $em->getEventManager(); $this->listenersInvoker = new ListenersInvoker($em); diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index fa8677e25bd..b573ae200d9 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -26,11 +26,11 @@ public function __construct( /** * The UnitOfWork used to coordinate object-level transactions. */ - private UnitOfWork $unitOfWork, + private readonly UnitOfWork $unitOfWork, /** * The metadata factory, used to retrieve the ORM metadata of entity classes. */ - private ClassMetadataFactory $metadataFactory + private readonly ClassMetadataFactory $metadataFactory ) { } diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index fac993f7408..6e7a8745534 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -28,7 +28,7 @@ */ class NonProxyLoadingEntityManager implements EntityManagerInterface { - public function __construct(private EntityManagerInterface $realEntityManager) + public function __construct(private readonly EntityManagerInterface $realEntityManager) { } diff --git a/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php b/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php index 17270a707af..6192ac7ae00 100644 --- a/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php +++ b/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php @@ -8,7 +8,7 @@ final class SqlLogger extends AbstractLogger { - public function __construct(private QueryLog $queryLog) + public function __construct(private readonly QueryLog $queryLog) { } diff --git a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php b/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php index 8c29aa64db7..6babfa94b17 100644 --- a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php @@ -32,7 +32,7 @@ class ConcurrentRegionMock implements ConcurrentRegion public array $locks = []; public function __construct( - private Region $region + private readonly Region $region ) { } diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index 06c51cb9d38..e5bd749e55e 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -13,24 +13,17 @@ use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use ReflectionMethod; -use ReflectionProperty; use function file_put_contents; use function is_dir; -use function restore_error_handler; use function rmdir; -use function set_error_handler; -use function str_repeat; use function sys_get_temp_dir; use function uniqid; use function unlink; -use const E_WARNING; - /** * @extends RegionTestCase * @group DDC-2183 - * @extends AbstractRegionTest */ class FileLockRegionTest extends RegionTestCase { @@ -45,18 +38,16 @@ private function getFileName(FileLockRegion $region, CacheKey $key): string { $reflection = new ReflectionMethod($region, 'getLockFileName'); - $reflection->setAccessible(true); - return $reflection->invoke($region, $key); } - protected function createRegion(): FileLockRegion + protected function createRegion(int $lockLifetime = 60): FileLockRegion { $this->directory = sys_get_temp_dir() . '/doctrine_lock_' . uniqid(); $region = new DefaultRegion('concurren_region_test', $this->cacheItemPool); - return new FileLockRegion($region, $this->directory, 60); + return new FileLockRegion($region, $this->directory, $lockLifetime); } public function testGetRegionName(): void @@ -221,13 +212,10 @@ public function testLockedEvictAll(): void public function testLockLifetime(): void { - $key = new CacheKeyMock('key'); - $entry = new CacheEntryMock(['foo' => 'bar']); - $file = $this->getFileName($this->region, $key); - $property = new ReflectionProperty($this->region, 'lockLifetime'); - - $property->setAccessible(true); - $property->setValue($this->region, -10); + $this->region = $this->createRegion(-10); + $key = new CacheKeyMock('key'); + $entry = new CacheEntryMock(['foo' => 'bar']); + $file = $this->getFileName($this->region, $key); self::assertFalse($this->region->contains($key)); self::assertTrue($this->region->put($key, $entry)); @@ -243,26 +231,6 @@ public function testLockLifetime(): void self::assertFileDoesNotExist($file); } - /** - * @group 1072 - * @group DDC-3191 - */ - public function testHandlesScanErrorsGracefullyOnEvictAll(): void - { - $region = $this->createRegion(); - $reflectionDirectory = new ReflectionProperty($region, 'directory'); - - $reflectionDirectory->setAccessible(true); - $reflectionDirectory->setValue($region, str_repeat('a', 10000)); - - set_error_handler(static fn (): bool => true, E_WARNING); - try { - self::assertTrue($region->evictAll()); - } finally { - restore_error_handler(); - } - } - private function cleanTestDirectory(?string $path): void { $path = $path ?: $this->directory; From a0be22b65f246b5946d18b0200c2abe04b6484e7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 4 Aug 2022 08:28:50 +0200 Subject: [PATCH 147/475] Use intersection types in tests (#9959) --- phpcs.xml.dist | 5 +++++ .../Tests/ORM/Cache/CacheLoggerChainTest.php | 4 +--- .../Tests/ORM/Cache/DefaultCacheFactoryTest.php | 4 +--- .../Collection/CollectionPersisterTestCase.php | 13 +++---------- .../ReadWriteCachedCollectionPersisterTest.php | 5 +---- .../Entity/EntityPersisterTestCase.php | 13 +++---------- .../ReadWriteCachedEntityPersisterTest.php | 3 ++- .../Tests/ORM/Functional/SQLFilterTest.php | 17 +++-------------- .../ORM/Hydration/AbstractHydratorTest.php | 15 ++++----------- .../Internal/HydrationCompleteHandlerTest.php | 8 ++------ .../Tests/ORM/LazyCriteriaCollectionTest.php | 5 +---- .../Repository/DefaultRepositoryFactoryTest.php | 16 ++++------------ .../ORM/Tools/Pagination/PaginatorTest.php | 9 +++------ tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 7 ++----- 14 files changed, 35 insertions(+), 89 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d4441c51c43..074159324ee 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -132,6 +132,11 @@ tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php + + + tests/* + + */tests/* diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index aa3f83949ba..2ba9bb1b7b9 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -19,9 +19,7 @@ class CacheLoggerChainTest extends DoctrineTestCase { private CacheLoggerChain $logger; - - /** @var CacheLogger&MockObject */ - private CacheLogger $mock; + private CacheLogger&MockObject $mock; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 7437aab925d..e988fe7f65c 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -36,9 +36,7 @@ */ class DefaultCacheFactoryTest extends OrmTestCase { - /** @var CacheFactory&MockObject */ - private CacheFactory $factory; - + private CacheFactory&MockObject $factory; private EntityManagerMock $em; private RegionsConfiguration $regionsConfig; diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php index 19c0c1c3ff0..1f7447fb4dc 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php @@ -22,12 +22,8 @@ */ abstract class CollectionPersisterTestCase extends OrmTestCase { - /** @var Region&MockObject */ - protected Region $region; - - /** @var CollectionPersister&MockObject */ - protected CollectionPersister $collectionPersister; - + protected Region&MockObject $region; + protected CollectionPersister&MockObject $collectionPersister; protected EntityManagerMock $em; abstract protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister; @@ -43,10 +39,7 @@ protected function setUp(): void $this->collectionPersister = $this->createMock(CollectionPersister::class); } - /** - * @return Region&MockObject - */ - protected function createRegion(): Region + protected function createRegion(): Region&MockObject { return $this->createMock(Region::class); } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index cbc9c0b509d..c5395d87a47 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -26,10 +26,7 @@ protected function createPersister(EntityManagerInterface $em, CollectionPersist return new ReadWriteCachedCollectionPersister($persister, $region, $em, $mapping); } - /** - * @return ConcurrentRegion&MockObject - */ - protected function createRegion(): ConcurrentRegion + protected function createRegion(): ConcurrentRegion&MockObject { return $this->createMock(ConcurrentRegion::class); } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php index ae3d7655a57..8b264a5f6e2 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php @@ -25,12 +25,8 @@ */ abstract class EntityPersisterTestCase extends OrmTestCase { - /** @var Region&MockObject */ - protected Region $region; - - /** @var EntityPersister&MockObject */ - protected EntityPersister $entityPersister; - + protected Region&MockObject $region; + protected EntityPersister&MockObject $entityPersister; protected EntityManagerMock $em; abstract protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister; @@ -46,10 +42,7 @@ protected function setUp(): void $this->entityPersister = $this->createMock(EntityPersister::class); } - /** - * @return Region&MockObject - */ - protected function createRegion(): Region + protected function createRegion(): Region&MockObject { return $this->createMock(Region::class); } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 7bc17860d5a..9d742ca0616 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Entity\EntityPersister; use Doctrine\Tests\Models\Cache\Country; +use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; /** @@ -26,7 +27,7 @@ protected function createPersister(EntityManagerInterface $em, EntityPersister $ return new ReadWriteCachedEntityPersister($persister, $region, $em, $metadata); } - protected function createRegion(): Region + protected function createRegion(): ConcurrentRegion&MockObject { return $this->createMock(ConcurrentRegion::class); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 73278d04794..7c34497ed82 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -204,10 +204,7 @@ private function configureFilters(EntityManagerInterface $em): void $config->addFilter('soft_delete', '\Doctrine\Tests\ORM\Functional\MySoftDeleteFilter'); } - /** - * @return Connection&MockObject - */ - private function getMockConnection(): Connection + private function getMockConnection(): Connection&MockObject { $connection = $this->createMock(Connection::class); $connection->method('getEventManager') @@ -216,20 +213,12 @@ private function getMockConnection(): Connection return $connection; } - /** - * @return EntityManagerInterface&MockObject - */ - private function getMockEntityManager(): EntityManagerInterface + private function getMockEntityManager(): EntityManagerInterface&MockObject { return $this->createMock(EntityManagerInterface::class); } - /** - * @psalm-param EntityManagerInterface&MockObject $em - * - * @return FilterCollection&MockObject - */ - private function addMockFilterCollection(EntityManagerInterface $em): FilterCollection + private function addMockFilterCollection(EntityManagerInterface&MockObject $em): FilterCollection&MockObject { $filterCollection = $this->createMock(FilterCollection::class); diff --git a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php index 1be4b5788d3..fe60af19275 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php @@ -23,17 +23,10 @@ */ class AbstractHydratorTest extends OrmFunctionalTestCase { - /** @var EventManager&MockObject */ - private EventManager $mockEventManager; - - /** @var Result&MockObject */ - private Result $mockResult; - - /** @var ResultSetMapping&MockObject */ - private ResultSetMapping $mockResultMapping; - - /** @var AbstractHydrator&MockObject */ - private AbstractHydrator $hydrator; + private EventManager&MockObject $mockEventManager; + private Result&MockObject $mockResult; + private ResultSetMapping&MockObject $mockResultMapping; + private AbstractHydrator&MockObject $hydrator; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index 1fa1ee5d9f0..69124ac83ea 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -24,12 +24,8 @@ */ class HydrationCompleteHandlerTest extends TestCase { - /** @var ListenersInvoker&MockObject */ - private $listenersInvoker; - - /** @var EntityManagerInterface&MockObject */ - private $entityManager; - + private ListenersInvoker&MockObject $listenersInvoker; + private EntityManagerInterface&MockObject $entityManager; private HydrationCompleteHandler $handler; protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 50a8703e8e5..a64fd7221f5 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -17,11 +17,8 @@ */ class LazyCriteriaCollectionTest extends TestCase { - /** @var EntityPersister&MockObject */ - private $persister; - + private EntityPersister&MockObject $persister; private Criteria $criteria; - private LazyCriteriaCollection $lazyCriteriaCollection; protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index 5b55d407ac8..5522edf3c64 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -22,12 +22,8 @@ */ class DefaultRepositoryFactoryTest extends TestCase { - /** @var EntityManagerInterface&MockObject */ - private EntityManagerInterface $entityManager; - - /** @var Configuration&MockObject */ - private Configuration $configuration; - + private EntityManagerInterface&MockObject $entityManager; + private Configuration&MockObject $configuration; private DefaultRepositoryFactory $repositoryFactory; protected function setUp(): void @@ -109,12 +105,11 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void /** * @psalm-param class-string $className * - * @return ClassMetadata&MockObject * @psalm-return ClassMetadata&MockObject * * @template TEntity of object */ - private function buildClassMetadata(string $className): ClassMetadata + private function buildClassMetadata(string $className): ClassMetadata&MockObject { $metadata = $this->createMock(ClassMetadata::class); $metadata->method('getName')->will(self::returnValue($className)); @@ -125,10 +120,7 @@ private function buildClassMetadata(string $className): ClassMetadata return $metadata; } - /** - * @return EntityManagerInterface&MockObject - */ - private function createEntityManager(): EntityManagerInterface + private function createEntityManager(): EntityManagerInterface&MockObject { $entityManager = $this->createMock(EntityManagerInterface::class); $entityManager->method('getConfiguration')->willReturn($this->configuration); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index 29903fda23a..dd5a21c0ece 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -18,12 +18,9 @@ class PaginatorTest extends OrmTestCase { - /** @var Connection&MockObject */ - private $connection; - /** @var EntityManagerInterface&MockObject */ - private $em; - /** @var AbstractHydrator&MockObject */ - private $hydrator; + private Connection&MockObject $connection; + private EntityManagerInterface&MockObject $em; + private AbstractHydrator&MockObject $hydrator; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 0df86f09cb9..5cf0bc2ee42 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -52,18 +52,15 @@ class UnitOfWorkTest extends OrmTestCase /** * Provides a sequence mock to the UnitOfWork - * - * @var Connection&MockObject */ - private $connection; + private Connection $connection; /** * The EntityManager mock that provides the mock persisters */ private EntityManagerMock $_emMock; - /** @var EventManager&MockObject */ - private $eventManager; + private EventManager&MockObject $eventManager; protected function setUp(): void { From 1a82e4a294287de7faca7c30f7409f8d60af0281 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 4 Aug 2022 08:29:29 +0200 Subject: [PATCH 148/475] Drop unmaintained Symfony versions (#9957) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 297b4fde56c..77d56bc886f 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "doctrine/lexer": "^1.2.3", "doctrine/persistence": "^3", "psr/cache": "^1 || ^2 || ^3", - "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0" + "symfony/console": "^4.4 || ^5.4 || ^6.0" }, "require-dev": { "doctrine/annotations": "^1.13", From 23f5c016cfa09d7a435876a7e12a32e454a9b927 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 4 Aug 2022 22:51:21 +0200 Subject: [PATCH 149/475] Resolve QueryBuilder deprecations (#9953) --- UPGRADE.md | 34 +++++ lib/Doctrine/ORM/Internal/QueryType.php | 12 ++ lib/Doctrine/ORM/QueryBuilder.php | 118 ++++-------------- psalm-baseline.xml | 4 - psalm.xml | 1 - tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 56 ++------- 6 files changed, 81 insertions(+), 144 deletions(-) create mode 100644 lib/Doctrine/ORM/Internal/QueryType.php diff --git a/UPGRADE.md b/UPGRADE.md index 8bf749997f8..2dc90e39022 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,39 @@ # Upgrade to 3.0 +## BC BREAK: Removed `QueryBuilder` methods and constants. + +The following `QueryBuilder` constants and methods have been removed: + +1. `SELECT`, +2. `DELETE`, +3. `UPDATE`, +4. `STATE_DIRTY`, +5. `STATE_CLEAN`, +6. `getState()`, +7. `getType()`. + +## BC BREAK: Omitting only the alias argument for `QueryBuilder::update` and `QueryBuilder::delete` is not supported anymore + +When building an UPDATE or DELETE query and when passing a class/type to the function, the alias argument must not be omitted. + +### Before + +```php +$qb = $em->createQueryBuilder() + ->delete('User u') + ->where('u.id = :user_id') + ->setParameter('user_id', 1); +``` + +### After + +```php +$qb = $em->createQueryBuilder() + ->delete('User', 'u') + ->where('u.id = :user_id') + ->setParameter('user_id', 1); +``` + ## BC BREAK: Split output walkers and tree walkers `SqlWalker` and its child classes don't implement the `TreeWalker` interface diff --git a/lib/Doctrine/ORM/Internal/QueryType.php b/lib/Doctrine/ORM/Internal/QueryType.php new file mode 100644 index 00000000000..4cb0ab7688e --- /dev/null +++ b/lib/Doctrine/ORM/Internal/QueryType.php @@ -0,0 +1,12 @@ + [], ]; - /** - * The type of query this is. Can be select, update or delete. - * - * @psalm-var self::SELECT|self::DELETE|self::UPDATE - */ - private int $type = self::SELECT; - - /** - * The state of the query object. Can be dirty or clean. - * - * @psalm-var self::STATE_* - */ - private int $state = self::STATE_CLEAN; + private QueryType $type = QueryType::Select; /** * The complete DQL string for this query. @@ -240,25 +213,6 @@ public function setCacheMode(int $cacheMode): static return $this; } - /** - * Gets the type of the currently built query. - * - * @deprecated If necessary, track the type of the query being built outside of the builder. - * - * @psalm-return self::SELECT|self::DELETE|self::UPDATE - */ - public function getType(): int - { - Deprecation::trigger( - 'doctrine/dbal', - 'https://github.com/doctrine/orm/pull/9945', - 'Relying on the type of the query being built is deprecated.' - . ' If necessary, track the type of the query being built outside of the builder.' - ); - - return $this->type; - } - /** * Gets the associated EntityManager for this query builder. */ @@ -267,25 +221,6 @@ public function getEntityManager(): EntityManagerInterface return $this->em; } - /** - * Gets the state of this query builder instance. - * - * @deprecated The builder state is an internal concern. - * - * @return int Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. - * @psalm-return self::STATE_* - */ - public function getState(): int - { - Deprecation::trigger( - 'doctrine/dbal', - 'https://github.com/doctrine/orm/pull/9945', - 'Relying on the query builder state is deprecated as it is an internal concern.' - ); - - return $this->state; - } - /** * Gets the complete DQL string formed by the current specifications of this QueryBuilder. * @@ -298,20 +233,11 @@ public function getState(): int */ public function getDQL(): string { - if ($this->dql !== null && $this->state === self::STATE_CLEAN) { - return $this->dql; - } - - $dql = match ($this->type) { - self::DELETE => $this->getDQLForDelete(), - self::UPDATE => $this->getDQLForUpdate(), - self::SELECT => $this->getDQLForSelect(), + return $this->dql ??= match ($this->type) { + QueryType::Select => $this->getDQLForSelect(), + QueryType::Delete => $this->getDQLForDelete(), + QueryType::Update => $this->getDQLForUpdate(), }; - - $this->state = self::STATE_CLEAN; - $this->dql = $dql; - - return $dql; } /** @@ -670,7 +596,7 @@ public function add(string $dqlPartName, string|object|array $dqlPart, bool $app $this->dqlParts[$dqlPartName] = $isMultiple ? [$dqlPart] : $dqlPart; } - $this->state = self::STATE_DIRTY; + $this->dql = null; return $this; } @@ -690,7 +616,7 @@ public function add(string $dqlPartName, string|object|array $dqlPart, bool $app */ public function select(mixed ...$select): static { - $this->type = self::SELECT; + $this->type = QueryType::Select; if ($select === []) { return $this; @@ -733,7 +659,7 @@ public function distinct(bool $flag = true): static */ public function addSelect(mixed ...$select): static { - $this->type = self::SELECT; + $this->type = QueryType::Select; if ($select === []) { return $this; @@ -760,18 +686,18 @@ public function addSelect(mixed ...$select): static */ public function delete(?string $delete = null, ?string $alias = null): static { - $this->type = self::DELETE; + $this->type = QueryType::Delete; if (! $delete) { return $this; } if (! $alias) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9733', - 'Omitting the alias is deprecated and will throw an exception in Doctrine 3.0.' - ); + throw new InvalidArgumentException(sprintf( + '%s(): The alias for entity %s must not be omitted.', + __METHOD__, + $delete + )); } return $this->add('from', new Expr\From($delete, $alias)); @@ -795,18 +721,18 @@ public function delete(?string $delete = null, ?string $alias = null): static */ public function update(?string $update = null, ?string $alias = null): static { - $this->type = self::UPDATE; + $this->type = QueryType::Update; if (! $update) { return $this; } if (! $alias) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9733', - 'Omitting the alias is deprecated and will throw an exception in Doctrine 3.0.' - ); + throw new InvalidArgumentException(sprintf( + '%s(): The alias for entity %s must not be omitted.', + __METHOD__, + $update + )); } return $this->add('from', new Expr\From($update, $alias)); @@ -1386,7 +1312,7 @@ public function resetDQLParts(?array $parts = null): static public function resetDQLPart(string $part): static { $this->dqlParts[$part] = is_array($this->dqlParts[$part]) ? [] : null; - $this->state = self::STATE_DIRTY; + $this->dql = null; return $this; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1a94ae786d7..f6378368cc3 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2062,10 +2062,6 @@ $dqlPart - - $alias - $alias - diff --git a/psalm.xml b/psalm.xml index 5d876ea7b27..bb0910955ad 100644 --- a/psalm.xml +++ b/psalm.xml @@ -30,7 +30,6 @@ - diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index d278127e79a..16c6553cfd0 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -6,7 +6,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Cache; use Doctrine\ORM\Query; use Doctrine\ORM\Query\Expr\Join; @@ -29,8 +28,6 @@ */ class QueryBuilderTest extends OrmTestCase { - use VerifyDeprecations; - private EntityManagerMock $entityManager; protected function setUp(): void @@ -52,16 +49,7 @@ public function testSelectSetsType(): void ->delete(CmsUser::class, 'u') ->select('u.id', 'u.username'); - self::assertEquals($qb->getType(), QueryBuilder::SELECT); - } - - public function testEmptySelectSetsType(): void - { - $qb = $this->entityManager->createQueryBuilder() - ->delete(CmsUser::class, 'u') - ->select(); - - self::assertEquals($qb->getType(), QueryBuilder::SELECT); + $this->assertValidQueryBuilder($qb, 'SELECT u.id, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u'); } public function testDeleteSetsType(): void @@ -70,7 +58,7 @@ public function testDeleteSetsType(): void ->from(CmsUser::class, 'u') ->delete(); - self::assertEquals($qb->getType(), QueryBuilder::DELETE); + $this->assertValidQueryBuilder($qb, 'DELETE Doctrine\Tests\Models\CMS\CmsUser u'); } public function testUpdateSetsType(): void @@ -79,7 +67,7 @@ public function testUpdateSetsType(): void ->from(CmsUser::class, 'u') ->update(); - self::assertEquals($qb->getType(), QueryBuilder::UPDATE); + $this->assertValidQueryBuilder($qb, 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u'); } public function testSimpleSelect(): void @@ -828,21 +816,6 @@ public function testGetEntityManager(): void self::assertEquals($this->entityManager, $qb->getEntityManager()); } - public function testInitialStateIsClean(): void - { - $qb = $this->entityManager->createQueryBuilder(); - self::assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); - } - - public function testAlteringQueryChangesStateToDirty(): void - { - $qb = $this->entityManager->createQueryBuilder() - ->select('u') - ->from(CmsUser::class, 'u'); - - self::assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); - } - public function testSelectWithFuncExpression(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -1281,24 +1254,21 @@ public function testJoin(): void self::assertSame('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN Doctrine\Tests\Models\CMS\CmsArticle a0 INNER JOIN Doctrine\Tests\Models\CMS\CmsArticle a1', $builder->getDQL()); } - public function testUpdateDeprecationMessage(): void + public function testUpdateWithoutAlias(): void { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/9733'); - - $qb = $this->entityManager->createQueryBuilder() - ->update(CmsUser::class . ' u') - ->set('u.username', ':username'); + $qb = $this->entityManager->createQueryBuilder(); - $this->assertValidQueryBuilder($qb, 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.username = :username'); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Doctrine\ORM\QueryBuilder::update(): The alias for entity Doctrine\Tests\Models\CMS\CmsUser u must not be omitted.'); + $qb->update(CmsUser::class . ' u'); } - public function testDeleteDeprecationMessage(): void + public function testDeleteWithoutAlias(): void { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/9733'); - - $qb = $this->entityManager->createQueryBuilder() - ->delete(CmsUser::class . ' u'); + $qb = $this->entityManager->createQueryBuilder(); - $this->assertValidQueryBuilder($qb, 'DELETE Doctrine\Tests\Models\CMS\CmsUser u '); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Doctrine\ORM\QueryBuilder::delete(): The alias for entity Doctrine\Tests\Models\CMS\CmsUser u must not be omitted.'); + $qb->delete(CmsUser::class . ' u'); } } From 0e074e407a945075b0740f8cd18ae021c9e06fa3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 7 Aug 2022 18:42:52 +0200 Subject: [PATCH 150/475] Stabilize the DBAL dependency (#9968) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 84830250b0c..475b0f291ae 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-ctype": "*", "doctrine/collections": "^1.5", "doctrine/common": "^3.3", - "doctrine/dbal": "^3.4@dev", + "doctrine/dbal": "^3.4", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.1", "doctrine/inflector": "^1.4 || ^2.0", From f9257cdf7829e94acad7a334c2852465a21fd0ba Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 7 Aug 2022 19:22:03 +0200 Subject: [PATCH 151/475] Flag QueryType as internal (#9963) --- lib/Doctrine/ORM/Internal/QueryType.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Doctrine/ORM/Internal/QueryType.php b/lib/Doctrine/ORM/Internal/QueryType.php index 4cb0ab7688e..f72245551d8 100644 --- a/lib/Doctrine/ORM/Internal/QueryType.php +++ b/lib/Doctrine/ORM/Internal/QueryType.php @@ -4,6 +4,9 @@ namespace Doctrine\ORM\Internal; +/** + * @internal To be used inside the QueryBuilder only. + */ enum QueryType { case Select; From c39cbf15be2cbc5c3bef801fa8ecd1d3ad988f4f Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 7 Aug 2022 21:37:36 +0200 Subject: [PATCH 152/475] Add types to ProxyFactory (#9962) --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 36 +++++++++---------------- psalm-baseline.xml | 5 ++-- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index c3f9b5fd42e..f9ec04397ef 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -24,21 +24,11 @@ */ class ProxyFactory extends AbstractProxyFactory { - /** @var EntityManagerInterface The EntityManager this factory is bound to. */ - private $em; + /** The UnitOfWork this factory uses to retrieve persisters */ + private readonly UnitOfWork $uow; - /** @var UnitOfWork The UnitOfWork this factory uses to retrieve persisters */ - private $uow; - - /** @var string */ - private $proxyNs; - - /** - * The IdentifierFlattener used for manipulating identifiers - * - * @var IdentifierFlattener - */ - private $identifierFlattener; + /** The IdentifierFlattener used for manipulating identifiers */ + private readonly IdentifierFlattener $identifierFlattener; /** * Initializes a new instance of the ProxyFactory class that is @@ -51,23 +41,22 @@ class ProxyFactory extends AbstractProxyFactory * values are constants of {@see AbstractProxyFactory}. * @psalm-param bool|AutogenerateMode $autoGenerate */ - public function __construct(EntityManagerInterface $em, $proxyDir, $proxyNs, $autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER) - { + public function __construct( + private readonly EntityManagerInterface $em, + string $proxyDir, + private readonly string $proxyNs, + bool|int $autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER, + ) { $proxyGenerator = new ProxyGenerator($proxyDir, $proxyNs); $proxyGenerator->setPlaceholder('baseProxyInterface', Proxy::class); parent::__construct($proxyGenerator, $em->getMetadataFactory(), $autoGenerate); - $this->em = $em; $this->uow = $em->getUnitOfWork(); - $this->proxyNs = $proxyNs; $this->identifierFlattener = new IdentifierFlattener($this->uow, $em->getMetadataFactory()); } - /** - * {@inheritDoc} - */ - protected function skipClass(ClassMetadata $metadata) + protected function skipClass(ClassMetadata $metadata): bool { return $metadata->isMappedSuperclass || $metadata->isEmbeddedClass @@ -77,7 +66,7 @@ protected function skipClass(ClassMetadata $metadata) /** * {@inheritDoc} */ - protected function createProxyDefinition($className) + protected function createProxyDefinition($className): ProxyDefinition { $classMetadata = $this->em->getClassMetadata($className); $entityPersister = $this->uow->getEntityPersister($className); @@ -175,7 +164,6 @@ private function createCloner(ClassMetadata $classMetadata, EntityPersister $ent continue; } - $property->setAccessible(true); $property->setValue($proxy, $property->getValue($original)); } }; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d9d995737fb..bc42f4d77b6 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1096,8 +1096,9 @@ $property->name - - setAccessible + + getValue + setValue __wakeup From 7e45006300e6f14c470322b225145842a66edda3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 7 Aug 2022 22:35:19 +0200 Subject: [PATCH 153/475] Update Psalm config (#9974) --- psalm.xml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/psalm.xml b/psalm.xml index a1cb2070434..77f4fd8fc63 100644 --- a/psalm.xml +++ b/psalm.xml @@ -24,30 +24,12 @@ - - - - - - - - - - - - - - - - - - From 7c4442561f0018495c22e4d83bded1eb097e732b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 8 Aug 2022 21:30:51 +0200 Subject: [PATCH 154/475] Add types to Node::dispatch() (#9978) --- .../ORM/Query/AST/AggregateExpression.php | 7 +- .../ORM/Query/AST/ArithmeticExpression.php | 7 +- .../ORM/Query/AST/ArithmeticFactor.php | 9 +- lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php | 9 +- .../ORM/Query/AST/BetweenExpression.php | 9 +- .../ORM/Query/AST/CoalesceExpression.php | 9 +- .../Query/AST/CollectionMemberExpression.php | 7 +- .../ORM/Query/AST/ComparisonExpression.php | 9 +- .../ORM/Query/AST/ConditionalExpression.php | 9 +- .../ORM/Query/AST/ConditionalFactor.php | 9 +- .../ORM/Query/AST/ConditionalPrimary.php | 9 +- .../ORM/Query/AST/ConditionalTerm.php | 9 +- lib/Doctrine/ORM/Query/AST/DeleteClause.php | 9 +- .../ORM/Query/AST/DeleteStatement.php | 9 +- .../EmptyCollectionComparisonExpression.php | 9 +- .../ORM/Query/AST/ExistsExpression.php | 9 +- lib/Doctrine/ORM/Query/AST/FromClause.php | 9 +- .../ORM/Query/AST/Functions/FunctionNode.php | 7 +- .../ORM/Query/AST/GeneralCaseExpression.php | 9 +- lib/Doctrine/ORM/Query/AST/GroupByClause.php | 9 +- lib/Doctrine/ORM/Query/AST/HavingClause.php | 9 +- .../AST/IdentificationVariableDeclaration.php | 9 +- lib/Doctrine/ORM/Query/AST/InExpression.php | 9 +- lib/Doctrine/ORM/Query/AST/IndexBy.php | 11 +- lib/Doctrine/ORM/Query/AST/InputParameter.php | 6 +- .../ORM/Query/AST/InstanceOfExpression.php | 9 +- lib/Doctrine/ORM/Query/AST/Join.php | 9 +- .../Query/AST/JoinAssociationDeclaration.php | 9 +- .../ORM/Query/AST/JoinClassPathExpression.php | 7 +- .../ORM/Query/AST/JoinVariableDeclaration.php | 7 +- lib/Doctrine/ORM/Query/AST/LikeExpression.php | 8 +- lib/Doctrine/ORM/Query/AST/Literal.php | 7 +- .../ORM/Query/AST/NewObjectExpression.php | 9 +- lib/Doctrine/ORM/Query/AST/Node.php | 6 +- .../Query/AST/NullComparisonExpression.php | 9 +- .../ORM/Query/AST/NullIfExpression.php | 9 +- lib/Doctrine/ORM/Query/AST/OrderByClause.php | 9 +- lib/Doctrine/ORM/Query/AST/OrderByItem.php | 9 +- .../ORM/Query/AST/ParenthesisExpression.php | 7 +- lib/Doctrine/ORM/Query/AST/PathExpression.php | 7 +- .../ORM/Query/AST/QuantifiedExpression.php | 9 +- .../Query/AST/RangeVariableDeclaration.php | 7 +- lib/Doctrine/ORM/Query/AST/SelectClause.php | 9 +- .../ORM/Query/AST/SelectExpression.php | 9 +- .../ORM/Query/AST/SelectStatement.php | 9 +- .../Query/AST/SimpleArithmeticExpression.php | 9 +- .../ORM/Query/AST/SimpleCaseExpression.php | 9 +- .../ORM/Query/AST/SimpleSelectClause.php | 9 +- .../ORM/Query/AST/SimpleSelectExpression.php | 9 +- .../ORM/Query/AST/SimpleWhenClause.php | 9 +- lib/Doctrine/ORM/Query/AST/Subselect.php | 9 +- .../ORM/Query/AST/SubselectFromClause.php | 9 +- lib/Doctrine/ORM/Query/AST/UpdateClause.php | 9 +- lib/Doctrine/ORM/Query/AST/UpdateItem.php | 9 +- .../ORM/Query/AST/UpdateStatement.php | 9 +- lib/Doctrine/ORM/Query/AST/WhenClause.php | 9 +- lib/Doctrine/ORM/Query/AST/WhereClause.php | 9 +- phpstan-baseline.neon | 10 - psalm-baseline.xml | 201 ------------------ 59 files changed, 212 insertions(+), 487 deletions(-) diff --git a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php index 9a939348f40..07666bbc30d 100644 --- a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php +++ b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + class AggregateExpression extends Node { /** @var string */ @@ -31,10 +33,7 @@ public function __construct($functionName, $pathExpression, $isDistinct) $this->isDistinct = $isDistinct; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkAggregateExpression($this); } diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php index 6f91ae3e42e..eecf4acd44b 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")" * @@ -33,10 +35,7 @@ public function isSubselect() return (bool) $this->subselect; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkArithmeticExpression($this); } diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php b/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php index 62c71588532..a2f86e51295 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary * @@ -47,11 +49,8 @@ public function isNegativeSigned() return $this->sign === false; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkArithmeticFactor($this); + return $walker->walkArithmeticFactor($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php b/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php index 6f2d2d5468e..5c20c06b382 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}* * @@ -22,11 +24,8 @@ public function __construct(array $arithmeticFactors) $this->arithmeticFactors = $arithmeticFactors; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkArithmeticTerm($this); + return $walker->walkArithmeticTerm($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php b/lib/Doctrine/ORM/Query/AST/BetweenExpression.php index bda34837fa7..2ea941ba0a1 100644 --- a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php +++ b/lib/Doctrine/ORM/Query/AST/BetweenExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + class BetweenExpression extends Node { /** @var ArithmeticExpression */ @@ -30,11 +32,8 @@ public function __construct($expr, $leftExpr, $rightExpr) $this->rightBetweenExpression = $rightExpr; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkBetweenExpression($this); + return $walker->walkBetweenExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php b/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php index ff4c51e3ba9..68f6efaa927 100644 --- a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php +++ b/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")" * @@ -22,11 +24,8 @@ public function __construct(array $scalarExpressions) $this->scalarExpressions = $scalarExpressions; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkCoalesceExpression($this); + return $walker->walkCoalesceExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php b/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php index 4cceb62f020..b8605975c10 100644 --- a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php +++ b/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * CollectionMemberExpression ::= EntityExpression ["NOT"] "MEMBER" ["OF"] CollectionValuedPathExpression * @@ -30,10 +32,7 @@ public function __construct($entityExpr, $collValuedPathExpr) $this->collectionValuedPathExpression = $collValuedPathExpr; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkCollectionMemberExpression($this); } diff --git a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php index caf7baf32dc..41ab5ad0c49 100644 --- a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ComparisonExpression ::= ArithmeticExpression ComparisonOperator ( QuantifiedExpression | ArithmeticExpression ) | * StringExpression ComparisonOperator (StringExpression | QuantifiedExpression) | @@ -37,11 +39,8 @@ public function __construct($leftExpr, $operator, $rightExpr) $this->operator = $operator; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkComparisonExpression($this); + return $walker->walkComparisonExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php b/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php index 15f8c1d117e..0b5d6dc55c3 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}* * @@ -22,11 +24,8 @@ public function __construct(array $conditionalTerms) $this->conditionalTerms = $conditionalTerms; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkConditionalExpression($this); + return $walker->walkConditionalExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php b/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php index 3de5e155bcb..064163959d5 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ConditionalFactor ::= ["NOT"] ConditionalPrimary * @@ -25,11 +27,8 @@ public function __construct($conditionalPrimary) $this->conditionalPrimary = $conditionalPrimary; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkConditionalFactor($this); + return $walker->walkConditionalFactor($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php index 5a5b8072973..2e3d885dadc 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")" * @@ -33,11 +35,8 @@ public function isConditionalExpression() return (bool) $this->conditionalExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkConditionalPrimary($this); + return $walker->walkConditionalPrimary($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php b/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php index 937fdbd8b60..eaebfe87e58 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}* * @@ -22,11 +24,8 @@ public function __construct(array $conditionalFactors) $this->conditionalFactors = $conditionalFactors; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkConditionalTerm($this); + return $walker->walkConditionalTerm($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/DeleteClause.php b/lib/Doctrine/ORM/Query/AST/DeleteClause.php index 3334929181b..0135b25756e 100644 --- a/lib/Doctrine/ORM/Query/AST/DeleteClause.php +++ b/lib/Doctrine/ORM/Query/AST/DeleteClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName [["AS"] AliasIdentificationVariable] * @@ -25,11 +27,8 @@ public function __construct($abstractSchemaName) $this->abstractSchemaName = $abstractSchemaName; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkDeleteClause($this); + return $walker->walkDeleteClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php b/lib/Doctrine/ORM/Query/AST/DeleteStatement.php index cd1eab539ec..bdcc3dc09a3 100644 --- a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php +++ b/lib/Doctrine/ORM/Query/AST/DeleteStatement.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * DeleteStatement = DeleteClause [WhereClause] * @@ -25,11 +27,8 @@ public function __construct($deleteClause) $this->deleteClause = $deleteClause; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkDeleteStatement($this); + return $walker->walkDeleteStatement($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php index 7507cf2dc61..d812d766135 100644 --- a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY" * @@ -25,11 +27,8 @@ public function __construct($expression) $this->expression = $expression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkEmptyCollectionComparisonExpression($this); + return $walker->walkEmptyCollectionComparisonExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php b/lib/Doctrine/ORM/Query/AST/ExistsExpression.php index 10d14fbf17c..9ac64b27c87 100644 --- a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ExistsExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")" * @@ -25,11 +27,8 @@ public function __construct($subselect) $this->subselect = $subselect; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkExistsExpression($this); + return $walker->walkExistsExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/FromClause.php b/lib/Doctrine/ORM/Query/AST/FromClause.php index ce42137aaf4..8f8fa740c08 100644 --- a/lib/Doctrine/ORM/Query/AST/FromClause.php +++ b/lib/Doctrine/ORM/Query/AST/FromClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration} * @@ -22,11 +24,8 @@ public function __construct(array $identificationVariableDeclarations) $this->identificationVariableDeclarations = $identificationVariableDeclarations; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkFromClause($this); + return $walker->walkFromClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php b/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php index 13428ff2f65..358bc79ceaf 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php @@ -33,12 +33,7 @@ public function __construct($name) */ abstract public function getSql(SqlWalker $sqlWalker); - /** - * @param SqlWalker $sqlWalker - * - * @return string - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $sqlWalker): string { return $sqlWalker->walkFunction($this); } diff --git a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php b/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php index 13728f7d064..393a144269d 100644 --- a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END" * @@ -27,11 +29,8 @@ public function __construct(array $whenClauses, $elseScalarExpression) $this->elseScalarExpression = $elseScalarExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkGeneralCaseExpression($this); + return $walker->walkGeneralCaseExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/GroupByClause.php b/lib/Doctrine/ORM/Query/AST/GroupByClause.php index 8a8252e23b4..511438f75ca 100644 --- a/lib/Doctrine/ORM/Query/AST/GroupByClause.php +++ b/lib/Doctrine/ORM/Query/AST/GroupByClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + class GroupByClause extends Node { /** @var mixed[] */ @@ -17,11 +19,8 @@ public function __construct(array $groupByItems) $this->groupByItems = $groupByItems; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkGroupByClause($this); + return $walker->walkGroupByClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/HavingClause.php b/lib/Doctrine/ORM/Query/AST/HavingClause.php index 6381f53eff2..cd621f8c838 100644 --- a/lib/Doctrine/ORM/Query/AST/HavingClause.php +++ b/lib/Doctrine/ORM/Query/AST/HavingClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + class HavingClause extends Node { /** @var ConditionalExpression */ @@ -17,11 +19,8 @@ public function __construct($conditionalExpression) $this->conditionalExpression = $conditionalExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkHavingClause($this); + return $walker->walkHavingClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php index c43f1411492..cf96dfb50ff 100644 --- a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}* * @@ -32,11 +34,8 @@ public function __construct($rangeVariableDecl, $indexBy, array $joins) $this->joins = $joins; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkIdentificationVariableDeclaration($this); + return $walker->walkIdentificationVariableDeclaration($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/InExpression.php b/lib/Doctrine/ORM/Query/AST/InExpression.php index 1b023cd9f95..f83c128fa16 100644 --- a/lib/Doctrine/ORM/Query/AST/InExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * InExpression ::= ArithmeticExpression ["NOT"] "IN" "(" (Literal {"," Literal}* | Subselect) ")" * @@ -31,11 +33,8 @@ public function __construct($expression) $this->expression = $expression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkInExpression($this); + return $walker->walkInExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/IndexBy.php b/lib/Doctrine/ORM/Query/AST/IndexBy.php index a14b475316e..58ccc9a7300 100644 --- a/lib/Doctrine/ORM/Query/AST/IndexBy.php +++ b/lib/Doctrine/ORM/Query/AST/IndexBy.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * IndexBy ::= "INDEX" "BY" SingleValuedPathExpression * @@ -19,11 +21,10 @@ public function __construct(PathExpression $singleValuedPathExpression) $this->singleValuedPathExpression = $singleValuedPathExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkIndexBy($this); + $walker->walkIndexBy($this); + + return ''; } } diff --git a/lib/Doctrine/ORM/Query/AST/InputParameter.php b/lib/Doctrine/ORM/Query/AST/InputParameter.php index bc85576c672..7a6ab07e760 100644 --- a/lib/Doctrine/ORM/Query/AST/InputParameter.php +++ b/lib/Doctrine/ORM/Query/AST/InputParameter.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\QueryException; +use Doctrine\ORM\Query\SqlWalker; use function is_numeric; use function strlen; @@ -34,10 +35,7 @@ public function __construct($value) $this->name = $param; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkInputParameter($this); } diff --git a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php index c4f5e4d6a7e..5ee5ff742fc 100644 --- a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")") * InstanceOfParameter ::= AbstractSchemaName | InputParameter @@ -29,11 +31,8 @@ public function __construct($identVariable) $this->identificationVariable = $identVariable; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkInstanceOfExpression($this); + return $walker->walkInstanceOfExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/Join.php b/lib/Doctrine/ORM/Query/AST/Join.php index c32209af9f9..f558a9e31d3 100644 --- a/lib/Doctrine/ORM/Query/AST/Join.php +++ b/lib/Doctrine/ORM/Query/AST/Join.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression * ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression] @@ -39,11 +41,8 @@ public function __construct($joinType, $joinAssociationDeclaration) $this->joinAssociationDeclaration = $joinAssociationDeclaration; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkJoin($this); + return $walker->walkJoin($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php index 3c85fc4d4ce..f324abec7f1 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * JoinAssociationDeclaration ::= JoinAssociationPathExpression ["AS"] AliasIdentificationVariable * @@ -32,11 +34,8 @@ public function __construct($joinAssociationPathExpression, $aliasIdentification $this->indexBy = $indexBy; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkJoinAssociationDeclaration($this); + return $walker->walkJoinAssociationDeclaration($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php b/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php index 96a6e9e8dea..c262b2acc70 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * JoinClassPathExpression ::= AbstractSchemaName ["AS"] AliasIdentificationVariable * @@ -27,10 +29,7 @@ public function __construct($abstractSchemaName, $aliasIdentificationVar) $this->aliasIdentificationVariable = $aliasIdentificationVar; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkJoinPathExpression($this); } diff --git a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php index 08da7c73bb8..2e061750d75 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * JoinVariableDeclaration ::= Join [IndexBy] * @@ -27,10 +29,7 @@ public function __construct($join, $indexBy) $this->indexBy = $indexBy; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkJoinVariableDeclaration($this); } diff --git a/lib/Doctrine/ORM/Query/AST/LikeExpression.php b/lib/Doctrine/ORM/Query/AST/LikeExpression.php index c3b61b89f8c..27c5fd5c168 100644 --- a/lib/Doctrine/ORM/Query/AST/LikeExpression.php +++ b/lib/Doctrine/ORM/Query/AST/LikeExpression.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\AST\Functions\FunctionNode; +use Doctrine\ORM\Query\SqlWalker; /** * LikeExpression ::= StringExpression ["NOT"] "LIKE" string ["ESCAPE" char] @@ -37,11 +38,8 @@ public function __construct($stringExpression, $stringPattern, $escapeChar = nul $this->escapeChar = $escapeChar; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkLikeExpression($this); + return $walker->walkLikeExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/Literal.php b/lib/Doctrine/ORM/Query/AST/Literal.php index ef3933441b0..242d4fdffaf 100644 --- a/lib/Doctrine/ORM/Query/AST/Literal.php +++ b/lib/Doctrine/ORM/Query/AST/Literal.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + class Literal extends Node { public const STRING = 1; @@ -30,10 +32,7 @@ public function __construct($type, $value) $this->value = $value; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkLiteral($this); } diff --git a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php b/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php index 7d7b71e943f..f173fbb23d9 100644 --- a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * NewObjectExpression ::= "NEW" IdentificationVariable "(" NewObjectArg {"," NewObjectArg}* ")" * @@ -27,11 +29,8 @@ public function __construct($className, array $args) $this->args = $args; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkNewObject($this); + return $walker->walkNewObject($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/Node.php b/lib/Doctrine/ORM/Query/AST/Node.php index 4bc3245d14b..442fd7e1a47 100644 --- a/lib/Doctrine/ORM/Query/AST/Node.php +++ b/lib/Doctrine/ORM/Query/AST/Node.php @@ -27,13 +27,9 @@ abstract class Node * * Implementation is not mandatory for all nodes. * - * @param SqlWalker $walker - * - * @return string - * * @throws ASTException */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { throw ASTException::noDispatchForNode($this); } diff --git a/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php index 72a6b43437e..27d410dee0d 100644 --- a/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * NullComparisonExpression ::= (SingleValuedPathExpression | InputParameter) "IS" ["NOT"] "NULL" * @@ -25,11 +27,8 @@ public function __construct($expression) $this->expression = $expression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkNullComparisonExpression($this); + return $walker->walkNullComparisonExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/NullIfExpression.php b/lib/Doctrine/ORM/Query/AST/NullIfExpression.php index 4a2dbc1b7c7..920ca7f0740 100644 --- a/lib/Doctrine/ORM/Query/AST/NullIfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NullIfExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * NullIfExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")" * @@ -27,11 +29,8 @@ public function __construct($firstExpression, $secondExpression) $this->secondExpression = $secondExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkNullIfExpression($this); + return $walker->walkNullIfExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/OrderByClause.php b/lib/Doctrine/ORM/Query/AST/OrderByClause.php index 5e8ee964774..3c9ca6d50a2 100644 --- a/lib/Doctrine/ORM/Query/AST/OrderByClause.php +++ b/lib/Doctrine/ORM/Query/AST/OrderByClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}* * @@ -22,11 +24,8 @@ public function __construct(array $orderByItems) $this->orderByItems = $orderByItems; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkOrderByClause($this); + return $walker->walkOrderByClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/OrderByItem.php b/lib/Doctrine/ORM/Query/AST/OrderByItem.php index 85a7c78d491..2b76d465fd3 100644 --- a/lib/Doctrine/ORM/Query/AST/OrderByItem.php +++ b/lib/Doctrine/ORM/Query/AST/OrderByItem.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + use function strtoupper; /** @@ -43,11 +45,8 @@ public function isDesc() return strtoupper($this->type) === 'DESC'; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkOrderByItem($this); + return $walker->walkOrderByItem($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php b/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php index 74b14c00ac4..195938157e0 100644 --- a/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * ParenthesisExpression ::= "(" ArithmeticPrimary ")" */ @@ -17,10 +19,7 @@ public function __construct(Node $expression) $this->expression = $expression; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkParenthesisExpression($this); } diff --git a/lib/Doctrine/ORM/Query/AST/PathExpression.php b/lib/Doctrine/ORM/Query/AST/PathExpression.php index cafd10a44d5..0726f8d3faa 100644 --- a/lib/Doctrine/ORM/Query/AST/PathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/PathExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression * SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression @@ -50,10 +52,7 @@ public function __construct($expectedType, $identificationVariable, $field = nul $this->field = $field; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkPathExpression($this); } diff --git a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php index c6e594ce7a7..17c112e47a4 100644 --- a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php +++ b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + use function strtoupper; /** @@ -51,11 +53,8 @@ public function isSome() return strtoupper($this->type) === 'SOME'; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkQuantifiedExpression($this); + return $walker->walkQuantifiedExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php index 946d4463bea..60f97ccfd22 100644 --- a/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable * @@ -32,10 +34,7 @@ public function __construct($abstractSchemaName, $aliasIdentificationVar, $isRoo $this->isRoot = $isRoot; } - /** - * {@inheritdoc} - */ - public function dispatch($walker) + public function dispatch(SqlWalker $walker): string { return $walker->walkRangeVariableDeclaration($this); } diff --git a/lib/Doctrine/ORM/Query/AST/SelectClause.php b/lib/Doctrine/ORM/Query/AST/SelectClause.php index b5bda5ca5da..15a16ac6686 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SelectClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SelectClause = "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression} * @@ -27,11 +29,8 @@ public function __construct(array $selectExpressions, $isDistinct) $this->selectExpressions = $selectExpressions; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSelectClause($this); + return $walker->walkSelectClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/SelectExpression.php b/lib/Doctrine/ORM/Query/AST/SelectExpression.php index 1231542629d..ebe072a754e 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SelectExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SelectExpression ::= IdentificationVariable ["." "*"] | StateFieldPathExpression | * (AggregateExpression | "(" Subselect ")") [["AS"] ["HIDDEN"] FieldAliasIdentificationVariable] @@ -33,11 +35,8 @@ public function __construct($expression, $fieldIdentificationVariable, $hiddenAl $this->hiddenAliasResultVariable = $hiddenAliasResultVariable; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSelectExpression($this); + return $walker->walkSelectExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/SelectStatement.php b/lib/Doctrine/ORM/Query/AST/SelectStatement.php index e155461ed5e..c20a3a8cca9 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectStatement.php +++ b/lib/Doctrine/ORM/Query/AST/SelectStatement.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SelectStatement = SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] * @@ -39,11 +41,8 @@ public function __construct($selectClause, $fromClause) $this->fromClause = $fromClause; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSelectStatement($this); + return $walker->walkSelectStatement($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php index 3dda43ef305..525925422e8 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}* * @@ -22,11 +24,8 @@ public function __construct(array $arithmeticTerms) $this->arithmeticTerms = $arithmeticTerms; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSimpleArithmeticExpression($this); + return $walker->walkSimpleArithmeticExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php index 5d3f06b55ba..812f2297b97 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" * @@ -32,11 +34,8 @@ public function __construct($caseOperand, array $simpleWhenClauses, $elseScalarE $this->elseScalarExpression = $elseScalarExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSimpleCaseExpression($this); + return $walker->walkSimpleCaseExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php index f2e53978f02..4f8fd0047e9 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression * @@ -27,11 +29,8 @@ public function __construct($simpleSelectExpression, $isDistinct) $this->isDistinct = $isDistinct; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSimpleSelectClause($this); + return $walker->walkSimpleSelectClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php index 5765a43b928..306e666633e 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SimpleSelectExpression ::= StateFieldPathExpression | IdentificationVariable * | (AggregateExpression [["AS"] FieldAliasIdentificationVariable]) @@ -26,11 +28,8 @@ public function __construct($expression) $this->expression = $expression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSimpleSelectExpression($this); + return $walker->walkSimpleSelectExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php b/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php index c6d2850f369..33bb28030ff 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression * @@ -27,11 +29,8 @@ public function __construct($caseScalarExpression, $thenScalarExpression) $this->thenScalarExpression = $thenScalarExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkWhenClauseExpression($this); + return $walker->walkWhenClauseExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/Subselect.php b/lib/Doctrine/ORM/Query/AST/Subselect.php index a08f6098fd6..5a6fc692c22 100644 --- a/lib/Doctrine/ORM/Query/AST/Subselect.php +++ b/lib/Doctrine/ORM/Query/AST/Subselect.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] * @@ -39,11 +41,8 @@ public function __construct($simpleSelectClause, $subselectFromClause) $this->subselectFromClause = $subselectFromClause; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSubselect($this); + return $walker->walkSubselect($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php b/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php index bb157c03a3a..00ebff57644 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}* * @@ -22,11 +24,8 @@ public function __construct(array $identificationVariableDeclarations) $this->identificationVariableDeclarations = $identificationVariableDeclarations; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkSubselectFromClause($this); + return $walker->walkSubselectFromClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateClause.php b/lib/Doctrine/ORM/Query/AST/UpdateClause.php index ae9b6cf8050..d855898dac8 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateClause.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * UpdateClause ::= "UPDATE" AbstractSchemaName [["AS"] AliasIdentificationVariable] "SET" UpdateItem {"," UpdateItem}* * @@ -30,11 +32,8 @@ public function __construct($abstractSchemaName, array $updateItems) $this->updateItems = $updateItems; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkUpdateClause($this); + return $walker->walkUpdateClause($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateItem.php b/lib/Doctrine/ORM/Query/AST/UpdateItem.php index 75bd55a4204..2497499700d 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateItem.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateItem.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * UpdateItem ::= [IdentificationVariable "."] {StateField | SingleValuedAssociationField} "=" NewValue * NewValue ::= SimpleArithmeticExpression | StringPrimary | DatetimePrimary | BooleanPrimary | @@ -29,11 +31,8 @@ public function __construct($pathExpression, $newValue) $this->newValue = $newValue; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkUpdateItem($this); + return $walker->walkUpdateItem($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php b/lib/Doctrine/ORM/Query/AST/UpdateStatement.php index da1bad45952..1f905a5c0d9 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateStatement.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * UpdateStatement = UpdateClause [WhereClause] * @@ -25,11 +27,8 @@ public function __construct($updateClause) $this->updateClause = $updateClause; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkUpdateStatement($this); + return $walker->walkUpdateStatement($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/WhenClause.php b/lib/Doctrine/ORM/Query/AST/WhenClause.php index 7d9fbf49399..528a8d61a37 100644 --- a/lib/Doctrine/ORM/Query/AST/WhenClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhenClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression * @@ -27,11 +29,8 @@ public function __construct($caseConditionExpression, $thenScalarExpression) $this->thenScalarExpression = $thenScalarExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkWhenClauseExpression($this); + return $walker->walkWhenClauseExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/WhereClause.php b/lib/Doctrine/ORM/Query/AST/WhereClause.php index c3dda8e6973..c089939c587 100644 --- a/lib/Doctrine/ORM/Query/AST/WhereClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhereClause.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\AST; +use Doctrine\ORM\Query\SqlWalker; + /** * WhereClause ::= "WHERE" ConditionalExpression * @@ -22,11 +24,8 @@ public function __construct($conditionalExpression) $this->conditionalExpression = $conditionalExpression; } - /** - * {@inheritdoc} - */ - public function dispatch($sqlWalker) + public function dispatch(SqlWalker $walker): string { - return $sqlWalker->walkWhereClause($this); + return $walker->walkWhereClause($this); } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8ed696bfd54..e8cc0895d7b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -270,16 +270,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php - - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\AST\\\\IndexBy\\:\\:dispatch\\(\\) should return string but returns void\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/IndexBy.php - - - - message: "#^Result of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkIndexBy\\(\\) \\(void\\) is used\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/AST/IndexBy.php - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkJoinPathExpression\\(\\)\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bc42f4d77b6..7116924a52f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1118,93 +1118,31 @@ $parserResult - - - $sqlWalker - - - - - $sqlWalker - - - - $sqlWalker - $not - - - $sqlWalker - - $not - - - $sqlWalker - - - - - $sqlWalker - - - - - $sqlWalker - - - - - $sqlWalker - - - - - $sqlWalker - - - - $sqlWalker - $aliasIdentificationVariable - - - $sqlWalker - - - - $sqlWalker - $not - - $sqlWalker - $not - - - $sqlWalker - - $parser->SimpleArithmeticExpression() @@ -1400,67 +1338,22 @@ $stringPrimary - - - $sqlWalker - - - - - $sqlWalker - - - - - $sqlWalker - - - - - $sqlWalker - - - - $sqlWalker - $not - - dispatch - - - $sqlWalker->walkIndexBy($this) - - - $sqlWalker - null - - $sqlWalker - $not $value - - - $sqlWalker - - - - - $sqlWalker - - walkJoinPathExpression @@ -1471,16 +1364,6 @@ walkJoinVariableDeclaration - - - $sqlWalker - - - - - $sqlWalker - - is_array($obj) @@ -1490,120 +1373,41 @@ - - $sqlWalker - $not - - - $sqlWalker - - - - - $sqlWalker - - - - $sqlWalker - $type - - $sqlWalker - $type - - - $sqlWalker - - - - - $sqlWalker - - - - - $sqlWalker - - - - - $sqlWalker - - - - $sqlWalker - null - - - $sqlWalker - - - - $sqlWalker - $fieldIdentificationVariable - - $sqlWalker - walkWhenClauseExpression - - - $sqlWalker - - - - - $sqlWalker - - - - $sqlWalker - $aliasIdentificationVariable - - - $sqlWalker - - - - - $sqlWalker - - - - $sqlWalker - null @@ -1611,11 +1415,6 @@ walkWhenClauseExpression - - - $sqlWalker - - null From 41bca04103f910d3b24dc2aff66f7069b4dcb640 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 8 Aug 2022 22:02:40 +0200 Subject: [PATCH 155/475] Add types to EntityListenerResolver (#9976) --- lib/Doctrine/ORM/Event/ListenersInvoker.php | 39 +++++++++---------- .../Mapping/DefaultEntityListenerResolver.php | 35 +++-------------- .../ORM/Mapping/EntityListenerResolver.php | 14 ++----- psalm-baseline.xml | 3 -- .../Mapping/EntityListenerResolverTest.php | 7 ---- 5 files changed, 27 insertions(+), 71 deletions(-) diff --git a/lib/Doctrine/ORM/Event/ListenersInvoker.php b/lib/Doctrine/ORM/Event/ListenersInvoker.php index dacf0dcea31..d0ea7cfb250 100644 --- a/lib/Doctrine/ORM/Event/ListenersInvoker.php +++ b/lib/Doctrine/ORM/Event/ListenersInvoker.php @@ -15,20 +15,16 @@ */ class ListenersInvoker { - public const INVOKE_NONE = 0; - public const INVOKE_LISTENERS = 1; - public const INVOKE_CALLBACKS = 2; - public const INVOKE_MANAGER = 4; + final public const INVOKE_NONE = 0; + final public const INVOKE_LISTENERS = 1; + final public const INVOKE_CALLBACKS = 2; + final public const INVOKE_MANAGER = 4; - /** @var EntityListenerResolver The Entity listener resolver. */ - private $resolver; + /** The Entity listener resolver. */ + private readonly EntityListenerResolver $resolver; - /** - * The EventManager used for dispatching events. - * - * @var EventManager - */ - private $eventManager; + /** The EventManager used for dispatching events. */ + private readonly EventManager $eventManager; public function __construct(EntityManagerInterface $em) { @@ -42,10 +38,9 @@ public function __construct(EntityManagerInterface $em) * @param ClassMetadata $metadata The entity metadata. * @param string $eventName The entity lifecycle event. * - * @return int Bitmask of subscribed event systems. - * @psalm-return int-mask-of + * @psalm-return int-mask-of Bitmask of subscribed event systems. */ - public function getSubscribedSystems(ClassMetadata $metadata, $eventName) + public function getSubscribedSystems(ClassMetadata $metadata, string $eventName): int { $invoke = self::INVOKE_NONE; @@ -71,13 +66,15 @@ public function getSubscribedSystems(ClassMetadata $metadata, $eventName) * @param string $eventName The entity lifecycle event. * @param object $entity The Entity on which the event occurred. * @param EventArgs $event The Event args. - * @param int $invoke Bitmask to invoke listeners. - * @psalm-param int-mask-of $invoke - * - * @return void + * @psalm-param int-mask-of $invoke Bitmask to invoke listeners. */ - public function invoke(ClassMetadata $metadata, $eventName, $entity, EventArgs $event, $invoke) - { + public function invoke( + ClassMetadata $metadata, + string $eventName, + object $entity, + EventArgs $event, + int $invoke + ): void { if ($invoke & self::INVOKE_CALLBACKS) { foreach ($metadata->lifecycleCallbacks[$eventName] as $callback) { $entity->$callback($event); diff --git a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php b/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php index e89263d83c8..fbe3118155e 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php +++ b/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php @@ -4,12 +4,7 @@ namespace Doctrine\ORM\Mapping; -use InvalidArgumentException; - use function get_class; -use function gettype; -use function is_object; -use function sprintf; use function trim; /** @@ -18,12 +13,9 @@ class DefaultEntityListenerResolver implements EntityListenerResolver { /** @psalm-var array Map to store entity listener instances. */ - private $instances = []; + private array $instances = []; - /** - * {@inheritdoc} - */ - public function clear($className = null) + public function clear(?string $className = null): void { if ($className === null) { $this->instances = []; @@ -32,33 +24,18 @@ public function clear($className = null) } $className = trim($className, '\\'); - if (isset($this->instances[$className])) { - unset($this->instances[$className]); - } + unset($this->instances[$className]); } - /** - * {@inheritdoc} - */ - public function register($object) + public function register(object $object): void { - if (! is_object($object)) { - throw new InvalidArgumentException(sprintf('An object was expected, but got "%s".', gettype($object))); - } - $this->instances[get_class($object)] = $object; } - /** - * {@inheritdoc} - */ - public function resolve($className) + public function resolve(string $className): object { $className = trim($className, '\\'); - if (isset($this->instances[$className])) { - return $this->instances[$className]; - } - return $this->instances[$className] = new $className(); + return $this->instances[$className] ??= new $className(); } } diff --git a/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php b/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php index 2a10a2f9fa2..7cfed783876 100644 --- a/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php +++ b/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php @@ -13,26 +13,18 @@ interface EntityListenerResolver * Clear all instances from the set, or a specific instance when given its identifier. * * @param string|null $className May be any arbitrary string. Name kept for BC only. - * - * @return void */ - public function clear($className = null); + public function clear(?string $className = null): void; /** * Returns a entity listener instance for the given identifier. * * @param string $className May be any arbitrary string. Name kept for BC only. - * - * @return object An entity listener */ - public function resolve($className); + public function resolve(string $className): object; /** * Register a entity listener instance. - * - * @param object $object An entity listener - * - * @return void */ - public function register($object); + public function register(object $object): void; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 921f32178d7..158d6575ce5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -503,9 +503,6 @@ - - is_object($object) - new $className() diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index f1e20934feb..64af718f92a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -87,11 +87,4 @@ public function testClearAll(): void self::assertNotSame($obj1, $this->resolver->resolve($className1)); self::assertNotSame($obj2, $this->resolver->resolve($className2)); } - - public function testRegisterStringException(): void - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('An object was expected, but got "string".'); - $this->resolver->register('CompanyContractListener'); - } } From 3cd2562626b5a41262fcf9a06cdd65b051ff6b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 27 Aug 2022 21:19:49 +0200 Subject: [PATCH 156/475] Upgrade to doctrine/coding-standard 10.0 --- composer.json | 2 +- lib/Doctrine/ORM/AbstractQuery.php | 66 +- lib/Doctrine/ORM/Cache.php | 8 +- lib/Doctrine/ORM/Cache/CacheConfiguration.php | 14 +- lib/Doctrine/ORM/Cache/CacheFactory.php | 2 +- .../ORM/Cache/CollectionCacheEntry.php | 4 +- lib/Doctrine/ORM/Cache/CollectionHydrator.php | 10 +- lib/Doctrine/ORM/Cache/ConcurrentRegion.php | 2 +- lib/Doctrine/ORM/Cache/DefaultCache.php | 18 +- .../ORM/Cache/DefaultCacheFactory.php | 16 +- .../ORM/Cache/DefaultCollectionHydrator.php | 9 +- .../ORM/Cache/DefaultEntityHydrator.php | 6 +- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 16 +- lib/Doctrine/ORM/Cache/EntityHydrator.php | 2 +- .../CannotUpdateReadOnlyCollection.php | 2 +- .../Cache/Exception/NonCacheableEntity.php | 2 +- .../NonCacheableEntityAssociation.php | 2 +- lib/Doctrine/ORM/Cache/Lock.php | 2 +- .../ORM/Cache/Logging/CacheLoggerChain.php | 6 +- .../Cache/Logging/StatisticsCacheLogger.php | 12 +- .../AbstractCollectionPersister.php | 15 +- .../Collection/CachedCollectionPersister.php | 2 +- .../ReadOnlyCachedCollectionPersister.php | 2 +- .../ReadWriteCachedCollectionPersister.php | 4 +- .../Entity/AbstractEntityPersister.php | 58 +- lib/Doctrine/ORM/Cache/QueryCache.php | 6 +- lib/Doctrine/ORM/Cache/QueryCacheEntry.php | 10 +- lib/Doctrine/ORM/Cache/QueryCacheKey.php | 8 +- lib/Doctrine/ORM/Cache/Region.php | 6 +- .../ORM/Cache/Region/DefaultRegion.php | 13 +- .../ORM/Cache/Region/FileLockRegion.php | 15 +- .../ORM/Cache/RegionsConfiguration.php | 2 +- .../ORM/Cache/TimestampCacheEntry.php | 2 +- lib/Doctrine/ORM/Cache/TimestampCacheKey.php | 4 +- .../Cache/TimestampQueryCacheValidator.php | 5 +- lib/Doctrine/ORM/Configuration.php | 18 +- .../ORM/Decorator/EntityManagerDecorator.php | 8 +- lib/Doctrine/ORM/EntityManager.php | 20 +- lib/Doctrine/ORM/EntityManagerInterface.php | 8 +- lib/Doctrine/ORM/EntityNotFoundException.php | 4 +- lib/Doctrine/ORM/EntityRepository.php | 28 +- lib/Doctrine/ORM/Event/LifecycleEventArgs.php | 10 +- lib/Doctrine/ORM/Event/ListenersInvoker.php | 2 +- .../OnClassMetadataNotFoundEventArgs.php | 10 +- lib/Doctrine/ORM/Event/OnClearEventArgs.php | 2 +- lib/Doctrine/ORM/Event/OnFlushEventArgs.php | 2 +- lib/Doctrine/ORM/Event/PostFlushEventArgs.php | 2 +- lib/Doctrine/ORM/Event/PreFlushEventArgs.php | 2 +- lib/Doctrine/ORM/Event/PreUpdateEventArgs.php | 2 +- .../ORM/Exception/EntityMissingAssignedId.php | 4 +- .../ORM/Exception/InvalidEntityRepository.php | 2 +- .../ORM/Exception/MismatchedEventManager.php | 2 +- .../ORM/Exception/MissingIdentifierField.php | 2 +- .../MissingMappingDriverImplementation.php | 2 +- .../MultipleSelectorsFoundException.php | 8 +- lib/Doctrine/ORM/Exception/NotSupported.php | 4 +- .../Exception/UnexpectedAssociationValue.php | 4 +- .../UnrecognizedIdentifierFields.php | 6 +- lib/Doctrine/ORM/Id/AbstractIdGenerator.php | 2 +- lib/Doctrine/ORM/Id/AssignedGenerator.php | 2 +- .../ORM/Id/BigIntegerIdentityGenerator.php | 2 +- lib/Doctrine/ORM/Id/IdentityGenerator.php | 2 +- lib/Doctrine/ORM/Id/SequenceGenerator.php | 18 +- .../Internal/Hydration/AbstractHydrator.php | 12 +- .../ORM/Internal/Hydration/ArrayHydrator.php | 4 +- .../Internal/Hydration/HydrationException.php | 12 +- .../ORM/Internal/Hydration/ObjectHydrator.php | 4 +- .../Hydration/SimpleObjectHydrator.php | 6 +- .../ORM/Internal/HydrationCompleteHandler.php | 2 +- lib/Doctrine/ORM/Internal/QueryType.php | 4 +- lib/Doctrine/ORM/Internal/SQLResultCasing.php | 4 +- .../ORM/Mapping/AnsiQuoteStrategy.php | 6 +- .../ORM/Mapping/AssociationOverride.php | 6 +- .../ORM/Mapping/AssociationOverrides.php | 4 +- .../ORM/Mapping/AttributeOverrides.php | 4 +- .../Mapping/Builder/AssociationBuilder.php | 42 +- .../Mapping/Builder/ClassMetadataBuilder.php | 16 +- .../ORM/Mapping/Builder/EmbeddedBuilder.php | 4 +- .../ORM/Mapping/Builder/FieldBuilder.php | 4 +- .../Builder/ManyToManyAssociationBuilder.php | 4 +- .../Builder/OneToManyAssociationBuilder.php | 4 +- lib/Doctrine/ORM/Mapping/Cache.php | 2 +- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 2 +- .../ORM/Mapping/ClassMetadataFactory.php | 30 +- .../ORM/Mapping/ClassMetadataInfo.php | 50 +- lib/Doctrine/ORM/Mapping/Column.php | 16 +- .../ORM/Mapping/CustomIdGenerator.php | 2 +- .../Mapping/DefaultEntityListenerResolver.php | 2 +- .../ORM/Mapping/DefaultNamingStrategy.php | 2 +- .../ORM/Mapping/DefaultQuoteStrategy.php | 6 +- .../ORM/Mapping/DiscriminatorColumn.php | 8 +- lib/Doctrine/ORM/Mapping/DiscriminatorMap.php | 4 +- .../ORM/Mapping/Driver/AnnotationDriver.php | 24 +- .../ORM/Mapping/Driver/AttributeDriver.php | 20 +- .../ORM/Mapping/Driver/AttributeReader.php | 14 +- .../ORM/Mapping/Driver/DatabaseDriver.php | 12 +- lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 22 +- lib/Doctrine/ORM/Mapping/Embedded.php | 8 +- lib/Doctrine/ORM/Mapping/Entity.php | 6 +- .../ORM/Mapping/EntityListenerResolver.php | 2 +- lib/Doctrine/ORM/Mapping/EntityListeners.php | 4 +- .../Mapping/Exception/CannotGenerateIds.php | 2 +- .../Exception/InvalidCustomGenerator.php | 6 +- lib/Doctrine/ORM/Mapping/Index.php | 10 +- lib/Doctrine/ORM/Mapping/JoinColumn.php | 18 +- lib/Doctrine/ORM/Mapping/JoinTable.php | 10 +- lib/Doctrine/ORM/Mapping/ManyToMany.php | 8 +- lib/Doctrine/ORM/Mapping/ManyToOne.php | 6 +- lib/Doctrine/ORM/Mapping/MappedSuperclass.php | 6 +- lib/Doctrine/ORM/Mapping/MappingException.php | 112 ++- lib/Doctrine/ORM/Mapping/NamingStrategy.php | 2 +- lib/Doctrine/ORM/Mapping/OneToMany.php | 8 +- lib/Doctrine/ORM/Mapping/OneToOne.php | 10 +- lib/Doctrine/ORM/Mapping/OrderBy.php | 4 +- lib/Doctrine/ORM/Mapping/QuoteStrategy.php | 4 +- .../Mapping/ReflectionEmbeddedProperty.php | 6 +- .../ORM/Mapping/ReflectionEnumProperty.php | 14 +- .../Mapping/ReflectionReadonlyProperty.php | 8 +- .../ORM/Mapping/SequenceGenerator.php | 4 +- lib/Doctrine/ORM/Mapping/Table.php | 10 +- .../ORM/Mapping/UnderscoreNamingStrategy.php | 11 +- lib/Doctrine/ORM/Mapping/UniqueConstraint.php | 8 +- lib/Doctrine/ORM/NativeQuery.php | 6 +- lib/Doctrine/ORM/NonUniqueResultException.php | 2 +- .../ORM/ORMInvalidArgumentException.php | 22 +- lib/Doctrine/ORM/ORMSetup.php | 26 +- lib/Doctrine/ORM/OptimisticLockException.php | 6 +- lib/Doctrine/ORM/PersistentCollection.php | 12 +- .../AbstractCollectionPersister.php | 2 +- .../Collection/CollectionPersister.php | 2 +- .../Collection/ManyToManyPersister.php | 24 +- .../Collection/OneToManyPersister.php | 10 +- .../AbstractEntityInheritancePersister.php | 2 +- .../Entity/BasicEntityPersister.php | 86 +- .../Entity/CachedPersisterContext.php | 6 +- .../ORM/Persisters/Entity/EntityPersister.php | 46 +- .../Entity/JoinedSubclassPersister.php | 8 +- .../Entity/SingleTablePersister.php | 4 +- ...MatchingAssociationFieldRequiresObject.php | 2 +- .../ORM/Persisters/PersisterException.php | 2 +- .../ORM/Persisters/SqlExpressionVisitor.php | 2 +- lib/Doctrine/ORM/PessimisticLockException.php | 4 +- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 6 +- lib/Doctrine/ORM/Query.php | 38 +- .../ORM/Query/AST/AggregateExpression.php | 12 +- .../ORM/Query/AST/ArithmeticExpression.php | 8 +- .../ORM/Query/AST/ArithmeticFactor.php | 16 +- lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php | 4 +- .../ORM/Query/AST/CoalesceExpression.php | 4 +- .../ORM/Query/AST/ComparisonExpression.php | 6 +- .../ORM/Query/AST/ConditionalExpression.php | 4 +- .../ORM/Query/AST/ConditionalFactor.php | 10 +- .../ORM/Query/AST/ConditionalPrimary.php | 8 +- .../ORM/Query/AST/ConditionalTerm.php | 4 +- lib/Doctrine/ORM/Query/AST/DeleteClause.php | 10 +- .../ORM/Query/AST/DeleteStatement.php | 10 +- .../EmptyCollectionComparisonExpression.php | 10 +- .../ORM/Query/AST/ExistsExpression.php | 10 +- lib/Doctrine/ORM/Query/AST/FromClause.php | 4 +- .../ORM/Query/AST/Functions/AbsFunction.php | 10 +- .../Query/AST/Functions/BitAndFunction.php | 10 +- .../ORM/Query/AST/Functions/BitOrFunction.php | 10 +- .../Query/AST/Functions/ConcatFunction.php | 8 +- .../AST/Functions/CurrentDateFunction.php | 8 +- .../AST/Functions/CurrentTimeFunction.php | 8 +- .../Functions/CurrentTimestampFunction.php | 8 +- .../Query/AST/Functions/DateAddFunction.php | 24 +- .../Query/AST/Functions/DateDiffFunction.php | 10 +- .../Query/AST/Functions/DateSubFunction.php | 20 +- .../ORM/Query/AST/Functions/FunctionNode.php | 18 +- .../Query/AST/Functions/LengthFunction.php | 10 +- .../Query/AST/Functions/LocateFunction.php | 10 +- .../ORM/Query/AST/Functions/LowerFunction.php | 10 +- .../ORM/Query/AST/Functions/ModFunction.php | 10 +- .../ORM/Query/AST/Functions/SizeFunction.php | 6 +- .../ORM/Query/AST/Functions/SqrtFunction.php | 10 +- .../Query/AST/Functions/SubstringFunction.php | 10 +- .../ORM/Query/AST/Functions/TrimFunction.php | 6 +- .../ORM/Query/AST/Functions/UpperFunction.php | 10 +- .../ORM/Query/AST/GeneralCaseExpression.php | 8 +- lib/Doctrine/ORM/Query/AST/GroupByClause.php | 4 +- lib/Doctrine/ORM/Query/AST/HavingClause.php | 10 +- .../AST/IdentificationVariableDeclaration.php | 21 +- lib/Doctrine/ORM/Query/AST/InExpression.php | 10 +- .../ORM/Query/AST/InstanceOfExpression.php | 4 +- lib/Doctrine/ORM/Query/AST/Join.php | 8 +- .../Query/AST/JoinAssociationDeclaration.php | 14 +- .../AST/JoinAssociationPathExpression.php | 10 +- .../ORM/Query/AST/JoinClassPathExpression.php | 6 +- .../ORM/Query/AST/JoinVariableDeclaration.php | 10 +- lib/Doctrine/ORM/Query/AST/LikeExpression.php | 14 +- lib/Doctrine/ORM/Query/AST/Literal.php | 8 +- .../ORM/Query/AST/NewObjectExpression.php | 8 +- .../Query/AST/NullComparisonExpression.php | 10 +- .../ORM/Query/AST/NullIfExpression.php | 10 +- lib/Doctrine/ORM/Query/AST/OrderByClause.php | 4 +- lib/Doctrine/ORM/Query/AST/OrderByItem.php | 18 +- .../ORM/Query/AST/PartialObjectExpression.php | 8 +- lib/Doctrine/ORM/Query/AST/PathExpression.php | 12 +- .../ORM/Query/AST/QuantifiedExpression.php | 22 +- .../Query/AST/RangeVariableDeclaration.php | 10 +- lib/Doctrine/ORM/Query/AST/SelectClause.php | 6 +- .../ORM/Query/AST/SelectExpression.php | 14 +- .../ORM/Query/AST/SelectStatement.php | 10 +- .../Query/AST/SimpleArithmeticExpression.php | 4 +- .../ORM/Query/AST/SimpleCaseExpression.php | 19 +- .../ORM/Query/AST/SimpleSelectClause.php | 10 +- .../ORM/Query/AST/SimpleSelectExpression.php | 10 +- .../ORM/Query/AST/SimpleWhenClause.php | 10 +- lib/Doctrine/ORM/Query/AST/Subselect.php | 10 +- .../ORM/Query/AST/SubselectFromClause.php | 4 +- ...electIdentificationVariableDeclaration.php | 10 +- lib/Doctrine/ORM/Query/AST/UpdateClause.php | 8 +- lib/Doctrine/ORM/Query/AST/UpdateItem.php | 10 +- .../ORM/Query/AST/UpdateStatement.php | 10 +- lib/Doctrine/ORM/Query/AST/WhenClause.php | 10 +- lib/Doctrine/ORM/Query/AST/WhereClause.php | 10 +- .../ORM/Query/Exec/AbstractSqlExecutor.php | 4 +- .../Query/Exec/MultiTableUpdateExecutor.php | 2 +- .../Exec/SingleTableDeleteUpdateExecutor.php | 4 +- lib/Doctrine/ORM/Query/Expr/Andx.php | 4 +- lib/Doctrine/ORM/Query/Expr/Base.php | 10 +- lib/Doctrine/ORM/Query/Expr/Comparison.php | 30 +- lib/Doctrine/ORM/Query/Expr/Composite.php | 8 +- lib/Doctrine/ORM/Query/Expr/From.php | 30 +- lib/Doctrine/ORM/Query/Expr/Func.php | 18 +- lib/Doctrine/ORM/Query/Expr/GroupBy.php | 4 +- lib/Doctrine/ORM/Query/Expr/Join.php | 20 +- lib/Doctrine/ORM/Query/Expr/Literal.php | 4 +- lib/Doctrine/ORM/Query/Expr/Math.php | 30 +- lib/Doctrine/ORM/Query/Expr/OrderBy.php | 8 +- lib/Doctrine/ORM/Query/Expr/Orx.php | 4 +- lib/Doctrine/ORM/Query/Expr/Select.php | 4 +- lib/Doctrine/ORM/Query/Filter/SQLFilter.php | 6 +- lib/Doctrine/ORM/Query/FilterCollection.php | 2 +- lib/Doctrine/ORM/Query/Parser.php | 68 +- lib/Doctrine/ORM/Query/QueryException.php | 36 +- .../ORM/Query/QueryExpressionVisitor.php | 14 +- lib/Doctrine/ORM/Query/ResultSetMapping.php | 10 +- .../ORM/Query/ResultSetMappingBuilder.php | 14 +- lib/Doctrine/ORM/Query/SqlWalker.php | 32 +- lib/Doctrine/ORM/Query/TreeWalkerAdapter.php | 2 +- lib/Doctrine/ORM/Query/TreeWalkerChain.php | 6 +- lib/Doctrine/ORM/QueryBuilder.php | 72 +- .../Repository/DefaultRepositoryFactory.php | 2 +- .../Exception/InvalidFindByCall.php | 4 +- .../Exception/InvalidMagicMethodCall.php | 4 +- .../Tools/AttachEntityListenersListener.php | 2 +- .../ClearCache/CollectionRegionCommand.php | 11 +- .../ClearCache/EntityRegionCommand.php | 7 +- .../Command/ClearCache/MetadataCommand.php | 3 +- .../Command/ClearCache/QueryRegionCommand.php | 7 +- .../Command/ClearCache/ResultCommand.php | 3 +- .../Command/GenerateProxiesCommand.php | 4 +- .../ORM/Tools/Console/Command/InfoCommand.php | 7 +- .../Command/MappingDescribeCommand.php | 19 +- .../Tools/Console/Command/RunDqlCommand.php | 2 +- .../Command/SchemaTool/AbstractCommand.php | 4 +- .../Command/SchemaTool/CreateCommand.php | 3 +- .../Command/SchemaTool/DropCommand.php | 5 +- .../Command/SchemaTool/UpdateCommand.php | 7 +- .../Console/Command/ValidateSchemaCommand.php | 4 +- .../ORM/Tools/Console/ConsoleRunner.php | 4 +- .../UnknownManagerException.php | 6 +- .../ORM/Tools/Console/MetadataFilter.php | 10 +- .../ORM/Tools/DebugUnitOfWorkListener.php | 2 +- .../Tools/Event/GenerateSchemaEventArgs.php | 2 +- .../Event/GenerateSchemaTableEventArgs.php | 2 +- .../Exception/MissingColumnException.php | 2 +- .../Tools/Pagination/CountOutputWalker.php | 6 +- .../ORM/Tools/Pagination/CountWalker.php | 4 +- .../Pagination/LimitSubqueryOutputWalker.php | 30 +- .../Tools/Pagination/LimitSubqueryWalker.php | 8 +- .../ORM/Tools/Pagination/Paginator.php | 14 +- .../Pagination/RowNumberOverFunction.php | 6 +- .../ORM/Tools/Pagination/WhereInWalker.php | 16 +- .../ORM/Tools/ResolveTargetEntityListener.php | 10 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 48 +- lib/Doctrine/ORM/Tools/ToolsException.php | 2 +- .../ORM/TransactionRequiredException.php | 4 +- lib/Doctrine/ORM/UnitOfWork.php | 50 +- .../HierarchyDiscriminatorResolver.php | 6 +- .../ORM/Utility/IdentifierFlattener.php | 4 +- lib/Doctrine/ORM/Utility/PersisterHelper.php | 2 +- .../UnitOfWorkComputeChangesBench.php | 10 +- .../Performance/EntityManagerFactory.php | 4 +- ...etchJoinArrayHydrationPerformanceBench.php | 10 +- ...oinFullObjectHydrationPerformanceBench.php | 10 +- ...PartialObjectHydrationPerformanceBench.php | 10 +- .../Hydration/SimpleHydrationBench.php | 8 +- .../SimpleInsertPerformanceBench.php | 10 +- ...pleQueryArrayHydrationPerformanceBench.php | 10 +- ...eryFullObjectHydrationPerformanceBench.php | 10 +- ...PartialObjectHydrationPerformanceBench.php | 10 +- ...leQueryScalarHydrationPerformanceBench.php | 10 +- ...leInheritanceHydrationPerformanceBench.php | 12 +- ...TableInheritanceInsertPerformanceBench.php | 6 +- .../ProxyInitializationTimeBench.php | 12 +- .../ProxyInstantiationTimeBench.php | 4 +- .../Performance/Mock/NonLoadingPersister.php | 10 +- .../Mock/NonProxyLoadingEntityManager.php | 10 +- .../QueryBoundParameterProcessingBench.php | 8 +- .../Mapping/class-metadata-constructor.php | 4 +- .../Doctrine/StaticAnalysis/get-metadata.php | 4 +- .../Tests/DbalExtensions/Connection.php | 2 +- .../Tests/DbalExtensions/QueryLog.php | 14 +- .../Tests/DbalExtensions/SqlLogger.php | 2 +- tests/Doctrine/Tests/DbalTypes/Rot13Type.php | 4 +- tests/Doctrine/Tests/DoctrineTestCase.php | 8 +- tests/Doctrine/Tests/Mocks/CacheKeyMock.php | 4 +- .../Doctrine/Tests/Mocks/CacheRegionMock.php | 9 +- .../Tests/Mocks/ConcurrentRegionMock.php | 13 +- .../Tests/Mocks/CustomTreeWalkerJoin.php | 2 +- .../Tests/Mocks/EntityManagerMock.php | 6 +- .../Tests/Mocks/EntityPersisterMock.php | 8 +- .../Tests/Mocks/ExceptionConverterMock.php | 2 +- tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php | 2 +- .../Doctrine/Tests/Models/CMS/CmsAddress.php | 16 +- .../Tests/Models/CMS/CmsAddressDTO.php | 2 +- .../Doctrine/Tests/Models/CMS/CmsEmployee.php | 2 +- tests/Doctrine/Tests/Models/CMS/CmsGroup.php | 8 +- .../Tests/Models/CMS/CmsPhonenumber.php | 2 +- tests/Doctrine/Tests/Models/CMS/CmsTag.php | 4 +- tests/Doctrine/Tests/Models/CMS/CmsUser.php | 24 +- .../Doctrine/Tests/Models/CMS/CmsUserDTO.php | 2 +- tests/Doctrine/Tests/Models/Cache/Action.php | 2 +- tests/Doctrine/Tests/Models/Cache/Address.php | 6 +- .../Tests/Models/Cache/Attraction.php | 10 +- tests/Doctrine/Tests/Models/Cache/Bar.php | 4 +- tests/Doctrine/Tests/Models/Cache/Beach.php | 4 +- tests/Doctrine/Tests/Models/Cache/City.php | 28 +- tests/Doctrine/Tests/Models/Cache/Client.php | 6 +- .../Tests/Models/Cache/ComplexAction.php | 12 +- tests/Doctrine/Tests/Models/Cache/Country.php | 6 +- tests/Doctrine/Tests/Models/Cache/Flight.php | 2 +- tests/Doctrine/Tests/Models/Cache/Login.php | 6 +- tests/Doctrine/Tests/Models/Cache/Person.php | 6 +- .../Tests/Models/Cache/Restaurant.php | 4 +- tests/Doctrine/Tests/Models/Cache/State.php | 16 +- tests/Doctrine/Tests/Models/Cache/Token.php | 8 +- tests/Doctrine/Tests/Models/Cache/Travel.php | 6 +- .../Doctrine/Tests/Models/Cache/Traveler.php | 10 +- .../Tests/Models/Cache/TravelerProfile.php | 8 +- .../Models/Cache/TravelerProfileInfo.php | 6 +- .../Tests/Models/Company/CompanyAuction.php | 2 +- .../Tests/Models/Company/CompanyCar.php | 8 +- .../Tests/Models/Company/CompanyContract.php | 14 +- .../Company/CompanyContractListener.php | 32 +- .../Tests/Models/Company/CompanyEmployee.php | 8 +- .../Tests/Models/Company/CompanyEvent.php | 2 +- .../Models/Company/CompanyFixContract.php | 6 +- .../Models/Company/CompanyFlexContract.php | 8 +- .../Company/CompanyFlexUltraContract.php | 2 +- .../CompanyFlexUltraContractListener.php | 8 +- .../Tests/Models/Company/CompanyManager.php | 4 +- .../Models/Company/CompanyOrganization.php | 8 +- .../Tests/Models/Company/CompanyPerson.php | 14 +- .../Tests/Models/Company/CompanyRaffle.php | 2 +- .../JoinedChildClass.php | 4 +- .../SingleChildClass.php | 4 +- .../CustomType/CustomIdObjectTypeChild.php | 6 +- .../CustomType/CustomIdObjectTypeParent.php | 2 +- .../Models/CustomType/CustomTypeParent.php | 8 +- .../Models/DDC117/DDC117ApproveChanges.php | 6 +- .../Tests/Models/DDC117/DDC117Article.php | 12 +- .../Models/DDC117/DDC117ArticleDetails.php | 9 +- .../Tests/Models/DDC117/DDC117Editor.php | 10 +- .../Tests/Models/DDC117/DDC117Link.php | 2 +- .../Tests/Models/DDC117/DDC117Reference.php | 10 +- .../Tests/Models/DDC117/DDC117Translation.php | 13 +- .../DDC1476EntityWithDefaultFieldType.php | 8 +- .../Tests/Models/DDC1872/DDC1872Bar.php | 4 +- .../DDC1872ExampleEntityWithoutOverride.php | 4 +- .../Tests/Models/DDC2372/DDC2372Address.php | 2 +- .../Tests/Models/DDC2372/DDC2372User.php | 2 +- .../Models/DDC2504/DDC2504ChildClass.php | 4 +- .../Models/DDC2504/DDC2504OtherClass.php | 4 +- .../Tests/Models/DDC3579/DDC3579Group.php | 16 +- .../Tests/Models/DDC3579/DDC3579User.php | 16 +- .../Tests/Models/DDC3597/DDC3597Media.php | 8 +- .../Tests/Models/DDC3711/DDC3711EntityB.php | 4 +- .../Models/DDC3899/DDC3899FixContract.php | 4 +- .../Models/DDC3899/DDC3899FlexContract.php | 4 +- .../Tests/Models/DDC4006/DDC4006User.php | 4 +- .../Tests/Models/DDC4006/DDC4006UserId.php | 4 +- .../Models/DDC5934/DDC5934BaseContract.php | 4 +- .../Tests/Models/DDC5934/DDC5934Member.php | 4 +- .../Tests/Models/DDC6412/DDC6412File.php | 4 +- .../DDC753EntityWithCustomRepository.php | 4 +- ...DC753EntityWithDefaultCustomRepository.php | 4 +- .../DDC753EntityWithInvalidRepository.php | 4 +- .../Models/DDC869/DDC869ChequePayment.php | 6 +- .../Models/DDC869/DDC869CreditCardPayment.php | 6 +- .../Tests/Models/DDC869/DDC869Payment.php | 8 +- .../Tests/Models/DDC889/DDC889Class.php | 2 +- .../Tests/Models/DDC889/DDC889Entity.php | 4 +- .../Tests/Models/DDC889/DDC889SuperClass.php | 6 +- .../Tests/Models/DDC964/DDC964Address.php | 36 +- .../Tests/Models/DDC964/DDC964Admin.php | 4 +- .../Tests/Models/DDC964/DDC964Group.php | 16 +- .../Tests/Models/DDC964/DDC964Guest.php | 2 +- .../Tests/Models/DDC964/DDC964User.php | 24 +- .../DtoWithArrayOfEnums.php | 4 +- .../DataTransferObjects/DtoWithEnum.php | 2 +- .../DirectoryTree/AbstractContentItem.php | 10 +- .../Tests/Models/DirectoryTree/Directory.php | 4 +- .../Tests/Models/DirectoryTree/File.php | 2 +- .../Tests/Models/ECommerce/ECommerceCart.php | 10 +- .../Models/ECommerce/ECommerceCategory.php | 14 +- .../Models/ECommerce/ECommerceCustomer.php | 10 +- .../Models/ECommerce/ECommerceFeature.php | 8 +- .../Models/ECommerce/ECommerceProduct.php | 22 +- tests/Doctrine/Tests/Models/Enums/Card.php | 4 +- .../Tests/Models/Enums/CardWithNullable.php | 4 +- tests/Doctrine/Tests/Models/Enums/Scale.php | 4 +- .../Models/Enums/TypedCardEnumCompositeId.php | 4 +- .../Tests/Models/Enums/TypedCardEnumId.php | 4 +- .../Tests/Models/Forum/ForumAdministrator.php | 4 +- .../Models/Generic/NonAlphaColumnsEntity.php | 6 +- .../Doctrine/Tests/Models/GeoNames/Admin1.php | 6 +- .../Models/GeoNames/Admin1AlternateName.php | 6 +- tests/Doctrine/Tests/Models/GeoNames/City.php | 6 +- .../Tests/Models/GeoNames/Country.php | 6 +- .../AnotherChildClass.php | 4 +- .../JoinedInheritanceType/ChildClass.php | 4 +- .../Tests/Models/Legacy/LegacyCar.php | 4 +- .../Tests/Models/Legacy/LegacyUser.php | 8 +- .../Models/Legacy/LegacyUserReference.php | 6 +- .../Models/ManyToManyPersister/ChildClass.php | 2 +- .../ManyToManyPersister/OtherParentClass.php | 2 +- .../ManyToManyPersister/ParentClass.php | 2 +- .../Tests/Models/Navigation/NavCountry.php | 6 +- .../Tests/Models/Navigation/NavPhotos.php | 6 +- .../Models/Navigation/NavPointOfInterest.php | 14 +- .../Tests/Models/Navigation/NavTour.php | 6 +- .../Tests/Models/Navigation/NavUser.php | 6 +- .../Tests/Models/Pagination/User1.php | 4 +- .../PersistentCollectionContent.php | 4 +- .../PersistentCollectionHolder.php | 4 +- .../PersistentObject/PersistentEntity.php | 4 +- tests/Doctrine/Tests/Models/Quote/City.php | 6 +- .../Tests/Models/Quote/FullAddress.php | 4 +- tests/Doctrine/Tests/Models/Quote/Group.php | 8 +- .../Tests/Models/Quote/NumericEntity.php | 6 +- tests/Doctrine/Tests/Models/Quote/User.php | 10 +- .../Tests/Models/ReadonlyProperties/Book.php | 4 +- .../Tests/Models/Routing/RoutingLeg.php | 4 +- .../Tests/Models/Routing/RoutingLocation.php | 4 +- .../Tests/Models/Routing/RoutingRoute.php | 4 +- .../Models/Routing/RoutingRouteBooking.php | 4 +- .../Tests/Models/StockExchange/Bond.php | 6 +- .../Tests/Models/StockExchange/Market.php | 6 +- .../Tests/Models/StockExchange/Stock.php | 10 +- tests/Doctrine/Tests/Models/Taxi/Car.php | 4 +- tests/Doctrine/Tests/Models/Taxi/Driver.php | 2 +- tests/Doctrine/Tests/Models/Taxi/PaidRide.php | 2 +- tests/Doctrine/Tests/Models/Taxi/Ride.php | 2 +- .../Tests/Models/TypedProperties/Contact.php | 6 +- .../Models/TypedProperties/UserTyped.php | 30 +- .../Tests/Models/Upsertable/Insertable.php | 8 +- .../Tests/Models/Upsertable/Updatable.php | 8 +- .../Doctrine/Tests/ORM/AbstractQueryTest.php | 2 +- .../Doctrine/Tests/ORM/Cache/CacheKeyTest.php | 4 +- .../Tests/ORM/Cache/CacheLoggerChainTest.php | 4 +- .../ORM/Cache/DefaultCacheFactoryTest.php | 16 +- .../Tests/ORM/Cache/DefaultCacheTest.php | 4 +- .../Cache/DefaultCollectionHydratorTest.php | 6 +- .../ORM/Cache/DefaultEntityHydratorTest.php | 12 +- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 30 +- .../Tests/ORM/Cache/DefaultRegionTest.php | 6 +- .../Tests/ORM/Cache/FileLockRegionTest.php | 4 +- .../CollectionPersisterTestCase.php | 4 +- ...ReadWriteCachedCollectionPersisterTest.php | 4 +- .../ReadOnlyCachedCollectionPersisterTest.php | 4 +- ...ReadWriteCachedCollectionPersisterTest.php | 4 +- .../Entity/EntityPersisterTestCase.php | 10 +- ...rictReadWriteCachedEntityPersisterTest.php | 4 +- .../ReadOnlyCachedEntityPersisterTest.php | 4 +- .../ReadWriteCachedEntityPersisterTest.php | 4 +- .../Tests/ORM/Cache/RegionTestCase.php | 4 +- .../ORM/Cache/StatisticsCacheLoggerTest.php | 4 +- .../Doctrine/Tests/ORM/ConfigurationTest.php | 10 +- .../Tests/ORM/Entity/ConstructorTest.php | 2 +- .../Doctrine/Tests/ORM/EntityManagerTest.php | 18 +- .../Tests/ORM/EntityNotFoundExceptionTest.php | 4 +- .../AbstractManyToManyAssociationTestCase.php | 2 +- .../Functional/AdvancedAssociationTest.php | 20 +- .../ORM/Functional/AdvancedDqlQueryTest.php | 4 +- .../ORM/Functional/BasicFunctionalTest.php | 44 +- .../ORM/Functional/CascadeRemoveOrderTest.php | 22 +- .../ClassTableInheritanceSecondTest.php | 12 +- .../Functional/ClassTableInheritanceTest.php | 40 +- .../Functional/CompositePrimaryKeyTest.php | 8 +- .../ORM/Functional/CustomFunctionsTest.php | 2 +- .../ORM/Functional/CustomIdObjectTypeTest.php | 4 +- .../ORM/Functional/DatabaseDriverTest.php | 8 +- .../ORM/Functional/DatabaseDriverTestCase.php | 4 +- .../ORM/Functional/DefaultValuesTest.php | 10 +- .../ORM/Functional/DetachedEntityTest.php | 12 +- .../ORM/Functional/EntityListenersTest.php | 4 +- .../EntityRepositoryCriteriaTest.php | 10 +- .../ORM/Functional/EntityRepositoryTest.php | 188 ++--- .../Tests/ORM/Functional/EnumTest.php | 12 +- .../Functional/ExtraLazyCollectionTest.php | 102 +-- .../Tests/ORM/Functional/FlushEventTest.php | 4 +- .../ORM/Functional/HydrationCacheTest.php | 4 +- .../Tests/ORM/Functional/IdentityMapTest.php | 4 +- .../ORM/Functional/IndexByAssociationTest.php | 8 +- .../JoinedTableCompositeKeyTest.php | 6 +- .../ORM/Functional/LifecycleCallbackTest.php | 56 +- .../Functional/Locking/GearmanLockTest.php | 14 +- .../Functional/Locking/LockAgentWorker.php | 8 +- .../Tests/ORM/Functional/Locking/LockTest.php | 12 +- .../ORM/Functional/Locking/OptimisticTest.php | 24 +- .../ManyToManyBasicAssociationTest.php | 36 +- ...ManyToManyBidirectionalAssociationTest.php | 16 +- ...nyToManySelfReferentialAssociationTest.php | 16 +- .../Functional/ManyToOneOrphanRemovalTest.php | 10 +- .../Tests/ORM/Functional/NativeQueryTest.php | 38 +- .../Tests/ORM/Functional/NewOperatorTest.php | 34 +- .../Tests/ORM/Functional/NotifyPolicyTest.php | 12 +- .../OneToManyBidirectionalAssociationTest.php | 16 +- .../Functional/OneToManyOrphanRemovalTest.php | 16 +- ...OneToManyUnidirectionalAssociationTest.php | 2 +- .../Functional/OneToOneEagerLoadingTest.php | 81 +- ...eToOneInverseSideLoadAfterDqlQueryTest.php | 8 +- ...OneToOneSelfReferentialAssociationTest.php | 16 +- .../OneToOneSingleTableInheritanceTest.php | 2 +- .../OneToOneUnidirectionalAssociationTest.php | 6 +- ...edJoinedTableInheritanceCollectionTest.php | 12 +- .../Tests/ORM/Functional/PaginationTest.php | 146 +--- .../PersistentCollectionCriteriaTest.php | 2 +- .../Functional/PersistentCollectionTest.php | 2 +- .../ORM/Functional/PostLoadEventTest.php | 10 +- .../Functional/ProxiesLikeEntitiesTest.php | 2 +- .../QueryBuilderParenthesisTest.php | 10 +- .../Tests/ORM/Functional/QueryCacheTest.php | 12 +- .../ORM/Functional/QueryDqlFunctionTest.php | 24 +- .../Tests/ORM/Functional/QueryTest.php | 54 +- .../Tests/ORM/Functional/ReadOnlyTest.php | 26 +- .../ORM/Functional/ReadonlyPropertiesTest.php | 6 +- .../ORM/Functional/ReferenceProxyTest.php | 32 +- .../Tests/ORM/Functional/ResultCacheTest.php | 30 +- .../Tests/ORM/Functional/SQLFilterTest.php | 12 +- .../SchemaTool/CompanySchemaTest.php | 4 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 8 +- .../ORM/Functional/SchemaTool/DDC214Test.php | 16 +- .../SchemaTool/MySqlSchemaToolTest.php | 8 +- .../SchemaTool/PostgreSqlSchemaToolTest.php | 6 +- .../ORM/Functional/SchemaValidatorTest.php | 8 +- ...econdLevelCacheCompositePrimaryKeyTest.php | 4 +- .../SecondLevelCacheConcurrentTest.php | 4 +- .../SecondLevelCacheCriteriaTest.php | 20 +- ...econdLevelCacheExtraLazyCollectionTest.php | 4 +- .../SecondLevelCacheFunctionalTestCase.php | 4 +- ...condLevelCacheJoinTableInheritanceTest.php | 6 +- .../SecondLevelCacheManyToManyTest.php | 4 +- .../SecondLevelCacheManyToOneTest.php | 4 +- .../SecondLevelCacheOneToManyTest.php | 6 +- .../SecondLevelCacheOneToOneTest.php | 4 +- .../SecondLevelCacheQueryCacheTest.php | 8 +- .../SecondLevelCacheRepositoryTest.php | 4 +- ...ndLevelCacheSingleTableInheritanceTest.php | 6 +- .../ORM/Functional/SecondLevelCacheTest.php | 12 +- .../ORM/Functional/SequenceGeneratorTest.php | 4 +- .../SingleTableCompositeKeyTest.php | 4 +- .../Functional/SingleTableInheritanceTest.php | 42 +- .../StandardEntityPersisterTest.php | 4 +- .../ORM/Functional/Ticket/DDC1040Test.php | 4 +- .../ORM/Functional/Ticket/DDC1041Test.php | 4 +- .../ORM/Functional/Ticket/DDC1043Test.php | 4 +- .../ORM/Functional/Ticket/DDC1080Test.php | 18 +- .../ORM/Functional/Ticket/DDC1113Test.php | 14 +- .../ORM/Functional/Ticket/DDC1129Test.php | 4 +- .../ORM/Functional/Ticket/DDC1163Test.php | 34 +- .../ORM/Functional/Ticket/DDC117Test.php | 86 +- .../ORM/Functional/Ticket/DDC1181Test.php | 18 +- .../ORM/Functional/Ticket/DDC1193Test.php | 6 +- .../ORM/Functional/Ticket/DDC1209Test.php | 28 +- .../ORM/Functional/Ticket/DDC1225Test.php | 10 +- .../ORM/Functional/Ticket/DDC1228Test.php | 8 +- .../ORM/Functional/Ticket/DDC1238Test.php | 16 +- .../ORM/Functional/Ticket/DDC1250Test.php | 8 +- .../ORM/Functional/Ticket/DDC1300Test.php | 20 +- .../ORM/Functional/Ticket/DDC1301Test.php | 2 +- .../ORM/Functional/Ticket/DDC1306Test.php | 4 +- .../ORM/Functional/Ticket/DDC1335Test.php | 32 +- .../ORM/Functional/Ticket/DDC1400Test.php | 18 +- .../ORM/Functional/Ticket/DDC1430Test.php | 28 +- .../ORM/Functional/Ticket/DDC1436Test.php | 8 +- .../ORM/Functional/Ticket/DDC144Test.php | 6 +- .../ORM/Functional/Ticket/DDC1452Test.php | 18 +- .../ORM/Functional/Ticket/DDC1454Test.php | 8 +- .../ORM/Functional/Ticket/DDC1458Test.php | 10 +- .../ORM/Functional/Ticket/DDC1461Test.php | 6 +- .../ORM/Functional/Ticket/DDC1514Test.php | 18 +- .../ORM/Functional/Ticket/DDC1515Test.php | 14 +- .../ORM/Functional/Ticket/DDC1526Test.php | 8 +- .../ORM/Functional/Ticket/DDC1545Test.php | 10 +- .../ORM/Functional/Ticket/DDC1548Test.php | 18 +- .../ORM/Functional/Ticket/DDC1595Test.php | 12 +- .../ORM/Functional/Ticket/DDC163Test.php | 4 +- .../ORM/Functional/Ticket/DDC1643Test.php | 8 +- .../ORM/Functional/Ticket/DDC1654Test.php | 22 +- .../ORM/Functional/Ticket/DDC1655Test.php | 14 +- .../ORM/Functional/Ticket/DDC1666Test.php | 4 +- .../ORM/Functional/Ticket/DDC1685Test.php | 4 +- .../ORM/Functional/Ticket/DDC168Test.php | 4 +- .../ORM/Functional/Ticket/DDC1690Test.php | 8 +- .../ORM/Functional/Ticket/DDC1695Test.php | 6 +- .../ORM/Functional/Ticket/DDC1707Test.php | 14 +- .../ORM/Functional/Ticket/DDC1719Test.php | 10 +- .../ORM/Functional/Ticket/DDC1757Test.php | 18 +- .../ORM/Functional/Ticket/DDC1778Test.php | 8 +- .../ORM/Functional/Ticket/DDC1787Test.php | 10 +- .../ORM/Functional/Ticket/DDC1884Test.php | 4 +- .../ORM/Functional/Ticket/DDC1918Test.php | 4 +- .../ORM/Functional/Ticket/DDC1925Test.php | 4 +- .../ORM/Functional/Ticket/DDC192Test.php | 6 +- .../ORM/Functional/Ticket/DDC1995Test.php | 4 +- .../ORM/Functional/Ticket/DDC1998Test.php | 8 +- .../ORM/Functional/Ticket/DDC199Test.php | 2 +- .../ORM/Functional/Ticket/DDC2012Test.php | 2 +- .../ORM/Functional/Ticket/DDC2074Test.php | 4 +- .../ORM/Functional/Ticket/DDC2084Test.php | 16 +- .../ORM/Functional/Ticket/DDC2106Test.php | 8 +- .../ORM/Functional/Ticket/DDC211Test.php | 8 +- .../ORM/Functional/Ticket/DDC2138Test.php | 18 +- .../ORM/Functional/Ticket/DDC2175Test.php | 4 +- .../ORM/Functional/Ticket/DDC2182Test.php | 2 +- .../ORM/Functional/Ticket/DDC2224Test.php | 12 +- .../ORM/Functional/Ticket/DDC2230Test.php | 6 +- .../ORM/Functional/Ticket/DDC2252Test.php | 16 +- .../ORM/Functional/Ticket/DDC2306Test.php | 22 +- .../ORM/Functional/Ticket/DDC2346Test.php | 10 +- .../ORM/Functional/Ticket/DDC2350Test.php | 8 +- .../ORM/Functional/Ticket/DDC2359Test.php | 4 +- .../ORM/Functional/Ticket/DDC237Test.php | 2 +- .../ORM/Functional/Ticket/DDC2387Test.php | 4 +- .../ORM/Functional/Ticket/DDC2415Test.php | 12 +- .../ORM/Functional/Ticket/DDC2494Test.php | 14 +- .../ORM/Functional/Ticket/DDC2519Test.php | 8 +- .../ORM/Functional/Ticket/DDC2575Test.php | 32 +- .../ORM/Functional/Ticket/DDC2579Test.php | 29 +- .../ORM/Functional/Ticket/DDC258Test.php | 14 +- .../ORM/Functional/Ticket/DDC2602Test.php | 22 +- .../ORM/Functional/Ticket/DDC2655Test.php | 4 +- .../ORM/Functional/Ticket/DDC2660Test.php | 12 +- .../ORM/Functional/Ticket/DDC2692Test.php | 4 +- .../ORM/Functional/Ticket/DDC2759Test.php | 22 +- .../ORM/Functional/Ticket/DDC2775Test.php | 6 +- .../ORM/Functional/Ticket/DDC2780Test.php | 8 +- .../ORM/Functional/Ticket/DDC2790Test.php | 4 +- .../ORM/Functional/Ticket/DDC279Test.php | 20 +- .../ORM/Functional/Ticket/DDC2825Test.php | 10 +- .../ORM/Functional/Ticket/DDC2862Test.php | 12 +- .../ORM/Functional/Ticket/DDC2895Test.php | 2 +- .../ORM/Functional/Ticket/DDC2931Test.php | 6 +- .../ORM/Functional/Ticket/DDC2943Test.php | 4 +- .../ORM/Functional/Ticket/DDC2984Test.php | 12 +- .../ORM/Functional/Ticket/DDC2996Test.php | 16 +- .../ORM/Functional/Ticket/DDC3033Test.php | 14 +- .../ORM/Functional/Ticket/DDC3042Test.php | 16 +- .../ORM/Functional/Ticket/DDC3068Test.php | 4 +- .../ORM/Functional/Ticket/DDC309Test.php | 8 +- .../ORM/Functional/Ticket/DDC3103Test.php | 16 +- .../ORM/Functional/Ticket/DDC3123Test.php | 6 +- .../ORM/Functional/Ticket/DDC3160Test.php | 4 +- .../ORM/Functional/Ticket/DDC3170Test.php | 14 +- .../ORM/Functional/Ticket/DDC3192Test.php | 12 +- .../ORM/Functional/Ticket/DDC3223Test.php | 6 +- .../ORM/Functional/Ticket/DDC3300Test.php | 20 +- .../ORM/Functional/Ticket/DDC3303Test.php | 32 +- .../ORM/Functional/Ticket/DDC331Test.php | 6 +- .../ORM/Functional/Ticket/DDC3330Test.php | 4 +- .../ORM/Functional/Ticket/DDC3346Test.php | 10 +- .../ORM/Functional/Ticket/DDC345Test.php | 10 +- .../ORM/Functional/Ticket/DDC353Test.php | 10 +- .../ORM/Functional/Ticket/DDC3582Test.php | 2 +- .../ORM/Functional/Ticket/DDC3597Test.php | 10 +- .../ORM/Functional/Ticket/DDC3634Test.php | 10 +- .../ORM/Functional/Ticket/DDC3644Test.php | 34 +- .../ORM/Functional/Ticket/DDC3719Test.php | 4 +- .../ORM/Functional/Ticket/DDC371Test.php | 4 +- .../ORM/Functional/Ticket/DDC3785Test.php | 32 +- .../ORM/Functional/Ticket/DDC381Test.php | 4 +- .../ORM/Functional/Ticket/DDC4024Test.php | 4 +- .../ORM/Functional/Ticket/DDC422Test.php | 6 +- .../ORM/Functional/Ticket/DDC425Test.php | 4 +- .../ORM/Functional/Ticket/DDC440Test.php | 8 +- .../ORM/Functional/Ticket/DDC448Test.php | 4 +- .../ORM/Functional/Ticket/DDC493Test.php | 12 +- .../ORM/Functional/Ticket/DDC512Test.php | 10 +- .../ORM/Functional/Ticket/DDC513Test.php | 12 +- .../ORM/Functional/Ticket/DDC522Test.php | 6 +- .../ORM/Functional/Ticket/DDC531Test.php | 10 +- .../ORM/Functional/Ticket/DDC588Test.php | 10 +- .../ORM/Functional/Ticket/DDC599Test.php | 14 +- .../ORM/Functional/Ticket/DDC618Test.php | 34 +- .../ORM/Functional/Ticket/DDC6303Test.php | 22 +- .../ORM/Functional/Ticket/DDC633Test.php | 10 +- .../ORM/Functional/Ticket/DDC6460Test.php | 22 +- .../ORM/Functional/Ticket/DDC656Test.php | 4 +- .../ORM/Functional/Ticket/DDC657Test.php | 4 +- .../ORM/Functional/Ticket/DDC698Test.php | 2 +- .../Tests/ORM/Functional/Ticket/DDC69Test.php | 20 +- .../ORM/Functional/Ticket/DDC719Test.php | 18 +- .../ORM/Functional/Ticket/DDC735Test.php | 18 +- .../ORM/Functional/Ticket/DDC736Test.php | 4 +- .../ORM/Functional/Ticket/DDC767Test.php | 4 +- .../ORM/Functional/Ticket/DDC809Test.php | 10 +- .../ORM/Functional/Ticket/DDC812Test.php | 6 +- .../ORM/Functional/Ticket/DDC832Test.php | 48 +- .../ORM/Functional/Ticket/DDC837Test.php | 24 +- .../ORM/Functional/Ticket/DDC849Test.php | 2 +- .../ORM/Functional/Ticket/DDC881Test.php | 28 +- .../ORM/Functional/Ticket/DDC933Test.php | 4 +- .../ORM/Functional/Ticket/DDC949Test.php | 4 +- .../ORM/Functional/Ticket/DDC960Test.php | 14 +- .../ORM/Functional/Ticket/DDC992Test.php | 14 +- .../ORM/Functional/Ticket/GH2947Test.php | 6 +- .../ORM/Functional/Ticket/GH5562Test.php | 6 +- .../ORM/Functional/Ticket/GH5762Test.php | 20 +- .../ORM/Functional/Ticket/GH5804Test.php | 12 +- .../ORM/Functional/Ticket/GH5887Test.php | 20 +- .../ORM/Functional/Ticket/GH6029Test.php | 10 +- .../ORM/Functional/Ticket/GH6141Test.php | 16 +- .../ORM/Functional/Ticket/GH6217Test.php | 8 +- .../ORM/Functional/Ticket/GH6362Test.php | 14 +- .../ORM/Functional/Ticket/GH6394Test.php | 16 +- .../ORM/Functional/Ticket/GH6402Test.php | 4 +- .../ORM/Functional/Ticket/GH6464Test.php | 8 +- .../ORM/Functional/Ticket/GH6531Test.php | 58 +- .../ORM/Functional/Ticket/GH6682Test.php | 6 +- .../ORM/Functional/Ticket/GH6699Test.php | 4 +- .../ORM/Functional/Ticket/GH6740Test.php | 20 +- .../ORM/Functional/Ticket/GH6823Test.php | 2 +- .../ORM/Functional/Ticket/GH6937Test.php | 12 +- .../ORM/Functional/Ticket/GH7012Test.php | 12 +- .../ORM/Functional/Ticket/GH7062Test.php | 18 +- .../ORM/Functional/Ticket/GH7067Test.php | 4 +- .../ORM/Functional/Ticket/GH7068Test.php | 2 +- .../ORM/Functional/Ticket/GH7079Test.php | 8 +- .../ORM/Functional/Ticket/GH7259Test.php | 24 +- .../ORM/Functional/Ticket/GH7286Test.php | 36 +- .../ORM/Functional/Ticket/GH7366Test.php | 12 +- .../Ticket/GH7496WithToIterableTest.php | 34 +- .../ORM/Functional/Ticket/GH7505Test.php | 12 +- .../ORM/Functional/Ticket/GH7512Test.php | 8 +- .../ORM/Functional/Ticket/GH7629Test.php | 4 +- .../ORM/Functional/Ticket/GH7661Test.php | 26 +- .../ORM/Functional/Ticket/GH7735Test.php | 14 +- .../ORM/Functional/Ticket/GH7737Test.php | 24 +- .../ORM/Functional/Ticket/GH7761Test.php | 4 +- .../ORM/Functional/Ticket/GH7767Test.php | 26 +- .../ORM/Functional/Ticket/GH7820Test.php | 12 +- .../ORM/Functional/Ticket/GH7829Test.php | 4 +- .../ORM/Functional/Ticket/GH7836Test.php | 30 +- .../ORM/Functional/Ticket/GH7864Test.php | 14 +- .../ORM/Functional/Ticket/GH7869Test.php | 12 +- .../ORM/Functional/Ticket/GH7941Test.php | 14 +- .../ORM/Functional/Ticket/GH8055Test.php | 8 +- .../ORM/Functional/Ticket/GH8061Test.php | 8 +- .../ORM/Functional/Ticket/GH8217Test.php | 16 +- .../ORM/Functional/Ticket/GH8443Test.php | 24 +- .../ORM/Functional/Ticket/GH8499Test.php | 18 +- .../ORM/Functional/Ticket/GH8663Test.php | 4 +- .../ORM/Functional/Ticket/GH8914Test.php | 8 +- .../ORM/Functional/Ticket/GH9027Test.php | 6 +- .../ORM/Functional/Ticket/GH9109Test.php | 22 +- .../ORM/Functional/Ticket/GH9230Test.php | 8 +- .../ORM/Functional/Ticket/GH9335Test.php | 26 +- .../ORM/Functional/Ticket/GH9579Test.php | 10 +- .../ORM/Functional/Ticket/GH9807Test.php | 14 +- .../ORM/Functional/Ticket/Issue5989Test.php | 4 +- .../Ticket4646InstanceOfAbstractTest.php | 4 +- .../Ticket4646InstanceOfMultiLevelTest.php | 4 +- .../Ticket4646InstanceOfParametricTest.php | 6 +- .../Ticket/Ticket4646InstanceOfTest.php | 4 +- ...46InstanceOfWithMultipleParametersTest.php | 2 +- .../Tests/ORM/Functional/TypeTest.php | 4 +- .../Tests/ORM/Functional/TypeValueSqlTest.php | 4 +- .../ManyToManyCompositeIdForeignKeyTest.php | 42 +- .../ManyToManyCompositeIdTest.php | 30 +- .../ManyToManyExtraLazyTest.php | 20 +- .../ValueConversionType/ManyToManyTest.php | 30 +- .../OneToManyCompositeIdForeignKeyTest.php | 40 +- .../OneToManyCompositeIdTest.php | 28 +- .../OneToManyExtraLazyTest.php | 10 +- .../ValueConversionType/OneToManyTest.php | 28 +- .../OneToOneCompositeIdForeignKeyTest.php | 40 +- .../OneToOneCompositeIdTest.php | 28 +- .../ValueConversionType/OneToOneTest.php | 28 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 207 ++--- .../ORM/Functional/VersionedOneToOneTest.php | 2 +- .../ORM/Hydration/AbstractHydratorTest.php | 12 +- .../Tests/ORM/Hydration/ArrayHydratorTest.php | 20 +- .../ORM/Hydration/ObjectHydratorTest.php | 62 +- .../ORM/Hydration/ResultSetMappingTest.php | 6 +- .../Hydration/ScalarColumnHydratorTest.php | 2 +- .../ORM/Hydration/ScalarHydratorTest.php | 8 +- .../Hydration/SimpleObjectHydratorTest.php | 12 +- .../Hydration/SingleScalarHydratorTest.php | 8 +- .../Tests/ORM/Id/AssignedGeneratorTest.php | 4 +- .../Internal/HydrationCompleteHandlerTest.php | 20 +- .../Tests/ORM/LazyCriteriaCollectionTest.php | 4 +- .../ORM/Mapping/AnnotationDriverTest.php | 88 +- .../ORM/Mapping/AnsiQuoteStrategyTest.php | 8 +- .../Tests/ORM/Mapping/AttributeDriverTest.php | 2 +- .../Tests/ORM/Mapping/AttributeReaderTest.php | 4 +- .../Mapping/BasicInheritanceMappingTest.php | 24 +- .../ORM/Mapping/ClassMetadataBuilderTest.php | 58 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 36 +- .../Mapping/ClassMetadataLoadEventTest.php | 4 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 174 ++-- .../ORM/Mapping/DefaultQuoteStrategyTest.php | 2 +- .../Mapping/EntityListenerResolverTest.php | 4 +- .../ORM/Mapping/MappingDriverTestCase.php | 232 ++--- .../JoinColumnClassNamingStrategy.php | 2 +- .../Tests/ORM/Mapping/NamingStrategyTest.php | 36 +- .../Tests/ORM/Mapping/QuoteStrategyTest.php | 18 +- .../ReflectionEmbeddedPropertyTest.php | 6 +- .../ReflectionReadonlyPropertyTest.php | 4 +- .../ORM/Mapping/Symfony/DriverTestCase.php | 12 +- .../ORM/Mapping/Symfony/XmlDriverTest.php | 4 +- .../ORM/Mapping/XmlMappingDriverTest.php | 34 +- .../php/Doctrine.Tests.Models.Enums.Card.php | 4 +- ...ine.Tests.Models.Upsertable.Insertable.php | 8 +- ...rine.Tests.Models.Upsertable.Updatable.php | 8 +- .../ORM/ORMInvalidArgumentExceptionTest.php | 12 +- tests/Doctrine/Tests/ORM/ORMSetupTest.php | 18 +- .../Tests/ORM/PersistentCollectionTest.php | 24 +- .../BasicEntityPersisterTypeValueSqlTest.php | 20 +- .../JoinedSubclassPersisterTest.php | 4 +- .../Persisters/ManyToManyPersisterTest.php | 4 +- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 20 +- .../ORM/Query/CustomTreeWalkersJoinTest.php | 4 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 14 +- .../ORM/Query/DeleteSqlGenerationTest.php | 64 +- tests/Doctrine/Tests/ORM/Query/ExprTest.php | 26 +- .../Tests/ORM/Query/FilterCollectionTest.php | 4 +- .../ORM/Query/LanguageRecognitionTest.php | 92 +- tests/Doctrine/Tests/ORM/Query/LexerTest.php | 4 +- .../ORM/Query/ParameterTypeInfererTest.php | 4 +- .../ORM/Query/QueryExpressionVisitorTest.php | 14 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 86 +- .../ORM/Query/SelectSqlGenerationTest.php | 794 +++++++----------- .../Tests/ORM/Query/SqlWalkerTest.php | 10 +- .../ORM/Query/UpdateSqlGenerationTest.php | 40 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 92 +- .../DefaultRepositoryFactoryTest.php | 6 +- .../AttachEntityListenersListenerTest.php | 14 +- .../ClearCacheCollectionRegionCommandTest.php | 18 +- .../ClearCacheEntityRegionCommandTest.php | 18 +- .../ClearCacheQueryRegionCommandTest.php | 18 +- .../Tools/Console/Command/InfoCommandTest.php | 4 +- .../Command/MappingDescribeCommandTest.php | 6 +- .../Console/Command/RunDqlCommandTest.php | 8 +- .../SchemaTool/AbstractCommandTest.php | 6 +- .../Command/SchemaTool/CreateCommandTest.php | 4 +- .../Command/SchemaTool/DropCommandTest.php | 4 +- .../Command/SchemaTool/UpdateCommandTest.php | 4 +- .../Command/ValidateSchemaCommandTest.php | 4 +- .../Pagination/CountOutputWalkerTest.php | 20 +- .../ORM/Tools/Pagination/CountWalkerTest.php | 30 +- .../LimitSubqueryOutputWalkerTest.php | 104 ++- .../Pagination/LimitSubqueryWalkerTest.php | 26 +- .../Tools/Pagination/PaginationTestCase.php | 28 +- .../ORM/Tools/Pagination/PaginatorTest.php | 8 +- .../Tools/Pagination/WhereInWalkerTest.php | 72 +- .../Tools/ResolveTargetEntityListenerTest.php | 18 +- .../Tests/ORM/Tools/SchemaToolTest.php | 52 +- .../Tests/ORM/Tools/SchemaValidatorTest.php | 138 +-- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 32 +- .../HierarchyDiscriminatorResolverTest.php | 2 +- .../Utility/IdentifierFlattenerEnumIdTest.php | 10 +- .../ORM/Utility/IdentifierFlattenerTest.php | 14 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 34 +- tests/Doctrine/Tests/OrmTestCase.php | 14 +- tests/Doctrine/Tests/TestUtil.php | 12 +- 880 files changed, 4199 insertions(+), 7884 deletions(-) diff --git a/composer.json b/composer.json index f7344a0f21a..7cb45263c43 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ }, "require-dev": { "doctrine/annotations": "^1.13", - "doctrine/coding-standard": "^9.0.2", + "doctrine/coding-standard": "^10.0", "phpbench/phpbench": "^1.0", "phpstan/phpstan": "1.8.2", "phpunit/phpunit": "^9.5", diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 102190b0abd..8040aad1958 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -89,7 +89,7 @@ abstract class AbstractQuery /** * The user-specified ResultSetMapping to use. */ - protected ?ResultSetMapping $_resultSetMapping = null; + protected ResultSetMapping|null $_resultSetMapping = null; /** * The map of query hints. @@ -105,14 +105,14 @@ abstract class AbstractQuery */ protected string|int $_hydrationMode = self::HYDRATE_OBJECT; - protected ?QueryCacheProfile $_queryCacheProfile = null; + protected QueryCacheProfile|null $_queryCacheProfile = null; /** * Whether or not expire the result cache. */ protected bool $_expireResultCache = false; - protected ?QueryCacheProfile $_hydrationCacheProfile = null; + protected QueryCacheProfile|null $_hydrationCacheProfile = null; /** * Whether to use second level cache, if available. @@ -124,16 +124,16 @@ abstract class AbstractQuery /** * Second level cache region name. */ - protected ?string $cacheRegion = null; + protected string|null $cacheRegion = null; /** * Second level query cache mode. * * @psalm-var Cache::MODE_*|null */ - protected ?int $cacheMode = null; + protected int|null $cacheMode = null; - protected ?CacheLogger $cacheLogger = null; + protected CacheLogger|null $cacheLogger = null; protected int $lifetime = 0; @@ -144,7 +144,7 @@ public function __construct( /** * The entity manager used by this query object. */ - protected EntityManagerInterface $em + protected EntityManagerInterface $em, ) { $this->parameters = new ArrayCollection(); $this->_hints = $em->getConfiguration()->getDefaultQueryHints(); @@ -169,17 +169,13 @@ public function setCacheable(bool $cacheable): static return $this; } - /** - * @return bool TRUE if the query results are enabled for second level cache, FALSE otherwise. - */ + /** @return bool TRUE if the query results are enabled for second level cache, FALSE otherwise. */ public function isCacheable(): bool { return $this->cacheable; } - /** - * @return $this - */ + /** @return $this */ public function setCacheRegion(string $cacheRegion): static { $this->cacheRegion = $cacheRegion; @@ -192,14 +188,12 @@ public function setCacheRegion(string $cacheRegion): static * * @return string|null The cache region name; NULL indicates the default region. */ - public function getCacheRegion(): ?string + public function getCacheRegion(): string|null { return $this->cacheRegion; } - /** - * @return bool TRUE if the query cache and second level cache are enabled, FALSE otherwise. - */ + /** @return bool TRUE if the query cache and second level cache are enabled, FALSE otherwise. */ protected function isCacheEnabled(): bool { return $this->cacheable && $this->hasCache; @@ -222,10 +216,8 @@ public function setLifetime(int $lifetime): static return $this; } - /** - * @psalm-return Cache::MODE_*|null - */ - public function getCacheMode(): ?int + /** @psalm-return Cache::MODE_*|null */ + public function getCacheMode(): int|null { return $this->cacheMode; } @@ -288,7 +280,7 @@ public function getParameters(): ArrayCollection * * @return Parameter|null The value of the bound parameter, or NULL if not available. */ - public function getParameter(int|string $key): ?Parameter + public function getParameter(int|string $key): Parameter|null { $key = Parameter::normalizeName($key); @@ -450,7 +442,7 @@ public function setResultSetMapping(ResultSetMapping $rsm): static /** * Gets the ResultSetMapping used for hydration. */ - protected function getResultSetMapping(): ?ResultSetMapping + protected function getResultSetMapping(): ResultSetMapping|null { return $this->_resultSetMapping; } @@ -486,7 +478,7 @@ private function translateNamespaces(ResultSetMapping $rsm): void * $query->setHydrationCacheProfile(new QueryCacheProfile()); * $query->setHydrationCacheProfile(new QueryCacheProfile($lifetime, $resultKey)); */ - public function setHydrationCacheProfile(?QueryCacheProfile $profile): static + public function setHydrationCacheProfile(QueryCacheProfile|null $profile): static { if ($profile === null) { $this->_hydrationCacheProfile = null; @@ -506,7 +498,7 @@ public function setHydrationCacheProfile(?QueryCacheProfile $profile): static return $this; } - public function getHydrationCacheProfile(): ?QueryCacheProfile + public function getHydrationCacheProfile(): QueryCacheProfile|null { return $this->_hydrationCacheProfile; } @@ -519,7 +511,7 @@ public function getHydrationCacheProfile(): ?QueryCacheProfile * * @return $this */ - public function setResultCacheProfile(?QueryCacheProfile $profile): static + public function setResultCacheProfile(QueryCacheProfile|null $profile): static { if ($profile === null) { $this->_queryCacheProfile = null; @@ -542,7 +534,7 @@ public function setResultCacheProfile(?QueryCacheProfile $profile): static /** * Defines a cache driver to be used for caching result sets and implicitly enables caching. */ - public function setResultCache(?CacheItemPoolInterface $resultCache): static + public function setResultCache(CacheItemPoolInterface|null $resultCache): static { if ($resultCache === null) { if ($this->_queryCacheProfile) { @@ -568,7 +560,7 @@ public function setResultCache(?CacheItemPoolInterface $resultCache): static * * @return $this */ - public function enableResultCache(?int $lifetime = null, ?string $resultCacheId = null): static + public function enableResultCache(int|null $lifetime = null, string|null $resultCacheId = null): static { $this->setResultCacheLifetime($lifetime); $this->setResultCacheId($resultCacheId); @@ -595,7 +587,7 @@ public function disableResultCache(): static * * @return $this */ - public function setResultCacheLifetime(?int $lifetime): static + public function setResultCacheLifetime(int|null $lifetime): static { $lifetime = (int) $lifetime; @@ -639,7 +631,7 @@ public function getExpireResultCache(): bool return $this->_expireResultCache; } - public function getQueryCacheProfile(): ?QueryCacheProfile + public function getQueryCacheProfile(): QueryCacheProfile|null { return $this->_queryCacheProfile; } @@ -854,7 +846,7 @@ public function getHints(): array */ public function toIterable( ArrayCollection|array $parameters = [], - string|int|null $hydrationMode = null + string|int|null $hydrationMode = null, ): iterable { if ($hydrationMode !== null) { $this->setHydrationMode($hydrationMode); @@ -886,7 +878,7 @@ public function toIterable( */ public function execute( ArrayCollection|array|null $parameters = null, - string|int|null $hydrationMode = null + string|int|null $hydrationMode = null, ): mixed { if ($this->cacheable && $this->isCacheEnabled()) { return $this->executeUsingQueryCache($parameters, $hydrationMode); @@ -903,7 +895,7 @@ public function execute( */ private function executeIgnoreQueryCache( ArrayCollection|array|null $parameters = null, - string|int|null $hydrationMode = null + string|int|null $hydrationMode = null, ): mixed { if ($hydrationMode !== null) { $this->setHydrationMode($hydrationMode); @@ -974,7 +966,7 @@ private function getHydrationCache(): CacheItemPoolInterface */ private function executeUsingQueryCache( ArrayCollection|array|null $parameters = null, - string|int|null $hydrationMode = null + string|int|null $hydrationMode = null, ): mixed { $rsm = $this->getResultSetMapping(); if ($rsm === null) { @@ -986,7 +978,7 @@ private function executeUsingQueryCache( $this->getHash(), $this->lifetime, $this->cacheMode ?: Cache::MODE_NORMAL, - $this->getTimestampKey() + $this->getTimestampKey(), ); $result = $queryCache->get($queryKey, $rsm, $this->_hints); @@ -1013,7 +1005,7 @@ private function executeUsingQueryCache( return $result; } - private function getTimestampKey(): ?TimestampCacheKey + private function getTimestampKey(): TimestampCacheKey|null { assert($this->_resultSetMapping !== null); $entityName = reset($this->_resultSetMapping->aliasMap); @@ -1060,7 +1052,7 @@ protected function getHydrationCacheId(): array * If this is not explicitly set by the developer then a hash is automatically * generated for you. */ - public function setResultCacheId(?string $id): static + public function setResultCacheId(string|null $id): static { if (! $this->_queryCacheProfile) { return $this->setResultCacheProfile(new QueryCacheProfile(0, $id)); diff --git a/lib/Doctrine/ORM/Cache.php b/lib/Doctrine/ORM/Cache.php index 6e34f747839..8020b27546a 100644 --- a/lib/Doctrine/ORM/Cache.php +++ b/lib/Doctrine/ORM/Cache.php @@ -38,9 +38,9 @@ interface Cache */ public const MODE_REFRESH = 4; - public function getEntityCacheRegion(string $className): ?Region; + public function getEntityCacheRegion(string $className): Region|null; - public function getCollectionCacheRegion(string $className, string $association): ?Region; + public function getCollectionCacheRegion(string $className, string $association): Region|null; /** * Determine whether the cache contains data for the given entity "instance". @@ -90,7 +90,7 @@ public function containsQuery(string $regionName): bool; /** * Evicts all cached query results under the given name, or default query cache if the region name is NULL. */ - public function evictQueryRegion(?string $regionName = null): void; + public function evictQueryRegion(string|null $regionName = null): void; /** * Evict data from all query regions. @@ -102,5 +102,5 @@ public function evictQueryRegions(): void; * * @param string|null $regionName Query cache region name, or default query cache if the region name is NULL. */ - public function getQueryCache(?string $regionName = null): QueryCache; + public function getQueryCache(string|null $regionName = null): QueryCache; } diff --git a/lib/Doctrine/ORM/Cache/CacheConfiguration.php b/lib/Doctrine/ORM/Cache/CacheConfiguration.php index 99417792beb..0f8dea7682a 100644 --- a/lib/Doctrine/ORM/Cache/CacheConfiguration.php +++ b/lib/Doctrine/ORM/Cache/CacheConfiguration.php @@ -11,12 +11,12 @@ */ class CacheConfiguration { - private ?CacheFactory $cacheFactory = null; - private ?RegionsConfiguration $regionsConfig = null; - private ?CacheLogger $cacheLogger = null; - private ?QueryCacheValidator $queryValidator = null; + private CacheFactory|null $cacheFactory = null; + private RegionsConfiguration|null $regionsConfig = null; + private CacheLogger|null $cacheLogger = null; + private QueryCacheValidator|null $queryValidator = null; - public function getCacheFactory(): ?CacheFactory + public function getCacheFactory(): CacheFactory|null { return $this->cacheFactory; } @@ -26,7 +26,7 @@ public function setCacheFactory(CacheFactory $factory): void $this->cacheFactory = $factory; } - public function getCacheLogger(): ?CacheLogger + public function getCacheLogger(): CacheLogger|null { return $this->cacheLogger; } @@ -49,7 +49,7 @@ public function setRegionsConfiguration(RegionsConfiguration $regionsConfig): vo public function getQueryValidator(): QueryCacheValidator { return $this->queryValidator ??= new TimestampQueryCacheValidator( - $this->cacheFactory->getTimestampRegion() + $this->cacheFactory->getTimestampRegion(), ); } diff --git a/lib/Doctrine/ORM/Cache/CacheFactory.php b/lib/Doctrine/ORM/Cache/CacheFactory.php index 405ad86b74c..635a5ff5c30 100644 --- a/lib/Doctrine/ORM/Cache/CacheFactory.php +++ b/lib/Doctrine/ORM/Cache/CacheFactory.php @@ -32,7 +32,7 @@ public function buildCachedCollectionPersister(EntityManagerInterface $em, Colle /** * Build a query cache based on the given region name */ - public function buildQueryCache(EntityManagerInterface $em, ?string $regionName = null): QueryCache; + public function buildQueryCache(EntityManagerInterface $em, string|null $regionName = null): QueryCache; /** * Build an entity hydrator diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php index e5904bc44da..18229b20f8f 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php @@ -17,9 +17,7 @@ class CollectionCacheEntry implements CacheEntry */ public array $identifiers; - /** - * @param CacheKey[] $identifiers List of entity identifiers hold by the collection - */ + /** @param CacheKey[] $identifiers List of entity identifiers hold by the collection */ public function __construct(array $identifiers) { $this->identifiers = $identifiers; diff --git a/lib/Doctrine/ORM/Cache/CollectionHydrator.php b/lib/Doctrine/ORM/Cache/CollectionHydrator.php index db8ba112542..16a6572aa42 100644 --- a/lib/Doctrine/ORM/Cache/CollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/CollectionHydrator.php @@ -13,13 +13,9 @@ */ interface CollectionHydrator { - /** - * @param mixed[]|Collection $collection The collection. - */ + /** @param mixed[]|Collection $collection The collection. */ public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, array|Collection $collection): CollectionCacheEntry; - /** - * @return mixed[]|null - */ - public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): ?array; + /** @return mixed[]|null */ + public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): array|null; } diff --git a/lib/Doctrine/ORM/Cache/ConcurrentRegion.php b/lib/Doctrine/ORM/Cache/ConcurrentRegion.php index 3ea33ba45e6..e9ca8707422 100644 --- a/lib/Doctrine/ORM/Cache/ConcurrentRegion.php +++ b/lib/Doctrine/ORM/Cache/ConcurrentRegion.php @@ -22,7 +22,7 @@ interface ConcurrentRegion extends Region * * @throws LockException Indicates a problem accessing the region. */ - public function lock(CacheKey $key): ?Lock; + public function lock(CacheKey $key): Lock|null; /** * Attempts to read unlock the mapping for the given key. diff --git a/lib/Doctrine/ORM/Cache/DefaultCache.php b/lib/Doctrine/ORM/Cache/DefaultCache.php index f46fb12a996..04264e7eb94 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultCache.php @@ -29,10 +29,10 @@ class DefaultCache implements Cache */ private array $queryCaches = []; - private ?QueryCache $defaultQueryCache = null; + private QueryCache|null $defaultQueryCache = null; public function __construct( - private readonly EntityManagerInterface $em + private readonly EntityManagerInterface $em, ) { $this->uow = $em->getUnitOfWork(); $this->cacheFactory = $em->getConfiguration() @@ -40,7 +40,7 @@ public function __construct( ->getCacheFactory(); } - public function getEntityCacheRegion(string $className): ?Region + public function getEntityCacheRegion(string $className): Region|null { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getEntityPersister($metadata->rootEntityName); @@ -52,7 +52,7 @@ public function getEntityCacheRegion(string $className): ?Region return $persister->getCacheRegion(); } - public function getCollectionCacheRegion(string $className, string $association): ?Region + public function getCollectionCacheRegion(string $className, string $association): Region|null { $metadata = $this->em->getClassMetadata($className); $persister = $this->uow->getCollectionPersister($metadata->getAssociationMapping($association)); @@ -177,7 +177,7 @@ public function containsQuery(string $regionName): bool return isset($this->queryCaches[$regionName]); } - public function evictQueryRegion(?string $regionName = null): void + public function evictQueryRegion(string|null $regionName = null): void { if ($regionName === null && $this->defaultQueryCache !== null) { $this->defaultQueryCache->clear(); @@ -199,7 +199,7 @@ public function evictQueryRegions(): void } } - public function getQueryCache(?string $regionName = null): QueryCache + public function getQueryCache(string|null $regionName = null): QueryCache { if ($regionName === null) { return $this->defaultQueryCache ??= $this->cacheFactory->buildQueryCache($this->em); @@ -220,7 +220,7 @@ private function buildEntityCacheKey(ClassMetadata $metadata, mixed $identifier) private function buildCollectionCacheKey( ClassMetadata $metadata, string $association, - mixed $ownerIdentifier + mixed $ownerIdentifier, ): CollectionCacheKey { if (! is_array($ownerIdentifier)) { $ownerIdentifier = $this->toIdentifierArray($metadata, $ownerIdentifier); @@ -229,9 +229,7 @@ private function buildCollectionCacheKey( return new CollectionCacheKey($metadata->rootEntityName, $association, $ownerIdentifier); } - /** - * @return array - */ + /** @return array */ private function toIdentifierArray(ClassMetadata $metadata, mixed $identifier): array { if (is_object($identifier)) { diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 2ff5949cb10..07562f4d7df 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -31,18 +31,16 @@ class DefaultCacheFactory implements CacheFactory { - private CacheItemPoolInterface $cacheItemPool; private RegionsConfiguration $regionsConfig; - private ?TimestampRegion $timestampRegion = null; + private TimestampRegion|null $timestampRegion = null; /** @var Region[] */ private array $regions = []; - private ?string $fileLockRegionDirectory = null; + private string|null $fileLockRegionDirectory = null; - public function __construct(RegionsConfiguration $cacheConfig, CacheItemPoolInterface $cacheItemPool) + public function __construct(RegionsConfiguration $cacheConfig, private CacheItemPoolInterface $cacheItemPool) { - $this->cacheItemPool = $cacheItemPool; $this->regionsConfig = $cacheConfig; } @@ -118,7 +116,7 @@ public function buildCachedCollectionPersister(EntityManagerInterface $em, Colle throw new InvalidArgumentException(sprintf('Unrecognized access strategy type [%s]', $usage)); } - public function buildQueryCache(EntityManagerInterface $em, ?string $regionName = null): QueryCache + public function buildQueryCache(EntityManagerInterface $em, string|null $regionName = null): QueryCache { return new DefaultQueryCache( $em, @@ -126,8 +124,8 @@ public function buildQueryCache(EntityManagerInterface $em, ?string $regionName [ 'region' => $regionName ?: Cache::DEFAULT_QUERY_REGION_NAME, 'usage' => ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE, - ] - ) + ], + ), ); } @@ -164,7 +162,7 @@ public function getRegion(array $cache): Region ) { throw new LogicException( 'If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, ' . - 'The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory, DefaultCacheFactory#setFileLockRegionDirectory(). ' + 'The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory, DefaultCacheFactory#setFileLockRegionDirectory(). ', ); } diff --git a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php index f5023f22be2..6f8b99c0c5c 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php @@ -25,7 +25,7 @@ class DefaultCollectionHydrator implements CollectionHydrator private static array $hints = [Query::HINT_CACHE_ENABLED => true]; public function __construct( - private readonly EntityManagerInterface $em + private readonly EntityManagerInterface $em, ) { $this->uow = $em->getUnitOfWork(); } @@ -41,10 +41,7 @@ public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key return new CollectionCacheEntry($data); } - /** - * {@inheritdoc} - */ - public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): ?array + public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): array|null { $assoc = $metadata->associationMappings[$key->association]; $targetPersister = $this->uow->getEntityPersister($assoc['targetEntity']); @@ -63,7 +60,7 @@ public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, $entity = $this->uow->createEntity( $entityEntry->class, $entityEntry->resolveAssociationEntries($this->em), - self::$hints + self::$hints, ); $collection->hydrateSet($index, $entity); diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 15e11db93ee..64f6e5ccc7e 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -29,7 +29,7 @@ class DefaultEntityHydrator implements EntityHydrator private static array $hints = [Query::HINT_CACHE_ENABLED => true]; public function __construct( - private EntityManagerInterface $em + private EntityManagerInterface $em, ) { $this->uow = $em->getUnitOfWork(); $this->identifierFlattener = new IdentifierFlattener($em->getUnitOfWork(), $em->getMetadataFactory()); @@ -71,7 +71,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob : $assoc; $associationIds = $this->identifierFlattener->flattenIdentifier( $targetClassMetadata, - $targetClassMetadata->getIdentifierValues($data[$name]) + $targetClassMetadata->getIdentifierValues($data[$name]), ); unset($data[$name]); @@ -125,7 +125,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob return new EntityCacheEntry($metadata->name, $data); } - public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, ?object $entity = null): ?object + public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, object|null $entity = null): object|null { $data = $entry->data; $hints = self::$hints; diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 67126f8234e..00f9b9d4047 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -34,14 +34,14 @@ class DefaultQueryCache implements QueryCache { private readonly UnitOfWork $uow; private readonly QueryCacheValidator $validator; - protected ?CacheLogger $cacheLogger = null; + protected CacheLogger|null $cacheLogger = null; /** @var array */ private static array $hints = [Query::HINT_CACHE_ENABLED => true]; public function __construct( private readonly EntityManagerInterface $em, - private readonly Region $region + private readonly Region $region, ) { $cacheConfig = $em->getConfiguration()->getSecondLevelCacheConfiguration(); @@ -53,7 +53,7 @@ public function __construct( /** * {@inheritdoc} */ - public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []): ?array + public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []): array|null { if (! ($key->cacheMode & Cache::MODE_GET)) { return null; @@ -184,7 +184,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] if ($unCachedAssociationData instanceof AssociationCacheEntry) { $data[$fieldName] = $this->em->getReference( $unCachedAssociationData->class, - $unCachedAssociationData->identifier + $unCachedAssociationData->identifier, ); } } @@ -304,7 +304,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, ar * @return mixed[]|null * @psalm-return array{targetEntity: class-string, type: mixed, list?: array[], identifier?: array}|null */ - private function storeAssociationCache(QueryCacheKey $key, array $assoc, mixed $assocValue): ?array + private function storeAssociationCache(QueryCacheKey $key, array $assoc, mixed $assocValue): array|null { $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); $assocMetadata = $assocPersister->getClassMetadata(); @@ -353,13 +353,11 @@ private function storeAssociationCache(QueryCacheKey $key, array $assoc, mixed $ ]; } - /** - * @psalm-return list|object|null - */ + /** @psalm-return list|object|null */ private function getAssociationValue( ResultSetMapping $rsm, string $assocAlias, - object $entity + object $entity, ): array|object|null { $path = []; $alias = $assocAlias; diff --git a/lib/Doctrine/ORM/Cache/EntityHydrator.php b/lib/Doctrine/ORM/Cache/EntityHydrator.php index 8a64f290e43..13cd21f3b37 100644 --- a/lib/Doctrine/ORM/Cache/EntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/EntityHydrator.php @@ -24,5 +24,5 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob * @param EntityCacheEntry $entry The entity cache entry. * @param object|null $entity The entity to load the cache into. If not specified, a new entity is created. */ - public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, ?object $entity = null): ?object; + public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, object|null $entity = null): object|null; } diff --git a/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyCollection.php b/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyCollection.php index ad6a21daa7c..7ecb4fe7b76 100644 --- a/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyCollection.php +++ b/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyCollection.php @@ -13,7 +13,7 @@ public static function fromEntityAndField(string $sourceEntity, string $fieldNam return new self(sprintf( 'Cannot update a readonly collection "%s#%s"', $sourceEntity, - $fieldName + $fieldName, )); } } diff --git a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php b/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php index 29e39473ef1..4f5da85ac0e 100644 --- a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php +++ b/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php @@ -12,7 +12,7 @@ public static function fromEntity(string $entityName): self { return new self(sprintf( 'Entity "%s" not configured as part of the second-level cache.', - $entityName + $entityName, )); } } diff --git a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php b/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php index 9315cd60a04..984286f2018 100644 --- a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php +++ b/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php @@ -13,7 +13,7 @@ public static function fromEntityAndField(string $entityName, string $field): se return new self(sprintf( 'Entity association field "%s#%s" not configured as part of the second-level cache.', $entityName, - $field + $field, )); } } diff --git a/lib/Doctrine/ORM/Cache/Lock.php b/lib/Doctrine/ORM/Cache/Lock.php index 928d56737ee..d6d60a365ee 100644 --- a/lib/Doctrine/ORM/Cache/Lock.php +++ b/lib/Doctrine/ORM/Cache/Lock.php @@ -13,7 +13,7 @@ class Lock public function __construct( public string $value, - ?int $time = null + int|null $time = null, ) { $this->time = $time ?? time(); } diff --git a/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php b/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php index 8b6eef01f67..8eef3b54572 100644 --- a/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php +++ b/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php @@ -18,14 +18,12 @@ public function setLogger(string $name, CacheLogger $logger): void $this->loggers[$name] = $logger; } - public function getLogger(string $name): ?CacheLogger + public function getLogger(string $name): CacheLogger|null { return $this->loggers[$name] ?? null; } - /** - * @return array - */ + /** @return array */ public function getLoggers(): array { return $this->loggers; diff --git a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php b/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php index 44de7d7e6db..092104eaa36 100644 --- a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php +++ b/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php @@ -108,25 +108,19 @@ public function getRegionPutCount(string $regionName): int return $this->cachePutCountMap[$regionName] ?? 0; } - /** - * @return array - */ + /** @return array */ public function getRegionsMiss(): array { return $this->cacheMissCountMap; } - /** - * @return array - */ + /** @return array */ public function getRegionsHit(): array { return $this->cacheHitCountMap; } - /** - * @return array - */ + /** @return array */ public function getRegionsPut(): array { return $this->cachePutCountMap; diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index 96ff5112e54..4498aec1cb8 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -35,16 +35,14 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister protected string $regionName; protected CollectionHydrator $hydrator; - protected ?CacheLogger $cacheLogger; + protected CacheLogger|null $cacheLogger; - /** - * @param mixed[] $association The association mapping. - */ + /** @param mixed[] $association The association mapping. */ public function __construct( protected CollectionPersister $persister, protected Region $region, EntityManagerInterface $em, - protected array $association + protected array $association, ) { $configuration = $em->getConfiguration(); $cacheConfig = $configuration->getSecondLevelCacheConfiguration(); @@ -74,10 +72,7 @@ public function getTargetEntityMetadata(): ClassMetadata return $this->targetEntity; } - /** - * {@inheritdoc} - */ - public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key): ?array + public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key): array|null { $cache = $this->region->get($key); @@ -158,7 +153,7 @@ public function get(PersistentCollection $collection, mixed $index): mixed /** * {@inheritdoc} */ - public function slice(PersistentCollection $collection, int $offset, ?int $length = null): array + public function slice(PersistentCollection $collection, int $offset, int|null $length = null): array { return $this->persister->slice($collection, $offset, $length); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php index 20c626ea544..6b10c808b01 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php @@ -25,7 +25,7 @@ public function getTargetEntityMetadata(): ClassMetadata; * * @return mixed[]|null */ - public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key): ?array; + public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key): array|null; /** * Stores a collection into cache diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php index cf140771a2a..f4ef8a73d56 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php @@ -15,7 +15,7 @@ public function update(PersistentCollection $collection): void if ($collection->isDirty() && $collection->getSnapshot()) { throw CannotUpdateReadOnlyCollection::fromEntityAndField( ClassUtils::getClass($collection->getOwner()), - $this->association['fieldName'] + $this->association['fieldName'], ); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php index 1c6fd98ca82..bca0fd10e44 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php @@ -14,9 +14,7 @@ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister { - /** - * @param mixed[] $association The association mapping. - */ + /** @param mixed[] $association The association mapping. */ public function __construct(CollectionPersister $persister, ConcurrentRegion $region, EntityManagerInterface $em, array $association) { parent::__construct($persister, $region, $em, $association); diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 64ffb368622..c070628ac50 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -41,7 +41,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister protected TimestampCacheKey $timestampKey; protected EntityHydrator $hydrator; protected Cache $cache; - protected ?CacheLogger $cacheLogger = null; + protected CacheLogger|null $cacheLogger = null; protected string $regionName; /** @@ -49,13 +49,13 @@ abstract class AbstractEntityPersister implements CachedEntityPersister * * @var array|null */ - protected ?array $joinedAssociations = null; + protected array|null $joinedAssociations = null; public function __construct( protected EntityPersister $persister, protected Region $region, EntityManagerInterface $em, - protected ClassMetadata $class + protected ClassMetadata $class, ) { $configuration = $em->getConfiguration(); $cacheConfig = $configuration->getSecondLevelCacheConfiguration(); @@ -86,11 +86,11 @@ public function getInserts(): array public function getSelectSQL( array|Criteria $criteria, - ?array $assoc = null, + array|null $assoc = null, LockMode|int|null $lockMode = null, - ?int $limit = null, - ?int $offset = null, - ?array $orderBy = null + int|null $limit = null, + int|null $offset = null, + array|null $orderBy = null, ): string { return $this->persister->getSelectSQL($criteria, $assoc, $lockMode, $limit, $offset, $orderBy); } @@ -113,13 +113,13 @@ public function getResultSetMapping(): ResultSetMapping public function getSelectConditionStatementSQL( string $field, mixed $value, - ?array $assoc = null, - ?string $comparison = null + array|null $assoc = null, + string|null $comparison = null, ): string { return $this->persister->getSelectConditionStatementSQL($field, $value, $assoc, $comparison); } - public function exists(object $entity, ?Criteria $extraConditions = null): bool + public function exists(object $entity, Criteria|null $extraConditions = null): bool { if ($extraConditions === null) { $key = new EntityCacheKey($this->class->rootEntityName, $this->class->getIdentifierValues($entity)); @@ -205,9 +205,9 @@ private function storeJoinedAssociations(object $entity): void protected function getHash( string $query, array|Criteria $criteria, - ?array $orderBy = null, - ?int $limit = null, - ?int $offset = null + array|null $orderBy = null, + int|null $limit = null, + int|null $offset = null, ): string { [$params] = $criteria instanceof Criteria ? $this->persister->expandCriteriaParameters($criteria) @@ -243,8 +243,8 @@ public function getClassMetadata(): ClassMetadata public function getManyToManyCollection( array $assoc, object $sourceEntity, - ?int $offset = null, - ?int $limit = null + int|null $offset = null, + int|null $limit = null, ): array { return $this->persister->getManyToManyCollection($assoc, $sourceEntity, $offset, $limit); } @@ -255,8 +255,8 @@ public function getManyToManyCollection( public function getOneToManyCollection( array $assoc, object $sourceEntity, - ?int $offset = null, - ?int $limit = null + int|null $offset = null, + int|null $limit = null, ): array { return $this->persister->getOneToManyCollection($assoc, $sourceEntity, $offset, $limit); } @@ -281,13 +281,13 @@ public function executeInserts(): array */ public function load( array $criteria, - ?object $entity = null, - ?array $assoc = null, + object|null $entity = null, + array|null $assoc = null, array $hints = [], LockMode|int|null $lockMode = null, - ?int $limit = null, - ?array $orderBy = null - ): ?object { + int|null $limit = null, + array|null $orderBy = null, + ): object|null { if ($entity !== null || $assoc !== null || $hints !== [] || $lockMode !== null) { return $this->persister->load($criteria, $entity, $assoc, $hints, $lockMode, $limit, $orderBy); } @@ -328,9 +328,9 @@ public function load( */ public function loadAll( array $criteria = [], - ?array $orderBy = null, - ?int $limit = null, - ?int $offset = null + array|null $orderBy = null, + int|null $limit = null, + int|null $offset = null, ): array { $query = $this->persister->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy); $hash = $this->getHash($query, $criteria); @@ -362,7 +362,7 @@ public function loadAll( /** * {@inheritdoc} */ - public function loadById(array $identifier, ?object $entity = null): ?object + public function loadById(array $identifier, object|null $entity = null): object|null { $cacheKey = new EntityCacheKey($this->class->rootEntityName, $identifier); $cacheEntry = $this->region->get($cacheKey); @@ -457,7 +457,7 @@ public function loadCriteria(Criteria $criteria): array public function loadManyToManyCollection( array $assoc, object $sourceEntity, - PersistentCollection $collection + PersistentCollection $collection, ): array { $persister = $this->uow->getCollectionPersister($assoc); $hasCache = ($persister instanceof CachedPersister); @@ -491,7 +491,7 @@ public function loadManyToManyCollection( public function loadOneToManyCollection( array $assoc, object $sourceEntity, - PersistentCollection $collection + PersistentCollection $collection, ): mixed { $persister = $this->uow->getCollectionPersister($assoc); $hasCache = ($persister instanceof CachedPersister); @@ -522,7 +522,7 @@ public function loadOneToManyCollection( /** * {@inheritdoc} */ - public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): ?object + public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): object|null { return $this->persister->loadOneToOneEntity($assoc, $sourceEntity, $identifier); } diff --git a/lib/Doctrine/ORM/Cache/QueryCache.php b/lib/Doctrine/ORM/Cache/QueryCache.php index 4e80a8040e4..e6976802400 100644 --- a/lib/Doctrine/ORM/Cache/QueryCache.php +++ b/lib/Doctrine/ORM/Cache/QueryCache.php @@ -14,9 +14,7 @@ interface QueryCache { public function clear(): bool; - /** - * @param mixed[] $hints - */ + /** @param mixed[] $hints */ public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, array $hints = []): bool; /** @@ -24,7 +22,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, ar * * @return mixed[]|null */ - public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []): ?array; + public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []): array|null; public function getRegion(): Region; } diff --git a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php index 27e6e83c899..6d9aaa10b79 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php @@ -26,18 +26,14 @@ class QueryCacheEntry implements CacheEntry */ public float $time; - /** - * @param array $result - */ - public function __construct(array $result, ?float $time = null) + /** @param array $result */ + public function __construct(array $result, float|null $time = null) { $this->result = $result; $this->time = $time ?: microtime(true); } - /** - * @param array $values - */ + /** @param array $values */ public static function __set_state(array $values): self { return new self($values['result'], $values['time']); diff --git a/lib/Doctrine/ORM/Cache/QueryCacheKey.php b/lib/Doctrine/ORM/Cache/QueryCacheKey.php index 728ce3d5f43..654b0c8ab95 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheKey.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheKey.php @@ -27,16 +27,14 @@ class QueryCacheKey extends CacheKey public int $cacheMode; /** @readonly Public only for performance reasons, it should be considered immutable. */ - public ?TimestampCacheKey $timestampKey = null; + public TimestampCacheKey|null $timestampKey = null; - /** - * @psalm-param Cache::MODE_* $cacheMode - */ + /** @psalm-param Cache::MODE_* $cacheMode */ public function __construct( string $cacheId, int $lifetime = 0, int $cacheMode = Cache::MODE_NORMAL, - ?TimestampCacheKey $timestampKey = null + TimestampCacheKey|null $timestampKey = null, ) { $this->hash = $cacheId; $this->lifetime = $lifetime; diff --git a/lib/Doctrine/ORM/Cache/Region.php b/lib/Doctrine/ORM/Cache/Region.php index 9bb5217fe59..f7a1b26a936 100644 --- a/lib/Doctrine/ORM/Cache/Region.php +++ b/lib/Doctrine/ORM/Cache/Region.php @@ -32,7 +32,7 @@ public function contains(CacheKey $key): bool; * * @throws CacheException Indicates a problem accessing the item or region. */ - public function get(CacheKey $key): ?CacheEntry; + public function get(CacheKey $key): CacheEntry|null; /** * Get all items from the cache identified by $keys. @@ -42,7 +42,7 @@ public function get(CacheKey $key): ?CacheEntry; * * @return CacheEntry[]|null The cached entries or NULL if one or more entries can not be found */ - public function getMultiple(CollectionCacheEntry $collection): ?array; + public function getMultiple(CollectionCacheEntry $collection): array|null; /** * Put an item into the cache. @@ -53,7 +53,7 @@ public function getMultiple(CollectionCacheEntry $collection): ?array; * * @throws CacheException Indicates a problem accessing the region. */ - public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null): bool; + public function put(CacheKey $key, CacheEntry $entry, Lock|null $lock = null): bool; /** * Remove an item from the cache. diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php index 3d4d474d768..be6bf18dc8b 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php @@ -29,7 +29,7 @@ class DefaultRegion implements Region public function __construct( private readonly string $name, private readonly CacheItemPoolInterface $cacheItemPool, - private readonly int $lifetime = 0 + private readonly int $lifetime = 0, ) { } @@ -43,7 +43,7 @@ public function contains(CacheKey $key): bool return $this->cacheItemPool->hasItem($this->getCacheEntryKey($key)); } - public function get(CacheKey $key): ?CacheEntry + public function get(CacheKey $key): CacheEntry|null { $item = $this->cacheItemPool->getItem($this->getCacheEntryKey($key)); $entry = $item->isHit() ? $item->get() : null; @@ -55,14 +55,11 @@ public function get(CacheKey $key): ?CacheEntry return $entry; } - /** - * {@inheritdoc} - */ - public function getMultiple(CollectionCacheEntry $collection): ?array + public function getMultiple(CollectionCacheEntry $collection): array|null { $keys = array_map( Closure::fromCallable([$this, 'getCacheEntryKey']), - $collection->identifiers + $collection->identifiers, ); /** @var iterable $items */ $items = $this->cacheItemPool->getItems($keys); @@ -87,7 +84,7 @@ public function getMultiple(CollectionCacheEntry $collection): ?array return $result; } - public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null): bool + public function put(CacheKey $key, CacheEntry $entry, Lock|null $lock = null): bool { $item = $this->cacheItemPool ->getItem($this->getCacheEntryKey($key)) diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index f30f404477f..c8411922918 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -45,7 +45,7 @@ class FileLockRegion implements ConcurrentRegion public function __construct( private readonly Region $region, private readonly string $directory, - private readonly string|int $lockLifetime + private readonly string|int $lockLifetime, ) { if (! is_dir($directory) && ! @mkdir($directory, 0775, true)) { throw new InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $directory)); @@ -56,7 +56,7 @@ public function __construct( } } - private function isLocked(CacheKey $key, ?Lock $lock = null): bool + private function isLocked(CacheKey $key, Lock|null $lock = null): bool { $filename = $this->getLockFileName($key); @@ -116,7 +116,7 @@ public function contains(CacheKey $key): bool return $this->region->contains($key); } - public function get(CacheKey $key): ?CacheEntry + public function get(CacheKey $key): CacheEntry|null { if ($this->isLocked($key)) { return null; @@ -125,10 +125,7 @@ public function get(CacheKey $key): ?CacheEntry return $this->region->get($key); } - /** - * {@inheritdoc} - */ - public function getMultiple(CollectionCacheEntry $collection): ?array + public function getMultiple(CollectionCacheEntry $collection): array|null { if (array_filter(array_map([$this, 'isLocked'], $collection->identifiers))) { return null; @@ -137,7 +134,7 @@ public function getMultiple(CollectionCacheEntry $collection): ?array return $this->region->getMultiple($collection); } - public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null): bool + public function put(CacheKey $key, CacheEntry $entry, Lock|null $lock = null): bool { if ($this->isLocked($key, $lock)) { return false; @@ -170,7 +167,7 @@ public function evictAll(): bool return $this->region->evictAll(); } - public function lock(CacheKey $key): ?Lock + public function lock(CacheKey $key): Lock|null { if ($this->isLocked($key)) { return null; diff --git a/lib/Doctrine/ORM/Cache/RegionsConfiguration.php b/lib/Doctrine/ORM/Cache/RegionsConfiguration.php index a7691f04ef5..a8528312b6a 100644 --- a/lib/Doctrine/ORM/Cache/RegionsConfiguration.php +++ b/lib/Doctrine/ORM/Cache/RegionsConfiguration.php @@ -17,7 +17,7 @@ class RegionsConfiguration public function __construct( private int $defaultLifetime = 3600, - private int $defaultLockLifetime = 60 + private int $defaultLockLifetime = 60, ) { } diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php index f946de46ff2..4b146f925c9 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php @@ -14,7 +14,7 @@ class TimestampCacheEntry implements CacheEntry /** @readonly Public only for performance reasons, it should be considered immutable. */ public float $time; - public function __construct(?float $time = null) + public function __construct(float|null $time = null) { $this->time = $time ?? microtime(true); } diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheKey.php b/lib/Doctrine/ORM/Cache/TimestampCacheKey.php index 7142b1a8512..278458f1764 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheKey.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheKey.php @@ -9,9 +9,7 @@ */ class TimestampCacheKey extends CacheKey { - /** - * @param string $space Result cache id - */ + /** @param string $space Result cache id */ public function __construct(string $space) { $this->hash = $space; diff --git a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php index 9ff50f86248..754b9fa7390 100644 --- a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php +++ b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php @@ -8,11 +8,8 @@ class TimestampQueryCacheValidator implements QueryCacheValidator { - private TimestampRegion $timestampRegion; - - public function __construct(TimestampRegion $timestampRegion) + public function __construct(private TimestampRegion $timestampRegion) { - $this->timestampRegion = $timestampRegion; } public function isValid(QueryCacheKey $key, QueryCacheEntry $entry): bool diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 8371e9e10d1..ad4dd5ad426 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -129,7 +129,7 @@ public function getEntityNamespaces(): array /** * Gets the cache driver implementation that is used for the mapping metadata. */ - public function getMetadataDriverImpl(): ?MappingDriver + public function getMetadataDriverImpl(): MappingDriver|null { return $this->_attributes['metadataDriverImpl'] ?? null; } @@ -137,7 +137,7 @@ public function getMetadataDriverImpl(): ?MappingDriver /** * Gets the cache driver implementation that is used for the query cache (SQL cache). */ - public function getQueryCache(): ?CacheItemPoolInterface + public function getQueryCache(): CacheItemPoolInterface|null { return $this->_attributes['queryCache'] ?? null; } @@ -150,7 +150,7 @@ public function setQueryCache(CacheItemPoolInterface $cache): void $this->_attributes['queryCache'] = $cache; } - public function getHydrationCache(): ?CacheItemPoolInterface + public function getHydrationCache(): CacheItemPoolInterface|null { return $this->_attributes['hydrationCache'] ?? null; } @@ -160,7 +160,7 @@ public function setHydrationCache(CacheItemPoolInterface $cache): void $this->_attributes['hydrationCache'] = $cache; } - public function getMetadataCache(): ?CacheItemPoolInterface + public function getMetadataCache(): CacheItemPoolInterface|null { return $this->_attributes['metadataCache'] ?? null; } @@ -324,7 +324,7 @@ public function setCustomHydrationModes(array $modes): void * * @psalm-return class-string|null */ - public function getCustomHydrationMode(string $modeName): ?string + public function getCustomHydrationMode(string $modeName): string|null { return $this->_attributes['customHydrationModes'][$modeName] ?? null; } @@ -349,9 +349,7 @@ public function setClassMetadataFactoryName(string $cmfName): void $this->_attributes['classMetadataFactoryName'] = $cmfName; } - /** - * @psalm-return class-string - */ + /** @psalm-return class-string */ public function getClassMetadataFactoryName(): string { if (! isset($this->_attributes['classMetadataFactoryName'])) { @@ -379,7 +377,7 @@ public function addFilter(string $name, string $className): void * defined. * @psalm-return class-string|null */ - public function getFilterClassName(string $name): ?string + public function getFilterClassName(string $name): string|null { return $this->_attributes['filters'][$name] ?? null; } @@ -501,7 +499,7 @@ public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig $this->_attributes['secondLevelCacheConfiguration'] = $cacheConfig; } - public function getSecondLevelCacheConfiguration(): ?CacheConfiguration + public function getSecondLevelCacheConfiguration(): CacheConfiguration|null { if (! isset($this->_attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) { $this->_attributes['secondLevelCacheConfiguration'] = new CacheConfiguration(); diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index d324429df4a..b5332988865 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -99,7 +99,7 @@ public function createQueryBuilder(): QueryBuilder /** * {@inheritdoc} */ - public function getReference(string $entityName, $id): ?object + public function getReference(string $entityName, $id): object|null { return $this->wrapped->getReference($entityName, $id); } @@ -107,7 +107,7 @@ public function getReference(string $entityName, $id): ?object /** * {@inheritdoc} */ - public function getPartialReference(string $entityName, $identifier): ?object + public function getPartialReference(string $entityName, $identifier): object|null { return $this->wrapped->getPartialReference($entityName, $identifier); } @@ -125,7 +125,7 @@ public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null $this->wrapped->lock($entity, $lockMode, $lockVersion); } - public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object + public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, int|null $lockVersion = null): object|null { return $this->wrapped->find($className, $id, $lockMode, $lockVersion); } @@ -175,7 +175,7 @@ public function hasFilters(): bool return $this->wrapped->hasFilters(); } - public function getCache(): ?Cache + public function getCache(): Cache|null { return $this->wrapped->getCache(); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index a47c8647783..5621dd697d6 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -102,7 +102,7 @@ class EntityManager implements EntityManagerInterface /** * The expression builder instance used to generate query expressions. */ - private ?Expr $expressionBuilder = null; + private Expr|null $expressionBuilder = null; /** * Whether the EntityManager is closed or not. @@ -112,12 +112,12 @@ class EntityManager implements EntityManagerInterface /** * Collection of query filters. */ - private ?FilterCollection $filterCollection = null; + private FilterCollection|null $filterCollection = null; /** * The second level cache regions API. */ - private ?Cache $cache = null; + private Cache|null $cache = null; /** * Creates a new EntityManager that operates on the given database connection @@ -146,7 +146,7 @@ public function __construct(Connection $conn, Configuration $config) $this, $config->getProxyDir(), $config->getProxyNamespace(), - $config->getAutoGenerateProxyClasses() + $config->getAutoGenerateProxyClasses(), ); if ($config->isSecondLevelCacheEnabled()) { @@ -176,7 +176,7 @@ public function beginTransaction(): void $this->conn->beginTransaction(); } - public function getCache(): ?Cache + public function getCache(): Cache|null { return $this->cache; } @@ -276,7 +276,7 @@ public function flush(): void /** * {@inheritdoc} */ - public function find($className, mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object + public function find($className, mixed $id, LockMode|int|null $lockMode = null, int|null $lockVersion = null): object|null { $class = $this->metadataFactory->getMetadataFor(ltrim($className, '\\')); @@ -375,7 +375,7 @@ public function find($className, mixed $id, LockMode|int|null $lockMode = null, /** * {@inheritDoc} */ - public function getReference(string $entityName, $id): ?object + public function getReference(string $entityName, $id): object|null { $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); @@ -419,7 +419,7 @@ public function getReference(string $entityName, $id): ?object /** * {@inheritDoc} */ - public function getPartialReference(string $entityName, $identifier): ?object + public function getPartialReference(string $entityName, $identifier): object|null { $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); @@ -641,7 +641,7 @@ public function initializeObject(object $obj): void * @throws DBALException * @throws ManagerException */ - public static function create(array|Connection $connection, Configuration $config, ?EventManager $eventManager = null): EntityManager + public static function create(array|Connection $connection, Configuration $config, EventManager|null $eventManager = null): EntityManager { $connection = static::createConnection($connection, $config, $eventManager); @@ -657,7 +657,7 @@ public static function create(array|Connection $connection, Configuration $confi * @throws DBALException * @throws ManagerException */ - protected static function createConnection(array|Connection $connection, Configuration $config, ?EventManager $eventManager = null): Connection + protected static function createConnection(array|Connection $connection, Configuration $config, EventManager|null $eventManager = null): Connection { if (is_array($connection)) { return DriverManager::getConnection($connection, $config, $eventManager ?? new EventManager()); diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index 46d6bc87ceb..fa445f8572a 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -33,7 +33,7 @@ public function getRepository(string $className): EntityRepository; /** * Returns the cache API for managing the second level cache regions or NULL if the cache is not enabled. */ - public function getCache(): ?Cache; + public function getCache(): Cache|null; /** * Gets the database connection object used by the EntityManager. @@ -130,7 +130,7 @@ public function createQueryBuilder(): QueryBuilder; * * @template T of object */ - public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object; + public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, int|null $lockVersion = null): object|null; /** * Gets a reference to the entity identified by the given type and identifier @@ -146,7 +146,7 @@ public function find(string $className, mixed $id, LockMode|int|null $lockMode = * * @template T of object */ - public function getReference(string $entityName, $id): ?object; + public function getReference(string $entityName, $id): object|null; /** * Gets a partial reference to the entity identified by the given type and identifier @@ -171,7 +171,7 @@ public function getReference(string $entityName, $id): ?object; * * @template T of object */ - public function getPartialReference(string $entityName, $identifier): ?object; + public function getPartialReference(string $entityName, $identifier): object|null; /** * Closes the EntityManager. All entities that are currently managed diff --git a/lib/Doctrine/ORM/EntityNotFoundException.php b/lib/Doctrine/ORM/EntityNotFoundException.php index 6130812ce0e..693dfa4ecbe 100644 --- a/lib/Doctrine/ORM/EntityNotFoundException.php +++ b/lib/Doctrine/ORM/EntityNotFoundException.php @@ -32,7 +32,7 @@ public static function fromClassNameAndIdentifier($className, array $id) } return new self( - 'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found' + 'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found', ); } @@ -43,7 +43,7 @@ public static function noIdentifierFound(string $className): self { return new self(sprintf( 'Unable to find "%s" entity identifier associated with the UnitOfWork', - $className + $className, )); } } diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 245c0d02ade..bc5597877cc 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -37,14 +37,12 @@ class EntityRepository implements ObjectRepository, Selectable { /** @psalm-var class-string */ private readonly string $entityName; - private static ?Inflector $inflector = null; + private static Inflector|null $inflector = null; - /** - * @psalm-param ClassMetadata $class - */ + /** @psalm-param ClassMetadata $class */ public function __construct( private readonly EntityManagerInterface $em, - private readonly ClassMetadata $class + private readonly ClassMetadata $class, ) { $this->entityName = $class->name; } @@ -52,7 +50,7 @@ public function __construct( /** * Creates a new QueryBuilder instance that is prepopulated for this entity name. */ - public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + public function createQueryBuilder(string $alias, string|null $indexBy = null): QueryBuilder { return $this->em->createQueryBuilder() ->select($alias) @@ -83,7 +81,7 @@ public function createResultSetMappingBuilder(string $alias): ResultSetMappingBu * @return object|null The entity instance or NULL if the entity can not be found. * @psalm-return ?T */ - public function find(mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object + public function find(mixed $id, LockMode|int|null $lockMode = null, int|null $lockVersion = null): object|null { return $this->em->find($this->entityName, $id, $lockMode, $lockVersion); } @@ -105,7 +103,7 @@ public function findAll(): array * * @psalm-return list */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + public function findBy(array $criteria, array|null $orderBy = null, int|null $limit = null, int|null $offset = null): array { $persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName); @@ -120,7 +118,7 @@ public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = nu * * @psalm-return T|null */ - public function findOneBy(array $criteria, ?array $orderBy = null): ?object + public function findOneBy(array $criteria, array|null $orderBy = null): object|null { $persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName); @@ -166,13 +164,11 @@ public function __call(string $method, array $arguments): mixed throw new BadMethodCallException(sprintf( 'Undefined method "%s". The method name must start with ' . 'either findBy, findOneBy or countBy!', - $method + $method, )); } - /** - * @psalm-return class-string - */ + /** @psalm-return class-string */ protected function getEntityName(): string { return $this->entityName; @@ -188,9 +184,7 @@ protected function getEntityManager(): EntityManagerInterface return $this->em; } - /** - * @psalm-return ClassMetadata - */ + /** @psalm-return ClassMetadata */ protected function getClassMetadata(): ClassMetadata { return $this->class; @@ -233,7 +227,7 @@ private function resolveMagicCall(string $method, string $by, array $arguments): throw InvalidMagicMethodCall::becauseFieldNotFoundIn( $this->entityName, $fieldName, - $method . $by + $method . $by, ); } diff --git a/lib/Doctrine/ORM/Event/LifecycleEventArgs.php b/lib/Doctrine/ORM/Event/LifecycleEventArgs.php index 7e8e8df0c16..e32cb6b9304 100644 --- a/lib/Doctrine/ORM/Event/LifecycleEventArgs.php +++ b/lib/Doctrine/ORM/Event/LifecycleEventArgs.php @@ -16,9 +16,7 @@ */ class LifecycleEventArgs extends BaseLifecycleEventArgs { - /** - * @param object $object - */ + /** @param object $object */ public function __construct($object, EntityManagerInterface $objectManager) { Deprecation::triggerIfCalledFromOutside( @@ -26,7 +24,7 @@ public function __construct($object, EntityManagerInterface $objectManager) 'https://github.com/doctrine/orm/issues/9875', 'The %s class is deprecated and will be removed in ORM 3.0. Use %s instead.', self::class, - BaseLifecycleEventArgs::class + BaseLifecycleEventArgs::class, ); parent::__construct($object, $objectManager); @@ -45,7 +43,7 @@ public function getEntity() 'doctrine/orm', 'https://github.com/doctrine/orm/issues/9875', 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__ + __METHOD__, ); return $this->getObject(); @@ -64,7 +62,7 @@ public function getEntityManager() 'doctrine/orm', 'https://github.com/doctrine/orm/issues/9875', 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__ + __METHOD__, ); return $this->getObjectManager(); diff --git a/lib/Doctrine/ORM/Event/ListenersInvoker.php b/lib/Doctrine/ORM/Event/ListenersInvoker.php index d0ea7cfb250..c0c327e5aad 100644 --- a/lib/Doctrine/ORM/Event/ListenersInvoker.php +++ b/lib/Doctrine/ORM/Event/ListenersInvoker.php @@ -73,7 +73,7 @@ public function invoke( string $eventName, object $entity, EventArgs $event, - int $invoke + int $invoke, ): void { if ($invoke & self::INVOKE_CALLBACKS) { foreach ($metadata->lifecycleCallbacks[$eventName] as $callback) { diff --git a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php b/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php index c1121f940c5..52349d8360f 100644 --- a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php @@ -36,17 +36,13 @@ public function __construct($className, ObjectManager $objectManager) parent::__construct($objectManager); } - /** - * @return void - */ - public function setFoundMetadata(?ClassMetadata $classMetadata) + /** @return void */ + public function setFoundMetadata(ClassMetadata|null $classMetadata) { $this->foundMetadata = $classMetadata; } - /** - * @return ClassMetadata|null - */ + /** @return ClassMetadata|null */ public function getFoundMetadata() { return $this->foundMetadata; diff --git a/lib/Doctrine/ORM/Event/OnClearEventArgs.php b/lib/Doctrine/ORM/Event/OnClearEventArgs.php index 83f5c2589f5..ef6854b5c28 100644 --- a/lib/Doctrine/ORM/Event/OnClearEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClearEventArgs.php @@ -28,7 +28,7 @@ public function getEntityManager(): EntityManagerInterface 'doctrine/orm', 'https://github.com/doctrine/orm/issues/9875', 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__ + __METHOD__, ); return $this->getObjectManager(); diff --git a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php index 340719f78f5..4a3a7525178 100644 --- a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php @@ -30,7 +30,7 @@ public function getEntityManager() 'doctrine/orm', 'https://github.com/doctrine/orm/issues/9875', 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__ + __METHOD__, ); return $this->getObjectManager(); diff --git a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php b/lib/Doctrine/ORM/Event/PostFlushEventArgs.php index ae3f52a4066..8eb7d4f7b68 100644 --- a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PostFlushEventArgs.php @@ -30,7 +30,7 @@ public function getEntityManager() 'doctrine/orm', 'https://github.com/doctrine/orm/issues/9875', 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__ + __METHOD__, ); return $this->getObjectManager(); diff --git a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php index b8bdb25538e..1424e46ab14 100644 --- a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php @@ -28,7 +28,7 @@ public function getEntityManager() 'doctrine/orm', 'https://github.com/doctrine/orm/issues/9875', 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__ + __METHOD__, ); return $this->getObjectManager(); diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php index 6bff30ef6cc..f5480848c20 100644 --- a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -108,7 +108,7 @@ private function assertValidField(string $field): void throw new InvalidArgumentException(sprintf( 'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.', $field, - get_debug_type($this->getObject()) + get_debug_type($this->getObject()), )); } } diff --git a/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php b/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php index 1278a3f67eb..36954b5eff8 100644 --- a/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php +++ b/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php @@ -10,9 +10,7 @@ final class EntityMissingAssignedId extends LogicException implements ORMException { - /** - * @param object $entity - */ + /** @param object $entity */ public static function forField($entity, string $field): self { return new self('Entity of type ' . get_debug_type($entity) . " is missing an assigned ID for field '" . $field . "'. " . diff --git a/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php b/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php index cde6a2d6c11..c28143d2395 100644 --- a/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php +++ b/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php @@ -12,7 +12,7 @@ final class InvalidEntityRepository extends LogicException implements Configurat public static function fromClassName(string $className): self { return new self( - "Invalid repository class '" . $className . "'. It must be a " . EntityRepository::class . '.' + "Invalid repository class '" . $className . "'. It must be a " . EntityRepository::class . '.', ); } } diff --git a/lib/Doctrine/ORM/Exception/MismatchedEventManager.php b/lib/Doctrine/ORM/Exception/MismatchedEventManager.php index 17725ad18ee..c30578546e3 100644 --- a/lib/Doctrine/ORM/Exception/MismatchedEventManager.php +++ b/lib/Doctrine/ORM/Exception/MismatchedEventManager.php @@ -11,7 +11,7 @@ final class MismatchedEventManager extends LogicException implements ManagerExce public static function create(): self { return new self( - 'Cannot use different EventManager instances for EntityManager and Connection.' + 'Cannot use different EventManager instances for EntityManager and Connection.', ); } } diff --git a/lib/Doctrine/ORM/Exception/MissingIdentifierField.php b/lib/Doctrine/ORM/Exception/MissingIdentifierField.php index 408b244096b..2c02db416e1 100644 --- a/lib/Doctrine/ORM/Exception/MissingIdentifierField.php +++ b/lib/Doctrine/ORM/Exception/MissingIdentifierField.php @@ -15,7 +15,7 @@ public static function fromFieldAndClass(string $fieldName, string $className): return new self(sprintf( 'The identifier %s is missing for a query of %s', $fieldName, - $className + $className, )); } } diff --git a/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php b/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php index 9e3de5d79bd..ce5104b2609 100644 --- a/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php +++ b/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php @@ -12,7 +12,7 @@ public static function create(): self { return new self( "It's a requirement to specify a Metadata Driver and pass it " . - 'to Doctrine\\ORM\\Configuration::setMetadataDriverImpl().' + 'to Doctrine\\ORM\\Configuration::setMetadataDriverImpl().', ); } } diff --git a/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php b/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php index b9f3f8d6dd4..8084d66b47c 100644 --- a/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php +++ b/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php @@ -13,16 +13,14 @@ final class MultipleSelectorsFoundException extends LogicException implements OR { public const MULTIPLE_SELECTORS_FOUND_EXCEPTION = 'Multiple selectors found: %s. Please select only one.'; - /** - * @param string[] $selectors - */ + /** @param string[] $selectors */ public static function create(array $selectors): self { return new self( sprintf( self::MULTIPLE_SELECTORS_FOUND_EXCEPTION, - implode(', ', $selectors) - ) + implode(', ', $selectors), + ), ); } } diff --git a/lib/Doctrine/ORM/Exception/NotSupported.php b/lib/Doctrine/ORM/Exception/NotSupported.php index 366a88cd048..a061aebb0dd 100644 --- a/lib/Doctrine/ORM/Exception/NotSupported.php +++ b/lib/Doctrine/ORM/Exception/NotSupported.php @@ -24,7 +24,7 @@ public static function createForDbal3(string $context): self Solution: See the doctrine/deprecations logs for new alternative approaches. EXCEPTION , - $context + $context, )); } @@ -37,7 +37,7 @@ public static function createForPersistence3(string $context): self Solution: See the doctrine/deprecations logs for new alternative approaches. EXCEPTION , - $context + $context, )); } } diff --git a/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php b/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php index 900a74ed662..cf3ca187c51 100644 --- a/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php +++ b/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php @@ -14,14 +14,14 @@ public static function create( string $class, string $association, string $given, - string $expected + string $expected, ): self { return new self(sprintf( 'Found entity of type %s on association %s#%s, but expecting %s', $given, $class, $association, - $expected + $expected, )); } } diff --git a/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php b/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php index 3be4bdf3f66..645bdae84dd 100644 --- a/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php +++ b/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php @@ -11,15 +11,13 @@ final class UnrecognizedIdentifierFields extends LogicException implements ManagerException { - /** - * @param string[] $fieldNames - */ + /** @param string[] $fieldNames */ public static function fromClassAndFieldNames(string $className, array $fieldNames): self { return new self(sprintf( 'Unrecognized identifier fields: "%s" are not present on class "%s".', implode("', '", $fieldNames), - $className + $className, )); } } diff --git a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php b/lib/Doctrine/ORM/Id/AbstractIdGenerator.php index 054fc21fd48..6d981f8f5a8 100644 --- a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php +++ b/lib/Doctrine/ORM/Id/AbstractIdGenerator.php @@ -11,7 +11,7 @@ abstract class AbstractIdGenerator /** * Generates an identifier for an entity. */ - abstract public function generateId(EntityManagerInterface $em, ?object $entity): mixed; + abstract public function generateId(EntityManagerInterface $em, object|null $entity): mixed; /** * Gets whether this generator is a post-insert generator which means that diff --git a/lib/Doctrine/ORM/Id/AssignedGenerator.php b/lib/Doctrine/ORM/Id/AssignedGenerator.php index 24d610bd118..093049ec13c 100644 --- a/lib/Doctrine/ORM/Id/AssignedGenerator.php +++ b/lib/Doctrine/ORM/Id/AssignedGenerator.php @@ -21,7 +21,7 @@ class AssignedGenerator extends AbstractIdGenerator * * @throws EntityMissingAssignedId */ - public function generateId(EntityManagerInterface $em, ?object $entity): array + public function generateId(EntityManagerInterface $em, object|null $entity): array { $class = $em->getClassMetadata(get_class($entity)); $idFields = $class->getIdentifierFieldNames(); diff --git a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php b/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php index 79f8dd438d4..762a7cb7070 100644 --- a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php @@ -13,7 +13,7 @@ */ class BigIntegerIdentityGenerator extends AbstractIdGenerator { - public function generateId(EntityManagerInterface $em, ?object $entity): string + public function generateId(EntityManagerInterface $em, object|null $entity): string { return (string) $em->getConnection()->lastInsertId(); } diff --git a/lib/Doctrine/ORM/Id/IdentityGenerator.php b/lib/Doctrine/ORM/Id/IdentityGenerator.php index 4d111dc6172..4610f66426b 100644 --- a/lib/Doctrine/ORM/Id/IdentityGenerator.php +++ b/lib/Doctrine/ORM/Id/IdentityGenerator.php @@ -13,7 +13,7 @@ */ class IdentityGenerator extends AbstractIdGenerator { - public function generateId(EntityManagerInterface $em, ?object $entity): int + public function generateId(EntityManagerInterface $em, object|null $entity): int { return (int) $em->getConnection()->lastInsertId(); } diff --git a/lib/Doctrine/ORM/Id/SequenceGenerator.php b/lib/Doctrine/ORM/Id/SequenceGenerator.php index 8d72b49fe5c..45d43f57154 100644 --- a/lib/Doctrine/ORM/Id/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Id/SequenceGenerator.php @@ -16,8 +16,8 @@ */ class SequenceGenerator extends AbstractIdGenerator implements Serializable { - private int $nextValue = 0; - private ?int $maxValue = null; + private int $nextValue = 0; + private int|null $maxValue = null; /** * Initializes a new sequence generator. @@ -27,11 +27,11 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable */ public function __construct( private string $sequenceName, - private int $allocationSize + private int $allocationSize, ) { } - public function generateId(EntityManagerInterface $em, ?object $entity): int + public function generateId(EntityManagerInterface $em, object|null $entity): int { if ($this->maxValue === null || $this->nextValue === $this->maxValue) { // Allocate new values @@ -52,7 +52,7 @@ public function generateId(EntityManagerInterface $em, ?object $entity): int /** * Gets the maximum value of the currently allocated bag of values. */ - public function getCurrentMaxValue(): ?int + public function getCurrentMaxValue(): int|null { return $this->maxValue; } @@ -70,9 +70,7 @@ final public function serialize(): string return serialize($this->__serialize()); } - /** - * @return array - */ + /** @return array */ public function __serialize(): array { return [ @@ -86,9 +84,7 @@ final public function unserialize(string $serialized): void $this->__unserialize(unserialize($serialized)); } - /** - * @param array $data - */ + /** @param array $data */ public function __unserialize(array $data): void { $this->sequenceName = $data['sequenceName']; diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 5b6028192d0..25efb3aa9ed 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -34,7 +34,7 @@ abstract class AbstractHydrator /** * The ResultSetMapping. */ - protected ?ResultSetMapping $_rsm = null; + protected ResultSetMapping|null $_rsm = null; /** * The dbms Platform instance. @@ -63,7 +63,7 @@ abstract class AbstractHydrator /** * The statement that provides the data to hydrate. */ - protected ?Result $_stmt = null; + protected Result|null $_stmt = null; /** * The query hints. @@ -382,7 +382,7 @@ protected function gatherScalarRowData(array &$data): array * @return mixed[]|null * @psalm-return array|null */ - protected function hydrateColumnInfo(string $key): ?array + protected function hydrateColumnInfo(string $key): array|null { if (isset($this->_cache[$key])) { return $this->_cache[$key]; @@ -411,7 +411,7 @@ protected function hydrateColumnInfo(string $key): ?array 'discriminatorColumn' => $this->_rsm->discriminatorColumns[$ownerMap], 'discriminatorValue' => $classMetadata->discriminatorValue, 'discriminatorValues' => $this->getDiscriminatorValues($classMetadata), - ] + ], ); } @@ -481,7 +481,7 @@ private function getDiscriminatorValues(ClassMetadata $classMetadata): array { $values = array_map( fn (string $subClass): string => (string) $this->getClassMetadata($subClass)->discriminatorValue, - $classMetadata->subClasses + $classMetadata->subClasses, ); $values[] = (string) $classMetadata->discriminatorValue; @@ -541,7 +541,7 @@ private function buildEnum($value, string $enumType) if (is_array($value)) { return array_map( static fn ($value) => $enumType::from($value), - $value + $value, ); } diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index ea34ed573f4..0fca7b86fae 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -240,10 +240,10 @@ protected function hydrateRowData(array $row, array &$result): void * @param bool $oneToOne Whether it is a single-valued association or not. */ private function updateResultPointer( - ?array &$coll, + array|null &$coll, string|int|false $index, string $dqlAlias, - bool $oneToOne + bool $oneToOne, ): void { if ($coll === null) { unset($this->_resultPointers[$dqlAlias]); // Ticket #1228 diff --git a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php b/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php index 0ca90019f1a..710114f7e6b 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php +++ b/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php @@ -23,7 +23,7 @@ public static function parentObjectOfRelationNotFound(string $alias, string $par "The parent object of entity result with alias '%s' was not found." . " The parent alias is '%s'.", $alias, - $parentAlias + $parentAlias, )); } @@ -41,7 +41,7 @@ public static function missingDiscriminatorColumn(string $entityName, string $di 'The discriminator column "%s" is missing for "%s" using the DQL alias "%s".', $discrColumnName, $entityName, - $dqlAlias + $dqlAlias, )); } @@ -51,19 +51,17 @@ public static function missingDiscriminatorMetaMappingColumn(string $entityName, 'The meta mapping for the discriminator column "%s" is missing for "%s" using the DQL alias "%s".', $discrColumnName, $entityName, - $dqlAlias + $dqlAlias, )); } - /** - * @param list $discrValues - */ + /** @param list $discrValues */ public static function invalidDiscriminatorValue(string $discrValue, array $discrValues): self { return new self(sprintf( 'The discriminator value "%s" is invalid. It must be one of "%s".', $discrValue, - implode('", "', $discrValues) + implode('", "', $discrValues), )); } } diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 5f0a66dfdd2..14c84e2e1b1 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -165,7 +165,7 @@ private function initRelatedCollection( object $entity, ClassMetadata $class, string $fieldName, - string $parentDqlAlias + string $parentDqlAlias, ): PersistentCollection { $oid = spl_object_id($entity); $relation = $class->associationMappings[$fieldName]; @@ -179,7 +179,7 @@ private function initRelatedCollection( $value = new PersistentCollection( $this->_em, $this->_metadataCache[$relation['targetEntity']], - $value + $value, ); $value->setOwner($entity, $relation); diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index cbbd42137da..1ea775cfd37 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -23,7 +23,7 @@ class SimpleObjectHydrator extends AbstractHydrator { use SQLResultCasing; - private ?ClassMetadata $class = null; + private ClassMetadata|null $class = null; protected function prepare(): void { @@ -87,13 +87,13 @@ protected function hydrateRowData(array $row, array &$result): void throw HydrationException::missingDiscriminatorColumn( $entityName, $discrColumnName, - key($this->resultSetMapping()->aliasMap) + key($this->resultSetMapping()->aliasMap), ); } if ($row[$discrColumnName] === '') { throw HydrationException::emptyDiscriminatorValue(key( - $this->resultSetMapping()->aliasMap + $this->resultSetMapping()->aliasMap, )); } diff --git a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php index 8a97d398cd2..5ac1774db99 100644 --- a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php +++ b/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php @@ -57,7 +57,7 @@ public function hydrationComplete(): void Events::postLoad, $entity, new LifecycleEventArgs($entity, $this->em), - $invoke + $invoke, ); } } diff --git a/lib/Doctrine/ORM/Internal/QueryType.php b/lib/Doctrine/ORM/Internal/QueryType.php index f72245551d8..b5e60c7e828 100644 --- a/lib/Doctrine/ORM/Internal/QueryType.php +++ b/lib/Doctrine/ORM/Internal/QueryType.php @@ -4,9 +4,7 @@ namespace Doctrine\ORM\Internal; -/** - * @internal To be used inside the QueryBuilder only. - */ +/** @internal To be used inside the QueryBuilder only. */ enum QueryType { case Select; diff --git a/lib/Doctrine/ORM/Internal/SQLResultCasing.php b/lib/Doctrine/ORM/Internal/SQLResultCasing.php index 2edb9e3e4a0..53b412ef79e 100644 --- a/lib/Doctrine/ORM/Internal/SQLResultCasing.php +++ b/lib/Doctrine/ORM/Internal/SQLResultCasing.php @@ -12,9 +12,7 @@ use function strtolower; use function strtoupper; -/** - * @internal - */ +/** @internal */ trait SQLResultCasing { private function getSQLResultCasing(AbstractPlatform $platform, string $column): string diff --git a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php index 0778c86c23a..a9b953d650a 100644 --- a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php @@ -18,7 +18,7 @@ class AnsiQuoteStrategy implements QuoteStrategy public function getColumnName( string $fieldName, ClassMetadata $class, - AbstractPlatform $platform + AbstractPlatform $platform, ): string { return $class->fieldMappings[$fieldName]['columnName']; } @@ -50,7 +50,7 @@ public function getJoinColumnName(array $joinColumn, ClassMetadata $class, Abstr public function getReferencedJoinColumnName( array $joinColumn, ClassMetadata $class, - AbstractPlatform $platform + AbstractPlatform $platform, ): string { return $joinColumn['referencedColumnName']; } @@ -75,7 +75,7 @@ public function getColumnAlias( string $columnName, int $counter, AbstractPlatform $platform, - ?ClassMetadata $class = null + ClassMetadata|null $class = null, ): string { return $this->getSQLResultCasing($platform, $columnName . '_' . $counter); } diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverride.php b/lib/Doctrine/ORM/Mapping/AssociationOverride.php index 68dedb6b5ae..4d02f05e938 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationOverride.php +++ b/lib/Doctrine/ORM/Mapping/AssociationOverride.php @@ -64,9 +64,9 @@ public function __construct( string $name, $joinColumns = null, $inverseJoinColumns = null, - ?JoinTable $joinTable = null, - ?string $inversedBy = null, - ?string $fetch = null + JoinTable|null $joinTable = null, + string|null $inversedBy = null, + string|null $fetch = null, ) { if ($joinColumns instanceof JoinColumn) { $joinColumns = [$joinColumns]; diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php b/lib/Doctrine/ORM/Mapping/AssociationOverrides.php index 211009d27c9..8df99c255c0 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AssociationOverrides.php @@ -25,9 +25,7 @@ final class AssociationOverrides implements Annotation */ public $overrides = []; - /** - * @param array|AssociationOverride $overrides - */ + /** @param array|AssociationOverride $overrides */ public function __construct($overrides) { if (! is_array($overrides)) { diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php index 2fec6fb0ca4..eed26647e65 100644 --- a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php @@ -25,9 +25,7 @@ final class AttributeOverrides implements Annotation */ public $overrides = []; - /** - * @param array|AttributeOverride $overrides - */ + /** @param array|AttributeOverride $overrides */ public function __construct($overrides) { if (! is_array($overrides)) { diff --git a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php index 53546e6e59c..0b8bc3cdff0 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php @@ -18,18 +18,14 @@ class AssociationBuilder /** @var mixed[]|null */ protected $joinColumns; - /** @var int */ - protected $type; - /** * @param mixed[] $mapping * @param int $type */ - public function __construct(ClassMetadataBuilder $builder, array $mapping, $type) + public function __construct(ClassMetadataBuilder $builder, array $mapping, protected $type) { $this->builder = $builder; $this->mapping = $mapping; - $this->type = $type; } /** @@ -56,9 +52,7 @@ public function inversedBy($fieldName) return $this; } - /** - * @return $this - */ + /** @return $this */ public function cascadeAll() { $this->mapping['cascade'] = ['ALL']; @@ -66,9 +60,7 @@ public function cascadeAll() return $this; } - /** - * @return $this - */ + /** @return $this */ public function cascadePersist() { $this->mapping['cascade'][] = 'persist'; @@ -76,9 +68,7 @@ public function cascadePersist() return $this; } - /** - * @return $this - */ + /** @return $this */ public function cascadeRemove() { $this->mapping['cascade'][] = 'remove'; @@ -86,9 +76,7 @@ public function cascadeRemove() return $this; } - /** - * @return $this - */ + /** @return $this */ public function cascadeMerge() { $this->mapping['cascade'][] = 'merge'; @@ -96,9 +84,7 @@ public function cascadeMerge() return $this; } - /** - * @return $this - */ + /** @return $this */ public function cascadeDetach() { $this->mapping['cascade'][] = 'detach'; @@ -106,9 +92,7 @@ public function cascadeDetach() return $this; } - /** - * @return $this - */ + /** @return $this */ public function cascadeRefresh() { $this->mapping['cascade'][] = 'refresh'; @@ -116,9 +100,7 @@ public function cascadeRefresh() return $this; } - /** - * @return $this - */ + /** @return $this */ public function fetchExtraLazy() { $this->mapping['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; @@ -126,9 +108,7 @@ public function fetchExtraLazy() return $this; } - /** - * @return $this - */ + /** @return $this */ public function fetchEager() { $this->mapping['fetch'] = ClassMetadata::FETCH_EAGER; @@ -136,9 +116,7 @@ public function fetchEager() return $this; } - /** - * @return $this - */ + /** @return $this */ public function fetchLazy() { $this->mapping['fetch'] = ClassMetadata::FETCH_LAZY; diff --git a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php index 4647bebab3c..d023481955e 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php @@ -68,7 +68,7 @@ public function addEmbedded($fieldName, $class, $columnPrefix = null) 'fieldName' => $fieldName, 'class' => $class, 'columnPrefix' => $columnPrefix, - ] + ], ); return $this; @@ -192,7 +192,7 @@ public function setDiscriminatorColumn($name, $type = 'string', $length = 255) 'name' => $name, 'type' => $type, 'length' => $length, - ] + ], ); return $this; @@ -286,7 +286,7 @@ public function createField($name, $type) [ 'fieldName' => $name, 'type' => $type, - ] + ], ); } @@ -306,7 +306,7 @@ public function createEmbedded($fieldName, $class) 'fieldName' => $fieldName, 'class' => $class, 'columnPrefix' => null, - ] + ], ); } @@ -348,7 +348,7 @@ public function createManyToOne($name, $targetEntity) 'fieldName' => $name, 'targetEntity' => $targetEntity, ], - ClassMetadata::MANY_TO_ONE + ClassMetadata::MANY_TO_ONE, ); } @@ -368,7 +368,7 @@ public function createOneToOne($name, $targetEntity) 'fieldName' => $name, 'targetEntity' => $targetEntity, ], - ClassMetadata::ONE_TO_ONE + ClassMetadata::ONE_TO_ONE, ); } @@ -425,7 +425,7 @@ public function createManyToMany($name, $targetEntity) 'fieldName' => $name, 'targetEntity' => $targetEntity, ], - ClassMetadata::MANY_TO_MANY + ClassMetadata::MANY_TO_MANY, ); } @@ -482,7 +482,7 @@ public function createOneToMany($name, $targetEntity) 'fieldName' => $name, 'targetEntity' => $targetEntity, ], - ClassMetadata::ONE_TO_MANY + ClassMetadata::ONE_TO_MANY, ); } diff --git a/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php index da92ddec2e1..a8508ab3bbe 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php @@ -17,9 +17,7 @@ class EmbeddedBuilder /** @var mixed[] */ private $mapping; - /** - * @param mixed[] $mapping - */ + /** @param mixed[] $mapping */ public function __construct(ClassMetadataBuilder $builder, array $mapping) { $this->builder = $builder; diff --git a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php index 89e88b5bb5c..bdd87788cb9 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php @@ -31,9 +31,7 @@ class FieldBuilder /** @var string|null */ private $customIdGenerator; - /** - * @param mixed[] $mapping - */ + /** @param mixed[] $mapping */ public function __construct(ClassMetadataBuilder $builder, array $mapping) { $this->builder = $builder; diff --git a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php index 4907d9b817a..5da24eb4b90 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php @@ -55,9 +55,7 @@ public function addInverseJoinColumn($columnName, $referencedColumnName, $nullab return $this; } - /** - * @return ClassMetadataBuilder - */ + /** @return ClassMetadataBuilder */ public function build() { $mapping = $this->mapping; diff --git a/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php index a6daab53a2a..daf323bc36d 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php @@ -35,9 +35,7 @@ public function setIndexBy($fieldName) return $this; } - /** - * @return ClassMetadataBuilder - */ + /** @return ClassMetadataBuilder */ public function build() { $mapping = $this->mapping; diff --git a/lib/Doctrine/ORM/Mapping/Cache.php b/lib/Doctrine/ORM/Mapping/Cache.php index 8284447c060..2d777058bc8 100644 --- a/lib/Doctrine/ORM/Mapping/Cache.php +++ b/lib/Doctrine/ORM/Mapping/Cache.php @@ -26,7 +26,7 @@ final class Cache implements Annotation /** @var string|null Cache region name. */ public $region; - public function __construct(string $usage = 'READ_ONLY', ?string $region = null) + public function __construct(string $usage = 'READ_ONLY', string|null $region = null) { $this->usage = $usage; $this->region = $region; diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index c589fc205a7..dc665fa4881 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -21,7 +21,7 @@ class ClassMetadata extends ClassMetadataInfo * @param string $entityName The name of the entity class the new instance is used for. * @psalm-param class-string $entityName */ - public function __construct($entityName, ?NamingStrategy $namingStrategy = null) + public function __construct($entityName, NamingStrategy|null $namingStrategy = null) { parent::__construct($entityName, $namingStrategy); } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 05139391278..76791965ccf 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -48,10 +48,10 @@ */ class ClassMetadataFactory extends AbstractClassMetadataFactory { - private ?EntityManagerInterface $em = null; - private ?AbstractPlatform $targetPlatform = null; - private ?MappingDriver $driver = null; - private ?EventManager $evm = null; + private EntityManagerInterface|null $em = null; + private AbstractPlatform|null $targetPlatform = null; + private MappingDriver|null $driver = null; + private EventManager|null $evm = null; /** @var mixed[] */ private array $embeddablesActiveNesting = []; @@ -68,7 +68,7 @@ protected function initialize(): void $this->initialized = true; } - protected function onNotFoundMetadata(string $className): ?ClassMetadata + protected function onNotFoundMetadata(string $className): ClassMetadata|null { if (! $this->evm->hasListeners(Events::onClassMetadataNotFound)) { return null; @@ -88,9 +88,9 @@ protected function onNotFoundMetadata(string $className): ?ClassMetadata */ protected function doLoadMetadata( ClassMetadataInterface $class, - ?ClassMetadataInterface $parent, + ClassMetadataInterface|null $parent, bool $rootEntityFound, - array $nonSuperclassParents + array $nonSuperclassParents, ): void { if ($parent) { $class->setInheritanceType($parent->inheritanceType); @@ -209,7 +209,7 @@ protected function doLoadMetadata( 'doctrine/orm', 'https://github.com/doctrine/orm/issues/8383', 'NOTIFY Change Tracking policy used in "%s" is deprecated, use deferred explicit instead.', - $class->name + $class->name, ); } @@ -221,7 +221,7 @@ protected function doLoadMetadata( * * @throws MappingException */ - protected function validateRuntimeMetadata(ClassMetadata $class, ?ClassMetadataInterface $parent): void + protected function validateRuntimeMetadata(ClassMetadata $class, ClassMetadataInterface|null $parent): void { if (! $class->reflClass) { // only validate if there is a reflection class instance @@ -398,7 +398,7 @@ private function addInheritedEmbeddedClasses(ClassMetadata $subClass, ClassMetad private function addNestedEmbeddedClasses( ClassMetadata $subClass, ClassMetadata $parentClass, - string $prefix + string $prefix, ): void { foreach ($subClass->embeddedClasses as $property => $embeddableClass) { if (isset($embeddableClass['inherited'])) { @@ -416,7 +416,7 @@ private function addNestedEmbeddedClasses( ? $prefix . '.' . $embeddableClass['declaredField'] : $prefix, 'originalField' => $embeddableClass['originalField'] ?: $property, - ] + ], ); } } @@ -465,7 +465,7 @@ private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, Class 'name' => $mapping['name'], 'columns' => $mapping['columns'], 'entities' => $entities, - ] + ], ); } } @@ -522,7 +522,7 @@ private function completeIdGeneratorMapping(ClassMetadata $class): void $sequenceGenerator = new SequenceGenerator( $this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->getTargetPlatform()), - (int) $definition['allocationSize'] + (int) $definition['allocationSize'], ); $class->setIdGenerator($sequenceGenerator); break; @@ -549,9 +549,7 @@ private function completeIdGeneratorMapping(ClassMetadata $class): void } } - /** - * @psalm-return ClassMetadata::GENERATOR_TYPE_SEQUENCE|ClassMetadata::GENERATOR_TYPE_IDENTITY - */ + /** @psalm-return ClassMetadata::GENERATOR_TYPE_SEQUENCE|ClassMetadata::GENERATOR_TYPE_IDENTITY */ private function determineIdGeneratorStrategy(AbstractPlatform $platform): int { if ( diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 9b8ddb38a12..32861a468a4 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -752,7 +752,7 @@ class ClassMetadataInfo implements ClassMetadata * @param string $entityName The name of the entity class the new instance is used for. * @psalm-param class-string $entityName */ - public function __construct($entityName, ?NamingStrategy $namingStrategy = null) + public function __construct($entityName, NamingStrategy|null $namingStrategy = null) { $this->name = $entityName; $this->rootEntityName = $entityName; @@ -1029,13 +1029,13 @@ public function wakeupReflection($reflService) $childProperty = $this->getAccessibleProperty( $reflService, $this->embeddedClasses[$embeddedClass['declaredField']]['class'], - $embeddedClass['originalField'] + $embeddedClass['originalField'], ); assert($childProperty !== null); $parentReflFields[$property] = new ReflectionEmbeddedProperty( $parentReflFields[$embeddedClass['declaredField']], $childProperty, - $this->embeddedClasses[$embeddedClass['declaredField']]['class'] + $this->embeddedClasses[$embeddedClass['declaredField']]['class'], ); continue; @@ -1044,7 +1044,7 @@ public function wakeupReflection($reflService) $fieldRefl = $this->getAccessibleProperty( $reflService, $embeddedClass['declared'] ?? $this->name, - $property + $property, ); $parentReflFields[$property] = $fieldRefl; @@ -1059,14 +1059,14 @@ public function wakeupReflection($reflService) if (isset($mapping['enumType'])) { $childProperty = new ReflectionEnumProperty( $childProperty, - $mapping['enumType'] + $mapping['enumType'], ); } $this->reflFields[$field] = new ReflectionEmbeddedProperty( $parentReflFields[$mapping['declaredField']], $childProperty, - $mapping['originalClass'] + $mapping['originalClass'], ); continue; } @@ -1078,7 +1078,7 @@ public function wakeupReflection($reflService) if (isset($mapping['enumType']) && $this->reflFields[$field] !== null) { $this->reflFields[$field] = new ReflectionEnumProperty( $this->reflFields[$field], - $mapping['enumType'] + $mapping['enumType'], ); } } @@ -1674,7 +1674,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping) throw MappingException::cannotMapCompositePrimaryKeyEntitiesAsForeignId( $mapping['targetEntity'], $this->name, - $mapping['fieldName'] + $mapping['fieldName'], ); } @@ -1690,7 +1690,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping) if ($this->cache && ! isset($mapping['cache'])) { throw NonCacheableEntityAssociation::fromEntityAndField( $this->name, - $mapping['fieldName'] + $mapping['fieldName'], ); } } @@ -1736,7 +1736,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping) throw MappingException::invalidCascadeOption( array_diff($cascades, $allCascades), $this->name, - $mapping['fieldName'] + $mapping['fieldName'], ); } @@ -2117,7 +2117,7 @@ public function hasField(string $fieldName): bool * @return mixed[] * @psalm-return list */ - public function getColumnNames(?array $fieldNames = null) + public function getColumnNames(array|null $fieldNames = null) { if ($fieldNames === null) { return array_keys($this->fieldNames); @@ -2177,9 +2177,7 @@ public function usesIdGenerator() return $this->generatorType !== self::GENERATOR_TYPE_NONE; } - /** - * @return bool - */ + /** @return bool */ public function isInheritanceTypeNone() { return $this->inheritanceType === self::INHERITANCE_TYPE_NONE; @@ -2254,7 +2252,7 @@ public function isIdentifierNatural() * * @todo 3.0 Remove this. PersisterHelper should fix it somehow */ - public function getTypeOfField(string $fieldName): ?string + public function getTypeOfField(string $fieldName): string|null { return isset($this->fieldMappings[$fieldName]) ? $this->fieldMappings[$fieldName]['type'] @@ -2849,7 +2847,7 @@ public function addLifecycleCallback($callback, $event) 'https://github.com/doctrine/orm/pull/8381', 'Registering lifecycle callback %s on Embedded class %s is not doing anything and will throw exception in 3.0', $event, - $this->name + $this->name, ); } @@ -2947,9 +2945,7 @@ public function setDiscriminatorColumn($columnDef) } } - /** - * @return array - */ + /** @return array */ final public function getDiscriminatorColumn(): array { if ($this->discriminatorColumn === null) { @@ -3369,7 +3365,7 @@ public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) $property, $fieldMapping['columnName'], $this->reflClass->name, - $embeddable->reflClass->name + $embeddable->reflClass->name, ); } @@ -3377,9 +3373,7 @@ public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) } } - /** - * @throws MappingException - */ + /** @throws MappingException */ private function assertFieldNotMapped(string $fieldName): void { if ( @@ -3427,9 +3421,7 @@ public function getSequencePrefix(AbstractPlatform $platform) return $sequencePrefix; } - /** - * @psalm-param array $mapping - */ + /** @psalm-param array $mapping */ private function assertMappingOrderBy(array $mapping): void { if (isset($mapping['orderBy']) && ! is_array($mapping['orderBy'])) { @@ -3437,10 +3429,8 @@ private function assertMappingOrderBy(array $mapping): void } } - /** - * @psalm-param class-string $class - */ - private function getAccessibleProperty(ReflectionService $reflService, string $class, string $field): ?ReflectionProperty + /** @psalm-param class-string $class */ + private function getAccessibleProperty(ReflectionService $reflService, string $class, string $field): ReflectionProperty|null { $reflectionProperty = $reflService->getAccessibleProperty($class, $field); if ($reflectionProperty?->isReadOnly()) { diff --git a/lib/Doctrine/ORM/Mapping/Column.php b/lib/Doctrine/ORM/Mapping/Column.php index f799bd9bccd..95aff82585e 100644 --- a/lib/Doctrine/ORM/Mapping/Column.php +++ b/lib/Doctrine/ORM/Mapping/Column.php @@ -72,19 +72,19 @@ final class Column implements Annotation * @psalm-param 'NEVER'|'INSERT'|'ALWAYS'|null $generated */ public function __construct( - ?string $name = null, - ?string $type = null, - ?int $length = null, - ?int $precision = null, - ?int $scale = null, + string|null $name = null, + string|null $type = null, + int|null $length = null, + int|null $precision = null, + int|null $scale = null, bool $unique = false, bool $nullable = false, bool $insertable = true, bool $updatable = true, - ?string $enumType = null, + string|null $enumType = null, array $options = [], - ?string $columnDefinition = null, - ?string $generated = null + string|null $columnDefinition = null, + string|null $generated = null, ) { $this->name = $name; $this->type = $type; diff --git a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php b/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php index 440fa081b54..e67bcf9503f 100644 --- a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php +++ b/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php @@ -18,7 +18,7 @@ final class CustomIdGenerator implements Annotation /** @var string|null */ public $class; - public function __construct(?string $class = null) + public function __construct(string|null $class = null) { $this->class = $class; } diff --git a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php b/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php index fbe3118155e..34c8940faf8 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php +++ b/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php @@ -15,7 +15,7 @@ class DefaultEntityListenerResolver implements EntityListenerResolver /** @psalm-var array Map to store entity listener instances. */ private array $instances = []; - public function clear(?string $className = null): void + public function clear(string|null $className = null): void { if ($className === null) { $this->instances = []; diff --git a/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php index 7228840691e..15218f9cd7c 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php @@ -60,7 +60,7 @@ public function joinTableName( public function joinKeyColumnName( string $entityName, - ?string $referencedColumnName, + string|null $referencedColumnName, ): string { return strtolower($this->classToTableName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName())); diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index 49d14a4e44c..56f654a27e6 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -71,7 +71,7 @@ public function getJoinColumnName(array $joinColumn, ClassMetadata $class, Abstr public function getReferencedJoinColumnName( array $joinColumn, ClassMetadata $class, - AbstractPlatform $platform + AbstractPlatform $platform, ): string { return isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['referencedColumnName']) @@ -120,7 +120,7 @@ static function ($joinColumn) use ($platform) { ? $platform->quoteIdentifier($joinColumn['name']) : $joinColumn['name']; }, - $joinColumns + $joinColumns, ); $quotedColumnNames = array_merge($quotedColumnNames, $assocQuotedColumnNames); @@ -133,7 +133,7 @@ public function getColumnAlias( string $columnName, int $counter, AbstractPlatform $platform, - ?ClassMetadata $class = null + ClassMetadata|null $class = null, ): string { // 1 ) Concatenate column name and counter // 2 ) Trim the column alias to the maximum identifier length of the platform. diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php b/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php index aa00a2d33a4..7fb895d2c0d 100644 --- a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php @@ -35,10 +35,10 @@ final class DiscriminatorColumn implements Annotation public $columnDefinition; public function __construct( - ?string $name = null, - ?string $type = null, - ?int $length = null, - ?string $columnDefinition = null + string|null $name = null, + string|null $type = null, + int|null $length = null, + string|null $columnDefinition = null, ) { $this->name = $name; $this->type = $type; diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php b/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php index ad36032b298..6c942823f7a 100644 --- a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php @@ -18,9 +18,7 @@ final class DiscriminatorMap implements Annotation /** @var array */ public $value; - /** - * @param array $value - */ + /** @param array $value */ public function __construct(array $value) { $this->value = $value; diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 71e1bd2b99a..6a7a8964eb9 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -143,7 +143,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad ) { throw MappingException::invalidIndexConfiguration( $className, - (string) ($indexAnnot->name ?? count($primaryTable['indexes'])) + (string) ($indexAnnot->name ?? count($primaryTable['indexes'])), ); } @@ -182,7 +182,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad ) { throw MappingException::invalidUniqueConstraintConfiguration( $className, - (string) ($uniqueConstraintAnnot->name ?? count($primaryTable['uniqueConstraints'])) + (string) ($uniqueConstraintAnnot->name ?? count($primaryTable['uniqueConstraints'])), ); } @@ -250,7 +250,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'name' => $resultSetMapping->name, 'entities' => $entities, 'columns' => $columns, - ] + ], ); } } @@ -261,7 +261,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad assert($inheritanceTypeAnnot instanceof Mapping\InheritanceType); $metadata->setInheritanceType( - constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value) + constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value), ); if ($metadata->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { @@ -276,7 +276,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'type' => $discrColumnAnnot->type ?: 'string', 'length' => $discrColumnAnnot->length ?? 255, 'columnDefinition' => $discrColumnAnnot->columnDefinition, - ] + ], ); } else { $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]); @@ -323,7 +323,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad [ 'usage' => (int) constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), 'region' => $cacheAnnot->region, - ] + ], ); } @@ -372,7 +372,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'sequenceName' => $seqGeneratorAnnot->sequenceName, 'allocationSize' => $seqGeneratorAnnot->allocationSize, 'initialValue' => $seqGeneratorAnnot->initialValue, - ] + ], ); } else { $customGeneratorAnnot = $this->reader->getPropertyAnnotation($property, Mapping\CustomIdGenerator::class); @@ -380,7 +380,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad $metadata->setCustomGeneratorDefinition( [ 'class' => $customGeneratorAnnot->class, - ] + ], ); } } @@ -390,7 +390,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad $mapping, $metadata, $joinColumns, - $className + $className, ); } } @@ -511,7 +511,7 @@ private function loadRelationShipMapping( array &$mapping, PersistenceClassMetadata $metadata, array $joinColumns, - string $className + string $className, ): void { $oneToOneAnnot = $this->reader->getPropertyAnnotation($property, Mapping\OneToOne::class); if ($oneToOneAnnot) { @@ -801,7 +801,7 @@ public function getReader() 'doctrine/orm', 'https://github.com/doctrine/orm/pull/9587', '%s is deprecated with no replacement', - __METHOD__ + __METHOD__, ); return $this->reader; @@ -830,7 +830,7 @@ public function isTransient($className) * * @return AnnotationDriver */ - public static function create($paths = [], ?AnnotationReader $reader = null) + public static function create($paths = [], AnnotationReader|null $reader = null) { if ($reader === null) { $reader = new AnnotationReader(); diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php index 8422b20ad5a..ba7872e4d84 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php @@ -43,9 +43,7 @@ class AttributeDriver implements MappingDriver */ protected $reader; - /** - * @param array $paths - */ + /** @param array $paths */ public function __construct(array $paths) { $this->reader = new AttributeReader(); @@ -65,7 +63,7 @@ public function getReader() 'doctrine/orm', 'https://github.com/doctrine/orm/pull/9587', '%s is deprecated with no replacement', - __METHOD__ + __METHOD__, ); return $this->reader; @@ -159,7 +157,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad ) { throw MappingException::invalidIndexConfiguration( $className, - (string) ($indexAnnot->name ?? $idx) + (string) ($indexAnnot->name ?? $idx), ); } @@ -200,7 +198,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad ) { throw MappingException::invalidUniqueConstraintConfiguration( $className, - (string) ($uniqueConstraintAnnot->name ?? $idx) + (string) ($uniqueConstraintAnnot->name ?? $idx), ); } @@ -234,7 +232,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad $inheritanceTypeAttribute = $classAttributes[Mapping\InheritanceType::class]; $metadata->setInheritanceType( - constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAttribute->value) + constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAttribute->value), ); if ($metadata->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { @@ -248,7 +246,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'type' => $discrColumnAttribute->type ?: 'string', 'length' => $discrColumnAttribute->length ?: 255, 'columnDefinition' => $discrColumnAttribute->columnDefinition, - ] + ], ); } else { $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]); @@ -295,7 +293,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad [ 'usage' => (int) constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAttribute->usage), 'region' => $cacheAttribute->region, - ] + ], ); } @@ -346,13 +344,13 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'sequenceName' => $seqGeneratorAttribute->sequenceName, 'allocationSize' => $seqGeneratorAttribute->allocationSize, 'initialValue' => $seqGeneratorAttribute->initialValue, - ] + ], ); } elseif ($customGeneratorAttribute !== null) { $metadata->setCustomGeneratorDefinition( [ 'class' => $customGeneratorAttribute->class, - ] + ], ); } } elseif ($oneToOneAttribute !== null) { diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php index a5b36420e43..a957562a5e6 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php @@ -17,9 +17,7 @@ use function is_subclass_of; use function sprintf; -/** - * @internal - */ +/** @internal */ final class AttributeReader { /** @var array,bool> */ @@ -67,7 +65,7 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN if ($this->isRepeatable($annotationName)) { throw new LogicException(sprintf( 'The attribute "%s" is repeatable. Call getPropertyAnnotationCollection() instead.', - $annotationName + $annotationName, )); } @@ -84,12 +82,12 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN */ public function getPropertyAnnotationCollection( ReflectionProperty $property, - string $annotationName + string $annotationName, ): RepeatableAttributeCollection { if (! $this->isRepeatable($annotationName)) { throw new LogicException(sprintf( 'The attribute "%s" is not repeatable. Call getPropertyAnnotation() instead.', - $annotationName + $annotationName, )); } @@ -134,9 +132,7 @@ private function convertToAttributeInstances(array $attributes): array return $instances; } - /** - * @param class-string $attributeClassName - */ + /** @param class-string $attributeClassName */ private function isRepeatable(string $attributeClassName): bool { if (isset($this->isRepeatableAttribute[$attributeClassName])) { diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index a36f3b4ba36..489c66e52ea 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -191,7 +191,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'Passing an instance of %s to %s is deprecated, please pass a ClassMetadata instance instead.', get_class($metadata), __METHOD__, - ClassMetadata::class + ClassMetadata::class, ); } @@ -277,9 +277,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad } } - /** - * @throws MappingException - */ + /** @throws MappingException */ private function reverseEngineerMappingFromDatabase(): void { if ($this->tables !== null) { @@ -301,7 +299,7 @@ private function reverseEngineerMappingFromDatabase(): void if (! $table->hasPrimaryKey()) { throw new MappingException( 'Table ' . $tableName . ' has no primary key. Doctrine does not ' . - "support reverse engineering from tables that don't have a primary key." + "support reverse engineering from tables that don't have a primary key.", ); } @@ -512,7 +510,7 @@ private function getTablePrimaryKeys(Table $table): array { try { return $table->getPrimaryKey()->getColumns(); - } catch (SchemaException $e) { + } catch (SchemaException) { // Do nothing } @@ -541,7 +539,7 @@ private function getClassNameForTable(string $tableName): string private function getFieldNameForColumn( string $tableName, string $columnName, - bool $fk = false + bool $fk = false, ): string { if (isset($this->fieldNamesForColumns[$tableName], $this->fieldNamesForColumns[$tableName][$columnName])) { return $this->fieldNamesForColumns[$tableName][$columnName]; diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 60ac316fa88..e2e416b1162 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -52,7 +52,7 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS if (! extension_loaded('simplexml')) { throw new LogicException(sprintf( 'The XML metadata driver cannot be enabled because the SimpleXML PHP extension is missing.' - . ' Please configure PHP with SimpleXML or choose a different metadata driver.' + . ' Please configure PHP with SimpleXML or choose a different metadata driver.', )); } @@ -62,14 +62,14 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS 'https://github.com/doctrine/orm/pull/6728', sprintf( 'Using XML mapping driver with XSD validation disabled is deprecated' - . ' and will not be supported in Doctrine ORM 3.0.' - ) + . ' and will not be supported in Doctrine ORM 3.0.', + ), ); } if ($isXsdValidationEnabled && ! extension_loaded('dom')) { throw new LogicException(sprintf( - 'XSD validation cannot be enabled because the DOM extension is missing.' + 'XSD validation cannot be enabled because the DOM extension is missing.', )); } @@ -101,7 +101,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad } } elseif ($xmlRoot->getName() === 'mapped-superclass') { $metadata->setCustomRepositoryClass( - isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null + isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null, ); $metadata->isMappedSuperclass = true; } elseif ($xmlRoot->getName() === 'embeddable') { @@ -165,7 +165,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'name' => (string) $rsmElement['name'], 'entities' => $entities, 'columns' => $columns, - ] + ], ); } } @@ -184,7 +184,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : 'string', 'length' => isset($discrColumn['length']) ? (int) $discrColumn['length'] : 255, 'columnDefinition' => isset($discrColumn['column-definition']) ? (string) $discrColumn['column-definition'] : null, - ] + ], ); } else { $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]); @@ -231,7 +231,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad ) { throw MappingException::invalidIndexConfiguration( $className, - (string) ($indexXml['name'] ?? count($metadata->table['indexes'])) + (string) ($indexXml['name'] ?? count($metadata->table['indexes'])), ); } @@ -274,7 +274,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad ) { throw MappingException::invalidUniqueConstraintConfiguration( $className, - (string) ($uniqueXml['name'] ?? count($metadata->table['uniqueConstraints'])) + (string) ($uniqueXml['name'] ?? count($metadata->table['uniqueConstraints'])), ); } @@ -389,14 +389,14 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad 'sequenceName' => (string) $seqGenerator['sequence-name'], 'allocationSize' => (string) $seqGenerator['allocation-size'], 'initialValue' => (string) $seqGenerator['initial-value'], - ] + ], ); } elseif (isset($idElement->{'custom-id-generator'})) { $customGenerator = $idElement->{'custom-id-generator'}; $metadata->setCustomGeneratorDefinition( [ 'class' => (string) $customGenerator['class'], - ] + ], ); } } diff --git a/lib/Doctrine/ORM/Mapping/Embedded.php b/lib/Doctrine/ORM/Mapping/Embedded.php index b330cfc3c50..fb5104218f5 100644 --- a/lib/Doctrine/ORM/Mapping/Embedded.php +++ b/lib/Doctrine/ORM/Mapping/Embedded.php @@ -18,12 +18,8 @@ final class Embedded implements Annotation /** @var string|null */ public $class; - /** @var string|bool|null */ - public $columnPrefix; - - public function __construct(?string $class = null, $columnPrefix = null) + public function __construct(string|null $class = null, public $columnPrefix = null) { - $this->class = $class; - $this->columnPrefix = $columnPrefix; + $this->class = $class; } } diff --git a/lib/Doctrine/ORM/Mapping/Entity.php b/lib/Doctrine/ORM/Mapping/Entity.php index 902e668bc54..dedc2704cc6 100644 --- a/lib/Doctrine/ORM/Mapping/Entity.php +++ b/lib/Doctrine/ORM/Mapping/Entity.php @@ -26,10 +26,8 @@ final class Entity implements Annotation /** @var bool */ public $readOnly = false; - /** - * @psalm-param class-string>|null $repositoryClass - */ - public function __construct(?string $repositoryClass = null, bool $readOnly = false) + /** @psalm-param class-string>|null $repositoryClass */ + public function __construct(string|null $repositoryClass = null, bool $readOnly = false) { $this->repositoryClass = $repositoryClass; $this->readOnly = $readOnly; diff --git a/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php b/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php index 7cfed783876..eabc217314d 100644 --- a/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php +++ b/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php @@ -14,7 +14,7 @@ interface EntityListenerResolver * * @param string|null $className May be any arbitrary string. Name kept for BC only. */ - public function clear(?string $className = null): void; + public function clear(string|null $className = null): void; /** * Returns a entity listener instance for the given identifier. diff --git a/lib/Doctrine/ORM/Mapping/EntityListeners.php b/lib/Doctrine/ORM/Mapping/EntityListeners.php index d8268422a39..1ba79ef3789 100644 --- a/lib/Doctrine/ORM/Mapping/EntityListeners.php +++ b/lib/Doctrine/ORM/Mapping/EntityListeners.php @@ -25,9 +25,7 @@ final class EntityListeners implements Annotation */ public $value = []; - /** - * @param array $value - */ + /** @param array $value */ public function __construct(array $value = []) { $this->value = $value; diff --git a/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php b/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php index 8fc0dabee8f..a9895ceb218 100644 --- a/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php +++ b/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php @@ -17,7 +17,7 @@ public static function withPlatform(AbstractPlatform $platform): self { return new self(sprintf( 'Platform %s does not support generating identifiers', - get_debug_type($platform) + get_debug_type($platform), )); } } diff --git a/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php b/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php index e88e469c9d6..b9e10bf1649 100644 --- a/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php +++ b/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php @@ -17,14 +17,12 @@ public static function onClassNotConfigured(): self return new self('Cannot instantiate custom generator, no class has been defined'); } - /** - * @param mixed[] $definition - */ + /** @param mixed[] $definition */ public static function onMissingClass(array $definition): self { return new self(sprintf( 'Cannot instantiate custom generator : %s', - var_export($definition, true) + var_export($definition, true), )); } } diff --git a/lib/Doctrine/ORM/Mapping/Index.php b/lib/Doctrine/ORM/Mapping/Index.php index ca53aaf6175..2e547a993bf 100644 --- a/lib/Doctrine/ORM/Mapping/Index.php +++ b/lib/Doctrine/ORM/Mapping/Index.php @@ -37,11 +37,11 @@ final class Index implements Annotation * @param array|null $options */ public function __construct( - ?array $columns = null, - ?array $fields = null, - ?string $name = null, - ?array $flags = null, - ?array $options = null + array|null $columns = null, + array|null $fields = null, + string|null $name = null, + array|null $flags = null, + array|null $options = null, ) { $this->columns = $columns; $this->fields = $fields; diff --git a/lib/Doctrine/ORM/Mapping/JoinColumn.php b/lib/Doctrine/ORM/Mapping/JoinColumn.php index 0cf70971a20..9b6ac41962d 100644 --- a/lib/Doctrine/ORM/Mapping/JoinColumn.php +++ b/lib/Doctrine/ORM/Mapping/JoinColumn.php @@ -27,9 +27,6 @@ final class JoinColumn implements Annotation /** @var bool */ public $nullable = true; - /** @var mixed */ - public $onDelete; - /** @var string|null */ public $columnDefinition; @@ -43,24 +40,21 @@ final class JoinColumn implements Annotation /** @var array */ public $options = []; - /** - * @param array $options - */ + /** @param array $options */ public function __construct( - ?string $name = null, + string|null $name = null, string $referencedColumnName = 'id', bool $unique = false, bool $nullable = true, - $onDelete = null, - ?string $columnDefinition = null, - ?string $fieldName = null, - array $options = [] + public $onDelete = null, + string|null $columnDefinition = null, + string|null $fieldName = null, + array $options = [], ) { $this->name = $name; $this->referencedColumnName = $referencedColumnName; $this->unique = $unique; $this->nullable = $nullable; - $this->onDelete = $onDelete; $this->columnDefinition = $columnDefinition; $this->fieldName = $fieldName; $this->options = $options; diff --git a/lib/Doctrine/ORM/Mapping/JoinTable.php b/lib/Doctrine/ORM/Mapping/JoinTable.php index 75a2d30270b..ae39de288af 100644 --- a/lib/Doctrine/ORM/Mapping/JoinTable.php +++ b/lib/Doctrine/ORM/Mapping/JoinTable.php @@ -30,15 +30,13 @@ final class JoinTable implements Annotation /** @var array */ public $options = []; - /** - * @param array $options - */ + /** @param array $options */ public function __construct( - ?string $name = null, - ?string $schema = null, + string|null $name = null, + string|null $schema = null, $joinColumns = [], $inverseJoinColumns = [], - array $options = [] + array $options = [], ) { $this->name = $name; $this->schema = $schema; diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/lib/Doctrine/ORM/Mapping/ManyToMany.php index 99767eedae3..0891a17254c 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -47,12 +47,12 @@ final class ManyToMany implements Annotation */ public function __construct( string $targetEntity, - ?string $mappedBy = null, - ?string $inversedBy = null, - ?array $cascade = null, + string|null $mappedBy = null, + string|null $inversedBy = null, + array|null $cascade = null, string $fetch = 'LAZY', bool $orphanRemoval = false, - ?string $indexBy = null + string|null $indexBy = null, ) { $this->targetEntity = $targetEntity; $this->mappedBy = $mappedBy; diff --git a/lib/Doctrine/ORM/Mapping/ManyToOne.php b/lib/Doctrine/ORM/Mapping/ManyToOne.php index abcd82d8d7b..a98b801b9c4 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToOne.php +++ b/lib/Doctrine/ORM/Mapping/ManyToOne.php @@ -37,10 +37,10 @@ final class ManyToOne implements Annotation * @param string[]|null $cascade */ public function __construct( - ?string $targetEntity = null, - ?array $cascade = null, + string|null $targetEntity = null, + array|null $cascade = null, string $fetch = 'LAZY', - ?string $inversedBy = null + string|null $inversedBy = null, ) { $this->targetEntity = $targetEntity; $this->cascade = $cascade; diff --git a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php b/lib/Doctrine/ORM/Mapping/MappedSuperclass.php index d4e53fa77bd..f652461ae55 100644 --- a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php +++ b/lib/Doctrine/ORM/Mapping/MappedSuperclass.php @@ -22,10 +22,8 @@ final class MappedSuperclass implements Annotation */ public $repositoryClass; - /** - * @psalm-param class-string|null $repositoryClass - */ - public function __construct(?string $repositoryClass = null) + /** @psalm-param class-string|null $repositoryClass */ + public function __construct(string|null $repositoryClass = null) { $this->repositoryClass = $repositoryClass; } diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 9400afa75e4..600fe7851c8 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -26,9 +26,7 @@ */ class MappingException extends Exception implements ORMException { - /** - * @return MappingException - */ + /** @return MappingException */ public static function pathRequired() { return new self('Specifying the paths to your entities is required ' . @@ -47,13 +45,13 @@ public static function identifierRequired($entityName) return new self(sprintf( 'No identifier/primary key specified for Entity "%s" sub class of "%s". Every Entity must have an identifier/primary key.', $entityName, - $parent + $parent, )); } return new self(sprintf( 'No identifier/primary key specified for Entity "%s". Every Entity must have an identifier/primary key.', - $entityName + $entityName, )); } @@ -68,9 +66,7 @@ public static function invalidInheritanceType($entityName, $type) return new self(sprintf("The inheritance type '%s' specified for '%s' does not exist.", $type, $entityName)); } - /** - * @return MappingException - */ + /** @return MappingException */ public static function generatorNotAllowedWithCompositeId() { return new self("Id generators can't be used with a composite id."); @@ -85,7 +81,7 @@ public static function missingFieldName($entity) { return new self(sprintf( "The field or association mapping misses the 'fieldName' attribute in entity '%s'.", - $entity + $entity, )); } @@ -156,7 +152,7 @@ public static function invalidOverrideFieldType($className, $fieldName) return new self(sprintf( "The column type of attribute '%s' on class '%s' could not be changed.", $fieldName, - $className + $className, )); } @@ -225,7 +221,7 @@ public static function missingQueryMapping($entity, $queryName) return new self(sprintf( 'Query named "%s" in "%s requires a result class or result set mapping.', $queryName, - $entity + $entity, )); } @@ -240,7 +236,7 @@ public static function missingResultSetMappingEntity($entity, $resultName) return new self(sprintf( 'Result set mapping named "%s" in "%s requires a entity class name.', $resultName, - $entity + $entity, )); } @@ -255,7 +251,7 @@ public static function missingResultSetMappingFieldName($entity, $resultName) return new self(sprintf( 'Result set mapping named "%s" in "%s requires a field name.', $resultName, - $entity + $entity, )); } @@ -274,7 +270,7 @@ public static function oneToManyRequiresMappedBy(string $entityName, string $fie return new self(sprintf( "OneToMany mapping on entity '%s' field '%s' requires the 'mappedBy' attribute.", $entityName, - $fieldName + $fieldName, )); } @@ -346,7 +342,7 @@ public static function joinColumnMustPointToMappedField($className, $joinColumn) return new self(sprintf( 'The column %s must be mapped to a field in class %s since it is referenced by a join column of another class.', $joinColumn, - $className + $className, )); } @@ -362,13 +358,13 @@ public static function classIsNotAValidEntityOrMappedSuperClass($className) return new self(sprintf( 'Class "%s" sub class of "%s" is not a valid entity or mapped super class.', $className, - $parent + $parent, )); } return new self(sprintf( 'Class "%s" is not a valid entity or mapped super class.', - $className + $className, )); } @@ -383,7 +379,7 @@ public static function duplicateFieldMapping($entity, $fieldName) return new self(sprintf( 'Property "%s" in "%s" was already declared, but it must be declared only once', $fieldName, - $entity + $entity, )); } @@ -398,7 +394,7 @@ public static function duplicateAssociationMapping($entity, $fieldName) return new self(sprintf( 'Property "%s" in "%s" was already declared, but it must be declared only once', $fieldName, - $entity + $entity, )); } @@ -413,7 +409,7 @@ public static function duplicateQueryMapping($entity, $queryName) return new self(sprintf( 'Query named "%s" in "%s" was already declared, but it must be declared only once', $queryName, - $entity + $entity, )); } @@ -428,7 +424,7 @@ public static function duplicateResultSetMapping($entity, $resultName) return new self(sprintf( 'Result set mapping named "%s" in "%s" was already declared, but it must be declared only once', $resultName, - $entity + $entity, )); } @@ -465,7 +461,7 @@ public static function unsupportedOptimisticLockingType($entity, $fieldName, $un 'Locking type "%s" (specified in "%s", field "%s") is not supported by Doctrine.', $unsupportedType, $entity, - $fieldName + $fieldName, )); } @@ -482,7 +478,7 @@ public static function fileMappingDriversRequireConfiguredDirectoryPath($path = return new self( 'File mapping drivers must have a valid directory path, ' . - 'however the given path ' . $path . ' seems to be incorrect!' + 'however the given path ' . $path . ' seems to be incorrect!', ); } @@ -501,7 +497,7 @@ public static function invalidClassInDiscriminatorMap($className, $owningClass) "Entity class '%s' used in the discriminator map of class '%s' " . 'does not exist.', $className, - $owningClass + $owningClass, )); } @@ -522,8 +518,8 @@ static function ($a, $b) { return sprintf("'%s': '%s'", $a, $b); }, array_keys($map), - array_values($map) - )) . '})' + array_values($map), + )) . '})', ); } @@ -536,7 +532,7 @@ public static function missingDiscriminatorMap($className) { return new self(sprintf( "Entity class '%s' is using inheritance but no discriminator map was defined.", - $className + $className, )); } @@ -549,7 +545,7 @@ public static function missingDiscriminatorColumn($className) { return new self(sprintf( "Entity class '%s' is using inheritance but no discriminator column was defined.", - $className + $className, )); } @@ -564,7 +560,7 @@ public static function invalidDiscriminatorColumnType($className, $type) return new self(sprintf( "Discriminator column type on entity class '%s' is not allowed to be '%s'. 'string' or 'integer' type variables are suggested!", $className, - $type + $type, )); } @@ -589,7 +585,7 @@ public static function cannotVersionIdField($className, $fieldName) return new self(sprintf( "Setting Id field '%s' as versionable in entity class '%s' is not supported.", $fieldName, - $className + $className, )); } @@ -651,7 +647,7 @@ public static function noFieldNameFoundForColumn($className, $column) "Cannot find a field on '%s' that is mapped to column '%s'. Either the " . 'field does not exist or an association exists but it has multiple join columns.', $className, - $column + $column, )); } @@ -666,7 +662,7 @@ public static function illegalOrphanRemovalOnIdentifierAssociation($className, $ return new self(sprintf( "The orphan removal option is not allowed on an association that is part of the identifier in '%s#%s'.", $className, - $field + $field, )); } @@ -693,7 +689,7 @@ public static function illegalInverseIdentifierAssociation($className, $field) return new self(sprintf( "An inverse association is not allowed to be identifier in '%s#%s'.", $className, - $field + $field, )); } @@ -708,7 +704,7 @@ public static function illegalToManyIdentifierAssociation($className, $field) return new self(sprintf( "Many-to-many or one-to-many associations are not allowed to be identifier in '%s#%s'.", $className, - $field + $field, )); } @@ -733,7 +729,7 @@ public static function mappedClassNotPartOfDiscriminatorMap($className, $rootCla return new self( "Entity '" . $className . "' has to be part of the discriminator map of '" . $rootClassName . "' " . "to be properly mapped in the inheritance hierarchy. Alternatively you can make '" . $className . "' an abstract class " . - 'to avoid this exception from occurring.' + 'to avoid this exception from occurring.', ); } @@ -838,7 +834,7 @@ public static function invalidCascadeOption(array $cascades, $className, $proper "You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'", $className, $propertyName, - $cascades + $cascades, )); } @@ -850,7 +846,7 @@ public static function invalidCascadeOption(array $cascades, $className, $proper public static function missingSequenceName($className) { return new self( - sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className) + sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className), ); } @@ -867,8 +863,8 @@ public static function infiniteEmbeddableNesting($className, $propertyName) 'Infinite nesting detected for embedded property %s::%s. ' . 'You cannot embed an embeddable from the same type inside an embeddable.', $className, - $propertyName - ) + $propertyName, + ), ); } @@ -885,48 +881,42 @@ public static function illegalOverrideOfInheritedProperty($className, $propertyN 'Override for %s::%s is only allowed for attributes/associations ' . 'declared on a mapped superclass or a trait.', $className, - $propertyName - ) + $propertyName, + ), ); } - /** - * @return self - */ + /** @return self */ public static function invalidIndexConfiguration($className, $indexName) { return new self( sprintf( 'Index %s for entity %s should contain columns or fields values, but not both.', $indexName, - $className - ) + $className, + ), ); } - /** - * @return self - */ + /** @return self */ public static function invalidUniqueConstraintConfiguration($className, $indexName) { return new self( sprintf( 'Unique constraint %s for entity %s should contain columns or fields values, but not both.', $indexName, - $className - ) + $className, + ), ); } - /** - * @param mixed $givenValue - */ + /** @param mixed $givenValue */ public static function invalidOverrideType(string $expectdType, $givenValue): self { return new self(sprintf( 'Expected %s, but %s was given.', $expectdType, - get_debug_type($givenValue) + get_debug_type($givenValue), )); } @@ -936,7 +926,7 @@ public static function nonEnumTypeMapped(string $className, string $fieldName, s 'Attempting to map non-enum type %s as enum in entity %s::$%s', $enumType, $className, - $fieldName + $fieldName, )); } @@ -949,7 +939,7 @@ public static function invalidEnumValue( string $fieldName, string $value, string $enumType, - ValueError $previous + ValueError $previous, ): self { return new self(sprintf( <<<'EXCEPTION' @@ -961,13 +951,11 @@ public static function invalidEnumValue( $className, $fieldName, $value, - $enumType + $enumType, ), 0, $previous); } - /** - * @param LibXMLError[] $errors - */ + /** @param LibXMLError[] $errors */ public static function fromLibXmlErrors(array $errors): self { $formatter = static function (LibXMLError $error): string { @@ -975,7 +963,7 @@ public static function fromLibXmlErrors(array $errors): self 'libxml error: %s in %s at line %d', $error->message, $error->file, - $error->line + $error->line, ); }; diff --git a/lib/Doctrine/ORM/Mapping/NamingStrategy.php b/lib/Doctrine/ORM/Mapping/NamingStrategy.php index 26401cb9e3a..afedebe68db 100644 --- a/lib/Doctrine/ORM/Mapping/NamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/NamingStrategy.php @@ -67,5 +67,5 @@ public function joinTableName(string $sourceEntity, string $targetEntity, string * entity with join columns * defined in the mapping */ - public function joinKeyColumnName(string $entityName, ?string $referencedColumnName): string; + public function joinKeyColumnName(string $entityName, string|null $referencedColumnName): string; } diff --git a/lib/Doctrine/ORM/Mapping/OneToMany.php b/lib/Doctrine/ORM/Mapping/OneToMany.php index 63f0ae46b6b..abbe32f180b 100644 --- a/lib/Doctrine/ORM/Mapping/OneToMany.php +++ b/lib/Doctrine/ORM/Mapping/OneToMany.php @@ -43,12 +43,12 @@ final class OneToMany implements Annotation * @param string[]|null $cascade */ public function __construct( - ?string $mappedBy = null, - ?string $targetEntity = null, - ?array $cascade = null, + string|null $mappedBy = null, + string|null $targetEntity = null, + array|null $cascade = null, string $fetch = 'LAZY', bool $orphanRemoval = false, - ?string $indexBy = null + string|null $indexBy = null, ) { $this->mappedBy = $mappedBy; $this->targetEntity = $targetEntity; diff --git a/lib/Doctrine/ORM/Mapping/OneToOne.php b/lib/Doctrine/ORM/Mapping/OneToOne.php index 946d3fab7a4..694f459c1e8 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOne.php +++ b/lib/Doctrine/ORM/Mapping/OneToOne.php @@ -43,12 +43,12 @@ final class OneToOne implements Annotation * @param array|null $cascade */ public function __construct( - ?string $mappedBy = null, - ?string $inversedBy = null, - ?string $targetEntity = null, - ?array $cascade = null, + string|null $mappedBy = null, + string|null $inversedBy = null, + string|null $targetEntity = null, + array|null $cascade = null, string $fetch = 'LAZY', - bool $orphanRemoval = false + bool $orphanRemoval = false, ) { $this->mappedBy = $mappedBy; $this->inversedBy = $inversedBy; diff --git a/lib/Doctrine/ORM/Mapping/OrderBy.php b/lib/Doctrine/ORM/Mapping/OrderBy.php index a5f45241b4f..8cc76b40767 100644 --- a/lib/Doctrine/ORM/Mapping/OrderBy.php +++ b/lib/Doctrine/ORM/Mapping/OrderBy.php @@ -18,9 +18,7 @@ final class OrderBy implements Annotation /** @var array */ public $value; - /** - * @param array $value - */ + /** @param array $value */ public function __construct(array $value) { $this->value = $value; diff --git a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php index 395680fe3dd..e6f8b6333dd 100644 --- a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php @@ -50,7 +50,7 @@ public function getJoinColumnName(array $joinColumn, ClassMetadata $class, Abstr public function getReferencedJoinColumnName( array $joinColumn, ClassMetadata $class, - AbstractPlatform $platform + AbstractPlatform $platform, ): string; /** @@ -67,6 +67,6 @@ public function getColumnAlias( string $columnName, int $counter, AbstractPlatform $platform, - ?ClassMetadata $class = null + ClassMetadata|null $class = null, ): string; } diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php index 024b37a31d9..a216d8b4b94 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php @@ -18,7 +18,7 @@ */ final class ReflectionEmbeddedProperty extends ReflectionProperty { - private ?Instantiator $instantiator = null; + private Instantiator|null $instantiator = null; /** * @param ReflectionProperty $parentProperty reflection property of the class where the embedded object has to be put @@ -28,12 +28,12 @@ final class ReflectionEmbeddedProperty extends ReflectionProperty public function __construct( private readonly ReflectionProperty $parentProperty, private readonly ReflectionProperty $childProperty, - private readonly string $embeddedClass + private readonly string $embeddedClass, ) { parent::__construct($childProperty->getDeclaringClass()->getName(), $childProperty->getName()); } - public function getValue(?object $object = null): mixed + public function getValue(object|null $object = null): mixed { $embeddedObject = $this->parentProperty->getValue($object); diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php index 98448d519fd..8bb14ccfd2f 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php @@ -14,20 +14,18 @@ final class ReflectionEnumProperty extends ReflectionProperty { - /** - * @param class-string $enumType - */ + /** @param class-string $enumType */ public function __construct( private readonly ReflectionProperty $originalReflectionProperty, - private readonly string $enumType + private readonly string $enumType, ) { parent::__construct( $originalReflectionProperty->getDeclaringClass()->getName(), - $originalReflectionProperty->getName() + $originalReflectionProperty->getName(), ); } - public function getValue(?object $object = null): int|string|array|null + public function getValue(object|null $object = null): int|string|array|null { if ($object === null) { return null; @@ -42,7 +40,7 @@ public function getValue(?object $object = null): int|string|array|null if (is_array($enum)) { return array_map( static fn (BackedEnum $item): int|string => $item->value, - $enum + $enum, ); } @@ -80,7 +78,7 @@ private function initializeEnumValue(object $object, int|string $value): BackedE $this->originalReflectionProperty->getName(), (string) $value, $enumType, - $e + $e, ); } } diff --git a/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php index c3697226abc..13e9f6ddda3 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php @@ -14,13 +14,11 @@ use function is_object; use function sprintf; -/** - * @internal - */ +/** @internal */ final class ReflectionReadonlyProperty extends ReflectionProperty { public function __construct( - private readonly ReflectionProperty $wrappedProperty + private readonly ReflectionProperty $wrappedProperty, ) { if (! $wrappedProperty->isReadOnly()) { throw new InvalidArgumentException('Given property is not readonly.'); @@ -29,7 +27,7 @@ public function __construct( parent::__construct($wrappedProperty->class, $wrappedProperty->name); } - public function getValue(?object $object = null): mixed + public function getValue(object|null $object = null): mixed { return $this->wrappedProperty->getValue(...func_get_args()); } diff --git a/lib/Doctrine/ORM/Mapping/SequenceGenerator.php b/lib/Doctrine/ORM/Mapping/SequenceGenerator.php index 84593f2d102..232c6bed4e7 100644 --- a/lib/Doctrine/ORM/Mapping/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Mapping/SequenceGenerator.php @@ -25,9 +25,9 @@ final class SequenceGenerator implements Annotation public $initialValue = 1; public function __construct( - ?string $sequenceName = null, + string|null $sequenceName = null, int $allocationSize = 1, - int $initialValue = 1 + int $initialValue = 1, ) { $this->sequenceName = $sequenceName; $this->allocationSize = $allocationSize; diff --git a/lib/Doctrine/ORM/Mapping/Table.php b/lib/Doctrine/ORM/Mapping/Table.php index 7dd6cb273cf..774f7c2d5ec 100644 --- a/lib/Doctrine/ORM/Mapping/Table.php +++ b/lib/Doctrine/ORM/Mapping/Table.php @@ -36,11 +36,11 @@ final class Table implements Annotation * @param array $options */ public function __construct( - ?string $name = null, - ?string $schema = null, - ?array $indexes = null, - ?array $uniqueConstraints = null, - array $options = [] + string|null $name = null, + string|null $schema = null, + array|null $indexes = null, + array|null $uniqueConstraints = null, + array $options = [], ) { $this->name = $name; $this->schema = $schema; diff --git a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php b/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php index eafbafd5f69..cedc1502205 100644 --- a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php +++ b/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php @@ -22,21 +22,16 @@ */ class UnderscoreNamingStrategy implements NamingStrategy { - private int $case; - /** * Underscore naming strategy construct. * * @param int $case CASE_LOWER | CASE_UPPER */ - public function __construct(int $case = CASE_LOWER) + public function __construct(private int $case = CASE_LOWER) { - $this->case = $case; } - /** - * @return int CASE_LOWER | CASE_UPPER - */ + /** @return int CASE_LOWER | CASE_UPPER */ public function getCase(): int { return $this->case; @@ -94,7 +89,7 @@ public function joinTableName( public function joinKeyColumnName( string $entityName, - ?string $referencedColumnName + string|null $referencedColumnName, ): string { return $this->classToTableName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName()); diff --git a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php b/lib/Doctrine/ORM/Mapping/UniqueConstraint.php index 37d515d8215..097163e39db 100644 --- a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php +++ b/lib/Doctrine/ORM/Mapping/UniqueConstraint.php @@ -33,10 +33,10 @@ final class UniqueConstraint implements Annotation * @param array $options */ public function __construct( - ?string $name = null, - ?array $columns = null, - ?array $fields = null, - ?array $options = null + string|null $name = null, + array|null $columns = null, + array|null $fields = null, + array|null $options = null, ) { $this->name = $name; $this->columns = $columns; diff --git a/lib/Doctrine/ORM/NativeQuery.php b/lib/Doctrine/ORM/NativeQuery.php index 97ba4c87c33..f76e427797c 100644 --- a/lib/Doctrine/ORM/NativeQuery.php +++ b/lib/Doctrine/ORM/NativeQuery.php @@ -19,9 +19,7 @@ final class NativeQuery extends AbstractQuery { private string $sql; - /** - * @return $this - */ + /** @return $this */ public function setSQL(string $sql): self { $this->sql = $sql; @@ -62,7 +60,7 @@ protected function _doExecute(): Result|int $this->sql, $parameters, $types, - $this->_queryCacheProfile + $this->_queryCacheProfile, ); } } diff --git a/lib/Doctrine/ORM/NonUniqueResultException.php b/lib/Doctrine/ORM/NonUniqueResultException.php index 80caa7c20b3..8f56e44c5ca 100644 --- a/lib/Doctrine/ORM/NonUniqueResultException.php +++ b/lib/Doctrine/ORM/NonUniqueResultException.php @@ -11,7 +11,7 @@ class NonUniqueResultException extends UnexpectedResultException { public const DEFAULT_MESSAGE = 'More than one result was found for query although one row or none was expected.'; - public function __construct(?string $message = null) + public function __construct(string|null $message = null) { parent::__construct($message ?? self::DEFAULT_MESSAGE); } diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index 248136f3fd6..d45ae7e5ad1 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -62,7 +62,7 @@ public static function entityWithoutIdentity($className, $entity) { return new self( "The given entity of type '" . $className . "' (" . self::objToStr($entity) . ') has no identity/no ' . - 'id values set. It cannot be added to the identity map.' + 'id values set. It cannot be added to the identity map.', ); } @@ -90,7 +90,7 @@ static function (array $newEntityWithAssociation): string { return self::newEntityFoundThroughRelationshipMessage($associationMapping, $entity); }, - $newEntitiesWithAssociations + $newEntitiesWithAssociations, ); if (count($errorMessages) === 1) { @@ -100,7 +100,7 @@ static function (array $newEntityWithAssociation): string { return new self( 'Multiple non-persisted new entities were found through the given association graph:' . "\n\n * " - . implode("\n * ", $errorMessages) + . implode("\n * ", $errorMessages), ); } @@ -185,18 +185,14 @@ public static function invalidObject($context, $given, $parameterIndex = 1) ' to be an entity object, ' . gettype($given) . ' given.'); } - /** - * @return ORMInvalidArgumentException - */ + /** @return ORMInvalidArgumentException */ public static function invalidCompositeIdentifier() { return new self('Binding an entity with a composite primary key to a query is not supported. ' . 'You should split the parameter into the explicit fields and bind them separately.'); } - /** - * @return ORMInvalidArgumentException - */ + /** @return ORMInvalidArgumentException */ public static function invalidIdentifierBindingEntity(string $class) { return new self(sprintf( @@ -205,7 +201,7 @@ public static function invalidIdentifierBindingEntity(string $class) Class "%s" does not have an identifier. EXCEPTION , - $class + $class, )); } @@ -224,7 +220,7 @@ public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $a $expectedType, $assoc['sourceEntity'], $assoc['fieldName'], - get_debug_type($actualValue) + get_debug_type($actualValue), )); } @@ -236,9 +232,7 @@ private static function objToStr(object $obj): string return $obj instanceof Stringable ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj); } - /** - * @psalm-param array $associationMapping - */ + /** @psalm-param array $associationMapping */ private static function newEntityFoundThroughRelationshipMessage(array $associationMapping, object $entity): string { return 'A new entity was found through the relationship \'' diff --git a/lib/Doctrine/ORM/ORMSetup.php b/lib/Doctrine/ORM/ORMSetup.php index efd5682aedb..1800d920ab1 100644 --- a/lib/Doctrine/ORM/ORMSetup.php +++ b/lib/Doctrine/ORM/ORMSetup.php @@ -34,8 +34,8 @@ final class ORMSetup public static function createAnnotationMetadataConfiguration( array $paths, bool $isDevMode = false, - ?string $proxyDir = null, - ?CacheItemPoolInterface $cache = null + string|null $proxyDir = null, + CacheItemPoolInterface|null $cache = null, ): Configuration { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(self::createDefaultAnnotationDriver($paths)); @@ -50,13 +50,13 @@ public static function createAnnotationMetadataConfiguration( */ public static function createDefaultAnnotationDriver( array $paths = [], - ?CacheItemPoolInterface $cache = null + CacheItemPoolInterface|null $cache = null, ): AnnotationDriver { if (! class_exists(AnnotationReader::class)) { throw new LogicException(sprintf( 'The annotation metadata driver cannot be enabled because the "doctrine/annotations" library' . ' is not installed. Please run "composer require doctrine/annotations" or choose a different' - . ' metadata driver.' + . ' metadata driver.', )); } @@ -81,8 +81,8 @@ public static function createDefaultAnnotationDriver( public static function createAttributeMetadataConfiguration( array $paths, bool $isDevMode = false, - ?string $proxyDir = null, - ?CacheItemPoolInterface $cache = null + string|null $proxyDir = null, + CacheItemPoolInterface|null $cache = null, ): Configuration { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new AttributeDriver($paths)); @@ -98,9 +98,9 @@ public static function createAttributeMetadataConfiguration( public static function createXMLMetadataConfiguration( array $paths, bool $isDevMode = false, - ?string $proxyDir = null, - ?CacheItemPoolInterface $cache = null, - bool $isXsdValidationEnabled = false + string|null $proxyDir = null, + CacheItemPoolInterface|null $cache = null, + bool $isXsdValidationEnabled = false, ): Configuration { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new XmlDriver($paths, XmlDriver::DEFAULT_FILE_EXTENSION, $isXsdValidationEnabled)); @@ -113,8 +113,8 @@ public static function createXMLMetadataConfiguration( */ public static function createConfiguration( bool $isDevMode = false, - ?string $proxyDir = null, - ?CacheItemPoolInterface $cache = null + string|null $proxyDir = null, + CacheItemPoolInterface|null $cache = null, ): Configuration { $proxyDir = $proxyDir ?: sys_get_temp_dir(); @@ -135,7 +135,7 @@ public static function createConfiguration( private static function createCacheInstance( bool $isDevMode, string $proxyDir, - ?CacheItemPoolInterface $cache + CacheItemPoolInterface|null $cache, ): CacheItemPoolInterface { if ($cache !== null) { return $cache; @@ -144,7 +144,7 @@ private static function createCacheInstance( if (! class_exists(ArrayAdapter::class)) { throw new RuntimeException( 'The Doctrine setup tool cannot configure caches without symfony/cache.' - . ' Please add symfony/cache as explicit dependency or pass your own cache implementation.' + . ' Please add symfony/cache as explicit dependency or pass your own cache implementation.', ); } diff --git a/lib/Doctrine/ORM/OptimisticLockException.php b/lib/Doctrine/ORM/OptimisticLockException.php index 91a9e91b1de..f95888c405e 100644 --- a/lib/Doctrine/ORM/OptimisticLockException.php +++ b/lib/Doctrine/ORM/OptimisticLockException.php @@ -15,17 +15,13 @@ */ class OptimisticLockException extends Exception implements ORMException { - /** @var object|null */ - private $entity; - /** * @param string $msg * @param object|null $entity */ - public function __construct($msg, $entity, ?Throwable $previous = null) + public function __construct($msg, private $entity, Throwable|null $previous = null) { parent::__construct($msg, 0, $previous); - $this->entity = $entity; } /** diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 86c1036f300..e0116c49e3e 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -154,13 +154,13 @@ public function hydrateAdd($element): void // Set back reference to owner $this->typeClass->reflFields[$this->backRefFieldName]->setValue( $element, - $this->owner + $this->owner, ); $this->em->getUnitOfWork()->setOriginalEntityProperty( spl_object_id($element), $this->backRefFieldName, - $this->owner + $this->owner, ); } } @@ -182,7 +182,7 @@ public function hydrateSet($key, $element): void // Set back reference to owner $this->typeClass->reflFields[$this->backRefFieldName]->setValue( $element, - $this->owner + $this->owner, ); } } @@ -235,7 +235,7 @@ public function getDeleteDiff(): array return array_values(array_diff_key( array_combine(array_map('spl_object_id', $this->snapshot), $this->snapshot), - array_combine(array_map('spl_object_id', $collectionItems), $collectionItems) + array_combine(array_map('spl_object_id', $collectionItems), $collectionItems), )); } @@ -251,7 +251,7 @@ public function getInsertDiff(): array return array_values(array_diff_key( array_combine(array_map('spl_object_id', $collectionItems), $collectionItems), - array_combine(array_map('spl_object_id', $this->snapshot), $this->snapshot) + array_combine(array_map('spl_object_id', $this->snapshot), $this->snapshot), )); } @@ -260,7 +260,7 @@ public function getInsertDiff(): array * * @psalm-return array|null */ - public function getMapping(): ?array + public function getMapping(): array|null { return $this->association; } diff --git a/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php index 68a62421430..26f0b9ef901 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php @@ -24,7 +24,7 @@ abstract class AbstractCollectionPersister implements CollectionPersister * Initializes a new instance of a class derived from AbstractCollectionPersister. */ public function __construct( - protected EntityManagerInterface $em + protected EntityManagerInterface $em, ) { $this->uow = $em->getUnitOfWork(); $this->conn = $em->getConnection(); diff --git a/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php b/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php index 8a959f7aa31..07c4eaf9d42 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php @@ -33,7 +33,7 @@ public function count(PersistentCollection $collection): int; * * @return mixed[] */ - public function slice(PersistentCollection $collection, int $offset, ?int $length = null): array; + public function slice(PersistentCollection $collection, int $offset, int|null $length = null): array; /** * Checks for existence of an element. diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 7700fde3ac2..440cb844e1d 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -61,7 +61,7 @@ public function update(PersistentCollection $collection): void $this->conn->executeStatement( $deleteSql, $this->getDeleteRowSQLParameters($collection, $element), - $deleteTypes + $deleteTypes, ); } @@ -69,7 +69,7 @@ public function update(PersistentCollection $collection): void $this->conn->executeStatement( $insertSql, $this->getInsertRowSQLParameters($collection, $element), - $insertTypes + $insertTypes, ); } } @@ -93,7 +93,7 @@ public function get(PersistentCollection $collection, mixed $index): mixed $mapping, [], LockMode::NONE, - 1 + 1, ); } @@ -156,7 +156,7 @@ public function count(PersistentCollection $collection): int /** * {@inheritDoc} */ - public function slice(PersistentCollection $collection, int $offset, ?int $length = null): array + public function slice(PersistentCollection $collection, int $offset, int|null $length = null): array { $mapping = $collection->getMapping(); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); @@ -175,7 +175,7 @@ public function containsKey(PersistentCollection $collection, mixed $key): bool [$quotedJoinTable, $whereClauses, $params, $types] = $this->getJoinTableRestrictionsWithKey( $collection, (string) $key, - true + true, ); $sql = 'SELECT 1 FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses); @@ -192,7 +192,7 @@ public function contains(PersistentCollection $collection, object $element): boo [$quotedJoinTable, $whereClauses, $params, $types] = $this->getJoinTableRestrictions( $collection, $element, - true + true, ); $sql = 'SELECT 1 FROM ' . $quotedJoinTable . ' WHERE ' . implode(' AND ', $whereClauses); @@ -503,7 +503,7 @@ protected function getInsertRowSQLParameters(PersistentCollection $collection, o */ private function collectJoinTableColumnParameters( PersistentCollection $collection, - object $element + object $element, ): array { $params = []; $mapping = $collection->getMapping(); @@ -552,7 +552,7 @@ private function collectJoinTableColumnParameters( private function getJoinTableRestrictionsWithKey( PersistentCollection $collection, string $key, - bool $addFilters + bool $addFilters, ): array { $filterMapping = $collection->getMapping(); $mapping = $filterMapping; @@ -639,7 +639,7 @@ private function getJoinTableRestrictionsWithKey( private function getJoinTableRestrictions( PersistentCollection $collection, object $element, - bool $addFilters + bool $addFilters, ): array { $filterMapping = $collection->getMapping(); $mapping = $filterMapping; @@ -726,7 +726,7 @@ private function getOrderingSql(Criteria $criteria, ClassMetadata $targetClass): $field = $this->quoteStrategy->getColumnName( $name, $targetClass, - $this->platform + $this->platform, ); $orderBy[] = $field . ' ' . $direction; } @@ -737,9 +737,7 @@ private function getOrderingSql(Criteria $criteria, ClassMetadata $targetClass): return ''; } - /** - * @throws DBALException - */ + /** @throws DBALException */ private function getLimitSql(Criteria $criteria): string { $limit = $criteria->getMaxResults(); diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 4177e8437ca..24dd48cf7f0 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -71,7 +71,7 @@ public function get(PersistentCollection $collection, mixed $index): mixed $mapping, [], null, - 1 + 1, ); } @@ -91,7 +91,7 @@ public function count(PersistentCollection $collection): int /** * {@inheritdoc} */ - public function slice(PersistentCollection $collection, int $offset, ?int $length = null): array + public function slice(PersistentCollection $collection, int $offset, int|null $length = null): array { $mapping = $collection->getMapping(); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); @@ -145,9 +145,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri throw new BadMethodCallException('Filtering a collection by Criteria is not supported by this CollectionPersister.'); } - /** - * @throws DBALException - */ + /** @throws DBALException */ private function deleteEntityCollection(PersistentCollection $collection): int { $mapping = $collection->getMapping(); @@ -205,7 +203,7 @@ private function deleteJoinedEntityCollection(PersistentCollection $collection): // 2) Build insert table records into temporary table $query = $this->em->createQuery( ' SELECT t0.' . implode(', t0.', $rootClass->getIdentifierFieldNames()) - . ' FROM ' . $targetClass->name . ' t0 WHERE t0.' . $mapping['mappedBy'] . ' = :owner' + . ' FROM ' . $targetClass->name . ' t0 WHERE t0.' . $mapping['mappedBy'] . ' = :owner', )->setParameter('owner', $collection->getOwner()); $sql = $query->getSQL(); diff --git a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php index 397fb1f6cd6..372c2bf25a5 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php @@ -44,7 +44,7 @@ protected function getSelectColumnSQL(string $field, ClassMetadata $class, strin $sql = sprintf( '%s.%s', $this->getSQLTableAlias($class->name, $tableAlias), - $this->quoteStrategy->getColumnName($field, $class, $this->platform) + $this->quoteStrategy->getColumnName($field, $class, $this->platform), ); $this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field, $class->name); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 296b3f63f47..86a9d337112 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -148,7 +148,7 @@ class BasicEntityPersister implements EntityPersister * The INSERT SQL statement used for entities handled by this persister. * This SQL is only generated once per request, if at all. */ - private ?string $insertSql = null; + private string|null $insertSql = null; /** * The quote strategy. @@ -181,12 +181,12 @@ public function __construct( $this->noLimitsContext = $this->currentPersisterContext = new CachedPersisterContext( $class, new Query\ResultSetMapping(), - false + false, ); $this->limitsHandlingContext = new CachedPersisterContext( $class, new Query\ResultSetMapping(), - true + true, ); } @@ -311,7 +311,7 @@ protected function fetchVersionAndNotUpsertableValues(ClassMetadata $versionedCl $values = $this->conn->fetchNumeric( $sql, array_values($flatId), - $this->extractIdentifierTypes($id, $versionedClass) + $this->extractIdentifierTypes($id, $versionedClass), ); if ($values === false) { @@ -387,7 +387,7 @@ final protected function updateTable( object $entity, string $quotedTableName, array $updateData, - bool $versioned = false + bool $versioned = false, ): void { $set = []; $types = []; @@ -436,7 +436,7 @@ final protected function updateTable( $where[] = $this->quoteStrategy->getJoinColumnName( $this->class->associationMappings[$idField]['joinColumns'][0], $this->class, - $this->platform + $this->platform, ); $targetMapping = $this->em->getClassMetadata($this->class->associationMappings[$idField]['targetEntity']); @@ -693,13 +693,13 @@ public function getOwningTable(string $fieldName): string */ public function load( array $criteria, - ?object $entity = null, - ?array $assoc = null, + object|null $entity = null, + array|null $assoc = null, array $hints = [], LockMode|int|null $lockMode = null, - ?int $limit = null, - ?array $orderBy = null - ): ?object { + int|null $limit = null, + array|null $orderBy = null, + ): object|null { $this->switchPersisterContext(null, $limit); $sql = $this->getSelectSQL($criteria, $assoc, $lockMode, $limit, null, $orderBy); @@ -720,7 +720,7 @@ public function load( /** * {@inheritdoc} */ - public function loadById(array $identifier, ?object $entity = null): ?object + public function loadById(array $identifier, object|null $entity = null): object|null { return $this->load($identifier, $entity); } @@ -728,7 +728,7 @@ public function loadById(array $identifier, ?object $entity = null): ?object /** * {@inheritdoc} */ - public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): ?object + public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): object|null { $foundEntity = $this->em->getUnitOfWork()->tryGetById($identifier, $assoc['targetEntity']); if ($foundEntity !== false) { @@ -768,7 +768,7 @@ public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $id if (! isset($sourceClass->fieldNames[$sourceKeyColumn])) { throw MappingException::joinColumnMustPointToMappedField( $sourceClass->name, - $sourceKeyColumn + $sourceKeyColumn, ); } @@ -863,9 +863,9 @@ public function expandCriteriaParameters(Criteria $criteria): array */ public function loadAll( array $criteria = [], - ?array $orderBy = null, - ?int $limit = null, - ?int $offset = null + array|null $orderBy = null, + int|null $limit = null, + int|null $offset = null, ): array { $this->switchPersisterContext($offset, $limit); @@ -884,8 +884,8 @@ public function loadAll( public function getManyToManyCollection( array $assoc, object $sourceEntity, - ?int $offset = null, - ?int $limit = null + int|null $offset = null, + int|null $limit = null, ): array { $this->switchPersisterContext($offset, $limit); @@ -924,7 +924,7 @@ private function loadArrayFromResult(array $assoc, Result $stmt): array private function loadCollectionFromStatement( array $assoc, Result $stmt, - PersistentCollection $coll + PersistentCollection $coll, ): array { $rsm = $this->currentPersisterContext->rsm; $hints = [ @@ -958,8 +958,8 @@ public function loadManyToManyCollection(array $assoc, object $sourceEntity, Per private function getManyToManyStatement( array $assoc, object $sourceEntity, - ?int $offset = null, - ?int $limit = null + int|null $offset = null, + int|null $limit = null, ): Result { $this->switchPersisterContext($offset, $limit); @@ -1005,7 +1005,7 @@ private function getManyToManyStatement( default: throw MappingException::joinColumnMustPointToMappedField( $sourceClass->name, - $sourceKeyColumn + $sourceKeyColumn, ); } @@ -1025,11 +1025,11 @@ private function getManyToManyStatement( public function getSelectSQL( array|Criteria $criteria, - ?array $assoc = null, + array|null $assoc = null, LockMode|int|null $lockMode = null, - ?int $limit = null, - ?int $offset = null, - ?array $orderBy = null + int|null $limit = null, + int|null $offset = null, + array|null $orderBy = null, ): string { $this->switchPersisterContext($offset, $limit); @@ -1221,7 +1221,7 @@ protected function getSelectColumnsSQL(): string $eagerAssocField, $eagerAssoc, $eagerEntity, - $assocAlias + $assocAlias, ); if ($eagerAssocColumnSQL) { @@ -1290,7 +1290,7 @@ protected function getSelectColumnAssociationSQL( string $field, array $assoc, ClassMetadata $class, - string $alias = 'r' + string $alias = 'r', ): string { if (! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) { return ''; @@ -1513,7 +1513,7 @@ protected function getLockTablesSql(LockMode|int $lockMode): string 'FROM ' . $this->quoteStrategy->getTableName($this->class, $this->platform) . ' ' . $this->getSQLTableAlias($this->class->name), - $lockMode + $lockMode, ); } @@ -1536,8 +1536,8 @@ protected function getSelectConditionCriteriaSQL(Criteria $criteria): string public function getSelectConditionStatementSQL( string $field, mixed $value, - ?array $assoc = null, - ?string $comparison = null + array|null $assoc = null, + string|null $comparison = null, ): string { $selectedColumns = []; $columns = $this->getSelectConditionStatementColumnSQL($field, $assoc); @@ -1616,7 +1616,7 @@ public function getSelectConditionStatementSQL( */ private function getSelectConditionStatementColumnSQL( string $field, - ?array $assoc = null + array|null $assoc = null, ): array { if (isset($this->class->fieldMappings[$field])) { $className = $this->class->fieldMappings[$field]['inherited'] ?? $this->class->name; @@ -1647,7 +1647,7 @@ private function getSelectConditionStatementColumnSQL( if (! $association['isOwningSide']) { throw InvalidFindByCall::fromInverseSideUsage( $this->class->name, - $field + $field, ); } @@ -1682,7 +1682,7 @@ private function getSelectConditionStatementColumnSQL( * @psalm-param array $criteria * @psalm-param array|null $assoc */ - protected function getSelectConditionSQL(array $criteria, ?array $assoc = null): string + protected function getSelectConditionSQL(array $criteria, array|null $assoc = null): string { $conditions = []; @@ -1699,8 +1699,8 @@ protected function getSelectConditionSQL(array $criteria, ?array $assoc = null): public function getOneToManyCollection( array $assoc, object $sourceEntity, - ?int $offset = null, - ?int $limit = null + int|null $offset = null, + int|null $limit = null, ): array { $this->switchPersisterContext($offset, $limit); @@ -1715,7 +1715,7 @@ public function getOneToManyCollection( public function loadOneToManyCollection( array $assoc, object $sourceEntity, - PersistentCollection $collection + PersistentCollection $collection, ): mixed { $stmt = $this->getOneToManyStatement($assoc, $sourceEntity); @@ -1730,8 +1730,8 @@ public function loadOneToManyCollection( private function getOneToManyStatement( array $assoc, object $sourceEntity, - ?int $offset = null, - ?int $limit = null + int|null $offset = null, + int|null $limit = null, ): Result { $this->switchPersisterContext($offset, $limit); @@ -1944,7 +1944,7 @@ private function getIndividualValue(mixed $value): array return [$this->em->getUnitOfWork()->getSingleIdentifierValue($value)]; } - public function exists(object $entity, ?Criteria $extraConditions = null): bool + public function exists(object $entity, Criteria|null $extraConditions = null): bool { $criteria = $this->class->getIdentifierValues($entity); @@ -2030,7 +2030,7 @@ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, strin * * This is due to the fact that to-many associations cannot be fetch-joined when a limit is involved */ - protected function switchPersisterContext(?int $offset, ?int $limit): void + protected function switchPersisterContext(int|null $offset, int|null $limit): void { if ($offset === null && $limit === null) { $this->currentPersisterContext = $this->noLimitsContext; @@ -2056,7 +2056,7 @@ static function ($fieldName) use ($class, $entityManager): string { return $types[0]; }, - $class->identifier + $class->identifier, ); } } diff --git a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php index 009bdd9d3bc..3cd1b4f388a 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php +++ b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php @@ -69,13 +69,11 @@ class CachedPersisterContext */ public $handlesLimits; - /** - * @param bool $handlesLimits - */ + /** @param bool $handlesLimits */ public function __construct( ClassMetadata $class, ResultSetMapping $rsm, - $handlesLimits + $handlesLimits, ) { $this->class = $class; $this->rsm = $rsm; diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index 6885ea0149d..cdda39119cd 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -50,11 +50,11 @@ public function getInsertSQL(): string; */ public function getSelectSQL( array|Criteria $criteria, - ?array $assoc = null, + array|null $assoc = null, LockMode|int|null $lockMode = null, - ?int $limit = null, - ?int $offset = null, - ?array $orderBy = null + int|null $limit = null, + int|null $offset = null, + array|null $orderBy = null, ): string; /** @@ -88,8 +88,8 @@ public function expandCriteriaParameters(Criteria $criteria): array; public function getSelectConditionStatementSQL( string $field, mixed $value, - ?array $assoc = null, - ?string $comparison = null + array|null $assoc = null, + string|null $comparison = null, ): string; /** @@ -173,13 +173,13 @@ public function getOwningTable(string $fieldName): string; */ public function load( array $criteria, - ?object $entity = null, - ?array $assoc = null, + object|null $entity = null, + array|null $assoc = null, array $hints = [], LockMode|int|null $lockMode = null, - ?int $limit = null, - ?array $orderBy = null - ): ?object; + int|null $limit = null, + array|null $orderBy = null, + ): object|null; /** * Loads an entity by identifier. @@ -191,7 +191,7 @@ public function load( * * @todo Check parameters */ - public function loadById(array $identifier, ?object $entity = null): ?object; + public function loadById(array $identifier, object|null $entity = null): object|null; /** * Loads an entity of this persister's mapped class as part of a single-valued @@ -207,7 +207,7 @@ public function loadById(array $identifier, ?object $entity = null): ?object; * * @throws MappingException */ - public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): ?object; + public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): object|null; /** * Refreshes a managed entity. @@ -239,9 +239,9 @@ public function loadCriteria(Criteria $criteria): array; */ public function loadAll( array $criteria = [], - ?array $orderBy = null, - ?int $limit = null, - ?int $offset = null + array|null $orderBy = null, + int|null $limit = null, + int|null $offset = null, ): array; /** @@ -254,8 +254,8 @@ public function loadAll( public function getManyToManyCollection( array $assoc, object $sourceEntity, - ?int $offset = null, - ?int $limit = null + int|null $offset = null, + int|null $limit = null, ): array; /** @@ -270,7 +270,7 @@ public function getManyToManyCollection( public function loadManyToManyCollection( array $assoc, object $sourceEntity, - PersistentCollection $collection + PersistentCollection $collection, ): array; /** @@ -282,7 +282,7 @@ public function loadManyToManyCollection( public function loadOneToManyCollection( array $assoc, object $sourceEntity, - PersistentCollection $collection + PersistentCollection $collection, ): mixed; /** @@ -303,12 +303,12 @@ public function lock(array $criteria, LockMode|int $lockMode): void; public function getOneToManyCollection( array $assoc, object $sourceEntity, - ?int $offset = null, - ?int $limit = null + int|null $offset = null, + int|null $limit = null, ): array; /** * Checks whether the given managed entity exists in the database. */ - public function exists(object $entity, ?Criteria $extraConditions = null): bool; + public function exists(object $entity, Criteria|null $extraConditions = null): bool; } diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 8b3640a50fc..b214cab9e11 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -236,7 +236,7 @@ public function delete(object $entity): bool return (bool) $this->conn->delete($rootTable, $id, $rootTypes); } - public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, LockMode|int|null $lockMode = null, ?int $limit = null, ?int $offset = null, ?array $orderBy = null): string + public function getSelectSQL(array|Criteria $criteria, array|null $assoc = null, LockMode|int|null $lockMode = null, int|null $limit = null, int|null $offset = null, array|null $orderBy = null): string { $this->switchPersisterContext($offset, $limit); @@ -253,7 +253,7 @@ public function getSelectSQL(array|Criteria $criteria, ?array $assoc = null, Loc $filterSql = $this->generateFilterConditionSQL( $this->em->getClassMetadata($this->class->rootEntityName), - $this->getSQLTableAlias($this->class->rootEntityName) + $this->getSQLTableAlias($this->class->rootEntityName), ); // If the current class in the root entity, add the filters if ($filterSql) { @@ -394,7 +394,7 @@ protected function getSelectColumnsSQL(): string $tableAlias, $joinColumn['name'], $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform), - PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em) + PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em), ); } } @@ -437,7 +437,7 @@ protected function getSelectColumnsSQL(): string $tableAlias, $joinColumn['name'], $this->quoteStrategy->getJoinColumnName($joinColumn, $subClass, $this->platform), - PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em) + PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em), ); } } diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index af454b666bd..47d8a12ecd7 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -76,7 +76,7 @@ protected function getSelectColumnsSQL(): string $tableAlias, $joinColumn['name'], $this->quoteStrategy->getJoinColumnName($joinColumn, $subClass, $this->platform), - PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em) + PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em), ); } } @@ -108,7 +108,7 @@ protected function getSQLTableAlias(string $className, string $assocName = ''): /** * {@inheritdoc} */ - protected function getSelectConditionSQL(array $criteria, ?array $assoc = null): string + protected function getSelectConditionSQL(array $criteria, array|null $assoc = null): string { $conditionSql = parent::getSelectConditionSQL($criteria, $assoc); diff --git a/lib/Doctrine/ORM/Persisters/MatchingAssociationFieldRequiresObject.php b/lib/Doctrine/ORM/Persisters/MatchingAssociationFieldRequiresObject.php index 210ff425b1d..4e7251ef228 100644 --- a/lib/Doctrine/ORM/Persisters/MatchingAssociationFieldRequiresObject.php +++ b/lib/Doctrine/ORM/Persisters/MatchingAssociationFieldRequiresObject.php @@ -16,7 +16,7 @@ public static function fromClassAndAssociation(string $class, string $associatio 'Cannot match on %s::%s with a non-object value. Matching objects by id is ' . 'not compatible with matching on an in-memory collection, which compares objects by reference.', $class, - $associationName + $associationName, )); } } diff --git a/lib/Doctrine/ORM/Persisters/PersisterException.php b/lib/Doctrine/ORM/Persisters/PersisterException.php index de442725409..b49cfa6ef3a 100644 --- a/lib/Doctrine/ORM/Persisters/PersisterException.php +++ b/lib/Doctrine/ORM/Persisters/PersisterException.php @@ -23,7 +23,7 @@ public static function matchingAssocationFieldRequiresObject($class, $associatio 'Cannot match on %s::%s with a non-object value. Matching objects by id is ' . 'not compatible with matching on an in-memory collection, which compares objects by reference.', $class, - $associationName + $associationName, )); } } diff --git a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php b/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php index 967d4b4f65c..044181ba6db 100644 --- a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php @@ -51,7 +51,7 @@ public function walkComparison(Comparison $comparison) ) { throw MatchingAssociationFieldRequiresObject::fromClassAndAssociation( $this->classMetadata->name, - $field + $field, ); } diff --git a/lib/Doctrine/ORM/PessimisticLockException.php b/lib/Doctrine/ORM/PessimisticLockException.php index c94a1977b06..41df2d73804 100644 --- a/lib/Doctrine/ORM/PessimisticLockException.php +++ b/lib/Doctrine/ORM/PessimisticLockException.php @@ -9,9 +9,7 @@ class PessimisticLockException extends RuntimeException implements ORMException { - /** - * @return PessimisticLockException - */ + /** @return PessimisticLockException */ public static function lockFailed() { return new self('The pessimistic lock failed.'); diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index f9ec04397ef..654ac336223 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -76,7 +76,7 @@ protected function createProxyDefinition($className): ProxyDefinition $classMetadata->getIdentifierFieldNames(), $classMetadata->getReflectionProperties(), $this->createInitializer($classMetadata, $entityPersister), - $this->createCloner($classMetadata, $entityPersister) + $this->createCloner($classMetadata, $entityPersister), ); } @@ -125,7 +125,7 @@ private function createInitializer(ClassMetadata $classMetadata, EntityPersister throw EntityNotFoundException::fromClassNameAndIdentifier( $classMetadata->getName(), - $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier) + $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier), ); } }; @@ -155,7 +155,7 @@ private function createCloner(ClassMetadata $classMetadata, EntityPersister $ent if ($original === null) { throw EntityNotFoundException::fromClassNameAndIdentifier( $classMetadata->getName(), - $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier) + $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier), ); } diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 6877e249b6e..02873d02563 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -127,7 +127,7 @@ final class Query extends AbstractQuery /** * Cached DQL query. */ - private ?string $dql = null; + private string|null $dql = null; /** * The parser result that holds DQL => SQL information. @@ -142,12 +142,12 @@ final class Query extends AbstractQuery /** * The maximum number of results to return (the "limit"). */ - private ?int $maxResults = null; + private int|null $maxResults = null; /** * The cache driver used for caching queries. */ - private ?CacheItemPoolInterface $queryCache = null; + private CacheItemPoolInterface|null $queryCache = null; /** * Whether or not expire the query cache. @@ -157,7 +157,7 @@ final class Query extends AbstractQuery /** * The query cache lifetime. */ - private ?int $queryCacheTTL = null; + private int|null $queryCacheTTL = null; /** * Whether to use a query cache, if available. Defaults to TRUE. @@ -286,7 +286,7 @@ protected function _doExecute(): Result|int $executor, $sqlParams, $types, - $this->em->getConnection()->getParams() + $this->em->getConnection()->getParams(), ); return $executor->execute($this->em->getConnection(), $sqlParams, $types); @@ -301,7 +301,7 @@ private function evictResultSetCache( AbstractSqlExecutor $executor, array $sqlParams, array $types, - array $connectionParams + array $connectionParams, ): void { if ($this->_queryCacheProfile === null || ! $this->getExpireResultCache()) { return; @@ -430,7 +430,7 @@ private function resolveParameterValue(Parameter $parameter): array * * @return $this */ - public function setQueryCache(?CacheItemPoolInterface $queryCache): self + public function setQueryCache(CacheItemPoolInterface|null $queryCache): self { $this->queryCache = $queryCache; @@ -456,7 +456,7 @@ public function useQueryCache(bool $bool): self * * @return $this */ - public function setQueryCacheLifetime(?int $timeToLive): self + public function setQueryCacheLifetime(int|null $timeToLive): self { $this->queryCacheTTL = $timeToLive; @@ -466,7 +466,7 @@ public function setQueryCacheLifetime(?int $timeToLive): self /** * Retrieves the lifetime of resultset cache. */ - public function getQueryCacheLifetime(): ?int + public function getQueryCacheLifetime(): int|null { return $this->queryCacheTTL; } @@ -502,14 +502,14 @@ public function free(): void /** * Sets a DQL query string. */ - public function setDQL(?string $dqlQuery): self + public function setDQL(string|null $dqlQuery): self { if ($dqlQuery === null) { Deprecation::trigger( 'doctrine/orm', 'https://github.com/doctrine/orm/pull/9784', 'Calling %s with null is deprecated and will result in a TypeError in Doctrine 3.0', - __METHOD__ + __METHOD__, ); return $this; @@ -524,7 +524,7 @@ public function setDQL(?string $dqlQuery): self /** * Returns the DQL query that is represented by this query object. */ - public function getDQL(): ?string + public function getDQL(): string|null { return $this->dql; } @@ -562,7 +562,7 @@ public function contains(string $dql): bool * * @return $this */ - public function setFirstResult(?int $firstResult): self + public function setFirstResult(int|null $firstResult): self { if (! is_int($firstResult)) { Deprecation::trigger( @@ -570,7 +570,7 @@ public function setFirstResult(?int $firstResult): self 'https://github.com/doctrine/orm/pull/9809', 'Calling %s with %s is deprecated and will result in a TypeError in Doctrine 3.0. Pass an integer.', __METHOD__, - get_debug_type($firstResult) + get_debug_type($firstResult), ); $firstResult = (int) $firstResult; @@ -588,7 +588,7 @@ public function setFirstResult(?int $firstResult): self * * @return int|null The position of the first result. */ - public function getFirstResult(): ?int + public function getFirstResult(): int|null { return $this->firstResult; } @@ -598,7 +598,7 @@ public function getFirstResult(): ?int * * @return $this */ - public function setMaxResults(?int $maxResults): self + public function setMaxResults(int|null $maxResults): self { $this->maxResults = $maxResults; $this->_state = self::STATE_DIRTY; @@ -612,7 +612,7 @@ public function setMaxResults(?int $maxResults): self * * @return int|null Maximum number of results. */ - public function getMaxResults(): ?int + public function getMaxResults(): int|null { return $this->maxResults; } @@ -666,7 +666,7 @@ public function setLockMode(LockMode|int $lockMode): self * * @return int|null The current lock mode of this query or NULL if no specific lock mode is set. */ - public function getLockMode(): ?int + public function getLockMode(): int|null { $lockMode = $this->getHint(self::HINT_LOCK_MODE); @@ -689,7 +689,7 @@ protected function getQueryCacheId(): string '&platform=' . get_debug_type($this->getEntityManager()->getConnection()->getDatabasePlatform()) . ($this->em->hasFilters() ? $this->em->getFilters()->getHash() : '') . '&firstResult=' . $this->firstResult . '&maxResult=' . $this->maxResults . - '&hydrationMode=' . $this->_hydrationMode . '&types=' . serialize($this->parsedTypes) . 'DOCTRINE_QUERY_CACHE_SALT' + '&hydrationMode=' . $this->_hydrationMode . '&types=' . serialize($this->parsedTypes) . 'DOCTRINE_QUERY_CACHE_SALT', ); } diff --git a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php index 07666bbc30d..d8ff21b9cfa 100644 --- a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php +++ b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php @@ -8,12 +8,6 @@ class AggregateExpression extends Node { - /** @var string */ - public $functionName; - - /** @var PathExpression|SimpleArithmeticExpression */ - public $pathExpression; - /** * Some aggregate expressions support distinct, eg COUNT. * @@ -26,11 +20,9 @@ class AggregateExpression extends Node * @param PathExpression|SimpleArithmeticExpression $pathExpression * @param bool $isDistinct */ - public function __construct($functionName, $pathExpression, $isDistinct) + public function __construct(public $functionName, public $pathExpression, $isDistinct) { - $this->functionName = $functionName; - $this->pathExpression = $pathExpression; - $this->isDistinct = $isDistinct; + $this->isDistinct = $isDistinct; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php index eecf4acd44b..f103f466bd0 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php @@ -19,17 +19,13 @@ class ArithmeticExpression extends Node /** @var Subselect|null */ public $subselect; - /** - * @return bool - */ + /** @return bool */ public function isSimpleArithmeticExpression() { return (bool) $this->simpleArithmeticExpression; } - /** - * @return bool - */ + /** @return bool */ public function isSubselect() { return (bool) $this->subselect; diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php b/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php index a2f86e51295..9e33084ae4f 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php @@ -13,9 +13,6 @@ */ class ArithmeticFactor extends Node { - /** @var mixed */ - public $arithmeticPrimary; - /** * NULL represents no sign, TRUE means positive and FALSE means negative sign. * @@ -27,23 +24,18 @@ class ArithmeticFactor extends Node * @param mixed $arithmeticPrimary * @param bool|null $sign */ - public function __construct($arithmeticPrimary, $sign = null) + public function __construct(public $arithmeticPrimary, $sign = null) { - $this->arithmeticPrimary = $arithmeticPrimary; - $this->sign = $sign; + $this->sign = $sign; } - /** - * @return bool - */ + /** @return bool */ public function isPositiveSigned() { return $this->sign === true; } - /** - * @return bool - */ + /** @return bool */ public function isNegativeSigned() { return $this->sign === false; diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php b/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php index 5c20c06b382..955ed3c6c8f 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php @@ -16,9 +16,7 @@ class ArithmeticTerm extends Node /** @var mixed[] */ public $arithmeticFactors; - /** - * @param mixed[] $arithmeticFactors - */ + /** @param mixed[] $arithmeticFactors */ public function __construct(array $arithmeticFactors) { $this->arithmeticFactors = $arithmeticFactors; diff --git a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php b/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php index 68f6efaa927..77723fe6714 100644 --- a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php +++ b/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php @@ -16,9 +16,7 @@ class CoalesceExpression extends Node /** @var mixed[] */ public $scalarExpressions = []; - /** - * @param mixed[] $scalarExpressions - */ + /** @param mixed[] $scalarExpressions */ public function __construct(array $scalarExpressions) { $this->scalarExpressions = $scalarExpressions; diff --git a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php index 41ab5ad0c49..4842de7e1e1 100644 --- a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php @@ -24,19 +24,15 @@ class ComparisonExpression extends Node /** @var Node|string */ public $rightExpression; - /** @var string */ - public $operator; - /** * @param Node|string $leftExpr * @param string $operator * @param Node|string $rightExpr */ - public function __construct($leftExpr, $operator, $rightExpr) + public function __construct($leftExpr, public $operator, $rightExpr) { $this->leftExpression = $leftExpr; $this->rightExpression = $rightExpr; - $this->operator = $operator; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php b/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php index 0b5d6dc55c3..e0065bedab2 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php @@ -16,9 +16,7 @@ class ConditionalExpression extends Node /** @var mixed[] */ public $conditionalTerms = []; - /** - * @param mixed[] $conditionalTerms - */ + /** @param mixed[] $conditionalTerms */ public function __construct(array $conditionalTerms) { $this->conditionalTerms = $conditionalTerms; diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php b/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php index 064163959d5..17e5cdbcc44 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php @@ -16,15 +16,9 @@ class ConditionalFactor extends Node /** @var bool */ public $not = false; - /** @var ConditionalPrimary */ - public $conditionalPrimary; - - /** - * @param ConditionalPrimary $conditionalPrimary - */ - public function __construct($conditionalPrimary) + /** @param ConditionalPrimary $conditionalPrimary */ + public function __construct(public $conditionalPrimary) { - $this->conditionalPrimary = $conditionalPrimary; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php index 2e3d885dadc..1670ba9a38e 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php @@ -19,17 +19,13 @@ class ConditionalPrimary extends Node /** @var ConditionalExpression|null */ public $conditionalExpression; - /** - * @return bool - */ + /** @return bool */ public function isSimpleConditionalExpression() { return (bool) $this->simpleConditionalExpression; } - /** - * @return bool - */ + /** @return bool */ public function isConditionalExpression() { return (bool) $this->conditionalExpression; diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php b/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php index eaebfe87e58..ad40b40d554 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php @@ -16,9 +16,7 @@ class ConditionalTerm extends Node /** @var mixed[] */ public $conditionalFactors = []; - /** - * @param mixed[] $conditionalFactors - */ + /** @param mixed[] $conditionalFactors */ public function __construct(array $conditionalFactors) { $this->conditionalFactors = $conditionalFactors; diff --git a/lib/Doctrine/ORM/Query/AST/DeleteClause.php b/lib/Doctrine/ORM/Query/AST/DeleteClause.php index 0135b25756e..8bd5279c751 100644 --- a/lib/Doctrine/ORM/Query/AST/DeleteClause.php +++ b/lib/Doctrine/ORM/Query/AST/DeleteClause.php @@ -13,18 +13,12 @@ */ class DeleteClause extends Node { - /** @var string */ - public $abstractSchemaName; - /** @var string */ public $aliasIdentificationVariable; - /** - * @param string $abstractSchemaName - */ - public function __construct($abstractSchemaName) + /** @param string $abstractSchemaName */ + public function __construct(public $abstractSchemaName) { - $this->abstractSchemaName = $abstractSchemaName; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php b/lib/Doctrine/ORM/Query/AST/DeleteStatement.php index bdcc3dc09a3..ff3b8869c40 100644 --- a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php +++ b/lib/Doctrine/ORM/Query/AST/DeleteStatement.php @@ -13,18 +13,12 @@ */ class DeleteStatement extends Node { - /** @var DeleteClause */ - public $deleteClause; - /** @var WhereClause|null */ public $whereClause; - /** - * @param DeleteClause $deleteClause - */ - public function __construct($deleteClause) + /** @param DeleteClause $deleteClause */ + public function __construct(public $deleteClause) { - $this->deleteClause = $deleteClause; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php index d812d766135..4bc341b6f01 100644 --- a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php @@ -13,18 +13,12 @@ */ class EmptyCollectionComparisonExpression extends Node { - /** @var PathExpression */ - public $expression; - /** @var bool */ public $not; - /** - * @param PathExpression $expression - */ - public function __construct($expression) + /** @param PathExpression $expression */ + public function __construct(public $expression) { - $this->expression = $expression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php b/lib/Doctrine/ORM/Query/AST/ExistsExpression.php index 9ac64b27c87..caed4e6f1f3 100644 --- a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ExistsExpression.php @@ -16,15 +16,9 @@ class ExistsExpression extends Node /** @var bool */ public $not; - /** @var Subselect */ - public $subselect; - - /** - * @param Subselect $subselect - */ - public function __construct($subselect) + /** @param Subselect $subselect */ + public function __construct(public $subselect) { - $this->subselect = $subselect; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/FromClause.php b/lib/Doctrine/ORM/Query/AST/FromClause.php index 8f8fa740c08..0109de87336 100644 --- a/lib/Doctrine/ORM/Query/AST/FromClause.php +++ b/lib/Doctrine/ORM/Query/AST/FromClause.php @@ -16,9 +16,7 @@ class FromClause extends Node /** @var mixed[] */ public $identificationVariableDeclarations = []; - /** - * @param mixed[] $identificationVariableDeclarations - */ + /** @param mixed[] $identificationVariableDeclarations */ public function __construct(array $identificationVariableDeclarations) { $this->identificationVariableDeclarations = $identificationVariableDeclarations; diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php index c3bb13a6e31..9e4b7ad2a5c 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php @@ -19,19 +19,15 @@ class AbsFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $simpleArithmeticExpression; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression( - $this->simpleArithmeticExpression + $this->simpleArithmeticExpression, ) . ')'; } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php index 10983f027fd..a0988bb1b30 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php @@ -22,22 +22,18 @@ class BitAndFunction extends FunctionNode /** @var Node */ public $secondArithmetic; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); return $platform->getBitAndComparisonExpression( $this->firstArithmetic->dispatch($sqlWalker), - $this->secondArithmetic->dispatch($sqlWalker) + $this->secondArithmetic->dispatch($sqlWalker), ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php index 499363f2307..08bca26e707 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php @@ -22,22 +22,18 @@ class BitOrFunction extends FunctionNode /** @var Node */ public $secondArithmetic; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); return $platform->getBitOrComparisonExpression( $this->firstArithmetic->dispatch($sqlWalker), - $this->secondArithmetic->dispatch($sqlWalker) + $this->secondArithmetic->dispatch($sqlWalker), ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php index 553fd0bdac4..b2101650be0 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php @@ -25,9 +25,7 @@ class ConcatFunction extends FunctionNode /** @psalm-var list */ public $concatExpressions = []; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -41,9 +39,7 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getConcatExpression(...$args); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php index 0279df5116f..a1dc659a217 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php @@ -15,17 +15,13 @@ */ class CurrentDateFunction extends FunctionNode { - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentDateSQL(); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php index dd84e9fa1b4..a27b6732af8 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php @@ -15,17 +15,13 @@ */ class CurrentTimeFunction extends FunctionNode { - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimeSQL(); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php index 9ef3d91235d..74a9883168c 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php @@ -15,17 +15,13 @@ */ class CurrentTimestampFunction extends FunctionNode { - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimestampSQL(); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php index 1a36ad52692..2c21fdf1097 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php @@ -31,57 +31,55 @@ class DateAddFunction extends FunctionNode /** @var Node */ public $unit = null; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { switch (strtolower($this->unit->value)) { case 'second': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddSecondsExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'minute': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMinutesExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'hour': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'day': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'week': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddWeeksExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'month': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'year': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddYearsExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); default: throw QueryException::semanticalError( - 'DATE_ADD() only supports units of type second, minute, hour, day, week, month and year.' + 'DATE_ADD() only supports units of type second, minute, hour, day, week, month and year.', ); } } @@ -99,9 +97,7 @@ private function dispatchIntervalExpression(SqlWalker $sqlWalker) return $sql; } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php index df2a7e685d6..c082ab9cc4e 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php @@ -22,20 +22,16 @@ class DateDiffFunction extends FunctionNode /** @var Node */ public $date2; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getDateDiffExpression( $this->date1->dispatch($sqlWalker), - $this->date2->dispatch($sqlWalker) + $this->date2->dispatch($sqlWalker), ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php index 496274a9a60..45830268ebb 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php @@ -19,57 +19,55 @@ */ class DateSubFunction extends DateAddFunction { - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { switch (strtolower($this->unit->value)) { case 'second': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubSecondsExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'minute': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMinutesExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'hour': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'day': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'week': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubWeeksExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'month': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMonthExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); case 'year': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubYearsExpression( $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker) + $this->dispatchIntervalExpression($sqlWalker), ); default: throw QueryException::semanticalError( - 'DATE_SUB() only supports units of type second, minute, hour, day, week, month and year.' + 'DATE_SUB() only supports units of type second, minute, hour, day, week, month and year.', ); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php b/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php index 358bc79ceaf..6318d539d03 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php @@ -17,20 +17,12 @@ */ abstract class FunctionNode extends Node { - /** @var string */ - public $name; - - /** - * @param string $name - */ - public function __construct($name) + /** @param string $name */ + public function __construct(public $name) { - $this->name = $name; } - /** - * @return string - */ + /** @return string */ abstract public function getSql(SqlWalker $sqlWalker); public function dispatch(SqlWalker $sqlWalker): string @@ -38,8 +30,6 @@ public function dispatch(SqlWalker $sqlWalker): string return $sqlWalker->walkFunction($this); } - /** - * @return void - */ + /** @return void */ abstract public function parse(Parser $parser); } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php index 7168c39b1f6..fa0cb502fe5 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php @@ -22,19 +22,15 @@ class LengthFunction extends FunctionNode implements TypedExpression /** @var Node */ public $stringPrimary; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getLengthExpression( - $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php index b6c6692d24f..b62587917ba 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php @@ -26,9 +26,7 @@ class LocateFunction extends FunctionNode /** @var SimpleArithmeticExpression|bool */ public $simpleArithmeticExpression = false; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -40,16 +38,14 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getLocateExpression( $secondString, $firstString, - $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) + $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression), ); } return $platform->getLocateExpression($secondString, $firstString); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php index e83f91e4973..e548d843ee3 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php @@ -21,20 +21,16 @@ class LowerFunction extends FunctionNode /** @var Node */ public $stringPrimary; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return sprintf( 'LOWER(%s)', - $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php index 1eb22bd2be0..af5aa535889 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php @@ -22,20 +22,16 @@ class ModFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $secondSimpleArithmeticExpression; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return $sqlWalker->getConnection()->getDatabasePlatform()->getModExpression( $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), - $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression) + $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression), ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 76fccf5ae29..5ecc2486a68 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -90,7 +90,7 @@ public function getSql(SqlWalker $sqlWalker) $sourceColumnName = $quoteStrategy->getColumnName( $class->fieldNames[$joinColumn['referencedColumnName']], $class, - $platform + $platform, ); $sql .= $joinTableAlias . '.' . $joinColumn['name'] @@ -102,9 +102,7 @@ public function getSql(SqlWalker $sqlWalker) return '(' . $sql . ')'; } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php index 8251efc5e79..b5e04ad1201 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php @@ -21,20 +21,16 @@ class SqrtFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $simpleArithmeticExpression; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return sprintf( 'SQRT(%s)', - $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) + $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression), ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php index b390f3a4f14..6b758e4b6fc 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php @@ -26,9 +26,7 @@ class SubstringFunction extends FunctionNode /** @var SimpleArithmeticExpression|null */ public $secondSimpleArithmeticExpression = null; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { $optionalSecondSimpleArithmeticExpression = null; @@ -39,13 +37,11 @@ public function getSql(SqlWalker $sqlWalker) return $sqlWalker->getConnection()->getDatabasePlatform()->getSubstringExpression( $sqlWalker->walkStringPrimary($this->stringPrimary), $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), - $optionalSecondSimpleArithmeticExpression + $optionalSecondSimpleArithmeticExpression, ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php index 3a14d81c9d2..370b225ab2e 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -47,7 +47,7 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getTrimExpression( $stringPrimary, $trimMode, - $platform->quoteStringLiteral($this->trimChar) + $platform->quoteStringLiteral($this->trimChar), ); } @@ -81,9 +81,7 @@ public function parse(Parser $parser) $parser->match(Lexer::T_CLOSE_PARENTHESIS); } - /** - * @psalm-return TrimMode::* - */ + /** @psalm-return TrimMode::* */ private function getTrimMode(): TrimMode|int { if ($this->leading) { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php index fcedc281d7f..65a30b2ecf7 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php @@ -21,20 +21,16 @@ class UpperFunction extends FunctionNode /** @var Node */ public $stringPrimary; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return sprintf( 'UPPER(%s)', - $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) + $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), ); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); diff --git a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php b/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php index 393a144269d..4fd4594d5de 100644 --- a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php @@ -16,17 +16,13 @@ class GeneralCaseExpression extends Node /** @var mixed[] */ public $whenClauses = []; - /** @var mixed */ - public $elseScalarExpression = null; - /** * @param mixed[] $whenClauses * @param mixed $elseScalarExpression */ - public function __construct(array $whenClauses, $elseScalarExpression) + public function __construct(array $whenClauses, public $elseScalarExpression = null) { - $this->whenClauses = $whenClauses; - $this->elseScalarExpression = $elseScalarExpression; + $this->whenClauses = $whenClauses; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/GroupByClause.php b/lib/Doctrine/ORM/Query/AST/GroupByClause.php index 511438f75ca..50f0de8d768 100644 --- a/lib/Doctrine/ORM/Query/AST/GroupByClause.php +++ b/lib/Doctrine/ORM/Query/AST/GroupByClause.php @@ -11,9 +11,7 @@ class GroupByClause extends Node /** @var mixed[] */ public $groupByItems = []; - /** - * @param mixed[] $groupByItems - */ + /** @param mixed[] $groupByItems */ public function __construct(array $groupByItems) { $this->groupByItems = $groupByItems; diff --git a/lib/Doctrine/ORM/Query/AST/HavingClause.php b/lib/Doctrine/ORM/Query/AST/HavingClause.php index cd621f8c838..95d5da5cdd8 100644 --- a/lib/Doctrine/ORM/Query/AST/HavingClause.php +++ b/lib/Doctrine/ORM/Query/AST/HavingClause.php @@ -8,15 +8,9 @@ class HavingClause extends Node { - /** @var ConditionalExpression */ - public $conditionalExpression; - - /** - * @param ConditionalExpression $conditionalExpression - */ - public function __construct($conditionalExpression) + /** @param ConditionalExpression $conditionalExpression */ + public function __construct(public $conditionalExpression) { - $this->conditionalExpression = $conditionalExpression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php index cf96dfb50ff..5fbc67d88ba 100644 --- a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php @@ -13,25 +13,16 @@ */ class IdentificationVariableDeclaration extends Node { - /** @var RangeVariableDeclaration|null */ - public $rangeVariableDeclaration = null; - - /** @var IndexBy|null */ - public $indexBy = null; - - /** @var mixed[] */ - public $joins = []; - /** - * @param RangeVariableDeclaration|null $rangeVariableDecl + * @param RangeVariableDeclaration|null $rangeVariableDeclaration * @param IndexBy|null $indexBy * @param mixed[] $joins */ - public function __construct($rangeVariableDecl, $indexBy, array $joins) - { - $this->rangeVariableDeclaration = $rangeVariableDecl; - $this->indexBy = $indexBy; - $this->joins = $joins; + public function __construct( + public $rangeVariableDeclaration = null, + public $indexBy = null, + public array $joins = [], + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/InExpression.php b/lib/Doctrine/ORM/Query/AST/InExpression.php index f83c128fa16..258d8aea8f8 100644 --- a/lib/Doctrine/ORM/Query/AST/InExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InExpression.php @@ -16,21 +16,15 @@ class InExpression extends Node /** @var bool */ public $not; - /** @var ArithmeticExpression */ - public $expression; - /** @var mixed[] */ public $literals = []; /** @var Subselect|null */ public $subselect; - /** - * @param ArithmeticExpression $expression - */ - public function __construct($expression) + /** @param ArithmeticExpression $expression */ + public function __construct(public $expression) { - $this->expression = $expression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php index 5ee5ff742fc..1d35dec93bb 100644 --- a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php @@ -23,9 +23,7 @@ class InstanceOfExpression extends Node /** @var mixed[] */ public $value; - /** - * @param string $identVariable - */ + /** @param string $identVariable */ public function __construct($identVariable) { $this->identificationVariable = $identVariable; diff --git a/lib/Doctrine/ORM/Query/AST/Join.php b/lib/Doctrine/ORM/Query/AST/Join.php index f558a9e31d3..96a1b6ab78b 100644 --- a/lib/Doctrine/ORM/Query/AST/Join.php +++ b/lib/Doctrine/ORM/Query/AST/Join.php @@ -24,9 +24,6 @@ class Join extends Node */ public $joinType = self::JOIN_TYPE_INNER; - /** @var Node|null */ - public $joinAssociationDeclaration = null; - /** @var ConditionalExpression|null */ public $conditionalExpression = null; @@ -35,10 +32,9 @@ class Join extends Node * @param Node $joinAssociationDeclaration * @psalm-param self::JOIN_TYPE_* $joinType */ - public function __construct($joinType, $joinAssociationDeclaration) + public function __construct($joinType, public $joinAssociationDeclaration = null) { - $this->joinType = $joinType; - $this->joinAssociationDeclaration = $joinAssociationDeclaration; + $this->joinType = $joinType; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php index f324abec7f1..0beb7369c0b 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php @@ -13,25 +13,13 @@ */ class JoinAssociationDeclaration extends Node { - /** @var JoinAssociationPathExpression */ - public $joinAssociationPathExpression; - - /** @var string */ - public $aliasIdentificationVariable; - - /** @var IndexBy|null */ - public $indexBy; - /** * @param JoinAssociationPathExpression $joinAssociationPathExpression * @param string $aliasIdentificationVariable * @param IndexBy|null $indexBy */ - public function __construct($joinAssociationPathExpression, $aliasIdentificationVariable, $indexBy) + public function __construct(public $joinAssociationPathExpression, public $aliasIdentificationVariable, public $indexBy) { - $this->joinAssociationPathExpression = $joinAssociationPathExpression; - $this->aliasIdentificationVariable = $aliasIdentificationVariable; - $this->indexBy = $indexBy; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php b/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php index da1283fb247..708d58297fc 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php @@ -11,19 +11,11 @@ */ class JoinAssociationPathExpression extends Node { - /** @var string */ - public $identificationVariable; - - /** @var string */ - public $associationField; - /** * @param string $identificationVariable * @param string $associationField */ - public function __construct($identificationVariable, $associationField) + public function __construct(public $identificationVariable, public $associationField) { - $this->identificationVariable = $identificationVariable; - $this->associationField = $associationField; } } diff --git a/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php b/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php index c262b2acc70..dc4f215c919 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php @@ -13,9 +13,6 @@ */ class JoinClassPathExpression extends Node { - /** @var mixed */ - public $abstractSchemaName; - /** @var mixed */ public $aliasIdentificationVariable; @@ -23,9 +20,8 @@ class JoinClassPathExpression extends Node * @param mixed $abstractSchemaName * @param mixed $aliasIdentificationVar */ - public function __construct($abstractSchemaName, $aliasIdentificationVar) + public function __construct(public $abstractSchemaName, $aliasIdentificationVar) { - $this->abstractSchemaName = $abstractSchemaName; $this->aliasIdentificationVariable = $aliasIdentificationVar; } diff --git a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php index 2e061750d75..6ac08090f3a 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php @@ -13,20 +13,12 @@ */ class JoinVariableDeclaration extends Node { - /** @var Join */ - public $join; - - /** @var IndexBy|null */ - public $indexBy; - /** * @param Join $join * @param IndexBy|null $indexBy */ - public function __construct($join, $indexBy) + public function __construct(public $join, public $indexBy) { - $this->join = $join; - $this->indexBy = $indexBy; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/LikeExpression.php b/lib/Doctrine/ORM/Query/AST/LikeExpression.php index 27c5fd5c168..5f170ee1908 100644 --- a/lib/Doctrine/ORM/Query/AST/LikeExpression.php +++ b/lib/Doctrine/ORM/Query/AST/LikeExpression.php @@ -17,25 +17,13 @@ class LikeExpression extends Node /** @var bool */ public $not = false; - /** @var Node|string */ - public $stringExpression; - - /** @var InputParameter|FunctionNode|PathExpression|Literal */ - public $stringPattern; - - /** @var Literal|null */ - public $escapeChar; - /** * @param Node|string $stringExpression * @param InputParameter|FunctionNode|PathExpression|Literal $stringPattern * @param Literal|null $escapeChar */ - public function __construct($stringExpression, $stringPattern, $escapeChar = null) + public function __construct(public $stringExpression, public $stringPattern, public $escapeChar = null) { - $this->stringExpression = $stringExpression; - $this->stringPattern = $stringPattern; - $this->escapeChar = $escapeChar; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/Literal.php b/lib/Doctrine/ORM/Query/AST/Literal.php index 242d4fdffaf..0810e27de5a 100644 --- a/lib/Doctrine/ORM/Query/AST/Literal.php +++ b/lib/Doctrine/ORM/Query/AST/Literal.php @@ -18,18 +18,14 @@ class Literal extends Node */ public $type; - /** @var mixed */ - public $value; - /** * @param int $type * @param mixed $value * @psalm-param self::* $type */ - public function __construct($type, $value) + public function __construct($type, public $value) { - $this->type = $type; - $this->value = $value; + $this->type = $type; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php b/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php index f173fbb23d9..451d4881144 100644 --- a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php @@ -13,9 +13,6 @@ */ class NewObjectExpression extends Node { - /** @var string */ - public $className; - /** @var mixed[] */ public $args; @@ -23,10 +20,9 @@ class NewObjectExpression extends Node * @param string $className * @param mixed[] $args */ - public function __construct($className, array $args) + public function __construct(public $className, array $args) { - $this->className = $className; - $this->args = $args; + $this->args = $args; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php index 27d410dee0d..9256c396916 100644 --- a/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php @@ -16,15 +16,9 @@ class NullComparisonExpression extends Node /** @var bool */ public $not; - /** @var Node */ - public $expression; - - /** - * @param Node $expression - */ - public function __construct($expression) + /** @param Node $expression */ + public function __construct(public $expression) { - $this->expression = $expression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/NullIfExpression.php b/lib/Doctrine/ORM/Query/AST/NullIfExpression.php index 920ca7f0740..52b546f0282 100644 --- a/lib/Doctrine/ORM/Query/AST/NullIfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NullIfExpression.php @@ -13,20 +13,12 @@ */ class NullIfExpression extends Node { - /** @var mixed */ - public $firstExpression; - - /** @var mixed */ - public $secondExpression; - /** * @param mixed $firstExpression * @param mixed $secondExpression */ - public function __construct($firstExpression, $secondExpression) + public function __construct(public $firstExpression, public $secondExpression) { - $this->firstExpression = $firstExpression; - $this->secondExpression = $secondExpression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/OrderByClause.php b/lib/Doctrine/ORM/Query/AST/OrderByClause.php index 3c9ca6d50a2..4c9bee12976 100644 --- a/lib/Doctrine/ORM/Query/AST/OrderByClause.php +++ b/lib/Doctrine/ORM/Query/AST/OrderByClause.php @@ -16,9 +16,7 @@ class OrderByClause extends Node /** @var OrderByItem[] */ public $orderByItems = []; - /** - * @param OrderByItem[] $orderByItems - */ + /** @param OrderByItem[] $orderByItems */ public function __construct(array $orderByItems) { $this->orderByItems = $orderByItems; diff --git a/lib/Doctrine/ORM/Query/AST/OrderByItem.php b/lib/Doctrine/ORM/Query/AST/OrderByItem.php index 2b76d465fd3..0a2951c4dcc 100644 --- a/lib/Doctrine/ORM/Query/AST/OrderByItem.php +++ b/lib/Doctrine/ORM/Query/AST/OrderByItem.php @@ -15,31 +15,21 @@ */ class OrderByItem extends Node { - /** @var mixed */ - public $expression; - /** @var string */ public $type; - /** - * @param mixed $expression - */ - public function __construct($expression) + /** @param mixed $expression */ + public function __construct(public $expression) { - $this->expression = $expression; } - /** - * @return bool - */ + /** @return bool */ public function isAsc() { return strtoupper($this->type) === 'ASC'; } - /** - * @return bool - */ + /** @return bool */ public function isDesc() { return strtoupper($this->type) === 'DESC'; diff --git a/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php b/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php index 020c0999a9b..3f9acbaf884 100644 --- a/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php @@ -6,9 +6,6 @@ class PartialObjectExpression extends Node { - /** @var string */ - public $identificationVariable; - /** @var mixed[] */ public $partialFieldSet; @@ -16,9 +13,8 @@ class PartialObjectExpression extends Node * @param string $identificationVariable * @param mixed[] $partialFieldSet */ - public function __construct($identificationVariable, array $partialFieldSet) + public function __construct(public $identificationVariable, array $partialFieldSet) { - $this->identificationVariable = $identificationVariable; - $this->partialFieldSet = $partialFieldSet; + $this->partialFieldSet = $partialFieldSet; } } diff --git a/lib/Doctrine/ORM/Query/AST/PathExpression.php b/lib/Doctrine/ORM/Query/AST/PathExpression.php index 0726f8d3faa..a8a579d40a4 100644 --- a/lib/Doctrine/ORM/Query/AST/PathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/PathExpression.php @@ -33,23 +33,15 @@ class PathExpression extends Node */ public $expectedType; - /** @var string */ - public $identificationVariable; - - /** @var string|null */ - public $field; - /** * @param int $expectedType * @param string $identificationVariable * @param string|null $field * @psalm-param int-mask-of $expectedType */ - public function __construct($expectedType, $identificationVariable, $field = null) + public function __construct($expectedType, public $identificationVariable, public $field = null) { - $this->expectedType = $expectedType; - $this->identificationVariable = $identificationVariable; - $this->field = $field; + $this->expectedType = $expectedType; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php index 17c112e47a4..a504a494412 100644 --- a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php +++ b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php @@ -18,36 +18,24 @@ class QuantifiedExpression extends Node /** @var string */ public $type; - /** @var Subselect */ - public $subselect; - - /** - * @param Subselect $subselect - */ - public function __construct($subselect) + /** @param Subselect $subselect */ + public function __construct(public $subselect) { - $this->subselect = $subselect; } - /** - * @return bool - */ + /** @return bool */ public function isAll() { return strtoupper($this->type) === 'ALL'; } - /** - * @return bool - */ + /** @return bool */ public function isAny() { return strtoupper($this->type) === 'ANY'; } - /** - * @return bool - */ + /** @return bool */ public function isSome() { return strtoupper($this->type) === 'SOME'; diff --git a/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php index 60f97ccfd22..2da603191e7 100644 --- a/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php @@ -13,25 +13,17 @@ */ class RangeVariableDeclaration extends Node { - /** @var string */ - public $abstractSchemaName; - /** @var string */ public $aliasIdentificationVariable; - /** @var bool */ - public $isRoot; - /** * @param string $abstractSchemaName * @param string $aliasIdentificationVar * @param bool $isRoot */ - public function __construct($abstractSchemaName, $aliasIdentificationVar, $isRoot = true) + public function __construct(public $abstractSchemaName, $aliasIdentificationVar, public $isRoot = true) { - $this->abstractSchemaName = $abstractSchemaName; $this->aliasIdentificationVariable = $aliasIdentificationVar; - $this->isRoot = $isRoot; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SelectClause.php b/lib/Doctrine/ORM/Query/AST/SelectClause.php index 15a16ac6686..08fa042e7d6 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SelectClause.php @@ -13,9 +13,6 @@ */ class SelectClause extends Node { - /** @var bool */ - public $isDistinct; - /** @var mixed[] */ public $selectExpressions = []; @@ -23,9 +20,8 @@ class SelectClause extends Node * @param mixed[] $selectExpressions * @param bool $isDistinct */ - public function __construct(array $selectExpressions, $isDistinct) + public function __construct(array $selectExpressions, public $isDistinct) { - $this->isDistinct = $isDistinct; $this->selectExpressions = $selectExpressions; } diff --git a/lib/Doctrine/ORM/Query/AST/SelectExpression.php b/lib/Doctrine/ORM/Query/AST/SelectExpression.php index ebe072a754e..75ad4888381 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SelectExpression.php @@ -14,25 +14,13 @@ */ class SelectExpression extends Node { - /** @var mixed */ - public $expression; - - /** @var string|null */ - public $fieldIdentificationVariable; - - /** @var bool */ - public $hiddenAliasResultVariable; - /** * @param mixed $expression * @param string|null $fieldIdentificationVariable * @param bool $hiddenAliasResultVariable */ - public function __construct($expression, $fieldIdentificationVariable, $hiddenAliasResultVariable = false) + public function __construct(public $expression, public $fieldIdentificationVariable, public $hiddenAliasResultVariable = false) { - $this->expression = $expression; - $this->fieldIdentificationVariable = $fieldIdentificationVariable; - $this->hiddenAliasResultVariable = $hiddenAliasResultVariable; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SelectStatement.php b/lib/Doctrine/ORM/Query/AST/SelectStatement.php index c20a3a8cca9..5f47ebe262c 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectStatement.php +++ b/lib/Doctrine/ORM/Query/AST/SelectStatement.php @@ -13,12 +13,6 @@ */ class SelectStatement extends Node { - /** @var SelectClause */ - public $selectClause; - - /** @var FromClause */ - public $fromClause; - /** @var WhereClause|null */ public $whereClause; @@ -35,10 +29,8 @@ class SelectStatement extends Node * @param SelectClause $selectClause * @param FromClause $fromClause */ - public function __construct($selectClause, $fromClause) + public function __construct(public $selectClause, public $fromClause) { - $this->selectClause = $selectClause; - $this->fromClause = $fromClause; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php index 525925422e8..7505bafcd20 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php @@ -16,9 +16,7 @@ class SimpleArithmeticExpression extends Node /** @var mixed[] */ public $arithmeticTerms = []; - /** - * @param mixed[] $arithmeticTerms - */ + /** @param mixed[] $arithmeticTerms */ public function __construct(array $arithmeticTerms) { $this->arithmeticTerms = $arithmeticTerms; diff --git a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php index 812f2297b97..9a12dd8871a 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php @@ -13,25 +13,16 @@ */ class SimpleCaseExpression extends Node { - /** @var PathExpression */ - public $caseOperand = null; - - /** @var mixed[] */ - public $simpleWhenClauses = []; - - /** @var mixed */ - public $elseScalarExpression = null; - /** * @param PathExpression $caseOperand * @param mixed[] $simpleWhenClauses * @param mixed $elseScalarExpression */ - public function __construct($caseOperand, array $simpleWhenClauses, $elseScalarExpression) - { - $this->caseOperand = $caseOperand; - $this->simpleWhenClauses = $simpleWhenClauses; - $this->elseScalarExpression = $elseScalarExpression; + public function __construct( + public $caseOperand = null, + public array $simpleWhenClauses = [], + public $elseScalarExpression = null, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php index 4f8fd0047e9..f84558def83 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php @@ -13,20 +13,12 @@ */ class SimpleSelectClause extends Node { - /** @var bool */ - public $isDistinct = false; - - /** @var SimpleSelectExpression */ - public $simpleSelectExpression; - /** * @param SimpleSelectExpression $simpleSelectExpression * @param bool $isDistinct */ - public function __construct($simpleSelectExpression, $isDistinct) + public function __construct(public $simpleSelectExpression, public $isDistinct = false) { - $this->simpleSelectExpression = $simpleSelectExpression; - $this->isDistinct = $isDistinct; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php index 306e666633e..1a9fd3fe246 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php @@ -14,18 +14,12 @@ */ class SimpleSelectExpression extends Node { - /** @var Node|string */ - public $expression; - /** @var string */ public $fieldIdentificationVariable; - /** - * @param Node|string $expression - */ - public function __construct($expression) + /** @param Node|string $expression */ + public function __construct(public $expression) { - $this->expression = $expression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php b/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php index 33bb28030ff..712e90a12f1 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php @@ -13,20 +13,12 @@ */ class SimpleWhenClause extends Node { - /** @var mixed */ - public $caseScalarExpression = null; - - /** @var mixed */ - public $thenScalarExpression = null; - /** * @param mixed $caseScalarExpression * @param mixed $thenScalarExpression */ - public function __construct($caseScalarExpression, $thenScalarExpression) + public function __construct(public $caseScalarExpression = null, public $thenScalarExpression = null) { - $this->caseScalarExpression = $caseScalarExpression; - $this->thenScalarExpression = $thenScalarExpression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/Subselect.php b/lib/Doctrine/ORM/Query/AST/Subselect.php index 5a6fc692c22..9a237004c1b 100644 --- a/lib/Doctrine/ORM/Query/AST/Subselect.php +++ b/lib/Doctrine/ORM/Query/AST/Subselect.php @@ -13,12 +13,6 @@ */ class Subselect extends Node { - /** @var SimpleSelectClause */ - public $simpleSelectClause; - - /** @var SubselectFromClause */ - public $subselectFromClause; - /** @var WhereClause|null */ public $whereClause; @@ -35,10 +29,8 @@ class Subselect extends Node * @param SimpleSelectClause $simpleSelectClause * @param SubselectFromClause $subselectFromClause */ - public function __construct($simpleSelectClause, $subselectFromClause) + public function __construct(public $simpleSelectClause, public $subselectFromClause) { - $this->simpleSelectClause = $simpleSelectClause; - $this->subselectFromClause = $subselectFromClause; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php b/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php index 00ebff57644..89dab07eea7 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php @@ -16,9 +16,7 @@ class SubselectFromClause extends Node /** @var mixed[] */ public $identificationVariableDeclarations = []; - /** - * @param mixed[] $identificationVariableDeclarations - */ + /** @param mixed[] $identificationVariableDeclarations */ public function __construct(array $identificationVariableDeclarations) { $this->identificationVariableDeclarations = $identificationVariableDeclarations; diff --git a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php index b0e881b0f47..225cf8d3037 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php @@ -11,19 +11,11 @@ */ class SubselectIdentificationVariableDeclaration { - /** @var PathExpression */ - public $associationPathExpression; - - /** @var string */ - public $aliasIdentificationVariable; - /** * @param PathExpression $associationPathExpression * @param string $aliasIdentificationVariable */ - public function __construct($associationPathExpression, $aliasIdentificationVariable) + public function __construct(public $associationPathExpression, public $aliasIdentificationVariable) { - $this->associationPathExpression = $associationPathExpression; - $this->aliasIdentificationVariable = $aliasIdentificationVariable; } } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateClause.php b/lib/Doctrine/ORM/Query/AST/UpdateClause.php index d855898dac8..0c05dee5ae6 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateClause.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateClause.php @@ -13,9 +13,6 @@ */ class UpdateClause extends Node { - /** @var string */ - public $abstractSchemaName; - /** @var string */ public $aliasIdentificationVariable; @@ -26,10 +23,9 @@ class UpdateClause extends Node * @param string $abstractSchemaName * @param mixed[] $updateItems */ - public function __construct($abstractSchemaName, array $updateItems) + public function __construct(public $abstractSchemaName, array $updateItems) { - $this->abstractSchemaName = $abstractSchemaName; - $this->updateItems = $updateItems; + $this->updateItems = $updateItems; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/UpdateItem.php b/lib/Doctrine/ORM/Query/AST/UpdateItem.php index 2497499700d..793603607f9 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateItem.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateItem.php @@ -15,20 +15,12 @@ */ class UpdateItem extends Node { - /** @var PathExpression */ - public $pathExpression; - - /** @var InputParameter|ArithmeticExpression|null */ - public $newValue; - /** * @param PathExpression $pathExpression * @param InputParameter|ArithmeticExpression|null $newValue */ - public function __construct($pathExpression, $newValue) + public function __construct(public $pathExpression, public $newValue) { - $this->pathExpression = $pathExpression; - $this->newValue = $newValue; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php b/lib/Doctrine/ORM/Query/AST/UpdateStatement.php index 1f905a5c0d9..0f1645e0c4a 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateStatement.php @@ -13,18 +13,12 @@ */ class UpdateStatement extends Node { - /** @var UpdateClause */ - public $updateClause; - /** @var WhereClause|null */ public $whereClause; - /** - * @param UpdateClause $updateClause - */ - public function __construct($updateClause) + /** @param UpdateClause $updateClause */ + public function __construct(public $updateClause) { - $this->updateClause = $updateClause; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/WhenClause.php b/lib/Doctrine/ORM/Query/AST/WhenClause.php index 528a8d61a37..e40b71ca6cf 100644 --- a/lib/Doctrine/ORM/Query/AST/WhenClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhenClause.php @@ -13,20 +13,12 @@ */ class WhenClause extends Node { - /** @var ConditionalExpression */ - public $caseConditionExpression = null; - - /** @var mixed */ - public $thenScalarExpression = null; - /** * @param ConditionalExpression $caseConditionExpression * @param mixed $thenScalarExpression */ - public function __construct($caseConditionExpression, $thenScalarExpression) + public function __construct(public $caseConditionExpression = null, public $thenScalarExpression = null) { - $this->caseConditionExpression = $caseConditionExpression; - $this->thenScalarExpression = $thenScalarExpression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/WhereClause.php b/lib/Doctrine/ORM/Query/AST/WhereClause.php index c089939c587..b13b697f391 100644 --- a/lib/Doctrine/ORM/Query/AST/WhereClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhereClause.php @@ -13,15 +13,9 @@ */ class WhereClause extends Node { - /** @var ConditionalExpression|ConditionalTerm */ - public $conditionalExpression; - - /** - * @param ConditionalExpression $conditionalExpression - */ - public function __construct($conditionalExpression) + /** @param ConditionalExpression $conditionalExpression */ + public function __construct(public $conditionalExpression) { - $this->conditionalExpression = $conditionalExpression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php index 34c5d0a4bf0..8ea7d9271a0 100644 --- a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php @@ -34,9 +34,7 @@ public function getSqlStatements() return $this->_sqlStatements; } - /** - * @return void - */ + /** @return void */ public function setQueryCacheProfile(QueryCacheProfile $qcp) { $this->queryCacheProfile = $qcp; diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php index 8ee3febd901..920b68597dd 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -160,7 +160,7 @@ public function execute(Connection $conn, array $params, array $types) $numUpdated = $conn->executeStatement( $this->_insertSql, array_slice($params, $this->_numParametersInUpdateClause), - array_slice($types, $this->_numParametersInUpdateClause) + array_slice($types, $this->_numParametersInUpdateClause), ); // Execute UPDATE statements diff --git a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php index 92d49c911e4..bf67d86d30b 100644 --- a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php @@ -19,9 +19,7 @@ */ class SingleTableDeleteUpdateExecutor extends AbstractSqlExecutor { - /** - * @param SqlWalker $sqlWalker - */ + /** @param SqlWalker $sqlWalker */ public function __construct(AST\Node $AST, $sqlWalker) { if ($AST instanceof AST\UpdateStatement) { diff --git a/lib/Doctrine/ORM/Query/Expr/Andx.php b/lib/Doctrine/ORM/Query/Expr/Andx.php index 75765fa0b2b..229a4567963 100644 --- a/lib/Doctrine/ORM/Query/Expr/Andx.php +++ b/lib/Doctrine/ORM/Query/Expr/Andx.php @@ -25,9 +25,7 @@ class Andx extends Composite /** @psalm-var list */ protected $parts = []; - /** - * @psalm-return list - */ + /** @psalm-return list */ public function getParts() { return $this->parts; diff --git a/lib/Doctrine/ORM/Query/Expr/Base.php b/lib/Doctrine/ORM/Query/Expr/Base.php index 2933384b28f..bdab1c9ea7e 100644 --- a/lib/Doctrine/ORM/Query/Expr/Base.php +++ b/lib/Doctrine/ORM/Query/Expr/Base.php @@ -36,9 +36,7 @@ abstract class Base /** @psalm-var list */ protected $parts = []; - /** - * @param mixed $args - */ + /** @param mixed $args */ public function __construct($args = []) { $this->addMultiple($args); @@ -73,7 +71,7 @@ public function add($arg) if (! is_string($arg) && ! in_array(get_class($arg), $this->allowedClasses, true)) { throw new InvalidArgumentException(sprintf( "Expression of type '%s' not allowed in this context.", - get_debug_type($arg) + get_debug_type($arg), )); } @@ -92,9 +90,7 @@ public function count() return count($this->parts); } - /** - * @return string - */ + /** @return string */ public function __toString() { if ($this->count() === 1) { diff --git a/lib/Doctrine/ORM/Query/Expr/Comparison.php b/lib/Doctrine/ORM/Query/Expr/Comparison.php index 74d77a43678..152b6c98174 100644 --- a/lib/Doctrine/ORM/Query/Expr/Comparison.php +++ b/lib/Doctrine/ORM/Query/Expr/Comparison.php @@ -18,15 +18,6 @@ class Comparison public const GT = '>'; public const GTE = '>='; - /** @var mixed */ - protected $leftExpr; - - /** @var string */ - protected $operator; - - /** @var mixed */ - protected $rightExpr; - /** * Creates a comparison expression with the given arguments. * @@ -34,40 +25,29 @@ class Comparison * @param string $operator * @param mixed $rightExpr */ - public function __construct($leftExpr, $operator, $rightExpr) + public function __construct(protected $leftExpr, protected $operator, protected $rightExpr) { - $this->leftExpr = $leftExpr; - $this->operator = $operator; - $this->rightExpr = $rightExpr; } - /** - * @return mixed - */ + /** @return mixed */ public function getLeftExpr() { return $this->leftExpr; } - /** - * @return string - */ + /** @return string */ public function getOperator() { return $this->operator; } - /** - * @return mixed - */ + /** @return mixed */ public function getRightExpr() { return $this->rightExpr; } - /** - * @return string - */ + /** @return string */ public function __toString() { return $this->leftExpr . ' ' . $this->operator . ' ' . $this->rightExpr; diff --git a/lib/Doctrine/ORM/Query/Expr/Composite.php b/lib/Doctrine/ORM/Query/Expr/Composite.php index 7fa06320062..2270fbca34b 100644 --- a/lib/Doctrine/ORM/Query/Expr/Composite.php +++ b/lib/Doctrine/ORM/Query/Expr/Composite.php @@ -15,9 +15,7 @@ */ class Composite extends Base { - /** - * @return string - */ + /** @return string */ public function __toString() { if ($this->count() === 1) { @@ -33,9 +31,7 @@ public function __toString() return implode($this->separator, $components); } - /** - * @param string|object $part - */ + /** @param string|object $part */ private function processQueryPart($part): string { $queryPart = (string) $part; diff --git a/lib/Doctrine/ORM/Query/Expr/From.php b/lib/Doctrine/ORM/Query/Expr/From.php index f6162c77617..1157eb93478 100644 --- a/lib/Doctrine/ORM/Query/Expr/From.php +++ b/lib/Doctrine/ORM/Query/Expr/From.php @@ -11,54 +11,34 @@ */ class From { - /** @var class-string */ - protected $from; - - /** @var string */ - protected $alias; - - /** @var string|null */ - protected $indexBy; - /** * @param class-string $from The class name. * @param string $alias The alias of the class. * @param string $indexBy The index for the from. */ - public function __construct($from, $alias, $indexBy = null) + public function __construct(protected $from, protected $alias, protected $indexBy = null) { - $this->from = $from; - $this->alias = $alias; - $this->indexBy = $indexBy; } - /** - * @return class-string - */ + /** @return class-string */ public function getFrom() { return $this->from; } - /** - * @return string - */ + /** @return string */ public function getAlias() { return $this->alias; } - /** - * @return string|null - */ + /** @return string|null */ public function getIndexBy() { return $this->indexBy; } - /** - * @return string - */ + /** @return string */ public function __toString() { return $this->from . ' ' . $this->alias . diff --git a/lib/Doctrine/ORM/Query/Expr/Func.php b/lib/Doctrine/ORM/Query/Expr/Func.php index 22f999b69ab..7c77979903e 100644 --- a/lib/Doctrine/ORM/Query/Expr/Func.php +++ b/lib/Doctrine/ORM/Query/Expr/Func.php @@ -13,9 +13,6 @@ */ class Func { - /** @var string */ - protected $name; - /** @var mixed[] */ protected $arguments; @@ -26,31 +23,24 @@ class Func * @param mixed[]|mixed $arguments * @psalm-param list|mixed $arguments */ - public function __construct($name, $arguments) + public function __construct(protected $name, $arguments) { - $this->name = $name; $this->arguments = (array) $arguments; } - /** - * @return string - */ + /** @return string */ public function getName() { return $this->name; } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function getArguments() { return $this->arguments; } - /** - * @return string - */ + /** @return string */ public function __toString() { return $this->name . '(' . implode(', ', $this->arguments) . ')'; diff --git a/lib/Doctrine/ORM/Query/Expr/GroupBy.php b/lib/Doctrine/ORM/Query/Expr/GroupBy.php index 66c3e85e078..178a48b231b 100644 --- a/lib/Doctrine/ORM/Query/Expr/GroupBy.php +++ b/lib/Doctrine/ORM/Query/Expr/GroupBy.php @@ -20,9 +20,7 @@ class GroupBy extends Base /** @psalm-var list */ protected $parts = []; - /** - * @psalm-return list - */ + /** @psalm-return list */ public function getParts() { return $this->parts; diff --git a/lib/Doctrine/ORM/Query/Expr/Join.php b/lib/Doctrine/ORM/Query/Expr/Join.php index 27b34821369..588826b048c 100644 --- a/lib/Doctrine/ORM/Query/Expr/Join.php +++ b/lib/Doctrine/ORM/Query/Expr/Join.php @@ -26,16 +26,14 @@ class Join public function __construct( protected string $joinType, protected string $join, - protected ?string $alias = null, - protected ?string $conditionType = null, + protected string|null $alias = null, + protected string|null $conditionType = null, protected string|Comparison|Composite|null $condition = null, - protected ?string $indexBy = null + protected string|null $indexBy = null, ) { } - /** - * @psalm-return self::INNER_JOIN|self::LEFT_JOIN - */ + /** @psalm-return self::INNER_JOIN|self::LEFT_JOIN */ public function getJoinType(): string { return $this->joinType; @@ -46,15 +44,13 @@ public function getJoin(): string return $this->join; } - public function getAlias(): ?string + public function getAlias(): string|null { return $this->alias; } - /** - * @psalm-return self::ON|self::WITH|null - */ - public function getConditionType(): ?string + /** @psalm-return self::ON|self::WITH|null */ + public function getConditionType(): string|null { return $this->conditionType; } @@ -64,7 +60,7 @@ public function getCondition(): string|Comparison|Composite|null return $this->condition; } - public function getIndexBy(): ?string + public function getIndexBy(): string|null { return $this->indexBy; } diff --git a/lib/Doctrine/ORM/Query/Expr/Literal.php b/lib/Doctrine/ORM/Query/Expr/Literal.php index 4bc0e8f82f9..d3930fcb97d 100644 --- a/lib/Doctrine/ORM/Query/Expr/Literal.php +++ b/lib/Doctrine/ORM/Query/Expr/Literal.php @@ -20,9 +20,7 @@ class Literal extends Base /** @psalm-var list */ protected $parts = []; - /** - * @psalm-return list - */ + /** @psalm-return list */ public function getParts() { return $this->parts; diff --git a/lib/Doctrine/ORM/Query/Expr/Math.php b/lib/Doctrine/ORM/Query/Expr/Math.php index 8ffb523b509..42b165aa708 100644 --- a/lib/Doctrine/ORM/Query/Expr/Math.php +++ b/lib/Doctrine/ORM/Query/Expr/Math.php @@ -11,15 +11,6 @@ */ class Math { - /** @var mixed */ - protected $leftExpr; - - /** @var string */ - protected $operator; - - /** @var mixed */ - protected $rightExpr; - /** * Creates a mathematical expression with the given arguments. * @@ -27,40 +18,29 @@ class Math * @param string $operator * @param mixed $rightExpr */ - public function __construct($leftExpr, $operator, $rightExpr) + public function __construct(protected $leftExpr, protected $operator, protected $rightExpr) { - $this->leftExpr = $leftExpr; - $this->operator = $operator; - $this->rightExpr = $rightExpr; } - /** - * @return mixed - */ + /** @return mixed */ public function getLeftExpr() { return $this->leftExpr; } - /** - * @return string - */ + /** @return string */ public function getOperator() { return $this->operator; } - /** - * @return mixed - */ + /** @return mixed */ public function getRightExpr() { return $this->rightExpr; } - /** - * @return string - */ + /** @return string */ public function __toString() { // Adjusting Left Expression diff --git a/lib/Doctrine/ORM/Query/Expr/OrderBy.php b/lib/Doctrine/ORM/Query/Expr/OrderBy.php index 4dc4fb27148..dc6cfbd78ee 100644 --- a/lib/Doctrine/ORM/Query/Expr/OrderBy.php +++ b/lib/Doctrine/ORM/Query/Expr/OrderBy.php @@ -61,17 +61,13 @@ public function count() return count($this->parts); } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function getParts() { return $this->parts; } - /** - * @return string - */ + /** @return string */ public function __toString() { return $this->preSeparator . implode($this->separator, $this->parts) . $this->postSeparator; diff --git a/lib/Doctrine/ORM/Query/Expr/Orx.php b/lib/Doctrine/ORM/Query/Expr/Orx.php index eb6f377b9c4..2d3ae0df00d 100644 --- a/lib/Doctrine/ORM/Query/Expr/Orx.php +++ b/lib/Doctrine/ORM/Query/Expr/Orx.php @@ -25,9 +25,7 @@ class Orx extends Composite /** @psalm-var list */ protected $parts = []; - /** - * @psalm-return list - */ + /** @psalm-return list */ public function getParts() { return $this->parts; diff --git a/lib/Doctrine/ORM/Query/Expr/Select.php b/lib/Doctrine/ORM/Query/Expr/Select.php index c3729228cba..a3929fb08ad 100644 --- a/lib/Doctrine/ORM/Query/Expr/Select.php +++ b/lib/Doctrine/ORM/Query/Expr/Select.php @@ -23,9 +23,7 @@ class Select extends Base /** @psalm-var list */ protected $parts = []; - /** - * @psalm-return list - */ + /** @psalm-return list */ public function getParts() { return $this->parts; diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index 5ced1fc61e8..1d1dfed0e70 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -33,7 +33,7 @@ abstract class SQLFilter private array $parameters = []; final public function __construct( - private readonly EntityManagerInterface $em + private readonly EntityManagerInterface $em, ) { } @@ -68,7 +68,7 @@ final public function setParameterList(string $name, array $values, string $type * * @return $this */ - final public function setParameter(string $name, mixed $value, ?string $type = null): static + final public function setParameter(string $name, mixed $value, string|null $type = null): static { if ($type === null) { $type = ParameterTypeInferer::inferType($value); @@ -132,7 +132,7 @@ final public function getParameterList(string $name): string $quoted = array_map( static fn (mixed $value): string => $connection->quote((string) $value), - $param['value'] + $param['value'], ); return implode(',', $quoted); diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index c226e59d961..d08c63532f2 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -49,7 +49,7 @@ class FilterCollection private int $filtersState = self::FILTERS_STATE_CLEAN; public function __construct( - private readonly EntityManagerInterface $em + private readonly EntityManagerInterface $em, ) { $this->config = $em->getConfiguration(); } diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 418410f5de1..1a1c9028c03 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -552,7 +552,7 @@ public function semanticalError($message = '', $token = null) * @return mixed[] * @psalm-return array{value: string, type: int|null|string, position: int}|null */ - private function peekBeyondClosingParenthesis(bool $resetPeek = true): ?array + private function peekBeyondClosingParenthesis(bool $resetPeek = true): array|null { $token = $this->lexer->peek(); $numUnmatched = 1; @@ -586,7 +586,7 @@ private function peekBeyondClosingParenthesis(bool $resetPeek = true): ?array * * @psalm-param Token|null $token */ - private function isMathOperator(?array $token): bool + private function isMathOperator(array|null $token): bool { return $token !== null && in_array($token['type'], [Lexer::T_PLUS, Lexer::T_MINUS, Lexer::T_DIVIDE, Lexer::T_MULTIPLY], true); } @@ -618,7 +618,7 @@ private function isAggregateFunction(int $tokenType): bool return in_array( $tokenType, [Lexer::T_AVG, Lexer::T_MIN, Lexer::T_MAX, Lexer::T_SUM, Lexer::T_COUNT], - true + true, ); } @@ -630,7 +630,7 @@ private function isNextAllAnySome(): bool return in_array( $this->lexer->lookahead['type'], [Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME], - true + true, ); } @@ -647,7 +647,7 @@ private function processDeferredIdentificationVariables(): void if (! isset($this->queryComponents[$identVariable])) { $this->semanticalError( sprintf("'%s' is not defined.", $identVariable), - $deferredItem['token'] + $deferredItem['token'], ); } @@ -657,7 +657,7 @@ private function processDeferredIdentificationVariables(): void if (! isset($qComp['metadata'])) { $this->semanticalError( sprintf("'%s' does not point to a Class.", $identVariable), - $deferredItem['token'] + $deferredItem['token'], ); } @@ -665,7 +665,7 @@ private function processDeferredIdentificationVariables(): void if ($qComp['nestingLevel'] > $deferredItem['nestingLevel']) { $this->semanticalError( sprintf("'%s' is used outside the scope of its declaration.", $identVariable), - $deferredItem['token'] + $deferredItem['token'], ); } } @@ -740,14 +740,14 @@ private function processDeferredPartialObjectExpressions(): void $this->semanticalError(sprintf( "There is no mapped field named '%s' on class %s.", $field, - $class->name + $class->name, ), $deferredItem['token']); } if (array_intersect($class->identifier, $expr->partialFieldSet) !== $class->identifier) { $this->semanticalError( 'The partial field selection of class ' . $class->name . ' must contain the identifier.', - $deferredItem['token'] + $deferredItem['token'], ); } } @@ -766,7 +766,7 @@ private function processDeferredResultVariables(): void if (! isset($this->queryComponents[$resultVariable])) { $this->semanticalError( sprintf("'%s' is not defined.", $resultVariable), - $deferredItem['token'] + $deferredItem['token'], ); } @@ -776,7 +776,7 @@ private function processDeferredResultVariables(): void if (! isset($qComp['resultVariable'])) { $this->semanticalError( sprintf("'%s' does not point to a ResultVariable.", $resultVariable), - $deferredItem['token'] + $deferredItem['token'], ); } @@ -784,7 +784,7 @@ private function processDeferredResultVariables(): void if ($qComp['nestingLevel'] > $deferredItem['nestingLevel']) { $this->semanticalError( sprintf("'%s' is used outside the scope of its declaration.", $resultVariable), - $deferredItem['token'] + $deferredItem['token'], ); } } @@ -815,7 +815,7 @@ private function processDeferredPathExpressions(): void if (! isset($class->associationMappings[$field]) && ! isset($class->fieldMappings[$field])) { $this->semanticalError( 'Class ' . $class->name . ' has no field or association named ' . $field, - $deferredItem['token'] + $deferredItem['token'], ); } @@ -997,7 +997,7 @@ public function AliasIdentificationVariable() if ($exists) { $this->semanticalError( sprintf("'%s' is already defined.", $aliasIdentVariable), - $this->lexer->token + $this->lexer->token, ); } @@ -1034,7 +1034,7 @@ private function validateAbstractSchemaName(string $schemaName): void if (! (class_exists($schemaName, true) || interface_exists($schemaName, true))) { $this->semanticalError( sprintf("Class '%s' is not defined.", $schemaName), - $this->lexer->token + $this->lexer->token, ); } } @@ -1054,7 +1054,7 @@ public function AliasResultVariable() if ($exists) { $this->semanticalError( sprintf("'%s' is already defined.", $resultVariable), - $this->lexer->token + $this->lexer->token, ); } @@ -1093,7 +1093,7 @@ public function JoinAssociationPathExpression() if (! isset($this->queryComponents[$identVariable])) { $this->semanticalError( - 'Identification Variable ' . $identVariable . ' used in join path expression but was not defined before.' + 'Identification Variable ' . $identVariable . ' used in join path expression but was not defined before.', ); } @@ -1164,7 +1164,7 @@ public function AssociationPathExpression() { return $this->PathExpression( AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION | - AST\PathExpression::TYPE_COLLECTION_VALUED_ASSOCIATION + AST\PathExpression::TYPE_COLLECTION_VALUED_ASSOCIATION, ); } @@ -1177,7 +1177,7 @@ public function SingleValuedPathExpression() { return $this->PathExpression( AST\PathExpression::TYPE_STATE_FIELD | - AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION + AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, ); } @@ -1654,7 +1654,7 @@ public function IdentificationVariableDeclaration() return new AST\IdentificationVariableDeclaration( $rangeVariableDeclaration, $indexBy, - $joins + $joins, ); } @@ -1864,7 +1864,7 @@ public function PartialObjectExpression() Deprecation::trigger( 'doctrine/orm', 'https://github.com/doctrine/orm/issues/8471', - 'PARTIAL syntax in DQL is deprecated.' + 'PARTIAL syntax in DQL is deprecated.', ); $this->match(Lexer::T_PARTIAL); @@ -2317,7 +2317,7 @@ public function SelectExpression() default: $this->syntaxError( 'IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression', - $this->lexer->lookahead + $this->lexer->lookahead, ); } @@ -2687,7 +2687,7 @@ public function SimpleConditionalExpression() public function EmptyCollectionComparisonExpression() { $emptyCollectionCompExpr = new AST\EmptyCollectionComparisonExpression( - $this->CollectionValuedPathExpression() + $this->CollectionValuedPathExpression(), ); $this->match(Lexer::T_IS); @@ -2728,7 +2728,7 @@ public function CollectionMemberExpression() $collMemberExpr = new AST\CollectionMemberExpression( $entityExpr, - $this->CollectionValuedPathExpression() + $this->CollectionValuedPathExpression(), ); $collMemberExpr->not = $not; @@ -2751,7 +2751,7 @@ public function Literal() case Lexer::T_INTEGER: case Lexer::T_FLOAT: $this->match( - $this->lexer->isNextToken(Lexer::T_INTEGER) ? Lexer::T_INTEGER : Lexer::T_FLOAT + $this->lexer->isNextToken(Lexer::T_INTEGER) ? Lexer::T_INTEGER : Lexer::T_FLOAT, ); return new AST\Literal(AST\Literal::NUMERIC, $this->lexer->token['value']); @@ -2759,7 +2759,7 @@ public function Literal() case Lexer::T_TRUE: case Lexer::T_FALSE: $this->match( - $this->lexer->isNextToken(Lexer::T_TRUE) ? Lexer::T_TRUE : Lexer::T_FALSE + $this->lexer->isNextToken(Lexer::T_TRUE) ? Lexer::T_TRUE : Lexer::T_FALSE, ); return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token['value']); @@ -3030,7 +3030,7 @@ public function StringPrimary() } $this->syntaxError( - 'StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression' + 'StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression', ); } @@ -3485,7 +3485,7 @@ public function FunctionDeclaration() /** * Helper function for FunctionDeclaration grammar rule. */ - private function CustomFunctionDeclaration(): ?FunctionNode + private function CustomFunctionDeclaration(): FunctionNode|null { $token = $this->lexer->lookahead; $funcName = strtolower($token['value']); @@ -3533,9 +3533,7 @@ public function FunctionsReturningNumerics() return $function; } - /** - * @return FunctionNode - */ + /** @return FunctionNode */ public function CustomFunctionsReturningNumerics() { // getCustomNumericFunction is case-insensitive @@ -3574,9 +3572,7 @@ public function FunctionsReturningDatetime() return $function; } - /** - * @return FunctionNode - */ + /** @return FunctionNode */ public function CustomFunctionsReturningDatetime() { // getCustomDatetimeFunction is case-insensitive @@ -3617,9 +3613,7 @@ public function FunctionsReturningStrings() return $function; } - /** - * @return FunctionNode - */ + /** @return FunctionNode */ public function CustomFunctionsReturningStrings() { // getCustomStringFunction is case-insensitive diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index de3e7abce32..d1140931c59 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -43,9 +43,7 @@ public static function semanticalError($message, $previous = null) return new self('[Semantical Error] ' . $message, 0, $previous); } - /** - * @return QueryException - */ + /** @return QueryException */ public static function invalidLockMode() { return new self('Invalid lock mode hint provided.'); @@ -114,9 +112,7 @@ public static function unknownParameter($key) return new self('Invalid parameter: token ' . $key . ' is not defined in the query.'); } - /** - * @return QueryException - */ + /** @return QueryException */ public static function parameterTypeMismatch() { return new self('DQL Query parameter and type numbers mismatch, but have to be exactly equal.'); @@ -125,7 +121,7 @@ public static function parameterTypeMismatch() public static function invalidPathExpression(PathExpression $pathExpr): self { return new self( - "Invalid PathExpression '" . $pathExpr->identificationVariable . '.' . $pathExpr->field . "'." + "Invalid PathExpression '" . $pathExpr->identificationVariable . '.' . $pathExpr->field . "'.", ); } @@ -144,19 +140,17 @@ public static function iterateWithFetchJoinCollectionNotAllowed($assoc) { return new self( 'Invalid query operation: Not allowed to iterate over fetch join collections ' . - 'in class ' . $assoc['sourceEntity'] . ' association ' . $assoc['fieldName'] + 'in class ' . $assoc['sourceEntity'] . ' association ' . $assoc['fieldName'], ); } - /** - * @return QueryException - */ + /** @return QueryException */ public static function partialObjectsAreDangerous() { return new self( 'Loading partial objects is dangerous. Fetch full objects or consider ' . 'using a different fetch mode. If you really want partial objects, ' . - 'set the doctrine.forcePartialLoad query hint to TRUE.' + 'set the doctrine.forcePartialLoad query hint to TRUE.', ); } @@ -171,18 +165,16 @@ public static function overwritingJoinConditionsNotYetSupported($assoc) return new self( 'Unsupported query operation: It is not yet possible to overwrite the join ' . 'conditions in class ' . $assoc['sourceEntityName'] . ' association ' . $assoc['fieldName'] . '. ' . - 'Use WITH to append additional join conditions to the association.' + 'Use WITH to append additional join conditions to the association.', ); } - /** - * @return QueryException - */ + /** @return QueryException */ public static function associationPathInverseSideNotSupported(PathExpression $pathExpr) { return new self( 'A single-valued association path expression to an inverse side is not supported in DQL queries. ' . - 'Instead of "' . $pathExpr->identificationVariable . '.' . $pathExpr->field . '" use an explicit join.' + 'Instead of "' . $pathExpr->identificationVariable . '.' . $pathExpr->field . '" use an explicit join.', ); } @@ -196,7 +188,7 @@ public static function iterateWithFetchJoinNotAllowed($assoc) { return new self( 'Iterate with fetch join in class ' . $assoc['sourceEntity'] . - ' using association ' . $assoc['fieldName'] . ' not allowed.' + ' using association ' . $assoc['fieldName'] . ' not allowed.', ); } @@ -205,15 +197,13 @@ public static function iterateWithMixedResultNotAllowed(): QueryException return new self('Iterating a query with mixed results (using scalars) is not supported.'); } - /** - * @return QueryException - */ + /** @return QueryException */ public static function associationPathCompositeKeyNotSupported() { return new self( 'A single-valued association path expression to an entity with a composite primary ' . 'key is not supported. Explicitly name the components of the composite primary key ' . - 'in the query.' + 'in the query.', ); } @@ -238,7 +228,7 @@ public static function invalidQueryComponent($dqlAlias) { return new self( "Invalid query component given for DQL alias '" . $dqlAlias . "', " . - "requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys." + "requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys.", ); } } diff --git a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php index c1aea9b17d9..179149b7e82 100644 --- a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php +++ b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php @@ -28,22 +28,16 @@ class QueryExpressionVisitor extends ExpressionVisitor Comparison::LTE => Expr\Comparison::LTE, ]; - /** @var mixed[] */ - private $queryAliases; - /** @var Expr */ private $expr; /** @var list */ private $parameters = []; - /** - * @param mixed[] $queryAliases - */ - public function __construct($queryAliases) + /** @param mixed[] $queryAliases */ + public function __construct(private $queryAliases) { - $this->queryAliases = $queryAliases; - $this->expr = new Expr(); + $this->expr = new Expr(); } /** @@ -191,7 +185,7 @@ public function walkComparison(Comparison $comparison) return new Expr\Comparison( $field, $operator, - $placeholder + $placeholder, ); } diff --git a/lib/Doctrine/ORM/Query/ResultSetMapping.php b/lib/Doctrine/ORM/Query/ResultSetMapping.php index 00919c893ee..7bd81208336 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMapping.php +++ b/lib/Doctrine/ORM/Query/ResultSetMapping.php @@ -181,7 +181,7 @@ class ResultSetMapping * * @todo Rename: addRootEntity */ - public function addEntityResult(string $class, string $alias, ?string $resultAlias = null): static + public function addEntityResult(string $class, string $alias, string|null $resultAlias = null): static { $this->aliasMap[$alias] = $class; $this->entityMappings[$alias] = $resultAlias; @@ -317,7 +317,7 @@ public function isFieldResult(string $columnName): bool * * @todo Rename: addField */ - public function addFieldResult(string $alias, string $columnName, string $fieldName, ?string $declaringClass = null): static + public function addFieldResult(string $alias, string $columnName, string $fieldName, string|null $declaringClass = null): static { // column name (in result set) => field name $this->fieldMappings[$columnName] = $fieldName; @@ -485,9 +485,7 @@ public function getFieldName(string $columnName): string return $this->fieldMappings[$columnName]; } - /** - * @psalm-return array - */ + /** @psalm-return array */ public function getAliasMap(): array { return $this->aliasMap; @@ -532,7 +530,7 @@ public function addMetaResult( string $columnName, string $fieldName, bool $isIdentifierColumn = false, - ?string $type = null + string|null $type = null, ): static { $this->metaMappings[$columnName] = $fieldName; $this->columnOwnerMap[$columnName] = $alias; diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 213e7faa0f4..6069488b351 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -45,9 +45,7 @@ class ResultSetMappingBuilder extends ResultSetMapping private int $sqlCounter = 0; - /** - * @psalm-param self::COLUMN_RENAMING_* $defaultRenameMode - */ + /** @psalm-param self::COLUMN_RENAMING_* $defaultRenameMode */ public function __construct( private readonly EntityManagerInterface $em, private readonly int $defaultRenameMode = self::COLUMN_RENAMING_NONE, @@ -68,7 +66,7 @@ public function addRootEntityFromClassMetadata( string $class, string $alias, array $renamedColumns = [], - ?int $renameMode = null + int|null $renameMode = null, ): void { $renameMode = $renameMode ?: $this->defaultRenameMode; $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); @@ -96,7 +94,7 @@ public function addJoinedEntityFromClassMetadata( string $parentAlias, string $relation, array $renamedColumns = [], - ?int $renameMode = null + int|null $renameMode = null, ): void { $renameMode = $renameMode ?: $this->defaultRenameMode; $columnAliasMap = $this->getColumnAliasMap($class, $renameMode, $renamedColumns); @@ -129,7 +127,7 @@ protected function addAllClassFields(string $class, string $alias, array $column if (isset($this->fieldMappings[$columnAlias])) { throw new InvalidArgumentException(sprintf( "The column '%s' conflicts with another column in the mapper.", - $columnName + $columnName, )); } @@ -149,7 +147,7 @@ protected function addAllClassFields(string $class, string $alias, array $column if (isset($this->metaMappings[$columnAlias])) { throw new InvalidArgumentException(sprintf( "The column '%s' conflicts with another column in the mapper.", - $columnAlias + $columnAlias, )); } @@ -203,7 +201,7 @@ private function getColumnAlias(string $columnName, int $mode, array $customRena private function getColumnAliasMap( string $className, int $mode, - array $customRenameColumns + array $customRenameColumns, ): array { if ($customRenameColumns) { // for BC with 2.2-2.3 API $mode = self::COLUMN_RENAMING_CUSTOM; diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 0ec1d79dec0..446ef544628 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -138,13 +138,11 @@ class SqlWalker */ private readonly QuoteStrategy $quoteStrategy; - /** - * @psalm-param array $queryComponents The query components (symbol table). - */ + /** @psalm-param array $queryComponents The query components (symbol table). */ public function __construct( private readonly Query $query, private readonly ParserResult $parserResult, - private array $queryComponents + private array $queryComponents, ) { $this->rsm = $parserResult->getResultSetMapping(); $this->em = $query->getEntityManager(); @@ -283,7 +281,7 @@ public function getSQLColumnAlias(string $columnName): string */ private function generateClassTableInheritanceJoins( ClassMetadata $class, - string $dqlAlias + string $dqlAlias, ): string { $sql = ''; @@ -414,7 +412,7 @@ private function generateDiscriminatorColumnConditionSQL(array $dqlAliases): str */ private function generateFilterConditionSQL( ClassMetadata $targetEntity, - string $targetTableAlias + string $targetTableAlias, ): string { if (! $this->em->hasFilters()) { return ''; @@ -552,7 +550,7 @@ public function walkEntityIdentificationVariable(string $identVariable): string /** * Walks down an IdentificationVariable (no AST node associated), thereby generating the SQL. */ - public function walkIdentificationVariable(string $identificationVariable, ?string $fieldName = null): string + public function walkIdentificationVariable(string $identificationVariable, string|null $fieldName = null): string { $class = $this->getMetadataForDqlAlias($identificationVariable); @@ -654,7 +652,7 @@ public function walkSelectClause(AST\SelectClause $selectClause): string $class->name, $dqlAlias, $this->queryComponents[$dqlAlias]['parent'], - $this->queryComponents[$dqlAlias]['relation']['fieldName'] + $this->queryComponents[$dqlAlias]['relation']['fieldName'], ); } @@ -834,7 +832,7 @@ public function walkRangeVariableDeclaration(AST\RangeVariableDeclaration $range */ private function generateRangeVariableDeclarationSQL( AST\RangeVariableDeclaration $rangeVariableDeclaration, - bool $buildNestedJoins + bool $buildNestedJoins, ): string { $class = $this->em->getClassMetadata($rangeVariableDeclaration->abstractSchemaName); $dqlAlias = $rangeVariableDeclaration->aliasIdentificationVariable; @@ -846,7 +844,7 @@ private function generateRangeVariableDeclarationSQL( $sql = $this->platform->appendLockHint( $this->quoteStrategy->getTableName($class, $this->platform) . ' ' . $this->getSQLTableAlias($class->getTableName(), $dqlAlias), - $this->query->getHint(Query::HINT_LOCK_MODE) ?: LockMode::NONE + $this->query->getHint(Query::HINT_LOCK_MODE) ?: LockMode::NONE, ); if (! $class->isInheritanceTypeJoined()) { @@ -872,7 +870,7 @@ private function generateRangeVariableDeclarationSQL( public function walkJoinAssociationDeclaration( AST\JoinAssociationDeclaration $joinAssociationDeclaration, int $joinType = AST\Join::JOIN_TYPE_INNER, - ?AST\ConditionalPrimary $condExpr = null + AST\ConditionalPrimary|null $condExpr = null, ): string { $sql = ''; @@ -1453,7 +1451,7 @@ public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesis return sprintf('(%s)', $parenthesisExpression->expression->dispatch($this)); } - public function walkNewObject(AST\NewObjectExpression $newObjectExpression, ?string $newObjectResultAlias = null): string + public function walkNewObject(AST\NewObjectExpression $newObjectExpression, string|null $newObjectResultAlias = null): string { $sqlSelectExpressions = []; $objIndex = $newObjectResultAlias ?: $this->newObjectCounter++; @@ -1702,7 +1700,7 @@ public function walkUpdateItem(AST\UpdateItem $updateItem): string * * WhereClause or not, the appropriate discriminator sql is added. */ - public function walkWhereClause(?AST\WhereClause $whereClause): string + public function walkWhereClause(AST\WhereClause|null $whereClause): string { $condSql = $whereClause !== null ? $this->walkConditionalExpression($whereClause->conditionalExpression) : ''; $discrSql = $this->generateDiscriminatorColumnConditionSQL($this->rootAliases); @@ -1743,7 +1741,7 @@ public function walkWhereClause(?AST\WhereClause $whereClause): string * Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL. */ public function walkConditionalExpression( - AST\ConditionalExpression|AST\ConditionalPrimary|AST\ConditionalTerm|AST\ConditionalFactor $condExpr + AST\ConditionalExpression|AST\ConditionalPrimary|AST\ConditionalTerm|AST\ConditionalFactor $condExpr, ): string { // Phase 2 AST optimization: Skip processing of ConditionalExpression // if only one ConditionalTerm is defined @@ -1758,7 +1756,7 @@ public function walkConditionalExpression( * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. */ public function walkConditionalTerm( - AST\ConditionalTerm|AST\ConditionalPrimary|AST\ConditionalFactor $condTerm + AST\ConditionalTerm|AST\ConditionalPrimary|AST\ConditionalFactor $condTerm, ): string { // Phase 2 AST optimization: Skip processing of ConditionalTerm // if only one ConditionalFactor is defined @@ -1773,7 +1771,7 @@ public function walkConditionalTerm( * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. */ public function walkConditionalFactor( - AST\ConditionalFactor|AST\ConditionalPrimary $factor + AST\ConditionalFactor|AST\ConditionalPrimary $factor, ): string { // Phase 2 AST optimization: Skip processing of ConditionalFactor // if only one ConditionalPrimary is defined @@ -2219,7 +2217,7 @@ public function walkResultVariable(string $resultVariable): string */ private function getChildDiscriminatorsFromClassMetadata( ClassMetadata $rootClass, - AST\InstanceOfExpression $instanceOfExpr + AST\InstanceOfExpression $instanceOfExpr, ): string { $sqlParameterList = []; $discriminators = []; diff --git a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php index 247ac02447f..4cba85a6855 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php @@ -26,7 +26,7 @@ abstract class TreeWalkerAdapter implements TreeWalker public function __construct( private readonly AbstractQuery $query, private readonly ParserResult $parserResult, - private array $queryComponents + private array $queryComponents, ) { } diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChain.php b/lib/Doctrine/ORM/Query/TreeWalkerChain.php index 0c37e58e545..f0fe0c99dde 100644 --- a/lib/Doctrine/ORM/Query/TreeWalkerChain.php +++ b/lib/Doctrine/ORM/Query/TreeWalkerChain.php @@ -30,7 +30,7 @@ class TreeWalkerChain implements TreeWalker public function __construct( private readonly AbstractQuery $query, private readonly ParserResult $parserResult, - private array $queryComponents + private array $queryComponents, ) { } @@ -78,9 +78,7 @@ public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void } } - /** - * @psalm-return Generator - */ + /** @psalm-return Generator */ private function getWalkers(): Generator { foreach ($this->walkers as $walkerClass) { diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 1d785625071..31b7a47f230 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -60,7 +60,7 @@ class QueryBuilder /** * The complete DQL string for this query. */ - private ?string $dql = null; + private string|null $dql = null; /** * The query parameters. @@ -77,7 +77,7 @@ class QueryBuilder /** * The maximum number of results to retrieve. */ - private ?int $maxResults = null; + private int|null $maxResults = null; /** * Keeps root entity alias names for join entities. @@ -94,14 +94,14 @@ class QueryBuilder /** * Second level cache region name. */ - protected ?string $cacheRegion = null; + protected string|null $cacheRegion = null; /** * Second level query cache mode. * * @psalm-var Cache::MODE_*|null */ - protected ?int $cacheMode = null; + protected int|null $cacheMode = null; protected int $lifetime = 0; @@ -111,7 +111,7 @@ class QueryBuilder * @param EntityManagerInterface $em The EntityManager to use. */ public function __construct( - private readonly EntityManagerInterface $em + private readonly EntityManagerInterface $em, ) { $this->parameters = new ArrayCollection(); } @@ -156,9 +156,7 @@ public function isCacheable(): bool return $this->cacheable; } - /** - * @return $this - */ + /** @return $this */ public function setCacheRegion(string $cacheRegion): static { $this->cacheRegion = $cacheRegion; @@ -171,7 +169,7 @@ public function setCacheRegion(string $cacheRegion): static * * @return string|null The cache region name; NULL indicates the default region. */ - public function getCacheRegion(): ?string + public function getCacheRegion(): string|null { return $this->cacheRegion; } @@ -193,10 +191,8 @@ public function setLifetime(int $lifetime): static return $this; } - /** - * @psalm-return Cache::MODE_*|null - */ - public function getCacheMode(): ?int + /** @psalm-return Cache::MODE_*|null */ + public function getCacheMode(): int|null { return $this->cacheMode; } @@ -490,7 +486,7 @@ public function getParameters(): ArrayCollection /** * Gets a (previously set) query parameter of the query being constructed. */ - public function getParameter(string|int $key): ?Parameter + public function getParameter(string|int $key): Parameter|null { $key = Parameter::normalizeName($key); @@ -506,7 +502,7 @@ public function getParameter(string|int $key): ?Parameter * * @return $this */ - public function setFirstResult(?int $firstResult): static + public function setFirstResult(int|null $firstResult): static { $this->firstResult = (int) $firstResult; @@ -517,7 +513,7 @@ public function setFirstResult(?int $firstResult): static * Gets the position of the first result the query object was set to retrieve (the "offset"). * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder. */ - public function getFirstResult(): ?int + public function getFirstResult(): int|null { return $this->firstResult; } @@ -527,7 +523,7 @@ public function getFirstResult(): ?int * * @return $this */ - public function setMaxResults(?int $maxResults): static + public function setMaxResults(int|null $maxResults): static { $this->maxResults = $maxResults; @@ -538,7 +534,7 @@ public function setMaxResults(?int $maxResults): static * Gets the maximum number of results the query object was set to retrieve (the "limit"). * Returns NULL if {@link setMaxResults} was not applied to this query builder. */ - public function getMaxResults(): ?int + public function getMaxResults(): int|null { return $this->maxResults; } @@ -558,7 +554,7 @@ public function add(string $dqlPartName, string|object|array $dqlPart, bool $app if ($append && ($dqlPartName === 'where' || $dqlPartName === 'having')) { throw new InvalidArgumentException( "Using \$append = true does not have an effect with 'where' or 'having' " . - 'parts. See QueryBuilder#andWhere() for an example for correct usage.' + 'parts. See QueryBuilder#andWhere() for an example for correct usage.', ); } @@ -684,7 +680,7 @@ public function addSelect(mixed ...$select): static * * @return $this */ - public function delete(?string $delete = null, ?string $alias = null): static + public function delete(string|null $delete = null, string|null $alias = null): static { $this->type = QueryType::Delete; @@ -696,7 +692,7 @@ public function delete(?string $delete = null, ?string $alias = null): static throw new InvalidArgumentException(sprintf( '%s(): The alias for entity %s must not be omitted.', __METHOD__, - $delete + $delete, )); } @@ -719,7 +715,7 @@ public function delete(?string $delete = null, ?string $alias = null): static * * @return $this */ - public function update(?string $update = null, ?string $alias = null): static + public function update(string|null $update = null, string|null $alias = null): static { $this->type = QueryType::Update; @@ -731,7 +727,7 @@ public function update(?string $update = null, ?string $alias = null): static throw new InvalidArgumentException(sprintf( '%s(): The alias for entity %s must not be omitted.', __METHOD__, - $update + $update, )); } @@ -754,7 +750,7 @@ public function update(?string $update = null, ?string $alias = null): static * * @return $this */ - public function from(string $from, string $alias, ?string $indexBy = null): static + public function from(string $from, string $alias, string|null $indexBy = null): static { return $this->add('from', new Expr\From($from, $alias, $indexBy), true); } @@ -785,7 +781,7 @@ public function indexBy(string $alias, string $indexBy): static if (! in_array($alias, $rootAliases, true)) { throw new Query\QueryException( - sprintf('Specified root alias %s must be set before invoking indexBy().', $alias) + sprintf('Specified root alias %s must be set before invoking indexBy().', $alias), ); } @@ -822,9 +818,9 @@ public function indexBy(string $alias, string $indexBy): static public function join( string $join, string $alias, - ?string $conditionType = null, + string|null $conditionType = null, string|Expr\Composite|Expr\Comparison|null $condition = null, - ?string $indexBy = null + string|null $indexBy = null, ): static { return $this->innerJoin($join, $alias, $conditionType, $condition, $indexBy); } @@ -849,9 +845,9 @@ public function join( public function innerJoin( string $join, string $alias, - ?string $conditionType = null, + string|null $conditionType = null, string|Expr\Composite|Expr\Comparison|null $condition = null, - ?string $indexBy = null + string|null $indexBy = null, ): static { $parentAlias = substr($join, 0, (int) strpos($join, '.')); @@ -863,7 +859,7 @@ public function innerJoin( $alias, $conditionType, $condition, - $indexBy + $indexBy, ); return $this->add('join', [$rootAlias => $join], true); @@ -890,9 +886,9 @@ public function innerJoin( public function leftJoin( string $join, string $alias, - ?string $conditionType = null, + string|null $conditionType = null, string|Expr\Composite|Expr\Comparison|null $condition = null, - ?string $indexBy = null + string|null $indexBy = null, ): static { $parentAlias = substr($join, 0, (int) strpos($join, '.')); @@ -904,7 +900,7 @@ public function leftJoin( $alias, $conditionType, $condition, - $indexBy + $indexBy, ); return $this->add('join', [$rootAlias => $join], true); @@ -1117,7 +1113,7 @@ public function orHaving(mixed ...$having): static * * @return $this */ - public function orderBy(string|Expr\OrderBy $sort, ?string $order = null): static + public function orderBy(string|Expr\OrderBy $sort, string|null $order = null): static { $orderBy = $sort instanceof Expr\OrderBy ? $sort : new Expr\OrderBy($sort, $order); @@ -1129,7 +1125,7 @@ public function orderBy(string|Expr\OrderBy $sort, ?string $order = null): stati * * @return $this */ - public function addOrderBy(string|Expr\OrderBy $sort, ?string $order = null): static + public function addOrderBy(string|Expr\OrderBy $sort, string|null $order = null): static { $orderBy = $sort instanceof Expr\OrderBy ? $sort : new Expr\OrderBy($sort, $order); @@ -1267,9 +1263,7 @@ private function getDQLForSelect(): string return $dql; } - /** - * @psalm-param array $options - */ + /** @psalm-param array $options */ private function getReducedDQLQueryPart(string $queryPartName, array $options = []): string { $queryPart = $this->getDQLPart($queryPartName); @@ -1291,7 +1285,7 @@ private function getReducedDQLQueryPart(string $queryPartName, array $options = * * @return $this */ - public function resetDQLParts(?array $parts = null): static + public function resetDQLParts(array|null $parts = null): static { if ($parts === null) { $parts = array_keys($this->dqlParts); diff --git a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php b/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php index c8c640d3785..5c408fb17f5 100644 --- a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php +++ b/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php @@ -38,7 +38,7 @@ public function getRepository(EntityManagerInterface $entityManager, string $ent */ private function createRepository( EntityManagerInterface $entityManager, - string $entityName + string $entityName, ): EntityRepository { $metadata = $entityManager->getClassMetadata($entityName); $repositoryClassName = $metadata->customRepositoryClassName diff --git a/lib/Doctrine/ORM/Repository/Exception/InvalidFindByCall.php b/lib/Doctrine/ORM/Repository/Exception/InvalidFindByCall.php index 81cea2b5f86..c5dd0155e89 100644 --- a/lib/Doctrine/ORM/Repository/Exception/InvalidFindByCall.php +++ b/lib/Doctrine/ORM/Repository/Exception/InvalidFindByCall.php @@ -11,11 +11,11 @@ final class InvalidFindByCall extends LogicException implements RepositoryExcept { public static function fromInverseSideUsage( string $entityName, - string $associationFieldName + string $associationFieldName, ): self { return new self( "You cannot search for the association field '" . $entityName . '#' . $associationFieldName . "', " . - 'because it is the inverse side of an association. Find methods only work on owning side associations.' + 'because it is the inverse side of an association. Find methods only work on owning side associations.', ); } } diff --git a/lib/Doctrine/ORM/Repository/Exception/InvalidMagicMethodCall.php b/lib/Doctrine/ORM/Repository/Exception/InvalidMagicMethodCall.php index c16d1fc8e3a..1da49cb7d6b 100644 --- a/lib/Doctrine/ORM/Repository/Exception/InvalidMagicMethodCall.php +++ b/lib/Doctrine/ORM/Repository/Exception/InvalidMagicMethodCall.php @@ -12,11 +12,11 @@ final class InvalidMagicMethodCall extends LogicException implements RepositoryE public static function becauseFieldNotFoundIn( string $entityName, string $fieldName, - string $method + string $method, ): self { return new self( "Entity '" . $entityName . "' has no field '" . $fieldName . "'. " . - "You can therefore not call '" . $method . "' on the entities' repository." + "You can therefore not call '" . $method . "' on the entities' repository.", ); } diff --git a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php index 72908a86636..59cd77eb8f7 100644 --- a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php +++ b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php @@ -28,7 +28,7 @@ public function addEntityListener( string $entityClass, string $listenerClass, string $eventName, - $listenerCallback = null + $listenerCallback = null, ): void { $this->entityListeners[ltrim($entityClass, '\\')][] = [ 'event' => $eventName, diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php index f1bcee8f1a6..c0fc8434498 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php @@ -53,8 +53,7 @@ protected function configure(): void Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. -EOT - ); +EOT); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -83,8 +82,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int sprintf( 'Flushing cache provider configured for "%s#%s"', $ownerClass, - $assoc - ) + $assoc, + ), ); return 0; @@ -104,8 +103,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'Clearing second-level cache entry for collection "%s#%s" owner entity identified by "%s"', $ownerClass, $assoc, - $ownerId - ) + $ownerId, + ), ); $cache->evictCollection($ownerClass, $assoc, $ownerId); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php index 05c69a41180..758f68a53ed 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php @@ -52,8 +52,7 @@ protected function configure(): void Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. -EOT - ); +EOT); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -95,8 +94,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int sprintf( 'Clearing second-level cache entry for entity "%s" identified by "%s"', $entityClass, - $entityId - ) + $entityId, + ), ); $cache->evictEntity($entityClass, $entityId); diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php index 850cc89fce3..4ba30e93a07 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php @@ -26,8 +26,7 @@ protected function configure(): void ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, cache entries will be flushed instead of deleted/invalidated.') ->setHelp(<<<'EOT' The %command.name% command is meant to clear the metadata cache of associated Entity Manager. -EOT - ); +EOT); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php index f9a07f736e1..06ab676138a 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php @@ -51,8 +51,7 @@ protected function configure(): void Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. -EOT - ); +EOT); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -79,8 +78,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $ui->comment( sprintf( 'Flushing cache provider configured for second-level cache query region named "%s"', - $name - ) + $name, + ), ); return 0; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php index f2bc3f62ab2..2a6d845917a 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php @@ -40,8 +40,7 @@ protected function configure(): void Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, because of a limitation of its execution nature. -EOT - ); +EOT); } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php index 6b8d2a8b07e..65cb9a7f55c 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php @@ -64,13 +64,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (! file_exists($destPath)) { throw new InvalidArgumentException( - sprintf("Proxies destination directory '%s' does not exist.", $em->getConfiguration()->getProxyDir()) + sprintf("Proxies destination directory '%s' does not exist.", $em->getConfiguration()->getProxyDir()), ); } if (! is_writable($destPath)) { throw new InvalidArgumentException( - sprintf("Proxies destination directory '%s' does not have write permissions.", $destPath) + sprintf("Proxies destination directory '%s' does not have write permissions.", $destPath), ); } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php index 35a1ff2ec48..743d540b955 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php @@ -29,8 +29,7 @@ protected function configure(): void The %command.name% shows basic information about which entities exist and possibly if their mapping information contains errors or not. -EOT - ); +EOT); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -48,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int [ 'You do not have any mapped Doctrine ORM entities according to the current configuration.', 'If you have entities or mapping files you should check your mapping configuration for errors.', - ] + ], ); return 1; @@ -69,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int sprintf('[FAIL] %s', $entityClassName), sprintf('%s', $e->getMessage()), '', - ] + ], ); $failure = true; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 3cc57ff5f41..dd542531c12 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -57,8 +57,7 @@ protected function configure(): void Or: %command.full_name% MyEntity -EOT - ); +EOT); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -80,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function displayEntity( string $entityName, EntityManagerInterface $entityManager, - SymfonyStyle $ui + SymfonyStyle $ui, ): void { $metadata = $this->getClassMetadata($entityName, $entityManager); @@ -119,8 +118,8 @@ private function displayEntity( [$this->formatField('Association mappings:', '')], $this->formatMappings($metadata->associationMappings), [$this->formatField('Field mappings:', '')], - $this->formatMappings($metadata->fieldMappings) - ) + $this->formatMappings($metadata->fieldMappings), + ), ); } @@ -139,7 +138,7 @@ private function getMappedEntities(EntityManagerInterface $entityManager): array if (! $entityClassNames) { throw new InvalidArgumentException( 'You do not have any mapped Doctrine ORM entities according to the current configuration. ' . - 'If you have entities or mapping files you should check your mapping configuration for errors.' + 'If you have entities or mapping files you should check your mapping configuration for errors.', ); } @@ -154,7 +153,7 @@ private function getMappedEntities(EntityManagerInterface $entityManager): array */ private function getClassMetadata( string $entityName, - EntityManagerInterface $entityManager + EntityManagerInterface $entityManager, ): ClassMetadata { try { return $entityManager->getClassMetadata($entityName); @@ -169,7 +168,7 @@ private function getClassMetadata( if (! $matches) { throw new InvalidArgumentException(sprintf( 'Could not find any mapped Entity classes matching "%s"', - $entityName + $entityName, )); } @@ -177,7 +176,7 @@ private function getClassMetadata( throw new InvalidArgumentException(sprintf( 'Entity name "%s" is ambiguous, possible matches: "%s"', $entityName, - implode(', ', $matches) + implode(', ', $matches), )); } @@ -208,7 +207,7 @@ private function formatValue(mixed $value): string if (is_array($value)) { return json_encode( $value, - JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR, ); } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php index 78ac6b754e5..5eb78e4ad0f 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php @@ -64,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (! defined($hydrationMode)) { throw new RuntimeException(sprintf( "Hydration mode '%s' does not exist. It should be either: object. array, scalar or single-scalar.", - $hydrationModeName + $hydrationModeName, )); } diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php index 46c47a13faa..b6da9cd1af9 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php @@ -17,9 +17,7 @@ */ abstract class AbstractCommand extends AbstractEntityManagerCommand { - /** - * @param mixed[] $metadatas - */ + /** @param mixed[] $metadatas */ abstract protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui): int; protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php index 1d7d4168cc3..b90fc92b344 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php @@ -33,8 +33,7 @@ protected function configure(): void on a global level: $config->setFilterSchemaAssetsExpression($regexp); -EOT - ); +EOT); } /** diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php index f791dbcd40e..2c4d9cdc494 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php @@ -37,8 +37,7 @@ protected function configure(): void on a global level: $config->setFilterSchemaAssetsExpression($regexp); -EOT - ); +EOT); } /** @@ -101,7 +100,7 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $ '', sprintf(' %s --force to execute the command', $this->getName()), sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName()), - ] + ], ); return 1; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php index ba4e141709d..746294bab63 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -61,8 +61,7 @@ protected function configure(): void on a global level: $config->setFilterSchemaAssetsExpression($regexp); -EOT - ); +EOT); } /** @@ -116,7 +115,7 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $ '', 'Use the incremental update to detect changes during development and use', 'the SQL DDL provided to manually update your database in production.', - ] + ], ); $ui->text( @@ -127,7 +126,7 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $ '', sprintf(' %s --force to execute the command', $this->getName()), sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName()), - ] + ], ); return 1; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php index eaaf38897d7..7cddcad6101 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php @@ -49,8 +49,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $ui->text( sprintf( '[FAIL] The entity-class %s mapping is invalid:', - $className - ) + $className, + ), ); $ui->listing($errorMessages); diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php index 3d678a4e1a6..0a00483244e 100644 --- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php @@ -40,7 +40,7 @@ public static function run(EntityManagerProvider $entityManagerProvider, array $ */ public static function createApplication( EntityManagerProvider $entityManagerProvider, - array $commands = [] + array $commands = [], ): Application { $version = InstalledVersions::getVersion('doctrine/orm'); assert($version !== null); @@ -82,7 +82,7 @@ public static function addCommands(Application $cli, EntityManagerProvider $enti new Command\ValidateSchemaCommand($entityManagerProvider), new Command\InfoCommand($entityManagerProvider), new Command\MappingDescribeCommand($entityManagerProvider), - ] + ], ); } } diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/UnknownManagerException.php b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/UnknownManagerException.php index 3489e5deb9d..583d90908a9 100644 --- a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/UnknownManagerException.php +++ b/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/UnknownManagerException.php @@ -11,15 +11,13 @@ final class UnknownManagerException extends OutOfBoundsException { - /** - * @psalm-param list $knownManagers - */ + /** @psalm-param list $knownManagers */ public static function unknownManager(string $unknownManager, array $knownManagers = []): self { return new self(sprintf( 'Requested unknown entity manager: %s, known managers: %s', $unknownManager, - implode(', ', $knownManagers) + implode(', ', $knownManagers), )); } } diff --git a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php b/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php index 4ecc4caa570..05e248cea67 100644 --- a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php +++ b/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php @@ -41,9 +41,7 @@ public static function filter(array $metadatas, array|string $filter): array return iterator_to_array($metadatas); } - /** - * @param mixed[]|string $filter - */ + /** @param mixed[]|string $filter */ public function __construct(ArrayIterator $metadata, array|string $filter) { $this->filter = (array) $filter; @@ -65,7 +63,7 @@ public function accept(): bool if ($pregResult === false) { throw new RuntimeException( - sprintf("Error while evaluating regex '/%s/'.", $filter) + sprintf("Error while evaluating regex '/%s/'.", $filter), ); } @@ -77,9 +75,7 @@ public function accept(): bool return false; } - /** - * @return ArrayIterator - */ + /** @return ArrayIterator */ public function getInnerIterator(): ArrayIterator { $innerIterator = parent::getInnerIterator(); diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index 36fccf9874a..52bd953aaf6 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -33,7 +33,7 @@ class DebugUnitOfWorkListener */ public function __construct( private readonly string $file = 'php://output', - private readonly string $context = '' + private readonly string $context = '', ) { } diff --git a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php index 7af3e775d2b..3b0993e6510 100644 --- a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php +++ b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php @@ -17,7 +17,7 @@ class GenerateSchemaEventArgs extends EventArgs { public function __construct( private readonly EntityManagerInterface $em, - private readonly Schema $schema + private readonly Schema $schema, ) { } diff --git a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php index f7da465bf19..a09aaae8e2c 100644 --- a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php +++ b/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php @@ -19,7 +19,7 @@ class GenerateSchemaTableEventArgs extends EventArgs public function __construct( private readonly ClassMetadata $classMetadata, private readonly Schema $schema, - private readonly Table $classTable + private readonly Table $classTable, ) { } diff --git a/lib/Doctrine/ORM/Tools/Exception/MissingColumnException.php b/lib/Doctrine/ORM/Tools/Exception/MissingColumnException.php index fa3fde1a34c..764721e045b 100644 --- a/lib/Doctrine/ORM/Tools/Exception/MissingColumnException.php +++ b/lib/Doctrine/ORM/Tools/Exception/MissingColumnException.php @@ -17,7 +17,7 @@ public static function fromColumnSourceAndTarget(string $column, string $source, 'Column name "%s" referenced for relation from %s towards %s does not exist.', $column, $source, - $target + $target, )); } } diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index 3c6aae1b132..6189422841e 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -63,7 +63,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): string if ($selectStatement->groupByClause) { return sprintf( 'SELECT COUNT(*) AS dctrn_count FROM (%s) dctrn_table', - $sql + $sql, ); } @@ -108,7 +108,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): string if (count($rootIdentifier) !== count($sqlIdentifier)) { throw new RuntimeException(sprintf( 'Not all identifier properties can be found in the ResultSetMapping: %s', - implode(', ', array_diff($rootIdentifier, array_keys($sqlIdentifier))) + implode(', ', array_diff($rootIdentifier, array_keys($sqlIdentifier))), )); } @@ -116,7 +116,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): string return sprintf( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT %s FROM (%s) dctrn_result) dctrn_table', implode(', ', $sqlIdentifier), - $sql + $sql, ); } } diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php index 754259f5a7c..d2129435558 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -50,7 +50,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void $pathExpression = new PathExpression( PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $rootAlias, - $identifierFieldName + $identifierFieldName, ); $pathExpression->type = $pathType; @@ -58,7 +58,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void $selectStatement->selectClause->selectExpressions = [ new SelectExpression( new AggregateExpression('count', $pathExpression, $distinct), - null + null, ), ]; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 5e0cf0281f8..3aebe7db471 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -58,7 +58,7 @@ class LimitSubqueryOutputWalker extends SqlWalker private AbstractPlatform $platform; private ResultSetMapping $rsm; private int $firstResult; - private ?int $maxResults; + private int|null $maxResults; private EntityManagerInterface $em; private QuoteStrategy $quoteStrategy; @@ -81,7 +81,7 @@ class LimitSubqueryOutputWalker extends SqlWalker public function __construct( Query $query, ParserResult $parserResult, - array $queryComponents + array $queryComponents, ) { $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform(); $this->rsm = $parserResult->getResultSetMapping(); @@ -176,7 +176,7 @@ public function walkSelectStatementWithRowNumber(SelectStatement $AST): string $sql = sprintf( 'SELECT DISTINCT %s FROM (%s) dctrn_result', implode(', ', $sqlIdentifier), - $innerSql + $innerSql, ); if ($hasOrderBy) { @@ -187,7 +187,7 @@ public function walkSelectStatementWithRowNumber(SelectStatement $AST): string $sql = $this->platform->modifyLimitQuery( $sql, $this->maxResults, - $this->firstResult + $this->firstResult, ); // Add the columns to the ResultSetMapping. It's not really nice but @@ -230,7 +230,7 @@ public function walkSelectStatementWithoutRowNumber(SelectStatement $AST, bool $ $sql = sprintf( 'SELECT DISTINCT %s FROM (%s) dctrn_result', implode(', ', $sqlIdentifier), - $innerSql + $innerSql, ); // http://www.doctrine-project.org/jira/browse/DDC-1958 @@ -240,7 +240,7 @@ public function walkSelectStatementWithoutRowNumber(SelectStatement $AST, bool $ $sql = $this->platform->modifyLimitQuery( $sql, $this->maxResults, - $this->firstResult + $this->firstResult, ); // Add the columns to the ResultSetMapping. It's not really nice but @@ -323,7 +323,7 @@ private function preserveSqlOrdering( array $sqlIdentifier, string $innerSql, string $sql, - ?OrderByClause $orderByClause + OrderByClause|null $orderByClause, ): string { // If the sql statement has an order by clause, we need to wrap it in a new select distinct statement if (! $orderByClause) { @@ -334,7 +334,7 @@ private function preserveSqlOrdering( return sprintf( 'SELECT DISTINCT %s FROM (%s) dctrn_result', implode(', ', $sqlIdentifier), - $this->recreateInnerSql($orderByClause, $sqlIdentifier, $innerSql) + $this->recreateInnerSql($orderByClause, $sqlIdentifier, $innerSql), ); } @@ -346,7 +346,7 @@ private function preserveSqlOrdering( private function recreateInnerSql( OrderByClause $orderByClause, array $identifiers, - string $innerSql + string $innerSql, ): string { [$searchPatterns, $replacements] = $this->generateSqlAliasReplacements(); @@ -358,7 +358,7 @@ private function recreateInnerSql( $orderByItemString = preg_replace( $searchPatterns, $replacements, - $this->walkOrderByItem($orderByItem) + $this->walkOrderByItem($orderByItem), ); $orderByItems[] = $orderByItemString; @@ -373,7 +373,7 @@ private function recreateInnerSql( 'SELECT DISTINCT %s FROM (%s) dctrn_result_inner ORDER BY %s', implode(', ', $identifiers), $innerSql, - implode(', ', $orderByItems) + implode(', ', $orderByItems), ); } @@ -407,7 +407,7 @@ private function generateSqlAliasReplacements(): array $columnName = $this->quoteStrategy->getColumnName( $fieldName, $metadataList[$dqlAliasForFieldAlias], - $this->em->getConnection()->getDatabasePlatform() + $this->em->getConnection()->getDatabasePlatform(), ); // Get the SQL table alias for the entity and field @@ -467,9 +467,7 @@ private function getInnerSQL(SelectStatement $AST): string return $innerSql; } - /** - * @return string[] - */ + /** @return string[] */ private function getSQLIdentifier(SelectStatement $AST): array { // Find out the SQL alias of the identifier column of the root entity. @@ -517,7 +515,7 @@ private function getSQLIdentifier(SelectStatement $AST): array if (count($rootIdentifier) !== count($sqlIdentifier)) { throw new RuntimeException(sprintf( 'Not all identifier properties can be found in the ResultSetMapping: %s', - implode(', ', array_diff($rootIdentifier, array_keys($sqlIdentifier))) + implode(', ', array_diff($rootIdentifier, array_keys($sqlIdentifier))), )); } diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index 4230e1d036f..52e3c2841d0 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -50,7 +50,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void $this->_getQuery()->setHint( self::IDENTIFIER_TYPE, - Type::getType($rootClass->fieldMappings[$identifier]['type']) + Type::getType($rootClass->fieldMappings[$identifier]['type']), ); $this->_getQuery()->setHint(self::FORCE_DBAL_TYPE_CONVERSION, true); @@ -58,7 +58,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void $pathExpression = new PathExpression( PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $rootAlias, - $identifier + $identifier, ); $pathExpression->type = PathExpression::TYPE_STATE_FIELD; @@ -75,7 +75,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void if ($item->expression instanceof PathExpression) { $selectStatement->selectClause->selectExpressions[] = new SelectExpression( $this->createSelectExpressionItem($item->expression), - '_dctrn_ord' . $this->aliasCounter++ + '_dctrn_ord' . $this->aliasCounter++, ); continue; @@ -87,7 +87,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void if (isset($qComp['resultVariable'])) { $selectStatement->selectClause->selectExpressions[] = new SelectExpression( $qComp['resultVariable'], - $item->expression + $item->expression, ); } } diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index c24ac4c0350..f7ade370120 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -32,15 +32,13 @@ class Paginator implements Countable, IteratorAggregate use SQLResultCasing; private readonly Query $query; - private ?bool $useOutputWalkers = null; - private ?int $count = null; + private bool|null $useOutputWalkers = null; + private int|null $count = null; - /** - * @param bool $fetchJoinCollection Whether the query joins a collection (true by default). - */ + /** @param bool $fetchJoinCollection Whether the query joins a collection (true by default). */ public function __construct( Query|QueryBuilder $query, - private readonly bool $fetchJoinCollection = true + private readonly bool $fetchJoinCollection = true, ) { if ($query instanceof QueryBuilder) { $query = $query->getQuery(); @@ -70,7 +68,7 @@ public function getFetchJoinCollection(): bool /** * Returns whether the paginator will use an output walker. */ - public function getUseOutputWalkers(): ?bool + public function getUseOutputWalkers(): bool|null { return $this->useOutputWalkers; } @@ -80,7 +78,7 @@ public function getUseOutputWalkers(): ?bool * * @return $this */ - public function setUseOutputWalkers(?bool $useOutputWalkers): static + public function setUseOutputWalkers(bool|null $useOutputWalkers): static { $this->useOutputWalkers = $useOutputWalkers; diff --git a/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php b/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php index 610e5ae2fc3..44c0cb8fc1c 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php +++ b/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php @@ -22,13 +22,11 @@ class RowNumberOverFunction extends FunctionNode /** @var OrderByClause */ public $orderByClause; - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getSql(SqlWalker $sqlWalker) { return 'ROW_NUMBER() OVER(' . trim($sqlWalker->walkOrderByClause( - $this->orderByClause + $this->orderByClause, )) . ')'; } diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php index c537a640fec..990dd74a09e 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -74,7 +74,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void if ($count > 0) { $arithmeticExpression = new ArithmeticExpression(); $arithmeticExpression->simpleArithmeticExpression = new SimpleArithmeticExpression( - [$pathExpression] + [$pathExpression], ); $expression = new InExpression($arithmeticExpression); $expression->literals[] = new InputParameter(':' . self::PAGINATOR_ID_ALIAS); @@ -84,8 +84,8 @@ public function walkSelectStatement(SelectStatement $selectStatement): void $identifierFieldName, $rootClass, $this->_getQuery() - ->getEntityManager() - )[0] + ->getEntityManager(), + )[0], ); } else { $expression = new NullComparisonExpression($pathExpression); @@ -104,9 +104,9 @@ public function walkSelectStatement(SelectStatement $selectStatement): void [ $selectStatement->whereClause->conditionalExpression, $conditionalPrimary, - ] + ], ), - ] + ], ); } elseif ( $selectStatement->whereClause->conditionalExpression instanceof ConditionalExpression @@ -118,14 +118,14 @@ public function walkSelectStatement(SelectStatement $selectStatement): void [ $tmpPrimary, $conditionalPrimary, - ] + ], ); } } else { $selectStatement->whereClause = new WhereClause( new ConditionalExpression( - [new ConditionalTerm([$conditionalPrimary])] - ) + [new ConditionalTerm([$conditionalPrimary])], + ), ); } } diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php index 663c4b681dc..c2c54132fb3 100644 --- a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -47,16 +47,14 @@ public function addResolveTargetEntity(string $originalEntity, string $newEntity $this->resolveTargetEntities[ltrim($originalEntity, '\\')] = $mapping; } - /** - * @internal this is an event callback, and should not be called directly - */ + /** @internal this is an event callback, and should not be called directly */ public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args): void { if (array_key_exists($args->getClassName(), $this->resolveTargetEntities)) { $args->setFoundMetadata( $args ->getObjectManager() - ->getClassMetadata($this->resolveTargetEntities[$args->getClassName()]['targetEntity']) + ->getClassMetadata($this->resolveTargetEntities[$args->getClassName()]['targetEntity']), ); } } @@ -89,9 +87,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $args): void } } - /** - * @param mixed[] $mapping - */ + /** @param mixed[] $mapping */ private function remapAssociation(ClassMetadata $classMetadata, array $mapping): void { $newMapping = $this->resolveTargetEntities[$mapping['targetEntity']]; diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 6018e70209a..3f3e0ac3af5 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -106,7 +106,7 @@ public function getCreateSchemaSql(array $classes): array */ private function processingNotRequired( ClassMetadata $class, - array $processedClasses + array $processedClasses, ): bool { return isset($processedClasses[$class->name]) || $class->isMappedSuperclass || @@ -135,7 +135,7 @@ private function getIndexColumns(ClassMetadata $class, array $indexData): array ) { throw MappingException::invalidIndexConfiguration( $class, - $indexData['name'] ?? 'unnamed' + $indexData['name'] ?? 'unnamed', ); } @@ -228,7 +228,7 @@ public function getSchemaFromMetadata(array $classes): Schema $columnName = $this->quoteStrategy->getColumnName( $identifierField, $class, - $this->platform + $this->platform, ); // TODO: This seems rather hackish, can we optimize it? $table->getColumn($columnName)->setAutoincrement(false); @@ -246,7 +246,7 @@ public function getSchemaFromMetadata(array $classes): Schema array_filter( $classes, static fn (ClassMetadata $class): bool => $class->name === $idMapping['targetEntity'] - ) + ), ); foreach ($idMapping['joinColumns'] as $joinColumn) { @@ -254,7 +254,7 @@ public function getSchemaFromMetadata(array $classes): Schema $columnName = $this->quoteStrategy->getJoinColumnName( $joinColumn, $class, - $this->platform + $this->platform, ); $pkColumns[] = $columnName; @@ -269,11 +269,11 @@ public function getSchemaFromMetadata(array $classes): Schema $table->addForeignKeyConstraint( $this->quoteStrategy->getTableName( $this->em->getClassMetadata($class->rootEntityName), - $this->platform + $this->platform, ), $inheritedKeyColumns, $inheritedKeyColumns, - ['onDelete' => 'CASCADE'] + ['onDelete' => 'CASCADE'], ); } @@ -328,7 +328,7 @@ public function getSchemaFromMetadata(array $classes): Schema $this->getIndexColumns($class, $indexData), is_numeric($indexName) ? null : $indexName, (array) $indexData['flags'], - $indexData['options'] ?? [] + $indexData['options'] ?? [], ); } } @@ -363,7 +363,7 @@ public function getSchemaFromMetadata(array $classes): Schema $schema->createSequence( $quotedName, (int) $seqDef['allocationSize'], - (int) $seqDef['initialValue'] + (int) $seqDef['initialValue'], ); } } @@ -371,7 +371,7 @@ public function getSchemaFromMetadata(array $classes): Schema if ($eventManager->hasListeners(ToolEvents::postGenerateSchemaTable)) { $eventManager->dispatchEvent( ToolEvents::postGenerateSchemaTable, - new GenerateSchemaTableEventArgs($class, $schema, $table) + new GenerateSchemaTableEventArgs($class, $schema, $table), ); } } @@ -387,7 +387,7 @@ public function getSchemaFromMetadata(array $classes): Schema if ($eventManager->hasListeners(ToolEvents::postGenerateSchema)) { $eventManager->dispatchEvent( ToolEvents::postGenerateSchema, - new GenerateSchemaEventArgs($this->em, $schema) + new GenerateSchemaEventArgs($this->em, $schema), ); } @@ -452,7 +452,7 @@ private function gatherColumns(ClassMetadata $class, Table $table): void private function gatherColumn( ClassMetadata $class, array $mapping, - Table $table + Table $table, ): void { $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); $columnType = $mapping['type']; @@ -528,7 +528,7 @@ private function gatherRelationsSql( Table $table, Schema $schema, array &$addedFks, - array &$blacklistedFks + array &$blacklistedFks, ): void { foreach ($class->associationMappings as $id => $mapping) { if (isset($mapping['inherited']) && ! in_array($id, $class->identifier, true)) { @@ -547,7 +547,7 @@ private function gatherRelationsSql( $mapping, $primaryKeyColumns, $addedFks, - $blacklistedFks + $blacklistedFks, ); } elseif ($mapping['type'] === ClassMetadata::ONE_TO_MANY && $mapping['isOwningSide']) { //... create join table, one-many through join table supported later @@ -557,7 +557,7 @@ private function gatherRelationsSql( $joinTable = $mapping['joinTable']; $theJoinTable = $schema->createTable( - $this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform) + $this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform), ); if (isset($joinTable['options'])) { @@ -576,7 +576,7 @@ private function gatherRelationsSql( $mapping, $primaryKeyColumns, $addedFks, - $blacklistedFks + $blacklistedFks, ); // Build second FK constraint (relation table => target table) @@ -587,7 +587,7 @@ private function gatherRelationsSql( $mapping, $primaryKeyColumns, $addedFks, - $blacklistedFks + $blacklistedFks, ); $theJoinTable->setPrimaryKey($primaryKeyColumns); @@ -606,7 +606,7 @@ private function gatherRelationsSql( * * @psalm-return array{ClassMetadata, string}|null */ - private function getDefiningClass(ClassMetadata $class, string $referencedColumnName): ?array + private function getDefiningClass(ClassMetadata $class, string $referencedColumnName): array|null { $referencedFieldName = $class->getFieldName($referencedColumnName); @@ -623,7 +623,7 @@ private function getDefiningClass(ClassMetadata $class, string $referencedColumn ) { return $this->getDefiningClass( $this->em->getClassMetadata($class->associationMappings[$fieldName]['targetEntity']), - $class->getSingleAssociationReferencedJoinColumnName($fieldName) + $class->getSingleAssociationReferencedJoinColumnName($fieldName), ); } } @@ -653,7 +653,7 @@ private function gatherRelationJoinColumns( array $mapping, array &$primaryKeyColumns, array &$addedFks, - array &$blacklistedFks + array &$blacklistedFks, ): void { $localColumns = []; $foreignColumns = []; @@ -664,14 +664,14 @@ private function gatherRelationJoinColumns( foreach ($joinColumns as $joinColumn) { [$definingClass, $referencedFieldName] = $this->getDefiningClass( $class, - $joinColumn['referencedColumnName'] + $joinColumn['referencedColumnName'], ); if (! $definingClass) { throw MissingColumnException::fromColumnSourceAndTarget( $joinColumn['referencedColumnName'], $mapping['sourceEntity'], - $mapping['targetEntity'] + $mapping['targetEntity'], ); } @@ -679,7 +679,7 @@ private function gatherRelationJoinColumns( $quotedRefColumnName = $this->quoteStrategy->getReferencedJoinColumnName( $joinColumn, $class, - $this->platform + $this->platform, ); $primaryKeyColumns[] = $quotedColumnName; @@ -760,7 +760,7 @@ private function gatherRelationJoinColumns( $foreignTableName, $localColumns, $foreignColumns, - $fkOptions + $fkOptions, ); } } diff --git a/lib/Doctrine/ORM/Tools/ToolsException.php b/lib/Doctrine/ORM/Tools/ToolsException.php index abb0dfb0f1a..e5cb973b430 100644 --- a/lib/Doctrine/ORM/Tools/ToolsException.php +++ b/lib/Doctrine/ORM/Tools/ToolsException.php @@ -18,7 +18,7 @@ public static function schemaToolFailure(string $sql, Throwable $e): self return new self( "Schema-Tool failed with Error '" . $e->getMessage() . "' while executing DDL: " . $sql, 0, - $e + $e, ); } } diff --git a/lib/Doctrine/ORM/TransactionRequiredException.php b/lib/Doctrine/ORM/TransactionRequiredException.php index da0b7e5c0f6..2f9ef347f7c 100644 --- a/lib/Doctrine/ORM/TransactionRequiredException.php +++ b/lib/Doctrine/ORM/TransactionRequiredException.php @@ -14,9 +14,7 @@ */ class TransactionRequiredException extends LogicException implements ORMException { - /** - * @return TransactionRequiredException - */ + /** @return TransactionRequiredException */ public static function transactionRequired() { return new self('An open transaction is required for this operation.'); diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 69a85ade0fd..8bcf9027842 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -293,7 +293,7 @@ class UnitOfWork implements PropertyChangedListener * @param EntityManagerInterface $em The EntityManager that "owns" this UnitOfWork instance. */ public function __construct( - private readonly EntityManagerInterface $em + private readonly EntityManagerInterface $em, ) { $this->evm = $em->getEventManager(); $this->listenersInvoker = new ListenersInvoker($em); @@ -584,7 +584,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void $value = new PersistentCollection( $this->em, $this->em->getClassMetadata($assoc['targetEntity']), - $value + $value, ); $value->setOwner($entity, $assoc); $value->setDirty(! $value->isEmpty()); @@ -811,7 +811,7 @@ private function computeAssociationChanges(array $assoc, mixed $value): void $assoc['sourceEntity'], $assoc['fieldName'], get_debug_type($entry), - $assoc['targetEntity'] + $assoc['targetEntity'], ); } @@ -893,9 +893,7 @@ private function persistNew(ClassMetadata $class, object $entity): void $this->scheduleForInsert($entity); } - /** - * @param mixed[] $idValue - */ + /** @param mixed[] $idValue */ private function hasMissingIdsWhichAreForeignKeys(ClassMetadata $class, array $idValue): bool { foreach ($idValue as $idField => $idFieldValue) { @@ -1053,7 +1051,7 @@ private function executeInserts(ClassMetadata $class): void private function addToEntityIdentifiersAndEntityMap( ClassMetadata $class, int $oid, - object $entity + object $entity, ): void { $identifier = []; @@ -1129,7 +1127,7 @@ private function executeDeletions(ClassMetadata $class): void $this->entityDeletions[$oid], $this->entityIdentifiers[$oid], $this->originalEntityData[$oid], - $this->entityStates[$oid] + $this->entityStates[$oid], ); // Entity with this $oid after deletion treated as NEW, even if the $oid @@ -1425,7 +1423,7 @@ public function addToIdentityMap(object $entity): bool * * @psalm-return self::STATE_* */ - public function getEntityState(object $entity, ?int $assume = null): int + public function getEntityState(object $entity, int|null $assume = null): int { $oid = spl_object_id($entity); @@ -1535,7 +1533,7 @@ public function removeFromIdentityMap(object $entity): bool * * @ignore */ - public function getByIdHash(string $idHash, string $rootClassName): ?object + public function getByIdHash(string $idHash, string $rootClassName): object|null { return $this->identityMap[$rootClassName][$idHash]; } @@ -1648,7 +1646,7 @@ private function doPersist(object $entity, array &$visited): void throw new UnexpectedValueException(sprintf( 'Unexpected entity state: %s. %s', $entityState, - self::objToStr($entity) + self::objToStr($entity), )); } @@ -1716,7 +1714,7 @@ private function doRemove(object $entity, array &$visited): void throw new UnexpectedValueException(sprintf( 'Unexpected entity state: %s. %s', $entityState, - self::objToStr($entity) + self::objToStr($entity), )); } } @@ -1741,7 +1739,7 @@ public function detach(object $entity): void private function doDetach( object $entity, array &$visited, - bool $noCascade = false + bool $noCascade = false, ): void { $oid = spl_object_id($entity); @@ -1763,7 +1761,7 @@ private function doDetach( $this->entityDeletions[$oid], $this->entityIdentifiers[$oid], $this->entityStates[$oid], - $this->originalEntityData[$oid] + $this->originalEntityData[$oid], ); break; case self::STATE_NEW: @@ -1814,7 +1812,7 @@ private function doRefresh(object $entity, array &$visited): void $this->getEntityPersister($class->name)->refresh( array_combine($class->getIdentifierFieldNames(), $this->entityIdentifiers[$oid]), - $entity + $entity, ); $this->cascadeRefresh($entity, $visited); @@ -1931,7 +1929,7 @@ private function cascadePersist(object $entity, array &$visited): void throw ORMInvalidArgumentException::invalidAssociation( $this->em->getClassMetadata($assoc['targetEntity']), $assoc, - $relatedEntities + $relatedEntities, ); } @@ -1946,7 +1944,7 @@ private function cascadePersist(object $entity, array &$visited): void throw ORMInvalidArgumentException::invalidAssociation( $this->em->getClassMetadata($assoc['targetEntity']), $assoc, - $relatedEntities + $relatedEntities, ); } @@ -2059,7 +2057,7 @@ public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null $this->getEntityPersister($class->name)->lock( array_combine($class->getIdentifierFieldNames(), $this->entityIdentifiers[$oid]), - $lockMode + $lockMode, ); break; @@ -2251,7 +2249,7 @@ public function createEntity(string $className, array $data, array &$hints = []) 'doctrine/orm', 'https://github.com/doctrine/orm/issues/8471', 'Partial Objects are deprecated (here entity %s)', - $className + $className, ); return $entity; @@ -2468,7 +2466,7 @@ public function triggerEagerLoads(): void $class = $this->em->getClassMetadata($entityName); $this->getEntityPersister($entityName)->loadAll( - array_combine($class->identifier, [array_values($ids)]) + array_combine($class->identifier, [array_values($ids)]), ); } } @@ -2909,9 +2907,7 @@ private function isIdentifierEquals(object $entity1, object $entity2): bool return $id1 === $id2 || implode(' ', $id1) === implode(' ', $id2); } - /** - * @throws ORMInvalidArgumentException - */ + /** @throws ORMInvalidArgumentException */ private function assertThatThereAreNoUnintentionallyNonPersistedAssociations(): void { $entitiesNeedingCascadePersist = array_diff_key($this->nonCascadedNewDetectedEntities, $this->entityInsertions); @@ -2920,7 +2916,7 @@ private function assertThatThereAreNoUnintentionallyNonPersistedAssociations(): if ($entitiesNeedingCascadePersist) { throw ORMInvalidArgumentException::newEntitiesFoundThroughRelationships( - array_values($entitiesNeedingCascadePersist) + array_values($entitiesNeedingCascadePersist), ); } } @@ -2936,14 +2932,12 @@ public function hydrationComplete(): void $this->hydrationCompleteHandler->hydrationComplete(); } - /** - * @throws MappingException if the entity has more than a single identifier. - */ + /** @throws MappingException if the entity has more than a single identifier. */ private function convertSingleFieldIdentifierToPHPValue(ClassMetadata $class, mixed $identifierValue): mixed { return $this->em->getConnection()->convertToPHPValue( $identifierValue, - $class->getTypeOfField($class->getSingleIdentifierFieldName()) + $class->getTypeOfField($class->getSingleIdentifierFieldName()), ); } } diff --git a/lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php b/lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php index 1c7b4d50e6d..b682125d02e 100644 --- a/lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php +++ b/lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php @@ -7,9 +7,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\Mapping\ClassMetadata; -/** - * @internal This class exists only to avoid code duplication, do not reuse it externally - */ +/** @internal This class exists only to avoid code duplication, do not reuse it externally */ final class HierarchyDiscriminatorResolver { private function __construct() @@ -25,7 +23,7 @@ private function __construct() */ public static function resolveDiscriminatorsForClass( ClassMetadata $rootClassMetadata, - EntityManagerInterface $entityManager + EntityManagerInterface $entityManager, ): array { $hierarchyClasses = $rootClassMetadata->subClasses; $hierarchyClasses[] = $rootClassMetadata->name; diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index b573ae200d9..627f8daee8b 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -30,7 +30,7 @@ public function __construct( /** * The metadata factory, used to retrieve the ORM metadata of entity classes. */ - private readonly ClassMetadataFactory $metadataFactory + private readonly ClassMetadataFactory $metadataFactory, ) { } @@ -49,7 +49,7 @@ public function flattenIdentifier(ClassMetadata $class, array $id): array foreach ($class->identifier as $field) { if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_a($id[$field], $class->associationMappings[$field]['targetEntity'])) { $targetClassMetadata = $this->metadataFactory->getMetadataFor( - $class->associationMappings[$field]['targetEntity'] + $class->associationMappings[$field]['targetEntity'], ); assert($targetClassMetadata instanceof ClassMetadata); diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index 479ed9c1122..572d0c4b129 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -110,7 +110,7 @@ public static function getTypeOfColumn($columnName, ClassMetadata $class, Entity throw new RuntimeException(sprintf( 'Could not resolve type of column "%s" of class "%s"', $columnName, - $class->getName() + $class->getName(), )); } } diff --git a/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php b/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php index 1e042772932..a4c21687bd2 100644 --- a/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php +++ b/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php @@ -12,15 +12,13 @@ use function str_replace; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class UnitOfWorkComputeChangesBench { /** @var CmsUser[] */ - private ?array $users = null; + private array|null $users = null; - private ?UnitOfWork $unitOfWork = null; + private UnitOfWork|null $unitOfWork = null; public function init(): void { @@ -44,7 +42,7 @@ public function init(): void 'name' => $user->name, 'address' => $user->address, 'email' => $user->email, - ] + ], ); } diff --git a/tests/Doctrine/Performance/EntityManagerFactory.php b/tests/Doctrine/Performance/EntityManagerFactory.php index 3ea47ee3e9b..b9b283c435a 100644 --- a/tests/Doctrine/Performance/EntityManagerFactory.php +++ b/tests/Doctrine/Performance/EntityManagerFactory.php @@ -39,7 +39,7 @@ public static function getEntityManager(array $schemaClassNames): EntityManagerI 'driverClass' => Driver::class, 'memory' => true, ], - $config + $config, ); (new SchemaTool($entityManager)) @@ -65,7 +65,7 @@ public static function makeEntityManagerWithNoResultsConnection(): EntityManager $connection = new class ([], new Driver(), null, new EventManager()) extends Connection { /** {@inheritdoc} */ - public function executeQuery(string $sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null): Result + public function executeQuery(string $sql, array $params = [], $types = [], QueryCacheProfile|null $qcp = null): Result { return new Result(new ArrayResult([]), $this); } diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php index a9831d309dd..3c6b332dbd3 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php @@ -13,16 +13,14 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class MixedQueryFetchJoinArrayHydrationPerformanceBench { - private ?ArrayHydrator $hydrator = null; + private ArrayHydrator|null $hydrator = null; - private ?ResultSetMapping $rsm = null; + private ResultSetMapping|null $rsm = null; - private ?Result $result = null; + private Result|null $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php index 7ce3d2cdd4c..fad34c0521f 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php @@ -14,16 +14,14 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class MixedQueryFetchJoinFullObjectHydrationPerformanceBench { - private ?ObjectHydrator $hydrator = null; + private ObjectHydrator|null $hydrator = null; - private ?ResultSetMapping $rsm = null; + private ResultSetMapping|null $rsm = null; - private ?Result $result = null; + private Result|null $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php index 7cc9b5e0944..6a1638afcf5 100644 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php @@ -14,16 +14,14 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class MixedQueryFetchJoinPartialObjectHydrationPerformanceBench { - private ?ObjectHydrator $hydrator = null; + private ObjectHydrator|null $hydrator = null; - private ?ResultSetMapping $rsm = null; + private ResultSetMapping|null $rsm = null; - private ?Result $result = null; + private Result|null $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php b/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php index bb1be9dccce..ab08f886e2e 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php @@ -16,14 +16,12 @@ use Doctrine\Tests\Models\CMS\CmsTag; use Doctrine\Tests\Models\CMS\CmsUser; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class SimpleHydrationBench { - private ?EntityManagerInterface $entityManager = null; + private EntityManagerInterface|null $entityManager = null; - private ?EntityRepository $repository = null; + private EntityRepository|null $repository = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php index 51bed946873..fdc474d66f0 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php @@ -17,17 +17,15 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class SimpleInsertPerformanceBench { - private ?EntityManagerInterface $entityManager = null; + private EntityManagerInterface|null $entityManager = null; /** @var CMS\CmsUser[] */ - private ?array $users = null; + private array|null $users = null; - private ?string $tableName = null; + private string|null $tableName = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php index f6999e25333..c51bac44a6f 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php @@ -12,16 +12,14 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class SimpleQueryArrayHydrationPerformanceBench { - private ?ArrayHydrator $hydrator = null; + private ArrayHydrator|null $hydrator = null; - private ?ResultSetMapping $rsm = null; + private ResultSetMapping|null $rsm = null; - private ?Result $result = null; + private Result|null $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php index 7cfc9e38bae..3b158c30373 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php @@ -13,16 +13,14 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class SimpleQueryFullObjectHydrationPerformanceBench { - private ?ObjectHydrator $hydrator = null; + private ObjectHydrator|null $hydrator = null; - private ?ResultSetMapping $rsm = null; + private ResultSetMapping|null $rsm = null; - private ?Result $result = null; + private Result|null $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php index 819cca579c2..b894068eb2c 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php @@ -13,16 +13,14 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class SimpleQueryPartialObjectHydrationPerformanceBench { - private ?ObjectHydrator $hydrator = null; + private ObjectHydrator|null $hydrator = null; - private ?ResultSetMapping $rsm = null; + private ResultSetMapping|null $rsm = null; - private ?Result $result = null; + private Result|null $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php index 9d11c42388b..0ed9fda0892 100644 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php @@ -12,16 +12,14 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class SimpleQueryScalarHydrationPerformanceBench { - private ?ScalarHydrator $hydrator = null; + private ScalarHydrator|null $hydrator = null; - private ?ResultSetMapping $rsm = null; + private ResultSetMapping|null $rsm = null; - private ?Result $result = null; + private Result|null $result = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php index 757909979b1..4dc0e55c2fd 100644 --- a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php @@ -20,18 +20,16 @@ use Doctrine\Tests\Models\Company\CompanyRaffle; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class SingleTableInheritanceHydrationPerformanceBench { - private ?EntityRepository $contractsRepository = null; + private EntityRepository|null $contractsRepository = null; - private ?EntityRepository $fixContractsRepository = null; + private EntityRepository|null $fixContractsRepository = null; - private ?EntityRepository $flexContractRepository = null; + private EntityRepository|null $flexContractRepository = null; - private ?EntityRepository $ultraContractRepository = null; + private EntityRepository|null $ultraContractRepository = null; public function init(): void { diff --git a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php index cc86027e465..a9dac5224d8 100644 --- a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php +++ b/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php @@ -23,12 +23,10 @@ use function array_map; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class SingleTableInheritanceInsertPerformanceBench { - private ?EntityManagerInterface $entityManager = null; + private EntityManagerInterface|null $entityManager = null; /** @var Company\CompanyFixContract[] */ private array $fixContracts = []; diff --git a/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php b/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php index d8007af7a4c..a45a502fc1d 100644 --- a/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php +++ b/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php @@ -10,22 +10,20 @@ use Doctrine\Tests\Models\CMS\CmsEmployee; use Doctrine\Tests\Models\CMS\CmsUser; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class ProxyInitializationTimeBench { /** @var Proxy[] */ - private ?array $cmsUsers = null; + private array|null $cmsUsers = null; /** @var Proxy[] */ - private ?array $cmsEmployees = null; + private array|null $cmsEmployees = null; /** @var Proxy[] */ - private ?array $initializedUsers = null; + private array|null $initializedUsers = null; /** @var Proxy[] */ - private ?array $initializedEmployees = null; + private array|null $initializedEmployees = null; public function init(): void { diff --git a/tests/Doctrine/Performance/LazyLoading/ProxyInstantiationTimeBench.php b/tests/Doctrine/Performance/LazyLoading/ProxyInstantiationTimeBench.php index 7dde30f09ff..5bcdfb07393 100644 --- a/tests/Doctrine/Performance/LazyLoading/ProxyInstantiationTimeBench.php +++ b/tests/Doctrine/Performance/LazyLoading/ProxyInstantiationTimeBench.php @@ -10,9 +10,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class ProxyInstantiationTimeBench { /** @var AbstractProxyFactory */ diff --git a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php b/tests/Doctrine/Performance/Mock/NonLoadingPersister.php index b240f417166..8fb8b06dffa 100644 --- a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php +++ b/tests/Doctrine/Performance/Mock/NonLoadingPersister.php @@ -21,13 +21,13 @@ public function __construct() */ public function load( array $criteria, - ?object $entity = null, - ?array $assoc = null, + object|null $entity = null, + array|null $assoc = null, array $hints = [], LockMode|int|null $lockMode = null, - ?int $limit = null, - ?array $orderBy = null - ): ?object { + int|null $limit = null, + array|null $orderBy = null, + ): object|null { return $entity; } } diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 6e7a8745534..e98030e7782 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -40,7 +40,7 @@ public function getProxyFactory(): ProxyFactory $this, $config->getProxyDir(), $config->getProxyNamespace(), - $config->getAutoGenerateProxyClasses() + $config->getAutoGenerateProxyClasses(), ); } @@ -59,7 +59,7 @@ public function getUnitOfWork(): UnitOfWork return new NonProxyLoadingUnitOfWork(); } - public function getCache(): ?Cache + public function getCache(): Cache|null { return $this->realEntityManager->getCache(); } @@ -112,7 +112,7 @@ public function createQueryBuilder(): QueryBuilder /** * {@inheritDoc} */ - public function getReference(string $entityName, $id): ?object + public function getReference(string $entityName, $id): object|null { return $this->realEntityManager->getReference($entityName, $id); } @@ -120,7 +120,7 @@ public function getReference(string $entityName, $id): ?object /** * {@inheritDoc} */ - public function getPartialReference(string $entityName, $identifier): ?object + public function getPartialReference(string $entityName, $identifier): object|null { return $this->realEntityManager->getPartialReference($entityName, $identifier); } @@ -176,7 +176,7 @@ public function hasFilters(): bool return $this->realEntityManager->hasFilters(); } - public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, ?int $lockVersion = null): ?object + public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, int|null $lockVersion = null): object|null { return $this->realEntityManager->find($className, $id, $lockMode, $lockVersion); } diff --git a/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php b/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php index b67a5c045f0..8672ae62ca0 100644 --- a/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php +++ b/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php @@ -12,14 +12,12 @@ use function range; -/** - * @BeforeMethods({"init"}) - */ +/** @BeforeMethods({"init"}) */ final class QueryBoundParameterProcessingBench { - private ?Query $parsedQueryWithInferredParameterType = null; + private Query|null $parsedQueryWithInferredParameterType = null; - private ?Query $parsedQueryWithDeclaredParameterType = null; + private Query|null $parsedQueryWithDeclaredParameterType = null; public function init(): void { diff --git a/tests/Doctrine/StaticAnalysis/Mapping/class-metadata-constructor.php b/tests/Doctrine/StaticAnalysis/Mapping/class-metadata-constructor.php index 4050c7a9f91..0d5da396903 100644 --- a/tests/Doctrine/StaticAnalysis/Mapping/class-metadata-constructor.php +++ b/tests/Doctrine/StaticAnalysis/Mapping/class-metadata-constructor.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; -/** - * @template T of object - */ +/** @template T of object */ class MetadataGenerator { /** diff --git a/tests/Doctrine/StaticAnalysis/get-metadata.php b/tests/Doctrine/StaticAnalysis/get-metadata.php index 86e0cc92a16..1442efd4af6 100644 --- a/tests/Doctrine/StaticAnalysis/get-metadata.php +++ b/tests/Doctrine/StaticAnalysis/get-metadata.php @@ -15,9 +15,7 @@ */ abstract class GetMetadata { - /** - * @psalm-param class-string|object $class - */ + /** @psalm-param class-string|object $class */ abstract public function getEntityManager(string|object $class): EntityManagerInterface; /** diff --git a/tests/Doctrine/Tests/DbalExtensions/Connection.php b/tests/Doctrine/Tests/DbalExtensions/Connection.php index 3531398b159..7d9ec33e3f8 100644 --- a/tests/Doctrine/Tests/DbalExtensions/Connection.php +++ b/tests/Doctrine/Tests/DbalExtensions/Connection.php @@ -14,7 +14,7 @@ class Connection extends BaseConnection { public QueryLog $queryLog; - public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null) + public function __construct(array $params, Driver $driver, Configuration|null $config = null, EventManager|null $eventManager = null) { $this->queryLog = new QueryLog(); $logging = new LoggingMiddleware(new SqlLogger($this->queryLog)); diff --git a/tests/Doctrine/Tests/DbalExtensions/QueryLog.php b/tests/Doctrine/Tests/DbalExtensions/QueryLog.php index 7b1f23bc379..ca46b2fd113 100644 --- a/tests/Doctrine/Tests/DbalExtensions/QueryLog.php +++ b/tests/Doctrine/Tests/DbalExtensions/QueryLog.php @@ -11,7 +11,7 @@ final class QueryLog private bool $enabled = false; - public function logQuery(string $sql, ?array $params = null, ?array $types = null): void + public function logQuery(string $sql, array|null $params = null, array|null $types = null): void { if (! $this->enabled) { return; @@ -24,9 +24,7 @@ public function logQuery(string $sql, ?array $params = null, ?array $types = nul ]; } - /** - * @return $this - */ + /** @return $this */ public function reset(): self { $this->enabled = false; @@ -35,9 +33,7 @@ public function reset(): self return $this; } - /** - * @return $this - */ + /** @return $this */ public function enable(): self { $this->enabled = true; @@ -45,9 +41,7 @@ public function enable(): self return $this; } - /** - * @return $this - */ + /** @return $this */ public function disable(): self { $this->enabled = false; diff --git a/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php b/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php index 6192ac7ae00..2bde7406004 100644 --- a/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php +++ b/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php @@ -21,7 +21,7 @@ public function log($level, $message, array $context = []): void $this->queryLog->logQuery( $context['sql'], $context['params'] ?? null, - $context['types'] ?? null + $context['types'] ?? null, ); } } diff --git a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php index c364fd7d838..61a5477b622 100644 --- a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php +++ b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php @@ -20,7 +20,7 @@ class Rot13Type extends Type * * @param string|null $value */ - public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + public function convertToDatabaseValue($value, AbstractPlatform $platform): string|null { if ($value === null) { return null; @@ -34,7 +34,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str * * @param string|null $value */ - public function convertToPHPValue($value, AbstractPlatform $platform): ?string + public function convertToPHPValue($value, AbstractPlatform $platform): string|null { if ($value === null) { return null; diff --git a/tests/Doctrine/Tests/DoctrineTestCase.php b/tests/Doctrine/Tests/DoctrineTestCase.php index 4fdf5d65c7d..28db9f96faf 100644 --- a/tests/Doctrine/Tests/DoctrineTestCase.php +++ b/tests/Doctrine/Tests/DoctrineTestCase.php @@ -23,9 +23,7 @@ abstract class DoctrineTestCase extends TestCase 'assertFileDoesNotExist' => 'assertFileNotExists', // can be removed PHPUnit 9 is minimum ]; - /** - * @param array $arguments - */ + /** @param array $arguments */ public static function __callStatic(string $method, array $arguments): mixed { if (isset(self::$phpunitMethodRenames[$method])) { @@ -37,9 +35,7 @@ public static function __callStatic(string $method, array $arguments): mixed throw new BadMethodCallException(sprintf('%s::%s does not exist', static::class, $method)); } - /** - * @param array $arguments - */ + /** @param array $arguments */ public function __call(string $method, array $arguments): mixed { if ($method === 'createStub') { diff --git a/tests/Doctrine/Tests/Mocks/CacheKeyMock.php b/tests/Doctrine/Tests/Mocks/CacheKeyMock.php index c36dacd7a51..aa4bf505dbc 100644 --- a/tests/Doctrine/Tests/Mocks/CacheKeyMock.php +++ b/tests/Doctrine/Tests/Mocks/CacheKeyMock.php @@ -13,9 +13,7 @@ */ class CacheKeyMock extends CacheKey { - /** - * @param string $hash The string hash that represend this cache key - */ + /** @param string $hash The string hash that represend this cache key */ public function __construct(string $hash) { $this->hash = $hash; diff --git a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php index 9bcad7eb09f..a6968bff2f5 100644 --- a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/CacheRegionMock.php @@ -73,24 +73,21 @@ public function evictAll(): bool return $this->getReturn(__FUNCTION__, true); } - public function get(CacheKey $key): ?CacheEntry + public function get(CacheKey $key): CacheEntry|null { $this->calls[__FUNCTION__][] = ['key' => $key]; return $this->getReturn(__FUNCTION__, null); } - /** - * {@inheritdoc} - */ - public function getMultiple(CollectionCacheEntry $collection): ?array + public function getMultiple(CollectionCacheEntry $collection): array|null { $this->calls[__FUNCTION__][] = ['collection' => $collection]; return $this->getReturn(__FUNCTION__, null); } - public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null): bool + public function put(CacheKey $key, CacheEntry $entry, Lock|null $lock = null): bool { $this->calls[__FUNCTION__][] = ['key' => $key, 'entry' => $entry]; diff --git a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php b/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php index 6babfa94b17..a1e9ac43659 100644 --- a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php @@ -32,7 +32,7 @@ class ConcurrentRegionMock implements ConcurrentRegion public array $locks = []; public function __construct( - private readonly Region $region + private readonly Region $region, ) { } @@ -97,7 +97,7 @@ public function evictAll(): bool return $this->region->evictAll(); } - public function get(CacheKey $key): ?CacheEntry + public function get(CacheKey $key): CacheEntry|null { $this->calls[__FUNCTION__][] = ['key' => $key]; @@ -110,10 +110,7 @@ public function get(CacheKey $key): ?CacheEntry return $this->region->get($key); } - /** - * {@inheritdoc} - */ - public function getMultiple(CollectionCacheEntry $collection): ?array + public function getMultiple(CollectionCacheEntry $collection): array|null { $this->calls[__FUNCTION__][] = ['collection' => $collection]; @@ -131,7 +128,7 @@ public function getName(): string return $this->region->getName(); } - public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null): bool + public function put(CacheKey $key, CacheEntry $entry, Lock|null $lock = null): bool { $this->calls[__FUNCTION__][] = ['key' => $key, 'entry' => $entry]; @@ -148,7 +145,7 @@ public function put(CacheKey $key, CacheEntry $entry, ?Lock $lock = null): bool return $this->region->put($key, $entry); } - public function lock(CacheKey $key): ?Lock + public function lock(CacheKey $key): Lock|null { $this->calls[__FUNCTION__][] = ['key' => $key]; diff --git a/tests/Doctrine/Tests/Mocks/CustomTreeWalkerJoin.php b/tests/Doctrine/Tests/Mocks/CustomTreeWalkerJoin.php index e15d332a479..94addb649c8 100644 --- a/tests/Doctrine/Tests/Mocks/CustomTreeWalkerJoin.php +++ b/tests/Doctrine/Tests/Mocks/CustomTreeWalkerJoin.php @@ -53,7 +53,7 @@ private function modifySelectStatement(SelectStatement $selectStatement, Identif 'map' => null, 'nestingLevel' => 0, 'token' => null, - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php index d1c1493b799..7a96b78d6e9 100644 --- a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php @@ -16,8 +16,8 @@ */ class EntityManagerMock extends EntityManager { - private ?UnitOfWork $_uowMock = null; - private ?ProxyFactory $_proxyFactoryMock = null; + private UnitOfWork|null $_uowMock = null; + private ProxyFactory|null $_proxyFactoryMock = null; public function getUnitOfWork(): UnitOfWork { @@ -49,7 +49,7 @@ public function getProxyFactory(): ProxyFactory * * {@inheritdoc} */ - public static function create($conn, ?Configuration $config = null, ?EventManager $eventManager = null): self + public static function create($conn, Configuration|null $config = null, EventManager|null $eventManager = null): self { if ($config === null) { $config = new Configuration(); diff --git a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php index a4383f2936b..95dfc9c94b0 100644 --- a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php @@ -17,7 +17,7 @@ class EntityPersisterMock extends BasicEntityPersister private array $updates = []; private array $deletes = []; private int $identityColumnValueCounter = 0; - private ?int $mockIdGeneratorType = null; + private int|null $mockIdGeneratorType = null; /** @psalm-var list */ private array $postInsertIds = []; @@ -38,9 +38,7 @@ public function addInsert(object $entity): void ]; } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function executeInserts(): array { return $this->postInsertIds; @@ -56,7 +54,7 @@ public function update(object $entity): void $this->updates[] = $entity; } - public function exists(object $entity, ?Criteria $extraConditions = null): bool + public function exists(object $entity, Criteria|null $extraConditions = null): bool { $this->existsCalled = true; diff --git a/tests/Doctrine/Tests/Mocks/ExceptionConverterMock.php b/tests/Doctrine/Tests/Mocks/ExceptionConverterMock.php index 6bd69e97fcf..d6e91402f4f 100644 --- a/tests/Doctrine/Tests/Mocks/ExceptionConverterMock.php +++ b/tests/Doctrine/Tests/Mocks/ExceptionConverterMock.php @@ -11,7 +11,7 @@ class ExceptionConverterMock implements ExceptionConverter { - public function convert(Exception $exception, ?Query $query): DriverException + public function convert(Exception $exception, Query|null $query): DriverException { return new DriverException($exception, $query); } diff --git a/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php b/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php index 8381e7cc3a0..330dd0e2ce0 100644 --- a/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php +++ b/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php @@ -16,7 +16,7 @@ class UnitOfWorkMock extends UnitOfWork { private array $mockDataChangeSets = []; - private ?array $persisterMock = null; + private array|null $persisterMock = null; public function getEntityPersister(string $entityName): EntityPersister { diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index 6abb9cc76f9..c66744501a5 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -141,7 +141,7 @@ public function setUser(CmsUser $user): void public static function loadMetadata(ClassMetadata $metadata): void { $metadata->setPrimaryTable( - ['name' => 'company_person'] + ['name' => 'company_person'], ); $metadata->mapField( @@ -149,21 +149,21 @@ public static function loadMetadata(ClassMetadata $metadata): void 'id' => true, 'fieldName' => 'id', 'type' => 'integer', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'zip', 'length' => 50, - ] + ], ); $metadata->mapField( [ 'fieldName' => 'city', 'length' => 50, - ] + ], ); $metadata->mapOneToOne( @@ -171,7 +171,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'user', 'targetEntity' => 'CmsUser', 'joinColumns' => [['referencedColumnName' => 'id']], - ] + ], ); $metadata->addSqlResultSetMapping( @@ -197,7 +197,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'entityClass' => self::class, ], ], - ] + ], ); $metadata->addSqlResultSetMapping( @@ -210,7 +210,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fields' => [], ], ], - ] + ], ); $metadata->addSqlResultSetMapping( @@ -219,7 +219,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'columns' => [ ['name' => 'count'], ], - ] + ], ); $metadata->addEntityListener(Events::postPersist, 'CmsAddressListener', 'postPersist'); diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php b/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php index f8c45522ac5..cfe1579aaf9 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php @@ -6,7 +6,7 @@ class CmsAddressDTO { - public function __construct(public ?string $country = null, public ?string $city = null, public ?string $zip = null) + public function __construct(public string|null $country = null, public string|null $city = null, public string|null $zip = null) { } } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php b/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php index fb4ad4e0042..8601504bc6c 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php @@ -46,7 +46,7 @@ public function getName(): string return $this->name; } - public function getSpouse(): ?CmsEmployee + public function getSpouse(): CmsEmployee|null { return $this->spouse; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php index fda1d9aefee..d7e284f499c 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php @@ -62,17 +62,13 @@ public function addUser(CmsUser $user): void $this->users[] = $user; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getUsers(): Collection { return $this->users; } - /** - * @return Collection - */ + /** @return Collection */ public function getIterator(): Collection { return $this->getUsers(); diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php b/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php index 5ffc16ba55e..761328753b4 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php @@ -36,7 +36,7 @@ public function setUser(CmsUser $user): void $this->user = $user; } - public function getUser(): ?CmsUser + public function getUser(): CmsUser|null { return $this->user; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsTag.php b/tests/Doctrine/Tests/Models/CMS/CmsTag.php index b6afb4a1434..aa0325dafda 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsTag.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsTag.php @@ -55,9 +55,7 @@ public function addUser(CmsUser $user): void $this->users[] = $user; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getUsers(): Collection { return $this->users; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Doctrine/Tests/Models/CMS/CmsUser.php index bd2276915cc..f6eade91bcc 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -202,7 +202,7 @@ public function getUsername(): string return $this->username; } - public function getName(): ?string + public function getName(): string|null { return $this->name; } @@ -216,9 +216,7 @@ public function addPhonenumber(CmsPhonenumber $phone): void $phone->setUser($this); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getPhonenumbers(): Collection { return $this->phonenumbers; @@ -236,9 +234,7 @@ public function addGroup(CmsGroup $group): void $group->addUser($this); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getGroups(): Collection { return $this->groups; @@ -281,12 +277,12 @@ public function setAddress(CmsAddress $address): void } } - public function getEmail(): ?CmsEmail + public function getEmail(): CmsEmail|null { return $this->email; } - public function setEmail(?CmsEmail $email = null): void + public function setEmail(CmsEmail|null $email = null): void { if ($this->email !== $email) { $this->email = $email; @@ -300,7 +296,7 @@ public function setEmail(?CmsEmail $email = null): void public static function loadMetadata(ClassMetadata $metadata): void { $metadata->setPrimaryTable( - ['name' => 'cms_users'] + ['name' => 'cms_users'], ); $metadata->addSqlResultSetMapping( @@ -343,7 +339,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'discriminatorColumn' => null, ], ], - ] + ], ); $metadata->addSqlResultSetMapping( @@ -374,7 +370,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'discriminatorColumn' => null, ], ], - ] + ], ); $metadata->addSqlResultSetMapping( @@ -404,7 +400,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'columns' => [ ['name' => 'numphones'], ], - ] + ], ); $metadata->addSqlResultSetMapping( @@ -451,7 +447,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'columns' => [ ['name' => 'numphones'], ], - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php b/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php index 341a6bb70c1..36b639aeb73 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php @@ -6,7 +6,7 @@ class CmsUserDTO { - public function __construct(public ?string $name = null, public ?string $email = null, public ?string $address = null, public ?int $phonenumbers = null) + public function __construct(public string|null $name = null, public string|null $email = null, public string|null $address = null, public int|null $phonenumbers = null) { } } diff --git a/tests/Doctrine/Tests/Models/Cache/Action.php b/tests/Doctrine/Tests/Models/Cache/Action.php index 81c0e724cf5..3d66a46e0c9 100644 --- a/tests/Doctrine/Tests/Models/Cache/Action.php +++ b/tests/Doctrine/Tests/Models/Cache/Action.php @@ -31,7 +31,7 @@ public function __construct( * @Column(type="string", length=255) * @GeneratedValue(strategy="NONE") */ - public string $name + public string $name, ) { $this->tokens = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Address.php b/tests/Doctrine/Tests/Models/Cache/Address.php index beabc0c9c18..2f7457d893e 100644 --- a/tests/Doctrine/Tests/Models/Cache/Address.php +++ b/tests/Doctrine/Tests/Models/Cache/Address.php @@ -34,10 +34,8 @@ class Address public $person; public function __construct( - /** - * @Column - */ - public string $location + /** @Column */ + public string $location, ) { } } diff --git a/tests/Doctrine/Tests/Models/Cache/Attraction.php b/tests/Doctrine/Tests/Models/Cache/Attraction.php index 1968cbac550..06e208c5627 100644 --- a/tests/Doctrine/Tests/Models/Cache/Attraction.php +++ b/tests/Doctrine/Tests/Models/Cache/Attraction.php @@ -47,16 +47,14 @@ abstract class Attraction protected $infos; public function __construct( - /** - * @Column(unique=true) - */ + /** @Column(unique=true) */ protected string $name, /** * @Cache * @ManyToOne(targetEntity="City", inversedBy="attractions") * @JoinColumn(name="city_id", referencedColumnName="id") */ - protected City $city + protected City $city, ) { $this->infos = new ArrayCollection(); } @@ -91,9 +89,7 @@ public function setCity(City $city): void $this->city = $city; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getInfos(): Collection { return $this->infos; diff --git a/tests/Doctrine/Tests/Models/Cache/Bar.php b/tests/Doctrine/Tests/Models/Cache/Bar.php index 53c4fa03403..e937370b609 100644 --- a/tests/Doctrine/Tests/Models/Cache/Bar.php +++ b/tests/Doctrine/Tests/Models/Cache/Bar.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class Bar extends Attraction { } diff --git a/tests/Doctrine/Tests/Models/Cache/Beach.php b/tests/Doctrine/Tests/Models/Cache/Beach.php index 26d5838e519..65fdad68827 100644 --- a/tests/Doctrine/Tests/Models/Cache/Beach.php +++ b/tests/Doctrine/Tests/Models/Cache/Beach.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class Beach extends Attraction { } diff --git a/tests/Doctrine/Tests/Models/Cache/City.php b/tests/Doctrine/Tests/Models/Cache/City.php index c10414fda23..90e2cbb55ce 100644 --- a/tests/Doctrine/Tests/Models/Cache/City.php +++ b/tests/Doctrine/Tests/Models/Cache/City.php @@ -55,16 +55,14 @@ class City public $attractions; public function __construct( - /** - * @Column(unique=true) - */ + /** @Column(unique=true) */ #[ORM\Column(unique: true)] protected string $name, /** * @Cache * @ManyToOne(targetEntity="State", inversedBy="cities") * @JoinColumn(name="state_id", referencedColumnName="id") */ - #[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'citities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] protected ?State $state = null + #[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'citities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] protected State|null $state = null, ) { $this->travels = new ArrayCollection(); $this->attractions = new ArrayCollection(); @@ -90,7 +88,7 @@ public function setName(string $name): void $this->name = $name; } - public function getState(): ?State + public function getState(): State|null { return $this->state; } @@ -105,9 +103,7 @@ public function addTravel(Travel $travel): void $this->travels[] = $travel; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getTravels(): Collection { return $this->travels; @@ -118,9 +114,7 @@ public function addAttraction(Attraction $attraction): void $this->attractions[] = $attraction; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getAttractions(): Collection { return $this->attractions; @@ -136,7 +130,7 @@ public static function loadMetadata(ClassMetadata $metadata): void $metadata->enableCache( [ 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, - ] + ], ); $metadata->mapField( @@ -144,14 +138,14 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'id', 'type' => 'integer', 'id' => true, - ] + ], ); $metadata->mapField( [ 'fieldName' => 'name', 'type' => 'string', - ] + ], ); $metadata->mapOneToOne( @@ -166,7 +160,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'referencedColumnName' => 'id', ], ], - ] + ], ); $metadata->enableAssociationCache('state', [ 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, @@ -177,7 +171,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'travels', 'targetEntity' => Travel::class, 'mappedBy' => 'visitedCities', - ] + ], ); $metadata->mapOneToMany( @@ -186,7 +180,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'targetEntity' => Attraction::class, 'mappedBy' => 'city', 'orderBy' => ['name' => 'ASC'], - ] + ], ); $metadata->enableAssociationCache('attractions', [ 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, diff --git a/tests/Doctrine/Tests/Models/Cache/Client.php b/tests/Doctrine/Tests/Models/Cache/Client.php index 7b77968e228..a0b2ee1d213 100644 --- a/tests/Doctrine/Tests/Models/Cache/Client.php +++ b/tests/Doctrine/Tests/Models/Cache/Client.php @@ -25,10 +25,8 @@ class Client public $id; public function __construct( - /** - * @Column(unique=true) - */ - public string $name + /** @Column(unique=true) */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php index 35421217758..0a18e4b2fa9 100644 --- a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php +++ b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php @@ -28,23 +28,19 @@ class ComplexAction public function __construct( /** - * @var Action * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) * @JoinColumn(name="action1_name", referencedColumnName="name") */ - public $action1, + public Action $action1, /** - * @var Action * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) * @JoinColumn(name="action2_name", referencedColumnName="name") */ - public $action2, - /** - * @Column - */ - public string $name + public Action $action2, + /** @Column */ + public string $name, ) { $this->tokens = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Country.php b/tests/Doctrine/Tests/Models/Cache/Country.php index a54fd13b1d8..d8fff573bef 100644 --- a/tests/Doctrine/Tests/Models/Cache/Country.php +++ b/tests/Doctrine/Tests/Models/Cache/Country.php @@ -27,10 +27,8 @@ class Country protected $id; public function __construct( - /** - * @Column(unique=true) - */ - protected string $name + /** @Column(unique=true) */ + protected string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/Flight.php b/tests/Doctrine/Tests/Models/Cache/Flight.php index 7e65a80595f..b24c408deee 100644 --- a/tests/Doctrine/Tests/Models/Cache/Flight.php +++ b/tests/Doctrine/Tests/Models/Cache/Flight.php @@ -40,7 +40,7 @@ public function __construct( * @ManyToOne(targetEntity="City") * @JoinColumn(name="going_to_city_id", referencedColumnName="id") */ - protected City $goingTo + protected City $goingTo, ) { $this->departure = new DateTime(); } diff --git a/tests/Doctrine/Tests/Models/Cache/Login.php b/tests/Doctrine/Tests/Models/Cache/Login.php index 1971cad1710..cee0fa19363 100644 --- a/tests/Doctrine/Tests/Models/Cache/Login.php +++ b/tests/Doctrine/Tests/Models/Cache/Login.php @@ -34,10 +34,8 @@ class Login public $token; public function __construct( - /** - * @Column - */ - public string $name + /** @Column */ + public string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/Person.php b/tests/Doctrine/Tests/Models/Cache/Person.php index ee1f62f5e14..c30bd1140c0 100644 --- a/tests/Doctrine/Tests/Models/Cache/Person.php +++ b/tests/Doctrine/Tests/Models/Cache/Person.php @@ -34,10 +34,8 @@ class Person public $address; public function __construct( - /** - * @Column(unique=true) - */ - public string $name + /** @Column(unique=true) */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/Models/Cache/Restaurant.php b/tests/Doctrine/Tests/Models/Cache/Restaurant.php index 8ad5c3f132c..595b7e10de3 100644 --- a/tests/Doctrine/Tests/Models/Cache/Restaurant.php +++ b/tests/Doctrine/Tests/Models/Cache/Restaurant.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class Restaurant extends Attraction { } diff --git a/tests/Doctrine/Tests/Models/Cache/State.php b/tests/Doctrine/Tests/Models/Cache/State.php index 5046caf1dd8..d3f093be1fd 100644 --- a/tests/Doctrine/Tests/Models/Cache/State.php +++ b/tests/Doctrine/Tests/Models/Cache/State.php @@ -39,16 +39,14 @@ class State protected $cities; public function __construct( - /** - * @Column(unique=true) - */ + /** @Column(unique=true) */ protected string $name, /** * @Cache * @ManyToOne(targetEntity="Country") * @JoinColumn(name="country_id", referencedColumnName="id") */ - protected ?Country $country = null + protected Country|null $country = null, ) { $this->cities = new ArrayCollection(); } @@ -73,7 +71,7 @@ public function setName(string $name): void $this->name = $name; } - public function getCountry(): ?Country + public function getCountry(): Country|null { return $this->country; } @@ -83,17 +81,13 @@ public function setCountry(Country $country): void $this->country = $country; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getCities(): Collection { return $this->cities; } - /** - * @psalm-param Collection $cities - */ + /** @psalm-param Collection $cities */ public function setCities(Collection $cities): void { $this->cities = $cities; diff --git a/tests/Doctrine/Tests/Models/Cache/Token.php b/tests/Doctrine/Tests/Models/Cache/Token.php index 3e591609e84..d6327011089 100644 --- a/tests/Doctrine/Tests/Models/Cache/Token.php +++ b/tests/Doctrine/Tests/Models/Cache/Token.php @@ -63,10 +63,8 @@ public function __construct( * @Column(type="string", length=255) */ public string $token, - /** - * @OneToOne(targetEntity="Client") - */ - public ?Client $client = null + /** @OneToOne(targetEntity="Client") */ + public Client|null $client = null, ) { $this->logins = new ArrayCollection(); $this->expiresAt = new DateTime(date('Y-m-d H:i:s', strtotime('+7 day'))); @@ -78,7 +76,7 @@ public function addLogin(Login $login): void $login->token = $this; } - public function getClient(): ?Client + public function getClient(): Client|null { return $this->client; } diff --git a/tests/Doctrine/Tests/Models/Cache/Travel.php b/tests/Doctrine/Tests/Models/Cache/Travel.php index f044f9783b0..545f71d4bf5 100644 --- a/tests/Doctrine/Tests/Models/Cache/Travel.php +++ b/tests/Doctrine/Tests/Models/Cache/Travel.php @@ -60,7 +60,7 @@ public function __construct( * @ManyToOne(targetEntity="Traveler", inversedBy="travels") * @JoinColumn(name="traveler_id", referencedColumnName="id") */ - protected Traveler $traveler + protected Traveler $traveler, ) { $this->createdAt = new DateTime('now'); $this->visitedCities = new ArrayCollection(); @@ -81,9 +81,7 @@ public function setTraveler(Traveler $traveler): void $this->traveler = $traveler; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getVisitedCities(): Collection { return $this->visitedCities; diff --git a/tests/Doctrine/Tests/Models/Cache/Traveler.php b/tests/Doctrine/Tests/Models/Cache/Traveler.php index 005678908e9..e23d3d6632b 100644 --- a/tests/Doctrine/Tests/Models/Cache/Traveler.php +++ b/tests/Doctrine/Tests/Models/Cache/Traveler.php @@ -45,10 +45,8 @@ class Traveler protected $profile; public function __construct( - /** - * @Column - */ - protected string $name + /** @Column */ + protected string $name, ) { $this->travels = new ArrayCollection(); } @@ -83,9 +81,7 @@ public function setProfile(TravelerProfile $profile): void $this->profile = $profile; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getTravels(): Collection { return $this->travels; diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php index 95319ee6768..d27c61a4985 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php @@ -31,13 +31,11 @@ class TravelerProfile * @OneToOne(targetEntity="TravelerProfileInfo", mappedBy="profile") * @Cache() */ - private ?TravelerProfileInfo $info = null; + private TravelerProfileInfo|null $info = null; public function __construct( - /** - * @Column(unique=true) - */ - private string $name + /** @Column(unique=true) */ + private string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php index 24d49544221..909426b63c7 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php @@ -35,10 +35,8 @@ public function __construct( * @OneToOne(targetEntity="TravelerProfile", inversedBy="info") */ private TravelerProfile $profile, - /** - * @Column(unique=true) - */ - private string $description + /** @Column(unique=true) */ + private string $description, ) { } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php b/tests/Doctrine/Tests/Models/Company/CompanyAuction.php index adcc239a3f0..27a0d3dba6f 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyAuction.php @@ -15,7 +15,7 @@ class CompanyAuction extends CompanyEvent { /** @Column(type="string", length=255) */ - private ?string $data = null; + private string|null $data = null; public function setData(string $data): void { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyCar.php b/tests/Doctrine/Tests/Models/Company/CompanyCar.php index 7afaffed77b..0fc723fc6fc 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyCar.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyCar.php @@ -24,10 +24,8 @@ class CompanyCar private int $id; public function __construct( - /** - * @Column(type="string", length=50) - */ - private ?string $brand = null + /** @Column(type="string", length=50) */ + private string|null $brand = null, ) { } @@ -36,7 +34,7 @@ public function getId(): int return $this->id; } - public function getBrand(): ?string + public function getBrand(): string|null { return $this->brand; } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index 19e1373b632..c210e30ee2b 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -83,7 +83,7 @@ abstract class CompanyContract private int $id; /** @ManyToOne(targetEntity="CompanyEmployee", inversedBy="soldContracts") */ - private ?CompanyEmployee $salesPerson = null; + private CompanyEmployee|null $salesPerson = null; /** @Column(type="boolean") */ private bool $completed = false; @@ -128,9 +128,7 @@ public function setSalesPerson(CompanyEmployee $salesPerson): void $this->salesPerson = $salesPerson; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getEngineers(): Collection { return $this->engineers; @@ -156,7 +154,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'name' => 'discr', 'type' => 'string', - ] + ], ); $metadata->mapField( @@ -164,7 +162,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'id' => true, 'name' => 'id', 'fieldName' => 'id', - ] + ], ); $metadata->mapField( @@ -172,7 +170,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'boolean', 'name' => 'completed', 'fieldName' => 'completed', - ] + ], ); $metadata->setDiscriminatorMap( @@ -180,7 +178,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fix' => 'CompanyFixContract', 'flexible' => 'CompanyFlexContract', 'flexultra' => 'CompanyFlexUltraContract', - ] + ], ); $metadata->addEntityListener(Events::postPersist, 'CompanyContractListener', 'postPersistHandler'); diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php b/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php index f87882639d2..26b4dc67bec 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php @@ -42,72 +42,56 @@ class CompanyContractListener /** @psalm-var list> */ public $postLoadCalls; - /** - * @PostPersist - */ + /** @PostPersist */ #[ORM\PostPersist] public function postPersistHandler(CompanyContract $contract): void { $this->postPersistCalls[] = func_get_args(); } - /** - * @PrePersist - */ + /** @PrePersist */ #[ORM\PrePersist] public function prePersistHandler(CompanyContract $contract): void { $this->prePersistCalls[] = func_get_args(); } - /** - * @PostUpdate - */ + /** @PostUpdate */ #[ORM\PostUpdate] public function postUpdateHandler(CompanyContract $contract): void { $this->postUpdateCalls[] = func_get_args(); } - /** - * @PreUpdate - */ + /** @PreUpdate */ #[ORM\PreUpdate] public function preUpdateHandler(CompanyContract $contract): void { $this->preUpdateCalls[] = func_get_args(); } - /** - * @PostRemove - */ + /** @PostRemove */ #[ORM\PostRemove] public function postRemoveHandler(CompanyContract $contract): void { $this->postRemoveCalls[] = func_get_args(); } - /** - * @PreRemove - */ + /** @PreRemove */ #[ORM\PreRemove] public function preRemoveHandler(CompanyContract $contract): void { $this->preRemoveCalls[] = func_get_args(); } - /** - * @PreFlush - */ + /** @PreFlush */ #[ORM\PreFlush] public function preFlushHandler(CompanyContract $contract): void { $this->preFlushCalls[] = func_get_args(); } - /** - * @PostLoad - */ + /** @PostLoad */ #[ORM\PostLoad] public function postLoadHandler(CompanyContract $contract): void { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php index ae1298c4e6e..47281312687 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php @@ -19,13 +19,13 @@ class CompanyEmployee extends CompanyPerson { /** @Column(type="integer") */ - private ?int $salary = null; + private int|null $salary = null; /** @Column(type="string", length=255) */ - private ?string $department = null; + private string|null $department = null; /** @Column(type="datetime", nullable=true) */ - private ?DateTime $startDate = null; + private DateTime|null $startDate = null; /** * @psalm-var Collection @@ -59,7 +59,7 @@ public function setDepartment(string $dep): void $this->department = $dep; } - public function getStartDate(): ?DateTime + public function getStartDate(): DateTime|null { return $this->startDate; } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php b/tests/Doctrine/Tests/Models/Company/CompanyEvent.php index 41197283c26..378c3a94d4f 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEvent.php @@ -35,7 +35,7 @@ abstract class CompanyEvent * @ManyToOne(targetEntity="CompanyOrganization", inversedBy="events", cascade={"persist"}) * @JoinColumn(name="org_id", referencedColumnName="id") */ - private ?CompanyOrganization $organization = null; + private CompanyOrganization|null $organization = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php index 697bfda3539..34addb2d834 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ #[ORM\Entity] class CompanyFixContract extends CompanyContract { @@ -40,7 +38,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'integer', 'name' => 'fixPrice', 'fieldName' => 'fixPrice', - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index 056959df1e5..605451ba83e 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -102,9 +102,7 @@ public function setPricePerHour(int $pricePerHour): void $this->pricePerHour = $pricePerHour; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getManagers(): Collection { return $this->managers; @@ -127,7 +125,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'integer', 'name' => 'hoursWorked', 'fieldName' => 'hoursWorked', - ] + ], ); $metadata->mapField( @@ -135,7 +133,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'integer', 'name' => 'pricePerHour', 'fieldName' => 'pricePerHour', - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php index cdd5d0e5028..ae480953f9f 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -46,7 +46,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'integer', 'name' => 'maxPrice', 'fieldName' => 'maxPrice', - ] + ], ); $metadata->addEntityListener(Events::postPersist, 'CompanyContractListener', 'postPersistHandler'); $metadata->addEntityListener(Events::prePersist, 'CompanyContractListener', 'prePersistHandler'); diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php index e794b9d2505..89277e7c43e 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php @@ -15,18 +15,14 @@ class CompanyFlexUltraContractListener /** @psalm-var list */ public $prePersistCalls; - /** - * @PrePersist - */ + /** @PrePersist */ #[ORM\PrePersist] public function prePersistHandler1(CompanyContract $contract, LifecycleEventArgs $args): void { $this->prePersistCalls[] = func_get_args(); } - /** - * @PrePersist - */ + /** @PrePersist */ #[ORM\PrePersist] public function prePersistHandler2(CompanyContract $contract, LifecycleEventArgs $args): void { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/tests/Doctrine/Tests/Models/Company/CompanyManager.php index 40534fb6430..642ee25c598 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyManager.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyManager.php @@ -19,13 +19,13 @@ class CompanyManager extends CompanyEmployee { /** @Column(type="string", length=250) */ - private ?string $title = null; + private string|null $title = null; /** * @OneToOne(targetEntity="CompanyCar", cascade={"persist"}) * @JoinColumn(name="car_id", referencedColumnName="id") */ - private ?CompanyCar $car = null; + private CompanyCar|null $car = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php b/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php index dcf24ea2497..a5c0870bfa8 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php @@ -38,9 +38,7 @@ public function getId(): int return $this->id; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getEvents(): Collection { return $this->events; @@ -56,9 +54,9 @@ public function addEvent(CompanyEvent $event): void * @OneToOne(targetEntity="CompanyEvent", cascade={"persist"}) * @JoinColumn(name="main_event_id", referencedColumnName="id", nullable=true) */ - private ?CompanyEvent $mainevent = null; + private CompanyEvent|null $mainevent = null; - public function getMainEvent(): ?CompanyEvent + public function getMainEvent(): CompanyEvent|null { return $this->mainevent; } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php index 82156845878..74277c48fa7 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php @@ -62,13 +62,13 @@ class CompanyPerson private int $id; /** @Column */ - private ?string $name = null; + private string|null $name = null; /** * @OneToOne(targetEntity="CompanyPerson") * @JoinColumn(name="spouse_id", referencedColumnName="id", onDelete="CASCADE") */ - private ?CompanyPerson $spouse = null; + private CompanyPerson|null $spouse = null; /** * @psalm-var Collection @@ -105,14 +105,12 @@ public function setName(string $name): void $this->name = $name; } - public function getSpouse(): ?CompanyPerson + public function getSpouse(): CompanyPerson|null { return $this->spouse; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getFriends(): Collection { return $this->friends; @@ -137,7 +135,7 @@ public function setSpouse(CompanyPerson $spouse): void public static function loadMetadata(ClassMetadata $metadata): void { $metadata->setPrimaryTable( - ['name' => 'company_person'] + ['name' => 'company_person'], ); $metadata->addSqlResultSetMapping( @@ -160,7 +158,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'discriminatorColumn' => 'discriminator', ], ], - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php index 2beabff4277..a0f30f74b79 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php @@ -15,7 +15,7 @@ class CompanyRaffle extends CompanyEvent { /** @Column */ - private ?string $data = null; + private string|null $data = null; public function setData(string $data): void { diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php index a0be32bab79..af4e8c123b5 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php @@ -8,9 +8,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** - * @Entity - */ +/** @Entity */ class JoinedChildClass extends JoinedRootClass { /** diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php index 3d8fca8a588..a5f3a17d9cd 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php @@ -8,9 +8,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** - * @Entity - */ +/** @Entity */ class SingleChildClass extends SingleRootClass { /** diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php index 698d3bf3eca..f1a7a8bde05 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php @@ -23,10 +23,8 @@ public function __construct( * @Column(type="CustomIdObject", length=255) */ public CustomIdObject $id, - /** - * @ManyToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent", inversedBy="children") - */ - public CustomIdObjectTypeParent $parent + /** @ManyToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent", inversedBy="children") */ + public CustomIdObjectTypeParent $parent, ) { } } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php index 466fd2454cb..6b03d183270 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php @@ -30,7 +30,7 @@ public function __construct( * @Id * @Column(type="CustomIdObject", length=255) */ - public CustomIdObject $id + public CustomIdObject $id, ) { $this->children = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php index debd5230dca..ef947af372c 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php @@ -71,9 +71,7 @@ public function addMyFriend(CustomTypeParent $friend): void $friend->addFriendWithMe($this); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getMyFriends(): Collection { return $this->myFriends; @@ -84,9 +82,7 @@ public function addFriendWithMe(CustomTypeParent $friend): void $this->getFriendsWithMe()->add($friend); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getFriendsWithMe() { return $this->friendsWithMe; diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php index b03eff8e092..1ee6649ba43 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; -/** - * @Entity - */ +/** @Entity */ class DDC117ApproveChanges { /** @@ -45,7 +43,7 @@ public function __construct( * @JoinColumn(name="trans_language", referencedColumnName="language") * }) */ - private DDC117Translation $translation + private DDC117Translation $translation, ) { } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php index 56726e98756..471c8744545 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; -/** - * @Entity - */ +/** @Entity */ class DDC117Article { /** @@ -32,7 +30,7 @@ class DDC117Article private $references; /** @OneToOne(targetEntity="DDC117ArticleDetails", mappedBy="article", cascade={"persist", "remove"}) */ - private ?DDC117ArticleDetails $details = null; + private DDC117ArticleDetails|null $details = null; /** * @psalm-var Collection @@ -47,10 +45,8 @@ class DDC117Article private Collection $links; public function __construct( - /** - * @Column - */ - private string $title + /** @Column */ + private string $title, ) { $this->references = new ArrayCollection(); $this->translations = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php index 0e9b1c78e10..e74fec0ffee 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php @@ -10,9 +10,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; -/** - * @Entity - */ +/** @Entity */ class DDC117ArticleDetails { /** @Column(type="text") */ @@ -20,13 +18,12 @@ class DDC117ArticleDetails public function __construct( /** - * @var DDC117Article * @Id * @OneToOne(targetEntity="DDC117Article", inversedBy="details") * @JoinColumn(name="article_id", referencedColumnName="article_id") */ - private $article, - string $text + private DDC117Article $article, + string $text, ) { $article->setDetails($this); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php index 2bf51a2f873..98c0e421fe5 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php @@ -16,9 +16,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; -/** - * @Entity - */ +/** @Entity */ class DDC117Editor { /** @@ -55,10 +53,8 @@ class DDC117Editor public $lastTranslation; public function __construct( - /** - * @Column(type="string", length=255) - */ - public ?string $name = '' + /** @Column(type="string", length=255) */ + public string|null $name = '', ) { $this->reviewingTranslations = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php index 976825ef54a..714599bec84 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php @@ -29,7 +29,7 @@ public function __construct( * @JoinColumn(name="target_id", referencedColumnName="article_id") */ public DDC117Article $target, - $description + $description, ) { } } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php index cd0ba64980d..75791cdb49c 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; -/** - * @Entity - */ +/** @Entity */ class DDC117Reference { /** @@ -38,10 +36,8 @@ class DDC117Reference public function __construct( DDC117Article $source, DDC117Article $target, - /** - * @Column(type="string", length=255) - */ - private string $description + /** @Column(type="string", length=255) */ + private string $description, ) { $source->addReference($this); $target->addReference($this); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php index d3d909047a6..6c41caccb00 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; -/** - * @Entity - */ +/** @Entity */ class DDC117Translation { /** @@ -33,21 +31,18 @@ class DDC117Translation public function __construct( /** - * @var DDC117Article * @Id * @ManyToOne(targetEntity="DDC117Article", inversedBy="translations") * @JoinColumn(name="article_id", referencedColumnName="article_id") */ - private $article, + private DDC117Article $article, /** * @Id * @Column(type="string", length=255) */ private string $language, - /** - * @Column(type="string", length=255) - */ - private string $title + /** @Column(type="string", length=255) */ + private string $title, ) { $this->reviewedByEditors = new ArrayCollection(); $this->lastTranslatedBy = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php b/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php index 33ca8199fb8..1bc9b1f0cc9 100644 --- a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php +++ b/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** - * @Entity() - */ +/** @Entity() */ #[ORM\Entity] class DDC1476EntityWithDefaultFieldType { @@ -54,10 +52,10 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->mapField( - ['fieldName' => 'name'] + ['fieldName' => 'name'], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php index 1743aba292b..4a97a227887 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php @@ -8,9 +8,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** - * @Entity - */ +/** @Entity */ class DDC1872Bar { /** diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php index 04cb21e15f2..6f3a46e18e5 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class DDC1872ExampleEntityWithoutOverride { use DDC1872ExampleTrait; diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php index 0229b9c9687..4fd1ed7bd0a 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php @@ -25,7 +25,7 @@ class DDC2372Address private int $id; /** @Column(type="string", length=255) */ - private ?string $street = null; + private string|null $street = null; /** * @var User diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php index 961b15e5249..c9514042112 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php @@ -27,7 +27,7 @@ class DDC2372User private int $id; /** @Column(type="string", length=50) */ - private ?string $name = null; + private string|null $name = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php b/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php index 697fbb276a2..1fbc5c9ff73 100644 --- a/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php +++ b/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class DDC2504ChildClass extends DDC2504RootClass { } diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php b/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php index c11df9837fb..efb6cebee2c 100644 --- a/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php +++ b/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\PersistentCollection; -/** - * @Entity - */ +/** @Entity */ class DDC2504OtherClass { /** diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php index 04af9f4175e..a68adbef79c 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** - * @Entity - */ +/** @Entity */ #[Entity] class DDC3579Group { @@ -34,10 +32,8 @@ class DDC3579Group private $admins; public function __construct( - /** - * @Column - */ - #[Column] private ?string $name = null + /** @Column */ + #[Column] private string|null $name = null, ) { $this->admins = new ArrayCollection(); } @@ -47,7 +43,7 @@ public function setName(string $name): void $this->name = $name; } - public function getName(): ?string + public function getName(): string|null { return $this->name; } @@ -57,9 +53,7 @@ public function addAdmin(DDC3579Admin $admin): void $this->admins[] = $admin; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getAdmins(): Collection { return $this->admins; diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php index e53f009df60..f8537660bf6 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\MappedSuperclass; -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ #[MappedSuperclass] class DDC3579User { @@ -35,10 +33,8 @@ class DDC3579User protected $groups; public function __construct( - /** - * @Column(name="user_name", nullable=true, unique=false, length=250) - */ - #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected ?string $name = null + /** @Column(name="user_name", nullable=true, unique=false, length=250) */ + #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected string|null $name = null, ) { $this->groups = new ArrayCollection(); } @@ -80,7 +76,7 @@ public static function loadMetadata($metadata): void 'type' => 'integer', 'columnName' => 'user_id', 'length' => 150, - ] + ], ); $metadata->mapField( @@ -91,14 +87,14 @@ public static function loadMetadata($metadata): void 'nullable' => true, 'unique' => false, 'length' => 250, - ] + ], ); $metadata->mapManyToMany( [ 'fieldName' => 'groups', 'targetEntity' => 'DDC3579Group', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php index 05503872c83..c0f4e45e79e 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php @@ -18,13 +18,11 @@ abstract class DDC3597Media extends DDC3597Root private int $size = 0; /** @Column */ - private ?string $format = null; + private string|null $format = null; public function __construct( - /** - * @Column - */ - private string $distributionHash + /** @Column */ + private string $distributionHash, ) { } diff --git a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php index e45e36ba9a1..9e0e01667a0 100644 --- a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php +++ b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php @@ -8,9 +8,9 @@ class DDC3711EntityB { - private ?int $id1 = null; + private int|null $id1 = null; - private ?int $id2 = null; + private int|null $id2 = null; /** @var ArrayCollection */ private $entityA; diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php index 812bb9e87ae..0406e1eee5f 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php @@ -7,9 +7,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class DDC3899FixContract extends DDC3899Contract { /** diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php index fa78a55028a..80cf146316b 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php @@ -7,9 +7,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class DDC3899FlexContract extends DDC3899Contract { /** diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php index 5c027ed0192..2fc52c94b08 100644 --- a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php +++ b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php @@ -7,9 +7,7 @@ use Doctrine\ORM\Mapping\Embedded; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class DDC4006User { /** @Embedded(class="DDC4006UserId") */ diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php b/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php index 82bf3acecc7..3d4b7659245 100644 --- a/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php +++ b/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** - * @Embeddable - */ +/** @Embeddable */ class DDC4006UserId { /** diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php b/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php index 285a4d5919f..7b6ce747990 100644 --- a/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php +++ b/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** - * @Entity - */ +/** @Entity */ #[Entity] class DDC5934BaseContract { diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php b/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php index e12ff0de9d1..3e8af0d865c 100644 --- a/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php +++ b/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php @@ -7,9 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity() - */ +/** @ORM\Entity() */ #[ORM\Entity] class DDC5934Member { diff --git a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php b/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php index d29bddbfd90..b77c1de6872 100644 --- a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php +++ b/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php @@ -8,9 +8,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; -/** - * @Entity - */ +/** @Entity */ class DDC6412File { /** diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php index 928ec34e2eb..2d773b2e641 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** - * @Entity(repositoryClass = "Doctrine\Tests\Models\DDC753\DDC753CustomRepository") - */ +/** @Entity(repositoryClass = "Doctrine\Tests\Models\DDC753\DDC753CustomRepository") */ class DDC753EntityWithCustomRepository { /** diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php index 37255fb3694..8a1b5ba0857 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** - * @Entity() - */ +/** @Entity() */ class DDC753EntityWithDefaultCustomRepository { /** diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php index 1b47c1463d9..a6ba10707e3 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** - * @Entity(repositoryClass = "\stdClass") - */ +/** @Entity(repositoryClass = "\stdClass") */ class DDC753EntityWithInvalidRepository { /** diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php index a284cc3e783..32f1bb996fe 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ #[ORM\Entity] class DDC869ChequePayment extends DDC869Payment { @@ -28,7 +26,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'fieldName' => 'serialNumber', 'type' => 'string', - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php index 551d49c1ae6..fb3be4f2a91 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ #[ORM\Entity] class DDC869CreditCardPayment extends DDC869Payment { @@ -28,7 +26,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'fieldName' => 'creditCardNumber', 'type' => 'string', - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php index 6ade87d43f7..4380d4ce12e 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\MappedSuperclass; -/** - * @MappedSuperclass(repositoryClass = "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository") - */ +/** @MappedSuperclass(repositoryClass = "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository") */ #[ORM\MappedSuperclass(repositoryClass: DDC869PaymentRepository::class)] class DDC869Payment { @@ -41,13 +39,13 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'id', 'type' => 'integer', 'columnName' => 'id', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'value', 'type' => 'float', - ] + ], ); $metadata->isMappedSuperclass = true; $metadata->setCustomRepositoryClass(DDC869PaymentRepository::class); diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php b/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php index c9533aa18c5..30f08cc1cf7 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php @@ -27,7 +27,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'id', 'type' => 'integer', 'columnName' => 'id', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php b/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php index eeb4b3bdadc..61e53296fdf 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php @@ -8,9 +8,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ #[ORM\Entity] class DDC889Entity extends DDC889SuperClass { diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php b/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php index 7e8acc50fc3..7f9507113a7 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\MappedSuperclass; -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ #[ORM\MappedSuperclass] class DDC889SuperClass { @@ -25,7 +23,7 @@ class DDC889SuperClass public static function loadMetadata(ClassMetadata $metadata): void { $metadata->mapField( - ['fieldName' => 'name'] + ['fieldName' => 'name'], ); $metadata->isMappedSuperclass = true; diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php index bd847bef934..bf59e245305 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** - * @Entity - */ +/** @Entity */ class DDC964Address { /** @@ -22,22 +20,14 @@ class DDC964Address private int $id; public function __construct( - /** - * @Column - */ - private ?string $zip = null, - /** - * @Column - */ - private ?string $country = null, - /** - * @Column - */ - private ?string $city = null, - /** - * @Column - */ - private ?string $street = null + /** @Column */ + private string|null $zip = null, + /** @Column */ + private string|null $country = null, + /** @Column */ + private string|null $city = null, + /** @Column */ + private string|null $street = null, ) { } @@ -46,7 +36,7 @@ public function getId(): int return $this->id; } - public function getCountry(): ?string + public function getCountry(): string|null { return $this->country; } @@ -56,7 +46,7 @@ public function setCountry(string $country): void $this->country = $country; } - public function getZip(): ?string + public function getZip(): string|null { return $this->zip; } @@ -66,7 +56,7 @@ public function setZip(string $zip): void $this->zip = $zip; } - public function getCity(): ?string + public function getCity(): string|null { return $this->city; } @@ -76,7 +66,7 @@ public function setCity(string $city): void $this->city = $city; } - public function getStreet(): ?string + public function getStreet(): string|null { return $this->street; } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php index bcde2787862..e724d85283e 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php @@ -43,7 +43,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'referencedColumnName' => 'id', ], ], - ] + ], ); $metadata->setAssociationOverride( @@ -58,7 +58,7 @@ public static function loadMetadata(ClassMetadata $metadata): void ['name' => 'admingroup_id'], ], ], - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php index 07f1a946b64..c2d20723725 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** - * @Entity - */ +/** @Entity */ class DDC964Group { /** @@ -30,10 +28,8 @@ class DDC964Group private $users; public function __construct( - /** - * @Column - */ - private ?string $name = null + /** @Column */ + private string|null $name = null, ) { $this->users = new ArrayCollection(); } @@ -43,7 +39,7 @@ public function setName(string $name): void $this->name = $name; } - public function getName(): ?string + public function getName(): string|null { return $this->name; } @@ -53,9 +49,7 @@ public function addUser(DDC964User $user): void $this->users[] = $user; } - /** - * @psalm-return ArrayCollection - */ + /** @psalm-return ArrayCollection */ public function getUsers(): ArrayCollection { return $this->users; diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php index d5967dbec92..7e7a03b4d39 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php @@ -49,7 +49,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'nullable' => false, 'unique' => true, 'length' => 240, - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php index 291f965f42b..8d949a3fc6b 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php @@ -17,9 +17,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\MappedSuperclass; -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ #[MappedSuperclass] class DDC964User { @@ -56,10 +54,8 @@ class DDC964User protected $address; public function __construct( - /** - * @Column(name="user_name", nullable=true, unique=false, length=250) - */ - #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected ?string $name = null + /** @Column(name="user_name", nullable=true, unique=false, length=250) */ + #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected string|null $name = null, ) { $this->groups = new ArrayCollection(); } @@ -69,7 +65,7 @@ public function getId(): int return $this->id; } - public function getName(): ?string + public function getName(): string|null { return $this->name; } @@ -85,9 +81,7 @@ public function addGroup(DDC964Group $group): void $group->addUser($this); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getGroups(): ArrayCollection { return $this->groups; @@ -114,7 +108,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'integer', 'columnName' => 'user_id', 'length' => 150, - ] + ], ); $metadata->mapField( [ @@ -124,7 +118,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'nullable' => true, 'unique' => false, 'length' => 250, - ] + ], ); $metadata->mapManyToOne( @@ -133,7 +127,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'targetEntity' => 'DDC964Address', 'cascade' => ['persist','merge'], 'joinColumn' => ['name' => 'address_id', 'referencedColumnMame' => 'id'], - ] + ], ); $metadata->mapManyToMany( @@ -157,7 +151,7 @@ public static function loadMetadata(ClassMetadata $metadata): void ], ], ], - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); diff --git a/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php b/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php index ac7a6bdefc5..66b00fae6eb 100644 --- a/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php +++ b/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php @@ -11,9 +11,7 @@ final class DtoWithArrayOfEnums /** @var Unit[] */ public $supportedUnits; - /** - * @param Unit[] $supportedUnits - */ + /** @param Unit[] $supportedUnits */ public function __construct(array $supportedUnits) { $this->supportedUnits = $supportedUnits; diff --git a/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithEnum.php b/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithEnum.php index dfef95e5baf..eedb3718e84 100644 --- a/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithEnum.php +++ b/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithEnum.php @@ -11,7 +11,7 @@ final class DtoWithEnum /** @var Suit|null */ public $suit; - public function __construct(?Suit $suit) + public function __construct(Suit|null $suit) { $this->suit = $suit; } diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php index cc15e2edc17..2471169ea52 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php @@ -10,9 +10,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\MappedSuperclass; -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ abstract class AbstractContentItem { /** @@ -41,10 +39,8 @@ abstract class AbstractContentItem public static $fileSystem; public function __construct( - /** - * @ManyToOne(targetEntity="Directory") - */ - protected ?Directory $parentDirectory = null + /** @ManyToOne(targetEntity="Directory") */ + protected Directory|null $parentDirectory = null, ) { } diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php index 70e973876eb..62c62e843d2 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php @@ -7,9 +7,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class Directory extends AbstractContentItem { /** diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/File.php b/tests/Doctrine/Tests/Models/DirectoryTree/File.php index fecd7098d80..c2a8f203a3b 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/File.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/File.php @@ -20,7 +20,7 @@ class File extends AbstractContentItem */ protected $extension = 'html'; - public function __construct(?Directory $parent = null) + public function __construct(Directory|null $parent = null) { parent::__construct($parent); } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php index 823a75586f1..5bbaa69d8ae 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php @@ -33,13 +33,13 @@ class ECommerceCart private int $id; /** @Column(length=50, nullable=true) */ - private ?string $payment = null; + private string|null $payment = null; /** * @OneToOne(targetEntity="ECommerceCustomer", inversedBy="cart") * @JoinColumn(name="customer_id", referencedColumnName="id") */ - private ?ECommerceCustomer $customer = null; + private ECommerceCustomer|null $customer = null; /** * @psalm-var Collection @@ -87,14 +87,12 @@ public function removeCustomer(): void } } - public function getCustomer(): ?ECommerceCustomer + public function getCustomer(): ECommerceCustomer|null { return $this->customer; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getProducts(): Collection { return $this->products; diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php index 20d9487c976..ffc9401343e 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php @@ -33,7 +33,7 @@ class ECommerceCategory private int $id; /** @Column(type="string", length=50) */ - private ?string $name = null; + private string|null $name = null; /** * @psalm-var Collection @@ -51,7 +51,7 @@ class ECommerceCategory * @ManyToOne(targetEntity="ECommerceCategory", inversedBy="children") * @JoinColumn(name="parent_id", referencedColumnName="id") */ - private ?ECommerceCategory $parent = null; + private ECommerceCategory|null $parent = null; public function __construct() { @@ -90,9 +90,7 @@ public function removeProduct(ECommerceProduct $product): void } } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getProducts(): Collection { return $this->products; @@ -103,15 +101,13 @@ private function setParent(ECommerceCategory $parent): void $this->parent = $parent; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getChildren(): Collection { return $this->children; } - public function getParent(): ?ECommerceCategory + public function getParent(): ECommerceCategory|null { return $this->parent; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php index 15cb7c4cfa5..bd9ba52ddfb 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php @@ -29,10 +29,10 @@ class ECommerceCustomer private int $id; /** @Column(type="string", length=50) */ - private ?string $name = null; + private string|null $name = null; /** @OneToOne(targetEntity="ECommerceCart", mappedBy="customer", cascade={"persist"}) */ - private ?ECommerceCart $cart = null; + private ECommerceCart|null $cart = null; /** * Example of a one-one self referential association. A mentor can follow @@ -42,7 +42,7 @@ class ECommerceCustomer * @OneToOne(targetEntity="ECommerceCustomer", cascade={"persist"}, fetch="EAGER") * @JoinColumn(name="mentor_id", referencedColumnName="id") */ - private ?ECommerceCustomer $mentor = null; + private ECommerceCustomer|null $mentor = null; public function getId(): int { @@ -73,7 +73,7 @@ public function brokenSetCart(ECommerceCart $cart): void $this->cart = $cart; } - public function getCart(): ?ECommerceCart + public function getCart(): ECommerceCart|null { return $this->cart; } @@ -97,7 +97,7 @@ public function removeMentor(): void $this->mentor = null; } - public function getMentor(): ?ECommerceCustomer + public function getMentor(): ECommerceCustomer|null { return $this->mentor; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php index a9b3873678d..ba3ed712fc2 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php @@ -28,20 +28,20 @@ class ECommerceFeature private int $id; /** @Column(length=50) */ - private ?string $description = null; + private string|null $description = null; /** * @ManyToOne(targetEntity="ECommerceProduct", inversedBy="features") * @JoinColumn(name="product_id", referencedColumnName="id") */ - private ?ECommerceProduct $product = null; + private ECommerceProduct|null $product = null; public function getId(): int { return $this->id; } - public function getDescription(): ?string + public function getDescription(): string|null { return $this->description; } @@ -65,7 +65,7 @@ public function removeProduct(): void } } - public function getProduct(): ?ECommerceProduct + public function getProduct(): ECommerceProduct|null { return $this->product; } diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php index be203cddefe..9dd39632ca8 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php @@ -35,13 +35,13 @@ class ECommerceProduct private int $id; /** @Column(type="string", length=50, nullable=true) */ - private ?string $name = null; + private string|null $name = null; /** * @OneToOne(targetEntity="ECommerceShipping", cascade={"persist"}) * @JoinColumn(name="shipping_id", referencedColumnName="id") */ - private ?ECommerceShipping $shipping = null; + private ECommerceShipping|null $shipping = null; /** * @psalm-var Collection @@ -98,7 +98,7 @@ public function setName(string $name): void $this->name = $name; } - public function getShipping(): ?ECommerceShipping + public function getShipping(): ECommerceShipping|null { return $this->shipping; } @@ -113,9 +113,7 @@ public function removeShipping(): void $this->shipping = null; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getFeatures(): Collection { return $this->features; @@ -159,25 +157,19 @@ public function removeCategory(ECommerceCategory $category): void } } - /** - * @psalm-param Collection $categories - */ + /** @psalm-param Collection $categories */ public function setCategories(Collection $categories): void { $this->categories = $categories; } - /** - * @psalm-return Collection $categories - */ + /** @psalm-return Collection $categories */ public function getCategories(): Collection { return $this->categories; } - /** - * @psalm-return Collection $categories - */ + /** @psalm-return Collection $categories */ public function getRelated(): Collection { return $this->related; diff --git a/tests/Doctrine/Tests/Models/Enums/Card.php b/tests/Doctrine/Tests/Models/Enums/Card.php index 126dbf91195..f9378fe0873 100644 --- a/tests/Doctrine/Tests/Models/Enums/Card.php +++ b/tests/Doctrine/Tests/Models/Enums/Card.php @@ -35,14 +35,14 @@ public static function loadMetadata(ClassMetadata $metadata): void 'id' => true, 'fieldName' => 'id', 'type' => 'integer', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'suit', 'type' => 'string', 'enumType' => Suit::class, - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php b/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php index ac147962e98..d3c1f0d9ef6 100644 --- a/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php +++ b/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php @@ -35,7 +35,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'id' => true, 'fieldName' => 'id', 'type' => 'integer', - ] + ], ); $metadata->mapField( [ @@ -43,7 +43,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'string', 'enumType' => Suit::class, 'nullable' => true, - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/Enums/Scale.php b/tests/Doctrine/Tests/Models/Enums/Scale.php index f101bc0c445..46ded6cf3db 100644 --- a/tests/Doctrine/Tests/Models/Enums/Scale.php +++ b/tests/Doctrine/Tests/Models/Enums/Scale.php @@ -35,14 +35,14 @@ public static function loadMetadata(ClassMetadata $metadata): void 'id' => true, 'fieldName' => 'id', 'type' => 'integer', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'supportedUnits', 'type' => 'simple_array', 'enumType' => Unit::class, - ] + ], ); } } diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php index 79196b97239..2b85d08ef69 100644 --- a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php +++ b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** - * @Entity - */ +/** @Entity */ #[Entity] class TypedCardEnumCompositeId { diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php index 43fc70ca167..38474d61bb5 100644 --- a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php +++ b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** - * @Entity - */ +/** @Entity */ #[Entity] class TypedCardEnumId { diff --git a/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php b/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php index 47e24b9794a..9ce94b9755f 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php @@ -7,9 +7,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class ForumAdministrator extends ForumUser { /** diff --git a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php index 1585a84e506..0e39f7e63f1 100644 --- a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php +++ b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php @@ -25,10 +25,8 @@ class NonAlphaColumnsEntity public $id; public function __construct( - /** - * @Column(type="string", length=255, name="`simple-entity-value`") - */ - public string $value + /** @Column(type="string", length=255, name="`simple-entity-value`") */ + public string $value, ) { } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php index 27273de8b4c..f58bae5aa0c 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php @@ -35,9 +35,7 @@ public function __construct( * @GeneratedValue(strategy="NONE") */ public int $id, - /** - * @Column(type="string", length=255); - */ + /** @Column(type="string", length=255); */ public string $name, /** * @Id @@ -45,7 +43,7 @@ public function __construct( * @JoinColumn(name="country", referencedColumnName="id") * @Cache */ - public Country $country + public Country $country, ) { } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php index c70597a9ec7..7e56d95111d 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php @@ -28,9 +28,7 @@ public function __construct( * @GeneratedValue(strategy="NONE") */ public int $id, - /** - * @Column(type="string", length=255); - */ + /** @Column(type="string", length=255); */ public string $name, /** * @ManyToOne(targetEntity="Admin1", inversedBy="names") @@ -40,7 +38,7 @@ public function __construct( * }) * @Cache */ - public Admin1 $admin1 + public Admin1 $admin1, ) { } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/City.php b/tests/Doctrine/Tests/Models/GeoNames/City.php index 1ca55e7d279..9b707fc7762 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/City.php +++ b/tests/Doctrine/Tests/Models/GeoNames/City.php @@ -47,10 +47,8 @@ public function __construct( * @GeneratedValue(strategy="NONE") */ public int $id, - /** - * @Column(type="string", length=255); - */ - public string $name + /** @Column(type="string", length=255); */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Country.php b/tests/Doctrine/Tests/Models/GeoNames/Country.php index 871fec6a4e2..7ac209f7f68 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Country.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Country.php @@ -25,10 +25,8 @@ public function __construct( * @GeneratedValue(strategy="NONE") */ public string $id, - /** - * @Column(type="string", length=255); - */ - public string $name + /** @Column(type="string", length=255); */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php b/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php index 1a95087288e..184b1762853 100644 --- a/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php +++ b/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - */ +/** @Entity */ class AnotherChildClass extends ChildClass { } diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php b/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php index 22226d8cd18..4ba72c516f3 100644 --- a/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php +++ b/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping\MappedSuperclass; -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ abstract class ChildClass extends RootClass { } diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php b/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php index 4695f868015..75c013a3ec8 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php @@ -48,9 +48,7 @@ public function addUser(LegacyUser $user): void $this->users[] = $user; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getUsers(): Collection { return $this->users; diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php b/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php index c965b135be9..b25bc6d067a 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php @@ -92,9 +92,7 @@ public function addReference(LegacyUserReference $reference): void $this->references[] = $reference; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function references(): Collection { return $this->references; @@ -106,9 +104,7 @@ public function addCar(LegacyCar $car): void $car->addUser($this); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getCars(): Collection { return $this->cars; diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php b/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php index ab54b759896..b35810a1184 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php @@ -38,10 +38,8 @@ class LegacyUserReference public function __construct( LegacyUser $source, LegacyUser $target, - /** - * @Column(type="string", length=255, name="description") - */ - private string $_description + /** @Column(type="string", length=255, name="description") */ + private string $_description, ) { $source->addReference($this); $target->addReference($this); diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php index 14ccdc6a14a..80cd4fda2ab 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php @@ -47,7 +47,7 @@ public function __construct( * @ManyToOne(targetEntity=OtherParentClass::class, cascade={"persist"}) * @JoinColumn(name="other_parent_id", referencedColumnName="id") */ - public OtherParentClass $otherParent + public OtherParentClass $otherParent, ) { $this->parents = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php index 98d34382b03..6ecf532d13c 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php @@ -20,7 +20,7 @@ public function __construct( * @Id * @Column(name="id", type="integer") */ - public int $id + public int $id, ) { } } diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php index 3ad07f298da..97846fec23c 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php @@ -30,7 +30,7 @@ public function __construct( * @Id * @Column(name="id", type="integer") */ - public int $id + public int $id, ) { $this->children = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php index 0ebac14188a..c84d30232e6 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php @@ -32,10 +32,8 @@ class NavCountry private $pois; public function __construct( - /** - * @Column(type="string", length=255) - */ - private string $name + /** @Column(type="string", length=255) */ + private string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php index c2667d518f8..e14d49563a9 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php @@ -35,10 +35,8 @@ public function __construct( * }) */ private NavPointOfInterest $poi, - /** - * @Column(type="string", length=255, name="file_name") - */ - private string $file + /** @Column(type="string", length=255, name="file_name") */ + private string $file, ) { } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php index 6cb9c496598..5586c6b17db 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php @@ -49,14 +49,10 @@ class NavPointOfInterest public function __construct( int $lat, int $long, - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $name, - /** - * @ManyToOne(targetEntity="NavCountry", inversedBy="pois") - */ - private NavCountry $country + /** @ManyToOne(targetEntity="NavCountry", inversedBy="pois") */ + private NavCountry $country, ) { $this->lat = $lat; $this->long = $long; @@ -88,9 +84,7 @@ public function addVisitor(NavUser $user): void $this->visitors[] = $user; } - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ public function getVisitors(): Collection { return $this->visitors; diff --git a/tests/Doctrine/Tests/Models/Navigation/NavTour.php b/tests/Doctrine/Tests/Models/Navigation/NavTour.php index 3181ca7d2e4..3e75d220b8c 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavTour.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavTour.php @@ -42,10 +42,8 @@ class NavTour private Collection $pois; public function __construct( - /** - * @Column(type="string", length=255) - */ - private string $name + /** @Column(type="string", length=255) */ + private string $name, ) { $this->pois = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavUser.php b/tests/Doctrine/Tests/Models/Navigation/NavUser.php index 0b228faabc5..86a407c8fcd 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavUser.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavUser.php @@ -24,10 +24,8 @@ class NavUser private int $id; public function __construct( - /** - * @Column(type="string", length=255) - */ - private string $name + /** @Column(type="string", length=255) */ + private string $name, ) { } } diff --git a/tests/Doctrine/Tests/Models/Pagination/User1.php b/tests/Doctrine/Tests/Models/Pagination/User1.php index f70471f1a10..e05eb9342f1 100644 --- a/tests/Doctrine/Tests/Models/Pagination/User1.php +++ b/tests/Doctrine/Tests/Models/Pagination/User1.php @@ -7,9 +7,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity() - */ +/** @Entity() */ class User1 extends User { /** diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php index 25f59b12151..1ced97b1afa 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php @@ -10,9 +10,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** - * @Entity - */ +/** @Entity */ class PersistentCollectionContent extends PersistentObject { /** diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php index 071361ff0f6..613c89548d5 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** - * @Entity - */ +/** @Entity */ class PersistentCollectionHolder extends PersistentObject { /** diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php index 16252c86d74..25813bf54be 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToOne; -/** - * @Entity - */ +/** @Entity */ class PersistentEntity extends PersistentObject { /** diff --git a/tests/Doctrine/Tests/Models/Quote/City.php b/tests/Doctrine/Tests/Models/Quote/City.php index 3a31b1f247f..41a1501c457 100644 --- a/tests/Doctrine/Tests/Models/Quote/City.php +++ b/tests/Doctrine/Tests/Models/Quote/City.php @@ -25,10 +25,8 @@ class City public $id; public function __construct( - /** - * @Column(name="`city-name`") - */ - public string $name + /** @Column(name="`city-name`") */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/Models/Quote/FullAddress.php b/tests/Doctrine/Tests/Models/Quote/FullAddress.php index f879a0c9ca4..7e84abd7625 100644 --- a/tests/Doctrine/Tests/Models/Quote/FullAddress.php +++ b/tests/Doctrine/Tests/Models/Quote/FullAddress.php @@ -8,9 +8,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; -/** - * @Entity - */ +/** @Entity */ class FullAddress extends Address { /** diff --git a/tests/Doctrine/Tests/Models/Quote/Group.php b/tests/Doctrine/Tests/Models/Quote/Group.php index b19063242a5..0f4bf935332 100644 --- a/tests/Doctrine/Tests/Models/Quote/Group.php +++ b/tests/Doctrine/Tests/Models/Quote/Group.php @@ -35,15 +35,13 @@ class Group public $users; public function __construct( - /** - * @Column(name="`group-name`") - */ - public ?string $name = null, + /** @Column(name="`group-name`") */ + public string|null $name = null, /** * @ManyToOne(targetEntity="Group", cascade={"persist"}) * @JoinColumn(name="`parent-id`", referencedColumnName="`group-id`") */ - public ?Group $parent = null + public Group|null $parent = null, ) { } } diff --git a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php index bbb2804b0f5..f453eef06d2 100644 --- a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php +++ b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php @@ -25,10 +25,8 @@ class NumericEntity public $id; public function __construct( - /** - * @Column(type="string", length=255, name="`2:2`") - */ - public string $value + /** @Column(type="string", length=255, name="`2:2`") */ + public string $value, ) { } } diff --git a/tests/Doctrine/Tests/Models/Quote/User.php b/tests/Doctrine/Tests/Models/Quote/User.php index 02b95307f7c..1367cb7e00a 100644 --- a/tests/Doctrine/Tests/Models/Quote/User.php +++ b/tests/Doctrine/Tests/Models/Quote/User.php @@ -76,22 +76,18 @@ public function __construct() $this->groups = new ArrayCollection(); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getPhones(): Collection { return $this->phones; } - public function getAddress(): ?Address + public function getAddress(): Address|null { return $this->address; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getGroups(): Collection { return $this->groups; diff --git a/tests/Doctrine/Tests/Models/ReadonlyProperties/Book.php b/tests/Doctrine/Tests/Models/ReadonlyProperties/Book.php index d2ce8bfd9bd..baaaf18e206 100644 --- a/tests/Doctrine/Tests/Models/ReadonlyProperties/Book.php +++ b/tests/Doctrine/Tests/Models/ReadonlyProperties/Book.php @@ -41,9 +41,7 @@ public function getTitle(): string return $this->title; } - /** - * @return list - */ + /** @return list */ public function getAuthors(): array { return $this->authors->getValues(); diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php b/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php index 70fdee64325..ee8808c2eda 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; -/** - * @Entity - */ +/** @Entity */ class RoutingLeg { /** diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php b/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php index aa2b6cf6f2a..38ff74ce4c4 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php @@ -9,9 +9,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** - * @Entity - */ +/** @Entity */ class RoutingLocation { /** diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php b/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php index 64c6850db31..e95a54da6ba 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php @@ -16,9 +16,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OrderBy; -/** - * @Entity - */ +/** @Entity */ class RoutingRoute { /** diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php b/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php index 6c33f76cd7a..4d769bc5a9f 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; -/** - * @Entity - */ +/** @Entity */ class RoutingRouteBooking { /** diff --git a/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/tests/Doctrine/Tests/Models/StockExchange/Bond.php index 20825007941..b03d15fdd38 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Bond.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Bond.php @@ -36,10 +36,8 @@ class Bond public $stocks; public function __construct( - /** - * @Column(type="string", length=255) - */ - private string $name + /** @Column(type="string", length=255) */ + private string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/StockExchange/Market.php b/tests/Doctrine/Tests/Models/StockExchange/Market.php index 26dbf8143bc..7c7cf4584d5 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Market.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Market.php @@ -32,10 +32,8 @@ class Market public $stocks; public function __construct( - /** - * @Column(type="string", length=255) - */ - private string $name + /** @Column(type="string", length=255) */ + private string $name, ) { $this->stocks = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/Models/StockExchange/Stock.php b/tests/Doctrine/Tests/Models/StockExchange/Stock.php index 6c9c0b75594..0790f3aebb5 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Stock.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Stock.php @@ -31,14 +31,10 @@ public function __construct( * @Column(type="string", length=255) */ private string $symbol, - /** - * @Column(type="decimal") - */ + /** @Column(type="decimal") */ private float $price, - /** - * @ManyToOne(targetEntity="Market", inversedBy="stocks") - */ - private Market $market + /** @ManyToOne(targetEntity="Market", inversedBy="stocks") */ + private Market $market, ) { $market->addStock($this); } diff --git a/tests/Doctrine/Tests/Models/Taxi/Car.php b/tests/Doctrine/Tests/Models/Taxi/Car.php index 49bd1de0407..f1443da8dcc 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Car.php +++ b/tests/Doctrine/Tests/Models/Taxi/Car.php @@ -23,10 +23,10 @@ class Car * @Column(type="string", length=25) * @GeneratedValue(strategy="NONE") */ - private ?string $brand = null; + private string|null $brand = null; /** @Column(type="string", length=255); */ - private ?string $model = null; + private string|null $model = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Taxi/Driver.php b/tests/Doctrine/Tests/Models/Taxi/Driver.php index 5ce14d4fc48..c27ccbadd09 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Driver.php +++ b/tests/Doctrine/Tests/Models/Taxi/Driver.php @@ -26,7 +26,7 @@ class Driver private int $id; /** @Column(type="string", length=255); */ - private ?string $name = null; + private string|null $name = null; /** * @psalm-var Collection diff --git a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php index 6b2137352f8..98ff20ec032 100644 --- a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php +++ b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php @@ -37,7 +37,7 @@ public function __construct( * @ManyToOne(targetEntity="Car", inversedBy="carRides") * @JoinColumn(name="car", referencedColumnName="brand") */ - private Car $car + private Car $car, ) { } diff --git a/tests/Doctrine/Tests/Models/Taxi/Ride.php b/tests/Doctrine/Tests/Models/Taxi/Ride.php index 127ae45272f..099ffdb883c 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Ride.php +++ b/tests/Doctrine/Tests/Models/Taxi/Ride.php @@ -30,7 +30,7 @@ public function __construct( * @ManyToOne(targetEntity="Car", inversedBy="freeCarRides") * @JoinColumn(name="car", referencedColumnName="brand") */ - private Car $car + private Car $car, ) { } } diff --git a/tests/Doctrine/Tests/Models/TypedProperties/Contact.php b/tests/Doctrine/Tests/Models/TypedProperties/Contact.php index d5e1f555372..cc35b7f3397 100644 --- a/tests/Doctrine/Tests/Models/TypedProperties/Contact.php +++ b/tests/Doctrine/Tests/Models/TypedProperties/Contact.php @@ -7,13 +7,11 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\Column; -/** - * @ORM\Embeddable() - */ +/** @ORM\Embeddable() */ #[ORM\Embeddable] class Contact { /** @Column() */ #[ORM\Column] - public ?string $email = null; + public string|null $email = null; } diff --git a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php index b1030bb9053..123e2034d6b 100644 --- a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php +++ b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php @@ -37,7 +37,7 @@ class UserTyped /** @Column(length=50) */ #[ORM\Column(length: 50)] - public ?string $status = null; + public string|null $status = null; /** @Column(length=255, unique=true) */ #[ORM\Column(length: 255, unique: true)] @@ -76,24 +76,24 @@ class UserTyped /** @ManyToOne */ #[ORM\ManyToOne] - public ?CmsEmail $mainEmail = null; + public CmsEmail|null $mainEmail = null; /** @Embedded */ #[ORM\Embedded] - public ?Contact $contact = null; + public Contact|null $contact = null; public static function loadMetadata(ClassMetadata $metadata): void { $metadata->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_NONE); $metadata->setPrimaryTable( - ['name' => 'cms_users_typed'] + ['name' => 'cms_users_typed'], ); $metadata->mapField( [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); @@ -101,32 +101,32 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'fieldName' => 'status', 'length' => 50, - ] + ], ); $metadata->mapField( [ 'fieldName' => 'username', 'length' => 255, 'unique' => true, - ] + ], ); $metadata->mapField( - ['fieldName' => 'dateInterval'] + ['fieldName' => 'dateInterval'], ); $metadata->mapField( - ['fieldName' => 'dateTime'] + ['fieldName' => 'dateTime'], ); $metadata->mapField( - ['fieldName' => 'dateTimeImmutable'] + ['fieldName' => 'dateTimeImmutable'], ); $metadata->mapField( - ['fieldName' => 'array'] + ['fieldName' => 'array'], ); $metadata->mapField( - ['fieldName' => 'boolean'] + ['fieldName' => 'boolean'], ); $metadata->mapField( - ['fieldName' => 'float'] + ['fieldName' => 'float'], ); $metadata->mapOneToOne( @@ -140,11 +140,11 @@ public static function loadMetadata(ClassMetadata $metadata): void [], ], 'orphanRemoval' => true, - ] + ], ); $metadata->mapManyToOne( - ['fieldName' => 'mainEmail'] + ['fieldName' => 'mainEmail'], ); $metadata->mapEmbedded(['fieldName' => 'contact']); diff --git a/tests/Doctrine/Tests/Models/Upsertable/Insertable.php b/tests/Doctrine/Tests/Models/Upsertable/Insertable.php index 87c99eb55db..e2a618a7487 100644 --- a/tests/Doctrine/Tests/Models/Upsertable/Insertable.php +++ b/tests/Doctrine/Tests/Models/Upsertable/Insertable.php @@ -45,14 +45,14 @@ class Insertable public static function loadMetadata(ClassMetadata $metadata): ClassMetadata { $metadata->setPrimaryTable( - ['name' => 'insertable_column'] + ['name' => 'insertable_column'], ); $metadata->mapField( [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); @@ -62,10 +62,10 @@ public static function loadMetadata(ClassMetadata $metadata): ClassMetadata 'notInsertable' => true, 'options' => ['default' => '1234'], 'generated' => ClassMetadata::GENERATED_INSERT, - ] + ], ); $metadata->mapField( - ['fieldName' => 'insertableContent'] + ['fieldName' => 'insertableContent'], ); return $metadata; diff --git a/tests/Doctrine/Tests/Models/Upsertable/Updatable.php b/tests/Doctrine/Tests/Models/Upsertable/Updatable.php index daff3a5faad..bbda42fcfa7 100644 --- a/tests/Doctrine/Tests/Models/Upsertable/Updatable.php +++ b/tests/Doctrine/Tests/Models/Upsertable/Updatable.php @@ -44,14 +44,14 @@ class Updatable public static function loadMetadata(ClassMetadata $metadata): ClassMetadata { $metadata->setPrimaryTable( - ['name' => 'updatable_column'] + ['name' => 'updatable_column'], ); $metadata->mapField( [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); @@ -60,10 +60,10 @@ public static function loadMetadata(ClassMetadata $metadata): ClassMetadata 'fieldName' => 'nonUpdatableContent', 'notUpdatable' => true, 'generated' => ClassMetadata::GENERATED_ALWAYS, - ] + ], ); $metadata->mapField( - ['fieldName' => 'updatableContent'] + ['fieldName' => 'updatableContent'], ); return $metadata; diff --git a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php index 0f3738c0c6e..5ce4a9019bd 100644 --- a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php +++ b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php @@ -68,7 +68,7 @@ protected function _doExecute(): Result|int return 0; } - public function getResultCache(): ?CacheItemPoolInterface + public function getResultCache(): CacheItemPoolInterface|null { return $this->_queryCacheProfile->getResultCache(); } diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php index 90c576ac4d7..4ed0cf68071 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php @@ -8,9 +8,7 @@ use Doctrine\ORM\Cache\EntityCacheKey; use Doctrine\Tests\DoctrineTestCase; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class CacheKeyTest extends DoctrineTestCase { public function testEntityCacheKeyIdentifierCollision(): void diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index 2ba9bb1b7b9..28adcbd1cce 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -13,9 +13,7 @@ use Doctrine\Tests\Models\Cache\State; use PHPUnit\Framework\MockObject\MockObject; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class CacheLoggerChainTest extends DoctrineTestCase { private CacheLoggerChain $logger; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index e988fe7f65c..9cead5e88ca 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -31,9 +31,7 @@ use PHPUnit\Framework\MockObject\MockObject; use Psr\Cache\CacheItemPoolInterface; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class DefaultCacheFactoryTest extends OrmTestCase { private CacheFactory&MockObject $factory; @@ -257,14 +255,14 @@ public function testInvalidFileLockRegionDirectoryException(): void $this->expectExceptionMessage( 'If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" ' . 'is required, The default implementation provided by doctrine is ' - . '"Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory' + . '"Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory', ); $factory->getRegion( [ 'usage' => ClassMetadata::CACHE_USAGE_READ_WRITE, 'region' => 'foo', - ] + ], ); } @@ -278,14 +276,14 @@ public function testInvalidFileLockRegionDirectoryExceptionWithEmptyString(): vo $this->expectExceptionMessage( 'If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" ' . 'is required, The default implementation provided by doctrine is ' - . '"Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory' + . '"Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory', ); $factory->getRegion( [ 'usage' => ClassMetadata::CACHE_USAGE_READ_WRITE, 'region' => 'foo', - ] + ], ); } @@ -299,8 +297,8 @@ public function testBuildsDefaultCacheRegionFromGenericCacheRegion(): void [ 'region' => 'bar', 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, - ] - ) + ], + ), ); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index 579187794be..098c4c6b90f 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -22,9 +22,7 @@ use function array_merge; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class DefaultCacheTest extends OrmTestCase { private DefaultCache $cache; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php index b134ba1568b..5b845441eb4 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php @@ -16,9 +16,7 @@ use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class DefaultCollectionHydratorTest extends OrmFunctionalTestCase { private DefaultCollectionHydrator $structure; @@ -43,7 +41,7 @@ public function testLoadCacheCollection(): void [ new EntityCacheKey(City::class, ['id' => 31]), new EntityCacheKey(City::class, ['id' => 32]), - ] + ], ); $targetRegion->put(new EntityCacheKey(City::class, ['id' => 31]), new EntityCacheEntry(City::class, ['id' => 31, 'name' => 'Foo'])); diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php index 07e9cdc9a31..eeb87e9ddc1 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php @@ -16,9 +16,7 @@ use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmTestCase; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class DefaultEntityHydratorTest extends OrmTestCase { private DefaultEntityHydrator $structure; @@ -90,7 +88,7 @@ public function testBuildCacheEntry(): void 'id' => 1, 'name' => 'Foo', ], - $cache->data + $cache->data, ); } @@ -124,7 +122,7 @@ public function testBuildCacheEntryAssociation(): void 'name' => 'Bar', 'country' => new AssociationCacheEntry(Country::class, ['id' => 11]), ], - $cache->data + $cache->data, ); } @@ -155,7 +153,7 @@ public function testBuildCacheEntryNonInitializedAssocProxy(): void 'name' => 'Bar', 'country' => new AssociationCacheEntry(Country::class, ['id' => 11]), ], - $cache->data + $cache->data, ); } @@ -187,7 +185,7 @@ public function testCacheEntryWithWrongIdentifierType(): void 'name' => 'Bar', 'country' => new AssociationCacheEntry(Country::class, ['id' => 11]), ], - $cache->data + $cache->data, ); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 57a4c28aef6..577f6975b93 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -31,9 +31,7 @@ use function microtime; use function sprintf; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class DefaultQueryCacheTest extends OrmTestCase { private DefaultQueryCache $queryCache; @@ -271,7 +269,7 @@ public function testGetBasicQueryResult(): void [ ['identifier' => ['id' => 1]], ['identifier' => ['id' => 2]], - ] + ], ); $data = [ @@ -286,7 +284,7 @@ public function testGetBasicQueryResult(): void [ new EntityCacheEntry(Country::class, $data[0]), new EntityCacheEntry(Country::class, $data[1]), - ] + ], ); $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); @@ -310,7 +308,7 @@ public function testGetWithAssociation(): void [ ['identifier' => ['id' => 1]], ['identifier' => ['id' => 2]], - ] + ], ); $data = [ @@ -325,7 +323,7 @@ public function testGetWithAssociation(): void [ new EntityCacheEntry(Country::class, $data[0]), new EntityCacheEntry(Country::class, $data[1]), - ] + ], ); $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); @@ -349,7 +347,7 @@ public function testGetWithAssociationCacheMiss(): void [ ['identifier' => ['id' => 1]], ['identifier' => ['id' => 2]], - ] + ], ); $this->region->addReturn('get', $entry); @@ -359,7 +357,7 @@ public function testGetWithAssociationCacheMiss(): void [ new EntityCacheEntry(Country::class, ['id' => 1, 'name' => 'Foo']), false, - ] + ], ); $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); @@ -466,7 +464,7 @@ public function testIgnoreCacheNonGetMode(): void [ ['identifier' => ['id' => 1]], ['identifier' => ['id' => 2]], - ] + ], ); $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); @@ -505,7 +503,7 @@ public function testGetShouldIgnoreOldQueryCacheEntryResult(): void [ ['identifier' => ['id' => 1]], ['identifier' => ['id' => 2]], - ] + ], ); $entities = [ ['id' => 1, 'name' => 'Foo'], @@ -521,7 +519,7 @@ public function testGetShouldIgnoreOldQueryCacheEntryResult(): void [ new EntityCacheEntry(Country::class, $entities[0]), new EntityCacheEntry(Country::class, $entities[1]), - ] + ], ); $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); @@ -550,7 +548,7 @@ public function testGetShouldIgnoreNonQueryCacheEntryResult(): void [ new EntityCacheEntry(Country::class, $data[0]), new EntityCacheEntry(Country::class, $data[1]), - ] + ], ); $rsm->addRootEntityFromClassMetadata(Country::class, 'c'); @@ -566,7 +564,7 @@ public function testGetShouldIgnoreMissingEntityQueryCacheEntry(): void [ ['identifier' => ['id' => 1]], ['identifier' => ['id' => 2]], - ] + ], ); $this->region->addReturn('get', $entry); @@ -676,11 +674,11 @@ class CacheFactoryDefaultQueryCacheTest extends DefaultCacheFactory { public function __construct( private DefaultQueryCache $queryCache, - private CacheRegionMock $region + private CacheRegionMock $region, ) { } - public function buildQueryCache(EntityManagerInterface $em, ?string $regionName = null): DefaultQueryCache + public function buildQueryCache(EntityManagerInterface $em, string|null $regionName = null): DefaultQueryCache { return $this->queryCache; } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index 800ee240ad4..031cfb01a2a 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -85,7 +85,7 @@ public function testGetMultiPreservesOrderAndKeys(): void $actual = array_map( 'iterator_to_array', - $this->region->getMultiple(new CollectionCacheEntry(['one' => $key1, 'two' => $key2])) + $this->region->getMultiple(new CollectionCacheEntry(['one' => $key1, 'two' => $key2])), ); self::assertSame([ @@ -104,7 +104,7 @@ public function corruptedDataDoesNotLeakIntoApplicationWhenGettingSingleEntry(): $this->cacheItemPool->save( $this->cacheItemPool ->getItem('DC2_REGION_' . $this->region->getName() . '_' . $key1->hash) - ->set('a-very-invalid-value') + ->set('a-very-invalid-value'), ); self::assertTrue($this->region->contains($key1)); @@ -121,7 +121,7 @@ public function corruptedDataDoesNotLeakIntoApplicationWhenGettingMultipleEntrie $this->cacheItemPool->save( $this->cacheItemPool ->getItem('DC2_REGION_' . $this->region->getName() . '_' . $key1->hash) - ->set('a-very-invalid-value') + ->set('a-very-invalid-value'), ); self::assertTrue($this->region->contains($key1)); diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index e5bd749e55e..5c5298fd29c 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -231,7 +231,7 @@ public function testLockLifetime(): void self::assertFileDoesNotExist($file); } - private function cleanTestDirectory(?string $path): void + private function cleanTestDirectory(string|null $path): void { $path = $path ?: $this->directory; @@ -241,7 +241,7 @@ private function cleanTestDirectory(?string $path): void $directoryIterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path), - RecursiveIteratorIterator::CHILD_FIRST + RecursiveIteratorIterator::CHILD_FIRST, ); foreach ($directoryIterator as $file) { diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php index 1f7447fb4dc..405f73ac350 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php @@ -17,9 +17,7 @@ use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\MockObject\MockObject; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ abstract class CollectionPersisterTestCase extends OrmTestCase { protected Region&MockObject $region; diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php index 60daa7a9156..68193d3bc40 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php @@ -10,9 +10,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Persisters\Collection\CollectionPersister; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class NonStrictReadWriteCachedCollectionPersisterTest extends CollectionPersisterTestCase { protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php index ef8ce486d08..34f4b003400 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php @@ -10,9 +10,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Persisters\Collection\CollectionPersister; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class ReadOnlyCachedCollectionPersisterTest extends CollectionPersisterTestCase { protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index c5395d87a47..fb75b2dcaae 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -16,9 +16,7 @@ use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class ReadWriteCachedCollectionPersisterTest extends CollectionPersisterTestCase { protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php index 8b264a5f6e2..09bf0c90c77 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php @@ -20,9 +20,7 @@ use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\MockObject\MockObject; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ abstract class EntityPersisterTestCase extends OrmTestCase { protected Region&MockObject $region; @@ -97,7 +95,7 @@ public function testInvokeGetSelectSQL(): void self::identicalTo(1), self::identicalTo(2), self::identicalTo(3), - self::identicalTo([4]) + self::identicalTo([4]), ) ->willReturn('SELECT * FROM foo WERE name = ?'); @@ -107,7 +105,7 @@ public function testInvokeGetSelectSQL(): void 1, 2, 3, - [4] + [4], )); } @@ -225,7 +223,7 @@ public function testInvokeLoad(): void self::identicalTo([1]), self::identicalTo(2), self::identicalTo(3), - self::identicalTo([4]) + self::identicalTo([4]), ) ->willReturn($entity); diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php index 61b40c2b17a..71ae563bdde 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php @@ -15,9 +15,7 @@ use Doctrine\Tests\Models\Cache\Country; use ReflectionProperty; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class NonStrictReadWriteCachedEntityPersisterTest extends EntityPersisterTestCase { protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php index 7fba7a82417..c537d66ffb0 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Persisters\Entity\EntityPersister; use Doctrine\Tests\Models\Cache\Country; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class ReadOnlyCachedEntityPersisterTest extends EntityPersisterTestCase { protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 9d742ca0616..b149bb0634e 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -17,9 +17,7 @@ use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class ReadWriteCachedEntityPersisterTest extends EntityPersisterTestCase { protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php b/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php index fcbc6d1d2eb..bfb133fa109 100644 --- a/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php @@ -43,9 +43,7 @@ public static function dataProviderCacheValues(): array ]; } - /** - * @dataProvider dataProviderCacheValues - */ + /** @dataProvider dataProviderCacheValues */ public function testPutGetContainsEvict(CacheKey $key, CacheEntry $value): void { self::assertFalse($this->region->contains($key)); diff --git a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php index 08cb4b834d1..82f4bef6fd1 100644 --- a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php @@ -11,9 +11,7 @@ use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\Cache\State; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class StatisticsCacheLoggerTest extends DoctrineTestCase { private StatisticsCacheLogger $logger; diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 23d61c96163..58009043848 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -137,7 +137,7 @@ public function testSetCustomHydrationModes(): void self::assertSame(self::class, $this->configuration->getCustomHydrationMode('HydrationModeName')); $this->configuration->setCustomHydrationModes( - ['AnotherHydrationModeName' => self::class] + ['AnotherHydrationModeName' => self::class], ); self::assertNull($this->configuration->getCustomHydrationMode('HydrationModeName')); @@ -184,9 +184,7 @@ public function testSetGetQuoteStrategy(): void self::assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); } - /** - * @group DDC-1955 - */ + /** @group DDC-1955 */ public function testSetGetEntityListenerResolver(): void { self::assertInstanceOf(EntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); @@ -196,9 +194,7 @@ public function testSetGetEntityListenerResolver(): void self::assertSame($resolver, $this->configuration->getEntityListenerResolver()); } - /** - * @group DDC-2183 - */ + /** @group DDC-2183 */ public function testSetGetSecondLevelCacheConfig(): void { $mockClass = $this->createMock(CacheConfiguration::class); diff --git a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php index a206fe536d7..73e01a87661 100644 --- a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php +++ b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php @@ -22,7 +22,7 @@ class ConstructorTestEntity1 /** @var string|null */ public $username; - public function __construct(?string $username = null) + public function __construct(string|null $username = null) { if ($username !== null) { $this->username = $username; diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 692509b8687..f6b5f0e0431 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -32,9 +32,7 @@ protected function setUp(): void $this->entityManager = $this->getTestEntityManager(); } - /** - * @group DDC-899 - */ + /** @group DDC-899 */ public function testIsOpen(): void { self::assertTrue($this->entityManager->isOpen()); @@ -119,9 +117,7 @@ public function testCreateQuery(): void self::assertEquals('SELECT 1', $q->getDql()); } - /** - * @psalm-return list - */ + /** @psalm-return list */ public static function dataAffectedByErrorIfClosedException(): array { return [ @@ -132,9 +128,7 @@ public static function dataAffectedByErrorIfClosedException(): array ]; } - /** - * @dataProvider dataAffectedByErrorIfClosedException - */ + /** @dataProvider dataAffectedByErrorIfClosedException */ public function testAffectedByErrorIfClosedException(string $methodName): void { $this->expectException(EntityManagerClosed::class); @@ -164,15 +158,13 @@ public function dataToBeReturnedByWrapInTransaction(): Generator public function testWrapInTransactionAcceptsReturn(mixed $expectedValue): void { $return = $this->entityManager->wrapInTransaction( - static fn (EntityManagerInterface $em): mixed => $expectedValue + static fn (EntityManagerInterface $em): mixed => $expectedValue, ); $this->assertSame($expectedValue, $return); } - /** - * @group #5796 - */ + /** @group #5796 */ public function testWrapInTransactionReThrowsThrowables(): void { try { diff --git a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php b/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php index 8cb401c8a57..319b06c9780 100644 --- a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php @@ -18,7 +18,7 @@ public function testFromClassNameAndIdentifier(): void { $exception = EntityNotFoundException::fromClassNameAndIdentifier( 'foo', - ['foo' => 'bar'] + ['foo' => 'bar'], ); self::assertInstanceOf(EntityNotFoundException::class, $exception); @@ -26,7 +26,7 @@ public function testFromClassNameAndIdentifier(): void $exception = EntityNotFoundException::fromClassNameAndIdentifier( 'foo', - [] + [], ); self::assertInstanceOf(EntityNotFoundException::class, $exception); diff --git a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php index e382bb5aca1..ff62e166aee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php @@ -47,7 +47,7 @@ protected function countForeignKeys($firstId, $secondId): int $this->firstField, $this->table, $this->firstField, - $this->secondField + $this->secondField, ), [$firstId, $secondId])->fetchAll()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php index 70b05e4e7c7..3d0b335754f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -37,7 +37,7 @@ protected function setUp(): void PhraseType::class, Definition::class, Lemma::class, - Type::class + Type::class, ); } @@ -164,7 +164,7 @@ class Lemma private int $id; /** @Column(type="string", name="lemma_name", unique=true, length=255) */ - private ?string $lemma = null; + private string|null $lemma = null; /** @ManyToMany(targetEntity="Type", mappedBy="lemmas", cascade={"persist"}) */ private Collection $types; @@ -227,10 +227,10 @@ class Type private int $id; /** @Column(type="string", name="type_name", unique=true) */ - private ?string $type = null; + private string|null $type = null; /** @Column(type="string", name="type_abbreviation", unique=true) */ - private ?string $abbreviation = null; + private string|null $abbreviation = null; /** * @ManyToMany(targetEntity="Lemma") @@ -310,13 +310,13 @@ class Phrase private int $id; /** @Column(type="string", name="phrase_name", unique=true, length=255) */ - private ?string $phrase = null; + private string|null $phrase = null; /** * @ManyToOne(targetEntity="PhraseType") * @JoinColumn(name="phrase_type_id", referencedColumnName="phrase_type_id") */ - private ?PhraseType $type = null; + private PhraseType|null $type = null; /** * @psalm-var Collection @@ -382,10 +382,10 @@ class PhraseType private int $id; /** @Column(type="string", name="phrase_type_name", unique=true) */ - private ?string $type = null; + private string|null $type = null; /** @Column(type="string", name="phrase_type_abbreviation", unique=true) */ - private ?string $abbreviation = null; + private string|null $abbreviation = null; /** * @psalm-var Collection @@ -453,10 +453,10 @@ class Definition * @ManyToOne(targetEntity="Phrase") * @JoinColumn(name="definition_phrase_id", referencedColumnName="phrase_id") */ - private ?Phrase $phrase = null; + private Phrase|null $phrase = null; /** @Column(type="text", name="definition_text") */ - private ?string $definition = null; + private string|null $definition = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php index 25c1a85784f..74239ebd563 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php @@ -175,7 +175,7 @@ public function testSelectSubselect(): void public function testInSubselect(): void { - $dql = <<_em->createQuery($dql)->execute(); $query = $this->_em->createQuery( - 'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1' + 'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1', ); self::assertGreaterThan(0, $query->getResult()); diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 1141dbbfc57..76e69cd5e44 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -129,7 +129,7 @@ public function testBasicOneToOne(): void // Check that the foreign key has been set $userId = $this->_em->getConnection()->executeQuery( 'SELECT user_id FROM cms_addresses WHERE id=?', - [$address->id] + [$address->id], )->fetchOne(); self::assertIsNumeric($userId); @@ -144,9 +144,7 @@ public function testBasicOneToOne(): void self::assertNotInstanceOf(Proxy::class, $user2->address); } - /** - * @group DDC-1230 - */ + /** @group DDC-1230 */ public function testRemove(): void { $user = new CmsUser(); @@ -335,9 +333,7 @@ public function testBasicRefresh(): void self::assertEquals('developer', $user->status); } - /** - * @group DDC-833 - */ + /** @group DDC-833 */ public function testRefreshResetsCollection(): void { $user = new CmsUser(); @@ -367,9 +363,7 @@ public function testRefreshResetsCollection(): void self::assertCount(1, $user->phonenumbers); } - /** - * @group DDC-833 - */ + /** @group DDC-833 */ public function testDqlRefreshResetsCollection(): void { $user = new CmsUser(); @@ -403,9 +397,7 @@ public function testDqlRefreshResetsCollection(): void self::assertCount(1, $user->phonenumbers); } - /** - * @group DDC-833 - */ + /** @group DDC-833 */ public function testCreateEntityOfProxy(): void { $user = new CmsUser(); @@ -583,12 +575,12 @@ public function testOneToManyCascadeRemove(): void $this->_em->clear(); self::assertEquals(0, $this->_em->createQuery( - 'select count(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p' + 'select count(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p', ) ->getSingleScalarResult()); self::assertEquals(0, $this->_em->createQuery( - 'select count(u.id) from Doctrine\Tests\Models\CMS\CmsUser u' + 'select count(u.id) from Doctrine\Tests\Models\CMS\CmsUser u', ) ->getSingleScalarResult()); } @@ -897,9 +889,7 @@ public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void self::assertEquals('Benjamin E.', $this->_em->find($user::class, $userId)->name); } - /** - * @group DDC-952 - */ + /** @group DDC-952 */ public function testManyToOneFetchModeQuery(): void { $user = new CmsUser(); @@ -928,9 +918,7 @@ public function testManyToOneFetchModeQuery(): void $this->assertQueryCount(2); } - /** - * @group DDC-720 - */ + /** @group DDC-720 */ public function testFlushSingleManagedEntity(): void { $user = new CmsUser(); @@ -949,9 +937,7 @@ public function testFlushSingleManagedEntity(): void self::assertEquals('administrator', $user->status); } - /** - * @group DDC-720 - */ + /** @group DDC-720 */ public function testFlushAndCascadePersist(): void { $user = new CmsUser(); @@ -976,9 +962,7 @@ public function testFlushAndCascadePersist(): void self::assertTrue($address->id > 0, 'other user has an id'); } - /** - * @group DDC-720 - */ + /** @group DDC-720 */ public function testFlushSingleAndNoCascade(): void { $user = new CmsUser(); @@ -1025,9 +1009,7 @@ public function testFlushSingleNewEntityThenRemove(): void self::assertNull($this->_em->find($user::class, $userId)); } - /** - * @group DDC-1585 - */ + /** @group DDC-1585 */ public function testWrongAssociationInstance(): void { $user = new CmsUser(); @@ -1039,7 +1021,7 @@ public function testWrongAssociationInstance(): void $this->expectException(ORMInvalidArgumentException::class); $this->expectExceptionMessage( 'Expected value of type "Doctrine\Tests\Models\CMS\CmsAddress" for association field ' . - '"Doctrine\Tests\Models\CMS\CmsUser#$address", got "Doctrine\Tests\Models\CMS\CmsUser" instead.' + '"Doctrine\Tests\Models\CMS\CmsUser#$address", got "Doctrine\Tests\Models\CMS\CmsUser" instead.', ); $this->_em->persist($user); diff --git a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php index a1369f1d091..f1c531a044e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php @@ -15,9 +15,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group CascadeRemoveOrderTest - */ +/** @group CascadeRemoveOrderTest */ class CascadeRemoveOrderTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -26,7 +24,7 @@ protected function setUp(): void $this->createSchemaForModels( CascadeRemoveOrderEntityO::class, - CascadeRemoveOrderEntityG::class + CascadeRemoveOrderEntityG::class, ); } @@ -71,9 +69,7 @@ public function testMany(): void } } -/** - * @Entity - */ +/** @Entity */ class CascadeRemoveOrderEntityO { /** @@ -87,7 +83,7 @@ class CascadeRemoveOrderEntityO * @OneToOne(targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG") * @JoinColumn(nullable=true, onDelete="SET NULL") */ - private ?CascadeRemoveOrderEntityG $oneToOneG = null; + private CascadeRemoveOrderEntityG|null $oneToOneG = null; /** * @psalm-var Collection @@ -124,18 +120,14 @@ public function addOneToManyG(CascadeRemoveOrderEntityG $eG): void $this->oneToManyG->add($eG); } - /** - * @psalm-return array - */ + /** @psalm-return array */ public function getOneToManyGs(): array { return $this->oneToManyG->toArray(); } } -/** - * @Entity - */ +/** @Entity */ class CascadeRemoveOrderEntityG { /** @@ -153,7 +145,7 @@ public function __construct( * ) */ private CascadeRemoveOrderEntityO $ownerO, - private int $position = 1 + private int $position = 1, ) { $this->ownerO->addOneToManyG($this); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php index ffd472e5198..34d489c6cb5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php @@ -33,7 +33,7 @@ protected function setUp(): void CTIParent::class, CTIChild::class, CTIRelated::class, - CTIRelated2::class + CTIRelated2::class, ); } @@ -100,7 +100,7 @@ class CTIParent private int $id; /** @OneToOne(targetEntity="CTIRelated", mappedBy="ctiParent") */ - private ?CTIRelated $related = null; + private CTIRelated|null $related = null; public function getId(): int { @@ -126,7 +126,7 @@ public function setRelated(CTIRelated $related): void class CTIChild extends CTIParent { /** @Column(type="string", length=255) */ - private ?string $data = null; + private string|null $data = null; public function getData(): string { @@ -153,7 +153,7 @@ class CTIRelated * @OneToOne(targetEntity="CTIParent") * @JoinColumn(name="ctiparent_id", referencedColumnName="id") */ - private ?CTIParent $ctiParent = null; + private CTIParent|null $ctiParent = null; public function getId(): int { @@ -202,9 +202,7 @@ public function addCTIChild(CTIChild $child): void $this->ctiChildren->add($child); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getCTIChildren(): Collection { return $this->ctiChildren; diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index f1deeebd316..e74ad0f3747 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -306,9 +306,7 @@ public function testLazyLoading2(): void IterableTester::assertResultsAreTheSame($q); } - /** - * @group DDC-368 - */ + /** @group DDC-368 */ public function testBulkUpdateIssueDDC368(): void { $this->_em->createQuery('UPDATE ' . CompanyEmployee::class . ' AS p SET p.salary = 1') @@ -324,9 +322,7 @@ public function testBulkUpdateIssueDDC368(): void IterableTester::assertResultsAreTheSame($query); } - /** - * @group DDC-1341 - */ + /** @group DDC-1341 */ public function testBulkUpdateNonScalarParameterDDC1341(): void { $this->_em->createQuery('UPDATE ' . CompanyEmployee::class . ' AS p SET p.startDate = ?0 WHERE p.department = ?1') @@ -337,9 +333,7 @@ public function testBulkUpdateNonScalarParameterDDC1341(): void $this->addToAssertionCount(1); } - /** - * @group DDC-130 - */ + /** @group DDC-130 */ public function testDeleteJoinTableRecords(): void { $employee1 = new CompanyEmployee(); @@ -366,9 +360,7 @@ public function testDeleteJoinTableRecords(): void self::assertNull($this->_em->find($employee1::class, $employee1Id)); } - /** - * @group DDC-728 - */ + /** @group DDC-728 */ public function testQueryForInheritedSingleValuedAssociation(): void { $manager = new CompanyManager(); @@ -395,9 +387,7 @@ public function testQueryForInheritedSingleValuedAssociation(): void self::assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); } - /** - * @group DDC-817 - */ + /** @group DDC-817 */ public function testFindByAssociation(): void { $manager = new CompanyManager(); @@ -427,9 +417,7 @@ public function testFindByAssociation(): void self::assertEquals($manager->getId(), $pmanager->getId()); } - /** - * @group DDC-834 - */ + /** @group DDC-834 */ public function testGetReferenceEntityWithSubclasses(): void { $manager = new CompanyManager(); @@ -452,9 +440,7 @@ public function testGetReferenceEntityWithSubclasses(): void self::assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); } - /** - * @group DDC-992 - */ + /** @group DDC-992 */ public function testGetSubClassManyToManyCollection(): void { $manager = new CompanyManager(); @@ -478,9 +464,7 @@ public function testGetSubClassManyToManyCollection(): void self::assertCount(1, $manager->getFriends()); } - /** - * @group DDC-1777 - */ + /** @group DDC-1777 */ public function testExistsSubclass(): void { $manager = new CompanyManager(); @@ -497,9 +481,7 @@ public function testExistsSubclass(): void self::assertTrue($this->_em->getUnitOfWork()->getEntityPersister($manager::class)->exists($manager)); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatching(): void { $manager = new CompanyManager(); @@ -513,13 +495,13 @@ public function testMatching(): void $repository = $this->_em->getRepository(CompanyEmployee::class); $users = $repository->matching(new Criteria( - Criteria::expr()->eq('department', 'IT') + Criteria::expr()->eq('department', 'IT'), )); self::assertCount(1, $users); $repository = $this->_em->getRepository(CompanyManager::class); $users = $repository->matching(new Criteria( - Criteria::expr()->eq('department', 'IT') + Criteria::expr()->eq('department', 'IT'), )); self::assertCount(1, $users); } diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php index 7a5f35bf5ce..6fa23599830 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -59,9 +59,7 @@ public function testPersistCompositePkEntity(): void self::assertEquals('Brandenburger Tor', $poi->getName()); } - /** - * @group DDC-1651 - */ + /** @group DDC-1651 */ public function testSetParameterCompositeKeyObject(): void { $this->putGermanysBrandenburderTor(); @@ -168,9 +166,7 @@ public function testUnrecognizedIdentifierFieldsOnGetReference(): void $poi = $this->_em->getReference(NavPointOfInterest::class, ['lat' => 10, 'long' => 20, 'key1' => 100]); } - /** - * @group DDC-1939 - */ + /** @group DDC-1939 */ public function testDeleteCompositePersistentCollection(): void { $this->putGermanysBrandenburderTor(); diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php index c3d59a43f25..4b21059fedc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php @@ -85,7 +85,7 @@ public function getSql(SqlWalker $sqlWalker): string class CustomCount extends FunctionNode { - private ?AggregateExpression $aggregateExpression = null; + private AggregateExpression|null $aggregateExpression = null; public function parse(Parser $parser): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php index 7cc731b81b5..742bc1f6af8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php @@ -56,7 +56,7 @@ public function testFetchJoinCustomIdObject(): void ->createQuery( 'SELECT parent, children FROM ' . CustomIdObjectTypeParent::class - . ' parent LEFT JOIN parent.children children' + . ' parent LEFT JOIN parent.children children', ) ->getResult(); @@ -84,7 +84,7 @@ public function testFetchJoinWhereCustomIdObject(): void 'SELECT parent, children FROM ' . CustomIdObjectTypeParent::class . ' parent LEFT JOIN parent.children children ' - . 'WHERE children.id = ?1' + . 'WHERE children.id = ?1', ) ->setParameter(1, $parent->children->first()->id) ->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index efaa3c44cad..f6d97be2c1e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -30,9 +30,7 @@ protected function setUp(): void $this->schemaManager = $this->createSchemaManager(); } - /** - * @group DDC-2059 - */ + /** @group DDC-2059 */ public function testIssue2059(): void { $user = new Table('ddc2059_user'); @@ -194,13 +192,13 @@ public function testLoadMetadataFromDatabaseDetail(): void self::assertNotEmpty($metadata->table['indexes']['index1']['columns']); self::assertEquals( ['column_index1', 'column_index2'], - $metadata->table['indexes']['index1']['columns'] + $metadata->table['indexes']['index1']['columns'], ); self::assertNotEmpty($metadata->table['uniqueConstraints']['unique_index1']['columns']); self::assertEquals( ['column_unique_index1', 'column_unique_index2'], - $metadata->table['uniqueConstraints']['unique_index1']['columns'] + $metadata->table['uniqueConstraints']['unique_index1']['columns'], ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php index 3f44040975d..7a9039cfe11 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php @@ -20,9 +20,7 @@ */ abstract class DatabaseDriverTestCase extends OrmFunctionalTestCase { - /** - * @psalm-return array - */ + /** @psalm-return array */ protected function convertToClassMetadata(array $entityTables, array $manyTables = []): array { $sm = $this->createSchemaManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index 5899aeefe0c..637b84771ff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -23,13 +23,11 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( DefaultValueUser::class, - DefaultValueAddress::class + DefaultValueAddress::class, ); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testSimpleDetachMerge(): void { $user = new DefaultValueUser(); @@ -63,9 +61,7 @@ public function testSimpleDetachMerge(): void self::assertEquals('Poweruser', $a2->getUser()->type); } - /** - * @group DDC-1386 - */ + /** @group DDC-1386 */ public function testGetPartialReferenceWithDefaultValueNotEvaluatedInFlush(): void { $user = new DefaultValueUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index 37461ed8f1c..dc9ffc4e4de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -20,9 +20,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-203 - */ + /** @group DDC-203 */ public function testDetachedEntityThrowsExceptionOnFlush(): void { $ph = new CmsPhonenumber(); @@ -39,9 +37,7 @@ public function testDetachedEntityThrowsExceptionOnFlush(): void $this->_em->flush(); } - /** - * @group DDC-822 - */ + /** @group DDC-822 */ public function testUseDetachedEntityAsQueryParameter(): void { $user = new CmsUser(); @@ -64,9 +60,7 @@ public function testUseDetachedEntityAsQueryParameter(): void self::assertEquals('gblanco', $newUser->username); } - /** - * @group DDC-920 - */ + /** @group DDC-920 */ public function testDetachManagedUnpersistedEntity(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php index 869eb261196..d362e1bdf54 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php @@ -11,9 +11,7 @@ use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1955 - */ +/** @group DDC-1955 */ class EntityListenersTest extends OrmFunctionalTestCase { private CompanyContractListener $listener; diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php index 9a271dd2526..a934e48d42f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php @@ -66,7 +66,7 @@ public function testLteDateComparison(): void $repository = $this->_em->getRepository(DateTimeModel::class); $dates = $repository->matching(new Criteria( - Criteria::expr()->lte('datetime', new DateTime('today')) + Criteria::expr()->lte('datetime', new DateTime('today')), )); self::assertCount(2, $dates); @@ -98,7 +98,7 @@ public function testIsNullComparison(): void $repository = $this->_em->getRepository(DateTimeModel::class); $dates = $repository->matching(new Criteria( - Criteria::expr()->isNull('time') + Criteria::expr()->isNull('time'), )); self::assertCount(1, $dates); @@ -110,7 +110,7 @@ public function testEqNullComparison(): void $repository = $this->_em->getRepository(DateTimeModel::class); $dates = $repository->matching(new Criteria( - Criteria::expr()->eq('time', null) + Criteria::expr()->eq('time', null), )); self::assertCount(1, $dates); @@ -122,7 +122,7 @@ public function testNotEqNullComparison(): void $repository = $this->_em->getRepository(DateTimeModel::class); $dates = $repository->matching(new Criteria( - Criteria::expr()->neq('time', null) + Criteria::expr()->neq('time', null), )); self::assertCount(1, $dates); @@ -141,7 +141,7 @@ public function testCanCountWithoutLoadingCollection(): void // Test it can work even with a constraint $dates = $repository->matching(new Criteria( - Criteria::expr()->lte('datetime', new DateTime('today')) + Criteria::expr()->lte('datetime', new DateTime('today')), )); self::assertFalse($dates->isInitialized()); diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index b059ba3c0b8..87acfd93d4f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -84,9 +84,7 @@ public function loadFixture(): int return $user1Id; } - /** - * @psalm-return array{int, int} - */ + /** @psalm-return array{int, int} */ public function loadAssociatedFixture(): array { $address = new CmsAddress(); @@ -109,9 +107,7 @@ public function loadAssociatedFixture(): array return [$user->id, $address->id]; } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function loadFixtureUserEmail(): array { $user1 = new CmsUser(); @@ -368,9 +364,7 @@ public function testIdentityMappedOptimisticLockUnversionedEntityThrowsException $this->_em->find(CmsUser::class, $userId, LockMode::OPTIMISTIC); } - /** - * @group DDC-819 - */ + /** @group DDC-819 */ public function testFindMagicCallByNullValue(): void { $this->loadFixture(); @@ -381,9 +375,7 @@ public function testFindMagicCallByNullValue(): void self::assertCount(1, $users); } - /** - * @group DDC-819 - */ + /** @group DDC-819 */ public function testInvalidMagicCall(): void { $this->expectException(BadMethodCallException::class); @@ -392,9 +384,7 @@ public function testInvalidMagicCall(): void $repos->foo(); } - /** - * @group DDC-817 - */ + /** @group DDC-817 */ public function testFindByAssociationKeyExceptionOnInverseSide(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -406,9 +396,7 @@ public function testFindByAssociationKeyExceptionOnInverseSide(): void $user = $repos->findBy(['address' => $addressId]); } - /** - * @group DDC-817 - */ + /** @group DDC-817 */ public function testFindOneByAssociationKey(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -419,9 +407,7 @@ public function testFindOneByAssociationKey(): void self::assertEquals($addressId, $address->id); } - /** - * @group DDC-1241 - */ + /** @group DDC-1241 */ public function testFindOneByOrderBy(): void { $this->loadFixture(); @@ -433,9 +419,7 @@ public function testFindOneByOrderBy(): void self::assertNotSame($userAsc, $userDesc); } - /** - * @group DDC-817 - */ + /** @group DDC-817 */ public function testFindByAssociationKey(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -447,9 +431,7 @@ public function testFindByAssociationKey(): void self::assertEquals($addressId, $addresses[0]->id); } - /** - * @group DDC-817 - */ + /** @group DDC-817 */ public function testFindAssociationByMagicCall(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -461,9 +443,7 @@ public function testFindAssociationByMagicCall(): void self::assertEquals($addressId, $addresses[0]->id); } - /** - * @group DDC-817 - */ + /** @group DDC-817 */ public function testFindOneAssociationByMagicCall(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -474,9 +454,7 @@ public function testFindOneAssociationByMagicCall(): void self::assertEquals($addressId, $address->id); } - /** - * @group DDC-1087 - */ + /** @group DDC-1087 */ public function testIsNullCriteriaDoesNotGenerateAParameter(): void { $repos = $this->_em->getRepository(CmsUser::class); @@ -497,9 +475,7 @@ public function testIsNullCriteria(): void self::assertCount(1, $users); } - /** - * @group DDC-1094 - */ + /** @group DDC-1094 */ public function testFindByLimitOffset(): void { $this->loadFixture(); @@ -515,9 +491,7 @@ public function testFindByLimitOffset(): void self::assertNotSame($users1[0], $users2[0]); } - /** - * @group DDC-1094 - */ + /** @group DDC-1094 */ public function testFindByOrderBy(): void { $this->loadFixture(); @@ -532,9 +506,7 @@ public function testFindByOrderBy(): void self::assertSame($usersAsc[3], $usersDesc[0]); } - /** - * @group DDC-1376 - */ + /** @group DDC-1376 */ public function testFindByOrderByAssociation(): void { $this->loadFixtureUserEmail(); @@ -550,9 +522,7 @@ public function testFindByOrderByAssociation(): void self::assertEquals($resultAsc[2]->getEmail()->getId(), $resultDesc[0]->getEmail()->getId()); } - /** - * @group DDC-1426 - */ + /** @group DDC-1426 */ public function testFindFieldByMagicCallOrderBy(): void { $this->loadFixture(); @@ -572,9 +542,7 @@ public function testFindFieldByMagicCallOrderBy(): void self::assertSame($usersAsc[1], $usersDesc[0]); } - /** - * @group DDC-1426 - */ + /** @group DDC-1426 */ public function testFindFieldByMagicCallLimitOffset(): void { $this->loadFixture(); @@ -588,9 +556,7 @@ public function testFindFieldByMagicCallLimitOffset(): void self::assertNotSame($users1[0], $users2[0]); } - /** - * @group DDC-753 - */ + /** @group DDC-753 */ public function testDefaultRepositoryClassName(): void { self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); @@ -610,20 +576,16 @@ public function testDefaultRepositoryClassName(): void self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); } - /** - * @group DDC-3257 - */ + /** @group DDC-3257 */ public function testCanRetrieveRepositoryFromClassNameWithLeadingBackslash(): void { self::assertSame( $this->_em->getRepository('\\' . CmsUser::class), - $this->_em->getRepository(CmsUser::class) + $this->_em->getRepository(CmsUser::class), ); } - /** - * @group DDC-1376 - */ + /** @group DDC-1376 */ public function testInvalidOrderByAssociation(): void { $this->expectException(InvalidFindByCall::class); @@ -632,9 +594,7 @@ public function testInvalidOrderByAssociation(): void ->findBy(['status' => 'test'], ['address' => 'ASC']); } - /** - * @group DDC-1500 - */ + /** @group DDC-1500 */ public function testInvalidOrientation(): void { $this->expectException(InvalidOrientation::class); @@ -644,9 +604,7 @@ public function testInvalidOrientation(): void $repo->findBy(['status' => 'test'], ['username' => 'INVALID']); } - /** - * @group DDC-1713 - */ + /** @group DDC-1713 */ public function testFindByAssociationArray(): void { $address1 = new CmsAddress(); @@ -703,9 +661,7 @@ public function testFindByAssociationArray(): void } } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingEmptyCriteria(): void { $this->loadFixture(); @@ -716,129 +672,111 @@ public function testMatchingEmptyCriteria(): void self::assertCount(4, $users); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingCriteriaEqComparison(): void { $this->loadFixture(); $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria( - Criteria::expr()->eq('username', 'beberlei') + Criteria::expr()->eq('username', 'beberlei'), )); self::assertCount(1, $users); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingCriteriaNeqComparison(): void { $this->loadFixture(); $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria( - Criteria::expr()->neq('username', 'beberlei') + Criteria::expr()->neq('username', 'beberlei'), )); self::assertCount(3, $users); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingCriteriaInComparison(): void { $this->loadFixture(); $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria( - Criteria::expr()->in('username', ['beberlei', 'gblanco']) + Criteria::expr()->in('username', ['beberlei', 'gblanco']), )); self::assertCount(2, $users); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingCriteriaNotInComparison(): void { $this->loadFixture(); $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria( - Criteria::expr()->notIn('username', ['beberlei', 'gblanco', 'asm89']) + Criteria::expr()->notIn('username', ['beberlei', 'gblanco', 'asm89']), )); self::assertCount(1, $users); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingCriteriaLtComparison(): void { $firstUserId = $this->loadFixture(); $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria( - Criteria::expr()->lt('id', $firstUserId + 1) + Criteria::expr()->lt('id', $firstUserId + 1), )); self::assertCount(1, $users); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingCriteriaLeComparison(): void { $firstUserId = $this->loadFixture(); $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria( - Criteria::expr()->lte('id', $firstUserId + 1) + Criteria::expr()->lte('id', $firstUserId + 1), )); self::assertCount(2, $users); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingCriteriaGtComparison(): void { $firstUserId = $this->loadFixture(); $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria( - Criteria::expr()->gt('id', $firstUserId) + Criteria::expr()->gt('id', $firstUserId), )); self::assertCount(3, $users); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatchingCriteriaGteComparison(): void { $firstUserId = $this->loadFixture(); $repository = $this->_em->getRepository(CmsUser::class); $users = $repository->matching(new Criteria( - Criteria::expr()->gte('id', $firstUserId) + Criteria::expr()->gte('id', $firstUserId), )); self::assertCount(4, $users); } - /** - * @group DDC-2430 - */ + /** @group DDC-2430 */ public function testMatchingCriteriaAssocationByObjectInMemory(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -846,7 +784,7 @@ public function testMatchingCriteriaAssocationByObjectInMemory(): void $user = $this->_em->find(CmsUser::class, $userId); $criteria = new Criteria( - Criteria::expr()->eq('user', $user) + Criteria::expr()->eq('user', $user), ); $repository = $this->_em->getRepository(CmsAddress::class); @@ -859,9 +797,7 @@ public function testMatchingCriteriaAssocationByObjectInMemory(): void self::assertCount(1, $addresses->matching($criteria)); } - /** - * @group DDC-2430 - */ + /** @group DDC-2430 */ public function testMatchingCriteriaAssocationInWithArray(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -869,7 +805,7 @@ public function testMatchingCriteriaAssocationInWithArray(): void $user = $this->_em->find(CmsUser::class, $userId); $criteria = new Criteria( - Criteria::expr()->in('user', [$user]) + Criteria::expr()->in('user', [$user]), ); $repository = $this->_em->getRepository(CmsAddress::class); @@ -930,9 +866,7 @@ public function testMatchingCriteriaEndsWithComparison(): void self::assertCount(2, $users); } - /** - * @group DDC-2478 - */ + /** @group DDC-2478 */ public function testMatchingCriteriaNullAssocComparison(): void { $fixtures = $this->loadFixtureUserEmail(); @@ -959,9 +893,7 @@ public function testMatchingCriteriaNullAssocComparison(): void self::assertNull($usersEqNull[0]->getEmail()); } - /** - * @group DDC-2055 - */ + /** @group DDC-2055 */ public function testCreateResultSetMappingBuilder(): void { $repository = $this->_em->getRepository(CmsUser::class); @@ -971,9 +903,7 @@ public function testCreateResultSetMappingBuilder(): void self::assertEquals(['u' => CmsUser::class], $rsm->aliasMap); } - /** - * @group DDC-3045 - */ + /** @group DDC-3045 */ public function testFindByFieldInjectionPrevented(): void { $this->expectException(UnrecognizedField::class); @@ -983,9 +913,7 @@ public function testFindByFieldInjectionPrevented(): void $repository->findBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']); } - /** - * @group DDC-3045 - */ + /** @group DDC-3045 */ public function testFindOneByFieldInjectionPrevented(): void { $this->expectException(ORMException::class); @@ -995,9 +923,7 @@ public function testFindOneByFieldInjectionPrevented(): void $repository->findOneBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']); } - /** - * @group DDC-3045 - */ + /** @group DDC-3045 */ public function testMatchingInjectionPrevented(): void { $this->expectException(UnrecognizedField::class); @@ -1005,16 +931,14 @@ public function testMatchingInjectionPrevented(): void $repository = $this->_em->getRepository(CmsUser::class); $result = $repository->matching(new Criteria( - Criteria::expr()->eq('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1', 'beberlei') + Criteria::expr()->eq('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1', 'beberlei'), )); // Because repository returns a lazy collection, we call toArray to force initialization $result->toArray(); } - /** - * @group DDC-3045 - */ + /** @group DDC-3045 */ public function testFindInjectionPrevented(): void { $this->expectException(UnrecognizedIdentifierFields::class); @@ -1024,9 +948,7 @@ public function testFindInjectionPrevented(): void $repository->find(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test', 'id' => 1]); } - /** - * @group DDC-3056 - */ + /** @group DDC-3056 */ public function testFindByNullValueInInCondition(): void { $user1 = new CmsUser(); @@ -1049,9 +971,7 @@ public function testFindByNullValueInInCondition(): void self::assertSame($user1, reset($users)); } - /** - * @group DDC-3056 - */ + /** @group DDC-3056 */ public function testFindByNullValueInMultipleInCriteriaValues(): void { $user1 = new CmsUser(); @@ -1077,9 +997,7 @@ public function testFindByNullValueInMultipleInCriteriaValues(): void self::assertSame($user1, reset($users)); } - /** - * @group DDC-3056 - */ + /** @group DDC-3056 */ public function testFindMultipleByNullValueInMultipleInCriteriaValues(): void { $user1 = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php index 6837c35d832..9cbb0b39bae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php @@ -26,9 +26,7 @@ use function sprintf; use function uniqid; -/** - * @requires PHP 8.1 - */ +/** @requires PHP 8.1 */ class EnumTest extends OrmFunctionalTestCase { public function setUp(): void @@ -230,7 +228,7 @@ public function testEnumWithNonMatchingDatabaseValueThrowsException(string $card $this->_em->getConnection()->update( $metadata->table['name'], [$metadata->fieldMappings['suit']['columnName'] => 'invalid'], - [$metadata->fieldMappings['id']['columnName'] => $card->id] + [$metadata->fieldMappings['id']['columnName'] => $card->id], ); $this->expectException(MappingException::class); @@ -241,15 +239,13 @@ public function testEnumWithNonMatchingDatabaseValueThrowsException(string $card Solution: Either add the case to the enum type or migrate the database column to use another case of the enum EXCEPTION , - $cardClass + $cardClass, )); $this->_em->find($cardClass, $card->id); } - /** - * @return array - */ + /** @return array */ public function provideCardClasses(): array { return [ diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index c72d11448f0..d0cc33d3098 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -21,23 +21,23 @@ */ class ExtraLazyCollectionTest extends OrmFunctionalTestCase { - private ?int $userId = null; + private int|null $userId = null; - private ?int $userId2 = null; + private int|null $userId2 = null; - private ?int $groupId = null; + private int|null $groupId = null; - private ?int $articleId = null; + private int|null $articleId = null; - private ?int $ddc2504OtherClassId = null; + private int|null $ddc2504OtherClassId = null; - private ?int $ddc2504ChildClassId = null; + private int|null $ddc2504ChildClassId = null; - private ?string $username = null; + private string|null $username = null; - private ?string $groupname = null; + private string|null $groupname = null; - private ?string $topic = null; + private string|null $topic = null; /** @var CmsPhonenumber */ private $phonenumber; @@ -120,9 +120,7 @@ public function testCountNotInitializesCollection(): void $this->assertQueryCount(2, 'Expecting two queries to be fired for count, then iteration.'); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testCountWhenNewEntityPresent(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -155,9 +153,7 @@ public function testCountWhenInitialized(): void $this->assertQueryCount(1, 'Should only execute one query to initialize collection, no extra query for count() more.'); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testCountInverseCollection(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); @@ -167,9 +163,7 @@ public function testCountInverseCollection(): void self::assertFalse($group->users->isInitialized(), 'Extra Lazy collection should not be initialized by counting the collection.'); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testCountOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -178,9 +172,7 @@ public function testCountOneToMany(): void self::assertCount(2, $user->articles); } - /** - * @group DDC-2504 - */ + /** @group DDC-2504 */ public function testCountOneToManyJoinedInheritance(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -189,9 +181,7 @@ public function testCountOneToManyJoinedInheritance(): void self::assertCount(2, $otherClass->childClasses); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testFullSlice(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -254,9 +244,7 @@ public function testSliceInitializedCollection(): void self::assertTrue($user->groups->contains(array_shift($someGroups))); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testSliceInverseCollection(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); @@ -275,9 +263,7 @@ public function testSliceInverseCollection(): void $this->assertQueryCount(2, 'Slicing two parts should only execute two additional queries.'); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testSliceOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -291,9 +277,7 @@ public function testSliceOneToMany(): void $this->assertQueryCount(2); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testContainsOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -339,9 +323,7 @@ public function testContainsOneToMany(): void self::assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** - * @group DDC-2504 - */ + /** @group DDC-2504 */ public function testLazyOneToManyJoinedInheritanceIsLazilyInitialized(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -349,9 +331,7 @@ public function testLazyOneToManyJoinedInheritanceIsLazilyInitialized(): void self::assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); } - /** - * @group DDC-2504 - */ + /** @group DDC-2504 */ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWhenMatchingItemIsFound(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -365,9 +345,7 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect $this->assertQueryCount(1, 'Search operation was performed via SQL'); } - /** - * @group DDC-2504 - */ + /** @group DDC-2504 */ public function testContainsOnOneToManyJoinedInheritanceWillNotCauseQueriesWhenNonPersistentItemIsMatched(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -377,9 +355,7 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotCauseQueriesWhenN $this->assertQueryCount(0, 'Checking for contains of new entity should cause no query to be executed.'); } - /** - * @group DDC-2504 - */ + /** @group DDC-2504 */ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithClearStateMatchingItem(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -395,9 +371,7 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect self::assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** - * @group DDC-2504 - */ + /** @group DDC-2504 */ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithNewStateNotMatchingItem(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -412,9 +386,7 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect self::assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** - * @group DDC-2504 - */ + /** @group DDC-2504 */ public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollection(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -424,9 +396,7 @@ public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollect self::assertFalse($otherClass->childClasses->isInitialized()); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testContainsManyToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -473,9 +443,7 @@ public function testContainsManyToMany(): void self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** - * @group DDC-546 - */ + /** @group DDC-546 */ public function testContainsManyToManyInverse(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); @@ -497,9 +465,7 @@ public function testContainsManyToManyInverse(): void self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** - * @group DDC-1399 - */ + /** @group DDC-1399 */ public function testCountAfterAddThenFlush(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -561,9 +527,7 @@ public function testGetIndexByIdentifier(): void $this->assertQueryCount(1, 'Getting the same entity should not cause an extra query to be executed'); } - /** - * @group DDC-1398 - */ + /** @group DDC-1398 */ public function testGetIndexByOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -578,9 +542,7 @@ public function testGetIndexByOneToMany(): void self::assertSame($article, $this->_em->find(CmsArticle::class, $this->articleId)); } - /** - * @group DDC-1398 - */ + /** @group DDC-1398 */ public function testGetIndexByManyToManyInverseSide(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); @@ -595,9 +557,7 @@ public function testGetIndexByManyToManyInverseSide(): void self::assertSame($user, $this->_em->find(CmsUser::class, $this->userId)); } - /** - * @group DDC-1398 - */ + /** @group DDC-1398 */ public function testGetIndexByManyToManyOwningSide(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -612,9 +572,7 @@ public function testGetIndexByManyToManyOwningSide(): void self::assertSame($group, $this->_em->find(CmsGroup::class, $this->groupId)); } - /** - * @group DDC-1398 - */ + /** @group DDC-1398 */ public function testGetNonExistentIndexBy(): void { $user = $this->_em->find(CmsUser::class, $this->userId); diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php index d9ccc262e12..057df54f134 100644 --- a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -48,9 +48,7 @@ public function testPersistNewEntitiesOnPreFlush(): void //$this->_em->flush(); } - /** - * @group DDC-2173 - */ + /** @group DDC-2173 */ public function testPreAndOnFlushCalledAlways(): void { $listener = new OnFlushCalledListener(); diff --git a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php index c7b62ab3a96..6171eab0564 100644 --- a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php @@ -9,9 +9,7 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; -/** - * @group DDC-1766 - */ +/** @group DDC-1766 */ class HydrationCacheTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php index 113604fa6f1..1d1aaee4873 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php @@ -205,9 +205,7 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQue self::assertCount(4, $user3->getPhonenumbers()); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefresh(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php index f03abb5dd7c..ed3e2115b37 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php @@ -11,14 +11,12 @@ use function assert; -/** - * @group DDC-250 - */ +/** @group DDC-250 */ class IndexByAssociationTest extends OrmFunctionalTestCase { - private ?Market $market = null; + private Market|null $market = null; - private ?Bond $bond = null; + private Bond|null $bond = null; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php index cdb427f5d25..48ddd411aa1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php @@ -28,9 +28,7 @@ public function testInsertWithCompositeKey(): void self::assertEquals($childEntity, $entity); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testUpdateWithCompositeKey(): void { $childEntity = new JoinedChildClass(); @@ -54,7 +52,7 @@ private function findEntity(): JoinedChildClass { return $this->_em->find( JoinedRootClass::class, - ['keyPart1' => 'part-1', 'keyPart2' => 'part-2'] + ['keyPart1' => 'part-1', 'keyPart2' => 'part-2'], ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index eac58462cee..6cfb5cfee7f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -44,7 +44,7 @@ protected function setUp(): void LifecycleCallbackEventArgEntity::class, LifecycleCallbackTestEntity::class, LifecycleCallbackTestUser::class, - LifecycleCallbackCascader::class + LifecycleCallbackCascader::class, ); } @@ -113,9 +113,7 @@ public function testChangesDontGetLost(): void self::assertEquals('Hello World', $user2->getValue()); } - /** - * @group DDC-194 - */ + /** @group DDC-194 */ public function testGetReferenceWithPostLoadEventIsDelayedUntilProxyTrigger(): void { $entity = new LifecycleCallbackTestEntity(); @@ -133,9 +131,7 @@ public function testGetReferenceWithPostLoadEventIsDelayedUntilProxyTrigger(): v self::assertTrue($reference->postLoadCallbackInvoked); } - /** - * @group DDC-958 - */ + /** @group DDC-958 */ public function testPostLoadTriggeredOnRefresh(): void { $entity = new LifecycleCallbackTestEntity(); @@ -154,9 +150,7 @@ public function testPostLoadTriggeredOnRefresh(): void self::assertTrue($reference->postLoadCallbackInvoked, 'postLoad should be invoked when refresh() is called.'); } - /** - * @group DDC-113 - */ + /** @group DDC-113 */ public function testCascadedEntitiesCallsPrePersist(): void { $e1 = new LifecycleCallbackTestEntity(); @@ -275,7 +269,7 @@ public function testCascadedEntitiesNotLoadedInPostLoadDuringIterationWithSimple $this->_em->clear(); $query = $this->_em->createQuery( - 'SELECT e FROM Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity AS e' + 'SELECT e FROM Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity AS e', ); $result = iterator_to_array($query->toIterable([], Query::HYDRATE_SIMPLEOBJECT)); @@ -361,9 +355,7 @@ public function testLifecycleListenerChangeUpdateChangeSet(): void self::assertEquals('Bob', $bob->getName()); } - /** - * @group DDC-1955 - */ + /** @group DDC-1955 */ public function testLifecycleCallbackEventArgs(): void { $e = new LifecycleCallbackEventArgEntity(); @@ -415,10 +407,10 @@ class LifecycleCallbackTestUser private int $id; /** @Column(type="string", length=255) */ - private ?string $value = null; + private string|null $value = null; /** @Column(type="string", length=255) */ - private ?string $name = null; + private string|null $name = null; public function getId(): int { @@ -640,65 +632,49 @@ class LifecycleCallbackEventArgEntity /** @var array */ public $calls = []; - /** - * @PostPersist - */ + /** @PostPersist */ public function postPersistHandler(LifecycleEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** - * @PrePersist - */ + /** @PrePersist */ public function prePersistHandler(LifecycleEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** - * @PostUpdate - */ + /** @PostUpdate */ public function postUpdateHandler(LifecycleEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** - * @PreUpdate - */ + /** @PreUpdate */ public function preUpdateHandler(PreUpdateEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** - * @PostRemove - */ + /** @PostRemove */ public function postRemoveHandler(LifecycleEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** - * @PreRemove - */ + /** @PreRemove */ public function preRemoveHandler(LifecycleEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** - * @PreFlush - */ + /** @PreFlush */ public function preFlushHandler(PreFlushEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** - * @PostLoad - */ + /** @PostLoad */ public function postLoadHandler(LifecycleEventArgs $event): void { $this->calls[__FUNCTION__] = $event; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php index 482c769eec5..3f0ce6a0c8a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php @@ -13,12 +13,10 @@ use function max; use function serialize; -/** - * @group locking_functional - */ +/** @group locking_functional */ class GearmanLockTest extends OrmFunctionalTestCase { - private ?GearmanClient $gearman = null; + private GearmanClient|null $gearman = null; private int $maxRunTime = 0; @@ -37,7 +35,7 @@ protected function setUp(): void $this->gearman = new GearmanClient(); $this->gearman->addServer( $_SERVER['GEARMAN_HOST'] ?? null, - $_SERVER['GEARMAN_PORT'] ?? 4730 + $_SERVER['GEARMAN_PORT'] ?? 4730, ); $this->gearman->setCompleteCallback([$this, 'gearmanTaskCompleted']); @@ -144,12 +142,12 @@ protected function assertLockWorked($forTime = 2, $notLongerThan = null): void self::assertTrue( $this->maxRunTime > $forTime, 'Because of locking this tests should have run at least ' . $forTime . ' seconds, ' . - 'but only did for ' . $this->maxRunTime . ' seconds.' + 'but only did for ' . $this->maxRunTime . ' seconds.', ); self::assertTrue( $this->maxRunTime < $notLongerThan, 'The longest task should not run longer than ' . $notLongerThan . ' seconds, ' . - 'but did for ' . $this->maxRunTime . ' seconds.' + 'but did for ' . $this->maxRunTime . ' seconds.', ); } @@ -186,7 +184,7 @@ protected function startJob($fn, $fixture): void [ 'conn' => $this->_em->getConnection()->getParams(), 'fixture' => $fixture, - ] + ], )); self::assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php index 9024466d9f0..3000341ffed 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php @@ -23,7 +23,7 @@ class LockAgentWorker { - private ?EntityManagerInterface $em = null; + private EntityManagerInterface|null $em = null; public static function run(): void { @@ -32,7 +32,7 @@ public static function run(): void $worker = new GearmanWorker(); $worker->addServer( $_SERVER['GEARMAN_HOST'] ?? null, - $_SERVER['GEARMAN_PORT'] ?? 4730 + $_SERVER['GEARMAN_PORT'] ?? 4730, ); $worker->addFunction('findWithLock', [$lockAgent, 'findWithLock']); $worker->addFunction('dqlWithLock', [$lockAgent, 'dqlWithLock']); @@ -89,9 +89,7 @@ public function lock($job): float }); } - /** - * @return mixed[] - */ + /** @return mixed[] */ protected function processWorkload($job): array { echo 'Received job: ' . $job->handle() . ' for function ' . $job->functionName() . "\n"; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index 1cc0ec5b3e9..73d44eaf48a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -14,9 +14,7 @@ use Exception; use InvalidArgumentException; -/** - * @group locking - */ +/** @group locking */ class LockTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -182,9 +180,7 @@ public function testLockPessimisticWrite(): void self::assertStringContainsString($writeLockSql, $lastLoggedQuery); } - /** - * @group DDC-178 - */ + /** @group DDC-178 */ public function testLockPessimisticRead(): void { $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSQL(); @@ -218,9 +214,7 @@ public function testLockPessimisticRead(): void self::assertStringContainsString($readLockSql, $lastLoggedQuery); } - /** - * @group DDC-1693 - */ + /** @group DDC-1693 */ public function testLockOptimisticNonVersionedThrowsExceptionInDQL(): void { $dql = 'SELECT u FROM ' . CmsUser::class . " u WHERE u.username = 'gblanco'"; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index 072d2f6fb17..9f53b90ebdc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -38,7 +38,7 @@ private function createSchema(): void OptimisticJoinedParent::class, OptimisticJoinedChild::class, OptimisticStandard::class, - OptimisticTimestamp::class + OptimisticTimestamp::class, ); } @@ -58,9 +58,7 @@ public function testJoinedChildInsertSetsInitialVersionValue(): OptimisticJoined return $test; } - /** - * @depends testJoinedChildInsertSetsInitialVersionValue - */ + /** @depends testJoinedChildInsertSetsInitialVersionValue */ public function testJoinedChildFailureThrowsException(OptimisticJoinedChild $child): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild t WHERE t.id = :id'); @@ -99,9 +97,7 @@ public function testJoinedParentInsertSetsInitialVersionValue(): OptimisticJoine return $test; } - /** - * @depends testJoinedParentInsertSetsInitialVersionValue - */ + /** @depends testJoinedParentInsertSetsInitialVersionValue */ public function testJoinedParentFailureThrowsException(OptimisticJoinedParent $parent): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent t WHERE t.id = :id'); @@ -159,9 +155,7 @@ public function testStandardInsertSetsInitialVersionValue(): OptimisticStandard return $test; } - /** - * @depends testStandardInsertSetsInitialVersionValue - */ + /** @depends testStandardInsertSetsInitialVersionValue */ public function testStandardFailureThrowsException(OptimisticStandard $entity): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard t WHERE t.id = :id'); @@ -219,9 +213,7 @@ public function testOptimisticTimestampSetsDefaultValue(): OptimisticTimestamp return $test; } - /** - * @depends testOptimisticTimestampSetsDefaultValue - */ + /** @depends testOptimisticTimestampSetsDefaultValue */ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestamp $entity): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id'); @@ -251,9 +243,7 @@ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestam self::assertSame($test, $caughtException->getEntity()); } - /** - * @depends testOptimisticTimestampSetsDefaultValue - */ + /** @depends testOptimisticTimestampSetsDefaultValue */ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTimestamp $entity): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id'); @@ -270,7 +260,7 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime try { $expectedVersionExpired = DateTime::createFromFormat( 'U', - (string) ($test->version->getTimestamp() - 3600) + (string) ($test->version->getTimestamp() - 3600), ); $this->_em->lock($test, LockMode::OPTIMISTIC, $expectedVersionExpired); diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php index 30c2bc33be6..707d692dff9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -172,7 +172,7 @@ public function assertGblancoGroupCountIs(int $expectedGroupCount): void self::assertEquals( $expectedGroupCount, $this->_em->createQuery($countDql)->getSingleScalarResult(), - "Failed to verify that CmsUser with username 'gblanco' has a group count of 10 with a DQL count query." + "Failed to verify that CmsUser with username 'gblanco' has a group count of 10 with a DQL count query.", ); } @@ -207,9 +207,7 @@ public function testRetrieveManyToManyAndAddMore(): void self::assertCount(3, $freshUser->getGroups()); } - /** - * @group DDC-130 - */ + /** @group DDC-130 */ public function testRemoveUserWithManyGroups(): void { $user = $this->addCmsUserGblancoWithGroups(2); @@ -222,9 +220,7 @@ public function testRemoveUserWithManyGroups(): void self::assertNull($newUser); } - /** - * @group DDC-130 - */ + /** @group DDC-130 */ public function testRemoveGroupWithUser(): void { $user = $this->addCmsUserGblancoWithGroups(2); @@ -252,9 +248,7 @@ public function testDereferenceCollectionDelete(): void self::assertCount(0, $newUser->getGroups()); } - /** - * @group DDC-839 - */ + /** @group DDC-839 */ public function testWorkWithDqlHydratedEmptyCollection(): void { $user = $this->addCmsUserGblancoWithGroups(0); @@ -301,9 +295,7 @@ public function addCmsUserGblancoWithGroups(int $groupCount = 1): CmsUser return $user; } - /** - * @group DDC-978 - */ + /** @group DDC-978 */ public function testClearAndResetCollection(): void { $user = $this->addCmsUserGblancoWithGroups(2); @@ -325,7 +317,7 @@ public function testClearAndResetCollection(): void self::assertInstanceOf( PersistentCollection::class, $user->groups, - 'UnitOfWork should have replaced ArrayCollection with PersistentCollection.' + 'UnitOfWork should have replaced ArrayCollection with PersistentCollection.', ); $this->_em->flush(); @@ -337,9 +329,7 @@ public function testClearAndResetCollection(): void self::assertEquals('Developers_New2', $user->groups[1]->name); } - /** - * @group DDC-733 - */ + /** @group DDC-733 */ public function testInitializePersistentCollection(): void { $user = $this->addCmsUserGblancoWithGroups(2); @@ -372,9 +362,7 @@ public function testClearBeforeLazyLoad(): void self::assertCount(0, $user->groups); } - /** - * @group DDC-3952 - */ + /** @group DDC-3952 */ public function testManyToManyOrderByIsNotIgnored(): void { $user = $this->addCmsUserGblancoWithGroups(1); @@ -407,13 +395,11 @@ public function testManyToManyOrderByIsNotIgnored(): void ->getGroups() ->matching($criteria) ->map(static fn (CmsGroup $group) => $group->getName()) - ->toArray() + ->toArray(), ); } - /** - * @group DDC-3952 - */ + /** @group DDC-3952 */ public function testManyToManyOrderByHonorsFieldNameColumnNameAliases(): void { $user = new CmsUser(); @@ -449,7 +435,7 @@ public function testManyToManyOrderByHonorsFieldNameColumnNameAliases(): void ->getTags() ->matching($criteria) ->map(static fn (CmsTag $tag) => $tag->getName()) - ->toArray() + ->toArray(), ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php index 0fe632e6e05..63353457d7c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php @@ -100,9 +100,7 @@ private function createLoadingFixture(): void $this->_em->clear(); } - /** - * @psalm-return list - */ + /** @psalm-return list */ protected function findProducts(): array { $query = $this->_em->createQuery('SELECT p, c FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p LEFT JOIN p.categories c ORDER BY p.id, c.id'); @@ -119,9 +117,7 @@ protected function findProducts(): array return $result; } - /** - * @psalm-return list - */ + /** @psalm-return list */ protected function findCategories(): array { $query = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\ECommerce\ECommerceCategory c LEFT JOIN c.products p ORDER BY c.id, p.id'); @@ -141,9 +137,7 @@ protected function findCategories(): array return $result; } - /** - * @psalm-param list - */ + /** @psalm-param list */ public function assertLazyLoadFromInverseSide(array $products): void { [$firstProduct, $secondProduct] = $products; @@ -179,9 +173,7 @@ public function assertLazyLoadFromInverseSide(array $products): void $this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts); } - /** - * @psalm-param list - */ + /** @psalm-param list */ public function assertLazyLoadFromOwningSide(array $categories): void { [$firstCategory, $secondCategory] = $categories; diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php index 2131d705273..fc67c11d35a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php @@ -52,11 +52,11 @@ public function testSavesAManyToManyAssociationWithCascadeSaveSet(): void $this->assertForeignKeysContain( $this->firstProduct->getId(), - $this->firstRelated->getId() + $this->firstRelated->getId(), ); $this->assertForeignKeysContain( $this->firstProduct->getId(), - $this->secondRelated->getId() + $this->secondRelated->getId(), ); } @@ -71,11 +71,11 @@ public function testRemovesAManyToManyAssociation(): void $this->assertForeignKeysNotContain( $this->firstProduct->getId(), - $this->firstRelated->getId() + $this->firstRelated->getId(), ); $this->assertForeignKeysContain( $this->firstProduct->getId(), - $this->secondRelated->getId() + $this->secondRelated->getId(), ); } @@ -98,9 +98,7 @@ public function testLazyLoadsOwningSide(): void $this->assertLoadingOfOwningSide($products); } - /** - * @psalm-param list $products - */ + /** @psalm-param list $products */ public function assertLoadingOfOwningSide(array $products): void { [$firstProduct, $secondProduct] = $products; @@ -135,9 +133,7 @@ protected function createLoadingFixture(): void $this->_em->clear(); } - /** - * @psalm-return list - */ + /** @psalm-return list */ protected function findProducts(): array { $query = $this->_em->createQuery('SELECT p, r FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p LEFT JOIN p.related r ORDER BY p.id, r.id'); diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php index 1e9ed4a0049..58659fc1845 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php @@ -69,14 +69,14 @@ public function testOrphanRemovalIsPurelyOrnemental(): void $this->_em->clear(); $query = $this->_em->createQuery( - 'SELECT u FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\Person u' + 'SELECT u FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\Person u', ); $result = $query->getResult(); self::assertEquals(0, count($result), 'Person should be removed by EntityManager'); $query = $this->_em->createQuery( - 'SELECT p FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\PhoneNumber p' + 'SELECT p FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\PhoneNumber p', ); $result = $query->getResult(); @@ -84,11 +84,11 @@ public function testOrphanRemovalIsPurelyOrnemental(): void } protected function getEntityManager( - ?Connection $connection = null, - ?MappingDriver $mappingDriver = null + Connection|null $connection = null, + MappingDriver|null $mappingDriver = null, ): EntityManagerInterface { return parent::getEntityManager($connection, new XmlDriver( - __DIR__ . DIRECTORY_SEPARATOR . 'xml' + __DIR__ . DIRECTORY_SEPARATOR . 'xml', )); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 8157eb30fc0..c4410122d3d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -31,7 +31,7 @@ class NativeQueryTest extends OrmFunctionalTestCase use SQLResultCasing; use VerifyDeprecations; - private ?AbstractPlatform $platform = null; + private AbstractPlatform|null $platform = null; protected function setUp(): void { @@ -313,9 +313,7 @@ public function testJoinedOneToOneNativeQueryWithRSMBuilder(): void self::assertEquals($user->name, $address->getUser()->getName()); } - /** - * @group rsm-sti - */ + /** @group rsm-sti */ public function testConcreteClassInSingleTableInheritanceSchemaWithRSMBuilderIsFine(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -324,9 +322,7 @@ public function testConcreteClassInSingleTableInheritanceSchemaWithRSMBuilderIsF self::assertSame(CompanyFixContract::class, $rsm->getClassName('c')); } - /** - * @group rsm-sti - */ + /** @group rsm-sti */ public function testAbstractClassInSingleTableInheritanceSchemaWithRSMBuilderThrowsException(): void { $this->expectException(InvalidArgumentException::class); @@ -344,9 +340,7 @@ public function testRSMBuilderThrowsExceptionOnColumnConflict(): void $rsm->addJoinedEntityFromClassMetadata(CmsAddress::class, 'a', 'u', 'address'); } - /** - * @group PR-39 - */ + /** @group PR-39 */ public function testUnknownParentAliasThrowsException(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -362,9 +356,7 @@ public function testUnknownParentAliasThrowsException(): void $users = $query->getResult(); } - /** - * @group DDC-2055 - */ + /** @group DDC-2055 */ public function testGenerateSelectClauseNoRenameSingleEntity(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -375,9 +367,7 @@ public function testGenerateSelectClauseNoRenameSingleEntity(): void $this->assertSQLEquals('u.id AS id, u.status AS status, u.username AS username, u.name AS name, u.email_id AS email_id', $selectClause); } - /** - * @group DDC-2055 - */ + /** @group DDC-2055 */ public function testGenerateSelectClauseCustomRenames(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -391,9 +381,7 @@ public function testGenerateSelectClauseCustomRenames(): void $this->assertSQLEquals('u.id AS id1, u.status AS status, u.username AS username2, u.name AS name, u.email_id AS email_id', $selectClause); } - /** - * @group DDC-2055 - */ + /** @group DDC-2055 */ public function testGenerateSelectClauseRenameTableAlias(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -404,9 +392,7 @@ public function testGenerateSelectClauseRenameTableAlias(): void $this->assertSQLEquals('u1.id AS id, u1.status AS status, u1.username AS username, u1.name AS name, u1.email_id AS email_id', $selectClause); } - /** - * @group DDC-2055 - */ + /** @group DDC-2055 */ public function testGenerateSelectClauseIncrement(): void { $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); @@ -417,9 +403,7 @@ public function testGenerateSelectClauseIncrement(): void $this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', $selectClause); } - /** - * @group DDC-2055 - */ + /** @group DDC-2055 */ public function testGenerateSelectClauseToString(): void { $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); @@ -428,9 +412,7 @@ public function testGenerateSelectClauseToString(): void $this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', (string) $rsm); } - /** - * @group DDC-3899 - */ + /** @group DDC-3899 */ public function testGenerateSelectClauseWithDiscriminatorColumn(): void { $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php index 044542eede5..61d9f136185 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php @@ -16,9 +16,7 @@ use function count; -/** - * @group DDC-1574 - */ +/** @group DDC-1574 */ class NewOperatorTest extends OrmFunctionalTestCase { /** @var list */ @@ -32,9 +30,7 @@ protected function setUp(): void $this->loadFixtures(); } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function provideDataForHydrationMode(): array { return [ @@ -104,9 +100,7 @@ private function loadFixtures(): void $this->fixtures = [$u1, $u2, $u3]; } - /** - * @dataProvider provideDataForHydrationMode - */ + /** @dataProvider provideDataForHydrationMode */ public function testShouldSupportsBasicUsage($hydrationMode): void { $dql = ' @@ -147,9 +141,7 @@ public function testShouldSupportsBasicUsage($hydrationMode): void self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); } - /** - * @dataProvider provideDataForHydrationMode - */ + /** @dataProvider provideDataForHydrationMode */ public function testShouldIgnoreAliasesForSingleObject($hydrationMode): void { $dql = ' @@ -349,17 +341,17 @@ public function testShouldSupportSimpleArithmeticExpression(): void self::assertEquals( $this->fixtures[0]->address->id + $this->fixtures[0]->id, - $result[0]->phonenumbers + $result[0]->phonenumbers, ); self::assertEquals( $this->fixtures[1]->address->id + $this->fixtures[1]->id, - $result[1]->phonenumbers + $result[1]->phonenumbers, ); self::assertEquals( $this->fixtures[2]->address->id + $this->fixtures[2]->id, - $result[2]->phonenumbers + $result[2]->phonenumbers, ); } @@ -409,17 +401,17 @@ public function testShouldSupportAggregateFunctions(): void self::assertEquals( count($this->fixtures[0]->phonenumbers), - $result[0]->phonenumbers + $result[0]->phonenumbers, ); self::assertEquals( count($this->fixtures[1]->phonenumbers), - $result[1]->phonenumbers + $result[1]->phonenumbers, ); self::assertEquals( count($this->fixtures[2]->phonenumbers), - $result[2]->phonenumbers + $result[2]->phonenumbers, ); } @@ -469,17 +461,17 @@ public function testShouldSupportArithmeticExpression(): void self::assertEquals( count($this->fixtures[0]->phonenumbers) + $this->fixtures[0]->id, - $result[0]->phonenumbers + $result[0]->phonenumbers, ); self::assertEquals( count($this->fixtures[1]->phonenumbers) + $this->fixtures[1]->id, - $result[1]->phonenumbers + $result[1]->phonenumbers, ); self::assertEquals( count($this->fixtures[2]->phonenumbers) + $this->fixtures[2]->id, - $result[2]->phonenumbers + $result[2]->phonenumbers, ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index d6605761609..0d5abf93128 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -128,7 +128,7 @@ class NotifyUser extends NotifyBaseEntity private int $id; /** @Column */ - private ?string $name = null; + private string|null $name = null; /** * @psalm-var Collection @@ -157,9 +157,7 @@ public function setName(string $name): void $this->name = $name; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getGroups(): Collection { return $this->groups; @@ -177,7 +175,7 @@ class NotifyGroup extends NotifyBaseEntity private int $id; /** @Column */ - private ?string $name = null; + private string|null $name = null; /** * @psalm-var Collection @@ -206,9 +204,7 @@ public function setName(string $name): void $this->name = $name; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getUsers(): Collection { return $this->users; diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index 447d3baa661..d1b1d976707 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -155,9 +155,7 @@ public function testJoinFromOwningSide(): void self::assertCount(0, $features); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testMatching(): void { $this->createFixture(); @@ -166,7 +164,7 @@ public function testMatching(): void $features = $product->getFeatures(); $results = $features->matching(new Criteria( - Criteria::expr()->eq('description', 'Model writing tutorial') + Criteria::expr()->eq('description', 'Model writing tutorial'), )); self::assertInstanceOf(Collection::class, $results); @@ -178,9 +176,7 @@ public function testMatching(): void self::assertCount(2, $results); } - /** - * @group DDC-2340 - */ + /** @group DDC-2340 */ public function testMatchingOnDirtyCollection(): void { $this->createFixture(); @@ -194,7 +190,7 @@ public function testMatchingOnDirtyCollection(): void $features->add($thirdFeature); $results = $features->matching(new Criteria( - Criteria::expr()->eq('description', 'Model writing tutorial') + Criteria::expr()->eq('description', 'Model writing tutorial'), )); self::assertCount(2, $results); @@ -212,7 +208,7 @@ public function testMatchingBis(): void $product->addFeature($thirdFeature); $results = $features->matching(new Criteria( - Criteria::expr()->eq('description', 'Third feature') + Criteria::expr()->eq('description', 'Third feature'), )); self::assertInstanceOf(Collection::class, $results); @@ -238,7 +234,7 @@ public function assertFeatureForeignKeyIs($value, ECommerceFeature $feature): vo { $foreignKey = $this->_em->getConnection()->executeQuery( 'SELECT product_id FROM ecommerce_features WHERE id=?', - [$feature->getId()] + [$feature->getId()], )->fetchOne(); self::assertEquals($value, $foreignKey); } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php index a3ee90a6b74..232946f5e94 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php @@ -62,9 +62,7 @@ public function testOrphanRemoval(): void self::assertCount(0, $result, 'CmsPhonenumber should be removed by orphanRemoval'); } - /** - * @group DDC-3382 - */ + /** @group DDC-3382 */ public function testOrphanRemovalRemoveFromCollection(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -80,9 +78,7 @@ public function testOrphanRemovalRemoveFromCollection(): void self::assertCount(1, $result, 'CmsPhonenumber should be removed by orphanRemoval'); } - /** - * @group DDC-3382 - */ + /** @group DDC-3382 */ public function testOrphanRemovalClearCollectionAndReAdd(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -100,9 +96,7 @@ public function testOrphanRemovalClearCollectionAndReAdd(): void self::assertCount(1, $result, 'CmsPhonenumber should be removed by orphanRemoval'); } - /** - * @group DDC-2524 - */ + /** @group DDC-2524 */ public function testOrphanRemovalClearCollectionAndAddNew(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -121,9 +115,7 @@ public function testOrphanRemovalClearCollectionAndAddNew(): void self::assertCount(1, $result, 'Old CmsPhonenumbers should be removed by orphanRemoval and new one added'); } - /** - * @group DDC-1496 - */ + /** @group DDC-1496 */ public function testOrphanRemovalUnitializedCollection(): void { $user = $this->_em->find(CmsUser::class, $this->userId); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php index c0695cf0375..066a3b7bb72 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php @@ -53,7 +53,7 @@ public function testPersistOwningInverseCascade(): void $routes = $this->_em->createQuery( 'SELECT r, l, f, t FROM Doctrine\Tests\Models\Routing\RoutingRoute r ' . - 'JOIN r.legs l JOIN l.fromLocation f JOIN l.toLocation t' + 'JOIN r.legs l JOIN l.fromLocation f JOIN l.toLocation t', )->getSingleResult(); self::assertCount(1, $routes->legs); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 22997f59ce5..a892b04718c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -17,9 +17,7 @@ use Doctrine\ORM\Proxy\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-952 - */ +/** @group DDC-952 */ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -30,13 +28,11 @@ protected function setUp(): void TrainDriver::class, TrainOwner::class, Waggon::class, - TrainOrder::class + TrainOrder::class, ); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testEagerLoadOneToOneOwningSide(): void { $train = new Train(new TrainOwner('Alexander')); @@ -59,9 +55,7 @@ public function testEagerLoadOneToOneOwningSide(): void $this->assertQueryCount(1); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testEagerLoadOneToOneNullOwningSide(): void { $train = new Train(new TrainOwner('Alexander')); @@ -79,9 +73,7 @@ public function testEagerLoadOneToOneNullOwningSide(): void $this->assertQueryCount(1); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testEagerLoadOneToOneInverseSide(): void { $owner = new TrainOwner('Alexander'); @@ -100,9 +92,7 @@ public function testEagerLoadOneToOneInverseSide(): void $this->assertQueryCount(1); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testEagerLoadOneToOneNullInverseSide(): void { $driver = new TrainDriver('Dagny Taggert'); @@ -137,9 +127,7 @@ public function testEagerLoadManyToOne(): void self::assertNotNull($waggon->train); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testEagerLoadWithNullableColumnsGeneratesLeftJoinOnBothSides(): void { $train = new Train(new TrainOwner('Alexander')); @@ -162,9 +150,7 @@ public function testEagerLoadWithNullableColumnsGeneratesLeftJoinOnBothSides(): self::assertSame($driverId, $driver->id); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testEagerLoadWithNonNullableColumnsGeneratesInnerJoinOnOwningSide(): void { $waggon = new Waggon(); @@ -182,19 +168,17 @@ public function testEagerLoadWithNonNullableColumnsGeneratesInnerJoinOnOwningSid // The last query is the eager loading of the owner of the train $this->assertSQLEquals( 'SELECT t0.id AS id_1, t0.name AS name_2, t3.id AS id_4, t3.driver_id AS driver_id_5, t3.owner_id AS owner_id_6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id IN (?)', - $this->getLastLoggedQuery()['sql'] + $this->getLastLoggedQuery()['sql'], ); // The one before is the fetching of the waggon and train $this->assertSQLEquals( 'SELECT t0.id AS id_1, t0.train_id AS train_id_2, t3.id AS id_4, t3.driver_id AS driver_id_5, t3.owner_id AS owner_id_6 FROM Waggon t0 INNER JOIN Train t3 ON t0.train_id = t3.id WHERE t0.id = ?', - $this->getLastLoggedQuery(1)['sql'] + $this->getLastLoggedQuery(1)['sql'], ); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningSide(): void { $owner = new TrainOwner('Alexander'); @@ -206,9 +190,7 @@ public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningS self::assertNotNull($owner, 'An owner without a train should be able to exist.'); } - /** - * @group DDC-1946 - */ + /** @group DDC-1946 */ public function testEagerLoadingDoesNotBreakRefresh(): void { $train = new Train(new TrainOwner('Johannes')); @@ -225,9 +207,7 @@ public function testEagerLoadingDoesNotBreakRefresh(): void } } -/** - * @Entity - */ +/** @Entity */ class Train { /** @@ -287,9 +267,7 @@ public function addWaggon(Waggon $w): void } } -/** - * @Entity - */ +/** @Entity */ class TrainDriver { /** @@ -309,10 +287,8 @@ class TrainDriver public $train; public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } @@ -322,9 +298,7 @@ public function setTrain(Train $t): void } } -/** - * @Entity - */ +/** @Entity */ class TrainOwner { /** @@ -344,10 +318,8 @@ class TrainOwner public $train; public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } @@ -357,9 +329,7 @@ public function setTrain(Train $t): void } } -/** - * @Entity - */ +/** @Entity */ class Waggon { /** @@ -382,9 +352,7 @@ public function setTrain($train): void } } -/** - * @Entity - */ +/** @Entity */ class TrainOrder { /** @@ -396,11 +364,8 @@ class TrainOrder public $id; public function __construct( - /** - * @var Train - * @OneToOne(targetEntity="Train", fetch="EAGER") - */ - public $train + /** @OneToOne(targetEntity="Train", fetch="EAGER") */ + public Train $train, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php index 763e64dd01d..911a86f44c9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php @@ -19,9 +19,7 @@ protected function setUp(): void $this->createSchemaForModels(OwningSide::class, InverseSide::class); } - /** - * @group GH-6759 - */ + /** @group GH-6759 */ public function testInverseSideOneToOneLoadedAfterDqlQuery(): void { $owner = new OwningSide(); @@ -53,12 +51,12 @@ public function testInverseSideOneToOneLoadedAfterDqlQuery(): void $this->assertSQLEquals( 'select o0_.id as id_0 from one_to_one_inverse_side_load_inverse o0_ where o0_.id = ?', - $this->getLastLoggedQuery(1)['sql'] + $this->getLastLoggedQuery(1)['sql'], ); $this->assertSQLEquals( 'select t0.id as id_1, t0.inverse as inverse_2 from one_to_one_inverse_side_load_owning t0 WHERE t0.inverse = ?', - $this->getLastLoggedQuery()['sql'] + $this->getLastLoggedQuery()['sql'], ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index 77c3c1e8495..16bd557b184 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -76,9 +76,7 @@ public function testEagerLoadsAssociation(): void $this->assertLoadingOfAssociation($customer); } - /** - * @group mine - */ + /** @group mine */ public function testLazyLoadsAssociation(): void { $this->createFixture(); @@ -143,9 +141,7 @@ private function createFixture(): int } } -/** - * @Entity - */ +/** @Entity */ class MultiSelfReference { /** @@ -159,13 +155,13 @@ class MultiSelfReference * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) * @JoinColumn(name="other1", referencedColumnName="id") */ - private ?MultiSelfReference $other1 = null; + private MultiSelfReference|null $other1 = null; /** * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) * @JoinColumn(name="other2", referencedColumnName="id") */ - private ?MultiSelfReference $other2 = null; + private MultiSelfReference|null $other2 = null; public function getId(): int { @@ -177,7 +173,7 @@ public function setOther1(MultiSelfReference $other1): void $this->other1 = $other1; } - public function getOther1(): ?MultiSelfReference + public function getOther1(): MultiSelfReference|null { return $this->other1; } @@ -187,7 +183,7 @@ public function setOther2(MultiSelfReference $other2): void $this->other2 = $other2; } - public function getOther2(): ?MultiSelfReference + public function getOther2(): MultiSelfReference|null { return $this->other2; } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php index b433be59d65..1eb8b62448a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php @@ -20,7 +20,7 @@ protected function setUp(): void $this->createSchemaForModels( Pet::class, Cat::class, - LitterBox::class + LitterBox::class, ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index 527b7bf9109..696f9a2c3b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -107,14 +107,12 @@ public function assertForeignKeyIs($value): void { $foreignKey = $this->_em->getConnection()->executeQuery( 'SELECT shipping_id FROM ecommerce_products WHERE id=?', - [$this->product->getId()] + [$this->product->getId()], )->fetchOne(); self::assertEquals($value, $foreignKey); } - /** - * @group DDC-762 - */ + /** @group DDC-762 */ public function testNullForeignKey(): void { $product = new ECommerceProduct(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php index 486805741cf..983ec1cdb80 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php @@ -30,7 +30,7 @@ protected function setUp(): void $this->createSchemaForModels( OJTICPet::class, OJTICCat::class, - OJTICDog::class + OJTICDog::class, ); $dog = new OJTICDog(); @@ -64,7 +64,7 @@ public function testOrderdOneToManyCollection(): void $this->_em->clear(); $result = $this->_em->createQuery( - "SELECT p, c FROM Doctrine\Tests\ORM\Functional\OJTICPet p JOIN p.children c WHERE p.name = 'Poofy'" + "SELECT p, c FROM Doctrine\Tests\ORM\Functional\OJTICPet p JOIN p.children c WHERE p.name = 'Poofy'", ) ->getResult(); @@ -129,16 +129,12 @@ public function getName(): string } } -/** - * @Entity - */ +/** @Entity */ class OJTICCat extends OJTICPet { } -/** - * @Entity - */ +/** @Entity */ class OJTICDog extends OJTICPet { } diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index 1aa0d4ccd42..7a5ac2b9e37 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -35,9 +35,7 @@ use function iterator_to_array; use function sprintf; -/** - * @group DDC-1613 - */ +/** @group DDC-1613 */ class PaginationTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -57,9 +55,7 @@ protected function setUp(): void $this->populate(); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testCountSimpleWithoutJoin($useOutputWalkers): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'; @@ -70,9 +66,7 @@ public function testCountSimpleWithoutJoin($useOutputWalkers): void self::assertCount(9, $paginator); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testCountWithFetchJoin($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'; @@ -107,9 +101,7 @@ public function testCountComplexWithoutOutputWalker(): void self::assertCount(3, $paginator); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testCountWithComplexScalarOrderBy($useOutputWalkers): void { $dql = 'SELECT l FROM Doctrine\Tests\Models\Pagination\Logo l ORDER BY l.imageWidth * l.imageHeight DESC'; @@ -120,9 +112,7 @@ public function testCountWithComplexScalarOrderBy($useOutputWalkers): void self::assertCount(9, $paginator); } - /** - * @dataProvider useOutputWalkersAndFetchJoinCollection - */ + /** @dataProvider useOutputWalkersAndFetchJoinCollection */ public function testIterateSimpleWithoutJoin($useOutputWalkers, $fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'; @@ -234,9 +224,7 @@ private function iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetc self::assertEquals($checkField . '5', $result[0]->$checkField); } - /** - * @dataProvider useOutputWalkersAndFetchJoinCollection - */ + /** @dataProvider useOutputWalkersAndFetchJoinCollection */ public function testIterateSimpleWithoutJoinWithOrder($useOutputWalkers, $fetchJoinCollection): void { // Ascending @@ -245,9 +233,7 @@ public function testIterateSimpleWithoutJoinWithOrder($useOutputWalkers, $fetchJ $this->iterateWithOrderDesc($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** - * @dataProvider useOutputWalkersAndFetchJoinCollection - */ + /** @dataProvider useOutputWalkersAndFetchJoinCollection */ public function testIterateSimpleWithoutJoinWithOrderAndLimit($useOutputWalkers, $fetchJoinCollection): void { // Ascending @@ -256,9 +242,7 @@ public function testIterateSimpleWithoutJoinWithOrderAndLimit($useOutputWalkers, $this->iterateWithOrderDescWithLimit($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** - * @dataProvider useOutputWalkersAndFetchJoinCollection - */ + /** @dataProvider useOutputWalkersAndFetchJoinCollection */ public function testIterateSimpleWithoutJoinWithOrderAndLimitAndOffset($useOutputWalkers, $fetchJoinCollection): void { // Ascending @@ -267,9 +251,7 @@ public function testIterateSimpleWithoutJoinWithOrderAndLimitAndOffset($useOutpu $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrder($fetchJoinCollection): void { // Ascending @@ -278,9 +260,7 @@ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrder($fe $this->iterateWithOrderDesc(true, $fetchJoinCollection, $dql, 'image'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrderAndLimit($fetchJoinCollection): void { // Ascending @@ -289,9 +269,7 @@ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrderAndL $this->iterateWithOrderDescWithLimit(true, $fetchJoinCollection, $dql, 'image'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrderAndLimitAndOffset($fetchJoinCollection): void { // Ascending @@ -300,9 +278,7 @@ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrderAndL $this->iterateWithOrderDescWithLimitAndOffset(true, $fetchJoinCollection, $dql, 'image'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoin($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'; @@ -313,9 +289,7 @@ public function testIterateWithFetchJoin($useOutputWalkers): void self::assertCount(9, $paginator->getIterator()); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinWithOrder($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g ORDER BY u.username'; @@ -323,9 +297,7 @@ public function testIterateWithFetchJoinWithOrder($useOutputWalkers): void $this->iterateWithOrderDesc($useOutputWalkers, true, $dql, 'username'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinWithOrderAndLimit($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g ORDER BY u.username'; @@ -333,9 +305,7 @@ public function testIterateWithFetchJoinWithOrderAndLimit($useOutputWalkers): vo $this->iterateWithOrderDescWithLimit($useOutputWalkers, true, $dql, 'username'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinWithOrderAndLimitAndOffset($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g ORDER BY u.username'; @@ -343,9 +313,7 @@ public function testIterateWithFetchJoinWithOrderAndLimitAndOffset($useOutputWal $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, true, $dql, 'username'); } - /** - * @dataProvider useOutputWalkersAndFetchJoinCollection - */ + /** @dataProvider useOutputWalkersAndFetchJoinCollection */ public function testIterateWithRegularJoinWithOrderByColumnFromJoined($useOutputWalkers, $fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e ORDER BY e.email'; @@ -353,9 +321,7 @@ public function testIterateWithRegularJoinWithOrderByColumnFromJoined($useOutput $this->iterateWithOrderDesc($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** - * @dataProvider useOutputWalkersAndFetchJoinCollection - */ + /** @dataProvider useOutputWalkersAndFetchJoinCollection */ public function testIterateWithRegularJoinWithOrderByColumnFromJoinedWithLimit($useOutputWalkers, $fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e ORDER BY e.email'; @@ -363,9 +329,7 @@ public function testIterateWithRegularJoinWithOrderByColumnFromJoinedWithLimit($ $this->iterateWithOrderDescWithLimit($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** - * @dataProvider useOutputWalkersAndFetchJoinCollection - */ + /** @dataProvider useOutputWalkersAndFetchJoinCollection */ public function testIterateWithRegularJoinWithOrderByColumnFromJoinedWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e ORDER BY e.email'; @@ -373,9 +337,7 @@ public function testIterateWithRegularJoinWithOrderByColumnFromJoinedWithLimitAn $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByReferencingJoined($fetchJoinCollection): void { // long function name is loooooooooooong @@ -385,9 +347,7 @@ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByRef $this->iterateWithOrderDesc(true, $fetchJoinCollection, $dql, 'name'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByReferencingJoinedWithLimit($fetchJoinCollection): void { // long function name is loooooooooooong @@ -397,9 +357,7 @@ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByRef $this->iterateWithOrderDescWithLimit(true, $fetchJoinCollection, $dql, 'name'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByReferencingJoinedWithLimitAndOffset($fetchJoinCollection): void { // long function name is loooooooooooong @@ -409,9 +367,7 @@ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByRef $this->iterateWithOrderDescWithLimitAndOffset(true, $fetchJoinCollection, $dql, 'name'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinWithOrderByColumnFromJoined($useOutputWalkers): void { $dql = 'SELECT u,g,e FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g JOIN u.email e ORDER BY e.email'; @@ -419,9 +375,7 @@ public function testIterateWithFetchJoinWithOrderByColumnFromJoined($useOutputWa $this->iterateWithOrderDesc($useOutputWalkers, true, $dql, 'username'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinWithOrderByColumnFromJoinedWithLimit($useOutputWalkers): void { $dql = 'SELECT u,g,e FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g JOIN u.email e ORDER BY e.email'; @@ -429,9 +383,7 @@ public function testIterateWithFetchJoinWithOrderByColumnFromJoinedWithLimit($us $this->iterateWithOrderDescWithLimit($useOutputWalkers, true, $dql, 'username'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinWithOrderByColumnFromJoinedWithLimitAndOffset($useOutputWalkers): void { $dql = 'SELECT u,g,e FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g JOIN u.email e ORDER BY e.email'; @@ -439,9 +391,7 @@ public function testIterateWithFetchJoinWithOrderByColumnFromJoinedWithLimitAndO $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, true, $dql, 'username'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByReferencingJoined($fetchJoinCollection): void { $dql = 'SELECT c,l FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.logo l ORDER BY l.imageWidth * l.imageHeight'; @@ -449,9 +399,7 @@ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByRefer $this->iterateWithOrderDesc(true, $fetchJoinCollection, $dql, 'name'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByReferencingJoinedWithLimit($fetchJoinCollection): void { $dql = 'SELECT c,l FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.logo l ORDER BY l.imageWidth * l.imageHeight'; @@ -459,9 +407,7 @@ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByRefer $this->iterateWithOrderDescWithLimit(true, $fetchJoinCollection, $dql, 'name'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByReferencingJoinedWithLimitAndOffset($fetchJoinCollection): void { $dql = 'SELECT c,l FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.logo l ORDER BY l.imageWidth * l.imageHeight'; @@ -469,9 +415,7 @@ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByRefer $this->iterateWithOrderDescWithLimitAndOffset(true, $fetchJoinCollection, $dql, 'name'); } - /** - * @dataProvider fetchJoinCollection - */ + /** @dataProvider fetchJoinCollection */ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByReferencingJoinedWithLimitAndOffsetWithInheritanceType($fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\Pagination\User u ORDER BY u.id'; @@ -498,9 +442,7 @@ public function testJoinedClassTableInheritance(): void self::assertCount(1, $paginator->getIterator()); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromBoth($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; @@ -531,9 +473,7 @@ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromBothWithLi $this->iterateWithOrderDescWithLimit(false, true, $dqlDesc, 'name'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRoot($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; @@ -541,9 +481,7 @@ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRoot($useO $this->iterateWithOrderDesc($useOutputWalkers, true, $dql, 'name'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRootWithLimit($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; @@ -551,9 +489,7 @@ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRootWithLi $this->iterateWithOrderDescWithLimit($useOutputWalkers, true, $dql, 'name'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRootWithLimitAndOffset($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; @@ -561,9 +497,7 @@ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRootWithLi $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, true, $dql, 'name'); } - /** - * @dataProvider useOutputWalkers - */ + /** @dataProvider useOutputWalkers */ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromJoined($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY d.name'; @@ -668,9 +602,7 @@ public function testQueryWalkerIsKept(): void self::assertEquals(1, $paginator->count()); } - /** - * @group GH-7890 - */ + /** @group GH-7890 */ public function testCustomIdTypeWithoutOutputWalker(): void { $this->_em->persist(new CustomIdObjectTypeParent(new CustomIdObject('foo'))); @@ -695,7 +627,7 @@ public function testCountQueryStripsParametersInSelect(): void $query = $this->_em->createQuery( 'SELECT u, (CASE WHEN u.id < :vipMaxId THEN 1 ELSE 0 END) AS hidden promotedFirst FROM Doctrine\\Tests\\Models\\CMS\\CmsUser u - WHERE u.id < :id or 1=1' + WHERE u.id < :id or 1=1', ); $query->setParameter('vipMaxId', 10); $query->setParameter('id', 100); @@ -720,9 +652,7 @@ public function testCountQueryStripsParametersInSelect(): void self::assertCount(9, $paginator); } - /** - * @dataProvider useOutputWalkersAndFetchJoinCollection - */ + /** @dataProvider useOutputWalkersAndFetchJoinCollection */ public function testPaginationWithSubSelectOrderByExpression($useOutputWalker, $fetchJoinCollection): void { $query = $this->_em->createQuery( @@ -735,7 +665,7 @@ public function testPaginationWithSubSelectOrderByExpression($useOutputWalker, $ ) AS HIDDEN max_version FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY max_version DESC -SQL +SQL, ); $paginator = new Paginator($query, $fetchJoinCollection); @@ -855,7 +785,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void $condition->simpleConditionalExpression = new ComparisonExpression( $path, '=', - new Literal(Literal::STRING, 'Name1') + new Literal(Literal::STRING, 'Name1'), ); $selectStatement->whereClause = new WhereClause($condition); diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php index 162017a6dc8..e9779dfca6d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php @@ -88,7 +88,7 @@ public function testCanCountWithoutLoadingPersistentCollection(): void // Make sure it works with constraints $tweets = $user->tweets->matching(new Criteria( - Criteria::expr()->eq('content', 'Foo') + Criteria::expr()->eq('content', 'Foo'), )); self::assertInstanceOf(LazyCriteriaCollection::class, $tweets); diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php index 381f918dde0..15b5dda920a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php @@ -23,7 +23,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( PersistentCollectionHolder::class, - PersistentCollectionContent::class + PersistentCollectionContent::class, ); PersistentObject::setObjectManager($this->_em); diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php index 637d52df197..18595bbfa36 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php @@ -16,7 +16,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase { - private ?int $userId = null; + private int|null $userId = null; protected function setUp(): void { @@ -198,9 +198,7 @@ public function testLoadedProxyAssociationToManyShouldTriggerEvent(): void $phonenumbersCol->first(); } - /** - * @group DDC-3005 - */ + /** @group DDC-3005 */ public function testAssociationsArePopulatedWhenEventIsFired(): void { $checkerListener = new PostLoadListenerCheckAssociationsArePopulated(); @@ -215,9 +213,7 @@ public function testAssociationsArePopulatedWhenEventIsFired(): void self::assertTrue($checkerListener->populated, 'Association of email is not populated in postLoad event'); } - /** - * @group DDC-3005 - */ + /** @group DDC-3005 */ public function testEventRaisedCorrectTimesWhenOtherEntityLoadedInEventHandler(): void { $eventManager = $this->_em->getEventManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php index 74ea162fbce..60a68e0dcc0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php @@ -40,7 +40,7 @@ protected function setUp(): void CmsArticle::class, CmsAddress::class, CmsEmail::class, - CmsGroup::class + CmsGroup::class, ); $this->user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php index fc798648852..07a49935b7f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php @@ -37,7 +37,7 @@ public function testParenthesisOnSingleLine(): void self::assertSame( 'SELECT o FROM ' . QueryBuilderParenthesisEntity::class . ' o WHERE o.property3 = :value3 AND (o.property1 = :value1 OR o.property2 = :value2) AND (o.property1 = :value1 or o.property2 = :value2)', - $dql + $dql, ); } @@ -49,7 +49,7 @@ public function testParenthesisOnMultiLine(): void $queryBuilder->andWhere( 'o.property1 = :value1 -OR o.property2 = :value2' +OR o.property2 = :value2', ); $queryBuilder->setParameter('value1', 'x'); $queryBuilder->setParameter('value2', 'x'); @@ -63,15 +63,13 @@ public function testParenthesisOnMultiLine(): void self::assertSame( 'SELECT o FROM ' . QueryBuilderParenthesisEntity::class . ' o WHERE o.property3 = :value3 AND (o.property1 = :value1 OR o.property2 = :value2)', - $dql + $dql, ); } } -/** - * @Entity - */ +/** @Entity */ class QueryBuilderParenthesisEntity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php index 3c12c89c589..4935c3d78ee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php @@ -42,9 +42,7 @@ public function testQueryCacheDependsOnHints(): array return [$query, $cache]; } - /** - * @depends testQueryCacheDependsOnHints - */ + /** @depends testQueryCacheDependsOnHints */ public function testQueryCacheDependsOnFirstResult(array $previous): void { [$query, $cache] = $previous; @@ -60,9 +58,7 @@ public function testQueryCacheDependsOnFirstResult(array $previous): void self::assertCount($cacheCount + 1, $cache->getValues()); } - /** - * @depends testQueryCacheDependsOnHints - */ + /** @depends testQueryCacheDependsOnHints */ public function testQueryCacheDependsOnMaxResults(array $previous): void { [$query, $cache] = $previous; @@ -77,9 +73,7 @@ public function testQueryCacheDependsOnMaxResults(array $previous): void self::assertCount($cacheCount + 1, $cache->getValues()); } - /** - * @depends testQueryCacheDependsOnHints - */ + /** @depends testQueryCacheDependsOnHints */ public function testQueryCacheDependsOnHydrationMode(array $previous): void { [$query, $cache] = $previous; diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index c3a88353fbd..a9f38194be3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -248,9 +248,7 @@ public function testOperatorMultiply(): void self::assertEquals(1_600_000, $result[3]['op']); } - /** - * @group test - */ + /** @group test */ public function testOperatorDiv(): void { $result = $this->_em->createQuery('SELECT m, (m.salary/0.5) AS op FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') @@ -275,9 +273,7 @@ public function testConcatFunction(): void self::assertEquals('Benjamin E.HR', $arg[3]['namedep']); } - /** - * @group DDC-1014 - */ + /** @group DDC-1014 */ public function testDateDiff(): void { $query = $this->_em->createQuery("SELECT DATE_DIFF(CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day')) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); @@ -302,7 +298,7 @@ public function testDateAdd(string $unit, int $amount, int $delta = 0): void 'SELECT CURRENT_TIMESTAMP() as now, DATE_ADD(CURRENT_TIMESTAMP(), %d, \'%s\') AS add FROM %s m', $amount, $unit, - CompanyManager::class + CompanyManager::class, ); $result = $this->_em->createQuery($query) @@ -325,7 +321,7 @@ public function testDateAdd(string $unit, int $amount, int $delta = 0): void self::assertEqualsWithDelta( $inOneUnit, new DateTimeImmutable($result['add']), - $delta + $delta, ); } @@ -340,7 +336,7 @@ public function testDateSub(string $unit, int $amount, int $delta = 0): void 'SELECT CURRENT_TIMESTAMP() as now, DATE_SUB(CURRENT_TIMESTAMP(), %d, \'%s\') AS sub FROM %s m', $amount, $unit, - CompanyManager::class + CompanyManager::class, ); $result = $this->_em->createQuery($query) @@ -363,7 +359,7 @@ public function testDateSub(string $unit, int $amount, int $delta = 0): void self::assertEqualsWithDelta( $oneUnitAgo, new DateTimeImmutable($result['sub']), - $delta + $delta, ); } @@ -382,9 +378,7 @@ public function dateAddSubProvider(): array ]; } - /** - * @group DDC-1213 - */ + /** @group DDC-1213 */ public function testBitOrComparison(): void { $dql = 'SELECT m, ' . @@ -406,9 +400,7 @@ public function testBitOrComparison(): void self::assertEquals($result[3][0]['salary'] / 100000 | 2, $result[3]['salary_bit_or']); } - /** - * @group DDC-1213 - */ + /** @group DDC-1213 */ public function testBitAndComparison(): void { $dql = 'SELECT m, ' . diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 8f21e62960b..e157178c544 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -166,9 +166,7 @@ public function testInvalidInputParameterThrowsException(): void ->getSingleResult(); } - /** - * @requires PHP 8.1 - */ + /** @requires PHP 8.1 */ public function testUseStringEnumCaseAsParameter(): void { $user = new CmsUser(); @@ -196,9 +194,7 @@ public function testUseStringEnumCaseAsParameter(): void self::assertSame('jane', $result[0]->username); } - /** - * @requires PHP 8.1 - */ + /** @requires PHP 8.1 */ public function testUseIntegerEnumCaseAsParameter(): void { $user = new CmsUser(); @@ -238,7 +234,7 @@ public function testSetParameters(): void self::assertSame( [1 => 'jwage', 2 => 'active'], - $this->getLastLoggedQuery()['params'] + $this->getLastLoggedQuery()['params'], ); } @@ -253,9 +249,7 @@ public function testSetParametersBackwardsCompatible(): void self::assertSame($parameters, $this->getLastLoggedQuery()['params']); } - /** - * @group DDC-1070 - */ + /** @group DDC-1070 */ public function testIterateResultAsArrayAndParams(): void { $article1 = new CmsArticle(); @@ -284,7 +278,7 @@ public function testIterateResultAsArrayAndParams(): void $articles = $query->toIterable( new ArrayCollection([new Parameter(1, 'Doctrine 2')]), - Query::HYDRATE_ARRAY + Query::HYDRATE_ARRAY, ); $articles = IterableTester::iterableToArray($articles); @@ -497,9 +491,7 @@ public function testModifiedLimitQuery(): void ->getScalarResult(); } - /** - * @group DDC-604 - */ + /** @group DDC-604 */ public function testEntityParameters(): void { $article = new CmsArticle(); @@ -527,9 +519,7 @@ public function testEntityParameters(): void self::assertFalse($result[0]->user->__isInitialized__); } - /** - * @group DDC-952 - */ + /** @group DDC-952 */ public function testEnableFetchEagerMode(): void { for ($i = 0; $i < 10; $i++) { @@ -558,9 +548,7 @@ public function testEnableFetchEagerMode(): void } } - /** - * @group DDC-991 - */ + /** @group DDC-991 */ public function testgetOneOrNullResult(): void { $user = new CmsUser(); @@ -582,9 +570,7 @@ public function testgetOneOrNullResult(): void self::assertEquals('gblanco', $fetchedUsername); } - /** - * @group DDC-991 - */ + /** @group DDC-991 */ public function testgetOneOrNullResultSeveralRows(): void { $user = new CmsUser(); @@ -607,9 +593,7 @@ public function testgetOneOrNullResultSeveralRows(): void $fetchedUser = $query->getOneOrNullResult(); } - /** - * @group DDC-991 - */ + /** @group DDC-991 */ public function testgetOneOrNullResultNoRows(): void { $query = $this->_em->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u'); @@ -619,9 +603,7 @@ public function testgetOneOrNullResultNoRows(): void self::assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR)); } - /** - * @group DBAL-171 - */ + /** @group DBAL-171 */ public function testParameterOrder(): void { $user1 = new CmsUser(); @@ -650,7 +632,7 @@ public function testParameterOrder(): void [ new Parameter('b', [$user1->id, $user2->id, $user3->id]), new Parameter('a', 'developer'), - ] + ], )); $result = $query->getResult(); @@ -764,9 +746,7 @@ public function testQueryWithHiddenAsSelectExpression(): void self::assertInstanceOf(CmsUser::class, $users[0]); } - /** - * @group DDC-1651 - */ + /** @group DDC-1651 */ public function testSetParameterBindingSingleIdentifierObject(): void { $userC = new CmsUser(); @@ -787,9 +767,7 @@ public function testSetParameterBindingSingleIdentifierObject(): void $q->getResult(); } - /** - * @group DDC-2319 - */ + /** @group DDC-2319 */ public function testSetCollectionParameterBindingSingleIdentifierObject(): void { $u1 = new CmsUser(); @@ -837,9 +815,7 @@ public function testSetCollectionParameterBindingSingleIdentifierObject(): void self::assertEquals($u3->username, $resultUser3->username); } - /** - * @group DDC-1822 - */ + /** @group DDC-1822 */ public function testUnexpectedResultException(): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'; diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 7472faded57..b2e680fdb6a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -42,9 +42,7 @@ public function testReadOnlyEntityNeverChangeTracked(): void self::assertEquals(1234, $dbReadOnly->numericValue); } - /** - * @group DDC-1659 - */ + /** @group DDC-1659 */ public function testClearReadOnly(): void { $readOnly = new ReadOnlyEntity('Test1', 1234); @@ -57,9 +55,7 @@ public function testClearReadOnly(): void self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); } - /** - * @group DDC-1659 - */ + /** @group DDC-1659 */ public function testClearEntitiesReadOnly(): void { $readOnly = new ReadOnlyEntity('Test1', 1234); @@ -137,9 +133,7 @@ public function testNotReadOnlyIfObjectWasKnownBefore(): void } } -/** - * @Entity(readOnly=true) - */ +/** @Entity(readOnly=true) */ class ReadOnlyEntity { /** @@ -150,18 +144,12 @@ class ReadOnlyEntity */ public $id; - /** - * @param int $number - */ + /** @param int $number */ public function __construct( - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ public string $name, - /** - * @Column(type="integer") - */ - public $numericValue + /** @Column(type="integer") */ + public $numericValue, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php index 5b12172e461..59bcbfc8348 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php @@ -14,9 +14,7 @@ use function dirname; -/** - * @requires PHP 8.1 - */ +/** @requires PHP 8.1 */ class ReadonlyPropertiesTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -26,7 +24,7 @@ protected function setUp(): void } $this->_em = $this->getEntityManager(null, new AttributeDriver( - [dirname(__DIR__, 2) . '/Models/ReadonlyProperties'] + [dirname(__DIR__, 2) . '/Models/ReadonlyProperties'], )); $this->_schemaTool = new SchemaTool($this->_em); diff --git a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php index e80bad46ac5..5b805a57d1d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php @@ -63,9 +63,7 @@ public function testLazyLoadsFieldValuesFromDatabase(): void self::assertEquals('Doctrine Cookbook', $productProxy->getName()); } - /** - * @group DDC-727 - */ + /** @group DDC-727 */ public function testAccessMetatadaForProxy(): void { $id = $this->createProduct(); @@ -76,9 +74,7 @@ public function testAccessMetatadaForProxy(): void self::assertEquals(ECommerceProduct::class, $class->name); } - /** - * @group DDC-1033 - */ + /** @group DDC-1033 */ public function testReferenceFind(): void { $id = $this->createProduct(); @@ -90,9 +86,7 @@ public function testReferenceFind(): void self::assertEquals('Doctrine Cookbook', $entity2->getName()); } - /** - * @group DDC-1033 - */ + /** @group DDC-1033 */ public function testCloneProxy(): void { $id = $this->createProduct(); @@ -115,9 +109,7 @@ public function testCloneProxy(): void self::assertFalse($entity->isCloned); } - /** - * @group DDC-733 - */ + /** @group DDC-733 */ public function testInitializeProxy(): void { $id = $this->createProduct(); @@ -130,9 +122,7 @@ public function testInitializeProxy(): void self::assertTrue($entity->__isInitialized__, 'Should be initialized after called UnitOfWork::initializeObject()'); } - /** - * @group DDC-1163 - */ + /** @group DDC-1163 */ public function testInitializeChangeAndFlushProxy(): void { $id = $this->createProduct(); @@ -148,9 +138,7 @@ public function testInitializeChangeAndFlushProxy(): void self::assertEquals('Doctrine 2 Cookbook', $entity->getName()); } - /** - * @group DDC-1022 - */ + /** @group DDC-1022 */ public function testWakeupCalledOnProxy(): void { $id = $this->createProduct(); @@ -177,9 +165,7 @@ public function testDoNotInitializeProxyOnGettingTheIdentifier(): void self::assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); } - /** - * @group DDC-1625 - */ + /** @group DDC-1625 */ public function testDoNotInitializeProxyOnGettingTheIdentifierDDC1625(): void { $id = $this->createAuction(); @@ -227,9 +213,7 @@ public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier(): v self::assertTrue($entity->__isInitialized__, 'Getting something other than the identifier initializes the proxy.'); } - /** - * @group DDC-1604 - */ + /** @group DDC-1604 */ public function testCommonPersistenceProxy(): void { $id = $this->createProduct(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php index 358da1f60d7..00af1ef7075 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php @@ -83,9 +83,7 @@ public function testSetResultCacheId(): void self::assertCacheHasItem('testing_result_cache_id', $cache); } - /** - * @group DDC-1026 - */ + /** @group DDC-1026 */ public function testUseResultCacheParams(): void { $cache = new ArrayAdapter(); @@ -153,9 +151,7 @@ public function testEnableResultCacheWithIterable(): void $this->resetCache(); } - /** - * @group DDC-1026 - */ + /** @group DDC-1026 */ public function testEnableResultCacheParams(): void { $cache = new ArrayAdapter(); @@ -219,9 +215,7 @@ public function testNativeQueryResultCaching(): array return [$query, $cache]; } - /** - * @depends testNativeQueryResultCaching - */ + /** @depends testNativeQueryResultCaching */ public function testResultCacheNotDependsOnQueryHints(array $previous): void { [$query, $cache] = $previous; @@ -236,9 +230,7 @@ public function testResultCacheNotDependsOnQueryHints(array $previous): void self::assertCount($cacheCount, $cache->getValues()); } - /** - * @depends testNativeQueryResultCaching - */ + /** @depends testNativeQueryResultCaching */ public function testResultCacheDependsOnParameters(array $previous): void { [$query, $cache] = $previous; @@ -253,9 +245,7 @@ public function testResultCacheDependsOnParameters(array $previous): void self::assertCount($cacheCount + 1, $cache->getValues()); } - /** - * @depends testNativeQueryResultCaching - */ + /** @depends testNativeQueryResultCaching */ public function testResultCacheNotDependsOnHydrationMode(array $previous): void { [$query, $cache] = $previous; @@ -270,9 +260,7 @@ public function testResultCacheNotDependsOnHydrationMode(array $previous): void self::assertCount($cacheCount, $cache->getValues()); } - /** - * @group DDC-909 - */ + /** @group DDC-909 */ public function testResultCacheWithObjectParameter(): void { $user1 = new CmsUser(); @@ -336,7 +324,7 @@ private function setResultCache(AbstractQuery $query, CacheItemPoolInterface $ca { $query->setResultCacheProfile( (new QueryCacheProfile()) - ->setResultCache($cache) + ->setResultCache($cache), ); } @@ -344,7 +332,7 @@ private static function assertCacheHasItem(string $key, CacheItemPoolInterface $ { self::assertTrue( $cache->hasItem($key), - sprintf('Failed asserting that a given cache contains the key "%s".', $key) + sprintf('Failed asserting that a given cache contains the key "%s".', $key), ); } @@ -357,7 +345,7 @@ private static function assertCacheDoesNotHaveItem(string $key, CacheItemPoolInt { self::assertFalse( $cache->hasItem($key), - sprintf('Failed asserting that a given cache does not contain the key "%s".', $key) + sprintf('Failed asserting that a given cache does not contain the key "%s".', $key), ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 7c34497ed82..186e98cf8c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -176,9 +176,7 @@ public function testEntityManagerGetFilter(): void self::assertTrue($exceptionThrown); } - /** - * @group DDC-2203 - */ + /** @group DDC-2203 */ public function testEntityManagerIsFilterEnabled(): void { $em = $this->getEntityManager(); @@ -432,14 +430,14 @@ public function testRepositoryFindBy(): void $this->loadFixtureData(); self::assertCount(1, $this->_em->getRepository(CmsGroup::class)->findBy( - ['id' => $this->groupId2] + ['id' => $this->groupId2], )); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); self::assertCount(0, $this->_em->getRepository(CmsGroup::class)->findBy( - ['id' => $this->groupId2] + ['id' => $this->groupId2], )); } @@ -460,14 +458,14 @@ public function testRepositoryFindOneBy(): void $this->loadFixtureData(); self::assertNotNull($this->_em->getRepository(CmsGroup::class)->findOneBy( - ['id' => $this->groupId2] + ['id' => $this->groupId2], )); $this->useCMSGroupPrefixFilter(); $this->_em->clear(); self::assertNull($this->_em->getRepository(CmsGroup::class)->findOneBy( - ['id' => $this->groupId2] + ['id' => $this->groupId2], )); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php index 0fd1475f6c3..854897bea97 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php @@ -18,9 +18,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-966 - */ + /** @group DDC-966 */ public function testGeneratedSchema(): Schema { $schema = $this->createSchemaManager()->createSchema(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 48a4935b1d1..5e9e39e5326 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -15,9 +15,7 @@ class DBAL483Test extends OrmFunctionalTestCase { - /** - * @group DBAL-483 - */ + /** @group DBAL-483 */ public function testDefaultValueIsComparedCorrectly(): void { $class = DBAL483Default::class; @@ -32,9 +30,7 @@ public function testDefaultValueIsComparedCorrectly(): void } } -/** - * @Entity - */ +/** @Entity */ class DBAL483Default { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 494a186ed71..4f5e20795ad 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -30,9 +30,7 @@ protected function setUp(): void } } - /** - * @group DDC-214 - */ + /** @group DDC-214 */ public function testCmsAddressModel(): void { $this->assertCreatedSchemaNeedsNoUpdates( @@ -41,13 +39,11 @@ public function testCmsAddressModel(): void Models\CMS\CmsAddress::class, Models\CMS\CmsGroup::class, Models\CMS\CmsArticle::class, - Models\CMS\CmsEmail::class + Models\CMS\CmsEmail::class, ); } - /** - * @group DDC-214 - */ + /** @group DDC-214 */ public function testCompanyModel(): void { $this->assertCreatedSchemaNeedsNoUpdates( @@ -58,13 +54,11 @@ public function testCompanyModel(): void Models\Company\CompanyEvent::class, Models\Company\CompanyAuction::class, Models\Company\CompanyRaffle::class, - Models\Company\CompanyCar::class + Models\Company\CompanyCar::class, ); } - /** - * @param class-string ...$classes - */ + /** @param class-string ...$classes */ public function assertCreatedSchemaNeedsNoUpdates(string ...$classes): void { $this->createSchemaForModels(...$classes); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index f9652406c63..592efc11093 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -53,7 +53,7 @@ public function testGetCreateSchemaSql(): void // DBAL 3 self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) - self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB') + self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), )); self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[2]); self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[3]); @@ -62,7 +62,7 @@ public function testGetCreateSchemaSql(): void // DBAL 3 self::equalTo('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) - self::equalTo('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB') + self::equalTo('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), )); self::assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[6]); self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[7]); @@ -99,9 +99,7 @@ public function testGetCreateSchemaSql3(): void self::assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); } - /** - * @group DBAL-204 - */ + /** @group DBAL-204 */ public function testGetCreateSchemaSql4(): void { if (! class_exists(Visitor::class)) { diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index e2a92e69828..6a6371f1fdc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -38,14 +38,12 @@ public function testPostgresMetadataSequenceIncrementedBy10(): void self::assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); } - /** - * @group DDC-1657 - */ + /** @group DDC-1657 */ public function testUpdateSchemaWithPostgreSQLSchema(): void { $sql = $this->getUpdateSchemaSqlForModels( DDC1657Screen::class, - DDC1657Avatar::class + DDC1657Avatar::class, ); $sql = array_filter($sql, static fn ($sql) => str_starts_with($sql, 'DROP SEQUENCE stonewood.')); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php index 6871df64e37..2e8ccae416a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php @@ -32,9 +32,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @throws DBALException - */ + /** @throws DBALException */ private function registerType(string $className): void { $type = constant($className . '::NAME'); @@ -59,9 +57,7 @@ public static function dataValidateModelSets(): array return $modelSets; } - /** - * @dataProvider dataValidateModelSets - */ + /** @dataProvider dataValidateModelSets */ public function testValidateModelSets(string $modelSet): void { $validator = new SchemaValidator($this->_em); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php index 555f6ca991d..af27215ce97 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php @@ -8,9 +8,7 @@ use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\Flight; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheFunctionalTestCase { public function testPutAndLoadCompositPrimaryKeyEntities(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php index 1d3659d39eb..48900cb660c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php @@ -18,9 +18,7 @@ use function assert; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheConcurrentTest extends SecondLevelCacheFunctionalTestCase { private CacheFactorySecondLevelCacheConcurrentTest $cacheFactory; diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php index f77e50e085e..1806d2ad98f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheCriteriaTest extends SecondLevelCacheFunctionalTestCase { public function testMatchingPut(): void @@ -28,7 +26,7 @@ public function testMatchingPut(): void $this->getQueryLog()->reset()->enable(); $name = $this->countries[0]->getName(); $result1 = $repository->matching(new Criteria( - Criteria::expr()->eq('name', $name) + Criteria::expr()->eq('name', $name), )); // Because matching returns lazy collection, we force initialization @@ -43,7 +41,7 @@ public function testMatchingPut(): void $this->_em->clear(); $result2 = $repository->matching(new Criteria( - Criteria::expr()->eq('name', $name) + Criteria::expr()->eq('name', $name), )); $this->assertQueryCount(1); @@ -67,7 +65,7 @@ public function testRepositoryMatching(): void $repository = $this->_em->getRepository(Country::class); $this->getQueryLog()->reset()->enable(); $result1 = $repository->matching(new Criteria( - Criteria::expr()->eq('name', $this->countries[0]->getName()) + Criteria::expr()->eq('name', $this->countries[0]->getName()), )); // Because matching returns lazy collection, we force initialization @@ -81,7 +79,7 @@ public function testRepositoryMatching(): void $this->_em->clear(); $result2 = $repository->matching(new Criteria( - Criteria::expr()->eq('name', $this->countries[0]->getName()) + Criteria::expr()->eq('name', $this->countries[0]->getName()), )); // Because matching returns lazy collection, we force initialization @@ -96,7 +94,7 @@ public function testRepositoryMatching(): void self::assertEquals($this->countries[0]->getName(), $result2[0]->getName()); $result3 = $repository->matching(new Criteria( - Criteria::expr()->eq('name', $this->countries[1]->getName()) + Criteria::expr()->eq('name', $this->countries[1]->getName()), )); // Because matching returns lazy collection, we force initialization @@ -111,7 +109,7 @@ public function testRepositoryMatching(): void self::assertEquals($this->countries[1]->getName(), $result3[0]->getName()); $result4 = $repository->matching(new Criteria( - Criteria::expr()->eq('name', $this->countries[1]->getName()) + Criteria::expr()->eq('name', $this->countries[1]->getName()), )); $this->assertQueryCount(2); @@ -136,7 +134,7 @@ public function testCollectionMatching(): void $this->getQueryLog()->reset()->enable(); $collection = $entity->getCities(); $matching = $collection->matching(new Criteria( - Criteria::expr()->eq('name', $itemName) + Criteria::expr()->eq('name', $itemName), )); $this->assertQueryCount(1); @@ -149,7 +147,7 @@ public function testCollectionMatching(): void $this->getQueryLog()->reset()->enable(); $collection = $entity->getCities(); $matching = $collection->matching(new Criteria( - Criteria::expr()->eq('name', $itemName) + Criteria::expr()->eq('name', $itemName), )); $this->assertQueryCount(0); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php index 3dc1039dc6e..d8c14c33058 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\Travel; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheExtraLazyCollectionTest extends SecondLevelCacheFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php index f09e4d0a4bc..a26f3ecd3f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php @@ -23,9 +23,7 @@ use Doctrine\Tests\Models\Cache\TravelerProfileInfo; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ abstract class SecondLevelCacheFunctionalTestCase extends OrmFunctionalTestCase { /** @psalm-var list */ diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php index 4dfb1c4b2f2..5a750e8c040 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php @@ -12,9 +12,7 @@ use function count; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheFunctionalTestCase { public function testUseSameRegion(): void @@ -215,7 +213,7 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void $contact = new AttractionContactInfo( '1234-1234', - $this->_em->find(Attraction::class, $this->attractions[5]->getId()) + $this->_em->find(Attraction::class, $this->attractions[5]->getId()), ); $this->_em->persist($contact); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php index 2177f90047a..abd821c0ba4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php @@ -10,9 +10,7 @@ use Doctrine\Tests\Models\Cache\Travel; use Doctrine\Tests\Models\Cache\Traveler; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheManyToManyTest extends SecondLevelCacheFunctionalTestCase { public function testShouldPutManyToManyCollectionOwningSideOnPersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php index 0a480b55609..cd2e2527891 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php @@ -12,9 +12,7 @@ use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\Token; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheManyToOneTest extends SecondLevelCacheFunctionalTestCase { public function testPutOnPersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php index 6cdfce8af94..aff29b6d9a4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php @@ -14,9 +14,7 @@ use function sprintf; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheOneToManyTest extends SecondLevelCacheFunctionalTestCase { public function testShouldPutCollectionInverseSideOnPersist(): void @@ -385,7 +383,7 @@ public function testCacheInitializeCollectionWithNewObjects(): void $query = sprintf( 'SELECT t, tt FROM Doctrine\Tests\Models\Cache\Traveler t JOIN t.travels tt WHERE t.id = %s', - $travelerId + $travelerId, ); $result = $this->_em->createQuery($query)->getSingleResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php index 776f3b1f66d..ac04b843891 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php @@ -13,9 +13,7 @@ use Doctrine\Tests\Models\Cache\TravelerProfile; use Doctrine\Tests\Models\Cache\TravelerProfileInfo; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheOneToOneTest extends SecondLevelCacheFunctionalTestCase { public function testPutOneToOneOnUnidirectionalPersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index adddc8b92e3..8e338f5c784 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -20,9 +20,7 @@ use Doctrine\Tests\Models\Cache\State; use ReflectionMethod; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheFunctionalTestCase { public function testBasicQueryCache(): void @@ -290,9 +288,7 @@ public function testBasicQueryCachePutEntityCache(): void self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } - /** - * @group 5854 - */ + /** @group 5854 */ public function testMultipleNestedDQLAliases(): void { $this->loadFixturesCountries(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php index 25cab2d372c..e8be947b6b3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php @@ -8,9 +8,7 @@ use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheRepositoryTest extends SecondLevelCacheFunctionalTestCase { public function testRepositoryCacheFind(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php index 76e3547d870..a7f5cd32468 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php @@ -13,9 +13,7 @@ use function count; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheFunctionalTestCase { public function testUseSameRegion(): void @@ -236,7 +234,7 @@ public function testQueryCacheShouldBeEvictedOnTimestampUpdate(): void $contact = new Beach( 'Botafogo', - $this->_em->find(City::class, $this->cities[1]->getId()) + $this->_em->find(City::class, $this->cities[1]->getId()), ); $this->_em->persist($contact); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php index 5d2fd050358..a829d7c456b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php @@ -15,9 +15,7 @@ use function uniqid; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class SecondLevelCacheTest extends SecondLevelCacheFunctionalTestCase { public function testPutOnPersist(): void @@ -209,7 +207,7 @@ public function testPostFlushFailure(): void Events::postFlush => static function (): void { throw new RuntimeException('post flush failure'); }, - ] + ], ); $this->_em->getEventManager() @@ -241,7 +239,7 @@ public function testPostUpdateFailure(): void Events::postUpdate => static function (): void { throw new RuntimeException('post update failure'); }, - ] + ], ); $this->_em->getEventManager() @@ -288,7 +286,7 @@ public function testPostRemoveFailure(): void Events::postRemove => static function (): void { throw new RuntimeException('post remove failure'); }, - ] + ], ); $this->_em->getEventManager() @@ -315,7 +313,7 @@ public function testPostRemoveFailure(): void self::assertFalse( $this->cache->containsEntity(Country::class, $countryId), - 'Removal attempts should clear the cache entry corresponding to the entity' + 'Removal attempts should clear the cache entry corresponding to the entity', ); self::assertInstanceOf(Country::class, $this->_em->find(Country::class, $countryId)); diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php index ace932b7439..6f2664bbf0e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php @@ -39,9 +39,7 @@ public function testHighAllocationSizeSequence(): void } } -/** - * @Entity - */ +/** @Entity */ class SequenceEntity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php index 1c7a4d95611..472e53c5f13 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php @@ -28,9 +28,7 @@ public function testInsertWithCompositeKey(): void self::assertEquals($childEntity, $entity); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testUpdateWithCompositeKey(): void { $childEntity = new SingleChildClass(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php index 7e4a1afbd13..5d8a509596a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -20,16 +20,16 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase { - private ?CompanyEmployee $salesPerson = null; + private CompanyEmployee|null $salesPerson = null; /** @var list */ private array $engineers = []; - private ?CompanyFixContract $fix = null; + private CompanyFixContract|null $fix = null; - private ?CompanyFlexContract $flex = null; + private CompanyFlexContract|null $flex = null; - private ?CompanyFlexUltraContract $ultra = null; + private CompanyFlexUltraContract|null $ultra = null; protected function setUp(): void { @@ -256,9 +256,7 @@ public function testQueryChildClassWithCondition(): void self::assertEquals(1000, $contract->getFixPrice()); } - /** - * @group non-cacheable - */ + /** @group non-cacheable */ public function testUpdateChildClassWithCondition(): void { $this->loadFullFixture(); @@ -315,9 +313,7 @@ public function testDeleteByBaseClassCondition(): void self::assertFalse($contracts[0]->isCompleted(), 'Only non completed contracts should be left.'); } - /** - * @group DDC-130 - */ + /** @group DDC-130 */ public function testDeleteJoinTableRecords(): void { $this->loadFullFixture(); @@ -329,9 +325,7 @@ public function testDeleteJoinTableRecords(): void self::assertNull($this->_em->find($this->fix::class, $this->fix->getId()), 'Contract should not be present in the database anymore.'); } - /** - * @group DDC-817 - */ + /** @group DDC-817 */ public function testFindByAssociation(): void { $this->loadFullFixture(); @@ -353,29 +347,25 @@ public function testFindByAssociation(): void self::assertCount(1, $contracts, 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'"); } - /** - * @group DDC-1637 - */ + /** @group DDC-1637 */ public function testInheritanceMatching(): void { $this->loadFullFixture(); $repository = $this->_em->getRepository(CompanyContract::class); $contracts = $repository->matching(new Criteria( - Criteria::expr()->eq('salesPerson', $this->salesPerson) + Criteria::expr()->eq('salesPerson', $this->salesPerson), )); self::assertCount(3, $contracts); $repository = $this->_em->getRepository(CompanyFixContract::class); $contracts = $repository->matching(new Criteria( - Criteria::expr()->eq('salesPerson', $this->salesPerson) + Criteria::expr()->eq('salesPerson', $this->salesPerson), )); self::assertCount(1, $contracts); } - /** - * @group DDC-2430 - */ + /** @group DDC-2430 */ public function testMatchingNonObjectOnAssocationThrowsException(): void { $this->loadFullFixture(); @@ -386,16 +376,14 @@ public function testMatchingNonObjectOnAssocationThrowsException(): void $this->expectExceptionMessage('annot match on Doctrine\Tests\Models\Company\CompanyContract::salesPerson with a non-object value.'); $contracts = $repository->matching(new Criteria( - Criteria::expr()->eq('salesPerson', $this->salesPerson->getId()) + Criteria::expr()->eq('salesPerson', $this->salesPerson->getId()), )); // Load the association because it's wrapped in a lazy collection $contracts->toArray(); } - /** - * @group DDC-834 - */ + /** @group DDC-834 */ public function testGetReferenceEntityWithSubclasses(): void { $this->loadFullFixture(); @@ -410,9 +398,7 @@ public function testGetReferenceEntityWithSubclasses(): void self::assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); } - /** - * @group DDC-952 - */ + /** @group DDC-952 */ public function testEagerLoadInheritanceHierarchy(): void { $this->loadFullFixture(); diff --git a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php index 5e53c763632..dcf6b1df43c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php @@ -68,7 +68,7 @@ public function testAddPersistRetrieve(): void $q = $this->_em->createQuery( 'SELECT p, f FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p - JOIN p.features f' + JOIN p.features f', ); $res = $q->getResult(); @@ -98,7 +98,7 @@ public function testAddPersistRetrieve(): void $q = $this->_em->createQuery( 'SELECT p, f FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p - JOIN p.features f' + JOIN p.features f', ); $res = $q->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php index 6230702185f..41795351cb0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php @@ -8,9 +8,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1040 - */ +/** @group DDC-1040 */ class DDC1040Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php index b79f3d1738f..19f96242610 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -8,9 +8,7 @@ use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1041 - */ +/** @group DDC-1041 */ class DDC1041Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php index 54f6e75bdfc..4ea477c3580 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php @@ -7,9 +7,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1043 - */ +/** @group DDC-1043 */ class DDC1043Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index 1c40fd65c6f..b3b8e58a336 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -17,9 +17,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1080 - */ +/** @group DDC-1080 */ class DDC1080Test extends OrmFunctionalTestCase { public function testHydration(): void @@ -27,7 +25,7 @@ public function testHydration(): void $this->createSchemaForModels( DDC1080Foo::class, DDC1080Bar::class, - DDC1080FooBar::class + DDC1080FooBar::class, ); $foo1 = new DDC1080Foo(); @@ -121,9 +119,7 @@ public function getFooTitle(): string return $this->fooTitle; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getFooBars(): Collection { return $this->fooBars; @@ -187,9 +183,7 @@ public function getBarTitle(): string return $this->barTitle; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getFooBars(): Collection { return $this->fooBars; @@ -263,12 +257,12 @@ public function setBar(DDC1080Bar $bar): DDC1080FooBar return $this; } - public function getOrderNr(): ?int + public function getOrderNr(): int|null { return $this->orderNr; } - public function setOrderNr(?int $orderNr): DDC1080FooBar + public function setOrderNr(int|null $orderNr): DDC1080FooBar { $this->orderNr = $orderNr; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php index a33cac1d5ac..a76d5acce5c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php @@ -28,7 +28,7 @@ protected function setUp(): void DDC1113Engine::class, DDC1113Vehicle::class, DDC1113Car::class, - DDC1113Bus::class + DDC1113Bus::class, ); } @@ -84,23 +84,17 @@ class DDC1113Vehicle public $engine; } -/** - * @Entity - */ +/** @Entity */ class DDC1113Car extends DDC1113Vehicle { } -/** - * @Entity - */ +/** @Entity */ class DDC1113Bus extends DDC1113Vehicle { } -/** - * @Entity - */ +/** @Entity */ class DDC1113Engine { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php index 95cd565a0ba..f7b23e082fe 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php @@ -7,9 +7,7 @@ use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1129 - */ +/** @group DDC-1129 */ class DDC1129Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index e4f8dcae8d4..5551b13d87c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -20,14 +20,12 @@ use function assert; -/** - * @group DDC-1163 - */ +/** @group DDC-1163 */ class DDC1163Test extends OrmFunctionalTestCase { - private ?int $productId = null; + private int|null $productId = null; - private ?int $proxyHolderId = null; + private int|null $proxyHolderId = null; protected function setUp(): void { @@ -37,7 +35,7 @@ protected function setUp(): void DDC1163Product::class, DDC1163SpecialProduct::class, DDC1163ProxyHolder::class, - DDC1163Tag::class + DDC1163Tag::class, ); } @@ -98,7 +96,7 @@ private function setPropertyAndAssignTagToSpecialProduct(): void // this screams violation of law of demeter ;) self::assertEquals( DDC1163SpecialProduct::class, - $this->_em->getUnitOfWork()->getEntityPersister($specialProduct::class)->getClassMetadata()->name + $this->_em->getUnitOfWork()->getEntityPersister($specialProduct::class)->getClassMetadata()->name, ); $tag = new DDC1163Tag('Foo'); @@ -107,9 +105,7 @@ private function setPropertyAndAssignTagToSpecialProduct(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1163ProxyHolder { /** @@ -120,7 +116,7 @@ class DDC1163ProxyHolder private int $id; /** @OneToOne(targetEntity="DDC1163SpecialProduct") */ - private ?DDC1163SpecialProduct $specialProduct = null; + private DDC1163SpecialProduct|null $specialProduct = null; public function getId(): int { @@ -160,13 +156,11 @@ public function getId(): int } } -/** - * @Entity - */ +/** @Entity */ class DDC1163SpecialProduct extends DDC1163Product { /** @Column(name="subclass_property", type="string", nullable=true) */ - private ?string $subclassProperty = null; + private string|null $subclassProperty = null; public function setSubclassProperty(string $value): void { @@ -174,9 +168,7 @@ public function setSubclassProperty(string $value): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1163Tag { /** @@ -195,10 +187,8 @@ class DDC1163Tag private $product; public function __construct( - /** - * @Column(name="name", type="string", length=255) - */ - private string $name + /** @Column(name="name", type="string", length=255) */ + private string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php index a34ccb1c1ac..aae1afa41da 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -19,20 +19,18 @@ use function assert; use function count; -/** - * @group DDC-117 - */ +/** @group DDC-117 */ class DDC117Test extends OrmFunctionalTestCase { use VerifyDeprecations; - private ?DDC117Article $article1; + private DDC117Article|null $article1; - private ?DDC117Article $article2; + private DDC117Article|null $article2; private DDC117Reference $reference; - private ?DDC117Translation $translation; + private DDC117Translation|null $translation; private DDC117ArticleDetails $articleDetails; @@ -64,9 +62,7 @@ protected function setUp(): void $this->_em->clear(); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testAssociationOnlyCompositeKey(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -103,9 +99,7 @@ public function testAssociationOnlyCompositeKey(): void $this->_em->contains($dqlRef); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testUpdateAssociationEntity(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -121,9 +115,7 @@ public function testUpdateAssociationEntity(): void self::assertEquals('New Description!!', $mapRef->getDescription()); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testFetchDql(): void { $dql = 'SELECT r, s FROM Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1'; @@ -137,9 +129,7 @@ public function testFetchDql(): void } } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testRemoveCompositeElement(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -170,9 +160,7 @@ public function testDqlRemoveCompositeElement(): void self::assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testInverseSideAccess(): void { $this->article1 = $this->_em->find(DDC117Article::class, $this->article1->id()); @@ -199,9 +187,7 @@ public function testInverseSideAccess(): void } } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testMixedCompositeKey(): void { $idCriteria = ['article' => $this->article1->id(), 'language' => 'en']; @@ -222,9 +208,7 @@ public function testMixedCompositeKey(): void self::assertInstanceOf(DDC117Translation::class, $this->translation); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testMixedCompositeKeyViolateUniqueness(): void { $this->article1 = $this->_em->find(DDC117Article::class, $this->article1->id()); @@ -236,9 +220,7 @@ public function testMixedCompositeKeyViolateUniqueness(): void $this->_em->flush(); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testOneToOneForeignObjectId(): void { $this->article1 = new DDC117Article('Foo'); @@ -258,9 +240,7 @@ public function testOneToOneForeignObjectId(): void self::assertEquals('not so very long text!', $article->getText()); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testOneToOneCascadeRemove(): void { $article = $this->_em->find($this->article1::class, $this->article1->id()); @@ -270,9 +250,7 @@ public function testOneToOneCascadeRemove(): void self::assertFalse($this->_em->contains($article->getDetails())); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testOneToOneCascadePersist(): void { $this->article1 = new DDC117Article('Foo'); @@ -284,9 +262,7 @@ public function testOneToOneCascadePersist(): void self::assertSame($this->articleDetails, $this->_em->find(DDC117ArticleDetails::class, $this->article1)); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testReferencesToForeignKeyEntities(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -307,9 +283,7 @@ public function testReferencesToForeignKeyEntities(): void self::assertInstanceOf(DDC117Translation::class, $approveChanges->getTranslation()); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testLoadOneToManyCollectionOfForeignKeyEntities(): void { $article = $this->_em->find($this->article1::class, $this->article1->id()); @@ -321,9 +295,7 @@ public function testLoadOneToManyCollectionOfForeignKeyEntities(): void self::assertTrue($translations->isInitialized()); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testLoadManyToManyCollectionOfForeignKeyEntities(): void { $editor = $this->loadEditorFixture(); @@ -340,9 +312,7 @@ public function testLoadManyToManyCollectionOfForeignKeyEntities(): void self::assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testClearManyToManyCollectionOfForeignKeyEntities(): void { $editor = $this->loadEditorFixture(); @@ -356,9 +326,7 @@ public function testClearManyToManyCollectionOfForeignKeyEntities(): void self::assertCount(0, $editor->reviewingTranslations); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testLoadInverseManyToManyCollection(): void { $editor = $this->loadEditorFixture(); @@ -383,9 +351,7 @@ public function testLoadInverseManyToManyCollection(): void self::assertCount(1, $trans->reviewedByEditors); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testLoadOneToManyOfSourceEntityWithAssociationIdentifier(): void { $editor = $this->loadEditorFixture(); @@ -428,9 +394,7 @@ private function loadEditorFixture(): DDC117Editor return $this->_em->find($editor::class, $editor->id); } - /** - * @group DDC-1652 - */ + /** @group DDC-1652 */ public function testArrayHydrationWithCompositeKey(): void { $dql = 'SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t'; @@ -456,9 +420,7 @@ public function testArrayHydrationWithCompositeKey(): void self::assertCount($before + 3, $data); } - /** - * @group DDC-2246 - */ + /** @group DDC-2246 */ public function testGetEntityState(): void { if ($this->isSecondLevelCacheEnabled) { @@ -478,9 +440,7 @@ public function testGetEntityState(): void self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($reference)); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testIndexByOnCompositeKeyField(): void { $article = $this->_em->find(DDC117Article::class, $this->article1->id()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php index 52ab662d9b8..df71a959ec0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php @@ -22,13 +22,11 @@ protected function setUp(): void $this->createSchemaForModels( DDC1181Hotel::class, DDC1181Booking::class, - DDC1181Room::class + DDC1181Room::class, ); } - /** - * @group DDC-1181 - */ + /** @group DDC-1181 */ public function testIssue(): void { $hotel = new DDC1181Hotel(); @@ -60,9 +58,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1181Hotel { /** @@ -80,9 +76,7 @@ class DDC1181Hotel public $bookings; } -/** - * @Entity - */ +/** @Entity */ class DDC1181Booking { /** @@ -105,9 +99,7 @@ class DDC1181Booking public $room; } -/** - * @Entity - */ +/** @Entity */ class DDC1181Room { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index 35ad187be27..c05b4697083 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -20,13 +20,11 @@ protected function setUp(): void $this->createSchemaForModels( DDC1193Company::class, DDC1193Person::class, - DDC1193Account::class + DDC1193Account::class, ); } - /** - * @group DDC-1193 - */ + /** @group DDC-1193 */ public function testIssue(): void { $company = new DDC1193Company(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php index e69e824f6cb..f4bcdc162f6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php @@ -22,13 +22,11 @@ protected function setUp(): void $this->createSchemaForModels( DDC1209One::class, DDC1209Two::class, - DDC1209Three::class + DDC1209Three::class, ); } - /** - * @group DDC-1209 - */ + /** @group DDC-1209 */ public function testIdentifierCanHaveCustomType(): void { $entity = new DDC1209Three(); @@ -39,9 +37,7 @@ public function testIdentifierCanHaveCustomType(): void self::assertSame($entity, $this->_em->find(DDC1209Three::class, $entity->date)); } - /** - * @group DDC-1209 - */ + /** @group DDC-1209 */ public function testCompositeIdentifierCanHaveCustomType(): void { $future1 = new DDC1209One(); @@ -63,15 +59,13 @@ public function testCompositeIdentifierCanHaveCustomType(): void 'startingDatetime' => $future2->startingDatetime, 'duringDatetime' => $future2->duringDatetime, 'endingDatetime' => $future2->endingDatetime, - ] - ) + ], + ), ); } } -/** - * @Entity - */ +/** @Entity */ class DDC1209One { /** @@ -87,9 +81,7 @@ public function getId(): int } } -/** - * @Entity - */ +/** @Entity */ class DDC1209Two { /** @@ -119,7 +111,7 @@ public function __construct( * @ManyToOne(targetEntity="DDC1209One") * @JoinColumn(referencedColumnName="id", nullable=false) */ - private DDC1209One $future1 + private DDC1209One $future1, ) { $this->startingDatetime = new DateTime2(); $this->duringDatetime = new DateTime2(); @@ -127,9 +119,7 @@ public function __construct( } } -/** - * @Entity - */ +/** @Entity */ class DDC1209Three { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index 86a4d7f1d5d..d17110330d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -15,9 +15,7 @@ use function strtolower; -/** - * @group DDC-1225 - */ +/** @group DDC-1225 */ class DDC1225Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -25,7 +23,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( DDC1225TestEntity1::class, - DDC1225TestEntity2::class + DDC1225TestEntity2::class, ); } @@ -39,7 +37,7 @@ public function testIssue(): void self::assertEquals( strtolower('SELECT t0_.test_entity2_id AS test_entity2_id_0 FROM te1 t0_ WHERE t0_.test_entity2_id = ?'), - strtolower($qb->getQuery()->getSQL()) + strtolower($qb->getQuery()->getSQL()), ); } } @@ -55,7 +53,7 @@ class DDC1225TestEntity1 * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225TestEntity2") * @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false) */ - private ?DDC1225TestEntity2 $testEntity2 = null; + private DDC1225TestEntity2|null $testEntity2 = null; public function setTestEntity2(DDC1225TestEntity2 $testEntity2): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php index 9f81fbbbea1..83c87f82c1f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php @@ -75,9 +75,7 @@ public function testRefresh(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1228User { /** @@ -106,9 +104,7 @@ public function getProfile(): DDC1228Profile } } -/** - * @Entity - */ +/** @Entity */ class DDC1228Profile { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php index d7e1845fa0a..d35e8c5dee5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -10,9 +10,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1238 - */ +/** @group DDC-1238 */ class DDC1238Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -65,9 +63,7 @@ public function testIssueProxyClear(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1238User { /** @@ -75,17 +71,17 @@ class DDC1238User * @GeneratedValue * @Column(type="integer") */ - private ?int $id = null; + private int|null $id = null; /** @Column */ - private ?string $name = null; + private string|null $name = null; - public function getId(): ?int + public function getId(): int|null { return $this->id; } - public function getName(): ?string + public function getName(): string|null { return $this->name; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php index 06998b6baa0..a77624883f0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1250 - */ +/** @group DDC-1250 */ class DDC1250Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -44,9 +42,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1250ClientHistory { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php index da19f707bd6..5ea32a8d3fa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1300 - */ +/** @group DDC-1300 */ class DDC1300Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -24,7 +22,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( DDC1300Foo::class, - DDC1300FooLocale::class + DDC1300FooLocale::class, ); } @@ -51,9 +49,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1300Foo { /** @@ -77,18 +73,14 @@ class DDC1300Foo */ public $fooLocaleRefFoo = null; - /** - * @param mixed[]|null $options - */ - public function __construct(?array $options = null) + /** @param mixed[]|null $options */ + public function __construct(array|null $options = null) { $this->fooLocaleRefFoo = new ArrayCollection(); } } -/** - * @Entity - */ +/** @Entity */ class DDC1300FooLocale { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php index 6485460372d..2a26bd1b2c1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php @@ -17,7 +17,7 @@ */ class DDC1301Test extends OrmFunctionalTestCase { - private ?int $userId = null; + private int|null $userId = null; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php index e1d212da262..6af2cbd4e6c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1306 - */ +/** @group DDC-1306 */ class DDC1306Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index 4c113882727..38b36430485 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -16,9 +16,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1335 - */ +/** @group DDC-1335 */ class DDC1335Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -154,9 +152,7 @@ private function loadFixture(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1335User { /** @@ -174,15 +170,11 @@ class DDC1335User public $phones; public function __construct( - /** - * @Column(type="string", length=255, unique=true) - */ + /** @Column(type="string", length=255, unique=true) */ public string $email, - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ public string $name, - array $numbers = [] + array $numbers = [], ) { $this->phones = new ArrayCollection(); @@ -192,9 +184,7 @@ public function __construct( } } -/** - * @Entity - */ +/** @Entity */ class DDC1335Phone { /** @@ -205,19 +195,15 @@ class DDC1335Phone */ public $id; - /** - * @param string $number - */ + /** @param string $number */ public function __construct( /** * @ManyToOne(targetEntity="DDC1335User", inversedBy="phones") * @JoinColumn(name="user_id", referencedColumnName="id", nullable = false) */ public DDC1335User $user, - /** - * @Column(name="numericalValue", type="string", nullable = false) - */ - public $numericalValue + /** @Column(name="numericalValue", type="string", nullable = false) */ + public $numericalValue, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php index dee785fd442..a4652fe5b78 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1400 - */ +/** @group DDC-1400 */ class DDC1400Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -25,7 +23,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC1400Article::class, DDC1400User::class, - DDC1400UserState::class + DDC1400UserState::class, ); } @@ -71,9 +69,7 @@ public function testFailingCase(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1400Article { /** @@ -91,9 +87,7 @@ class DDC1400Article public $userStates; } -/** - * @Entity - */ +/** @Entity */ class DDC1400User { /** @@ -111,9 +105,7 @@ class DDC1400User public $userStates; } -/** - * @Entity - */ +/** @Entity */ class DDC1400UserState { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index 9be7d3dbd36..0a3e801bc74 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -17,9 +17,7 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Exception; -/** - * @group DDC-1430 - */ +/** @group DDC-1430 */ class DDC1430Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -31,7 +29,7 @@ protected function setUp(): void [ $this->_em->getClassMetadata(DDC1430Order::class), $this->_em->getClassMetadata(DDC1430OrderProduct::class), - ] + ], ); $this->loadFixtures(); } catch (Exception) { @@ -141,9 +139,7 @@ public function loadFixtures(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1430Order { /** @@ -166,10 +162,8 @@ public function getId(): int } public function __construct( - /** - * @Column(name="order_status", type="string", length=255) - */ - private string $status + /** @Column(name="order_status", type="string", length=255) */ + private string $status, ) { $this->date = new DateTime(); $this->products = new ArrayCollection(); @@ -202,9 +196,7 @@ public function addProduct(DDC1430OrderProduct $product): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1430OrderProduct { /** @@ -219,13 +211,11 @@ class DDC1430OrderProduct * @ManyToOne(targetEntity="DDC1430Order", inversedBy="products") * @JoinColumn(name="order_id", referencedColumnName="order_id", nullable = false) */ - private ?DDC1430Order $order = null; + private DDC1430Order|null $order = null; public function __construct( - /** - * @Column(type="float") - */ - private float $value + /** @Column(type="float") */ + private float $value, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php index 79c30c2f98b..8ffa2a499d0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1436 - */ +/** @group DDC-1436 */ class DDC1436Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -56,9 +54,7 @@ public function testIdentityMap(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1436Page { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php index c4ac7cf3b2f..5a55b5d2286 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php @@ -22,13 +22,11 @@ protected function setUp(): void $this->createSchemaForModels( DDC144FlowElement::class, - DDC144Operand::class + DDC144Operand::class, ); } - /** - * @group DDC-144 - */ + /** @group DDC-144 */ public function testIssue(): void { $operand = new DDC144Operand(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php index 5aa90545af1..1f24b2fba02 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -17,9 +17,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1452 - */ +/** @group DDC-1452 */ class DDC1452Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -29,7 +27,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC1452EntityA::class, - DDC1452EntityB::class + DDC1452EntityB::class, ); } @@ -92,9 +90,7 @@ public function testFetchJoinOneToOneFromInverse(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1452EntityA { /** @@ -122,18 +118,14 @@ public function __construct() $this->entitiesB = new ArrayCollection(); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getEntitiesB(): Collection { return $this->entitiesB; } } -/** - * @Entity - */ +/** @Entity */ class DDC1452EntityB { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php index 8e2741c84b7..23c382e9742 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -16,9 +16,7 @@ use function mt_getrandmax; use function random_int; -/** - * @group DDC-1454 - */ +/** @group DDC-1454 */ class DDC1454Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -36,9 +34,7 @@ public function testFailingCase(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1454Picture extends DDC1454File { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php index 86b330d93d3..7d9a4df1450 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php @@ -18,7 +18,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( TestEntity::class, - TestAdditionalEntity::class + TestAdditionalEntity::class, ); } @@ -57,9 +57,7 @@ public function testIssue(): void } -/** - * @Entity - */ +/** @Entity */ class TestEntity { /** @@ -102,9 +100,7 @@ public function setAdditional(TestAdditionalEntity $additional): void $this->additional = $additional; } } -/** - * @Entity - */ +/** @Entity */ class TestAdditionalEntity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index 6bc2ebfea98..32f6dfcdc83 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -13,9 +13,7 @@ use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1461 - */ +/** @group DDC-1461 */ class DDC1461Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -24,7 +22,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC1461TwitterAccount::class, - DDC1461User::class + DDC1461User::class, ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php index 4de542f1ea4..ad3759e7d26 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1514 - */ +/** @group DDC-1514 */ class DDC1514Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -26,7 +24,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC1514EntityA::class, DDC1514EntityB::class, - DDC1514EntityC::class + DDC1514EntityC::class, ); } @@ -69,9 +67,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1514EntityA { /** @@ -106,9 +102,7 @@ public function __construct() } } -/** - * @Entity - */ +/** @Entity */ class DDC1514EntityB { /** @@ -131,9 +125,7 @@ class DDC1514EntityB public $entityATo; } -/** - * @Entity - */ +/** @Entity */ class DDC1514EntityC { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php index d8268f9ef8c..8e79f862517 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1515 - */ +/** @group DDC-1515 */ class DDC1515Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -21,7 +19,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( DDC1515Foo::class, - DDC1515Bar::class + DDC1515Bar::class, ); } @@ -42,9 +40,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1515Foo { /** @@ -55,9 +51,7 @@ class DDC1515Foo public $bar; } -/** - * @Entity - */ +/** @Entity */ class DDC1515Bar { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php index 380bdbd075c..65b9e2d3460 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1526 - */ +/** @group DDC-1526 */ class DDC1526Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -53,9 +51,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1526Menu { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php index 3255f3ac7bc..673ef13f432 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php @@ -8,16 +8,14 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1545 - */ +/** @group DDC-1545 */ class DDC1545Test extends OrmFunctionalTestCase { - private ?int $articleId = null; + private int|null $articleId = null; - private ?int $userId = null; + private int|null $userId = null; - private ?int $user2Id = null; + private int|null $user2Id = null; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php index 0486813fefb..ccae4bd04a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1548 - */ +/** @group DDC-1548 */ class DDC1548Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -22,7 +20,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC1548E1::class, DDC1548E2::class, - DDC1548Rel::class + DDC1548Rel::class, ); } @@ -44,9 +42,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1548E1 { /** @@ -57,9 +53,7 @@ class DDC1548E1 public $rel; } -/** - * @Entity - */ +/** @Entity */ class DDC1548E2 { /** @@ -70,9 +64,7 @@ class DDC1548E2 public $rel; } -/** - * @Entity - */ +/** @Entity */ class DDC1548Rel { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php index e7387a4a2cf..30908f3bfb8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC1595BaseInheritance::class, DDC1595InheritedEntity1::class, - DDC1595InheritedEntity2::class + DDC1595InheritedEntity2::class, ); } @@ -51,14 +51,14 @@ public function testIssue(): void // DDC-1596 $this->assertSQLEquals( "SELECT t0.id AS id_1, t0.type FROM base t0 WHERE t0.id = ? AND t0.type IN ('Entity1')", - $this->getLastLoggedQuery()['sql'] + $this->getLastLoggedQuery()['sql'], ); $entities = $entity1->getEntities()->getValues(); self::assertEquals( "SELECT t0.id AS id_1, t0.type FROM base t0 INNER JOIN entity1_entity2 ON t0.id = entity1_entity2.item WHERE entity1_entity2.parent = ? AND t0.type IN ('Entity2')", - $this->getLastLoggedQuery()['sql'] + $this->getLastLoggedQuery()['sql'], ); $this->_em->clear(); @@ -68,7 +68,7 @@ public function testIssue(): void $this->assertSQLEquals( 'SELECT COUNT(*) FROM entity1_entity2 t WHERE t.parent = ?', - $this->getLastLoggedQuery()['sql'] + $this->getLastLoggedQuery()['sql'], ); } } @@ -110,9 +110,7 @@ class DDC1595InheritedEntity1 extends DDC1595BaseInheritance */ protected $entities; - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getEntities(): Collection { return $this->entities; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php index c758eb04093..1f6880b43f6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php @@ -15,9 +15,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-163 - */ + /** @group DDC-163 */ public function testQueryWithOrConditionUsingTwoRelationOnSameEntity(): void { $p1 = new CompanyPerson(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php index e7967290e15..83380840c5c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php @@ -8,14 +8,12 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1643 - */ +/** @group DDC-1643 */ class DDC1643Test extends OrmFunctionalTestCase { - private ?CmsUser $user1; + private CmsUser|null $user1; - private ?CmsUser $user2; + private CmsUser|null $user2; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php index 02d734d613f..10015f0c9f8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1654 - */ +/** @group DDC-1654 */ class DDC1654Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -24,7 +22,7 @@ protected function setUp(): void [ DDC1654Post::class, DDC1654Comment::class, - ] + ], ); } @@ -74,9 +72,7 @@ public function testManyToManyRemoveElementFromCollectionOrphanRemoval(): void self::assertCount(0, $comments); } - /** - * @group DDC-3382 - */ + /** @group DDC-3382 */ public function testManyToManyRemoveElementFromReAddToCollectionOrphanRemoval(): void { $post = new DDC1654Post(); @@ -115,9 +111,7 @@ public function testManyToManyClearCollectionOrphanRemoval(): void self::assertCount(0, $comments); } - /** - * @group DDC-3382 - */ + /** @group DDC-3382 */ public function testManyToManyClearCollectionReAddOrphanRemoval(): void { $post = new DDC1654Post(); @@ -139,9 +133,7 @@ public function testManyToManyClearCollectionReAddOrphanRemoval(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1654Post { /** @@ -160,9 +152,7 @@ class DDC1654Post public $comments = []; } -/** - * @Entity - */ +/** @Entity */ class DDC1654Comment { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index 370f0092e31..0d45fcdf853 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -33,7 +33,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC1655Foo::class, DDC1655Bar::class, - DDC1655Baz::class + DDC1655Baz::class, ); } @@ -124,9 +124,7 @@ class DDC1655Foo */ public $baz; - /** - * @PostLoad - */ + /** @PostLoad */ public function postLoad(): void { $this->loaded++; @@ -142,18 +140,14 @@ class DDC1655Bar extends DDC1655Foo /** @var int */ public $subLoaded; - /** - * @PostLoad - */ + /** @PostLoad */ public function postSubLoaded(): void { $this->subLoaded++; } } -/** - * @Entity - */ +/** @Entity */ class DDC1655Baz { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php index 9fd6311bd01..ad13c659d9f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php @@ -8,9 +8,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1666 - */ +/** @group DDC-1666 */ class DDC1666Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php index c013e42845b..0e789d5f769 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php @@ -10,9 +10,7 @@ use Doctrine\Tests\OrmFunctionalTestCase; use RuntimeException; -/** - * @group DDC-1685 - */ +/** @group DDC-1685 */ class DDC1685Test extends OrmFunctionalTestCase { private Paginator $paginator; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php index f9980c8cbe8..982b4ee0d3c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php @@ -33,9 +33,7 @@ public function tearDown(): void parent::tearDown(); } - /** - * @group DDC-168 - */ + /** @group DDC-168 */ public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFieldsArray(): void { $spouse = new CompanyEmployee(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php index 1221b04ac8a..fbb0f26fee9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php @@ -113,10 +113,10 @@ class DDC1690Parent extends NotifyBaseEntity private int $id; /** @Column */ - private ?string $name = null; + private string|null $name = null; /** @OneToOne(targetEntity="DDC1690Child") */ - private ?DDC1690Child $child = null; + private DDC1690Child|null $child = null; public function getId(): int { @@ -156,10 +156,10 @@ class DDC1690Child extends NotifyBaseEntity private int $id; /** @Column */ - private ?string $name = null; + private string|null $name = null; /** @OneToOne(targetEntity="DDC1690Parent", mappedBy="child") */ - private ?DDC1690Parent $parent = null; + private DDC1690Parent|null $parent = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php index 7abeeefa233..a3eafb928e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1695 - */ +/** @group DDC-1695 */ class DDC1695Test extends OrmFunctionalTestCase { public function testIssue(): void @@ -29,7 +27,7 @@ public function testIssue(): void self::assertEquals( 'SELECT d0_."SmallText" AS SmallText_0, d0_."PublishDate" AS PublishDate_1 FROM "DDC1695News" d0_', - $sql + $sql, ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index 7ffb3768a8c..2186b4315e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -15,9 +15,7 @@ use Doctrine\ORM\Mapping\PostLoad; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1707 - */ +/** @group DDC-1707 */ class DDC1707Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -26,7 +24,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC1707Base::class, - DDC1707Child::class + DDC1707Child::class, ); } @@ -60,17 +58,13 @@ abstract class DDC1707Base /** @var bool */ public $postLoad = false; - /** - * @PostLoad - */ + /** @PostLoad */ public function onPostLoad(): void { $this->postLoad = true; } } -/** - * @Entity - */ +/** @Entity */ class DDC1707Child extends DDC1707Base { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php index ccd7663d5af..0f725be40ca 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php @@ -11,9 +11,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1719 - */ +/** @group DDC-1719 */ class DDC1719Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -98,10 +96,8 @@ class DDC1719SimpleEntity public $id; public function __construct( - /** - * @Column(type="string", name="`simple-entity-value`") - */ - public string $value + /** @Column(type="string", name="`simple-entity-value`") */ + public string $value, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php index b20b511c1b7..97e64973faa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php @@ -34,14 +34,12 @@ public function testFailingCase(): void self::assertEquals( 'SELECT _a FROM ' . __NAMESPACE__ . '\DDC1757A _a, ' . __NAMESPACE__ . '\DDC1757B _b INNER JOIN _b.c _c INNER JOIN _c.d _d', $dql, - 'Wrong DQL query' + 'Wrong DQL query', ); } } -/** - * @Entity - */ +/** @Entity */ class DDC1757A { /** @@ -52,9 +50,7 @@ class DDC1757A private int $id; } -/** - * @Entity - */ +/** @Entity */ class DDC1757B { /** @@ -68,9 +64,7 @@ class DDC1757B private DDC1757C $c; } -/** - * @Entity - */ +/** @Entity */ class DDC1757C { /** @@ -85,9 +79,7 @@ class DDC1757C private DDC1757D $d; } -/** - * @Entity - */ +/** @Entity */ class DDC1757D { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php index 55eef0b56d5..2fb2b51e373 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php @@ -8,14 +8,12 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1778 - */ +/** @group DDC-1778 */ class DDC1778Test extends OrmFunctionalTestCase { - private ?CmsUser $user; + private CmsUser|null $user; - private ?CmsPhonenumber $phone; + private CmsPhonenumber|null $phone; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php index 02abb943371..a3e3231d9a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1787 - */ +/** @group DDC-1787 */ class DDC1787Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -24,7 +22,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( DDC1787Foo::class, - DDC1787Bar::class + DDC1787Bar::class, ); } @@ -68,9 +66,7 @@ public function getVersion(): int } } -/** - * @Entity - */ +/** @Entity */ class DDC1787Bar extends DDC1787Foo { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php index c31acf44e5e..4f4b4a8394e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php @@ -10,9 +10,7 @@ use Doctrine\Tests\Models\Taxi\Ride; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1884 - */ +/** @group DDC-1884 */ class DDC1884Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php index b63e0e1807b..2fb1fb8d0b6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php @@ -11,9 +11,7 @@ use function iterator_to_array; -/** - * @group DDC-1918 - */ +/** @group DDC-1918 */ class DDC1918Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php index ffd8ecae13b..1dc0cb97a48 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php @@ -68,7 +68,7 @@ class DDC1925Product private int $id; /** @Column(name="title", type="string", length=255) */ - private ?string $title = null; + private string|null $title = null; /** * @psalm-var Collection @@ -132,7 +132,7 @@ class DDC1925User private int $id; /** @Column(name="title", type="string", length=255) */ - private ?string $title = null; + private string|null $title = null; /** * Get id diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php index 07a2f6d4a20..18f3ee16bef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-192 - */ +/** @group DDC-192 */ class DDC192Test extends OrmFunctionalTestCase { public function testSchemaCreation(): void @@ -32,7 +30,7 @@ public function testSchemaCreation(): void foreach ($classes as $class) { self::assertContains( $this->_em->getClassMetadata($class)->getTableName(), - $tables + $tables, ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php index 2e2cb0a5350..41d077add9d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php @@ -8,9 +8,7 @@ use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-1995 - */ +/** @group DDC-1995 */ class DDC1995Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index 640294ac6f9..95884614c94 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -13,9 +13,7 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Stringable; -/** - * @group DDC-1998 - */ +/** @group DDC-1998 */ class DDC1998Test extends OrmFunctionalTestCase { public function testSqlConversionAsIdentifier(): void @@ -48,9 +46,7 @@ public function testSqlConversionAsIdentifier(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC1998Entity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php index 3efcfaa48e1..57458451a10 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php @@ -26,7 +26,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC199ParentClass::class, DDC199ChildClass::class, - DDC199RelatedClass::class + DDC199RelatedClass::class, ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index 922e18c41dc..ddaf3e8524a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -39,7 +39,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC2012Item::class, - DDC2012ItemPerson::class + DDC2012ItemPerson::class, ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php index d5deaea3ad2..95c6507e219 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php @@ -10,9 +10,7 @@ use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2074 - */ +/** @group DDC-2074 */ class DDC2074Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php index 8e6aa405c59..d5050f86e2f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php @@ -9,9 +9,7 @@ use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2084 - */ +/** @group DDC-2084 */ class DDC2084Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -20,7 +18,7 @@ protected function setUp(): void $this->createSchemaForModels( __NAMESPACE__ . '\DDC2084\MyEntity1', - __NAMESPACE__ . '\DDC2084\MyEntity2' + __NAMESPACE__ . '\DDC2084\MyEntity2', ); } @@ -58,7 +56,7 @@ public function testInvalidIdentifierBindingEntityException(): void <<<'EXCEPTION' Binding entities to query parameters only allowed for entities that have an identifier. Class "Doctrine\Tests\ORM\Functional\Ticket\DDC2084\MyEntity2" does not have an identifier. -EXCEPTION +EXCEPTION, ); $this->_em->find(__NAMESPACE__ . '\DDC2084\MyEntity1', new MyEntity2('Foo')); } @@ -86,7 +84,7 @@ public function __construct( * @OneToOne(targetEntity="MyEntity2") * @JoinColumn(name="entity2_id", referencedColumnName="id", nullable=false) */ - private MyEntity2 $entity2 + private MyEntity2 $entity2, ) { } @@ -115,10 +113,8 @@ class MyEntity2 private int $id; public function __construct( - /** - * @Column - */ - private string $value + /** @Column */ + private string $value, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php index 8d9bd74d2e3..ed74875aea9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php @@ -15,9 +15,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2106 - */ +/** @group DDC-2106 */ class DDC2106Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -46,9 +44,7 @@ public function testDetachedEntityAsId(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC2106Entity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php index 21215b092bc..c06075cfce9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php @@ -91,9 +91,7 @@ public function setName(string $name): void $this->name = $name; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getGroups(): Collection { return $this->groups; @@ -136,9 +134,7 @@ public function setName(string $name): void $this->name = $name; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getUsers(): Collection { return $this->users; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index a2cc16a75e4..1d90f1bcbbd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -26,9 +26,7 @@ class DDC2138Test extends OrmFunctionalTestCase { - /** - * @group DDC-2138 - */ + /** @group DDC-2138 */ public function testForeignKeyOnSTIWithMultipleMapping(): void { $em = $this->_em; @@ -37,7 +35,7 @@ public function testForeignKeyOnSTIWithMultipleMapping(): void DDC2138Structure::class, DDC2138UserFollowedObject::class, DDC2138UserFollowedStructure::class, - DDC2138UserFollowedUser::class + DDC2138UserFollowedUser::class, ); self::assertTrue($schema->hasTable('users_followed_objects'), 'Table users_followed_objects should exist.'); @@ -107,9 +105,7 @@ public function getId(): int } } -/** - * @Entity - */ +/** @Entity */ class DDC2138UserFollowedStructure extends DDC2138UserFollowedObject { /** @@ -125,7 +121,7 @@ public function __construct( * @ManyToOne(targetEntity="DDC2138Structure") * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) */ - private Structure $followedStructure + private Structure $followedStructure, ) { } @@ -143,9 +139,7 @@ public function getFollowedStructure(): Structure } } -/** - * @Entity - */ +/** @Entity */ class DDC2138UserFollowedUser extends DDC2138UserFollowedObject { /** @@ -161,7 +155,7 @@ public function __construct( * @ManyToOne(targetEntity="DDC2138User") * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) */ - private User $followedUser + private User $followedUser, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php index 5bb724627f7..79195bdb017 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2175 - */ +/** @group DDC-2175 */ class DDC2175Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php index a785e43b03e..7f89c33dfdf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -25,7 +25,7 @@ public function testPassColumnOptionsToJoinColumns(): void [ $this->_em->getClassMetadata(DDC2182OptionParent::class), $this->_em->getClassMetadata(DDC2182OptionChild::class), - ] + ], ); self::assertEquals('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); self::assertEquals('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[1]); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index f3505607a65..a287d09faa1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -17,9 +17,7 @@ use function method_exists; use function sprintf; -/** - * @group DDC-2224 - */ +/** @group DDC-2224 */ class DDC2224Test extends OrmFunctionalTestCase { public static function setUpBeforeClass(): void @@ -39,9 +37,7 @@ public function testIssue(): Query return $query; } - /** - * @depends testIssue - */ + /** @depends testIssue */ public function testCacheMissWhenTypeChanges(Query $query): void { $query->setParameter('field', 'test', 'string'); @@ -77,9 +73,7 @@ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): } } -/** - * @Entity - */ +/** @Entity */ class DDC2224Entity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index 066303063d2..d43b2e21409 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -17,9 +17,7 @@ use function assert; -/** - * @group DDC-2230 - */ +/** @group DDC-2230 */ class DDC2230Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -28,7 +26,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC2230User::class, - DDC2230Address::class + DDC2230Address::class, ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index fddc77f6e89..09e9977694e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -19,9 +19,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2252 - */ +/** @group DDC-2252 */ class DDC2252Test extends OrmFunctionalTestCase { /** @psalm-var DDC2252User */ @@ -44,7 +42,7 @@ protected function setUp(): void DDC2252User::class, DDC2252Privilege::class, DDC2252Membership::class, - DDC2252MerchantAccount::class + DDC2252MerchantAccount::class, ); $this->loadFixtures(); @@ -190,9 +188,7 @@ public function getUid(): int return $this->uid; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getMemberships(): Collection { return $this->memberships; @@ -238,7 +234,7 @@ public function __construct( * @ManyToOne(targetEntity="DDC2252MerchantAccount") * @JoinColumn(name="mch_accountid", referencedColumnName="accountid") */ - protected DDC2252MerchantAccount $merchantAccount + protected DDC2252MerchantAccount $merchantAccount, ) { $this->privileges = new ArrayCollection(); } @@ -248,9 +244,7 @@ public function addPrivilege(DDC2252Privilege $privilege): void $this->privileges[] = $privilege; } - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ public function getPrivileges(): Collection { return $this->privileges; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index 5adfdf736f3..6194ff953c5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -17,9 +17,7 @@ use function assert; -/** - * @group DDC-2306 - */ +/** @group DDC-2306 */ class DDC2306Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -30,7 +28,7 @@ protected function setUp(): void DDC2306Zone::class, DDC2306User::class, DDC2306Address::class, - DDC2306UserAddress::class + DDC2306UserAddress::class, ); } @@ -79,7 +77,7 @@ public function testIssue(): void self::assertEquals( $userId, $user->id, - 'As of DDC-1734, the identifier is NULL for un-managed proxies. The identifier should be an integer here' + 'As of DDC-1734, the identifier is NULL for un-managed proxies. The identifier should be an integer here', ); } } @@ -96,9 +94,7 @@ class DDC2306Zone public $id; } -/** - * @Entity - */ +/** @Entity */ class DDC2306User { /** @@ -171,14 +167,10 @@ class DDC2306UserAddress /** Constructor */ public function __construct( - /** - * @ManyToOne(targetEntity="DDC2306User") - */ + /** @ManyToOne(targetEntity="DDC2306User") */ public DDC2306User $user, - /** - * @ManyToOne(targetEntity="DDC2306Address", fetch="LAZY") - */ - public DDC2306Address $address + /** @ManyToOne(targetEntity="DDC2306Address", fetch="LAZY") */ + public DDC2306Address $address, ) { $user->addresses->add($this); $address->users->add($this); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index 0dc4a79a95a..3295120c461 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -17,9 +17,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2346 - */ +/** @group DDC-2346 */ class DDC2346Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -29,7 +27,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC2346Foo::class, DDC2346Bar::class, - DDC2346Baz::class + DDC2346Baz::class, ); } @@ -115,9 +113,7 @@ class DDC2346Bar } -/** - * @Entity - */ +/** @Entity */ class DDC2346Baz extends DDC2346Bar { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php index 5eb1aaaccef..2f9e7c514bd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php @@ -52,9 +52,7 @@ public function testEagerCollectionsAreOnlyRetrievedOnce(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC2350User { /** @@ -72,9 +70,7 @@ class DDC2350User public $reportedBugs; } -/** - * @Entity - */ +/** @Entity */ class DDC2350Bug { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index fbbaf820140..870e5ea3dd7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -17,9 +17,7 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriver; use PHPUnit\Framework\TestCase; -/** - * @group DDC-2359 - */ +/** @group DDC-2359 */ class DDC2359Test extends TestCase { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php index de5ebaf0ea4..321c298f02f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -22,7 +22,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC237EntityX::class, DDC237EntityY::class, - DDC237EntityZ::class + DDC237EntityZ::class, ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php index f3fbaa5cb3a..0086cd3765e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php @@ -10,9 +10,7 @@ class DDC2387Test extends DatabaseDriverTestCase { - /** - * @group DDC-2387 - */ + /** @group DDC-2387 */ public function testCompositeAssociationKeyDetection(): void { $product = new Table('ddc2387_product'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php index 3a1a4ccb8aa..39c4cde555e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php @@ -12,9 +12,7 @@ use function md5; -/** - * @group DDC-2415 - */ +/** @group DDC-2415 */ class DDC2415Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -25,7 +23,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC2415ParentEntity::class, - DDC2415ChildEntity::class + DDC2415ChildEntity::class, ); } @@ -68,7 +66,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'id' => true, 'fieldName' => 'id', 'type' => 'string', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); @@ -95,14 +93,14 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'fieldName' => 'name', 'type' => 'string', - ] + ], ); } } class DDC2415Generator extends AbstractIdGenerator { - public function generateId(EntityManagerInterface $em, ?object $entity): string + public function generateId(EntityManagerInterface $em, object|null $entity): string { return md5($entity->getName()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index cebcfa0ee6e..314705c730d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -34,7 +34,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC2494Currency::class, - DDC2494Campaign::class + DDC2494Campaign::class, ); } @@ -99,10 +99,8 @@ public function __construct( * @Column(type="ddc2494_tinyint") */ protected int $id, - /** - * @Column(name="temp", type="ddc2494_tinyint", nullable=false) - */ - protected int $temp + /** @Column(name="temp", type="ddc2494_tinyint", nullable=false) */ + protected int $temp, ) { } @@ -116,9 +114,7 @@ public function getTemp(): int return $this->temp; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getCampaigns(): Collection { return $this->campaigns; @@ -144,7 +140,7 @@ public function __construct( * @ManyToOne(targetEntity="DDC2494Currency", inversedBy="campaigns") * @JoinColumn(name="currency_id", referencedColumnName="id", nullable=false) */ - protected DDC2494Currency $currency + protected DDC2494Currency $currency, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php index dab55094320..c0a7f308af3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\Legacy\LegacyUserReference; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2519 - */ +/** @group DDC-2519 */ class DDC2519Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -22,9 +20,7 @@ protected function setUp(): void $this->loadFixture(); } - /** - * @group DDC-2519 - */ + /** @group DDC-2519 */ public function testIssue(): void { $dql = 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l'; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index 9487c3562cd..dfef40b3b45 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2575 - */ +/** @group DDC-2575 */ class DDC2575Test extends OrmFunctionalTestCase { /** @psalm-var list */ @@ -33,7 +31,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC2575Root::class, DDC2575A::class, - DDC2575B::class + DDC2575B::class, ); $entityRoot1 = new DDC2575Root(1); @@ -97,9 +95,7 @@ public function testHydrationIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC2575Root { /** @@ -114,17 +110,13 @@ public function __construct( * @Column(type="integer") */ public int $id, - /** - * @Column(type="integer") - */ - public int $sampleField = 0 + /** @Column(type="integer") */ + public int $sampleField = 0, ) { } } -/** - * @Entity - */ +/** @Entity */ class DDC2575A { public function __construct( @@ -138,14 +130,12 @@ public function __construct( * @ManyToOne(targetEntity="DDC2575B") * @JoinColumn(name="b_id", referencedColumnName="id", nullable=FALSE, onDelete="CASCADE") */ - public DDC2575B $bRelation + public DDC2575B $bRelation, ) { } } -/** - * @Entity - */ +/** @Entity */ class DDC2575B { public function __construct( @@ -154,10 +144,8 @@ public function __construct( * @Column(type="integer") */ public int $id, - /** - * @Column(type="integer") - */ - public int $sampleField = 0 + /** @Column(type="integer") */ + public int $sampleField = 0, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index a5b13fe53f0..e9afd6e5f4c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -15,9 +15,7 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Stringable; -/** - * @group DDC-2579 - */ +/** @group DDC-2579 */ class DDC2579Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -29,7 +27,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC2579Entity::class, DDC2579EntityAssoc::class, - DDC2579AssocAssoc::class + DDC2579AssocAssoc::class, ); } @@ -69,9 +67,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC2579Entity { /** @@ -91,36 +87,29 @@ class DDC2579Entity public function __construct( DDC2579EntityAssoc $assoc, - /** - * @Column(type="integer") - */ - public int $value = 0 + /** @Column(type="integer") */ + public int $value = 0, ) { $this->id = $assoc->assocAssoc->associationId; $this->assoc = $assoc; } } -/** - * @Entity - */ +/** @Entity */ class DDC2579EntityAssoc { public function __construct( /** - * @var DDC2579AssocAssoc * @Id * @ManyToOne(targetEntity="DDC2579AssocAssoc") * @JoinColumn(name="association_id", referencedColumnName="associationId") */ - public $assocAssoc + public DDC2579AssocAssoc $assocAssoc, ) { } } -/** - * @Entity - */ +/** @Entity */ class DDC2579AssocAssoc { public function __construct( @@ -128,7 +117,7 @@ public function __construct( * @Id * @Column(type="ddc2579", length=255) */ - public DDC2579Id $associationId + public DDC2579Id $associationId, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php index 50780e34032..1f0065c3817 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -23,13 +23,11 @@ protected function setUp(): void DDC258Super::class, DDC258Class1::class, DDC258Class2::class, - DDC258Class3::class + DDC258Class3::class, ); } - /** - * @group DDC-258 - */ + /** @group DDC-258 */ public function testIssue(): void { $c1 = new DDC258Class1(); @@ -97,9 +95,7 @@ abstract class DDC258Super public $id; } -/** - * @Entity - */ +/** @Entity */ class DDC258Class1 extends DDC258Super { /** @@ -115,9 +111,7 @@ class DDC258Class1 extends DDC258Super public $description; } -/** - * @Entity - */ +/** @Entity */ class DDC258Class2 extends DDC258Super { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php index 510e0784013..7f6078e8443 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php @@ -22,9 +22,7 @@ use const JSON_THROW_ON_ERROR; -/** - * @group DDC-2602 - */ +/** @group DDC-2602 */ class DDC2602Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -35,7 +33,7 @@ protected function setUp(): void DDC2602User::class, DDC2602Biography::class, DDC2602BiographyField::class, - DDC2602BiographyFieldChoice::class + DDC2602BiographyFieldChoice::class, ); $this->loadFixture(); @@ -160,9 +158,7 @@ public function postLoad(LifecycleEventArgs $event): void } -/** - * @Entity - */ +/** @Entity */ class DDC2602User { /** @@ -191,9 +187,7 @@ class DDC2602User public $biography; } -/** - * @Entity - */ +/** @Entity */ class DDC2602Biography { /** @@ -224,9 +218,7 @@ class DDC2602Biography public $fieldList = []; } -/** - * @Entity - */ +/** @Entity */ class DDC2602BiographyField { /** @@ -265,9 +257,7 @@ public function __construct() } } -/** - * @Entity - */ +/** @Entity */ class DDC2602BiographyFieldChoice { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php index 05d0e8e7c42..5641e1b51c6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php @@ -7,9 +7,7 @@ use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2655 - */ +/** @group DDC-2655 */ class DDC2655Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php index 74c8a6d1c7f..73ed1e9a0a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php @@ -14,9 +14,7 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Exception; -/** - * @group DDC-2660 - */ +/** @group DDC-2660 */ class DDC2660Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -29,7 +27,7 @@ protected function setUp(): void $this->_em->getClassMetadata(DDC2660Product::class), $this->_em->getClassMetadata(DDC2660Customer::class), $this->_em->getClassMetadata(DDC2660CustomerOrder::class), - ] + ], ); } catch (Exception) { return; @@ -134,10 +132,8 @@ public function __construct( * @ManyToOne(targetEntity="DDC2660Customer") */ public DDC2660Customer $customer, - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index e9a1c0b3560..c7c3ecc348b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2692 - */ +/** @group DDC-2692 */ class DDC2692Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index 141c654c1bb..dd5dc6748f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -15,9 +15,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2759 - */ +/** @group DDC-2759 */ class DDC2759Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -28,7 +26,7 @@ protected function setUp(): void DDC2759Qualification::class, DDC2759Category::class, DDC2759QualificationMetadata::class, - DDC2759MetadataCategory::class + DDC2759MetadataCategory::class, ); $qualification = new DDC2759Qualification(); @@ -132,10 +130,8 @@ class DDC2759QualificationMetadata protected $metadataCategories; public function __construct( - /** - * @OneToOne(targetEntity="DDC2759Qualification", inversedBy="metadata") - */ - public DDC2759Qualification $content + /** @OneToOne(targetEntity="DDC2759Qualification", inversedBy="metadata") */ + public DDC2759Qualification $content, ) { } } @@ -155,14 +151,10 @@ class DDC2759MetadataCategory public $id; public function __construct( - /** - * @ManyToOne(targetEntity="DDC2759QualificationMetadata", inversedBy="metadataCategories") - */ + /** @ManyToOne(targetEntity="DDC2759QualificationMetadata", inversedBy="metadataCategories") */ public DDC2759QualificationMetadata $metadata, - /** - * @ManyToOne(targetEntity="DDC2759Category", inversedBy="metadataCategories") - */ - public DDC2759Category $category + /** @ManyToOne(targetEntity="DDC2759Category", inversedBy="metadataCategories") */ + public DDC2759Category $category, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php index 8093f331e1b..572d56d2269 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php @@ -32,13 +32,11 @@ protected function setUp(): void Role::class, AdminRole::class, Authorization::class, - ] + ], ); } - /** - * @group DDC-2775 - */ + /** @group DDC-2775 */ public function testIssueCascadeRemove(): void { $role = new AdminRole(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php index 64b8536d349..2e52037edd6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2780 - */ +/** @group DDC-2780 */ class DDC2780Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -52,9 +50,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC2780User { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php index 88fbf701925..4779d4deefd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php @@ -12,9 +12,7 @@ use function array_intersect_key; use function intval; -/** - * @group DDC-2790 - */ +/** @group DDC-2790 */ class DDC2790Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php index 218c3afd58b..f17170d99b6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php @@ -24,13 +24,11 @@ protected function setUp(): void DDC279EntityXAbstract::class, DDC279EntityX::class, DDC279EntityY::class, - DDC279EntityZ::class + DDC279EntityZ::class, ); } - /** - * @group DDC-279 - */ + /** @group DDC-279 */ public function testDDC279(): void { $x = new DDC279EntityX(); @@ -53,7 +51,7 @@ public function testDDC279(): void $query = $this->_em->createQuery( 'SELECT x, y, z FROM Doctrine\Tests\ORM\Functional\Ticket\DDC279EntityX x ' . - 'INNER JOIN x.y y INNER JOIN y.z z WHERE x.id = ?1' + 'INNER JOIN x.y y INNER JOIN y.z z WHERE x.id = ?1', )->setParameter(1, $x->id); $result = $query->getResult(); @@ -92,9 +90,7 @@ abstract class DDC279EntityXAbstract public $data; } -/** - * @Entity - */ +/** @Entity */ class DDC279EntityX extends DDC279EntityXAbstract { /** @@ -105,9 +101,7 @@ class DDC279EntityX extends DDC279EntityXAbstract public $y; } -/** - * @Entity - */ +/** @Entity */ class DDC279EntityY { /** @@ -132,9 +126,7 @@ class DDC279EntityY public $z; } -/** - * @Entity - */ +/** @Entity */ class DDC279EntityZ { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index dbac108568e..4cb956b7da4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -34,9 +34,7 @@ protected function setUp(): void } } - /** - * @dataProvider getTestedClasses - */ + /** @dataProvider getTestedClasses */ public function testClassSchemaMappingsValidity(string $className, string $expectedSchemaName, string $expectedTableName): void { $classMetadata = $this->_em->getClassMetadata($className); @@ -58,13 +56,11 @@ public function testClassSchemaMappingsValidity(string $className, string $expec // Checks sequence name validity self::assertEquals( $fullTableName . '_' . $classMetadata->getSingleIdentifierColumnName() . '_seq', - $classMetadata->getSequenceName($platform) + $classMetadata->getSequenceName($platform), ); } - /** - * @dataProvider getTestedClasses - */ + /** @dataProvider getTestedClasses */ public function testPersistenceOfEntityWithSchemaMapping(string $className): void { $this->createSchemaForModels($className); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index 73fc94ec6cf..902770b35cc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -129,15 +129,13 @@ class DDC2862Driver protected $id; public function __construct( - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ protected string $name, /** * @Cache() * @OneToOne(targetEntity="DDC2862User") */ - protected ?DDC2862User $userProfile = null + protected DDC2862User|null $userProfile = null, ) { } @@ -183,10 +181,8 @@ class DDC2862User protected $id; public function __construct( - /** - * @Column(type="string", length=255) - */ - protected string $name + /** @Column(type="string", length=255) */ + protected string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index e15bc61fdbe..7c9b13989b6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -34,7 +34,7 @@ public function testPostLoadOneToManyInheritance(): void 'prePersist' => ['setLastModifiedPreUpdate'], 'preUpdate' => ['setLastModifiedPreUpdate'], ], - $cm->lifecycleCallbacks + $cm->lifecycleCallbacks, ); $ddc2895 = new DDC2895(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index 820b4c1a80c..b5d0ea4071d 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -12,9 +12,7 @@ use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2931 - */ +/** @group DDC-2931 */ class DDC2931Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -72,7 +70,7 @@ public function testFetchJoinedEntitiesCanBeRefreshed(): void ->_em ->createQuery( 'SELECT e, p, c FROM ' - . __NAMESPACE__ . '\\DDC2931User e LEFT JOIN e.parent p LEFT JOIN e.child c WHERE e = :id' + . __NAMESPACE__ . '\\DDC2931User e LEFT JOIN e.parent p LEFT JOIN e.child c WHERE e = :id', ) ->setParameter('id', $second) ->setHint(Query::HINT_REFRESH, true) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php index 0d37fd55d2d..9ae5179a8c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2943 - */ +/** @group DDC-2943 */ class DDC2943Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 0a0a5cc1555..198d2f46fcc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -18,9 +18,7 @@ use function is_string; -/** - * @group DDC-2984 - */ +/** @group DDC-2984 */ class DDC2984Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -30,7 +28,7 @@ protected function setUp(): void if (! Type::hasType('ddc2984_domain_user_id')) { Type::addType( 'ddc2984_domain_user_id', - DDC2984UserIdCustomDbalType::class + DDC2984UserIdCustomDbalType::class, ); } @@ -69,7 +67,7 @@ public function testIssue(): void class DDC2984User { /** @Column(type="string", length=50) */ - private ?string $name = null; + private string|null $name = null; public function __construct( /** @@ -77,7 +75,7 @@ public function __construct( * @Column(type="ddc2984_domain_user_id", length=255) * @GeneratedValue(strategy="NONE") */ - private DDC2984DomainUserId $userId + private DDC2984DomainUserId $userId, ) { } @@ -139,7 +137,7 @@ public function getName(): string /** * {@inheritDoc} */ - public function convertToPHPValue($value, AbstractPlatform $platform): ?DDC2984DomainUserId + public function convertToPHPValue($value, AbstractPlatform $platform): DDC2984DomainUserId|null { return ! empty($value) ? new DDC2984DomainUserId($value) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index b6f86e24ce4..417e57190dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -13,16 +13,14 @@ use Doctrine\ORM\Mapping\PreFlush; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2996 - */ +/** @group DDC-2996 */ class DDC2996Test extends OrmFunctionalTestCase { public function testIssue(): void { $this->createSchemaForModels( DDC2996User::class, - DDC2996UserPreference::class + DDC2996UserPreference::class, ); $pref = new DDC2996UserPreference(); @@ -45,9 +43,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC2996User { /** @@ -89,9 +85,7 @@ class DDC2996UserPreference */ public $user; - /** - * @PreFlush - */ + /** @PreFlush */ public function preFlush($event): void { $em = $event->getEntityManager(); @@ -101,7 +95,7 @@ public function preFlush($event): void $this->user->counter++; $uow->recomputeSingleEntityChangeSet( $em->getClassMetadata($this->user::class), - $this->user + $this->user, ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index 7edc5ea9502..725d2bf254b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -20,16 +20,14 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-3033 - */ +/** @group DDC-3033 */ class DDC3033Test extends OrmFunctionalTestCase { public function testIssue(): void { $this->createSchemaForModels( DDC3033User::class, - DDC3033Product::class + DDC3033Product::class, ); $user = new DDC3033User(); @@ -107,16 +105,12 @@ public function __construct() $this->buyers = new ArrayCollection(); } - /** - * @PreUpdate - */ + /** @PreUpdate */ public function preUpdate(LifecycleEventArgs $eventArgs): void { } - /** - * @PostUpdate - */ + /** @PostUpdate */ public function postUpdate(LifecycleEventArgs $eventArgs): void { $em = $eventArgs->getObjectManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php index 7c77a32475f..c9de116adbb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php @@ -10,9 +10,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-3042 - */ +/** @group DDC-3042 */ class DDC3042Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -29,16 +27,14 @@ public function testSQLGenerationDoesNotProvokeAliasCollisions(): void $this ->_em ->createQuery( - 'SELECT f, b FROM ' . __NAMESPACE__ . '\DDC3042Foo f JOIN ' . __NAMESPACE__ . '\DDC3042Bar b WITH 1 = 1' + 'SELECT f, b FROM ' . __NAMESPACE__ . '\DDC3042Foo f JOIN ' . __NAMESPACE__ . '\DDC3042Bar b WITH 1 = 1', ) - ->getSQL() + ->getSQL(), ); } } -/** - * @Entity - */ +/** @Entity */ class DDC3042Foo { /** @@ -100,9 +96,7 @@ class DDC3042Foo public $field10; } -/** - * @Entity - */ +/** @Entity */ class DDC3042Bar { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php index 8d19f4d8a88..244165726a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\Taxi\Ride; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-3068 - */ +/** @group DDC-3068 */ class DDC3068Test extends OrmFunctionalTestCase { private Driver $foo; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php index 24e3f3e08c1..00bc3873b42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php @@ -64,9 +64,7 @@ public function testTwoToIterableHydrations(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC309Country { /** @@ -78,9 +76,7 @@ class DDC309Country public $id; } -/** - * @Entity - */ +/** @Entity */ class DDC309User { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php index caa252e7c99..0bc9e1a5525 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php @@ -12,14 +12,10 @@ use function serialize; use function unserialize; -/** - * @group DDC-3103 - */ +/** @group DDC-3103 */ class DDC3103Test extends OrmFunctionalTestCase { - /** - * @covers \Doctrine\ORM\Mapping\ClassMetadata::__sleep - */ + /** @covers \Doctrine\ORM\Mapping\ClassMetadata::__sleep */ public function testIssue(): void { $classMetadata = new ClassMetadata(DDC3103ArticleId::class); @@ -28,19 +24,17 @@ public function testIssue(): void self::assertTrue( $classMetadata->isEmbeddedClass, - 'The isEmbeddedClass property should be true from the mapping data.' + 'The isEmbeddedClass property should be true from the mapping data.', ); self::assertTrue( unserialize(serialize($classMetadata))->isEmbeddedClass, - 'The isEmbeddedClass property should still be true after serialization and unserialization.' + 'The isEmbeddedClass property should still be true after serialization and unserialization.', ); } } -/** - * @Embeddable - */ +/** @Embeddable */ class DDC3103ArticleId { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php index 29ff6eb818c..b3e692632ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php @@ -11,9 +11,7 @@ use PHPUnit\Framework\Assert; use ReflectionProperty; -/** - * @group DDC-3123 - */ +/** @group DDC-3123 */ class DDC3123Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -49,7 +47,7 @@ public function postFlush(): void Assert::assertEmpty( $property->getValue($this->uow), - 'ExtraUpdates are reset before postFlush' + 'ExtraUpdates are reset before postFlush', ); } }); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php index bb61473dce4..39d41ba4b85 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php @@ -20,9 +20,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-3160 - */ + /** @group DDC-3160 */ public function testNoUpdateOnInsert(): void { $listener = new DDC3160OnFlushListener(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php index 6dcdbaaeb4e..c521e9fb557 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-2306 - */ +/** @group DDC-2306 */ class DDC3170Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -27,7 +25,7 @@ protected function setUp(): void DDC3170AbstractEntityJoined::class, DDC3170ProductJoined::class, DDC3170AbstractEntitySingleTable::class, - DDC3170ProductSingleTable::class + DDC3170ProductSingleTable::class, ); } @@ -87,9 +85,7 @@ abstract class DDC3170AbstractEntityJoined public $id; } -/** - * @Entity - */ +/** @Entity */ class DDC3170ProductJoined extends DDC3170AbstractEntityJoined { } @@ -111,9 +107,7 @@ abstract class DDC3170AbstractEntitySingleTable public $id; } -/** - * @Entity - */ +/** @Entity */ class DDC3170ProductSingleTable extends DDC3170AbstractEntitySingleTable { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index aaa0e7d83d1..62ad870f4dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -32,7 +32,7 @@ protected function setUp(): void if (Type::hasType('ddc3192_currency_code')) { self::fail( 'Type ddc3192_currency_code exists for testing DDC-3192 only, ' . - 'but it has already been registered for some reason' + 'but it has already been registered for some reason', ); } @@ -40,7 +40,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC3192Currency::class, - DDC3192Transaction::class + DDC3192Transaction::class, ); } @@ -94,7 +94,7 @@ public function __construct( * @Id * @Column(type="ddc3192_currency_code") */ - public string $code + public string $code, ) { } } @@ -114,15 +114,13 @@ class DDC3192Transaction public $id; public function __construct( - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ public int $amount, /** * @ManyToOne(targetEntity="DDC3192Currency", inversedBy="transactions") * @JoinColumn(name="currency_id", referencedColumnName="code", nullable=false) */ - public DDC3192Currency $currency + public DDC3192Currency $currency, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php index 43709878ee3..0f800dd1afa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php @@ -30,7 +30,7 @@ protected function setUp(): void Participant::class, Status::class, ProfileStatus::class, - ] + ], ); } @@ -114,9 +114,7 @@ public function getId(): int } } -/** - * @Entity - */ +/** @Entity */ class ProfileStatus extends Status { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index c0c9bfe927a..1d41cba4dfc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Tools\ResolveTargetEntityListener; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-3300 - */ +/** @group DDC-3300 */ class DDC3300Test extends OrmFunctionalTestCase { public function testResolveTargetEntitiesChangesDiscriminatorMapValues(): void @@ -26,13 +24,13 @@ public function testResolveTargetEntitiesChangesDiscriminatorMapValues(): void $resolveTargetEntity->addResolveTargetEntity( DDC3300Boss::class, DDC3300HumanBoss::class, - [] + [], ); $resolveTargetEntity->addResolveTargetEntity( DDC3300Employee::class, DDC3300HumanEmployee::class, - [] + [], ); $this->_em->getEventManager()->addEventSubscriber($resolveTargetEntity); @@ -81,10 +79,8 @@ interface DDC3300Boss class DDC3300HumanBoss extends DDC3300Person implements DDC3300Boss { public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $bossCol + /** @Column(type="string", length=255) */ + public string $bossCol, ) { } } @@ -97,10 +93,8 @@ interface DDC3300Employee class DDC3300HumanEmployee extends DDC3300Person implements DDC3300Employee { public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $employeeCol + /** @Column(type="string", length=255) */ + public string $employeeCol, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php index 776dfb68f95..491623ec730 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -35,7 +35,7 @@ public function testEmbeddedObjectsAreAlsoInherited(): void $employee = new DDC3303Employee( 'John Doe', new DDC3303Address('Somewhere', 123, 'Over the rainbow'), - 'Doctrine Inc' + 'Doctrine Inc', ); $this->_em->persist($employee); @@ -56,32 +56,22 @@ public function __construct( * @Column(type="string", length=255) */ private string $name, - /** - * @Embedded(class="DDC3303Address") - */ - private DDC3303Address $address + /** @Embedded(class="DDC3303Address") */ + private DDC3303Address $address, ) { } } -/** - * @Embeddable - */ +/** @Embeddable */ class DDC3303Address { public function __construct( - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $street, - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ private int $number, - /** - * @Column(type="string", length=255) - */ - private string $city + /** @Column(type="string", length=255) */ + private string $city, ) { } } @@ -95,10 +85,8 @@ class DDC3303Employee extends DDC3303Person public function __construct( string $name, DDC3303Address $address, - /** - * @Column(type="string", length=255) - */ - private string $company + /** @Column(type="string", length=255) */ + private string $company, ) { parent::__construct($name, $address); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php index 128245576b0..c502e587a7f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php @@ -19,15 +19,13 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-331 - */ + /** @group DDC-331 */ public function testSelectFieldOnRootEntity(): void { $q = $this->_em->createQuery('SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e'); self::assertEquals( strtolower('SELECT c0_.name AS name_0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id'), - strtolower($q->getSQL()) + strtolower($q->getSQL()), ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php index ff70572f41a..7346ada62a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php @@ -30,7 +30,7 @@ protected function setUp(): void [ DDC3330Building::class, DDC3330Hall::class, - ] + ], ); } @@ -46,7 +46,7 @@ public function testIssueCollectionOrderWithPaginator(): void 'SELECT b, h' . ' FROM Doctrine\Tests\ORM\Functional\Ticket\DDC3330Building b' . ' LEFT JOIN b.halls h' . - ' ORDER BY b.id ASC, h.name DESC' + ' ORDER BY b.id ASC, h.name DESC', ) ->setMaxResults(3); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php index a3ddde88e88..71668124184 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php @@ -10,9 +10,7 @@ use function assert; -/** - * @group DDC-3346 - */ +/** @group DDC-3346 */ class DDC3346Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -27,7 +25,7 @@ protected function setUp(): void public function testFindOneWithEagerFetchWillNotHydrateLimitedCollection(): void { $author = $this->_em->getRepository(DDC3346Author::class)->findOneBy( - ['username' => 'bwoogy'] + ['username' => 'bwoogy'], ); assert($author instanceof DDC3346Author); @@ -40,7 +38,7 @@ public function testFindLimitedWithEagerFetchWillNotHydrateLimitedCollection(): $authors = $this->_em->getRepository(DDC3346Author::class)->findBy( ['username' => 'bwoogy'], null, - 1 + 1, ); self::assertCount(1, $authors); @@ -54,7 +52,7 @@ public function testFindWithEagerFetchAndOffsetWillNotHydrateLimitedCollection() ['username' => 'bwoogy'], null, null, - 0 // using an explicitly defined offset + 0, // using an explicitly defined offset ); self::assertCount(1, $authors); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php index f23f1ae166c..6bca5557925 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -30,7 +30,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC345User::class, DDC345Group::class, - DDC345Membership::class + DDC345Membership::class, ); } @@ -69,9 +69,7 @@ public function testTwoIterateHydrations(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC345User { /** @@ -100,9 +98,7 @@ public function __construct() } } -/** - * @Entity - */ +/** @Entity */ class DDC345Group { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index 53b4d557203..a6b1a879731 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -72,9 +72,7 @@ public function testFailingCase(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC353Picture { /** @@ -90,7 +88,7 @@ class DDC353Picture * @JoinColumn(name="file_id", referencedColumnName="file_id") * }) */ - private ?DDC353File $file = null; + private DDC353File|null $file = null; public function getPictureId(): int { @@ -108,9 +106,7 @@ public function getFile(): DDC353File } } -/** - * @Entity - */ +/** @Entity */ class DDC353File { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php index 0886a6b5d26..7a52d0602a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php @@ -45,7 +45,7 @@ public function __construct( * @Column * @Id */ - private string $id + private string $id, ) { $this->embeddable1 = new DDC3582Embeddable1(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php index b20466f41b2..002fa53f03e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\DDC3597\DDC3597Root; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-117 - */ +/** @group DDC-117 */ class DDC3597Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -20,13 +18,11 @@ protected function setUp(): void $this->createSchemaForModels( DDC3597Root::class, DDC3597Media::class, - DDC3597Image::class + DDC3597Image::class, ); } - /** - * @group DDC-3597 - */ + /** @group DDC-3597 */ public function testSaveImageEntity(): void { $imageEntity = new DDC3597Image('foobar'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index 7e83ee87bc0..a0feed423de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -22,9 +22,7 @@ use const PHP_INT_MAX; -/** - * @group DDC-3634 - */ +/** @group DDC-3634 */ class DDC3634Test extends OrmFunctionalTestCase { private LastInsertIdMocker $idMocker; @@ -49,7 +47,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC3634Entity::class, DDC3634JTIBaseEntity::class, - DDC3634JTIChildEntity::class + DDC3634JTIChildEntity::class, ); } @@ -125,7 +123,7 @@ class DDC3634JTIChildEntity extends DDC3634JTIBaseEntity class LastInsertIdMocker { - public ?string $mockedId = null; + public string|null $mockedId = null; } final class LastInsertIdMockConnection extends AbstractConnectionMiddleware @@ -155,7 +153,7 @@ public function connect(array $params): LastInsertIdMockConnection { return new LastInsertIdMockConnection( parent::connect($params), - $this->idMocker + $this->idMocker, ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php index dd8a7563a37..a489027d894 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php @@ -33,13 +33,11 @@ protected function setUp(): void DDC3644Address::class, DDC3644Animal::class, DDC3644Pet::class, - ] + ], ); } - /** - * @group DDC-3644 - */ + /** @group DDC-3644 */ public function testIssueWithRegularEntity(): void { // Define initial dataset @@ -89,9 +87,7 @@ public function testIssueWithRegularEntity(): void self::assertCount(1, $addresses); } - /** - * @group DDC-3644 - */ + /** @group DDC-3644 */ public function testIssueWithJoinedEntity(): void { // Define initial dataset @@ -140,9 +136,7 @@ public function testIssueWithJoinedEntity(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC3644User { /** @@ -190,9 +184,7 @@ public function setPets(Collection $pets): void } } -/** - * @Entity - */ +/** @Entity */ class DDC3644Address { /** @@ -211,10 +203,8 @@ class DDC3644Address public $user; public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $address + /** @Column(type="string", length=255) */ + public string $address, ) { } } @@ -236,17 +226,13 @@ abstract class DDC3644Animal public $id; public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } } -/** - * @Entity - */ +/** @Entity */ class DDC3644Pet extends DDC3644Animal { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php index d6a3c48c3e5..9cee857a993 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php @@ -17,9 +17,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-3719 - */ + /** @group DDC-3719 */ public function testCriteriaOnNotOwningSide(): void { $manager = new CompanyManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index 8f3ca785963..87e889b89fe 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -17,9 +17,7 @@ use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-371 - */ +/** @group DDC-371 */ class DDC371Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php index 1aacd0b3222..209de09dfd9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php @@ -31,13 +31,11 @@ protected function setUp(): void $this->createSchemaForModels( DDC3785Asset::class, DDC3785AssetId::class, - DDC3785Attribute::class + DDC3785Attribute::class, ); } - /** - * @group DDC-3785 - */ + /** @group DDC-3785 */ public function testOwningValueObjectIdIsCorrectlyTransformedWhenRemovingOrphanedChildEntities(): void { $id = new DDC3785AssetId('919609ba-57d9-4a13-be1d-d202521e858a'); @@ -79,9 +77,7 @@ class DDC3785Asset */ private $attributes; - /** - * @psalm-param list $attributes - */ + /** @psalm-param list $attributes */ public function __construct( /** * @Id @@ -89,7 +85,7 @@ public function __construct( * @Column(type="ddc3785_asset_id") */ private DDC3785AssetId $id, - $attributes = [] + $attributes = [], ) { $this->attributes = new ArrayCollection(); @@ -103,9 +99,7 @@ public function getId(): DDC3785AssetId return $this->id; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getAttributes() { return $this->attributes; @@ -127,14 +121,10 @@ class DDC3785Attribute public $id; public function __construct( - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ private string $name, - /** - * @Column(type="string", length=255) - */ - private string $value + /** @Column(type="string", length=255) */ + private string $value, ) { } } @@ -143,10 +133,8 @@ public function __construct( class DDC3785AssetId implements Stringable { public function __construct( - /** - * @Column(type = "guid") - */ - private string $id + /** @Column(type = "guid") */ + private string $id, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php index 80f012401c5..1025f1e0e22 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php @@ -43,9 +43,7 @@ public function testCallUnserializedProxyMethods(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC381Entity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php index 60e622285c2..4cc73f0085c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php @@ -7,9 +7,7 @@ use Doctrine\ORM\NonUniqueResultException; use Doctrine\Tests\DoctrineTestCase; -/** - * @group DDC4024 - */ +/** @group DDC4024 */ final class DDC4024Test extends DoctrineTestCase { public function testConstructorShouldUseProvidedMessage(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index 0ccfc3e652a..fedfb56dd22 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -28,13 +28,11 @@ protected function setUp(): void $this->createSchemaForModels( DDC422Guest::class, DDC422Customer::class, - DDC422Contact::class + DDC422Contact::class, ); } - /** - * @group DDC-422 - */ + /** @group DDC-422 */ public function testIssue(): void { $customer = new DDC422Customer(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php index bdd852d213a..b6324c0ff0b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php @@ -20,9 +20,7 @@ protected function setUp(): void $this->createSchemaForModels(DDC425Entity::class); } - /** - * @group DDC-425 - */ + /** @group DDC-425 */ public function testIssue(): void { $num = $this->_em->createQuery('DELETE ' . __NAMESPACE__ . '\DDC425Entity e WHERE e.someDatetimeField > ?1') diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php index 0404c668b0e..8e7b487e897 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -26,9 +26,7 @@ protected function setUp(): void $this->createSchemaForModels(DDC440Phone::class, DDC440Client::class); } - /** - * @group DDC-440 - */ + /** @group DDC-440 */ public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations(): void { /* The key of the problem is that the first phone is fetched via two association, mainPhone and phones. @@ -201,9 +199,7 @@ public function addPhone(DDC440Phone $value): void $value->setClient($this, false); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getPhones(): Collection { return $this->phones; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php index bf96fb96d2f..0675a92bd72 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC448MainTable::class, DDC448ConnectedClass::class, - DDC448SubTable::class + DDC448SubTable::class, ); } @@ -36,7 +36,7 @@ public function testIssue(): void $q = $this->_em->createQuery('select b from ' . __NAMESPACE__ . '\\DDC448SubTable b where b.connectedClassId = ?1'); self::assertEquals( strtolower('SELECT d0_.id AS id_0, d0_.discr AS discr_1, d0_.connectedClassId AS connectedClassId_2 FROM SubTable s1_ INNER JOIN DDC448MainTable d0_ ON s1_.id = d0_.id WHERE d0_.connectedClassId = ?'), - strtolower($q->getSQL()) + strtolower($q->getSQL()), ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php index 98181d12391..061821a2580 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php @@ -25,7 +25,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC493Customer::class, DDC493Distributor::class, - DDC493Contact::class + DDC493Contact::class, ); } @@ -34,7 +34,7 @@ public function testIssue(): void $q = $this->_em->createQuery('select u, c.data from ' . __NAMESPACE__ . '\\DDC493Distributor u JOIN u.contact c'); self::assertEquals( strtolower('SELECT d0_.id AS id_0, d1_.data AS data_1, d0_.discr AS discr_2, d0_.contact AS contact_3 FROM DDC493Distributor d2_ INNER JOIN DDC493Customer d0_ ON d2_.id = d0_.id INNER JOIN DDC493Contact d1_ ON d0_.contact = d1_.id'), - strtolower($q->getSQL()) + strtolower($q->getSQL()), ); } } @@ -62,16 +62,12 @@ class DDC493Customer public $contact; } -/** - * @Entity - */ +/** @Entity */ class DDC493Distributor extends DDC493Customer { } -/** - * @Entity - */ +/** @Entity */ class DDC493Contact { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php index da8d3c73507..008f5794d75 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php @@ -23,7 +23,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC512Customer::class, DDC512OfferItem::class, - DDC512Item::class + DDC512Item::class, ); } @@ -57,9 +57,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC512Customer { /** @@ -81,9 +79,7 @@ class DDC512Customer public $item; } -/** - * @Entity - */ +/** @Entity */ class DDC512OfferItem extends DDC512Item { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php index 7d530384f57..e78a0a942c2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php @@ -25,7 +25,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC513OfferItem::class, DDC513Item::class, - DDC513Price::class + DDC513Price::class, ); } @@ -34,14 +34,12 @@ public function testIssue(): void $q = $this->_em->createQuery('select u from ' . __NAMESPACE__ . '\\DDC513OfferItem u left join u.price p'); self::assertEquals( strtolower('SELECT d0_.id AS id_0, d0_.discr AS discr_1, d0_.price AS price_2 FROM DDC513OfferItem d1_ INNER JOIN DDC513Item d0_ ON d1_.id = d0_.id LEFT JOIN DDC513Price d2_ ON d0_.price = d2_.id'), - strtolower($q->getSQL()) + strtolower($q->getSQL()), ); } } -/** - * @Entity - */ +/** @Entity */ class DDC513OfferItem extends DDC513Item { } @@ -70,9 +68,7 @@ class DDC513Item public $price; } -/** - * @Entity - */ +/** @Entity */ class DDC513Price { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index f37e1dbdae6..96843c6aa4d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -26,13 +26,11 @@ protected function setUp(): void $this->createSchemaForModels( DDC522Customer::class, DDC522Cart::class, - DDC522ForeignKeyTest::class + DDC522ForeignKeyTest::class, ); } - /** - * @group DDC-522 - */ + /** @group DDC-522 */ public function testJoinColumnWithSameNameAsAssociationField(): void { $cust = new DDC522Customer(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php index d9299555d8e..40daa7de47c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php @@ -26,7 +26,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( DDC531Item::class, - DDC531SubItem::class + DDC531SubItem::class, ); } @@ -92,18 +92,14 @@ public function getParent(): DDC531Item return $this->parent; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getChildren(): Collection { return $this->children; } } -/** - * @Entity - */ +/** @Entity */ class DDC531SubItem extends DDC531Item { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php index eacfd9cde71..00da592737e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -32,9 +32,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC588Site { /** @@ -46,10 +44,8 @@ class DDC588Site public $id; public function __construct( - /** - * @Column(type="string", length=45) - */ - protected string $name = '' + /** @Column(type="string", length=45) */ + protected string $name = '', ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php index ecb0495d038..0894c2d3158 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC599Item::class, DDC599Subitem::class, - DDC599Child::class + DDC599Child::class, ); } @@ -109,18 +109,14 @@ public function __construct() $this->children = new ArrayCollection(); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getChildren(): Collection { return $this->children; } } -/** - * @Entity - */ +/** @Entity */ class DDC599Subitem extends DDC599Item { /** @@ -130,9 +126,7 @@ class DDC599Subitem extends DDC599Item public $elem; } -/** - * @Entity - */ +/** @Entity */ class DDC599Child { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index 83339b3566f..6e95b974c31 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -16,9 +16,7 @@ use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-618 - */ +/** @group DDC-618 */ class DDC618Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -73,9 +71,7 @@ public function testIndexByHydrateArray(): void self::assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); } - /** - * @group DDC-1018 - */ + /** @group DDC-1018 */ public function testIndexByJoin(): void { $dql = 'SELECT A, B FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A ' . @@ -97,9 +93,7 @@ public function testIndexByJoin(): void self::assertTrue(isset($result[0]['books']['Test']), 'Indexing by title should have books by title.'); } - /** - * @group DDC-1018 - */ + /** @group DDC-1018 */ public function testIndexByToOneJoinSilentlyIgnored(): void { $dql = 'SELECT B, A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Book B ' . @@ -116,9 +110,7 @@ public function testIndexByToOneJoinSilentlyIgnored(): void self::assertEquals('Alice', $result[0]['author']['name']); } - /** - * @group DDC-1018 - */ + /** @group DDC-1018 */ public function testCombineIndexBy(): void { $dql = 'SELECT A, B FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A INDEX BY A.id ' . @@ -135,9 +127,7 @@ public function testCombineIndexBy(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC618Author { /** @@ -171,9 +161,7 @@ public function addBook(string $title): void } } -/** - * @Entity - */ +/** @Entity */ class DDC618Book { /** @@ -185,14 +173,10 @@ class DDC618Book public $id; public function __construct( - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ public string $title, - /** - * @ManyToOne(targetEntity="DDC618Author", inversedBy="books") - */ - public DDC618Author $author + /** @ManyToOne(targetEntity="DDC618Author", inversedBy="books") */ + public DDC618Author $author, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php index cdca83c5c90..ca231826825 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php @@ -21,9 +21,7 @@ use function array_walk; use function count; -/** - * @group #6303 - */ +/** @group #6303 */ class DDC6303Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -33,7 +31,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC6303BaseClass::class, DDC6303ChildA::class, - DDC6303ChildB::class + DDC6303ChildB::class, ); } @@ -118,10 +116,8 @@ class DDC6303ChildA extends DDC6303BaseClass { public function __construct( string $id, - /** - * @Column(type="string", length=255) - */ - private mixed $originalData + /** @Column(type="string", length=255) */ + private mixed $originalData, ) { $this->id = $id; } @@ -133,15 +129,11 @@ public function __construct( */ class DDC6303ChildB extends DDC6303BaseClass { - /** - * @param mixed[] $originalData - */ + /** @param mixed[] $originalData */ public function __construct( string $id, - /** - * @Column(type="simple_array", nullable=true) - */ - private array $originalData + /** @Column(type="simple_array", nullable=true) */ + private array $originalData, ) { $this->id = $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php index 12f04591656..36d05161232 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php @@ -19,7 +19,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( DDC633Patient::class, - DDC633Appointment::class + DDC633Appointment::class, ); } @@ -75,9 +75,7 @@ public function testDQLDeferredEagerLoad(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC633Appointment { /** @@ -95,9 +93,7 @@ class DDC633Appointment public $patient; } -/** - * @Entity - */ +/** @Entity */ class DDC633Patient { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php index fffc1ff34f9..c05baa7eb99 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php @@ -26,15 +26,13 @@ protected function setUp(): void [ DDC6460Entity::class, DDC6460ParentEntity::class, - ] + ], ); } catch (SchemaException) { } } - /** - * @group DDC-6460 - */ + /** @group DDC-6460 */ public function testInlineEmbeddable(): void { $isFieldMapped = $this->_em @@ -44,9 +42,7 @@ public function testInlineEmbeddable(): void self::assertTrue($isFieldMapped); } - /** - * @group DDC-6460 - */ + /** @group DDC-6460 */ public function testInlineEmbeddableProxyInitialization(): void { $entity = new DDC6460Entity(); @@ -73,9 +69,7 @@ public function testInlineEmbeddableProxyInitialization(): void } } -/** - * @Embeddable() - */ +/** @Embeddable() */ class DDC6460Embeddable { /** @@ -85,9 +79,7 @@ class DDC6460Embeddable public $field; } -/** - * @Entity() - */ +/** @Entity() */ class DDC6460Entity { /** @@ -105,9 +97,7 @@ class DDC6460Entity public $embedded; } -/** - * @Entity() - */ +/** @Entity() */ class DDC6460ParentEntity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index 5bf16c34d63..3804149d77a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -44,9 +44,7 @@ public function testRecomputeSingleEntityChangeSetPreservesFieldOrder(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC656Entity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php index 19ac140c5de..5b7168855e7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-657 - */ +/** @group DDC-657 */ class DDC657Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php index f53b69fa77f..62c84572de6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php @@ -36,7 +36,7 @@ public function testTicket(): void self::assertEquals( strtolower('SELECT p0_.privilegeID AS privilegeID_0, p0_.name AS name_1, r1_.roleID AS roleID_2, r1_.name AS name_3, r1_.shortName AS shortName_4 FROM Privileges p0_ LEFT JOIN RolePrivileges r2_ ON p0_.privilegeID = r2_.privilegeID LEFT JOIN Roles r1_ ON r1_.roleID = r2_.roleID'), - strtolower($sql) + strtolower($sql), ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php index dfee1bd5e62..415a80fe80a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php @@ -121,7 +121,7 @@ class Lemma private int $id; /** @Column(type="string", name="lemma_name", unique=true, length=255) */ - private ?string $lemma = null; + private string|null $lemma = null; /** * @var Collection @@ -164,9 +164,7 @@ public function removeRelation(Relation $relation): void } } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getRelations(): Collection { return $this->relations; @@ -192,19 +190,19 @@ class Relation * @ManyToOne(targetEntity="Lemma", inversedBy="relations") * @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id") */ - private ?Lemma $parent = null; + private Lemma|null $parent = null; /** * @OneToOne(targetEntity="Lemma") * @JoinColumn(name="relation_child_id", referencedColumnName="lemma_id") */ - private ?Lemma $child = null; + private Lemma|null $child = null; /** * @ManyToOne(targetEntity="RelationType", inversedBy="relations") * @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id") */ - private ?RelationType $type = null; + private RelationType|null $type = null; public function setParent(Lemma $parent): void { @@ -271,10 +269,10 @@ class RelationType private int $id; /** @Column(type="string", name="relation_type_name", unique=true, length=255) */ - private ?string $type = null; + private string|null $type = null; /** @Column(type="string", name="relation_type_abbreviation", unique=true, length=255) */ - private ?string $abbreviation = null; + private string|null $abbreviation = null; /** * @var Collection @@ -327,9 +325,7 @@ public function removeRelation(Relation $relation): void } } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getRelations(): Collection { return $this->relations; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php index a24724c270c..13c7601fd0e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -35,14 +35,12 @@ public function testIsEmptySqlGeneration(): void self::assertEquals( strtolower($referenceSQL), - strtolower($q->getSQL()) + strtolower($q->getSQL()), ); } } -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ class MyEntity { /** @@ -141,25 +139,19 @@ public function setDescription(string $description): void $this->description = $description; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getChildren(): Collection { return $this->children; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getParents(): Collection { return $this->parents; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getChannels(): Collection { return $this->channels; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php index 5694ff91b1e..9e319510e13 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -54,9 +54,7 @@ public function testRemoveElementAppliesOrphanRemoval(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC735Product { /** @@ -83,9 +81,7 @@ public function __construct() $this->reviews = new ArrayCollection(); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getReviews(): Collection { return $this->reviews; @@ -102,9 +98,7 @@ public function removeReview(DDC735Review $review): void } } -/** - * @Entity - */ +/** @Entity */ class DDC735Review { /** @@ -116,10 +110,8 @@ class DDC735Review protected $id; public function __construct( - /** - * @ManyToOne(targetEntity="DDC735Product", inversedBy="reviews") - */ - protected DDC735Product $product + /** @ManyToOne(targetEntity="DDC735Product", inversedBy="reviews") */ + protected DDC735Product $product, ) { $product->addReview($this); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php index 1219e4e6c79..d50d14d988f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php @@ -23,9 +23,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-736 - */ + /** @group DDC-736 */ public function testReorderEntityFetchJoinForHydration(): void { $cust = new ECommerceCustomer(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php index a79355a7301..f5be4fe74a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php @@ -19,9 +19,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-767 - */ + /** @group DDC-767 */ public function testCollectionChangesInsideTransaction(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php index dd85e0345ed..f51acb7ddae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php @@ -21,7 +21,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( DDC809Variant::class, - DDC809SpecificationValue::class + DDC809SpecificationValue::class, ); $conn = $this->_em->getConnection(); @@ -46,9 +46,7 @@ protected function setUp(): void $conn->insert('var_spec_value_test', ['variant_id' => 545209, 'specification_value_id' => 94607]); } - /** - * @group DDC-809 - */ + /** @group DDC-809 */ public function testIssue(): void { $result = $this->_em->createQueryBuilder() @@ -90,9 +88,7 @@ class DDC809Variant */ protected $specificationValues; - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getSpecificationValues(): Collection { return $this->specificationValues; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php index a6e3c7926f9..9a4d190776b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php @@ -16,9 +16,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-812 - */ + /** @group DDC-812 */ public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManagedEntity(): void { $article = new CmsArticle(); @@ -38,7 +36,7 @@ public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManag $article2 = $this->_em->find($article::class, $article->id); $article2Again = $this->_em->createQuery( - 'select a, c from Doctrine\Tests\Models\CMS\CmsArticle a join a.comments c where a.id = ?1' + 'select a, c from Doctrine\Tests\Models\CMS\CmsArticle a join a.comments c where a.id = ?1', ) ->setParameter(1, $article->id) ->getSingleResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index a83e8e76941..26cc5d7f1ab 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -30,7 +30,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC832JoinedIndex::class, DDC832JoinedTreeIndex::class, - DDC832Like::class + DDC832Like::class, ); } @@ -49,9 +49,7 @@ public function tearDown(): void } } - /** - * @group DDC-832 - */ + /** @group DDC-832 */ public function testQuotedTableBasicUpdate(): void { $like = new DDC832Like('test'); @@ -65,9 +63,7 @@ public function testQuotedTableBasicUpdate(): void self::assertEquals($like, $this->_em->find(DDC832Like::class, $like->id)); } - /** - * @group DDC-832 - */ + /** @group DDC-832 */ public function testQuotedTableBasicRemove(): void { $like = new DDC832Like('test'); @@ -83,9 +79,7 @@ public function testQuotedTableBasicRemove(): void self::assertNull($this->_em->find(DDC832Like::class, $idToBeRemoved)); } - /** - * @group DDC-832 - */ + /** @group DDC-832 */ public function testQuotedTableJoinedUpdate(): void { $index = new DDC832JoinedIndex('test'); @@ -99,9 +93,7 @@ public function testQuotedTableJoinedUpdate(): void self::assertEquals($index, $this->_em->find(DDC832JoinedIndex::class, $index->id)); } - /** - * @group DDC-832 - */ + /** @group DDC-832 */ public function testQuotedTableJoinedRemove(): void { $index = new DDC832JoinedIndex('test'); @@ -117,9 +109,7 @@ public function testQuotedTableJoinedRemove(): void self::assertNull($this->_em->find(DDC832JoinedIndex::class, $idToBeRemoved)); } - /** - * @group DDC-832 - */ + /** @group DDC-832 */ public function testQuotedTableJoinedChildUpdate(): void { $index = new DDC832JoinedTreeIndex('test', 1, 2); @@ -133,9 +123,7 @@ public function testQuotedTableJoinedChildUpdate(): void self::assertEquals($index, $this->_em->find(DDC832JoinedTreeIndex::class, $index->id)); } - /** - * @group DDC-832 - */ + /** @group DDC-832 */ public function testQuotedTableJoinedChildRemove(): void { $index = new DDC832JoinedTreeIndex('test', 1, 2); @@ -174,10 +162,8 @@ class DDC832Like public $version; public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $word + /** @Column(type="string", length=255) */ + public string $word, ) { } } @@ -207,10 +193,8 @@ class DDC832JoinedIndex public $version; public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } } @@ -223,14 +207,10 @@ class DDC832JoinedTreeIndex extends DDC832JoinedIndex { public function __construct( string $name, - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ public int $lft, - /** - * @Column(type="integer") - */ - public int $rgt + /** @Column(type="integer") */ + public int $rgt, ) { $this->name = $name; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index 2f3ab0563be..d2674f9cf27 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -25,13 +25,11 @@ protected function setUp(): void DDC837Class1::class, DDC837Class2::class, DDC837Class3::class, - DDC837Aggregate::class + DDC837Aggregate::class, ); } - /** - * @group DDC-837 - */ + /** @group DDC-837 */ public function testIssue(): void { $c1 = new DDC837Class1(); @@ -117,9 +115,7 @@ abstract class DDC837Super public $id; } -/** - * @Entity - */ +/** @Entity */ class DDC837Class1 extends DDC837Super { /** @@ -141,9 +137,7 @@ class DDC837Class1 extends DDC837Super public $aggregate; } -/** - * @Entity - */ +/** @Entity */ class DDC837Class2 extends DDC837Super { /** @@ -191,9 +185,7 @@ class DDC837Class3 extends DDC837Super public $bananas; } -/** - * @Entity - */ +/** @Entity */ class DDC837Aggregate { /** @@ -205,10 +197,8 @@ class DDC837Aggregate public $id; public function __construct( - /** - * @Column(name="sysname", type="string", length=255) - */ - protected string $sysname + /** @Column(name="sysname", type="string", length=255) */ + protected string $sysname, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php index a84af634a33..ca6b153ec29 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php @@ -10,7 +10,7 @@ class DDC849Test extends OrmFunctionalTestCase { - private ?CmsUser $user; + private CmsUser|null $user; private CmsGroup $group1; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index ac142712f0f..0cb448c9058 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -27,7 +27,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC881User::class, DDC881PhoneNumber::class, - DDC881PhoneCall::class + DDC881PhoneCall::class, ); } @@ -102,9 +102,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class DDC881User { /** @@ -115,7 +113,7 @@ class DDC881User private int $id; /** @Column(type="string", length=255) */ - private ?string $name = null; + private string|null $name = null; /** * @psalm-var Collection @@ -134,25 +132,23 @@ public function setName(string $name): void } } -/** - * @Entity - */ +/** @Entity */ class DDC881PhoneNumber { /** * @Id * @Column(type="integer") */ - private ?int $id = null; + private int|null $id = null; /** * @Id * @ManyToOne(targetEntity="DDC881User",cascade={"all"}) */ - private ?DDC881User $user = null; + private DDC881User|null $user = null; /** @Column(type="string", length=255) */ - private ?string $phonenumber = null; + private string|null $phonenumber = null; /** * @psalm-var Collection @@ -180,18 +176,14 @@ public function setPhoneNumber(string $phoneNumber): void $this->phonenumber = $phoneNumber; } - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ public function getCalls(): Collection { return $this->calls; } } -/** - * @Entity - */ +/** @Entity */ class DDC881PhoneCall { /** @@ -208,7 +200,7 @@ class DDC881PhoneCall * @JoinColumn(name="user_id", referencedColumnName="user_id") * }) */ - private ?DDC881PhoneNumber $phonenumber = null; + private DDC881PhoneNumber|null $phonenumber = null; /** @Column(type="string",nullable=true) */ private string $callDate; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php index 2c198785914..915815a9dcb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php @@ -25,9 +25,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-933 - */ + /** @group DDC-933 */ public function testLockCTIClass(): void { if ($this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php index d7101851405..7cc47a802a2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php @@ -15,9 +15,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-949 - */ + /** @group DDC-949 */ public function testBooleanThroughRepository(): void { $true = new BooleanModel(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php index 0ae12000fef..5376da880c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -21,9 +21,7 @@ protected function setUp(): void $this->createSchemaForModels(DDC960Root::class, DDC960Child::class); } - /** - * @group DDC-960 - */ + /** @group DDC-960 */ public function testUpdateRootVersion(): void { $child = new DDC960Child('Test'); @@ -72,16 +70,12 @@ public function getVersion(): int } } -/** - * @Entity - */ +/** @Entity */ class DDC960Child extends DDC960Root { public function __construct( - /** - * @Column(type="string", length=255) - */ - private string $name + /** @Column(type="string", length=255) */ + private string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index 797538732eb..4221db3ae3a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -19,9 +19,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group DDC-992 - */ +/** @group DDC-992 */ class DDC992Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -30,7 +28,7 @@ protected function setUp(): void $this->createSchemaForModels( DDC992Role::class, DDC992Parent::class, - DDC992Child::class + DDC992Child::class, ); } @@ -118,9 +116,7 @@ class DDC992Parent public $childs; } -/** - * @Entity - */ +/** @Entity */ class DDC992Child extends DDC992Parent { public function childs(): Collection @@ -129,9 +125,7 @@ public function childs(): Collection } } -/** - * @Entity - */ +/** @Entity */ class DDC992Role { public function getRoleID(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php index 2e2d125a968..00e62ca0b97 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php @@ -14,9 +14,7 @@ use Stringable; use Symfony\Component\Cache\Adapter\ArrayAdapter; -/** - * @group GH-2947 - */ +/** @group GH-2947 */ class GH2947Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -91,7 +89,7 @@ public function __construct( * @Column(type="string", length=25) * @GeneratedValue(strategy="NONE") */ - public string $brand + public string $brand, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php index 053167a8505..9a335f4d79c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php @@ -28,13 +28,11 @@ protected function setUp(): void $this->createSchemaForModels( GH5562User::class, GH5562Manager::class, - GH5562Merchant::class + GH5562Merchant::class, ); } - /** - * @group GH-5562 - */ + /** @group GH-5562 */ public function testCacheShouldBeUpdatedWhenAssociationChanges(): void { $manager = new GH5562Manager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index 2751e2917a4..6349f4b555e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -20,9 +20,7 @@ use function array_unique; use function count; -/** - * @group GH-5762 - */ +/** @group GH-5762 */ class GH5762Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -32,7 +30,7 @@ protected function setUp(): void $this->createSchemaForModels( GH5762Driver::class, GH5762DriverRide::class, - GH5762Car::class + GH5762Car::class, ); } @@ -127,10 +125,8 @@ public function __construct( * @GeneratedValue(strategy="NONE") */ public int $id, - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { $this->driverRides = new ArrayCollection(); } @@ -154,7 +150,7 @@ public function __construct( * @ManyToOne(targetEntity="GH5762Car", inversedBy="carRides") * @JoinColumn(name="car", referencedColumnName="brand") */ - public GH5762Car $car + public GH5762Car $car, ) { $this->driver->driverRides->add($this); $this->car->carRides->add($this); @@ -180,10 +176,8 @@ public function __construct( * @GeneratedValue(strategy="NONE") */ public string $brand, - /** - * @Column(type="string", length=255) - */ - public string $model + /** @Column(type="string", length=255) */ + public string $model, ) { $this->carRides = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index 047c2429e14..cb09b8c1038 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -18,9 +18,7 @@ use function method_exists; -/** - * @group GH-5804 - */ +/** @group GH-5804 */ final class GH5804Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -51,7 +49,7 @@ public function testTextColumnSaveAndRetrieve2(): void final class GH5804Generator extends AbstractIdGenerator { - public function generateId(EntityManagerInterface $em, ?object $entity): string + public function generateId(EntityManagerInterface $em, object|null $entity): string { return 'test5804'; } @@ -81,7 +79,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st /** * {@inheritdoc} */ - public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string + public function convertToDatabaseValue($value, AbstractPlatform $platform): string|null { if (empty($value)) { return null; @@ -91,9 +89,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str } } -/** - * @Entity - */ +/** @Entity */ class GH5804Article { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index 21206eabac0..4fedeb36897 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -18,9 +18,7 @@ use function assert; -/** - * @group GH-5887 - */ +/** @group GH-5887 */ class GH5887Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -62,9 +60,7 @@ public function testLazyLoadsForeignEntitiesInOneToOneRelationWhileHavingCustomI } } -/** - * @Entity - */ +/** @Entity */ class GH5887Cart { /** @@ -72,7 +68,7 @@ class GH5887Cart * @Column(type="integer") * @GeneratedValue(strategy="NONE") */ - private ?int $id = null; + private int|null $id = null; /** * One Cart has One Customer. @@ -80,7 +76,7 @@ class GH5887Cart * @OneToOne(targetEntity="GH5887Customer", inversedBy="cart") * @JoinColumn(name="customer_id", referencedColumnName="id") */ - private ?GH5887Customer $customer = null; + private GH5887Customer|null $customer = null; public function getId(): int { @@ -106,9 +102,7 @@ public function setCustomer(GH5887Customer $customer): void } } -/** - * @Entity - */ +/** @Entity */ class GH5887Customer { /** @@ -116,14 +110,14 @@ class GH5887Customer * @Column(type="GH5887CustomIdObject", length=255) * @GeneratedValue(strategy="NONE") */ - private ?GH5887CustomIdObject $id = null; + private GH5887CustomIdObject|null $id = null; /** * One Customer has One Cart. * * @OneToOne(targetEntity="GH5887Cart", mappedBy="customer") */ - private ?GH5887Cart $cart = null; + private GH5887Cart|null $cart = null; public function getId(): GH5887CustomIdObject { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php index 7ad76e338e4..12f4273e708 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php @@ -32,7 +32,7 @@ protected function setUp(): void GH6029Group2::class, GH6029Product::class, GH6029Feature::class, - ] + ], ); } @@ -53,8 +53,8 @@ public function testManyToManyAssociation(): void 'Expected value of type "%s" for association field "%s#$groups", got "%s" instead.', GH6029Group::class, GH6029User::class, - GH6029Group2::class - ) + GH6029Group2::class, + ), ); $this->_em->persist($user); @@ -78,8 +78,8 @@ public function testOneToManyAssociation(): void 'Expected value of type "%s" for association field "%s#$features", got "%s" instead.', GH6029Feature::class, GH6029Product::class, - GH6029Group2::class - ) + GH6029Group2::class, + ), ); $this->_em->persist($product); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php index 0eff597d17a..96d8f95147b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->createSchemaForModels( GH6141Person::class, GH6141Boss::class, - GH6141Employee::class + GH6141Employee::class, ); } @@ -65,14 +65,14 @@ public function testEnumDiscriminatorsShouldBeConvertedToString(): void self::assertEquals($boss, $query->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT)); self::assertEquals( GH6141People::get(GH6141People::BOSS), - $query->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY)['discr'] + $query->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY)['discr'], ); $query->setParameter('name', 'Bob'); self::assertEquals($employee, $query->getOneOrNullResult(AbstractQuery::HYDRATE_OBJECT)); self::assertEquals( GH6141People::get(GH6141People::EMPLOYEE), - $query->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY)['discr'] + $query->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY)['discr'], ); } } @@ -112,9 +112,7 @@ class GH6141People implements Stringable public const BOSS = 'boss'; public const EMPLOYEE = 'employee'; - /** - * @throws InvalidArgumentException - */ + /** @throws InvalidArgumentException */ public static function get(string $value): GH6141People { if (! self::isValid($value)) { @@ -164,10 +162,8 @@ abstract class GH6141Person public $id; public function __construct( - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php index ce862a7235f..ac82a248977 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php @@ -14,9 +14,7 @@ use function uniqid; -/** - * @group #6217 - */ +/** @group #6217 */ final class GH6217Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -27,7 +25,7 @@ protected function setUp(): void $this->createSchemaForModels( GH6217AssociatedEntity::class, - GH6217FetchedEntity::class + GH6217FetchedEntity::class, ); } @@ -98,7 +96,7 @@ public function __construct( * @Cache("NONSTRICT_READ_WRITE") * @ManyToOne(targetEntity=GH6217AssociatedEntity::class, fetch="EAGER") */ - public GH6217AssociatedEntity $eager + public GH6217AssociatedEntity $eager, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index 57b625ca904..2bf6fd1897a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -32,7 +32,7 @@ protected function setUp(): void GH6362Start::class, GH6362Base::class, GH6362Child::class, - GH6362Join::class + GH6362Join::class, ); } @@ -88,9 +88,7 @@ public function testInheritanceJoinAlias(): void } } -/** - * @Entity - */ +/** @Entity */ class GH6362Start { /** @@ -128,9 +126,7 @@ abstract class GH6362Base private $starts; } -/** - * @Entity - */ +/** @Entity */ class GH6362Child extends GH6362Base { /** @@ -140,9 +136,7 @@ class GH6362Child extends GH6362Base private $joins; } -/** - * @Entity - */ +/** @Entity */ class GH6362Join { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php index c13a5fa92c4..4b1b428820d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php @@ -45,9 +45,7 @@ public function testFetchVersionValueForDifferentIdFieldAndColumn(): void } } -/** - * @Entity - */ +/** @Entity */ class A { /** @@ -62,14 +60,12 @@ public function __construct( * @Id * @Column(type="integer") */ - public int $id + public int $id, ) { } } -/** - * @Entity - */ +/** @Entity */ class B { /** @@ -86,10 +82,8 @@ public function __construct( * @JoinColumn(name="aid", referencedColumnName="id") */ public A $a, - /** - * @Column(type="string", length=255) - */ - public string $something + /** @Column(type="string", length=255) */ + public string $something, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php index 5a925bcde00..74db31ebce8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php @@ -10,9 +10,7 @@ use Doctrine\Tests\Models\Quote\User; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH-6402 - */ +/** @group GH-6402 */ class GH6402Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php index 838015bb3b9..2fd091721e3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php @@ -13,9 +13,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH-6464 - */ +/** @group GH-6464 */ class GH6464Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -25,7 +23,7 @@ protected function setUp(): void $this->createSchemaForModels( GH6464Post::class, GH6464User::class, - GH6464Author::class + GH6464Author::class, ); } @@ -46,7 +44,7 @@ public function testIssue(): void self::assertDoesNotMatchRegularExpression( '/INNER JOIN \w+ \w+ INNER JOIN/', $query->getSQL(), - 'As of GH-6464, every INNER JOIN should have an ON clause, which is missing here' + 'As of GH-6464, every INNER JOIN should have an ON clause, which is missing here', ); // Query shouldn't yield a result, yet it shouldn't crash (anymore) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php index eae1b85a193..865cc962da4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php @@ -30,13 +30,11 @@ protected function setUp(): void GH6531Order::class, GH6531OrderItem::class, GH6531Product::class, - ] + ], ); } - /** - * @group GH-6531 - */ + /** @group GH-6531 */ public function testSimpleDerivedIdentity(): void { $user = new GH6531User(); @@ -51,9 +49,7 @@ public function testSimpleDerivedIdentity(): void self::assertSame($address, $this->_em->find(GH6531Address::class, $user)); } - /** - * @group GH-6531 - */ + /** @group GH-6531 */ public function testDynamicAttributes(): void { $article = new GH6531Article(); @@ -64,13 +60,11 @@ public function testDynamicAttributes(): void self::assertSame( $article->attributes['name'], - $this->_em->find(GH6531ArticleAttribute::class, ['article' => $article, 'attribute' => 'name']) + $this->_em->find(GH6531ArticleAttribute::class, ['article' => $article, 'attribute' => 'name']), ); } - /** - * @group GH-6531 - */ + /** @group GH-6531 */ public function testJoinTableWithMetadata(): void { $product = new GH6531Product(); @@ -85,14 +79,12 @@ public function testJoinTableWithMetadata(): void self::assertSame( $order->items->first(), - $this->_em->find(GH6531OrderItem::class, ['product' => $product, 'order' => $order]) + $this->_em->find(GH6531OrderItem::class, ['product' => $product, 'order' => $order]), ); } } -/** - * @Entity - */ +/** @Entity */ class GH6531User { /** @@ -104,9 +96,7 @@ class GH6531User public $id; } -/** - * @Entity - */ +/** @Entity */ class GH6531Address { /** @@ -117,9 +107,7 @@ class GH6531Address public $user; } -/** - * @Entity - */ +/** @Entity */ class GH6531Article { /** @@ -142,9 +130,7 @@ public function addAttribute(string $name, string $value): void } } -/** - * @Entity - */ +/** @Entity */ class GH6531ArticleAttribute { public function __construct( @@ -153,22 +139,18 @@ public function __construct( * @Column(type="string", length=255) */ public string $attribute, - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ public string $value, /** * @Id * @ManyToOne(targetEntity=GH6531Article::class, inversedBy="attributes") */ - public GH6531Article $article + public GH6531Article $article, ) { } } -/** - * @Entity - */ +/** @Entity */ class GH6531Order { /** @@ -196,9 +178,7 @@ public function addItem(GH6531Product $product, int $amount): void } } -/** - * @Entity - */ +/** @Entity */ class GH6531Product { /** @@ -210,9 +190,7 @@ class GH6531Product public $id; } -/** - * @Entity - */ +/** @Entity */ class GH6531OrderItem { public function __construct( @@ -226,10 +204,8 @@ public function __construct( * @ManyToOne(targetEntity=GH6531Product::class) */ public GH6531Product $product, - /** - * @Column(type="integer") - */ - public int $amount = 1 + /** @Column(type="integer") */ + public int $amount = 1, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php index eb928fcb333..11a14a0be24 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php @@ -9,9 +9,7 @@ final class GH6682Test extends OrmFunctionalTestCase { - /** - * @group GH-6682 - */ + /** @group GH-6682 */ public function testIssue(): void { $parsedDefinition = [ @@ -25,7 +23,7 @@ public function testIssue(): void self::assertSame( ['sequenceName' => 'test_sequence', 'allocationSize' => '1', 'initialValue' => '1'], - $classMetadataInfo->sequenceGeneratorDefinition + $classMetadataInfo->sequenceGeneratorDefinition, ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php index 8405bf6e502..70088a4b719 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php @@ -7,9 +7,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH-6699 - */ +/** @group GH-6699 */ final class GH6699Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php index 7079ccccfc2..dd032941733 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php @@ -44,9 +44,7 @@ protected function setUp(): void $this->secondCategoryId = $secondCategory->getId(); } - /** - * @group GH-6740 - */ + /** @group GH-6740 */ public function testCollectionFilteringLteOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); @@ -55,9 +53,7 @@ public function testCollectionFilteringLteOperator(): void self::assertCount(2, $product->getCategories()->matching($criteria)); } - /** - * @group GH-6740 - */ + /** @group GH-6740 */ public function testCollectionFilteringLtOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); @@ -66,9 +62,7 @@ public function testCollectionFilteringLtOperator(): void self::assertCount(1, $product->getCategories()->matching($criteria)); } - /** - * @group GH-6740 - */ + /** @group GH-6740 */ public function testCollectionFilteringGteOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); @@ -77,9 +71,7 @@ public function testCollectionFilteringGteOperator(): void self::assertCount(2, $product->getCategories()->matching($criteria)); } - /** - * @group GH-6740 - */ + /** @group GH-6740 */ public function testCollectionFilteringGtOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); @@ -88,9 +80,7 @@ public function testCollectionFilteringGtOperator(): void self::assertCount(1, $product->getCategories()->matching($criteria)); } - /** - * @group GH-6740 - */ + /** @group GH-6740 */ public function testCollectionFilteringEqualsOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php index 1c08a4263c6..aa557150892 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php @@ -27,7 +27,7 @@ public function testCharsetCollationWhenCreatingForeignRelations(): void $this->createSchemaForModels( GH6823User::class, GH6823Group::class, - GH6823Status::class + GH6823Status::class, ); $schemaManager = $this->createSchemaManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php index efd8ed55f00..0eb32c23360 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH-6937 - */ +/** @group GH-6937 */ final class GH6937Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -114,9 +112,7 @@ abstract class GH6937Person public $name; } -/** - * @Entity - */ +/** @Entity */ abstract class GH6937Employee extends GH6937Person { /** @@ -126,9 +122,7 @@ abstract class GH6937Employee extends GH6937Person public $phoneNumber; } -/** - * @Entity - */ +/** @Entity */ class GH6937Manager extends GH6937Employee { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php index c7e06d3676e..4465a70c13e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php @@ -24,9 +24,7 @@ protected function setUp(): void $this->setUpEntitySchema([GH7012UserData::class]); } - /** - * @group GH-7012 - */ + /** @group GH-7012 */ public function testUpdateEntityWithIdentifierAssociationWithQuotedJoinColumn(): void { $user = new QuotedUser(); @@ -45,7 +43,7 @@ public function testUpdateEntityWithIdentifierAssociationWithQuotedJoinColumn(): self::assertSame( '4321', - $this->_em->getRepository(GH7012UserData::class)->findOneBy(['user' => $user])->name + $this->_em->getRepository(GH7012UserData::class)->findOneBy(['user' => $user])->name, ); } } @@ -64,10 +62,8 @@ public function __construct( * @JoinColumn(name="`user-id`", referencedColumnName="`user-id`", onDelete="CASCADE") */ public QuotedUser $user, - /** - * @Column(type="string", name="`name`") - */ - public string $name + /** @Column(type="string", name="`name`") */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php index 401251cd5b5..eb498d921da 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php @@ -33,13 +33,11 @@ protected function setUp(): void GH7062Season::class, GH7062Ranking::class, GH7062RankingPosition::class, - ] + ], ); } - /** - * @group GH-7062 - */ + /** @group GH-7062 */ public function testEntityWithAssociationKeyIdentityCanBeUpdated(): void { $this->createInitialRankingWithRelatedEntities(); @@ -107,9 +105,7 @@ class GH7062Ranking */ public $positions; - /** - * @param GH7062Team[] $teams - */ + /** @param GH7062Team[] $teams */ public function __construct( /** * @Id @@ -117,7 +113,7 @@ public function __construct( * @JoinColumn(name="season", referencedColumnName="id") */ public GH7062Season $season, - array $teams + array $teams, ) { $this->positions = new ArrayCollection(); @@ -146,7 +142,7 @@ public function __construct( * @Id * @Column(type="string", length=255) */ - public string $id + public string $id, ) { } } @@ -164,7 +160,7 @@ public function __construct( * @Id * @Column(type="string", length=255) */ - public string $id + public string $id, ) { } } @@ -195,7 +191,7 @@ public function __construct( * @ManyToOne(targetEntity=GH7062Team::class) * @JoinColumn(name="team_id", referencedColumnName="id") */ - public GH7062Team $team + public GH7062Team $team, ) { $this->points = 0; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php index 25c7957ba1a..e83329efecb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php @@ -25,9 +25,7 @@ protected function setUp(): void $this->setUpEntitySchema([GH7067Entity::class]); } - /** - * @group GH-7067 - */ + /** @group GH-7067 */ public function testSLCWithVersion(): void { $entity = new GH7067Entity(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php index da83bfd15d1..fc3274d8bac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php @@ -21,7 +21,7 @@ protected function setUp(): void $this->setUpEntitySchema( [ SomeEntity::class, - ] + ], ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php index 7f82d59bb7e..447024d50b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php @@ -17,9 +17,7 @@ use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH7079 - */ +/** @group GH7079 */ final class GH7079Test extends OrmFunctionalTestCase { private DefaultQuoteStrategy $strategy; @@ -61,12 +59,12 @@ public function testJoinTableName(): void 'targetEntity' => 'DDC7079CmsUser', 'inversedBy' => 'users', 'joinTable' => $table, - ] + ], ); self::assertEquals( $this->getTableFullName($table), - $this->strategy->getJoinTableName($cm->associationMappings['user'], $cm, $this->platform) + $this->strategy->getJoinTableName($cm->associationMappings['user'], $cm, $this->platform), ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php index 2c244863179..2bbb9bd4f91 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php @@ -21,9 +21,7 @@ protected function setUp(): void $this->setUpEntitySchema([GH7259Space::class, GH7259File::class, GH7259FileVersion::class, GH7259Feed::class]); } - /** - * @group GH-7259 - */ + /** @group GH-7259 */ public function testPersistFileBeforeVersion(): void { $space = new GH7259Space(); @@ -48,9 +46,7 @@ public function testPersistFileBeforeVersion(): void self::assertNotNull($fileVersion->id); } - /** - * @group GH-7259 - */ + /** @group GH-7259 */ public function testPersistFileAfterVersion(): void { $space = new GH7259Space(); @@ -79,9 +75,7 @@ public function testPersistFileAfterVersion(): void } } -/** - * @Entity() - */ +/** @Entity() */ class GH7259File { /** @@ -100,9 +94,7 @@ class GH7259File public $space; } -/** - * @Entity() - */ +/** @Entity() */ class GH7259FileVersion { /** @@ -121,9 +113,7 @@ class GH7259FileVersion public $file; } -/** - * @Entity() - */ +/** @Entity() */ class GH7259Space { /** @@ -142,9 +132,7 @@ class GH7259Space public $ruleFile; } -/** - * @Entity() - */ +/** @Entity() */ class GH7259Feed { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php index fd4a30220f5..e5aaf05b198 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php @@ -24,7 +24,7 @@ protected function setUp(): void $this->setUpEntitySchema( [ GH7286Entity::class, - ] + ], ); $this->_em->persist(new GH7286Entity('foo', 1)); @@ -42,7 +42,7 @@ public function testAggregateExpressionInFunction(): void . ' FROM ' . GH7286Entity::class . ' e' . ' WHERE e.type IS NOT NULL' . ' GROUP BY e.type' - . ' ORDER BY e.type' + . ' ORDER BY e.type', ); self::assertSame( @@ -50,13 +50,11 @@ public function testAggregateExpressionInFunction(): void ['pair' => 'bar3'], ['pair' => 'foo1'], ], - $query->getArrayResult() + $query->getArrayResult(), ); } - /** - * @group DDC-1091 - */ + /** @group DDC-1091 */ public function testAggregateFunctionInCustomFunction(): void { $this->_em->getConfiguration()->addCustomStringFunction('CC', GH7286CustomConcat::class); @@ -65,20 +63,18 @@ public function testAggregateFunctionInCustomFunction(): void 'SELECT CC(e.type, MIN(e.version)) pair' . ' FROM ' . GH7286Entity::class . ' e' . ' WHERE e.type IS NOT NULL AND e.type != :type' - . ' GROUP BY e.type' + . ' GROUP BY e.type', ); $query->setParameter('type', 'bar'); self::assertSame( ['pair' => 'foo1'], - $query->getSingleResult() + $query->getSingleResult(), ); } } -/** - * @Entity - */ +/** @Entity */ class GH7286Entity { /** @@ -90,23 +86,19 @@ class GH7286Entity public $id; public function __construct( - /** - * @Column(nullable=true) - */ - public ?string $type, - /** - * @Column(type="integer") - */ - public int $version + /** @Column(nullable=true) */ + public string|null $type, + /** @Column(type="integer") */ + public int $version, ) { } } class GH7286CustomConcat extends FunctionNode { - private ?Node $first = null; + private Node|null $first = null; - private ?Node $second = null; + private Node|null $second = null; public function parse(Parser $parser): void { @@ -124,7 +116,7 @@ public function getSql(SqlWalker $walker): string { return $walker->getConnection()->getDatabasePlatform()->getConcatExpression( $this->first->dispatch($walker), - $this->second->dispatch($walker) + $this->second->dispatch($walker), ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php index 5cf788d1229..f5b1394974c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php @@ -22,7 +22,7 @@ protected function setUp(): void $this->setUpEntitySchema( [ GH7366Entity::class, - ] + ], ); $this->_em->persist(new GH7366Entity('baz')); @@ -42,9 +42,7 @@ public function testOptimisticLockNoExceptionOnFind(): void } } -/** - * @Entity - */ +/** @Entity */ class GH7366Entity { /** @@ -63,10 +61,8 @@ class GH7366Entity protected $lockVersion = 1; public function __construct( - /** - * @Column(length=32) - */ - protected string $name + /** @Column(length=32) */ + protected string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php index 05b86ed7bd2..afd2aa7c3b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php @@ -24,7 +24,7 @@ protected function setUp(): void GH7496EntityA::class, GH7496EntityB::class, GH7496EntityAinB::class, - ] + ], ); $this->_em->persist($a1 = new GH7496EntityA(1, 'A#1')); @@ -40,11 +40,11 @@ protected function setUp(): void public function testNonUniqueObjectHydrationDuringIteration(): void { $q = $this->_em->createQuery( - 'SELECT b FROM ' . GH7496EntityAinB::class . ' aib JOIN ' . GH7496EntityB::class . ' b WITH aib.eB = b' + 'SELECT b FROM ' . GH7496EntityAinB::class . ' aib JOIN ' . GH7496EntityB::class . ' b WITH aib.eB = b', ); $bs = IterableTester::iterableToArray( - $q->toIterable([], AbstractQuery::HYDRATE_OBJECT) + $q->toIterable([], AbstractQuery::HYDRATE_OBJECT), ); self::assertCount(2, $bs); @@ -54,7 +54,7 @@ public function testNonUniqueObjectHydrationDuringIteration(): void self::assertEquals(1, $bs[1]->id); $bs = IterableTester::iterableToArray( - $q->toIterable([], AbstractQuery::HYDRATE_ARRAY) + $q->toIterable([], AbstractQuery::HYDRATE_ARRAY), ); self::assertCount(2, $bs); @@ -63,9 +63,7 @@ public function testNonUniqueObjectHydrationDuringIteration(): void } } -/** - * @Entity - */ +/** @Entity */ class GH7496EntityA { public function __construct( @@ -74,17 +72,13 @@ public function __construct( * @Column(type="integer", name="a_id") */ public int $id, - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } } -/** - * @Entity - */ +/** @Entity */ class GH7496EntityB { public function __construct( @@ -93,17 +87,13 @@ public function __construct( * @Column(type="integer", name="b_id") */ public int $id, - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } } -/** - * @Entity - */ +/** @Entity */ class GH7496EntityAinB { /** @@ -125,7 +115,7 @@ public function __construct( * @ManyToOne(targetEntity=GH7496EntityB::class) * @JoinColumn(name="b_id", referencedColumnName="b_id", nullable=false) */ - public $eB + public $eB, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php index c0d5dd4cab6..3cda57fbad7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php @@ -16,9 +16,7 @@ use function assert; -/** - * @group GH7505 - */ +/** @group GH7505 */ final class GH7505Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -76,9 +74,7 @@ abstract class GH7505AbstractResponse public $id; } -/** - * @Entity() - */ +/** @Entity() */ class GH7505ArrayResponse extends GH7505AbstractResponse { /** @@ -88,9 +84,7 @@ class GH7505ArrayResponse extends GH7505AbstractResponse public $value = []; } -/** - * @Entity() - */ +/** @Entity() */ class GH7505TextResponse extends GH7505AbstractResponse { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php index 204dcb7bf3f..253138ed6db 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php @@ -69,16 +69,12 @@ class GH7512EntityA public $entityCs; } -/** - * @Entity() - */ +/** @Entity() */ class GH7512EntityB extends GH7512EntityA { } -/** - * @Entity() - */ +/** @Entity() */ class GH7512EntityC { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php index 6dcb67dd50e..afe4057cc7d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php @@ -36,9 +36,7 @@ public function testClearScheduledForSynchronizationWhenCommitEmpty(): void self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDirtyCheck($entity)); } - /** - * @group GH-8231 - */ + /** @group GH-8231 */ public function testPersistAfterRemoveSchedulesForSynchronization(): void { $entity = $this->_em->find(GH7629Entity::class, 1); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php index 449021505e9..5f41e0bdfb8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php @@ -14,9 +14,7 @@ use function array_keys; -/** - * @group GH-7661 - */ +/** @group GH-7661 */ class GH7661Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -53,9 +51,7 @@ public function testIndexByAssociation(): void } } -/** - * @Entity - */ +/** @Entity */ class GH7661User { /** @@ -67,9 +63,7 @@ class GH7661User public $id; } -/** - * @Entity - */ +/** @Entity */ class GH7661Event { /** @@ -86,9 +80,7 @@ class GH7661Event public $participants; } -/** - * @Entity - */ +/** @Entity */ class GH7661Participant { /** @@ -100,14 +92,10 @@ class GH7661Participant public $id; public function __construct( - /** - * @ManyToOne(targetEntity=GH7661User::class) - */ + /** @ManyToOne(targetEntity=GH7661User::class) */ public GH7661User $user, - /** - * @ManyToOne(targetEntity=GH7661Event::class) - */ - public GH7661Event $event + /** @ManyToOne(targetEntity=GH7661Event::class) */ + public GH7661Event $event, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php index fdb76377b3c..37fafa4f729 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php @@ -25,7 +25,7 @@ protected function setUp(): void $this->createSchemaForModels( GH7735Car::class, GH7735Power::class, - GH7735Engine::class + GH7735Engine::class, ); $this->_em->persist(new GH7735Car(1, new GH7735Engine(1, 'turbo', new GH7735Power(1)))); @@ -66,7 +66,7 @@ public function __construct( * @JoinColumn(nullable=false) * @Cache("READ_ONLY") */ - private GH7735Engine $engine + private GH7735Engine $engine, ) { } @@ -93,15 +93,13 @@ public function __construct( * @Column(type="integer") */ private int $id, - /** - * @Column - */ + /** @Column */ private string $model, /** * @OneToOne(targetEntity=GH7735Power::class, mappedBy="engine", cascade={"all"}) * @Cache("READ_ONLY") */ - private GH7735Power $power + private GH7735Power $power, ) { $power->setEngine($this); } @@ -132,14 +130,14 @@ class GH7735Power * @OneToOne(targetEntity=GH7735Engine::class, inversedBy="power") * @Cache("READ_ONLY") */ - private ?GH7735Engine $engine = null; + private GH7735Engine|null $engine = null; public function __construct( /** * @Id * @Column(type="integer") */ - private int $id + private int $id, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php index 4f7dfb8276f..be7a97031ec 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php @@ -15,9 +15,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH7737 - */ +/** @group GH7737 */ class GH7737Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -37,9 +35,7 @@ protected function setUp(): void $this->_em->clear(); } - /** - * @test - */ + /** @test */ public function memberOfCriteriaShouldBeCompatibleWithQueryBuilder(): void { $query = $this->_em->createQueryBuilder() @@ -61,9 +57,7 @@ public function memberOfCriteriaShouldBeCompatibleWithQueryBuilder(): void } } -/** - * @Entity - */ +/** @Entity */ class GH7737Group { public function __construct( @@ -72,17 +66,13 @@ public function __construct( * @Column(type="integer") */ public int $id, - /** - * @Column - */ - public string $name + /** @Column */ + public string $name, ) { } } -/** - * @Entity - */ +/** @Entity */ class GH7737Person { /** @@ -97,7 +87,7 @@ public function __construct( * @Id * @Column(type="integer") */ - public int $id + public int $id, ) { $this->groups = new ArrayCollection(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php index e6a603c041c..93fe7d714f7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php @@ -53,9 +53,7 @@ public function testCollectionClearDoesNotClearIfNotPersisted(): void self::assertCount(1, $entity->children); } - /** - * @group GH-7862 - */ + /** @group GH-7862 */ public function testCollectionClearDoesClearIfPersisted(): void { $entity = $this->_em->find(GH7761Entity::class, 1); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php index 91be2c75204..4b304d5bbf2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php @@ -17,9 +17,7 @@ use function assert; -/** - * @group GH7767 - */ +/** @group GH7767 */ class GH7767Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -63,9 +61,7 @@ public function testMatchingOverrulesCollectionOrdering(): void } } -/** - * @Entity - */ +/** @Entity */ class GH7767ParentEntity { /** @@ -87,18 +83,14 @@ public function addChild(int $position): void $this->children[] = new GH7767ChildEntity($this, $position); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getChildren(): Collection { return $this->children; } } -/** - * @Entity - */ +/** @Entity */ class GH7767ChildEntity { /** @@ -109,14 +101,10 @@ class GH7767ChildEntity private int $id; public function __construct( - /** - * @ManyToOne(targetEntity=GH7767ParentEntity::class, inversedBy="children") - */ + /** @ManyToOne(targetEntity=GH7767ParentEntity::class, inversedBy="children") */ private GH7767ParentEntity $parent, - /** - * @Column(type="integer") - */ - public int $position + /** @Column(type="integer") */ + public int $position, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php index 94b5d1505ee..25a6167b845 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php @@ -76,7 +76,7 @@ public function testWillFindSongsInPaginator(): void self::assertSame( self::SONG, - array_map(static fn (GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))) + array_map(static fn (GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), ); } @@ -94,7 +94,7 @@ public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void self::assertSame( self::SONG, array_map(static fn (GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), - 'Expected to return expected data before query cache is populated with DQL -> SQL translation. Were SQL parameters translated?' + 'Expected to return expected data before query cache is populated with DQL -> SQL translation. Were SQL parameters translated?', ); $query = $this->_em->getRepository(GH7820Line::class) @@ -104,7 +104,7 @@ public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void self::assertSame( self::SONG, array_map(static fn (GH7820Line $line): string => $line->toString(), iterator_to_array(new Paginator($query))), - 'Expected to return expected data even when DQL -> SQL translation is present in cache. Were SQL parameters translated again?' + 'Expected to return expected data even when DQL -> SQL translation is present in cache. Were SQL parameters translated again?', ); } } @@ -118,10 +118,8 @@ public function __construct( * @Column(type="Doctrine\Tests\ORM\Functional\Ticket\GH7820LineTextType", length=255) */ private GH7820LineText $text, - /** - * @Column(type="integer") - */ - private int $lineNumber + /** @Column(type="integer") */ + private int $lineNumber, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php index f9d9eaae121..22cdb1866e4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php @@ -8,9 +8,7 @@ use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH7829 - */ +/** @group GH7829 */ final class GH7829Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php index b96edce7e8b..54090499e2a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php @@ -17,9 +17,7 @@ use function assert; -/** - * @group GH7836 - */ +/** @group GH7836 */ class GH7836Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -84,9 +82,7 @@ public function testMatchingKeepsOrderOfCriteriaOrderingKeys(): void } } -/** - * @Entity - */ +/** @Entity */ class GH7836ParentEntity { /** @@ -108,18 +104,14 @@ public function addChild(int $position, string $name): void $this->children[] = new GH7836ChildEntity($this, $position, $name); } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getChildren(): Collection { return $this->children; } } -/** - * @Entity - */ +/** @Entity */ class GH7836ChildEntity { /** @@ -130,18 +122,12 @@ class GH7836ChildEntity private int $id; public function __construct( - /** - * @ManyToOne(targetEntity=GH7836ParentEntity::class, inversedBy="children") - */ + /** @ManyToOne(targetEntity=GH7836ParentEntity::class, inversedBy="children") */ private GH7836ParentEntity $parent, - /** - * @Column(type="integer") - */ + /** @Column(type="integer") */ public int $position, - /** - * @Column(type="string", length=255) - */ - public string $name + /** @Column(type="string", length=255) */ + public string $name, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php index 81c077a65db..6c99afeee15 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php @@ -16,9 +16,7 @@ use function array_values; -/** - * @group gh7864 - */ +/** @group gh7864 */ class GH7864Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -29,7 +27,7 @@ protected function setUp(): void [ GH7864User::class, GH7864Tweet::class, - ] + ], ); } @@ -63,9 +61,7 @@ public function testExtraLazyRemoveElement(): void } } -/** - * @Entity - */ +/** @Entity */ class GH7864User { /** @@ -100,9 +96,7 @@ public function addTweet(GH7864Tweet $tweet): void } } -/** - * @Entity - */ +/** @Entity */ class GH7864Tweet { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php index faf3332b504..213670b6e56 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php @@ -18,9 +18,7 @@ use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\OrmTestCase; -/** - * @group GH7869 - */ +/** @group GH7869 */ class GH7869Test extends OrmTestCase { public function testDQLDeferredEagerLoad(): void @@ -61,9 +59,7 @@ public function getClassMetadata($className): ClassMetadata } } -/** - * @Entity - */ +/** @Entity */ class GH7869Appointment { /** @@ -81,9 +77,7 @@ class GH7869Appointment public $patient; } -/** - * @Entity - */ +/** @Entity */ class GH7869Patient { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php index 571ef57d01d..24a1699a523 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php @@ -49,7 +49,7 @@ public function typesShouldBeConvertedForDQLFunctions(): void COUNT(product.id) as count, SUM(product.price) as sales, AVG(product.price) as average - FROM ' . GH7941Product::class . ' product' + FROM ' . GH7941Product::class . ' product', ); $result = $query->getSingleResult(); @@ -69,7 +69,7 @@ public function typesShouldBeConvertedForDQLFunctions(): void ABS(product.price) as absolute, SQRT(ABS(product.price)) as square_root, LENGTH(product.name) as length - FROM ' . GH7941Product::class . ' product' + FROM ' . GH7941Product::class . ' product', ); foreach ($query->getResult() as $i => $item) { @@ -107,14 +107,10 @@ class GH7941Product public $createdAt; public function __construct( - /** - * @Column(type="string", length=255) - */ + /** @Column(type="string", length=255) */ public string $name, - /** - * @Column(type="decimal") - */ - public string $price + /** @Column(type="decimal") */ + public string $price, ) { $this->createdAt = new DateTimeImmutable(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php index 357838cf3d2..9e22d4f9283 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH8055 - */ +/** @group GH8055 */ final class GH8055Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -65,9 +63,7 @@ class GH8055BaseClass public $id; } -/** - * @Entity() - */ +/** @Entity() */ class GH8055SubClass extends GH8055BaseClass { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php index e024276e75a..914c0113a4e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php @@ -15,9 +15,7 @@ use function method_exists; use function sprintf; -/** - * @group GH8061 - */ +/** @group GH8061 */ final class GH8061Test extends OrmTestCase { public static function setUpBeforeClass(): void @@ -35,9 +33,7 @@ public function testConvertToPHPValueSQLForNewObjectExpression(): void } } -/** - * @Entity - */ +/** @Entity */ final class GH8061Entity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php index f077da78dee..d598c4959d1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php @@ -24,13 +24,11 @@ protected function setUp(): void [ GH8217Collection::class, GH8217CollectionItem::class, - ] + ], ); } - /** - * @group GH-8217 - */ + /** @group GH-8217 */ public function testNoQueriesAfterSecondFlush(): void { $collection = new GH8217Collection(); @@ -45,9 +43,7 @@ public function testNoQueriesAfterSecondFlush(): void } } -/** - * @Entity - */ +/** @Entity */ class GH8217Collection { /** @@ -76,9 +72,7 @@ public function addItem(GH8217CollectionItem $item): void } } -/** - * @Entity - */ +/** @Entity */ class GH8217CollectionItem { public function __construct( @@ -92,7 +86,7 @@ public function __construct( * @Id * @Column(type="integer", options={"unsigned": true}) */ - public int $collectionIndex + public int $collectionIndex, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php index 0f92a4bca21..d33bdc754f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php @@ -30,9 +30,7 @@ protected function setUp(): void $this->createSchemaForModels(GH8443Foo::class); } - /** - * @group GH-8443 - */ + /** @group GH-8443 */ public function testJoinRootEntityWithForcePartialLoad(): void { $person = new CompanyPerson(); @@ -54,16 +52,14 @@ public function testJoinRootEntityWithForcePartialLoad(): void $manager = $this->_em->createQuery( "SELECT m from Doctrine\Tests\Models\Company\CompanyManager m JOIN m.spouse s - WITH s.name = 'John'" + WITH s.name = 'John'", )->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true)->getSingleResult(); $this->_em->refresh($manager); $this->assertEquals('John', $manager->getSpouse()->getName()); } - /** - * @group GH-8443 - */ + /** @group GH-8443 */ public function testJoinRootEntityWithOnlyOneEntityInHierarchy(): void { $bar = new GH8443Foo('bar'); @@ -77,7 +73,7 @@ public function testJoinRootEntityWithOnlyOneEntityInHierarchy(): void $this->_em->clear(); $foo = $this->_em->createQuery( - 'SELECT f from ' . GH8443Foo::class . " f JOIN f.bar b WITH b.name = 'bar'" + 'SELECT f from ' . GH8443Foo::class . " f JOIN f.bar b WITH b.name = 'bar'", )->getSingleResult(); assert($foo instanceof GH8443Foo); @@ -102,7 +98,7 @@ class GH8443Foo * @Column(type="integer") * @GeneratedValue */ - private ?int $id = null; + private int|null $id = null; /** * @var GH8443Foo|null @@ -112,14 +108,12 @@ class GH8443Foo private $bar; public function __construct( - /** - * @Column - */ - private string $name + /** @Column */ + private string $name, ) { } - public function getName(): ?string + public function getName(): string|null { return $this->name; } @@ -132,7 +126,7 @@ public function setBar(GH8443Foo $bar): void } } - public function getBar(): ?GH8443Foo + public function getBar(): GH8443Foo|null { return $this->bar; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php index c6a7874ff95..5ddb2fe0de9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php @@ -36,9 +36,7 @@ protected function createSchema(): void $this->createSchemaForModels(GH8499VersionableEntity::class); } - /** - * @group GH-8499 - */ + /** @group GH-8499 */ public function testOptimisticTimestampSetsDefaultValue(): GH8499VersionableEntity { $this->createSchema(); @@ -68,12 +66,12 @@ public function testOptimisticLockWithDateTimeForVersion(GH8499VersionableEntity $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); $modifiedDate = new DateTime(date( $format, - strtotime($test->getRevision()->format($format)) - 3600 + strtotime($test->getRevision()->format($format)) - 3600, )); $this->conn->executeQuery( 'UPDATE GH8499VersionableEntity SET revision = ? WHERE id = ?', - [$modifiedDate->format($format), $test->id] + [$modifiedDate->format($format), $test->id], ); $this->_em->refresh($test); @@ -86,18 +84,16 @@ public function testOptimisticLockWithDateTimeForVersion(GH8499VersionableEntity self::assertEquals( 'Test Entity Locked', $test->getName(), - 'Entity not modified after persist/flush,' + 'Entity not modified after persist/flush,', ); self::assertGreaterThan( $modifiedDate->getTimestamp(), $test->getRevision()->getTimestamp(), - 'Current version timestamp is not greater than previous one.' + 'Current version timestamp is not greater than previous one.', ); } - /** - * @group GH-8499 - */ + /** @group GH-8499 */ public function testOptimisticLockWithDateTimeForVersionThrowsException(): void { $this->createSchema(); @@ -170,7 +166,7 @@ public function setDescription(string $description): void $this->description = $description; } - public function getRevision(): ?DateTimeInterface + public function getRevision(): DateTimeInterface|null { return $this->revision; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php index 5395611929b..8b111677d04 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php @@ -29,9 +29,7 @@ public function testDeletedEntity(): void } } -/** - * @Entity - */ +/** @Entity */ class GH8663VersionedEntity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php index c57b493dbb9..f2745305968 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php @@ -27,9 +27,7 @@ public function testDiscriminatorMapWithSeveralLevelsIsSupported(): void } } -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ abstract class GH8914BaseEntity { } @@ -51,9 +49,7 @@ class GH8914Person extends GH8914BaseEntity public $id; } -/** - * @Entity - */ +/** @Entity */ class GH8914Employee extends GH8914Person { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php index 0982baeff1c..288ef33e5dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php @@ -23,9 +23,7 @@ protected function setUp(): void $this->createSchemaForModels(GH9027Cart::class, GH9027Customer::class); } - /** - * @group GH-9027 - */ + /** @group GH-9027 */ public function testUnitOfWorkHandlesNullRelations(): void { $uow = new UnitOfWork($this->_em); @@ -34,7 +32,7 @@ public function testUnitOfWorkHandlesNullRelations(): void $cart = $uow->createEntity( GH9027Cart::class, ['id' => 1, 'customer' => 24252], - $hints + $hints, ); $this->assertEquals(null, $cart->customer); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php index 6d9ab61faa6..ff665fb8359 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php @@ -14,9 +14,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH-9109 - */ +/** @group GH-9109 */ class GH9109Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -88,9 +86,7 @@ public function testIssue(): void } } -/** - * @Entity - */ +/** @Entity */ class GH9109Product { /** @@ -101,7 +97,7 @@ class GH9109Product private int $id; /** @Column(name="`title`", type="string", length=255) */ - private ?string $title = null; + private string|null $title = null; /** * @var Collection|GH9109User[] @@ -130,9 +126,7 @@ public function getTitle(): string return $this->title; } - /** - * @psalm-return Collection - */ + /** @psalm-return Collection */ public function getBuyers(): Collection { return $this->buyers; @@ -144,9 +138,7 @@ public function addBuyer(GH9109User $buyer): void } } -/** - * @Entity - */ +/** @Entity */ class GH9109User { /** @@ -157,10 +149,10 @@ class GH9109User private int $id; /** @Column(name="`first_name`", type="string", length=255) */ - private ?string $firstName = null; + private string|null $firstName = null; /** @Column(name="last_name", type="string", length=255) */ - private ?string $lastName = null; + private string|null $lastName = null; public function getId(): int { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php index 8dfeb663289..1908e71d6a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php @@ -10,9 +10,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH-9230 - */ +/** @group GH-9230 */ class GH9230Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -128,9 +126,7 @@ public function testIssue(string $property, $falsyValue, $truthyValue): void } -/** - * @Entity - */ +/** @Entity */ class GH9230Entity { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php index eaf0263c18e..fa9b5b994e9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php @@ -16,9 +16,7 @@ use Doctrine\Tests\Mocks\CompatibilityType; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH9335 - */ +/** @group GH9335 */ final class GH9335Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -104,9 +102,7 @@ public function __toString(): string } } -/** - * @Entity - */ +/** @Entity */ class GH9335Book { /** @@ -129,14 +125,14 @@ class GH9335Book */ private $author; - public function __construct(GH9335IntObject $id, string $title, ?GH9335Author $author = null) + public function __construct(GH9335IntObject $id, string $title, GH9335Author|null $author = null) { $this->setId($id); $this->setTitle($title); $this->setAuthor($author); } - public function getId(): ?GH9335IntObject + public function getId(): GH9335IntObject|null { return $this->id; } @@ -146,7 +142,7 @@ public function setId($id): void $this->id = $id; } - public function getTitle(): ?string + public function getTitle(): string|null { return $this->title; } @@ -156,12 +152,12 @@ public function setTitle($title): void $this->title = $title; } - public function getAuthor(): ?GH9335Author + public function getAuthor(): GH9335Author|null { return $this->author; } - public function setAuthor(?GH9335Author $author): self + public function setAuthor(GH9335Author|null $author): self { $this->author = $author; @@ -174,9 +170,7 @@ public function setAuthor(?GH9335Author $author): self } } -/** - * @Entity - */ +/** @Entity */ class GH9335Author { /** @@ -193,12 +187,12 @@ class GH9335Author */ private $name; - public function __construct(?string $name) + public function __construct(string|null $name) { $this->setName($name); } - public function getBook(): ?GH9335Book + public function getBook(): GH9335Book|null { return $this->book; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php index 0159a3fd6e3..a087d5205f1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php @@ -16,9 +16,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group GH-9579 - */ +/** @group GH-9579 */ class GH9579Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -28,7 +26,7 @@ protected function setUp(): void $this->createSchemaForModels( GH9579Container::class, GH9579Item::class, - GH9579Part::class + GH9579Part::class, ); $container = new GH9579Container(); @@ -49,9 +47,7 @@ protected function setUp(): void $this->_em->clear(); } - /** - * @group GH-9579 - */ + /** @group GH-9579 */ public function testIssue(): void { $dql = <<<'DQL' diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php index 6298fce4fb5..106c7c7744e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php @@ -42,7 +42,7 @@ public function testHydrateJoinedCollectionWithFirstNullishRow(): void $uow->createEntity( GH9807Main::class, - ['id' => 1] + ['id' => 1], ); $resultSet = [ @@ -73,9 +73,7 @@ public function testHydrateJoinedCollectionWithFirstNullishRow(): void } } -/** - * @Entity - */ +/** @Entity */ class GH9807Main { /** @@ -93,18 +91,14 @@ class GH9807Main */ private $joins; - /** - * @return Collection - */ + /** @return Collection */ public function getJoins(): Collection { return $this->joins; } } -/** - * @Entity - */ +/** @Entity */ class GH9807Join { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php index 0c2b6b06d2a..400e12d30b1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php @@ -9,9 +9,7 @@ use Doctrine\Tests\Models\Issue5989\Issue5989Person; use Doctrine\Tests\OrmFunctionalTestCase; -/** - * @group issue-5989 - */ +/** @group issue-5989 */ class Issue5989Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php index 15c78330487..b3d9d7c64f0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php @@ -22,7 +22,7 @@ protected function setUp(): void $this->createSchemaForModels( PersonTicket4646Abstract::class, - EmployeeTicket4646Abstract::class + EmployeeTicket4646Abstract::class, ); } @@ -59,7 +59,7 @@ abstract class PersonTicket4646Abstract */ private int $id; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php index 2591f0299b5..da4e98e01ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php @@ -23,7 +23,7 @@ protected function setUp(): void $this->createSchemaForModels( PersonTicket4646MultiLevel::class, EmployeeTicket4646MultiLevel::class, - EngineerTicket4646MultiLevel::class + EngineerTicket4646MultiLevel::class, ); } @@ -64,7 +64,7 @@ class PersonTicket4646MultiLevel */ private int $id; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php index 4c2393071b2..56e17b3e42a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php @@ -21,7 +21,7 @@ protected function setUp(): void parent::setUp(); $this->createSchemaForModels( PersonTicket4646Parametric::class, - EmployeeTicket4646Parametric::class + EmployeeTicket4646Parametric::class, ); } @@ -35,7 +35,7 @@ public function testInstanceOf(): void $query = $this->_em->createQuery($dql); $query->setParameter( 'parameter', - $this->_em->getClassMetadata(PersonTicket4646Parametric::class) + $this->_em->getClassMetadata(PersonTicket4646Parametric::class), ); $result = $query->getResult(); self::assertCount(2, $result); @@ -62,7 +62,7 @@ class PersonTicket4646Parametric */ private int $id; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php index d83a3031d35..8850bb12646 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php @@ -22,7 +22,7 @@ protected function setUp(): void $this->createSchemaForModels( PersonTicket4646::class, - EmployeeTicket4646::class + EmployeeTicket4646::class, ); } @@ -61,7 +61,7 @@ class PersonTicket4646 */ private int $id; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php index 8e2312a8d81..1bae12a5b0f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php @@ -24,7 +24,7 @@ protected function setUp(): void PersonTicket4646Multiple::class, EmployeeTicket4646Multiple::class, ManagerTicket4646Multiple::class, - InternTicket4646Multiple::class + InternTicket4646Multiple::class, ); } diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index bbaeb970079..59f96542d9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -44,9 +44,7 @@ public function testDecimal(): void self::assertSame('0.1515', $decimal->highScale); } - /** - * @group DDC-1394 - */ + /** @group DDC-1394 */ public function testBoolean(): void { $bool = new BooleanModel(); diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php index b03602fa3ef..cff3466b7a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php @@ -50,9 +50,7 @@ public function testUpperCaseStringType(): void self::assertEquals('FOO', $this->_em->getConnection()->fetchOne('select lowerCaseString from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); } - /** - * @group DDC-1642 - */ + /** @group DDC-1642 */ public function testUpperCaseStringTypeWhenColumnNameIsDefined(): void { $entity = new CustomTypeUpperCase(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php index 208aaca61d0..de934a8c8ce 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php @@ -74,24 +74,22 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('tuv', $conn->fetchOne('SELECT owning_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedManyToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); $owning = $this->_em->find( OwningManyToManyCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); self::assertInstanceOf(AuxiliaryEntity::class, $auxiliary); @@ -99,24 +97,22 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningManyToManyCompositeIdForeignKeyEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedManyToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); $owning = $this->_em->find( OwningManyToManyCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); self::assertEquals('abc', $auxiliary->id4); @@ -125,45 +121,39 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id2); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase */ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedManyToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => $auxiliary] + ['id1' => 'def', 'foreignEntity' => $auxiliary], ); self::assertInstanceOf(InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningManyToManyCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); self::assertCount(1, $owning->associatedEntities); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( InversedManyToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); self::assertCount(1, $inversed->associatedEntities); @@ -181,7 +171,7 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): $inversed = $this->_em->find( InversedManyToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); foreach ($inversed->associatedEntities as $owning) { diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php index 81c6a5d4aff..7ddd4b13a1f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php @@ -65,38 +65,34 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('tuv', $conn->fetchOne('SELECT owning_id FROM vct_xref_manytomany_compositeid LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedManyToManyCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); $owning = $this->_em->find( OwningManyToManyCompositeIdEntity::class, - 'ghi' + 'ghi', ); self::assertInstanceOf(InversedManyToManyCompositeIdEntity::class, $inversed); self::assertInstanceOf(OwningManyToManyCompositeIdEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedManyToManyCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); $owning = $this->_em->find( OwningManyToManyCompositeIdEntity::class, - 'ghi' + 'ghi', ); self::assertEquals('abc', $inversed->id1); @@ -104,27 +100,23 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id3); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningManyToManyCompositeIdEntity::class, - 'ghi' + 'ghi', ); self::assertCount(1, $owning->associatedEntities); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( InversedManyToManyCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); self::assertCount(1, $inversed->associatedEntities); @@ -142,7 +134,7 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): $inversed = $this->_em->find( InversedManyToManyCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); foreach ($inversed->associatedEntities as $owning) { diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php index b6d9e798954..b1234927679 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php @@ -69,7 +69,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedIsCounted(): v { $owning = $this->_em->find( OwningManyToManyExtraLazyEntity::class, - 'ghi' + 'ghi', ); self::assertEquals(2, $owning->associatedEntities->count()); @@ -79,7 +79,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningIsCounted(): v { $inversed = $this->_em->find( InversedManyToManyExtraLazyEntity::class, - 'abc' + 'abc', ); self::assertEquals(2, $inversed->associatedEntities->count()); @@ -89,12 +89,12 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnEnti { $owning = $this->_em->find( OwningManyToManyExtraLazyEntity::class, - 'ghi' + 'ghi', ); $inversed = $this->_em->find( InversedManyToManyExtraLazyEntity::class, - 'abc' + 'abc', ); self::assertTrue($owning->associatedEntities->contains($inversed)); @@ -104,12 +104,12 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnEnti { $inversed = $this->_em->find( InversedManyToManyExtraLazyEntity::class, - 'abc' + 'abc', ); $owning = $this->_em->find( OwningManyToManyExtraLazyEntity::class, - 'ghi' + 'ghi', ); self::assertTrue($inversed->associatedEntities->contains($owning)); @@ -119,7 +119,7 @@ public function testThatTheExtraLazyCollectionFromOwningToInversedContainsAnInde { $owning = $this->_em->find( OwningManyToManyExtraLazyEntity::class, - 'ghi' + 'ghi', ); self::assertTrue($owning->associatedEntities->containsKey('abc')); @@ -129,7 +129,7 @@ public function testThatTheExtraLazyCollectionFromInversedToOwningContainsAnInde { $inversed = $this->_em->find( InversedManyToManyExtraLazyEntity::class, - 'abc' + 'abc', ); self::assertTrue($inversed->associatedEntities->containsKey('ghi')); @@ -139,7 +139,7 @@ public function testThatASliceOfTheExtraLazyCollectionFromOwningToInversedIsLoad { $owning = $this->_em->find( OwningManyToManyExtraLazyEntity::class, - 'ghi' + 'ghi', ); self::assertCount(1, $owning->associatedEntities->slice(0, 1)); @@ -149,7 +149,7 @@ public function testThatASliceOfTheExtraLazyCollectionFromInversedToOwningIsLoad { $inversed = $this->_em->find( InversedManyToManyExtraLazyEntity::class, - 'abc' + 'abc', ); self::assertCount(1, $inversed->associatedEntities->slice(1, 1)); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php index f4a0eeee661..20349eb988d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php @@ -62,65 +62,57 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('qrs', $conn->fetchOne('SELECT owning_id FROM vct_xref_manytomany LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedManyToManyEntity::class, - 'abc' + 'abc', ); $owning = $this->_em->find( OwningManyToManyEntity::class, - 'def' + 'def', ); self::assertInstanceOf(InversedManyToManyEntity::class, $inversed); self::assertInstanceOf(OwningManyToManyEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedManyToManyEntity::class, - 'abc' + 'abc', ); $owning = $this->_em->find( OwningManyToManyEntity::class, - 'def' + 'def', ); self::assertEquals('abc', $inversed->id1); self::assertEquals('def', $owning->id2); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningManyToManyEntity::class, - 'def' + 'def', ); self::assertCount(1, $owning->associatedEntities); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( InversedManyToManyEntity::class, - 'abc' + 'abc', ); self::assertCount(1, $inversed->associatedEntities); @@ -138,7 +130,7 @@ public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): $inversed = $this->_em->find( InversedManyToManyEntity::class, - 'abc' + 'abc', ); foreach ($inversed->associatedEntities as $owning) { diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php index 3e30e273842..ce8291c32cf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php @@ -72,24 +72,22 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('nop', $conn->fetchOne('SELECT associated_foreign_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedOneToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); $owning = $this->_em->find( OwningManyToOneCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); self::assertInstanceOf(AuxiliaryEntity::class, $auxiliary); @@ -97,24 +95,22 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningManyToOneCompositeIdForeignKeyEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedOneToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); $owning = $this->_em->find( OwningManyToOneCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); self::assertEquals('abc', $auxiliary->id4); @@ -123,32 +119,28 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id2); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase */ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedOneToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => $auxiliary] + ['id1' => 'def', 'foreignEntity' => $auxiliary], ); self::assertInstanceOf(InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningManyToOneCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); $inversedProxy = $owning->associatedEntity; @@ -158,14 +150,12 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( InversedOneToManyCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); self::assertCount(1, $inversed->associatedEntities); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php index f3e2c800de2..d71cd1acaa9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php @@ -63,38 +63,34 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('qrs', $conn->fetchOne('SELECT associated_id2 FROM vct_owning_manytoone_compositeid LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedOneToManyCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); $owning = $this->_em->find( OwningManyToOneCompositeIdEntity::class, - 'ghi' + 'ghi', ); self::assertInstanceOf(InversedOneToManyCompositeIdEntity::class, $inversed); self::assertInstanceOf(OwningManyToOneCompositeIdEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedOneToManyCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); $owning = $this->_em->find( OwningManyToOneCompositeIdEntity::class, - 'ghi' + 'ghi', ); self::assertEquals('abc', $inversed->id1); @@ -102,14 +98,12 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id3); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningManyToOneCompositeIdEntity::class, - 'ghi' + 'ghi', ); $inversedProxy = $owning->associatedEntity; @@ -117,14 +111,12 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( InversedOneToManyCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); self::assertCount(1, $inversed->associatedEntities); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php index acb78c45c73..434e740f2bc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php @@ -66,7 +66,7 @@ public function testThatExtraLazyCollectionIsCounted(): void { $inversed = $this->_em->find( InversedOneToManyExtraLazyEntity::class, - 'abc' + 'abc', ); self::assertEquals(3, $inversed->associatedEntities->count()); @@ -76,12 +76,12 @@ public function testThatExtraLazyCollectionContainsAnEntity(): void { $inversed = $this->_em->find( InversedOneToManyExtraLazyEntity::class, - 'abc' + 'abc', ); $owning = $this->_em->find( OwningManyToOneExtraLazyEntity::class, - 'def' + 'def', ); self::assertTrue($inversed->associatedEntities->contains($owning)); @@ -91,7 +91,7 @@ public function testThatExtraLazyCollectionContainsAnIndexbyKey(): void { $inversed = $this->_em->find( InversedOneToManyExtraLazyEntity::class, - 'abc' + 'abc', ); self::assertTrue($inversed->associatedEntities->containsKey('def')); @@ -101,7 +101,7 @@ public function testThatASliceOfTheExtraLazyCollectionIsLoaded(): void { $inversed = $this->_em->find( InversedOneToManyExtraLazyEntity::class, - 'abc' + 'abc', ); self::assertCount(2, $inversed->associatedEntities->slice(0, 2)); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php index 8165f51cf2c..ff87c7ae430 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php @@ -60,52 +60,46 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('nop', $conn->fetchOne('SELECT associated_id FROM vct_owning_manytoone LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedOneToManyEntity::class, - 'abc' + 'abc', ); $owning = $this->_em->find( OwningManyToOneEntity::class, - 'def' + 'def', ); self::assertInstanceOf(InversedOneToManyEntity::class, $inversed); self::assertInstanceOf(OwningManyToOneEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedOneToManyEntity::class, - 'abc' + 'abc', ); $owning = $this->_em->find( OwningManyToOneEntity::class, - 'def' + 'def', ); self::assertEquals('abc', $inversed->id1); self::assertEquals('def', $owning->id2); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningManyToOneEntity::class, - 'def' + 'def', ); $inversedProxy = $owning->associatedEntity; @@ -113,14 +107,12 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( InversedOneToManyEntity::class, - 'abc' + 'abc', ); self::assertCount(1, $inversed->associatedEntities); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php index 2bfcf3148d1..1bcb1bedc9d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php @@ -71,24 +71,22 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('nop', $conn->fetchOne('SELECT associated_foreign_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedOneToOneCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); $owning = $this->_em->find( OwningOneToOneCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); self::assertInstanceOf(AuxiliaryEntity::class, $auxiliary); @@ -96,24 +94,22 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningOneToOneCompositeIdForeignKeyEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedOneToOneCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); $owning = $this->_em->find( OwningOneToOneCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); self::assertEquals('abc', $auxiliary->id4); @@ -122,32 +118,28 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id2); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase */ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( AuxiliaryEntity::class, - 'abc' + 'abc', ); $inversed = $this->_em->find( InversedOneToOneCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => $auxiliary] + ['id1' => 'def', 'foreignEntity' => $auxiliary], ); self::assertInstanceOf(InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningOneToOneCompositeIdForeignKeyEntity::class, - 'ghi' + 'ghi', ); $inversedProxy = $owning->associatedEntity; @@ -155,14 +147,12 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( InversedOneToOneCompositeIdForeignKeyEntity::class, - ['id1' => 'def', 'foreignEntity' => 'abc'] + ['id1' => 'def', 'foreignEntity' => 'abc'], ); self::assertInstanceOf(OwningOneToOneCompositeIdForeignKeyEntity::class, $inversed->associatedEntity); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php index 972ebfc574f..3ace3c1eeaf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php @@ -62,38 +62,34 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('qrs', $conn->fetchOne('SELECT associated_id2 FROM vct_owning_onetoone_compositeid LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedOneToOneCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); $owning = $this->_em->find( OwningOneToOneCompositeIdEntity::class, - 'ghi' + 'ghi', ); self::assertInstanceOf(InversedOneToOneCompositeIdEntity::class, $inversed); self::assertInstanceOf(OwningOneToOneCompositeIdEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedOneToOneCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); $owning = $this->_em->find( OwningOneToOneCompositeIdEntity::class, - 'ghi' + 'ghi', ); self::assertEquals('abc', $inversed->id1); @@ -101,14 +97,12 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id3); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningOneToOneCompositeIdEntity::class, - 'ghi' + 'ghi', ); $inversedProxy = $owning->associatedEntity; @@ -116,14 +110,12 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( InversedOneToOneCompositeIdEntity::class, - ['id1' => 'abc', 'id2' => 'def'] + ['id1' => 'abc', 'id2' => 'def'], ); self::assertInstanceOf(OwningOneToOneCompositeIdEntity::class, $inversed->associatedEntity); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php index 657f077afca..eec2291db8c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php @@ -60,52 +60,46 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('nop', $conn->fetchOne('SELECT associated_id FROM vct_owning_onetoone LIMIT 1')); } - /** - * @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase - */ + /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedOneToOneEntity::class, - 'abc' + 'abc', ); $owning = $this->_em->find( OwningOneToOneEntity::class, - 'def' + 'def', ); self::assertInstanceOf(InversedOneToOneEntity::class, $inversed); self::assertInstanceOf(OwningOneToOneEntity::class, $owning); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( InversedOneToOneEntity::class, - 'abc' + 'abc', ); $owning = $this->_em->find( OwningOneToOneEntity::class, - 'def' + 'def', ); self::assertEquals('abc', $inversed->id1); self::assertEquals('def', $owning->id2); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( OwningOneToOneEntity::class, - 'def' + 'def', ); $inversedProxy = $owning->associatedEntity; @@ -113,14 +107,12 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** - * @depends testThatEntitiesAreFetchedFromTheDatabase - */ + /** @depends testThatEntitiesAreFetchedFromTheDatabase */ public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( InversedOneToOneEntity::class, - 'abc' + 'abc', ); self::assertInstanceOf(OwningOneToOneEntity::class, $inversed->associatedEntity); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index de30f3384d0..678804990e7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -25,9 +25,7 @@ use function class_exists; use function sprintf; -/** - * @group DDC-93 - */ +/** @group DDC-93 */ class ValueObjectsTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -40,7 +38,7 @@ protected function setUp(): void DDC93Vehicle::class, DDC93Car::class, DDC3027Animal::class, - DDC3027Dog::class + DDC3027Dog::class, ); } @@ -51,12 +49,12 @@ public function testMetadataHasReflectionEmbeddablesAccessible(): void if (class_exists(CommonRuntimePublicReflectionProperty::class)) { self::assertInstanceOf( CommonRuntimePublicReflectionProperty::class, - $classMetadata->getReflectionProperty('address') + $classMetadata->getReflectionProperty('address'), ); } else { self::assertInstanceOf( RuntimePublicReflectionProperty::class, - $classMetadata->getReflectionProperty('address') + $classMetadata->getReflectionProperty('address'), ); } @@ -155,9 +153,7 @@ public function testLoadDql(): void } } - /** - * @group dql - */ + /** @group dql */ public function testDqlOnEmbeddedObjectsField(): void { if ($this->isSecondLevelCacheEnabled) { @@ -180,7 +176,7 @@ public function testDqlOnEmbeddedObjectsField(): void $this->_em->createQuery($selectDql) ->setParameter('city', 'asdf') ->setParameter('country', 'Germany') - ->getOneOrNullResult() + ->getOneOrNullResult(), ); // UPDATE @@ -325,28 +321,24 @@ public function testInlineEmbeddableInMappedSuperClass(): void self::assertTrue($isFieldMapped); } - /** - * @dataProvider getInfiniteEmbeddableNestingData - */ + /** @dataProvider getInfiniteEmbeddableNestingData */ public function testThrowsExceptionOnInfiniteEmbeddableNesting( string $embeddableClassName, - string $declaredEmbeddableClassName + string $declaredEmbeddableClassName, ): void { $this->expectException(MappingException::class); $this->expectExceptionMessage( sprintf( 'Infinite nesting detected for embedded property %s::nested. ' . 'You cannot embed an embeddable from the same type inside an embeddable.', - __NAMESPACE__ . '\\' . $declaredEmbeddableClassName - ) + __NAMESPACE__ . '\\' . $declaredEmbeddableClassName, + ), ); $this->createSchemaForModels(__NAMESPACE__ . '\\' . $embeddableClassName); } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function getInfiniteEmbeddableNestingData(): array { return [ @@ -357,9 +349,7 @@ public function getInfiniteEmbeddableNestingData(): array } -/** - * @Entity - */ +/** @Entity */ class DDC93Person { /** @@ -377,30 +367,21 @@ class DDC93Person public $timestamps; public function __construct( - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $name = null, - /** - * @Embedded(class="DDC93Address") - */ - public ?DDC93Address $address = null + /** @Column(type="string", length=255) */ + public string|null $name = null, + /** @Embedded(class="DDC93Address") */ + public DDC93Address|null $address = null, ) { $this->timestamps = new DDC93Timestamps(new DateTime()); } } -/** - * @Embeddable - */ +/** @Embeddable */ class DDC93Timestamps { public function __construct( - /** - * @Column(type = "datetime") - */ - public DateTime $createdAt + /** @Column(type = "datetime") */ + public DateTime $createdAt, ) { } } @@ -424,61 +405,39 @@ abstract class DDC93Vehicle public $id; public function __construct( - /** - * @Embedded(class = "DDC93Address") - */ - public DDC93Address $address + /** @Embedded(class = "DDC93Address") */ + public DDC93Address $address, ) { } } -/** - * @Entity - */ +/** @Entity */ class DDC93Car extends DDC93Vehicle { } -/** - * @Embeddable - */ +/** @Embeddable */ class DDC93Country { public function __construct( - /** - * @Column(type="string", nullable=true) - */ - public ?string $name = null + /** @Column(type="string", nullable=true) */ + public string|null $name = null, ) { } } -/** - * @Embeddable - */ +/** @Embeddable */ class DDC93Address { public function __construct( - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $street = null, - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $zip = null, - /** - * @var string|null - * @Column(type="string", length=255) - */ - public $city = null, - /** - * @var DDC93Country - * @Embedded(class = "DDC93Country") - */ - public $country = null + /** @Column(type="string", length=255) */ + public string|null $street = null, + /** @Column(type="string", length=255) */ + public string|null $zip = null, + /** @Column(type="string", length=255) */ + public string|null $city = null, + /** @Embedded(class = "DDC93Country") */ + public DDC93Country|null $country = null, ) { } } @@ -513,59 +472,41 @@ class DDC93ContactInfo public $address; } -/** - * @Entity - */ +/** @Entity */ class DDC3028PersonWithPrefix { public function __construct( - /** - * @Embedded(class="DDC3028Id", columnPrefix = "foobar_") - */ - public ?DDC3028Id $id = null, - /** - * @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "bloo_") - */ - public ?DDC3028NestedEmbeddable $nested = null + /** @Embedded(class="DDC3028Id", columnPrefix = "foobar_") */ + public DDC3028Id|null $id = null, + /** @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "bloo_") */ + public DDC3028NestedEmbeddable|null $nested = null, ) { } } -/** - * @Entity - */ +/** @Entity */ class DDC3028PersonEmptyPrefix { public function __construct( - /** - * @Embedded(class="DDC3028Id", columnPrefix = "") - */ - public ?DDC3028Id $id = null, - /** - * @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "") - */ - public ?DDC3028NestedEmbeddable $nested = null + /** @Embedded(class="DDC3028Id", columnPrefix = "") */ + public DDC3028Id|null $id = null, + /** @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "") */ + public DDC3028NestedEmbeddable|null $nested = null, ) { } } -/** - * @Entity - */ +/** @Entity */ class DDC3028PersonPrefixFalse { public function __construct( - /** - * @Embedded(class="DDC3028Id", columnPrefix = false) - */ - public ?DDC3028Id $id = null + /** @Embedded(class="DDC3028Id", columnPrefix = false) */ + public DDC3028Id|null $id = null, ) { } } -/** - * @Embeddable - */ +/** @Embeddable */ class DDC3028Id { public function __construct( @@ -573,36 +514,26 @@ public function __construct( * @Id * @Column(type="string", length=255) */ - public ?string $id = null + public string|null $id = null, ) { } } -/** - * @Embeddable - */ +/** @Embeddable */ class DDC3028NestedEmbeddable { public function __construct( - /** - * @Embedded(class="DDC3028Id", columnPrefix = "foo_") - */ - public ?DDC3028Id $nestedWithPrefix = null, - /** - * @Embedded(class="DDC3028Id", columnPrefix = "") - */ - public ?DDC3028Id $nestedWithEmptyPrefix = null, - /** - * @Embedded(class="DDC3028Id", columnPrefix = false) - */ - public ?DDC3028Id $nestedWithPrefixFalse = null + /** @Embedded(class="DDC3028Id", columnPrefix = "foo_") */ + public DDC3028Id|null $nestedWithPrefix = null, + /** @Embedded(class="DDC3028Id", columnPrefix = "") */ + public DDC3028Id|null $nestedWithEmptyPrefix = null, + /** @Embedded(class="DDC3028Id", columnPrefix = false) */ + public DDC3028Id|null $nestedWithPrefixFalse = null, ) { } } -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ abstract class DDC3027Animal { /** @@ -620,16 +551,12 @@ abstract class DDC3027Animal public $address; } -/** - * @Entity - */ +/** @Entity */ class DDC3027Dog extends DDC3027Animal { } -/** - * @Embeddable - */ +/** @Embeddable */ class DDCInfiniteNestingEmbeddable { /** @@ -639,9 +566,7 @@ class DDCInfiniteNestingEmbeddable public $nested; } -/** - * @Embeddable - */ +/** @Embeddable */ class DDCNestingEmbeddable1 { /** @@ -663,9 +588,7 @@ class DDCNestingEmbeddable1 public $nested; } -/** - * @Embeddable - */ +/** @Embeddable */ class DDCNestingEmbeddable2 { /** @@ -687,9 +610,7 @@ class DDCNestingEmbeddable2 public $nested; } -/** - * @Embeddable - */ +/** @Embeddable */ class DDCNestingEmbeddable3 { /** @@ -711,9 +632,7 @@ class DDCNestingEmbeddable3 public $nested; } -/** - * @Embeddable - */ +/** @Embeddable */ class DDCNestingEmbeddable4 { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php index d008e17ef79..5921eceaf0f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php @@ -21,7 +21,7 @@ protected function setUp(): void $this->createSchemaForModels( FirstRelatedEntity::class, - SecondRelatedEntity::class + SecondRelatedEntity::class, ); } diff --git a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php index fe60af19275..ad0d9c20cbc 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php @@ -18,9 +18,7 @@ use function iterator_to_array; -/** - * @covers \Doctrine\ORM\Internal\Hydration\AbstractHydrator - */ +/** @covers \Doctrine\ORM\Internal\Hydration\AbstractHydrator */ class AbstractHydratorTest extends OrmFunctionalTestCase { private EventManager&MockObject $mockEventManager; @@ -90,9 +88,7 @@ public function testOnClearEventListenerIsDetachedOnCleanup(): void iterator_to_array($this->hydrator->toIterable($this->mockResult, $this->mockResultMapping)); } - /** - * @group #6623 - */ + /** @group #6623 */ public function testHydrateAllRegistersAndClearsAllAttachedListeners(): void { $eventListenerHasBeenRegistered = false; @@ -119,9 +115,7 @@ public function testHydrateAllRegistersAndClearsAllAttachedListeners(): void $this->hydrator->hydrateAll($this->mockResult, $this->mockResultMapping); } - /** - * @group #8482 - */ + /** @group #8482 */ public function testHydrateAllClearsAllAttachedListenersEvenOnError(): void { $eventListenerHasBeenRegistered = false; diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php index c71db7dd9d8..8ce6b4ea924 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php @@ -15,9 +15,7 @@ class ArrayHydratorTest extends HydrationTestCase { - /** - * @psalm-return list - */ + /** @psalm-return list */ public function provideDataForUserEntityResult(): array { return [ @@ -438,7 +436,7 @@ public function testMixedQueryFetchJoin(int|string $userEntityKey): void CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -509,7 +507,7 @@ public function testMixedQueryFetchJoinCustomIndex(int|string $userEntityKey): v CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -587,13 +585,13 @@ public function testMixedQueryMultipleFetchJoin(): void CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addJoinedEntityResult( CmsArticle::class, 'a', 'u', - 'articles' + 'articles', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -706,19 +704,19 @@ public function testMixedQueryMultipleDeepMixedFetchJoin(): void CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addJoinedEntityResult( CmsArticle::class, 'a', 'u', - 'articles' + 'articles', ); $rsm->addJoinedEntityResult( CmsComment::class, 'c', 'a', - 'comments' + 'comments', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -863,7 +861,7 @@ public function testEntityQueryCustomResultSetOrder(): void ForumBoard::class, 'b', 'c', - 'boards' + 'boards', ); $rsm->addFieldResult('c', 'c__id', 'id'); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index 85771952f65..e6814b55ba9 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -34,9 +34,7 @@ class ObjectHydratorTest extends HydrationTestCase { - /** - * @psalm-return list - */ + /** @psalm-return list */ public function provideDataForUserEntityResult(): array { return [ @@ -45,9 +43,7 @@ public function provideDataForUserEntityResult(): array ]; } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function provideDataForMultipleRootEntityResult(): array { return [ @@ -58,9 +54,7 @@ public function provideDataForMultipleRootEntityResult(): array ]; } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function provideDataForProductEntityResult(): array { return [ @@ -452,7 +446,7 @@ public function testMixedQueryFetchJoin($userEntityKey): void CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -530,7 +524,7 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -608,13 +602,13 @@ public function testMixedQueryMultipleFetchJoin($userEntityKey): void CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addJoinedEntityResult( CmsArticle::class, 'a', 'u', - 'articles' + 'articles', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -718,19 +712,19 @@ public function testMixedQueryMultipleDeepMixedFetchJoin($userEntityKey): void CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addJoinedEntityResult( CmsArticle::class, 'a', 'u', - 'articles' + 'articles', ); $rsm->addJoinedEntityResult( CmsComment::class, 'c', 'a', - 'comments' + 'comments', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -875,7 +869,7 @@ public function testEntityQueryCustomResultSetOrder(): void ForumBoard::class, 'b', 'c', - 'boards' + 'boards', ); $rsm->addFieldResult('c', 'c__id', 'id'); $rsm->addFieldResult('c', 'c__position', 'position'); @@ -1124,13 +1118,13 @@ public function testChainedJoinWithEmptyCollections(): void CmsArticle::class, 'a', 'u', - 'articles' + 'articles', ); $rsm->addJoinedEntityResult( CmsComment::class, 'c', 'a', - 'comments' + 'comments', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -1187,13 +1181,13 @@ public function testChainedJoinWithEmptyCollectionsWithAliasedUserEntity(): void CmsArticle::class, 'a', 'u', - 'articles' + 'articles', ); $rsm->addJoinedEntityResult( CmsComment::class, 'c', 'a', - 'comments' + 'comments', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -1267,7 +1261,7 @@ public function testResultIteration(): void $iterableResult = $hydrator->toIterable( $this->createResultMock($resultSet), $rsm, - [Query::HINT_FORCE_PARTIAL_LOAD => true] + [Query::HINT_FORCE_PARTIAL_LOAD => true], ); $rowNum = 0; @@ -1290,7 +1284,7 @@ public function testResultIteration(): void $iterableResult = $hydrator->toIterable( $this->createResultMock($resultSet), $rsm, - [Query::HINT_FORCE_PARTIAL_LOAD => true] + [Query::HINT_FORCE_PARTIAL_LOAD => true], ); $rowNum = 0; @@ -1341,7 +1335,7 @@ public function testResultIterationWithAliasedUserEntity(): void $iterableResult = $hydrator->toIterable( new Result(new ArrayResult($resultSet), $this->createMock(Connection::class)), $rsm, - [Query::HINT_FORCE_PARTIAL_LOAD => true] + [Query::HINT_FORCE_PARTIAL_LOAD => true], ); foreach ($iterableResult as $row) { @@ -1366,7 +1360,7 @@ public function testResultIterationWithAliasedUserEntity(): void $iterableResult = $hydrator->toIterable( $this->createResultMock($resultSet), $rsm, - [Query::HINT_FORCE_PARTIAL_LOAD => true] + [Query::HINT_FORCE_PARTIAL_LOAD => true], ); foreach ($iterableResult as $row) { @@ -1713,7 +1707,7 @@ public function testMissingIdForCollectionValuedChildEntity($userEntityKey): voi CmsPhonenumber::class, 'p', 'u', - 'phonenumbers' + 'phonenumbers', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -1775,7 +1769,7 @@ public function testMissingIdForSingleValuedChildEntity($userEntityKey): void CmsAddress::class, 'a', 'u', - 'address' + 'address', ); $rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__status', 'status'); @@ -1888,13 +1882,11 @@ public function testIndexByScalarsOnly($userEntityKey): void 'ROMANB' => ['nameUpper' => 'ROMANB'], 'JWAGE' => ['nameUpper' => 'JWAGE'], ], - $result + $result, ); } - /** - * @group DDC-1470 - */ + /** @group DDC-1470 */ public function testMissingMetaMappingException(): void { $this->expectException(HydrationException::class); @@ -1918,9 +1910,7 @@ public function testMissingMetaMappingException(): void $hydrator->hydrateAll($stmt, $rsm); } - /** - * @group DDC-1470 - */ + /** @group DDC-1470 */ public function testMissingDiscriminatorColumnException(): void { $this->expectException(HydrationException::class); @@ -1951,9 +1941,7 @@ public function testMissingDiscriminatorColumnException(): void $hydrator->hydrateAll($stmt, $rsm); } - /** - * @group DDC-3076 - */ + /** @group DDC-3076 */ public function testInvalidDiscriminatorValueException(): void { $this->expectException(HydrationException::class); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php index 198ac003429..d042064821c 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -34,7 +34,7 @@ public function testBasicResultSetMapping(): void { $this->_rsm->addEntityResult( CmsUser::class, - 'u' + 'u', ); $this->_rsm->addFieldResult('u', 'id', 'id'); $this->_rsm->addFieldResult('u', 'status', 'status'); @@ -90,9 +90,7 @@ public function testFluentInterface(): void self::assertTrue($rms->isMixedResult()); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testIndexByMetadataColumn(): void { $this->_rsm->addEntityResult(LegacyUser::class, 'u'); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php index 3d617e7603f..b87bc6c1496 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php @@ -113,7 +113,7 @@ public function testMultipleColumnEntityQueryThrowsException(): void $this->expectException(MultipleSelectorsFoundException::class); $this->expectExceptionMessage(sprintf( MultipleSelectorsFoundException::MULTIPLE_SELECTORS_FOUND_EXCEPTION, - 'id, name' + 'id, name', )); $hydrator->hydrateAll($stmt, $rsm); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php index 6073846e4a0..fef42af6fb2 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php @@ -45,9 +45,7 @@ public function testNewHydrationSimpleEntityQuery(): void self::assertEquals(2, $result[1]['u_id']); } - /** - * @group DDC-407 - */ + /** @group DDC-407 */ public function testHydrateScalarResults(): void { $rsm = new ResultSetMapping(); @@ -69,9 +67,7 @@ public function testHydrateScalarResults(): void self::assertCount(1, $hydrator->hydrateAll($stmt, $rsm)); } - /** - * @group DDC-644 - */ + /** @group DDC-644 */ public function testSkipUnknownColumns(): void { $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php index e4c46a530de..9078e52d929 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php @@ -21,9 +21,7 @@ class SimpleObjectHydratorTest extends HydrationTestCase { - /** - * @group DDC-1470 - */ + /** @group DDC-1470 */ public function testMissingDiscriminatorColumnException(): void { $this->expectException(HydrationException::class); @@ -70,9 +68,7 @@ public function testExtraFieldInResultSetShouldBeIgnore(): void self::assertEquals($result[0], $expectedEntity); } - /** - * @group DDC-3076 - */ + /** @group DDC-3076 */ public function testInvalidDiscriminatorValueException(): void { $this->expectException(HydrationException::class); @@ -99,9 +95,7 @@ public function testInvalidDiscriminatorValueException(): void $hydrator->hydrateAll($stmt, $rsm); } - /** - * @group issue-5989 - */ + /** @group issue-5989 */ public function testNullValueShouldNotOverwriteFieldWithSameNameInJoinedInheritance(): void { $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php index 792b5c5ed22..a8ab2ea819f 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php @@ -12,9 +12,7 @@ class SingleScalarHydratorTest extends HydrationTestCase { - /** - * @return Generator>,mixed}> - */ + /** @return Generator>,mixed}> */ public static function validResultSetProvider(): Generator { // SELECT u.name FROM CmsUser u WHERE u.id = 1 @@ -86,9 +84,7 @@ public function testHydrateSingleScalarFromScalarMappingWithValidResultSet(array $this->assertEquals($expectedResult, $result); } - /** - * @return Generator>}> - */ + /** @return Generator>}> */ public static function invalidResultSetProvider(): Generator { // Single row (OK), multiple columns (NOT OK) diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php index 7c9a2560840..d8bf42559a1 100644 --- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -27,9 +27,7 @@ protected function setUp(): void $this->assignedGen = new AssignedGenerator(); } - /** - * @dataProvider entitiesWithoutId - */ + /** @dataProvider entitiesWithoutId */ public function testThrowsExceptionIfIdNotAssigned($entity): void { $this->expectException(ORMException::class); diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index 69124ac83ea..b41d0cafcc0 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -35,9 +35,7 @@ protected function setUp(): void $this->handler = new HydrationCompleteHandler($this->listenersInvoker, $this->entityManager); } - /** - * @dataProvider invocationFlagProvider - */ + /** @dataProvider invocationFlagProvider */ public function testDefersPostLoadOfEntity(int $listenersFlag): void { $metadata = $this->createMock(ClassMetadata::class); @@ -63,15 +61,13 @@ public function testDefersPostLoadOfEntity(int $listenersFlag): void Events::postLoad, $entity, self::callback(static fn (LifecycleEventArgs $args) => $entity === $args->getObject() && $entityManager === $args->getObjectManager()), - $listenersFlag + $listenersFlag, ); $this->handler->hydrationComplete(); } - /** - * @dataProvider invocationFlagProvider - */ + /** @dataProvider invocationFlagProvider */ public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void { $metadata = $this->createMock(ClassMetadata::class); @@ -93,9 +89,7 @@ public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void $this->handler->hydrationComplete(); } - /** - * @dataProvider invocationFlagProvider - */ + /** @dataProvider invocationFlagProvider */ public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void { $metadata1 = $this->createMock(ClassMetadata::class); @@ -124,7 +118,7 @@ public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void self::logicalOr($entity1, $entity2), self::callback(static fn (LifecycleEventArgs $args) => in_array($args->getObject(), [$entity1, $entity2], true) && $entityManager === $args->getObjectManager()), - $listenersFlag + $listenersFlag, ); $this->handler->hydrationComplete(); @@ -150,9 +144,7 @@ public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners(): voi $this->handler->hydrationComplete(); } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function invocationFlagProvider(): array { return [ diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index a64fd7221f5..4b553e7f2ae 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -12,9 +12,7 @@ use PHPUnit\Framework\TestCase; use stdClass; -/** - * @covers \Doctrine\ORM\LazyCriteriaCollection - */ +/** @covers \Doctrine\ORM\LazyCriteriaCollection */ class LazyCriteriaCollectionTest extends TestCase { private EntityPersister&MockObject $persister; diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index 2a95b15b426..c11706a7f3e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -39,9 +39,7 @@ class AnnotationDriverTest extends MappingDriverTestCase { - /** - * @group DDC-268 - */ + /** @group DDC-268 */ public function testLoadMetadataForNonEntityThrowsException(): void { $cm = new ClassMetadata(stdClass::class); @@ -63,9 +61,7 @@ public function testFailingSecondLevelCacheAssociation(): void $mappingDriver->loadMetadataForClass(AnnotationSLC::class, $class); } - /** - * @group DDC-268 - */ + /** @group DDC-268 */ public function testColumnWithMissingTypeDefaultsToString(): void { $cm = new ClassMetadata(ColumnWithoutType::class); @@ -76,9 +72,7 @@ public function testColumnWithMissingTypeDefaultsToString(): void self::assertEquals('string', $cm->fieldMappings['id']['type']); } - /** - * @group DDC-318 - */ + /** @group DDC-318 */ public function testGetAllClassNamesIsIdempotent(): void { $annotationDriver = $this->loadDriverForCMSModels(); @@ -90,9 +84,7 @@ public function testGetAllClassNamesIsIdempotent(): void self::assertEquals($original, $afterTestReset); } - /** - * @group DDC-318 - */ + /** @group DDC-318 */ public function testGetAllClassNamesIsIdempotentEvenWithDifferentDriverInstances(): void { $annotationDriver = $this->loadDriverForCMSModels(); @@ -104,9 +96,7 @@ public function testGetAllClassNamesIsIdempotentEvenWithDifferentDriverInstances self::assertEquals($original, $afterTestReset); } - /** - * @group DDC-318 - */ + /** @group DDC-318 */ public function testGetAllClassNamesReturnsAlreadyLoadedClassesIfAppropriate(): void { $this->ensureIsLoaded(CmsUser::class); @@ -117,9 +107,7 @@ public function testGetAllClassNamesReturnsAlreadyLoadedClassesIfAppropriate(): self::assertContains(CmsUser::class, $classes); } - /** - * @group DDC-318 - */ + /** @group DDC-318 */ public function testGetClassNamesReturnsOnlyTheAppropriateClasses(): void { $this->ensureIsLoaded(ECommerceCart::class); @@ -138,17 +126,13 @@ protected function loadDriverForCMSModels(): AnnotationDriver return $annotationDriver; } - /** - * @return AnnotationDriver - */ + /** @return AnnotationDriver */ protected function loadDriver(): MappingDriver { return $this->createAnnotationDriver(); } - /** - * @psalm-var class-string $entityClassName - */ + /** @psalm-var class-string $entityClassName */ protected function ensureIsLoaded(string $entityClassName): void { new $entityClassName(); @@ -176,9 +160,7 @@ public function testJoinTablesWithMappedSuperclassForAnnotationDriver(): void self::assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); } - /** - * @group DDC-945 - */ + /** @group DDC-945 */ public function testInvalidMappedSuperClassWithManyToManyAssociation(): void { $annotationDriver = $this->loadDriver(); @@ -191,15 +173,13 @@ public function testInvalidMappedSuperClassWithManyToManyAssociation(): void $this->expectException(MappingException::class); $this->expectExceptionMessage( 'It is illegal to put an inverse side one-to-many or many-to-many association on ' . - "mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'" + "mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'", ); $factory->getMetadataFor(UsingInvalidMappedSuperClass::class); } - /** - * @group DDC-1050 - */ + /** @group DDC-1050 */ public function testInvalidMappedSuperClassWithInheritanceInformation(): void { $annotationDriver = $this->loadDriver(); @@ -212,15 +192,13 @@ public function testInvalidMappedSuperClassWithInheritanceInformation(): void $this->expectException(MappingException::class); $this->expectExceptionMessage( 'It is not supported to define inheritance information on a mapped ' . - "superclass '" . MappedSuperClassInheritence::class . "'." + "superclass '" . MappedSuperClassInheritence::class . "'.", ); $usingInvalidMsc = $factory->getMetadataFor(MappedSuperClassInheritence::class); } - /** - * @group DDC-1034 - */ + /** @group DDC-1034 */ public function testInheritanceSkipsParentLifecycleCallbacks(): void { $annotationDriver = $this->loadDriver(); @@ -237,9 +215,7 @@ public function testInheritanceSkipsParentLifecycleCallbacks(): void self::assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); } - /** - * @group DDC-1156 - */ + /** @group DDC-1156 */ public function testMappedSuperclassInMiddleOfInheritanceHierarchy(): void { $annotationDriver = $this->loadDriver(); @@ -306,9 +282,7 @@ public function provideDiscriminatorColumnTestcases(): Generator } } -/** - * @Entity - */ +/** @Entity */ class ColumnWithoutType { /** @@ -319,9 +293,7 @@ class ColumnWithoutType public $id; } -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ class InvalidMappedSuperClass { /** @@ -331,9 +303,7 @@ class InvalidMappedSuperClass private $users; } -/** - * @Entity - */ +/** @Entity */ class UsingInvalidMappedSuperClass extends InvalidMappedSuperClass { /** @@ -368,16 +338,12 @@ class AnnotationParent */ private int $id; - /** - * @PostLoad - */ + /** @PostLoad */ public function postLoad(): void { } - /** - * @PreUpdate - */ + /** @PreUpdate */ public function preUpdate(): void { } @@ -405,27 +371,21 @@ class SuperEntity private string $id; } -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ class MiddleMappedSuperclass extends SuperEntity { /** @Column(type="string", length=255) */ private string $name; } -/** - * @Entity - */ +/** @Entity */ class ChildEntity extends MiddleMappedSuperclass { /** @Column(type="string", length=255) */ private string $text; } -/** - * @Entity - */ +/** @Entity */ class InvalidFetchOption { /** @OneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", fetch="eager") */ @@ -445,9 +405,7 @@ class AnnotationSLC */ public $foo; } -/** - * @Entity - */ +/** @Entity */ class AnnotationSLCFoo { /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index 10ef06baf2b..e76aff61948 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -69,7 +69,7 @@ public function testJoinTableName(): void 'targetEntity' => 'CmsUser', 'inversedBy' => 'users', 'joinTable' => ['name' => 'cmsaddress_cmsuser'], - ] + ], ); self::assertEquals('cmsaddress_cmsuser', $this->strategy->getJoinTableName($class->associationMappings['user'], $class, $this->platform)); @@ -84,7 +84,7 @@ public function testIdentifierColumnNames(): void 'id' => true, 'fieldName' => 'id', 'columnName' => 'id', - ] + ], ); self::assertEquals(['id'], $this->strategy->getIdentifierColumnNames($class, $this->platform)); @@ -107,7 +107,7 @@ public function testJoinColumnName(): void 'joinColumns' => [ ['name' => 'article'], ], - ] + ], ); $joinColumn = $class->associationMappings['article']['joinColumns'][0]; @@ -126,7 +126,7 @@ public function testReferencedJoinColumnName(): void 'joinColumns' => [ ['name' => 'article'], ], - ] + ], ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 99652e1b19f..65770a320bb 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -37,7 +37,7 @@ public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): v 'uniqueConstraints' => ['foo' => ['columns' => ['id']]], 'indexes' => ['bar' => ['columns' => ['id']]], ], - $metadata->table + $metadata->table, ); self::assertEquals(['assoz_id', 'assoz_id'], $metadata->associationMappings['assoc']['joinTableColumns']); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeReaderTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeReaderTest.php index 2f9dbcbd38d..a72b358c2f1 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeReaderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeReaderTest.php @@ -22,7 +22,7 @@ public function testItThrowsWhenGettingRepeatableAnnotationWithTheWrongMethod(): $property = new ReflectionProperty(TestEntity::class, 'id'); $this->expectException(LogicException::class); $this->expectExceptionMessage( - 'The attribute "Doctrine\ORM\Mapping\Index" is repeatable. Call getPropertyAnnotationCollection() instead.' + 'The attribute "Doctrine\ORM\Mapping\Index" is repeatable. Call getPropertyAnnotationCollection() instead.', ); $reader->getPropertyAnnotation($property, ORM\Index::class); } @@ -33,7 +33,7 @@ public function testItThrowsWhenGettingNonRepeatableAnnotationWithTheWrongMethod $property = new ReflectionProperty(TestEntity::class, 'id'); $this->expectException(LogicException::class); $this->expectExceptionMessage( - 'The attribute "Doctrine\ORM\Mapping\Id" is not repeatable. Call getPropertyAnnotation() instead.' + 'The attribute "Doctrine\ORM\Mapping\Id" is not repeatable. Call getPropertyAnnotation() instead.', ); $reader->getPropertyAnnotationCollection($property, ORM\Id::class); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index a19b3335a64..3356abae711 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -81,9 +81,7 @@ public function testGetMetadataForSubclassWithMappedSuperclass(): void self::assertArrayHasKey('mappedRelated1', $class->associationMappings); } - /** - * @group DDC-869 - */ + /** @group DDC-869 */ public function testGetMetadataForSubclassWithMappedSuperclassWithRepository(): void { $class = $this->cmf->getMetadataFor(DDC869CreditCardPayment::class); @@ -108,9 +106,7 @@ public function testGetMetadataForSubclassWithMappedSuperclassWithRepository(): self::assertEquals($class->customRepositoryClassName, EntityRepository::class); } - /** - * @group DDC-388 - */ + /** @group DDC-388 */ public function testSerializationWithPrivateFieldsFromMappedSuperclass(): void { $class = $this->cmf->getMetadataFor(EntitySubClass2::class); @@ -123,9 +119,7 @@ public function testSerializationWithPrivateFieldsFromMappedSuperclass(): void self::assertArrayHasKey('mappedRelated1', $class2->reflFields); } - /** - * @group DDC-1203 - */ + /** @group DDC-1203 */ public function testUnmappedSuperclassInHierarchy(): void { $class = $this->cmf->getMetadataFor(HierarchyD::class); @@ -135,9 +129,7 @@ public function testUnmappedSuperclassInHierarchy(): void self::assertArrayHasKey('d', $class->fieldMappings); } - /** - * @group DDC-1204 - */ + /** @group DDC-1204 */ public function testUnmappedEntityInHierarchy(): void { $this->expectException(MappingException::class); @@ -145,7 +137,7 @@ public function testUnmappedEntityInHierarchy(): void 'Entity \'Doctrine\Tests\ORM\Mapping\HierarchyBEntity\' has to be part of the discriminator map' . ' of \'Doctrine\Tests\ORM\Mapping\HierarchyBase\' to be properly mapped in the inheritance hierarchy.' . ' Alternatively you can make \'Doctrine\Tests\ORM\Mapping\HierarchyBEntity\' an abstract class to' - . ' avoid this exception from occurring.' + . ' avoid this exception from occurring.', ); $this->cmf->getMetadataFor(HierarchyE::class); @@ -174,7 +166,7 @@ public function testGeneratedValueFromMappedSuperclass(): void self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], - $class->sequenceGeneratorDefinition + $class->sequenceGeneratorDefinition, ); } @@ -190,7 +182,7 @@ public function testSequenceDefinitionInHierarchyWithSandwichMappedSuperclass(): self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], - $class->sequenceGeneratorDefinition + $class->sequenceGeneratorDefinition, ); } @@ -206,7 +198,7 @@ public function testMultipleMappedSuperclasses(): void self::assertInstanceOf(IdSequenceGenerator::class, $class->idGenerator); self::assertEquals( ['allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'], - $class->sequenceGeneratorDefinition + $class->sequenceGeneratorDefinition, ); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 86138158f7b..e4dd30653e9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -15,9 +15,7 @@ use Doctrine\Tests\Models\ValueObjects\Name; use Doctrine\Tests\OrmTestCase; -/** - * @group DDC-659 - */ +/** @group DDC-659 */ class ClassMetadataBuilderTest extends OrmTestCase { private ClassMetadata $cm; @@ -57,7 +55,7 @@ public function testAddEmbeddedWithOnlyRequiredParams(): void 'originalField' => null, ], ], - $this->cm->embeddedClasses + $this->cm->embeddedClasses, ); } @@ -67,8 +65,8 @@ public function testAddEmbeddedWithPrefix(): void $this->builder->addEmbedded( 'name', Name::class, - 'nm_' - ) + 'nm_', + ), ); self::assertEquals( @@ -80,7 +78,7 @@ public function testAddEmbeddedWithPrefix(): void 'originalField' => null, ], ], - $this->cm->embeddedClasses + $this->cm->embeddedClasses, ); } @@ -99,7 +97,7 @@ public function testCreateEmbeddedWithoutExtraParams(): void 'declaredField' => null, 'originalField' => null, ], - $this->cm->embeddedClasses['name'] + $this->cm->embeddedClasses['name'], ); } @@ -118,7 +116,7 @@ public function testCreateEmbeddedWithColumnPrefix(): void 'declaredField' => null, 'originalField' => null, ], - $this->cm->embeddedClasses['name'] + $this->cm->embeddedClasses['name'], ); } @@ -164,7 +162,7 @@ public function testSetPrimaryTableRelated(): void 'indexes' => ['users_idx' => ['columns' => ['username', 'name']]], 'uniqueConstraints' => ['users_idx' => ['columns' => ['username', 'name']]], ], - $this->cm->table + $this->cm->table, ); } @@ -193,7 +191,7 @@ public function testAddDiscriminatorMapClass(): void self::assertEquals( ['test' => CmsUser::class, 'test2' => CmsGroup::class], - $this->cm->discriminatorMap + $this->cm->discriminatorMap, ); self::assertEquals('test', $this->cm->discriminatorValue); } @@ -240,7 +238,7 @@ public function testCreateVersionedField(): void 'nullable' => true, 'unique' => true, ], - $this->cm->fieldMappings['name'] + $this->cm->fieldMappings['name'], ); } @@ -258,7 +256,7 @@ public function testCreateUnsignedOptionField(): void self::assertEquals( ['fieldName' => 'state', 'type' => 'integer', 'options' => ['unsigned' => true], 'columnName' => 'state'], - $this->cm->fieldMappings['state'] + $this->cm->fieldMappings['state'], ); } @@ -276,7 +274,7 @@ public function testCreateManyToOne(): void ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') ->cascadeAll() ->fetchExtraLazy() - ->build() + ->build(), ); self::assertEquals( @@ -322,7 +320,7 @@ public function testCreateManyToOne(): void 'orphanRemoval' => false, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } @@ -336,7 +334,7 @@ public function testCreateManyToOneWithIdentity(): void ->cascadeAll() ->fetchExtraLazy() ->makePrimaryKey() - ->build() + ->build(), ); self::assertEquals( @@ -383,7 +381,7 @@ public function testCreateManyToOneWithIdentity(): void 'id' => true, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } @@ -394,7 +392,7 @@ public function testCreateOneToOne(): void ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') ->cascadeAll() ->fetchExtraLazy() - ->build() + ->build(), ); self::assertEquals( @@ -440,7 +438,7 @@ public function testCreateOneToOne(): void 'orphanRemoval' => false, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } @@ -454,7 +452,7 @@ public function testCreateOneToOneWithIdentity(): void ->cascadeAll() ->fetchExtraLazy() ->makePrimaryKey() - ->build() + ->build(), ); self::assertEquals( @@ -501,7 +499,7 @@ public function testCreateOneToOneWithIdentity(): void 'orphanRemoval' => false, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } @@ -527,7 +525,7 @@ public function testCreateManyToMany(): void ->addInverseJoinColumn('user_id', 'id') ->cascadeAll() ->fetchExtraLazy() - ->build() + ->build(), ); self::assertEquals( @@ -596,7 +594,7 @@ public function testCreateManyToMany(): void 'orphanRemoval' => false, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } @@ -621,7 +619,7 @@ public function testCreateOneToMany(): void ->mappedBy('test') ->setOrderBy(['test']) ->setIndexBy('test') - ->build() + ->build(), ); self::assertEquals( @@ -649,7 +647,7 @@ public function testCreateOneToMany(): void 'orphanRemoval' => false, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } @@ -672,7 +670,7 @@ public function testOrphanRemovalOnCreateOneToOne(): void ->createOneToOne('groups', CmsGroup::class) ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') ->orphanRemoval() - ->build() + ->build(), ); self::assertEquals( @@ -712,7 +710,7 @@ public function testOrphanRemovalOnCreateOneToOne(): void 'orphanRemoval' => true, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } @@ -723,7 +721,7 @@ public function testOrphanRemovalOnCreateOneToMany(): void ->createOneToMany('groups', CmsGroup::class) ->mappedBy('test') ->orphanRemoval() - ->build() + ->build(), ); self::assertEquals( @@ -747,7 +745,7 @@ public function testOrphanRemovalOnCreateOneToMany(): void 'orphanRemoval' => true, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } @@ -817,7 +815,7 @@ public function testOrphanRemovalOnManyToMany(): void 'orphanRemoval' => true, ], ], - $this->cm->associationMappings + $this->cm->associationMappings, ); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 5f5f0277f11..3327da34047 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -151,9 +151,7 @@ public function testGetMetadataForThrowsExceptionOnMissingCustomGeneratorDefinit $actual = $cmf->getMetadataFor($cm1->name); } - /** - * @group DDC-1512 - */ + /** @group DDC-1512 */ public function testIsTransient(): void { $cmf = new ClassMetadataFactory(); @@ -162,13 +160,13 @@ public function testIsTransient(): void ->method('isTransient') ->withConsecutive( [CmsUser::class], - [CmsArticle::class] + [CmsArticle::class], ) ->willReturnMap( [ [CmsUser::class, true], [CmsArticle::class, false], - ] + ], ); $em = $this->createEntityManager($driver); @@ -280,7 +278,7 @@ protected function createValidClassMetadata(): ClassMetadata ['name' => 'other_id', 'referencedColumnName' => 'id'], ]; $cm1->mapOneToOne( - ['fieldName' => 'association', 'targetEntity' => 'TestEntity1', 'joinColumns' => $joinColumns] + ['fieldName' => 'association', 'targetEntity' => 'TestEntity1', 'joinColumns' => $joinColumns], ); // and an id generator type $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); @@ -288,9 +286,7 @@ protected function createValidClassMetadata(): ClassMetadata return $cm1; } - /** - * @group DDC-1845 - */ + /** @group DDC-1845 */ public function testQuoteMetadata(): void { $cmf = new ClassMetadataFactory(); @@ -401,9 +397,7 @@ public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args): self::assertSame($metadata, $cmf->getMetadataFor('Foo')); } - /** - * @group DDC-3427 - */ + /** @group DDC-3427 */ public function testAcceptsEntityManagerInterfaceInstances(): void { $classMetadataFactory = new ClassMetadataFactory(); @@ -418,9 +412,7 @@ public function testAcceptsEntityManagerInterfaceInstances(): void self::assertSame($entityManager, $property->getValue($classMetadataFactory)); } - /** - * @group DDC-3305 - */ + /** @group DDC-3305 */ public function testRejectsEmbeddableWithoutValidClassName(): void { $metadata = $this->createValidClassMetadata(); @@ -430,7 +422,7 @@ public function testRejectsEmbeddableWithoutValidClassName(): void 'fieldName' => 'embedded', 'class' => '', 'columnPrefix' => false, - ] + ], ); $cmf = $this->createTestFactory(); @@ -443,9 +435,7 @@ public function testRejectsEmbeddableWithoutValidClassName(): void $cmf->getMetadataFor($metadata->name); } - /** - * @group DDC-4006 - */ + /** @group DDC-4006 */ public function testInheritsIdGeneratorMappingFromEmbeddable(): void { $cmf = new ClassMetadataFactory(); @@ -505,16 +495,14 @@ protected function newClassMetadataInstance(string $className): ClassMetadata if (! isset($this->mockMetadata[$className])) { throw new InvalidArgumentException(sprintf( 'No mock metadata found for class %s.', - $className + $className, )); } return $this->mockMetadata[$className]; } - /** - * @psalm-param class-string $className - */ + /** @psalm-param class-string $className */ public function setMetadataForClass(string $className, ClassMetadata $metadata): void { $this->mockMetadata[$className] = $metadata; @@ -539,7 +527,7 @@ class TestEntity1 class CustomIdGenerator extends AbstractIdGenerator { - public function generateId(EntityManagerInterface $em, ?object $entity): string + public function generateId(EntityManagerInterface $em, object|null $entity): string { return 'foo'; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index 7a80f2b399b..80c9b34303e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -16,9 +16,7 @@ class ClassMetadataLoadEventTest extends OrmTestCase { - /** - * @group DDC-1610 - */ + /** @group DDC-1610 */ public function testEvent(): void { $em = $this->getTestEntityManager(); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 713fb1b7bc4..bdd842fe4d8 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -174,9 +174,7 @@ public function testFieldTypeFromReflection(): void self::assertEquals('float', $cm->getTypeOfField('float')); } - /** - * @group DDC-115 - */ + /** @group DDC-115 */ public function testMapAssociationInGlobalNamespace(): void { require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; @@ -192,7 +190,7 @@ public function testMapAssociationInGlobalNamespace(): void 'joinColumns' => [['name' => 'bar_id', 'referencedColumnName' => 'id']], 'inverseJoinColumns' => [['name' => 'baz_id', 'referencedColumnName' => 'id']], ], - ] + ], ); self::assertEquals('DoctrineGlobalUser', $cm->associationMappings['author']['targetEntity']); @@ -206,7 +204,7 @@ public function testMapManyToManyJoinTableDefaults(): void [ 'fieldName' => 'groups', 'targetEntity' => 'CmsGroup', - ] + ], ); $assoc = $cm->associationMappings['groups']; @@ -216,7 +214,7 @@ public function testMapManyToManyJoinTableDefaults(): void 'joinColumns' => [['name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], 'inverseJoinColumns' => [['name' => 'cmsgroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], ], - $assoc['joinTable'] + $assoc['joinTable'], ); self::assertTrue($assoc['isOnDeleteCascade']); } @@ -229,7 +227,7 @@ public function testSerializeManyToManyJoinTableCascade(): void [ 'fieldName' => 'groups', 'targetEntity' => 'CmsGroup', - ] + ], ); $assoc = $cm->associationMappings['groups']; @@ -238,9 +236,7 @@ public function testSerializeManyToManyJoinTableCascade(): void self::assertTrue($assoc['isOnDeleteCascade']); } - /** - * @group DDC-115 - */ + /** @group DDC-115 */ public function testSetDiscriminatorMapInGlobalNamespace(): void { require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; @@ -253,9 +249,7 @@ public function testSetDiscriminatorMapInGlobalNamespace(): void self::assertEquals('DoctrineGlobalUser', $cm->discriminatorMap['foo']); } - /** - * @group DDC-115 - */ + /** @group DDC-115 */ public function testSetSubClassesInGlobalNamespace(): void { require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; @@ -267,9 +261,7 @@ public function testSetSubClassesInGlobalNamespace(): void self::assertEquals('DoctrineGlobalArticle', $cm->subClasses[0]); } - /** - * @group DDC-268 - */ + /** @group DDC-268 */ public function testSetInvalidVersionMappingThrowsException(): void { $field = []; @@ -370,9 +362,7 @@ public function testDuplicateFieldAndAssociationMapping2ThrowsException(): void $cm->mapField(['fieldName' => 'name', 'columnName' => 'name']); } - /** - * @group DDC-1224 - */ + /** @group DDC-1224 */ public function testGetTemporaryTableNameSchema(): void { $cm = new ClassMetadata(CmsUser::class); @@ -407,7 +397,7 @@ public function testDefaultTableName(): void 'joinColumns' => [['referencedColumnName' => 'id']], 'inverseJoinColumns' => [['referencedColumnName' => 'id']], ], - ] + ], ); self::assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']); } @@ -424,7 +414,7 @@ public function testDefaultJoinColumnName(): void 'fieldName' => 'user', 'targetEntity' => 'CmsUser', 'joinColumns' => [['referencedColumnName' => 'id']], - ] + ], ); self::assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); @@ -440,15 +430,13 @@ public function testDefaultJoinColumnName(): void 'joinColumns' => [['referencedColumnName' => 'id']], 'inverseJoinColumns' => [['referencedColumnName' => 'id']], ], - ] + ], ); self::assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']); self::assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); } - /** - * @group DDC-559 - */ + /** @group DDC-559 */ public function testUnderscoreNamingStrategyDefaults(): void { $namingStrategy = new UnderscoreNamingStrategy(CASE_UPPER); @@ -459,14 +447,14 @@ public function testUnderscoreNamingStrategyDefaults(): void [ 'fieldName' => 'user', 'targetEntity' => 'CmsUser', - ] + ], ); $manyToManyMetadata->mapManyToMany( [ 'fieldName' => 'user', 'targetEntity' => 'CmsUser', - ] + ], ); self::assertEquals(['USER_ID' => 'ID'], $oneToOneMetadata->associationMappings['user']['sourceToTargetKeyColumns']); @@ -493,9 +481,7 @@ public function testUnderscoreNamingStrategyDefaults(): void self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); } - /** - * @group DDC-886 - */ + /** @group DDC-886 */ public function testSetMultipleIdentifierSetsComposite(): void { $cm = new ClassMetadata(CmsUser::class); @@ -508,9 +494,7 @@ public function testSetMultipleIdentifierSetsComposite(): void self::assertTrue($cm->isIdentifierComposite); } - /** - * @group DDC-944 - */ + /** @group DDC-944 */ public function testMappingNotFound(): void { $cm = new ClassMetadata(CmsUser::class); @@ -522,9 +506,7 @@ public function testMappingNotFound(): void $cm->getFieldMapping('foo'); } - /** - * @group DDC-961 - */ + /** @group DDC-961 */ public function testJoinTableMappingDefaults(): void { $cm = new ClassMetadata('DoctrineGlobalArticle'); @@ -535,9 +517,7 @@ public function testJoinTableMappingDefaults(): void self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']['joinTable']['name']); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testMapIdentifierAssociation(): void { $cm = new ClassMetadata(DDC117ArticleDetails::class); @@ -549,16 +529,14 @@ public function testMapIdentifierAssociation(): void 'id' => true, 'targetEntity' => DDC117Article::class, 'joinColumns' => [], - ] + ], ); self::assertTrue($cm->containsForeignIdentifier, "Identifier Association should set 'containsForeignIdentifier' boolean flag."); self::assertEquals(['article'], $cm->identifier); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testOrphanRemovalIdentifierAssociation(): void { $cm = new ClassMetadata(DDC117ArticleDetails::class); @@ -574,13 +552,11 @@ public function testOrphanRemovalIdentifierAssociation(): void 'targetEntity' => DDC117Article::class, 'orphanRemoval' => true, 'joinColumns' => [], - ] + ], ); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testInverseIdentifierAssociation(): void { $cm = new ClassMetadata(DDC117ArticleDetails::class); @@ -596,13 +572,11 @@ public function testInverseIdentifierAssociation(): void 'mappedBy' => 'details', // INVERSE! 'targetEntity' => DDC117Article::class, 'joinColumns' => [], - ] + ], ); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testIdentifierAssociationManyToMany(): void { $cm = new ClassMetadata(DDC117ArticleDetails::class); @@ -617,13 +591,11 @@ public function testIdentifierAssociationManyToMany(): void 'id' => true, 'targetEntity' => DDC117Article::class, 'joinColumns' => [], - ] + ], ); } - /** - * @group DDC-996 - */ + /** @group DDC-996 */ public function testEmptyFieldNameThrowsException(): void { $this->expectException(MappingException::class); @@ -635,9 +607,7 @@ public function testEmptyFieldNameThrowsException(): void $cm->mapField(['fieldName' => '']); } - /** - * @group DDC-1663 - */ + /** @group DDC-1663 */ public function testRetrievalOfResultSetMappings(): void { $cm = new ClassMetadata(CmsUser::class); @@ -653,15 +623,13 @@ public function testRetrievalOfResultSetMappings(): void 'entityClass' => CmsUser::class, ], ], - ] + ], ); self::assertCount(1, $cm->getSqlResultSetMappings()); } - /** - * @group DDC-1663 - */ + /** @group DDC-1663 */ public function testRetrieveOfSqlResultSetMapping(): void { $cm = new ClassMetadata(CmsUser::class); @@ -701,7 +669,7 @@ public function testRetrieveOfSqlResultSetMapping(): void 'columns' => [ ['name' => 'scalarColumn'], ], - ] + ], ); $mapping = $cm->getSqlResultSetMapping('find-all'); @@ -717,9 +685,7 @@ public function testRetrieveOfSqlResultSetMapping(): void self::assertEquals('scalarColumn', $mapping['columns'][0]['name']); } - /** - * @group DDC-2451 - */ + /** @group DDC-2451 */ public function testSerializeEntityListeners(): void { $metadata = new ClassMetadata(CompanyContract::class); @@ -734,9 +700,7 @@ public function testSerializeEntityListeners(): void self::assertEquals($metadata->entityListeners, $unserialize->entityListeners); } - /** - * @group DDC-1663 - */ + /** @group DDC-1663 */ public function testNamingCollisionSqlResultSetMappingShouldThrowException(): void { $this->expectException(MappingException::class); @@ -752,7 +716,7 @@ public function testNamingCollisionSqlResultSetMappingShouldThrowException(): vo 'entityClass' => CmsUser::class, ], ], - ] + ], ); $cm->addSqlResultSetMapping( @@ -763,13 +727,11 @@ public function testNamingCollisionSqlResultSetMappingShouldThrowException(): vo 'entityClass' => CmsUser::class, ], ], - ] + ], ); } - /** - * @group DDC-1068 - */ + /** @group DDC-1068 */ public function testClassCaseSensitivity(): void { $user = new CmsUser(); @@ -779,9 +741,7 @@ public function testClassCaseSensitivity(): void self::assertEquals(CmsUser::class, $cm->name); } - /** - * @group DDC-659 - */ + /** @group DDC-659 */ public function testLifecycleCallbackNotFound(): void { $cm = new ClassMetadata(CmsUser::class); @@ -794,9 +754,7 @@ public function testLifecycleCallbackNotFound(): void $cm->validateLifecycleCallbacks(new RuntimeReflectionService()); } - /** - * @group ImproveErrorMessages - */ + /** @group ImproveErrorMessages */ public function testTargetEntityNotFound(): void { $cm = new ClassMetadata(CmsUser::class); @@ -809,9 +767,7 @@ public function testTargetEntityNotFound(): void $cm->validateAssociations(); } - /** - * @group DDC-1663 - */ + /** @group DDC-1663 */ public function testNameIsMandatoryForEntityNameSqlResultSetMappingException(): void { $this->expectException(MappingException::class); @@ -826,7 +782,7 @@ public function testNameIsMandatoryForEntityNameSqlResultSetMappingException(): 'fields' => [], ], ], - ] + ], ); } @@ -859,14 +815,14 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void [ 'fieldName' => 'user', 'targetEntity' => 'CmsUser', - ] + ], ); $articleMetadata->mapManyToMany( [ 'fieldName' => 'author', 'targetEntity' => CmsUser::class, - ] + ], ); self::assertEquals('routing_routingleg', $routingMetadata->table['name']); @@ -894,9 +850,7 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategyProperty ]); } - /** - * @group DDC-1746 - */ + /** @group DDC-1746 */ public function testInvalidCascade(): void { $cm = new ClassMetadata(CmsUser::class); @@ -953,9 +907,7 @@ public function testInvalidOverrideAttributeFieldTypeException(): void $cm->setAttributeOverride('name', ['type' => 'date']); } - /** - * @group DDC-1955 - */ + /** @group DDC-1955 */ public function testInvalidEntityListenerClassException(): void { $this->expectException(MappingException::class); @@ -966,9 +918,7 @@ public function testInvalidEntityListenerClassException(): void $cm->addEntityListener(Events::postLoad, '\InvalidClassName', 'postLoadHandler'); } - /** - * @group DDC-1955 - */ + /** @group DDC-1955 */ public function testInvalidEntityListenerMethodException(): void { $this->expectException(MappingException::class); @@ -987,7 +937,7 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void [ 'fieldName' => 'friendsWithMe', 'targetEntity' => 'CustomTypeParent', - ] + ], ); self::assertEquals( @@ -996,16 +946,14 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void 'joinColumns' => [['name' => 'customtypeparent_source', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], 'inverseJoinColumns' => [['name' => 'customtypeparent_target', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], ], - $cm->associationMappings['friendsWithMe']['joinTable'] + $cm->associationMappings['friendsWithMe']['joinTable'], ); self::assertEquals(['customtypeparent_source', 'customtypeparent_target'], $cm->associationMappings['friendsWithMe']['joinTableColumns']); self::assertEquals(['customtypeparent_source' => 'id'], $cm->associationMappings['friendsWithMe']['relationToSourceKeyColumns']); self::assertEquals(['customtypeparent_target' => 'id'], $cm->associationMappings['friendsWithMe']['relationToTargetKeyColumns']); } - /** - * @group DDC-2608 - */ + /** @group DDC-2608 */ public function testSetSequenceGeneratorThrowsExceptionWhenSequenceNameIsMissing(): void { $cm = new ClassMetadata(CmsUser::class); @@ -1028,13 +976,11 @@ public function testQuotedSequenceName(): void self::assertSame( ['sequenceName' => 'foo', 'quoted' => true, 'allocationSize' => '1', 'initialValue' => '1'], - $cm->sequenceGeneratorDefinition + $cm->sequenceGeneratorDefinition, ); } - /** - * @group DDC-2700 - */ + /** @group DDC-2700 */ public function testIsIdentifierMappedSuperClass(): void { $class = new ClassMetadata(DDC2700MappedSuperClass::class); @@ -1042,9 +988,7 @@ public function testIsIdentifierMappedSuperClass(): void self::assertFalse($class->isIdentifier('foo')); } - /** - * @group DDC-3120 - */ + /** @group DDC-3120 */ public function testCanInstantiateInternalPhpClassSubclass(): void { $classMetadata = new ClassMetadata(MyArrayObjectEntity::class); @@ -1052,9 +996,7 @@ public function testCanInstantiateInternalPhpClassSubclass(): void self::assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); } - /** - * @group DDC-3120 - */ + /** @group DDC-3120 */ public function testCanInstantiateInternalPhpClassSubclassFromUnserializedMetadata(): void { $classMetadata = unserialize(serialize(new ClassMetadata(MyArrayObjectEntity::class))); @@ -1074,7 +1016,7 @@ public function testWakeupReflectionWithEmbeddableAndStaticReflectionService(): 'fieldName' => 'test', 'class' => TestEntity1::class, 'columnPrefix' => false, - ] + ], ); $field = [ @@ -1103,9 +1045,7 @@ public function testGetColumnNamesWithGivenFieldNames(): void self::assertSame(['foo', 'baz'], $metadata->getColumnNames(['status', 'name'])); } - /** - * @group DDC-6460 - */ + /** @group DDC-6460 */ public function testInlineEmbeddable(): void { $classMetadata = new ClassMetadata(TestEntity1::class); @@ -1115,16 +1055,14 @@ public function testInlineEmbeddable(): void 'fieldName' => 'test', 'class' => TestEntity1::class, 'columnPrefix' => false, - ] + ], ); self::assertTrue($classMetadata->hasField('test')); } } -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ class DDC2700MappedSuperClass { /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php index f42857f3cc6..ff40bf05f58 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php @@ -30,7 +30,7 @@ public function testGetJoinTableName(): void self::assertSame( 'readers.author_reader', - $strategy->getJoinTableName($metadata->associationMappings['readers'], $metadata, $platform) + $strategy->getJoinTableName($metadata->associationMappings['readers'], $metadata, $platform), ); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index 64af718f92a..2d5195bf44e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -10,9 +10,7 @@ use Doctrine\Tests\OrmTestCase; use InvalidArgumentException; -/** - * @group DDC-1955 - */ +/** @group DDC-1955 */ class EntityListenerResolverTest extends OrmTestCase { private DefaultEntityListenerResolver $resolver; diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 3c73c12e8a3..ac0c5766319 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -81,9 +81,7 @@ abstract class MappingDriverTestCase extends OrmTestCase { abstract protected function loadDriver(): MappingDriver; - /** - * @psalm-param class-string $entityClassName - */ + /** @psalm-param class-string $entityClassName */ public function createClassMetadata(string $entityClassName): ClassMetadata { $mappingDriver = $this->loadDriver(); @@ -95,7 +93,7 @@ public function createClassMetadata(string $entityClassName): ClassMetadata return $class; } - protected function createClassMetadataFactory(?EntityManagerInterface $em = null): ClassMetadataFactory + protected function createClassMetadataFactory(EntityManagerInterface|null $em = null): ClassMetadataFactory { $driver = $this->loadDriver(); $em ??= $this->getTestEntityManager(); @@ -116,9 +114,7 @@ public function testEntityTableNameAndInheritance(): ClassMetadata return $class; } - /** - * @depends testEntityTableNameAndInheritance - */ + /** @depends testEntityTableNameAndInheritance */ public function testEntityIndexes(ClassMetadata $class): ClassMetadata { self::assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.'); @@ -128,7 +124,7 @@ public function testEntityIndexes(ClassMetadata $class): ClassMetadata 0 => ['columns' => ['user_email']], 'fields' => ['fields' => ['name', 'email']], ], - $class->table['indexes'] + $class->table['indexes'], ); return $class; @@ -152,19 +148,17 @@ public function testEntityIndexFlagsAndPartialIndexes(): void 'options' => ['where' => 'content IS NOT NULL'], ], ], - $class->table['indexes'] + $class->table['indexes'], ); } - /** - * @depends testEntityTableNameAndInheritance - */ + /** @depends testEntityTableNameAndInheritance */ public function testEntityUniqueConstraints(ClassMetadata $class): ClassMetadata { self::assertArrayHasKey( 'uniqueConstraints', $class->table, - 'ClassMetadata should have uniqueConstraints key in table property when Unique Constraints are set.' + 'ClassMetadata should have uniqueConstraints key in table property when Unique Constraints are set.', ); self::assertEquals( @@ -172,7 +166,7 @@ public function testEntityUniqueConstraints(ClassMetadata $class): ClassMetadata 'search_idx' => ['columns' => ['name', 'user_email'], 'options' => ['where' => 'name IS NOT NULL']], 'phone_idx' => ['fields' => ['name', 'phone']], ], - $class->table['uniqueConstraints'] + $class->table['uniqueConstraints'], ); return $class; @@ -184,9 +178,7 @@ public function testEntityIncorrectUniqueContraint(): void $this->createClassMetadata(UserIncorrectUniqueConstraint::class); } - /** - * @depends testEntityTableNameAndInheritance - */ + /** @depends testEntityTableNameAndInheritance */ public function testEntityOptions(ClassMetadata $class): ClassMetadata { self::assertArrayHasKey('options', $class->table, 'ClassMetadata should have options key in table property.'); @@ -196,15 +188,13 @@ public function testEntityOptions(ClassMetadata $class): ClassMetadata 'foo' => 'bar', 'baz' => ['key' => 'val'], ], - $class->table['options'] + $class->table['options'], ); return $class; } - /** - * @depends testEntityOptions - */ + /** @depends testEntityOptions */ public function testEntitySequence(ClassMetadata $class): void { self::assertIsArray($class->sequenceGeneratorDefinition, 'No Sequence Definition set on this driver.'); @@ -214,7 +204,7 @@ public function testEntitySequence(ClassMetadata $class): void 'allocationSize' => 100, 'initialValue' => 1, ], - $class->sequenceGeneratorDefinition + $class->sequenceGeneratorDefinition, ); } @@ -225,18 +215,16 @@ public function testEntityCustomGenerator(): void self::assertEquals( ClassMetadata::GENERATOR_TYPE_CUSTOM, $class->generatorType, - 'Generator Type' + 'Generator Type', ); self::assertEquals( ['class' => stdClass::class], $class->customGeneratorDefinition, - 'Custom Generator Definition' + 'Custom Generator Definition', ); } - /** - * @depends testEntityTableNameAndInheritance - */ + /** @depends testEntityTableNameAndInheritance */ public function testFieldMappings(ClassMetadata $class): ClassMetadata { self::assertEquals(4, count($class->fieldMappings)); @@ -248,9 +236,7 @@ public function testFieldMappings(ClassMetadata $class): ClassMetadata return $class; } - /** - * @depends testFieldMappings - */ + /** @depends testFieldMappings */ public function testVersionedField(ClassMetadata $class): void { self::assertTrue($class->isVersioned); @@ -259,9 +245,7 @@ public function testVersionedField(ClassMetadata $class): void self::assertFalse(isset($class->fieldMappings['version']['version'])); } - /** - * @depends testEntityTableNameAndInheritance - */ + /** @depends testEntityTableNameAndInheritance */ public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadata { self::assertEquals('id', $class->fieldMappings['id']['columnName']); @@ -271,9 +255,7 @@ public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadat return $class; } - /** - * @depends testEntityTableNameAndInheritance - */ + /** @depends testEntityTableNameAndInheritance */ public function testStringFieldMappings(ClassMetadata $class): ClassMetadata { self::assertEquals('string', $class->fieldMappings['name']['type']); @@ -302,9 +284,7 @@ public function testFieldTypeFromReflection(): void self::assertEquals(Contact::class, $class->embeddedClasses['contact']['class']); } - /** - * @depends testEntityTableNameAndInheritance - */ + /** @depends testEntityTableNameAndInheritance */ public function testFieldOptions(ClassMetadata $class): ClassMetadata { $expected = ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false]; @@ -313,9 +293,7 @@ public function testFieldOptions(ClassMetadata $class): ClassMetadata return $class; } - /** - * @depends testEntityTableNameAndInheritance - */ + /** @depends testEntityTableNameAndInheritance */ public function testIdFieldOptions(ClassMetadata $class): ClassMetadata { self::assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']['options']); @@ -323,9 +301,7 @@ public function testIdFieldOptions(ClassMetadata $class): ClassMetadata return $class; } - /** - * @depends testFieldMappings - */ + /** @depends testFieldMappings */ public function testIdentifier(ClassMetadata $class): ClassMetadata { self::assertEquals(['id'], $class->identifier); @@ -335,9 +311,7 @@ public function testIdentifier(ClassMetadata $class): ClassMetadata return $class; } - /** - * @group #6129 - */ + /** @group #6129 */ public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata { $class = $this->createClassMetadata(User::class); @@ -351,9 +325,7 @@ public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata return $class; } - /** - * @depends testIdentifier - */ + /** @depends testIdentifier */ public function testAssociations(ClassMetadata $class): ClassMetadata { self::assertEquals(3, count($class->associationMappings)); @@ -361,9 +333,7 @@ public function testAssociations(ClassMetadata $class): ClassMetadata return $class; } - /** - * @depends testAssociations - */ + /** @depends testAssociations */ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['address'])); @@ -379,9 +349,7 @@ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetada return $class; } - /** - * @depends testOwningOneToOneAssociation - */ + /** @depends testOwningOneToOneAssociation */ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['phonenumbers'])); @@ -399,9 +367,7 @@ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMeta return $class; } - /** - * @depends testInverseOneToManyAssociation - */ + /** @depends testInverseOneToManyAssociation */ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['groups'])); @@ -418,9 +384,7 @@ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): C return $class; } - /** - * @depends testManyToManyAssociationWithCascadeAll - */ + /** @depends testManyToManyAssociationWithCascadeAll */ public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata { self::assertCount(2, $class->lifecycleCallbacks); @@ -430,9 +394,7 @@ public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata return $class; } - /** - * @depends testManyToManyAssociationWithCascadeAll - */ + /** @depends testManyToManyAssociationWithCascadeAll */ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $class): ClassMetadata { self::assertCount(2, $class->lifecycleCallbacks['prePersist']); @@ -441,9 +403,7 @@ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $ return $class; } - /** - * @depends testLifecycleCallbacksSupportMultipleMethodNames - */ + /** @depends testLifecycleCallbacksSupportMultipleMethodNames */ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMetadata { // Non-Nullability of Join Column @@ -453,9 +413,7 @@ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMeta return $class; } - /** - * @depends testJoinColumnUniqueAndNullable - */ + /** @depends testJoinColumnUniqueAndNullable */ public function testColumnDefinition(ClassMetadata $class): ClassMetadata { self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); @@ -464,9 +422,7 @@ public function testColumnDefinition(ClassMetadata $class): ClassMetadata return $class; } - /** - * @depends testColumnDefinition - */ + /** @depends testColumnDefinition */ public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata { self::assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); @@ -474,9 +430,7 @@ public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata return $class; } - /** - * @group DDC-514 - */ + /** @group DDC-514 */ public function testDiscriminatorColumnDefaults(): void { if (str_contains(static::class, 'PHPMappingDriver')) { @@ -487,13 +441,11 @@ public function testDiscriminatorColumnDefaults(): void self::assertEquals( ['name' => 'discr', 'type' => 'string', 'length' => '32', 'fieldName' => 'discr', 'columnDefinition' => null], - $class->discriminatorColumn + $class->discriminatorColumn, ); } - /** - * @group DDC-869 - */ + /** @group DDC-869 */ public function testMappedSuperclassWithRepository(): void { $em = $this->getTestEntityManager(); @@ -518,9 +470,7 @@ public function testMappedSuperclassWithRepository(): void self::assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); } - /** - * @group DDC-1476 - */ + /** @group DDC-1476 */ public function testDefaultFieldType(): void { $factory = $this->createClassMetadataFactory(); @@ -550,9 +500,7 @@ public function testDefaultFieldType(): void self::assertEquals(ClassMetadata::GENERATOR_TYPE_NONE, $class->generatorType); } - /** - * @group DDC-1170 - */ + /** @group DDC-1170 */ public function testIdentifierColumnDefinition(): void { $class = $this->createClassMetadata(DDC1170Entity::class); @@ -567,9 +515,7 @@ public function testIdentifierColumnDefinition(): void self::assertEquals('varchar(255) not null', strtolower($class->fieldMappings['value']['columnDefinition'])); } - /** - * @group DDC-559 - */ + /** @group DDC-559 */ public function testNamingStrategy(): void { $em = $this->getTestEntityManager(); @@ -601,9 +547,7 @@ public function testDiscriminatorColumnDefinition(): void self::assertEquals('dtype', $class->discriminatorColumn['name']); } - /** - * @group DDC-889 - */ + /** @group DDC-889 */ public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses(): void { $this->expectException(MappingException::class); @@ -612,9 +556,7 @@ public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses(): $this->createClassMetadata(DDC889Class::class); } - /** - * @group DDC-889 - */ + /** @group DDC-889 */ public function testIdentifierRequiredShouldMentionParentClasses(): void { $factory = $this->createClassMetadataFactory(); @@ -625,9 +567,7 @@ public function testIdentifierRequiredShouldMentionParentClasses(): void $factory->getMetadataFor(DDC889Entity::class); } - /** - * @group DDC-1663 - */ + /** @group DDC-1663 */ public function testSqlResultSetMapping(): void { $userMetadata = $this->createClassMetadata(CmsUser::class); @@ -840,9 +780,7 @@ public function testAttributeOverridesMapping(): void self::assertTrue($guestMetadata->fieldMappings['name']['unique']); } - /** - * @group DDC-1955 - */ + /** @group DDC-1955 */ public function testEntityListeners(): void { $em = $this->getTestEntityManager(); @@ -871,9 +809,7 @@ public function testEntityListeners(): void self::assertEquals($flexClass->entityListeners, $superClass->entityListeners); } - /** - * @group DDC-1955 - */ + /** @group DDC-1955 */ public function testEntityListenersOverride(): void { $em = $this->getTestEntityManager(); @@ -904,9 +840,7 @@ public function testEntityListenersOverride(): void self::assertEquals('prePersistHandler2', $prePersist['method']); } - /** - * @group DDC-1955 - */ + /** @group DDC-1955 */ public function testEntityListenersNamingConvention(): void { $em = $this->getTestEntityManager(); @@ -959,9 +893,7 @@ public function testEntityListenersNamingConvention(): void self::assertEquals(Events::preFlush, $preFlush['method']); } - /** - * @group DDC-2183 - */ + /** @group DDC-2183 */ public function testSecondLevelCacheMapping(): void { $em = $this->getTestEntityManager(); @@ -1092,9 +1024,7 @@ public function testUpdatableColumn(): void self::assertArrayNotHasKey('notUpdatable', $metadata->getFieldMapping('updatableContent')); } - /** - * @requires PHP 8.1 - */ + /** @requires PHP 8.1 */ public function testEnumType(): void { $metadata = $this->createClassMetadata(Card::class); @@ -1185,25 +1115,19 @@ class User #[ORM\Column(type: 'integer'), ORM\Version] public $version; - /** - * @PrePersist - */ + /** @PrePersist */ #[ORM\PrePersist] public function doStuffOnPrePersist(): void { } - /** - * @PrePersist - */ + /** @PrePersist */ #[ORM\PrePersist] public function doOtherStuffOnPrePersistToo(): void { } - /** - * @PostPersist - */ + /** @PostPersist */ #[ORM\PostPersist] public function doStuffOnPostPersist(): void { @@ -1216,7 +1140,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'name' => 'cms_users', 'options' => ['foo' => 'bar', 'baz' => ['key' => 'val']], - ] + ], ); $metadata->setChangeTrackingPolicy(ClassMetadata::CHANGETRACKING_DEFERRED_IMPLICIT); $metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist'); @@ -1229,7 +1153,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'integer', 'columnName' => 'id', 'options' => ['foo' => 'bar', 'unsigned' => false], - ] + ], ); $metadata->mapField( [ @@ -1240,7 +1164,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'nullable' => true, 'columnName' => 'name', 'options' => ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false], - ] + ], ); $metadata->mapField( [ @@ -1248,7 +1172,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'type' => 'string', 'columnName' => 'user_email', 'columnDefinition' => 'CHAR(32) NOT NULL', - ] + ], ); $mapping = ['fieldName' => 'version', 'type' => 'integer']; $metadata->setVersionMapping($mapping); @@ -1272,7 +1196,7 @@ public static function loadMetadata(ClassMetadata $metadata): void ], ], 'orphanRemoval' => false, - ] + ], ); $metadata->mapOneToMany( [ @@ -1284,7 +1208,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'orphanRemoval' => true, 'orderBy' => ['number' => 'ASC'], - ] + ], ); $metadata->mapManyToMany( [ @@ -1323,7 +1247,7 @@ public static function loadMetadata(ClassMetadata $metadata): void ], ], 'orderBy' => null, - ] + ], ); $metadata->table['uniqueConstraints'] = [ 'search_idx' => ['columns' => ['name', 'user_email'], 'options' => ['where' => 'name IS NOT NULL']], @@ -1339,7 +1263,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'sequenceName' => 'tablename_seq', 'allocationSize' => 100, 'initialValue' => 1, - ] + ], ); } } @@ -1382,20 +1306,20 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'id', 'type' => 'integer', 'columnName' => 'id', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'name', 'type' => 'string', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'email', 'type' => 'string', 'columnName' => 'user_email', - ] + ], ); $metadata->table['indexes'] = [ 'name_idx' => ['columns' => ['name'], 'fields' => ['email']], @@ -1441,20 +1365,20 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'id', 'type' => 'integer', 'columnName' => 'id', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'name', 'type' => 'string', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'email', 'type' => 'string', 'columnName' => 'user_email', - ] + ], ); $metadata->table['uniqueConstraints'] = [ 'name_idx' => ['columns' => ['name'], 'fields' => ['email']], @@ -1508,17 +1432,13 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** - * @Entity - */ +/** @Entity */ #[ORM\Entity] class DDC1170Entity { public function __construct( - /** - * @Column(columnDefinition = "VARCHAR(255) NOT NULL") - */ - #[ORM\Column(columnDefinition: 'VARCHAR(255) NOT NULL')] private ?string $value = null + /** @Column(columnDefinition = "VARCHAR(255) NOT NULL") */ + #[ORM\Column(columnDefinition: 'VARCHAR(255) NOT NULL')] private string|null $value = null, ) { } @@ -1535,7 +1455,7 @@ public function getId(): int return $this->id; } - public function getValue(): ?string + public function getValue(): string|null { return $this->value; } @@ -1547,14 +1467,14 @@ public static function loadMetadata(ClassMetadata $metadata): void 'id' => true, 'fieldName' => 'id', 'columnDefinition' => 'INT unsigned NOT NULL', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'value', 'columnDefinition' => 'VARCHAR(255) NOT NULL', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); @@ -1587,7 +1507,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->setDiscriminatorColumn( @@ -1595,7 +1515,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'name' => 'dtype', 'type' => 'string', 'columnDefinition' => "ENUM('ONE','TWO')", - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); @@ -1639,7 +1559,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'indexes' => [ ['columns' => ['content'], 'flags' => ['fulltext'], 'options' => ['where' => 'content IS NOT NULL']], ], - ] + ], ); $metadata->mapField( @@ -1652,7 +1572,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'nullable' => false, 'precision' => 0, 'columnName' => 'content', - ] + ], ); } } @@ -1684,7 +1604,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); @@ -1727,7 +1647,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); @@ -1768,14 +1688,14 @@ public static function loadMetadata(ClassMetadata $metadata): void 'id' => true, 'fieldName' => 'id', 'type' => 'integer', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'count', 'type' => 'integer', 'columnName' => '`count`', - ] + ], ); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php index 18dc5e0184e..e78dee59ffd 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php @@ -13,7 +13,7 @@ */ class JoinColumnClassNamingStrategy extends DefaultNamingStrategy { - public function joinColumnName(string $propertyName, ?string $className = null): string + public function joinColumnName(string $propertyName, string|null $className = null): string { return strtolower($this->classToTableName($className)) . '_' . $propertyName diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php index 85a027469a4..12c62cc5f10 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php @@ -13,9 +13,7 @@ use const CASE_LOWER; use const CASE_UPPER; -/** - * @group DDC-559 - */ +/** @group DDC-559 */ class NamingStrategyTest extends OrmTestCase { private static function defaultNaming(): DefaultNamingStrategy @@ -59,9 +57,7 @@ public static function dataClassToTableName(): array ]; } - /** - * @dataProvider dataClassToTableName - */ + /** @dataProvider dataClassToTableName */ public function testClassToTableName(NamingStrategy $strategy, string $expected, string $className): void { self::assertSame($expected, $strategy->classToTableName($className)); @@ -94,14 +90,12 @@ public static function dataPropertyToColumnName(): array ]; } - /** - * @dataProvider dataPropertyToColumnName - */ + /** @dataProvider dataPropertyToColumnName */ public function testPropertyToColumnName( NamingStrategy $strategy, string $expected, string $propertyName, - string $className + string $className, ): void { self::assertSame($expected, $strategy->propertyToColumnName($propertyName, $className)); } @@ -123,9 +117,7 @@ public static function dataReferenceColumnName(): array ]; } - /** - * @dataProvider dataReferenceColumnName - */ + /** @dataProvider dataReferenceColumnName */ public function testReferenceColumnName(NamingStrategy $strategy, string $expected): void { self::assertSame($expected, $strategy->referenceColumnName()); @@ -159,14 +151,12 @@ public static function dataJoinColumnName(): array ]; } - /** - * @dataProvider dataJoinColumnName - */ + /** @dataProvider dataJoinColumnName */ public function testJoinColumnName( UnderscoreNamingStrategy|DefaultNamingStrategy $strategy, string $expected, string $propertyName, - ?string $className = null + string|null $className = null, ): void { self::assertSame($expected, $strategy->joinColumnName($propertyName, $className)); } @@ -196,15 +186,13 @@ public static function dataJoinTableName(): array ]; } - /** - * @dataProvider dataJoinTableName - */ + /** @dataProvider dataJoinTableName */ public function testJoinTableName( NamingStrategy $strategy, string $expected, string $ownerEntity, string $associatedEntity, - string $propertyName + string $propertyName, ): void { self::assertSame($expected, $strategy->joinTableName($ownerEntity, $associatedEntity, $propertyName)); } @@ -233,14 +221,12 @@ public static function dataJoinKeyColumnName(): array ]; } - /** - * @dataProvider dataJoinKeyColumnName - */ + /** @dataProvider dataJoinKeyColumnName */ public function testJoinKeyColumnName( NamingStrategy $strategy, string $expected, string $propertyEntityName, - ?string $referencedColumnName = null + string|null $referencedColumnName = null, ): void { self::assertSame($expected, $strategy->joinKeyColumnName($propertyEntityName, $referencedColumnName)); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php index 58a1654e1af..c410e727479 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php @@ -15,9 +15,7 @@ use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails; use Doctrine\Tests\OrmTestCase; -/** - * @group DDC-1845 - */ +/** @group DDC-1845 */ class QuoteStrategyTest extends OrmTestCase { private DefaultQuoteStrategy $strategy; @@ -87,7 +85,7 @@ public function testJoinTableName(): void 'targetEntity' => 'CmsUser', 'inversedBy' => 'users', 'joinTable' => ['name' => '`cmsaddress_cmsuser`'], - ] + ], ); $cm2->mapManyToMany( @@ -96,7 +94,7 @@ public function testJoinTableName(): void 'targetEntity' => 'CmsUser', 'inversedBy' => 'users', 'joinTable' => ['name' => 'cmsaddress_cmsuser'], - ] + ], ); self::assertEquals('"cmsaddress_cmsuser"', $this->strategy->getJoinTableName($cm1->associationMappings['user'], $cm1, $this->platform)); @@ -113,7 +111,7 @@ public function testIdentifierColumnNames(): void 'id' => true, 'fieldName' => 'id', 'columnName' => '`id`', - ] + ], ); $cm2->mapField( @@ -121,7 +119,7 @@ public function testIdentifierColumnNames(): void 'id' => true, 'fieldName' => 'id', 'columnName' => 'id', - ] + ], ); self::assertEquals(['"id"'], $this->strategy->getIdentifierColumnNames($cm1, $this->platform)); @@ -149,7 +147,7 @@ public function testQuoteIdentifierJoinColumns(): void 'joinColumns' => [ ['name' => '`article`'], ], - ] + ], ); self::assertEquals(['"article"'], $this->strategy->getIdentifierColumnNames($cm, $this->platform)); @@ -167,7 +165,7 @@ public function testJoinColumnName(): void 'joinColumns' => [ ['name' => '`article`'], ], - ] + ], ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; @@ -186,7 +184,7 @@ public function testReferencedJoinColumnName(): void 'joinColumns' => [ ['name' => '`article`'], ], - ] + ], ); $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php index 07ffb89463c..066d2d161c7 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php @@ -30,7 +30,7 @@ class ReflectionEmbeddedPropertyTest extends TestCase public function testCanSetAndGetEmbeddedProperty( ReflectionProperty $parentProperty, ReflectionProperty $childProperty, - string $embeddableClass + string $embeddableClass, ): void { $embeddedPropertyReflection = new ReflectionEmbeddedProperty($parentProperty, $childProperty, $embeddableClass); @@ -57,14 +57,14 @@ public function testCanSetAndGetEmbeddedProperty( public function testWillSkipReadingPropertiesFromNullEmbeddable( ReflectionProperty $parentProperty, ReflectionProperty $childProperty, - string $embeddableClass + string $embeddableClass, ): void { $embeddedPropertyReflection = new ReflectionEmbeddedProperty($parentProperty, $childProperty, $embeddableClass); $instantiator = new Instantiator(); self::assertNull($embeddedPropertyReflection->getValue( - $instantiator->instantiate($parentProperty->getDeclaringClass()->getName()) + $instantiator->instantiate($parentProperty->getDeclaringClass()->getName()), )); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php index aa3e77444de..976740867ad 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php @@ -12,9 +12,7 @@ use PHPUnit\Framework\TestCase; use ReflectionProperty; -/** - * @requires PHP 8.1 - */ +/** @requires PHP 8.1 */ class ReflectionReadonlyPropertyTest extends TestCase { public function testSecondWriteWithSameValue(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php index 8fc417e8fbc..b563fa18462 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php @@ -16,9 +16,7 @@ use function touch; use function unlink; -/** - * @group DDC-1418 - */ +/** @group DDC-1418 */ abstract class DriverTestCase extends TestCase { private string $dir; @@ -29,7 +27,7 @@ public function testFindMappingFile(): void [ 'MyNamespace\MySubnamespace\EntityFoo' => 'foo', 'MyNamespace\MySubnamespace\Entity' => $this->dir, - ] + ], ); touch($filename = $this->dir . '/Foo' . $this->getFileExtension()); @@ -41,7 +39,7 @@ public function testFindMappingFileInSubnamespace(): void $driver = $this->getDriver( [ 'MyNamespace\MySubnamespace\Entity' => $this->dir, - ] + ], ); touch($filename = $this->dir . '/Foo.Bar' . $this->getFileExtension()); @@ -56,7 +54,7 @@ public function testFindMappingFileNamespacedFoundFileNotFound(): void $driver = $this->getDriver( [ 'MyNamespace\MySubnamespace\Entity' => $this->dir, - ] + ], ); $driver->getLocator()->findMappingFile('MyNamespace\MySubnamespace\Entity\Foo'); @@ -70,7 +68,7 @@ public function testFindMappingNamespaceNotFound(): void $driver = $this->getDriver( [ 'MyNamespace\MySubnamespace\Entity' => $this->dir, - ] + ], ); $driver->getLocator()->findMappingFile('MyOtherNamespace\MySubnamespace\Entity\Foo'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php index 7d8ea716792..93c07f58378 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php @@ -9,9 +9,7 @@ use function array_flip; -/** - * @group DDC-1418 - */ +/** @group DDC-1418 */ class XmlDriverTest extends DriverTestCase { protected function getFileExtension(): string diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index c167a5b0cd0..7a08a86228c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -36,7 +36,7 @@ protected function loadDriver(): MappingDriver return new XmlDriver( __DIR__ . DIRECTORY_SEPARATOR . 'xml', XmlDriver::DEFAULT_FILE_EXTENSION, - true + true, ); } @@ -109,7 +109,7 @@ public function testEmbeddedMappingsWithUseColumnPrefix(): void self::assertEquals( '__prefix__', $factory->getMetadataFor(DDC3293UserPrefixed::class) - ->embeddedClasses['address']['columnPrefix'] + ->embeddedClasses['address']['columnPrefix'], ); } @@ -128,7 +128,7 @@ public function testEmbeddedMappingsWithFalseUseColumnPrefix(): void self::assertFalse( $factory->getMetadataFor(DDC3293User::class) - ->embeddedClasses['address']['columnPrefix'] + ->embeddedClasses['address']['columnPrefix'], ); } @@ -145,13 +145,11 @@ public function testEmbeddedMapping(): void 'originalField' => null, ], ], - $class->embeddedClasses + $class->embeddedClasses, ); } - /** - * @group DDC-1468 - */ + /** @group DDC-1468 */ public function testItMentionsFilenameAndEntityNameOnInvalidMapping(): void { $this->expectException(PersistenceMappingException::class); @@ -167,7 +165,7 @@ public function testValidateXmlSchema( string $class, string $tableName, array $fieldNames, - array $associationNames + array $associationNames, ): void { $metadata = $this->createClassMetadata($class); @@ -177,9 +175,7 @@ public function testValidateXmlSchema( $this->assertEquals($metadata->getAssociationNames(), $associationNames); } - /** - * @psalm-return []array{0: class-string, 1: string, 2: list, 3: list} - */ + /** @psalm-return []array{0: class-string, 1: string, 2: list, 3: list} */ public static function dataValidSchema(): array { return [ @@ -223,9 +219,7 @@ public function testValidateIncorrectXmlSchema(string $class, array $expectedExc } } - /** - * @return non-empty-list}> - */ + /** @return non-empty-list}> */ public static function dataInvalidSchema(): array { return [ @@ -248,9 +242,7 @@ public static function dataInvalidSchema(): array ]; } - /** - * @group GH-7141 - */ + /** @group GH-7141 */ public function testOneToManyDefaultOrderByAsc(): void { $driver = $this->loadDriver(); @@ -261,7 +253,7 @@ public function testOneToManyDefaultOrderByAsc(): void self::assertEquals( Criteria::ASC, - $class->getMetadataValue('associationMappings')['tags']['orderBy']['position'] + $class->getMetadataValue('associationMappings')['tags']['orderBy']['position'], ); } @@ -275,13 +267,11 @@ public function testManyToManyDefaultOrderByAsc(): void self::assertEquals( Criteria::ASC, - $class->getMetadataValue('associationMappings')['tags']['orderBy']['position'] + $class->getMetadataValue('associationMappings')['tags']['orderBy']['position'], ); } - /** - * @group DDC-889 - */ + /** @group DDC-889 */ public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses(): void { $this->expectException(MappingException::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php index fd0eca82a85..0fad421c746 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php +++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php @@ -9,12 +9,12 @@ 'id' => true, 'fieldName' => 'id', 'type' => 'integer', - ] + ], ); $metadata->mapField( [ 'fieldName' => 'suit', 'type' => 'string', 'enumType' => Suit::class, - ] + ], ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php index 42be971a2de..c45c91afcc2 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php +++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php @@ -5,14 +5,14 @@ use Doctrine\ORM\Mapping\ClassMetadata; $metadata->setPrimaryTable( - ['name' => 'insertable_column'] + ['name' => 'insertable_column'], ); $metadata->mapField( [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); @@ -22,8 +22,8 @@ 'notInsertable' => true, 'options' => ['default' => '1234'], 'generated' => ClassMetadata::GENERATED_INSERT, - ] + ], ); $metadata->mapField( - ['fieldName' => 'insertableContent'] + ['fieldName' => 'insertableContent'], ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php index 7a5746abda4..75ecb8efb44 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php +++ b/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php @@ -5,14 +5,14 @@ use Doctrine\ORM\Mapping\ClassMetadata; $metadata->setPrimaryTable( - ['name' => 'updatable_column'] + ['name' => 'updatable_column'], ); $metadata->mapField( [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); @@ -21,8 +21,8 @@ 'fieldName' => 'nonUpdatableContent', 'notUpdatable' => true, 'generated' => ClassMetadata::GENERATED_ALWAYS, - ] + ], ); $metadata->mapField( - ['fieldName' => 'updatableContent'] + ['fieldName' => 'updatableContent'], ); diff --git a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php index bd65e60edcb..0ce66f9a507 100644 --- a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php @@ -12,14 +12,10 @@ use function spl_object_id; use function uniqid; -/** - * @covers \Doctrine\ORM\ORMInvalidArgumentException - */ +/** @covers \Doctrine\ORM\ORMInvalidArgumentException */ class ORMInvalidArgumentExceptionTest extends TestCase { - /** - * @psalm-return list - */ + /** @psalm-return list */ public function invalidEntityNames(): array { return [ @@ -31,9 +27,7 @@ public function invalidEntityNames(): array ]; } - /** - * @dataProvider newEntitiesFoundThroughRelationshipsErrorMessages - */ + /** @dataProvider newEntitiesFoundThroughRelationshipsErrorMessages */ public function testNewEntitiesFoundThroughRelationships(array $newEntities, string $expectedMessage): void { $exception = ORMInvalidArgumentException::newEntitiesFoundThroughRelationships($newEntities); diff --git a/tests/Doctrine/Tests/ORM/ORMSetupTest.php b/tests/Doctrine/Tests/ORM/ORMSetupTest.php index 6fbd103a54b..0a246f46de6 100644 --- a/tests/Doctrine/Tests/ORM/ORMSetupTest.php +++ b/tests/Doctrine/Tests/ORM/ORMSetupTest.php @@ -40,7 +40,7 @@ public function testNewDefaultAnnotationDriver(): void $reader = $annotationDriver->getReader(); $annotation = $reader->getMethodAnnotation( $reflectionClass->getMethod('namespacedAnnotationMethod'), - AnnotationNamespace\PrePersist::class + AnnotationNamespace\PrePersist::class, ); self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); } @@ -63,9 +63,7 @@ public function testXMLConfiguration(): void self::assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); } - /** - * @requires extension apcu - */ + /** @requires extension apcu */ public function testCacheNamespaceShouldBeGeneratedForApcu(): void { $config = ORMSetup::createConfiguration(false, '/foo'); @@ -78,18 +76,14 @@ public function testCacheNamespaceShouldBeGeneratedForApcu(): void self::assertSame('dc2_1effb2475fcfba4f9e8b8a1dbc8f3caf:', $namespaceProperty->getValue($cache)); } - /** - * @group DDC-1350 - */ + /** @group DDC-1350 */ public function testConfigureProxyDir(): void { $config = ORMSetup::createAnnotationMetadataConfiguration([], true, '/foo'); self::assertEquals('/foo', $config->getProxyDir()); } - /** - * @group DDC-1350 - */ + /** @group DDC-1350 */ public function testConfigureCache(): void { $cache = new ArrayAdapter(); @@ -100,9 +94,7 @@ public function testConfigureCache(): void self::assertSame($cache, $config->getMetadataCache()); } - /** - * @group DDC-3190 - */ + /** @group DDC-3190 */ public function testConfigureCacheCustomInstance(): void { $cache = new ArrayAdapter(); diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index 45733f148bd..792027e3604 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -98,9 +98,7 @@ public function testNextInitializesCollection(): void self::assertTrue($this->collection->isInitialized()); } - /** - * @group DDC-3382 - */ + /** @group DDC-3382 */ public function testNonObjects(): void { self::assertEmpty($this->collection); @@ -120,9 +118,7 @@ public function testNonObjects(): void self::assertNull($this->collection->get(3)); } - /** - * @group 6110 - */ + /** @group 6110 */ public function testRemovingElementsAlsoRemovesKeys(): void { $dummy = new stdClass(); @@ -134,9 +130,7 @@ public function testRemovingElementsAlsoRemovesKeys(): void self::assertEquals([], array_keys($this->collection->toArray())); } - /** - * @group 6110 - */ + /** @group 6110 */ public function testClearWillAlsoClearKeys(): void { $this->collection->add(new stdClass()); @@ -144,9 +138,7 @@ public function testClearWillAlsoClearKeys(): void self::assertEquals([], array_keys($this->collection->toArray())); } - /** - * @group 6110 - */ + /** @group 6110 */ public function testClearWillAlsoResetKeyPositions(): void { $dummy = new stdClass(); @@ -221,7 +213,7 @@ public function testWillDeDuplicateNewItemsThatWerePreviouslyPersistedInDirtyCol ->with($this->collection) ->willReturnCallback(static function (PersistentCollection $persistentCollection) use ( $persistedElement, - $newElementThatIsAlsoPersisted + $newElementThatIsAlsoPersisted, ): void { $persistentCollection->unwrap()->add($newElementThatIsAlsoPersisted); $persistentCollection->unwrap()->add($persistedElement); @@ -231,7 +223,7 @@ public function testWillDeDuplicateNewItemsThatWerePreviouslyPersistedInDirtyCol self::assertSame( [$newElementThatIsAlsoPersisted, $persistedElement, $newElement], - $this->collection->toArray() + $this->collection->toArray(), ); self::assertTrue($this->collection->isInitialized()); self::assertTrue($this->collection->isDirty()); @@ -263,7 +255,7 @@ public function testWillNotMarkCollectionAsDirtyAfterInitializationIfNoElementsW ->with($this->collection) ->willReturnCallback(static function (PersistentCollection $persistentCollection) use ( $persistedElement, - $newElementThatIsAlsoPersisted + $newElementThatIsAlsoPersisted, ): void { $persistentCollection->unwrap()->add($newElementThatIsAlsoPersisted); $persistentCollection->unwrap()->add($persistedElement); @@ -273,7 +265,7 @@ public function testWillNotMarkCollectionAsDirtyAfterInitializationIfNoElementsW self::assertSame( [$newElementThatIsAlsoPersisted, $persistedElement], - $this->collection->toArray() + $this->collection->toArray(), ); self::assertTrue($this->collection->isInitialized()); self::assertFalse($this->collection->isDirty()); diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index 49eaf5f9159..ef8eaefb2c0 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -108,9 +108,7 @@ public function testGetSelectConditionSQLUsesTypeValuesSQL(): void self::assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); } - /** - * @group DDC-1719 - */ + /** @group DDC-1719 */ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): void { $persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(NonAlphaColumnsEntity::class)); @@ -120,9 +118,7 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi self::assertEquals('t0."simple-entity-id" AS simpleentityid_1, t0."simple-entity-value" AS simpleentityvalue_2', $method->invoke($persister)); } - /** - * @group DDC-2073 - */ + /** @group DDC-2073 */ public function testSelectConditionStatementIsNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::IS); @@ -141,24 +137,22 @@ public function testSelectConditionStatementNeqNull(): void self::assertEquals('test IS NOT NULL', $statement); } - /** - * @group DDC-3056 - */ + /** @group DDC-3056 */ public function testSelectConditionStatementWithMultipleValuesContainingNull(): void { self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', - $this->persister->getSelectConditionStatementSQL('id', [null]) + $this->persister->getSelectConditionStatementSQL('id', [null]), ); self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', - $this->persister->getSelectConditionStatementSQL('id', [null, 123]) + $this->persister->getSelectConditionStatementSQL('id', [null, 123]), ); self::assertEquals( '(t0.id IN (?) OR t0.id IS NULL)', - $this->persister->getSelectConditionStatementSQL('id', [123, null]) + $this->persister->getSelectConditionStatementSQL('id', [123, null]), ); } @@ -213,7 +207,7 @@ public function testDeleteManyToManyUsesTypeValuesSQL(): void 'customtype_parent_friends', ['customtypeparent_id' => 1], ['integer'], - ] + ], ); $persister->delete($parent); diff --git a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php index 11ea6b52872..5f2b55313ca 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php @@ -27,9 +27,7 @@ protected function setUp(): void $this->persister = new JoinedSubclassPersister($this->em, $this->em->getClassMetadata(RootClass::class)); } - /** - * @group DDC-3470 - */ + /** @group DDC-3470 */ public function testExecuteInsertsWillReturnEmptySetWithNoQueuedInserts(): void { self::assertSame([], $this->persister->executeInserts()); diff --git a/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php index 02046cd3149..640e79ec63c 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php @@ -13,9 +13,7 @@ use Doctrine\Tests\Models\ManyToManyPersister\ParentClass; use Doctrine\Tests\OrmTestCase; -/** - * @covers \Doctrine\ORM\Persisters\Collection\ManyToManyPersister - */ +/** @covers \Doctrine\ORM\Persisters\Collection\ManyToManyPersister */ final class ManyToManyPersisterTest extends OrmTestCase { /** diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index ab21c480f41..b12af4121f8 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -86,13 +86,11 @@ public function testSkipMappedSuperClassesOnGeneration(): void self::assertSame( 0, $this->proxyFactory->generateProxyClasses([$cm]), - 'No proxies generated.' + 'No proxies generated.', ); } - /** - * @group 6625 - */ + /** @group 6625 */ public function testSkipEmbeddableClassesOnGeneration(): void { $cm = new ClassMetadata(stdClass::class); @@ -101,13 +99,11 @@ public function testSkipEmbeddableClassesOnGeneration(): void self::assertSame( 0, $this->proxyFactory->generateProxyClasses([$cm]), - 'No proxies generated.' + 'No proxies generated.', ); } - /** - * @group DDC-1771 - */ + /** @group DDC-1771 */ public function testSkipAbstractClassesOnGeneration(): void { $cm = new ClassMetadata(AbstractClass::class); @@ -119,9 +115,7 @@ public function testSkipAbstractClassesOnGeneration(): void self::assertEquals(0, $num, 'No proxies generated.'); } - /** - * @group DDC-2432 - */ + /** @group DDC-2432 */ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void { $persister = $this->getMockBuilder(BasicEntityPersister::class) @@ -149,9 +143,7 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void self::assertInstanceOf(Closure::class, $proxy->__getCloner(), 'The cloner wasn\'t removed'); } - /** - * @group DDC-2432 - */ + /** @group DDC-2432 */ public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void { $persister = $this->getMockBuilder(BasicEntityPersister::class) diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php index f9ca3d300de..16be0ce6ff3 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php @@ -37,7 +37,7 @@ public function testAddsJoin(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.country AS country_5, c1_.zip AS zip_6, c1_.city AS city_7, c0_.email_id AS email_id_8, c1_.user_id AS user_id_9 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.country AS country_5, c1_.zip AS zip_6, c1_.city AS city_7, c0_.email_id AS email_id_8, c1_.user_id AS user_id_9 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id', ); } @@ -45,7 +45,7 @@ public function testDoesNotAddJoin(): void { $this->assertSqlGeneration( 'select a from Doctrine\Tests\Models\CMS\CmsAddress a', - 'SELECT c0_.id AS id_0, c0_.country AS country_1, c0_.zip AS zip_2, c0_.city AS city_3, c0_.user_id AS user_id_4 FROM cms_addresses c0_' + 'SELECT c0_.id AS id_0, c0_.country AS country_1, c0_.zip AS zip_2, c0_.city AS city_3, c0_.user_id AS user_id_4 FROM cms_addresses c0_', ); } } diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index 733cb23da00..8350d60ba52 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -43,7 +43,7 @@ protected function setUp(): void * @param list> $treeWalkers * @param class-string|null $outputWalker */ - public function generateSql(string $dqlToBeTested, array $treeWalkers, ?string $outputWalker): string + public function generateSql(string $dqlToBeTested, array $treeWalkers, string|null $outputWalker): string { $query = $this->entityManager->createQuery($dqlToBeTested); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $treeWalkers) @@ -64,7 +64,7 @@ public function assertSqlGeneration( string $dqlToBeTested, string $sqlToBeConfirmed, array $treeWalkers = [], - ?string $outputWalker = null + string|null $outputWalker = null, ): void { self::assertEquals($sqlToBeConfirmed, $this->generateSql($dqlToBeTested, $treeWalkers, $outputWalker)); } @@ -74,7 +74,7 @@ public function testSupportsQueriesWithoutWhere(): void $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u', 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.id = 1', - [CustomTreeWalker::class] + [CustomTreeWalker::class], ); } @@ -83,7 +83,7 @@ public function testSupportsQueriesWithMultipleConditionalExpressions(): void $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.name = :name or u.name = :otherName', 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE (c0_.name = ? OR c0_.name = ?) AND c0_.id = 1', - [CustomTreeWalker::class] + [CustomTreeWalker::class], ); } @@ -92,7 +92,7 @@ public function testSupportsQueriesWithSimpleConditionalExpression(): void $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.name = :name', 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ WHERE c0_.name = ? AND c0_.id = 1', - [CustomTreeWalker::class] + [CustomTreeWalker::class], ); } @@ -104,7 +104,7 @@ public function testSetUnknownQueryComponentThrowsException(): void $this->generateSql( 'select u from Doctrine\Tests\Models\CMS\CmsUser u', [], - AddUnknownQueryComponentWalker::class + AddUnknownQueryComponentWalker::class, ); } @@ -113,7 +113,7 @@ public function testSupportsSeveralHintsQueries(): void $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u', 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.country AS country_5, c1_.zip AS zip_6, c1_.city AS city_7, c0_.email_id AS email_id_8, c1_.user_id AS user_id_9 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c0_.id = 1', - [CustomTreeWalkerJoin::class, CustomTreeWalker::class] + [CustomTreeWalkerJoin::class, CustomTreeWalker::class], ); } } diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php index 1e954ceb294..e09d00e3b87 100644 --- a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php @@ -32,14 +32,12 @@ public function assertSqlGeneration(string $dqlToBeTested, string $sqlToBeConfir $query->free(); } - /** - * @group 6939 - */ + /** @group 6939 */ public function testSupportsDeleteWithoutWhereAndAlias(): void { $this->assertSqlGeneration( 'DELETE FROM Doctrine\Tests\Models\CMS\CmsUser', - 'DELETE FROM cms_users' + 'DELETE FROM cms_users', ); } @@ -47,7 +45,7 @@ public function testSupportsDeleteWithoutWhereAndFrom(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u', - 'DELETE FROM cms_users' + 'DELETE FROM cms_users', ); } @@ -55,7 +53,7 @@ public function testSupportsDeleteWithoutWhere(): void { $this->assertSqlGeneration( 'DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'DELETE FROM cms_users' + 'DELETE FROM cms_users', ); } @@ -63,7 +61,7 @@ public function testSupportsWhereClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', - 'DELETE FROM cms_users WHERE id = ?' + 'DELETE FROM cms_users WHERE id = ?', ); } @@ -71,7 +69,7 @@ public function testSupportsWhereOrExpressions(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 OR u.name = ?2', - 'DELETE FROM cms_users WHERE username = ? OR name = ?' + 'DELETE FROM cms_users WHERE username = ? OR name = ?', ); } @@ -79,7 +77,7 @@ public function testSupportsWhereNestedConditionalExpressions(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR ( u.username = ?2 OR u.name = ?3)', - 'DELETE FROM cms_users WHERE id = ? OR (username = ? OR name = ?)' + 'DELETE FROM cms_users WHERE id = ? OR (username = ? OR name = ?)', ); //$this->assertSqlGeneration( @@ -92,7 +90,7 @@ public function testIsCaseAgnostic(): void { $this->assertSqlGeneration( 'delete from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1', - 'DELETE FROM cms_users WHERE username = ?' + 'DELETE FROM cms_users WHERE username = ?', ); } @@ -100,7 +98,7 @@ public function testSupportsAndCondition(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 AND u.name = ?2', - 'DELETE FROM cms_users WHERE username = ? AND name = ?' + 'DELETE FROM cms_users WHERE username = ? AND name = ?', ); } @@ -108,7 +106,7 @@ public function testSupportsWhereNot(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT u.id != ?1', - 'DELETE FROM cms_users WHERE NOT id <> ?' + 'DELETE FROM cms_users WHERE NOT id <> ?', ); } @@ -116,7 +114,7 @@ public function testSupportsWhereNotWithParentheses(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 )', - 'DELETE FROM cms_users WHERE NOT (id <> ?)' + 'DELETE FROM cms_users WHERE NOT (id <> ?)', ); } @@ -124,7 +122,7 @@ public function testSupportsWhereNotWithAndExpression(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 AND u.username = ?2 )', - 'DELETE FROM cms_users WHERE NOT (id <> ? AND username = ?)' + 'DELETE FROM cms_users WHERE NOT (id <> ? AND username = ?)', ); } @@ -135,7 +133,7 @@ public function testSupportsGreaterThanComparisonClause(): void // id = ? was already tested (see testDeleteWithWhere()) $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ?1', - 'DELETE FROM cms_users WHERE id > ?' + 'DELETE FROM cms_users WHERE id > ?', ); } @@ -143,7 +141,7 @@ public function testSupportsGreaterThanOrEqualToComparisonClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id >= ?1', - 'DELETE FROM cms_users WHERE id >= ?' + 'DELETE FROM cms_users WHERE id >= ?', ); } @@ -151,7 +149,7 @@ public function testSupportsLessThanComparisonClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id < ?1', - 'DELETE FROM cms_users WHERE id < ?' + 'DELETE FROM cms_users WHERE id < ?', ); } @@ -159,7 +157,7 @@ public function testSupportsLessThanOrEqualToComparisonClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <= ?1', - 'DELETE FROM cms_users WHERE id <= ?' + 'DELETE FROM cms_users WHERE id <= ?', ); } @@ -167,7 +165,7 @@ public function testSupportsNotEqualToComparisonClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <> ?1', - 'DELETE FROM cms_users WHERE id <> ?' + 'DELETE FROM cms_users WHERE id <> ?', ); } @@ -175,7 +173,7 @@ public function testSupportsNotEqualToComparisonClauseExpressedWithExclamationMa { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id != ?1', - 'DELETE FROM cms_users WHERE id <> ?' + 'DELETE FROM cms_users WHERE id <> ?', ); } @@ -183,7 +181,7 @@ public function testSupportsNotBetweenClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT BETWEEN ?1 AND ?2', - 'DELETE FROM cms_users WHERE id NOT BETWEEN ? AND ?' + 'DELETE FROM cms_users WHERE id NOT BETWEEN ? AND ?', ); } @@ -191,7 +189,7 @@ public function testSupportsBetweenClauseUsedWithAndClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2 AND u.username != ?3', - 'DELETE FROM cms_users WHERE id BETWEEN ? AND ? AND username <> ?' + 'DELETE FROM cms_users WHERE id BETWEEN ? AND ? AND username <> ?', ); } @@ -200,7 +198,7 @@ public function testSupportsNotLikeClause(): void // "WHERE" Expression LikeExpression $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username NOT LIKE ?1', - 'DELETE FROM cms_users WHERE username NOT LIKE ?' + 'DELETE FROM cms_users WHERE username NOT LIKE ?', ); } @@ -208,7 +206,7 @@ public function testSupportsLikeClauseWithEscapeExpression(): void { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username LIKE ?1 ESCAPE '\\'", - "DELETE FROM cms_users WHERE username LIKE ? ESCAPE '\\'" + "DELETE FROM cms_users WHERE username LIKE ? ESCAPE '\\'", ); } @@ -217,7 +215,7 @@ public function testSupportsIsNullClause(): void // "WHERE" Expression NullComparisonExpression $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NULL', - 'DELETE FROM cms_users WHERE name IS NULL' + 'DELETE FROM cms_users WHERE name IS NULL', ); } @@ -225,7 +223,7 @@ public function testSupportsIsNotNullClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NOT NULL', - 'DELETE FROM cms_users WHERE name IS NOT NULL' + 'DELETE FROM cms_users WHERE name IS NOT NULL', ); } @@ -233,7 +231,7 @@ public function testSupportsAtomExpressionAsClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE 1 = 1', - 'DELETE FROM cms_users WHERE 1 = 1' + 'DELETE FROM cms_users WHERE 1 = 1', ); } @@ -241,7 +239,7 @@ public function testSupportsParameterizedAtomExpression(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE ?1 = 1', - 'DELETE FROM cms_users WHERE ? = 1' + 'DELETE FROM cms_users WHERE ? = 1', ); } @@ -249,7 +247,7 @@ public function testSupportsInClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN ( ?1, ?2, ?3, ?4 )', - 'DELETE FROM cms_users WHERE id IN (?, ?, ?, ?)' + 'DELETE FROM cms_users WHERE id IN (?, ?, ?, ?)', ); } @@ -257,18 +255,16 @@ public function testSupportsNotInClause(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN ( ?1, ?2 )', - 'DELETE FROM cms_users WHERE id NOT IN (?, ?)' + 'DELETE FROM cms_users WHERE id NOT IN (?, ?)', ); } - /** - * @group DDC-980 - */ + /** @group DDC-980 */ public function testSubselectTableAliasReferencing(): void { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) = 10', - 'DELETE FROM cms_users WHERE (SELECT COUNT(*) FROM cms_users_groups c0_ WHERE c0_.user_id = cms_users.id) = 10' + 'DELETE FROM cms_users WHERE (SELECT COUNT(*) FROM cms_users_groups c0_ WHERE c0_.user_id = cms_users.id) = 10', ); } } diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index cd6d679dfa3..19d981848fd 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -119,7 +119,7 @@ public function testIntelligentParenthesisPreventionAndExpr(): void { self::assertEquals( '1 = 1 AND 2 = 2', - (string) $this->expr->andX($this->expr->orX($this->expr->andX($this->expr->eq(1, 1))), (string) $this->expr->eq(2, 2)) + (string) $this->expr->andX($this->expr->orX($this->expr->andX($this->expr->eq(1, 1))), (string) $this->expr->eq(2, 2)), ); } @@ -308,33 +308,25 @@ public function provideLiteralIterableValue(): Generator yield 'generator' => [$gen()]; } - /** - * @dataProvider provideIterableValue - */ + /** @dataProvider provideIterableValue */ public function testInExpr(iterable $value): void { self::assertEquals('u.id IN(1, 2, 3)', (string) $this->expr->in('u.id', $value)); } - /** - * @dataProvider provideLiteralIterableValue - */ + /** @dataProvider provideLiteralIterableValue */ public function testInLiteralExpr(iterable $value): void { self::assertEquals("u.type IN('foo', 'bar')", (string) $this->expr->in('u.type', $value)); } - /** - * @dataProvider provideIterableValue - */ + /** @dataProvider provideIterableValue */ public function testNotInExpr(iterable $value): void { self::assertEquals('u.id NOT IN(1, 2, 3)', (string) $this->expr->notIn('u.id', $value)); } - /** - * @dataProvider provideLiteralIterableValue - */ + /** @dataProvider provideLiteralIterableValue */ public function testNotInLiteralExpr(iterable $value): void { self::assertEquals("u.type NOT IN('foo', 'bar')", (string) $this->expr->notIn('u.type', $value)); @@ -389,18 +381,14 @@ public function testAddThrowsException(): void $orExpr->add($this->expr->quot(5, 2)); } - /** - * @group DDC-1683 - */ + /** @group DDC-1683 */ public function testBooleanLiteral(): void { self::assertEquals('true', $this->expr->literal(true)); self::assertEquals('false', $this->expr->literal(false)); } - /** - * @group DDC-1686 - */ + /** @group DDC-1686 */ public function testExpressionGetter(): void { // Andx diff --git a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php index 0a5ee1cb9f8..e8129df6442 100644 --- a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php @@ -48,9 +48,7 @@ public function testHasFilter(): void self::assertFalse($filterCollection->has('fakeFilter')); } - /** - * @depends testEnable - */ + /** @depends testEnable */ public function testIsEnabled(): void { $filterCollection = $this->em->getFilters(); diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index 94983341196..a9ac1bcaa30 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -39,9 +39,7 @@ public function assertInvalidDQL(string $dql): void $this->parseDql($dql); } - /** - * @psalm-param array $hints - */ + /** @psalm-param array $hints */ public function parseDql(string $dql, array $hints = []): ParserResult { $query = $this->entityManager->createQuery($dql); @@ -75,9 +73,7 @@ public function testSelectSingleComponentWithAsterisk(): void $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); } - /** - * @dataProvider invalidDQL - */ + /** @dataProvider invalidDQL */ public function testRejectsInvalidDQL(string $dql): void { $this->expectException(QueryException::class); @@ -86,15 +82,13 @@ public function testRejectsInvalidDQL(string $dql): void [ 'Unknown' => 'Unknown', 'CMS' => 'Doctrine\Tests\Models\CMS', - ] + ], ); $this->parseDql($dql); } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function invalidDQL(): array { return [ @@ -264,17 +258,13 @@ public function testJoinClassPathUsingWITH(): void $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WITH a.user = u.id'); } - /** - * @group DDC-3701 - */ + /** @group DDC-3701 */ public function testJoinClassPathUsingWHERE(): void { $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = u.id'); } - /** - * @group DDC-3701 - */ + /** @group DDC-3701 */ public function testDDC3701WHEREIsNotWITH(): void { $this->assertInvalidDQL('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN Doctrine\Tests\Models\Company\CompanyEmployee e WHERE e.id = c.salesPerson WHERE c.completed = true'); @@ -325,18 +315,14 @@ public function testArithmeticExpressionWithParenthesisInSubselectPart(): void $this->assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); } - /** - * @group DDC-1079 - */ + /** @group DDC-1079 */ public function testSelectLiteralInSubselect(): void { $this->assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u'); $this->assertValidDQL('SELECT (SELECT 0 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u'); } - /** - * @group DDC-1077 - */ + /** @group DDC-1077 */ public function testConstantValueInSelect(): void { $this->assertValidDQL("SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u"); @@ -556,9 +542,7 @@ public function testInputParameterInSelect(): void $this->assertValidDQL('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u'); } - /** - * @group DDC-1091 - */ + /** @group DDC-1091 */ public function testCustomFunctionsReturningStringInStringPrimary(): void { $this->entityManager->getConfiguration()->addCustomStringFunction('CC', ConcatFunction::class); @@ -566,17 +550,13 @@ public function testCustomFunctionsReturningStringInStringPrimary(): void $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'"); } - /** - * @group DDC-505 - */ + /** @group DDC-505 */ public function testDQLKeywordInJoinIsAllowed(): void { $this->assertValidDQL('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g'); } - /** - * @group DDC-505 - */ + /** @group DDC-505 */ public function testDQLKeywordInConditionIsAllowed(): void { $this->assertValidDQL('SELECT g FROM ' . __NAMESPACE__ . '\DQLKeywordsModelGroup g WHERE g.from=0'); @@ -589,57 +569,43 @@ public function testInverseSideSingleValuedAssociationPathNotAllowed() } */ - /** - * @group DDC-617 - */ + /** @group DDC-617 */ public function testSelectOnlyNonRootEntityAlias(): void { $this->assertInvalidDQL('SELECT g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'); } - /** - * @group DDC-1108 - */ + /** @group DDC-1108 */ public function testInputParameterSingleChar(): void { $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :q'); } - /** - * @group DDC-1053 - */ + /** @group DDC-1053 */ public function testGroupBy(): void { $this->assertValidDQL('SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id'); } - /** - * @group DDC-1053 - */ + /** @group DDC-1053 */ public function testGroupByIdentificationVariable(): void { $this->assertValidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g'); } - /** - * @group DDC-1053 - */ + /** @group DDC-1053 */ public function testGroupByUnknownIdentificationVariable(): void { $this->assertInvalidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY m'); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testSizeOfForeignKeyOneToManyPrimaryKeyEntity(): void { $this->assertValidDQL('SELECT a, t FROM Doctrine\Tests\Models\DDC117\DDC117Article a JOIN a.translations t WHERE SIZE(a.translations) > 0'); } - /** - * @group DDC-117 - */ + /** @group DDC-117 */ public function testSizeOfForeignKeyManyToManyPrimaryKeyEntity(): void { $this->assertValidDQL('SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE SIZE(e.reviewingTranslations) > 0'); @@ -655,41 +621,31 @@ public function testCaseSupportContainingCoalesceExpression(): void $this->assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u"); } - /** - * @group DDC-1858 - */ + /** @group DDC-1858 */ public function testHavingSupportIsNullExpression(): void { $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL'); } - /** - * @group DDC-3085 - */ + /** @group DDC-3085 */ public function testHavingSupportResultVariableInNullComparisonExpression(): void { $this->assertValidDQL('SELECT u AS user, SUM(a.id) AS score FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN Doctrine\Tests\Models\CMS\CmsAddress a WITH a.user = u GROUP BY u HAVING score IS NOT NULL AND score >= 5'); } - /** - * @group DDC-1858 - */ + /** @group DDC-1858 */ public function testHavingSupportLikeExpression(): void { $this->assertValidDQL("SELECT _u.id, count(_articles) as uuuu FROM Doctrine\Tests\Models\CMS\CmsUser _u LEFT JOIN _u.articles _articles GROUP BY _u HAVING uuuu LIKE '3'"); } - /** - * @group DDC-3018 - */ + /** @group DDC-3018 */ public function testNewLiteralExpression(): void { $this->assertValidDQL('SELECT new ' . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', 1, true) FROM Doctrine\Tests\Models\CMS\CmsUser u"); } - /** - * @group DDC-3075 - */ + /** @group DDC-3075 */ public function testNewLiteralWithSubselectExpression(): void { $this->assertValidDQL('SELECT new ' . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser su), true) FROM Doctrine\Tests\Models\CMS\CmsUser u"); @@ -698,7 +654,7 @@ public function testNewLiteralWithSubselectExpression(): void public function testStringPrimaryAcceptsAggregateExpression(): void { $this->assertValidDQL( - 'SELECT CONCAT(a.topic, MAX(a.version)) last FROM Doctrine\Tests\Models\CMS\CmsArticle a GROUP BY a' + 'SELECT CONCAT(a.topic, MAX(a.version)) last FROM Doctrine\Tests\Models\CMS\CmsArticle a GROUP BY a', ); } } diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index 58265b14b16..c5f4a3ccf03 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -9,9 +9,7 @@ class LexerTest extends OrmTestCase { - /** - * @dataProvider provideTokens - */ + /** @dataProvider provideTokens */ public function testScannerRecognizesTokens($type, $value): void { $lexer = new Lexer($value); diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index b26e08ea825..2a2f4827faa 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -38,9 +38,7 @@ public function providerParameterTypeInferer(): Generator yield 'array_of_string_backed_enum' => [[UserStatus::Active], Connection::PARAM_STR_ARRAY]; } - /** - * @dataProvider providerParameterTypeInferer - */ + /** @dataProvider providerParameterTypeInferer */ public function testParameterTypeInferer(mixed $value, ParameterType|int|string $expected): void { self::assertEquals($expected, ParameterTypeInferer::inferType($value)); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 966a0793132..a21d97d0402 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -25,10 +25,8 @@ protected function setUp(): void $this->visitor = new QueryExpressionVisitor(['o', 'p']); } - /** - * @dataProvider comparisonData - */ - public function testWalkComparison(CriteriaComparison $criteriaExpr, QueryBuilder\Comparison|QueryBuilder\Func|string $queryExpr, ?Parameter $parameter = null): void + /** @dataProvider comparisonData */ + public function testWalkComparison(CriteriaComparison $criteriaExpr, QueryBuilder\Comparison|QueryBuilder\Func|string $queryExpr, Parameter|null $parameter = null): void { self::assertEquals($queryExpr, $this->visitor->walkComparison($criteriaExpr)); if ($parameter) { @@ -84,8 +82,8 @@ public function testWalkAndCompositeExpression(): void $expr = $this->visitor->walkCompositeExpression( $cb->andX( $cb->eq('foo', 1), - $cb->eq('bar', 1) - ) + $cb->eq('bar', 1), + ), ); self::assertInstanceOf(QueryBuilder\Andx::class, $expr); @@ -98,8 +96,8 @@ public function testWalkOrCompositeExpression(): void $expr = $this->visitor->walkCompositeExpression( $cb->orX( $cb->eq('foo', 1), - $cb->eq('bar', 1) - ) + $cb->eq('bar', 1), + ), ); self::assertInstanceOf(QueryBuilder\Orx::class, $expr); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index a384c9902f3..acc6a8bf1ec 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -139,9 +139,7 @@ public function testSettingNullFirstResultIsDeprecated(): void $q->setFirstResult(null); } - /** - * @group DDC-968 - */ + /** @group DDC-968 */ public function testHints(): void { $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); @@ -188,9 +186,7 @@ public function testIterateEmptyResult(): void self::assertTrue(true); } - /** - * @group DDC-1697 - */ + /** @group DDC-1697 */ public function testCollectionParameters(): void { $cities = [ @@ -210,9 +206,7 @@ public function testCollectionParameters(): void self::assertEquals($cities, $parameter->getValue()); } - /** - * @psalm-return Generator - */ + /** @psalm-return Generator */ public function provideProcessParameterValueIterable(): Generator { $baseArray = [ @@ -231,9 +225,7 @@ public function provideProcessParameterValueIterable(): Generator yield 'array_of_enum' => [array_map([City::class, 'from'], $baseArray)]; } - /** - * @dataProvider provideProcessParameterValueIterable - */ + /** @dataProvider provideProcessParameterValueIterable */ public function testProcessParameterValueIterable(iterable $cities): void { $query = $this->entityManager->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)'); @@ -243,7 +235,7 @@ public function testProcessParameterValueIterable(iterable $cities): void 3 => 'Cannes', 9 => 'St Julien', ], - $query->processParameterValue($cities) + $query->processParameterValue($cities), ); } @@ -256,15 +248,13 @@ public function testProcessParameterValueWithIterableEntityShouldNotBeTreatedAsI self::assertEquals(1, $query->processParameterValue($group)); } - /** - * @group DDC-2224 - */ + /** @group DDC-2224 */ public function testProcessParameterValueClassMetadata(): void { $query = $this->entityManager->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)'); self::assertEquals( CmsAddress::class, - $query->processParameterValue($this->entityManager->getClassMetadata(CmsAddress::class)) + $query->processParameterValue($this->entityManager->getClassMetadata(CmsAddress::class)), ); } @@ -276,7 +266,7 @@ public function testProcessParameterValueObject(): void self::assertSame( 12345, - $query->processParameterValue($user) + $query->processParameterValue($user), ); } @@ -300,9 +290,7 @@ public function testProcessParameterValueNull(): void self::assertNull($query->processParameterValue(null)); } - /** - * @requires PHP 8.1 - */ + /** @requires PHP 8.1 */ public function testProcessParameterValueBackedEnum(): void { $query = $this->entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.status = :status'); @@ -311,9 +299,7 @@ public function testProcessParameterValueBackedEnum(): void self::assertSame([2], $query->processParameterValue([AccessLevel::User])); } - /** - * @requires PHP 8.1 - */ + /** @requires PHP 8.1 */ public function testProcessParameterValueBackedEnumArray(): void { $query = $this->entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.status IN (:status)'); @@ -340,9 +326,7 @@ public function testDefaultQueryHints(): void self::assertSame($config->getDefaultQueryHints(), $q2->getHints()); } - /** - * @group DDC-3714 - */ + /** @group DDC-3714 */ public function testResultCacheCaching(): void { $entityManager = $this->createTestEntityManagerWithConnection( @@ -350,8 +334,8 @@ public function testResultCacheCaching(): void new ArrayResult([ ['id_0' => 1], ]), - new ArrayResult([]) - ) + new ArrayResult([]), + ), ); $entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); @@ -372,9 +356,7 @@ public function testResultCacheCaching(): void self::assertCount(0, $res); } - /** - * @group DDC-3741 - */ + /** @group DDC-3741 */ public function testSetHydrationCacheProfileNull(): void { $query = $this->entityManager->createQuery(); @@ -382,9 +364,7 @@ public function testSetHydrationCacheProfileNull(): void self::assertNull($query->getHydrationCacheProfile()); } - /** - * @group 2947 - */ + /** @group 2947 */ public function testResultCacheEviction(): void { $entityManager = $this->createTestEntityManagerWithConnection( @@ -398,8 +378,8 @@ public function testResultCacheEviction(): void ]), new ArrayResult([ ['id_0' => 1], - ]) - ) + ]), + ), ); $entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); @@ -420,9 +400,7 @@ public function testResultCacheEviction(): void self::assertCount(2, $query->expireResultCache(false)->getResult()); } - /** - * @group #6162 - */ + /** @group #6162 */ public function testSelectJoinSubquery(): void { $query = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u JOIN (SELECT )'); @@ -432,9 +410,7 @@ public function testSelectJoinSubquery(): void $query->getSQL(); } - /** - * @group #6162 - */ + /** @group #6162 */ public function testSelectFromSubquery(): void { $query = $this->entityManager->createQuery('select u from (select Doctrine\Tests\Models\CMS\CmsUser c) as u'); @@ -444,9 +420,7 @@ public function testSelectFromSubquery(): void $query->getSQL(); } - /** - * @group 6699 - */ + /** @group 6699 */ public function testGetParameterTypeJuggling(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.id = ?0'); @@ -458,9 +432,7 @@ public function testGetParameterTypeJuggling(): void self::assertSame(0, $query->getParameter('0')->getValue()); } - /** - * @group 6699 - */ + /** @group 6699 */ public function testSetParameterWithNameZeroIsNotOverridden(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.id != ?0 and u.username = :name'); @@ -473,9 +445,7 @@ public function testSetParameterWithNameZeroIsNotOverridden(): void self::assertSame('Doctrine', $query->getParameter('name')->getValue()); } - /** - * @group 6699 - */ + /** @group 6699 */ public function testSetParameterWithNameZeroDoesNotOverrideAnotherParameter(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.id != ?0 and u.username = :name'); @@ -488,9 +458,7 @@ public function testSetParameterWithNameZeroDoesNotOverrideAnotherParameter(): v self::assertSame('Doctrine', $query->getParameter('name')->getValue()); } - /** - * @group 6699 - */ + /** @group 6699 */ public function testSetParameterWithTypeJugglingWorks(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.id != ?0 and u.username = :name'); @@ -506,9 +474,7 @@ public function testSetParameterWithTypeJugglingWorks(): void self::assertSame('Doctrine', $query->getParameter('name')->getValue()); } - /** - * @group 6748 - */ + /** @group 6748 */ public function testResultCacheProfileCanBeRemovedViaSetter(): void { $this->entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); @@ -547,9 +513,7 @@ public function testNonExistentExecutor(): void $this->entityManager->createQuery('0')->execute(); } - /** - * @group 8106 - */ + /** @group 8106 */ public function testGetParameterColonNormalize(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.name = :name'); diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 9e660fffb6a..2bf55a7ba11 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -52,7 +52,7 @@ public function assertSqlGeneration( string $dqlToBeTested, string $sqlToBeConfirmed, array $queryHints = [], - array $queryParams = [] + array $queryParams = [], ): void { $query = $this->entityManager->createQuery($dqlToBeTested); @@ -72,7 +72,7 @@ public function assertSqlGeneration( parent::assertEquals( $sqlToBeConfirmed, $sqlGenerated, - sprintf('"%s" is not equal to "%s"', $sqlGenerated, $sqlToBeConfirmed) + sprintf('"%s" is not equal to "%s"', $sqlGenerated, $sqlToBeConfirmed), ); $query->free(); @@ -85,7 +85,7 @@ public function assertInvalidSqlGeneration( string $dqlToBeTested, string $expectedException, array $queryHints = [], - array $queryParams = [] + array $queryParams = [], ): void { $this->expectException($expectedException); @@ -109,21 +109,17 @@ public function assertInvalidSqlGeneration( self::fail($sql); } - /** - * @group DDC-3697 - */ + /** @group DDC-3697 */ public function testJoinWithRangeVariablePutsConditionIntoSqlWhereClause(): void { $this->assertSqlGeneration( 'SELECT c.id FROM Doctrine\Tests\Models\Company\CompanyPerson c JOIN Doctrine\Tests\Models\Company\CompanyPerson r WHERE c.spouse = r AND r.id = 42', 'SELECT c0_.id AS id_0 FROM company_persons c0_ INNER JOIN company_persons c1_ WHERE c0_.spouse_id = c1_.id AND c1_.id = 42', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } - /** - * @group DDC-3697 - */ + /** @group DDC-3697 */ public function testJoinWithRangeVariableAndInheritancePutsConditionIntoSqlWhereClause(): void { /* @@ -134,7 +130,7 @@ public function testJoinWithRangeVariableAndInheritancePutsConditionIntoSqlWhere $this->assertSqlGeneration( 'SELECT c.id FROM Doctrine\Tests\Models\Company\CompanyPerson c JOIN Doctrine\Tests\Models\Company\CompanyPerson r WHERE c.spouse = r AND r.id = 42', 'SELECT c0_.id AS id_0 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id INNER JOIN company_persons c3_ LEFT JOIN company_managers c4_ ON c3_.id = c4_.id LEFT JOIN company_employees c5_ ON c3_.id = c5_.id WHERE c0_.spouse_id = c3_.id AND c3_.id = 42', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } @@ -142,7 +138,7 @@ public function testSupportsSelectForAllFields(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_', ); } @@ -150,7 +146,7 @@ public function testSupportsSelectForOneField(): void { $this->assertSqlGeneration( 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id_0 FROM cms_users c0_' + 'SELECT c0_.id AS id_0 FROM cms_users c0_', ); } @@ -158,7 +154,7 @@ public function testSupportsSelectForOneNestedField(): void { $this->assertSqlGeneration( 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u', - 'SELECT c0_.id AS id_0 FROM cms_articles c1_ INNER JOIN cms_users c0_ ON c1_.user_id = c0_.id' + 'SELECT c0_.id AS id_0 FROM cms_articles c1_ INNER JOIN cms_users c0_ ON c1_.user_id = c0_.id', ); } @@ -166,7 +162,7 @@ public function testSupportsSelectForAllNestedField(): void { $this->assertSqlGeneration( 'SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u ORDER BY u.name ASC', - 'SELECT c0_.id AS id_0, c0_.topic AS topic_1, c0_.text AS text_2, c0_.version AS version_3 FROM cms_articles c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id ORDER BY c1_.name ASC' + 'SELECT c0_.id AS id_0, c0_.topic AS topic_1, c0_.text AS text_2, c0_.version AS version_3 FROM cms_articles c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id ORDER BY c1_.name ASC', ); } @@ -174,7 +170,7 @@ public function testNotExistsExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE NOT EXISTS (SELECT c1_.phonenumber FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = 1234)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE NOT EXISTS (SELECT c1_.phonenumber FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = 1234)', ); } @@ -182,7 +178,7 @@ public function testSupportsSelectForMultipleColumnsOfASingleComponent(): void { $this->assertSqlGeneration( 'SELECT u.username, u.name FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.username AS username_0, c0_.name AS name_1 FROM cms_users c0_' + 'SELECT c0_.username AS username_0, c0_.name AS name_1 FROM cms_users c0_', ); } @@ -190,7 +186,7 @@ public function testSupportsSelectUsingMultipleFromComponents(): void { $this->assertSqlGeneration( 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4 FROM cms_users c0_, cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4 FROM cms_users c0_, cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id', ); } @@ -198,7 +194,7 @@ public function testSupportsJoinOnMultipleComponents(): void { $this->assertSqlGeneration( 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsPhonenumber p WITH u = p.user', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON (c0_.id = c1_.user_id)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON (c0_.id = c1_.user_id)', ); } @@ -206,17 +202,17 @@ public function testSupportsJoinOnMultipleComponentsWithJoinedInheritanceType(): { $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e JOIN Doctrine\Tests\Models\Company\CompanyManager m WITH e.id = m.id', - 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id INNER JOIN (company_managers c2_ INNER JOIN company_employees c4_ ON c2_.id = c4_.id INNER JOIN company_persons c3_ ON c2_.id = c3_.id) ON (c0_.id = c3_.id)' + 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id INNER JOIN (company_managers c2_ INNER JOIN company_employees c4_ ON c2_.id = c4_.id INNER JOIN company_persons c3_ ON c2_.id = c3_.id) ON (c0_.id = c3_.id)', ); $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e LEFT JOIN Doctrine\Tests\Models\Company\CompanyManager m WITH e.id = m.id', - 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN (company_managers c2_ INNER JOIN company_employees c4_ ON c2_.id = c4_.id INNER JOIN company_persons c3_ ON c2_.id = c3_.id) ON (c0_.id = c3_.id)' + 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN (company_managers c2_ INNER JOIN company_employees c4_ ON c2_.id = c4_.id INNER JOIN company_persons c3_ ON c2_.id = c3_.id) ON (c0_.id = c3_.id)', ); $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN c.salesPerson s LEFT JOIN Doctrine\Tests\Models\Company\CompanyEvent e WITH s.id = e.id', - 'SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ INNER JOIN company_employees c1_ ON c0_.salesPerson_id = c1_.id LEFT JOIN company_persons c2_ ON c1_.id = c2_.id LEFT JOIN company_events c3_ ON (c2_.id = c3_.id) WHERE c0_.discr IN (\'fix\', \'flexible\', \'flexultra\')' + 'SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ INNER JOIN company_employees c1_ ON c0_.salesPerson_id = c1_.id LEFT JOIN company_persons c2_ ON c1_.id = c2_.id LEFT JOIN company_events c3_ ON (c2_.id = c3_.id) WHERE c0_.discr IN (\'fix\', \'flexible\', \'flexultra\')', ); } @@ -224,7 +220,7 @@ public function testSupportsSelectWithCollectionAssociationJoin(): void { $this->assertSqlGeneration( 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON c0_.id = c1_.user_id' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.phonenumber AS phonenumber_4 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON c0_.id = c1_.user_id', ); } @@ -232,7 +228,7 @@ public function testSupportsSelectWithSingleValuedAssociationJoin(): void { $this->assertSqlGeneration( 'SELECT u, a FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a', - 'SELECT f0_.id AS id_0, f0_.username AS username_1, f1_.id AS id_2 FROM forum_users f0_ INNER JOIN forum_avatars f1_ ON f0_.avatar_id = f1_.id' + 'SELECT f0_.id AS id_0, f0_.username AS username_1, f1_.id AS id_2 FROM forum_users f0_ INNER JOIN forum_avatars f1_ ON f0_.avatar_id = f1_.id', ); } @@ -240,7 +236,7 @@ public function testSelectCorrelatedSubqueryComplexMathematicalExpression(): voi { $this->assertSqlGeneration( 'SELECT (SELECT (count(p.phonenumber)+5)*10 FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p JOIN p.user ui WHERE ui.id = u.id) AS c FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT (SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr_1 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = c2_.id) AS sclr_0 FROM cms_users c2_' + 'SELECT (SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr_1 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = c2_.id) AS sclr_0 FROM cms_users c2_', ); } @@ -248,7 +244,7 @@ public function testSelectComplexMathematicalExpression(): void { $this->assertSqlGeneration( 'SELECT (count(p.phonenumber)+5)*10 FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p JOIN p.user ui WHERE ui.id = ?1', - 'SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr_0 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = ?' + 'SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr_0 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = ?', ); } @@ -263,14 +259,12 @@ public function testSingleAssociationPathExpressionInSubselect() ); }*/ - /** - * @group DDC-1077 - */ + /** @group DDC-1077 */ public function testConstantValueInSelect(): void { $this->assertSqlGeneration( "SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", - "SELECT c0_.name AS name_0, 'foo' AS sclr_1 FROM cms_users c0_" + "SELECT c0_.name AS name_0, 'foo' AS sclr_1 FROM cms_users c0_", ); } @@ -278,7 +272,7 @@ public function testSupportsOrderByWithAscAsDefault(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ ORDER BY f0_.id ASC' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ ORDER BY f0_.id ASC', ); } @@ -286,7 +280,7 @@ public function testSupportsOrderByAsc(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id asc', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ ORDER BY f0_.id ASC' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ ORDER BY f0_.id ASC', ); } @@ -294,7 +288,7 @@ public function testSupportsOrderByDesc(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id desc', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ ORDER BY f0_.id DESC' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ ORDER BY f0_.id DESC', ); } @@ -302,7 +296,7 @@ public function testSupportsOrderByWithSimpleArithmeticExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY LENGTH(u.username) + LENGTH(u.username) asc', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ ORDER BY LENGTH(f0_.username) + LENGTH(f0_.username) ASC' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ ORDER BY LENGTH(f0_.username) + LENGTH(f0_.username) ASC', ); } @@ -310,7 +304,7 @@ public function testSupportsSelectDistinct(): void { $this->assertSqlGeneration( 'SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT DISTINCT c0_.name AS name_0 FROM cms_users c0_' + 'SELECT DISTINCT c0_.name AS name_0 FROM cms_users c0_', ); } @@ -318,7 +312,7 @@ public function testSupportsAggregateFunctionInSelectedFields(): void { $this->assertSqlGeneration( 'SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id', - 'SELECT COUNT(c0_.id) AS sclr_0 FROM cms_users c0_ GROUP BY c0_.id' + 'SELECT COUNT(c0_.id) AS sclr_0 FROM cms_users c0_ GROUP BY c0_.id', ); } @@ -326,20 +320,18 @@ public function testSupportsAggregateFunctionWithSimpleArithmetic(): void { $this->assertSqlGeneration( 'SELECT MAX(u.id + 4) * 2 FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT MAX(c0_.id + 4) * 2 AS sclr_0 FROM cms_users c0_' + 'SELECT MAX(c0_.id + 4) * 2 AS sclr_0 FROM cms_users c0_', ); } - /** - * @group DDC-3276 - */ + /** @group DDC-3276 */ public function testSupportsAggregateCountFunctionWithSimpleArithmetic(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $this->assertSqlGeneration( 'SELECT COUNT(CONCAT(u.id, u.name)) FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id', - 'SELECT COUNT(CONCAT(c0_.id, c0_.name)) AS sclr_0 FROM cms_users c0_ GROUP BY c0_.id' + 'SELECT COUNT(CONCAT(c0_.id, c0_.name)) AS sclr_0 FROM cms_users c0_ GROUP BY c0_.id', ); } @@ -347,7 +339,7 @@ public function testSupportsWhereClauseWithPositionalParameter(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.id = ?1', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.id = ?' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.id = ?', ); } @@ -355,7 +347,7 @@ public function testSupportsWhereClauseWithNamedParameter(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.username = :name', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.username = ?' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.username = ?', ); } @@ -363,7 +355,7 @@ public function testSupportsWhereAndClauseWithNamedParameters(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.username = :name and u.username = :name2', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.username = ? AND f0_.username = ?' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.username = ? AND f0_.username = ?', ); } @@ -371,7 +363,7 @@ public function testSupportsCombinedWhereClauseWithNamedParameter(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\Forum\ForumUser u where (u.username = :name OR u.username = :name2) AND u.id = :id', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE (f0_.username = ? OR f0_.username = ?) AND f0_.id = ?' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE (f0_.username = ? OR f0_.username = ?) AND f0_.id = ?', ); } @@ -379,7 +371,7 @@ public function testSupportsAggregateFunctionInASelectDistinct(): void { $this->assertSqlGeneration( 'SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT COUNT(DISTINCT c0_.name) AS sclr_0 FROM cms_users c0_' + 'SELECT COUNT(DISTINCT c0_.name) AS sclr_0 FROM cms_users c0_', ); } @@ -388,7 +380,7 @@ public function testSupportsASqlKeywordInAStringLiteralParam(): void { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE '%foo OR bar%'", - "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE c0_.name LIKE '%foo OR bar%'" + "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE c0_.name LIKE '%foo OR bar%'", ); } @@ -396,7 +388,7 @@ public function testSupportsArithmeticExpressionsInWherePart(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE ((c0_.id + 5000) * c0_.id + 3) < 10000000' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE ((c0_.id + 5000) * c0_.id + 3) < 10000000', ); } @@ -404,7 +396,7 @@ public function testSupportsMultipleEntitiesInFromClause(): void { $this->assertSqlGeneration( 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u2 WHERE u.id = u2.id', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.topic AS topic_5, c1_.text AS text_6, c1_.version AS version_7 FROM cms_users c0_, cms_articles c1_ INNER JOIN cms_users c2_ ON c1_.user_id = c2_.id WHERE c0_.id = c2_.id' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.topic AS topic_5, c1_.text AS text_6, c1_.version AS version_7 FROM cms_users c0_, cms_articles c1_ INNER JOIN cms_users c2_ ON c1_.user_id = c2_.id WHERE c0_.id = c2_.id', ); } @@ -412,7 +404,7 @@ public function testSupportsMultipleEntitiesInFromClauseUsingPathExpression(): v { $this->assertSqlGeneration( 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.id = a.user', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.topic AS topic_5, c1_.text AS text_6, c1_.version AS version_7 FROM cms_users c0_, cms_articles c1_ WHERE c0_.id = c1_.user_id' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c1_.id AS id_4, c1_.topic AS topic_5, c1_.text AS text_6, c1_.version AS version_7 FROM cms_users c0_, cms_articles c1_ WHERE c0_.id = c1_.user_id', ); } @@ -420,26 +412,24 @@ public function testSupportsPlainJoinWithoutClause(): void { $this->assertSqlGeneration( 'SELECT u.id, a.id from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a', - 'SELECT c0_.id AS id_0, c1_.id AS id_1 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id' + 'SELECT c0_.id AS id_0, c1_.id AS id_1 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id', ); $this->assertSqlGeneration( 'SELECT u.id, a.id from Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a', - 'SELECT c0_.id AS id_0, c1_.id AS id_1 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id' + 'SELECT c0_.id AS id_0, c1_.id AS id_1 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id', ); } - /** - * @group DDC-135 - */ + /** @group DDC-135 */ public function testSupportsJoinAndWithClauseRestriction(): void { $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic LIKE '%foo%'", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')" + "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')", ); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a WITH a.topic LIKE '%foo%'", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')" + "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')", ); } @@ -452,7 +442,7 @@ public function testJoinOnClauseNotYetSupportedThrowsException(): void $this->expectException(QueryException::class); $sql = $this->entityManager->createQuery( - "SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a ON a.topic LIKE '%foo%'" + "SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a ON a.topic LIKE '%foo%'", )->getSql(); } @@ -460,7 +450,7 @@ public function testSupportsMultipleJoins(): void { $this->assertSqlGeneration( 'SELECT u.id, a.id, p.phonenumber, c.id from Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a JOIN u.phonenumbers p JOIN a.comments c', - 'SELECT c0_.id AS id_0, c1_.id AS id_1, c2_.phonenumber AS phonenumber_2, c3_.id AS id_3 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id INNER JOIN cms_phonenumbers c2_ ON c0_.id = c2_.user_id INNER JOIN cms_comments c3_ ON c1_.id = c3_.article_id' + 'SELECT c0_.id AS id_0, c1_.id AS id_1, c2_.phonenumber AS phonenumber_2, c3_.id AS id_3 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id INNER JOIN cms_phonenumbers c2_ ON c0_.id = c2_.user_id INNER JOIN cms_comments c3_ ON c1_.id = c3_.article_id', ); } @@ -468,18 +458,16 @@ public function testSupportsTrimFunction(): void { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(TRAILING ' ' FROM u.name) = 'someone'", - "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE TRIM(TRAILING ' ' FROM c0_.name) = 'someone'" + "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE TRIM(TRAILING ' ' FROM c0_.name) = 'someone'", ); } - /** - * @group DDC-2668 - */ + /** @group DDC-2668 */ public function testSupportsTrimLeadingZeroString(): void { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(TRAILING '0' FROM u.name) != ''", - "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE TRIM(TRAILING '0' FROM c0_.name) <> ''" + "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE TRIM(TRAILING '0' FROM c0_.name) <> ''", ); } @@ -488,18 +476,16 @@ public function testSupportsBetweenClauseWithPositionalParameters(): void { $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE c0_.id BETWEEN ? AND ?' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE c0_.id BETWEEN ? AND ?', ); } - /** - * @group DDC-1802 - */ + /** @group DDC-1802 */ public function testSupportsNotBetweenForSizeFunction(): void { $this->assertSqlGeneration( 'SELECT m.name FROM Doctrine\Tests\Models\StockExchange\Market m WHERE SIZE(m.stocks) NOT BETWEEN ?1 AND ?2', - 'SELECT e0_.name AS name_0 FROM exchange_markets e0_ WHERE (SELECT COUNT(*) FROM exchange_stocks e1_ WHERE e1_.market_id = e0_.id) NOT BETWEEN ? AND ?' + 'SELECT e0_.name AS name_0 FROM exchange_markets e0_ WHERE (SELECT COUNT(*) FROM exchange_stocks e1_ WHERE e1_.market_id = e0_.id) NOT BETWEEN ? AND ?', ); } @@ -509,7 +495,7 @@ public function testSupportsFunctionalExpressionsInWherePart(): void "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'", // String quoting in the SQL usually depends on the database platform. // This test works with a mock connection which uses ' for string quoting. - "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE TRIM(c0_.name) = 'someone'" + "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE TRIM(c0_.name) = 'someone'", ); } @@ -517,7 +503,7 @@ public function testSupportsInstanceOfExpressionsInWherePart(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee', - "SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_ WHERE c0_.discr IN ('manager', 'employee')" + "SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_ WHERE c0_.discr IN ('manager', 'employee')", ); } @@ -526,29 +512,25 @@ public function testSupportsInstanceOfExpressionInWherePartWithMultipleValues(): // This also uses FQCNs starting with or without a backslash in the INSTANCE OF parameter $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF (Doctrine\Tests\Models\Company\CompanyEmployee, \Doctrine\Tests\Models\Company\CompanyManager)', - "SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_ WHERE c0_.discr IN ('manager', 'employee')" + "SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_ WHERE c0_.discr IN ('manager', 'employee')", ); } - /** - * @group DDC-1194 - */ + /** @group DDC-1194 */ public function testSupportsInstanceOfExpressionsInWherePartPrefixedSlash(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF \Doctrine\Tests\Models\Company\CompanyEmployee', - "SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_ WHERE c0_.discr IN ('manager', 'employee')" + "SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_ WHERE c0_.discr IN ('manager', 'employee')", ); } - /** - * @group DDC-1194 - */ + /** @group DDC-1194 */ public function testSupportsInstanceOfExpressionsInWherePartWithUnrelatedClass(): void { $this->assertInvalidSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF \Doctrine\Tests\Models\CMS\CmsUser', - QueryException::class + QueryException::class, ); } @@ -556,7 +538,7 @@ public function testSupportsInstanceOfExpressionsInWherePartInDeeperLevel(): voi { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Company\CompanyEmployee u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyManager', - "SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id WHERE c0_.discr IN ('manager')" + "SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id WHERE c0_.discr IN ('manager')", ); } @@ -564,7 +546,7 @@ public function testSupportsInstanceOfExpressionsInWherePartInDeepestLevel(): vo { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Company\CompanyManager u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyManager', - "SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id WHERE c0_.discr IN ('manager')" + "SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id WHERE c0_.discr IN ('manager')", ); } @@ -574,7 +556,7 @@ public function testSupportsInstanceOfExpressionsUsingInputParameterInWherePart( 'SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_ WHERE c0_.discr IN (?)', [], - [1 => $this->entityManager->getClassMetadata(CompanyEmployee::class)] + [1 => $this->entityManager->getClassMetadata(CompanyEmployee::class)], ); } @@ -583,7 +565,7 @@ public function testSupportsSingleValuedInExpressionWithoutSpacesInWherePart(): { $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE IDENTITY(u.email) IN(46)', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE c0_.email_id IN (46)' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE c0_.email_id IN (46)', ); } @@ -591,7 +573,7 @@ public function testSupportsMultipleValuedInExpressionInWherePart(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.id IN (1, 2)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.id IN (1, 2)', ); } @@ -599,18 +581,16 @@ public function testSupportsNotInExpressionInWherePart(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :id NOT IN (1)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE ? NOT IN (1)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE ? NOT IN (1)', ); } - /** - * @group DDC-1802 - */ + /** @group DDC-1802 */ public function testSupportsNotInExpressionForModFunction(): void { $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE MOD(u.id, 5) NOT IN(1,3,4)', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE MOD(c0_.id, 5) NOT IN (1, 3, 4)' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE MOD(c0_.id, 5) NOT IN (1, 3, 4)', ); } @@ -618,7 +598,7 @@ public function testInExpressionWithSingleValuedAssociationPathExpressionInWhere { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.avatar_id IN (?, ?)' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.avatar_id IN (?, ?)', ); } @@ -627,7 +607,7 @@ public function testInvalidInExpressionWithSingleValuedAssociationPathExpression // We do not support SingleValuedAssociationPathExpression on inverse side $this->assertInvalidSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address IN (?1, ?2)', - QueryException::class + QueryException::class, ); } @@ -637,11 +617,11 @@ public function testInExpressionWithArithmeticExpression(): void $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.username IN (FOO('Lo'), 'Lo', :name)", - "SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.username IN (ABS('Lo'), 'Lo', ?)" + "SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.username IN (ABS('Lo'), 'Lo', ?)", ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.id IN (1 + 1)', - 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.id IN (1 + 1)' + 'SELECT f0_.id AS id_0, f0_.username AS username_1 FROM forum_users f0_ WHERE f0_.id IN (1 + 1)', ); } @@ -651,21 +631,21 @@ public function testSupportsConcatFunctionForMysqlAndPostgresql(): void $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", - "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE CONCAT(c0_.name, 's') = ?" + "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE CONCAT(c0_.name, 's') = ?", ); $this->assertSqlGeneration( 'SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', - 'SELECT CONCAT(c0_.id, c0_.name) AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?' + 'SELECT CONCAT(c0_.id, c0_.name) AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?', ); $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", - "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE c0_.name || 's' = ?" + "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE c0_.name || 's' = ?", ); $this->assertSqlGeneration( 'SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', - 'SELECT c0_.id || c0_.name AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?' + 'SELECT c0_.id || c0_.name AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?', ); } @@ -673,18 +653,16 @@ public function testSupportsExistsExpressionInWherePartWithCorrelatedSubquery(): { $this->assertSqlGeneration( 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = u.id)', - 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT c1_.phonenumber FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = c0_.id)' + 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT c1_.phonenumber FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = c0_.id)', ); } - /** - * @group DDC-593 - */ + /** @group DDC-593 */ public function testSubqueriesInComparisonExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id >= (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = :name)) AND (u.id <= (SELECT u3.id FROM Doctrine\Tests\Models\CMS\CmsUser u3 WHERE u3.name = :name))', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (c0_.id >= (SELECT c1_.id FROM cms_users c1_ WHERE c1_.name = ?)) AND (c0_.id <= (SELECT c2_.id FROM cms_users c2_ WHERE c2_.name = ?))' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (c0_.id >= (SELECT c1_.id FROM cms_users c1_ WHERE c1_.name = ?)) AND (c0_.id <= (SELECT c2_.id FROM cms_users c2_ WHERE c2_.name = ?))', ); } @@ -700,7 +678,7 @@ public function testSupportsMemberOfExpressionOneToMany(): void self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id AND c1_.phonenumber = ?)', - $q->getSql() + $q->getSql(), ); } @@ -716,7 +694,7 @@ public function testSupportsMemberOfExpressionManyToMany(): void self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (?))', - $q->getSql() + $q->getSql(), ); } @@ -733,7 +711,7 @@ public function testSupportsMemberOfExpressionManyToManyParameterArray(): void self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (?))', - $q->getSql() + $q->getSql(), ); } @@ -747,7 +725,7 @@ public function testSupportsMemberOfExpressionSelfReferencing(): void $q->setParameter('param', $person); self::assertEquals( 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c1_.car_id AS car_id_8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ WHERE c3_.person_id = c0_.id AND c3_.friend_id IN (?))', - $q->getSql() + $q->getSql(), ); } @@ -758,7 +736,7 @@ public function testSupportsMemberOfWithSingleValuedAssociation(): void self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (c0_.email_id))', - $q->getSql() + $q->getSql(), ); } @@ -769,7 +747,7 @@ public function testSupportsMemberOfWithIdentificationVariable(): void self::assertEquals( 'SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id AND c1_.group_id IN (c0_.id))', - $q->getSql() + $q->getSql(), ); } @@ -808,7 +786,7 @@ public function testExistsExpressionInWhereCorrelatedSubqueryAssocCondition(): v 'SELECT DISTINCT c0_.id AS id_0, c0_.name AS name_1 FROM cms_employees c0_' . ' WHERE EXISTS (' . 'SELECT c1_.id FROM cms_employees c1_ WHERE c1_.id = c0_.spouse_id' - . ')' + . ')', ); } @@ -826,7 +804,7 @@ public function testExistsExpressionWithSimpleSelectReturningScalar(): void 'SELECT DISTINCT c0_.id AS id_0, c0_.name AS name_1 FROM cms_employees c0_' . ' WHERE EXISTS (' . 'SELECT 1 AS sclr_2 FROM cms_employees c1_ WHERE c1_.id = c0_.spouse_id' - . ')' + . ')', ); } @@ -851,8 +829,8 @@ public function testLimitAndOffsetFromQueryClass(): void $q->getSql(), self::logicalOr( self::identicalTo('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10'), - self::identicalTo('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10 OFFSET 0') - ) + self::identicalTo('SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.email_id AS email_id_4 FROM cms_users c0_ LIMIT 10 OFFSET 0'), + ), ); } @@ -860,7 +838,7 @@ public function testSizeFunction(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 1' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 1', ); } @@ -868,7 +846,7 @@ public function testSizeFunctionSupportsManyToMany(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) > 1', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id) > 1' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id) > 1', ); } @@ -876,11 +854,11 @@ public function testEmptyCollectionComparisonExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) = 0' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) = 0', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS NOT EMPTY', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 0' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 0', ); } @@ -888,7 +866,7 @@ public function testNestedExpressions(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.id > 10 and u.id < 42 and ((u.id * 2) > 5)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.id > 10 AND c0_.id < 42 AND ((c0_.id * 2) > 5)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.id > 10 AND c0_.id < 42 AND ((c0_.id * 2) > 5)', ); } @@ -896,7 +874,7 @@ public function testNestedExpressions2(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where (u.id > 10) and (u.id < 42 and ((u.id * 2) > 5)) or u.id <> 42', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id < 42 AND ((c0_.id * 2) > 5)) OR c0_.id <> 42' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id < 42 AND ((c0_.id * 2) > 5)) OR c0_.id <> 42', ); } @@ -904,7 +882,7 @@ public function testNestedExpressions3(): void { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\CMS\CmsUser u where (u.id > 10) and (u.id between 1 and 10 or u.id in (1, 2, 3, 4, 5))', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id BETWEEN 1 AND 10 OR c0_.id IN (1, 2, 3, 4, 5))' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id BETWEEN 1 AND 10 OR c0_.id IN (1, 2, 3, 4, 5))', ); } @@ -912,7 +890,7 @@ public function testOrderByCollectionAssociationSize(): void { $this->assertSqlGeneration( 'select u, size(u.articles) as numArticles from Doctrine\Tests\Models\CMS\CmsUser u order by numArticles', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT COUNT(*) FROM cms_articles c1_ WHERE c1_.user_id = c0_.id) AS sclr_4 FROM cms_users c0_ ORDER BY sclr_4 ASC' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT COUNT(*) FROM cms_articles c1_ WHERE c1_.user_id = c0_.id) AS sclr_4 FROM cms_users c0_ ORDER BY sclr_4 ASC', ); } @@ -920,7 +898,7 @@ public function testOrderBySupportsSingleValuedPathExpressionOwningSide(): void { $this->assertSqlGeneration( 'select a from Doctrine\Tests\Models\CMS\CmsArticle a order by a.user', - 'SELECT c0_.id AS id_0, c0_.topic AS topic_1, c0_.text AS text_2, c0_.version AS version_3 FROM cms_articles c0_ ORDER BY c0_.user_id ASC' + 'SELECT c0_.id AS id_0, c0_.topic AS topic_1, c0_.text AS text_2, c0_.version AS version_3 FROM cms_articles c0_ ORDER BY c0_.user_id ASC', ); } @@ -936,12 +914,12 @@ public function testBooleanLiteralInWhereOnSqlite(): void $this->entityManager = $this->createTestEntityManagerWithPlatform(new SQLitePlatform()); $this->assertSqlGeneration( 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true', - 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanField_1 FROM boolean_model b0_ WHERE b0_.booleanField = 1' + 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanField_1 FROM boolean_model b0_ WHERE b0_.booleanField = 1', ); $this->assertSqlGeneration( 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false', - 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanField_1 FROM boolean_model b0_ WHERE b0_.booleanField = 0' + 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanField_1 FROM boolean_model b0_ WHERE b0_.booleanField = 0', ); } @@ -950,12 +928,12 @@ public function testBooleanLiteralInWhereOnPostgres(): void $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $this->assertSqlGeneration( 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true', - 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanfield_1 FROM boolean_model b0_ WHERE b0_.booleanField = true' + 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanfield_1 FROM boolean_model b0_ WHERE b0_.booleanField = true', ); $this->assertSqlGeneration( 'SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false', - 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanfield_1 FROM boolean_model b0_ WHERE b0_.booleanField = false' + 'SELECT b0_.id AS id_0, b0_.booleanField AS booleanfield_1 FROM boolean_model b0_ WHERE b0_.booleanField = false', ); } @@ -963,7 +941,7 @@ public function testSingleValuedAssociationFieldInWhere(): void { $this->assertSqlGeneration( 'SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1', - 'SELECT c0_.phonenumber AS phonenumber_0 FROM cms_phonenumbers c0_ WHERE c0_.user_id = ?' + 'SELECT c0_.phonenumber AS phonenumber_0 FROM cms_phonenumbers c0_ WHERE c0_.user_id = ?', ); } @@ -971,7 +949,7 @@ public function testSingleValuedAssociationNullCheckOnOwningSide(): void { $this->assertSqlGeneration( 'SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.user IS NULL', - 'SELECT c0_.id AS id_0, c0_.country AS country_1, c0_.zip AS zip_2, c0_.city AS city_3 FROM cms_addresses c0_ WHERE c0_.user_id IS NULL' + 'SELECT c0_.id AS id_0, c0_.country AS country_1, c0_.zip AS zip_2, c0_.city AS city_3 FROM cms_addresses c0_ WHERE c0_.user_id IS NULL', ); } @@ -984,7 +962,7 @@ public function testSingleValuedAssociationNullCheckOnInverseSide(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.address a WHERE a.id IS NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL', ); } @@ -996,61 +974,57 @@ public function testStringFunctionLikeExpression(): void { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) LIKE '%foo OR bar%'", - "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE '%foo OR bar%'" + "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE '%foo OR bar%'", ); $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) LIKE :str', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE ?' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE ?', ); $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(UPPER(u.name), '_moo') LIKE :str", - "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE UPPER(c0_.name) || '_moo' LIKE ?" + "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE UPPER(c0_.name) || '_moo' LIKE ?", ); // DDC-1572 $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE UPPER(u.name) LIKE UPPER(:str)', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE UPPER(c0_.name) LIKE UPPER(?)' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE UPPER(c0_.name) LIKE UPPER(?)', ); $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE UPPER(LOWER(u.name)) LIKE UPPER(LOWER(:str))', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE UPPER(LOWER(c0_.name)) LIKE UPPER(LOWER(?))' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE UPPER(LOWER(c0_.name)) LIKE UPPER(LOWER(?))', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic LIKE u.name', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE c0_.name)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE c0_.name)', ); } - /** - * @group DDC-1802 - */ + /** @group DDC-1802 */ public function testStringFunctionNotLikeExpression(): void { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) NOT LIKE '%foo OR bar%'", - "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE LOWER(c0_.name) NOT LIKE '%foo OR bar%'" + "SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE LOWER(c0_.name) NOT LIKE '%foo OR bar%'", ); $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE UPPER(LOWER(u.name)) NOT LIKE UPPER(LOWER(:str))', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE UPPER(LOWER(c0_.name)) NOT LIKE UPPER(LOWER(?))' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ WHERE UPPER(LOWER(c0_.name)) NOT LIKE UPPER(LOWER(?))', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic NOT LIKE u.name', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic NOT LIKE c0_.name)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic NOT LIKE c0_.name)', ); } - /** - * @group DDC-338 - */ + /** @group DDC-338 */ public function testOrderedCollectionFetchJoined(): void { $this->assertSqlGeneration( 'SELECT r, l FROM Doctrine\Tests\Models\Routing\RoutingRoute r JOIN r.legs l', 'SELECT r0_.id AS id_0, r1_.id AS id_1, r1_.departureDate AS departureDate_2, r1_.arrivalDate AS arrivalDate_3 FROM RoutingRoute r0_ INNER JOIN RoutingRouteLegs r2_ ON r0_.id = r2_.route_id INNER JOIN RoutingLeg r1_ ON r1_.id = r2_.leg_id ' . - 'ORDER BY r1_.departureDate ASC' + 'ORDER BY r1_.departureDate ASC', ); } @@ -1058,7 +1032,7 @@ public function testSubselectInSelect(): void { $this->assertSqlGeneration( "SELECT u.name, (SELECT COUNT(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234) pcount FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'", - "SELECT c0_.name AS name_0, (SELECT COUNT(c1_.phonenumber) AS sclr_2 FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = 1234) AS sclr_1 FROM cms_users c0_ WHERE c0_.name = 'jon'" + "SELECT c0_.name AS name_0, (SELECT COUNT(c1_.phonenumber) AS sclr_2 FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = 1234) AS sclr_1 FROM cms_users c0_ WHERE c0_.name = 'jon'", ); } @@ -1076,7 +1050,7 @@ public function testPessimisticWriteLockQueryHint(): void "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 ' . "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", - [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_WRITE] + [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_WRITE], ); } @@ -1092,7 +1066,7 @@ public function testPessimisticReadLockQueryHintPostgreSql(): void "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 ' . "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR SHARE", - [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ] + [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ], ); } @@ -1106,18 +1080,16 @@ public function testLockModeNoneQueryHint(): void "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 ' . "FROM cms_users c0_ WHERE c0_.username = 'gblanco'", - [ORMQuery::HINT_LOCK_MODE => LockMode::NONE] + [ORMQuery::HINT_LOCK_MODE => LockMode::NONE], ); } - /** - * @group DDC-430 - */ + /** @group DDC-430 */ public function testSupportSelectWithMoreThan10InputParameters(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR u.id = ?2 OR u.id = ?3 OR u.id = ?4 OR u.id = ?5 OR u.id = ?6 OR u.id = ?7 OR u.id = ?8 OR u.id = ?9 OR u.id = ?10 OR u.id = ?11', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ?' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ?', ); } @@ -1133,7 +1105,7 @@ public function testPessimisticReadLockQueryHintMySql(): void "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 ' . "FROM cms_users c0_ WHERE c0_.username = 'gblanco' LOCK IN SHARE MODE", - [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ] + [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ], ); } @@ -1149,13 +1121,11 @@ public function testPessimisticReadLockQueryHintOracle(): void "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", 'SELECT c0_.id AS ID_0, c0_.status AS STATUS_1, c0_.username AS USERNAME_2, c0_.name AS NAME_3 ' . "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", - [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ] + [ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ], ); } - /** - * @group DDC-431 - */ + /** @group DDC-431 */ public function testSupportToCustomDQLFunctions(): void { $config = $this->entityManager->getConfiguration(); @@ -1163,42 +1133,36 @@ public function testSupportToCustomDQLFunctions(): void $this->assertSqlGeneration( 'SELECT MYABS(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p', - 'SELECT ABS(c0_.phonenumber) AS sclr_0 FROM cms_phonenumbers c0_' + 'SELECT ABS(c0_.phonenumber) AS sclr_0 FROM cms_phonenumbers c0_', ); $config->setCustomNumericFunctions([]); } - /** - * @group DDC-826 - */ + /** @group DDC-826 */ public function testMappedSuperclassAssociationJoin(): void { $this->assertSqlGeneration( 'SELECT f FROM Doctrine\Tests\Models\DirectoryTree\File f JOIN f.parentDirectory d WHERE f.id = ?1', - 'SELECT f0_.id AS id_0, f0_.extension AS extension_1, f0_.name AS name_2 FROM "file" f0_ INNER JOIN Directory d1_ ON f0_.parentDirectory_id = d1_.id WHERE f0_.id = ?' + 'SELECT f0_.id AS id_0, f0_.extension AS extension_1, f0_.name AS name_2 FROM "file" f0_ INNER JOIN Directory d1_ ON f0_.parentDirectory_id = d1_.id WHERE f0_.id = ?', ); } - /** - * @group DDC-1053 - */ + /** @group DDC-1053 */ public function testGroupBy(): void { $this->assertSqlGeneration( 'SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id', - 'SELECT c0_.id AS id_0, count(c1_.id) AS sclr_1 FROM cms_groups c0_ INNER JOIN cms_users_groups c2_ ON c0_.id = c2_.group_id INNER JOIN cms_users c1_ ON c1_.id = c2_.user_id GROUP BY c0_.id' + 'SELECT c0_.id AS id_0, count(c1_.id) AS sclr_1 FROM cms_groups c0_ INNER JOIN cms_users_groups c2_ ON c0_.id = c2_.group_id INNER JOIN cms_users c1_ ON c1_.id = c2_.user_id GROUP BY c0_.id', ); } - /** - * @group DDC-1053 - */ + /** @group DDC-1053 */ public function testGroupByIdentificationVariable(): void { $this->assertSqlGeneration( 'SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g', - 'SELECT c0_.id AS id_0, c0_.name AS name_1, count(c1_.id) AS sclr_2 FROM cms_groups c0_ INNER JOIN cms_users_groups c2_ ON c0_.id = c2_.group_id INNER JOIN cms_users c1_ ON c1_.id = c2_.user_id GROUP BY c0_.id, c0_.name' + 'SELECT c0_.id AS id_0, c0_.name AS name_1, count(c1_.id) AS sclr_2 FROM cms_groups c0_ INNER JOIN cms_users_groups c2_ ON c0_.id = c2_.group_id INNER JOIN cms_users c1_ ON c1_.id = c2_.user_id GROUP BY c0_.id, c0_.name', ); } @@ -1206,7 +1170,7 @@ public function testCaseContainingNullIf(): void { $this->assertSqlGeneration( 'SELECT NULLIF(g.id, g.name) AS NullIfEqual FROM Doctrine\Tests\Models\CMS\CmsGroup g', - 'SELECT NULLIF(c0_.id, c0_.name) AS sclr_0 FROM cms_groups c0_' + 'SELECT NULLIF(c0_.id, c0_.name) AS sclr_0 FROM cms_groups c0_', ); } @@ -1214,7 +1178,7 @@ public function testCaseContainingCoalesce(): void { $this->assertSqlGeneration( "SELECT COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u", - "SELECT COALESCE(NULLIF(c0_.name, ''), c0_.username) AS sclr_0 FROM cms_users c0_" + "SELECT COALESCE(NULLIF(c0_.name, ''), c0_.username) AS sclr_0 FROM cms_users c0_", ); } @@ -1225,7 +1189,7 @@ public function testSubSelectDiscriminator(): void { $this->assertSqlGeneration( 'SELECT u.name, (SELECT COUNT(cfc.id) total FROM Doctrine\Tests\Models\Company\CompanyFixContract cfc) as cfc_count FROM Doctrine\Tests\Models\CMS\CmsUser u', - "SELECT c0_.name AS name_0, (SELECT COUNT(c1_.id) AS sclr_2 FROM company_contracts c1_ WHERE c1_.discr IN ('fix')) AS sclr_1 FROM cms_users c0_" + "SELECT c0_.name AS name_0, (SELECT COUNT(c1_.id) AS sclr_2 FROM company_contracts c1_ WHERE c1_.discr IN ('fix')) AS sclr_1 FROM cms_users c0_", ); } @@ -1248,7 +1212,7 @@ public function testSubSelectAliasesFromOuterQuery(): void { $this->assertSqlGeneration( 'SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_4 FROM cms_users c0_' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_4 FROM cms_users c0_', ); } @@ -1256,7 +1220,7 @@ public function testSubSelectAliasesFromOuterQueryWithSubquery(): void { $this->assertSqlGeneration( 'SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id AND ui.name IN (SELECT uii.name FROM Doctrine\Tests\Models\CMS\CmsUser uii)) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id AND c1_.name IN (SELECT c2_.name FROM cms_users c2_)) AS sclr_4 FROM cms_users c0_' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id AND c1_.name IN (SELECT c2_.name FROM cms_users c2_)) AS sclr_4 FROM cms_users c0_', ); } @@ -1264,18 +1228,16 @@ public function testSubSelectAliasesFromOuterQueryReuseInWhereClause(): void { $this->assertSqlGeneration( 'SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo WHERE bar = ?0', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_4 FROM cms_users c0_ WHERE sclr_4 = ?' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_4 FROM cms_users c0_ WHERE sclr_4 = ?', ); } - /** - * @group DDC-1298 - */ + /** @group DDC-1298 */ public function testSelectForeignKeyPKWithoutFields(): void { $this->assertSqlGeneration( 'SELECT t, s, l FROM Doctrine\Tests\Models\DDC117\DDC117Link l INNER JOIN l.target t INNER JOIN l.source s', - 'SELECT d0_.article_id AS article_id_0, d0_.title AS title_1, d1_.article_id AS article_id_2, d1_.title AS title_3, d2_.source_id AS source_id_4, d2_.target_id AS target_id_5 FROM DDC117Link d2_ INNER JOIN DDC117Article d0_ ON d2_.target_id = d0_.article_id INNER JOIN DDC117Article d1_ ON d2_.source_id = d1_.article_id' + 'SELECT d0_.article_id AS article_id_0, d0_.title AS title_1, d1_.article_id AS article_id_2, d1_.title AS title_3, d2_.source_id AS source_id_4, d2_.target_id AS target_id_5 FROM DDC117Link d2_ INNER JOIN DDC117Article d0_ ON d2_.target_id = d0_.article_id INNER JOIN DDC117Article d1_ ON d2_.source_id = d1_.article_id', ); } @@ -1283,7 +1245,7 @@ public function testGeneralCaseWithSingleWhenClause(): void { $this->assertSqlGeneration( 'SELECT g.id, CASE WHEN ((g.id / 2) > 18) THEN 1 ELSE 0 END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g', - 'SELECT c0_.id AS id_0, CASE WHEN ((c0_.id / 2) > 18) THEN 1 ELSE 0 END AS sclr_1 FROM cms_groups c0_' + 'SELECT c0_.id AS id_0, CASE WHEN ((c0_.id / 2) > 18) THEN 1 ELSE 0 END AS sclr_1 FROM cms_groups c0_', ); } @@ -1291,7 +1253,7 @@ public function testGeneralCaseWithMultipleWhenClause(): void { $this->assertSqlGeneration( 'SELECT g.id, CASE WHEN (g.id / 2 < 10) THEN 2 WHEN ((g.id / 2) > 20) THEN 1 ELSE 0 END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g', - 'SELECT c0_.id AS id_0, CASE WHEN (c0_.id / 2 < 10) THEN 2 WHEN ((c0_.id / 2) > 20) THEN 1 ELSE 0 END AS sclr_1 FROM cms_groups c0_' + 'SELECT c0_.id AS id_0, CASE WHEN (c0_.id / 2 < 10) THEN 2 WHEN ((c0_.id / 2) > 20) THEN 1 ELSE 0 END AS sclr_1 FROM cms_groups c0_', ); } @@ -1299,7 +1261,7 @@ public function testSimpleCaseWithSingleWhenClause(): void { $this->assertSqlGeneration( "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id = CASE g.name WHEN 'admin' THEN 1 ELSE 2 END", - "SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id = CASE c0_.name WHEN 'admin' THEN 1 ELSE 2 END" + "SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id = CASE c0_.name WHEN 'admin' THEN 1 ELSE 2 END", ); } @@ -1307,7 +1269,7 @@ public function testSimpleCaseWithMultipleWhenClause(): void { $this->assertSqlGeneration( "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id = (CASE g.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END)", - "SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id = (CASE c0_.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END)" + "SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id = (CASE c0_.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END)", ); } @@ -1315,7 +1277,7 @@ public function testGeneralCaseWithSingleWhenClauseInSubselect(): void { $this->assertSqlGeneration( 'SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE WHEN ((g2.id / 2) > 18) THEN 2 ELSE 1 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)', - 'SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE WHEN ((c1_.id / 2) > 18) THEN 2 ELSE 1 END AS sclr_2 FROM cms_groups c1_)' + 'SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE WHEN ((c1_.id / 2) > 18) THEN 2 ELSE 1 END AS sclr_2 FROM cms_groups c1_)', ); } @@ -1323,7 +1285,7 @@ public function testGeneralCaseWithMultipleWhenClauseInSubselect(): void { $this->assertSqlGeneration( 'SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE WHEN (g.id / 2 < 10) THEN 3 WHEN ((g.id / 2) > 20) THEN 2 ELSE 1 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)', - 'SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE WHEN (c0_.id / 2 < 10) THEN 3 WHEN ((c0_.id / 2) > 20) THEN 2 ELSE 1 END AS sclr_2 FROM cms_groups c1_)' + 'SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE WHEN (c0_.id / 2 < 10) THEN 3 WHEN ((c0_.id / 2) > 20) THEN 2 ELSE 1 END AS sclr_2 FROM cms_groups c1_)', ); } @@ -1331,7 +1293,7 @@ public function testSimpleCaseWithSingleWhenClauseInSubselect(): void { $this->assertSqlGeneration( "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE g2.name WHEN 'admin' THEN 1 ELSE 2 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", - "SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE c1_.name WHEN 'admin' THEN 1 ELSE 2 END AS sclr_2 FROM cms_groups c1_)" + "SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE c1_.name WHEN 'admin' THEN 1 ELSE 2 END AS sclr_2 FROM cms_groups c1_)", ); } @@ -1339,49 +1301,45 @@ public function testSimpleCaseWithMultipleWhenClauseInSubselect(): void { $this->assertSqlGeneration( "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE g2.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", - "SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE c1_.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END AS sclr_2 FROM cms_groups c1_)" + "SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE c1_.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END AS sclr_2 FROM cms_groups c1_)", ); } - /** - * @group DDC-1696 - */ + /** @group DDC-1696 */ public function testSimpleCaseWithStringPrimary(): void { $this->assertSqlGeneration( "SELECT g.id, CASE WHEN ((g.id / 2) > 18) THEN 'Foo' ELSE 'Bar' END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT c0_.id AS id_0, CASE WHEN ((c0_.id / 2) > 18) THEN 'Foo' ELSE 'Bar' END AS sclr_1 FROM cms_groups c0_" + "SELECT c0_.id AS id_0, CASE WHEN ((c0_.id / 2) > 18) THEN 'Foo' ELSE 'Bar' END AS sclr_1 FROM cms_groups c0_", ); } - /** - * @group DDC-2205 - */ + /** @group DDC-2205 */ public function testCaseNegativeValuesInThenExpression(): void { $this->assertSqlGeneration( "SELECT CASE g.name WHEN 'admin' THEN - 1 ELSE - 2 END FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT CASE c0_.name WHEN 'admin' THEN -1 ELSE -2 END AS sclr_0 FROM cms_groups c0_" + "SELECT CASE c0_.name WHEN 'admin' THEN -1 ELSE -2 END AS sclr_0 FROM cms_groups c0_", ); $this->assertSqlGeneration( "SELECT CASE g.name WHEN 'admin' THEN - 2 WHEN 'guest' THEN - 1 ELSE 0 END FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT CASE c0_.name WHEN 'admin' THEN -2 WHEN 'guest' THEN -1 ELSE 0 END AS sclr_0 FROM cms_groups c0_" + "SELECT CASE c0_.name WHEN 'admin' THEN -2 WHEN 'guest' THEN -1 ELSE 0 END AS sclr_0 FROM cms_groups c0_", ); $this->assertSqlGeneration( "SELECT CASE g.name WHEN 'admin' THEN (- 1) ELSE (- 2) END FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT CASE c0_.name WHEN 'admin' THEN (-1) ELSE (-2) END AS sclr_0 FROM cms_groups c0_" + "SELECT CASE c0_.name WHEN 'admin' THEN (-1) ELSE (-2) END AS sclr_0 FROM cms_groups c0_", ); $this->assertSqlGeneration( "SELECT CASE g.name WHEN 'admin' THEN ( - :value) ELSE ( + :value) END FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT CASE c0_.name WHEN 'admin' THEN (-?) ELSE (+?) END AS sclr_0 FROM cms_groups c0_" + "SELECT CASE c0_.name WHEN 'admin' THEN (-?) ELSE (+?) END AS sclr_0 FROM cms_groups c0_", ); $this->assertSqlGeneration( "SELECT CASE g.name WHEN 'admin' THEN ( - g.id) ELSE ( + g.id) END FROM Doctrine\Tests\Models\CMS\CmsGroup g", - "SELECT CASE c0_.name WHEN 'admin' THEN (-c0_.id) ELSE (+c0_.id) END AS sclr_0 FROM cms_groups c0_" + "SELECT CASE c0_.name WHEN 'admin' THEN (-c0_.id) ELSE (+c0_.id) END AS sclr_0 FROM cms_groups c0_", ); } @@ -1389,49 +1347,45 @@ public function testIdentityFunctionWithCompositePrimaryKey(): void { $this->assertSqlGeneration( "SELECT IDENTITY(p.poi, 'long') AS long FROM Doctrine\Tests\Models\Navigation\NavPhotos p", - 'SELECT n0_.poi_long AS sclr_0 FROM navigation_photos n0_' + 'SELECT n0_.poi_long AS sclr_0 FROM navigation_photos n0_', ); $this->assertSqlGeneration( "SELECT IDENTITY(p.poi, 'lat') AS lat FROM Doctrine\Tests\Models\Navigation\NavPhotos p", - 'SELECT n0_.poi_lat AS sclr_0 FROM navigation_photos n0_' + 'SELECT n0_.poi_lat AS sclr_0 FROM navigation_photos n0_', ); $this->assertSqlGeneration( "SELECT IDENTITY(p.poi, 'long') AS long, IDENTITY(p.poi, 'lat') AS lat FROM Doctrine\Tests\Models\Navigation\NavPhotos p", - 'SELECT n0_.poi_long AS sclr_0, n0_.poi_lat AS sclr_1 FROM navigation_photos n0_' + 'SELECT n0_.poi_long AS sclr_0, n0_.poi_lat AS sclr_1 FROM navigation_photos n0_', ); $this->assertInvalidSqlGeneration( "SELECT IDENTITY(p.poi, 'invalid') AS invalid FROM Doctrine\Tests\Models\Navigation\NavPhotos p", - QueryException::class + QueryException::class, ); } - /** - * @group DDC-2519 - */ + /** @group DDC-2519 */ public function testPartialWithAssociationIdentifier(): void { $this->assertSqlGeneration( 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l', - 'SELECT l0_.iUserIdSource AS iUserIdSource_0, l0_.iUserIdTarget AS iUserIdTarget_1 FROM legacy_users_reference l0_' + 'SELECT l0_.iUserIdSource AS iUserIdSource_0, l0_.iUserIdTarget AS iUserIdTarget_1 FROM legacy_users_reference l0_', ); $this->assertSqlGeneration( 'SELECT PARTIAL l.{_description, _source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l', - 'SELECT l0_.description AS description_0, l0_.iUserIdSource AS iUserIdSource_1, l0_.iUserIdTarget AS iUserIdTarget_2 FROM legacy_users_reference l0_' + 'SELECT l0_.description AS description_0, l0_.iUserIdSource AS iUserIdSource_1, l0_.iUserIdTarget AS iUserIdTarget_2 FROM legacy_users_reference l0_', ); } - /** - * @group DDC-1339 - */ + /** @group DDC-1339 */ public function testIdentityFunctionInSelectClause(): void { $this->assertSqlGeneration( 'SELECT IDENTITY(u.email) as email_id FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.email_id AS sclr_0 FROM cms_users c0_' + 'SELECT c0_.email_id AS sclr_0 FROM cms_users c0_', ); } @@ -1440,191 +1394,161 @@ public function testIdentityFunctionInJoinedSubclass(): void //relation is in the subclass (CompanyManager) we are querying $this->assertSqlGeneration( 'SELECT m, IDENTITY(m.car) as car_id FROM Doctrine\Tests\Models\Company\CompanyManager m', - 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c2_.car_id AS sclr_6, c0_.discr AS discr_7 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id' + 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c2_.car_id AS sclr_6, c0_.discr AS discr_7 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', ); //relation is in the base class (CompanyPerson). $this->assertSqlGeneration( 'SELECT m, IDENTITY(m.spouse) as spouse_id FROM Doctrine\Tests\Models\Company\CompanyManager m', - 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.spouse_id AS sclr_6, c0_.discr AS discr_7 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id' + 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.spouse_id AS sclr_6, c0_.discr AS discr_7 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', ); } - /** - * @group DDC-1339 - */ + /** @group DDC-1339 */ public function testIdentityFunctionDoesNotAcceptStateField(): void { $this->assertInvalidSqlGeneration( 'SELECT IDENTITY(u.name) as name FROM Doctrine\Tests\Models\CMS\CmsUser u', - QueryException::class + QueryException::class, ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeJoinInRootClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c1_.car_id AS car_id_8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeJoinInRootClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeJoinInChildClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeJoinInChildClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeJoinInLeafClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeJoinInLeafClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeSingleTableInRootClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6, c0_.salesPerson_id AS salesPerson_id_7 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeSingleTableInRootClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeSingleTableInChildClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeSingleTableInChildClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeSingleTableInLeafClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } - /** - * @group DDC-1389 - */ + /** @group DDC-1389 */ public function testInheritanceTypeSingleTableInLeafClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } - /** - * @group DDC-1161 - */ + /** @group DDC-1161 */ public function testSelfReferenceWithOneToOneDoesNotDuplicateAlias(): void { $this->assertSqlGeneration( 'SELECT p, pp FROM Doctrine\Tests\Models\Company\CompanyPerson p JOIN p.spouse pp', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c3_.id AS id_6, c3_.name AS name_7, c4_.title AS title_8, c5_.salary AS salary_9, c5_.department AS department_10, c5_.startDate AS startDate_11, c0_.discr AS discr_12, c0_.spouse_id AS spouse_id_13, c1_.car_id AS car_id_14, c3_.discr AS discr_15, c3_.spouse_id AS spouse_id_16, c4_.car_id AS car_id_17 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id INNER JOIN company_persons c3_ ON c0_.spouse_id = c3_.id LEFT JOIN company_managers c4_ ON c3_.id = c4_.id LEFT JOIN company_employees c5_ ON c3_.id = c5_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } - /** - * @group DDC-1384 - */ + /** @group DDC-1384 */ public function testAliasDoesNotExceedPlatformDefinedLength(): void { $this->assertSqlGeneration( 'SELECT m FROM ' . __NAMESPACE__ . '\\DDC1384Model m', - 'SELECT d0_.aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalkerFooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo AS ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo_0 FROM DDC1384Model d0_' + 'SELECT d0_.aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalkerFooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo AS ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo_0 FROM DDC1384Model d0_', ); } @@ -1636,114 +1560,100 @@ public function testIssue331(): void { $this->assertSqlGeneration( 'SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e', - 'SELECT c0_.name AS name_0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id' + 'SELECT c0_.name AS name_0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id', ); } - /** - * @group DDC-1435 - */ + /** @group DDC-1435 */ public function testForeignKeyAsPrimaryKeySubselect(): void { $this->assertSqlGeneration( 'SELECT s FROM Doctrine\Tests\Models\DDC117\DDC117Article s WHERE EXISTS (SELECT r FROM Doctrine\Tests\Models\DDC117\DDC117Reference r WHERE r.source = s)', - 'SELECT d0_.article_id AS article_id_0, d0_.title AS title_1 FROM DDC117Article d0_ WHERE EXISTS (SELECT d1_.source_id, d1_.target_id FROM DDC117Reference d1_ WHERE d1_.source_id = d0_.article_id)' + 'SELECT d0_.article_id AS article_id_0, d0_.title AS title_1 FROM DDC117Article d0_ WHERE EXISTS (SELECT d1_.source_id, d1_.target_id FROM DDC117Reference d1_ WHERE d1_.source_id = d0_.article_id)', ); } - /** - * @group DDC-1474 - */ + /** @group DDC-1474 */ public function testSelectWithArithmeticExpressionBeforeField(): void { $this->assertSqlGeneration( 'SELECT - e.value AS value, e.id FROM ' . __NAMESPACE__ . '\DDC1474Entity e', - 'SELECT -d0_.value AS sclr_0, d0_.id AS id_1 FROM DDC1474Entity d0_' + 'SELECT -d0_.value AS sclr_0, d0_.id AS id_1 FROM DDC1474Entity d0_', ); $this->assertSqlGeneration( 'SELECT e.id, + e.value AS value FROM ' . __NAMESPACE__ . '\DDC1474Entity e', - 'SELECT d0_.id AS id_0, +d0_.value AS sclr_1 FROM DDC1474Entity d0_' + 'SELECT d0_.id AS id_0, +d0_.value AS sclr_1 FROM DDC1474Entity d0_', ); } - /** - * @group DDC-1430 - */ + /** @group DDC-1430 */ public function testGroupByAllFieldsWhenObjectHasForeignKeys(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ GROUP BY c0_.id, c0_.status, c0_.username, c0_.name, c0_.email_id' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ GROUP BY c0_.id, c0_.status, c0_.username, c0_.name, c0_.email_id', ); $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\CMS\CmsEmployee e GROUP BY e', - 'SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_employees c0_ GROUP BY c0_.id, c0_.name, c0_.spouse_id' + 'SELECT c0_.id AS id_0, c0_.name AS name_1 FROM cms_employees c0_ GROUP BY c0_.id, c0_.name, c0_.spouse_id', ); } - /** - * @group DDC-1236 - */ + /** @group DDC-1236 */ public function testGroupBySupportsResultVariable(): void { $this->assertSqlGeneration( 'SELECT u, u.status AS st FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY st', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.status AS status_4 FROM cms_users c0_ GROUP BY c0_.status' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, c0_.status AS status_4 FROM cms_users c0_ GROUP BY c0_.status', ); } - /** - * @group DDC-1236 - */ + /** @group DDC-1236 */ public function testGroupBySupportsIdentificationVariable(): void { $this->assertSqlGeneration( 'SELECT u AS user FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY user', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ GROUP BY id_0, status_1, username_2, name_3' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ GROUP BY id_0, status_1, username_2, name_3', ); } - /** - * @group DDC-1213 - */ + /** @group DDC-1213 */ public function testSupportsBitComparison(): void { $this->assertSqlGeneration( 'SELECT BIT_OR(4,2), BIT_AND(4,2), u FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT (4 | 2) AS sclr_0, (4 & 2) AS sclr_1, c0_.id AS id_2, c0_.status AS status_3, c0_.username AS username_4, c0_.name AS name_5 FROM cms_users c0_' + 'SELECT (4 | 2) AS sclr_0, (4 & 2) AS sclr_1, c0_.id AS id_2, c0_.status AS status_3, c0_.username AS username_4, c0_.name AS name_5 FROM cms_users c0_', ); $this->assertSqlGeneration( 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_OR(u.id,2) > 0', - 'SELECT (c0_.id | 2) AS sclr_0, (c0_.id & 2) AS sclr_1 FROM cms_users c0_ WHERE (c0_.id | 2) > 0' + 'SELECT (c0_.id | 2) AS sclr_0, (c0_.id & 2) AS sclr_1 FROM cms_users c0_ WHERE (c0_.id | 2) > 0', ); $this->assertSqlGeneration( 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_AND(u.id , 4) > 0', - 'SELECT (c0_.id | 2) AS sclr_0, (c0_.id & 2) AS sclr_1 FROM cms_users c0_ WHERE (c0_.id & 4) > 0' + 'SELECT (c0_.id | 2) AS sclr_0, (c0_.id & 2) AS sclr_1 FROM cms_users c0_ WHERE (c0_.id & 4) > 0', ); $this->assertSqlGeneration( 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_OR(u.id , 2) > 0 OR BIT_AND(u.id , 4) > 0', - 'SELECT (c0_.id | 2) AS sclr_0, (c0_.id & 2) AS sclr_1 FROM cms_users c0_ WHERE (c0_.id | 2) > 0 OR (c0_.id & 4) > 0' + 'SELECT (c0_.id | 2) AS sclr_0, (c0_.id & 2) AS sclr_1 FROM cms_users c0_ WHERE (c0_.id | 2) > 0 OR (c0_.id & 4) > 0', ); } - /** - * @group DDC-1539 - */ + /** @group DDC-1539 */ public function testParenthesesOnTheLeftHandOfComparison(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where ( (u.id + u.id) * u.id ) > 100', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE ((c0_.id + c0_.id) * c0_.id) > 100' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE ((c0_.id + c0_.id) * c0_.id) > 100', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where (u.id + u.id) * u.id > 100', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (c0_.id + c0_.id) * c0_.id > 100' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE (c0_.id + c0_.id) * c0_.id > 100', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where 100 < (u.id + u.id) * u.id ', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE 100 < (c0_.id + c0_.id) * c0_.id' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE 100 < (c0_.id + c0_.id) * c0_.id', ); } @@ -1751,115 +1661,109 @@ public function testSupportsParenthesisExpressionInSubSelect(): void { $this->assertSqlGeneration( 'SELECT u.id, (SELECT (1000*SUM(subU.id)/SUM(subU.id)) FROM Doctrine\Tests\Models\CMS\CmsUser subU where subU.id = u.id) AS subSelect FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT c0_.id AS id_0, (SELECT (1000 * SUM(c1_.id) / SUM(c1_.id)) FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_1 FROM cms_users c0_' + 'SELECT c0_.id AS id_0, (SELECT (1000 * SUM(c1_.id) / SUM(c1_.id)) FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr_1 FROM cms_users c0_', ); } - /** - * @group DDC-1557 - */ + /** @group DDC-1557 */ public function testSupportsSubSqlFunction(): void { $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.name IN ( SELECT TRIM(u2.name) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr_4 FROM cms_users c1_)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr_4 FROM cms_users c1_)', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.name IN ( SELECT TRIM(u2.name) FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE LOWER(u2.name) LIKE \'%fabio%\')', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr_4 FROM cms_users c1_ WHERE LOWER(c1_.name) LIKE \'%fabio%\')' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.name IN (SELECT TRIM(c1_.name) AS sclr_4 FROM cms_users c1_ WHERE LOWER(c1_.name) LIKE \'%fabio%\')', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.email IN ( SELECT TRIM(IDENTITY(u2.email)) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT TRIM(c1_.email_id) AS sclr_4 FROM cms_users c1_)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT TRIM(c1_.email_id) AS sclr_4 FROM cms_users c1_)', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE u1.email IN ( SELECT IDENTITY(u2.email) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT c1_.email_id AS sclr_4 FROM cms_users c1_)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.email_id IN (SELECT c1_.email_id AS sclr_4 FROM cms_users c1_)', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE COUNT(u1.id) = ( SELECT SUM(u2.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COUNT(c0_.id) = (SELECT SUM(c1_.id) AS sclr_4 FROM cms_users c1_)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COUNT(c0_.id) = (SELECT SUM(c1_.id) AS sclr_4 FROM cms_users c1_)', ); $this->assertSqlGeneration( 'SELECT u1 FROM Doctrine\Tests\Models\CMS\CmsUser u1 WHERE COUNT(u1.id) <= ( SELECT SUM(u2.id) + COUNT(u2.email) FROM Doctrine\Tests\Models\CMS\CmsUser u2 )', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COUNT(c0_.id) <= (SELECT SUM(c1_.id) + COUNT(c1_.email_id) AS sclr_4 FROM cms_users c1_)' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COUNT(c0_.id) <= (SELECT SUM(c1_.id) + COUNT(c1_.email_id) AS sclr_4 FROM cms_users c1_)', ); } - /** - * @group DDC-1574 - */ + /** @group DDC-1574 */ public function testSupportsNewOperator(): void { $this->assertSqlGeneration( 'SELECT new Doctrine\Tests\Models\CMS\CmsUserDTO(u.name, e.email, a.city) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e JOIN u.address a', - 'SELECT c0_.name AS sclr_0, c1_.email AS sclr_1, c2_.city AS sclr_2 FROM cms_users c0_ INNER JOIN cms_emails c1_ ON c0_.email_id = c1_.id INNER JOIN cms_addresses c2_ ON c0_.id = c2_.user_id' + 'SELECT c0_.name AS sclr_0, c1_.email AS sclr_1, c2_.city AS sclr_2 FROM cms_users c0_ INNER JOIN cms_emails c1_ ON c0_.email_id = c1_.id INNER JOIN cms_addresses c2_ ON c0_.id = c2_.user_id', ); $this->assertSqlGeneration( 'SELECT new Doctrine\Tests\Models\CMS\CmsUserDTO(u.name, e.email, a.id + u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e JOIN u.address a', - 'SELECT c0_.name AS sclr_0, c1_.email AS sclr_1, c2_.id + c0_.id AS sclr_2 FROM cms_users c0_ INNER JOIN cms_emails c1_ ON c0_.email_id = c1_.id INNER JOIN cms_addresses c2_ ON c0_.id = c2_.user_id' + 'SELECT c0_.name AS sclr_0, c1_.email AS sclr_1, c2_.id + c0_.id AS sclr_2 FROM cms_users c0_ INNER JOIN cms_emails c1_ ON c0_.email_id = c1_.id INNER JOIN cms_addresses c2_ ON c0_.id = c2_.user_id', ); $this->assertSqlGeneration( 'SELECT new Doctrine\Tests\Models\CMS\CmsUserDTO(u.name, e.email, a.city, COUNT(p)) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e JOIN u.address a JOIN u.phonenumbers p', - 'SELECT c0_.name AS sclr_0, c1_.email AS sclr_1, c2_.city AS sclr_2, COUNT(c3_.phonenumber) AS sclr_3 FROM cms_users c0_ INNER JOIN cms_emails c1_ ON c0_.email_id = c1_.id INNER JOIN cms_addresses c2_ ON c0_.id = c2_.user_id INNER JOIN cms_phonenumbers c3_ ON c0_.id = c3_.user_id' + 'SELECT c0_.name AS sclr_0, c1_.email AS sclr_1, c2_.city AS sclr_2, COUNT(c3_.phonenumber) AS sclr_3 FROM cms_users c0_ INNER JOIN cms_emails c1_ ON c0_.email_id = c1_.id INNER JOIN cms_addresses c2_ ON c0_.id = c2_.user_id INNER JOIN cms_phonenumbers c3_ ON c0_.id = c3_.user_id', ); $this->assertSqlGeneration( 'SELECT new Doctrine\Tests\Models\CMS\CmsUserDTO(u.name, e.email, a.city, COUNT(p) + u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e JOIN u.address a JOIN u.phonenumbers p', - 'SELECT c0_.name AS sclr_0, c1_.email AS sclr_1, c2_.city AS sclr_2, COUNT(c3_.phonenumber) + c0_.id AS sclr_3 FROM cms_users c0_ INNER JOIN cms_emails c1_ ON c0_.email_id = c1_.id INNER JOIN cms_addresses c2_ ON c0_.id = c2_.user_id INNER JOIN cms_phonenumbers c3_ ON c0_.id = c3_.user_id' + 'SELECT c0_.name AS sclr_0, c1_.email AS sclr_1, c2_.city AS sclr_2, COUNT(c3_.phonenumber) + c0_.id AS sclr_3 FROM cms_users c0_ INNER JOIN cms_emails c1_ ON c0_.email_id = c1_.id INNER JOIN cms_addresses c2_ ON c0_.id = c2_.user_id INNER JOIN cms_phonenumbers c3_ ON c0_.id = c3_.user_id', ); $this->assertSqlGeneration( 'SELECT new Doctrine\Tests\Models\CMS\CmsUserDTO(a.id, a.country, a.city), new Doctrine\Tests\Models\CMS\CmsAddressDTO(u.name, e.email) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e JOIN u.address a ORDER BY u.name', - 'SELECT c0_.id AS sclr_0, c0_.country AS sclr_1, c0_.city AS sclr_2, c1_.name AS sclr_3, c2_.email AS sclr_4 FROM cms_users c1_ INNER JOIN cms_emails c2_ ON c1_.email_id = c2_.id INNER JOIN cms_addresses c0_ ON c1_.id = c0_.user_id ORDER BY c1_.name ASC' + 'SELECT c0_.id AS sclr_0, c0_.country AS sclr_1, c0_.city AS sclr_2, c1_.name AS sclr_3, c2_.email AS sclr_4 FROM cms_users c1_ INNER JOIN cms_emails c2_ ON c1_.email_id = c2_.id INNER JOIN cms_addresses c0_ ON c1_.id = c0_.user_id ORDER BY c1_.name ASC', ); $this->assertSqlGeneration( 'SELECT new Doctrine\Tests\Models\CMS\CmsUserDTO(a.id, (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser su), a.country, a.city), new Doctrine\Tests\Models\CMS\CmsAddressDTO(u.name, e.email) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e JOIN u.address a ORDER BY u.name', - 'SELECT c0_.id AS sclr_0, (SELECT 1 AS sclr_2 FROM cms_users c1_) AS sclr_1, c0_.country AS sclr_3, c0_.city AS sclr_4, c2_.name AS sclr_5, c3_.email AS sclr_6 FROM cms_users c2_ INNER JOIN cms_emails c3_ ON c2_.email_id = c3_.id INNER JOIN cms_addresses c0_ ON c2_.id = c0_.user_id ORDER BY c2_.name ASC' + 'SELECT c0_.id AS sclr_0, (SELECT 1 AS sclr_2 FROM cms_users c1_) AS sclr_1, c0_.country AS sclr_3, c0_.city AS sclr_4, c2_.name AS sclr_5, c3_.email AS sclr_6 FROM cms_users c2_ INNER JOIN cms_emails c3_ ON c2_.email_id = c3_.id INNER JOIN cms_addresses c0_ ON c2_.id = c0_.user_id ORDER BY c2_.name ASC', ); } - /** - * @group DDC-2234 - */ + /** @group DDC-2234 */ public function testWhereFunctionIsNullComparisonExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE IDENTITY(u.email) IS NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.email_id IS NULL' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.email_id IS NULL', ); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NULLIF(u.name, 'FabioBatSilva') IS NULL AND IDENTITY(u.email) IS NOT NULL", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE NULLIF(c0_.name, 'FabioBatSilva') IS NULL AND c0_.email_id IS NOT NULL" + "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE NULLIF(c0_.name, 'FabioBatSilva') IS NULL AND c0_.email_id IS NOT NULL", ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE IDENTITY(u.email) IS NOT NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.email_id IS NOT NULL' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE c0_.email_id IS NOT NULL', ); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NULLIF(u.name, 'FabioBatSilva') IS NOT NULL", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE NULLIF(c0_.name, 'FabioBatSilva') IS NOT NULL" + "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE NULLIF(c0_.name, 'FabioBatSilva') IS NOT NULL", ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE COALESCE(u.name, u.id) IS NOT NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COALESCE(c0_.name, c0_.id) IS NOT NULL' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COALESCE(c0_.name, c0_.id) IS NOT NULL', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE COALESCE(u.id, IDENTITY(u.email)) IS NOT NULL', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COALESCE(c0_.id, c0_.email_id) IS NOT NULL' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COALESCE(c0_.id, c0_.email_id) IS NOT NULL', ); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE COALESCE(IDENTITY(u.email), NULLIF(u.name, 'FabioBatSilva')) IS NOT NULL", - "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COALESCE(c0_.email_id, NULLIF(c0_.name, 'FabioBatSilva')) IS NOT NULL" + "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ WHERE COALESCE(c0_.email_id, NULLIF(c0_.name, 'FabioBatSilva')) IS NOT NULL", ); } @@ -1873,7 +1777,7 @@ public function testCustomTypeValueSql(): void $this->assertSqlGeneration( 'SELECT p.customInteger FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p WHERE p.id = 1', - 'SELECT -(c0_.customInteger) AS customInteger_0 FROM customtype_parents c0_ WHERE c0_.id = 1' + 'SELECT -(c0_.customInteger) AS customInteger_0 FROM customtype_parents c0_ WHERE c0_.id = 1', ); } @@ -1887,7 +1791,7 @@ public function testCustomTypeValueSqlIgnoresIdentifierColumn(): void $this->assertSqlGeneration( 'SELECT p.id FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p WHERE p.id = 1', - 'SELECT c0_.id AS id_0 FROM customtype_parents c0_ WHERE c0_.id = 1' + 'SELECT c0_.id AS id_0 FROM customtype_parents c0_ WHERE c0_.id = 1', ); } @@ -1901,7 +1805,7 @@ public function testCustomTypeValueSqlForAllFields(): void $this->assertSqlGeneration( 'SELECT p FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', - 'SELECT c0_.id AS id_0, -(c0_.customInteger) AS customInteger_1 FROM customtype_parents c0_' + 'SELECT c0_.id AS id_0, -(c0_.customInteger) AS customInteger_1 FROM customtype_parents c0_', ); } @@ -1915,37 +1819,33 @@ public function testCustomTypeValueSqlForPartialObject(): void $this->assertSqlGeneration( 'SELECT partial p.{id, customInteger} FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', - 'SELECT c0_.id AS id_0, -(c0_.customInteger) AS customInteger_1 FROM customtype_parents c0_' + 'SELECT c0_.id AS id_0, -(c0_.customInteger) AS customInteger_1 FROM customtype_parents c0_', ); } - /** - * @group DDC-1529 - */ + /** @group DDC-1529 */ public function testMultipleFromAndInheritanceCondition(): void { $this->assertSqlGeneration( 'SELECT fix, flex FROM Doctrine\Tests\Models\Company\CompanyFixContract fix, Doctrine\Tests\Models\Company\CompanyFlexContract flex', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c1_.id AS id_3, c1_.completed AS completed_4, c1_.hoursWorked AS hoursWorked_5, c1_.pricePerHour AS pricePerHour_6, c1_.maxPrice AS maxPrice_7, c0_.discr AS discr_8, c1_.discr AS discr_9 FROM company_contracts c0_, company_contracts c1_ WHERE (c0_.discr IN ('fix') AND c1_.discr IN ('flexible', 'flexultra'))" + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c1_.id AS id_3, c1_.completed AS completed_4, c1_.hoursWorked AS hoursWorked_5, c1_.pricePerHour AS pricePerHour_6, c1_.maxPrice AS maxPrice_7, c0_.discr AS discr_8, c1_.discr AS discr_9 FROM company_contracts c0_, company_contracts c1_ WHERE (c0_.discr IN ('fix') AND c1_.discr IN ('flexible', 'flexultra'))", ); } - /** - * @group DDC-775 - */ + /** @group DDC-775 */ public function testOrderByClauseSupportsSimpleArithmeticExpression(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.id + 1 ', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY c0_.id + 1 ASC' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY c0_.id + 1 ASC', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY ( ( (u.id + 1) * (u.id - 1) ) / 2)', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY (((c0_.id + 1) * (c0_.id - 1)) / 2) ASC' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY (((c0_.id + 1) * (c0_.id - 1)) / 2) ASC', ); $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY ((u.id + 5000) * u.id + 3) ', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY ((c0_.id + 5000) * c0_.id + 3) ASC' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY ((c0_.id + 5000) * c0_.id + 3) ASC', ); } @@ -1953,275 +1853,243 @@ public function testOrderByClauseSupportsFunction(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY CONCAT(u.username, u.name) ', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY c0_.username || c0_.name ASC' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 FROM cms_users c0_ ORDER BY c0_.username || c0_.name ASC', ); } - /** - * @group DDC-1719 - */ + /** @group DDC-1719 */ public function testStripNonAlphanumericCharactersFromAlias(): void { $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity e', - 'SELECT n0_."simple-entity-id" AS simpleentityid_0, n0_."simple-entity-value" AS simpleentityvalue_1 FROM "not-a-simple-entity" n0_' + 'SELECT n0_."simple-entity-id" AS simpleentityid_0, n0_."simple-entity-value" AS simpleentityvalue_1 FROM "not-a-simple-entity" n0_', ); $this->assertSqlGeneration( 'SELECT e.value FROM Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity e ORDER BY e.value', - 'SELECT n0_."simple-entity-value" AS simpleentityvalue_0 FROM "not-a-simple-entity" n0_ ORDER BY n0_."simple-entity-value" ASC' + 'SELECT n0_."simple-entity-value" AS simpleentityvalue_0 FROM "not-a-simple-entity" n0_ ORDER BY n0_."simple-entity-value" ASC', ); $this->assertSqlGeneration( 'SELECT TRIM(e.value) FROM Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity e ORDER BY e.value', - 'SELECT TRIM(n0_."simple-entity-value") AS sclr_0 FROM "not-a-simple-entity" n0_ ORDER BY n0_."simple-entity-value" ASC' + 'SELECT TRIM(n0_."simple-entity-value") AS sclr_0 FROM "not-a-simple-entity" n0_ ORDER BY n0_."simple-entity-value" ASC', ); } - /** - * @group DDC-2435 - */ + /** @group DDC-2435 */ public function testColumnNameWithNumbersAndNonAlphanumericCharacters(): void { $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Quote\NumericEntity e', - 'SELECT t0_."1:1" AS 11_0, t0_."2:2" AS 22_1 FROM table t0_' + 'SELECT t0_."1:1" AS 11_0, t0_."2:2" AS 22_1 FROM table t0_', ); $this->assertSqlGeneration( 'SELECT e.value FROM Doctrine\Tests\Models\Quote\NumericEntity e', - 'SELECT t0_."2:2" AS 22_0 FROM table t0_' + 'SELECT t0_."2:2" AS 22_0 FROM table t0_', ); $this->assertSqlGeneration( 'SELECT TRIM(e.value) FROM Doctrine\Tests\Models\Quote\NumericEntity e', - 'SELECT TRIM(t0_."2:2") AS sclr_0 FROM table t0_' + 'SELECT TRIM(t0_."2:2") AS sclr_0 FROM table t0_', ); } - /** - * @group DDC-1845 - */ + /** @group DDC-1845 */ public function testQuotedTableDeclaration(): void { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\Quote\User u', - 'SELECT q0_."user-id" AS userid_0, q0_."user-name" AS username_1 FROM "quote-user" q0_' + 'SELECT q0_."user-id" AS userid_0, q0_."user-name" AS username_1 FROM "quote-user" q0_', ); } - /** - * @group DDC-1845 - */ + /** @group DDC-1845 */ public function testQuotedWalkJoinVariableDeclaration(): void { $this->assertSqlGeneration( 'SELECT u, a FROM Doctrine\Tests\Models\Quote\User u JOIN u.address a', - 'SELECT q0_."user-id" AS userid_0, q0_."user-name" AS username_1, q1_."address-id" AS addressid_2, q1_."address-zip" AS addresszip_3, q1_.type AS type_4 FROM "quote-user" q0_ INNER JOIN "quote-address" q1_ ON q0_."address-id" = q1_."address-id" AND q1_.type IN (\'simple\', \'full\')' + 'SELECT q0_."user-id" AS userid_0, q0_."user-name" AS username_1, q1_."address-id" AS addressid_2, q1_."address-zip" AS addresszip_3, q1_.type AS type_4 FROM "quote-user" q0_ INNER JOIN "quote-address" q1_ ON q0_."address-id" = q1_."address-id" AND q1_.type IN (\'simple\', \'full\')', ); $this->assertSqlGeneration( 'SELECT u, p FROM Doctrine\Tests\Models\Quote\User u JOIN u.phones p', - 'SELECT q0_."user-id" AS userid_0, q0_."user-name" AS username_1, q1_."phone-number" AS phonenumber_2 FROM "quote-user" q0_ INNER JOIN "quote-phone" q1_ ON q0_."user-id" = q1_."user-id"' + 'SELECT q0_."user-id" AS userid_0, q0_."user-name" AS username_1, q1_."phone-number" AS phonenumber_2 FROM "quote-user" q0_ INNER JOIN "quote-phone" q1_ ON q0_."user-id" = q1_."user-id"', ); $this->assertSqlGeneration( 'SELECT u, g FROM Doctrine\Tests\Models\Quote\User u JOIN u.groups g', - 'SELECT q0_."user-id" AS userid_0, q0_."user-name" AS username_1, q1_."group-id" AS groupid_2, q1_."group-name" AS groupname_3 FROM "quote-user" q0_ INNER JOIN "quote-users-groups" q2_ ON q0_."user-id" = q2_."user-id" INNER JOIN "quote-group" q1_ ON q1_."group-id" = q2_."group-id"' + 'SELECT q0_."user-id" AS userid_0, q0_."user-name" AS username_1, q1_."group-id" AS groupid_2, q1_."group-name" AS groupname_3 FROM "quote-user" q0_ INNER JOIN "quote-users-groups" q2_ ON q0_."user-id" = q2_."user-id" INNER JOIN "quote-group" q1_ ON q1_."group-id" = q2_."group-id"', ); $this->assertSqlGeneration( 'SELECT a, u FROM Doctrine\Tests\Models\Quote\Address a JOIN a.user u', - 'SELECT q0_."address-id" AS addressid_0, q0_."address-zip" AS addresszip_1, q1_."user-id" AS userid_2, q1_."user-name" AS username_3, q0_.type AS type_4 FROM "quote-address" q0_ INNER JOIN "quote-user" q1_ ON q0_."user-id" = q1_."user-id" WHERE q0_.type IN (\'simple\', \'full\')' + 'SELECT q0_."address-id" AS addressid_0, q0_."address-zip" AS addresszip_1, q1_."user-id" AS userid_2, q1_."user-name" AS username_3, q0_.type AS type_4 FROM "quote-address" q0_ INNER JOIN "quote-user" q1_ ON q0_."user-id" = q1_."user-id" WHERE q0_.type IN (\'simple\', \'full\')', ); $this->assertSqlGeneration( 'SELECT g, u FROM Doctrine\Tests\Models\Quote\Group g JOIN g.users u', - 'SELECT q0_."group-id" AS groupid_0, q0_."group-name" AS groupname_1, q1_."user-id" AS userid_2, q1_."user-name" AS username_3 FROM "quote-group" q0_ INNER JOIN "quote-users-groups" q2_ ON q0_."group-id" = q2_."group-id" INNER JOIN "quote-user" q1_ ON q1_."user-id" = q2_."user-id"' + 'SELECT q0_."group-id" AS groupid_0, q0_."group-name" AS groupname_1, q1_."user-id" AS userid_2, q1_."user-name" AS username_3 FROM "quote-group" q0_ INNER JOIN "quote-users-groups" q2_ ON q0_."group-id" = q2_."group-id" INNER JOIN "quote-user" q1_ ON q1_."user-id" = q2_."user-id"', ); $this->assertSqlGeneration( 'SELECT g, p FROM Doctrine\Tests\Models\Quote\Group g JOIN g.parent p', - 'SELECT q0_."group-id" AS groupid_0, q0_."group-name" AS groupname_1, q1_."group-id" AS groupid_2, q1_."group-name" AS groupname_3 FROM "quote-group" q0_ INNER JOIN "quote-group" q1_ ON q0_."parent-id" = q1_."group-id"' + 'SELECT q0_."group-id" AS groupid_0, q0_."group-name" AS groupname_1, q1_."group-id" AS groupid_2, q1_."group-name" AS groupname_3 FROM "quote-group" q0_ INNER JOIN "quote-group" q1_ ON q0_."parent-id" = q1_."group-id"', ); } - /** - * @group DDC-2208 - */ + /** @group DDC-2208 */ public function testCaseThenParameterArithmeticExpression(): void { $this->assertSqlGeneration( 'SELECT SUM(CASE WHEN e.salary <= :value THEN e.salary - :value WHEN e.salary >= :value THEN :value - e.salary ELSE 0 END) FROM Doctrine\Tests\Models\Company\CompanyEmployee e', - 'SELECT SUM(CASE WHEN c0_.salary <= ? THEN c0_.salary - ? WHEN c0_.salary >= ? THEN ? - c0_.salary ELSE 0 END) AS sclr_0 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id' + 'SELECT SUM(CASE WHEN c0_.salary <= ? THEN c0_.salary - ? WHEN c0_.salary >= ? THEN ? - c0_.salary ELSE 0 END) AS sclr_0 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id', ); $this->assertSqlGeneration( 'SELECT SUM(CASE WHEN e.salary <= :value THEN e.salary - :value WHEN e.salary >= :value THEN :value - e.salary ELSE e.salary + 0 END) FROM Doctrine\Tests\Models\Company\CompanyEmployee e', - 'SELECT SUM(CASE WHEN c0_.salary <= ? THEN c0_.salary - ? WHEN c0_.salary >= ? THEN ? - c0_.salary ELSE c0_.salary + 0 END) AS sclr_0 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id' + 'SELECT SUM(CASE WHEN c0_.salary <= ? THEN c0_.salary - ? WHEN c0_.salary >= ? THEN ? - c0_.salary ELSE c0_.salary + 0 END) AS sclr_0 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id', ); $this->assertSqlGeneration( 'SELECT SUM(CASE WHEN e.salary <= :value THEN (e.salary - :value) WHEN e.salary >= :value THEN (:value - e.salary) ELSE (e.salary + :value) END) FROM Doctrine\Tests\Models\Company\CompanyEmployee e', - 'SELECT SUM(CASE WHEN c0_.salary <= ? THEN (c0_.salary - ?) WHEN c0_.salary >= ? THEN (? - c0_.salary) ELSE (c0_.salary + ?) END) AS sclr_0 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id' + 'SELECT SUM(CASE WHEN c0_.salary <= ? THEN (c0_.salary - ?) WHEN c0_.salary >= ? THEN (? - c0_.salary) ELSE (c0_.salary + ?) END) AS sclr_0 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id', ); } - /** - * @group DDC-2268 - */ + /** @group DDC-2268 */ public function testCaseThenFunction(): void { $this->assertSqlGeneration( 'SELECT CASE WHEN LENGTH(u.name) <> 0 THEN CONCAT(u.id, u.name) ELSE u.id END AS name FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT CASE WHEN LENGTH(c0_.name) <> 0 THEN c0_.id || c0_.name ELSE c0_.id END AS sclr_0 FROM cms_users c0_' + 'SELECT CASE WHEN LENGTH(c0_.name) <> 0 THEN c0_.id || c0_.name ELSE c0_.id END AS sclr_0 FROM cms_users c0_', ); $this->assertSqlGeneration( 'SELECT CASE WHEN LENGTH(u.name) <> LENGTH(TRIM(u.name)) THEN TRIM(u.name) ELSE u.name END AS name FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT CASE WHEN LENGTH(c0_.name) <> LENGTH(TRIM(c0_.name)) THEN TRIM(c0_.name) ELSE c0_.name END AS sclr_0 FROM cms_users c0_' + 'SELECT CASE WHEN LENGTH(c0_.name) <> LENGTH(TRIM(c0_.name)) THEN TRIM(c0_.name) ELSE c0_.name END AS sclr_0 FROM cms_users c0_', ); $this->assertSqlGeneration( 'SELECT CASE WHEN LENGTH(u.name) > :value THEN SUBSTRING(u.name, 0, :value) ELSE TRIM(u.name) END AS name FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT CASE WHEN LENGTH(c0_.name) > ? THEN SUBSTRING(c0_.name FROM 0 FOR ?) ELSE TRIM(c0_.name) END AS sclr_0 FROM cms_users c0_' + 'SELECT CASE WHEN LENGTH(c0_.name) > ? THEN SUBSTRING(c0_.name FROM 0 FOR ?) ELSE TRIM(c0_.name) END AS sclr_0 FROM cms_users c0_', ); } - /** - * @group DDC-2268 - */ + /** @group DDC-2268 */ public function testSupportsMoreThanTwoParametersInConcatFunction(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1", - "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE CONCAT(c0_.name, c0_.status, 's') = ?" + "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE CONCAT(c0_.name, c0_.status, 's') = ?", ); $this->assertSqlGeneration( 'SELECT CONCAT(u.id, u.name, u.status) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', - 'SELECT CONCAT(c0_.id, c0_.name, c0_.status) AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?' + 'SELECT CONCAT(c0_.id, c0_.name, c0_.status) AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?', ); } - /** - * @group DDC-2188 - */ + /** @group DDC-2188 */ public function testArithmeticPriority(): void { $this->assertSqlGeneration( 'SELECT 100/(2*2) FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT 100 / (2 * 2) AS sclr_0 FROM cms_users c0_' + 'SELECT 100 / (2 * 2) AS sclr_0 FROM cms_users c0_', ); $this->assertSqlGeneration( 'SELECT (u.id / (u.id * 2)) FROM Doctrine\Tests\Models\CMS\CmsUser u', - 'SELECT (c0_.id / (c0_.id * 2)) AS sclr_0 FROM cms_users c0_' + 'SELECT (c0_.id / (c0_.id * 2)) AS sclr_0 FROM cms_users c0_', ); $this->assertSqlGeneration( 'SELECT 100/(2*2) + (u.id / (u.id * 2)) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id / (u.id * 2)) > 0', - 'SELECT 100 / (2 * 2) + (c0_.id / (c0_.id * 2)) AS sclr_0 FROM cms_users c0_ WHERE (c0_.id / (c0_.id * 2)) > 0' + 'SELECT 100 / (2 * 2) + (c0_.id / (c0_.id * 2)) AS sclr_0 FROM cms_users c0_ WHERE (c0_.id / (c0_.id * 2)) > 0', ); } - /** - * @group DDC-2475 - */ + /** @group DDC-2475 */ public function testOrderByClauseShouldReplaceOrderByRelationMapping(): void { $this->assertSqlGeneration( 'SELECT r, b FROM Doctrine\Tests\Models\Routing\RoutingRoute r JOIN r.bookings b', - 'SELECT r0_.id AS id_0, r1_.id AS id_1, r1_.passengerName AS passengerName_2 FROM RoutingRoute r0_ INNER JOIN RoutingRouteBooking r1_ ON r0_.id = r1_.route_id ORDER BY r1_.passengerName ASC' + 'SELECT r0_.id AS id_0, r1_.id AS id_1, r1_.passengerName AS passengerName_2 FROM RoutingRoute r0_ INNER JOIN RoutingRouteBooking r1_ ON r0_.id = r1_.route_id ORDER BY r1_.passengerName ASC', ); $this->assertSqlGeneration( 'SELECT r, b FROM Doctrine\Tests\Models\Routing\RoutingRoute r JOIN r.bookings b ORDER BY b.passengerName DESC', - 'SELECT r0_.id AS id_0, r1_.id AS id_1, r1_.passengerName AS passengerName_2 FROM RoutingRoute r0_ INNER JOIN RoutingRouteBooking r1_ ON r0_.id = r1_.route_id ORDER BY r1_.passengerName DESC' + 'SELECT r0_.id AS id_0, r1_.id AS id_1, r1_.passengerName AS passengerName_2 FROM RoutingRoute r0_ INNER JOIN RoutingRouteBooking r1_ ON r0_.id = r1_.route_id ORDER BY r1_.passengerName DESC', ); } - /** - * @group DDC-1858 - */ + /** @group DDC-1858 */ public function testHavingSupportIsNullExpression(): void { $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING c0_.username IS NULL' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING c0_.username IS NULL', ); $this->assertSqlGeneration( 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING MAX(u.name) IS NULL', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING MAX(c0_.name) IS NULL' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING MAX(c0_.name) IS NULL', ); } - /** - * @group DDC-2506 - */ + /** @group DDC-2506 */ public function testClassTableInheritanceJoinWithConditionAppliesToBaseTable(): void { $this->assertSqlGeneration( 'SELECT e.id FROM Doctrine\Tests\Models\Company\CompanyOrganization o JOIN o.events e WITH e.id = ?1', 'SELECT c0_.id AS id_0 FROM company_organizations c1_ INNER JOIN (company_events c0_ LEFT JOIN company_auctions c2_ ON c0_.id = c2_.id LEFT JOIN company_raffles c3_ ON c0_.id = c3_.id) ON c1_.id = c0_.org_id AND (c0_.id = ?)', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false] + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } - /** - * @group DDC-2235 - */ + /** @group DDC-2235 */ public function testSingleTableInheritanceLeftJoinWithCondition(): void { // Regression test for the bug $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyEmployee e LEFT JOIN Doctrine\Tests\Models\Company\CompanyContract c WITH c.salesPerson = e.id', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_employees c1_ INNER JOIN company_persons c2_ ON c1_.id = c2_.id LEFT JOIN company_contracts c0_ ON (c0_.salesPerson_id = c2_.id) AND c0_.discr IN ('fix', 'flexible', 'flexultra')" + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_employees c1_ INNER JOIN company_persons c2_ ON c1_.id = c2_.id LEFT JOIN company_contracts c0_ ON (c0_.salesPerson_id = c2_.id) AND c0_.discr IN ('fix', 'flexible', 'flexultra')", ); } - /** - * @group DDC-2235 - */ + /** @group DDC-2235 */ public function testSingleTableInheritanceLeftJoinWithConditionAndWhere(): void { // Ensure other WHERE predicates are passed through to the main WHERE clause $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyEmployee e LEFT JOIN Doctrine\Tests\Models\Company\CompanyContract c WITH c.salesPerson = e.id WHERE e.salary > 1000', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_employees c1_ INNER JOIN company_persons c2_ ON c1_.id = c2_.id LEFT JOIN company_contracts c0_ ON (c0_.salesPerson_id = c2_.id) AND c0_.discr IN ('fix', 'flexible', 'flexultra') WHERE c1_.salary > 1000" + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_employees c1_ INNER JOIN company_persons c2_ ON c1_.id = c2_.id LEFT JOIN company_contracts c0_ ON (c0_.salesPerson_id = c2_.id) AND c0_.discr IN ('fix', 'flexible', 'flexultra') WHERE c1_.salary > 1000", ); } - /** - * @group DDC-2235 - */ + /** @group DDC-2235 */ public function testSingleTableInheritanceInnerJoinWithCondition(): void { // Test inner joins too $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyEmployee e INNER JOIN Doctrine\Tests\Models\Company\CompanyContract c WITH c.salesPerson = e.id', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_employees c1_ INNER JOIN company_persons c2_ ON c1_.id = c2_.id INNER JOIN company_contracts c0_ ON (c0_.salesPerson_id = c2_.id) AND c0_.discr IN ('fix', 'flexible', 'flexultra')" + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_employees c1_ INNER JOIN company_persons c2_ ON c1_.id = c2_.id INNER JOIN company_contracts c0_ ON (c0_.salesPerson_id = c2_.id) AND c0_.discr IN ('fix', 'flexible', 'flexultra')", ); } - /** - * @group DDC-2235 - */ + /** @group DDC-2235 */ public function testSingleTableInheritanceLeftJoinNonAssociationWithConditionAndWhere(): void { // Test that the discriminator IN() predicate is still added into // the where clause when not joining onto that table $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c LEFT JOIN Doctrine\Tests\Models\Company\CompanyEmployee e WITH e.id = c.salesPerson WHERE c.completed = true', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ LEFT JOIN (company_employees c1_ INNER JOIN company_persons c2_ ON c1_.id = c2_.id) ON (c2_.id = c0_.salesPerson_id) WHERE (c0_.completed = 1) AND c0_.discr IN ('fix', 'flexible', 'flexultra')" + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ LEFT JOIN (company_employees c1_ INNER JOIN company_persons c2_ ON c1_.id = c2_.id) ON (c2_.id = c0_.salesPerson_id) WHERE (c0_.completed = 1) AND c0_.discr IN ('fix', 'flexible', 'flexultra')", ); } - /** - * @group DDC-2235 - */ + /** @group DDC-2235 */ public function testSingleTableInheritanceJoinCreatesOnCondition(): void { // Test that the discriminator IN() predicate is still added @@ -2229,13 +2097,11 @@ public function testSingleTableInheritanceJoinCreatesOnCondition(): void // via a join association $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN c.salesPerson s WHERE c.completed = true', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ INNER JOIN company_employees c1_ ON c0_.salesPerson_id = c1_.id LEFT JOIN company_persons c2_ ON c1_.id = c2_.id WHERE (c0_.completed = 1) AND c0_.discr IN ('fix', 'flexible', 'flexultra')" + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ INNER JOIN company_employees c1_ ON c0_.salesPerson_id = c1_.id LEFT JOIN company_persons c2_ ON c1_.id = c2_.id WHERE (c0_.completed = 1) AND c0_.discr IN ('fix', 'flexible', 'flexultra')", ); } - /** - * @group DDC-2235 - */ + /** @group DDC-2235 */ public function testSingleTableInheritanceCreatesOnConditionAndWhere(): void { // Test that when joining onto an entity using single table inheritance via @@ -2245,51 +2111,43 @@ public function testSingleTableInheritanceCreatesOnConditionAndWhere(): void 'SELECT e, COUNT(c) FROM Doctrine\Tests\Models\Company\CompanyEmployee e JOIN e.contracts c WHERE e.department = :department', "SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, COUNT(c2_.id) AS sclr_5, c0_.discr AS discr_6 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id INNER JOIN company_contract_employees c3_ ON c1_.id = c3_.employee_id INNER JOIN company_contracts c2_ ON c2_.id = c3_.contract_id AND c2_.discr IN ('fix', 'flexible', 'flexultra') WHERE c1_.department = ?", [], - ['department' => 'foobar'] + ['department' => 'foobar'], ); } - /** - * @group DDC-1858 - */ + /** @group DDC-1858 */ public function testHavingSupportResultVariableInExpression(): void { $this->assertSqlGeneration( 'SELECT u.name AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING foo IN (?1)', - 'SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING name_0 IN (?)' + 'SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING name_0 IN (?)', ); } - /** - * @group DDC-1858 - */ + /** @group DDC-1858 */ public function testHavingSupportResultVariableLikeExpression(): void { $this->assertSqlGeneration( "SELECT u.name AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING foo LIKE '3'", - "SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING name_0 LIKE '3'" + "SELECT c0_.name AS name_0 FROM cms_users c0_ HAVING name_0 LIKE '3'", ); } - /** - * @group DDC-3085 - */ + /** @group DDC-3085 */ public function testHavingSupportResultVariableNullComparisonExpression(): void { $this->assertSqlGeneration( 'SELECT u AS user, SUM(a.id) AS score FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN Doctrine\Tests\Models\CMS\CmsAddress a WITH a.user = u GROUP BY u HAVING score IS NOT NULL AND score >= 5', - 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, SUM(c1_.id) AS sclr_4 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON (c1_.user_id = c0_.id) GROUP BY c0_.id, c0_.status, c0_.username, c0_.name, c0_.email_id HAVING sclr_4 IS NOT NULL AND sclr_4 >= 5' + 'SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3, SUM(c1_.id) AS sclr_4 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON (c1_.user_id = c0_.id) GROUP BY c0_.id, c0_.status, c0_.username, c0_.name, c0_.email_id HAVING sclr_4 IS NOT NULL AND sclr_4 >= 5', ); } - /** - * @group DDC-1858 - */ + /** @group DDC-1858 */ public function testHavingSupportResultVariableInAggregateFunction(): void { $this->assertSqlGeneration( 'SELECT COUNT(u.name) AS countName FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING countName IS NULL', - 'SELECT COUNT(c0_.name) AS sclr_0 FROM cms_users c0_ HAVING sclr_0 IS NULL' + 'SELECT COUNT(c0_.name) AS sclr_0 FROM cms_users c0_ HAVING sclr_0 IS NULL', ); } @@ -2303,13 +2161,11 @@ public function testHavingRegressionUsingVariableWithMathOperatorsExpression($op { $this->assertSqlGeneration( 'SELECT COUNT(u.name) AS countName FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING 1 ' . $operator . ' countName > 0', - 'SELECT COUNT(c0_.name) AS sclr_0 FROM cms_users c0_ HAVING 1 ' . $operator . ' sclr_0 > 0' + 'SELECT COUNT(c0_.name) AS sclr_0 FROM cms_users c0_ HAVING 1 ' . $operator . ' sclr_0 > 0', ); } - /** - * @psalm-return list - */ + /** @psalm-return list */ public function mathematicOperatorsProvider(): array { return [['+'], ['-'], ['*'], ['/']]; @@ -2338,9 +2194,7 @@ public function parse(Parser $parser): void $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } -/** - * @Entity - */ +/** @Entity */ class DDC1384Model { /** @@ -2353,9 +2207,7 @@ class DDC1384Model } -/** - * @Entity - */ +/** @Entity */ class DDC1474Entity { /** @@ -2367,10 +2219,8 @@ class DDC1474Entity protected $id; public function __construct( - /** - * @Column(type="float") - */ - private string $value + /** @Column(type="float") */ + private string $value, ) { } diff --git a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php index a66f9811e73..dd63cc9f6cb 100644 --- a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php @@ -23,22 +23,18 @@ protected function setUp(): void $this->sqlWalker = new SqlWalker(new Query($this->getTestEntityManager()), new ParserResult(), []); } - /** - * @dataProvider getColumnNamesAndSqlAliases - */ + /** @dataProvider getColumnNamesAndSqlAliases */ public function testGetSQLTableAlias($tableName, $expectedAlias): void { self::assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName)); } - /** - * @dataProvider getColumnNamesAndSqlAliases - */ + /** @dataProvider getColumnNamesAndSqlAliases */ public function testGetSQLTableAliasIsSameForMultipleCalls($tableName): void { self::assertSame( $this->sqlWalker->getSQLTableAlias($tableName), - $this->sqlWalker->getSQLTableAlias($tableName) + $this->sqlWalker->getSQLTableAlias($tableName), ); } diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php index 470dd727711..fdcc14e98f3 100644 --- a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -44,7 +44,7 @@ public function testSupportsQueriesWithoutWhere(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1', - 'UPDATE cms_users SET name = ?' + 'UPDATE cms_users SET name = ?', ); } @@ -52,7 +52,7 @@ public function testSupportsMultipleFieldsWithoutWhere(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1, u.username = ?2', - 'UPDATE cms_users SET name = ?, username = ?' + 'UPDATE cms_users SET name = ?, username = ?', ); } @@ -60,7 +60,7 @@ public function testSupportsWhereClauses(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id = ?2', - 'UPDATE cms_users SET name = ? WHERE id = ?' + 'UPDATE cms_users SET name = ? WHERE id = ?', ); } @@ -68,7 +68,7 @@ public function testSupportsWhereClausesOnTheUpdatedField(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.name = ?2', - 'UPDATE cms_users SET name = ? WHERE name = ?' + 'UPDATE cms_users SET name = ? WHERE name = ?', ); } @@ -76,7 +76,7 @@ public function testSupportsMultipleWhereClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.name = ?2 AND u.status = ?3', - 'UPDATE cms_users SET name = ? WHERE name = ? AND status = ?' + 'UPDATE cms_users SET name = ? WHERE name = ? AND status = ?', ); } @@ -84,7 +84,7 @@ public function testSupportsInClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id IN (1, 3, 4)', - 'UPDATE cms_users SET name = ? WHERE id IN (1, 3, 4)' + 'UPDATE cms_users SET name = ? WHERE id IN (1, 3, 4)', ); } @@ -92,7 +92,7 @@ public function testSupportsParametrizedInClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id IN (?2, ?3, ?4)', - 'UPDATE cms_users SET name = ? WHERE id IN (?, ?, ?)' + 'UPDATE cms_users SET name = ? WHERE id IN (?, ?, ?)', ); } @@ -100,7 +100,7 @@ public function testSupportsNotInClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id NOT IN (1, 3, 4)', - 'UPDATE cms_users SET name = ? WHERE id NOT IN (1, 3, 4)' + 'UPDATE cms_users SET name = ? WHERE id NOT IN (1, 3, 4)', ); } @@ -108,7 +108,7 @@ public function testSupportsGreaterThanClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id > ?2', - 'UPDATE cms_users SET status = ? WHERE id > ?' + 'UPDATE cms_users SET status = ? WHERE id > ?', ); } @@ -116,7 +116,7 @@ public function testSupportsGreaterThanOrEqualToClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id >= ?2', - 'UPDATE cms_users SET status = ? WHERE id >= ?' + 'UPDATE cms_users SET status = ? WHERE id >= ?', ); } @@ -124,7 +124,7 @@ public function testSupportsLessThanClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id < ?2', - 'UPDATE cms_users SET status = ? WHERE id < ?' + 'UPDATE cms_users SET status = ? WHERE id < ?', ); } @@ -132,7 +132,7 @@ public function testSupportsLessThanOrEqualToClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id <= ?2', - 'UPDATE cms_users SET status = ? WHERE id <= ?' + 'UPDATE cms_users SET status = ? WHERE id <= ?', ); } @@ -140,7 +140,7 @@ public function testSupportsBetweenClause(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id BETWEEN :from AND :to', - 'UPDATE cms_users SET status = ? WHERE id BETWEEN ? AND ?' + 'UPDATE cms_users SET status = ? WHERE id BETWEEN ? AND ?', ); } @@ -148,7 +148,7 @@ public function testSingleValuedAssociationFieldInWhere(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsPhonenumber p SET p.phonenumber = 1234 WHERE p.user = ?1', - 'UPDATE cms_phonenumbers SET phonenumber = 1234 WHERE user_id = ?' + 'UPDATE cms_phonenumbers SET phonenumber = 1234 WHERE user_id = ?', ); } @@ -156,18 +156,16 @@ public function testSingleValuedAssociationFieldInSetClause(): void { $this->assertSqlGeneration( 'update Doctrine\Tests\Models\CMS\CmsComment c set c.article = null where c.article=?1', - 'UPDATE cms_comments SET article_id = NULL WHERE article_id = ?' + 'UPDATE cms_comments SET article_id = NULL WHERE article_id = ?', ); } - /** - * @group DDC-980 - */ + /** @group DDC-980 */ public function testSubselectTableAliasReferencing(): void { $this->assertSqlGeneration( "UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = 'inactive' WHERE SIZE(u.groups) = 10", - "UPDATE cms_users SET status = 'inactive' WHERE (SELECT COUNT(*) FROM cms_users_groups c0_ WHERE c0_.user_id = cms_users.id) = 10" + "UPDATE cms_users SET status = 'inactive' WHERE (SELECT COUNT(*) FROM cms_users_groups c0_ WHERE c0_.user_id = cms_users.id) = 10", ); } @@ -175,7 +173,7 @@ public function testCustomTypeValueSqlCompletelyIgnoredInUpdateStatements(): voi { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CustomType\CustomTypeParent p SET p.customInteger = 1 WHERE p.id = 1', - 'UPDATE customtype_parents SET customInteger = 1 WHERE id = 1' + 'UPDATE customtype_parents SET customInteger = 1 WHERE id = 1', ); } @@ -183,7 +181,7 @@ public function testUpdateWithSubselectAsNewValue(): void { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\Company\CompanyFixContract fc SET fc.fixPrice = (SELECT ce2.salary FROM Doctrine\Tests\Models\Company\CompanyEmployee ce2 WHERE ce2.id = 2) WHERE fc.id = 1', - "UPDATE company_contracts SET fixPrice = (SELECT c0_.salary FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id LEFT JOIN company_managers c2_ ON c0_.id = c2_.id WHERE c1_.id = 2) WHERE (id = 1) AND discr IN ('fix')" + "UPDATE company_contracts SET fixPrice = (SELECT c0_.salary FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id LEFT JOIN company_managers c2_ ON c0_.id = c2_.id WHERE c1_.id = 2) WHERE (id = 1) AND discr IN ('fix')", ); } } diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 16c6553cfd0..727d8f0b7fa 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -134,7 +134,7 @@ public function testComplexInnerJoin(): void $this->assertValidQueryBuilder( $qb, - 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id' + 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id', ); } @@ -148,7 +148,7 @@ public function testComplexInnerJoinWithComparisonCondition(): void $this->assertValidQueryBuilder( $qb, - 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id' + 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id', ); } @@ -160,12 +160,12 @@ public function testComplexInnerJoinWithCompositeCondition(): void ->from(CmsUser::class, 'u') ->innerJoin('u.articles', 'a', Join::ON, $qb->expr()->andX( $qb->expr()->eq('u.id', 'a.author_id'), - $qb->expr()->isNotNull('u.name') + $qb->expr()->isNotNull('u.name'), )); $this->assertValidQueryBuilder( $qb, - 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id AND u.name IS NOT NULL' + 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id AND u.name IS NOT NULL', ); } @@ -178,7 +178,7 @@ public function testComplexInnerJoinWithIndexBy(): void $this->assertValidQueryBuilder( $qb, - 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INDEX BY a.name ON u.id = a.author_id' + 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INDEX BY a.name ON u.id = a.author_id', ); } @@ -460,7 +460,7 @@ public function testAddMultipleSameCriteriaWhere(): void $criteria = new Criteria(); $criteria->where($criteria->expr()->andX( $criteria->expr()->eq('field', 'value1'), - $criteria->expr()->eq('field', 'value2') + $criteria->expr()->eq('field', 'value2'), )); $qb->addCriteria($criteria); @@ -470,9 +470,7 @@ public function testAddMultipleSameCriteriaWhere(): void self::assertNotNull($qb->getParameter('field_1')); } - /** - * @group DDC-2844 - */ + /** @group DDC-2844 */ public function testAddCriteriaWhereWithMultipleParametersWithSameField(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -489,9 +487,7 @@ public function testAddCriteriaWhereWithMultipleParametersWithSameField(): void self::assertSame('value2', $qb->getParameter('field_1')->getValue()); } - /** - * @group DDC-2844 - */ + /** @group DDC-2844 */ public function testAddCriteriaWhereWithMultipleParametersWithDifferentFields(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -508,9 +504,7 @@ public function testAddCriteriaWhereWithMultipleParametersWithDifferentFields(): self::assertSame('value2', $qb->getParameter('field2')->getValue()); } - /** - * @group DDC-2844 - */ + /** @group DDC-2844 */ public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndDifferentProperties(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -527,9 +521,7 @@ public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndDiffere self::assertSame('value2', $qb->getParameter('field2')->getValue()); } - /** - * @group DDC-2844 - */ + /** @group DDC-2844 */ public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndSameProperty(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -561,9 +553,7 @@ public function testAddCriteriaOrder(): void self::assertEquals('u.field DESC', (string) $orderBy[0]); } - /** - * @group DDC-3108 - */ + /** @group DDC-3108 */ public function testAddCriteriaOrderOnJoinAlias(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -869,9 +859,7 @@ public function testResetAllDQLParts(): void self::assertCount(0, $qb->getDQLPart('orderBy')); } - /** - * @group DDC-867 - */ + /** @group DDC-867 */ public function testDeepClone(): void { $qb = $this->entityManager->createQueryBuilder() @@ -889,9 +877,7 @@ public function testDeepClone(): void self::assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); } - /** - * @group DDC-3108 - */ + /** @group DDC-3108 */ public function testAddCriteriaWhereWithJoinAlias(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -909,9 +895,7 @@ public function testAddCriteriaWhereWithJoinAlias(): void self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); } - /** - * @group DDC-3108 - */ + /** @group DDC-3108 */ public function testAddCriteriaWhereWithDefaultAndJoinAlias(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -929,9 +913,7 @@ public function testAddCriteriaWhereWithDefaultAndJoinAlias(): void self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); } - /** - * @group DDC-3108 - */ + /** @group DDC-3108 */ public function testAddCriteriaWhereOnJoinAliasWithDuplicateFields(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -951,9 +933,7 @@ public function testAddCriteriaWhereOnJoinAliasWithDuplicateFields(): void self::assertSame('value3', $qb->getParameter('alias2_field_2')->getValue()); } - /** - * @group DDC-1933 - */ + /** @group DDC-1933 */ public function testParametersAreCloned(): void { $originalQb = new QueryBuilder($this->entityManager); @@ -1016,9 +996,7 @@ public function testBCAddJoinWithoutRootAlias(): void self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL()); } - /** - * @group DDC-1211 - */ + /** @group DDC-1211 */ public function testEmptyStringLiteral(): void { $expr = $this->entityManager->getExpressionBuilder(); @@ -1030,9 +1008,7 @@ public function testEmptyStringLiteral(): void self::assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL()); } - /** - * @group DDC-1211 - */ + /** @group DDC-1211 */ public function testEmptyNumericLiteral(): void { $expr = $this->entityManager->getExpressionBuilder(); @@ -1044,9 +1020,7 @@ public function testEmptyNumericLiteral(): void self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL()); } - /** - * @group DDC-1227 - */ + /** @group DDC-1227 */ public function testAddFromString(): void { $qb = $this->entityManager->createQueryBuilder() @@ -1056,9 +1030,7 @@ public function testAddFromString(): void self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); } - /** - * @group DDC-1619 - */ + /** @group DDC-1619 */ public function testAddDistinct(): void { $qb = $this->entityManager->createQueryBuilder() @@ -1069,9 +1041,7 @@ public function testAddDistinct(): void self::assertEquals('SELECT DISTINCT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); } - /** - * @group DDC-2192 - */ + /** @group DDC-2192 */ public function testWhereAppend(): void { $this->expectException(InvalidArgumentException::class); @@ -1121,9 +1091,7 @@ public function testSecondLevelCacheQueryBuilderOptions(): void self::assertEquals(Cache::MODE_REFRESH, $query->getCacheMode()); } - /** - * @group DDC-2253 - */ + /** @group DDC-2253 */ public function testRebuildsFromParts(): void { $qb = $this->entityManager->createQueryBuilder() @@ -1166,9 +1134,7 @@ public function testGetAllAliasesWithJoins(): void self::assertEquals(['u', 'g'], $aliases); } - /** - * @group 6699 - */ + /** @group 6699 */ public function testGetParameterTypeJuggling(): void { $builder = $this->entityManager->createQueryBuilder() @@ -1183,9 +1149,7 @@ public function testGetParameterTypeJuggling(): void self::assertSame(0, $builder->getParameter('0')->getValue()); } - /** - * @group 6699 - */ + /** @group 6699 */ public function testSetParameterWithNameZeroIsNotOverridden(): void { $builder = $this->entityManager->createQueryBuilder() @@ -1202,9 +1166,7 @@ public function testSetParameterWithNameZeroIsNotOverridden(): void self::assertSame('Doctrine', $builder->getParameter('name')->getValue()); } - /** - * @group 6699 - */ + /** @group 6699 */ public function testSetParameterWithNameZeroDoesNotOverrideAnotherParameter(): void { $builder = $this->entityManager->createQueryBuilder() @@ -1221,9 +1183,7 @@ public function testSetParameterWithNameZeroDoesNotOverrideAnotherParameter(): v self::assertSame('Doctrine', $builder->getParameter('name')->getValue()); } - /** - * @group 6699 - */ + /** @group 6699 */ public function testSetParameterWithTypeJugglingWorks(): void { $builder = $this->entityManager->createQueryBuilder() diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index 5522edf3c64..b93f1db2514 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -47,7 +47,7 @@ public function testCreatesRepositoryFromDefaultRepositoryClass(): void self::assertInstanceOf( DDC869PaymentRepository::class, - $this->repositoryFactory->getRepository($this->entityManager, self::class) + $this->repositoryFactory->getRepository($this->entityManager, self::class), ); } @@ -60,7 +60,7 @@ public function testCreatedRepositoriesAreCached(): void self::assertSame( $this->repositoryFactory->getRepository($this->entityManager, self::class), - $this->repositoryFactory->getRepository($this->entityManager, self::class) + $this->repositoryFactory->getRepository($this->entityManager, self::class), ); } @@ -76,7 +76,7 @@ public function testCreatesRepositoryFromCustomClassMetadata(): void self::assertInstanceOf( DDC753DefaultRepository::class, - $this->repositoryFactory->getRepository($this->entityManager, self::class) + $this->repositoryFactory->getRepository($this->entityManager, self::class), ); } diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php index 909e3046ff2..ab86d00c029 100644 --- a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php @@ -45,7 +45,7 @@ public function testAttachEntityListeners(): void AttachEntityListenersListenerTestFooEntity::class, AttachEntityListenersListenerTestListener::class, Events::postLoad, - 'postLoadHandler' + 'postLoadHandler', ); $metadata = $this->factory->getMetadataFor(AttachEntityListenersListenerTestFooEntity::class); @@ -61,14 +61,14 @@ public function testAttachToExistingEntityListeners(): void $this->listener->addEntityListener( AttachEntityListenersListenerTestBarEntity::class, AttachEntityListenersListenerTestListener2::class, - Events::prePersist + Events::prePersist, ); $this->listener->addEntityListener( AttachEntityListenersListenerTestBarEntity::class, AttachEntityListenersListenerTestListener2::class, Events::postPersist, - 'postPersistHandler' + 'postPersistHandler', ); $metadata = $this->factory->getMetadataFor(AttachEntityListenersListenerTestBarEntity::class); @@ -99,22 +99,20 @@ public function testDuplicateEntityListenerException(): void $this->listener->addEntityListener( AttachEntityListenersListenerTestFooEntity::class, AttachEntityListenersListenerTestListener::class, - Events::postPersist + Events::postPersist, ); $this->listener->addEntityListener( AttachEntityListenersListenerTestFooEntity::class, AttachEntityListenersListenerTestListener::class, - Events::postPersist + Events::postPersist, ); $this->factory->getMetadataFor(AttachEntityListenersListenerTestFooEntity::class); } } -/** - * @Entity - */ +/** @Entity */ class AttachEntityListenersListenerTestFooEntity { /** diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php index 887b1fbad62..a3c0971d01e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class ClearCacheCollectionRegionCommandTest extends OrmFunctionalTestCase { private Application $application; @@ -41,7 +39,7 @@ public function testClearAllRegion(): void 'command' => $command->getName(), '--all' => true, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString(' // Clearing all second-level cache collection regions', $tester->getDisplay()); @@ -58,12 +56,12 @@ public function testClearByOwnerEntityClassName(): void 'owner-class' => State::class, 'association' => 'cities', ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Clearing second-level cache for collection "Doctrine\Tests\Models\Cache\State#cities"', - $tester->getDisplay() + $tester->getDisplay(), ); } @@ -79,12 +77,12 @@ public function testClearCacheEntryName(): void 'association' => 'cities', 'owner-id' => 1, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Clearing second-level cache entry for collection "Doctrine\Tests\Models\Cache\State#cities" owner', - $tester->getDisplay() + $tester->getDisplay(), ); self::assertStringContainsString('identified by "1"', $tester->getDisplay()); @@ -102,12 +100,12 @@ public function testFlushRegionName(): void 'association' => 'cities', '--flush' => true, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Flushing cache provider configured for "Doctrine\Tests\Models\Cache\State#cities"', - $tester->getDisplay() + $tester->getDisplay(), ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php index 91ef097ebba..c9e61210762 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php @@ -11,9 +11,7 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class ClearCacheEntityRegionCommandTest extends OrmFunctionalTestCase { private Application $application; @@ -41,7 +39,7 @@ public function testClearAllRegion(): void 'command' => $command->getName(), '--all' => true, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString(' // Clearing all second-level cache entity regions', $tester->getDisplay()); @@ -57,12 +55,12 @@ public function testClearByEntityClassName(): void 'command' => $command->getName(), 'entity-class' => Country::class, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Clearing second-level cache for entity "Doctrine\Tests\Models\Cache\Country"', - $tester->getDisplay() + $tester->getDisplay(), ); } @@ -77,12 +75,12 @@ public function testClearCacheEntryName(): void 'entity-class' => Country::class, 'entity-id' => 1, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Clearing second-level cache entry for entity "Doctrine\Tests\Models\Cache\Country" identified by', - $tester->getDisplay() + $tester->getDisplay(), ); self::assertStringContainsString(' // "1"', $tester->getDisplay()); @@ -99,12 +97,12 @@ public function testFlushRegionName(): void 'entity-class' => Country::class, '--flush' => true, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Flushing cache provider configured for entity named "Doctrine\Tests\Models\Cache\Country"', - $tester->getDisplay() + $tester->getDisplay(), ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php index c00b4eaa4f2..bd72f2776da 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php @@ -10,9 +10,7 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** - * @group DDC-2183 - */ +/** @group DDC-2183 */ class ClearCacheQueryRegionCommandTest extends OrmFunctionalTestCase { private Application $application; @@ -40,7 +38,7 @@ public function testClearAllRegion(): void 'command' => $command->getName(), '--all' => true, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString(' // Clearing all second-level cache query regions', $tester->getDisplay()); @@ -56,12 +54,12 @@ public function testClearDefaultRegionName(): void 'command' => $command->getName(), 'region-name' => null, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Clearing second-level cache query region named "query_cache_region"', - $tester->getDisplay() + $tester->getDisplay(), ); } @@ -75,12 +73,12 @@ public function testClearByRegionName(): void 'command' => $command->getName(), 'region-name' => 'my_region', ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Clearing second-level cache query region named "my_region"', - $tester->getDisplay() + $tester->getDisplay(), ); } @@ -95,12 +93,12 @@ public function testFlushRegionName(): void 'region-name' => 'my_region', '--flush' => true, ], - ['decorated' => false] + ['decorated' => false], ); self::assertStringContainsString( ' // Flushing cache provider configured for second-level cache query region named "my_region"', - $tester->getDisplay() + $tester->getDisplay(), ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php index c1573a36d25..21908dcf334 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php @@ -67,12 +67,12 @@ public function testEmptyEntityClassNames(): void self::assertStringContainsString( ' ! [CAUTION] You do not have any mapped Doctrine ORM entities according to the current configuration', - $tester->getDisplay() + $tester->getDisplay(), ); self::assertStringContainsString( ' ! If you have entities or mapping files you should check your mapping configuration for errors.', - $tester->getDisplay() + $tester->getDisplay(), ); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php index 8a173ddb51c..383509b5e7f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php @@ -42,7 +42,7 @@ public function testShowSpecificFuzzySingle(): void [ 'command' => $this->command->getName(), 'entityName' => 'AttractionInfo', - ] + ], ); $display = $this->tester->getDisplay(); @@ -59,7 +59,7 @@ public function testShowSpecificFuzzyAmbiguous(): void [ 'command' => $this->command->getName(), 'entityName' => 'Attraction', - ] + ], ); } @@ -71,7 +71,7 @@ public function testShowSpecificNotFound(): void [ 'command' => $this->command->getName(), 'entityName' => 'AttractionFooBar', - ] + ], ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php index 4098cfa92a4..9903ea422f9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php @@ -56,8 +56,8 @@ public function testWillRunQuery(): void [ 'command' => $this->command->getName(), 'dql' => 'SELECT e FROM ' . DateTimeModel::class . ' e', - ] - ) + ], + ), ); self::assertStringContainsString(DateTimeModel::class, $this->tester->getDisplay()); @@ -75,8 +75,8 @@ public function testWillShowQuery(): void 'command' => $this->command->getName(), 'dql' => 'SELECT e FROM ' . DateTimeModel::class . ' e', '--show-sql' => 'true', - ] - ) + ], + ), ); self::assertStringMatchesFormat('SELECT %a', trim($this->tester->getDisplay())); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php index 79b0cff23c8..6973e62a1e4 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php @@ -13,9 +13,7 @@ abstract class AbstractCommandTest extends OrmFunctionalTestCase { - /** - * @param class-string $commandClass - */ + /** @param class-string $commandClass */ protected function getCommandTester(string $commandClass): CommandTester { $entityManager = $this->getEntityManager(null, ORMSetup::createDefaultAnnotationDriver([ @@ -27,7 +25,7 @@ protected function getCommandTester(string $commandClass): CommandTester } return new CommandTester(new $commandClass( - new SingleManagerProvider($entityManager) + new SingleManagerProvider($entityManager), )); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php index db546ec984b..cc43238de5d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php @@ -8,9 +8,7 @@ class CreateCommandTest extends AbstractCommandTest { - /** - * @doesNotPerformAssertions - */ + /** @doesNotPerformAssertions */ public function testItPrintsTheSql(): void { $tester = $this->getCommandTester(CreateCommand::class); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php index 97035800c9e..de06ea9da78 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php @@ -9,9 +9,7 @@ final class DropCommandTest extends AbstractCommandTest { - /** - * @doesNotPerformAssertions - */ + /** @doesNotPerformAssertions */ public function testItPrintsTheSql(): void { $this->createSchemaForModels(Keyboard::class); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php index f070745eec6..df94ca4256e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php @@ -8,9 +8,7 @@ class UpdateCommandTest extends AbstractCommandTest { - /** - * @doesNotPerformAssertions - */ + /** @doesNotPerformAssertions */ public function testItPrintsTheSql(): void { $tester = $this->getCommandTester(UpdateCommand::class); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php index 7e52ac1cd62..5e70fa425af 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php @@ -43,7 +43,7 @@ public function testNotInSync(): void $this->tester->execute( [ 'command' => $this->command->getName(), - ] + ], ); $display = $this->tester->getDisplay(); @@ -65,7 +65,7 @@ public function testNotInSyncVerbose(): void ], [ 'verbosity' => OutputInterface::VERBOSITY_VERBOSE, - ] + ], ); $display = $this->tester->getDisplay(); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php index fef4f8f045f..0f0611bf4bb 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php @@ -13,56 +13,56 @@ class CountOutputWalkerTest extends PaginationTestCase public function testCountQuery(): void { $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a' + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, c1_.id AS id_1, a2_.id AS id_2, a2_.name AS name_3, b0_.author_id AS author_id_4, b0_.category_id AS category_id_5 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id) dctrn_result) dctrn_table', - $query->getSQL() + $query->getSQL(), ); } public function testCountQueryMixedResultsWithName(): void { $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a' + 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result) dctrn_table', - $query->getSQL() + $query->getSQL(), ); } public function testCountQueryGroupBy(): void { $query = $this->entityManager->createQuery( - 'SELECT p.name FROM Doctrine\Tests\ORM\Tools\Pagination\Person p GROUP BY p.name' + 'SELECT p.name FROM Doctrine\Tests\ORM\Tools\Pagination\Person p GROUP BY p.name', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); self::assertSame( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT p0_.name AS name_0 FROM Person p0_ GROUP BY p0_.name) dctrn_table', - $query->getSQL() + $query->getSQL(), ); } public function testCountQueryHaving(): void { $query = $this->entityManager->createQuery( - 'SELECT g, u, count(u.id) AS userCount FROM Doctrine\Tests\ORM\Tools\Pagination\Group g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0' + 'SELECT g, u, count(u.id) AS userCount FROM Doctrine\Tests\ORM\Tools\Pagination\Group g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); self::assertSame( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT count(u0_.id) AS sclr_0, g1_.id AS id_1, u0_.id AS id_2 FROM groups g1_ LEFT JOIN user_group u2_ ON g1_.id = u2_.group_id LEFT JOIN User u0_ ON u0_.id = u2_.user_id GROUP BY g1_.id HAVING sclr_0 > 0) dctrn_table', - $query->getSQL() + $query->getSQL(), ); } @@ -74,14 +74,14 @@ public function testCountQueryOrderBySqlServer(): void } $query = $this->entityManager->createQuery( - 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p ORDER BY p.id' + 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p ORDER BY p.id', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); $query->setFirstResult(null)->setMaxResults(null); self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_) dctrn_result) dctrn_table', - $query->getSQL() + $query->getSQL(), ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index d384f6122a9..99c3f647bc9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -8,15 +8,13 @@ use Doctrine\ORM\Tools\Pagination\CountWalker; use RuntimeException; -/** - * @group DDC-1613 - */ +/** @group DDC-1613 */ class CountWalkerTest extends PaginationTestCase { public function testCountQuery(): void { $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a' + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a', ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); @@ -24,14 +22,14 @@ public function testCountQuery(): void self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', - $query->getSQL() + $query->getSQL(), ); } public function testCountQueryMixedResultsWithName(): void { $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a' + 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a', ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); @@ -39,14 +37,14 @@ public function testCountQueryMixedResultsWithName(): void self::assertEquals( 'SELECT count(DISTINCT a0_.id) AS sclr_0 FROM Author a0_', - $query->getSQL() + $query->getSQL(), ); } public function testCountQueryKeepsGroupBy(): void { $query = $this->entityManager->createQuery( - 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b GROUP BY b.id' + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b GROUP BY b.id', ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); @@ -54,14 +52,14 @@ public function testCountQueryKeepsGroupBy(): void self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ GROUP BY b0_.id', - $query->getSQL() + $query->getSQL(), ); } public function testCountQueryRemovesOrderBy(): void { $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a ORDER BY a.name' + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a ORDER BY a.name', ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); @@ -69,14 +67,14 @@ public function testCountQueryRemovesOrderBy(): void self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', - $query->getSQL() + $query->getSQL(), ); } public function testCountQueryRemovesLimits(): void { $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a' + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a', ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); @@ -84,14 +82,14 @@ public function testCountQueryRemovesLimits(): void self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', - $query->getSQL() + $query->getSQL(), ); } public function testCountQueryHavingException(): void { $query = $this->entityManager->createQuery( - 'SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0' + 'SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0', ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setFirstResult(null)->setMaxResults(null); @@ -108,7 +106,7 @@ public function testCountQueryHavingException(): void public function testCountQueryWithArbitraryJoin(): void { $query = $this->entityManager->createQuery( - 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p LEFT JOIN Doctrine\Tests\ORM\Tools\Pagination\Category c WITH p.category = c' + 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p LEFT JOIN Doctrine\Tests\ORM\Tools\Pagination\Category c WITH p.category = c', ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); @@ -116,7 +114,7 @@ public function testCountQueryWithArbitraryJoin(): void self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ LEFT JOIN Category c1_ ON (b0_.category_id = c1_.id)', - $query->getSQL() + $query->getSQL(), ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 22db3ea66de..dc59fe0d784 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -15,7 +15,7 @@ final class LimitSubqueryOutputWalkerTest extends PaginationTestCase public function testLimitSubquery(): void { $query = $this->entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a' + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a', ); $query->expireQueryCache(true); $limitQuery = clone $query; @@ -23,7 +23,7 @@ public function testLimitSubquery(): void self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, m0_.author_id AS author_id_5, m0_.category_id AS category_id_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -32,14 +32,14 @@ public function testLimitSubqueryWithSortPg(): void $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $query = $entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title' + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title', ); $limitQuery = clone $query; $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0, MIN(sclr_5) AS dctrn_minrownum FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS sclr_5, m0_.author_id AS author_id_6, m0_.category_id AS category_id_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -48,14 +48,14 @@ public function testLimitSubqueryWithScalarSortPg(): void $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $query = $entityManager->createQuery( - 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity' + 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity', ); $limitQuery = clone $query; $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -64,14 +64,14 @@ public function testLimitSubqueryWithMixedSortPg(): void $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $query = $entityManager->createQuery( - 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC' + 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC', ); $limitQuery = clone $query; $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -80,14 +80,14 @@ public function testLimitSubqueryWithHiddenScalarSortPg(): void $entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); $query = $entityManager->createQuery( - 'SELECT u, g, COUNT(g.id) AS hidden g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC' + 'SELECT u, g, COUNT(g.id) AS hidden g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC', ); $limitQuery = clone $query; $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -103,7 +103,7 @@ public function testLimitSubqueryWithSortOracle(): void $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); $query = $entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title' + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title', ); $query->expireQueryCache(true); $limitQuery = clone $query; @@ -111,7 +111,7 @@ public function testLimitSubqueryWithSortOracle(): void self::assertSame( 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS SCLR_5, m0_.author_id AS AUTHOR_ID_6, m0_.category_id AS CATEGORY_ID_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -120,7 +120,7 @@ public function testLimitSubqueryWithScalarSortOracle(): void $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); $query = $entityManager->createQuery( - 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity' + 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity', ); $query->expireQueryCache(true); $limitQuery = clone $query; @@ -128,7 +128,7 @@ public function testLimitSubqueryWithScalarSortOracle(): void self::assertSame( 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -137,7 +137,7 @@ public function testLimitSubqueryWithMixedSortOracle(): void $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); $query = $entityManager->createQuery( - 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC' + 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC', ); $query->expireQueryCache(true); $limitQuery = clone $query; @@ -145,7 +145,7 @@ public function testLimitSubqueryWithMixedSortOracle(): void self::assertSame( 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -154,7 +154,7 @@ public function testLimitSubqueryOracle(): void $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); $query = $entityManager->createQuery( - 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a' + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a', ); $query->expireQueryCache(true); $limitQuery = clone $query; @@ -162,40 +162,38 @@ public function testLimitSubqueryOracle(): void self::assertSame( 'SELECT DISTINCT ID_0 FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, m0_.author_id AS AUTHOR_ID_5, m0_.category_id AS CATEGORY_ID_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } public function testCountQueryMixedResultsWithName(): void { $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a' + 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a', ); $limitQuery = clone $query; $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } - /** - * @group DDC-3336 - */ + /** @group DDC-3336 */ public function testCountQueryWithArithmeticOrderByCondition(): void { $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $query = $entityManager->createQuery( - 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY (1 - 1000) * 1 DESC' + 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY (1 - 1000) * 1 DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, (1 - 1000) * 1 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1 FROM Author a0_) dctrn_result_inner ORDER BY (1 - 1000) * 1 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -204,14 +202,14 @@ public function testCountQueryWithComplexScalarOrderByItem(): void $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $query = $entityManager->createQuery( - 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC' + 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_2 * imageWidth_3 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageHeight_2 * imageWidth_3 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -220,14 +218,14 @@ public function testCountQueryWithComplexScalarOrderByItemJoined(): void $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $query = $entityManager->createQuery( - 'SELECT u FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC' + 'SELECT u FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_1 * imageWidth_2 FROM (SELECT u0_.id AS id_0, a1_.imageHeight AS imageHeight_1, a1_.imageWidth AS imageWidth_2, a1_.user_id AS user_id_3 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_1 * imageWidth_2 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -236,14 +234,14 @@ public function testCountQueryWithComplexScalarOrderByItemJoinedWithPartial(): v $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $query = $entityManager->createQuery( - 'SELECT u, partial a.{id, imageAltDesc} FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC' + 'SELECT u, partial a.{id, imageAltDesc} FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_3 * imageWidth_4 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.imageAltDesc AS imageAltDesc_2, a1_.imageHeight AS imageHeight_3, a1_.imageWidth AS imageWidth_4, a1_.user_id AS user_id_5 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_3 * imageWidth_4 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -252,31 +250,29 @@ public function testCountQueryWithComplexScalarOrderByItemOracle(): void $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); $query = $entityManager->createQuery( - 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC' + 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.image AS IMAGE_1, a0_.imageHeight AS IMAGEHEIGHT_2, a0_.imageWidth AS IMAGEWIDTH_3, a0_.imageAltDesc AS IMAGEALTDESC_4, ROW_NUMBER() OVER(ORDER BY a0_.imageHeight * a0_.imageWidth DESC) AS SCLR_5, a0_.user_id AS USER_ID_6 FROM Avatar a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', - $query->getSQL() + $query->getSQL(), ); } - /** - * @group DDC-3434 - */ + /** @group DDC-3434 */ public function testLimitSubqueryWithHiddenSelectionInOrderBy(): void { $query = $this->entityManager->createQuery( - 'SELECT a, a.name AS HIDDEN ord FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY ord DESC' + 'SELECT a, a.name AS HIDDEN ord FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY ord DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_) dctrn_result_inner ORDER BY name_2 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -285,28 +281,28 @@ public function testLimitSubqueryWithColumnWithSortDirectionInName(): void $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); $query = $entityManager->createQuery( - 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageAltDesc DESC' + 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageAltDesc DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageAltDesc_4 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageAltDesc_4 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } public function testLimitSubqueryWithOrderByInnerJoined(): void { $query = $this->entityManager->createQuery( - 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b JOIN b.author a ORDER BY a.name ASC' + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b JOIN b.author a ORDER BY a.name ASC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_1 FROM (SELECT b0_.id AS id_0, a1_.name AS name_1, b0_.author_id AS author_id_2, b0_.category_id AS category_id_3 FROM BlogPost b0_ INNER JOIN Author a1_ ON b0_.author_id = a1_.id) dctrn_result_inner ORDER BY name_1 ASC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -316,13 +312,13 @@ public function testLimitSubqueryWithOrderByAndSubSelectInWhereClauseMySql(): vo $query = $entityManager->createQuery( 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b WHERE ((SELECT COUNT(simple.id) FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost simple) = 1) -ORDER BY b.id DESC' +ORDER BY b.id DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ WHERE ((SELECT COUNT(b1_.id) AS sclr_3 FROM BlogPost b1_) = 1)) dctrn_result_inner ORDER BY id_0 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -332,13 +328,13 @@ public function testLimitSubqueryWithOrderByAndSubSelectInWhereClausePgSql(): vo $query = $entityManager->createQuery( 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b WHERE ((SELECT COUNT(simple.id) FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost simple) = 1) -ORDER BY b.id DESC' +ORDER BY b.id DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0, MIN(sclr_1) AS dctrn_minrownum FROM (SELECT b0_.id AS id_0, ROW_NUMBER() OVER(ORDER BY b0_.id DESC) AS sclr_1, b0_.author_id AS author_id_2, b0_.category_id AS category_id_3 FROM BlogPost b0_ WHERE ((SELECT COUNT(b1_.id) AS sclr_4 FROM BlogPost b1_) = 1)) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', - $query->getSQL() + $query->getSQL(), ); } @@ -351,13 +347,13 @@ public function testLimitSubqueryOrderByFieldFromMappedSuperclass(): void // now use the third one in query $query = $entityManager->createQuery( - 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC' + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.name AS name_1 FROM Banner b0_) dctrn_result_inner ORDER BY id_0 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -376,13 +372,13 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpression(): void WHERE bp.author = a ) AS HIDDEN first_blog_post FROM Doctrine\Tests\ORM\Tools\Pagination\Author a - ORDER BY first_blog_post DESC' + ORDER BY first_blog_post DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, sclr_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, (SELECT MIN(m1_.title) AS sclr_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS sclr_2 FROM Author a0_) dctrn_result_inner ORDER BY sclr_2 DESC) dctrn_result', - $query->getSQL() + $query->getSQL(), ); } @@ -401,13 +397,13 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpressionPg(): void WHERE bp.author = a ) AS HIDDEN first_blog_post FROM Doctrine\Tests\ORM\Tools\Pagination\Author a - ORDER BY first_blog_post DESC' + ORDER BY first_blog_post DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT id_0, MIN(sclr_4) AS dctrn_minrownum FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, (SELECT MIN(m1_.title) AS sclr_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS sclr_2, ROW_NUMBER() OVER(ORDER BY (SELECT MIN(m1_.title) AS sclr_5 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) DESC) AS sclr_4 FROM Author a0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', - $query->getSQL() + $query->getSQL(), ); } @@ -426,13 +422,13 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpressionOracle(): void WHERE bp.author = a ) AS HIDDEN first_blog_post FROM Doctrine\Tests\ORM\Tools\Pagination\Author a - ORDER BY first_blog_post DESC' + ORDER BY first_blog_post DESC', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); self::assertSame( 'SELECT DISTINCT ID_0, MIN(SCLR_4) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.name AS NAME_1, (SELECT MIN(m1_.title) AS SCLR_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS SCLR_2, ROW_NUMBER() OVER(ORDER BY (SELECT MIN(m1_.title) AS SCLR_5 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) DESC) AS SCLR_4 FROM Author a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', - $query->getSQL() + $query->getSQL(), ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php index 5893e01d258..87fa03b5ca9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php @@ -7,9 +7,7 @@ use Doctrine\ORM\Query; use Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker; -/** - * @group DDC-1613 - */ +/** @group DDC-1613 */ class LimitSubqueryWalkerTest extends PaginationTestCase { public function testLimitSubquery(): void @@ -22,7 +20,7 @@ public function testLimitSubquery(): void self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -36,7 +34,7 @@ public function testLimitSubqueryWithSort(): void self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.title AS title_1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -50,7 +48,7 @@ public function testLimitSubqueryWithSortFunction(): void self::assertSame( 'SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id GROUP BY m0_.id ORDER BY COUNT(c1_.id) ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -64,7 +62,7 @@ public function testCountQueryMixedResultsWithName(): void self::assertEquals( 'SELECT DISTINCT a0_.id AS id_0 FROM Author a0_', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -78,7 +76,7 @@ public function testAggQueryMixedResultsWithNameAndSort(): void self::assertSame( 'SELECT DISTINCT a0_.id AS id_0, sum(a0_.name) AS sclr_1 FROM Author a0_ ORDER BY sclr_1 DESC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -92,13 +90,11 @@ public function testAggQueryMultipleMixedResultsWithSort(): void self::assertSame( 'SELECT DISTINCT a0_.id AS id_0, sum(a0_.name) AS sclr_1, (SELECT count(a1_.id) AS sclr_3 FROM Author a1_ WHERE a1_.id = a0_.id) AS sclr_2 FROM Author a0_ ORDER BY sclr_1 DESC, sclr_2 ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } - /** - * @group DDC-2890 - */ + /** @group DDC-2890 */ public function testLimitSubqueryWithSortOnAssociation(): void { $dql = 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p ORDER BY p.author'; @@ -109,7 +105,7 @@ public function testLimitSubqueryWithSortOnAssociation(): void self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.author_id AS sclr_1 FROM MyBlogPost m0_ ORDER BY m0_.author_id ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -126,7 +122,7 @@ public function testLimitSubqueryWithArbitraryJoin(): void self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON (m0_.category_id = c1_.id)', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } @@ -140,7 +136,7 @@ public function testLimitSubqueryWithSortWithArbitraryJoin(): void self::assertEquals( 'SELECT DISTINCT m0_.id AS id_0, m0_.title AS title_1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON (m0_.category_id = c1_.id) ORDER BY m0_.title ASC', - $limitQuery->getSQL() + $limitQuery->getSQL(), ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php index f2b6ed84004..defad03c55f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php @@ -31,9 +31,7 @@ protected function setUp(): void } -/** - * @Entity - */ +/** @Entity */ class MyBlogPost { /** @@ -63,9 +61,7 @@ class MyBlogPost public $title; } -/** - * @Entity - */ +/** @Entity */ class MyAuthor { /** @@ -77,9 +73,7 @@ class MyAuthor public $id; } -/** - * @Entity - */ +/** @Entity */ class MyCategory { /** @@ -92,9 +86,7 @@ class MyCategory } -/** - * @Entity - */ +/** @Entity */ class BlogPost { /** @@ -118,9 +110,7 @@ class BlogPost public $category; } -/** - * @Entity - */ +/** @Entity */ class Author { /** @@ -138,9 +128,7 @@ class Author public $name; } -/** - * @Entity - */ +/** @Entity */ class Person { /** @@ -164,9 +152,7 @@ class Person public $biography; } -/** - * @Entity - */ +/** @Entity */ class Category { /** diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php index dd5a21c0ece..59bbb0bfd6f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -65,7 +65,7 @@ public function testExtraParametersAreStrippedWhenWalkerRemovingOriginalSelectEl WHERE a.user = u AND 1 = :paramInSubSelect ) AS HIDDEN max_version FROM Doctrine\\Tests\\Models\\CMS\\CmsUser u - WHERE u.id = :paramInWhere' + WHERE u.id = :paramInWhere', ); $query->setParameters(['paramInWhere' => $paramInWhere, 'paramInSubSelect' => $paramInSubSelect]); $query->setMaxResults(1); @@ -77,7 +77,7 @@ public function testExtraParametersAreStrippedWhenWalkerRemovingOriginalSelectEl ->withConsecutive( [self::anything(), [$paramInWhere]], [self::anything(), [$paramInWhere]], - [self::anything(), [$paramInSubSelect, $paramInWhere, $returnedIds]] + [self::anything(), [$paramInSubSelect, $paramInWhere, $returnedIds]], ); $paginator->count(); @@ -102,9 +102,7 @@ public function testgetIteratorDoesCareAboutExtraParametersWithoutOutputWalkersW $this->createPaginatorWithExtraParametersWithoutOutputWalkers([[10]])->getIterator(); } - /** - * @param int[][] $willReturnRows - */ + /** @param int[][] $willReturnRows */ private function createPaginatorWithExtraParametersWithoutOutputWalkers(array $willReturnRows): Paginator { $this->hydrator->method('hydrateAll')->willReturn($willReturnRows); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php index 76e39afb8b6..ce8a1bd4c93 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php @@ -11,9 +11,7 @@ use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneIdForeignKeyEntity; -/** - * @group DDC-1613 - */ +/** @group DDC-1613 */ class WhereInWalkerTest extends PaginationTestCase { protected function setUp(): void @@ -28,7 +26,7 @@ protected function setUp(): void public function testWhereInQueryNoWhere(): void { $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g' + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g', ); $whereInQuery = clone $query; $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); @@ -37,19 +35,19 @@ public function testWhereInQueryNoWhere(): void self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE u0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testCountQueryMixedResultsWithName(): void { $query = $this->entityManager->createQuery( - 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a' + 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a', ); $whereInQuery = clone $query; $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); @@ -58,19 +56,19 @@ public function testCountQueryMixedResultsWithName(): void self::assertEquals( 'SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_ WHERE a0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testWhereInQuerySingleWhere(): void { $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1' + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1', ); $whereInQuery = clone $query; $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); @@ -79,19 +77,19 @@ public function testWhereInQuerySingleWhere(): void self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND u0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testWhereInQueryMultipleWhereWithAnd(): void { $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 AND 2 = 2' + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 AND 2 = 2', ); $whereInQuery = clone $query; $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); @@ -100,19 +98,19 @@ public function testWhereInQueryMultipleWhereWithAnd(): void self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND 2 = 2 AND u0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testWhereInQueryMultipleWhereWithOr(): void { $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 OR 2 = 2' + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 OR 2 = 2', ); $whereInQuery = clone $query; $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); @@ -121,19 +119,19 @@ public function testWhereInQueryMultipleWhereWithOr(): void self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND u0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testWhereInQueryMultipleWhereWithMixed1(): void { $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE (1 = 1 OR 2 = 2) AND 3 = 3' + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE (1 = 1 OR 2 = 2) AND 3 = 3', ); $whereInQuery = clone $query; $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); @@ -142,19 +140,19 @@ public function testWhereInQueryMultipleWhereWithMixed1(): void self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND 3 = 3 AND u0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testWhereInQueryMultipleWhereWithMixed2(): void { $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 AND 2 = 2 OR 3 = 3' + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 AND 2 = 2 OR 3 = 3', ); $whereInQuery = clone $query; $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); @@ -163,19 +161,19 @@ public function testWhereInQueryMultipleWhereWithMixed2(): void self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 AND 2 = 2 OR 3 = 3) AND u0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testWhereInQueryWhereNot(): void { $query = $this->entityManager->createQuery( - 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE NOT 1 = 2' + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE NOT 1 = 2', ); $whereInQuery = clone $query; $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); @@ -184,12 +182,12 @@ public function testWhereInQueryWhereNot(): void self::assertEquals( 'SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (NOT 1 = 2) AND u0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } @@ -199,7 +197,7 @@ public function testWhereInQueryWhereNot(): void public function testWhereInQueryWithArbitraryJoinNoWhere(): void { $whereInQuery = $this->entityManager->createQuery( - 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN Doctrine\Tests\ORM\Tools\Pagination\Category c WITH p.category = c' + 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN Doctrine\Tests\ORM\Tools\Pagination\Category c WITH p.category = c', ); $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); @@ -207,19 +205,19 @@ public function testWhereInQueryWithArbitraryJoinNoWhere(): void self::assertEquals( 'SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE b0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testWhereInQueryWithArbitraryJoinSingleWhere(): void { $whereInQuery = $this->entityManager->createQuery( - 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN Doctrine\Tests\ORM\Tools\Pagination\Category c WITH p.category = c WHERE 1 = 1' + 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN Doctrine\Tests\ORM\Tools\Pagination\Category c WITH p.category = c WHERE 1 = 1', ); $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); @@ -227,19 +225,19 @@ public function testWhereInQueryWithArbitraryJoinSingleWhere(): void self::assertEquals( 'SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE 1 = 1 AND b0_.id IN (?)', - $whereInQuery->getSQL() + $whereInQuery->getSQL(), ); $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ); } public function testWillReplaceBoundQueryIdentifiersWithConvertedTypesAsPerIdentifierMapping(): void { $whereInQuery = $this->entityManager->createQuery( - 'SELECT e.id4 FROM ' . AuxiliaryEntity::class . ' e' + 'SELECT e.id4 FROM ' . AuxiliaryEntity::class . ' e', ); $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 3); @@ -247,14 +245,14 @@ public function testWillReplaceBoundQueryIdentifiersWithConvertedTypesAsPerIdent $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - ['sbb', 'one', 'onm'] + ['sbb', 'one', 'onm'], ); } public function testWillReplaceBoundQueryIdentifiersWithConvertedTypesAsPerAssociatedEntityIdentifierMapping(): void { $whereInQuery = $this->entityManager->createQuery( - 'SELECT e FROM ' . OwningManyToOneIdForeignKeyEntity::class . ' e' + 'SELECT e FROM ' . OwningManyToOneIdForeignKeyEntity::class . ' e', ); $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]); $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 3); @@ -262,7 +260,7 @@ public function testWillReplaceBoundQueryIdentifiersWithConvertedTypesAsPerAssoc $this->assertPaginatorWhereInParameterToBe( $whereInQuery, - ['sbb', 'one', 'onm'] + ['sbb', 'one', 'onm'], ); } diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index 36acf92beb9..f99a7a4e076 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -38,9 +38,7 @@ protected function setUp(): void $this->listener = new ResolveTargetEntityListener(); } - /** - * @group DDC-1544 - */ + /** @group DDC-1544 */ public function testResolveTargetEntityListenerCanResolveTargetEntity(): void { $evm = $this->em->getEventManager(); @@ -75,9 +73,7 @@ public function testResolveTargetEntityListenerCanRetrieveTargetEntityByInterfac self::assertSame($this->factory->getMetadataFor(ResolveTargetEntity::class), $cm); } - /** - * @group DDC-2109 - */ + /** @group DDC-2109 */ public function testAssertTableColumnsAreNotAddedInManyToMany(): void { $evm = $this->em->getEventManager(); @@ -109,7 +105,7 @@ public function testDoesResolveTargetEntitiesInDQLAlsoWithInterfaces(): void $this ->em ->createQuery('SELECT f FROM Doctrine\Tests\ORM\Tools\ResolveTarget f') - ->getSQL() + ->getSQL(), ); } } @@ -123,9 +119,7 @@ interface Target extends ResolveTarget { } -/** - * @Entity - */ +/** @Entity */ class ResolveTargetEntity implements ResolveTarget { /** @@ -162,9 +156,7 @@ public function getId(): int } } -/** - * @Entity - */ +/** @Entity */ class TargetEntity implements Target { /** diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index 76c9a2cde5e..a49420a66a0 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -73,7 +73,7 @@ public function testAnnotationOptionsAttribute(): void $schemaTool = new SchemaTool($em); $schema = $schemaTool->getSchemaFromMetadata( - [$em->getClassMetadata(TestEntityWithAnnotationOptionsAttribute::class)] + [$em->getClassMetadata(TestEntityWithAnnotationOptionsAttribute::class)], ); $table = $schema->getTable('TestEntityWithAnnotationOptionsAttribute'); @@ -85,9 +85,7 @@ public function testAnnotationOptionsAttribute(): void } } - /** - * @group DDC-200 - */ + /** @group DDC-200 */ public function testPassColumnDefinitionToJoinColumn(): void { $customColumnDef = 'MEDIUMINT(6) UNSIGNED NOT NULL'; @@ -109,9 +107,7 @@ public function testPassColumnDefinitionToJoinColumn(): void self::assertEquals($customColumnDef, $table->getColumn('avatar_id')->getColumnDefinition()); } - /** - * @group 6830 - */ + /** @group 6830 */ public function testPassColumnOptionsToJoinColumn(): void { $em = $this->getTestEntityManager(); @@ -132,24 +128,22 @@ public function testPassColumnOptionsToJoinColumn(): void self::assertSame( $tableCategory->getColumn('id')->getFixed(), $tableBoard->getColumn('category_id')->getFixed(), - 'Foreign key/join column should have the same value of option `fixed` as the referenced column' + 'Foreign key/join column should have the same value of option `fixed` as the referenced column', ); self::assertEquals( $tableCategory->getColumn('id')->getPlatformOptions(), $tableBoard->getColumn('category_id')->getPlatformOptions(), - 'Foreign key/join column should have the same custom options as the referenced column' + 'Foreign key/join column should have the same custom options as the referenced column', ); self::assertEquals( ['collation' => 'latin1_bin', 'foo' => 'bar'], - $tableBoard->getColumn('category_id')->getPlatformOptions() + $tableBoard->getColumn('category_id')->getPlatformOptions(), ); } - /** - * @group DDC-283 - */ + /** @group DDC-283 */ public function testPostGenerateEvents(): void { $listener = new GenerateSchemaEventListener(); @@ -157,7 +151,7 @@ public function testPostGenerateEvents(): void $em = $this->getTestEntityManager(); $em->getEventManager()->addEventListener( [ToolEvents::postGenerateSchemaTable, ToolEvents::postGenerateSchema], - $listener + $listener, ); $schemaTool = new SchemaTool($em); @@ -188,9 +182,7 @@ public function testNullDefaultNotAddedToPlatformOptions(): void ->getPlatformOptions()); } - /** - * @requires PHP 8.1 - */ + /** @requires PHP 8.1 */ public function testEnumTypeAddedToCustomSchemaOptions(): void { $em = $this->getTestEntityManager(); @@ -205,9 +197,7 @@ public function testEnumTypeAddedToCustomSchemaOptions(): void self::assertSame(Suit::class, $platformOptions['enumType']); } - /** - * @group DDC-3671 - */ + /** @group DDC-3671 */ public function testSchemaHasProperIndexesFromUniqueConstraintAnnotation(): void { $em = $this->getTestEntityManager(); @@ -275,7 +265,7 @@ public function testDerivedCompositeKey(): void $em->getClassMetadata(JoinedDerivedIdentityClass::class), $em->getClassMetadata(JoinedDerivedRootClass::class), $em->getClassMetadata(JoinedDerivedChildClass::class), - ] + ], ); self::assertTrue($schema->hasTable('joined_derived_identity')); @@ -355,9 +345,7 @@ public function testIncorrectUniqueConstraintsBasedOnFields(): void $schemaTool->getSchemaFromMetadata([$class]); } - /** - * @group schema-configuration - */ + /** @group schema-configuration */ public function testConfigurationSchemaIgnoredEntity(): void { $em = $this->getTestEntityManager(); @@ -484,9 +472,7 @@ class SecondEntity public $name; } -/** - * @Entity - */ +/** @Entity */ class GH6830Board { /** @@ -504,9 +490,7 @@ class GH6830Board public $category; } -/** - * @Entity - */ +/** @Entity */ class GH6830Category { /** @@ -583,7 +567,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->mapField(['fieldName' => 'index']); @@ -597,7 +581,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'indexes' => [ ['columns' => ['index'], 'fields' => ['fieldName']], ], - ] + ], ); } } @@ -622,7 +606,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'id' => true, 'fieldName' => 'id', - ] + ], ); $metadata->mapField(['fieldName' => 'index']); @@ -636,7 +620,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'uniqueConstraints' => [ ['columns' => ['index'], 'fields' => ['fieldName']], ], - ] + ], ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 4e6a0240a94..999d14b5a3d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -29,9 +29,9 @@ class SchemaValidatorTest extends OrmTestCase { - private ?EntityManagerInterface $em = null; + private EntityManagerInterface|null $em = null; - private ?SchemaValidator $validator = null; + private SchemaValidator|null $validator = null; protected function setUp(): void { @@ -39,9 +39,7 @@ protected function setUp(): void $this->validator = new SchemaValidator($this->em); } - /** - * @dataProvider modelSetProvider - */ + /** @dataProvider modelSetProvider */ public function testCmsModelSet(string $path): void { $this->em->getConfiguration() @@ -63,9 +61,7 @@ public function modelSetProvider(): array ]; } - /** - * @group DDC-1439 - */ + /** @group DDC-1439 */ public function testInvalidManyToManyJoinColumnSchema(): void { $class1 = $this->em->getClassMetadata(InvalidEntity1::class); @@ -78,13 +74,11 @@ public function testInvalidManyToManyJoinColumnSchema(): void "The inverse join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity2', however 'key4' are missing.", "The join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the source entity 'Doctrine\Tests\ORM\Tools\InvalidEntity1', however 'key2' are missing.", ], - $ce + $ce, ); } - /** - * @group DDC-1439 - */ + /** @group DDC-1439 */ public function testInvalidToOneJoinColumnSchema(): void { $class1 = $this->em->getClassMetadata(InvalidEntity1::class); @@ -97,13 +91,11 @@ public function testInvalidToOneJoinColumnSchema(): void "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\InvalidEntity1'.", "The join columns of the association 'assoc' have to match to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity1', however 'key1, key2' are missing.", ], - $ce + $ce, ); } - /** - * @group DDC-1587 - */ + /** @group DDC-1587 */ public function testValidOneToOneAsIdentifierSchema(): void { $class1 = $this->em->getClassMetadata(DDC1587ValidEntity2::class); @@ -114,9 +106,7 @@ public function testValidOneToOneAsIdentifierSchema(): void self::assertEquals([], $ce); } - /** - * @group DDC-1649 - */ + /** @group DDC-1649 */ public function testInvalidTripleAssociationAsKeyMapping(): void { $classThree = $this->em->getClassMetadata(DDC1649Three::class); @@ -127,13 +117,11 @@ public function testInvalidTripleAssociationAsKeyMapping(): void "Cannot map association 'Doctrine\Tests\ORM\Tools\DDC1649Three#two as identifier, because the target entity 'Doctrine\Tests\ORM\Tools\DDC1649Two' also maps an association as identifier.", "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\DDC1649Two'.", ], - $ce + $ce, ); } - /** - * @group DDC-3274 - */ + /** @group DDC-3274 */ public function testInvalidBiDirectionalRelationMappingMissingInversedByAttribute(): void { $class = $this->em->getClassMetadata(DDC3274One::class); @@ -145,13 +133,11 @@ public function testInvalidBiDirectionalRelationMappingMissingInversedByAttribut 'relationship, but the specified mappedBy association on the target-entity ' . "Doctrine\Tests\ORM\Tools\DDC3274Two#one does not contain the required 'inversedBy=\"two\"' attribute.", ], - $ce + $ce, ); } - /** - * @group 9536 - */ + /** @group 9536 */ public function testInvalidBiDirectionalRelationMappingMissingMappedByAttribute(): void { $class = $this->em->getClassMetadata(Issue9536Owner::class); @@ -164,13 +150,11 @@ public function testInvalidBiDirectionalRelationMappingMissingMappedByAttribute( "Doctrine\Tests\ORM\Tools\Issue9536Target#two does not contain the required 'mappedBy=\"one\"' " . 'attribute.', ], - $ce + $ce, ); } - /** - * @group DDC-3322 - */ + /** @group DDC-3322 */ public function testInvalidOrderByInvalidField(): void { $class = $this->em->getClassMetadata(DDC3322One::class); @@ -181,13 +165,11 @@ public function testInvalidOrderByInvalidField(): void 'The association Doctrine\Tests\ORM\Tools\DDC3322One#invalidAssoc is ordered by a foreign field ' . 'invalidField that is not a field on the target entity Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1.', ], - $ce + $ce, ); } - /** - * @group DDC-3322 - */ + /** @group DDC-3322 */ public function testInvalidOrderByCollectionValuedAssociation(): void { $class = $this->em->getClassMetadata(DDC3322Two::class); @@ -198,13 +180,11 @@ public function testInvalidOrderByCollectionValuedAssociation(): void 'The association Doctrine\Tests\ORM\Tools\DDC3322Two#invalidAssoc is ordered by a field oneToMany ' . 'on Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 that is a collection-valued association.', ], - $ce + $ce, ); } - /** - * @group DDC-3322 - */ + /** @group DDC-3322 */ public function testInvalidOrderByAssociationInverseSide(): void { $class = $this->em->getClassMetadata(DDC3322Three::class); @@ -215,13 +195,11 @@ public function testInvalidOrderByAssociationInverseSide(): void 'The association Doctrine\Tests\ORM\Tools\DDC3322Three#invalidAssoc is ordered by a field oneToOneInverse ' . 'on Doctrine\Tests\ORM\Tools\DDC3322ValidEntity1 that is the inverse side of an association.', ], - $ce + $ce, ); } - /** - * @group 8052 - */ + /** @group 8052 */ public function testInvalidAssociationInsideEmbeddable(): void { $class = $this->em->getClassMetadata(EmbeddableWithAssociation::class); @@ -229,13 +207,11 @@ public function testInvalidAssociationInsideEmbeddable(): void self::assertEquals( ["Embeddable 'Doctrine\Tests\ORM\Tools\EmbeddableWithAssociation' does not support associations"], - $ce + $ce, ); } - /** - * @group 8771 - */ + /** @group 8771 */ public function testMappedSuperclassNotPresentInDiscriminator(): void { $class1 = $this->em->getClassMetadata(MappedSuperclassEntity::class); @@ -245,9 +221,7 @@ public function testMappedSuperclassNotPresentInDiscriminator(): void } } -/** - * @MappedSuperclass - */ +/** @MappedSuperclass */ abstract class MappedSuperclassEntity extends ParentEntity { } @@ -267,16 +241,12 @@ abstract class ParentEntity protected $key; } -/** - * @Entity - */ +/** @Entity */ class ChildEntity extends MappedSuperclassEntity { } -/** - * @Entity - */ +/** @Entity */ class InvalidEntity1 { /** @@ -304,9 +274,7 @@ class InvalidEntity1 protected $entity2; } -/** - * @Entity - */ +/** @Entity */ class InvalidEntity2 { /** @@ -371,9 +339,7 @@ class DDC1587ValidEntity2 private string $num; } -/** - * @Entity - */ +/** @Entity */ class DDC1649One { /** @@ -385,9 +351,7 @@ class DDC1649One public $id; } -/** - * @Entity - */ +/** @Entity */ class DDC1649Two { /** @@ -397,9 +361,7 @@ class DDC1649Two public $one; } -/** - * @Entity - */ +/** @Entity */ class DDC1649Three { /** @@ -410,9 +372,7 @@ class DDC1649Three private DDC1649Two $two; } -/** - * @Entity - */ +/** @Entity */ class DDC3274One { /** @@ -427,9 +387,7 @@ class DDC3274One private ArrayCollection $two; } -/** - * @Entity - */ +/** @Entity */ class DDC3274Two { /** @@ -439,9 +397,7 @@ class DDC3274Two private DDC3274One $one; } -/** - * @Entity - */ +/** @Entity */ class Issue9536Target { /** @@ -456,9 +412,7 @@ class Issue9536Target private Issue9536Owner $two; } -/** - * @Entity - */ +/** @Entity */ class Issue9536Owner { /** @@ -473,9 +427,7 @@ class Issue9536Owner private Issue9536Target $one; } -/** - * @Entity - */ +/** @Entity */ class DDC3322ValidEntity1 { /** @@ -517,9 +469,7 @@ class DDC3322ValidEntity1 private DDC3322ValidEntity2 $oneToOneOwning; } -/** - * @Entity - */ +/** @Entity */ class DDC3322ValidEntity2 { /** @@ -542,9 +492,7 @@ class DDC3322ValidEntity2 private DDC3322ValidEntity1 $oneToOneInverse; } -/** - * @Entity - */ +/** @Entity */ class DDC3322One { /** @@ -569,9 +517,7 @@ class DDC3322One private $invalidAssoc; } -/** - * @Entity - */ +/** @Entity */ class DDC3322Two { /** @@ -596,9 +542,7 @@ class DDC3322Two private $invalidAssoc; } -/** - * @Entity - */ +/** @Entity */ class DDC3322Three { /** @@ -622,9 +566,7 @@ class DDC3322Three private $invalidAssoc; } -/** - * @Embeddable - */ +/** @Embeddable */ class EmbeddableWithAssociation { /** @OneToOne(targetEntity="Doctrine\Tests\Models\ECommerce\ECommerceCart") */ diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 5cf0bc2ee42..38ac0ed2d58 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -292,8 +292,8 @@ public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue(mixed ForumUser::class, new EntityPersisterMock( $this->_emMock, - $this->_emMock->getClassMetadata(ForumUser::class) - ) + $this->_emMock->getClassMetadata(ForumUser::class), + ), ); $user = new ForumUser(); @@ -315,7 +315,7 @@ public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationV $this->_unitOfWork->setEntityPersister( ForumUser::class, - new EntityPersisterMock($this->_emMock, $metadata) + new EntityPersisterMock($this->_emMock, $metadata), ); $user = new ForumUser(); @@ -366,9 +366,7 @@ public function invalidAssociationValuesDataProvider(): array ]; } - /** - * @dataProvider entitiesWithValidIdentifiersProvider - */ + /** @dataProvider entitiesWithValidIdentifiersProvider */ public function testAddToIdentityMapValidIdentifiers(object $entity, string $idHash): void { $this->_unitOfWork->persist($entity); @@ -377,9 +375,7 @@ public function testAddToIdentityMapValidIdentifiers(object $entity, string $idH self::assertSame($entity, $this->_unitOfWork->getByIdHash($idHash, $entity::class)); } - /** - * @psalm-return array - */ + /** @psalm-return array */ public function entitiesWithValidIdentifiersProvider() { $emptyString = new EntityWithStringIdentifier(); @@ -437,9 +433,7 @@ public function testAddToIdentityMapInvalidIdentifiers(object $entity, array $id $this->_unitOfWork->registerManaged($entity, $identifier, []); } - /** - * @psalm-return array}> - */ + /** @psalm-return array}> */ public function entitiesWithInvalidIdentifiersProvider(): array { $firstNullString = new EntityWithCompositeStringIdentifier(); @@ -586,9 +580,7 @@ public function testPreviousDetectedIllegalNewNonCascadedEntitiesAreCleanedUpOnS self::assertCount(0, $persister2->getInserts()); } - /** - * @group #7946 Throw OptimisticLockException when connection::commit() returns false. - */ + /** @group #7946 Throw OptimisticLockException when connection::commit() returns false. */ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails(): void { $platform = $this->getMockBuilder(AbstractPlatform::class) @@ -636,9 +628,7 @@ public function testItThrowsWhenLookingUpIdentifierForUnknownEntity(): void } } -/** - * @Entity - */ +/** @Entity */ class NotifyChangedEntity implements NotifyPropertyChanged { /** @psalm-var list */ @@ -727,19 +717,19 @@ class NotifyChangedRelatedItem private int $id; /** @ManyToOne(targetEntity="NotifyChangedEntity", inversedBy="items") */ - private ?NotifyChangedEntity $owner = null; + private NotifyChangedEntity|null $owner = null; public function getId(): int { return $this->id; } - public function getOwner(): ?NotifyChangedEntity + public function getOwner(): NotifyChangedEntity|null { return $this->owner; } - public function setOwner(?NotifyChangedEntity $owner): void + public function setOwner(NotifyChangedEntity|null $owner): void { $this->owner = $owner; } diff --git a/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php b/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php index be037861967..2f4d789c809 100644 --- a/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php @@ -29,7 +29,7 @@ public function testResolveDiscriminatorsForClass(): void [ [$classMetadata->name, $classMetadata], [$childClassMetadata->name, $childClassMetadata], - ] + ], ); $discriminators = HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($classMetadata, $em); diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php index a0b9fad4e72..150080fc37c 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php @@ -24,13 +24,11 @@ protected function setUp(): void $this->createSchemaForModels( TypedCardEnumId::class, - TypedCardEnumCompositeId::class + TypedCardEnumCompositeId::class, ); } - /** - * @group utilities - */ + /** @group utilities */ public function testFlattenIdentifierWithEnumId(): void { $typedCardEnumIdEntity = new TypedCardEnumId(); @@ -57,9 +55,7 @@ public function testFlattenIdentifierWithEnumId(): void self::assertEquals(Suit::Clubs, $findTypedCardEnumIdEntity->suit); } - /** - * @group utilities - */ + /** @group utilities */ public function testFlattenIdentifierWithCompositeEnumId(): void { $typedCardEnumCompositeIdEntity = new TypedCardEnumCompositeId(); diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php index 42170e4090c..7f2041e59de 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php @@ -29,20 +29,18 @@ protected function setUp(): void $this->identifierFlattener = new IdentifierFlattener( $this->_em->getUnitOfWork(), - $this->_em->getMetadataFactory() + $this->_em->getMetadataFactory(), ); $this->createSchemaForModels( FirstRelatedEntity::class, SecondRelatedEntity::class, Flight::class, - City::class + City::class, ); } - /** - * @group utilities - */ + /** @group utilities */ public function testFlattenIdentifierWithOneToOneId(): void { $secondRelatedEntity = new SecondRelatedEntity(); @@ -72,7 +70,7 @@ public function testFlattenIdentifierWithOneToOneId(): void self::assertInstanceOf( SecondRelatedEntity::class, $id['secondEntity'], - 'The entity should be an instance of SecondRelatedEntity' + 'The entity should be an instance of SecondRelatedEntity', ); $flatIds = $this->identifierFlattener->flattenIdentifier($class, $id); @@ -84,9 +82,7 @@ public function testFlattenIdentifierWithOneToOneId(): void self::assertEquals($id['secondEntity']->id, $flatIds['secondEntity']); } - /** - * @group utilities - */ + /** @group utilities */ public function testFlattenIdentifierWithMutlipleIds(): void { $leeds = new City('Leeds'); diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index e6b4765c9e6..a42b8af82d8 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -476,9 +476,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase ], ]; - /** - * @param class-string ...$models - */ + /** @param class-string ...$models */ final protected function createSchemaForModels(string ...$models): void { try { @@ -497,9 +495,7 @@ final protected function getUpdateSchemaSqlForModels(string ...$models): array return $this->_schemaTool->getUpdateSchemaSql($this->getMetadataForModels($models)); } - /** - * @param class-string ...$models - */ + /** @param class-string ...$models */ final protected function getSchemaForModels(string ...$models): Schema { return $this->_schemaTool->getSchemaFromMetadata($this->getMetadataForModels($models)); @@ -516,7 +512,7 @@ private function getMetadataForModels(array $models): array function (string $className): ClassMetadata { return $this->_em->getClassMetadata($className); }, - $models + $models, ); } @@ -702,8 +698,8 @@ protected function tearDown(): void sprintf( 'UPDATE %s SET %s = NULL', $platform->quoteIdentifier('quote-address'), - $platform->quoteIdentifier('user-id') - ) + $platform->quoteIdentifier('user-id'), + ), ); $conn->executeStatement('DELETE FROM ' . $platform->quoteIdentifier('quote-users-groups')); @@ -887,8 +883,8 @@ protected function setUp(): void * @throws ORMException */ protected function getEntityManager( - ?Connection $connection = null, - ?MappingDriver $mappingDriver = null + Connection|null $connection = null, + MappingDriver|null $mappingDriver = null, ): EntityManagerInterface { // NOTE: Functional tests use their own shared metadata cache, because // the actual database platform used during execution has effect on some @@ -919,7 +915,7 @@ protected function getEntityManager( $cacheConfig = new CacheConfiguration(); $factory = new DefaultCacheFactory( $cacheConfig->getRegionsConfiguration(), - $this->getSharedSecondLevelCache() + $this->getSharedSecondLevelCache(), ); $this->secondLevelCacheFactory = $factory; @@ -940,7 +936,7 @@ protected function getEntityManager( $mappingDriver ?? ORMSetup::createDefaultAnnotationDriver([ realpath(__DIR__ . '/Models/Cache'), realpath(__DIR__ . '/Models/GeoNames'), - ]) + ]), ); $conn = $connection ?: static::$sharedConn; @@ -978,9 +974,7 @@ final protected function createSchemaManager(): AbstractSchemaManager return $this->_em->getConnection()->createSchemaManager(); } - /** - * @throws Throwable - */ + /** @throws Throwable */ protected function onNotSuccessfulTest(Throwable $e): void { if ($e instanceof AssertionFailedError || $e instanceof Warning) { @@ -1021,7 +1015,7 @@ public function assertSQLEquals(string $expectedSql, string $actualSql): void self::assertEquals( strtolower($expectedSql), strtolower($actualSql), - 'Lowercase comparison of SQL statements failed.' + 'Lowercase comparison of SQL statements failed.', ); } @@ -1049,7 +1043,7 @@ final protected function getQueryLog(): QueryLog throw new RuntimeException(sprintf( 'The query log is only available if %s is used as wrapper class. Got %s.', Connection::class, - get_debug_type($connection) + get_debug_type($connection), )); } @@ -1061,9 +1055,7 @@ final protected function assertQueryCount(int $expectedCount, string $message = self::assertThat($this->getQueryLog()->queries, new Count($expectedCount), $message); } - /** - * @psalm-return array{sql: string, params: array|null, types: array|null} - */ + /** @psalm-return array{sql: string, params: array|null, types: array|null} */ final protected function getLastLoggedQuery(int $index = 0): array { $queries = $this->getQueryLog()->queries; diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 1bd436ab9b9..a4bebfdebc1 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -35,12 +35,12 @@ abstract class OrmTestCase extends DoctrineTestCase /** * The metadata cache that is shared between all ORM tests (except functional tests). */ - private static ?CacheItemPoolInterface $metadataCache = null; + private static CacheItemPoolInterface|null $metadataCache = null; /** * The query cache that is shared between all ORM tests (except functional tests). */ - private static ?CacheItemPoolInterface $queryCache = null; + private static CacheItemPoolInterface|null $queryCache = null; /** @var bool */ protected $isSecondLevelCacheEnabled = false; @@ -54,13 +54,13 @@ abstract class OrmTestCase extends DoctrineTestCase /** @var StatisticsCacheLogger */ protected $secondLevelCacheLogger; - private ?CacheItemPoolInterface $secondLevelCache = null; + private CacheItemPoolInterface|null $secondLevelCache = null; protected function createAnnotationDriver(array $paths = []): AnnotationDriver { return new AnnotationDriver( new PsrCachedReader(new AnnotationReader(), new ArrayAdapter()), - $paths + $paths, ); } @@ -75,7 +75,7 @@ protected function createAnnotationDriver(array $paths = []): AnnotationDriver protected function getTestEntityManager(): EntityManagerMock { return $this->buildTestEntityManagerWithPlatform( - $this->createConnectionMock($this->createPlatformMock()) + $this->createConnectionMock($this->createPlatformMock()), ); } @@ -87,7 +87,7 @@ protected function createTestEntityManagerWithConnection(Connection $connection) protected function createTestEntityManagerWithPlatform(AbstractPlatform $platform): EntityManagerMock { return $this->buildTestEntityManagerWithPlatform( - $this->createConnectionMock($platform) + $this->createConnectionMock($platform), ); } @@ -109,7 +109,7 @@ private function buildTestEntityManagerWithPlatform(Connection $connection): Ent $cacheConfig = new CacheConfiguration(); $factory = new DefaultCacheFactory( $cacheConfig->getRegionsConfiguration(), - $this->getSharedSecondLevelCache() + $this->getSharedSecondLevelCache(), ); $this->secondLevelCacheFactory = $factory; diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index 225152cf2d1..7dbf4bead9a 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -50,7 +50,7 @@ class TestUtil * 1) Each invocation of this method returns a NEW database connection. * 2) The database is dropped and recreated to ensure it's clean. */ - public static function getConnection(?Configuration $config = null): DbalExtensions\Connection + public static function getConnection(Configuration|null $config = null): DbalExtensions\Connection { if (! self::$initialized) { self::initializeDatabase(); @@ -127,9 +127,7 @@ private static function addDbEventSubscribers(Connection $conn): void } } - /** - * @psalm-return array - */ + /** @psalm-return array */ private static function getPrivilegedConnectionParameters(): array { if (isset($GLOBALS['privileged_db_driver'])) { @@ -142,14 +140,12 @@ private static function getPrivilegedConnectionParameters(): array return $parameters; } - /** - * @psalm-return array - */ + /** @psalm-return array */ private static function getTestConnectionParameters(): array { if (! isset($GLOBALS['db_driver'])) { throw new UnexpectedValueException( - 'You must provide database connection params including a db_driver value. See phpunit.xml.dist for details' + 'You must provide database connection params including a db_driver value. See phpunit.xml.dist for details', ); } From 21e142b9a53943942bddce997869f4fe0bcbc160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 27 Aug 2022 21:43:29 +0200 Subject: [PATCH 157/475] Revert changes that cause test failures --- phpcs.xml.dist | 5 ++++ .../Tests/Models/Cache/ComplexAction.php | 6 ++-- .../Models/DDC117/DDC117ArticleDetails.php | 3 +- .../Tests/Models/DDC117/DDC117Translation.php | 3 +- .../Functional/OneToOneEagerLoadingTest.php | 2 +- .../ORM/Functional/Ticket/DDC2579Test.php | 3 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 28 +++++++++++++------ 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 074159324ee..aa1721297c5 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -37,6 +37,11 @@ would break signature compatibility. --> tests/Doctrine/Tests/Mocks/HydratorMockStatement.php + tests/Doctrine/Tests/Models/Cache/ComplexAction.php + tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php + tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php + tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php + tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php index 0a18e4b2fa9..0cb0d4fc984 100644 --- a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php +++ b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php @@ -28,17 +28,19 @@ class ComplexAction public function __construct( /** + * @var Action * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) * @JoinColumn(name="action1_name", referencedColumnName="name") */ - public Action $action1, + public $action1, /** + * @var Action * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) * @JoinColumn(name="action2_name", referencedColumnName="name") */ - public Action $action2, + public $action2, /** @Column */ public string $name, ) { diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php index e74fec0ffee..a4cfba94cbe 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php @@ -18,11 +18,12 @@ class DDC117ArticleDetails public function __construct( /** + * @var DDC117Article * @Id * @OneToOne(targetEntity="DDC117Article", inversedBy="details") * @JoinColumn(name="article_id", referencedColumnName="article_id") */ - private DDC117Article $article, + private $article, string $text, ) { $article->setDetails($this); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php index 6c41caccb00..f918b975cdd 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php @@ -31,11 +31,12 @@ class DDC117Translation public function __construct( /** + * @var DDC117Article * @Id * @ManyToOne(targetEntity="DDC117Article", inversedBy="translations") * @JoinColumn(name="article_id", referencedColumnName="article_id") */ - private DDC117Article $article, + private $article, /** * @Id * @Column(type="string", length=255) diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index a892b04718c..eca31814ccb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -365,7 +365,7 @@ class TrainOrder public function __construct( /** @OneToOne(targetEntity="Train", fetch="EAGER") */ - public Train $train, + public Train|null $train = null, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index e9afd6e5f4c..3c1e2130769 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -100,11 +100,12 @@ class DDC2579EntityAssoc { public function __construct( /** + * @var DDC2579AssocAssoc * @Id * @ManyToOne(targetEntity="DDC2579AssocAssoc") * @JoinColumn(name="association_id", referencedColumnName="associationId") */ - public DDC2579AssocAssoc $assocAssoc, + public $assocAssoc, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 678804990e7..38328e9af09 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -367,8 +367,11 @@ class DDC93Person public $timestamps; public function __construct( - /** @Column(type="string", length=255) */ - public string|null $name = null, + /** + * @var string|null + * @Column(type="string", length=255) + */ + public $name = null, /** @Embedded(class="DDC93Address") */ public DDC93Address|null $address = null, ) { @@ -430,14 +433,23 @@ public function __construct( class DDC93Address { public function __construct( - /** @Column(type="string", length=255) */ - public string|null $street = null, - /** @Column(type="string", length=255) */ - public string|null $zip = null, + /** + * @var string|null + * @Column(type="string", length=255) + */ + public $street = null, + /** + * @var string|null + * @Column(type="string", length=255) + */ + public $zip = null, /** @Column(type="string", length=255) */ public string|null $city = null, - /** @Embedded(class = "DDC93Country") */ - public DDC93Country|null $country = null, + /** + * @var DDC93Country|null + * @Embedded(class = "DDC93Country") + */ + public $country = null, ) { } } From 4dcaa2c23bbcbdfbfa6090cf4fbb909f321facbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 27 Aug 2022 21:48:25 +0200 Subject: [PATCH 158/475] Improve PHPDoc for WhereClause::$conditionalExpression --- lib/Doctrine/ORM/Query/AST/WhereClause.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/AST/WhereClause.php b/lib/Doctrine/ORM/Query/AST/WhereClause.php index b13b697f391..971ce6c16d6 100644 --- a/lib/Doctrine/ORM/Query/AST/WhereClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhereClause.php @@ -13,7 +13,7 @@ */ class WhereClause extends Node { - /** @param ConditionalExpression $conditionalExpression */ + /** @param ConditionalExpression|ConditionalTerm $conditionalExpression */ public function __construct(public $conditionalExpression) { } From 1d3c6d6eb88a9a4bb497c1357d1dc3666d459104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 27 Aug 2022 21:54:15 +0200 Subject: [PATCH 159/475] Adjust CPP migration --- lib/Doctrine/ORM/Mapping/Embedded.php | 10 ++--- lib/Doctrine/ORM/Mapping/JoinColumn.php | 49 +++++-------------------- 2 files changed, 14 insertions(+), 45 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Embedded.php b/lib/Doctrine/ORM/Mapping/Embedded.php index fb5104218f5..693984de3b4 100644 --- a/lib/Doctrine/ORM/Mapping/Embedded.php +++ b/lib/Doctrine/ORM/Mapping/Embedded.php @@ -15,11 +15,9 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class Embedded implements Annotation { - /** @var string|null */ - public $class; - - public function __construct(string|null $class = null, public $columnPrefix = null) - { - $this->class = $class; + public function __construct( + public string|null $class = null, + public string|bool|null $columnPrefix = null, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/JoinColumn.php b/lib/Doctrine/ORM/Mapping/JoinColumn.php index 9b6ac41962d..c4a4f2ada34 100644 --- a/lib/Doctrine/ORM/Mapping/JoinColumn.php +++ b/lib/Doctrine/ORM/Mapping/JoinColumn.php @@ -15,48 +15,19 @@ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class JoinColumn implements Annotation { - /** @var string|null */ - public $name; - - /** @var string */ - public $referencedColumnName = 'id'; - - /** @var bool */ - public $unique = false; - - /** @var bool */ - public $nullable = true; - - /** @var string|null */ - public $columnDefinition; - /** - * Field name used in non-object hydration (array/scalar). - * - * @var string|null + * @param string|null $fieldName Field name used in non-object hydration (array/scalar). + * @param array $options */ - public $fieldName; - - /** @var array */ - public $options = []; - - /** @param array $options */ public function __construct( - string|null $name = null, - string $referencedColumnName = 'id', - bool $unique = false, - bool $nullable = true, - public $onDelete = null, - string|null $columnDefinition = null, - string|null $fieldName = null, - array $options = [], + public string|null $name = null, + public string $referencedColumnName = 'id', + public bool $unique = false, + public bool $nullable = true, + public mixed $onDelete = null, + public string|null $columnDefinition = null, + public string|null $fieldName = null, + public array $options = [], ) { - $this->name = $name; - $this->referencedColumnName = $referencedColumnName; - $this->unique = $unique; - $this->nullable = $nullable; - $this->columnDefinition = $columnDefinition; - $this->fieldName = $fieldName; - $this->options = $options; } } From 883c8c443ff1a8eb4eb70f51b82034e0dd15d317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 27 Aug 2022 22:01:00 +0200 Subject: [PATCH 160/475] Update baseline --- psalm-baseline.xml | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1bf157d6cb3..852b2d30bdd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -190,11 +190,11 @@ $this->metadataFactory->getMetadataFor($className) - ?object - ?object - ?object ClassMetadataFactory Mapping\ClassMetadata + object|null + object|null + object|null $config->getProxyDir() @@ -664,11 +664,6 @@ isset($xmlRoot->{'unique-constraints'}) - - - $columnPrefix - - $discriminatorColumn @@ -686,11 +681,6 @@ $onDelete - - - $onDelete - - $value @@ -1364,11 +1354,6 @@ $type - - - null - - $fieldIdentificationVariable @@ -1385,9 +1370,6 @@ - - null - walkWhenClauseExpression @@ -1732,11 +1714,14 @@ $this->queryComponents[$factor]['token']['value'] $this->queryComponents[$term]['token']['value'] - + $arithmeticExpr->simpleArithmeticExpression $arithmeticExpr->subselect $condExpr + $generalCaseExpression->elseScalarExpression $identificationVariableDecl->rangeVariableDeclaration + $simpleCaseExpression->caseOperand + $simpleCaseExpression->elseScalarExpression $targetClass->associationMappings @@ -1771,7 +1756,7 @@ ! $filteredParameters->isEmpty() ? $filteredParameters->first() : null - ?Parameter + Parameter|null $spacePos From 4aa3c630dfb37eab71b7b3103d7c4dc393468d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 27 Aug 2022 22:15:36 +0200 Subject: [PATCH 161/475] Address DBAL deprecations - listTableDetails() has been deprecated in favor of introspectTable(). - createSchema() has been deprecated in favor of introspectSchema(). --- lib/Doctrine/ORM/Tools/SchemaTool.php | 17 +++++++++++++---- .../Tests/ORM/Functional/Ticket/GH6823Test.php | 11 +++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 3f3e0ac3af5..18e14f718ea 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -834,8 +834,10 @@ public function dropDatabase(): void */ public function getDropDatabaseSQL(): array { + $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? 'introspectSchema' : 'createSchema'; + return $this->schemaManager - ->createSchema() + ->$method() ->toDropSql($this->platform); } @@ -850,7 +852,10 @@ public function getDropSchemaSQL(array $classes): array { $schema = $this->getSchemaFromMetadata($classes); - $deployedSchema = $this->schemaManager->createSchema(); + $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? + 'introspectSchema' : + 'createSchema'; + $deployedSchema = $this->schemaManager->$method(); foreach ($schema->getTables() as $table) { if (! $deployedSchema->hasTable($table->getName())) { @@ -934,8 +939,12 @@ private function createSchemaForComparison(Schema $toSchema): Schema $config = $connection->getConfiguration(); $previousFilter = $config->getSchemaAssetsFilter(); + $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? + 'introspectSchema' : + 'createSchema'; + if ($previousFilter === null) { - return $this->schemaManager->createSchema(); + return $this->schemaManager->$method(); } // whitelist assets we already know about in $toSchema, use the existing filter otherwise @@ -946,7 +955,7 @@ private function createSchemaForComparison(Schema $toSchema): Schema }); try { - return $this->schemaManager->createSchema(); + return $this->schemaManager->$method(); } finally { // restore schema assets filter $config->setSchemaAssetsFilter($previousFilter); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php index aa557150892..8ab0284a02d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php @@ -16,6 +16,8 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use function method_exists; + class GH6823Test extends OrmFunctionalTestCase { public function testCharsetCollationWhenCreatingForeignRelations(): void @@ -31,27 +33,28 @@ public function testCharsetCollationWhenCreatingForeignRelations(): void ); $schemaManager = $this->createSchemaManager(); + $method = method_exists($schemaManager, 'introspectTable') ? 'introspectTable' : 'listTableDetails'; /* gh6823_user.group_id should use charset ascii and collation * ascii_general_ci, because that is what gh6823_group.id falls back to */ - $userGroupIdOptions = $schemaManager->listTableDetails('gh6823_user')->getColumn('group_id')->toArray(); + $userGroupIdOptions = $schemaManager->$method('gh6823_user')->getColumn('group_id')->toArray(); self::assertSame('ascii', $userGroupIdOptions['charset']); self::assertSame('ascii_general_ci', $userGroupIdOptions['collation']); /* gh6823_user.status_id should use charset latin1 and collation * latin1_bin, because that is what gh6823_status.id uses */ - $userStatusIdOptions = $schemaManager->listTableDetails('gh6823_user')->getColumn('status_id')->toArray(); + $userStatusIdOptions = $schemaManager->$method('gh6823_user')->getColumn('status_id')->toArray(); self::assertSame('latin1', $userStatusIdOptions['charset']); self::assertSame('latin1_bin', $userStatusIdOptions['collation']); /* gh6823_user_tags.user_id should use charset utf8mb4 and collation * utf8mb4_bin, because that is what gh6823_user.id falls back to */ - $userTagsUserIdOptions = $schemaManager->listTableDetails('gh6823_user_tags')->getColumn('user_id')->toArray(); + $userTagsUserIdOptions = $schemaManager->$method('gh6823_user_tags')->getColumn('user_id')->toArray(); self::assertSame('utf8mb4', $userTagsUserIdOptions['charset']); self::assertSame('utf8mb4_bin', $userTagsUserIdOptions['collation']); /* gh6823_user_tags.tag_id should use charset latin1 and collation * latin1_bin, because that is what gh6823_tag.id falls back to */ - $userTagsTagIdOption = $schemaManager->listTableDetails('gh6823_user_tags')->getColumn('tag_id')->toArray(); + $userTagsTagIdOption = $schemaManager->$method('gh6823_user_tags')->getColumn('tag_id')->toArray(); self::assertSame('latin1', $userTagsTagIdOption['charset']); self::assertSame('latin1_bin', $userTagsTagIdOption['collation']); } From 147984871435a8a1b3a9a84c52411827ac0dfee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 21 Sep 2022 23:29:36 +0200 Subject: [PATCH 162/475] Specify precision for decimal columns doctrine/dbal 4 no longer provides a default value for that column option. --- tests/Doctrine/Tests/Models/StockExchange/Stock.php | 2 +- tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/Models/StockExchange/Stock.php b/tests/Doctrine/Tests/Models/StockExchange/Stock.php index 0790f3aebb5..153e0a5eafe 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Stock.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Stock.php @@ -31,7 +31,7 @@ public function __construct( * @Column(type="string", length=255) */ private string $symbol, - /** @Column(type="decimal") */ + /** @Column(type="decimal", precision=10) */ private float $price, /** @ManyToOne(targetEntity="Market", inversedBy="stocks") */ private Market $market, diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php index 24a1699a523..8b2d4607162 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php @@ -109,7 +109,7 @@ class GH7941Product public function __construct( /** @Column(type="string", length=255) */ public string $name, - /** @Column(type="decimal") */ + /** @Column(type="decimal", precision=10) */ public string $price, ) { $this->createdAt = new DateTimeImmutable(); From 965de8b742ba8968099269609bbed5616d7243e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 21 Sep 2022 23:30:34 +0200 Subject: [PATCH 163/475] Address AbstractSchemaManager::createSchema() removal --- lib/Doctrine/ORM/Tools/SchemaTool.php | 4 +++- .../Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php | 8 +++++++- .../Tests/ORM/Functional/SchemaTool/DDC214Test.php | 7 ++++++- tests/Doctrine/Tests/TestUtil.php | 7 ++++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 18e14f718ea..9883f645d1e 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -834,7 +834,9 @@ public function dropDatabase(): void */ public function getDropDatabaseSQL(): array { - $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? 'introspectSchema' : 'createSchema'; + $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? + 'introspectSchema' : + 'createSchema'; return $this->schemaManager ->$method() diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php index 854897bea97..4e23a596492 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php @@ -4,9 +4,12 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; +use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Schema; use Doctrine\Tests\OrmFunctionalTestCase; +use function method_exists; + /** * Functional tests for the Class Table Inheritance mapping strategy. */ @@ -21,7 +24,10 @@ protected function setUp(): void /** @group DDC-966 */ public function testGeneratedSchema(): Schema { - $schema = $this->createSchemaManager()->createSchema(); + $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? + 'introspectSchema' : + 'createSchema'; + $schema = $this->createSchemaManager()->$method(); self::assertTrue($schema->hasTable('company_contracts')); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 4f5e20795ad..72763d9a323 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -5,11 +5,13 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; use Doctrine\DBAL\Platforms\SQLitePlatform; +use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; use function array_filter; use function implode; +use function method_exists; use function str_contains; use const PHP_EOL; @@ -65,7 +67,10 @@ public function assertCreatedSchemaNeedsNoUpdates(string ...$classes): void $sm = $this->createSchemaManager(); - $fromSchema = $sm->createSchema(); + $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? + 'introspectSchema' : + 'createSchema'; + $fromSchema = $sm->$method(); $toSchema = $this->getSchemaForModels(...$classes); $comparator = $sm->createComparator(); $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index 7dbf4bead9a..abb1249d1b0 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -10,12 +10,14 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use Doctrine\DBAL\Platforms\SQLitePlatform; +use Doctrine\DBAL\Schema\AbstractSchemaManager; use UnexpectedValueException; use function assert; use function explode; use function fwrite; use function get_debug_type; +use function method_exists; use function sprintf; use function str_starts_with; use function strlen; @@ -90,7 +92,10 @@ private static function initializeDatabase(): void $platform = $privConn->getDatabasePlatform(); if ($platform instanceof SQLitePlatform) { - $schema = $testConn->createSchemaManager()->createSchema(); + $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? + 'introspectSchema' : + 'createSchema'; + $schema = $testConn->createSchemaManager()->$method(); $stmts = $schema->toDropSql($testConn->getDatabasePlatform()); foreach ($stmts as $stmt) { From ffd47ce2dd88fc613be7170101a1f9221e648d76 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 22 Sep 2022 11:24:05 +0200 Subject: [PATCH 164/475] Add types to mapping builders (#10052) --- .../Mapping/Builder/AssociationBuilder.php | 85 ++++----- .../Mapping/Builder/ClassMetadataBuilder.php | 168 +++++------------- .../ORM/Mapping/Builder/EmbeddedBuilder.php | 22 +-- .../Mapping/Builder/EntityListenerBuilder.php | 10 +- .../ORM/Mapping/Builder/FieldBuilder.php | 93 +++------- .../Builder/ManyToManyAssociationBuilder.php | 33 ++-- .../Builder/OneToManyAssociationBuilder.php | 13 +- psalm-baseline.xml | 12 -- .../ORM/Mapping/ClassMetadataBuilderTest.php | 4 +- 9 files changed, 131 insertions(+), 309 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php index 0b8bc3cdff0..50817b4c39b 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php @@ -9,43 +9,27 @@ class AssociationBuilder { - /** @var ClassMetadataBuilder */ - protected $builder; - - /** @var mixed[] */ - protected $mapping; - /** @var mixed[]|null */ - protected $joinColumns; + protected array|null $joinColumns = null; - /** - * @param mixed[] $mapping - * @param int $type - */ - public function __construct(ClassMetadataBuilder $builder, array $mapping, protected $type) - { - $this->builder = $builder; - $this->mapping = $mapping; + /** @param mixed[] $mapping */ + public function __construct( + protected readonly ClassMetadataBuilder $builder, + protected array $mapping, + protected readonly int $type, + ) { } - /** - * @param string $fieldName - * - * @return $this - */ - public function mappedBy($fieldName) + /** @return $this */ + public function mappedBy(string $fieldName): static { $this->mapping['mappedBy'] = $fieldName; return $this; } - /** - * @param string $fieldName - * - * @return $this - */ - public function inversedBy($fieldName) + /** @return $this */ + public function inversedBy(string $fieldName): static { $this->mapping['inversedBy'] = $fieldName; @@ -53,7 +37,7 @@ public function inversedBy($fieldName) } /** @return $this */ - public function cascadeAll() + public function cascadeAll(): static { $this->mapping['cascade'] = ['ALL']; @@ -61,7 +45,7 @@ public function cascadeAll() } /** @return $this */ - public function cascadePersist() + public function cascadePersist(): static { $this->mapping['cascade'][] = 'persist'; @@ -69,7 +53,7 @@ public function cascadePersist() } /** @return $this */ - public function cascadeRemove() + public function cascadeRemove(): static { $this->mapping['cascade'][] = 'remove'; @@ -77,7 +61,7 @@ public function cascadeRemove() } /** @return $this */ - public function cascadeMerge() + public function cascadeMerge(): static { $this->mapping['cascade'][] = 'merge'; @@ -85,7 +69,7 @@ public function cascadeMerge() } /** @return $this */ - public function cascadeDetach() + public function cascadeDetach(): static { $this->mapping['cascade'][] = 'detach'; @@ -93,7 +77,7 @@ public function cascadeDetach() } /** @return $this */ - public function cascadeRefresh() + public function cascadeRefresh(): static { $this->mapping['cascade'][] = 'refresh'; @@ -101,7 +85,7 @@ public function cascadeRefresh() } /** @return $this */ - public function fetchExtraLazy() + public function fetchExtraLazy(): static { $this->mapping['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; @@ -109,7 +93,7 @@ public function fetchExtraLazy() } /** @return $this */ - public function fetchEager() + public function fetchEager(): static { $this->mapping['fetch'] = ClassMetadata::FETCH_EAGER; @@ -117,7 +101,7 @@ public function fetchEager() } /** @return $this */ - public function fetchLazy() + public function fetchLazy(): static { $this->mapping['fetch'] = ClassMetadata::FETCH_LAZY; @@ -127,17 +111,16 @@ public function fetchLazy() /** * Add Join Columns. * - * @param string $columnName - * @param string $referencedColumnName - * @param bool $nullable - * @param bool $unique - * @param string|null $onDelete - * @param string|null $columnDef - * * @return $this */ - public function addJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null) - { + public function addJoinColumn( + string $columnName, + string $referencedColumnName, + bool $nullable = true, + bool $unique = false, + string|null $onDelete = null, + string|null $columnDef = null, + ): static { $this->joinColumns[] = [ 'name' => $columnName, 'referencedColumnName' => $referencedColumnName, @@ -155,7 +138,7 @@ public function addJoinColumn($columnName, $referencedColumnName, $nullable = tr * * @return $this */ - public function makePrimaryKey() + public function makePrimaryKey(): static { $this->mapping['id'] = true; @@ -167,19 +150,15 @@ public function makePrimaryKey() * * @return $this */ - public function orphanRemoval() + public function orphanRemoval(): static { $this->mapping['orphanRemoval'] = true; return $this; } - /** - * @return ClassMetadataBuilder - * - * @throws InvalidArgumentException - */ - public function build() + /** @throws InvalidArgumentException */ + public function build(): ClassMetadataBuilder { $mapping = $this->mapping; if ($this->joinColumns) { diff --git a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php index d023481955e..d3798805aa2 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php @@ -13,12 +13,9 @@ */ class ClassMetadataBuilder { - /** @var ClassMetadata */ - private $cm; - - public function __construct(ClassMetadata $cm) - { - $this->cm = $cm; + public function __construct( + private readonly ClassMetadata $cm, + ) { } public function getClassMetadata(): ClassMetadata @@ -31,7 +28,7 @@ public function getClassMetadata(): ClassMetadata * * @return $this */ - public function setMappedSuperClass() + public function setMappedSuperClass(): static { $this->cm->isMappedSuperclass = true; $this->cm->isEmbeddedClass = false; @@ -44,7 +41,7 @@ public function setMappedSuperClass() * * @return $this */ - public function setEmbeddable() + public function setEmbeddable(): static { $this->cm->isEmbeddedClass = true; $this->cm->isMappedSuperclass = false; @@ -55,13 +52,9 @@ public function setEmbeddable() /** * Adds and embedded class * - * @param string $fieldName - * @param string $class - * @param string|false|null $columnPrefix - * * @return $this */ - public function addEmbedded($fieldName, $class, $columnPrefix = null) + public function addEmbedded(string $fieldName, string $class, string|false|null $columnPrefix = null): static { $this->cm->mapEmbedded( [ @@ -77,11 +70,9 @@ public function addEmbedded($fieldName, $class, $columnPrefix = null) /** * Sets custom Repository class name. * - * @param string $repositoryClassName - * * @return $this */ - public function setCustomRepositoryClass($repositoryClassName) + public function setCustomRepositoryClass(string $repositoryClassName): static { $this->cm->setCustomRepositoryClass($repositoryClassName); @@ -93,7 +84,7 @@ public function setCustomRepositoryClass($repositoryClassName) * * @return $this */ - public function setReadOnly() + public function setReadOnly(): static { $this->cm->markReadOnly(); @@ -103,11 +94,9 @@ public function setReadOnly() /** * Sets the table name. * - * @param string $name - * * @return $this */ - public function setTable($name) + public function setTable(string $name): static { $this->cm->setPrimaryTable(['name' => $name]); @@ -117,12 +106,11 @@ public function setTable($name) /** * Adds Index. * - * @param string $name * @psalm-param list $columns * * @return $this */ - public function addIndex(array $columns, $name) + public function addIndex(array $columns, string $name): static { if (! isset($this->cm->table['indexes'])) { $this->cm->table['indexes'] = []; @@ -136,12 +124,11 @@ public function addIndex(array $columns, $name) /** * Adds Unique Constraint. * - * @param string $name * @psalm-param list $columns * * @return $this */ - public function addUniqueConstraint(array $columns, $name) + public function addUniqueConstraint(array $columns, string $name): static { if (! isset($this->cm->table['uniqueConstraints'])) { $this->cm->table['uniqueConstraints'] = []; @@ -157,7 +144,7 @@ public function addUniqueConstraint(array $columns, $name) * * @return $this */ - public function setJoinedTableInheritance() + public function setJoinedTableInheritance(): static { $this->cm->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_JOINED); @@ -169,7 +156,7 @@ public function setJoinedTableInheritance() * * @return $this */ - public function setSingleTableInheritance() + public function setSingleTableInheritance(): static { $this->cm->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE); @@ -179,13 +166,9 @@ public function setSingleTableInheritance() /** * Sets the discriminator column details. * - * @param string $name - * @param string $type - * @param int $length - * * @return $this */ - public function setDiscriminatorColumn($name, $type = 'string', $length = 255) + public function setDiscriminatorColumn(string $name, string $type = 'string', int $length = 255): static { $this->cm->setDiscriminatorColumn( [ @@ -201,12 +184,9 @@ public function setDiscriminatorColumn($name, $type = 'string', $length = 255) /** * Adds a subclass to this inheritance hierarchy. * - * @param string $name - * @param string $class - * * @return $this */ - public function addDiscriminatorMapClass($name, $class) + public function addDiscriminatorMapClass(string $name, string $class): static { $this->cm->addDiscriminatorMapClass($name, $class); @@ -218,7 +198,7 @@ public function addDiscriminatorMapClass($name, $class) * * @return $this */ - public function setChangeTrackingPolicyDeferredExplicit() + public function setChangeTrackingPolicyDeferredExplicit(): static { $this->cm->setChangeTrackingPolicy(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT); @@ -230,7 +210,7 @@ public function setChangeTrackingPolicyDeferredExplicit() * * @return $this */ - public function setChangeTrackingPolicyNotify() + public function setChangeTrackingPolicyNotify(): static { $this->cm->setChangeTrackingPolicy(ClassMetadata::CHANGETRACKING_NOTIFY); @@ -240,12 +220,9 @@ public function setChangeTrackingPolicyNotify() /** * Adds lifecycle event. * - * @param string $methodName - * @param string $event - * * @return $this */ - public function addLifecycleEvent($methodName, $event) + public function addLifecycleEvent(string $methodName, string $event): static { $this->cm->addLifecycleCallback($methodName, $event); @@ -255,13 +232,11 @@ public function addLifecycleEvent($methodName, $event) /** * Adds Field. * - * @param string $name - * @param string $type * @psalm-param array $mapping * * @return $this */ - public function addField($name, $type, array $mapping = []) + public function addField(string $name, string $type, array $mapping = []): static { $mapping['fieldName'] = $name; $mapping['type'] = $type; @@ -273,13 +248,8 @@ public function addField($name, $type, array $mapping = []) /** * Creates a field builder. - * - * @param string $name - * @param string $type - * - * @return FieldBuilder */ - public function createField($name, $type) + public function createField(string $name, string $type): FieldBuilder { return new FieldBuilder( $this, @@ -292,13 +262,8 @@ public function createField($name, $type) /** * Creates an embedded builder. - * - * @param string $fieldName - * @param string $class - * - * @return EmbeddedBuilder */ - public function createEmbedded($fieldName, $class) + public function createEmbedded(string $fieldName, string $class): EmbeddedBuilder { return new EmbeddedBuilder( $this, @@ -312,15 +277,12 @@ public function createEmbedded($fieldName, $class) /** * Adds a simple many to one association, optionally with the inversed by field. - * - * @param string $name - * @param string $targetEntity - * @param string|null $inversedBy - * - * @return ClassMetadataBuilder */ - public function addManyToOne($name, $targetEntity, $inversedBy = null) - { + public function addManyToOne( + string $name, + string $targetEntity, + string|null $inversedBy = null, + ): ClassMetadataBuilder { $builder = $this->createManyToOne($name, $targetEntity); if ($inversedBy) { @@ -334,13 +296,8 @@ public function addManyToOne($name, $targetEntity, $inversedBy = null) * Creates a ManyToOne Association Builder. * * Note: This method does not add the association, you have to call build() on the AssociationBuilder. - * - * @param string $name - * @param string $targetEntity - * - * @return AssociationBuilder */ - public function createManyToOne($name, $targetEntity) + public function createManyToOne(string $name, string $targetEntity): AssociationBuilder { return new AssociationBuilder( $this, @@ -354,13 +311,8 @@ public function createManyToOne($name, $targetEntity) /** * Creates a OneToOne Association Builder. - * - * @param string $name - * @param string $targetEntity - * - * @return AssociationBuilder */ - public function createOneToOne($name, $targetEntity) + public function createOneToOne(string $name, string $targetEntity): AssociationBuilder { return new AssociationBuilder( $this, @@ -374,14 +326,8 @@ public function createOneToOne($name, $targetEntity) /** * Adds simple inverse one-to-one association. - * - * @param string $name - * @param string $targetEntity - * @param string $mappedBy - * - * @return ClassMetadataBuilder */ - public function addInverseOneToOne($name, $targetEntity, $mappedBy) + public function addInverseOneToOne(string $name, string $targetEntity, string $mappedBy): ClassMetadataBuilder { $builder = $this->createOneToOne($name, $targetEntity); $builder->mappedBy($mappedBy); @@ -391,15 +337,12 @@ public function addInverseOneToOne($name, $targetEntity, $mappedBy) /** * Adds simple owning one-to-one association. - * - * @param string $name - * @param string $targetEntity - * @param string|null $inversedBy - * - * @return ClassMetadataBuilder */ - public function addOwningOneToOne($name, $targetEntity, $inversedBy = null) - { + public function addOwningOneToOne( + string $name, + string $targetEntity, + string|null $inversedBy = null, + ): ClassMetadataBuilder { $builder = $this->createOneToOne($name, $targetEntity); if ($inversedBy) { @@ -411,13 +354,8 @@ public function addOwningOneToOne($name, $targetEntity, $inversedBy = null) /** * Creates a ManyToMany Association Builder. - * - * @param string $name - * @param string $targetEntity - * - * @return ManyToManyAssociationBuilder */ - public function createManyToMany($name, $targetEntity) + public function createManyToMany(string $name, string $targetEntity): ManyToManyAssociationBuilder { return new ManyToManyAssociationBuilder( $this, @@ -431,15 +369,12 @@ public function createManyToMany($name, $targetEntity) /** * Adds a simple owning many to many association. - * - * @param string $name - * @param string $targetEntity - * @param string|null $inversedBy - * - * @return ClassMetadataBuilder */ - public function addOwningManyToMany($name, $targetEntity, $inversedBy = null) - { + public function addOwningManyToMany( + string $name, + string $targetEntity, + string|null $inversedBy = null, + ): ClassMetadataBuilder { $builder = $this->createManyToMany($name, $targetEntity); if ($inversedBy) { @@ -451,14 +386,8 @@ public function addOwningManyToMany($name, $targetEntity, $inversedBy = null) /** * Adds a simple inverse many to many association. - * - * @param string $name - * @param string $targetEntity - * @param string $mappedBy - * - * @return ClassMetadataBuilder */ - public function addInverseManyToMany($name, $targetEntity, $mappedBy) + public function addInverseManyToMany(string $name, string $targetEntity, string $mappedBy): ClassMetadataBuilder { $builder = $this->createManyToMany($name, $targetEntity); $builder->mappedBy($mappedBy); @@ -468,13 +397,8 @@ public function addInverseManyToMany($name, $targetEntity, $mappedBy) /** * Creates a one to many association builder. - * - * @param string $name - * @param string $targetEntity - * - * @return OneToManyAssociationBuilder */ - public function createOneToMany($name, $targetEntity) + public function createOneToMany(string $name, string $targetEntity): OneToManyAssociationBuilder { return new OneToManyAssociationBuilder( $this, @@ -488,14 +412,8 @@ public function createOneToMany($name, $targetEntity) /** * Adds simple OneToMany association. - * - * @param string $name - * @param string $targetEntity - * @param string $mappedBy - * - * @return ClassMetadataBuilder */ - public function addOneToMany($name, $targetEntity, $mappedBy) + public function addOneToMany(string $name, string $targetEntity, string $mappedBy): ClassMetadataBuilder { $builder = $this->createOneToMany($name, $targetEntity); $builder->mappedBy($mappedBy); diff --git a/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php index a8508ab3bbe..b9d2127393b 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php @@ -11,27 +11,19 @@ */ class EmbeddedBuilder { - /** @var ClassMetadataBuilder */ - private $builder; - - /** @var mixed[] */ - private $mapping; - /** @param mixed[] $mapping */ - public function __construct(ClassMetadataBuilder $builder, array $mapping) - { - $this->builder = $builder; - $this->mapping = $mapping; + public function __construct( + private readonly ClassMetadataBuilder $builder, + private array $mapping, + ) { } /** * Sets the column prefix for all of the embedded columns. * - * @param string $columnPrefix - * * @return $this */ - public function setColumnPrefix($columnPrefix) + public function setColumnPrefix(string $columnPrefix): static { $this->mapping['columnPrefix'] = $columnPrefix; @@ -42,10 +34,8 @@ public function setColumnPrefix($columnPrefix) * Finalizes this embeddable and attach it to the ClassMetadata. * * Without this call an EmbeddedBuilder has no effect on the ClassMetadata. - * - * @return ClassMetadataBuilder */ - public function build() + public function build(): ClassMetadataBuilder { $cm = $this->builder->getClassMetadata(); diff --git a/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php index 1ba8c7a787a..a0b14b954c5 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php @@ -16,8 +16,8 @@ */ class EntityListenerBuilder { - /** @var array Hash-map to handle event names. */ - private static $events = [ + /** Hash-map to handle event names. */ + private const EVENTS = [ Events::preRemove => true, Events::postRemove => true, Events::prePersist => true, @@ -34,11 +34,9 @@ class EntityListenerBuilder * @param ClassMetadata $metadata The entity metadata. * @param string $className The listener class name. * - * @return void - * * @throws MappingException When the listener class not found. */ - public static function bindEntityListener(ClassMetadata $metadata, $className) + public static function bindEntityListener(ClassMetadata $metadata, string $className): void { $class = $metadata->fullyQualifiedClassName($className); @@ -47,7 +45,7 @@ public static function bindEntityListener(ClassMetadata $metadata, $className) } foreach (get_class_methods($class) as $method) { - if (! isset(self::$events[$method])) { + if (! isset(self::EVENTS[$method])) { continue; } diff --git a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php index bdd87788cb9..8326ff5017c 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php @@ -13,39 +13,27 @@ */ class FieldBuilder { - /** @var ClassMetadataBuilder */ - private $builder; + private bool $version = false; + private string|null $generatedValue = null; - /** @var mixed[] */ - private $mapping; + /** @var mixed[]|null */ + private array|null $sequenceDef = null; - /** @var bool */ - private $version; - - /** @var string */ - private $generatedValue; - - /** @var mixed[] */ - private $sequenceDef; - - /** @var string|null */ - private $customIdGenerator; + private string|null $customIdGenerator = null; /** @param mixed[] $mapping */ - public function __construct(ClassMetadataBuilder $builder, array $mapping) - { - $this->builder = $builder; - $this->mapping = $mapping; + public function __construct( + private readonly ClassMetadataBuilder $builder, + private array $mapping, + ) { } /** * Sets length. * - * @param int $length - * * @return $this */ - public function length($length) + public function length(int $length): static { $this->mapping['length'] = $length; @@ -55,13 +43,11 @@ public function length($length) /** * Sets nullable. * - * @param bool $flag - * * @return $this */ - public function nullable($flag = true) + public function nullable(bool $flag = true): static { - $this->mapping['nullable'] = (bool) $flag; + $this->mapping['nullable'] = $flag; return $this; } @@ -69,13 +55,11 @@ public function nullable($flag = true) /** * Sets Unique. * - * @param bool $flag - * * @return $this */ - public function unique($flag = true) + public function unique(bool $flag = true): static { - $this->mapping['unique'] = (bool) $flag; + $this->mapping['unique'] = $flag; return $this; } @@ -83,11 +67,9 @@ public function unique($flag = true) /** * Sets column name. * - * @param string $name - * * @return $this */ - public function columnName($name) + public function columnName(string $name): static { $this->mapping['columnName'] = $name; @@ -97,11 +79,9 @@ public function columnName($name) /** * Sets Precision. * - * @param int $p - * * @return $this */ - public function precision($p) + public function precision(int $p): static { $this->mapping['precision'] = $p; @@ -139,11 +119,9 @@ public function updatable(bool $flag = true): self /** * Sets scale. * - * @param int $s - * * @return $this */ - public function scale($s) + public function scale(int $s): static { $this->mapping['scale'] = $s; @@ -155,7 +133,7 @@ public function scale($s) * * @return $this */ - public function makePrimaryKey() + public function makePrimaryKey(): static { $this->mapping['id'] = true; @@ -165,24 +143,17 @@ public function makePrimaryKey() /** * Sets an option. * - * @param string $name - * @param mixed $value - * * @return $this */ - public function option($name, $value) + public function option(string $name, mixed $value): static { $this->mapping['options'][$name] = $value; return $this; } - /** - * @param string $strategy - * - * @return $this - */ - public function generatedValue($strategy = 'AUTO') + /** @return $this */ + public function generatedValue(string $strategy = 'AUTO'): static { $this->generatedValue = $strategy; @@ -194,7 +165,7 @@ public function generatedValue($strategy = 'AUTO') * * @return $this */ - public function isVersionField() + public function isVersionField(): static { $this->version = true; @@ -204,13 +175,9 @@ public function isVersionField() /** * Sets Sequence Generator. * - * @param string $sequenceName - * @param int $allocationSize - * @param int $initialValue - * * @return $this */ - public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initialValue = 1) + public function setSequenceGenerator(string $sequenceName, int $allocationSize = 1, int $initialValue = 1): static { $this->sequenceDef = [ 'sequenceName' => $sequenceName, @@ -224,11 +191,9 @@ public function setSequenceGenerator($sequenceName, $allocationSize = 1, $initia /** * Sets column definition. * - * @param string $def - * * @return $this */ - public function columnDefinition($def) + public function columnDefinition(string $def): static { $this->mapping['columnDefinition'] = $def; @@ -239,13 +204,11 @@ public function columnDefinition($def) * Set the FQCN of the custom ID generator. * This class must extend \Doctrine\ORM\Id\AbstractIdGenerator. * - * @param string $customIdGenerator - * * @return $this */ - public function setCustomIdGenerator($customIdGenerator) + public function setCustomIdGenerator(string $customIdGenerator): static { - $this->customIdGenerator = (string) $customIdGenerator; + $this->customIdGenerator = $customIdGenerator; return $this; } @@ -254,10 +217,8 @@ public function setCustomIdGenerator($customIdGenerator) * Finalizes this field and attach it to the ClassMetadata. * * Without this call a FieldBuilder has no effect on the ClassMetadata. - * - * @return ClassMetadataBuilder */ - public function build() + public function build(): ClassMetadataBuilder { $cm = $this->builder->getClassMetadata(); if ($this->generatedValue) { diff --git a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php index 5da24eb4b90..b83a8baef9b 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php @@ -11,18 +11,13 @@ */ class ManyToManyAssociationBuilder extends OneToManyAssociationBuilder { - /** @var string|null */ - private $joinTableName; + private string|null $joinTableName = null; /** @var mixed[] */ - private $inverseJoinColumns = []; + private array $inverseJoinColumns = []; - /** - * @param string $name - * - * @return $this - */ - public function setJoinTable($name) + /** @return $this */ + public function setJoinTable(string $name): static { $this->joinTableName = $name; @@ -32,17 +27,16 @@ public function setJoinTable($name) /** * Adds Inverse Join Columns. * - * @param string $columnName - * @param string $referencedColumnName - * @param bool $nullable - * @param bool $unique - * @param string|null $onDelete - * @param string|null $columnDef - * * @return $this */ - public function addInverseJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null) - { + public function addInverseJoinColumn( + string $columnName, + string $referencedColumnName, + bool $nullable = true, + bool $unique = false, + string|null $onDelete = null, + string|null $columnDef = null, + ): static { $this->inverseJoinColumns[] = [ 'name' => $columnName, 'referencedColumnName' => $referencedColumnName, @@ -55,8 +49,7 @@ public function addInverseJoinColumn($columnName, $referencedColumnName, $nullab return $this; } - /** @return ClassMetadataBuilder */ - public function build() + public function build(): ClassMetadataBuilder { $mapping = $this->mapping; $mapping['joinTable'] = []; diff --git a/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php index daf323bc36d..077c558cdd9 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php @@ -16,27 +16,22 @@ class OneToManyAssociationBuilder extends AssociationBuilder * * @return $this */ - public function setOrderBy(array $fieldNames) + public function setOrderBy(array $fieldNames): static { $this->mapping['orderBy'] = $fieldNames; return $this; } - /** - * @param string $fieldName - * - * @return $this - */ - public function setIndexBy($fieldName) + /** @return $this */ + public function setIndexBy(string $fieldName): static { $this->mapping['indexBy'] = $fieldName; return $this; } - /** @return ClassMetadataBuilder */ - public function build() + public function build(): ClassMetadataBuilder { $mapping = $this->mapping; if ($this->joinColumns) { diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fc2fa7fce48..699785cee0d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -311,18 +311,6 @@ $class - - - $generatedValue - $sequenceDef - $version - - - (bool) $flag - (bool) $flag - (string) $customIdGenerator - - ClassMetadata diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index e4dd30653e9..cd66b1a78b0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -180,8 +180,8 @@ public function testSetInheritanceSingleTable(): void public function testSetDiscriminatorColumn(): void { - $this->assertIsFluent($this->builder->setDiscriminatorColumn('discr', 'string', '124')); - self::assertEquals(['fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => '124'], $this->cm->discriminatorColumn); + $this->assertIsFluent($this->builder->setDiscriminatorColumn('discr', 'string', 124)); + self::assertEquals(['fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => 124], $this->cm->discriminatorColumn); } public function testAddDiscriminatorMapClass(): void From f32ae29385668ebc309bc0cd38df47316f030342 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 22 Sep 2022 15:34:46 +0200 Subject: [PATCH 165/475] Add types to PersisterHelper (#10053) --- lib/Doctrine/ORM/Utility/PersisterHelper.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index 572d0c4b129..9eca8aa6613 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -20,13 +20,11 @@ class PersisterHelper { /** - * @param string $fieldName - * - * @return array + * @return list * * @throws QueryException */ - public static function getTypeOfField($fieldName, ClassMetadata $class, EntityManagerInterface $em) + public static function getTypeOfField(string $fieldName, ClassMetadata $class, EntityManagerInterface $em): array { if (isset($class->fieldMappings[$fieldName])) { return [$class->fieldMappings[$fieldName]['type']]; @@ -58,14 +56,8 @@ public static function getTypeOfField($fieldName, ClassMetadata $class, EntityMa return $types; } - /** - * @param string $columnName - * - * @return string - * - * @throws RuntimeException - */ - public static function getTypeOfColumn($columnName, ClassMetadata $class, EntityManagerInterface $em) + /** @throws RuntimeException */ + public static function getTypeOfColumn(string $columnName, ClassMetadata $class, EntityManagerInterface $em): string { if (isset($class->fieldNames[$columnName])) { $fieldName = $class->fieldNames[$columnName]; From d62359a00931d5d712889eefd1588ac5d9867f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 21 Sep 2022 21:14:32 +0200 Subject: [PATCH 166/475] Migrate QueryBuilder to PHP 8.1 --- lib/Doctrine/ORM/QueryBuilder.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 31b7a47f230..40abef2a065 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -12,9 +12,9 @@ use Doctrine\ORM\Query\QueryExpressionVisitor; use InvalidArgumentException; use RuntimeException; +use Stringable; use function array_keys; -use function array_merge; use function array_unshift; use function assert; use function count; @@ -36,7 +36,7 @@ * This class is responsible for building DQL query strings via an object oriented * PHP interface. */ -class QueryBuilder +class QueryBuilder implements Stringable { /** * The array of DQL parts collected. @@ -378,7 +378,7 @@ public function getRootAliases(): array */ public function getAllAliases(): array { - return array_merge($this->getRootAliases(), array_keys($this->joinRootAliases)); + return [...$this->getRootAliases(), ...array_keys($this->joinRootAliases)]; } /** @@ -511,9 +511,8 @@ public function setFirstResult(int|null $firstResult): static /** * Gets the position of the first result the query object was set to retrieve (the "offset"). - * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder. */ - public function getFirstResult(): int|null + public function getFirstResult(): int { return $this->firstResult; } From 75a7cc983c906b4981bab21da0bff617f34ddd2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 21 Sep 2022 21:22:50 +0200 Subject: [PATCH 167/475] Migrate ClassMetadataInfo to PHP 8.1 --- .../ORM/Mapping/ClassMetadataInfo.php | 570 +++++------------- psalm-baseline.xml | 47 +- 2 files changed, 161 insertions(+), 456 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 38e04cd6497..cd769dbd658 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -26,6 +26,7 @@ use ReflectionNamedType; use ReflectionProperty; use RuntimeException; +use Stringable; use function array_diff; use function array_flip; @@ -139,7 +140,7 @@ * unique?: bool, * } */ -class ClassMetadataInfo implements ClassMetadata +class ClassMetadataInfo implements ClassMetadata, Stringable { /* The inheritance mapping types */ /** @@ -300,31 +301,21 @@ class ClassMetadataInfo implements ClassMetadata */ public const GENERATED_ALWAYS = 2; - /** - * READ-ONLY: The name of the entity class. - * - * @var string - * @psalm-var class-string - */ - public $name; - /** * READ-ONLY: The namespace the entity class is contained in. * - * @var string * @todo Not really needed. Usage could be localized. */ - public $namespace; + public string|null $namespace = null; /** * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same * as {@link $name}. * - * @var string * @psalm-var class-string */ - public $rootEntityName; + public string $rootEntityName; /** * READ-ONLY: The definition of custom generator. Only used for CUSTOM @@ -340,51 +331,46 @@ class ClassMetadataInfo implements ClassMetadata * @todo Merge with tableGeneratorDefinition into generic generatorDefinition * @var array|null */ - public $customGeneratorDefinition; + public array|null $customGeneratorDefinition = null; /** * The name of the custom repository class used for the entity class. * (Optional). * - * @var string|null * @psalm-var ?class-string */ - public $customRepositoryClassName; + public string|null $customRepositoryClassName = null; /** * READ-ONLY: Whether this class describes the mapping of a mapped superclass. - * - * @var bool */ - public $isMappedSuperclass = false; + public bool $isMappedSuperclass = false; /** * READ-ONLY: Whether this class describes the mapping of an embeddable class. - * - * @var bool */ - public $isEmbeddedClass = false; + public bool $isEmbeddedClass = false; /** * READ-ONLY: The names of the parent classes (ancestors). * * @psalm-var list */ - public $parentClasses = []; + public array $parentClasses = []; /** * READ-ONLY: The names of all subclasses (descendants). * * @psalm-var list */ - public $subClasses = []; + public array $subClasses = []; /** * READ-ONLY: The names of all embedded classes based on properties. * * @psalm-var array */ - public $embeddedClasses = []; + public array $embeddedClasses = []; /** * READ-ONLY: The mappings of the results of native SQL queries. @@ -404,7 +390,7 @@ class ClassMetadataInfo implements ClassMetadata * columns: mixed[] * }> */ - public $sqlResultSetMappings = []; + public array $sqlResultSetMappings = []; /** * READ-ONLY: The field names of all fields that are part of the identifier/primary key @@ -412,23 +398,21 @@ class ClassMetadataInfo implements ClassMetadata * * @psalm-var list */ - public $identifier = []; + public array $identifier = []; /** * READ-ONLY: The inheritance mapping type used by the class. * - * @var int * @psalm-var self::INHERITANCE_TYPE_* */ - public $inheritanceType = self::INHERITANCE_TYPE_NONE; + public int $inheritanceType = self::INHERITANCE_TYPE_NONE; /** * READ-ONLY: The Id generator type used by the class. * - * @var int * @psalm-var self::GENERATOR_TYPE_* */ - public $generatorType = self::GENERATOR_TYPE_NONE; + public int $generatorType = self::GENERATOR_TYPE_NONE; /** * READ-ONLY: The field mappings of the class. @@ -478,7 +462,7 @@ class ClassMetadataInfo implements ClassMetadata * @var mixed[] * @psalm-var array */ - public $fieldMappings = []; + public array $fieldMappings = []; /** * READ-ONLY: An array of field names. Used to look up field names from column names. @@ -486,7 +470,7 @@ class ClassMetadataInfo implements ClassMetadata * * @psalm-var array */ - public $fieldNames = []; + public array $fieldNames = []; /** * READ-ONLY: A map of field names to column names. Keys are field names and values column names. @@ -497,7 +481,7 @@ class ClassMetadataInfo implements ClassMetadata * * @var mixed[] */ - public $columnNames = []; + public array $columnNames = []; /** * READ-ONLY: The discriminator value of this class. @@ -506,10 +490,8 @@ class ClassMetadataInfo implements ClassMetadata * where a discriminator column is used. * * @see discriminatorColumn - * - * @var mixed */ - public $discriminatorValue; + public mixed $discriminatorValue = null; /** * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. @@ -523,7 +505,7 @@ class ClassMetadataInfo implements ClassMetadata * * @psalm-var array */ - public $discriminatorMap = []; + public array $discriminatorMap = []; /** * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE @@ -531,7 +513,7 @@ class ClassMetadataInfo implements ClassMetadata * * @psalm-var array{name: string, fieldName: string, type: string, length?: int, columnDefinition?: string|null}|null */ - public $discriminatorColumn; + public array|null $discriminatorColumn = null; /** * READ-ONLY: The primary table definition. The definition is an array with the @@ -552,21 +534,21 @@ class ClassMetadataInfo implements ClassMetadata * quoted?: bool * } */ - public $table; + public array $table; /** * READ-ONLY: The registered lifecycle callbacks for entities of this class. * * @psalm-var array> */ - public $lifecycleCallbacks = []; + public array $lifecycleCallbacks = []; /** * READ-ONLY: The registered entity listeners. * * @psalm-var array> */ - public $entityListeners = []; + public array $entityListeners = []; /** * READ-ONLY: The association mappings of this class. @@ -623,40 +605,33 @@ class ClassMetadataInfo implements ClassMetadata * * @psalm-var array */ - public $associationMappings = []; + public array $associationMappings = []; /** * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. - * - * @var bool */ - public $isIdentifierComposite = false; + public bool $isIdentifierComposite = false; /** * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. * * This flag is necessary because some code blocks require special treatment of this cases. - * - * @var bool */ - public $containsForeignIdentifier = false; + public bool $containsForeignIdentifier = false; /** * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one ENUM type. * * This flag is necessary because some code blocks require special treatment of this cases. - * - * @var bool */ - public $containsEnumIdentifier = false; + public bool $containsEnumIdentifier = false; /** * READ-ONLY: The ID generator used for generating IDs for this class. * - * @var AbstractIdGenerator * @todo Remove! */ - public $idGenerator; + public AbstractIdGenerator $idGenerator; /** * READ-ONLY: The definition of the sequence generator of this class. Only used for the @@ -675,47 +650,39 @@ class ClassMetadataInfo implements ClassMetadata * @psalm-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed}|null * @todo Merge with tableGeneratorDefinition into generic generatorDefinition */ - public $sequenceGeneratorDefinition; + public array|null $sequenceGeneratorDefinition = null; /** * READ-ONLY: The policy used for change-tracking on entities of this class. - * - * @var int */ - public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; + public int $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; /** * READ-ONLY: A Flag indicating whether one or more columns of this class * have to be reloaded after insert / update operations. - * - * @var bool */ - public $requiresFetchAfterChange = false; + public bool $requiresFetchAfterChange = false; /** * READ-ONLY: A flag for whether or not instances of this class are to be versioned * with optimistic locking. - * - * @var bool */ - public $isVersioned = false; + public bool $isVersioned = false; /** * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). - * - * @var string|null */ - public $versionField; + public string|null $versionField = null; /** @var mixed[]|null */ - public $cache; + public array|null $cache = null; /** * The ReflectionClass instance of the mapped class. * - * @var ReflectionClass|null + * @var ReflectionClass|null */ - public $reflClass; + public ReflectionClass|null $reflClass = null; /** * Is this entity marked as "read-only"? @@ -723,39 +690,33 @@ class ClassMetadataInfo implements ClassMetadata * That means it is never considered for change-tracking in the UnitOfWork. It is a very helpful performance * optimization for entities that are immutable, either in your domain or through the relation database * (coming from a view, or a history table for example). - * - * @var bool */ - public $isReadOnly = false; + public bool $isReadOnly = false; /** * NamingStrategy determining the default column and table names. - * - * @var NamingStrategy */ - protected $namingStrategy; + protected NamingStrategy $namingStrategy; /** * The ReflectionProperty instances of the mapped class. * * @var array */ - public $reflFields = []; + public array $reflFields = []; - /** @var InstantiatorInterface|null */ - private $instantiator; + private InstantiatorInterface|null $instantiator = null; /** * Initializes a new ClassMetadata instance that will hold the object-relational mapping * metadata of the class with the given name. * - * @param string $entityName The name of the entity class the new instance is used for. - * @psalm-param class-string $entityName + * @param string $name The name of the entity class the new instance is used for. + * @psalm-param class-string $name */ - public function __construct($entityName, NamingStrategy|null $namingStrategy = null) + public function __construct(public $name, NamingStrategy|null $namingStrategy = null) { - $this->name = $entityName; - $this->rootEntityName = $entityName; + $this->rootEntityName = $name; $this->namingStrategy = $namingStrategy ?: new DefaultNamingStrategy(); $this->instantiator = new Instantiator(); } @@ -766,19 +727,15 @@ public function __construct($entityName, NamingStrategy|null $namingStrategy = n * @return ReflectionProperty[]|null[] An array of ReflectionProperty instances. * @psalm-return array */ - public function getReflectionProperties() + public function getReflectionProperties(): array { return $this->reflFields; } /** * Gets a ReflectionProperty for a specific field of the mapped class. - * - * @param string $name - * - * @return ReflectionProperty */ - public function getReflectionProperty($name) + public function getReflectionProperty(string $name): ReflectionProperty|null { return $this->reflFields[$name]; } @@ -786,11 +743,9 @@ public function getReflectionProperty($name) /** * Gets the ReflectionProperty for the single identifier field. * - * @return ReflectionProperty - * * @throws BadMethodCallException If the class has a composite identifier. */ - public function getSingleIdReflectionProperty() + public function getSingleIdReflectionProperty(): ReflectionProperty|null { if ($this->isIdentifierComposite) { throw new BadMethodCallException('Class ' . $this->name . ' has a composite identifier.'); @@ -809,7 +764,7 @@ public function getSingleIdReflectionProperty() * * @return array */ - public function getIdentifierValues($entity) + public function getIdentifierValues($entity): array { if ($this->isIdentifierComposite) { $id = []; @@ -838,14 +793,11 @@ public function getIdentifierValues($entity) /** * Populates the entity identifier of an entity. * - * @param object $entity * @psalm-param array $id * - * @return void - * * @todo Rename to assignIdentifier() */ - public function setIdentifierValues($entity, array $id) + public function setIdentifierValues(object $entity, array $id): void { foreach ($id as $idField => $idValue) { $this->reflFields[$idField]->setValue($entity, $idValue); @@ -854,27 +806,16 @@ public function setIdentifierValues($entity, array $id) /** * Sets the specified field to the specified value on the given entity. - * - * @param object $entity - * @param string $field - * @param mixed $value - * - * @return void */ - public function setFieldValue($entity, $field, $value) + public function setFieldValue(object $entity, string $field, mixed $value): void { $this->reflFields[$field]->setValue($entity, $value); } /** * Gets the specified field's value off the given entity. - * - * @param object $entity - * @param string $field - * - * @return mixed */ - public function getFieldValue($entity, $field) + public function getFieldValue(object $entity, string $field): mixed { return $this->reflFields[$field]->getValue($entity); } @@ -886,7 +827,7 @@ public function getFieldValue($entity, $field) * * @todo Construct meaningful string representation. */ - public function __toString() + public function __toString(): string { return self::class . '@' . spl_object_id($this); } @@ -1001,22 +942,16 @@ public function __sleep() /** * Creates a new instance of the mapped class, without invoking the constructor. - * - * @return object */ - public function newInstance() + public function newInstance(): object { return $this->instantiator->instantiate($this->name); } /** * Restores some state that can not be serialized/unserialized. - * - * @param ReflectionService $reflService - * - * @return void */ - public function wakeupReflection($reflService) + public function wakeupReflection(ReflectionService $reflService): void { // Restore ReflectionClass and properties $this->reflClass = $reflService->getClass($this->name); @@ -1095,10 +1030,8 @@ public function wakeupReflection($reflService) * metadata of the class with the given name. * * @param ReflectionService $reflService The reflection service. - * - * @return void */ - public function initializeReflection($reflService) + public function initializeReflection(ReflectionService $reflService): void { $this->reflClass = $reflService->getClass($this->name); $this->namespace = $reflService->getClassNamespace($this->name); @@ -1113,11 +1046,9 @@ public function initializeReflection($reflService) /** * Validates Identifier. * - * @return void - * * @throws MappingException */ - public function validateIdentifier() + public function validateIdentifier(): void { if ($this->isMappedSuperclass || $this->isEmbeddedClass) { return; @@ -1136,11 +1067,9 @@ public function validateIdentifier() /** * Validates association targets actually exist. * - * @return void - * * @throws MappingException */ - public function validateAssociations() + public function validateAssociations(): void { foreach ($this->associationMappings as $mapping) { if ( @@ -1156,13 +1085,9 @@ public function validateAssociations() /** * Validates lifecycle callbacks. * - * @param ReflectionService $reflService - * - * @return void - * * @throws MappingException */ - public function validateLifecycleCallbacks($reflService) + public function validateLifecycleCallbacks(ReflectionService $reflService): void { foreach ($this->lifecycleCallbacks as $callbacks) { foreach ($callbacks as $callbackFuncName) { @@ -1175,18 +1100,16 @@ public function validateLifecycleCallbacks($reflService) /** * {@inheritDoc} + * + * Can return null when using static reflection, in violation of the LSP */ public function getReflectionClass() { return $this->reflClass; } - /** - * @psalm-param array{usage?: mixed, region?: mixed} $cache - * - * @return void - */ - public function enableCache(array $cache) + /** @psalm-param array{usage?: mixed, region?: mixed} $cache */ + public function enableCache(array $cache): void { if (! isset($cache['usage'])) { $cache['usage'] = self::CACHE_USAGE_READ_ONLY; @@ -1199,26 +1122,19 @@ public function enableCache(array $cache) $this->cache = $cache; } - /** - * @param string $fieldName - * @psalm-param array{usage?: int, region?: string} $cache - * - * @return void - */ - public function enableAssociationCache($fieldName, array $cache) + /** @psalm-param array{usage?: int, region?: string} $cache */ + public function enableAssociationCache(string $fieldName, array $cache): void { $this->associationMappings[$fieldName]['cache'] = $this->getAssociationCacheDefaults($fieldName, $cache); } /** - * @param string $fieldName - * @param array $cache * @psalm-param array{usage?: int, region?: string|null} $cache * * @return int[]|string[] * @psalm-return array{usage: int, region: string|null} */ - public function getAssociationCacheDefaults($fieldName, array $cache) + public function getAssociationCacheDefaults(string $fieldName, array $cache): array { if (! isset($cache['usage'])) { $cache['usage'] = $this->cache['usage'] ?? self::CACHE_USAGE_READ_ONLY; @@ -1233,42 +1149,32 @@ public function getAssociationCacheDefaults($fieldName, array $cache) /** * Sets the change tracking policy used by this class. - * - * @param int $policy - * - * @return void */ - public function setChangeTrackingPolicy($policy) + public function setChangeTrackingPolicy(int $policy): void { $this->changeTrackingPolicy = $policy; } /** * Whether the change tracking policy of this class is "deferred explicit". - * - * @return bool */ - public function isChangeTrackingDeferredExplicit() + public function isChangeTrackingDeferredExplicit(): bool { return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_EXPLICIT; } /** * Whether the change tracking policy of this class is "deferred implicit". - * - * @return bool */ - public function isChangeTrackingDeferredImplicit() + public function isChangeTrackingDeferredImplicit(): bool { return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_IMPLICIT; } /** * Whether the change tracking policy of this class is "notify". - * - * @return bool */ - public function isChangeTrackingNotify() + public function isChangeTrackingNotify(): bool { return $this->changeTrackingPolicy === self::CHANGETRACKING_NOTIFY; } @@ -1289,28 +1195,14 @@ public function isIdentifier(string $fieldName): bool return in_array($fieldName, $this->identifier, true); } - /** - * Checks if the field is unique. - * - * @param string $fieldName The field name. - * - * @return bool TRUE if the field is unique, FALSE otherwise. - */ - public function isUniqueField($fieldName) + public function isUniqueField(string $fieldName): bool { $mapping = $this->getFieldMapping($fieldName); return $mapping !== false && isset($mapping['unique']) && $mapping['unique']; } - /** - * Checks if the field is not null. - * - * @param string $fieldName The field name. - * - * @return bool TRUE if the field is not null, FALSE otherwise. - */ - public function isNullable($fieldName) + public function isNullable(string $fieldName): bool { $mapping = $this->getFieldMapping($fieldName); @@ -1321,12 +1213,8 @@ public function isNullable($fieldName) * Gets a column name for a field name. * If the column name for the field cannot be found, the given field name * is returned. - * - * @param string $fieldName The field name. - * - * @return string The column name. */ - public function getColumnName($fieldName) + public function getColumnName(string $fieldName): string { return $this->columnNames[$fieldName] ?? $fieldName; } @@ -1335,14 +1223,12 @@ public function getColumnName($fieldName) * Gets the mapping of a (regular) field that holds some data but not a * reference to another object. * - * @param string $fieldName The field name. - * * @return mixed[] The field mapping. * @psalm-return FieldMapping * * @throws MappingException */ - public function getFieldMapping($fieldName) + public function getFieldMapping(string $fieldName): array { if (! isset($this->fieldMappings[$fieldName])) { throw MappingException::mappingNotFound($this->name, $fieldName); @@ -1364,7 +1250,7 @@ public function getFieldMapping($fieldName) * * @throws MappingException */ - public function getAssociationMapping($fieldName) + public function getAssociationMapping(string $fieldName): array { if (! isset($this->associationMappings[$fieldName])) { throw MappingException::mappingNotFound($this->name, $fieldName); @@ -1378,7 +1264,7 @@ public function getAssociationMapping($fieldName) * * @psalm-return array */ - public function getAssociationMappings() + public function getAssociationMappings(): array { return $this->associationMappings; } @@ -1387,11 +1273,9 @@ public function getAssociationMappings() * Gets the field name for a column name. * If no field name can be found the column name is returned. * - * @param string $columnName The column name. - * * @return string The column alias. */ - public function getFieldName($columnName) + public function getFieldName(string $columnName): string { return $this->fieldNames[$columnName] ?? $columnName; } @@ -1401,14 +1285,12 @@ public function getFieldName($columnName) * * @see ClassMetadataInfo::$sqlResultSetMappings * - * @param string $name The result set mapping name. - * * @return mixed[] * @psalm-return array{name: string, entities: array, columns: array} * * @throws MappingException */ - public function getSqlResultSetMapping($name) + public function getSqlResultSetMapping(string $name): array { if (! isset($this->sqlResultSetMappings[$name])) { throw MappingException::resultMappingNotFound($this->name, $name); @@ -1423,15 +1305,13 @@ public function getSqlResultSetMapping($name) * @return mixed[] * @psalm-return array */ - public function getSqlResultSetMappings() + public function getSqlResultSetMappings(): array { return $this->sqlResultSetMappings; } /** * Checks whether given property has type - * - * @param string $name Property name */ private function isTypedProperty(string $name): bool { @@ -2051,11 +1931,9 @@ public function getIdentifierFieldNames(): array * Gets the name of the single id field. Note that this only works on * entity classes that have a single-field pk. * - * @return string - * * @throws MappingException If the class doesn't have an identifier or it has a composite primary key. */ - public function getSingleIdentifierFieldName() + public function getSingleIdentifierFieldName(): string { if ($this->isIdentifierComposite) { throw MappingException::singleIdNotAllowedOnCompositePrimaryKey($this->name); @@ -2072,11 +1950,9 @@ public function getSingleIdentifierFieldName() * Gets the column name of the single id column. Note that this only works on * entity classes that have a single-field pk. * - * @return string - * * @throws MappingException If the class doesn't have an identifier or it has a composite primary key. */ - public function getSingleIdentifierColumnName() + public function getSingleIdentifierColumnName(): string { return $this->getColumnName($this->getSingleIdentifierFieldName()); } @@ -2087,10 +1963,8 @@ public function getSingleIdentifierColumnName() * Mainly used by the ClassMetadataFactory to assign inherited identifiers. * * @psalm-param list $identifier - * - * @return void */ - public function setIdentifier(array $identifier) + public function setIdentifier(array $identifier): void { $this->identifier = $identifier; $this->isIdentifierComposite = (count($this->identifier) > 1); @@ -2117,7 +1991,7 @@ public function hasField(string $fieldName): bool * @return mixed[] * @psalm-return list */ - public function getColumnNames(array|null $fieldNames = null) + public function getColumnNames(array|null $fieldNames = null): array { if ($fieldNames === null) { return array_keys($this->fieldNames); @@ -2131,7 +2005,7 @@ public function getColumnNames(array|null $fieldNames = null) * * @psalm-return list */ - public function getIdentifierColumnNames() + public function getIdentifierColumnNames(): array { $columnNames = []; @@ -2144,9 +2018,7 @@ public function getIdentifierColumnNames() // Association defined as Id field $joinColumns = $this->associationMappings[$idProperty]['joinColumns']; - $assocColumnNames = array_map(static function ($joinColumn) { - return $joinColumn['name']; - }, $joinColumns); + $assocColumnNames = array_map(static fn ($joinColumn) => $joinColumn['name'], $joinColumns); $columnNames = array_merge($columnNames, $assocColumnNames); } @@ -2157,28 +2029,22 @@ public function getIdentifierColumnNames() /** * Sets the type of Id generator to use for the mapped class. * - * @param int $generatorType * @psalm-param self::GENERATOR_TYPE_* $generatorType - * - * @return void */ - public function setIdGeneratorType($generatorType) + public function setIdGeneratorType(int $generatorType): void { $this->generatorType = $generatorType; } /** * Checks whether the mapped class uses an Id generator. - * - * @return bool TRUE if the mapped class uses an Id generator, FALSE otherwise. */ - public function usesIdGenerator() + public function usesIdGenerator(): bool { return $this->generatorType !== self::GENERATOR_TYPE_NONE; } - /** @return bool */ - public function isInheritanceTypeNone() + public function isInheritanceTypeNone(): bool { return $this->inheritanceType === self::INHERITANCE_TYPE_NONE; } @@ -2189,7 +2055,7 @@ public function isInheritanceTypeNone() * @return bool TRUE if the class participates in a JOINED inheritance mapping, * FALSE otherwise. */ - public function isInheritanceTypeJoined() + public function isInheritanceTypeJoined(): bool { return $this->inheritanceType === self::INHERITANCE_TYPE_JOINED; } @@ -2200,7 +2066,7 @@ public function isInheritanceTypeJoined() * @return bool TRUE if the class participates in a SINGLE_TABLE inheritance mapping, * FALSE otherwise. */ - public function isInheritanceTypeSingleTable() + public function isInheritanceTypeSingleTable(): bool { return $this->inheritanceType === self::INHERITANCE_TYPE_SINGLE_TABLE; } @@ -2211,17 +2077,15 @@ public function isInheritanceTypeSingleTable() * @return bool TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, * FALSE otherwise. */ - public function isInheritanceTypeTablePerClass() + public function isInheritanceTypeTablePerClass(): bool { return $this->inheritanceType === self::INHERITANCE_TYPE_TABLE_PER_CLASS; } /** * Checks whether the class uses an identity column for the Id generation. - * - * @return bool TRUE if the class uses the IDENTITY generator, FALSE otherwise. */ - public function isIdGeneratorIdentity() + public function isIdGeneratorIdentity(): bool { return $this->generatorType === self::GENERATOR_TYPE_IDENTITY; } @@ -2229,11 +2093,9 @@ public function isIdGeneratorIdentity() /** * Checks whether the class uses a sequence for id generation. * - * @return bool TRUE if the class uses the SEQUENCE generator, FALSE otherwise. - * * @psalm-assert-if-true !null $this->sequenceGeneratorDefinition */ - public function isIdGeneratorSequence() + public function isIdGeneratorSequence(): bool { return $this->generatorType === self::GENERATOR_TYPE_SEQUENCE; } @@ -2241,10 +2103,8 @@ public function isIdGeneratorSequence() /** * Checks whether the class has a natural identifier/pk (which means it does * not use any Id generator. - * - * @return bool */ - public function isIdentifierNatural() + public function isIdentifierNatural(): bool { return $this->generatorType === self::GENERATOR_TYPE_NONE; } @@ -2263,30 +2123,24 @@ public function getTypeOfField(string $fieldName): string|null /** * Gets the name of the primary table. - * - * @return string */ - public function getTableName() + public function getTableName(): string { return $this->table['name']; } /** * Gets primary table's schema name. - * - * @return string|null */ - public function getSchemaName() + public function getSchemaName(): string|null { return $this->table['schema'] ?? null; } /** * Gets the table name to use for temporary identifier tables of this class. - * - * @return string */ - public function getTemporaryIdTableName() + public function getTemporaryIdTableName(): string { // replace dots with underscores because PostgreSQL creates temporary tables in a special schema return str_replace('.', '_', $this->getTableName() . '_id_tmp'); @@ -2296,10 +2150,8 @@ public function getTemporaryIdTableName() * Sets the mapped subclasses of this class. * * @psalm-param list $subclasses The names of all mapped subclasses. - * - * @return void */ - public function setSubclasses(array $subclasses) + public function setSubclasses(array $subclasses): void { foreach ($subclasses as $subclass) { $this->subClasses[] = $this->fullyQualifiedClassName($subclass); @@ -2312,10 +2164,8 @@ public function setSubclasses(array $subclasses) * directParent -> directParentParent -> directParentParentParent ... -> root. * * @psalm-param list $classNames - * - * @return void */ - public function setParentClasses(array $classNames) + public function setParentClasses(array $classNames): void { $this->parentClasses = $classNames; @@ -2327,14 +2177,11 @@ public function setParentClasses(array $classNames) /** * Sets the inheritance type used by the class and its subclasses. * - * @param int $type * @psalm-param self::INHERITANCE_TYPE_* $type * - * @return void - * * @throws MappingException */ - public function setInheritanceType($type) + public function setInheritanceType(int $type): void { if (! $this->isInheritanceType($type)) { throw MappingException::invalidInheritanceType($this->name, $type); @@ -2346,14 +2193,11 @@ public function setInheritanceType($type) /** * Sets the association to override association mapping of property for an entity relationship. * - * @param string $fieldName * @psalm-param array $overrideMapping * - * @return void - * * @throws MappingException */ - public function setAssociationOverride($fieldName, array $overrideMapping) + public function setAssociationOverride(string $fieldName, array $overrideMapping): void { if (! isset($this->associationMappings[$fieldName])) { throw MappingException::invalidOverrideFieldName($this->name, $fieldName); @@ -2411,14 +2255,11 @@ public function setAssociationOverride($fieldName, array $overrideMapping) /** * Sets the override for a mapped field. * - * @param string $fieldName * @psalm-param array $overrideMapping * - * @return void - * * @throws MappingException */ - public function setAttributeOverride($fieldName, array $overrideMapping) + public function setAttributeOverride(string $fieldName, array $overrideMapping): void { if (! isset($this->fieldMappings[$fieldName])) { throw MappingException::invalidOverrideFieldName($this->name, $fieldName); @@ -2458,44 +2299,29 @@ public function setAttributeOverride($fieldName, array $overrideMapping) /** * Checks whether a mapped field is inherited from an entity superclass. - * - * @param string $fieldName - * - * @return bool TRUE if the field is inherited, FALSE otherwise. */ - public function isInheritedField($fieldName) + public function isInheritedField(string $fieldName): bool { return isset($this->fieldMappings[$fieldName]['inherited']); } /** * Checks if this entity is the root in any entity-inheritance-hierarchy. - * - * @return bool */ - public function isRootEntity() + public function isRootEntity(): bool { return $this->name === $this->rootEntityName; } /** * Checks whether a mapped association field is inherited from a superclass. - * - * @param string $fieldName - * - * @return bool TRUE if the field is inherited, FALSE otherwise. */ - public function isInheritedAssociation($fieldName) + public function isInheritedAssociation(string $fieldName): bool { return isset($this->associationMappings[$fieldName]['inherited']); } - /** - * @param string $fieldName - * - * @return bool - */ - public function isInheritedEmbeddedClass($fieldName) + public function isInheritedEmbeddedClass(string $fieldName): bool { return isset($this->embeddedClasses[$fieldName]['inherited']); } @@ -2504,12 +2330,8 @@ public function isInheritedEmbeddedClass($fieldName) * Sets the name of the primary table the class is mapped to. * * @deprecated Use {@link setPrimaryTable}. - * - * @param string $tableName The table name. - * - * @return void */ - public function setTableName($tableName) + public function setTableName(string $tableName): void { $this->table['name'] = $tableName; } @@ -2525,10 +2347,8 @@ public function setTableName($tableName) * If a key is omitted, the current value is kept. * * @psalm-param array $table The table description. - * - * @return void */ - public function setPrimaryTable(array $table) + public function setPrimaryTable(array $table): void { if (isset($table['name'])) { // Split schema and table name from a table name like "myschema.mytable" @@ -2567,8 +2387,6 @@ public function setPrimaryTable(array $table) /** * Checks whether the given type identifies an inheritance type. - * - * @return bool TRUE if the given type identifies an inheritance type, FALSE otherwise. */ private function isInheritanceType(int $type): bool { @@ -2583,11 +2401,9 @@ private function isInheritanceType(int $type): bool * * @psalm-param array $mapping The field mapping. * - * @return void - * * @throws MappingException */ - public function mapField(array $mapping) + public function mapField(array $mapping): void { $mapping = $this->validateAndCompleteFieldMapping($mapping); $this->assertFieldNotMapped($mapping['fieldName']); @@ -2606,11 +2422,9 @@ public function mapField(array $mapping) * * @psalm-param AssociationMapping $mapping * - * @return void - * * @throws MappingException */ - public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/) + public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/): void { if (isset($this->associationMappings[$mapping['fieldName']])) { throw MappingException::duplicateAssociationMapping($this->name, $mapping['fieldName']); @@ -2625,10 +2439,8 @@ public function addInheritedAssociationMapping(array $mapping/*, $owningClassNam * This is mainly used to add inherited field mappings to derived classes. * * @psalm-param array $fieldMapping - * - * @return void */ - public function addInheritedFieldMapping(array $fieldMapping) + public function addInheritedFieldMapping(array $fieldMapping): void { $this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping; $this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName']; @@ -2641,11 +2453,9 @@ public function addInheritedFieldMapping(array $fieldMapping) * * @psalm-param array $resultMapping * - * @return void - * * @throws MappingException */ - public function addSqlResultSetMapping(array $resultMapping) + public function addSqlResultSetMapping(array $resultMapping): void { if (! isset($resultMapping['name'])) { throw MappingException::nameIsMandatoryForSqlResultSetMapping($this->name); @@ -2698,10 +2508,8 @@ public function addSqlResultSetMapping(array $resultMapping) * Adds a one-to-one mapping. * * @param array $mapping The mapping. - * - * @return void */ - public function mapOneToOne(array $mapping) + public function mapOneToOne(array $mapping): void { $mapping['type'] = self::ONE_TO_ONE; @@ -2714,10 +2522,8 @@ public function mapOneToOne(array $mapping) * Adds a one-to-many mapping. * * @psalm-param array $mapping The mapping. - * - * @return void */ - public function mapOneToMany(array $mapping) + public function mapOneToMany(array $mapping): void { $mapping['type'] = self::ONE_TO_MANY; @@ -2730,10 +2536,8 @@ public function mapOneToMany(array $mapping) * Adds a many-to-one mapping. * * @psalm-param array $mapping The mapping. - * - * @return void */ - public function mapManyToOne(array $mapping) + public function mapManyToOne(array $mapping): void { $mapping['type'] = self::MANY_TO_ONE; @@ -2747,10 +2551,8 @@ public function mapManyToOne(array $mapping) * Adds a many-to-many mapping. * * @psalm-param array $mapping The mapping. - * - * @return void */ - public function mapManyToMany(array $mapping) + public function mapManyToMany(array $mapping): void { $mapping['type'] = self::MANY_TO_MANY; @@ -2764,11 +2566,9 @@ public function mapManyToMany(array $mapping) * * @psalm-param array $assocMapping * - * @return void - * * @throws MappingException */ - protected function _storeAssociationMapping(array $assocMapping) + protected function _storeAssociationMapping(array $assocMapping): void { $sourceFieldName = $assocMapping['fieldName']; @@ -2782,10 +2582,8 @@ protected function _storeAssociationMapping(array $assocMapping) * * @param string|null $repositoryClassName The class name of the custom mapper. * @psalm-param class-string|null $repositoryClassName - * - * @return void */ - public function setCustomRepositoryClass($repositoryClassName) + public function setCustomRepositoryClass(string|null $repositoryClassName): void { $this->customRepositoryClassName = $this->fullyQualifiedClassName($repositoryClassName); } @@ -2797,11 +2595,8 @@ public function setCustomRepositoryClass($repositoryClassName) * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker * * @param string $lifecycleEvent The lifecycle event. - * @param object $entity The Entity on which the event occurred. - * - * @return void */ - public function invokeLifecycleCallbacks($lifecycleEvent, $entity) + public function invokeLifecycleCallbacks(string $lifecycleEvent, object $entity): void { foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) { $entity->$callback(); @@ -2810,12 +2605,8 @@ public function invokeLifecycleCallbacks($lifecycleEvent, $entity) /** * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. - * - * @param string $lifecycleEvent - * - * @return bool */ - public function hasLifecycleCallbacks($lifecycleEvent) + public function hasLifecycleCallbacks(string $lifecycleEvent): bool { return isset($this->lifecycleCallbacks[$lifecycleEvent]); } @@ -2823,25 +2614,18 @@ public function hasLifecycleCallbacks($lifecycleEvent) /** * Gets the registered lifecycle callbacks for an event. * - * @param string $event - * * @return string[] * @psalm-return list */ - public function getLifecycleCallbacks($event) + public function getLifecycleCallbacks(string $event): array { return $this->lifecycleCallbacks[$event] ?? []; } /** * Adds a lifecycle callback for entities of this class. - * - * @param string $callback - * @param string $event - * - * @return void */ - public function addLifecycleCallback($callback, $event) + public function addLifecycleCallback(string $callback, string $event): void { if ($this->isEmbeddedClass) { Deprecation::trigger( @@ -2865,10 +2649,8 @@ public function addLifecycleCallback($callback, $event) * Any previously registered callbacks are overwritten. * * @psalm-param array> $callbacks - * - * @return void */ - public function setLifecycleCallbacks(array $callbacks) + public function setLifecycleCallbacks(array $callbacks): void { $this->lifecycleCallbacks = $callbacks; } @@ -2880,11 +2662,9 @@ public function setLifecycleCallbacks(array $callbacks) * @param string $class The listener class. * @param string $method The listener callback method. * - * @return void - * * @throws MappingException */ - public function addEntityListener($eventName, $class, $method) + public function addEntityListener(string $eventName, string $class, string $method): void { $class = $this->fullyQualifiedClassName($class); @@ -2916,11 +2696,9 @@ public function addEntityListener($eventName, $class, $method) * @param mixed[]|null $columnDef * @psalm-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null}|null $columnDef * - * @return void - * * @throws MappingException */ - public function setDiscriminatorColumn($columnDef) + public function setDiscriminatorColumn(array|null $columnDef): void { if ($columnDef !== null) { if (! isset($columnDef['name'])) { @@ -2962,10 +2740,8 @@ final public function getDiscriminatorColumn(): array * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. * * @param array $map - * - * @return void */ - public function setDiscriminatorMap(array $map) + public function setDiscriminatorMap(array $map): void { foreach ($map as $value => $className) { $this->addDiscriminatorMapClass($value, $className); @@ -2975,14 +2751,9 @@ public function setDiscriminatorMap(array $map) /** * Adds one entry of the discriminator map with a new class and corresponding name. * - * @param int|string $name - * @param string $className - * - * @return void - * * @throws MappingException */ - public function addDiscriminatorMapClass($name, $className) + public function addDiscriminatorMapClass(int|string $name, string $className): void { $className = $this->fullyQualifiedClassName($className); $className = ltrim($className, '\\'); @@ -3023,12 +2794,8 @@ public function isCollectionValuedAssociation(string $fieldName): bool /** * Is this an association that only has a single join column? - * - * @param string $fieldName - * - * @return bool */ - public function isAssociationWithSingleJoinColumn($fieldName) + public function isAssociationWithSingleJoinColumn(string $fieldName): bool { return isset($this->associationMappings[$fieldName]) && isset($this->associationMappings[$fieldName]['joinColumns'][0]) @@ -3038,13 +2805,9 @@ public function isAssociationWithSingleJoinColumn($fieldName) /** * Returns the single association join column (if any). * - * @param string $fieldName - * - * @return string - * * @throws MappingException */ - public function getSingleAssociationJoinColumnName($fieldName) + public function getSingleAssociationJoinColumnName(string $fieldName): string { if (! $this->isAssociationWithSingleJoinColumn($fieldName)) { throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); @@ -3056,13 +2819,9 @@ public function getSingleAssociationJoinColumnName($fieldName) /** * Returns the single association referenced join column name (if any). * - * @param string $fieldName - * - * @return string - * * @throws MappingException */ - public function getSingleAssociationReferencedJoinColumnName($fieldName) + public function getSingleAssociationReferencedJoinColumnName(string $fieldName): string { if (! $this->isAssociationWithSingleJoinColumn($fieldName)) { throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); @@ -3076,13 +2835,9 @@ public function getSingleAssociationReferencedJoinColumnName($fieldName) * * This method is used in foreign-key as primary-key contexts. * - * @param string $columnName - * - * @return string - * * @throws MappingException */ - public function getFieldForColumn($columnName) + public function getFieldForColumn(string $columnName): string { if (isset($this->fieldNames[$columnName])) { return $this->fieldNames[$columnName]; @@ -3102,12 +2857,8 @@ public function getFieldForColumn($columnName) /** * Sets the ID generator used to generate IDs for instances of this class. - * - * @param AbstractIdGenerator $generator - * - * @return void */ - public function setIdGenerator($generator) + public function setIdGenerator(AbstractIdGenerator $generator): void { $this->idGenerator = $generator; } @@ -3116,10 +2867,8 @@ public function setIdGenerator($generator) * Sets definition. * * @psalm-param array $definition - * - * @return void */ - public function setCustomGeneratorDefinition(array $definition) + public function setCustomGeneratorDefinition(array $definition): void { $this->customGeneratorDefinition = $definition; } @@ -3139,11 +2888,9 @@ public function setCustomGeneratorDefinition(array $definition) * * @psalm-param array{sequenceName?: string, allocationSize?: int|string, initialValue?: int|string, quoted?: mixed} $definition * - * @return void - * * @throws MappingException */ - public function setSequenceGeneratorDefinition(array $definition) + public function setSequenceGeneratorDefinition(array $definition): void { if (! isset($definition['sequenceName']) || trim($definition['sequenceName']) === '') { throw MappingException::missingSequenceName($this->name); @@ -3174,11 +2921,9 @@ public function setSequenceGeneratorDefinition(array $definition) * * @psalm-param array $mapping The version field mapping array. * - * @return void - * * @throws MappingException */ - public function setVersionMapping(array &$mapping) + public function setVersionMapping(array &$mapping): void { $this->isVersioned = true; $this->versionField = $mapping['fieldName']; @@ -3197,12 +2942,8 @@ public function setVersionMapping(array &$mapping) /** * Sets whether this class is to be versioned for optimistic locking. - * - * @param bool $bool - * - * @return void */ - public function setVersioned($bool) + public function setVersioned(bool $bool): void { $this->isVersioned = $bool; @@ -3214,22 +2955,16 @@ public function setVersioned($bool) /** * Sets the name of the field that is to be used for versioning if this class is * versioned for optimistic locking. - * - * @param string|null $versionField - * - * @return void */ - public function setVersionField($versionField) + public function setVersionField(string|null $versionField): void { $this->versionField = $versionField; } /** * Marks this class as read only, no change tracking is applied to it. - * - * @return void */ - public function markReadOnly() + public function markReadOnly(): void { $this->isReadOnly = true; } @@ -3280,12 +3015,10 @@ public function getAssociationMappedByTargetField(string $assocName): string } /** - * @param string|null $className - * * @return string|null null if the input value is null * @psalm-return class-string|null */ - public function fullyQualifiedClassName($className) + public function fullyQualifiedClassName(string|null $className): string|null { if (empty($className)) { return $className; @@ -3298,12 +3031,7 @@ public function fullyQualifiedClassName($className) return $className; } - /** - * @param string $name - * - * @return mixed - */ - public function getMetadataValue($name) + public function getMetadataValue(string $name): mixed { if (isset($this->$name)) { return $this->$name; @@ -3317,11 +3045,9 @@ public function getMetadataValue($name) * * @psalm-param array $mapping * - * @return void - * * @throws MappingException */ - public function mapEmbedded(array $mapping) + public function mapEmbedded(array $mapping): void { $this->assertFieldNotMapped($mapping['fieldName']); @@ -3342,12 +3068,8 @@ public function mapEmbedded(array $mapping) /** * Inline the embeddable class - * - * @param string $property - * - * @return void */ - public function inlineEmbeddable($property, ClassMetadataInfo $embeddable) + public function inlineEmbeddable(string $property, ClassMetadataInfo $embeddable): void { foreach ($embeddable->fieldMappings as $fieldMapping) { $fieldMapping['originalClass'] ??= $embeddable->name; @@ -3390,11 +3112,9 @@ private function assertFieldNotMapped(string $fieldName): void /** * Gets the sequence name based on class metadata. * - * @return string - * * @todo Sequence names should be computed in DBAL depending on the platform */ - public function getSequenceName(AbstractPlatform $platform) + public function getSequenceName(AbstractPlatform $platform): string { $sequencePrefix = $this->getSequencePrefix($platform); $columnName = $this->getSingleIdentifierColumnName(); @@ -3405,11 +3125,9 @@ public function getSequenceName(AbstractPlatform $platform) /** * Gets the sequence name prefix based on class metadata. * - * @return string - * * @todo Sequence names should be computed in DBAL depending on the platform */ - public function getSequencePrefix(AbstractPlatform $platform) + public function getSequencePrefix(AbstractPlatform $platform): string { $tableName = $this->getTableName(); $sequencePrefix = $tableName; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 699785cee0d..f1786f8aa37 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -312,9 +312,7 @@ - - ClassMetadata - ClassMetadata + ClassMetadata ClassMetadata @@ -324,10 +322,6 @@ $nonSuperclassParents new $definition['class']() - - ! $definition - $definition - $subClass->table[$indexType][$indexName] @@ -360,11 +354,13 @@ hasListeners loadMetadataForClass - - $parent->generatorType - $parent->generatorType + $parent->idGenerator $parent->idGenerator + + + $parent->generatorType + $parent->generatorType @@ -374,31 +370,22 @@ $this->columnNames $this->columnNames - - ! $this->table + ! class_exists($mapping['targetEntity']) - $this->table protected function _validateAndCompleteAssociationMapping(array $mapping) protected function _validateAndCompleteManyToManyMapping(array $mapping) protected function _validateAndCompleteOneToOneMapping(array $mapping) - - ReflectionProperty - ReflectionProperty + + getReflectionClass string $definition $this->subClasses - - $this->reflClass - - - getReflectionClass - $cache $className @@ -414,11 +401,9 @@ array{usage: int, region: string|null} class-string|null - + $this->associationMappings[$assocName]['mappedBy'] $this->reflClass - $this->reflFields[$name] - $this->reflFields[$this->identifier[0]] $entity @@ -452,10 +437,8 @@ $this->associationMappings[$fieldName]['joinColumns'] $this->associationMappings[$idProperty]['joinColumns'] - + $idGenerator - $namespace - $sequenceGeneratorDefinition $table @@ -472,13 +455,17 @@ $this->table $this->table - + $mapping !== false $mapping !== false - + array_values + + ! $this->table + $this->table + From f310e1f5ba777d9203091f76947a3172306145a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 6 Oct 2022 08:54:16 +0200 Subject: [PATCH 168/475] Address method rename See https://github.com/doctrine/dbal/pull/5724 --- lib/Doctrine/ORM/Tools/SchemaTool.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 9883f645d1e..7ed4ee84323 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -338,7 +338,8 @@ public function getSchemaFromMetadata(array $classes): Schema $uniqIndex = new Index($indexName, $this->getIndexColumns($class, $indexData), true, false, [], $indexData['options'] ?? []); foreach ($table->getIndexes() as $tableIndexName => $tableIndex) { - if ($tableIndex->isFullfilledBy($uniqIndex)) { + $method = method_exists($tableIndex, 'isFulfilledBy') ? 'isFulfilledBy' : 'isFullfilledBy'; + if ($tableIndex->$method($uniqIndex)) { $table->dropIndex($tableIndexName); break; } From cfefa1e9b7642f31831ce4ae839963e9b4b7ed1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 7 Oct 2022 21:28:57 +0200 Subject: [PATCH 169/475] Do not instantiate interface In DBAL 4.0, Doctrine\DBAL\Exception becomes an interface. --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 38ac0ed2d58..ea14100ccbf 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -605,7 +605,7 @@ public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails( $this->_emMock->setUnitOfWork($this->_unitOfWork); $this->connection->method('commit') - ->willThrowException(new Exception()); + ->willThrowException($this->createStub(Exception::class)); // Setup fake persister and id generator $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(ForumUser::class)); From 7c17bba801b911b2a41b8b91b899afe6375fc160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 9 Oct 2022 22:24:18 +0200 Subject: [PATCH 170/475] Remove SQL resultset mapping (#10114) --- docs/en/reference/annotations-reference.rst | 136 ----------- doctrine-mapping.xsd | 19 -- .../ORM/Mapping/ClassMetadataFactory.php | 32 --- .../ORM/Mapping/ClassMetadataInfo.php | 111 --------- lib/Doctrine/ORM/Mapping/ColumnResult.php | 22 -- .../ORM/Mapping/Driver/AnnotationDriver.php | 40 --- .../Mapping/Driver/DoctrineAnnotations.php | 5 - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 42 ---- lib/Doctrine/ORM/Mapping/EntityResult.php | 38 --- lib/Doctrine/ORM/Mapping/FieldResult.php | 28 --- lib/Doctrine/ORM/Mapping/MappingException.php | 10 - .../ORM/Mapping/SqlResultSetMapping.php | 36 --- .../ORM/Mapping/SqlResultSetMappings.php | 22 -- .../Command/MappingDescribeCommand.php | 1 - phpcs.xml.dist | 5 - psalm-baseline.xml | 22 +- .../Doctrine/Tests/Models/CMS/CmsAddress.php | 84 ------- tests/Doctrine/Tests/Models/CMS/CmsUser.php | 229 ------------------ .../Tests/Models/Company/CompanyContract.php | 32 --- .../Models/Company/CompanyFlexContract.php | 38 +-- .../Tests/Models/Company/CompanyPerson.php | 42 ---- .../Tests/ORM/Mapping/AttributeDriverTest.php | 5 - .../Tests/ORM/Mapping/ClassMetadataTest.php | 128 ---------- .../ORM/Mapping/MappingDriverTestCase.php | 67 ----- ...ctrine.Tests.Models.CMS.CmsAddress.dcm.xml | 20 +- .../Doctrine.Tests.Models.CMS.CmsUser.dcm.xml | 50 +--- ...Tests.Models.Company.CompanyPerson.dcm.xml | 15 +- 27 files changed, 10 insertions(+), 1269 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/ColumnResult.php delete mode 100644 lib/Doctrine/ORM/Mapping/EntityResult.php delete mode 100644 lib/Doctrine/ORM/Mapping/FieldResult.php delete mode 100644 lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php delete mode 100644 lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index a67e24c8ebf..6bd5f0e5076 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -47,7 +47,6 @@ Index ----- - :ref:`@Column ` -- :ref:`@ColumnResult ` - :ref:`@Cache ` - :ref:`@ChangeTrackingPolicy ` - :ref:`@CustomIdGenerator ` @@ -56,8 +55,6 @@ Index - :ref:`@Embeddable ` - :ref:`@Embedded ` - :ref:`@Entity ` -- :ref:`@EntityResult ` -- :ref:`@FieldResult ` - :ref:`@GeneratedValue ` - :ref:`@HasLifecycleCallbacks ` - :ref:`@Index ` @@ -80,7 +77,6 @@ Index - :ref:`@PreRemove ` - :ref:`@PreUpdate ` - :ref:`@SequenceGenerator ` -- :ref:`@SqlResultSetMapping ` - :ref:`@Table ` - :ref:`@UniqueConstraint ` - :ref:`@Version ` @@ -216,17 +212,6 @@ Examples: */ protected $fullname; -.. _annref_column_result: - -@ColumnResult -~~~~~~~~~~~~~~ -References name of a column in the SELECT clause of a SQL query. -Scalar result types can be included in the query result by specifying this annotation in the metadata. - -Required attributes: - -- **name**: The name of a column in the SELECT clause of a SQL query - .. _annref_cache: @Cache @@ -436,39 +421,6 @@ Example: // ... } -.. _annref_entity_result: - -@EntityResult -~~~~~~~~~~~~~~ -References an entity in the SELECT clause of a SQL query. -If this annotation is used, the SQL statement should select all of the columns that are mapped to the entity object. -This should include foreign key columns to related entities. -The results obtained when insufficient data is available are undefined. - -Required attributes: - -- **entityClass**: The class of the result. - -Optional attributes: - -- **fields**: Array of @FieldResult, Maps the columns specified in the SELECT list of the query to the properties or fields of the entity class. -- **discriminatorColumn**: Specifies the column name of the column in the SELECT list that is used to determine the type of the entity instance. - -.. _annref_field_result: - -@FieldResult -~~~~~~~~~~~~~ -Is used to map the columns specified in the SELECT list of the query to the properties or fields of the entity class. - -Required attributes: - -- **name**: Name of the persistent field or property of the class. - - -Optional attributes: - -- **column**: Name of the column in the SELECT clause. - .. _annref_generatedvalue: @GeneratedValue @@ -1088,94 +1040,6 @@ Example: */ protected $id = null; -.. _annref_sql_resultset_mapping: - -@SqlResultSetMapping -~~~~~~~~~~~~~~~~~~~~ -The SqlResultSetMapping annotation is used to specify the mapping of the result of a native SQL query. -The SqlResultSetMapping annotation can be applied to an entity or mapped superclass. - -Required attributes: - -- **name**: The name given to the result set mapping, and used to refer to it in the methods of the Query API. - - -Optional attributes: - -- **entities**: Array of @EntityResult, Specifies the result set mapping to entities. -- **columns**: Array of @ColumnResult, Specifies the result set mapping to scalar values. - -Example: - -.. code-block:: php - - - - - - - - - - - - - - - - - - - - @@ -146,7 +128,6 @@ - diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 76791965ccf..2fcfabfc8ab 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -184,10 +184,6 @@ protected function doLoadMetadata( $class->containsEnumIdentifier = true; } - if (! empty($parent->sqlResultSetMappings)) { - $this->addInheritedSqlResultSetMappings($class, $parent); - } - if (! empty($parent->entityListeners) && empty($class->entityListeners)) { $class->entityListeners = $parent->entityListeners; } @@ -443,34 +439,6 @@ private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $par } } - /** - * Adds inherited sql result set mappings to the subclass mapping. - */ - private function addInheritedSqlResultSetMappings(ClassMetadata $subClass, ClassMetadata $parentClass): void - { - foreach ($parentClass->sqlResultSetMappings as $name => $mapping) { - if (! isset($subClass->sqlResultSetMappings[$name])) { - $entities = []; - foreach ($mapping['entities'] as $entity) { - $entities[] = [ - 'fields' => $entity['fields'], - 'isSelfClass' => $entity['isSelfClass'], - 'discriminatorColumn' => $entity['discriminatorColumn'], - 'entityClass' => $entity['isSelfClass'] ? $subClass->name : $entity['entityClass'], - ]; - } - - $subClass->addSqlResultSetMapping( - [ - 'name' => $mapping['name'], - 'columns' => $mapping['columns'], - 'entities' => $entities, - ], - ); - } - } - } - /** * Completes the ID generator mapping. If "auto" is specified we choose the generator * most appropriate for the targeted database platform. diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index cd769dbd658..247c680f61a 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -372,26 +372,6 @@ class ClassMetadataInfo implements ClassMetadata, Stringable */ public array $embeddedClasses = []; - /** - * READ-ONLY: The mappings of the results of native SQL queries. - * - * A native result mapping definition has the following structure: - *
-     * array(
-     *     'name'               => ,
-     *     'entities'           => array(),
-     *     'columns'            => array()
-     * )
-     * 
- * - * @psalm-var array - */ - public array $sqlResultSetMappings = []; - /** * READ-ONLY: The field names of all fields that are part of the identifier/primary key * of the mapped entity class. @@ -917,10 +897,6 @@ public function __sleep() $serialized[] = 'entityListeners'; } - if ($this->sqlResultSetMappings) { - $serialized[] = 'sqlResultSetMappings'; - } - if ($this->isReadOnly) { $serialized[] = 'isReadOnly'; } @@ -1280,36 +1256,6 @@ public function getFieldName(string $columnName): string return $this->fieldNames[$columnName] ?? $columnName; } - /** - * Gets the result set mapping. - * - * @see ClassMetadataInfo::$sqlResultSetMappings - * - * @return mixed[] - * @psalm-return array{name: string, entities: array, columns: array} - * - * @throws MappingException - */ - public function getSqlResultSetMapping(string $name): array - { - if (! isset($this->sqlResultSetMappings[$name])) { - throw MappingException::resultMappingNotFound($this->name, $name); - } - - return $this->sqlResultSetMappings[$name]; - } - - /** - * Gets all sql result set mappings of the class. - * - * @return mixed[] - * @psalm-return array - */ - public function getSqlResultSetMappings(): array - { - return $this->sqlResultSetMappings; - } - /** * Checks whether given property has type */ @@ -2447,63 +2393,6 @@ public function addInheritedFieldMapping(array $fieldMapping): void $this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName']; } - /** - * INTERNAL: - * Adds a sql result set mapping to this class. - * - * @psalm-param array $resultMapping - * - * @throws MappingException - */ - public function addSqlResultSetMapping(array $resultMapping): void - { - if (! isset($resultMapping['name'])) { - throw MappingException::nameIsMandatoryForSqlResultSetMapping($this->name); - } - - if (isset($this->sqlResultSetMappings[$resultMapping['name']])) { - throw MappingException::duplicateResultSetMapping($this->name, $resultMapping['name']); - } - - if (isset($resultMapping['entities'])) { - foreach ($resultMapping['entities'] as $key => $entityResult) { - if (! isset($entityResult['entityClass'])) { - throw MappingException::missingResultSetMappingEntity($this->name, $resultMapping['name']); - } - - $entityResult['isSelfClass'] = false; - if ($entityResult['entityClass'] === '__CLASS__') { - $entityResult['isSelfClass'] = true; - $entityResult['entityClass'] = $this->name; - } - - $entityResult['entityClass'] = $this->fullyQualifiedClassName($entityResult['entityClass']); - - $resultMapping['entities'][$key]['entityClass'] = ltrim($entityResult['entityClass'], '\\'); - $resultMapping['entities'][$key]['isSelfClass'] = $entityResult['isSelfClass']; - - if (isset($entityResult['fields'])) { - foreach ($entityResult['fields'] as $k => $field) { - if (! isset($field['name'])) { - throw MappingException::missingResultSetMappingFieldName($this->name, $resultMapping['name']); - } - - if (! isset($field['column'])) { - $fieldName = $field['name']; - if (str_contains($fieldName, '.')) { - [, $fieldName] = explode('.', $fieldName); - } - - $resultMapping['entities'][$key]['fields'][$k]['column'] = $fieldName; - } - } - } - } - } - - $this->sqlResultSetMappings[$resultMapping['name']] = $resultMapping; - } - /** * Adds a one-to-one mapping. * diff --git a/lib/Doctrine/ORM/Mapping/ColumnResult.php b/lib/Doctrine/ORM/Mapping/ColumnResult.php deleted file mode 100644 index 86bd0471cb3..00000000000 --- a/lib/Doctrine/ORM/Mapping/ColumnResult.php +++ /dev/null @@ -1,22 +0,0 @@ -enableCache($cacheMap); } - // Evaluate SqlResultSetMappings annotation - if (isset($classAnnotations[Mapping\SqlResultSetMappings::class])) { - $sqlResultSetMappingsAnnot = $classAnnotations[Mapping\SqlResultSetMappings::class]; - - foreach ($sqlResultSetMappingsAnnot->value as $resultSetMapping) { - $entities = []; - $columns = []; - foreach ($resultSetMapping->entities as $entityResultAnnot) { - $entityResult = [ - 'fields' => [], - 'entityClass' => $entityResultAnnot->entityClass, - 'discriminatorColumn' => $entityResultAnnot->discriminatorColumn, - ]; - - foreach ($entityResultAnnot->fields as $fieldResultAnnot) { - $entityResult['fields'][] = [ - 'name' => $fieldResultAnnot->name, - 'column' => $fieldResultAnnot->column, - ]; - } - - $entities[] = $entityResult; - } - - foreach ($resultSetMapping->columns as $columnResultAnnot) { - $columns[] = [ - 'name' => $columnResultAnnot->name, - ]; - } - - $metadata->addSqlResultSetMapping( - [ - 'name' => $resultSetMapping->name, - 'entities' => $entities, - 'columns' => $columns, - ], - ); - } - } - // Evaluate InheritanceType annotation if (isset($classAnnotations[Mapping\InheritanceType::class])) { $inheritanceTypeAnnot = $classAnnotations[Mapping\InheritanceType::class]; diff --git a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php index f334b3883ce..2e19dd354a2 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php @@ -37,11 +37,6 @@ require_once __DIR__ . '/../PostRemove.php'; require_once __DIR__ . '/../PostLoad.php'; require_once __DIR__ . '/../PreFlush.php'; -require_once __DIR__ . '/../FieldResult.php'; -require_once __DIR__ . '/../ColumnResult.php'; -require_once __DIR__ . '/../EntityResult.php'; -require_once __DIR__ . '/../SqlResultSetMapping.php'; -require_once __DIR__ . '/../SqlResultSetMappings.php'; require_once __DIR__ . '/../AssociationOverride.php'; require_once __DIR__ . '/../AssociationOverrides.php'; require_once __DIR__ . '/../AttributeOverride.php'; diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index e2e416b1162..644a94e6f4f 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -128,48 +128,6 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad $metadata->enableCache($this->cacheToArray($xmlRoot->cache)); } - // Evaluate sql result set mapping - if (isset($xmlRoot->{'sql-result-set-mappings'})) { - foreach ($xmlRoot->{'sql-result-set-mappings'}->{'sql-result-set-mapping'} as $rsmElement) { - $entities = []; - $columns = []; - foreach ($rsmElement as $entityElement) { - // - if (isset($entityElement['entity-class'])) { - $entityResult = [ - 'fields' => [], - 'entityClass' => (string) $entityElement['entity-class'], - 'discriminatorColumn' => isset($entityElement['discriminator-column']) ? (string) $entityElement['discriminator-column'] : null, - ]; - - foreach ($entityElement as $fieldElement) { - $entityResult['fields'][] = [ - 'name' => isset($fieldElement['name']) ? (string) $fieldElement['name'] : null, - 'column' => isset($fieldElement['column']) ? (string) $fieldElement['column'] : null, - ]; - } - - $entities[] = $entityResult; - } - - // - if (isset($entityElement['name'])) { - $columns[] = [ - 'name' => (string) $entityElement['name'], - ]; - } - } - - $metadata->addSqlResultSetMapping( - [ - 'name' => (string) $rsmElement['name'], - 'entities' => $entities, - 'columns' => $columns, - ], - ); - } - } - if (isset($xmlRoot['inheritance-type'])) { $inheritanceType = (string) $xmlRoot['inheritance-type']; $metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType)); diff --git a/lib/Doctrine/ORM/Mapping/EntityResult.php b/lib/Doctrine/ORM/Mapping/EntityResult.php deleted file mode 100644 index 3db8471fe12..00000000000 --- a/lib/Doctrine/ORM/Mapping/EntityResult.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ - public $fields = []; - - /** - * Specifies the column name of the column in the SELECT list that is used to determine the type of the entity instance. - * - * @var string - */ - public $discriminatorColumn; -} diff --git a/lib/Doctrine/ORM/Mapping/FieldResult.php b/lib/Doctrine/ORM/Mapping/FieldResult.php deleted file mode 100644 index 12588f4904a..00000000000 --- a/lib/Doctrine/ORM/Mapping/FieldResult.php +++ /dev/null @@ -1,28 +0,0 @@ - - */ - public $entities = []; - - /** - * Specifies the result set mapping to scalar values. - * - * @var array<\Doctrine\ORM\Mapping\ColumnResult> - */ - public $columns = []; -} diff --git a/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php b/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php deleted file mode 100644 index 13e7a16365e..00000000000 --- a/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - public $value = []; -} diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index dd542531c12..ee1e851b972 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -96,7 +96,6 @@ private function displayEntity( $this->formatField('Parent classes', $metadata->parentClasses), $this->formatField('Sub classes', $metadata->subClasses), $this->formatField('Embedded classes', $metadata->subClasses), - $this->formatField('SQL result set mappings', $metadata->sqlResultSetMappings), $this->formatField('Identifier', $metadata->identifier), $this->formatField('Inheritance type', $metadata->inheritanceType), $this->formatField('Discriminator column', $metadata->discriminatorColumn), diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 5ce9881308e..b8b73a1c739 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -85,7 +85,6 @@ lib/Doctrine/ORM/Mapping/Cache.php lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php lib/Doctrine/ORM/Mapping/Column.php - lib/Doctrine/ORM/Mapping/ColumnResult.php lib/Doctrine/ORM/Mapping/CustomIdGenerator.php lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php lib/Doctrine/ORM/Mapping/DiscriminatorMap.php @@ -93,8 +92,6 @@ lib/Doctrine/ORM/Mapping/Embedded.php lib/Doctrine/ORM/Mapping/Entity.php lib/Doctrine/ORM/Mapping/EntityListeners.php - lib/Doctrine/ORM/Mapping/EntityResult.php - lib/Doctrine/ORM/Mapping/FieldResult.php lib/Doctrine/ORM/Mapping/GeneratedValue.php lib/Doctrine/ORM/Mapping/HasLifecycleCallbacks.php lib/Doctrine/ORM/Mapping/Id.php @@ -118,8 +115,6 @@ lib/Doctrine/ORM/Mapping/PreRemove.php lib/Doctrine/ORM/Mapping/PreUpdate.php lib/Doctrine/ORM/Mapping/SequenceGenerator.php - lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php - lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php lib/Doctrine/ORM/Mapping/Table.php lib/Doctrine/ORM/Mapping/UniqueConstraint.php lib/Doctrine/ORM/Mapping/Version.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bfee897f0e9..a1ac510fb87 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -441,13 +441,12 @@ $idGenerator $table - + $this->associationMappings $this->associationMappings $this->entityListeners $this->fieldMappings $this->fullyQualifiedClassName($repositoryClassName) - $this->sqlResultSetMappings $this->table $this->table $this->table @@ -467,11 +466,6 @@ $this->table
- - - $name - - new $className() @@ -619,7 +613,7 @@ $indexXml->options $uniqueXml->options - + isset($xmlRoot->cache) isset($xmlRoot->embedded) isset($xmlRoot->field) @@ -635,16 +629,9 @@ isset($xmlRoot->{'many-to-one'}) isset($xmlRoot->{'one-to-many'}) isset($xmlRoot->{'one-to-one'}) - isset($xmlRoot->{'sql-result-set-mappings'}) isset($xmlRoot->{'unique-constraints'}) - - - $discriminatorColumn - $entityClass - - $column @@ -701,11 +688,6 @@ $sequenceName - - - $name - - strrpos($className, '\\') diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index c66744501a5..081f0340af9 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -8,17 +8,12 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\ColumnResult; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\EntityListeners; -use Doctrine\ORM\Mapping\EntityResult; -use Doctrine\ORM\Mapping\FieldResult; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; -use Doctrine\ORM\Mapping\SqlResultSetMapping; -use Doctrine\ORM\Mapping\SqlResultSetMappings; use Doctrine\ORM\Mapping\Table; /** @@ -26,37 +21,6 @@ * * @Entity * @Table(name="cms_addresses") - * @SqlResultSetMappings({ - * @SqlResultSetMapping( - * name = "mapping-find-all", - * entities= { - * @EntityResult( - * entityClass = "CmsAddress", - * fields = { - * @FieldResult(name = "id", column="id"), - * @FieldResult(name = "city", column="city"), - * @FieldResult(name = "country", column="country") - * } - * ) - * } - * ), - * @SqlResultSetMapping( - * name = "mapping-without-fields", - * entities= { - * @EntityResult( - * entityClass = "__CLASS__" - * ) - * } - * ), - * @SqlResultSetMapping( - * name = "mapping-count", - * columns = { - * @ColumnResult( - * name = "count" - * ) - * } - * ) - * }) * @EntityListeners({"CmsAddressListener"}) */ #[ORM\Entity] @@ -174,54 +138,6 @@ public static function loadMetadata(ClassMetadata $metadata): void ], ); - $metadata->addSqlResultSetMapping( - [ - 'name' => 'mapping-find-all', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'city', - 'column' => 'city', - ], - [ - 'name' => 'country', - 'column' => 'country', - ], - ], - 'entityClass' => self::class, - ], - ], - ], - ); - - $metadata->addSqlResultSetMapping( - [ - 'name' => 'mapping-without-fields', - 'columns' => [], - 'entities' => [ - [ - 'entityClass' => self::class, - 'fields' => [], - ], - ], - ], - ); - - $metadata->addSqlResultSetMapping( - [ - 'name' => 'mapping-count', - 'columns' => [ - ['name' => 'count'], - ], - ], - ); - $metadata->addEntityListener(Events::postPersist, 'CmsAddressListener', 'postPersist'); $metadata->addEntityListener(Events::prePersist, 'CmsAddressListener', 'prePersist'); diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Doctrine/Tests/Models/CMS/CmsUser.php index f6eade91bcc..d7c63046c57 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -8,10 +8,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\ColumnResult; use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\EntityResult; -use Doctrine\ORM\Mapping\FieldResult; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; @@ -19,86 +16,11 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; -use Doctrine\ORM\Mapping\SqlResultSetMapping; -use Doctrine\ORM\Mapping\SqlResultSetMappings; use Doctrine\ORM\Mapping\Table; /** * @Entity * @Table(name="cms_users") - * @SqlResultSetMappings({ - * @SqlResultSetMapping( - * name = "mappingJoinedAddress", - * entities= { - * @EntityResult( - * entityClass = "__CLASS__", - * fields = { - * @FieldResult(name = "id"), - * @FieldResult(name = "name"), - * @FieldResult(name = "status"), - * @FieldResult(name = "address.zip"), - * @FieldResult(name = "address.city"), - * @FieldResult(name = "address.country"), - * @FieldResult(name = "address.id", column = "a_id"), - * } - * ) - * } - * ), - * @SqlResultSetMapping( - * name = "mappingJoinedPhonenumber", - * entities= { - * @EntityResult( - * entityClass = "CmsUser", - * fields = { - * @FieldResult("id"), - * @FieldResult("name"), - * @FieldResult("status"), - * @FieldResult("phonenumbers.phonenumber" , column = "number"), - * } - * ) - * } - * ), - * @SqlResultSetMapping( - * name = "mappingUserPhonenumberCount", - * entities= { - * @EntityResult( - * entityClass = "CmsUser", - * fields = { - * @FieldResult(name = "id"), - * @FieldResult(name = "name"), - * @FieldResult(name = "status"), - * } - * ) - * }, - * columns = { - * @ColumnResult("numphones") - * } - * ), - * @SqlResultSetMapping( - * name = "mappingMultipleJoinsEntityResults", - * entities= { - * @EntityResult( - * entityClass = "__CLASS__", - * fields = { - * @FieldResult(name = "id", column="u_id"), - * @FieldResult(name = "name", column="u_name"), - * @FieldResult(name = "status", column="u_status"), - * } - * ), - * @EntityResult( - * entityClass = "CmsAddress", - * fields = { - * @FieldResult(name = "id", column="a_id"), - * @FieldResult(name = "zip", column="a_zip"), - * @FieldResult(name = "country", column="a_country"), - * } - * ) - * }, - * columns = { - * @ColumnResult("numphones") - * } - * ) - * }) */ class CmsUser { @@ -298,156 +220,5 @@ public static function loadMetadata(ClassMetadata $metadata): void $metadata->setPrimaryTable( ['name' => 'cms_users'], ); - - $metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingJoinedAddress', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - [ - 'name' => 'status', - 'column' => 'status', - ], - [ - 'name' => 'address.zip', - 'column' => 'zip', - ], - [ - 'name' => 'address.city', - 'column' => 'city', - ], - [ - 'name' => 'address.country', - 'column' => 'country', - ], - [ - 'name' => 'address.id', - 'column' => 'a_id', - ], - ], - 'entityClass' => self::class, - 'discriminatorColumn' => null, - ], - ], - ], - ); - - $metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingJoinedPhonenumber', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - [ - 'name' => 'status', - 'column' => 'status', - ], - [ - 'name' => 'phonenumbers.phonenumber', - 'column' => 'number', - ], - ], - 'entityClass' => self::class, - 'discriminatorColumn' => null, - ], - ], - ], - ); - - $metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingUserPhonenumberCount', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - [ - 'name' => 'status', - 'column' => 'status', - ], - ], - 'entityClass' => self::class, - 'discriminatorColumn' => null, - ], - ], - 'columns' => [ - ['name' => 'numphones'], - ], - ], - ); - - $metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingMultipleJoinsEntityResults', - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'u_id', - ], - [ - 'name' => 'name', - 'column' => 'u_name', - ], - [ - 'name' => 'status', - 'column' => 'u_status', - ], - ], - 'entityClass' => self::class, - 'discriminatorColumn' => null, - ], - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'a_id', - ], - [ - 'name' => 'zip', - 'column' => 'a_zip', - ], - [ - 'name' => 'country', - 'column' => 'a_country', - ], - ], - 'entityClass' => CmsAddress::class, - 'discriminatorColumn' => null, - ], - ], - 'columns' => [ - ['name' => 'numphones'], - ], - ], - ); } } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index c210e30ee2b..b0dfb64d379 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -14,8 +14,6 @@ use Doctrine\ORM\Mapping\DiscriminatorMap; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\EntityListeners; -use Doctrine\ORM\Mapping\EntityResult; -use Doctrine\ORM\Mapping\FieldResult; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; @@ -23,8 +21,6 @@ use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; -use Doctrine\ORM\Mapping\SqlResultSetMapping; -use Doctrine\ORM\Mapping\SqlResultSetMappings; use Doctrine\ORM\Mapping\Table; /** @@ -38,34 +34,6 @@ * "flexible" = "CompanyFlexContract", * "flexultra" = "CompanyFlexUltraContract" * }) - * @SqlResultSetMappings({ - * @SqlResultSetMapping( - * name = "mapping-all-contracts", - * entities= { - * @EntityResult( - * entityClass = "__CLASS__", - * discriminatorColumn = "discr", - * fields = { - * @FieldResult("id"), - * @FieldResult("completed"), - * } - * ) - * } - * ), - * @SqlResultSetMapping( - * name = "mapping-all", - * entities= { - * @EntityResult( - * entityClass = "__CLASS__", - * discriminatorColumn = "discr", - * fields = { - * @FieldResult("id"), - * @FieldResult("completed"), - * } - * ) - * } - * ), - * }) */ #[ORM\Entity, ORM\Table(name: 'company_contracts')] #[ORM\InheritanceType('SINGLE_TABLE')] diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index 605451ba83e..fb9679446dd 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -9,47 +9,13 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\EntityResult; -use Doctrine\ORM\Mapping\FieldResult; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; -use Doctrine\ORM\Mapping\SqlResultSetMapping; -use Doctrine\ORM\Mapping\SqlResultSetMappings; - -/** - * @Entity - * @SqlResultSetMappings({ - * @SqlResultSetMapping( - * name = "mapping-all-flex", - * entities= { - * @EntityResult( - * entityClass = "__CLASS__", - * discriminatorColumn = "discr", - * fields = { - * @FieldResult("id"), - * @FieldResult("hoursWorked"), - * } - * ) - * } - * ), - * @SqlResultSetMapping( - * name = "mapping-all", - * entities= { - * @EntityResult( - * entityClass = "CompanyFlexContract", - * discriminatorColumn = "discr", - * fields = { - * @FieldResult("id"), - * @FieldResult("hoursWorked"), - * } - * ) - * } - * ), - * }) - */ + +/** @Entity */ #[ORM\Entity] class CompanyFlexContract extends CompanyContract { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php index 74277c48fa7..f35b066bd14 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php @@ -11,8 +11,6 @@ use Doctrine\ORM\Mapping\DiscriminatorColumn; use Doctrine\ORM\Mapping\DiscriminatorMap; use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\EntityResult; -use Doctrine\ORM\Mapping\FieldResult; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; @@ -20,8 +18,6 @@ use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\OneToOne; -use Doctrine\ORM\Mapping\SqlResultSetMapping; -use Doctrine\ORM\Mapping\SqlResultSetMappings; use Doctrine\ORM\Mapping\Table; /** @@ -36,21 +32,6 @@ * "manager" = "CompanyManager", * "employee" = "CompanyEmployee" * }) - * @SqlResultSetMappings({ - * @SqlResultSetMapping( - * name = "mappingFetchAll", - * entities= { - * @EntityResult( - * entityClass = "__CLASS__", - * discriminatorColumn = "discriminator", - * fields = { - * @FieldResult("id"), - * @FieldResult("name"), - * } - * ) - * } - * ) - * }) */ class CompanyPerson { @@ -137,28 +118,5 @@ public static function loadMetadata(ClassMetadata $metadata): void $metadata->setPrimaryTable( ['name' => 'company_person'], ); - - $metadata->addSqlResultSetMapping( - [ - 'name' => 'mappingFetchAll', - 'columns' => [], - 'entities' => [ - [ - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - ], - 'entityClass' => self::class, - 'discriminatorColumn' => 'discriminator', - ], - ], - ], - ); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 65770a320bb..9360c5006cc 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -20,11 +20,6 @@ protected function loadDriver(): MappingDriver return new AttributeDriver($paths); } - public function testSqlResultSetMapping(): void - { - self::markTestSkipped('AttributeDriver does not support named sql resultset mapping.'); - } - public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): void { $factory = $this->createClassMetadataFactory(); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index bdd842fe4d8..9e7545fca1e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -607,84 +607,6 @@ public function testEmptyFieldNameThrowsException(): void $cm->mapField(['fieldName' => '']); } - /** @group DDC-1663 */ - public function testRetrievalOfResultSetMappings(): void - { - $cm = new ClassMetadata(CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - self::assertCount(0, $cm->getSqlResultSetMappings()); - - $cm->addSqlResultSetMapping( - [ - 'name' => 'find-all', - 'entities' => [ - [ - 'entityClass' => CmsUser::class, - ], - ], - ], - ); - - self::assertCount(1, $cm->getSqlResultSetMappings()); - } - - /** @group DDC-1663 */ - public function testRetrieveOfSqlResultSetMapping(): void - { - $cm = new ClassMetadata(CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addSqlResultSetMapping( - [ - 'name' => 'find-all', - 'entities' => [ - [ - 'entityClass' => '__CLASS__', - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'name', - 'column' => 'name', - ], - ], - ], - [ - 'entityClass' => CmsEmail::class, - 'fields' => [ - [ - 'name' => 'id', - 'column' => 'id', - ], - [ - 'name' => 'email', - 'column' => 'email', - ], - ], - ], - ], - 'columns' => [ - ['name' => 'scalarColumn'], - ], - ], - ); - - $mapping = $cm->getSqlResultSetMapping('find-all'); - - self::assertEquals(CmsUser::class, $mapping['entities'][0]['entityClass']); - self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - - self::assertEquals(CmsEmail::class, $mapping['entities'][1]['entityClass']); - self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][1]['fields'][0]); - self::assertEquals(['name' => 'email', 'column' => 'email'], $mapping['entities'][1]['fields'][1]); - - self::assertEquals('scalarColumn', $mapping['columns'][0]['name']); - } - /** @group DDC-2451 */ public function testSerializeEntityListeners(): void { @@ -700,37 +622,6 @@ public function testSerializeEntityListeners(): void self::assertEquals($metadata->entityListeners, $unserialize->entityListeners); } - /** @group DDC-1663 */ - public function testNamingCollisionSqlResultSetMappingShouldThrowException(): void - { - $this->expectException(MappingException::class); - $this->expectExceptionMessage('Result set mapping named "find-all" in "Doctrine\Tests\Models\CMS\CmsUser" was already declared, but it must be declared only once'); - $cm = new ClassMetadata(CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - - $cm->addSqlResultSetMapping( - [ - 'name' => 'find-all', - 'entities' => [ - [ - 'entityClass' => CmsUser::class, - ], - ], - ], - ); - - $cm->addSqlResultSetMapping( - [ - 'name' => 'find-all', - 'entities' => [ - [ - 'entityClass' => CmsUser::class, - ], - ], - ], - ); - } - /** @group DDC-1068 */ public function testClassCaseSensitivity(): void { @@ -767,25 +658,6 @@ public function testTargetEntityNotFound(): void $cm->validateAssociations(); } - /** @group DDC-1663 */ - public function testNameIsMandatoryForEntityNameSqlResultSetMappingException(): void - { - $this->expectException(MappingException::class); - $this->expectExceptionMessage('Result set mapping named "find-all" in "Doctrine\Tests\Models\CMS\CmsUser requires a entity class name.'); - $cm = new ClassMetadata(CmsUser::class); - $cm->initializeReflection(new RuntimeReflectionService()); - $cm->addSqlResultSetMapping( - [ - 'name' => 'find-all', - 'entities' => [ - [ - 'fields' => [], - ], - ], - ], - ); - } - public function testNameIsMandatoryForDiscriminatorColumnsMappingException(): void { $this->expectException(MappingException::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index ac0c5766319..74f658dccd3 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -567,73 +567,6 @@ public function testIdentifierRequiredShouldMentionParentClasses(): void $factory->getMetadataFor(DDC889Entity::class); } - /** @group DDC-1663 */ - public function testSqlResultSetMapping(): void - { - $userMetadata = $this->createClassMetadata(CmsUser::class); - $personMetadata = $this->createClassMetadata(CompanyPerson::class); - - // user asserts - self::assertCount(4, $userMetadata->getSqlResultSetMappings()); - - $mapping = $userMetadata->getSqlResultSetMapping('mappingJoinedAddress'); - self::assertEquals([], $mapping['columns']); - self::assertEquals('mappingJoinedAddress', $mapping['name']); - self::assertNull($mapping['entities'][0]['discriminatorColumn']); - self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - self::assertEquals(['name' => 'address.zip', 'column' => 'zip'], $mapping['entities'][0]['fields'][3]); - self::assertEquals(['name' => 'address.city', 'column' => 'city'], $mapping['entities'][0]['fields'][4]); - self::assertEquals(['name' => 'address.country', 'column' => 'country'], $mapping['entities'][0]['fields'][5]); - self::assertEquals(['name' => 'address.id', 'column' => 'a_id'], $mapping['entities'][0]['fields'][6]); - self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - - $mapping = $userMetadata->getSqlResultSetMapping('mappingJoinedPhonenumber'); - self::assertEquals([], $mapping['columns']); - self::assertEquals('mappingJoinedPhonenumber', $mapping['name']); - self::assertNull($mapping['entities'][0]['discriminatorColumn']); - self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - self::assertEquals(['name' => 'phonenumbers.phonenumber', 'column' => 'number'], $mapping['entities'][0]['fields'][3]); - self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - - $mapping = $userMetadata->getSqlResultSetMapping('mappingUserPhonenumberCount'); - self::assertEquals(['name' => 'numphones'], $mapping['columns'][0]); - self::assertEquals('mappingUserPhonenumberCount', $mapping['name']); - self::assertNull($mapping['entities'][0]['discriminatorColumn']); - self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - self::assertEquals(['name' => 'status', 'column' => 'status'], $mapping['entities'][0]['fields'][2]); - self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - - $mapping = $userMetadata->getSqlResultSetMapping('mappingMultipleJoinsEntityResults'); - self::assertEquals(['name' => 'numphones'], $mapping['columns'][0]); - self::assertEquals('mappingMultipleJoinsEntityResults', $mapping['name']); - self::assertNull($mapping['entities'][0]['discriminatorColumn']); - self::assertEquals(['name' => 'id', 'column' => 'u_id'], $mapping['entities'][0]['fields'][0]); - self::assertEquals(['name' => 'name', 'column' => 'u_name'], $mapping['entities'][0]['fields'][1]); - self::assertEquals(['name' => 'status', 'column' => 'u_status'], $mapping['entities'][0]['fields'][2]); - self::assertEquals($userMetadata->name, $mapping['entities'][0]['entityClass']); - self::assertNull($mapping['entities'][1]['discriminatorColumn']); - self::assertEquals(['name' => 'id', 'column' => 'a_id'], $mapping['entities'][1]['fields'][0]); - self::assertEquals(['name' => 'zip', 'column' => 'a_zip'], $mapping['entities'][1]['fields'][1]); - self::assertEquals(['name' => 'country', 'column' => 'a_country'], $mapping['entities'][1]['fields'][2]); - self::assertEquals(CmsAddress::class, $mapping['entities'][1]['entityClass']); - - //person asserts - self::assertCount(1, $personMetadata->getSqlResultSetMappings()); - - $mapping = $personMetadata->getSqlResultSetMapping('mappingFetchAll'); - self::assertEquals([], $mapping['columns']); - self::assertEquals('mappingFetchAll', $mapping['name']); - self::assertEquals('discriminator', $mapping['entities'][0]['discriminatorColumn']); - self::assertEquals(['name' => 'id', 'column' => 'id'], $mapping['entities'][0]['fields'][0]); - self::assertEquals(['name' => 'name', 'column' => 'name'], $mapping['entities'][0]['fields'][1]); - self::assertEquals($personMetadata->name, $mapping['entities'][0]['entityClass']); - } - /** * @requires PHP 8.1 * @group DDC-964 diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml index 1e61b508b0e..4960b173785 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml @@ -4,29 +4,11 @@ https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + - - - - - - - - - - - - - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml index 8a8e6e1fc64..5e9bb53580b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml @@ -6,56 +6,10 @@ https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -86,7 +40,7 @@ - + diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml index 7ad91a9ebc0..d4aa6dbbf7c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml @@ -13,25 +13,16 @@ - - - - - - - - - - + - + - + From dc2bd9e4126cb96ece2c948281e590f1371500d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 30 Sep 2022 23:38:43 +0200 Subject: [PATCH 171/475] Migrate collections to PHP 8 syntax --- composer.json | 2 +- lib/Doctrine/ORM/LazyCriteriaCollection.php | 35 ++---- lib/Doctrine/ORM/PersistentCollection.php | 121 ++++++-------------- 3 files changed, 44 insertions(+), 114 deletions(-) diff --git a/composer.json b/composer.json index f1ed9a8e740..4714c72fdcc 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "php": "^8.1", "composer-runtime-api": "^2", "ext-ctype": "*", - "doctrine/collections": "^1.5 || ^2.0", + "doctrine/collections": "^2.0", "doctrine/common": "^3.3", "doctrine/dbal": "^3.4", "doctrine/deprecations": "^0.5.3 || ^1", diff --git a/lib/Doctrine/ORM/LazyCriteriaCollection.php b/lib/Doctrine/ORM/LazyCriteriaCollection.php index 737f468d937..a33a1b28f5d 100644 --- a/lib/Doctrine/ORM/LazyCriteriaCollection.php +++ b/lib/Doctrine/ORM/LazyCriteriaCollection.php @@ -7,6 +7,7 @@ use Doctrine\Common\Collections\AbstractLazyCollection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; +use Doctrine\Common\Collections\ReadableCollection; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Persisters\Entity\EntityPersister; @@ -25,19 +26,12 @@ */ class LazyCriteriaCollection extends AbstractLazyCollection implements Selectable { - /** @var EntityPersister */ - protected $entityPersister; + private int|null $count = null; - /** @var Criteria */ - protected $criteria; - - /** @var int|null */ - private $count; - - public function __construct(EntityPersister $entityPersister, Criteria $criteria) - { - $this->entityPersister = $entityPersister; - $this->criteria = $criteria; + public function __construct( + protected EntityPersister $entityPersister, + protected Criteria $criteria, + ) { } /** @@ -59,10 +53,8 @@ public function count(): int /** * check if collection is empty without loading it - * - * @return bool TRUE if the collection is empty, FALSE otherwise. */ - public function isEmpty() + public function isEmpty(): bool { if ($this->isInitialized()) { return $this->collection->isEmpty(); @@ -78,7 +70,7 @@ public function isEmpty() * * @template TMaybeContained */ - public function contains($element) + public function contains(mixed $element): bool { if ($this->isInitialized()) { return $this->collection->contains($element); @@ -87,10 +79,8 @@ public function contains($element) return $this->entityPersister->exists($element, $this->criteria); } - /** - * {@inheritDoc} - */ - public function matching(Criteria $criteria) + /** @return ReadableCollection&Selectable */ + public function matching(Criteria $criteria): ReadableCollection { $this->initialize(); assert($this->collection instanceof Selectable); @@ -98,10 +88,7 @@ public function matching(Criteria $criteria) return $this->collection->matching($criteria); } - /** - * {@inheritDoc} - */ - protected function doInitialize() + protected function doInitialize(): void { $elements = $this->entityPersister->loadCriteria($this->criteria); $this->collection = new ArrayCollection($elements); diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 81049afada7..8ff3e7a018a 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -18,7 +18,6 @@ use function array_values; use function array_walk; use function assert; -use function get_class; use function is_object; use function spl_object_id; @@ -44,14 +43,12 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec * * @psalm-var array */ - private $snapshot = []; + private array $snapshot = []; /** * The entity that owns this collection. - * - * @var object|null */ - private $owner; + private object|null $owner = null; /** * The association mapping the collection belongs to. @@ -59,37 +56,29 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec * * @psalm-var array|null */ - private $association; + private array|null $association = null; /** * The EntityManager that manages the persistence of the collection. - * - * @var EntityManagerInterface|null */ - private $em; + private EntityManagerInterface|null $em = null; /** * The name of the field on the target entities that points to the owner * of the collection. This is only set if the association is bi-directional. - * - * @var string|null */ - private $backRefFieldName; + private string|null $backRefFieldName = null; /** * The class descriptor of the collection's entity type. - * - * @var ClassMetadata|null */ - private $typeClass; + private ClassMetadata|null $typeClass = null; /** * Whether the collection is dirty and needs to be synchronized with the database * when the UnitOfWork that manages its persistent state commits. - * - * @var bool */ - private $isDirty = false; + private bool $isDirty = false; /** * Creates a new persistent collection. @@ -98,8 +87,11 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec * @param ClassMetadata $class The class descriptor of the entity type of this collection. * @psalm-param Collection $collection The collection elements. */ - public function __construct(EntityManagerInterface $em, $class, Collection $collection) - { + public function __construct( + EntityManagerInterface $em, + ClassMetadata $class, + Collection $collection, + ) { $this->collection = $collection; $this->em = $em; $this->typeClass = $class; @@ -111,10 +103,9 @@ public function __construct(EntityManagerInterface $em, $class, Collection $coll * Sets the collection's owning entity together with the AssociationMapping that * describes the association between the owner and the elements of the collection. * - * @param object $entity * @psalm-param array $assoc */ - public function setOwner($entity, array $assoc): void + public function setOwner(object $entity, array $assoc): void { $this->owner = $entity; $this->association = $assoc; @@ -124,15 +115,13 @@ public function setOwner($entity, array $assoc): void /** * INTERNAL: * Gets the collection owner. - * - * @return object|null */ - public function getOwner() + public function getOwner(): object|null { return $this->owner; } - public function getTypeClass(): Mapping\ClassMetadata + public function getTypeClass(): ClassMetadata { assert($this->typeClass !== null); @@ -150,10 +139,8 @@ private function getUnitOfWork(): UnitOfWork * INTERNAL: * Adds an element to a collection during hydration. This will automatically * complete bidirectional associations in the case of a one-to-many association. - * - * @param mixed $element The element to add. */ - public function hydrateAdd($element): void + public function hydrateAdd(mixed $element): void { $this->unwrap()->add($element); @@ -178,11 +165,8 @@ public function hydrateAdd($element): void /** * INTERNAL: * Sets a keyed element in the collection during hydration. - * - * @param mixed $key The key to set. - * @param mixed $element The element to set. */ - public function hydrateSet($key, $element): void + public function hydrateSet(mixed $key, mixed $element): void { $this->unwrap()->set($key, $element); @@ -293,7 +277,7 @@ private function changed(): void $this->association['type'] === ClassMetadata::MANY_TO_MANY && $this->owner && $this->em !== null && - $this->em->getClassMetadata(get_class($this->owner))->isChangeTrackingNotify() + $this->em->getClassMetadata($this->owner::class)->isChangeTrackingNotify() ) { $this->getUnitOfWork()->scheduleForDirtyCheck($this->owner); } @@ -302,8 +286,6 @@ private function changed(): void /** * Gets a boolean flag indicating whether this collection is dirty which means * its state needs to be synchronized with the database. - * - * @return bool TRUE if the collection is dirty, FALSE otherwise. */ public function isDirty(): bool { @@ -312,28 +294,21 @@ public function isDirty(): bool /** * Sets a boolean flag, indicating whether this collection is dirty. - * - * @param bool $dirty Whether the collection should be marked dirty or not. */ - public function setDirty($dirty): void + public function setDirty(bool $dirty): void { $this->isDirty = $dirty; } /** * Sets the initialized flag of the collection, forcing it into that state. - * - * @param bool $bool */ - public function setInitialized($bool): void + public function setInitialized(bool $bool): void { $this->initialized = $bool; } - /** - * {@inheritdoc} - */ - public function remove($key) + public function remove(string|int $key): mixed { // TODO: If the keys are persistent as well (not yet implemented) // and the collection is not initialized and orphanRemoval is @@ -359,10 +334,7 @@ public function remove($key) return $removed; } - /** - * {@inheritdoc} - */ - public function removeElement($element): bool + public function removeElement(mixed $element): bool { $removed = parent::removeElement($element); @@ -384,10 +356,7 @@ public function removeElement($element): bool return $removed; } - /** - * {@inheritdoc} - */ - public function containsKey($key): bool + public function containsKey(mixed $key): bool { if ( ! $this->initialized && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY @@ -406,7 +375,7 @@ public function containsKey($key): bool * * @template TMaybeContained */ - public function contains($element): bool + public function contains(mixed $element): bool { if (! $this->initialized && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->association); @@ -417,10 +386,7 @@ public function contains($element): bool return parent::contains($element); } - /** - * {@inheritdoc} - */ - public function get($key) + public function get(string|int $key): mixed { if ( ! $this->initialized @@ -450,10 +416,7 @@ public function count(): int return parent::count(); } - /** - * {@inheritdoc} - */ - public function set($key, $value): void + public function set(string|int $key, mixed $value): void { parent::set($key, $value); @@ -464,10 +427,7 @@ public function set($key, $value): void } } - /** - * {@inheritdoc} - */ - public function add($value): bool + public function add(mixed $value): bool { $this->unwrap()->add($value); @@ -480,28 +440,17 @@ public function add($value): bool return true; } - /* ArrayAccess implementation */ - - /** - * {@inheritdoc} - */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return $this->containsKey($offset); } - /** - * {@inheritdoc} - */ - public function offsetGet($offset): mixed + public function offsetGet(mixed $offset): mixed { return $this->get($offset); } - /** - * {@inheritdoc} - */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { if (! isset($offset)) { $this->add($value); @@ -512,10 +461,7 @@ public function offsetSet($offset, $value): void $this->set($offset, $value); } - /** - * {@inheritdoc} - */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { $this->remove($offset); } @@ -584,13 +530,10 @@ public function __sleep(): array * Keys have to be preserved by this method. Calling this method will only return the * selected slice and NOT change the elements contained in the collection slice is called on. * - * @param int $offset - * @param int|null $length - * * @return mixed[] * @psalm-return array */ - public function slice($offset, $length = null): array + public function slice(int $offset, int|null $length = null): array { if (! $this->initialized && ! $this->isDirty && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->association); From 8efcaf97eba3b064ca2fc0e0767494614adda3ed Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 18 Oct 2022 09:39:12 +0200 Subject: [PATCH 172/475] Add native types to annotation classes (#10151) --- .../ORM/Mapping/AssociationOverride.php | 59 ++------- .../ORM/Mapping/AssociationOverrides.php | 5 +- .../ORM/Mapping/AttributeOverride.php | 24 +--- .../ORM/Mapping/AttributeOverrides.php | 4 +- lib/Doctrine/ORM/Mapping/Cache.php | 20 +-- .../ORM/Mapping/ChangeTrackingPolicy.php | 16 +-- lib/Doctrine/ORM/Mapping/Column.php | 125 +++--------------- .../ORM/Mapping/CustomIdGenerator.php | 12 +- .../ORM/Mapping/DiscriminatorColumn.php | 36 +---- lib/Doctrine/ORM/Mapping/DiscriminatorMap.php | 12 +- lib/Doctrine/ORM/Mapping/Embedded.php | 6 +- lib/Doctrine/ORM/Mapping/Entity.php | 21 +-- lib/Doctrine/ORM/Mapping/EntityListeners.php | 14 +- lib/Doctrine/ORM/Mapping/GeneratedValue.php | 16 +-- lib/Doctrine/ORM/Mapping/Index.php | 45 +------ lib/Doctrine/ORM/Mapping/InheritanceType.php | 16 +-- .../ORM/Mapping/JoinColumnProperties.php | 79 ++--------- lib/Doctrine/ORM/Mapping/JoinColumns.php | 8 +- lib/Doctrine/ORM/Mapping/JoinTable.php | 47 ++----- lib/Doctrine/ORM/Mapping/ManyToMany.php | 67 +--------- lib/Doctrine/ORM/Mapping/ManyToOne.php | 40 +----- lib/Doctrine/ORM/Mapping/MappedSuperclass.php | 13 +- lib/Doctrine/ORM/Mapping/OneToMany.php | 58 +------- lib/Doctrine/ORM/Mapping/OneToOne.php | 58 +------- lib/Doctrine/ORM/Mapping/OrderBy.php | 12 +- .../ORM/Mapping/SequenceGenerator.php | 27 +--- lib/Doctrine/ORM/Mapping/Table.php | 45 +------ lib/Doctrine/ORM/Mapping/UniqueConstraint.php | 42 +----- psalm-baseline.xml | 11 -- 29 files changed, 142 insertions(+), 796 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverride.php b/lib/Doctrine/ORM/Mapping/AssociationOverride.php index c1cabbe83c4..885eb964cd5 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationOverride.php +++ b/lib/Doctrine/ORM/Mapping/AssociationOverride.php @@ -13,68 +13,35 @@ */ final class AssociationOverride implements Annotation { - /** - * The name of the relationship property whose mapping is being overridden. - * - * @var string - * @readonly - */ - public $name; - /** * The join column that is being mapped to the persistent attribute. * * @var array|null - * @readonly */ - public $joinColumns; + public readonly array|null $joinColumns; /** * The join column that is being mapped to the persistent attribute. * * @var array|null - * @readonly - */ - public $inverseJoinColumns; - - /** - * The join table that maps the relationship. - * - * @var JoinTable|null - * @readonly - */ - public $joinTable; - - /** - * The name of the association-field on the inverse-side. - * - * @var string|null - * @readonly - */ - public $inversedBy; - - /** - * The fetching strategy to use for the association. - * - * @var string|null - * @psalm-var 'LAZY'|'EAGER'|'EXTRA_LAZY'|null - * @readonly - * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) */ - public $fetch; + public readonly array|null $inverseJoinColumns; /** + * @param string $name The name of the relationship property whose mapping is being overridden. * @param JoinColumn|array $joinColumns * @param JoinColumn|array $inverseJoinColumns + * @param JoinTable|null $joinTable The join table that maps the relationship. + * @param string|null $inversedBy The name of the association-field on the inverse-side. * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY'|null $fetch */ public function __construct( - string $name, - $joinColumns = null, - $inverseJoinColumns = null, - JoinTable|null $joinTable = null, - string|null $inversedBy = null, - string|null $fetch = null, + public readonly string $name, + array|JoinColumn|null $joinColumns = null, + array|JoinColumn|null $inverseJoinColumns = null, + public readonly JoinTable|null $joinTable = null, + public readonly string|null $inversedBy = null, + public readonly string|null $fetch = null, ) { if ($joinColumns instanceof JoinColumn) { $joinColumns = [$joinColumns]; @@ -84,11 +51,7 @@ public function __construct( $inverseJoinColumns = [$inverseJoinColumns]; } - $this->name = $name; $this->joinColumns = $joinColumns; $this->inverseJoinColumns = $inverseJoinColumns; - $this->joinTable = $joinTable; - $this->inversedBy = $inversedBy; - $this->fetch = $fetch; } } diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php b/lib/Doctrine/ORM/Mapping/AssociationOverrides.php index 33f2a8265a2..364a431e416 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AssociationOverrides.php @@ -23,12 +23,11 @@ final class AssociationOverrides implements Annotation * Mapping overrides of relationship properties. * * @var list - * @readonly */ - public $overrides = []; + public readonly array $overrides; /** @param array|AssociationOverride $overrides */ - public function __construct($overrides) + public function __construct(array|AssociationOverride $overrides) { if (! is_array($overrides)) { $overrides = [$overrides]; diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverride.php b/lib/Doctrine/ORM/Mapping/AttributeOverride.php index e18e0cf958d..9db5e63db32 100644 --- a/lib/Doctrine/ORM/Mapping/AttributeOverride.php +++ b/lib/Doctrine/ORM/Mapping/AttributeOverride.php @@ -13,25 +13,9 @@ */ final class AttributeOverride implements Annotation { - /** - * The name of the property whose mapping is being overridden. - * - * @var string - * @readonly - */ - public $name; - - /** - * The column definition. - * - * @var Column - * @readonly - */ - public $column; - - public function __construct(string $name, Column $column) - { - $this->name = $name; - $this->column = $column; + public function __construct( + public string $name, + public Column $column, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php index 6f2f9bd962e..ede2c71918b 100644 --- a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php @@ -25,10 +25,10 @@ final class AttributeOverrides implements Annotation * @var list * @readonly */ - public $overrides = []; + public array $overrides = []; /** @param array|AttributeOverride $overrides */ - public function __construct($overrides) + public function __construct(array|AttributeOverride $overrides) { if (! is_array($overrides)) { $overrides = [$overrides]; diff --git a/lib/Doctrine/ORM/Mapping/Cache.php b/lib/Doctrine/ORM/Mapping/Cache.php index 3471e7bf65a..c7572fc481d 100644 --- a/lib/Doctrine/ORM/Mapping/Cache.php +++ b/lib/Doctrine/ORM/Mapping/Cache.php @@ -17,22 +17,10 @@ #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY)] final class Cache implements Annotation { - /** - * The concurrency strategy. - * - * @Enum({"READ_ONLY", "NONSTRICT_READ_WRITE", "READ_WRITE"}) - * @var string - * @psalm-var 'READ_ONLY'|'NONSTRICT_READ_WRITE'|'READ_WRITE' - */ - public $usage = 'READ_ONLY'; - - /** @var string|null Cache region name. */ - public $region; - /** @psalm-param 'READ_ONLY'|'NONSTRICT_READ_WRITE'|'READ_WRITE' $usage */ - public function __construct(string $usage = 'READ_ONLY', string|null $region = null) - { - $this->usage = $usage; - $this->region = $region; + public function __construct( + public readonly string $usage = 'READ_ONLY', + public readonly string|null $region = null, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php index fb23eb0be8e..08032518269 100644 --- a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php +++ b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php @@ -15,19 +15,9 @@ #[Attribute(Attribute::TARGET_CLASS)] final class ChangeTrackingPolicy implements Annotation { - /** - * The change tracking policy. - * - * @var string - * @psalm-var 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY' - * @readonly - * @Enum({"DEFERRED_IMPLICIT", "DEFERRED_EXPLICIT", "NOTIFY"}) - */ - public $value; - /** @psalm-param 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY' $value */ - public function __construct(string $value) - { - $this->value = $value; + public function __construct( + public readonly string $value, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/Column.php b/lib/Doctrine/ORM/Mapping/Column.php index e9bde8d1389..f9c019a2327 100644 --- a/lib/Doctrine/ORM/Mapping/Column.php +++ b/lib/Doctrine/ORM/Mapping/Column.php @@ -17,121 +17,26 @@ final class Column implements Annotation { /** - * @var string|null - * @readonly - */ - public $name; - - /** - * @var mixed - * @readonly - */ - public $type; - - /** - * @var int|null - * @readonly - */ - public $length; - - /** - * The precision for a decimal (exact numeric) column (Applies only for decimal column). - * - * @var int|null - * @readonly - */ - public $precision = 0; - - /** - * The scale for a decimal (exact numeric) column (Applies only for decimal column). - * - * @var int|null - * @readonly - */ - public $scale = 0; - - /** - * @var bool - * @readonly - */ - public $unique = false; - - /** - * @var bool - * @readonly - */ - public $nullable = false; - - /** - * @var bool - * @readonly - */ - public $insertable = true; - - /** - * @var bool - * @readonly - */ - public $updatable = true; - - /** - * @var class-string|null - * @readonly - */ - public $enumType = null; - - /** - * @var array - * @readonly - */ - public $options = []; - - /** - * @var string|null - * @readonly - */ - public $columnDefinition; - - /** - * @var string|null - * @readonly - * @psalm-var 'NEVER'|'INSERT'|'ALWAYS'|null - * @Enum({"NEVER", "INSERT", "ALWAYS"}) - */ - public $generated; - - /** + * @param int|null $precision The precision for a decimal (exact numeric) column (Applies only for decimal column). + * @param int|null $scale The scale for a decimal (exact numeric) column (Applies only for decimal column). * @param class-string|null $enumType * @param array $options * @psalm-param 'NEVER'|'INSERT'|'ALWAYS'|null $generated */ public function __construct( - string|null $name = null, - string|null $type = null, - int|null $length = null, - int|null $precision = null, - int|null $scale = null, - bool $unique = false, - bool $nullable = false, - bool $insertable = true, - bool $updatable = true, - string|null $enumType = null, - array $options = [], - string|null $columnDefinition = null, - string|null $generated = null, + public readonly string|null $name = null, + public readonly string|null $type = null, + public readonly int|null $length = null, + public readonly int|null $precision = null, + public readonly int|null $scale = null, + public readonly bool $unique = false, + public readonly bool $nullable = false, + public readonly bool $insertable = true, + public readonly bool $updatable = true, + public readonly string|null $enumType = null, + public readonly array $options = [], + public readonly string|null $columnDefinition = null, + public readonly string|null $generated = null, ) { - $this->name = $name; - $this->type = $type; - $this->length = $length; - $this->precision = $precision; - $this->scale = $scale; - $this->unique = $unique; - $this->nullable = $nullable; - $this->insertable = $insertable; - $this->updatable = $updatable; - $this->enumType = $enumType; - $this->options = $options; - $this->columnDefinition = $columnDefinition; - $this->generated = $generated; } } diff --git a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php b/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php index 8530aeaa7b1..ccf1592b528 100644 --- a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php +++ b/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php @@ -15,14 +15,8 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class CustomIdGenerator implements Annotation { - /** - * @var string|null - * @readonly - */ - public $class; - - public function __construct(string|null $class = null) - { - $this->class = $class; + public function __construct( + public readonly string|null $class = null, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php b/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php index e01c0e8ce32..a8f1f19d90e 100644 --- a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php @@ -15,39 +15,11 @@ #[Attribute(Attribute::TARGET_CLASS)] final class DiscriminatorColumn implements Annotation { - /** - * @var string|null - * @readonly - */ - public $name; - - /** - * @var string|null - * @readonly - */ - public $type; - - /** - * @var int|null - * @readonly - */ - public $length; - - /** - * @var string|null - * @readonly - */ - public $columnDefinition; - public function __construct( - string|null $name = null, - string|null $type = null, - int|null $length = null, - string|null $columnDefinition = null, + public readonly string|null $name = null, + public readonly string|null $type = null, + public readonly int|null $length = null, + public readonly string|null $columnDefinition = null, ) { - $this->name = $name; - $this->type = $type; - $this->length = $length; - $this->columnDefinition = $columnDefinition; } } diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php b/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php index 49d4e5e3b06..2c5ccb0aa37 100644 --- a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php @@ -15,15 +15,9 @@ #[Attribute(Attribute::TARGET_CLASS)] final class DiscriminatorMap implements Annotation { - /** - * @var array - * @readonly - */ - public $value; - /** @param array $value */ - public function __construct(array $value) - { - $this->value = $value; + public function __construct( + public readonly array $value, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/Embedded.php b/lib/Doctrine/ORM/Mapping/Embedded.php index c1be5fb81b3..3a0961dc580 100644 --- a/lib/Doctrine/ORM/Mapping/Embedded.php +++ b/lib/Doctrine/ORM/Mapping/Embedded.php @@ -16,10 +16,8 @@ final class Embedded implements Annotation { public function __construct( - /** @readonly */ - public string|null $class = null, - /** @readonly */ - public string|bool|null $columnPrefix = null, + public readonly string|null $class = null, + public readonly string|bool|null $columnPrefix = null, ) { } } diff --git a/lib/Doctrine/ORM/Mapping/Entity.php b/lib/Doctrine/ORM/Mapping/Entity.php index c90878a60b3..ffdaf38748d 100644 --- a/lib/Doctrine/ORM/Mapping/Entity.php +++ b/lib/Doctrine/ORM/Mapping/Entity.php @@ -17,23 +17,10 @@ #[Attribute(Attribute::TARGET_CLASS)] final class Entity implements Annotation { - /** - * @var string|null - * @psalm-var class-string>|null - * @readonly - */ - public $repositoryClass; - - /** - * @var bool - * @readonly - */ - public $readOnly = false; - /** @psalm-param class-string>|null $repositoryClass */ - public function __construct(string|null $repositoryClass = null, bool $readOnly = false) - { - $this->repositoryClass = $repositoryClass; - $this->readOnly = $readOnly; + public function __construct( + public readonly string|null $repositoryClass = null, + public readonly bool $readOnly = false, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/EntityListeners.php b/lib/Doctrine/ORM/Mapping/EntityListeners.php index f1a80aeeea1..aacf11c5044 100644 --- a/lib/Doctrine/ORM/Mapping/EntityListeners.php +++ b/lib/Doctrine/ORM/Mapping/EntityListeners.php @@ -18,17 +18,9 @@ #[Attribute(Attribute::TARGET_CLASS)] final class EntityListeners implements Annotation { - /** - * Specifies the names of the entity listeners. - * - * @var array - * @readonly - */ - public $value = []; - /** @param array $value */ - public function __construct(array $value = []) - { - $this->value = $value; + public function __construct( + public readonly array $value = [], + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/GeneratedValue.php b/lib/Doctrine/ORM/Mapping/GeneratedValue.php index 5bc9dbc93a0..9acb4228ffe 100644 --- a/lib/Doctrine/ORM/Mapping/GeneratedValue.php +++ b/lib/Doctrine/ORM/Mapping/GeneratedValue.php @@ -15,19 +15,9 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class GeneratedValue implements Annotation { - /** - * The type of ID generator. - * - * @var string - * @psalm-var 'AUTO'|'SEQUENCE'|'IDENTITY'|'NONE'|'CUSTOM' - * @readonly - * @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "CUSTOM"}) - */ - public $strategy = 'AUTO'; - /** @psalm-param 'AUTO'|'SEQUENCE'|'IDENTITY'|'NONE'|'CUSTOM' $strategy */ - public function __construct(string $strategy = 'AUTO') - { - $this->strategy = $strategy; + public function __construct( + public readonly string $strategy = 'AUTO', + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/Index.php b/lib/Doctrine/ORM/Mapping/Index.php index 8dfc564c8a3..b2f7fdae778 100644 --- a/lib/Doctrine/ORM/Mapping/Index.php +++ b/lib/Doctrine/ORM/Mapping/Index.php @@ -15,36 +15,6 @@ #[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] final class Index implements Annotation { - /** - * @var string|null - * @readonly - */ - public $name; - - /** - * @var array|null - * @readonly - */ - public $columns; - - /** - * @var array|null - * @readonly - */ - public $fields; - - /** - * @var array|null - * @readonly - */ - public $flags; - - /** - * @var array|null - * @readonly - */ - public $options; - /** * @param array|null $columns * @param array|null $fields @@ -52,16 +22,11 @@ final class Index implements Annotation * @param array|null $options */ public function __construct( - array|null $columns = null, - array|null $fields = null, - string|null $name = null, - array|null $flags = null, - array|null $options = null, + public readonly array|null $columns = null, + public readonly array|null $fields = null, + public readonly string|null $name = null, + public readonly array|null $flags = null, + public readonly array|null $options = null, ) { - $this->columns = $columns; - $this->fields = $fields; - $this->name = $name; - $this->flags = $flags; - $this->options = $options; } } diff --git a/lib/Doctrine/ORM/Mapping/InheritanceType.php b/lib/Doctrine/ORM/Mapping/InheritanceType.php index 33db6a95aae..bfad4349f33 100644 --- a/lib/Doctrine/ORM/Mapping/InheritanceType.php +++ b/lib/Doctrine/ORM/Mapping/InheritanceType.php @@ -15,19 +15,9 @@ #[Attribute(Attribute::TARGET_CLASS)] final class InheritanceType implements Annotation { - /** - * The inheritance type used by the class and its subclasses. - * - * @var string - * @psalm-var 'NONE'|'JOINED'|'SINGLE_TABLE'|'TABLE_PER_CLASS' - * @readonly - * @Enum({"NONE", "JOINED", "SINGLE_TABLE", "TABLE_PER_CLASS"}) - */ - public $value; - /** @psalm-param 'NONE'|'JOINED'|'SINGLE_TABLE'|'TABLE_PER_CLASS' $value */ - public function __construct(string $value) - { - $this->value = $value; + public function __construct( + public readonly string $value, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/JoinColumnProperties.php b/lib/Doctrine/ORM/Mapping/JoinColumnProperties.php index 0963e1e1534..7d132952b31 100644 --- a/lib/Doctrine/ORM/Mapping/JoinColumnProperties.php +++ b/lib/Doctrine/ORM/Mapping/JoinColumnProperties.php @@ -6,77 +6,16 @@ trait JoinColumnProperties { - /** - * @var string|null - * @readonly - */ - public $name; - - /** - * @var string - * @readonly - */ - public $referencedColumnName = 'id'; - - /** - * @var bool - * @readonly - */ - public $unique = false; - - /** - * @var bool - * @readonly - */ - public $nullable = true; - - /** - * @var mixed - * @readonly - */ - public $onDelete; - - /** - * @var string|null - * @readonly - */ - public $columnDefinition; - - /** - * Field name used in non-object hydration (array/scalar). - * - * @var string|null - * @readonly - */ - public $fieldName; - - /** - * @var array - * @readonly - */ - public $options = []; - - /** - * @param mixed $onDelete - * @param array $options - */ + /** @param array $options */ public function __construct( - string|null $name = null, - string $referencedColumnName = 'id', - bool $unique = false, - bool $nullable = true, - $onDelete = null, - string|null $columnDefinition = null, - string|null $fieldName = null, - array $options = [], + public readonly string|null $name = null, + public readonly string $referencedColumnName = 'id', + public readonly bool $unique = false, + public readonly bool $nullable = true, + public readonly mixed $onDelete = null, + public readonly string|null $columnDefinition = null, + public readonly string|null $fieldName = null, + public readonly array $options = [], ) { - $this->name = $name; - $this->referencedColumnName = $referencedColumnName; - $this->unique = $unique; - $this->nullable = $nullable; - $this->onDelete = $onDelete; - $this->columnDefinition = $columnDefinition; - $this->fieldName = $fieldName; - $this->options = $options; } } diff --git a/lib/Doctrine/ORM/Mapping/JoinColumns.php b/lib/Doctrine/ORM/Mapping/JoinColumns.php index d00bdcc5834..30388931780 100644 --- a/lib/Doctrine/ORM/Mapping/JoinColumns.php +++ b/lib/Doctrine/ORM/Mapping/JoinColumns.php @@ -6,10 +6,14 @@ /** * @Annotation + * @NamedArgumentConstructor * @Target("PROPERTY") */ final class JoinColumns implements Annotation { - /** @var array<\Doctrine\ORM\Mapping\JoinColumn> */ - public $value; + /** @param array $value */ + public function __construct( + public readonly array $value, + ) { + } } diff --git a/lib/Doctrine/ORM/Mapping/JoinTable.php b/lib/Doctrine/ORM/Mapping/JoinTable.php index 5e44e147652..ca10bac706a 100644 --- a/lib/Doctrine/ORM/Mapping/JoinTable.php +++ b/lib/Doctrine/ORM/Mapping/JoinTable.php @@ -15,50 +15,27 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class JoinTable implements Annotation { - /** - * @var string|null - * @readonly - */ - public $name; + /** @var array */ + public readonly array $joinColumns; - /** - * @var string|null - * @readonly - */ - public $schema; + /** @var array */ + public readonly array $inverseJoinColumns; /** - * @var array - * @readonly + * @param array|JoinColumn $joinColumns + * @param array|JoinColumn $inverseJoinColumns + * @param array $options */ - public $joinColumns = []; - - /** - * @var array - * @readonly - */ - public $inverseJoinColumns = []; - - /** - * @var array - * @readonly - */ - public $options = []; - - /** @param array $options */ public function __construct( - string|null $name = null, - string|null $schema = null, - $joinColumns = [], - $inverseJoinColumns = [], - array $options = [], + public readonly string|null $name = null, + public readonly string|null $schema = null, + array|JoinColumn $joinColumns = [], + array|JoinColumn $inverseJoinColumns = [], + public readonly array $options = [], ) { - $this->name = $name; - $this->schema = $schema; $this->joinColumns = $joinColumns instanceof JoinColumn ? [$joinColumns] : $joinColumns; $this->inverseJoinColumns = $inverseJoinColumns instanceof JoinColumn ? [$inverseJoinColumns] : $inverseJoinColumns; - $this->options = $options; } } diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/lib/Doctrine/ORM/Mapping/ManyToMany.php index 0f5f2de5a86..abc11265f05 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -15,72 +15,19 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class ManyToMany implements Annotation { - /** - * @var class-string|null - * @readonly - */ - public $targetEntity; - - /** - * @var string|null - * @readonly - */ - public $mappedBy; - - /** - * @var string|null - * @readonly - */ - public $inversedBy; - - /** - * @var string[]|null - * @readonly - */ - public $cascade; - - /** - * The fetching strategy to use for the association. - * - * @var string - * @psalm-var 'LAZY'|'EAGER'|'EXTRA_LAZY' - * @readonly - * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) - */ - public $fetch = 'LAZY'; - - /** - * @var bool - * @readonly - */ - public $orphanRemoval = false; - - /** - * @var string|null - * @readonly - */ - public $indexBy; - /** * @param class-string $targetEntity * @param string[]|null $cascade * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch */ public function __construct( - string $targetEntity, - string|null $mappedBy = null, - string|null $inversedBy = null, - array|null $cascade = null, - string $fetch = 'LAZY', - bool $orphanRemoval = false, - string|null $indexBy = null, + public readonly string $targetEntity, + public readonly string|null $mappedBy = null, + public readonly string|null $inversedBy = null, + public readonly array|null $cascade = null, + public readonly string $fetch = 'LAZY', + public readonly bool $orphanRemoval = false, + public readonly string|null $indexBy = null, ) { - $this->targetEntity = $targetEntity; - $this->mappedBy = $mappedBy; - $this->inversedBy = $inversedBy; - $this->cascade = $cascade; - $this->fetch = $fetch; - $this->orphanRemoval = $orphanRemoval; - $this->indexBy = $indexBy; } } diff --git a/lib/Doctrine/ORM/Mapping/ManyToOne.php b/lib/Doctrine/ORM/Mapping/ManyToOne.php index 412db2948b1..b573a93e2e6 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToOne.php +++ b/lib/Doctrine/ORM/Mapping/ManyToOne.php @@ -15,48 +15,16 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class ManyToOne implements Annotation { - /** - * @var class-string|null - * @readonly - */ - public $targetEntity; - - /** - * @var string[]|null - * @readonly - */ - public $cascade; - - /** - * The fetching strategy to use for the association. - * - * @var string - * @psalm-var 'LAZY'|'EAGER'|'EXTRA_LAZY' - * @readonly - * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) - */ - public $fetch = 'LAZY'; - - /** - * @var string|null - * @readonly - */ - public $inversedBy; - /** * @param class-string|null $targetEntity * @param string[]|null $cascade * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch */ public function __construct( - string|null $targetEntity = null, - array|null $cascade = null, - string $fetch = 'LAZY', - string|null $inversedBy = null, + public readonly string|null $targetEntity = null, + public readonly array|null $cascade = null, + public readonly string $fetch = 'LAZY', + public readonly string|null $inversedBy = null, ) { - $this->targetEntity = $targetEntity; - $this->cascade = $cascade; - $this->fetch = $fetch; - $this->inversedBy = $inversedBy; } } diff --git a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php b/lib/Doctrine/ORM/Mapping/MappedSuperclass.php index 09a6d889b3b..519f82d4034 100644 --- a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php +++ b/lib/Doctrine/ORM/Mapping/MappedSuperclass.php @@ -16,16 +16,9 @@ #[Attribute(Attribute::TARGET_CLASS)] final class MappedSuperclass implements Annotation { - /** - * @var string|null - * @psalm-var class-string|null - * @readonly - */ - public $repositoryClass; - /** @psalm-param class-string|null $repositoryClass */ - public function __construct(string|null $repositoryClass = null) - { - $this->repositoryClass = $repositoryClass; + public function __construct( + public readonly string|null $repositoryClass = null, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/OneToMany.php b/lib/Doctrine/ORM/Mapping/OneToMany.php index 027fd9c8ad9..8f088533756 100644 --- a/lib/Doctrine/ORM/Mapping/OneToMany.php +++ b/lib/Doctrine/ORM/Mapping/OneToMany.php @@ -15,64 +15,18 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class OneToMany implements Annotation { - /** - * @var string|null - * @readonly - */ - public $mappedBy; - - /** - * @var class-string|null - * @readonly - */ - public $targetEntity; - - /** - * @var array|null - * @readonly - */ - public $cascade; - - /** - * The fetching strategy to use for the association. - * - * @var string - * @psalm-var 'LAZY'|'EAGER'|'EXTRA_LAZY' - * @readonly - * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) - */ - public $fetch = 'LAZY'; - - /** - * @var bool - * @readonly - */ - public $orphanRemoval = false; - - /** - * @var string|null - * @readonly - */ - public $indexBy; - /** * @param class-string|null $targetEntity * @param string[]|null $cascade * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch */ public function __construct( - string|null $mappedBy = null, - string|null $targetEntity = null, - array|null $cascade = null, - string $fetch = 'LAZY', - bool $orphanRemoval = false, - string|null $indexBy = null, + public readonly string|null $mappedBy = null, + public readonly string|null $targetEntity = null, + public readonly array|null $cascade = null, + public readonly string $fetch = 'LAZY', + public readonly bool $orphanRemoval = false, + public readonly string|null $indexBy = null, ) { - $this->mappedBy = $mappedBy; - $this->targetEntity = $targetEntity; - $this->cascade = $cascade; - $this->fetch = $fetch; - $this->orphanRemoval = $orphanRemoval; - $this->indexBy = $indexBy; } } diff --git a/lib/Doctrine/ORM/Mapping/OneToOne.php b/lib/Doctrine/ORM/Mapping/OneToOne.php index 0f3961dadc6..ede066982fc 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOne.php +++ b/lib/Doctrine/ORM/Mapping/OneToOne.php @@ -15,64 +15,18 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class OneToOne implements Annotation { - /** - * @var class-string|null - * @readonly - */ - public $targetEntity; - - /** - * @var string|null - * @readonly - */ - public $mappedBy; - - /** - * @var string|null - * @readonly - */ - public $inversedBy; - - /** - * @var array|null - * @readonly - */ - public $cascade; - - /** - * The fetching strategy to use for the association. - * - * @var string - * @psalm-var 'LAZY'|'EAGER'|'EXTRA_LAZY' - * @readonly - * @Enum({"LAZY", "EAGER", "EXTRA_LAZY"}) - */ - public $fetch = 'LAZY'; - - /** - * @var bool - * @readonly - */ - public $orphanRemoval = false; - /** * @param class-string|null $targetEntity * @param array|null $cascade * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch */ public function __construct( - string|null $mappedBy = null, - string|null $inversedBy = null, - string|null $targetEntity = null, - array|null $cascade = null, - string $fetch = 'LAZY', - bool $orphanRemoval = false, + public readonly string|null $mappedBy = null, + public readonly string|null $inversedBy = null, + public readonly string|null $targetEntity = null, + public readonly array|null $cascade = null, + public readonly string $fetch = 'LAZY', + public readonly bool $orphanRemoval = false, ) { - $this->mappedBy = $mappedBy; - $this->inversedBy = $inversedBy; - $this->targetEntity = $targetEntity; - $this->cascade = $cascade; - $this->fetch = $fetch; - $this->orphanRemoval = $orphanRemoval; } } diff --git a/lib/Doctrine/ORM/Mapping/OrderBy.php b/lib/Doctrine/ORM/Mapping/OrderBy.php index fa8c33bbaaa..3287d644af9 100644 --- a/lib/Doctrine/ORM/Mapping/OrderBy.php +++ b/lib/Doctrine/ORM/Mapping/OrderBy.php @@ -15,15 +15,9 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class OrderBy implements Annotation { - /** - * @var array - * @readonly - */ - public $value; - /** @param array $value */ - public function __construct(array $value) - { - $this->value = $value; + public function __construct( + public readonly array $value, + ) { } } diff --git a/lib/Doctrine/ORM/Mapping/SequenceGenerator.php b/lib/Doctrine/ORM/Mapping/SequenceGenerator.php index 67fb916e5a5..5564a8463d9 100644 --- a/lib/Doctrine/ORM/Mapping/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Mapping/SequenceGenerator.php @@ -15,31 +15,10 @@ #[Attribute(Attribute::TARGET_PROPERTY)] final class SequenceGenerator implements Annotation { - /** - * @var string|null - * @readonly - */ - public $sequenceName; - - /** - * @var int - * @readonly - */ - public $allocationSize = 1; - - /** - * @var int - * @readonly - */ - public $initialValue = 1; - public function __construct( - string|null $sequenceName = null, - int $allocationSize = 1, - int $initialValue = 1, + public readonly string|null $sequenceName = null, + public readonly int $allocationSize = 1, + public readonly int $initialValue = 1, ) { - $this->sequenceName = $sequenceName; - $this->allocationSize = $allocationSize; - $this->initialValue = $initialValue; } } diff --git a/lib/Doctrine/ORM/Mapping/Table.php b/lib/Doctrine/ORM/Mapping/Table.php index 9860ed1a36f..2ba38d78b1e 100644 --- a/lib/Doctrine/ORM/Mapping/Table.php +++ b/lib/Doctrine/ORM/Mapping/Table.php @@ -15,52 +15,17 @@ #[Attribute(Attribute::TARGET_CLASS)] final class Table implements Annotation { - /** - * @var string|null - * @readonly - */ - public $name; - - /** - * @var string|null - * @readonly - */ - public $schema; - - /** - * @var array|null - * @readonly - */ - public $indexes; - - /** - * @var array|null - * @readonly - */ - public $uniqueConstraints; - - /** - * @var array - * @readonly - */ - public $options = []; - /** * @param array $indexes * @param array $uniqueConstraints * @param array $options */ public function __construct( - string|null $name = null, - string|null $schema = null, - array|null $indexes = null, - array|null $uniqueConstraints = null, - array $options = [], + public readonly string|null $name = null, + public readonly string|null $schema = null, + public readonly array|null $indexes = null, + public readonly array|null $uniqueConstraints = null, + public readonly array $options = [], ) { - $this->name = $name; - $this->schema = $schema; - $this->indexes = $indexes; - $this->uniqueConstraints = $uniqueConstraints; - $this->options = $options; } } diff --git a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php b/lib/Doctrine/ORM/Mapping/UniqueConstraint.php index 341673d8b43..fdb8cb3db94 100644 --- a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php +++ b/lib/Doctrine/ORM/Mapping/UniqueConstraint.php @@ -16,43 +16,15 @@ final class UniqueConstraint implements Annotation { /** - * @var string|null - * @readonly - */ - public $name; - - /** - * @var array|null - * @readonly - */ - public $columns; - - /** - * @var array|null - * @readonly - */ - public $fields; - - /** - * @var array|null - * @readonly - */ - public $options; - - /** - * @param array $columns - * @param array $fields - * @param array $options + * @param array|null $columns + * @param array|null $fields + * @param array|null $options */ public function __construct( - string|null $name = null, - array|null $columns = null, - array|null $fields = null, - array|null $options = null, + public readonly string|null $name = null, + public readonly array|null $columns = null, + public readonly array|null $fields = null, + public readonly array|null $options = null, ) { - $this->name = $name; - $this->columns = $columns; - $this->fields = $fields; - $this->options = $options; } } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 00e90de8308..9ef47050196 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -626,17 +626,6 @@ isset($xmlRoot->{'unique-constraints'}) - - - $value - - - - - $inverseJoinColumns - $joinColumns - - $className From 59b7fa2ebc4cd9ca90927f0b7b33524660f3c40c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 24 Oct 2022 23:36:08 +0200 Subject: [PATCH 173/475] Fix build --- lib/Doctrine/ORM/EntityManager.php | 7 ++++++- phpstan-dbal4.neon | 18 ++++++++++++++++++ psalm.xml | 10 ++++++++++ .../Tests/ORM/Functional/SQLFilterTest.php | 7 +++++-- .../Tests/ORM/Functional/Ticket/GH7869Test.php | 9 +++++++-- .../ORM/Mapping/ClassMetadataFactoryTest.php | 8 +++++++- .../Tests/ORM/PersistentCollectionTest.php | 8 ++++++-- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 8 ++++++-- .../Command/SchemaTool/UpdateCommandTest.php | 7 +++++++ .../Command/ValidateSchemaCommandTest.php | 7 +++++++ tests/Doctrine/Tests/OrmFunctionalTestCase.php | 16 +++++++++++----- 11 files changed, 90 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 5229c42bb98..2bf96adacdf 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -35,6 +35,7 @@ use function is_array; use function is_object; use function ltrim; +use function method_exists; /** * The EntityManager is the central access point to ORM functionality. @@ -132,7 +133,11 @@ public function __construct(Connection $conn, Configuration $config, EventManage $this->conn = $conn; $this->config = $config; - $this->eventManager = $eventManager ?? $conn->getEventManager(); + $this->eventManager = $eventManager + ?? (method_exists($conn, 'getEventManager') + ? $conn->getEventManager() + : new EventManager() + ); $metadataFactoryClassName = $config->getClassMetadataFactoryName(); diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon index fa8291b8612..7184d49b038 100644 --- a/phpstan-dbal4.neon +++ b/phpstan-dbal4.neon @@ -22,3 +22,21 @@ parameters: - message: '~Strict comparison using \=\=\= between callable\(\)\: mixed and null will always evaluate to false\.~' path: lib/Doctrine/ORM/Tools/SchemaTool.php + + # FIXME + - + message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Connection\\:\\:getEventManager\\(\\)\\.$#" + count: 1 + path: lib/Doctrine/ORM/EntityManager.php + - + message: "#^Static method Doctrine\\\\DBAL\\\\DriverManager\\:\\:getConnection\\(\\) invoked with 3 parameters, 1\\-2 required\\.$#" + count: 1 + path: lib/Doctrine/ORM/EntityManager.php + - + message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Schema\\\\SchemaDiff\\:\\:toSaveSql\\(\\)\\.$#" + count: 1 + path: lib/Doctrine/ORM/Tools/SchemaTool.php + - + message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Schema\\\\SchemaDiff\\:\\:toSql\\(\\)\\.$#" + count: 1 + path: lib/Doctrine/ORM/Tools/SchemaTool.php diff --git a/psalm.xml b/psalm.xml index 677db491384..709b8b65ce2 100644 --- a/psalm.xml +++ b/psalm.xml @@ -112,6 +112,9 @@ + + + @@ -145,6 +148,13 @@ + + + + + + + diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 186e98cf8c3..bb8f8919f3a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -33,6 +33,7 @@ use function count; use function in_array; +use function method_exists; use function serialize; /** @@ -205,8 +206,10 @@ private function configureFilters(EntityManagerInterface $em): void private function getMockConnection(): Connection&MockObject { $connection = $this->createMock(Connection::class); - $connection->method('getEventManager') - ->willReturn(new EventManager()); + if (method_exists($connection, 'getEventManager')) { + $connection->method('getEventManager') + ->willReturn(new EventManager()); + } return $connection; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php index 11a5eec69e2..e2eec45b590 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php @@ -18,6 +18,8 @@ use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\OrmTestCase; +use function method_exists; + /** @group GH7869 */ class GH7869Test extends OrmTestCase { @@ -30,8 +32,11 @@ public function testDQLDeferredEagerLoad(): void $connection = $this->createMock(Connection::class); $connection->method('getDatabasePlatform') ->willReturn($platform); - $connection->method('getEventManager') - ->willReturn(new EventManager()); + + if (method_exists($connection, 'getEventManager')) { + $connection->method('getEventManager') + ->willReturn(new EventManager()); + } $em = new class (new EntityManagerMock($connection)) extends EntityManagerDecorator { /** @var int */ diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index b5089b31dc0..bd756345399 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -49,6 +49,7 @@ use function array_search; use function assert; use function count; +use function method_exists; use function sprintf; class ClassMetadataFactoryTest extends OrmTestCase @@ -211,7 +212,12 @@ public function testGetAllMetadataWorksWithBadConnection(): void { // DDC-3551 $conn = $this->createMock(Connection::class); - $conn->method('getEventManager')->willReturn($this->createMock(EventManager::class)); + + if (method_exists($conn, 'getEventManager')) { + $conn->method('getEventManager') + ->willReturn(new EventManager()); + } + $mockDriver = new MetadataDriverMock(); $em = $this->createEntityManager($mockDriver, $conn); diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index bd4ad9d1d08..a99aa7f3b57 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -45,8 +45,12 @@ protected function setUp(): void $connection = $this->createMock(Connection::class); $connection->method('getDatabasePlatform') ->willReturn($platform); - $connection->method('getEventManager') - ->willReturn(new EventManager()); + + if (method_exists($connection, 'getEventManager')) { + $connection->method('getEventManager') + ->willReturn(new EventManager()); + } + $connection->method('executeQuery') ->willReturn($this->createMock(Result::class)); diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index 50e5d070efa..57eb93cc198 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -24,6 +24,7 @@ use stdClass; use function assert; +use function method_exists; use function sys_get_temp_dir; /** @@ -46,8 +47,11 @@ protected function setUp(): void $connection = $this->createMock(Connection::class); $connection->method('getDatabasePlatform') ->willReturn($platform); - $connection->method('getEventManager') - ->willReturn(new EventManager()); + + if (method_exists($connection, 'getEventManager')) { + $connection->method('getEventManager') + ->willReturn(new EventManager()); + } $this->emMock = new EntityManagerMock($connection); $this->uowMock = new UnitOfWorkMock($this->emMock); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php index 88ea2cf1617..d950d4c88cf 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php @@ -4,13 +4,20 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command\SchemaTool; +use Doctrine\DBAL\Schema\SchemaDiff; use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand; +use function method_exists; + class UpdateCommandTest extends AbstractCommandTest { /** @doesNotPerformAssertions */ public function testItPrintsTheSql(): void { + if (! method_exists(SchemaDiff::class, 'toSaveSql')) { + self::markTestSkipped('FIXME for DBAL 4.'); + } + $tester = $this->getCommandTester(UpdateCommand::class); $tester->execute( ['--dump-sql' => true], diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php index 5e70fa425af..2385e071c07 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command; use Doctrine\DBAL\Platforms\SQLitePlatform; +use Doctrine\DBAL\Schema\SchemaDiff; use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\OrmFunctionalTestCase; @@ -12,6 +13,8 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; +use function method_exists; + /** * Tests for {@see \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand} * @@ -31,6 +34,10 @@ protected function setUp(): void self::markTestSkipped('Only with sqlite'); } + if (! method_exists(SchemaDiff::class, 'toSaveSql')) { + self::markTestSkipped('FIXME for DBAL 4.'); + } + $application = new Application(); $application->add(new ValidateSchemaCommand(new SingleManagerProvider($this->_em))); diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index e8817d1827a..21569ef2918 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests; +use Doctrine\Common\EventManager; use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; @@ -185,6 +186,7 @@ use function getenv; use function implode; use function is_object; +use function method_exists; use function realpath; use function sprintf; use function str_contains; @@ -944,11 +946,15 @@ protected function getEntityManager( $conn->queryLog->reset(); // get rid of more global state - $evm = $conn->getEventManager(); - foreach ($evm->getAllListeners() as $event => $listeners) { - foreach ($listeners as $listener) { - $evm->removeEventListener([$event], $listener); + if (method_exists($conn, 'getEventManager')) { + $evm = $conn->getEventManager(); + foreach ($evm->getAllListeners() as $event => $listeners) { + foreach ($listeners as $listener) { + $evm->removeEventListener([$event], $listener); + } } + } else { + $evm = new EventManager(); } if ($enableSecondLevelCache) { @@ -966,7 +972,7 @@ protected function getEntityManager( $evm->addEventListener(['onFlush'], new DebugUnitOfWorkListener()); } - return new EntityManager($conn, $config); + return new EntityManager($conn, $config, $evm); } final protected function createSchemaManager(): AbstractSchemaManager From adceff29f157be6353073d880c8fae4c60e4572b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 25 Oct 2022 16:59:19 +0200 Subject: [PATCH 174/475] Remove EntityManager::create() (#10172) --- UPGRADE.md | 7 ++ lib/Doctrine/ORM/EntityManager.php | 64 ------------------- .../ORM/Exception/MismatchedEventManager.php | 17 ----- phpstan-dbal4.neon | 8 --- psalm.xml | 7 +- .../Tests/Mocks/EntityManagerMock.php | 11 ---- 6 files changed, 11 insertions(+), 103 deletions(-) delete mode 100644 lib/Doctrine/ORM/Exception/MismatchedEventManager.php diff --git a/UPGRADE.md b/UPGRADE.md index 269f62ddc58..d99225bee67 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,12 @@ # Upgrade to 3.0 +## BC BREAK: Removed `EntityManager::create()` + +The constructor of `EntityManager` is now public and must be used instead of the `create()` method. +However, the constructor expects a `Connection` while `create()` accepted an array with connection parameters. +You can pass that array to DBAL's `Doctrine\DBAL\DriverManager::getConnection()` method to bootstrap the +connection. + ## BC BREAK: Removed `QueryBuilder` methods and constants. The following `QueryBuilder` constants and methods have been removed: diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 2bf96adacdf..32d7891f810 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -8,14 +8,9 @@ use Doctrine\Common\EventManager; use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Exception\InvalidHydrationMode; -use Doctrine\ORM\Exception\ManagerException; -use Doctrine\ORM\Exception\MismatchedEventManager; use Doctrine\ORM\Exception\MissingIdentifierField; use Doctrine\ORM\Exception\MissingMappingDriverImplementation; use Doctrine\ORM\Exception\ORMException; @@ -638,65 +633,6 @@ public function initializeObject(object $obj): void $this->unitOfWork->initializeObject($obj); } - /** - * Factory method to create EntityManager instances. - * - * @deprecated Use {@see DriverManager::getConnection()} to bootstrap the connection and call the constructor. - * - * @param mixed[]|Connection $connection An array with the connection parameters or an existing Connection instance. - * @psalm-param array|Connection $connection - * - * @throws DBALException - * @throws ManagerException - */ - public static function create(array|Connection $connection, Configuration $config, EventManager|null $eventManager = null): EntityManager - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9961', - '%s() is deprecated. To boostrap a DBAL connection, call %s::getConnection() instead. Use the constructor to create an instance of %s.', - __METHOD__, - DriverManager::class, - self::class, - ); - - $connection = static::createConnection($connection, $config, $eventManager); - - return new EntityManager($connection, $config); - } - - /** - * Factory method to create Connection instances. - * - * @deprecated Use {@see DriverManager::getConnection()} to bootstrap the connection. - * - * @param mixed[]|Connection $connection An array with the connection parameters or an existing Connection instance. - * @psalm-param array|Connection $connection - * - * @throws DBALException - * @throws ManagerException - */ - protected static function createConnection(array|Connection $connection, Configuration $config, EventManager|null $eventManager = null): Connection - { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9961', - '%s() is deprecated, call %s::getConnection() instead.', - __METHOD__, - DriverManager::class, - ); - - if (is_array($connection)) { - return DriverManager::getConnection($connection, $config, $eventManager ?? new EventManager()); - } - - if ($eventManager !== null && $connection->getEventManager() !== $eventManager) { - throw MismatchedEventManager::create(); - } - - return $connection; - } - public function getFilters(): FilterCollection { return $this->filterCollection ??= new FilterCollection($this); diff --git a/lib/Doctrine/ORM/Exception/MismatchedEventManager.php b/lib/Doctrine/ORM/Exception/MismatchedEventManager.php deleted file mode 100644 index c30578546e3..00000000000 --- a/lib/Doctrine/ORM/Exception/MismatchedEventManager.php +++ /dev/null @@ -1,17 +0,0 @@ - - + + - @@ -150,8 +150,9 @@ - + + diff --git a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php index cfeb23a3cef..752d32a2d56 100644 --- a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Mocks; -use BadMethodCallException; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\ORM\Configuration; @@ -13,8 +12,6 @@ use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\UnitOfWork; -use function sprintf; - /** * Special EntityManager mock used for testing purposes. */ @@ -59,12 +56,4 @@ public function getProxyFactory(): ProxyFactory { return $this->_proxyFactoryMock ?? parent::getProxyFactory(); } - - /** - * {@inheritdoc} - */ - public static function create($connection, Configuration|null $config, EventManager|null $eventManager = null): self - { - throw new BadMethodCallException(sprintf('Call to deprecated method %s().', __METHOD__)); - } } From 9c7f57556986031f2378dd3885f7bf36d8e0f07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 5 Oct 2022 18:44:34 +0200 Subject: [PATCH 175/475] Switch to attribute driver --- docs/en/reference/advanced-configuration.rst | 2 +- .../Performance/EntityManagerFactory.php | 5 ++-- .../Tests/Mocks/EntityManagerMock.php | 3 +- .../Functional/Locking/LockAgentWorker.php | 2 +- tests/Doctrine/Tests/ORM/ORMSetupTest.php | 29 ++----------------- .../SchemaTool/AbstractCommandTest.php | 3 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 3 +- tests/Doctrine/Tests/OrmTestCase.php | 10 +++---- 8 files changed, 17 insertions(+), 40 deletions(-) diff --git a/docs/en/reference/advanced-configuration.rst b/docs/en/reference/advanced-configuration.rst index d2e2d281763..ea50160e1a3 100644 --- a/docs/en/reference/advanced-configuration.rst +++ b/docs/en/reference/advanced-configuration.rst @@ -132,7 +132,7 @@ The attribute driver can be injected in the ``Doctrine\ORM\Configuration``: .. code-block:: php setMetadataDriverImpl($driverImpl); diff --git a/tests/Doctrine/Performance/EntityManagerFactory.php b/tests/Doctrine/Performance/EntityManagerFactory.php index 62710b6573f..716d69f2fe7 100644 --- a/tests/Doctrine/Performance/EntityManagerFactory.php +++ b/tests/Doctrine/Performance/EntityManagerFactory.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Tools\SchemaTool; @@ -30,7 +31,7 @@ public static function getEntityManager(array $schemaClassNames): EntityManagerI $config->setProxyDir(__DIR__ . '/../Tests/Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); $config->setAutoGenerateProxyClasses(ProxyFactory::AUTOGENERATE_EVAL); - $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([ + $config->setMetadataDriverImpl(new AttributeDriver([ realpath(__DIR__ . '/Models/Cache'), realpath(__DIR__ . '/Models/GeoNames'), ])); @@ -56,7 +57,7 @@ public static function makeEntityManagerWithNoResultsConnection(): EntityManager $config->setProxyDir(__DIR__ . '/../Tests/Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); $config->setAutoGenerateProxyClasses(ProxyFactory::AUTOGENERATE_EVAL); - $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([ + $config->setMetadataDriverImpl(new AttributeDriver([ realpath(__DIR__ . '/Models/Cache'), realpath(__DIR__ . '/Models/Generic'), realpath(__DIR__ . '/Models/GeoNames'), diff --git a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php index 752d32a2d56..6a5b654efe0 100644 --- a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Connection; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\UnitOfWork; @@ -26,7 +27,7 @@ public function __construct(Connection $conn, Configuration|null $config = null, $config = new Configuration(); $config->setProxyDir(__DIR__ . '/../Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver()); + $config->setMetadataDriverImpl(new AttributeDriver([])); } parent::__construct($conn, $config, $eventManager); diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php index fc277a11aeb..b95de6c2e33 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php @@ -117,7 +117,7 @@ protected function createEntityManager(Connection $conn): EntityManagerInterface $config->setProxyNamespace('MyProject\Proxies'); $config->setAutoGenerateProxyClasses(true); - $annotDriver = ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../../Models/']); + $annotDriver = new AttributeDriver([__DIR__ . '/../../../Models/']); $config->setMetadataDriverImpl($annotDriver); $config->setMetadataCache(new ArrayAdapter()); diff --git a/tests/Doctrine/Tests/ORM/ORMSetupTest.php b/tests/Doctrine/Tests/ORM/ORMSetupTest.php index 0a246f46de6..4785107e22a 100644 --- a/tests/Doctrine/Tests/ORM/ORMSetupTest.php +++ b/tests/Doctrine/Tests/ORM/ORMSetupTest.php @@ -6,7 +6,6 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping as AnnotationNamespace; -use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\ORMSetup; @@ -21,30 +20,6 @@ class ORMSetupTest extends TestCase { - public function testAnnotationConfiguration(): void - { - $config = ORMSetup::createAnnotationMetadataConfiguration([], true); - - self::assertInstanceOf(Configuration::class, $config); - self::assertEquals(sys_get_temp_dir(), $config->getProxyDir()); - self::assertEquals('DoctrineProxies', $config->getProxyNamespace()); - self::assertInstanceOf(AnnotationDriver::class, $config->getMetadataDriverImpl()); - } - - public function testNewDefaultAnnotationDriver(): void - { - $paths = [__DIR__]; - $reflectionClass = new ReflectionClass(AnnotatedDummy::class); - - $annotationDriver = ORMSetup::createDefaultAnnotationDriver($paths); - $reader = $annotationDriver->getReader(); - $annotation = $reader->getMethodAnnotation( - $reflectionClass->getMethod('namespacedAnnotationMethod'), - AnnotationNamespace\PrePersist::class, - ); - self::assertInstanceOf(AnnotationNamespace\PrePersist::class, $annotation); - } - public function testAttributeConfiguration(): void { $config = ORMSetup::createAttributeMetadataConfiguration([], true); @@ -79,7 +54,7 @@ public function testCacheNamespaceShouldBeGeneratedForApcu(): void /** @group DDC-1350 */ public function testConfigureProxyDir(): void { - $config = ORMSetup::createAnnotationMetadataConfiguration([], true, '/foo'); + $config = ORMSetup::createAttributeMetadataConfiguration([], true, '/foo'); self::assertEquals('/foo', $config->getProxyDir()); } @@ -87,7 +62,7 @@ public function testConfigureProxyDir(): void public function testConfigureCache(): void { $cache = new ArrayAdapter(); - $config = ORMSetup::createAnnotationMetadataConfiguration([], true, null, $cache); + $config = ORMSetup::createAttributeMetadataConfiguration([], true, null, $cache); self::assertSame($cache, $config->getResultCache()); self::assertSame($cache, $config->getQueryCache()); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php index 6973e62a1e4..8fda1e084bb 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command\SchemaTool; use Doctrine\DBAL\Platforms\SQLitePlatform; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; @@ -16,7 +17,7 @@ abstract class AbstractCommandTest extends OrmFunctionalTestCase /** @param class-string $commandClass */ protected function getCommandTester(string $commandClass): CommandTester { - $entityManager = $this->getEntityManager(null, ORMSetup::createDefaultAnnotationDriver([ + $entityManager = $this->getEntityManager(null, new AttributeDriver([ __DIR__ . '/Models', ])); diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 21569ef2918..dec3b09ab74 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -21,6 +21,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\DebugUnitOfWorkListener; use Doctrine\ORM\Tools\SchemaTool; @@ -935,7 +936,7 @@ protected function getEntityManager( } $config->setMetadataDriverImpl( - $mappingDriver ?? ORMSetup::createDefaultAnnotationDriver([ + $mappingDriver ?? new AttributeDriver([ realpath(__DIR__ . '/Models/Cache'), realpath(__DIR__ . '/Models/GeoNames'), ]), diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 7cb9de1aefb..e8c6409e647 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -18,6 +18,7 @@ use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger; use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\ORMSetup; use Doctrine\Tests\Mocks\EntityManagerMock; use Psr\Cache\CacheItemPoolInterface; @@ -56,12 +57,9 @@ abstract class OrmTestCase extends DoctrineTestCase private CacheItemPoolInterface|null $secondLevelCache = null; - protected function createAnnotationDriver(array $paths = []): AnnotationDriver + protected function createAnnotationDriver(array $paths = []): AttributeDriver { - return new AnnotationDriver( - new PsrCachedReader(new AnnotationReader(), new ArrayAdapter()), - $paths, - ); + return new AttributeDriver($paths); } /** @@ -101,7 +99,7 @@ private function buildTestEntityManagerWithPlatform(Connection $connection): Ent $config->setQueryCache(self::getSharedQueryCache()); $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); - $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([ + $config->setMetadataDriverImpl(new AttributeDriver([ realpath(__DIR__ . '/Models/Cache'), ])); From f8587c4ed72e162172ead634921719b237c923f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 5 Oct 2022 21:12:55 +0200 Subject: [PATCH 176/475] Remove annotation driver --- .../ORM/Mapping/Driver/AnnotationDriver.php | 806 ------------------ lib/Doctrine/ORM/ORMSetup.php | 69 -- phpstan-baseline.neon | 30 - psalm-baseline.xml | 30 - .../ORM/Mapping/AnnotationDriverTest.php | 496 ----------- 5 files changed, 1431 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php deleted file mode 100644 index 01086c818dc..00000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ /dev/null @@ -1,806 +0,0 @@ - - */ - protected $entityAnnotationClasses = [ - Mapping\Entity::class => 1, - Mapping\MappedSuperclass::class => 2, - ]; - - /** - * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading - * docblock annotations. - * - * @param Reader $reader The AnnotationReader to use - * @param string|string[]|null $paths One or multiple paths where mapping classes can be found. - */ - public function __construct($reader, $paths = null) - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/10098', - 'The annotation mapping driver is deprecated and will be removed in Doctrine ORM 3.0, please migrate to the attribute or XML driver.', - ); - $this->reader = $reader; - - $this->addPaths((array) $paths); - } - - /** - * {@inheritDoc} - * - * @psalm-param class-string $className - * @psalm-param ClassMetadata $metadata - * - * @template T of object - */ - public function loadMetadataForClass($className, PersistenceClassMetadata $metadata) - { - $class = $metadata->getReflectionClass() - // this happens when running annotation driver in combination with - // static reflection services. This is not the nicest fix - ?? new ReflectionClass($metadata->name); - - $classAnnotations = $this->reader->getClassAnnotations($class); - foreach ($classAnnotations as $key => $annot) { - if (! is_numeric($key)) { - continue; - } - - unset($classAnnotations[$key]); - $classAnnotations[get_class($annot)] = $annot; - } - - // Evaluate Entity annotation - if (isset($classAnnotations[Mapping\Entity::class])) { - $entityAnnot = $classAnnotations[Mapping\Entity::class]; - assert($entityAnnot instanceof Mapping\Entity); - if ($entityAnnot->repositoryClass !== null) { - $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass); - } - - if ($entityAnnot->readOnly) { - $metadata->markReadOnly(); - } - } elseif (isset($classAnnotations[Mapping\MappedSuperclass::class])) { - $mappedSuperclassAnnot = $classAnnotations[Mapping\MappedSuperclass::class]; - assert($mappedSuperclassAnnot instanceof Mapping\MappedSuperclass); - - $metadata->setCustomRepositoryClass($mappedSuperclassAnnot->repositoryClass); - $metadata->isMappedSuperclass = true; - } elseif (isset($classAnnotations[Mapping\Embeddable::class])) { - $metadata->isEmbeddedClass = true; - } else { - throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className); - } - - // Evaluate Table annotation - if (isset($classAnnotations[Mapping\Table::class])) { - $tableAnnot = $classAnnotations[Mapping\Table::class]; - assert($tableAnnot instanceof Mapping\Table); - $primaryTable = [ - 'name' => $tableAnnot->name, - 'schema' => $tableAnnot->schema, - ]; - - foreach ($tableAnnot->indexes ?? [] as $indexAnnot) { - $index = []; - - if (! empty($indexAnnot->columns)) { - $index['columns'] = $indexAnnot->columns; - } - - if (! empty($indexAnnot->fields)) { - $index['fields'] = $indexAnnot->fields; - } - - if ( - isset($index['columns'], $index['fields']) - || ( - ! isset($index['columns']) - && ! isset($index['fields']) - ) - ) { - throw MappingException::invalidIndexConfiguration( - $className, - (string) ($indexAnnot->name ?? count($primaryTable['indexes'])), - ); - } - - if (! empty($indexAnnot->flags)) { - $index['flags'] = $indexAnnot->flags; - } - - if (! empty($indexAnnot->options)) { - $index['options'] = $indexAnnot->options; - } - - if (! empty($indexAnnot->name)) { - $primaryTable['indexes'][$indexAnnot->name] = $index; - } else { - $primaryTable['indexes'][] = $index; - } - } - - foreach ($tableAnnot->uniqueConstraints ?? [] as $uniqueConstraintAnnot) { - $uniqueConstraint = []; - - if (! empty($uniqueConstraintAnnot->columns)) { - $uniqueConstraint['columns'] = $uniqueConstraintAnnot->columns; - } - - if (! empty($uniqueConstraintAnnot->fields)) { - $uniqueConstraint['fields'] = $uniqueConstraintAnnot->fields; - } - - if ( - isset($uniqueConstraint['columns'], $uniqueConstraint['fields']) - || ( - ! isset($uniqueConstraint['columns']) - && ! isset($uniqueConstraint['fields']) - ) - ) { - throw MappingException::invalidUniqueConstraintConfiguration( - $className, - (string) ($uniqueConstraintAnnot->name ?? count($primaryTable['uniqueConstraints'])), - ); - } - - if (! empty($uniqueConstraintAnnot->options)) { - $uniqueConstraint['options'] = $uniqueConstraintAnnot->options; - } - - if (! empty($uniqueConstraintAnnot->name)) { - $primaryTable['uniqueConstraints'][$uniqueConstraintAnnot->name] = $uniqueConstraint; - } else { - $primaryTable['uniqueConstraints'][] = $uniqueConstraint; - } - } - - if ($tableAnnot->options) { - $primaryTable['options'] = $tableAnnot->options; - } - - $metadata->setPrimaryTable($primaryTable); - } - - // Evaluate @Cache annotation - if (isset($classAnnotations[Mapping\Cache::class])) { - $cacheAnnot = $classAnnotations[Mapping\Cache::class]; - $cacheMap = [ - 'region' => $cacheAnnot->region, - 'usage' => (int) constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), - ]; - - $metadata->enableCache($cacheMap); - } - - // Evaluate InheritanceType annotation - if (isset($classAnnotations[Mapping\InheritanceType::class])) { - $inheritanceTypeAnnot = $classAnnotations[Mapping\InheritanceType::class]; - assert($inheritanceTypeAnnot instanceof Mapping\InheritanceType); - - $metadata->setInheritanceType( - constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value), - ); - - if ($metadata->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { - // Evaluate DiscriminatorColumn annotation - if (isset($classAnnotations[Mapping\DiscriminatorColumn::class])) { - $discrColumnAnnot = $classAnnotations[Mapping\DiscriminatorColumn::class]; - assert($discrColumnAnnot instanceof Mapping\DiscriminatorColumn); - - $metadata->setDiscriminatorColumn( - [ - 'name' => $discrColumnAnnot->name, - 'type' => $discrColumnAnnot->type ?: 'string', - 'length' => $discrColumnAnnot->length ?? 255, - 'columnDefinition' => $discrColumnAnnot->columnDefinition, - ], - ); - } else { - $metadata->setDiscriminatorColumn(['name' => 'dtype', 'type' => 'string', 'length' => 255]); - } - - // Evaluate DiscriminatorMap annotation - if (isset($classAnnotations[Mapping\DiscriminatorMap::class])) { - $discrMapAnnot = $classAnnotations[Mapping\DiscriminatorMap::class]; - assert($discrMapAnnot instanceof Mapping\DiscriminatorMap); - $metadata->setDiscriminatorMap($discrMapAnnot->value); - } - } - } - - // Evaluate DoctrineChangeTrackingPolicy annotation - if (isset($classAnnotations[Mapping\ChangeTrackingPolicy::class])) { - $changeTrackingAnnot = $classAnnotations[Mapping\ChangeTrackingPolicy::class]; - assert($changeTrackingAnnot instanceof Mapping\ChangeTrackingPolicy); - $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value)); - } - - // Evaluate annotations on properties/fields - foreach ($class->getProperties() as $property) { - if ( - $metadata->isMappedSuperclass && ! $property->isPrivate() - || - $metadata->isInheritedField($property->name) - || - $metadata->isInheritedAssociation($property->name) - || - $metadata->isInheritedEmbeddedClass($property->name) - ) { - continue; - } - - $mapping = []; - $mapping['fieldName'] = $property->getName(); - - // Evaluate @Cache annotation - $cacheAnnot = $this->reader->getPropertyAnnotation($property, Mapping\Cache::class); - if ($cacheAnnot !== null) { - $mapping['cache'] = $metadata->getAssociationCacheDefaults( - $mapping['fieldName'], - [ - 'usage' => (int) constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnot->usage), - 'region' => $cacheAnnot->region, - ], - ); - } - - // Check for JoinColumn/JoinColumns annotations - $joinColumns = []; - - $joinColumnAnnot = $this->reader->getPropertyAnnotation($property, Mapping\JoinColumn::class); - if ($joinColumnAnnot) { - $joinColumns[] = $this->joinColumnToArray($joinColumnAnnot); - } else { - $joinColumnsAnnot = $this->reader->getPropertyAnnotation($property, Mapping\JoinColumns::class); - if ($joinColumnsAnnot) { - foreach ($joinColumnsAnnot->value as $joinColumn) { - $joinColumns[] = $this->joinColumnToArray($joinColumn); - } - } - } - - // Field can only be annotated with one of: - // @Column, @OneToOne, @OneToMany, @ManyToOne, @ManyToMany - $columnAnnot = $this->reader->getPropertyAnnotation($property, Mapping\Column::class); - if ($columnAnnot) { - $mapping = $this->columnToArray($property->getName(), $columnAnnot); - - $idAnnot = $this->reader->getPropertyAnnotation($property, Mapping\Id::class); - if ($idAnnot) { - $mapping['id'] = true; - } - - $generatedValueAnnot = $this->reader->getPropertyAnnotation($property, Mapping\GeneratedValue::class); - if ($generatedValueAnnot) { - $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy)); - } - - if ($this->reader->getPropertyAnnotation($property, Mapping\Version::class)) { - $metadata->setVersionMapping($mapping); - } - - $metadata->mapField($mapping); - - // Check for SequenceGenerator/TableGenerator definition - $seqGeneratorAnnot = $this->reader->getPropertyAnnotation($property, Mapping\SequenceGenerator::class); - if ($seqGeneratorAnnot) { - $metadata->setSequenceGeneratorDefinition( - [ - 'sequenceName' => $seqGeneratorAnnot->sequenceName, - 'allocationSize' => $seqGeneratorAnnot->allocationSize, - 'initialValue' => $seqGeneratorAnnot->initialValue, - ], - ); - } else { - $customGeneratorAnnot = $this->reader->getPropertyAnnotation($property, Mapping\CustomIdGenerator::class); - if ($customGeneratorAnnot) { - $metadata->setCustomGeneratorDefinition( - [ - 'class' => $customGeneratorAnnot->class, - ], - ); - } - } - } else { - $this->loadRelationShipMapping( - $property, - $mapping, - $metadata, - $joinColumns, - $className, - ); - } - } - - // Evaluate AssociationOverrides annotation - if (isset($classAnnotations[Mapping\AssociationOverrides::class])) { - $associationOverridesAnnot = $classAnnotations[Mapping\AssociationOverrides::class]; - assert($associationOverridesAnnot instanceof Mapping\AssociationOverrides); - - foreach ($associationOverridesAnnot->overrides as $associationOverride) { - $override = []; - $fieldName = $associationOverride->name; - - // Check for JoinColumn/JoinColumns annotations - if ($associationOverride->joinColumns) { - $joinColumns = []; - - foreach ($associationOverride->joinColumns as $joinColumn) { - $joinColumns[] = $this->joinColumnToArray($joinColumn); - } - - $override['joinColumns'] = $joinColumns; - } - - // Check for JoinTable annotations - if ($associationOverride->joinTable) { - $joinTableAnnot = $associationOverride->joinTable; - $joinTable = [ - 'name' => $joinTableAnnot->name, - 'schema' => $joinTableAnnot->schema, - ]; - - foreach ($joinTableAnnot->joinColumns as $joinColumn) { - $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn); - } - - foreach ($joinTableAnnot->inverseJoinColumns as $joinColumn) { - $joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumn); - } - - $override['joinTable'] = $joinTable; - } - - // Check for inversedBy - if ($associationOverride->inversedBy) { - $override['inversedBy'] = $associationOverride->inversedBy; - } - - // Check for `fetch` - if ($associationOverride->fetch) { - $override['fetch'] = constant(Mapping\ClassMetadata::class . '::FETCH_' . $associationOverride->fetch); - } - - $metadata->setAssociationOverride($fieldName, $override); - } - } - - // Evaluate AttributeOverrides annotation - if (isset($classAnnotations[Mapping\AttributeOverrides::class])) { - $attributeOverridesAnnot = $classAnnotations[Mapping\AttributeOverrides::class]; - assert($attributeOverridesAnnot instanceof Mapping\AttributeOverrides); - - foreach ($attributeOverridesAnnot->overrides as $attributeOverrideAnnot) { - $attributeOverride = $this->columnToArray($attributeOverrideAnnot->name, $attributeOverrideAnnot->column); - - $metadata->setAttributeOverride($attributeOverrideAnnot->name, $attributeOverride); - } - } - - // Evaluate EntityListeners annotation - if (isset($classAnnotations[Mapping\EntityListeners::class])) { - $entityListenersAnnot = $classAnnotations[Mapping\EntityListeners::class]; - assert($entityListenersAnnot instanceof Mapping\EntityListeners); - - foreach ($entityListenersAnnot->value as $item) { - $listenerClassName = $metadata->fullyQualifiedClassName($item); - - if (! class_exists($listenerClassName)) { - throw MappingException::entityListenerClassNotFound($listenerClassName, $className); - } - - $hasMapping = false; - $listenerClass = new ReflectionClass($listenerClassName); - - foreach ($listenerClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { - // find method callbacks. - $callbacks = $this->getMethodCallbacks($method); - $hasMapping = $hasMapping ?: ! empty($callbacks); - - foreach ($callbacks as $value) { - $metadata->addEntityListener($value[1], $listenerClassName, $value[0]); - } - } - - // Evaluate the listener using naming convention. - if (! $hasMapping) { - EntityListenerBuilder::bindEntityListener($metadata, $listenerClassName); - } - } - } - - // Evaluate @HasLifecycleCallbacks annotation - if (isset($classAnnotations[Mapping\HasLifecycleCallbacks::class])) { - foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { - foreach ($this->getMethodCallbacks($method) as $value) { - $metadata->addLifecycleCallback($value[0], $value[1]); - } - } - } - } - - /** - * @param mixed[] $joinColumns - * @psalm-param array $mapping - */ - private function loadRelationShipMapping( - ReflectionProperty $property, - array &$mapping, - PersistenceClassMetadata $metadata, - array $joinColumns, - string $className, - ): void { - $oneToOneAnnot = $this->reader->getPropertyAnnotation($property, Mapping\OneToOne::class); - if ($oneToOneAnnot) { - $idAnnot = $this->reader->getPropertyAnnotation($property, Mapping\Id::class); - if ($idAnnot) { - $mapping['id'] = true; - } - - $mapping['targetEntity'] = $oneToOneAnnot->targetEntity; - $mapping['joinColumns'] = $joinColumns; - $mapping['mappedBy'] = $oneToOneAnnot->mappedBy; - $mapping['inversedBy'] = $oneToOneAnnot->inversedBy; - $mapping['cascade'] = $oneToOneAnnot->cascade; - $mapping['orphanRemoval'] = $oneToOneAnnot->orphanRemoval; - $mapping['fetch'] = $this->getFetchMode($className, $oneToOneAnnot->fetch); - $metadata->mapOneToOne($mapping); - - return; - } - - $oneToManyAnnot = $this->reader->getPropertyAnnotation($property, Mapping\OneToMany::class); - if ($oneToManyAnnot) { - $mapping['mappedBy'] = $oneToManyAnnot->mappedBy; - $mapping['targetEntity'] = $oneToManyAnnot->targetEntity; - $mapping['cascade'] = $oneToManyAnnot->cascade; - $mapping['indexBy'] = $oneToManyAnnot->indexBy; - $mapping['orphanRemoval'] = $oneToManyAnnot->orphanRemoval; - $mapping['fetch'] = $this->getFetchMode($className, $oneToManyAnnot->fetch); - - $orderByAnnot = $this->reader->getPropertyAnnotation($property, Mapping\OrderBy::class); - if ($orderByAnnot) { - $mapping['orderBy'] = $orderByAnnot->value; - } - - $metadata->mapOneToMany($mapping); - } - - $manyToOneAnnot = $this->reader->getPropertyAnnotation($property, Mapping\ManyToOne::class); - if ($manyToOneAnnot) { - $idAnnot = $this->reader->getPropertyAnnotation($property, Mapping\Id::class); - if ($idAnnot) { - $mapping['id'] = true; - } - - $mapping['joinColumns'] = $joinColumns; - $mapping['cascade'] = $manyToOneAnnot->cascade; - $mapping['inversedBy'] = $manyToOneAnnot->inversedBy; - $mapping['targetEntity'] = $manyToOneAnnot->targetEntity; - $mapping['fetch'] = $this->getFetchMode($className, $manyToOneAnnot->fetch); - $metadata->mapManyToOne($mapping); - } - - $manyToManyAnnot = $this->reader->getPropertyAnnotation($property, Mapping\ManyToMany::class); - if ($manyToManyAnnot) { - $joinTable = []; - - $joinTableAnnot = $this->reader->getPropertyAnnotation($property, Mapping\JoinTable::class); - if ($joinTableAnnot) { - $joinTable = [ - 'name' => $joinTableAnnot->name, - 'schema' => $joinTableAnnot->schema, - ]; - - if ($joinTableAnnot->options) { - $joinTable['options'] = $joinTableAnnot->options; - } - - foreach ($joinTableAnnot->joinColumns as $joinColumn) { - $joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn); - } - - foreach ($joinTableAnnot->inverseJoinColumns as $joinColumn) { - $joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumn); - } - } - - $mapping['joinTable'] = $joinTable; - $mapping['targetEntity'] = $manyToManyAnnot->targetEntity; - $mapping['mappedBy'] = $manyToManyAnnot->mappedBy; - $mapping['inversedBy'] = $manyToManyAnnot->inversedBy; - $mapping['cascade'] = $manyToManyAnnot->cascade; - $mapping['indexBy'] = $manyToManyAnnot->indexBy; - $mapping['orphanRemoval'] = $manyToManyAnnot->orphanRemoval; - $mapping['fetch'] = $this->getFetchMode($className, $manyToManyAnnot->fetch); - - $orderByAnnot = $this->reader->getPropertyAnnotation($property, Mapping\OrderBy::class); - if ($orderByAnnot) { - $mapping['orderBy'] = $orderByAnnot->value; - } - - $metadata->mapManyToMany($mapping); - } - - $embeddedAnnot = $this->reader->getPropertyAnnotation($property, Mapping\Embedded::class); - if ($embeddedAnnot) { - $mapping['class'] = $embeddedAnnot->class; - $mapping['columnPrefix'] = $embeddedAnnot->columnPrefix; - - $metadata->mapEmbedded($mapping); - } - } - - /** - * Attempts to resolve the fetch mode. - * - * @psalm-return ClassMetadata::FETCH_* The fetch mode as defined in ClassMetadata. - * - * @throws MappingException If the fetch mode is not valid. - */ - private function getFetchMode(string $className, string $fetchMode): int - { - if (! defined('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $fetchMode)) { - throw MappingException::invalidFetchMode($className, $fetchMode); - } - - return constant('Doctrine\ORM\Mapping\ClassMetadata::FETCH_' . $fetchMode); - } - - /** - * Attempts to resolve the generated mode. - * - * @psalm-return ClassMetadata::GENERATED_* - * - * @throws MappingException If the fetch mode is not valid. - */ - private function getGeneratedMode(string $generatedMode): int - { - if (! defined('Doctrine\ORM\Mapping\ClassMetadata::GENERATED_' . $generatedMode)) { - throw MappingException::invalidGeneratedMode($generatedMode); - } - - return constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATED_' . $generatedMode); - } - - /** - * Parses the given method. - * - * @return callable[] - * @psalm-return list - */ - private function getMethodCallbacks(ReflectionMethod $method): array - { - $callbacks = []; - $annotations = $this->reader->getMethodAnnotations($method); - - foreach ($annotations as $annot) { - if ($annot instanceof Mapping\PrePersist) { - $callbacks[] = [$method->name, Events::prePersist]; - } - - if ($annot instanceof Mapping\PostPersist) { - $callbacks[] = [$method->name, Events::postPersist]; - } - - if ($annot instanceof Mapping\PreUpdate) { - $callbacks[] = [$method->name, Events::preUpdate]; - } - - if ($annot instanceof Mapping\PostUpdate) { - $callbacks[] = [$method->name, Events::postUpdate]; - } - - if ($annot instanceof Mapping\PreRemove) { - $callbacks[] = [$method->name, Events::preRemove]; - } - - if ($annot instanceof Mapping\PostRemove) { - $callbacks[] = [$method->name, Events::postRemove]; - } - - if ($annot instanceof Mapping\PostLoad) { - $callbacks[] = [$method->name, Events::postLoad]; - } - - if ($annot instanceof Mapping\PreFlush) { - $callbacks[] = [$method->name, Events::preFlush]; - } - } - - return $callbacks; - } - - /** - * Parse the given JoinColumn as array - * - * @return mixed[] - * @psalm-return array{ - * name: string|null, - * unique: bool, - * nullable: bool, - * onDelete: mixed, - * columnDefinition: string|null, - * referencedColumnName: string, - * options?: array - * } - */ - private function joinColumnToArray(Mapping\JoinColumn $joinColumn): array - { - $mapping = [ - 'name' => $joinColumn->name, - 'unique' => $joinColumn->unique, - 'nullable' => $joinColumn->nullable, - 'onDelete' => $joinColumn->onDelete, - 'columnDefinition' => $joinColumn->columnDefinition, - 'referencedColumnName' => $joinColumn->referencedColumnName, - ]; - - if ($joinColumn->options) { - $mapping['options'] = $joinColumn->options; - } - - return $mapping; - } - - /** - * Parse the given Column as array - * - * @return mixed[] - * @psalm-return array{ - * fieldName: string, - * type: mixed, - * scale: int, - * length: int, - * unique: bool, - * nullable: bool, - * precision: int, - * notInsertable?: bool, - * notUpdateble?: bool, - * generated?: ClassMetadata::GENERATED_*, - * enumType?: class-string, - * options?: mixed[], - * columnName?: string, - * columnDefinition?: string - * } - */ - private function columnToArray(string $fieldName, Mapping\Column $column): array - { - $mapping = [ - 'fieldName' => $fieldName, - 'type' => $column->type, - 'scale' => $column->scale, - 'length' => $column->length, - 'unique' => $column->unique, - 'nullable' => $column->nullable, - 'precision' => $column->precision, - ]; - - if (! $column->insertable) { - $mapping['notInsertable'] = true; - } - - if (! $column->updatable) { - $mapping['notUpdatable'] = true; - } - - if ($column->generated) { - $mapping['generated'] = $this->getGeneratedMode($column->generated); - } - - if ($column->options) { - $mapping['options'] = $column->options; - } - - if (isset($column->name)) { - $mapping['columnName'] = $column->name; - } - - if (isset($column->columnDefinition)) { - $mapping['columnDefinition'] = $column->columnDefinition; - } - - if ($column->enumType !== null) { - $mapping['enumType'] = $column->enumType; - } - - return $mapping; - } - - /** - * Retrieve the current annotation reader - * - * @return Reader - */ - public function getReader() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9587', - '%s is deprecated with no replacement', - __METHOD__, - ); - - return $this->reader; - } - - /** - * {@inheritDoc} - */ - public function isTransient($className) - { - $classAnnotations = $this->reader->getClassAnnotations(new ReflectionClass($className)); - - foreach ($classAnnotations as $annot) { - if (isset($this->entityAnnotationClasses[get_class($annot)])) { - return false; - } - } - - return true; - } - - /** - * Factory method for the Annotation Driver. - * - * @param mixed[]|string $paths - * - * @return AnnotationDriver - */ - public static function create($paths = [], AnnotationReader|null $reader = null) - { - if ($reader === null) { - $reader = new AnnotationReader(); - } - - return new self($reader, $paths); - } -} diff --git a/lib/Doctrine/ORM/ORMSetup.php b/lib/Doctrine/ORM/ORMSetup.php index ac19e8ef606..76057ed8c34 100644 --- a/lib/Doctrine/ORM/ORMSetup.php +++ b/lib/Doctrine/ORM/ORMSetup.php @@ -4,13 +4,8 @@ namespace Doctrine\ORM; -use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\Annotations\PsrCachedReader; -use Doctrine\Deprecations\Deprecation; -use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; -use LogicException; use Psr\Cache\CacheItemPoolInterface; use Redis; use RuntimeException; @@ -22,74 +17,10 @@ use function class_exists; use function extension_loaded; use function md5; -use function sprintf; use function sys_get_temp_dir; final class ORMSetup { - /** - * Creates a configuration with an annotation metadata driver. - * - * @deprecated Use another mapping driver. - * - * @param string[] $paths - */ - public static function createAnnotationMetadataConfiguration( - array $paths, - bool $isDevMode = false, - string|null $proxyDir = null, - CacheItemPoolInterface|null $cache = null, - ): Configuration { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/10098', - '%s is deprecated and will be removed in Doctrine ORM 3.0', - __METHOD__, - ); - $config = self::createConfiguration($isDevMode, $proxyDir, $cache); - $config->setMetadataDriverImpl(self::createDefaultAnnotationDriver($paths)); - - return $config; - } - - /** - * Adds a new default annotation driver with a correctly configured annotation reader. - * - * @deprecated Use another mapping driver. - * - * @param string[] $paths - */ - public static function createDefaultAnnotationDriver( - array $paths = [], - CacheItemPoolInterface|null $cache = null, - ): AnnotationDriver { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/10098', - '%s is deprecated and will be removed in Doctrine ORM 3.0', - __METHOD__, - ); - if (! class_exists(AnnotationReader::class)) { - throw new LogicException(sprintf( - 'The annotation metadata driver cannot be enabled because the "doctrine/annotations" library' - . ' is not installed. Please run "composer require doctrine/annotations" or choose a different' - . ' metadata driver.', - )); - } - - $reader = new AnnotationReader(); - - if ($cache === null && class_exists(ArrayAdapter::class)) { - $cache = new ArrayAdapter(); - } - - if ($cache !== null) { - $reader = new PsrCachedReader($reader, $cache); - } - - return new AnnotationDriver($reader, $paths); - } - /** * Creates a configuration with an attribute metadata driver. * diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f90f6d3b172..fa5f37dbf37 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -140,36 +140,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:mapEmbedded\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:mapManyToMany\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:mapManyToOne\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:mapOneToMany\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:mapOneToOne\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9ef47050196..4fbf03d57b4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -482,36 +482,6 @@ $class->associationMappings[$fieldName]['joinColumns'] - - - new ReflectionClass($metadata->name) - - - - $mapping - - - $metadata - - - - $listenerClassName - - - $primaryTable['indexes'] - $primaryTable['uniqueConstraints'] - - - $metadata->getReflectionClass() - - - mapEmbedded - mapManyToMany - mapManyToOne - mapOneToMany - mapOneToOne - - new ReflectionClass($metadata->name) diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php deleted file mode 100644 index c11706a7f3e..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ /dev/null @@ -1,496 +0,0 @@ -initializeReflection(new RuntimeReflectionService()); - $reader = new AnnotationReader(); - $annotationDriver = new AnnotationDriver($reader); - - $this->expectException(MappingException::class); - $annotationDriver->loadMetadataForClass(stdClass::class, $cm); - } - - public function testFailingSecondLevelCacheAssociation(): void - { - $this->expectException(CacheException::class); - $this->expectExceptionMessage('Entity association field "Doctrine\Tests\ORM\Mapping\AnnotationSLC#foo" not configured as part of the second-level cache.'); - $mappingDriver = $this->loadDriver(); - - $class = new ClassMetadata(AnnotationSLC::class); - $mappingDriver->loadMetadataForClass(AnnotationSLC::class, $class); - } - - /** @group DDC-268 */ - public function testColumnWithMissingTypeDefaultsToString(): void - { - $cm = new ClassMetadata(ColumnWithoutType::class); - $cm->initializeReflection(new RuntimeReflectionService()); - $annotationDriver = $this->loadDriver(); - - $annotationDriver->loadMetadataForClass(InvalidColumn::class, $cm); - self::assertEquals('string', $cm->fieldMappings['id']['type']); - } - - /** @group DDC-318 */ - public function testGetAllClassNamesIsIdempotent(): void - { - $annotationDriver = $this->loadDriverForCMSModels(); - $original = $annotationDriver->getAllClassNames(); - - $annotationDriver = $this->loadDriverForCMSModels(); - $afterTestReset = $annotationDriver->getAllClassNames(); - - self::assertEquals($original, $afterTestReset); - } - - /** @group DDC-318 */ - public function testGetAllClassNamesIsIdempotentEvenWithDifferentDriverInstances(): void - { - $annotationDriver = $this->loadDriverForCMSModels(); - $original = $annotationDriver->getAllClassNames(); - - $annotationDriver = $this->loadDriverForCMSModels(); - $afterTestReset = $annotationDriver->getAllClassNames(); - - self::assertEquals($original, $afterTestReset); - } - - /** @group DDC-318 */ - public function testGetAllClassNamesReturnsAlreadyLoadedClassesIfAppropriate(): void - { - $this->ensureIsLoaded(CmsUser::class); - - $annotationDriver = $this->loadDriverForCMSModels(); - $classes = $annotationDriver->getAllClassNames(); - - self::assertContains(CmsUser::class, $classes); - } - - /** @group DDC-318 */ - public function testGetClassNamesReturnsOnlyTheAppropriateClasses(): void - { - $this->ensureIsLoaded(ECommerceCart::class); - - $annotationDriver = $this->loadDriverForCMSModels(); - $classes = $annotationDriver->getAllClassNames(); - - self::assertNotContains(ECommerceCart::class, $classes); - } - - protected function loadDriverForCMSModels(): AnnotationDriver - { - $annotationDriver = $this->loadDriver(); - $annotationDriver->addPaths([__DIR__ . '/../../Models/CMS/']); - - return $annotationDriver; - } - - /** @return AnnotationDriver */ - protected function loadDriver(): MappingDriver - { - return $this->createAnnotationDriver(); - } - - /** @psalm-var class-string $entityClassName */ - protected function ensureIsLoaded(string $entityClassName): void - { - new $entityClassName(); - } - - /** - * @group DDC-671 - * - * Entities for this test are in AbstractMappingDriverTest - */ - public function testJoinTablesWithMappedSuperclassForAnnotationDriver(): void - { - $annotationDriver = $this->loadDriver(); - $annotationDriver->addPaths([__DIR__ . '/../../Models/DirectoryTree/']); - - $em = $this->getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new ClassMetadataFactory(); - $factory->setEntityManager($em); - - $classPage = $factory->getMetadataFor(File::class); - self::assertEquals(File::class, $classPage->associationMappings['parentDirectory']['sourceEntity']); - - $classDirectory = $factory->getMetadataFor(Directory::class); - self::assertEquals(Directory::class, $classDirectory->associationMappings['parentDirectory']['sourceEntity']); - } - - /** @group DDC-945 */ - public function testInvalidMappedSuperClassWithManyToManyAssociation(): void - { - $annotationDriver = $this->loadDriver(); - - $em = $this->getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new ClassMetadataFactory(); - $factory->setEntityManager($em); - - $this->expectException(MappingException::class); - $this->expectExceptionMessage( - 'It is illegal to put an inverse side one-to-many or many-to-many association on ' . - "mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'", - ); - - $factory->getMetadataFor(UsingInvalidMappedSuperClass::class); - } - - /** @group DDC-1050 */ - public function testInvalidMappedSuperClassWithInheritanceInformation(): void - { - $annotationDriver = $this->loadDriver(); - - $em = $this->getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new ClassMetadataFactory(); - $factory->setEntityManager($em); - - $this->expectException(MappingException::class); - $this->expectExceptionMessage( - 'It is not supported to define inheritance information on a mapped ' . - "superclass '" . MappedSuperClassInheritence::class . "'.", - ); - - $usingInvalidMsc = $factory->getMetadataFor(MappedSuperClassInheritence::class); - } - - /** @group DDC-1034 */ - public function testInheritanceSkipsParentLifecycleCallbacks(): void - { - $annotationDriver = $this->loadDriver(); - - $em = $this->getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new ClassMetadataFactory(); - $factory->setEntityManager($em); - - $cm = $factory->getMetadataFor(AnnotationChild::class); - self::assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); - - $cm = $factory->getMetadataFor(AnnotationParent::class); - self::assertEquals(['postLoad' => ['postLoad'], 'preUpdate' => ['preUpdate']], $cm->lifecycleCallbacks); - } - - /** @group DDC-1156 */ - public function testMappedSuperclassInMiddleOfInheritanceHierarchy(): void - { - $annotationDriver = $this->loadDriver(); - - $em = $this->getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - - $factory = new ClassMetadataFactory(); - $factory->setEntityManager($em); - - self::assertInstanceOf(ClassMetadata::class, $factory->getMetadataFor(ChildEntity::class)); - } - - public function testInvalidFetchOptionThrowsException(): void - { - $annotationDriver = $this->loadDriver(); - - $em = $this->getTestEntityManager(); - $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new ClassMetadataFactory(); - $factory->setEntityManager($em); - - $this->expectException(MappingException::class); - $this->expectExceptionMessage("Entity 'Doctrine\Tests\ORM\Mapping\InvalidFetchOption' has a mapping with invalid fetch mode 'eager'"); - - $factory->getMetadataFor(InvalidFetchOption::class); - } - - public function testAttributeOverridesMappingWithTrait(): void - { - $factory = $this->createClassMetadataFactory(); - - $metadataWithoutOverride = $factory->getMetadataFor(DDC1872ExampleEntityWithoutOverride::class); - $metadataWithOverride = $factory->getMetadataFor(DDC1872ExampleEntityWithOverride::class); - - self::assertEquals('trait_foo', $metadataWithoutOverride->fieldMappings['foo']['columnName']); - self::assertEquals('foo_overridden', $metadataWithOverride->fieldMappings['foo']['columnName']); - self::assertArrayHasKey('example_trait_bar_id', $metadataWithoutOverride->associationMappings['bar']['joinColumnFieldNames']); - self::assertArrayHasKey('example_entity_overridden_bar_id', $metadataWithOverride->associationMappings['bar']['joinColumnFieldNames']); - } - - /** - * @psalm-param class-string $class - * - * @dataProvider provideDiscriminatorColumnTestcases - */ - public function testLengthForDiscriminatorColumn(string $class, int $expectedLength): void - { - $factory = $this->createClassMetadataFactory(); - - $metadata = $factory->getMetadataFor($class); - - self::assertNotNull($metadata->discriminatorColumn); - self::assertArrayHasKey('length', $metadata->discriminatorColumn); - self::assertSame($expectedLength, $metadata->discriminatorColumn['length']); - } - - public function provideDiscriminatorColumnTestcases(): Generator - { - yield [DiscriminatorColumnWithNullLength::class, 255]; - yield [DiscriminatorColumnWithNoLength::class, 255]; - yield [DiscriminatorColumnWithZeroLength::class, 0]; - yield [DiscriminatorColumnWithNonZeroLength::class, 60]; - } -} - -/** @Entity */ -class ColumnWithoutType -{ - /** - * @var int - * @Id - * @Column - */ - public $id; -} - -/** @MappedSuperclass */ -class InvalidMappedSuperClass -{ - /** - * @psalm-var Collection - * @ManyToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", mappedBy="invalid") - */ - private $users; -} - -/** @Entity */ -class UsingInvalidMappedSuperClass extends InvalidMappedSuperClass -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - private int $id; -} - -/** - * @MappedSuperclass - * @InheritanceType("JOINED") - * @DiscriminatorMap({"test" = "ColumnWithoutType"}) - */ -class MappedSuperClassInheritence -{ -} - -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({"parent" = "AnnotationParent", "child" = "AnnotationChild"}) - * @HasLifecycleCallbacks - */ -class AnnotationParent -{ - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ - private int $id; - - /** @PostLoad */ - public function postLoad(): void - { - } - - /** @PreUpdate */ - public function preUpdate(): void - { - } -} - -/** - * @Entity - * @HasLifecycleCallbacks - */ -class AnnotationChild extends AnnotationParent -{ -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"s"="SuperEntity", "c"="ChildEntity"}) - */ -class SuperEntity -{ - /** - * @Id - * @Column(type="string", length=255) - */ - private string $id; -} - -/** @MappedSuperclass */ -class MiddleMappedSuperclass extends SuperEntity -{ - /** @Column(type="string", length=255) */ - private string $name; -} - -/** @Entity */ -class ChildEntity extends MiddleMappedSuperclass -{ - /** @Column(type="string", length=255) */ - private string $text; -} - -/** @Entity */ -class InvalidFetchOption -{ - /** @OneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", fetch="eager") */ - private CmsUser $collection; -} - -/** - * @Entity - * @Cache - */ -class AnnotationSLC -{ - /** - * @var AnnotationSLCFoo - * @Id - * @ManyToOne(targetEntity="AnnotationSLCFoo") - */ - public $foo; -} -/** @Entity */ -class AnnotationSLCFoo -{ - /** - * @var string - * @Column(type="string", length=255) - */ - public $id; -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn( - * name="type", - * type="string", - * length=0, - * columnDefinition="enum('region','airport','station','poi') NOT NULL", - * ), - * @DiscriminatorMap({"s"="SuperEntity", "c"="ChildEntity"}) - */ -class DiscriminatorColumnWithZeroLength -{ - /** - * @var int - * @Id - * @Column - */ - public $id; -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn( - * name="type", - * type="string", - * ), - * @DiscriminatorMap({"s"="SuperEntity", "c"="ChildEntity"}) - */ -class DiscriminatorColumnWithNoLength -{ - /** - * @var int - * @Id - * @Column - */ - public $id; -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn( - * name="type", - * type="string", - * length=60, - * ), - * @DiscriminatorMap({"s"="SuperEntity", "c"="ChildEntity"}) - */ -class DiscriminatorColumnWithNonZeroLength -{ - /** - * @var int - * @Id - * @Column - */ - public $id; -} - -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn( - * name="type", - * type="string", - * length=null, - * ), - * @DiscriminatorMap({"s"="SuperEntity", "c"="ChildEntity"}) - */ -class DiscriminatorColumnWithNullLength -{ - /** - * @var int - * @Id - * @Column - */ - public $id; -} From 29aee06e7624c8682e3fb5c576c366ce43b736fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 5 Oct 2022 20:45:36 +0200 Subject: [PATCH 177/475] Remove annotations that duplicate attributes --- .../Doctrine/Tests/Models/CMS/CmsAddress.php | 14 +- tests/Doctrine/Tests/Models/Cache/City.php | 30 +--- .../Tests/Models/Company/CompanyContract.php | 17 --- .../Company/CompanyContractListener.php | 8 - .../Models/Company/CompanyFixContract.php | 1 - .../Models/Company/CompanyFlexContract.php | 1 - .../Company/CompanyFlexUltraContract.php | 4 - .../CompanyFlexUltraContractListener.php | 2 - .../DDC1476EntityWithDefaultFieldType.php | 13 +- .../Models/DDC2825/ExplicitSchemaAndTable.php | 11 +- .../DDC2825/SchemaAndTableInTableName.php | 10 +- .../Tests/Models/DDC3579/DDC3579Admin.php | 9 -- .../Tests/Models/DDC3579/DDC3579Group.php | 13 +- .../Tests/Models/DDC3579/DDC3579User.php | 14 +- .../Models/DDC5934/DDC5934BaseContract.php | 13 +- .../Tests/Models/DDC5934/DDC5934Contract.php | 6 - .../Tests/Models/DDC5934/DDC5934Member.php | 7 +- .../Models/DDC869/DDC869ChequePayment.php | 6 +- .../Models/DDC869/DDC869CreditCardPayment.php | 6 +- .../Tests/Models/DDC869/DDC869Payment.php | 13 +- .../Tests/Models/DDC889/DDC889Entity.php | 1 - .../Tests/Models/DDC889/DDC889SuperClass.php | 6 +- .../Tests/Models/DDC964/DDC964Admin.php | 17 --- .../Tests/Models/DDC964/DDC964Guest.php | 20 --- .../Tests/Models/DDC964/DDC964User.php | 24 +-- tests/Doctrine/Tests/Models/Enums/Card.php | 11 +- .../Tests/Models/Enums/CardWithNullable.php | 11 +- tests/Doctrine/Tests/Models/Enums/Scale.php | 11 +- .../Models/Enums/TypedCardEnumCompositeId.php | 9 -- .../Tests/Models/Enums/TypedCardEnumId.php | 5 - .../Tests/Models/TypedProperties/Contact.php | 2 - .../Models/TypedProperties/UserTyped.php | 23 --- .../Tests/Models/Upsertable/Insertable.php | 21 +-- .../Tests/Models/Upsertable/Updatable.php | 21 +-- .../ORM/Functional/Ticket/DDC2825Test.php | 11 +- .../ORM/Mapping/MappingDriverTestCase.php | 143 ++---------------- 36 files changed, 49 insertions(+), 485 deletions(-) diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index 081f0340af9..8e17aeedd30 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -16,24 +16,12 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * CmsAddress - * - * @Entity - * @Table(name="cms_addresses") - * @EntityListeners({"CmsAddressListener"}) - */ #[ORM\Entity] #[ORM\Table(name: 'cms_addresses')] #[ORM\EntityListeners(['CmsAddressListener'])] class CmsAddress { - /** - * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue - */ + /** @var int */ #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')] public $id; diff --git a/tests/Doctrine/Tests/Models/Cache/City.php b/tests/Doctrine/Tests/Models/Cache/City.php index ed0bceb7216..e5805543582 100644 --- a/tests/Doctrine/Tests/Models/Cache/City.php +++ b/tests/Doctrine/Tests/Models/Cache/City.php @@ -20,48 +20,24 @@ use Doctrine\ORM\Mapping\OrderBy; use Doctrine\ORM\Mapping\Table; -/** - * @Cache - * @Entity - * @Table("cache_city") - */ #[ORM\Entity, ORM\Table(name: 'cache_city'), ORM\Cache] class City { - /** - * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + /** @var int */ #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')] protected $id; - /** - * @var Collection - * @ManyToMany(targetEntity="Travel", mappedBy="visitedCities") - */ + /** @var Collection */ #[ORM\ManyToMany(targetEntity: 'Travel', mappedBy: 'visitedCities')] public $travels; - /** - * @psalm-var Collection - * @Cache - * @OrderBy({"name" = "ASC"}) - * @OneToMany(targetEntity="Attraction", mappedBy="city") - */ + /** @psalm-var Collection */ #[ORM\Cache, ORM\OrderBy(['name' => 'ASC'])] #[ORM\OneToMany(targetEntity: 'Attraction', mappedBy: 'city')] public $attractions; public function __construct( - /** @Column(unique=true) */ #[ORM\Column(unique: true)] protected string $name, - /** - * @Cache - * @ManyToOne(targetEntity="State", inversedBy="cities") - * @JoinColumn(name="state_id", referencedColumnName="id") - */ #[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'cities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] protected State|null $state = null, ) { $this->travels = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index b0dfb64d379..53aa792ca17 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -23,18 +23,6 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="company_contracts") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @EntityListeners({"CompanyContractListener"}) - * @DiscriminatorMap({ - * "fix" = "CompanyFixContract", - * "flexible" = "CompanyFlexContract", - * "flexultra" = "CompanyFlexUltraContract" - * }) - */ #[ORM\Entity, ORM\Table(name: 'company_contracts')] #[ORM\InheritanceType('SINGLE_TABLE')] #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')] @@ -42,11 +30,6 @@ #[ORM\EntityListeners(['CompanyContractListener'])] abstract class CompanyContract { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue] private int $id; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php b/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php index 26b4dc67bec..26b21778a86 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php @@ -42,56 +42,48 @@ class CompanyContractListener /** @psalm-var list> */ public $postLoadCalls; - /** @PostPersist */ #[ORM\PostPersist] public function postPersistHandler(CompanyContract $contract): void { $this->postPersistCalls[] = func_get_args(); } - /** @PrePersist */ #[ORM\PrePersist] public function prePersistHandler(CompanyContract $contract): void { $this->prePersistCalls[] = func_get_args(); } - /** @PostUpdate */ #[ORM\PostUpdate] public function postUpdateHandler(CompanyContract $contract): void { $this->postUpdateCalls[] = func_get_args(); } - /** @PreUpdate */ #[ORM\PreUpdate] public function preUpdateHandler(CompanyContract $contract): void { $this->preUpdateCalls[] = func_get_args(); } - /** @PostRemove */ #[ORM\PostRemove] public function postRemoveHandler(CompanyContract $contract): void { $this->postRemoveCalls[] = func_get_args(); } - /** @PreRemove */ #[ORM\PreRemove] public function preRemoveHandler(CompanyContract $contract): void { $this->preRemoveCalls[] = func_get_args(); } - /** @PreFlush */ #[ORM\PreFlush] public function preFlushHandler(CompanyContract $contract): void { $this->preFlushCalls[] = func_get_args(); } - /** @PostLoad */ #[ORM\PostLoad] public function postLoadHandler(CompanyContract $contract): void { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php index 34addb2d834..e48d7887bf3 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ #[ORM\Entity] class CompanyFixContract extends CompanyContract { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index fb9679446dd..6e6a4a3d035 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -15,7 +15,6 @@ use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; -/** @Entity */ #[ORM\Entity] class CompanyFlexContract extends CompanyContract { diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php index ae480953f9f..805de4584d1 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -13,10 +13,6 @@ use function max; -/** - * @Entity - * @EntityListeners({"CompanyContractListener","CompanyFlexUltraContractListener"}) - */ #[ORM\Entity] #[ORM\EntityListeners(['CompanyContractListener', 'CompanyFlexUltraContractListener'])] class CompanyFlexUltraContract extends CompanyFlexContract diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php index 47dc298a2cd..8b91649150b 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php @@ -15,14 +15,12 @@ class CompanyFlexUltraContractListener /** @psalm-var list */ public $prePersistCalls; - /** @PrePersist */ #[ORM\PrePersist] public function prePersistHandler1(CompanyContract $contract, PrePersistEventArgs $args): void { $this->prePersistCalls[] = func_get_args(); } - /** @PrePersist */ #[ORM\PrePersist] public function prePersistHandler2(CompanyContract $contract, PrePersistEventArgs $args): void { diff --git a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php b/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php index 1bc9b1f0cc9..c9a731a2c4b 100644 --- a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php +++ b/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php @@ -11,23 +11,14 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity() */ #[ORM\Entity] class DDC1476EntityWithDefaultFieldType { - /** - * @var int - * @Id - * @Column() - * @GeneratedValue("NONE") - */ + /** @var int */ #[ORM\Id, ORM\Column, ORM\GeneratedValue(strategy: 'NONE')] protected $id; - /** - * @var string - * @Column() - */ + /** @var string */ #[ORM\Column] protected $name; diff --git a/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php b/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php index 687cf494da9..628fe130334 100644 --- a/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php +++ b/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php @@ -11,19 +11,10 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="explicit_table", schema="explicit_schema") - */ #[ORM\Entity, ORM\Table(name: 'explicit_table', schema: 'explicit_schema')] class ExplicitSchemaAndTable { - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + /** @var int */ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php b/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php index a30693d85e6..1e25f6960e1 100644 --- a/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php +++ b/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php @@ -14,19 +14,11 @@ /** * Quoted column name to check that sequence names are * correctly handled - * - * @Entity - * @Table(name="implicit_schema.implicit_table") */ #[ORM\Entity, ORM\Table(name: 'implicit_schema.implicit_table')] class SchemaAndTableInTableName { - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + /** @var int */ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php index cc0d1c75d6b..e8456aa4618 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php @@ -8,15 +8,6 @@ use Doctrine\ORM\Mapping\AssociationOverrides; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - * @AssociationOverrides({ - * @AssociationOverride( - * name="groups", - * inversedBy="admins" - * ) - * }) - */ #[Entity] #[AssociationOverrides([new AssociationOverride(name: 'groups', inversedBy: 'admins')])] class DDC3579Admin extends DDC3579User diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php index a68adbef79c..4d9143a5d8f 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php @@ -12,27 +12,18 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** @Entity */ #[Entity] class DDC3579Group { - /** - * @GeneratedValue - * @Id - * @Column(type="integer") - */ + /** @GeneratedValue */ #[Id, GeneratedValue, Column(type: 'integer')] private int $id; - /** - * @psalm-var Collection - * @ManyToMany(targetEntity="DDC3579Admin", mappedBy="groups") - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: DDC3579Admin::class, mappedBy: 'groups')] private $admins; public function __construct( - /** @Column */ #[Column] private string|null $name = null, ) { $this->admins = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php index f8537660bf6..f42524e43eb 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php @@ -12,28 +12,18 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\MappedSuperclass; -/** @MappedSuperclass */ #[MappedSuperclass] class DDC3579User { - /** - * @var int - * @Id - * @GeneratedValue - * @Column(type="integer", name="user_id", length=150) - */ + /** @var int */ #[Id, GeneratedValue, Column(type: 'integer', name: 'user_id', length: 150)] protected $id; - /** - * @var ArrayCollection - * @ManyToMany(targetEntity="DDC3579Group") - */ + /** @var ArrayCollection */ #[ManyToMany(targetEntity: DDC3579Group::class)] protected $groups; public function __construct( - /** @Column(name="user_name", nullable=true, unique=false, length=250) */ #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected string|null $name = null, ) { $this->groups = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php b/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php index 7b6ce747990..da3cb326439 100644 --- a/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php +++ b/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php @@ -13,23 +13,14 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** @Entity */ #[Entity] class DDC5934BaseContract { - /** - * @var int - * @Id() - * @Column(name="id", type="integer") - * @GeneratedValue() - */ + /** @var int */ #[Id, Column, GeneratedValue] public $id; - /** - * @psalm-var Collection - * @ManyToMany(targetEntity="DDC5934Member", fetch="LAZY", inversedBy="contracts") - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: DDC5934Member::class, fetch: 'LAZY', inversedBy: 'contracts')] public $members; diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934Contract.php b/tests/Doctrine/Tests/Models/DDC5934/DDC5934Contract.php index ab064c23127..e924e830aa2 100644 --- a/tests/Doctrine/Tests/Models/DDC5934/DDC5934Contract.php +++ b/tests/Doctrine/Tests/Models/DDC5934/DDC5934Contract.php @@ -9,12 +9,6 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - * @AssociationOverrides( - * @AssociationOverride(name="members", fetch="EXTRA_LAZY") - * ) - */ #[Entity] #[AssociationOverrides([new AssociationOverride(name: 'members', fetch: 'EXTRA_LAZY')])] class DDC5934Contract extends DDC5934BaseContract diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php b/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php index 3e8af0d865c..c43ddfccd5a 100644 --- a/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php +++ b/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php @@ -7,15 +7,10 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; -/** @ORM\Entity() */ #[ORM\Entity] class DDC5934Member { - /** - * @ORM\ManyToMany(targetEntity="DDC5934BaseContract", mappedBy="members") - * - * @var ArrayCollection - */ + /** @var ArrayCollection */ #[ORM\ManyToMany(targetEntity: DDC5934BaseContract::class, mappedBy: 'members')] public $contracts; diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php index 32f1bb996fe..539eb134517 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php @@ -9,14 +9,10 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ #[ORM\Entity] class DDC869ChequePayment extends DDC869Payment { - /** - * @var string - * @Column(type="string", length=255) - */ + /** @var string */ #[ORM\Column(type: 'string')] protected $serialNumber; diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php index fb3be4f2a91..c2b81eeb007 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php @@ -9,14 +9,10 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ #[ORM\Entity] class DDC869CreditCardPayment extends DDC869Payment { - /** - * @var string - * @Column(type="string", length=255) - */ + /** @var string */ #[ORM\Column(type: 'string')] protected $creditCardNumber; diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php index 4380d4ce12e..e5bb907f9cd 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php @@ -11,23 +11,14 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\MappedSuperclass; -/** @MappedSuperclass(repositoryClass = "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository") */ #[ORM\MappedSuperclass(repositoryClass: DDC869PaymentRepository::class)] class DDC869Payment { - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + /** @var int */ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue] protected $id; - /** - * @var float - * @Column(type="float") - */ + /** @var float */ #[ORM\Column(type: 'float')] protected $value; diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php b/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php index 61e53296fdf..6e8f168a861 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php @@ -8,7 +8,6 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ #[ORM\Entity] class DDC889Entity extends DDC889SuperClass { diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php b/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php index 7f9507113a7..6d42d9ff602 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php @@ -9,14 +9,10 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\MappedSuperclass; -/** @MappedSuperclass */ #[ORM\MappedSuperclass] class DDC889SuperClass { - /** - * @var string - * @Column() - */ + /** @var string */ #[ORM\Column] protected $name; diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php index e724d85283e..1d802dea597 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php @@ -11,23 +11,6 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; -/** - * @Entity - * @AssociationOverrides({ - * @AssociationOverride(name="groups", - * joinTable=@JoinTable( - * name="ddc964_users_admingroups", - * joinColumns=@JoinColumn(name="adminuser_id"), - * inverseJoinColumns=@JoinColumn(name="admingroup_id") - * ) - * ), - * @AssociationOverride(name="address", - * joinColumns=@JoinColumn( - * name="adminaddress_id", referencedColumnName="id" - * ) - * ) - * }) - */ #[Entity] #[AssociationOverrides([new AssociationOverride(name: 'groups', joinTable: new JoinTable(name: 'ddc964_users_admingroups'), joinColumns: [new JoinColumn(name: 'adminuser_id')], inverseJoinColumns: [new JoinColumn(name: 'admingroup_id')]), new AssociationOverride(name: 'address', joinColumns: [new JoinColumn(name: 'adminaddress_id', referencedColumnName: 'id')])])] class DDC964Admin extends DDC964User diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php index 7e7a03b4d39..501c67d9680 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php @@ -10,26 +10,6 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** - * @Entity - * @AttributeOverrides({ - * @AttributeOverride(name="id", - * column=@Column( - * name = "guest_id", - * type = "integer", - length = 140 - * ) - * ), - * @AttributeOverride(name="name", - * column=@Column( - * name = "guest_name", - * nullable = false, - * unique = true, - * length = 240 - * ) - * ) - * }) - */ #[Entity] #[AttributeOverrides([new AttributeOverride(name: 'id', column: new Column(name: 'guest_id', type: 'integer', length: 140)), new AttributeOverride(name: 'name', column: new Column(name: 'guest_name', nullable: false, unique: true, length: 240))])] class DDC964Guest extends DDC964User diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php index 8d949a3fc6b..de4aa2f38d2 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php @@ -17,44 +17,26 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\MappedSuperclass; -/** @MappedSuperclass */ #[MappedSuperclass] class DDC964User { - /** - * @var int - * @Id - * @GeneratedValue - * @Column(type="integer", name="user_id", length=150) - */ + /** @var int */ #[Id, GeneratedValue, Column(type: 'integer', name: 'user_id', length: 150)] protected $id; - /** - * @psalm-var Collection - * @ManyToMany(targetEntity="DDC964Group", inversedBy="users", cascade={"persist", "merge", "detach"}) - * @JoinTable(name="ddc964_users_groups", - * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")} - * ) - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: DDC964Group::class, inversedBy: 'users', cascade: ['persist', 'merge', 'detach'])] #[JoinTable(name: 'ddc964_users_groups')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] protected $groups; - /** - * @var DDC964Address - * @ManyToOne(targetEntity="DDC964Address", cascade={"persist", "merge"}) - * @JoinColumn(name="address_id", referencedColumnName="id") - */ + /** @var DDC964Address */ #[ManyToOne(targetEntity: DDC964Address::class, cascade: ['persist', 'merge'])] #[JoinColumn(name: 'address_id', referencedColumnName: 'id')] protected $address; public function __construct( - /** @Column(name="user_name", nullable=true, unique=false, length=250) */ #[Column(name: 'user_name', nullable: true, unique: false, length: 250)] protected string|null $name = null, ) { $this->groups = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Enums/Card.php b/tests/Doctrine/Tests/Models/Enums/Card.php index f9378fe0873..6af14fb152c 100644 --- a/tests/Doctrine/Tests/Models/Enums/Card.php +++ b/tests/Doctrine/Tests/Models/Enums/Card.php @@ -10,21 +10,14 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ #[Entity] class Card { - /** - * @Id @GeneratedValue @Column(type="integer") - * @var int - */ + /** @var int */ #[Id, GeneratedValue, Column(type: 'integer')] public $id; - /** - * @Column(type="string", length=255, enumType=Suit::class) - * @var Suit - */ + /** @var Suit */ #[Column(type: 'string', enumType: Suit::class)] public $suit; diff --git a/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php b/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php index d3c1f0d9ef6..b9702cb0050 100644 --- a/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php +++ b/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php @@ -10,21 +10,14 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ #[Entity] class CardWithNullable { - /** - * @Id @GeneratedValue @Column(type="integer") - * @var int - */ + /** @var int */ #[Id, GeneratedValue, Column(type: 'integer')] public $id; - /** - * @Column(type="string", length=255, enumType=Suit::class, nullable=true) - * @var ?Suit - */ + /** @var ?Suit */ #[Column(type: 'string', nullable: true, enumType: Suit::class)] public $suit; diff --git a/tests/Doctrine/Tests/Models/Enums/Scale.php b/tests/Doctrine/Tests/Models/Enums/Scale.php index 46ded6cf3db..19a612b1c70 100644 --- a/tests/Doctrine/Tests/Models/Enums/Scale.php +++ b/tests/Doctrine/Tests/Models/Enums/Scale.php @@ -10,21 +10,14 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ #[Entity] class Scale { - /** - * @Id @GeneratedValue @Column(type="integer") - * @var int - */ + /** @var int */ #[Id, GeneratedValue, Column(type: 'integer')] public $id; - /** - * @Column(type="simple_array", enumType=Unit::class) - * @var Unit[] - */ + /** @var Unit[] */ #[Column(type: 'simple_array', enumType: Unit::class)] public $supportedUnits; diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php index 2b85d08ef69..a21ee66c88c 100644 --- a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php +++ b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php @@ -9,21 +9,12 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** @Entity */ #[Entity] class TypedCardEnumCompositeId { - /** - * @ORM\Id() - * @ORM\Column(type="string", enumType=Suit::class) - */ #[Id, Column(type: 'string', enumType: Suit::class)] public Suit $suit; - /** - * @ORM\Id() - * @ORM\Column(type="string", enumType=Unit::class) - */ #[Id, Column(type: 'string', enumType: Unit::class)] public Unit $unit; } diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php index 38474d61bb5..a9411df9c83 100644 --- a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php +++ b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php @@ -9,14 +9,9 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** @Entity */ #[Entity] class TypedCardEnumId { - /** - * @ORM\Id() - * @ORM\Column(type="string", enumType=Suit::class) - */ #[Id, Column(type: 'string', enumType: Suit::class)] public Suit $suit; } diff --git a/tests/Doctrine/Tests/Models/TypedProperties/Contact.php b/tests/Doctrine/Tests/Models/TypedProperties/Contact.php index cc35b7f3397..333a18386d7 100644 --- a/tests/Doctrine/Tests/Models/TypedProperties/Contact.php +++ b/tests/Doctrine/Tests/Models/TypedProperties/Contact.php @@ -7,11 +7,9 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\Column; -/** @ORM\Embeddable() */ #[ORM\Embeddable] class Contact { - /** @Column() */ #[ORM\Column] public string|null $email = null; } diff --git a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php index 123e2034d6b..f4b2178fa60 100644 --- a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php +++ b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php @@ -20,65 +20,42 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\Models\CMS\CmsEmail; -/** - * @Entity - * @Table(name="cms_users_typed") - */ #[ORM\Entity, ORM\Table(name: 'cms_users_typed')] class UserTyped { - /** - * @Id - * @Column - * @GeneratedValue - */ #[ORM\Id, ORM\Column, ORM\GeneratedValue] public int $id; - /** @Column(length=50) */ #[ORM\Column(length: 50)] public string|null $status = null; - /** @Column(length=255, unique=true) */ #[ORM\Column(length: 255, unique: true)] public string $username; - /** @Column */ #[ORM\Column] public DateInterval $dateInterval; - /** @Column */ #[ORM\Column] public DateTime $dateTime; - /** @Column */ #[ORM\Column] public DateTimeImmutable $dateTimeImmutable; - /** @Column */ #[ORM\Column] public array $array; - /** @Column */ #[ORM\Column] public bool $boolean; - /** @Column */ #[ORM\Column] public float $float; - /** - * @OneToOne(cascade={"persist"}, orphanRemoval=true) - * @JoinColumn - */ #[ORM\OneToOne(cascade: ['persist'], orphanRemoval: true), ORM\JoinColumn] public CmsEmail $email; - /** @ManyToOne */ #[ORM\ManyToOne] public CmsEmail|null $mainEmail = null; - /** @Embedded */ #[ORM\Embedded] public Contact|null $contact = null; diff --git a/tests/Doctrine/Tests/Models/Upsertable/Insertable.php b/tests/Doctrine/Tests/Models/Upsertable/Insertable.php index e2a618a7487..4efd878d5f6 100644 --- a/tests/Doctrine/Tests/Models/Upsertable/Insertable.php +++ b/tests/Doctrine/Tests/Models/Upsertable/Insertable.php @@ -11,34 +11,19 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="insertable_column") - */ #[Entity] #[Table(name: 'insertable_column')] class Insertable { - /** - * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + /** @var int */ #[Id, GeneratedValue, Column(type: 'integer')] public $id; - /** - * @var string - * @Column(type="string", length=255, insertable=false, options={"default": "1234"}, generated="INSERT") - */ + /** @var string */ #[Column(type: 'string', insertable: false, options: ['default' => '1234'], generated: 'INSERT')] public $nonInsertableContent; - /** - * @var string - * @Column(type="string", length=255, insertable=true) - */ + /** @var string */ #[Column(type: 'string', insertable: true)] public $insertableContent; diff --git a/tests/Doctrine/Tests/Models/Upsertable/Updatable.php b/tests/Doctrine/Tests/Models/Upsertable/Updatable.php index bbda42fcfa7..df7670ce030 100644 --- a/tests/Doctrine/Tests/Models/Upsertable/Updatable.php +++ b/tests/Doctrine/Tests/Models/Upsertable/Updatable.php @@ -11,33 +11,18 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="updatable_column") - */ #[Entity, Table(name: 'updatable_column')] class Updatable { - /** - * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + /** @var int */ #[Id, GeneratedValue, Column(type: 'integer')] public $id; - /** - * @var string - * @Column(type="string", length=255, name="non_updatable_content", updatable=false, generated="ALWAYS") - */ + /** @var string */ #[Column(name: 'non_updatable_content', type: 'string', length: 255, updatable: false, generated: 'ALWAYS')] public $nonUpdatableContent; - /** - * @var string - * @Column(type="string", length=255, updatable=true) - */ + /** @var string */ #[Column(type: 'string', length: 255, updatable: true)] public $updatableContent; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index 4cb956b7da4..9ad70ad0130 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -87,19 +87,10 @@ public function getTestedClasses(): array } } -/** - * @Entity - * @Table(name="myschema.order") - */ #[ORM\Entity, ORM\Table(name: 'myschema.order')] class DDC2825ClassWithImplicitlyDefinedSchemaAndQuotedTableName { - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - * @var int - */ + /** @var int */ #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 74f658dccd3..1aee7301855 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -966,101 +966,57 @@ public function testEnumType(): void } } -/** - * @Entity - * @HasLifecycleCallbacks - * @Table( - * name="cms_users", - * uniqueConstraints={@UniqueConstraint(name="search_idx", columns={"name", "user_email"}, options={"where": "name IS NOT NULL"}), @UniqueConstraint(name="phone_idx", fields={"name", "phone"})}, - * indexes={@Index(name="name_idx", columns={"name"}), @Index(name="0", columns={"user_email"}), @index(name="fields", fields={"name", "email"})}, - * options={"foo": "bar", "baz": {"key": "val"}} - * ) - */ #[ORM\Entity(), ORM\HasLifecycleCallbacks()] #[ORM\Table(name: 'cms_users', options: ['foo' => 'bar', 'baz' => ['key' => 'val']])] #[ORM\Index(name: 'name_idx', columns: ['name']), ORM\Index(name: '0', columns: ['user_email']), ORM\Index(name: 'fields', fields: ['name', 'email'])] #[ORM\UniqueConstraint(name: 'search_idx', columns: ['name', 'user_email'], options: ['where' => 'name IS NOT NULL']), ORM\UniqueConstraint(name: 'phone_idx', fields: ['name', 'phone'])] class User { - /** - * @var int - * @Id - * @Column(type="integer", options={"foo": "bar", "unsigned": false}) - * @GeneratedValue(strategy="AUTO") - * @SequenceGenerator(sequenceName="tablename_seq", initialValue=1, allocationSize=100) - **/ + /** @var int **/ #[ORM\Id, ORM\Column(type: 'integer', options: ['foo' => 'bar', 'unsigned' => false])] #[ORM\GeneratedValue(strategy: 'AUTO')] #[ORM\SequenceGenerator(sequenceName: 'tablename_seq', initialValue: 1, allocationSize: 100)] public $id; - /** - * @var string - * @Column(length=50, nullable=true, unique=true, options={"foo": "bar", "baz": {"key": "val"}, "fixed": false}) - */ + /** @var string */ #[ORM\Column(length: 50, nullable: true, unique: true, options: ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false])] public $name; - /** - * @var string - * @Column(name="user_email", columnDefinition="CHAR(32) NOT NULL") - */ + /** @var string */ #[ORM\Column(name: 'user_email', columnDefinition: 'CHAR(32) NOT NULL')] public $email; - /** - * @var Address - * @OneToOne(targetEntity="Address", cascade={"remove"}, inversedBy="user") - * @JoinColumn(onDelete="CASCADE") - */ + /** @var Address */ #[ORM\OneToOne(targetEntity: 'Address', cascade: ['remove'], inversedBy: 'user')] #[ORM\JoinColumn(onDelete: 'CASCADE')] public $address; - /** - * @var Collection - * @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"}, orphanRemoval=true) - * @OrderBy({"number"="ASC"}) - */ + /** @var Collection */ #[ORM\OneToMany(targetEntity: 'Phonenumber', mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] #[ORM\OrderBy(['number' => 'ASC'])] public $phonenumbers; - /** - * @var Collection - * @ManyToMany(targetEntity="Group", cascade={"all"}) - * @JoinTable(name="cms_user_groups", - * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id", nullable=false, unique=false)}, - * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id", columnDefinition="INT NULL")} - * ) - */ + /** @var Collection */ #[ORM\ManyToMany(targetEntity: 'Group', cascade: ['all'])] #[ORM\JoinTable(name: 'cms_user_groups')] #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false, unique: false)] #[ORM\InverseJoinColumn(name: 'group_id', referencedColumnName: 'id', columnDefinition: 'INT NULL')] public $groups; - /** - * @var int - * @Column(type="integer") - * @Version - */ + /** @var int */ #[ORM\Column(type: 'integer'), ORM\Version] public $version; - /** @PrePersist */ #[ORM\PrePersist] public function doStuffOnPrePersist(): void { } - /** @PrePersist */ #[ORM\PrePersist] public function doOtherStuffOnPrePersistToo(): void { } - /** @PostPersist */ #[ORM\PostPersist] public function doStuffOnPostPersist(): void { @@ -1319,23 +1275,11 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"cat" = "Cat", "dog" = "Dog"}) - * @DiscriminatorColumn(name="discr", length=32, type="string") - */ #[ORM\Entity, ORM\InheritanceType('SINGLE_TABLE'), ORM\DiscriminatorColumn(name: 'discr', length: 32, type: 'string')] #[ORM\DiscriminatorMap(['cat' => 'Cat', 'dog' => 'Dog'])] abstract class Animal { - /** - * @var string - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="CUSTOM") - * @CustomIdGenerator(class="stdClass") - */ + /** @var string */ #[ORM\Id, ORM\Column(type: 'string'), ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\CustomIdGenerator(class: stdClass::class)] public $id; @@ -1347,7 +1291,6 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** @Entity */ #[ORM\Entity] class Cat extends Animal { @@ -1356,7 +1299,6 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** @Entity */ #[ORM\Entity] class Dog extends Animal { @@ -1365,21 +1307,14 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** @Entity */ #[ORM\Entity] class DDC1170Entity { public function __construct( - /** @Column(columnDefinition = "VARCHAR(255) NOT NULL") */ #[ORM\Column(columnDefinition: 'VARCHAR(255) NOT NULL')] private string|null $value = null, ) { } - /** - * @Id - * @GeneratedValue(strategy="NONE") - * @Column(type="integer", columnDefinition = "INT unsigned NOT NULL") - **/ #[ORM\Id, ORM\GeneratedValue(strategy: 'NONE'), ORM\Column(type: 'integer', columnDefinition: 'INT UNSIGNED NOT NULL')] private int $id; @@ -1414,23 +1349,12 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"ONE" = "DDC807SubClasse1", "TWO" = "DDC807SubClasse2"}) - * @DiscriminatorColumn(name = "dtype", columnDefinition="ENUM('ONE','TWO')") - */ #[ORM\Entity, ORM\InheritanceType('SINGLE_TABLE')] #[ORM\DiscriminatorColumn(name: 'dtype', columnDefinition: "ENUM('ONE','TWO')")] #[ORM\DiscriminatorMap(['ONE' => 'DDC807SubClasse1', 'TWO' => 'DDC807SubClasse2'])] class DDC807Entity { - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - **/ + /** @var int **/ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue(strategy: 'NONE')] public $id; @@ -1472,15 +1396,10 @@ class Group { } -/** - * @Entity - * @Table(indexes={@Index(columns={"content"}, flags={"fulltext"}, options={"where": "content IS NOT NULL"})}) - */ #[ORM\Entity, ORM\Table(name: 'Comment')] #[ORM\Index(columns: ['content'], flags: ['fulltext'], options: ['where' => 'content IS NOT NULL'])] class Comment { - /** @Column(type="text") */ #[ORM\Column(type: 'text')] private string $content; @@ -1510,24 +1429,11 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({ - * "ONE" = "SingleTableEntityNoDiscriminatorColumnMappingSub1", - * "TWO" = "SingleTableEntityNoDiscriminatorColumnMappingSub2" - * }) - */ #[ORM\Entity, ORM\InheritanceType('SINGLE_TABLE')] #[ORM\DiscriminatorMap(['ONE' => 'SingleTableEntityNoDiscriminatorColumnMappingSub1', 'TWO' => 'SingleTableEntityNoDiscriminatorColumnMappingSub2'])] class SingleTableEntityNoDiscriminatorColumnMapping { - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - */ + /** @var int */ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue(strategy: 'NONE')] public $id; @@ -1551,26 +1457,12 @@ class SingleTableEntityNoDiscriminatorColumnMappingSub2 extends SingleTableEntit { } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({ - * "ONE" = "SingleTableEntityIncompleteDiscriminatorColumnMappingSub1", - * "TWO" = "SingleTableEntityIncompleteDiscriminatorColumnMappingSub2" - * }) - * @DiscriminatorColumn(name="dtype") - */ #[ORM\Entity, ORM\InheritanceType('SINGLE_TABLE')] #[ORM\DiscriminatorMap(['ONE' => 'SingleTableEntityNoDiscriminatorColumnMappingSub1', 'TWO' => 'SingleTableEntityNoDiscriminatorColumnMappingSub2'])] #[ORM\DiscriminatorColumn(name: 'dtype')] class SingleTableEntityIncompleteDiscriminatorColumnMapping { - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - */ + /** @var int */ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue(strategy: 'NONE')] public $id; @@ -1594,23 +1486,14 @@ class SingleTableEntityIncompleteDiscriminatorColumnMappingSub2 extends SingleTa { } -/** @Entity */ #[ORM\Entity] class ReservedWordInTableColumn { - /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - */ + /** @var int */ #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue(strategy: 'NONE')] public $id; - /** - * @var string|null - * @Column(name="`count`", type="integer") - */ + /** @var string|null */ #[ORM\Column(name: '`count`', type: 'integer')] public $count; From bbdbfb807c325121f38a4f325c3d00a6d338cee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 25 Oct 2022 23:09:55 +0200 Subject: [PATCH 178/475] Run Rector I used the following config: paths([ __DIR__ . '/tests', ]); $rectorConfig->sets([ DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, ]); }; --- .../Doctrine/Tests/Models/CMS/CmsAddress.php | 10 +- .../Doctrine/Tests/Models/CMS/CmsArticle.php | 26 +- .../Doctrine/Tests/Models/CMS/CmsComment.php | 20 +- tests/Doctrine/Tests/Models/CMS/CmsEmail.php | 15 +- .../Doctrine/Tests/Models/CMS/CmsEmployee.php | 21 +- tests/Doctrine/Tests/Models/CMS/CmsGroup.php | 15 +- .../Tests/Models/CMS/CmsPhonenumber.php | 14 +- tests/Doctrine/Tests/Models/CMS/CmsTag.php | 15 +- tests/Doctrine/Tests/Models/CMS/CmsUser.php | 47 ++-- tests/Doctrine/Tests/Models/Cache/Action.php | 16 +- tests/Doctrine/Tests/Models/Cache/Address.php | 18 +- .../Tests/Models/Cache/Attraction.php | 36 +-- .../Models/Cache/AttractionContactInfo.php | 8 +- .../Tests/Models/Cache/AttractionInfo.php | 27 +- .../Models/Cache/AttractionLocationInfo.php | 8 +- tests/Doctrine/Tests/Models/Cache/Bar.php | 2 +- tests/Doctrine/Tests/Models/Cache/Beach.php | 2 +- tests/Doctrine/Tests/Models/Cache/Client.php | 14 +- .../Tests/Models/Cache/ComplexAction.php | 22 +- tests/Doctrine/Tests/Models/Cache/Country.php | 16 +- tests/Doctrine/Tests/Models/Cache/Flight.php | 30 +-- tests/Doctrine/Tests/Models/Cache/Login.php | 18 +- tests/Doctrine/Tests/Models/Cache/Person.php | 18 +- .../Tests/Models/Cache/Restaurant.php | 2 +- tests/Doctrine/Tests/Models/Cache/State.php | 28 +- tests/Doctrine/Tests/Models/Cache/Token.php | 32 +-- tests/Doctrine/Tests/Models/Cache/Travel.php | 40 ++- .../Doctrine/Tests/Models/Cache/Traveler.php | 28 +- .../Tests/Models/Cache/TravelerProfile.php | 22 +- .../Models/Cache/TravelerProfileInfo.php | 24 +- .../Tests/Models/Company/CompanyAuction.php | 8 +- .../Tests/Models/Company/CompanyCar.php | 16 +- .../Tests/Models/Company/CompanyContract.php | 14 +- .../Tests/Models/Company/CompanyEmployee.php | 16 +- .../Tests/Models/Company/CompanyEvent.php | 26 +- .../Models/Company/CompanyFixContract.php | 2 +- .../Models/Company/CompanyFlexContract.php | 20 +- .../Company/CompanyFlexUltraContract.php | 2 +- .../Tests/Models/Company/CompanyManager.php | 16 +- .../Models/Company/CompanyOrganization.php | 22 +- .../Tests/Models/Company/CompanyPerson.php | 46 ++-- .../Tests/Models/Company/CompanyRaffle.php | 8 +- .../JoinedChildClass.php | 10 +- .../JoinedDerivedChildClass.php | 14 +- .../JoinedDerivedIdentityClass.php | 15 +- .../JoinedDerivedRootClass.php | 23 +- .../JoinedRootClass.php | 18 +- .../SingleChildClass.php | 10 +- .../SingleRootClass.php | 18 +- .../CustomType/CustomIdObjectTypeChild.php | 14 +- .../CustomType/CustomIdObjectTypeParent.php | 14 +- .../Models/CustomType/CustomTypeChild.php | 14 +- .../Models/CustomType/CustomTypeParent.php | 29 +- .../Models/CustomType/CustomTypeUpperCase.php | 16 +- .../Models/DDC117/DDC117ApproveChanges.php | 36 +-- .../Tests/Models/DDC117/DDC117Article.php | 20 +- .../Models/DDC117/DDC117ArticleDetails.php | 10 +- .../Tests/Models/DDC117/DDC117Editor.php | 34 +-- .../Tests/Models/DDC117/DDC117Link.php | 19 +- .../Tests/Models/DDC117/DDC117Reference.php | 18 +- .../Tests/Models/DDC117/DDC117Translation.php | 20 +- .../Tests/Models/DDC1590/DDC1590Entity.php | 14 +- .../Tests/Models/DDC1590/DDC1590User.php | 8 +- .../Tests/Models/DDC1872/DDC1872Bar.php | 8 +- .../DDC1872ExampleEntityWithOverride.php | 24 +- .../DDC1872ExampleEntityWithoutOverride.php | 2 +- .../Models/DDC1872/DDC1872ExampleTrait.php | 10 +- .../Tests/Models/DDC2372/DDC2372Address.php | 18 +- .../Tests/Models/DDC2372/DDC2372Admin.php | 6 +- .../Tests/Models/DDC2372/DDC2372User.php | 16 +- .../Traits/DDC2372AddressAndAccessors.php | 4 +- .../Models/DDC2504/DDC2504ChildClass.php | 2 +- .../Models/DDC2504/DDC2504OtherClass.php | 10 +- .../Tests/Models/DDC2504/DDC2504RootClass.php | 21 +- .../Tests/Models/DDC3231/DDC3231User1.php | 14 +- .../DDC3231/DDC3231User1NoNamespace.php | 14 +- .../Tests/Models/DDC3231/DDC3231User2.php | 14 +- .../DDC3231/DDC3231User2NoNamespace.php | 14 +- .../Tests/Models/DDC3346/DDC3346Article.php | 16 +- .../Tests/Models/DDC3346/DDC3346Author.php | 16 +- .../Tests/Models/DDC3579/DDC3579Group.php | 2 +- .../Tests/Models/DDC3597/DDC3597Image.php | 5 +- .../Tests/Models/DDC3597/DDC3597Media.php | 9 +- .../Tests/Models/DDC3597/DDC3597Root.php | 27 +- .../DDC3597/Embeddable/DDC3597Dimension.php | 7 +- .../Tests/Models/DDC3699/DDC3699Child.php | 16 +- .../Tests/Models/DDC3699/DDC3699Parent.php | 4 +- .../Models/DDC3699/DDC3699RelationMany.php | 12 +- .../Models/DDC3699/DDC3699RelationOne.php | 12 +- .../Tests/Models/DDC3899/DDC3899Contract.php | 23 +- .../Models/DDC3899/DDC3899FixContract.php | 4 +- .../Models/DDC3899/DDC3899FlexContract.php | 6 +- .../Tests/Models/DDC3899/DDC3899User.php | 12 +- .../Tests/Models/DDC4006/DDC4006User.php | 4 +- .../Tests/Models/DDC4006/DDC4006UserId.php | 10 +- .../Tests/Models/DDC6412/DDC6412File.php | 8 +- .../DDC753EntityWithCustomRepository.php | 10 +- ...DC753EntityWithDefaultCustomRepository.php | 10 +- .../DDC753EntityWithInvalidRepository.php | 10 +- .../Tests/Models/DDC889/DDC889Class.php | 6 +- .../Tests/Models/DDC964/DDC964Address.php | 18 +- .../Tests/Models/DDC964/DDC964Group.php | 14 +- .../DirectoryTree/AbstractContentItem.php | 14 +- .../Tests/Models/DirectoryTree/Directory.php | 4 +- .../Tests/Models/DirectoryTree/File.php | 8 +- .../Tests/Models/ECommerce/ECommerceCart.php | 30 +-- .../Models/ECommerce/ECommerceCategory.php | 25 +- .../Models/ECommerce/ECommerceCustomer.php | 22 +- .../Models/ECommerce/ECommerceFeature.php | 21 +- .../Models/ECommerce/ECommerceProduct.php | 41 ++- .../Models/ECommerce/ECommerceShipping.php | 15 +- .../Tests/Models/Forum/ForumAdministrator.php | 4 +- .../Tests/Models/Forum/ForumAvatar.php | 12 +- .../Tests/Models/Forum/ForumBoard.php | 15 +- .../Tests/Models/Forum/ForumCategory.php | 18 +- .../Tests/Models/Forum/ForumEntry.php | 14 +- .../Doctrine/Tests/Models/Forum/ForumUser.php | 18 +- .../Tests/Models/GH8565/GH8565Employee.php | 8 +- .../Tests/Models/GH8565/GH8565Manager.php | 8 +- .../Tests/Models/GH8565/GH8565Person.php | 22 +- .../Tests/Models/Generic/BooleanModel.php | 14 +- .../Tests/Models/Generic/DateTimeModel.php | 18 +- .../Tests/Models/Generic/DecimalModel.php | 16 +- .../Models/Generic/NonAlphaColumnsEntity.php | 14 +- .../Models/Generic/SerializationModel.php | 16 +- .../Doctrine/Tests/Models/GeoNames/Admin1.php | 32 +-- .../Models/GeoNames/Admin1AlternateName.php | 30 +-- tests/Doctrine/Tests/Models/GeoNames/City.php | 34 +-- .../Tests/Models/GeoNames/Country.php | 18 +- .../Models/Global/GlobalNamespaceModel.php | 49 ++-- .../EntityWithArrayDefaultArrayValueM2M.php | 10 +- .../Tests/Models/Hydration/SimpleEntity.php | 8 +- .../Models/Issue5989/Issue5989Employee.php | 8 +- .../Models/Issue5989/Issue5989Manager.php | 8 +- .../Models/Issue5989/Issue5989Person.php | 22 +- .../AnotherChildClass.php | 2 +- .../JoinedInheritanceType/ChildClass.php | 2 +- .../JoinedInheritanceType/RootClass.php | 12 +- .../Tests/Models/Legacy/LegacyArticle.php | 20 +- .../Tests/Models/Legacy/LegacyCar.php | 16 +- .../Tests/Models/Legacy/LegacyUser.php | 30 +-- .../Models/Legacy/LegacyUserReference.php | 26 +- .../Models/ManyToManyPersister/ChildClass.php | 35 +-- .../ManyToManyPersister/OtherParentClass.php | 12 +- .../ManyToManyPersister/ParentClass.php | 14 +- .../CompositeToOneKeyState.php | 14 +- .../Models/MixedToOneIdentity/Country.php | 8 +- .../Tests/Models/Navigation/NavCountry.php | 18 +- .../Tests/Models/Navigation/NavPhotos.php | 26 +- .../Models/Navigation/NavPointOfInterest.php | 36 +-- .../Tests/Models/Navigation/NavTour.php | 30 +-- .../Tests/Models/Navigation/NavUser.php | 16 +- .../Models/NonPublicSchemaJoins/User.php | 23 +- .../Models/NullDefault/NullDefaultColumn.php | 10 +- .../OneToOneInverseSideLoad/InverseSide.php | 14 +- .../OneToOneInverseSideLoad/OwningSide.php | 16 +- .../OneToOneSingleTableInheritance/Cat.php | 4 +- .../LitterBox.php | 12 +- .../OneToOneSingleTableInheritance/Pet.php | 16 +- .../Tests/Models/Pagination/Company.php | 19 +- .../Tests/Models/Pagination/Department.php | 15 +- .../Doctrine/Tests/Models/Pagination/Logo.php | 21 +- .../Doctrine/Tests/Models/Pagination/User.php | 22 +- .../Tests/Models/Pagination/User1.php | 4 +- .../PersistentCollectionContent.php | 8 +- .../PersistentCollectionHolder.php | 10 +- .../PersistentObject/PersistentEntity.php | 12 +- tests/Doctrine/Tests/Models/Quote/Address.php | 24 +- tests/Doctrine/Tests/Models/Quote/City.php | 14 +- .../Tests/Models/Quote/FullAddress.php | 6 +- tests/Doctrine/Tests/Models/Quote/Group.php | 22 +- .../Tests/Models/Quote/NumericEntity.php | 14 +- tests/Doctrine/Tests/Models/Quote/Phone.php | 14 +- tests/Doctrine/Tests/Models/Quote/User.php | 40 +-- .../Tests/Models/Routing/RoutingLeg.php | 20 +- .../Tests/Models/Routing/RoutingLocation.php | 10 +- .../Tests/Models/Routing/RoutingRoute.php | 24 +- .../Models/Routing/RoutingRouteBooking.php | 14 +- .../Tests/Models/StockExchange/Bond.php | 19 +- .../Tests/Models/StockExchange/Market.php | 18 +- .../Tests/Models/StockExchange/Stock.php | 21 +- tests/Doctrine/Tests/Models/Taxi/Car.php | 20 +- tests/Doctrine/Tests/Models/Taxi/Driver.php | 20 +- tests/Doctrine/Tests/Models/Taxi/PaidRide.php | 23 +- tests/Doctrine/Tests/Models/Taxi/Ride.php | 21 +- tests/Doctrine/Tests/Models/Tweet/Tweet.php | 16 +- tests/Doctrine/Tests/Models/Tweet/User.php | 18 +- .../Doctrine/Tests/Models/Tweet/UserList.php | 16 +- .../ValueConversionType/AuxiliaryEntity.php | 10 +- .../InversedManyToManyCompositeIdEntity.php | 16 +- ...dManyToManyCompositeIdForeignKeyEntity.php | 18 +- .../InversedManyToManyEntity.php | 12 +- .../InversedManyToManyExtraLazyEntity.php | 17 +- .../InversedOneToManyCompositeIdEntity.php | 18 +- ...edOneToManyCompositeIdForeignKeyEntity.php | 20 +- .../InversedOneToManyEntity.php | 14 +- .../InversedOneToManyExtraLazyEntity.php | 17 +- .../InversedOneToOneCompositeIdEntity.php | 18 +- ...sedOneToOneCompositeIdForeignKeyEntity.php | 20 +- .../InversedOneToOneEntity.php | 14 +- .../OwningManyToManyCompositeIdEntity.php | 25 +- ...gManyToManyCompositeIdForeignKeyEntity.php | 25 +- .../OwningManyToManyEntity.php | 21 +- .../OwningManyToManyExtraLazyEntity.php | 26 +- .../OwningManyToOneCompositeIdEntity.php | 18 +- ...ngManyToOneCompositeIdForeignKeyEntity.php | 18 +- .../OwningManyToOneEntity.php | 14 +- .../OwningManyToOneExtraLazyEntity.php | 14 +- .../OwningManyToOneIdForeignKeyEntity.php | 12 +- .../OwningOneToOneCompositeIdEntity.php | 18 +- ...ingOneToOneCompositeIdForeignKeyEntity.php | 24 +- .../OwningOneToOneEntity.php | 14 +- .../Models/VersionedManyToOne/Article.php | 20 +- .../Models/VersionedManyToOne/Category.php | 16 +- .../VersionedOneToOne/FirstRelatedEntity.php | 18 +- .../VersionedOneToOne/SecondRelatedEntity.php | 18 +- .../Functional/AdvancedAssociationTest.php | 114 +++----- .../ORM/Functional/CascadeRemoveOrderTest.php | 39 +-- .../ClassTableInheritanceSecondTest.php | 58 ++-- .../ORM/Functional/DefaultValuesTest.php | 39 ++- .../Tests/ORM/Functional/GH5988Test.php | 22 +- .../ORM/Functional/LifecycleCallbackTest.php | 124 ++++----- .../ORM/Functional/Locking/OptimisticTest.php | 70 +++-- .../Tests/ORM/Functional/NotifyPolicyTest.php | 32 +-- .../Functional/OneToOneEagerLoadingTest.php | 64 ++--- ...OneToOneSelfReferentialAssociationTest.php | 22 +- ...edJoinedTableInheritanceCollectionTest.php | 41 ++- .../QueryBuilderParenthesisTest.php | 14 +- .../Tests/ORM/Functional/ReadOnlyTest.php | 12 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 12 +- .../SchemaTool/MySqlSchemaToolTest.php | 12 +- .../SchemaTool/PostgreSqlSchemaToolTest.php | 38 ++- .../ORM/Functional/SequenceGeneratorTest.php | 10 +- .../ORM/Functional/Ticket/DDC1080Test.php | 58 ++-- .../ORM/Functional/Ticket/DDC1113Test.php | 30 +-- .../ORM/Functional/Ticket/DDC1163Test.php | 50 ++-- .../ORM/Functional/Ticket/DDC1181Test.php | 36 ++- .../ORM/Functional/Ticket/DDC1193Test.php | 28 +- .../ORM/Functional/Ticket/DDC1209Test.php | 38 ++- .../ORM/Functional/Ticket/DDC1225Test.php | 28 +- .../ORM/Functional/Ticket/DDC1228Test.php | 22 +- .../ORM/Functional/Ticket/DDC1238Test.php | 12 +- .../ORM/Functional/Ticket/DDC1250Test.php | 14 +- .../ORM/Functional/Ticket/DDC1300Test.php | 27 +- .../ORM/Functional/Ticket/DDC1335Test.php | 30 +-- .../ORM/Functional/Ticket/DDC1400Test.php | 34 +-- .../ORM/Functional/Ticket/DDC1430Test.php | 30 +-- .../ORM/Functional/Ticket/DDC1436Test.php | 12 +- .../ORM/Functional/Ticket/DDC144Test.php | 28 +- .../ORM/Functional/Ticket/DDC1452Test.php | 24 +- .../ORM/Functional/Ticket/DDC1454Test.php | 16 +- .../ORM/Functional/Ticket/DDC1458Test.php | 24 +- .../ORM/Functional/Ticket/DDC1461Test.php | 28 +- .../ORM/Functional/Ticket/DDC1514Test.php | 36 +-- .../ORM/Functional/Ticket/DDC1515Test.php | 16 +- .../ORM/Functional/Ticket/DDC1526Test.php | 12 +- .../ORM/Functional/Ticket/DDC1548Test.php | 24 +- .../ORM/Functional/Ticket/DDC1595Test.php | 43 ++- .../ORM/Functional/Ticket/DDC1654Test.php | 19 +- .../ORM/Functional/Ticket/DDC1655Test.php | 41 ++- .../ORM/Functional/Ticket/DDC1690Test.php | 32 +-- .../ORM/Functional/Ticket/DDC1695Test.php | 48 ++-- .../ORM/Functional/Ticket/DDC1707Test.php | 20 +- .../ORM/Functional/Ticket/DDC1719Test.php | 14 +- .../ORM/Functional/Ticket/DDC1757Test.php | 40 ++- .../ORM/Functional/Ticket/DDC1787Test.php | 26 +- .../ORM/Functional/Ticket/DDC1925Test.php | 43 ++- .../ORM/Functional/Ticket/DDC192Test.php | 30 +-- .../ORM/Functional/Ticket/DDC1998Test.php | 8 +- .../ORM/Functional/Ticket/DDC199Test.php | 44 ++- .../ORM/Functional/Ticket/DDC2012Test.php | 29 +- .../ORM/Functional/Ticket/DDC2084Test.php | 30 +-- .../ORM/Functional/Ticket/DDC2106Test.php | 12 +- .../ORM/Functional/Ticket/DDC211Test.php | 40 ++- .../ORM/Functional/Ticket/DDC2138Test.php | 78 +++--- .../ORM/Functional/Ticket/DDC2175Test.php | 20 +- .../ORM/Functional/Ticket/DDC2182Test.php | 30 +-- .../ORM/Functional/Ticket/DDC2214Test.php | 18 +- .../ORM/Functional/Ticket/DDC2224Test.php | 10 +- .../ORM/Functional/Ticket/DDC2230Test.php | 22 +- .../ORM/Functional/Ticket/DDC2252Test.php | 76 +++--- .../ORM/Functional/Ticket/DDC2306Test.php | 44 +-- .../ORM/Functional/Ticket/DDC2346Test.php | 30 +-- .../ORM/Functional/Ticket/DDC2350Test.php | 20 +- .../ORM/Functional/Ticket/DDC2359Test.php | 8 +- .../ORM/Functional/Ticket/DDC237Test.php | 50 ++-- .../ORM/Functional/Ticket/DDC2494Test.php | 34 +-- .../ORM/Functional/Ticket/DDC2575Test.php | 38 ++- .../ORM/Functional/Ticket/DDC2579Test.php | 30 +-- .../ORM/Functional/Ticket/DDC258Test.php | 39 ++- .../ORM/Functional/Ticket/DDC2602Test.php | 69 ++--- .../ORM/Functional/Ticket/DDC2660Test.php | 44 ++- .../ORM/Functional/Ticket/DDC2692Test.php | 12 +- .../ORM/Functional/Ticket/DDC2759Test.php | 60 ++--- .../ORM/Functional/Ticket/DDC2775Test.php | 60 ++--- .../ORM/Functional/Ticket/DDC2780Test.php | 20 +- .../ORM/Functional/Ticket/DDC279Test.php | 48 ++-- .../ORM/Functional/Ticket/DDC2862Test.php | 38 ++- .../ORM/Functional/Ticket/DDC2895Test.php | 26 +- .../ORM/Functional/Ticket/DDC2931Test.php | 14 +- .../ORM/Functional/Ticket/DDC2984Test.php | 16 +- .../ORM/Functional/Ticket/DDC2996Test.php | 28 +- .../ORM/Functional/Ticket/DDC3033Test.php | 47 ++-- .../ORM/Functional/Ticket/DDC3042Test.php | 36 +-- .../ORM/Functional/Ticket/DDC309Test.php | 16 +- .../ORM/Functional/Ticket/DDC3103Test.php | 4 +- .../ORM/Functional/Ticket/DDC3170Test.php | 36 ++- .../ORM/Functional/Ticket/DDC3192Test.php | 34 +-- .../ORM/Functional/Ticket/DDC3223Test.php | 54 ++-- .../ORM/Functional/Ticket/DDC3300Test.php | 27 +- .../ORM/Functional/Ticket/DDC3303Test.php | 28 +- .../ORM/Functional/Ticket/DDC3330Test.php | 30 +-- .../ORM/Functional/Ticket/DDC345Test.php | 57 ++-- .../ORM/Functional/Ticket/DDC353Test.php | 26 +- .../ORM/Functional/Ticket/DDC3582Test.php | 22 +- .../ORM/Functional/Ticket/DDC3634Test.php | 27 +- .../ORM/Functional/Ticket/DDC3644Test.php | 52 ++-- .../ORM/Functional/Ticket/DDC371Test.php | 30 +-- .../ORM/Functional/Ticket/DDC3785Test.php | 44 ++- .../ORM/Functional/Ticket/DDC381Test.php | 8 +- .../ORM/Functional/Ticket/DDC422Test.php | 36 ++- .../ORM/Functional/Ticket/DDC425Test.php | 10 +- .../ORM/Functional/Ticket/DDC440Test.php | 44 ++- .../ORM/Functional/Ticket/DDC444Test.php | 16 +- .../ORM/Functional/Ticket/DDC448Test.php | 47 ++-- .../ORM/Functional/Ticket/DDC493Test.php | 32 ++- .../ORM/Functional/Ticket/DDC512Test.php | 30 +-- .../ORM/Functional/Ticket/DDC513Test.php | 32 ++- .../ORM/Functional/Ticket/DDC522Test.php | 40 +-- .../ORM/Functional/Ticket/DDC531Test.php | 24 +- .../ORM/Functional/Ticket/DDC5684Test.php | 12 +- .../ORM/Functional/Ticket/DDC588Test.php | 10 +- .../ORM/Functional/Ticket/DDC599Test.php | 34 ++- .../ORM/Functional/Ticket/DDC618Test.php | 22 +- .../ORM/Functional/Ticket/DDC6303Test.php | 35 +-- .../ORM/Functional/Ticket/DDC633Test.php | 20 +- .../ORM/Functional/Ticket/DDC6460Test.php | 24 +- .../ORM/Functional/Ticket/DDC656Test.php | 12 +- .../ORM/Functional/Ticket/DDC698Test.php | 42 ++- .../Tests/ORM/Functional/Ticket/DDC69Test.php | 70 ++--- .../ORM/Functional/Ticket/DDC719Test.php | 30 +-- .../ORM/Functional/Ticket/DDC735Test.php | 25 +- .../ORM/Functional/Ticket/DDC809Test.php | 36 +-- .../ORM/Functional/Ticket/DDC832Test.php | 52 ++-- .../ORM/Functional/Ticket/DDC837Test.php | 53 ++-- .../ORM/Functional/Ticket/DDC881Test.php | 54 ++-- .../ORM/Functional/Ticket/DDC960Test.php | 29 +- .../ORM/Functional/Ticket/DDC992Test.php | 42 ++- .../ORM/Functional/Ticket/GH2947Test.php | 14 +- .../ORM/Functional/Ticket/GH5562Test.php | 42 ++- .../ORM/Functional/Ticket/GH5762Test.php | 58 ++-- .../ORM/Functional/Ticket/GH5804Test.php | 16 +- .../ORM/Functional/Ticket/GH5887Test.php | 28 +- .../ORM/Functional/Ticket/GH6029Test.php | 48 ++-- .../ORM/Functional/Ticket/GH6141Test.php | 25 +- .../ORM/Functional/Ticket/GH6217Test.php | 34 +-- .../ORM/Functional/Ticket/GH6362Test.php | 44 ++- .../ORM/Functional/Ticket/GH6394Test.php | 28 +- .../ORM/Functional/Ticket/GH6464Test.php | 28 +- .../ORM/Functional/Ticket/GH6531Test.php | 74 +++--- .../ORM/Functional/Ticket/GH6823Test.php | 71 ++--- .../ORM/Functional/Ticket/GH6937Test.php | 26 +- .../ORM/Functional/Ticket/GH7012Test.php | 16 +- .../ORM/Functional/Ticket/GH7062Test.php | 62 ++--- .../ORM/Functional/Ticket/GH7067Test.php | 18 +- .../ORM/Functional/Ticket/GH7068Test.php | 8 +- .../ORM/Functional/Ticket/GH7079Test.php | 30 +-- .../ORM/Functional/Ticket/GH7259Test.php | 48 ++-- .../ORM/Functional/Ticket/GH7286Test.php | 12 +- .../ORM/Functional/Ticket/GH7366Test.php | 14 +- .../Ticket/GH7496WithToIterableTest.php | 40 ++- .../ORM/Functional/Ticket/GH7505Test.php | 29 +- .../ORM/Functional/Ticket/GH7512Test.php | 31 +-- .../ORM/Functional/Ticket/GH7629Test.php | 12 +- .../ORM/Functional/Ticket/GH7661Test.php | 30 +-- .../ORM/Functional/Ticket/GH7735Test.php | 58 ++-- .../ORM/Functional/Ticket/GH7737Test.php | 24 +- .../ORM/Functional/Ticket/GH7761Test.php | 34 ++- .../ORM/Functional/Ticket/GH7767Test.php | 28 +- .../ORM/Functional/Ticket/GH7820Test.php | 10 +- .../ORM/Functional/Ticket/GH7836Test.php | 30 +-- .../ORM/Functional/Ticket/GH7864Test.php | 24 +- .../ORM/Functional/Ticket/GH7869Test.php | 20 +- .../ORM/Functional/Ticket/GH7875Test.php | 24 +- .../ORM/Functional/Ticket/GH7941Test.php | 18 +- .../ORM/Functional/Ticket/GH8055Test.php | 25 +- .../ORM/Functional/Ticket/GH8061Test.php | 10 +- .../ORM/Functional/Ticket/GH8217Test.php | 27 +- .../ORM/Functional/Ticket/GH8443Test.php | 28 +- .../ORM/Functional/Ticket/GH8499Test.php | 20 +- .../ORM/Functional/Ticket/GH8663Test.php | 12 +- .../ORM/Functional/Ticket/GH8914Test.php | 20 +- .../ORM/Functional/Ticket/GH9027Test.php | 22 +- .../ORM/Functional/Ticket/GH9109Test.php | 28 +- .../ORM/Functional/Ticket/GH9230Test.php | 18 +- .../ORM/Functional/Ticket/GH9335Test.php | 20 +- .../ORM/Functional/Ticket/GH9579Test.php | 52 ++-- .../ORM/Functional/Ticket/GH9807Test.php | 25 +- .../ORM/Functional/Ticket/Ticket2481Test.php | 16 +- .../Ticket4646InstanceOfAbstractTest.php | 28 +- .../Ticket4646InstanceOfMultiLevelTest.php | 36 +-- .../Ticket4646InstanceOfParametricTest.php | 29 +- .../Ticket/Ticket4646InstanceOfTest.php | 29 +- ...46InstanceOfWithMultipleParametersTest.php | 43 +-- .../Tests/ORM/Functional/ValueObjectsTest.php | 152 +++++------ .../Tests/ORM/Id/AssignedGeneratorTest.php | 16 +- .../Mapping/BasicInheritanceMappingTest.php | 122 ++++----- .../ORM/Mapping/ClassMetadataFactoryTest.php | 18 +- .../Mapping/ClassMetadataLoadEventTest.php | 16 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 4 +- .../ORM/Mapping/MappingDriverTestCase.php | 38 ++- tests/Doctrine/Tests/ORM/ORMSetupTest.php | 2 +- .../ORM/Query/LanguageRecognitionTest.php | 24 +- .../ORM/Query/SelectSqlGenerationTest.php | 18 +- .../AttachEntityListenersListenerTest.php | 20 +- .../Command/SchemaTool/Models/Keyboard.php | 14 +- .../ORM/Tools/Console/MetadataFilterTest.php | 36 +-- .../Tools/Pagination/PaginationTestCase.php | 141 +++++----- .../Tools/ResolveTargetEntityListenerTest.php | 32 +-- .../Tests/ORM/Tools/SchemaToolTest.php | 103 +++----- .../Tests/ORM/Tools/SchemaValidatorTest.php | 250 ++++++++---------- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 101 ++++--- 422 files changed, 4602 insertions(+), 6131 deletions(-) diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index 8e17aeedd30..07cf96e84c6 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -27,20 +27,20 @@ class CmsAddress /** * @var string - * @Column(length=50) */ + #[Column(length: 50)] public $country; /** * @var string - * @Column(length=50) */ + #[Column(length: 50)] public $zip; /** * @var string - * @Column(length=50) */ + #[Column(length: 50)] public $city; /** @@ -52,9 +52,9 @@ class CmsAddress /** * @var CmsUser - * @OneToOne(targetEntity="CmsUser", inversedBy="address") - * @JoinColumn(referencedColumnName="id") */ + #[OneToOne(targetEntity: 'CmsUser', inversedBy: 'address')] + #[JoinColumn(referencedColumnName: 'id')] public $user; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php index d7130ed7634..a4a9b6b9cbf 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php @@ -15,50 +15,48 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\Version; -/** - * @Entity - * @Table(name="cms_articles") - */ +#[Table(name: 'cms_articles')] +#[Entity] class CmsArticle { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $topic; /** * @var string - * @Column(type="text") */ + #[Column(type: 'text')] public $text; /** * @var CmsUser - * @ManyToOne(targetEntity="CmsUser", inversedBy="articles") - * @JoinColumn(name="user_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'CmsUser', inversedBy: 'articles')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; /** * @var Collection - * @OneToMany(targetEntity="CmsComment", mappedBy="article") */ + #[OneToMany(targetEntity: 'CmsComment', mappedBy: 'article')] public $comments; /** * @var int - * @Version - * @Column(type="integer") */ + #[Version] + #[Column(type: 'integer')] public $version; public function setAuthor(CmsUser $author): void diff --git a/tests/Doctrine/Tests/Models/CMS/CmsComment.php b/tests/Doctrine/Tests/Models/CMS/CmsComment.php index 7c042173c45..d6db1cbba92 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsComment.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsComment.php @@ -13,37 +13,35 @@ use Doctrine\ORM\Mapping\Table; use Stringable; -/** - * @Entity - * @Table(name="cms_comments") - */ +#[Table(name: 'cms_comments')] +#[Entity] class CmsComment implements Stringable { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $topic; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $text; /** * @var CmsArticle - * @ManyToOne(targetEntity="CmsArticle", inversedBy="comments") - * @JoinColumn(name="article_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'CmsArticle', inversedBy: 'comments')] + #[JoinColumn(name: 'article_id', referencedColumnName: 'id')] public $article; public function setArticle(CmsArticle $article): void diff --git a/tests/Doctrine/Tests/Models/CMS/CmsEmail.php b/tests/Doctrine/Tests/Models/CMS/CmsEmail.php index 8d30291802b..e494732e387 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsEmail.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsEmail.php @@ -13,30 +13,29 @@ /** * CmsEmail - * - * @Entity - * @Table(name="cms_emails") */ +#[Table(name: 'cms_emails')] +#[Entity] class CmsEmail { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; /** * @var string - * @Column(length=250) */ + #[Column(length: 250)] public $email; /** * @var CmsUser - * @OneToOne(targetEntity="CmsUser", mappedBy="email") */ + #[OneToOne(targetEntity: 'CmsUser', mappedBy: 'email')] public $user; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php b/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php index 8601504bc6c..e7c653f23ff 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php @@ -14,26 +14,21 @@ /** * Description of CmsEmployee - * - * @Entity - * @Table(name="cms_employees") */ +#[Table(name: 'cms_employees')] +#[Entity] class CmsEmployee { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column */ + #[Column] private string $name; - /** - * @OneToOne(targetEntity="CmsEmployee") - * @JoinColumn(name="spouse_id", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'CmsEmployee')] + #[JoinColumn(name: 'spouse_id', referencedColumnName: 'id')] private CmsEmployee $spouse; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php index d7e284f499c..d7f7454bbe5 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php @@ -16,30 +16,29 @@ /** * Description of CmsGroup - * - * @Entity - * @Table(name="cms_groups") */ +#[Table(name: 'cms_groups')] +#[Entity] class CmsGroup implements IteratorAggregate { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(length=50) */ + #[Column(length: 50)] public $name; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CmsUser", mappedBy="groups") */ + #[ManyToMany(targetEntity: 'CmsUser', mappedBy: 'groups')] public $users; public function __construct() diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php b/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php index 761328753b4..e52fd9fd1e8 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php @@ -11,24 +11,22 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="cms_phonenumbers") - */ +#[Table(name: 'cms_phonenumbers')] +#[Entity] class CmsPhonenumber { /** * @var string - * @Id - * @Column(length=50) */ + #[Id] + #[Column(length: 50)] public $phonenumber; /** * @var CmsUser - * @ManyToOne(targetEntity="CmsUser", inversedBy="phonenumbers", cascade={"merge"}) - * @JoinColumn(name="user_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'CmsUser', inversedBy: 'phonenumbers', cascade: ['merge'])] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; public function setUser(CmsUser $user): void diff --git a/tests/Doctrine/Tests/Models/CMS/CmsTag.php b/tests/Doctrine/Tests/Models/CMS/CmsTag.php index aa0325dafda..a56c3028463 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsTag.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsTag.php @@ -14,30 +14,29 @@ /** * Description of CmsTag - * - * @Entity - * @Table(name="cms_tags") */ +#[Table(name: 'cms_tags')] +#[Entity] class CmsTag { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(length=50, name="tag_name", nullable=true) */ + #[Column(length: 50, name: 'tag_name', nullable: true)] public $name; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CmsUser", mappedBy="tags") */ + #[ManyToMany(targetEntity: 'CmsUser', mappedBy: 'tags')] public $users; public function setName(string $name): void diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Doctrine/Tests/Models/CMS/CmsUser.php index d7c63046c57..191cd6f7445 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\CMS; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadata; @@ -18,81 +19,77 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="cms_users") - */ +#[Table(name: 'cms_users')] +#[Entity] class CmsUser { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=50, nullable=true) */ + #[Column(type: 'string', length: 50, nullable: true)] public $status; /** * @var string - * @Column(type="string", length=255, unique=true) */ + #[Column(type: 'string', length: 255, unique: true)] public $username; /** * @psalm-var string|null - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="CmsPhonenumber", mappedBy="user", cascade={"persist", "merge"}, orphanRemoval=true) */ + #[OneToMany(targetEntity: 'CmsPhonenumber', mappedBy: 'user', cascade: ['persist', 'merge'], orphanRemoval: true)] public $phonenumbers; /** * @psalm-var Collection - * @OneToMany(targetEntity="CmsArticle", mappedBy="user", cascade={"detach"}) */ + #[OneToMany(targetEntity: 'CmsArticle', mappedBy: 'user', cascade: ['detach'])] public $articles; /** * @var CmsAddress - * @OneToOne(targetEntity="CmsAddress", mappedBy="user", cascade={"persist"}, orphanRemoval=true) */ + #[OneToOne(targetEntity: 'CmsAddress', mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] public $address; /** * @var CmsEmail - * @OneToOne(targetEntity="CmsEmail", inversedBy="user", cascade={"persist"}, orphanRemoval=true) - * @JoinColumn(referencedColumnName="id", nullable=true) */ + #[OneToOne(targetEntity: 'CmsEmail', inversedBy: 'user', cascade: ['persist'], orphanRemoval: true)] + #[JoinColumn(referencedColumnName: 'id', nullable: true)] public $email; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CmsGroup", inversedBy="users", cascade={"persist", "merge", "detach"}) - * @JoinTable(name="cms_users_groups", - * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'cms_users_groups')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'CmsGroup', inversedBy: 'users', cascade: ['persist', 'merge', 'detach'])] public $groups; /** * @var Collection - * @ManyToMany(targetEntity="CmsTag", inversedBy="users", cascade={"all"}) - * @JoinTable(name="cms_users_tags", - * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="tag_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'cms_users_tags')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'CmsTag', inversedBy: 'users', cascade: ['all'])] public $tags; /** @var mixed */ diff --git a/tests/Doctrine/Tests/Models/Cache/Action.php b/tests/Doctrine/Tests/Models/Cache/Action.php index 3d66a46e0c9..68760a63b22 100644 --- a/tests/Doctrine/Tests/Models/Cache/Action.php +++ b/tests/Doctrine/Tests/Models/Cache/Action.php @@ -13,24 +13,20 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_action") - */ +#[Table('cache_action')] +#[Entity] class Action { /** * @psalm-var Collection - * @OneToMany(targetEntity="Token", cascade={"persist", "remove"}, mappedBy="action") */ + #[OneToMany(targetEntity: 'Token', cascade: ['persist', 'remove'], mappedBy: 'action')] public $tokens; public function __construct( - /** - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] public string $name, ) { $this->tokens = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Cache/Address.php b/tests/Doctrine/Tests/Models/Cache/Address.php index 2f7457d893e..4980b9f95f5 100644 --- a/tests/Doctrine/Tests/Models/Cache/Address.php +++ b/tests/Doctrine/Tests/Models/Cache/Address.php @@ -12,29 +12,27 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_client_address") - */ +#[Table('cache_client_address')] +#[Entity] class Address { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var Person - * @JoinColumn(name="person_id", referencedColumnName="id") - * @OneToOne(targetEntity="Person", inversedBy="address") */ + #[JoinColumn(name: 'person_id', referencedColumnName: 'id')] + #[OneToOne(targetEntity: 'Person', inversedBy: 'address')] public $person; public function __construct( - /** @Column */ + #[Column] public string $location, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/Attraction.php b/tests/Doctrine/Tests/Models/Cache/Attraction.php index 06e208c5627..7722900a7b1 100644 --- a/tests/Doctrine/Tests/Models/Cache/Attraction.php +++ b/tests/Doctrine/Tests/Models/Cache/Attraction.php @@ -18,42 +18,34 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Cache("NONSTRICT_READ_WRITE") - * @Entity - * @Table("cache_attraction") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({ - * 1 = "Restaurant", - * 2 = "Beach", - * 3 = "Bar" - * }) - */ +#[Table('cache_attraction')] +#[Cache('NONSTRICT_READ_WRITE')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorMap([1 => 'Restaurant', 2 => 'Beach', 3 => 'Bar'])] abstract class Attraction { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; /** * @psalm-var Collection - * @Cache - * @OneToMany(targetEntity="AttractionInfo", mappedBy="attraction") */ + #[Cache] + #[OneToMany(targetEntity: 'AttractionInfo', mappedBy: 'attraction')] protected $infos; public function __construct( - /** @Column(unique=true) */ + #[Column(unique: true)] protected string $name, - /** - * @Cache - * @ManyToOne(targetEntity="City", inversedBy="attractions") - * @JoinColumn(name="city_id", referencedColumnName="id") - */ + #[Cache] + #[ManyToOne(targetEntity: 'City', inversedBy: 'attractions')] + #[JoinColumn(name: 'city_id', referencedColumnName: 'id')] protected City $city, ) { $this->infos = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php b/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php index 65e6a70e78f..cea2c3da043 100644 --- a/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php @@ -8,16 +8,14 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_attraction_contact_info") - */ +#[Table('cache_attraction_contact_info')] +#[Entity] class AttractionContactInfo extends AttractionInfo { /** * @var string - * @Column(unique=true) */ + #[Column(unique: true)] protected $fone; public function __construct(string $fone, Attraction $attraction) diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php b/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php index bc8e68185fe..07008ac586e 100644 --- a/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php @@ -15,32 +15,27 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Cache - * @Entity - * @Table("cache_attraction_info") - * @InheritanceType("JOINED") - * @DiscriminatorMap({ - * 1 = "AttractionContactInfo", - * 2 = "AttractionLocationInfo", - * }) - */ +#[Table('cache_attraction_info')] +#[Cache] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorMap([1 => 'AttractionContactInfo', 2 => 'AttractionLocationInfo'])] abstract class AttractionInfo { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; /** * @var Attraction - * @Cache - * @ManyToOne(targetEntity="Attraction", inversedBy="infos") - * @JoinColumn(name="attraction_id", referencedColumnName="id") */ + #[Cache] + #[ManyToOne(targetEntity: 'Attraction', inversedBy: 'infos')] + #[JoinColumn(name: 'attraction_id', referencedColumnName: 'id')] protected $attraction; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php b/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php index daf48374e29..d34f7293783 100644 --- a/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php @@ -8,16 +8,14 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_attraction_location_info") - */ +#[Table('cache_attraction_location_info')] +#[Entity] class AttractionLocationInfo extends AttractionInfo { /** * @var string - * @Column(unique=true) */ + #[Column(unique: true)] protected $address; public function __construct(string $address, Attraction $attraction) diff --git a/tests/Doctrine/Tests/Models/Cache/Bar.php b/tests/Doctrine/Tests/Models/Cache/Bar.php index e937370b609..19517107fa2 100644 --- a/tests/Doctrine/Tests/Models/Cache/Bar.php +++ b/tests/Doctrine/Tests/Models/Cache/Bar.php @@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class Bar extends Attraction { } diff --git a/tests/Doctrine/Tests/Models/Cache/Beach.php b/tests/Doctrine/Tests/Models/Cache/Beach.php index 65fdad68827..e09baeab212 100644 --- a/tests/Doctrine/Tests/Models/Cache/Beach.php +++ b/tests/Doctrine/Tests/Models/Cache/Beach.php @@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class Beach extends Attraction { } diff --git a/tests/Doctrine/Tests/Models/Cache/Client.php b/tests/Doctrine/Tests/Models/Cache/Client.php index a0b2ee1d213..25316748440 100644 --- a/tests/Doctrine/Tests/Models/Cache/Client.php +++ b/tests/Doctrine/Tests/Models/Cache/Client.php @@ -10,22 +10,20 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_client") - */ +#[Table('cache_client')] +#[Entity] class Client { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; public function __construct( - /** @Column(unique=true) */ + #[Column(unique: true)] public string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php index 0cb0d4fc984..2e174d651f3 100644 --- a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php +++ b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php @@ -14,34 +14,32 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_complex_action") - */ +#[Table('cache_complex_action')] +#[Entity] class ComplexAction { /** * @psalm-var Collection - * @OneToMany(targetEntity="Token", cascade={"persist", "remove"}, mappedBy="complexAction") */ + #[OneToMany(targetEntity: 'Token', cascade: ['persist', 'remove'], mappedBy: 'complexAction')] public $tokens; public function __construct( /** * @var Action - * @Id - * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) - * @JoinColumn(name="action1_name", referencedColumnName="name") */ + #[Id] + #[OneToOne(targetEntity: 'Action', cascade: ['persist', 'remove'])] + #[JoinColumn(name: 'action1_name', referencedColumnName: 'name')] public $action1, /** * @var Action - * @Id - * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) - * @JoinColumn(name="action2_name", referencedColumnName="name") */ + #[Id] + #[OneToOne(targetEntity: 'Action', cascade: ['persist', 'remove'])] + #[JoinColumn(name: 'action2_name', referencedColumnName: 'name')] public $action2, - /** @Column */ + #[Column] public string $name, ) { $this->tokens = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Cache/Country.php b/tests/Doctrine/Tests/Models/Cache/Country.php index d8fff573bef..772a5dff5a5 100644 --- a/tests/Doctrine/Tests/Models/Cache/Country.php +++ b/tests/Doctrine/Tests/Models/Cache/Country.php @@ -11,23 +11,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Cache - * @Entity - * @Table("cache_country") - */ +#[Table('cache_country')] +#[Cache] +#[Entity] class Country { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; public function __construct( - /** @Column(unique=true) */ + #[Column(unique: true)] protected string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/Flight.php b/tests/Doctrine/Tests/Models/Cache/Flight.php index b24c408deee..c59a142a1df 100644 --- a/tests/Doctrine/Tests/Models/Cache/Flight.php +++ b/tests/Doctrine/Tests/Models/Cache/Flight.php @@ -13,33 +13,27 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_flight") - * @Cache("NONSTRICT_READ_WRITE") - */ +#[Table('cache_flight')] +#[Entity] +#[Cache('NONSTRICT_READ_WRITE')] class Flight { /** * @var DateTime - * @Column(type="date") */ + #[Column(type: 'date')] protected $departure; public function __construct( - /** - * @Id - * @Cache - * @ManyToOne(targetEntity="City") - * @JoinColumn(name="leaving_from_city_id", referencedColumnName="id") - */ + #[Id] + #[Cache] + #[ManyToOne(targetEntity: 'City')] + #[JoinColumn(name: 'leaving_from_city_id', referencedColumnName: 'id')] protected City $leavingFrom, - /** - * @Id - * @Cache - * @ManyToOne(targetEntity="City") - * @JoinColumn(name="going_to_city_id", referencedColumnName="id") - */ + #[Id] + #[Cache] + #[ManyToOne(targetEntity: 'City')] + #[JoinColumn(name: 'going_to_city_id', referencedColumnName: 'id')] protected City $goingTo, ) { $this->departure = new DateTime(); diff --git a/tests/Doctrine/Tests/Models/Cache/Login.php b/tests/Doctrine/Tests/Models/Cache/Login.php index cee0fa19363..9c7705a43f5 100644 --- a/tests/Doctrine/Tests/Models/Cache/Login.php +++ b/tests/Doctrine/Tests/Models/Cache/Login.php @@ -12,29 +12,27 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_login") - */ +#[Table('cache_login')] +#[Entity] class Login { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var Token - * @ManyToOne(targetEntity="Token", cascade={"persist", "remove"}, inversedBy="logins") - * @JoinColumn(name="token_id", referencedColumnName="token") */ + #[ManyToOne(targetEntity: 'Token', cascade: ['persist', 'remove'], inversedBy: 'logins')] + #[JoinColumn(name: 'token_id', referencedColumnName: 'token')] public $token; public function __construct( - /** @Column */ + #[Column] public string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/Person.php b/tests/Doctrine/Tests/Models/Cache/Person.php index c30bd1140c0..201411709d8 100644 --- a/tests/Doctrine/Tests/Models/Cache/Person.php +++ b/tests/Doctrine/Tests/Models/Cache/Person.php @@ -12,29 +12,27 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_person") - * @Cache("NONSTRICT_READ_WRITE") - */ +#[Table('cache_person')] +#[Entity] +#[Cache('NONSTRICT_READ_WRITE')] class Person { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var Address - * @OneToOne(targetEntity="Address", mappedBy="person") */ + #[OneToOne(targetEntity: 'Address', mappedBy: 'person')] public $address; public function __construct( - /** @Column(unique=true) */ + #[Column(unique: true)] public string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/Restaurant.php b/tests/Doctrine/Tests/Models/Cache/Restaurant.php index 595b7e10de3..1eafb56b4e7 100644 --- a/tests/Doctrine/Tests/Models/Cache/Restaurant.php +++ b/tests/Doctrine/Tests/Models/Cache/Restaurant.php @@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class Restaurant extends Attraction { } diff --git a/tests/Doctrine/Tests/Models/Cache/State.php b/tests/Doctrine/Tests/Models/Cache/State.php index d3f093be1fd..05d92786f99 100644 --- a/tests/Doctrine/Tests/Models/Cache/State.php +++ b/tests/Doctrine/Tests/Models/Cache/State.php @@ -16,36 +16,32 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_state") - * @Cache("NONSTRICT_READ_WRITE") - */ +#[Table('cache_state')] +#[Entity] +#[Cache('NONSTRICT_READ_WRITE')] class State { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; /** * @psalm-var Collection - * @Cache("NONSTRICT_READ_WRITE") - * @OneToMany(targetEntity="City", mappedBy="state") */ + #[Cache('NONSTRICT_READ_WRITE')] + #[OneToMany(targetEntity: 'City', mappedBy: 'state')] protected $cities; public function __construct( - /** @Column(unique=true) */ + #[Column(unique: true)] protected string $name, - /** - * @Cache - * @ManyToOne(targetEntity="Country") - * @JoinColumn(name="country_id", referencedColumnName="id") - */ + #[Cache] + #[ManyToOne(targetEntity: 'Country')] + #[JoinColumn(name: 'country_id', referencedColumnName: 'id')] protected Country|null $country = null, ) { $this->cities = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Cache/Token.php b/tests/Doctrine/Tests/Models/Cache/Token.php index d6327011089..68c7ad5cd58 100644 --- a/tests/Doctrine/Tests/Models/Cache/Token.php +++ b/tests/Doctrine/Tests/Models/Cache/Token.php @@ -21,49 +21,43 @@ use function date; use function strtotime; -/** - * @Entity - * @Cache("READ_ONLY") - * @Table("cache_token") - */ +#[Table('cache_token')] +#[Entity] +#[Cache('READ_ONLY')] class Token { /** * @var DateTime - * @Column(type="date") */ + #[Column(type: 'date')] public $expiresAt; /** * @psalm-var Collection - * @OneToMany(targetEntity="Login", cascade={"persist", "remove"}, mappedBy="token") */ + #[OneToMany(targetEntity: 'Login', cascade: ['persist', 'remove'], mappedBy: 'token')] public $logins; /** * @var Action - * @ManyToOne(targetEntity="Action", cascade={"persist", "remove"}, inversedBy="tokens") - * @JoinColumn(name="action_name", referencedColumnName="name") */ + #[ManyToOne(targetEntity: 'Action', cascade: ['persist', 'remove'], inversedBy: 'tokens')] + #[JoinColumn(name: 'action_name', referencedColumnName: 'name')] public $action; /** - * @ManyToOne(targetEntity="ComplexAction", cascade={"persist", "remove"}, inversedBy="tokens") - * @JoinColumns({ - * @JoinColumn(name="complex_action1_name", referencedColumnName="action1_name"), - * @JoinColumn(name="complex_action2_name", referencedColumnName="action2_name") - * }) * @var ComplexAction */ + #[JoinColumn(name: 'complex_action1_name', referencedColumnName: 'action1_name')] + #[JoinColumn(name: 'complex_action2_name', referencedColumnName: 'action2_name')] + #[ManyToOne(targetEntity: 'ComplexAction', cascade: ['persist', 'remove'], inversedBy: 'tokens')] public $complexAction; public function __construct( - /** - * @Id - * @Column(type="string", length=255) - */ + #[Id] + #[Column(type: 'string', length: 255)] public string $token, - /** @OneToOne(targetEntity="Client") */ + #[OneToOne(targetEntity: 'Client')] public Client|null $client = null, ) { $this->logins = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Cache/Travel.php b/tests/Doctrine/Tests/Models/Cache/Travel.php index 545f71d4bf5..9a49f39a7e6 100644 --- a/tests/Doctrine/Tests/Models/Cache/Travel.php +++ b/tests/Doctrine/Tests/Models/Cache/Travel.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Cache; +use Doctrine\ORM\Mapping\InverseJoinColumn; use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; @@ -18,48 +19,39 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Cache - * @Entity - * @Table("cache_travel") - */ +#[Table('cache_travel')] +#[Cache] +#[Entity] class Travel { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; /** * @var DateTime - * @Column(type="date") */ + #[Column(type: 'date')] protected $createdAt; /** * @psalm-var Collection - * @Cache - * @ManyToMany(targetEntity="City", inversedBy="travels", cascade={"persist", "remove"}) - * @JoinTable(name="cache_visited_cities", - * joinColumns={ - * @JoinColumn(name="travel_id", referencedColumnName="id") - * }, - * inverseJoinColumns={ - * @JoinColumn(name="city_id", referencedColumnName="id") - * } - * ) */ + #[JoinTable(name: 'cache_visited_cities')] + #[JoinColumn(name: 'travel_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'city_id', referencedColumnName: 'id')] + #[Cache] + #[ManyToMany(targetEntity: 'City', inversedBy: 'travels', cascade: ['persist', 'remove'])] public $visitedCities; public function __construct( - /** - * @Cache - * @ManyToOne(targetEntity="Traveler", inversedBy="travels") - * @JoinColumn(name="traveler_id", referencedColumnName="id") - */ + #[Cache] + #[ManyToOne(targetEntity: 'Traveler', inversedBy: 'travels')] + #[JoinColumn(name: 'traveler_id', referencedColumnName: 'id')] protected Traveler $traveler, ) { $this->createdAt = new DateTime('now'); diff --git a/tests/Doctrine/Tests/Models/Cache/Traveler.php b/tests/Doctrine/Tests/Models/Cache/Traveler.php index e23d3d6632b..1ec44167ffd 100644 --- a/tests/Doctrine/Tests/Models/Cache/Traveler.php +++ b/tests/Doctrine/Tests/Models/Cache/Traveler.php @@ -15,37 +15,35 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Cache - * @Entity - * @Table("cache_traveler") - */ +#[Table('cache_traveler')] +#[Cache] +#[Entity] class Traveler { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; /** * @psalm-var Collection - * @Cache("NONSTRICT_READ_WRITE") - * @OneToMany(targetEntity="Travel", mappedBy="traveler", cascade={"persist", "remove"}, orphanRemoval=true) */ + #[Cache('NONSTRICT_READ_WRITE')] + #[OneToMany(targetEntity: 'Travel', mappedBy: 'traveler', cascade: ['persist', 'remove'], orphanRemoval: true)] public $travels; /** - * @var TravelerProfile - * @Cache - * @OneToOne(targetEntity="TravelerProfile") - */ + * @var TravelerProfile + */ + #[Cache] + #[OneToOne(targetEntity: 'TravelerProfile')] protected $profile; public function __construct( - /** @Column */ + #[Column] protected string $name, ) { $this->travels = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php index d27c61a4985..7680d50a677 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php @@ -12,29 +12,25 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_traveler_profile") - * @Cache("NONSTRICT_READ_WRITE") - */ +#[Table('cache_traveler_profile')] +#[Entity] +#[Cache('NONSTRICT_READ_WRITE')] class TravelerProfile { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; - /** - * @OneToOne(targetEntity="TravelerProfileInfo", mappedBy="profile") - * @Cache() - */ + #[OneToOne(targetEntity: 'TravelerProfileInfo', mappedBy: 'profile')] + #[Cache] private TravelerProfileInfo|null $info = null; public function __construct( - /** @Column(unique=true) */ + #[Column(unique: true)] private string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php index 909426b63c7..839e5ab868b 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php @@ -13,29 +13,25 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table("cache_traveler_profile_info") - * @Cache("NONSTRICT_READ_WRITE") - */ +#[Table('cache_traveler_profile_info')] +#[Entity] +#[Cache('NONSTRICT_READ_WRITE')] class TravelerProfileInfo { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; public function __construct( - /** - * @Cache() - * @JoinColumn(name="profile_id", referencedColumnName="id") - * @OneToOne(targetEntity="TravelerProfile", inversedBy="info") - */ + #[Cache] + #[JoinColumn(name: 'profile_id', referencedColumnName: 'id')] + #[OneToOne(targetEntity: 'TravelerProfile', inversedBy: 'info')] private TravelerProfile $profile, - /** @Column(unique=true) */ + #[Column(unique: true)] private string $description, ) { } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php b/tests/Doctrine/Tests/Models/Company/CompanyAuction.php index 27a0d3dba6f..5bafabf8e89 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyAuction.php @@ -8,13 +8,11 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="company_auctions") - */ +#[Table(name: 'company_auctions')] +#[Entity] class CompanyAuction extends CompanyEvent { - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string|null $data = null; public function setData(string $data): void diff --git a/tests/Doctrine/Tests/Models/Company/CompanyCar.php b/tests/Doctrine/Tests/Models/Company/CompanyCar.php index 0fc723fc6fc..67ead59dbf2 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyCar.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyCar.php @@ -10,21 +10,17 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="company_cars") - */ +#[Table(name: 'company_cars')] +#[Entity] class CompanyCar { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; public function __construct( - /** @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] private string|null $brand = null, ) { } diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index 53aa792ca17..9523dd2f741 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Company; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Events; @@ -33,20 +34,19 @@ abstract class CompanyContract #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue] private int $id; - /** @ManyToOne(targetEntity="CompanyEmployee", inversedBy="soldContracts") */ + #[ManyToOne(targetEntity: 'CompanyEmployee', inversedBy: 'soldContracts')] private CompanyEmployee|null $salesPerson = null; - /** @Column(type="boolean") */ + #[Column(type: 'boolean')] private bool $completed = false; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CompanyEmployee", inversedBy="contracts") - * @JoinTable(name="company_contract_employees", - * joinColumns={@JoinColumn(name="contract_id", referencedColumnName="id", onDelete="CASCADE")}, - * inverseJoinColumns={@JoinColumn(name="employee_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'company_contract_employees')] + #[JoinColumn(name: 'contract_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[InverseJoinColumn(name: 'employee_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'CompanyEmployee', inversedBy: 'contracts')] private $engineers; public function __construct() diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php index 47281312687..d0e359466b7 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php @@ -12,31 +12,29 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="company_employees") - */ +#[Table(name: 'company_employees')] +#[Entity] class CompanyEmployee extends CompanyPerson { - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int|null $salary = null; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string|null $department = null; - /** @Column(type="datetime", nullable=true) */ + #[Column(type: 'datetime', nullable: true)] private DateTime|null $startDate = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CompanyContract", mappedBy="engineers", fetch="EXTRA_LAZY") */ + #[ManyToMany(targetEntity: 'CompanyContract', mappedBy: 'engineers', fetch: 'EXTRA_LAZY')] public $contracts; /** * @psalm-var Collection - * @OneToMany(targetEntity="CompanyFlexUltraContract", mappedBy="salesPerson", fetch="EXTRA_LAZY") */ + #[OneToMany(targetEntity: 'CompanyFlexUltraContract', mappedBy: 'salesPerson', fetch: 'EXTRA_LAZY')] public $soldContracts; public function getSalary(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php b/tests/Doctrine/Tests/Models/Company/CompanyEvent.php index 378c3a94d4f..22b6fb42f06 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEvent.php @@ -15,26 +15,20 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="company_events") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="event_type", type="string", length=255) - * @DiscriminatorMap({"auction"="CompanyAuction", "raffle"="CompanyRaffle"}) - */ +#[Table(name: 'company_events')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'event_type', type: 'string', length: 255)] +#[DiscriminatorMap(['auction' => 'CompanyAuction', 'raffle' => 'CompanyRaffle'])] abstract class CompanyEvent { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** - * @ManyToOne(targetEntity="CompanyOrganization", inversedBy="events", cascade={"persist"}) - * @JoinColumn(name="org_id", referencedColumnName="id") - */ + #[ManyToOne(targetEntity: 'CompanyOrganization', inversedBy: 'events', cascade: ['persist'])] + #[JoinColumn(name: 'org_id', referencedColumnName: 'id')] private CompanyOrganization|null $organization = null; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php index e48d7887bf3..58532bbf32d 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php @@ -12,7 +12,7 @@ #[ORM\Entity] class CompanyFixContract extends CompanyContract { - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int $fixPrice = 0; public function calculatePrice(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index 6e6a4a3d035..6470f63cdda 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Company; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; @@ -19,27 +20,26 @@ class CompanyFlexContract extends CompanyContract { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int $hoursWorked = 0; - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int $pricePerHour = 0; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CompanyManager", inversedBy="managedContracts", fetch="EXTRA_LAZY") - * @JoinTable(name="company_contract_managers", - * joinColumns={@JoinColumn(name="contract_id", referencedColumnName="id", onDelete="CASCADE")}, - * inverseJoinColumns={@JoinColumn(name="employee_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'company_contract_managers')] + #[JoinColumn(name: 'contract_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[InverseJoinColumn(name: 'employee_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'CompanyManager', inversedBy: 'managedContracts', fetch: 'EXTRA_LAZY')] public $managers; public function calculatePrice(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php index 805de4584d1..c468af13883 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -17,7 +17,7 @@ #[ORM\EntityListeners(['CompanyContractListener', 'CompanyFlexUltraContractListener'])] class CompanyFlexUltraContract extends CompanyFlexContract { - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int $maxPrice = 0; public function calculatePrice(): int diff --git a/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/tests/Doctrine/Tests/Models/Company/CompanyManager.php index 642ee25c598..d3571fabc2c 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyManager.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyManager.php @@ -12,25 +12,21 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="company_managers") - */ +#[Table(name: 'company_managers')] +#[Entity] class CompanyManager extends CompanyEmployee { - /** @Column(type="string", length=250) */ + #[Column(type: 'string', length: 250)] private string|null $title = null; - /** - * @OneToOne(targetEntity="CompanyCar", cascade={"persist"}) - * @JoinColumn(name="car_id", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'CompanyCar', cascade: ['persist'])] + #[JoinColumn(name: 'car_id', referencedColumnName: 'id')] private CompanyCar|null $car = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CompanyFlexContract", mappedBy="managers", fetch="EXTRA_LAZY") */ + #[ManyToMany(targetEntity: 'CompanyFlexContract', mappedBy: 'managers', fetch: 'EXTRA_LAZY')] public $managedContracts; public function getTitle(): string diff --git a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php b/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php index a5c0870bfa8..c00c7aacc17 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php @@ -14,23 +14,19 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="company_organizations") - */ +#[Table(name: 'company_organizations')] +#[Entity] class CompanyOrganization { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="CompanyEvent", mappedBy="organization", cascade={"persist"}, fetch="EXTRA_LAZY") */ + #[OneToMany(targetEntity: 'CompanyEvent', mappedBy: 'organization', cascade: ['persist'], fetch: 'EXTRA_LAZY')] public $events; public function getId(): int @@ -50,10 +46,8 @@ public function addEvent(CompanyEvent $event): void $event->setOrganization($this); } - /** - * @OneToOne(targetEntity="CompanyEvent", cascade={"persist"}) - * @JoinColumn(name="main_event_id", referencedColumnName="id", nullable=true) - */ + #[OneToOne(targetEntity: 'CompanyEvent', cascade: ['persist'])] + #[JoinColumn(name: 'main_event_id', referencedColumnName: 'id', nullable: true)] private CompanyEvent|null $mainevent = null; public function getMainEvent(): CompanyEvent|null diff --git a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php index f35b066bd14..10e89d38144 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Company; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadata; @@ -22,48 +23,33 @@ /** * Description of CompanyPerson - * - * @Entity - * @Table(name="company_persons") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @DiscriminatorMap({ - * "person" = "CompanyPerson", - * "manager" = "CompanyManager", - * "employee" = "CompanyEmployee" - * }) */ +#[Table(name: 'company_persons')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string', length: 255)] +#[DiscriminatorMap(['person' => 'CompanyPerson', 'manager' => 'CompanyManager', 'employee' => 'CompanyEmployee'])] class CompanyPerson { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column */ + #[Column] private string|null $name = null; - /** - * @OneToOne(targetEntity="CompanyPerson") - * @JoinColumn(name="spouse_id", referencedColumnName="id", onDelete="CASCADE") - */ + #[OneToOne(targetEntity: 'CompanyPerson')] + #[JoinColumn(name: 'spouse_id', referencedColumnName: 'id', onDelete: 'CASCADE')] private CompanyPerson|null $spouse = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CompanyPerson") - * @JoinTable( - * name="company_persons_friends", - * joinColumns={ - * @JoinColumn(name="person_id", referencedColumnName="id", onDelete="CASCADE") - * }, - * inverseJoinColumns={ - * @JoinColumn(name="friend_id", referencedColumnName="id", onDelete="CASCADE") - * } - * ) */ + #[JoinTable(name: 'company_persons_friends')] + #[JoinColumn(name: 'person_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[InverseJoinColumn(name: 'friend_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ManyToMany(targetEntity: 'CompanyPerson')] private $friends; public function __construct() diff --git a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php index a0f30f74b79..3826f4f28df 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php @@ -8,13 +8,11 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="company_raffles") - */ +#[Table(name: 'company_raffles')] +#[Entity] class CompanyRaffle extends CompanyEvent { - /** @Column */ + #[Column] private string|null $data = null; public function setData(string $data): void diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php index af4e8c123b5..7499dbef802 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php @@ -8,18 +8,16 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class JoinedChildClass extends JoinedRootClass { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $extension = 'ext'; - /** - * @Column(type="string", length=255) - * @Id - */ + #[Column(type: 'string', length: 255)] + #[Id] private string $additionalId = 'additional'; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php index bbfcc43b5f3..1016372c5e8 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php @@ -9,21 +9,17 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name = "joined_derived_child") - */ +#[Table(name: 'joined_derived_child')] +#[Entity] class JoinedDerivedChildClass extends JoinedDerivedRootClass { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $extension = 'ext'; - /** - * @Column(type="string", length=255) - * @Id - */ + #[Column(type: 'string', length: 255)] + #[Id] private string $additionalId = 'additional'; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php index b249224f6c0..22fc8f2b912 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php @@ -10,25 +10,20 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name = "joined_derived_identity") - */ +#[Table(name: 'joined_derived_identity')] +#[Entity] class JoinedDerivedIdentityClass { /** * @var string - * @Column(type="string", length=255) - * @Id */ + #[Column(type: 'string', length: 255)] + #[Id] protected $id = 'part-0'; /** * @var JoinedDerivedRootClass[] - * @OneToMany( - * targetEntity="JoinedDerivedRootClass", - * mappedBy="keyPart1" - * ) */ + #[OneToMany(targetEntity: 'JoinedDerivedRootClass', mappedBy: 'keyPart1')] protected $children; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php index 9cb9af1e576..7658b2934ae 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php @@ -13,29 +13,24 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name = "joined_derived_root") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @DiscriminatorMap({"child" = "JoinedDerivedChildClass", "root" = "JoinedDerivedRootClass"}) - */ +#[Table(name: 'joined_derived_root')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string', length: 255)] +#[DiscriminatorMap(['child' => 'JoinedDerivedChildClass', 'root' => 'JoinedDerivedRootClass'])] class JoinedDerivedRootClass { /** * @var JoinedDerivedIdentityClass - * @ManyToOne( - * targetEntity="JoinedDerivedIdentityClass", - * inversedBy="children" - * ) - * @Id */ + #[ManyToOne(targetEntity: 'JoinedDerivedIdentityClass', inversedBy: 'children')] + #[Id] protected $keyPart1 = 'part-1'; /** * @var string - * @Column(type="string", length=255) - * @Id */ + #[Column(type: 'string', length: 255)] + #[Id] protected $keyPart2 = 'part-2'; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php index d34be1ac572..43fab121659 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php @@ -11,25 +11,23 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"child" = "JoinedChildClass", "root" = "JoinedRootClass"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['child' => 'JoinedChildClass', 'root' => 'JoinedRootClass'])] class JoinedRootClass { /** * @var string - * @Column(type="string", length=255) - * @Id */ + #[Column(type: 'string', length: 255)] + #[Id] protected $keyPart1 = 'part-1'; /** * @var string - * @Column(type="string", length=255) - * @Id */ + #[Column(type: 'string', length: 255)] + #[Id] protected $keyPart2 = 'part-2'; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php index a5f3a17d9cd..36be1462f77 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php @@ -8,18 +8,16 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class SingleChildClass extends SingleRootClass { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $extension = 'ext'; - /** - * @Column(type="string", length=255) - * @Id - */ + #[Column(type: 'string', length: 255)] + #[Id] private string $additionalId = 'additional'; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php index 48cb9e773db..82b882acf5a 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php @@ -11,25 +11,23 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @DiscriminatorMap({"child" = "SingleChildClass", "root" = "SingleRootClass"}) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'discr', type: 'string', length: 255)] +#[DiscriminatorMap(['child' => 'SingleChildClass', 'root' => 'SingleRootClass'])] class SingleRootClass { /** * @var string - * @Column(type="string", length=255) - * @Id */ + #[Column(type: 'string', length: 255)] + #[Id] protected $keyPart1 = 'part-1'; /** * @var string - * @Column(type="string", length=255) - * @Id */ + #[Column(type: 'string', length: 255)] + #[Id] protected $keyPart2 = 'part-2'; } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php index f1a7a8bde05..38cc701f67e 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php @@ -11,19 +11,15 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\DbalTypes\CustomIdObject; -/** - * @Entity - * @Table(name="custom_id_type_child") - */ +#[Table(name: 'custom_id_type_child')] +#[Entity] class CustomIdObjectTypeChild { public function __construct( - /** - * @Id - * @Column(type="CustomIdObject", length=255) - */ + #[Id] + #[Column(type: 'CustomIdObject', length: 255)] public CustomIdObject $id, - /** @ManyToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent", inversedBy="children") */ + #[ManyToOne(targetEntity: 'Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent', inversedBy: 'children')] public CustomIdObjectTypeParent $parent, ) { } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php index 6b03d183270..373b182e648 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php @@ -13,23 +13,19 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\DbalTypes\CustomIdObject; -/** - * @Entity - * @Table(name="custom_id_type_parent") - */ +#[Table(name: 'custom_id_type_parent')] +#[Entity] class CustomIdObjectTypeParent { /** * @psalm-var Collection - * @OneToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild", cascade={"persist", "remove"}, mappedBy="parent") */ + #[OneToMany(targetEntity: 'Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild', cascade: ['persist', 'remove'], mappedBy: 'parent')] public $children; public function __construct( - /** - * @Id - * @Column(type="CustomIdObject", length=255) - */ + #[Id] + #[Column(type: 'CustomIdObject', length: 255)] public CustomIdObject $id, ) { $this->children = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php index e727da2c810..7792b2e40d9 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php @@ -10,23 +10,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="customtype_children") - */ +#[Table(name: 'customtype_children')] +#[Entity] class CustomTypeChild { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="upper_case_string", length=255) */ + #[Column(type: 'upper_case_string', length: 255)] public $lowerCaseString = 'foo'; } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php index ef947af372c..050896f4065 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\CustomType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -16,47 +17,43 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="customtype_parents") - */ +#[Table(name: 'customtype_parents')] +#[Entity] class CustomTypeParent { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var int - * @Column(type="negative_to_positive", nullable=true) */ + #[Column(type: 'negative_to_positive', nullable: true)] public $customInteger; /** * @var CustomTypeChild - * @OneToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeChild", cascade={"persist", "remove"}) */ + #[OneToOne(targetEntity: 'Doctrine\Tests\Models\CustomType\CustomTypeChild', cascade: ['persist', 'remove'])] public $child; /** * @psalm-var Collection - * @ManyToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeParent", mappedBy="myFriends") */ + #[ManyToMany(targetEntity: 'Doctrine\Tests\Models\CustomType\CustomTypeParent', mappedBy: 'myFriends')] private $friendsWithMe; /** * @psalm-var Collection - * @ManyToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeParent", inversedBy="friendsWithMe") - * @JoinTable( - * name="customtype_parent_friends", - * joinColumns={@JoinColumn(name="customtypeparent_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="friend_customtypeparent_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'customtype_parent_friends')] + #[JoinColumn(name: 'customtypeparent_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'friend_customtypeparent_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'Doctrine\Tests\Models\CustomType\CustomTypeParent', inversedBy: 'friendsWithMe')] private $myFriends; public function __construct() diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php index df6c288ff55..97051aa72be 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php @@ -10,29 +10,27 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="customtype_uppercases") - */ +#[Table(name: 'customtype_uppercases')] +#[Entity] class CustomTypeUpperCase { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="upper_case_string", length=255) */ + #[Column(type: 'upper_case_string', length: 255)] public $lowerCaseString; /** * @var string - * @Column(type="upper_case_string", length=255, name="named_lower_case_string", nullable = true) */ + #[Column(type: 'upper_case_string', length: 255, name: 'named_lower_case_string', nullable: true)] public $namedLowerCaseString; } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php index 1ee6649ba43..00c035516be 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php @@ -12,37 +12,25 @@ use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; -/** @Entity */ +#[Entity] class DDC117ApproveChanges { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; public function __construct( - /** - * @ManyToOne(targetEntity="DDC117ArticleDetails") - * @JoinColumn(name="details_id", referencedColumnName="article_id") - */ + #[ManyToOne(targetEntity: 'DDC117ArticleDetails')] + #[JoinColumn(name: 'details_id', referencedColumnName: 'article_id')] private DDC117ArticleDetails $articleDetails, - /** - * @ManyToOne(targetEntity="DDC117Reference") - * @JoinColumns({ - * @JoinColumn(name="source_id", referencedColumnName="source_id"), - * @JoinColumn(name="target_id", referencedColumnName="target_id") - * }) - */ + #[JoinColumn(name: 'source_id', referencedColumnName: 'source_id')] + #[JoinColumn(name: 'target_id', referencedColumnName: 'target_id')] + #[ManyToOne(targetEntity: 'DDC117Reference')] private DDC117Reference $reference, - /** - * @ManyToOne(targetEntity="DDC117Translation") - * @JoinColumns({ - * @JoinColumn(name="trans_article_id", referencedColumnName="article_id"), - * @JoinColumn(name="trans_language", referencedColumnName="language") - * }) - */ + #[JoinColumn(name: 'trans_article_id', referencedColumnName: 'article_id')] + #[JoinColumn(name: 'trans_language', referencedColumnName: 'language')] + #[ManyToOne(targetEntity: 'DDC117Translation')] private DDC117Translation $translation, ) { } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php index 471c8744545..357b7119aac 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php @@ -13,39 +13,37 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; -/** @Entity */ +#[Entity] class DDC117Article { - /** - * @Id - * @Column(type="integer", name="article_id") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer', name: 'article_id')] + #[GeneratedValue] private int $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC117Reference", mappedBy="source", cascade={"remove"}) */ + #[OneToMany(targetEntity: 'DDC117Reference', mappedBy: 'source', cascade: ['remove'])] private $references; - /** @OneToOne(targetEntity="DDC117ArticleDetails", mappedBy="article", cascade={"persist", "remove"}) */ + #[OneToOne(targetEntity: 'DDC117ArticleDetails', mappedBy: 'article', cascade: ['persist', 'remove'])] private DDC117ArticleDetails|null $details = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC117Translation", mappedBy="article", cascade={"persist", "remove"}) */ + #[OneToMany(targetEntity: 'DDC117Translation', mappedBy: 'article', cascade: ['persist', 'remove'])] private $translations; /** * @var Collection - * @OneToMany(targetEntity="DDC117Link", mappedBy="source", indexBy="target_id", cascade={"persist", "remove"}) */ + #[OneToMany(targetEntity: 'DDC117Link', mappedBy: 'source', indexBy: 'target_id', cascade: ['persist', 'remove'])] private Collection $links; public function __construct( - /** @Column */ + #[Column] private string $title, ) { $this->references = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php index a4cfba94cbe..c49c936c22c 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php @@ -10,19 +10,19 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; -/** @Entity */ +#[Entity] class DDC117ArticleDetails { - /** @Column(type="text") */ + #[Column(type: 'text')] private string $text; public function __construct( /** * @var DDC117Article - * @Id - * @OneToOne(targetEntity="DDC117Article", inversedBy="details") - * @JoinColumn(name="article_id", referencedColumnName="article_id") */ + #[Id] + #[OneToOne(targetEntity: 'DDC117Article', inversedBy: 'details')] + #[JoinColumn(name: 'article_id', referencedColumnName: 'article_id')] private $article, string $text, ) { diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php index 98c0e421fe5..f3cd3da1c4f 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\DDC117; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -16,44 +17,37 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; -/** @Entity */ +#[Entity] class DDC117Editor { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC117Translation", inversedBy="reviewedByEditors") - * @JoinTable( - * inverseJoinColumns={ - * @JoinColumn(name="article_id", referencedColumnName="article_id"), - * @JoinColumn(name="language", referencedColumnName="language") - * }, - * joinColumns={ - * @JoinColumn(name="editor_id", referencedColumnName="id") - * } - * ) */ + #[JoinTable] + #[JoinColumn(name: 'editor_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'article_id', referencedColumnName: 'article_id')] + #[InverseJoinColumn(name: 'language', referencedColumnName: 'language')] + #[ManyToMany(targetEntity: 'DDC117Translation', inversedBy: 'reviewedByEditors')] public $reviewingTranslations; /** * @var DDC117Translation - * @ManyToOne(targetEntity="DDC117Translation", inversedBy="lastTranslatedBy") - * @JoinColumns({ - * @JoinColumn(name="lt_article_id", referencedColumnName="article_id"), - * @JoinColumn(name="lt_language", referencedColumnName="language") - * }) */ + #[JoinColumn(name: 'lt_article_id', referencedColumnName: 'article_id')] + #[JoinColumn(name: 'lt_language', referencedColumnName: 'language')] + #[ManyToOne(targetEntity: 'DDC117Translation', inversedBy: 'lastTranslatedBy')] public $lastTranslation; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string|null $name = '', ) { $this->reviewingTranslations = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php index 714599bec84..8bff0ce81ef 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php @@ -11,23 +11,18 @@ /** * Foreign Key Entity without additional fields! - * - * @Entity */ +#[Entity] class DDC117Link { public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="DDC117Article", inversedBy="links") - * @JoinColumn(name="source_id", referencedColumnName="article_id") - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC117Article', inversedBy: 'links')] + #[JoinColumn(name: 'source_id', referencedColumnName: 'article_id')] public DDC117Article $source, - /** - * @Id - * @ManyToOne(targetEntity="DDC117Article") - * @JoinColumn(name="target_id", referencedColumnName="article_id") - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC117Article')] + #[JoinColumn(name: 'target_id', referencedColumnName: 'article_id')] public DDC117Article $target, $description, ) { diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php index 75791cdb49c..bc01d8bc8bd 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php @@ -11,32 +11,32 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; -/** @Entity */ +#[Entity] class DDC117Reference { /** * @var DDC117Article - * @Id - * @ManyToOne(targetEntity="DDC117Article", inversedBy="references") - * @JoinColumn(name="source_id", referencedColumnName="article_id") */ + #[Id] + #[ManyToOne(targetEntity: 'DDC117Article', inversedBy: 'references')] + #[JoinColumn(name: 'source_id', referencedColumnName: 'article_id')] private $source; /** * @var DDC117Article - * @Id - * @ManyToOne(targetEntity="DDC117Article") - * @JoinColumn(name="target_id", referencedColumnName="article_id") */ + #[Id] + #[ManyToOne(targetEntity: 'DDC117Article')] + #[JoinColumn(name: 'target_id', referencedColumnName: 'article_id')] private $target; - /** @Column(type="datetime") */ + #[Column(type: 'datetime')] private DateTime $created; public function __construct( DDC117Article $source, DDC117Article $target, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $description, ) { $source->addReference($this); diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php index f918b975cdd..a7522fb88d5 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php @@ -14,35 +14,33 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; -/** @Entity */ +#[Entity] class DDC117Translation { /** * @var Collection - * @ManyToMany(targetEntity="DDC117Editor", mappedBy="reviewingTranslations") */ + #[ManyToMany(targetEntity: 'DDC117Editor', mappedBy: 'reviewingTranslations')] public $reviewedByEditors; /** * @var Collection - * @OneToMany(targetEntity="DDC117Editor", mappedBy="lastTranslation") */ + #[OneToMany(targetEntity: 'DDC117Editor', mappedBy: 'lastTranslation')] public $lastTranslatedBy; public function __construct( /** * @var DDC117Article - * @Id - * @ManyToOne(targetEntity="DDC117Article", inversedBy="translations") - * @JoinColumn(name="article_id", referencedColumnName="article_id") */ + #[Id] + #[ManyToOne(targetEntity: 'DDC117Article', inversedBy: 'translations')] + #[JoinColumn(name: 'article_id', referencedColumnName: 'article_id')] private $article, - /** - * @Id - * @Column(type="string", length=255) - */ + #[Id] + #[Column(type: 'string', length: 255)] private string $language, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $title, ) { $this->reviewedByEditors = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php b/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php index 26d41781542..be8ca6967ed 100644 --- a/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php +++ b/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php @@ -11,24 +11,22 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\MappedSuperclass; -/** - * @Entity - * @MappedSuperclass - */ +#[Entity] +#[MappedSuperclass] abstract class DDC1590Entity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var DateTime - * @Column(type="datetime") */ + #[Column(type: 'datetime')] protected $createdAt; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php b/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php index 44a11ce9f17..7274bdfe30e 100644 --- a/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php +++ b/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php @@ -9,15 +9,13 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\Models\DDC1590\DDC1590Entity; -/** - * @Entity - * @Table(name="users") - */ +#[Table(name: 'users')] +#[Entity] class DDC1590User extends DDC1590Entity { /** * @var string - * @Column(type="string", length=255, length=255) */ + #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php index 4a97a227887..cdd34457df0 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php @@ -8,12 +8,10 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class DDC1872Bar { - /** - * @Id - * @Column(type="string", length=255) - */ + #[Id] + #[Column(type: 'string', length: 255)] private string $id; } diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php index 94e04997403..e37332c0ba2 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php @@ -12,27 +12,9 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\JoinColumn; -/** - * @Entity - * @AttributeOverrides({ - * @AttributeOverride(name="foo", - * column=@Column( - * name = "foo_overridden", - * type = "integer", - * length = 140, - * nullable = false, - * unique = false - * ) - * ) - * }) - * @AssociationOverrides({ - * @AssociationOverride(name="bar", - * joinColumns=@JoinColumn( - * name="example_entity_overridden_bar_id", referencedColumnName="id" - * ) - * ) - * }) - */ +#[Entity] +#[AttributeOverrides([new AttributeOverride(name: 'foo', column: new Column(name: 'foo_overridden', type: 'integer', length: 140, nullable: false, unique: false))])] +#[AssociationOverrides([new AssociationOverride(name: 'bar', joinColumns: new JoinColumn(name: 'example_entity_overridden_bar_id', referencedColumnName: 'id'))])] class DDC1872ExampleEntityWithOverride { use DDC1872ExampleTrait; diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php index 6f3a46e18e5..205d36ee184 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php @@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class DDC1872ExampleEntityWithoutOverride { use DDC1872ExampleTrait; diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php index bf34c2acdfa..b05a285af2c 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php @@ -13,21 +13,21 @@ trait DDC1872ExampleTrait { /** * @var string - * @Id - * @Column(type="string", length=255) */ + #[Id] + #[Column(type: 'string', length: 255)] private $id; /** * @var int - * @Column(name="trait_foo", type="integer", length=100, nullable=true, unique=true) */ + #[Column(name: 'trait_foo', type: 'integer', length: 100, nullable: true, unique: true)] protected $foo; /** * @var DDC1872Bar - * @OneToOne(targetEntity="DDC1872Bar", cascade={"persist", "merge"}) - * @JoinColumn(name="example_trait_bar_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC1872Bar', cascade: ['persist', 'merge'])] + #[JoinColumn(name: 'example_trait_bar_id', referencedColumnName: 'id')] protected $bar; } diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php index 4fd1ed7bd0a..de27cdf858c 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php @@ -11,26 +11,22 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="addresses") - */ +#[Table(name: 'addresses')] +#[Entity] class DDC2372Address { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string|null $street = null; /** * @var User - * @OneToOne(targetEntity="User", mappedBy="address") */ + #[OneToOne(targetEntity: 'User', mappedBy: 'address')] private $user; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Admin.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Admin.php index 404c373d239..c3cdce6d382 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Admin.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Admin.php @@ -7,10 +7,8 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="admins") - */ +#[Table(name: 'admins')] +#[Entity] class DDC2372Admin extends DDC2372User { } diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php index c9514042112..b8c10bacbcf 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php @@ -11,22 +11,18 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\Models\DDC2372\Traits\DDC2372AddressAndAccessors; -/** - * @Entity - * @Table(name="users") - */ +#[Table(name: 'users')] +#[Entity] class DDC2372User { use DDC2372AddressAndAccessors; - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] private string|null $name = null; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php b/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php index 75943fe484d..019e5690116 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php +++ b/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php @@ -12,9 +12,9 @@ trait DDC2372AddressAndAccessors { /** * @var DDC2372Address - * @OneToOne(targetEntity="Doctrine\Tests\Models\DDC2372\DDC2372Address", inversedBy="user") - * @JoinColumn(name="address_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'Doctrine\Tests\Models\DDC2372\DDC2372Address', inversedBy: 'user')] + #[JoinColumn(name: 'address_id', referencedColumnName: 'id')] private $address; public function getAddress(): DDC2372Address diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php b/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php index 1fbc5c9ff73..e3ebaab39a8 100644 --- a/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php +++ b/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php @@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class DDC2504ChildClass extends DDC2504RootClass { } diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php b/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php index efb6cebee2c..fb40e31083c 100644 --- a/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php +++ b/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php @@ -12,22 +12,22 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\PersistentCollection; -/** @Entity */ +#[Entity] class DDC2504OtherClass { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; /** * @var DDC2504ChildClass - * @OneToMany(targetEntity="DDC2504ChildClass", mappedBy="other", fetch="EXTRA_LAZY") * @var ArrayCollection|PersistentCollection */ + #[OneToMany(targetEntity: 'DDC2504ChildClass', mappedBy: 'other', fetch: 'EXTRA_LAZY')] public $childClasses; public function __construct() diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php b/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php index 9210d129b3a..6243a9b205f 100644 --- a/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php +++ b/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php @@ -13,28 +13,23 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\ManyToOne; -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @DiscriminatorMap({ - * "root" = "DDC2504RootClass", - * "child" = "DDC2504ChildClass" - * }) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string', length: 255)] +#[DiscriminatorMap(['root' => 'DDC2504RootClass', 'child' => 'DDC2504ChildClass'])] class DDC2504RootClass { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; /** * @var DDC2504OtherClass - * @ManyToOne(targetEntity="DDC2504OtherClass", inversedBy="childClasses") */ + #[ManyToOne(targetEntity: 'DDC2504OtherClass', inversedBy: 'childClasses')] public $other; } diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php index 6eb920ad09c..d29a42f87e2 100644 --- a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php +++ b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php @@ -10,23 +10,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity(repositoryClass="DDC3231User1Repository") - * @Table(name="users") - */ +#[Table(name: 'users')] +#[Entity(repositoryClass: 'DDC3231User1Repository')] class DDC3231User1 { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php index 9b7406095fc..14288445751 100644 --- a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php +++ b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php @@ -8,23 +8,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity(repositoryClass="DDC3231User1NoNamespaceRepository") - * @Table(name="no_namespace_users") - */ +#[Table(name: 'no_namespace_users')] +#[Entity(repositoryClass: 'DDC3231User1NoNamespaceRepository')] class DDC3231User1NoNamespace { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php index 6e910e7d13e..02a28683f35 100644 --- a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php +++ b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php @@ -10,23 +10,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity(repositoryClass="DDC3231User2Repository") - * @Table(name="users2") - */ +#[Table(name: 'users2')] +#[Entity(repositoryClass: 'DDC3231User2Repository')] class DDC3231User2 { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php index 7312603fc80..f9fd764b36e 100644 --- a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php +++ b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php @@ -8,23 +8,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity(repositoryClass="DDC3231User2NoNamespaceRepository") - * @Table(name="no_namespace_users2") - */ +#[Table(name: 'no_namespace_users2')] +#[Entity(repositoryClass: 'DDC3231User2NoNamespaceRepository')] class DDC3231User2NoNamespace { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php index f1539db1f2e..1390bbc36a1 100644 --- a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php +++ b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php @@ -12,24 +12,22 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="ddc3346_articles") - */ +#[Table(name: 'ddc3346_articles')] +#[Entity] class DDC3346Article { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var DDC3346Author - * @ManyToOne(targetEntity="DDC3346Author", inversedBy="articles") - * @JoinColumn(name="user_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'DDC3346Author', inversedBy: 'articles')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; } diff --git a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php index 6b85bff3b9a..ae9041d7c6d 100644 --- a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php +++ b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php @@ -12,29 +12,27 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="ddc3346_users") - */ +#[Table(name: 'ddc3346_users')] +#[Entity] class DDC3346Author { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255, unique=true) */ + #[Column(type: 'string', length: 255, unique: true)] public $username; /** * @var Collection - * @OneToMany(targetEntity="DDC3346Article", mappedBy="user", fetch="EAGER", cascade={"detach"}) */ + #[OneToMany(targetEntity: 'DDC3346Article', mappedBy: 'user', fetch: 'EAGER', cascade: ['detach'])] public $articles = []; } diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php index 4d9143a5d8f..0733079f60d 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php @@ -15,8 +15,8 @@ #[Entity] class DDC3579Group { - /** @GeneratedValue */ #[Id, GeneratedValue, Column(type: 'integer')] + #[GeneratedValue] private int $id; /** @psalm-var Collection */ diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php index 6df59005710..3e731c0c227 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php @@ -10,12 +10,11 @@ /** * Description of Image - * - * @Entity */ +#[Entity] class DDC3597Image extends DDC3597Media { - /** @Embedded(class = "Doctrine\Tests\Models\DDC3597\Embeddable\DDC3597Dimension", columnPrefix = false) */ + #[Embedded(class: 'Doctrine\Tests\Models\DDC3597\Embeddable\DDC3597Dimension', columnPrefix: false)] private DDC3597Dimension $dimension; public function __construct(string $distributionHash) diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php index c0f4e45e79e..e2517de9430 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php @@ -9,19 +9,18 @@ /** * Description of Media - * - * @Entity */ +#[Entity] abstract class DDC3597Media extends DDC3597Root { - /** @Column */ + #[Column] private int $size = 0; - /** @Column */ + #[Column] private string|null $format = null; public function __construct( - /** @Column */ + #[Column] private string $distributionHash, ) { } diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php index dddcbde6d35..db8f908e67d 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php @@ -18,40 +18,38 @@ /** * Description of Root - * - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discriminator", type="string", length=255) - * @DiscriminatorMap({ "image" = "DDC3597Image"}) - * @HasLifecycleCallbacks */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discriminator', type: 'string', length: 255)] +#[DiscriminatorMap(['image' => 'DDC3597Image'])] +#[HasLifecycleCallbacks] abstract class DDC3597Root { /** * @var int - * @Column(name="id", type="integer", nullable=false) - * @Id - * @GeneratedValue(strategy="IDENTITY") */ + #[Column(name: 'id', type: 'integer', nullable: false)] + #[Id] + #[GeneratedValue(strategy: 'IDENTITY')] protected $id; /** * @var DateTime - * @Column(name="created_at", type="datetime", nullable=false) */ + #[Column(name: 'created_at', type: 'datetime', nullable: false)] protected $createdAt = null; /** * @var DateTime - * @Column(name="updated_at", type="datetime", nullable=false) */ + #[Column(name: 'updated_at', type: 'datetime', nullable: false)] protected $updatedAt = null; /** * Set createdAt - * - * @PrePersist */ + #[PrePersist] public function prePersist(): void { $this->updatedAt = $this->createdAt = new DateTime(); @@ -59,9 +57,8 @@ public function prePersist(): void /** * Set updatedAt - * - * @PreUpdate */ + #[PreUpdate] public function preUpdate(): void { $this->updatedAt = new DateTime(); diff --git a/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php b/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php index 680a98982f5..d5a92ef8558 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php +++ b/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php @@ -9,15 +9,14 @@ /** * Description of DDC3597Dimension - * - * @Embeddable */ +#[Embeddable] class DDC3597Dimension { - /** @Column(type="integer", name="width") */ + #[Column(type: 'integer', name: 'width')] private int $width; - /** @Column(type="integer", name="height") */ + #[Column(type: 'integer', name: 'height')] private int $height; public function __construct($width = 0, $height = 0) diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php b/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php index d9f48ceb025..895d156ced0 100644 --- a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php +++ b/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php @@ -12,34 +12,32 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="ddc3699_child") - */ +#[Table(name: 'ddc3699_child')] +#[Entity] class DDC3699Child extends DDC3699Parent { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $childField; /** * @var DDC3699RelationOne - * @OneToOne(targetEntity="DDC3699RelationOne", inversedBy="child") */ + #[OneToOne(targetEntity: 'DDC3699RelationOne', inversedBy: 'child')] public $oneRelation; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3699RelationMany", mappedBy="child") */ + #[OneToMany(targetEntity: 'DDC3699RelationMany', mappedBy: 'child')] public $relations; } diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php b/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php index 82f22833e89..ca804cb859e 100644 --- a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php +++ b/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php @@ -7,12 +7,12 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\MappedSuperclass; -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class DDC3699Parent { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $parentField; } diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php b/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php index 5d6efc01aa6..eb481dd3a5e 100644 --- a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php +++ b/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php @@ -10,22 +10,20 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="ddc3699_relation_many") - */ +#[Table(name: 'ddc3699_relation_many')] +#[Entity] class DDC3699RelationMany { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var DDC3699Child - * @ManyToOne(targetEntity="DDC3699Child", inversedBy="relations") */ + #[ManyToOne(targetEntity: 'DDC3699Child', inversedBy: 'relations')] public $child; } diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php b/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php index e99e1f97050..13ab5817c07 100644 --- a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php +++ b/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php @@ -10,22 +10,20 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="ddc3699_relation_one") - */ +#[Table(name: 'ddc3699_relation_one')] +#[Entity] class DDC3699RelationOne { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var DDC3699Child - * @OneToOne(targetEntity="DDC3699Child", mappedBy="oneRelation") */ + #[OneToOne(targetEntity: 'DDC3699Child', mappedBy: 'oneRelation')] public $child; } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php index 54da4d163e9..44b6e23f47e 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php @@ -13,34 +13,29 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="dc3899_contracts") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @DiscriminatorMap({ - * "fix" = "DDC3899FixContract", - * "flexible" = "DDC3899FlexContract" - * }) - */ +#[Table(name: 'dc3899_contracts')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'discr', type: 'string', length: 255)] +#[DiscriminatorMap(['fix' => 'DDC3899FixContract', 'flexible' => 'DDC3899FlexContract'])] abstract class DDC3899Contract { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var bool - * @Column(type="boolean") */ + #[Column(type: 'boolean')] public $completed = false; /** * @var DDC3899User - * @ManyToOne(targetEntity="DDC3899User", inversedBy="contract") */ + #[ManyToOne(targetEntity: 'DDC3899User', inversedBy: 'contract')] public $user; } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php index 0406e1eee5f..a9db871b2b0 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php @@ -7,12 +7,12 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class DDC3899FixContract extends DDC3899Contract { /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $fixPrice = 0; } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php index 80cf146316b..3bbda5de96a 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php @@ -7,18 +7,18 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class DDC3899FlexContract extends DDC3899Contract { /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $hoursWorked = 0; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $pricePerHour = 0; } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php index 998f858c3b7..f98d9d5f66e 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php @@ -11,22 +11,20 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="dc3899_users") - */ +#[Table(name: 'dc3899_users')] +#[Entity] class DDC3899User { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3899Contract", mappedBy="user") */ + #[OneToMany(targetEntity: 'DDC3899Contract', mappedBy: 'user')] public $contracts; } diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php index 2fc52c94b08..b728a1441c7 100644 --- a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php +++ b/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php @@ -7,9 +7,9 @@ use Doctrine\ORM\Mapping\Embedded; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class DDC4006User { - /** @Embedded(class="DDC4006UserId") */ + #[Embedded(class: 'DDC4006UserId')] private DDC4006UserId $id; } diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php b/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php index 3d4b7659245..c5650fcb82f 100644 --- a/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php +++ b/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php @@ -9,13 +9,11 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Embeddable */ +#[Embeddable] class DDC4006UserId { - /** - * @Id - * @GeneratedValue("IDENTITY") - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue('IDENTITY')] + #[Column(type: 'integer')] private int $id; } diff --git a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php b/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php index b77c1de6872..f601c763253 100644 --- a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php +++ b/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php @@ -8,19 +8,19 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; -/** @Entity */ +#[Entity] class DDC6412File { /** * @var int - * @Column(type="integer") - * @GeneratedValue */ + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(length=50, name="file_name") */ + #[Column(length: 50, name: 'file_name')] public $name; } diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php index 2d773b2e641..49826bc0757 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php @@ -9,20 +9,20 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity(repositoryClass = "Doctrine\Tests\Models\DDC753\DDC753CustomRepository") */ +#[Entity(repositoryClass: 'Doctrine\Tests\Models\DDC753\DDC753CustomRepository')] class DDC753EntityWithCustomRepository { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php index 8a1b5ba0857..dec2a21149b 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php @@ -9,20 +9,20 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity() */ +#[Entity] class DDC753EntityWithDefaultCustomRepository { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php index a6ba10707e3..e8a0c99f868 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php @@ -9,20 +9,20 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity(repositoryClass = "\stdClass") */ +#[Entity(repositoryClass: '\stdClass')] class DDC753EntityWithInvalidRepository { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php b/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php index 30f08cc1cf7..c79d938435d 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php @@ -13,10 +13,10 @@ class DDC889Class extends DDC889SuperClass { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; public static function loadMetadata(ClassMetadata $metadata): void diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php index bf59e245305..c4ea9f10a68 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php @@ -9,24 +9,22 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class DDC964Address { - /** - * @GeneratedValue - * @Id - * @Column(type="integer") - */ + #[GeneratedValue] + #[Id] + #[Column(type: 'integer')] private int $id; public function __construct( - /** @Column */ + #[Column] private string|null $zip = null, - /** @Column */ + #[Column] private string|null $country = null, - /** @Column */ + #[Column] private string|null $city = null, - /** @Column */ + #[Column] private string|null $street = null, ) { } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php index c2d20723725..4d72a465cd9 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php @@ -11,24 +11,22 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** @Entity */ +#[Entity] class DDC964Group { - /** - * @GeneratedValue - * @Id - * @Column(type="integer") - */ + #[GeneratedValue] + #[Id] + #[Column(type: 'integer')] private int $id; /** * @psalm-var ArrayCollection - * @ManyToMany(targetEntity="DDC964User", mappedBy="groups") */ + #[ManyToMany(targetEntity: 'DDC964User', mappedBy: 'groups')] private $users; public function __construct( - /** @Column */ + #[Column] private string|null $name = null, ) { $this->users = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php index 2471169ea52..15abce65a3f 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php @@ -10,20 +10,18 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\MappedSuperclass; -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class AbstractContentItem { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $name; /** @@ -39,7 +37,7 @@ abstract class AbstractContentItem public static $fileSystem; public function __construct( - /** @ManyToOne(targetEntity="Directory") */ + #[ManyToOne(targetEntity: 'Directory')] protected Directory|null $parentDirectory = null, ) { } diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php index 62c62e843d2..ff27b455518 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php @@ -7,13 +7,13 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class Directory extends AbstractContentItem { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $path; public function setPath(string $path): void diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/File.php b/tests/Doctrine/Tests/Models/DirectoryTree/File.php index c2a8f203a3b..e62e7c556ab 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/File.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/File.php @@ -8,16 +8,14 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="`file`") - */ +#[Table(name: '`file`')] +#[Entity] class File extends AbstractContentItem { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected $extension = 'html'; public function __construct(Directory|null $parent = null) diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php index 5bbaa69d8ae..35206144bfc 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\ECommerce; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -19,35 +20,30 @@ /** * ECommerceCart * Represents a typical cart of a shopping application. - * - * @Entity - * @Table(name="ecommerce_carts") */ +#[Table(name: 'ecommerce_carts')] +#[Entity] class ECommerceCart { - /** - * @Column(type="integer") - * @Id - * @GeneratedValue - */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] private int $id; - /** @Column(length=50, nullable=true) */ + #[Column(length: 50, nullable: true)] private string|null $payment = null; - /** - * @OneToOne(targetEntity="ECommerceCustomer", inversedBy="cart") - * @JoinColumn(name="customer_id", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'ECommerceCustomer', inversedBy: 'cart')] + #[JoinColumn(name: 'customer_id', referencedColumnName: 'id')] private ECommerceCustomer|null $customer = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="ECommerceProduct", cascade={"persist"}) - * @JoinTable(name="ecommerce_carts_products", - * joinColumns={@JoinColumn(name="cart_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}) */ + #[JoinTable(name: 'ecommerce_carts_products')] + #[JoinColumn(name: 'cart_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'product_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'ECommerceProduct', cascade: ['persist'])] private $products; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php index ffc9401343e..2d454dbe898 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php @@ -19,38 +19,33 @@ /** * ECommerceCategory * Represents a tag applied on particular products. - * - * @Entity - * @Table(name="ecommerce_categories") */ +#[Table(name: 'ecommerce_categories')] +#[Entity] class ECommerceCategory { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] private string|null $name = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="ECommerceProduct", mappedBy="categories") */ + #[ManyToMany(targetEntity: 'ECommerceProduct', mappedBy: 'categories')] private $products; /** * @psalm-var Collection - * @OneToMany(targetEntity="ECommerceCategory", mappedBy="parent", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'ECommerceCategory', mappedBy: 'parent', cascade: ['persist'])] private $children; - /** - * @ManyToOne(targetEntity="ECommerceCategory", inversedBy="children") - * @JoinColumn(name="parent_id", referencedColumnName="id") - */ + #[ManyToOne(targetEntity: 'ECommerceCategory', inversedBy: 'children')] + #[JoinColumn(name: 'parent_id', referencedColumnName: 'id')] private ECommerceCategory|null $parent = null; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php index bd9ba52ddfb..6a03e5d76b3 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php @@ -15,33 +15,29 @@ /** * ECommerceCustomer * Represents a registered user of a shopping application. - * - * @Entity - * @Table(name="ecommerce_customers") */ +#[Table(name: 'ecommerce_customers')] +#[Entity] class ECommerceCustomer { - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] private string|null $name = null; - /** @OneToOne(targetEntity="ECommerceCart", mappedBy="customer", cascade={"persist"}) */ + #[OneToOne(targetEntity: 'ECommerceCart', mappedBy: 'customer', cascade: ['persist'])] private ECommerceCart|null $cart = null; /** * Example of a one-one self referential association. A mentor can follow * only one customer at the time, while a customer can choose only one * mentor. Not properly appropriate but it works. - * - * @OneToOne(targetEntity="ECommerceCustomer", cascade={"persist"}, fetch="EAGER") - * @JoinColumn(name="mentor_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'ECommerceCustomer', cascade: ['persist'], fetch: 'EAGER')] + #[JoinColumn(name: 'mentor_id', referencedColumnName: 'id')] private ECommerceCustomer|null $mentor = null; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php index ba3ed712fc2..7e33ba09044 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php @@ -14,26 +14,21 @@ /** * Describes a product feature. - * - * @Entity - * @Table(name="ecommerce_features") */ +#[Table(name: 'ecommerce_features')] +#[Entity] class ECommerceFeature { - /** - * @Column(type="integer") - * @Id - * @GeneratedValue - */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] private int $id; - /** @Column(length=50) */ + #[Column(length: 50)] private string|null $description = null; - /** - * @ManyToOne(targetEntity="ECommerceProduct", inversedBy="features") - * @JoinColumn(name="product_id", referencedColumnName="id") - */ + #[ManyToOne(targetEntity: 'ECommerceProduct', inversedBy: 'features')] + #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] private ECommerceProduct|null $product = null; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php index 9dd39632ca8..9b87c3fe02c 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\ECommerce; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -21,41 +22,37 @@ /** * ECommerceProduct * Represents a type of product of a shopping application. - * - * @Entity - * @Table(name="ecommerce_products",indexes={@Index(name="name_idx", columns={"name"})}) */ +#[Table(name: 'ecommerce_products')] +#[Index(name: 'name_idx', columns: ['name'])] +#[Entity] class ECommerceProduct { - /** - * @Column(type="integer") - * @Id - * @GeneratedValue - */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] private int $id; - /** @Column(type="string", length=50, nullable=true) */ + #[Column(type: 'string', length: 50, nullable: true)] private string|null $name = null; - /** - * @OneToOne(targetEntity="ECommerceShipping", cascade={"persist"}) - * @JoinColumn(name="shipping_id", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'ECommerceShipping', cascade: ['persist'])] + #[JoinColumn(name: 'shipping_id', referencedColumnName: 'id')] private ECommerceShipping|null $shipping = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="ECommerceFeature", mappedBy="product", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'ECommerceFeature', mappedBy: 'product', cascade: ['persist'])] private $features; /** * @psalm-var Collection - * @ManyToMany(targetEntity="ECommerceCategory", cascade={"persist"}, inversedBy="products") - * @JoinTable(name="ecommerce_products_categories", - * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="category_id", referencedColumnName="id")}) */ + #[JoinTable(name: 'ecommerce_products_categories')] + #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'category_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'ECommerceCategory', cascade: ['persist'], inversedBy: 'products')] private $categories; /** @@ -63,11 +60,11 @@ class ECommerceProduct * simplicity. * * @psalm-var Collection - * @ManyToMany(targetEntity="ECommerceProduct", cascade={"persist"}) - * @JoinTable(name="ecommerce_products_related", - * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="related_id", referencedColumnName="id")}) */ + #[JoinTable(name: 'ecommerce_products_related')] + #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'related_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'ECommerceProduct', cascade: ['persist'])] private $related; /** @var bool */ diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php index 45b0b82a995..4564d2c4c46 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php @@ -13,20 +13,17 @@ /** * ECommerceShipping * Represents a shipping method. - * - * @Entity - * @Table(name="ecommerce_shippings") */ +#[Table(name: 'ecommerce_shippings')] +#[Entity] class ECommerceShipping { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int|string|null $days = null; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php b/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php index 9ce94b9755f..611ff0c8223 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php @@ -7,12 +7,12 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class ForumAdministrator extends ForumUser { /** * @var int - * @Column(type="integer", name="access_level") */ + #[Column(type: 'integer', name: 'access_level')] public $accessLevel; } diff --git a/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php b/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php index 7b44f0cd918..9e251220eba 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php @@ -10,17 +10,15 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="forum_avatars") - */ +#[Table(name: 'forum_avatars')] +#[Entity] class ForumAvatar { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/Models/Forum/ForumBoard.php b/tests/Doctrine/Tests/Models/Forum/ForumBoard.php index 3ba24d8c8d8..5954000e7ac 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumBoard.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumBoard.php @@ -13,27 +13,26 @@ /** * Represents a board in a forum. - * - * @Entity - * @Table(name="forum_boards") */ +#[Table(name: 'forum_boards')] +#[Entity] class ForumBoard { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $position; /** * @var ForumCategory - * @ManyToOne(targetEntity="ForumCategory", inversedBy="boards") - * @JoinColumn(name="category_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'ForumCategory', inversedBy: 'boards')] + #[JoinColumn(name: 'category_id', referencedColumnName: 'id')] public $category; } diff --git a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php b/tests/Doctrine/Tests/Models/Forum/ForumCategory.php index 41871f1fe91..62907c3e61d 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumCategory.php @@ -11,34 +11,30 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="forum_categories") - */ +#[Table(name: 'forum_categories')] +#[Entity] class ForumCategory { - /** - * @Column(type="integer") - * @Id - */ + #[Column(type: 'integer')] + #[Id] private int $id; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $position; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="ForumBoard", mappedBy="category") */ + #[OneToMany(targetEntity: 'ForumBoard', mappedBy: 'category')] public $boards; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Forum/ForumEntry.php b/tests/Doctrine/Tests/Models/Forum/ForumEntry.php index d12835b5172..de877ca2a71 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumEntry.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumEntry.php @@ -10,23 +10,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="forum_entries") - */ +#[Table(name: 'forum_entries')] +#[Entity] class ForumEntry { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] public $topic; public function &getTopicByReference(): string diff --git a/tests/Doctrine/Tests/Models/Forum/ForumUser.php b/tests/Doctrine/Tests/Models/Forum/ForumUser.php index dfb5756c569..ee101fd99b9 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumUser.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumUser.php @@ -12,31 +12,29 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="forum_users") - */ +#[Table(name: 'forum_users')] +#[Entity] class ForumUser { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] public $username; /** * @var ForumAvatar - * @OneToOne(targetEntity="ForumAvatar", cascade={"persist"}) - * @JoinColumn(name="avatar_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'ForumAvatar', cascade: ['persist'])] + #[JoinColumn(name: 'avatar_id', referencedColumnName: 'id')] public $avatar; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php b/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php index 1c539f24c4c..5833ffc172d 100644 --- a/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php +++ b/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php @@ -9,15 +9,13 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\DbalTypes\GH8565EmployeePayloadType; -/** - * @Entity - * @Table(name="gh8565_employees") - */ +#[Table(name: 'gh8565_employees')] +#[Entity] class GH8565Employee extends GH8565Person { /** - * @Column(type="GH8565EmployeePayloadType", nullable=false) * @var GH8565EmployeePayloadType */ + #[Column(type: 'GH8565EmployeePayloadType', nullable: false)] public $type; } diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php b/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php index a3bd9546d38..67d6e107872 100644 --- a/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php +++ b/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php @@ -9,15 +9,13 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\DbalTypes\GH8565ManagerPayloadType; -/** - * @Entity - * @Table(name="gh8565_managers") - */ +#[Table(name: 'gh8565_managers')] +#[Entity] class GH8565Manager extends GH8565Person { /** - * @Column(type="GH8565ManagerPayloadType", nullable=false) * @var GH8565ManagerPayloadType */ + #[Column(type: 'GH8565ManagerPayloadType', nullable: false)] public $type; } diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php b/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php index 1bd144c4cbb..c83d761c8a6 100644 --- a/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php +++ b/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php @@ -13,24 +13,18 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="gh8565_persons") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @DiscriminatorMap({ - * "person" = "GH8565Person", - * "manager" = "GH8565Manager", - * "employee" = "GH8565Employee" - * }) - */ +#[Table(name: 'gh8565_persons')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string', length: 255)] +#[DiscriminatorMap(['person' => 'GH8565Person', 'manager' => 'GH8565Manager', 'employee' => 'GH8565Employee'])] class GH8565Person { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/Models/Generic/BooleanModel.php b/tests/Doctrine/Tests/Models/Generic/BooleanModel.php index f859de27299..9a9ba587dde 100644 --- a/tests/Doctrine/Tests/Models/Generic/BooleanModel.php +++ b/tests/Doctrine/Tests/Models/Generic/BooleanModel.php @@ -10,23 +10,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="boolean_model") - */ +#[Table(name: 'boolean_model')] +#[Entity] class BooleanModel { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var bool - * @Column(type="boolean") */ + #[Column(type: 'boolean')] public $booleanField; } diff --git a/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php b/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php index 9a27b48f730..81ae7f253d8 100644 --- a/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php +++ b/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php @@ -10,35 +10,33 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="date_time_model") - */ +#[Table(name: 'date_time_model')] +#[Entity] class DateTimeModel { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DateTime|null - * @Column(name="col_datetime", type="datetime", nullable=true) */ + #[Column(name: 'col_datetime', type: 'datetime', nullable: true)] public $datetime; /** * @var DateTime|null - * @Column(name="col_date", type="date", nullable=true) */ + #[Column(name: 'col_date', type: 'date', nullable: true)] public $date; /** * @var DateTime|null - * @Column(name="col_time", type="time", nullable=true) */ + #[Column(name: 'col_time', type: 'time', nullable: true)] public $time; } diff --git a/tests/Doctrine/Tests/Models/Generic/DecimalModel.php b/tests/Doctrine/Tests/Models/Generic/DecimalModel.php index 94dae1fad3e..931623fbd9b 100644 --- a/tests/Doctrine/Tests/Models/Generic/DecimalModel.php +++ b/tests/Doctrine/Tests/Models/Generic/DecimalModel.php @@ -10,29 +10,27 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="decimal_model") - */ +#[Table(name: 'decimal_model')] +#[Entity] class DecimalModel { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var float - * @Column(name="`decimal`", type="decimal", scale=2, precision=5) */ + #[Column(name: '`decimal`', type: 'decimal', scale: 2, precision: 5)] public $decimal; /** * @var float - * @Column(name="`high_scale`", type="decimal", scale=4, precision=14) */ + #[Column(name: '`high_scale`', type: 'decimal', scale: 4, precision: 14)] public $highScale; } diff --git a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php index 0e39f7e63f1..3bcdafe70c4 100644 --- a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php +++ b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php @@ -10,22 +10,20 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="`not-a-simple-entity`") - */ +#[Table(name: '`not-a-simple-entity`')] +#[Entity] class NonAlphaColumnsEntity { /** * @var int - * @Id - * @Column(type="integer", name="`simple-entity-id`") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer', name: '`simple-entity-id`')] + #[GeneratedValue(strategy: 'AUTO')] public $id; public function __construct( - /** @Column(type="string", length=255, name="`simple-entity-value`") */ + #[Column(type: 'string', length: 255, name: '`simple-entity-value`')] public string $value, ) { } diff --git a/tests/Doctrine/Tests/Models/Generic/SerializationModel.php b/tests/Doctrine/Tests/Models/Generic/SerializationModel.php index ab61dcff606..1684c1eedb5 100644 --- a/tests/Doctrine/Tests/Models/Generic/SerializationModel.php +++ b/tests/Doctrine/Tests/Models/Generic/SerializationModel.php @@ -10,29 +10,27 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="serialize_model") - */ +#[Table(name: 'serialize_model')] +#[Entity] class SerializationModel { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var mixed[] - * @Column(name="the_array", type="array", nullable=true) */ + #[Column(name: 'the_array', type: 'array', nullable: true)] public $array; /** * @var object - * @Column(name="the_obj", type="object", nullable=true) */ + #[Column(name: 'the_obj', type: 'object', nullable: true)] public $object; } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php index f58bae5aa0c..ecb57767b85 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php @@ -14,35 +14,29 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="geonames_admin1") - * @Cache - */ +#[Table(name: 'geonames_admin1')] +#[Entity] +#[Cache] class Admin1 { /** * @psalm-var Collection - * @OneToMany(targetEntity="Admin1AlternateName", mappedBy="admin1") - * @Cache */ + #[OneToMany(targetEntity: 'Admin1AlternateName', mappedBy: 'admin1')] + #[Cache] public $names = []; public function __construct( - /** - * @Id - * @Column(type="integer", length=25) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'integer', length: 25)] + #[GeneratedValue(strategy: 'NONE')] public int $id, - /** @Column(type="string", length=255); */ + #[Column(type: 'string', length: 255)] public string $name, - /** - * @Id - * @ManyToOne(targetEntity="Country") - * @JoinColumn(name="country", referencedColumnName="id") - * @Cache - */ + #[Id] + #[ManyToOne(targetEntity: 'Country')] + #[JoinColumn(name: 'country', referencedColumnName: 'id')] + #[Cache] public Country $country, ) { } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php index 7e56d95111d..b02d041c7d8 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php @@ -14,30 +14,22 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="geonames_admin1_alternate_name") - * @Cache - */ +#[Table(name: 'geonames_admin1_alternate_name')] +#[Entity] +#[Cache] class Admin1AlternateName { public function __construct( - /** - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 25)] + #[GeneratedValue(strategy: 'NONE')] public int $id, - /** @Column(type="string", length=255); */ + #[Column(type: 'string', length: 255)] public string $name, - /** - * @ManyToOne(targetEntity="Admin1", inversedBy="names") - * @JoinColumns({ - * @JoinColumn(name="admin1", referencedColumnName="id"), - * @JoinColumn(name="country", referencedColumnName="country") - * }) - * @Cache - */ + #[JoinColumn(name: 'admin1', referencedColumnName: 'id')] + #[JoinColumn(name: 'country', referencedColumnName: 'country')] + #[ManyToOne(targetEntity: 'Admin1', inversedBy: 'names')] + #[Cache] public Admin1 $admin1, ) { } diff --git a/tests/Doctrine/Tests/Models/GeoNames/City.php b/tests/Doctrine/Tests/Models/GeoNames/City.php index 9b707fc7762..fd00f137ab3 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/City.php +++ b/tests/Doctrine/Tests/Models/GeoNames/City.php @@ -14,40 +14,34 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="geonames_city") - * @Cache - */ +#[Table(name: 'geonames_city')] +#[Entity] +#[Cache] class City { /** * @var Country - * @ManyToOne(targetEntity="Country") - * @JoinColumn(name="country", referencedColumnName="id") - * @Cache */ + #[ManyToOne(targetEntity: 'Country')] + #[JoinColumn(name: 'country', referencedColumnName: 'id')] + #[Cache] public $country; /** * @var Admin1 - * @ManyToOne(targetEntity="Admin1") - * @JoinColumns({ - * @JoinColumn(name="admin1", referencedColumnName="id"), - * @JoinColumn(name="country", referencedColumnName="country") - * }) - * @Cache */ + #[JoinColumn(name: 'admin1', referencedColumnName: 'id')] + #[JoinColumn(name: 'country', referencedColumnName: 'country')] + #[ManyToOne(targetEntity: 'Admin1')] + #[Cache] public $admin1; public function __construct( - /** - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 25)] + #[GeneratedValue(strategy: 'NONE')] public int $id, - /** @Column(type="string", length=255); */ + #[Column(type: 'string', length: 255)] public string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Country.php b/tests/Doctrine/Tests/Models/GeoNames/Country.php index 7ac209f7f68..ab4cb345f1f 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Country.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Country.php @@ -11,21 +11,17 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="geonames_country") - * @Cache - */ +#[Table(name: 'geonames_country')] +#[Entity] +#[Cache] class Country { public function __construct( - /** - * @Id - * @Column(type="string", length=2) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 2)] + #[GeneratedValue(strategy: 'NONE')] public string $id, - /** @Column(type="string", length=255); */ + #[Column(type: 'string', length: 255)] public string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php b/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php index 345318649d7..2579b9894bd 100644 --- a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php +++ b/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php @@ -1,6 +1,7 @@ - * @ManyToMany(targetEntity="DoctrineGlobalUser") - * @JoinTable(name="author_articles", - * joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="author_id", referencedColumnName="id", unique=true)} - * ) */ + #[JoinTable(name: 'author_articles')] + #[JoinColumn(name: 'article_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'author_id', referencedColumnName: 'id', unique: true)] + #[ManyToMany(targetEntity: 'DoctrineGlobalUser')] protected $author; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DoctrineGlobalUser") - * @JoinTable(name="editor_articles", - * joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="editor_id", referencedColumnName="id", unique=true)} - * ) */ + #[JoinTable(name: 'editor_articles')] + #[JoinColumn(name: 'article_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'editor_id', referencedColumnName: 'id', unique: true)] + #[ManyToMany(targetEntity: 'DoctrineGlobalUser')] protected $editor; } -/** - * @Entity - * @Table(name="users") - */ +#[Table(name: 'users')] +#[Entity] class DoctrineGlobalUser { - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] private int $id; - /** @Column(type="string", length=64) */ + #[Column(type: 'string', length: 64)] private string $username; - /** @Column(type="string", length=128) */ + #[Column(type: 'string', length: 128)] private string $email; } diff --git a/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php b/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php index 6c14f41f7ca..919ee05ebea 100644 --- a/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php +++ b/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php @@ -11,20 +11,20 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** @Entity */ +#[Entity] class EntityWithArrayDefaultArrayValueM2M { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity=SimpleEntity::class) */ + #[ManyToMany(targetEntity: SimpleEntity::class)] public $collection = []; } diff --git a/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php b/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php index 770c03c0b57..79c9f1dc725 100644 --- a/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php +++ b/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php @@ -9,14 +9,14 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class SimpleEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php index cffd23e68ef..eabd7f4e628 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php @@ -8,15 +8,13 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="issue5989_employees") - */ +#[Table(name: 'issue5989_employees')] +#[Entity] class Issue5989Employee extends Issue5989Person { /** - * @Column(type="simple_array", nullable=true) * @var array */ + #[Column(type: 'simple_array', nullable: true)] public $tags; } diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php index 0cce464542c..334c407241d 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php @@ -8,15 +8,13 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="issue5989_managers") - */ +#[Table(name: 'issue5989_managers')] +#[Entity] class Issue5989Manager extends Issue5989Person { /** - * @Column(type="simple_array", nullable=true) * @var array */ + #[Column(type: 'simple_array', nullable: true)] public $tags; } diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php index 73b7a949ea1..4328af3aaa8 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php @@ -13,24 +13,18 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="issue5989_persons") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @DiscriminatorMap({ - * "person" = "Issue5989Person", - * "manager" = "Issue5989Manager", - * "employee" = "Issue5989Employee" - * }) - */ +#[Table(name: 'issue5989_persons')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string', length: 255)] +#[DiscriminatorMap(['person' => 'Issue5989Person', 'manager' => 'Issue5989Manager', 'employee' => 'Issue5989Employee'])] class Issue5989Person { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php b/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php index 184b1762853..60ea8ab7932 100644 --- a/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php +++ b/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php @@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\Entity; -/** @Entity */ +#[Entity] class AnotherChildClass extends ChildClass { } diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php b/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php index 4ba72c516f3..d017df22df4 100644 --- a/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php +++ b/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php @@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\MappedSuperclass; -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class ChildClass extends RootClass { } diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php b/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php index 8615d440fbd..a46959bc57c 100644 --- a/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php +++ b/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php @@ -10,17 +10,15 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; -/** - * @Entity - * @InheritanceType("JOINED") - */ +#[Entity] +#[InheritanceType('JOINED')] class RootClass { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php b/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php index c41dea37679..19ff89fbd85 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php @@ -12,37 +12,35 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="legacy_articles") - */ +#[Table(name: 'legacy_articles')] +#[Entity] class LegacyArticle { /** * @var int - * @Id - * @Column(name="iArticleId", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'iArticleId', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(name="sTopic", type="string", length=255) */ + #[Column(name: 'sTopic', type: 'string', length: 255)] public $topic; /** * @var string - * @Column(name="sText", type="text") */ + #[Column(name: 'sText', type: 'text')] public $text; /** * @var LegacyUser - * @ManyToOne(targetEntity="LegacyUser", inversedBy="articles") - * @JoinColumn(name="iUserId", referencedColumnName="iUserId") */ + #[ManyToOne(targetEntity: 'LegacyUser', inversedBy: 'articles')] + #[JoinColumn(name: 'iUserId', referencedColumnName: 'iUserId')] public $user; public function setAuthor(LegacyUser $author): void diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php b/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php index 75c013a3ec8..0c81c7fe69c 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php @@ -12,30 +12,28 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="legacy_cars") - */ +#[Table(name: 'legacy_cars')] +#[Entity] class LegacyCar { /** * @var int - * @Id - * @GeneratedValue - * @Column(name="iCarId", type="integer", nullable=false) */ + #[Id] + #[GeneratedValue] + #[Column(name: 'iCarId', type: 'integer', nullable: false)] public $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity="LegacyUser", mappedBy="cars") */ + #[ManyToMany(targetEntity: 'LegacyUser', mappedBy: 'cars')] public $users; /** * @var string - * @Column(name="sDescription", type="string", length=255, unique=true) */ + #[Column(name: 'sDescription', type: 'string', length: 255, unique: true)] public $description; public function getDescription(): string diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php b/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php index b25bc6d067a..cda0b01d56c 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Legacy; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -16,52 +17,49 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="legacy_users") - */ +#[Table(name: 'legacy_users')] +#[Entity] class LegacyUser { /** * @var int - * @Id - * @GeneratedValue - * @Column(name="iUserId", type="integer", nullable=false) */ + #[Id] + #[GeneratedValue] + #[Column(name: 'iUserId', type: 'integer', nullable: false)] public $id; /** * @var string - * @Column(name="sUsername", type="string", length=255, unique=true) */ + #[Column(name: 'sUsername', type: 'string', length: 255, unique: true)] public $username; /** * @var string - * @Column(type="string", length=255, name="name") */ + #[Column(type: 'string', length: 255, name: 'name')] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="LegacyArticle", mappedBy="user") */ + #[OneToMany(targetEntity: 'LegacyArticle', mappedBy: 'user')] public $articles; /** * @psalm-var Collection - * @OneToMany(targetEntity="LegacyUserReference", mappedBy="_source", cascade={"remove"}) */ + #[OneToMany(targetEntity: 'LegacyUserReference', mappedBy: '_source', cascade: ['remove'])] public $references; /** * @psalm-var Collection - * @ManyToMany(targetEntity="LegacyCar", inversedBy="users", cascade={"persist", "merge"}) - * @JoinTable(name="legacy_users_cars", - * joinColumns={@JoinColumn(name="iUserId", referencedColumnName="iUserId")}, - * inverseJoinColumns={@JoinColumn(name="iCarId", referencedColumnName="iCarId")} - * ) */ + #[JoinTable(name: 'legacy_users_cars')] + #[JoinColumn(name: 'iUserId', referencedColumnName: 'iUserId')] + #[InverseJoinColumn(name: 'iCarId', referencedColumnName: 'iCarId')] + #[ManyToMany(targetEntity: 'LegacyCar', inversedBy: 'users', cascade: ['persist', 'merge'])] public $cars; public function __construct() diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php b/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php index b35810a1184..f0586fda85a 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php @@ -12,33 +12,27 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="legacy_users_reference") - */ +#[Table(name: 'legacy_users_reference')] +#[Entity] class LegacyUserReference { - /** - * @Id - * @ManyToOne(targetEntity="LegacyUser", inversedBy="references") - * @JoinColumn(name="iUserIdSource", referencedColumnName="iUserId") - */ + #[Id] + #[ManyToOne(targetEntity: 'LegacyUser', inversedBy: 'references')] + #[JoinColumn(name: 'iUserIdSource', referencedColumnName: 'iUserId')] private LegacyUser $_source; - /** - * @Id - * @ManyToOne(targetEntity="LegacyUser") - * @JoinColumn(name="iUserIdTarget", referencedColumnName="iUserId") - */ + #[Id] + #[ManyToOne(targetEntity: 'LegacyUser')] + #[JoinColumn(name: 'iUserIdTarget', referencedColumnName: 'iUserId')] private LegacyUser $_target; - /** @Column(type="datetime", name="created") */ + #[Column(type: 'datetime', name: 'created')] private DateTime $created; public function __construct( LegacyUser $source, LegacyUser $target, - /** @Column(type="string", length=255, name="description") */ + #[Column(type: 'string', length: 255, name: 'description')] private string $_description, ) { $source->addReference($this); diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php index 80cd4fda2ab..293da400b9e 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\ManyToManyPersister; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -15,38 +16,28 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="manytomanypersister_child") - */ +#[Table(name: 'manytomanypersister_child')] +#[Entity] class ChildClass { /** - * @ManyToMany(targetEntity=ParentClass::class, inversedBy="children") - * @JoinTable( - * name="parent_child", - * joinColumns={ - * @JoinColumn(name="child_id1", referencedColumnName="id1"), - * @JoinColumn(name="child_id2", referencedColumnName="other_parent_id") - * }, - * inverseJoinColumns={@JoinColumn(name="parent_id", referencedColumnName="id")} - * ) * @var Collection|ParentClass[] * @psalm-var Collection */ + #[JoinTable(name: 'parent_child')] + #[JoinColumn(name: 'child_id1', referencedColumnName: 'id1')] + #[JoinColumn(name: 'child_id2', referencedColumnName: 'other_parent_id')] + #[InverseJoinColumn(name: 'parent_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: ParentClass::class, inversedBy: 'children')] public $parents; public function __construct( - /** - * @Id - * @Column(name="id1", type="integer") - */ + #[Id] + #[Column(name: 'id1', type: 'integer')] public int $id1, - /** - * @Id - * @ManyToOne(targetEntity=OtherParentClass::class, cascade={"persist"}) - * @JoinColumn(name="other_parent_id", referencedColumnName="id") - */ + #[Id] + #[ManyToOne(targetEntity: OtherParentClass::class, cascade: ['persist'])] + #[JoinColumn(name: 'other_parent_id', referencedColumnName: 'id')] public OtherParentClass $otherParent, ) { $this->parents = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php index 6ecf532d13c..30c7392a844 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php @@ -9,17 +9,13 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="manytomanypersister_other_parent") - */ +#[Table(name: 'manytomanypersister_other_parent')] +#[Entity] class OtherParentClass { public function __construct( - /** - * @Id - * @Column(name="id", type="integer") - */ + #[Id] + #[Column(name: 'id', type: 'integer')] public int $id, ) { } diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php index 97846fec23c..f39cb68a494 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php @@ -12,24 +12,20 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="manytomanypersister_parent") - */ +#[Table(name: 'manytomanypersister_parent')] +#[Entity] class ParentClass { /** - * @ManyToMany(targetEntity=ChildClass::class, mappedBy="parents", orphanRemoval=true, cascade={"persist"}) * @var Collection|ChildClass[] * @psalm-var Collection */ + #[ManyToMany(targetEntity: ChildClass::class, mappedBy: 'parents', orphanRemoval: true, cascade: ['persist'])] public $children; public function __construct( - /** - * @Id - * @Column(name="id", type="integer") - */ + #[Id] + #[Column(name: 'id', type: 'integer')] public int $id, ) { $this->children = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php b/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php index 4e092d4b5d6..75c5efd7e8e 100644 --- a/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php +++ b/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php @@ -11,22 +11,22 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; -/** @Entity */ +#[Entity] class CompositeToOneKeyState { /** * @var string - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] public $state; /** * @var Country - * @Id - * @ManyToOne(targetEntity="Country", cascade={"MERGE"}) - * @JoinColumn(referencedColumnName="country") */ + #[Id] + #[ManyToOne(targetEntity: 'Country', cascade: ['MERGE'])] + #[JoinColumn(referencedColumnName: 'country')] public $country; } diff --git a/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php b/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php index 0f699fee83e..8187da9ba44 100644 --- a/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php +++ b/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php @@ -9,14 +9,14 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class Country { /** * @var string - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] public $country; } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php index c84d30232e6..9933bfc2041 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php @@ -12,27 +12,23 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="navigation_countries") - */ +#[Table(name: 'navigation_countries')] +#[Entity] class NavCountry { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="NavPointOfInterest", mappedBy="country") */ + #[OneToMany(targetEntity: 'NavPointOfInterest', mappedBy: 'country')] private $pois; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php index e14d49563a9..2618e71be0b 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php @@ -13,29 +13,21 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="navigation_photos") - */ +#[Table(name: 'navigation_photos')] +#[Entity] class NavPhotos { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; public function __construct( - /** - * @ManyToOne(targetEntity="NavPointOfInterest") - * @JoinColumns({ - * @JoinColumn(name="poi_long", referencedColumnName="nav_long"), - * @JoinColumn(name="poi_lat", referencedColumnName="nav_lat") - * }) - */ + #[JoinColumn(name: 'poi_long', referencedColumnName: 'nav_long')] + #[JoinColumn(name: 'poi_lat', referencedColumnName: 'nav_lat')] + #[ManyToOne(targetEntity: 'NavPointOfInterest')] private NavPointOfInterest $poi, - /** @Column(type="string", length=255, name="file_name") */ + #[Column(type: 'string', length: 255, name: 'file_name')] private string $file, ) { } diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php index 5586c6b17db..76d7bcdafb1 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Navigation; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -15,43 +16,34 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="navigation_pois") - */ +#[Table(name: 'navigation_pois')] +#[Entity] class NavPointOfInterest { - /** - * @Id - * @Column(type="integer", name="nav_long") - */ + #[Id] + #[Column(type: 'integer', name: 'nav_long')] private int $long; - /** - * @Id - * @Column(type="integer", name="nav_lat") - */ + #[Id] + #[Column(type: 'integer', name: 'nav_lat')] private int $lat; /** * @psalm-var Collection - * @ManyToMany(targetEntity="NavUser", cascade={"persist"}) - * @JoinTable(name="navigation_pois_visitors", - * inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, - * joinColumns={ - * @JoinColumn(name="poi_long", referencedColumnName="nav_long"), - * @JoinColumn(name="poi_lat", referencedColumnName="nav_lat") - * } - * ) */ + #[JoinTable(name: 'navigation_pois_visitors')] + #[JoinColumn(name: 'poi_long', referencedColumnName: 'nav_long')] + #[JoinColumn(name: 'poi_lat', referencedColumnName: 'nav_lat')] + #[InverseJoinColumn(name: 'user_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'NavUser', cascade: ['persist'])] private $visitors; public function __construct( int $lat, int $long, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name, - /** @ManyToOne(targetEntity="NavCountry", inversedBy="pois") */ + #[ManyToOne(targetEntity: 'NavCountry', inversedBy: 'pois')] private NavCountry $country, ) { $this->lat = $lat; diff --git a/tests/Doctrine/Tests/Models/Navigation/NavTour.php b/tests/Doctrine/Tests/Models/Navigation/NavTour.php index 3e75d220b8c..5d9ff440d46 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavTour.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavTour.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Navigation; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -15,34 +16,27 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="navigation_tours") - */ +#[Table(name: 'navigation_tours')] +#[Entity] class NavTour { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @var Collection - * @ManyToMany(targetEntity="NavPointOfInterest") - * @JoinTable(name="navigation_tour_pois", - * joinColumns={@JoinColumn(name="tour_id", referencedColumnName="id")}, - * inverseJoinColumns={ - * @JoinColumn(name="poi_long", referencedColumnName="nav_long"), - * @JoinColumn(name="poi_lat", referencedColumnName="nav_lat") - * } - * ) */ + #[JoinTable(name: 'navigation_tour_pois')] + #[JoinColumn(name: 'tour_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'poi_long', referencedColumnName: 'nav_long')] + #[InverseJoinColumn(name: 'poi_lat', referencedColumnName: 'nav_lat')] + #[ManyToMany(targetEntity: 'NavPointOfInterest')] private Collection $pois; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name, ) { $this->pois = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/Navigation/NavUser.php b/tests/Doctrine/Tests/Models/Navigation/NavUser.php index 86a407c8fcd..d87555508ac 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavUser.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavUser.php @@ -10,21 +10,17 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="navigation_users") - */ +#[Table(name: 'navigation_users')] +#[Entity] class NavUser { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php b/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php index a808127260f..32e5b205dcf 100644 --- a/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php +++ b/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\NonPublicSchemaJoins; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; @@ -14,34 +15,30 @@ /** * Doctrine\Tests\Models\NonPublicSchemaJoins\User - * - * @Entity - * @Table(name="readers.user") */ +#[Table(name: 'readers.user')] +#[Entity] class User { /** * @var int - * @Column(type="integer") - * @Id */ + #[Column(type: 'integer')] + #[Id] public $id; /** - * @ManyToMany(targetEntity="Doctrine\Tests\Models\NonPublicSchemaJoins\User", inversedBy="authors") - * @JoinTable( - * name="author_reader", - * schema="readers", - * joinColumns={@JoinColumn(name="author_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="reader_id", referencedColumnName="id")} - * ) * @var User[] */ + #[JoinTable(name: 'author_reader', schema: 'readers')] + #[JoinColumn(name: 'author_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'reader_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'Doctrine\Tests\Models\NonPublicSchemaJoins\User', inversedBy: 'authors')] public $readers; /** - * @ManyToMany(targetEntity="Doctrine\Tests\Models\NonPublicSchemaJoins\User", mappedBy="readers") * @var User[] */ + #[ManyToMany(targetEntity: 'Doctrine\Tests\Models\NonPublicSchemaJoins\User', mappedBy: 'readers')] public $authors; } diff --git a/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php b/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php index 308adccba86..9f22778c51b 100644 --- a/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php +++ b/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php @@ -9,20 +9,20 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class NullDefaultColumn { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var mixed - * @Column(options={"default":NULL}) */ + #[Column(options: ['default' => null])] public $nullDefault; } diff --git a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php b/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php index 69d988f3492..41698b28e18 100644 --- a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php +++ b/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php @@ -11,23 +11,21 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity() - * @Table(name="one_to_one_inverse_side_load_inverse") - */ +#[Table(name: 'one_to_one_inverse_side_load_inverse')] +#[Entity] class InverseSide { /** * @var string - * @Id() - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] public $id; /** * @var OwningSide - * @OneToOne(targetEntity=OwningSide::class, mappedBy="inverse") */ + #[OneToOne(targetEntity: OwningSide::class, mappedBy: 'inverse')] public $owning; } diff --git a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php b/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php index f9099165f06..f4b6da7a9d8 100644 --- a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php +++ b/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php @@ -12,26 +12,24 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity() - * @Table(name="one_to_one_inverse_side_load_owning") - */ +#[Table(name: 'one_to_one_inverse_side_load_owning')] +#[Entity] class OwningSide { /** * @var string - * @Id() - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] public $id; /** * Owning side * * @var InverseSide - * @OneToOne(targetEntity=InverseSide::class, inversedBy="owning") - * @JoinColumn(nullable=false, name="inverse") */ + #[OneToOne(targetEntity: InverseSide::class, inversedBy: 'owning')] + #[JoinColumn(nullable: false, name: 'inverse')] public $inverse; } diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php index adc0a218a05..7cbaebe381b 100644 --- a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php +++ b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php @@ -7,12 +7,12 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\OneToOne; -/** @Entity */ +#[Entity] class Cat extends Pet { /** * @var LitterBox - * @OneToOne(targetEntity="LitterBox") */ + #[OneToOne(targetEntity: 'LitterBox')] public $litterBox; } diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php index e00b3176d05..1bfcd7b707f 100644 --- a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php +++ b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php @@ -10,17 +10,15 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="one_to_one_single_table_inheritance_litter_box") - */ +#[Table(name: 'one_to_one_single_table_inheritance_litter_box')] +#[Entity] class LitterBox { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php index 597706e5c99..33df9837d46 100644 --- a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php +++ b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php @@ -12,19 +12,17 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="one_to_one_single_table_inheritance_pet") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"cat" = "Cat"}) - */ +#[Table(name: 'one_to_one_single_table_inheritance_pet')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorMap(['cat' => 'Cat'])] abstract class Pet { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/Models/Pagination/Company.php b/tests/Doctrine/Tests/Models/Pagination/Company.php index fa4309c69cd..e7b7ee6f69c 100644 --- a/tests/Doctrine/Tests/Models/Pagination/Company.php +++ b/tests/Doctrine/Tests/Models/Pagination/Company.php @@ -15,41 +15,40 @@ /** * Company - * - * @Entity - * @Table(name="pagination_company") */ +#[Table(name: 'pagination_company')] +#[Entity] class Company { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @var string - * @Column(type="string", length=255, name="jurisdiction_code", nullable=true) */ + #[Column(type: 'string', length: 255, name: 'jurisdiction_code', nullable: true)] public $jurisdiction; /** * @var Logo - * @OneToOne(targetEntity="Logo", mappedBy="company", cascade={"persist"}, orphanRemoval=true) */ + #[OneToOne(targetEntity: 'Logo', mappedBy: 'company', cascade: ['persist'], orphanRemoval: true)] public $logo; /** * @psalm-var Collection - * @OneToMany(targetEntity="Department", mappedBy="company", cascade={"persist"}, orphanRemoval=true) */ + #[OneToMany(targetEntity: 'Department', mappedBy: 'company', cascade: ['persist'], orphanRemoval: true)] public $departments; } diff --git a/tests/Doctrine/Tests/Models/Pagination/Department.php b/tests/Doctrine/Tests/Models/Pagination/Department.php index d3139dd8c4c..88d3b6d06e8 100644 --- a/tests/Doctrine/Tests/Models/Pagination/Department.php +++ b/tests/Doctrine/Tests/Models/Pagination/Department.php @@ -13,29 +13,28 @@ /** * Department - * - * @Entity - * @Table(name="pagination_department") */ +#[Table(name: 'pagination_department')] +#[Entity] class Department { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @var Company - * @ManyToOne(targetEntity="Company", inversedBy="departments", cascade={"persist"}) */ + #[ManyToOne(targetEntity: 'Company', inversedBy: 'departments', cascade: ['persist'])] public $company; } diff --git a/tests/Doctrine/Tests/Models/Pagination/Logo.php b/tests/Doctrine/Tests/Models/Pagination/Logo.php index 14358c09aee..67f4eb0e963 100644 --- a/tests/Doctrine/Tests/Models/Pagination/Logo.php +++ b/tests/Doctrine/Tests/Models/Pagination/Logo.php @@ -14,42 +14,41 @@ /** * Logo - * - * @Entity - * @Table(name="pagination_logo") */ +#[Table(name: 'pagination_logo')] +#[Entity] class Logo { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $image; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $imageHeight; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $imageWidth; /** * @var Company - * @OneToOne(targetEntity="Company", inversedBy="logo", cascade={"persist"}) - * @JoinColumn(name="company_id") */ + #[OneToOne(targetEntity: 'Company', inversedBy: 'logo', cascade: ['persist'])] + #[JoinColumn(name: 'company_id')] public $company; } diff --git a/tests/Doctrine/Tests/Models/Pagination/User.php b/tests/Doctrine/Tests/Models/Pagination/User.php index 231cc635e21..c35fd44bd81 100644 --- a/tests/Doctrine/Tests/Models/Pagination/User.php +++ b/tests/Doctrine/Tests/Models/Pagination/User.php @@ -13,25 +13,21 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="pagination_user") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="string", length=255) - * @DiscriminatorMap({"user1"="User1"}) - */ +#[Table(name: 'pagination_user')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'type', type: 'string', length: 255)] +#[DiscriminatorMap(['user1' => 'User1'])] abstract class User { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; } diff --git a/tests/Doctrine/Tests/Models/Pagination/User1.php b/tests/Doctrine/Tests/Models/Pagination/User1.php index e05eb9342f1..8b79a281414 100644 --- a/tests/Doctrine/Tests/Models/Pagination/User1.php +++ b/tests/Doctrine/Tests/Models/Pagination/User1.php @@ -7,12 +7,12 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; -/** @Entity() */ +#[Entity] class User1 extends User { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $email; } diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php index 1ced97b1afa..8b964ee3ae8 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php @@ -10,14 +10,14 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class PersistentCollectionContent extends PersistentObject { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; } diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php index 613c89548d5..35bcd1029c4 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php @@ -13,21 +13,21 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; -/** @Entity */ +#[Entity] class PersistentCollectionHolder extends PersistentObject { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; /** * @var Collection - * @ManyToMany(targetEntity="PersistentCollectionContent", cascade={"all"}, fetch="EXTRA_LAZY") */ + #[ManyToMany(targetEntity: 'PersistentCollectionContent', cascade: ['all'], fetch: 'EXTRA_LAZY')] protected $collection; public function __construct() diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php index 25813bf54be..cc5a659ec2d 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php @@ -11,26 +11,26 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToOne; -/** @Entity */ +#[Entity] class PersistentEntity extends PersistentObject { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; /** - * @Column(type="string", length=255) * @var string */ + #[Column(type: 'string', length: 255)] protected $name; /** - * @ManyToOne(targetEntity="PersistentEntity") * @var PersistentEntity */ + #[ManyToOne(targetEntity: 'PersistentEntity')] protected $parent; } diff --git a/tests/Doctrine/Tests/Models/Quote/Address.php b/tests/Doctrine/Tests/Models/Quote/Address.php index b5f3fd2d95c..f0cbf4083fc 100644 --- a/tests/Doctrine/Tests/Models/Quote/Address.php +++ b/tests/Doctrine/Tests/Models/Quote/Address.php @@ -15,34 +15,32 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="`quote-address`") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="string", length=255) - * @DiscriminatorMap({"simple" = Address::class, "full" = FullAddress::class}) - */ +#[Table(name: '`quote-address`')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'type', type: 'string', length: 255)] +#[DiscriminatorMap(['simple' => Address::class, 'full' => FullAddress::class])] class Address { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer", name="`address-id`") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer', name: '`address-id`')] public $id; /** * @var string - * @Column(name="`address-zip`") */ + #[Column(name: '`address-zip`')] public $zip; /** * @var User - * @OneToOne(targetEntity="User", inversedBy="address") - * @JoinColumn(name="`user-id`", referencedColumnName="`user-id`") */ + #[OneToOne(targetEntity: 'User', inversedBy: 'address')] + #[JoinColumn(name: '`user-id`', referencedColumnName: '`user-id`')] public $user; public function setUser(User $user): void diff --git a/tests/Doctrine/Tests/Models/Quote/City.php b/tests/Doctrine/Tests/Models/Quote/City.php index 41a1501c457..f60472c06c1 100644 --- a/tests/Doctrine/Tests/Models/Quote/City.php +++ b/tests/Doctrine/Tests/Models/Quote/City.php @@ -10,22 +10,20 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="`quote-city`") - */ +#[Table(name: '`quote-city`')] +#[Entity] class City { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer", name="`city-id`") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer', name: '`city-id`')] public $id; public function __construct( - /** @Column(name="`city-name`") */ + #[Column(name: '`city-name`')] public string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/Quote/FullAddress.php b/tests/Doctrine/Tests/Models/Quote/FullAddress.php index 7e84abd7625..fbefed7b9d7 100644 --- a/tests/Doctrine/Tests/Models/Quote/FullAddress.php +++ b/tests/Doctrine/Tests/Models/Quote/FullAddress.php @@ -8,13 +8,13 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; -/** @Entity */ +#[Entity] class FullAddress extends Address { /** * @var City - * @OneToOne(targetEntity=City::class, cascade={"persist"}) - * @JoinColumn(name="`city-id`", referencedColumnName="`city-id`") */ + #[OneToOne(targetEntity: City::class, cascade: ['persist'])] + #[JoinColumn(name: '`city-id`', referencedColumnName: '`city-id`')] public $city; } diff --git a/tests/Doctrine/Tests/Models/Quote/Group.php b/tests/Doctrine/Tests/Models/Quote/Group.php index 0f4bf935332..8a4e4654b93 100644 --- a/tests/Doctrine/Tests/Models/Quote/Group.php +++ b/tests/Doctrine/Tests/Models/Quote/Group.php @@ -14,33 +14,29 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="`quote-group`") - */ +#[Table(name: '`quote-group`')] +#[Entity] class Group { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer", name="`group-id`") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer', name: '`group-id`')] public $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity="User", mappedBy="groups") */ + #[ManyToMany(targetEntity: 'User', mappedBy: 'groups')] public $users; public function __construct( - /** @Column(name="`group-name`") */ + #[Column(name: '`group-name`')] public string|null $name = null, - /** - * @ManyToOne(targetEntity="Group", cascade={"persist"}) - * @JoinColumn(name="`parent-id`", referencedColumnName="`group-id`") - */ + #[ManyToOne(targetEntity: 'Group', cascade: ['persist'])] + #[JoinColumn(name: '`parent-id`', referencedColumnName: '`group-id`')] public Group|null $parent = null, ) { } diff --git a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php index f453eef06d2..aa3d1b4643b 100644 --- a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php +++ b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php @@ -10,22 +10,20 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="table") - */ +#[Table(name: 'table')] +#[Entity] class NumericEntity { /** * @var int - * @Id - * @Column(type="integer", name="`1:1`") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer', name: '`1:1`')] + #[GeneratedValue(strategy: 'AUTO')] public $id; public function __construct( - /** @Column(type="string", length=255, name="`2:2`") */ + #[Column(type: 'string', length: 255, name: '`2:2`')] public string $value, ) { } diff --git a/tests/Doctrine/Tests/Models/Quote/Phone.php b/tests/Doctrine/Tests/Models/Quote/Phone.php index 0102a01e04c..13625b99011 100644 --- a/tests/Doctrine/Tests/Models/Quote/Phone.php +++ b/tests/Doctrine/Tests/Models/Quote/Phone.php @@ -11,23 +11,21 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="`quote-phone`") - */ +#[Table(name: '`quote-phone`')] +#[Entity] class Phone { /** * @var string - * @Id - * @Column(name="`phone-number`") */ + #[Id] + #[Column(name: '`phone-number`')] public $number; /** * @var User - * @ManyToOne(targetEntity="User", inversedBy="phones") - * @JoinColumn(name="`user-id`", referencedColumnName="`user-id`") */ + #[ManyToOne(targetEntity: 'User', inversedBy: 'phones')] + #[JoinColumn(name: '`user-id`', referencedColumnName: '`user-id`')] public $user; } diff --git a/tests/Doctrine/Tests/Models/Quote/User.php b/tests/Doctrine/Tests/Models/Quote/User.php index 1367cb7e00a..11ca1b3211b 100644 --- a/tests/Doctrine/Tests/Models/Quote/User.php +++ b/tests/Doctrine/Tests/Models/Quote/User.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Quote; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -17,57 +18,44 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="`quote-user`") - */ +#[Table(name: '`quote-user`')] +#[Entity] class User { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer", name="`user-id`") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer', name: '`user-id`')] public $id; /** * @var string - * @Column(type="string", length=255, name="`user-name`") */ + #[Column(type: 'string', length: 255, name: '`user-name`')] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="Phone", mappedBy="user", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'Phone', mappedBy: 'user', cascade: ['persist'])] public $phones; /** * @var Address - * @JoinColumn(name="`address-id`", referencedColumnName="`address-id`") - * @OneToOne(targetEntity="Address", mappedBy="user", cascade={"persist"}, fetch="EAGER") */ + #[JoinColumn(name: '`address-id`', referencedColumnName: '`address-id`')] + #[OneToOne(targetEntity: 'Address', mappedBy: 'user', cascade: ['persist'], fetch: 'EAGER')] public $address; /** * @psalm-var Collection - * @ManyToMany(targetEntity="Group", inversedBy="users", cascade={"all"}, fetch="EXTRA_LAZY") - * @JoinTable(name="`quote-users-groups`", - * joinColumns={ - * @JoinColumn( - * name="`user-id`", - * referencedColumnName="`user-id`" - * ) - * }, - * inverseJoinColumns={ - * @JoinColumn( - * name="`group-id`", - * referencedColumnName="`group-id`" - * ) - * } - * ) */ + #[JoinTable(name: '`quote-users-groups`')] + #[JoinColumn(name: '`user-id`', referencedColumnName: '`user-id`')] + #[InverseJoinColumn(name: '`group-id`', referencedColumnName: '`group-id`')] + #[ManyToMany(targetEntity: 'Group', inversedBy: 'users', cascade: ['all'], fetch: 'EXTRA_LAZY')] public $groups; public function __construct() diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php b/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php index ee8808c2eda..6bb473f11b8 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php @@ -11,40 +11,40 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; -/** @Entity */ +#[Entity] class RoutingLeg { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var RoutingLocation - * @ManyToOne(targetEntity="RoutingLocation") - * @JoinColumn(name="from_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'RoutingLocation')] + #[JoinColumn(name: 'from_id', referencedColumnName: 'id')] public $fromLocation; /** * @var RoutingLocation - * @ManyToOne(targetEntity="RoutingLocation") - * @JoinColumn(name="to_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'RoutingLocation')] + #[JoinColumn(name: 'to_id', referencedColumnName: 'id')] public $toLocation; /** * @var DateTime - * @Column(type="datetime") */ + #[Column(type: 'datetime')] public $departureDate; /** * @var DateTime - * @Column(type="datetime") */ + #[Column(type: 'datetime')] public $arrivalDate; } diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php b/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php index 38ff74ce4c4..fee78ad274f 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php @@ -9,21 +9,21 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; -/** @Entity */ +#[Entity] class RoutingLocation { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; public function getName(): string diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php b/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php index e95a54da6ba..ce4db441445 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\Routing; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -16,33 +17,32 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OrderBy; -/** @Entity */ +#[Entity] class RoutingRoute { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var Collection - * @ManyToMany(targetEntity="RoutingLeg", cascade={"all"}) - * @JoinTable(name="RoutingRouteLegs", - * joinColumns={@JoinColumn(name="route_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="leg_id", referencedColumnName="id", unique=true)} - * ) - * @OrderBy({"departureDate" = "ASC"}) */ + #[JoinTable(name: 'RoutingRouteLegs')] + #[JoinColumn(name: 'route_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'leg_id', referencedColumnName: 'id', unique: true)] + #[ManyToMany(targetEntity: 'RoutingLeg', cascade: ['all'])] + #[OrderBy(['departureDate' => 'ASC'])] public $legs; /** * @var Collection - * @OneToMany(targetEntity="RoutingRouteBooking", mappedBy="route") - * @OrderBy({"passengerName" = "ASC"}) */ + #[OneToMany(targetEntity: 'RoutingRouteBooking', mappedBy: 'route')] + #[OrderBy(['passengerName' => 'ASC'])] public $bookings = []; public function __construct() diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php b/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php index 4d769bc5a9f..2d070e6a396 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php @@ -11,28 +11,28 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; -/** @Entity */ +#[Entity] class RoutingRouteBooking { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var RoutingRoute - * @ManyToOne(targetEntity="RoutingRoute", inversedBy="bookings") - * @JoinColumn(name="route_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'RoutingRoute', inversedBy: 'bookings')] + #[JoinColumn(name: 'route_id', referencedColumnName: 'id')] public $route; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $passengerName = null; public function getPassengerName(): string diff --git a/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/tests/Doctrine/Tests/Models/StockExchange/Bond.php index b03d15fdd38..f9a6e026eda 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Bond.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Bond.php @@ -15,28 +15,25 @@ /** * Bonds have many stocks. This uses a many to many association and fails to model how many of a * particular stock a bond has. But i Need a many-to-many association, so please bear with my modelling skills ;) - * - * @Entity - * @Table(name="exchange_bonds") */ +#[Table(name: 'exchange_bonds')] +#[Entity] class Bond { - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; /** - * @ManyToMany(targetEntity="Stock", indexBy="symbol") - * @JoinTable(name="exchange_bonds_stocks") * @var Stock[] */ + #[JoinTable(name: 'exchange_bonds_stocks')] + #[ManyToMany(targetEntity: 'Stock', indexBy: 'symbol')] public $stocks; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name, ) { } diff --git a/tests/Doctrine/Tests/Models/StockExchange/Market.php b/tests/Doctrine/Tests/Models/StockExchange/Market.php index 7c7cf4584d5..2f65ab0ddc8 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Market.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Market.php @@ -12,27 +12,23 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="exchange_markets") - */ +#[Table(name: 'exchange_markets')] +#[Entity] class Market { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** - * @OneToMany(targetEntity="Stock", mappedBy="market", indexBy="symbol") * @psalm-var ArrayCollection */ + #[OneToMany(targetEntity: 'Stock', mappedBy: 'market', indexBy: 'symbol')] public $stocks; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name, ) { $this->stocks = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/Models/StockExchange/Stock.php b/tests/Doctrine/Tests/Models/StockExchange/Stock.php index 153e0a5eafe..a40d3cbe235 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Stock.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Stock.php @@ -11,29 +11,24 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="exchange_stocks") - */ +#[Table(name: 'exchange_stocks')] +#[Entity] class Stock { - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; public function __construct( /** * For real this column would have to be unique=true. But I want to test behavior of non-unique overrides. - * - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $symbol, - /** @Column(type="decimal", precision=10) */ + #[Column(type: 'decimal', precision: 10)] private float $price, - /** @ManyToOne(targetEntity="Market", inversedBy="stocks") */ + #[ManyToOne(targetEntity: 'Market', inversedBy: 'stocks')] private Market $market, ) { $market->addStock($this); diff --git a/tests/Doctrine/Tests/Models/Taxi/Car.php b/tests/Doctrine/Tests/Models/Taxi/Car.php index f1443da8dcc..e09b0169f02 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Car.php +++ b/tests/Doctrine/Tests/Models/Taxi/Car.php @@ -12,32 +12,28 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="taxi_car") - */ +#[Table(name: 'taxi_car')] +#[Entity] class Car { - /** - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 25)] + #[GeneratedValue(strategy: 'NONE')] private string|null $brand = null; - /** @Column(type="string", length=255); */ + #[Column(type: 'string', length: 255)] private string|null $model = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="Ride", mappedBy="car") */ + #[OneToMany(targetEntity: 'Ride', mappedBy: 'car')] private $freeCarRides; /** * @psalm-var Collection - * @OneToMany(targetEntity="PaidRide", mappedBy="car") */ + #[OneToMany(targetEntity: 'PaidRide', mappedBy: 'car')] private $carRides; public function getBrand(): string diff --git a/tests/Doctrine/Tests/Models/Taxi/Driver.php b/tests/Doctrine/Tests/Models/Taxi/Driver.php index c27ccbadd09..8fcefbfb3b2 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Driver.php +++ b/tests/Doctrine/Tests/Models/Taxi/Driver.php @@ -12,32 +12,28 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="taxi_driver") - */ +#[Table(name: 'taxi_driver')] +#[Entity] class Driver { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", length=255); */ + #[Column(type: 'string', length: 255)] private string|null $name = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="Ride", mappedBy="driver") */ + #[OneToMany(targetEntity: 'Ride', mappedBy: 'driver')] private $freeDriverRides; /** * @psalm-var Collection - * @OneToMany(targetEntity="PaidRide", mappedBy="driver") */ + #[OneToMany(targetEntity: 'PaidRide', mappedBy: 'driver')] private $driverRides; public function getId(): int diff --git a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php index 98ff20ec032..a41e9f6dda2 100644 --- a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php +++ b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php @@ -13,30 +13,25 @@ /** * Same as Ride but with an extra column that is not part of the composite primary key - * - * @Entity - * @Table(name="taxi_paid_ride") */ +#[Table(name: 'taxi_paid_ride')] +#[Entity] class PaidRide { /** * @var float - * @Column(type="decimal", precision=6, scale=2) */ + #[Column(type: 'decimal', precision: 6, scale: 2)] private $fare; public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="Driver", inversedBy="driverRides") - * @JoinColumn(name="driver_id", referencedColumnName="id") - */ + #[Id] + #[ManyToOne(targetEntity: 'Driver', inversedBy: 'driverRides')] + #[JoinColumn(name: 'driver_id', referencedColumnName: 'id')] private Driver $driver, - /** - * @Id - * @ManyToOne(targetEntity="Car", inversedBy="carRides") - * @JoinColumn(name="car", referencedColumnName="brand") - */ + #[Id] + #[ManyToOne(targetEntity: 'Car', inversedBy: 'carRides')] + #[JoinColumn(name: 'car', referencedColumnName: 'brand')] private Car $car, ) { } diff --git a/tests/Doctrine/Tests/Models/Taxi/Ride.php b/tests/Doctrine/Tests/Models/Taxi/Ride.php index 099ffdb883c..878447fa741 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Ride.php +++ b/tests/Doctrine/Tests/Models/Taxi/Ride.php @@ -12,24 +12,19 @@ /** * Test model that contains only Id-columns - * - * @Entity - * @Table(name="taxi_ride") */ +#[Table(name: 'taxi_ride')] +#[Entity] class Ride { public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="Driver", inversedBy="freeDriverRides") - * @JoinColumn(name="driver_id", referencedColumnName="id") - */ + #[Id] + #[ManyToOne(targetEntity: 'Driver', inversedBy: 'freeDriverRides')] + #[JoinColumn(name: 'driver_id', referencedColumnName: 'id')] private Driver $driver, - /** - * @Id - * @ManyToOne(targetEntity="Car", inversedBy="freeCarRides") - * @JoinColumn(name="car", referencedColumnName="brand") - */ + #[Id] + #[ManyToOne(targetEntity: 'Car', inversedBy: 'freeCarRides')] + #[JoinColumn(name: 'car', referencedColumnName: 'brand')] private Car $car, ) { } diff --git a/tests/Doctrine/Tests/Models/Tweet/Tweet.php b/tests/Doctrine/Tests/Models/Tweet/Tweet.php index f53ad2f1aa3..01a88f1f25a 100644 --- a/tests/Doctrine/Tests/Models/Tweet/Tweet.php +++ b/tests/Doctrine/Tests/Models/Tweet/Tweet.php @@ -11,30 +11,28 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="tweet_tweet") - */ +#[Table(name: 'tweet_tweet')] +#[Entity] class Tweet { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $content; /** * @var User - * @ManyToOne(targetEntity="User", inversedBy="tweets") */ + #[ManyToOne(targetEntity: 'User', inversedBy: 'tweets')] public $author; public function setAuthor(User $user): void diff --git a/tests/Doctrine/Tests/Models/Tweet/User.php b/tests/Doctrine/Tests/Models/Tweet/User.php index b134136ab0f..9b99e6d0d30 100644 --- a/tests/Doctrine/Tests/Models/Tweet/User.php +++ b/tests/Doctrine/Tests/Models/Tweet/User.php @@ -13,36 +13,34 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="tweet_user") - */ +#[Table(name: 'tweet_user')] +#[Entity] class User { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="Tweet", mappedBy="author", cascade={"persist"}, fetch="EXTRA_LAZY") */ + #[OneToMany(targetEntity: 'Tweet', mappedBy: 'author', cascade: ['persist'], fetch: 'EXTRA_LAZY')] public $tweets; /** * @psalm-var Collection - * @OneToMany(targetEntity="UserList", mappedBy="owner", fetch="EXTRA_LAZY", orphanRemoval=true) */ + #[OneToMany(targetEntity: 'UserList', mappedBy: 'owner', fetch: 'EXTRA_LAZY', orphanRemoval: true)] public $userLists; public function __construct() diff --git a/tests/Doctrine/Tests/Models/Tweet/UserList.php b/tests/Doctrine/Tests/Models/Tweet/UserList.php index 2695e723f7d..faf22c01e39 100644 --- a/tests/Doctrine/Tests/Models/Tweet/UserList.php +++ b/tests/Doctrine/Tests/Models/Tweet/UserList.php @@ -11,29 +11,27 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="tweet_user_list") - */ +#[Table(name: 'tweet_user_list')] +#[Entity] class UserList { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $listName; /** * @var User - * @ManyToOne(targetEntity="User", inversedBy="userLists") */ + #[ManyToOne(targetEntity: 'User', inversedBy: 'userLists')] public $owner; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php index 2aa60cc8e63..74deaed199e 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php @@ -9,16 +9,14 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_auxiliary") - */ +#[Table(name: 'vct_auxiliary')] +#[Entity] class AuxiliaryEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id4; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php index a3c495ede67..640af5746b9 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php @@ -12,30 +12,28 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_manytomany_compositeid") - */ +#[Table(name: 'vct_inversed_manytomany_compositeid')] +#[Entity] class InversedManyToManyCompositeIdEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @psalm-var Collection - * @ManyToMany(targetEntity="OwningManyToManyCompositeIdEntity", mappedBy="associatedEntities") */ + #[ManyToMany(targetEntity: 'OwningManyToManyCompositeIdEntity', mappedBy: 'associatedEntities')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php index d86ee008ee0..d0798d3a06f 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php @@ -14,31 +14,29 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_manytomany_compositeid_foreignkey") - */ +#[Table(name: 'vct_inversed_manytomany_compositeid_foreignkey')] +#[Entity] class InversedManyToManyCompositeIdForeignKeyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var AuxiliaryEntity - * @ManyToOne(targetEntity="AuxiliaryEntity") - * @JoinColumn(name="foreign_id", referencedColumnName="id4") - * @Id */ + #[ManyToOne(targetEntity: 'AuxiliaryEntity')] + #[JoinColumn(name: 'foreign_id', referencedColumnName: 'id4')] + #[Id] public $foreignEntity; /** * @psalm-var Collection - * @ManyToMany(targetEntity="OwningManyToManyCompositeIdForeignKeyEntity", mappedBy="associatedEntities") */ + #[ManyToMany(targetEntity: 'OwningManyToManyCompositeIdForeignKeyEntity', mappedBy: 'associatedEntities')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php index 94d499fdbe8..687f333e39d 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php @@ -12,23 +12,21 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_manytomany") - */ +#[Table(name: 'vct_inversed_manytomany')] +#[Entity] class InversedManyToManyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @psalm-var Collection - * @ManyToMany(targetEntity="OwningManyToManyEntity", mappedBy="associatedEntities") */ + #[ManyToMany(targetEntity: 'OwningManyToManyEntity', mappedBy: 'associatedEntities')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php index b949fad6328..857d9ab9daf 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php @@ -12,28 +12,21 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_manytomany_extralazy") - */ +#[Table(name: 'vct_inversed_manytomany_extralazy')] +#[Entity] class InversedManyToManyExtraLazyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var Collection - * @ManyToMany( - * targetEntity="OwningManyToManyExtraLazyEntity", - * mappedBy="associatedEntities", - * fetch="EXTRA_LAZY", - * indexBy="id2" - * ) */ + #[ManyToMany(targetEntity: 'OwningManyToManyExtraLazyEntity', mappedBy: 'associatedEntities', fetch: 'EXTRA_LAZY', indexBy: 'id2')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php index 066674be04d..dfab64d2436 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php @@ -12,36 +12,34 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_onetomany_compositeid") - */ +#[Table(name: 'vct_inversed_onetomany_compositeid')] +#[Entity] class InversedOneToManyCompositeIdEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var string - * @Column(type="string", length=255, name="some_property") */ + #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; /** * @psalm-var Collection - * @OneToMany(targetEntity="OwningManyToOneCompositeIdEntity", mappedBy="associatedEntity") */ + #[OneToMany(targetEntity: 'OwningManyToOneCompositeIdEntity', mappedBy: 'associatedEntity')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php index 944379eec6c..c2b82e76fc6 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php @@ -14,37 +14,35 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_onetomany_compositeid_foreignkey") - */ +#[Table(name: 'vct_inversed_onetomany_compositeid_foreignkey')] +#[Entity] class InversedOneToManyCompositeIdForeignKeyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var AuxiliaryEntity - * @ManyToOne(targetEntity="AuxiliaryEntity") - * @JoinColumn(name="foreign_id", referencedColumnName="id4") - * @Id */ + #[ManyToOne(targetEntity: 'AuxiliaryEntity')] + #[JoinColumn(name: 'foreign_id', referencedColumnName: 'id4')] + #[Id] public $foreignEntity; /** * @var string - * @Column(type="string", length=255, name="some_property") */ + #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; /** * @psalm-var Collection - * @OneToMany(targetEntity="OwningManyToOneCompositeIdForeignKeyEntity", mappedBy="associatedEntity") */ + #[OneToMany(targetEntity: 'OwningManyToOneCompositeIdForeignKeyEntity', mappedBy: 'associatedEntity')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php index 9d69f8c28a4..bca66220a97 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php @@ -12,29 +12,27 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_onetomany") - */ +#[Table(name: 'vct_inversed_onetomany')] +#[Entity] class InversedOneToManyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @psalm-var Collection - * @OneToMany(targetEntity="OwningManyToOneEntity", mappedBy="associatedEntity") */ + #[OneToMany(targetEntity: 'OwningManyToOneEntity', mappedBy: 'associatedEntity')] public $associatedEntities; /** * @var string - * @Column(type="string", name="some_property", length=255) */ + #[Column(type: 'string', name: 'some_property', length: 255)] public $someProperty; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php index d748fb77489..7213d1cf19f 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php @@ -12,28 +12,21 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_onetomany_extralazy") - */ +#[Table(name: 'vct_inversed_onetomany_extralazy')] +#[Entity] class InversedOneToManyExtraLazyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var Collection - * @OneToMany( - * targetEntity="OwningManyToOneExtraLazyEntity", - * mappedBy="associatedEntity", - * fetch="EXTRA_LAZY", - * indexBy="id2" - * ) */ + #[OneToMany(targetEntity: 'OwningManyToOneExtraLazyEntity', mappedBy: 'associatedEntity', fetch: 'EXTRA_LAZY', indexBy: 'id2')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php index 9d7d071ce9e..8a867705f96 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php @@ -10,35 +10,33 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_onetoone_compositeid") - */ +#[Table(name: 'vct_inversed_onetoone_compositeid')] +#[Entity] class InversedOneToOneCompositeIdEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var string - * @Column(type="string", length=255, name="some_property") */ + #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; /** * @var OwningOneToOneCompositeIdEntity - * @OneToOne(targetEntity="OwningOneToOneCompositeIdEntity", mappedBy="associatedEntity") */ + #[OneToOne(targetEntity: 'OwningOneToOneCompositeIdEntity', mappedBy: 'associatedEntity')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php index 18b40c7f7d3..7eff93ea244 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php @@ -12,36 +12,34 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_onetoone_compositeid_foreignkey") - */ +#[Table(name: 'vct_inversed_onetoone_compositeid_foreignkey')] +#[Entity] class InversedOneToOneCompositeIdForeignKeyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var AuxiliaryEntity - * @ManyToOne(targetEntity="AuxiliaryEntity") - * @JoinColumn(name="foreign_id", referencedColumnName="id4") - * @Id */ + #[ManyToOne(targetEntity: 'AuxiliaryEntity')] + #[JoinColumn(name: 'foreign_id', referencedColumnName: 'id4')] + #[Id] public $foreignEntity; /** * @var string - * @Column(type="string", length=255, name="some_property") */ + #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; /** * @var OwningOneToOneCompositeIdForeignKeyEntity - * @OneToOne(targetEntity="OwningOneToOneCompositeIdForeignKeyEntity", mappedBy="associatedEntity") */ + #[OneToOne(targetEntity: 'OwningOneToOneCompositeIdForeignKeyEntity', mappedBy: 'associatedEntity')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php index 9b856b6e32c..f66310aaea3 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php @@ -10,28 +10,26 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_inversed_onetoone") - */ +#[Table(name: 'vct_inversed_onetoone')] +#[Entity] class InversedOneToOneEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id1; /** * @var string - * @Column(type="string", length=255, name="some_property") */ + #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; /** * @var OwningOneToOneEntity - * @OneToOne(targetEntity="OwningOneToOneEntity", mappedBy="associatedEntity") */ + #[OneToOne(targetEntity: 'OwningOneToOneEntity', mappedBy: 'associatedEntity')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php index cda302a420a..fad761aae5b 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\ValueConversionType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -14,31 +15,25 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytomany_compositeid") - */ +#[Table(name: 'vct_owning_manytomany_compositeid')] +#[Entity] class OwningManyToManyCompositeIdEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id3; /** * @var Collection - * @ManyToMany(targetEntity="InversedManyToManyCompositeIdEntity", inversedBy="associatedEntities") - * @JoinTable( - * name="vct_xref_manytomany_compositeid", - * joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id3")}, - * inverseJoinColumns={ - * @JoinColumn(name="inversed_id1", referencedColumnName="id1"), - * @JoinColumn(name="inversed_id2", referencedColumnName="id2") - * } - * ) */ + #[JoinTable(name: 'vct_xref_manytomany_compositeid')] + #[JoinColumn(name: 'owning_id', referencedColumnName: 'id3')] + #[InverseJoinColumn(name: 'inversed_id1', referencedColumnName: 'id1')] + #[InverseJoinColumn(name: 'inversed_id2', referencedColumnName: 'id2')] + #[ManyToMany(targetEntity: 'InversedManyToManyCompositeIdEntity', inversedBy: 'associatedEntities')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php index 823df4958a5..c71d76f344c 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\ValueConversionType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -14,31 +15,25 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytomany_compositeid_foreignkey") - */ +#[Table(name: 'vct_owning_manytomany_compositeid_foreignkey')] +#[Entity] class OwningManyToManyCompositeIdForeignKeyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var Collection - * @ManyToMany(targetEntity="InversedManyToManyCompositeIdForeignKeyEntity", inversedBy="associatedEntities") - * @JoinTable( - * name="vct_xref_manytomany_compositeid_foreignkey", - * joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id2")}, - * inverseJoinColumns={ - * @JoinColumn(name="associated_id", referencedColumnName="id1"), - * @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id") - * } - * ) */ + #[JoinTable(name: 'vct_xref_manytomany_compositeid_foreignkey')] + #[JoinColumn(name: 'owning_id', referencedColumnName: 'id2')] + #[InverseJoinColumn(name: 'associated_id', referencedColumnName: 'id1')] + #[InverseJoinColumn(name: 'associated_foreign_id', referencedColumnName: 'foreign_id')] + #[ManyToMany(targetEntity: 'InversedManyToManyCompositeIdForeignKeyEntity', inversedBy: 'associatedEntities')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php index 4b037be3fca..924d8aec1e9 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\ValueConversionType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -14,28 +15,24 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytomany") - */ +#[Table(name: 'vct_owning_manytomany')] +#[Entity] class OwningManyToManyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var Collection - * @ManyToMany(targetEntity="InversedManyToManyEntity", inversedBy="associatedEntities") - * @JoinTable( - * name="vct_xref_manytomany", - * joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id2")}, - * inverseJoinColumns={@JoinColumn(name="inversed_id", referencedColumnName="id1")} - * ) */ + #[JoinTable(name: 'vct_xref_manytomany')] + #[JoinColumn(name: 'owning_id', referencedColumnName: 'id2')] + #[InverseJoinColumn(name: 'inversed_id', referencedColumnName: 'id1')] + #[ManyToMany(targetEntity: 'InversedManyToManyEntity', inversedBy: 'associatedEntities')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php index 13b12402dce..f8f738f4b66 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\Models\ValueConversionType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -14,33 +15,24 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytomany_extralazy") - */ +#[Table(name: 'vct_owning_manytomany_extralazy')] +#[Entity] class OwningManyToManyExtraLazyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var Collection - * @ManyToMany( - * targetEntity="InversedManyToManyExtraLazyEntity", - * inversedBy="associatedEntities", - * fetch="EXTRA_LAZY", - * indexBy="id1" - * ) - * @JoinTable( - * name="vct_xref_manytomany_extralazy", - * joinColumns={@JoinColumn(name="owning_id", referencedColumnName="id2")}, - * inverseJoinColumns={@JoinColumn(name="inversed_id", referencedColumnName="id1")} - * ) */ + #[JoinTable(name: 'vct_xref_manytomany_extralazy')] + #[JoinColumn(name: 'owning_id', referencedColumnName: 'id2')] + #[InverseJoinColumn(name: 'inversed_id', referencedColumnName: 'id1')] + #[ManyToMany(targetEntity: 'InversedManyToManyExtraLazyEntity', inversedBy: 'associatedEntities', fetch: 'EXTRA_LAZY', indexBy: 'id1')] public $associatedEntities; public function __construct() diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php index 6dee5c8be53..e9717c684c8 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php @@ -12,26 +12,22 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytoone_compositeid") - */ +#[Table(name: 'vct_owning_manytoone_compositeid')] +#[Entity] class OwningManyToOneCompositeIdEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id3; /** * @var InversedOneToManyCompositeIdEntity - * @ManyToOne(targetEntity="InversedOneToManyCompositeIdEntity", inversedBy="associatedEntities") - * @JoinColumns({ - * @JoinColumn(name="associated_id1", referencedColumnName="id1"), - * @JoinColumn(name="associated_id2", referencedColumnName="id2") - * }) */ + #[JoinColumn(name: 'associated_id1', referencedColumnName: 'id1')] + #[JoinColumn(name: 'associated_id2', referencedColumnName: 'id2')] + #[ManyToOne(targetEntity: 'InversedOneToManyCompositeIdEntity', inversedBy: 'associatedEntities')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php index 0a1c6761468..5afa4541b9c 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php @@ -12,26 +12,22 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytoone_compositeid_foreignkey") - */ +#[Table(name: 'vct_owning_manytoone_compositeid_foreignkey')] +#[Entity] class OwningManyToOneCompositeIdForeignKeyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var InversedOneToManyCompositeIdForeignKeyEntity - * @ManyToOne(targetEntity="InversedOneToManyCompositeIdForeignKeyEntity", inversedBy="associatedEntities") - * @JoinColumns({ - * @JoinColumn(name="associated_id", referencedColumnName="id1"), - * @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id") - * }) */ + #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] + #[JoinColumn(name: 'associated_foreign_id', referencedColumnName: 'foreign_id')] + #[ManyToOne(targetEntity: 'InversedOneToManyCompositeIdForeignKeyEntity', inversedBy: 'associatedEntities')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php index 283d95f50ff..e0de3a54a4c 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php @@ -11,23 +11,21 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytoone") - */ +#[Table(name: 'vct_owning_manytoone')] +#[Entity] class OwningManyToOneEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var InversedOneToManyEntity - * @ManyToOne(targetEntity="InversedOneToManyEntity", inversedBy="associatedEntities") - * @JoinColumn(name="associated_id", referencedColumnName="id1") */ + #[ManyToOne(targetEntity: 'InversedOneToManyEntity', inversedBy: 'associatedEntities')] + #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php index 500d7e57865..5e181c0c91e 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php @@ -11,23 +11,21 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytoone_extralazy") - */ +#[Table(name: 'vct_owning_manytoone_extralazy')] +#[Entity] class OwningManyToOneExtraLazyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var InversedOneToManyExtraLazyEntity - * @ManyToOne(targetEntity="InversedOneToManyExtraLazyEntity", inversedBy="associatedEntities") - * @JoinColumn(name="associated_id", referencedColumnName="id1") */ + #[ManyToOne(targetEntity: 'InversedOneToManyExtraLazyEntity', inversedBy: 'associatedEntities')] + #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php index acd92bbab15..8d2751bb73b 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php @@ -10,17 +10,15 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_manytoone_foreignkey") - */ +#[Table(name: 'vct_owning_manytoone_foreignkey')] +#[Entity] class OwningManyToOneIdForeignKeyEntity { /** * @var associatedEntities - * @Id - * @ManyToOne(targetEntity=AuxiliaryEntity::class, inversedBy="associatedEntities") - * @JoinColumn(name="associated_id", referencedColumnName="id4") */ + #[Id] + #[ManyToOne(targetEntity: AuxiliaryEntity::class, inversedBy: 'associatedEntities')] + #[JoinColumn(name: 'associated_id', referencedColumnName: 'id4')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php index 1ce91c02ed3..ff5e8f00f6c 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php @@ -12,26 +12,22 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_onetoone_compositeid") - */ +#[Table(name: 'vct_owning_onetoone_compositeid')] +#[Entity] class OwningOneToOneCompositeIdEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id3; /** * @var InversedOneToOneCompositeIdEntity - * @OneToOne(targetEntity="InversedOneToOneCompositeIdEntity", inversedBy="associatedEntity") - * @JoinColumns({ - * @JoinColumn(name="associated_id1", referencedColumnName="id1"), - * @JoinColumn(name="associated_id2", referencedColumnName="id2") - * }) */ + #[JoinColumn(name: 'associated_id1', referencedColumnName: 'id1')] + #[JoinColumn(name: 'associated_id2', referencedColumnName: 'id2')] + #[OneToOne(targetEntity: 'InversedOneToOneCompositeIdEntity', inversedBy: 'associatedEntity')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php index d315724b6b2..4104e043234 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php @@ -13,31 +13,23 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\UniqueConstraint; -/** - * @Entity - * @Table( - * name="vct_owning_onetoone_compositeid_foreignkey", - * uniqueConstraints={ - * @UniqueConstraint(name="associated_entity_uniq", columns={"associated_id", "associated_foreign_id"}) - * } - * ) - */ +#[Table(name: 'vct_owning_onetoone_compositeid_foreignkey')] +#[UniqueConstraint(name: 'associated_entity_uniq', columns: ['associated_id', 'associated_foreign_id'])] +#[Entity] class OwningOneToOneCompositeIdForeignKeyEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var InversedOneToOneCompositeIdForeignKeyEntity - * @OneToOne(targetEntity="InversedOneToOneCompositeIdForeignKeyEntity", inversedBy="associatedEntity") - * @JoinColumns({ - * @JoinColumn(name="associated_id", referencedColumnName="id1"), - * @JoinColumn(name="associated_foreign_id", referencedColumnName="foreign_id") - * }) */ + #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] + #[JoinColumn(name: 'associated_foreign_id', referencedColumnName: 'foreign_id')] + #[OneToOne(targetEntity: 'InversedOneToOneCompositeIdForeignKeyEntity', inversedBy: 'associatedEntity')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php index df81a30abe0..c951ca15e98 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php @@ -11,23 +11,21 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="vct_owning_onetoone") - */ +#[Table(name: 'vct_owning_onetoone')] +#[Entity] class OwningOneToOneEntity { /** * @var string - * @Column(type="rot13", length=255) - * @Id */ + #[Column(type: 'rot13', length: 255)] + #[Id] public $id2; /** * @var InversedOneToOneEntity - * @OneToOne(targetEntity="InversedOneToOneEntity", inversedBy="associatedEntity") - * @JoinColumn(name="associated_id", referencedColumnName="id1") */ + #[OneToOne(targetEntity: 'InversedOneToOneEntity', inversedBy: 'associatedEntity')] + #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php b/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php index 76d7a342828..ff3d84edbe6 100644 --- a/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php +++ b/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php @@ -12,38 +12,36 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\Version; -/** - * @Entity - * @Table(name="versioned_many_to_one_article") - */ +#[Table(name: 'versioned_many_to_one_article')] +#[Entity] class Article { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(name="name") */ + #[Column(name: 'name')] public $name; /** * @var Category - * @ManyToOne(targetEntity="Category", cascade={"merge", "persist"}) */ + #[ManyToOne(targetEntity: 'Category', cascade: ['merge', 'persist'])] public $category; /** * Version column * * @var int - * @Column(type="integer", name="version") - * @Version */ + #[Column(type: 'integer', name: 'version')] + #[Version] public $version; } diff --git a/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php b/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php index de854878e34..c53cf7ec1e2 100644 --- a/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php +++ b/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php @@ -11,26 +11,24 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\Version; -/** - * @Entity - * @Table(name="versioned_many_to_one_category") - */ +#[Table(name: 'versioned_many_to_one_category')] +#[Entity] class Category { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * Version column * * @var int - * @Column(type="integer", name="version") - * @Version */ + #[Column(type: 'integer', name: 'version')] + #[Version] public $version; } diff --git a/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php b/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php index 5714d03242f..ea14434a021 100644 --- a/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php +++ b/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php @@ -12,31 +12,29 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\Version; -/** - * @Entity - * @Table(name="first_entity") - */ +#[Table(name: 'first_entity')] +#[Entity] class FirstRelatedEntity { /** * @var SecondRelatedEntity - * @Id - * @OneToOne(targetEntity="SecondRelatedEntity", fetch="EAGER") - * @JoinColumn(name="second_entity_id", referencedColumnName="id") */ + #[Id] + #[OneToOne(targetEntity: 'SecondRelatedEntity', fetch: 'EAGER')] + #[JoinColumn(name: 'second_entity_id', referencedColumnName: 'id')] public $secondEntity; /** * @var string - * @Column(name="name") */ + #[Column(name: 'name')] public $name; /** * @var int * Version column - * @Column(type="integer", name="version") - * @Version */ + #[Column(type: 'integer', name: 'version')] + #[Version] public $version; } diff --git a/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php b/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php index 1030b4be284..fd0cd32194c 100644 --- a/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php +++ b/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php @@ -11,31 +11,29 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\Version; -/** - * @Entity - * @Table(name="second_entity") - */ +#[Table(name: 'second_entity')] +#[Entity] class SecondRelatedEntity { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(name="name") */ + #[Column(name: 'name')] public $name; /** * @var int * Version column - * @Column(type="integer", name="version") - * @Version */ + #[Column(type: 'integer', name: 'version')] + #[Version] public $version; } diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php index 3d0b335754f..c421596a8b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -148,25 +149,21 @@ public function testManyToMany(): void } } -/** - * @Entity - * @Table(name="lemma") - */ +#[Table(name: 'lemma')] +#[Entity] class Lemma { public const CLASS_NAME = self::class; - /** - * @Id - * @Column(type="integer", name="lemma_id") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer', name: 'lemma_id')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", name="lemma_name", unique=true, length=255) */ + #[Column(type: 'string', name: 'lemma_name', unique: true, length: 255)] private string|null $lemma = null; - /** @ManyToMany(targetEntity="Type", mappedBy="lemmas", cascade={"persist"}) */ + #[ManyToMany(targetEntity: 'Type', mappedBy: 'lemmas', cascade: ['persist'])] private Collection $types; public function __construct() @@ -211,34 +208,27 @@ public function getTypes(): Collection } } -/** - * @Entity - * @Table(name="type") - */ +#[Table(name: 'type')] +#[Entity] class Type { public const CLASS_NAME = self::class; - /** - * @Id - * @Column(type="integer", name="type_id") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer', name: 'type_id')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", name="type_name", unique=true) */ + #[Column(type: 'string', name: 'type_name', unique: true)] private string|null $type = null; - /** @Column(type="string", name="type_abbreviation", unique=true) */ + #[Column(type: 'string', name: 'type_abbreviation', unique: true)] private string|null $abbreviation = null; - /** - * @ManyToMany(targetEntity="Lemma") - * @JoinTable(name="lemma_type", - * joinColumns={@JoinColumn(name="type_id", referencedColumnName="type_id")}, - * inverseJoinColumns={@JoinColumn(name="lemma_id", referencedColumnName="lemma_id")} - * ) - */ + #[JoinTable(name: 'lemma_type')] + #[JoinColumn(name: 'type_id', referencedColumnName: 'type_id')] + #[InverseJoinColumn(name: 'lemma_id', referencedColumnName: 'lemma_id')] + #[ManyToMany(targetEntity: 'Lemma')] private Collection $lemmas; public function __construct() @@ -294,34 +284,28 @@ public function getCategories(): Collection } -/** - * @Entity - * @Table(name="phrase") - */ +#[Table(name: 'phrase')] +#[Entity] class Phrase { public const CLASS_NAME = self::class; - /** - * @Id - * @Column(type="integer", name="phrase_id") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer', name: 'phrase_id')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", name="phrase_name", unique=true, length=255) */ + #[Column(type: 'string', name: 'phrase_name', unique: true, length: 255)] private string|null $phrase = null; - /** - * @ManyToOne(targetEntity="PhraseType") - * @JoinColumn(name="phrase_type_id", referencedColumnName="phrase_type_id") - */ + #[ManyToOne(targetEntity: 'PhraseType')] + #[JoinColumn(name: 'phrase_type_id', referencedColumnName: 'phrase_type_id')] private PhraseType|null $type = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="Definition", mappedBy="phrase", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'Definition', mappedBy: 'phrase', cascade: ['persist'])] private $definitions; public function __construct() @@ -366,31 +350,27 @@ public function getDefinitions(): Collection } } -/** - * @Entity - * @Table(name="phrase_type") - */ +#[Table(name: 'phrase_type')] +#[Entity] class PhraseType { public const CLASS_NAME = self::class; - /** - * @Id - * @Column(type="integer", name="phrase_type_id") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer', name: 'phrase_type_id')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", name="phrase_type_name", unique=true) */ + #[Column(type: 'string', name: 'phrase_type_name', unique: true)] private string|null $type = null; - /** @Column(type="string", name="phrase_type_abbreviation", unique=true) */ + #[Column(type: 'string', name: 'phrase_type_abbreviation', unique: true)] private string|null $abbreviation = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="Phrase", mappedBy="type") */ + #[OneToMany(targetEntity: 'Phrase', mappedBy: 'type')] private $phrases; public function __construct() @@ -434,28 +414,22 @@ public function getPhrases(): Collection } } -/** - * @Entity - * @Table(name="definition") - */ +#[Table(name: 'definition')] +#[Entity] class Definition { public const CLASS_NAME = self::class; - /** - * @Id - * @Column(type="integer", name="definition_id") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer', name: 'definition_id')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @ManyToOne(targetEntity="Phrase") - * @JoinColumn(name="definition_phrase_id", referencedColumnName="phrase_id") - */ + #[ManyToOne(targetEntity: 'Phrase')] + #[JoinColumn(name: 'definition_phrase_id', referencedColumnName: 'phrase_id')] private Phrase|null $phrase = null; - /** @Column(type="text", name="definition_text") */ + #[Column(type: 'text', name: 'definition_text')] private string|null $definition = null; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php index f1c531a044e..3755909b394 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php @@ -69,30 +69,22 @@ public function testMany(): void } } -/** @Entity */ +#[Entity] class CascadeRemoveOrderEntityO { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** - * @OneToOne(targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG") - * @JoinColumn(nullable=true, onDelete="SET NULL") - */ + #[OneToOne(targetEntity: 'Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG')] + #[JoinColumn(nullable: true, onDelete: 'SET NULL')] private CascadeRemoveOrderEntityG|null $oneToOneG = null; /** * @psalm-var Collection - * @OneToMany( - * targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG", - * mappedBy="ownerO", - * cascade={"persist", "remove"} - * ) */ + #[OneToMany(targetEntity: 'Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG', mappedBy: 'ownerO', cascade: ['persist', 'remove'])] private $oneToManyG; public function __construct() @@ -127,23 +119,16 @@ public function getOneToManyGs(): array } } -/** @Entity */ +#[Entity] class CascadeRemoveOrderEntityG { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; public function __construct( - /** - * @ManyToOne( - * targetEntity="Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityO", - * inversedBy="oneToMany" - * ) - */ + #[ManyToOne(targetEntity: 'Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityO', inversedBy: 'oneToMany')] private CascadeRemoveOrderEntityO $ownerO, private int $position = 1, ) { diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php index 34d489c6cb5..8b84d2bbaa3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php @@ -83,23 +83,19 @@ public function testManyToManyToCTIHierarchy(): void } } -/** - * @Entity - * @Table(name="cti_parents") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"parent" = "CTIParent", "child" = "CTIChild"}) - */ +#[Table(name: 'cti_parents')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['parent' => 'CTIParent', 'child' => 'CTIChild'])] class CTIParent { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @OneToOne(targetEntity="CTIRelated", mappedBy="ctiParent") */ + #[OneToOne(targetEntity: 'CTIRelated', mappedBy: 'ctiParent')] private CTIRelated|null $related = null; public function getId(): int @@ -119,13 +115,11 @@ public function setRelated(CTIRelated $related): void } } -/** - * @Entity - * @Table(name="cti_children") - */ +#[Table(name: 'cti_children')] +#[Entity] class CTIChild extends CTIParent { - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string|null $data = null; public function getData(): string @@ -139,20 +133,16 @@ public function setData(string $data): void } } -/** @Entity */ +#[Entity] class CTIRelated { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @OneToOne(targetEntity="CTIParent") - * @JoinColumn(name="ctiparent_id", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'CTIParent')] + #[JoinColumn(name: 'ctiparent_id', referencedColumnName: 'id')] private CTIParent|null $ctiParent = null; public function getId(): int @@ -171,20 +161,18 @@ public function setCTIParent(CTIParent $ctiParent): void } } -/** @Entity */ +#[Entity] class CTIRelated2 { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity="CTIChild") */ + #[ManyToMany(targetEntity: 'CTIChild')] private $ctiChildren; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index 12b30c899da..bebd7fb02e1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -85,33 +85,31 @@ public function testGetPartialReferenceWithDefaultValueNotEvaluatedInFlush(): vo } -/** - * @Entity - * @Table(name="defaultvalueuser") - */ +#[Table(name: 'defaultvalueuser')] +#[Entity] class DefaultValueUser { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name = ''; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $type = 'Poweruser'; /** * @var DefaultValueAddress - * @OneToOne(targetEntity="DefaultValueAddress", mappedBy="user", cascade={"persist"}) */ + #[OneToOne(targetEntity: 'DefaultValueAddress', mappedBy: 'user', cascade: ['persist'])] public $address; public function getId(): int @@ -122,36 +120,35 @@ public function getId(): int /** * CmsAddress - * - * @Entity - * @Table(name="defaultvalueaddresses") */ +#[Table(name: 'defaultvalueaddresses')] +#[Entity] class DefaultValueAddress { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] public $country; /** * @var string - * @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] public $zip; /** * @var string - * @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] public $city; /** @@ -162,9 +159,9 @@ class DefaultValueAddress /** * @var DefaultValueUser - * @OneToOne(targetEntity="DefaultValueUser") - * @JoinColumn(name="user_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DefaultValueUser')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; public function getUser(): DefaultValueUser diff --git a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php index e0149e85105..023a1edbc21 100644 --- a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php @@ -92,28 +92,24 @@ public function getName(): string } } -/** - * @Entity - * @Table - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"child" = GH5988CustomIdObjectTypeChild::class}) - */ +#[Table] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['child' => GH5988CustomIdObjectTypeChild::class])] abstract class GH5988CustomIdObjectTypeParent { /** - * @Id - * @Column(type="Doctrine\Tests\ORM\Functional\GH5988CustomIdObjectHashType", length=255) * @var CustomIdObject */ + #[Id] + #[Column(type: 'Doctrine\Tests\ORM\Functional\GH5988CustomIdObjectHashType', length: 255)] public $id; } -/** - * @Entity - * @Table - */ +#[Table] +#[Entity] class GH5988CustomIdObjectTypeChild extends GH5988CustomIdObjectTypeParent { public function __construct(CustomIdObject $id, public string $name) diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index eb5d58d2c21..65ae8bd3237 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -398,23 +398,19 @@ public function testLifecycleCallbackEventArgs(): void } } -/** - * @Entity - * @HasLifecycleCallbacks - */ +#[Entity] +#[HasLifecycleCallbacks] class LifecycleCallbackTestUser { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string|null $value = null; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string|null $name = null; public function getId(): int @@ -442,18 +438,16 @@ public function setName(string $name): void $this->name = $name; } - /** @PreUpdate */ + #[PreUpdate] public function testCallback(): void { $this->value = 'Hello World'; } } -/** - * @Entity - * @HasLifecycleCallbacks - * @Table(name="lc_cb_test_entity") - */ +#[Table(name: 'lc_cb_test_entity')] +#[Entity] +#[HasLifecycleCallbacks] class LifecycleCallbackTestEntity { /* test stuff */ @@ -473,24 +467,22 @@ class LifecycleCallbackTestEntity /** @var bool */ public $preFlushCallbackInvoked = false; - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; /** * @var string - * @Column(type="string", nullable=true) */ + #[Column(type: 'string', nullable: true)] public $value; /** * @var LifecycleCallbackCascader - * @ManyToOne(targetEntity="LifecycleCallbackCascader") - * @JoinColumn(name="cascader_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'LifecycleCallbackCascader')] + #[JoinColumn(name: 'cascader_id', referencedColumnName: 'id')] public $cascader; public function getId(): int @@ -503,43 +495,41 @@ public function getValue(): string return $this->value; } - /** @PrePersist */ + #[PrePersist] public function doStuffOnPrePersist(): void { $this->prePersistCallbackInvoked = true; } - /** @PostPersist */ + #[PostPersist] public function doStuffOnPostPersist(): void { $this->postPersistCallbackInvoked = true; } - /** @PostLoad */ + #[PostLoad] public function doStuffOnPostLoad(): void { $this->postLoadCallbackInvoked = true; $this->postLoadCascaderNotNull = isset($this->cascader); } - /** @PreUpdate */ + #[PreUpdate] public function doStuffOnPreUpdate(): void { $this->value = 'changed from preUpdate callback!'; } - /** @PreFlush */ + #[PreFlush] public function doStuffOnPreFlush(): void { $this->preFlushCallbackInvoked = true; } } -/** - * @Entity - * @HasLifecycleCallbacks - * @Table(name="lc_cb_test_cascade") - */ +#[Table(name: 'lc_cb_test_cascade')] +#[Entity] +#[HasLifecycleCallbacks] class LifecycleCallbackCascader { /* test stuff */ @@ -549,17 +539,15 @@ class LifecycleCallbackCascader /** @var int */ public $postLoadEntitiesCount = 0; - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="LifecycleCallbackTestEntity", mappedBy="cascader", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'LifecycleCallbackTestEntity', mappedBy: 'cascader', cascade: ['persist'])] public $entities; public function __construct() @@ -567,7 +555,7 @@ public function __construct() $this->entities = new ArrayCollection(); } - /** @PostLoad */ + #[PostLoad] public function doStuffOnPostLoad(): void { $this->postLoadCallbackInvoked = true; @@ -580,29 +568,23 @@ public function getId(): int } } -/** - * @MappedSuperclass - * @HasLifecycleCallbacks - */ +#[MappedSuperclass] +#[HasLifecycleCallbacks] class LifecycleCallbackParentEntity { - /** @PrePersist */ + #[PrePersist] public function doStuff(): void { } } -/** - * @Entity - * @Table(name="lc_cb_childentity") - */ +#[Table(name: 'lc_cb_childentity')] +#[Entity] class LifecycleCallbackChildEntity extends LifecycleCallbackParentEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; } @@ -614,72 +596,70 @@ public function preUpdate(PreUpdateEventArgs $eventArgs): void } } -/** - * @Entity - * @HasLifecycleCallbacks - */ +#[Entity] +#[HasLifecycleCallbacks] class LifecycleCallbackEventArgEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column() */ + #[Column] public $value; /** @var array */ public $calls = []; - /** @PostPersist */ + #[PostPersist] public function postPersistHandler(PostPersistEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** @PrePersist */ + #[PrePersist] public function prePersistHandler(PrePersistEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** @PostUpdate */ + #[PostUpdate] public function postUpdateHandler(PostUpdateEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** @PreUpdate */ + #[PreUpdate] public function preUpdateHandler(PreUpdateEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** @PostRemove */ + #[PostRemove] public function postRemoveHandler(PostRemoveEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** @PreRemove */ + #[PreRemove] public function preRemoveHandler(PreRemoveEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** @PreFlush */ + #[PreFlush] public function preFlushHandler(PreFlushEventArgs $event): void { $this->calls[__FUNCTION__] = $event; } - /** @PostLoad */ + #[PostLoad] public function postLoadHandler(PostLoadEventArgs $event): void { $this->calls[__FUNCTION__] = $event; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index 9f53b90ebdc..43c054e0832 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -273,75 +273,67 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime } } -/** - * @Entity - * @Table(name="optimistic_joined_parent") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string", length=255) - * @DiscriminatorMap({"parent" = "OptimisticJoinedParent", "child" = "OptimisticJoinedChild"}) - */ +#[Table(name: 'optimistic_joined_parent')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string', length: 255)] +#[DiscriminatorMap(['parent' => 'OptimisticJoinedParent', 'child' => 'OptimisticJoinedChild'])] class OptimisticJoinedParent { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @var int - * @Version - * @Column(type="integer") */ + #[Version] + #[Column(type: 'integer')] public $version; } -/** - * @Entity - * @Table(name="optimistic_joined_child") - */ +#[Table(name: 'optimistic_joined_child')] +#[Entity] class OptimisticJoinedChild extends OptimisticJoinedParent { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $whatever; } -/** - * @Entity - * @Table(name="optimistic_standard") - */ +#[Table(name: 'optimistic_standard')] +#[Entity] class OptimisticStandard { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; - /** - * @Version - * @Column(type="integer") - */ + #[Version] + #[Column(type: 'integer')] private int $version; public function getVersion(): int @@ -350,30 +342,28 @@ public function getVersion(): int } } -/** - * @Entity - * @Table(name="optimistic_timestamp") - */ +#[Table(name: 'optimistic_timestamp')] +#[Entity] class OptimisticTimestamp { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @var DateTime - * @Version - * @Column(type="datetime") */ + #[Version] + #[Column(type: 'datetime')] public $version; } diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index 0d5abf93128..aaf11962d9e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -114,26 +114,22 @@ protected function onPropertyChanged($propName, $oldValue, $newValue): void } } -/** - * @Entity - * @ChangeTrackingPolicy("NOTIFY") - */ +#[Entity] +#[ChangeTrackingPolicy('NOTIFY')] class NotifyUser extends NotifyBaseEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column */ + #[Column] private string|null $name = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="NotifyGroup") */ + #[ManyToMany(targetEntity: 'NotifyGroup')] private $groups; public function __construct() @@ -164,23 +160,21 @@ public function getGroups(): Collection } } -/** @Entity */ +#[Entity] class NotifyGroup extends NotifyBaseEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column */ + #[Column] private string|null $name = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="NotifyUser", mappedBy="groups") */ + #[ManyToMany(targetEntity: 'NotifyUser', mappedBy: 'groups')] private $users; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 48db8c33e2b..84a1d562548 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -207,39 +207,39 @@ public function testEagerLoadingDoesNotBreakRefresh(): void } } -/** @Entity */ +#[Entity] class Train { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * Owning side * * @var TrainDriver - * @OneToOne(targetEntity="TrainDriver", inversedBy="train", fetch="EAGER", cascade={"persist"}) - * @JoinColumn(nullable=true) */ + #[OneToOne(targetEntity: 'TrainDriver', inversedBy: 'train', fetch: 'EAGER', cascade: ['persist'])] + #[JoinColumn(nullable: true)] public $driver; /** * Owning side * * @var TrainOwner - * @OneToOne(targetEntity="TrainOwner", inversedBy="train", fetch="EAGER", cascade={"persist"}) - * @JoinColumn(nullable=false) */ + #[OneToOne(targetEntity: 'TrainOwner', inversedBy: 'train', fetch: 'EAGER', cascade: ['persist'])] + #[JoinColumn(nullable: false)] public $owner; /** * @psalm-var Collection - * @OneToMany(targetEntity="Waggon", mappedBy="train", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'Waggon', mappedBy: 'train', cascade: ['persist'])] public $waggons; public function __construct(TrainOwner $owner) @@ -267,27 +267,27 @@ public function addWaggon(Waggon $w): void } } -/** @Entity */ +#[Entity] class TrainDriver { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * Inverse side * * @var Train - * @OneToOne(targetEntity="Train", mappedBy="driver", fetch="EAGER") */ + #[OneToOne(targetEntity: 'Train', mappedBy: 'driver', fetch: 'EAGER')] public $train; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } @@ -298,27 +298,27 @@ public function setTrain(Train $t): void } } -/** @Entity */ +#[Entity] class TrainOwner { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * Inverse side * * @var Train - * @OneToOne(targetEntity="Train", mappedBy="owner", fetch="EAGER") */ + #[OneToOne(targetEntity: 'Train', mappedBy: 'owner', fetch: 'EAGER')] public $train; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } @@ -329,21 +329,21 @@ public function setTrain(Train $t): void } } -/** @Entity */ +#[Entity] class Waggon { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var Train - * @ManyToOne(targetEntity="Train", inversedBy="waggons", fetch="EAGER") - * @JoinColumn(nullable=false) */ + #[ManyToOne(targetEntity: 'Train', inversedBy: 'waggons', fetch: 'EAGER')] + #[JoinColumn(nullable: false)] public $train; public function setTrain($train): void @@ -352,19 +352,19 @@ public function setTrain($train): void } } -/** @Entity */ +#[Entity] class TrainOrder { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; public function __construct( - /** @OneToOne(targetEntity="Train", fetch="EAGER") */ + #[OneToOne(targetEntity: 'Train', fetch: 'EAGER')] public Train|null $train = null, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index 1b01b987ab7..87e05a861a7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -141,26 +141,20 @@ private function createFixture(): int } } -/** @Entity */ +#[Entity] class MultiSelfReference { - /** - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue(strategy: 'AUTO')] + #[Column(type: 'integer')] private int $id; - /** - * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) - * @JoinColumn(name="other1", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'MultiSelfReference', cascade: ['persist'])] + #[JoinColumn(name: 'other1', referencedColumnName: 'id')] private MultiSelfReference|null $other1 = null; - /** - * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) - * @JoinColumn(name="other2", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'MultiSelfReference', cascade: ['persist'])] + #[JoinColumn(name: 'other2', referencedColumnName: 'id')] private MultiSelfReference|null $other2 = null; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php index 983ec1cdb80..d1ee4f493f9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorColumn; use Doctrine\ORM\Mapping\DiscriminatorMap; @@ -76,51 +77,47 @@ public function testOrderdOneToManyCollection(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({ - * "cat" = "OJTICCat", - * "dog" = "OJTICDog"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['cat' => 'OJTICCat', 'dog' => 'OJTICDog'])] abstract class OJTICPet { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column */ + #[Column] public $name; /** * @var OJTICPet - * @ManyToOne(targetEntity="OJTICPet") */ + #[ManyToOne(targetEntity: 'OJTICPet')] public $mother; /** * @psalm-var Collection - * @OneToMany(targetEntity="OJTICPet", mappedBy="mother") - * @OrderBy({"name" = "ASC"}) */ + #[OneToMany(targetEntity: 'OJTICPet', mappedBy: 'mother')] + #[OrderBy(['name' => 'ASC'])] public $children; /** * @psalm-var Collection - * @ManyToMany(targetEntity="OJTICPet") - * @JoinTable(name="OTJIC_Pet_Friends", - * joinColumns={@JoinColumn(name="pet_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="friend_id", referencedColumnName="id")}) - * @OrderBy({"name" = "ASC"}) */ + #[JoinTable(name: 'OTJIC_Pet_Friends')] + #[JoinColumn(name: 'pet_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'friend_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'OJTICPet')] + #[OrderBy(['name' => 'ASC'])] public $friends; public function getName(): string @@ -129,12 +126,12 @@ public function getName(): string } } -/** @Entity */ +#[Entity] class OJTICCat extends OJTICPet { } -/** @Entity */ +#[Entity] class OJTICDog extends OJTICPet { } diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php index 07a49935b7f..9c1f98218b4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php @@ -69,32 +69,32 @@ public function testParenthesisOnMultiLine(): void } -/** @Entity */ +#[Entity] class QueryBuilderParenthesisEntity { /** * @var int|null - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; /** * @var string|null - * @Column() */ + #[Column] public $property1; /** * @var string|null - * @Column() */ + #[Column] public $property2; /** * @var string|null - * @Column() */ + #[Column] public $property3; } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index b2e680fdb6a..02f586edfcc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -133,22 +133,22 @@ public function testNotReadOnlyIfObjectWasKnownBefore(): void } } -/** @Entity(readOnly=true) */ +#[Entity(readOnly: true)] class ReadOnlyEntity { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** @param int $number */ public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public $numericValue, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 5e9e39e5326..047d7f1767f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -30,26 +30,26 @@ public function testDefaultValueIsComparedCorrectly(): void } } -/** @Entity */ +#[Entity] class DBAL483Default { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var int - * @Column(type="integer", options={"default": 0}) */ + #[Column(type: 'integer', options: ['default' => 0])] public $num; /** * @var string - * @Column(type="string", options={"default": "foo"}) */ + #[Column(type: 'string', options: ['default' => 'foo'])] public $str = 'foo'; } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 592efc11093..79f77ff4a6e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -115,17 +115,15 @@ public function testGetCreateSchemaSql4(): void } } -/** - * @Entity - * @Table("namespace.entity") - */ +#[Table('namespace.entity')] +#[Entity] class MysqlSchemaNamespacedEntity { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index 6a6371f1fdc..c777c7f0db3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -51,65 +51,57 @@ public function testUpdateSchemaWithPostgreSQLSchema(): void } } -/** - * @Entity - * @Table(name="stonewood.screen") - */ +#[Table(name: 'stonewood.screen')] +#[Entity] class DDC1657Screen { /** * Identifier - * - * @Id - * @GeneratedValue(strategy="IDENTITY") - * @Column(name="pk", type="integer", nullable=false) */ + #[Id] + #[GeneratedValue(strategy: 'IDENTITY')] + #[Column(name: 'pk', type: 'integer', nullable: false)] private int $pk; /** * Title - * - * @Column(name="title", type="string", length=255, nullable=false) */ + #[Column(name: 'title', type: 'string', length: 255, nullable: false)] private string $title; /** * Path - * - * @Column(name="path", type="string", length=255, nullable=false) */ + #[Column(name: 'path', type: 'string', length: 255, nullable: false)] private string $path; /** * Register date * * @var Date - * @Column(name="ddate", type="date", nullable=false) */ + #[Column(name: 'ddate', type: 'date', nullable: false)] private $ddate; /** * Avatar * * @var Stonewood\Model\Entity\Avatar - * @ManyToOne(targetEntity="DDC1657Avatar") - * @JoinColumn(name="pk_avatar", referencedColumnName="pk", nullable=true, onDelete="CASCADE") */ + #[ManyToOne(targetEntity: 'DDC1657Avatar')] + #[JoinColumn(name: 'pk_avatar', referencedColumnName: 'pk', nullable: true, onDelete: 'CASCADE')] private $avatar; } -/** - * @Entity - * @Table(name="stonewood.avatar") - */ +#[Table(name: 'stonewood.avatar')] +#[Entity] class DDC1657Avatar { /** * Identifier - * - * @Id - * @GeneratedValue(strategy="IDENTITY") - * @Column(name="pk", type="integer", nullable=false) */ + #[Id] + #[GeneratedValue(strategy: 'IDENTITY')] + #[Column(name: 'pk', type: 'integer', nullable: false)] private int $pk; } diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php index 6f2664bbf0e..8809e46ea65 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php @@ -39,15 +39,15 @@ public function testHighAllocationSizeSequence(): void } } -/** @Entity */ +#[Entity] class SequenceEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="SEQUENCE") - * @SequenceGenerator(allocationSize=5, sequenceName="person_id_seq") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'SEQUENCE')] + #[SequenceGenerator(allocationSize: 5, sequenceName: 'person_id_seq')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index b3b8e58a336..84e8184594c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -76,32 +76,29 @@ public function testHydration(): void } -/** - * @Entity - * @Table(name="foo") - */ +#[Table(name: 'foo')] +#[Entity] class DDC1080Foo { /** * @var int - * @Id - * @Column(name="fooID", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'fooID', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $fooID; /** * @var string - * @Column(name="fooTitle", type="string", length=255) */ + #[Column(name: 'fooTitle', type: 'string', length: 255)] protected $fooTitle; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1080FooBar", mappedBy="foo", - * cascade={"persist"}) - * @OrderBy({"orderNr"="ASC"}) */ + #[OneToMany(targetEntity: 'DDC1080FooBar', mappedBy: 'foo', cascade: ['persist'])] + #[OrderBy(['orderNr' => 'ASC'])] protected $fooBars; public function __construct() @@ -140,32 +137,29 @@ public function setFooBars(array $fooBars): void $this->fooBars = $fooBars; } } -/** - * @Entity - * @Table(name="bar") - */ +#[Table(name: 'bar')] +#[Entity] class DDC1080Bar { /** * @var int - * @Id - * @Column(name="barID", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'barID', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $barID; /** * @var string - * @Column(name="barTitle", type="string", length=255) */ + #[Column(name: 'barTitle', type: 'string', length: 255)] protected $barTitle; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1080FooBar", mappedBy="bar", - * cascade={"persist"}) - * @OrderBy({"orderNr"="ASC"}) */ + #[OneToMany(targetEntity: 'DDC1080FooBar', mappedBy: 'bar', cascade: ['persist'])] + #[OrderBy(['orderNr' => 'ASC'])] protected $fooBars; public function __construct() @@ -205,32 +199,30 @@ public function setFooBars(array $fooBars): void } } -/** - * @Table(name="fooBar") - * @Entity - */ +#[Table(name: 'fooBar')] +#[Entity] class DDC1080FooBar { /** * @var DDC1080Foo - * @ManyToOne(targetEntity="DDC1080Foo") - * @JoinColumn(name="fooID", referencedColumnName="fooID") - * @Id */ + #[ManyToOne(targetEntity: 'DDC1080Foo')] + #[JoinColumn(name: 'fooID', referencedColumnName: 'fooID')] + #[Id] protected $foo = null; /** * @var DDC1080Bar - * @ManyToOne(targetEntity="DDC1080Bar") - * @JoinColumn(name="barID", referencedColumnName="barID") - * @Id */ + #[ManyToOne(targetEntity: 'DDC1080Bar')] + #[JoinColumn(name: 'barID', referencedColumnName: 'barID')] + #[Id] protected $bar = null; /** * @var int orderNr - * @Column(name="orderNr", type="integer", nullable=false) */ + #[Column(name: 'orderNr', type: 'integer', nullable: false)] protected $orderNr = null; public function getFoo(): DDC1080Foo diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php index a76d5acce5c..d400f4168c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php @@ -56,52 +56,50 @@ public function testIssue(): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"vehicle" = "DDC1113Vehicle", "car" = "DDC1113Car", "bus" = "DDC1113Bus"}) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorMap(['vehicle' => 'DDC1113Vehicle', 'car' => 'DDC1113Car', 'bus' => 'DDC1113Bus'])] class DDC1113Vehicle { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var DDC1113Vehicle - * @ManyToOne(targetEntity="DDC1113Vehicle") */ + #[ManyToOne(targetEntity: 'DDC1113Vehicle')] public $parent; /** * @var DDC1113Engine - * @OneToOne(targetEntity="DDC1113Engine", cascade={"persist", "remove"}) */ + #[OneToOne(targetEntity: 'DDC1113Engine', cascade: ['persist', 'remove'])] public $engine; } -/** @Entity */ +#[Entity] class DDC1113Car extends DDC1113Vehicle { } -/** @Entity */ +#[Entity] class DDC1113Bus extends DDC1113Vehicle { } -/** @Entity */ +#[Entity] class DDC1113Engine { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index 827d5078ede..91b09597ced 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -105,17 +105,15 @@ private function setPropertyAndAssignTagToSpecialProduct(): void } } -/** @Entity */ +#[Entity] class DDC1163ProxyHolder { - /** - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @OneToOne(targetEntity="DDC1163SpecialProduct") */ + #[OneToOne(targetEntity: 'DDC1163SpecialProduct')] private DDC1163SpecialProduct|null $specialProduct = null; public function getId(): int @@ -134,20 +132,18 @@ public function getSpecialProduct(): DDC1163SpecialProduct } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"special" = "DDC1163SpecialProduct"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['special' => 'DDC1163SpecialProduct'])] abstract class DDC1163Product { /** * @var int - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] protected $id; public function getId(): int @@ -156,10 +152,10 @@ public function getId(): int } } -/** @Entity */ +#[Entity] class DDC1163SpecialProduct extends DDC1163Product { - /** @Column(name="subclass_property", type="string", nullable=true) */ + #[Column(name: 'subclass_property', type: 'string', nullable: true)] private string|null $subclassProperty = null; public function setSubclassProperty(string $value): void @@ -168,26 +164,22 @@ public function setSubclassProperty(string $value): void } } -/** @Entity */ +#[Entity] class DDC1163Tag { - /** - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; /** * @var Product - * @ManyToOne(targetEntity="DDC1163Product", inversedBy="tags") - * @JoinColumns({ - * @JoinColumn(name="product_id", referencedColumnName="id") - * }) */ + #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] + #[ManyToOne(targetEntity: 'DDC1163Product', inversedBy: 'tags')] private $product; public function __construct( - /** @Column(name="name", type="string", length=255) */ + #[Column(name: 'name', type: 'string', length: 255)] private string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php index df71a959ec0..f1ca32234c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php @@ -58,55 +58,51 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC1181Hotel { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** - * @OneToMany(targetEntity="DDC1181Booking", mappedBy="hotel", cascade={"remove"}) * @var Booking[] */ + #[OneToMany(targetEntity: 'DDC1181Booking', mappedBy: 'hotel', cascade: ['remove'])] public $bookings; } -/** @Entity */ +#[Entity] class DDC1181Booking { /** * @var Hotel - * @Id - * @ManyToOne(targetEntity="DDC1181Hotel", inversedBy="bookings") - * @JoinColumns({ - * @JoinColumn(name="hotel_id", referencedColumnName="id") - * }) */ + #[JoinColumn(name: 'hotel_id', referencedColumnName: 'id')] + #[Id] + #[ManyToOne(targetEntity: 'DDC1181Hotel', inversedBy: 'bookings')] public $hotel; /** * @var Room - * @Id - * @ManyToOne(targetEntity="DDC1181Room") - * @JoinColumns({ - * @JoinColumn(name="room_id", referencedColumnName="id") - * }) */ + #[JoinColumn(name: 'room_id', referencedColumnName: 'id')] + #[Id] + #[ManyToOne(targetEntity: 'DDC1181Room')] public $room; } -/** @Entity */ +#[Entity] class DDC1181Room { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index 895e2013237..e8af579250e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -53,50 +53,50 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC1193Company { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC1193Person - * @OneToOne(targetEntity="DDC1193Person", cascade={"persist", "remove"}) */ + #[OneToOne(targetEntity: 'DDC1193Person', cascade: ['persist', 'remove'])] public $member; } -/** @Entity */ +#[Entity] class DDC1193Person { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC1193Account - * @OneToOne(targetEntity="DDC1193Account", cascade={"persist", "remove"}) */ + #[OneToOne(targetEntity: 'DDC1193Account', cascade: ['persist', 'remove'])] public $account; } -/** @Entity */ +#[Entity] class DDC1193Account { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php index f4bcdc162f6..4a795e0d6b8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php @@ -65,14 +65,12 @@ public function testCompositeIdentifierCanHaveCustomType(): void } } -/** @Entity */ +#[Entity] class DDC1209One { - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; public function getId(): int @@ -81,36 +79,34 @@ public function getId(): int } } -/** @Entity */ +#[Entity] class DDC1209Two { /** * @var DateTime2 - * @Id - * @Column(type="datetime", nullable=false) */ + #[Id] + #[Column(type: 'datetime', nullable: false)] public $startingDatetime; /** * @var DateTime2 - * @Id - * @Column(type="datetime", nullable=false) */ + #[Id] + #[Column(type: 'datetime', nullable: false)] public $duringDatetime; /** * @var DateTime2 - * @Id - * @Column(type="datetime", nullable=false) */ + #[Id] + #[Column(type: 'datetime', nullable: false)] public $endingDatetime; public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="DDC1209One") - * @JoinColumn(referencedColumnName="id", nullable=false) - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC1209One')] + #[JoinColumn(referencedColumnName: 'id', nullable: false)] private DDC1209One $future1, ) { $this->startingDatetime = new DateTime2(); @@ -119,14 +115,14 @@ public function __construct( } } -/** @Entity */ +#[Entity] class DDC1209Three { /** * @var DateTime2 - * @Id - * @Column(type="datetime", name="somedate") */ + #[Id] + #[Column(type: 'datetime', name: 'somedate')] public $date; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index d17110330d6..d7e2b67400b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -42,17 +42,13 @@ public function testIssue(): void } } -/** - * @Entity - * @Table(name="te1") - */ +#[Table(name: 'te1')] +#[Entity] class DDC1225TestEntity1 { - /** - * @Id - * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225TestEntity2") - * @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false) - */ + #[Id] + #[ManyToOne(targetEntity: 'Doctrine\Tests\ORM\Functional\Ticket\DDC1225TestEntity2')] + #[JoinColumn(name: 'test_entity2_id', referencedColumnName: 'id', nullable: false)] private DDC1225TestEntity2|null $testEntity2 = null; public function setTestEntity2(DDC1225TestEntity2 $testEntity2): void @@ -66,16 +62,12 @@ public function getTestEntity2(): DDC1225TestEntity2 } } -/** - * @Entity - * @Table(name="te2") - */ +#[Table(name: 'te2')] +#[Entity] class DDC1225TestEntity2 { - /** - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue(strategy: 'AUTO')] + #[Column(type: 'integer')] private int $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php index 1b2f8f88154..1faf8bec8f1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php @@ -75,27 +75,27 @@ public function testRefresh(): void } } -/** @Entity */ +#[Entity] class DDC1228User { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** - * @Column(type="string", length=255) * @var string */ + #[Column(type: 'string', length: 255)] public $name = 'Bar'; /** * @var DDC1228Profile - * @OneToOne(targetEntity="DDC1228Profile") */ + #[OneToOne(targetEntity: 'DDC1228Profile')] public $profile; public function getProfile(): DDC1228Profile @@ -104,21 +104,21 @@ public function getProfile(): DDC1228Profile } } -/** @Entity */ +#[Entity] class DDC1228Profile { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** - * @Column(type="string", length=255) * @var string */ + #[Column(type: 'string', length: 255)] public $name; public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php index d35e8c5dee5..e1aaf59c772 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -63,17 +63,15 @@ public function testIssueProxyClear(): void } } -/** @Entity */ +#[Entity] class DDC1238User { - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int|null $id = null; - /** @Column */ + #[Column] private string|null $name = null; public function getId(): int|null diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php index a77624883f0..05fb009a464 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -42,28 +42,28 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC1250ClientHistory { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var DDC1250ClientHistory - * @OneToOne(targetEntity="DDC1250ClientHistory", inversedBy="declinedBy") - * @JoinColumn(name="declined_clients_history_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC1250ClientHistory', inversedBy: 'declinedBy')] + #[JoinColumn(name: 'declined_clients_history_id', referencedColumnName: 'id')] public $declinedClientsHistory; /** * @var DDC1250ClientHistory - * @OneToOne(targetEntity="DDC1250ClientHistory", mappedBy="declinedClientsHistory") */ + #[OneToOne(targetEntity: 'DDC1250ClientHistory', mappedBy: 'declinedClientsHistory')] public $declinedBy; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php index 5ea32a8d3fa..94b09db2910 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php @@ -49,28 +49,27 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC1300Foo { /** * @var int fooID - * @Column(name="fooID", type="integer", nullable=false) - * @GeneratedValue(strategy="AUTO") - * @Id */ + #[Column(name: 'fooID', type: 'integer', nullable: false)] + #[GeneratedValue(strategy: 'AUTO')] + #[Id] public $fooID = null; /** * @var string fooReference - * @Column(name="fooReference", type="string", nullable=true, length=45) */ + #[Column(name: 'fooReference', type: 'string', nullable: true, length: 45)] public $fooReference = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1300FooLocale", mappedBy="foo", - * cascade={"persist"}) */ + #[OneToMany(targetEntity: 'DDC1300FooLocale', mappedBy: 'foo', cascade: ['persist'])] public $fooLocaleRefFoo = null; /** @param mixed[]|null $options */ @@ -80,27 +79,27 @@ public function __construct(array|null $options = null) } } -/** @Entity */ +#[Entity] class DDC1300FooLocale { /** * @var DDC1300Foo - * @ManyToOne(targetEntity="DDC1300Foo") - * @JoinColumn(name="fooID", referencedColumnName="fooID") - * @Id */ + #[ManyToOne(targetEntity: 'DDC1300Foo')] + #[JoinColumn(name: 'fooID', referencedColumnName: 'fooID')] + #[Id] public $foo = null; /** * @var string locale - * @Column(name="locale", type="string", nullable=false, length=5) - * @Id */ + #[Column(name: 'locale', type: 'string', nullable: false, length: 5)] + #[Id] public $locale = null; /** * @var string title - * @Column(name="title", type="string", nullable=true, length=150) */ + #[Column(name: 'title', type: 'string', nullable: true, length: 150)] public $title = null; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index 38b36430485..ca30bf0c709 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -152,27 +152,27 @@ private function loadFixture(): void } } -/** @Entity */ +#[Entity] class DDC1335User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1335Phone", mappedBy="user", cascade={"persist", "remove"}) */ + #[OneToMany(targetEntity: 'DDC1335Phone', mappedBy: 'user', cascade: ['persist', 'remove'])] public $phones; public function __construct( - /** @Column(type="string", length=255, unique=true) */ + #[Column(type: 'string', length: 255, unique: true)] public string $email, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, array $numbers = [], ) { @@ -184,25 +184,23 @@ public function __construct( } } -/** @Entity */ +#[Entity] class DDC1335Phone { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue] public $id; /** @param string $number */ public function __construct( - /** - * @ManyToOne(targetEntity="DDC1335User", inversedBy="phones") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable = false) - */ + #[ManyToOne(targetEntity: 'DDC1335User', inversedBy: 'phones')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)] public DDC1335User $user, - /** @Column(name="numericalValue", type="string", nullable = false) */ + #[Column(name: 'numericalValue', type: 'string', nullable: false)] public $numericalValue, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php index a4652fe5b78..26ef9a02a9e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php @@ -69,68 +69,68 @@ public function testFailingCase(): void } } -/** @Entity */ +#[Entity] class DDC1400Article { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1400UserState", mappedBy="article", indexBy="userId", fetch="EXTRA_LAZY") */ + #[OneToMany(targetEntity: 'DDC1400UserState', mappedBy: 'article', indexBy: 'userId', fetch: 'EXTRA_LAZY')] public $userStates; } -/** @Entity */ +#[Entity] class DDC1400User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1400UserState", mappedBy="user", indexBy="articleId", fetch="EXTRA_LAZY") */ + #[OneToMany(targetEntity: 'DDC1400UserState', mappedBy: 'user', indexBy: 'articleId', fetch: 'EXTRA_LAZY')] public $userStates; } -/** @Entity */ +#[Entity] class DDC1400UserState { /** * @var DDC1400Article - * @Id - * @ManyToOne(targetEntity="DDC1400Article", inversedBy="userStates") */ + #[Id] + #[ManyToOne(targetEntity: 'DDC1400Article', inversedBy: 'userStates')] public $article; /** * @var DDC1400User - * @Id - * @ManyToOne(targetEntity="DDC1400User", inversedBy="userStates") */ + #[Id] + #[ManyToOne(targetEntity: 'DDC1400User', inversedBy: 'userStates')] public $user; /** * @var int - * @Column(name="user_id", type="integer") */ + #[Column(name: 'user_id', type: 'integer')] public $userId; /** * @var int - * @Column(name="article_id", type="integer") */ + #[Column(name: 'article_id', type: 'integer')] public $articleId; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index 0a3e801bc74..f841194757c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -139,21 +139,21 @@ public function loadFixtures(): void } } -/** @Entity */ +#[Entity] class DDC1430Order { /** * @var int - * @Id - * @Column(name="order_id", type="integer") - * @GeneratedValue() */ + #[Id] + #[Column(name: 'order_id', type: 'integer')] + #[GeneratedValue] protected $id; - /** @Column(name="created_at", type="datetime") */ + #[Column(name: 'created_at', type: 'datetime')] private DateTime $date; - /** @OneToMany(targetEntity="DDC1430OrderProduct", mappedBy="order", cascade={"persist", "remove"}) */ + #[OneToMany(targetEntity: 'DDC1430OrderProduct', mappedBy: 'order', cascade: ['persist', 'remove'])] private Collection $products; public function getId(): int @@ -162,7 +162,7 @@ public function getId(): int } public function __construct( - /** @Column(name="order_status", type="string", length=255) */ + #[Column(name: 'order_status', type: 'string', length: 255)] private string $status, ) { $this->date = new DateTime(); @@ -196,25 +196,23 @@ public function addProduct(DDC1430OrderProduct $product): void } } -/** @Entity */ +#[Entity] class DDC1430OrderProduct { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue() */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; - /** - * @ManyToOne(targetEntity="DDC1430Order", inversedBy="products") - * @JoinColumn(name="order_id", referencedColumnName="order_id", nullable = false) - */ + #[ManyToOne(targetEntity: 'DDC1430Order', inversedBy: 'products')] + #[JoinColumn(name: 'order_id', referencedColumnName: 'order_id', nullable: false)] private DDC1430Order|null $order = null; public function __construct( - /** @Column(type="float") */ + #[Column(type: 'float')] private float $value, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php index 8ffa2a499d0..99362c26926 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -54,22 +54,22 @@ public function testIdentityMap(): void } } -/** @Entity */ +#[Entity] class DDC1436Page { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer", name="id") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer', name: 'id')] protected $id; /** * @var DDC1436Page - * @ManyToOne(targetEntity="DDC1436Page") - * @JoinColumn(name="pid", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'DDC1436Page')] + #[JoinColumn(name: 'pid', referencedColumnName: 'id')] protected $parent; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php index 5a55b5d2286..9efb5f29592 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php @@ -40,27 +40,25 @@ public function testIssue(): void } } -/** - * @Entity - * @Table(name="ddc144_flowelements") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(type="string", name="discr") - * @DiscriminatorMap({"flowelement" = "DDC144FlowElement", "operand" = "DDC144Operand"}) - */ +#[Table(name: 'ddc144_flowelements')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(type: 'string', name: 'discr')] +#[DiscriminatorMap(['flowelement' => 'DDC144FlowElement', 'operand' => 'DDC144Operand'])] class DDC144FlowElement { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column */ + #[Column] public $property; } @@ -69,16 +67,14 @@ abstract class DDC144Expression extends DDC144FlowElement abstract public function method(): void; } -/** - * @Entity - * @Table(name="ddc144_operands") - */ +#[Table(name: 'ddc144_operands')] +#[Entity] class DDC144Operand extends DDC144Expression { /** * @var string - * @Column */ + #[Column] public $operandProperty; public function method(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php index f7c93d88b2a..4fe12d27718 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -90,27 +90,27 @@ public function testFetchJoinOneToOneFromInverse(): void } } -/** @Entity */ +#[Entity] class DDC1452EntityA { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column */ + #[Column] public $title; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1452EntityB", mappedBy="entityAFrom") */ + #[OneToMany(targetEntity: 'DDC1452EntityB', mappedBy: 'entityAFrom')] public $entitiesB; public function __construct() @@ -125,25 +125,25 @@ public function getEntitiesB(): Collection } } -/** @Entity */ +#[Entity] class DDC1452EntityB { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC1452EntityA - * @ManyToOne(targetEntity="DDC1452EntityA", inversedBy="entitiesB") */ + #[ManyToOne(targetEntity: 'DDC1452EntityA', inversedBy: 'entitiesB')] public $entityAFrom; /** * @var DDC1452EntityA - * @ManyToOne(targetEntity="DDC1452EntityA") */ + #[ManyToOne(targetEntity: 'DDC1452EntityA')] public $entityATo; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php index 23c382e9742..5996a55a67c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -34,24 +34,22 @@ public function testFailingCase(): void } } -/** @Entity */ +#[Entity] class DDC1454Picture extends DDC1454File { } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"file" = "DDC1454File", "picture" = "DDC1454Picture"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['file' => 'DDC1454File', 'picture' => 'DDC1454Picture'])] class DDC1454File { /** * @var int - * @Column(name="file_id", type="integer") - * @Id */ + #[Column(name: 'file_id', type: 'integer')] + #[Id] public $fileId; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php index 7d9a4df1450..b51572e43b7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php @@ -57,27 +57,27 @@ public function testIssue(): void } -/** @Entity */ +#[Entity] class TestEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] protected $value; /** * @var TestAdditionalEntity - * @OneToOne(targetEntity="TestAdditionalEntity", inversedBy="entity", orphanRemoval=true, cascade={"persist", "remove"}) */ + #[OneToOne(targetEntity: 'TestAdditionalEntity', inversedBy: 'entity', orphanRemoval: true, cascade: ['persist', 'remove'])] protected $additional; public function getValue(): int @@ -100,26 +100,26 @@ public function setAdditional(TestAdditionalEntity $additional): void $this->additional = $additional; } } -/** @Entity */ +#[Entity] class TestAdditionalEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var TestEntity - * @OneToOne(targetEntity="TestEntity", mappedBy="additional") */ + #[OneToOne(targetEntity: 'TestEntity', mappedBy: 'additional')] protected $entity; /** * @var bool - * @Column(type="boolean") */ + #[Column(type: 'boolean')] protected $bool; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index 32f6dfcdc83..efe28d8718c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -46,44 +46,40 @@ public function testChangeDetectionDeferredExplicit(): void } } -/** - * @Entity - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ +#[Entity] +#[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class DDC1461User { /** * @var int - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") */ + #[Id] + #[GeneratedValue(strategy: 'AUTO')] + #[Column(type: 'integer')] public $id; /** * @var DDC1461TwitterAccount - * @OneToOne(targetEntity="DDC1461TwitterAccount", orphanRemoval=true, fetch="EAGER", cascade = {"persist"}, inversedBy="user") */ + #[OneToOne(targetEntity: 'DDC1461TwitterAccount', orphanRemoval: true, fetch: 'EAGER', cascade: ['persist'], inversedBy: 'user')] public $twitterAccount; } -/** - * @Entity - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ +#[Entity] +#[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class DDC1461TwitterAccount { /** * @var int - * @Id - * @GeneratedValue(strategy="AUTO") - * @Column(type="integer") */ + #[Id] + #[GeneratedValue(strategy: 'AUTO')] + #[Column(type: 'integer')] public $id; /** * @var DDC1461User - * @OneToOne(targetEntity="DDC1461User", fetch="EAGER") */ + #[OneToOne(targetEntity: 'DDC1461User', fetch: 'EAGER')] public $user; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php index ad3759e7d26..e3b2d713177 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -67,33 +67,33 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC1514EntityA { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column */ + #[Column] public $title; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC1514EntityB", mappedBy="entityAFrom") */ + #[ManyToMany(targetEntity: 'DDC1514EntityB', mappedBy: 'entityAFrom')] public $entitiesB; /** * @var DDC1514EntityC - * @ManyToOne(targetEntity="DDC1514EntityC") */ + #[ManyToOne(targetEntity: 'DDC1514EntityC')] public $entityC; public function __construct() @@ -102,43 +102,43 @@ public function __construct() } } -/** @Entity */ +#[Entity] class DDC1514EntityB { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC1514EntityA - * @ManyToOne(targetEntity="DDC1514EntityA", inversedBy="entitiesB") */ + #[ManyToOne(targetEntity: 'DDC1514EntityA', inversedBy: 'entitiesB')] public $entityAFrom; /** * @var DDC1514EntityA - * @ManyToOne(targetEntity="DDC1514EntityA") */ + #[ManyToOne(targetEntity: 'DDC1514EntityA')] public $entityATo; } -/** @Entity */ +#[Entity] class DDC1514EntityC { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column */ + #[Column] public $title; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php index 8e79f862517..26b4bd6d1de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -40,31 +40,31 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC1515Foo { /** * @var DDC1515Bar - * @OneToOne(targetEntity="DDC1515Bar", inversedBy="foo") - * @Id */ + #[OneToOne(targetEntity: 'DDC1515Bar', inversedBy: 'foo')] + #[Id] public $bar; } -/** @Entity */ +#[Entity] class DDC1515Bar { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC1515Foo - * @OneToOne(targetEntity="DDC1515Foo", mappedBy="bar") */ + #[OneToOne(targetEntity: 'DDC1515Foo', mappedBy: 'bar')] public $foo; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php index 65b9e2d3460..e39b73def76 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php @@ -51,25 +51,25 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC1526Menu { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; /** * @var DDC1526Menu - * @ManyToOne(targetEntity="DDC1526Menu", inversedBy="children") */ + #[ManyToOne(targetEntity: 'DDC1526Menu', inversedBy: 'children')] public $parent; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1526Menu", mappedBy="parent") */ + #[OneToMany(targetEntity: 'DDC1526Menu', mappedBy: 'parent')] public $children; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php index ccae4bd04a9..d8d21912f7e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -42,47 +42,47 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC1548E1 { /** * @var DDC1548Rel - * @Id - * @OneToOne(targetEntity="DDC1548Rel", inversedBy="e1") */ + #[Id] + #[OneToOne(targetEntity: 'DDC1548Rel', inversedBy: 'e1')] public $rel; } -/** @Entity */ +#[Entity] class DDC1548E2 { /** * @var DDC1548Rel - * @Id - * @OneToOne(targetEntity="DDC1548Rel", inversedBy="e2") */ + #[Id] + #[OneToOne(targetEntity: 'DDC1548Rel', inversedBy: 'e2')] public $rel; } -/** @Entity */ +#[Entity] class DDC1548Rel { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var DDC1548E1 - * @OneToOne(targetEntity="DDC1548E1", mappedBy="rel") */ + #[OneToOne(targetEntity: 'DDC1548E1', mappedBy: 'rel')] public $e1; /** * @var DDC1548E2 - * @OneToOne(targetEntity="DDC1548E2", mappedBy="rel") */ + #[OneToOne(targetEntity: 'DDC1548E2', mappedBy: 'rel')] public $e2; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php index 30908f3bfb8..19a4a6fe4e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorColumn; @@ -73,41 +74,33 @@ public function testIssue(): void } } -/** - * @Entity - * @Table(name="base") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({ - * "Entity1" = "DDC1595InheritedEntity1", - * "Entity2" = "DDC1595InheritedEntity2" - * }) - */ +#[Table(name: 'base')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['Entity1' => 'DDC1595InheritedEntity1', 'Entity2' => 'DDC1595InheritedEntity2'])] abstract class DDC1595BaseInheritance { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; } -/** - * @Entity - * @Table(name="entity1") - */ +#[Table(name: 'entity1')] +#[Entity] class DDC1595InheritedEntity1 extends DDC1595BaseInheritance { /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC1595InheritedEntity2", fetch="EXTRA_LAZY") - * @JoinTable(name="entity1_entity2", - * joinColumns={@JoinColumn(name="parent", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="item", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'entity1_entity2')] + #[JoinColumn(name: 'parent', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'item', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'DDC1595InheritedEntity2', fetch: 'EXTRA_LAZY')] protected $entities; /** @psalm-return Collection */ @@ -117,10 +110,8 @@ public function getEntities(): Collection } } -/** - * @Entity - * @Table(name="entity2") - */ +#[Table(name: 'entity2')] +#[Entity] class DDC1595InheritedEntity2 extends DDC1595BaseInheritance { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php index 10015f0c9f8..085f2c72917 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php @@ -133,33 +133,32 @@ public function testManyToManyClearCollectionReAddOrphanRemoval(): void } } -/** @Entity */ +#[Entity] class DDC1654Post { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC1654Comment", orphanRemoval=true, - * cascade={"persist"}) */ + #[ManyToMany(targetEntity: 'DDC1654Comment', orphanRemoval: true, cascade: ['persist'])] public $comments = []; } -/** @Entity */ +#[Entity] class DDC1654Comment { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index 0d45fcdf853..3e54b71c07a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -96,23 +96,18 @@ public function testPostLoadInheritanceChild(): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({ - * "foo" = "DDC1655Foo", - * "bar" = "DDC1655Bar" - * }) - * @HasLifecycleCallbacks - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorMap(['foo' => 'DDC1655Foo', 'bar' => 'DDC1655Bar'])] +#[HasLifecycleCallbacks] class DDC1655Foo { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** @var int */ @@ -120,47 +115,45 @@ class DDC1655Foo /** * @var DDC1655Baz - * @ManyToOne(targetEntity="DDC1655Baz", inversedBy="foos") */ + #[ManyToOne(targetEntity: 'DDC1655Baz', inversedBy: 'foos')] public $baz; - /** @PostLoad */ + #[PostLoad] public function postLoad(): void { $this->loaded++; } } -/** - * @Entity - * @HasLifecycleCallbacks - */ +#[Entity] +#[HasLifecycleCallbacks] class DDC1655Bar extends DDC1655Foo { /** @var int */ public $subLoaded; - /** @PostLoad */ + #[PostLoad] public function postSubLoaded(): void { $this->subLoaded++; } } -/** @Entity */ +#[Entity] class DDC1655Baz { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC1655Foo", mappedBy="baz") */ + #[OneToMany(targetEntity: 'DDC1655Foo', mappedBy: 'baz')] public $foos = []; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php index 45ed21f8cd6..a758fdb0a1a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php @@ -99,23 +99,19 @@ protected function onPropertyChanged($propName, $oldValue, $newValue): void } } -/** - * @Entity - * @ChangeTrackingPolicy("NOTIFY") - */ +#[Entity] +#[ChangeTrackingPolicy('NOTIFY')] class DDC1690Parent extends NotifyBaseEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column */ + #[Column] private string|null $name = null; - /** @OneToOne(targetEntity="DDC1690Child") */ + #[OneToOne(targetEntity: 'DDC1690Child')] private DDC1690Child|null $child = null; public function getId(): int @@ -145,20 +141,18 @@ public function getChild(): DDC1690Child } } -/** @Entity */ +#[Entity] class DDC1690Child extends NotifyBaseEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column */ + #[Column] private string|null $name = null; - /** @OneToOne(targetEntity="DDC1690Parent", mappedBy="child") */ + #[OneToOne(targetEntity: 'DDC1690Parent', mappedBy: 'child')] private DDC1690Parent|null $parent = null; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php index a3eafb928e6..eaced3986d7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -32,67 +32,63 @@ public function testIssue(): void } } -/** - * @Table(name="`DDC1695News`") - * @Entity - */ +#[Table(name: '`DDC1695News`')] +#[Entity] class DDC1695News { - /** - * @Column(name="`IdNews`", type="integer", nullable=false) - * @Id - * @GeneratedValue - */ + #[Column(name: '`IdNews`', type: 'integer', nullable: false)] + #[Id] + #[GeneratedValue] private int $idNews; - /** @Column(name="`IdUser`", type="bigint", nullable=false) */ + #[Column(name: '`IdUser`', type: 'bigint', nullable: false)] private int $idUser; - /** @Column(name="`IdLanguage`", type="integer", nullable=false) */ + #[Column(name: '`IdLanguage`', type: 'integer', nullable: false)] private int $idLanguage; - /** @Column(name="`IdCondition`", type="integer", nullable=true) */ + #[Column(name: '`IdCondition`', type: 'integer', nullable: true)] private int $idCondition; - /** @Column(name="`IdHealthProvider`", type="integer", nullable=true) */ + #[Column(name: '`IdHealthProvider`', type: 'integer', nullable: true)] private int $idHealthProvider; - /** @Column(name="`IdSpeciality`", type="integer", nullable=true) */ + #[Column(name: '`IdSpeciality`', type: 'integer', nullable: true)] private int $idSpeciality; - /** @Column(name="`IdMedicineType`", type="integer", nullable=true) */ + #[Column(name: '`IdMedicineType`', type: 'integer', nullable: true)] private int $idMedicineType; - /** @Column(name="`IdTreatment`", type="integer", nullable=true) */ + #[Column(name: '`IdTreatment`', type: 'integer', nullable: true)] private int $idTreatment; - /** @Column(name="`Title`", type="string", nullable=true) */ + #[Column(name: '`Title`', type: 'string', nullable: true)] private string $title; - /** @Column(name="`SmallText`", type="string", nullable=true) */ + #[Column(name: '`SmallText`', type: 'string', nullable: true)] private string $smallText; - /** @Column(name="`LongText`", type="string", nullable=true) */ + #[Column(name: '`LongText`', type: 'string', nullable: true)] private string $longText; - /** @Column(name="`PublishDate`", type="datetimetz", nullable=true) */ + #[Column(name: '`PublishDate`', type: 'datetimetz', nullable: true)] private DateTimeZone $publishDate; - /** @Column(name="`IdxNews`", type="json_array", nullable=true) */ + #[Column(name: '`IdxNews`', type: 'json_array', nullable: true)] private array $idxNews; - /** @Column(name="`Highlight`", type="boolean", nullable=false) */ + #[Column(name: '`Highlight`', type: 'boolean', nullable: false)] private bool $highlight; - /** @Column(name="`Order`", type="integer", nullable=false) */ + #[Column(name: '`Order`', type: 'integer', nullable: false)] private int $order; - /** @Column(name="`Deleted`", type="boolean", nullable=false) */ + #[Column(name: '`Deleted`', type: 'boolean', nullable: false)] private bool $deleted; - /** @Column(name="`Active`", type="boolean", nullable=false) */ + #[Column(name: '`Active`', type: 'boolean', nullable: false)] private bool $active; - /** @Column(name="`UpdateToHighlighted`", type="boolean", nullable=true) */ + #[Column(name: '`UpdateToHighlighted`', type: 'boolean', nullable: true)] private bool $updateToHighlighted; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index 2186b4315e6..c39fcf5fd58 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -39,32 +39,30 @@ public function testPostLoadOnChild(): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"c": "DDC1707Child"}) - * @HasLifecycleCallbacks - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorMap(['c' => 'DDC1707Child'])] +#[HasLifecycleCallbacks] abstract class DDC1707Base { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; /** @var bool */ public $postLoad = false; - /** @PostLoad */ + #[PostLoad] public function onPostLoad(): void { $this->postLoad = true; } } -/** @Entity */ +#[Entity] class DDC1707Child extends DDC1707Base { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php index 0f725be40ca..6cb2a6ad4bd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php @@ -81,22 +81,20 @@ public function testCreateRetrieveUpdateDelete(): void } } -/** - * @Entity - * @Table(name="`ddc-1719-simple-entity`") - */ +#[Table(name: '`ddc-1719-simple-entity`')] +#[Entity] class DDC1719SimpleEntity { /** * @var int - * @Id - * @Column(type="integer", name="`simple-entity-id`") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer', name: '`simple-entity-id`')] + #[GeneratedValue(strategy: 'AUTO')] public $id; public function __construct( - /** @Column(type="string", name="`simple-entity-value`") */ + #[Column(type: 'string', name: '`simple-entity-value`')] public string $value, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php index 97e64973faa..9cc17f78721 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php @@ -39,54 +39,50 @@ public function testFailingCase(): void } } -/** @Entity */ +#[Entity] class DDC1757A { - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; } -/** @Entity */ +#[Entity] class DDC1757B { - /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @OneToOne(targetEntity="DDC1757C") */ + #[OneToOne(targetEntity: 'DDC1757C')] private DDC1757C $c; } -/** @Entity */ +#[Entity] class DDC1757C { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; - /** @OneToOne(targetEntity="DDC1757D") */ + #[OneToOne(targetEntity: 'DDC1757D')] private DDC1757D $d; } -/** @Entity */ +#[Entity] class DDC1757D { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php index a3e3231d9a9..22e8ed59d8f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php @@ -39,25 +39,19 @@ public function testIssue(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"bar" = "DDC1787Bar", "foo" = "DDC1787Foo"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['bar' => 'DDC1787Bar', 'foo' => 'DDC1787Foo'])] class DDC1787Foo { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @Version - * @Column(type="integer") - */ + #[Version] + #[Column(type: 'integer')] private int $version; public function getVersion(): int @@ -66,7 +60,7 @@ public function getVersion(): int } } -/** @Entity */ +#[Entity] class DDC1787Bar extends DDC1787Foo { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php index 1dc0cb97a48..b6b27081165 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -54,31 +55,25 @@ public function testIssue(): void } } -/** - * @Table - * @Entity - */ +#[Table] +#[Entity] class DDC1925Product { - /** - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(name="title", type="string", length=255) */ + #[Column(name: 'title', type: 'string', length: 255)] private string|null $title = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC1925User") - * @JoinTable( - * name="user_purchases", - * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'user_purchases')] + #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'user_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'DDC1925User')] private $buyers; /** @@ -118,20 +113,16 @@ public function addBuyer(DDC1925User $buyer): void } } -/** - * @Table - * @Entity - */ +#[Table] +#[Entity] class DDC1925User { - /** - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(name="title", type="string", length=255) */ + #[Column(name: 'title', type: 'string', length: 255)] private string|null $title = null; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php index 18f3ee16bef..cbc720d8380 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php @@ -36,47 +36,43 @@ public function testSchemaCreation(): void } } -/** - * @Entity - * @Table(name="ddc192_users") - */ +#[Table(name: 'ddc192_users')] +#[Entity] class DDC192User { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(name="name", type="string", length=255) */ + #[Column(name: 'name', type: 'string', length: 255)] public $name; } -/** - * @Entity - * @Table(name="ddc192_phonenumbers") - */ +#[Table(name: 'ddc192_phonenumbers')] +#[Entity] class DDC192Phonenumber { /** * @var string - * @Id - * @Column(name="phone", type="string", length=40) */ + #[Id] + #[Column(name: 'phone', type: 'string', length: 40)] protected $phone; /** * @var DDC192User - * @Id - * @ManyToOne(targetEntity="DDC192User") - * @JoinColumn(name="userId", referencedColumnName="id") */ + #[Id] + #[ManyToOne(targetEntity: 'DDC192User')] + #[JoinColumn(name: 'userId', referencedColumnName: 'id')] protected $user; public function setPhone(string $value): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index 95884614c94..2403f8cc027 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -46,20 +46,20 @@ public function testSqlConversionAsIdentifier(): void } } -/** @Entity */ +#[Entity] class DDC1998Entity { /** * @var string - * @Id - * @Column(type="ddc1998", length=255) */ + #[Id] + #[Column(type: 'ddc1998', length: 255)] public $id; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $num = 0; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php index 57458451a10..87f5d05edf1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php @@ -63,71 +63,67 @@ public function testPolymorphicLoading(): void } -/** - * @Entity - * @Table(name="ddc199_entities") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"parent" = "DDC199ParentClass", "child" = "DDC199ChildClass"}) - */ +#[Table(name: 'ddc199_entities')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['parent' => 'DDC199ParentClass', 'child' => 'DDC199ChildClass'])] class DDC199ParentClass { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $parentData; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC199RelatedClass", mappedBy="parent") */ + #[OneToMany(targetEntity: 'DDC199RelatedClass', mappedBy: 'parent')] public $relatedEntities; } -/** @Entity */ +#[Entity] class DDC199ChildClass extends DDC199ParentClass { /** * @var string - * @Column */ + #[Column] public $childData; } -/** - * @Entity - * @Table(name="ddc199_relatedclass") - */ +#[Table(name: 'ddc199_relatedclass')] +#[Entity] class DDC199RelatedClass { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column */ + #[Column] public $relatedData; /** * @var DDC199ParentClass - * @ManyToOne(targetEntity="DDC199ParentClass", inversedBy="relatedEntities") - * @JoinColumn(name="parent_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'DDC199ParentClass', inversedBy: 'relatedEntities')] + #[JoinColumn(name: 'parent_id', referencedColumnName: 'id')] public $parent; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index ddaf3e8524a..ac4541dbecc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -82,37 +82,30 @@ public function testIssue(): void } } -/** - * @Table(name="ddc2010_item") - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type_id", type="smallint") - * @DiscriminatorMap({ - * 1 = "DDC2012ItemPerson", - * 2 = "DDC2012Item" - * }) - */ +#[Table(name: 'ddc2010_item')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'type_id', type: 'smallint')] +#[DiscriminatorMap([1 => 'DDC2012ItemPerson', 2 => 'DDC2012Item'])] class DDC2012Item { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @psalm-var list - * @Column(name="tsv", type="tsvector", length=255, nullable=true) */ + #[Column(name: 'tsv', type: 'tsvector', length: 255, nullable: true)] public $tsv; } -/** - * @Table(name="ddc2010_item_person") - * @Entity - */ +#[Table(name: 'ddc2010_item_person')] +#[Entity] class DDC2012ItemPerson extends DDC2012Item { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php index d5050f86e2f..77c7ecbbdd6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php @@ -72,18 +72,14 @@ public function testInvalidIdentifierBindingEntityException(): void use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="DDC2084_ENTITY1") - */ +#[Table(name: 'DDC2084_ENTITY1')] +#[Entity] class MyEntity1 { public function __construct( - /** - * @Id - * @OneToOne(targetEntity="MyEntity2") - * @JoinColumn(name="entity2_id", referencedColumnName="id", nullable=false) - */ + #[Id] + #[OneToOne(targetEntity: 'MyEntity2')] + #[JoinColumn(name: 'entity2_id', referencedColumnName: 'id', nullable: false)] private MyEntity2 $entity2, ) { } @@ -99,21 +95,17 @@ public function getMyEntity2(): MyEntity2 } } -/** - * @Entity - * @Table(name="DDC2084_ENTITY2") - */ +#[Table(name: 'DDC2084_ENTITY2')] +#[Entity] class MyEntity2 { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; public function __construct( - /** @Column */ + #[Column] private string $value, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php index ed74875aea9..b5164720e12 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php @@ -44,27 +44,27 @@ public function testDetachedEntityAsId(): void } } -/** @Entity */ +#[Entity] class DDC2106Entity { /** * @var int - * @Id - * @GeneratedValue(strategy="IDENTITY") - * @Column(type="integer") */ + #[Id] + #[GeneratedValue(strategy: 'IDENTITY')] + #[Column(type: 'integer')] public $id; /** * @var DDC2106Entity - * @ManyToOne(targetEntity="DDC2106Entity", inversedBy="children") */ + #[ManyToOne(targetEntity: 'DDC2106Entity', inversedBy: 'children')] public $parent; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC2106Entity", mappedBy="parent", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'DDC2106Entity', mappedBy: 'parent', cascade: ['persist'])] public $children; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php index c06075cfce9..9d7884e977a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -51,34 +52,31 @@ public function testIssue(): void } -/** - * @Entity - * @Table(name="ddc211_users") - */ +#[Table(name: 'ddc211_users')] +#[Entity] class DDC211User { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var string - * @Column(name="name", type="string", length=255) */ + #[Column(name: 'name', type: 'string', length: 255)] protected $name; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC211Group", inversedBy="users") - * @JoinTable(name="user_groups", - * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'user_groups')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'DDC211Group', inversedBy: 'users')] protected $groups; public function __construct() @@ -98,30 +96,28 @@ public function getGroups(): Collection } } -/** - * @Entity - * @Table(name="ddc211_groups") - */ +#[Table(name: 'ddc211_groups')] +#[Entity] class DDC211Group { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var string - * @Column(name="name", type="string", length=255) */ + #[Column(name: 'name', type: 'string', length: 255)] protected $name; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC211User", mappedBy="groups") */ + #[ManyToMany(targetEntity: 'DDC211User', mappedBy: 'groups')] protected $users; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index 1d90f1bcbbd..dce769e7b7b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -58,42 +58,38 @@ public function testForeignKeyOnSTIWithMultipleMapping(): void -/** - * @Table(name="structures") - * @Entity - */ +#[Table(name: 'structures')] +#[Entity] class DDC2138Structure { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var string - * @Column(type="string", length=32, nullable=true) */ + #[Column(type: 'string', length: 32, nullable: true)] protected $name; } -/** - * @Entity - * @Table(name="users_followed_objects") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="object_type", type="smallint") - * @DiscriminatorMap({4 = "DDC2138UserFollowedUser", 3 = "DDC2138UserFollowedStructure"}) - */ +#[Table(name: 'users_followed_objects')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'object_type', type: 'smallint')] +#[DiscriminatorMap([4 => 'DDC2138UserFollowedUser', 3 => 'DDC2138UserFollowedStructure'])] abstract class DDC2138UserFollowedObject { /** * @var int $id - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** @@ -105,22 +101,18 @@ public function getId(): int } } -/** @Entity */ +#[Entity] class DDC2138UserFollowedStructure extends DDC2138UserFollowedObject { /** * Construct a UserFollowedStructure entity */ public function __construct( - /** - * @ManyToOne(targetEntity="DDC2138User", inversedBy="followedStructures") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) - */ + #[ManyToOne(targetEntity: 'DDC2138User', inversedBy: 'followedStructures')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)] protected User $user, - /** - * @ManyToOne(targetEntity="DDC2138Structure") - * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) - */ + #[ManyToOne(targetEntity: 'DDC2138Structure')] + #[JoinColumn(name: 'object_id', referencedColumnName: 'id', nullable: false)] private Structure $followedStructure, ) { } @@ -139,22 +131,18 @@ public function getFollowedStructure(): Structure } } -/** @Entity */ +#[Entity] class DDC2138UserFollowedUser extends DDC2138UserFollowedObject { /** * Construct a UserFollowedUser entity */ public function __construct( - /** - * @ManyToOne(targetEntity="DDC2138User", inversedBy="followedUsers") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) - */ + #[ManyToOne(targetEntity: 'DDC2138User', inversedBy: 'followedUsers')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)] protected User $user, - /** - * @ManyToOne(targetEntity="DDC2138User") - * @JoinColumn(name="object_id", referencedColumnName="id", nullable=false) - */ + #[ManyToOne(targetEntity: 'DDC2138User')] + #[JoinColumn(name: 'object_id', referencedColumnName: 'id', nullable: false)] private User $followedUser, ) { } @@ -173,36 +161,34 @@ public function getFollowedUser(): User } } -/** - * @Table(name="users") - * @Entity - */ +#[Table(name: 'users')] +#[Entity] class DDC2138User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var string - * @Column(type="string", length=32, nullable=true) */ + #[Column(type: 'string', length: 32, nullable: true)] protected $name; /** * @var ArrayCollection $followedUsers - * @OneToMany(targetEntity="DDC2138UserFollowedUser", mappedBy="user", cascade={"persist"}, orphanRemoval=true) */ + #[OneToMany(targetEntity: 'DDC2138UserFollowedUser', mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] protected $followedUsers; /** * @var ArrayCollection $followedStructures - * @OneToMany(targetEntity="DDC2138UserFollowedStructure", mappedBy="user", cascade={"persist"}, orphanRemoval=true) */ + #[OneToMany(targetEntity: 'DDC2138UserFollowedStructure', mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] protected $followedStructures; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php index 79195bdb017..88f0dc87491 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php @@ -44,31 +44,29 @@ public function testIssue(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({"entity": "DDC2175Entity"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorMap(['entity' => 'DDC2175Entity'])] class DDC2175Entity { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $field; /** * @var int - * @Version - * @Column(type="integer") */ + #[Version] + #[Column(type: 'integer')] public $version; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php index 7f89c33dfdf..d804be0caef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -33,34 +33,24 @@ public function testPassColumnOptionsToJoinColumns(): void } } -/** - * @Entity - * @Table - */ +#[Table] +#[Entity] class DDC2182OptionParent { - /** - * @Id - * @Column(type="integer", options={"unsigned": true}) - */ + #[Id] + #[Column(type: 'integer', options: ['unsigned' => true])] private int $id; } -/** - * @Entity - * @Table - */ +#[Table] +#[Entity] class DDC2182OptionChild { - /** - * @Id - * @Column - */ + #[Id] + #[Column] private string $id; - /** - * @ManyToOne(targetEntity="DDC2182OptionParent") - * @JoinColumn(referencedColumnName="id") - */ + #[ManyToOne(targetEntity: 'DDC2182OptionParent')] + #[JoinColumn(referencedColumnName: 'id')] private DDC2182OptionParent $parent; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php index 40866868107..5d353d1f3b1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php @@ -56,32 +56,32 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC2214Foo { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var DDC2214Bar - * @ManyToOne(targetEntity="DDC2214Bar") */ + #[ManyToOne(targetEntity: 'DDC2214Bar')] public $bar; } -/** @Entity */ +#[Entity] class DDC2214Bar { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index a287d09faa1..f4ee4f557cd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -73,20 +73,20 @@ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): } } -/** @Entity */ +#[Entity] class DDC2224Entity { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var mixed - * @Column(type="DDC2224Type", length=255) */ + #[Column(type: 'DDC2224Type', length: 255)] public $field; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index 64b7a111bc9..eef3038e75a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -50,36 +50,34 @@ public function testNotifyTrackingCalledOnProxyInitialization(): void } } -/** @Entity */ +#[Entity] class DDC2230User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var DDC2230Address - * @OneToOne(targetEntity="DDC2230Address") */ + #[OneToOne(targetEntity: 'DDC2230Address')] public $address; } -/** - * @Entity - * @ChangeTrackingPolicy("NOTIFY") - */ +#[Entity] +#[ChangeTrackingPolicy('NOTIFY')] class DDC2230Address implements NotifyPropertyChanged { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** @var \Doctrine\Common\PropertyChangedListener */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index 09e9977694e..a617bb5ce68 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -119,18 +120,16 @@ public function testIssue(): void } } -/** - * @Entity() - * @Table(name="ddc2252_acl_privilege") - */ +#[Table(name: 'ddc2252_acl_privilege')] +#[Entity] class DDC2252Privilege { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $privilegeid; public function getPrivilegeid(): int @@ -139,17 +138,15 @@ public function getPrivilegeid(): int } } -/** - * @Entity - * @Table(name="ddc2252_mch_account") - */ +#[Table(name: 'ddc2252_mch_account')] +#[Entity] class DDC2252MerchantAccount { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] protected $accountid = 111; public function getAccountid(): int @@ -158,24 +155,22 @@ public function getAccountid(): int } } -/** - * @Entity - * @Table(name="ddc2252_user_account") - */ +#[Table(name: 'ddc2252_user_account')] +#[Entity] class DDC2252User { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] protected $uid = 222; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC2252Membership", mappedBy="userAccount", cascade={"persist"}) - * @JoinColumn(name="uid", referencedColumnName="uid") */ + #[OneToMany(targetEntity: 'DDC2252Membership', mappedBy: 'userAccount', cascade: ['persist'])] + #[JoinColumn(name: 'uid', referencedColumnName: 'uid')] protected $memberships; public function __construct() @@ -200,40 +195,29 @@ public function addMembership(DDC2252Membership $membership): void } } -/** - * @Entity - * @Table(name="ddc2252_mch_account_member") - * @HasLifecycleCallbacks - */ +#[Table(name: 'ddc2252_mch_account_member')] +#[Entity] +#[HasLifecycleCallbacks] class DDC2252Membership { /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC2252Privilege", indexBy="privilegeid") - * @JoinTable(name="ddc2252_user_mch_account_privilege", - * joinColumns={ - * @JoinColumn(name="mch_accountid", referencedColumnName="mch_accountid"), - * @JoinColumn(name="uid", referencedColumnName="uid") - * }, - * inverseJoinColumns={ - * @JoinColumn(name="privilegeid", referencedColumnName="privilegeid") - * } - * ) */ + #[JoinTable(name: 'ddc2252_user_mch_account_privilege')] + #[JoinColumn(name: 'mch_accountid', referencedColumnName: 'mch_accountid')] + #[JoinColumn(name: 'uid', referencedColumnName: 'uid')] + #[InverseJoinColumn(name: 'privilegeid', referencedColumnName: 'privilegeid')] + #[ManyToMany(targetEntity: 'DDC2252Privilege', indexBy: 'privilegeid')] protected $privileges; public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="DDC2252User", inversedBy="memberships") - * @JoinColumn(name="uid", referencedColumnName="uid") - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC2252User', inversedBy: 'memberships')] + #[JoinColumn(name: 'uid', referencedColumnName: 'uid')] protected DDC2252User $userAccount, - /** - * @Id - * @ManyToOne(targetEntity="DDC2252MerchantAccount") - * @JoinColumn(name="mch_accountid", referencedColumnName="accountid") - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC2252MerchantAccount')] + #[JoinColumn(name: 'mch_accountid', referencedColumnName: 'accountid')] protected DDC2252MerchantAccount $merchantAccount, ) { $this->privileges = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index 53c9cb272fe..fa19eae768b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -82,39 +82,39 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC2306Zone { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class DDC2306User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC2306UserAddress[]|Collection - * @OneToMany(targetEntity="DDC2306UserAddress", mappedBy="user") */ + #[OneToMany(targetEntity: 'DDC2306UserAddress', mappedBy: 'user')] public $addresses; /** * @var DDC2306Zone - * @ManyToOne(targetEntity="DDC2306Zone", fetch="EAGER") */ + #[ManyToOne(targetEntity: 'DDC2306Zone', fetch: 'EAGER')] public $zone; /** Constructor */ @@ -124,27 +124,27 @@ public function __construct() } } -/** @Entity */ +#[Entity] class DDC2306Address { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC2306UserAddress[]|Collection - * @OneToMany(targetEntity="DDC2306UserAddress", mappedBy="address", orphanRemoval=true) */ + #[OneToMany(targetEntity: 'DDC2306UserAddress', mappedBy: 'address', orphanRemoval: true)] public $users; /** * @var DDC2306Zone - * @ManyToOne(targetEntity="DDC2306Zone", fetch="EAGER") */ + #[ManyToOne(targetEntity: 'DDC2306Zone', fetch: 'EAGER')] public $zone; /** Constructor */ @@ -154,22 +154,22 @@ public function __construct() } } -/** @Entity */ +#[Entity] class DDC2306UserAddress { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** Constructor */ public function __construct( - /** @ManyToOne(targetEntity="DDC2306User") */ + #[ManyToOne(targetEntity: 'DDC2306User')] public DDC2306User $user, - /** @ManyToOne(targetEntity="DDC2306Address", fetch="LAZY") */ + #[ManyToOne(targetEntity: 'DDC2306Address', fetch: 'LAZY')] public DDC2306Address $address, ) { $user->addresses->add($this); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index 3295120c461..05664ac943f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -65,21 +65,21 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC2346Foo { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC2346Bar[]|Collection - * @OneToMany(targetEntity="DDC2346Bar", mappedBy="foo") */ + #[OneToMany(targetEntity: 'DDC2346Bar', mappedBy: 'foo')] public $bars; /** Constructor */ @@ -89,31 +89,29 @@ public function __construct() } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"bar" = "DDC2346Bar", "baz" = "DDC2346Baz"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['bar' => 'DDC2346Bar', 'baz' => 'DDC2346Baz'])] class DDC2346Bar { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC2346Foo - * @ManyToOne(targetEntity="DDC2346Foo", inversedBy="bars", fetch="EAGER") */ + #[ManyToOne(targetEntity: 'DDC2346Foo', inversedBy: 'bars', fetch: 'EAGER')] public $foo; } -/** @Entity */ +#[Entity] class DDC2346Baz extends DDC2346Bar { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php index 2f9e7c514bd..3f51cc093c6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php @@ -52,37 +52,37 @@ public function testEagerCollectionsAreOnlyRetrievedOnce(): void } } -/** @Entity */ +#[Entity] class DDC2350User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC2350Bug", mappedBy="user", fetch="EAGER") */ + #[OneToMany(targetEntity: 'DDC2350Bug', mappedBy: 'user', fetch: 'EAGER')] public $reportedBugs; } -/** @Entity */ +#[Entity] class DDC2350Bug { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC2350User - * @ManyToOne(targetEntity="DDC2350User", inversedBy="reportedBugs") */ + #[ManyToOne(targetEntity: 'DDC2350User', inversedBy: 'reportedBugs')] public $user; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index 870e5ea3dd7..ac29909e4d2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -61,14 +61,14 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC2359Foo { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php index 3f2ea7b08cb..0cbf6e97005 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -71,76 +71,70 @@ public function testUninitializedProxyIsInitializedOnFetchJoin(): void } -/** - * @Entity - * @Table(name="ddc237_x") - */ +#[Table(name: 'ddc237_x')] +#[Entity] class DDC237EntityX { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; /** * @var DDC237EntityY - * @OneToOne(targetEntity="DDC237EntityY") - * @JoinColumn(name="y_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC237EntityY')] + #[JoinColumn(name: 'y_id', referencedColumnName: 'id')] public $y; } -/** - * @Entity - * @Table(name="ddc237_y") - */ +#[Table(name: 'ddc237_y')] +#[Entity] class DDC237EntityY { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; } -/** - * @Entity - * @Table(name="ddc237_z") - */ +#[Table(name: 'ddc237_z')] +#[Entity] class DDC237EntityZ { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; /** * @var DDC237EntityY - * @OneToOne(targetEntity="DDC237EntityY") - * @JoinColumn(name="y_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC237EntityY')] + #[JoinColumn(name: 'y_id', referencedColumnName: 'id')] public $y; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index 3e1fca58ebd..ef5ebdb2ec7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -81,25 +81,21 @@ public function testIssue(): void } } -/** - * @Table(name="ddc2494_currency") - * @Entity - */ +#[Table(name: 'ddc2494_currency')] +#[Entity] class DDC2494Currency { /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC2494Campaign", mappedBy="currency") */ + #[OneToMany(targetEntity: 'DDC2494Campaign', mappedBy: 'currency')] protected $campaigns; public function __construct( - /** - * @Id - * @Column(type="ddc2494_tinyint") - */ + #[Id] + #[Column(type: 'ddc2494_tinyint')] protected int $id, - /** @Column(name="temp", type="ddc2494_tinyint", nullable=false) */ + #[Column(name: 'temp', type: 'ddc2494_tinyint', nullable: false)] protected int $temp, ) { } @@ -121,25 +117,21 @@ public function getCampaigns(): Collection } } -/** - * @Table(name="ddc2494_campaign") - * @Entity - */ +#[Table(name: 'ddc2494_campaign')] +#[Entity] class DDC2494Campaign { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; public function __construct( - /** - * @ManyToOne(targetEntity="DDC2494Currency", inversedBy="campaigns") - * @JoinColumn(name="currency_id", referencedColumnName="id", nullable=false) - */ + #[ManyToOne(targetEntity: 'DDC2494Currency', inversedBy: 'campaigns')] + #[JoinColumn(name: 'currency_id', referencedColumnName: 'id', nullable: false)] protected DDC2494Currency $currency, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index dfef40b3b45..39cd9171768 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -95,56 +95,48 @@ public function testHydrationIssue(): void } } -/** @Entity */ +#[Entity] class DDC2575Root { /** * @var DDC2575A - * @OneToOne(targetEntity="DDC2575A", mappedBy="rootRelation") */ + #[OneToOne(targetEntity: 'DDC2575A', mappedBy: 'rootRelation')] public $aRelation; public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] public int $id, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $sampleField = 0, ) { } } -/** @Entity */ +#[Entity] class DDC2575A { public function __construct( - /** - * @Id - * @OneToOne(targetEntity="DDC2575Root", inversedBy="aRelation") - * @JoinColumn(name="root_id", referencedColumnName="id", nullable=FALSE, onDelete="CASCADE") - */ + #[Id] + #[OneToOne(targetEntity: 'DDC2575Root', inversedBy: 'aRelation')] + #[JoinColumn(name: 'root_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] public DDC2575Root $rootRelation, - /** - * @ManyToOne(targetEntity="DDC2575B") - * @JoinColumn(name="b_id", referencedColumnName="id", nullable=FALSE, onDelete="CASCADE") - */ + #[ManyToOne(targetEntity: 'DDC2575B')] + #[JoinColumn(name: 'b_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] public DDC2575B $bRelation, ) { } } -/** @Entity */ +#[Entity] class DDC2575B { public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] public int $id, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $sampleField = 0, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index 3c1e2130769..27061bb552e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -67,27 +67,27 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC2579Entity { /** * @var DDC2579Id - * @Id - * @Column(type="ddc2579", length=255) */ + #[Id] + #[Column(type: 'ddc2579', length: 255)] public $id; /** * @var DDC2579EntityAssoc - * @Id - * @ManyToOne(targetEntity="DDC2579EntityAssoc") - * @JoinColumn(name="relation_id", referencedColumnName="association_id") */ + #[Id] + #[ManyToOne(targetEntity: 'DDC2579EntityAssoc')] + #[JoinColumn(name: 'relation_id', referencedColumnName: 'association_id')] public $assoc; public function __construct( DDC2579EntityAssoc $assoc, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $value = 0, ) { $this->id = $assoc->assocAssoc->associationId; @@ -95,29 +95,27 @@ public function __construct( } } -/** @Entity */ +#[Entity] class DDC2579EntityAssoc { public function __construct( /** * @var DDC2579AssocAssoc - * @Id - * @ManyToOne(targetEntity="DDC2579AssocAssoc") - * @JoinColumn(name="association_id", referencedColumnName="associationId") */ + #[Id] + #[ManyToOne(targetEntity: 'DDC2579AssocAssoc')] + #[JoinColumn(name: 'association_id', referencedColumnName: 'associationId')] public $assocAssoc, ) { } } -/** @Entity */ +#[Entity] class DDC2579AssocAssoc { public function __construct( - /** - * @Id - * @Column(type="ddc2579", length=255) - */ + #[Id] + #[Column(type: 'ddc2579', length: 255)] public DDC2579Id $associationId, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php index 1f0065c3817..465c4684b31 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -77,78 +77,75 @@ public function testIssue(): void } } -/** - * @Entity - * @Table(name="DDC258Super") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"class1" = "DDC258Class1", "class2" = "DDC258Class2", "class3"="DDC258Class3"}) - */ +#[Table(name: 'DDC258Super')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['class1' => 'DDC258Class1', 'class2' => 'DDC258Class2', 'class3' => 'DDC258Class3'])] abstract class DDC258Super { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } -/** @Entity */ +#[Entity] class DDC258Class1 extends DDC258Super { /** * @var string - * @Column(name="title", type="string", length=150) */ + #[Column(name: 'title', type: 'string', length: 150)] public $title; /** * @var string - * @Column(name="content", type="string", length=500) */ + #[Column(name: 'content', type: 'string', length: 500)] public $description; } -/** @Entity */ +#[Entity] class DDC258Class2 extends DDC258Super { /** * @var string - * @Column(name="title", type="string", length=150) */ + #[Column(name: 'title', type: 'string', length: 150)] public $title; /** * @var string - * @Column(name="content", type="string", length=500) */ + #[Column(name: 'content', type: 'string', length: 500)] public $description; /** * @var string - * @Column(name="text", type="text") */ + #[Column(name: 'text', type: 'text')] public $text; } /** * An extra class to demonstrate why title and description aren't in Super - * - * @Entity */ +#[Entity] class DDC258Class3 extends DDC258Super { /** * @var string - * @Column(name="title", type="string", length=150) */ + #[Column(name: 'title', type: 'string', length: 150)] public $apples; /** * @var string - * @Column(name="content", type="string", length=500) */ + #[Column(name: 'content', type: 'string', length: 500)] public $bananas; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php index 487535df5e4..4a156202c5a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php @@ -158,97 +158,85 @@ public function postLoad(PostLoadEventArgs $event): void } -/** @Entity */ +#[Entity] class DDC2602User { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** - * @Column(type="string", length=15) * @var string */ + #[Column(type: 'string', length: 15)] public $name; /** * @var DDC2602Biography - * @OneToOne( - * targetEntity="DDC2602Biography", - * inversedBy="user", - * cascade={"persist", "merge", "refresh", "remove"} - * ) - * @JoinColumn(nullable=false) */ + #[OneToOne(targetEntity: 'DDC2602Biography', inversedBy: 'user', cascade: ['persist', 'merge', 'refresh', 'remove'])] + #[JoinColumn(nullable: false)] public $biography; } -/** @Entity */ +#[Entity] class DDC2602Biography { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var DDC2602User - * @OneToOne( - * targetEntity="DDC2602User", - * mappedBy="biography", - * cascade={"persist", "merge", "refresh"} - * ) */ + #[OneToOne(targetEntity: 'DDC2602User', mappedBy: 'biography', cascade: ['persist', 'merge', 'refresh'])] public $user; /** - * @Column(type="text", nullable=true) * @var string */ + #[Column(type: 'text', nullable: true)] public $content; /** @var array */ public $fieldList = []; } -/** @Entity */ +#[Entity] class DDC2602BiographyField { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", unique=true, length=100) */ + #[Column(type: 'string', unique: true, length: 100)] public $alias; /** * @var string - * @Column(type="string", length=100) */ + #[Column(type: 'string', length: 100)] public $label; /** - * @OneToMany( - * targetEntity="DDC2602BiographyFieldChoice", - * mappedBy="field", - * cascade={"persist", "merge", "refresh"} - * ) * @var ArrayCollection */ + #[OneToMany(targetEntity: 'DDC2602BiographyFieldChoice', mappedBy: 'field', cascade: ['persist', 'merge', 'refresh'])] public $choiceList; public function __construct() @@ -257,31 +245,28 @@ public function __construct() } } -/** @Entity */ +#[Entity] class DDC2602BiographyFieldChoice { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", unique=true, length=100) */ + #[Column(type: 'string', unique: true, length: 100)] public $label; /** - * @ManyToOne( - * targetEntity="DDC2602BiographyField", - * inversedBy="choiceList" - * ) - * @JoinColumn(onDelete="CASCADE") * @var DDC2602BiographyField */ + #[ManyToOne(targetEntity: 'DDC2602BiographyField', inversedBy: 'choiceList')] + #[JoinColumn(onDelete: 'CASCADE')] public $field; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php index 73ed1e9a0a6..36885df7513 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php @@ -85,54 +85,44 @@ public function testIssueWithoutExtraColumn(): void } } } -/** - * @Entity - * @Table(name="ddc_2660_product") - */ +#[Table(name: 'ddc_2660_product')] +#[Entity] class DDC2660Product { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** - * @Entity - * @Table(name="ddc_2660_customer") - */ +#[Table(name: 'ddc_2660_customer')] +#[Entity] class DDC2660Customer { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** - * @Entity - * @Table(name="ddc_2660_customer_order") - */ +#[Table(name: 'ddc_2660_customer_order')] +#[Entity] class DDC2660CustomerOrder { public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="DDC2660Product") - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC2660Product')] public DDC2660Product $product, - /** - * @Id - * @ManyToOne(targetEntity="DDC2660Customer") - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC2660Customer')] public DDC2660Customer $customer, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index c7c3ecc348b..1ca96d1b6a8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -58,17 +58,15 @@ public function preFlush(PreFlushEventArgs $args): void self::assertSame(1, $listener->registeredCalls); } } -/** - * @Entity - * @Table(name="ddc_2692_foo") - */ +#[Table(name: 'ddc_2692_foo')] +#[Entity] class DDC2692Foo { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index dd5dc6748f4..6c5c250b21a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -67,93 +67,85 @@ public function testCorrectNumberOfAssociationsIsReturned(): void } } -/** - * @Entity - * @Table(name="ddc_2759_qualification") - */ +#[Table(name: 'ddc_2759_qualification')] +#[Entity] class DDC2759Qualification { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC2759QualificationMetadata - * @OneToOne(targetEntity="DDC2759QualificationMetadata", mappedBy="content") */ + #[OneToOne(targetEntity: 'DDC2759QualificationMetadata', mappedBy: 'content')] public $metadata; } -/** - * @Entity - * @Table(name="ddc_2759_category") - */ +#[Table(name: 'ddc_2759_category')] +#[Entity] class DDC2759Category { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC2759MetadataCategory", mappedBy="category") */ + #[OneToMany(targetEntity: 'DDC2759MetadataCategory', mappedBy: 'category')] public $metadataCategories; } -/** - * @Entity - * @Table(name="ddc_2759_qualification_metadata") - */ +#[Table(name: 'ddc_2759_qualification_metadata')] +#[Entity] class DDC2759QualificationMetadata { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC2759MetadataCategory", mappedBy="metadata") */ + #[OneToMany(targetEntity: 'DDC2759MetadataCategory', mappedBy: 'metadata')] protected $metadataCategories; public function __construct( - /** @OneToOne(targetEntity="DDC2759Qualification", inversedBy="metadata") */ + #[OneToOne(targetEntity: 'DDC2759Qualification', inversedBy: 'metadata')] public DDC2759Qualification $content, ) { } } -/** - * @Entity - * @Table(name="ddc_2759_metadata_category") - */ +#[Table(name: 'ddc_2759_metadata_category')] +#[Entity] class DDC2759MetadataCategory { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; public function __construct( - /** @ManyToOne(targetEntity="DDC2759QualificationMetadata", inversedBy="metadataCategories") */ + #[ManyToOne(targetEntity: 'DDC2759QualificationMetadata', inversedBy: 'metadataCategories')] public DDC2759QualificationMetadata $metadata, - /** @ManyToOne(targetEntity="DDC2759Category", inversedBy="metadataCategories") */ + #[ManyToOne(targetEntity: 'DDC2759Category', inversedBy: 'metadataCategories')] public DDC2759Category $category, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php index 572d56d2269..2dc8ca6a8dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php @@ -65,33 +65,31 @@ public function testIssueCascadeRemove(): void } } -/** - * @Entity - * @Table(name="ddc2775_role") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="role_type", type="string") - * @DiscriminatorMap({"admin"="AdminRole"}) - */ +#[Table(name: 'ddc2775_role')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'role_type', type: 'string')] +#[DiscriminatorMap(['admin' => 'AdminRole'])] abstract class Role { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var User - * @ManyToOne(targetEntity="User", inversedBy="roles") */ + #[ManyToOne(targetEntity: 'User', inversedBy: 'roles')] public $user; /** * @psalm-var Collection - * @OneToMany(targetEntity="Authorization", mappedBy="role", cascade={"all"}, orphanRemoval=true) */ + #[OneToMany(targetEntity: 'Authorization', mappedBy: 'role', cascade: ['all'], orphanRemoval: true)] public $authorizations; public function addAuthorization(Authorization $authorization): void @@ -101,65 +99,59 @@ public function addAuthorization(Authorization $authorization): void } } -/** - * @Entity - * @Table(name="ddc2775_admin_role") - */ +#[Table(name: 'ddc2775_admin_role')] +#[Entity] class AdminRole extends Role { } -/** - * @Entity - * @Table(name="ddc2775_authorizations") - */ +#[Table(name: 'ddc2775_authorizations')] +#[Entity] class Authorization { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var User - * @ManyToOne(targetEntity="User", inversedBy="authorizations") */ + #[ManyToOne(targetEntity: 'User', inversedBy: 'authorizations')] public $user; /** * @var Role - * @ManyToOne(targetEntity="Role", inversedBy="authorizations") */ + #[ManyToOne(targetEntity: 'Role', inversedBy: 'authorizations')] public $role; } -/** - * @Entity - * @Table(name="ddc2775_users") - */ +#[Table(name: 'ddc2775_users')] +#[Entity] class User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="Role", mappedBy="user", cascade={"all"}, orphanRemoval=true) */ + #[OneToMany(targetEntity: 'Role', mappedBy: 'user', cascade: ['all'], orphanRemoval: true)] public $roles; /** * @psalm-var Collection - * @OneToMany(targetEntity="Authorization", mappedBy="user", cascade={"all"}, orphanRemoval=true) */ + #[OneToMany(targetEntity: 'Authorization', mappedBy: 'user', cascade: ['all'], orphanRemoval: true)] public $authorizations; public function addRole(Role $role): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php index 2e52037edd6..4cdaa276b4e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php @@ -50,39 +50,39 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC2780User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** - * @ManyToOne(targetEntity="DDC2780Project") * @var DDC2780Project */ + #[ManyToOne(targetEntity: 'DDC2780Project')] public $project; } -/** @Entity */ +#[Entity] class DDC2780Project { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** - * @OneToMany(targetEntity="DDC2780User", mappedBy="project") * @var DDC2780User[] */ + #[OneToMany(targetEntity: 'DDC2780User', mappedBy: 'project')] public $users; /** Constructor */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php index f17170d99b6..1c356711cdd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php @@ -67,79 +67,77 @@ public function testDDC279(): void } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"DDC279EntityX" = "DDC279EntityX"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['DDC279EntityX' => 'DDC279EntityX'])] abstract class DDC279EntityXAbstract { /** * @var int - * @Id - * @GeneratedValue - * @Column(name="id", type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(name: 'id', type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; } -/** @Entity */ +#[Entity] class DDC279EntityX extends DDC279EntityXAbstract { /** * @var DDC279EntityY - * @OneToOne(targetEntity="DDC279EntityY") - * @JoinColumn(name="y_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC279EntityY')] + #[JoinColumn(name: 'y_id', referencedColumnName: 'id')] public $y; } -/** @Entity */ +#[Entity] class DDC279EntityY { /** * @var int - * @Id - * @GeneratedValue - * @Column(name="id", type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(name: 'id', type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; /** * @var DDC279EntityZ - * @OneToOne(targetEntity="DDC279EntityZ") - * @JoinColumn(name="z_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC279EntityZ')] + #[JoinColumn(name: 'z_id', referencedColumnName: 'id')] public $z; } -/** @Entity */ +#[Entity] class DDC279EntityZ { /** * @var int - * @Id - * @GeneratedValue - * @Column(name="id", type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(name: 'id', type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index 902770b35cc..1bb2a180549 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -113,28 +113,24 @@ public function testIssueReopened(): void } } -/** - * @Entity - * @Table(name="ddc2862_drivers") - * @Cache("NONSTRICT_READ_WRITE") - */ +#[Table(name: 'ddc2862_drivers')] +#[Entity] +#[Cache('NONSTRICT_READ_WRITE')] class DDC2862Driver { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected string $name, - /** - * @Cache() - * @OneToOne(targetEntity="DDC2862User") - */ + #[Cache] + #[OneToOne(targetEntity: 'DDC2862User')] protected DDC2862User|null $userProfile = null, ) { } @@ -165,23 +161,21 @@ public function getUserProfile(): DDC2862User } } -/** - * @Entity - * @Table(name="ddc2862_users") - * @Cache("NONSTRICT_READ_WRITE") - */ +#[Table(name: 'ddc2862_users')] +#[Entity] +#[Cache('NONSTRICT_READ_WRITE')] class DDC2862User { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] protected string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index 7c9b13989b6..ffe3c50325b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -50,22 +50,18 @@ public function testPostLoadOneToManyInheritance(): void } } -/** - * @MappedSuperclass - * @HasLifecycleCallbacks - */ +#[MappedSuperclass] +#[HasLifecycleCallbacks] abstract class AbstractDDC2895 { /** - * @Column(name="last_modified", type="datetimetz", nullable=false) * @var DateTime */ + #[Column(name: 'last_modified', type: 'datetimetz', nullable: false)] protected $lastModified; - /** - * @PrePersist - * @PreUpdate - */ + #[PrePersist] + #[PreUpdate] public function setLastModifiedPreUpdate(): void { $this->setLastModified(new DateTime()); @@ -82,18 +78,16 @@ public function getLastModified(): DateTime } } -/** - * @Entity - * @HasLifecycleCallbacks - */ +#[Entity] +#[HasLifecycleCallbacks] class DDC2895 extends AbstractDDC2895 { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; public function setId(mixed $id): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index b5d0ea4071d..3d6cc3178a5 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -84,33 +84,33 @@ public function testFetchJoinedEntitiesCanBeRefreshed(): void } -/** @Entity */ +#[Entity] class DDC2931User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var DDC2931User - * @OneToOne(targetEntity="DDC2931User", inversedBy="child") */ + #[OneToOne(targetEntity: 'DDC2931User', inversedBy: 'child')] public $parent; /** * @var DDC2931User - * @OneToOne(targetEntity="DDC2931User", mappedBy="parent") */ + #[OneToOne(targetEntity: 'DDC2931User', mappedBy: 'parent')] public $child; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $value = 0; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 198d2f46fcc..02298504b63 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -60,21 +60,17 @@ public function testIssue(): void } } -/** - * @Entity - * @Table(name="users") - */ +#[Table(name: 'users')] +#[Entity] class DDC2984User { - /** @Column(type="string", length=50) */ + #[Column(type: 'string', length: 50)] private string|null $name = null; public function __construct( - /** - * @Id - * @Column(type="ddc2984_domain_user_id", length=255) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'ddc2984_domain_user_id', length: 255)] + #[GeneratedValue(strategy: 'NONE')] private DDC2984DomainUserId $userId, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index 417e57190dd..460f063934c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -43,49 +43,47 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC2996User { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $counter = 0; } -/** - * @Entity - * @HasLifecycleCallbacks - */ +#[Entity] +#[HasLifecycleCallbacks] class DDC2996UserPreference { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $value; /** * @var DDC2996User - * @ManyToOne(targetEntity="DDC2996User") */ + #[ManyToOne(targetEntity: 'DDC2996User')] public $user; - /** @PreFlush */ + #[PreFlush] public function preFlush($event): void { $em = $event->getEntityManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index 24045cdfe8e..1197752a43d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Event\PostUpdateEventArgs; @@ -63,11 +64,9 @@ public function testIssue(): void } } -/** - * @Table - * @Entity - * @HasLifecycleCallbacks - */ +#[Table] +#[Entity] +#[HasLifecycleCallbacks] class DDC3033Product { /** @psalm-var array */ @@ -75,27 +74,25 @@ class DDC3033Product /** * @var int $id - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string $title - * @Column(name="title", type="string", length=255) */ + #[Column(name: 'title', type: 'string', length: 255)] public $title; /** * @var Collection - * @ManyToMany(targetEntity="DDC3033User") - * @JoinTable( - * name="user_purchases_3033", - * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'user_purchases_3033')] + #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'user_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'DDC3033User')] public $buyers; /** @@ -106,12 +103,12 @@ public function __construct() $this->buyers = new ArrayCollection(); } - /** @PreUpdate */ + #[PreUpdate] public function preUpdate(PreUpdateEventArgs $eventArgs): void { } - /** @PostUpdate */ + #[PostUpdate] public function postUpdate(PostUpdateEventArgs $eventArgs): void { $em = $eventArgs->getObjectManager(); @@ -124,24 +121,22 @@ public function postUpdate(PostUpdateEventArgs $eventArgs): void } } -/** - * @Table - * @Entity - * @HasLifecycleCallbacks - */ +#[Table] +#[Entity] +#[HasLifecycleCallbacks] class DDC3033User { /** * @var int - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(name="title", type="string", length=255) */ + #[Column(name: 'title', type: 'string', length: 255)] public $name; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php index c9de116adbb..99b7f6dcb70 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php @@ -34,76 +34,76 @@ public function testSQLGenerationDoesNotProvokeAliasCollisions(): void } } -/** @Entity */ +#[Entity] class DDC3042Foo { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $field; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field1; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field2; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field3; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field4; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field5; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field6; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field7; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field8; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field9; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $field10; } -/** @Entity */ +#[Entity] class DDC3042Bar { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $field; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php index 00bc3873b42..8b86b9e8ad1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php @@ -64,26 +64,26 @@ public function testTwoToIterableHydrations(): void } } -/** @Entity */ +#[Entity] class DDC309Country { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class DDC309User { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php index 0bc9e1a5525..cad2088b89a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php @@ -34,12 +34,12 @@ public function testIssue(): void } } -/** @Embeddable */ +#[Embeddable] class DDC3103ArticleId { /** * @var string - * @Column(name="name", type="string", length=255) */ + #[Column(name: 'name', type: 'string', length: 255)] protected $nameValue; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php index c521e9fb557..2c90c63f2e8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php @@ -68,46 +68,42 @@ public function testIssue(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"product" = "DDC3170ProductJoined"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['product' => 'DDC3170ProductJoined'])] abstract class DDC3170AbstractEntityJoined { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class DDC3170ProductJoined extends DDC3170AbstractEntityJoined { } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"product" = "DDC3170ProductSingleTable"}) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['product' => 'DDC3170ProductSingleTable'])] abstract class DDC3170AbstractEntitySingleTable { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class DDC3170ProductSingleTable extends DDC3170AbstractEntitySingleTable { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index 62ad870f4dd..72a2989b673 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -77,49 +77,41 @@ public function testIssue(): void } } -/** - * @Table(name="ddc3192_currency") - * @Entity - */ +#[Table(name: 'ddc3192_currency')] +#[Entity] class DDC3192Currency { /** * @var Collection - * @OneToMany(targetEntity="DDC3192Transaction", mappedBy="currency") */ + #[OneToMany(targetEntity: 'DDC3192Transaction', mappedBy: 'currency')] public $transactions; public function __construct( - /** - * @Id - * @Column(type="ddc3192_currency_code") - */ + #[Id] + #[Column(type: 'ddc3192_currency_code')] public string $code, ) { } } -/** - * @Table(name="ddc3192_transaction") - * @Entity - */ +#[Table(name: 'ddc3192_transaction')] +#[Entity] class DDC3192Transaction { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; public function __construct( - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $amount, - /** - * @ManyToOne(targetEntity="DDC3192Currency", inversedBy="transactions") - * @JoinColumn(name="currency_id", referencedColumnName="code", nullable=false) - */ + #[ManyToOne(targetEntity: 'DDC3192Currency', inversedBy: 'transactions')] + #[JoinColumn(name: 'currency_id', referencedColumnName: 'code', nullable: false)] public DDC3192Currency $currency, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php index 0f800dd1afa..6683352a899 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php @@ -54,58 +54,44 @@ public function testIssueGetId(): void } } -/** - * @Entity - * @Table(name="ddc3223_journalist") - */ +#[Table(name: 'ddc3223_journalist')] +#[Entity] class Journalist extends Participant { } -/** - * @Entity - * @Table(name="ddc3223_participant") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({ - * "journalist" = "Journalist", - * "participant" = "Participant", - * }) - */ +#[Table(name: 'ddc3223_participant')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['journalist' => 'Journalist', 'participant' => 'Participant'])] class Participant { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var ProfileStatus - * @ManyToOne(targetEntity="ProfileStatus") */ + #[ManyToOne(targetEntity: 'ProfileStatus')] public $profileStatus; } -/** - * @Entity - * @Table(name="ddc3223_status") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({ - * "profile" = "ProfileStatus", - * "status" = "Status", - * }) - */ +#[Table(name: 'ddc3223_status')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['profile' => 'ProfileStatus', 'status' => 'Status'])] class Status { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; public function getId(): int @@ -114,7 +100,7 @@ public function getId(): int } } -/** @Entity */ +#[Entity] class ProfileStatus extends Status { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index 1d41cba4dfc..a706eed15a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -51,23 +51,18 @@ public function testResolveTargetEntitiesChangesDiscriminatorMapValues(): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({ - * "boss" = "Doctrine\Tests\ORM\Functional\Ticket\DDC3300Boss", - * "employee" = "Doctrine\Tests\ORM\Functional\Ticket\DDC3300Employee" - * }) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['boss' => 'Doctrine\Tests\ORM\Functional\Ticket\DDC3300Boss', 'employee' => 'Doctrine\Tests\ORM\Functional\Ticket\DDC3300Employee'])] abstract class DDC3300Person { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } @@ -75,11 +70,11 @@ interface DDC3300Boss { } -/** @Entity */ +#[Entity] class DDC3300HumanBoss extends DDC3300Person implements DDC3300Boss { public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $bossCol, ) { } @@ -89,11 +84,11 @@ interface DDC3300Employee { } -/** @Entity */ +#[Entity] class DDC3300HumanEmployee extends DDC3300Person implements DDC3300Employee { public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $employeeCol, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php index 491623ec730..1c345e18956 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -46,46 +46,42 @@ public function testEmbeddedObjectsAreAlsoInherited(): void } } -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class DDC3303Person { public function __construct( - /** - * @Id - * @GeneratedValue(strategy="NONE") - * @Column(type="string", length=255) - */ + #[Id] + #[GeneratedValue(strategy: 'NONE')] + #[Column(type: 'string', length: 255)] private string $name, - /** @Embedded(class="DDC3303Address") */ + #[Embedded(class: 'DDC3303Address')] private DDC3303Address $address, ) { } } -/** @Embeddable */ +#[Embeddable] class DDC3303Address { public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $street, - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int $number, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $city, ) { } } -/** - * @Entity - * @Table(name="ddc3303_employee") - */ +#[Table(name: 'ddc3303_employee')] +#[Entity] class DDC3303Employee extends DDC3303Person { public function __construct( string $name, DDC3303Address $address, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $company, ) { parent::__construct($name, $address); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php index 7346ada62a9..36928e473ff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php @@ -73,24 +73,22 @@ private function createBuildingAndHalls(): void } } -/** - * @Entity - * @Table(name="ddc3330_building") - */ +#[Table(name: 'ddc3330_building')] +#[Entity] class DDC3330Building { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3330Hall", mappedBy="building", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'DDC3330Hall', mappedBy: 'building', cascade: ['persist'])] public $halls; public function addHall(DDC3330Hall $hall): void @@ -100,29 +98,27 @@ public function addHall(DDC3330Hall $hall): void } } -/** - * @Entity - * @Table(name="ddc3330_hall") - */ +#[Table(name: 'ddc3330_hall')] +#[Entity] class DDC3330Hall { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var DDC3330Building - * @ManyToOne(targetEntity="DDC3330Building", inversedBy="halls") */ + #[ManyToOne(targetEntity: 'DDC3330Building', inversedBy: 'halls')] public $building; /** * @var string - * @Column(type="string", length=100) */ + #[Column(type: 'string', length: 100)] public $name; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php index 6bca5557925..7ead3e2ed1b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -69,27 +69,27 @@ public function testTwoIterateHydrations(): void } } -/** @Entity */ +#[Entity] class DDC345User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC345Membership", mappedBy="user", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'DDC345Membership', mappedBy: 'user', cascade: ['persist'])] public $memberships; public function __construct() @@ -98,27 +98,27 @@ public function __construct() } } -/** @Entity */ +#[Entity] class DDC345Group { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC345Membership", mappedBy="group", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'DDC345Membership', mappedBy: 'group', cascade: ['persist'])] public $memberships; public function __construct() @@ -127,47 +127,44 @@ public function __construct() } } -/** - * @Entity - * @HasLifecycleCallbacks - * @Table(name="ddc345_memberships", uniqueConstraints={ - * @UniqueConstraint(name="ddc345_memship_fks", columns={"user_id","group_id"}) - * }) - */ +#[Table(name: 'ddc345_memberships')] +#[UniqueConstraint(name: 'ddc345_memship_fks', columns: ['user_id', 'group_id'])] +#[Entity] +#[HasLifecycleCallbacks] class DDC345Membership { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC345User - * @OneToOne(targetEntity="DDC345User", inversedBy="memberships") - * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) */ + #[OneToOne(targetEntity: 'DDC345User', inversedBy: 'memberships')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)] public $user; /** * @var DDC345Group - * @OneToOne(targetEntity="DDC345Group", inversedBy="memberships") - * @JoinColumn(name="group_id", referencedColumnName="id", nullable=false) */ + #[OneToOne(targetEntity: 'DDC345Group', inversedBy: 'memberships')] + #[JoinColumn(name: 'group_id', referencedColumnName: 'id', nullable: false)] public $group; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $state; /** * @var DateTime - * @Column(type="datetime") */ + #[Column(type: 'datetime')] public $updated; /** @var int */ @@ -176,7 +173,7 @@ class DDC345Membership /** @var int */ public $preUpdateCallCount = 0; - /** @PrePersist */ + #[PrePersist] public function doStuffOnPrePersist(): void { //echo "***** PrePersist\n"; @@ -184,7 +181,7 @@ public function doStuffOnPrePersist(): void $this->updated = new DateTime(); } - /** @PreUpdate */ + #[PreUpdate] public function doStuffOnPreUpdate(): void { //echo "***** PreUpdate\n"; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index a6b1a879731..a573b6699dc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -72,22 +72,16 @@ public function testFailingCase(): void } } -/** @Entity */ +#[Entity] class DDC353Picture { - /** - * @Column(name="picture_id", type="integer") - * @Id - * @GeneratedValue - */ + #[Column(name: 'picture_id', type: 'integer')] + #[Id] + #[GeneratedValue] private int $pictureId; - /** - * @ManyToOne(targetEntity="DDC353File", cascade={"persist", "remove"}) - * @JoinColumns({ - * @JoinColumn(name="file_id", referencedColumnName="file_id") - * }) - */ + #[JoinColumn(name: 'file_id', referencedColumnName: 'file_id')] + #[ManyToOne(targetEntity: 'DDC353File', cascade: ['persist', 'remove'])] private DDC353File|null $file = null; public function getPictureId(): int @@ -106,15 +100,15 @@ public function getFile(): DDC353File } } -/** @Entity */ +#[Entity] class DDC353File { /** * @var int - * @Column(name="file_id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(name: 'file_id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $fileId; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php index 7a52d0602a6..09f552a54a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php @@ -31,33 +31,31 @@ public function testNestedEmbeddablesAreHydratedWithProperClass(): void } } -/** @Entity */ +#[Entity] class DDC3582Entity { /** * @var DDC3582Embeddable1 - * @Embedded(class="DDC3582Embeddable1") */ + #[Embedded(class: 'DDC3582Embeddable1')] public $embeddable1; public function __construct( - /** - * @Column - * @Id - */ + #[Column] + #[Id] private string $id, ) { $this->embeddable1 = new DDC3582Embeddable1(); } } -/** @Embeddable */ +#[Embeddable] class DDC3582Embeddable1 { /** * @var DDC3582Embeddable2 - * @Embedded(class="DDC3582Embeddable2") */ + #[Embedded(class: 'DDC3582Embeddable2')] public $embeddable2; public function __construct() @@ -66,13 +64,13 @@ public function __construct() } } -/** @Embeddable */ +#[Embeddable] class DDC3582Embeddable2 { /** * @var DDC3582Embeddable3 - * @Embedded(class="DDC3582Embeddable3") */ + #[Embedded(class: 'DDC3582Embeddable3')] public $embeddable3; public function __construct() @@ -81,12 +79,12 @@ public function __construct() } } -/** @Embeddable */ +#[Embeddable] class DDC3582Embeddable3 { /** * @var string - * @Column */ + #[Column] public $embeddedValue = 'foo'; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index a0feed423de..e63ab3ee6bb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -85,38 +85,33 @@ public function testSavesIntegerAutoGeneratedValueAsStringWithJoinedInheritance( } } -/** @Entity */ +#[Entity] class DDC3634Entity { /** * @var int - * @Id - * @Column(type="bigint") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'bigint')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({ - * DDC3634JTIBaseEntity::class = DDC3634JTIBaseEntity::class, - * DDC3634JTIChildEntity::class = DDC3634JTIChildEntity::class, - * }) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorMap([DDC3634JTIBaseEntity::class => DDC3634JTIBaseEntity::class, DDC3634JTIChildEntity::class => DDC3634JTIChildEntity::class])] class DDC3634JTIBaseEntity { /** * @var int - * @Id - * @Column(type="bigint") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'bigint')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } -/** @Entity */ +#[Entity] class DDC3634JTIChildEntity extends DDC3634JTIBaseEntity { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php index a489027d894..08183b6ef2d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php @@ -136,33 +136,33 @@ public function testIssueWithJoinedEntity(): void } } -/** @Entity */ +#[Entity] class DDC3644User { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer", name="hash_id") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer', name: 'hash_id')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3644Address", mappedBy="user", orphanRemoval=true) */ + #[OneToMany(targetEntity: 'DDC3644Address', mappedBy: 'user', orphanRemoval: true)] public $addresses = []; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3644Pet", mappedBy="owner", orphanRemoval=true) */ + #[OneToMany(targetEntity: 'DDC3644Pet', mappedBy: 'owner', orphanRemoval: true)] public $pets = []; public function setAddresses(Collection $addresses): void @@ -184,61 +184,59 @@ public function setPets(Collection $pets): void } } -/** @Entity */ +#[Entity] class DDC3644Address { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var DDC3644User - * @ManyToOne(targetEntity="DDC3644User", inversedBy="addresses") - * @JoinColumn(referencedColumnName="hash_id") */ + #[ManyToOne(targetEntity: 'DDC3644User', inversedBy: 'addresses')] + #[JoinColumn(referencedColumnName: 'hash_id')] public $user; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $address, ) { } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discriminator", type="string") - * @DiscriminatorMap({"pet" = "DDC3644Pet"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discriminator', type: 'string')] +#[DiscriminatorMap(['pet' => 'DDC3644Pet'])] abstract class DDC3644Animal { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } } -/** @Entity */ +#[Entity] class DDC3644Pet extends DDC3644Animal { /** * @var DDC3644User - * @ManyToOne(targetEntity="DDC3644User", inversedBy="pets") - * @JoinColumn(referencedColumnName="hash_id") */ + #[ManyToOne(targetEntity: 'DDC3644User', inversedBy: 'pets')] + #[JoinColumn(referencedColumnName: 'hash_id')] public $owner; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index 10de88acd9f..e2a80448e6e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -57,46 +57,42 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC371Child { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; /** * @var DDC371Parent - * @ManyToOne(targetEntity="DDC371Parent", inversedBy="children") - * @JoinColumn(name="parentId") */ + #[ManyToOne(targetEntity: 'DDC371Parent', inversedBy: 'children')] + #[JoinColumn(name: 'parentId')] public $parent; } -/** @Entity */ +#[Entity] class DDC371Parent { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC371Child", mappedBy="parent") */ + #[OneToMany(targetEntity: 'DDC371Child', mappedBy: 'parent')] public $children; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php index 209de09dfd9..1d952b2ded5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -61,29 +62,24 @@ public function testOwningValueObjectIdIsCorrectlyTransformedWhenRemovingOrphane } } -/** - * @Entity - * @Table(name="asset") - */ +#[Table(name: 'asset')] +#[Entity] class DDC3785Asset { /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC3785Attribute", cascade={"persist"}, orphanRemoval=true) - * @JoinTable(name="asset_attributes", - * joinColumns={@JoinColumn(name="asset_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="attribute_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'asset_attributes')] + #[JoinColumn(name: 'asset_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'attribute_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'DDC3785Attribute', cascade: ['persist'], orphanRemoval: true)] private $attributes; /** @psalm-param list $attributes */ public function __construct( - /** - * @Id - * @GeneratedValue(strategy="NONE") - * @Column(type="ddc3785_asset_id") - */ + #[Id] + #[GeneratedValue(strategy: 'NONE')] + #[Column(type: 'ddc3785_asset_id')] private DDC3785AssetId $id, $attributes = [], ) { @@ -106,34 +102,32 @@ public function getAttributes() } } -/** - * @Entity - * @Table(name="attribute") - */ +#[Table(name: 'attribute')] +#[Entity] class DDC3785Attribute { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $value, ) { } } -/** @Embeddable */ +#[Embeddable] class DDC3785AssetId implements Stringable { public function __construct( - /** @Column(type = "guid") */ + #[Column(type: 'guid')] private string $id, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php index 1025f1e0e22..2728e482f49 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php @@ -43,15 +43,15 @@ public function testCallUnserializedProxyMethods(): void } } -/** @Entity */ +#[Entity] class DDC381Entity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index fedfb56dd22..2dee15df5bd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -54,34 +55,31 @@ public function testIssue(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"guest" = "DDC422Guest", "customer" = "DDC422Customer"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['guest' => 'DDC422Guest', 'customer' => 'DDC422Customer'])] class DDC422Guest { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class DDC422Customer extends DDC422Guest { /** * @var Collection - * @ManyToMany(targetEntity="DDC422Contact", cascade={"persist","remove"}) - * @JoinTable(name="ddc422_customers_contacts", - * joinColumns={@JoinColumn(name="customer_id", referencedColumnName="id", onDelete="cascade" )}, - * inverseJoinColumns={@JoinColumn(name="contact_id", referencedColumnName="id", onDelete="cascade" )} - * ) */ + #[JoinTable(name: 'ddc422_customers_contacts')] + #[JoinColumn(name: 'customer_id', referencedColumnName: 'id', onDelete: 'cascade')] + #[InverseJoinColumn(name: 'contact_id', referencedColumnName: 'id', onDelete: 'cascade')] + #[ManyToMany(targetEntity: 'DDC422Contact', cascade: ['persist', 'remove'])] public $contacts; public function __construct() @@ -90,14 +88,14 @@ public function __construct() } } -/** @Entity */ +#[Entity] class DDC422Contact { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php index b6324c0ff0b..d206481afd2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php @@ -30,20 +30,20 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC425Entity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DateTime - * @Column(type="datetime") */ + #[Column(type: 'datetime')] public $someDatetimeField; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php index 8e7b487e897..0b2199a46d5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -80,33 +80,29 @@ public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations(): } } -/** - * @Entity - * @Table(name="phone") - */ +#[Table(name: 'phone')] +#[Entity] class DDC440Phone { /** * @var int - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var DDC440Client - * @ManyToOne(targetEntity="DDC440Client",inversedBy="phones") - * @JoinColumns({ - * @JoinColumn(name="client_id", referencedColumnName="id") - * }) */ + #[JoinColumn(name: 'client_id', referencedColumnName: 'id')] + #[ManyToOne(targetEntity: 'DDC440Client', inversedBy: 'phones')] protected $client; /** * @var string - * @Column(name="phonenumber", type="string", length=255) */ + #[Column(name: 'phonenumber', type: 'string', length: 255)] protected $number; public function setNumber(string $value): void @@ -143,40 +139,36 @@ public function setId(int $value): void } } -/** - * @Entity - * @Table(name="client") - */ +#[Table(name: 'client')] +#[Entity] class DDC440Client { /** * @var int - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] protected $id; /** * @var DDC440Phone - * @OneToOne(targetEntity="DDC440Phone", fetch="EAGER") - * @JoinColumns({ - * @JoinColumn(name="main_phone_id", referencedColumnName="id",onDelete="SET NULL") - * }) */ + #[JoinColumn(name: 'main_phone_id', referencedColumnName: 'id', onDelete: 'SET NULL')] + #[OneToOne(targetEntity: 'DDC440Phone', fetch: 'EAGER')] protected $mainPhone; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER", indexBy="id") - * @OrderBy({"number"="ASC"}) */ + #[OneToMany(targetEntity: 'DDC440Phone', mappedBy: 'client', cascade: ['persist', 'remove'], fetch: 'EAGER', indexBy: 'id')] + #[OrderBy(['number' => 'ASC'])] protected $phones; /** * @var string - * @Column(name="name", type="string", length=255) */ + #[Column(name: 'name', type: 'string', length: 255)] protected $name; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php index ff263faccd7..ee07c7d4752 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php @@ -62,24 +62,22 @@ public function testExplicitPolicy(): void } -/** - * @Entity - * @Table(name="ddc444") - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ +#[Table(name: 'ddc444')] +#[Entity] +#[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class DDC444User { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(name="name", type="string", length=255) */ + #[Column(name: 'name', type: 'string', length: 255)] public $name; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php index 0675a92bd72..57250117ec3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -41,51 +41,38 @@ public function testIssue(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="smallint") - * @DiscriminatorMap({ - * "0" = "DDC448MainTable", - * "1" = "DDC448SubTable" - * }) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'smallint')] +#[DiscriminatorMap(['0' => 'DDC448MainTable', '1' => 'DDC448SubTable'])] class DDC448MainTable { - /** - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @ManyToOne(targetEntity="DDC448ConnectedClass", cascade={"all"}, fetch="EAGER") - * @JoinColumn(name="connectedClassId", referencedColumnName="id", onDelete="CASCADE", nullable=true) - */ + #[ManyToOne(targetEntity: 'DDC448ConnectedClass', cascade: ['all'], fetch: 'EAGER')] + #[JoinColumn(name: 'connectedClassId', referencedColumnName: 'id', onDelete: 'CASCADE', nullable: true)] private DDC448ConnectedClass $connectedClassId; } -/** - * @Entity - * @Table(name="connectedClass") - * @HasLifecycleCallbacks - */ +#[Table(name: 'connectedClass')] +#[Entity] +#[HasLifecycleCallbacks] class DDC448ConnectedClass { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $id; // connected with DDC448MainTable } -/** - * @Entity - * @Table(name="SubTable") - */ +#[Table(name: 'SubTable')] +#[Entity] class DDC448SubTable extends DDC448MainTable { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php index 061821a2580..cd0418a66f6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php @@ -39,47 +39,45 @@ public function testIssue(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"distributor" = "DDC493Distributor", "customer" = "DDC493Customer"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['distributor' => 'DDC493Distributor', 'customer' => 'DDC493Customer'])] class DDC493Customer { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var DDC493Contact - * @OneToOne(targetEntity="DDC493Contact", cascade={"remove","persist"}) - * @JoinColumn(name="contact", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC493Contact', cascade: ['remove', 'persist'])] + #[JoinColumn(name: 'contact', referencedColumnName: 'id')] public $contact; } -/** @Entity */ +#[Entity] class DDC493Distributor extends DDC493Customer { } -/** @Entity */ +#[Entity] class DDC493Contact { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php index 008f5794d75..c335c82fec3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php @@ -57,15 +57,15 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC512Customer { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** @@ -73,30 +73,28 @@ class DDC512Customer * (item = item), this currently confuses Doctrine. * * @var DDC512OfferItem - * @OneToOne(targetEntity="DDC512OfferItem", cascade={"remove","persist"}) - * @JoinColumn(name="item_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC512OfferItem', cascade: ['remove', 'persist'])] + #[JoinColumn(name: 'item_id', referencedColumnName: 'id')] public $item; } -/** @Entity */ +#[Entity] class DDC512OfferItem extends DDC512Item { } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"item" = "DDC512Item", "offerItem" = "DDC512OfferItem"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['item' => 'DDC512Item', 'offerItem' => 'DDC512OfferItem'])] class DDC512Item { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php index e78a0a942c2..af9ace41051 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php @@ -39,49 +39,47 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC513OfferItem extends DDC513Item { } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"item" = "DDC513Item", "offerItem" = "DDC513OfferItem"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['item' => 'DDC513Item', 'offerItem' => 'DDC513OfferItem'])] class DDC513Item { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var DDC513Price - * @OneToOne(targetEntity="DDC513Price", cascade={"remove","persist"}) - * @JoinColumn(name="price", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC513Price', cascade: ['remove', 'persist'])] + #[JoinColumn(name: 'price', referencedColumnName: 'id')] public $price; } -/** @Entity */ +#[Entity] class DDC513Price { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $data; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index 2ba70408ae3..b209a3279df 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -87,76 +87,76 @@ public function testJoinColumnWithNullSameNameAssociationField(): void } } -/** @Entity */ +#[Entity] class DDC522Customer { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var mixed - * @Column */ + #[Column] public $name; /** * @var DDC522Cart - * @OneToOne(targetEntity="DDC522Cart", mappedBy="customer") */ + #[OneToOne(targetEntity: 'DDC522Cart', mappedBy: 'customer')] public $cart; } -/** @Entity */ +#[Entity] class DDC522Cart { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $total; /** * @var DDC522Customer - * @OneToOne(targetEntity="DDC522Customer", inversedBy="cart") - * @JoinColumn(name="customer", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC522Customer', inversedBy: 'cart')] + #[JoinColumn(name: 'customer', referencedColumnName: 'id')] public $customer; } -/** @Entity */ +#[Entity] class DDC522ForeignKeyTest { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var int|null - * @Column(type="integer", name="cart_id", nullable=true) */ + #[Column(type: 'integer', name: 'cart_id', nullable: true)] public $cartId; /** * @var DDC522Cart|null - * @OneToOne(targetEntity="DDC522Cart") - * @JoinColumn(name="cart_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'DDC522Cart')] + #[JoinColumn(name: 'cart_id', referencedColumnName: 'id')] public $cart; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php index c84a97bdaa7..a0c2daa88a7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php @@ -53,33 +53,31 @@ public function testIssue(): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="integer") - * @DiscriminatorMap({"0" = "DDC531Item", "1" = "DDC531SubItem"}) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'type', type: 'integer')] +#[DiscriminatorMap(['0' => 'DDC531Item', '1' => 'DDC531SubItem'])] class DDC531Item { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC531Item", mappedBy="parent") */ + #[OneToMany(targetEntity: 'DDC531Item', mappedBy: 'parent')] protected $children; /** * @var DDC531Item - * @ManyToOne(targetEntity="DDC531Item", inversedBy="children") - * @JoinColumn(name="parentId", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'DDC531Item', inversedBy: 'children')] + #[JoinColumn(name: 'parentId', referencedColumnName: 'id')] public $parent; public function __construct() @@ -99,7 +97,7 @@ public function getChildren(): Collection } } -/** @Entity */ +#[Entity] class DDC531SubItem extends DDC531Item { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index 457768f8cec..344b114a0ee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -101,17 +101,15 @@ public function __toString(): string } } -/** - * @Entity - * @Table(name="ticket_5684_objects") - */ +#[Table(name: 'ticket_5684_objects')] +#[Entity] class DDC5684Object { /** * @var DDC5684ObjectIdType - * @Id - * @Column(type=DDC5684ObjectIdType::class) - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: DDC5684ObjectIdType::class)] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php index 00da592737e..0e3390bca3e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -32,19 +32,19 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC588Site { /** * @var int - * @Id - * @Column(type="integer", name="site_id") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer', name: 'site_id')] + #[GeneratedValue] public $id; public function __construct( - /** @Column(type="string", length=45) */ + #[Column(type: 'string', length: 45)] protected string $name = '', ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php index 0894c2d3158..2a5f3b05bff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -82,26 +82,24 @@ public function testCascadeRemoveOnChildren(): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="integer") - * @DiscriminatorMap({"0" = "DDC599Item", "1" = "DDC599Subitem"}) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'type', type: 'integer')] +#[DiscriminatorMap(['0' => 'DDC599Item', '1' => 'DDC599Subitem'])] class DDC599Item { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC599Child", mappedBy="parent", cascade={"remove"}) */ + #[OneToMany(targetEntity: 'DDC599Child', mappedBy: 'parent', cascade: ['remove'])] protected $children; public function __construct() @@ -116,31 +114,31 @@ public function getChildren(): Collection } } -/** @Entity */ +#[Entity] class DDC599Subitem extends DDC599Item { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $elem; } -/** @Entity */ +#[Entity] class DDC599Child { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var DDC599Item - * @ManyToOne(targetEntity="DDC599Item", inversedBy="children") - * @JoinColumn(name="parentId", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'DDC599Item', inversedBy: 'children')] + #[JoinColumn(name: 'parentId', referencedColumnName: 'id')] public $parent; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index 6e95b974c31..d3f54b796c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -127,26 +127,26 @@ public function testCombineIndexBy(): void } } -/** @Entity */ +#[Entity] class DDC618Author { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC618Book", mappedBy="author", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'DDC618Book', mappedBy: 'author', cascade: ['persist'])] public $books; public function __construct() @@ -161,21 +161,21 @@ public function addBook(string $title): void } } -/** @Entity */ +#[Entity] class DDC618Book { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $title, - /** @ManyToOne(targetEntity="DDC618Author", inversedBy="books") */ + #[ManyToOne(targetEntity: 'DDC618Author', inversedBy: 'books')] public DDC618Author $author, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php index ca231826825..967dc24eb18 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php @@ -86,53 +86,46 @@ private function assertHydratedEntitiesSameToPersistedOnes(array $persistedEntit } /** - * @Entity - * @Table - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({ - * DDC6303ChildB::class = DDC6303ChildB::class, - * DDC6303ChildA::class = DDC6303ChildA::class, - * }) * * Note: discriminator map order *IS IMPORTANT* for this test */ +#[Table] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap([DDC6303ChildB::class => DDC6303ChildB::class, DDC6303ChildA::class => DDC6303ChildA::class])] abstract class DDC6303BaseClass { /** * @var string - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] public $id; } -/** - * @Entity - * @Table - */ +#[Table] +#[Entity] class DDC6303ChildA extends DDC6303BaseClass { public function __construct( string $id, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private mixed $originalData, ) { $this->id = $id; } } -/** - * @Entity - * @Table - */ +#[Table] +#[Entity] class DDC6303ChildB extends DDC6303BaseClass { /** @param mixed[] $originalData */ public function __construct( string $id, - /** @Column(type="simple_array", nullable=true) */ + #[Column(type: 'simple_array', nullable: true)] private array $originalData, ) { $this->id = $id; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php index 8184eff7e59..ea1e655bf42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php @@ -75,38 +75,38 @@ public function testDQLDeferredEagerLoad(): void } } -/** @Entity */ +#[Entity] class DDC633Appointment { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC633Patient - * @OneToOne(targetEntity="DDC633Patient", inversedBy="appointment", fetch="EAGER") */ + #[OneToOne(targetEntity: 'DDC633Patient', inversedBy: 'appointment', fetch: 'EAGER')] public $patient; } -/** @Entity */ +#[Entity] class DDC633Patient { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var DDC633Appointment - * @OneToOne(targetEntity="DDC633Appointment", mappedBy="patient") */ + #[OneToOne(targetEntity: 'DDC633Appointment', mappedBy: 'patient')] public $appointment; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php index 31fe6efe5dc..bc0c003febf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php @@ -69,48 +69,48 @@ public function testInlineEmbeddableProxyInitialization(): void } } -/** @Embeddable() */ +#[Embeddable] class DDC6460Embeddable { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $field; } -/** @Entity() */ +#[Entity] class DDC6460Entity { /** * @var int - * @Id - * @GeneratedValue(strategy = "NONE") - * @Column(type = "integer") */ + #[Id] + #[GeneratedValue(strategy: 'NONE')] + #[Column(type: 'integer')] public $id; /** * @var DDC6460Embeddable - * @Embedded(class = "DDC6460Embeddable") */ + #[Embedded(class: 'DDC6460Embeddable')] public $embedded; } -/** @Entity() */ +#[Entity] class DDC6460ParentEntity { /** * @var int - * @Id - * @GeneratedValue(strategy = "NONE") - * @Column(type = "integer") */ + #[Id] + #[GeneratedValue(strategy: 'NONE')] + #[Column(type: 'integer')] public $id; /** * @var DDC6460Entity - * @ManyToOne(targetEntity="DDC6460Entity", fetch="EXTRA_LAZY", cascade={"persist"}) */ + #[ManyToOne(targetEntity: 'DDC6460Entity', fetch: 'EXTRA_LAZY', cascade: ['persist'])] public $lazyLoaded; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index 3804149d77a..04a116f1867 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -44,27 +44,27 @@ public function testRecomputeSingleEntityChangeSetPreservesFieldOrder(): void } } -/** @Entity */ +#[Entity] class DDC656Entity { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $type; /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $specificationId; public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php index 62c84572de6..18e9f6819a3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -41,69 +42,64 @@ public function testTicket(): void } } -/** - * @Table(name="Roles") - * @Entity - */ +#[Table(name: 'Roles')] +#[Entity] class DDC698Role { /** * @var int - * @Id - * @Column(name="roleID", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'roleID', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $roleID; /** * @var string - * @Column(name="name", type="string", length=45) */ + #[Column(name: 'name', type: 'string', length: 45)] protected $name; /** * @var string - * @Column(name="shortName", type="string", length=45) */ + #[Column(name: 'shortName', type: 'string', length: 45)] protected $shortName; /** * @var Collection - * @ManyToMany(targetEntity="DDC698Privilege", inversedBy="roles") - * @JoinTable(name="RolePrivileges", - * joinColumns={@JoinColumn(name="roleID", referencedColumnName="roleID")}, - * inverseJoinColumns={@JoinColumn(name="privilegeID", referencedColumnName="privilegeID")} - * ) */ + #[JoinTable(name: 'RolePrivileges')] + #[JoinColumn(name: 'roleID', referencedColumnName: 'roleID')] + #[InverseJoinColumn(name: 'privilegeID', referencedColumnName: 'privilegeID')] + #[ManyToMany(targetEntity: 'DDC698Privilege', inversedBy: 'roles')] protected $privilege; } -/** - * @Table(name="Privileges") - * @Entity() - */ +#[Table(name: 'Privileges')] +#[Entity] class DDC698Privilege { /** * @var int - * @Id - * @Column(name="privilegeID", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'privilegeID', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] protected $privilegeID; /** * @var string - * @Column(name="name", type="string", length=45) */ + #[Column(name: 'name', type: 'string', length: 45)] protected $name; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC698Role", mappedBy="privilege") */ + #[ManyToMany(targetEntity: 'DDC698Role', mappedBy: 'privilege')] protected $roles; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php index 415a80fe80a..efc9fb43c17 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php @@ -105,28 +105,24 @@ public function testIssue(): void } } -/** - * @Entity - * @Table(name="lemma") - */ +#[Table(name: 'lemma')] +#[Entity] class Lemma { public const CLASS_NAME = self::class; - /** - * @Id - * @Column(type="integer", name="lemma_id") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer', name: 'lemma_id')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", name="lemma_name", unique=true, length=255) */ + #[Column(type: 'string', name: 'lemma_name', unique: true, length: 255)] private string|null $lemma = null; /** * @var Collection - * @OneToMany(targetEntity="Relation", mappedBy="parent", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'Relation', mappedBy: 'parent', cascade: ['persist'])] private Collection $relations; public function __construct() @@ -171,37 +167,27 @@ public function getRelations(): Collection } } -/** - * @Entity - * @Table(name="relation") - */ +#[Table(name: 'relation')] +#[Entity] class Relation { public const CLASS_NAME = self::class; - /** - * @Id - * @Column(type="integer", name="relation_id") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer', name: 'relation_id')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @ManyToOne(targetEntity="Lemma", inversedBy="relations") - * @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id") - */ + #[ManyToOne(targetEntity: 'Lemma', inversedBy: 'relations')] + #[JoinColumn(name: 'relation_parent_id', referencedColumnName: 'lemma_id')] private Lemma|null $parent = null; - /** - * @OneToOne(targetEntity="Lemma") - * @JoinColumn(name="relation_child_id", referencedColumnName="lemma_id") - */ + #[OneToOne(targetEntity: 'Lemma')] + #[JoinColumn(name: 'relation_child_id', referencedColumnName: 'lemma_id')] private Lemma|null $child = null; - /** - * @ManyToOne(targetEntity="RelationType", inversedBy="relations") - * @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id") - */ + #[ManyToOne(targetEntity: 'RelationType', inversedBy: 'relations')] + #[JoinColumn(name: 'relation_type_id', referencedColumnName: 'relation_type_id')] private RelationType|null $type = null; public function setParent(Lemma $parent): void @@ -253,31 +239,27 @@ public function removeType(): void } } -/** - * @Entity - * @Table(name="relation_type") - */ +#[Table(name: 'relation_type')] +#[Entity] class RelationType { public const CLASS_NAME = self::class; - /** - * @Id - * @Column(type="integer", name="relation_type_id") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer', name: 'relation_type_id')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", name="relation_type_name", unique=true, length=255) */ + #[Column(type: 'string', name: 'relation_type_name', unique: true, length: 255)] private string|null $type = null; - /** @Column(type="string", name="relation_type_abbreviation", unique=true, length=255) */ + #[Column(type: 'string', name: 'relation_type_abbreviation', unique: true, length: 255)] private string|null $abbreviation = null; /** * @var Collection - * @OneToMany(targetEntity="Relation", mappedBy="type", cascade={"persist"}) */ + #[OneToMany(targetEntity: 'Relation', mappedBy: 'type', cascade: ['persist'])] private $relations; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php index 13c7601fd0e..dffa134b9eb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -40,15 +41,15 @@ public function testIsEmptySqlGeneration(): void } } -/** @MappedSuperclass */ +#[MappedSuperclass] class MyEntity { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] protected $id; public function getId(): int @@ -57,38 +58,35 @@ public function getId(): int } } -/** - * @Entity - * @Table(name="groups") - */ +#[Table(name: 'groups')] +#[Entity] class DDC719Group extends MyEntity { /** * @var string - * @Column(type="string", nullable=false) */ + #[Column(type: 'string', nullable: false)] protected $name; /** * @var string - * @Column(type="string", nullable=true) */ + #[Column(type: 'string', nullable: true)] protected $description; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC719Group", inversedBy="parents") - * @JoinTable(name="groups_groups", - * joinColumns={@JoinColumn(name="parent_id", referencedColumnName="id")}, - * inverseJoinColumns={@JoinColumn(name="child_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'groups_groups')] + #[JoinColumn(name: 'parent_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'child_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'DDC719Group', inversedBy: 'parents')] protected $children = null; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC719Group", mappedBy="children") */ + #[ManyToMany(targetEntity: 'DDC719Group', mappedBy: 'children')] protected $parents = null; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php index 9e319510e13..7f599075d07 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -54,26 +54,21 @@ public function testRemoveElementAppliesOrphanRemoval(): void } } -/** @Entity */ +#[Entity] class DDC735Product { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; /** * @psalm-var Collection - * @OneToMany( - * targetEntity="DDC735Review", - * mappedBy="product", - * cascade={"persist"}, - * orphanRemoval=true - * ) */ + #[OneToMany(targetEntity: 'DDC735Review', mappedBy: 'product', cascade: ['persist'], orphanRemoval: true)] protected $reviews; public function __construct() @@ -98,19 +93,19 @@ public function removeReview(DDC735Review $review): void } } -/** @Entity */ +#[Entity] class DDC735Review { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; public function __construct( - /** @ManyToOne(targetEntity="DDC735Product", inversedBy="reviews") */ + #[ManyToOne(targetEntity: 'DDC735Product', inversedBy: 'reviews')] protected DDC735Product $product, ) { $product->addReview($this); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php index f51acb7ddae..adb7384602b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -61,31 +62,24 @@ public function testIssue(): void } } -/** - * @Table(name="variant_test") - * @Entity - */ +#[Table(name: 'variant_test')] +#[Entity] class DDC809Variant { /** * @var int - * @Column(name="variant_id", type="integer") - * @Id */ + #[Column(name: 'variant_id', type: 'integer')] + #[Id] protected $variantId; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC809SpecificationValue", inversedBy="Variants") - * @JoinTable(name="var_spec_value_test", - * joinColumns={ - * @JoinColumn(name="variant_id", referencedColumnName="variant_id") - * }, - * inverseJoinColumns={ - * @JoinColumn(name="specification_value_id", referencedColumnName="specification_value_id") - * } - * ) */ + #[JoinTable(name: 'var_spec_value_test')] + #[JoinColumn(name: 'variant_id', referencedColumnName: 'variant_id')] + #[InverseJoinColumn(name: 'specification_value_id', referencedColumnName: 'specification_value_id')] + #[ManyToMany(targetEntity: 'DDC809SpecificationValue', inversedBy: 'Variants')] protected $specificationValues; /** @psalm-return Collection */ @@ -95,22 +89,20 @@ public function getSpecificationValues(): Collection } } -/** - * @Table(name="specification_value_test") - * @Entity - */ +#[Table(name: 'specification_value_test')] +#[Entity] class DDC809SpecificationValue { /** * @var int - * @Column(name="specification_value_id", type="integer") - * @Id */ + #[Column(name: 'specification_value_id', type: 'integer')] + #[Id] protected $specificationValueId; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC809Variant", mappedBy="SpecificationValues") */ + #[ManyToMany(targetEntity: 'DDC809Variant', mappedBy: 'SpecificationValues')] protected $variants; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index 26cc5d7f1ab..ddc6b78a736 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -140,76 +140,70 @@ public function testQuotedTableJoinedChildRemove(): void } } -/** - * @Entity - * @Table(name="`LIKE`") - */ +#[Table(name: '`LIKE`')] +#[Entity] class DDC832Like { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var int - * @Version - * @Column(type="integer") */ + #[Version] + #[Column(type: 'integer')] public $version; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $word, ) { } } -/** - * @Entity - * @Table(name="`INDEX`") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"like" = "DDC832JoinedIndex", "fuzzy" = "DDC832JoinedTreeIndex"}) - */ +#[Table(name: '`INDEX`')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['like' => 'DDC832JoinedIndex', 'fuzzy' => 'DDC832JoinedTreeIndex'])] class DDC832JoinedIndex { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var int - * @Version - * @Column(type="integer") */ + #[Version] + #[Column(type: 'integer')] public $version; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } } -/** - * @Entity - * @Table(name="`TREE_INDEX`") - */ +#[Table(name: '`TREE_INDEX`')] +#[Entity] class DDC832JoinedTreeIndex extends DDC832JoinedIndex { public function __construct( string $name, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $lft, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $rgt, ) { $this->name = $name; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index d2674f9cf27..44dbd2efbf8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -97,107 +97,104 @@ public function testIssue(): void } } -/** - * @Entity - * @Table(name="DDC837Super") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"class1" = "DDC837Class1", "class2" = "DDC837Class2", "class3"="DDC837Class3"}) - */ +#[Table(name: 'DDC837Super')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['class1' => 'DDC837Class1', 'class2' => 'DDC837Class2', 'class3' => 'DDC837Class3'])] abstract class DDC837Super { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } -/** @Entity */ +#[Entity] class DDC837Class1 extends DDC837Super { /** * @var string - * @Column(name="title", type="string", length=150) */ + #[Column(name: 'title', type: 'string', length: 150)] public $title; /** * @var string - * @Column(name="content", type="string", length=500) */ + #[Column(name: 'content', type: 'string', length: 500)] public $description; /** * @var DDC837Aggregate - * @OneToOne(targetEntity="DDC837Aggregate") */ + #[OneToOne(targetEntity: 'DDC837Aggregate')] public $aggregate; } -/** @Entity */ +#[Entity] class DDC837Class2 extends DDC837Super { /** * @var string - * @Column(name="title", type="string", length=150) */ + #[Column(name: 'title', type: 'string', length: 150)] public $title; /** * @var string - * @Column(name="content", type="string", length=500) */ + #[Column(name: 'content', type: 'string', length: 500)] public $description; /** * @var string - * @Column(name="text", type="text") */ + #[Column(name: 'text', type: 'text')] public $text; /** * @var DDC837Aggregate - * @OneToOne(targetEntity="DDC837Aggregate") */ + #[OneToOne(targetEntity: 'DDC837Aggregate')] public $aggregate; } /** * An extra class to demonstrate why title and description aren't in Super - * - * @Entity */ +#[Entity] class DDC837Class3 extends DDC837Super { /** * @var string - * @Column(name="title", type="string", length=150) */ + #[Column(name: 'title', type: 'string', length: 150)] public $apples; /** * @var string - * @Column(name="content", type="string", length=500) */ + #[Column(name: 'content', type: 'string', length: 500)] public $bananas; } -/** @Entity */ +#[Entity] class DDC837Aggregate { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue] public $id; public function __construct( - /** @Column(name="sysname", type="string", length=255) */ + #[Column(name: 'sysname', type: 'string', length: 255)] protected string $sysname, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index 30e08cdcb83..33139c175c5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -102,23 +102,21 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class DDC881User { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string|null $name = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC881PhoneNumber",mappedBy="id") */ + #[OneToMany(targetEntity: 'DDC881PhoneNumber', mappedBy: 'id')] private $phoneNumbers; public function getName(): string @@ -132,28 +130,24 @@ public function setName(string $name): void } } -/** @Entity */ +#[Entity] class DDC881PhoneNumber { - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] private int|null $id = null; - /** - * @Id - * @ManyToOne(targetEntity="DDC881User",cascade={"all"}) - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC881User', cascade: ['all'])] private DDC881User|null $user = null; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string|null $phonenumber = null; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC881PhoneCall", mappedBy="phonenumber") */ + #[OneToMany(targetEntity: 'DDC881PhoneCall', mappedBy: 'phonenumber')] private $calls; public function __construct() @@ -183,26 +177,20 @@ public function getCalls(): Collection } } -/** @Entity */ +#[Entity] class DDC881PhoneCall { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @ManyToOne(targetEntity="DDC881PhoneNumber", inversedBy="calls", cascade={"all"}) - * @JoinColumns({ - * @JoinColumn(name="phonenumber_id", referencedColumnName="id"), - * @JoinColumn(name="user_id", referencedColumnName="user_id") - * }) - */ + #[JoinColumn(name: 'phonenumber_id', referencedColumnName: 'id')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'user_id')] + #[ManyToOne(targetEntity: 'DDC881PhoneNumber', inversedBy: 'calls', cascade: ['all'])] private DDC881PhoneNumber|null $phonenumber = null; - /** @Column(type="string",nullable=true) */ + #[Column(type: 'string', nullable: true)] private string $callDate; public function setPhoneNumber(DDC881PhoneNumber $phoneNumber): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php index 5376da880c3..a96ffb8994d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -36,27 +36,18 @@ public function testUpdateRootVersion(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({ - * "root" = "DDC960Root", - * "child" = "DDC960Child" - * }) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorMap(['root' => 'DDC960Root', 'child' => 'DDC960Child'])] class DDC960Root { - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; - /** - * @Column(type="integer") - * @Version - */ + #[Column(type: 'integer')] + #[Version] private int $version; public function getId(): int @@ -70,11 +61,11 @@ public function getVersion(): int } } -/** @Entity */ +#[Entity] class DDC960Child extends DDC960Root { public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index 4221db3ae3a..bfaf0b7732b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -88,35 +89,33 @@ public function testOneToManyChild(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorMap({"child" = "DDC992Child", "parent" = "DDC992Parent"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorMap(['child' => 'DDC992Child', 'parent' => 'DDC992Parent'])] class DDC992Parent { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var DDC992Parent - * @ManyToOne(targetEntity="DDC992Parent", inversedBy="childs") */ + #[ManyToOne(targetEntity: 'DDC992Parent', inversedBy: 'childs')] public $parent; /** * @var Collection - * @OneToMany(targetEntity="DDC992Child", mappedBy="parent") */ + #[OneToMany(targetEntity: 'DDC992Child', mappedBy: 'parent')] public $childs; } -/** @Entity */ +#[Entity] class DDC992Child extends DDC992Parent { public function childs(): Collection @@ -125,7 +124,7 @@ public function childs(): Collection } } -/** @Entity */ +#[Entity] class DDC992Role { public function getRoleID(): int @@ -135,32 +134,31 @@ public function getRoleID(): int /** * @var int - * @Id - * @Column(name="roleID", type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(name: 'roleID', type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $roleID; /** * @var string - * @Column(name="name", type="string", length=45) */ + #[Column(name: 'name', type: 'string', length: 45)] public $name; /** * @psalm-var Collection - * @ManyToMany(targetEntity="DDC992Role", mappedBy="extends") */ + #[ManyToMany(targetEntity: 'DDC992Role', mappedBy: 'extends')] public $extendedBy; /** * @psalm-var Collection - * @ManyToMany (targetEntity="DDC992Role", inversedBy="extendedBy") - * @JoinTable(name="RoleRelations", - * joinColumns={@JoinColumn(name="roleID", referencedColumnName="roleID")}, - * inverseJoinColumns={@JoinColumn(name="extendsRoleID", referencedColumnName="roleID")}, - * ) */ + #[JoinTable(name: 'RoleRelations')] + #[JoinColumn(name: 'roleID', referencedColumnName: 'roleID')] + #[InverseJoinColumn(name: 'extendsRoleID', referencedColumnName: 'roleID')] + #[ManyToMany(targetEntity: 'DDC992Role', inversedBy: 'extendedBy')] public $extends; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php index 00e62ca0b97..7d0b77e52d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php @@ -77,18 +77,14 @@ private function updateData(): void } } -/** - * @Entity - * @Table(name="GH2947_car") - */ +#[Table(name: 'GH2947_car')] +#[Entity] class GH2947Car implements Stringable { public function __construct( - /** - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 25)] + #[GeneratedValue(strategy: 'NONE')] public string $brand, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php index 9a335f4d79c..56c0ea6f897 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php @@ -63,65 +63,59 @@ public function testCacheShouldBeUpdatedWhenAssociationChanges(): void } } -/** - * @Entity - * @Cache(usage="NONSTRICT_READ_WRITE") - */ +#[Entity] +#[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH5562Merchant { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="IDENTITY") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'IDENTITY')] public $id; /** * @var GH5562Manager - * @OneToOne(targetEntity=GH5562Manager::class, mappedBy="merchant") - * @Cache(usage="NONSTRICT_READ_WRITE") */ + #[OneToOne(targetEntity: GH5562Manager::class, mappedBy: 'merchant')] + #[Cache(usage: 'NONSTRICT_READ_WRITE')] public $manager; /** * @var string - * @Column(name="name", type="string", length=255, nullable=false) */ + #[Column(name: 'name', type: 'string', length: 255, nullable: false)] public $name; } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"MANAGER" = GH5562Manager::class}) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorMap(['MANAGER' => GH5562Manager::class])] abstract class GH5562User { /** * @var int - * @Id - * @Column(name="id", type="integer") - * @GeneratedValue(strategy="IDENTITY") */ + #[Id] + #[Column(name: 'id', type: 'integer')] + #[GeneratedValue(strategy: 'IDENTITY')] public $id; } -/** - * @Entity - * @Cache(usage="NONSTRICT_READ_WRITE") - */ +#[Entity] +#[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH5562Manager extends GH5562User { /** * @var string - * @Column */ + #[Column] public $username; /** * @var GH5562Merchant - * @OneToOne(targetEntity=GH5562Merchant::class, inversedBy="manager") */ + #[OneToOne(targetEntity: GH5562Merchant::class, inversedBy: 'manager')] public $merchant; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index 6349f4b555e..0e2c9b2761d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -106,50 +106,40 @@ private function createData(): void } } -/** - * @Entity - * @Table(name="driver") - */ +#[Table(name: 'driver')] +#[Entity] class GH5762Driver { /** * @psalm-var Collection - * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="driver") */ + #[OneToMany(targetEntity: 'GH5762DriverRide', mappedBy: 'driver')] public $driverRides; public function __construct( - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'NONE')] public int $id, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { $this->driverRides = new ArrayCollection(); } } -/** - * @Entity - * @Table(name="driver_ride") - */ +#[Table(name: 'driver_ride')] +#[Entity] class GH5762DriverRide { public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="GH5762Driver", inversedBy="driverRides") - * @JoinColumn(name="driver_id", referencedColumnName="id") - */ + #[Id] + #[ManyToOne(targetEntity: 'GH5762Driver', inversedBy: 'driverRides')] + #[JoinColumn(name: 'driver_id', referencedColumnName: 'id')] public GH5762Driver $driver, - /** - * @Id - * @ManyToOne(targetEntity="GH5762Car", inversedBy="carRides") - * @JoinColumn(name="car", referencedColumnName="brand") - */ + #[Id] + #[ManyToOne(targetEntity: 'GH5762Car', inversedBy: 'carRides')] + #[JoinColumn(name: 'car', referencedColumnName: 'brand')] public GH5762Car $car, ) { $this->driver->driverRides->add($this); @@ -157,26 +147,22 @@ public function __construct( } } -/** - * @Entity - * @Table(name="car") - */ +#[Table(name: 'car')] +#[Entity] class GH5762Car { /** * @psalm-var Collection - * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="car") */ + #[OneToMany(targetEntity: 'GH5762DriverRide', mappedBy: 'car')] public $carRides; public function __construct( - /** - * @Id - * @Column(type="string", length=25) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 25)] + #[GeneratedValue(strategy: 'NONE')] public string $brand, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $model, ) { $this->carRides = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index cb09b8c1038..d45780f158a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -89,28 +89,28 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): stri } } -/** @Entity */ +#[Entity] class GH5804Article { /** * @var string - * @Id - * @Column(type="GH5804Type", length=255) - * @GeneratedValue(strategy="CUSTOM") - * @CustomIdGenerator(class=\Doctrine\Tests\ORM\Functional\Ticket\GH5804Generator::class) */ + #[Id] + #[Column(type: 'GH5804Type', length: 255)] + #[GeneratedValue(strategy: 'CUSTOM')] + #[CustomIdGenerator(class: \Doctrine\Tests\ORM\Functional\Ticket\GH5804Generator::class)] public $id; /** * @var int - * @Version - * @Column(type="integer") */ + #[Version] + #[Column(type: 'integer')] public $version; /** * @var string - * @Column(type="text") */ + #[Column(type: 'text')] public $text; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index 4fedeb36897..556fb58f022 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -60,22 +60,19 @@ public function testLazyLoadsForeignEntitiesInOneToOneRelationWhileHavingCustomI } } -/** @Entity */ +#[Entity] class GH5887Cart { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'NONE')] private int|null $id = null; /** * One Cart has One Customer. - * - * @OneToOne(targetEntity="GH5887Customer", inversedBy="cart") - * @JoinColumn(name="customer_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'GH5887Customer', inversedBy: 'cart')] + #[JoinColumn(name: 'customer_id', referencedColumnName: 'id')] private GH5887Customer|null $customer = null; public function getId(): int @@ -102,21 +99,18 @@ public function setCustomer(GH5887Customer $customer): void } } -/** @Entity */ +#[Entity] class GH5887Customer { - /** - * @Id - * @Column(type="GH5887CustomIdObject", length=255) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'GH5887CustomIdObject', length: 255)] + #[GeneratedValue(strategy: 'NONE')] private GH5887CustomIdObject|null $id = null; /** * One Customer has One Cart. - * - * @OneToOne(targetEntity="GH5887Cart", mappedBy="customer") */ + #[OneToOne(targetEntity: 'GH5887Cart', mappedBy: 'customer')] private GH5887Cart|null $cart = null; public function getId(): GH5887CustomIdObject diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php index 12f4273e708..5bb190e1252 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php @@ -87,21 +87,21 @@ public function testOneToManyAssociation(): void } } -/** @Entity */ +#[Entity] class GH6029User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity=GH6029Group::class, cascade={"all"}) */ + #[ManyToMany(targetEntity: GH6029Group::class, cascade: ['all'])] public $groups; public function __construct() @@ -110,45 +110,45 @@ public function __construct() } } -/** @Entity */ +#[Entity] class GH6029Group { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class GH6029Group2 { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class GH6029Product { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity=GH6029Feature::class, mappedBy="product", cascade={"all"}) */ + #[OneToMany(targetEntity: GH6029Feature::class, mappedBy: 'product', cascade: ['all'])] public $features; public function __construct() @@ -157,21 +157,21 @@ public function __construct() } } -/** @Entity */ +#[Entity] class GH6029Feature { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var GH6029Product - * @ManyToOne(targetEntity=GH6029Product::class, inversedBy="features") - * @JoinColumn(name="product_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: GH6029Product::class, inversedBy: 'features')] + #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] public $product; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php index 3e544916c18..7f6b3c648dc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php @@ -142,38 +142,33 @@ public function __toString(): string } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="gh6141people") - * @DiscriminatorMap({ - * GH6141People::BOSS = GH6141Boss::class, - * GH6141People::EMPLOYEE = GH6141Employee::class - * }) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'gh6141people')] +#[DiscriminatorMap([GH6141People::BOSS => GH6141Boss::class, GH6141People::EMPLOYEE => GH6141Employee::class])] abstract class GH6141Person { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } } -/** @Entity */ +#[Entity] class GH6141Boss extends GH6141Person { } -/** @Entity */ +#[Entity] class GH6141Employee extends GH6141Person { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php index ac82a248977..c5f299f3203 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php @@ -58,18 +58,16 @@ public function testLoadingOfSecondLevelCacheOnEagerAssociations(): void } } -/** - * @Entity - * @Cache(usage="NONSTRICT_READ_WRITE") - */ +#[Entity] +#[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH6217AssociatedEntity { /** * @var string - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] public $id; public function __construct() @@ -78,24 +76,18 @@ public function __construct() } } -/** - * @Entity - * @Cache(usage="NONSTRICT_READ_WRITE") - */ +#[Entity] +#[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH6217FetchedEntity { public function __construct( - /** - * @Id - * @Cache("NONSTRICT_READ_WRITE") - * @ManyToOne(targetEntity=GH6217AssociatedEntity::class) - */ + #[Id] + #[Cache('NONSTRICT_READ_WRITE')] + #[ManyToOne(targetEntity: GH6217AssociatedEntity::class)] public GH6217AssociatedEntity $lazy, - /** - * @Id - * @Cache("NONSTRICT_READ_WRITE") - * @ManyToOne(targetEntity=GH6217AssociatedEntity::class, fetch="EAGER") - */ + #[Id] + #[Cache('NONSTRICT_READ_WRITE')] + #[ManyToOne(targetEntity: GH6217AssociatedEntity::class, fetch: 'EAGER')] public GH6217AssociatedEntity $eager, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index 2bf6fd1897a..6915efb6dad 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -88,64 +88,60 @@ public function testInheritanceJoinAlias(): void } } -/** @Entity */ +#[Entity] class GH6362Start { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] protected $id; - /** @ManyToOne(targetEntity="GH6362Base", inversedBy="starts") */ + #[ManyToOne(targetEntity: 'GH6362Base', inversedBy: 'starts')] private GH6362Base $bases; } -/** - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="string") - * @DiscriminatorMap({"child" = "GH6362Child"}) - * @Entity - */ +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'type', type: 'string')] +#[DiscriminatorMap(['child' => 'GH6362Child'])] +#[Entity] abstract class GH6362Base { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] protected $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="GH6362Start", mappedBy="bases") */ + #[OneToMany(targetEntity: 'GH6362Start', mappedBy: 'bases')] private $starts; } -/** @Entity */ +#[Entity] class GH6362Child extends GH6362Base { /** * @psalm-var Collection - * @OneToMany(targetEntity="GH6362Join", mappedBy="child") */ + #[OneToMany(targetEntity: 'GH6362Join', mappedBy: 'child')] private $joins; } -/** @Entity */ +#[Entity] class GH6362Join { - /** - * @Column(type="integer") - * @Id - * @GeneratedValue - */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] private int $id; - /** @ManyToOne(targetEntity="GH6362Child", inversedBy="joins") */ + #[ManyToOne(targetEntity: 'GH6362Child', inversedBy: 'joins')] private GH6362Child $child; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php index 4b1b428820d..46b85f2802d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php @@ -45,44 +45,40 @@ public function testFetchVersionValueForDifferentIdFieldAndColumn(): void } } -/** @Entity */ +#[Entity] class A { /** - * @Version - * @Column(type="integer") * @var int */ + #[Version] + #[Column(type: 'integer')] public $version; public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] public int $id, ) { } } -/** @Entity */ +#[Entity] class B { /** - * @Version - * @Column(type="integer") * @var int */ + #[Version] + #[Column(type: 'integer')] public $version; public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="A") - * @JoinColumn(name="aid", referencedColumnName="id") - */ + #[Id] + #[ManyToOne(targetEntity: 'A')] + #[JoinColumn(name: 'aid', referencedColumnName: 'id')] public A $a, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $something, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php index 2fd091721e3..2194d7c8ad1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php @@ -52,42 +52,40 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class GH6464Post { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $authorId; } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"author" = "GH6464Author"}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['author' => 'GH6464Author'])] abstract class GH6464User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class GH6464Author extends GH6464User { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php index 865cc962da4..2100618082e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php @@ -84,44 +84,44 @@ public function testJoinTableWithMetadata(): void } } -/** @Entity */ +#[Entity] class GH6531User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class GH6531Address { /** * @var GH6531User - * @Id - * @OneToOne(targetEntity=GH6531User::class) */ + #[Id] + #[OneToOne(targetEntity: GH6531User::class)] public $user; } -/** @Entity */ +#[Entity] class GH6531Article { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity=GH6531ArticleAttribute::class, mappedBy="article", cascade={"ALL"}, indexBy="attribute") * */ + #[OneToMany(targetEntity: GH6531ArticleAttribute::class, mappedBy: 'article', cascade: ['ALL'], indexBy: 'attribute')] public $attributes; public function addAttribute(string $name, string $value): void @@ -130,41 +130,37 @@ public function addAttribute(string $name, string $value): void } } -/** @Entity */ +#[Entity] class GH6531ArticleAttribute { public function __construct( - /** - * @Id - * @Column(type="string", length=255) - */ + #[Id] + #[Column(type: 'string', length: 255)] public string $attribute, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $value, - /** - * @Id - * @ManyToOne(targetEntity=GH6531Article::class, inversedBy="attributes") - */ + #[Id] + #[ManyToOne(targetEntity: GH6531Article::class, inversedBy: 'attributes')] public GH6531Article $article, ) { } } -/** @Entity */ +#[Entity] class GH6531Order { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity=GH6531OrderItem::class, mappedBy="order", cascade={"ALL"}) */ + #[OneToMany(targetEntity: GH6531OrderItem::class, mappedBy: 'order', cascade: ['ALL'])] public $items; public function __construct() @@ -178,33 +174,29 @@ public function addItem(GH6531Product $product, int $amount): void } } -/** @Entity */ +#[Entity] class GH6531Product { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class GH6531OrderItem { public function __construct( - /** - * @Id - * @ManyToOne(targetEntity=GH6531Order::class) - */ + #[Id] + #[ManyToOne(targetEntity: GH6531Order::class)] public GH6531Order $order, - /** - * @Id - * @ManyToOne(targetEntity=GH6531Product::class) - */ + #[Id] + #[ManyToOne(targetEntity: GH6531Product::class)] public GH6531Product $product, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $amount = 1, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php index 8ab0284a02d..464c2a53486 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\ORM\Mapping\Column; @@ -60,95 +61,73 @@ public function testCharsetCollationWhenCreatingForeignRelations(): void } } -/** - * @Entity - * @Table(name="gh6823_user", options={ - * "charset"="utf8mb4", - * "collation"="utf8mb4_bin" - * }) - */ +#[Table(name: 'gh6823_user', options: ['charset' => 'utf8mb4', 'collation' => 'utf8mb4_bin'])] +#[Entity] class GH6823User { /** * @var string - * @Id - * @Column(type="string", length=255) */ + #[Id] + #[Column(type: 'string', length: 255)] public $id; /** * @var GH6823Group - * @ManyToOne(targetEntity="GH6823Group") - * @JoinColumn(name="group_id", referencedColumnName="id", options={"charset"="ascii", "collation"="ascii_general_ci"}) */ + #[ManyToOne(targetEntity: 'GH6823Group')] + #[JoinColumn(name: 'group_id', referencedColumnName: 'id', options: ['charset' => 'ascii', 'collation' => 'ascii_general_ci'])] public $group; /** * @var GH6823Status - * @ManyToOne(targetEntity="GH6823Status") - * @JoinColumn(name="status_id", referencedColumnName="id", options={"charset"="latin1", "collation"="latin1_bin"}) */ + #[ManyToOne(targetEntity: 'GH6823Status')] + #[JoinColumn(name: 'status_id', referencedColumnName: 'id', options: ['charset' => 'latin1', 'collation' => 'latin1_bin'])] public $status; /** * @var Collection - * @ManyToMany(targetEntity="GH6823Tag") - * @JoinTable(name="gh6823_user_tags", joinColumns={ - * @JoinColumn(name="user_id", referencedColumnName="id", options={"charset"="utf8mb4", "collation"="utf8mb4_bin"}) - * }, inverseJoinColumns={ - * @JoinColumn(name="tag_id", referencedColumnName="id", options={"charset"="latin1", "collation"="latin1_bin"}) - * }, options={"charset"="ascii", "collation"="ascii_general_ci"}) */ + #[JoinTable(name: 'gh6823_user_tags', options: ['charset' => 'ascii', 'collation' => 'ascii_general_ci'])] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id', options: ['charset' => 'utf8mb4', 'collation' => 'utf8mb4_bin'])] + #[InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id', options: ['charset' => 'latin1', 'collation' => 'latin1_bin'])] + #[ManyToMany(targetEntity: 'GH6823Tag')] public $tags; } -/** - * @Entity - * @Table(name="gh6823_group", options={ - * "charset"="ascii", - * "collation"="ascii_general_ci" - * }) - */ +#[Table(name: 'gh6823_group', options: ['charset' => 'ascii', 'collation' => 'ascii_general_ci'])] +#[Entity] class GH6823Group { /** * @var string - * @Id - * @Column(type="string", length=255) */ + #[Id] + #[Column(type: 'string', length: 255)] public $id; } -/** - * @Entity - * @Table(name="gh6823_status", options={ - * "charset"="koi8r", - * "collation"="koi8r_bin" - * }) - */ +#[Table(name: 'gh6823_status', options: ['charset' => 'koi8r', 'collation' => 'koi8r_bin'])] +#[Entity] class GH6823Status { /** * @var string - * @Id - * @Column(type="string", length=255, options={"charset"="latin1", "collation"="latin1_bin"}) */ + #[Id] + #[Column(type: 'string', length: 255, options: ['charset' => 'latin1', 'collation' => 'latin1_bin'])] public $id; } -/** - * @Entity - * @Table(name="gh6823_tag", options={ - * "charset"="koi8r", - * "collation"="koi8r_bin" - * }) - */ +#[Table(name: 'gh6823_tag', options: ['charset' => 'koi8r', 'collation' => 'koi8r_bin'])] +#[Entity] class GH6823Tag { /** * @var string - * @Id - * @Column(type="string", length=255, options={"charset"="latin1", "collation"="latin1_bin"}) */ + #[Id] + #[Column(type: 'string', length: 255, options: ['charset' => 'latin1', 'collation' => 'latin1_bin'])] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php index 0eb32c23360..10ed46ce8d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php @@ -89,45 +89,43 @@ public function testPhoneNumberIsPopulatedWithQueryBuilder(): void } } -/** - * @Entity - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"employee"=GH6937Employee::class, "manager"=GH6937Manager::class}) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['employee' => GH6937Employee::class, 'manager' => GH6937Manager::class])] abstract class GH6937Person { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; } -/** @Entity */ +#[Entity] abstract class GH6937Employee extends GH6937Person { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $phoneNumber; } -/** @Entity */ +#[Entity] class GH6937Manager extends GH6937Employee { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $department; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php index df58288824b..f4181bc8f32 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php @@ -49,20 +49,16 @@ public function testUpdateEntityWithIdentifierAssociationWithQuotedJoinColumn(): } -/** - * @Entity - * @Table(name="`quote-user-data`") - */ +#[Table(name: '`quote-user-data`')] +#[Entity] class GH7012UserData { public function __construct( - /** - * @Id - * @OneToOne(targetEntity=QuotedUser::class) - * @JoinColumn(name="`user-id`", referencedColumnName="`user-id`", onDelete="CASCADE") - */ + #[Id] + #[OneToOne(targetEntity: QuotedUser::class)] + #[JoinColumn(name: '`user-id`', referencedColumnName: '`user-id`', onDelete: 'CASCADE')] public QuotedUser $user, - /** @Column(type="string", name="`name`") */ + #[Column(type: 'string', name: '`name`')] public string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php index eb498d921da..045e95df777 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php @@ -92,26 +92,23 @@ private function verifyRanking(): void /** * Simple Entity whose identity is defined through another Entity (Season) - * - * @Entity - * @Table(name="soccer_rankings") */ +#[Table(name: 'soccer_rankings')] +#[Entity] class GH7062Ranking { /** - * @OneToMany(targetEntity=GH7062RankingPosition::class, mappedBy="ranking", cascade={"all"}) * @var Collection|GH7062RankingPosition[] * @psalm-var Collection */ + #[OneToMany(targetEntity: GH7062RankingPosition::class, mappedBy: 'ranking', cascade: ['all'])] public $positions; /** @param GH7062Team[] $teams */ public function __construct( - /** - * @Id - * @OneToOne(targetEntity=GH7062Season::class, inversedBy="ranking") - * @JoinColumn(name="season", referencedColumnName="id") - */ + #[Id] + #[OneToOne(targetEntity: GH7062Season::class, inversedBy: 'ranking')] + #[JoinColumn(name: 'season', referencedColumnName: 'id')] public GH7062Season $season, array $teams, ) { @@ -125,23 +122,20 @@ public function __construct( /** * Entity which serves as a identity provider for other entities - * - * @Entity - * @Table(name="soccer_seasons") */ +#[Table(name: 'soccer_seasons')] +#[Entity] class GH7062Season { /** * @var GH7062Ranking|null - * @OneToOne(targetEntity=GH7062Ranking::class, mappedBy="season", cascade={"all"}) */ + #[OneToOne(targetEntity: GH7062Ranking::class, mappedBy: 'season', cascade: ['all'])] public $ranking; public function __construct( - /** - * @Id - * @Column(type="string", length=255) - */ + #[Id] + #[Column(type: 'string', length: 255)] public string $id, ) { } @@ -149,17 +143,14 @@ public function __construct( /** * Entity which serves as a identity provider for other entities - * - * @Entity - * @Table(name="soccer_teams") */ +#[Table(name: 'soccer_teams')] +#[Entity] class GH7062Team { public function __construct( - /** - * @Id - * @Column(type="string", length=255) - */ + #[Id] + #[Column(type: 'string', length: 255)] public string $id, ) { } @@ -167,30 +158,25 @@ public function __construct( /** * Entity whose identity is defined through two other entities - * - * @Entity - * @Table(name="soccer_ranking_positions") */ +#[Table(name: 'soccer_ranking_positions')] +#[Entity] class GH7062RankingPosition { /** - * @Column(type="integer") * @var int */ + #[Column(type: 'integer')] public $points; public function __construct( - /** - * @Id - * @ManyToOne(targetEntity=GH7062Ranking::class, inversedBy="positions") - * @JoinColumn(name="season", referencedColumnName="season") - */ + #[Id] + #[ManyToOne(targetEntity: GH7062Ranking::class, inversedBy: 'positions')] + #[JoinColumn(name: 'season', referencedColumnName: 'season')] public GH7062Ranking $ranking, - /** - * @Id - * @ManyToOne(targetEntity=GH7062Team::class) - * @JoinColumn(name="team_id", referencedColumnName="id") - */ + #[Id] + #[ManyToOne(targetEntity: GH7062Team::class)] + #[JoinColumn(name: 'team_id', referencedColumnName: 'id')] public GH7062Team $team, ) { $this->points = 0; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php index e83329efecb..437260119d1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php @@ -47,30 +47,28 @@ public function testSLCWithVersion(): void } } -/** - * @Entity() - * @Cache(usage="NONSTRICT_READ_WRITE") - */ +#[Entity] +#[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH7067Entity { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** - * @Column(type="datetime") * @var DateTime */ + #[Column(type: 'datetime')] public $lastUpdate; /** - * @Column(type="datetime") - * @Version * @var DateTime */ + #[Column(type: 'datetime')] + #[Version] public $version; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php index fc3274d8bac..67e9f363927 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php @@ -39,14 +39,14 @@ public function testLockModeIsRespected(): void } } -/** @Entity */ +#[Entity] final class SomeEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php index 447024d50b0..f4a048e1dcb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php @@ -82,45 +82,41 @@ private function createClassMetadata(string $className): ClassMetadata } } -/** - * @Entity - * @Table(name="cms_users", schema="cms") - */ +#[Table(name: 'cms_users', schema: 'cms')] +#[Entity] class GH7079CmsUser { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var GH7079CmsAddress - * @OneToOne(targetEntity=GH7079CmsAddress::class, mappedBy="user", cascade={"persist"}, orphanRemoval=true) */ + #[OneToOne(targetEntity: GH7079CmsAddress::class, mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] public $address; } -/** - * @Entity - * @Table(name="cms_addresses", schema="cms") - */ +#[Table(name: 'cms_addresses', schema: 'cms')] +#[Entity] class GH7079CmsAddress { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] public $id; /** * @var GH7079CmsUser - * @OneToOne(targetEntity=GH7079CmsUser::class, inversedBy="address") - * @JoinColumn(referencedColumnName="id") */ + #[OneToOne(targetEntity: GH7079CmsUser::class, inversedBy: 'address')] + #[JoinColumn(referencedColumnName: 'id')] public $user; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php index 2bbb9bd4f91..10322b2201b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php @@ -75,78 +75,78 @@ public function testPersistFileAfterVersion(): void } } -/** @Entity() */ +#[Entity] class GH7259File { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** - * @ManyToOne(targetEntity=GH7259Space::class) - * @JoinColumn(nullable=false) * @var GH7259Space|null */ + #[ManyToOne(targetEntity: GH7259Space::class)] + #[JoinColumn(nullable: false)] public $space; } -/** @Entity() */ +#[Entity] class GH7259FileVersion { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** - * @ManyToOne(targetEntity=GH7259File::class) - * @JoinColumn(nullable=false) * @var GH7259File|null */ + #[ManyToOne(targetEntity: GH7259File::class)] + #[JoinColumn(nullable: false)] public $file; } -/** @Entity() */ +#[Entity] class GH7259Space { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** - * @ManyToOne(targetEntity=GH7259File::class) - * @JoinColumn(nullable=true) * @var GH7259File|null */ + #[ManyToOne(targetEntity: GH7259File::class)] + #[JoinColumn(nullable: true)] public $ruleFile; } -/** @Entity() */ +#[Entity] class GH7259Feed { /** - * @Id - * @GeneratedValue - * @Column(type="integer") * @var int */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** - * @ManyToOne(targetEntity=GH7259Space::class) - * @JoinColumn(nullable=false) * @var GH7259Space|null */ + #[ManyToOne(targetEntity: GH7259Space::class)] + #[JoinColumn(nullable: false)] public $space; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php index e5aaf05b198..5d8ce3df78a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php @@ -74,21 +74,21 @@ public function testAggregateFunctionInCustomFunction(): void } } -/** @Entity */ +#[Entity] class GH7286Entity { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; public function __construct( - /** @Column(nullable=true) */ + #[Column(nullable: true)] public string|null $type, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $version, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php index f5b1394974c..42e0b439b77 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php @@ -42,26 +42,26 @@ public function testOptimisticLockNoExceptionOnFind(): void } } -/** @Entity */ +#[Entity] class GH7366Entity { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var int - * @Column(type="integer") - * @Version */ + #[Column(type: 'integer')] + #[Version] protected $lockVersion = 1; public function __construct( - /** @Column(length=32) */ + #[Column(length: 32)] protected string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php index afd2aa7c3b0..1adba40cf11 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php @@ -63,37 +63,33 @@ public function testNonUniqueObjectHydrationDuringIteration(): void } } -/** @Entity */ +#[Entity] class GH7496EntityA { public function __construct( - /** - * @Id - * @Column(type="integer", name="a_id") - */ + #[Id] + #[Column(type: 'integer', name: 'a_id')] public int $id, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } } -/** @Entity */ +#[Entity] class GH7496EntityB { public function __construct( - /** - * @Id - * @Column(type="integer", name="b_id") - */ + #[Id] + #[Column(type: 'integer', name: 'b_id')] public int $id, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } } -/** @Entity */ +#[Entity] class GH7496EntityAinB { /** @@ -101,20 +97,14 @@ class GH7496EntityAinB * @param GH7496EntityB $b */ public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] public int $id, - /** - * @ManyToOne(targetEntity=GH7496EntityA::class) - * @JoinColumn(name="a_id", referencedColumnName="a_id", nullable=false) - */ + #[ManyToOne(targetEntity: GH7496EntityA::class)] + #[JoinColumn(name: 'a_id', referencedColumnName: 'a_id', nullable: false)] public $eA, - /** - * @ManyToOne(targetEntity=GH7496EntityB::class) - * @JoinColumn(name="b_id", referencedColumnName="b_id", nullable=false) - */ + #[ManyToOne(targetEntity: GH7496EntityB::class)] + #[JoinColumn(name: 'b_id', referencedColumnName: 'b_id', nullable: false)] public $eB, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php index 3cda57fbad7..0d9bd8db96d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php @@ -53,43 +53,38 @@ public function testSimpleArrayTypeHydratedCorrectly(): void } } -/** - * @Entity() - * @Table(name="gh7505_responses") - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({ - * "array" = GH7505ArrayResponse::class, - * "text" = GH7505TextResponse::class, - * }) - */ +#[Table(name: 'gh7505_responses')] +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['array' => GH7505ArrayResponse::class, 'text' => GH7505TextResponse::class])] abstract class GH7505AbstractResponse { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; } -/** @Entity() */ +#[Entity] class GH7505ArrayResponse extends GH7505AbstractResponse { /** * @var mixed[] - * @Column(name="value_array", type="simple_array") */ + #[Column(name: 'value_array', type: 'simple_array')] public $value = []; } -/** @Entity() */ +#[Entity] class GH7505TextResponse extends GH7505AbstractResponse { /** - * @Column(name="value_string", type="string", length=255) * @var string|null */ + #[Column(name: 'value_string', type: 'string', length: 255)] public $value; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php index fa58570274f..65240b0b937 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php @@ -44,50 +44,45 @@ public function testFindEntityByAssociationPropertyJoinedChildWithClearMetadata( } } -/** - * @Entity() - * @InheritanceType("JOINED") - * @DiscriminatorMap({ - * "entitya"=GH7512EntityA::class, - * "entityB"=GH7512EntityB::class - * }) - */ +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorMap(['entitya' => GH7512EntityA::class, 'entityB' => GH7512EntityB::class])] class GH7512EntityA { /** - * @Column(type="integer") - * @Id() - * @GeneratedValue(strategy="AUTO") * @var int */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** - * @OneToMany(targetEntity="GH7512EntityC", mappedBy="entityA") * @var Collection */ + #[OneToMany(targetEntity: 'GH7512EntityC', mappedBy: 'entityA')] public $entityCs; } -/** @Entity() */ +#[Entity] class GH7512EntityB extends GH7512EntityA { } -/** @Entity() */ +#[Entity] class GH7512EntityC { /** - * @Column(type="integer") - * @Id() - * @GeneratedValue(strategy="AUTO") * @var int */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** - * @ManyToOne(targetEntity="GH7512EntityA", inversedBy="entityCs") * @var GH7512EntityA */ + #[ManyToOne(targetEntity: 'GH7512EntityA', inversedBy: 'entityCs')] public $entityA; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php index afe4057cc7d..77e007f41e5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php @@ -49,17 +49,15 @@ public function testPersistAfterRemoveSchedulesForSynchronization(): void } } -/** - * @Entity - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ +#[Entity] +#[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class GH7629Entity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php index 5f41e0bdfb8..d6b797fed3e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php @@ -51,50 +51,50 @@ public function testIndexByAssociation(): void } } -/** @Entity */ +#[Entity] class GH7661User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class GH7661Event { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var GH7661Participant[] - * @OneToMany(targetEntity=GH7661Participant::class, mappedBy="event", indexBy="user_id") */ + #[OneToMany(targetEntity: GH7661Participant::class, mappedBy: 'event', indexBy: 'user_id')] public $participants; } -/** @Entity */ +#[Entity] class GH7661Participant { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; public function __construct( - /** @ManyToOne(targetEntity=GH7661User::class) */ + #[ManyToOne(targetEntity: GH7661User::class)] public GH7661User $user, - /** @ManyToOne(targetEntity=GH7661Event::class) */ + #[ManyToOne(targetEntity: GH7661Event::class)] public GH7661Event $event, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php index 37fafa4f729..786cabe4596 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php @@ -49,23 +49,17 @@ public function findByReturnsCachedEntity(): void } } -/** - * @Entity - * @Cache(usage="READ_ONLY") - */ +#[Entity] +#[Cache(usage: 'READ_ONLY')] class GH7735Car { public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] private int $id, - /** - * @ManyToOne(targetEntity=GH7735Engine::class, cascade={"all"}) - * @JoinColumn(nullable=false) - * @Cache("READ_ONLY") - */ + #[ManyToOne(targetEntity: GH7735Engine::class, cascade: ['all'])] + #[JoinColumn(nullable: false)] + #[Cache('READ_ONLY')] private GH7735Engine $engine, ) { } @@ -81,24 +75,18 @@ public function getEngine(): GH7735Engine } } -/** - * @Entity - * @Cache(usage="READ_ONLY") - */ +#[Entity] +#[Cache(usage: 'READ_ONLY')] class GH7735Engine { public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] private int $id, - /** @Column */ + #[Column] private string $model, - /** - * @OneToOne(targetEntity=GH7735Power::class, mappedBy="engine", cascade={"all"}) - * @Cache("READ_ONLY") - */ + #[OneToOne(targetEntity: GH7735Power::class, mappedBy: 'engine', cascade: ['all'])] + #[Cache('READ_ONLY')] private GH7735Power $power, ) { $power->setEngine($this); @@ -120,23 +108,17 @@ public function getModel(): string } } -/** - * @Entity - * @Cache(usage="READ_ONLY") - */ +#[Entity] +#[Cache(usage: 'READ_ONLY')] class GH7735Power { - /** - * @OneToOne(targetEntity=GH7735Engine::class, inversedBy="power") - * @Cache("READ_ONLY") - */ + #[OneToOne(targetEntity: GH7735Engine::class, inversedBy: 'power')] + #[Cache('READ_ONLY')] private GH7735Engine|null $engine = null; public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] private int $id, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php index be7a97031ec..67c63fa529f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; @@ -57,36 +58,33 @@ public function memberOfCriteriaShouldBeCompatibleWithQueryBuilder(): void } } -/** @Entity */ +#[Entity] class GH7737Group { public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] public int $id, - /** @Column */ + #[Column] public string $name, ) { } } -/** @Entity */ +#[Entity] class GH7737Person { /** * @var Collection - * @ManyToMany(targetEntity=GH7737Group::class) - * @JoinTable(inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id", unique=true)}) */ + #[JoinTable] + #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id', unique: true)] + #[ManyToMany(targetEntity: GH7737Group::class)] public $groups; public function __construct( - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] public int $id, ) { $this->groups = new ArrayCollection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php index 93fe7d714f7..fef937275fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ChangeTrackingPolicy; @@ -69,28 +70,25 @@ public function testCollectionClearDoesClearIfPersisted(): void } } -/** - * @Entity - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ +#[Entity] +#[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class GH7761Entity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var Collection - * @ManyToMany(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\GH7761ChildEntity", cascade={"all"}) - * @JoinTable(name="gh7761_to_child", - * joinColumns={@JoinColumn(name="entity_id")}, - * inverseJoinColumns={@JoinColumn(name="child_id")} - * ) */ + #[JoinTable(name: 'gh7761_to_child')] + #[JoinColumn(name: 'entity_id')] + #[InverseJoinColumn(name: 'child_id')] + #[ManyToMany(targetEntity: 'Doctrine\Tests\ORM\Functional\Ticket\GH7761ChildEntity', cascade: ['all'])] public $children; public function __construct() @@ -99,17 +97,15 @@ public function __construct() } } -/** - * @Entity - * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") - */ +#[Entity] +#[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class GH7761ChildEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php index 4b304d5bbf2..f6efa39e679 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php @@ -61,21 +61,19 @@ public function testMatchingOverrulesCollectionOrdering(): void } } -/** @Entity */ +#[Entity] class GH7767ParentEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @psalm-var Collection - * @OneToMany(targetEntity=GH7767ChildEntity::class, mappedBy="parent", fetch="EXTRA_LAZY", cascade={"persist"}) - * @OrderBy({"position" = "ASC"}) */ + #[OneToMany(targetEntity: GH7767ChildEntity::class, mappedBy: 'parent', fetch: 'EXTRA_LAZY', cascade: ['persist'])] + #[OrderBy(['position' => 'ASC'])] private $children; public function addChild(int $position): void @@ -90,20 +88,18 @@ public function getChildren(): Collection } } -/** @Entity */ +#[Entity] class GH7767ChildEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; public function __construct( - /** @ManyToOne(targetEntity=GH7767ParentEntity::class, inversedBy="children") */ + #[ManyToOne(targetEntity: GH7767ParentEntity::class, inversedBy: 'children')] private GH7767ParentEntity $parent, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $position, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php index 25a6167b845..76359a1de75 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php @@ -109,16 +109,14 @@ public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void } } -/** @Entity */ +#[Entity] class GH7820Line { public function __construct( - /** - * @Id() - * @Column(type="Doctrine\Tests\ORM\Functional\Ticket\GH7820LineTextType", length=255) - */ + #[Id] + #[Column(type: 'Doctrine\Tests\ORM\Functional\Ticket\GH7820LineTextType', length: 255)] private GH7820LineText $text, - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int $lineNumber, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php index 54090499e2a..b3be490ff8f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php @@ -82,21 +82,19 @@ public function testMatchingKeepsOrderOfCriteriaOrderingKeys(): void } } -/** @Entity */ +#[Entity] class GH7836ParentEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @var Collection - * @OneToMany(targetEntity=GH7836ChildEntity::class, mappedBy="parent", fetch="EXTRA_LAZY", cascade={"persist"}) - * @OrderBy({"position" = "ASC", "name" = "ASC"}) */ + #[OneToMany(targetEntity: GH7836ChildEntity::class, mappedBy: 'parent', fetch: 'EXTRA_LAZY', cascade: ['persist'])] + #[OrderBy(['position' => 'ASC', 'name' => 'ASC'])] private $children; public function addChild(int $position, string $name): void @@ -111,22 +109,20 @@ public function getChildren(): Collection } } -/** @Entity */ +#[Entity] class GH7836ChildEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; public function __construct( - /** @ManyToOne(targetEntity=GH7836ParentEntity::class, inversedBy="children") */ + #[ManyToOne(targetEntity: GH7836ParentEntity::class, inversedBy: 'children')] private GH7836ParentEntity $parent, - /** @Column(type="integer") */ + #[Column(type: 'integer')] public int $position, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php index 6c99afeee15..c60f3862a7f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php @@ -61,27 +61,27 @@ public function testExtraLazyRemoveElement(): void } } -/** @Entity */ +#[Entity] class GH7864User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @var Collection - * @OneToMany(targetEntity="GH7864Tweet", mappedBy="user", fetch="EXTRA_LAZY") */ + #[OneToMany(targetEntity: 'GH7864Tweet', mappedBy: 'user', fetch: 'EXTRA_LAZY')] public $tweets; public function __construct() @@ -96,26 +96,26 @@ public function addTweet(GH7864Tweet $tweet): void } } -/** @Entity */ +#[Entity] class GH7864Tweet { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $content; /** * @var GH7864User - * @ManyToOne(targetEntity="GH7864User", inversedBy="tweets") */ + #[ManyToOne(targetEntity: 'GH7864User', inversedBy: 'tweets')] public $user; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php index e2eec45b590..ab8876ba420 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php @@ -64,38 +64,38 @@ public function getClassMetadata($className): ClassMetadata } } -/** @Entity */ +#[Entity] class GH7869Appointment { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var GH7869Patient - * @OneToOne(targetEntity="GH7869Patient", inversedBy="appointment", fetch="EAGER") */ + #[OneToOne(targetEntity: 'GH7869Patient', inversedBy: 'appointment', fetch: 'EAGER')] public $patient; } -/** @Entity */ +#[Entity] class GH7869Patient { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var GH7869Appointment - * @OneToOne(targetEntity="GH7869Appointment", mappedBy="patient") */ + #[OneToOne(targetEntity: 'GH7869Appointment', mappedBy: 'patient')] public $appointment; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php index f405f78f15e..8f5a91b0938 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php @@ -89,32 +89,28 @@ public function testUpdateSchemaSqlWithSchemaAssetFilter(): void } } -/** - * @Entity - * @Table(name="gh7875_my_entity") - */ +#[Table(name: 'gh7875_my_entity')] +#[Entity] class GH7875MyEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } -/** - * @Entity - * @Table(name="gh7875_my_other_entity") - */ +#[Table(name: 'gh7875_my_other_entity')] +#[Entity] class GH7875MyOtherEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php index 8b2d4607162..1532af1ca60 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php @@ -86,30 +86,28 @@ public function typesShouldBeConvertedForDQLFunctions(): void } } -/** - * @Entity - * @Table() - */ +#[Table] +#[Entity] class GH7941Product { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var DateTimeImmutable - * @Column(type="datetime_immutable") */ + #[Column(type: 'datetime_immutable')] public $createdAt; public function __construct( - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string $name, - /** @Column(type="decimal", precision=10) */ + #[Column(type: 'decimal', precision: 10)] public string $price, ) { $this->createdAt = new DateTimeImmutable(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php index 9e22d4f9283..c4a1846142a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php @@ -42,33 +42,28 @@ public function testNumericDescriminatorColumn(): void } } -/** - * @Entity() - * @Table(name="gh8055") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="integer") - * @DiscriminatorMap({ - * "1" = GH8055BaseClass::class, - * "2" = GH8055SubClass::class - * }) - */ +#[Table(name: 'gh8055')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'integer')] +#[DiscriminatorMap([1 => GH8055BaseClass::class, 2 => GH8055SubClass::class])] class GH8055BaseClass { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; } -/** @Entity() */ +#[Entity] class GH8055SubClass extends GH8055BaseClass { /** - * @Column(name="test", type="string", length=255) * @var string */ + #[Column(name: 'test', type: 'string', length: 255)] public $value; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php index 914c0113a4e..4f4ec6aaf0a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php @@ -33,21 +33,21 @@ public function testConvertToPHPValueSQLForNewObjectExpression(): void } } -/** @Entity */ +#[Entity] final class GH8061Entity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var mixed - * @Column(type="GH8061Type", length=255) */ + #[Column(type: 'GH8061Type', length: 255)] public $field; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php index d598c4959d1..3726a4c8b98 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php @@ -43,22 +43,21 @@ public function testNoQueriesAfterSecondFlush(): void } } -/** @Entity */ +#[Entity] class GH8217Collection { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="GH8217CollectionItem", mappedBy="collection", - * cascade={"persist", "remove"}, orphanRemoval=true) */ + #[OneToMany(targetEntity: 'GH8217CollectionItem', mappedBy: 'collection', cascade: ['persist', 'remove'], orphanRemoval: true)] public $items; public function __construct() @@ -72,20 +71,16 @@ public function addItem(GH8217CollectionItem $item): void } } -/** @Entity */ +#[Entity] class GH8217CollectionItem { public function __construct( - /** - * @Id - * @ManyToOne(targetEntity="GH8217Collection", inversedBy="items") - * @JoinColumn(name="id", referencedColumnName="id") - */ + #[Id] + #[ManyToOne(targetEntity: 'GH8217Collection', inversedBy: 'items')] + #[JoinColumn(name: 'id', referencedColumnName: 'id')] public GH8217Collection $collection, - /** - * @Id - * @Column(type="integer", options={"unsigned": true}) - */ + #[Id] + #[Column(type: 'integer', options: ['unsigned' => true])] public int $collectionIndex, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php index d33bdc754f3..99726136dc6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php @@ -82,33 +82,27 @@ public function testJoinRootEntityWithOnlyOneEntityInHierarchy(): void $this->assertEquals('bar', $bar->getName()); } } -/** - * @Entity - * @Table(name="GH2947_foo") - * @InheritanceType("JOINED") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({ - * "foo" = "GH8443Foo" - * }) - */ +#[Table(name: 'GH2947_foo')] +#[Entity] +#[InheritanceType('JOINED')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['foo' => 'GH8443Foo'])] class GH8443Foo { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int|null $id = null; /** * @var GH8443Foo|null - * @OneToOne(targetEntity="GH8443Foo") - * @JoinColumn(name="bar_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'GH8443Foo')] + #[JoinColumn(name: 'bar_id', referencedColumnName: 'id')] private $bar; public function __construct( - /** @Column */ + #[Column] private string $name, ) { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php index 5ddb2fe0de9..0176c51047c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php @@ -108,37 +108,35 @@ public function testOptimisticLockWithDateTimeForVersionThrowsException(): void } } -/** - * @Entity - * @Table - */ +#[Table] +#[Entity] class GH8499VersionableEntity { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** - * @Column(type="string", length=255) * @var string */ + #[Column(type: 'string', length: 255)] public $name; /** - * @Column(type="string", length=255) * @var string */ + #[Column(type: 'string', length: 255)] public $description; /** - * @Version - * @Column(type="datetime") * @var DateTimeInterface */ + #[Version] + #[Column(type: 'datetime')] public $revision; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php index 8b111677d04..8d066463e03 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php @@ -29,21 +29,21 @@ public function testDeletedEntity(): void } } -/** @Entity */ +#[Entity] class GH8663VersionedEntity { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; /** - * @Version - * @Column(type="integer") * @var int */ + #[Version] + #[Column(type: 'integer')] protected $version; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php index f2745305968..1f396a86d3e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php @@ -27,29 +27,27 @@ public function testDiscriminatorMapWithSeveralLevelsIsSupported(): void } } -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class GH8914BaseEntity { } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"person" = "GH8914Person", "employee" = "GH8914Employee"}) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'discr', type: 'string')] +#[DiscriminatorMap(['person' => 'GH8914Person', 'employee' => 'GH8914Employee'])] class GH8914Person extends GH8914BaseEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class GH8914Employee extends GH8914Person { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php index 288ef33e5dd..91f26452fe4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php @@ -39,39 +39,39 @@ public function testUnitOfWorkHandlesNullRelations(): void } } -/** @Entity */ +#[Entity] class GH9027Customer { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var GH9027Cart - * @OneToOne(targetEntity="GH9027Cart", mappedBy="customer") */ + #[OneToOne(targetEntity: 'GH9027Cart', mappedBy: 'customer')] public $cart; } -/** @Entity */ +#[Entity] class GH9027Cart { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var GH9027Customer - * @OneToOne(targetEntity="GH9027Customer", inversedBy="cart") - * @JoinColumn(name="customer", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'GH9027Customer', inversedBy: 'cart')] + #[JoinColumn(name: 'customer', referencedColumnName: 'id')] public $customer; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php index ff665fb8359..d75963c1f48 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php @@ -86,24 +86,22 @@ public function testIssue(): void } } -/** @Entity */ +#[Entity] class GH9109Product { - /** - * @Column(name="`id`", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(name: '`id`', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(name="`title`", type="string", length=255) */ + #[Column(name: '`title`', type: 'string', length: 255)] private string|null $title = null; /** * @var Collection|GH9109User[] * @psalm-var Collection - * @ManyToMany(targetEntity="GH9109User") */ + #[ManyToMany(targetEntity: 'GH9109User')] private $buyers; public function __construct() @@ -138,20 +136,18 @@ public function addBuyer(GH9109User $buyer): void } } -/** @Entity */ +#[Entity] class GH9109User { - /** - * @Column(name="`id`", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") - */ + #[Column(name: '`id`', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(name="`first_name`", type="string", length=255) */ + #[Column(name: '`first_name`', type: 'string', length: 255)] private string|null $firstName = null; - /** @Column(name="last_name", type="string", length=255) */ + #[Column(name: 'last_name', type: 'string', length: 255)] private string|null $lastName = null; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php index 1908e71d6a6..bfa4659362f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php @@ -126,44 +126,44 @@ public function testIssue(string $property, $falsyValue, $truthyValue): void } -/** @Entity */ +#[Entity] class GH9230Entity { /** * @var int - * @Column(name="id", type="integer") - * @Id - * @GeneratedValue(strategy="AUTO") */ + #[Column(name: 'id', type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var ?string - * @Column(name="name", type="string", nullable=true) */ + #[Column(name: 'name', type: 'string', nullable: true)] public $name; /** * @var ?int - * @Column(name="counter", type="integer", nullable=true) */ + #[Column(name: 'counter', type: 'integer', nullable: true)] public $counter; /** * @var ?bool - * @Column(name="enabled", type="boolean", nullable=true) */ + #[Column(name: 'enabled', type: 'boolean', nullable: true)] public $enabled; /** * @var ?float - * @Column(name="price", type="decimal", scale=1, precision=2, nullable=true) */ + #[Column(name: 'price', type: 'decimal', scale: 1, precision: 2, nullable: true)] public $price; /** * @var mixed[] - * @Column(name="extra", type="json", nullable=true) */ + #[Column(name: 'extra', type: 'json', nullable: true)] public $extra; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php index fa9b5b994e9..05d9e92c3e8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php @@ -102,27 +102,27 @@ public function __toString(): string } } -/** @Entity */ +#[Entity] class GH9335Book { /** * @var GH9335IntObject - * @Id - * @Column(type=GH9335IntObjectType::class, unique=true) */ + #[Id] + #[Column(type: GH9335IntObjectType::class, unique: true)] private $id; /** - * @Column(type="string") * @var string */ + #[Column(type: 'string')] private $title; /** - * @OneToOne(targetEntity="GH9335Author", mappedBy="book", cascade={"persist", "remove"}) * @var GH9335Author */ + #[OneToOne(targetEntity: 'GH9335Author', mappedBy: 'book', cascade: ['persist', 'remove'])] private $author; public function __construct(GH9335IntObject $id, string $title, GH9335Author|null $author = null) @@ -170,21 +170,21 @@ public function setAuthor(GH9335Author|null $author): self } } -/** @Entity */ +#[Entity] class GH9335Author { /** * @var GH9335Book - * @Id - * @OneToOne(targetEntity="GH9335Book", inversedBy="author") - * @JoinColumn(name="book") */ + #[Id] + #[OneToOne(targetEntity: 'GH9335Book', inversedBy: 'author')] + #[JoinColumn(name: 'book')] private $book; /** - * @Column(type="string", nullable="true" ) * @var string */ + #[Column(type: 'string', nullable: true)] private $name; public function __construct(string|null $name) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php index a087d5205f1..74c685f378b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php @@ -65,24 +65,22 @@ public function testIssue(): void } } -/** - * @Entity - * @Table(name="GH9579_containers") - */ +#[Table(name: 'GH9579_containers')] +#[Entity] class GH9579Container { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var Collection - * @OneToMany (targetEntity="GH9579Item", mappedBy="container") */ + #[OneToMany(targetEntity: 'GH9579Item', mappedBy: 'container')] public $items; public function __construct() @@ -92,16 +90,14 @@ public function __construct() /** * @var GH9579Item - * @OneToOne(targetEntity="GH9579Item") - * @JoinColumn(name="item_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'GH9579Item')] + #[JoinColumn(name: 'item_id', referencedColumnName: 'id')] public $currentItem; } -/** - * @Entity - * @Table(name="GH9579_items") - */ +#[Table(name: 'GH9579_items')] +#[Entity] class GH9579Item { public function __construct() @@ -110,45 +106,43 @@ public function __construct() } /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var Collection - * @OneToMany(targetEntity="GH9579Part", mappedBy="item") */ + #[OneToMany(targetEntity: 'GH9579Part', mappedBy: 'item')] public $parts; /** * @var GH9579Container - * @ManyToOne (targetEntity="GH9579Container", inversedBy="items") - * @JoinColumn(name="container_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'GH9579Container', inversedBy: 'items')] + #[JoinColumn(name: 'container_id', referencedColumnName: 'id')] public $container; } -/** - * @Entity - * @Table(name="GH9579_parts") - */ +#[Table(name: 'GH9579_parts')] +#[Entity] class GH9579Part { /** - * @Id - * @Column(type="integer") - * @GeneratedValue * @var int */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var GH9579Item - * @ManyToOne (targetEntity="GH9579Item", inversedBy="parts") - * @JoinColumn(name="item_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: 'GH9579Item', inversedBy: 'parts')] + #[JoinColumn(name: 'item_id', referencedColumnName: 'id')] public $item; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php index 106c7c7744e..553ee9a998f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php @@ -73,22 +73,21 @@ public function testHydrateJoinedCollectionWithFirstNullishRow(): void } } -/** @Entity */ +#[Entity] class GH9807Main { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] private $id; /** - * @ORM\ManyToMany(targetEntity="GH9807Join", inversedBy="starts") - * * @var Collection */ + #[ORM\ManyToMany(targetEntity: 'GH9807Join', inversedBy: 'starts')] private $joins; /** @return Collection */ @@ -98,28 +97,26 @@ public function getJoins(): Collection } } -/** @Entity */ +#[Entity] class GH9807Join { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue] private $id; /** - * @ORM\ManyToMany(targetEntity="GH9807Main", mappedBy="bases") - * * @var Collection */ + #[ORM\ManyToMany(targetEntity: 'GH9807Main', mappedBy: 'bases')] private $mains; /** - * @ORM\Column(type="string", nullable=false) - * * @var string */ + #[ORM\Column(type: 'string', nullable: false)] private $value; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php index b1702fbaf19..82a448ccb5b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php @@ -30,17 +30,15 @@ public function testEmptyInsert(): void } } -/** - * @Entity - * @Table(name="ticket_2481_products") - */ +#[Table(name: 'ticket_2481_products')] +#[Entity] class Ticket2481Product { /** - * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + * @var int + */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php index b3d9d7c64f0..c9aea38997e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php @@ -41,22 +41,16 @@ public function testInstanceOf(): void } } -/** - * @Entity() - * @Table(name="instance_of_abstract_test_person") - * @InheritanceType(value="JOINED") - * @DiscriminatorColumn(name="kind", type="string") - * @DiscriminatorMap(value={ - * "employee": EmployeeTicket4646Abstract::class - * }) - */ +#[Table(name: 'instance_of_abstract_test_person')] +#[Entity] +#[InheritanceType(value: 'JOINED')] +#[DiscriminatorColumn(name: 'kind', type: 'string')] +#[DiscriminatorMap(value: ['employee' => EmployeeTicket4646Abstract::class])] abstract class PersonTicket4646Abstract { - /** - * @Id() - * @GeneratedValue() - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; public function getId(): int|null @@ -65,10 +59,8 @@ public function getId(): int|null } } -/** - * @Entity() - * @Table(name="instance_of_abstract_test_employee") - */ +#[Table(name: 'instance_of_abstract_test_employee')] +#[Entity] class EmployeeTicket4646Abstract extends PersonTicket4646Abstract { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php index da4e98e01ac..fd234d8fb21 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php @@ -44,24 +44,16 @@ public function testInstanceOf(): void } } -/** - * @Entity() - * @Table(name="instance_of_multi_level_test_person") - * @InheritanceType(value="JOINED") - * @DiscriminatorColumn(name="kind", type="string") - * @DiscriminatorMap(value={ - * "person": "Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646MultiLevel", - * "employee": "Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646MultiLevel", - * "engineer": "Doctrine\Tests\ORM\Functional\Ticket\EngineerTicket4646MultiLevel", - * }) - */ +#[Table(name: 'instance_of_multi_level_test_person')] +#[Entity] +#[InheritanceType(value: 'JOINED')] +#[DiscriminatorColumn(name: 'kind', type: 'string')] +#[DiscriminatorMap(value: ['person' => 'Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646MultiLevel', 'employee' => 'Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646MultiLevel', 'engineer' => 'Doctrine\Tests\ORM\Functional\Ticket\EngineerTicket4646MultiLevel'])] class PersonTicket4646MultiLevel { - /** - * @Id() - * @GeneratedValue() - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; public function getId(): int|null @@ -70,18 +62,14 @@ public function getId(): int|null } } -/** - * @Entity() - * @Table(name="instance_of_multi_level_employee") - */ +#[Table(name: 'instance_of_multi_level_employee')] +#[Entity] class EmployeeTicket4646MultiLevel extends PersonTicket4646MultiLevel { } -/** - * @Entity() - * @Table(name="instance_of_multi_level_engineer") - */ +#[Table(name: 'instance_of_multi_level_engineer')] +#[Entity] class EngineerTicket4646MultiLevel extends EmployeeTicket4646MultiLevel { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php index 56e17b3e42a..65fabd30487 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php @@ -43,23 +43,16 @@ public function testInstanceOf(): void } } -/** - * @Entity() - * @Table(name="instance_of_parametric_person") - * @InheritanceType(value="JOINED") - * @DiscriminatorColumn(name="kind", type="string") - * @DiscriminatorMap(value={ - * "person": "Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Parametric", - * "employee": "Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646Parametric" - * }) - */ +#[Table(name: 'instance_of_parametric_person')] +#[Entity] +#[InheritanceType(value: 'JOINED')] +#[DiscriminatorColumn(name: 'kind', type: 'string')] +#[DiscriminatorMap(value: ['person' => 'Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Parametric', 'employee' => 'Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646Parametric'])] class PersonTicket4646Parametric { - /** - * @Id() - * @GeneratedValue() - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; public function getId(): int|null @@ -68,10 +61,8 @@ public function getId(): int|null } } -/** - * @Entity() - * @Table(name="instance_of_parametric_employee") - */ +#[Table(name: 'instance_of_parametric_employee')] +#[Entity] class EmployeeTicket4646Parametric extends PersonTicket4646Parametric { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php index 8850bb12646..803892768e1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php @@ -42,23 +42,16 @@ public function testInstanceOf(): void } } -/** - * @Entity() - * @Table(name="instance_of_test_person") - * @InheritanceType(value="JOINED") - * @DiscriminatorColumn(name="kind", type="string") - * @DiscriminatorMap(value={ - * "person": "Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646", - * "employee": "Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646" - * }) - */ +#[Table(name: 'instance_of_test_person')] +#[Entity] +#[InheritanceType(value: 'JOINED')] +#[DiscriminatorColumn(name: 'kind', type: 'string')] +#[DiscriminatorMap(value: ['person' => 'Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646', 'employee' => 'Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646'])] class PersonTicket4646 { - /** - * @Id() - * @GeneratedValue() - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; public function getId(): int|null @@ -67,10 +60,8 @@ public function getId(): int|null } } -/** - * @Entity() - * @Table(name="instance_of_test_employee") - */ +#[Table(name: 'instance_of_test_employee')] +#[Entity] class EmployeeTicket4646 extends PersonTicket4646 { } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php index 1bae12a5b0f..1bece72951f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php @@ -46,25 +46,16 @@ public function testInstanceOf(): void } } -/** - * @Entity() - * @Table(name="instance_of_test_multiple_person") - * @InheritanceType(value="JOINED") - * @DiscriminatorColumn(name="kind", type="string") - * @DiscriminatorMap(value={ - * "person": "Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Multiple", - * "employee": "Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646Multiple", - * "manager": "Doctrine\Tests\ORM\Functional\Ticket\ManagerTicket4646Multiple", - * "intern": "Doctrine\Tests\ORM\Functional\Ticket\InternTicket4646Multiple" - * }) - */ +#[Table(name: 'instance_of_test_multiple_person')] +#[Entity] +#[InheritanceType(value: 'JOINED')] +#[DiscriminatorColumn(name: 'kind', type: 'string')] +#[DiscriminatorMap(value: ['person' => 'Doctrine\Tests\ORM\Functional\Ticket\PersonTicket4646Multiple', 'employee' => 'Doctrine\Tests\ORM\Functional\Ticket\EmployeeTicket4646Multiple', 'manager' => 'Doctrine\Tests\ORM\Functional\Ticket\ManagerTicket4646Multiple', 'intern' => 'Doctrine\Tests\ORM\Functional\Ticket\InternTicket4646Multiple'])] class PersonTicket4646Multiple { - /** - * @Id() - * @GeneratedValue() - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; public function getId(): int @@ -73,26 +64,20 @@ public function getId(): int } } -/** - * @Entity() - * @Table(name="instance_of_test_multiple_employee") - */ +#[Table(name: 'instance_of_test_multiple_employee')] +#[Entity] class EmployeeTicket4646Multiple extends PersonTicket4646Multiple { } -/** - * @Entity() - * @Table(name="instance_of_test_multiple_manager") - */ +#[Table(name: 'instance_of_test_multiple_manager')] +#[Entity] class ManagerTicket4646Multiple extends PersonTicket4646Multiple { } -/** - * @Entity() - * @Table(name="instance_of_test_multiple_intern") - */ +#[Table(name: 'instance_of_test_multiple_intern')] +#[Entity] class InternTicket4646Multiple extends PersonTicket4646Multiple { } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 38328e9af09..53549eca8f6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -349,319 +349,311 @@ public function getInfiniteEmbeddableNestingData(): array } -/** @Entity */ +#[Entity] class DDC93Person { /** * @var int - * @Id - * @GeneratedValue - * @Column(type="integer") */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] public $id; /** * @var DDC93Timestamps - * @Embedded(class = "DDC93Timestamps") */ + #[Embedded(class: 'DDC93Timestamps')] public $timestamps; public function __construct( /** * @var string|null - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name = null, - /** @Embedded(class="DDC93Address") */ + #[Embedded(class: 'DDC93Address')] public DDC93Address|null $address = null, ) { $this->timestamps = new DDC93Timestamps(new DateTime()); } } -/** @Embeddable */ +#[Embeddable] class DDC93Timestamps { public function __construct( - /** @Column(type = "datetime") */ + #[Column(type: 'datetime')] public DateTime $createdAt, ) { } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name = "t", type = "string", length = 10) - * @DiscriminatorMap({ - * "v" = "Doctrine\Tests\ORM\Functional\DDC93Car", - * }) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 't', type: 'string', length: 10)] +#[DiscriminatorMap(['v' => 'Doctrine\Tests\ORM\Functional\DDC93Car'])] abstract class DDC93Vehicle { /** * @var int - * @Id - * @GeneratedValue(strategy = "AUTO") - * @Column(type = "integer") */ + #[Id] + #[GeneratedValue(strategy: 'AUTO')] + #[Column(type: 'integer')] public $id; public function __construct( - /** @Embedded(class = "DDC93Address") */ + #[Embedded(class: 'DDC93Address')] public DDC93Address $address, ) { } } -/** @Entity */ +#[Entity] class DDC93Car extends DDC93Vehicle { } -/** @Embeddable */ +#[Embeddable] class DDC93Country { public function __construct( - /** @Column(type="string", nullable=true) */ + #[Column(type: 'string', nullable: true)] public string|null $name = null, ) { } } -/** @Embeddable */ +#[Embeddable] class DDC93Address { public function __construct( /** * @var string|null - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $street = null, /** * @var string|null - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $zip = null, - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public string|null $city = null, /** * @var DDC93Country|null - * @Embedded(class = "DDC93Country") */ + #[Embedded(class: 'DDC93Country')] public $country = null, ) { } } -/** @Entity */ +#[Entity] class DDC93Customer { - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(type: 'integer')] private int $id; - /** @Embedded(class = "DDC93ContactInfo", columnPrefix = "contact_info_") */ + #[Embedded(class: 'DDC93ContactInfo', columnPrefix: 'contact_info_')] private DDC93ContactInfo $contactInfo; } -/** @Embeddable */ +#[Embeddable] class DDC93ContactInfo { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $email; /** * @var DDC93Address - * @Embedded(class = "DDC93Address") */ + #[Embedded(class: 'DDC93Address')] public $address; } -/** @Entity */ +#[Entity] class DDC3028PersonWithPrefix { public function __construct( - /** @Embedded(class="DDC3028Id", columnPrefix = "foobar_") */ + #[Embedded(class: 'DDC3028Id', columnPrefix: 'foobar_')] public DDC3028Id|null $id = null, - /** @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "bloo_") */ + #[Embedded(class: 'DDC3028NestedEmbeddable', columnPrefix: 'bloo_')] public DDC3028NestedEmbeddable|null $nested = null, ) { } } -/** @Entity */ +#[Entity] class DDC3028PersonEmptyPrefix { public function __construct( - /** @Embedded(class="DDC3028Id", columnPrefix = "") */ + #[Embedded(class: 'DDC3028Id', columnPrefix: '')] public DDC3028Id|null $id = null, - /** @Embedded(class="DDC3028NestedEmbeddable", columnPrefix = "") */ + #[Embedded(class: 'DDC3028NestedEmbeddable', columnPrefix: '')] public DDC3028NestedEmbeddable|null $nested = null, ) { } } -/** @Entity */ +#[Entity] class DDC3028PersonPrefixFalse { public function __construct( - /** @Embedded(class="DDC3028Id", columnPrefix = false) */ + #[Embedded(class: 'DDC3028Id', columnPrefix: false)] public DDC3028Id|null $id = null, ) { } } -/** @Embeddable */ +#[Embeddable] class DDC3028Id { public function __construct( - /** - * @Id - * @Column(type="string", length=255) - */ + #[Id] + #[Column(type: 'string', length: 255)] public string|null $id = null, ) { } } -/** @Embeddable */ +#[Embeddable] class DDC3028NestedEmbeddable { public function __construct( - /** @Embedded(class="DDC3028Id", columnPrefix = "foo_") */ + #[Embedded(class: 'DDC3028Id', columnPrefix: 'foo_')] public DDC3028Id|null $nestedWithPrefix = null, - /** @Embedded(class="DDC3028Id", columnPrefix = "") */ + #[Embedded(class: 'DDC3028Id', columnPrefix: '')] public DDC3028Id|null $nestedWithEmptyPrefix = null, - /** @Embedded(class="DDC3028Id", columnPrefix = false) */ + #[Embedded(class: 'DDC3028Id', columnPrefix: false)] public DDC3028Id|null $nestedWithPrefixFalse = null, ) { } } -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class DDC3027Animal { /** * @var int - * @Id - * @GeneratedValue(strategy = "AUTO") - * @Column(type = "integer") */ + #[Id] + #[GeneratedValue(strategy: 'AUTO')] + #[Column(type: 'integer')] public $id; /** * @var DDC93Address - * @Embedded(class = "DDC93Address") */ + #[Embedded(class: 'DDC93Address')] public $address; } -/** @Entity */ +#[Entity] class DDC3027Dog extends DDC3027Animal { } -/** @Embeddable */ +#[Embeddable] class DDCInfiniteNestingEmbeddable { /** * @var DDCInfiniteNestingEmbeddable - * @Embedded(class="DDCInfiniteNestingEmbeddable") */ + #[Embedded(class: 'DDCInfiniteNestingEmbeddable')] public $nested; } -/** @Embeddable */ +#[Embeddable] class DDCNestingEmbeddable1 { /** * @var DDC3028Id - * @Embedded(class="DDC3028Id") */ + #[Embedded(class: 'DDC3028Id')] public $id1; /** * @var DDC3028Id - * @Embedded(class="DDC3028Id") */ + #[Embedded(class: 'DDC3028Id')] public $id2; /** * @var DDCNestingEmbeddable2 - * @Embedded(class="DDCNestingEmbeddable2") */ + #[Embedded(class: 'DDCNestingEmbeddable2')] public $nested; } -/** @Embeddable */ +#[Embeddable] class DDCNestingEmbeddable2 { /** * @var DDC3028Id - * @Embedded(class="DDC3028Id") */ + #[Embedded(class: 'DDC3028Id')] public $id1; /** * @var DDC3028Id - * @Embedded(class="DDC3028Id") */ + #[Embedded(class: 'DDC3028Id')] public $id2; /** * @var DDCNestingEmbeddable3 - * @Embedded(class="DDCNestingEmbeddable3") */ + #[Embedded(class: 'DDCNestingEmbeddable3')] public $nested; } -/** @Embeddable */ +#[Embeddable] class DDCNestingEmbeddable3 { /** * @var DDC3028Id - * @Embedded(class="DDC3028Id") */ + #[Embedded(class: 'DDC3028Id')] public $id1; /** * @var DDC3028Id - * @Embedded(class="DDC3028Id") */ + #[Embedded(class: 'DDC3028Id')] public $id2; /** * @var DDCNestingEmbeddable4 - * @Embedded(class="DDCNestingEmbeddable4") */ + #[Embedded(class: 'DDCNestingEmbeddable4')] public $nested; } -/** @Embeddable */ +#[Embeddable] class DDCNestingEmbeddable4 { /** * @var DDC3028Id - * @Embedded(class="DDC3028Id") */ + #[Embedded(class: 'DDC3028Id')] public $id1; /** * @var DDC3028Id - * @Embedded(class="DDC3028Id") */ + #[Embedded(class: 'DDC3028Id')] public $id2; /** * @var DDCNestingEmbeddable1 - * @Embedded(class="DDCNestingEmbeddable1") */ + #[Embedded(class: 'DDCNestingEmbeddable1')] public $nested; } diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php index d8bf42559a1..a1c25c7d444 100644 --- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -58,31 +58,31 @@ public function testCorrectIdGeneration(): void } } -/** @Entity */ +#[Entity] class AssignedSingleIdEntity { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $myId; } -/** @Entity */ +#[Entity] class AssignedCompositeIdEntity { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $myId1; /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $myId2; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 3356abae711..e9887ff4942 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -228,32 +228,28 @@ class TransientBaseClass private $transient2; } -/** @Entity */ +#[Entity] class EntitySubClass extends TransientBaseClass { - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] private int $id; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name; } -/** @MappedSuperclass */ +#[MappedSuperclass] class MappedSuperclassBase { - /** @Column(type="integer") */ + #[Column(type: 'integer')] private int $mapped1; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $mapped2; - /** - * @OneToOne(targetEntity="MappedSuperclassRelated1") - * @JoinColumn(name="related1_id", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'MappedSuperclassRelated1')] + #[JoinColumn(name: 'related1_id', referencedColumnName: 'id')] private MappedSuperclassRelated1 $mappedRelated1; /** @var mixed */ @@ -264,151 +260,137 @@ class MappedSuperclassRelated1 { } -/** @Entity */ +#[Entity] class EntitySubClass2 extends MappedSuperclassBase { - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] private int $id; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name; } -/** - * @MappedSuperclass - * @Table( - * uniqueConstraints={@UniqueConstraint(name="IDX_MAPPED1_INDEX",columns={"mapped1"})}, - * indexes={@Index(name="IDX_MAPPED2_INDEX", columns={"mapped2"})} - * ) - */ +#[Table] +#[Index(name: 'IDX_MAPPED2_INDEX', columns: ['mapped2'])] +#[UniqueConstraint(name: 'IDX_MAPPED1_INDEX', columns: ['mapped1'])] +#[MappedSuperclass] class MappedSuperclassBaseIndex { - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $mapped1; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $mapped2; } -/** - * @Entity - * @Table(uniqueConstraints={@UniqueConstraint(name="IDX_NAME_INDEX",columns={"name"})}) - */ +#[Table] +#[UniqueConstraint(name: 'IDX_NAME_INDEX', columns: ['name'])] +#[Entity] class EntityIndexSubClass extends MappedSuperclassBaseIndex { - /** - * @Id - * @Column(type="integer") - */ + #[Id] + #[Column(type: 'integer')] private int $id; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name; } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorColumn(name="type", type="string", length=20) - * @DiscriminatorMap({ - * "c" = "HierarchyC", - * "d" = "HierarchyD", - * "e" = "HierarchyE" - * }) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorColumn(name: 'type', type: 'string', length: 20)] +#[DiscriminatorMap(['c' => 'HierarchyC', 'd' => 'HierarchyD', 'e' => 'HierarchyE'])] abstract class HierarchyBase { /** - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="SEQUENCE") - * @SequenceGenerator(sequenceName="foo", initialValue=10) * @var int */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'SEQUENCE')] + #[SequenceGenerator(sequenceName: 'foo', initialValue: 10)] public $id; } -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class HierarchyASuperclass extends HierarchyBase { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $a; } -/** @Entity */ +#[Entity] class HierarchyBEntity extends HierarchyBase { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $b; } -/** @Entity */ +#[Entity] class HierarchyC extends HierarchyBase { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $c; } -/** @Entity */ +#[Entity] class HierarchyD extends HierarchyASuperclass { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $d; } -/** @Entity */ +#[Entity] class HierarchyE extends HierarchyBEntity { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $e; } -/** @Entity */ +#[Entity] class SuperclassEntity extends SuperclassBase { } -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class SuperclassBase { /** * @var int - * @Column(type="integer") - * @Id - * @GeneratedValue(strategy="SEQUENCE") - * @SequenceGenerator(sequenceName="foo", initialValue=10) */ + #[Column(type: 'integer')] + #[Id] + #[GeneratedValue(strategy: 'SEQUENCE')] + #[SequenceGenerator(sequenceName: 'foo', initialValue: 10)] public $id; } -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class MediumSuperclassBase extends SuperclassBase { } -/** @Entity */ +#[Entity] class MediumSuperclassEntity extends MediumSuperclassBase { } -/** @Entity(repositoryClass = "Doctrine\ORM\EntityRepository") */ +#[Entity(repositoryClass: 'Doctrine\ORM\EntityRepository')] class SubclassWithRepository extends DDC869Payment { } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index bd756345399..ecc7bdb0ce6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -468,24 +468,22 @@ public function testInvalidSubClassCase(): void } } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"cube" = cube::class}) - * @DiscriminatorColumn(name="discr", length=32, type="string") - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorMap(['cube' => cube::class])] +#[DiscriminatorColumn(name: 'discr', length: 32, type: 'string')] abstract class Shape { /** * @var string - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'AUTO')] public $id; } -/** @Entity */ +#[Entity] final class Cube extends Shape { } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index 80c9b34303e..d4fc5afc5e3 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -41,20 +41,16 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void } } -/** - * @Entity - * @Table(name="load_event_test_entity") - */ +#[Table(name: 'load_event_test_entity')] +#[Entity] class LoadEventTestEntity { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private string $name; /** @var mixed */ diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 9e7545fca1e..cada4e039c4 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -934,13 +934,13 @@ public function testInlineEmbeddable(): void } } -/** @MappedSuperclass */ +#[MappedSuperclass] class DDC2700MappedSuperClass { /** * @var mixed - * @Column */ + #[Column] private $foo; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 1aee7301855..302bbff8244 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -1157,32 +1157,29 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** - * @Entity - * @Table( - * indexes={@Index(name="name_idx", columns={"name"}, fields={"email"})}, - * ) - */ +#[Table] +#[Index(name: 'name_idx', columns: ['name'], fields: ['email'])] +#[Entity] class UserIncorrectIndex { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") **/ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column */ + #[Column] public $name; /** * @var string - * @Column(name="user_email") */ + #[Column(name: 'user_email')] public $email; public static function loadMetadata(ClassMetadata $metadata): void @@ -1216,32 +1213,29 @@ public static function loadMetadata(ClassMetadata $metadata): void } } -/** - * @Entity - * @Table( - * uniqueConstraints={@UniqueConstraint(name="name_idx", columns={"name"}, fields={"email"})}, - * ) - */ +#[Table] +#[UniqueConstraint(name: 'name_idx', columns: ['name'], fields: ['email'])] +#[Entity] class UserIncorrectUniqueConstraint { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") **/ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; /** * @var string - * @Column */ + #[Column] public $name; /** * @var string - * @Column(name="user_email") */ + #[Column(name: 'user_email')] public $email; public static function loadMetadata(ClassMetadata $metadata): void diff --git a/tests/Doctrine/Tests/ORM/ORMSetupTest.php b/tests/Doctrine/Tests/ORM/ORMSetupTest.php index 4785107e22a..c1a23df7af6 100644 --- a/tests/Doctrine/Tests/ORM/ORMSetupTest.php +++ b/tests/Doctrine/Tests/ORM/ORMSetupTest.php @@ -83,7 +83,7 @@ public function testConfigureCacheCustomInstance(): void class AnnotatedDummy { - /** @AnnotationNamespace\PrePersist */ + #[AnnotationNamespace\PrePersist] public function namespacedAnnotationMethod(): void { } diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index a9ac1bcaa30..f332f6799ee 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -659,31 +659,27 @@ public function testStringPrimaryAcceptsAggregateExpression(): void } } -/** @Entity */ +#[Entity] class DQLKeywordsModelUser { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @OneToOne(targetEntity="DQLKeywordsModelGroup") */ + #[OneToOne(targetEntity: 'DQLKeywordsModelGroup')] private DQLKeywordsModelGroup $group; } -/** @Entity */ +#[Entity] class DQLKeywordsModelGroup { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @Column */ + #[Column] private string $from; } diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 2bf55a7ba11..717e881e161 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -2194,32 +2194,32 @@ public function parse(Parser $parser): void $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } -/** @Entity */ +#[Entity] class DDC1384Model { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalkerFooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; } -/** @Entity */ +#[Entity] class DDC1474Entity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue() */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] protected $id; public function __construct( - /** @Column(type="float") */ + #[Column(type: 'float')] private string $value, ) { } diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php index ab86d00c029..d0642dfb934 100644 --- a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php @@ -112,30 +112,28 @@ public function testDuplicateEntityListenerException(): void } } -/** @Entity */ +#[Entity] class AttachEntityListenersListenerTestFooEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } -/** - * @Entity - * @EntityListeners({"AttachEntityListenersListenerTestListener"}) - */ +#[Entity] +#[EntityListeners(['AttachEntityListenersListenerTestListener'])] class AttachEntityListenersListenerTestBarEntity { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] public $id; } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php index 0570cd6f6ac..9d9e26aac20 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php @@ -10,24 +10,22 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; -/** - * @Entity - * @Table(name="keyboard") - */ +#[Table(name: 'keyboard')] +#[Entity] final class Keyboard { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="NONE") */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'NONE')] private $id; /** * @var string - * @Column(type="string", length=255); */ + #[Column(type: 'string', length: 255)] private $name; public function __construct(int $id, string $name) diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php index 9c403e8bca5..5da91b8c4f9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php @@ -146,68 +146,68 @@ public function testFilterWithRegex(): void } } -/** @Entity */ +#[Entity] class MetadataFilterTestEntityAaa { /** * @var int - * @Id - * @Column */ + #[Id] + #[Column] protected $id; } -/** @Entity */ +#[Entity] class MetadataFilterTestEntityBbb { /** * @var int - * @Id - * @Column */ + #[Id] + #[Column] protected $id; } -/** @Entity */ +#[Entity] class MetadataFilterTestEntityCcc { /** * @var int - * @Id - * @Column */ + #[Id] + #[Column] protected $id; } -/** @Entity */ +#[Entity] class MetadataFilterTestEntityFoo { /** * @var int - * @Id - * @Column */ + #[Id] + #[Column] protected $id; } -/** @Entity */ +#[Entity] class MetadataFilterTestEntityBar { /** * @var int - * @Id - * @Column */ + #[Id] + #[Column] protected $id; } -/** @Entity */ +#[Entity] class MetadataFilterTestEntityFooBar { /** * @var int - * @Id - * @Column */ + #[Id] + #[Column] protected $id; } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php index defad03c55f..d040200fbae 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Tools\Pagination; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; @@ -31,241 +32,235 @@ protected function setUp(): void } -/** @Entity */ +#[Entity] class MyBlogPost { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var Author - * @ManyToOne(targetEntity="Author") */ + #[ManyToOne(targetEntity: 'Author')] public $author; /** * @var Category - * @ManyToOne(targetEntity="Category") */ + #[ManyToOne(targetEntity: 'Category')] public $category; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $title; } -/** @Entity */ +#[Entity] class MyAuthor { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class MyCategory { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class BlogPost { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var Author - * @ManyToOne(targetEntity="Author") */ + #[ManyToOne(targetEntity: 'Author')] public $author; /** * @var Category - * @ManyToOne(targetEntity="Category") */ + #[ManyToOne(targetEntity: 'Category')] public $category; } -/** @Entity */ +#[Entity] class Author { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; } -/** @Entity */ +#[Entity] class Person { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $biography; } -/** @Entity */ +#[Entity] class Category { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; } -/** - * @Entity - * @Table(name="groups") - */ +#[Table(name: 'groups')] +#[Entity] class Group { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity="User", mappedBy="groups") */ + #[ManyToMany(targetEntity: 'User', mappedBy: 'groups')] public $users; } -/** @Entity */ +#[Entity] class User { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity="Group", inversedBy="users") - * @JoinTable( - * name="user_group", - * joinColumns = {@JoinColumn(name="user_id", referencedColumnName="id")}, - * inverseJoinColumns = {@JoinColumn(name="group_id", referencedColumnName="id")} - * ) */ + #[JoinTable(name: 'user_group')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] + #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] + #[ManyToMany(targetEntity: 'Group', inversedBy: 'users')] public $groups; /** * @var Avatar - * @OneToOne(targetEntity="Avatar", mappedBy="user") */ + #[OneToOne(targetEntity: 'Avatar', mappedBy: 'user')] public $avatar; } -/** @Entity */ +#[Entity] class Avatar { /** * @var int - * @Id - * @Column(type="integer") - * @GeneratedValue */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] public $id; /** * @var User - * @OneToOne(targetEntity="User", inversedBy="avatar") - * @JoinColumn(name="user_id", referencedColumnName="id") */ + #[OneToOne(targetEntity: 'User', inversedBy: 'avatar')] + #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $image; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $imageHeight; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $imageWidth; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $imageAltDesc; } -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class Identified { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; public function getId(): int @@ -274,12 +269,12 @@ public function getId(): int } } -/** @Entity */ +#[Entity] class Banner extends Identified { /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] public $name; } diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index f99a7a4e076..9af862a92a1 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -119,35 +119,31 @@ interface Target extends ResolveTarget { } -/** @Entity */ +#[Entity] class ResolveTargetEntity implements ResolveTarget { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; /** * @psalm-var Collection - * @ManyToMany(targetEntity="Doctrine\Tests\ORM\Tools\Target") */ + #[ManyToMany(targetEntity: 'Doctrine\Tests\ORM\Tools\Target')] private $manyToMany; - /** @ManyToOne(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTarget", inversedBy="oneToMany") */ + #[ManyToOne(targetEntity: 'Doctrine\Tests\ORM\Tools\ResolveTarget', inversedBy: 'oneToMany')] private ResolveTarget $manyToOne; /** * @psalm-var Collection - * @OneToMany(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTarget", mappedBy="manyToOne") */ + #[OneToMany(targetEntity: 'Doctrine\Tests\ORM\Tools\ResolveTarget', mappedBy: 'manyToOne')] private $oneToMany; - /** - * @OneToOne(targetEntity="Doctrine\Tests\ORM\Tools\Target") - * @JoinColumn(name="target_entity_id", referencedColumnName="id") - */ + #[OneToOne(targetEntity: 'Doctrine\Tests\ORM\Tools\Target')] + #[JoinColumn(name: 'target_entity_id', referencedColumnName: 'id')] private Target $oneToOne; public function getId(): int @@ -156,14 +152,12 @@ public function getId(): int } } -/** @Entity */ +#[Entity] class TargetEntity implements Target { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue(strategy: 'AUTO')] private int $id; public function getId(): int diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index a49420a66a0..5473e5bcdb2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -372,19 +372,15 @@ public function testConfigurationSchemaIgnoredEntity(): void } } -/** - * @Entity - * @Table(options={"foo": "bar", "baz": {"key": "val"}}) - */ +#[Table(options: ['foo' => 'bar', 'baz' => ['key' => 'val']])] +#[Entity] class TestEntityWithAnnotationOptionsAttribute { - /** - * @Id - * @Column - */ + #[Id] + #[Column] private int $id; - /** @Column(type="string", options={"foo": "bar", "baz": {"key": "val"}}) */ + #[Column(type: 'string', options: ['foo' => 'bar', 'baz' => ['key' => 'val']])] private string $test; } @@ -407,143 +403,126 @@ public function postGenerateSchema(GenerateSchemaEventArgs $eventArgs): void } } -/** - * @Entity - * @Table(name="unique_constraint_annotation_table", uniqueConstraints={ - * @UniqueConstraint(name="uniq_hash", columns={"hash"}) - * }) - */ +#[Table(name: 'unique_constraint_annotation_table')] +#[UniqueConstraint(name: 'uniq_hash', columns: ['hash'])] +#[Entity] class UniqueConstraintAnnotationModel { - /** - * @Id - * @Column - */ + #[Id] + #[Column] private int $id; - /** @Column(name="hash", type="string", length=8, nullable=false, unique=true) */ + #[Column(name: 'hash', type: 'string', length: 8, nullable: false, unique: true)] private string $hash; } -/** - * @Entity - * @Table(name="first_entity") - */ +#[Table(name: 'first_entity')] +#[Entity] class FirstEntity { /** * @var int - * @Id - * @Column(name="id") */ + #[Id] + #[Column(name: 'id')] public $id; /** * @var SecondEntity - * @OneToOne(targetEntity="SecondEntity") - * @JoinColumn(name="id", referencedColumnName="first_entity_id") */ + #[OneToOne(targetEntity: 'SecondEntity')] + #[JoinColumn(name: 'id', referencedColumnName: 'first_entity_id')] public $secondEntity; /** * @var string - * @Column(name="name") */ + #[Column(name: 'name')] public $name; } -/** - * @Entity - * @Table(name="second_entity") - */ +#[Table(name: 'second_entity')] +#[Entity] class SecondEntity { /** * @var int - * @Id - * @Column(name="first_entity_id") */ + #[Id] + #[Column(name: 'first_entity_id')] public $firstEntityId; /** * @var string - * @Column(name="name") */ + #[Column(name: 'name')] public $name; } -/** @Entity */ +#[Entity] class GH6830Board { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var GH6830Category - * @ManyToOne(targetEntity=GH6830Category::class, inversedBy="boards") - * @JoinColumn(name="category_id", referencedColumnName="id") */ + #[ManyToOne(targetEntity: GH6830Category::class, inversedBy: 'boards')] + #[JoinColumn(name: 'category_id', referencedColumnName: 'id')] public $category; } -/** @Entity */ +#[Entity] class GH6830Category { /** - * @Id - * @Column(type="string", length=8, options={"fixed":true, "collation":"latin1_bin", "foo":"bar"}) * @var string */ + #[Id] + #[Column(type: 'string', length: 8, options: ['fixed' => true, 'collation' => 'latin1_bin', 'foo' => 'bar'])] public $id; /** * @psalm-var Collection - * @OneToMany(targetEntity=GH6830Board::class, mappedBy="category") */ + #[OneToMany(targetEntity: GH6830Board::class, mappedBy: 'category')] public $boards; } -/** - * @Entity - * @Table( - * name="field_index", - * indexes={ - * @Index(name="index", fields={"index", "fieldName"}), - * }, - * uniqueConstraints={ - * @UniqueConstraint(name="uniq", fields={"index", "table"}) - * } - * ) - */ +#[Table(name: 'field_index')] +#[Index(name: 'index', fields: ['index', 'fieldName'])] +#[UniqueConstraint(name: 'uniq', fields: ['index', 'table'])] +#[Entity] class IndexByFieldEntity { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var string - * @Column */ + #[Column] public $index; /** * @var string - * @Column */ + #[Column] public $table; /** * @var string - * @Column */ + #[Column] public $fieldName; } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 91de8f41567..044ddf19b18 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Tools; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; @@ -221,354 +222,329 @@ public function testMappedSuperclassNotPresentInDiscriminator(): void } } -/** @MappedSuperclass */ +#[MappedSuperclass] abstract class MappedSuperclassEntity extends ParentEntity { } -/** - * @Entity - * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"child" = ChildEntity::class}) - */ +#[Entity] +#[InheritanceType('SINGLE_TABLE')] +#[DiscriminatorMap(['child' => ChildEntity::class])] abstract class ParentEntity { /** * @var mixed - * @Id - * @Column */ + #[Id] + #[Column] protected $key; } -/** @Entity */ +#[Entity] class ChildEntity extends MappedSuperclassEntity { } -/** @Entity */ +#[Entity] class InvalidEntity1 { /** * @var mixed - * @Id - * @Column */ + #[Id] + #[Column] protected $key1; /** * @var mixed - * @Id - * @Column */ + #[Id] + #[Column] protected $key2; /** * @var ArrayCollection - * @ManyToMany (targetEntity="InvalidEntity2") - * @JoinTable (name="Entity1Entity2", - * joinColumns={@JoinColumn(name="key1", referencedColumnName="key1")}, - * inverseJoinColumns={@JoinColumn(name="key3", referencedColumnName="key3")} - * ) */ + #[JoinTable(name: 'Entity1Entity2')] + #[JoinColumn(name: 'key1', referencedColumnName: 'key1')] + #[InverseJoinColumn(name: 'key3', referencedColumnName: 'key3')] + #[ManyToMany(targetEntity: 'InvalidEntity2')] protected $entity2; } -/** @Entity */ +#[Entity] class InvalidEntity2 { /** * @var mixed - * @Id - * @Column */ + #[Id] + #[Column] protected $key3; /** * @var mixed - * @Id - * @Column */ + #[Id] + #[Column] protected $key4; /** * @var InvalidEntity1 - * @ManyToOne(targetEntity="InvalidEntity1") */ + #[ManyToOne(targetEntity: 'InvalidEntity1')] protected $assoc; } -/** - * @Entity(repositoryClass="Entity\Repository\Agent") - * @Table(name="agent") - */ +#[Table(name: 'agent')] +#[Entity(repositoryClass: 'Entity\Repository\Agent')] class DDC1587ValidEntity1 { - /** - * @Id - * @GeneratedValue - * @Column(name="pk", type="integer") - */ + #[Id] + #[GeneratedValue] + #[Column(name: 'pk', type: 'integer')] private int $pk; - /** @Column(name="name", type="string", length=32) */ + #[Column(name: 'name', type: 'string', length: 32)] private string $name; /** * @var Identifier - * @OneToOne(targetEntity="DDC1587ValidEntity2", cascade={"all"}, mappedBy="agent") - * @JoinColumn(name="pk", referencedColumnName="pk_agent") */ + #[OneToOne(targetEntity: 'DDC1587ValidEntity2', cascade: ['all'], mappedBy: 'agent')] + #[JoinColumn(name: 'pk', referencedColumnName: 'pk_agent')] private $identifier; } -/** - * @Entity - * @Table - */ +#[Table] +#[Entity] class DDC1587ValidEntity2 { - /** - * @Id - * @OneToOne(targetEntity="DDC1587ValidEntity1", inversedBy="identifier") - * @JoinColumn(name="pk_agent", referencedColumnName="pk", nullable=false) - */ + #[Id] + #[OneToOne(targetEntity: 'DDC1587ValidEntity1', inversedBy: 'identifier')] + #[JoinColumn(name: 'pk_agent', referencedColumnName: 'pk', nullable: false)] private DDC1587ValidEntity1 $agent; - /** @Column(name="num", type="string", length=16, nullable=true) */ + #[Column(name: 'num', type: 'string', length: 16, nullable: true)] private string $num; } -/** @Entity */ +#[Entity] class DDC1649One { /** * @var mixed - * @Id - * @Column - * @GeneratedValue */ + #[Id] + #[Column] + #[GeneratedValue] public $id; } -/** @Entity */ +#[Entity] class DDC1649Two { /** * @var DDC1649One - * @Id @ManyToOne(targetEntity="DDC1649One") */ + #[Id] public $one; } -/** @Entity */ +#[Entity] class DDC1649Three { - /** - * @Id - * @ManyToOne(targetEntity="DDC1649Two") - * @JoinColumn(name="id", referencedColumnName="id") - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC1649Two')] + #[JoinColumn(name: 'id', referencedColumnName: 'id')] private DDC1649Two $two; } -/** @Entity */ +#[Entity] class DDC3274One { /** * @var mixed - * @Id - * @Column - * @GeneratedValue */ + #[Id] + #[Column] + #[GeneratedValue] private $id; - /** @OneToMany(targetEntity="DDC3274Two", mappedBy="one") */ + #[OneToMany(targetEntity: 'DDC3274Two', mappedBy: 'one')] private ArrayCollection $two; } -/** @Entity */ +#[Entity] class DDC3274Two { - /** - * @Id - * @ManyToOne(targetEntity="DDC3274One") - */ + #[Id] + #[ManyToOne(targetEntity: 'DDC3274One')] private DDC3274One $one; } -/** @Entity */ +#[Entity] class Issue9536Target { /** * @var mixed - * @Id - * @Column - * @GeneratedValue */ + #[Id] + #[Column] + #[GeneratedValue] private $id; - /** @OneToOne(targetEntity="Issue9536Owner") */ + #[OneToOne(targetEntity: 'Issue9536Owner')] private Issue9536Owner $two; } -/** @Entity */ +#[Entity] class Issue9536Owner { /** * @var mixed - * @Id - * @Column - * @GeneratedValue */ + #[Id] + #[Column] + #[GeneratedValue] private $id; - /** @OneToOne(targetEntity="Issue9536Target", inversedBy="two") */ + #[OneToOne(targetEntity: 'Issue9536Target', inversedBy: 'two')] private Issue9536Target $one; } -/** @Entity */ +#[Entity] class DDC3322ValidEntity1 { /** * @var mixed - * @Id - * @Column - * @GeneratedValue */ + #[Id] + #[Column] + #[GeneratedValue] private $id; - /** @ManyToOne(targetEntity="DDC3322One", inversedBy="validAssoc") */ + #[ManyToOne(targetEntity: 'DDC3322One', inversedBy: 'validAssoc')] private DDC3322One $oneValid; - /** @ManyToOne(targetEntity="DDC3322One", inversedBy="invalidAssoc") */ + #[ManyToOne(targetEntity: 'DDC3322One', inversedBy: 'invalidAssoc')] private DDC3322One $oneInvalid; - /** @ManyToOne(targetEntity="DDC3322Two", inversedBy="validAssoc") */ + #[ManyToOne(targetEntity: 'DDC3322Two', inversedBy: 'validAssoc')] private DDC3322Two $twoValid; - /** @ManyToOne(targetEntity="DDC3322Two", inversedBy="invalidAssoc") */ + #[ManyToOne(targetEntity: 'DDC3322Two', inversedBy: 'invalidAssoc')] private DDC3322Two $twoInvalid; - /** @ManyToOne(targetEntity="DDC3322Three", inversedBy="validAssoc") */ + #[ManyToOne(targetEntity: 'DDC3322Three', inversedBy: 'validAssoc')] private DDC3322Three $threeValid; - /** @ManyToOne(targetEntity="DDC3322Three", inversedBy="invalidAssoc") */ + #[ManyToOne(targetEntity: 'DDC3322Three', inversedBy: 'invalidAssoc')] private DDC3322Three $threeInvalid; - /** @OneToMany(targetEntity="DDC3322ValidEntity2", mappedBy="manyToOne") */ + #[OneToMany(targetEntity: 'DDC3322ValidEntity2', mappedBy: 'manyToOne')] private DDC3322ValidEntity2 $oneToMany; - /** @ManyToOne(targetEntity="DDC3322ValidEntity2", inversedBy="oneToMany") */ + #[ManyToOne(targetEntity: 'DDC3322ValidEntity2', inversedBy: 'oneToMany')] private DDC3322ValidEntity2 $manyToOne; - /** @OneToOne(targetEntity="DDC3322ValidEntity2", mappedBy="oneToOneOwning") */ + #[OneToOne(targetEntity: 'DDC3322ValidEntity2', mappedBy: 'oneToOneOwning')] private DDC3322ValidEntity2 $oneToOneInverse; - /** @OneToOne(targetEntity="DDC3322ValidEntity2", inversedBy="oneToOneInverse") */ + #[OneToOne(targetEntity: 'DDC3322ValidEntity2', inversedBy: 'oneToOneInverse')] private DDC3322ValidEntity2 $oneToOneOwning; } -/** @Entity */ +#[Entity] class DDC3322ValidEntity2 { - /** - * @Id - * @Column - * @GeneratedValue - */ + #[Id] + #[Column] + #[GeneratedValue] private int $id; - /** @ManyToOne(targetEntity="DDC3322ValidEntity1", inversedBy="oneToMany") */ + #[ManyToOne(targetEntity: 'DDC3322ValidEntity1', inversedBy: 'oneToMany')] private DDC3322ValidEntity1 $manyToOne; - /** @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="manyToOne") */ + #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'manyToOne')] private DDC3322ValidEntity1 $oneToMany; - /** @OneToOne(targetEntity="DDC3322ValidEntity1", inversedBy="oneToOneInverse") */ + #[OneToOne(targetEntity: 'DDC3322ValidEntity1', inversedBy: 'oneToOneInverse')] private DDC3322ValidEntity1 $oneToOneOwning; - /** @OneToOne(targetEntity="DDC3322ValidEntity1", mappedBy="oneToOneOwning") */ + #[OneToOne(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'oneToOneOwning')] private DDC3322ValidEntity1 $oneToOneInverse; } -/** @Entity */ +#[Entity] class DDC3322One { - /** - * @Id - * @Column - * @GeneratedValue - */ + #[Id] + #[Column] + #[GeneratedValue] private int $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="oneValid") - * @OrderBy({"id" = "ASC"}) */ + #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'oneValid')] + #[OrderBy(['id' => 'ASC'])] private $validAssoc; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="oneInvalid") - * @OrderBy({"invalidField" = "ASC"}) */ + #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'oneInvalid')] + #[OrderBy(['invalidField' => 'ASC'])] private $invalidAssoc; } -/** @Entity */ +#[Entity] class DDC3322Two { - /** - * @Id - * @Column - * @GeneratedValue - */ + #[Id] + #[Column] + #[GeneratedValue] private int $id; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="twoValid") - * @OrderBy({"manyToOne" = "ASC"}) */ + #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'twoValid')] + #[OrderBy(['manyToOne' => 'ASC'])] private $validAssoc; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="twoInvalid") - * @OrderBy({"oneToMany" = "ASC"}) */ + #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'twoInvalid')] + #[OrderBy(['oneToMany' => 'ASC'])] private $invalidAssoc; } -/** @Entity */ +#[Entity] class DDC3322Three { - /** - * @Id - * @Column - * @GeneratedValue - */ + #[Id] + #[Column] + #[GeneratedValue] private int $id; - /** - * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="threeValid") - * @OrderBy({"oneToOneOwning" = "ASC"}) - */ + #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'threeValid')] + #[OrderBy(['oneToOneOwning' => 'ASC'])] private DDC3322ValidEntity1 $validAssoc; /** * @psalm-var Collection - * @OneToMany(targetEntity="DDC3322ValidEntity1", mappedBy="threeInvalid") - * @OrderBy({"oneToOneInverse" = "ASC"}) */ + #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'threeInvalid')] + #[OrderBy(['oneToOneInverse' => 'ASC'])] private $invalidAssoc; } -/** @Embeddable */ +#[Embeddable] class EmbeddableWithAssociation { - /** @OneToOne(targetEntity="Doctrine\Tests\Models\ECommerce\ECommerceCart") */ + #[OneToOne(targetEntity: 'Doctrine\Tests\Models\ECommerce\ECommerceCart')] private ECommerceCart $cart; } diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 340d366ef84..bd98dc62106 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -628,31 +628,28 @@ public function testItThrowsWhenLookingUpIdentifierForUnknownEntity(): void } } -/** @Entity */ +#[Entity] class NotifyChangedEntity implements NotifyPropertyChanged { /** @psalm-var list */ private array $_listeners = []; - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; /** * @var string - * @Column(type="string", length=255) */ + #[Column(type: 'string', length: 255)] private $data; private mixed $transient = null; // not persisted - /** * @psalm-var Collection - * @OneToMany(targetEntity="NotifyChangedRelatedItem", mappedBy="owner") */ + #[OneToMany(targetEntity: 'NotifyChangedRelatedItem', mappedBy: 'owner')] private $items; public function __construct() @@ -706,17 +703,15 @@ protected function onPropertyChanged(mixed $propName, mixed $oldValue, mixed $ne } } -/** @Entity */ +#[Entity] class NotifyChangedRelatedItem { - /** - * @Id - * @Column(type="integer") - * @GeneratedValue - */ + #[Id] + #[Column(type: 'integer')] + #[GeneratedValue] private int $id; - /** @ManyToOne(targetEntity="NotifyChangedEntity", inversedBy="items") */ + #[ManyToOne(targetEntity: 'NotifyChangedEntity', inversedBy: 'items')] private NotifyChangedEntity|null $owner = null; public function getId(): int @@ -735,78 +730,78 @@ public function setOwner(NotifyChangedEntity|null $owner): void } } -/** @Entity */ +#[Entity] class VersionedAssignedIdentifierEntity { /** * @var int - * @Id - * @Column(type="integer") */ + #[Id] + #[Column(type: 'integer')] public $id; /** * @var int - * @Version - * @Column(type="integer") */ + #[Version] + #[Column(type: 'integer')] public $version; } -/** @Entity */ +#[Entity] class EntityWithStringIdentifier { /** - * @Id - * @Column(type="string", length=255) * @var string|null */ + #[Id] + #[Column(type: 'string', length: 255)] public $id; } -/** @Entity */ +#[Entity] class EntityWithBooleanIdentifier { /** - * @Id - * @Column(type="boolean") * @var bool|null */ + #[Id] + #[Column(type: 'boolean')] public $id; } -/** @Entity */ +#[Entity] class EntityWithCompositeStringIdentifier { /** - * @Id - * @Column(type="string", length=255) * @var string|null */ + #[Id] + #[Column(type: 'string', length: 255)] public $id1; /** - * @Id - * @Column(type="string", length=255) * @var string|null */ + #[Id] + #[Column(type: 'string', length: 255)] public $id2; } -/** @Entity */ +#[Entity] class EntityWithRandomlyGeneratedField { /** * @var string - * @Id - * @Column(type="string", length=255) */ + #[Id] + #[Column(type: 'string', length: 255)] public $id; /** * @var int - * @Column(type="integer") */ + #[Column(type: 'integer')] public $generatedField; public function __construct() @@ -816,14 +811,12 @@ public function __construct() } } -/** @Entity */ +#[Entity] class CascadePersistedEntity { - /** - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] private string $id; public function __construct() @@ -832,20 +825,18 @@ public function __construct() } } -/** @Entity */ +#[Entity] class EntityWithCascadingAssociation { - /** - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] private string $id; /** * @var CascadePersistedEntity|null - * @ManyToOne(targetEntity=CascadePersistedEntity::class, cascade={"persist"}) */ + #[ManyToOne(targetEntity: CascadePersistedEntity::class, cascade: ['persist'])] public $cascaded; public function __construct() @@ -854,20 +845,18 @@ public function __construct() } } -/** @Entity */ +#[Entity] class EntityWithNonCascadingAssociation { - /** - * @Id - * @Column(type="string", length=255) - * @GeneratedValue(strategy="NONE") - */ + #[Id] + #[Column(type: 'string', length: 255)] + #[GeneratedValue(strategy: 'NONE')] private string $id; /** * @var CascadePersistedEntity|null - * @ManyToOne(targetEntity=CascadePersistedEntity::class) */ + #[ManyToOne(targetEntity: CascadePersistedEntity::class)] public $nonCascaded; public function __construct() From d46f67bf952a88aba4aa3045684aa4a7cbc46d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 25 Oct 2022 23:15:24 +0200 Subject: [PATCH 179/475] Add missing ManyToOne attribute The tests does not behave as expected without it. --- tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 044ddf19b18..a5aadd4b665 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -348,6 +348,7 @@ class DDC1649Two * @var DDC1649One */ #[Id] + #[ManyToOne(targetEntity: 'DDC1649One')] public $one; } From ef4543df33468899d9ff99e264949a6aa31dad9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 25 Oct 2022 23:16:09 +0200 Subject: [PATCH 180/475] Just a little cs fix, no big deal. --- .../Doctrine/Tests/Models/CMS/CmsAddress.php | 16 +- .../Doctrine/Tests/Models/CMS/CmsArticle.php | 24 +-- .../Doctrine/Tests/Models/CMS/CmsComment.php | 16 +- tests/Doctrine/Tests/Models/CMS/CmsEmail.php | 12 +- tests/Doctrine/Tests/Models/CMS/CmsGroup.php | 12 +- .../Tests/Models/CMS/CmsPhonenumber.php | 8 +- tests/Doctrine/Tests/Models/CMS/CmsTag.php | 12 +- tests/Doctrine/Tests/Models/CMS/CmsUser.php | 42 ++--- tests/Doctrine/Tests/Models/Cache/Action.php | 4 +- tests/Doctrine/Tests/Models/Cache/Address.php | 8 +- .../Tests/Models/Cache/Attraction.php | 8 +- .../Models/Cache/AttractionContactInfo.php | 4 +- .../Tests/Models/Cache/AttractionInfo.php | 8 +- .../Models/Cache/AttractionLocationInfo.php | 4 +- tests/Doctrine/Tests/Models/Cache/Client.php | 4 +- .../Tests/Models/Cache/ComplexAction.php | 12 +- tests/Doctrine/Tests/Models/Cache/Country.php | 4 +- tests/Doctrine/Tests/Models/Cache/Flight.php | 4 +- tests/Doctrine/Tests/Models/Cache/Login.php | 8 +- tests/Doctrine/Tests/Models/Cache/Person.php | 8 +- tests/Doctrine/Tests/Models/Cache/State.php | 8 +- tests/Doctrine/Tests/Models/Cache/Token.php | 16 +- tests/Doctrine/Tests/Models/Cache/Travel.php | 14 +- .../Doctrine/Tests/Models/Cache/Traveler.php | 12 +- .../Tests/Models/Cache/TravelerProfile.php | 4 +- .../Models/Cache/TravelerProfileInfo.php | 4 +- .../Tests/Models/Company/CompanyContract.php | 6 +- .../Tests/Models/Company/CompanyEmployee.php | 8 +- .../Models/Company/CompanyFlexContract.php | 10 +- .../Tests/Models/Company/CompanyManager.php | 4 +- .../Models/Company/CompanyOrganization.php | 4 +- .../Tests/Models/Company/CompanyPerson.php | 6 +- .../JoinedChildClass.php | 4 +- .../JoinedDerivedChildClass.php | 4 +- .../JoinedDerivedIdentityClass.php | 8 +- .../JoinedDerivedRootClass.php | 8 +- .../JoinedRootClass.php | 8 +- .../SingleChildClass.php | 4 +- .../SingleRootClass.php | 8 +- .../CustomType/CustomIdObjectTypeParent.php | 4 +- .../Models/CustomType/CustomTypeChild.php | 8 +- .../Models/CustomType/CustomTypeParent.php | 22 +-- .../Models/CustomType/CustomTypeUpperCase.php | 12 +- .../Tests/Models/DDC117/DDC117Article.php | 12 +- .../Models/DDC117/DDC117ArticleDetails.php | 4 +- .../Tests/Models/DDC117/DDC117Editor.php | 14 +- .../Tests/Models/DDC117/DDC117Reference.php | 8 +- .../Tests/Models/DDC117/DDC117Translation.php | 12 +- .../Tests/Models/DDC1590/DDC1590Entity.php | 8 +- .../Tests/Models/DDC1590/DDC1590User.php | 4 +- .../Models/DDC1872/DDC1872ExampleTrait.php | 12 +- .../Tests/Models/DDC2372/DDC2372Address.php | 4 +- .../Traits/DDC2372AddressAndAccessors.php | 4 +- .../Models/DDC2504/DDC2504OtherClass.php | 4 +- .../Tests/Models/DDC2504/DDC2504RootClass.php | 8 +- .../Tests/Models/DDC3231/DDC3231User1.php | 8 +- .../DDC3231/DDC3231User1NoNamespace.php | 8 +- .../Tests/Models/DDC3231/DDC3231User2.php | 8 +- .../DDC3231/DDC3231User2NoNamespace.php | 8 +- .../Tests/Models/DDC3346/DDC3346Article.php | 8 +- .../Tests/Models/DDC3346/DDC3346Author.php | 12 +- .../Tests/Models/DDC3597/DDC3597Root.php | 12 +- .../Tests/Models/DDC3699/DDC3699Child.php | 16 +- .../Tests/Models/DDC3699/DDC3699Parent.php | 4 +- .../Models/DDC3699/DDC3699RelationMany.php | 8 +- .../Models/DDC3699/DDC3699RelationOne.php | 8 +- .../Tests/Models/DDC3899/DDC3899Contract.php | 12 +- .../Models/DDC3899/DDC3899FixContract.php | 4 +- .../Models/DDC3899/DDC3899FlexContract.php | 8 +- .../Tests/Models/DDC3899/DDC3899User.php | 8 +- .../Tests/Models/DDC6412/DDC6412File.php | 8 +- .../DDC753EntityWithCustomRepository.php | 8 +- ...DC753EntityWithDefaultCustomRepository.php | 8 +- .../DDC753EntityWithInvalidRepository.php | 8 +- .../Tests/Models/DDC889/DDC889Class.php | 4 +- .../Tests/Models/DDC964/DDC964Group.php | 4 +- .../DirectoryTree/AbstractContentItem.php | 4 +- .../Tests/Models/DirectoryTree/Directory.php | 4 +- .../Tests/Models/DirectoryTree/File.php | 4 +- .../Tests/Models/ECommerce/ECommerceCart.php | 6 +- .../Models/ECommerce/ECommerceCategory.php | 8 +- .../Models/ECommerce/ECommerceProduct.php | 10 +- .../Tests/Models/Forum/ForumAdministrator.php | 4 +- .../Tests/Models/Forum/ForumAvatar.php | 4 +- .../Tests/Models/Forum/ForumBoard.php | 12 +- .../Tests/Models/Forum/ForumCategory.php | 12 +- .../Tests/Models/Forum/ForumEntry.php | 8 +- .../Doctrine/Tests/Models/Forum/ForumUser.php | 12 +- .../Tests/Models/GH8565/GH8565Employee.php | 4 +- .../Tests/Models/GH8565/GH8565Manager.php | 4 +- .../Tests/Models/GH8565/GH8565Person.php | 4 +- .../Tests/Models/Generic/BooleanModel.php | 8 +- .../Tests/Models/Generic/DateTimeModel.php | 16 +- .../Tests/Models/Generic/DecimalModel.php | 12 +- .../Models/Generic/NonAlphaColumnsEntity.php | 4 +- .../Models/Generic/SerializationModel.php | 12 +- .../Doctrine/Tests/Models/GeoNames/Admin1.php | 4 +- tests/Doctrine/Tests/Models/GeoNames/City.php | 8 +- .../Models/Global/GlobalNamespaceModel.php | 22 +-- .../EntityWithArrayDefaultArrayValueM2M.php | 8 +- .../Tests/Models/Hydration/SimpleEntity.php | 4 +- .../Models/Issue5989/Issue5989Employee.php | 4 +- .../Models/Issue5989/Issue5989Manager.php | 4 +- .../Models/Issue5989/Issue5989Person.php | 4 +- .../JoinedInheritanceType/RootClass.php | 4 +- .../Tests/Models/Legacy/LegacyArticle.php | 16 +- .../Tests/Models/Legacy/LegacyCar.php | 12 +- .../Tests/Models/Legacy/LegacyUser.php | 26 +--- .../Models/ManyToManyPersister/ChildClass.php | 2 +- .../CompositeToOneKeyState.php | 8 +- .../Models/MixedToOneIdentity/Country.php | 4 +- .../Tests/Models/Navigation/NavCountry.php | 4 +- .../Models/Navigation/NavPointOfInterest.php | 6 +- .../Tests/Models/Navigation/NavTour.php | 6 +- .../Models/NonPublicSchemaJoins/User.php | 14 +- .../Models/NullDefault/NullDefaultColumn.php | 8 +- .../OneToOneInverseSideLoad/InverseSide.php | 8 +- .../OneToOneInverseSideLoad/OwningSide.php | 4 +- .../OneToOneSingleTableInheritance/Cat.php | 4 +- .../LitterBox.php | 4 +- .../OneToOneSingleTableInheritance/Pet.php | 4 +- .../Tests/Models/Pagination/Company.php | 20 +-- .../Tests/Models/Pagination/Department.php | 12 +- .../Doctrine/Tests/Models/Pagination/Logo.php | 20 +-- .../Doctrine/Tests/Models/Pagination/User.php | 4 +- .../Tests/Models/Pagination/User1.php | 4 +- .../PersistentCollectionContent.php | 4 +- .../PersistentCollectionHolder.php | 8 +- .../PersistentObject/PersistentEntity.php | 12 +- tests/Doctrine/Tests/Models/Quote/Address.php | 12 +- tests/Doctrine/Tests/Models/Quote/City.php | 4 +- .../Tests/Models/Quote/FullAddress.php | 4 +- tests/Doctrine/Tests/Models/Quote/Group.php | 8 +- .../Tests/Models/Quote/NumericEntity.php | 4 +- tests/Doctrine/Tests/Models/Quote/Phone.php | 8 +- tests/Doctrine/Tests/Models/Quote/User.php | 22 +-- .../Tests/Models/Routing/RoutingLeg.php | 20 +-- .../Tests/Models/Routing/RoutingLocation.php | 8 +- .../Tests/Models/Routing/RoutingRoute.php | 14 +- .../Models/Routing/RoutingRouteBooking.php | 12 +- .../Tests/Models/StockExchange/Bond.php | 4 +- .../Tests/Models/StockExchange/Market.php | 4 +- tests/Doctrine/Tests/Models/Taxi/Car.php | 8 +- tests/Doctrine/Tests/Models/Taxi/Driver.php | 8 +- tests/Doctrine/Tests/Models/Taxi/PaidRide.php | 4 +- tests/Doctrine/Tests/Models/Tweet/Tweet.php | 12 +- tests/Doctrine/Tests/Models/Tweet/User.php | 16 +- .../Doctrine/Tests/Models/Tweet/UserList.php | 12 +- .../ValueConversionType/AuxiliaryEntity.php | 4 +- .../InversedManyToManyCompositeIdEntity.php | 12 +- ...dManyToManyCompositeIdForeignKeyEntity.php | 12 +- .../InversedManyToManyEntity.php | 8 +- .../InversedManyToManyExtraLazyEntity.php | 8 +- .../InversedOneToManyCompositeIdEntity.php | 16 +- ...edOneToManyCompositeIdForeignKeyEntity.php | 16 +- .../InversedOneToManyEntity.php | 12 +- .../InversedOneToManyExtraLazyEntity.php | 8 +- .../InversedOneToOneCompositeIdEntity.php | 16 +- ...sedOneToOneCompositeIdForeignKeyEntity.php | 16 +- .../InversedOneToOneEntity.php | 12 +- .../OwningManyToManyCompositeIdEntity.php | 10 +- ...gManyToManyCompositeIdForeignKeyEntity.php | 10 +- .../OwningManyToManyEntity.php | 10 +- .../OwningManyToManyExtraLazyEntity.php | 10 +- .../OwningManyToOneCompositeIdEntity.php | 8 +- ...ngManyToOneCompositeIdForeignKeyEntity.php | 8 +- .../OwningManyToOneEntity.php | 8 +- .../OwningManyToOneExtraLazyEntity.php | 8 +- .../OwningManyToOneIdForeignKeyEntity.php | 4 +- .../OwningOneToOneCompositeIdEntity.php | 8 +- ...ingOneToOneCompositeIdForeignKeyEntity.php | 8 +- .../OwningOneToOneEntity.php | 8 +- .../Models/VersionedManyToOne/Article.php | 12 +- .../Models/VersionedManyToOne/Category.php | 4 +- .../VersionedOneToOne/FirstRelatedEntity.php | 8 +- .../VersionedOneToOne/SecondRelatedEntity.php | 8 +- .../Functional/AdvancedAssociationTest.php | 10 +- .../ORM/Functional/CascadeRemoveOrderTest.php | 4 +- .../ClassTableInheritanceSecondTest.php | 4 +- .../ORM/Functional/DefaultValuesTest.php | 36 ++--- .../Tests/ORM/Functional/GH5988Test.php | 4 +- .../ORM/Functional/LifecycleCallbackTest.php | 20 +-- .../ORM/Functional/Locking/OptimisticTest.php | 36 ++--- .../Tests/ORM/Functional/NotifyPolicyTest.php | 8 +- .../Functional/OneToOneEagerLoadingTest.php | 28 +--- ...edJoinedTableInheritanceCollectionTest.php | 22 +-- .../QueryBuilderParenthesisTest.php | 16 +- .../Tests/ORM/Functional/ReadOnlyTest.php | 11 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 12 +- .../SchemaTool/MySqlSchemaToolTest.php | 4 +- .../ORM/Functional/SequenceGeneratorTest.php | 4 +- .../ORM/Functional/Ticket/DDC1080Test.php | 36 ++--- .../ORM/Functional/Ticket/DDC1113Test.php | 16 +- .../ORM/Functional/Ticket/DDC1163Test.php | 8 +- .../ORM/Functional/Ticket/DDC1181Test.php | 20 +-- .../ORM/Functional/Ticket/DDC1193Test.php | 20 +-- .../ORM/Functional/Ticket/DDC1209Test.php | 16 +- .../ORM/Functional/Ticket/DDC1228Test.php | 20 +-- .../ORM/Functional/Ticket/DDC1250Test.php | 12 +- .../ORM/Functional/Ticket/DDC1300Test.php | 24 +-- .../ORM/Functional/Ticket/DDC1335Test.php | 19 +-- .../ORM/Functional/Ticket/DDC1400Test.php | 32 +--- .../ORM/Functional/Ticket/DDC1430Test.php | 8 +- .../ORM/Functional/Ticket/DDC1436Test.php | 8 +- .../ORM/Functional/Ticket/DDC144Test.php | 12 +- .../ORM/Functional/Ticket/DDC1452Test.php | 24 +-- .../ORM/Functional/Ticket/DDC1454Test.php | 4 +- .../ORM/Functional/Ticket/DDC1458Test.php | 24 +-- .../ORM/Functional/Ticket/DDC1461Test.php | 16 +- .../ORM/Functional/Ticket/DDC1514Test.php | 36 ++--- .../ORM/Functional/Ticket/DDC1515Test.php | 12 +- .../ORM/Functional/Ticket/DDC1526Test.php | 12 +- .../ORM/Functional/Ticket/DDC1548Test.php | 20 +-- .../ORM/Functional/Ticket/DDC1595Test.php | 10 +- .../ORM/Functional/Ticket/DDC1654Test.php | 12 +- .../ORM/Functional/Ticket/DDC1655Test.php | 16 +- .../ORM/Functional/Ticket/DDC1707Test.php | 4 +- .../ORM/Functional/Ticket/DDC1719Test.php | 4 +- .../ORM/Functional/Ticket/DDC1757Test.php | 8 +- .../ORM/Functional/Ticket/DDC1925Test.php | 6 +- .../ORM/Functional/Ticket/DDC192Test.php | 16 +- .../ORM/Functional/Ticket/DDC1998Test.php | 8 +- .../ORM/Functional/Ticket/DDC199Test.php | 28 +--- .../ORM/Functional/Ticket/DDC2012Test.php | 8 +- .../ORM/Functional/Ticket/DDC2106Test.php | 12 +- .../ORM/Functional/Ticket/DDC211Test.php | 26 +--- .../ORM/Functional/Ticket/DDC2138Test.php | 28 +--- .../ORM/Functional/Ticket/DDC2175Test.php | 12 +- .../ORM/Functional/Ticket/DDC2214Test.php | 12 +- .../ORM/Functional/Ticket/DDC2224Test.php | 8 +- .../ORM/Functional/Ticket/DDC2230Test.php | 12 +- .../ORM/Functional/Ticket/DDC2252Test.php | 22 +-- .../ORM/Functional/Ticket/DDC2306Test.php | 32 +--- .../ORM/Functional/Ticket/DDC2346Test.php | 16 +- .../ORM/Functional/Ticket/DDC2350Test.php | 16 +- .../ORM/Functional/Ticket/DDC2359Test.php | 4 +- .../ORM/Functional/Ticket/DDC237Test.php | 32 +--- .../ORM/Functional/Ticket/DDC2494Test.php | 8 +- .../ORM/Functional/Ticket/DDC2575Test.php | 4 +- .../ORM/Functional/Ticket/DDC2579Test.php | 12 +- .../ORM/Functional/Ticket/DDC258Test.php | 32 +--- .../ORM/Functional/Ticket/DDC2602Test.php | 52 ++----- .../ORM/Functional/Ticket/DDC2660Test.php | 8 +- .../ORM/Functional/Ticket/DDC2692Test.php | 4 +- .../ORM/Functional/Ticket/DDC2759Test.php | 28 +--- .../ORM/Functional/Ticket/DDC2775Test.php | 36 ++--- .../ORM/Functional/Ticket/DDC2780Test.php | 16 +- .../ORM/Functional/Ticket/DDC279Test.php | 32 +--- .../ORM/Functional/Ticket/DDC2862Test.php | 8 +- .../ORM/Functional/Ticket/DDC2895Test.php | 8 +- .../ORM/Functional/Ticket/DDC2931Test.php | 16 +- .../ORM/Functional/Ticket/DDC2996Test.php | 20 +-- .../ORM/Functional/Ticket/DDC3033Test.php | 22 +-- .../ORM/Functional/Ticket/DDC3042Test.php | 48 ++---- .../ORM/Functional/Ticket/DDC309Test.php | 8 +- .../ORM/Functional/Ticket/DDC3103Test.php | 4 +- .../ORM/Functional/Ticket/DDC3170Test.php | 8 +- .../ORM/Functional/Ticket/DDC3192Test.php | 8 +- .../ORM/Functional/Ticket/DDC3223Test.php | 8 +- .../ORM/Functional/Ticket/DDC3300Test.php | 4 +- .../ORM/Functional/Ticket/DDC3330Test.php | 20 +-- .../ORM/Functional/Ticket/DDC345Test.php | 44 ++---- .../ORM/Functional/Ticket/DDC353Test.php | 4 +- .../ORM/Functional/Ticket/DDC3582Test.php | 16 +- .../ORM/Functional/Ticket/DDC3634Test.php | 8 +- .../ORM/Functional/Ticket/DDC3644Test.php | 32 +--- .../ORM/Functional/Ticket/DDC371Test.php | 16 +- .../ORM/Functional/Ticket/DDC3785Test.php | 10 +- .../ORM/Functional/Ticket/DDC381Test.php | 4 +- .../ORM/Functional/Ticket/DDC422Test.php | 14 +- .../ORM/Functional/Ticket/DDC425Test.php | 8 +- .../ORM/Functional/Ticket/DDC440Test.php | 28 +--- .../ORM/Functional/Ticket/DDC444Test.php | 8 +- .../ORM/Functional/Ticket/DDC448Test.php | 4 +- .../ORM/Functional/Ticket/DDC493Test.php | 16 +- .../ORM/Functional/Ticket/DDC512Test.php | 8 +- .../ORM/Functional/Ticket/DDC513Test.php | 16 +- .../ORM/Functional/Ticket/DDC522Test.php | 36 ++--- .../ORM/Functional/Ticket/DDC531Test.php | 12 +- .../ORM/Functional/Ticket/DDC5684Test.php | 4 +- .../ORM/Functional/Ticket/DDC588Test.php | 4 +- .../ORM/Functional/Ticket/DDC599Test.php | 20 +-- .../ORM/Functional/Ticket/DDC618Test.php | 16 +- .../ORM/Functional/Ticket/DDC6303Test.php | 5 +- .../ORM/Functional/Ticket/DDC633Test.php | 16 +- .../ORM/Functional/Ticket/DDC6460Test.php | 20 +-- .../ORM/Functional/Ticket/DDC656Test.php | 12 +- .../ORM/Functional/Ticket/DDC698Test.php | 30 +--- .../Tests/ORM/Functional/Ticket/DDC69Test.php | 8 +- .../ORM/Functional/Ticket/DDC719Test.php | 22 +-- .../ORM/Functional/Ticket/DDC735Test.php | 12 +- .../ORM/Functional/Ticket/DDC809Test.php | 18 +-- .../ORM/Functional/Ticket/DDC832Test.php | 16 +- .../ORM/Functional/Ticket/DDC837Test.php | 44 ++---- .../ORM/Functional/Ticket/DDC881Test.php | 8 +- .../ORM/Functional/Ticket/DDC992Test.php | 30 +--- .../ORM/Functional/Ticket/GH5562Test.php | 24 +-- .../ORM/Functional/Ticket/GH5762Test.php | 8 +- .../ORM/Functional/Ticket/GH5804Test.php | 14 +- .../ORM/Functional/Ticket/GH6029Test.php | 32 +--- .../ORM/Functional/Ticket/GH6141Test.php | 4 +- .../ORM/Functional/Ticket/GH6217Test.php | 4 +- .../ORM/Functional/Ticket/GH6362Test.php | 16 +- .../ORM/Functional/Ticket/GH6394Test.php | 8 +- .../ORM/Functional/Ticket/GH6464Test.php | 12 +- .../ORM/Functional/Ticket/GH6531Test.php | 28 +--- .../ORM/Functional/Ticket/GH6823Test.php | 30 +--- .../ORM/Functional/Ticket/GH6937Test.php | 16 +- .../ORM/Functional/Ticket/GH7062Test.php | 8 +- .../ORM/Functional/Ticket/GH7067Test.php | 12 +- .../ORM/Functional/Ticket/GH7068Test.php | 4 +- .../ORM/Functional/Ticket/GH7079Test.php | 16 +- .../ORM/Functional/Ticket/GH7259Test.php | 32 +--- .../ORM/Functional/Ticket/GH7286Test.php | 4 +- .../ORM/Functional/Ticket/GH7366Test.php | 8 +- .../Ticket/GH7496WithToIterableTest.php | 8 +- .../ORM/Functional/Ticket/GH7505Test.php | 12 +- .../ORM/Functional/Ticket/GH7512Test.php | 16 +- .../ORM/Functional/Ticket/GH7629Test.php | 4 +- .../ORM/Functional/Ticket/GH7661Test.php | 16 +- .../ORM/Functional/Ticket/GH7737Test.php | 6 +- .../ORM/Functional/Ticket/GH7761Test.php | 14 +- .../ORM/Functional/Ticket/GH7767Test.php | 4 +- .../ORM/Functional/Ticket/GH7836Test.php | 4 +- .../ORM/Functional/Ticket/GH7864Test.php | 24 +-- .../ORM/Functional/Ticket/GH7869Test.php | 16 +- .../ORM/Functional/Ticket/GH7875Test.php | 8 +- .../ORM/Functional/Ticket/GH7941Test.php | 8 +- .../ORM/Functional/Ticket/GH8055Test.php | 8 +- .../ORM/Functional/Ticket/GH8061Test.php | 8 +- .../ORM/Functional/Ticket/GH8217Test.php | 8 +- .../ORM/Functional/Ticket/GH8443Test.php | 4 +- .../ORM/Functional/Ticket/GH8499Test.php | 16 +- .../ORM/Functional/Ticket/GH8663Test.php | 8 +- .../ORM/Functional/Ticket/GH8914Test.php | 4 +- .../ORM/Functional/Ticket/GH9027Test.php | 16 +- .../ORM/Functional/Ticket/GH9230Test.php | 24 +-- .../ORM/Functional/Ticket/GH9335Test.php | 20 +-- .../ORM/Functional/Ticket/GH9579Test.php | 32 +--- .../ORM/Functional/Ticket/GH9807Test.php | 20 +-- .../ORM/Functional/Ticket/Ticket2481Test.php | 4 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 147 ++++++------------ .../Tests/ORM/Id/AssignedGeneratorTest.php | 12 +- .../Mapping/BasicInheritanceMappingTest.php | 28 +--- .../ORM/Mapping/ClassMetadataFactoryTest.php | 4 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 4 +- .../ORM/Mapping/MappingDriverTestCase.php | 24 +-- .../ORM/Query/SelectSqlGenerationTest.php | 8 +- .../AttachEntityListenersListenerTest.php | 8 +- .../Command/SchemaTool/Models/Keyboard.php | 8 +- .../ORM/Tools/Console/MetadataFilterTest.php | 24 +-- .../Tools/Pagination/PaginationTestCase.php | 110 ++++--------- .../Tools/ResolveTargetEntityListenerTest.php | 8 +- .../Tests/ORM/Tools/SchemaToolTest.php | 52 ++----- .../Tests/ORM/Tools/SchemaValidatorTest.php | 78 +++------- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 48 ++---- 356 files changed, 1193 insertions(+), 3469 deletions(-) diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index 07cf96e84c6..9c125f7bc14 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -25,21 +25,15 @@ class CmsAddress #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(length: 50)] public $country; - /** - * @var string - */ + /** @var string */ #[Column(length: 50)] public $zip; - /** - * @var string - */ + /** @var string */ #[Column(length: 50)] public $city; @@ -50,9 +44,7 @@ class CmsAddress */ public $street; - /** - * @var CmsUser - */ + /** @var CmsUser */ #[OneToOne(targetEntity: 'CmsUser', inversedBy: 'address')] #[JoinColumn(referencedColumnName: 'id')] public $user; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php index a4a9b6b9cbf..759db3430da 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsArticle.php @@ -19,42 +19,30 @@ #[Entity] class CmsArticle { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $topic; - /** - * @var string - */ + /** @var string */ #[Column(type: 'text')] public $text; - /** - * @var CmsUser - */ + /** @var CmsUser */ #[ManyToOne(targetEntity: 'CmsUser', inversedBy: 'articles')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'CmsComment', mappedBy: 'article')] public $comments; - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsComment.php b/tests/Doctrine/Tests/Models/CMS/CmsComment.php index d6db1cbba92..e5d816283e9 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsComment.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsComment.php @@ -17,29 +17,21 @@ #[Entity] class CmsComment implements Stringable { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $topic; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $text; - /** - * @var CmsArticle - */ + /** @var CmsArticle */ #[ManyToOne(targetEntity: 'CmsArticle', inversedBy: 'comments')] #[JoinColumn(name: 'article_id', referencedColumnName: 'id')] public $article; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsEmail.php b/tests/Doctrine/Tests/Models/CMS/CmsEmail.php index e494732e387..905b3624d9f 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsEmail.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsEmail.php @@ -18,23 +18,17 @@ #[Entity] class CmsEmail { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(length: 250)] public $email; - /** - * @var CmsUser - */ + /** @var CmsUser */ #[OneToOne(targetEntity: 'CmsUser', mappedBy: 'email')] public $user; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php index d7f7454bbe5..d419b46ba41 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php @@ -21,23 +21,17 @@ #[Entity] class CmsGroup implements IteratorAggregate { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(length: 50)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'CmsUser', mappedBy: 'groups')] public $users; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php b/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php index e52fd9fd1e8..7bfe373cb3d 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php @@ -15,16 +15,12 @@ #[Entity] class CmsPhonenumber { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(length: 50)] public $phonenumber; - /** - * @var CmsUser - */ + /** @var CmsUser */ #[ManyToOne(targetEntity: 'CmsUser', inversedBy: 'phonenumbers', cascade: ['merge'])] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsTag.php b/tests/Doctrine/Tests/Models/CMS/CmsTag.php index a56c3028463..aef3dc132c8 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsTag.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsTag.php @@ -19,23 +19,17 @@ #[Entity] class CmsTag { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(length: 50, name: 'tag_name', nullable: true)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'CmsUser', mappedBy: 'tags')] public $users; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Doctrine/Tests/Models/CMS/CmsUser.php index 191cd6f7445..335525fb366 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Models\CMS; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadata; @@ -12,6 +11,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -23,69 +23,49 @@ #[Entity] class CmsUser { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 50, nullable: true)] public $status; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, unique: true)] public $username; - /** - * @psalm-var string|null - */ + /** @psalm-var string|null */ #[Column(type: 'string', length: 255)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'CmsPhonenumber', mappedBy: 'user', cascade: ['persist', 'merge'], orphanRemoval: true)] public $phonenumbers; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'CmsArticle', mappedBy: 'user', cascade: ['detach'])] public $articles; - /** - * @var CmsAddress - */ + /** @var CmsAddress */ #[OneToOne(targetEntity: 'CmsAddress', mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] public $address; - /** - * @var CmsEmail - */ + /** @var CmsEmail */ #[OneToOne(targetEntity: 'CmsEmail', inversedBy: 'user', cascade: ['persist'], orphanRemoval: true)] #[JoinColumn(referencedColumnName: 'id', nullable: true)] public $email; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'cms_users_groups')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] #[ManyToMany(targetEntity: 'CmsGroup', inversedBy: 'users', cascade: ['persist', 'merge', 'detach'])] public $groups; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'cms_users_tags')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/Models/Cache/Action.php b/tests/Doctrine/Tests/Models/Cache/Action.php index 68760a63b22..95495b8df7c 100644 --- a/tests/Doctrine/Tests/Models/Cache/Action.php +++ b/tests/Doctrine/Tests/Models/Cache/Action.php @@ -17,9 +17,7 @@ #[Entity] class Action { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Token', cascade: ['persist', 'remove'], mappedBy: 'action')] public $tokens; diff --git a/tests/Doctrine/Tests/Models/Cache/Address.php b/tests/Doctrine/Tests/Models/Cache/Address.php index 4980b9f95f5..442457d957c 100644 --- a/tests/Doctrine/Tests/Models/Cache/Address.php +++ b/tests/Doctrine/Tests/Models/Cache/Address.php @@ -16,17 +16,13 @@ #[Entity] class Address { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var Person - */ + /** @var Person */ #[JoinColumn(name: 'person_id', referencedColumnName: 'id')] #[OneToOne(targetEntity: 'Person', inversedBy: 'address')] public $person; diff --git a/tests/Doctrine/Tests/Models/Cache/Attraction.php b/tests/Doctrine/Tests/Models/Cache/Attraction.php index 7722900a7b1..385dc65adcb 100644 --- a/tests/Doctrine/Tests/Models/Cache/Attraction.php +++ b/tests/Doctrine/Tests/Models/Cache/Attraction.php @@ -25,17 +25,13 @@ #[DiscriminatorMap([1 => 'Restaurant', 2 => 'Beach', 3 => 'Bar'])] abstract class Attraction { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] protected $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[Cache] #[OneToMany(targetEntity: 'AttractionInfo', mappedBy: 'attraction')] protected $infos; diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php b/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php index cea2c3da043..70ac0565594 100644 --- a/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php @@ -12,9 +12,7 @@ #[Entity] class AttractionContactInfo extends AttractionInfo { - /** - * @var string - */ + /** @var string */ #[Column(unique: true)] protected $fone; diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php b/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php index 07008ac586e..6885565b30b 100644 --- a/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php @@ -22,17 +22,13 @@ #[DiscriminatorMap([1 => 'AttractionContactInfo', 2 => 'AttractionLocationInfo'])] abstract class AttractionInfo { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] protected $id; - /** - * @var Attraction - */ + /** @var Attraction */ #[Cache] #[ManyToOne(targetEntity: 'Attraction', inversedBy: 'infos')] #[JoinColumn(name: 'attraction_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php b/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php index d34f7293783..093df20f8bc 100644 --- a/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php @@ -12,9 +12,7 @@ #[Entity] class AttractionLocationInfo extends AttractionInfo { - /** - * @var string - */ + /** @var string */ #[Column(unique: true)] protected $address; diff --git a/tests/Doctrine/Tests/Models/Cache/Client.php b/tests/Doctrine/Tests/Models/Cache/Client.php index 25316748440..991fa1e8816 100644 --- a/tests/Doctrine/Tests/Models/Cache/Client.php +++ b/tests/Doctrine/Tests/Models/Cache/Client.php @@ -14,9 +14,7 @@ #[Entity] class Client { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php index 2e174d651f3..58eb8513db6 100644 --- a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php +++ b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php @@ -18,23 +18,17 @@ #[Entity] class ComplexAction { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Token', cascade: ['persist', 'remove'], mappedBy: 'complexAction')] public $tokens; public function __construct( - /** - * @var Action - */ + /** @var Action */ #[Id] #[OneToOne(targetEntity: 'Action', cascade: ['persist', 'remove'])] #[JoinColumn(name: 'action1_name', referencedColumnName: 'name')] public $action1, - /** - * @var Action - */ + /** @var Action */ #[Id] #[OneToOne(targetEntity: 'Action', cascade: ['persist', 'remove'])] #[JoinColumn(name: 'action2_name', referencedColumnName: 'name')] diff --git a/tests/Doctrine/Tests/Models/Cache/Country.php b/tests/Doctrine/Tests/Models/Cache/Country.php index 772a5dff5a5..09b3b1c3595 100644 --- a/tests/Doctrine/Tests/Models/Cache/Country.php +++ b/tests/Doctrine/Tests/Models/Cache/Country.php @@ -16,9 +16,7 @@ #[Entity] class Country { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/Models/Cache/Flight.php b/tests/Doctrine/Tests/Models/Cache/Flight.php index c59a142a1df..e1b12aadfca 100644 --- a/tests/Doctrine/Tests/Models/Cache/Flight.php +++ b/tests/Doctrine/Tests/Models/Cache/Flight.php @@ -18,9 +18,7 @@ #[Cache('NONSTRICT_READ_WRITE')] class Flight { - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'date')] protected $departure; diff --git a/tests/Doctrine/Tests/Models/Cache/Login.php b/tests/Doctrine/Tests/Models/Cache/Login.php index 9c7705a43f5..52e522448e0 100644 --- a/tests/Doctrine/Tests/Models/Cache/Login.php +++ b/tests/Doctrine/Tests/Models/Cache/Login.php @@ -16,17 +16,13 @@ #[Entity] class Login { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var Token - */ + /** @var Token */ #[ManyToOne(targetEntity: 'Token', cascade: ['persist', 'remove'], inversedBy: 'logins')] #[JoinColumn(name: 'token_id', referencedColumnName: 'token')] public $token; diff --git a/tests/Doctrine/Tests/Models/Cache/Person.php b/tests/Doctrine/Tests/Models/Cache/Person.php index 201411709d8..40ff28d67ec 100644 --- a/tests/Doctrine/Tests/Models/Cache/Person.php +++ b/tests/Doctrine/Tests/Models/Cache/Person.php @@ -17,17 +17,13 @@ #[Cache('NONSTRICT_READ_WRITE')] class Person { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var Address - */ + /** @var Address */ #[OneToOne(targetEntity: 'Address', mappedBy: 'person')] public $address; diff --git a/tests/Doctrine/Tests/Models/Cache/State.php b/tests/Doctrine/Tests/Models/Cache/State.php index 05d92786f99..d72fbacadfb 100644 --- a/tests/Doctrine/Tests/Models/Cache/State.php +++ b/tests/Doctrine/Tests/Models/Cache/State.php @@ -21,17 +21,13 @@ #[Cache('NONSTRICT_READ_WRITE')] class State { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] protected $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[Cache('NONSTRICT_READ_WRITE')] #[OneToMany(targetEntity: 'City', mappedBy: 'state')] protected $cities; diff --git a/tests/Doctrine/Tests/Models/Cache/Token.php b/tests/Doctrine/Tests/Models/Cache/Token.php index 68c7ad5cd58..a0a5a749cc6 100644 --- a/tests/Doctrine/Tests/Models/Cache/Token.php +++ b/tests/Doctrine/Tests/Models/Cache/Token.php @@ -26,28 +26,20 @@ #[Cache('READ_ONLY')] class Token { - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'date')] public $expiresAt; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Login', cascade: ['persist', 'remove'], mappedBy: 'token')] public $logins; - /** - * @var Action - */ + /** @var Action */ #[ManyToOne(targetEntity: 'Action', cascade: ['persist', 'remove'], inversedBy: 'tokens')] #[JoinColumn(name: 'action_name', referencedColumnName: 'name')] public $action; - /** - * @var ComplexAction - */ + /** @var ComplexAction */ #[JoinColumn(name: 'complex_action1_name', referencedColumnName: 'action1_name')] #[JoinColumn(name: 'complex_action2_name', referencedColumnName: 'action2_name')] #[ManyToOne(targetEntity: 'ComplexAction', cascade: ['persist', 'remove'], inversedBy: 'tokens')] diff --git a/tests/Doctrine/Tests/Models/Cache/Travel.php b/tests/Doctrine/Tests/Models/Cache/Travel.php index 9a49f39a7e6..784c8ba0b8f 100644 --- a/tests/Doctrine/Tests/Models/Cache/Travel.php +++ b/tests/Doctrine/Tests/Models/Cache/Travel.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Models\Cache; -use Doctrine\ORM\Mapping\InverseJoinColumn; use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; @@ -13,6 +12,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -24,23 +24,17 @@ #[Entity] class Travel { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] protected $id; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'date')] protected $createdAt; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'cache_visited_cities')] #[JoinColumn(name: 'travel_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'city_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/Models/Cache/Traveler.php b/tests/Doctrine/Tests/Models/Cache/Traveler.php index 1ec44167ffd..a1f5363785c 100644 --- a/tests/Doctrine/Tests/Models/Cache/Traveler.php +++ b/tests/Doctrine/Tests/Models/Cache/Traveler.php @@ -20,24 +20,18 @@ #[Entity] class Traveler { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] protected $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[Cache('NONSTRICT_READ_WRITE')] #[OneToMany(targetEntity: 'Travel', mappedBy: 'traveler', cascade: ['persist', 'remove'], orphanRemoval: true)] public $travels; - /** - * @var TravelerProfile - */ + /** @var TravelerProfile */ #[Cache] #[OneToOne(targetEntity: 'TravelerProfile')] protected $profile; diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php index 7680d50a677..cb9cb996301 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php @@ -17,9 +17,7 @@ #[Cache('NONSTRICT_READ_WRITE')] class TravelerProfile { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php index 839e5ab868b..0d608f18fa0 100644 --- a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php +++ b/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php @@ -18,9 +18,7 @@ #[Cache('NONSTRICT_READ_WRITE')] class TravelerProfileInfo { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index 9523dd2f741..974fb8dfbe5 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Models\Company; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Events; @@ -18,6 +17,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -40,9 +40,7 @@ abstract class CompanyContract #[Column(type: 'boolean')] private bool $completed = false; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'company_contract_employees')] #[JoinColumn(name: 'contract_id', referencedColumnName: 'id', onDelete: 'CASCADE')] #[InverseJoinColumn(name: 'employee_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php index d0e359466b7..e48746cab8b 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php @@ -25,15 +25,11 @@ class CompanyEmployee extends CompanyPerson #[Column(type: 'datetime', nullable: true)] private DateTime|null $startDate = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'CompanyContract', mappedBy: 'engineers', fetch: 'EXTRA_LAZY')] public $contracts; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'CompanyFlexUltraContract', mappedBy: 'salesPerson', fetch: 'EXTRA_LAZY')] public $soldContracts; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index 6470f63cdda..aa3138a48de 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Models\Company; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; @@ -12,6 +11,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -19,9 +19,7 @@ #[ORM\Entity] class CompanyFlexContract extends CompanyContract { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -33,9 +31,7 @@ class CompanyFlexContract extends CompanyContract #[Column(type: 'integer')] private int $pricePerHour = 0; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'company_contract_managers')] #[JoinColumn(name: 'contract_id', referencedColumnName: 'id', onDelete: 'CASCADE')] #[InverseJoinColumn(name: 'employee_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/tests/Doctrine/Tests/Models/Company/CompanyManager.php index d3571fabc2c..c0a12351dba 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyManager.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyManager.php @@ -23,9 +23,7 @@ class CompanyManager extends CompanyEmployee #[JoinColumn(name: 'car_id', referencedColumnName: 'id')] private CompanyCar|null $car = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'CompanyFlexContract', mappedBy: 'managers', fetch: 'EXTRA_LAZY')] public $managedContracts; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php b/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php index c00c7aacc17..3e6de6f5037 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php @@ -23,9 +23,7 @@ class CompanyOrganization #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'CompanyEvent', mappedBy: 'organization', cascade: ['persist'], fetch: 'EXTRA_LAZY')] public $events; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php index 10e89d38144..ad4082a4ea3 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyPerson.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Models\Company; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadata; @@ -15,6 +14,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -43,9 +43,7 @@ class CompanyPerson #[JoinColumn(name: 'spouse_id', referencedColumnName: 'id', onDelete: 'CASCADE')] private CompanyPerson|null $spouse = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'company_persons_friends')] #[JoinColumn(name: 'person_id', referencedColumnName: 'id', onDelete: 'CASCADE')] #[InverseJoinColumn(name: 'friend_id', referencedColumnName: 'id', onDelete: 'CASCADE')] diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php index 7499dbef802..b1a8fb9db79 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php @@ -11,9 +11,7 @@ #[Entity] class JoinedChildClass extends JoinedRootClass { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $extension = 'ext'; diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php index 1016372c5e8..3089c2fd606 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php @@ -13,9 +13,7 @@ #[Entity] class JoinedDerivedChildClass extends JoinedDerivedRootClass { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $extension = 'ext'; diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php index 22fc8f2b912..a364b8914cf 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php @@ -14,16 +14,12 @@ #[Entity] class JoinedDerivedIdentityClass { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] #[Id] protected $id = 'part-0'; - /** - * @var JoinedDerivedRootClass[] - */ + /** @var JoinedDerivedRootClass[] */ #[OneToMany(targetEntity: 'JoinedDerivedRootClass', mappedBy: 'keyPart1')] protected $children; } diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php index 7658b2934ae..bbdd6d371e5 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php @@ -20,16 +20,12 @@ #[DiscriminatorMap(['child' => 'JoinedDerivedChildClass', 'root' => 'JoinedDerivedRootClass'])] class JoinedDerivedRootClass { - /** - * @var JoinedDerivedIdentityClass - */ + /** @var JoinedDerivedIdentityClass */ #[ManyToOne(targetEntity: 'JoinedDerivedIdentityClass', inversedBy: 'children')] #[Id] protected $keyPart1 = 'part-1'; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] #[Id] protected $keyPart2 = 'part-2'; diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php index 43fab121659..3d89d1bd7a9 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php @@ -17,16 +17,12 @@ #[DiscriminatorMap(['child' => 'JoinedChildClass', 'root' => 'JoinedRootClass'])] class JoinedRootClass { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] #[Id] protected $keyPart1 = 'part-1'; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] #[Id] protected $keyPart2 = 'part-2'; diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php index 36be1462f77..7e6e21192fa 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php @@ -11,9 +11,7 @@ #[Entity] class SingleChildClass extends SingleRootClass { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $extension = 'ext'; diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php index 82b882acf5a..82842a6e39a 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php @@ -17,16 +17,12 @@ #[DiscriminatorMap(['child' => 'SingleChildClass', 'root' => 'SingleRootClass'])] class SingleRootClass { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] #[Id] protected $keyPart1 = 'part-1'; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] #[Id] protected $keyPart2 = 'part-2'; diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php index 373b182e648..1df2d4860ad 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php @@ -17,9 +17,7 @@ #[Entity] class CustomIdObjectTypeParent { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild', cascade: ['persist', 'remove'], mappedBy: 'parent')] public $children; diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php index 7792b2e40d9..fdcf7b30a0d 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php @@ -14,17 +14,13 @@ #[Entity] class CustomTypeChild { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'upper_case_string', length: 255)] public $lowerCaseString = 'foo'; } diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php index 050896f4065..50107740a2c 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\Models\CustomType; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -21,35 +21,25 @@ #[Entity] class CustomTypeParent { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'negative_to_positive', nullable: true)] public $customInteger; - /** - * @var CustomTypeChild - */ + /** @var CustomTypeChild */ #[OneToOne(targetEntity: 'Doctrine\Tests\Models\CustomType\CustomTypeChild', cascade: ['persist', 'remove'])] public $child; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'Doctrine\Tests\Models\CustomType\CustomTypeParent', mappedBy: 'myFriends')] private $friendsWithMe; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'customtype_parent_friends')] #[JoinColumn(name: 'customtypeparent_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'friend_customtypeparent_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php b/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php index 97051aa72be..8c2daf2cac0 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php @@ -14,23 +14,17 @@ #[Entity] class CustomTypeUpperCase { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'upper_case_string', length: 255)] public $lowerCaseString; - /** - * @var string - */ + /** @var string */ #[Column(type: 'upper_case_string', length: 255, name: 'named_lower_case_string', nullable: true)] public $namedLowerCaseString; } diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php index 357b7119aac..6ab22230e3e 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php @@ -21,24 +21,18 @@ class DDC117Article #[GeneratedValue] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC117Reference', mappedBy: 'source', cascade: ['remove'])] private $references; #[OneToOne(targetEntity: 'DDC117ArticleDetails', mappedBy: 'article', cascade: ['persist', 'remove'])] private DDC117ArticleDetails|null $details = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC117Translation', mappedBy: 'article', cascade: ['persist', 'remove'])] private $translations; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'DDC117Link', mappedBy: 'source', indexBy: 'target_id', cascade: ['persist', 'remove'])] private Collection $links; diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php index c49c936c22c..2b0646ef88d 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php @@ -17,9 +17,7 @@ class DDC117ArticleDetails private string $text; public function __construct( - /** - * @var DDC117Article - */ + /** @var DDC117Article */ #[Id] #[OneToOne(targetEntity: 'DDC117Article', inversedBy: 'details')] #[JoinColumn(name: 'article_id', referencedColumnName: 'article_id')] diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php index f3cd3da1c4f..347df297cb0 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\Models\DDC117; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\JoinTable; @@ -20,17 +20,13 @@ #[Entity] class DDC117Editor { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable] #[JoinColumn(name: 'editor_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'article_id', referencedColumnName: 'article_id')] @@ -38,9 +34,7 @@ class DDC117Editor #[ManyToMany(targetEntity: 'DDC117Translation', inversedBy: 'reviewedByEditors')] public $reviewingTranslations; - /** - * @var DDC117Translation - */ + /** @var DDC117Translation */ #[JoinColumn(name: 'lt_article_id', referencedColumnName: 'article_id')] #[JoinColumn(name: 'lt_language', referencedColumnName: 'language')] #[ManyToOne(targetEntity: 'DDC117Translation', inversedBy: 'lastTranslatedBy')] diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php index bc01d8bc8bd..3f8460fa3f2 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php @@ -14,17 +14,13 @@ #[Entity] class DDC117Reference { - /** - * @var DDC117Article - */ + /** @var DDC117Article */ #[Id] #[ManyToOne(targetEntity: 'DDC117Article', inversedBy: 'references')] #[JoinColumn(name: 'source_id', referencedColumnName: 'article_id')] private $source; - /** - * @var DDC117Article - */ + /** @var DDC117Article */ #[Id] #[ManyToOne(targetEntity: 'DDC117Article')] #[JoinColumn(name: 'target_id', referencedColumnName: 'article_id')] diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php index a7522fb88d5..cccc8d8d80a 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php @@ -17,22 +17,16 @@ #[Entity] class DDC117Translation { - /** - * @var Collection - */ + /** @var Collection */ #[ManyToMany(targetEntity: 'DDC117Editor', mappedBy: 'reviewingTranslations')] public $reviewedByEditors; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'DDC117Editor', mappedBy: 'lastTranslation')] public $lastTranslatedBy; public function __construct( - /** - * @var DDC117Article - */ + /** @var DDC117Article */ #[Id] #[ManyToOne(targetEntity: 'DDC117Article', inversedBy: 'translations')] #[JoinColumn(name: 'article_id', referencedColumnName: 'article_id')] diff --git a/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php b/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php index be8ca6967ed..cd776db844c 100644 --- a/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php +++ b/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php @@ -15,17 +15,13 @@ #[MappedSuperclass] abstract class DDC1590Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'datetime')] protected $createdAt; diff --git a/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php b/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php index 7274bdfe30e..789dc9eadad 100644 --- a/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php +++ b/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php @@ -13,9 +13,7 @@ #[Entity] class DDC1590User extends DDC1590Entity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php index b05a285af2c..735d014eb69 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php @@ -11,22 +11,16 @@ trait DDC1872ExampleTrait { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] private $id; - /** - * @var int - */ + /** @var int */ #[Column(name: 'trait_foo', type: 'integer', length: 100, nullable: true, unique: true)] protected $foo; - /** - * @var DDC1872Bar - */ + /** @var DDC1872Bar */ #[OneToOne(targetEntity: 'DDC1872Bar', cascade: ['persist', 'merge'])] #[JoinColumn(name: 'example_trait_bar_id', referencedColumnName: 'id')] protected $bar; diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php index de27cdf858c..475396fcb90 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php +++ b/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php @@ -23,9 +23,7 @@ class DDC2372Address #[Column(type: 'string', length: 255)] private string|null $street = null; - /** - * @var User - */ + /** @var User */ #[OneToOne(targetEntity: 'User', mappedBy: 'address')] private $user; diff --git a/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php b/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php index 019e5690116..0114e22f6ad 100644 --- a/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php +++ b/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php @@ -10,9 +10,7 @@ trait DDC2372AddressAndAccessors { - /** - * @var DDC2372Address - */ + /** @var DDC2372Address */ #[OneToOne(targetEntity: 'Doctrine\Tests\Models\DDC2372\DDC2372Address', inversedBy: 'user')] #[JoinColumn(name: 'address_id', referencedColumnName: 'id')] private $address; diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php b/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php index fb40e31083c..360343da913 100644 --- a/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php +++ b/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php @@ -15,9 +15,7 @@ #[Entity] class DDC2504OtherClass { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php b/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php index 6243a9b205f..16e79bd284d 100644 --- a/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php +++ b/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php @@ -19,17 +19,13 @@ #[DiscriminatorMap(['root' => 'DDC2504RootClass', 'child' => 'DDC2504ChildClass'])] class DDC2504RootClass { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] public $id; - /** - * @var DDC2504OtherClass - */ + /** @var DDC2504OtherClass */ #[ManyToOne(targetEntity: 'DDC2504OtherClass', inversedBy: 'childClasses')] public $other; } diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php index d29a42f87e2..0e50ff1a97d 100644 --- a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php +++ b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php @@ -14,17 +14,13 @@ #[Entity(repositoryClass: 'DDC3231User1Repository')] class DDC3231User1 { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php index 14288445751..a5e2ea2b4b1 100644 --- a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php +++ b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php @@ -12,17 +12,13 @@ #[Entity(repositoryClass: 'DDC3231User1NoNamespaceRepository')] class DDC3231User1NoNamespace { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php index 02a28683f35..4e82a5750c7 100644 --- a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php +++ b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php @@ -14,17 +14,13 @@ #[Entity(repositoryClass: 'DDC3231User2Repository')] class DDC3231User2 { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php index f9fd764b36e..d8c1e6a2afc 100644 --- a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php +++ b/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php @@ -12,17 +12,13 @@ #[Entity(repositoryClass: 'DDC3231User2NoNamespaceRepository')] class DDC3231User2NoNamespace { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php index 1390bbc36a1..fddb0231667 100644 --- a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php +++ b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php @@ -16,17 +16,13 @@ #[Entity] class DDC3346Article { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var DDC3346Author - */ + /** @var DDC3346Author */ #[ManyToOne(targetEntity: 'DDC3346Author', inversedBy: 'articles')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; diff --git a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php index ae9041d7c6d..8c76fb3a85f 100644 --- a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php +++ b/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php @@ -16,23 +16,17 @@ #[Entity] class DDC3346Author { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, unique: true)] public $username; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'DDC3346Article', mappedBy: 'user', fetch: 'EAGER', cascade: ['detach'])] public $articles = []; } diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php index db8f908e67d..6f0ae3b4fae 100644 --- a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php +++ b/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php @@ -26,23 +26,17 @@ #[HasLifecycleCallbacks] abstract class DDC3597Root { - /** - * @var int - */ + /** @var int */ #[Column(name: 'id', type: 'integer', nullable: false)] #[Id] #[GeneratedValue(strategy: 'IDENTITY')] protected $id; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(name: 'created_at', type: 'datetime', nullable: false)] protected $createdAt = null; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(name: 'updated_at', type: 'datetime', nullable: false)] protected $updatedAt = null; diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php b/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php index 895d156ced0..57a179f8bf8 100644 --- a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php +++ b/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php @@ -16,28 +16,20 @@ #[Entity] class DDC3699Child extends DDC3699Parent { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $childField; - /** - * @var DDC3699RelationOne - */ + /** @var DDC3699RelationOne */ #[OneToOne(targetEntity: 'DDC3699RelationOne', inversedBy: 'child')] public $oneRelation; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3699RelationMany', mappedBy: 'child')] public $relations; } diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php b/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php index ca804cb859e..3644975bc7d 100644 --- a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php +++ b/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php @@ -10,9 +10,7 @@ #[MappedSuperclass] abstract class DDC3699Parent { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $parentField; } diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php b/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php index eb481dd3a5e..a990663438c 100644 --- a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php +++ b/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php @@ -14,16 +14,12 @@ #[Entity] class DDC3699RelationMany { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var DDC3699Child - */ + /** @var DDC3699Child */ #[ManyToOne(targetEntity: 'DDC3699Child', inversedBy: 'relations')] public $child; } diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php b/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php index 13ab5817c07..c75246899d1 100644 --- a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php +++ b/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php @@ -14,16 +14,12 @@ #[Entity] class DDC3699RelationOne { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var DDC3699Child - */ + /** @var DDC3699Child */ #[OneToOne(targetEntity: 'DDC3699Child', mappedBy: 'oneRelation')] public $child; } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php index 44b6e23f47e..43e585eaca2 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php @@ -20,22 +20,16 @@ #[DiscriminatorMap(['fix' => 'DDC3899FixContract', 'flexible' => 'DDC3899FlexContract'])] abstract class DDC3899Contract { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var bool - */ + /** @var bool */ #[Column(type: 'boolean')] public $completed = false; - /** - * @var DDC3899User - */ + /** @var DDC3899User */ #[ManyToOne(targetEntity: 'DDC3899User', inversedBy: 'contract')] public $user; } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php index a9db871b2b0..10f83f1c6f5 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php @@ -10,9 +10,7 @@ #[Entity] class DDC3899FixContract extends DDC3899Contract { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $fixPrice = 0; } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php index 3bbda5de96a..aa87d1d7cea 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php @@ -10,15 +10,11 @@ #[Entity] class DDC3899FlexContract extends DDC3899Contract { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $hoursWorked = 0; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $pricePerHour = 0; } diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php b/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php index f98d9d5f66e..9ae1febb10c 100644 --- a/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php +++ b/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php @@ -15,16 +15,12 @@ #[Entity] class DDC3899User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3899Contract', mappedBy: 'user')] public $contracts; } diff --git a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php b/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php index f601c763253..0596adc2624 100644 --- a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php +++ b/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php @@ -11,16 +11,12 @@ #[Entity] class DDC6412File { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(length: 50, name: 'file_name')] public $name; } diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php index 49826bc0757..ff75104078d 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php @@ -12,17 +12,13 @@ #[Entity(repositoryClass: 'Doctrine\Tests\Models\DDC753\DDC753CustomRepository')] class DDC753EntityWithCustomRepository { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php index dec2a21149b..81fd2f77c04 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php @@ -12,17 +12,13 @@ #[Entity] class DDC753EntityWithDefaultCustomRepository { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php index e8a0c99f868..e99dbe2b317 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php @@ -12,17 +12,13 @@ #[Entity(repositoryClass: '\stdClass')] class DDC753EntityWithInvalidRepository { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; } diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php b/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php index c79d938435d..565f50e1db1 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php @@ -11,9 +11,7 @@ class DDC889Class extends DDC889SuperClass { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php index 4d72a465cd9..b25c5a0f10b 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php @@ -19,9 +19,7 @@ class DDC964Group #[Column(type: 'integer')] private int $id; - /** - * @psalm-var ArrayCollection - */ + /** @psalm-var ArrayCollection */ #[ManyToMany(targetEntity: 'DDC964User', mappedBy: 'groups')] private $users; diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php index 15abce65a3f..b3330101ba4 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php @@ -18,9 +18,7 @@ abstract class AbstractContentItem #[GeneratedValue] private int $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php index ff27b455518..47bdb67441f 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php @@ -10,9 +10,7 @@ #[Entity] class Directory extends AbstractContentItem { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $path; diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/File.php b/tests/Doctrine/Tests/Models/DirectoryTree/File.php index e62e7c556ab..6b9f9aa1132 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/File.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/File.php @@ -12,9 +12,7 @@ #[Entity] class File extends AbstractContentItem { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $extension = 'html'; diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php index 35206144bfc..206a409deeb 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\Models\ECommerce; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -37,9 +37,7 @@ class ECommerceCart #[JoinColumn(name: 'customer_id', referencedColumnName: 'id')] private ECommerceCustomer|null $customer = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'ecommerce_carts_products')] #[JoinColumn(name: 'cart_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'product_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php index 2d454dbe898..db64b563f6d 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php @@ -32,15 +32,11 @@ class ECommerceCategory #[Column(type: 'string', length: 50)] private string|null $name = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'ECommerceProduct', mappedBy: 'categories')] private $products; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'ECommerceCategory', mappedBy: 'parent', cascade: ['persist'])] private $children; diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php index 9b87c3fe02c..8978ab0fad4 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Models\ECommerce; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -12,6 +11,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Index; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -40,15 +40,11 @@ class ECommerceProduct #[JoinColumn(name: 'shipping_id', referencedColumnName: 'id')] private ECommerceShipping|null $shipping = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'ECommerceFeature', mappedBy: 'product', cascade: ['persist'])] private $features; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'ecommerce_products_categories')] #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'category_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php b/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php index 611ff0c8223..5b352b00f2e 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php @@ -10,9 +10,7 @@ #[Entity] class ForumAdministrator extends ForumUser { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer', name: 'access_level')] public $accessLevel; } diff --git a/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php b/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php index 9e251220eba..99efd34e60b 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php @@ -14,9 +14,7 @@ #[Entity] class ForumAvatar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/Models/Forum/ForumBoard.php b/tests/Doctrine/Tests/Models/Forum/ForumBoard.php index 5954000e7ac..7e1f67a6be6 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumBoard.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumBoard.php @@ -18,20 +18,14 @@ #[Entity] class ForumBoard { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $position; - /** - * @var ForumCategory - */ + /** @var ForumCategory */ #[ManyToOne(targetEntity: 'ForumCategory', inversedBy: 'boards')] #[JoinColumn(name: 'category_id', referencedColumnName: 'id')] public $category; diff --git a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php b/tests/Doctrine/Tests/Models/Forum/ForumCategory.php index 62907c3e61d..f35e88fd5f8 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumCategory.php @@ -19,21 +19,15 @@ class ForumCategory #[Id] private int $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $position; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'ForumBoard', mappedBy: 'category')] public $boards; diff --git a/tests/Doctrine/Tests/Models/Forum/ForumEntry.php b/tests/Doctrine/Tests/Models/Forum/ForumEntry.php index de877ca2a71..1ab7b53dbc7 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumEntry.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumEntry.php @@ -14,16 +14,12 @@ #[Entity] class ForumEntry { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 50)] public $topic; diff --git a/tests/Doctrine/Tests/Models/Forum/ForumUser.php b/tests/Doctrine/Tests/Models/Forum/ForumUser.php index ee101fd99b9..08a4b937715 100644 --- a/tests/Doctrine/Tests/Models/Forum/ForumUser.php +++ b/tests/Doctrine/Tests/Models/Forum/ForumUser.php @@ -16,23 +16,17 @@ #[Entity] class ForumUser { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 50)] public $username; - /** - * @var ForumAvatar - */ + /** @var ForumAvatar */ #[OneToOne(targetEntity: 'ForumAvatar', cascade: ['persist'])] #[JoinColumn(name: 'avatar_id', referencedColumnName: 'id')] public $avatar; diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php b/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php index 5833ffc172d..c9c81223806 100644 --- a/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php +++ b/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php @@ -13,9 +13,7 @@ #[Entity] class GH8565Employee extends GH8565Person { - /** - * @var GH8565EmployeePayloadType - */ + /** @var GH8565EmployeePayloadType */ #[Column(type: 'GH8565EmployeePayloadType', nullable: false)] public $type; } diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php b/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php index 67d6e107872..f70cf34b4f2 100644 --- a/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php +++ b/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php @@ -13,9 +13,7 @@ #[Entity] class GH8565Manager extends GH8565Person { - /** - * @var GH8565ManagerPayloadType - */ + /** @var GH8565ManagerPayloadType */ #[Column(type: 'GH8565ManagerPayloadType', nullable: false)] public $type; } diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php b/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php index c83d761c8a6..fe0682a11fd 100644 --- a/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php +++ b/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php @@ -20,9 +20,7 @@ #[DiscriminatorMap(['person' => 'GH8565Person', 'manager' => 'GH8565Manager', 'employee' => 'GH8565Employee'])] class GH8565Person { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/Models/Generic/BooleanModel.php b/tests/Doctrine/Tests/Models/Generic/BooleanModel.php index 9a9ba587dde..2acf73d550f 100644 --- a/tests/Doctrine/Tests/Models/Generic/BooleanModel.php +++ b/tests/Doctrine/Tests/Models/Generic/BooleanModel.php @@ -14,17 +14,13 @@ #[Entity] class BooleanModel { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var bool - */ + /** @var bool */ #[Column(type: 'boolean')] public $booleanField; } diff --git a/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php b/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php index 81ae7f253d8..95b7db1a5b4 100644 --- a/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php +++ b/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php @@ -14,29 +14,21 @@ #[Entity] class DateTimeModel { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DateTime|null - */ + /** @var DateTime|null */ #[Column(name: 'col_datetime', type: 'datetime', nullable: true)] public $datetime; - /** - * @var DateTime|null - */ + /** @var DateTime|null */ #[Column(name: 'col_date', type: 'date', nullable: true)] public $date; - /** - * @var DateTime|null - */ + /** @var DateTime|null */ #[Column(name: 'col_time', type: 'time', nullable: true)] public $time; } diff --git a/tests/Doctrine/Tests/Models/Generic/DecimalModel.php b/tests/Doctrine/Tests/Models/Generic/DecimalModel.php index 931623fbd9b..faeffc577f3 100644 --- a/tests/Doctrine/Tests/Models/Generic/DecimalModel.php +++ b/tests/Doctrine/Tests/Models/Generic/DecimalModel.php @@ -14,23 +14,17 @@ #[Entity] class DecimalModel { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var float - */ + /** @var float */ #[Column(name: '`decimal`', type: 'decimal', scale: 2, precision: 5)] public $decimal; - /** - * @var float - */ + /** @var float */ #[Column(name: '`high_scale`', type: 'decimal', scale: 4, precision: 14)] public $highScale; } diff --git a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php index 3bcdafe70c4..8ec55238cc5 100644 --- a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php +++ b/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php @@ -14,9 +14,7 @@ #[Entity] class NonAlphaColumnsEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer', name: '`simple-entity-id`')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/Models/Generic/SerializationModel.php b/tests/Doctrine/Tests/Models/Generic/SerializationModel.php index 1684c1eedb5..0508ccae3a1 100644 --- a/tests/Doctrine/Tests/Models/Generic/SerializationModel.php +++ b/tests/Doctrine/Tests/Models/Generic/SerializationModel.php @@ -14,23 +14,17 @@ #[Entity] class SerializationModel { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var mixed[] - */ + /** @var mixed[] */ #[Column(name: 'the_array', type: 'array', nullable: true)] public $array; - /** - * @var object - */ + /** @var object */ #[Column(name: 'the_obj', type: 'object', nullable: true)] public $object; } diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php index ecb57767b85..f20e365c134 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1.php @@ -19,9 +19,7 @@ #[Cache] class Admin1 { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Admin1AlternateName', mappedBy: 'admin1')] #[Cache] public $names = []; diff --git a/tests/Doctrine/Tests/Models/GeoNames/City.php b/tests/Doctrine/Tests/Models/GeoNames/City.php index fd00f137ab3..2a6211b939d 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/City.php +++ b/tests/Doctrine/Tests/Models/GeoNames/City.php @@ -19,17 +19,13 @@ #[Cache] class City { - /** - * @var Country - */ + /** @var Country */ #[ManyToOne(targetEntity: 'Country')] #[JoinColumn(name: 'country', referencedColumnName: 'id')] #[Cache] public $country; - /** - * @var Admin1 - */ + /** @var Admin1 */ #[JoinColumn(name: 'admin1', referencedColumnName: 'id')] #[JoinColumn(name: 'country', referencedColumnName: 'country')] #[ManyToOne(targetEntity: 'Admin1')] diff --git a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php b/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php index 2579b9894bd..eebdf7c20db 100644 --- a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php +++ b/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php @@ -1,12 +1,12 @@ - */ + /** @psalm-var Collection */ #[JoinTable(name: 'author_articles')] #[JoinColumn(name: 'article_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'author_id', referencedColumnName: 'id', unique: true)] #[ManyToMany(targetEntity: 'DoctrineGlobalUser')] protected $author; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'editor_articles')] #[JoinColumn(name: 'article_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'editor_id', referencedColumnName: 'id', unique: true)] diff --git a/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php b/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php index 919ee05ebea..1c8af8e1563 100644 --- a/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php +++ b/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php @@ -14,17 +14,13 @@ #[Entity] class EntityWithArrayDefaultArrayValueM2M { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: SimpleEntity::class)] public $collection = []; } diff --git a/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php b/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php index 79c9f1dc725..ec77a24ab9a 100644 --- a/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php +++ b/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php @@ -12,9 +12,7 @@ #[Entity] class SimpleEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php index eabd7f4e628..b48c60dc59e 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php @@ -12,9 +12,7 @@ #[Entity] class Issue5989Employee extends Issue5989Person { - /** - * @var array - */ + /** @var array */ #[Column(type: 'simple_array', nullable: true)] public $tags; } diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php index 334c407241d..e353e42f1bf 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php @@ -12,9 +12,7 @@ #[Entity] class Issue5989Manager extends Issue5989Person { - /** - * @var array - */ + /** @var array */ #[Column(type: 'simple_array', nullable: true)] public $tags; } diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php index 4328af3aaa8..809f60f7b7f 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php @@ -20,9 +20,7 @@ #[DiscriminatorMap(['person' => 'Issue5989Person', 'manager' => 'Issue5989Manager', 'employee' => 'Issue5989Employee'])] class Issue5989Person { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php b/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php index a46959bc57c..0c12e9715f4 100644 --- a/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php +++ b/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php @@ -14,9 +14,7 @@ #[InheritanceType('JOINED')] class RootClass { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php b/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php index 19ff89fbd85..a910ea22eeb 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php @@ -16,29 +16,21 @@ #[Entity] class LegacyArticle { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'iArticleId', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'sTopic', type: 'string', length: 255)] public $topic; - /** - * @var string - */ + /** @var string */ #[Column(name: 'sText', type: 'text')] public $text; - /** - * @var LegacyUser - */ + /** @var LegacyUser */ #[ManyToOne(targetEntity: 'LegacyUser', inversedBy: 'articles')] #[JoinColumn(name: 'iUserId', referencedColumnName: 'iUserId')] public $user; diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php b/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php index 0c81c7fe69c..5297d6a2e66 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php @@ -16,23 +16,17 @@ #[Entity] class LegacyCar { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(name: 'iCarId', type: 'integer', nullable: false)] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'LegacyUser', mappedBy: 'cars')] public $users; - /** - * @var string - */ + /** @var string */ #[Column(name: 'sDescription', type: 'string', length: 255, unique: true)] public $description; diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php b/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php index cda0b01d56c..50e1231a596 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\Models\Legacy; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -21,41 +21,29 @@ #[Entity] class LegacyUser { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(name: 'iUserId', type: 'integer', nullable: false)] public $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'sUsername', type: 'string', length: 255, unique: true)] public $username; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, name: 'name')] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'LegacyArticle', mappedBy: 'user')] public $articles; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'LegacyUserReference', mappedBy: '_source', cascade: ['remove'])] public $references; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'legacy_users_cars')] #[JoinColumn(name: 'iUserId', referencedColumnName: 'iUserId')] #[InverseJoinColumn(name: 'iCarId', referencedColumnName: 'iCarId')] diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php index 293da400b9e..b92cb70ccb5 100644 --- a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php +++ b/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\Models\ManyToManyPersister; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; diff --git a/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php b/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php index 75c5efd7e8e..f3372e96763 100644 --- a/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php +++ b/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php @@ -14,17 +14,13 @@ #[Entity] class CompositeToOneKeyState { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] #[GeneratedValue(strategy: 'NONE')] public $state; - /** - * @var Country - */ + /** @var Country */ #[Id] #[ManyToOne(targetEntity: 'Country', cascade: ['MERGE'])] #[JoinColumn(referencedColumnName: 'country')] diff --git a/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php b/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php index 8187da9ba44..5beb998d839 100644 --- a/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php +++ b/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php @@ -12,9 +12,7 @@ #[Entity] class Country { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] #[GeneratedValue(strategy: 'NONE')] diff --git a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php index 9933bfc2041..e9f92dced88 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavCountry.php @@ -21,9 +21,7 @@ class NavCountry #[GeneratedValue] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'NavPointOfInterest', mappedBy: 'country')] private $pois; diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php index 76d7bcdafb1..711b09514a5 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\Models\Navigation; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -28,9 +28,7 @@ class NavPointOfInterest #[Column(type: 'integer', name: 'nav_lat')] private int $lat; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'navigation_pois_visitors')] #[JoinColumn(name: 'poi_long', referencedColumnName: 'nav_long')] #[JoinColumn(name: 'poi_lat', referencedColumnName: 'nav_lat')] diff --git a/tests/Doctrine/Tests/Models/Navigation/NavTour.php b/tests/Doctrine/Tests/Models/Navigation/NavTour.php index 5d9ff440d46..5e42f509b78 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavTour.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavTour.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\Models\Navigation; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -25,9 +25,7 @@ class NavTour #[GeneratedValue] private int $id; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'navigation_tour_pois')] #[JoinColumn(name: 'tour_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'poi_long', referencedColumnName: 'nav_long')] diff --git a/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php b/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php index 32e5b205dcf..d86470bc031 100644 --- a/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php +++ b/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php @@ -4,10 +4,10 @@ namespace Doctrine\Tests\Models\NonPublicSchemaJoins; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -20,25 +20,19 @@ #[Entity] class User { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] public $id; - /** - * @var User[] - */ + /** @var User[] */ #[JoinTable(name: 'author_reader', schema: 'readers')] #[JoinColumn(name: 'author_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'reader_id', referencedColumnName: 'id')] #[ManyToMany(targetEntity: 'Doctrine\Tests\Models\NonPublicSchemaJoins\User', inversedBy: 'authors')] public $readers; - /** - * @var User[] - */ + /** @var User[] */ #[ManyToMany(targetEntity: 'Doctrine\Tests\Models\NonPublicSchemaJoins\User', mappedBy: 'readers')] public $authors; } diff --git a/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php b/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php index 9f22778c51b..9d75c7609dc 100644 --- a/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php +++ b/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php @@ -12,17 +12,13 @@ #[Entity] class NullDefaultColumn { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var mixed - */ + /** @var mixed */ #[Column(options: ['default' => null])] public $nullDefault; } diff --git a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php b/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php index 41698b28e18..e13bc077dd0 100644 --- a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php +++ b/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php @@ -15,17 +15,13 @@ #[Entity] class InverseSide { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] #[GeneratedValue(strategy: 'NONE')] public $id; - /** - * @var OwningSide - */ + /** @var OwningSide */ #[OneToOne(targetEntity: OwningSide::class, mappedBy: 'inverse')] public $owning; } diff --git a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php b/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php index f4b6da7a9d8..fc58b6b8b05 100644 --- a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php +++ b/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php @@ -16,9 +16,7 @@ #[Entity] class OwningSide { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] #[GeneratedValue(strategy: 'NONE')] diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php index 7cbaebe381b..f63f165c84f 100644 --- a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php +++ b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php @@ -10,9 +10,7 @@ #[Entity] class Cat extends Pet { - /** - * @var LitterBox - */ + /** @var LitterBox */ #[OneToOne(targetEntity: 'LitterBox')] public $litterBox; } diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php index 1bfcd7b707f..c90cbe43d85 100644 --- a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php +++ b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php @@ -14,9 +14,7 @@ #[Entity] class LitterBox { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php index 33df9837d46..f9bf67d0d17 100644 --- a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php +++ b/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php @@ -18,9 +18,7 @@ #[DiscriminatorMap(['cat' => 'Cat'])] abstract class Pet { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/Models/Pagination/Company.php b/tests/Doctrine/Tests/Models/Pagination/Company.php index e7b7ee6f69c..66f16d874c7 100644 --- a/tests/Doctrine/Tests/Models/Pagination/Company.php +++ b/tests/Doctrine/Tests/Models/Pagination/Company.php @@ -20,35 +20,25 @@ #[Entity] class Company { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, name: 'jurisdiction_code', nullable: true)] public $jurisdiction; - /** - * @var Logo - */ + /** @var Logo */ #[OneToOne(targetEntity: 'Logo', mappedBy: 'company', cascade: ['persist'], orphanRemoval: true)] public $logo; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Department', mappedBy: 'company', cascade: ['persist'], orphanRemoval: true)] public $departments; } diff --git a/tests/Doctrine/Tests/Models/Pagination/Department.php b/tests/Doctrine/Tests/Models/Pagination/Department.php index 88d3b6d06e8..9d906bd9970 100644 --- a/tests/Doctrine/Tests/Models/Pagination/Department.php +++ b/tests/Doctrine/Tests/Models/Pagination/Department.php @@ -18,23 +18,17 @@ #[Entity] class Department { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @var Company - */ + /** @var Company */ #[ManyToOne(targetEntity: 'Company', inversedBy: 'departments', cascade: ['persist'])] public $company; } diff --git a/tests/Doctrine/Tests/Models/Pagination/Logo.php b/tests/Doctrine/Tests/Models/Pagination/Logo.php index 67f4eb0e963..413070c5d56 100644 --- a/tests/Doctrine/Tests/Models/Pagination/Logo.php +++ b/tests/Doctrine/Tests/Models/Pagination/Logo.php @@ -19,35 +19,25 @@ #[Entity] class Logo { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $image; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $imageHeight; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $imageWidth; - /** - * @var Company - */ + /** @var Company */ #[OneToOne(targetEntity: 'Company', inversedBy: 'logo', cascade: ['persist'])] #[JoinColumn(name: 'company_id')] public $company; diff --git a/tests/Doctrine/Tests/Models/Pagination/User.php b/tests/Doctrine/Tests/Models/Pagination/User.php index c35fd44bd81..3600c857e4a 100644 --- a/tests/Doctrine/Tests/Models/Pagination/User.php +++ b/tests/Doctrine/Tests/Models/Pagination/User.php @@ -25,9 +25,7 @@ abstract class User #[GeneratedValue] private int $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; } diff --git a/tests/Doctrine/Tests/Models/Pagination/User1.php b/tests/Doctrine/Tests/Models/Pagination/User1.php index 8b79a281414..2d73598d147 100644 --- a/tests/Doctrine/Tests/Models/Pagination/User1.php +++ b/tests/Doctrine/Tests/Models/Pagination/User1.php @@ -10,9 +10,7 @@ #[Entity] class User1 extends User { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $email; } diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php index 8b964ee3ae8..2c960587d25 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php @@ -13,9 +13,7 @@ #[Entity] class PersistentCollectionContent extends PersistentObject { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php index 35bcd1029c4..c155e9be03f 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php @@ -16,17 +16,13 @@ #[Entity] class PersistentCollectionHolder extends PersistentObject { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] protected $id; - /** - * @var Collection - */ + /** @var Collection */ #[ManyToMany(targetEntity: 'PersistentCollectionContent', cascade: ['all'], fetch: 'EXTRA_LAZY')] protected $collection; diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php b/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php index cc5a659ec2d..ed55f4bb7a0 100644 --- a/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php +++ b/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php @@ -14,23 +14,17 @@ #[Entity] class PersistentEntity extends PersistentObject { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] protected $name; - /** - * @var PersistentEntity - */ + /** @var PersistentEntity */ #[ManyToOne(targetEntity: 'PersistentEntity')] protected $parent; } diff --git a/tests/Doctrine/Tests/Models/Quote/Address.php b/tests/Doctrine/Tests/Models/Quote/Address.php index f0cbf4083fc..bffefdd3b09 100644 --- a/tests/Doctrine/Tests/Models/Quote/Address.php +++ b/tests/Doctrine/Tests/Models/Quote/Address.php @@ -22,23 +22,17 @@ #[DiscriminatorMap(['simple' => Address::class, 'full' => FullAddress::class])] class Address { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer', name: '`address-id`')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(name: '`address-zip`')] public $zip; - /** - * @var User - */ + /** @var User */ #[OneToOne(targetEntity: 'User', inversedBy: 'address')] #[JoinColumn(name: '`user-id`', referencedColumnName: '`user-id`')] public $user; diff --git a/tests/Doctrine/Tests/Models/Quote/City.php b/tests/Doctrine/Tests/Models/Quote/City.php index f60472c06c1..07b8b9d897c 100644 --- a/tests/Doctrine/Tests/Models/Quote/City.php +++ b/tests/Doctrine/Tests/Models/Quote/City.php @@ -14,9 +14,7 @@ #[Entity] class City { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer', name: '`city-id`')] diff --git a/tests/Doctrine/Tests/Models/Quote/FullAddress.php b/tests/Doctrine/Tests/Models/Quote/FullAddress.php index fbefed7b9d7..5e13a2734e6 100644 --- a/tests/Doctrine/Tests/Models/Quote/FullAddress.php +++ b/tests/Doctrine/Tests/Models/Quote/FullAddress.php @@ -11,9 +11,7 @@ #[Entity] class FullAddress extends Address { - /** - * @var City - */ + /** @var City */ #[OneToOne(targetEntity: City::class, cascade: ['persist'])] #[JoinColumn(name: '`city-id`', referencedColumnName: '`city-id`')] public $city; diff --git a/tests/Doctrine/Tests/Models/Quote/Group.php b/tests/Doctrine/Tests/Models/Quote/Group.php index 8a4e4654b93..d9d941def13 100644 --- a/tests/Doctrine/Tests/Models/Quote/Group.php +++ b/tests/Doctrine/Tests/Models/Quote/Group.php @@ -18,17 +18,13 @@ #[Entity] class Group { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer', name: '`group-id`')] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'User', mappedBy: 'groups')] public $users; diff --git a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php index aa3d1b4643b..bb6aadab937 100644 --- a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php +++ b/tests/Doctrine/Tests/Models/Quote/NumericEntity.php @@ -14,9 +14,7 @@ #[Entity] class NumericEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer', name: '`1:1`')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/Models/Quote/Phone.php b/tests/Doctrine/Tests/Models/Quote/Phone.php index 13625b99011..daf159182c5 100644 --- a/tests/Doctrine/Tests/Models/Quote/Phone.php +++ b/tests/Doctrine/Tests/Models/Quote/Phone.php @@ -15,16 +15,12 @@ #[Entity] class Phone { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(name: '`phone-number`')] public $number; - /** - * @var User - */ + /** @var User */ #[ManyToOne(targetEntity: 'User', inversedBy: 'phones')] #[JoinColumn(name: '`user-id`', referencedColumnName: '`user-id`')] public $user; diff --git a/tests/Doctrine/Tests/Models/Quote/User.php b/tests/Doctrine/Tests/Models/Quote/User.php index 11ca1b3211b..efb7353a830 100644 --- a/tests/Doctrine/Tests/Models/Quote/User.php +++ b/tests/Doctrine/Tests/Models/Quote/User.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\Models\Quote; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -22,36 +22,26 @@ #[Entity] class User { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer', name: '`user-id`')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, name: '`user-name`')] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Phone', mappedBy: 'user', cascade: ['persist'])] public $phones; - /** - * @var Address - */ + /** @var Address */ #[JoinColumn(name: '`address-id`', referencedColumnName: '`address-id`')] #[OneToOne(targetEntity: 'Address', mappedBy: 'user', cascade: ['persist'], fetch: 'EAGER')] public $address; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: '`quote-users-groups`')] #[JoinColumn(name: '`user-id`', referencedColumnName: '`user-id`')] #[InverseJoinColumn(name: '`group-id`', referencedColumnName: '`group-id`')] diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php b/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php index 6bb473f11b8..c02d35b4e41 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php @@ -14,37 +14,27 @@ #[Entity] class RoutingLeg { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var RoutingLocation - */ + /** @var RoutingLocation */ #[ManyToOne(targetEntity: 'RoutingLocation')] #[JoinColumn(name: 'from_id', referencedColumnName: 'id')] public $fromLocation; - /** - * @var RoutingLocation - */ + /** @var RoutingLocation */ #[ManyToOne(targetEntity: 'RoutingLocation')] #[JoinColumn(name: 'to_id', referencedColumnName: 'id')] public $toLocation; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'datetime')] public $departureDate; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'datetime')] public $arrivalDate; } diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php b/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php index fee78ad274f..8c70dbfb612 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php @@ -12,17 +12,13 @@ #[Entity] class RoutingLocation { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php b/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php index ce4db441445..8720d7016ed 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\Models\Routing; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -20,17 +20,13 @@ #[Entity] class RoutingRoute { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'RoutingRouteLegs')] #[JoinColumn(name: 'route_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'leg_id', referencedColumnName: 'id', unique: true)] @@ -38,9 +34,7 @@ class RoutingRoute #[OrderBy(['departureDate' => 'ASC'])] public $legs; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'RoutingRouteBooking', mappedBy: 'route')] #[OrderBy(['passengerName' => 'ASC'])] public $bookings = []; diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php b/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php index 2d070e6a396..12d185b8517 100644 --- a/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php +++ b/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php @@ -14,24 +14,18 @@ #[Entity] class RoutingRouteBooking { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var RoutingRoute - */ + /** @var RoutingRoute */ #[ManyToOne(targetEntity: 'RoutingRoute', inversedBy: 'bookings')] #[JoinColumn(name: 'route_id', referencedColumnName: 'id')] public $route; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $passengerName = null; diff --git a/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/tests/Doctrine/Tests/Models/StockExchange/Bond.php index f9a6e026eda..d913aa431bb 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Bond.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Bond.php @@ -25,9 +25,7 @@ class Bond #[Column(type: 'integer')] private int $id; - /** - * @var Stock[] - */ + /** @var Stock[] */ #[JoinTable(name: 'exchange_bonds_stocks')] #[ManyToMany(targetEntity: 'Stock', indexBy: 'symbol')] public $stocks; diff --git a/tests/Doctrine/Tests/Models/StockExchange/Market.php b/tests/Doctrine/Tests/Models/StockExchange/Market.php index 2f65ab0ddc8..832afb62ac9 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Market.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Market.php @@ -21,9 +21,7 @@ class Market #[GeneratedValue] private int $id; - /** - * @psalm-var ArrayCollection - */ + /** @psalm-var ArrayCollection */ #[OneToMany(targetEntity: 'Stock', mappedBy: 'market', indexBy: 'symbol')] public $stocks; diff --git a/tests/Doctrine/Tests/Models/Taxi/Car.php b/tests/Doctrine/Tests/Models/Taxi/Car.php index e09b0169f02..1ee808363a6 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Car.php +++ b/tests/Doctrine/Tests/Models/Taxi/Car.php @@ -24,15 +24,11 @@ class Car #[Column(type: 'string', length: 255)] private string|null $model = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Ride', mappedBy: 'car')] private $freeCarRides; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'PaidRide', mappedBy: 'car')] private $carRides; diff --git a/tests/Doctrine/Tests/Models/Taxi/Driver.php b/tests/Doctrine/Tests/Models/Taxi/Driver.php index 8fcefbfb3b2..58e83efbf68 100644 --- a/tests/Doctrine/Tests/Models/Taxi/Driver.php +++ b/tests/Doctrine/Tests/Models/Taxi/Driver.php @@ -24,15 +24,11 @@ class Driver #[Column(type: 'string', length: 255)] private string|null $name = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Ride', mappedBy: 'driver')] private $freeDriverRides; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'PaidRide', mappedBy: 'driver')] private $driverRides; diff --git a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php index a41e9f6dda2..c6686aed73f 100644 --- a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php +++ b/tests/Doctrine/Tests/Models/Taxi/PaidRide.php @@ -18,9 +18,7 @@ #[Entity] class PaidRide { - /** - * @var float - */ + /** @var float */ #[Column(type: 'decimal', precision: 6, scale: 2)] private $fare; diff --git a/tests/Doctrine/Tests/Models/Tweet/Tweet.php b/tests/Doctrine/Tests/Models/Tweet/Tweet.php index 01a88f1f25a..8d180d61552 100644 --- a/tests/Doctrine/Tests/Models/Tweet/Tweet.php +++ b/tests/Doctrine/Tests/Models/Tweet/Tweet.php @@ -15,23 +15,17 @@ #[Entity] class Tweet { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $content; - /** - * @var User - */ + /** @var User */ #[ManyToOne(targetEntity: 'User', inversedBy: 'tweets')] public $author; diff --git a/tests/Doctrine/Tests/Models/Tweet/User.php b/tests/Doctrine/Tests/Models/Tweet/User.php index 9b99e6d0d30..38d2e89f8e1 100644 --- a/tests/Doctrine/Tests/Models/Tweet/User.php +++ b/tests/Doctrine/Tests/Models/Tweet/User.php @@ -17,29 +17,21 @@ #[Entity] class User { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Tweet', mappedBy: 'author', cascade: ['persist'], fetch: 'EXTRA_LAZY')] public $tweets; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'UserList', mappedBy: 'owner', fetch: 'EXTRA_LAZY', orphanRemoval: true)] public $userLists; diff --git a/tests/Doctrine/Tests/Models/Tweet/UserList.php b/tests/Doctrine/Tests/Models/Tweet/UserList.php index faf22c01e39..55db602e2bb 100644 --- a/tests/Doctrine/Tests/Models/Tweet/UserList.php +++ b/tests/Doctrine/Tests/Models/Tweet/UserList.php @@ -15,23 +15,17 @@ #[Entity] class UserList { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $listName; - /** - * @var User - */ + /** @var User */ #[ManyToOne(targetEntity: 'User', inversedBy: 'userLists')] public $owner; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php index 74deaed199e..0b8918b07ca 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php @@ -13,9 +13,7 @@ #[Entity] class AuxiliaryEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id4; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php index 640af5746b9..fca65f2528f 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php @@ -16,23 +16,17 @@ #[Entity] class InversedManyToManyCompositeIdEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'OwningManyToManyCompositeIdEntity', mappedBy: 'associatedEntities')] public $associatedEntities; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php index d0798d3a06f..aeb65dfbc4f 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php @@ -18,24 +18,18 @@ #[Entity] class InversedManyToManyCompositeIdForeignKeyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var AuxiliaryEntity - */ + /** @var AuxiliaryEntity */ #[ManyToOne(targetEntity: 'AuxiliaryEntity')] #[JoinColumn(name: 'foreign_id', referencedColumnName: 'id4')] #[Id] public $foreignEntity; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'OwningManyToManyCompositeIdForeignKeyEntity', mappedBy: 'associatedEntities')] public $associatedEntities; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php index 687f333e39d..01c40b7a573 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php @@ -16,16 +16,12 @@ #[Entity] class InversedManyToManyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'OwningManyToManyEntity', mappedBy: 'associatedEntities')] public $associatedEntities; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php index 857d9ab9daf..8dd18be20d9 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php @@ -16,16 +16,12 @@ #[Entity] class InversedManyToManyExtraLazyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var Collection - */ + /** @var Collection */ #[ManyToMany(targetEntity: 'OwningManyToManyExtraLazyEntity', mappedBy: 'associatedEntities', fetch: 'EXTRA_LAZY', indexBy: 'id2')] public $associatedEntities; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php index dfab64d2436..dd297b39081 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php @@ -16,29 +16,21 @@ #[Entity] class InversedOneToManyCompositeIdEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'OwningManyToOneCompositeIdEntity', mappedBy: 'associatedEntity')] public $associatedEntities; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php index c2b82e76fc6..05f72effcff 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php @@ -18,30 +18,22 @@ #[Entity] class InversedOneToManyCompositeIdForeignKeyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var AuxiliaryEntity - */ + /** @var AuxiliaryEntity */ #[ManyToOne(targetEntity: 'AuxiliaryEntity')] #[JoinColumn(name: 'foreign_id', referencedColumnName: 'id4')] #[Id] public $foreignEntity; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'OwningManyToOneCompositeIdForeignKeyEntity', mappedBy: 'associatedEntity')] public $associatedEntities; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php index bca66220a97..03795dcbd88 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php @@ -16,22 +16,16 @@ #[Entity] class InversedOneToManyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'OwningManyToOneEntity', mappedBy: 'associatedEntity')] public $associatedEntities; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', name: 'some_property', length: 255)] public $someProperty; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php index 7213d1cf19f..b7522a1905d 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php @@ -16,16 +16,12 @@ #[Entity] class InversedOneToManyExtraLazyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'OwningManyToOneExtraLazyEntity', mappedBy: 'associatedEntity', fetch: 'EXTRA_LAZY', indexBy: 'id2')] public $associatedEntities; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php index 8a867705f96..7478950ff35 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php @@ -14,29 +14,21 @@ #[Entity] class InversedOneToOneCompositeIdEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; - /** - * @var OwningOneToOneCompositeIdEntity - */ + /** @var OwningOneToOneCompositeIdEntity */ #[OneToOne(targetEntity: 'OwningOneToOneCompositeIdEntity', mappedBy: 'associatedEntity')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php index 7eff93ea244..ac1abe1ceeb 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php @@ -16,30 +16,22 @@ #[Entity] class InversedOneToOneCompositeIdForeignKeyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var AuxiliaryEntity - */ + /** @var AuxiliaryEntity */ #[ManyToOne(targetEntity: 'AuxiliaryEntity')] #[JoinColumn(name: 'foreign_id', referencedColumnName: 'id4')] #[Id] public $foreignEntity; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; - /** - * @var OwningOneToOneCompositeIdForeignKeyEntity - */ + /** @var OwningOneToOneCompositeIdForeignKeyEntity */ #[OneToOne(targetEntity: 'OwningOneToOneCompositeIdForeignKeyEntity', mappedBy: 'associatedEntity')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php index f66310aaea3..36096592a77 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php @@ -14,22 +14,16 @@ #[Entity] class InversedOneToOneEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id1; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255, name: 'some_property')] public $someProperty; - /** - * @var OwningOneToOneEntity - */ + /** @var OwningOneToOneEntity */ #[OneToOne(targetEntity: 'OwningOneToOneEntity', mappedBy: 'associatedEntity')] public $associatedEntity; } diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php index fad761aae5b..26bb0bade33 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\Models\ValueConversionType; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -19,16 +19,12 @@ #[Entity] class OwningManyToManyCompositeIdEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id3; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'vct_xref_manytomany_compositeid')] #[JoinColumn(name: 'owning_id', referencedColumnName: 'id3')] #[InverseJoinColumn(name: 'inversed_id1', referencedColumnName: 'id1')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php index c71d76f344c..d132d350704 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\Models\ValueConversionType; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -19,16 +19,12 @@ #[Entity] class OwningManyToManyCompositeIdForeignKeyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'vct_xref_manytomany_compositeid_foreignkey')] #[JoinColumn(name: 'owning_id', referencedColumnName: 'id2')] #[InverseJoinColumn(name: 'associated_id', referencedColumnName: 'id1')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php index 924d8aec1e9..c2b9534a0b1 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\Models\ValueConversionType; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -19,16 +19,12 @@ #[Entity] class OwningManyToManyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'vct_xref_manytomany')] #[JoinColumn(name: 'owning_id', referencedColumnName: 'id2')] #[InverseJoinColumn(name: 'inversed_id', referencedColumnName: 'id1')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php index f8f738f4b66..d8a5d5092df 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\Models\ValueConversionType; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -19,16 +19,12 @@ #[Entity] class OwningManyToManyExtraLazyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'vct_xref_manytomany_extralazy')] #[JoinColumn(name: 'owning_id', referencedColumnName: 'id2')] #[InverseJoinColumn(name: 'inversed_id', referencedColumnName: 'id1')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php index e9717c684c8..9c83ca48950 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php @@ -16,16 +16,12 @@ #[Entity] class OwningManyToOneCompositeIdEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id3; - /** - * @var InversedOneToManyCompositeIdEntity - */ + /** @var InversedOneToManyCompositeIdEntity */ #[JoinColumn(name: 'associated_id1', referencedColumnName: 'id1')] #[JoinColumn(name: 'associated_id2', referencedColumnName: 'id2')] #[ManyToOne(targetEntity: 'InversedOneToManyCompositeIdEntity', inversedBy: 'associatedEntities')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php index 5afa4541b9c..be3168c81d9 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php @@ -16,16 +16,12 @@ #[Entity] class OwningManyToOneCompositeIdForeignKeyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var InversedOneToManyCompositeIdForeignKeyEntity - */ + /** @var InversedOneToManyCompositeIdForeignKeyEntity */ #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] #[JoinColumn(name: 'associated_foreign_id', referencedColumnName: 'foreign_id')] #[ManyToOne(targetEntity: 'InversedOneToManyCompositeIdForeignKeyEntity', inversedBy: 'associatedEntities')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php index e0de3a54a4c..7896465571d 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php @@ -15,16 +15,12 @@ #[Entity] class OwningManyToOneEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var InversedOneToManyEntity - */ + /** @var InversedOneToManyEntity */ #[ManyToOne(targetEntity: 'InversedOneToManyEntity', inversedBy: 'associatedEntities')] #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] public $associatedEntity; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php index 5e181c0c91e..8e4dbfb5f96 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php @@ -15,16 +15,12 @@ #[Entity] class OwningManyToOneExtraLazyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var InversedOneToManyExtraLazyEntity - */ + /** @var InversedOneToManyExtraLazyEntity */ #[ManyToOne(targetEntity: 'InversedOneToManyExtraLazyEntity', inversedBy: 'associatedEntities')] #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] public $associatedEntity; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php index 8d2751bb73b..286c8241ad7 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php @@ -14,9 +14,7 @@ #[Entity] class OwningManyToOneIdForeignKeyEntity { - /** - * @var associatedEntities - */ + /** @var associatedEntities */ #[Id] #[ManyToOne(targetEntity: AuxiliaryEntity::class, inversedBy: 'associatedEntities')] #[JoinColumn(name: 'associated_id', referencedColumnName: 'id4')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php index ff5e8f00f6c..90a4cb1091c 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php @@ -16,16 +16,12 @@ #[Entity] class OwningOneToOneCompositeIdEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id3; - /** - * @var InversedOneToOneCompositeIdEntity - */ + /** @var InversedOneToOneCompositeIdEntity */ #[JoinColumn(name: 'associated_id1', referencedColumnName: 'id1')] #[JoinColumn(name: 'associated_id2', referencedColumnName: 'id2')] #[OneToOne(targetEntity: 'InversedOneToOneCompositeIdEntity', inversedBy: 'associatedEntity')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php index 4104e043234..fcff6cf6803 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php @@ -18,16 +18,12 @@ #[Entity] class OwningOneToOneCompositeIdForeignKeyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var InversedOneToOneCompositeIdForeignKeyEntity - */ + /** @var InversedOneToOneCompositeIdForeignKeyEntity */ #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] #[JoinColumn(name: 'associated_foreign_id', referencedColumnName: 'foreign_id')] #[OneToOne(targetEntity: 'InversedOneToOneCompositeIdForeignKeyEntity', inversedBy: 'associatedEntity')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php index c951ca15e98..7ea304d6777 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php @@ -15,16 +15,12 @@ #[Entity] class OwningOneToOneEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'rot13', length: 255)] #[Id] public $id2; - /** - * @var InversedOneToOneEntity - */ + /** @var InversedOneToOneEntity */ #[OneToOne(targetEntity: 'InversedOneToOneEntity', inversedBy: 'associatedEntity')] #[JoinColumn(name: 'associated_id', referencedColumnName: 'id1')] public $associatedEntity; diff --git a/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php b/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php index ff3d84edbe6..41468abc189 100644 --- a/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php +++ b/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php @@ -16,23 +16,17 @@ #[Entity] class Article { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name')] public $name; - /** - * @var Category - */ + /** @var Category */ #[ManyToOne(targetEntity: 'Category', cascade: ['merge', 'persist'])] public $category; diff --git a/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php b/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php index c53cf7ec1e2..148de2e3fed 100644 --- a/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php +++ b/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php @@ -15,9 +15,7 @@ #[Entity] class Category { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php b/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php index ea14434a021..3c30def93a9 100644 --- a/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php +++ b/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php @@ -16,17 +16,13 @@ #[Entity] class FirstRelatedEntity { - /** - * @var SecondRelatedEntity - */ + /** @var SecondRelatedEntity */ #[Id] #[OneToOne(targetEntity: 'SecondRelatedEntity', fetch: 'EAGER')] #[JoinColumn(name: 'second_entity_id', referencedColumnName: 'id')] public $secondEntity; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name')] public $name; diff --git a/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php b/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php index fd0cd32194c..a1e85ba6373 100644 --- a/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php +++ b/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php @@ -15,17 +15,13 @@ #[Entity] class SecondRelatedEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name')] public $name; diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php index c421596a8b0..c830ccdd6ee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -302,9 +302,7 @@ class Phrase #[JoinColumn(name: 'phrase_type_id', referencedColumnName: 'phrase_type_id')] private PhraseType|null $type = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Definition', mappedBy: 'phrase', cascade: ['persist'])] private $definitions; @@ -367,9 +365,7 @@ class PhraseType #[Column(type: 'string', name: 'phrase_type_abbreviation', unique: true)] private string|null $abbreviation = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Phrase', mappedBy: 'type')] private $phrases; diff --git a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php index 3755909b394..f3b7a30e2f8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php @@ -81,9 +81,7 @@ class CascadeRemoveOrderEntityO #[JoinColumn(nullable: true, onDelete: 'SET NULL')] private CascadeRemoveOrderEntityG|null $oneToOneG = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Doctrine\Tests\ORM\Functional\CascadeRemoveOrderEntityG', mappedBy: 'ownerO', cascade: ['persist', 'remove'])] private $oneToManyG; diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php index 8b84d2bbaa3..764f7733788 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php @@ -169,9 +169,7 @@ class CTIRelated2 #[GeneratedValue] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'CTIChild')] private $ctiChildren; diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index bebd7fb02e1..c91a3e8fc9c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -89,26 +89,18 @@ public function testGetPartialReferenceWithDefaultValueNotEvaluatedInFlush(): vo #[Entity] class DefaultValueUser { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name = ''; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $type = 'Poweruser'; - /** - * @var DefaultValueAddress - */ + /** @var DefaultValueAddress */ #[OneToOne(targetEntity: 'DefaultValueAddress', mappedBy: 'user', cascade: ['persist'])] public $address; @@ -125,29 +117,21 @@ public function getId(): int #[Entity] class DefaultValueAddress { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 50)] public $country; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 50)] public $zip; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 50)] public $city; @@ -157,9 +141,7 @@ class DefaultValueAddress */ public $street; - /** - * @var DefaultValueUser - */ + /** @var DefaultValueUser */ #[OneToOne(targetEntity: 'DefaultValueUser')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; diff --git a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php index 023a1edbc21..cfa9dc0dc06 100644 --- a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php @@ -99,9 +99,7 @@ public function getName(): string #[DiscriminatorMap(['child' => GH5988CustomIdObjectTypeChild::class])] abstract class GH5988CustomIdObjectTypeParent { - /** - * @var CustomIdObject - */ + /** @var CustomIdObject */ #[Id] #[Column(type: 'Doctrine\Tests\ORM\Functional\GH5988CustomIdObjectHashType', length: 255)] public $id; diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index 65ae8bd3237..b139e0f3641 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -472,15 +472,11 @@ class LifecycleCallbackTestEntity #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', nullable: true)] public $value; - /** - * @var LifecycleCallbackCascader - */ + /** @var LifecycleCallbackCascader */ #[ManyToOne(targetEntity: 'LifecycleCallbackCascader')] #[JoinColumn(name: 'cascader_id', referencedColumnName: 'id')] public $cascader; @@ -544,9 +540,7 @@ class LifecycleCallbackCascader #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'LifecycleCallbackTestEntity', mappedBy: 'cascader', cascade: ['persist'])] public $entities; @@ -600,17 +594,13 @@ public function preUpdate(PreUpdateEventArgs $eventArgs): void #[HasLifecycleCallbacks] class LifecycleCallbackEventArgEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $value; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index 43c054e0832..0030300c0be 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -280,23 +280,17 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime #[DiscriminatorMap(['parent' => 'OptimisticJoinedParent', 'child' => 'OptimisticJoinedChild'])] class OptimisticJoinedParent { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; @@ -307,9 +301,7 @@ class OptimisticJoinedParent #[Entity] class OptimisticJoinedChild extends OptimisticJoinedParent { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $whatever; } @@ -318,17 +310,13 @@ class OptimisticJoinedChild extends OptimisticJoinedParent #[Entity] class OptimisticStandard { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; @@ -346,23 +334,17 @@ public function getVersion(): int #[Entity] class OptimisticTimestamp { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @var DateTime - */ + /** @var DateTime */ #[Version] #[Column(type: 'datetime')] public $version; diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index aaf11962d9e..b3e57e369bc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -126,9 +126,7 @@ class NotifyUser extends NotifyBaseEntity #[Column] private string|null $name = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'NotifyGroup')] private $groups; @@ -171,9 +169,7 @@ class NotifyGroup extends NotifyBaseEntity #[Column] private string|null $name = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'NotifyUser', mappedBy: 'groups')] private $users; diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 84a1d562548..18741fef0ef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -210,9 +210,7 @@ public function testEagerLoadingDoesNotBreakRefresh(): void #[Entity] class Train { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -236,9 +234,7 @@ class Train #[JoinColumn(nullable: false)] public $owner; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Waggon', mappedBy: 'train', cascade: ['persist'])] public $waggons; @@ -270,9 +266,7 @@ public function addWaggon(Waggon $w): void #[Entity] class TrainDriver { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -301,9 +295,7 @@ public function setTrain(Train $t): void #[Entity] class TrainOwner { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -332,16 +324,12 @@ public function setTrain(Train $t): void #[Entity] class Waggon { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var Train - */ + /** @var Train */ #[ManyToOne(targetEntity: 'Train', inversedBy: 'waggons', fetch: 'EAGER')] #[JoinColumn(nullable: false)] public $train; @@ -355,9 +343,7 @@ public function setTrain($train): void #[Entity] class TrainOrder { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php index d1ee4f493f9..88b308d78d4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorColumn; use Doctrine\ORM\Mapping\DiscriminatorMap; @@ -12,6 +11,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -83,36 +83,26 @@ public function testOrderdOneToManyCollection(): void #[DiscriminatorMap(['cat' => 'OJTICCat', 'dog' => 'OJTICDog'])] abstract class OJTICPet { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $name; - /** - * @var OJTICPet - */ + /** @var OJTICPet */ #[ManyToOne(targetEntity: 'OJTICPet')] public $mother; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'OJTICPet', mappedBy: 'mother')] #[OrderBy(['name' => 'ASC'])] public $children; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'OTJIC_Pet_Friends')] #[JoinColumn(name: 'pet_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'friend_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php index 9c1f98218b4..2cebe1abc52 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php @@ -72,29 +72,21 @@ public function testParenthesisOnMultiLine(): void #[Entity] class QueryBuilderParenthesisEntity { - /** - * @var int|null - */ + /** @var int|null */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] public $id; - /** - * @var string|null - */ + /** @var string|null */ #[Column] public $property1; - /** - * @var string|null - */ + /** @var string|null */ #[Column] public $property2; - /** - * @var string|null - */ + /** @var string|null */ #[Column] public $property3; } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 02f586edfcc..7d887b61966 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -136,20 +136,15 @@ public function testNotReadOnlyIfObjectWasKnownBefore(): void #[Entity(readOnly: true)] class ReadOnlyEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** @param int $number */ public function __construct( - #[Column(type: 'string', length: 255)] - public string $name, - #[Column(type: 'integer')] - public $numericValue, + #[Column(type: 'string', length: 255)] public string $name, + #[Column(type: 'integer')] public int $numericValue, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 047d7f1767f..b241d211d34 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -33,23 +33,17 @@ public function testDefaultValueIsComparedCorrectly(): void #[Entity] class DBAL483Default { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer', options: ['default' => 0])] public $num; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', options: ['default' => 'foo'])] public $str = 'foo'; } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 79f77ff4a6e..534d0d687ae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -119,9 +119,7 @@ public function testGetCreateSchemaSql4(): void #[Entity] class MysqlSchemaNamespacedEntity { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php index 8809e46ea65..371afa9579d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php @@ -42,9 +42,7 @@ public function testHighAllocationSizeSequence(): void #[Entity] class SequenceEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'SEQUENCE')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index 84e8184594c..c2fae321557 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -80,23 +80,17 @@ public function testHydration(): void #[Entity] class DDC1080Foo { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'fooID', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $fooID; - /** - * @var string - */ + /** @var string */ #[Column(name: 'fooTitle', type: 'string', length: 255)] protected $fooTitle; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1080FooBar', mappedBy: 'foo', cascade: ['persist'])] #[OrderBy(['orderNr' => 'ASC'])] protected $fooBars; @@ -141,23 +135,17 @@ public function setFooBars(array $fooBars): void #[Entity] class DDC1080Bar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'barID', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $barID; - /** - * @var string - */ + /** @var string */ #[Column(name: 'barTitle', type: 'string', length: 255)] protected $barTitle; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1080FooBar', mappedBy: 'bar', cascade: ['persist'])] #[OrderBy(['orderNr' => 'ASC'])] protected $fooBars; @@ -203,25 +191,19 @@ public function setFooBars(array $fooBars): void #[Entity] class DDC1080FooBar { - /** - * @var DDC1080Foo - */ + /** @var DDC1080Foo */ #[ManyToOne(targetEntity: 'DDC1080Foo')] #[JoinColumn(name: 'fooID', referencedColumnName: 'fooID')] #[Id] protected $foo = null; - /** - * @var DDC1080Bar - */ + /** @var DDC1080Bar */ #[ManyToOne(targetEntity: 'DDC1080Bar')] #[JoinColumn(name: 'barID', referencedColumnName: 'barID')] #[Id] protected $bar = null; - /** - * @var int orderNr - */ + /** @var int orderNr */ #[Column(name: 'orderNr', type: 'integer', nullable: false)] protected $orderNr = null; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php index d400f4168c0..8f50698a4e2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php @@ -61,23 +61,17 @@ public function testIssue(): void #[DiscriminatorMap(['vehicle' => 'DDC1113Vehicle', 'car' => 'DDC1113Car', 'bus' => 'DDC1113Bus'])] class DDC1113Vehicle { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DDC1113Vehicle - */ + /** @var DDC1113Vehicle */ #[ManyToOne(targetEntity: 'DDC1113Vehicle')] public $parent; - /** - * @var DDC1113Engine - */ + /** @var DDC1113Engine */ #[OneToOne(targetEntity: 'DDC1113Engine', cascade: ['persist', 'remove'])] public $engine; } @@ -95,9 +89,7 @@ class DDC1113Bus extends DDC1113Vehicle #[Entity] class DDC1113Engine { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index 91b09597ced..38edc3ae4f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -138,9 +138,7 @@ public function getSpecialProduct(): DDC1163SpecialProduct #[DiscriminatorMap(['special' => 'DDC1163SpecialProduct'])] abstract class DDC1163Product { - /** - * @var int - */ + /** @var int */ #[Column(name: 'id', type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] @@ -171,9 +169,7 @@ class DDC1163Tag #[Id] #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @var Product - */ + /** @var Product */ #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] #[ManyToOne(targetEntity: 'DDC1163Product', inversedBy: 'tags')] private $product; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php index f1ca32234c0..a30e7af7538 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php @@ -61,17 +61,13 @@ public function testIssue(): void #[Entity] class DDC1181Hotel { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var Booking[] - */ + /** @var Booking[] */ #[OneToMany(targetEntity: 'DDC1181Booking', mappedBy: 'hotel', cascade: ['remove'])] public $bookings; } @@ -79,16 +75,12 @@ class DDC1181Hotel #[Entity] class DDC1181Booking { - /** - * @var Hotel - */ + /** @var Hotel */ #[JoinColumn(name: 'hotel_id', referencedColumnName: 'id')] #[Id] #[ManyToOne(targetEntity: 'DDC1181Hotel', inversedBy: 'bookings')] public $hotel; - /** - * @var Room - */ + /** @var Room */ #[JoinColumn(name: 'room_id', referencedColumnName: 'id')] #[Id] #[ManyToOne(targetEntity: 'DDC1181Room')] @@ -98,9 +90,7 @@ class DDC1181Booking #[Entity] class DDC1181Room { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index e8af579250e..f29d665082b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -56,17 +56,13 @@ public function testIssue(): void #[Entity] class DDC1193Company { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC1193Person - */ + /** @var DDC1193Person */ #[OneToOne(targetEntity: 'DDC1193Person', cascade: ['persist', 'remove'])] public $member; } @@ -74,17 +70,13 @@ class DDC1193Company #[Entity] class DDC1193Person { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC1193Account - */ + /** @var DDC1193Account */ #[OneToOne(targetEntity: 'DDC1193Account', cascade: ['persist', 'remove'])] public $account; } @@ -92,9 +84,7 @@ class DDC1193Person #[Entity] class DDC1193Account { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php index 4a795e0d6b8..b38b4aa9761 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php @@ -82,23 +82,17 @@ public function getId(): int #[Entity] class DDC1209Two { - /** - * @var DateTime2 - */ + /** @var DateTime2 */ #[Id] #[Column(type: 'datetime', nullable: false)] public $startingDatetime; - /** - * @var DateTime2 - */ + /** @var DateTime2 */ #[Id] #[Column(type: 'datetime', nullable: false)] public $duringDatetime; - /** - * @var DateTime2 - */ + /** @var DateTime2 */ #[Id] #[Column(type: 'datetime', nullable: false)] public $endingDatetime; @@ -118,9 +112,7 @@ public function __construct( #[Entity] class DDC1209Three { - /** - * @var DateTime2 - */ + /** @var DateTime2 */ #[Id] #[Column(type: 'datetime', name: 'somedate')] public $date; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php index 1faf8bec8f1..0faa10ca510 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php @@ -78,23 +78,17 @@ public function testRefresh(): void #[Entity] class DDC1228User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name = 'Bar'; - /** - * @var DDC1228Profile - */ + /** @var DDC1228Profile */ #[OneToOne(targetEntity: 'DDC1228Profile')] public $profile; @@ -107,17 +101,13 @@ public function getProfile(): DDC1228Profile #[Entity] class DDC1228Profile { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php index 05fb009a464..8b432d2f3f5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -45,24 +45,18 @@ public function testIssue(): void #[Entity] class DDC1250ClientHistory { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DDC1250ClientHistory - */ + /** @var DDC1250ClientHistory */ #[OneToOne(targetEntity: 'DDC1250ClientHistory', inversedBy: 'declinedBy')] #[JoinColumn(name: 'declined_clients_history_id', referencedColumnName: 'id')] public $declinedClientsHistory; - /** - * @var DDC1250ClientHistory - */ + /** @var DDC1250ClientHistory */ #[OneToOne(targetEntity: 'DDC1250ClientHistory', mappedBy: 'declinedClientsHistory')] public $declinedBy; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php index 94b09db2910..d4524f3dfe5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php @@ -52,23 +52,17 @@ public function testIssue(): void #[Entity] class DDC1300Foo { - /** - * @var int fooID - */ + /** @var int fooID */ #[Column(name: 'fooID', type: 'integer', nullable: false)] #[GeneratedValue(strategy: 'AUTO')] #[Id] public $fooID = null; - /** - * @var string fooReference - */ + /** @var string fooReference */ #[Column(name: 'fooReference', type: 'string', nullable: true, length: 45)] public $fooReference = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1300FooLocale', mappedBy: 'foo', cascade: ['persist'])] public $fooLocaleRefFoo = null; @@ -82,24 +76,18 @@ public function __construct(array|null $options = null) #[Entity] class DDC1300FooLocale { - /** - * @var DDC1300Foo - */ + /** @var DDC1300Foo */ #[ManyToOne(targetEntity: 'DDC1300Foo')] #[JoinColumn(name: 'fooID', referencedColumnName: 'fooID')] #[Id] public $foo = null; - /** - * @var string locale - */ + /** @var string locale */ #[Column(name: 'locale', type: 'string', nullable: false, length: 5)] #[Id] public $locale = null; - /** - * @var string title - */ + /** @var string title */ #[Column(name: 'title', type: 'string', nullable: true, length: 150)] public $title = null; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index ca30bf0c709..9a2cf5de1fb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -155,19 +155,14 @@ private function loadFixture(): void #[Entity] class DDC1335User { - /** - * @var int - */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] - public $id; + public int|null $id = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1335Phone', mappedBy: 'user', cascade: ['persist', 'remove'])] - public $phones; + public Collection $phones; public function __construct( #[Column(type: 'string', length: 255, unique: true)] @@ -187,21 +182,17 @@ public function __construct( #[Entity] class DDC1335Phone { - /** - * @var int - */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue] - public $id; + public int|null $id = null; - /** @param string $number */ public function __construct( #[ManyToOne(targetEntity: 'DDC1335User', inversedBy: 'phones')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)] public DDC1335User $user, #[Column(name: 'numericalValue', type: 'string', nullable: false)] - public $numericalValue, + public string $numericalValue, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php index 26ef9a02a9e..af7f9a2c081 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php @@ -72,17 +72,13 @@ public function testFailingCase(): void #[Entity] class DDC1400Article { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1400UserState', mappedBy: 'article', indexBy: 'userId', fetch: 'EXTRA_LAZY')] public $userStates; } @@ -90,17 +86,13 @@ class DDC1400Article #[Entity] class DDC1400User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1400UserState', mappedBy: 'user', indexBy: 'articleId', fetch: 'EXTRA_LAZY')] public $userStates; } @@ -108,29 +100,21 @@ class DDC1400User #[Entity] class DDC1400UserState { - /** - * @var DDC1400Article - */ + /** @var DDC1400Article */ #[Id] #[ManyToOne(targetEntity: 'DDC1400Article', inversedBy: 'userStates')] public $article; - /** - * @var DDC1400User - */ + /** @var DDC1400User */ #[Id] #[ManyToOne(targetEntity: 'DDC1400User', inversedBy: 'userStates')] public $user; - /** - * @var int - */ + /** @var int */ #[Column(name: 'user_id', type: 'integer')] public $userId; - /** - * @var int - */ + /** @var int */ #[Column(name: 'article_id', type: 'integer')] public $articleId; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index f841194757c..f82b447cd9a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -142,9 +142,7 @@ public function loadFixtures(): void #[Entity] class DDC1430Order { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'order_id', type: 'integer')] #[GeneratedValue] @@ -199,9 +197,7 @@ public function addProduct(DDC1430OrderProduct $product): void #[Entity] class DDC1430OrderProduct { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php index 99362c26926..813820e681f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -57,17 +57,13 @@ public function testIdentityMap(): void #[Entity] class DDC1436Page { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer', name: 'id')] protected $id; - /** - * @var DDC1436Page - */ + /** @var DDC1436Page */ #[ManyToOne(targetEntity: 'DDC1436Page')] #[JoinColumn(name: 'pid', referencedColumnName: 'id')] protected $parent; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php index 9efb5f29592..4dd0fb39de5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php @@ -47,17 +47,13 @@ public function testIssue(): void #[DiscriminatorMap(['flowelement' => 'DDC144FlowElement', 'operand' => 'DDC144Operand'])] class DDC144FlowElement { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $property; } @@ -71,9 +67,7 @@ abstract public function method(): void; #[Entity] class DDC144Operand extends DDC144Expression { - /** - * @var string - */ + /** @var string */ #[Column] public $operandProperty; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php index 4fe12d27718..64e086aedf8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -93,23 +93,17 @@ public function testFetchJoinOneToOneFromInverse(): void #[Entity] class DDC1452EntityA { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $title; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1452EntityB', mappedBy: 'entityAFrom')] public $entitiesB; @@ -128,22 +122,16 @@ public function getEntitiesB(): Collection #[Entity] class DDC1452EntityB { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC1452EntityA - */ + /** @var DDC1452EntityA */ #[ManyToOne(targetEntity: 'DDC1452EntityA', inversedBy: 'entitiesB')] public $entityAFrom; - /** - * @var DDC1452EntityA - */ + /** @var DDC1452EntityA */ #[ManyToOne(targetEntity: 'DDC1452EntityA')] public $entityATo; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php index 5996a55a67c..ee1a1ef5b6b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -45,9 +45,7 @@ class DDC1454Picture extends DDC1454File #[DiscriminatorMap(['file' => 'DDC1454File', 'picture' => 'DDC1454Picture'])] class DDC1454File { - /** - * @var int - */ + /** @var int */ #[Column(name: 'file_id', type: 'integer')] #[Id] public $fileId; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php index b51572e43b7..92a224f1738 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php @@ -60,23 +60,17 @@ public function testIssue(): void #[Entity] class TestEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] protected $value; - /** - * @var TestAdditionalEntity - */ + /** @var TestAdditionalEntity */ #[OneToOne(targetEntity: 'TestAdditionalEntity', inversedBy: 'entity', orphanRemoval: true, cascade: ['persist', 'remove'])] protected $additional; @@ -103,22 +97,16 @@ public function setAdditional(TestAdditionalEntity $additional): void #[Entity] class TestAdditionalEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var TestEntity - */ + /** @var TestEntity */ #[OneToOne(targetEntity: 'TestEntity', mappedBy: 'additional')] protected $entity; - /** - * @var bool - */ + /** @var bool */ #[Column(type: 'boolean')] protected $bool; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index efe28d8718c..501c1ffe205 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -50,17 +50,13 @@ public function testChangeDetectionDeferredExplicit(): void #[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class DDC1461User { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue(strategy: 'AUTO')] #[Column(type: 'integer')] public $id; - /** - * @var DDC1461TwitterAccount - */ + /** @var DDC1461TwitterAccount */ #[OneToOne(targetEntity: 'DDC1461TwitterAccount', orphanRemoval: true, fetch: 'EAGER', cascade: ['persist'], inversedBy: 'user')] public $twitterAccount; } @@ -69,17 +65,13 @@ class DDC1461User #[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class DDC1461TwitterAccount { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue(strategy: 'AUTO')] #[Column(type: 'integer')] public $id; - /** - * @var DDC1461User - */ + /** @var DDC1461User */ #[OneToOne(targetEntity: 'DDC1461User', fetch: 'EAGER')] public $user; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php index e3b2d713177..2ed8c1bc37e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -70,29 +70,21 @@ public function testIssue(): void #[Entity] class DDC1514EntityA { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $title; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'DDC1514EntityB', mappedBy: 'entityAFrom')] public $entitiesB; - /** - * @var DDC1514EntityC - */ + /** @var DDC1514EntityC */ #[ManyToOne(targetEntity: 'DDC1514EntityC')] public $entityC; @@ -105,22 +97,16 @@ public function __construct() #[Entity] class DDC1514EntityB { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC1514EntityA - */ + /** @var DDC1514EntityA */ #[ManyToOne(targetEntity: 'DDC1514EntityA', inversedBy: 'entitiesB')] public $entityAFrom; - /** - * @var DDC1514EntityA - */ + /** @var DDC1514EntityA */ #[ManyToOne(targetEntity: 'DDC1514EntityA')] public $entityATo; } @@ -128,17 +114,13 @@ class DDC1514EntityB #[Entity] class DDC1514EntityC { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $title; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php index 26b4bd6d1de..8e678b1a21d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -43,9 +43,7 @@ public function testIssue(): void #[Entity] class DDC1515Foo { - /** - * @var DDC1515Bar - */ + /** @var DDC1515Bar */ #[OneToOne(targetEntity: 'DDC1515Bar', inversedBy: 'foo')] #[Id] public $bar; @@ -54,17 +52,13 @@ class DDC1515Foo #[Entity] class DDC1515Bar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC1515Foo - */ + /** @var DDC1515Foo */ #[OneToOne(targetEntity: 'DDC1515Foo', mappedBy: 'bar')] public $foo; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php index e39b73def76..d8516ef20f2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php @@ -54,22 +54,16 @@ public function testIssue(): void #[Entity] class DDC1526Menu { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] public $id; - /** - * @var DDC1526Menu - */ + /** @var DDC1526Menu */ #[ManyToOne(targetEntity: 'DDC1526Menu', inversedBy: 'children')] public $parent; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1526Menu', mappedBy: 'parent')] public $children; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php index d8d21912f7e..4a1e23af9ab 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -45,9 +45,7 @@ public function testIssue(): void #[Entity] class DDC1548E1 { - /** - * @var DDC1548Rel - */ + /** @var DDC1548Rel */ #[Id] #[OneToOne(targetEntity: 'DDC1548Rel', inversedBy: 'e1')] public $rel; @@ -56,9 +54,7 @@ class DDC1548E1 #[Entity] class DDC1548E2 { - /** - * @var DDC1548Rel - */ + /** @var DDC1548Rel */ #[Id] #[OneToOne(targetEntity: 'DDC1548Rel', inversedBy: 'e2')] public $rel; @@ -67,22 +63,16 @@ class DDC1548E2 #[Entity] class DDC1548Rel { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DDC1548E1 - */ + /** @var DDC1548E1 */ #[OneToOne(targetEntity: 'DDC1548E1', mappedBy: 'rel')] public $e1; - /** - * @var DDC1548E2 - */ + /** @var DDC1548E2 */ #[OneToOne(targetEntity: 'DDC1548E2', mappedBy: 'rel')] public $e2; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php index 19a4a6fe4e6..5b89d190935 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorColumn; @@ -13,6 +12,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -81,9 +81,7 @@ public function testIssue(): void #[DiscriminatorMap(['Entity1' => 'DDC1595InheritedEntity1', 'Entity2' => 'DDC1595InheritedEntity2'])] abstract class DDC1595BaseInheritance { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -94,9 +92,7 @@ abstract class DDC1595BaseInheritance #[Entity] class DDC1595InheritedEntity1 extends DDC1595BaseInheritance { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'entity1_entity2')] #[JoinColumn(name: 'parent', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'item', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php index 085f2c72917..ca7996fa285 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php @@ -136,17 +136,13 @@ public function testManyToManyClearCollectionReAddOrphanRemoval(): void #[Entity] class DDC1654Post { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'DDC1654Comment', orphanRemoval: true, cascade: ['persist'])] public $comments = []; } @@ -154,9 +150,7 @@ class DDC1654Post #[Entity] class DDC1654Comment { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index 3e54b71c07a..dadd1e53438 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -102,9 +102,7 @@ public function testPostLoadInheritanceChild(): void #[HasLifecycleCallbacks] class DDC1655Foo { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -113,9 +111,7 @@ class DDC1655Foo /** @var int */ public $loaded = 0; - /** - * @var DDC1655Baz - */ + /** @var DDC1655Baz */ #[ManyToOne(targetEntity: 'DDC1655Baz', inversedBy: 'foos')] public $baz; @@ -143,17 +139,13 @@ public function postSubLoaded(): void #[Entity] class DDC1655Baz { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC1655Foo', mappedBy: 'baz')] public $foos = []; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index c39fcf5fd58..bc0dcf1223d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -45,9 +45,7 @@ public function testPostLoadOnChild(): void #[HasLifecycleCallbacks] abstract class DDC1707Base { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php index 6cb2a6ad4bd..1f96c78cf4b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php @@ -85,9 +85,7 @@ public function testCreateRetrieveUpdateDelete(): void #[Entity] class DDC1719SimpleEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer', name: '`simple-entity-id`')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php index 9cc17f78721..8378dd34056 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php @@ -63,9 +63,7 @@ class DDC1757B #[Entity] class DDC1757C { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] @@ -78,9 +76,7 @@ class DDC1757C #[Entity] class DDC1757D { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php index b6b27081165..078d7606b92 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -67,9 +67,7 @@ class DDC1925Product #[Column(name: 'title', type: 'string', length: 255)] private string|null $title = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'user_purchases')] #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'user_id', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php index cbc720d8380..06f48d1d863 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php @@ -40,17 +40,13 @@ public function testSchemaCreation(): void #[Entity] class DDC192User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 255)] public $name; } @@ -60,16 +56,12 @@ class DDC192User #[Entity] class DDC192Phonenumber { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(name: 'phone', type: 'string', length: 40)] protected $phone; - /** - * @var DDC192User - */ + /** @var DDC192User */ #[Id] #[ManyToOne(targetEntity: 'DDC192User')] #[JoinColumn(name: 'userId', referencedColumnName: 'id')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index 2403f8cc027..106f5f9806b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -49,16 +49,12 @@ public function testSqlConversionAsIdentifier(): void #[Entity] class DDC1998Entity { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'ddc1998', length: 255)] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $num = 0; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php index 87f5d05edf1..c848cdf8283 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php @@ -70,23 +70,17 @@ public function testPolymorphicLoading(): void #[DiscriminatorMap(['parent' => 'DDC199ParentClass', 'child' => 'DDC199ChildClass'])] class DDC199ParentClass { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $parentData; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC199RelatedClass', mappedBy: 'parent')] public $relatedEntities; } @@ -95,9 +89,7 @@ class DDC199ParentClass #[Entity] class DDC199ChildClass extends DDC199ParentClass { - /** - * @var string - */ + /** @var string */ #[Column] public $childData; } @@ -106,23 +98,17 @@ class DDC199ChildClass extends DDC199ParentClass #[Entity] class DDC199RelatedClass { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $relatedData; - /** - * @var DDC199ParentClass - */ + /** @var DDC199ParentClass */ #[ManyToOne(targetEntity: 'DDC199ParentClass', inversedBy: 'relatedEntities')] #[JoinColumn(name: 'parent_id', referencedColumnName: 'id')] public $parent; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index ac4541dbecc..a8e334e3499 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -89,17 +89,13 @@ public function testIssue(): void #[DiscriminatorMap([1 => 'DDC2012ItemPerson', 2 => 'DDC2012Item'])] class DDC2012Item { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @psalm-var list - */ + /** @psalm-var list */ #[Column(name: 'tsv', type: 'tsvector', length: 255, nullable: true)] public $tsv; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php index b5164720e12..5dcfaa95b53 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php @@ -47,23 +47,17 @@ public function testDetachedEntityAsId(): void #[Entity] class DDC2106Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue(strategy: 'IDENTITY')] #[Column(type: 'integer')] public $id; - /** - * @var DDC2106Entity - */ + /** @var DDC2106Entity */ #[ManyToOne(targetEntity: 'DDC2106Entity', inversedBy: 'children')] public $parent; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC2106Entity', mappedBy: 'parent', cascade: ['persist'])] public $children; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php index 9d7884e977a..94f803176a8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -56,23 +56,17 @@ public function testIssue(): void #[Entity] class DDC211User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 255)] protected $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'user_groups')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] @@ -100,23 +94,17 @@ public function getGroups(): Collection #[Entity] class DDC211Group { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 255)] protected $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'DDC211User', mappedBy: 'groups')] protected $users; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index dce769e7b7b..6cbe6e5178c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -62,17 +62,13 @@ public function testForeignKeyOnSTIWithMultipleMapping(): void #[Entity] class DDC2138Structure { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 32, nullable: true)] protected $name; } @@ -84,9 +80,7 @@ class DDC2138Structure #[DiscriminatorMap([4 => 'DDC2138UserFollowedUser', 3 => 'DDC2138UserFollowedStructure'])] abstract class DDC2138UserFollowedObject { - /** - * @var int $id - */ + /** @var int $id */ #[Column(name: 'id', type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] @@ -165,29 +159,21 @@ public function getFollowedUser(): User #[Entity] class DDC2138User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 32, nullable: true)] protected $name; - /** - * @var ArrayCollection $followedUsers - */ + /** @var ArrayCollection $followedUsers */ #[OneToMany(targetEntity: 'DDC2138UserFollowedUser', mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] protected $followedUsers; - /** - * @var ArrayCollection $followedStructures - */ + /** @var ArrayCollection $followedStructures */ #[OneToMany(targetEntity: 'DDC2138UserFollowedStructure', mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] protected $followedStructures; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php index 88f0dc87491..609b697f317 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php @@ -49,23 +49,17 @@ public function testIssue(): void #[DiscriminatorMap(['entity' => 'DDC2175Entity'])] class DDC2175Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $field; - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php index 5d353d1f3b1..9f34c0025f9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php @@ -59,17 +59,13 @@ public function testIssue(): void #[Entity] class DDC2214Foo { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var DDC2214Bar - */ + /** @var DDC2214Bar */ #[ManyToOne(targetEntity: 'DDC2214Bar')] public $bar; } @@ -77,9 +73,7 @@ class DDC2214Foo #[Entity] class DDC2214Bar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index f4ee4f557cd..c48033adf4e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -76,17 +76,13 @@ public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform): #[Entity] class DDC2224Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var mixed - */ + /** @var mixed */ #[Column(type: 'DDC2224Type', length: 255)] public $field; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index eef3038e75a..b6a629e4ebc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -53,17 +53,13 @@ public function testNotifyTrackingCalledOnProxyInitialization(): void #[Entity] class DDC2230User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var DDC2230Address - */ + /** @var DDC2230Address */ #[OneToOne(targetEntity: 'DDC2230Address')] public $address; } @@ -72,9 +68,7 @@ class DDC2230User #[ChangeTrackingPolicy('NOTIFY')] class DDC2230Address implements NotifyPropertyChanged { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index a617bb5ce68..8d24c1045e4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -12,6 +11,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\HasLifecycleCallbacks; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -124,9 +124,7 @@ public function testIssue(): void #[Entity] class DDC2252Privilege { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -142,9 +140,7 @@ public function getPrivilegeid(): int #[Entity] class DDC2252MerchantAccount { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] protected $accountid = 111; @@ -159,16 +155,12 @@ public function getAccountid(): int #[Entity] class DDC2252User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] protected $uid = 222; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC2252Membership', mappedBy: 'userAccount', cascade: ['persist'])] #[JoinColumn(name: 'uid', referencedColumnName: 'uid')] protected $memberships; @@ -200,9 +192,7 @@ public function addMembership(DDC2252Membership $membership): void #[HasLifecycleCallbacks] class DDC2252Membership { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'ddc2252_user_mch_account_privilege')] #[JoinColumn(name: 'mch_accountid', referencedColumnName: 'mch_accountid')] #[JoinColumn(name: 'uid', referencedColumnName: 'uid')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index fa19eae768b..4711a1c2c85 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -85,9 +85,7 @@ public function testIssue(): void #[Entity] class DDC2306Zone { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -97,23 +95,17 @@ class DDC2306Zone #[Entity] class DDC2306User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC2306UserAddress[]|Collection - */ + /** @var DDC2306UserAddress[]|Collection */ #[OneToMany(targetEntity: 'DDC2306UserAddress', mappedBy: 'user')] public $addresses; - /** - * @var DDC2306Zone - */ + /** @var DDC2306Zone */ #[ManyToOne(targetEntity: 'DDC2306Zone', fetch: 'EAGER')] public $zone; @@ -127,23 +119,17 @@ public function __construct() #[Entity] class DDC2306Address { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC2306UserAddress[]|Collection - */ + /** @var DDC2306UserAddress[]|Collection */ #[OneToMany(targetEntity: 'DDC2306UserAddress', mappedBy: 'address', orphanRemoval: true)] public $users; - /** - * @var DDC2306Zone - */ + /** @var DDC2306Zone */ #[ManyToOne(targetEntity: 'DDC2306Zone', fetch: 'EAGER')] public $zone; @@ -157,9 +143,7 @@ public function __construct() #[Entity] class DDC2306UserAddress { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index 05664ac943f..eed0b693d43 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -68,17 +68,13 @@ public function testIssue(): void #[Entity] class DDC2346Foo { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC2346Bar[]|Collection - */ + /** @var DDC2346Bar[]|Collection */ #[OneToMany(targetEntity: 'DDC2346Bar', mappedBy: 'foo')] public $bars; @@ -95,17 +91,13 @@ public function __construct() #[DiscriminatorMap(['bar' => 'DDC2346Bar', 'baz' => 'DDC2346Baz'])] class DDC2346Bar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC2346Foo - */ + /** @var DDC2346Foo */ #[ManyToOne(targetEntity: 'DDC2346Foo', inversedBy: 'bars', fetch: 'EAGER')] public $foo; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php index 3f51cc093c6..edaaa94cb03 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php @@ -55,17 +55,13 @@ public function testEagerCollectionsAreOnlyRetrievedOnce(): void #[Entity] class DDC2350User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC2350Bug', mappedBy: 'user', fetch: 'EAGER')] public $reportedBugs; } @@ -73,16 +69,12 @@ class DDC2350User #[Entity] class DDC2350Bug { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC2350User - */ + /** @var DDC2350User */ #[ManyToOne(targetEntity: 'DDC2350User', inversedBy: 'reportedBugs')] public $user; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index ac29909e4d2..3cd18559c76 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -64,9 +64,7 @@ public function testIssue(): void #[Entity] class DDC2359Foo { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php index 0cbf6e97005..e7a40b6840b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -75,21 +75,15 @@ public function testUninitializedProxyIsInitializedOnFetchJoin(): void #[Entity] class DDC237EntityX { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; - /** - * @var DDC237EntityY - */ + /** @var DDC237EntityY */ #[OneToOne(targetEntity: 'DDC237EntityY')] #[JoinColumn(name: 'y_id', referencedColumnName: 'id')] public $y; @@ -100,16 +94,12 @@ class DDC237EntityX #[Entity] class DDC237EntityY { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; } @@ -118,22 +108,16 @@ class DDC237EntityY #[Entity] class DDC237EntityZ { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; - /** - * @var DDC237EntityY - */ + /** @var DDC237EntityY */ #[OneToOne(targetEntity: 'DDC237EntityY')] #[JoinColumn(name: 'y_id', referencedColumnName: 'id')] public $y; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index ef5ebdb2ec7..f16019a93bf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -85,9 +85,7 @@ public function testIssue(): void #[Entity] class DDC2494Currency { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC2494Campaign', mappedBy: 'currency')] protected $campaigns; @@ -121,9 +119,7 @@ public function getCampaigns(): Collection #[Entity] class DDC2494Campaign { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index 39cd9171768..5048ba5151d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -98,9 +98,7 @@ public function testHydrationIssue(): void #[Entity] class DDC2575Root { - /** - * @var DDC2575A - */ + /** @var DDC2575A */ #[OneToOne(targetEntity: 'DDC2575A', mappedBy: 'rootRelation')] public $aRelation; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index 27061bb552e..e610a806123 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -70,16 +70,12 @@ public function testIssue(): void #[Entity] class DDC2579Entity { - /** - * @var DDC2579Id - */ + /** @var DDC2579Id */ #[Id] #[Column(type: 'ddc2579', length: 255)] public $id; - /** - * @var DDC2579EntityAssoc - */ + /** @var DDC2579EntityAssoc */ #[Id] #[ManyToOne(targetEntity: 'DDC2579EntityAssoc')] #[JoinColumn(name: 'relation_id', referencedColumnName: 'association_id')] @@ -99,9 +95,7 @@ public function __construct( class DDC2579EntityAssoc { public function __construct( - /** - * @var DDC2579AssocAssoc - */ + /** @var DDC2579AssocAssoc */ #[Id] #[ManyToOne(targetEntity: 'DDC2579AssocAssoc')] #[JoinColumn(name: 'association_id', referencedColumnName: 'associationId')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php index 465c4684b31..581230e11c6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -84,9 +84,7 @@ public function testIssue(): void #[DiscriminatorMap(['class1' => 'DDC258Class1', 'class2' => 'DDC258Class2', 'class3' => 'DDC258Class3'])] abstract class DDC258Super { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] @@ -96,15 +94,11 @@ abstract class DDC258Super #[Entity] class DDC258Class1 extends DDC258Super { - /** - * @var string - */ + /** @var string */ #[Column(name: 'title', type: 'string', length: 150)] public $title; - /** - * @var string - */ + /** @var string */ #[Column(name: 'content', type: 'string', length: 500)] public $description; } @@ -112,21 +106,15 @@ class DDC258Class1 extends DDC258Super #[Entity] class DDC258Class2 extends DDC258Super { - /** - * @var string - */ + /** @var string */ #[Column(name: 'title', type: 'string', length: 150)] public $title; - /** - * @var string - */ + /** @var string */ #[Column(name: 'content', type: 'string', length: 500)] public $description; - /** - * @var string - */ + /** @var string */ #[Column(name: 'text', type: 'text')] public $text; } @@ -137,15 +125,11 @@ class DDC258Class2 extends DDC258Super #[Entity] class DDC258Class3 extends DDC258Super { - /** - * @var string - */ + /** @var string */ #[Column(name: 'title', type: 'string', length: 150)] public $apples; - /** - * @var string - */ + /** @var string */ #[Column(name: 'content', type: 'string', length: 500)] public $bananas; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php index 4a156202c5a..d95a68db72c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php @@ -161,23 +161,17 @@ public function postLoad(PostLoadEventArgs $event): void #[Entity] class DDC2602User { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 15)] public $name; - /** - * @var DDC2602Biography - */ + /** @var DDC2602Biography */ #[OneToOne(targetEntity: 'DDC2602Biography', inversedBy: 'user', cascade: ['persist', 'merge', 'refresh', 'remove'])] #[JoinColumn(nullable: false)] public $biography; @@ -186,23 +180,17 @@ class DDC2602User #[Entity] class DDC2602Biography { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DDC2602User - */ + /** @var DDC2602User */ #[OneToOne(targetEntity: 'DDC2602User', mappedBy: 'biography', cascade: ['persist', 'merge', 'refresh'])] public $user; - /** - * @var string - */ + /** @var string */ #[Column(type: 'text', nullable: true)] public $content; @@ -213,29 +201,21 @@ class DDC2602Biography #[Entity] class DDC2602BiographyField { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', unique: true, length: 100)] public $alias; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 100)] public $label; - /** - * @var ArrayCollection - */ + /** @var ArrayCollection */ #[OneToMany(targetEntity: 'DDC2602BiographyFieldChoice', mappedBy: 'field', cascade: ['persist', 'merge', 'refresh'])] public $choiceList; @@ -248,23 +228,17 @@ public function __construct() #[Entity] class DDC2602BiographyFieldChoice { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', unique: true, length: 100)] public $label; - /** - * @var DDC2602BiographyField - */ + /** @var DDC2602BiographyField */ #[ManyToOne(targetEntity: 'DDC2602BiographyField', inversedBy: 'choiceList')] #[JoinColumn(onDelete: 'CASCADE')] public $field; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php index 36885df7513..f5aaa2c7e50 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php @@ -89,9 +89,7 @@ public function testIssueWithoutExtraColumn(): void #[Entity] class DDC2660Product { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -102,9 +100,7 @@ class DDC2660Product #[Entity] class DDC2660Customer { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index 1ca96d1b6a8..a582a288cd1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -62,9 +62,7 @@ public function preFlush(PreFlushEventArgs $args): void #[Entity] class DDC2692Foo { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index 6c5c250b21a..9cfa123c72b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -71,17 +71,13 @@ public function testCorrectNumberOfAssociationsIsReturned(): void #[Entity] class DDC2759Qualification { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC2759QualificationMetadata - */ + /** @var DDC2759QualificationMetadata */ #[OneToOne(targetEntity: 'DDC2759QualificationMetadata', mappedBy: 'content')] public $metadata; } @@ -90,17 +86,13 @@ class DDC2759Qualification #[Entity] class DDC2759Category { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC2759MetadataCategory', mappedBy: 'category')] public $metadataCategories; } @@ -109,17 +101,13 @@ class DDC2759Category #[Entity] class DDC2759QualificationMetadata { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC2759MetadataCategory', mappedBy: 'metadata')] protected $metadataCategories; @@ -134,9 +122,7 @@ public function __construct( #[Entity] class DDC2759MetadataCategory { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php index 2dc8ca6a8dd..191d081cfda 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php @@ -72,23 +72,17 @@ public function testIssueCascadeRemove(): void #[DiscriminatorMap(['admin' => 'AdminRole'])] abstract class Role { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var User - */ + /** @var User */ #[ManyToOne(targetEntity: 'User', inversedBy: 'roles')] public $user; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Authorization', mappedBy: 'role', cascade: ['all'], orphanRemoval: true)] public $authorizations; @@ -109,23 +103,17 @@ class AdminRole extends Role #[Entity] class Authorization { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var User - */ + /** @var User */ #[ManyToOne(targetEntity: 'User', inversedBy: 'authorizations')] public $user; - /** - * @var Role - */ + /** @var Role */ #[ManyToOne(targetEntity: 'Role', inversedBy: 'authorizations')] public $role; } @@ -134,23 +122,17 @@ class Authorization #[Entity] class User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Role', mappedBy: 'user', cascade: ['all'], orphanRemoval: true)] public $roles; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Authorization', mappedBy: 'user', cascade: ['all'], orphanRemoval: true)] public $authorizations; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php index 4cdaa276b4e..3022b6aab9c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php @@ -53,17 +53,13 @@ public function testIssue(): void #[Entity] class DDC2780User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC2780Project - */ + /** @var DDC2780Project */ #[ManyToOne(targetEntity: 'DDC2780Project')] public $project; } @@ -71,17 +67,13 @@ class DDC2780User #[Entity] class DDC2780Project { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC2780User[] - */ + /** @var DDC2780User[] */ #[OneToMany(targetEntity: 'DDC2780User', mappedBy: 'project')] public $users; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php index 1c356711cdd..f3e729d83a2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php @@ -73,17 +73,13 @@ public function testDDC279(): void #[DiscriminatorMap(['DDC279EntityX' => 'DDC279EntityX'])] abstract class DDC279EntityXAbstract { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(name: 'id', type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; } @@ -91,9 +87,7 @@ abstract class DDC279EntityXAbstract #[Entity] class DDC279EntityX extends DDC279EntityXAbstract { - /** - * @var DDC279EntityY - */ + /** @var DDC279EntityY */ #[OneToOne(targetEntity: 'DDC279EntityY')] #[JoinColumn(name: 'y_id', referencedColumnName: 'id')] public $y; @@ -102,23 +96,17 @@ class DDC279EntityX extends DDC279EntityXAbstract #[Entity] class DDC279EntityY { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(name: 'id', type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; - /** - * @var DDC279EntityZ - */ + /** @var DDC279EntityZ */ #[OneToOne(targetEntity: 'DDC279EntityZ')] #[JoinColumn(name: 'z_id', referencedColumnName: 'id')] public $z; @@ -127,17 +115,13 @@ class DDC279EntityY #[Entity] class DDC279EntityZ { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(name: 'id', type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index 1bb2a180549..38fe3dea730 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -118,9 +118,7 @@ public function testIssueReopened(): void #[Cache('NONSTRICT_READ_WRITE')] class DDC2862Driver { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -166,9 +164,7 @@ public function getUserProfile(): DDC2862User #[Cache('NONSTRICT_READ_WRITE')] class DDC2862User { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php index ffe3c50325b..7a55ca71bc9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php @@ -54,9 +54,7 @@ public function testPostLoadOneToManyInheritance(): void #[HasLifecycleCallbacks] abstract class AbstractDDC2895 { - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(name: 'last_modified', type: 'datetimetz', nullable: false)] protected $lastModified; @@ -82,9 +80,7 @@ public function getLastModified(): DateTime #[HasLifecycleCallbacks] class DDC2895 extends AbstractDDC2895 { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index 3d6cc3178a5..de8ba511853 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -87,29 +87,21 @@ public function testFetchJoinedEntitiesCanBeRefreshed(): void #[Entity] class DDC2931User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var DDC2931User - */ + /** @var DDC2931User */ #[OneToOne(targetEntity: 'DDC2931User', inversedBy: 'child')] public $parent; - /** - * @var DDC2931User - */ + /** @var DDC2931User */ #[OneToOne(targetEntity: 'DDC2931User', mappedBy: 'parent')] public $child; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $value = 0; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index 460f063934c..543df7c89b7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -46,16 +46,12 @@ public function testIssue(): void #[Entity] class DDC2996User { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $counter = 0; } @@ -64,22 +60,16 @@ class DDC2996User #[HasLifecycleCallbacks] class DDC2996UserPreference { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $value; - /** - * @var DDC2996User - */ + /** @var DDC2996User */ #[ManyToOne(targetEntity: 'DDC2996User')] public $user; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index 1197752a43d..d8d8d62f497 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Event\PostUpdateEventArgs; @@ -14,6 +13,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\HasLifecycleCallbacks; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -72,23 +72,17 @@ class DDC3033Product /** @psalm-var array */ public $changeSet = []; - /** - * @var int $id - */ + /** @var int $id */ #[Column(name: 'id', type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string $title - */ + /** @var string $title */ #[Column(name: 'title', type: 'string', length: 255)] public $title; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'user_purchases_3033')] #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'user_id', referencedColumnName: 'id')] @@ -126,17 +120,13 @@ public function postUpdate(PostUpdateEventArgs $eventArgs): void #[HasLifecycleCallbacks] class DDC3033User { - /** - * @var int - */ + /** @var int */ #[Column(name: 'id', type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'title', type: 'string', length: 255)] public $name; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php index 99b7f6dcb70..0725e3cc767 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php @@ -37,61 +37,39 @@ public function testSQLGenerationDoesNotProvokeAliasCollisions(): void #[Entity] class DDC3042Foo { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $field; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field1; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field2; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field3; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field4; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field5; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field6; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field7; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field8; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field9; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $field10; } @@ -99,9 +77,7 @@ class DDC3042Foo #[Entity] class DDC3042Bar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php index 8b86b9e8ad1..bc0dde9db39 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php @@ -67,9 +67,7 @@ public function testTwoToIterableHydrations(): void #[Entity] class DDC309Country { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue] @@ -79,9 +77,7 @@ class DDC309Country #[Entity] class DDC309User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php index cad2088b89a..877f9039de0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php @@ -37,9 +37,7 @@ public function testIssue(): void #[Embeddable] class DDC3103ArticleId { - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 255)] protected $nameValue; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php index 2c90c63f2e8..59d322d6936 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php @@ -74,9 +74,7 @@ public function testIssue(): void #[DiscriminatorMap(['product' => 'DDC3170ProductJoined'])] abstract class DDC3170AbstractEntityJoined { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -94,9 +92,7 @@ class DDC3170ProductJoined extends DDC3170AbstractEntityJoined #[DiscriminatorMap(['product' => 'DDC3170ProductSingleTable'])] abstract class DDC3170AbstractEntitySingleTable { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index 72a2989b673..44c2d151bcc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -81,9 +81,7 @@ public function testIssue(): void #[Entity] class DDC3192Currency { - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'DDC3192Transaction', mappedBy: 'currency')] public $transactions; @@ -99,9 +97,7 @@ public function __construct( #[Entity] class DDC3192Transaction { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php index 6683352a899..509a99d254a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php @@ -67,17 +67,13 @@ class Journalist extends Participant #[DiscriminatorMap(['journalist' => 'Journalist', 'participant' => 'Participant'])] class Participant { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var ProfileStatus - */ + /** @var ProfileStatus */ #[ManyToOne(targetEntity: 'ProfileStatus')] public $profileStatus; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index a706eed15a6..5fddbf20437 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -57,9 +57,7 @@ public function testResolveTargetEntitiesChangesDiscriminatorMapValues(): void #[DiscriminatorMap(['boss' => 'Doctrine\Tests\ORM\Functional\Ticket\DDC3300Boss', 'employee' => 'Doctrine\Tests\ORM\Functional\Ticket\DDC3300Employee'])] abstract class DDC3300Person { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php index 36928e473ff..5bf7c285f94 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php @@ -77,17 +77,13 @@ private function createBuildingAndHalls(): void #[Entity] class DDC3330Building { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3330Hall', mappedBy: 'building', cascade: ['persist'])] public $halls; @@ -102,23 +98,17 @@ public function addHall(DDC3330Hall $hall): void #[Entity] class DDC3330Hall { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var DDC3330Building - */ + /** @var DDC3330Building */ #[ManyToOne(targetEntity: 'DDC3330Building', inversedBy: 'halls')] public $building; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 100)] public $name; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php index 7ead3e2ed1b..f78ec2b4062 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -72,23 +72,17 @@ public function testTwoIterateHydrations(): void #[Entity] class DDC345User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC345Membership', mappedBy: 'user', cascade: ['persist'])] public $memberships; @@ -101,23 +95,17 @@ public function __construct() #[Entity] class DDC345Group { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC345Membership', mappedBy: 'group', cascade: ['persist'])] public $memberships; @@ -133,37 +121,27 @@ public function __construct() #[HasLifecycleCallbacks] class DDC345Membership { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC345User - */ + /** @var DDC345User */ #[OneToOne(targetEntity: 'DDC345User', inversedBy: 'memberships')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)] public $user; - /** - * @var DDC345Group - */ + /** @var DDC345Group */ #[OneToOne(targetEntity: 'DDC345Group', inversedBy: 'memberships')] #[JoinColumn(name: 'group_id', referencedColumnName: 'id', nullable: false)] public $group; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $state; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'datetime')] public $updated; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index a573b6699dc..466c549b8cf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -103,9 +103,7 @@ public function getFile(): DDC353File #[Entity] class DDC353File { - /** - * @var int - */ + /** @var int */ #[Column(name: 'file_id', type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php index 09f552a54a0..f4dd2a2eff0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php @@ -34,9 +34,7 @@ public function testNestedEmbeddablesAreHydratedWithProperClass(): void #[Entity] class DDC3582Entity { - /** - * @var DDC3582Embeddable1 - */ + /** @var DDC3582Embeddable1 */ #[Embedded(class: 'DDC3582Embeddable1')] public $embeddable1; @@ -52,9 +50,7 @@ public function __construct( #[Embeddable] class DDC3582Embeddable1 { - /** - * @var DDC3582Embeddable2 - */ + /** @var DDC3582Embeddable2 */ #[Embedded(class: 'DDC3582Embeddable2')] public $embeddable2; @@ -67,9 +63,7 @@ public function __construct() #[Embeddable] class DDC3582Embeddable2 { - /** - * @var DDC3582Embeddable3 - */ + /** @var DDC3582Embeddable3 */ #[Embedded(class: 'DDC3582Embeddable3')] public $embeddable3; @@ -82,9 +76,7 @@ public function __construct() #[Embeddable] class DDC3582Embeddable3 { - /** - * @var string - */ + /** @var string */ #[Column] public $embeddedValue = 'foo'; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index e63ab3ee6bb..f58ed6a5e8a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -88,9 +88,7 @@ public function testSavesIntegerAutoGeneratedValueAsStringWithJoinedInheritance( #[Entity] class DDC3634Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'bigint')] #[GeneratedValue(strategy: 'AUTO')] @@ -102,9 +100,7 @@ class DDC3634Entity #[DiscriminatorMap([DDC3634JTIBaseEntity::class => DDC3634JTIBaseEntity::class, DDC3634JTIChildEntity::class => DDC3634JTIChildEntity::class])] class DDC3634JTIBaseEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'bigint')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php index 08183b6ef2d..4656059db69 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php @@ -139,29 +139,21 @@ public function testIssueWithJoinedEntity(): void #[Entity] class DDC3644User { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer', name: 'hash_id')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3644Address', mappedBy: 'user', orphanRemoval: true)] public $addresses = []; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3644Pet', mappedBy: 'owner', orphanRemoval: true)] public $pets = []; @@ -187,17 +179,13 @@ public function setPets(Collection $pets): void #[Entity] class DDC3644Address { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DDC3644User - */ + /** @var DDC3644User */ #[ManyToOne(targetEntity: 'DDC3644User', inversedBy: 'addresses')] #[JoinColumn(referencedColumnName: 'hash_id')] public $user; @@ -215,9 +203,7 @@ public function __construct( #[DiscriminatorMap(['pet' => 'DDC3644Pet'])] abstract class DDC3644Animal { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -233,9 +219,7 @@ public function __construct( #[Entity] class DDC3644Pet extends DDC3644Animal { - /** - * @var DDC3644User - */ + /** @var DDC3644User */ #[ManyToOne(targetEntity: 'DDC3644User', inversedBy: 'pets')] #[JoinColumn(referencedColumnName: 'hash_id')] public $owner; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index e2a80448e6e..c59ddb7a7a7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -64,14 +64,10 @@ class DDC371Child #[Column(type: 'integer')] #[GeneratedValue] private int $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; - /** - * @var DDC371Parent - */ + /** @var DDC371Parent */ #[ManyToOne(targetEntity: 'DDC371Parent', inversedBy: 'children')] #[JoinColumn(name: 'parentId')] public $parent; @@ -84,15 +80,11 @@ class DDC371Parent #[Column(type: 'integer')] #[GeneratedValue] private int $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC371Child', mappedBy: 'parent')] public $children; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php index 1d952b2ded5..ec8da8b95fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -14,6 +13,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -66,9 +66,7 @@ public function testOwningValueObjectIdIsCorrectlyTransformedWhenRemovingOrphane #[Entity] class DDC3785Asset { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'asset_attributes')] #[JoinColumn(name: 'asset_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'attribute_id', referencedColumnName: 'id')] @@ -106,9 +104,7 @@ public function getAttributes() #[Entity] class DDC3785Attribute { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php index 2728e482f49..11a53b60981 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php @@ -46,9 +46,7 @@ public function testCallUnserializedProxyMethods(): void #[Entity] class DDC381Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index 2dee15df5bd..7438c4c3db9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -14,6 +13,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -61,9 +61,7 @@ public function testIssue(): void #[DiscriminatorMap(['guest' => 'DDC422Guest', 'customer' => 'DDC422Customer'])] class DDC422Guest { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -73,9 +71,7 @@ class DDC422Guest #[Entity] class DDC422Customer extends DDC422Guest { - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'ddc422_customers_contacts')] #[JoinColumn(name: 'customer_id', referencedColumnName: 'id', onDelete: 'cascade')] #[InverseJoinColumn(name: 'contact_id', referencedColumnName: 'id', onDelete: 'cascade')] @@ -91,9 +87,7 @@ public function __construct() #[Entity] class DDC422Contact { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php index d206481afd2..313840515fb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php @@ -33,17 +33,13 @@ public function testIssue(): void #[Entity] class DDC425Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'datetime')] public $someDatetimeField; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php index 0b2199a46d5..c4e71b42493 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -84,24 +84,18 @@ public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations(): #[Entity] class DDC440Phone { - /** - * @var int - */ + /** @var int */ #[Column(name: 'id', type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var DDC440Client - */ + /** @var DDC440Client */ #[JoinColumn(name: 'client_id', referencedColumnName: 'id')] #[ManyToOne(targetEntity: 'DDC440Client', inversedBy: 'phones')] protected $client; - /** - * @var string - */ + /** @var string */ #[Column(name: 'phonenumber', type: 'string', length: 255)] protected $number; @@ -143,31 +137,23 @@ public function setId(int $value): void #[Entity] class DDC440Client { - /** - * @var int - */ + /** @var int */ #[Column(name: 'id', type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] protected $id; - /** - * @var DDC440Phone - */ + /** @var DDC440Phone */ #[JoinColumn(name: 'main_phone_id', referencedColumnName: 'id', onDelete: 'SET NULL')] #[OneToOne(targetEntity: 'DDC440Phone', fetch: 'EAGER')] protected $mainPhone; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC440Phone', mappedBy: 'client', cascade: ['persist', 'remove'], fetch: 'EAGER', indexBy: 'id')] #[OrderBy(['number' => 'ASC'])] protected $phones; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 255)] protected $name; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php index ee07c7d4752..2c7f4e689eb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php @@ -67,17 +67,13 @@ public function testExplicitPolicy(): void #[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class DDC444User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 255)] public $name; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php index 57250117ec3..041b0b524e2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -62,9 +62,7 @@ class DDC448MainTable #[HasLifecycleCallbacks] class DDC448ConnectedClass { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php index cd0418a66f6..aed5c4eea94 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php @@ -45,16 +45,12 @@ public function testIssue(): void #[DiscriminatorMap(['distributor' => 'DDC493Distributor', 'customer' => 'DDC493Customer'])] class DDC493Customer { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var DDC493Contact - */ + /** @var DDC493Contact */ #[OneToOne(targetEntity: 'DDC493Contact', cascade: ['remove', 'persist'])] #[JoinColumn(name: 'contact', referencedColumnName: 'id')] public $contact; @@ -68,16 +64,12 @@ class DDC493Distributor extends DDC493Customer #[Entity] class DDC493Contact { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php index c335c82fec3..5666f2d071a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php @@ -60,9 +60,7 @@ public function testIssue(): void #[Entity] class DDC512Customer { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] @@ -90,9 +88,7 @@ class DDC512OfferItem extends DDC512Item #[DiscriminatorMap(['item' => 'DDC512Item', 'offerItem' => 'DDC512OfferItem'])] class DDC512Item { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php index af9ace41051..53a069e403c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php @@ -50,17 +50,13 @@ class DDC513OfferItem extends DDC513Item #[DiscriminatorMap(['item' => 'DDC513Item', 'offerItem' => 'DDC513OfferItem'])] class DDC513Item { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var DDC513Price - */ + /** @var DDC513Price */ #[OneToOne(targetEntity: 'DDC513Price', cascade: ['remove', 'persist'])] #[JoinColumn(name: 'price', referencedColumnName: 'id')] public $price; @@ -69,17 +65,13 @@ class DDC513Item #[Entity] class DDC513Price { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $data; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index b209a3279df..8b862b70ee0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -90,23 +90,17 @@ public function testJoinColumnWithNullSameNameAssociationField(): void #[Entity] class DDC522Customer { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var mixed - */ + /** @var mixed */ #[Column] public $name; - /** - * @var DDC522Cart - */ + /** @var DDC522Cart */ #[OneToOne(targetEntity: 'DDC522Cart', mappedBy: 'customer')] public $cart; } @@ -114,23 +108,17 @@ class DDC522Customer #[Entity] class DDC522Cart { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $total; - /** - * @var DDC522Customer - */ + /** @var DDC522Customer */ #[OneToOne(targetEntity: 'DDC522Customer', inversedBy: 'cart')] #[JoinColumn(name: 'customer', referencedColumnName: 'id')] public $customer; @@ -139,23 +127,17 @@ class DDC522Cart #[Entity] class DDC522ForeignKeyTest { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var int|null - */ + /** @var int|null */ #[Column(type: 'integer', name: 'cart_id', nullable: true)] public $cartId; - /** - * @var DDC522Cart|null - */ + /** @var DDC522Cart|null */ #[OneToOne(targetEntity: 'DDC522Cart')] #[JoinColumn(name: 'cart_id', referencedColumnName: 'id')] public $cart; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php index a0c2daa88a7..2bd10c6f544 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php @@ -59,23 +59,17 @@ public function testIssue(): void #[DiscriminatorMap(['0' => 'DDC531Item', '1' => 'DDC531SubItem'])] class DDC531Item { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC531Item', mappedBy: 'parent')] protected $children; - /** - * @var DDC531Item - */ + /** @var DDC531Item */ #[ManyToOne(targetEntity: 'DDC531Item', inversedBy: 'children')] #[JoinColumn(name: 'parentId', referencedColumnName: 'id')] public $parent; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index 344b114a0ee..259025935b2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -105,9 +105,7 @@ public function __toString(): string #[Entity] class DDC5684Object { - /** - * @var DDC5684ObjectIdType - */ + /** @var DDC5684ObjectIdType */ #[Id] #[Column(type: DDC5684ObjectIdType::class)] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php index 0e3390bca3e..7bdd65d1adf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -35,9 +35,7 @@ public function testIssue(): void #[Entity] class DDC588Site { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer', name: 'site_id')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php index 2a5f3b05bff..354e71dd953 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -88,17 +88,13 @@ public function testCascadeRemoveOnChildren(): void #[DiscriminatorMap(['0' => 'DDC599Item', '1' => 'DDC599Subitem'])] class DDC599Item { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC599Child', mappedBy: 'parent', cascade: ['remove'])] protected $children; @@ -117,9 +113,7 @@ public function getChildren(): Collection #[Entity] class DDC599Subitem extends DDC599Item { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $elem; } @@ -127,17 +121,13 @@ class DDC599Subitem extends DDC599Item #[Entity] class DDC599Child { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var DDC599Item - */ + /** @var DDC599Item */ #[ManyToOne(targetEntity: 'DDC599Item', inversedBy: 'children')] #[JoinColumn(name: 'parentId', referencedColumnName: 'id')] public $parent; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index d3f54b796c4..47b1e034759 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -130,22 +130,16 @@ public function testCombineIndexBy(): void #[Entity] class DDC618Author { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC618Book', mappedBy: 'author', cascade: ['persist'])] public $books; @@ -164,9 +158,7 @@ public function addBook(string $title): void #[Entity] class DDC618Book { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php index 967dc24eb18..8a8fe37877d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php @@ -86,7 +86,6 @@ private function assertHydratedEntitiesSameToPersistedOnes(array $persistedEntit } /** - * * Note: discriminator map order *IS IMPORTANT* for this test */ #[Table] @@ -96,9 +95,7 @@ private function assertHydratedEntitiesSameToPersistedOnes(array $persistedEntit #[DiscriminatorMap([DDC6303ChildB::class => DDC6303ChildB::class, DDC6303ChildA::class => DDC6303ChildA::class])] abstract class DDC6303BaseClass { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] #[GeneratedValue(strategy: 'NONE')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php index ea1e655bf42..034d42bb0c6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php @@ -78,17 +78,13 @@ public function testDQLDeferredEagerLoad(): void #[Entity] class DDC633Appointment { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC633Patient - */ + /** @var DDC633Patient */ #[OneToOne(targetEntity: 'DDC633Patient', inversedBy: 'appointment', fetch: 'EAGER')] public $patient; } @@ -96,17 +92,13 @@ class DDC633Appointment #[Entity] class DDC633Patient { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var DDC633Appointment - */ + /** @var DDC633Appointment */ #[OneToOne(targetEntity: 'DDC633Appointment', mappedBy: 'patient')] public $appointment; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php index bc0c003febf..b9f3db68ea1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php @@ -72,9 +72,7 @@ public function testInlineEmbeddableProxyInitialization(): void #[Embeddable] class DDC6460Embeddable { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $field; } @@ -82,17 +80,13 @@ class DDC6460Embeddable #[Entity] class DDC6460Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue(strategy: 'NONE')] #[Column(type: 'integer')] public $id; - /** - * @var DDC6460Embeddable - */ + /** @var DDC6460Embeddable */ #[Embedded(class: 'DDC6460Embeddable')] public $embedded; } @@ -100,17 +94,13 @@ class DDC6460Entity #[Entity] class DDC6460ParentEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue(strategy: 'NONE')] #[Column(type: 'integer')] public $id; - /** - * @var DDC6460Entity - */ + /** @var DDC6460Entity */ #[ManyToOne(targetEntity: 'DDC6460Entity', fetch: 'EXTRA_LAZY', cascade: ['persist'])] public $lazyLoaded; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index 04a116f1867..5b7c367f0e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -47,21 +47,15 @@ public function testRecomputeSingleEntityChangeSetPreservesFieldOrder(): void #[Entity] class DDC656Entity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $type; - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php index 18e9f6819a3..f504d714579 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -46,31 +46,23 @@ public function testTicket(): void #[Entity] class DDC698Role { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'roleID', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $roleID; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 45)] protected $name; - /** - * @var string - */ + /** @var string */ #[Column(name: 'shortName', type: 'string', length: 45)] protected $shortName; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'RolePrivileges')] #[JoinColumn(name: 'roleID', referencedColumnName: 'roleID')] #[InverseJoinColumn(name: 'privilegeID', referencedColumnName: 'privilegeID')] @@ -83,23 +75,17 @@ class DDC698Role #[Entity] class DDC698Privilege { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'privilegeID', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] protected $privilegeID; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 45)] protected $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'DDC698Role', mappedBy: 'privilege')] protected $roles; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php index efc9fb43c17..113da8cae2a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php @@ -119,9 +119,7 @@ class Lemma #[Column(type: 'string', name: 'lemma_name', unique: true, length: 255)] private string|null $lemma = null; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'Relation', mappedBy: 'parent', cascade: ['persist'])] private Collection $relations; @@ -256,9 +254,7 @@ class RelationType #[Column(type: 'string', name: 'relation_type_abbreviation', unique: true, length: 255)] private string|null $abbreviation = null; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'Relation', mappedBy: 'type', cascade: ['persist'])] private $relations; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php index dffa134b9eb..3469bac2742 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -44,9 +44,7 @@ public function testIsEmptySqlGeneration(): void #[MappedSuperclass] class MyEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -62,30 +60,22 @@ public function getId(): int #[Entity] class DDC719Group extends MyEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', nullable: false)] protected $name; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', nullable: true)] protected $description; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'groups_groups')] #[JoinColumn(name: 'parent_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'child_id', referencedColumnName: 'id')] #[ManyToMany(targetEntity: 'DDC719Group', inversedBy: 'parents')] protected $children = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'DDC719Group', mappedBy: 'children')] protected $parents = null; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php index 7f599075d07..9068d7f9e9b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -57,17 +57,13 @@ public function testRemoveElementAppliesOrphanRemoval(): void #[Entity] class DDC735Product { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] protected $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC735Review', mappedBy: 'product', cascade: ['persist'], orphanRemoval: true)] protected $reviews; @@ -96,9 +92,7 @@ public function removeReview(DDC735Review $review): void #[Entity] class DDC735Review { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php index adb7384602b..1045ae9c23a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php @@ -4,11 +4,11 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -66,16 +66,12 @@ public function testIssue(): void #[Entity] class DDC809Variant { - /** - * @var int - */ + /** @var int */ #[Column(name: 'variant_id', type: 'integer')] #[Id] protected $variantId; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'var_spec_value_test')] #[JoinColumn(name: 'variant_id', referencedColumnName: 'variant_id')] #[InverseJoinColumn(name: 'specification_value_id', referencedColumnName: 'specification_value_id')] @@ -93,16 +89,12 @@ public function getSpecificationValues(): Collection #[Entity] class DDC809SpecificationValue { - /** - * @var int - */ + /** @var int */ #[Column(name: 'specification_value_id', type: 'integer')] #[Id] protected $specificationValueId; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'DDC809Variant', mappedBy: 'SpecificationValues')] protected $variants; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index ddc6b78a736..e18e8aff159 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -144,17 +144,13 @@ public function testQuotedTableJoinedChildRemove(): void #[Entity] class DDC832Like { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; @@ -173,17 +169,13 @@ public function __construct( #[DiscriminatorMap(['like' => 'DDC832JoinedIndex', 'fuzzy' => 'DDC832JoinedTreeIndex'])] class DDC832JoinedIndex { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index 44dbd2efbf8..9fc2693ad4f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -104,9 +104,7 @@ public function testIssue(): void #[DiscriminatorMap(['class1' => 'DDC837Class1', 'class2' => 'DDC837Class2', 'class3' => 'DDC837Class3'])] abstract class DDC837Super { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] @@ -116,21 +114,15 @@ abstract class DDC837Super #[Entity] class DDC837Class1 extends DDC837Super { - /** - * @var string - */ + /** @var string */ #[Column(name: 'title', type: 'string', length: 150)] public $title; - /** - * @var string - */ + /** @var string */ #[Column(name: 'content', type: 'string', length: 500)] public $description; - /** - * @var DDC837Aggregate - */ + /** @var DDC837Aggregate */ #[OneToOne(targetEntity: 'DDC837Aggregate')] public $aggregate; } @@ -138,27 +130,19 @@ class DDC837Class1 extends DDC837Super #[Entity] class DDC837Class2 extends DDC837Super { - /** - * @var string - */ + /** @var string */ #[Column(name: 'title', type: 'string', length: 150)] public $title; - /** - * @var string - */ + /** @var string */ #[Column(name: 'content', type: 'string', length: 500)] public $description; - /** - * @var string - */ + /** @var string */ #[Column(name: 'text', type: 'text')] public $text; - /** - * @var DDC837Aggregate - */ + /** @var DDC837Aggregate */ #[OneToOne(targetEntity: 'DDC837Aggregate')] public $aggregate; } @@ -169,15 +153,11 @@ class DDC837Class2 extends DDC837Super #[Entity] class DDC837Class3 extends DDC837Super { - /** - * @var string - */ + /** @var string */ #[Column(name: 'title', type: 'string', length: 150)] public $apples; - /** - * @var string - */ + /** @var string */ #[Column(name: 'content', type: 'string', length: 500)] public $bananas; } @@ -185,9 +165,7 @@ class DDC837Class3 extends DDC837Super #[Entity] class DDC837Aggregate { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index 33139c175c5..4d170583f41 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -113,9 +113,7 @@ class DDC881User #[Column(type: 'string', length: 255)] private string|null $name = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC881PhoneNumber', mappedBy: 'id')] private $phoneNumbers; @@ -144,9 +142,7 @@ class DDC881PhoneNumber #[Column(type: 'string', length: 255)] private string|null $phonenumber = null; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC881PhoneCall', mappedBy: 'phonenumber')] private $calls; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index bfaf0b7732b..46ef531c6dc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\Column; @@ -13,6 +12,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -94,23 +94,17 @@ public function testOneToManyChild(): void #[DiscriminatorMap(['child' => 'DDC992Child', 'parent' => 'DDC992Parent'])] class DDC992Parent { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DDC992Parent - */ + /** @var DDC992Parent */ #[ManyToOne(targetEntity: 'DDC992Parent', inversedBy: 'childs')] public $parent; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'DDC992Child', mappedBy: 'parent')] public $childs; } @@ -132,29 +126,21 @@ public function getRoleID(): int return $this->roleID; } - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'roleID', type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $roleID; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 45)] public $name; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'DDC992Role', mappedBy: 'extends')] public $extendedBy; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'RoleRelations')] #[JoinColumn(name: 'roleID', referencedColumnName: 'roleID')] #[InverseJoinColumn(name: 'extendsRoleID', referencedColumnName: 'roleID')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php index 56c0ea6f897..98a936e1bac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php @@ -67,24 +67,18 @@ public function testCacheShouldBeUpdatedWhenAssociationChanges(): void #[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH5562Merchant { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'IDENTITY')] public $id; - /** - * @var GH5562Manager - */ + /** @var GH5562Manager */ #[OneToOne(targetEntity: GH5562Manager::class, mappedBy: 'merchant')] #[Cache(usage: 'NONSTRICT_READ_WRITE')] public $manager; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name', type: 'string', length: 255, nullable: false)] public $name; } @@ -94,9 +88,7 @@ class GH5562Merchant #[DiscriminatorMap(['MANAGER' => GH5562Manager::class])] abstract class GH5562User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id', type: 'integer')] #[GeneratedValue(strategy: 'IDENTITY')] @@ -107,15 +99,11 @@ abstract class GH5562User #[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH5562Manager extends GH5562User { - /** - * @var string - */ + /** @var string */ #[Column] public $username; - /** - * @var GH5562Merchant - */ + /** @var GH5562Merchant */ #[OneToOne(targetEntity: GH5562Merchant::class, inversedBy: 'manager')] public $merchant; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index 0e2c9b2761d..6083f8b88af 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -110,9 +110,7 @@ private function createData(): void #[Entity] class GH5762Driver { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'GH5762DriverRide', mappedBy: 'driver')] public $driverRides; @@ -151,9 +149,7 @@ public function __construct( #[Entity] class GH5762Car { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'GH5762DriverRide', mappedBy: 'car')] public $carRides; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index d45780f158a..f8441ab0ea7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -92,25 +92,19 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): stri #[Entity] class GH5804Article { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'GH5804Type', length: 255)] #[GeneratedValue(strategy: 'CUSTOM')] - #[CustomIdGenerator(class: \Doctrine\Tests\ORM\Functional\Ticket\GH5804Generator::class)] + #[CustomIdGenerator(class: GH5804Generator::class)] public $id; - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; - /** - * @var string - */ + /** @var string */ #[Column(type: 'text')] public $text; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php index 5bb190e1252..aaacc4f0128 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php @@ -90,17 +90,13 @@ public function testOneToManyAssociation(): void #[Entity] class GH6029User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: GH6029Group::class, cascade: ['all'])] public $groups; @@ -113,9 +109,7 @@ public function __construct() #[Entity] class GH6029Group { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -125,9 +119,7 @@ class GH6029Group #[Entity] class GH6029Group2 { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -137,17 +129,13 @@ class GH6029Group2 #[Entity] class GH6029Product { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: GH6029Feature::class, mappedBy: 'product', cascade: ['all'])] public $features; @@ -160,17 +148,13 @@ public function __construct() #[Entity] class GH6029Feature { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var GH6029Product - */ + /** @var GH6029Product */ #[ManyToOne(targetEntity: GH6029Product::class, inversedBy: 'features')] #[JoinColumn(name: 'product_id', referencedColumnName: 'id')] public $product; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php index 7f6b3c648dc..b58a3b7a2fb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php @@ -148,9 +148,7 @@ public function __toString(): string #[DiscriminatorMap([GH6141People::BOSS => GH6141Boss::class, GH6141People::EMPLOYEE => GH6141Employee::class])] abstract class GH6141Person { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php index c5f299f3203..dd8516757a3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php @@ -62,9 +62,7 @@ public function testLoadingOfSecondLevelCacheOnEagerAssociations(): void #[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH6217AssociatedEntity { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] #[GeneratedValue(strategy: 'NONE')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index 6915efb6dad..4b9679c7ff5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -91,9 +91,7 @@ public function testInheritanceJoinAlias(): void #[Entity] class GH6362Start { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] @@ -109,17 +107,13 @@ class GH6362Start #[Entity] abstract class GH6362Base { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] protected $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'GH6362Start', mappedBy: 'bases')] private $starts; } @@ -127,9 +121,7 @@ abstract class GH6362Base #[Entity] class GH6362Child extends GH6362Base { - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'GH6362Join', mappedBy: 'child')] private $joins; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php index 46b85f2802d..9eb673ddb34 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php @@ -48,9 +48,7 @@ public function testFetchVersionValueForDifferentIdFieldAndColumn(): void #[Entity] class A { - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; @@ -66,9 +64,7 @@ public function __construct( #[Entity] class B { - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php index 2194d7c8ad1..a6e629a5ae6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php @@ -55,17 +55,13 @@ public function testIssue(): void #[Entity] class GH6464Post { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $authorId; } @@ -76,9 +72,7 @@ class GH6464Post #[DiscriminatorMap(['author' => 'GH6464Author'])] abstract class GH6464User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php index 2100618082e..c5265a9634a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php @@ -87,9 +87,7 @@ public function testJoinTableWithMetadata(): void #[Entity] class GH6531User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -99,9 +97,7 @@ class GH6531User #[Entity] class GH6531Address { - /** - * @var GH6531User - */ + /** @var GH6531User */ #[Id] #[OneToOne(targetEntity: GH6531User::class)] public $user; @@ -110,17 +106,13 @@ class GH6531Address #[Entity] class GH6531Article { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - * */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: GH6531ArticleAttribute::class, mappedBy: 'article', cascade: ['ALL'], indexBy: 'attribute')] public $attributes; @@ -149,17 +141,13 @@ public function __construct( #[Entity] class GH6531Order { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: GH6531OrderItem::class, mappedBy: 'order', cascade: ['ALL'])] public $items; @@ -177,9 +165,7 @@ public function addItem(GH6531Product $product, int $amount): void #[Entity] class GH6531Product { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php index 464c2a53486..6d9210b1da6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php @@ -4,12 +4,12 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -65,30 +65,22 @@ public function testCharsetCollationWhenCreatingForeignRelations(): void #[Entity] class GH6823User { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] public $id; - /** - * @var GH6823Group - */ + /** @var GH6823Group */ #[ManyToOne(targetEntity: 'GH6823Group')] #[JoinColumn(name: 'group_id', referencedColumnName: 'id', options: ['charset' => 'ascii', 'collation' => 'ascii_general_ci'])] public $group; - /** - * @var GH6823Status - */ + /** @var GH6823Status */ #[ManyToOne(targetEntity: 'GH6823Status')] #[JoinColumn(name: 'status_id', referencedColumnName: 'id', options: ['charset' => 'latin1', 'collation' => 'latin1_bin'])] public $status; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'gh6823_user_tags', options: ['charset' => 'ascii', 'collation' => 'ascii_general_ci'])] #[JoinColumn(name: 'user_id', referencedColumnName: 'id', options: ['charset' => 'utf8mb4', 'collation' => 'utf8mb4_bin'])] #[InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id', options: ['charset' => 'latin1', 'collation' => 'latin1_bin'])] @@ -100,9 +92,7 @@ class GH6823User #[Entity] class GH6823Group { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] public $id; @@ -112,9 +102,7 @@ class GH6823Group #[Entity] class GH6823Status { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255, options: ['charset' => 'latin1', 'collation' => 'latin1_bin'])] public $id; @@ -124,9 +112,7 @@ class GH6823Status #[Entity] class GH6823Tag { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255, options: ['charset' => 'latin1', 'collation' => 'latin1_bin'])] public $id; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php index 10ed46ce8d9..1b0884be784 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php @@ -95,17 +95,13 @@ public function testPhoneNumberIsPopulatedWithQueryBuilder(): void #[DiscriminatorMap(['employee' => GH6937Employee::class, 'manager' => GH6937Manager::class])] abstract class GH6937Person { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; } @@ -113,9 +109,7 @@ abstract class GH6937Person #[Entity] abstract class GH6937Employee extends GH6937Person { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $phoneNumber; } @@ -123,9 +117,7 @@ abstract class GH6937Employee extends GH6937Person #[Entity] class GH6937Manager extends GH6937Employee { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $department; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php index 045e95df777..17a39e4ca0d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php @@ -127,9 +127,7 @@ public function __construct( #[Entity] class GH7062Season { - /** - * @var GH7062Ranking|null - */ + /** @var GH7062Ranking|null */ #[OneToOne(targetEntity: GH7062Ranking::class, mappedBy: 'season', cascade: ['all'])] public $ranking; @@ -163,9 +161,7 @@ public function __construct( #[Entity] class GH7062RankingPosition { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $points; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php index 437260119d1..41de82c3216 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php @@ -51,23 +51,17 @@ public function testSLCWithVersion(): void #[Cache(usage: 'NONSTRICT_READ_WRITE')] class GH7067Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'datetime')] public $lastUpdate; - /** - * @var DateTime - */ + /** @var DateTime */ #[Column(type: 'datetime')] #[Version] public $version; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php index 67e9f363927..7d3d44ae2fb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php @@ -42,9 +42,7 @@ public function testLockModeIsRespected(): void #[Entity] final class SomeEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php index f4a048e1dcb..d4f91806122 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php @@ -86,17 +86,13 @@ private function createClassMetadata(string $className): ClassMetadata #[Entity] class GH7079CmsUser { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var GH7079CmsAddress - */ + /** @var GH7079CmsAddress */ #[OneToOne(targetEntity: GH7079CmsAddress::class, mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] public $address; } @@ -105,17 +101,13 @@ class GH7079CmsUser #[Entity] class GH7079CmsAddress { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] public $id; - /** - * @var GH7079CmsUser - */ + /** @var GH7079CmsUser */ #[OneToOne(targetEntity: GH7079CmsUser::class, inversedBy: 'address')] #[JoinColumn(referencedColumnName: 'id')] public $user; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php index 10322b2201b..daa2cdae65c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php @@ -78,17 +78,13 @@ public function testPersistFileAfterVersion(): void #[Entity] class GH7259File { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var GH7259Space|null - */ + /** @var GH7259Space|null */ #[ManyToOne(targetEntity: GH7259Space::class)] #[JoinColumn(nullable: false)] public $space; @@ -97,17 +93,13 @@ class GH7259File #[Entity] class GH7259FileVersion { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var GH7259File|null - */ + /** @var GH7259File|null */ #[ManyToOne(targetEntity: GH7259File::class)] #[JoinColumn(nullable: false)] public $file; @@ -116,17 +108,13 @@ class GH7259FileVersion #[Entity] class GH7259Space { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var GH7259File|null - */ + /** @var GH7259File|null */ #[ManyToOne(targetEntity: GH7259File::class)] #[JoinColumn(nullable: true)] public $ruleFile; @@ -135,17 +123,13 @@ class GH7259Space #[Entity] class GH7259Feed { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var GH7259Space|null - */ + /** @var GH7259Space|null */ #[ManyToOne(targetEntity: GH7259Space::class)] #[JoinColumn(nullable: false)] public $space; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php index 5d8ce3df78a..c56f66e13a4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php @@ -77,9 +77,7 @@ public function testAggregateFunctionInCustomFunction(): void #[Entity] class GH7286Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php index 42e0b439b77..23ed7700763 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php @@ -45,17 +45,13 @@ public function testOptimisticLockNoExceptionOnFind(): void #[Entity] class GH7366Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Version] protected $lockVersion = 1; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php index 1adba40cf11..be502f3a792 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php @@ -92,20 +92,16 @@ public function __construct( #[Entity] class GH7496EntityAinB { - /** - * @param GH7496EntityA $a - * @param GH7496EntityB $b - */ public function __construct( #[Id] #[Column(type: 'integer')] public int $id, #[ManyToOne(targetEntity: GH7496EntityA::class)] #[JoinColumn(name: 'a_id', referencedColumnName: 'a_id', nullable: false)] - public $eA, + public GH7496EntityA $eA, #[ManyToOne(targetEntity: GH7496EntityB::class)] #[JoinColumn(name: 'b_id', referencedColumnName: 'b_id', nullable: false)] - public $eB, + public GH7496EntityB $eB, ) { } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php index 0d9bd8db96d..566aab7a784 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php @@ -60,9 +60,7 @@ public function testSimpleArrayTypeHydratedCorrectly(): void #[DiscriminatorMap(['array' => GH7505ArrayResponse::class, 'text' => GH7505TextResponse::class])] abstract class GH7505AbstractResponse { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -72,9 +70,7 @@ abstract class GH7505AbstractResponse #[Entity] class GH7505ArrayResponse extends GH7505AbstractResponse { - /** - * @var mixed[] - */ + /** @var mixed[] */ #[Column(name: 'value_array', type: 'simple_array')] public $value = []; } @@ -82,9 +78,7 @@ class GH7505ArrayResponse extends GH7505AbstractResponse #[Entity] class GH7505TextResponse extends GH7505AbstractResponse { - /** - * @var string|null - */ + /** @var string|null */ #[Column(name: 'value_string', type: 'string', length: 255)] public $value; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php index 65240b0b937..a3305c5ef3e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php @@ -49,17 +49,13 @@ public function testFindEntityByAssociationPropertyJoinedChildWithClearMetadata( #[DiscriminatorMap(['entitya' => GH7512EntityA::class, 'entityB' => GH7512EntityB::class])] class GH7512EntityA { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'GH7512EntityC', mappedBy: 'entityA')] public $entityCs; } @@ -72,17 +68,13 @@ class GH7512EntityB extends GH7512EntityA #[Entity] class GH7512EntityC { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var GH7512EntityA - */ + /** @var GH7512EntityA */ #[ManyToOne(targetEntity: 'GH7512EntityA', inversedBy: 'entityCs')] public $entityA; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php index 77e007f41e5..1c4f2175325 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php @@ -53,9 +53,7 @@ public function testPersistAfterRemoveSchedulesForSynchronization(): void #[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class GH7629Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php index d6b797fed3e..c75098654e9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php @@ -54,9 +54,7 @@ public function testIndexByAssociation(): void #[Entity] class GH7661User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -66,16 +64,12 @@ class GH7661User #[Entity] class GH7661Event { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var GH7661Participant[] - */ + /** @var GH7661Participant[] */ #[OneToMany(targetEntity: GH7661Participant::class, mappedBy: 'event', indexBy: 'user_id')] public $participants; } @@ -83,9 +77,7 @@ class GH7661Event #[Entity] class GH7661Participant { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php index 67c63fa529f..51b2e5017e0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -74,9 +74,7 @@ public function __construct( #[Entity] class GH7737Person { - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable] #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id', unique: true)] #[ManyToMany(targetEntity: GH7737Group::class)] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php index fef937275fc..3495b4c1b9f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ChangeTrackingPolicy; @@ -12,6 +11,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -74,17 +74,13 @@ public function testCollectionClearDoesClearIfPersisted(): void #[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class GH7761Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var Collection - */ + /** @var Collection */ #[JoinTable(name: 'gh7761_to_child')] #[JoinColumn(name: 'entity_id')] #[InverseJoinColumn(name: 'child_id')] @@ -101,9 +97,7 @@ public function __construct() #[ChangeTrackingPolicy('DEFERRED_EXPLICIT')] class GH7761ChildEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php index f6efa39e679..cf983d8670f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php @@ -69,9 +69,7 @@ class GH7767ParentEntity #[GeneratedValue] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: GH7767ChildEntity::class, mappedBy: 'parent', fetch: 'EXTRA_LAZY', cascade: ['persist'])] #[OrderBy(['position' => 'ASC'])] private $children; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php index b3be490ff8f..4003d1e7c82 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php @@ -90,9 +90,7 @@ class GH7836ParentEntity #[GeneratedValue] private int $id; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: GH7836ChildEntity::class, mappedBy: 'parent', fetch: 'EXTRA_LAZY', cascade: ['persist'])] #[OrderBy(['position' => 'ASC', 'name' => 'ASC'])] private $children; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php index c60f3862a7f..a9a0b52cd78 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php @@ -64,23 +64,17 @@ public function testExtraLazyRemoveElement(): void #[Entity] class GH7864User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'GH7864Tweet', mappedBy: 'user', fetch: 'EXTRA_LAZY')] public $tweets; @@ -99,23 +93,17 @@ public function addTweet(GH7864Tweet $tweet): void #[Entity] class GH7864Tweet { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $content; - /** - * @var GH7864User - */ + /** @var GH7864User */ #[ManyToOne(targetEntity: 'GH7864User', inversedBy: 'tweets')] public $user; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php index ab8876ba420..4f18fc17a13 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php @@ -67,17 +67,13 @@ public function getClassMetadata($className): ClassMetadata #[Entity] class GH7869Appointment { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var GH7869Patient - */ + /** @var GH7869Patient */ #[OneToOne(targetEntity: 'GH7869Patient', inversedBy: 'appointment', fetch: 'EAGER')] public $patient; } @@ -85,17 +81,13 @@ class GH7869Appointment #[Entity] class GH7869Patient { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var GH7869Appointment - */ + /** @var GH7869Appointment */ #[OneToOne(targetEntity: 'GH7869Appointment', mappedBy: 'patient')] public $appointment; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php index 8f5a91b0938..3b4fa7d0b96 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php @@ -93,9 +93,7 @@ public function testUpdateSchemaSqlWithSchemaAssetFilter(): void #[Entity] class GH7875MyEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] @@ -106,9 +104,7 @@ class GH7875MyEntity #[Entity] class GH7875MyOtherEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php index 1532af1ca60..6693828964b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php @@ -90,17 +90,13 @@ public function typesShouldBeConvertedForDQLFunctions(): void #[Entity] class GH7941Product { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DateTimeImmutable - */ + /** @var DateTimeImmutable */ #[Column(type: 'datetime_immutable')] public $createdAt; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php index c4a1846142a..a7283260255 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php @@ -49,9 +49,7 @@ public function testNumericDescriminatorColumn(): void #[DiscriminatorMap([1 => GH8055BaseClass::class, 2 => GH8055SubClass::class])] class GH8055BaseClass { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] @@ -61,9 +59,7 @@ class GH8055BaseClass #[Entity] class GH8055SubClass extends GH8055BaseClass { - /** - * @var string - */ + /** @var string */ #[Column(name: 'test', type: 'string', length: 255)] public $value; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php index 4f4ec6aaf0a..daea03687c6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php @@ -36,17 +36,13 @@ public function testConvertToPHPValueSQLForNewObjectExpression(): void #[Entity] final class GH8061Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var mixed - */ + /** @var mixed */ #[Column(type: 'GH8061Type', length: 255)] public $field; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php index 3726a4c8b98..4b9575c7e93 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php @@ -46,17 +46,13 @@ public function testNoQueriesAfterSecondFlush(): void #[Entity] class GH8217Collection { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'GH8217CollectionItem', mappedBy: 'collection', cascade: ['persist', 'remove'], orphanRemoval: true)] public $items; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php index 99726136dc6..d1081ff2620 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php @@ -94,9 +94,7 @@ class GH8443Foo #[GeneratedValue] private int|null $id = null; - /** - * @var GH8443Foo|null - */ + /** @var GH8443Foo|null */ #[OneToOne(targetEntity: 'GH8443Foo')] #[JoinColumn(name: 'bar_id', referencedColumnName: 'id')] private $bar; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php index 0176c51047c..a92ef99b832 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php @@ -112,29 +112,21 @@ public function testOptimisticLockWithDateTimeForVersionThrowsException(): void #[Entity] class GH8499VersionableEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $description; - /** - * @var DateTimeInterface - */ + /** @var DateTimeInterface */ #[Version] #[Column(type: 'datetime')] public $revision; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php index 8d066463e03..d827c74cdbf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php @@ -32,17 +32,13 @@ public function testDeletedEntity(): void #[Entity] class GH8663VersionedEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] protected $id; - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] protected $version; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php index 1f396a86d3e..91141236e7a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php @@ -38,9 +38,7 @@ abstract class GH8914BaseEntity #[DiscriminatorMap(['person' => 'GH8914Person', 'employee' => 'GH8914Employee'])] class GH8914Person extends GH8914BaseEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php index 91f26452fe4..08a776de0ef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php @@ -42,17 +42,13 @@ public function testUnitOfWorkHandlesNullRelations(): void #[Entity] class GH9027Customer { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var GH9027Cart - */ + /** @var GH9027Cart */ #[OneToOne(targetEntity: 'GH9027Cart', mappedBy: 'customer')] public $cart; } @@ -60,17 +56,13 @@ class GH9027Customer #[Entity] class GH9027Cart { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var GH9027Customer - */ + /** @var GH9027Customer */ #[OneToOne(targetEntity: 'GH9027Customer', inversedBy: 'cart')] #[JoinColumn(name: 'customer', referencedColumnName: 'id')] public $customer; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php index bfa4659362f..bbbbd29c6fa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php @@ -129,41 +129,29 @@ public function testIssue(string $property, $falsyValue, $truthyValue): void #[Entity] class GH9230Entity { - /** - * @var int - */ + /** @var int */ #[Column(name: 'id', type: 'integer')] #[Id] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var ?string - */ + /** @var ?string */ #[Column(name: 'name', type: 'string', nullable: true)] public $name; - /** - * @var ?int - */ + /** @var ?int */ #[Column(name: 'counter', type: 'integer', nullable: true)] public $counter; - /** - * @var ?bool - */ + /** @var ?bool */ #[Column(name: 'enabled', type: 'boolean', nullable: true)] public $enabled; - /** - * @var ?float - */ + /** @var ?float */ #[Column(name: 'price', type: 'decimal', scale: 1, precision: 2, nullable: true)] public $price; - /** - * @var mixed[] - */ + /** @var mixed[] */ #[Column(name: 'extra', type: 'json', nullable: true)] public $extra; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php index 05d9e92c3e8..c77d0d78b8b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php @@ -105,23 +105,17 @@ public function __toString(): string #[Entity] class GH9335Book { - /** - * @var GH9335IntObject - */ + /** @var GH9335IntObject */ #[Id] #[Column(type: GH9335IntObjectType::class, unique: true)] private $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string')] private $title; - /** - * @var GH9335Author - */ + /** @var GH9335Author */ #[OneToOne(targetEntity: 'GH9335Author', mappedBy: 'book', cascade: ['persist', 'remove'])] private $author; @@ -173,17 +167,13 @@ public function setAuthor(GH9335Author|null $author): self #[Entity] class GH9335Author { - /** - * @var GH9335Book - */ + /** @var GH9335Book */ #[Id] #[OneToOne(targetEntity: 'GH9335Book', inversedBy: 'author')] #[JoinColumn(name: 'book')] private $book; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', nullable: true)] private $name; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php index 74c685f378b..9d2b5714c1c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php @@ -69,17 +69,13 @@ public function testIssue(): void #[Entity] class GH9579Container { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'GH9579Item', mappedBy: 'container')] public $items; @@ -88,9 +84,7 @@ public function __construct() $this->items = new ArrayCollection(); } - /** - * @var GH9579Item - */ + /** @var GH9579Item */ #[OneToOne(targetEntity: 'GH9579Item')] #[JoinColumn(name: 'item_id', referencedColumnName: 'id')] public $currentItem; @@ -105,23 +99,17 @@ public function __construct() $this->parts = new ArrayCollection(); } - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var Collection - */ + /** @var Collection */ #[OneToMany(targetEntity: 'GH9579Part', mappedBy: 'item')] public $parts; - /** - * @var GH9579Container - */ + /** @var GH9579Container */ #[ManyToOne(targetEntity: 'GH9579Container', inversedBy: 'items')] #[JoinColumn(name: 'container_id', referencedColumnName: 'id')] public $container; @@ -131,17 +119,13 @@ public function __construct() #[Entity] class GH9579Part { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var GH9579Item - */ + /** @var GH9579Item */ #[ManyToOne(targetEntity: 'GH9579Item', inversedBy: 'parts')] #[JoinColumn(name: 'item_id', referencedColumnName: 'id')] public $item; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php index 553ee9a998f..9d8e8f1c51b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php @@ -76,17 +76,13 @@ public function testHydrateJoinedCollectionWithFirstNullishRow(): void #[Entity] class GH9807Main { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] private $id; - /** - * @var Collection - */ + /** @var Collection */ #[ORM\ManyToMany(targetEntity: 'GH9807Join', inversedBy: 'starts')] private $joins; @@ -100,23 +96,17 @@ public function getJoins(): Collection #[Entity] class GH9807Join { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue] private $id; - /** - * @var Collection - */ + /** @var Collection */ #[ORM\ManyToMany(targetEntity: 'GH9807Main', mappedBy: 'bases')] private $mains; - /** - * @var string - */ + /** @var string */ #[ORM\Column(type: 'string', nullable: false)] private $value; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php index 82a448ccb5b..b3882dfccb3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php @@ -34,9 +34,7 @@ public function testEmptyInsert(): void #[Entity] class Ticket2481Product { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 53549eca8f6..aec20995f3f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -352,28 +352,20 @@ public function getInfiniteEmbeddableNestingData(): array #[Entity] class DDC93Person { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue] #[Column(type: 'integer')] public $id; - /** - * @var DDC93Timestamps - */ + /** @var DDC93Timestamps */ #[Embedded(class: 'DDC93Timestamps')] public $timestamps; public function __construct( - /** - * @var string|null - */ - #[Column(type: 'string', length: 255)] - public $name = null, - #[Embedded(class: 'DDC93Address')] - public DDC93Address|null $address = null, + /** @var string|null */ + #[Column(type: 'string', length: 255)] public $name = null, + #[Embedded(class: 'DDC93Address')] public DDC93Address|null $address = null, ) { $this->timestamps = new DDC93Timestamps(new DateTime()); } @@ -383,8 +375,7 @@ public function __construct( class DDC93Timestamps { public function __construct( - #[Column(type: 'datetime')] - public DateTime $createdAt, + #[Column(type: 'datetime')] public DateTime $createdAt, ) { } } @@ -395,17 +386,14 @@ public function __construct( #[DiscriminatorMap(['v' => 'Doctrine\Tests\ORM\Functional\DDC93Car'])] abstract class DDC93Vehicle { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue(strategy: 'AUTO')] #[Column(type: 'integer')] public $id; public function __construct( - #[Embedded(class: 'DDC93Address')] - public DDC93Address $address, + #[Embedded(class: 'DDC93Address')] public DDC93Address $address, ) { } } @@ -419,8 +407,7 @@ class DDC93Car extends DDC93Vehicle class DDC93Country { public function __construct( - #[Column(type: 'string', nullable: true)] - public string|null $name = null, + #[Column(type: 'string', nullable: true)] public string|null $name = null, ) { } } @@ -428,25 +415,23 @@ public function __construct( #[Embeddable] class DDC93Address { + #[Embedded(class: DDC93Country::class)] + public DDC93Country|null $country = null; + + /** + * @param string|null $street + * @param string|null $zip + */ public function __construct( - /** - * @var string|null - */ #[Column(type: 'string', length: 255)] public $street = null, - /** - * @var string|null - */ #[Column(type: 'string', length: 255)] public $zip = null, #[Column(type: 'string', length: 255)] public string|null $city = null, - /** - * @var DDC93Country|null - */ - #[Embedded(class: 'DDC93Country')] - public $country = null, + DDC93Country|null $country = null, ) { + $this->country = $country; } } @@ -465,15 +450,11 @@ class DDC93Customer #[Embeddable] class DDC93ContactInfo { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $email; - /** - * @var DDC93Address - */ + /** @var DDC93Address */ #[Embedded(class: 'DDC93Address')] public $address; } @@ -482,10 +463,8 @@ class DDC93ContactInfo class DDC3028PersonWithPrefix { public function __construct( - #[Embedded(class: 'DDC3028Id', columnPrefix: 'foobar_')] - public DDC3028Id|null $id = null, - #[Embedded(class: 'DDC3028NestedEmbeddable', columnPrefix: 'bloo_')] - public DDC3028NestedEmbeddable|null $nested = null, + #[Embedded(class: 'DDC3028Id', columnPrefix: 'foobar_')] public DDC3028Id|null $id = null, + #[Embedded(class: 'DDC3028NestedEmbeddable', columnPrefix: 'bloo_')] public DDC3028NestedEmbeddable|null $nested = null, ) { } } @@ -494,10 +473,8 @@ public function __construct( class DDC3028PersonEmptyPrefix { public function __construct( - #[Embedded(class: 'DDC3028Id', columnPrefix: '')] - public DDC3028Id|null $id = null, - #[Embedded(class: 'DDC3028NestedEmbeddable', columnPrefix: '')] - public DDC3028NestedEmbeddable|null $nested = null, + #[Embedded(class: 'DDC3028Id', columnPrefix: '')] public DDC3028Id|null $id = null, + #[Embedded(class: 'DDC3028NestedEmbeddable', columnPrefix: '')] public DDC3028NestedEmbeddable|null $nested = null, ) { } } @@ -506,8 +483,7 @@ public function __construct( class DDC3028PersonPrefixFalse { public function __construct( - #[Embedded(class: 'DDC3028Id', columnPrefix: false)] - public DDC3028Id|null $id = null, + #[Embedded(class: 'DDC3028Id', columnPrefix: false)] public DDC3028Id|null $id = null, ) { } } @@ -516,9 +492,7 @@ public function __construct( class DDC3028Id { public function __construct( - #[Id] - #[Column(type: 'string', length: 255)] - public string|null $id = null, + #[Id] #[Column(type: 'string', length: 255)] public string|null $id = null, ) { } } @@ -527,12 +501,9 @@ public function __construct( class DDC3028NestedEmbeddable { public function __construct( - #[Embedded(class: 'DDC3028Id', columnPrefix: 'foo_')] - public DDC3028Id|null $nestedWithPrefix = null, - #[Embedded(class: 'DDC3028Id', columnPrefix: '')] - public DDC3028Id|null $nestedWithEmptyPrefix = null, - #[Embedded(class: 'DDC3028Id', columnPrefix: false)] - public DDC3028Id|null $nestedWithPrefixFalse = null, + #[Embedded(class: 'DDC3028Id', columnPrefix: 'foo_')] public DDC3028Id|null $nestedWithPrefix = null, + #[Embedded(class: 'DDC3028Id', columnPrefix: '')] public DDC3028Id|null $nestedWithEmptyPrefix = null, + #[Embedded(class: 'DDC3028Id', columnPrefix: false)] public DDC3028Id|null $nestedWithPrefixFalse = null, ) { } } @@ -540,17 +511,13 @@ public function __construct( #[MappedSuperclass] abstract class DDC3027Animal { - /** - * @var int - */ + /** @var int */ #[Id] #[GeneratedValue(strategy: 'AUTO')] #[Column(type: 'integer')] public $id; - /** - * @var DDC93Address - */ + /** @var DDC93Address */ #[Embedded(class: 'DDC93Address')] public $address; } @@ -563,9 +530,7 @@ class DDC3027Dog extends DDC3027Animal #[Embeddable] class DDCInfiniteNestingEmbeddable { - /** - * @var DDCInfiniteNestingEmbeddable - */ + /** @var DDCInfiniteNestingEmbeddable */ #[Embedded(class: 'DDCInfiniteNestingEmbeddable')] public $nested; } @@ -573,21 +538,15 @@ class DDCInfiniteNestingEmbeddable #[Embeddable] class DDCNestingEmbeddable1 { - /** - * @var DDC3028Id - */ + /** @var DDC3028Id */ #[Embedded(class: 'DDC3028Id')] public $id1; - /** - * @var DDC3028Id - */ + /** @var DDC3028Id */ #[Embedded(class: 'DDC3028Id')] public $id2; - /** - * @var DDCNestingEmbeddable2 - */ + /** @var DDCNestingEmbeddable2 */ #[Embedded(class: 'DDCNestingEmbeddable2')] public $nested; } @@ -595,21 +554,15 @@ class DDCNestingEmbeddable1 #[Embeddable] class DDCNestingEmbeddable2 { - /** - * @var DDC3028Id - */ + /** @var DDC3028Id */ #[Embedded(class: 'DDC3028Id')] public $id1; - /** - * @var DDC3028Id - */ + /** @var DDC3028Id */ #[Embedded(class: 'DDC3028Id')] public $id2; - /** - * @var DDCNestingEmbeddable3 - */ + /** @var DDCNestingEmbeddable3 */ #[Embedded(class: 'DDCNestingEmbeddable3')] public $nested; } @@ -617,21 +570,15 @@ class DDCNestingEmbeddable2 #[Embeddable] class DDCNestingEmbeddable3 { - /** - * @var DDC3028Id - */ + /** @var DDC3028Id */ #[Embedded(class: 'DDC3028Id')] public $id1; - /** - * @var DDC3028Id - */ + /** @var DDC3028Id */ #[Embedded(class: 'DDC3028Id')] public $id2; - /** - * @var DDCNestingEmbeddable4 - */ + /** @var DDCNestingEmbeddable4 */ #[Embedded(class: 'DDCNestingEmbeddable4')] public $nested; } @@ -639,21 +586,15 @@ class DDCNestingEmbeddable3 #[Embeddable] class DDCNestingEmbeddable4 { - /** - * @var DDC3028Id - */ + /** @var DDC3028Id */ #[Embedded(class: 'DDC3028Id')] public $id1; - /** - * @var DDC3028Id - */ + /** @var DDC3028Id */ #[Embedded(class: 'DDC3028Id')] public $id2; - /** - * @var DDCNestingEmbeddable1 - */ + /** @var DDCNestingEmbeddable1 */ #[Embedded(class: 'DDCNestingEmbeddable1')] public $nested; } diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php index a1c25c7d444..af5290dc6a2 100644 --- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -61,9 +61,7 @@ public function testCorrectIdGeneration(): void #[Entity] class AssignedSingleIdEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $myId; @@ -72,16 +70,12 @@ class AssignedSingleIdEntity #[Entity] class AssignedCompositeIdEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $myId1; - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $myId2; diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index e9887ff4942..94791fd86bd 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -302,9 +302,7 @@ class EntityIndexSubClass extends MappedSuperclassBaseIndex #[DiscriminatorMap(['c' => 'HierarchyC', 'd' => 'HierarchyD', 'e' => 'HierarchyE'])] abstract class HierarchyBase { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue(strategy: 'SEQUENCE')] @@ -315,9 +313,7 @@ abstract class HierarchyBase #[MappedSuperclass] abstract class HierarchyASuperclass extends HierarchyBase { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $a; } @@ -325,9 +321,7 @@ abstract class HierarchyASuperclass extends HierarchyBase #[Entity] class HierarchyBEntity extends HierarchyBase { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $b; } @@ -335,9 +329,7 @@ class HierarchyBEntity extends HierarchyBase #[Entity] class HierarchyC extends HierarchyBase { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $c; } @@ -345,9 +337,7 @@ class HierarchyC extends HierarchyBase #[Entity] class HierarchyD extends HierarchyASuperclass { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $d; } @@ -355,9 +345,7 @@ class HierarchyD extends HierarchyASuperclass #[Entity] class HierarchyE extends HierarchyBEntity { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $e; } @@ -370,9 +358,7 @@ class SuperclassEntity extends SuperclassBase #[MappedSuperclass] abstract class SuperclassBase { - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] #[Id] #[GeneratedValue(strategy: 'SEQUENCE')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index ecc7bdb0ce6..4726f70a869 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -474,9 +474,7 @@ public function testInvalidSubClassCase(): void #[DiscriminatorColumn(name: 'discr', length: 32, type: 'string')] abstract class Shape { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index cada4e039c4..e8b74316ac7 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -937,9 +937,7 @@ public function testInlineEmbeddable(): void #[MappedSuperclass] class DDC2700MappedSuperClass { - /** - * @var mixed - */ + /** @var mixed */ #[Column] private $foo; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 302bbff8244..e8cafbd9729 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -1162,23 +1162,17 @@ public static function loadMetadata(ClassMetadata $metadata): void #[Entity] class UserIncorrectIndex { - /** - * @var int - **/ + /** @var int **/ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $name; - /** - * @var string - */ + /** @var string */ #[Column(name: 'user_email')] public $email; @@ -1218,23 +1212,17 @@ public static function loadMetadata(ClassMetadata $metadata): void #[Entity] class UserIncorrectUniqueConstraint { - /** - * @var int - **/ + /** @var int **/ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $name; - /** - * @var string - */ + /** @var string */ #[Column(name: 'user_email')] public $email; diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 717e881e161..3ce84c59f24 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -2197,9 +2197,7 @@ public function parse(Parser $parser): void #[Entity] class DDC1384Model { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -2210,9 +2208,7 @@ class DDC1384Model #[Entity] class DDC1474Entity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php index d0642dfb934..d5063ea32cd 100644 --- a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php @@ -115,9 +115,7 @@ public function testDuplicateEntityListenerException(): void #[Entity] class AttachEntityListenersListenerTestFooEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] @@ -128,9 +126,7 @@ class AttachEntityListenersListenerTestFooEntity #[EntityListeners(['AttachEntityListenersListenerTestListener'])] class AttachEntityListenersListenerTestBarEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'AUTO')] diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php index 9d9e26aac20..af20d0090b5 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php @@ -14,17 +14,13 @@ #[Entity] final class Keyboard { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue(strategy: 'NONE')] private $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] private $name; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php index 5da91b8c4f9..c01bde697e8 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php @@ -149,9 +149,7 @@ public function testFilterWithRegex(): void #[Entity] class MetadataFilterTestEntityAaa { - /** - * @var int - */ + /** @var int */ #[Id] #[Column] protected $id; @@ -160,9 +158,7 @@ class MetadataFilterTestEntityAaa #[Entity] class MetadataFilterTestEntityBbb { - /** - * @var int - */ + /** @var int */ #[Id] #[Column] protected $id; @@ -171,9 +167,7 @@ class MetadataFilterTestEntityBbb #[Entity] class MetadataFilterTestEntityCcc { - /** - * @var int - */ + /** @var int */ #[Id] #[Column] protected $id; @@ -182,9 +176,7 @@ class MetadataFilterTestEntityCcc #[Entity] class MetadataFilterTestEntityFoo { - /** - * @var int - */ + /** @var int */ #[Id] #[Column] protected $id; @@ -193,9 +185,7 @@ class MetadataFilterTestEntityFoo #[Entity] class MetadataFilterTestEntityBar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column] protected $id; @@ -204,9 +194,7 @@ class MetadataFilterTestEntityBar #[Entity] class MetadataFilterTestEntityFooBar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column] protected $id; diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php index d040200fbae..2532f5fe09c 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php @@ -4,13 +4,13 @@ namespace Doctrine\Tests\ORM\Tools\Pagination; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -35,29 +35,21 @@ protected function setUp(): void #[Entity] class MyBlogPost { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var Author - */ + /** @var Author */ #[ManyToOne(targetEntity: 'Author')] public $author; - /** - * @var Category - */ + /** @var Category */ #[ManyToOne(targetEntity: 'Category')] public $category; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $title; } @@ -65,9 +57,7 @@ class MyBlogPost #[Entity] class MyAuthor { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -77,9 +67,7 @@ class MyAuthor #[Entity] class MyCategory { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -90,23 +78,17 @@ class MyCategory #[Entity] class BlogPost { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var Author - */ + /** @var Author */ #[ManyToOne(targetEntity: 'Author')] public $author; - /** - * @var Category - */ + /** @var Category */ #[ManyToOne(targetEntity: 'Category')] public $category; } @@ -114,17 +96,13 @@ class BlogPost #[Entity] class Author { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; } @@ -132,23 +110,17 @@ class Author #[Entity] class Person { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $biography; } @@ -156,9 +128,7 @@ class Person #[Entity] class Category { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] @@ -170,17 +140,13 @@ class Category #[Entity] class Group { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'User', mappedBy: 'groups')] public $users; } @@ -188,26 +154,20 @@ class Group #[Entity] class User { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[JoinTable(name: 'user_group')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] #[ManyToMany(targetEntity: 'Group', inversedBy: 'users')] public $groups; - /** - * @var Avatar - */ + /** @var Avatar */ #[OneToOne(targetEntity: 'Avatar', mappedBy: 'user')] public $avatar; } @@ -215,42 +175,30 @@ class User #[Entity] class Avatar { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] #[GeneratedValue] public $id; - /** - * @var User - */ + /** @var User */ #[OneToOne(targetEntity: 'User', inversedBy: 'avatar')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $image; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $imageHeight; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $imageWidth; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $imageAltDesc; } @@ -272,9 +220,7 @@ public function getId(): int #[Entity] class Banner extends Identified { - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] public $name; } diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index 9af862a92a1..67b9da9d6d6 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -127,18 +127,14 @@ class ResolveTargetEntity implements ResolveTarget #[GeneratedValue(strategy: 'AUTO')] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[ManyToMany(targetEntity: 'Doctrine\Tests\ORM\Tools\Target')] private $manyToMany; #[ManyToOne(targetEntity: 'Doctrine\Tests\ORM\Tools\ResolveTarget', inversedBy: 'oneToMany')] private ResolveTarget $manyToOne; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'Doctrine\Tests\ORM\Tools\ResolveTarget', mappedBy: 'manyToOne')] private $oneToMany; diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index 5473e5bcdb2..d5b7eaefe54 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -420,23 +420,17 @@ class UniqueConstraintAnnotationModel #[Entity] class FirstEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'id')] public $id; - /** - * @var SecondEntity - */ + /** @var SecondEntity */ #[OneToOne(targetEntity: 'SecondEntity')] #[JoinColumn(name: 'id', referencedColumnName: 'first_entity_id')] public $secondEntity; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name')] public $name; } @@ -445,16 +439,12 @@ class FirstEntity #[Entity] class SecondEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(name: 'first_entity_id')] public $firstEntityId; - /** - * @var string - */ + /** @var string */ #[Column(name: 'name')] public $name; } @@ -462,16 +452,12 @@ class SecondEntity #[Entity] class GH6830Board { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var GH6830Category - */ + /** @var GH6830Category */ #[ManyToOne(targetEntity: GH6830Category::class, inversedBy: 'boards')] #[JoinColumn(name: 'category_id', referencedColumnName: 'id')] public $category; @@ -480,16 +466,12 @@ class GH6830Board #[Entity] class GH6830Category { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 8, options: ['fixed' => true, 'collation' => 'latin1_bin', 'foo' => 'bar'])] public $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: GH6830Board::class, mappedBy: 'category')] public $boards; } @@ -500,28 +482,20 @@ class GH6830Category #[Entity] class IndexByFieldEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var string - */ + /** @var string */ #[Column] public $index; - /** - * @var string - */ + /** @var string */ #[Column] public $table; - /** - * @var string - */ + /** @var string */ #[Column] public $fieldName; } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index a5aadd4b665..b4a3d8b8912 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Tools; -use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; @@ -15,6 +14,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; +use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -232,9 +232,7 @@ abstract class MappedSuperclassEntity extends ParentEntity #[DiscriminatorMap(['child' => ChildEntity::class])] abstract class ParentEntity { - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] protected $key; @@ -248,23 +246,17 @@ class ChildEntity extends MappedSuperclassEntity #[Entity] class InvalidEntity1 { - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] protected $key1; - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] protected $key2; - /** - * @var ArrayCollection - */ + /** @var ArrayCollection */ #[JoinTable(name: 'Entity1Entity2')] #[JoinColumn(name: 'key1', referencedColumnName: 'key1')] #[InverseJoinColumn(name: 'key3', referencedColumnName: 'key3')] @@ -275,23 +267,17 @@ class InvalidEntity1 #[Entity] class InvalidEntity2 { - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] protected $key3; - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] protected $key4; - /** - * @var InvalidEntity1 - */ + /** @var InvalidEntity1 */ #[ManyToOne(targetEntity: 'InvalidEntity1')] protected $assoc; } @@ -308,9 +294,7 @@ class DDC1587ValidEntity1 #[Column(name: 'name', type: 'string', length: 32)] private string $name; - /** - * @var Identifier - */ + /** @var Identifier */ #[OneToOne(targetEntity: 'DDC1587ValidEntity2', cascade: ['all'], mappedBy: 'agent')] #[JoinColumn(name: 'pk', referencedColumnName: 'pk_agent')] private $identifier; @@ -332,9 +316,7 @@ class DDC1587ValidEntity2 #[Entity] class DDC1649One { - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] #[GeneratedValue] @@ -344,9 +326,7 @@ class DDC1649One #[Entity] class DDC1649Two { - /** - * @var DDC1649One - */ + /** @var DDC1649One */ #[Id] #[ManyToOne(targetEntity: 'DDC1649One')] public $one; @@ -364,9 +344,7 @@ class DDC1649Three #[Entity] class DDC3274One { - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] #[GeneratedValue] @@ -387,9 +365,7 @@ class DDC3274Two #[Entity] class Issue9536Target { - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] #[GeneratedValue] @@ -402,9 +378,7 @@ class Issue9536Target #[Entity] class Issue9536Owner { - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] #[GeneratedValue] @@ -417,9 +391,7 @@ class Issue9536Owner #[Entity] class DDC3322ValidEntity1 { - /** - * @var mixed - */ + /** @var mixed */ #[Id] #[Column] #[GeneratedValue] @@ -485,16 +457,12 @@ class DDC3322One #[GeneratedValue] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'oneValid')] #[OrderBy(['id' => 'ASC'])] private $validAssoc; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'oneInvalid')] #[OrderBy(['invalidField' => 'ASC'])] private $invalidAssoc; @@ -508,16 +476,12 @@ class DDC3322Two #[GeneratedValue] private int $id; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'twoValid')] #[OrderBy(['manyToOne' => 'ASC'])] private $validAssoc; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'twoInvalid')] #[OrderBy(['oneToMany' => 'ASC'])] private $invalidAssoc; @@ -535,9 +499,7 @@ class DDC3322Three #[OrderBy(['oneToOneOwning' => 'ASC'])] private DDC3322ValidEntity1 $validAssoc; - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'DDC3322ValidEntity1', mappedBy: 'threeInvalid')] #[OrderBy(['oneToOneInverse' => 'ASC'])] private $invalidAssoc; diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index bd98dc62106..152648f50e6 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -639,16 +639,12 @@ class NotifyChangedEntity implements NotifyPropertyChanged #[GeneratedValue] private int $id; - /** - * @var string - */ + /** @var string */ #[Column(type: 'string', length: 255)] private $data; private mixed $transient = null; // not persisted - /** - * @psalm-var Collection - */ + /** @psalm-var Collection */ #[OneToMany(targetEntity: 'NotifyChangedRelatedItem', mappedBy: 'owner')] private $items; @@ -733,16 +729,12 @@ public function setOwner(NotifyChangedEntity|null $owner): void #[Entity] class VersionedAssignedIdentifierEntity { - /** - * @var int - */ + /** @var int */ #[Id] #[Column(type: 'integer')] public $id; - /** - * @var int - */ + /** @var int */ #[Version] #[Column(type: 'integer')] public $version; @@ -751,9 +743,7 @@ class VersionedAssignedIdentifierEntity #[Entity] class EntityWithStringIdentifier { - /** - * @var string|null - */ + /** @var string|null */ #[Id] #[Column(type: 'string', length: 255)] public $id; @@ -762,9 +752,7 @@ class EntityWithStringIdentifier #[Entity] class EntityWithBooleanIdentifier { - /** - * @var bool|null - */ + /** @var bool|null */ #[Id] #[Column(type: 'boolean')] public $id; @@ -773,16 +761,12 @@ class EntityWithBooleanIdentifier #[Entity] class EntityWithCompositeStringIdentifier { - /** - * @var string|null - */ + /** @var string|null */ #[Id] #[Column(type: 'string', length: 255)] public $id1; - /** - * @var string|null - */ + /** @var string|null */ #[Id] #[Column(type: 'string', length: 255)] public $id2; @@ -791,16 +775,12 @@ class EntityWithCompositeStringIdentifier #[Entity] class EntityWithRandomlyGeneratedField { - /** - * @var string - */ + /** @var string */ #[Id] #[Column(type: 'string', length: 255)] public $id; - /** - * @var int - */ + /** @var int */ #[Column(type: 'integer')] public $generatedField; @@ -833,9 +813,7 @@ class EntityWithCascadingAssociation #[GeneratedValue(strategy: 'NONE')] private string $id; - /** - * @var CascadePersistedEntity|null - */ + /** @var CascadePersistedEntity|null */ #[ManyToOne(targetEntity: CascadePersistedEntity::class, cascade: ['persist'])] public $cascaded; @@ -853,9 +831,7 @@ class EntityWithNonCascadingAssociation #[GeneratedValue(strategy: 'NONE')] private string $id; - /** - * @var CascadePersistedEntity|null - */ + /** @var CascadePersistedEntity|null */ #[ManyToOne(targetEntity: CascadePersistedEntity::class)] public $nonCascaded; From ae6524bb2fb861f10eb20b88a84882462ba1698a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 25 Oct 2022 23:51:42 +0200 Subject: [PATCH 181/475] Bump DBAL to 3.5 and remove BC hacks (#10173) --- composer.json | 2 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 35 ++++--------------- phpcs.xml.dist | 5 --- phpstan-dbal4.neon | 4 --- psalm-baseline.xml | 3 +- psalm.xml | 31 +--------------- .../Tests/DbalTypes/CustomIdObjectType.php | 8 +---- tests/Doctrine/Tests/DbalTypes/Rot13Type.php | 17 +-------- .../Doctrine/Tests/ORM/ConfigurationTest.php | 4 --- .../ORM/Functional/DetachedEntityTest.php | 4 --- .../Tests/ORM/Functional/GH5988Test.php | 7 +--- .../SchemaTool/CompanySchemaTest.php | 8 +---- .../ORM/Functional/SchemaTool/DDC214Test.php | 13 ++----- .../ORM/Functional/Ticket/DDC2012Test.php | 7 +--- .../ORM/Functional/Ticket/DDC2224Test.php | 7 +--- .../ORM/Functional/Ticket/GH5804Test.php | 8 +---- .../ORM/Functional/Ticket/GH6823Test.php | 11 +++--- .../ORM/Functional/Ticket/GH8061Test.php | 7 +--- .../Mapping/EntityListenerResolverTest.php | 1 - .../ORM/Mapping/MappingDriverTestCase.php | 2 -- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 6 ---- tests/Doctrine/Tests/TestUtil.php | 7 +--- 22 files changed, 24 insertions(+), 173 deletions(-) diff --git a/composer.json b/composer.json index 10f57235ca6..fe847bef856 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-ctype": "*", "doctrine/collections": "^2.0", "doctrine/common": "^3.3", - "doctrine/dbal": "^3.4", + "doctrine/dbal": "^3.5", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.2 || ^2", "doctrine/inflector": "^1.4 || ^2.0", diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index b4b8bb20ca4..747654ce609 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -340,8 +340,7 @@ public function getSchemaFromMetadata(array $classes): Schema $uniqIndex = new Index($indexName, $this->getIndexColumns($class, $indexData), true, false, [], $indexData['options'] ?? []); foreach ($table->getIndexes() as $tableIndexName => $tableIndex) { - $method = method_exists($tableIndex, 'isFulfilledBy') ? 'isFulfilledBy' : 'isFullfilledBy'; - if ($tableIndex->$method($uniqIndex)) { + if ($tableIndex->isFulfilledBy($uniqIndex)) { $table->dropIndex($tableIndexName); break; } @@ -502,9 +501,8 @@ private function gatherColumn( } if ($table->hasColumn($columnName)) { - $method = method_exists($table, 'modifyColumn') ? 'modifyColumn' : 'changeColumn'; // required in some inheritance scenarios - $table->$method($columnName, $options); + $table->modifyColumn($columnName, $options); } else { $table->addColumn($columnName, $columnType, $options); } @@ -838,12 +836,8 @@ public function dropDatabase(): void */ public function getDropDatabaseSQL(): array { - $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? - 'introspectSchema' : - 'createSchema'; - return $this->schemaManager - ->$method() + ->introspectSchema() ->toDropSql($this->platform); } @@ -858,7 +852,7 @@ public function getDropSchemaSQL(array $classes): array { $schema = $this->getSchemaFromMetadata($classes); - $deployedSchema = $this->introspectSchema(); + $deployedSchema = $this->schemaManager->introspectSchema(); foreach ($schema->getTables() as $table) { if (! $deployedSchema->hasTable($table->getName())) { @@ -949,10 +943,6 @@ public function getUpdateSchemaSql(array $classes, bool $saveMode = false): arra return $schemaDiff->toSaveSql($this->platform); } - if (! method_exists(AbstractPlatform::class, 'getAlterSchemaSQL')) { - return $schemaDiff->toSql($this->platform); - } - return $this->platform->getAlterSchemaSQL($schemaDiff); } @@ -967,12 +957,8 @@ private function createSchemaForComparison(Schema $toSchema): Schema $config = $connection->getConfiguration(); $previousFilter = $config->getSchemaAssetsFilter(); - $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? - 'introspectSchema' : - 'createSchema'; - if ($previousFilter === null) { - return $this->introspectSchema(); + return $this->schemaManager->introspectSchema(); } // whitelist assets we already know about in $toSchema, use the existing filter otherwise @@ -983,19 +969,10 @@ private function createSchemaForComparison(Schema $toSchema): Schema }); try { - return $this->introspectSchema(); + return $this->schemaManager->introspectSchema(); } finally { // restore schema assets filter $config->setSchemaAssetsFilter($previousFilter); } } - - private function introspectSchema(): Schema - { - $method = method_exists($this->schemaManager, 'introspectSchema') - ? 'introspectSchema' - : 'createSchema'; - - return $this->schemaManager->$method(); - } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index b8b73a1c739..52c7f95beed 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -132,11 +132,6 @@ tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php - - - tests/* - - */tests/* diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon index 23b7c9c432a..c8a65adb258 100644 --- a/phpstan-dbal4.neon +++ b/phpstan-dbal4.neon @@ -28,7 +28,3 @@ parameters: message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Schema\\\\SchemaDiff\\:\\:toSaveSql\\(\\)\\.$#" count: 1 path: lib/Doctrine/ORM/Tools/SchemaTool.php - - - message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Schema\\\\SchemaDiff\\:\\:toSql\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/SchemaTool.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9ef47050196..c81e4cea163 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -173,9 +173,8 @@ - + $className - $connection $entity diff --git a/psalm.xml b/psalm.xml index d3248503b2d..e75bc279f6e 100644 --- a/psalm.xml +++ b/psalm.xml @@ -30,10 +30,9 @@ - + - @@ -49,18 +48,6 @@ - - - - - - - - - - - - @@ -79,14 +66,6 @@ - - - - - - - - @@ -133,14 +112,6 @@ - - - - - - - - diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php b/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php index 2094f3e3367..83fd76499ab 100644 --- a/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php +++ b/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php @@ -7,8 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; -use function method_exists; - class CustomIdObjectType extends Type { public const NAME = 'CustomIdObject'; @@ -34,11 +32,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): CustomIdO */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - if (method_exists($platform, 'getStringTypeDeclarationSQL')) { - return $platform->getStringTypeDeclarationSQL($column); - } - - return $platform->getVarcharTypeDeclarationSQL($column); + return $platform->getStringTypeDeclarationSQL($column); } public function getName(): string diff --git a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php index 61a5477b622..d5eb65e017f 100644 --- a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php +++ b/tests/Doctrine/Tests/DbalTypes/Rot13Type.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; -use function method_exists; use function str_rot13; /** @@ -48,21 +47,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): string|nu */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - if (method_exists($platform, 'getStringTypeDeclarationSQL')) { - return $platform->getStringTypeDeclarationSQL($column); - } - - return $platform->getVarcharTypeDeclarationSQL($column); - } - - /** - * {@inheritdoc} - * - * @return int|null - */ - public function getDefaultLength(AbstractPlatform $platform) - { - return $platform->getVarcharDefaultLength(); + return $platform->getStringTypeDeclarationSQL($column); } public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index fcc4436de02..244e20e2bdd 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -4,9 +4,6 @@ namespace Doctrine\Tests\ORM; -use Doctrine\Common\Cache\ArrayCache; -use Doctrine\Common\Cache\Cache; -use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Configuration; @@ -17,7 +14,6 @@ use Doctrine\ORM\Mapping\NamingStrategy; use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\ORM\Proxy\ProxyFactory; -use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\DDC753\DDC753CustomRepository; diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index e9895675700..dc9ffc4e4de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -5,10 +5,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; -use Doctrine\ORM\OptimisticLockException; -use Doctrine\Persistence\Proxy; -use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; diff --git a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php index e0149e85105..28fa4542997 100644 --- a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php @@ -16,7 +16,6 @@ use Doctrine\Tests\DbalTypes\CustomIdObject; use Doctrine\Tests\OrmFunctionalTestCase; -use function method_exists; use function str_replace; /** @@ -79,11 +78,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform): CustomIdO */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - if (method_exists($platform, 'getStringTypeDeclarationSQL')) { - return $platform->getStringTypeDeclarationSQL($column); - } - - return $platform->getVarcharTypeDeclarationSQL($column); + return $platform->getStringTypeDeclarationSQL($column); } public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php index 4e23a596492..eaba7fa8ce0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php @@ -4,12 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; -use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Schema; use Doctrine\Tests\OrmFunctionalTestCase; -use function method_exists; - /** * Functional tests for the Class Table Inheritance mapping strategy. */ @@ -24,10 +21,7 @@ protected function setUp(): void /** @group DDC-966 */ public function testGeneratedSchema(): Schema { - $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? - 'introspectSchema' : - 'createSchema'; - $schema = $this->createSchemaManager()->$method(); + $schema = $this->createSchemaManager()->introspectSchema(); self::assertTrue($schema->hasTable('company_contracts')); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 60ef9714dc9..38914583487 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -4,16 +4,12 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; -use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SQLitePlatform; -use Doctrine\DBAL\Schema\AbstractSchemaManager; -use Doctrine\DBAL\Schema\Comparator; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; use function array_filter; use function implode; -use function method_exists; use function str_contains; use const PHP_EOL; @@ -69,17 +65,12 @@ public function assertCreatedSchemaNeedsNoUpdates(string ...$classes): void $sm = $this->createSchemaManager(); - $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? - 'introspectSchema' : - 'createSchema'; - $fromSchema = $sm->$method(); + $fromSchema = $sm->introspectSchema(); $toSchema = $this->getSchemaForModels(...$classes); $comparator = $sm->createComparator(); $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); - $sql = method_exists(AbstractPlatform::class, 'getAlterSchemaSQL') ? - $this->_em->getConnection()->getDatabasePlatform()->getAlterSchemaSQL($schemaDiff) : - $schemaDiff->toSql($this->_em->getConnection()->getDatabasePlatform()); + $sql = $this->_em->getConnection()->getDatabasePlatform()->getAlterSchemaSQL($schemaDiff); $sql = array_filter($sql, static fn ($sql) => ! str_contains($sql, 'DROP')); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index ddaf3e8524a..0bf50d57f16 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -19,7 +19,6 @@ use function explode; use function implode; use function is_array; -use function method_exists; use function sprintf; use function strtolower; @@ -129,11 +128,7 @@ class DDC2012TsVectorType extends Type */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - if (method_exists($platform, 'getStringTypeDeclarationSQL')) { - return $platform->getStringTypeDeclarationSQL($column); - } - - return $platform->getVarcharTypeDeclarationSQL($column); + return $platform->getStringTypeDeclarationSQL($column); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index a287d09faa1..e7986d6e87e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -14,7 +14,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; -use function method_exists; use function sprintf; /** @group DDC-2224 */ @@ -52,11 +51,7 @@ class DDC2224Type extends Type */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - if (method_exists($platform, 'getStringTypeDeclarationSQL')) { - return $platform->getStringTypeDeclarationSQL($column); - } - - return $platform->getVarcharTypeDeclarationSQL($column); + return $platform->getStringTypeDeclarationSQL($column); } public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index cb09b8c1038..1721bb7f329 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -16,8 +16,6 @@ use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; -use function method_exists; - /** @group GH-5804 */ final class GH5804Test extends OrmFunctionalTestCase { @@ -69,11 +67,7 @@ public function getName(): string */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - if (method_exists($platform, 'getStringTypeDeclarationSQL')) { - return $platform->getStringTypeDeclarationSQL($column); - } - - return $platform->getVarcharTypeDeclarationSQL($column); + return $platform->getStringTypeDeclarationSQL($column); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php index 8ab0284a02d..0147cfe927b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php @@ -16,8 +16,6 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; -use function method_exists; - class GH6823Test extends OrmFunctionalTestCase { public function testCharsetCollationWhenCreatingForeignRelations(): void @@ -33,28 +31,27 @@ public function testCharsetCollationWhenCreatingForeignRelations(): void ); $schemaManager = $this->createSchemaManager(); - $method = method_exists($schemaManager, 'introspectTable') ? 'introspectTable' : 'listTableDetails'; /* gh6823_user.group_id should use charset ascii and collation * ascii_general_ci, because that is what gh6823_group.id falls back to */ - $userGroupIdOptions = $schemaManager->$method('gh6823_user')->getColumn('group_id')->toArray(); + $userGroupIdOptions = $schemaManager->introspectTable('gh6823_user')->getColumn('group_id')->toArray(); self::assertSame('ascii', $userGroupIdOptions['charset']); self::assertSame('ascii_general_ci', $userGroupIdOptions['collation']); /* gh6823_user.status_id should use charset latin1 and collation * latin1_bin, because that is what gh6823_status.id uses */ - $userStatusIdOptions = $schemaManager->$method('gh6823_user')->getColumn('status_id')->toArray(); + $userStatusIdOptions = $schemaManager->introspectTable('gh6823_user')->getColumn('status_id')->toArray(); self::assertSame('latin1', $userStatusIdOptions['charset']); self::assertSame('latin1_bin', $userStatusIdOptions['collation']); /* gh6823_user_tags.user_id should use charset utf8mb4 and collation * utf8mb4_bin, because that is what gh6823_user.id falls back to */ - $userTagsUserIdOptions = $schemaManager->$method('gh6823_user_tags')->getColumn('user_id')->toArray(); + $userTagsUserIdOptions = $schemaManager->introspectTable('gh6823_user_tags')->getColumn('user_id')->toArray(); self::assertSame('utf8mb4', $userTagsUserIdOptions['charset']); self::assertSame('utf8mb4_bin', $userTagsUserIdOptions['collation']); /* gh6823_user_tags.tag_id should use charset latin1 and collation * latin1_bin, because that is what gh6823_tag.id falls back to */ - $userTagsTagIdOption = $schemaManager->$method('gh6823_user_tags')->getColumn('tag_id')->toArray(); + $userTagsTagIdOption = $schemaManager->introspectTable('gh6823_user_tags')->getColumn('tag_id')->toArray(); self::assertSame('latin1', $userTagsTagIdOption['charset']); self::assertSame('latin1_bin', $userTagsTagIdOption['collation']); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php index 914c0113a4e..fc24aaefb9c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmTestCase; -use function method_exists; use function sprintf; /** @group GH8061 */ @@ -55,11 +54,7 @@ final class GH8061Type extends Type { public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - if (method_exists($platform, 'getStringTypeDeclarationSQL')) { - return $platform->getStringTypeDeclarationSQL($column); - } - - return $platform->getVarcharTypeDeclarationSQL($column); + return $platform->getStringTypeDeclarationSQL($column); } public function getName(): string diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index 2d5195bf44e..a8dbafe750c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -8,7 +8,6 @@ use Doctrine\Tests\Models\Company\CompanyContractListener; use Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener; use Doctrine\Tests\OrmTestCase; -use InvalidArgumentException; /** @group DDC-1955 */ class EntityListenerResolverTest extends OrmTestCase diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 74f658dccd3..4f3fd07ee8f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -41,14 +41,12 @@ use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddressListener; use Doctrine\Tests\Models\CMS\CmsEmail; -use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\Company\CompanyContract; use Doctrine\Tests\Models\Company\CompanyContractListener; use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; use Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener; -use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType; use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable; use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName; diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 340d366ef84..989dc9aded8 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -36,7 +36,6 @@ use PHPUnit\Framework\MockObject\MockObject; use stdClass; -use function method_exists; use function random_int; use function uniqid; @@ -72,11 +71,6 @@ protected function setUp(): void $driverStatement = $this->createMock(Statement::class); - if (method_exists($driverStatement, 'rowCount')) { - $driverStatement->method('rowCount') - ->willReturn(0); - } - $driverConnection = $this->createMock(Driver\Connection::class); $driverConnection->method('prepare') ->willReturn($driverStatement); diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index abb1249d1b0..a4275288fd1 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -10,14 +10,12 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException; use Doctrine\DBAL\Platforms\SQLitePlatform; -use Doctrine\DBAL\Schema\AbstractSchemaManager; use UnexpectedValueException; use function assert; use function explode; use function fwrite; use function get_debug_type; -use function method_exists; use function sprintf; use function str_starts_with; use function strlen; @@ -92,10 +90,7 @@ private static function initializeDatabase(): void $platform = $privConn->getDatabasePlatform(); if ($platform instanceof SQLitePlatform) { - $method = method_exists(AbstractSchemaManager::class, 'introspectSchema') ? - 'introspectSchema' : - 'createSchema'; - $schema = $testConn->createSchemaManager()->$method(); + $schema = $testConn->createSchemaManager()->introspectSchema(); $stmts = $schema->toDropSql($testConn->getDatabasePlatform()); foreach ($stmts as $stmt) { From 1f15e3b1988f6161c5d97ead97ae50989c404376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 26 Oct 2022 09:37:39 +0200 Subject: [PATCH 182/475] Purge annotations from the codebase and docs (#10177) --- UPGRADE.md | 5 + composer.json | 4 - docs/en/_exts/configurationblock.py | 1 - ...nting-the-notify-changetracking-policy.rst | 2 +- docs/en/cookbook/validation-of-entities.rst | 17 - docs/en/index.rst | 1 - docs/en/reference/advanced-configuration.rst | 11 +- docs/en/reference/annotations-reference.rst | 1164 ----------------- docs/en/reference/association-mapping.rst | 310 ----- docs/en/reference/attributes-reference.rst | 9 +- docs/en/reference/basic-mapping.rst | 78 +- docs/en/reference/caching.rst | 2 +- docs/en/reference/events.rst | 85 +- docs/en/reference/faq.rst | 2 +- docs/en/reference/inheritance-mapping.rst | 121 -- docs/en/reference/metadata-drivers.rst | 11 +- docs/en/reference/php-mapping.rst | 5 +- docs/en/reference/second-level-cache.rst | 62 - .../transactions-and-concurrency.rst | 22 - docs/en/reference/working-with-objects.rst | 2 +- docs/en/sidebar.rst | 1 - docs/en/toc.rst | 3 +- docs/en/tutorials/composite-primary-keys.rst | 53 - docs/en/tutorials/embeddables.rst | 49 - docs/en/tutorials/extra-lazy-associations.rst | 17 - docs/en/tutorials/getting-started.rst | 142 +- docs/en/tutorials/ordered-associations.rst | 16 - .../working-with-indexed-associations.rst | 109 -- lib/Doctrine/ORM/Mapping/MappingException.php | 7 - phpcs.xml.dist | 6 - psalm.xml | 1 - .../Performance/EntityManagerFactory.php | 1 - .../Tests/Mocks/EntityManagerMock.php | 1 - .../Doctrine/Tests/Models/CMS/CmsAddress.php | 5 - tests/Doctrine/Tests/Models/Cache/City.php | 11 - tests/Doctrine/Tests/Models/Cache/Token.php | 1 - .../Tests/Models/Company/CompanyContract.php | 8 - .../Company/CompanyContractListener.php | 8 - .../Models/Company/CompanyFixContract.php | 1 - .../Models/Company/CompanyFlexContract.php | 1 - .../Company/CompanyFlexUltraContract.php | 2 - .../CompanyFlexUltraContractListener.php | 1 - .../Models/DDC117/DDC117ApproveChanges.php | 1 - .../Tests/Models/DDC117/DDC117Editor.php | 1 - .../DDC1476EntityWithDefaultFieldType.php | 4 - .../Models/DDC2825/ExplicitSchemaAndTable.php | 5 - .../DDC2825/SchemaAndTableInTableName.php | 5 - .../Models/DDC869/DDC869ChequePayment.php | 2 - .../Models/DDC869/DDC869CreditCardPayment.php | 2 - .../Tests/Models/DDC869/DDC869Payment.php | 4 - .../Tests/Models/DDC889/DDC889Entity.php | 1 - .../Tests/Models/DDC889/DDC889SuperClass.php | 2 - .../Models/Enums/TypedCardEnumCompositeId.php | 1 - .../Tests/Models/Enums/TypedCardEnumId.php | 1 - .../Models/GeoNames/Admin1AlternateName.php | 1 - tests/Doctrine/Tests/Models/GeoNames/City.php | 1 - .../Tests/Models/Navigation/NavPhotos.php | 1 - .../Tests/Models/TypedProperties/Contact.php | 1 - .../Models/TypedProperties/UserTyped.php | 9 - .../OwningManyToOneCompositeIdEntity.php | 1 - ...ngManyToOneCompositeIdForeignKeyEntity.php | 1 - .../OwningOneToOneCompositeIdEntity.php | 1 - ...ingOneToOneCompositeIdForeignKeyEntity.php | 1 - .../Doctrine/Tests/ORM/ConfigurationTest.php | 6 +- .../Functional/Locking/LockAgentWorker.php | 1 - .../OneToManyBidirectionalAssociationTest.php | 6 +- .../ORM/Functional/Ticket/DDC1163Test.php | 1 - .../ORM/Functional/Ticket/DDC1181Test.php | 1 - .../ORM/Functional/Ticket/DDC2825Test.php | 5 - .../ORM/Functional/Ticket/DDC3103Test.php | 2 +- .../ORM/Functional/Ticket/DDC353Test.php | 1 - .../ORM/Functional/Ticket/DDC440Test.php | 1 - .../ORM/Functional/Ticket/DDC881Test.php | 1 - .../ORM/Functional/Ticket/GH7737Test.php | 1 - .../Tests/ORM/Mapping/AttributeDriverTest.php | 5 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 8 +- .../ORM/Mapping/MappingDriverTestCase.php | 19 +- .../Mapping/StaticPHPMappingDriverTest.php | 4 +- tests/Doctrine/Tests/ORM/ORMSetupTest.php | 7 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 2 +- .../AttachEntityListenersListenerTest.php | 2 +- .../SchemaTool/AbstractCommandTest.php | 1 - .../ORM/Tools/Console/MetadataFilterTest.php | 2 +- .../Tools/ResolveTargetEntityListenerTest.php | 4 +- .../Tests/ORM/Tools/SchemaToolTest.php | 22 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 1 - tests/Doctrine/Tests/OrmTestCase.php | 6 +- 87 files changed, 60 insertions(+), 2453 deletions(-) delete mode 100644 docs/en/reference/annotations-reference.rst diff --git a/UPGRADE.md b/UPGRADE.md index d99225bee67..a6eb374068a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC Break: Removed AnnotationDriver + +The annotation driver and anything related to annotation has been removed. +Please migrate to another mapping driver. + ## BC BREAK: Removed `EntityManager::create()` The constructor of `EntityManager` is now public and must be used instead of the `create()` method. diff --git a/composer.json b/composer.json index fe847bef856..2f9e1d19b3a 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,6 @@ "symfony/console": "^4.4 || ^5.4 || ^6.0" }, "require-dev": { - "doctrine/annotations": "^1.13", "doctrine/coding-standard": "^10.0", "phpbench/phpbench": "^1.0", "phpstan/phpstan": "1.8.8", @@ -46,9 +45,6 @@ "symfony/cache": "^4.4 || ^5.4 || ^6.0", "vimeo/psalm": "4.29.0" }, - "conflict": { - "doctrine/annotations": "<1.13 || >= 2.0" - }, "suggest": { "ext-dom": "Provides support for XSD validation for XML mapping files", "symfony/cache": "Provides cache support for Setup Tool with doctrine/cache 2.0" diff --git a/docs/en/_exts/configurationblock.py b/docs/en/_exts/configurationblock.py index 1046bcf84e5..c1d413643b1 100644 --- a/docs/en/_exts/configurationblock.py +++ b/docs/en/_exts/configurationblock.py @@ -41,7 +41,6 @@ class ConfigurationBlock(Directive): 'php+html': 'PHP', 'html+php': 'PHP', 'ini': 'INI', - 'php-annotations': 'Annotations', } def run(self): diff --git a/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst b/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst index e56393c4609..a47be84762d 100644 --- a/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst +++ b/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst @@ -55,7 +55,7 @@ listeners: .. code-block:: php ` * **Drivers**: - :doc:`Docblock Annotations ` | :doc:`Attributes ` | :doc:`XML ` | :doc:`PHP ` diff --git a/docs/en/reference/advanced-configuration.rst b/docs/en/reference/advanced-configuration.rst index ea50160e1a3..ddb1d03743d 100644 --- a/docs/en/reference/advanced-configuration.rst +++ b/docs/en/reference/advanced-configuration.rst @@ -117,15 +117,12 @@ There are currently 4 available implementations: - ``Doctrine\ORM\Mapping\Driver\AttributeDriver`` - ``Doctrine\ORM\Mapping\Driver\XmlDriver`` - ``Doctrine\ORM\Mapping\Driver\DriverChain`` -- ``Doctrine\ORM\Mapping\Driver\AnnotationDriver`` (deprecated and will - be removed in ``doctrine/orm`` 3.0) - ``Doctrine\ORM\Mapping\Driver\YamlDriver`` (deprecated and will be removed in ``doctrine/orm`` 3.0) Throughout the most part of this manual the AttributeDriver is used in the examples. For information on the usage of the -AnnotationDriver or XmlDriver please refer to the dedicated -chapters ``Annotation Reference`` and ``XML Mapping``. +XmlDriver please refer to the dedicated chapter ``XML Mapping``. The attribute driver can be injected in the ``Doctrine\ORM\Configuration``: @@ -155,9 +152,9 @@ Metadata Cache (***RECOMMENDED***) Gets or sets the cache adapter to use for caching metadata information, that is, all the information you supply via attributes, -annotations or xml, so that they do not need to be parsed and -loaded from scratch on every single request which is a waste of -resources. The cache implementation must implement the PSR-6 +xml, so that they do not need to be parsed and loaded from scratch on +every single request which is a waste of resources. The cache +implementation must implement the PSR-6 ``Psr\Cache\CacheItemPoolInterface`` interface. Usage of a metadata cache is highly recommended. diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst deleted file mode 100644 index 6bd5f0e5076..00000000000 --- a/docs/en/reference/annotations-reference.rst +++ /dev/null @@ -1,1164 +0,0 @@ -Annotations Reference -===================== - -.. warning:: - The annotation driver is deprecated and will be removed in version - 3.0. It is strongly recommended to switch to one of the other - mapping drivers. - -.. note:: - - To be able to use annotations, you will have to install an extra - package called ``doctrine/annotations``. - -You've probably used docblock annotations in some form already, -most likely to provide documentation metadata for a tool like -``PHPDocumentor`` (@author, @link, ...). Docblock annotations are a -tool to embed metadata inside the documentation section which can -then be processed by some tool. Doctrine ORM generalizes the concept -of docblock annotations so that they can be used for any kind of -metadata and so that it is easy to define new docblock annotations. -In order to allow more involved annotation values and to reduce the -chances of clashes with other docblock annotations, the Doctrine ORM -docblock annotations feature an alternative syntax that is heavily -inspired by the Annotation syntax introduced in Java 5. - -The implementation of these enhanced docblock annotations is located in -the ``doctrine/annotations`` package, but in the -``Doctrine\Common\Annotations`` namespace for backwards compatibility -reasons. Note that ``doctrine/annotations`` is not required by Doctrine -ORM, and you will need to require that package if you want to use -annotations. Doctrine ORM docblock annotations support namespaces and -nested annotations among other things. The Doctrine ORM defines its -own set of docblock annotations for supplying object-relational mapping -metadata. - -.. note:: - - If you're not comfortable with the concept of docblock - annotations, don't worry, as mentioned earlier Doctrine ORM provides - XML as alternative and you could easily implement your own - favourite mechanism for defining ORM metadata. - -In this chapter a reference of every Doctrine ORM Annotation is given -with short explanations on their context and usage. - -Index ------ - -- :ref:`@Column ` -- :ref:`@Cache ` -- :ref:`@ChangeTrackingPolicy ` -- :ref:`@CustomIdGenerator ` -- :ref:`@DiscriminatorColumn ` -- :ref:`@DiscriminatorMap ` -- :ref:`@Embeddable ` -- :ref:`@Embedded ` -- :ref:`@Entity ` -- :ref:`@GeneratedValue ` -- :ref:`@HasLifecycleCallbacks ` -- :ref:`@Index ` -- :ref:`@Id ` -- :ref:`@InheritanceType ` -- :ref:`@JoinColumn ` -- :ref:`@JoinColumns ` -- :ref:`@JoinTable ` -- :ref:`@ManyToOne ` -- :ref:`@ManyToMany ` -- :ref:`@MappedSuperclass ` -- :ref:`@OneToOne ` -- :ref:`@OneToMany ` -- :ref:`@OrderBy ` -- :ref:`@PostLoad ` -- :ref:`@PostPersist ` -- :ref:`@PostRemove ` -- :ref:`@PostUpdate ` -- :ref:`@PrePersist ` -- :ref:`@PreRemove ` -- :ref:`@PreUpdate ` -- :ref:`@SequenceGenerator ` -- :ref:`@Table ` -- :ref:`@UniqueConstraint ` -- :ref:`@Version ` - -Reference ---------- - -.. _annref_column: - -@Column -~~~~~~~ - -Marks an annotated instance variable as "persistent". It has to be -inside the instance variables PHP DocBlock comment. Any value hold -inside this variable will be saved to and loaded from the database -as part of the lifecycle of the instance variables entity-class. - -Required attributes: - -- **type**: Name of the Doctrine Type which is converted between PHP - and Database representation. Default to ``string`` or :ref:`Type from PHP property type ` - -Optional attributes: - -- **name**: By default the property name is used for the database - column name also, however the 'name' attribute allows you to - determine the column name. - -- **length**: Used by the "string" type to determine its maximum - length in the database. Doctrine does not validate the length of a - string value for you. - -- **precision**: The precision for a decimal (exact numeric) column - (applies only for decimal column), which is the maximum number of - digits that are stored for the values. - -- **scale**: The scale for a decimal (exact numeric) column (applies - only for decimal column), which represents the number of digits - to the right of the decimal point and must not be greater than - *precision*. - -- **unique**: Boolean value to determine if the value of the column - should be unique across all rows of the underlying entities table. - -- **nullable**: Determines if NULL values allowed for this column. If not specified, default value is false. - -- **insertable**: Boolean value to determine if the column should be - included when inserting a new row into the underlying entities table. - If not specified, default value is true. - -- **updatable**: Boolean value to determine if the column should be - included when updating the row of the underlying entities table. - If not specified, default value is true. - -- **generated**: An enum with the possible values ALWAYS, INSERT, NEVER. Is - used after an INSERT or UPDATE statement to determine if the database - generated this value and it needs to be fetched using a SELECT statement. - -- **options**: Array of additional options: - - - ``default``: The default value to set for the column if no value - is supplied. - - - ``unsigned``: Boolean value to determine if the column should - be capable of representing only non-negative integers - (applies only for integer column and might not be supported by - all vendors). - - - ``fixed``: Boolean value to determine if the specified length of - a string column should be fixed or varying (applies only for - string/binary column and might not be supported by all vendors). - - - ``comment``: The comment of the column in the schema (might not - be supported by all vendors). - - - ``collation``: The collation of the column (only supported by Drizzle, Mysql, PostgreSQL>=9.1, Sqlite and SQLServer). - - - ``check``: Adds a check constraint type to the column (might not - be supported by all vendors). - -- **columnDefinition**: DDL SQL snippet that starts after the column - name and specifies the complete (non-portable!) column definition. - This attribute allows to make use of advanced RMDBS features. - However you should make careful use of this feature and the - consequences. SchemaTool will not detect changes on the column correctly - anymore if you use "columnDefinition". - - Additionally you should remember that the "type" - attribute still handles the conversion between PHP and Database - values. If you use this attribute on a column that is used for - joins between tables you should also take a look at - :ref:`@JoinColumn `. - -.. note:: - - For more detailed information on each attribute, please refer to - the DBAL ``Schema-Representation`` documentation. - -Examples: - -.. code-block:: php - - ` -can be found in the configuration section. - -Example: - -.. code-block:: php - - ` and :ref:`@GeneratedValue(strategy="CUSTOM") ` are specified. - -Required attributes: - -- **class**: name of the class which should extend Doctrine\ORM\Id\AbstractIdGenerator - -Example: - -.. code-block:: php - - ` -annotation to establish the relationship between the two classes. - -.. code-block:: php - - `. This -annotation is optional and only has meaning when used in -conjunction with @Id. - -If this annotation is not specified with @Id the NONE strategy is -used as default. - -Optional attributes: - - -- **strategy**: Set the name of the identifier generation strategy. - Valid values are ``AUTO``, ``SEQUENCE``, ``IDENTITY``, ``CUSTOM`` and ``NONE``, explained - in the :ref:`Identifier Generation Strategies ` section. - If not specified, default value is AUTO. - -Example: - -.. code-block:: php - - ` annotation on -the entity-class level. It provides a hint to the SchemaTool to -generate a database index on the specified table columns. It only -has meaning in the SchemaTool schema generation context. - -Required attributes: - - -- **name**: Name of the Index -- **fields**: Array of fields. Exactly one of **fields**, **columns** is required. -- **columns**: Array of columns. Exactly one of **fields**, **columns** is required. - -Optional attributes: - -- **options**: Array of platform specific options: - - - ``where``: SQL WHERE condition to be used for partial indexes. It will - only have effect on supported platforms. - -Basic example: - -.. code-block:: php - - ` and -:ref:`@DiscriminatorColumn ` annotations. - -Examples: - -.. code-block:: php - - `, :ref:`@OneToOne ` fields -and in the Context of :ref:`@JoinTable ` nested inside -a @ManyToMany. If this annotation or both *name* and *referencedColumnName* -are missing they will be computed considering the field's name and the current -:doc:`naming strategy `. - -Optional attributes: - -- **name**: Column name that holds the foreign key identifier for - this relation. In the context of @JoinTable it specifies the column - name in the join table. -- **referencedColumnName**: Name of the primary key identifier that - is used for joining of this relation. Defaults to *id*. -- **unique**: Determines whether this relation is exclusive between the - affected entities and should be enforced as such on the database - constraint level. Defaults to false. -- **nullable**: Determine whether the related entity is required, or if - null is an allowed state for the relation. Defaults to true. -- **onDelete**: Cascade Action (Database-level) -- **columnDefinition**: DDL SQL snippet that starts after the column - name and specifies the complete (non-portable!) column definition. - This attribute enables the use of advanced RMDBS features. Using - this attribute on @JoinColumn is necessary if you need slightly - different column definitions for joining columns, for example - regarding NULL/NOT NULL defaults. However by default a - "columnDefinition" attribute on :ref:`@Column ` also sets - the related @JoinColumn's columnDefinition. This is necessary to - make foreign keys work. - -Example: - -.. code-block:: php - - ` or :ref:`@OneToOne ` -relation with an entity that has multiple identifiers. - -.. _annref_jointable: - -@JoinTable -~~~~~~~~~~~~~~ - -Using :ref:`@OneToMany ` or -:ref:`@ManyToMany ` on the owning side of the relation -requires to specify the @JoinTable annotation which describes the -details of the database join table. If you do not specify -@JoinTable on these relations reasonable mapping defaults apply -using the affected table and the column names. - -Optional attributes: - - -- **name**: Database name of the join-table -- **joinColumns**: An array of @JoinColumn annotations describing the - join-relation between the owning entities table and the join table. -- **inverseJoinColumns**: An array of @JoinColumn annotations - describing the join-relation between the inverse entities table and - the join table. - -Example: - -.. code-block:: php - - ` is an -additional, optional annotation that has reasonable default -configuration values using the table and names of the two related -entities. - -Required attributes: - - -- **targetEntity**: FQCN of the referenced target entity. Can be the - unqualified class name if both classes are in the same namespace. - *IMPORTANT:* No leading backslash! - -Optional attributes: - - -- **mappedBy**: This option specifies the property name on the - targetEntity that is the owning side of this relation. It is a - required attribute for the inverse side of a relationship. -- **inversedBy**: The inversedBy attribute designates the field in the - entity that is the inverse side of the relationship. -- **cascade**: Cascade Option -- **fetch**: One of LAZY, EXTRA_LAZY or EAGER -- **indexBy**: Index the collection by a field on the target entity. - -.. note:: - - For ManyToMany bidirectional relationships either side may - be the owning side (the side that defines the @JoinTable and/or - does not make use of the mappedBy attribute, thus using a default - join table). - -Example: - -.. code-block:: php - - `. - -Optional attributes: - - -- **repositoryClass**: Specifies the FQCN of a subclass of the EntityRepository. - That will be inherited for all subclasses of that Mapped Superclass. - -Example: - -.. code-block:: php - - ` with one additional option which can -be specified. The configuration defaults for -:ref:`@JoinColumn ` using the target entity table and -primary key column names apply here too. - -Required attributes: - - -- **targetEntity**: FQCN of the referenced target entity. Can be the - unqualified class name if both classes are in the same namespace. - When typed properties are used it is inherited from PHP type. - *IMPORTANT:* No leading backslash! - -Optional attributes: - - -- **cascade**: Cascade Option -- **fetch**: One of LAZY or EAGER -- **orphanRemoval**: Boolean that specifies if orphans, inverse - OneToOne entities that are not connected to any owning instance, - should be removed by Doctrine. Defaults to false. -- **inversedBy**: The inversedBy attribute designates the field in the - entity that is the inverse side of the relationship. - -Example: - -.. code-block:: php - - ` or :ref:`@OneToMany ` -annotation to specify by which criteria the collection should be -retrieved from the database by using an ORDER BY clause. - -This annotation requires a single non-attributed value with an DQL -snippet: - -Example: - -.. code-block:: php - - ` annotation on -the entity-class level. It allows to hint the SchemaTool to -generate a database unique constraint on the specified table -columns. It only has meaning in the SchemaTool schema generation -context. - -Required attributes: - - -- **name**: Name of the Index -- **fields**: Array of fields. Exactly one of **fields**, **columns** is required. -- **columns**: Array of columns. Exactly one of **fields**, **columns** is required. - -Optional attributes: - -- **options**: Array of platform specific options: - - - ``where``: SQL WHERE condition to be used for partial indexes. It will - only have effect on supported platforms. - -Basic example: - -.. code-block:: php - - ` -scenario. It only works on :ref:`@Column ` annotations that have -the type ``integer`` or ``datetime``. Combining ``@Version`` with -:ref:`@Id ` is not supported. - -Example: - -.. code-block:: php - - @@ -142,30 +121,6 @@ references one ``Shipment`` entity. // ... } - .. code-block:: annotation - - @@ -236,38 +191,6 @@ object. // ... } - .. code-block:: annotation - - @@ -389,41 +312,6 @@ bidirectional many-to-one. // ... } - .. code-block:: annotation - - - * @OneToMany(targetEntity="Feature", mappedBy="product") - */ - private Collection $features; - // ... - - public function __construct() { - $this->features = new ArrayCollection(); - } - } - - /** @Entity */ - class Feature - { - // ... - /** - * Many features have one product. This is the owning side. - * @ManyToOne(targetEntity="Product", inversedBy="features") - * @JoinColumn(name="product_id", referencedColumnName="id") - */ - private Product|null $product = null; - // ... - } - .. code-block:: xml @@ -499,39 +387,6 @@ The following example sets up such a unidirectional one-to-many association: // ... } - .. code-block:: annotation - - - */ - private Collection $phonenumbers; - - public function __construct() - { - $this->phonenumbers = new \Doctrine\Common\Collections\ArrayCollection(); - } - - // ... - } - - /** @Entity */ - class Phonenumber - { - // ... - } - .. code-block:: xml @@ -609,33 +464,6 @@ database perspective is known as an adjacency list approach. } } - .. code-block:: annotation - - - */ - private Collection $children; - - /** - * Many Categories have One Category. - * @ManyToOne(targetEntity="Category", inversedBy="children") - * @JoinColumn(name="parent_id", referencedColumnName="id") - */ - private Category|null $parent = null; - // ... - - public function __construct() { - $this->children = new \Doctrine\Common\Collections\ArrayCollection(); - } - } - .. code-block:: xml @@ -699,38 +527,6 @@ entities: // ... } - .. code-block:: annotation - - - */ - private Collection $groups; - - // ... - - public function __construct() { - $this->groups = new \Doctrine\Common\Collections\ArrayCollection(); - } - } - - /** @Entity */ - class Group - { - // ... - } - .. code-block:: xml @@ -826,47 +622,6 @@ one is bidirectional. // ... } - .. code-block:: annotation - - - */ - private Collection $groups; - - public function __construct() { - $this->groups = new \Doctrine\Common\Collections\ArrayCollection(); - } - - // ... - } - - /** @Entity */ - class Group - { - // ... - /** - * Many Groups have Many Users. - * @ManyToMany(targetEntity="User", mappedBy="groups") - * @var Collection - */ - private Collection $users; - - public function __construct() { - $this->users = new \Doctrine\Common\Collections\ArrayCollection(); - } - - // ... - } - .. code-block:: xml @@ -1026,12 +781,6 @@ As an example, consider this mapping: #[OneToOne(targetEntity: Shipment::class)] private Shipment|null $shipment = null; - .. code-block:: annotation - - @@ -1053,16 +802,6 @@ mapping: #[JoinColumn(name: 'shipment_id', referencedColumnName: 'id')] private Shipment|null $shipment = null; - .. code-block:: annotation - - @@ -1090,20 +829,6 @@ similar defaults. As an example, consider this mapping: // ... } - .. code-block:: annotation - - - */ - private Collection $groups; - // ... - } - .. code-block:: xml @@ -1134,25 +859,6 @@ This is essentially the same as the following, more verbose, mapping: // ... } - .. code-block:: annotation - - - */ - private Collection $groups; - // ... - } - .. code-block:: xml @@ -1190,12 +896,6 @@ attribute on ``JoinColumn`` will be inherited from PHP type. So that: #[OneToOne] private Shipment $shipment; - .. code-block:: annotation - - @@ -1208,16 +908,6 @@ Is essentially the same as following: .. configuration-block:: - .. code-block:: annotation - - ` - :doc:`XML ` - :doc:`PHP code ` -- :doc:`Docblock Annotations ` (deprecated and - will be removed in ``doctrine/orm`` 3.0) - :doc:`YAML ` (deprecated and will be removed in ``doctrine/orm`` 3.0.) This manual will usually show mapping metadata via attributes, though -many examples also show the equivalent configuration in annotations, -YAML and XML. +many examples also show the equivalent configuration in YAML and XML. .. note:: All metadata drivers perform equally. Once the metadata of a class has been - read from the source (attributes, annotations, XML, etc.) it is stored in an instance + read from the source (attributes, XML, etc.) it is stored in an instance of the ``Doctrine\ORM\Mapping\ClassMetadata`` class which are stored in the metadata cache. If you're not using a metadata cache (not recommended!) then the XML driver is the fastest. @@ -78,17 +75,6 @@ Marking our ``Message`` class as an entity for Doctrine is straightforward: // ... } - .. code-block:: annotation - - @@ -116,21 +102,6 @@ You can change this by configuring information about the table: // ... } - .. code-block:: annotation - - @@ -170,23 +141,6 @@ specified, ``string`` is used as the default. private $postedAt; } - .. code-block:: annotation - - @@ -352,20 +306,6 @@ the field that serves as the identifier with the ``#[Id]`` attribute. // ... } - .. code-block:: annotation - - @@ -436,20 +376,6 @@ besides specifying the sequence's name: // ... } - .. code-block:: annotation - - diff --git a/docs/en/reference/caching.rst b/docs/en/reference/caching.rst index 37ce9c00919..1b84fbc93e9 100644 --- a/docs/en/reference/caching.rst +++ b/docs/en/reference/caching.rst @@ -109,7 +109,7 @@ Metadata Cache ~~~~~~~~~~~~~~ Your class metadata can be parsed from a few different sources like -XML, Attributes, Annotations etc. Instead of parsing this +XML, Attributes, etc. Instead of parsing this information on each request we should cache it using one of the cache drivers. diff --git a/docs/en/reference/events.rst b/docs/en/reference/events.rst index 3d93b6cfe23..ae0de4d0fd1 100644 --- a/docs/en/reference/events.rst +++ b/docs/en/reference/events.rst @@ -243,40 +243,6 @@ specific to a particular entity class's lifecycle. $this->value = 'changed from preUpdate callback!'; } } - .. code-block:: annotation - - createdAt = date('Y-m-d H:i:s'); - } - - /** @PrePersist */ - public function doOtherStuffOnPrePersist() - { - $this->value = 'changed from prePersist callback!'; - } - - /** @PreUpdate */ - public function doStuffOnPreUpdate(PreUpdateEventArgs $eventArgs) - { - $this->value = 'changed from preUpdate callback!'; - } - } .. code-block:: xml @@ -756,16 +722,6 @@ An entity listener is a lifecycle listener class used for an entity. { // .... } - .. code-block:: annotation - - @@ -848,45 +804,6 @@ you need to map the listener method using the event type mapping: public function postLoadHandler(User $user, PostLoadEventArgs $event): void { // ... } } - .. code-block:: annotation - - @@ -989,7 +906,7 @@ Load ClassMetadata Event ``loadClassMetadata`` - The ``loadClassMetadata`` event occurs after the mapping metadata for a class has been loaded from a mapping source -(attributes/annotations/xml/yaml) in to a ``Doctrine\ORM\Mapping\ClassMetadata`` instance. +(attributes/xml/yaml) in to a ``Doctrine\ORM\Mapping\ClassMetadata`` instance. You can hook in to this process and manipulate the instance. This event is not a lifecycle callback. diff --git a/docs/en/reference/faq.rst b/docs/en/reference/faq.rst index 249761f400a..e9ea8401375 100644 --- a/docs/en/reference/faq.rst +++ b/docs/en/reference/faq.rst @@ -13,7 +13,7 @@ Database Schema How do I set the charset and collation for MySQL tables? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can't set these values with attributes, annotations or inside yml or +You can't set these values with attributes or inside yml or xml mapping files. To make a database work with the default charset and collation you should configure MySQL to use it as default charset, or create the database with charset and collation details. This way they diff --git a/docs/en/reference/inheritance-mapping.rst b/docs/en/reference/inheritance-mapping.rst index 4d5b1c0e173..7c4567f8627 100644 --- a/docs/en/reference/inheritance-mapping.rst +++ b/docs/en/reference/inheritance-mapping.rst @@ -117,30 +117,6 @@ Example: // ... } - .. code-block:: annotation - - - */ - protected Collection $groups; - - /** - * @ManyToOne(targetEntity="Address") - * @JoinColumn(name="address_id", referencedColumnName="id") - */ - protected Address|null $address = null; - } - - // admin mapping - namespace MyProject\Model; - /** - * @Entity - * @AssociationOverrides({ - * @AssociationOverride(name="groups", - * joinTable=@JoinTable( - * name="users_admingroups", - * joinColumns=@JoinColumn(name="adminuser_id"), - * inverseJoinColumns=@JoinColumn(name="admingroup_id") - * ) - * ), - * @AssociationOverride(name="address", - * joinColumns=@JoinColumn( - * name="adminaddress_id", referencedColumnName="id" - * ) - * ) - * }) - */ - class Admin extends User - { - } - .. code-block:: xml @@ -537,51 +461,6 @@ Could be used by an entity that extends a mapped superclass to override a field { } - .. code-block:: annotation - - diff --git a/docs/en/reference/metadata-drivers.rst b/docs/en/reference/metadata-drivers.rst index 8d77bffca0d..45e7ca7aeba 100644 --- a/docs/en/reference/metadata-drivers.rst +++ b/docs/en/reference/metadata-drivers.rst @@ -16,11 +16,6 @@ metadata: - **Attributes** (AttributeDriver) - **PHP Code in files or static functions** (PhpDriver) -There are also two deprecated ways to do this: - -- **Class DocBlock Annotations** (AnnotationDriver) -- **YAML files** (YamlDriver) - They will be removed in 3.0, make sure to avoid them. Something important to note about the above drivers is they are all @@ -44,11 +39,7 @@ an entity. $em->getConfiguration()->setMetadataCacheImpl(new ApcuCache()); -If you want to use one of the included core metadata drivers you need to -configure it. If you pick the annotation driver despite it being -deprecated, you will additionally need to install -``doctrine/annotations``. All the drivers are in the -``Doctrine\ORM\Mapping\Driver`` namespace: +All the drivers are in the ``Doctrine\ORM\Mapping\Driver`` namespace: .. code-block:: php diff --git a/docs/en/reference/php-mapping.rst b/docs/en/reference/php-mapping.rst index d6718af864b..6ab068135fe 100644 --- a/docs/en/reference/php-mapping.rst +++ b/docs/en/reference/php-mapping.rst @@ -13,9 +13,8 @@ programatically specify your mapping information inside of a static function defined on the entity class itself. This is useful for cases where you want to keep your entity and mapping -information together but don't want to use attributes or -annotations. For this you just need -to use the ``StaticPHPDriver``: +information together but don't want to use attributes. For this you just +need to use the ``StaticPHPDriver``: .. code-block:: php diff --git a/docs/en/reference/second-level-cache.rst b/docs/en/reference/second-level-cache.rst index e4e576f39a6..0d470c8896e 100644 --- a/docs/en/reference/second-level-cache.rst +++ b/docs/en/reference/second-level-cache.rst @@ -295,30 +295,6 @@ level cache region. // other properties and methods } - .. code-block:: annotation - - @@ -368,44 +344,6 @@ It caches the primary keys of association and cache each element will be cached // other properties and methods } - .. code-block:: annotation - - - */ - protected Collection $cities; - - // other properties and methods - } - .. code-block:: xml diff --git a/docs/en/reference/transactions-and-concurrency.rst b/docs/en/reference/transactions-and-concurrency.rst index 0f17cf230c4..5dcf71a0c81 100644 --- a/docs/en/reference/transactions-and-concurrency.rst +++ b/docs/en/reference/transactions-and-concurrency.rst @@ -200,17 +200,6 @@ example we'll use an integer. // ... } - .. code-block:: annotation - - @@ -235,17 +224,6 @@ timestamp or datetime): // ... } - .. code-block:: annotation - - diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index 573f62cd500..f592810d789 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -834,7 +834,7 @@ By default the EntityManager returns a default implementation of ``Doctrine\ORM\EntityRepository`` when you call ``EntityManager#getRepository($entityClass)``. You can overwrite this behaviour by specifying the class name of your own Entity -Repository in the Attribute, Annotation or XML metadata. In large +Repository in the Attribute or XML metadata. In large applications that require lots of specialized DQL queries using a custom repository is one recommended way of grouping these queries in a central location. diff --git a/docs/en/sidebar.rst b/docs/en/sidebar.rst index b2f8d219c79..6859d999ba2 100644 --- a/docs/en/sidebar.rst +++ b/docs/en/sidebar.rst @@ -41,7 +41,6 @@ reference/native-sql reference/change-tracking-policies reference/partial-objects - reference/annotations-reference reference/attributes-reference reference/xml-mapping reference/php-mapping diff --git a/docs/en/toc.rst b/docs/en/toc.rst index ccacd8d40fe..4bad21f66d8 100644 --- a/docs/en/toc.rst +++ b/docs/en/toc.rst @@ -43,7 +43,6 @@ Reference Guide reference/native-sql reference/change-tracking-policies reference/partial-objects - reference/annotations-reference reference/attributes-reference reference/xml-mapping reference/php-mapping @@ -59,7 +58,7 @@ Reference Guide reference/advanced-configuration reference/second-level-cache reference/security - + Cookbook -------- diff --git a/docs/en/tutorials/composite-primary-keys.rst b/docs/en/tutorials/composite-primary-keys.rst index ead3bab07d6..d64fc99e120 100644 --- a/docs/en/tutorials/composite-primary-keys.rst +++ b/docs/en/tutorials/composite-primary-keys.rst @@ -50,59 +50,6 @@ and year of production as primary keys: } } - .. code-block:: annotation - - name = $name; - $this->year = $year; - } - - public function getModelName(): string - { - return $this->name; - } - - public function getYearOfProduction(): int - { - return $this->year; - } - } - - .. code-block:: annotation - - diff --git a/docs/en/tutorials/embeddables.rst b/docs/en/tutorials/embeddables.rst index 734b1a3399c..d0a8d517657 100644 --- a/docs/en/tutorials/embeddables.rst +++ b/docs/en/tutorials/embeddables.rst @@ -44,33 +44,6 @@ instead of simply adding the respective columns to the ``User`` class. private string $country; } - .. code-block:: annotation - - @@ -131,17 +104,6 @@ The following example shows you how to set your prefix to ``myPrefix_``: private Address $address; } - .. code-block:: annotation - - @@ -164,17 +126,6 @@ directly, set ``columnPrefix=false`` (``use-column-prefix="false"`` for XML): private Address $address; } - .. code-block:: annotation - - diff --git a/docs/en/tutorials/extra-lazy-associations.rst b/docs/en/tutorials/extra-lazy-associations.rst index 94bc93fe8d7..2ae2d788816 100644 --- a/docs/en/tutorials/extra-lazy-associations.rst +++ b/docs/en/tutorials/extra-lazy-associations.rst @@ -65,23 +65,6 @@ switch to extra lazy as shown in these examples: public Collection $users; } - .. code-block:: annotation - - - */ - public Collection $users; - } - .. code-block:: xml diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index 9067fd1f480..87ffb15303b 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -142,11 +142,7 @@ step: paths: array(__DIR__."/src"), isDevMode: true, ); - // or if you prefer annotation, YAML or XML - // $config = ORMSetup::createAnnotationMetadataConfiguration( - // paths: array(__DIR__."/src"), - // isDevMode: true, - // ); + // or if you prefer XML // $config = ORMSetup::createXMLMetadataConfiguration( // paths: array(__DIR__."/config/xml"), // isDevMode: true, @@ -514,33 +510,6 @@ methods, but you only need to choose one. // .. (other code) } - .. code-block:: annotation - - @@ -1062,59 +1031,6 @@ the ``Product`` before: // ... (other code) } - .. code-block:: annotation - - @@ -1195,47 +1111,6 @@ Finally, we'll add metadata mappings for the ``User`` entity. // .. (other code) } - .. code-block:: annotation - - An ArrayCollection of Bug objects. - */ - private Collection $reportedBugs; - - /** - * @ORM\OneToMany(targetEntity="Bug", mappedBy="engineer") - * @var Collection An ArrayCollection of Bug objects. - */ - private Collection $assignedBugs; - - // .. (other code) - } .. code-block:: xml @@ -1752,21 +1627,6 @@ we have to adjust the metadata slightly. // ... } - .. code-block:: annotation - - - */ - private Collection $groups; - } - .. code-block:: xml diff --git a/docs/en/tutorials/working-with-indexed-associations.rst b/docs/en/tutorials/working-with-indexed-associations.rst index 46ecdbab136..8dad1f66adb 100644 --- a/docs/en/tutorials/working-with-indexed-associations.rst +++ b/docs/en/tutorials/working-with-indexed-associations.rst @@ -89,74 +89,6 @@ The code and mappings for the Market entity looks like this: } } - .. 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 @@ -215,47 +147,6 @@ here are the code and mappings for it: } } - .. code-block:: annotation - - symbol = $symbol; - $this->market = $market; - $market->addStock($this); - } - - public function getSymbol(): string - { - return $this->symbol; - } - } - .. code-block:: xml diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 71a23e93711..f264ec4252a 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -26,13 +26,6 @@ */ class MappingException extends Exception implements ORMException { - /** @return MappingException */ - public static function pathRequired() - { - return new self('Specifying the paths to your entities is required ' . - 'in the AnnotationDriver to retrieve all class names.'); - } - /** * @param string $entityName * diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 52c7f95beed..2db1993e27b 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -179,10 +179,6 @@ tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php - - tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php - - tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php @@ -206,7 +202,6 @@ lib/Doctrine/ORM/Query.php lib/Doctrine/ORM/Query/TreeWalkerAdapter.php lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php - lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php @@ -226,7 +221,6 @@ lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php - lib/Doctrine/ORM/Tools/Export/Driver/AnnotationExporter.php lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php diff --git a/psalm.xml b/psalm.xml index e75bc279f6e..6f11cbb315d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -33,7 +33,6 @@ - diff --git a/tests/Doctrine/Performance/EntityManagerFactory.php b/tests/Doctrine/Performance/EntityManagerFactory.php index 716d69f2fe7..66a50f3a89f 100644 --- a/tests/Doctrine/Performance/EntityManagerFactory.php +++ b/tests/Doctrine/Performance/EntityManagerFactory.php @@ -15,7 +15,6 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Driver\AttributeDriver; -use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Tools\SchemaTool; diff --git a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php index 6a5b654efe0..6ebffcccb71 100644 --- a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping\Driver\AttributeDriver; -use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\UnitOfWork; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index 9c125f7bc14..80b7c63d4ec 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -8,13 +8,8 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\EntityListeners; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; -use Doctrine\ORM\Mapping\Table; #[ORM\Entity] #[ORM\Table(name: 'cms_addresses')] diff --git a/tests/Doctrine/Tests/Models/Cache/City.php b/tests/Doctrine/Tests/Models/Cache/City.php index e5805543582..0ac4a5d6d7d 100644 --- a/tests/Doctrine/Tests/Models/Cache/City.php +++ b/tests/Doctrine/Tests/Models/Cache/City.php @@ -7,18 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\Cache; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\ManyToMany; -use Doctrine\ORM\Mapping\ManyToOne; -use Doctrine\ORM\Mapping\OneToMany; -use Doctrine\ORM\Mapping\OrderBy; -use Doctrine\ORM\Mapping\Table; #[ORM\Entity, ORM\Table(name: 'cache_city'), ORM\Cache] class City diff --git a/tests/Doctrine/Tests/Models/Cache/Token.php b/tests/Doctrine/Tests/Models/Cache/Token.php index a0a5a749cc6..44de9a286f2 100644 --- a/tests/Doctrine/Tests/Models/Cache/Token.php +++ b/tests/Doctrine/Tests/Models/Cache/Token.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Doctrine/Tests/Models/Company/CompanyContract.php index 974fb8dfbe5..ef01a3bb5c9 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -10,19 +10,11 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\DiscriminatorColumn; -use Doctrine\ORM\Mapping\DiscriminatorMap; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\EntityListeners; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; -use Doctrine\ORM\Mapping\Table; #[ORM\Entity, ORM\Table(name: 'company_contracts')] #[ORM\InheritanceType('SINGLE_TABLE')] diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php b/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php index 26b21778a86..f3f433fc9b6 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php @@ -5,14 +5,6 @@ namespace Doctrine\Tests\Models\Company; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\PostLoad; -use Doctrine\ORM\Mapping\PostPersist; -use Doctrine\ORM\Mapping\PostRemove; -use Doctrine\ORM\Mapping\PostUpdate; -use Doctrine\ORM\Mapping\PreFlush; -use Doctrine\ORM\Mapping\PrePersist; -use Doctrine\ORM\Mapping\PreRemove; -use Doctrine\ORM\Mapping\PreUpdate; use function func_get_args; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php index 58532bbf32d..0e2793fe55c 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php @@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; #[ORM\Entity] class CompanyFixContract extends CompanyContract diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index aa3138a48de..6b6bfb182e4 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -8,7 +8,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InverseJoinColumn; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php index c468af13883..c6893929e15 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -8,8 +8,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\EntityListeners; use function max; diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php index 8b91649150b..e83b68e2a68 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php @@ -6,7 +6,6 @@ use Doctrine\ORM\Event\PrePersistEventArgs; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\PrePersist; use function func_get_args; diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php index 00c035516be..4f20de3d8b4 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; #[Entity] diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php index 347df297cb0..adf43398e99 100644 --- a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php +++ b/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InverseJoinColumn; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; diff --git a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php b/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php index c9a731a2c4b..584743bc1b0 100644 --- a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php +++ b/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php @@ -6,10 +6,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; #[ORM\Entity] class DDC1476EntityWithDefaultFieldType diff --git a/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php b/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php index 628fe130334..333fc9bfd95 100644 --- a/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php +++ b/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php @@ -5,11 +5,6 @@ namespace Doctrine\Tests\Models\DDC2825; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\Table; #[ORM\Entity, ORM\Table(name: 'explicit_table', schema: 'explicit_schema')] class ExplicitSchemaAndTable diff --git a/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php b/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php index 1e25f6960e1..e6c8ecb295a 100644 --- a/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php +++ b/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php @@ -5,11 +5,6 @@ namespace Doctrine\Tests\Models\DDC2825; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\Table; /** * Quoted column name to check that sequence names are diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php index 539eb134517..5497299ec9b 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php @@ -6,8 +6,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; #[ORM\Entity] class DDC869ChequePayment extends DDC869Payment diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php index c2b81eeb007..c6a3b21dabb 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php @@ -6,8 +6,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; #[ORM\Entity] class DDC869CreditCardPayment extends DDC869Payment diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php index e5bb907f9cd..c1b3c91b437 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php @@ -6,10 +6,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\MappedSuperclass; #[ORM\MappedSuperclass(repositoryClass: DDC869PaymentRepository::class)] class DDC869Payment diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php b/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php index 6e8f168a861..d24304489ea 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php @@ -6,7 +6,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Entity; #[ORM\Entity] class DDC889Entity extends DDC889SuperClass diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php b/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php index 6d42d9ff602..74e36ab275a 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php @@ -6,8 +6,6 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\MappedSuperclass; #[ORM\MappedSuperclass] class DDC889SuperClass diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php index a21ee66c88c..b9346fab9d3 100644 --- a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php +++ b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Models\Enums; -use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php index a9411df9c83..f25ca14ef57 100644 --- a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php +++ b/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\Models\Enums; -use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php index b02d041c7d8..aeefcdd4956 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php +++ b/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; diff --git a/tests/Doctrine/Tests/Models/GeoNames/City.php b/tests/Doctrine/Tests/Models/GeoNames/City.php index 2a6211b939d..1cf580471d5 100644 --- a/tests/Doctrine/Tests/Models/GeoNames/City.php +++ b/tests/Doctrine/Tests/Models/GeoNames/City.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php index 2618e71be0b..34203eb2e5e 100644 --- a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php +++ b/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; diff --git a/tests/Doctrine/Tests/Models/TypedProperties/Contact.php b/tests/Doctrine/Tests/Models/TypedProperties/Contact.php index 333a18386d7..0229cec95c9 100644 --- a/tests/Doctrine/Tests/Models/TypedProperties/Contact.php +++ b/tests/Doctrine/Tests/Models/TypedProperties/Contact.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\Models\TypedProperties; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\Column; #[ORM\Embeddable] class Contact diff --git a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php index f4b2178fa60..256cd14ccdb 100644 --- a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php +++ b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php @@ -9,15 +9,6 @@ use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Embedded; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\ManyToOne; -use Doctrine\ORM\Mapping\OneToOne; -use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\Models\CMS\CmsEmail; #[ORM\Entity, ORM\Table(name: 'cms_users_typed')] diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php index 9c83ca48950..89a5432ec14 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php @@ -8,7 +8,6 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php index be3168c81d9..bfa3a03974b 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php @@ -8,7 +8,6 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php index 90a4cb1091c..9ba6ab24ca0 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php @@ -8,7 +8,6 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php index fcff6cf6803..8050bb413c2 100644 --- a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php +++ b/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php @@ -8,7 +8,6 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\UniqueConstraint; diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 244e20e2bdd..67cc5aa70b5 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -9,7 +9,7 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Exception\InvalidEntityRepository; -use Doctrine\ORM\Mapping as AnnotationNamespace; +use Doctrine\ORM\Mapping as MappingNamespace; use Doctrine\ORM\Mapping\EntityListenerResolver; use Doctrine\ORM\Mapping\NamingStrategy; use Doctrine\ORM\Mapping\QuoteStrategy; @@ -146,7 +146,7 @@ public function testSetCustomHydrationModes(): void public function testSetGetClassMetadataFactoryName(): void { - self::assertSame(AnnotationNamespace\ClassMetadataFactory::class, $this->configuration->getClassMetadataFactoryName()); + self::assertSame(MappingNamespace\ClassMetadataFactory::class, $this->configuration->getClassMetadataFactoryName()); $this->configuration->setClassMetadataFactoryName(self::class); self::assertSame(self::class, $this->configuration->getClassMetadataFactoryName()); } @@ -188,7 +188,7 @@ public function testSetGetQuoteStrategy(): void public function testSetGetEntityListenerResolver(): void { self::assertInstanceOf(EntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); - self::assertInstanceOf(AnnotationNamespace\DefaultEntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); + self::assertInstanceOf(MappingNamespace\DefaultEntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); $resolver = $this->createMock(EntityListenerResolver::class); $this->configuration->setEntityListenerResolver($resolver); self::assertSame($resolver, $this->configuration->getEntityListenerResolver()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php index b95de6c2e33..77427af0814 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\ORMSetup; use Doctrine\Tests\ORM\Functional\Locking\Doctrine\ORM\Query; use GearmanWorker; use InvalidArgumentException; diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index c12c6b6f8f1..79691996805 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -31,7 +31,7 @@ protected function setUp(): void $this->firstFeature = new ECommerceFeature(); $this->firstFeature->setDescription('Model writing tutorial'); $this->secondFeature = new ECommerceFeature(); - $this->secondFeature->setDescription('Annotations examples'); + $this->secondFeature->setDescription('Attributes examples'); } public function testSavesAOneToManyAssociationWithCascadeSaveSet(): void @@ -91,7 +91,7 @@ public function testEagerLoadsOneToManyAssociation(): void self::assertInstanceOf(ECommerceFeature::class, $features[1]); self::assertSame($product, $features[1]->getProduct()); self::assertNotInstanceOf(Proxy::class, $features[1]->getProduct()); - self::assertEquals('Annotations examples', $features[1]->getDescription()); + self::assertEquals('Attributes examples', $features[1]->getDescription()); } public function testLazyLoadsObjectsOnTheOwningSide(): void @@ -110,7 +110,7 @@ public function testLazyLoadsObjectsOnTheOwningSide(): void self::assertEquals('Model writing tutorial', $features[0]->getDescription()); self::assertInstanceOf(ECommerceFeature::class, $features[1]); self::assertSame($product, $features[1]->getProduct()); - self::assertEquals('Annotations examples', $features[1]->getDescription()); + self::assertEquals('Attributes examples', $features[1]->getDescription()); } public function testLazyLoadsObjectsOnTheInverseSide(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index 38edc3ae4f4..a71fbab733b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Persistence\Proxy; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php index a30e7af7538..c0b83c44b92 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index 9ad70ad0130..61f91a82d07 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -5,11 +5,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\Entity; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable; use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName; use Doctrine\Tests\OrmFunctionalTestCase; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php index 877f9039de0..5672cd611f1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php @@ -20,7 +20,7 @@ public function testIssue(): void { $classMetadata = new ClassMetadata(DDC3103ArticleId::class); - $this->createAnnotationDriver()->loadMetadataForClass(DDC3103ArticleId::class, $classMetadata); + $this->createAttributeDriver()->loadMetadataForClass(DDC3103ArticleId::class, $classMetadata); self::assertTrue( $classMetadata->isEmbeddedClass, diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php index 466c549b8cf..f991531ecf5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php index c4e71b42493..c26c11b8565 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index 4d170583f41..8a4f0c67bb5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinColumns; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\PersistentCollection; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php index 51b2e5017e0..5cee250913e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php @@ -11,7 +11,6 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InverseJoinColumn; -use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 9360c5006cc..c91c125b819 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -6,7 +6,6 @@ use Attribute; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\Annotation; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use stdClass; @@ -75,11 +74,11 @@ class AttributeEntityStartingWithRepeatableAttributes } #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)] -class AttributeTransientAnnotation implements Annotation +class AttributeTransientAttribute { } -#[AttributeTransientAnnotation] +#[AttributeTransientAttribute] class AttributeTransientClass { } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 4726f70a869..aad1c5fe0b5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -181,7 +181,7 @@ public function testAddDefaultDiscriminatorMap(): void self::markTestSkipped('This test is just incorrect and must be fixed'); $cmf = new ClassMetadataFactory(); - $driver = $this->createAnnotationDriver([__DIR__ . '/../../Models/JoinedInheritanceType/']); + $driver = $this->createAttributeDriver([__DIR__ . '/../../Models/JoinedInheritanceType/']); $em = $this->createEntityManager($driver); $cmf->setEntityManager($em); @@ -296,7 +296,7 @@ protected function createValidClassMetadata(): ClassMetadata public function testQuoteMetadata(): void { $cmf = new ClassMetadataFactory(); - $driver = $this->createAnnotationDriver([__DIR__ . '/../../Models/Quote/']); + $driver = $this->createAttributeDriver([__DIR__ . '/../../Models/Quote/']); $em = $this->createEntityManager($driver); $cmf->setEntityManager($em); @@ -445,7 +445,7 @@ public function testRejectsEmbeddableWithoutValidClassName(): void public function testInheritsIdGeneratorMappingFromEmbeddable(): void { $cmf = new ClassMetadataFactory(); - $driver = $this->createAnnotationDriver([__DIR__ . '/../../Models/DDC4006/']); + $driver = $this->createAttributeDriver([__DIR__ . '/../../Models/DDC4006/']); $em = $this->createEntityManager($driver); $cmf->setEntityManager($em); @@ -460,7 +460,7 @@ public function testInvalidSubClassCase(): void $this->expectExceptionMessage('Entity class \'Doctrine\Tests\ORM\Mapping\cube\' used in the discriminator map of class \'Doctrine\Tests\ORM\Mapping\Shape\' does not exist.'); $cmf = new ClassMetadataFactory(); - $driver = $this->createAnnotationDriver([__DIR__]); + $driver = $this->createAttributeDriver([__DIR__]); $em = $this->createEntityManager($driver); $cmf->setEntityManager($em); diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index e32083013ae..0221378d9c9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -11,30 +11,15 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\Column; -use Doctrine\ORM\Mapping\CustomIdGenerator; use Doctrine\ORM\Mapping\DefaultNamingStrategy; -use Doctrine\ORM\Mapping\DiscriminatorColumn; -use Doctrine\ORM\Mapping\DiscriminatorMap; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\HasLifecycleCallbacks; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Index; -use Doctrine\ORM\Mapping\InheritanceType; -use Doctrine\ORM\Mapping\JoinColumn; -use Doctrine\ORM\Mapping\JoinTable; -use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\MappingException; -use Doctrine\ORM\Mapping\OneToMany; -use Doctrine\ORM\Mapping\OneToOne; -use Doctrine\ORM\Mapping\OrderBy; -use Doctrine\ORM\Mapping\PostPersist; -use Doctrine\ORM\Mapping\PrePersist; -use Doctrine\ORM\Mapping\SequenceGenerator; use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; use Doctrine\ORM\Mapping\UniqueConstraint; -use Doctrine\ORM\Mapping\Version; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Tests\Models\Cache\City; @@ -854,7 +839,7 @@ public function testSecondLevelCacheMapping(): void * @group DDC-2825 * @group 881 */ - public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): void + public function testSchemaDefinitionViaExplicitTableSchemaAttributeProperty(): void { $metadata = $this->createClassMetadataFactory()->getMetadataFor(ExplicitSchemaAndTable::class); assert($metadata instanceof ClassMetadata); @@ -867,7 +852,7 @@ public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): * @group DDC-2825 * @group 881 */ - public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotationProperty(): void + public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAttributeProperty(): void { $metadata = $this->createClassMetadataFactory()->getMetadataFor(SchemaAndTableInTableName::class); assert($metadata instanceof ClassMetadata); diff --git a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php index 2ebba696dcc..cad8b12108d 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php @@ -32,7 +32,7 @@ public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses(): * @group DDC-2825 * @group 881 */ - public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): void + public function testSchemaDefinitionViaExplicitTableSchemaAttributeProperty(): void { self::markTestIncomplete(); } @@ -41,7 +41,7 @@ public function testSchemaDefinitionViaExplicitTableSchemaAnnotationProperty(): * @group DDC-2825 * @group 881 */ - public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAnnotationProperty(): void + public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAttributeProperty(): void { self::markTestIncomplete(); } diff --git a/tests/Doctrine/Tests/ORM/ORMSetupTest.php b/tests/Doctrine/Tests/ORM/ORMSetupTest.php index c1a23df7af6..21c0987181b 100644 --- a/tests/Doctrine/Tests/ORM/ORMSetupTest.php +++ b/tests/Doctrine/Tests/ORM/ORMSetupTest.php @@ -5,12 +5,11 @@ namespace Doctrine\Tests\ORM; use Doctrine\ORM\Configuration; -use Doctrine\ORM\Mapping as AnnotationNamespace; +use Doctrine\ORM\Mapping as MappingNamespace; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\ORMSetup; use PHPUnit\Framework\TestCase; -use ReflectionClass; use ReflectionProperty; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\ApcuAdapter; @@ -83,8 +82,8 @@ public function testConfigureCacheCustomInstance(): void class AnnotatedDummy { - #[AnnotationNamespace\PrePersist] - public function namespacedAnnotationMethod(): void + #[MappingNamespace\PrePersist] + public function namespacedAttributeMethod(): void { } } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index acc6a8bf1ec..2d79cef6d0b 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -273,7 +273,7 @@ public function testProcessParameterValueObject(): void public function testProcessParameterValueValueObjectWithDriverChain(): void { $driverChain = new MappingDriverChain(); - $driverChain->addDriver($this->createAnnotationDriver(), 'Foo'); + $driverChain->addDriver($this->createAttributeDriver(), 'Foo'); $this->entityManager->getConfiguration()->setMetadataDriverImpl($driverChain); $query = $this->entityManager->createQuery(); diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php index d5063ea32cd..01d0a2ee46e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php @@ -29,7 +29,7 @@ class AttachEntityListenersListenerTest extends OrmTestCase protected function setUp(): void { $this->listener = new AttachEntityListenersListener(); - $driver = $this->createAnnotationDriver(); + $driver = $this->createAttributeDriver(); $this->em = $this->getTestEntityManager(); $evm = $this->em->getEventManager(); $this->factory = new ClassMetadataFactory(); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php index 8fda1e084bb..60f5f0326ec 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/AbstractCommandTest.php @@ -6,7 +6,6 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\ORM\Mapping\Driver\AttributeDriver; -use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\OrmFunctionalTestCase; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php index c01bde697e8..f99db43463e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php @@ -26,7 +26,7 @@ protected function setUp(): void { parent::setUp(); - $driver = $this->createAnnotationDriver(); + $driver = $this->createAttributeDriver(); $em = $this->getTestEntityManager(); $em->getConfiguration()->setMetadataDriverImpl($driver); diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index 67b9da9d6d6..7f045afdc32 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -30,10 +30,8 @@ class ResolveTargetEntityListenerTest extends OrmTestCase protected function setUp(): void { - $annotationDriver = $this->createAnnotationDriver(); - $this->em = $this->getTestEntityManager(); - $this->em->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $this->em->getConfiguration()->setMetadataDriverImpl($this->createAttributeDriver()); $this->factory = $this->em->getMetadataFactory(); $this->listener = new ResolveTargetEntityListener(); } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index d5b7eaefe54..d05274db6ec 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -46,7 +46,7 @@ class SchemaToolTest extends OrmTestCase { - public function testAddUniqueIndexForUniqueFieldAnnotation(): void + public function testAddUniqueIndexForUniqueFieldAttribute(): void { $em = $this->getTestEntityManager(); $schemaTool = new SchemaTool($em); @@ -67,15 +67,15 @@ public function testAddUniqueIndexForUniqueFieldAnnotation(): void self::assertTrue($schema->getTable('cms_users')->columnsAreIndexed(['username']), 'username column should be indexed.'); } - public function testAnnotationOptionsAttribute(): void + public function testAttributeOptionsArgument(): void { $em = $this->getTestEntityManager(); $schemaTool = new SchemaTool($em); $schema = $schemaTool->getSchemaFromMetadata( - [$em->getClassMetadata(TestEntityWithAnnotationOptionsAttribute::class)], + [$em->getClassMetadata(TestEntityWithAttributeOptionsArgument::class)], ); - $table = $schema->getTable('TestEntityWithAnnotationOptionsAttribute'); + $table = $schema->getTable('TestEntityWithAttributeOptionsArgument'); foreach ([$table->getOptions(), $table->getColumn('test')->getPlatformOptions()] as $options) { self::assertArrayHasKey('foo', $options); @@ -198,18 +198,18 @@ public function testEnumTypeAddedToCustomSchemaOptions(): void } /** @group DDC-3671 */ - public function testSchemaHasProperIndexesFromUniqueConstraintAnnotation(): void + public function testSchemaHasProperIndexesFromUniqueConstraintAttribute(): void { $em = $this->getTestEntityManager(); $schemaTool = new SchemaTool($em); $classes = [ - $em->getClassMetadata(UniqueConstraintAnnotationModel::class), + $em->getClassMetadata(UniqueConstraintAttributeModel::class), ]; $schema = $schemaTool->getSchemaFromMetadata($classes); - self::assertTrue($schema->hasTable('unique_constraint_annotation_table')); - $table = $schema->getTable('unique_constraint_annotation_table'); + self::assertTrue($schema->hasTable('unique_constraint_attribute_table')); + $table = $schema->getTable('unique_constraint_attribute_table'); self::assertCount(2, $table->getIndexes()); self::assertTrue($table->hasIndex('primary')); @@ -374,7 +374,7 @@ public function testConfigurationSchemaIgnoredEntity(): void #[Table(options: ['foo' => 'bar', 'baz' => ['key' => 'val']])] #[Entity] -class TestEntityWithAnnotationOptionsAttribute +class TestEntityWithAttributeOptionsArgument { #[Id] #[Column] @@ -403,10 +403,10 @@ public function postGenerateSchema(GenerateSchemaEventArgs $eventArgs): void } } -#[Table(name: 'unique_constraint_annotation_table')] +#[Table(name: 'unique_constraint_attribute_table')] #[UniqueConstraint(name: 'uniq_hash', columns: ['hash'])] #[Entity] -class UniqueConstraintAnnotationModel +class UniqueConstraintAttributeModel { #[Id] #[Column] diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index dec3b09ab74..bf45e8b6399 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -22,7 +22,6 @@ use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Driver\AttributeDriver; -use Doctrine\ORM\ORMSetup; use Doctrine\ORM\Tools\DebugUnitOfWorkListener; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\ToolsException; diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index e8c6409e647..73b2293ff2b 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -4,8 +4,6 @@ namespace Doctrine\Tests; -use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\Annotations\PsrCachedReader; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Result; @@ -17,9 +15,7 @@ use Doctrine\ORM\Cache\DefaultCacheFactory; use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger; use Doctrine\ORM\Configuration; -use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\Driver\AttributeDriver; -use Doctrine\ORM\ORMSetup; use Doctrine\Tests\Mocks\EntityManagerMock; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -57,7 +53,7 @@ abstract class OrmTestCase extends DoctrineTestCase private CacheItemPoolInterface|null $secondLevelCache = null; - protected function createAnnotationDriver(array $paths = []): AttributeDriver + protected function createAttributeDriver(array $paths = []): AttributeDriver { return new AttributeDriver($paths); } From 31db15f50131c6d57d40ab7d125061c08fdf39f2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 26 Oct 2022 10:15:47 +0200 Subject: [PATCH 183/475] Remove DriverChain (#10175) --- UPGRADE.md | 5 +++-- lib/Doctrine/ORM/Mapping/Driver/DriverChain.php | 16 ---------------- 2 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/DriverChain.php diff --git a/UPGRADE.md b/UPGRADE.md index a6eb374068a..1a74500d518 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -158,9 +158,10 @@ class MyStrategy implements NamingStrategy } ``` -## BC BREAK: Remove StaticPHPDriver +## BC BREAK: Remove `StaticPHPDriver` and `DriverChain` -Use `Doctrine\Persistence\Mapping\Driver\StaticPHPDriver` from +Use `Doctrine\Persistence\Mapping\Driver\StaticPHPDriver` and +`Doctrine\Persistence\Mapping\Driver\MappingDriverChain` from `doctrine/persistence` instead. ## BC BREAK: `UnderscoreNamingStrategy` is number aware only diff --git a/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php b/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php deleted file mode 100644 index 1aeb6b064d6..00000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Wed, 26 Oct 2022 23:50:26 +0200 Subject: [PATCH 184/475] Remove last remnants of the YAML driver (#10185) --- docs/en/reference/advanced-configuration.rst | 4 +- docs/en/reference/basic-mapping.rst | 3 +- docs/en/reference/events.rst | 2 +- docs/en/reference/yaml-mapping.rst | 158 ------------------ .../Doctrine.Tests.Models.Enums.Card.dcm.yml | 11 -- ....Tests.Models.Generic.BooleanModel.dcm.yml | 11 -- ...Tests.Models.Upsertable.Insertable.dcm.yml | 17 -- ....Tests.Models.Upsertable.Updatable.dcm.yml | 17 -- 8 files changed, 3 insertions(+), 220 deletions(-) delete mode 100644 docs/en/reference/yaml-mapping.rst delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Enums.Card.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.yml delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.yml diff --git a/docs/en/reference/advanced-configuration.rst b/docs/en/reference/advanced-configuration.rst index ddb1d03743d..5cd920cc177 100644 --- a/docs/en/reference/advanced-configuration.rst +++ b/docs/en/reference/advanced-configuration.rst @@ -111,14 +111,12 @@ Gets or sets the metadata driver implementation that is used by Doctrine to acquire the object-relational metadata for your classes. -There are currently 4 available implementations: +There are currently 3 available implementations: - ``Doctrine\ORM\Mapping\Driver\AttributeDriver`` - ``Doctrine\ORM\Mapping\Driver\XmlDriver`` - ``Doctrine\ORM\Mapping\Driver\DriverChain`` -- ``Doctrine\ORM\Mapping\Driver\YamlDriver`` (deprecated and will be - removed in ``doctrine/orm`` 3.0) Throughout the most part of this manual the AttributeDriver is used in the examples. For information on the usage of the diff --git a/docs/en/reference/basic-mapping.rst b/docs/en/reference/basic-mapping.rst index ccb2d515bda..ee0cc13065e 100644 --- a/docs/en/reference/basic-mapping.rst +++ b/docs/en/reference/basic-mapping.rst @@ -47,10 +47,9 @@ mapping metadata: - :doc:`Attributes ` - :doc:`XML ` - :doc:`PHP code ` -- :doc:`YAML ` (deprecated and will be removed in ``doctrine/orm`` 3.0.) This manual will usually show mapping metadata via attributes, though -many examples also show the equivalent configuration in YAML and XML. +many examples also show the equivalent configuration in XML. .. note:: diff --git a/docs/en/reference/events.rst b/docs/en/reference/events.rst index ae0de4d0fd1..e0e9ab3bc2c 100644 --- a/docs/en/reference/events.rst +++ b/docs/en/reference/events.rst @@ -906,7 +906,7 @@ Load ClassMetadata Event ``loadClassMetadata`` - The ``loadClassMetadata`` event occurs after the mapping metadata for a class has been loaded from a mapping source -(attributes/xml/yaml) in to a ``Doctrine\ORM\Mapping\ClassMetadata`` instance. +(attributes/xml) in to a ``Doctrine\ORM\Mapping\ClassMetadata`` instance. You can hook in to this process and manipulate the instance. This event is not a lifecycle callback. diff --git a/docs/en/reference/yaml-mapping.rst b/docs/en/reference/yaml-mapping.rst deleted file mode 100644 index bb5feb9b870..00000000000 --- a/docs/en/reference/yaml-mapping.rst +++ /dev/null @@ -1,158 +0,0 @@ -YAML Mapping -============ - -.. warning:: - The YAML driver is deprecated and will be removed in version 3.0. - It is strongly recommended to switch to one of the other mappings. - -The YAML mapping driver enables you to provide the ORM metadata in -form of YAML documents. - -The YAML mapping document of a class is loaded on-demand the first -time it is requested and subsequently stored in the metadata cache. -In order to work, this requires certain conventions: - - -- Each entity/mapped superclass must get its own dedicated YAML - mapping document. -- The name of the mapping document must consist of the fully - qualified name of the class, where namespace separators are - replaced by dots (.). -- All mapping documents should get the extension ".dcm.yml" to - identify it as a Doctrine mapping file. This is more of a - convention and you are not forced to do this. You can change the - file extension easily enough. - -.. code-block:: php - - setFileExtension('.yml'); - -It is recommended to put all YAML mapping documents in a single -folder but you can spread the documents over several folders if you -want to. In order to tell the YamlDriver where to look for your -mapping documents, supply an array of paths as the first argument -of the constructor, like this: - -.. code-block:: php - - setMetadataDriverImpl($driver); - -Simplified YAML Driver -~~~~~~~~~~~~~~~~~~~~~~ - -The Symfony project sponsored a driver that simplifies usage of the YAML Driver. -The changes between the original driver are: - -- File Extension is .orm.yml -- Filenames are shortened, "MyProject\\Entities\\User" will become User.orm.yml -- You can add a global file and add multiple entities in this file. - -Configuration of this client works a little bit different: - -.. code-block:: php - - 'MyProject\Entities', - '/path/to/files2' => 'OtherProject\Entities' - ); - $driver = new \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver($namespaces); - $driver->setGlobalBasename('global'); // global.orm.yml - -Example -------- - -As a quick start, here is a small example document that makes use -of several common elements: - -.. code-block:: yaml - - # Doctrine.Tests.ORM.Mapping.User.dcm.yml - Doctrine\Tests\ORM\Mapping\User: - type: entity - repositoryClass: Doctrine\Tests\ORM\Mapping\UserRepository - table: cms_users - schema: schema_name # The schema the table lies in, for platforms that support schemas (Optional, >= 2.5) - readOnly: true - indexes: - name_index: - columns: [ name ] - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 50 - email: - type: string - length: 32 - column: user_email - unique: true - options: - fixed: true - comment: User's email address - loginCount: - type: integer - column: login_count - nullable: false - options: - unsigned: true - default: 0 - oneToOne: - address: - targetEntity: Address - joinColumn: - name: address_id - referencedColumnName: id - onDelete: CASCADE - oneToMany: - phonenumbers: - targetEntity: Phonenumber - mappedBy: user - cascade: ["persist", "merge"] - manyToMany: - groups: - targetEntity: Group - joinTable: - name: cms_users_groups - joinColumns: - user_id: - referencedColumnName: id - inverseJoinColumns: - group_id: - referencedColumnName: id - lifecycleCallbacks: - prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] - postPersist: [ doStuffOnPostPersist ] - -Be aware that class-names specified in the YAML files should be -fully qualified. - -Reference -~~~~~~~~~~~~~~~~~~~~~~ - -Unique Constraints ------------------- - -It is possible to define unique constraints by the following declaration: - -.. code-block:: yaml - - # ECommerceProduct.orm.yml - ECommerceProduct: - type: entity - fields: - # definition of some fields - uniqueConstraints: - search_idx: - columns: [ name, email ] - diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Enums.Card.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Enums.Card.dcm.yml deleted file mode 100644 index 1694c72070f..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Enums.Card.dcm.yml +++ /dev/null @@ -1,11 +0,0 @@ -Doctrine\Tests\Models\Enums\Card: - type: entity - id: - id: - type: integer - generator: - strategy: AUTO - fields: - suit: - type: string - enumType: Doctrine\Tests\Models\Enums\Suit \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml deleted file mode 100644 index 5b1ec64b874..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.yml +++ /dev/null @@ -1,11 +0,0 @@ -\stdClass: - type: entity - id: - id: - type: integer - unsigned: true - generator: - strategy: AUTO - fields: - booleanField: - type: boolean diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.yml deleted file mode 100644 index 4e5e8531841..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.yml +++ /dev/null @@ -1,17 +0,0 @@ -Doctrine\Tests\Models\Upsertable\Insertable: - type: entity - table: insertable_column - id: - id: - generator: - strategy: AUTO - fields: - nonInsertableContent: - type: string - insertable: false - generated: INSERT - options: - default: 1234 - insertableContent: - type: string - insertable: true \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.yml deleted file mode 100644 index 386ae77209b..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.yml +++ /dev/null @@ -1,17 +0,0 @@ -Doctrine\Tests\Models\Upsertable\Updatable: - type: entity - table: updatable_column - id: - id: - generator: - strategy: AUTO - fields: - nonUpdatableContent: - type: string - updatable: false - generated: ALWAYS - options: - default: 1234 - updatableContent: - type: string - updatable: true From 373fd32b0e8398b54951cdbad2bf8ad869bfdf8f Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 31 Oct 2022 09:50:08 +0100 Subject: [PATCH 185/475] Remove the Annotation interface --- UPGRADE.md | 3 +++ lib/Doctrine/ORM/Mapping/Annotation.php | 10 --------- .../ORM/Mapping/Driver/AttributeReader.php | 22 +++++++++---------- .../Mapping/Driver/DoctrineAnnotations.php | 1 - .../Driver/RepeatableAttributeCollection.php | 4 ++-- lib/Doctrine/ORM/Mapping/MappingAttribute.php | 2 +- psalm.xml | 8 ------- 7 files changed, 17 insertions(+), 33 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Annotation.php diff --git a/UPGRADE.md b/UPGRADE.md index ed0618ec14a..9ee676758d4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -5,6 +5,9 @@ The annotation driver and anything related to annotation has been removed. Please migrate to another mapping driver. +The `Doctrine\ORM\Mapping\Annotation` maker interface has been removed in favor of the new +`Doctrine\ORM\Mapping\MappingAttribute` interface. + ## BC BREAK: Removed `EntityManager::create()` The constructor of `EntityManager` is now public and must be used instead of the `create()` method. diff --git a/lib/Doctrine/ORM/Mapping/Annotation.php b/lib/Doctrine/ORM/Mapping/Annotation.php deleted file mode 100644 index 65223a070f6..00000000000 --- a/lib/Doctrine/ORM/Mapping/Annotation.php +++ /dev/null @@ -1,10 +0,0 @@ -,bool> */ + /** @var array, bool> */ private array $isRepeatableAttribute = []; /** * @psalm-return class-string-map> * - * @template T of Annotation + * @template T of MappingAttribute */ public function getClassAnnotations(ReflectionClass $class): array { @@ -36,7 +36,7 @@ public function getClassAnnotations(ReflectionClass $class): array /** * @return class-string-map> * - * @template T of Annotation + * @template T of MappingAttribute */ public function getMethodAnnotations(ReflectionMethod $method): array { @@ -46,7 +46,7 @@ public function getMethodAnnotations(ReflectionMethod $method): array /** * @return class-string-map> * - * @template T of Annotation + * @template T of MappingAttribute */ public function getPropertyAnnotations(ReflectionProperty $property): array { @@ -58,7 +58,7 @@ public function getPropertyAnnotations(ReflectionProperty $property): array * * @return T|null * - * @template T of Annotation + * @template T of MappingAttribute */ public function getPropertyAnnotation(ReflectionProperty $property, $annotationName) { @@ -78,7 +78,7 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN * * @return RepeatableAttributeCollection * - * @template T of Annotation + * @template T of MappingAttribute */ public function getPropertyAnnotationCollection( ReflectionProperty $property, @@ -99,7 +99,7 @@ public function getPropertyAnnotationCollection( * * @return class-string-map> * - * @template T of Annotation + * @template T of MappingAttribute */ private function convertToAttributeInstances(array $attributes): array { @@ -109,12 +109,12 @@ private function convertToAttributeInstances(array $attributes): array $attributeName = $attribute->getName(); assert(is_string($attributeName)); // Make sure we only get Doctrine Annotations - if (! is_subclass_of($attributeName, Annotation::class)) { + if (! is_subclass_of($attributeName, MappingAttribute::class)) { continue; } $instance = $attribute->newInstance(); - assert($instance instanceof Annotation); + assert($instance instanceof MappingAttribute); if ($this->isRepeatable($attributeName)) { if (! isset($instances[$attributeName])) { @@ -132,7 +132,7 @@ private function convertToAttributeInstances(array $attributes): array return $instances; } - /** @param class-string $attributeClassName */ + /** @param class-string $attributeClassName */ private function isRepeatable(string $attributeClassName): bool { if (isset($this->isRepeatableAttribute[$attributeClassName])) { diff --git a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php index 2a9c8e519ff..d1e794207c8 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php @@ -2,7 +2,6 @@ declare(strict_types=1); -require_once __DIR__ . '/../Annotation.php'; require_once __DIR__ . '/../MappingAttribute.php'; require_once __DIR__ . '/../Entity.php'; require_once __DIR__ . '/../Embeddable.php'; diff --git a/lib/Doctrine/ORM/Mapping/Driver/RepeatableAttributeCollection.php b/lib/Doctrine/ORM/Mapping/Driver/RepeatableAttributeCollection.php index 995d293f82e..2f6ae93f4fb 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/RepeatableAttributeCollection.php +++ b/lib/Doctrine/ORM/Mapping/Driver/RepeatableAttributeCollection.php @@ -5,11 +5,11 @@ namespace Doctrine\ORM\Mapping\Driver; use ArrayObject; -use Doctrine\ORM\Mapping\Annotation; +use Doctrine\ORM\Mapping\MappingAttribute; /** * @template-extends ArrayObject - * @template T of Annotation + * @template T of MappingAttribute */ final class RepeatableAttributeCollection extends ArrayObject { diff --git a/lib/Doctrine/ORM/Mapping/MappingAttribute.php b/lib/Doctrine/ORM/Mapping/MappingAttribute.php index 979d5031744..61091a90d0d 100644 --- a/lib/Doctrine/ORM/Mapping/MappingAttribute.php +++ b/lib/Doctrine/ORM/Mapping/MappingAttribute.php @@ -5,6 +5,6 @@ namespace Doctrine\ORM\Mapping; /** A marker interface for mapping attributes. */ -interface MappingAttribute extends Annotation +interface MappingAttribute { } diff --git a/psalm.xml b/psalm.xml index 29ec9db6779..6f11cbb315d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -24,16 +24,8 @@ - - - - - - - - From 3182cceda4cce7165b3375d77707dd49c3f95576 Mon Sep 17 00:00:00 2001 From: michnovka Date: Wed, 2 Nov 2022 16:50:55 +0100 Subject: [PATCH 186/475] EntityManager#refresh lockMode on 3.0.x (#10196) --- UPGRADE.md | 5 +++++ .../ORM/Decorator/EntityManagerDecorator.php | 11 +---------- lib/Doctrine/ORM/EntityManager.php | 10 ---------- lib/Doctrine/ORM/EntityManagerInterface.php | 16 +++++++++++++++- lib/Doctrine/ORM/UnitOfWork.php | 12 +++--------- psalm.xml | 3 --- .../Mock/NonProxyLoadingEntityManager.php | 4 ++-- 7 files changed, 26 insertions(+), 35 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 9ee676758d4..c93dd986960 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: Changed `EntityManagerInterface#refresh($entity)`, `EntityManagerDecorator#refresh($entity)` and `UnitOfWork#refresh($entity)` signatures + +The new signatures of these methods add an optional `LockMode|int|null $lockMode` +param with default `null` value (no lock). + ## BC Break: Removed AnnotationDriver The annotation driver and anything related to annotation has been removed. diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index 72818cad2a7..c546efd8a4a 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -24,9 +24,6 @@ use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\ObjectManagerDecorator; -use function func_get_arg; -use function func_num_args; - /** * Base class for EntityManager decorators * @@ -133,14 +130,8 @@ public function find(string $className, mixed $id, LockMode|int|null $lockMode = return $this->wrapped->find($className, $id, $lockMode, $lockVersion); } - public function refresh(object $object): void + public function refresh(object $object, LockMode|int|null $lockMode = null): void { - $lockMode = null; - - if (func_num_args() > 1) { - $lockMode = func_get_arg(1); - } - $this->wrapped->refresh($object, $lockMode); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index dc4d3cdedb8..ef80a6b4811 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -496,16 +496,6 @@ public function remove(object $object): void $this->unitOfWork->remove($object); } - /** - * Refreshes the persistent state of an entity from the database, - * overriding any local changes that have not yet been persisted. - * - * @psalm-param LockMode::*|null $lockMode - * - * @throws ORMInvalidArgumentException - * @throws ORMException - * @throws TransactionRequiredException - */ public function refresh(object $object, LockMode|int|null $lockMode = null): void { $this->errorIfClosed(); diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index 379b19c88ce..db8e1f803e8 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -17,7 +17,6 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Persistence\ObjectManager; -/** @method void refresh(object $object, LockMode|int|null $lockMode = null) */ interface EntityManagerInterface extends ObjectManager { /** @@ -133,6 +132,21 @@ public function createQueryBuilder(): QueryBuilder; */ public function find(string $className, mixed $id, LockMode|int|null $lockMode = null, int|null $lockVersion = null): object|null; + /** + * Refreshes the persistent state of an object from the database, + * overriding any local changes that have not yet been persisted. + * + * @param LockMode|int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants + * or NULL if no specific lock mode should be used + * during the search. + * @psalm-param LockMode::*|null $lockMode + * + * @throws ORMInvalidArgumentException + * @throws ORMException + * @throws TransactionRequiredException + */ + public function refresh(object $object, LockMode|int|null $lockMode = null): void; + /** * Gets a reference to the entity identified by the given type and identifier * without actually loading it, if the entity is not yet loaded. diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 1c114f5fd1f..a07797348df 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -64,8 +64,6 @@ use function assert; use function count; use function current; -use function func_get_arg; -use function func_num_args; use function get_debug_type; use function implode; use function in_array; @@ -1790,19 +1788,15 @@ private function doDetach( * Refreshes the state of the given entity from the database, overwriting * any local, unpersisted changes. * + * @psalm-param LockMode::*|null $lockMode + * * @throws InvalidArgumentException If the entity is not MANAGED. * @throws TransactionRequiredException */ - public function refresh(object $entity): void + public function refresh(object $entity, LockMode|int|null $lockMode = null): void { $visited = []; - $lockMode = null; - - if (func_num_args() > 1) { - $lockMode = func_get_arg(1); - } - $this->doRefresh($entity, $visited, $lockMode); } diff --git a/psalm.xml b/psalm.xml index 968f208c50c..6f11cbb315d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -88,9 +88,6 @@ - - - diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index e98030e7782..39db18da09f 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -201,9 +201,9 @@ public function detach(object $object): void $this->realEntityManager->detach($object); } - public function refresh(object $object): void + public function refresh(object $object, LockMode|int|null $lockMode = null): void { - $this->realEntityManager->refresh($object); + $this->realEntityManager->refresh($object, $lockMode); } public function flush(): void From ee1b78441ce9200fa1df0ec222ef55b209ee50fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 7 Nov 2022 12:00:28 +0100 Subject: [PATCH 187/475] Purge annotations from /lib (#10203) * Remove file used by annotation registry * Remove meta-annotations They should have been removed when the annotation driver was removed. * Remove unneeded coding standard rule exclusion * Remove annotation documentation of indexBy --- .../working-with-indexed-associations.rst | 1 - .../ORM/Mapping/AssociationOverride.php | 8 +--- .../ORM/Mapping/AssociationOverrides.php | 8 +--- .../ORM/Mapping/AttributeOverride.php | 8 +--- .../ORM/Mapping/AttributeOverrides.php | 8 +--- lib/Doctrine/ORM/Mapping/Cache.php | 9 +--- .../ORM/Mapping/ChangeTrackingPolicy.php | 6 --- lib/Doctrine/ORM/Mapping/Column.php | 6 --- .../ORM/Mapping/CustomIdGenerator.php | 6 --- .../ORM/Mapping/DiscriminatorColumn.php | 6 --- lib/Doctrine/ORM/Mapping/DiscriminatorMap.php | 6 --- .../Mapping/Driver/DoctrineAnnotations.php | 45 ------------------- lib/Doctrine/ORM/Mapping/Embeddable.php | 4 -- lib/Doctrine/ORM/Mapping/Embedded.php | 6 --- lib/Doctrine/ORM/Mapping/Entity.php | 8 +--- lib/Doctrine/ORM/Mapping/EntityListeners.php | 5 --- lib/Doctrine/ORM/Mapping/GeneratedValue.php | 6 --- .../ORM/Mapping/HasLifecycleCallbacks.php | 4 -- lib/Doctrine/ORM/Mapping/Id.php | 4 -- lib/Doctrine/ORM/Mapping/Index.php | 6 --- lib/Doctrine/ORM/Mapping/InheritanceType.php | 6 --- lib/Doctrine/ORM/Mapping/JoinColumn.php | 6 --- lib/Doctrine/ORM/Mapping/JoinColumns.php | 5 --- lib/Doctrine/ORM/Mapping/JoinTable.php | 6 --- lib/Doctrine/ORM/Mapping/ManyToMany.php | 6 --- lib/Doctrine/ORM/Mapping/ManyToOne.php | 6 --- lib/Doctrine/ORM/Mapping/MappedSuperclass.php | 6 --- lib/Doctrine/ORM/Mapping/OneToMany.php | 6 --- lib/Doctrine/ORM/Mapping/OneToOne.php | 6 --- lib/Doctrine/ORM/Mapping/OrderBy.php | 6 --- lib/Doctrine/ORM/Mapping/PostLoad.php | 4 -- lib/Doctrine/ORM/Mapping/PostPersist.php | 4 -- lib/Doctrine/ORM/Mapping/PostRemove.php | 4 -- lib/Doctrine/ORM/Mapping/PostUpdate.php | 4 -- lib/Doctrine/ORM/Mapping/PreFlush.php | 4 -- lib/Doctrine/ORM/Mapping/PrePersist.php | 4 -- lib/Doctrine/ORM/Mapping/PreRemove.php | 4 -- lib/Doctrine/ORM/Mapping/PreUpdate.php | 4 -- .../ORM/Mapping/SequenceGenerator.php | 6 --- lib/Doctrine/ORM/Mapping/Table.php | 6 --- lib/Doctrine/ORM/Mapping/UniqueConstraint.php | 6 --- lib/Doctrine/ORM/Mapping/Version.php | 4 -- phpcs.xml.dist | 8 ---- 43 files changed, 6 insertions(+), 275 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php diff --git a/docs/en/tutorials/working-with-indexed-associations.rst b/docs/en/tutorials/working-with-indexed-associations.rst index 8dad1f66adb..ad4d7a263a0 100644 --- a/docs/en/tutorials/working-with-indexed-associations.rst +++ b/docs/en/tutorials/working-with-indexed-associations.rst @@ -24,7 +24,6 @@ Mapping Indexed Associations You can map indexed associations by adding: * ``indexBy`` argument to any ``#[OneToMany]`` or ``#[ManyToMany]`` attribute. - * ``indexBy`` attribute to any ``@OneToMany`` or ``@ManyToMany`` annotation. * ``index-by`` attribute to any ```` or ```` xml element. The code and mappings for the Market entity looks like this: diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverride.php b/lib/Doctrine/ORM/Mapping/AssociationOverride.php index 193bfb50f50..e0ebc073fd3 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationOverride.php +++ b/lib/Doctrine/ORM/Mapping/AssociationOverride.php @@ -4,13 +4,7 @@ namespace Doctrine\ORM\Mapping; -/** - * This attribute is used to override association mapping of property for an entity relationship. - * - * @Annotation - * @NamedArgumentConstructor - * @Target("ANNOTATION") - */ +/** This attribute is used to override association mapping of property for an entity relationship. */ final class AssociationOverride implements MappingAttribute { /** diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php b/lib/Doctrine/ORM/Mapping/AssociationOverrides.php index df50b38ec09..9fc6807b7b8 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AssociationOverrides.php @@ -9,13 +9,7 @@ use function array_values; use function is_array; -/** - * This attribute is used to override association mappings of relationship properties. - * - * @Annotation - * @NamedArgumentConstructor() - * @Target("CLASS") - */ +/** This attribute is used to override association mappings of relationship properties. */ #[Attribute(Attribute::TARGET_CLASS)] final class AssociationOverrides implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverride.php b/lib/Doctrine/ORM/Mapping/AttributeOverride.php index 5da719e26d9..8f0e70c7295 100644 --- a/lib/Doctrine/ORM/Mapping/AttributeOverride.php +++ b/lib/Doctrine/ORM/Mapping/AttributeOverride.php @@ -4,13 +4,7 @@ namespace Doctrine\ORM\Mapping; -/** - * This attribute is used to override the mapping of a entity property. - * - * @Annotation - * @NamedArgumentConstructor - * @Target("ANNOTATION") - */ +/** This attribute is used to override the mapping of a entity property. */ final class AttributeOverride implements MappingAttribute { public function __construct( diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php index aaf407e70df..de7d7de4f95 100644 --- a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php @@ -9,13 +9,7 @@ use function array_values; use function is_array; -/** - * This attribute is used to override the mapping of a entity property. - * - * @Annotation - * @NamedArgumentConstructor() - * @Target("CLASS") - */ +/** This attribute is used to override the mapping of a entity property. */ #[Attribute(Attribute::TARGET_CLASS)] final class AttributeOverrides implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/Cache.php b/lib/Doctrine/ORM/Mapping/Cache.php index 698eb94ae22..3161ab3a545 100644 --- a/lib/Doctrine/ORM/Mapping/Cache.php +++ b/lib/Doctrine/ORM/Mapping/Cache.php @@ -5,15 +5,8 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * Caching to an entity or a collection. - * - * @Annotation - * @NamedArgumentConstructor() - * @Target({"CLASS","PROPERTY"}) - */ +/** Caching to an entity or a collection. */ #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PROPERTY)] final class Cache implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php index cb4067ca9bc..fb02c4339e6 100644 --- a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php +++ b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("CLASS") - */ #[Attribute(Attribute::TARGET_CLASS)] final class ChangeTrackingPolicy implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/Column.php b/lib/Doctrine/ORM/Mapping/Column.php index 722040a8790..68121e67ece 100644 --- a/lib/Doctrine/ORM/Mapping/Column.php +++ b/lib/Doctrine/ORM/Mapping/Column.php @@ -6,13 +6,7 @@ use Attribute; use BackedEnum; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor - * @Target({"PROPERTY","ANNOTATION"}) - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class Column implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php b/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php index 7ba5bea956f..7b31dc33e92 100644 --- a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php +++ b/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor - * @Target("PROPERTY") - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class CustomIdGenerator implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php b/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php index 59259566bb6..e40df24110b 100644 --- a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("CLASS") - */ #[Attribute(Attribute::TARGET_CLASS)] final class DiscriminatorColumn implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php b/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php index 39b05e2b908..2b204a9ea58 100644 --- a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("CLASS") - */ #[Attribute(Attribute::TARGET_CLASS)] final class DiscriminatorMap implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php b/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php deleted file mode 100644 index d1e794207c8..00000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php +++ /dev/null @@ -1,45 +0,0 @@ - $value */ diff --git a/lib/Doctrine/ORM/Mapping/JoinTable.php b/lib/Doctrine/ORM/Mapping/JoinTable.php index fbf3be620f9..0558761185d 100644 --- a/lib/Doctrine/ORM/Mapping/JoinTable.php +++ b/lib/Doctrine/ORM/Mapping/JoinTable.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target({"PROPERTY","ANNOTATION"}) - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class JoinTable implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/lib/Doctrine/ORM/Mapping/ManyToMany.php index bfb97550487..d90a762fa6d 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToMany.php +++ b/lib/Doctrine/ORM/Mapping/ManyToMany.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("PROPERTY") - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class ManyToMany implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/ManyToOne.php b/lib/Doctrine/ORM/Mapping/ManyToOne.php index 59a1ac9f5bf..8fccff3e45d 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToOne.php +++ b/lib/Doctrine/ORM/Mapping/ManyToOne.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("PROPERTY") - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class ManyToOne implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php b/lib/Doctrine/ORM/Mapping/MappedSuperclass.php index e45896cead3..29475a280b5 100644 --- a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php +++ b/lib/Doctrine/ORM/Mapping/MappedSuperclass.php @@ -5,14 +5,8 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; use Doctrine\ORM\EntityRepository; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("CLASS") - */ #[Attribute(Attribute::TARGET_CLASS)] final class MappedSuperclass implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/OneToMany.php b/lib/Doctrine/ORM/Mapping/OneToMany.php index 3563b2242f1..4eac8842ee6 100644 --- a/lib/Doctrine/ORM/Mapping/OneToMany.php +++ b/lib/Doctrine/ORM/Mapping/OneToMany.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("PROPERTY") - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class OneToMany implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/OneToOne.php b/lib/Doctrine/ORM/Mapping/OneToOne.php index 285110b84bb..e3e64559a6f 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOne.php +++ b/lib/Doctrine/ORM/Mapping/OneToOne.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("PROPERTY") - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class OneToOne implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/OrderBy.php b/lib/Doctrine/ORM/Mapping/OrderBy.php index a4003340403..5cb2ed93cbc 100644 --- a/lib/Doctrine/ORM/Mapping/OrderBy.php +++ b/lib/Doctrine/ORM/Mapping/OrderBy.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("PROPERTY") - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class OrderBy implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/PostLoad.php b/lib/Doctrine/ORM/Mapping/PostLoad.php index 0b2d063e896..9ce1e5c2b9c 100644 --- a/lib/Doctrine/ORM/Mapping/PostLoad.php +++ b/lib/Doctrine/ORM/Mapping/PostLoad.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("METHOD") - */ #[Attribute(Attribute::TARGET_METHOD)] final class PostLoad implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/PostPersist.php b/lib/Doctrine/ORM/Mapping/PostPersist.php index d28ac86c797..f7bf2e18b96 100644 --- a/lib/Doctrine/ORM/Mapping/PostPersist.php +++ b/lib/Doctrine/ORM/Mapping/PostPersist.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("METHOD") - */ #[Attribute(Attribute::TARGET_METHOD)] final class PostPersist implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/PostRemove.php b/lib/Doctrine/ORM/Mapping/PostRemove.php index 9b7e1c40ae4..394c175674f 100644 --- a/lib/Doctrine/ORM/Mapping/PostRemove.php +++ b/lib/Doctrine/ORM/Mapping/PostRemove.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("METHOD") - */ #[Attribute(Attribute::TARGET_METHOD)] final class PostRemove implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/PostUpdate.php b/lib/Doctrine/ORM/Mapping/PostUpdate.php index 771c2db731d..7b956757412 100644 --- a/lib/Doctrine/ORM/Mapping/PostUpdate.php +++ b/lib/Doctrine/ORM/Mapping/PostUpdate.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("METHOD") - */ #[Attribute(Attribute::TARGET_METHOD)] final class PostUpdate implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/PreFlush.php b/lib/Doctrine/ORM/Mapping/PreFlush.php index 50dfa703000..f2c09d71c9e 100644 --- a/lib/Doctrine/ORM/Mapping/PreFlush.php +++ b/lib/Doctrine/ORM/Mapping/PreFlush.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("METHOD") - */ #[Attribute(Attribute::TARGET_METHOD)] final class PreFlush implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/PrePersist.php b/lib/Doctrine/ORM/Mapping/PrePersist.php index ab4e4d54a9d..1b88a7a1c4a 100644 --- a/lib/Doctrine/ORM/Mapping/PrePersist.php +++ b/lib/Doctrine/ORM/Mapping/PrePersist.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("METHOD") - */ #[Attribute(Attribute::TARGET_METHOD)] final class PrePersist implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/PreRemove.php b/lib/Doctrine/ORM/Mapping/PreRemove.php index 68c69157b76..f63d4e0975d 100644 --- a/lib/Doctrine/ORM/Mapping/PreRemove.php +++ b/lib/Doctrine/ORM/Mapping/PreRemove.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("METHOD") - */ #[Attribute(Attribute::TARGET_METHOD)] final class PreRemove implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/PreUpdate.php b/lib/Doctrine/ORM/Mapping/PreUpdate.php index b6f2fcda624..9b73bfd61fd 100644 --- a/lib/Doctrine/ORM/Mapping/PreUpdate.php +++ b/lib/Doctrine/ORM/Mapping/PreUpdate.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("METHOD") - */ #[Attribute(Attribute::TARGET_METHOD)] final class PreUpdate implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/SequenceGenerator.php b/lib/Doctrine/ORM/Mapping/SequenceGenerator.php index 9054e7c9ab4..6c06e845827 100644 --- a/lib/Doctrine/ORM/Mapping/SequenceGenerator.php +++ b/lib/Doctrine/ORM/Mapping/SequenceGenerator.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("PROPERTY") - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class SequenceGenerator implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/Table.php b/lib/Doctrine/ORM/Mapping/Table.php index b9ae8f3ae92..1ec28a81468 100644 --- a/lib/Doctrine/ORM/Mapping/Table.php +++ b/lib/Doctrine/ORM/Mapping/Table.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor - * @Target("CLASS") - */ #[Attribute(Attribute::TARGET_CLASS)] final class Table implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php b/lib/Doctrine/ORM/Mapping/UniqueConstraint.php index 353126b14a3..3180be063c7 100644 --- a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php +++ b/lib/Doctrine/ORM/Mapping/UniqueConstraint.php @@ -5,13 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; -use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; -/** - * @Annotation - * @NamedArgumentConstructor() - * @Target("ANNOTATION") - */ #[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] final class UniqueConstraint implements MappingAttribute { diff --git a/lib/Doctrine/ORM/Mapping/Version.php b/lib/Doctrine/ORM/Mapping/Version.php index 7f87e1d7a7c..7252e055908 100644 --- a/lib/Doctrine/ORM/Mapping/Version.php +++ b/lib/Doctrine/ORM/Mapping/Version.php @@ -6,10 +6,6 @@ use Attribute; -/** - * @Annotation - * @Target("PROPERTY") - */ #[Attribute(Attribute::TARGET_PROPERTY)] final class Version implements MappingAttribute { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 2db1993e27b..8f850fd270d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -61,14 +61,6 @@ lib/Doctrine/ORM/Tools/ToolEvents.php - - - lib/Doctrine/ORM/Mapping/Column.php - lib/Doctrine/ORM/Mapping/Index.php - lib/Doctrine/ORM/Mapping/Table.php - lib/Doctrine/ORM/Mapping/UniqueConstraint.php - - lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php From 2f1ed28f098dd2bae4c83674624eb148c44e446a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 8 Nov 2022 22:02:00 +0100 Subject: [PATCH 188/475] Migrate cache namespace to php 8 --- .../ORM/Cache/AssociationCacheEntry.php | 29 +++------------- lib/Doctrine/ORM/Cache/CacheKey.php | 9 ++--- .../ORM/Cache/CollectionCacheEntry.php | 14 +------- lib/Doctrine/ORM/Cache/CollectionCacheKey.php | 31 +++++------------ .../ORM/Cache/DefaultCacheFactory.php | 4 +-- .../ORM/Cache/DefaultEntityHydrator.php | 9 +++-- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 11 +++---- lib/Doctrine/ORM/Cache/EntityCacheEntry.php | 33 ++++--------------- lib/Doctrine/ORM/Cache/EntityCacheKey.php | 25 +++++--------- ...onStrictReadWriteCachedEntityPersister.php | 4 +-- lib/Doctrine/ORM/Cache/QueryCacheEntry.php | 26 ++++----------- lib/Doctrine/ORM/Cache/QueryCacheKey.php | 31 +++-------------- .../ORM/Cache/Region/DefaultRegion.php | 3 +- .../ORM/Cache/Region/FileLockRegion.php | 4 +-- .../ORM/Cache/TimestampCacheEntry.php | 6 +--- lib/Doctrine/ORM/Cache/TimestampCacheKey.php | 2 +- .../Cache/TimestampQueryCacheValidator.php | 2 +- .../ORM/Mapping/AttributeOverrides.php | 3 +- psalm-baseline.xml | 3 ++ tests/Doctrine/Tests/Mocks/CacheKeyMock.php | 5 --- 20 files changed, 64 insertions(+), 190 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php index 810ecde1d3f..7dc1fbeefc8 100644 --- a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php @@ -4,35 +4,16 @@ namespace Doctrine\ORM\Cache; -/** - * Association cache entry - */ class AssociationCacheEntry implements CacheEntry { - /** - * The entity identifier - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @var array - */ - public array $identifier; - - /** - * The entity class name - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @psalm-var class-string - */ - public string $class; - /** * @param array $identifier The entity identifier. - * @psalm-param class-string $class + * @param class-string $class The entity class name */ - public function __construct(string $class, array $identifier) - { - $this->class = $class; - $this->identifier = $identifier; + public function __construct( + public readonly string $class, + public readonly array $identifier, + ) { } /** diff --git a/lib/Doctrine/ORM/Cache/CacheKey.php b/lib/Doctrine/ORM/Cache/CacheKey.php index 47466c063fa..970702cbcd1 100644 --- a/lib/Doctrine/ORM/Cache/CacheKey.php +++ b/lib/Doctrine/ORM/Cache/CacheKey.php @@ -10,10 +10,7 @@ */ abstract class CacheKey { - /** - * Unique identifier - * - * @readonly Public only for performance reasons, it should be considered immutable. - */ - public string $hash; + public function __construct(public readonly string $hash) + { + } } diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php index 18229b20f8f..fde45759312 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php @@ -4,23 +4,11 @@ namespace Doctrine\ORM\Cache; -/** - * Collection cache entry - */ class CollectionCacheEntry implements CacheEntry { - /** - * The list of entity identifiers hold by the collection - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @var CacheKey[] - */ - public array $identifiers; - /** @param CacheKey[] $identifiers List of entity identifiers hold by the collection */ - public function __construct(array $identifiers) + public function __construct(public readonly array $identifiers) { - $this->identifiers = $identifiers; } /** diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php b/lib/Doctrine/ORM/Cache/CollectionCacheKey.php index eb2414f83bd..1f86480b380 100644 --- a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php +++ b/lib/Doctrine/ORM/Cache/CollectionCacheKey.php @@ -17,37 +17,22 @@ class CollectionCacheKey extends CacheKey /** * The owner entity identifier * - * @readonly Public only for performance reasons, it should be considered immutable. * @var array */ - public array $ownerIdentifier; - - /** - * The owner entity class - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @psalm-var class-string - */ - public string $entityClass; - - /** - * The association name - * - * @readonly Public only for performance reasons, it should be considered immutable. - */ - public string $association; + public readonly array $ownerIdentifier; /** * @param array $ownerIdentifier The identifier of the owning entity. - * @psalm-param class-string $entityClass + * @param class-string $entityClass The owner entity class */ - public function __construct(string $entityClass, string $association, array $ownerIdentifier) - { + public function __construct( + public readonly string $entityClass, + public readonly string $association, + array $ownerIdentifier, + ) { ksort($ownerIdentifier); $this->ownerIdentifier = $ownerIdentifier; - $this->entityClass = $entityClass; - $this->association = $association; - $this->hash = str_replace('\\', '.', strtolower($entityClass)) . '_' . implode(' ', $ownerIdentifier) . '__' . $association; + parent::__construct(str_replace('\\', '.', strtolower($entityClass)) . '_' . implode(' ', $ownerIdentifier) . '__' . $association); } } diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 07562f4d7df..f9240f2a5f2 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -31,7 +31,6 @@ class DefaultCacheFactory implements CacheFactory { - private RegionsConfiguration $regionsConfig; private TimestampRegion|null $timestampRegion = null; /** @var Region[] */ @@ -39,9 +38,8 @@ class DefaultCacheFactory implements CacheFactory private string|null $fileLockRegionDirectory = null; - public function __construct(RegionsConfiguration $cacheConfig, private CacheItemPoolInterface $cacheItemPool) + public function __construct(private readonly RegionsConfiguration $regionsConfig, private readonly CacheItemPoolInterface $cacheItemPool) { - $this->regionsConfig = $cacheConfig; } public function setFileLockRegionDirectory(string $fileLockRegionDirectory): void diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 64f6e5ccc7e..dba3eb219e4 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -11,7 +11,6 @@ use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\Utility\IdentifierFlattener; -use function array_merge; use function assert; use function is_array; use function is_object; @@ -22,14 +21,14 @@ */ class DefaultEntityHydrator implements EntityHydrator { - private UnitOfWork $uow; - private IdentifierFlattener $identifierFlattener; + private readonly UnitOfWork $uow; + private readonly IdentifierFlattener $identifierFlattener; /** @var array */ private static array $hints = [Query::HINT_CACHE_ENABLED => true]; public function __construct( - private EntityManagerInterface $em, + private readonly EntityManagerInterface $em, ) { $this->uow = $em->getUnitOfWork(); $this->identifierFlattener = new IdentifierFlattener($em->getUnitOfWork(), $em->getMetadataFactory()); @@ -38,7 +37,7 @@ public function __construct( public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, object $entity): EntityCacheEntry { $data = $this->uow->getOriginalEntityData($entity); - $data = array_merge($data, $metadata->getIdentifierValues($entity)); // why update has no identifier values ? + $data = [...$data, ...$metadata->getIdentifierValues($entity)]; // why update has no identifier values ? if ($metadata->requiresFetchAfterChange) { if ($metadata->isVersioned) { diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index e040a8cfd4c..787ca4a99f0 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -15,6 +15,7 @@ use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\Proxy; @@ -82,9 +83,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] $cm = $this->em->getClassMetadata($entityName); - $generateKeys = static function (array $entry) use ($cm): EntityCacheKey { - return new EntityCacheKey($cm->rootEntityName, $entry['identifier']); - }; + $generateKeys = static fn (array $entry): EntityCacheKey => new EntityCacheKey($cm->rootEntityName, $entry['identifier']); $cacheKeys = new CollectionCacheEntry(array_map($generateKeys, $cacheEntry->result)); $entries = $region->getMultiple($cacheKeys) ?? []; @@ -139,9 +138,7 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = [] continue; } - $generateKeys = static function ($id) use ($assocMetadata): EntityCacheKey { - return new EntityCacheKey($assocMetadata->rootEntityName, $id); - }; + $generateKeys = static fn (array $id): EntityCacheKey => new EntityCacheKey($assocMetadata->rootEntityName, $id); $collection = new PersistentCollection($this->em, $assocMetadata, new ArrayCollection()); $assocKeys = new CollectionCacheEntry(array_map($generateKeys, $assoc['list'])); @@ -214,7 +211,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, ar throw FeatureNotImplemented::nonSelectStatements(); } - if (($hints[Query\SqlWalker::HINT_PARTIAL] ?? false) === true || ($hints[Query::HINT_FORCE_PARTIAL_LOAD] ?? false) === true) { + if (($hints[SqlWalker::HINT_PARTIAL] ?? false) === true || ($hints[Query::HINT_FORCE_PARTIAL_LOAD] ?? false) === true) { throw FeatureNotImplemented::partialEntities(); } diff --git a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php index d8853545971..69bc81379d0 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php @@ -8,41 +8,22 @@ use function array_map; -/** - * Entity cache entry - */ class EntityCacheEntry implements CacheEntry { /** - * The entity map data - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @var array - */ - public array $data; - - /** - * The entity class name - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @psalm-var class-string + * @param array $data The entity map data + * @psalm-param class-string $class The entity class name */ - public string $class; - - /** - * @param array $data The entity data. - * @psalm-param class-string $class - */ - public function __construct(string $class, array $data) - { - $this->class = $class; - $this->data = $data; + public function __construct( + public readonly string $class, + public readonly array $data, + ) { } /** * Creates a new EntityCacheEntry * - * This method allow Doctrine\Common\Cache\PhpFileCache compatibility + * This method allows Doctrine\Common\Cache\PhpFileCache compatibility * * @param array $values array containing property values */ diff --git a/lib/Doctrine/ORM/Cache/EntityCacheKey.php b/lib/Doctrine/ORM/Cache/EntityCacheKey.php index f6486969886..de740ea54f4 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheKey.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheKey.php @@ -17,30 +17,21 @@ class EntityCacheKey extends CacheKey /** * The entity identifier * - * @readonly Public only for performance reasons, it should be considered immutable. * @var array */ - public array $identifier; + public readonly array $identifier; /** - * The entity class name - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @psalm-var class-string - */ - public string $entityClass; - - /** - * @param string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class. + * @param class-string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class. * @param array $identifier The entity identifier - * @psalm-param class-string $entityClass */ - public function __construct(string $entityClass, array $identifier) - { + public function __construct( + public readonly string $entityClass, + array $identifier, + ) { ksort($identifier); - $this->identifier = $identifier; - $this->entityClass = $entityClass; - $this->hash = str_replace('\\', '.', strtolower($entityClass) . '_' . implode(' ', $identifier)); + $this->identifier = $identifier; + parent::__construct(str_replace('\\', '.', strtolower($entityClass) . '_' . implode(' ', $identifier))); } } diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php index febb187f72b..43c76ab2cac 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php @@ -6,8 +6,6 @@ use Doctrine\ORM\Cache\EntityCacheKey; -use function get_class; - /** * Specific non-strict read/write cached entity persister */ @@ -72,7 +70,7 @@ public function update(object $entity): void private function updateCache(object $entity, bool $isChanged): bool { - $class = $this->metadataFactory->getMetadataFor(get_class($entity)); + $class = $this->metadataFactory->getMetadataFor($entity::class); $key = new EntityCacheKey($class->rootEntityName, $this->uow->getEntityIdentifier($entity)); $entry = $this->hydrator->buildCacheEntry($class, $key, $entity); $cached = $this->region->put($key, $entry); diff --git a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php index 6d9aaa10b79..1e39262b92d 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php @@ -6,31 +6,19 @@ use function microtime; -/** - * Query cache entry - */ class QueryCacheEntry implements CacheEntry { - /** - * List of entity identifiers - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @var array - */ - public array $result; - /** * Time creation of this cache entry - * - * @readonly Public only for performance reasons, it should be considered immutable. */ - public float $time; + public readonly float $time; - /** @param array $result */ - public function __construct(array $result, float|null $time = null) - { - $this->result = $result; - $this->time = $time ?: microtime(true); + /** @param array $result List of entity identifiers */ + public function __construct( + public readonly array $result, + float|null $time = null, + ) { + $this->time = $time ?: microtime(true); } /** @param array $values */ diff --git a/lib/Doctrine/ORM/Cache/QueryCacheKey.php b/lib/Doctrine/ORM/Cache/QueryCacheKey.php index 654b0c8ab95..2372e5a253e 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheKey.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheKey.php @@ -11,34 +11,13 @@ */ class QueryCacheKey extends CacheKey { - /** - * Cache key lifetime - * - * @readonly Public only for performance reasons, it should be considered immutable. - */ - public int $lifetime; - - /** - * Cache mode - * - * @readonly Public only for performance reasons, it should be considered immutable. - * @psalm-var Cache::MODE_* - */ - public int $cacheMode; - - /** @readonly Public only for performance reasons, it should be considered immutable. */ - public TimestampCacheKey|null $timestampKey = null; - - /** @psalm-param Cache::MODE_* $cacheMode */ + /** @param Cache::MODE_* $cacheMode */ public function __construct( string $cacheId, - int $lifetime = 0, - int $cacheMode = Cache::MODE_NORMAL, - TimestampCacheKey|null $timestampKey = null, + public readonly int $lifetime = 0, + public readonly int $cacheMode = Cache::MODE_NORMAL, + public readonly TimestampCacheKey|null $timestampKey = null, ) { - $this->hash = $cacheId; - $this->lifetime = $lifetime; - $this->cacheMode = $cacheMode; - $this->timestampKey = $timestampKey; + parent::__construct($cacheId); } } diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php index be6bf18dc8b..05761954a7a 100644 --- a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Cache\Region; -use Closure; use Doctrine\ORM\Cache\CacheEntry; use Doctrine\ORM\Cache\CacheKey; use Doctrine\ORM\Cache\CollectionCacheEntry; @@ -58,7 +57,7 @@ public function get(CacheKey $key): CacheEntry|null public function getMultiple(CollectionCacheEntry $collection): array|null { $keys = array_map( - Closure::fromCallable([$this, 'getCacheEntryKey']), + $this->getCacheEntryKey(...), $collection->identifiers, ); /** @var iterable $items */ diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php index c8411922918..dfc2535c32b 100644 --- a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php +++ b/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php @@ -35,7 +35,7 @@ */ class FileLockRegion implements ConcurrentRegion { - public const LOCK_EXTENSION = 'lock'; + final public const LOCK_EXTENSION = 'lock'; /** * @param numeric-string|int $lockLifetime @@ -127,7 +127,7 @@ public function get(CacheKey $key): CacheEntry|null public function getMultiple(CollectionCacheEntry $collection): array|null { - if (array_filter(array_map([$this, 'isLocked'], $collection->identifiers))) { + if (array_filter(array_map($this->isLocked(...), $collection->identifiers))) { return null; } diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php index 4b146f925c9..60c9175c14e 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php @@ -6,13 +6,9 @@ use function microtime; -/** - * Timestamp cache entry - */ class TimestampCacheEntry implements CacheEntry { - /** @readonly Public only for performance reasons, it should be considered immutable. */ - public float $time; + public readonly float $time; public function __construct(float|null $time = null) { diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheKey.php b/lib/Doctrine/ORM/Cache/TimestampCacheKey.php index 278458f1764..5aef4c5a05c 100644 --- a/lib/Doctrine/ORM/Cache/TimestampCacheKey.php +++ b/lib/Doctrine/ORM/Cache/TimestampCacheKey.php @@ -12,6 +12,6 @@ class TimestampCacheKey extends CacheKey /** @param string $space Result cache id */ public function __construct(string $space) { - $this->hash = $space; + parent::__construct($space); } } diff --git a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php index 754b9fa7390..98240888e0c 100644 --- a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php +++ b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php @@ -8,7 +8,7 @@ class TimestampQueryCacheValidator implements QueryCacheValidator { - public function __construct(private TimestampRegion $timestampRegion) + public function __construct(private readonly TimestampRegion $timestampRegion) { } diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php index aaf407e70df..a3bdf88499b 100644 --- a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php +++ b/lib/Doctrine/ORM/Mapping/AttributeOverrides.php @@ -23,9 +23,8 @@ final class AttributeOverrides implements MappingAttribute * One or more field or property mapping overrides. * * @var list - * @readonly */ - public array $overrides = []; + public readonly array $overrides; /** @param array|AttributeOverride $overrides */ public function __construct(array|AttributeOverride $overrides) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fabdea7de21..d70c499cdc1 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -43,6 +43,9 @@ + + $data + $targetClassMetadata->associationMappings diff --git a/tests/Doctrine/Tests/Mocks/CacheKeyMock.php b/tests/Doctrine/Tests/Mocks/CacheKeyMock.php index aa4bf505dbc..4b1ad539482 100644 --- a/tests/Doctrine/Tests/Mocks/CacheKeyMock.php +++ b/tests/Doctrine/Tests/Mocks/CacheKeyMock.php @@ -13,9 +13,4 @@ */ class CacheKeyMock extends CacheKey { - /** @param string $hash The string hash that represend this cache key */ - public function __construct(string $hash) - { - $this->hash = $hash; - } } From 3d729a768fc7f5d8c83d6b469abdfcc52cf25184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 8 Nov 2022 22:10:08 +0100 Subject: [PATCH 189/475] Stop modifying readonly properties --- tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php | 3 +-- .../Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 577f6975b93..033f346652c 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -504,14 +504,13 @@ public function testGetShouldIgnoreOldQueryCacheEntryResult(): void ['identifier' => ['id' => 1]], ['identifier' => ['id' => 2]], ], + microtime(true) - 100, ); $entities = [ ['id' => 1, 'name' => 'Foo'], ['id' => 2, 'name' => 'Bar'], ]; - $entry->time = microtime(true) - 100; - $this->region->addReturn('get', $entry); $this->region->addReturn( diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 2d7c3cd2499..7f3e46ab6a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -830,7 +830,7 @@ public function testQueryCacheLifetime(): void ->get($key); self::assertInstanceOf(QueryCacheEntry::class, $entry); - $entry->time /= 2; + $entry = new QueryCacheEntry($entry->result, $entry->time / 2); $this->cache->getQueryCache() ->getRegion() From a8445c96619dd872bc12d75b06172e9c2dae5f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 11 Nov 2022 10:49:48 +0100 Subject: [PATCH 190/475] Migrate function nodes to PHP 8 syntax (#10214) --- .../ORM/Query/AST/Functions/AbsFunction.php | 6 +- .../ORM/Query/AST/Functions/AvgFunction.php | 3 +- .../Query/AST/Functions/BitAndFunction.php | 13 +-- .../ORM/Query/AST/Functions/BitOrFunction.php | 13 +-- .../Query/AST/Functions/ConcatFunction.php | 13 +-- .../ORM/Query/AST/Functions/CountFunction.php | 3 +- .../AST/Functions/CurrentDateFunction.php | 6 +- .../AST/Functions/CurrentTimeFunction.php | 6 +- .../Functions/CurrentTimestampFunction.php | 6 +- .../Query/AST/Functions/DateAddFunction.php | 98 +++++++------------ .../Query/AST/Functions/DateDiffFunction.php | 13 +-- .../Query/AST/Functions/DateSubFunction.php | 86 +++++++--------- .../ORM/Query/AST/Functions/FunctionNode.php | 9 +- .../Query/AST/Functions/IdentityFunction.php | 10 +- .../Query/AST/Functions/LengthFunction.php | 9 +- .../Query/AST/Functions/LocateFunction.php | 13 +-- .../ORM/Query/AST/Functions/LowerFunction.php | 9 +- .../ORM/Query/AST/Functions/MaxFunction.php | 3 +- .../ORM/Query/AST/Functions/MinFunction.php | 3 +- .../ORM/Query/AST/Functions/ModFunction.php | 6 +- .../ORM/Query/AST/Functions/SizeFunction.php | 5 +- .../ORM/Query/AST/Functions/SqrtFunction.php | 6 +- .../Query/AST/Functions/SubstringFunction.php | 9 +- .../ORM/Query/AST/Functions/SumFunction.php | 3 +- .../ORM/Query/AST/Functions/TrimFunction.php | 29 ++---- .../ORM/Query/AST/Functions/UpperFunction.php | 9 +- .../Pagination/RowNumberOverFunction.php | 8 +- psalm-baseline.xml | 24 ++--- 28 files changed, 151 insertions(+), 270 deletions(-) diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php index 9e4b7ad2a5c..0930faf2616 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php @@ -19,16 +19,14 @@ class AbsFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $simpleArithmeticExpression; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression( $this->simpleArithmeticExpression, ) . ')'; } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php index a0b0ca5e527..ba7b7f35055 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php @@ -13,8 +13,7 @@ */ final class AvgFunction extends FunctionNode { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php index a0988bb1b30..1f67866c536 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php @@ -16,14 +16,10 @@ */ class BitAndFunction extends FunctionNode { - /** @var Node */ - public $firstArithmetic; + public Node $firstArithmetic; + public Node $secondArithmetic; - /** @var Node */ - public $secondArithmetic; - - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -33,8 +29,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php index 08bca26e707..49d29a982cf 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php @@ -16,14 +16,10 @@ */ class BitOrFunction extends FunctionNode { - /** @var Node */ - public $firstArithmetic; + public Node $firstArithmetic; + public Node $secondArithmetic; - /** @var Node */ - public $secondArithmetic; - - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -33,8 +29,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php index b2101650be0..4c530bbda9f 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php @@ -16,17 +16,13 @@ */ class ConcatFunction extends FunctionNode { - /** @var Node */ - public $firstStringPrimary; - - /** @var Node */ - public $secondStringPrimary; + public Node $firstStringPrimary; + public Node $secondStringPrimary; /** @psalm-var list */ public $concatExpressions = []; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -39,8 +35,7 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getConcatExpression(...$args); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php index a7e0c18c9d6..dc926a52a2b 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php @@ -16,8 +16,7 @@ */ final class CountFunction extends FunctionNode implements TypedExpression { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php index a1dc659a217..4c585d40c23 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php @@ -15,14 +15,12 @@ */ class CurrentDateFunction extends FunctionNode { - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentDateSQL(); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php index a27b6732af8..7cf2841129a 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php @@ -15,14 +15,12 @@ */ class CurrentTimeFunction extends FunctionNode { - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimeSQL(); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php index 74a9883168c..96d564be452 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php @@ -15,14 +15,12 @@ */ class CurrentTimestampFunction extends FunctionNode { - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getCurrentTimestampSQL(); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php index 2c21fdf1097..aaed131184e 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php @@ -22,66 +22,45 @@ */ class DateAddFunction extends FunctionNode { - /** @var Node */ - public $firstDateExpression = null; + public Node $firstDateExpression; + public Node $intervalExpression; + public Node $unit; - /** @var Node */ - public $intervalExpression = null; - - /** @var Node */ - public $unit = null; - - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { - switch (strtolower($this->unit->value)) { - case 'second': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddSecondsExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'minute': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMinutesExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'hour': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'day': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'week': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddWeeksExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'month': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'year': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddYearsExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - default: - throw QueryException::semanticalError( - 'DATE_ADD() only supports units of type second, minute, hour, day, week, month and year.', - ); - } + return match (strtolower((string) $this->unit->value)) { + 'second' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddSecondsExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'minute' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMinutesExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'hour' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'day' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'week' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddWeeksExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'month' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'year' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddYearsExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + default => throw QueryException::semanticalError( + 'DATE_ADD() only supports units of type second, minute, hour, day, week, month and year.', + ), + }; } /** @@ -97,8 +76,7 @@ private function dispatchIntervalExpression(SqlWalker $sqlWalker) return $sql; } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php index c082ab9cc4e..bbd73c47df6 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php @@ -16,14 +16,10 @@ */ class DateDiffFunction extends FunctionNode { - /** @var Node */ - public $date1; + public Node $date1; + public Node $date2; - /** @var Node */ - public $date2; - - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getDateDiffExpression( $this->date1->dispatch($sqlWalker), @@ -31,8 +27,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php index 45830268ebb..254f1219277 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php @@ -19,57 +19,41 @@ */ class DateSubFunction extends DateAddFunction { - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { - switch (strtolower($this->unit->value)) { - case 'second': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubSecondsExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'minute': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMinutesExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'hour': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'day': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'week': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubWeeksExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'month': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMonthExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - case 'year': - return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubYearsExpression( - $this->firstDateExpression->dispatch($sqlWalker), - $this->dispatchIntervalExpression($sqlWalker), - ); - - default: - throw QueryException::semanticalError( - 'DATE_SUB() only supports units of type second, minute, hour, day, week, month and year.', - ); - } + return match (strtolower((string) $this->unit->value)) { + 'second' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubSecondsExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'minute' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMinutesExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'hour' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'day' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'week' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubWeeksExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'month' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubMonthExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + 'year' => $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubYearsExpression( + $this->firstDateExpression->dispatch($sqlWalker), + $this->dispatchIntervalExpression($sqlWalker), + ), + default => throw QueryException::semanticalError( + 'DATE_SUB() only supports units of type second, minute, hour, day, week, month and year.', + ), + }; } /** @@ -77,7 +61,7 @@ public function getSql(SqlWalker $sqlWalker) * * @throws ASTException */ - private function dispatchIntervalExpression(SqlWalker $sqlWalker) + private function dispatchIntervalExpression(SqlWalker $sqlWalker): string { $sql = $this->intervalExpression->dispatch($sqlWalker); assert(is_numeric($sql)); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php b/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php index 6318d539d03..4cc549e7cd4 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php @@ -17,19 +17,16 @@ */ abstract class FunctionNode extends Node { - /** @param string $name */ - public function __construct(public $name) + public function __construct(public string $name) { } - /** @return string */ - abstract public function getSql(SqlWalker $sqlWalker); + abstract public function getSql(SqlWalker $sqlWalker): string; public function dispatch(SqlWalker $sqlWalker): string { return $sqlWalker->walkFunction($this); } - /** @return void */ - abstract public function parse(Parser $parser); + abstract public function parse(Parser $parser): void; } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index be00521ee26..74726e17b49 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -27,10 +27,7 @@ class IdentityFunction extends FunctionNode /** @var string|null */ public $fieldMapping; - /** - * {@inheritdoc} - */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { assert($this->pathExpression->field !== null); $entityManager = $sqlWalker->getEntityManager(); @@ -72,10 +69,7 @@ public function getSql(SqlWalker $sqlWalker) return $tableAlias . '.' . $columnName; } - /** - * {@inheritdoc} - */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php index fa0cb502fe5..ad9dcf8d4c3 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php @@ -19,19 +19,16 @@ */ class LengthFunction extends FunctionNode implements TypedExpression { - /** @var Node */ - public $stringPrimary; + public Node $stringPrimary; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getLengthExpression( $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php index b62587917ba..b9fe10d6ea9 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php @@ -17,17 +17,13 @@ */ class LocateFunction extends FunctionNode { - /** @var Node */ - public $firstStringPrimary; - - /** @var Node */ - public $secondStringPrimary; + public Node $firstStringPrimary; + public Node $secondStringPrimary; /** @var SimpleArithmeticExpression|bool */ public $simpleArithmeticExpression = false; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -45,8 +41,7 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getLocateExpression($secondString, $firstString); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php index e548d843ee3..65afff783cf 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php @@ -18,11 +18,9 @@ */ class LowerFunction extends FunctionNode { - /** @var Node */ - public $stringPrimary; + public Node $stringPrimary; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return sprintf( 'LOWER(%s)', @@ -30,8 +28,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php index a08e33413e0..8a6eecf3031 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php @@ -13,8 +13,7 @@ */ final class MaxFunction extends FunctionNode { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php index 83cc3ac27e9..98d73a2825e 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php @@ -13,8 +13,7 @@ */ final class MinFunction extends FunctionNode { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php index af5aa535889..d4529aeffee 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php @@ -22,8 +22,7 @@ class ModFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $secondSimpleArithmeticExpression; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return $sqlWalker->getConnection()->getDatabasePlatform()->getModExpression( $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), @@ -31,8 +30,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 5ecc2486a68..e59818ad2ce 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -26,7 +26,7 @@ class SizeFunction extends FunctionNode * @inheritdoc * @todo If the collection being counted is already joined, the SQL can be simpler (more efficient). */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { assert($this->collectionPathExpression->field !== null); $entityManager = $sqlWalker->getEntityManager(); @@ -102,8 +102,7 @@ public function getSql(SqlWalker $sqlWalker) return '(' . $sql . ')'; } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php index b5e04ad1201..1f74392f5bc 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php @@ -21,8 +21,7 @@ class SqrtFunction extends FunctionNode /** @var SimpleArithmeticExpression */ public $simpleArithmeticExpression; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return sprintf( 'SQRT(%s)', @@ -30,8 +29,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php index 6b758e4b6fc..89e45ebe111 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php @@ -17,8 +17,7 @@ */ class SubstringFunction extends FunctionNode { - /** @var Node */ - public $stringPrimary; + public Node $stringPrimary; /** @var SimpleArithmeticExpression */ public $firstSimpleArithmeticExpression; @@ -26,8 +25,7 @@ class SubstringFunction extends FunctionNode /** @var SimpleArithmeticExpression|null */ public $secondSimpleArithmeticExpression = null; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $optionalSecondSimpleArithmeticExpression = null; if ($this->secondSimpleArithmeticExpression !== null) { @@ -41,8 +39,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php index c317c018e90..588dce9775a 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php @@ -13,8 +13,7 @@ */ final class SumFunction extends FunctionNode { - /** @var AggregateExpression */ - private $aggregateExpression; + private AggregateExpression $aggregateExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php index 370b225ab2e..b0436e00a40 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -19,25 +19,13 @@ */ class TrimFunction extends FunctionNode { - /** @var bool */ - public $leading; + public bool $leading = false; + public bool $trailing = false; + public bool $both = false; + public string|false $trimChar = false; + public Node $stringPrimary; - /** @var bool */ - public $trailing; - - /** @var bool */ - public $both; - - /** @var string|false */ - public $trimChar = false; - - /** @var Node */ - public $stringPrimary; - - /** - * {@inheritdoc} - */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { $stringPrimary = $sqlWalker->walkStringPrimary($this->stringPrimary); $platform = $sqlWalker->getConnection()->getDatabasePlatform(); @@ -54,10 +42,7 @@ public function getSql(SqlWalker $sqlWalker) return $platform->getTrimExpression($stringPrimary, $trimMode); } - /** - * {@inheritdoc} - */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $lexer = $parser->getLexer(); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php index 65a30b2ecf7..3f1cd6b3333 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php @@ -18,11 +18,9 @@ */ class UpperFunction extends FunctionNode { - /** @var Node */ - public $stringPrimary; + public Node $stringPrimary; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return sprintf( 'UPPER(%s)', @@ -30,8 +28,7 @@ public function getSql(SqlWalker $sqlWalker) ); } - /** @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php b/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php index 44c0cb8fc1c..a0fdd012dbc 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php +++ b/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php @@ -19,11 +19,9 @@ */ class RowNumberOverFunction extends FunctionNode { - /** @var OrderByClause */ - public $orderByClause; + public OrderByClause $orderByClause; - /** @inheritdoc */ - public function getSql(SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker): string { return 'ROW_NUMBER() OVER(' . trim($sqlWalker->walkOrderByClause( $this->orderByClause, @@ -35,7 +33,7 @@ public function getSql(SqlWalker $sqlWalker) * * @inheritdoc */ - public function parse(Parser $parser) + public function parse(Parser $parser): void { throw RowNumberOverFunctionNotEnabled::create(); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d70c499cdc1..ad2f5c49ab0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -65,9 +65,6 @@ $cacheKeys->identifiers[$index] $cacheKeys->identifiers[$index] - - $id - $assocEntry->class $assocEntry->class @@ -316,6 +313,7 @@ ClassMetadata + ClassMetadata @@ -1039,11 +1037,11 @@ $parser->ArithmeticPrimary() $parser->ArithmeticPrimary() - - null - null - null - + + $firstDateExpression + $intervalExpression + $unit + $this->unit->value @@ -1059,6 +1057,11 @@ + + DateSubFunction + DateSubFunction + DateSubFunction + $this->unit->value @@ -1173,11 +1176,8 @@ $lexer->lookahead['value'] $lexer->token['value'] - - $both - $leading + $stringPrimary - $trailing From e9f3a43f37cf04880890d4b20d0f70ab31e9e56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 21 Nov 2022 23:41:40 +0100 Subject: [PATCH 191/475] Migrate persisters to PHP 8 syntax --- .../Collection/ManyToManyPersister.php | 11 +++-- .../Collection/OneToManyPersister.php | 5 +-- .../Entity/BasicEntityPersister.php | 20 ++++----- .../Entity/CachedPersisterContext.php | 40 +++++------------ .../Entity/SingleTablePersister.php | 1 + .../ORM/Persisters/PersisterException.php | 9 +--- .../ORM/Persisters/SqlExpressionVisitor.php | 45 ++++++------------- .../ORM/Persisters/SqlValueVisitor.php | 25 ++++------- phpstan-baseline.neon | 5 --- 9 files changed, 54 insertions(+), 107 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 440cb844e1d..96e753c5cb1 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -17,7 +17,6 @@ use function array_fill; use function array_pop; use function count; -use function get_class; use function implode; use function in_array; use function reset; @@ -74,7 +73,7 @@ public function update(PersistentCollection $collection): void } } - public function get(PersistentCollection $collection, mixed $index): mixed + public function get(PersistentCollection $collection, mixed $index): object|null { $mapping = $collection->getMapping(); @@ -207,7 +206,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri { $mapping = $collection->getMapping(); $owner = $collection->getOwner(); - $ownerMetadata = $this->em->getClassMetadata(get_class($owner)); + $ownerMetadata = $this->em->getClassMetadata($owner::class); $id = $this->uow->getEntityIdentifier($owner); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $onConditions = $this->getOnConditionSQL($mapping); @@ -361,7 +360,7 @@ protected function getDeleteSQL(PersistentCollection $collection): string { $columns = []; $mapping = $collection->getMapping(); - $class = $this->em->getClassMetadata(get_class($collection->getOwner())); + $class = $this->em->getClassMetadata($collection->getOwner()::class); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { @@ -441,7 +440,7 @@ protected function getDeleteRowSQL(PersistentCollection $collection): array * @return mixed[] * @psalm-return list */ - protected function getDeleteRowSQLParameters(PersistentCollection $collection, object $element) + protected function getDeleteRowSQLParameters(PersistentCollection $collection, object $element): array { return $this->collectJoinTableColumnParameters($collection, $element); } @@ -514,7 +513,7 @@ private function collectJoinTableColumnParameters( $class1 = $class2 = null; if ($isComposite) { - $class1 = $this->em->getClassMetadata(get_class($collection->getOwner())); + $class1 = $this->em->getClassMetadata($collection->getOwner()::class); $class2 = $collection->getTypeClass(); } diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 24dd48cf7f0..bcb46cabbc7 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -11,7 +11,6 @@ use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Utility\PersisterHelper; -use function array_merge; use function array_reverse; use function array_values; use function assert; @@ -52,7 +51,7 @@ public function update(PersistentCollection $collection): void return; } - public function get(PersistentCollection $collection, mixed $index): mixed + public function get(PersistentCollection $collection, mixed $index): object|null { $mapping = $collection->getMapping(); @@ -213,7 +212,7 @@ private function deleteJoinedEntityCollection(PersistentCollection $collection): $numDeleted = $this->conn->executeStatement($statement, $parameters); // 3) Delete records on each table in the hierarchy - $classNames = array_merge($targetClass->parentClasses, [$targetClass->name], $targetClass->subClasses); + $classNames = [...$targetClass->parentClasses, ...[$targetClass->name], ...$targetClass->subClasses]; foreach (array_reverse($classNames) as $className) { $tableName = $this->quoteStrategy->getTableName($this->em->getClassMetadata($className), $this->platform); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 86a9d337112..e525172f560 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -158,11 +158,11 @@ class BasicEntityPersister implements EntityPersister /** * The IdentifierFlattener used for manipulating identifiers */ - private IdentifierFlattener $identifierFlattener; + private readonly IdentifierFlattener $identifierFlattener; protected CachedPersisterContext $currentPersisterContext; - private CachedPersisterContext $limitsHandlingContext; - private CachedPersisterContext $noLimitsContext; + private readonly CachedPersisterContext $limitsHandlingContext; + private readonly CachedPersisterContext $noLimitsContext; /** * Initializes a new BasicEntityPersister that uses the given EntityManager @@ -338,7 +338,7 @@ private function extractIdentifierTypes(array $id, ClassMetadata $versionedClass $types = []; foreach ($id as $field => $value) { - $types = array_merge($types, $this->getTypes($field, $value, $versionedClass)); + $types = [...$types, ...$this->getTypes($field, $value, $versionedClass)]; } return $types; @@ -852,7 +852,7 @@ public function expandCriteriaParameters(Criteria $criteria): array foreach ($types as $type) { [$field, $value] = $type; - $sqlTypes = array_merge($sqlTypes, $this->getTypes($field, $value, $this->class)); + $sqlTypes = [...$sqlTypes, ...$this->getTypes($field, $value, $this->class)]; } return [$sqlParams, $sqlTypes]; @@ -1791,7 +1791,7 @@ public function expandParameters(array $criteria): array continue; // skip null values. } - $types = array_merge($types, $this->getTypes($field, $value, $this->class)); + $types = [...$types, ...$this->getTypes($field, $value, $this->class)]; $params = array_merge($params, $this->getValues($value)); } @@ -1820,7 +1820,7 @@ private function expandToManyParameters(array $criteria): array continue; // skip null values. } - $types = array_merge($types, $this->getTypes($criterion['field'], $criterion['value'], $criterion['class'])); + $types = [...$types, ...$this->getTypes($criterion['field'], $criterion['value'], $criterion['class'])]; $params = array_merge($params, $this->getValues($criterion['value'])); } @@ -1869,7 +1869,7 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar } if (is_array($value)) { - return array_map([$this, 'getArrayBindingType'], $types); + return array_map($this->getArrayBindingType(...), $types); } return $types; @@ -1964,8 +1964,8 @@ public function exists(object $entity, Criteria|null $extraConditions = null): b $sql .= ' AND ' . $this->getSelectConditionCriteriaSQL($extraConditions); [$criteriaParams, $criteriaTypes] = $this->expandCriteriaParameters($extraConditions); - $params = array_merge($params, $criteriaParams); - $types = array_merge($types, $criteriaTypes); + $params = [...$params, ...$criteriaParams]; + $types = [...$types, ...$criteriaTypes]; } $filterSql = $this->generateFilterConditionSQL($this->class, $alias); diff --git a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php index 3cd1b4f388a..cd42340ff2b 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php +++ b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php @@ -18,20 +18,6 @@ */ class CachedPersisterContext { - /** - * Metadata object that describes the mapping of the mapped entity class. - * - * @var \Doctrine\ORM\Mapping\ClassMetadata - */ - public $class; - - /** - * ResultSetMapping that is used for all queries. Is generated lazily once per request. - * - * @var ResultSetMapping - */ - public $rsm; - /** * The SELECT column list SQL fragment used for querying entities by this persister. * This SQL fragment is only generated once per request, if at all. @@ -62,21 +48,19 @@ class CachedPersisterContext */ public $sqlTableAliases = []; - /** - * Whether this persistent context is considering limit operations applied to the selection queries - * - * @var bool - */ - public $handlesLimits; - - /** @param bool $handlesLimits */ public function __construct( - ClassMetadata $class, - ResultSetMapping $rsm, - $handlesLimits, + /** + * Metadata object that describes the mapping of the mapped entity class. + */ + public ClassMetadata $class, + /** + * ResultSetMapping that is used for all queries. Is generated lazily once per request. + */ + public ResultSetMapping $rsm, + /** + * Whether this persistent context is considering limit operations applied to the selection queries + */ + public bool $handlesLimits, ) { - $this->class = $class; - $this->rsm = $rsm; - $this->handlesLimits = (bool) $handlesLimits; } } diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index 47d8a12ecd7..f98df63df27 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -29,6 +29,7 @@ protected function getDiscriminatorColumnTableName(): string protected function getSelectColumnsSQL(): string { + $columnList = []; if ($this->currentPersisterContext->selectColumnListSql !== null) { return $this->currentPersisterContext->selectColumnListSql; } diff --git a/lib/Doctrine/ORM/Persisters/PersisterException.php b/lib/Doctrine/ORM/Persisters/PersisterException.php index b49cfa6ef3a..0f8fe84f54c 100644 --- a/lib/Doctrine/ORM/Persisters/PersisterException.php +++ b/lib/Doctrine/ORM/Persisters/PersisterException.php @@ -11,13 +11,8 @@ class PersisterException extends Exception implements ORMException { - /** - * @param string $class - * @param string $associationName - * - * @return PersisterException - */ - public static function matchingAssocationFieldRequiresObject($class, $associationName) + /** @return PersisterException */ + public static function matchingAssocationFieldRequiresObject(string $class, string $associationName) { return new self(sprintf( 'Cannot match on %s::%s with a non-object value. Matching objects by id is ' . diff --git a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php b/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php index 044181ba6db..c9509b08075 100644 --- a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php @@ -21,24 +21,14 @@ */ class SqlExpressionVisitor extends ExpressionVisitor { - /** @var BasicEntityPersister */ - private $persister; - - /** @var ClassMetadata */ - private $classMetadata; - - public function __construct(BasicEntityPersister $persister, ClassMetadata $classMetadata) - { - $this->persister = $persister; - $this->classMetadata = $classMetadata; + public function __construct( + private readonly BasicEntityPersister $persister, + private readonly ClassMetadata $classMetadata, + ) { } - /** - * Converts a comparison expression into the target query language output. - * - * @return mixed - */ - public function walkComparison(Comparison $comparison) + /** Converts a comparison expression into the target query language output. */ + public function walkComparison(Comparison $comparison): string { $field = $comparison->getField(); $value = $comparison->getValue()->getValue(); // shortcut for walkValue() @@ -61,11 +51,9 @@ public function walkComparison(Comparison $comparison) /** * Converts a composite expression into the target query language output. * - * @return string - * * @throws RuntimeException */ - public function walkCompositeExpression(CompositeExpression $expr) + public function walkCompositeExpression(CompositeExpression $expr): string { $expressionList = []; @@ -73,24 +61,17 @@ public function walkCompositeExpression(CompositeExpression $expr) $expressionList[] = $this->dispatch($child); } - switch ($expr->getType()) { - case CompositeExpression::TYPE_AND: - return '(' . implode(' AND ', $expressionList) . ')'; - - case CompositeExpression::TYPE_OR: - return '(' . implode(' OR ', $expressionList) . ')'; - - default: - throw new RuntimeException('Unknown composite ' . $expr->getType()); - } + return match ($expr->getType()) { + CompositeExpression::TYPE_AND => '(' . implode(' AND ', $expressionList) . ')', + CompositeExpression::TYPE_OR => '(' . implode(' OR ', $expressionList) . ')', + default => throw new RuntimeException('Unknown composite ' . $expr->getType()), + }; } /** * Converts a value expression into the target query language part. - * - * @return string */ - public function walkValue(Value $value) + public function walkValue(Value $value): string { return '?'; } diff --git a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php index a61d0a25f86..67a56d95f19 100644 --- a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php @@ -15,10 +15,10 @@ class SqlValueVisitor extends ExpressionVisitor { /** @var mixed[] */ - private $values = []; + private array $values = []; /** @var mixed[][] */ - private $types = []; + private array $types = []; /** * Converts a comparison expression into the target query language output. @@ -73,7 +73,7 @@ public function walkValue(Value $value) * @return mixed[][] * @psalm-return array{0: array, 1: array>} */ - public function getParamsAndTypes() + public function getParamsAndTypes(): array { return [$this->values, $this->types]; } @@ -88,18 +88,11 @@ protected function getValueFromComparison(Comparison $comparison) { $value = $comparison->getValue()->getValue(); - switch ($comparison->getOperator()) { - case Comparison::CONTAINS: - return '%' . $value . '%'; - - case Comparison::STARTS_WITH: - return $value . '%'; - - case Comparison::ENDS_WITH: - return '%' . $value; - - default: - return $value; - } + return match ($comparison->getOperator()) { + Comparison::CONTAINS => '%' . $value . '%', + Comparison::STARTS_WITH => $value . '%', + Comparison::ENDS_WITH => '%' . $value, + default => $value, + }; } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ebf5c3ea26d..01d491152ba 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -185,11 +185,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - - - message: "#^Property Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\CachedPersisterContext\\:\\:\\$class \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\) does not accept Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\.$#" - count: 1 - path: lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php - - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$isEmbeddedClass\\.$#" count: 1 From 4d73e3ce7801d3bf3254257332e903d8ecea4096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 12 Nov 2022 10:04:59 +0100 Subject: [PATCH 192/475] Migrate Expr and Lexer to PHP 8 syntax --- lib/Doctrine/ORM/Query/Expr.php | 165 ++++++--------------- lib/Doctrine/ORM/Query/Expr/Andx.php | 9 +- lib/Doctrine/ORM/Query/Expr/Base.php | 39 ++--- lib/Doctrine/ORM/Query/Expr/Comparison.php | 40 ++--- lib/Doctrine/ORM/Query/Expr/Composite.php | 8 +- lib/Doctrine/ORM/Query/Expr/From.php | 27 ++-- lib/Doctrine/ORM/Query/Expr/Func.php | 21 +-- lib/Doctrine/ORM/Query/Expr/GroupBy.php | 11 +- lib/Doctrine/ORM/Query/Expr/Join.php | 12 +- lib/Doctrine/ORM/Query/Expr/Literal.php | 11 +- lib/Doctrine/ORM/Query/Expr/Math.php | 27 ++-- lib/Doctrine/ORM/Query/Expr/OrderBy.php | 49 +++--- lib/Doctrine/ORM/Query/Expr/Orx.php | 9 +- lib/Doctrine/ORM/Query/Expr/Select.php | 13 +- lib/Doctrine/ORM/Query/Lexer.php | 160 ++++++++++---------- 15 files changed, 239 insertions(+), 362 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index 18f988b1067..1b3372914fa 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -36,7 +36,7 @@ class Expr * but requires at least one defined * when converting to string. */ - public function andX(...$x): Expr\Andx + public function andX(Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x): Expr\Andx { return new Expr\Andx($x); } @@ -54,31 +54,23 @@ public function andX(...$x): Expr\Andx * but requires at least one defined * when converting to string. */ - public function orX(...$x): Expr\Orx + public function orX(Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x): Expr\Orx { return new Expr\Orx($x); } /** * Creates an ASCending order expression. - * - * @param mixed $expr - * - * @return Expr\OrderBy */ - public function asc($expr) + public function asc(mixed $expr): Expr\OrderBy { return new Expr\OrderBy($expr, 'ASC'); } /** * Creates a DESCending order expression. - * - * @param mixed $expr - * - * @return Expr\OrderBy */ - public function desc($expr) + public function desc(mixed $expr): Expr\OrderBy { return new Expr\OrderBy($expr, 'DESC'); } @@ -95,10 +87,8 @@ public function desc($expr) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Comparison */ - public function eq($x, $y) + public function eq(mixed $x, mixed $y): Expr\Comparison { return new Expr\Comparison($x, Expr\Comparison::EQ, $y); } @@ -114,10 +104,8 @@ public function eq($x, $y) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Comparison */ - public function neq($x, $y) + public function neq(mixed $x, mixed $y): Expr\Comparison { return new Expr\Comparison($x, Expr\Comparison::NEQ, $y); } @@ -133,10 +121,8 @@ public function neq($x, $y) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Comparison */ - public function lt($x, $y) + public function lt(mixed $x, mixed $y): Expr\Comparison { return new Expr\Comparison($x, Expr\Comparison::LT, $y); } @@ -152,10 +138,8 @@ public function lt($x, $y) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Comparison */ - public function lte($x, $y) + public function lte(mixed $x, mixed $y): Expr\Comparison { return new Expr\Comparison($x, Expr\Comparison::LTE, $y); } @@ -171,10 +155,8 @@ public function lte($x, $y) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Comparison */ - public function gt($x, $y) + public function gt(mixed $x, mixed $y): Expr\Comparison { return new Expr\Comparison($x, Expr\Comparison::GT, $y); } @@ -190,10 +172,8 @@ public function gt($x, $y) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Comparison */ - public function gte($x, $y) + public function gte(mixed $x, mixed $y): Expr\Comparison { return new Expr\Comparison($x, Expr\Comparison::GTE, $y); } @@ -202,10 +182,8 @@ public function gte($x, $y) * Creates an instance of AVG() function, with the given argument. * * @param mixed $x Argument to be used in AVG() function. - * - * @return Expr\Func */ - public function avg($x) + public function avg(mixed $x): Expr\Func { return new Expr\Func('AVG', [$x]); } @@ -214,10 +192,8 @@ public function avg($x) * Creates an instance of MAX() function, with the given argument. * * @param mixed $x Argument to be used in MAX() function. - * - * @return Expr\Func */ - public function max($x) + public function max(mixed $x): Expr\Func { return new Expr\Func('MAX', [$x]); } @@ -226,10 +202,8 @@ public function max($x) * Creates an instance of MIN() function, with the given argument. * * @param mixed $x Argument to be used in MIN() function. - * - * @return Expr\Func */ - public function min($x) + public function min(mixed $x): Expr\Func { return new Expr\Func('MIN', [$x]); } @@ -238,10 +212,8 @@ public function min($x) * Creates an instance of COUNT() function, with the given argument. * * @param mixed $x Argument to be used in COUNT() function. - * - * @return Expr\Func */ - public function count($x) + public function count(mixed $x): Expr\Func { return new Expr\Func('COUNT', [$x]); } @@ -250,10 +222,8 @@ public function count($x) * Creates an instance of COUNT(DISTINCT) function, with the given argument. * * @param mixed ...$x Argument to be used in COUNT(DISTINCT) function. - * - * @return string */ - public function countDistinct(mixed ...$x) + public function countDistinct(mixed ...$x): string { return 'COUNT(DISTINCT ' . implode(', ', $x) . ')'; } @@ -262,10 +232,8 @@ public function countDistinct(mixed ...$x) * Creates an instance of EXISTS() function, with the given DQL Subquery. * * @param mixed $subquery DQL Subquery to be used in EXISTS() function. - * - * @return Expr\Func */ - public function exists($subquery) + public function exists(mixed $subquery): Expr\Func { return new Expr\Func('EXISTS', [$subquery]); } @@ -274,10 +242,8 @@ public function exists($subquery) * Creates an instance of ALL() function, with the given DQL Subquery. * * @param mixed $subquery DQL Subquery to be used in ALL() function. - * - * @return Expr\Func */ - public function all($subquery) + public function all(mixed $subquery): Expr\Func { return new Expr\Func('ALL', [$subquery]); } @@ -286,10 +252,8 @@ public function all($subquery) * Creates a SOME() function expression with the given DQL subquery. * * @param mixed $subquery DQL Subquery to be used in SOME() function. - * - * @return Expr\Func */ - public function some($subquery) + public function some(mixed $subquery): Expr\Func { return new Expr\Func('SOME', [$subquery]); } @@ -298,10 +262,8 @@ public function some($subquery) * Creates an ANY() function expression with the given DQL subquery. * * @param mixed $subquery DQL Subquery to be used in ANY() function. - * - * @return Expr\Func */ - public function any($subquery) + public function any(mixed $subquery): Expr\Func { return new Expr\Func('ANY', [$subquery]); } @@ -310,10 +272,8 @@ public function any($subquery) * Creates a negation expression of the given restriction. * * @param mixed $restriction Restriction to be used in NOT() function. - * - * @return Expr\Func */ - public function not($restriction) + public function not(mixed $restriction): Expr\Func { return new Expr\Func('NOT', [$restriction]); } @@ -322,21 +282,16 @@ public function not($restriction) * Creates an ABS() function expression with the given argument. * * @param mixed $x Argument to be used in ABS() function. - * - * @return Expr\Func */ - public function abs($x) + public function abs(mixed $x): Expr\Func { return new Expr\Func('ABS', [$x]); } /** * Creates a MOD($x, $y) function expression to return the remainder of $x divided by $y. - * - * @param mixed $x - * @param mixed $y */ - public function mod($x, $y): Expr\Func + public function mod(mixed $x, mixed $y): Expr\Func { return new Expr\Func('MOD', [$x, $y]); } @@ -353,10 +308,8 @@ public function mod($x, $y): Expr\Func * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Math */ - public function prod($x, $y) + public function prod(mixed $x, mixed $y): Expr\Math { return new Expr\Math($x, '*', $y); } @@ -372,10 +325,8 @@ public function prod($x, $y) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Math */ - public function diff($x, $y) + public function diff(mixed $x, mixed $y): Expr\Math { return new Expr\Math($x, '-', $y); } @@ -391,10 +342,8 @@ public function diff($x, $y) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Math */ - public function sum($x, $y) + public function sum(mixed $x, mixed $y): Expr\Math { return new Expr\Math($x, '+', $y); } @@ -410,10 +359,8 @@ public function sum($x, $y) * * @param mixed $x Left expression. * @param mixed $y Right expression. - * - * @return Expr\Math */ - public function quot($x, $y) + public function quot(mixed $x, mixed $y): Expr\Math { return new Expr\Math($x, '/', $y); } @@ -422,10 +369,8 @@ public function quot($x, $y) * Creates a SQRT() function expression with the given argument. * * @param mixed $x Argument to be used in SQRT() function. - * - * @return Expr\Func */ - public function sqrt($x) + public function sqrt(mixed $x): Expr\Func { return new Expr\Func('SQRT', [$x]); } @@ -435,10 +380,8 @@ public function sqrt($x) * * @param string $x Field in string format to be restricted by IN() function. * @param mixed $y Argument to be used in IN() function. - * - * @return Expr\Func */ - public function in($x, $y) + public function in(string $x, mixed $y): Expr\Func { if (is_iterable($y)) { if ($y instanceof Traversable) { @@ -460,10 +403,8 @@ public function in($x, $y) * * @param string $x Field in string format to be restricted by NOT IN() function. * @param mixed $y Argument to be used in NOT IN() function. - * - * @return Expr\Func */ - public function notIn($x, $y) + public function notIn(string $x, mixed $y): Expr\Func { if (is_iterable($y)) { if ($y instanceof Traversable) { @@ -484,10 +425,8 @@ public function notIn($x, $y) * Creates an IS NULL expression with the given arguments. * * @param string $x Field in string format to be restricted by IS NULL. - * - * @return string */ - public function isNull($x) + public function isNull(string $x): string { return $x . ' IS NULL'; } @@ -496,10 +435,8 @@ public function isNull($x) * Creates an IS NOT NULL expression with the given arguments. * * @param string $x Field in string format to be restricted by IS NOT NULL. - * - * @return string */ - public function isNotNull($x) + public function isNotNull(string $x): string { return $x . ' IS NOT NULL'; } @@ -509,10 +446,8 @@ public function isNotNull($x) * * @param string $x Field in string format to be inspected by LIKE() comparison. * @param mixed $y Argument to be used in LIKE() comparison. - * - * @return Expr\Comparison */ - public function like($x, $y) + public function like(string $x, mixed $y): Expr\Comparison { return new Expr\Comparison($x, 'LIKE', $y); } @@ -522,10 +457,8 @@ public function like($x, $y) * * @param string $x Field in string format to be inspected by LIKE() comparison. * @param mixed $y Argument to be used in LIKE() comparison. - * - * @return Expr\Comparison */ - public function notLike($x, $y) + public function notLike(string $x, mixed $y): Expr\Comparison { return new Expr\Comparison($x, 'NOT LIKE', $y); } @@ -534,10 +467,8 @@ public function notLike($x, $y) * Creates a CONCAT() function expression with the given arguments. * * @param mixed ...$x Arguments to be used in CONCAT() function. - * - * @return Expr\Func */ - public function concat(mixed ...$x) + public function concat(mixed ...$x): Expr\Func { return new Expr\Func('CONCAT', $x); } @@ -548,10 +479,8 @@ public function concat(mixed ...$x) * @param mixed $x Argument to be used as string to be cropped by SUBSTRING() function. * @param int $from Initial offset to start cropping string. May accept negative values. * @param int|null $len Length of crop. May accept negative values. - * - * @return Expr\Func */ - public function substring($x, $from, $len = null) + public function substring(mixed $x, int $from, $len = null): Expr\Func { $args = [$x, $from]; if ($len !== null) { @@ -568,7 +497,7 @@ public function substring($x, $from, $len = null) * * @return Expr\Func A LOWER function expression. */ - public function lower($x) + public function lower(mixed $x): Expr\Func { return new Expr\Func('LOWER', [$x]); } @@ -580,7 +509,7 @@ public function lower($x) * * @return Expr\Func An UPPER function expression. */ - public function upper($x) + public function upper(mixed $x): Expr\Func { return new Expr\Func('UPPER', [$x]); } @@ -592,7 +521,7 @@ public function upper($x) * * @return Expr\Func A LENGTH function expression. */ - public function length($x) + public function length(mixed $x): Expr\Func { return new Expr\Func('LENGTH', [$x]); } @@ -601,10 +530,8 @@ public function length($x) * Creates a literal expression of the given argument. * * @param scalar $literal Argument to be converted to literal. - * - * @return Expr\Literal */ - public function literal($literal) + public function literal(mixed $literal): Expr\Literal { return new Expr\Literal($this->quoteLiteral($literal)); } @@ -614,7 +541,7 @@ public function literal($literal) * * @param scalar $literal The literal value. */ - private function quoteLiteral($literal): string + private function quoteLiteral(mixed $literal): string { if (is_int($literal) || is_float($literal)) { return (string) $literal; @@ -636,7 +563,7 @@ private function quoteLiteral($literal): string * * @return string A BETWEEN expression. */ - public function between($val, $x, $y) + public function between(mixed $val, int|string $x, int|string $y): string { return $val . ' BETWEEN ' . $x . ' AND ' . $y; } @@ -648,7 +575,7 @@ public function between($val, $x, $y) * * @return Expr\Func a TRIM expression. */ - public function trim($x) + public function trim(mixed $x): Expr\Func { return new Expr\Func('TRIM', $x); } @@ -658,10 +585,8 @@ public function trim($x) * * @param string $x Value to be checked * @param string $y Value to be checked against - * - * @return Expr\Comparison */ - public function isMemberOf($x, $y) + public function isMemberOf(string $x, string $y): Expr\Comparison { return new Expr\Comparison($x, 'MEMBER OF', $y); } @@ -671,10 +596,8 @@ public function isMemberOf($x, $y) * * @param string $x Value to be checked * @param string $y Value to be checked against - * - * @return Expr\Comparison */ - public function isInstanceOf($x, $y) + public function isInstanceOf(string $x, string $y): Expr\Comparison { return new Expr\Comparison($x, 'INSTANCE OF', $y); } diff --git a/lib/Doctrine/ORM/Query/Expr/Andx.php b/lib/Doctrine/ORM/Query/Expr/Andx.php index 229a4567963..a20bcef098f 100644 --- a/lib/Doctrine/ORM/Query/Expr/Andx.php +++ b/lib/Doctrine/ORM/Query/Expr/Andx.php @@ -11,11 +11,10 @@ */ class Andx extends Composite { - /** @var string */ - protected $separator = ' AND '; + protected string $separator = ' AND '; /** @var string[] */ - protected $allowedClasses = [ + protected array $allowedClasses = [ Comparison::class, Func::class, Orx::class, @@ -23,10 +22,10 @@ class Andx extends Composite ]; /** @psalm-var list */ - protected $parts = []; + protected array $parts = []; /** @psalm-return list */ - public function getParts() + public function getParts(): array { return $this->parts; } diff --git a/lib/Doctrine/ORM/Query/Expr/Base.php b/lib/Doctrine/ORM/Query/Expr/Base.php index 6fe3e347d5a..6fd5b82b923 100644 --- a/lib/Doctrine/ORM/Query/Expr/Base.php +++ b/lib/Doctrine/ORM/Query/Expr/Base.php @@ -8,7 +8,6 @@ use Stringable; use function count; -use function get_class; use function get_debug_type; use function implode; use function in_array; @@ -20,25 +19,19 @@ * * @link www.doctrine-project.org */ -abstract class Base +abstract class Base implements Stringable { - /** @var string */ - protected $preSeparator = '('; - - /** @var string */ - protected $separator = ', '; - - /** @var string */ - protected $postSeparator = ')'; + protected string $preSeparator = '('; + protected string $separator = ', '; + protected string $postSeparator = ')'; /** @var list */ - protected $allowedClasses = []; + protected array $allowedClasses = []; /** @var list */ - protected $parts = []; + protected array $parts = []; - /** @param mixed $args */ - public function __construct($args = []) + public function __construct(mixed $args = []) { $this->addMultiple($args); } @@ -49,7 +42,7 @@ public function __construct($args = []) * * @return $this */ - public function addMultiple($args = []) + public function addMultiple($args = []): static { foreach ((array) $args as $arg) { $this->add($arg); @@ -59,17 +52,15 @@ public function addMultiple($args = []) } /** - * @param mixed $arg - * * @return $this * * @throws InvalidArgumentException */ - public function add($arg) + public function add(mixed $arg): static { if ($arg !== null && (! $arg instanceof self || $arg->count() > 0)) { // If we decide to keep Expr\Base instances, we can use this check - if (! is_string($arg) && ! in_array(get_class($arg), $this->allowedClasses, true)) { + if (! is_string($arg) && ! in_array($arg::class, $this->allowedClasses, true)) { throw new InvalidArgumentException(sprintf( "Expression of type '%s' not allowed in this context.", get_debug_type($arg), @@ -82,17 +73,13 @@ public function add($arg) return $this; } - /** - * @return int - * @psalm-return 0|positive-int - */ - public function count() + /** @psalm-return 0|positive-int */ + public function count(): int { return count($this->parts); } - /** @return string */ - public function __toString() + public function __toString(): string { if ($this->count() === 1) { return (string) $this->parts[0]; diff --git a/lib/Doctrine/ORM/Query/Expr/Comparison.php b/lib/Doctrine/ORM/Query/Expr/Comparison.php index 152b6c98174..ec8ef21b2d9 100644 --- a/lib/Doctrine/ORM/Query/Expr/Comparison.php +++ b/lib/Doctrine/ORM/Query/Expr/Comparison.php @@ -4,51 +4,43 @@ namespace Doctrine\ORM\Query\Expr; +use Stringable; + /** * Expression class for DQL comparison expressions. * * @link www.doctrine-project.org */ -class Comparison +class Comparison implements Stringable { - public const EQ = '='; - public const NEQ = '<>'; - public const LT = '<'; - public const LTE = '<='; - public const GT = '>'; - public const GTE = '>='; - - /** - * Creates a comparison expression with the given arguments. - * - * @param mixed $leftExpr - * @param string $operator - * @param mixed $rightExpr - */ - public function __construct(protected $leftExpr, protected $operator, protected $rightExpr) + final public const EQ = '='; + final public const NEQ = '<>'; + final public const LT = '<'; + final public const LTE = '<='; + final public const GT = '>'; + final public const GTE = '>='; + + /** Creates a comparison expression with the given arguments. */ + public function __construct(protected mixed $leftExpr, protected string $operator, protected mixed $rightExpr) { } - /** @return mixed */ - public function getLeftExpr() + public function getLeftExpr(): mixed { return $this->leftExpr; } - /** @return string */ - public function getOperator() + public function getOperator(): string { return $this->operator; } - /** @return mixed */ - public function getRightExpr() + public function getRightExpr(): mixed { return $this->rightExpr; } - /** @return string */ - public function __toString() + public function __toString(): string { return $this->leftExpr . ' ' . $this->operator . ' ' . $this->rightExpr; } diff --git a/lib/Doctrine/ORM/Query/Expr/Composite.php b/lib/Doctrine/ORM/Query/Expr/Composite.php index 2270fbca34b..f3007a77534 100644 --- a/lib/Doctrine/ORM/Query/Expr/Composite.php +++ b/lib/Doctrine/ORM/Query/Expr/Composite.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\Expr; +use Stringable; + use function implode; use function is_object; use function preg_match; @@ -15,8 +17,7 @@ */ class Composite extends Base { - /** @return string */ - public function __toString() + public function __toString(): string { if ($this->count() === 1) { return (string) $this->parts[0]; @@ -31,8 +32,7 @@ public function __toString() return implode($this->separator, $components); } - /** @param string|object $part */ - private function processQueryPart($part): string + private function processQueryPart(string|Stringable $part): string { $queryPart = (string) $part; diff --git a/lib/Doctrine/ORM/Query/Expr/From.php b/lib/Doctrine/ORM/Query/Expr/From.php index 1157eb93478..21af0786e27 100644 --- a/lib/Doctrine/ORM/Query/Expr/From.php +++ b/lib/Doctrine/ORM/Query/Expr/From.php @@ -4,42 +4,43 @@ namespace Doctrine\ORM\Query\Expr; +use Stringable; + /** * Expression class for DQL from. * * @link www.doctrine-project.org */ -class From +class From implements Stringable { /** - * @param class-string $from The class name. - * @param string $alias The alias of the class. - * @param string $indexBy The index for the from. + * @param class-string $from The class name. + * @param string $alias The alias of the class. */ - public function __construct(protected $from, protected $alias, protected $indexBy = null) - { + public function __construct( + protected string $from, + protected string $alias, + protected string|null $indexBy = null, + ) { } /** @return class-string */ - public function getFrom() + public function getFrom(): string { return $this->from; } - /** @return string */ - public function getAlias() + public function getAlias(): string { return $this->alias; } - /** @return string|null */ - public function getIndexBy() + public function getIndexBy(): string|null { return $this->indexBy; } - /** @return string */ - public function __toString() + public function __toString(): string { return $this->from . ' ' . $this->alias . ($this->indexBy ? ' INDEX BY ' . $this->indexBy : ''); diff --git a/lib/Doctrine/ORM/Query/Expr/Func.php b/lib/Doctrine/ORM/Query/Expr/Func.php index 7c77979903e..1ecb8e25fae 100644 --- a/lib/Doctrine/ORM/Query/Expr/Func.php +++ b/lib/Doctrine/ORM/Query/Expr/Func.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\Expr; +use Stringable; + use function implode; /** @@ -11,37 +13,36 @@ * * @link www.doctrine-project.org */ -class Func +class Func implements Stringable { /** @var mixed[] */ - protected $arguments; + protected array $arguments; /** * Creates a function, with the given argument. * - * @param string $name * @param mixed[]|mixed $arguments * @psalm-param list|mixed $arguments */ - public function __construct(protected $name, $arguments) - { + public function __construct( + protected string $name, + $arguments, + ) { $this->arguments = (array) $arguments; } - /** @return string */ - public function getName() + public function getName(): string { return $this->name; } /** @psalm-return list */ - public function getArguments() + public function getArguments(): array { return $this->arguments; } - /** @return string */ - public function __toString() + public function __toString(): string { return $this->name . '(' . implode(', ', $this->arguments) . ')'; } diff --git a/lib/Doctrine/ORM/Query/Expr/GroupBy.php b/lib/Doctrine/ORM/Query/Expr/GroupBy.php index 178a48b231b..fa4625a6355 100644 --- a/lib/Doctrine/ORM/Query/Expr/GroupBy.php +++ b/lib/Doctrine/ORM/Query/Expr/GroupBy.php @@ -11,17 +11,14 @@ */ class GroupBy extends Base { - /** @var string */ - protected $preSeparator = ''; - - /** @var string */ - protected $postSeparator = ''; + protected string $preSeparator = ''; + protected string $postSeparator = ''; /** @psalm-var list */ - protected $parts = []; + protected array $parts = []; /** @psalm-return list */ - public function getParts() + public function getParts(): array { return $this->parts; } diff --git a/lib/Doctrine/ORM/Query/Expr/Join.php b/lib/Doctrine/ORM/Query/Expr/Join.php index 906af5640d4..c3b6dc9dd00 100644 --- a/lib/Doctrine/ORM/Query/Expr/Join.php +++ b/lib/Doctrine/ORM/Query/Expr/Join.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\Expr; +use Stringable; + use function strtoupper; /** @@ -11,13 +13,13 @@ * * @link www.doctrine-project.org */ -class Join +class Join implements Stringable { - public const INNER_JOIN = 'INNER'; - public const LEFT_JOIN = 'LEFT'; + final public const INNER_JOIN = 'INNER'; + final public const LEFT_JOIN = 'LEFT'; - public const ON = 'ON'; - public const WITH = 'WITH'; + final public const ON = 'ON'; + final public const WITH = 'WITH'; /** * @psalm-param self::INNER_JOIN|self::LEFT_JOIN $joinType diff --git a/lib/Doctrine/ORM/Query/Expr/Literal.php b/lib/Doctrine/ORM/Query/Expr/Literal.php index d3930fcb97d..0c130309c45 100644 --- a/lib/Doctrine/ORM/Query/Expr/Literal.php +++ b/lib/Doctrine/ORM/Query/Expr/Literal.php @@ -11,17 +11,14 @@ */ class Literal extends Base { - /** @var string */ - protected $preSeparator = ''; - - /** @var string */ - protected $postSeparator = ''; + protected string $preSeparator = ''; + protected string $postSeparator = ''; /** @psalm-var list */ - protected $parts = []; + protected array $parts = []; /** @psalm-return list */ - public function getParts() + public function getParts(): array { return $this->parts; } diff --git a/lib/Doctrine/ORM/Query/Expr/Math.php b/lib/Doctrine/ORM/Query/Expr/Math.php index 42b165aa708..05e0b39b6b8 100644 --- a/lib/Doctrine/ORM/Query/Expr/Math.php +++ b/lib/Doctrine/ORM/Query/Expr/Math.php @@ -4,44 +4,41 @@ namespace Doctrine\ORM\Query\Expr; +use Stringable; + /** * Expression class for DQL math statements. * * @link www.doctrine-project.org */ -class Math +class Math implements Stringable { /** * Creates a mathematical expression with the given arguments. - * - * @param mixed $leftExpr - * @param string $operator - * @param mixed $rightExpr */ - public function __construct(protected $leftExpr, protected $operator, protected $rightExpr) - { + public function __construct( + protected mixed $leftExpr, + protected string $operator, + protected mixed $rightExpr, + ) { } - /** @return mixed */ - public function getLeftExpr() + public function getLeftExpr(): mixed { return $this->leftExpr; } - /** @return string */ - public function getOperator() + public function getOperator(): string { return $this->operator; } - /** @return mixed */ - public function getRightExpr() + public function getRightExpr(): mixed { return $this->rightExpr; } - /** @return string */ - public function __toString() + public function __toString(): string { // Adjusting Left Expression $leftExpr = (string) $this->leftExpr; diff --git a/lib/Doctrine/ORM/Query/Expr/OrderBy.php b/lib/Doctrine/ORM/Query/Expr/OrderBy.php index dc6cfbd78ee..ac9e1601563 100644 --- a/lib/Doctrine/ORM/Query/Expr/OrderBy.php +++ b/lib/Doctrine/ORM/Query/Expr/OrderBy.php @@ -4,6 +4,8 @@ namespace Doctrine\ORM\Query\Expr; +use Stringable; + use function count; use function implode; @@ -12,63 +14,46 @@ * * @link www.doctrine-project.org */ -class OrderBy +class OrderBy implements Stringable { - /** @var string */ - protected $preSeparator = ''; - - /** @var string */ - protected $separator = ', '; - - /** @var string */ - protected $postSeparator = ''; + protected string $preSeparator = ''; + protected string $separator = ', '; + protected string $postSeparator = ''; /** @var string[] */ - protected $allowedClasses = []; + protected array $allowedClasses = []; /** @psalm-var list */ - protected $parts = []; + protected array $parts = []; - /** - * @param string|null $sort - * @param string|null $order - */ - public function __construct($sort = null, $order = null) - { + public function __construct( + string|null $sort = null, + string|null $order = null, + ) { if ($sort) { $this->add($sort, $order); } } - /** - * @param string $sort - * @param string|null $order - * - * @return void - */ - public function add($sort, $order = null) + public function add(string $sort, string|null $order = null): void { $order = ! $order ? 'ASC' : $order; $this->parts[] = $sort . ' ' . $order; } - /** - * @return int - * @psalm-return 0|positive-int - */ - public function count() + /** @psalm-return 0|positive-int */ + public function count(): int { return count($this->parts); } /** @psalm-return list */ - public function getParts() + public function getParts(): array { return $this->parts; } - /** @return string */ - public function __toString() + public function __toString(): string { return $this->preSeparator . implode($this->separator, $this->parts) . $this->postSeparator; } diff --git a/lib/Doctrine/ORM/Query/Expr/Orx.php b/lib/Doctrine/ORM/Query/Expr/Orx.php index 2d3ae0df00d..2ae23320168 100644 --- a/lib/Doctrine/ORM/Query/Expr/Orx.php +++ b/lib/Doctrine/ORM/Query/Expr/Orx.php @@ -11,11 +11,10 @@ */ class Orx extends Composite { - /** @var string */ - protected $separator = ' OR '; + protected string $separator = ' OR '; /** @var string[] */ - protected $allowedClasses = [ + protected array $allowedClasses = [ Comparison::class, Func::class, Andx::class, @@ -23,10 +22,10 @@ class Orx extends Composite ]; /** @psalm-var list */ - protected $parts = []; + protected array $parts = []; /** @psalm-return list */ - public function getParts() + public function getParts(): array { return $this->parts; } diff --git a/lib/Doctrine/ORM/Query/Expr/Select.php b/lib/Doctrine/ORM/Query/Expr/Select.php index a3929fb08ad..91b0b600949 100644 --- a/lib/Doctrine/ORM/Query/Expr/Select.php +++ b/lib/Doctrine/ORM/Query/Expr/Select.php @@ -11,20 +11,17 @@ */ class Select extends Base { - /** @var string */ - protected $preSeparator = ''; - - /** @var string */ - protected $postSeparator = ''; + protected string $preSeparator = ''; + protected string $postSeparator = ''; /** @var string[] */ - protected $allowedClasses = [Func::class]; + protected array $allowedClasses = [Func::class]; /** @psalm-var list */ - protected $parts = []; + protected array $parts = []; /** @psalm-return list */ - public function getParts() + public function getParts(): array { return $this->parts; } diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index 651c0d0dec7..1732f4465a9 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -23,88 +23,88 @@ class Lexer extends AbstractLexer { // All tokens that are not valid identifiers must be < 100 - public const T_NONE = 1; - public const T_INTEGER = 2; - public const T_STRING = 3; - public const T_INPUT_PARAMETER = 4; - public const T_FLOAT = 5; - public const T_CLOSE_PARENTHESIS = 6; - public const T_OPEN_PARENTHESIS = 7; - public const T_COMMA = 8; - public const T_DIVIDE = 9; - public const T_DOT = 10; - public const T_EQUALS = 11; - public const T_GREATER_THAN = 12; - public const T_LOWER_THAN = 13; - public const T_MINUS = 14; - public const T_MULTIPLY = 15; - public const T_NEGATE = 16; - public const T_PLUS = 17; - public const T_OPEN_CURLY_BRACE = 18; - public const T_CLOSE_CURLY_BRACE = 19; + final public const T_NONE = 1; + final public const T_INTEGER = 2; + final public const T_STRING = 3; + final public const T_INPUT_PARAMETER = 4; + final public const T_FLOAT = 5; + final public const T_CLOSE_PARENTHESIS = 6; + final public const T_OPEN_PARENTHESIS = 7; + final public const T_COMMA = 8; + final public const T_DIVIDE = 9; + final public const T_DOT = 10; + final public const T_EQUALS = 11; + final public const T_GREATER_THAN = 12; + final public const T_LOWER_THAN = 13; + final public const T_MINUS = 14; + final public const T_MULTIPLY = 15; + final public const T_NEGATE = 16; + final public const T_PLUS = 17; + final public const T_OPEN_CURLY_BRACE = 18; + final public const T_CLOSE_CURLY_BRACE = 19; // All tokens that are identifiers or keywords that could be considered as identifiers should be >= 100 - public const T_FULLY_QUALIFIED_NAME = 101; - public const T_IDENTIFIER = 102; + final public const T_FULLY_QUALIFIED_NAME = 101; + final public const T_IDENTIFIER = 102; // All keyword tokens should be >= 200 - public const T_ALL = 200; - public const T_AND = 201; - public const T_ANY = 202; - public const T_AS = 203; - public const T_ASC = 204; - public const T_AVG = 205; - public const T_BETWEEN = 206; - public const T_BOTH = 207; - public const T_BY = 208; - public const T_CASE = 209; - public const T_COALESCE = 210; - public const T_COUNT = 211; - public const T_DELETE = 212; - public const T_DESC = 213; - public const T_DISTINCT = 214; - public const T_ELSE = 215; - public const T_EMPTY = 216; - public const T_END = 217; - public const T_ESCAPE = 218; - public const T_EXISTS = 219; - public const T_FALSE = 220; - public const T_FROM = 221; - public const T_GROUP = 222; - public const T_HAVING = 223; - public const T_HIDDEN = 224; - public const T_IN = 225; - public const T_INDEX = 226; - public const T_INNER = 227; - public const T_INSTANCE = 228; - public const T_IS = 229; - public const T_JOIN = 230; - public const T_LEADING = 231; - public const T_LEFT = 232; - public const T_LIKE = 233; - public const T_MAX = 234; - public const T_MEMBER = 235; - public const T_MIN = 236; - public const T_NEW = 237; - public const T_NOT = 238; - public const T_NULL = 239; - public const T_NULLIF = 240; - public const T_OF = 241; - public const T_OR = 242; - public const T_ORDER = 243; - public const T_OUTER = 244; - public const T_PARTIAL = 245; - public const T_SELECT = 246; - public const T_SET = 247; - public const T_SOME = 248; - public const T_SUM = 249; - public const T_THEN = 250; - public const T_TRAILING = 251; - public const T_TRUE = 252; - public const T_UPDATE = 253; - public const T_WHEN = 254; - public const T_WHERE = 255; - public const T_WITH = 256; + final public const T_ALL = 200; + final public const T_AND = 201; + final public const T_ANY = 202; + final public const T_AS = 203; + final public const T_ASC = 204; + final public const T_AVG = 205; + final public const T_BETWEEN = 206; + final public const T_BOTH = 207; + final public const T_BY = 208; + final public const T_CASE = 209; + final public const T_COALESCE = 210; + final public const T_COUNT = 211; + final public const T_DELETE = 212; + final public const T_DESC = 213; + final public const T_DISTINCT = 214; + final public const T_ELSE = 215; + final public const T_EMPTY = 216; + final public const T_END = 217; + final public const T_ESCAPE = 218; + final public const T_EXISTS = 219; + final public const T_FALSE = 220; + final public const T_FROM = 221; + final public const T_GROUP = 222; + final public const T_HAVING = 223; + final public const T_HIDDEN = 224; + final public const T_IN = 225; + final public const T_INDEX = 226; + final public const T_INNER = 227; + final public const T_INSTANCE = 228; + final public const T_IS = 229; + final public const T_JOIN = 230; + final public const T_LEADING = 231; + final public const T_LEFT = 232; + final public const T_LIKE = 233; + final public const T_MAX = 234; + final public const T_MEMBER = 235; + final public const T_MIN = 236; + final public const T_NEW = 237; + final public const T_NOT = 238; + final public const T_NULL = 239; + final public const T_NULLIF = 240; + final public const T_OF = 241; + final public const T_OR = 242; + final public const T_ORDER = 243; + final public const T_OUTER = 244; + final public const T_PARTIAL = 245; + final public const T_SELECT = 246; + final public const T_SET = 247; + final public const T_SOME = 248; + final public const T_SUM = 249; + final public const T_THEN = 250; + final public const T_TRAILING = 251; + final public const T_TRUE = 252; + final public const T_UPDATE = 253; + final public const T_WHEN = 254; + final public const T_WHERE = 255; + final public const T_WITH = 256; /** * Creates a new query scanner object. @@ -119,7 +119,7 @@ public function __construct($input) /** * {@inheritdoc} */ - protected function getCatchablePatterns() + protected function getCatchablePatterns(): array { return [ '[a-z_][a-z0-9_]*\:[a-z_][a-z0-9_]*(?:\\\[a-z_][a-z0-9_]*)*', // aliased name @@ -133,7 +133,7 @@ protected function getCatchablePatterns() /** * {@inheritdoc} */ - protected function getNonCatchablePatterns() + protected function getNonCatchablePatterns(): array { return ['\s+', '--.*', '(.)']; } From 8c732120bc0f35f6ff78791a6b6f7e4617501b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 4 Dec 2022 22:28:19 +0100 Subject: [PATCH 193/475] Use intersection types (#10255) We could not do that before, because it would make Psalm crash. --- lib/Doctrine/ORM/LazyCriteriaCollection.php | 2 +- lib/Doctrine/ORM/PersistentCollection.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/LazyCriteriaCollection.php b/lib/Doctrine/ORM/LazyCriteriaCollection.php index a33a1b28f5d..34dd27e3806 100644 --- a/lib/Doctrine/ORM/LazyCriteriaCollection.php +++ b/lib/Doctrine/ORM/LazyCriteriaCollection.php @@ -80,7 +80,7 @@ public function contains(mixed $element): bool } /** @return ReadableCollection&Selectable */ - public function matching(Criteria $criteria): ReadableCollection + public function matching(Criteria $criteria): ReadableCollection&Selectable { $this->initialize(); assert($this->collection instanceof Selectable); diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index e103c344707..f45d091d85f 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -614,7 +614,7 @@ public function matching(Criteria $criteria): Collection * * @return Collection&Selectable */ - public function unwrap(): Collection + public function unwrap(): Collection&Selectable { assert($this->collection instanceof Collection); assert($this->collection instanceof Selectable); From 9e578a4f0d0c86f35472ff5b101e984e835543d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 5 Dec 2022 22:38:16 +0100 Subject: [PATCH 194/475] Migrate AST namespace to PHP 8 syntax (#10219) * Migrate AST namespace to PHP 8 syntax * Use typed properties when type is non-object We know the phpdoc types in that namespace are pretty messed up, but it should be safe to assume that's only the case when the type is an object type. --- lib/Doctrine/ORM/Query/AST/ASTException.php | 7 +--- .../ORM/Query/AST/AggregateExpression.php | 18 +++------ .../ORM/Query/AST/ArithmeticExpression.php | 6 +-- .../ORM/Query/AST/ArithmeticFactor.php | 24 +++--------- lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php | 6 +-- .../ORM/Query/AST/BetweenExpression.php | 30 +++++---------- .../ORM/Query/AST/CoalesceExpression.php | 6 +-- .../Query/AST/CollectionMemberExpression.php | 24 +++--------- .../ORM/Query/AST/ComparisonExpression.php | 20 ++++------ .../ORM/Query/AST/ConditionalExpression.php | 6 +-- .../ORM/Query/AST/ConditionalPrimary.php | 6 +-- .../ORM/Query/AST/ConditionalTerm.php | 6 +-- lib/Doctrine/ORM/Query/AST/DeleteClause.php | 6 +-- lib/Doctrine/ORM/Query/AST/FromClause.php | 6 +-- .../Query/AST/Functions/ConcatFunction.php | 2 +- .../Query/AST/Functions/DateAddFunction.php | 2 +- .../Query/AST/Functions/IdentityFunction.php | 3 +- .../ORM/Query/AST/GeneralCaseExpression.php | 15 +++----- lib/Doctrine/ORM/Query/AST/GroupByClause.php | 6 +-- lib/Doctrine/ORM/Query/AST/InExpression.php | 5 +-- .../ORM/Query/AST/InListExpression.php | 8 +--- lib/Doctrine/ORM/Query/AST/IndexBy.php | 6 +-- lib/Doctrine/ORM/Query/AST/InputParameter.php | 17 +++------ .../ORM/Query/AST/InstanceOfExpression.php | 9 +---- lib/Doctrine/ORM/Query/AST/Join.php | 20 ++++------ .../Query/AST/JoinAssociationDeclaration.php | 8 ++-- .../AST/JoinAssociationPathExpression.php | 10 ++--- .../ORM/Query/AST/JoinClassPathExpression.php | 14 ++----- lib/Doctrine/ORM/Query/AST/Literal.php | 25 ++++-------- .../ORM/Query/AST/NewObjectExpression.php | 11 +----- lib/Doctrine/ORM/Query/AST/Node.php | 14 ++----- .../ORM/Query/AST/NullIfExpression.php | 6 +-- lib/Doctrine/ORM/Query/AST/OrderByClause.php | 6 +-- lib/Doctrine/ORM/Query/AST/OrderByItem.php | 12 ++---- .../ORM/Query/AST/ParenthesisExpression.php | 6 +-- .../ORM/Query/AST/PartialObjectExpression.php | 15 +++----- lib/Doctrine/ORM/Query/AST/PathExpression.php | 38 +++++++------------ .../ORM/Query/AST/QuantifiedExpression.php | 12 ++---- .../Query/AST/RangeVariableDeclaration.php | 16 +++----- lib/Doctrine/ORM/Query/AST/SelectClause.php | 15 +++----- .../ORM/Query/AST/SelectExpression.php | 12 +++--- .../Query/AST/SimpleArithmeticExpression.php | 6 +-- .../ORM/Query/AST/SimpleCaseExpression.php | 3 +- .../ORM/Query/AST/SimpleSelectClause.php | 11 +++--- .../ORM/Query/AST/SimpleSelectExpression.php | 3 +- .../ORM/Query/AST/SimpleWhenClause.php | 10 ++--- .../ORM/Query/AST/SubselectFromClause.php | 6 +-- ...electIdentificationVariableDeclaration.php | 11 +++--- lib/Doctrine/ORM/Query/AST/UpdateClause.php | 18 +++------ lib/Doctrine/ORM/Query/AST/WhenClause.php | 11 +++--- lib/Doctrine/ORM/Query/Parser.php | 1 + psalm-baseline.xml | 13 +------ 52 files changed, 176 insertions(+), 401 deletions(-) diff --git a/lib/Doctrine/ORM/Query/AST/ASTException.php b/lib/Doctrine/ORM/Query/AST/ASTException.php index de99519a367..1ef890acfc7 100644 --- a/lib/Doctrine/ORM/Query/AST/ASTException.php +++ b/lib/Doctrine/ORM/Query/AST/ASTException.php @@ -13,12 +13,7 @@ */ class ASTException extends QueryException { - /** - * @param Node $node - * - * @return ASTException - */ - public static function noDispatchForNode($node) + public static function noDispatchForNode(Node $node): self { return new self('Double-dispatch for node ' . get_debug_type($node) . ' is not supported.'); } diff --git a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php index d8ff21b9cfa..087fbff8422 100644 --- a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php +++ b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php @@ -9,20 +9,14 @@ class AggregateExpression extends Node { /** - * Some aggregate expressions support distinct, eg COUNT. - * - * @var bool - */ - public $isDistinct = false; - - /** - * @param string $functionName * @param PathExpression|SimpleArithmeticExpression $pathExpression - * @param bool $isDistinct + * @param bool $isDistinct Some aggregate expressions support distinct, eg COUNT. */ - public function __construct(public $functionName, public $pathExpression, $isDistinct) - { - $this->isDistinct = $isDistinct; + public function __construct( + public string $functionName, + public $pathExpression, + public bool $isDistinct, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php index f103f466bd0..70c63b49738 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php @@ -19,14 +19,12 @@ class ArithmeticExpression extends Node /** @var Subselect|null */ public $subselect; - /** @return bool */ - public function isSimpleArithmeticExpression() + public function isSimpleArithmeticExpression(): bool { return (bool) $this->simpleArithmeticExpression; } - /** @return bool */ - public function isSubselect() + public function isSubselect(): bool { return (bool) $this->subselect; } diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php b/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php index 9e33084ae4f..278a921084b 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php @@ -13,30 +13,18 @@ */ class ArithmeticFactor extends Node { - /** - * NULL represents no sign, TRUE means positive and FALSE means negative sign. - * - * @var bool|null - */ - public $sign; - - /** - * @param mixed $arithmeticPrimary - * @param bool|null $sign - */ - public function __construct(public $arithmeticPrimary, $sign = null) - { - $this->sign = $sign; + public function __construct( + public mixed $arithmeticPrimary, + public bool|null $sign = null, + ) { } - /** @return bool */ - public function isPositiveSigned() + public function isPositiveSigned(): bool { return $this->sign === true; } - /** @return bool */ - public function isNegativeSigned() + public function isNegativeSigned(): bool { return $this->sign === false; } diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php b/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php index 955ed3c6c8f..b23361264bb 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php @@ -13,13 +13,9 @@ */ class ArithmeticTerm extends Node { - /** @var mixed[] */ - public $arithmeticFactors; - /** @param mixed[] $arithmeticFactors */ - public function __construct(array $arithmeticFactors) + public function __construct(public array $arithmeticFactors) { - $this->arithmeticFactors = $arithmeticFactors; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php b/lib/Doctrine/ORM/Query/AST/BetweenExpression.php index 1bb8942ec28..24f351cbc25 100644 --- a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php +++ b/lib/Doctrine/ORM/Query/AST/BetweenExpression.php @@ -8,29 +8,17 @@ class BetweenExpression extends Node { - /** @var ArithmeticExpression */ - public $expression; - - /** @var ArithmeticExpression */ - public $leftBetweenExpression; - - /** @var ArithmeticExpression */ - public $rightBetweenExpression; - - /** @var bool */ - public $not; - /** - * @param ArithmeticExpression $expr - * @param ArithmeticExpression $leftExpr - * @param ArithmeticExpression $rightExpr + * @param ArithmeticExpression $expression + * @param ArithmeticExpression $leftBetweenExpression + * @param ArithmeticExpression $rightBetweenExpression */ - public function __construct($expr, $leftExpr, $rightExpr, bool $not = false) - { - $this->expression = $expr; - $this->leftBetweenExpression = $leftExpr; - $this->rightBetweenExpression = $rightExpr; - $this->not = $not; + public function __construct( + public $expression, + public $leftBetweenExpression, + public $rightBetweenExpression, + public bool $not = false, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php b/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php index 77723fe6714..89f025f6d13 100644 --- a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php +++ b/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php @@ -13,13 +13,9 @@ */ class CoalesceExpression extends Node { - /** @var mixed[] */ - public $scalarExpressions = []; - /** @param mixed[] $scalarExpressions */ - public function __construct(array $scalarExpressions) + public function __construct(public array $scalarExpressions) { - $this->scalarExpressions = $scalarExpressions; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php b/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php index c8ae9c92120..b926003e21c 100644 --- a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php +++ b/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php @@ -13,24 +13,12 @@ */ class CollectionMemberExpression extends Node { - /** @var mixed */ - public $entityExpression; - - /** @var PathExpression */ - public $collectionValuedPathExpression; - - /** @var bool */ - public $not; - - /** - * @param mixed $entityExpr - * @param PathExpression $collValuedPathExpr - */ - public function __construct($entityExpr, $collValuedPathExpr, bool $not = false) - { - $this->entityExpression = $entityExpr; - $this->collectionValuedPathExpression = $collValuedPathExpr; - $this->not = $not; + /** @param PathExpression $collectionValuedPathExpression */ + public function __construct( + public mixed $entityExpression, + public $collectionValuedPathExpression, + public bool $not = false, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php index 4842de7e1e1..2c28c461b92 100644 --- a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php @@ -18,21 +18,15 @@ */ class ComparisonExpression extends Node { - /** @var Node|string */ - public $leftExpression; - - /** @var Node|string */ - public $rightExpression; - /** - * @param Node|string $leftExpr - * @param string $operator - * @param Node|string $rightExpr + * @param Node|string $leftExpression + * @param Node|string $rightExpression */ - public function __construct($leftExpr, public $operator, $rightExpr) - { - $this->leftExpression = $leftExpr; - $this->rightExpression = $rightExpr; + public function __construct( + public $leftExpression, + public string $operator, + public $rightExpression, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php b/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php index e0065bedab2..26a98e53300 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php @@ -13,13 +13,9 @@ */ class ConditionalExpression extends Node { - /** @var mixed[] */ - public $conditionalTerms = []; - /** @param mixed[] $conditionalTerms */ - public function __construct(array $conditionalTerms) + public function __construct(public array $conditionalTerms) { - $this->conditionalTerms = $conditionalTerms; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php index 1670ba9a38e..a8015703301 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php @@ -19,14 +19,12 @@ class ConditionalPrimary extends Node /** @var ConditionalExpression|null */ public $conditionalExpression; - /** @return bool */ - public function isSimpleConditionalExpression() + public function isSimpleConditionalExpression(): bool { return (bool) $this->simpleConditionalExpression; } - /** @return bool */ - public function isConditionalExpression() + public function isConditionalExpression(): bool { return (bool) $this->conditionalExpression; } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php b/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php index ad40b40d554..36af59879d0 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php @@ -13,13 +13,9 @@ */ class ConditionalTerm extends Node { - /** @var mixed[] */ - public $conditionalFactors = []; - /** @param mixed[] $conditionalFactors */ - public function __construct(array $conditionalFactors) + public function __construct(public array $conditionalFactors) { - $this->conditionalFactors = $conditionalFactors; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/DeleteClause.php b/lib/Doctrine/ORM/Query/AST/DeleteClause.php index 8bd5279c751..25e90854751 100644 --- a/lib/Doctrine/ORM/Query/AST/DeleteClause.php +++ b/lib/Doctrine/ORM/Query/AST/DeleteClause.php @@ -13,11 +13,9 @@ */ class DeleteClause extends Node { - /** @var string */ - public $aliasIdentificationVariable; + public string $aliasIdentificationVariable; - /** @param string $abstractSchemaName */ - public function __construct(public $abstractSchemaName) + public function __construct(public string $abstractSchemaName) { } diff --git a/lib/Doctrine/ORM/Query/AST/FromClause.php b/lib/Doctrine/ORM/Query/AST/FromClause.php index 0109de87336..0b74393b635 100644 --- a/lib/Doctrine/ORM/Query/AST/FromClause.php +++ b/lib/Doctrine/ORM/Query/AST/FromClause.php @@ -13,13 +13,9 @@ */ class FromClause extends Node { - /** @var mixed[] */ - public $identificationVariableDeclarations = []; - /** @param mixed[] $identificationVariableDeclarations */ - public function __construct(array $identificationVariableDeclarations) + public function __construct(public array $identificationVariableDeclarations) { - $this->identificationVariableDeclarations = $identificationVariableDeclarations; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php index 4c530bbda9f..976a5a4bff1 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php @@ -20,7 +20,7 @@ class ConcatFunction extends FunctionNode public Node $secondStringPrimary; /** @psalm-var list */ - public $concatExpressions = []; + public array $concatExpressions = []; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php index aaed131184e..33aca04f780 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php @@ -68,7 +68,7 @@ public function getSql(SqlWalker $sqlWalker): string * * @throws ASTException */ - private function dispatchIntervalExpression(SqlWalker $sqlWalker) + private function dispatchIntervalExpression(SqlWalker $sqlWalker): string { $sql = $this->intervalExpression->dispatch($sqlWalker); assert(is_numeric($sql)); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 74726e17b49..7b6e188879a 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -24,8 +24,7 @@ class IdentityFunction extends FunctionNode /** @var PathExpression */ public $pathExpression; - /** @var string|null */ - public $fieldMapping; + public string|null $fieldMapping = null; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php b/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php index 4fd4594d5de..39d760a26b9 100644 --- a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php @@ -13,16 +13,11 @@ */ class GeneralCaseExpression extends Node { - /** @var mixed[] */ - public $whenClauses = []; - - /** - * @param mixed[] $whenClauses - * @param mixed $elseScalarExpression - */ - public function __construct(array $whenClauses, public $elseScalarExpression = null) - { - $this->whenClauses = $whenClauses; + /** @param mixed[] $whenClauses */ + public function __construct( + public array $whenClauses, + public mixed $elseScalarExpression = null, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/GroupByClause.php b/lib/Doctrine/ORM/Query/AST/GroupByClause.php index 50f0de8d768..eb0f1b9f89c 100644 --- a/lib/Doctrine/ORM/Query/AST/GroupByClause.php +++ b/lib/Doctrine/ORM/Query/AST/GroupByClause.php @@ -8,13 +8,9 @@ class GroupByClause extends Node { - /** @var mixed[] */ - public $groupByItems = []; - /** @param mixed[] $groupByItems */ - public function __construct(array $groupByItems) + public function __construct(public array $groupByItems) { - $this->groupByItems = $groupByItems; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/InExpression.php b/lib/Doctrine/ORM/Query/AST/InExpression.php index 5425af347b5..8cb3c3ff092 100644 --- a/lib/Doctrine/ORM/Query/AST/InExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InExpression.php @@ -14,11 +14,10 @@ */ class InExpression extends Node { - /** @var bool */ - public $not; + public bool $not = false; /** @var mixed[] */ - public $literals = []; + public array $literals = []; /** @var Subselect|null */ public $subselect; diff --git a/lib/Doctrine/ORM/Query/AST/InListExpression.php b/lib/Doctrine/ORM/Query/AST/InListExpression.php index 10fda3adbff..bd240fdfad6 100644 --- a/lib/Doctrine/ORM/Query/AST/InListExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InListExpression.php @@ -6,14 +6,10 @@ class InListExpression extends InExpression { - /** @var non-empty-list */ - public $literals; - /** @param non-empty-list $literals */ - public function __construct(ArithmeticExpression $expression, array $literals, bool $not = false) + public function __construct(ArithmeticExpression $expression, public array $literals, bool $not = false) { - $this->literals = $literals; - $this->not = $not; + $this->not = $not; parent::__construct($expression); } diff --git a/lib/Doctrine/ORM/Query/AST/IndexBy.php b/lib/Doctrine/ORM/Query/AST/IndexBy.php index 58ccc9a7300..3d90265bc58 100644 --- a/lib/Doctrine/ORM/Query/AST/IndexBy.php +++ b/lib/Doctrine/ORM/Query/AST/IndexBy.php @@ -13,12 +13,8 @@ */ class IndexBy extends Node { - /** @var PathExpression */ - public $singleValuedPathExpression = null; - - public function __construct(PathExpression $singleValuedPathExpression) + public function __construct(public PathExpression $singleValuedPathExpression) { - $this->singleValuedPathExpression = $singleValuedPathExpression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/InputParameter.php b/lib/Doctrine/ORM/Query/AST/InputParameter.php index 7a6ab07e760..a8e0a3b9f7f 100644 --- a/lib/Doctrine/ORM/Query/AST/InputParameter.php +++ b/lib/Doctrine/ORM/Query/AST/InputParameter.php @@ -13,18 +13,11 @@ class InputParameter extends Node { - /** @var bool */ - public $isNamed; - - /** @var string */ - public $name; - - /** - * @param string $value - * - * @throws QueryException - */ - public function __construct($value) + public bool $isNamed; + public string $name; + + /** @throws QueryException */ + public function __construct(string $value) { if (strlen($value) === 1) { throw QueryException::invalidParameterFormat($value); diff --git a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php index 8964b312a85..bd6628f2459 100644 --- a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php @@ -17,15 +17,12 @@ */ class InstanceOfExpression extends Node { - /** @var string */ - public $identificationVariable; - /** - * @param string $identVariable + * @param string $identificationVariable * @param non-empty-list $value */ public function __construct( - $identVariable, + public $identificationVariable, public array $value = [], public bool $not = false, ) { @@ -37,8 +34,6 @@ public function __construct( __METHOD__, ); } - - $this->identificationVariable = $identVariable; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/Join.php b/lib/Doctrine/ORM/Query/AST/Join.php index 96a1b6ab78b..0a0b1afc9d5 100644 --- a/lib/Doctrine/ORM/Query/AST/Join.php +++ b/lib/Doctrine/ORM/Query/AST/Join.php @@ -14,27 +14,21 @@ */ class Join extends Node { - public const JOIN_TYPE_LEFT = 1; - public const JOIN_TYPE_LEFTOUTER = 2; - public const JOIN_TYPE_INNER = 3; - - /** - * @var int - * @psalm-var self::JOIN_TYPE_* - */ - public $joinType = self::JOIN_TYPE_INNER; + final public const JOIN_TYPE_LEFT = 1; + final public const JOIN_TYPE_LEFTOUTER = 2; + final public const JOIN_TYPE_INNER = 3; /** @var ConditionalExpression|null */ public $conditionalExpression = null; /** - * @param int $joinType * @param Node $joinAssociationDeclaration * @psalm-param self::JOIN_TYPE_* $joinType */ - public function __construct($joinType, public $joinAssociationDeclaration = null) - { - $this->joinType = $joinType; + public function __construct( + public int $joinType, + public $joinAssociationDeclaration = null, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php index 0beb7369c0b..1ac8b863a07 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php @@ -15,11 +15,13 @@ class JoinAssociationDeclaration extends Node { /** * @param JoinAssociationPathExpression $joinAssociationPathExpression - * @param string $aliasIdentificationVariable * @param IndexBy|null $indexBy */ - public function __construct(public $joinAssociationPathExpression, public $aliasIdentificationVariable, public $indexBy) - { + public function __construct( + public $joinAssociationPathExpression, + public string $aliasIdentificationVariable, + public $indexBy, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php b/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php index 708d58297fc..230be36a0fa 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php @@ -11,11 +11,9 @@ */ class JoinAssociationPathExpression extends Node { - /** - * @param string $identificationVariable - * @param string $associationField - */ - public function __construct(public $identificationVariable, public $associationField) - { + public function __construct( + public string $identificationVariable, + public string $associationField, + ) { } } diff --git a/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php b/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php index dc4f215c919..cc9278278ed 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php @@ -13,16 +13,10 @@ */ class JoinClassPathExpression extends Node { - /** @var mixed */ - public $aliasIdentificationVariable; - - /** - * @param mixed $abstractSchemaName - * @param mixed $aliasIdentificationVar - */ - public function __construct(public $abstractSchemaName, $aliasIdentificationVar) - { - $this->aliasIdentificationVariable = $aliasIdentificationVar; + public function __construct( + public mixed $abstractSchemaName, + public mixed $aliasIdentificationVariable, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/Literal.php b/lib/Doctrine/ORM/Query/AST/Literal.php index 0810e27de5a..9ec20366c0d 100644 --- a/lib/Doctrine/ORM/Query/AST/Literal.php +++ b/lib/Doctrine/ORM/Query/AST/Literal.php @@ -8,24 +8,15 @@ class Literal extends Node { - public const STRING = 1; - public const BOOLEAN = 2; - public const NUMERIC = 3; + final public const STRING = 1; + final public const BOOLEAN = 2; + final public const NUMERIC = 3; - /** - * @var int - * @psalm-var self::* - */ - public $type; - - /** - * @param int $type - * @param mixed $value - * @psalm-param self::* $type - */ - public function __construct($type, public $value) - { - $this->type = $type; + /** @psalm-param self::* $type */ + public function __construct( + public int $type, + public mixed $value, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php b/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php index 451d4881144..7383c487234 100644 --- a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php @@ -13,16 +13,9 @@ */ class NewObjectExpression extends Node { - /** @var mixed[] */ - public $args; - - /** - * @param string $className - * @param mixed[] $args - */ - public function __construct(public $className, array $args) + /** @param mixed[] $args */ + public function __construct(public string $className, public array $args) { - $this->args = $args; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/Node.php b/lib/Doctrine/ORM/Query/AST/Node.php index 8f8079135a0..cdb58552c96 100644 --- a/lib/Doctrine/ORM/Query/AST/Node.php +++ b/lib/Doctrine/ORM/Query/AST/Node.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\SqlWalker; +use Stringable; use function get_debug_type; use function get_object_vars; @@ -20,7 +21,7 @@ * * @link www.doctrine-project.org */ -abstract class Node +abstract class Node implements Stringable { /** * Double-dispatch method, supposed to dispatch back to the walker. @@ -36,20 +37,13 @@ public function dispatch(SqlWalker $walker): string /** * Dumps the AST Node into a string representation for information purpose only. - * - * @return string */ - public function __toString() + public function __toString(): string { return $this->dump($this); } - /** - * @param mixed $value - * - * @return string - */ - public function dump($value) + public function dump(mixed $value): string { static $ident = 0; diff --git a/lib/Doctrine/ORM/Query/AST/NullIfExpression.php b/lib/Doctrine/ORM/Query/AST/NullIfExpression.php index 52b546f0282..6fffeeb082c 100644 --- a/lib/Doctrine/ORM/Query/AST/NullIfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NullIfExpression.php @@ -13,11 +13,7 @@ */ class NullIfExpression extends Node { - /** - * @param mixed $firstExpression - * @param mixed $secondExpression - */ - public function __construct(public $firstExpression, public $secondExpression) + public function __construct(public mixed $firstExpression, public mixed $secondExpression) { } diff --git a/lib/Doctrine/ORM/Query/AST/OrderByClause.php b/lib/Doctrine/ORM/Query/AST/OrderByClause.php index 4c9bee12976..f6d7a671a45 100644 --- a/lib/Doctrine/ORM/Query/AST/OrderByClause.php +++ b/lib/Doctrine/ORM/Query/AST/OrderByClause.php @@ -13,13 +13,9 @@ */ class OrderByClause extends Node { - /** @var OrderByItem[] */ - public $orderByItems = []; - /** @param OrderByItem[] $orderByItems */ - public function __construct(array $orderByItems) + public function __construct(public array $orderByItems) { - $this->orderByItems = $orderByItems; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/OrderByItem.php b/lib/Doctrine/ORM/Query/AST/OrderByItem.php index 0a2951c4dcc..64b3f405adc 100644 --- a/lib/Doctrine/ORM/Query/AST/OrderByItem.php +++ b/lib/Doctrine/ORM/Query/AST/OrderByItem.php @@ -15,22 +15,18 @@ */ class OrderByItem extends Node { - /** @var string */ - public $type; + public string $type; - /** @param mixed $expression */ - public function __construct(public $expression) + public function __construct(public mixed $expression) { } - /** @return bool */ - public function isAsc() + public function isAsc(): bool { return strtoupper($this->type) === 'ASC'; } - /** @return bool */ - public function isDesc() + public function isDesc(): bool { return strtoupper($this->type) === 'DESC'; } diff --git a/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php b/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php index 195938157e0..cda6d19aeea 100644 --- a/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php @@ -11,12 +11,8 @@ */ class ParenthesisExpression extends Node { - /** @var Node */ - public $expression; - - public function __construct(Node $expression) + public function __construct(public Node $expression) { - $this->expression = $expression; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php b/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php index 3f9acbaf884..875f4453fe1 100644 --- a/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php @@ -6,15 +6,10 @@ class PartialObjectExpression extends Node { - /** @var mixed[] */ - public $partialFieldSet; - - /** - * @param string $identificationVariable - * @param mixed[] $partialFieldSet - */ - public function __construct(public $identificationVariable, array $partialFieldSet) - { - $this->partialFieldSet = $partialFieldSet; + /** @param mixed[] $partialFieldSet */ + public function __construct( + public string $identificationVariable, + public array $partialFieldSet, + ) { } } diff --git a/lib/Doctrine/ORM/Query/AST/PathExpression.php b/lib/Doctrine/ORM/Query/AST/PathExpression.php index a8a579d40a4..4f5ce93c976 100644 --- a/lib/Doctrine/ORM/Query/AST/PathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/PathExpression.php @@ -17,31 +17,19 @@ */ class PathExpression extends Node { - public const TYPE_COLLECTION_VALUED_ASSOCIATION = 2; - public const TYPE_SINGLE_VALUED_ASSOCIATION = 4; - public const TYPE_STATE_FIELD = 8; - - /** - * @var int|null - * @psalm-var self::TYPE_*|null - */ - public $type; - - /** - * @var int - * @psalm-var int-mask-of - */ - public $expectedType; - - /** - * @param int $expectedType - * @param string $identificationVariable - * @param string|null $field - * @psalm-param int-mask-of $expectedType - */ - public function __construct($expectedType, public $identificationVariable, public $field = null) - { - $this->expectedType = $expectedType; + final public const TYPE_COLLECTION_VALUED_ASSOCIATION = 2; + final public const TYPE_SINGLE_VALUED_ASSOCIATION = 4; + final public const TYPE_STATE_FIELD = 8; + + /** @psalm-var self::TYPE_*|null */ + public int|null $type; + + /** @psalm-param int-mask-of $expectedType */ + public function __construct( + public int $expectedType, + public string $identificationVariable, + public string|null $field = null, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php index a504a494412..7994666f741 100644 --- a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php +++ b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php @@ -15,28 +15,24 @@ */ class QuantifiedExpression extends Node { - /** @var string */ - public $type; + public string $type; /** @param Subselect $subselect */ public function __construct(public $subselect) { } - /** @return bool */ - public function isAll() + public function isAll(): bool { return strtoupper($this->type) === 'ALL'; } - /** @return bool */ - public function isAny() + public function isAny(): bool { return strtoupper($this->type) === 'ANY'; } - /** @return bool */ - public function isSome() + public function isSome(): bool { return strtoupper($this->type) === 'SOME'; } diff --git a/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php index 2da603191e7..59bd5c8d586 100644 --- a/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php @@ -13,17 +13,11 @@ */ class RangeVariableDeclaration extends Node { - /** @var string */ - public $aliasIdentificationVariable; - - /** - * @param string $abstractSchemaName - * @param string $aliasIdentificationVar - * @param bool $isRoot - */ - public function __construct(public $abstractSchemaName, $aliasIdentificationVar, public $isRoot = true) - { - $this->aliasIdentificationVariable = $aliasIdentificationVar; + public function __construct( + public string $abstractSchemaName, + public string $aliasIdentificationVariable, + public bool $isRoot = true, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SelectClause.php b/lib/Doctrine/ORM/Query/AST/SelectClause.php index 08fa042e7d6..ad50e672ee5 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SelectClause.php @@ -13,16 +13,11 @@ */ class SelectClause extends Node { - /** @var mixed[] */ - public $selectExpressions = []; - - /** - * @param mixed[] $selectExpressions - * @param bool $isDistinct - */ - public function __construct(array $selectExpressions, public $isDistinct) - { - $this->selectExpressions = $selectExpressions; + /** @param mixed[] $selectExpressions */ + public function __construct( + public array $selectExpressions, + public bool $isDistinct, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SelectExpression.php b/lib/Doctrine/ORM/Query/AST/SelectExpression.php index 75ad4888381..f09f3cda0ac 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SelectExpression.php @@ -14,13 +14,11 @@ */ class SelectExpression extends Node { - /** - * @param mixed $expression - * @param string|null $fieldIdentificationVariable - * @param bool $hiddenAliasResultVariable - */ - public function __construct(public $expression, public $fieldIdentificationVariable, public $hiddenAliasResultVariable = false) - { + public function __construct( + public mixed $expression, + public string|null $fieldIdentificationVariable, + public bool $hiddenAliasResultVariable = false, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php index 7505bafcd20..ae7ca440ad5 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php @@ -13,13 +13,9 @@ */ class SimpleArithmeticExpression extends Node { - /** @var mixed[] */ - public $arithmeticTerms = []; - /** @param mixed[] $arithmeticTerms */ - public function __construct(array $arithmeticTerms) + public function __construct(public array $arithmeticTerms) { - $this->arithmeticTerms = $arithmeticTerms; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php index 9a12dd8871a..5fa21716de2 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php @@ -16,12 +16,11 @@ class SimpleCaseExpression extends Node /** * @param PathExpression $caseOperand * @param mixed[] $simpleWhenClauses - * @param mixed $elseScalarExpression */ public function __construct( public $caseOperand = null, public array $simpleWhenClauses = [], - public $elseScalarExpression = null, + public mixed $elseScalarExpression = null, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php index f84558def83..3631994beb6 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php @@ -13,12 +13,11 @@ */ class SimpleSelectClause extends Node { - /** - * @param SimpleSelectExpression $simpleSelectExpression - * @param bool $isDistinct - */ - public function __construct(public $simpleSelectExpression, public $isDistinct = false) - { + /** @param SimpleSelectExpression $simpleSelectExpression */ + public function __construct( + public $simpleSelectExpression, + public bool $isDistinct = false, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php index 1a9fd3fe246..9491612f39d 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php @@ -14,8 +14,7 @@ */ class SimpleSelectExpression extends Node { - /** @var string */ - public $fieldIdentificationVariable; + public string|null $fieldIdentificationVariable = null; /** @param Node|string $expression */ public function __construct(public $expression) diff --git a/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php b/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php index 712e90a12f1..892165a9891 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php @@ -13,12 +13,10 @@ */ class SimpleWhenClause extends Node { - /** - * @param mixed $caseScalarExpression - * @param mixed $thenScalarExpression - */ - public function __construct(public $caseScalarExpression = null, public $thenScalarExpression = null) - { + public function __construct( + public mixed $caseScalarExpression = null, + public mixed $thenScalarExpression = null, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php b/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php index 89dab07eea7..7cf01e22636 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php @@ -13,13 +13,9 @@ */ class SubselectFromClause extends Node { - /** @var mixed[] */ - public $identificationVariableDeclarations = []; - /** @param mixed[] $identificationVariableDeclarations */ - public function __construct(array $identificationVariableDeclarations) + public function __construct(public array $identificationVariableDeclarations) { - $this->identificationVariableDeclarations = $identificationVariableDeclarations; } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php index 225cf8d3037..051eccee889 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php @@ -11,11 +11,10 @@ */ class SubselectIdentificationVariableDeclaration { - /** - * @param PathExpression $associationPathExpression - * @param string $aliasIdentificationVariable - */ - public function __construct(public $associationPathExpression, public $aliasIdentificationVariable) - { + /** @param PathExpression $associationPathExpression */ + public function __construct( + public $associationPathExpression, + public string $aliasIdentificationVariable, + ) { } } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateClause.php b/lib/Doctrine/ORM/Query/AST/UpdateClause.php index 0c05dee5ae6..cafcff01b75 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateClause.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateClause.php @@ -13,19 +13,13 @@ */ class UpdateClause extends Node { - /** @var string */ - public $aliasIdentificationVariable; + public string $aliasIdentificationVariable; - /** @var mixed[] */ - public $updateItems = []; - - /** - * @param string $abstractSchemaName - * @param mixed[] $updateItems - */ - public function __construct(public $abstractSchemaName, array $updateItems) - { - $this->updateItems = $updateItems; + /** @param mixed[] $updateItems */ + public function __construct( + public string $abstractSchemaName, + public array $updateItems, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/AST/WhenClause.php b/lib/Doctrine/ORM/Query/AST/WhenClause.php index 78ec4092355..bf5b23e68c0 100644 --- a/lib/Doctrine/ORM/Query/AST/WhenClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhenClause.php @@ -13,12 +13,11 @@ */ class WhenClause extends Node { - /** - * @param ConditionalExpression $caseConditionExpression - * @param mixed $thenScalarExpression - */ - public function __construct(public $caseConditionExpression, public $thenScalarExpression = null) - { + /** @param ConditionalExpression $caseConditionExpression */ + public function __construct( + public $caseConditionExpression, + public mixed $thenScalarExpression = null, + ) { } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index dd45bc45598..4a0becb0f4d 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -1020,6 +1020,7 @@ public function ResultVariable() $this->match(Lexer::T_IDENTIFIER); $resultVariable = $this->lexer->token['value']; + assert(is_string($resultVariable)); // Defer ResultVariable validation $this->deferredResultVariables[] = [ diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c4c731ecb0b..e3c2d0b2f14 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1106,11 +1106,6 @@ $lexer->token['value'] - - - null - - walkJoinPathExpression @@ -1121,11 +1116,6 @@ walkJoinVariableDeclaration - - - __toString - - walkWhenClauseExpression @@ -1278,7 +1268,7 @@ AST\ArithmeticTerm AST\BetweenExpression| AST\SimpleArithmeticExpression|AST\ArithmeticTerm - string + class-string string string string @@ -1415,7 +1405,6 @@ $token['type'] $token['type'] $token['type'] - $token['type'] $token['value'] $token['value'] $token['value'] From caaf1509bfc7452dbede9450fa46cdd8e85537b3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 6 Dec 2022 21:46:30 +0100 Subject: [PATCH 195/475] Drop support for Symfony 4 (#10259) --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 55c981f7720..f5f011f785e 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "doctrine/lexer": "^1.2.3", "doctrine/persistence": "^3", "psr/cache": "^1 || ^2 || ^3", - "symfony/console": "^4.4 || ^5.4 || ^6.0" + "symfony/console": "^5.4 || ^6.0" }, "require-dev": { "doctrine/coding-standard": "^10.0", @@ -42,7 +42,7 @@ "phpunit/phpunit": "^9.5", "psr/log": "^1 || ^2 || ^3", "squizlabs/php_codesniffer": "3.7.1", - "symfony/cache": "^4.4 || ^5.4 || ^6.0", + "symfony/cache": "^5.4 || ^6.0", "vimeo/psalm": "5.1.0" }, "suggest": { From 90efde936a325b9d342bb6de07512223fb54a09d Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 6 Dec 2022 21:46:53 +0100 Subject: [PATCH 196/475] Remove InExpression (#10272) --- UPGRADE.md | 8 ++++ lib/Doctrine/ORM/Query/AST/InExpression.php | 45 ------------------- .../ORM/Query/AST/InListExpression.php | 17 ++++--- .../ORM/Query/AST/InSubselectExpression.php | 19 ++++---- .../ORM/Query/AST/InstanceOfExpression.php | 13 +----- lib/Doctrine/ORM/Query/SqlWalker.php | 33 -------------- phpstan-params.neon | 4 -- psalm.xml | 15 ------- .../Tests/ORM/Query/AST/InExpressionTest.php | 34 -------------- 9 files changed, 32 insertions(+), 156 deletions(-) delete mode 100644 lib/Doctrine/ORM/Query/AST/InExpression.php delete mode 100644 tests/Doctrine/Tests/ORM/Query/AST/InExpressionTest.php diff --git a/UPGRADE.md b/UPGRADE.md index c8a49781c27..ae5b65987b1 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,13 @@ # Upgrade to 3.0 +## BC BREAK: Removed `Doctrine\ORM\Query\AST\InExpression` + +The AST parser will create a `InListExpression` or a `InSubselectExpression` when +encountering an `IN ()` DQL expression instead of a generic `InExpression`. + +As a consequence, `SqlWalker::walkInExpression()` has been replaced by +`SqlWalker::walkInListExpression()` and `SqlWalker::walkInSubselectExpression()`. + ## BC BREAK: Changed `EntityManagerInterface#refresh($entity)`, `EntityManagerDecorator#refresh($entity)` and `UnitOfWork#refresh($entity)` signatures The new signatures of these methods add an optional `LockMode|int|null $lockMode` diff --git a/lib/Doctrine/ORM/Query/AST/InExpression.php b/lib/Doctrine/ORM/Query/AST/InExpression.php deleted file mode 100644 index 8cb3c3ff092..00000000000 --- a/lib/Doctrine/ORM/Query/AST/InExpression.php +++ /dev/null @@ -1,45 +0,0 @@ -walkInExpression($this); - } -} diff --git a/lib/Doctrine/ORM/Query/AST/InListExpression.php b/lib/Doctrine/ORM/Query/AST/InListExpression.php index bd240fdfad6..dc0f32b52da 100644 --- a/lib/Doctrine/ORM/Query/AST/InListExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InListExpression.php @@ -4,13 +4,20 @@ namespace Doctrine\ORM\Query\AST; -class InListExpression extends InExpression +use Doctrine\ORM\Query\SqlWalker; + +class InListExpression extends Node { /** @param non-empty-list $literals */ - public function __construct(ArithmeticExpression $expression, public array $literals, bool $not = false) - { - $this->not = $not; + public function __construct( + public ArithmeticExpression $expression, + public array $literals, + public bool $not = false, + ) { + } - parent::__construct($expression); + public function dispatch(SqlWalker $walker): string + { + return $walker->walkInListExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/InSubselectExpression.php b/lib/Doctrine/ORM/Query/AST/InSubselectExpression.php index 735b3d3c6a1..1128285a7f5 100644 --- a/lib/Doctrine/ORM/Query/AST/InSubselectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InSubselectExpression.php @@ -4,16 +4,19 @@ namespace Doctrine\ORM\Query\AST; -class InSubselectExpression extends InExpression +use Doctrine\ORM\Query\SqlWalker; + +class InSubselectExpression extends Node { - /** @var Subselect */ - public $subselect; + public function __construct( + public ArithmeticExpression $expression, + public Subselect $subselect, + public bool $not = false, + ) { + } - public function __construct(ArithmeticExpression $expression, Subselect $subselect, bool $not = false) + public function dispatch(SqlWalker $walker): string { - $this->subselect = $subselect; - $this->not = $not; - - parent::__construct($expression); + return $walker->walkInSubselectExpression($this); } } diff --git a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php index bd6628f2459..ae988224f75 100644 --- a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php @@ -4,11 +4,8 @@ namespace Doctrine\ORM\Query\AST; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Query\SqlWalker; -use function func_num_args; - /** * InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")") * InstanceOfParameter ::= AbstractSchemaName | InputParameter @@ -23,17 +20,9 @@ class InstanceOfExpression extends Node */ public function __construct( public $identificationVariable, - public array $value = [], + public array $value, public bool $not = false, ) { - if (func_num_args() < 2) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10267', - 'Not passing a value for $value to %s() is deprecated.', - __METHOD__, - ); - } } public function dispatch(SqlWalker $walker): string diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 4f351457dca..fdf4b4a1810 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -9,7 +9,6 @@ use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\QuoteStrategy; @@ -1944,38 +1943,6 @@ public function walkNullComparisonExpression(AST\NullComparisonExpression $nullC return $expression->dispatch($this) . $comparison; } - /** - * Walks down an InExpression AST node, thereby generating the appropriate SQL. - * - * @deprecated Use {@see walkInListExpression()} or {@see walkInSubselectExpression()} instead. - */ - public function walkInExpression(AST\InExpression $inExpr): string - { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - '%s() is deprecated, call walkInListExpression() or walkInSubselectExpression() instead.', - __METHOD__, - ); - - if ($inExpr instanceof AST\InListExpression) { - return $this->walkInListExpression($inExpr); - } - - if ($inExpr instanceof AST\InSubselectExpression) { - return $this->walkInSubselectExpression($inExpr); - } - - $sql = $this->walkArithmeticExpression($inExpr->expression) . ($inExpr->not ? ' NOT' : '') . ' IN ('; - - $sql .= $inExpr->subselect - ? $this->walkSubselect($inExpr->subselect) - : implode(', ', array_map([$this, 'walkInParameter'], $inExpr->literals)); - - $sql .= ')'; - - return $sql; - } - /** * Walks down an InExpression AST node, thereby generating the appropriate SQL. */ diff --git a/phpstan-params.neon b/phpstan-params.neon index 165c4ca9b9b..784f63e2d2b 100644 --- a/phpstan-params.neon +++ b/phpstan-params.neon @@ -9,7 +9,3 @@ parameters: Doctrine\ORM\Query\Parser: - syntaxError phpVersion: 80100 - - ignoreErrors: - # Remove on 3.0.x - - '~^Default value of the parameter #2 \$value \(array\{\}\) of method Doctrine\\ORM\\Query\\AST\\InstanceOfExpression\:\:__construct\(\) is incompatible with type non\-empty\-array\.$~' diff --git a/psalm.xml b/psalm.xml index 0b1fdb181a4..1ef40e59f31 100644 --- a/psalm.xml +++ b/psalm.xml @@ -24,7 +24,6 @@ - @@ -34,7 +33,6 @@ - @@ -66,12 +64,6 @@ - - - - - - @@ -92,13 +84,6 @@ - - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Query/AST/InExpressionTest.php b/tests/Doctrine/Tests/ORM/Query/AST/InExpressionTest.php deleted file mode 100644 index ee48869a539..00000000000 --- a/tests/Doctrine/Tests/ORM/Query/AST/InExpressionTest.php +++ /dev/null @@ -1,34 +0,0 @@ -expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/10267'); - - new InExpression(new ArithmeticExpression()); - } - - public function testNoDeprecations(): void - { - $this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/10267'); - - new InListExpression(new ArithmeticExpression(), [new Literal(Literal::STRING, 'foo')]); - new InSubselectExpression(new ArithmeticExpression(), $this->createMock(Subselect::class)); - } -} From a17809c3b902f84cad7fabfd2d18655a5df48be3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 10 Dec 2022 23:18:10 +0100 Subject: [PATCH 197/475] Modernize Closure::fromCallable() calls (#10285) --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 6 +++--- .../ORM/Repository/DefaultRepositoryFactoryTest.php | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index ac451ba3bd2..da6a62b627f 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -107,9 +107,9 @@ public function __construct( if ($em->getConfiguration()->isLazyGhostObjectEnabled()) { $proxyGenerator->setPlaceholder('baseProxyInterface', Proxy::class); - $proxyGenerator->setPlaceholder('useLazyGhostTrait', Closure::fromCallable([$this, 'generateUseLazyGhostTrait'])); - $proxyGenerator->setPlaceholder('skippedProperties', Closure::fromCallable([$this, 'generateSkippedProperties'])); - $proxyGenerator->setPlaceholder('serializeImpl', Closure::fromCallable([$this, 'generateSerializeImpl'])); + $proxyGenerator->setPlaceholder('useLazyGhostTrait', $this->generateUseLazyGhostTrait(...)); + $proxyGenerator->setPlaceholder('skippedProperties', $this->generateSkippedProperties(...)); + $proxyGenerator->setPlaceholder('serializeImpl', $this->generateSerializeImpl(...)); $proxyGenerator->setProxyClassTemplate(self::PROXY_CLASS_TEMPLATE); } else { $proxyGenerator->setPlaceholder('baseProxyInterface', LegacyProxy::class); diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index b93f1db2514..4827ed33e8e 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Repository; -use Closure; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; @@ -43,7 +42,7 @@ public function testCreatesRepositoryFromDefaultRepositoryClass(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); + ->will(self::returnCallback($this->buildClassMetadata(...))); self::assertInstanceOf( DDC869PaymentRepository::class, @@ -56,7 +55,7 @@ public function testCreatedRepositoriesAreCached(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); + ->will(self::returnCallback($this->buildClassMetadata(...))); self::assertSame( $this->repositoryFactory->getRepository($this->entityManager, self::class), @@ -87,11 +86,11 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void $em1->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); + ->will(self::returnCallback($this->buildClassMetadata(...))); $em2->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback(Closure::fromCallable([$this, 'buildClassMetadata']))); + ->will(self::returnCallback($this->buildClassMetadata(...))); $repo1 = $this->repositoryFactory->getRepository($em1, self::class); $repo2 = $this->repositoryFactory->getRepository($em2, self::class); From 9d8cadf1fca350449c753827350a47a1485410d9 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 10 Dec 2022 23:18:23 +0100 Subject: [PATCH 198/475] Remove setAccessible() calls (#10286) --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 1 - .../Tests/ORM/Cache/DefaultCacheTest.php | 2 -- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 2 -- ...ReadWriteCachedCollectionPersisterTest.php | 12 ------- ...rictReadWriteCachedEntityPersisterTest.php | 8 ----- .../ReadWriteCachedEntityPersisterTest.php | 8 ----- .../Tests/ORM/Functional/PaginationTest.php | 2 -- .../Tests/ORM/Functional/SQLFilterTest.php | 1 - .../SecondLevelCacheQueryCacheTest.php | 1 - .../ORM/Functional/Ticket/DDC3123Test.php | 1 - .../ORM/Mapping/ClassMetadataFactoryTest.php | 1 - .../ReflectionEmbeddedPropertyTest.php | 33 +++++++------------ tests/Doctrine/Tests/ORM/ORMSetupTest.php | 1 - .../BasicEntityPersisterTypeValueSqlTest.php | 9 ++--- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 2 -- 15 files changed, 14 insertions(+), 70 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index da6a62b627f..bf0cf044f2a 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -236,7 +236,6 @@ private function createLazyInitializer(ClassMetadata $classMetadata, EntityPersi continue; } - $property->setAccessible(true); $property->setValue($proxy, $property->getValue($entity)); } }; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index 098c4c6b90f..6d9ff650879 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -242,8 +242,6 @@ public function testToIdentifierArrayShouldLookupForEntityIdentifier(): void $method = new ReflectionMethod($this->cache, 'toIdentifierArray'); $property = new ReflectionProperty($entity, 'id'); - $property->setAccessible(true); - $method->setAccessible(true); $property->setValue($entity, $identifier); self::assertEquals(['id' => $identifier], $method->invoke($this->cache, $metadata, $identifier)); diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 033f346652c..8c36f9afaf7 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -580,8 +580,6 @@ public function testGetAssociationValue(): void $rsm = new ResultSetMappingBuilder($this->em); $key = new QueryCacheKey('query.key1', 0); - $reflection->setAccessible(true); - $germany = new Country('Germany'); $bavaria = new State('Bavaria', $germany); $wurzburg = new City('Würzburg', $bavaria); diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index fb75b2dcaae..61a8f4db97d 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -122,8 +122,6 @@ public function testTransactionRollBackDeleteShouldClearQueue(): void $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) @@ -154,8 +152,6 @@ public function testTransactionRollBackUpdateShouldClearQueue(): void $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) @@ -186,8 +182,6 @@ public function testTransactionRollCommitDeleteShouldClearQueue(): void $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) @@ -218,8 +212,6 @@ public function testTransactionRollCommitUpdateShouldClearQueue(): void $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) @@ -249,8 +241,6 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) @@ -274,8 +264,6 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void $key = new CollectionCacheKey(State::class, 'cities', ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedCollectionPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php index 71ae563bdde..268e7434199 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php @@ -29,8 +29,6 @@ public function testTransactionRollBackShouldClearQueue(): void $persister = $this->createPersisterDefault(); $property = new ReflectionProperty($persister, 'queuedCache'); - $property->setAccessible(true); - $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); $persister->update($entity); @@ -51,8 +49,6 @@ public function testInsertTransactionCommitShouldPutCache(): void $entry = new EntityCacheEntry(Country::class, ['id' => 1, 'name' => 'Foo']); $property = new ReflectionProperty($persister, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('put') ->with(self::equalTo($key), self::equalTo($entry)); @@ -88,8 +84,6 @@ public function testUpdateTransactionCommitShouldPutCache(): void $entry = new EntityCacheEntry(Country::class, ['id' => 1, 'name' => 'Foo']); $property = new ReflectionProperty($persister, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('put') ->with(self::equalTo($key), self::equalTo($entry)); @@ -116,8 +110,6 @@ public function testDeleteTransactionCommitShouldEvictCache(): void $key = new EntityCacheKey(Country::class, ['id' => 1]); $property = new ReflectionProperty($persister, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('evict') ->with(self::equalTo($key)); diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index b149bb0634e..66dfaf3a63b 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -117,8 +117,6 @@ public function testTransactionRollBackShouldClearQueue(): void $key = new EntityCacheKey(Country::class, ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::exactly(2)) ->method('lock') ->with(self::equalTo($key)) @@ -148,8 +146,6 @@ public function testTransactionCommitShouldClearQueue(): void $key = new EntityCacheKey(Country::class, ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::exactly(2)) ->method('lock') ->with(self::equalTo($key)) @@ -178,8 +174,6 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void $key = new EntityCacheKey(Country::class, ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) @@ -202,8 +196,6 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void $key = new EntityCacheKey(Country::class, ['id' => 1]); $property = new ReflectionProperty(ReadWriteCachedEntityPersister::class, 'queuedCache'); - $property->setAccessible(true); - $this->region->expects(self::once()) ->method('lock') ->with(self::equalTo($key)) diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index 7a5ac2b9e37..570d44974d0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -637,8 +637,6 @@ public function testCountQueryStripsParametersInSelect(): void $getCountQuery = new ReflectionMethod($paginator, 'getCountQuery'); - $getCountQuery->setAccessible(true); - self::assertCount(2, $getCountQuery->invoke($paginator)->getParameters()); self::assertCount(9, $paginator); diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index bb8f8919f3a..1cd732d160c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -273,7 +273,6 @@ public function testSQLFilterGetConnection(): void $filter = new MyLocaleFilter($em); $reflMethod = new ReflectionMethod(SQLFilter::class, 'getConnection'); - $reflMethod->setAccessible(true); self::assertSame($conn, $reflMethod->invoke($filter)); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 7f3e46ab6a6..69aea548600 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -805,7 +805,6 @@ public function testQueryCacheLifetime(): void $getHash = static function (AbstractQuery $query) { $method = new ReflectionMethod($query, 'getHash'); - $method->setAccessible(true); return $method->invoke($query); }; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php index b3e692632ac..4eab60a0e1f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php @@ -43,7 +43,6 @@ public function __construct(UnitOfWork $uow) public function postFlush(): void { $property = new ReflectionProperty(UnitOfWork::class, 'extraUpdates'); - $property->setAccessible(true); Assert::assertEmpty( $property->getValue($this->uow), diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 2f3449514e0..7a4fe8c4b18 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -414,7 +414,6 @@ public function testAcceptsEntityManagerInterfaceInstances(): void // not really the cleanest way to check it, but we won't add a getter to the CMF just for the sake of testing. $class = new ReflectionClass(ClassMetadataFactory::class); $property = $class->getProperty('em'); - $property->setAccessible(true); self::assertSame($entityManager, $property->getValue($classMetadataFactory)); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php index 066d2d161c7..ab66080db15 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php @@ -77,46 +77,37 @@ public function getTestedReflectionProperties(): array { return [ [ - $this->getReflectionProperty(BooleanModel::class, 'id'), - $this->getReflectionProperty(BooleanModel::class, 'id'), + new ReflectionProperty(BooleanModel::class, 'id'), + new ReflectionProperty(BooleanModel::class, 'id'), BooleanModel::class, ], // reflection on embeddables that have properties defined in abstract ancestors: [ - $this->getReflectionProperty(BooleanModel::class, 'id'), - $this->getReflectionProperty(AbstractEmbeddable::class, 'propertyInAbstractClass'), + new ReflectionProperty(BooleanModel::class, 'id'), + new ReflectionProperty(AbstractEmbeddable::class, 'propertyInAbstractClass'), ConcreteEmbeddable::class, ], [ - $this->getReflectionProperty(BooleanModel::class, 'id'), - $this->getReflectionProperty(ConcreteEmbeddable::class, 'propertyInConcreteClass'), + new ReflectionProperty(BooleanModel::class, 'id'), + new ReflectionProperty(ConcreteEmbeddable::class, 'propertyInConcreteClass'), ConcreteEmbeddable::class, ], // reflection on classes extending internal PHP classes: [ - $this->getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'), - $this->getReflectionProperty(ArrayObjectExtendingClass::class, 'privateProperty'), + new ReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'), + new ReflectionProperty(ArrayObjectExtendingClass::class, 'privateProperty'), ArrayObjectExtendingClass::class, ], [ - $this->getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'), - $this->getReflectionProperty(ArrayObjectExtendingClass::class, 'protectedProperty'), + new ReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'), + new ReflectionProperty(ArrayObjectExtendingClass::class, 'protectedProperty'), ArrayObjectExtendingClass::class, ], [ - $this->getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'), - $this->getReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'), + new ReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'), + new ReflectionProperty(ArrayObjectExtendingClass::class, 'publicProperty'), ArrayObjectExtendingClass::class, ], ]; } - - private function getReflectionProperty(string $className, string $propertyName): ReflectionProperty - { - $reflectionProperty = new ReflectionProperty($className, $propertyName); - - $reflectionProperty->setAccessible(true); - - return $reflectionProperty; - } } diff --git a/tests/Doctrine/Tests/ORM/ORMSetupTest.php b/tests/Doctrine/Tests/ORM/ORMSetupTest.php index 21c0987181b..3ff708ae030 100644 --- a/tests/Doctrine/Tests/ORM/ORMSetupTest.php +++ b/tests/Doctrine/Tests/ORM/ORMSetupTest.php @@ -44,7 +44,6 @@ public function testCacheNamespaceShouldBeGeneratedForApcu(): void $cache = $config->getMetadataCache(); $namespaceProperty = new ReflectionProperty(AbstractAdapter::class, 'namespace'); - $namespaceProperty->setAccessible(true); self::assertInstanceOf(ApcuAdapter::class, $cache); self::assertSame('dc2_1effb2475fcfba4f9e8b8a1dbc8f3caf:', $namespaceProperty->getValue($cache)); diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index ef8eaefb2c0..938e4153910 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -49,9 +49,7 @@ protected function setUp(): void public function testGetInsertSQLUsesTypeValuesSQL(): void { $method = new ReflectionMethod($this->persister, 'getInsertSQL'); - $method->setAccessible(true); - - $sql = $method->invoke($this->persister); + $sql = $method->invoke($this->persister); self::assertEquals('INSERT INTO customtype_parents (customInteger, child_id) VALUES (ABS(?), ?)', $sql); } @@ -101,9 +99,7 @@ public function testUpdateUsesTypeValuesSQL(): void public function testGetSelectConditionSQLUsesTypeValuesSQL(): void { $method = new ReflectionMethod($this->persister, 'getSelectConditionSQL'); - $method->setAccessible(true); - - $sql = $method->invoke($this->persister, ['customInteger' => 1, 'child' => 1]); + $sql = $method->invoke($this->persister, ['customInteger' => 1, 'child' => 1]); self::assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); } @@ -113,7 +109,6 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi { $persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(NonAlphaColumnsEntity::class)); $method = new ReflectionMethod($persister, 'getSelectColumnsSQL'); - $method->setAccessible(true); self::assertEquals('t0."simple-entity-id" AS simpleentityid_1, t0."simple-entity-value" AS simpleentityvalue_2', $method->invoke($persister)); } diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index 15f67c8f90f..210d1ba8e3b 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -179,8 +179,6 @@ public function testProxyClonesParentFields(): void // Set the id of the CompanyEmployee (which is in the parent CompanyPerson) $property = new ReflectionProperty(CompanyPerson::class, 'id'); - - $property->setAccessible(true); $property->setValue($companyEmployee, 42); $classMetaData = $this->emMock->getClassMetadata(CompanyEmployee::class); From 7fd49b7547b79c4cc9da44fe33d229dac588cbe7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 13 Dec 2022 23:28:07 +0100 Subject: [PATCH 199/475] Remove $entityAnnotationClasses and getReader() (#10303) --- UPGRADE.md | 6 ++ composer.json | 2 +- .../ORM/Mapping/Driver/AttributeDriver.php | 59 ++----------------- 3 files changed, 12 insertions(+), 55 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 30e6bafb62c..8f19e05038f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 3.0 +## BC BREAK: Removed `AttributeDriver::$entityAnnotationClasses` and `AttributeDriver::getReader()` + +* If you need to change the behavior of `AttributeDriver::isTransient()`, + override that method instead. +* The attribute reader is internal to the driver and should not be accessed from outside. + ## BC BREAK: Removed `Doctrine\ORM\Query\AST\InExpression` The AST parser will create a `InListExpression` or a `InSubselectExpression` when diff --git a/composer.json b/composer.json index 5782bd183b3..5dc4713249c 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "doctrine/inflector": "^1.4 || ^2.0", "doctrine/instantiator": "^1.3", "doctrine/lexer": "^1.2.3", - "doctrine/persistence": "^3", + "doctrine/persistence": "^3.1.1", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^5.4 || ^6.0" }, diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php index 2b1e64a0bb1..dd8399cae28 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php @@ -4,12 +4,10 @@ namespace Doctrine\ORM\Mapping\Driver; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping; use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\MappingAttribute; use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; use Doctrine\Persistence\Mapping\Driver\ColocatedMappingDriver; @@ -33,67 +31,22 @@ class AttributeDriver implements MappingDriver Mapping\MappedSuperclass::class => 2, ]; - /** - * @deprecated override isTransient() instead of overriding this property - * - * @var array, int> - */ - protected $entityAnnotationClasses = self::ENTITY_ATTRIBUTE_CLASSES; - - /** - * The attribute reader. - * - * @internal this property will be private in 3.0 - * - * @var AttributeReader - */ - protected $reader; + private AttributeReader $reader; /** @param array $paths */ public function __construct(array $paths) { $this->reader = new AttributeReader(); $this->addPaths($paths); - - if ($this->entityAnnotationClasses !== self::ENTITY_ATTRIBUTE_CLASSES) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10204', - 'Changing the value of %s::$entityAnnotationClasses is deprecated and will have no effect in Doctrine ORM 3.0.', - self::class, - ); - } } - /** - * Retrieve the current annotation reader - * - * @deprecated no replacement planned. - * - * @return AttributeReader - */ - public function getReader() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9587', - '%s is deprecated with no replacement', - __METHOD__, - ); - - return $this->reader; - } - - /** - * {@inheritDoc} - */ - public function isTransient($className) + public function isTransient(string $className): bool { $classAttributes = $this->reader->getClassAttributes(new ReflectionClass($className)); foreach ($classAttributes as $a) { $attr = $a instanceof RepeatableAttributeCollection ? $a[0] : $a; - if (isset($this->entityAnnotationClasses[get_class($attr)])) { + if (isset(self::ENTITY_ATTRIBUTE_CLASSES[get_class($attr)])) { return false; } } @@ -109,7 +62,7 @@ public function isTransient($className) * * @template T of object */ - public function loadMetadataForClass($className, PersistenceClassMetadata $metadata): void + public function loadMetadataForClass(string $className, PersistenceClassMetadata $metadata): void { $reflectionClass = $metadata->getReflectionClass() // this happens when running attribute driver in combination with @@ -651,8 +604,6 @@ private function getMethodCallbacks(ReflectionMethod $method): array /** * Parse the given JoinColumn as array * - * @param Mapping\JoinColumn|Mapping\InverseJoinColumn $joinColumn - * * @return mixed[] * @psalm-return array{ * name: string|null, @@ -664,7 +615,7 @@ private function getMethodCallbacks(ReflectionMethod $method): array * options?: array * } */ - private function joinColumnToArray($joinColumn): array + private function joinColumnToArray(Mapping\JoinColumn|Mapping\InverseJoinColumn $joinColumn): array { $mapping = [ 'name' => $joinColumn->name, From cdc7feccc88bc32c3648588aa894bc23f258ec80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 14 Dec 2022 21:27:40 +0100 Subject: [PATCH 200/475] Drop doctrine/lexer 1 This allows us to introduce the TokenType enum that represents the type of DQL tokens. --- composer.json | 2 +- .../cookbook/dql-user-defined-functions.rst | 20 +- .../reference/dql-doctrine-query-language.rst | 8 +- .../ORM/Query/AST/Functions/AbsFunction.php | 8 +- .../Query/AST/Functions/BitAndFunction.php | 10 +- .../ORM/Query/AST/Functions/BitOrFunction.php | 10 +- .../Query/AST/Functions/ConcatFunction.php | 14 +- .../AST/Functions/CurrentDateFunction.php | 8 +- .../AST/Functions/CurrentTimeFunction.php | 8 +- .../Functions/CurrentTimestampFunction.php | 8 +- .../Query/AST/Functions/DateAddFunction.php | 12 +- .../Query/AST/Functions/DateDiffFunction.php | 10 +- .../Query/AST/Functions/IdentityFunction.php | 14 +- .../Query/AST/Functions/LengthFunction.php | 8 +- .../Query/AST/Functions/LocateFunction.php | 14 +- .../ORM/Query/AST/Functions/LowerFunction.php | 8 +- .../ORM/Query/AST/Functions/ModFunction.php | 10 +- .../ORM/Query/AST/Functions/SizeFunction.php | 8 +- .../ORM/Query/AST/Functions/SqrtFunction.php | 8 +- .../Query/AST/Functions/SubstringFunction.php | 14 +- .../ORM/Query/AST/Functions/TrimFunction.php | 20 +- .../ORM/Query/AST/Functions/UpperFunction.php | 8 +- lib/Doctrine/ORM/Query/Lexer.php | 134 +-- lib/Doctrine/ORM/Query/Parser.php | 845 +++++++++--------- lib/Doctrine/ORM/Query/TokenType.php | 92 ++ phpstan-baseline.neon | 2 +- psalm-baseline.xml | 28 +- .../ORM/Functional/CustomFunctionsTest.php | 8 +- .../ORM/Functional/Ticket/GH7286Test.php | 10 +- tests/Doctrine/Tests/ORM/Query/LexerTest.php | 65 +- tests/Doctrine/Tests/ORM/Query/ParserTest.php | 30 +- .../ORM/Query/SelectSqlGenerationTest.php | 8 +- 32 files changed, 729 insertions(+), 723 deletions(-) create mode 100644 lib/Doctrine/ORM/Query/TokenType.php diff --git a/composer.json b/composer.json index e127ac4c3a1..d716d360fda 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "doctrine/event-manager": "^1.2 || ^2", "doctrine/inflector": "^1.4 || ^2.0", "doctrine/instantiator": "^1.3", - "doctrine/lexer": "^1.2.3 || ^2", + "doctrine/lexer": "^2", "doctrine/persistence": "^3.1.1", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^5.4 || ^6.0" diff --git a/docs/en/cookbook/dql-user-defined-functions.rst b/docs/en/cookbook/dql-user-defined-functions.rst index 9345a2535e9..b189ed59fcd 100644 --- a/docs/en/cookbook/dql-user-defined-functions.rst +++ b/docs/en/cookbook/dql-user-defined-functions.rst @@ -99,12 +99,12 @@ discuss it step by step: public function parse(\Doctrine\ORM\Query\Parser $parser) { - $parser->match(Lexer::T_IDENTIFIER); // (2) - $parser->match(Lexer::T_OPEN_PARENTHESIS); // (3) + $parser->match(TokenType::T_IDENTIFIER); // (2) + $parser->match(TokenType::T_OPEN_PARENTHESIS); // (3) $this->firstDateExpression = $parser->ArithmeticPrimary(); // (4) - $parser->match(Lexer::T_COMMA); // (5) + $parser->match(TokenType::T_COMMA); // (5) $this->secondDateExpression = $parser->ArithmeticPrimary(); // (6) - $parser->match(Lexer::T_CLOSE_PARENTHESIS); // (3) + $parser->match(TokenType::T_CLOSE_PARENTHESIS); // (3) } public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) @@ -183,23 +183,23 @@ I'll skip the blah and show the code for this function: public function parse(\Doctrine\ORM\Query\Parser $parser) { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstDateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_COMMA); + $parser->match(TokenType::T_IDENTIFIER); $this->intervalExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_IDENTIFIER); + $parser->match(TokenType::T_IDENTIFIER); /** @var Lexer $lexer */ $lexer = $parser->getLexer(); $this->unit = $lexer->token['value']; - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index 57f2e91231c..127719b9738 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -807,7 +807,7 @@ classes have to implement the base class : namespace MyProject\Query\AST; use Doctrine\ORM\Query\AST\Functions\FunctionNode; - use Doctrine\ORM\Query\Lexer; + use Doctrine\ORM\Query\TokenType; class MysqlFloor extends FunctionNode { @@ -822,12 +822,12 @@ classes have to implement the base class : public function parse(\Doctrine\ORM\Query\Parser $parser) { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php index 0930faf2616..d9dd68bba0a 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "ABS" "(" SimpleArithmeticExpression ")" @@ -28,11 +28,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php index 1f67866c536..f2d3146d21e 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "BIT_AND" "(" ArithmeticPrimary "," ArithmeticPrimary ")" @@ -31,13 +31,13 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstArithmetic = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondArithmetic = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php index 49d29a982cf..f3f84da56f6 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "BIT_OR" "(" ArithmeticPrimary "," ArithmeticPrimary ")" @@ -31,13 +31,13 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstArithmetic = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondArithmetic = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php index 976a5a4bff1..5b8d69605d4 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "CONCAT" "(" StringPrimary "," StringPrimary {"," StringPrimary }* ")" @@ -37,22 +37,22 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstStringPrimary = $parser->StringPrimary(); $this->concatExpressions[] = $this->firstStringPrimary; - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondStringPrimary = $parser->StringPrimary(); $this->concatExpressions[] = $this->secondStringPrimary; - while ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + while ($parser->getLexer()->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->concatExpressions[] = $parser->StringPrimary(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php index 4c585d40c23..cec963269f0 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php @@ -4,9 +4,9 @@ namespace Doctrine\ORM\Query\AST\Functions; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "CURRENT_DATE" @@ -22,8 +22,8 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php index 7cf2841129a..6473fcea494 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php @@ -4,9 +4,9 @@ namespace Doctrine\ORM\Query\AST\Functions; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "CURRENT_TIME" @@ -22,8 +22,8 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php index 96d564be452..edcd27cfa11 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php @@ -4,9 +4,9 @@ namespace Doctrine\ORM\Query\AST\Functions; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "CURRENT_TIMESTAMP" @@ -22,8 +22,8 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php index 33aca04f780..385ebac99c9 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php @@ -6,10 +6,10 @@ use Doctrine\ORM\Query\AST\ASTException; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function assert; use function is_numeric; @@ -78,15 +78,15 @@ private function dispatchIntervalExpression(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstDateExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->intervalExpression = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->unit = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php index bbd73c47df6..55598c09010 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "DATE_DIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")" @@ -29,13 +29,13 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->date1 = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->date2 = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index f98a1c486d5..18b396e58f8 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -5,10 +5,10 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\PathExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function assert; use function reset; @@ -70,20 +70,20 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->pathExpression = $parser->SingleValuedAssociationPathExpression(); - if ($parser->getLexer()->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); - $parser->match(Lexer::T_STRING); + if ($parser->getLexer()->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); + $parser->match(TokenType::T_STRING); $token = $parser->getLexer()->token; assert($token !== null); $this->fieldMapping = $token['value']; } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php index ad9dcf8d4c3..39949183bd2 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php @@ -8,9 +8,9 @@ use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\AST\TypedExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "LENGTH" "(" StringPrimary ")" @@ -30,12 +30,12 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getReturnType(): Type diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php index b9fe10d6ea9..839d54ca546 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php @@ -6,9 +6,9 @@ use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")" @@ -43,22 +43,22 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstStringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondStringPrimary = $parser->StringPrimary(); $lexer = $parser->getLexer(); - if ($lexer->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + if ($lexer->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php index 65afff783cf..8ae337ac273 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -30,11 +30,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php index d4529aeffee..f9daa3c3bdf 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")" @@ -32,15 +32,15 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index e59818ad2ce..f95eeefe2f0 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -6,9 +6,9 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\AST\PathExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function assert; @@ -104,11 +104,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->collectionPathExpression = $parser->CollectionValuedPathExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php index 1f74392f5bc..036ba9a42ac 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -31,11 +31,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php index 89e45ebe111..5b21fe42606 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php @@ -6,9 +6,9 @@ use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; /** * "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" @@ -41,22 +41,22 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); $lexer = $parser->getLexer(); - if ($lexer->isNextToken(Lexer::T_COMMA)) { - $parser->match(Lexer::T_COMMA); + if ($lexer->isNextToken(TokenType::T_COMMA)) { + $parser->match(TokenType::T_COMMA); $this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); } - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php index e214f4c515f..10ab8ebb1ad 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -6,9 +6,9 @@ use Doctrine\DBAL\Platforms\TrimMode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function assert; use function strcasecmp; @@ -47,25 +47,25 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->parseTrimMode($parser); - if ($lexer->isNextToken(Lexer::T_STRING)) { - $parser->match(Lexer::T_STRING); + if ($lexer->isNextToken(TokenType::T_STRING)) { + $parser->match(TokenType::T_STRING); assert($lexer->token !== null); $this->trimChar = $lexer->token['value']; } if ($this->leading || $this->trailing || $this->both || $this->trimChar) { - $parser->match(Lexer::T_FROM); + $parser->match(TokenType::T_FROM); } $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } /** @psalm-return TrimMode::* */ @@ -93,7 +93,7 @@ private function parseTrimMode(Parser $parser): void $value = $lexer->lookahead['value']; if (strcasecmp('leading', $value) === 0) { - $parser->match(Lexer::T_LEADING); + $parser->match(TokenType::T_LEADING); $this->leading = true; @@ -101,7 +101,7 @@ private function parseTrimMode(Parser $parser): void } if (strcasecmp('trailing', $value) === 0) { - $parser->match(Lexer::T_TRAILING); + $parser->match(TokenType::T_TRAILING); $this->trailing = true; @@ -109,7 +109,7 @@ private function parseTrimMode(Parser $parser): void } if (strcasecmp('both', $value) === 0) { - $parser->match(Lexer::T_BOTH); + $parser->match(TokenType::T_BOTH); $this->both = true; diff --git a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php index 3f1cd6b3333..1ecef66f8a5 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php @@ -5,9 +5,9 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use function sprintf; @@ -30,11 +30,11 @@ public function getSql(SqlWalker $sqlWalker): string public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->stringPrimary = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index 45d241da3be..33db4c24287 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -20,94 +20,10 @@ /** * Scans a DQL query for tokens. * - * @extends AbstractLexer + * @extends AbstractLexer */ class Lexer extends AbstractLexer { - // All tokens that are not valid identifiers must be < 100 - final public const T_NONE = 1; - final public const T_INTEGER = 2; - final public const T_STRING = 3; - final public const T_INPUT_PARAMETER = 4; - final public const T_FLOAT = 5; - final public const T_CLOSE_PARENTHESIS = 6; - final public const T_OPEN_PARENTHESIS = 7; - final public const T_COMMA = 8; - final public const T_DIVIDE = 9; - final public const T_DOT = 10; - final public const T_EQUALS = 11; - final public const T_GREATER_THAN = 12; - final public const T_LOWER_THAN = 13; - final public const T_MINUS = 14; - final public const T_MULTIPLY = 15; - final public const T_NEGATE = 16; - final public const T_PLUS = 17; - final public const T_OPEN_CURLY_BRACE = 18; - final public const T_CLOSE_CURLY_BRACE = 19; - - // All tokens that are identifiers or keywords that could be considered as identifiers should be >= 100 - final public const T_FULLY_QUALIFIED_NAME = 101; - final public const T_IDENTIFIER = 102; - - // All keyword tokens should be >= 200 - final public const T_ALL = 200; - final public const T_AND = 201; - final public const T_ANY = 202; - final public const T_AS = 203; - final public const T_ASC = 204; - final public const T_AVG = 205; - final public const T_BETWEEN = 206; - final public const T_BOTH = 207; - final public const T_BY = 208; - final public const T_CASE = 209; - final public const T_COALESCE = 210; - final public const T_COUNT = 211; - final public const T_DELETE = 212; - final public const T_DESC = 213; - final public const T_DISTINCT = 214; - final public const T_ELSE = 215; - final public const T_EMPTY = 216; - final public const T_END = 217; - final public const T_ESCAPE = 218; - final public const T_EXISTS = 219; - final public const T_FALSE = 220; - final public const T_FROM = 221; - final public const T_GROUP = 222; - final public const T_HAVING = 223; - final public const T_HIDDEN = 224; - final public const T_IN = 225; - final public const T_INDEX = 226; - final public const T_INNER = 227; - final public const T_INSTANCE = 228; - final public const T_IS = 229; - final public const T_JOIN = 230; - final public const T_LEADING = 231; - final public const T_LEFT = 232; - final public const T_LIKE = 233; - final public const T_MAX = 234; - final public const T_MEMBER = 235; - final public const T_MIN = 236; - final public const T_NEW = 237; - final public const T_NOT = 238; - final public const T_NULL = 239; - final public const T_NULLIF = 240; - final public const T_OF = 241; - final public const T_OR = 242; - final public const T_ORDER = 243; - final public const T_OUTER = 244; - final public const T_PARTIAL = 245; - final public const T_SELECT = 246; - final public const T_SET = 247; - final public const T_SOME = 248; - final public const T_SUM = 249; - final public const T_THEN = 250; - final public const T_TRAILING = 251; - final public const T_TRUE = 252; - final public const T_UPDATE = 253; - final public const T_WHEN = 254; - final public const T_WHERE = 255; - final public const T_WITH = 256; - /** * Creates a new query scanner object. * @@ -143,89 +59,89 @@ protected function getNonCatchablePatterns(): array /** * {@inheritdoc} */ - protected function getType(&$value) + protected function getType(&$value): TokenType { - $type = self::T_NONE; + $type = TokenType::T_NONE; switch (true) { // Recognize numeric values case is_numeric($value): if (str_contains($value, '.') || stripos($value, 'e') !== false) { - return self::T_FLOAT; + return TokenType::T_FLOAT; } - return self::T_INTEGER; + return TokenType::T_INTEGER; // Recognize quoted strings case $value[0] === "'": $value = str_replace("''", "'", substr($value, 1, strlen($value) - 2)); - return self::T_STRING; + return TokenType::T_STRING; // Recognize identifiers, aliased or qualified names case ctype_alpha($value[0]) || $value[0] === '_' || $value[0] === '\\': - $name = 'Doctrine\ORM\Query\Lexer::T_' . strtoupper($value); + $name = 'Doctrine\ORM\Query\TokenType::T_' . strtoupper($value); if (defined($name)) { $type = constant($name); - if ($type > 100) { + if ($type->value > 100) { return $type; } } if (str_contains($value, '\\')) { - return self::T_FULLY_QUALIFIED_NAME; + return TokenType::T_FULLY_QUALIFIED_NAME; } - return self::T_IDENTIFIER; + return TokenType::T_IDENTIFIER; // Recognize input parameters case $value[0] === '?' || $value[0] === ':': - return self::T_INPUT_PARAMETER; + return TokenType::T_INPUT_PARAMETER; // Recognize symbols case $value === '.': - return self::T_DOT; + return TokenType::T_DOT; case $value === ',': - return self::T_COMMA; + return TokenType::T_COMMA; case $value === '(': - return self::T_OPEN_PARENTHESIS; + return TokenType::T_OPEN_PARENTHESIS; case $value === ')': - return self::T_CLOSE_PARENTHESIS; + return TokenType::T_CLOSE_PARENTHESIS; case $value === '=': - return self::T_EQUALS; + return TokenType::T_EQUALS; case $value === '>': - return self::T_GREATER_THAN; + return TokenType::T_GREATER_THAN; case $value === '<': - return self::T_LOWER_THAN; + return TokenType::T_LOWER_THAN; case $value === '+': - return self::T_PLUS; + return TokenType::T_PLUS; case $value === '-': - return self::T_MINUS; + return TokenType::T_MINUS; case $value === '*': - return self::T_MULTIPLY; + return TokenType::T_MULTIPLY; case $value === '/': - return self::T_DIVIDE; + return TokenType::T_DIVIDE; case $value === '!': - return self::T_NEGATE; + return TokenType::T_NEGATE; case $value === '{': - return self::T_OPEN_CURLY_BRACE; + return TokenType::T_OPEN_CURLY_BRACE; case $value === '}': - return self::T_CLOSE_CURLY_BRACE; + return TokenType::T_CLOSE_CURLY_BRACE; // Default default: diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 4574200b71e..d4713b6be50 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -34,7 +34,7 @@ * An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language. * Parses a DQL query, reports any errors in it, and generates an AST. * - * @psalm-type DqlToken = Token + * @psalm-type DqlToken = Token * @psalm-type QueryComponent = array{ * metadata?: ClassMetadata, * parent?: string|null, @@ -288,15 +288,13 @@ public function getAST() * If they match, updates the lookahead token; otherwise raises a syntax * error. * - * @param Lexer::T_* $token The token type. - * * @return void * * @throws QueryException If the tokens don't match. */ - public function match($token) + public function match(TokenType $token) { - $lookaheadType = $this->lexer->lookahead['type'] ?? null; + $lookaheadType = $this->lexer->lookahead->type ?? null; // Short-circuit on first condition, usually types match if ($lookaheadType === $token) { @@ -306,17 +304,17 @@ public function match($token) } // If parameter is not identifier (1-99) must be exact match - if ($token < Lexer::T_IDENTIFIER) { + if ($token->value < TokenType::T_IDENTIFIER->value) { $this->syntaxError($this->lexer->getLiteral($token)); } // If parameter is keyword (200+) must be exact match - if ($token > Lexer::T_IDENTIFIER) { + if ($token->value > TokenType::T_IDENTIFIER->value) { $this->syntaxError($this->lexer->getLiteral($token)); } // If parameter is T_IDENTIFIER, then matches T_IDENTIFIER (100) and keywords (200+) - if ($token === Lexer::T_IDENTIFIER && $lookaheadType < Lexer::T_IDENTIFIER) { + if ($token->value === TokenType::T_IDENTIFIER->value && $lookaheadType->value < TokenType::T_IDENTIFIER->value) { $this->syntaxError($this->lexer->getLiteral($token)); } @@ -447,11 +445,11 @@ public function syntaxError($expected = '', $token = null) $token = $this->lexer->lookahead; } - $tokenPos = $token['position'] ?? '-1'; + $tokenPos = $token->position ?? '-1'; $message = sprintf('line 0, col %d: Error: ', $tokenPos); $message .= $expected !== '' ? sprintf('Expected %s, got ', $expected) : 'Unexpected '; - $message .= $this->lexer->lookahead === null ? 'end of string.' : sprintf("'%s'", $token['value']); + $message .= $this->lexer->lookahead === null ? 'end of string.' : sprintf("'%s'", $token->value); throw QueryException::syntaxError($message, QueryException::dqlError($this->query->getDQL() ?? '')); } @@ -459,8 +457,7 @@ public function syntaxError($expected = '', $token = null) /** * Generates a new semantical error. * - * @param string $message Optional message. - * @param mixed[]|null $token Optional token. + * @param string $message Optional message. * @psalm-param DqlToken|null $token * * @return void @@ -468,10 +465,10 @@ public function syntaxError($expected = '', $token = null) * * @throws QueryException */ - public function semanticalError($message = '', $token = null) + public function semanticalError($message = '', Token|null $token = null) { if ($token === null) { - $token = $this->lexer->lookahead ?? ['position' => 0]; + $token = $this->lexer->lookahead ?? new Token('fake token', 42, 0); } // Minimum exposed chars ahead of token @@ -480,12 +477,12 @@ public function semanticalError($message = '', $token = null) // Find a position of a final word to display in error string $dql = $this->query->getDQL(); $length = strlen($dql); - $pos = $token['position'] + $distance; + $pos = $token->position + $distance; $pos = strpos($dql, ' ', $length > $pos ? $pos : $length); - $length = $pos !== false ? $pos - $token['position'] : $distance; + $length = $pos !== false ? $pos - $token->position : $distance; - $tokenPos = $token['position'] > 0 ? $token['position'] : '-1'; - $tokenStr = substr($dql, $token['position'], $length); + $tokenPos = $token->position > 0 ? $token->position : '-1'; + $tokenStr = substr($dql, $token->position, $length); // Building informative message $message = 'line 0, col ' . $tokenPos . " near '" . $tokenStr . "': Error: " . $message; @@ -499,20 +496,20 @@ public function semanticalError($message = '', $token = null) * @param bool $resetPeek Reset peek after finding the closing parenthesis. * * @return mixed[] - * @psalm-return DqlToken|array|null + * @psalm-return DqlToken|null */ - private function peekBeyondClosingParenthesis(bool $resetPeek = true): Token|array|null + private function peekBeyondClosingParenthesis(bool $resetPeek = true): Token|null { $token = $this->lexer->peek(); $numUnmatched = 1; while ($numUnmatched > 0 && $token !== null) { - switch ($token['type']) { - case Lexer::T_OPEN_PARENTHESIS: + switch ($token->type) { + case TokenType::T_OPEN_PARENTHESIS: ++$numUnmatched; break; - case Lexer::T_CLOSE_PARENTHESIS: + case TokenType::T_CLOSE_PARENTHESIS: --$numUnmatched; break; @@ -533,11 +530,11 @@ private function peekBeyondClosingParenthesis(bool $resetPeek = true): Token|arr /** * Checks if the given token indicates a mathematical operator. * - * @psalm-param DqlToken|array|null $token + * @psalm-param DqlToken|null $token */ - private function isMathOperator(Token|array|null $token): bool + private function isMathOperator(Token|null $token): bool { - return $token !== null && in_array($token['type'], [Lexer::T_PLUS, Lexer::T_MINUS, Lexer::T_DIVIDE, Lexer::T_MULTIPLY], true); + return $token !== null && in_array($token->type, [TokenType::T_PLUS, TokenType::T_MINUS, TokenType::T_DIVIDE, TokenType::T_MULTIPLY], true); } /** @@ -548,26 +545,24 @@ private function isMathOperator(Token|array|null $token): bool private function isFunction(): bool { assert($this->lexer->lookahead !== null); - $lookaheadType = $this->lexer->lookahead['type']; + $lookaheadType = $this->lexer->lookahead->type; $peek = $this->lexer->peek(); $this->lexer->resetPeek(); - return $lookaheadType >= Lexer::T_IDENTIFIER && $peek !== null && $peek['type'] === Lexer::T_OPEN_PARENTHESIS; + return $lookaheadType->value >= TokenType::T_IDENTIFIER->value && $peek !== null && $peek->type === TokenType::T_OPEN_PARENTHESIS; } /** * Checks whether the given token type indicates an aggregate function. * - * @psalm-param Lexer::T_* $tokenType - * * @return bool TRUE if the token type is an aggregate function, FALSE otherwise. */ - private function isAggregateFunction(int $tokenType): bool + private function isAggregateFunction(TokenType $tokenType): bool { return in_array( $tokenType, - [Lexer::T_AVG, Lexer::T_MIN, Lexer::T_MAX, Lexer::T_SUM, Lexer::T_COUNT], + [TokenType::T_AVG, TokenType::T_MIN, TokenType::T_MAX, TokenType::T_SUM, TokenType::T_COUNT], true, ); } @@ -580,8 +575,8 @@ private function isNextAllAnySome(): bool assert($this->lexer->lookahead !== null); return in_array( - $this->lexer->lookahead['type'], - [Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME], + $this->lexer->lookahead->type, + [TokenType::T_ALL, TokenType::T_ANY, TokenType::T_SOME], true, ); } @@ -843,16 +838,16 @@ public function QueryLanguage() $this->lexer->moveNext(); - switch ($this->lexer->lookahead['type'] ?? null) { - case Lexer::T_SELECT: + switch ($this->lexer->lookahead->type ?? null) { + case TokenType::T_SELECT: $statement = $this->SelectStatement(); break; - case Lexer::T_UPDATE: + case TokenType::T_UPDATE: $statement = $this->UpdateStatement(); break; - case Lexer::T_DELETE: + case TokenType::T_DELETE: $statement = $this->DeleteStatement(); break; @@ -878,10 +873,10 @@ public function SelectStatement() { $selectStatement = new AST\SelectStatement($this->SelectClause(), $this->FromClause()); - $selectStatement->whereClause = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; - $selectStatement->groupByClause = $this->lexer->isNextToken(Lexer::T_GROUP) ? $this->GroupByClause() : null; - $selectStatement->havingClause = $this->lexer->isNextToken(Lexer::T_HAVING) ? $this->HavingClause() : null; - $selectStatement->orderByClause = $this->lexer->isNextToken(Lexer::T_ORDER) ? $this->OrderByClause() : null; + $selectStatement->whereClause = $this->lexer->isNextToken(TokenType::T_WHERE) ? $this->WhereClause() : null; + $selectStatement->groupByClause = $this->lexer->isNextToken(TokenType::T_GROUP) ? $this->GroupByClause() : null; + $selectStatement->havingClause = $this->lexer->isNextToken(TokenType::T_HAVING) ? $this->HavingClause() : null; + $selectStatement->orderByClause = $this->lexer->isNextToken(TokenType::T_ORDER) ? $this->OrderByClause() : null; return $selectStatement; } @@ -895,7 +890,7 @@ public function UpdateStatement() { $updateStatement = new AST\UpdateStatement($this->UpdateClause()); - $updateStatement->whereClause = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; + $updateStatement->whereClause = $this->lexer->isNextToken(TokenType::T_WHERE) ? $this->WhereClause() : null; return $updateStatement; } @@ -909,7 +904,7 @@ public function DeleteStatement() { $deleteStatement = new AST\DeleteStatement($this->DeleteClause()); - $deleteStatement->whereClause = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; + $deleteStatement->whereClause = $this->lexer->isNextToken(TokenType::T_WHERE) ? $this->WhereClause() : null; return $deleteStatement; } @@ -921,10 +916,10 @@ public function DeleteStatement() */ public function IdentificationVariable() { - $this->match(Lexer::T_IDENTIFIER); + $this->match(TokenType::T_IDENTIFIER); assert($this->lexer->token !== null); - $identVariable = $this->lexer->token['value']; + $identVariable = $this->lexer->token->value; $this->deferredIdentificationVariables[] = [ 'expression' => $identVariable, @@ -942,10 +937,10 @@ public function IdentificationVariable() */ public function AliasIdentificationVariable() { - $this->match(Lexer::T_IDENTIFIER); + $this->match(TokenType::T_IDENTIFIER); assert($this->lexer->token !== null); - $aliasIdentVariable = $this->lexer->token['value']; + $aliasIdentVariable = $this->lexer->token->value; $exists = isset($this->queryComponents[$aliasIdentVariable]); if ($exists) { @@ -965,17 +960,17 @@ public function AliasIdentificationVariable() */ public function AbstractSchemaName() { - if ($this->lexer->isNextToken(Lexer::T_FULLY_QUALIFIED_NAME)) { - $this->match(Lexer::T_FULLY_QUALIFIED_NAME); + if ($this->lexer->isNextToken(TokenType::T_FULLY_QUALIFIED_NAME)) { + $this->match(TokenType::T_FULLY_QUALIFIED_NAME); assert($this->lexer->token !== null); - return $this->lexer->token['value']; + return $this->lexer->token->value; } - $this->match(Lexer::T_IDENTIFIER); + $this->match(TokenType::T_IDENTIFIER); assert($this->lexer->token !== null); - return $this->lexer->token['value']; + return $this->lexer->token->value; } /** @@ -1003,10 +998,10 @@ private function validateAbstractSchemaName(string $schemaName): void */ public function AliasResultVariable() { - $this->match(Lexer::T_IDENTIFIER); + $this->match(TokenType::T_IDENTIFIER); assert($this->lexer->token !== null); - $resultVariable = $this->lexer->token['value']; + $resultVariable = $this->lexer->token->value; $exists = isset($this->queryComponents[$resultVariable]); if ($exists) { @@ -1026,10 +1021,10 @@ public function AliasResultVariable() */ public function ResultVariable() { - $this->match(Lexer::T_IDENTIFIER); + $this->match(TokenType::T_IDENTIFIER); assert($this->lexer->token !== null); - $resultVariable = $this->lexer->token['value']; + $resultVariable = $this->lexer->token->value; // Defer ResultVariable validation $this->deferredResultVariables[] = [ @@ -1056,11 +1051,11 @@ public function JoinAssociationPathExpression() ); } - $this->match(Lexer::T_DOT); - $this->match(Lexer::T_IDENTIFIER); + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_IDENTIFIER); assert($this->lexer->token !== null); - $field = $this->lexer->token['value']; + $field = $this->lexer->token->value; // Validate association field $class = $this->getMetadataForDqlAlias($identVariable); @@ -1089,16 +1084,16 @@ public function PathExpression($expectedTypes) $field = null; assert($this->lexer->token !== null); - if ($this->lexer->isNextToken(Lexer::T_DOT)) { - $this->match(Lexer::T_DOT); - $this->match(Lexer::T_IDENTIFIER); + if ($this->lexer->isNextToken(TokenType::T_DOT)) { + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_IDENTIFIER); - $field = $this->lexer->token['value']; + $field = $this->lexer->token->value; - while ($this->lexer->isNextToken(Lexer::T_DOT)) { - $this->match(Lexer::T_DOT); - $this->match(Lexer::T_IDENTIFIER); - $field .= '.' . $this->lexer->token['value']; + while ($this->lexer->isNextToken(TokenType::T_DOT)) { + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_IDENTIFIER); + $field .= '.' . $this->lexer->token->value; } } @@ -1179,11 +1174,11 @@ public function CollectionValuedPathExpression() public function SelectClause() { $isDistinct = false; - $this->match(Lexer::T_SELECT); + $this->match(TokenType::T_SELECT); // Check for DISTINCT - if ($this->lexer->isNextToken(Lexer::T_DISTINCT)) { - $this->match(Lexer::T_DISTINCT); + if ($this->lexer->isNextToken(TokenType::T_DISTINCT)) { + $this->match(TokenType::T_DISTINCT); $isDistinct = true; } @@ -1192,8 +1187,8 @@ public function SelectClause() $selectExpressions = []; $selectExpressions[] = $this->SelectExpression(); - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $selectExpressions[] = $this->SelectExpression(); } @@ -1209,10 +1204,10 @@ public function SelectClause() public function SimpleSelectClause() { $isDistinct = false; - $this->match(Lexer::T_SELECT); + $this->match(TokenType::T_SELECT); - if ($this->lexer->isNextToken(Lexer::T_DISTINCT)) { - $this->match(Lexer::T_DISTINCT); + if ($this->lexer->isNextToken(TokenType::T_DISTINCT)) { + $this->match(TokenType::T_DISTINCT); $isDistinct = true; } @@ -1227,7 +1222,7 @@ public function SimpleSelectClause() */ public function UpdateClause() { - $this->match(Lexer::T_UPDATE); + $this->match(TokenType::T_UPDATE); assert($this->lexer->lookahead !== null); $token = $this->lexer->lookahead; @@ -1235,8 +1230,8 @@ public function UpdateClause() $this->validateAbstractSchemaName($abstractSchemaName); - if ($this->lexer->isNextToken(Lexer::T_AS)) { - $this->match(Lexer::T_AS); + if ($this->lexer->isNextToken(TokenType::T_AS)) { + $this->match(TokenType::T_AS); } $aliasIdentificationVariable = $this->AliasIdentificationVariable(); @@ -1255,13 +1250,13 @@ public function UpdateClause() $this->queryComponents[$aliasIdentificationVariable] = $queryComponent; - $this->match(Lexer::T_SET); + $this->match(TokenType::T_SET); $updateItems = []; $updateItems[] = $this->UpdateItem(); - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $updateItems[] = $this->UpdateItem(); } @@ -1279,10 +1274,10 @@ public function UpdateClause() */ public function DeleteClause() { - $this->match(Lexer::T_DELETE); + $this->match(TokenType::T_DELETE); - if ($this->lexer->isNextToken(Lexer::T_FROM)) { - $this->match(Lexer::T_FROM); + if ($this->lexer->isNextToken(TokenType::T_FROM)) { + $this->match(TokenType::T_FROM); } assert($this->lexer->lookahead !== null); @@ -1293,11 +1288,11 @@ public function DeleteClause() $deleteClause = new AST\DeleteClause($abstractSchemaName); - if ($this->lexer->isNextToken(Lexer::T_AS)) { - $this->match(Lexer::T_AS); + if ($this->lexer->isNextToken(TokenType::T_AS)) { + $this->match(TokenType::T_AS); } - $aliasIdentificationVariable = $this->lexer->isNextToken(Lexer::T_IDENTIFIER) + $aliasIdentificationVariable = $this->lexer->isNextToken(TokenType::T_IDENTIFIER) ? $this->AliasIdentificationVariable() : 'alias_should_have_been_set'; @@ -1326,13 +1321,13 @@ public function DeleteClause() */ public function FromClause() { - $this->match(Lexer::T_FROM); + $this->match(TokenType::T_FROM); $identificationVariableDeclarations = []; $identificationVariableDeclarations[] = $this->IdentificationVariableDeclaration(); - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $identificationVariableDeclarations[] = $this->IdentificationVariableDeclaration(); } @@ -1347,13 +1342,13 @@ public function FromClause() */ public function SubselectFromClause() { - $this->match(Lexer::T_FROM); + $this->match(TokenType::T_FROM); $identificationVariables = []; $identificationVariables[] = $this->SubselectIdentificationVariableDeclaration(); - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $identificationVariables[] = $this->SubselectIdentificationVariableDeclaration(); } @@ -1368,7 +1363,7 @@ public function SubselectFromClause() */ public function WhereClause() { - $this->match(Lexer::T_WHERE); + $this->match(TokenType::T_WHERE); return new AST\WhereClause($this->ConditionalExpression()); } @@ -1380,7 +1375,7 @@ public function WhereClause() */ public function HavingClause() { - $this->match(Lexer::T_HAVING); + $this->match(TokenType::T_HAVING); return new AST\HavingClause($this->ConditionalExpression()); } @@ -1392,13 +1387,13 @@ public function HavingClause() */ public function GroupByClause() { - $this->match(Lexer::T_GROUP); - $this->match(Lexer::T_BY); + $this->match(TokenType::T_GROUP); + $this->match(TokenType::T_BY); $groupByItems = [$this->GroupByItem()]; - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $groupByItems[] = $this->GroupByItem(); } @@ -1413,14 +1408,14 @@ public function GroupByClause() */ public function OrderByClause() { - $this->match(Lexer::T_ORDER); - $this->match(Lexer::T_BY); + $this->match(TokenType::T_ORDER); + $this->match(TokenType::T_BY); $orderByItems = []; $orderByItems[] = $this->OrderByItem(); - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $orderByItems[] = $this->OrderByItem(); } @@ -1440,10 +1435,10 @@ public function Subselect() $subselect = new AST\Subselect($this->SimpleSelectClause(), $this->SubselectFromClause()); - $subselect->whereClause = $this->lexer->isNextToken(Lexer::T_WHERE) ? $this->WhereClause() : null; - $subselect->groupByClause = $this->lexer->isNextToken(Lexer::T_GROUP) ? $this->GroupByClause() : null; - $subselect->havingClause = $this->lexer->isNextToken(Lexer::T_HAVING) ? $this->HavingClause() : null; - $subselect->orderByClause = $this->lexer->isNextToken(Lexer::T_ORDER) ? $this->OrderByClause() : null; + $subselect->whereClause = $this->lexer->isNextToken(TokenType::T_WHERE) ? $this->WhereClause() : null; + $subselect->groupByClause = $this->lexer->isNextToken(TokenType::T_GROUP) ? $this->GroupByClause() : null; + $subselect->havingClause = $this->lexer->isNextToken(TokenType::T_HAVING) ? $this->HavingClause() : null; + $subselect->orderByClause = $this->lexer->isNextToken(TokenType::T_ORDER) ? $this->OrderByClause() : null; // Decrease query nesting level $this->nestingLevel--; @@ -1460,7 +1455,7 @@ public function UpdateItem() { $pathExpr = $this->SingleValuedPathExpression(); - $this->match(Lexer::T_EQUALS); + $this->match(TokenType::T_EQUALS); return new AST\UpdateItem($pathExpr, $this->NewValue()); } @@ -1475,13 +1470,13 @@ public function GroupByItem() // We need to check if we are in a IdentificationVariable or SingleValuedPathExpression $glimpse = $this->lexer->glimpse(); - if ($glimpse !== null && $glimpse['type'] === Lexer::T_DOT) { + if ($glimpse !== null && $glimpse->type === TokenType::T_DOT) { return $this->SingleValuedPathExpression(); } assert($this->lexer->lookahead !== null); // Still need to decide between IdentificationVariable or ResultVariable - $lookaheadValue = $this->lexer->lookahead['value']; + $lookaheadValue = $this->lexer->lookahead->value; if (! isset($this->queryComponents[$lookaheadValue])) { $this->semanticalError('Cannot group by undefined identification or result variable.'); @@ -1517,7 +1512,7 @@ public function OrderByItem() $expr = $this->SimpleArithmeticExpression(); break; - case $glimpse !== null && $glimpse['type'] === Lexer::T_DOT: + case $glimpse !== null && $glimpse->type === TokenType::T_DOT: $expr = $this->SingleValuedPathExpression(); break; @@ -1525,7 +1520,7 @@ public function OrderByItem() $expr = $this->ScalarExpression(); break; - case $this->lexer->lookahead['type'] === Lexer::T_CASE: + case $this->lexer->lookahead->type === TokenType::T_CASE: $expr = $this->CaseExpression(); break; @@ -1542,13 +1537,13 @@ public function OrderByItem() $item = new AST\OrderByItem($expr); switch (true) { - case $this->lexer->isNextToken(Lexer::T_DESC): - $this->match(Lexer::T_DESC); + case $this->lexer->isNextToken(TokenType::T_DESC): + $this->match(TokenType::T_DESC); $type = 'DESC'; break; - case $this->lexer->isNextToken(Lexer::T_ASC): - $this->match(Lexer::T_ASC); + case $this->lexer->isNextToken(TokenType::T_ASC): + $this->match(TokenType::T_ASC); break; default: @@ -1575,17 +1570,17 @@ public function OrderByItem() */ public function NewValue() { - if ($this->lexer->isNextToken(Lexer::T_NULL)) { - $this->match(Lexer::T_NULL); + if ($this->lexer->isNextToken(TokenType::T_NULL)) { + $this->match(TokenType::T_NULL); return null; } - if ($this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { - $this->match(Lexer::T_INPUT_PARAMETER); + if ($this->lexer->isNextToken(TokenType::T_INPUT_PARAMETER)) { + $this->match(TokenType::T_INPUT_PARAMETER); assert($this->lexer->token !== null); - return new AST\InputParameter($this->lexer->token['value']); + return new AST\InputParameter($this->lexer->token->value); } return $this->ArithmeticExpression(); @@ -1600,16 +1595,16 @@ public function IdentificationVariableDeclaration() { $joins = []; $rangeVariableDeclaration = $this->RangeVariableDeclaration(); - $indexBy = $this->lexer->isNextToken(Lexer::T_INDEX) + $indexBy = $this->lexer->isNextToken(TokenType::T_INDEX) ? $this->IndexBy() : null; $rangeVariableDeclaration->isRoot = true; while ( - $this->lexer->isNextToken(Lexer::T_LEFT) || - $this->lexer->isNextToken(Lexer::T_INNER) || - $this->lexer->isNextToken(Lexer::T_JOIN) + $this->lexer->isNextToken(TokenType::T_LEFT) || + $this->lexer->isNextToken(TokenType::T_INNER) || + $this->lexer->isNextToken(TokenType::T_JOIN) ) { $joins[] = $this->Join(); } @@ -1644,11 +1639,11 @@ public function SubselectIdentificationVariableDeclaration() $glimpse = $this->lexer->glimpse(); - if ($glimpse['type'] == Lexer::T_DOT) { + if ($glimpse->type == TokenType::T_DOT) { $associationPathExpression = $this->AssociationPathExpression(); - if ($this->lexer->isNextToken(Lexer::T_AS)) { - $this->match(Lexer::T_AS); + if ($this->lexer->isNextToken(TokenType::T_AS)) { + $this->match(TokenType::T_AS); } $aliasIdentificationVariable = $this->AliasIdentificationVariable(); @@ -1692,34 +1687,34 @@ public function Join() $joinType = AST\Join::JOIN_TYPE_INNER; switch (true) { - case $this->lexer->isNextToken(Lexer::T_LEFT): - $this->match(Lexer::T_LEFT); + case $this->lexer->isNextToken(TokenType::T_LEFT): + $this->match(TokenType::T_LEFT); $joinType = AST\Join::JOIN_TYPE_LEFT; // Possible LEFT OUTER join - if ($this->lexer->isNextToken(Lexer::T_OUTER)) { - $this->match(Lexer::T_OUTER); + if ($this->lexer->isNextToken(TokenType::T_OUTER)) { + $this->match(TokenType::T_OUTER); $joinType = AST\Join::JOIN_TYPE_LEFTOUTER; } break; - case $this->lexer->isNextToken(Lexer::T_INNER): - $this->match(Lexer::T_INNER); + case $this->lexer->isNextToken(TokenType::T_INNER): + $this->match(TokenType::T_INNER); break; default: // Do nothing } - $this->match(Lexer::T_JOIN); + $this->match(TokenType::T_JOIN); $next = $this->lexer->glimpse(); assert($next !== null); - $joinDeclaration = $next['type'] === Lexer::T_DOT ? $this->JoinAssociationDeclaration() : $this->RangeVariableDeclaration(); - $adhocConditions = $this->lexer->isNextToken(Lexer::T_WITH); + $joinDeclaration = $next->type === TokenType::T_DOT ? $this->JoinAssociationDeclaration() : $this->RangeVariableDeclaration(); + $adhocConditions = $this->lexer->isNextToken(TokenType::T_WITH); $join = new AST\Join($joinType, $joinDeclaration); // Describe non-root join declaration @@ -1729,7 +1724,7 @@ public function Join() // Check for ad-hoc Join conditions if ($adhocConditions) { - $this->match(Lexer::T_WITH); + $this->match(TokenType::T_WITH); $join->conditionalExpression = $this->ConditionalExpression(); } @@ -1746,7 +1741,7 @@ public function Join() */ public function RangeVariableDeclaration() { - if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS) && $this->lexer->glimpse()['type'] === Lexer::T_SELECT) { + if ($this->lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS) && $this->lexer->glimpse()->type === TokenType::T_SELECT) { $this->semanticalError('Subquery is not supported here', $this->lexer->token); } @@ -1754,8 +1749,8 @@ public function RangeVariableDeclaration() $this->validateAbstractSchemaName($abstractSchemaName); - if ($this->lexer->isNextToken(Lexer::T_AS)) { - $this->match(Lexer::T_AS); + if ($this->lexer->isNextToken(TokenType::T_AS)) { + $this->match(TokenType::T_AS); } assert($this->lexer->lookahead !== null); @@ -1787,14 +1782,14 @@ public function JoinAssociationDeclaration() { $joinAssociationPathExpression = $this->JoinAssociationPathExpression(); - if ($this->lexer->isNextToken(Lexer::T_AS)) { - $this->match(Lexer::T_AS); + if ($this->lexer->isNextToken(TokenType::T_AS)) { + $this->match(TokenType::T_AS); } assert($this->lexer->lookahead !== null); $aliasIdentificationVariable = $this->AliasIdentificationVariable(); - $indexBy = $this->lexer->isNextToken(Lexer::T_INDEX) ? $this->IndexBy() : null; + $indexBy = $this->lexer->isNextToken(TokenType::T_INDEX) ? $this->IndexBy() : null; $identificationVariable = $joinAssociationPathExpression->identificationVariable; $field = $joinAssociationPathExpression->associationField; @@ -1831,44 +1826,44 @@ public function PartialObjectExpression() 'PARTIAL syntax in DQL is deprecated.', ); - $this->match(Lexer::T_PARTIAL); + $this->match(TokenType::T_PARTIAL); $partialFieldSet = []; $identificationVariable = $this->IdentificationVariable(); - $this->match(Lexer::T_DOT); - $this->match(Lexer::T_OPEN_CURLY_BRACE); - $this->match(Lexer::T_IDENTIFIER); + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_OPEN_CURLY_BRACE); + $this->match(TokenType::T_IDENTIFIER); assert($this->lexer->token !== null); - $field = $this->lexer->token['value']; + $field = $this->lexer->token->value; // First field in partial expression might be embeddable property - while ($this->lexer->isNextToken(Lexer::T_DOT)) { - $this->match(Lexer::T_DOT); - $this->match(Lexer::T_IDENTIFIER); - $field .= '.' . $this->lexer->token['value']; + while ($this->lexer->isNextToken(TokenType::T_DOT)) { + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_IDENTIFIER); + $field .= '.' . $this->lexer->token->value; } $partialFieldSet[] = $field; - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); - $this->match(Lexer::T_IDENTIFIER); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); + $this->match(TokenType::T_IDENTIFIER); - $field = $this->lexer->token['value']; + $field = $this->lexer->token->value; - while ($this->lexer->isNextToken(Lexer::T_DOT)) { - $this->match(Lexer::T_DOT); - $this->match(Lexer::T_IDENTIFIER); - $field .= '.' . $this->lexer->token['value']; + while ($this->lexer->isNextToken(TokenType::T_DOT)) { + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_IDENTIFIER); + $field .= '.' . $this->lexer->token->value; } $partialFieldSet[] = $field; } - $this->match(Lexer::T_CLOSE_CURLY_BRACE); + $this->match(TokenType::T_CLOSE_CURLY_BRACE); $partialObjectExpression = new AST\PartialObjectExpression($identificationVariable, $partialFieldSet); @@ -1889,22 +1884,22 @@ public function PartialObjectExpression() */ public function NewObjectExpression() { - $this->match(Lexer::T_NEW); + $this->match(TokenType::T_NEW); $className = $this->AbstractSchemaName(); // note that this is not yet validated $token = $this->lexer->token; - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_OPEN_PARENTHESIS); $args[] = $this->NewObjectArg(); - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $args[] = $this->NewObjectArg(); } - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); $expression = new AST\NewObjectExpression($className, $args); @@ -1930,10 +1925,10 @@ public function NewObjectArg() $peek = $this->lexer->glimpse(); assert($peek !== null); - if ($token['type'] === Lexer::T_OPEN_PARENTHESIS && $peek['type'] === Lexer::T_SELECT) { - $this->match(Lexer::T_OPEN_PARENTHESIS); + if ($token->type === TokenType::T_OPEN_PARENTHESIS && $peek->type === TokenType::T_SELECT) { + $this->match(TokenType::T_OPEN_PARENTHESIS); $expression = $this->Subselect(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return $expression; } @@ -1948,8 +1943,8 @@ public function NewObjectArg() */ public function IndexBy() { - $this->match(Lexer::T_INDEX); - $this->match(Lexer::T_BY); + $this->match(TokenType::T_INDEX); + $this->match(TokenType::T_BY); $pathExpr = $this->SingleValuedPathExpression(); // Add the INDEX BY info to the query component @@ -1969,27 +1964,27 @@ public function ScalarExpression() { assert($this->lexer->token !== null); assert($this->lexer->lookahead !== null); - $lookahead = $this->lexer->lookahead['type']; + $lookahead = $this->lexer->lookahead->type; $peek = $this->lexer->glimpse(); switch (true) { - case $lookahead === Lexer::T_INTEGER: - case $lookahead === Lexer::T_FLOAT: + case $lookahead === TokenType::T_INTEGER: + case $lookahead === TokenType::T_FLOAT: // SimpleArithmeticExpression : (- u.value ) or ( + u.value ) or ( - 1 ) or ( + 1 ) - case $lookahead === Lexer::T_MINUS: - case $lookahead === Lexer::T_PLUS: + case $lookahead === TokenType::T_MINUS: + case $lookahead === TokenType::T_PLUS: return $this->SimpleArithmeticExpression(); - case $lookahead === Lexer::T_STRING: + case $lookahead === TokenType::T_STRING: return $this->StringPrimary(); - case $lookahead === Lexer::T_TRUE: - case $lookahead === Lexer::T_FALSE: + case $lookahead === TokenType::T_TRUE: + case $lookahead === TokenType::T_FALSE: $this->match($lookahead); - return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token['value']); + return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token->value); - case $lookahead === Lexer::T_INPUT_PARAMETER: + case $lookahead === TokenType::T_INPUT_PARAMETER: switch (true) { case $this->isMathOperator($peek): // :param + u.value @@ -1998,14 +1993,14 @@ public function ScalarExpression() default: return $this->InputParameter(); } - case $lookahead === Lexer::T_CASE: - case $lookahead === Lexer::T_COALESCE: - case $lookahead === Lexer::T_NULLIF: + case $lookahead === TokenType::T_CASE: + case $lookahead === TokenType::T_COALESCE: + case $lookahead === TokenType::T_NULLIF: // Since NULLIF and COALESCE can be identified as a function, // we need to check these before checking for FunctionDeclaration return $this->CaseExpression(); - case $lookahead === Lexer::T_OPEN_PARENTHESIS: + case $lookahead === TokenType::T_OPEN_PARENTHESIS: return $this->SimpleArithmeticExpression(); // this check must be done before checking for a filed path expression @@ -2024,7 +2019,7 @@ public function ScalarExpression() break; // it is no function, so it must be a field path - case $lookahead === Lexer::T_IDENTIFIER: + case $lookahead === TokenType::T_IDENTIFIER: $this->lexer->peek(); // lookahead => '.' $this->lexer->peek(); // lookahead => token after '.' $peek = $this->lexer->peek(); // lookahead => token after the token after the '.' @@ -2056,21 +2051,21 @@ public function ScalarExpression() public function CaseExpression() { assert($this->lexer->lookahead !== null); - $lookahead = $this->lexer->lookahead['type']; + $lookahead = $this->lexer->lookahead->type; switch ($lookahead) { - case Lexer::T_NULLIF: + case TokenType::T_NULLIF: return $this->NullIfExpression(); - case Lexer::T_COALESCE: + case TokenType::T_COALESCE: return $this->CoalesceExpression(); - case Lexer::T_CASE: + case TokenType::T_CASE: $this->lexer->resetPeek(); $peek = $this->lexer->peek(); assert($peek !== null); - if ($peek['type'] === Lexer::T_WHEN) { + if ($peek->type === TokenType::T_WHEN) { return $this->GeneralCaseExpression(); } @@ -2091,20 +2086,20 @@ public function CaseExpression() */ public function CoalesceExpression() { - $this->match(Lexer::T_COALESCE); - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_COALESCE); + $this->match(TokenType::T_OPEN_PARENTHESIS); // Process ScalarExpressions (1..N) $scalarExpressions = []; $scalarExpressions[] = $this->ScalarExpression(); - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $scalarExpressions[] = $this->ScalarExpression(); } - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return new AST\CoalesceExpression($scalarExpressions); } @@ -2116,14 +2111,14 @@ public function CoalesceExpression() */ public function NullIfExpression() { - $this->match(Lexer::T_NULLIF); - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_NULLIF); + $this->match(TokenType::T_OPEN_PARENTHESIS); $firstExpression = $this->ScalarExpression(); - $this->match(Lexer::T_COMMA); + $this->match(TokenType::T_COMMA); $secondExpression = $this->ScalarExpression(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return new AST\NullIfExpression($firstExpression, $secondExpression); } @@ -2135,18 +2130,18 @@ public function NullIfExpression() */ public function GeneralCaseExpression() { - $this->match(Lexer::T_CASE); + $this->match(TokenType::T_CASE); // Process WhenClause (1..N) $whenClauses = []; do { $whenClauses[] = $this->WhenClause(); - } while ($this->lexer->isNextToken(Lexer::T_WHEN)); + } while ($this->lexer->isNextToken(TokenType::T_WHEN)); - $this->match(Lexer::T_ELSE); + $this->match(TokenType::T_ELSE); $scalarExpression = $this->ScalarExpression(); - $this->match(Lexer::T_END); + $this->match(TokenType::T_END); return new AST\GeneralCaseExpression($whenClauses, $scalarExpression); } @@ -2159,7 +2154,7 @@ public function GeneralCaseExpression() */ public function SimpleCaseExpression() { - $this->match(Lexer::T_CASE); + $this->match(TokenType::T_CASE); $caseOperand = $this->StateFieldPathExpression(); // Process SimpleWhenClause (1..N) @@ -2167,11 +2162,11 @@ public function SimpleCaseExpression() do { $simpleWhenClauses[] = $this->SimpleWhenClause(); - } while ($this->lexer->isNextToken(Lexer::T_WHEN)); + } while ($this->lexer->isNextToken(TokenType::T_WHEN)); - $this->match(Lexer::T_ELSE); + $this->match(TokenType::T_ELSE); $scalarExpression = $this->ScalarExpression(); - $this->match(Lexer::T_END); + $this->match(TokenType::T_END); return new AST\SimpleCaseExpression($caseOperand, $simpleWhenClauses, $scalarExpression); } @@ -2183,9 +2178,9 @@ public function SimpleCaseExpression() */ public function WhenClause() { - $this->match(Lexer::T_WHEN); + $this->match(TokenType::T_WHEN); $conditionalExpression = $this->ConditionalExpression(); - $this->match(Lexer::T_THEN); + $this->match(TokenType::T_THEN); return new AST\WhenClause($conditionalExpression, $this->ScalarExpression()); } @@ -2197,9 +2192,9 @@ public function WhenClause() */ public function SimpleWhenClause() { - $this->match(Lexer::T_WHEN); + $this->match(TokenType::T_WHEN); $conditionalExpression = $this->ScalarExpression(); - $this->match(Lexer::T_THEN); + $this->match(TokenType::T_THEN); return new AST\SimpleWhenClause($conditionalExpression, $this->ScalarExpression()); } @@ -2218,24 +2213,24 @@ public function SelectExpression() $expression = null; $identVariable = null; $peek = $this->lexer->glimpse(); - $lookaheadType = $this->lexer->lookahead['type']; + $lookaheadType = $this->lexer->lookahead->type; assert($peek !== null); switch (true) { // ScalarExpression (u.name) - case $lookaheadType === Lexer::T_IDENTIFIER && $peek['type'] === Lexer::T_DOT: + case $lookaheadType === TokenType::T_IDENTIFIER && $peek->type === TokenType::T_DOT: $expression = $this->ScalarExpression(); break; // IdentificationVariable (u) - case $lookaheadType === Lexer::T_IDENTIFIER && $peek['type'] !== Lexer::T_OPEN_PARENTHESIS: + case $lookaheadType === TokenType::T_IDENTIFIER && $peek->type !== TokenType::T_OPEN_PARENTHESIS: $expression = $identVariable = $this->IdentificationVariable(); break; // CaseExpression (CASE ... or NULLIF(...) or COALESCE(...)) - case $lookaheadType === Lexer::T_CASE: - case $lookaheadType === Lexer::T_COALESCE: - case $lookaheadType === Lexer::T_NULLIF: + case $lookaheadType === TokenType::T_CASE: + case $lookaheadType === TokenType::T_COALESCE: + case $lookaheadType === TokenType::T_NULLIF: $expression = $this->CaseExpression(); break; @@ -2258,31 +2253,31 @@ public function SelectExpression() break; // PartialObjectExpression (PARTIAL u.{id, name}) - case $lookaheadType === Lexer::T_PARTIAL: + case $lookaheadType === TokenType::T_PARTIAL: $expression = $this->PartialObjectExpression(); $identVariable = $expression->identificationVariable; break; // Subselect - case $lookaheadType === Lexer::T_OPEN_PARENTHESIS && $peek['type'] === Lexer::T_SELECT: - $this->match(Lexer::T_OPEN_PARENTHESIS); + case $lookaheadType === TokenType::T_OPEN_PARENTHESIS && $peek->type === TokenType::T_SELECT: + $this->match(TokenType::T_OPEN_PARENTHESIS); $expression = $this->Subselect(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); break; // Shortcut: ScalarExpression => SimpleArithmeticExpression - case $lookaheadType === Lexer::T_OPEN_PARENTHESIS: - case $lookaheadType === Lexer::T_INTEGER: - case $lookaheadType === Lexer::T_STRING: - case $lookaheadType === Lexer::T_FLOAT: + case $lookaheadType === TokenType::T_OPEN_PARENTHESIS: + case $lookaheadType === TokenType::T_INTEGER: + case $lookaheadType === TokenType::T_STRING: + case $lookaheadType === TokenType::T_FLOAT: // SimpleArithmeticExpression : (- u.value ) or ( + u.value ) - case $lookaheadType === Lexer::T_MINUS: - case $lookaheadType === Lexer::T_PLUS: + case $lookaheadType === TokenType::T_MINUS: + case $lookaheadType === TokenType::T_PLUS: $expression = $this->SimpleArithmeticExpression(); break; // NewObjectExpression (New ClassName(id, name)) - case $lookaheadType === Lexer::T_NEW: + case $lookaheadType === TokenType::T_NEW: $expression = $this->NewObjectExpression(); break; @@ -2296,23 +2291,23 @@ public function SelectExpression() // [["AS"] ["HIDDEN"] AliasResultVariable] $mustHaveAliasResultVariable = false; - if ($this->lexer->isNextToken(Lexer::T_AS)) { - $this->match(Lexer::T_AS); + if ($this->lexer->isNextToken(TokenType::T_AS)) { + $this->match(TokenType::T_AS); $mustHaveAliasResultVariable = true; } $hiddenAliasResultVariable = false; - if ($this->lexer->isNextToken(Lexer::T_HIDDEN)) { - $this->match(Lexer::T_HIDDEN); + if ($this->lexer->isNextToken(TokenType::T_HIDDEN)) { + $this->match(TokenType::T_HIDDEN); $hiddenAliasResultVariable = true; } $aliasResultVariable = null; - if ($mustHaveAliasResultVariable || $this->lexer->isNextToken(Lexer::T_IDENTIFIER)) { + if ($mustHaveAliasResultVariable || $this->lexer->isNextToken(TokenType::T_IDENTIFIER)) { assert($expression instanceof AST\Node || is_string($expression)); $token = $this->lexer->lookahead; $aliasResultVariable = $this->AliasResultVariable(); @@ -2350,15 +2345,15 @@ public function SimpleSelectExpression() $peek = $this->lexer->glimpse(); assert($peek !== null); - switch ($this->lexer->lookahead['type']) { - case Lexer::T_IDENTIFIER: + switch ($this->lexer->lookahead->type) { + case TokenType::T_IDENTIFIER: switch (true) { - case $peek['type'] === Lexer::T_DOT: + case $peek->type === TokenType::T_DOT: $expression = $this->StateFieldPathExpression(); return new AST\SimpleSelectExpression($expression); - case $peek['type'] !== Lexer::T_OPEN_PARENTHESIS: + case $peek->type !== TokenType::T_OPEN_PARENTHESIS: $expression = $this->IdentificationVariable(); return new AST\SimpleSelectExpression($expression); @@ -2370,7 +2365,7 @@ public function SimpleSelectExpression() } // COUNT(u.id) - if ($this->isAggregateFunction($this->lexer->lookahead['type'])) { + if ($this->isAggregateFunction($this->lexer->lookahead->type)) { return new AST\SimpleSelectExpression($this->AggregateExpression()); } @@ -2383,8 +2378,8 @@ public function SimpleSelectExpression() break; - case Lexer::T_OPEN_PARENTHESIS: - if ($peek['type'] !== Lexer::T_SELECT) { + case TokenType::T_OPEN_PARENTHESIS: + if ($peek->type !== TokenType::T_SELECT) { // Shortcut: ScalarExpression => SimpleArithmeticExpression $expression = $this->SimpleArithmeticExpression(); @@ -2392,9 +2387,9 @@ public function SimpleSelectExpression() } // Subselect - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_OPEN_PARENTHESIS); $expression = $this->Subselect(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return new AST\SimpleSelectExpression($expression); @@ -2407,11 +2402,11 @@ public function SimpleSelectExpression() $expression = $this->ScalarExpression(); $expr = new AST\SimpleSelectExpression($expression); - if ($this->lexer->isNextToken(Lexer::T_AS)) { - $this->match(Lexer::T_AS); + if ($this->lexer->isNextToken(TokenType::T_AS)) { + $this->match(TokenType::T_AS); } - if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER)) { + if ($this->lexer->isNextToken(TokenType::T_IDENTIFIER)) { $token = $this->lexer->lookahead; $resultVariable = $this->AliasResultVariable(); $expr->fieldIdentificationVariable = $resultVariable; @@ -2437,8 +2432,8 @@ public function ConditionalExpression() $conditionalTerms = []; $conditionalTerms[] = $this->ConditionalTerm(); - while ($this->lexer->isNextToken(Lexer::T_OR)) { - $this->match(Lexer::T_OR); + while ($this->lexer->isNextToken(TokenType::T_OR)) { + $this->match(TokenType::T_OR); $conditionalTerms[] = $this->ConditionalTerm(); } @@ -2462,8 +2457,8 @@ public function ConditionalTerm() $conditionalFactors = []; $conditionalFactors[] = $this->ConditionalFactor(); - while ($this->lexer->isNextToken(Lexer::T_AND)) { - $this->match(Lexer::T_AND); + while ($this->lexer->isNextToken(TokenType::T_AND)) { + $this->match(TokenType::T_AND); $conditionalFactors[] = $this->ConditionalFactor(); } @@ -2486,8 +2481,8 @@ public function ConditionalFactor() { $not = false; - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } @@ -2512,7 +2507,7 @@ public function ConditionalPrimary() { $condPrimary = new AST\ConditionalPrimary(); - if (! $this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { + if (! $this->lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS)) { $condPrimary->simpleConditionalExpression = $this->SimpleConditionalExpression(); return $condPrimary; @@ -2523,8 +2518,8 @@ public function ConditionalPrimary() if ( $peek !== null && ( - in_array($peek['value'], ['=', '<', '<=', '<>', '>', '>=', '!='], true) || - in_array($peek['type'], [Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_IN, Lexer::T_IS, Lexer::T_EXISTS], true) || + in_array($peek->value, ['=', '<', '<=', '<>', '>', '>=', '!='], true) || + in_array($peek->type, [TokenType::T_NOT, TokenType::T_BETWEEN, TokenType::T_LIKE, TokenType::T_IN, TokenType::T_IS, TokenType::T_EXISTS], true) || $this->isMathOperator($peek) ) ) { @@ -2533,9 +2528,9 @@ public function ConditionalPrimary() return $condPrimary; } - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_OPEN_PARENTHESIS); $condPrimary->conditionalExpression = $this->ConditionalExpression(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return $condPrimary; } @@ -2560,7 +2555,7 @@ public function ConditionalPrimary() public function SimpleConditionalExpression() { assert($this->lexer->lookahead !== null); - if ($this->lexer->isNextToken(Lexer::T_EXISTS)) { + if ($this->lexer->isNextToken(TokenType::T_EXISTS)) { return $this->ExistsExpression(); } @@ -2568,28 +2563,28 @@ public function SimpleConditionalExpression() $peek = $this->lexer->glimpse(); $lookahead = $token; - if ($this->lexer->isNextToken(Lexer::T_NOT)) { + if ($this->lexer->isNextToken(TokenType::T_NOT)) { $token = $this->lexer->glimpse(); } assert($token !== null); assert($peek !== null); - if ($token['type'] === Lexer::T_IDENTIFIER || $token['type'] === Lexer::T_INPUT_PARAMETER || $this->isFunction()) { + if ($token->type === TokenType::T_IDENTIFIER || $token->type === TokenType::T_INPUT_PARAMETER || $this->isFunction()) { // Peek beyond the matching closing parenthesis. $beyond = $this->lexer->peek(); - switch ($peek['value']) { + switch ($peek->value) { case '(': // Peeks beyond the matched closing parenthesis. $token = $this->peekBeyondClosingParenthesis(false); assert($token !== null); - if ($token['type'] === Lexer::T_NOT) { + if ($token->type === TokenType::T_NOT) { $token = $this->lexer->peek(); assert($token !== null); } - if ($token['type'] === Lexer::T_IS) { + if ($token->type === TokenType::T_IS) { $lookahead = $this->lexer->peek(); } @@ -2599,7 +2594,7 @@ public function SimpleConditionalExpression() // Peek beyond the PathExpression or InputParameter. $token = $beyond; - while ($token['value'] === '.') { + while ($token->value === '.') { $this->lexer->peek(); $token = $this->lexer->peek(); @@ -2608,7 +2603,7 @@ public function SimpleConditionalExpression() // Also peek beyond a NOT if there is one. assert($token !== null); - if ($token['type'] === Lexer::T_NOT) { + if ($token->type === TokenType::T_NOT) { $token = $this->lexer->peek(); assert($token !== null); } @@ -2619,39 +2614,39 @@ public function SimpleConditionalExpression() assert($lookahead !== null); // Also peek beyond a NOT if there is one. - if ($lookahead['type'] === Lexer::T_NOT) { + if ($lookahead->type === TokenType::T_NOT) { $lookahead = $this->lexer->peek(); } $this->lexer->resetPeek(); } - if ($token['type'] === Lexer::T_BETWEEN) { + if ($token->type === TokenType::T_BETWEEN) { return $this->BetweenExpression(); } - if ($token['type'] === Lexer::T_LIKE) { + if ($token->type === TokenType::T_LIKE) { return $this->LikeExpression(); } - if ($token['type'] === Lexer::T_IN) { + if ($token->type === TokenType::T_IN) { return $this->InExpression(); } - if ($token['type'] === Lexer::T_INSTANCE) { + if ($token->type === TokenType::T_INSTANCE) { return $this->InstanceOfExpression(); } - if ($token['type'] === Lexer::T_MEMBER) { + if ($token->type === TokenType::T_MEMBER) { return $this->CollectionMemberExpression(); } assert($lookahead !== null); - if ($token['type'] === Lexer::T_IS && $lookahead['type'] === Lexer::T_NULL) { + if ($token->type === TokenType::T_IS && $lookahead->type === TokenType::T_NULL) { return $this->NullComparisonExpression(); } - if ($token['type'] === Lexer::T_IS && $lookahead['type'] === Lexer::T_EMPTY) { + if ($token->type === TokenType::T_IS && $lookahead->type === TokenType::T_EMPTY) { return $this->EmptyCollectionComparisonExpression(); } @@ -2666,15 +2661,15 @@ public function SimpleConditionalExpression() public function EmptyCollectionComparisonExpression() { $pathExpression = $this->CollectionValuedPathExpression(); - $this->match(Lexer::T_IS); + $this->match(TokenType::T_IS); $not = false; - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } - $this->match(Lexer::T_EMPTY); + $this->match(TokenType::T_EMPTY); return new AST\EmptyCollectionComparisonExpression( $pathExpression, @@ -2695,16 +2690,16 @@ public function CollectionMemberExpression() $not = false; $entityExpr = $this->EntityExpression(); - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } - $this->match(Lexer::T_MEMBER); + $this->match(TokenType::T_MEMBER); - if ($this->lexer->isNextToken(Lexer::T_OF)) { - $this->match(Lexer::T_OF); + if ($this->lexer->isNextToken(TokenType::T_OF)) { + $this->match(TokenType::T_OF); } return new AST\CollectionMemberExpression( @@ -2723,27 +2718,27 @@ public function Literal() { assert($this->lexer->lookahead !== null); assert($this->lexer->token !== null); - switch ($this->lexer->lookahead['type']) { - case Lexer::T_STRING: - $this->match(Lexer::T_STRING); + switch ($this->lexer->lookahead->type) { + case TokenType::T_STRING: + $this->match(TokenType::T_STRING); - return new AST\Literal(AST\Literal::STRING, $this->lexer->token['value']); + return new AST\Literal(AST\Literal::STRING, $this->lexer->token->value); - case Lexer::T_INTEGER: - case Lexer::T_FLOAT: + case TokenType::T_INTEGER: + case TokenType::T_FLOAT: $this->match( - $this->lexer->isNextToken(Lexer::T_INTEGER) ? Lexer::T_INTEGER : Lexer::T_FLOAT, + $this->lexer->isNextToken(TokenType::T_INTEGER) ? TokenType::T_INTEGER : TokenType::T_FLOAT, ); - return new AST\Literal(AST\Literal::NUMERIC, $this->lexer->token['value']); + return new AST\Literal(AST\Literal::NUMERIC, $this->lexer->token->value); - case Lexer::T_TRUE: - case Lexer::T_FALSE: + case TokenType::T_TRUE: + case TokenType::T_FALSE: $this->match( - $this->lexer->isNextToken(Lexer::T_TRUE) ? Lexer::T_TRUE : Lexer::T_FALSE, + $this->lexer->isNextToken(TokenType::T_TRUE) ? TokenType::T_TRUE : TokenType::T_FALSE, ); - return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token['value']); + return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token->value); default: $this->syntaxError('Literal'); @@ -2758,7 +2753,7 @@ public function Literal() public function InParameter() { assert($this->lexer->lookahead !== null); - if ($this->lexer->lookahead['type'] === Lexer::T_INPUT_PARAMETER) { + if ($this->lexer->lookahead->type === TokenType::T_INPUT_PARAMETER) { return $this->InputParameter(); } @@ -2772,10 +2767,10 @@ public function InParameter() */ public function InputParameter() { - $this->match(Lexer::T_INPUT_PARAMETER); + $this->match(TokenType::T_INPUT_PARAMETER); assert($this->lexer->token !== null); - return new AST\InputParameter($this->lexer->token['value']); + return new AST\InputParameter($this->lexer->token->value); } /** @@ -2787,14 +2782,14 @@ public function ArithmeticExpression() { $expr = new AST\ArithmeticExpression(); - if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { + if ($this->lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS)) { $peek = $this->lexer->glimpse(); assert($peek !== null); - if ($peek['type'] === Lexer::T_SELECT) { - $this->match(Lexer::T_OPEN_PARENTHESIS); + if ($peek->type === TokenType::T_SELECT) { + $this->match(TokenType::T_OPEN_PARENTHESIS); $expr->subselect = $this->Subselect(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return $expr; } @@ -2815,11 +2810,11 @@ public function SimpleArithmeticExpression() $terms = []; $terms[] = $this->ArithmeticTerm(); - while (($isPlus = $this->lexer->isNextToken(Lexer::T_PLUS)) || $this->lexer->isNextToken(Lexer::T_MINUS)) { - $this->match($isPlus ? Lexer::T_PLUS : Lexer::T_MINUS); + while (($isPlus = $this->lexer->isNextToken(TokenType::T_PLUS)) || $this->lexer->isNextToken(TokenType::T_MINUS)) { + $this->match($isPlus ? TokenType::T_PLUS : TokenType::T_MINUS); assert($this->lexer->token !== null); - $terms[] = $this->lexer->token['value']; + $terms[] = $this->lexer->token->value; $terms[] = $this->ArithmeticTerm(); } @@ -2842,11 +2837,11 @@ public function ArithmeticTerm() $factors = []; $factors[] = $this->ArithmeticFactor(); - while (($isMult = $this->lexer->isNextToken(Lexer::T_MULTIPLY)) || $this->lexer->isNextToken(Lexer::T_DIVIDE)) { - $this->match($isMult ? Lexer::T_MULTIPLY : Lexer::T_DIVIDE); + while (($isMult = $this->lexer->isNextToken(TokenType::T_MULTIPLY)) || $this->lexer->isNextToken(TokenType::T_DIVIDE)) { + $this->match($isMult ? TokenType::T_MULTIPLY : TokenType::T_DIVIDE); assert($this->lexer->token !== null); - $factors[] = $this->lexer->token['value']; + $factors[] = $this->lexer->token->value; $factors[] = $this->ArithmeticFactor(); } @@ -2868,9 +2863,9 @@ public function ArithmeticFactor() { $sign = null; - $isPlus = $this->lexer->isNextToken(Lexer::T_PLUS); - if ($isPlus || $this->lexer->isNextToken(Lexer::T_MINUS)) { - $this->match($isPlus ? Lexer::T_PLUS : Lexer::T_MINUS); + $isPlus = $this->lexer->isNextToken(TokenType::T_PLUS); + if ($isPlus || $this->lexer->isNextToken(TokenType::T_MINUS)) { + $this->match($isPlus ? TokenType::T_PLUS : TokenType::T_MINUS); $sign = $isPlus; } @@ -2895,47 +2890,47 @@ public function ArithmeticFactor() */ public function ArithmeticPrimary() { - if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { - $this->match(Lexer::T_OPEN_PARENTHESIS); + if ($this->lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS)) { + $this->match(TokenType::T_OPEN_PARENTHESIS); $expr = $this->SimpleArithmeticExpression(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return new AST\ParenthesisExpression($expr); } assert($this->lexer->lookahead !== null); - switch ($this->lexer->lookahead['type']) { - case Lexer::T_COALESCE: - case Lexer::T_NULLIF: - case Lexer::T_CASE: + switch ($this->lexer->lookahead->type) { + case TokenType::T_COALESCE: + case TokenType::T_NULLIF: + case TokenType::T_CASE: return $this->CaseExpression(); - case Lexer::T_IDENTIFIER: + case TokenType::T_IDENTIFIER: $peek = $this->lexer->glimpse(); - if ($peek !== null && $peek['value'] === '(') { + if ($peek !== null && $peek->value === '(') { return $this->FunctionDeclaration(); } - if ($peek !== null && $peek['value'] === '.') { + if ($peek !== null && $peek->value === '.') { return $this->SingleValuedPathExpression(); } - if (isset($this->queryComponents[$this->lexer->lookahead['value']]['resultVariable'])) { + if (isset($this->queryComponents[$this->lexer->lookahead->value]['resultVariable'])) { return $this->ResultVariable(); } return $this->StateFieldPathExpression(); - case Lexer::T_INPUT_PARAMETER: + case TokenType::T_INPUT_PARAMETER: return $this->InputParameter(); default: $peek = $this->lexer->glimpse(); - if ($peek !== null && $peek['value'] === '(') { + if ($peek !== null && $peek->value === '(') { return $this->FunctionDeclaration(); } @@ -2954,10 +2949,10 @@ public function StringExpression() assert($peek !== null); // Subselect - if ($this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS) && $peek['type'] === Lexer::T_SELECT) { - $this->match(Lexer::T_OPEN_PARENTHESIS); + if ($this->lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS) && $peek->type === TokenType::T_SELECT) { + $this->match(TokenType::T_OPEN_PARENTHESIS); $expr = $this->Subselect(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return $expr; } @@ -2965,8 +2960,8 @@ public function StringExpression() assert($this->lexer->lookahead !== null); // ResultVariable (string) if ( - $this->lexer->isNextToken(Lexer::T_IDENTIFIER) && - isset($this->queryComponents[$this->lexer->lookahead['value']]['resultVariable']) + $this->lexer->isNextToken(TokenType::T_IDENTIFIER) && + isset($this->queryComponents[$this->lexer->lookahead->value]['resultVariable']) ) { return $this->ResultVariable(); } @@ -2982,18 +2977,18 @@ public function StringExpression() public function StringPrimary() { assert($this->lexer->lookahead !== null); - $lookaheadType = $this->lexer->lookahead['type']; + $lookaheadType = $this->lexer->lookahead->type; switch ($lookaheadType) { - case Lexer::T_IDENTIFIER: + case TokenType::T_IDENTIFIER: $peek = $this->lexer->glimpse(); assert($peek !== null); - if ($peek['value'] === '.') { + if ($peek->value === '.') { return $this->StateFieldPathExpression(); } - if ($peek['value'] === '(') { + if ($peek->value === '(') { // do NOT directly go to FunctionsReturningString() because it doesn't check for custom functions. return $this->FunctionDeclaration(); } @@ -3001,18 +2996,18 @@ public function StringPrimary() $this->syntaxError("'.' or '('"); break; - case Lexer::T_STRING: - $this->match(Lexer::T_STRING); + case TokenType::T_STRING: + $this->match(TokenType::T_STRING); assert($this->lexer->token !== null); - return new AST\Literal(AST\Literal::STRING, $this->lexer->token['value']); + return new AST\Literal(AST\Literal::STRING, $this->lexer->token->value); - case Lexer::T_INPUT_PARAMETER: + case TokenType::T_INPUT_PARAMETER: return $this->InputParameter(); - case Lexer::T_CASE: - case Lexer::T_COALESCE: - case Lexer::T_NULLIF: + case TokenType::T_CASE: + case TokenType::T_COALESCE: + case TokenType::T_NULLIF: return $this->CaseExpression(); default: @@ -3037,7 +3032,7 @@ public function EntityExpression() $glimpse = $this->lexer->glimpse(); assert($glimpse !== null); - if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER) && $glimpse['value'] === '.') { + if ($this->lexer->isNextToken(TokenType::T_IDENTIFIER) && $glimpse->value === '.') { return $this->SingleValuedAssociationPathExpression(); } @@ -3051,7 +3046,7 @@ public function EntityExpression() */ public function SimpleEntityExpression() { - if ($this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { + if ($this->lexer->isNextToken(TokenType::T_INPUT_PARAMETER)) { return $this->InputParameter(); } @@ -3067,26 +3062,26 @@ public function SimpleEntityExpression() public function AggregateExpression() { assert($this->lexer->lookahead !== null); - $lookaheadType = $this->lexer->lookahead['type']; + $lookaheadType = $this->lexer->lookahead->type; $isDistinct = false; - if (! in_array($lookaheadType, [Lexer::T_COUNT, Lexer::T_AVG, Lexer::T_MAX, Lexer::T_MIN, Lexer::T_SUM], true)) { + if (! in_array($lookaheadType, [TokenType::T_COUNT, TokenType::T_AVG, TokenType::T_MAX, TokenType::T_MIN, TokenType::T_SUM], true)) { $this->syntaxError('One of: MAX, MIN, AVG, SUM, COUNT'); } $this->match($lookaheadType); assert($this->lexer->token !== null); - $functionName = $this->lexer->token['value']; - $this->match(Lexer::T_OPEN_PARENTHESIS); + $functionName = $this->lexer->token->value; + $this->match(TokenType::T_OPEN_PARENTHESIS); - if ($this->lexer->isNextToken(Lexer::T_DISTINCT)) { - $this->match(Lexer::T_DISTINCT); + if ($this->lexer->isNextToken(TokenType::T_DISTINCT)) { + $this->match(TokenType::T_DISTINCT); $isDistinct = true; } $pathExp = $this->SimpleArithmeticExpression(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return new AST\AggregateExpression($functionName, $pathExp, $isDistinct); } @@ -3099,20 +3094,20 @@ public function AggregateExpression() public function QuantifiedExpression() { assert($this->lexer->lookahead !== null); - $lookaheadType = $this->lexer->lookahead['type']; - $value = $this->lexer->lookahead['value']; + $lookaheadType = $this->lexer->lookahead->type; + $value = $this->lexer->lookahead->value; - if (! in_array($lookaheadType, [Lexer::T_ALL, Lexer::T_ANY, Lexer::T_SOME], true)) { + if (! in_array($lookaheadType, [TokenType::T_ALL, TokenType::T_ANY, TokenType::T_SOME], true)) { $this->syntaxError('ALL, ANY or SOME'); } $this->match($lookaheadType); - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_OPEN_PARENTHESIS); $qExpr = new AST\QuantifiedExpression($this->Subselect()); $qExpr->type = $value; - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return $qExpr; } @@ -3127,14 +3122,14 @@ public function BetweenExpression() $not = false; $arithExpr1 = $this->ArithmeticExpression(); - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } - $this->match(Lexer::T_BETWEEN); + $this->match(TokenType::T_BETWEEN); $arithExpr2 = $this->ArithmeticExpression(); - $this->match(Lexer::T_AND); + $this->match(TokenType::T_AND); $arithExpr3 = $this->ArithmeticExpression(); return new AST\BetweenExpression($arithExpr1, $arithExpr2, $arithExpr3, $not); @@ -3168,15 +3163,15 @@ public function InExpression() $expression = $this->ArithmeticExpression(); $not = false; - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } - $this->match(Lexer::T_IN); - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_IN); + $this->match(TokenType::T_OPEN_PARENTHESIS); - if ($this->lexer->isNextToken(Lexer::T_SELECT)) { + if ($this->lexer->isNextToken(TokenType::T_SELECT)) { $inExpression = new AST\InSubselectExpression( $expression, $this->Subselect(), @@ -3185,8 +3180,8 @@ public function InExpression() } else { $literals = [$this->InParameter()]; - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $literals[] = $this->InParameter(); } @@ -3197,7 +3192,7 @@ public function InExpression() ); } - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return $inExpression; } @@ -3212,15 +3207,15 @@ public function InstanceOfExpression() $identificationVariable = $this->IdentificationVariable(); $not = false; - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } - $this->match(Lexer::T_INSTANCE); - $this->match(Lexer::T_OF); + $this->match(TokenType::T_INSTANCE); + $this->match(TokenType::T_OF); - $exprValues = $this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS) + $exprValues = $this->lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS) ? $this->InstanceOfParameterList() : [$this->InstanceOfParameter()]; @@ -3234,17 +3229,17 @@ public function InstanceOfExpression() /** @return non-empty-list */ public function InstanceOfParameterList(): array { - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_OPEN_PARENTHESIS); $exprValues = [$this->InstanceOfParameter()]; - while ($this->lexer->isNextToken(Lexer::T_COMMA)) { - $this->match(Lexer::T_COMMA); + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); $exprValues[] = $this->InstanceOfParameter(); } - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return $exprValues; } @@ -3256,11 +3251,11 @@ public function InstanceOfParameterList(): array */ public function InstanceOfParameter() { - if ($this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { - $this->match(Lexer::T_INPUT_PARAMETER); + if ($this->lexer->isNextToken(TokenType::T_INPUT_PARAMETER)) { + $this->match(TokenType::T_INPUT_PARAMETER); assert($this->lexer->token !== null); - return new AST\InputParameter($this->lexer->token['value']); + return new AST\InputParameter($this->lexer->token->value); } $abstractSchemaName = $this->AbstractSchemaName(); @@ -3280,29 +3275,29 @@ public function LikeExpression() $stringExpr = $this->StringExpression(); $not = false; - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } - $this->match(Lexer::T_LIKE); + $this->match(TokenType::T_LIKE); - if ($this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) { - $this->match(Lexer::T_INPUT_PARAMETER); + if ($this->lexer->isNextToken(TokenType::T_INPUT_PARAMETER)) { + $this->match(TokenType::T_INPUT_PARAMETER); assert($this->lexer->token !== null); - $stringPattern = new AST\InputParameter($this->lexer->token['value']); + $stringPattern = new AST\InputParameter($this->lexer->token->value); } else { $stringPattern = $this->StringPrimary(); } $escapeChar = null; - if ($this->lexer->lookahead !== null && $this->lexer->lookahead['type'] === Lexer::T_ESCAPE) { - $this->match(Lexer::T_ESCAPE); - $this->match(Lexer::T_STRING); + if ($this->lexer->lookahead !== null && $this->lexer->lookahead->type === TokenType::T_ESCAPE) { + $this->match(TokenType::T_ESCAPE); + $this->match(TokenType::T_STRING); assert($this->lexer->token !== null); - $escapeChar = new AST\Literal(AST\Literal::STRING, $this->lexer->token['value']); + $escapeChar = new AST\Literal(AST\Literal::STRING, $this->lexer->token->value); } return new AST\LikeExpression($stringExpr, $stringPattern, $escapeChar, $not); @@ -3316,18 +3311,18 @@ public function LikeExpression() public function NullComparisonExpression() { switch (true) { - case $this->lexer->isNextToken(Lexer::T_INPUT_PARAMETER): - $this->match(Lexer::T_INPUT_PARAMETER); + case $this->lexer->isNextToken(TokenType::T_INPUT_PARAMETER): + $this->match(TokenType::T_INPUT_PARAMETER); assert($this->lexer->token !== null); - $expr = new AST\InputParameter($this->lexer->token['value']); + $expr = new AST\InputParameter($this->lexer->token->value); break; - case $this->lexer->isNextToken(Lexer::T_NULLIF): + case $this->lexer->isNextToken(TokenType::T_NULLIF): $expr = $this->NullIfExpression(); break; - case $this->lexer->isNextToken(Lexer::T_COALESCE): + case $this->lexer->isNextToken(TokenType::T_COALESCE): $expr = $this->CoalesceExpression(); break; @@ -3340,7 +3335,7 @@ public function NullComparisonExpression() $glimpse = $this->lexer->glimpse(); assert($glimpse !== null); - if ($glimpse['type'] === Lexer::T_DOT) { + if ($glimpse->type === TokenType::T_DOT) { $expr = $this->SingleValuedPathExpression(); // Leave switch statement @@ -3348,7 +3343,7 @@ public function NullComparisonExpression() } assert($this->lexer->lookahead !== null); - $lookaheadValue = $this->lexer->lookahead['value']; + $lookaheadValue = $this->lexer->lookahead->value; // Validate existing component if (! isset($this->queryComponents[$lookaheadValue])) { @@ -3370,16 +3365,16 @@ public function NullComparisonExpression() break; } - $this->match(Lexer::T_IS); + $this->match(TokenType::T_IS); $not = false; - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } - $this->match(Lexer::T_NULL); + $this->match(TokenType::T_NULL); return new AST\NullComparisonExpression($expr, $not); } @@ -3393,17 +3388,17 @@ public function ExistsExpression() { $not = false; - if ($this->lexer->isNextToken(Lexer::T_NOT)) { - $this->match(Lexer::T_NOT); + if ($this->lexer->isNextToken(TokenType::T_NOT)) { + $this->match(TokenType::T_NOT); $not = true; } - $this->match(Lexer::T_EXISTS); - $this->match(Lexer::T_OPEN_PARENTHESIS); + $this->match(TokenType::T_EXISTS); + $this->match(TokenType::T_OPEN_PARENTHESIS); $subselect = $this->Subselect(); - $this->match(Lexer::T_CLOSE_PARENTHESIS); + $this->match(TokenType::T_CLOSE_PARENTHESIS); return new AST\ExistsExpression($subselect, $not); } @@ -3416,40 +3411,40 @@ public function ExistsExpression() public function ComparisonOperator() { assert($this->lexer->lookahead !== null); - switch ($this->lexer->lookahead['value']) { + switch ($this->lexer->lookahead->value) { case '=': - $this->match(Lexer::T_EQUALS); + $this->match(TokenType::T_EQUALS); return '='; case '<': - $this->match(Lexer::T_LOWER_THAN); + $this->match(TokenType::T_LOWER_THAN); $operator = '<'; - if ($this->lexer->isNextToken(Lexer::T_EQUALS)) { - $this->match(Lexer::T_EQUALS); + if ($this->lexer->isNextToken(TokenType::T_EQUALS)) { + $this->match(TokenType::T_EQUALS); $operator .= '='; - } elseif ($this->lexer->isNextToken(Lexer::T_GREATER_THAN)) { - $this->match(Lexer::T_GREATER_THAN); + } elseif ($this->lexer->isNextToken(TokenType::T_GREATER_THAN)) { + $this->match(TokenType::T_GREATER_THAN); $operator .= '>'; } return $operator; case '>': - $this->match(Lexer::T_GREATER_THAN); + $this->match(TokenType::T_GREATER_THAN); $operator = '>'; - if ($this->lexer->isNextToken(Lexer::T_EQUALS)) { - $this->match(Lexer::T_EQUALS); + if ($this->lexer->isNextToken(TokenType::T_EQUALS)) { + $this->match(TokenType::T_EQUALS); $operator .= '='; } return $operator; case '!': - $this->match(Lexer::T_NEGATE); - $this->match(Lexer::T_EQUALS); + $this->match(TokenType::T_NEGATE); + $this->match(TokenType::T_EQUALS); return '<>'; @@ -3467,7 +3462,7 @@ public function FunctionDeclaration() { assert($this->lexer->lookahead !== null); $token = $this->lexer->lookahead; - $funcName = strtolower($token['value']); + $funcName = strtolower($token->value); $customFunctionDeclaration = $this->CustomFunctionDeclaration(); @@ -3497,7 +3492,7 @@ private function CustomFunctionDeclaration(): Functions\FunctionNode|null { assert($this->lexer->lookahead !== null); $token = $this->lexer->lookahead; - $funcName = strtolower($token['value']); + $funcName = strtolower($token->value); // Check for custom functions afterwards $config = $this->em->getConfiguration(); @@ -3534,7 +3529,7 @@ private function CustomFunctionDeclaration(): Functions\FunctionNode|null public function FunctionsReturningNumerics() { assert($this->lexer->lookahead !== null); - $funcNameLower = strtolower($this->lexer->lookahead['value']); + $funcNameLower = strtolower($this->lexer->lookahead->value); $funcClass = self::$numericFunctions[$funcNameLower]; $function = new $funcClass($funcNameLower); @@ -3548,7 +3543,7 @@ public function CustomFunctionsReturningNumerics() { assert($this->lexer->lookahead !== null); // getCustomNumericFunction is case-insensitive - $functionName = strtolower($this->lexer->lookahead['value']); + $functionName = strtolower($this->lexer->lookahead->value); $functionClass = $this->em->getConfiguration()->getCustomNumericFunction($functionName); assert($functionClass !== null); @@ -3575,7 +3570,7 @@ public function CustomFunctionsReturningNumerics() public function FunctionsReturningDatetime() { assert($this->lexer->lookahead !== null); - $funcNameLower = strtolower($this->lexer->lookahead['value']); + $funcNameLower = strtolower($this->lexer->lookahead->value); $funcClass = self::$datetimeFunctions[$funcNameLower]; $function = new $funcClass($funcNameLower); @@ -3589,7 +3584,7 @@ public function CustomFunctionsReturningDatetime() { assert($this->lexer->lookahead !== null); // getCustomDatetimeFunction is case-insensitive - $functionName = $this->lexer->lookahead['value']; + $functionName = $this->lexer->lookahead->value; $functionClass = $this->em->getConfiguration()->getCustomDatetimeFunction($functionName); assert($functionClass !== null); @@ -3617,7 +3612,7 @@ public function CustomFunctionsReturningDatetime() public function FunctionsReturningStrings() { assert($this->lexer->lookahead !== null); - $funcNameLower = strtolower($this->lexer->lookahead['value']); + $funcNameLower = strtolower($this->lexer->lookahead->value); $funcClass = self::$stringFunctions[$funcNameLower]; $function = new $funcClass($funcNameLower); @@ -3631,7 +3626,7 @@ public function CustomFunctionsReturningStrings() { assert($this->lexer->lookahead !== null); // getCustomStringFunction is case-insensitive - $functionName = $this->lexer->lookahead['value']; + $functionName = $this->lexer->lookahead->value; $functionClass = $this->em->getConfiguration()->getCustomStringFunction($functionName); assert($functionClass !== null); diff --git a/lib/Doctrine/ORM/Query/TokenType.php b/lib/Doctrine/ORM/Query/TokenType.php new file mode 100644 index 00000000000..bf1c351c2a6 --- /dev/null +++ b/lib/Doctrine/ORM/Query/TokenType.php @@ -0,0 +1,92 @@ += 100 + case T_FULLY_QUALIFIED_NAME = 101; + case T_IDENTIFIER = 102; + + // All keyword tokens should be >= 200 + case T_ALL = 200; + case T_AND = 201; + case T_ANY = 202; + case T_AS = 203; + case T_ASC = 204; + case T_AVG = 205; + case T_BETWEEN = 206; + case T_BOTH = 207; + case T_BY = 208; + case T_CASE = 209; + case T_COALESCE = 210; + case T_COUNT = 211; + case T_DELETE = 212; + case T_DESC = 213; + case T_DISTINCT = 214; + case T_ELSE = 215; + case T_EMPTY = 216; + case T_END = 217; + case T_ESCAPE = 218; + case T_EXISTS = 219; + case T_FALSE = 220; + case T_FROM = 221; + case T_GROUP = 222; + case T_HAVING = 223; + case T_HIDDEN = 224; + case T_IN = 225; + case T_INDEX = 226; + case T_INNER = 227; + case T_INSTANCE = 228; + case T_IS = 229; + case T_JOIN = 230; + case T_LEADING = 231; + case T_LEFT = 232; + case T_LIKE = 233; + case T_MAX = 234; + case T_MEMBER = 235; + case T_MIN = 236; + case T_NEW = 237; + case T_NOT = 238; + case T_NULL = 239; + case T_NULLIF = 240; + case T_OF = 241; + case T_OR = 242; + case T_ORDER = 243; + case T_OUTER = 244; + case T_PARTIAL = 245; + case T_SELECT = 246; + case T_SET = 247; + case T_SOME = 248; + case T_SUM = 249; + case T_THEN = 250; + case T_TRAILING = 251; + case T_TRUE = 252; + case T_UPDATE = 253; + case T_WHEN = 254; + case T_WHERE = 255; + case T_WITH = 256; +} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b1b3f200e2d..bee4d410305 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -266,7 +266,7 @@ parameters: path: lib/Doctrine/ORM/Query/Parser.php - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:peekBeyondClosingParenthesis\\(\\) never returns array so it can be removed from the return type\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:ArithmeticTerm\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticTerm but returns Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticFactor\\|string\\.$#" count: 1 path: lib/Doctrine/ORM/Query/Parser.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e84881876eb..2c67f40d950 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1217,6 +1217,10 @@ $stringPattern + + $this->lexer->lookahead !== null && $this->lexer->lookahead->type === TokenType::T_ESCAPE + $token->type === TokenType::T_OPEN_PARENTHESIS + AST\SelectStatement|AST\UpdateStatement|AST\DeleteStatement @@ -1274,28 +1278,26 @@ $this->ConditionalExpression() $this->SimpleArithmeticExpression() - + $dql $this->query->getDQL() + $token->value - - $this->lexer->glimpse()['type'] - $token['value'] - - - $this->lexer->glimpse() - $token + + $lookaheadType->value + $lookaheadType->value + $this->lexer->glimpse()->type + $token->value + $token->value + + getNumberOfRequiredParameters $args - - $this->lexer->lookahead !== null - - + $AST instanceof AST\SelectStatement - $token === Lexer::T_IDENTIFIER diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php index 4b21059fedc..8c71f8d1f43 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php @@ -7,9 +7,9 @@ use Doctrine\ORM\Query\AST\AggregateExpression; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\PathExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; @@ -71,10 +71,10 @@ class NoOp extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->field = $parser->ArithmeticPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $sqlWalker): string diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php index c56f66e13a4..52e3132b6d3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php @@ -10,9 +10,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\OrmFunctionalTestCase; final class GH7286Test extends OrmFunctionalTestCase @@ -100,14 +100,14 @@ class GH7286CustomConcat extends FunctionNode public function parse(Parser $parser): void { - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->first = $parser->StringPrimary(); - $parser->match(Lexer::T_COMMA); + $parser->match(TokenType::T_COMMA); $this->second = $parser->StringPrimary(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } public function getSql(SqlWalker $walker): string diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index c5f4a3ccf03..a2240719bec 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query\Lexer; +use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\OrmTestCase; class LexerTest extends OrmTestCase @@ -34,7 +35,7 @@ public function testScannerRecognizesTerminalString(): void $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_ALL, $token['type']); + self::assertEquals(TokenType::T_ALL, $token['type']); } public function testScannerRecognizesDecimalInteger(): void @@ -42,7 +43,7 @@ public function testScannerRecognizesDecimalInteger(): void $lexer = new Lexer('1234'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_INTEGER, $token['type']); + self::assertEquals(TokenType::T_INTEGER, $token['type']); self::assertEquals(1234, $token['value']); } @@ -51,7 +52,7 @@ public function testScannerRecognizesFloat(): void $lexer = new Lexer('1.234'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(TokenType::T_FLOAT, $token['type']); self::assertEquals(1.234, $token['value']); } @@ -60,7 +61,7 @@ public function testScannerRecognizesFloatWithExponent(): void $lexer = new Lexer('1.2e3'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(TokenType::T_FLOAT, $token['type']); self::assertEquals(1.2e3, $token['value']); } @@ -69,7 +70,7 @@ public function testScannerRecognizesFloatWithExponent2(): void $lexer = new Lexer('0.2e3'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(TokenType::T_FLOAT, $token['type']); self::assertEquals(.2e3, $token['value']); } @@ -78,7 +79,7 @@ public function testScannerRecognizesFloatWithNegativeExponent(): void $lexer = new Lexer('7E-10'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(TokenType::T_FLOAT, $token['type']); self::assertEquals(7E-10, $token['value']); } @@ -87,7 +88,7 @@ public function testScannerRecognizesFloatBig(): void $lexer = new Lexer('123456789.01'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(TokenType::T_FLOAT, $token['type']); self::assertEquals(1.2345678901e8, $token['value']); } @@ -96,12 +97,12 @@ public function testScannerRecognizesFloatContainingWhitespace(): void $lexer = new Lexer('- 1.234e2'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_MINUS, $token['type']); + self::assertEquals(TokenType::T_MINUS, $token['type']); self::assertEquals('-', $token['value']); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_FLOAT, $token['type']); + self::assertEquals(TokenType::T_FLOAT, $token['type']); self::assertNotEquals(-1.234e2, $token['value']); self::assertEquals(1.234e2, $token['value']); } @@ -111,7 +112,7 @@ public function testScannerRecognizesStringContainingWhitespace(): void $lexer = new Lexer("'This is a string.'"); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_STRING, $token['type']); + self::assertEquals(TokenType::T_STRING, $token['type']); self::assertEquals('This is a string.', $token['value']); } @@ -120,7 +121,7 @@ public function testScannerRecognizesStringContainingSingleQuotes(): void $lexer = new Lexer("'abc''defg'''"); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_STRING, $token['type']); + self::assertEquals(TokenType::T_STRING, $token['type']); self::assertEquals("abc'defg'", $token['value']); } @@ -129,7 +130,7 @@ public function testScannerRecognizesInputParameter(): void $lexer = new Lexer('?1'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals(TokenType::T_INPUT_PARAMETER, $token['type']); self::assertEquals('?1', $token['value']); } @@ -138,7 +139,7 @@ public function testScannerRecognizesNamedInputParameter(): void $lexer = new Lexer(':name'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals(TokenType::T_INPUT_PARAMETER, $token['type']); self::assertEquals(':name', $token['value']); } @@ -147,7 +148,7 @@ public function testScannerRecognizesNamedInputParameterStartingWithUnderscore() $lexer = new Lexer(':_name'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + self::assertEquals(TokenType::T_INPUT_PARAMETER, $token['type']); self::assertEquals(':_name', $token['value']); } @@ -159,57 +160,57 @@ public function testScannerTokenizesASimpleQueryCorrectly(): void $tokens = [ [ 'value' => 'SELECT', - 'type' => Lexer::T_SELECT, + 'type' => TokenType::T_SELECT, 'position' => 0, ], [ 'value' => 'u', - 'type' => Lexer::T_IDENTIFIER, + 'type' => TokenType::T_IDENTIFIER, 'position' => 7, ], [ 'value' => 'FROM', - 'type' => Lexer::T_FROM, + 'type' => TokenType::T_FROM, 'position' => 9, ], [ 'value' => 'My\Namespace\User', - 'type' => Lexer::T_FULLY_QUALIFIED_NAME, + 'type' => TokenType::T_FULLY_QUALIFIED_NAME, 'position' => 14, ], [ 'value' => 'u', - 'type' => Lexer::T_IDENTIFIER, + 'type' => TokenType::T_IDENTIFIER, 'position' => 32, ], [ 'value' => 'WHERE', - 'type' => Lexer::T_WHERE, + 'type' => TokenType::T_WHERE, 'position' => 34, ], [ 'value' => 'u', - 'type' => Lexer::T_IDENTIFIER, + 'type' => TokenType::T_IDENTIFIER, 'position' => 40, ], [ 'value' => '.', - 'type' => Lexer::T_DOT, + 'type' => TokenType::T_DOT, 'position' => 41, ], [ 'value' => 'name', - 'type' => Lexer::T_IDENTIFIER, + 'type' => TokenType::T_IDENTIFIER, 'position' => 42, ], [ 'value' => '=', - 'type' => Lexer::T_EQUALS, + 'type' => TokenType::T_EQUALS, 'position' => 47, ], [ 'value' => "Jack O'Neil", - 'type' => Lexer::T_STRING, + 'type' => TokenType::T_STRING, 'position' => 49, ], ]; @@ -229,13 +230,13 @@ public function testScannerTokenizesASimpleQueryCorrectly(): void public function provideTokens(): array { return [ - [Lexer::T_IDENTIFIER, 'u'], // one char - [Lexer::T_IDENTIFIER, 'someIdentifier'], - [Lexer::T_IDENTIFIER, 's0m31d3nt1f13r'], // including digits - [Lexer::T_IDENTIFIER, 'some_identifier'], // including underscore - [Lexer::T_IDENTIFIER, '_some_identifier'], // starts with underscore - [Lexer::T_IDENTIFIER, 'comma'], // name of a token class with value < 100 (whitebox test) - [Lexer::T_FULLY_QUALIFIED_NAME, 'Some\Class'], // DQL class reference + [TokenType::T_IDENTIFIER, 'u'], // one char + [TokenType::T_IDENTIFIER, 'someIdentifier'], + [TokenType::T_IDENTIFIER, 's0m31d3nt1f13r'], // including digits + [TokenType::T_IDENTIFIER, 'some_identifier'], // including underscore + [TokenType::T_IDENTIFIER, '_some_identifier'], // starts with underscore + [TokenType::T_IDENTIFIER, 'comma'], // name of a token class with value < 100 (whitebox test) + [TokenType::T_FULLY_QUALIFIED_NAME, 'Some\Class'], // DQL class reference ]; } } diff --git a/tests/Doctrine/Tests/ORM/Query/ParserTest.php b/tests/Doctrine/Tests/ORM/Query/ParserTest.php index 2a2a15f9f62..a52e967b5fa 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserTest.php @@ -5,9 +5,9 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; +use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmTestCase; use stdClass; @@ -52,7 +52,7 @@ public function testAbstractSchemaNameSupportsIdentifier(): void * @covers Doctrine\ORM\Query\Parser::match * @group DDC-3701 */ - public function testMatch(int $expectedToken, string $inputString): void + public function testMatch(TokenType $expectedToken, string $inputString): void { $parser = $this->createParser($inputString); @@ -66,7 +66,7 @@ public function testMatch(int $expectedToken, string $inputString): void * @covers Doctrine\ORM\Query\Parser::match * @group DDC-3701 */ - public function testMatchFailure(int $expectedToken, string $inputString): void + public function testMatchFailure(TokenType $expectedToken, string $inputString): void { $this->expectException(QueryException::class); @@ -87,11 +87,11 @@ public function validMatches() * but in LexerTest. */ return [ - [Lexer::T_WHERE, 'where'], // keyword - [Lexer::T_DOT, '.'], // token that cannot be an identifier - [Lexer::T_IDENTIFIER, 'someIdentifier'], - [Lexer::T_IDENTIFIER, 'from'], // also a terminal string (the "FROM" keyword) as in DDC-505 - [Lexer::T_IDENTIFIER, 'comma'], + [TokenType::T_WHERE, 'where'], // keyword + [TokenType::T_DOT, '.'], // token that cannot be an identifier + [TokenType::T_IDENTIFIER, 'someIdentifier'], + [TokenType::T_IDENTIFIER, 'from'], // also a terminal string (the "FROM" keyword) as in DDC-505 + [TokenType::T_IDENTIFIER, 'comma'], // not even a terminal string, but the name of a constant in the Lexer (whitebox test) ]; } @@ -100,14 +100,14 @@ public function validMatches() public function invalidMatches(): array { return [ - [Lexer::T_DOT, 'ALL'], // ALL is a terminal string (reserved keyword) and also possibly an identifier - [Lexer::T_DOT, ','], // "," is a token on its own, but cannot be used as identifier - [Lexer::T_WHERE, 'WITH'], // as in DDC-3697 - [Lexer::T_WHERE, '.'], + [TokenType::T_DOT, 'ALL'], // ALL is a terminal string (reserved keyword) and also possibly an identifier + [TokenType::T_DOT, ','], // "," is a token on its own, but cannot be used as identifier + [TokenType::T_WHERE, 'WITH'], // as in DDC-3697 + [TokenType::T_WHERE, '.'], // The following are qualified or aliased names and must not be accepted where only an Identifier is expected - [Lexer::T_IDENTIFIER, '\\Some\\Class'], - [Lexer::T_IDENTIFIER, 'Some\\Class'], + [TokenType::T_IDENTIFIER, '\\Some\\Class'], + [TokenType::T_IDENTIFIER, 'Some\\Class'], ]; } @@ -126,7 +126,7 @@ public function testNullLookahead(): void $parser = new Parser($query); $this->expectException(QueryException::class); - $parser->match(Lexer::T_SELECT); + $parser->match(TokenType::T_SELECT); } private function createParser(string $dql): Parser diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 3ce84c59f24..d2f9b2be064 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -18,10 +18,10 @@ use Doctrine\ORM\Query as ORMQuery; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; +use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\DbalTypes\NegativeToPositiveType; use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsPhonenumber; @@ -2186,12 +2186,12 @@ public function parse(Parser $parser): void { $lexer = $parser->getLexer(); - $parser->match(Lexer::T_IDENTIFIER); - $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(TokenType::T_IDENTIFIER); + $parser->match(TokenType::T_OPEN_PARENTHESIS); $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(TokenType::T_CLOSE_PARENTHESIS); } } #[Entity] From b3f9acd1bf3663f6d4684dc130b6f94eac510c65 Mon Sep 17 00:00:00 2001 From: michnovka Date: Thu, 15 Dec 2022 11:50:18 +0100 Subject: [PATCH 201/475] Clean-up code after PR10288 merge (#10305) --- lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php | 2 ++ lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php | 11 ++++++----- psalm-baseline.xml | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php b/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php index 2a762461e4e..fa5d48e5a8d 100644 --- a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; +use BackedEnum; #[Attribute(Attribute::TARGET_CLASS)] final class DiscriminatorColumn implements MappingAttribute @@ -14,6 +15,7 @@ public function __construct( public readonly string|null $type = null, public readonly int|null $length = null, public readonly string|null $columnDefinition = null, + /** @var class-string|null */ public readonly string|null $enumType = null, ) { } diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php index 79d543044c2..1d08477b203 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php @@ -207,14 +207,15 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata // Evaluate DiscriminatorColumn attribute if (isset($classAttributes[Mapping\DiscriminatorColumn::class])) { $discrColumnAttribute = $classAttributes[Mapping\DiscriminatorColumn::class]; + assert($discrColumnAttribute instanceof Mapping\DiscriminatorColumn); $metadata->setDiscriminatorColumn( [ - 'name' => isset($discrColumnAttribute->name) ? (string) $discrColumnAttribute->name : null, - 'type' => isset($discrColumnAttribute->type) ? (string) $discrColumnAttribute->type : 'string', - 'length' => isset($discrColumnAttribute->length) ? (int) $discrColumnAttribute->length : 255, - 'columnDefinition' => isset($discrColumnAttribute->columnDefinition) ? (string) $discrColumnAttribute->columnDefinition : null, - 'enumType' => isset($discrColumnAttribute->enumType) ? (string) $discrColumnAttribute->enumType : null, + 'name' => $discrColumnAttribute->name, + 'type' => $discrColumnAttribute->type ?? 'string', + 'length' => $discrColumnAttribute->length ?? 255, + 'columnDefinition' => $discrColumnAttribute->columnDefinition, + 'enumType' => $discrColumnAttribute->enumType, ], ); } else { diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e84881876eb..f697897cc37 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -502,7 +502,7 @@ - + $value[0] $value[0] From 8f360f08c5588423f4fd9e0ebe471922989a34d8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 20 Dec 2022 07:28:33 +0100 Subject: [PATCH 202/475] Migrate Doctrine\ORM\Internal\CommitOrder to PHP 8.1 (#10323) --- .../ORM/Internal/CommitOrder/Edge.php | 28 ++++--------------- .../ORM/Internal/CommitOrder/Vertex.php | 28 ++++--------------- .../ORM/Internal/CommitOrder/VertexState.php | 12 +++----- .../ORM/Internal/CommitOrderCalculator.php | 27 ++++++------------ psalm-baseline.xml | 5 ++-- 5 files changed, 26 insertions(+), 74 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/CommitOrder/Edge.php b/lib/Doctrine/ORM/Internal/CommitOrder/Edge.php index f1457755ee1..29613f803db 100644 --- a/lib/Doctrine/ORM/Internal/CommitOrder/Edge.php +++ b/lib/Doctrine/ORM/Internal/CommitOrder/Edge.php @@ -7,28 +7,10 @@ /** @internal */ final class Edge { - /** - * @var string - * @readonly - */ - public $from; - - /** - * @var string - * @readonly - */ - public $to; - - /** - * @var int - * @readonly - */ - public $weight; - - public function __construct(string $from, string $to, int $weight) - { - $this->from = $from; - $this->to = $to; - $this->weight = $weight; + public function __construct( + public readonly string $from, + public readonly string $to, + public readonly int $weight, + ) { } } diff --git a/lib/Doctrine/ORM/Internal/CommitOrder/Vertex.php b/lib/Doctrine/ORM/Internal/CommitOrder/Vertex.php index c4747e032d1..b3d9f20eee7 100644 --- a/lib/Doctrine/ORM/Internal/CommitOrder/Vertex.php +++ b/lib/Doctrine/ORM/Internal/CommitOrder/Vertex.php @@ -9,30 +9,14 @@ /** @internal */ final class Vertex { - /** - * @var string - * @readonly - */ - public $hash; - - /** - * @var int - * @psalm-var VertexState::* - */ - public $state = VertexState::NOT_VISITED; - - /** - * @var ClassMetadata - * @readonly - */ - public $value; + public VertexState $state = VertexState::NotVisited; /** @var array */ - public $dependencyList = []; + public array $dependencyList = []; - public function __construct(string $hash, ClassMetadata $value) - { - $this->hash = $hash; - $this->value = $value; + public function __construct( + public readonly string $hash, + public readonly ClassMetadata $value, + ) { } } diff --git a/lib/Doctrine/ORM/Internal/CommitOrder/VertexState.php b/lib/Doctrine/ORM/Internal/CommitOrder/VertexState.php index 395db58d554..4a0645aa3a5 100644 --- a/lib/Doctrine/ORM/Internal/CommitOrder/VertexState.php +++ b/lib/Doctrine/ORM/Internal/CommitOrder/VertexState.php @@ -5,13 +5,9 @@ namespace Doctrine\ORM\Internal\CommitOrder; /** @internal */ -final class VertexState +enum VertexState { - public const NOT_VISITED = 0; - public const IN_PROGRESS = 1; - public const VISITED = 2; - - private function __construct() - { - } + case NotVisited; + case InProgress; + case Visited; } diff --git a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php index c3d91ba9f7d..a4467ba2b07 100644 --- a/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php +++ b/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php @@ -20,15 +20,6 @@ */ class CommitOrderCalculator { - /** @deprecated */ - public const NOT_VISITED = VertexState::NOT_VISITED; - - /** @deprecated */ - public const IN_PROGRESS = VertexState::IN_PROGRESS; - - /** @deprecated */ - public const VISITED = VertexState::VISITED; - /** * Matrix of nodes (aka. vertex). * @@ -81,7 +72,7 @@ public function addDependency(string $fromHash, string $toHash, int $weight): vo public function sort(): array { foreach ($this->nodeList as $vertex) { - if ($vertex->state !== VertexState::NOT_VISITED) { + if ($vertex->state !== VertexState::NotVisited) { continue; } @@ -103,17 +94,17 @@ public function sort(): array */ private function visit(Vertex $vertex): void { - $vertex->state = VertexState::IN_PROGRESS; + $vertex->state = VertexState::InProgress; foreach ($vertex->dependencyList as $edge) { $adjacentVertex = $this->nodeList[$edge->to]; switch ($adjacentVertex->state) { - case VertexState::VISITED: + case VertexState::Visited: // Do nothing, since node was already visited break; - case VertexState::IN_PROGRESS: + case VertexState::InProgress: if ( isset($adjacentVertex->dependencyList[$vertex->hash]) && $adjacentVertex->dependencyList[$vertex->hash]->weight < $edge->weight @@ -123,25 +114,25 @@ private function visit(Vertex $vertex): void foreach ($adjacentVertex->dependencyList as $adjacentEdge) { $adjacentEdgeVertex = $this->nodeList[$adjacentEdge->to]; - if ($adjacentEdgeVertex->state === VertexState::NOT_VISITED) { + if ($adjacentEdgeVertex->state === VertexState::NotVisited) { $this->visit($adjacentEdgeVertex); } } - $adjacentVertex->state = VertexState::VISITED; + $adjacentVertex->state = VertexState::Visited; $this->sortedNodeList[] = $adjacentVertex->value; } break; - case VertexState::NOT_VISITED: + case VertexState::NotVisited: $this->visit($adjacentVertex); } } - if ($vertex->state !== VertexState::VISITED) { - $vertex->state = VertexState::VISITED; + if ($vertex->state !== VertexState::Visited) { + $vertex->state = VertexState::Visited; $this->sortedNodeList[] = $vertex->value; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index eeadf9d905e..64249608a16 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -251,9 +251,8 @@ - - $vertex->state !== VertexState::VISITED - $vertex->state !== VertexState::VISITED + + $vertex->state !== VertexState::Visited From ad58c6a6e23e7818f9eb7b99759895d7fabcbcef Mon Sep 17 00:00:00 2001 From: michnovka Date: Tue, 20 Dec 2022 07:32:34 +0100 Subject: [PATCH 203/475] Cleanup code from PR10313 from 2.14.x (#10326) --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 3 +-- lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php | 2 +- tests/Doctrine/Tests/DbalTypes/CustomIntType.php | 5 +---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index cca839f6971..ac776f223da 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -691,8 +691,7 @@ class ClassMetadataInfo implements ClassMetadata, Stringable private InstantiatorInterface|null $instantiator = null; - /** @var TypedFieldMapper $typedFieldMapper */ - private $typedFieldMapper; + private TypedFieldMapper $typedFieldMapper; /** * Initializes a new ClassMetadata instance that will hold the object-relational mapping diff --git a/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php b/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php index 728482cfa65..7d3a996b31e 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php +++ b/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php @@ -23,7 +23,7 @@ final class DefaultTypedFieldMapper implements TypedFieldMapper { /** @var array|string> $typedFieldMappings */ - private $typedFieldMappings; + private array $typedFieldMappings; private const DEFAULT_TYPED_FIELD_MAPPINGS = [ DateInterval::class => Types::DATEINTERVAL, diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIntType.php b/tests/Doctrine/Tests/DbalTypes/CustomIntType.php index 3a0e6136209..4ed60311e58 100644 --- a/tests/Doctrine/Tests/DbalTypes/CustomIntType.php +++ b/tests/Doctrine/Tests/DbalTypes/CustomIntType.php @@ -10,10 +10,7 @@ class CustomIntType extends IntegerType { public const NAME = 'custom_int_type'; - /** - * {@inheritdoc} - */ - public function getName() + public function getName(): string { return self::NAME; } From bdb3fc72dadd87dd6a1f4ef4a9a6b70fae2d5608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 20 Dec 2022 19:55:18 +0100 Subject: [PATCH 204/475] Allow Lexer 3 Co-authored-by: Alexander M. Turek --- composer.json | 2 +- .../Query/AST/Functions/IdentityFunction.php | 2 +- .../ORM/Query/AST/Functions/TrimFunction.php | 4 +- lib/Doctrine/ORM/Query/Lexer.php | 6 +- lib/Doctrine/ORM/Query/SqlWalker.php | 6 +- tests/Doctrine/Tests/ORM/Query/LexerTest.php | 133 ++++++------------ 6 files changed, 54 insertions(+), 99 deletions(-) diff --git a/composer.json b/composer.json index 9e8df045933..98a6acca518 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "doctrine/event-manager": "^1.2 || ^2", "doctrine/inflector": "^1.4 || ^2.0", "doctrine/instantiator": "^1.3", - "doctrine/lexer": "^2", + "doctrine/lexer": "^2.1 || ^3", "doctrine/persistence": "^3.1.1", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^5.4 || ^6.0" diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 18b396e58f8..720f5d48fba 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -81,7 +81,7 @@ public function parse(Parser $parser): void $token = $parser->getLexer()->token; assert($token !== null); - $this->fieldMapping = $token['value']; + $this->fieldMapping = $token->value; } $parser->match(TokenType::T_CLOSE_PARENTHESIS); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php index 10ab8ebb1ad..f3f2fb9f3df 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php @@ -56,7 +56,7 @@ public function parse(Parser $parser): void $parser->match(TokenType::T_STRING); assert($lexer->token !== null); - $this->trimChar = $lexer->token['value']; + $this->trimChar = $lexer->token->value; } if ($this->leading || $this->trailing || $this->both || $this->trimChar) { @@ -90,7 +90,7 @@ private function parseTrimMode(Parser $parser): void { $lexer = $parser->getLexer(); assert($lexer->lookahead !== null); - $value = $lexer->lookahead['value']; + $value = $lexer->lookahead->value; if (strcasecmp('leading', $value) === 0) { $parser->match(TokenType::T_LEADING); diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index 33db4c24287..b768cede77c 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -29,7 +29,7 @@ class Lexer extends AbstractLexer * * @param string $input A query string. */ - public function __construct($input) + public function __construct(string $input) { $this->setInput($input); } @@ -56,9 +56,7 @@ protected function getNonCatchablePatterns(): array return ['\s+', '--.*', '(.)']; } - /** - * {@inheritdoc} - */ + /** @param string $value */ protected function getType(&$value): TokenType { $type = TokenType::T_NONE; diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index c70a633068a..bb924324b15 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1062,7 +1062,7 @@ public function walkOrderByItem(AST\OrderByItem $orderByItem): string $expr = $orderByItem->expression; $sql = $expr instanceof AST\Node ? $expr->dispatch($this) - : $this->walkResultVariable($this->queryComponents[$expr]['token']['value']); + : $this->walkResultVariable($this->queryComponents[$expr]['token']->value); $this->orderedColumnsMap[$sql] = $type; @@ -2144,7 +2144,7 @@ public function walkArithmeticTerm(AST\Node|string $term): string { if (is_string($term)) { return isset($this->queryComponents[$term]) - ? $this->walkResultVariable($this->queryComponents[$term]['token']['value']) + ? $this->walkResultVariable($this->queryComponents[$term]['token']->value) : $term; } @@ -2164,7 +2164,7 @@ public function walkArithmeticFactor(AST\Node|string $factor): string { if (is_string($factor)) { return isset($this->queryComponents[$factor]) - ? $this->walkResultVariable($this->queryComponents[$factor]['token']['value']) + ? $this->walkResultVariable($this->queryComponents[$factor]['token']->value) : $factor; } diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index a2240719bec..121b8730d8d 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\Common\Lexer\Token; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\OrmTestCase; @@ -18,8 +19,8 @@ public function testScannerRecognizesTokens($type, $value): void $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals($type, $token['type']); - self::assertEquals($value, $token['value']); + self::assertEquals($type, $token->type); + self::assertEquals($value, $token->value); } public function testScannerRecognizesTerminalString(): void @@ -35,7 +36,7 @@ public function testScannerRecognizesTerminalString(): void $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_ALL, $token['type']); + self::assertEquals(TokenType::T_ALL, $token->type); } public function testScannerRecognizesDecimalInteger(): void @@ -43,8 +44,8 @@ public function testScannerRecognizesDecimalInteger(): void $lexer = new Lexer('1234'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_INTEGER, $token['type']); - self::assertEquals(1234, $token['value']); + self::assertEquals(TokenType::T_INTEGER, $token->type); + self::assertEquals(1234, $token->value); } public function testScannerRecognizesFloat(): void @@ -52,8 +53,8 @@ public function testScannerRecognizesFloat(): void $lexer = new Lexer('1.234'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_FLOAT, $token['type']); - self::assertEquals(1.234, $token['value']); + self::assertEquals(TokenType::T_FLOAT, $token->type); + self::assertEquals(1.234, $token->value); } public function testScannerRecognizesFloatWithExponent(): void @@ -61,8 +62,8 @@ public function testScannerRecognizesFloatWithExponent(): void $lexer = new Lexer('1.2e3'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_FLOAT, $token['type']); - self::assertEquals(1.2e3, $token['value']); + self::assertEquals(TokenType::T_FLOAT, $token->type); + self::assertEquals(1.2e3, $token->value); } public function testScannerRecognizesFloatWithExponent2(): void @@ -70,8 +71,8 @@ public function testScannerRecognizesFloatWithExponent2(): void $lexer = new Lexer('0.2e3'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_FLOAT, $token['type']); - self::assertEquals(.2e3, $token['value']); + self::assertEquals(TokenType::T_FLOAT, $token->type); + self::assertEquals(.2e3, $token->value); } public function testScannerRecognizesFloatWithNegativeExponent(): void @@ -79,8 +80,8 @@ public function testScannerRecognizesFloatWithNegativeExponent(): void $lexer = new Lexer('7E-10'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_FLOAT, $token['type']); - self::assertEquals(7E-10, $token['value']); + self::assertEquals(TokenType::T_FLOAT, $token->type); + self::assertEquals(7E-10, $token->value); } public function testScannerRecognizesFloatBig(): void @@ -88,8 +89,8 @@ public function testScannerRecognizesFloatBig(): void $lexer = new Lexer('123456789.01'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_FLOAT, $token['type']); - self::assertEquals(1.2345678901e8, $token['value']); + self::assertEquals(TokenType::T_FLOAT, $token->type); + self::assertEquals(1.2345678901e8, $token->value); } public function testScannerRecognizesFloatContainingWhitespace(): void @@ -97,14 +98,14 @@ public function testScannerRecognizesFloatContainingWhitespace(): void $lexer = new Lexer('- 1.234e2'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_MINUS, $token['type']); - self::assertEquals('-', $token['value']); + self::assertEquals(TokenType::T_MINUS, $token->type); + self::assertEquals('-', $token->value); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_FLOAT, $token['type']); - self::assertNotEquals(-1.234e2, $token['value']); - self::assertEquals(1.234e2, $token['value']); + self::assertEquals(TokenType::T_FLOAT, $token->type); + self::assertNotEquals(-1.234e2, $token->value); + self::assertEquals(1.234e2, $token->value); } public function testScannerRecognizesStringContainingWhitespace(): void @@ -112,8 +113,8 @@ public function testScannerRecognizesStringContainingWhitespace(): void $lexer = new Lexer("'This is a string.'"); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_STRING, $token['type']); - self::assertEquals('This is a string.', $token['value']); + self::assertEquals(TokenType::T_STRING, $token->type); + self::assertEquals('This is a string.', $token->value); } public function testScannerRecognizesStringContainingSingleQuotes(): void @@ -121,8 +122,8 @@ public function testScannerRecognizesStringContainingSingleQuotes(): void $lexer = new Lexer("'abc''defg'''"); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_STRING, $token['type']); - self::assertEquals("abc'defg'", $token['value']); + self::assertEquals(TokenType::T_STRING, $token->type); + self::assertEquals("abc'defg'", $token->value); } public function testScannerRecognizesInputParameter(): void @@ -130,8 +131,8 @@ public function testScannerRecognizesInputParameter(): void $lexer = new Lexer('?1'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_INPUT_PARAMETER, $token['type']); - self::assertEquals('?1', $token['value']); + self::assertEquals(TokenType::T_INPUT_PARAMETER, $token->type); + self::assertEquals('?1', $token->value); } public function testScannerRecognizesNamedInputParameter(): void @@ -139,8 +140,8 @@ public function testScannerRecognizesNamedInputParameter(): void $lexer = new Lexer(':name'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_INPUT_PARAMETER, $token['type']); - self::assertEquals(':name', $token['value']); + self::assertEquals(TokenType::T_INPUT_PARAMETER, $token->type); + self::assertEquals(':name', $token->value); } public function testScannerRecognizesNamedInputParameterStartingWithUnderscore(): void @@ -148,8 +149,8 @@ public function testScannerRecognizesNamedInputParameterStartingWithUnderscore() $lexer = new Lexer(':_name'); $lexer->moveNext(); $token = $lexer->lookahead; - self::assertEquals(TokenType::T_INPUT_PARAMETER, $token['type']); - self::assertEquals(':_name', $token['value']); + self::assertEquals(TokenType::T_INPUT_PARAMETER, $token->type); + self::assertEquals(':_name', $token->value); } public function testScannerTokenizesASimpleQueryCorrectly(): void @@ -158,69 +159,25 @@ public function testScannerTokenizesASimpleQueryCorrectly(): void $lexer = new Lexer($dql); $tokens = [ - [ - 'value' => 'SELECT', - 'type' => TokenType::T_SELECT, - 'position' => 0, - ], - [ - 'value' => 'u', - 'type' => TokenType::T_IDENTIFIER, - 'position' => 7, - ], - [ - 'value' => 'FROM', - 'type' => TokenType::T_FROM, - 'position' => 9, - ], - [ - 'value' => 'My\Namespace\User', - 'type' => TokenType::T_FULLY_QUALIFIED_NAME, - 'position' => 14, - ], - [ - 'value' => 'u', - 'type' => TokenType::T_IDENTIFIER, - 'position' => 32, - ], - [ - 'value' => 'WHERE', - 'type' => TokenType::T_WHERE, - 'position' => 34, - ], - [ - 'value' => 'u', - 'type' => TokenType::T_IDENTIFIER, - 'position' => 40, - ], - [ - 'value' => '.', - 'type' => TokenType::T_DOT, - 'position' => 41, - ], - [ - 'value' => 'name', - 'type' => TokenType::T_IDENTIFIER, - 'position' => 42, - ], - [ - 'value' => '=', - 'type' => TokenType::T_EQUALS, - 'position' => 47, - ], - [ - 'value' => "Jack O'Neil", - 'type' => TokenType::T_STRING, - 'position' => 49, - ], + new Token('SELECT', TokenType::T_SELECT, 0), + new Token('u', TokenType::T_IDENTIFIER, 7), + new Token('FROM', TokenType::T_FROM, 9), + new Token('My\Namespace\User', TokenType::T_FULLY_QUALIFIED_NAME, 14), + new Token('u', TokenType::T_IDENTIFIER, 32), + new Token('WHERE', TokenType::T_WHERE, 34), + new Token('u', TokenType::T_IDENTIFIER, 40), + new Token('.', TokenType::T_DOT, 41), + new Token('name', TokenType::T_IDENTIFIER, 42), + new Token('=', TokenType::T_EQUALS, 47), + new Token("Jack O'Neil", TokenType::T_STRING, 49), ]; foreach ($tokens as $expected) { $lexer->moveNext(); $actual = $lexer->lookahead; - self::assertEquals($expected['value'], $actual['value']); - self::assertEquals($expected['type'], $actual['type']); - self::assertEquals($expected['position'], $actual['position']); + self::assertEquals($expected->value, $actual->value); + self::assertEquals($expected->type, $actual->type); + self::assertEquals($expected->position, $actual->position); } self::assertFalse($lexer->moveNext()); From b31afda33b451fb0ea47fd9fef2824b4980bf1dd Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 29 Dec 2022 15:11:29 +0100 Subject: [PATCH 205/475] Modernize QueryExpressionVisitor (#10346) --- .../ORM/Query/QueryExpressionVisitor.php | 67 ++++++------------- .../ORM/Query/QueryExpressionVisitorTest.php | 6 -- .../ORM/Query/SqlExpressionVisitorTest.php | 16 +---- 3 files changed, 22 insertions(+), 67 deletions(-) diff --git a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php index 595eb253814..3e0ec655a46 100644 --- a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php +++ b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php @@ -12,7 +12,6 @@ use RuntimeException; use function count; -use function defined; use function str_replace; use function str_starts_with; @@ -21,23 +20,22 @@ */ class QueryExpressionVisitor extends ExpressionVisitor { - /** @var array */ - private static $operatorMap = [ + private const OPERATOR_MAP = [ Comparison::GT => Expr\Comparison::GT, Comparison::GTE => Expr\Comparison::GTE, Comparison::LT => Expr\Comparison::LT, Comparison::LTE => Expr\Comparison::LTE, ]; - /** @var Expr */ - private $expr; + private readonly Expr $expr; /** @var list */ - private $parameters = []; + private array $parameters = []; /** @param mixed[] $queryAliases */ - public function __construct(private $queryAliases) - { + public function __construct( + private readonly array $queryAliases, + ) { $this->expr = new Expr(); } @@ -47,37 +45,25 @@ public function __construct(private $queryAliases) * * @return ArrayCollection */ - public function getParameters() + public function getParameters(): ArrayCollection { return new ArrayCollection($this->parameters); } - /** - * Clears parameters. - * - * @return void - */ - public function clearParameters() + public function clearParameters(): void { $this->parameters = []; } /** * Converts Criteria expression to Query one based on static map. - * - * @param string $criteriaOperator - * - * @return string|null */ - private static function convertComparisonOperator($criteriaOperator) + private static function convertComparisonOperator(string $criteriaOperator): string|null { - return self::$operatorMap[$criteriaOperator] ?? null; + return self::OPERATOR_MAP[$criteriaOperator] ?? null; } - /** - * {@inheritDoc} - */ - public function walkCompositeExpression(CompositeExpression $expr) + public function walkCompositeExpression(CompositeExpression $expr): mixed { $expressionList = []; @@ -85,27 +71,15 @@ public function walkCompositeExpression(CompositeExpression $expr) $expressionList[] = $this->dispatch($child); } - switch ($expr->getType()) { - case CompositeExpression::TYPE_AND: - return new Expr\Andx($expressionList); - - case CompositeExpression::TYPE_OR: - return new Expr\Orx($expressionList); - - default: - // Multiversion support for `doctrine/collections` before and after v2.1.0 - if (defined(CompositeExpression::class . '::TYPE_NOT') && $expr->getType() === CompositeExpression::TYPE_NOT) { - return $this->expr->not($expressionList[0]); - } - - throw new RuntimeException('Unknown composite ' . $expr->getType()); - } + return match ($expr->getType()) { + CompositeExpression::TYPE_AND => new Expr\Andx($expressionList), + CompositeExpression::TYPE_OR => new Expr\Orx($expressionList), + CompositeExpression::TYPE_NOT => $this->expr->not($expressionList[0]), + default => throw new RuntimeException('Unknown composite ' . $expr->getType()), + }; } - /** - * {@inheritDoc} - */ - public function walkComparison(Comparison $comparison) + public function walkComparison(Comparison $comparison): mixed { if (! isset($this->queryAliases[0])) { throw new QueryException('No aliases are set before invoking walkComparison().'); @@ -199,10 +173,7 @@ public function walkComparison(Comparison $comparison) } } - /** - * {@inheritDoc} - */ - public function walkValue(Value $value) + public function walkValue(Value $value): mixed { return $value->getValue(); } diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 422af47fb0a..64902b7628b 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -13,8 +13,6 @@ use Doctrine\ORM\Query\QueryExpressionVisitor; use PHPUnit\Framework\TestCase; -use function method_exists; - /** * Test for QueryExpressionVisitor */ @@ -108,10 +106,6 @@ public function testWalkOrCompositeExpression(): void public function testWalkNotCompositeExpression(): void { - if (! method_exists(CriteriaBuilder::class, 'not')) { - self::markTestSkipped('doctrine/collections in version ^2.1 is required for this test to run.'); - } - $qb = new QueryBuilder(); $cb = new CriteriaBuilder(); diff --git a/tests/Doctrine/Tests/ORM/Query/SqlExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/SqlExpressionVisitorTest.php index cad4e43847f..3e2a3e30eda 100644 --- a/tests/Doctrine/Tests/ORM/Query/SqlExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SqlExpressionVisitorTest.php @@ -11,17 +11,11 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use function method_exists; - class SqlExpressionVisitorTest extends TestCase { - /** @var SqlExpressionVisitor */ - private $visitor; - - /** @var BasicEntityPersister&MockObject */ - private $persister; - /** @var ClassMetadata */ - private $classMetadata; + private SqlExpressionVisitor $visitor; + private BasicEntityPersister&MockObject $persister; + private ClassMetadata $classMetadata; protected function setUp(): void { @@ -32,10 +26,6 @@ protected function setUp(): void public function testWalkNotCompositeExpression(): void { - if (! method_exists(CriteriaBuilder::class, 'not')) { - self::markTestSkipped('doctrine/collections in version ^2.1 is required for this test to run.'); - } - $cb = new CriteriaBuilder(); $this->persister From 57f256912aa1921654771a6f369a7c8041151caf Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 30 Dec 2022 19:53:30 +0100 Subject: [PATCH 206/475] Leverage new ArrayParameterType constants (#10352) --- composer.json | 2 +- .../Persisters/Entity/BasicEntityPersister.php | 7 ++++--- lib/Doctrine/ORM/Query/ParameterTypeInferer.php | 6 +++--- .../Tests/ORM/Query/ParameterTypeInfererTest.php | 16 ++++++++-------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 98a6acca518..3c5a837c474 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-ctype": "*", "doctrine/collections": "^2.1", "doctrine/common": "^3.3", - "doctrine/dbal": "^3.5", + "doctrine/dbal": "^3.6@dev", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.2 || ^2", "doctrine/inflector": "^1.4 || ^2.0", diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 6921d580f3c..039696f1fd9 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Expr\Comparison; use Doctrine\Common\Util\ClassUtils; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; @@ -1885,9 +1886,9 @@ private function getArrayBindingType(ParameterType|int|string $type): int } return match ($type) { - ParameterType::STRING => Connection::PARAM_STR_ARRAY, - ParameterType::INTEGER => Connection::PARAM_INT_ARRAY, - ParameterType::ASCII => Connection::PARAM_ASCII_STR_ARRAY, + ParameterType::STRING => ArrayParameterType::STRING, + ParameterType::INTEGER => ArrayParameterType::INTEGER, + ParameterType::ASCII => ArrayParameterType::ASCII, }; } diff --git a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php index 1fe6cb03caa..51bcee79b06 100644 --- a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php +++ b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php @@ -8,7 +8,7 @@ use DateInterval; use DateTimeImmutable; use DateTimeInterface; -use Doctrine\DBAL\Connection; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Types; @@ -64,8 +64,8 @@ public static function inferType(mixed $value): ParameterType|int|string } return is_int($firstValue) - ? Connection::PARAM_INT_ARRAY - : Connection::PARAM_STR_ARRAY; + ? ArrayParameterType::INTEGER + : ArrayParameterType::STRING; } return ParameterType::STRING; diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index 2a2f4827faa..397cac522cd 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -7,7 +7,7 @@ use DateInterval; use DateTime; use DateTimeImmutable; -use Doctrine\DBAL\Connection; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Query\ParameterTypeInferer; @@ -18,7 +18,7 @@ class ParameterTypeInfererTest extends OrmTestCase { - /** @psalm-return Generator */ + /** @psalm-return Generator */ public function providerParameterTypeInferer(): Generator { yield 'integer' => [1, Types::INTEGER]; @@ -27,15 +27,15 @@ public function providerParameterTypeInferer(): Generator yield 'datetime_object' => [new DateTime(), Types::DATETIME_MUTABLE]; yield 'datetime_immutable_object' => [new DateTimeImmutable(), Types::DATETIME_IMMUTABLE]; yield 'date_interval_object' => [new DateInterval('P1D'), Types::DATEINTERVAL]; - yield 'array_of_int' => [[2], Connection::PARAM_INT_ARRAY]; - yield 'array_of_string' => [['foo'], Connection::PARAM_STR_ARRAY]; - yield 'array_of_numeric_string' => [['1', '2'], Connection::PARAM_STR_ARRAY]; - yield 'empty_array' => [[], Connection::PARAM_STR_ARRAY]; + yield 'array_of_int' => [[2], ArrayParameterType::INTEGER]; + yield 'array_of_string' => [['foo'], ArrayParameterType::STRING]; + yield 'array_of_numeric_string' => [['1', '2'], ArrayParameterType::STRING]; + yield 'empty_array' => [[], ArrayParameterType::STRING]; yield 'boolean' => [true, Types::BOOLEAN]; yield 'int_backed_enum' => [AccessLevel::Admin, Types::INTEGER]; yield 'string_backed_enum' => [UserStatus::Active, Types::STRING]; - yield 'array_of_int_backed_enum' => [[AccessLevel::Admin], Connection::PARAM_INT_ARRAY]; - yield 'array_of_string_backed_enum' => [[UserStatus::Active], Connection::PARAM_STR_ARRAY]; + yield 'array_of_int_backed_enum' => [[AccessLevel::Admin], ArrayParameterType::INTEGER]; + yield 'array_of_string_backed_enum' => [[UserStatus::Active], ArrayParameterType::STRING]; } /** @dataProvider providerParameterTypeInferer */ From 9062af45ca3f2025ed2a1868cf784cbc539b1abd Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 31 Dec 2022 16:18:08 +0100 Subject: [PATCH 207/475] Fix build for DBAL 4 (#10354) --- lib/Doctrine/ORM/AbstractQuery.php | 4 +++- .../ORM/Persisters/Entity/BasicEntityPersister.php | 11 ++++++----- .../ORM/Persisters/Entity/EntityPersister.php | 5 +++-- lib/Doctrine/ORM/Query/ParameterTypeInferer.php | 2 +- phpstan.neon | 3 +++ .../Tests/ORM/Query/ParameterTypeInfererTest.php | 4 ++-- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 8040aad1958..ccfd230c807 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -1030,9 +1030,11 @@ private function getTimestampKey(): TimestampCacheKey|null protected function getHydrationCacheId(): array { $parameters = []; + $types = []; foreach ($this->getParameters() as $parameter) { $parameters[$parameter->getName()] = $this->processParameterValue($parameter->getValue()); + $types[$parameter->getName()] = $parameter->getType(); } $sql = $this->getSQL(); @@ -1044,7 +1046,7 @@ protected function getHydrationCacheId(): array ksort($hints); assert($queryCacheProfile !== null); - return $queryCacheProfile->generateCacheKeys($sql, $parameters, $hints); + return $queryCacheProfile->generateCacheKeys($sql, $parameters, $types, $hints); } /** diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 039696f1fd9..c2d6a98c4ae 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -332,7 +332,7 @@ protected function fetchVersionAndNotUpsertableValues(ClassMetadata $versionedCl * @param mixed[] $id * * @return list - * @psalm-return list + * @psalm-return list */ private function extractIdentifierTypes(array $id, ClassMetadata $versionedClass): array { @@ -1812,7 +1812,7 @@ public function expandParameters(array $criteria): array * - class to which the field belongs to * * @return mixed[][] - * @psalm-return array{0: array, 1: list} + * @psalm-return array{0: array, 1: list} */ private function expandToManyParameters(array $criteria): array { @@ -1834,8 +1834,8 @@ private function expandToManyParameters(array $criteria): array /** * Infers field types to be used by parameter type casting. * - * @return list - * @psalm-return list + * @return list + * @psalm-return list * * @throws QueryException */ @@ -1879,7 +1879,8 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar return $types; } - private function getArrayBindingType(ParameterType|int|string $type): int + /** @psalm-return ArrayParameterType::* */ + private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int { if (! $type instanceof ParameterType) { $type = Type::getType((string) $type)->getBindingType(); diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index cdda39119cd..4967c876e71 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Persisters\Entity; use Doctrine\Common\Collections\Criteria; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; use Doctrine\ORM\Mapping\ClassMetadata; @@ -69,14 +70,14 @@ public function getCountSQL(array|Criteria $criteria = []): string; * * @param string[] $criteria * - * @psalm-return array{list, list} + * @psalm-return array{list, list} */ public function expandParameters(array $criteria): array; /** * Expands Criteria Parameters by walking the expressions and grabbing all parameters and types from it. * - * @psalm-return array{list, list} + * @psalm-return array{list, list} */ public function expandCriteriaParameters(Criteria $criteria): array; diff --git a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php index 51bcee79b06..dae28faee18 100644 --- a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php +++ b/lib/Doctrine/ORM/Query/ParameterTypeInferer.php @@ -29,7 +29,7 @@ final class ParameterTypeInferer * - Type (\Doctrine\DBAL\Types\Type::*) * - Connection (\Doctrine\DBAL\Connection::PARAM_*) */ - public static function inferType(mixed $value): ParameterType|int|string + public static function inferType(mixed $value): ParameterType|ArrayParameterType|int|string { if (is_int($value)) { return Types::INTEGER; diff --git a/phpstan.neon b/phpstan.neon index 3a599ca6fc9..fd318f3530a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -16,3 +16,6 @@ parameters: - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' path: lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php + - + message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' + path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index 397cac522cd..8e9c531ae74 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -18,7 +18,7 @@ class ParameterTypeInfererTest extends OrmTestCase { - /** @psalm-return Generator */ + /** @psalm-return Generator */ public function providerParameterTypeInferer(): Generator { yield 'integer' => [1, Types::INTEGER]; @@ -39,7 +39,7 @@ public function providerParameterTypeInferer(): Generator } /** @dataProvider providerParameterTypeInferer */ - public function testParameterTypeInferer(mixed $value, ParameterType|int|string $expected): void + public function testParameterTypeInferer(mixed $value, ParameterType|ArrayParameterType|int|string $expected): void { self::assertEquals($expected, ParameterTypeInferer::inferType($value)); } From 75bff1d983e5f64c5fa4d167ab7bb7588e1b9465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 20 Dec 2022 19:55:18 +0100 Subject: [PATCH 208/475] Drop doctrine/lexer 2 This allows us to have a totally typed lexer --- composer.json | 2 +- lib/Doctrine/ORM/Query/Lexer.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 86a3e58cf6b..5324d36b2aa 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "doctrine/event-manager": "^1.2 || ^2", "doctrine/inflector": "^1.4 || ^2.0", "doctrine/instantiator": "^1.3 || ^2", - "doctrine/lexer": "^2.1 || ^3", + "doctrine/lexer": "^3", "doctrine/persistence": "^3.1.1", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^5.4 || ^6.0" diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/lib/Doctrine/ORM/Query/Lexer.php index b768cede77c..810010f5db4 100644 --- a/lib/Doctrine/ORM/Query/Lexer.php +++ b/lib/Doctrine/ORM/Query/Lexer.php @@ -56,8 +56,7 @@ protected function getNonCatchablePatterns(): array return ['\s+', '--.*', '(.)']; } - /** @param string $value */ - protected function getType(&$value): TokenType + protected function getType(string &$value): TokenType { $type = TokenType::T_NONE; From 7e379f6872ad79debc2be4625a48cc1c79d96d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 3 Jan 2023 22:55:49 +0100 Subject: [PATCH 209/475] Migrate files with the least changes to PHP 8 These are the lowest hanging fruits I could find after running Rector: I looked for files with a diff of 2 lines. I did not include some changes that I find controversial, such as marking some constants as final when we should maybe consider making classes themselves final. --- lib/Doctrine/ORM/Cache/DefaultCacheFactory.php | 2 +- lib/Doctrine/ORM/EntityRepository.php | 2 +- lib/Doctrine/ORM/Id/AssignedGenerator.php | 4 +--- lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php | 2 +- lib/Doctrine/ORM/Mapping/ChainTypedFieldMapper.php | 2 +- lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php | 2 ++ lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php | 2 +- lib/Doctrine/ORM/Query/Filter/SQLFilter.php | 3 ++- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index f9240f2a5f2..d9f082c9324 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -47,7 +47,7 @@ public function setFileLockRegionDirectory(string $fileLockRegionDirectory): voi $this->fileLockRegionDirectory = $fileLockRegionDirectory; } - public function getFileLockRegionDirectory(): string + public function getFileLockRegionDirectory(): string|null { return $this->fileLockRegionDirectory; } diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index bc5597877cc..71dd1e47437 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -196,7 +196,7 @@ protected function getClassMetadata(): ClassMetadata * * @psalm-return AbstractLazyCollection&Selectable */ - public function matching(Criteria $criteria): AbstractLazyCollection + public function matching(Criteria $criteria): AbstractLazyCollection&Selectable { $persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName); diff --git a/lib/Doctrine/ORM/Id/AssignedGenerator.php b/lib/Doctrine/ORM/Id/AssignedGenerator.php index 093049ec13c..6c3c8a21d6c 100644 --- a/lib/Doctrine/ORM/Id/AssignedGenerator.php +++ b/lib/Doctrine/ORM/Id/AssignedGenerator.php @@ -7,8 +7,6 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\EntityMissingAssignedId; -use function get_class; - /** * Special generator for application-assigned identifiers (doesn't really generate anything). */ @@ -23,7 +21,7 @@ class AssignedGenerator extends AbstractIdGenerator */ public function generateId(EntityManagerInterface $em, object|null $entity): array { - $class = $em->getClassMetadata(get_class($entity)); + $class = $em->getClassMetadata($entity::class); $idFields = $class->getIdentifierFieldNames(); $identifier = []; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 5c027270650..6dd8adee66d 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -45,7 +45,7 @@ class ObjectHydrator extends AbstractHydrator private array $initializedCollections = []; /** @var array */ - private $uninitializedCollections = []; + private array $uninitializedCollections = []; /** @var mixed[] */ private array $existingCollections = []; diff --git a/lib/Doctrine/ORM/Mapping/ChainTypedFieldMapper.php b/lib/Doctrine/ORM/Mapping/ChainTypedFieldMapper.php index 0a8544cec1e..e4a9a590f03 100644 --- a/lib/Doctrine/ORM/Mapping/ChainTypedFieldMapper.php +++ b/lib/Doctrine/ORM/Mapping/ChainTypedFieldMapper.php @@ -12,7 +12,7 @@ final class ChainTypedFieldMapper implements TypedFieldMapper * @readonly * @var TypedFieldMapper[] $typedFieldMappers */ - private array $typedFieldMappers; + private readonly array $typedFieldMappers; public function __construct(TypedFieldMapper ...$typedFieldMappers) { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 926b85e09fd..366ed2bc37f 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -588,6 +588,8 @@ protected function initializeReflection(ClassMetadataInterface $class, Reflectio protected function getDriver(): MappingDriver { + assert($this->driver !== null); + return $this->driver; } diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php index 2256e37a290..783b55f21fd 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php @@ -60,7 +60,7 @@ public function getPropertyAttributes(ReflectionProperty $property): array * * @template T of MappingAttribute */ - public function getPropertyAttribute(ReflectionProperty $property, $attributeName) + public function getPropertyAttribute(ReflectionProperty $property, string $attributeName) { if ($this->isRepeatable($attributeName)) { throw new LogicException(sprintf( diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php index 1d1dfed0e70..29f37756eb3 100644 --- a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php +++ b/lib/Doctrine/ORM/Query/Filter/SQLFilter.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\ParameterTypeInferer; use InvalidArgumentException; +use Stringable; use function array_map; use function implode; @@ -23,7 +24,7 @@ * * @abstract */ -abstract class SQLFilter +abstract class SQLFilter implements Stringable { /** * Parameters for the filter. From 84e78b8200ed39c6a820a5f6f78f07defa947659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 4 Jan 2023 21:16:16 +0100 Subject: [PATCH 210/475] Remove deprecated methods and classes This is a follow-up for https://github.com/doctrine/orm/pull/9876 --- UPGRADE.md | 18 ++++- lib/Doctrine/ORM/Event/LifecycleEventArgs.php | 72 ------------------- lib/Doctrine/ORM/Event/OnClearEventArgs.php | 17 ----- lib/Doctrine/ORM/Event/OnFlushEventArgs.php | 19 ----- lib/Doctrine/ORM/Event/PostFlushEventArgs.php | 19 ----- lib/Doctrine/ORM/Event/PostLoadEventArgs.php | 4 ++ .../ORM/Event/PostPersistEventArgs.php | 4 ++ .../ORM/Event/PostRemoveEventArgs.php | 4 ++ .../ORM/Event/PostUpdateEventArgs.php | 4 ++ lib/Doctrine/ORM/Event/PreFlushEventArgs.php | 17 ----- .../ORM/Event/PrePersistEventArgs.php | 4 ++ lib/Doctrine/ORM/Event/PreRemoveEventArgs.php | 4 ++ lib/Doctrine/ORM/Event/PreUpdateEventArgs.php | 3 + psalm.xml | 1 - .../ORM/Functional/Ticket/DDC2996Test.php | 2 +- 15 files changed, 45 insertions(+), 147 deletions(-) delete mode 100644 lib/Doctrine/ORM/Event/LifecycleEventArgs.php diff --git a/UPGRADE.md b/UPGRADE.md index b78f85375ae..7042424c553 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,21 @@ # Upgrade to 3.0 +## Removed `getEntityManager()` in `Doctrine\ORM\Event\OnClearEventArgs` and `Doctrine\ORM\Event\*FlushEventArgs` + +Use `getObjectManager()` instead. + +## BC BREAK: Removed `Doctrine\ORM\Event\LifecycleEventArgs` class. + +Use one of the dedicated event classes instead: + +* `Doctrine\ORM\Event\PrePersistEventArgs` +* `Doctrine\ORM\Event\PreUpdateEventArgs` +* `Doctrine\ORM\Event\PreRemoveEventArgs` +* `Doctrine\ORM\Event\PostPersistEventArgs` +* `Doctrine\ORM\Event\PostUpdateEventArgs` +* `Doctrine\ORM\Event\PostRemoveEventArgs` +* `Doctrine\ORM\Event\PostLoadEventArgs` + ## BC BREAK: Removed `AttributeDriver::$entityAnnotationClasses` and `AttributeDriver::getReader()` * If you need to change the behavior of `AttributeDriver::isTransient()`, @@ -180,7 +196,7 @@ class MyStrategy implements NamingStrategy } ``` -## BC BREAK: Remove `StaticPHPDriver` and `DriverChain` +## BC BREAK: Remove `StaticPHPDriver` and `DriverChain` Use `Doctrine\Persistence\Mapping\Driver\StaticPHPDriver` and `Doctrine\Persistence\Mapping\Driver\MappingDriverChain` from diff --git a/lib/Doctrine/ORM/Event/LifecycleEventArgs.php b/lib/Doctrine/ORM/Event/LifecycleEventArgs.php deleted file mode 100644 index 88327f03d34..00000000000 --- a/lib/Doctrine/ORM/Event/LifecycleEventArgs.php +++ /dev/null @@ -1,72 +0,0 @@ - - */ -class LifecycleEventArgs extends BaseLifecycleEventArgs -{ - /** @param object $object */ - public function __construct($object, EntityManagerInterface $objectManager) - { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9875', - 'The %s class is deprecated and will be removed in ORM 3.0. Use %s instead.', - self::class, - BaseLifecycleEventArgs::class, - ); - - parent::__construct($object, $objectManager); - } - - /** - * Retrieves associated Entity. - * - * @deprecated 2.13. Use {@see getObject} instead. - * - * @return object - */ - public function getEntity() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9875', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObject() instead.', - __METHOD__, - ); - - return $this->getObject(); - } - - /** - * Retrieves associated EntityManager. - * - * @deprecated 2.13. Use {@see getObjectManager} instead. - * - * @return EntityManagerInterface - */ - public function getEntityManager() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9875', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__, - ); - - return $this->getObjectManager(); - } -} diff --git a/lib/Doctrine/ORM/Event/OnClearEventArgs.php b/lib/Doctrine/ORM/Event/OnClearEventArgs.php index ef6854b5c28..29a42f24aad 100644 --- a/lib/Doctrine/ORM/Event/OnClearEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClearEventArgs.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Event; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\Event\OnClearEventArgs as BaseOnClearEventArgs; @@ -17,20 +16,4 @@ */ class OnClearEventArgs extends BaseOnClearEventArgs { - /** - * Retrieves associated EntityManager. - * - * @deprecated 2.13. Use {@see getObjectManager} instead. - */ - public function getEntityManager(): EntityManagerInterface - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9875', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__, - ); - - return $this->getObjectManager(); - } } diff --git a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php index 4a3a7525178..b0594cac1b0 100644 --- a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Event; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\Event\ManagerEventArgs; @@ -17,22 +16,4 @@ */ class OnFlushEventArgs extends ManagerEventArgs { - /** - * Retrieve associated EntityManager. - * - * @deprecated 2.13. Use {@see getObjectManager} instead. - * - * @return EntityManagerInterface - */ - public function getEntityManager() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9875', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__, - ); - - return $this->getObjectManager(); - } } diff --git a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php b/lib/Doctrine/ORM/Event/PostFlushEventArgs.php index 8eb7d4f7b68..ca41ba8ee57 100644 --- a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PostFlushEventArgs.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Event; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\Event\ManagerEventArgs; @@ -17,22 +16,4 @@ */ class PostFlushEventArgs extends ManagerEventArgs { - /** - * Retrieves associated EntityManager. - * - * @deprecated 2.13. Use {@see getObjectManager} instead. - * - * @return EntityManagerInterface - */ - public function getEntityManager() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9875', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__, - ); - - return $this->getObjectManager(); - } } diff --git a/lib/Doctrine/ORM/Event/PostLoadEventArgs.php b/lib/Doctrine/ORM/Event/PostLoadEventArgs.php index 6365f360db3..8344e681337 100644 --- a/lib/Doctrine/ORM/Event/PostLoadEventArgs.php +++ b/lib/Doctrine/ORM/Event/PostLoadEventArgs.php @@ -4,6 +4,10 @@ namespace Doctrine\ORM\Event; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\LifecycleEventArgs; + +/** @extends LifecycleEventArgs */ final class PostLoadEventArgs extends LifecycleEventArgs { } diff --git a/lib/Doctrine/ORM/Event/PostPersistEventArgs.php b/lib/Doctrine/ORM/Event/PostPersistEventArgs.php index 49773f8b790..926ac1c21c1 100644 --- a/lib/Doctrine/ORM/Event/PostPersistEventArgs.php +++ b/lib/Doctrine/ORM/Event/PostPersistEventArgs.php @@ -4,6 +4,10 @@ namespace Doctrine\ORM\Event; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\LifecycleEventArgs; + +/** @extends LifecycleEventArgs */ final class PostPersistEventArgs extends LifecycleEventArgs { } diff --git a/lib/Doctrine/ORM/Event/PostRemoveEventArgs.php b/lib/Doctrine/ORM/Event/PostRemoveEventArgs.php index 8e105a57435..8bf857e9fc1 100644 --- a/lib/Doctrine/ORM/Event/PostRemoveEventArgs.php +++ b/lib/Doctrine/ORM/Event/PostRemoveEventArgs.php @@ -4,6 +4,10 @@ namespace Doctrine\ORM\Event; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\LifecycleEventArgs; + +/** @extends LifecycleEventArgs */ final class PostRemoveEventArgs extends LifecycleEventArgs { } diff --git a/lib/Doctrine/ORM/Event/PostUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PostUpdateEventArgs.php index 927f3c3487f..c9ff00477d4 100644 --- a/lib/Doctrine/ORM/Event/PostUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PostUpdateEventArgs.php @@ -4,6 +4,10 @@ namespace Doctrine\ORM\Event; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\LifecycleEventArgs; + +/** @extends LifecycleEventArgs */ final class PostUpdateEventArgs extends LifecycleEventArgs { } diff --git a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php index 1424e46ab14..671535c960c 100644 --- a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Event; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\Event\ManagerEventArgs; @@ -17,20 +16,4 @@ */ class PreFlushEventArgs extends ManagerEventArgs { - /** - * @deprecated 2.13. Use {@see getObjectManager} instead. - * - * @return EntityManagerInterface - */ - public function getEntityManager() - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/9875', - 'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.', - __METHOD__, - ); - - return $this->getObjectManager(); - } } diff --git a/lib/Doctrine/ORM/Event/PrePersistEventArgs.php b/lib/Doctrine/ORM/Event/PrePersistEventArgs.php index 5554ef3d757..e70c3cf7366 100644 --- a/lib/Doctrine/ORM/Event/PrePersistEventArgs.php +++ b/lib/Doctrine/ORM/Event/PrePersistEventArgs.php @@ -4,6 +4,10 @@ namespace Doctrine\ORM\Event; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\LifecycleEventArgs; + +/** @extends LifecycleEventArgs */ final class PrePersistEventArgs extends LifecycleEventArgs { } diff --git a/lib/Doctrine/ORM/Event/PreRemoveEventArgs.php b/lib/Doctrine/ORM/Event/PreRemoveEventArgs.php index 042b737983b..3af0d02930f 100644 --- a/lib/Doctrine/ORM/Event/PreRemoveEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreRemoveEventArgs.php @@ -4,6 +4,10 @@ namespace Doctrine\ORM\Event; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\Event\LifecycleEventArgs; + +/** @extends LifecycleEventArgs */ final class PreRemoveEventArgs extends LifecycleEventArgs { } diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php index c9f16fdbcb9..32eaf65c081 100644 --- a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -6,6 +6,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\PersistentCollection; +use Doctrine\Persistence\Event\LifecycleEventArgs; use InvalidArgumentException; use function get_debug_type; @@ -13,6 +14,8 @@ /** * Class that holds event arguments for a preUpdate event. + * + * @extends LifecycleEventArgs */ class PreUpdateEventArgs extends LifecycleEventArgs { diff --git a/psalm.xml b/psalm.xml index 21a82d88ef5..db04a6dd84c 100644 --- a/psalm.xml +++ b/psalm.xml @@ -23,7 +23,6 @@ - diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index 543df7c89b7..873393f870a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -76,7 +76,7 @@ class DDC2996UserPreference #[PreFlush] public function preFlush($event): void { - $em = $event->getEntityManager(); + $em = $event->getObjectManager(); $uow = $em->getUnitOfWork(); if ($uow->getOriginalEntityData($this->user)) { From a3db423eab7a17aa56bbe65e4ed3d1c3e9a353d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 4 Jan 2023 18:20:29 +0100 Subject: [PATCH 211/475] Migrate classes with the fewest changes to PHP 8 --- lib/Doctrine/ORM/EntityNotFoundException.php | 5 +--- .../ORM/Event/LoadClassMetadataEventArgs.php | 4 +-- lib/Doctrine/ORM/Event/PreUpdateEventArgs.php | 25 +++++-------------- .../ORM/Exception/EntityMissingAssignedId.php | 3 +-- .../ORM/Mapping/Driver/AttributeDriver.php | 5 ++-- lib/Doctrine/ORM/PessimisticLockException.php | 3 +-- .../ORM/Query/Exec/SingleSelectExecutor.php | 4 +-- .../Exec/SingleTableDeleteUpdateExecutor.php | 4 +-- lib/Doctrine/ORM/Query/Expr.php | 4 +-- lib/Doctrine/ORM/Query/Parameter.php | 4 +-- lib/Doctrine/ORM/Query/ResultSetMapping.php | 5 ++-- .../Tools/Pagination/CountOutputWalker.php | 4 +-- .../ORM/TransactionRequiredException.php | 3 +-- 13 files changed, 23 insertions(+), 50 deletions(-) diff --git a/lib/Doctrine/ORM/EntityNotFoundException.php b/lib/Doctrine/ORM/EntityNotFoundException.php index 693dfa4ecbe..142dc8a4ab5 100644 --- a/lib/Doctrine/ORM/EntityNotFoundException.php +++ b/lib/Doctrine/ORM/EntityNotFoundException.php @@ -18,12 +18,9 @@ class EntityNotFoundException extends RuntimeException implements ORMException /** * Static constructor. * - * @param string $className * @param string[] $id - * - * @return self */ - public static function fromClassNameAndIdentifier($className, array $id) + public static function fromClassNameAndIdentifier(string $className, array $id): self { $ids = []; diff --git a/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php b/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php index 94adb108c74..b45061687ea 100644 --- a/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php +++ b/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php @@ -17,10 +17,8 @@ class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs { /** * Retrieve associated EntityManager. - * - * @return EntityManagerInterface */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { return $this->getObjectManager(); } diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php index 32eaf65c081..7d6b203baf9 100644 --- a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -20,7 +20,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs { /** @var array */ - private $entityChangeSet; + private array $entityChangeSet; /** * @param object $entity @@ -40,19 +40,15 @@ public function __construct($entity, EntityManagerInterface $em, array &$changeS * @return mixed[][] * @psalm-return array */ - public function getEntityChangeSet() + public function getEntityChangeSet(): array { return $this->entityChangeSet; } /** * Checks if field has a changeset. - * - * @param string $field - * - * @return bool */ - public function hasChangedField($field) + public function hasChangedField(string $field): bool { return isset($this->entityChangeSet[$field]); } @@ -60,11 +56,9 @@ public function hasChangedField($field) /** * Gets the old value of the changeset of the changed field. * - * @param string $field - * * @return mixed */ - public function getOldValue($field) + public function getOldValue(string $field) { $this->assertValidField($field); @@ -74,11 +68,9 @@ public function getOldValue($field) /** * Gets the new value of the changeset of the changed field. * - * @param string $field - * * @return mixed */ - public function getNewValue($field) + public function getNewValue(string $field) { $this->assertValidField($field); @@ -87,13 +79,8 @@ public function getNewValue($field) /** * Sets the new value of this field. - * - * @param string $field - * @param mixed $value - * - * @return void */ - public function setNewValue($field, $value) + public function setNewValue(string $field, mixed $value): void { $this->assertValidField($field); diff --git a/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php b/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php index 36954b5eff8..d5664367b32 100644 --- a/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php +++ b/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php @@ -10,8 +10,7 @@ final class EntityMissingAssignedId extends LogicException implements ORMException { - /** @param object $entity */ - public static function forField($entity, string $field): self + public static function forField(object $entity, string $field): self { return new self('Entity of type ' . get_debug_type($entity) . " is missing an assigned ID for field '" . $field . "'. " . 'The identifier generation strategy for this entity requires the ID field to be populated before ' . diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php index cc0f9945cfa..3ccbb7c81d6 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php @@ -20,7 +20,6 @@ use function class_exists; use function constant; use function defined; -use function get_class; class AttributeDriver implements MappingDriver { @@ -31,7 +30,7 @@ class AttributeDriver implements MappingDriver Mapping\MappedSuperclass::class => 2, ]; - private AttributeReader $reader; + private readonly AttributeReader $reader; /** @param array $paths */ public function __construct(array $paths) @@ -46,7 +45,7 @@ public function isTransient(string $className): bool foreach ($classAttributes as $a) { $attr = $a instanceof RepeatableAttributeCollection ? $a[0] : $a; - if (isset(self::ENTITY_ATTRIBUTE_CLASSES[get_class($attr)])) { + if (isset(self::ENTITY_ATTRIBUTE_CLASSES[$attr::class])) { return false; } } diff --git a/lib/Doctrine/ORM/PessimisticLockException.php b/lib/Doctrine/ORM/PessimisticLockException.php index 41df2d73804..c71560f80bb 100644 --- a/lib/Doctrine/ORM/PessimisticLockException.php +++ b/lib/Doctrine/ORM/PessimisticLockException.php @@ -9,8 +9,7 @@ class PessimisticLockException extends RuntimeException implements ORMException { - /** @return PessimisticLockException */ - public static function lockFailed() + public static function lockFailed(): self { return new self('The pessimistic lock failed.'); } diff --git a/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php b/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php index 11700a3f4f8..9220922e5af 100644 --- a/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php @@ -23,10 +23,8 @@ public function __construct(SelectStatement $AST, SqlWalker $sqlWalker) /** * {@inheritDoc} - * - * @return Result */ - public function execute(Connection $conn, array $params, array $types) + public function execute(Connection $conn, array $params, array $types): Result { return $conn->executeQuery($this->_sqlStatements, $params, $types, $this->queryCacheProfile); } diff --git a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php index bf67d86d30b..55ddb7f9339 100644 --- a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php @@ -31,10 +31,8 @@ public function __construct(AST\Node $AST, $sqlWalker) /** * {@inheritDoc} - * - * @return int */ - public function execute(Connection $conn, array $params, array $types) + public function execute(Connection $conn, array $params, array $types): int { if ($conn instanceof PrimaryReadReplicaConnection) { $conn->ensureConnectedToPrimary(); diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index 1b3372914fa..beaec30fca6 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -531,7 +531,7 @@ public function length(mixed $x): Expr\Func * * @param scalar $literal Argument to be converted to literal. */ - public function literal(mixed $literal): Expr\Literal + public function literal(bool|string|int|float $literal): Expr\Literal { return new Expr\Literal($this->quoteLiteral($literal)); } @@ -541,7 +541,7 @@ public function literal(mixed $literal): Expr\Literal * * @param scalar $literal The literal value. */ - private function quoteLiteral(mixed $literal): string + private function quoteLiteral(bool|string|int|float $literal): string { if (is_int($literal) || is_float($literal)) { return (string) $literal; diff --git a/lib/Doctrine/ORM/Query/Parameter.php b/lib/Doctrine/ORM/Query/Parameter.php index 00b9bdf071b..43eb7a41239 100644 --- a/lib/Doctrine/ORM/Query/Parameter.php +++ b/lib/Doctrine/ORM/Query/Parameter.php @@ -24,7 +24,7 @@ public static function normalizeName(int|string $name): string /** * The parameter name. */ - private string $name; + private readonly string $name; /** * The parameter value. @@ -39,7 +39,7 @@ public static function normalizeName(int|string $name): string /** * Whether the parameter type was explicitly specified or not */ - private bool $typeSpecified; + private readonly bool $typeSpecified; public function __construct(int|string $name, mixed $value, mixed $type = null) { diff --git a/lib/Doctrine/ORM/Query/ResultSetMapping.php b/lib/Doctrine/ORM/Query/ResultSetMapping.php index 7bd81208336..612474db1d2 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMapping.php +++ b/lib/Doctrine/ORM/Query/ResultSetMapping.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Query; -use function array_merge; use function count; /** @@ -226,7 +225,7 @@ public function addIndexBy(string $alias, string $fieldName): static { $found = false; - foreach (array_merge($this->metaMappings, $this->fieldMappings) as $columnName => $columnFieldName) { + foreach ([...$this->metaMappings, ...$this->fieldMappings] as $columnName => $columnFieldName) { if (! ($columnFieldName === $fieldName && $this->columnOwnerMap[$columnName] === $alias)) { continue; } @@ -387,7 +386,7 @@ public function addScalarResult(string $columnName, string|int $alias, string $t * * @return $this */ - public function addEnumResult($columnName, $enumType) + public function addEnumResult(string $columnName, string $enumType): static { $this->enumMappings[$columnName] = $enumType; diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index 6189422841e..60f891c0f03 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -38,8 +38,8 @@ */ class CountOutputWalker extends SqlWalker { - private AbstractPlatform $platform; - private ResultSetMapping $rsm; + private readonly AbstractPlatform $platform; + private readonly ResultSetMapping $rsm; /** * {@inheritdoc} diff --git a/lib/Doctrine/ORM/TransactionRequiredException.php b/lib/Doctrine/ORM/TransactionRequiredException.php index 2f9ef347f7c..611454478a8 100644 --- a/lib/Doctrine/ORM/TransactionRequiredException.php +++ b/lib/Doctrine/ORM/TransactionRequiredException.php @@ -14,8 +14,7 @@ */ class TransactionRequiredException extends LogicException implements ORMException { - /** @return TransactionRequiredException */ - public static function transactionRequired() + public static function transactionRequired(): self { return new self('An open transaction is required for this operation.'); } From d83b1e338c836ce670daa6f8e5e34d936e64dfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 Jan 2023 18:34:46 +0100 Subject: [PATCH 212/475] Remove ClassMetadataInfo --- UPGRADE.md | 4 + lib/Doctrine/ORM/Mapping/ClassMetadata.php | 3017 +++++++++++++++- .../ORM/Mapping/ClassMetadataInfo.php | 3025 ----------------- lib/Doctrine/ORM/UnitOfWork.php | 3 +- phpcs.xml.dist | 2 +- phpstan-baseline.neon | 6 +- psalm-baseline.xml | 2 +- psalm.xml | 4 +- .../ORM/Mapping/MappingDriverTestCase.php | 2 +- 9 files changed, 3020 insertions(+), 3045 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php diff --git a/UPGRADE.md b/UPGRADE.md index 7042424c553..f595f117c00 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -4,6 +4,10 @@ Use `getObjectManager()` instead. +## BC BREAK: Removed `Doctrine\ORM\Mapping\ClassMetadataInfo` class + +Use `Doctrine\ORM\Mapping\ClassMetadata` instead. + ## BC BREAK: Removed `Doctrine\ORM\Event\LifecycleEventArgs` class. Use one of the dedicated event classes instead: diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 57e9df0f23f..b600b14329e 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -4,25 +4,3022 @@ namespace Doctrine\ORM\Mapping; +use BackedEnum; +use BadMethodCallException; +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\Deprecations\Deprecation; +use Doctrine\Instantiator\Instantiator; +use Doctrine\Instantiator\InstantiatorInterface; +use Doctrine\ORM\Cache\Exception\NonCacheableEntityAssociation; +use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\Id\AbstractIdGenerator; +use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; +use Doctrine\Persistence\Mapping\ReflectionService; +use InvalidArgumentException; +use LogicException; +use ReflectionClass; +use ReflectionNamedType; +use ReflectionProperty; +use RuntimeException; +use Stringable; + +use function array_diff; +use function array_flip; +use function array_intersect; +use function array_keys; +use function array_map; +use function array_merge; +use function array_pop; +use function array_values; +use function assert; +use function class_exists; +use function count; +use function enum_exists; +use function explode; +use function gettype; +use function in_array; +use function interface_exists; +use function is_array; +use function is_subclass_of; +use function ltrim; +use function method_exists; +use function spl_object_id; +use function str_contains; +use function str_replace; +use function strtolower; +use function trait_exists; +use function trim; + /** - * {@inheritDoc} + * A ClassMetadata instance holds all the object-relational mapping metadata + * of an entity and its associations. + * + * Once populated, ClassMetadata instances are usually cached in a serialized form. + * + * IMPORTANT NOTE: + * + * The fields of this class are only public for 2 reasons: + * 1) To allow fast READ access. + * 2) To drastically reduce the size of a serialized instance (private/protected members + * get the whole class name, namespace inclusive, prepended to every property in + * the serialized representation). * - * @todo remove or rename ClassMetadataInfo to ClassMetadata * @template-covariant T of object - * @template-extends ClassMetadataInfo + * @template-implements PersistenceClassMetadata + * @psalm-type FieldMapping = array{ + * type: string, + * fieldName: string, + * columnName: string, + * length?: int, + * id?: bool, + * nullable?: bool, + * notInsertable?: bool, + * notUpdatable?: bool, + * generated?: int, + * enumType?: class-string, + * columnDefinition?: string, + * precision?: int, + * scale?: int, + * unique?: string, + * inherited?: class-string, + * originalClass?: class-string, + * originalField?: string, + * quoted?: bool, + * declared?: class-string, + * declaredField?: string, + * options?: array + * } + * @psalm-type JoinColumnData = array{ + * name: string, + * referencedColumnName: string, + * unique?: bool, + * quoted?: bool, + * fieldName?: string, + * onDelete?: string, + * columnDefinition?: string, + * nullable?: bool, + * } + * @psalm-type AssociationMapping = array{ + * cache?: array, + * cascade: array, + * declared?: class-string, + * fetch: mixed, + * fieldName: string, + * id?: bool, + * inherited?: class-string, + * indexBy?: string, + * inversedBy: string|null, + * isCascadeRemove: bool, + * isCascadePersist: bool, + * isCascadeRefresh: bool, + * isCascadeMerge: bool, + * isCascadeDetach: bool, + * isOnDeleteCascade?: bool, + * isOwningSide: bool, + * joinColumns?: array, + * joinColumnFieldNames?: array, + * joinTable?: array, + * joinTableColumns?: list, + * mappedBy: string|null, + * orderBy?: array, + * originalClass?: class-string, + * originalField?: string, + * orphanRemoval?: bool, + * relationToSourceKeyColumns?: array, + * relationToTargetKeyColumns?: array, + * sourceEntity: class-string, + * sourceToTargetKeyColumns?: array, + * targetEntity: class-string, + * targetToSourceKeyColumns?: array, + * type: int, + * unique?: bool, + * } + * @psalm-type DiscriminatorColumnMapping = array{ + * name: string, + * fieldName: string, + * type: string, + * length?: int, + * columnDefinition?: string|null, + * enumType?: class-string|null, + * } */ -class ClassMetadata extends ClassMetadataInfo +class ClassMetadata implements PersistenceClassMetadata, Stringable { + /* The inheritance mapping types */ + /** + * NONE means the class does not participate in an inheritance hierarchy + * and therefore does not need an inheritance mapping type. + */ + public const INHERITANCE_TYPE_NONE = 1; + + /** + * JOINED means the class will be persisted according to the rules of + * Class Table Inheritance. + */ + public const INHERITANCE_TYPE_JOINED = 2; + + /** + * SINGLE_TABLE means the class will be persisted according to the rules of + * Single Table Inheritance. + */ + public const INHERITANCE_TYPE_SINGLE_TABLE = 3; + + /** + * TABLE_PER_CLASS means the class will be persisted according to the rules + * of Concrete Table Inheritance. + */ + public const INHERITANCE_TYPE_TABLE_PER_CLASS = 4; + + /* The Id generator types. */ + /** + * AUTO means the generator type will depend on what the used platform prefers. + * Offers full portability. + */ + public const GENERATOR_TYPE_AUTO = 1; + + /** + * SEQUENCE means a separate sequence object will be used. Platforms that do + * not have native sequence support may emulate it. Full portability is currently + * not guaranteed. + */ + public const GENERATOR_TYPE_SEQUENCE = 2; + + /** + * IDENTITY means an identity column is used for id generation. The database + * will fill in the id column on insertion. Platforms that do not support + * native identity columns may emulate them. Full portability is currently + * not guaranteed. + */ + public const GENERATOR_TYPE_IDENTITY = 4; + + /** + * NONE means the class does not have a generated id. That means the class + * must have a natural, manually assigned id. + */ + public const GENERATOR_TYPE_NONE = 5; + + /** + * CUSTOM means that customer will use own ID generator that supposedly work + */ + public const GENERATOR_TYPE_CUSTOM = 7; + + /** + * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time + * by doing a property-by-property comparison with the original data. This will + * be done for all entities that are in MANAGED state at commit-time. + * + * This is the default change tracking policy. + */ + public const CHANGETRACKING_DEFERRED_IMPLICIT = 1; + + /** + * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time + * by doing a property-by-property comparison with the original data. This will + * be done only for entities that were explicitly saved (through persist() or a cascade). + */ + public const CHANGETRACKING_DEFERRED_EXPLICIT = 2; + + /** + * NOTIFY means that Doctrine relies on the entities sending out notifications + * when their properties change. Such entity classes must implement + * the NotifyPropertyChanged interface. + */ + public const CHANGETRACKING_NOTIFY = 3; + + /** + * Specifies that an association is to be fetched when it is first accessed. + */ + public const FETCH_LAZY = 2; + + /** + * Specifies that an association is to be fetched when the owner of the + * association is fetched. + */ + public const FETCH_EAGER = 3; + + /** + * Specifies that an association is to be fetched lazy (on first access) and that + * commands such as Collection#count, Collection#slice are issued directly against + * the database if the collection is not yet initialized. + */ + public const FETCH_EXTRA_LAZY = 4; + + /** + * Identifies a one-to-one association. + */ + public const ONE_TO_ONE = 1; + + /** + * Identifies a many-to-one association. + */ + public const MANY_TO_ONE = 2; + + /** + * Identifies a one-to-many association. + */ + public const ONE_TO_MANY = 4; + + /** + * Identifies a many-to-many association. + */ + public const MANY_TO_MANY = 8; + + /** + * Combined bitmask for to-one (single-valued) associations. + */ + public const TO_ONE = 3; + + /** + * Combined bitmask for to-many (collection-valued) associations. + */ + public const TO_MANY = 12; + + /** + * ReadOnly cache can do reads, inserts and deletes, cannot perform updates or employ any locks, + */ + public const CACHE_USAGE_READ_ONLY = 1; + + /** + * Nonstrict Read Write Cache doesn’t employ any locks but can do inserts, update and deletes. + */ + public const CACHE_USAGE_NONSTRICT_READ_WRITE = 2; + + /** + * Read Write Attempts to lock the entity before update/delete. + */ + public const CACHE_USAGE_READ_WRITE = 3; + + /** + * The value of this column is never generated by the database. + */ + public const GENERATED_NEVER = 0; + + /** + * The value of this column is generated by the database on INSERT, but not on UPDATE. + */ + public const GENERATED_INSERT = 1; + + /** + * The value of this column is generated by the database on both INSERT and UDPATE statements. + */ + public const GENERATED_ALWAYS = 2; + + /** + * READ-ONLY: The namespace the entity class is contained in. + * + * @todo Not really needed. Usage could be localized. + */ + public string|null $namespace = null; + + /** + * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance + * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same + * as {@link $name}. + * + * @psalm-var class-string + */ + public string $rootEntityName; + + /** + * READ-ONLY: The definition of custom generator. Only used for CUSTOM + * generator type + * + * The definition has the following structure: + * + * array( + * 'class' => 'ClassName', + * ) + * + * + * @todo Merge with tableGeneratorDefinition into generic generatorDefinition + * @var array|null + */ + public array|null $customGeneratorDefinition = null; + + /** + * The name of the custom repository class used for the entity class. + * (Optional). + * + * @psalm-var ?class-string + */ + public string|null $customRepositoryClassName = null; + + /** + * READ-ONLY: Whether this class describes the mapping of a mapped superclass. + */ + public bool $isMappedSuperclass = false; + + /** + * READ-ONLY: Whether this class describes the mapping of an embeddable class. + */ + public bool $isEmbeddedClass = false; + + /** + * READ-ONLY: The names of the parent classes (ancestors). + * + * @psalm-var list + */ + public array $parentClasses = []; + + /** + * READ-ONLY: The names of all subclasses (descendants). + * + * @psalm-var list + */ + public array $subClasses = []; + + /** + * READ-ONLY: The names of all embedded classes based on properties. + * + * @psalm-var array + */ + public array $embeddedClasses = []; + + /** + * READ-ONLY: The field names of all fields that are part of the identifier/primary key + * of the mapped entity class. + * + * @psalm-var list + */ + public array $identifier = []; + + /** + * READ-ONLY: The inheritance mapping type used by the class. + * + * @psalm-var self::INHERITANCE_TYPE_* + */ + public int $inheritanceType = self::INHERITANCE_TYPE_NONE; + + /** + * READ-ONLY: The Id generator type used by the class. + * + * @psalm-var self::GENERATOR_TYPE_* + */ + public int $generatorType = self::GENERATOR_TYPE_NONE; + + /** + * READ-ONLY: The field mappings of the class. + * Keys are field names and values are mapping definitions. + * + * The mapping definition array has the following values: + * + * - fieldName (string) + * The name of the field in the Entity. + * + * - type (string) + * The type name of the mapped field. Can be one of Doctrine's mapping types + * or a custom mapping type. + * + * - columnName (string, optional) + * The column name. Optional. Defaults to the field name. + * + * - length (integer, optional) + * The database length of the column. Optional. Default value taken from + * the type. + * + * - id (boolean, optional) + * Marks the field as the primary key of the entity. Multiple fields of an + * entity can have the id attribute, forming a composite key. + * + * - nullable (boolean, optional) + * Whether the column is nullable. Defaults to FALSE. + * + * - 'notInsertable' (boolean, optional) + * Whether the column is not insertable. Optional. Is only set if value is TRUE. + * + * - 'notUpdatable' (boolean, optional) + * Whether the column is updatable. Optional. Is only set if value is TRUE. + * + * - columnDefinition (string, optional, schema-only) + * The SQL fragment that is used when generating the DDL for the column. + * + * - precision (integer, optional, schema-only) + * The precision of a decimal column. Only valid if the column type is decimal. + * + * - scale (integer, optional, schema-only) + * The scale of a decimal column. Only valid if the column type is decimal. + * + * - 'unique' (string, optional, schema-only) + * Whether a unique constraint should be generated for the column. + * + * @var mixed[] + * @psalm-var array + */ + public array $fieldMappings = []; + + /** + * READ-ONLY: An array of field names. Used to look up field names from column names. + * Keys are column names and values are field names. + * + * @psalm-var array + */ + public array $fieldNames = []; + + /** + * READ-ONLY: A map of field names to column names. Keys are field names and values column names. + * Used to look up column names from field names. + * This is the reverse lookup map of $_fieldNames. + * + * @deprecated 3.0 Remove this. + * + * @var mixed[] + */ + public array $columnNames = []; + + /** + * READ-ONLY: The discriminator value of this class. + * + * This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies + * where a discriminator column is used. + * + * @see discriminatorColumn + */ + public mixed $discriminatorValue = null; + + /** + * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. + * + * This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies + * where a discriminator column is used. + * + * @see discriminatorColumn + * + * @var array + * + * @psalm-var array + */ + public array $discriminatorMap = []; + + /** + * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE + * inheritance mappings. + * + * @var array + * @psalm-var DiscriminatorColumnMapping|null + */ + public array|null $discriminatorColumn = null; + + /** + * READ-ONLY: The primary table definition. The definition is an array with the + * following entries: + * + * name => + * schema => + * indexes => array + * uniqueConstraints => array + * + * @var mixed[] + * @psalm-var array{ + * name: string, + * schema?: string, + * indexes?: array, + * uniqueConstraints?: array, + * options?: array, + * quoted?: bool + * } + */ + public array $table; + + /** + * READ-ONLY: The registered lifecycle callbacks for entities of this class. + * + * @psalm-var array> + */ + public array $lifecycleCallbacks = []; + + /** + * READ-ONLY: The registered entity listeners. + * + * @psalm-var array> + */ + public array $entityListeners = []; + + /** + * READ-ONLY: The association mappings of this class. + * + * The mapping definition array supports the following keys: + * + * - fieldName (string) + * The name of the field in the entity the association is mapped to. + * + * - targetEntity (string) + * The class name of the target entity. If it is fully-qualified it is used as is. + * If it is a simple, unqualified class name the namespace is assumed to be the same + * as the namespace of the source entity. + * + * - mappedBy (string, required for bidirectional associations) + * The name of the field that completes the bidirectional association on the owning side. + * This key must be specified on the inverse side of a bidirectional association. + * + * - inversedBy (string, required for bidirectional associations) + * The name of the field that completes the bidirectional association on the inverse side. + * This key must be specified on the owning side of a bidirectional association. + * + * - cascade (array, optional) + * The names of persistence operations to cascade on the association. The set of possible + * values are: "persist", "remove", "detach", "merge", "refresh", "all" (implies all others). + * + * - orderBy (array, one-to-many/many-to-many only) + * A map of field names (of the target entity) to sorting directions (ASC/DESC). + * Example: array('priority' => 'desc') + * + * - fetch (integer, optional) + * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. + * Possible values are: ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY. + * + * - joinTable (array, optional, many-to-many only) + * Specification of the join table and its join columns (foreign keys). + * Only valid for many-to-many mappings. Note that one-to-many associations can be mapped + * through a join table by simply mapping the association as many-to-many with a unique + * constraint on the join table. + * + * - indexBy (string, optional, to-many only) + * Specification of a field on target-entity that is used to index the collection by. + * This field HAS to be either the primary key or a unique column. Otherwise the collection + * does not contain all the entities that are actually related. + * + * A join table definition has the following structure: + *
+     * array(
+     *     'name' => ,
+     *      'joinColumns' => array(),
+     *      'inverseJoinColumns' => array()
+     * )
+     * 
+ * + * @psalm-var array + */ + public array $associationMappings = []; + + /** + * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. + */ + public bool $isIdentifierComposite = false; + + /** + * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. + * + * This flag is necessary because some code blocks require special treatment of this cases. + */ + public bool $containsForeignIdentifier = false; + + /** + * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one ENUM type. + * + * This flag is necessary because some code blocks require special treatment of this cases. + */ + public bool $containsEnumIdentifier = false; + + /** + * READ-ONLY: The ID generator used for generating IDs for this class. + * + * @todo Remove! + */ + public AbstractIdGenerator $idGenerator; + + /** + * READ-ONLY: The definition of the sequence generator of this class. Only used for the + * SEQUENCE generation strategy. + * + * The definition has the following structure: + * + * array( + * 'sequenceName' => 'name', + * 'allocationSize' => '20', + * 'initialValue' => '1' + * ) + * + * + * @var array|null + * @psalm-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed}|null + * @todo Merge with tableGeneratorDefinition into generic generatorDefinition + */ + public array|null $sequenceGeneratorDefinition = null; + /** - * Repeating the ClassMetadataInfo constructor to infer correctly the template with PHPStan + * READ-ONLY: The policy used for change-tracking on entities of this class. + */ + public int $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; + + /** + * READ-ONLY: A Flag indicating whether one or more columns of this class + * have to be reloaded after insert / update operations. + */ + public bool $requiresFetchAfterChange = false; + + /** + * READ-ONLY: A flag for whether or not instances of this class are to be versioned + * with optimistic locking. + */ + public bool $isVersioned = false; + + /** + * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). + */ + public string|null $versionField = null; + + /** @var mixed[]|null */ + public array|null $cache = null; + + /** + * The ReflectionClass instance of the mapped class. + * + * @var ReflectionClass|null + */ + public ReflectionClass|null $reflClass = null; + + /** + * Is this entity marked as "read-only"? + * + * That means it is never considered for change-tracking in the UnitOfWork. It is a very helpful performance + * optimization for entities that are immutable, either in your domain or through the relation database + * (coming from a view, or a history table for example). + */ + public bool $isReadOnly = false; + + /** + * NamingStrategy determining the default column and table names. + */ + protected NamingStrategy $namingStrategy; + + /** + * The ReflectionProperty instances of the mapped class. * - * @see https://github.com/doctrine/orm/issues/8709 + * @var array + */ + public array $reflFields = []; + + private InstantiatorInterface|null $instantiator = null; + + private TypedFieldMapper $typedFieldMapper; + + /** + * Initializes a new ClassMetadata instance that will hold the object-relational mapping + * metadata of the class with the given name. * - * @param string $entityName The name of the entity class the new instance is used for. - * @psalm-param class-string $entityName + * @param string $name The name of the entity class the new instance is used for. + * @psalm-param class-string $name */ - public function __construct($entityName, NamingStrategy|null $namingStrategy = null, TypedFieldMapper|null $typedFieldMapper = null) + public function __construct(public $name, NamingStrategy|null $namingStrategy = null, TypedFieldMapper|null $typedFieldMapper = null) { - parent::__construct($entityName, $namingStrategy, $typedFieldMapper); + $this->rootEntityName = $name; + $this->namingStrategy = $namingStrategy ?? new DefaultNamingStrategy(); + $this->instantiator = new Instantiator(); + $this->typedFieldMapper = $typedFieldMapper ?? new DefaultTypedFieldMapper(); + } + + /** + * Gets the ReflectionProperties of the mapped class. + * + * @return ReflectionProperty[]|null[] An array of ReflectionProperty instances. + * @psalm-return array + */ + public function getReflectionProperties(): array + { + return $this->reflFields; + } + + /** + * Gets a ReflectionProperty for a specific field of the mapped class. + */ + public function getReflectionProperty(string $name): ReflectionProperty|null + { + return $this->reflFields[$name]; + } + + /** + * Gets the ReflectionProperty for the single identifier field. + * + * @throws BadMethodCallException If the class has a composite identifier. + */ + public function getSingleIdReflectionProperty(): ReflectionProperty|null + { + if ($this->isIdentifierComposite) { + throw new BadMethodCallException('Class ' . $this->name . ' has a composite identifier.'); + } + + return $this->reflFields[$this->identifier[0]]; + } + + /** + * Extracts the identifier values of an entity of this class. + * + * For composite identifiers, the identifier values are returned as an array + * with the same order as the field order in {@link identifier}. + * + * @param object $entity + * + * @return array + */ + public function getIdentifierValues($entity): array + { + if ($this->isIdentifierComposite) { + $id = []; + + foreach ($this->identifier as $idField) { + $value = $this->reflFields[$idField]->getValue($entity); + + if ($value !== null) { + $id[$idField] = $value; + } + } + + return $id; + } + + $id = $this->identifier[0]; + $value = $this->reflFields[$id]->getValue($entity); + + if ($value === null) { + return []; + } + + return [$id => $value]; + } + + /** + * Populates the entity identifier of an entity. + * + * @psalm-param array $id + * + * @todo Rename to assignIdentifier() + */ + public function setIdentifierValues(object $entity, array $id): void + { + foreach ($id as $idField => $idValue) { + $this->reflFields[$idField]->setValue($entity, $idValue); + } + } + + /** + * Sets the specified field to the specified value on the given entity. + */ + public function setFieldValue(object $entity, string $field, mixed $value): void + { + $this->reflFields[$field]->setValue($entity, $value); + } + + /** + * Gets the specified field's value off the given entity. + */ + public function getFieldValue(object $entity, string $field): mixed + { + return $this->reflFields[$field]->getValue($entity); + } + + /** + * Creates a string representation of this instance. + * + * @return string The string representation of this instance. + * + * @todo Construct meaningful string representation. + */ + public function __toString(): string + { + return self::class . '@' . spl_object_id($this); + } + + /** + * Determines which fields get serialized. + * + * It is only serialized what is necessary for best unserialization performance. + * That means any metadata properties that are not set or empty or simply have + * their default value are NOT serialized. + * + * Parts that are also NOT serialized because they can not be properly unserialized: + * - reflClass (ReflectionClass) + * - reflFields (ReflectionProperty array) + * + * @return string[] The names of all the fields that should be serialized. + */ + public function __sleep() + { + // This metadata is always serialized/cached. + $serialized = [ + 'associationMappings', + 'columnNames', //TODO: 3.0 Remove this. Can use fieldMappings[$fieldName]['columnName'] + 'fieldMappings', + 'fieldNames', + 'embeddedClasses', + 'identifier', + 'isIdentifierComposite', // TODO: REMOVE + 'name', + 'namespace', // TODO: REMOVE + 'table', + 'rootEntityName', + 'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime. + ]; + + // The rest of the metadata is only serialized if necessary. + if ($this->changeTrackingPolicy !== self::CHANGETRACKING_DEFERRED_IMPLICIT) { + $serialized[] = 'changeTrackingPolicy'; + } + + if ($this->customRepositoryClassName) { + $serialized[] = 'customRepositoryClassName'; + } + + if ($this->inheritanceType !== self::INHERITANCE_TYPE_NONE) { + $serialized[] = 'inheritanceType'; + $serialized[] = 'discriminatorColumn'; + $serialized[] = 'discriminatorValue'; + $serialized[] = 'discriminatorMap'; + $serialized[] = 'parentClasses'; + $serialized[] = 'subClasses'; + } + + if ($this->generatorType !== self::GENERATOR_TYPE_NONE) { + $serialized[] = 'generatorType'; + if ($this->generatorType === self::GENERATOR_TYPE_SEQUENCE) { + $serialized[] = 'sequenceGeneratorDefinition'; + } + } + + if ($this->isMappedSuperclass) { + $serialized[] = 'isMappedSuperclass'; + } + + if ($this->isEmbeddedClass) { + $serialized[] = 'isEmbeddedClass'; + } + + if ($this->containsForeignIdentifier) { + $serialized[] = 'containsForeignIdentifier'; + } + + if ($this->containsEnumIdentifier) { + $serialized[] = 'containsEnumIdentifier'; + } + + if ($this->isVersioned) { + $serialized[] = 'isVersioned'; + $serialized[] = 'versionField'; + } + + if ($this->lifecycleCallbacks) { + $serialized[] = 'lifecycleCallbacks'; + } + + if ($this->entityListeners) { + $serialized[] = 'entityListeners'; + } + + if ($this->isReadOnly) { + $serialized[] = 'isReadOnly'; + } + + if ($this->customGeneratorDefinition) { + $serialized[] = 'customGeneratorDefinition'; + } + + if ($this->cache) { + $serialized[] = 'cache'; + } + + if ($this->requiresFetchAfterChange) { + $serialized[] = 'requiresFetchAfterChange'; + } + + return $serialized; + } + + /** + * Creates a new instance of the mapped class, without invoking the constructor. + */ + public function newInstance(): object + { + return $this->instantiator->instantiate($this->name); + } + + /** + * Restores some state that can not be serialized/unserialized. + */ + public function wakeupReflection(ReflectionService $reflService): void + { + // Restore ReflectionClass and properties + $this->reflClass = $reflService->getClass($this->name); + $this->instantiator = $this->instantiator ?: new Instantiator(); + + $parentReflFields = []; + + foreach ($this->embeddedClasses as $property => $embeddedClass) { + if (isset($embeddedClass['declaredField'])) { + $childProperty = $this->getAccessibleProperty( + $reflService, + $this->embeddedClasses[$embeddedClass['declaredField']]['class'], + $embeddedClass['originalField'], + ); + assert($childProperty !== null); + $parentReflFields[$property] = new ReflectionEmbeddedProperty( + $parentReflFields[$embeddedClass['declaredField']], + $childProperty, + $this->embeddedClasses[$embeddedClass['declaredField']]['class'], + ); + + continue; + } + + $fieldRefl = $this->getAccessibleProperty( + $reflService, + $embeddedClass['declared'] ?? $this->name, + $property, + ); + + $parentReflFields[$property] = $fieldRefl; + $this->reflFields[$property] = $fieldRefl; + } + + foreach ($this->fieldMappings as $field => $mapping) { + if (isset($mapping['declaredField']) && isset($parentReflFields[$mapping['declaredField']])) { + $childProperty = $this->getAccessibleProperty($reflService, $mapping['originalClass'], $mapping['originalField']); + assert($childProperty !== null); + + if (isset($mapping['enumType'])) { + $childProperty = new ReflectionEnumProperty( + $childProperty, + $mapping['enumType'], + ); + } + + $this->reflFields[$field] = new ReflectionEmbeddedProperty( + $parentReflFields[$mapping['declaredField']], + $childProperty, + $mapping['originalClass'], + ); + continue; + } + + $this->reflFields[$field] = isset($mapping['declared']) + ? $this->getAccessibleProperty($reflService, $mapping['declared'], $field) + : $this->getAccessibleProperty($reflService, $this->name, $field); + + if (isset($mapping['enumType']) && $this->reflFields[$field] !== null) { + $this->reflFields[$field] = new ReflectionEnumProperty( + $this->reflFields[$field], + $mapping['enumType'], + ); + } + } + + foreach ($this->associationMappings as $field => $mapping) { + $this->reflFields[$field] = isset($mapping['declared']) + ? $this->getAccessibleProperty($reflService, $mapping['declared'], $field) + : $this->getAccessibleProperty($reflService, $this->name, $field); + } + } + + /** + * Initializes a new ClassMetadata instance that will hold the object-relational mapping + * metadata of the class with the given name. + * + * @param ReflectionService $reflService The reflection service. + */ + public function initializeReflection(ReflectionService $reflService): void + { + $this->reflClass = $reflService->getClass($this->name); + $this->namespace = $reflService->getClassNamespace($this->name); + + if ($this->reflClass) { + $this->name = $this->rootEntityName = $this->reflClass->getName(); + } + + $this->table['name'] = $this->namingStrategy->classToTableName($this->name); + } + + /** + * Validates Identifier. + * + * @throws MappingException + */ + public function validateIdentifier(): void + { + if ($this->isMappedSuperclass || $this->isEmbeddedClass) { + return; + } + + // Verify & complete identifier mapping + if (! $this->identifier) { + throw MappingException::identifierRequired($this->name); + } + + if ($this->usesIdGenerator() && $this->isIdentifierComposite) { + throw MappingException::compositeKeyAssignedIdGeneratorRequired($this->name); + } + } + + /** + * Validates association targets actually exist. + * + * @throws MappingException + */ + public function validateAssociations(): void + { + foreach ($this->associationMappings as $mapping) { + if ( + ! class_exists($mapping['targetEntity']) + && ! interface_exists($mapping['targetEntity']) + && ! trait_exists($mapping['targetEntity']) + ) { + throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']); + } + } + } + + /** + * Validates lifecycle callbacks. + * + * @throws MappingException + */ + public function validateLifecycleCallbacks(ReflectionService $reflService): void + { + foreach ($this->lifecycleCallbacks as $callbacks) { + foreach ($callbacks as $callbackFuncName) { + if (! $reflService->hasPublicMethod($this->name, $callbackFuncName)) { + throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callbackFuncName); + } + } + } + } + + /** + * {@inheritDoc} + * + * Can return null when using static reflection, in violation of the LSP + */ + public function getReflectionClass() + { + return $this->reflClass; + } + + /** @psalm-param array{usage?: mixed, region?: mixed} $cache */ + public function enableCache(array $cache): void + { + if (! isset($cache['usage'])) { + $cache['usage'] = self::CACHE_USAGE_READ_ONLY; + } + + if (! isset($cache['region'])) { + $cache['region'] = strtolower(str_replace('\\', '_', $this->rootEntityName)); + } + + $this->cache = $cache; + } + + /** @psalm-param array{usage?: int, region?: string} $cache */ + public function enableAssociationCache(string $fieldName, array $cache): void + { + $this->associationMappings[$fieldName]['cache'] = $this->getAssociationCacheDefaults($fieldName, $cache); + } + + /** + * @psalm-param array{usage?: int, region?: string|null} $cache + * + * @return int[]|string[] + * @psalm-return array{usage: int, region: string|null} + */ + public function getAssociationCacheDefaults(string $fieldName, array $cache): array + { + if (! isset($cache['usage'])) { + $cache['usage'] = $this->cache['usage'] ?? self::CACHE_USAGE_READ_ONLY; + } + + if (! isset($cache['region'])) { + $cache['region'] = strtolower(str_replace('\\', '_', $this->rootEntityName)) . '__' . $fieldName; + } + + return $cache; + } + + /** + * Sets the change tracking policy used by this class. + */ + public function setChangeTrackingPolicy(int $policy): void + { + $this->changeTrackingPolicy = $policy; + } + + /** + * Whether the change tracking policy of this class is "deferred explicit". + */ + public function isChangeTrackingDeferredExplicit(): bool + { + return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_EXPLICIT; + } + + /** + * Whether the change tracking policy of this class is "deferred implicit". + */ + public function isChangeTrackingDeferredImplicit(): bool + { + return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_IMPLICIT; + } + + /** + * Whether the change tracking policy of this class is "notify". + */ + public function isChangeTrackingNotify(): bool + { + return $this->changeTrackingPolicy === self::CHANGETRACKING_NOTIFY; + } + + /** + * Checks whether a field is part of the identifier/primary key field(s). + */ + public function isIdentifier(string $fieldName): bool + { + if (! $this->identifier) { + return false; + } + + if (! $this->isIdentifierComposite) { + return $fieldName === $this->identifier[0]; + } + + return in_array($fieldName, $this->identifier, true); + } + + public function isUniqueField(string $fieldName): bool + { + $mapping = $this->getFieldMapping($fieldName); + + return $mapping !== false && isset($mapping['unique']) && $mapping['unique']; + } + + public function isNullable(string $fieldName): bool + { + $mapping = $this->getFieldMapping($fieldName); + + return $mapping !== false && isset($mapping['nullable']) && $mapping['nullable']; + } + + /** + * Gets a column name for a field name. + * If the column name for the field cannot be found, the given field name + * is returned. + */ + public function getColumnName(string $fieldName): string + { + return $this->columnNames[$fieldName] ?? $fieldName; + } + + /** + * Gets the mapping of a (regular) field that holds some data but not a + * reference to another object. + * + * @return mixed[] The field mapping. + * @psalm-return FieldMapping + * + * @throws MappingException + */ + public function getFieldMapping(string $fieldName): array + { + if (! isset($this->fieldMappings[$fieldName])) { + throw MappingException::mappingNotFound($this->name, $fieldName); + } + + return $this->fieldMappings[$fieldName]; + } + + /** + * Gets the mapping of an association. + * + * @see ClassMetadata::$associationMappings + * + * @param string $fieldName The field name that represents the association in + * the object model. + * + * @return mixed[] The mapping. + * @psalm-return AssociationMapping + * + * @throws MappingException + */ + public function getAssociationMapping(string $fieldName): array + { + if (! isset($this->associationMappings[$fieldName])) { + throw MappingException::mappingNotFound($this->name, $fieldName); + } + + return $this->associationMappings[$fieldName]; + } + + /** + * Gets all association mappings of the class. + * + * @psalm-return array + */ + public function getAssociationMappings(): array + { + return $this->associationMappings; + } + + /** + * Gets the field name for a column name. + * If no field name can be found the column name is returned. + * + * @return string The column alias. + */ + public function getFieldName(string $columnName): string + { + return $this->fieldNames[$columnName] ?? $columnName; + } + + /** + * Checks whether given property has type + */ + private function isTypedProperty(string $name): bool + { + return isset($this->reflClass) + && $this->reflClass->hasProperty($name) + && $this->reflClass->getProperty($name)->hasType(); + } + + /** + * Validates & completes the given field mapping based on typed property. + * + * @param array{fieldName: string, type?: mixed} $mapping The field mapping to validate & complete. + * + * @return array{fieldName: string, enumType?: string, type?: mixed} The updated mapping. + */ + private function validateAndCompleteTypedFieldMapping(array $mapping): array + { + $field = $this->reflClass->getProperty($mapping['fieldName']); + + $mapping = $this->typedFieldMapper->validateAndComplete($mapping, $field); + + return $mapping; + } + + /** + * Validates & completes the basic mapping information based on typed property. + * + * @param array{type: self::ONE_TO_ONE|self::MANY_TO_ONE|self::ONE_TO_MANY|self::MANY_TO_MANY, fieldName: string, targetEntity?: class-string} $mapping The mapping. + * + * @return mixed[] The updated mapping. + */ + private function validateAndCompleteTypedAssociationMapping(array $mapping): array + { + $type = $this->reflClass->getProperty($mapping['fieldName'])->getType(); + + if ($type === null || ($mapping['type'] & self::TO_ONE) === 0) { + return $mapping; + } + + if (! isset($mapping['targetEntity']) && $type instanceof ReflectionNamedType) { + $mapping['targetEntity'] = $type->getName(); + } + + return $mapping; + } + + /** + * Validates & completes the given field mapping. + * + * @psalm-param array{ + * fieldName?: string, + * columnName?: string, + * id?: bool, + * generated?: int, + * enumType?: class-string, + * } $mapping The field mapping to validate & complete. + * + * @return mixed[] The updated mapping. + * + * @throws MappingException + */ + protected function validateAndCompleteFieldMapping(array $mapping): array + { + // Check mandatory fields + if (! isset($mapping['fieldName']) || ! $mapping['fieldName']) { + throw MappingException::missingFieldName($this->name); + } + + if ($this->isTypedProperty($mapping['fieldName'])) { + $mapping = $this->validateAndCompleteTypedFieldMapping($mapping); + } + + if (! isset($mapping['type'])) { + // Default to string + $mapping['type'] = 'string'; + } + + // Complete fieldName and columnName mapping + if (! isset($mapping['columnName'])) { + $mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name); + } + + if ($mapping['columnName'][0] === '`') { + $mapping['columnName'] = trim($mapping['columnName'], '`'); + $mapping['quoted'] = true; + } + + $this->columnNames[$mapping['fieldName']] = $mapping['columnName']; + + if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn && $this->discriminatorColumn['name'] === $mapping['columnName'])) { + throw MappingException::duplicateColumnName($this->name, $mapping['columnName']); + } + + $this->fieldNames[$mapping['columnName']] = $mapping['fieldName']; + + // Complete id mapping + if (isset($mapping['id']) && $mapping['id'] === true) { + if ($this->versionField === $mapping['fieldName']) { + throw MappingException::cannotVersionIdField($this->name, $mapping['fieldName']); + } + + if (! in_array($mapping['fieldName'], $this->identifier, true)) { + $this->identifier[] = $mapping['fieldName']; + } + + // Check for composite key + if (! $this->isIdentifierComposite && count($this->identifier) > 1) { + $this->isIdentifierComposite = true; + } + } + + if (isset($mapping['generated'])) { + if (! in_array($mapping['generated'], [self::GENERATED_NEVER, self::GENERATED_INSERT, self::GENERATED_ALWAYS])) { + throw MappingException::invalidGeneratedMode($mapping['generated']); + } + + if ($mapping['generated'] === self::GENERATED_NEVER) { + unset($mapping['generated']); + } + } + + if (isset($mapping['enumType'])) { + if (! enum_exists($mapping['enumType'])) { + throw MappingException::nonEnumTypeMapped($this->name, $mapping['fieldName'], $mapping['enumType']); + } + + if (! empty($mapping['id'])) { + $this->containsEnumIdentifier = true; + } + } + + return $mapping; + } + + /** + * Validates & completes the basic mapping information that is common to all + * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many). + * + * @psalm-param array $mapping The mapping. + * + * @return mixed[] The updated mapping. + * @psalm-return array{ + * mappedBy: mixed|null, + * inversedBy: mixed|null, + * isOwningSide: bool, + * sourceEntity: class-string, + * targetEntity: string, + * fieldName: mixed, + * fetch: mixed, + * cascade: array, + * isCascadeRemove: bool, + * isCascadePersist: bool, + * isCascadeRefresh: bool, + * isCascadeMerge: bool, + * isCascadeDetach: bool, + * type: int, + * originalField: string, + * originalClass: class-string, + * ?orphanRemoval: bool + * } + * + * @throws MappingException If something is wrong with the mapping. + */ + protected function _validateAndCompleteAssociationMapping(array $mapping) + { + if (! isset($mapping['mappedBy'])) { + $mapping['mappedBy'] = null; + } + + if (! isset($mapping['inversedBy'])) { + $mapping['inversedBy'] = null; + } + + $mapping['isOwningSide'] = true; // assume owning side until we hit mappedBy + + if (empty($mapping['indexBy'])) { + unset($mapping['indexBy']); + } + + // If targetEntity is unqualified, assume it is in the same namespace as + // the sourceEntity. + $mapping['sourceEntity'] = $this->name; + + if ($this->isTypedProperty($mapping['fieldName'])) { + $mapping = $this->validateAndCompleteTypedAssociationMapping($mapping); + } + + if (isset($mapping['targetEntity'])) { + $mapping['targetEntity'] = $this->fullyQualifiedClassName($mapping['targetEntity']); + $mapping['targetEntity'] = ltrim($mapping['targetEntity'], '\\'); + } + + if (($mapping['type'] & self::MANY_TO_ONE) > 0 && isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']) { + throw MappingException::illegalOrphanRemoval($this->name, $mapping['fieldName']); + } + + // Complete id mapping + if (isset($mapping['id']) && $mapping['id'] === true) { + if (isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']) { + throw MappingException::illegalOrphanRemovalOnIdentifierAssociation($this->name, $mapping['fieldName']); + } + + if (! in_array($mapping['fieldName'], $this->identifier, true)) { + if (isset($mapping['joinColumns']) && count($mapping['joinColumns']) >= 2) { + throw MappingException::cannotMapCompositePrimaryKeyEntitiesAsForeignId( + $mapping['targetEntity'], + $this->name, + $mapping['fieldName'], + ); + } + + $this->identifier[] = $mapping['fieldName']; + $this->containsForeignIdentifier = true; + } + + // Check for composite key + if (! $this->isIdentifierComposite && count($this->identifier) > 1) { + $this->isIdentifierComposite = true; + } + + if ($this->cache && ! isset($mapping['cache'])) { + throw NonCacheableEntityAssociation::fromEntityAndField( + $this->name, + $mapping['fieldName'], + ); + } + } + + // Mandatory attributes for both sides + // Mandatory: fieldName, targetEntity + if (! isset($mapping['fieldName']) || ! $mapping['fieldName']) { + throw MappingException::missingFieldName($this->name); + } + + if (! isset($mapping['targetEntity'])) { + throw MappingException::missingTargetEntity($mapping['fieldName']); + } + + // Mandatory and optional attributes for either side + if (! $mapping['mappedBy']) { + if (isset($mapping['joinTable']) && $mapping['joinTable']) { + if (isset($mapping['joinTable']['name']) && $mapping['joinTable']['name'][0] === '`') { + $mapping['joinTable']['name'] = trim($mapping['joinTable']['name'], '`'); + $mapping['joinTable']['quoted'] = true; + } + } + } else { + $mapping['isOwningSide'] = false; + } + + if (isset($mapping['id']) && $mapping['id'] === true && $mapping['type'] & self::TO_MANY) { + throw MappingException::illegalToManyIdentifierAssociation($this->name, $mapping['fieldName']); + } + + // Fetch mode. Default fetch mode to LAZY, if not set. + if (! isset($mapping['fetch'])) { + $mapping['fetch'] = self::FETCH_LAZY; + } + + // Cascades + $cascades = isset($mapping['cascade']) ? array_map('strtolower', $mapping['cascade']) : []; + + $allCascades = ['remove', 'persist', 'refresh', 'merge', 'detach']; + if (in_array('all', $cascades, true)) { + $cascades = $allCascades; + } elseif (count($cascades) !== count(array_intersect($cascades, $allCascades))) { + throw MappingException::invalidCascadeOption( + array_diff($cascades, $allCascades), + $this->name, + $mapping['fieldName'], + ); + } + + $mapping['cascade'] = $cascades; + $mapping['isCascadeRemove'] = in_array('remove', $cascades, true); + $mapping['isCascadePersist'] = in_array('persist', $cascades, true); + $mapping['isCascadeRefresh'] = in_array('refresh', $cascades, true); + $mapping['isCascadeMerge'] = in_array('merge', $cascades, true); + $mapping['isCascadeDetach'] = in_array('detach', $cascades, true); + + return $mapping; + } + + /** + * Validates & completes a one-to-one association mapping. + * + * @psalm-param array $mapping The mapping to validate & complete. + * + * @return mixed[] The validated & completed mapping. + * @psalm-return array{isOwningSide: mixed, orphanRemoval: bool, isCascadeRemove: bool} + * @psalm-return array{ + * mappedBy: mixed|null, + * inversedBy: mixed|null, + * isOwningSide: bool, + * sourceEntity: class-string, + * targetEntity: string, + * fieldName: mixed, + * fetch: mixed, + * cascade: array, + * isCascadeRemove: bool, + * isCascadePersist: bool, + * isCascadeRefresh: bool, + * isCascadeMerge: bool, + * isCascadeDetach: bool, + * type: int, + * originalField: string, + * originalClass: class-string, + * joinColumns?: array{0: array{name: string, referencedColumnName: string}}|mixed, + * id?: mixed, + * sourceToTargetKeyColumns?: array, + * joinColumnFieldNames?: array, + * targetToSourceKeyColumns?: array, + * orphanRemoval: bool + * } + * + * @throws RuntimeException + * @throws MappingException + */ + protected function _validateAndCompleteOneToOneMapping(array $mapping) + { + $mapping = $this->_validateAndCompleteAssociationMapping($mapping); + + if (isset($mapping['joinColumns']) && $mapping['joinColumns']) { + $mapping['isOwningSide'] = true; + } + + if ($mapping['isOwningSide']) { + if (empty($mapping['joinColumns'])) { + // Apply default join column + $mapping['joinColumns'] = [ + [ + 'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name), + 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), + ], + ]; + } + + $uniqueConstraintColumns = []; + + foreach ($mapping['joinColumns'] as &$joinColumn) { + if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { + if (count($mapping['joinColumns']) === 1) { + if (empty($mapping['id'])) { + $joinColumn['unique'] = true; + } + } else { + $uniqueConstraintColumns[] = $joinColumn['name']; + } + } + + if (empty($joinColumn['name'])) { + $joinColumn['name'] = $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name); + } + + if (empty($joinColumn['referencedColumnName'])) { + $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); + } + + if ($joinColumn['name'][0] === '`') { + $joinColumn['name'] = trim($joinColumn['name'], '`'); + $joinColumn['quoted'] = true; + } + + if ($joinColumn['referencedColumnName'][0] === '`') { + $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`'); + $joinColumn['quoted'] = true; + } + + $mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; + $mapping['joinColumnFieldNames'][$joinColumn['name']] = $joinColumn['fieldName'] ?? $joinColumn['name']; + } + + if ($uniqueConstraintColumns) { + if (! $this->table) { + throw new RuntimeException('ClassMetadata::setTable() has to be called before defining a one to one relationship.'); + } + + $this->table['uniqueConstraints'][$mapping['fieldName'] . '_uniq'] = ['columns' => $uniqueConstraintColumns]; + } + + $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']); + } + + $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; + $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; + + if ($mapping['orphanRemoval']) { + unset($mapping['unique']); + } + + if (isset($mapping['id']) && $mapping['id'] === true && ! $mapping['isOwningSide']) { + throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']); + } + + return $mapping; + } + + /** + * Validates & completes a one-to-many association mapping. + * + * @psalm-param array $mapping The mapping to validate and complete. + * + * @return mixed[] The validated and completed mapping. + * @psalm-return array{ + * mappedBy: mixed, + * inversedBy: mixed, + * isOwningSide: bool, + * sourceEntity: string, + * targetEntity: string, + * fieldName: mixed, + * fetch: int|mixed, + * cascade: array, + * isCascadeRemove: bool, + * isCascadePersist: bool, + * isCascadeRefresh: bool, + * isCascadeMerge: bool, + * isCascadeDetach: bool, + * orphanRemoval: bool + * } + * + * @throws MappingException + * @throws InvalidArgumentException + */ + protected function _validateAndCompleteOneToManyMapping(array $mapping) + { + $mapping = $this->_validateAndCompleteAssociationMapping($mapping); + + // OneToMany-side MUST be inverse (must have mappedBy) + if (! isset($mapping['mappedBy'])) { + throw MappingException::oneToManyRequiresMappedBy($this->name, $mapping['fieldName']); + } + + $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; + $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; + + $this->assertMappingOrderBy($mapping); + + return $mapping; + } + + /** + * Validates & completes a many-to-many association mapping. + * + * @psalm-param array $mapping The mapping to validate & complete. + * @psalm-param array $mapping The mapping to validate & complete. + * + * @return mixed[] The validated & completed mapping. + * @psalm-return array{ + * mappedBy: mixed, + * inversedBy: mixed, + * isOwningSide: bool, + * sourceEntity: class-string, + * targetEntity: string, + * fieldName: mixed, + * fetch: mixed, + * cascade: array, + * isCascadeRemove: bool, + * isCascadePersist: bool, + * isCascadeRefresh: bool, + * isCascadeMerge: bool, + * isCascadeDetach: bool, + * type: int, + * originalField: string, + * originalClass: class-string, + * joinTable?: array{inverseJoinColumns: mixed}|mixed, + * joinTableColumns?: list, + * isOnDeleteCascade?: true, + * relationToSourceKeyColumns?: array, + * relationToTargetKeyColumns?: array, + * orphanRemoval: bool + * } + * + * @throws InvalidArgumentException + */ + protected function _validateAndCompleteManyToManyMapping(array $mapping) + { + $mapping = $this->_validateAndCompleteAssociationMapping($mapping); + + if ($mapping['isOwningSide']) { + // owning side MUST have a join table + if (! isset($mapping['joinTable']['name'])) { + $mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']); + } + + $selfReferencingEntityWithoutJoinColumns = $mapping['sourceEntity'] === $mapping['targetEntity'] + && (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns']))); + + if (! isset($mapping['joinTable']['joinColumns'])) { + $mapping['joinTable']['joinColumns'] = [ + [ + 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null), + 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), + 'onDelete' => 'CASCADE', + ], + ]; + } + + if (! isset($mapping['joinTable']['inverseJoinColumns'])) { + $mapping['joinTable']['inverseJoinColumns'] = [ + [ + 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null), + 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), + 'onDelete' => 'CASCADE', + ], + ]; + } + + $mapping['joinTableColumns'] = []; + + foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) { + if (empty($joinColumn['name'])) { + $joinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $joinColumn['referencedColumnName']); + } + + if (empty($joinColumn['referencedColumnName'])) { + $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); + } + + if ($joinColumn['name'][0] === '`') { + $joinColumn['name'] = trim($joinColumn['name'], '`'); + $joinColumn['quoted'] = true; + } + + if ($joinColumn['referencedColumnName'][0] === '`') { + $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`'); + $joinColumn['quoted'] = true; + } + + if (isset($joinColumn['onDelete']) && strtolower($joinColumn['onDelete']) === 'cascade') { + $mapping['isOnDeleteCascade'] = true; + } + + $mapping['relationToSourceKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; + $mapping['joinTableColumns'][] = $joinColumn['name']; + } + + foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) { + if (empty($inverseJoinColumn['name'])) { + $inverseJoinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $inverseJoinColumn['referencedColumnName']); + } + + if (empty($inverseJoinColumn['referencedColumnName'])) { + $inverseJoinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); + } + + if ($inverseJoinColumn['name'][0] === '`') { + $inverseJoinColumn['name'] = trim($inverseJoinColumn['name'], '`'); + $inverseJoinColumn['quoted'] = true; + } + + if ($inverseJoinColumn['referencedColumnName'][0] === '`') { + $inverseJoinColumn['referencedColumnName'] = trim($inverseJoinColumn['referencedColumnName'], '`'); + $inverseJoinColumn['quoted'] = true; + } + + if (isset($inverseJoinColumn['onDelete']) && strtolower($inverseJoinColumn['onDelete']) === 'cascade') { + $mapping['isOnDeleteCascade'] = true; + } + + $mapping['relationToTargetKeyColumns'][$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName']; + $mapping['joinTableColumns'][] = $inverseJoinColumn['name']; + } + } + + $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; + + $this->assertMappingOrderBy($mapping); + + return $mapping; + } + + /** + * {@inheritDoc} + */ + public function getIdentifierFieldNames(): array + { + return $this->identifier; + } + + /** + * Gets the name of the single id field. Note that this only works on + * entity classes that have a single-field pk. + * + * @throws MappingException If the class doesn't have an identifier or it has a composite primary key. + */ + public function getSingleIdentifierFieldName(): string + { + if ($this->isIdentifierComposite) { + throw MappingException::singleIdNotAllowedOnCompositePrimaryKey($this->name); + } + + if (! isset($this->identifier[0])) { + throw MappingException::noIdDefined($this->name); + } + + return $this->identifier[0]; + } + + /** + * Gets the column name of the single id column. Note that this only works on + * entity classes that have a single-field pk. + * + * @throws MappingException If the class doesn't have an identifier or it has a composite primary key. + */ + public function getSingleIdentifierColumnName(): string + { + return $this->getColumnName($this->getSingleIdentifierFieldName()); + } + + /** + * INTERNAL: + * Sets the mapped identifier/primary key fields of this class. + * Mainly used by the ClassMetadataFactory to assign inherited identifiers. + * + * @psalm-param list $identifier + */ + public function setIdentifier(array $identifier): void + { + $this->identifier = $identifier; + $this->isIdentifierComposite = (count($this->identifier) > 1); + } + + /** + * {@inheritDoc} + */ + public function getIdentifier(): array + { + return $this->identifier; + } + + public function hasField(string $fieldName): bool + { + return isset($this->fieldMappings[$fieldName]) || isset($this->embeddedClasses[$fieldName]); + } + + /** + * Gets an array containing all the column names. + * + * @psalm-param list|null $fieldNames + * + * @return mixed[] + * @psalm-return list + */ + public function getColumnNames(array|null $fieldNames = null): array + { + if ($fieldNames === null) { + return array_keys($this->fieldNames); + } + + return array_values(array_map([$this, 'getColumnName'], $fieldNames)); + } + + /** + * Returns an array with all the identifier column names. + * + * @psalm-return list + */ + public function getIdentifierColumnNames(): array + { + $columnNames = []; + + foreach ($this->identifier as $idProperty) { + if (isset($this->fieldMappings[$idProperty])) { + $columnNames[] = $this->fieldMappings[$idProperty]['columnName']; + + continue; + } + + // Association defined as Id field + $joinColumns = $this->associationMappings[$idProperty]['joinColumns']; + $assocColumnNames = array_map(static fn ($joinColumn) => $joinColumn['name'], $joinColumns); + + $columnNames = array_merge($columnNames, $assocColumnNames); + } + + return $columnNames; + } + + /** + * Sets the type of Id generator to use for the mapped class. + * + * @psalm-param self::GENERATOR_TYPE_* $generatorType + */ + public function setIdGeneratorType(int $generatorType): void + { + $this->generatorType = $generatorType; + } + + /** + * Checks whether the mapped class uses an Id generator. + */ + public function usesIdGenerator(): bool + { + return $this->generatorType !== self::GENERATOR_TYPE_NONE; + } + + public function isInheritanceTypeNone(): bool + { + return $this->inheritanceType === self::INHERITANCE_TYPE_NONE; + } + + /** + * Checks whether the mapped class uses the JOINED inheritance mapping strategy. + * + * @return bool TRUE if the class participates in a JOINED inheritance mapping, + * FALSE otherwise. + */ + public function isInheritanceTypeJoined(): bool + { + return $this->inheritanceType === self::INHERITANCE_TYPE_JOINED; + } + + /** + * Checks whether the mapped class uses the SINGLE_TABLE inheritance mapping strategy. + * + * @return bool TRUE if the class participates in a SINGLE_TABLE inheritance mapping, + * FALSE otherwise. + */ + public function isInheritanceTypeSingleTable(): bool + { + return $this->inheritanceType === self::INHERITANCE_TYPE_SINGLE_TABLE; + } + + /** + * Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy. + * + * @return bool TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, + * FALSE otherwise. + */ + public function isInheritanceTypeTablePerClass(): bool + { + return $this->inheritanceType === self::INHERITANCE_TYPE_TABLE_PER_CLASS; + } + + /** + * Checks whether the class uses an identity column for the Id generation. + */ + public function isIdGeneratorIdentity(): bool + { + return $this->generatorType === self::GENERATOR_TYPE_IDENTITY; + } + + /** + * Checks whether the class uses a sequence for id generation. + * + * @psalm-assert-if-true !null $this->sequenceGeneratorDefinition + */ + public function isIdGeneratorSequence(): bool + { + return $this->generatorType === self::GENERATOR_TYPE_SEQUENCE; + } + + /** + * Checks whether the class has a natural identifier/pk (which means it does + * not use any Id generator. + */ + public function isIdentifierNatural(): bool + { + return $this->generatorType === self::GENERATOR_TYPE_NONE; + } + + /** + * Gets the type of a field. + * + * @todo 3.0 Remove this. PersisterHelper should fix it somehow + */ + public function getTypeOfField(string $fieldName): string|null + { + return isset($this->fieldMappings[$fieldName]) + ? $this->fieldMappings[$fieldName]['type'] + : null; + } + + /** + * Gets the name of the primary table. + */ + public function getTableName(): string + { + return $this->table['name']; + } + + /** + * Gets primary table's schema name. + */ + public function getSchemaName(): string|null + { + return $this->table['schema'] ?? null; + } + + /** + * Gets the table name to use for temporary identifier tables of this class. + */ + public function getTemporaryIdTableName(): string + { + // replace dots with underscores because PostgreSQL creates temporary tables in a special schema + return str_replace('.', '_', $this->getTableName() . '_id_tmp'); + } + + /** + * Sets the mapped subclasses of this class. + * + * @psalm-param list $subclasses The names of all mapped subclasses. + */ + public function setSubclasses(array $subclasses): void + { + foreach ($subclasses as $subclass) { + $this->subClasses[] = $this->fullyQualifiedClassName($subclass); + } + } + + /** + * Sets the parent class names. + * Assumes that the class names in the passed array are in the order: + * directParent -> directParentParent -> directParentParentParent ... -> root. + * + * @psalm-param list $classNames + */ + public function setParentClasses(array $classNames): void + { + $this->parentClasses = $classNames; + + if (count($classNames) > 0) { + $this->rootEntityName = array_pop($classNames); + } + } + + /** + * Sets the inheritance type used by the class and its subclasses. + * + * @psalm-param self::INHERITANCE_TYPE_* $type + * + * @throws MappingException + */ + public function setInheritanceType(int $type): void + { + if (! $this->isInheritanceType($type)) { + throw MappingException::invalidInheritanceType($this->name, $type); + } + + $this->inheritanceType = $type; + } + + /** + * Sets the association to override association mapping of property for an entity relationship. + * + * @psalm-param array $overrideMapping + * + * @throws MappingException + */ + public function setAssociationOverride(string $fieldName, array $overrideMapping): void + { + if (! isset($this->associationMappings[$fieldName])) { + throw MappingException::invalidOverrideFieldName($this->name, $fieldName); + } + + $mapping = $this->associationMappings[$fieldName]; + + //if (isset($mapping['inherited']) && (count($overrideMapping) !== 1 || ! isset($overrideMapping['fetch']))) { + // TODO: Deprecate overriding the fetch mode via association override for 3.0, + // users should do this with a listener and a custom attribute/annotation + // TODO: Enable this exception in 2.8 + //throw MappingException::illegalOverrideOfInheritedProperty($this->name, $fieldName); + //} + + if (isset($overrideMapping['joinColumns'])) { + $mapping['joinColumns'] = $overrideMapping['joinColumns']; + } + + if (isset($overrideMapping['inversedBy'])) { + $mapping['inversedBy'] = $overrideMapping['inversedBy']; + } + + if (isset($overrideMapping['joinTable'])) { + $mapping['joinTable'] = $overrideMapping['joinTable']; + } + + if (isset($overrideMapping['fetch'])) { + $mapping['fetch'] = $overrideMapping['fetch']; + } + + $mapping['joinColumnFieldNames'] = null; + $mapping['joinTableColumns'] = null; + $mapping['sourceToTargetKeyColumns'] = null; + $mapping['relationToSourceKeyColumns'] = null; + $mapping['relationToTargetKeyColumns'] = null; + + switch ($mapping['type']) { + case self::ONE_TO_ONE: + $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); + break; + case self::ONE_TO_MANY: + $mapping = $this->_validateAndCompleteOneToManyMapping($mapping); + break; + case self::MANY_TO_ONE: + $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); + break; + case self::MANY_TO_MANY: + $mapping = $this->_validateAndCompleteManyToManyMapping($mapping); + break; + } + + $this->associationMappings[$fieldName] = $mapping; + } + + /** + * Sets the override for a mapped field. + * + * @psalm-param array $overrideMapping + * + * @throws MappingException + */ + public function setAttributeOverride(string $fieldName, array $overrideMapping): void + { + if (! isset($this->fieldMappings[$fieldName])) { + throw MappingException::invalidOverrideFieldName($this->name, $fieldName); + } + + $mapping = $this->fieldMappings[$fieldName]; + + //if (isset($mapping['inherited'])) { + // TODO: Enable this exception in 2.8 + //throw MappingException::illegalOverrideOfInheritedProperty($this->name, $fieldName); + //} + + if (isset($mapping['id'])) { + $overrideMapping['id'] = $mapping['id']; + } + + if (! isset($overrideMapping['type'])) { + $overrideMapping['type'] = $mapping['type']; + } + + if (! isset($overrideMapping['fieldName'])) { + $overrideMapping['fieldName'] = $mapping['fieldName']; + } + + if ($overrideMapping['type'] !== $mapping['type']) { + throw MappingException::invalidOverrideFieldType($this->name, $fieldName); + } + + unset($this->fieldMappings[$fieldName]); + unset($this->fieldNames[$mapping['columnName']]); + unset($this->columnNames[$mapping['fieldName']]); + + $overrideMapping = $this->validateAndCompleteFieldMapping($overrideMapping); + + $this->fieldMappings[$fieldName] = $overrideMapping; + } + + /** + * Checks whether a mapped field is inherited from an entity superclass. + */ + public function isInheritedField(string $fieldName): bool + { + return isset($this->fieldMappings[$fieldName]['inherited']); + } + + /** + * Checks if this entity is the root in any entity-inheritance-hierarchy. + */ + public function isRootEntity(): bool + { + return $this->name === $this->rootEntityName; + } + + /** + * Checks whether a mapped association field is inherited from a superclass. + */ + public function isInheritedAssociation(string $fieldName): bool + { + return isset($this->associationMappings[$fieldName]['inherited']); + } + + public function isInheritedEmbeddedClass(string $fieldName): bool + { + return isset($this->embeddedClasses[$fieldName]['inherited']); + } + + /** + * Sets the name of the primary table the class is mapped to. + * + * @deprecated Use {@link setPrimaryTable}. + */ + public function setTableName(string $tableName): void + { + $this->table['name'] = $tableName; + } + + /** + * Sets the primary table definition. The provided array supports the + * following structure: + * + * name => (optional, defaults to class name) + * indexes => array of indexes (optional) + * uniqueConstraints => array of constraints (optional) + * + * If a key is omitted, the current value is kept. + * + * @psalm-param array $table The table description. + */ + public function setPrimaryTable(array $table): void + { + if (isset($table['name'])) { + // Split schema and table name from a table name like "myschema.mytable" + if (str_contains($table['name'], '.')) { + [$this->table['schema'], $table['name']] = explode('.', $table['name'], 2); + } + + if ($table['name'][0] === '`') { + $table['name'] = trim($table['name'], '`'); + $this->table['quoted'] = true; + } + + $this->table['name'] = $table['name']; + } + + if (isset($table['quoted'])) { + $this->table['quoted'] = $table['quoted']; + } + + if (isset($table['schema'])) { + $this->table['schema'] = $table['schema']; + } + + if (isset($table['indexes'])) { + $this->table['indexes'] = $table['indexes']; + } + + if (isset($table['uniqueConstraints'])) { + $this->table['uniqueConstraints'] = $table['uniqueConstraints']; + } + + if (isset($table['options'])) { + $this->table['options'] = $table['options']; + } + } + + /** + * Checks whether the given type identifies an inheritance type. + */ + private function isInheritanceType(int $type): bool + { + return $type === self::INHERITANCE_TYPE_NONE || + $type === self::INHERITANCE_TYPE_SINGLE_TABLE || + $type === self::INHERITANCE_TYPE_JOINED || + $type === self::INHERITANCE_TYPE_TABLE_PER_CLASS; + } + + /** + * Adds a mapped field to the class. + * + * @psalm-param array $mapping The field mapping. + * + * @throws MappingException + */ + public function mapField(array $mapping): void + { + $mapping = $this->validateAndCompleteFieldMapping($mapping); + $this->assertFieldNotMapped($mapping['fieldName']); + + if (isset($mapping['generated'])) { + $this->requiresFetchAfterChange = true; + } + + $this->fieldMappings[$mapping['fieldName']] = $mapping; + } + + /** + * INTERNAL: + * Adds an association mapping without completing/validating it. + * This is mainly used to add inherited association mappings to derived classes. + * + * @psalm-param AssociationMapping $mapping + * + * @throws MappingException + */ + public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/): void + { + if (isset($this->associationMappings[$mapping['fieldName']])) { + throw MappingException::duplicateAssociationMapping($this->name, $mapping['fieldName']); + } + + $this->associationMappings[$mapping['fieldName']] = $mapping; + } + + /** + * INTERNAL: + * Adds a field mapping without completing/validating it. + * This is mainly used to add inherited field mappings to derived classes. + * + * @psalm-param array $fieldMapping + */ + public function addInheritedFieldMapping(array $fieldMapping): void + { + $this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping; + $this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName']; + $this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName']; + } + + /** + * Adds a one-to-one mapping. + * + * @param array $mapping The mapping. + */ + public function mapOneToOne(array $mapping): void + { + $mapping['type'] = self::ONE_TO_ONE; + + $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); + + $this->_storeAssociationMapping($mapping); + } + + /** + * Adds a one-to-many mapping. + * + * @psalm-param array $mapping The mapping. + */ + public function mapOneToMany(array $mapping): void + { + $mapping['type'] = self::ONE_TO_MANY; + + $mapping = $this->_validateAndCompleteOneToManyMapping($mapping); + + $this->_storeAssociationMapping($mapping); + } + + /** + * Adds a many-to-one mapping. + * + * @psalm-param array $mapping The mapping. + */ + public function mapManyToOne(array $mapping): void + { + $mapping['type'] = self::MANY_TO_ONE; + + // A many-to-one mapping is essentially a one-one backreference + $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); + + $this->_storeAssociationMapping($mapping); + } + + /** + * Adds a many-to-many mapping. + * + * @psalm-param array $mapping The mapping. + */ + public function mapManyToMany(array $mapping): void + { + $mapping['type'] = self::MANY_TO_MANY; + + $mapping = $this->_validateAndCompleteManyToManyMapping($mapping); + + $this->_storeAssociationMapping($mapping); + } + + /** + * Stores the association mapping. + * + * @psalm-param array $assocMapping + * + * @throws MappingException + */ + protected function _storeAssociationMapping(array $assocMapping): void + { + $sourceFieldName = $assocMapping['fieldName']; + + $this->assertFieldNotMapped($sourceFieldName); + + $this->associationMappings[$sourceFieldName] = $assocMapping; + } + + /** + * Registers a custom repository class for the entity class. + * + * @param string|null $repositoryClassName The class name of the custom mapper. + * @psalm-param class-string|null $repositoryClassName + */ + public function setCustomRepositoryClass(string|null $repositoryClassName): void + { + $this->customRepositoryClassName = $this->fullyQualifiedClassName($repositoryClassName); + } + + /** + * Dispatches the lifecycle event of the given entity to the registered + * lifecycle callbacks and lifecycle listeners. + * + * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker + * + * @param string $lifecycleEvent The lifecycle event. + */ + public function invokeLifecycleCallbacks(string $lifecycleEvent, object $entity): void + { + foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) { + $entity->$callback(); + } + } + + /** + * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. + */ + public function hasLifecycleCallbacks(string $lifecycleEvent): bool + { + return isset($this->lifecycleCallbacks[$lifecycleEvent]); + } + + /** + * Gets the registered lifecycle callbacks for an event. + * + * @return string[] + * @psalm-return list + */ + public function getLifecycleCallbacks(string $event): array + { + return $this->lifecycleCallbacks[$event] ?? []; + } + + /** + * Adds a lifecycle callback for entities of this class. + */ + public function addLifecycleCallback(string $callback, string $event): void + { + if ($this->isEmbeddedClass) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/8381', + 'Registering lifecycle callback %s on Embedded class %s is not doing anything and will throw exception in 3.0', + $event, + $this->name, + ); + } + + if (isset($this->lifecycleCallbacks[$event]) && in_array($callback, $this->lifecycleCallbacks[$event], true)) { + return; + } + + $this->lifecycleCallbacks[$event][] = $callback; + } + + /** + * Sets the lifecycle callbacks for entities of this class. + * Any previously registered callbacks are overwritten. + * + * @psalm-param array> $callbacks + */ + public function setLifecycleCallbacks(array $callbacks): void + { + $this->lifecycleCallbacks = $callbacks; + } + + /** + * Adds a entity listener for entities of this class. + * + * @param string $eventName The entity lifecycle event. + * @param string $class The listener class. + * @param string $method The listener callback method. + * + * @throws MappingException + */ + public function addEntityListener(string $eventName, string $class, string $method): void + { + $class = $this->fullyQualifiedClassName($class); + + $listener = [ + 'class' => $class, + 'method' => $method, + ]; + + if (! class_exists($class)) { + throw MappingException::entityListenerClassNotFound($class, $this->name); + } + + if (! method_exists($class, $method)) { + throw MappingException::entityListenerMethodNotFound($class, $method, $this->name); + } + + if (isset($this->entityListeners[$eventName]) && in_array($listener, $this->entityListeners[$eventName], true)) { + throw MappingException::duplicateEntityListener($class, $method, $this->name); + } + + $this->entityListeners[$eventName][] = $listener; + } + + /** + * Sets the discriminator column definition. + * + * @see getDiscriminatorColumn() + * + * @param mixed[]|null $columnDef + * @psalm-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null, enumType?: class-string|null}|null $columnDef + * + * @throws MappingException + */ + public function setDiscriminatorColumn(array|null $columnDef): void + { + if ($columnDef !== null) { + if (! isset($columnDef['name'])) { + throw MappingException::nameIsMandatoryForDiscriminatorColumns($this->name); + } + + if (isset($this->fieldNames[$columnDef['name']])) { + throw MappingException::duplicateColumnName($this->name, $columnDef['name']); + } + + if (! isset($columnDef['fieldName'])) { + $columnDef['fieldName'] = $columnDef['name']; + } + + if (! isset($columnDef['type'])) { + $columnDef['type'] = 'string'; + } + + if (in_array($columnDef['type'], ['boolean', 'array', 'object', 'datetime', 'time', 'date'], true)) { + throw MappingException::invalidDiscriminatorColumnType($this->name, $columnDef['type']); + } + + $this->discriminatorColumn = $columnDef; + } + } + + /** + * @return array + * @psalm-return DiscriminatorColumnMapping + */ + final public function getDiscriminatorColumn(): array + { + if ($this->discriminatorColumn === null) { + throw new LogicException('The discriminator column was not set.'); + } + + return $this->discriminatorColumn; + } + + /** + * Sets the discriminator values used by this class. + * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. + * + * @param array $map + */ + public function setDiscriminatorMap(array $map): void + { + foreach ($map as $value => $className) { + $this->addDiscriminatorMapClass($value, $className); + } + } + + /** + * Adds one entry of the discriminator map with a new class and corresponding name. + * + * @throws MappingException + */ + public function addDiscriminatorMapClass(int|string $name, string $className): void + { + $className = $this->fullyQualifiedClassName($className); + $className = ltrim($className, '\\'); + + $this->discriminatorMap[$name] = $className; + + if ($this->name === $className) { + $this->discriminatorValue = $name; + + return; + } + + if (! (class_exists($className) || interface_exists($className))) { + throw MappingException::invalidClassInDiscriminatorMap($className, $this->name); + } + + if (is_subclass_of($className, $this->name) && ! in_array($className, $this->subClasses, true)) { + $this->subClasses[] = $className; + } + } + + public function hasAssociation(string $fieldName): bool + { + return isset($this->associationMappings[$fieldName]); + } + + public function isSingleValuedAssociation(string $fieldName): bool + { + return isset($this->associationMappings[$fieldName]) + && ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); + } + + public function isCollectionValuedAssociation(string $fieldName): bool + { + return isset($this->associationMappings[$fieldName]) + && ! ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); + } + + /** + * Is this an association that only has a single join column? + */ + public function isAssociationWithSingleJoinColumn(string $fieldName): bool + { + return isset($this->associationMappings[$fieldName]) + && isset($this->associationMappings[$fieldName]['joinColumns'][0]) + && ! isset($this->associationMappings[$fieldName]['joinColumns'][1]); + } + + /** + * Returns the single association join column (if any). + * + * @throws MappingException + */ + public function getSingleAssociationJoinColumnName(string $fieldName): string + { + if (! $this->isAssociationWithSingleJoinColumn($fieldName)) { + throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); + } + + return $this->associationMappings[$fieldName]['joinColumns'][0]['name']; + } + + /** + * Returns the single association referenced join column name (if any). + * + * @throws MappingException + */ + public function getSingleAssociationReferencedJoinColumnName(string $fieldName): string + { + if (! $this->isAssociationWithSingleJoinColumn($fieldName)) { + throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); + } + + return $this->associationMappings[$fieldName]['joinColumns'][0]['referencedColumnName']; + } + + /** + * Used to retrieve a fieldname for either field or association from a given column. + * + * This method is used in foreign-key as primary-key contexts. + * + * @throws MappingException + */ + public function getFieldForColumn(string $columnName): string + { + if (isset($this->fieldNames[$columnName])) { + return $this->fieldNames[$columnName]; + } + + foreach ($this->associationMappings as $assocName => $mapping) { + if ( + $this->isAssociationWithSingleJoinColumn($assocName) && + $this->associationMappings[$assocName]['joinColumns'][0]['name'] === $columnName + ) { + return $assocName; + } + } + + throw MappingException::noFieldNameFoundForColumn($this->name, $columnName); + } + + /** + * Sets the ID generator used to generate IDs for instances of this class. + */ + public function setIdGenerator(AbstractIdGenerator $generator): void + { + $this->idGenerator = $generator; + } + + /** + * Sets definition. + * + * @psalm-param array $definition + */ + public function setCustomGeneratorDefinition(array $definition): void + { + $this->customGeneratorDefinition = $definition; + } + + /** + * Sets the definition of the sequence ID generator for this class. + * + * The definition must have the following structure: + * + * array( + * 'sequenceName' => 'name', + * 'allocationSize' => 20, + * 'initialValue' => 1 + * 'quoted' => 1 + * ) + * + * + * @psalm-param array{sequenceName?: string, allocationSize?: int|string, initialValue?: int|string, quoted?: mixed} $definition + * + * @throws MappingException + */ + public function setSequenceGeneratorDefinition(array $definition): void + { + if (! isset($definition['sequenceName']) || trim($definition['sequenceName']) === '') { + throw MappingException::missingSequenceName($this->name); + } + + if ($definition['sequenceName'][0] === '`') { + $definition['sequenceName'] = trim($definition['sequenceName'], '`'); + $definition['quoted'] = true; + } + + if (! isset($definition['allocationSize']) || trim((string) $definition['allocationSize']) === '') { + $definition['allocationSize'] = '1'; + } + + if (! isset($definition['initialValue']) || trim((string) $definition['initialValue']) === '') { + $definition['initialValue'] = '1'; + } + + $definition['allocationSize'] = (string) $definition['allocationSize']; + $definition['initialValue'] = (string) $definition['initialValue']; + + $this->sequenceGeneratorDefinition = $definition; + } + + /** + * Sets the version field mapping used for versioning. Sets the default + * value to use depending on the column type. + * + * @psalm-param array $mapping The version field mapping array. + * + * @throws MappingException + */ + public function setVersionMapping(array &$mapping): void + { + $this->isVersioned = true; + $this->versionField = $mapping['fieldName']; + $this->requiresFetchAfterChange = true; + + if (! isset($mapping['default'])) { + if (in_array($mapping['type'], ['integer', 'bigint', 'smallint'], true)) { + $mapping['default'] = 1; + } elseif ($mapping['type'] === 'datetime') { + $mapping['default'] = 'CURRENT_TIMESTAMP'; + } else { + throw MappingException::unsupportedOptimisticLockingType($this->name, $mapping['fieldName'], $mapping['type']); + } + } + } + + /** + * Sets whether this class is to be versioned for optimistic locking. + */ + public function setVersioned(bool $bool): void + { + $this->isVersioned = $bool; + + if ($bool) { + $this->requiresFetchAfterChange = true; + } + } + + /** + * Sets the name of the field that is to be used for versioning if this class is + * versioned for optimistic locking. + */ + public function setVersionField(string|null $versionField): void + { + $this->versionField = $versionField; + } + + /** + * Marks this class as read only, no change tracking is applied to it. + */ + public function markReadOnly(): void + { + $this->isReadOnly = true; + } + + /** + * {@inheritDoc} + */ + public function getFieldNames(): array + { + return array_keys($this->fieldMappings); + } + + /** + * {@inheritDoc} + */ + public function getAssociationNames(): array + { + return array_keys($this->associationMappings); + } + + /** + * {@inheritDoc} + * + * @psalm-return class-string + * + * @throws InvalidArgumentException + */ + public function getAssociationTargetClass(string $assocName): string + { + return $this->associationMappings[$assocName]['targetEntity'] + ?? throw new InvalidArgumentException("Association name expected, '" . $assocName . "' is not an association."); + } + + public function getName(): string + { + return $this->name; + } + + public function isAssociationInverseSide(string $assocName): bool + { + return isset($this->associationMappings[$assocName]) + && ! $this->associationMappings[$assocName]['isOwningSide']; + } + + public function getAssociationMappedByTargetField(string $assocName): string + { + return $this->associationMappings[$assocName]['mappedBy']; + } + + /** + * @return string|null null if the input value is null + * @psalm-return class-string|null + */ + public function fullyQualifiedClassName(string|null $className): string|null + { + if (empty($className)) { + return $className; + } + + if (! str_contains($className, '\\') && $this->namespace) { + return $this->namespace . '\\' . $className; + } + + return $className; + } + + public function getMetadataValue(string $name): mixed + { + if (isset($this->$name)) { + return $this->$name; + } + + return null; + } + + /** + * Map Embedded Class + * + * @psalm-param array $mapping + * + * @throws MappingException + */ + public function mapEmbedded(array $mapping): void + { + $this->assertFieldNotMapped($mapping['fieldName']); + + if (! isset($mapping['class']) && $this->isTypedProperty($mapping['fieldName'])) { + $type = $this->reflClass->getProperty($mapping['fieldName'])->getType(); + if ($type instanceof ReflectionNamedType) { + $mapping['class'] = $type->getName(); + } + } + + $this->embeddedClasses[$mapping['fieldName']] = [ + 'class' => $this->fullyQualifiedClassName($mapping['class']), + 'columnPrefix' => $mapping['columnPrefix'] ?? null, + 'declaredField' => $mapping['declaredField'] ?? null, + 'originalField' => $mapping['originalField'] ?? null, + ]; + } + + /** + * Inline the embeddable class + */ + public function inlineEmbeddable(string $property, ClassMetadata $embeddable): void + { + foreach ($embeddable->fieldMappings as $fieldMapping) { + $fieldMapping['originalClass'] ??= $embeddable->name; + $fieldMapping['declaredField'] = isset($fieldMapping['declaredField']) + ? $property . '.' . $fieldMapping['declaredField'] + : $property; + $fieldMapping['originalField'] ??= $fieldMapping['fieldName']; + $fieldMapping['fieldName'] = $property . '.' . $fieldMapping['fieldName']; + + if (! empty($this->embeddedClasses[$property]['columnPrefix'])) { + $fieldMapping['columnName'] = $this->embeddedClasses[$property]['columnPrefix'] . $fieldMapping['columnName']; + } elseif ($this->embeddedClasses[$property]['columnPrefix'] !== false) { + assert($this->reflClass !== null); + assert($embeddable->reflClass !== null); + $fieldMapping['columnName'] = $this->namingStrategy + ->embeddedFieldToColumnName( + $property, + $fieldMapping['columnName'], + $this->reflClass->name, + $embeddable->reflClass->name, + ); + } + + $this->mapField($fieldMapping); + } + } + + /** @throws MappingException */ + private function assertFieldNotMapped(string $fieldName): void + { + if ( + isset($this->fieldMappings[$fieldName]) || + isset($this->associationMappings[$fieldName]) || + isset($this->embeddedClasses[$fieldName]) + ) { + throw MappingException::duplicateFieldMapping($this->name, $fieldName); + } + } + + /** + * Gets the sequence name based on class metadata. + * + * @todo Sequence names should be computed in DBAL depending on the platform + */ + public function getSequenceName(AbstractPlatform $platform): string + { + $sequencePrefix = $this->getSequencePrefix($platform); + $columnName = $this->getSingleIdentifierColumnName(); + + return $sequencePrefix . '_' . $columnName . '_seq'; + } + + /** + * Gets the sequence name prefix based on class metadata. + * + * @todo Sequence names should be computed in DBAL depending on the platform + */ + public function getSequencePrefix(AbstractPlatform $platform): string + { + $tableName = $this->getTableName(); + $sequencePrefix = $tableName; + + // Prepend the schema name to the table name if there is one + $schemaName = $this->getSchemaName(); + if ($schemaName) { + $sequencePrefix = $schemaName . '.' . $tableName; + } + + return $sequencePrefix; + } + + /** @psalm-param array $mapping */ + private function assertMappingOrderBy(array $mapping): void + { + if (isset($mapping['orderBy']) && ! is_array($mapping['orderBy'])) { + throw new InvalidArgumentException("'orderBy' is expected to be an array, not " . gettype($mapping['orderBy'])); + } + } + + /** @psalm-param class-string $class */ + private function getAccessibleProperty(ReflectionService $reflService, string $class, string $field): ReflectionProperty|null + { + $reflectionProperty = $reflService->getAccessibleProperty($class, $field); + if ($reflectionProperty?->isReadOnly()) { + $reflectionProperty = new ReflectionReadonlyProperty($reflectionProperty); + } + + return $reflectionProperty; } } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php deleted file mode 100644 index ac776f223da..00000000000 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ /dev/null @@ -1,3025 +0,0 @@ -ClassMetadata instance holds all the object-relational mapping metadata - * of an entity and its associations. - * - * Once populated, ClassMetadata instances are usually cached in a serialized form. - * - * IMPORTANT NOTE: - * - * The fields of this class are only public for 2 reasons: - * 1) To allow fast READ access. - * 2) To drastically reduce the size of a serialized instance (private/protected members - * get the whole class name, namespace inclusive, prepended to every property in - * the serialized representation). - * - * @template-covariant T of object - * @template-implements ClassMetadata - * @psalm-type FieldMapping = array{ - * type: string, - * fieldName: string, - * columnName: string, - * length?: int, - * id?: bool, - * nullable?: bool, - * notInsertable?: bool, - * notUpdatable?: bool, - * generated?: int, - * enumType?: class-string, - * columnDefinition?: string, - * precision?: int, - * scale?: int, - * unique?: string, - * inherited?: class-string, - * originalClass?: class-string, - * originalField?: string, - * quoted?: bool, - * declared?: class-string, - * declaredField?: string, - * options?: array - * } - * @psalm-type JoinColumnData = array{ - * name: string, - * referencedColumnName: string, - * unique?: bool, - * quoted?: bool, - * fieldName?: string, - * onDelete?: string, - * columnDefinition?: string, - * nullable?: bool, - * } - * @psalm-type AssociationMapping = array{ - * cache?: array, - * cascade: array, - * declared?: class-string, - * fetch: mixed, - * fieldName: string, - * id?: bool, - * inherited?: class-string, - * indexBy?: string, - * inversedBy: string|null, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * isOnDeleteCascade?: bool, - * isOwningSide: bool, - * joinColumns?: array, - * joinColumnFieldNames?: array, - * joinTable?: array, - * joinTableColumns?: list, - * mappedBy: string|null, - * orderBy?: array, - * originalClass?: class-string, - * originalField?: string, - * orphanRemoval?: bool, - * relationToSourceKeyColumns?: array, - * relationToTargetKeyColumns?: array, - * sourceEntity: class-string, - * sourceToTargetKeyColumns?: array, - * targetEntity: class-string, - * targetToSourceKeyColumns?: array, - * type: int, - * unique?: bool, - * } - * @psalm-type DiscriminatorColumnMapping = array{ - * name: string, - * fieldName: string, - * type: string, - * length?: int, - * columnDefinition?: string|null, - * enumType?: class-string|null, - * } - */ -class ClassMetadataInfo implements ClassMetadata, Stringable -{ - /* The inheritance mapping types */ - /** - * NONE means the class does not participate in an inheritance hierarchy - * and therefore does not need an inheritance mapping type. - */ - public const INHERITANCE_TYPE_NONE = 1; - - /** - * JOINED means the class will be persisted according to the rules of - * Class Table Inheritance. - */ - public const INHERITANCE_TYPE_JOINED = 2; - - /** - * SINGLE_TABLE means the class will be persisted according to the rules of - * Single Table Inheritance. - */ - public const INHERITANCE_TYPE_SINGLE_TABLE = 3; - - /** - * TABLE_PER_CLASS means the class will be persisted according to the rules - * of Concrete Table Inheritance. - */ - public const INHERITANCE_TYPE_TABLE_PER_CLASS = 4; - - /* The Id generator types. */ - /** - * AUTO means the generator type will depend on what the used platform prefers. - * Offers full portability. - */ - public const GENERATOR_TYPE_AUTO = 1; - - /** - * SEQUENCE means a separate sequence object will be used. Platforms that do - * not have native sequence support may emulate it. Full portability is currently - * not guaranteed. - */ - public const GENERATOR_TYPE_SEQUENCE = 2; - - /** - * IDENTITY means an identity column is used for id generation. The database - * will fill in the id column on insertion. Platforms that do not support - * native identity columns may emulate them. Full portability is currently - * not guaranteed. - */ - public const GENERATOR_TYPE_IDENTITY = 4; - - /** - * NONE means the class does not have a generated id. That means the class - * must have a natural, manually assigned id. - */ - public const GENERATOR_TYPE_NONE = 5; - - /** - * CUSTOM means that customer will use own ID generator that supposedly work - */ - public const GENERATOR_TYPE_CUSTOM = 7; - - /** - * DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time - * by doing a property-by-property comparison with the original data. This will - * be done for all entities that are in MANAGED state at commit-time. - * - * This is the default change tracking policy. - */ - public const CHANGETRACKING_DEFERRED_IMPLICIT = 1; - - /** - * DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time - * by doing a property-by-property comparison with the original data. This will - * be done only for entities that were explicitly saved (through persist() or a cascade). - */ - public const CHANGETRACKING_DEFERRED_EXPLICIT = 2; - - /** - * NOTIFY means that Doctrine relies on the entities sending out notifications - * when their properties change. Such entity classes must implement - * the NotifyPropertyChanged interface. - */ - public const CHANGETRACKING_NOTIFY = 3; - - /** - * Specifies that an association is to be fetched when it is first accessed. - */ - public const FETCH_LAZY = 2; - - /** - * Specifies that an association is to be fetched when the owner of the - * association is fetched. - */ - public const FETCH_EAGER = 3; - - /** - * Specifies that an association is to be fetched lazy (on first access) and that - * commands such as Collection#count, Collection#slice are issued directly against - * the database if the collection is not yet initialized. - */ - public const FETCH_EXTRA_LAZY = 4; - - /** - * Identifies a one-to-one association. - */ - public const ONE_TO_ONE = 1; - - /** - * Identifies a many-to-one association. - */ - public const MANY_TO_ONE = 2; - - /** - * Identifies a one-to-many association. - */ - public const ONE_TO_MANY = 4; - - /** - * Identifies a many-to-many association. - */ - public const MANY_TO_MANY = 8; - - /** - * Combined bitmask for to-one (single-valued) associations. - */ - public const TO_ONE = 3; - - /** - * Combined bitmask for to-many (collection-valued) associations. - */ - public const TO_MANY = 12; - - /** - * ReadOnly cache can do reads, inserts and deletes, cannot perform updates or employ any locks, - */ - public const CACHE_USAGE_READ_ONLY = 1; - - /** - * Nonstrict Read Write Cache doesn’t employ any locks but can do inserts, update and deletes. - */ - public const CACHE_USAGE_NONSTRICT_READ_WRITE = 2; - - /** - * Read Write Attempts to lock the entity before update/delete. - */ - public const CACHE_USAGE_READ_WRITE = 3; - - /** - * The value of this column is never generated by the database. - */ - public const GENERATED_NEVER = 0; - - /** - * The value of this column is generated by the database on INSERT, but not on UPDATE. - */ - public const GENERATED_INSERT = 1; - - /** - * The value of this column is generated by the database on both INSERT and UDPATE statements. - */ - public const GENERATED_ALWAYS = 2; - - /** - * READ-ONLY: The namespace the entity class is contained in. - * - * @todo Not really needed. Usage could be localized. - */ - public string|null $namespace = null; - - /** - * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance - * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same - * as {@link $name}. - * - * @psalm-var class-string - */ - public string $rootEntityName; - - /** - * READ-ONLY: The definition of custom generator. Only used for CUSTOM - * generator type - * - * The definition has the following structure: - * - * array( - * 'class' => 'ClassName', - * ) - * - * - * @todo Merge with tableGeneratorDefinition into generic generatorDefinition - * @var array|null - */ - public array|null $customGeneratorDefinition = null; - - /** - * The name of the custom repository class used for the entity class. - * (Optional). - * - * @psalm-var ?class-string - */ - public string|null $customRepositoryClassName = null; - - /** - * READ-ONLY: Whether this class describes the mapping of a mapped superclass. - */ - public bool $isMappedSuperclass = false; - - /** - * READ-ONLY: Whether this class describes the mapping of an embeddable class. - */ - public bool $isEmbeddedClass = false; - - /** - * READ-ONLY: The names of the parent classes (ancestors). - * - * @psalm-var list - */ - public array $parentClasses = []; - - /** - * READ-ONLY: The names of all subclasses (descendants). - * - * @psalm-var list - */ - public array $subClasses = []; - - /** - * READ-ONLY: The names of all embedded classes based on properties. - * - * @psalm-var array - */ - public array $embeddedClasses = []; - - /** - * READ-ONLY: The field names of all fields that are part of the identifier/primary key - * of the mapped entity class. - * - * @psalm-var list - */ - public array $identifier = []; - - /** - * READ-ONLY: The inheritance mapping type used by the class. - * - * @psalm-var self::INHERITANCE_TYPE_* - */ - public int $inheritanceType = self::INHERITANCE_TYPE_NONE; - - /** - * READ-ONLY: The Id generator type used by the class. - * - * @psalm-var self::GENERATOR_TYPE_* - */ - public int $generatorType = self::GENERATOR_TYPE_NONE; - - /** - * READ-ONLY: The field mappings of the class. - * Keys are field names and values are mapping definitions. - * - * The mapping definition array has the following values: - * - * - fieldName (string) - * The name of the field in the Entity. - * - * - type (string) - * The type name of the mapped field. Can be one of Doctrine's mapping types - * or a custom mapping type. - * - * - columnName (string, optional) - * The column name. Optional. Defaults to the field name. - * - * - length (integer, optional) - * The database length of the column. Optional. Default value taken from - * the type. - * - * - id (boolean, optional) - * Marks the field as the primary key of the entity. Multiple fields of an - * entity can have the id attribute, forming a composite key. - * - * - nullable (boolean, optional) - * Whether the column is nullable. Defaults to FALSE. - * - * - 'notInsertable' (boolean, optional) - * Whether the column is not insertable. Optional. Is only set if value is TRUE. - * - * - 'notUpdatable' (boolean, optional) - * Whether the column is updatable. Optional. Is only set if value is TRUE. - * - * - columnDefinition (string, optional, schema-only) - * The SQL fragment that is used when generating the DDL for the column. - * - * - precision (integer, optional, schema-only) - * The precision of a decimal column. Only valid if the column type is decimal. - * - * - scale (integer, optional, schema-only) - * The scale of a decimal column. Only valid if the column type is decimal. - * - * - 'unique' (string, optional, schema-only) - * Whether a unique constraint should be generated for the column. - * - * @var mixed[] - * @psalm-var array - */ - public array $fieldMappings = []; - - /** - * READ-ONLY: An array of field names. Used to look up field names from column names. - * Keys are column names and values are field names. - * - * @psalm-var array - */ - public array $fieldNames = []; - - /** - * READ-ONLY: A map of field names to column names. Keys are field names and values column names. - * Used to look up column names from field names. - * This is the reverse lookup map of $_fieldNames. - * - * @deprecated 3.0 Remove this. - * - * @var mixed[] - */ - public array $columnNames = []; - - /** - * READ-ONLY: The discriminator value of this class. - * - * This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies - * where a discriminator column is used. - * - * @see discriminatorColumn - */ - public mixed $discriminatorValue = null; - - /** - * READ-ONLY: The discriminator map of all mapped classes in the hierarchy. - * - * This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies - * where a discriminator column is used. - * - * @see discriminatorColumn - * - * @var array - * - * @psalm-var array - */ - public array $discriminatorMap = []; - - /** - * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE - * inheritance mappings. - * - * @var array - * @psalm-var DiscriminatorColumnMapping|null - */ - public array|null $discriminatorColumn = null; - - /** - * READ-ONLY: The primary table definition. The definition is an array with the - * following entries: - * - * name => - * schema => - * indexes => array - * uniqueConstraints => array - * - * @var mixed[] - * @psalm-var array{ - * name: string, - * schema?: string, - * indexes?: array, - * uniqueConstraints?: array, - * options?: array, - * quoted?: bool - * } - */ - public array $table; - - /** - * READ-ONLY: The registered lifecycle callbacks for entities of this class. - * - * @psalm-var array> - */ - public array $lifecycleCallbacks = []; - - /** - * READ-ONLY: The registered entity listeners. - * - * @psalm-var array> - */ - public array $entityListeners = []; - - /** - * READ-ONLY: The association mappings of this class. - * - * The mapping definition array supports the following keys: - * - * - fieldName (string) - * The name of the field in the entity the association is mapped to. - * - * - targetEntity (string) - * The class name of the target entity. If it is fully-qualified it is used as is. - * If it is a simple, unqualified class name the namespace is assumed to be the same - * as the namespace of the source entity. - * - * - mappedBy (string, required for bidirectional associations) - * The name of the field that completes the bidirectional association on the owning side. - * This key must be specified on the inverse side of a bidirectional association. - * - * - inversedBy (string, required for bidirectional associations) - * The name of the field that completes the bidirectional association on the inverse side. - * This key must be specified on the owning side of a bidirectional association. - * - * - cascade (array, optional) - * The names of persistence operations to cascade on the association. The set of possible - * values are: "persist", "remove", "detach", "merge", "refresh", "all" (implies all others). - * - * - orderBy (array, one-to-many/many-to-many only) - * A map of field names (of the target entity) to sorting directions (ASC/DESC). - * Example: array('priority' => 'desc') - * - * - fetch (integer, optional) - * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. - * Possible values are: ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY. - * - * - joinTable (array, optional, many-to-many only) - * Specification of the join table and its join columns (foreign keys). - * Only valid for many-to-many mappings. Note that one-to-many associations can be mapped - * through a join table by simply mapping the association as many-to-many with a unique - * constraint on the join table. - * - * - indexBy (string, optional, to-many only) - * Specification of a field on target-entity that is used to index the collection by. - * This field HAS to be either the primary key or a unique column. Otherwise the collection - * does not contain all the entities that are actually related. - * - * A join table definition has the following structure: - *
-     * array(
-     *     'name' => ,
-     *      'joinColumns' => array(),
-     *      'inverseJoinColumns' => array()
-     * )
-     * 
- * - * @psalm-var array - */ - public array $associationMappings = []; - - /** - * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. - */ - public bool $isIdentifierComposite = false; - - /** - * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. - * - * This flag is necessary because some code blocks require special treatment of this cases. - */ - public bool $containsForeignIdentifier = false; - - /** - * READ-ONLY: Flag indicating whether the identifier/primary key contains at least one ENUM type. - * - * This flag is necessary because some code blocks require special treatment of this cases. - */ - public bool $containsEnumIdentifier = false; - - /** - * READ-ONLY: The ID generator used for generating IDs for this class. - * - * @todo Remove! - */ - public AbstractIdGenerator $idGenerator; - - /** - * READ-ONLY: The definition of the sequence generator of this class. Only used for the - * SEQUENCE generation strategy. - * - * The definition has the following structure: - * - * array( - * 'sequenceName' => 'name', - * 'allocationSize' => '20', - * 'initialValue' => '1' - * ) - * - * - * @var array|null - * @psalm-var array{sequenceName: string, allocationSize: string, initialValue: string, quoted?: mixed}|null - * @todo Merge with tableGeneratorDefinition into generic generatorDefinition - */ - public array|null $sequenceGeneratorDefinition = null; - - /** - * READ-ONLY: The policy used for change-tracking on entities of this class. - */ - public int $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT; - - /** - * READ-ONLY: A Flag indicating whether one or more columns of this class - * have to be reloaded after insert / update operations. - */ - public bool $requiresFetchAfterChange = false; - - /** - * READ-ONLY: A flag for whether or not instances of this class are to be versioned - * with optimistic locking. - */ - public bool $isVersioned = false; - - /** - * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). - */ - public string|null $versionField = null; - - /** @var mixed[]|null */ - public array|null $cache = null; - - /** - * The ReflectionClass instance of the mapped class. - * - * @var ReflectionClass|null - */ - public ReflectionClass|null $reflClass = null; - - /** - * Is this entity marked as "read-only"? - * - * That means it is never considered for change-tracking in the UnitOfWork. It is a very helpful performance - * optimization for entities that are immutable, either in your domain or through the relation database - * (coming from a view, or a history table for example). - */ - public bool $isReadOnly = false; - - /** - * NamingStrategy determining the default column and table names. - */ - protected NamingStrategy $namingStrategy; - - /** - * The ReflectionProperty instances of the mapped class. - * - * @var array - */ - public array $reflFields = []; - - private InstantiatorInterface|null $instantiator = null; - - private TypedFieldMapper $typedFieldMapper; - - /** - * Initializes a new ClassMetadata instance that will hold the object-relational mapping - * metadata of the class with the given name. - * - * @param string $name The name of the entity class the new instance is used for. - * @psalm-param class-string $name - */ - public function __construct(public $name, NamingStrategy|null $namingStrategy = null, TypedFieldMapper|null $typedFieldMapper = null) - { - $this->rootEntityName = $name; - $this->namingStrategy = $namingStrategy ?? new DefaultNamingStrategy(); - $this->instantiator = new Instantiator(); - $this->typedFieldMapper = $typedFieldMapper ?? new DefaultTypedFieldMapper(); - } - - /** - * Gets the ReflectionProperties of the mapped class. - * - * @return ReflectionProperty[]|null[] An array of ReflectionProperty instances. - * @psalm-return array - */ - public function getReflectionProperties(): array - { - return $this->reflFields; - } - - /** - * Gets a ReflectionProperty for a specific field of the mapped class. - */ - public function getReflectionProperty(string $name): ReflectionProperty|null - { - return $this->reflFields[$name]; - } - - /** - * Gets the ReflectionProperty for the single identifier field. - * - * @throws BadMethodCallException If the class has a composite identifier. - */ - public function getSingleIdReflectionProperty(): ReflectionProperty|null - { - if ($this->isIdentifierComposite) { - throw new BadMethodCallException('Class ' . $this->name . ' has a composite identifier.'); - } - - return $this->reflFields[$this->identifier[0]]; - } - - /** - * Extracts the identifier values of an entity of this class. - * - * For composite identifiers, the identifier values are returned as an array - * with the same order as the field order in {@link identifier}. - * - * @param object $entity - * - * @return array - */ - public function getIdentifierValues($entity): array - { - if ($this->isIdentifierComposite) { - $id = []; - - foreach ($this->identifier as $idField) { - $value = $this->reflFields[$idField]->getValue($entity); - - if ($value !== null) { - $id[$idField] = $value; - } - } - - return $id; - } - - $id = $this->identifier[0]; - $value = $this->reflFields[$id]->getValue($entity); - - if ($value === null) { - return []; - } - - return [$id => $value]; - } - - /** - * Populates the entity identifier of an entity. - * - * @psalm-param array $id - * - * @todo Rename to assignIdentifier() - */ - public function setIdentifierValues(object $entity, array $id): void - { - foreach ($id as $idField => $idValue) { - $this->reflFields[$idField]->setValue($entity, $idValue); - } - } - - /** - * Sets the specified field to the specified value on the given entity. - */ - public function setFieldValue(object $entity, string $field, mixed $value): void - { - $this->reflFields[$field]->setValue($entity, $value); - } - - /** - * Gets the specified field's value off the given entity. - */ - public function getFieldValue(object $entity, string $field): mixed - { - return $this->reflFields[$field]->getValue($entity); - } - - /** - * Creates a string representation of this instance. - * - * @return string The string representation of this instance. - * - * @todo Construct meaningful string representation. - */ - public function __toString(): string - { - return self::class . '@' . spl_object_id($this); - } - - /** - * Determines which fields get serialized. - * - * It is only serialized what is necessary for best unserialization performance. - * That means any metadata properties that are not set or empty or simply have - * their default value are NOT serialized. - * - * Parts that are also NOT serialized because they can not be properly unserialized: - * - reflClass (ReflectionClass) - * - reflFields (ReflectionProperty array) - * - * @return string[] The names of all the fields that should be serialized. - */ - public function __sleep() - { - // This metadata is always serialized/cached. - $serialized = [ - 'associationMappings', - 'columnNames', //TODO: 3.0 Remove this. Can use fieldMappings[$fieldName]['columnName'] - 'fieldMappings', - 'fieldNames', - 'embeddedClasses', - 'identifier', - 'isIdentifierComposite', // TODO: REMOVE - 'name', - 'namespace', // TODO: REMOVE - 'table', - 'rootEntityName', - 'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime. - ]; - - // The rest of the metadata is only serialized if necessary. - if ($this->changeTrackingPolicy !== self::CHANGETRACKING_DEFERRED_IMPLICIT) { - $serialized[] = 'changeTrackingPolicy'; - } - - if ($this->customRepositoryClassName) { - $serialized[] = 'customRepositoryClassName'; - } - - if ($this->inheritanceType !== self::INHERITANCE_TYPE_NONE) { - $serialized[] = 'inheritanceType'; - $serialized[] = 'discriminatorColumn'; - $serialized[] = 'discriminatorValue'; - $serialized[] = 'discriminatorMap'; - $serialized[] = 'parentClasses'; - $serialized[] = 'subClasses'; - } - - if ($this->generatorType !== self::GENERATOR_TYPE_NONE) { - $serialized[] = 'generatorType'; - if ($this->generatorType === self::GENERATOR_TYPE_SEQUENCE) { - $serialized[] = 'sequenceGeneratorDefinition'; - } - } - - if ($this->isMappedSuperclass) { - $serialized[] = 'isMappedSuperclass'; - } - - if ($this->isEmbeddedClass) { - $serialized[] = 'isEmbeddedClass'; - } - - if ($this->containsForeignIdentifier) { - $serialized[] = 'containsForeignIdentifier'; - } - - if ($this->containsEnumIdentifier) { - $serialized[] = 'containsEnumIdentifier'; - } - - if ($this->isVersioned) { - $serialized[] = 'isVersioned'; - $serialized[] = 'versionField'; - } - - if ($this->lifecycleCallbacks) { - $serialized[] = 'lifecycleCallbacks'; - } - - if ($this->entityListeners) { - $serialized[] = 'entityListeners'; - } - - if ($this->isReadOnly) { - $serialized[] = 'isReadOnly'; - } - - if ($this->customGeneratorDefinition) { - $serialized[] = 'customGeneratorDefinition'; - } - - if ($this->cache) { - $serialized[] = 'cache'; - } - - if ($this->requiresFetchAfterChange) { - $serialized[] = 'requiresFetchAfterChange'; - } - - return $serialized; - } - - /** - * Creates a new instance of the mapped class, without invoking the constructor. - */ - public function newInstance(): object - { - return $this->instantiator->instantiate($this->name); - } - - /** - * Restores some state that can not be serialized/unserialized. - */ - public function wakeupReflection(ReflectionService $reflService): void - { - // Restore ReflectionClass and properties - $this->reflClass = $reflService->getClass($this->name); - $this->instantiator = $this->instantiator ?: new Instantiator(); - - $parentReflFields = []; - - foreach ($this->embeddedClasses as $property => $embeddedClass) { - if (isset($embeddedClass['declaredField'])) { - $childProperty = $this->getAccessibleProperty( - $reflService, - $this->embeddedClasses[$embeddedClass['declaredField']]['class'], - $embeddedClass['originalField'], - ); - assert($childProperty !== null); - $parentReflFields[$property] = new ReflectionEmbeddedProperty( - $parentReflFields[$embeddedClass['declaredField']], - $childProperty, - $this->embeddedClasses[$embeddedClass['declaredField']]['class'], - ); - - continue; - } - - $fieldRefl = $this->getAccessibleProperty( - $reflService, - $embeddedClass['declared'] ?? $this->name, - $property, - ); - - $parentReflFields[$property] = $fieldRefl; - $this->reflFields[$property] = $fieldRefl; - } - - foreach ($this->fieldMappings as $field => $mapping) { - if (isset($mapping['declaredField']) && isset($parentReflFields[$mapping['declaredField']])) { - $childProperty = $this->getAccessibleProperty($reflService, $mapping['originalClass'], $mapping['originalField']); - assert($childProperty !== null); - - if (isset($mapping['enumType'])) { - $childProperty = new ReflectionEnumProperty( - $childProperty, - $mapping['enumType'], - ); - } - - $this->reflFields[$field] = new ReflectionEmbeddedProperty( - $parentReflFields[$mapping['declaredField']], - $childProperty, - $mapping['originalClass'], - ); - continue; - } - - $this->reflFields[$field] = isset($mapping['declared']) - ? $this->getAccessibleProperty($reflService, $mapping['declared'], $field) - : $this->getAccessibleProperty($reflService, $this->name, $field); - - if (isset($mapping['enumType']) && $this->reflFields[$field] !== null) { - $this->reflFields[$field] = new ReflectionEnumProperty( - $this->reflFields[$field], - $mapping['enumType'], - ); - } - } - - foreach ($this->associationMappings as $field => $mapping) { - $this->reflFields[$field] = isset($mapping['declared']) - ? $this->getAccessibleProperty($reflService, $mapping['declared'], $field) - : $this->getAccessibleProperty($reflService, $this->name, $field); - } - } - - /** - * Initializes a new ClassMetadata instance that will hold the object-relational mapping - * metadata of the class with the given name. - * - * @param ReflectionService $reflService The reflection service. - */ - public function initializeReflection(ReflectionService $reflService): void - { - $this->reflClass = $reflService->getClass($this->name); - $this->namespace = $reflService->getClassNamespace($this->name); - - if ($this->reflClass) { - $this->name = $this->rootEntityName = $this->reflClass->getName(); - } - - $this->table['name'] = $this->namingStrategy->classToTableName($this->name); - } - - /** - * Validates Identifier. - * - * @throws MappingException - */ - public function validateIdentifier(): void - { - if ($this->isMappedSuperclass || $this->isEmbeddedClass) { - return; - } - - // Verify & complete identifier mapping - if (! $this->identifier) { - throw MappingException::identifierRequired($this->name); - } - - if ($this->usesIdGenerator() && $this->isIdentifierComposite) { - throw MappingException::compositeKeyAssignedIdGeneratorRequired($this->name); - } - } - - /** - * Validates association targets actually exist. - * - * @throws MappingException - */ - public function validateAssociations(): void - { - foreach ($this->associationMappings as $mapping) { - if ( - ! class_exists($mapping['targetEntity']) - && ! interface_exists($mapping['targetEntity']) - && ! trait_exists($mapping['targetEntity']) - ) { - throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']); - } - } - } - - /** - * Validates lifecycle callbacks. - * - * @throws MappingException - */ - public function validateLifecycleCallbacks(ReflectionService $reflService): void - { - foreach ($this->lifecycleCallbacks as $callbacks) { - foreach ($callbacks as $callbackFuncName) { - if (! $reflService->hasPublicMethod($this->name, $callbackFuncName)) { - throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callbackFuncName); - } - } - } - } - - /** - * {@inheritDoc} - * - * Can return null when using static reflection, in violation of the LSP - */ - public function getReflectionClass() - { - return $this->reflClass; - } - - /** @psalm-param array{usage?: mixed, region?: mixed} $cache */ - public function enableCache(array $cache): void - { - if (! isset($cache['usage'])) { - $cache['usage'] = self::CACHE_USAGE_READ_ONLY; - } - - if (! isset($cache['region'])) { - $cache['region'] = strtolower(str_replace('\\', '_', $this->rootEntityName)); - } - - $this->cache = $cache; - } - - /** @psalm-param array{usage?: int, region?: string} $cache */ - public function enableAssociationCache(string $fieldName, array $cache): void - { - $this->associationMappings[$fieldName]['cache'] = $this->getAssociationCacheDefaults($fieldName, $cache); - } - - /** - * @psalm-param array{usage?: int, region?: string|null} $cache - * - * @return int[]|string[] - * @psalm-return array{usage: int, region: string|null} - */ - public function getAssociationCacheDefaults(string $fieldName, array $cache): array - { - if (! isset($cache['usage'])) { - $cache['usage'] = $this->cache['usage'] ?? self::CACHE_USAGE_READ_ONLY; - } - - if (! isset($cache['region'])) { - $cache['region'] = strtolower(str_replace('\\', '_', $this->rootEntityName)) . '__' . $fieldName; - } - - return $cache; - } - - /** - * Sets the change tracking policy used by this class. - */ - public function setChangeTrackingPolicy(int $policy): void - { - $this->changeTrackingPolicy = $policy; - } - - /** - * Whether the change tracking policy of this class is "deferred explicit". - */ - public function isChangeTrackingDeferredExplicit(): bool - { - return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_EXPLICIT; - } - - /** - * Whether the change tracking policy of this class is "deferred implicit". - */ - public function isChangeTrackingDeferredImplicit(): bool - { - return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_IMPLICIT; - } - - /** - * Whether the change tracking policy of this class is "notify". - */ - public function isChangeTrackingNotify(): bool - { - return $this->changeTrackingPolicy === self::CHANGETRACKING_NOTIFY; - } - - /** - * Checks whether a field is part of the identifier/primary key field(s). - */ - public function isIdentifier(string $fieldName): bool - { - if (! $this->identifier) { - return false; - } - - if (! $this->isIdentifierComposite) { - return $fieldName === $this->identifier[0]; - } - - return in_array($fieldName, $this->identifier, true); - } - - public function isUniqueField(string $fieldName): bool - { - $mapping = $this->getFieldMapping($fieldName); - - return $mapping !== false && isset($mapping['unique']) && $mapping['unique']; - } - - public function isNullable(string $fieldName): bool - { - $mapping = $this->getFieldMapping($fieldName); - - return $mapping !== false && isset($mapping['nullable']) && $mapping['nullable']; - } - - /** - * Gets a column name for a field name. - * If the column name for the field cannot be found, the given field name - * is returned. - */ - public function getColumnName(string $fieldName): string - { - return $this->columnNames[$fieldName] ?? $fieldName; - } - - /** - * Gets the mapping of a (regular) field that holds some data but not a - * reference to another object. - * - * @return mixed[] The field mapping. - * @psalm-return FieldMapping - * - * @throws MappingException - */ - public function getFieldMapping(string $fieldName): array - { - if (! isset($this->fieldMappings[$fieldName])) { - throw MappingException::mappingNotFound($this->name, $fieldName); - } - - return $this->fieldMappings[$fieldName]; - } - - /** - * Gets the mapping of an association. - * - * @see ClassMetadataInfo::$associationMappings - * - * @param string $fieldName The field name that represents the association in - * the object model. - * - * @return mixed[] The mapping. - * @psalm-return AssociationMapping - * - * @throws MappingException - */ - public function getAssociationMapping(string $fieldName): array - { - if (! isset($this->associationMappings[$fieldName])) { - throw MappingException::mappingNotFound($this->name, $fieldName); - } - - return $this->associationMappings[$fieldName]; - } - - /** - * Gets all association mappings of the class. - * - * @psalm-return array - */ - public function getAssociationMappings(): array - { - return $this->associationMappings; - } - - /** - * Gets the field name for a column name. - * If no field name can be found the column name is returned. - * - * @return string The column alias. - */ - public function getFieldName(string $columnName): string - { - return $this->fieldNames[$columnName] ?? $columnName; - } - - /** - * Checks whether given property has type - */ - private function isTypedProperty(string $name): bool - { - return isset($this->reflClass) - && $this->reflClass->hasProperty($name) - && $this->reflClass->getProperty($name)->hasType(); - } - - /** - * Validates & completes the given field mapping based on typed property. - * - * @param array{fieldName: string, type?: mixed} $mapping The field mapping to validate & complete. - * - * @return array{fieldName: string, enumType?: string, type?: mixed} The updated mapping. - */ - private function validateAndCompleteTypedFieldMapping(array $mapping): array - { - $field = $this->reflClass->getProperty($mapping['fieldName']); - - $mapping = $this->typedFieldMapper->validateAndComplete($mapping, $field); - - return $mapping; - } - - /** - * Validates & completes the basic mapping information based on typed property. - * - * @param array{type: self::ONE_TO_ONE|self::MANY_TO_ONE|self::ONE_TO_MANY|self::MANY_TO_MANY, fieldName: string, targetEntity?: class-string} $mapping The mapping. - * - * @return mixed[] The updated mapping. - */ - private function validateAndCompleteTypedAssociationMapping(array $mapping): array - { - $type = $this->reflClass->getProperty($mapping['fieldName'])->getType(); - - if ($type === null || ($mapping['type'] & self::TO_ONE) === 0) { - return $mapping; - } - - if (! isset($mapping['targetEntity']) && $type instanceof ReflectionNamedType) { - $mapping['targetEntity'] = $type->getName(); - } - - return $mapping; - } - - /** - * Validates & completes the given field mapping. - * - * @psalm-param array{ - * fieldName?: string, - * columnName?: string, - * id?: bool, - * generated?: int, - * enumType?: class-string, - * } $mapping The field mapping to validate & complete. - * - * @return mixed[] The updated mapping. - * - * @throws MappingException - */ - protected function validateAndCompleteFieldMapping(array $mapping): array - { - // Check mandatory fields - if (! isset($mapping['fieldName']) || ! $mapping['fieldName']) { - throw MappingException::missingFieldName($this->name); - } - - if ($this->isTypedProperty($mapping['fieldName'])) { - $mapping = $this->validateAndCompleteTypedFieldMapping($mapping); - } - - if (! isset($mapping['type'])) { - // Default to string - $mapping['type'] = 'string'; - } - - // Complete fieldName and columnName mapping - if (! isset($mapping['columnName'])) { - $mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name); - } - - if ($mapping['columnName'][0] === '`') { - $mapping['columnName'] = trim($mapping['columnName'], '`'); - $mapping['quoted'] = true; - } - - $this->columnNames[$mapping['fieldName']] = $mapping['columnName']; - - if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn && $this->discriminatorColumn['name'] === $mapping['columnName'])) { - throw MappingException::duplicateColumnName($this->name, $mapping['columnName']); - } - - $this->fieldNames[$mapping['columnName']] = $mapping['fieldName']; - - // Complete id mapping - if (isset($mapping['id']) && $mapping['id'] === true) { - if ($this->versionField === $mapping['fieldName']) { - throw MappingException::cannotVersionIdField($this->name, $mapping['fieldName']); - } - - if (! in_array($mapping['fieldName'], $this->identifier, true)) { - $this->identifier[] = $mapping['fieldName']; - } - - // Check for composite key - if (! $this->isIdentifierComposite && count($this->identifier) > 1) { - $this->isIdentifierComposite = true; - } - } - - if (isset($mapping['generated'])) { - if (! in_array($mapping['generated'], [self::GENERATED_NEVER, self::GENERATED_INSERT, self::GENERATED_ALWAYS])) { - throw MappingException::invalidGeneratedMode($mapping['generated']); - } - - if ($mapping['generated'] === self::GENERATED_NEVER) { - unset($mapping['generated']); - } - } - - if (isset($mapping['enumType'])) { - if (! enum_exists($mapping['enumType'])) { - throw MappingException::nonEnumTypeMapped($this->name, $mapping['fieldName'], $mapping['enumType']); - } - - if (! empty($mapping['id'])) { - $this->containsEnumIdentifier = true; - } - } - - return $mapping; - } - - /** - * Validates & completes the basic mapping information that is common to all - * association mappings (one-to-one, many-ot-one, one-to-many, many-to-many). - * - * @psalm-param array $mapping The mapping. - * - * @return mixed[] The updated mapping. - * @psalm-return array{ - * mappedBy: mixed|null, - * inversedBy: mixed|null, - * isOwningSide: bool, - * sourceEntity: class-string, - * targetEntity: string, - * fieldName: mixed, - * fetch: mixed, - * cascade: array, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * type: int, - * originalField: string, - * originalClass: class-string, - * ?orphanRemoval: bool - * } - * - * @throws MappingException If something is wrong with the mapping. - */ - protected function _validateAndCompleteAssociationMapping(array $mapping) - { - if (! isset($mapping['mappedBy'])) { - $mapping['mappedBy'] = null; - } - - if (! isset($mapping['inversedBy'])) { - $mapping['inversedBy'] = null; - } - - $mapping['isOwningSide'] = true; // assume owning side until we hit mappedBy - - if (empty($mapping['indexBy'])) { - unset($mapping['indexBy']); - } - - // If targetEntity is unqualified, assume it is in the same namespace as - // the sourceEntity. - $mapping['sourceEntity'] = $this->name; - - if ($this->isTypedProperty($mapping['fieldName'])) { - $mapping = $this->validateAndCompleteTypedAssociationMapping($mapping); - } - - if (isset($mapping['targetEntity'])) { - $mapping['targetEntity'] = $this->fullyQualifiedClassName($mapping['targetEntity']); - $mapping['targetEntity'] = ltrim($mapping['targetEntity'], '\\'); - } - - if (($mapping['type'] & self::MANY_TO_ONE) > 0 && isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']) { - throw MappingException::illegalOrphanRemoval($this->name, $mapping['fieldName']); - } - - // Complete id mapping - if (isset($mapping['id']) && $mapping['id'] === true) { - if (isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']) { - throw MappingException::illegalOrphanRemovalOnIdentifierAssociation($this->name, $mapping['fieldName']); - } - - if (! in_array($mapping['fieldName'], $this->identifier, true)) { - if (isset($mapping['joinColumns']) && count($mapping['joinColumns']) >= 2) { - throw MappingException::cannotMapCompositePrimaryKeyEntitiesAsForeignId( - $mapping['targetEntity'], - $this->name, - $mapping['fieldName'], - ); - } - - $this->identifier[] = $mapping['fieldName']; - $this->containsForeignIdentifier = true; - } - - // Check for composite key - if (! $this->isIdentifierComposite && count($this->identifier) > 1) { - $this->isIdentifierComposite = true; - } - - if ($this->cache && ! isset($mapping['cache'])) { - throw NonCacheableEntityAssociation::fromEntityAndField( - $this->name, - $mapping['fieldName'], - ); - } - } - - // Mandatory attributes for both sides - // Mandatory: fieldName, targetEntity - if (! isset($mapping['fieldName']) || ! $mapping['fieldName']) { - throw MappingException::missingFieldName($this->name); - } - - if (! isset($mapping['targetEntity'])) { - throw MappingException::missingTargetEntity($mapping['fieldName']); - } - - // Mandatory and optional attributes for either side - if (! $mapping['mappedBy']) { - if (isset($mapping['joinTable']) && $mapping['joinTable']) { - if (isset($mapping['joinTable']['name']) && $mapping['joinTable']['name'][0] === '`') { - $mapping['joinTable']['name'] = trim($mapping['joinTable']['name'], '`'); - $mapping['joinTable']['quoted'] = true; - } - } - } else { - $mapping['isOwningSide'] = false; - } - - if (isset($mapping['id']) && $mapping['id'] === true && $mapping['type'] & self::TO_MANY) { - throw MappingException::illegalToManyIdentifierAssociation($this->name, $mapping['fieldName']); - } - - // Fetch mode. Default fetch mode to LAZY, if not set. - if (! isset($mapping['fetch'])) { - $mapping['fetch'] = self::FETCH_LAZY; - } - - // Cascades - $cascades = isset($mapping['cascade']) ? array_map('strtolower', $mapping['cascade']) : []; - - $allCascades = ['remove', 'persist', 'refresh', 'merge', 'detach']; - if (in_array('all', $cascades, true)) { - $cascades = $allCascades; - } elseif (count($cascades) !== count(array_intersect($cascades, $allCascades))) { - throw MappingException::invalidCascadeOption( - array_diff($cascades, $allCascades), - $this->name, - $mapping['fieldName'], - ); - } - - $mapping['cascade'] = $cascades; - $mapping['isCascadeRemove'] = in_array('remove', $cascades, true); - $mapping['isCascadePersist'] = in_array('persist', $cascades, true); - $mapping['isCascadeRefresh'] = in_array('refresh', $cascades, true); - $mapping['isCascadeMerge'] = in_array('merge', $cascades, true); - $mapping['isCascadeDetach'] = in_array('detach', $cascades, true); - - return $mapping; - } - - /** - * Validates & completes a one-to-one association mapping. - * - * @psalm-param array $mapping The mapping to validate & complete. - * - * @return mixed[] The validated & completed mapping. - * @psalm-return array{isOwningSide: mixed, orphanRemoval: bool, isCascadeRemove: bool} - * @psalm-return array{ - * mappedBy: mixed|null, - * inversedBy: mixed|null, - * isOwningSide: bool, - * sourceEntity: class-string, - * targetEntity: string, - * fieldName: mixed, - * fetch: mixed, - * cascade: array, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * type: int, - * originalField: string, - * originalClass: class-string, - * joinColumns?: array{0: array{name: string, referencedColumnName: string}}|mixed, - * id?: mixed, - * sourceToTargetKeyColumns?: array, - * joinColumnFieldNames?: array, - * targetToSourceKeyColumns?: array, - * orphanRemoval: bool - * } - * - * @throws RuntimeException - * @throws MappingException - */ - protected function _validateAndCompleteOneToOneMapping(array $mapping) - { - $mapping = $this->_validateAndCompleteAssociationMapping($mapping); - - if (isset($mapping['joinColumns']) && $mapping['joinColumns']) { - $mapping['isOwningSide'] = true; - } - - if ($mapping['isOwningSide']) { - if (empty($mapping['joinColumns'])) { - // Apply default join column - $mapping['joinColumns'] = [ - [ - 'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name), - 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), - ], - ]; - } - - $uniqueConstraintColumns = []; - - foreach ($mapping['joinColumns'] as &$joinColumn) { - if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { - if (count($mapping['joinColumns']) === 1) { - if (empty($mapping['id'])) { - $joinColumn['unique'] = true; - } - } else { - $uniqueConstraintColumns[] = $joinColumn['name']; - } - } - - if (empty($joinColumn['name'])) { - $joinColumn['name'] = $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name); - } - - if (empty($joinColumn['referencedColumnName'])) { - $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); - } - - if ($joinColumn['name'][0] === '`') { - $joinColumn['name'] = trim($joinColumn['name'], '`'); - $joinColumn['quoted'] = true; - } - - if ($joinColumn['referencedColumnName'][0] === '`') { - $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`'); - $joinColumn['quoted'] = true; - } - - $mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; - $mapping['joinColumnFieldNames'][$joinColumn['name']] = $joinColumn['fieldName'] ?? $joinColumn['name']; - } - - if ($uniqueConstraintColumns) { - if (! $this->table) { - throw new RuntimeException('ClassMetadataInfo::setTable() has to be called before defining a one to one relationship.'); - } - - $this->table['uniqueConstraints'][$mapping['fieldName'] . '_uniq'] = ['columns' => $uniqueConstraintColumns]; - } - - $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']); - } - - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; - $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; - - if ($mapping['orphanRemoval']) { - unset($mapping['unique']); - } - - if (isset($mapping['id']) && $mapping['id'] === true && ! $mapping['isOwningSide']) { - throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']); - } - - return $mapping; - } - - /** - * Validates & completes a one-to-many association mapping. - * - * @psalm-param array $mapping The mapping to validate and complete. - * - * @return mixed[] The validated and completed mapping. - * @psalm-return array{ - * mappedBy: mixed, - * inversedBy: mixed, - * isOwningSide: bool, - * sourceEntity: string, - * targetEntity: string, - * fieldName: mixed, - * fetch: int|mixed, - * cascade: array, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * orphanRemoval: bool - * } - * - * @throws MappingException - * @throws InvalidArgumentException - */ - protected function _validateAndCompleteOneToManyMapping(array $mapping) - { - $mapping = $this->_validateAndCompleteAssociationMapping($mapping); - - // OneToMany-side MUST be inverse (must have mappedBy) - if (! isset($mapping['mappedBy'])) { - throw MappingException::oneToManyRequiresMappedBy($this->name, $mapping['fieldName']); - } - - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; - $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; - - $this->assertMappingOrderBy($mapping); - - return $mapping; - } - - /** - * Validates & completes a many-to-many association mapping. - * - * @psalm-param array $mapping The mapping to validate & complete. - * @psalm-param array $mapping The mapping to validate & complete. - * - * @return mixed[] The validated & completed mapping. - * @psalm-return array{ - * mappedBy: mixed, - * inversedBy: mixed, - * isOwningSide: bool, - * sourceEntity: class-string, - * targetEntity: string, - * fieldName: mixed, - * fetch: mixed, - * cascade: array, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * type: int, - * originalField: string, - * originalClass: class-string, - * joinTable?: array{inverseJoinColumns: mixed}|mixed, - * joinTableColumns?: list, - * isOnDeleteCascade?: true, - * relationToSourceKeyColumns?: array, - * relationToTargetKeyColumns?: array, - * orphanRemoval: bool - * } - * - * @throws InvalidArgumentException - */ - protected function _validateAndCompleteManyToManyMapping(array $mapping) - { - $mapping = $this->_validateAndCompleteAssociationMapping($mapping); - - if ($mapping['isOwningSide']) { - // owning side MUST have a join table - if (! isset($mapping['joinTable']['name'])) { - $mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']); - } - - $selfReferencingEntityWithoutJoinColumns = $mapping['sourceEntity'] === $mapping['targetEntity'] - && (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns']))); - - if (! isset($mapping['joinTable']['joinColumns'])) { - $mapping['joinTable']['joinColumns'] = [ - [ - 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null), - 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), - 'onDelete' => 'CASCADE', - ], - ]; - } - - if (! isset($mapping['joinTable']['inverseJoinColumns'])) { - $mapping['joinTable']['inverseJoinColumns'] = [ - [ - 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null), - 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), - 'onDelete' => 'CASCADE', - ], - ]; - } - - $mapping['joinTableColumns'] = []; - - foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) { - if (empty($joinColumn['name'])) { - $joinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $joinColumn['referencedColumnName']); - } - - if (empty($joinColumn['referencedColumnName'])) { - $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); - } - - if ($joinColumn['name'][0] === '`') { - $joinColumn['name'] = trim($joinColumn['name'], '`'); - $joinColumn['quoted'] = true; - } - - if ($joinColumn['referencedColumnName'][0] === '`') { - $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`'); - $joinColumn['quoted'] = true; - } - - if (isset($joinColumn['onDelete']) && strtolower($joinColumn['onDelete']) === 'cascade') { - $mapping['isOnDeleteCascade'] = true; - } - - $mapping['relationToSourceKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; - $mapping['joinTableColumns'][] = $joinColumn['name']; - } - - foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) { - if (empty($inverseJoinColumn['name'])) { - $inverseJoinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $inverseJoinColumn['referencedColumnName']); - } - - if (empty($inverseJoinColumn['referencedColumnName'])) { - $inverseJoinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); - } - - if ($inverseJoinColumn['name'][0] === '`') { - $inverseJoinColumn['name'] = trim($inverseJoinColumn['name'], '`'); - $inverseJoinColumn['quoted'] = true; - } - - if ($inverseJoinColumn['referencedColumnName'][0] === '`') { - $inverseJoinColumn['referencedColumnName'] = trim($inverseJoinColumn['referencedColumnName'], '`'); - $inverseJoinColumn['quoted'] = true; - } - - if (isset($inverseJoinColumn['onDelete']) && strtolower($inverseJoinColumn['onDelete']) === 'cascade') { - $mapping['isOnDeleteCascade'] = true; - } - - $mapping['relationToTargetKeyColumns'][$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName']; - $mapping['joinTableColumns'][] = $inverseJoinColumn['name']; - } - } - - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; - - $this->assertMappingOrderBy($mapping); - - return $mapping; - } - - /** - * {@inheritDoc} - */ - public function getIdentifierFieldNames(): array - { - return $this->identifier; - } - - /** - * Gets the name of the single id field. Note that this only works on - * entity classes that have a single-field pk. - * - * @throws MappingException If the class doesn't have an identifier or it has a composite primary key. - */ - public function getSingleIdentifierFieldName(): string - { - if ($this->isIdentifierComposite) { - throw MappingException::singleIdNotAllowedOnCompositePrimaryKey($this->name); - } - - if (! isset($this->identifier[0])) { - throw MappingException::noIdDefined($this->name); - } - - return $this->identifier[0]; - } - - /** - * Gets the column name of the single id column. Note that this only works on - * entity classes that have a single-field pk. - * - * @throws MappingException If the class doesn't have an identifier or it has a composite primary key. - */ - public function getSingleIdentifierColumnName(): string - { - return $this->getColumnName($this->getSingleIdentifierFieldName()); - } - - /** - * INTERNAL: - * Sets the mapped identifier/primary key fields of this class. - * Mainly used by the ClassMetadataFactory to assign inherited identifiers. - * - * @psalm-param list $identifier - */ - public function setIdentifier(array $identifier): void - { - $this->identifier = $identifier; - $this->isIdentifierComposite = (count($this->identifier) > 1); - } - - /** - * {@inheritDoc} - */ - public function getIdentifier(): array - { - return $this->identifier; - } - - public function hasField(string $fieldName): bool - { - return isset($this->fieldMappings[$fieldName]) || isset($this->embeddedClasses[$fieldName]); - } - - /** - * Gets an array containing all the column names. - * - * @psalm-param list|null $fieldNames - * - * @return mixed[] - * @psalm-return list - */ - public function getColumnNames(array|null $fieldNames = null): array - { - if ($fieldNames === null) { - return array_keys($this->fieldNames); - } - - return array_values(array_map([$this, 'getColumnName'], $fieldNames)); - } - - /** - * Returns an array with all the identifier column names. - * - * @psalm-return list - */ - public function getIdentifierColumnNames(): array - { - $columnNames = []; - - foreach ($this->identifier as $idProperty) { - if (isset($this->fieldMappings[$idProperty])) { - $columnNames[] = $this->fieldMappings[$idProperty]['columnName']; - - continue; - } - - // Association defined as Id field - $joinColumns = $this->associationMappings[$idProperty]['joinColumns']; - $assocColumnNames = array_map(static fn ($joinColumn) => $joinColumn['name'], $joinColumns); - - $columnNames = array_merge($columnNames, $assocColumnNames); - } - - return $columnNames; - } - - /** - * Sets the type of Id generator to use for the mapped class. - * - * @psalm-param self::GENERATOR_TYPE_* $generatorType - */ - public function setIdGeneratorType(int $generatorType): void - { - $this->generatorType = $generatorType; - } - - /** - * Checks whether the mapped class uses an Id generator. - */ - public function usesIdGenerator(): bool - { - return $this->generatorType !== self::GENERATOR_TYPE_NONE; - } - - public function isInheritanceTypeNone(): bool - { - return $this->inheritanceType === self::INHERITANCE_TYPE_NONE; - } - - /** - * Checks whether the mapped class uses the JOINED inheritance mapping strategy. - * - * @return bool TRUE if the class participates in a JOINED inheritance mapping, - * FALSE otherwise. - */ - public function isInheritanceTypeJoined(): bool - { - return $this->inheritanceType === self::INHERITANCE_TYPE_JOINED; - } - - /** - * Checks whether the mapped class uses the SINGLE_TABLE inheritance mapping strategy. - * - * @return bool TRUE if the class participates in a SINGLE_TABLE inheritance mapping, - * FALSE otherwise. - */ - public function isInheritanceTypeSingleTable(): bool - { - return $this->inheritanceType === self::INHERITANCE_TYPE_SINGLE_TABLE; - } - - /** - * Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy. - * - * @return bool TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, - * FALSE otherwise. - */ - public function isInheritanceTypeTablePerClass(): bool - { - return $this->inheritanceType === self::INHERITANCE_TYPE_TABLE_PER_CLASS; - } - - /** - * Checks whether the class uses an identity column for the Id generation. - */ - public function isIdGeneratorIdentity(): bool - { - return $this->generatorType === self::GENERATOR_TYPE_IDENTITY; - } - - /** - * Checks whether the class uses a sequence for id generation. - * - * @psalm-assert-if-true !null $this->sequenceGeneratorDefinition - */ - public function isIdGeneratorSequence(): bool - { - return $this->generatorType === self::GENERATOR_TYPE_SEQUENCE; - } - - /** - * Checks whether the class has a natural identifier/pk (which means it does - * not use any Id generator. - */ - public function isIdentifierNatural(): bool - { - return $this->generatorType === self::GENERATOR_TYPE_NONE; - } - - /** - * Gets the type of a field. - * - * @todo 3.0 Remove this. PersisterHelper should fix it somehow - */ - public function getTypeOfField(string $fieldName): string|null - { - return isset($this->fieldMappings[$fieldName]) - ? $this->fieldMappings[$fieldName]['type'] - : null; - } - - /** - * Gets the name of the primary table. - */ - public function getTableName(): string - { - return $this->table['name']; - } - - /** - * Gets primary table's schema name. - */ - public function getSchemaName(): string|null - { - return $this->table['schema'] ?? null; - } - - /** - * Gets the table name to use for temporary identifier tables of this class. - */ - public function getTemporaryIdTableName(): string - { - // replace dots with underscores because PostgreSQL creates temporary tables in a special schema - return str_replace('.', '_', $this->getTableName() . '_id_tmp'); - } - - /** - * Sets the mapped subclasses of this class. - * - * @psalm-param list $subclasses The names of all mapped subclasses. - */ - public function setSubclasses(array $subclasses): void - { - foreach ($subclasses as $subclass) { - $this->subClasses[] = $this->fullyQualifiedClassName($subclass); - } - } - - /** - * Sets the parent class names. - * Assumes that the class names in the passed array are in the order: - * directParent -> directParentParent -> directParentParentParent ... -> root. - * - * @psalm-param list $classNames - */ - public function setParentClasses(array $classNames): void - { - $this->parentClasses = $classNames; - - if (count($classNames) > 0) { - $this->rootEntityName = array_pop($classNames); - } - } - - /** - * Sets the inheritance type used by the class and its subclasses. - * - * @psalm-param self::INHERITANCE_TYPE_* $type - * - * @throws MappingException - */ - public function setInheritanceType(int $type): void - { - if (! $this->isInheritanceType($type)) { - throw MappingException::invalidInheritanceType($this->name, $type); - } - - $this->inheritanceType = $type; - } - - /** - * Sets the association to override association mapping of property for an entity relationship. - * - * @psalm-param array $overrideMapping - * - * @throws MappingException - */ - public function setAssociationOverride(string $fieldName, array $overrideMapping): void - { - if (! isset($this->associationMappings[$fieldName])) { - throw MappingException::invalidOverrideFieldName($this->name, $fieldName); - } - - $mapping = $this->associationMappings[$fieldName]; - - //if (isset($mapping['inherited']) && (count($overrideMapping) !== 1 || ! isset($overrideMapping['fetch']))) { - // TODO: Deprecate overriding the fetch mode via association override for 3.0, - // users should do this with a listener and a custom attribute/annotation - // TODO: Enable this exception in 2.8 - //throw MappingException::illegalOverrideOfInheritedProperty($this->name, $fieldName); - //} - - if (isset($overrideMapping['joinColumns'])) { - $mapping['joinColumns'] = $overrideMapping['joinColumns']; - } - - if (isset($overrideMapping['inversedBy'])) { - $mapping['inversedBy'] = $overrideMapping['inversedBy']; - } - - if (isset($overrideMapping['joinTable'])) { - $mapping['joinTable'] = $overrideMapping['joinTable']; - } - - if (isset($overrideMapping['fetch'])) { - $mapping['fetch'] = $overrideMapping['fetch']; - } - - $mapping['joinColumnFieldNames'] = null; - $mapping['joinTableColumns'] = null; - $mapping['sourceToTargetKeyColumns'] = null; - $mapping['relationToSourceKeyColumns'] = null; - $mapping['relationToTargetKeyColumns'] = null; - - switch ($mapping['type']) { - case self::ONE_TO_ONE: - $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); - break; - case self::ONE_TO_MANY: - $mapping = $this->_validateAndCompleteOneToManyMapping($mapping); - break; - case self::MANY_TO_ONE: - $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); - break; - case self::MANY_TO_MANY: - $mapping = $this->_validateAndCompleteManyToManyMapping($mapping); - break; - } - - $this->associationMappings[$fieldName] = $mapping; - } - - /** - * Sets the override for a mapped field. - * - * @psalm-param array $overrideMapping - * - * @throws MappingException - */ - public function setAttributeOverride(string $fieldName, array $overrideMapping): void - { - if (! isset($this->fieldMappings[$fieldName])) { - throw MappingException::invalidOverrideFieldName($this->name, $fieldName); - } - - $mapping = $this->fieldMappings[$fieldName]; - - //if (isset($mapping['inherited'])) { - // TODO: Enable this exception in 2.8 - //throw MappingException::illegalOverrideOfInheritedProperty($this->name, $fieldName); - //} - - if (isset($mapping['id'])) { - $overrideMapping['id'] = $mapping['id']; - } - - if (! isset($overrideMapping['type'])) { - $overrideMapping['type'] = $mapping['type']; - } - - if (! isset($overrideMapping['fieldName'])) { - $overrideMapping['fieldName'] = $mapping['fieldName']; - } - - if ($overrideMapping['type'] !== $mapping['type']) { - throw MappingException::invalidOverrideFieldType($this->name, $fieldName); - } - - unset($this->fieldMappings[$fieldName]); - unset($this->fieldNames[$mapping['columnName']]); - unset($this->columnNames[$mapping['fieldName']]); - - $overrideMapping = $this->validateAndCompleteFieldMapping($overrideMapping); - - $this->fieldMappings[$fieldName] = $overrideMapping; - } - - /** - * Checks whether a mapped field is inherited from an entity superclass. - */ - public function isInheritedField(string $fieldName): bool - { - return isset($this->fieldMappings[$fieldName]['inherited']); - } - - /** - * Checks if this entity is the root in any entity-inheritance-hierarchy. - */ - public function isRootEntity(): bool - { - return $this->name === $this->rootEntityName; - } - - /** - * Checks whether a mapped association field is inherited from a superclass. - */ - public function isInheritedAssociation(string $fieldName): bool - { - return isset($this->associationMappings[$fieldName]['inherited']); - } - - public function isInheritedEmbeddedClass(string $fieldName): bool - { - return isset($this->embeddedClasses[$fieldName]['inherited']); - } - - /** - * Sets the name of the primary table the class is mapped to. - * - * @deprecated Use {@link setPrimaryTable}. - */ - public function setTableName(string $tableName): void - { - $this->table['name'] = $tableName; - } - - /** - * Sets the primary table definition. The provided array supports the - * following structure: - * - * name => (optional, defaults to class name) - * indexes => array of indexes (optional) - * uniqueConstraints => array of constraints (optional) - * - * If a key is omitted, the current value is kept. - * - * @psalm-param array $table The table description. - */ - public function setPrimaryTable(array $table): void - { - if (isset($table['name'])) { - // Split schema and table name from a table name like "myschema.mytable" - if (str_contains($table['name'], '.')) { - [$this->table['schema'], $table['name']] = explode('.', $table['name'], 2); - } - - if ($table['name'][0] === '`') { - $table['name'] = trim($table['name'], '`'); - $this->table['quoted'] = true; - } - - $this->table['name'] = $table['name']; - } - - if (isset($table['quoted'])) { - $this->table['quoted'] = $table['quoted']; - } - - if (isset($table['schema'])) { - $this->table['schema'] = $table['schema']; - } - - if (isset($table['indexes'])) { - $this->table['indexes'] = $table['indexes']; - } - - if (isset($table['uniqueConstraints'])) { - $this->table['uniqueConstraints'] = $table['uniqueConstraints']; - } - - if (isset($table['options'])) { - $this->table['options'] = $table['options']; - } - } - - /** - * Checks whether the given type identifies an inheritance type. - */ - private function isInheritanceType(int $type): bool - { - return $type === self::INHERITANCE_TYPE_NONE || - $type === self::INHERITANCE_TYPE_SINGLE_TABLE || - $type === self::INHERITANCE_TYPE_JOINED || - $type === self::INHERITANCE_TYPE_TABLE_PER_CLASS; - } - - /** - * Adds a mapped field to the class. - * - * @psalm-param array $mapping The field mapping. - * - * @throws MappingException - */ - public function mapField(array $mapping): void - { - $mapping = $this->validateAndCompleteFieldMapping($mapping); - $this->assertFieldNotMapped($mapping['fieldName']); - - if (isset($mapping['generated'])) { - $this->requiresFetchAfterChange = true; - } - - $this->fieldMappings[$mapping['fieldName']] = $mapping; - } - - /** - * INTERNAL: - * Adds an association mapping without completing/validating it. - * This is mainly used to add inherited association mappings to derived classes. - * - * @psalm-param AssociationMapping $mapping - * - * @throws MappingException - */ - public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/): void - { - if (isset($this->associationMappings[$mapping['fieldName']])) { - throw MappingException::duplicateAssociationMapping($this->name, $mapping['fieldName']); - } - - $this->associationMappings[$mapping['fieldName']] = $mapping; - } - - /** - * INTERNAL: - * Adds a field mapping without completing/validating it. - * This is mainly used to add inherited field mappings to derived classes. - * - * @psalm-param array $fieldMapping - */ - public function addInheritedFieldMapping(array $fieldMapping): void - { - $this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping; - $this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName']; - $this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName']; - } - - /** - * Adds a one-to-one mapping. - * - * @param array $mapping The mapping. - */ - public function mapOneToOne(array $mapping): void - { - $mapping['type'] = self::ONE_TO_ONE; - - $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); - - $this->_storeAssociationMapping($mapping); - } - - /** - * Adds a one-to-many mapping. - * - * @psalm-param array $mapping The mapping. - */ - public function mapOneToMany(array $mapping): void - { - $mapping['type'] = self::ONE_TO_MANY; - - $mapping = $this->_validateAndCompleteOneToManyMapping($mapping); - - $this->_storeAssociationMapping($mapping); - } - - /** - * Adds a many-to-one mapping. - * - * @psalm-param array $mapping The mapping. - */ - public function mapManyToOne(array $mapping): void - { - $mapping['type'] = self::MANY_TO_ONE; - - // A many-to-one mapping is essentially a one-one backreference - $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); - - $this->_storeAssociationMapping($mapping); - } - - /** - * Adds a many-to-many mapping. - * - * @psalm-param array $mapping The mapping. - */ - public function mapManyToMany(array $mapping): void - { - $mapping['type'] = self::MANY_TO_MANY; - - $mapping = $this->_validateAndCompleteManyToManyMapping($mapping); - - $this->_storeAssociationMapping($mapping); - } - - /** - * Stores the association mapping. - * - * @psalm-param array $assocMapping - * - * @throws MappingException - */ - protected function _storeAssociationMapping(array $assocMapping): void - { - $sourceFieldName = $assocMapping['fieldName']; - - $this->assertFieldNotMapped($sourceFieldName); - - $this->associationMappings[$sourceFieldName] = $assocMapping; - } - - /** - * Registers a custom repository class for the entity class. - * - * @param string|null $repositoryClassName The class name of the custom mapper. - * @psalm-param class-string|null $repositoryClassName - */ - public function setCustomRepositoryClass(string|null $repositoryClassName): void - { - $this->customRepositoryClassName = $this->fullyQualifiedClassName($repositoryClassName); - } - - /** - * Dispatches the lifecycle event of the given entity to the registered - * lifecycle callbacks and lifecycle listeners. - * - * @deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker - * - * @param string $lifecycleEvent The lifecycle event. - */ - public function invokeLifecycleCallbacks(string $lifecycleEvent, object $entity): void - { - foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) { - $entity->$callback(); - } - } - - /** - * Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event. - */ - public function hasLifecycleCallbacks(string $lifecycleEvent): bool - { - return isset($this->lifecycleCallbacks[$lifecycleEvent]); - } - - /** - * Gets the registered lifecycle callbacks for an event. - * - * @return string[] - * @psalm-return list - */ - public function getLifecycleCallbacks(string $event): array - { - return $this->lifecycleCallbacks[$event] ?? []; - } - - /** - * Adds a lifecycle callback for entities of this class. - */ - public function addLifecycleCallback(string $callback, string $event): void - { - if ($this->isEmbeddedClass) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/8381', - 'Registering lifecycle callback %s on Embedded class %s is not doing anything and will throw exception in 3.0', - $event, - $this->name, - ); - } - - if (isset($this->lifecycleCallbacks[$event]) && in_array($callback, $this->lifecycleCallbacks[$event], true)) { - return; - } - - $this->lifecycleCallbacks[$event][] = $callback; - } - - /** - * Sets the lifecycle callbacks for entities of this class. - * Any previously registered callbacks are overwritten. - * - * @psalm-param array> $callbacks - */ - public function setLifecycleCallbacks(array $callbacks): void - { - $this->lifecycleCallbacks = $callbacks; - } - - /** - * Adds a entity listener for entities of this class. - * - * @param string $eventName The entity lifecycle event. - * @param string $class The listener class. - * @param string $method The listener callback method. - * - * @throws MappingException - */ - public function addEntityListener(string $eventName, string $class, string $method): void - { - $class = $this->fullyQualifiedClassName($class); - - $listener = [ - 'class' => $class, - 'method' => $method, - ]; - - if (! class_exists($class)) { - throw MappingException::entityListenerClassNotFound($class, $this->name); - } - - if (! method_exists($class, $method)) { - throw MappingException::entityListenerMethodNotFound($class, $method, $this->name); - } - - if (isset($this->entityListeners[$eventName]) && in_array($listener, $this->entityListeners[$eventName], true)) { - throw MappingException::duplicateEntityListener($class, $method, $this->name); - } - - $this->entityListeners[$eventName][] = $listener; - } - - /** - * Sets the discriminator column definition. - * - * @see getDiscriminatorColumn() - * - * @param mixed[]|null $columnDef - * @psalm-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null, enumType?: class-string|null}|null $columnDef - * - * @throws MappingException - */ - public function setDiscriminatorColumn(array|null $columnDef): void - { - if ($columnDef !== null) { - if (! isset($columnDef['name'])) { - throw MappingException::nameIsMandatoryForDiscriminatorColumns($this->name); - } - - if (isset($this->fieldNames[$columnDef['name']])) { - throw MappingException::duplicateColumnName($this->name, $columnDef['name']); - } - - if (! isset($columnDef['fieldName'])) { - $columnDef['fieldName'] = $columnDef['name']; - } - - if (! isset($columnDef['type'])) { - $columnDef['type'] = 'string'; - } - - if (in_array($columnDef['type'], ['boolean', 'array', 'object', 'datetime', 'time', 'date'], true)) { - throw MappingException::invalidDiscriminatorColumnType($this->name, $columnDef['type']); - } - - $this->discriminatorColumn = $columnDef; - } - } - - /** - * @return array - * @psalm-return DiscriminatorColumnMapping - */ - final public function getDiscriminatorColumn(): array - { - if ($this->discriminatorColumn === null) { - throw new LogicException('The discriminator column was not set.'); - } - - return $this->discriminatorColumn; - } - - /** - * Sets the discriminator values used by this class. - * Used for JOINED and SINGLE_TABLE inheritance mapping strategies. - * - * @param array $map - */ - public function setDiscriminatorMap(array $map): void - { - foreach ($map as $value => $className) { - $this->addDiscriminatorMapClass($value, $className); - } - } - - /** - * Adds one entry of the discriminator map with a new class and corresponding name. - * - * @throws MappingException - */ - public function addDiscriminatorMapClass(int|string $name, string $className): void - { - $className = $this->fullyQualifiedClassName($className); - $className = ltrim($className, '\\'); - - $this->discriminatorMap[$name] = $className; - - if ($this->name === $className) { - $this->discriminatorValue = $name; - - return; - } - - if (! (class_exists($className) || interface_exists($className))) { - throw MappingException::invalidClassInDiscriminatorMap($className, $this->name); - } - - if (is_subclass_of($className, $this->name) && ! in_array($className, $this->subClasses, true)) { - $this->subClasses[] = $className; - } - } - - public function hasAssociation(string $fieldName): bool - { - return isset($this->associationMappings[$fieldName]); - } - - public function isSingleValuedAssociation(string $fieldName): bool - { - return isset($this->associationMappings[$fieldName]) - && ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); - } - - public function isCollectionValuedAssociation(string $fieldName): bool - { - return isset($this->associationMappings[$fieldName]) - && ! ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); - } - - /** - * Is this an association that only has a single join column? - */ - public function isAssociationWithSingleJoinColumn(string $fieldName): bool - { - return isset($this->associationMappings[$fieldName]) - && isset($this->associationMappings[$fieldName]['joinColumns'][0]) - && ! isset($this->associationMappings[$fieldName]['joinColumns'][1]); - } - - /** - * Returns the single association join column (if any). - * - * @throws MappingException - */ - public function getSingleAssociationJoinColumnName(string $fieldName): string - { - if (! $this->isAssociationWithSingleJoinColumn($fieldName)) { - throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); - } - - return $this->associationMappings[$fieldName]['joinColumns'][0]['name']; - } - - /** - * Returns the single association referenced join column name (if any). - * - * @throws MappingException - */ - public function getSingleAssociationReferencedJoinColumnName(string $fieldName): string - { - if (! $this->isAssociationWithSingleJoinColumn($fieldName)) { - throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); - } - - return $this->associationMappings[$fieldName]['joinColumns'][0]['referencedColumnName']; - } - - /** - * Used to retrieve a fieldname for either field or association from a given column. - * - * This method is used in foreign-key as primary-key contexts. - * - * @throws MappingException - */ - public function getFieldForColumn(string $columnName): string - { - if (isset($this->fieldNames[$columnName])) { - return $this->fieldNames[$columnName]; - } - - foreach ($this->associationMappings as $assocName => $mapping) { - if ( - $this->isAssociationWithSingleJoinColumn($assocName) && - $this->associationMappings[$assocName]['joinColumns'][0]['name'] === $columnName - ) { - return $assocName; - } - } - - throw MappingException::noFieldNameFoundForColumn($this->name, $columnName); - } - - /** - * Sets the ID generator used to generate IDs for instances of this class. - */ - public function setIdGenerator(AbstractIdGenerator $generator): void - { - $this->idGenerator = $generator; - } - - /** - * Sets definition. - * - * @psalm-param array $definition - */ - public function setCustomGeneratorDefinition(array $definition): void - { - $this->customGeneratorDefinition = $definition; - } - - /** - * Sets the definition of the sequence ID generator for this class. - * - * The definition must have the following structure: - * - * array( - * 'sequenceName' => 'name', - * 'allocationSize' => 20, - * 'initialValue' => 1 - * 'quoted' => 1 - * ) - * - * - * @psalm-param array{sequenceName?: string, allocationSize?: int|string, initialValue?: int|string, quoted?: mixed} $definition - * - * @throws MappingException - */ - public function setSequenceGeneratorDefinition(array $definition): void - { - if (! isset($definition['sequenceName']) || trim($definition['sequenceName']) === '') { - throw MappingException::missingSequenceName($this->name); - } - - if ($definition['sequenceName'][0] === '`') { - $definition['sequenceName'] = trim($definition['sequenceName'], '`'); - $definition['quoted'] = true; - } - - if (! isset($definition['allocationSize']) || trim((string) $definition['allocationSize']) === '') { - $definition['allocationSize'] = '1'; - } - - if (! isset($definition['initialValue']) || trim((string) $definition['initialValue']) === '') { - $definition['initialValue'] = '1'; - } - - $definition['allocationSize'] = (string) $definition['allocationSize']; - $definition['initialValue'] = (string) $definition['initialValue']; - - $this->sequenceGeneratorDefinition = $definition; - } - - /** - * Sets the version field mapping used for versioning. Sets the default - * value to use depending on the column type. - * - * @psalm-param array $mapping The version field mapping array. - * - * @throws MappingException - */ - public function setVersionMapping(array &$mapping): void - { - $this->isVersioned = true; - $this->versionField = $mapping['fieldName']; - $this->requiresFetchAfterChange = true; - - if (! isset($mapping['default'])) { - if (in_array($mapping['type'], ['integer', 'bigint', 'smallint'], true)) { - $mapping['default'] = 1; - } elseif ($mapping['type'] === 'datetime') { - $mapping['default'] = 'CURRENT_TIMESTAMP'; - } else { - throw MappingException::unsupportedOptimisticLockingType($this->name, $mapping['fieldName'], $mapping['type']); - } - } - } - - /** - * Sets whether this class is to be versioned for optimistic locking. - */ - public function setVersioned(bool $bool): void - { - $this->isVersioned = $bool; - - if ($bool) { - $this->requiresFetchAfterChange = true; - } - } - - /** - * Sets the name of the field that is to be used for versioning if this class is - * versioned for optimistic locking. - */ - public function setVersionField(string|null $versionField): void - { - $this->versionField = $versionField; - } - - /** - * Marks this class as read only, no change tracking is applied to it. - */ - public function markReadOnly(): void - { - $this->isReadOnly = true; - } - - /** - * {@inheritDoc} - */ - public function getFieldNames(): array - { - return array_keys($this->fieldMappings); - } - - /** - * {@inheritDoc} - */ - public function getAssociationNames(): array - { - return array_keys($this->associationMappings); - } - - /** - * {@inheritDoc} - * - * @psalm-return class-string - * - * @throws InvalidArgumentException - */ - public function getAssociationTargetClass(string $assocName): string - { - return $this->associationMappings[$assocName]['targetEntity'] - ?? throw new InvalidArgumentException("Association name expected, '" . $assocName . "' is not an association."); - } - - public function getName(): string - { - return $this->name; - } - - public function isAssociationInverseSide(string $assocName): bool - { - return isset($this->associationMappings[$assocName]) - && ! $this->associationMappings[$assocName]['isOwningSide']; - } - - public function getAssociationMappedByTargetField(string $assocName): string - { - return $this->associationMappings[$assocName]['mappedBy']; - } - - /** - * @return string|null null if the input value is null - * @psalm-return class-string|null - */ - public function fullyQualifiedClassName(string|null $className): string|null - { - if (empty($className)) { - return $className; - } - - if (! str_contains($className, '\\') && $this->namespace) { - return $this->namespace . '\\' . $className; - } - - return $className; - } - - public function getMetadataValue(string $name): mixed - { - if (isset($this->$name)) { - return $this->$name; - } - - return null; - } - - /** - * Map Embedded Class - * - * @psalm-param array $mapping - * - * @throws MappingException - */ - public function mapEmbedded(array $mapping): void - { - $this->assertFieldNotMapped($mapping['fieldName']); - - if (! isset($mapping['class']) && $this->isTypedProperty($mapping['fieldName'])) { - $type = $this->reflClass->getProperty($mapping['fieldName'])->getType(); - if ($type instanceof ReflectionNamedType) { - $mapping['class'] = $type->getName(); - } - } - - $this->embeddedClasses[$mapping['fieldName']] = [ - 'class' => $this->fullyQualifiedClassName($mapping['class']), - 'columnPrefix' => $mapping['columnPrefix'] ?? null, - 'declaredField' => $mapping['declaredField'] ?? null, - 'originalField' => $mapping['originalField'] ?? null, - ]; - } - - /** - * Inline the embeddable class - */ - public function inlineEmbeddable(string $property, ClassMetadataInfo $embeddable): void - { - foreach ($embeddable->fieldMappings as $fieldMapping) { - $fieldMapping['originalClass'] ??= $embeddable->name; - $fieldMapping['declaredField'] = isset($fieldMapping['declaredField']) - ? $property . '.' . $fieldMapping['declaredField'] - : $property; - $fieldMapping['originalField'] ??= $fieldMapping['fieldName']; - $fieldMapping['fieldName'] = $property . '.' . $fieldMapping['fieldName']; - - if (! empty($this->embeddedClasses[$property]['columnPrefix'])) { - $fieldMapping['columnName'] = $this->embeddedClasses[$property]['columnPrefix'] . $fieldMapping['columnName']; - } elseif ($this->embeddedClasses[$property]['columnPrefix'] !== false) { - assert($this->reflClass !== null); - assert($embeddable->reflClass !== null); - $fieldMapping['columnName'] = $this->namingStrategy - ->embeddedFieldToColumnName( - $property, - $fieldMapping['columnName'], - $this->reflClass->name, - $embeddable->reflClass->name, - ); - } - - $this->mapField($fieldMapping); - } - } - - /** @throws MappingException */ - private function assertFieldNotMapped(string $fieldName): void - { - if ( - isset($this->fieldMappings[$fieldName]) || - isset($this->associationMappings[$fieldName]) || - isset($this->embeddedClasses[$fieldName]) - ) { - throw MappingException::duplicateFieldMapping($this->name, $fieldName); - } - } - - /** - * Gets the sequence name based on class metadata. - * - * @todo Sequence names should be computed in DBAL depending on the platform - */ - public function getSequenceName(AbstractPlatform $platform): string - { - $sequencePrefix = $this->getSequencePrefix($platform); - $columnName = $this->getSingleIdentifierColumnName(); - - return $sequencePrefix . '_' . $columnName . '_seq'; - } - - /** - * Gets the sequence name prefix based on class metadata. - * - * @todo Sequence names should be computed in DBAL depending on the platform - */ - public function getSequencePrefix(AbstractPlatform $platform): string - { - $tableName = $this->getTableName(); - $sequencePrefix = $tableName; - - // Prepend the schema name to the table name if there is one - $schemaName = $this->getSchemaName(); - if ($schemaName) { - $sequencePrefix = $schemaName . '.' . $tableName; - } - - return $sequencePrefix; - } - - /** @psalm-param array $mapping */ - private function assertMappingOrderBy(array $mapping): void - { - if (isset($mapping['orderBy']) && ! is_array($mapping['orderBy'])) { - throw new InvalidArgumentException("'orderBy' is expected to be an array, not " . gettype($mapping['orderBy'])); - } - } - - /** @psalm-param class-string $class */ - private function getAccessibleProperty(ReflectionService $reflService, string $class, string $field): ReflectionProperty|null - { - $reflectionProperty = $reflService->getAccessibleProperty($class, $field); - if ($reflectionProperty?->isReadOnly()) { - $reflectionProperty = new ReflectionReadonlyProperty($reflectionProperty); - } - - return $reflectionProperty; - } -} diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 2ebb7775548..d793439d608 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -31,7 +31,6 @@ use Doctrine\ORM\Internal\CommitOrderCalculator; use Doctrine\ORM\Internal\HydrationCompleteHandler; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\ORM\Persisters\Collection\ManyToManyPersister; @@ -79,7 +78,7 @@ * * Internal note: This class contains highly performance-sensitive code. * - * @psalm-import-type AssociationMapping from ClassMetadataInfo + * @psalm-import-type AssociationMapping from ClassMetadata */ class UnitOfWork implements PropertyChangedListener { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index faf9017a16e..c55b0763731 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -189,7 +189,7 @@ lib/Doctrine/ORM/AbstractQuery.php - lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php + lib/Doctrine/ORM/Mapping/ClassMetadata.php lib/Doctrine/ORM/NativeQuery.php lib/Doctrine/ORM/Query.php lib/Doctrine/ORM/Query/TreeWalkerAdapter.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2b58807bb0f..ef503bb60bf 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -131,14 +131,14 @@ parameters: path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\:\\:fullyQualifiedClassName\\(\\) should return class\\-string\\|null but returns string\\|null\\.$#" + message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\:\\:fullyQualifiedClassName\\(\\) should return class\\-string\\|null but returns string\\|null\\.$#" count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php + path: lib/Doctrine/ORM/Mapping/ClassMetadata.php - message: "#^Negated boolean expression is always false\\.$#" count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php + path: lib/Doctrine/ORM/Mapping/ClassMetadata.php - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d8145c32afd..37326c05958 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -365,7 +365,7 @@ $parent->idGenerator
- + $this->columnNames $this->columnNames diff --git a/psalm.xml b/psalm.xml index db04a6dd84c..f075d151188 100644 --- a/psalm.xml +++ b/psalm.xml @@ -82,7 +82,7 @@ - + @@ -152,7 +152,7 @@ - + diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index ded61a42cde..f706c70b792 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -1585,7 +1585,7 @@ public static function loadMetadata(ClassMetadata $metadata): void ], ); - $metadata->setIdGeneratorType(ORM\ClassMetadataInfo::GENERATOR_TYPE_NONE); + $metadata->setIdGeneratorType(ORM\ClassMetadata::GENERATOR_TYPE_NONE); } } From a86d5a799d76c28a91cb454d4297f540e7ab59b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 Jan 2023 14:21:29 +0100 Subject: [PATCH 213/475] Migrate classes with the fewest changes --- lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php | 3 +-- lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php | 8 +++----- lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php | 7 ++----- lib/Doctrine/ORM/Query/FilterCollection.php | 2 +- lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php | 3 ++- lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php | 7 ++++--- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index d99413a250d..cd77aa532b8 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -537,12 +537,11 @@ protected function registerManaged(ClassMetadata $class, object $entity, array $ } /** - * @param mixed $value * @param class-string $enumType * * @return BackedEnum|array */ - final protected function buildEnum($value, string $enumType) + final protected function buildEnum(mixed $value, string $enumType): BackedEnum|array { if (is_array($value)) { return array_map( diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index 56f654a27e6..86df5209054 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -115,11 +115,9 @@ public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform // Association defined as Id field $joinColumns = $class->associationMappings[$fieldName]['joinColumns']; $assocQuotedColumnNames = array_map( - static function ($joinColumn) use ($platform) { - return isset($joinColumn['quoted']) - ? $platform->quoteIdentifier($joinColumn['name']) - : $joinColumn['name']; - }, + static fn (array $joinColumn) => isset($joinColumn['quoted']) + ? $platform->quoteIdentifier($joinColumn['name']) + : $joinColumn['name'], $joinColumns, ); diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php index c77f2d04ce9..93680eee10f 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php @@ -9,7 +9,6 @@ use ValueError; use function array_map; -use function get_class; use function is_array; final class ReflectionEnumProperty extends ReflectionProperty @@ -55,9 +54,7 @@ public function setValue(mixed $object, mixed $value = null): void { if ($value !== null) { if (is_array($value)) { - $value = array_map(function ($item) use ($object): BackedEnum { - return $this->initializeEnumValue($object, $item); - }, $value); + $value = array_map(fn (int|string|BackedEnum $item): BackedEnum => $this->initializeEnumValue($object, $item), $value); } else { $value = $this->initializeEnumValue($object, $value); } @@ -78,7 +75,7 @@ private function initializeEnumValue(object $object, int|string|BackedEnum $valu return $enumType::from($value); } catch (ValueError $e) { throw MappingException::invalidEnumValue( - get_class($object), + $object::class, $this->originalReflectionProperty->getName(), (string) $value, $enumType, diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/lib/Doctrine/ORM/Query/FilterCollection.php index d08c63532f2..6a3e1295e17 100644 --- a/lib/Doctrine/ORM/Query/FilterCollection.php +++ b/lib/Doctrine/ORM/Query/FilterCollection.php @@ -29,7 +29,7 @@ class FilterCollection */ public const FILTERS_STATE_DIRTY = 2; - private Configuration $config; + private readonly Configuration $config; /** * Instances of enabled filters. diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 6069488b351..073b8ec8639 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Utility\PersisterHelper; use InvalidArgumentException; +use Stringable; use function in_array; use function sprintf; @@ -17,7 +18,7 @@ /** * A ResultSetMappingBuilder uses the EntityManager to automatically populate entity fields. */ -class ResultSetMappingBuilder extends ResultSetMapping +class ResultSetMappingBuilder extends ResultSetMapping implements Stringable { use SQLResultCasing; diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php index 0ee370a0409..50bdf8a14c8 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -146,8 +146,9 @@ private function convertWhereInIdentifiersToDatabaseValue(string $type): void ->getEntityManager() ->getConnection(); - $query->setParameter(self::PAGINATOR_ID_ALIAS, array_map(static function ($id) use ($connection, $type) { - return $connection->convertToDatabaseValue($id, $type); - }, $identifiers)); + $query->setParameter( + self::PAGINATOR_ID_ALIAS, + array_map(static fn (mixed $id): mixed => $connection->convertToDatabaseValue($id, $type), $identifiers), + ); } } From c31344096247a73f63f04202cfb298bc4638a3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 8 Jan 2023 15:04:50 +0100 Subject: [PATCH 214/475] Migrate exceptions to PHP 8 syntax Co-authored-by: Alexander M. Turek Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com> --- lib/Doctrine/ORM/Mapping/MappingException.php | 474 +++--------------- lib/Doctrine/ORM/Query/QueryException.php | 113 +---- lib/Doctrine/ORM/Tools/SchemaTool.php | 2 +- psalm-baseline.xml | 8 - 4 files changed, 97 insertions(+), 500 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index f8ed3d82920..9ecae4c885c 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -26,12 +26,8 @@ */ class MappingException extends Exception implements ORMException { - /** - * @param class-string $entityName - * - * @return MappingException - */ - public static function identifierRequired($entityName) + /** @param class-string $entityName */ + public static function identifierRequired(string $entityName): self { $parent = get_parent_class($entityName); if ($parent !== false) { @@ -48,29 +44,17 @@ public static function identifierRequired($entityName) )); } - /** - * @param string $entityName - * @param int $type - * - * @return MappingException - */ - public static function invalidInheritanceType($entityName, $type) + public static function invalidInheritanceType(string $entityName, int $type): self { return new self(sprintf("The inheritance type '%s' specified for '%s' does not exist.", $type, $entityName)); } - /** @return MappingException */ - public static function generatorNotAllowedWithCompositeId() + public static function generatorNotAllowedWithCompositeId(): self { return new self("Id generators can't be used with a composite id."); } - /** - * @param string $entity - * - * @return MappingException - */ - public static function missingFieldName($entity) + public static function missingFieldName(string $entity): self { return new self(sprintf( "The field or association mapping misses the 'fieldName' attribute in entity '%s'.", @@ -78,43 +62,22 @@ public static function missingFieldName($entity) )); } - /** - * @param string $fieldName - * - * @return MappingException - */ - public static function missingTargetEntity($fieldName) + public static function missingTargetEntity(string $fieldName): self { return new self(sprintf("The association mapping '%s' misses the 'targetEntity' attribute.", $fieldName)); } - /** - * @param string $fieldName - * - * @return MappingException - */ - public static function missingSourceEntity($fieldName) + public static function missingSourceEntity(string $fieldName): self { return new self(sprintf("The association mapping '%s' misses the 'sourceEntity' attribute.", $fieldName)); } - /** - * @param string $fieldName - * - * @return MappingException - */ - public static function missingEmbeddedClass($fieldName) + public static function missingEmbeddedClass(string $fieldName): self { return new self(sprintf("The embed mapping '%s' misses the 'class' attribute.", $fieldName)); } - /** - * @param string $entityName - * @param string $fileName - * - * @return MappingException - */ - public static function mappingFileNotFound($entityName, $fileName) + public static function mappingFileNotFound(string $entityName, string $fileName): self { return new self(sprintf("No mapping file found named '%s' for class '%s'.", $fileName, $entityName)); } @@ -123,11 +86,8 @@ public static function mappingFileNotFound($entityName, $fileName) * Exception for invalid property name override. * * @param string $className The entity's name. - * @param string $fieldName - * - * @return MappingException */ - public static function invalidOverrideFieldName($className, $fieldName) + public static function invalidOverrideFieldName(string $className, string $fieldName): self { return new self(sprintf("Invalid field override named '%s' for class '%s'.", $fieldName, $className)); } @@ -136,11 +96,8 @@ public static function invalidOverrideFieldName($className, $fieldName) * Exception for invalid property type override. * * @param string $className The entity's name. - * @param string $fieldName - * - * @return MappingException */ - public static function invalidOverrideFieldType($className, $fieldName) + public static function invalidOverrideFieldType(string $className, string $fieldName): self { return new self(sprintf( "The column type of attribute '%s' on class '%s' could not be changed.", @@ -149,67 +106,32 @@ public static function invalidOverrideFieldType($className, $fieldName) )); } - /** - * @param string $className - * @param string $fieldName - * - * @return MappingException - */ - public static function mappingNotFound($className, $fieldName) + public static function mappingNotFound(string $className, string $fieldName): self { return new self(sprintf("No mapping found for field '%s' on class '%s'.", $fieldName, $className)); } - /** - * @param string $className - * @param string $queryName - * - * @return MappingException - */ - public static function queryNotFound($className, $queryName) + public static function queryNotFound(string $className, string $queryName): self { return new self(sprintf("No query found named '%s' on class '%s'.", $queryName, $className)); } - /** - * @param string $className - * @param string $resultName - * - * @return MappingException - */ - public static function resultMappingNotFound($className, $resultName) + public static function resultMappingNotFound(string $className, string $resultName): self { return new self(sprintf("No result set mapping found named '%s' on class '%s'.", $resultName, $className)); } - /** - * @param string $entity - * @param string $queryName - * - * @return MappingException - */ - public static function emptyQueryMapping($entity, $queryName) + public static function emptyQueryMapping(string $entity, string $queryName): self { return new self(sprintf('Query named "%s" in "%s" could not be empty.', $queryName, $entity)); } - /** - * @param string $className - * - * @return MappingException - */ - public static function nameIsMandatoryForQueryMapping($className) + public static function nameIsMandatoryForQueryMapping(string $className): self { return new self(sprintf("Query name on entity class '%s' is not defined.", $className)); } - /** - * @param string $entity - * @param string $queryName - * - * @return MappingException - */ - public static function missingQueryMapping($entity, $queryName) + public static function missingQueryMapping(string $entity, string $queryName): self { return new self(sprintf( 'Query named "%s" in "%s requires a result class or result set mapping.', @@ -218,13 +140,7 @@ public static function missingQueryMapping($entity, $queryName) )); } - /** - * @param string $entity - * @param string $resultName - * - * @return MappingException - */ - public static function missingResultSetMappingEntity($entity, $resultName) + public static function missingResultSetMappingEntity(string $entity, string $resultName): self { return new self(sprintf( 'Result set mapping named "%s" in "%s requires a entity class name.', @@ -233,13 +149,7 @@ public static function missingResultSetMappingEntity($entity, $resultName) )); } - /** - * @param string $entity - * @param string $resultName - * - * @return MappingException - */ - public static function missingResultSetMappingFieldName($entity, $resultName) + public static function missingResultSetMappingFieldName(string $entity, string $resultName): self { return new self(sprintf( 'Result set mapping named "%s" in "%s requires a field name.', @@ -257,12 +167,7 @@ public static function oneToManyRequiresMappedBy(string $entityName, string $fie )); } - /** - * @param string $fieldName - * - * @return MappingException - */ - public static function joinTableRequired($fieldName) + public static function joinTableRequired(string $fieldName): self { return new self(sprintf("The mapping of field '%s' requires an the 'joinTable' attribute.", $fieldName)); } @@ -274,10 +179,8 @@ public static function joinTableRequired($fieldName) * @param string $expectedOption Which option is required * @param string $hint Can optionally be used to supply a tip for common mistakes, * e.g. "Did you think of the plural s?" - * - * @return MappingException */ - public static function missingRequiredOption($field, $expectedOption, $hint = '') + public static function missingRequiredOption(string $field, string $expectedOption, string $hint = ''): self { $message = "The mapping of field '" . $field . "' is invalid: The option '" . $expectedOption . "' is required."; @@ -290,12 +193,8 @@ public static function missingRequiredOption($field, $expectedOption, $hint = '' /** * Generic exception for invalid mappings. - * - * @param string $fieldName - * - * @return MappingException */ - public static function invalidMapping($fieldName) + public static function invalidMapping(string $fieldName): self { return new self(sprintf("The mapping of field '%s' is invalid.", $fieldName)); } @@ -306,21 +205,13 @@ public static function invalidMapping($fieldName) * within the stacktrace * * @param string $entity The entity's name - * - * @return MappingException */ - public static function reflectionFailure($entity, ReflectionException $previousException) + public static function reflectionFailure(string $entity, ReflectionException $previousException): self { return new self(sprintf('An error occurred in %s', $entity), 0, $previousException); } - /** - * @param string $className - * @param string $joinColumn - * - * @return MappingException - */ - public static function joinColumnMustPointToMappedField($className, $joinColumn) + public static function joinColumnMustPointToMappedField(string $className, string $joinColumn): self { return new self(sprintf( 'The column %s must be mapped to a field in class %s since it is referenced by a join column of another class.', @@ -329,12 +220,8 @@ public static function joinColumnMustPointToMappedField($className, $joinColumn) )); } - /** - * @param class-string $className - * - * @return MappingException - */ - public static function classIsNotAValidEntityOrMappedSuperClass($className) + /** @param class-string $className */ + public static function classIsNotAValidEntityOrMappedSuperClass(string $className): self { $parent = get_parent_class($className); if ($parent !== false) { @@ -354,10 +241,8 @@ public static function classIsNotAValidEntityOrMappedSuperClass($className) /** * @param string $entity The entity's name. * @param string $fieldName The name of the field that was already declared. - * - * @return MappingException */ - public static function duplicateFieldMapping($entity, $fieldName) + public static function duplicateFieldMapping(string $entity, string $fieldName): self { return new self(sprintf( 'Property "%s" in "%s" was already declared, but it must be declared only once', @@ -366,13 +251,7 @@ public static function duplicateFieldMapping($entity, $fieldName) )); } - /** - * @param string $entity - * @param string $fieldName - * - * @return MappingException - */ - public static function duplicateAssociationMapping($entity, $fieldName) + public static function duplicateAssociationMapping(string $entity, string $fieldName): self { return new self(sprintf( 'Property "%s" in "%s" was already declared, but it must be declared only once', @@ -381,13 +260,7 @@ public static function duplicateAssociationMapping($entity, $fieldName) )); } - /** - * @param string $entity - * @param string $queryName - * - * @return MappingException - */ - public static function duplicateQueryMapping($entity, $queryName) + public static function duplicateQueryMapping(string $entity, string $queryName): self { return new self(sprintf( 'Query named "%s" in "%s" was already declared, but it must be declared only once', @@ -396,13 +269,7 @@ public static function duplicateQueryMapping($entity, $queryName) )); } - /** - * @param string $entity - * @param string $resultName - * - * @return MappingException - */ - public static function duplicateResultSetMapping($entity, $resultName) + public static function duplicateResultSetMapping(string $entity, string $resultName): self { return new self(sprintf( 'Result set mapping named "%s" in "%s" was already declared, but it must be declared only once', @@ -411,34 +278,17 @@ public static function duplicateResultSetMapping($entity, $resultName) )); } - /** - * @param string $entity - * - * @return MappingException - */ - public static function singleIdNotAllowedOnCompositePrimaryKey($entity) + public static function singleIdNotAllowedOnCompositePrimaryKey(string $entity): self { return new self('Single id is not allowed on composite primary key in entity ' . $entity); } - /** - * @param string $entity - * - * @return MappingException - */ - public static function noIdDefined($entity) + public static function noIdDefined(string $entity): self { return new self('No ID defined for entity ' . $entity); } - /** - * @param string $entity - * @param string $fieldName - * @param string $unsupportedType - * - * @return MappingException - */ - public static function unsupportedOptimisticLockingType($entity, $fieldName, $unsupportedType) + public static function unsupportedOptimisticLockingType(string $entity, string $fieldName, string $unsupportedType): self { return new self(sprintf( 'Locking type "%s" (specified in "%s", field "%s") is not supported by Doctrine.', @@ -448,12 +298,7 @@ public static function unsupportedOptimisticLockingType($entity, $fieldName, $un )); } - /** - * @param string|null $path - * - * @return MappingException - */ - public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null) + public static function fileMappingDriversRequireConfiguredDirectoryPath(string|null $path = null): self { if (! empty($path)) { $path = '[' . $path . ']'; @@ -471,10 +316,8 @@ public static function fileMappingDriversRequireConfiguredDirectoryPath($path = * * @param string $className The class that could not be found * @param string $owningClass The class that declares the discriminator map. - * - * @return MappingException */ - public static function invalidClassInDiscriminatorMap($className, $owningClass) + public static function invalidClassInDiscriminatorMap(string $className, string $owningClass): self { return new self(sprintf( "Entity class '%s' used in the discriminator map of class '%s' " . @@ -485,33 +328,23 @@ public static function invalidClassInDiscriminatorMap($className, $owningClass) } /** - * @param string $className * @param string[] $entries * @param array $map - * - * @return MappingException */ - public static function duplicateDiscriminatorEntry($className, array $entries, array $map) + public static function duplicateDiscriminatorEntry(string $className, array $entries, array $map): self { return new self( 'The entries ' . implode(', ', $entries) . " in discriminator map of class '" . $className . "' is duplicated. " . 'If the discriminator map is automatically generated you have to convert it to an explicit discriminator map now. ' . 'The entries of the current map are: @DiscriminatorMap({' . implode(', ', array_map( - static function ($a, $b) { - return sprintf("'%s': '%s'", $a, $b); - }, + static fn ($a, $b) => sprintf("'%s': '%s'", $a, $b), array_keys($map), array_values($map), )) . '})', ); } - /** - * @param string $className - * - * @return MappingException - */ - public static function missingDiscriminatorMap($className) + public static function missingDiscriminatorMap(string $className): self { return new self(sprintf( "Entity class '%s' is using inheritance but no discriminator map was defined.", @@ -519,12 +352,7 @@ public static function missingDiscriminatorMap($className) )); } - /** - * @param string $className - * - * @return MappingException - */ - public static function missingDiscriminatorColumn($className) + public static function missingDiscriminatorColumn(string $className): self { return new self(sprintf( "Entity class '%s' is using inheritance but no discriminator column was defined.", @@ -532,13 +360,7 @@ public static function missingDiscriminatorColumn($className) )); } - /** - * @param string $className - * @param string $type - * - * @return MappingException - */ - public static function invalidDiscriminatorColumnType($className, $type) + public static function invalidDiscriminatorColumnType(string $className, string $type): self { return new self(sprintf( "Discriminator column type on entity class '%s' is not allowed to be '%s'. 'string' or 'integer' type variables are suggested!", @@ -547,23 +369,12 @@ public static function invalidDiscriminatorColumnType($className, $type) )); } - /** - * @param string $className - * - * @return MappingException - */ - public static function nameIsMandatoryForDiscriminatorColumns($className) + public static function nameIsMandatoryForDiscriminatorColumns(string $className): self { return new self(sprintf("Discriminator column name on entity class '%s' is not defined.", $className)); } - /** - * @param string $className - * @param string $fieldName - * - * @return MappingException - */ - public static function cannotVersionIdField($className, $fieldName) + public static function cannotVersionIdField(string $className, string $fieldName): self { return new self(sprintf( "Setting Id field '%s' as versionable in entity class '%s' is not supported.", @@ -572,59 +383,28 @@ public static function cannotVersionIdField($className, $fieldName) )); } - /** - * @param string $className - * @param string $columnName - * - * @return MappingException - */ - public static function duplicateColumnName($className, $columnName) + public static function duplicateColumnName(string $className, string $columnName): self { return new self("Duplicate definition of column '" . $columnName . "' on entity '" . $className . "' in a field or discriminator column mapping."); } - /** - * @param string $className - * @param string $field - * - * @return MappingException - */ - public static function illegalToManyAssociationOnMappedSuperclass($className, $field) + public static function illegalToManyAssociationOnMappedSuperclass(string $className, string $field): self { return new self("It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass '" . $className . '#' . $field . "'."); } - /** - * @param string $className - * @param string $targetEntity - * @param string $targetField - * - * @return MappingException - */ - public static function cannotMapCompositePrimaryKeyEntitiesAsForeignId($className, $targetEntity, $targetField) + public static function cannotMapCompositePrimaryKeyEntitiesAsForeignId(string $className, string $targetEntity, string $targetField): self { return new self("It is not possible to map entity '" . $className . "' with a composite primary key " . "as part of the primary key of another entity '" . $targetEntity . '#' . $targetField . "'."); } - /** - * @param string $className - * @param string $field - * - * @return MappingException - */ - public static function noSingleAssociationJoinColumnFound($className, $field) + public static function noSingleAssociationJoinColumnFound(string $className, string $field): self { return new self(sprintf("'%s#%s' is not an association with a single join column.", $className, $field)); } - /** - * @param string $className - * @param string $column - * - * @return MappingException - */ - public static function noFieldNameFoundForColumn($className, $column) + public static function noFieldNameFoundForColumn(string $className, string $column): self { return new self(sprintf( "Cannot find a field on '%s' that is mapped to column '%s'. Either the " . @@ -634,13 +414,7 @@ public static function noFieldNameFoundForColumn($className, $column) )); } - /** - * @param string $className - * @param string $field - * - * @return MappingException - */ - public static function illegalOrphanRemovalOnIdentifierAssociation($className, $field) + public static function illegalOrphanRemovalOnIdentifierAssociation(string $className, string $field): self { return new self(sprintf( "The orphan removal option is not allowed on an association that is part of the identifier in '%s#%s'.", @@ -649,25 +423,13 @@ public static function illegalOrphanRemovalOnIdentifierAssociation($className, $ )); } - /** - * @param string $className - * @param string $field - * - * @return MappingException - */ - public static function illegalOrphanRemoval($className, $field) + public static function illegalOrphanRemoval(string $className, string $field): self { return new self('Orphan removal is only allowed on one-to-one and one-to-many ' . 'associations, but ' . $className . '#' . $field . ' is not.'); } - /** - * @param string $className - * @param string $field - * - * @return MappingException - */ - public static function illegalInverseIdentifierAssociation($className, $field) + public static function illegalInverseIdentifierAssociation(string $className, string $field): self { return new self(sprintf( "An inverse association is not allowed to be identifier in '%s#%s'.", @@ -676,13 +438,7 @@ public static function illegalInverseIdentifierAssociation($className, $field) )); } - /** - * @param string $className - * @param string $field - * - * @return MappingException - */ - public static function illegalToManyIdentifierAssociation($className, $field) + public static function illegalToManyIdentifierAssociation(string $className, string $field): self { return new self(sprintf( "Many-to-many or one-to-many associations are not allowed to be identifier in '%s#%s'.", @@ -691,23 +447,12 @@ public static function illegalToManyIdentifierAssociation($className, $field) )); } - /** - * @param string $className - * - * @return MappingException - */ - public static function noInheritanceOnMappedSuperClass($className) + public static function noInheritanceOnMappedSuperClass(string $className): self { return new self("It is not supported to define inheritance information on a mapped superclass '" . $className . "'."); } - /** - * @param string $className - * @param string $rootClassName - * - * @return MappingException - */ - public static function mappedClassNotPartOfDiscriminatorMap($className, $rootClassName) + public static function mappedClassNotPartOfDiscriminatorMap(string $className, string $rootClassName): self { return new self( "Entity '" . $className . "' has to be part of the discriminator map of '" . $rootClassName . "' " . @@ -716,48 +461,22 @@ public static function mappedClassNotPartOfDiscriminatorMap($className, $rootCla ); } - /** - * @param string $className - * @param string $methodName - * - * @return MappingException - */ - public static function lifecycleCallbackMethodNotFound($className, $methodName) + public static function lifecycleCallbackMethodNotFound(string $className, string $methodName): self { return new self("Entity '" . $className . "' has no method '" . $methodName . "' to be registered as lifecycle callback."); } - /** - * @param string $listenerName - * @param string $className - * - * @return MappingException - */ - public static function entityListenerClassNotFound($listenerName, $className) + public static function entityListenerClassNotFound(string $listenerName, string $className): self { return new self(sprintf('Entity Listener "%s" declared on "%s" not found.', $listenerName, $className)); } - /** - * @param string $listenerName - * @param string $methodName - * @param string $className - * - * @return MappingException - */ - public static function entityListenerMethodNotFound($listenerName, $methodName, $className) + public static function entityListenerMethodNotFound(string $listenerName, string $methodName, string $className): self { return new self(sprintf('Entity Listener "%s" declared on "%s" has no method "%s".', $listenerName, $className, $methodName)); } - /** - * @param string $listenerName - * @param string $methodName - * @param string $className - * - * @return MappingException - */ - public static function duplicateEntityListener($listenerName, $methodName, $className) + public static function duplicateEntityListener(string $listenerName, string $methodName, string $className): self { return new self(sprintf('Entity Listener "%s#%s()" in "%s" was already declared, but it must be declared only once.', $listenerName, $methodName, $className)); } @@ -768,46 +487,25 @@ public static function invalidFetchMode(string $className, string $fetchMode): s return new self("Entity '" . $className . "' has a mapping with invalid fetch mode '" . $fetchMode . "'"); } - /** @param int|string $generatedMode */ - public static function invalidGeneratedMode($generatedMode): self + public static function invalidGeneratedMode(int|string $generatedMode): self { return new self("Invalid generated mode '" . $generatedMode . "'"); } - /** - * @param string $className - * - * @return MappingException - */ - public static function compositeKeyAssignedIdGeneratorRequired($className) + public static function compositeKeyAssignedIdGeneratorRequired(string $className): self { return new self("Entity '" . $className . "' has a composite identifier but uses an ID generator other than manually assigning (Identity, Sequence). This is not supported."); } - /** - * @param string $targetEntity - * @param string $sourceEntity - * @param string $associationName - * - * @return MappingException - */ - public static function invalidTargetEntityClass($targetEntity, $sourceEntity, $associationName) + public static function invalidTargetEntityClass(string $targetEntity, string $sourceEntity, string $associationName): self { return new self('The target-entity ' . $targetEntity . " cannot be found in '" . $sourceEntity . '#' . $associationName . "'."); } - /** - * @param string[] $cascades - * @param string $className - * @param string $propertyName - * - * @return MappingException - */ - public static function invalidCascadeOption(array $cascades, $className, $propertyName) + /** @param string[] $cascades */ + public static function invalidCascadeOption(array $cascades, string $className, string $propertyName): self { - $cascades = implode(', ', array_map(static function ($e) { - return "'" . $e . "'"; - }, $cascades)); + $cascades = implode(', ', array_map(static fn (string $e): string => "'" . $e . "'", $cascades)); return new self(sprintf( "You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'", @@ -817,25 +515,14 @@ public static function invalidCascadeOption(array $cascades, $className, $proper )); } - /** - * @param string $className - * - * @return MappingException - */ - public static function missingSequenceName($className) + public static function missingSequenceName(string $className): self { return new self( sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className), ); } - /** - * @param string $className - * @param string $propertyName - * - * @return MappingException - */ - public static function infiniteEmbeddableNesting($className, $propertyName) + public static function infiniteEmbeddableNesting(string $className, string $propertyName): self { return new self( sprintf( @@ -847,13 +534,7 @@ public static function infiniteEmbeddableNesting($className, $propertyName) ); } - /** - * @param string $className - * @param string $propertyName - * - * @return self - */ - public static function illegalOverrideOfInheritedProperty($className, $propertyName) + public static function illegalOverrideOfInheritedProperty(string $className, string $propertyName): self { return new self( sprintf( @@ -865,8 +546,7 @@ public static function illegalOverrideOfInheritedProperty($className, $propertyN ); } - /** @return self */ - public static function invalidIndexConfiguration($className, $indexName) + public static function invalidIndexConfiguration(string $className, string $indexName): self { return new self( sprintf( @@ -877,8 +557,7 @@ public static function invalidIndexConfiguration($className, $indexName) ); } - /** @return self */ - public static function invalidUniqueConstraintConfiguration($className, $indexName) + public static function invalidUniqueConstraintConfiguration(string $className, string $indexName): self { return new self( sprintf( @@ -889,8 +568,7 @@ public static function invalidUniqueConstraintConfiguration($className, $indexNa ); } - /** @param mixed $givenValue */ - public static function invalidOverrideType(string $expectdType, $givenValue): self + public static function invalidOverrideType(string $expectdType, mixed $givenValue): self { return new self(sprintf( 'Expected %s, but %s was given.', @@ -937,14 +615,12 @@ public static function invalidEnumValue( /** @param LibXMLError[] $errors */ public static function fromLibXmlErrors(array $errors): self { - $formatter = static function (LibXMLError $error): string { - return sprintf( - 'libxml error: %s in %s at line %d', - $error->message, - $error->file, - $error->line, - ); - }; + $formatter = static fn (LibXMLError $error): string => sprintf( + 'libxml error: %s in %s at line %d', + $error->message, + $error->file, + $error->line, + ); return new self(implode(PHP_EOL, array_map($formatter, $errors))); } diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index d1140931c59..98dc6e52c85 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -8,112 +8,61 @@ use Doctrine\ORM\Query\AST\PathExpression; use Exception; use Stringable; +use Throwable; class QueryException extends Exception implements ORMException { - /** - * @param string $dql - * - * @return QueryException - */ - public static function dqlError($dql) + public static function dqlError(string $dql): self { return new self($dql); } - /** - * @param string $message - * @param Exception|null $previous - * - * @return QueryException - */ - public static function syntaxError($message, $previous = null) + public static function syntaxError(string $message, Throwable|null $previous = null): self { return new self('[Syntax Error] ' . $message, 0, $previous); } - /** - * @param string $message - * @param Exception|null $previous - * - * @return QueryException - */ - public static function semanticalError($message, $previous = null) + public static function semanticalError(string $message, Throwable|null $previous = null): self { return new self('[Semantical Error] ' . $message, 0, $previous); } - /** @return QueryException */ - public static function invalidLockMode() + public static function invalidLockMode(): self { return new self('Invalid lock mode hint provided.'); } - /** - * @param string $expected - * @param string $received - * - * @return QueryException - */ - public static function invalidParameterType($expected, $received) + public static function invalidParameterType(string $expected, string $received): self { return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.'); } - /** - * @param string $pos - * - * @return QueryException - */ - public static function invalidParameterPosition($pos) + public static function invalidParameterPosition(string $pos): self { return new self('Invalid parameter position: ' . $pos); } - /** - * @param int $expected - * @param int $received - * - * @return QueryException - */ - public static function tooManyParameters($expected, $received) + public static function tooManyParameters(int $expected, int $received): self { return new self('Too many parameters: the query defines ' . $expected . ' parameters and you bound ' . $received); } - /** - * @param int $expected - * @param int $received - * - * @return QueryException - */ - public static function tooFewParameters($expected, $received) + public static function tooFewParameters(int $expected, int $received): self { return new self('Too few parameters: the query defines ' . $expected . ' parameters but you only bound ' . $received); } - /** - * @param string $value - * - * @return QueryException - */ - public static function invalidParameterFormat($value) + public static function invalidParameterFormat(string $value): self { return new self('Invalid parameter format, ' . $value . ' given, but : or ? expected.'); } - /** - * @param string $key - * - * @return QueryException - */ - public static function unknownParameter($key) + public static function unknownParameter(string $key): self { return new self('Invalid parameter: token ' . $key . ' is not defined in the query.'); } - /** @return QueryException */ - public static function parameterTypeMismatch() + public static function parameterTypeMismatch(): self { return new self('DQL Query parameter and type numbers mismatch, but have to be exactly equal.'); } @@ -133,10 +82,8 @@ public static function invalidLiteral(string|Stringable $literal): self /** * @param string[] $assoc * @psalm-param array $assoc - * - * @return QueryException */ - public static function iterateWithFetchJoinCollectionNotAllowed($assoc) + public static function iterateWithFetchJoinCollectionNotAllowed(array $assoc): self { return new self( 'Invalid query operation: Not allowed to iterate over fetch join collections ' . @@ -144,8 +91,7 @@ public static function iterateWithFetchJoinCollectionNotAllowed($assoc) ); } - /** @return QueryException */ - public static function partialObjectsAreDangerous() + public static function partialObjectsAreDangerous(): self { return new self( 'Loading partial objects is dangerous. Fetch full objects or consider ' . @@ -157,10 +103,8 @@ public static function partialObjectsAreDangerous() /** * @param string[] $assoc * @psalm-param array $assoc - * - * @return QueryException */ - public static function overwritingJoinConditionsNotYetSupported($assoc) + public static function overwritingJoinConditionsNotYetSupported(array $assoc): self { return new self( 'Unsupported query operation: It is not yet possible to overwrite the join ' . @@ -169,8 +113,7 @@ public static function overwritingJoinConditionsNotYetSupported($assoc) ); } - /** @return QueryException */ - public static function associationPathInverseSideNotSupported(PathExpression $pathExpr) + public static function associationPathInverseSideNotSupported(PathExpression $pathExpr): self { return new self( 'A single-valued association path expression to an inverse side is not supported in DQL queries. ' . @@ -181,10 +124,8 @@ public static function associationPathInverseSideNotSupported(PathExpression $pa /** * @param string[] $assoc * @psalm-param array $assoc - * - * @return QueryException */ - public static function iterateWithFetchJoinNotAllowed($assoc) + public static function iterateWithFetchJoinNotAllowed(array $assoc): self { return new self( 'Iterate with fetch join in class ' . $assoc['sourceEntity'] . @@ -192,13 +133,12 @@ public static function iterateWithFetchJoinNotAllowed($assoc) ); } - public static function iterateWithMixedResultNotAllowed(): QueryException + public static function iterateWithMixedResultNotAllowed(): self { return new self('Iterating a query with mixed results (using scalars) is not supported.'); } - /** @return QueryException */ - public static function associationPathCompositeKeyNotSupported() + public static function associationPathCompositeKeyNotSupported(): self { return new self( 'A single-valued association path expression to an entity with a composite primary ' . @@ -207,24 +147,13 @@ public static function associationPathCompositeKeyNotSupported() ); } - /** - * @param string $className - * @param string $rootClass - * - * @return QueryException - */ - public static function instanceOfUnrelatedClass($className, $rootClass) + public static function instanceOfUnrelatedClass(string $className, string $rootClass): self { return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " . 'inheritance hierarchy does not exists between these two classes.'); } - /** - * @param string $dqlAlias - * - * @return QueryException - */ - public static function invalidQueryComponent($dqlAlias) + public static function invalidQueryComponent(string $dqlAlias): self { return new self( "Invalid query component given for DQL alias '" . $dqlAlias . "', " . diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 2733dc0e97d..cbcd6c74fa8 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -136,7 +136,7 @@ private function getIndexColumns(ClassMetadata $class, array $indexData): array ) ) { throw MappingException::invalidIndexConfiguration( - $class, + (string) $class, $indexData['name'] ?? 'unnamed', ); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index de2880487bf..21d535dc458 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -623,14 +623,6 @@ $xmlRoot->getName() === 'mapped-superclass' - - - $className - $className - $indexName - $indexName - - $object From 7a08253f18c50e937e4f9a2e44bc121933d48c56 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 18 Jan 2023 16:13:26 +0100 Subject: [PATCH 215/475] Remove "table per class" inheritance that was never actually implemented (#10414) --- docs/en/reference/php-mapping.rst | 1 - doctrine-mapping.xsd | 1 - lib/Doctrine/ORM/Mapping/ClassMetadata.php | 20 +------------------- lib/Doctrine/ORM/Mapping/InheritanceType.php | 2 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 2 -- 5 files changed, 2 insertions(+), 24 deletions(-) diff --git a/docs/en/reference/php-mapping.rst b/docs/en/reference/php-mapping.rst index 5b5dbe5339f..4665aaf707b 100644 --- a/docs/en/reference/php-mapping.rst +++ b/docs/en/reference/php-mapping.rst @@ -194,7 +194,6 @@ Inheritance Getters - ``isInheritanceTypeNone()`` - ``isInheritanceTypeJoined()`` - ``isInheritanceTypeSingleTable()`` -- ``isInheritanceTypeTablePerClass()`` - ``isInheritedField($fieldName)`` - ``isInheritedAssociation($fieldName)`` diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index 946b85072f0..a72530877aa 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -206,7 +206,6 @@ - diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index e64d54e1ace..afda64f79a7 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -167,12 +167,6 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable */ public const INHERITANCE_TYPE_SINGLE_TABLE = 3; - /** - * TABLE_PER_CLASS means the class will be persisted according to the rules - * of Concrete Table Inheritance. - */ - public const INHERITANCE_TYPE_TABLE_PER_CLASS = 4; - /* The Id generator types. */ /** * AUTO means the generator type will depend on what the used platform prefers. @@ -2040,17 +2034,6 @@ public function isInheritanceTypeSingleTable(): bool return $this->inheritanceType === self::INHERITANCE_TYPE_SINGLE_TABLE; } - /** - * Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy. - * - * @return bool TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, - * FALSE otherwise. - */ - public function isInheritanceTypeTablePerClass(): bool - { - return $this->inheritanceType === self::INHERITANCE_TYPE_TABLE_PER_CLASS; - } - /** * Checks whether the class uses an identity column for the Id generation. */ @@ -2361,8 +2344,7 @@ private function isInheritanceType(int $type): bool { return $type === self::INHERITANCE_TYPE_NONE || $type === self::INHERITANCE_TYPE_SINGLE_TABLE || - $type === self::INHERITANCE_TYPE_JOINED || - $type === self::INHERITANCE_TYPE_TABLE_PER_CLASS; + $type === self::INHERITANCE_TYPE_JOINED; } /** diff --git a/lib/Doctrine/ORM/Mapping/InheritanceType.php b/lib/Doctrine/ORM/Mapping/InheritanceType.php index 02b44acdaa3..c042ee79b6f 100644 --- a/lib/Doctrine/ORM/Mapping/InheritanceType.php +++ b/lib/Doctrine/ORM/Mapping/InheritanceType.php @@ -9,7 +9,7 @@ #[Attribute(Attribute::TARGET_CLASS)] final class InheritanceType implements MappingAttribute { - /** @psalm-param 'NONE'|'JOINED'|'SINGLE_TABLE'|'TABLE_PER_CLASS' $value */ + /** @psalm-param 'NONE'|'JOINED'|'SINGLE_TABLE' $value */ public function __construct( public readonly string $value, ) { diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index cbcd6c74fa8..ceec19a6db2 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -283,8 +283,6 @@ public function getSchemaFromMetadata(array $classes): Schema $table->setPrimaryKey($pkColumns); } } - } elseif ($class->isInheritanceTypeTablePerClass()) { - throw NotSupported::create(); } else { $this->gatherColumns($class, $table); $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks); From 4c1e520bd3c72bca5728eaaefaaca2bc87bdb85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 18 Jan 2023 17:11:42 +0100 Subject: [PATCH 216/475] Migrate remaining exceptions to PHP 8 syntax (#10402) --- .../ORM/ORMInvalidArgumentException.php | 113 +++--------------- lib/Doctrine/ORM/OptimisticLockException.php | 44 +++---- 2 files changed, 33 insertions(+), 124 deletions(-) diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index db20c3d994a..aa98cad1e39 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -24,43 +24,22 @@ */ class ORMInvalidArgumentException extends InvalidArgumentException { - /** - * @param object $entity - * - * @return ORMInvalidArgumentException - */ - public static function scheduleInsertForManagedEntity($entity) + public static function scheduleInsertForManagedEntity(object $entity): self { return new self('A managed+dirty entity ' . self::objToStr($entity) . ' can not be scheduled for insertion.'); } - /** - * @param object $entity - * - * @return ORMInvalidArgumentException - */ - public static function scheduleInsertForRemovedEntity($entity) + public static function scheduleInsertForRemovedEntity(object $entity): self { return new self('Removed entity ' . self::objToStr($entity) . ' can not be scheduled for insertion.'); } - /** - * @param object $entity - * - * @return ORMInvalidArgumentException - */ - public static function scheduleInsertTwice($entity) + public static function scheduleInsertTwice(object $entity): self { return new self('Entity ' . self::objToStr($entity) . ' can not be scheduled for insertion twice.'); } - /** - * @param string $className - * @param object $entity - * - * @return ORMInvalidArgumentException - */ - public static function entityWithoutIdentity($className, $entity) + public static function entityWithoutIdentity(string $className, object $entity): self { return new self( "The given entity of type '" . $className . "' (" . self::objToStr($entity) . ') has no identity/no ' . @@ -68,12 +47,7 @@ public static function entityWithoutIdentity($className, $entity) ); } - /** - * @param object $entity - * - * @return ORMInvalidArgumentException - */ - public static function readOnlyRequiresManagedEntity($entity) + public static function readOnlyRequiresManagedEntity(object $entity): self { return new self('Only managed entities can be marked or checked as read only. But ' . self::objToStr($entity) . ' is not'); } @@ -81,10 +55,8 @@ public static function readOnlyRequiresManagedEntity($entity) /** * @param array[][]|object[][] $newEntitiesWithAssociations non-empty an array * of [array $associationMapping, object $entity] pairs - * - * @return ORMInvalidArgumentException */ - public static function newEntitiesFoundThroughRelationships($newEntitiesWithAssociations) + public static function newEntitiesFoundThroughRelationships(array $newEntitiesWithAssociations): self { $errorMessages = array_map( static function (array $newEntityWithAssociation): string { @@ -106,96 +78,54 @@ static function (array $newEntityWithAssociation): string { ); } - /** - * @param object $entry - * @psalm-param AssociationMapping $associationMapping - * - * @return ORMInvalidArgumentException - */ - public static function newEntityFoundThroughRelationship(array $associationMapping, $entry) + /** @psalm-param AssociationMapping $associationMapping */ + public static function newEntityFoundThroughRelationship(array $associationMapping, object $entry): self { return new self(self::newEntityFoundThroughRelationshipMessage($associationMapping, $entry)); } - /** - * @param object $entry - * @psalm-param array $assoc - * - * @return ORMInvalidArgumentException - */ - public static function detachedEntityFoundThroughRelationship(array $assoc, $entry) + /** @psalm-param array $assoc */ + public static function detachedEntityFoundThroughRelationship(array $assoc, object $entry): self { return new self('A detached entity of type ' . $assoc['targetEntity'] . ' (' . self::objToStr($entry) . ') ' . " was found through the relationship '" . $assoc['sourceEntity'] . '#' . $assoc['fieldName'] . "' " . 'during cascading a persist operation.'); } - /** - * @param object $entity - * - * @return ORMInvalidArgumentException - */ - public static function entityNotManaged($entity) + public static function entityNotManaged(object $entity): self { return new self('Entity ' . self::objToStr($entity) . ' is not managed. An entity is managed if its fetched ' . 'from the database or registered as new through EntityManager#persist'); } - /** - * @param object $entity - * @param string $operation - * - * @return ORMInvalidArgumentException - */ - public static function entityHasNoIdentity($entity, $operation) + public static function entityHasNoIdentity(object $entity, string $operation): self { return new self('Entity has no identity, therefore ' . $operation . ' cannot be performed. ' . self::objToStr($entity)); } - /** - * @param object $entity - * @param string $operation - * - * @return ORMInvalidArgumentException - */ - public static function entityIsRemoved($entity, $operation) + public static function entityIsRemoved(object $entity, string $operation): self { return new self('Entity is removed, therefore ' . $operation . ' cannot be performed. ' . self::objToStr($entity)); } - /** - * @param object $entity - * @param string $operation - * - * @return ORMInvalidArgumentException - */ - public static function detachedEntityCannot($entity, $operation) + public static function detachedEntityCannot(object $entity, string $operation): self { return new self('Detached entity ' . self::objToStr($entity) . ' cannot be ' . $operation); } - /** - * @param string $context - * @param mixed $given - * @param int $parameterIndex - * - * @return ORMInvalidArgumentException - */ - public static function invalidObject($context, $given, $parameterIndex = 1) + public static function invalidObject(string $context, mixed $given, int $parameterIndex = 1): self { return new self($context . ' expects parameter ' . $parameterIndex . ' to be an entity object, ' . gettype($given) . ' given.'); } - /** @return ORMInvalidArgumentException */ - public static function invalidCompositeIdentifier() + public static function invalidCompositeIdentifier(): self { return new self('Binding an entity with a composite primary key to a query is not supported. ' . 'You should split the parameter into the explicit fields and bind them separately.'); } - /** @return ORMInvalidArgumentException */ - public static function invalidIdentifierBindingEntity(string $class) + public static function invalidIdentifierBindingEntity(string $class): self { return new self(sprintf( <<<'EXCEPTION' @@ -207,13 +137,8 @@ public static function invalidIdentifierBindingEntity(string $class) )); } - /** - * @param mixed[] $assoc - * @param mixed $actualValue - * - * @return self - */ - public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $actualValue) + /** @param mixed[] $assoc */ + public static function invalidAssociation(ClassMetadata $targetClass, array $assoc, mixed $actualValue): self { $expectedType = $targetClass->getName(); diff --git a/lib/Doctrine/ORM/OptimisticLockException.php b/lib/Doctrine/ORM/OptimisticLockException.php index 527990fa954..63bff462d60 100644 --- a/lib/Doctrine/ORM/OptimisticLockException.php +++ b/lib/Doctrine/ORM/OptimisticLockException.php @@ -15,56 +15,40 @@ */ class OptimisticLockException extends Exception implements ORMException { - /** - * @param string $msg - * @param object|string|null $entity - */ - public function __construct($msg, private $entity, Throwable|null $previous = null) - { + public function __construct( + string $msg, + private object|string|null $entity, + Throwable|null $previous = null, + ) { parent::__construct($msg, 0, $previous); } /** * Gets the entity that caused the exception. - * - * @return object|string|null */ - public function getEntity() + public function getEntity(): object|string|null { return $this->entity; } - /** - * @param object|class-string $entity - * - * @return OptimisticLockException - */ - public static function lockFailed($entity) + /** @param object|class-string $entity */ + public static function lockFailed(object|string $entity): self { return new self('The optimistic lock on an entity failed.', $entity); } - /** - * @param object $entity - * @param int|string|DateTimeInterface $expectedLockVersion - * @param int|string|DateTimeInterface $actualLockVersion - * - * @return OptimisticLockException - */ - public static function lockFailedVersionMismatch($entity, $expectedLockVersion, $actualLockVersion) - { + public static function lockFailedVersionMismatch( + object $entity, + int|string|DateTimeInterface $expectedLockVersion, + int|string|DateTimeInterface $actualLockVersion, + ): self { $expectedLockVersion = $expectedLockVersion instanceof DateTimeInterface ? $expectedLockVersion->getTimestamp() : $expectedLockVersion; $actualLockVersion = $actualLockVersion instanceof DateTimeInterface ? $actualLockVersion->getTimestamp() : $actualLockVersion; return new self('The optimistic lock failed, version ' . $expectedLockVersion . ' was expected, but is actually ' . $actualLockVersion, $entity); } - /** - * @param string $entityName - * - * @return OptimisticLockException - */ - public static function notVersioned($entityName) + public static function notVersioned(string $entityName): self { return new self('Cannot obtain optimistic lock on unversioned entity ' . $entityName, null); } From 4357161c3d7312087e2df0df493f81bbaea47734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 21 Jan 2023 12:37:03 +0100 Subject: [PATCH 217/475] Migrate entity manager to PHP 8 syntax --- lib/Doctrine/ORM/EntityManager.php | 31 ++++++++++++------------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index ef80a6b4811..8e74bad83f1 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -61,40 +61,30 @@ */ class EntityManager implements EntityManagerInterface { - /** - * The used Configuration. - */ - private Configuration $config; - - /** - * The database connection used by the EntityManager. - */ - private Connection $conn; - /** * The metadata factory, used to retrieve the ORM metadata of entity classes. */ - private ClassMetadataFactory $metadataFactory; + private readonly ClassMetadataFactory $metadataFactory; /** * The UnitOfWork used to coordinate object-level transactions. */ - private UnitOfWork $unitOfWork; + private readonly UnitOfWork $unitOfWork; /** * The event manager that is the central point of the event system. */ - private EventManager $eventManager; + private readonly EventManager $eventManager; /** * The proxy factory used to create dynamic proxies. */ - private ProxyFactory $proxyFactory; + private readonly ProxyFactory $proxyFactory; /** * The repository factory used to create dynamic repositories. */ - private RepositoryFactory $repositoryFactory; + private readonly RepositoryFactory $repositoryFactory; /** * The expression builder instance used to generate query expressions. @@ -119,15 +109,18 @@ class EntityManager implements EntityManagerInterface /** * Creates a new EntityManager that operates on the given database connection * and uses the given Configuration and EventManager implementations. + * + * @param Connection $conn The database connection used by the EntityManager. */ - public function __construct(Connection $conn, Configuration $config, EventManager|null $eventManager = null) - { + public function __construct( + private readonly Connection $conn, + private readonly Configuration $config, + EventManager|null $eventManager = null, + ) { if (! $config->getMetadataDriverImpl()) { throw MissingMappingDriverImplementation::create(); } - $this->conn = $conn; - $this->config = $config; $this->eventManager = $eventManager ?? (method_exists($conn, 'getEventManager') ? $conn->getEventManager() From 3d1f17278882f54e16e9fb9018906469aa8dd161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 23 Jan 2023 22:06:54 +0100 Subject: [PATCH 218/475] Migrate ParserResult to PHP 8 syntax --- lib/Doctrine/ORM/Query/ParserResult.php | 47 ++++++++----------- psalm-baseline.xml | 5 -- .../Tests/ORM/Query/ParserResultTest.php | 13 ++++- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/lib/Doctrine/ORM/Query/ParserResult.php b/lib/Doctrine/ORM/Query/ParserResult.php index fc513e438d2..ad0c1c1f7b3 100644 --- a/lib/Doctrine/ORM/Query/ParserResult.php +++ b/lib/Doctrine/ORM/Query/ParserResult.php @@ -5,6 +5,9 @@ namespace Doctrine\ORM\Query; use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; +use LogicException; + +use function sprintf; /** * Encapsulates the resulting components from a DQL query parsing process that @@ -16,24 +19,20 @@ class ParserResult { /** * The SQL executor used for executing the SQL. - * - * @var AbstractSqlExecutor */ - private $_sqlExecutor; + private AbstractSqlExecutor|null $_sqlExecutor = null; /** * The ResultSetMapping that describes how to map the SQL result set. - * - * @var ResultSetMapping */ - private $_resultSetMapping; + private ResultSetMapping $_resultSetMapping; /** * The mappings of DQL parameter names/positions to SQL parameter positions. * * @psalm-var array> */ - private $_parameterMappings = []; + private array $_parameterMappings = []; /** * Initializes a new instance of the ParserResult class. @@ -49,53 +48,47 @@ public function __construct() * * @return ResultSetMapping The result set mapping of the parsed query */ - public function getResultSetMapping() + public function getResultSetMapping(): ResultSetMapping { return $this->_resultSetMapping; } /** * Sets the ResultSetMapping of the parsed query. - * - * @return void */ - public function setResultSetMapping(ResultSetMapping $rsm) + public function setResultSetMapping(ResultSetMapping $rsm): void { $this->_resultSetMapping = $rsm; } /** * Sets the SQL executor that should be used for this ParserResult. - * - * @param AbstractSqlExecutor $executor - * - * @return void */ - public function setSqlExecutor($executor) + public function setSqlExecutor(AbstractSqlExecutor $executor): void { $this->_sqlExecutor = $executor; } /** * Gets the SQL executor used by this ParserResult. - * - * @return AbstractSqlExecutor */ - public function getSqlExecutor() + public function getSqlExecutor(): AbstractSqlExecutor { + if ($this->_sqlExecutor === null) { + throw new LogicException(sprintf( + 'Executor not set yet. Call %s::setSqlExecutor() first.', + self::class, + )); + } + return $this->_sqlExecutor; } /** * Adds a DQL to SQL parameter mapping. One DQL parameter name/position can map to * several SQL parameter positions. - * - * @param string|int $dqlPosition - * @param int $sqlPosition - * - * @return void */ - public function addParameterMapping($dqlPosition, $sqlPosition) + public function addParameterMapping(string|int $dqlPosition, int $sqlPosition): void { $this->_parameterMappings[$dqlPosition][] = $sqlPosition; } @@ -105,7 +98,7 @@ public function addParameterMapping($dqlPosition, $sqlPosition) * * @psalm-return array> The parameter mappings. */ - public function getParameterMappings() + public function getParameterMappings(): array { return $this->_parameterMappings; } @@ -118,7 +111,7 @@ public function getParameterMappings() * @return int[] The positions of the corresponding SQL parameters. * @psalm-return list */ - public function getSqlParameterPositions($dqlPosition) + public function getSqlParameterPositions(string|int $dqlPosition): array { return $this->_parameterMappings[$dqlPosition]; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 31906e3082c..48fc01770ae 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1313,11 +1313,6 @@ $AST instanceof AST\SelectStatement - - - $_sqlExecutor - - new ArrayCollection($this->parameters) diff --git a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php index f1bf6ea8e71..af9831bf77a 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php @@ -7,6 +7,7 @@ use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; use Doctrine\ORM\Query\ParserResult; use Doctrine\ORM\Query\ResultSetMapping; +use LogicException; use PHPUnit\Framework\TestCase; class ParserResultTest extends TestCase @@ -24,10 +25,18 @@ public function testGetRsm(): void self::assertInstanceOf(ResultSetMapping::class, $this->parserResult->getResultSetMapping()); } - public function testSetGetSqlExecutor(): void + public function testItThrowsWhenAttemptingToAccessTheExecutorBeforeItIsSet(): void { - self::assertNull($this->parserResult->getSqlExecutor()); + $this->expectException(LogicException::class); + $this->expectExceptionMessage( + 'Executor not set yet. Call Doctrine\ORM\Query\ParserResult::setSqlExecutor() first.', + ); + + $this->parserResult->getSqlExecutor(); + } + public function testSetGetSqlExecutor(): void + { $executor = $this->getMockForAbstractClass(AbstractSqlExecutor::class); $this->parserResult->setSqlExecutor($executor); self::assertSame($executor, $this->parserResult->getSqlExecutor()); From 5c346785802c0c191e5f68dbf7fd74219c0b251c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 29 Jan 2023 16:27:48 +0100 Subject: [PATCH 219/475] Migrate exec namespace to PHP 8 syntax --- .../ORM/Query/Exec/AbstractSqlExecutor.php | 18 ++++------ .../Query/Exec/MultiTableDeleteExecutor.php | 32 +++++++---------- .../Query/Exec/MultiTableUpdateExecutor.php | 34 +++++++------------ phpstan-baseline.neon | 5 --- psalm-baseline.xml | 5 --- 5 files changed, 32 insertions(+), 62 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php index 737d611a348..6d207253d5b 100644 --- a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php @@ -19,33 +19,29 @@ abstract class AbstractSqlExecutor { /** @var list|string */ - protected $_sqlStatements; + protected array|string $_sqlStatements; - /** @var QueryCacheProfile */ - protected $queryCacheProfile; + protected QueryCacheProfile|null $queryCacheProfile; /** * Gets the SQL statements that are executed by the executor. * * @return mixed[]|string All the SQL update statements. */ - public function getSqlStatements() + public function getSqlStatements(): array|string { return $this->_sqlStatements; } - /** @return void */ - public function setQueryCacheProfile(QueryCacheProfile $qcp) + public function setQueryCacheProfile(QueryCacheProfile $qcp): void { $this->queryCacheProfile = $qcp; } /** * Do not use query cache - * - * @return void */ - public function removeQueryCacheProfile() + public function removeQueryCacheProfile(): void { $this->queryCacheProfile = null; } @@ -57,8 +53,6 @@ public function removeQueryCacheProfile() * @psalm-param list|array $params The parameters. * @psalm-param array| * array $types The parameter types. - * - * @return Result|int */ - abstract public function execute(Connection $conn, array $params, array $types); + abstract public function execute(Connection $conn, array $params, array $types): Result|int; } diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php index 20586e1b9e3..bfdf3991dd6 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php @@ -13,7 +13,6 @@ use Doctrine\ORM\Utility\PersisterHelper; use Throwable; -use function array_merge; use function array_reverse; use function implode; @@ -25,14 +24,9 @@ */ class MultiTableDeleteExecutor extends AbstractSqlExecutor { - /** @var string */ - private $_createTempTableSql; - - /** @var string */ - private $_dropTempTableSql; - - /** @var string */ - private $_insertSql; + private readonly string $_createTempTableSql; + private readonly string $_dropTempTableSql; + private readonly string $_insertSql; /** * Initializes a new MultiTableDeleteExecutor. @@ -43,7 +37,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor * @param DeleteStatement $AST The root AST node of the DQL query. * @param SqlWalker $sqlWalker The walker used for SQL generation from the AST. */ - public function __construct(AST\Node $AST, $sqlWalker) + public function __construct(AST\Node $AST, SqlWalker $sqlWalker) { $em = $sqlWalker->getEntityManager(); $conn = $em->getConnection(); @@ -65,23 +59,25 @@ public function __construct(AST\Node $AST, $sqlWalker) // 1. Create an INSERT INTO temptable ... SELECT identifiers WHERE $AST->getWhereClause() $sqlWalker->setSQLTableAlias($primaryClass->getTableName(), 't0', $primaryDqlAlias); - $this->_insertSql = 'INSERT INTO ' . $tempTable . ' (' . $idColumnList . ')' + $insertSql = 'INSERT INTO ' . $tempTable . ' (' . $idColumnList . ')' . ' SELECT t0.' . implode(', t0.', $idColumnNames); - $rangeDecl = new AST\RangeVariableDeclaration($primaryClass->name, $primaryDqlAlias); - $fromClause = new AST\FromClause([new AST\IdentificationVariableDeclaration($rangeDecl, null, [])]); - $this->_insertSql .= $sqlWalker->walkFromClause($fromClause); + $rangeDecl = new AST\RangeVariableDeclaration($primaryClass->name, $primaryDqlAlias); + $fromClause = new AST\FromClause([new AST\IdentificationVariableDeclaration($rangeDecl, null, [])]); + $insertSql .= $sqlWalker->walkFromClause($fromClause); // Append WHERE clause, if there is one. if ($AST->whereClause) { - $this->_insertSql .= $sqlWalker->walkWhereClause($AST->whereClause); + $insertSql .= $sqlWalker->walkWhereClause($AST->whereClause); } + $this->_insertSql = $insertSql; + // 2. Create ID subselect statement used in DELETE ... WHERE ... IN (subselect) $idSubselect = 'SELECT ' . $idColumnList . ' FROM ' . $tempTable; // 3. Create and store DELETE statements - $classNames = array_merge($primaryClass->parentClasses, [$primaryClass->name], $primaryClass->subClasses); + $classNames = [...$primaryClass->parentClasses, ...[$primaryClass->name], ...$primaryClass->subClasses]; foreach (array_reverse($classNames) as $className) { $tableName = $quoteStrategy->getTableName($em->getClassMetadata($className), $platform); $this->_sqlStatements[] = 'DELETE FROM ' . $tableName @@ -105,10 +101,8 @@ public function __construct(AST\Node $AST, $sqlWalker) /** * {@inheritDoc} - * - * @return int */ - public function execute(Connection $conn, array $params, array $types) + public function execute(Connection $conn, array $params, array $types): int { // Create temporary id table $conn->executeStatement($this->_createTempTableSql); diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php index 920b68597dd..d6b0c72831c 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -13,7 +13,6 @@ use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Utility\PersisterHelper; -use function array_merge; use function array_reverse; use function array_slice; use function implode; @@ -24,20 +23,13 @@ */ class MultiTableUpdateExecutor extends AbstractSqlExecutor { - /** @var string */ - private $_createTempTableSql; - - /** @var string */ - private $_dropTempTableSql; - - /** @var string */ - private $_insertSql; + private readonly string $_createTempTableSql; + private readonly string $_dropTempTableSql; + private readonly string $_insertSql; /** @var mixed[] */ - private $_sqlParameters = []; - - /** @var int */ - private $_numParametersInUpdateClause = 0; + private array $_sqlParameters = []; + private int $_numParametersInUpdateClause = 0; /** * Initializes a new MultiTableUpdateExecutor. @@ -48,7 +40,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor * @param UpdateStatement $AST The root AST node of the DQL query. * @param SqlWalker $sqlWalker The walker used for SQL generation from the AST. */ - public function __construct(AST\Node $AST, $sqlWalker) + public function __construct(AST\Node $AST, SqlWalker $sqlWalker) { $em = $sqlWalker->getEntityManager(); $conn = $em->getConnection(); @@ -72,19 +64,19 @@ public function __construct(AST\Node $AST, $sqlWalker) // 1. Create an INSERT INTO temptable ... SELECT identifiers WHERE $AST->getWhereClause() $sqlWalker->setSQLTableAlias($primaryClass->getTableName(), 't0', $updateClause->aliasIdentificationVariable); - $this->_insertSql = 'INSERT INTO ' . $tempTable . ' (' . $idColumnList . ')' + $insertSql = 'INSERT INTO ' . $tempTable . ' (' . $idColumnList . ')' . ' SELECT t0.' . implode(', t0.', $idColumnNames); $rangeDecl = new AST\RangeVariableDeclaration($primaryClass->name, $updateClause->aliasIdentificationVariable); $fromClause = new AST\FromClause([new AST\IdentificationVariableDeclaration($rangeDecl, null, [])]); - $this->_insertSql .= $sqlWalker->walkFromClause($fromClause); + $insertSql .= $sqlWalker->walkFromClause($fromClause); // 2. Create ID subselect statement used in UPDATE ... WHERE ... IN (subselect) $idSubselect = 'SELECT ' . $idColumnList . ' FROM ' . $tempTable; // 3. Create and store UPDATE statements - $classNames = array_merge($primaryClass->parentClasses, [$primaryClass->name], $primaryClass->subClasses); + $classNames = [...$primaryClass->parentClasses, ...[$primaryClass->name], ...$primaryClass->subClasses]; $i = -1; foreach (array_reverse($classNames) as $className) { @@ -125,9 +117,11 @@ public function __construct(AST\Node $AST, $sqlWalker) // Append WHERE clause to insertSql, if there is one. if ($AST->whereClause) { - $this->_insertSql .= $sqlWalker->walkWhereClause($AST->whereClause); + $insertSql .= $sqlWalker->walkWhereClause($AST->whereClause); } + $this->_insertSql = $insertSql; + // 4. Store DDL for temporary identifier table. $columnDefinitions = []; @@ -147,10 +141,8 @@ public function __construct(AST\Node $AST, $sqlWalker) /** * {@inheritDoc} - * - * @return int */ - public function execute(Connection $conn, array $params, array $types) + public function execute(Connection $conn, array $params, array $types): int { // Create temporary id table $conn->executeStatement($this->_createTempTableSql); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b6e9f6b8660..19461d6bd83 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -240,11 +240,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/AST/WhenClause.php - - - message: "#^Property Doctrine\\\\ORM\\\\Query\\\\Exec\\\\AbstractSqlExecutor\\:\\:\\$queryCacheProfile \\(Doctrine\\\\DBAL\\\\Cache\\\\QueryCacheProfile\\) does not accept null\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php - - message: "#^PHPDoc type array\\ of property Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Andx\\:\\:\\$allowedClasses is not covariant with PHPDoc type array\\ of overridden property Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Base\\:\\:\\$allowedClasses\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9c0abf62417..30a156cefe6 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1147,11 +1147,6 @@ walkWhenClauseExpression - - - null - - $numDeleted From e8c1e6c1d32c68fba1f3dba5ad2a451cb45d233a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 4 Feb 2023 23:24:06 +0100 Subject: [PATCH 220/475] Migrate database driver to PHP 8 syntax --- .../ORM/Mapping/Driver/DatabaseDriver.php | 64 +++++-------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index caf9401b2d0..432e44487a0 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -25,7 +25,6 @@ use function assert; use function count; use function current; -use function get_class; use function in_array; use function preg_replace; use function sort; @@ -52,56 +51,42 @@ class DatabaseDriver implements MappingDriver */ private const OBJECT = 'object'; - /** @var AbstractSchemaManager */ - private $sm; - /** @var array|null */ - private $tables = null; + private array|null $tables = null; /** @var array */ - private $classToTableNames = []; + private array $classToTableNames = []; /** @psalm-var array */ - private $manyToManyTables = []; + private array $manyToManyTables = []; /** @var mixed[] */ - private $classNamesForTables = []; + private array $classNamesForTables = []; /** @var mixed[] */ - private $fieldNamesForColumns = []; + private array $fieldNamesForColumns = []; /** * The namespace for the generated entities. - * - * @var string|null */ - private $namespace; + private string|null $namespace = null; - /** @var Inflector */ - private $inflector; + private Inflector $inflector; - public function __construct(AbstractSchemaManager $schemaManager) + public function __construct(private readonly AbstractSchemaManager $sm) { - $this->sm = $schemaManager; $this->inflector = InflectorFactory::create()->build(); } /** * Set the namespace for the generated entities. - * - * @param string $namespace - * - * @return void */ - public function setNamespace($namespace) + public function setNamespace(string $namespace): void { $this->namespace = $namespace; } - /** - * {@inheritDoc} - */ - public function isTransient($className) + public function isTransient(string $className): bool { return true; } @@ -109,7 +94,7 @@ public function isTransient($className) /** * {@inheritDoc} */ - public function getAllClassNames() + public function getAllClassNames(): array { $this->reverseEngineerMappingFromDatabase(); @@ -118,27 +103,16 @@ public function getAllClassNames() /** * Sets class name for a table. - * - * @param string $tableName - * @param string $className - * - * @return void */ - public function setClassNameForTable($tableName, $className) + public function setClassNameForTable(string $tableName, string $className): void { $this->classNamesForTables[$tableName] = $className; } /** * Sets field name for a column on a specific table. - * - * @param string $tableName - * @param string $columnName - * @param string $fieldName - * - * @return void */ - public function setFieldNameForColumn($tableName, $columnName, $fieldName) + public function setFieldNameForColumn(string $tableName, string $columnName, string $fieldName): void { $this->fieldNamesForColumns[$tableName][$columnName] = $fieldName; } @@ -150,10 +124,8 @@ public function setFieldNameForColumn($tableName, $columnName, $fieldName) * @param Table[] $manyToManyTables * @psalm-param list $entityTables * @psalm-param list
$manyToManyTables - * - * @return void */ - public function setTables($entityTables, $manyToManyTables) + public function setTables(array $entityTables, array $manyToManyTables): void { $this->tables = $this->manyToManyTables = $this->classToTableNames = []; @@ -182,14 +154,14 @@ public function setInflector(Inflector $inflector): void * * @template T of object */ - public function loadMetadataForClass($className, PersistenceClassMetadata $metadata) + public function loadMetadataForClass(string $className, PersistenceClassMetadata $metadata): void { if (! $metadata instanceof ClassMetadata) { Deprecation::trigger( 'doctrine/orm', 'https://github.com/doctrine/orm/pull/249', 'Passing an instance of %s to %s is deprecated, please pass a ClassMetadata instance instead.', - get_class($metadata), + $metadata::class, __METHOD__, ClassMetadata::class, ); @@ -457,10 +429,8 @@ private function buildFieldMapping(string $tableName, Column $column): array /** * Build to one (one to one, many to one) association mapping from class metadata. - * - * @return void */ - private function buildToOneAssociationMappings(ClassMetadata $metadata) + private function buildToOneAssociationMappings(ClassMetadata $metadata): void { assert($this->tables !== null); From 941292fe85fc55a1551322911447be49a32ee0c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 5 Feb 2023 10:08:33 +0100 Subject: [PATCH 221/475] Migrate more classes to PHP 8 syntax --- .../OnClassMetadataNotFoundEventArgs.php | 29 +++++--------- lib/Doctrine/ORM/PersistentCollection.php | 19 +++++----- lib/Doctrine/ORM/Query/Printer.php | 38 +++++-------------- lib/Doctrine/ORM/Query/SqlWalker.php | 16 ++++---- psalm-baseline.xml | 5 --- 5 files changed, 36 insertions(+), 71 deletions(-) diff --git a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php b/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php index 52349d8360f..762c08340a2 100644 --- a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php @@ -19,41 +19,30 @@ */ class OnClassMetadataNotFoundEventArgs extends ManagerEventArgs { - /** @var string */ - private $className; - - /** @var ClassMetadata|null */ - private $foundMetadata; - - /** - * @param string $className - * @param EntityManagerInterface $objectManager - */ - public function __construct($className, ObjectManager $objectManager) - { - $this->className = (string) $className; + private ClassMetadata|null $foundMetadata = null; + /** @param EntityManagerInterface $objectManager */ + public function __construct( + private readonly string $className, + ObjectManager $objectManager, + ) { parent::__construct($objectManager); } - /** @return void */ - public function setFoundMetadata(ClassMetadata|null $classMetadata) + public function setFoundMetadata(ClassMetadata|null $classMetadata): void { $this->foundMetadata = $classMetadata; } - /** @return ClassMetadata|null */ - public function getFoundMetadata() + public function getFoundMetadata(): ClassMetadata|null { return $this->foundMetadata; } /** * Retrieve class name for which a failed metadata fetch attempt was executed - * - * @return string */ - public function getClassName() + public function getClassName(): string { return $this->className; } diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index f45d091d85f..fccfafbaead 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -69,11 +69,6 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec */ private string|null $backRefFieldName = null; - /** - * The class descriptor of the collection's entity type. - */ - private ClassMetadata|null $typeClass = null; - /** * Whether the collection is dirty and needs to be synchronized with the database * when the UnitOfWork that manages its persistent state commits. @@ -83,18 +78,17 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec /** * Creates a new persistent collection. * - * @param EntityManagerInterface $em The EntityManager the collection will be associated with. - * @param ClassMetadata $class The class descriptor of the entity type of this collection. + * @param EntityManagerInterface $em The EntityManager the collection will be associated with. + * @param ClassMetadata $typeClass The class descriptor of the entity type of this collection. * @psalm-param Collection&Selectable $collection The collection elements. */ public function __construct( EntityManagerInterface $em, - ClassMetadata $class, + private readonly ClassMetadata|null $typeClass, Collection $collection, ) { $this->collection = $collection; $this->em = $em; - $this->typeClass = $class; $this->initialized = true; } @@ -523,6 +517,11 @@ public function __sleep(): array return ['collection', 'initialized']; } + public function __wakeup(): void + { + $this->em = null; + } + /** * Extracts a slice of $length elements starting at position $offset from the Collection. * @@ -614,7 +613,7 @@ public function matching(Criteria $criteria): Collection * * @return Collection&Selectable */ - public function unwrap(): Collection&Selectable + public function unwrap(): Selectable&Collection { assert($this->collection instanceof Collection); assert($this->collection instanceof Selectable); diff --git a/lib/Doctrine/ORM/Query/Printer.php b/lib/Doctrine/ORM/Query/Printer.php index 561697ec79f..db1f159ae13 100644 --- a/lib/Doctrine/ORM/Query/Printer.php +++ b/lib/Doctrine/ORM/Query/Printer.php @@ -13,28 +13,16 @@ */ class Printer { - /** - * Current indentation level - * - * @var int - */ - protected $_indent = 0; - - /** - * Defines whether parse tree is printed (default, false) or not (true). - * - * @var bool - */ - protected $_silent; + /** Current indentation level */ + protected int $indent = 0; /** * Constructs a new parse tree printer. * * @param bool $silent Parse tree will not be printed if true. */ - public function __construct($silent = false) + public function __construct(protected bool $silent = false) { - $this->_silent = $silent; } /** @@ -44,25 +32,21 @@ public function __construct($silent = false) * This method is called before executing a production. * * @param string $name Production name. - * - * @return void */ - public function startProduction($name) + public function startProduction(string $name): void { $this->println('(' . $name); - $this->_indent++; + $this->indent++; } /** * Decreases indentation level by one and prints a closing parenthesis. * * This method is called after executing a production. - * - * @return void */ - public function endProduction() + public function endProduction(): void { - $this->_indent--; + $this->indent--; $this->println(')'); } @@ -70,13 +54,11 @@ public function endProduction() * Prints text indented with spaces depending on current indentation level. * * @param string $str The text. - * - * @return void */ - public function println($str) + public function println(string $str): void { - if (! $this->_silent) { - echo str_repeat(' ', $this->_indent), $str, "\n"; + if (! $this->silent) { + echo str_repeat(' ', $this->indent), $str, "\n"; } } } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 7fb7ef96db5..ea4ca08e931 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -627,7 +627,7 @@ public function walkPathExpression(AST\PathExpression $pathExpr): string public function walkSelectClause(AST\SelectClause $selectClause): string { $sql = 'SELECT ' . ($selectClause->isDistinct ? 'DISTINCT ' : ''); - $sqlSelectExpressions = array_filter(array_map([$this, 'walkSelectExpression'], $selectClause->selectExpressions)); + $sqlSelectExpressions = array_filter(array_map($this->walkSelectExpression(...), $selectClause->selectExpressions)); if ($this->query->getHint(Query::HINT_INTERNAL_ITERATION) === true && $selectClause->isDistinct) { $this->query->setHint(self::HINT_DISTINCT, true); @@ -1043,7 +1043,7 @@ public function walkFunction(AST\Functions\FunctionNode $function): string */ public function walkOrderByClause(AST\OrderByClause $orderByClause): string { - $orderByItems = array_map([$this, 'walkOrderByItem'], $orderByClause->orderByItems); + $orderByItems = array_map($this->walkOrderByItem(...), $orderByClause->orderByItems); $collectionOrderByItems = $this->generateOrderedCollectionOrderByItems(); if ($collectionOrderByItems !== '') { @@ -1677,7 +1677,7 @@ public function walkUpdateClause(AST\UpdateClause $updateClause): string $this->setSQLTableAlias($tableName, $tableName, $updateClause->aliasIdentificationVariable); $this->rootAliases[] = $updateClause->aliasIdentificationVariable; - return $sql . ' SET ' . implode(', ', array_map([$this, 'walkUpdateItem'], $updateClause->updateItems)); + return $sql . ' SET ' . implode(', ', array_map($this->walkUpdateItem(...), $updateClause->updateItems)); } /** @@ -1756,7 +1756,7 @@ public function walkConditionalExpression( return $this->walkConditionalTerm($condExpr); } - return implode(' OR ', array_map([$this, 'walkConditionalTerm'], $condExpr->conditionalTerms)); + return implode(' OR ', array_map($this->walkConditionalTerm(...), $condExpr->conditionalTerms)); } /** @@ -1771,7 +1771,7 @@ public function walkConditionalTerm( return $this->walkConditionalFactor($condTerm); } - return implode(' AND ', array_map([$this, 'walkConditionalFactor'], $condTerm->conditionalFactors)); + return implode(' AND ', array_map($this->walkConditionalFactor(...), $condTerm->conditionalFactors)); } /** @@ -1953,7 +1953,7 @@ public function walkInListExpression(AST\InListExpression $inExpr): string { return $this->walkArithmeticExpression($inExpr->expression) . ($inExpr->not ? ' NOT' : '') . ' IN (' - . implode(', ', array_map([$this, 'walkInParameter'], $inExpr->literals)) + . implode(', ', array_map($this->walkInParameter(...), $inExpr->literals)) . ')'; } @@ -2134,7 +2134,7 @@ public function walkSimpleArithmeticExpression(AST\Node|string $simpleArithmetic return $this->walkArithmeticTerm($simpleArithmeticExpr); } - return implode(' ', array_map([$this, 'walkArithmeticTerm'], $simpleArithmeticExpr->arithmeticTerms)); + return implode(' ', array_map($this->walkArithmeticTerm(...), $simpleArithmeticExpr->arithmeticTerms)); } /** @@ -2154,7 +2154,7 @@ public function walkArithmeticTerm(AST\Node|string $term): string return $this->walkArithmeticFactor($term); } - return implode(' ', array_map([$this, 'walkArithmeticFactor'], $term->arithmeticFactors)); + return implode(' ', array_map($this->walkArithmeticFactor(...), $term->arithmeticFactors)); } /** diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 241258b59c6..daa2401bd78 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -227,11 +227,6 @@ list<T> - - - (string) $className - - $entity From 09caeb27537fb8f3ed9a72d5869e5a64e1ab2ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 6 Feb 2023 20:21:04 +0100 Subject: [PATCH 222/475] Stop relying on underscores to indicate property visibility It conflicts with our coding standard. --- lib/Doctrine/ORM/AbstractQuery.php | 98 ++++++------ lib/Doctrine/ORM/Configuration.php | 128 ++++++++-------- .../Internal/Hydration/AbstractHydrator.php | 144 +++++++++--------- .../ORM/Internal/Hydration/ArrayHydrator.php | 2 +- .../ORM/Internal/Hydration/ObjectHydrator.php | 72 ++++----- .../Hydration/SimpleObjectHydrator.php | 22 +-- lib/Doctrine/ORM/NativeQuery.php | 2 +- lib/Doctrine/ORM/Query.php | 28 ++-- .../ORM/Query/Exec/AbstractSqlExecutor.php | 4 +- .../Query/Exec/MultiTableDeleteExecutor.php | 6 +- .../Query/Exec/MultiTableUpdateExecutor.php | 4 +- .../ORM/Query/Exec/SingleSelectExecutor.php | 4 +- .../Exec/SingleTableDeleteUpdateExecutor.php | 6 +- phpcs.xml.dist | 12 -- psalm-baseline.xml | 16 +- .../Doctrine/Tests/ORM/AbstractQueryTest.php | 2 +- 16 files changed, 268 insertions(+), 282 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index ccfd230c807..7470bc74f73 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -89,30 +89,30 @@ abstract class AbstractQuery /** * The user-specified ResultSetMapping to use. */ - protected ResultSetMapping|null $_resultSetMapping = null; + protected ResultSetMapping|null $resultSetMapping = null; /** * The map of query hints. * * @psalm-var array */ - protected array $_hints = []; + protected array $hints = []; /** * The hydration mode. * * @psalm-var string|AbstractQuery::HYDRATE_* */ - protected string|int $_hydrationMode = self::HYDRATE_OBJECT; + protected string|int $hydrationMode = self::HYDRATE_OBJECT; - protected QueryCacheProfile|null $_queryCacheProfile = null; + protected QueryCacheProfile|null $queryCacheProfile = null; /** * Whether or not expire the result cache. */ - protected bool $_expireResultCache = false; + protected bool $expireResultCache = false; - protected QueryCacheProfile|null $_hydrationCacheProfile = null; + protected QueryCacheProfile|null $hydrationCacheProfile = null; /** * Whether to use second level cache, if available. @@ -147,7 +147,7 @@ public function __construct( protected EntityManagerInterface $em, ) { $this->parameters = new ArrayCollection(); - $this->_hints = $em->getConfiguration()->getDefaultQueryHints(); + $this->hints = $em->getConfiguration()->getDefaultQueryHints(); $this->hasCache = $this->em->getConfiguration()->isSecondLevelCacheEnabled(); if ($this->hasCache) { @@ -260,7 +260,7 @@ public function free(): void { $this->parameters = new ArrayCollection(); - $this->_hints = $this->em->getConfiguration()->getDefaultQueryHints(); + $this->hints = $this->em->getConfiguration()->getDefaultQueryHints(); } /** @@ -434,7 +434,7 @@ private function processArrayParameterValue(array $value): array public function setResultSetMapping(ResultSetMapping $rsm): static { $this->translateNamespaces($rsm); - $this->_resultSetMapping = $rsm; + $this->resultSetMapping = $rsm; return $this; } @@ -444,7 +444,7 @@ public function setResultSetMapping(ResultSetMapping $rsm): static */ protected function getResultSetMapping(): ResultSetMapping|null { - return $this->_resultSetMapping; + return $this->resultSetMapping; } /** @@ -481,7 +481,7 @@ private function translateNamespaces(ResultSetMapping $rsm): void public function setHydrationCacheProfile(QueryCacheProfile|null $profile): static { if ($profile === null) { - $this->_hydrationCacheProfile = null; + $this->hydrationCacheProfile = null; return $this; } @@ -493,14 +493,14 @@ public function setHydrationCacheProfile(QueryCacheProfile|null $profile): stati } } - $this->_hydrationCacheProfile = $profile; + $this->hydrationCacheProfile = $profile; return $this; } public function getHydrationCacheProfile(): QueryCacheProfile|null { - return $this->_hydrationCacheProfile; + return $this->hydrationCacheProfile; } /** @@ -514,7 +514,7 @@ public function getHydrationCacheProfile(): QueryCacheProfile|null public function setResultCacheProfile(QueryCacheProfile|null $profile): static { if ($profile === null) { - $this->_queryCacheProfile = null; + $this->queryCacheProfile = null; return $this; } @@ -526,7 +526,7 @@ public function setResultCacheProfile(QueryCacheProfile|null $profile): static } } - $this->_queryCacheProfile = $profile; + $this->queryCacheProfile = $profile; return $this; } @@ -537,15 +537,15 @@ public function setResultCacheProfile(QueryCacheProfile|null $profile): static public function setResultCache(CacheItemPoolInterface|null $resultCache): static { if ($resultCache === null) { - if ($this->_queryCacheProfile) { - $this->_queryCacheProfile = new QueryCacheProfile($this->_queryCacheProfile->getLifetime(), $this->_queryCacheProfile->getCacheKey()); + if ($this->queryCacheProfile) { + $this->queryCacheProfile = new QueryCacheProfile($this->queryCacheProfile->getLifetime(), $this->queryCacheProfile->getCacheKey()); } return $this; } - $this->_queryCacheProfile = $this->_queryCacheProfile - ? $this->_queryCacheProfile->setResultCache($resultCache) + $this->queryCacheProfile = $this->queryCacheProfile + ? $this->queryCacheProfile->setResultCache($resultCache) : new QueryCacheProfile(0, null, $resultCache); return $this; @@ -575,7 +575,7 @@ public function enableResultCache(int|null $lifetime = null, string|null $result */ public function disableResultCache(): static { - $this->_queryCacheProfile = null; + $this->queryCacheProfile = null; return $this; } @@ -591,20 +591,20 @@ public function setResultCacheLifetime(int|null $lifetime): static { $lifetime = (int) $lifetime; - if ($this->_queryCacheProfile) { - $this->_queryCacheProfile = $this->_queryCacheProfile->setLifetime($lifetime); + if ($this->queryCacheProfile) { + $this->queryCacheProfile = $this->queryCacheProfile->setLifetime($lifetime); return $this; } - $this->_queryCacheProfile = new QueryCacheProfile($lifetime); + $this->queryCacheProfile = new QueryCacheProfile($lifetime); $cache = $this->em->getConfiguration()->getResultCache(); if (! $cache) { return $this; } - $this->_queryCacheProfile = $this->_queryCacheProfile->setResultCache($cache); + $this->queryCacheProfile = $this->queryCacheProfile->setResultCache($cache); return $this; } @@ -618,7 +618,7 @@ public function setResultCacheLifetime(int|null $lifetime): static */ public function expireResultCache(bool $expire = true): static { - $this->_expireResultCache = $expire; + $this->expireResultCache = $expire; return $this; } @@ -628,12 +628,12 @@ public function expireResultCache(bool $expire = true): static */ public function getExpireResultCache(): bool { - return $this->_expireResultCache; + return $this->expireResultCache; } public function getQueryCacheProfile(): QueryCacheProfile|null { - return $this->_queryCacheProfile; + return $this->queryCacheProfile; } /** @@ -644,7 +644,7 @@ public function getQueryCacheProfile(): QueryCacheProfile|null */ public function setFetchMode(string $class, string $assocName, int $fetchMode): static { - $this->_hints['fetchMode'][$class][$assocName] = $fetchMode; + $this->hints['fetchMode'][$class][$assocName] = $fetchMode; return $this; } @@ -660,7 +660,7 @@ public function setFetchMode(string $class, string $assocName, int $fetchMode): */ public function setHydrationMode(string|int $hydrationMode): static { - $this->_hydrationMode = $hydrationMode; + $this->hydrationMode = $hydrationMode; return $this; } @@ -672,7 +672,7 @@ public function setHydrationMode(string|int $hydrationMode): static */ public function getHydrationMode(): string|int { - return $this->_hydrationMode; + return $this->hydrationMode; } /** @@ -738,7 +738,7 @@ public function getOneOrNullResult(string|int|null $hydrationMode = null): mixed return null; } - if ($this->_hydrationMode !== self::HYDRATE_SINGLE_SCALAR && ! $result) { + if ($this->hydrationMode !== self::HYDRATE_SINGLE_SCALAR && ! $result) { return null; } @@ -770,7 +770,7 @@ public function getSingleResult(string|int|null $hydrationMode = null): mixed { $result = $this->execute(null, $hydrationMode); - if ($this->_hydrationMode !== self::HYDRATE_SINGLE_SCALAR && ! $result) { + if ($this->hydrationMode !== self::HYDRATE_SINGLE_SCALAR && ! $result) { throw new NoResultException(); } @@ -805,7 +805,7 @@ public function getSingleScalarResult(): mixed */ public function setHint(string $name, mixed $value): static { - $this->_hints[$name] = $value; + $this->hints[$name] = $value; return $this; } @@ -817,12 +817,12 @@ public function setHint(string $name, mixed $value): static */ public function getHint(string $name): mixed { - return $this->_hints[$name] ?? false; + return $this->hints[$name] ?? false; } public function hasHint(string $name): bool { - return isset($this->_hints[$name]); + return isset($this->hints[$name]); } /** @@ -832,7 +832,7 @@ public function hasHint(string $name): bool */ public function getHints(): array { - return $this->_hints; + return $this->hints; } /** @@ -867,7 +867,7 @@ public function toIterable( $stmt = $this->_doExecute(); - return $this->em->newHydrator($this->_hydrationMode)->toIterable($stmt, $rsm, $this->_hints); + return $this->em->newHydrator($this->hydrationMode)->toIterable($stmt, $rsm, $this->hints); } /** @@ -908,7 +908,7 @@ private function executeIgnoreQueryCache( $setCacheEntry = static function ($data): void { }; - if ($this->_hydrationCacheProfile !== null) { + if ($this->hydrationCacheProfile !== null) { [$cacheKey, $realCacheKey] = $this->getHydrationCacheId(); $cache = $this->getHydrationCache(); @@ -941,7 +941,7 @@ private function executeIgnoreQueryCache( throw new LogicException('Uninitialized result set mapping.'); } - $data = $this->em->newHydrator($this->_hydrationMode)->hydrateAll($stmt, $rsm, $this->_hints); + $data = $this->em->newHydrator($this->hydrationMode)->hydrateAll($stmt, $rsm, $this->hints); $setCacheEntry($data); @@ -950,9 +950,9 @@ private function executeIgnoreQueryCache( private function getHydrationCache(): CacheItemPoolInterface { - assert($this->_hydrationCacheProfile !== null); + assert($this->hydrationCacheProfile !== null); - $cache = $this->_hydrationCacheProfile->getResultCache(); + $cache = $this->hydrationCacheProfile->getResultCache(); assert($cache !== null); return $cache; @@ -981,7 +981,7 @@ private function executeUsingQueryCache( $this->getTimestampKey(), ); - $result = $queryCache->get($queryKey, $rsm, $this->_hints); + $result = $queryCache->get($queryKey, $rsm, $this->hints); if ($result !== null) { if ($this->cacheLogger) { @@ -992,7 +992,7 @@ private function executeUsingQueryCache( } $result = $this->executeIgnoreQueryCache($parameters, $hydrationMode); - $cached = $queryCache->put($queryKey, $rsm, $result, $this->_hints); + $cached = $queryCache->put($queryKey, $rsm, $result, $this->hints); if ($this->cacheLogger) { $this->cacheLogger->queryCacheMiss($queryCache->getRegion()->getName(), $queryKey); @@ -1007,8 +1007,8 @@ private function executeUsingQueryCache( private function getTimestampKey(): TimestampCacheKey|null { - assert($this->_resultSetMapping !== null); - $entityName = reset($this->_resultSetMapping->aliasMap); + assert($this->resultSetMapping !== null); + $entityName = reset($this->resultSetMapping->aliasMap); if (empty($entityName)) { return null; @@ -1056,11 +1056,11 @@ protected function getHydrationCacheId(): array */ public function setResultCacheId(string|null $id): static { - if (! $this->_queryCacheProfile) { + if (! $this->queryCacheProfile) { return $this->setResultCacheProfile(new QueryCacheProfile(0, $id)); } - $this->_queryCacheProfile = $this->_queryCacheProfile->setCacheKey($id); + $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey($id); return $this; } @@ -1081,8 +1081,8 @@ public function __clone() { $this->parameters = new ArrayCollection(); - $this->_hints = []; - $this->_hints = $this->em->getConfiguration()->getDefaultQueryHints(); + $this->hints = []; + $this->hints = $this->em->getConfiguration()->getDefaultQueryHints(); } /** diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 87eaeb72161..782c070a791 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -42,14 +42,14 @@ class Configuration extends \Doctrine\DBAL\Configuration { /** @var mixed[] */ - protected array $_attributes = []; + protected array $attributes = []; /** * Sets the directory where Doctrine generates any necessary proxy class files. */ public function setProxyDir(string $dir): void { - $this->_attributes['proxyDir'] = $dir; + $this->attributes['proxyDir'] = $dir; } /** @@ -57,7 +57,7 @@ public function setProxyDir(string $dir): void */ public function getProxyDir(): string|null { - return $this->_attributes['proxyDir'] ?? null; + return $this->attributes['proxyDir'] ?? null; } /** @@ -68,7 +68,7 @@ public function getProxyDir(): string|null */ public function getAutoGenerateProxyClasses(): int { - return $this->_attributes['autoGenerateProxyClasses'] ?? ProxyFactory::AUTOGENERATE_ALWAYS; + return $this->attributes['autoGenerateProxyClasses'] ?? ProxyFactory::AUTOGENERATE_ALWAYS; } /** @@ -80,7 +80,7 @@ public function getAutoGenerateProxyClasses(): int */ public function setAutoGenerateProxyClasses(bool|int $autoGenerate): void { - $this->_attributes['autoGenerateProxyClasses'] = (int) $autoGenerate; + $this->attributes['autoGenerateProxyClasses'] = (int) $autoGenerate; } /** @@ -88,7 +88,7 @@ public function setAutoGenerateProxyClasses(bool|int $autoGenerate): void */ public function getProxyNamespace(): string|null { - return $this->_attributes['proxyNamespace'] ?? null; + return $this->attributes['proxyNamespace'] ?? null; } /** @@ -96,7 +96,7 @@ public function getProxyNamespace(): string|null */ public function setProxyNamespace(string $ns): void { - $this->_attributes['proxyNamespace'] = $ns; + $this->attributes['proxyNamespace'] = $ns; } /** @@ -107,7 +107,7 @@ public function setProxyNamespace(string $ns): void */ public function setMetadataDriverImpl(MappingDriver $driverImpl): void { - $this->_attributes['metadataDriverImpl'] = $driverImpl; + $this->attributes['metadataDriverImpl'] = $driverImpl; } /** @@ -117,7 +117,7 @@ public function setMetadataDriverImpl(MappingDriver $driverImpl): void */ public function setEntityNamespaces(array $entityNamespaces): void { - $this->_attributes['entityNamespaces'] = $entityNamespaces; + $this->attributes['entityNamespaces'] = $entityNamespaces; } /** @@ -127,7 +127,7 @@ public function setEntityNamespaces(array $entityNamespaces): void */ public function getEntityNamespaces(): array { - return $this->_attributes['entityNamespaces']; + return $this->attributes['entityNamespaces']; } /** @@ -135,7 +135,7 @@ public function getEntityNamespaces(): array */ public function getMetadataDriverImpl(): MappingDriver|null { - return $this->_attributes['metadataDriverImpl'] ?? null; + return $this->attributes['metadataDriverImpl'] ?? null; } /** @@ -143,7 +143,7 @@ public function getMetadataDriverImpl(): MappingDriver|null */ public function getQueryCache(): CacheItemPoolInterface|null { - return $this->_attributes['queryCache'] ?? null; + return $this->attributes['queryCache'] ?? null; } /** @@ -151,27 +151,27 @@ public function getQueryCache(): CacheItemPoolInterface|null */ public function setQueryCache(CacheItemPoolInterface $cache): void { - $this->_attributes['queryCache'] = $cache; + $this->attributes['queryCache'] = $cache; } public function getHydrationCache(): CacheItemPoolInterface|null { - return $this->_attributes['hydrationCache'] ?? null; + return $this->attributes['hydrationCache'] ?? null; } public function setHydrationCache(CacheItemPoolInterface $cache): void { - $this->_attributes['hydrationCache'] = $cache; + $this->attributes['hydrationCache'] = $cache; } public function getMetadataCache(): CacheItemPoolInterface|null { - return $this->_attributes['metadataCache'] ?? null; + return $this->attributes['metadataCache'] ?? null; } public function setMetadataCache(CacheItemPoolInterface $cache): void { - $this->_attributes['metadataCache'] = $cache; + $this->attributes['metadataCache'] = $cache; } /** @@ -186,7 +186,7 @@ public function setMetadataCache(CacheItemPoolInterface $cache): void */ public function addCustomStringFunction(string $name, string|callable $className): void { - $this->_attributes['customStringFunctions'][strtolower($name)] = $className; + $this->attributes['customStringFunctions'][strtolower($name)] = $className; } /** @@ -198,7 +198,7 @@ public function getCustomStringFunction(string $name): string|callable|null { $name = strtolower($name); - return $this->_attributes['customStringFunctions'][$name] ?? null; + return $this->attributes['customStringFunctions'][$name] ?? null; } /** @@ -231,7 +231,7 @@ public function setCustomStringFunctions(array $functions): void */ public function addCustomNumericFunction(string $name, string|callable $className): void { - $this->_attributes['customNumericFunctions'][strtolower($name)] = $className; + $this->attributes['customNumericFunctions'][strtolower($name)] = $className; } /** @@ -243,7 +243,7 @@ public function getCustomNumericFunction(string $name): string|callable|null { $name = strtolower($name); - return $this->_attributes['customNumericFunctions'][$name] ?? null; + return $this->attributes['customNumericFunctions'][$name] ?? null; } /** @@ -276,7 +276,7 @@ public function setCustomNumericFunctions(array $functions): void */ public function addCustomDatetimeFunction(string $name, string|callable $className): void { - $this->_attributes['customDatetimeFunctions'][strtolower($name)] = $className; + $this->attributes['customDatetimeFunctions'][strtolower($name)] = $className; } /** @@ -288,7 +288,7 @@ public function getCustomDatetimeFunction(string $name): string|callable|null { $name = strtolower($name); - return $this->_attributes['customDatetimeFunctions'][$name] ?? null; + return $this->attributes['customDatetimeFunctions'][$name] ?? null; } /** @@ -314,7 +314,7 @@ public function setCustomDatetimeFunctions(array $functions): void */ public function setTypedFieldMapper(TypedFieldMapper|null $typedFieldMapper): void { - $this->_attributes['typedFieldMapper'] = $typedFieldMapper; + $this->attributes['typedFieldMapper'] = $typedFieldMapper; } /** @@ -322,7 +322,7 @@ public function setTypedFieldMapper(TypedFieldMapper|null $typedFieldMapper): vo */ public function getTypedFieldMapper(): TypedFieldMapper|null { - return $this->_attributes['typedFieldMapper'] ?? null; + return $this->attributes['typedFieldMapper'] ?? null; } /** @@ -332,7 +332,7 @@ public function getTypedFieldMapper(): TypedFieldMapper|null */ public function setCustomHydrationModes(array $modes): void { - $this->_attributes['customHydrationModes'] = []; + $this->attributes['customHydrationModes'] = []; foreach ($modes as $modeName => $hydrator) { $this->addCustomHydrationMode($modeName, $hydrator); @@ -346,7 +346,7 @@ public function setCustomHydrationModes(array $modes): void */ public function getCustomHydrationMode(string $modeName): string|null { - return $this->_attributes['customHydrationModes'][$modeName] ?? null; + return $this->attributes['customHydrationModes'][$modeName] ?? null; } /** @@ -356,7 +356,7 @@ public function getCustomHydrationMode(string $modeName): string|null */ public function addCustomHydrationMode(string $modeName, string $hydrator): void { - $this->_attributes['customHydrationModes'][$modeName] = $hydrator; + $this->attributes['customHydrationModes'][$modeName] = $hydrator; } /** @@ -366,17 +366,17 @@ public function addCustomHydrationMode(string $modeName, string $hydrator): void */ public function setClassMetadataFactoryName(string $cmfName): void { - $this->_attributes['classMetadataFactoryName'] = $cmfName; + $this->attributes['classMetadataFactoryName'] = $cmfName; } /** @psalm-return class-string */ public function getClassMetadataFactoryName(): string { - if (! isset($this->_attributes['classMetadataFactoryName'])) { - $this->_attributes['classMetadataFactoryName'] = ClassMetadataFactory::class; + if (! isset($this->attributes['classMetadataFactoryName'])) { + $this->attributes['classMetadataFactoryName'] = ClassMetadataFactory::class; } - return $this->_attributes['classMetadataFactoryName']; + return $this->attributes['classMetadataFactoryName']; } /** @@ -387,7 +387,7 @@ public function getClassMetadataFactoryName(): string */ public function addFilter(string $name, string $className): void { - $this->_attributes['filters'][$name] = $className; + $this->attributes['filters'][$name] = $className; } /** @@ -399,7 +399,7 @@ public function addFilter(string $name, string $className): void */ public function getFilterClassName(string $name): string|null { - return $this->_attributes['filters'][$name] ?? null; + return $this->attributes['filters'][$name] ?? null; } /** @@ -415,7 +415,7 @@ public function setDefaultRepositoryClassName(string $className): void throw InvalidEntityRepository::fromClassName($className); } - $this->_attributes['defaultRepositoryClassName'] = $className; + $this->attributes['defaultRepositoryClassName'] = $className; } /** @@ -425,7 +425,7 @@ public function setDefaultRepositoryClassName(string $className): void */ public function getDefaultRepositoryClassName(): string { - return $this->_attributes['defaultRepositoryClassName'] ?? EntityRepository::class; + return $this->attributes['defaultRepositoryClassName'] ?? EntityRepository::class; } /** @@ -433,7 +433,7 @@ public function getDefaultRepositoryClassName(): string */ public function setNamingStrategy(NamingStrategy $namingStrategy): void { - $this->_attributes['namingStrategy'] = $namingStrategy; + $this->attributes['namingStrategy'] = $namingStrategy; } /** @@ -441,11 +441,11 @@ public function setNamingStrategy(NamingStrategy $namingStrategy): void */ public function getNamingStrategy(): NamingStrategy { - if (! isset($this->_attributes['namingStrategy'])) { - $this->_attributes['namingStrategy'] = new DefaultNamingStrategy(); + if (! isset($this->attributes['namingStrategy'])) { + $this->attributes['namingStrategy'] = new DefaultNamingStrategy(); } - return $this->_attributes['namingStrategy']; + return $this->attributes['namingStrategy']; } /** @@ -453,7 +453,7 @@ public function getNamingStrategy(): NamingStrategy */ public function setQuoteStrategy(QuoteStrategy $quoteStrategy): void { - $this->_attributes['quoteStrategy'] = $quoteStrategy; + $this->attributes['quoteStrategy'] = $quoteStrategy; } /** @@ -461,11 +461,11 @@ public function setQuoteStrategy(QuoteStrategy $quoteStrategy): void */ public function getQuoteStrategy(): QuoteStrategy { - if (! isset($this->_attributes['quoteStrategy'])) { - $this->_attributes['quoteStrategy'] = new DefaultQuoteStrategy(); + if (! isset($this->attributes['quoteStrategy'])) { + $this->attributes['quoteStrategy'] = new DefaultQuoteStrategy(); } - return $this->_attributes['quoteStrategy']; + return $this->attributes['quoteStrategy']; } /** @@ -473,7 +473,7 @@ public function getQuoteStrategy(): QuoteStrategy */ public function setEntityListenerResolver(EntityListenerResolver $resolver): void { - $this->_attributes['entityListenerResolver'] = $resolver; + $this->attributes['entityListenerResolver'] = $resolver; } /** @@ -481,11 +481,11 @@ public function setEntityListenerResolver(EntityListenerResolver $resolver): voi */ public function getEntityListenerResolver(): EntityListenerResolver { - if (! isset($this->_attributes['entityListenerResolver'])) { - $this->_attributes['entityListenerResolver'] = new DefaultEntityListenerResolver(); + if (! isset($this->attributes['entityListenerResolver'])) { + $this->attributes['entityListenerResolver'] = new DefaultEntityListenerResolver(); } - return $this->_attributes['entityListenerResolver']; + return $this->attributes['entityListenerResolver']; } /** @@ -493,7 +493,7 @@ public function getEntityListenerResolver(): EntityListenerResolver */ public function setRepositoryFactory(RepositoryFactory $repositoryFactory): void { - $this->_attributes['repositoryFactory'] = $repositoryFactory; + $this->attributes['repositoryFactory'] = $repositoryFactory; } /** @@ -501,31 +501,31 @@ public function setRepositoryFactory(RepositoryFactory $repositoryFactory): void */ public function getRepositoryFactory(): RepositoryFactory { - return $this->_attributes['repositoryFactory'] ?? new DefaultRepositoryFactory(); + return $this->attributes['repositoryFactory'] ?? new DefaultRepositoryFactory(); } public function isSecondLevelCacheEnabled(): bool { - return $this->_attributes['isSecondLevelCacheEnabled'] ?? false; + return $this->attributes['isSecondLevelCacheEnabled'] ?? false; } public function setSecondLevelCacheEnabled(bool $flag = true): void { - $this->_attributes['isSecondLevelCacheEnabled'] = $flag; + $this->attributes['isSecondLevelCacheEnabled'] = $flag; } public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig): void { - $this->_attributes['secondLevelCacheConfiguration'] = $cacheConfig; + $this->attributes['secondLevelCacheConfiguration'] = $cacheConfig; } public function getSecondLevelCacheConfiguration(): CacheConfiguration|null { - if (! isset($this->_attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) { - $this->_attributes['secondLevelCacheConfiguration'] = new CacheConfiguration(); + if (! isset($this->attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) { + $this->attributes['secondLevelCacheConfiguration'] = new CacheConfiguration(); } - return $this->_attributes['secondLevelCacheConfiguration'] ?? null; + return $this->attributes['secondLevelCacheConfiguration'] ?? null; } /** @@ -535,7 +535,7 @@ public function getSecondLevelCacheConfiguration(): CacheConfiguration|null */ public function getDefaultQueryHints(): array { - return $this->_attributes['defaultQueryHints'] ?? []; + return $this->attributes['defaultQueryHints'] ?? []; } /** @@ -545,7 +545,7 @@ public function getDefaultQueryHints(): array */ public function setDefaultQueryHints(array $defaultQueryHints): void { - $this->_attributes['defaultQueryHints'] = $defaultQueryHints; + $this->attributes['defaultQueryHints'] = $defaultQueryHints; } /** @@ -555,7 +555,7 @@ public function setDefaultQueryHints(array $defaultQueryHints): void */ public function getDefaultQueryHint(string $name): mixed { - return $this->_attributes['defaultQueryHints'][$name] ?? false; + return $this->attributes['defaultQueryHints'][$name] ?? false; } /** @@ -563,7 +563,7 @@ public function getDefaultQueryHint(string $name): mixed */ public function setDefaultQueryHint(string $name, mixed $value): void { - $this->_attributes['defaultQueryHints'][$name] = $value; + $this->attributes['defaultQueryHints'][$name] = $value; } /** @@ -573,7 +573,7 @@ public function setDefaultQueryHint(string $name, mixed $value): void */ public function getSchemaIgnoreClasses(): array { - return $this->_attributes['schemaIgnoreClasses'] ?? []; + return $this->attributes['schemaIgnoreClasses'] ?? []; } /** @@ -583,12 +583,12 @@ public function getSchemaIgnoreClasses(): array */ public function setSchemaIgnoreClasses(array $schemaIgnoreClasses): void { - $this->_attributes['schemaIgnoreClasses'] = $schemaIgnoreClasses; + $this->attributes['schemaIgnoreClasses'] = $schemaIgnoreClasses; } public function isLazyGhostObjectEnabled(): bool { - return $this->_attributes['isLazyGhostObjectEnabled'] ?? false; + return $this->attributes['isLazyGhostObjectEnabled'] ?? false; } public function setLazyGhostObjectEnabled(bool $flag): void @@ -607,6 +607,6 @@ public function setLazyGhostObjectEnabled(bool $flag): void ); } - $this->_attributes['isLazyGhostObjectEnabled'] = $flag; + $this->attributes['isLazyGhostObjectEnabled'] = $flag; } } diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index cd77aa532b8..67eb4bcf137 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -34,54 +34,52 @@ abstract class AbstractHydrator /** * The ResultSetMapping. */ - protected ResultSetMapping|null $_rsm = null; + protected ResultSetMapping|null $rsm = null; /** * The dbms Platform instance. */ - protected AbstractPlatform $_platform; + protected AbstractPlatform $platform; /** * The UnitOfWork of the associated EntityManager. */ - protected UnitOfWork $_uow; + protected UnitOfWork $uow; /** * Local ClassMetadata cache to avoid going to the EntityManager all the time. * * @var array> */ - protected array $_metadataCache = []; + protected array $metadataCache = []; /** * The cache used during row-by-row hydration. * * @var array */ - protected array $_cache = []; + protected array $cache = []; /** * The statement that provides the data to hydrate. */ - protected Result|null $_stmt = null; + protected Result|null $stmt = null; /** * The query hints. * * @var array */ - protected array $_hints = []; - - protected EntityManagerInterface $_em; + protected array $hints = []; /** * Initializes a new instance of a class derived from AbstractHydrator. */ public function __construct(protected EntityManagerInterface $em) { - $this->_em = $em; - $this->_platform = $em->getConnection()->getDatabasePlatform(); - $this->_uow = $em->getUnitOfWork(); + $this->em = $em; + $this->platform = $em->getConnection()->getDatabasePlatform(); + $this->uow = $em->getUnitOfWork(); } /** @@ -95,11 +93,11 @@ public function __construct(protected EntityManagerInterface $em) */ final public function toIterable(Result $stmt, ResultSetMapping $resultSetMapping, array $hints = []): Generator { - $this->_stmt = $stmt; - $this->_rsm = $resultSetMapping; - $this->_hints = $hints; + $this->stmt = $stmt; + $this->rsm = $resultSetMapping; + $this->hints = $hints; - $evm = $this->_em->getEventManager(); + $evm = $this->em->getEventManager(); $evm->addEventListener([Events::onClear], $this); @@ -133,20 +131,20 @@ final public function toIterable(Result $stmt, ResultSetMapping $resultSetMappin final protected function statement(): Result { - if ($this->_stmt === null) { + if ($this->stmt === null) { throw new LogicException('Uninitialized _stmt property'); } - return $this->_stmt; + return $this->stmt; } final protected function resultSetMapping(): ResultSetMapping { - if ($this->_rsm === null) { + if ($this->rsm === null) { throw new LogicException('Uninitialized _rsm property'); } - return $this->_rsm; + return $this->rsm; } /** @@ -156,11 +154,11 @@ final protected function resultSetMapping(): ResultSetMapping */ public function hydrateAll(Result $stmt, ResultSetMapping $resultSetMapping, array $hints = []): mixed { - $this->_stmt = $stmt; - $this->_rsm = $resultSetMapping; - $this->_hints = $hints; + $this->stmt = $stmt; + $this->rsm = $resultSetMapping; + $this->hints = $hints; - $this->_em->getEventManager()->addEventListener([Events::onClear], $this); + $this->em->getEventManager()->addEventListener([Events::onClear], $this); $this->prepare(); try { @@ -196,13 +194,13 @@ protected function cleanup(): void { $this->statement()->free(); - $this->_stmt = null; - $this->_rsm = null; - $this->_cache = []; - $this->_metadataCache = []; + $this->stmt = null; + $this->rsm = null; + $this->cache = []; + $this->metadataCache = []; $this - ->_em + ->em ->getEventManager() ->removeEventListener([Events::onClear], $this); } @@ -274,7 +272,7 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon $argIndex = $cacheKeyInfo['argIndex']; $objIndex = $cacheKeyInfo['objIndex']; $type = $cacheKeyInfo['type']; - $value = $type->convertToPHPValue($value, $this->_platform); + $value = $type->convertToPHPValue($value, $this->platform); if ($value !== null && isset($cacheKeyInfo['enumType'])) { $value = $this->buildEnum($value, $cacheKeyInfo['enumType']); @@ -286,7 +284,7 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon case isset($cacheKeyInfo['isScalar']): $type = $cacheKeyInfo['type']; - $value = $type->convertToPHPValue($value, $this->_platform); + $value = $type->convertToPHPValue($value, $this->platform); if ($value !== null && isset($cacheKeyInfo['enumType'])) { $value = $this->buildEnum($value, $cacheKeyInfo['enumType']); @@ -318,7 +316,7 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon } $rowData['data'][$dqlAlias][$fieldName] = $type - ? $type->convertToPHPValue($value, $this->_platform) + ? $type->convertToPHPValue($value, $this->platform) : $value; if ($rowData['data'][$dqlAlias][$fieldName] !== null && isset($cacheKeyInfo['enumType'])) { @@ -367,7 +365,7 @@ protected function gatherScalarRowData(array &$data): array // erroneous behavior exists since 2.0 and we're forced to keep compatibility. if (! isset($cacheKeyInfo['isScalar'])) { $type = $cacheKeyInfo['type']; - $value = $type ? $type->convertToPHPValue($value, $this->_platform) : $value; + $value = $type ? $type->convertToPHPValue($value, $this->platform) : $value; $fieldName = $cacheKeyInfo['dqlAlias'] . '_' . $fieldName; } @@ -388,89 +386,89 @@ protected function gatherScalarRowData(array &$data): array */ protected function hydrateColumnInfo(string $key): array|null { - if (isset($this->_cache[$key])) { - return $this->_cache[$key]; + if (isset($this->cache[$key])) { + return $this->cache[$key]; } switch (true) { // NOTE: Most of the times it's a field mapping, so keep it first!!! - case isset($this->_rsm->fieldMappings[$key]): - $classMetadata = $this->getClassMetadata($this->_rsm->declaringClasses[$key]); - $fieldName = $this->_rsm->fieldMappings[$key]; + case isset($this->rsm->fieldMappings[$key]): + $classMetadata = $this->getClassMetadata($this->rsm->declaringClasses[$key]); + $fieldName = $this->rsm->fieldMappings[$key]; $fieldMapping = $classMetadata->fieldMappings[$fieldName]; - $ownerMap = $this->_rsm->columnOwnerMap[$key]; + $ownerMap = $this->rsm->columnOwnerMap[$key]; $columnInfo = [ 'isIdentifier' => in_array($fieldName, $classMetadata->identifier, true), 'fieldName' => $fieldName, 'type' => Type::getType($fieldMapping['type']), 'dqlAlias' => $ownerMap, - 'enumType' => $this->_rsm->enumMappings[$key] ?? null, + 'enumType' => $this->rsm->enumMappings[$key] ?? null, ]; // the current discriminator value must be saved in order to disambiguate fields hydration, // should there be field name collisions - if ($classMetadata->parentClasses && isset($this->_rsm->discriminatorColumns[$ownerMap])) { - return $this->_cache[$key] = array_merge( + if ($classMetadata->parentClasses && isset($this->rsm->discriminatorColumns[$ownerMap])) { + return $this->cache[$key] = array_merge( $columnInfo, [ - 'discriminatorColumn' => $this->_rsm->discriminatorColumns[$ownerMap], + 'discriminatorColumn' => $this->rsm->discriminatorColumns[$ownerMap], 'discriminatorValue' => $classMetadata->discriminatorValue, 'discriminatorValues' => $this->getDiscriminatorValues($classMetadata), ], ); } - return $this->_cache[$key] = $columnInfo; + return $this->cache[$key] = $columnInfo; - case isset($this->_rsm->newObjectMappings[$key]): + case isset($this->rsm->newObjectMappings[$key]): // WARNING: A NEW object is also a scalar, so it must be declared before! - $mapping = $this->_rsm->newObjectMappings[$key]; + $mapping = $this->rsm->newObjectMappings[$key]; - return $this->_cache[$key] = [ + return $this->cache[$key] = [ 'isScalar' => true, 'isNewObjectParameter' => true, - 'fieldName' => $this->_rsm->scalarMappings[$key], - 'type' => Type::getType($this->_rsm->typeMappings[$key]), + 'fieldName' => $this->rsm->scalarMappings[$key], + 'type' => Type::getType($this->rsm->typeMappings[$key]), 'argIndex' => $mapping['argIndex'], 'objIndex' => $mapping['objIndex'], 'class' => new ReflectionClass($mapping['className']), - 'enumType' => $this->_rsm->enumMappings[$key] ?? null, + 'enumType' => $this->rsm->enumMappings[$key] ?? null, ]; - case isset($this->_rsm->scalarMappings[$key], $this->_hints[LimitSubqueryWalker::FORCE_DBAL_TYPE_CONVERSION]): - return $this->_cache[$key] = [ - 'fieldName' => $this->_rsm->scalarMappings[$key], - 'type' => Type::getType($this->_rsm->typeMappings[$key]), + case isset($this->rsm->scalarMappings[$key], $this->hints[LimitSubqueryWalker::FORCE_DBAL_TYPE_CONVERSION]): + return $this->cache[$key] = [ + 'fieldName' => $this->rsm->scalarMappings[$key], + 'type' => Type::getType($this->rsm->typeMappings[$key]), 'dqlAlias' => '', - 'enumType' => $this->_rsm->enumMappings[$key] ?? null, + 'enumType' => $this->rsm->enumMappings[$key] ?? null, ]; - case isset($this->_rsm->scalarMappings[$key]): - return $this->_cache[$key] = [ + case isset($this->rsm->scalarMappings[$key]): + return $this->cache[$key] = [ 'isScalar' => true, - 'fieldName' => $this->_rsm->scalarMappings[$key], - 'type' => Type::getType($this->_rsm->typeMappings[$key]), - 'enumType' => $this->_rsm->enumMappings[$key] ?? null, + 'fieldName' => $this->rsm->scalarMappings[$key], + 'type' => Type::getType($this->rsm->typeMappings[$key]), + 'enumType' => $this->rsm->enumMappings[$key] ?? null, ]; - case isset($this->_rsm->metaMappings[$key]): + case isset($this->rsm->metaMappings[$key]): // Meta column (has meaning in relational schema only, i.e. foreign keys or discriminator columns). - $fieldName = $this->_rsm->metaMappings[$key]; - $dqlAlias = $this->_rsm->columnOwnerMap[$key]; - $type = isset($this->_rsm->typeMappings[$key]) - ? Type::getType($this->_rsm->typeMappings[$key]) + $fieldName = $this->rsm->metaMappings[$key]; + $dqlAlias = $this->rsm->columnOwnerMap[$key]; + $type = isset($this->rsm->typeMappings[$key]) + ? Type::getType($this->rsm->typeMappings[$key]) : null; // Cache metadata fetch - $this->getClassMetadata($this->_rsm->aliasMap[$dqlAlias]); + $this->getClassMetadata($this->rsm->aliasMap[$dqlAlias]); - return $this->_cache[$key] = [ - 'isIdentifier' => isset($this->_rsm->isIdentifierColumn[$dqlAlias][$key]), + return $this->cache[$key] = [ + 'isIdentifier' => isset($this->rsm->isIdentifierColumn[$dqlAlias][$key]), 'isMetaColumn' => true, 'fieldName' => $fieldName, 'type' => $type, 'dqlAlias' => $dqlAlias, - 'enumType' => $this->_rsm->enumMappings[$key] ?? null, + 'enumType' => $this->rsm->enumMappings[$key] ?? null, ]; } @@ -500,11 +498,11 @@ private function getDiscriminatorValues(ClassMetadata $classMetadata): array */ protected function getClassMetadata(string $className): ClassMetadata { - if (! isset($this->_metadataCache[$className])) { - $this->_metadataCache[$className] = $this->_em->getClassMetadata($className); + if (! isset($this->metadataCache[$className])) { + $this->metadataCache[$className] = $this->em->getClassMetadata($className); } - return $this->_metadataCache[$className]; + return $this->metadataCache[$className]; } /** @@ -533,7 +531,7 @@ protected function registerManaged(ClassMetadata $class, object $entity, array $ ]; } - $this->_em->getUnitOfWork()->registerManaged($entity, $id, $data); + $this->em->getUnitOfWork()->registerManaged($entity, $id, $data); } /** diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index 8cd58b351a4..baf8a26cfa5 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -99,7 +99,7 @@ protected function hydrateRowData(array $row, array &$result): void } $relationAlias = $this->resultSetMapping()->relationMap[$dqlAlias]; - $parentClass = $this->_metadataCache[$this->resultSetMapping()->aliasMap[$parent]]; + $parentClass = $this->metadataCache[$this->resultSetMapping()->aliasMap[$parent]]; $relation = $parentClass->associationMappings[$relationAlias]; // Check the type of the relation (many or single-valued) diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 6dd8adee66d..721ac80fb1e 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -52,8 +52,8 @@ class ObjectHydrator extends AbstractHydrator protected function prepare(): void { - if (! isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD])) { - $this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] = true; + if (! isset($this->hints[UnitOfWork::HINT_DEFEREAGERLOAD])) { + $this->hints[UnitOfWork::HINT_DEFEREAGERLOAD] = true; } foreach ($this->resultSetMapping()->aliasMap as $dqlAlias => $className) { @@ -76,7 +76,7 @@ protected function prepare(): void $sourceClass = $this->getClassMetadata($sourceClassName); $assoc = $sourceClass->associationMappings[$this->resultSetMapping()->relationMap[$dqlAlias]]; - $this->_hints['fetched'][$parent][$assoc['fieldName']] = true; + $this->hints['fetched'][$parent][$assoc['fieldName']] = true; if ($assoc['type'] === ClassMetadata::MANY_TO_MANY) { continue; @@ -84,7 +84,7 @@ protected function prepare(): void // Mark any non-collection opposite sides as fetched, too. if ($assoc['mappedBy']) { - $this->_hints['fetched'][$dqlAlias][$assoc['mappedBy']] = true; + $this->hints['fetched'][$dqlAlias][$assoc['mappedBy']] = true; continue; } @@ -98,14 +98,14 @@ protected function prepare(): void continue; } - $this->_hints['fetched'][$dqlAlias][$inverseAssoc['fieldName']] = true; + $this->hints['fetched'][$dqlAlias][$inverseAssoc['fieldName']] = true; } } } protected function cleanup(): void { - $eagerLoad = isset($this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD]) && $this->_hints[UnitOfWork::HINT_DEFEREAGERLOAD] === true; + $eagerLoad = isset($this->hints[UnitOfWork::HINT_DEFEREAGERLOAD]) && $this->hints[UnitOfWork::HINT_DEFEREAGERLOAD] === true; parent::cleanup(); @@ -116,10 +116,10 @@ protected function cleanup(): void $this->resultPointers = []; if ($eagerLoad) { - $this->_uow->triggerEagerLoads(); + $this->uow->triggerEagerLoads(); } - $this->_uow->hydrationComplete(); + $this->uow->hydrationComplete(); } protected function cleanupAfterRowIteration(): void @@ -178,19 +178,19 @@ private function initRelatedCollection( if (! $value instanceof PersistentCollection) { $value = new PersistentCollection( - $this->_em, - $this->_metadataCache[$relation['targetEntity']], + $this->em, + $this->metadataCache[$relation['targetEntity']], $value, ); $value->setOwner($entity, $relation); $class->reflFields[$fieldName]->setValue($entity, $value); - $this->_uow->setOriginalEntityProperty($oid, $fieldName, $value); + $this->uow->setOriginalEntityProperty($oid, $fieldName, $value); $this->initializedCollections[$oid . $fieldName] = $value; } elseif ( - isset($this->_hints[Query::HINT_REFRESH]) || - isset($this->_hints['fetched'][$parentDqlAlias][$fieldName]) && + isset($this->hints[Query::HINT_REFRESH]) || + isset($this->hints['fetched'][$parentDqlAlias][$fieldName]) && ! $value->isInitialized() ) { // Is already PersistentCollection, but either REFRESH or FETCH-JOIN and UNINITIALIZED! @@ -236,7 +236,7 @@ private function getEntity(array $data, string $dqlAlias): object throw HydrationException::emptyDiscriminatorValue($dqlAlias); } - $discrMap = $this->_metadataCache[$className]->discriminatorMap; + $discrMap = $this->metadataCache[$className]->discriminatorMap; $discriminatorValue = $data[$discrColumn]; if ($discriminatorValue instanceof BackedEnum) { $discriminatorValue = $discriminatorValue->value; @@ -253,13 +253,13 @@ private function getEntity(array $data, string $dqlAlias): object unset($data[$discrColumn]); } - if (isset($this->_hints[Query::HINT_REFRESH_ENTITY], $this->rootAliases[$dqlAlias])) { - $this->registerManaged($this->_metadataCache[$className], $this->_hints[Query::HINT_REFRESH_ENTITY], $data); + if (isset($this->hints[Query::HINT_REFRESH_ENTITY], $this->rootAliases[$dqlAlias])) { + $this->registerManaged($this->metadataCache[$className], $this->hints[Query::HINT_REFRESH_ENTITY], $data); } - $this->_hints['fetchAlias'] = $dqlAlias; + $this->hints['fetchAlias'] = $dqlAlias; - return $this->_uow->createEntity($className, $data, $this->_hints); + return $this->uow->createEntity($className, $data, $this->hints); } /** @@ -269,7 +269,7 @@ private function getEntity(array $data, string $dqlAlias): object private function getEntityFromIdentityMap(string $className, array $data): object|bool { // TODO: Abstract this code and UnitOfWork::createEntity() equivalent? - $class = $this->_metadataCache[$className]; + $class = $this->metadataCache[$className]; if ($class->isIdentifierComposite) { $idHash = ''; @@ -280,12 +280,12 @@ private function getEntityFromIdentityMap(string $className, array $data): objec : $data[$fieldName]); } - return $this->_uow->tryGetByIdHash(ltrim($idHash), $class->rootEntityName); + return $this->uow->tryGetByIdHash(ltrim($idHash), $class->rootEntityName); } elseif (isset($class->associationMappings[$class->identifier[0]])) { - return $this->_uow->tryGetByIdHash($data[$class->associationMappings[$class->identifier[0]]['joinColumns'][0]['name']], $class->rootEntityName); + return $this->uow->tryGetByIdHash($data[$class->associationMappings[$class->identifier[0]]['joinColumns'][0]['name']], $class->rootEntityName); } - return $this->_uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName); + return $this->uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName); } /** @@ -337,7 +337,7 @@ protected function hydrateRowData(array $row, array &$result): void continue; } - $parentClass = $this->_metadataCache[$this->resultSetMapping()->aliasMap[$parentAlias]]; + $parentClass = $this->metadataCache[$this->resultSetMapping()->aliasMap[$parentAlias]]; $relationField = $this->resultSetMapping()->relationMap[$dqlAlias]; $relation = $parentClass->associationMappings[$relationField]; $reflField = $parentClass->reflFields[$relationField]; @@ -357,7 +357,7 @@ protected function hydrateRowData(array $row, array &$result): void $rowData['data'][$parentAlias][$relationField] = $element; // Mark as not-fetched again - unset($this->_hints['fetched'][$parentAlias][$relationField]); + unset($this->hints['fetched'][$parentAlias][$relationField]); continue; } @@ -421,14 +421,14 @@ protected function hydrateRowData(array $row, array &$result): void // PATH B: Single-valued association $reflFieldValue = $reflField->getValue($parentObject); - if (! $reflFieldValue || isset($this->_hints[Query::HINT_REFRESH]) || ($reflFieldValue instanceof Proxy && ! $reflFieldValue->__isInitialized())) { + if (! $reflFieldValue || isset($this->hints[Query::HINT_REFRESH]) || ($reflFieldValue instanceof Proxy && ! $reflFieldValue->__isInitialized())) { // we only need to take action if this value is null, // we refresh the entity or its an uninitialized proxy. if (isset($nonemptyComponents[$dqlAlias])) { $element = $this->getEntity($data, $dqlAlias); $reflField->setValue($parentObject, $element); - $this->_uow->setOriginalEntityProperty($oid, $relationField, $element); - $targetClass = $this->_metadataCache[$relation['targetEntity']]; + $this->uow->setOriginalEntityProperty($oid, $relationField, $element); + $targetClass = $this->metadataCache[$relation['targetEntity']]; if ($relation['isOwningSide']) { // TODO: Just check hints['fetched'] here? @@ -437,7 +437,7 @@ protected function hydrateRowData(array $row, array &$result): void $inverseAssoc = $targetClass->associationMappings[$relation['inversedBy']]; if ($inverseAssoc['type'] & ClassMetadata::TO_ONE) { $targetClass->reflFields[$inverseAssoc['fieldName']]->setValue($element, $parentObject); - $this->_uow->setOriginalEntityProperty(spl_object_id($element), $inverseAssoc['fieldName'], $parentObject); + $this->uow->setOriginalEntityProperty(spl_object_id($element), $inverseAssoc['fieldName'], $parentObject); } } elseif ($parentClass === $targetClass && $relation['mappedBy']) { // Special case: bi-directional self-referencing one-one on the same class @@ -446,13 +446,13 @@ protected function hydrateRowData(array $row, array &$result): void } else { // For sure bidirectional, as there is no inverse side in unidirectional mappings $targetClass->reflFields[$relation['mappedBy']]->setValue($element, $parentObject); - $this->_uow->setOriginalEntityProperty(spl_object_id($element), $relation['mappedBy'], $parentObject); + $this->uow->setOriginalEntityProperty(spl_object_id($element), $relation['mappedBy'], $parentObject); } // Update result pointer $this->resultPointers[$dqlAlias] = $element; } else { - $this->_uow->setOriginalEntityProperty($oid, $relationField, null); + $this->uow->setOriginalEntityProperty($oid, $relationField, null); $reflField->setValue($parentObject, null); } // else leave $reflFieldValue null for single-valued associations @@ -490,8 +490,8 @@ protected function hydrateRowData(array $row, array &$result): void if (isset($this->resultSetMapping()->indexByMap[$dqlAlias])) { $resultKey = $row[$this->resultSetMapping()->indexByMap[$dqlAlias]]; - if (isset($this->_hints['collection'])) { - $this->_hints['collection']->hydrateSet($resultKey, $element); + if (isset($this->hints['collection'])) { + $this->hints['collection']->hydrateSet($resultKey, $element); } $result[$resultKey] = $element; @@ -499,8 +499,8 @@ protected function hydrateRowData(array $row, array &$result): void $resultKey = $this->resultCounter; ++$this->resultCounter; - if (isset($this->_hints['collection'])) { - $this->_hints['collection']->hydrateAdd($element); + if (isset($this->hints['collection'])) { + $this->hints['collection']->hydrateAdd($element); } $result[] = $element; @@ -518,8 +518,8 @@ protected function hydrateRowData(array $row, array &$result): void } } - if (isset($this->_hints[Query::HINT_INTERNAL_ITERATION]) && $this->_hints[Query::HINT_INTERNAL_ITERATION]) { - $this->_uow->hydrationComplete(); + if (isset($this->hints[Query::HINT_INTERNAL_ITERATION]) && $this->hints[Query::HINT_INTERNAL_ITERATION]) { + $this->uow->hydrationComplete(); } } diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 07d8f0eeffa..0c1e32aa149 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -44,8 +44,8 @@ protected function cleanup(): void { parent::cleanup(); - $this->_uow->triggerEagerLoads(); - $this->_uow->hydrationComplete(); + $this->uow->triggerEagerLoads(); + $this->uow->hydrationComplete(); } /** @@ -59,7 +59,7 @@ protected function hydrateAllData(): array $this->hydrateRowData($row, $result); } - $this->_em->getUnitOfWork()->triggerEagerLoads(); + $this->em->getUnitOfWork()->triggerEagerLoads(); return $result; } @@ -77,7 +77,7 @@ protected function hydrateRowData(array $row, array &$result): void // We need to find the correct entity class name if we have inheritance in resultset if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { $discrColumn = $this->class->getDiscriminatorColumn(); - $discrColumnName = $this->getSQLResultCasing($this->_platform, $discrColumn['name']); + $discrColumnName = $this->getSQLResultCasing($this->platform, $discrColumn['name']); // Find mapped discriminator column from the result set. $metaMappingDiscrColumnName = array_search($discrColumnName, $this->resultSetMapping()->metaMappings, true); @@ -134,7 +134,7 @@ protected function hydrateRowData(array $row, array &$result): void // Convert field to a valid PHP value if (isset($cacheKeyInfo['type'])) { $type = $cacheKeyInfo['type']; - $value = $type->convertToPHPValue($value, $this->_platform); + $value = $type->convertToPHPValue($value, $this->platform); } if ($value !== null && isset($cacheKeyInfo['enumType'])) { @@ -160,17 +160,17 @@ protected function hydrateRowData(array $row, array &$result): void } } - if (isset($this->_hints[Query::HINT_REFRESH_ENTITY])) { - $this->registerManaged($this->class, $this->_hints[Query::HINT_REFRESH_ENTITY], $data); + if (isset($this->hints[Query::HINT_REFRESH_ENTITY])) { + $this->registerManaged($this->class, $this->hints[Query::HINT_REFRESH_ENTITY], $data); } - $uow = $this->_em->getUnitOfWork(); - $entity = $uow->createEntity($entityName, $data, $this->_hints); + $uow = $this->em->getUnitOfWork(); + $entity = $uow->createEntity($entityName, $data, $this->hints); $result[] = $entity; - if (isset($this->_hints[Query::HINT_INTERNAL_ITERATION]) && $this->_hints[Query::HINT_INTERNAL_ITERATION]) { - $this->_uow->hydrationComplete(); + if (isset($this->hints[Query::HINT_INTERNAL_ITERATION]) && $this->hints[Query::HINT_INTERNAL_ITERATION]) { + $this->uow->hydrationComplete(); } } } diff --git a/lib/Doctrine/ORM/NativeQuery.php b/lib/Doctrine/ORM/NativeQuery.php index f76e427797c..d633e57c156 100644 --- a/lib/Doctrine/ORM/NativeQuery.php +++ b/lib/Doctrine/ORM/NativeQuery.php @@ -60,7 +60,7 @@ protected function _doExecute(): Result|int $this->sql, $parameters, $types, - $this->_queryCacheProfile, + $this->queryCacheProfile, ); } } diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 9a24634a225..5a2bc0f0533 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -187,11 +187,11 @@ public function getAST(): SelectStatement|UpdateStatement|DeleteStatement protected function getResultSetMapping(): ResultSetMapping { // parse query or load from cache - if ($this->_resultSetMapping === null) { - $this->_resultSetMapping = $this->parse()->getResultSetMapping(); + if ($this->resultSetMapping === null) { + $this->resultSetMapping = $this->parse()->getResultSetMapping(); } - return $this->_resultSetMapping; + return $this->resultSetMapping; } /** @@ -252,14 +252,14 @@ protected function _doExecute(): Result|int { $executor = $this->parse()->getSqlExecutor(); - if ($this->_queryCacheProfile) { - $executor->setQueryCacheProfile($this->_queryCacheProfile); + if ($this->queryCacheProfile) { + $executor->setQueryCacheProfile($this->queryCacheProfile); } else { $executor->removeQueryCacheProfile(); } - if ($this->_resultSetMapping === null) { - $this->_resultSetMapping = $this->parserResult->getResultSetMapping(); + if ($this->resultSetMapping === null) { + $this->resultSetMapping = $this->parserResult->getResultSetMapping(); } // Prepare parameters @@ -276,7 +276,7 @@ protected function _doExecute(): Result|int } // evict all cache for the entity region - if ($this->hasCache && isset($this->_hints[self::HINT_CACHE_EVICT]) && $this->_hints[self::HINT_CACHE_EVICT]) { + if ($this->hasCache && isset($this->hints[self::HINT_CACHE_EVICT]) && $this->hints[self::HINT_CACHE_EVICT]) { $this->evictEntityCacheRegion(); } @@ -303,18 +303,18 @@ private function evictResultSetCache( array $types, array $connectionParams, ): void { - if ($this->_queryCacheProfile === null || ! $this->getExpireResultCache()) { + if ($this->queryCacheProfile === null || ! $this->getExpireResultCache()) { return; } - $cache = $this->_queryCacheProfile->getResultCache(); + $cache = $this->queryCacheProfile->getResultCache(); assert($cache !== null); $statements = (array) $executor->getSqlStatements(); // Type casted since it can either be a string or an array foreach ($statements as $statement) { - $cacheKeys = $this->_queryCacheProfile->generateCacheKeys($statement, $sqlParams, $types, $connectionParams); + $cacheKeys = $this->queryCacheProfile->generateCacheKeys($statement, $sqlParams, $types, $connectionParams); $cache->deleteItem(reset($cacheKeys)); } } @@ -684,14 +684,14 @@ public function getLockMode(): int|null */ protected function getQueryCacheId(): string { - ksort($this->_hints); + ksort($this->hints); return md5( - $this->getDQL() . serialize($this->_hints) . + $this->getDQL() . serialize($this->hints) . '&platform=' . get_debug_type($this->getEntityManager()->getConnection()->getDatabasePlatform()) . ($this->em->hasFilters() ? $this->em->getFilters()->getHash() : '') . '&firstResult=' . $this->firstResult . '&maxResult=' . $this->maxResults . - '&hydrationMode=' . $this->_hydrationMode . '&types=' . serialize($this->parsedTypes) . 'DOCTRINE_QUERY_CACHE_SALT', + '&hydrationMode=' . $this->hydrationMode . '&types=' . serialize($this->parsedTypes) . 'DOCTRINE_QUERY_CACHE_SALT', ); } diff --git a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php index 6d207253d5b..0820b859a9c 100644 --- a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php @@ -19,7 +19,7 @@ abstract class AbstractSqlExecutor { /** @var list|string */ - protected array|string $_sqlStatements; + protected array|string $sqlStatements; protected QueryCacheProfile|null $queryCacheProfile; @@ -30,7 +30,7 @@ abstract class AbstractSqlExecutor */ public function getSqlStatements(): array|string { - return $this->_sqlStatements; + return $this->sqlStatements; } public function setQueryCacheProfile(QueryCacheProfile $qcp): void diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php index 373a05d7ff9..6096462c7d9 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php @@ -79,8 +79,8 @@ public function __construct(AST\Node $AST, SqlWalker $sqlWalker) // 3. Create and store DELETE statements $classNames = [...$primaryClass->parentClasses, ...[$primaryClass->name], ...$primaryClass->subClasses]; foreach (array_reverse($classNames) as $className) { - $tableName = $quoteStrategy->getTableName($em->getClassMetadata($className), $platform); - $this->_sqlStatements[] = 'DELETE FROM ' . $tableName + $tableName = $quoteStrategy->getTableName($em->getClassMetadata($className), $platform); + $this->sqlStatements[] = 'DELETE FROM ' . $tableName . ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')'; } @@ -112,7 +112,7 @@ public function execute(Connection $conn, array $params, array $types): int $numDeleted = $conn->executeStatement($this->insertSql, $params, $types); // Execute DELETE statements - foreach ($this->_sqlStatements as $sql) { + foreach ($this->sqlStatements as $sql) { $conn->executeStatement($sql); } } catch (Throwable $exception) { diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php index 2079c3007e1..dd5f3055d58 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -111,7 +111,7 @@ public function __construct(AST\Node $AST, SqlWalker $sqlWalker) } if ($affected) { - $this->_sqlStatements[$i] = $updateSql . ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')'; + $this->sqlStatements[$i] = $updateSql . ' WHERE (' . $idColumnList . ') IN (' . $idSubselect . ')'; } } @@ -156,7 +156,7 @@ public function execute(Connection $conn, array $params, array $types): int ); // Execute UPDATE statements - foreach ($this->_sqlStatements as $key => $statement) { + foreach ($this->sqlStatements as $key => $statement) { $paramValues = []; $paramTypes = []; diff --git a/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php b/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php index 9220922e5af..5445edb9994 100644 --- a/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php @@ -18,7 +18,7 @@ class SingleSelectExecutor extends AbstractSqlExecutor { public function __construct(SelectStatement $AST, SqlWalker $sqlWalker) { - $this->_sqlStatements = $sqlWalker->walkSelectStatement($AST); + $this->sqlStatements = $sqlWalker->walkSelectStatement($AST); } /** @@ -26,6 +26,6 @@ public function __construct(SelectStatement $AST, SqlWalker $sqlWalker) */ public function execute(Connection $conn, array $params, array $types): Result { - return $conn->executeQuery($this->_sqlStatements, $params, $types, $this->queryCacheProfile); + return $conn->executeQuery($this->sqlStatements, $params, $types, $this->queryCacheProfile); } } diff --git a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php index 55ddb7f9339..7252684f280 100644 --- a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php @@ -23,9 +23,9 @@ class SingleTableDeleteUpdateExecutor extends AbstractSqlExecutor public function __construct(AST\Node $AST, $sqlWalker) { if ($AST instanceof AST\UpdateStatement) { - $this->_sqlStatements = $sqlWalker->walkUpdateStatement($AST); + $this->sqlStatements = $sqlWalker->walkUpdateStatement($AST); } elseif ($AST instanceof AST\DeleteStatement) { - $this->_sqlStatements = $sqlWalker->walkDeleteStatement($AST); + $this->sqlStatements = $sqlWalker->walkDeleteStatement($AST); } } @@ -38,6 +38,6 @@ public function execute(Connection $conn, array $params, array $types): int $conn->ensureConnectedToPrimary(); } - return $conn->executeStatement($this->_sqlStatements, $params, $types); + return $conn->executeStatement($this->sqlStatements, $params, $types); } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index c55b0763731..ae1e544ecd8 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -203,18 +203,6 @@ - lib/Doctrine/ORM/AbstractQuery.php - lib/Doctrine/ORM/Configuration.php - lib/Doctrine/ORM/EntityRepository.php - lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php - lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php - lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php - lib/Doctrine/ORM/Query/Printer.php - lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php - lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php - lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php - lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php - lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php tests/Doctrine/Tests/OrmFunctionalTestCase.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index daa2401bd78..df19a2565cd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1209,14 +1209,14 @@ int - $this->_sqlStatements + $this->sqlStatements MultiTableDeleteExecutor MultiTableDeleteExecutor - $this->_sqlStatements + $this->sqlStatements @@ -1227,22 +1227,22 @@ int - $this->_sqlStatements + $this->sqlStatements MultiTableUpdateExecutor MultiTableUpdateExecutor - $this->_sqlStatements + $this->sqlStatements - $this->_sqlStatements + $this->sqlStatements - $this->_sqlStatements + $this->sqlStatements SingleSelectExecutor @@ -1250,13 +1250,13 @@ - $conn->executeStatement($this->_sqlStatements, $params, $types) + $conn->executeStatement($this->sqlStatements, $params, $types) int - $this->_sqlStatements + $this->sqlStatements SingleTableDeleteUpdateExecutor diff --git a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php index 5ce4a9019bd..a0360decbeb 100644 --- a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php +++ b/tests/Doctrine/Tests/ORM/AbstractQueryTest.php @@ -70,6 +70,6 @@ protected function _doExecute(): Result|int public function getResultCache(): CacheItemPoolInterface|null { - return $this->_queryCacheProfile->getResultCache(); + return $this->queryCacheProfile->getResultCache(); } } From 4fe224a320dc3e02e82340504e27c33c2926a86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 6 Feb 2023 23:51:04 +0100 Subject: [PATCH 223/475] Migrate ClassMetadata to PHP 8 syntax --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 14 +++++++------- phpstan-baseline.neon | 5 ----- psalm-baseline.xml | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 3f3ce1525fa..ab79131186d 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -766,7 +766,7 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable private InstantiatorInterface|null $instantiator = null; - private TypedFieldMapper $typedFieldMapper; + private readonly TypedFieldMapper $typedFieldMapper; /** * Initializes a new ClassMetadata instance that will hold the object-relational mapping @@ -1162,7 +1162,7 @@ public function validateLifecycleCallbacks(ReflectionService $reflService): void * * Can return null when using static reflection, in violation of the LSP */ - public function getReflectionClass() + public function getReflectionClass(): ReflectionClass|null { return $this->reflClass; } @@ -1486,7 +1486,7 @@ protected function validateAndCompleteFieldMapping(array $mapping): array * * @throws MappingException If something is wrong with the mapping. */ - protected function _validateAndCompleteAssociationMapping(array $mapping) + protected function _validateAndCompleteAssociationMapping(array $mapping): array { if (! isset($mapping['mappedBy'])) { $mapping['mappedBy'] = null; @@ -1640,7 +1640,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping) * @throws RuntimeException * @throws MappingException */ - protected function _validateAndCompleteOneToOneMapping(array $mapping) + protected function _validateAndCompleteOneToOneMapping(array $mapping): array { $mapping = $this->_validateAndCompleteAssociationMapping($mapping); @@ -1745,7 +1745,7 @@ protected function _validateAndCompleteOneToOneMapping(array $mapping) * @throws MappingException * @throws InvalidArgumentException */ - protected function _validateAndCompleteOneToManyMapping(array $mapping) + protected function _validateAndCompleteOneToManyMapping(array $mapping): array { $mapping = $this->_validateAndCompleteAssociationMapping($mapping); @@ -1795,7 +1795,7 @@ protected function _validateAndCompleteOneToManyMapping(array $mapping) * * @throws InvalidArgumentException */ - protected function _validateAndCompleteManyToManyMapping(array $mapping) + protected function _validateAndCompleteManyToManyMapping(array $mapping): array { $mapping = $this->_validateAndCompleteAssociationMapping($mapping); @@ -1970,7 +1970,7 @@ public function getColumnNames(array|null $fieldNames = null): array return array_keys($this->fieldNames); } - return array_values(array_map([$this, 'getColumnName'], $fieldNames)); + return array_values(array_map($this->getColumnName(...), $fieldNames)); } /** diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 58525a7890b..9223adc272a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -145,11 +145,6 @@ parameters: count: 2 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - message: "#^Expression on left side of \\?\\? is not nullable\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php - - message: "#^Empty array passed to foreach\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index df19a2565cd..399b8dedd02 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -331,7 +331,7 @@ $overrideMapping - getReflectionClass + ReflectionClass|null string From ce03a61b7a369a38b99b1c359eac5cbc665c02c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 7 Feb 2023 09:02:11 +0100 Subject: [PATCH 224/475] Migrate Parser to PHP 8 --- .../ORM/Query/AST/AggregateExpression.php | 7 +- .../ORM/Query/AST/ArithmeticExpression.php | 3 +- .../ORM/Query/AST/Functions/AbsFunction.php | 5 +- .../Query/AST/Functions/LocateFunction.php | 8 +- .../ORM/Query/AST/Functions/ModFunction.php | 9 +- .../ORM/Query/AST/Functions/SqrtFunction.php | 5 +- .../Query/AST/Functions/SubstringFunction.php | 8 +- .../Query/AST/NullComparisonExpression.php | 3 +- lib/Doctrine/ORM/Query/Parser.php | 545 +++++------------- lib/Doctrine/ORM/Query/SqlWalker.php | 2 + phpstan-baseline.neon | 37 +- psalm-baseline.xml | 53 -- 12 files changed, 163 insertions(+), 522 deletions(-) diff --git a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php index 087fbff8422..468c65c2a70 100644 --- a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php +++ b/lib/Doctrine/ORM/Query/AST/AggregateExpression.php @@ -8,13 +8,10 @@ class AggregateExpression extends Node { - /** - * @param PathExpression|SimpleArithmeticExpression $pathExpression - * @param bool $isDistinct Some aggregate expressions support distinct, eg COUNT. - */ + /** @param bool $isDistinct Some aggregate expressions support distinct, eg COUNT. */ public function __construct( public string $functionName, - public $pathExpression, + public Node|string $pathExpression, public bool $isDistinct, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php index 70c63b49738..9268414e85f 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php @@ -13,8 +13,7 @@ */ class ArithmeticExpression extends Node { - /** @var SimpleArithmeticExpression|null */ - public $simpleArithmeticExpression; + public Node|string|null $simpleArithmeticExpression = null; /** @var Subselect|null */ public $subselect; diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php index d9dd68bba0a..4edff060353 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php @@ -4,7 +4,7 @@ namespace Doctrine\ORM\Query\AST\Functions; -use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; +use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TokenType; @@ -16,8 +16,7 @@ */ class AbsFunction extends FunctionNode { - /** @var SimpleArithmeticExpression */ - public $simpleArithmeticExpression; + public Node|string $simpleArithmeticExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php index 839d54ca546..c0d3b4a21b5 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php @@ -5,7 +5,6 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TokenType; @@ -17,11 +16,10 @@ */ class LocateFunction extends FunctionNode { - public Node $firstStringPrimary; - public Node $secondStringPrimary; + public Node|string $firstStringPrimary; + public Node|string $secondStringPrimary; - /** @var SimpleArithmeticExpression|bool */ - public $simpleArithmeticExpression = false; + public Node|string|bool $simpleArithmeticExpression = false; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php index f9daa3c3bdf..7c1af0bd71b 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php @@ -4,7 +4,7 @@ namespace Doctrine\ORM\Query\AST\Functions; -use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; +use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TokenType; @@ -16,11 +16,8 @@ */ class ModFunction extends FunctionNode { - /** @var SimpleArithmeticExpression */ - public $firstSimpleArithmeticExpression; - - /** @var SimpleArithmeticExpression */ - public $secondSimpleArithmeticExpression; + public Node|string $firstSimpleArithmeticExpression; + public Node|string $secondSimpleArithmeticExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php index 036ba9a42ac..e643663b627 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php @@ -4,7 +4,7 @@ namespace Doctrine\ORM\Query\AST\Functions; -use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; +use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TokenType; @@ -18,8 +18,7 @@ */ class SqrtFunction extends FunctionNode { - /** @var SimpleArithmeticExpression */ - public $simpleArithmeticExpression; + public Node|string $simpleArithmeticExpression; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php index 5b21fe42606..5744f083ba4 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php @@ -5,7 +5,6 @@ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\AST\Node; -use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TokenType; @@ -19,11 +18,8 @@ class SubstringFunction extends FunctionNode { public Node $stringPrimary; - /** @var SimpleArithmeticExpression */ - public $firstSimpleArithmeticExpression; - - /** @var SimpleArithmeticExpression|null */ - public $secondSimpleArithmeticExpression = null; + public Node|string $firstSimpleArithmeticExpression; + public Node|string|null $secondSimpleArithmeticExpression = null; public function getSql(SqlWalker $sqlWalker): string { diff --git a/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php index 8b56df93f94..e60cb04c5e5 100644 --- a/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php @@ -13,9 +13,8 @@ */ class NullComparisonExpression extends Node { - /** @param Node $expression */ public function __construct( - public $expression, + public Node|string $expression, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index d4713b6be50..2c380ee462d 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -45,13 +45,13 @@ * token: DqlToken, * } */ -class Parser +final class Parser { /** * @readonly Maps BUILT-IN string function names to AST class names. * @psalm-var array> */ - private static $stringFunctions = [ + private static array $stringFunctions = [ 'concat' => Functions\ConcatFunction::class, 'substring' => Functions\SubstringFunction::class, 'trim' => Functions\TrimFunction::class, @@ -64,7 +64,7 @@ class Parser * @readonly Maps BUILT-IN numeric function names to AST class names. * @psalm-var array> */ - private static $numericFunctions = [ + private static array $numericFunctions = [ 'length' => Functions\LengthFunction::class, 'locate' => Functions\LocateFunction::class, 'abs' => Functions\AbsFunction::class, @@ -87,7 +87,7 @@ class Parser * @readonly Maps BUILT-IN datetime function names to AST class names. * @psalm-var array> */ - private static $datetimeFunctions = [ + private static array $datetimeFunctions = [ 'current_date' => Functions\CurrentDateFunction::class, 'current_time' => Functions\CurrentTimeFunction::class, 'current_timestamp' => Functions\CurrentTimestampFunction::class, @@ -101,68 +101,53 @@ class Parser */ /** @psalm-var list */ - private $deferredIdentificationVariables = []; + private array $deferredIdentificationVariables = []; /** @psalm-var list */ - private $deferredPartialObjectExpressions = []; + private array $deferredPartialObjectExpressions = []; /** @psalm-var list */ - private $deferredPathExpressions = []; + private array $deferredPathExpressions = []; /** @psalm-var list */ - private $deferredResultVariables = []; + private array $deferredResultVariables = []; /** @psalm-var list */ - private $deferredNewObjectExpressions = []; + private array $deferredNewObjectExpressions = []; /** * The lexer. - * - * @var Lexer */ - private $lexer; + private readonly Lexer $lexer; /** * The parser result. - * - * @var ParserResult */ - private $parserResult; + private readonly ParserResult $parserResult; /** * The EntityManager. - * - * @var EntityManagerInterface - */ - private $em; - - /** - * The Query to parse. - * - * @var Query */ - private $query; + private readonly EntityManagerInterface $em; /** * Map of declared query components in the parsed query. * * @psalm-var array */ - private $queryComponents = []; + private array $queryComponents = []; /** * Keeps the nesting level of defined ResultVariables. - * - * @var int */ - private $nestingLevel = 0; + private int $nestingLevel = 0; /** * Any additional custom tree walkers that modify the AST. * * @psalm-var list> */ - private $customTreeWalkers = []; + private array $customTreeWalkers = []; /** * The custom last tree walker, if any, that is responsible for producing the output. @@ -172,16 +157,15 @@ class Parser private $customOutputWalker; /** @psalm-var array */ - private $identVariableExpressions = []; + private array $identVariableExpressions = []; /** * Creates a new query parser object. * * @param Query $query The Query to parse. */ - public function __construct(Query $query) + public function __construct(private readonly Query $query) { - $this->query = $query; $this->em = $query->getEntityManager(); $this->lexer = new Lexer((string) $query->getDQL()); $this->parserResult = new ParserResult(); @@ -191,12 +175,9 @@ public function __construct(Query $query) * Sets a custom tree walker that produces output. * This tree walker will be run last over the AST, after any other walkers. * - * @param string $className * @psalm-param class-string $className - * - * @return void */ - public function setCustomOutputTreeWalker($className) + public function setCustomOutputTreeWalker(string $className): void { $this->customOutputWalker = $className; } @@ -204,52 +185,41 @@ public function setCustomOutputTreeWalker($className) /** * Adds a custom tree walker for modifying the AST. * - * @param string $className * @psalm-param class-string $className - * - * @return void */ - public function addCustomTreeWalker($className) + public function addCustomTreeWalker(string $className): void { $this->customTreeWalkers[] = $className; } /** * Gets the lexer used by the parser. - * - * @return Lexer */ - public function getLexer() + public function getLexer(): Lexer { return $this->lexer; } /** * Gets the ParserResult that is being filled with information during parsing. - * - * @return ParserResult */ - public function getParserResult() + public function getParserResult(): ParserResult { return $this->parserResult; } /** * Gets the EntityManager used by the parser. - * - * @return EntityManagerInterface */ - public function getEntityManager() + public function getEntityManager(): EntityManagerInterface { return $this->em; } /** * Parses and builds AST for the given Query. - * - * @return AST\SelectStatement|AST\UpdateStatement|AST\DeleteStatement */ - public function getAST() + public function getAST(): AST\SelectStatement|AST\UpdateStatement|AST\DeleteStatement { // Parse & build AST $AST = $this->QueryLanguage(); @@ -288,11 +258,9 @@ public function getAST() * If they match, updates the lookahead token; otherwise raises a syntax * error. * - * @return void - * * @throws QueryException If the tokens don't match. */ - public function match(TokenType $token) + public function match(TokenType $token): void { $lookaheadType = $this->lexer->lookahead->type ?? null; @@ -326,10 +294,8 @@ public function match(TokenType $token) * * @param bool $deep Whether to clean peek and reset errors. * @param int $position Position to reset. - * - * @return void */ - public function free($deep = false, $position = 0) + public function free(bool $deep = false, int $position = 0): void { // WARNING! Use this method with care. It resets the scanner! $this->lexer->resetPosition($position); @@ -345,10 +311,8 @@ public function free($deep = false, $position = 0) /** * Parses a query string. - * - * @return ParserResult */ - public function parse() + public function parse(): ParserResult { $AST = $this->getAST(); @@ -370,19 +334,11 @@ public function parse() $treeWalkerChain->addTreeWalker($walker); } - switch (true) { - case $AST instanceof AST\UpdateStatement: - $treeWalkerChain->walkUpdateStatement($AST); - break; - - case $AST instanceof AST\DeleteStatement: - $treeWalkerChain->walkDeleteStatement($AST); - break; - - case $AST instanceof AST\SelectStatement: - default: - $treeWalkerChain->walkSelectStatement($AST); - } + match (true) { + $AST instanceof AST\UpdateStatement => $treeWalkerChain->walkUpdateStatement($AST), + $AST instanceof AST\DeleteStatement => $treeWalkerChain->walkDeleteStatement($AST), + $AST instanceof AST\SelectStatement => $treeWalkerChain->walkSelectStatement($AST), + }; $this->queryComponents = $treeWalkerChain->getQueryComponents(); } @@ -402,10 +358,8 @@ public function parse() * They have to appear in the select clause in the same order as the * declarations (from ... x join ... y join ... z ...) appear in the query * as the hydration process relies on that order for proper operation. - * - * @param AST\SelectStatement|AST\DeleteStatement|AST\UpdateStatement $AST */ - private function fixIdentificationVariableOrder(AST\Node $AST): void + private function fixIdentificationVariableOrder(AST\SelectStatement|AST\DeleteStatement|AST\UpdateStatement $AST): void { if (count($this->identVariableExpressions) <= 1) { return; @@ -430,16 +384,12 @@ private function fixIdentificationVariableOrder(AST\Node $AST): void /** * Generates a new syntax error. * - * @param string $expected Expected string. - * @param mixed[]|null $token Got token. - * @psalm-param DqlToken|null $token - * - * @return void - * @psalm-return no-return + * @param string $expected Expected string. + * @param DqlToken|null $token Got token. * * @throws QueryException */ - public function syntaxError($expected = '', $token = null) + public function syntaxError(string $expected = '', Token|null $token = null): never { if ($token === null) { $token = $this->lexer->lookahead; @@ -460,12 +410,9 @@ public function syntaxError($expected = '', $token = null) * @param string $message Optional message. * @psalm-param DqlToken|null $token * - * @return void - * @psalm-return no-return - * * @throws QueryException */ - public function semanticalError($message = '', Token|null $token = null) + public function semanticalError(string $message = '', Token|null $token = null): never { if ($token === null) { $token = $this->lexer->lookahead ?? new Token('fake token', 42, 0); @@ -495,7 +442,6 @@ public function semanticalError($message = '', Token|null $token = null) * * @param bool $resetPeek Reset peek after finding the closing parenthesis. * - * @return mixed[] * @psalm-return DqlToken|null */ private function peekBeyondClosingParenthesis(bool $resetPeek = true): Token|null @@ -829,10 +775,8 @@ private function processRootEntityAliasSelected(): void /** * QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement - * - * @return AST\SelectStatement|AST\UpdateStatement|AST\DeleteStatement */ - public function QueryLanguage() + public function QueryLanguage(): AST\SelectStatement|AST\UpdateStatement|AST\DeleteStatement { $statement = null; @@ -866,10 +810,8 @@ public function QueryLanguage() /** * SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] - * - * @return AST\SelectStatement */ - public function SelectStatement() + public function SelectStatement(): AST\SelectStatement { $selectStatement = new AST\SelectStatement($this->SelectClause(), $this->FromClause()); @@ -883,10 +825,8 @@ public function SelectStatement() /** * UpdateStatement ::= UpdateClause [WhereClause] - * - * @return AST\UpdateStatement */ - public function UpdateStatement() + public function UpdateStatement(): AST\UpdateStatement { $updateStatement = new AST\UpdateStatement($this->UpdateClause()); @@ -897,10 +837,8 @@ public function UpdateStatement() /** * DeleteStatement ::= DeleteClause [WhereClause] - * - * @return AST\DeleteStatement */ - public function DeleteStatement() + public function DeleteStatement(): AST\DeleteStatement { $deleteStatement = new AST\DeleteStatement($this->DeleteClause()); @@ -911,10 +849,8 @@ public function DeleteStatement() /** * IdentificationVariable ::= identifier - * - * @return string */ - public function IdentificationVariable() + public function IdentificationVariable(): string { $this->match(TokenType::T_IDENTIFIER); @@ -932,10 +868,8 @@ public function IdentificationVariable() /** * AliasIdentificationVariable = identifier - * - * @return string */ - public function AliasIdentificationVariable() + public function AliasIdentificationVariable(): string { $this->match(TokenType::T_IDENTIFIER); @@ -955,10 +889,8 @@ public function AliasIdentificationVariable() /** * AbstractSchemaName ::= fully_qualified_name | identifier - * - * @return string */ - public function AbstractSchemaName() + public function AbstractSchemaName(): string { if ($this->lexer->isNextToken(TokenType::T_FULLY_QUALIFIED_NAME)) { $this->match(TokenType::T_FULLY_QUALIFIED_NAME); @@ -993,10 +925,8 @@ private function validateAbstractSchemaName(string $schemaName): void /** * AliasResultVariable ::= identifier - * - * @return string */ - public function AliasResultVariable() + public function AliasResultVariable(): string { $this->match(TokenType::T_IDENTIFIER); @@ -1016,10 +946,8 @@ public function AliasResultVariable() /** * ResultVariable ::= identifier - * - * @return string */ - public function ResultVariable() + public function ResultVariable(): string { $this->match(TokenType::T_IDENTIFIER); @@ -1038,10 +966,8 @@ public function ResultVariable() /** * JoinAssociationPathExpression ::= IdentificationVariable "." (CollectionValuedAssociationField | SingleValuedAssociationField) - * - * @return AST\JoinAssociationPathExpression */ - public function JoinAssociationPathExpression() + public function JoinAssociationPathExpression(): AST\JoinAssociationPathExpression { $identVariable = $this->IdentificationVariable(); @@ -1073,12 +999,9 @@ public function JoinAssociationPathExpression() * * PathExpression ::= IdentificationVariable {"." identifier}* * - * @param int $expectedTypes * @psalm-param int-mask-of $expectedTypes - * - * @return AST\PathExpression */ - public function PathExpression($expectedTypes) + public function PathExpression(int $expectedTypes): AST\PathExpression { $identVariable = $this->IdentificationVariable(); $field = null; @@ -1112,10 +1035,8 @@ public function PathExpression($expectedTypes) /** * AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression - * - * @return AST\PathExpression */ - public function AssociationPathExpression() + public function AssociationPathExpression(): AST\PathExpression { return $this->PathExpression( AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION | @@ -1125,10 +1046,8 @@ public function AssociationPathExpression() /** * SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression - * - * @return AST\PathExpression */ - public function SingleValuedPathExpression() + public function SingleValuedPathExpression(): AST\PathExpression { return $this->PathExpression( AST\PathExpression::TYPE_STATE_FIELD | @@ -1138,40 +1057,32 @@ public function SingleValuedPathExpression() /** * StateFieldPathExpression ::= IdentificationVariable "." StateField - * - * @return AST\PathExpression */ - public function StateFieldPathExpression() + public function StateFieldPathExpression(): AST\PathExpression { return $this->PathExpression(AST\PathExpression::TYPE_STATE_FIELD); } /** * SingleValuedAssociationPathExpression ::= IdentificationVariable "." SingleValuedAssociationField - * - * @return AST\PathExpression */ - public function SingleValuedAssociationPathExpression() + public function SingleValuedAssociationPathExpression(): AST\PathExpression { return $this->PathExpression(AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION); } /** * CollectionValuedPathExpression ::= IdentificationVariable "." CollectionValuedAssociationField - * - * @return AST\PathExpression */ - public function CollectionValuedPathExpression() + public function CollectionValuedPathExpression(): AST\PathExpression { return $this->PathExpression(AST\PathExpression::TYPE_COLLECTION_VALUED_ASSOCIATION); } /** * SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression} - * - * @return AST\SelectClause */ - public function SelectClause() + public function SelectClause(): AST\SelectClause { $isDistinct = false; $this->match(TokenType::T_SELECT); @@ -1198,10 +1109,8 @@ public function SelectClause() /** * SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression - * - * @return AST\SimpleSelectClause */ - public function SimpleSelectClause() + public function SimpleSelectClause(): AST\SimpleSelectClause { $isDistinct = false; $this->match(TokenType::T_SELECT); @@ -1217,10 +1126,8 @@ public function SimpleSelectClause() /** * UpdateClause ::= "UPDATE" AbstractSchemaName ["AS"] AliasIdentificationVariable "SET" UpdateItem {"," UpdateItem}* - * - * @return AST\UpdateClause */ - public function UpdateClause() + public function UpdateClause(): AST\UpdateClause { $this->match(TokenType::T_UPDATE); assert($this->lexer->lookahead !== null); @@ -1269,10 +1176,8 @@ public function UpdateClause() /** * DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName ["AS"] AliasIdentificationVariable - * - * @return AST\DeleteClause */ - public function DeleteClause() + public function DeleteClause(): AST\DeleteClause { $this->match(TokenType::T_DELETE); @@ -1316,10 +1221,8 @@ public function DeleteClause() /** * FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}* - * - * @return AST\FromClause */ - public function FromClause() + public function FromClause(): AST\FromClause { $this->match(TokenType::T_FROM); @@ -1337,10 +1240,8 @@ public function FromClause() /** * SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}* - * - * @return AST\SubselectFromClause */ - public function SubselectFromClause() + public function SubselectFromClause(): AST\SubselectFromClause { $this->match(TokenType::T_FROM); @@ -1358,10 +1259,8 @@ public function SubselectFromClause() /** * WhereClause ::= "WHERE" ConditionalExpression - * - * @return AST\WhereClause */ - public function WhereClause() + public function WhereClause(): AST\WhereClause { $this->match(TokenType::T_WHERE); @@ -1370,10 +1269,8 @@ public function WhereClause() /** * HavingClause ::= "HAVING" ConditionalExpression - * - * @return AST\HavingClause */ - public function HavingClause() + public function HavingClause(): AST\HavingClause { $this->match(TokenType::T_HAVING); @@ -1382,10 +1279,8 @@ public function HavingClause() /** * GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}* - * - * @return AST\GroupByClause */ - public function GroupByClause() + public function GroupByClause(): AST\GroupByClause { $this->match(TokenType::T_GROUP); $this->match(TokenType::T_BY); @@ -1403,10 +1298,8 @@ public function GroupByClause() /** * OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}* - * - * @return AST\OrderByClause */ - public function OrderByClause() + public function OrderByClause(): AST\OrderByClause { $this->match(TokenType::T_ORDER); $this->match(TokenType::T_BY); @@ -1425,10 +1318,8 @@ public function OrderByClause() /** * Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause] - * - * @return AST\Subselect */ - public function Subselect() + public function Subselect(): AST\Subselect { // Increase query nesting level $this->nestingLevel++; @@ -1448,10 +1339,8 @@ public function Subselect() /** * UpdateItem ::= SingleValuedPathExpression "=" NewValue - * - * @return AST\UpdateItem */ - public function UpdateItem() + public function UpdateItem(): AST\UpdateItem { $pathExpr = $this->SingleValuedPathExpression(); @@ -1462,10 +1351,8 @@ public function UpdateItem() /** * GroupByItem ::= IdentificationVariable | ResultVariable | SingleValuedPathExpression - * - * @return string|AST\PathExpression */ - public function GroupByItem() + public function GroupByItem(): string|AST\PathExpression { // We need to check if we are in a IdentificationVariable or SingleValuedPathExpression $glimpse = $this->lexer->glimpse(); @@ -1492,10 +1379,8 @@ public function GroupByItem() * SimpleArithmeticExpression | SingleValuedPathExpression | CaseExpression | * ScalarExpression | ResultVariable | FunctionDeclaration * ) ["ASC" | "DESC"] - * - * @return AST\OrderByItem */ - public function OrderByItem() + public function OrderByItem(): AST\OrderByItem { $this->lexer->peek(); // lookahead => '.' $this->lexer->peek(); // lookahead => token after '.' @@ -1507,31 +1392,14 @@ public function OrderByItem() $glimpse = $this->lexer->glimpse(); assert($this->lexer->lookahead !== null); - switch (true) { - case $this->isMathOperator($peek): - $expr = $this->SimpleArithmeticExpression(); - break; - - case $glimpse !== null && $glimpse->type === TokenType::T_DOT: - $expr = $this->SingleValuedPathExpression(); - break; - - case $this->lexer->peek() && $this->isMathOperator($this->peekBeyondClosingParenthesis()): - $expr = $this->ScalarExpression(); - break; - - case $this->lexer->lookahead->type === TokenType::T_CASE: - $expr = $this->CaseExpression(); - break; - - case $this->isFunction(): - $expr = $this->FunctionDeclaration(); - break; - - default: - $expr = $this->ResultVariable(); - break; - } + $expr = match (true) { + $this->isMathOperator($peek) => $this->SimpleArithmeticExpression(), + $glimpse !== null && $glimpse->type === TokenType::T_DOT => $this->SingleValuedPathExpression(), + $this->lexer->peek() && $this->isMathOperator($this->peekBeyondClosingParenthesis()) => $this->ScalarExpression(), + $this->lexer->lookahead->type === TokenType::T_CASE => $this->CaseExpression(), + $this->isFunction() => $this->FunctionDeclaration(), + default => $this->ResultVariable(), + }; $type = 'ASC'; $item = new AST\OrderByItem($expr); @@ -1588,10 +1456,8 @@ public function NewValue() /** * IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {Join}* - * - * @return AST\IdentificationVariableDeclaration */ - public function IdentificationVariableDeclaration() + public function IdentificationVariableDeclaration(): AST\IdentificationVariableDeclaration { $joins = []; $rangeVariableDeclaration = $this->RangeVariableDeclaration(); @@ -1629,10 +1495,8 @@ public function IdentificationVariableDeclaration() * expressions to be injected, but there is no scope to do that. Only scope * accessible is "FROM", prohibiting an easy implementation without larger * changes.} - * - * @return AST\IdentificationVariableDeclaration */ - public function SubselectIdentificationVariableDeclaration() + public function SubselectIdentificationVariableDeclaration(): AST\IdentificationVariableDeclaration { /* NOT YET IMPLEMENTED! @@ -1678,10 +1542,8 @@ public function SubselectIdentificationVariableDeclaration() * Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" * (JoinAssociationDeclaration | RangeVariableDeclaration) * ["WITH" ConditionalExpression] - * - * @return AST\Join */ - public function Join() + public function Join(): AST\Join { // Check Join type $joinType = AST\Join::JOIN_TYPE_INNER; @@ -1735,11 +1597,9 @@ public function Join() /** * RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable * - * @return AST\RangeVariableDeclaration - * * @throws QueryException */ - public function RangeVariableDeclaration() + public function RangeVariableDeclaration(): AST\RangeVariableDeclaration { if ($this->lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS) && $this->lexer->glimpse()->type === TokenType::T_SELECT) { $this->semanticalError('Subquery is not supported here', $this->lexer->token); @@ -1775,10 +1635,8 @@ public function RangeVariableDeclaration() /** * JoinAssociationDeclaration ::= JoinAssociationPathExpression ["AS"] AliasIdentificationVariable [IndexBy] - * - * @return AST\JoinAssociationDeclaration */ - public function JoinAssociationDeclaration() + public function JoinAssociationDeclaration(): AST\JoinAssociationDeclaration { $joinAssociationPathExpression = $this->JoinAssociationPathExpression(); @@ -1815,10 +1673,8 @@ public function JoinAssociationDeclaration() /** * PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet * PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}" - * - * @return AST\PartialObjectExpression */ - public function PartialObjectExpression() + public function PartialObjectExpression(): AST\PartialObjectExpression { Deprecation::trigger( 'doctrine/orm', @@ -1879,11 +1735,10 @@ public function PartialObjectExpression() /** * NewObjectExpression ::= "NEW" AbstractSchemaName "(" NewObjectArg {"," NewObjectArg}* ")" - * - * @return AST\NewObjectExpression */ - public function NewObjectExpression() + public function NewObjectExpression(): AST\NewObjectExpression { + $args = []; $this->match(TokenType::T_NEW); $className = $this->AbstractSchemaName(); // note that this is not yet validated @@ -1938,10 +1793,8 @@ public function NewObjectArg() /** * IndexBy ::= "INDEX" "BY" SingleValuedPathExpression - * - * @return AST\IndexBy */ - public function IndexBy() + public function IndexBy(): AST\IndexBy { $this->match(TokenType::T_INDEX); $this->match(TokenType::T_BY); @@ -1985,14 +1838,11 @@ public function ScalarExpression() return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token->value); case $lookahead === TokenType::T_INPUT_PARAMETER: - switch (true) { - case $this->isMathOperator($peek): - // :param + u.value - return $this->SimpleArithmeticExpression(); + return match (true) { + $this->isMathOperator($peek) => $this->SimpleArithmeticExpression(), + default => $this->InputParameter(), + }; - default: - return $this->InputParameter(); - } case $lookahead === TokenType::T_CASE: case $lookahead === TokenType::T_COALESCE: case $lookahead === TokenType::T_NULLIF: @@ -2005,19 +1855,13 @@ public function ScalarExpression() // this check must be done before checking for a filed path expression case $this->isFunction(): - $this->lexer->peek(); // "(" + $this->lexer->peek(); - switch (true) { - case $this->isMathOperator($this->peekBeyondClosingParenthesis()): - // SUM(u.id) + COUNT(u.id) - return $this->SimpleArithmeticExpression(); - - default: - // IDENTITY(u) - return $this->FunctionDeclaration(); - } + return match (true) { + $this->isMathOperator($this->peekBeyondClosingParenthesis()) => $this->SimpleArithmeticExpression(), + default => $this->FunctionDeclaration(), + }; - break; // it is no function, so it must be a field path case $lookahead === TokenType::T_IDENTIFIER: $this->lexer->peek(); // lookahead => '.' @@ -2081,10 +1925,8 @@ public function CaseExpression() /** * CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")" - * - * @return AST\CoalesceExpression */ - public function CoalesceExpression() + public function CoalesceExpression(): AST\CoalesceExpression { $this->match(TokenType::T_COALESCE); $this->match(TokenType::T_OPEN_PARENTHESIS); @@ -2106,10 +1948,8 @@ public function CoalesceExpression() /** * NullIfExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")" - * - * @return AST\NullIfExpression */ - public function NullIfExpression() + public function NullIfExpression(): AST\NullIfExpression { $this->match(TokenType::T_NULLIF); $this->match(TokenType::T_OPEN_PARENTHESIS); @@ -2125,10 +1965,8 @@ public function NullIfExpression() /** * GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END" - * - * @return AST\GeneralCaseExpression */ - public function GeneralCaseExpression() + public function GeneralCaseExpression(): AST\GeneralCaseExpression { $this->match(TokenType::T_CASE); @@ -2149,10 +1987,8 @@ public function GeneralCaseExpression() /** * SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" * CaseOperand ::= StateFieldPathExpression | TypeDiscriminator - * - * @return AST\SimpleCaseExpression */ - public function SimpleCaseExpression() + public function SimpleCaseExpression(): AST\SimpleCaseExpression { $this->match(TokenType::T_CASE); $caseOperand = $this->StateFieldPathExpression(); @@ -2173,10 +2009,8 @@ public function SimpleCaseExpression() /** * WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression - * - * @return AST\WhenClause */ - public function WhenClause() + public function WhenClause(): AST\WhenClause { $this->match(TokenType::T_WHEN); $conditionalExpression = $this->ConditionalExpression(); @@ -2187,10 +2021,8 @@ public function WhenClause() /** * SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression - * - * @return AST\SimpleWhenClause */ - public function SimpleWhenClause() + public function SimpleWhenClause(): AST\SimpleWhenClause { $this->match(TokenType::T_WHEN); $conditionalExpression = $this->ScalarExpression(); @@ -2204,10 +2036,8 @@ public function SimpleWhenClause() * IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | * PartialObjectExpression | "(" Subselect ")" | CaseExpression | NewObjectExpression * ) [["AS"] ["HIDDEN"] AliasResultVariable] - * - * @return AST\SelectExpression */ - public function SelectExpression() + public function SelectExpression(): AST\SelectExpression { assert($this->lexer->lookahead !== null); $expression = null; @@ -2238,17 +2068,10 @@ public function SelectExpression() case $this->isFunction(): $this->lexer->peek(); // "(" - switch (true) { - case $this->isMathOperator($this->peekBeyondClosingParenthesis()): - // SUM(u.id) + COUNT(u.id) - $expression = $this->ScalarExpression(); - break; - - default: - // IDENTITY(u) - $expression = $this->FunctionDeclaration(); - break; - } + $expression = match (true) { + $this->isMathOperator($this->peekBeyondClosingParenthesis()) => $this->ScalarExpression(), + default => $this->FunctionDeclaration(), + }; break; @@ -2336,10 +2159,8 @@ public function SelectExpression() * StateFieldPathExpression | IdentificationVariable | FunctionDeclaration | * AggregateExpression | "(" Subselect ")" | ScalarExpression * ) [["AS"] AliasResultVariable] - * - * @return AST\SimpleSelectExpression */ - public function SimpleSelectExpression() + public function SimpleSelectExpression(): AST\SimpleSelectExpression { assert($this->lexer->lookahead !== null); $peek = $this->lexer->glimpse(); @@ -2424,10 +2245,8 @@ public function SimpleSelectExpression() /** * ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}* - * - * @return AST\ConditionalExpression|AST\ConditionalFactor|AST\ConditionalPrimary|AST\ConditionalTerm */ - public function ConditionalExpression() + public function ConditionalExpression(): AST\ConditionalExpression|AST\ConditionalFactor|AST\ConditionalPrimary|AST\ConditionalTerm { $conditionalTerms = []; $conditionalTerms[] = $this->ConditionalTerm(); @@ -2449,10 +2268,8 @@ public function ConditionalExpression() /** * ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}* - * - * @return AST\ConditionalFactor|AST\ConditionalPrimary|AST\ConditionalTerm */ - public function ConditionalTerm() + public function ConditionalTerm(): AST\ConditionalFactor|AST\ConditionalPrimary|AST\ConditionalTerm { $conditionalFactors = []; $conditionalFactors[] = $this->ConditionalFactor(); @@ -2474,10 +2291,8 @@ public function ConditionalTerm() /** * ConditionalFactor ::= ["NOT"] ConditionalPrimary - * - * @return AST\ConditionalFactor|AST\ConditionalPrimary */ - public function ConditionalFactor() + public function ConditionalFactor(): AST\ConditionalFactor|AST\ConditionalPrimary { $not = false; @@ -2500,10 +2315,8 @@ public function ConditionalFactor() /** * ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")" - * - * @return AST\ConditionalPrimary */ - public function ConditionalPrimary() + public function ConditionalPrimary(): AST\ConditionalPrimary { $condPrimary = new AST\ConditionalPrimary(); @@ -2541,18 +2354,8 @@ public function ConditionalPrimary() * InExpression | NullComparisonExpression | ExistsExpression | * EmptyCollectionComparisonExpression | CollectionMemberExpression | * InstanceOfExpression - * - * @return AST\BetweenExpression| - * AST\CollectionMemberExpression| - * AST\ComparisonExpression| - * AST\EmptyCollectionComparisonExpression| - * AST\ExistsExpression| - * AST\InExpression| - * AST\InstanceOfExpression| - * AST\LikeExpression| - * AST\NullComparisonExpression - */ - public function SimpleConditionalExpression() + */ + public function SimpleConditionalExpression(): AST\ExistsExpression|AST\BetweenExpression|AST\LikeExpression|AST\InListExpression|AST\InSubselectExpression|AST\InstanceOfExpression|AST\CollectionMemberExpression|AST\NullComparisonExpression|AST\EmptyCollectionComparisonExpression|AST\ComparisonExpression { assert($this->lexer->lookahead !== null); if ($this->lexer->isNextToken(TokenType::T_EXISTS)) { @@ -2655,10 +2458,8 @@ public function SimpleConditionalExpression() /** * EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY" - * - * @return AST\EmptyCollectionComparisonExpression */ - public function EmptyCollectionComparisonExpression() + public function EmptyCollectionComparisonExpression(): AST\EmptyCollectionComparisonExpression { $pathExpression = $this->CollectionValuedPathExpression(); $this->match(TokenType::T_IS); @@ -2682,10 +2483,8 @@ public function EmptyCollectionComparisonExpression() * * EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression * SimpleEntityExpression ::= IdentificationVariable | InputParameter - * - * @return AST\CollectionMemberExpression */ - public function CollectionMemberExpression() + public function CollectionMemberExpression(): AST\CollectionMemberExpression { $not = false; $entityExpr = $this->EntityExpression(); @@ -2747,10 +2546,8 @@ public function Literal() /** * InParameter ::= ArithmeticExpression | InputParameter - * - * @return AST\InputParameter|AST\ArithmeticExpression */ - public function InParameter() + public function InParameter(): AST\InputParameter|AST\ArithmeticExpression { assert($this->lexer->lookahead !== null); if ($this->lexer->lookahead->type === TokenType::T_INPUT_PARAMETER) { @@ -2762,10 +2559,8 @@ public function InParameter() /** * InputParameter ::= PositionalParameter | NamedParameter - * - * @return AST\InputParameter */ - public function InputParameter() + public function InputParameter(): AST\InputParameter { $this->match(TokenType::T_INPUT_PARAMETER); assert($this->lexer->token !== null); @@ -2775,10 +2570,8 @@ public function InputParameter() /** * ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")" - * - * @return AST\ArithmeticExpression */ - public function ArithmeticExpression() + public function ArithmeticExpression(): AST\ArithmeticExpression { $expr = new AST\ArithmeticExpression(); @@ -2802,10 +2595,8 @@ public function ArithmeticExpression() /** * SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}* - * - * @return AST\SimpleArithmeticExpression|AST\ArithmeticTerm */ - public function SimpleArithmeticExpression() + public function SimpleArithmeticExpression(): AST\Node|string { $terms = []; $terms[] = $this->ArithmeticTerm(); @@ -2829,10 +2620,8 @@ public function SimpleArithmeticExpression() /** * ArithmeticTerm ::= ArithmeticFactor {("*" | "/") ArithmeticFactor}* - * - * @return AST\ArithmeticTerm */ - public function ArithmeticTerm() + public function ArithmeticTerm(): AST\Node|string { $factors = []; $factors[] = $this->ArithmeticFactor(); @@ -2856,10 +2645,8 @@ public function ArithmeticTerm() /** * ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary - * - * @return AST\ArithmeticFactor */ - public function ArithmeticFactor() + public function ArithmeticFactor(): AST\Node|string|AST\ArithmeticFactor { $sign = null; @@ -2885,10 +2672,8 @@ public function ArithmeticFactor() * | FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings * | FunctionsReturningDatetime | IdentificationVariable | ResultVariable * | InputParameter | CaseExpression - * - * @return AST\Node|string */ - public function ArithmeticPrimary() + public function ArithmeticPrimary(): AST\Node|string { if ($this->lexer->isNextToken(TokenType::T_OPEN_PARENTHESIS)) { $this->match(TokenType::T_OPEN_PARENTHESIS); @@ -2940,10 +2725,8 @@ public function ArithmeticPrimary() /** * StringExpression ::= StringPrimary | ResultVariable | "(" Subselect ")" - * - * @return AST\Subselect|AST\Node|string */ - public function StringExpression() + public function StringExpression(): AST\Subselect|AST\Node|string { $peek = $this->lexer->glimpse(); assert($peek !== null); @@ -3024,10 +2807,8 @@ public function StringPrimary() /** * EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression - * - * @return AST\InputParameter|AST\PathExpression */ - public function EntityExpression() + public function EntityExpression(): AST\InputParameter|AST\PathExpression { $glimpse = $this->lexer->glimpse(); assert($glimpse !== null); @@ -3041,10 +2822,8 @@ public function EntityExpression() /** * SimpleEntityExpression ::= IdentificationVariable | InputParameter - * - * @return AST\InputParameter|AST\PathExpression */ - public function SimpleEntityExpression() + public function SimpleEntityExpression(): AST\InputParameter|AST\PathExpression { if ($this->lexer->isNextToken(TokenType::T_INPUT_PARAMETER)) { return $this->InputParameter(); @@ -3056,10 +2835,8 @@ public function SimpleEntityExpression() /** * AggregateExpression ::= * ("AVG" | "MAX" | "MIN" | "SUM" | "COUNT") "(" ["DISTINCT"] SimpleArithmeticExpression ")" - * - * @return AST\AggregateExpression */ - public function AggregateExpression() + public function AggregateExpression(): AST\AggregateExpression { assert($this->lexer->lookahead !== null); $lookaheadType = $this->lexer->lookahead->type; @@ -3088,10 +2865,8 @@ public function AggregateExpression() /** * QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")" - * - * @return AST\QuantifiedExpression */ - public function QuantifiedExpression() + public function QuantifiedExpression(): AST\QuantifiedExpression { assert($this->lexer->lookahead !== null); $lookaheadType = $this->lexer->lookahead->type; @@ -3114,10 +2889,8 @@ public function QuantifiedExpression() /** * BetweenExpression ::= ArithmeticExpression ["NOT"] "BETWEEN" ArithmeticExpression "AND" ArithmeticExpression - * - * @return AST\BetweenExpression */ - public function BetweenExpression() + public function BetweenExpression(): AST\BetweenExpression { $not = false; $arithExpr1 = $this->ArithmeticExpression(); @@ -3137,10 +2910,8 @@ public function BetweenExpression() /** * ComparisonExpression ::= ArithmeticExpression ComparisonOperator ( QuantifiedExpression | ArithmeticExpression ) - * - * @return AST\ComparisonExpression */ - public function ComparisonExpression() + public function ComparisonExpression(): AST\ComparisonExpression { $this->lexer->glimpse(); @@ -3155,10 +2926,8 @@ public function ComparisonExpression() /** * InExpression ::= SingleValuedPathExpression ["NOT"] "IN" "(" (InParameter {"," InParameter}* | Subselect) ")" - * - * @return AST\InListExpression|AST\InSubselectExpression */ - public function InExpression() + public function InExpression(): AST\InListExpression|AST\InSubselectExpression { $expression = $this->ArithmeticExpression(); @@ -3199,10 +2968,8 @@ public function InExpression() /** * InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")") - * - * @return AST\InstanceOfExpression */ - public function InstanceOfExpression() + public function InstanceOfExpression(): AST\InstanceOfExpression { $identificationVariable = $this->IdentificationVariable(); @@ -3246,10 +3013,8 @@ public function InstanceOfParameterList(): array /** * InstanceOfParameter ::= AbstractSchemaName | InputParameter - * - * @return AST\InputParameter|string */ - public function InstanceOfParameter() + public function InstanceOfParameter(): AST\InputParameter|string { if ($this->lexer->isNextToken(TokenType::T_INPUT_PARAMETER)) { $this->match(TokenType::T_INPUT_PARAMETER); @@ -3267,10 +3032,8 @@ public function InstanceOfParameter() /** * LikeExpression ::= StringExpression ["NOT"] "LIKE" StringPrimary ["ESCAPE" char] - * - * @return AST\LikeExpression */ - public function LikeExpression() + public function LikeExpression(): AST\LikeExpression { $stringExpr = $this->StringExpression(); $not = false; @@ -3305,10 +3068,8 @@ public function LikeExpression() /** * NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | AggregateExpression | FunctionDeclaration | IdentificationVariable | SingleValuedPathExpression | ResultVariable) "IS" ["NOT"] "NULL" - * - * @return AST\NullComparisonExpression */ - public function NullComparisonExpression() + public function NullComparisonExpression(): AST\NullComparisonExpression { switch (true) { case $this->lexer->isNextToken(TokenType::T_INPUT_PARAMETER): @@ -3381,10 +3142,8 @@ public function NullComparisonExpression() /** * ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")" - * - * @return AST\ExistsExpression */ - public function ExistsExpression() + public function ExistsExpression(): AST\ExistsExpression { $not = false; @@ -3497,19 +3256,12 @@ private function CustomFunctionDeclaration(): Functions\FunctionNode|null // Check for custom functions afterwards $config = $this->em->getConfiguration(); - switch (true) { - case $config->getCustomStringFunction($funcName) !== null: - return $this->CustomFunctionsReturningStrings(); - - case $config->getCustomNumericFunction($funcName) !== null: - return $this->CustomFunctionsReturningNumerics(); - - case $config->getCustomDatetimeFunction($funcName) !== null: - return $this->CustomFunctionsReturningDatetime(); - - default: - return null; - } + return match (true) { + $config->getCustomStringFunction($funcName) !== null => $this->CustomFunctionsReturningStrings(), + $config->getCustomNumericFunction($funcName) !== null => $this->CustomFunctionsReturningNumerics(), + $config->getCustomDatetimeFunction($funcName) !== null => $this->CustomFunctionsReturningDatetime(), + default => null, + }; } /** @@ -3523,10 +3275,8 @@ private function CustomFunctionDeclaration(): Functions\FunctionNode|null * "DATE_DIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | * "BIT_AND" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | * "BIT_OR" "(" ArithmeticPrimary "," ArithmeticPrimary ")" - * - * @return Functions\FunctionNode */ - public function FunctionsReturningNumerics() + public function FunctionsReturningNumerics(): AST\Functions\FunctionNode { assert($this->lexer->lookahead !== null); $funcNameLower = strtolower($this->lexer->lookahead->value); @@ -3538,8 +3288,7 @@ public function FunctionsReturningNumerics() return $function; } - /** @return Functions\FunctionNode */ - public function CustomFunctionsReturningNumerics() + public function CustomFunctionsReturningNumerics(): AST\Functions\FunctionNode { assert($this->lexer->lookahead !== null); // getCustomNumericFunction is case-insensitive @@ -3564,10 +3313,8 @@ public function CustomFunctionsReturningNumerics() * "CURRENT_TIMESTAMP" | * "DATE_ADD" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")" | * "DATE_SUB" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")" - * - * @return Functions\FunctionNode */ - public function FunctionsReturningDatetime() + public function FunctionsReturningDatetime(): AST\Functions\FunctionNode { assert($this->lexer->lookahead !== null); $funcNameLower = strtolower($this->lexer->lookahead->value); @@ -3579,8 +3326,7 @@ public function FunctionsReturningDatetime() return $function; } - /** @return Functions\FunctionNode */ - public function CustomFunctionsReturningDatetime() + public function CustomFunctionsReturningDatetime(): AST\Functions\FunctionNode { assert($this->lexer->lookahead !== null); // getCustomDatetimeFunction is case-insensitive @@ -3606,10 +3352,8 @@ public function CustomFunctionsReturningDatetime() * "LOWER" "(" StringPrimary ")" | * "UPPER" "(" StringPrimary ")" | * "IDENTITY" "(" SingleValuedAssociationPathExpression {"," string} ")" - * - * @return Functions\FunctionNode */ - public function FunctionsReturningStrings() + public function FunctionsReturningStrings(): AST\Functions\FunctionNode { assert($this->lexer->lookahead !== null); $funcNameLower = strtolower($this->lexer->lookahead->value); @@ -3621,8 +3365,7 @@ public function FunctionsReturningStrings() return $function; } - /** @return Functions\FunctionNode */ - public function CustomFunctionsReturningStrings() + public function CustomFunctionsReturningStrings(): Functions\FunctionNode { assert($this->lexer->lookahead !== null); // getCustomStringFunction is case-insensitive diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index ea4ca08e931..bc72b7fd7b4 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1943,6 +1943,8 @@ public function walkNullComparisonExpression(AST\NullComparisonExpression $nullC return $this->walkInputParameter($expression) . $comparison; } + assert(! is_string($expression)); + return $expression->dispatch($this) . $comparison; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9223adc272a..467256f7d74 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -255,31 +255,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/Expr/Select.php - - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:ArithmeticFactor\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticFactor but returns Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\|string\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/Parser.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Query\\\\Parser\\:\\:ArithmeticTerm\\(\\) should return Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticTerm but returns Doctrine\\\\ORM\\\\Query\\\\AST\\\\ArithmeticFactor\\|string\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/Parser.php - - - - message: """ - #^PHPDoc tag @return has invalid value \\(AST\\\\BetweenExpression\\| - AST\\\\CollectionMemberExpression\\| - AST\\\\ComparisonExpression\\| - AST\\\\EmptyCollectionComparisonExpression\\| - AST\\\\ExistsExpression\\| - AST\\\\InExpression\\| - AST\\\\InstanceOfExpression\\| - AST\\\\LikeExpression\\| - AST\\\\NullComparisonExpression\\)\\: Unexpected token "\\\\n \\* ", expected type at offset 344$# - """ - count: 1 - path: lib/Doctrine/ORM/Query/Parser.php - - message: "#^Parameter \\#2 \\$stringPattern of class Doctrine\\\\ORM\\\\Query\\\\AST\\\\LikeExpression constructor expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\Functions\\\\FunctionNode\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\InputParameter\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\Literal\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\PathExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" count: 1 @@ -287,14 +262,9 @@ parameters: - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 3 + count: 2 path: lib/Doctrine/ORM/Query/Parser.php - - - message: "#^Call to function is_string\\(\\) with Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node will always evaluate to false\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Match arm is unreachable because previous comparison is always true\\.$#" count: 2 @@ -305,11 +275,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/SqlWalker.php - - - message: "#^Result of && is always false\\.$#" - count: 1 - path: lib/Doctrine/ORM/Query/SqlWalker.php - - message: "#^Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:add\\(\\) expects array\\<'join'\\|int, array\\\\|string\\>\\|object\\|string, non\\-empty\\-array\\ given\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 399b8dedd02..dfcfe4f68c5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1099,11 +1099,6 @@ $parserResult - - - $parser->SimpleArithmeticExpression() - - $parser->ArithmeticPrimary() @@ -1150,15 +1145,6 @@ $this->simpleArithmeticExpression - - $parser->SimpleArithmeticExpression() - - - - - $parser->SimpleArithmeticExpression() - $parser->SimpleArithmeticExpression() - @@ -1170,17 +1156,6 @@ $owningAssoc['targetToSourceKeyColumns'] - - - $parser->SimpleArithmeticExpression() - - - - - $parser->SimpleArithmeticExpression() - $parser->SimpleArithmeticExpression() - - walkJoinPathExpression @@ -1328,25 +1303,6 @@ $this->queryComponents - - $factors[0] - $primary - $terms[0] - $this->CollectionMemberExpression() - $this->ComparisonExpression() - $this->EmptyCollectionComparisonExpression() - $this->ExistsExpression() - $this->InExpression() - $this->InstanceOfExpression() - $this->LikeExpression() - $this->NullComparisonExpression() - - - AST\ArithmeticFactor - AST\ArithmeticTerm - AST\BetweenExpression| - AST\SimpleArithmeticExpression|AST\ArithmeticTerm - new $functionClass($functionName) new $functionClass($functionName) @@ -1367,7 +1323,6 @@ $AST $conditionalExpression $expr - $pathExp $this->ConditionalExpression() $this->ConditionalExpression() $this->lexer->getLiteral($token) @@ -1377,7 +1332,6 @@ $this->ConditionalExpression() $this->ConditionalExpression() - $this->SimpleArithmeticExpression() $dql @@ -1391,15 +1345,9 @@ $token->value $token->value - - $args - $token->value === TokenType::T_IDENTIFIER->value - - $AST instanceof AST\SelectStatement - @@ -1421,7 +1369,6 @@ $this->conn->quote((string) $newValue) - is_string($expression) $assoc From 7e2eb61deb80091bafb601d9e154080c4ac5f465 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 8 Feb 2023 08:56:21 +0100 Subject: [PATCH 225/475] Make missing inheritance declarations a failure (#10463) This follows up on #10431: This kind of misconfiguration triggered a deprecation warning since 2.15.x. Now let's make it an exception. --- UPGRADE.md | 5 +++++ lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php | 8 +------- .../Tests/ORM/Mapping/BasicInheritanceMappingTest.php | 8 +++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index d3c054a6dae..2a13864c760 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: Undeclared entity inheritance now throws a `MappingException` + +As soon as an entity class inherits from another entity class, inheritance has to +be declared by adding the appropriate configuration for the root entity. + ## Removed `getEntityManager()` in `Doctrine\ORM\Event\OnClearEventArgs` and `Doctrine\ORM\Event\*FlushEventArgs` Use `getObjectManager()` instead. diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 9d79bf95a1e..96457670d5a 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -137,13 +137,7 @@ protected function doLoadMetadata( if (! $class->isMappedSuperclass) { if ($rootEntityFound && $class->isInheritanceTypeNone()) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10431', - "Entity class '%s' is a subclass of the root entity class '%s', but no inheritance mapping type was declared. This is a misconfiguration and will be an error in Doctrine ORM 3.0.", - $class->name, - end($nonSuperclassParents), - ); + throw MappingException::missingInheritanceTypeDeclaration(end($nonSuperclassParents), $class->name); } foreach ($class->embeddedClasses as $property => $embeddableClass) { diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 18a025d1e40..f19bcdcd2bf 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -34,6 +34,7 @@ use function assert; use function serialize; +use function sprintf; use function unserialize; class BasicInheritanceMappingTest extends OrmTestCase @@ -225,7 +226,12 @@ public function testMappedSuperclassIndex(): void /** @dataProvider invalidHierarchyDeclarationClasses */ public function testUndeclaredHierarchyRejection(string $rootEntity, string $childClass): void { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/10431'); + $this->expectException(MappingException::class); + $this->expectExceptionMessage(sprintf( + "Entity class '%s' is a subclass of the root entity class '%s', but no inheritance mapping type was declared.", + $childClass, + $rootEntity, + )); $this->cmf->getMetadataFor($childClass); } From f5e7ddb21c9d5a3590958dd67808a6ed4e187ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 8 Feb 2023 20:07:39 +0100 Subject: [PATCH 226/475] Migrate the rest of the source code to PHP 8 syntax --- .../Mapping/DefaultEntityListenerResolver.php | 3 +-- lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 22 +++++++------------ lib/Doctrine/ORM/OptimisticLockException.php | 2 +- lib/Doctrine/ORM/Query/AST/PathExpression.php | 2 +- .../ORM/Query/Exec/AbstractSqlExecutor.php | 2 +- .../Pagination/LimitSubqueryOutputWalker.php | 12 +++++----- lib/Doctrine/ORM/UnitOfWork.php | 5 ++--- psalm-baseline.xml | 10 --------- 8 files changed, 20 insertions(+), 38 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php b/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php index 34c8940faf8..0b3e7a26724 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php +++ b/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Mapping; -use function get_class; use function trim; /** @@ -29,7 +28,7 @@ public function clear(string|null $className = null): void public function register(object $object): void { - $this->instances[get_class($object)] = $object; + $this->instances[$object::class] = $object; } public function resolve(string $className): object diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 424cdde987e..4ba2e38d679 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; use Doctrine\Persistence\Mapping\Driver\FileDriver; +use Doctrine\Persistence\Mapping\Driver\FileLocator; use DOMDocument; use InvalidArgumentException; use LogicException; @@ -41,14 +42,14 @@ class XmlDriver extends FileDriver { public const DEFAULT_FILE_EXTENSION = '.dcm.xml'; - /** @var bool */ - private $isXsdValidationEnabled; - /** * {@inheritDoc} */ - public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENSION, bool $isXsdValidationEnabled = false) - { + public function __construct( + string|array|FileLocator $locator, + string $fileExtension = self::DEFAULT_FILE_EXTENSION, + private readonly bool $isXsdValidationEnabled = false, + ) { if (! extension_loaded('simplexml')) { throw new LogicException(sprintf( 'The XML metadata driver cannot be enabled because the SimpleXML PHP extension is missing.' @@ -73,8 +74,6 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS )); } - $this->isXsdValidationEnabled = $isXsdValidationEnabled; - parent::__construct($locator, $fileExtension); } @@ -86,7 +85,7 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS * * @template T of object */ - public function loadMetadataForClass($className, PersistenceClassMetadata $metadata) + public function loadMetadataForClass($className, PersistenceClassMetadata $metadata): void { $xmlRoot = $this->getElement($className); assert($xmlRoot instanceof SimpleXMLElement); @@ -962,12 +961,7 @@ private function validateMapping(string $file): void } } - /** - * @param mixed $element - * - * @return bool - */ - protected function evaluateBoolean($element) + protected function evaluateBoolean(mixed $element): bool { $flag = (string) $element; diff --git a/lib/Doctrine/ORM/OptimisticLockException.php b/lib/Doctrine/ORM/OptimisticLockException.php index 63bff462d60..f84e134b05e 100644 --- a/lib/Doctrine/ORM/OptimisticLockException.php +++ b/lib/Doctrine/ORM/OptimisticLockException.php @@ -17,7 +17,7 @@ class OptimisticLockException extends Exception implements ORMException { public function __construct( string $msg, - private object|string|null $entity, + private readonly object|string|null $entity, Throwable|null $previous = null, ) { parent::__construct($msg, 0, $previous); diff --git a/lib/Doctrine/ORM/Query/AST/PathExpression.php b/lib/Doctrine/ORM/Query/AST/PathExpression.php index 4f5ce93c976..4a56fcdf367 100644 --- a/lib/Doctrine/ORM/Query/AST/PathExpression.php +++ b/lib/Doctrine/ORM/Query/AST/PathExpression.php @@ -22,7 +22,7 @@ class PathExpression extends Node final public const TYPE_STATE_FIELD = 8; /** @psalm-var self::TYPE_*|null */ - public int|null $type; + public int|null $type = null; /** @psalm-param int-mask-of $expectedType */ public function __construct( diff --git a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php index 0820b859a9c..1ec778cff79 100644 --- a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php @@ -21,7 +21,7 @@ abstract class AbstractSqlExecutor /** @var list|string */ protected array|string $sqlStatements; - protected QueryCacheProfile|null $queryCacheProfile; + protected QueryCacheProfile|null $queryCacheProfile = null; /** * Gets the SQL statements that are executed by the executor. diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index feac361a217..c6826b54739 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -55,12 +55,12 @@ class LimitSubqueryOutputWalker extends SqlWalker { private const ORDER_BY_PATH_EXPRESSION = '/(? */ private array $orderByPathExpressions = []; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index bb8f56830d1..ec59e1c266b 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -55,7 +55,6 @@ use function array_filter; use function array_key_exists; use function array_map; -use function array_merge; use function array_pop; use function array_sum; use function array_values; @@ -983,7 +982,7 @@ public function recomputeSingleEntityChangeSet(ClassMetadata $class, object $ent if ($changeSet) { if (isset($this->entityChangeSets[$oid])) { - $this->entityChangeSets[$oid] = array_merge($this->entityChangeSets[$oid], $changeSet); + $this->entityChangeSets[$oid] = [...$this->entityChangeSets[$oid], ...$changeSet]; } elseif (! isset($this->entityInsertions[$oid])) { $this->entityChangeSets[$oid] = $changeSet; $this->entityUpdates[$oid] = $entity; @@ -2891,7 +2890,7 @@ private function performCallbackOnCachedPersister(callable $callback): void return; } - foreach (array_merge($this->persisters, $this->collectionPersisters) as $persister) { + foreach ([...$this->persisters, ...$this->collectionPersisters] as $persister) { if ($persister instanceof CachedPersister) { $callback($persister); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index dfcfe4f68c5..379ea9a4f7b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -659,10 +659,6 @@ 'region' => $region, ] - - $fileExtension - $locator - $metadata @@ -1188,7 +1184,6 @@ MultiTableDeleteExecutor - MultiTableDeleteExecutor $this->sqlStatements @@ -1206,7 +1201,6 @@ MultiTableUpdateExecutor - MultiTableUpdateExecutor $this->sqlStatements @@ -1219,9 +1213,6 @@ $this->sqlStatements - - SingleSelectExecutor - @@ -1235,7 +1226,6 @@ SingleTableDeleteUpdateExecutor - SingleTableDeleteUpdateExecutor From 6b61e52baad86a3ff70922ebf2e42a6621e77112 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Mon, 13 Feb 2023 20:27:39 +0000 Subject: [PATCH 227/475] Turn deprecation from #10470 into an exception in 3.0.x --- UPGRADE.md | 5 +++++ lib/Doctrine/ORM/Mapping/ClassMetadata.php | 9 +-------- lib/Doctrine/ORM/Mapping/MappingException.php | 5 +++-- .../Tests/ORM/Mapping/BasicInheritanceMappingTest.php | 3 ++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index c7d980d9ca3..d725283e65b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: Overriding fields or associations declared in other than mapped superclasses + +As stated in the documentation, fields and associations may only be overridden when being inherited +from mapped superclasses. Overriding them for parent entity classes now throws a `MappingException`. + ## BC BREAK: Undeclared entity inheritance now throws a `MappingException` As soon as an entity class inherits from another entity class, inheritance has to diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 0694356a464..d710a3dc808 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -2231,14 +2231,7 @@ public function setAttributeOverride(string $fieldName, array $overrideMapping): $mapping = $this->fieldMappings[$fieldName]; if (isset($mapping['inherited'])) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10470', - 'Overrides are only allowed for fields or associations declared in mapped superclasses or traits. This is not the case for %s::%s, which was inherited from %s. This is a misconfiguration and will be an error in Doctrine ORM 3.0.', - $this->name, - $fieldName, - $mapping['inherited'], - ); + throw MappingException::illegalOverrideOfInheritedProperty($this->name, $fieldName, $mapping['inherited']); } if (isset($mapping['id'])) { diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 84d6d0f8993..ab4083332e1 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -547,13 +547,14 @@ public static function infiniteEmbeddableNesting(string $className, string $prop ); } - public static function illegalOverrideOfInheritedProperty(string $className, string $propertyName): self + public static function illegalOverrideOfInheritedProperty(string $className, string $propertyName, string $inheritFromClass): self { return new self( sprintf( - 'Overrides are only allowed for fields or associations declared in mapped superclasses or traits, which is not the case for %s::%s.', + 'Overrides are only allowed for fields or associations declared in mapped superclasses or traits. This is not the case for %s::%s, which was inherited from %s.', $className, $propertyName, + $inheritFromClass, ), ); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index b8236fcdbab..634618b64a2 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -260,7 +260,8 @@ public function testInvalidOverrideFieldInheritedFromEntity(): void { $cm = $this->cmf->getMetadataFor(CompanyFixContract::class); - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/10470'); + $this->expectException(MappingException::class); + $this->expectExceptionMessageMatches('/Overrides are only allowed for fields or associations declared in mapped superclasses or traits./'); $cm->setAttributeOverride('completed', ['name' => 'other_column_name']); } From 9c2c1178e2d64eaf5a40bd3d94339d61cc23fb89 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 28 Feb 2023 08:29:02 +0100 Subject: [PATCH 228/475] Stabilize DBAL version constraint (#10542) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 343ef098b7a..70aeda326ba 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-ctype": "*", "doctrine/collections": "^2.1", "doctrine/common": "^3.3", - "doctrine/dbal": "^3.6@dev", + "doctrine/dbal": "^3.6", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.2 || ^2", "doctrine/inflector": "^1.4 || ^2.0", From b69e8e0267349bb5bf939f70a1fbc3adf37051ea Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 2 Mar 2023 15:19:42 +0100 Subject: [PATCH 229/475] Add more native types to entity manager (#10556) --- .../ORM/Decorator/EntityManagerDecorator.php | 16 ++--- lib/Doctrine/ORM/EntityManager.php | 66 +++++++------------ lib/Doctrine/ORM/EntityManagerInterface.php | 7 +- .../Internal/Hydration/AbstractHydrator.php | 3 +- lib/Doctrine/ORM/UnitOfWork.php | 3 +- psalm-baseline.xml | 7 +- .../Mock/NonProxyLoadingEntityManager.php | 16 ++--- .../Tests/ORM/Functional/Locking/LockTest.php | 25 ++----- 8 files changed, 44 insertions(+), 99 deletions(-) diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index c546efd8a4a..dec9fe21755 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Decorator; +use DateTimeInterface; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; @@ -96,18 +97,12 @@ public function createQueryBuilder(): QueryBuilder return $this->wrapped->createQueryBuilder(); } - /** - * {@inheritdoc} - */ - public function getReference(string $entityName, $id): object|null + public function getReference(string $entityName, mixed $id): object|null { return $this->wrapped->getReference($entityName, $id); } - /** - * {@inheritdoc} - */ - public function getPartialReference(string $entityName, $identifier): object|null + public function getPartialReference(string $entityName, mixed $identifier): object|null { return $this->wrapped->getPartialReference($entityName, $identifier); } @@ -117,10 +112,7 @@ public function close(): void $this->wrapped->close(); } - /** - * {@inheritdoc} - */ - public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void + public function lock(object $entity, LockMode|int $lockMode, DateTimeInterface|int|null $lockVersion = null): void { $this->wrapped->lock($entity, $lockMode, $lockVersion); } diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 8e74bad83f1..24abe7e3a28 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM; use BackedEnum; +use DateTimeInterface; use Doctrine\Common\EventManager; use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; @@ -23,7 +24,6 @@ use Doctrine\ORM\Query\FilterCollection; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Repository\RepositoryFactory; -use Doctrine\Persistence\ObjectRepository; use Throwable; use function array_keys; @@ -366,10 +366,7 @@ public function find($className, mixed $id, LockMode|int|null $lockMode = null, } } - /** - * {@inheritDoc} - */ - public function getReference(string $entityName, $id): object|null + public function getReference(string $entityName, mixed $id): object|null { $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); @@ -410,10 +407,7 @@ public function getReference(string $entityName, $id): object|null return $entity; } - /** - * {@inheritDoc} - */ - public function getPartialReference(string $entityName, $identifier): object|null + public function getPartialReference(string $entityName, mixed $identifier): object|null { $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); @@ -510,10 +504,7 @@ public function detach(object $object): void $this->unitOfWork->detach($object); } - /** - * {@inheritDoc} - */ - public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void + public function lock(object $entity, LockMode|int $lockMode, DateTimeInterface|int|null $lockVersion = null): void { $this->unitOfWork->lock($entity, $lockMode, $lockVersion); } @@ -523,7 +514,6 @@ public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null * * @psalm-param class-string $className * - * @return ObjectRepository|EntityRepository The repository class. * @psalm-return EntityRepository * * @template T of object @@ -579,34 +569,15 @@ public function getUnitOfWork(): UnitOfWork public function newHydrator(string|int $hydrationMode): AbstractHydrator { - switch ($hydrationMode) { - case Query::HYDRATE_OBJECT: - return new Internal\Hydration\ObjectHydrator($this); - - case Query::HYDRATE_ARRAY: - return new Internal\Hydration\ArrayHydrator($this); - - case Query::HYDRATE_SCALAR: - return new Internal\Hydration\ScalarHydrator($this); - - case Query::HYDRATE_SINGLE_SCALAR: - return new Internal\Hydration\SingleScalarHydrator($this); - - case Query::HYDRATE_SIMPLEOBJECT: - return new Internal\Hydration\SimpleObjectHydrator($this); - - case Query::HYDRATE_SCALAR_COLUMN: - return new Internal\Hydration\ScalarColumnHydrator($this); - - default: - $class = $this->config->getCustomHydrationMode($hydrationMode); - - if ($class !== null) { - return new $class($this); - } - } - - throw InvalidHydrationMode::fromMode((string) $hydrationMode); + return match ($hydrationMode) { + Query::HYDRATE_OBJECT => new Internal\Hydration\ObjectHydrator($this), + Query::HYDRATE_ARRAY => new Internal\Hydration\ArrayHydrator($this), + Query::HYDRATE_SCALAR => new Internal\Hydration\ScalarHydrator($this), + Query::HYDRATE_SINGLE_SCALAR => new Internal\Hydration\SingleScalarHydrator($this), + Query::HYDRATE_SIMPLEOBJECT => new Internal\Hydration\SimpleObjectHydrator($this), + Query::HYDRATE_SCALAR_COLUMN => new Internal\Hydration\ScalarColumnHydrator($this), + default => $this->createCustomHydrator((string) $hydrationMode), + }; } public function getProxyFactory(): ProxyFactory @@ -666,4 +637,15 @@ private function configureMetadataCache(): void $this->metadataFactory->setCache($metadataCache); } + + private function createCustomHydrator(string $hydrationMode): AbstractHydrator + { + $class = $this->config->getCustomHydrationMode($hydrationMode); + + if ($class !== null) { + return new $class($this); + } + + throw InvalidHydrationMode::fromMode($hydrationMode); + } } diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index db8e1f803e8..40d7de2ded4 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -161,7 +161,7 @@ public function refresh(object $object, LockMode|int|null $lockMode = null): voi * * @template T of object */ - public function getReference(string $entityName, $id): object|null; + public function getReference(string $entityName, mixed $id): object|null; /** * Gets a partial reference to the entity identified by the given type and identifier @@ -186,7 +186,7 @@ public function getReference(string $entityName, $id): object|null; * * @template T of object */ - public function getPartialReference(string $entityName, $identifier): object|null; + public function getPartialReference(string $entityName, mixed $identifier): object|null; /** * Closes the EntityManager. All entities that are currently managed @@ -198,13 +198,12 @@ public function close(): void; /** * Acquire a lock on the given entity. * - * @param int|DateTimeInterface|null $lockVersion * @psalm-param LockMode::* $lockMode * * @throws OptimisticLockException * @throws PessimisticLockException */ - public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void; + public function lock(object $entity, LockMode|int $lockMode, DateTimeInterface|int|null $lockVersion = null): void; /** * Gets the EventManager used by the EntityManager. diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 67eb4bcf137..99b636be9d4 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -28,6 +28,8 @@ /** * Base class for all hydrators. A hydrator is a class that provides some form * of transformation of an SQL result set into another structure. + * + * @psalm-consistent-constructor */ abstract class AbstractHydrator { @@ -77,7 +79,6 @@ abstract class AbstractHydrator */ public function __construct(protected EntityManagerInterface $em) { - $this->em = $em; $this->platform = $em->getConnection()->getDatabasePlatform(); $this->uow = $em->getUnitOfWork(); } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index b0c5ad1465a..a805666f9e8 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2039,14 +2039,13 @@ private function cascadeRemove(object $entity, array &$visited): void /** * Acquire a lock on the given entity. * - * @param int|DateTimeInterface|null $lockVersion * @psalm-param LockMode::* $lockMode * * @throws ORMInvalidArgumentException * @throws TransactionRequiredException * @throws OptimisticLockException */ - public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void + public function lock(object $entity, LockMode|int $lockMode, DateTimeInterface|int|null $lockVersion = null): void { if ($this->getEntityState($entity, self::STATE_DETACHED) !== self::STATE_MANAGED) { throw ORMInvalidArgumentException::entityNotManaged($entity); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7fef7dec6e2..ecaa1c06fe7 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -204,12 +204,9 @@ new $metadataFactoryClassName() - + (string) $hydrationMode - - - new $class($this) - + diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 39db18da09f..815f7e4eec3 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -4,6 +4,7 @@ namespace Doctrine\Performance\Mock; +use DateTimeInterface; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; @@ -109,18 +110,12 @@ public function createQueryBuilder(): QueryBuilder return $this->realEntityManager->createQueryBuilder(); } - /** - * {@inheritDoc} - */ - public function getReference(string $entityName, $id): object|null + public function getReference(string $entityName, mixed $id): object|null { return $this->realEntityManager->getReference($entityName, $id); } - /** - * {@inheritDoc} - */ - public function getPartialReference(string $entityName, $identifier): object|null + public function getPartialReference(string $entityName, mixed $identifier): object|null { return $this->realEntityManager->getPartialReference($entityName, $identifier); } @@ -130,10 +125,7 @@ public function close(): void $this->realEntityManager->close(); } - /** - * {@inheritDoc} - */ - public function lock(object $entity, LockMode|int $lockMode, $lockVersion = null): void + public function lock(object $entity, LockMode|int $lockMode, DateTimeInterface|int|null $lockVersion = null): void { $this->realEntityManager->lock($entity, $lockMode, $lockVersion); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index bcd4fc0586f..d858e2a2e60 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -27,10 +27,8 @@ protected function setUp(): void /** * @group DDC-178 * @group locking - * @testWith [false] - * [true] */ - public function testLockVersionedEntity(bool $useStringVersion): void + public function testLockVersionedEntity(): void { $article = new CmsArticle(); $article->text = 'my article'; @@ -39,15 +37,7 @@ public function testLockVersionedEntity(bool $useStringVersion): void $this->_em->persist($article); $this->_em->flush(); - $lockVersion = $article->version; - if ($useStringVersion) { - // NOTE: Officially, the lock method (and callers) do not accept a string argument. Calling code should - // cast the version to (int) as per the docs. However, this is not currently enforced. This may change in - // a future release. - $lockVersion = (string) $lockVersion; - } - - $this->_em->lock($article, LockMode::OPTIMISTIC, $lockVersion); + $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version); $this->addToAssertionCount(1); } @@ -55,10 +45,8 @@ public function testLockVersionedEntity(bool $useStringVersion): void /** * @group DDC-178 * @group locking - * @testWith [false] - * [true] */ - public function testLockVersionedEntityMismatchThrowsException(bool $useStringVersion): void + public function testLockVersionedEntityMismatchThrowsException(): void { $article = new CmsArticle(); $article->text = 'my article'; @@ -68,12 +56,7 @@ public function testLockVersionedEntityMismatchThrowsException(bool $useStringVe $this->_em->flush(); $this->expectException(OptimisticLockException::class); - $lockVersion = $article->version + 1; - if ($useStringVersion) { - $lockVersion = (string) $lockVersion; - } - - $this->_em->lock($article, LockMode::OPTIMISTIC, $lockVersion); + $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); } /** From c44e19a5e75e3b23e4d1fb7cb3e31df83d7c7103 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 5 Mar 2023 12:43:00 +0100 Subject: [PATCH 230/475] PHPUnit 10 (#10492) --- ci/github/phpunit/mysqli.xml | 11 ++- ci/github/phpunit/pdo_mysql.xml | 12 ++-- ci/github/phpunit/pdo_pgsql.xml | 11 ++- ci/github/phpunit/pdo_sqlite.xml | 11 ++- ci/github/phpunit/pgsql.xml | 11 ++- ci/github/phpunit/sqlite3.xml | 11 ++- composer.json | 2 +- phpunit.xml.dist | 67 +++++++++---------- .../BasicEntityPersisterTypeValueSqlTest.php | 37 ++++++---- .../Command/SchemaTool/UpdateCommandTest.php | 8 +-- .../Doctrine/Tests/OrmFunctionalTestCase.php | 5 +- 11 files changed, 91 insertions(+), 95 deletions(-) diff --git a/ci/github/phpunit/mysqli.xml b/ci/github/phpunit/mysqli.xml index 81ad363497e..9e806f3ed04 100644 --- a/ci/github/phpunit/mysqli.xml +++ b/ci/github/phpunit/mysqli.xml @@ -3,9 +3,8 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" - convertDeprecationsToExceptions="true" + cacheDirectory=".phpunit.cache" > @@ -28,11 +27,11 @@ - - + + ../../../lib/Doctrine - - + + diff --git a/ci/github/phpunit/pdo_mysql.xml b/ci/github/phpunit/pdo_mysql.xml index 6f0c786d483..7fae48df0a6 100644 --- a/ci/github/phpunit/pdo_mysql.xml +++ b/ci/github/phpunit/pdo_mysql.xml @@ -3,9 +3,8 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" - convertDeprecationsToExceptions="true" + cacheDirectory=".phpunit.cache" > @@ -28,12 +27,11 @@ - - + + ../../../lib/Doctrine - - - + + diff --git a/ci/github/phpunit/pdo_pgsql.xml b/ci/github/phpunit/pdo_pgsql.xml index 2c53e3c93cb..4bf3d290a54 100644 --- a/ci/github/phpunit/pdo_pgsql.xml +++ b/ci/github/phpunit/pdo_pgsql.xml @@ -3,9 +3,8 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" - convertDeprecationsToExceptions="true" + cacheDirectory=".phpunit.cache" > @@ -25,11 +24,11 @@ - - + + ../../../lib/Doctrine - - + + diff --git a/ci/github/phpunit/pdo_sqlite.xml b/ci/github/phpunit/pdo_sqlite.xml index 69e74128110..ff282a35ed7 100644 --- a/ci/github/phpunit/pdo_sqlite.xml +++ b/ci/github/phpunit/pdo_sqlite.xml @@ -3,9 +3,8 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" - convertDeprecationsToExceptions="true" + cacheDirectory=".phpunit.cache" > @@ -23,11 +22,11 @@ - - + + ../../../lib/Doctrine - - + + diff --git a/ci/github/phpunit/pgsql.xml b/ci/github/phpunit/pgsql.xml index bccfccf4b6f..c4a5c5f207c 100644 --- a/ci/github/phpunit/pgsql.xml +++ b/ci/github/phpunit/pgsql.xml @@ -3,9 +3,8 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" - convertDeprecationsToExceptions="true" + cacheDirectory=".phpunit.cache" > @@ -25,11 +24,11 @@ - - + + ../../../lib/Doctrine - - + + diff --git a/ci/github/phpunit/sqlite3.xml b/ci/github/phpunit/sqlite3.xml index b9ae8b43ed7..c180a20c618 100644 --- a/ci/github/phpunit/sqlite3.xml +++ b/ci/github/phpunit/sqlite3.xml @@ -3,9 +3,8 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" - beStrictAboutTodoAnnotatedTests="true" failOnRisky="true" - convertDeprecationsToExceptions="true" + cacheDirectory=".phpunit.cache" > @@ -23,11 +22,11 @@ - - + + ../../../lib/Doctrine - - + + diff --git a/composer.json b/composer.json index 58a6daf0f94..13248f123db 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "doctrine/coding-standard": "^11.0", "phpbench/phpbench": "^1.0", "phpstan/phpstan": "1.10.3", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^10.0.14", "psr/log": "^1 || ^2 || ^3", "squizlabs/php_codesniffer": "3.7.2", "symfony/cache": "^5.4 || ^6.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ab844d2480a..da3b72933c2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,10 +14,9 @@ @@ -31,42 +30,38 @@ locking_functional + + + + + + + + - - - - + By default we assume that the `db_` config above has unrestricted access to the provided database + platform. - - - - + Note that these configurations are not merged - if you specify a `privileged_db_driver` then + you must also specify all the other options that your driver requires. + + + + + + + --> + + diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index 938e4153910..7e46efab1ba 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -20,6 +20,8 @@ use Doctrine\Tests\OrmTestCase; use ReflectionMethod; +use function array_slice; + class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase { protected BasicEntityPersister $persister; @@ -190,21 +192,28 @@ public function testDeleteManyToManyUsesTypeValuesSQL(): void $entityManager->getUnitOfWork()->registerManaged($parent, ['id' => 1], []); $entityManager->getUnitOfWork()->registerManaged($friend, ['id' => 2], []); - $connection->expects($this->atLeast(2)) - ->method('delete') - ->withConsecutive( - [ - 'customtype_parent_friends', - ['friend_customtypeparent_id' => 1], - ['integer'], - ], - [ - 'customtype_parent_friends', - ['customtypeparent_id' => 1], - ['integer'], - ], - ); + $deleteCalls = []; + + $connection->method('delete') + ->willReturnCallback(static function (...$args) use (&$deleteCalls): int { + $deleteCalls[] = $args; + + return 1; + }); $persister->delete($parent); + + self::assertSame([ + [ + 'customtype_parent_friends', + ['friend_customtypeparent_id' => 1], + ['integer'], + ], + [ + 'customtype_parent_friends', + ['customtypeparent_id' => 1], + ['integer'], + ], + ], array_slice($deleteCalls, 0, 2)); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php index 82cb980ee83..701643cbe07 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php @@ -30,6 +30,10 @@ public function testItPrintsTheSql(): void /** @dataProvider getCasesForWarningMessageFromCompleteOption */ public function testWarningMessageFromCompleteOption(string|null $name, string $expectedMessage): void { + if (! method_exists(SchemaDiff::class, 'toSaveSql')) { + self::markTestSkipped('This test requires DBAL 3'); + } + $tester = $this->getCommandTester(UpdateCommand::class, $name); $tester->execute( [], @@ -41,10 +45,6 @@ public function testWarningMessageFromCompleteOption(string|null $name, string $ public static function getCasesForWarningMessageFromCompleteOption(): iterable { - if (! method_exists(SchemaDiff::class, 'toSaveSql')) { - self::markTestSkipped('This test requires DBAL 3'); - } - yield 'default_name' => [ null, '[WARNING] Not passing the "--complete" option to "orm:schema-tool:update" is deprecated', diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 52eeb2a0b93..d154429e859 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -170,7 +170,6 @@ use Exception; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\Constraint\Count; -use PHPUnit\Framework\Warning; use Psr\Cache\CacheItemPoolInterface; use RuntimeException; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -980,9 +979,9 @@ final protected function createSchemaManager(): AbstractSchemaManager } /** @throws Throwable */ - protected function onNotSuccessfulTest(Throwable $e): void + protected function onNotSuccessfulTest(Throwable $e): never { - if ($e instanceof AssertionFailedError || $e instanceof Warning) { + if ($e instanceof AssertionFailedError) { throw $e; } From 59fb8ca57128410a8cf6064a2b0120b32528d4f8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 5 Mar 2023 12:43:47 +0100 Subject: [PATCH 231/475] Remove `Doctrine\ORM\Proxy\Proxy` interface (#10551) --- UPGRADE.md | 4 ++++ lib/Doctrine/ORM/Proxy/Proxy.php | 16 ---------------- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 3 +-- psalm-baseline.xml | 5 ----- 4 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 lib/Doctrine/ORM/Proxy/Proxy.php diff --git a/UPGRADE.md b/UPGRADE.md index d725283e65b..7cb2f33042a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: Removed `Doctrine\ORM\Proxy\Proxy` interface. + +Use `Doctrine\Persistence\Proxy` instead to check whether proxies are initialized. + ## BC BREAK: Overriding fields or associations declared in other than mapped superclasses As stated in the documentation, fields and associations may only be overridden when being inherited diff --git a/lib/Doctrine/ORM/Proxy/Proxy.php b/lib/Doctrine/ORM/Proxy/Proxy.php deleted file mode 100644 index 51837a2b973..00000000000 --- a/lib/Doctrine/ORM/Proxy/Proxy.php +++ /dev/null @@ -1,16 +0,0 @@ -setPlaceholder('serializeImpl', $this->generateSerializeImpl(...)); $proxyGenerator->setProxyClassTemplate(self::PROXY_CLASS_TEMPLATE); } else { - $proxyGenerator->setPlaceholder('baseProxyInterface', LegacyProxy::class); + $proxyGenerator->setPlaceholder('baseProxyInterface', CommonProxy::class); } parent::__construct($proxyGenerator, $em->getMetadataFactory(), $autoGenerate); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ecaa1c06fe7..bec4afabce0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1051,11 +1051,6 @@ - - - BaseProxy - - $classMetadata From b904f44c6c84a66c00c8cd0f4d9aa558f32a1402 Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Mon, 6 Mar 2023 11:14:22 +0100 Subject: [PATCH 232/475] Convert PHPUnit annotations to attributes (#10559) --- .../Tests/ORM/Cache/CacheConfigTest.php | 8 +- .../Doctrine/Tests/ORM/Cache/CacheKeyTest.php | 3 +- .../Tests/ORM/Cache/CacheLoggerChainTest.php | 3 +- .../ORM/Cache/DefaultCacheFactoryTest.php | 3 +- .../Tests/ORM/Cache/DefaultCacheTest.php | 3 +- .../Cache/DefaultCollectionHydratorTest.php | 3 +- .../ORM/Cache/DefaultEntityHydratorTest.php | 3 +- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 3 +- .../Tests/ORM/Cache/DefaultRegionTest.php | 20 +- .../Tests/ORM/Cache/FileLockRegionTest.php | 7 +- .../CollectionPersisterTestCase.php | 3 +- ...ReadWriteCachedCollectionPersisterTest.php | 3 +- .../ReadOnlyCachedCollectionPersisterTest.php | 3 +- ...ReadWriteCachedCollectionPersisterTest.php | 3 +- .../Entity/EntityPersisterTestCase.php | 3 +- ...rictReadWriteCachedEntityPersisterTest.php | 3 +- .../ReadOnlyCachedEntityPersisterTest.php | 3 +- .../ReadWriteCachedEntityPersisterTest.php | 3 +- .../Tests/ORM/Cache/RegionTestCase.php | 10 +- .../ORM/Cache/StatisticsCacheLoggerTest.php | 3 +- .../Doctrine/Tests/ORM/ConfigurationTest.php | 7 +- .../Doctrine/Tests/ORM/EntityManagerTest.php | 14 +- .../Tests/ORM/EntityNotFoundExceptionTest.php | 4 +- .../OnClassMetadataNotFoundEventArgsTest.php | 4 +- .../ORM/Functional/BasicFunctionalTest.php | 45 ++-- .../ORM/Functional/CascadeRemoveOrderTest.php | 3 +- .../Functional/ClassTableInheritanceTest.php | 23 +- .../Functional/CompositePrimaryKeyTest.php | 5 +- .../ORM/Functional/CustomIdObjectTypeTest.php | 13 +- .../ORM/Functional/DatabaseDriverTest.php | 3 +- .../ORM/Functional/DefaultValuesTest.php | 5 +- .../ORM/Functional/DetachedEntityTest.php | 7 +- .../ORM/Functional/EntityListenersTest.php | 3 +- .../ORM/Functional/EntityRepositoryTest.php | 103 +++++---- .../Tests/ORM/Functional/EnumTest.php | 18 +- .../Functional/ExtraLazyCollectionTest.php | 79 +++---- .../Tests/ORM/Functional/FlushEventTest.php | 3 +- .../Tests/ORM/Functional/GH5988Test.php | 4 +- .../ORM/Functional/HydrationCacheTest.php | 3 +- .../Tests/ORM/Functional/IdentityMapTest.php | 3 +- .../ORM/Functional/IndexByAssociationTest.php | 3 +- .../JoinedTableCompositeKeyTest.php | 3 +- .../ORM/Functional/LifecycleCallbackTest.php | 27 +-- .../Functional/Locking/GearmanLockTest.php | 3 +- .../Tests/ORM/Functional/Locking/LockTest.php | 57 ++--- .../ORM/Functional/Locking/OptimisticTest.php | 15 +- .../ManyToManyBasicAssociationTest.php | 21 +- .../Tests/ORM/Functional/NativeQueryTest.php | 19 +- .../Tests/ORM/Functional/NewOperatorTest.php | 8 +- .../OneToManyBidirectionalAssociationTest.php | 5 +- .../Functional/OneToManyOrphanRemovalTest.php | 9 +- .../Functional/OneToOneEagerLoadingTest.php | 19 +- ...eToOneInverseSideLoadAfterDqlQueryTest.php | 3 +- ...OneToOneSelfReferentialAssociationTest.php | 3 +- .../OneToOneSingleTableInheritanceTest.php | 6 +- .../OneToOneUnidirectionalAssociationTest.php | 3 +- .../Tests/ORM/Functional/PaginationTest.php | 72 +++---- .../Functional/PersistentCollectionTest.php | 7 +- .../ORM/Functional/PostLoadEventTest.php | 5 +- .../Tests/ORM/Functional/QueryCacheTest.php | 7 +- .../ORM/Functional/QueryDqlFunctionTest.php | 26 ++- .../Tests/ORM/Functional/QueryTest.php | 26 +-- .../Tests/ORM/Functional/ReadOnlyTest.php | 8 +- .../ORM/Functional/ReadonlyPropertiesTest.php | 3 +- .../ORM/Functional/ReferenceProxyTest.php | 17 +- .../Tests/ORM/Functional/ResultCacheTest.php | 14 +- .../Tests/ORM/Functional/SQLFilterTest.php | 12 +- .../SchemaTool/CompanySchemaTest.php | 10 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 3 +- .../ORM/Functional/SchemaTool/DDC214Test.php | 5 +- .../SchemaTool/MySqlSchemaToolTest.php | 3 +- .../SchemaTool/PostgreSqlSchemaToolTest.php | 3 +- .../ORM/Functional/SchemaValidatorTest.php | 7 +- ...econdLevelCacheCompositePrimaryKeyTest.php | 3 +- .../SecondLevelCacheConcurrentTest.php | 3 +- .../SecondLevelCacheCriteriaTest.php | 3 +- ...econdLevelCacheExtraLazyCollectionTest.php | 3 +- .../SecondLevelCacheFunctionalTestCase.php | 3 +- ...condLevelCacheJoinTableInheritanceTest.php | 3 +- .../SecondLevelCacheManyToManyTest.php | 3 +- .../SecondLevelCacheManyToOneTest.php | 3 +- .../SecondLevelCacheOneToManyTest.php | 3 +- .../SecondLevelCacheOneToOneTest.php | 3 +- .../SecondLevelCacheQueryCacheTest.php | 5 +- .../SecondLevelCacheRepositoryTest.php | 3 +- ...ndLevelCacheSingleTableInheritanceTest.php | 3 +- .../ORM/Functional/SecondLevelCacheTest.php | 3 +- .../SingleTableCompositeKeyTest.php | 3 +- .../Functional/SingleTableInheritanceTest.php | 15 +- .../ORM/Functional/Ticket/DDC1040Test.php | 3 +- .../ORM/Functional/Ticket/DDC1041Test.php | 3 +- .../ORM/Functional/Ticket/DDC1043Test.php | 3 +- .../ORM/Functional/Ticket/DDC1080Test.php | 3 +- .../ORM/Functional/Ticket/DDC1113Test.php | 7 +- .../ORM/Functional/Ticket/DDC1129Test.php | 3 +- .../ORM/Functional/Ticket/DDC1163Test.php | 3 +- .../ORM/Functional/Ticket/DDC117Test.php | 47 ++--- .../ORM/Functional/Ticket/DDC1181Test.php | 3 +- .../ORM/Functional/Ticket/DDC1193Test.php | 3 +- .../ORM/Functional/Ticket/DDC1209Test.php | 5 +- .../ORM/Functional/Ticket/DDC1225Test.php | 3 +- .../ORM/Functional/Ticket/DDC1228Test.php | 7 +- .../ORM/Functional/Ticket/DDC1238Test.php | 3 +- .../ORM/Functional/Ticket/DDC1250Test.php | 3 +- .../ORM/Functional/Ticket/DDC1300Test.php | 3 +- .../ORM/Functional/Ticket/DDC1301Test.php | 7 +- .../ORM/Functional/Ticket/DDC1306Test.php | 3 +- .../ORM/Functional/Ticket/DDC1335Test.php | 3 +- .../ORM/Functional/Ticket/DDC1400Test.php | 3 +- .../ORM/Functional/Ticket/DDC142Test.php | 7 +- .../ORM/Functional/Ticket/DDC1430Test.php | 3 +- .../ORM/Functional/Ticket/DDC1436Test.php | 3 +- .../ORM/Functional/Ticket/DDC144Test.php | 3 +- .../ORM/Functional/Ticket/DDC1452Test.php | 3 +- .../ORM/Functional/Ticket/DDC1454Test.php | 3 +- .../ORM/Functional/Ticket/DDC1461Test.php | 3 +- .../ORM/Functional/Ticket/DDC1514Test.php | 3 +- .../ORM/Functional/Ticket/DDC1515Test.php | 3 +- .../ORM/Functional/Ticket/DDC1526Test.php | 3 +- .../ORM/Functional/Ticket/DDC1545Test.php | 3 +- .../ORM/Functional/Ticket/DDC1548Test.php | 3 +- .../ORM/Functional/Ticket/DDC1595Test.php | 9 +- .../ORM/Functional/Ticket/DDC163Test.php | 3 +- .../ORM/Functional/Ticket/DDC1643Test.php | 3 +- .../ORM/Functional/Ticket/DDC1654Test.php | 7 +- .../ORM/Functional/Ticket/DDC1655Test.php | 9 +- .../ORM/Functional/Ticket/DDC1666Test.php | 3 +- .../ORM/Functional/Ticket/DDC1685Test.php | 3 +- .../ORM/Functional/Ticket/DDC168Test.php | 3 +- .../ORM/Functional/Ticket/DDC1695Test.php | 3 +- .../ORM/Functional/Ticket/DDC1707Test.php | 3 +- .../ORM/Functional/Ticket/DDC1719Test.php | 3 +- .../ORM/Functional/Ticket/DDC1778Test.php | 3 +- .../ORM/Functional/Ticket/DDC1787Test.php | 3 +- .../ORM/Functional/Ticket/DDC1843Test.php | 7 +- .../ORM/Functional/Ticket/DDC1884Test.php | 3 +- .../ORM/Functional/Ticket/DDC1885Test.php | 7 +- .../ORM/Functional/Ticket/DDC1918Test.php | 3 +- .../ORM/Functional/Ticket/DDC1925Test.php | 7 +- .../ORM/Functional/Ticket/DDC192Test.php | 3 +- .../ORM/Functional/Ticket/DDC1995Test.php | 3 +- .../ORM/Functional/Ticket/DDC1998Test.php | 3 +- .../ORM/Functional/Ticket/DDC2012Test.php | 7 +- .../ORM/Functional/Ticket/DDC2074Test.php | 3 +- .../ORM/Functional/Ticket/DDC2084Test.php | 3 +- .../ORM/Functional/Ticket/DDC2090Test.php | 7 +- .../ORM/Functional/Ticket/DDC2106Test.php | 3 +- .../ORM/Functional/Ticket/DDC2138Test.php | 3 +- .../ORM/Functional/Ticket/DDC2175Test.php | 3 +- .../ORM/Functional/Ticket/DDC2214Test.php | 4 +- .../ORM/Functional/Ticket/DDC2224Test.php | 6 +- .../ORM/Functional/Ticket/DDC2230Test.php | 3 +- .../ORM/Functional/Ticket/DDC2252Test.php | 3 +- .../ORM/Functional/Ticket/DDC2306Test.php | 3 +- .../ORM/Functional/Ticket/DDC2346Test.php | 3 +- .../ORM/Functional/Ticket/DDC2350Test.php | 7 +- .../ORM/Functional/Ticket/DDC2359Test.php | 3 +- .../ORM/Functional/Ticket/DDC2387Test.php | 3 +- .../ORM/Functional/Ticket/DDC2415Test.php | 3 +- .../ORM/Functional/Ticket/DDC2494Test.php | 7 +- .../ORM/Functional/Ticket/DDC2519Test.php | 5 +- .../ORM/Functional/Ticket/DDC2575Test.php | 3 +- .../ORM/Functional/Ticket/DDC2579Test.php | 3 +- .../ORM/Functional/Ticket/DDC258Test.php | 3 +- .../ORM/Functional/Ticket/DDC2602Test.php | 3 +- .../ORM/Functional/Ticket/DDC2655Test.php | 3 +- .../ORM/Functional/Ticket/DDC2660Test.php | 3 +- .../ORM/Functional/Ticket/DDC2692Test.php | 3 +- .../ORM/Functional/Ticket/DDC2759Test.php | 3 +- .../ORM/Functional/Ticket/DDC2775Test.php | 3 +- .../ORM/Functional/Ticket/DDC2780Test.php | 3 +- .../ORM/Functional/Ticket/DDC2790Test.php | 3 +- .../ORM/Functional/Ticket/DDC279Test.php | 3 +- .../ORM/Functional/Ticket/DDC2825Test.php | 9 +- .../ORM/Functional/Ticket/DDC2862Test.php | 7 +- .../ORM/Functional/Ticket/DDC2931Test.php | 3 +- .../ORM/Functional/Ticket/DDC2943Test.php | 3 +- .../ORM/Functional/Ticket/DDC2984Test.php | 3 +- .../ORM/Functional/Ticket/DDC2996Test.php | 3 +- .../ORM/Functional/Ticket/DDC3033Test.php | 3 +- .../ORM/Functional/Ticket/DDC3042Test.php | 3 +- .../ORM/Functional/Ticket/DDC3068Test.php | 3 +- .../ORM/Functional/Ticket/DDC3103Test.php | 6 +- .../ORM/Functional/Ticket/DDC3123Test.php | 3 +- .../ORM/Functional/Ticket/DDC3160Test.php | 3 +- .../ORM/Functional/Ticket/DDC3170Test.php | 3 +- .../ORM/Functional/Ticket/DDC3192Test.php | 7 +- .../ORM/Functional/Ticket/DDC3300Test.php | 3 +- .../ORM/Functional/Ticket/DDC3303Test.php | 8 +- .../ORM/Functional/Ticket/DDC331Test.php | 3 +- .../ORM/Functional/Ticket/DDC3346Test.php | 3 +- .../ORM/Functional/Ticket/DDC3597Test.php | 5 +- .../ORM/Functional/Ticket/DDC3634Test.php | 3 +- .../ORM/Functional/Ticket/DDC3644Test.php | 5 +- .../ORM/Functional/Ticket/DDC3719Test.php | 3 +- .../ORM/Functional/Ticket/DDC371Test.php | 3 +- .../ORM/Functional/Ticket/DDC3785Test.php | 3 +- .../ORM/Functional/Ticket/DDC4024Test.php | 3 +- .../ORM/Functional/Ticket/DDC422Test.php | 3 +- .../ORM/Functional/Ticket/DDC425Test.php | 3 +- .../ORM/Functional/Ticket/DDC440Test.php | 3 +- .../ORM/Functional/Ticket/DDC522Test.php | 9 +- .../ORM/Functional/Ticket/DDC5684Test.php | 7 +- .../ORM/Functional/Ticket/DDC588Test.php | 4 +- .../ORM/Functional/Ticket/DDC618Test.php | 9 +- .../ORM/Functional/Ticket/DDC6303Test.php | 3 +- .../ORM/Functional/Ticket/DDC633Test.php | 15 +- .../ORM/Functional/Ticket/DDC6460Test.php | 5 +- .../ORM/Functional/Ticket/DDC6558Test.php | 3 +- .../ORM/Functional/Ticket/DDC657Test.php | 3 +- .../ORM/Functional/Ticket/DDC736Test.php | 11 +- .../ORM/Functional/Ticket/DDC767Test.php | 3 +- .../ORM/Functional/Ticket/DDC809Test.php | 3 +- .../ORM/Functional/Ticket/DDC812Test.php | 3 +- .../ORM/Functional/Ticket/DDC832Test.php | 13 +- .../ORM/Functional/Ticket/DDC837Test.php | 3 +- .../ORM/Functional/Ticket/DDC881Test.php | 7 +- .../ORM/Functional/Ticket/DDC933Test.php | 3 +- .../ORM/Functional/Ticket/DDC949Test.php | 3 +- .../ORM/Functional/Ticket/DDC960Test.php | 3 +- .../ORM/Functional/Ticket/DDC992Test.php | 3 +- .../ORM/Functional/Ticket/GH10288Test.php | 5 +- .../ORM/Functional/Ticket/GH10336Test.php | 3 +- .../ORM/Functional/Ticket/GH10387Test.php | 6 +- .../ORM/Functional/Ticket/GH2947Test.php | 3 +- .../ORM/Functional/Ticket/GH5562Test.php | 3 +- .../ORM/Functional/Ticket/GH5762Test.php | 3 +- .../ORM/Functional/Ticket/GH5804Test.php | 3 +- .../ORM/Functional/Ticket/GH5887Test.php | 3 +- .../ORM/Functional/Ticket/GH5998Test.php | 3 +- .../ORM/Functional/Ticket/GH6029Test.php | 7 +- .../ORM/Functional/Ticket/GH6141Test.php | 4 +- .../ORM/Functional/Ticket/GH6217Test.php | 3 +- .../ORM/Functional/Ticket/GH6362Test.php | 4 +- .../ORM/Functional/Ticket/GH6394Test.php | 4 +- .../ORM/Functional/Ticket/GH6402Test.php | 3 +- .../ORM/Functional/Ticket/GH6464Test.php | 3 +- .../ORM/Functional/Ticket/GH6531Test.php | 7 +- .../ORM/Functional/Ticket/GH6682Test.php | 3 +- .../ORM/Functional/Ticket/GH6699Test.php | 3 +- .../ORM/Functional/Ticket/GH6740Test.php | 11 +- .../ORM/Functional/Ticket/GH6937Test.php | 3 +- .../ORM/Functional/Ticket/GH7012Test.php | 3 +- .../ORM/Functional/Ticket/GH7062Test.php | 3 +- .../ORM/Functional/Ticket/GH7067Test.php | 3 +- .../ORM/Functional/Ticket/GH7079Test.php | 3 +- .../ORM/Functional/Ticket/GH7259Test.php | 5 +- .../ORM/Functional/Ticket/GH7286Test.php | 3 +- .../ORM/Functional/Ticket/GH7505Test.php | 3 +- .../ORM/Functional/Ticket/GH7629Test.php | 3 +- .../ORM/Functional/Ticket/GH7661Test.php | 3 +- .../ORM/Functional/Ticket/GH7735Test.php | 8 +- .../ORM/Functional/Ticket/GH7737Test.php | 6 +- .../ORM/Functional/Ticket/GH7761Test.php | 3 +- .../ORM/Functional/Ticket/GH7767Test.php | 3 +- .../ORM/Functional/Ticket/GH7820Test.php | 7 +- .../ORM/Functional/Ticket/GH7829Test.php | 3 +- .../ORM/Functional/Ticket/GH7836Test.php | 3 +- .../ORM/Functional/Ticket/GH7864Test.php | 3 +- .../ORM/Functional/Ticket/GH7869Test.php | 3 +- .../ORM/Functional/Ticket/GH7875Test.php | 6 +- .../ORM/Functional/Ticket/GH7941Test.php | 6 +- .../ORM/Functional/Ticket/GH8055Test.php | 3 +- .../ORM/Functional/Ticket/GH8061Test.php | 3 +- .../ORM/Functional/Ticket/GH8127Test.php | 3 +- .../ORM/Functional/Ticket/GH8217Test.php | 3 +- .../ORM/Functional/Ticket/GH8443Test.php | 5 +- .../ORM/Functional/Ticket/GH8499Test.php | 12 +- .../ORM/Functional/Ticket/GH8914Test.php | 8 +- .../ORM/Functional/Ticket/GH9027Test.php | 3 +- .../ORM/Functional/Ticket/GH9109Test.php | 3 +- .../ORM/Functional/Ticket/GH9230Test.php | 10 +- .../ORM/Functional/Ticket/GH9335Test.php | 3 +- .../ORM/Functional/Ticket/GH9579Test.php | 5 +- .../ORM/Functional/Ticket/Issue5989Test.php | 3 +- .../Tests/ORM/Functional/TypeTest.php | 3 +- .../Tests/ORM/Functional/TypeValueSqlTest.php | 3 +- .../ManyToManyCompositeIdForeignKeyTest.php | 21 +- .../ManyToManyCompositeIdTest.php | 19 +- .../ManyToManyExtraLazyTest.php | 4 +- .../ValueConversionType/ManyToManyTest.php | 19 +- .../OneToManyCompositeIdForeignKeyTest.php | 15 +- .../OneToManyCompositeIdTest.php | 13 +- .../OneToManyExtraLazyTest.php | 4 +- .../ValueConversionType/OneToManyTest.php | 13 +- .../OneToOneCompositeIdForeignKeyTest.php | 15 +- .../OneToOneCompositeIdTest.php | 13 +- .../ValueConversionType/OneToOneTest.php | 13 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 8 +- .../ORM/Functional/VersionedOneToOneTest.php | 4 +- .../ORM/Hydration/AbstractHydratorTest.php | 13 +- .../Tests/ORM/Hydration/ArrayHydratorTest.php | 30 ++- .../ORM/Hydration/ObjectHydratorTest.php | 60 +++--- .../ORM/Hydration/ResultSetMappingTest.php | 6 +- .../ORM/Hydration/ScalarHydratorTest.php | 5 +- .../Hydration/SimpleObjectHydratorTest.php | 7 +- .../Hydration/SingleScalarHydratorTest.php | 29 +-- .../Tests/ORM/Id/AssignedGeneratorTest.php | 3 +- .../Internal/HydrationCompleteHandlerTest.php | 11 +- .../Tests/ORM/LazyCriteriaCollectionTest.php | 3 +- .../ORM/Mapping/AnsiQuoteStrategyTest.php | 7 +- .../Mapping/BasicInheritanceMappingTest.php | 41 ++-- .../ORM/Mapping/ClassMetadataBuilderTest.php | 3 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 16 +- .../Mapping/ClassMetadataLoadEventTest.php | 3 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 98 ++++----- .../ORM/Mapping/DefaultQuoteStrategyTest.php | 7 +- .../Mapping/EntityListenerResolverTest.php | 3 +- .../ORM/Mapping/MappingDriverTestCase.php | 178 +++++++--------- .../Tests/ORM/Mapping/NamingStrategyTest.php | 16 +- .../Tests/ORM/Mapping/QuoteStrategyTest.php | 3 +- .../ReflectionEmbeddedPropertyTest.php | 11 +- .../ReflectionReadonlyPropertyTest.php | 3 +- .../Mapping/StaticPHPMappingDriverTest.php | 16 +- .../ORM/Mapping/Symfony/DriverTestCase.php | 3 +- .../ORM/Mapping/Symfony/XmlDriverTest.php | 3 +- .../ORM/Mapping/TypedFieldMapperTest.php | 7 +- .../ORM/Mapping/XmlMappingDriverTest.php | 33 ++- .../ORM/ORMInvalidArgumentExceptionTest.php | 6 +- tests/Doctrine/Tests/ORM/ORMSetupTest.php | 10 +- .../ORM/Performance/SecondLevelCacheTest.php | 7 +- .../Tests/ORM/PersistentCollectionTest.php | 33 ++- .../BasicEntityPersisterTypeValueSqlTest.php | 7 +- .../JoinedSubclassPersisterTest.php | 7 +- .../Persisters/ManyToManyPersisterTest.php | 10 +- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 9 +- .../ORM/Query/DeleteSqlGenerationTest.php | 5 +- tests/Doctrine/Tests/ORM/Query/ExprTest.php | 26 ++- .../Tests/ORM/Query/FilterCollectionTest.php | 3 +- .../ORM/Query/LanguageRecognitionTest.php | 42 ++-- tests/Doctrine/Tests/ORM/Query/LexerTest.php | 3 +- .../ORM/Query/ParameterTypeInfererTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/ParserTest.php | 38 ++-- .../ORM/Query/QueryExpressionVisitorTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 41 ++-- .../ORM/Query/SelectSqlGenerationTest.php | 197 ++++++++---------- .../Tests/ORM/Query/SqlWalkerTest.php | 9 +- .../ORM/Query/UpdateSqlGenerationTest.php | 3 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 41 ++-- .../DefaultRepositoryFactoryTest.php | 4 +- .../ClearCacheCollectionRegionCommandTest.php | 3 +- .../ClearCacheEntityRegionCommandTest.php | 3 +- .../ClearCacheQueryRegionCommandTest.php | 3 +- .../Command/MappingDescribeCommandTest.php | 4 +- .../Console/Command/RunDqlCommandTest.php | 4 +- .../Command/SchemaTool/CreateCommandTest.php | 3 +- .../Command/SchemaTool/DropCommandTest.php | 3 +- .../Command/SchemaTool/UpdateCommandTest.php | 6 +- .../Command/ValidateSchemaCommandTest.php | 4 +- .../ORM/Tools/Console/ConsoleRunnerTest.php | 8 +- .../ORM/Tools/Console/MetadataFilterTest.php | 4 +- .../ORM/Tools/Pagination/CountWalkerTest.php | 3 +- .../LimitSubqueryOutputWalkerTest.php | 5 +- .../Pagination/LimitSubqueryWalkerTest.php | 5 +- .../Tools/Pagination/RootTypeWalkerTest.php | 3 +- .../Tools/Pagination/WhereInWalkerTest.php | 6 +- .../Tools/ResolveTargetEntityListenerTest.php | 22 +- .../Tests/ORM/Tools/SchemaToolTest.php | 14 +- .../Tests/ORM/Tools/SchemaValidatorTest.php | 26 +-- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 46 ++-- .../Utility/IdentifierFlattenerEnumIdTest.php | 13 +- .../ORM/Utility/IdentifierFlattenerTest.php | 9 +- 362 files changed, 1664 insertions(+), 1579 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php index 8621e9349ce..b36dad4b409 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php @@ -11,11 +11,11 @@ use Doctrine\ORM\Cache\TimestampQueryCacheValidator; use Doctrine\ORM\Cache\TimestampRegion; use Doctrine\Tests\DoctrineTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-2183 - * @covers \Doctrine\ORM\Cache\CacheConfiguration - */ +#[CoversClass(CacheConfiguration::class)] +#[Group('DDC-2183')] class CacheConfigTest extends DoctrineTestCase { private CacheConfiguration $config; diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php index 530f2a9d2e8..3f8d4465753 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php @@ -8,8 +8,9 @@ use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\EntityCacheKey; use Doctrine\Tests\DoctrineTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class CacheKeyTest extends DoctrineTestCase { public function testEntityCacheKeyIdentifierCollision(): void diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index 28adcbd1cce..685247bcf4a 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -11,9 +11,10 @@ use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\Cache\State; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class CacheLoggerChainTest extends DoctrineTestCase { private CacheLoggerChain $logger; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 5ff4f8a1fcc..6dd074527ae 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -28,10 +28,11 @@ use Doctrine\Tests\OrmTestCase; use InvalidArgumentException; use LogicException; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use Psr\Cache\CacheItemPoolInterface; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class DefaultCacheFactoryTest extends OrmTestCase { private CacheFactory&MockObject $factory; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php index 6ba76ff5f82..cd30af1322b 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php @@ -17,12 +17,13 @@ use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use ReflectionMethod; use ReflectionProperty; use function array_merge; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class DefaultCacheTest extends OrmTestCase { private DefaultCache $cache; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php index d5a1f534fd4..b5d0217657d 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php @@ -15,8 +15,9 @@ use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class DefaultCollectionHydratorTest extends OrmFunctionalTestCase { private DefaultCollectionHydrator $structure; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php index eeb87e9ddc1..e3271be38cc 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php @@ -15,8 +15,9 @@ use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class DefaultEntityHydratorTest extends OrmTestCase { private DefaultEntityHydrator $structure; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 8c36f9afaf7..2edc63afd81 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -26,12 +26,13 @@ use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use ReflectionMethod; use function microtime; use function sprintf; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class DefaultQueryCacheTest extends OrmTestCase { private DefaultQueryCache $queryCache; diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index 031cfb01a2a..b9f21e36209 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -8,13 +8,13 @@ use Doctrine\ORM\Cache\Region\DefaultRegion; use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheKeyMock; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use function array_map; -/** - * @extends RegionTestCase - * @group DDC-2183 - */ +/** @extends RegionTestCase */ +#[Group('DDC-2183')] class DefaultRegionTest extends RegionTestCase { protected function createRegion(): DefaultRegion @@ -94,10 +94,8 @@ public function testGetMultiPreservesOrderAndKeys(): void ], $actual); } - /** - * @test - * @group GH7266 - */ + #[Test] + #[Group('GH7266')] public function corruptedDataDoesNotLeakIntoApplicationWhenGettingSingleEntry(): void { $key1 = new CacheKeyMock('key.1'); @@ -111,10 +109,8 @@ public function corruptedDataDoesNotLeakIntoApplicationWhenGettingSingleEntry(): self::assertNull($this->region->get($key1)); } - /** - * @test - * @group GH7266 - */ + #[Test] + #[Group('GH7266')] public function corruptedDataDoesNotLeakIntoApplicationWhenGettingMultipleEntries(): void { $key1 = new CacheKeyMock('key.1'); diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php index 5c5298fd29c..bf6fe97ab94 100644 --- a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Cache\Region\FileLockRegion; use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheKeyMock; +use PHPUnit\Framework\Attributes\Group; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use ReflectionMethod; @@ -21,10 +22,8 @@ use function uniqid; use function unlink; -/** - * @extends RegionTestCase - * @group DDC-2183 - */ +/** @extends RegionTestCase */ +#[Group('DDC-2183')] class FileLockRegionTest extends RegionTestCase { protected string $directory; diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php index d9583e77c59..d05f9268b1b 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php @@ -15,9 +15,10 @@ use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; -/** @group DDC-2183 */ +#[Group('DDC-2183')] abstract class CollectionPersisterTestCase extends OrmTestCase { protected Region&MockObject $region; diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php index 68193d3bc40..c4c0d1e16dc 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php @@ -9,8 +9,9 @@ use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Persisters\Collection\CollectionPersister; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class NonStrictReadWriteCachedCollectionPersisterTest extends CollectionPersisterTestCase { protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php index 34f4b003400..5c55a1d8761 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php @@ -9,8 +9,9 @@ use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Persisters\Collection\CollectionPersister; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class ReadOnlyCachedCollectionPersisterTest extends CollectionPersisterTestCase { protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index 61a8f4db97d..107f24ac11c 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -13,10 +13,11 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\Tests\Models\Cache\State; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class ReadWriteCachedCollectionPersisterTest extends CollectionPersisterTestCase { protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php index 56759d32678..c357fe66ea1 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php @@ -18,9 +18,10 @@ use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; -/** @group DDC-2183 */ +#[Group('DDC-2183')] abstract class EntityPersisterTestCase extends OrmTestCase { protected Region&MockObject $region; diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php index 268e7434199..0c8f7c4387d 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php @@ -13,9 +13,10 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Entity\EntityPersister; use Doctrine\Tests\Models\Cache\Country; +use PHPUnit\Framework\Attributes\Group; use ReflectionProperty; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class NonStrictReadWriteCachedEntityPersisterTest extends EntityPersisterTestCase { protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php index c537d66ffb0..9ced1accddd 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Entity\EntityPersister; use Doctrine\Tests\Models\Cache\Country; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class ReadOnlyCachedEntityPersisterTest extends EntityPersisterTestCase { protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 66dfaf3a63b..40fbd20a7c4 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -14,10 +14,11 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Entity\EntityPersister; use Doctrine\Tests\Models\Cache\Country; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class ReadWriteCachedEntityPersisterTest extends EntityPersisterTestCase { protected function createPersister(EntityManagerInterface $em, EntityPersister $persister, Region $region, ClassMetadata $metadata): AbstractEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php b/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php index bfb133fa109..72102c4b462 100644 --- a/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php @@ -10,13 +10,13 @@ use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheKeyMock; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; -/** - * @template TRegion of Region - * @group DDC-2183 - */ +/** @template TRegion of Region */ +#[Group('DDC-2183')] abstract class RegionTestCase extends OrmFunctionalTestCase { /** @psalm-var TRegion */ @@ -43,7 +43,7 @@ public static function dataProviderCacheValues(): array ]; } - /** @dataProvider dataProviderCacheValues */ + #[DataProvider('dataProviderCacheValues')] public function testPutGetContainsEvict(CacheKey $key, CacheEntry $value): void { self::assertFalse($this->region->contains($key)); diff --git a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php index 82f4bef6fd1..0e9ca861780 100644 --- a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php @@ -10,8 +10,9 @@ use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\Cache\State; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class StatisticsCacheLoggerTest extends DoctrineTestCase { private StatisticsCacheLogger $logger; diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 69e97f468cc..568a8709ee4 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -18,6 +18,7 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\DDC753\DDC753CustomRepository; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; /** @@ -186,7 +187,7 @@ public function testSetGetQuoteStrategy(): void self::assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); } - /** @group DDC-1955 */ + #[Group('DDC-1955')] public function testSetGetEntityListenerResolver(): void { self::assertInstanceOf(EntityListenerResolver::class, $this->configuration->getEntityListenerResolver()); @@ -196,7 +197,7 @@ public function testSetGetEntityListenerResolver(): void self::assertSame($resolver, $this->configuration->getEntityListenerResolver()); } - /** @group DDC-2183 */ + #[Group('DDC-2183')] public function testSetGetSecondLevelCacheConfig(): void { $mockClass = $this->createMock(CacheConfiguration::class); @@ -206,7 +207,7 @@ public function testSetGetSecondLevelCacheConfig(): void self::assertEquals($mockClass, $this->configuration->getSecondLevelCacheConfiguration()); } - /** @group GH10313 */ + #[Group('GH10313')] public function testSetGetTypedFieldMapper(): void { self::assertEmpty($this->configuration->getTypedFieldMapper()); diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index f552f97480f..fbd9811b88e 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -19,6 +19,8 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmTestCase; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use stdClass; use TypeError; @@ -33,7 +35,7 @@ protected function setUp(): void $this->entityManager = $this->getTestEntityManager(); } - /** @group DDC-899 */ + #[Group('DDC-899')] public function testIsOpen(): void { self::assertTrue($this->entityManager->isOpen()); @@ -129,7 +131,7 @@ public static function dataAffectedByErrorIfClosedException(): array ]; } - /** @dataProvider dataAffectedByErrorIfClosedException */ + #[DataProvider('dataAffectedByErrorIfClosedException')] public function testAffectedByErrorIfClosedException(string $methodName): void { $this->expectException(EntityManagerClosed::class); @@ -152,10 +154,8 @@ public static function dataToBeReturnedByWrapInTransaction(): Generator yield ['foo']; } - /** - * @dataProvider dataToBeReturnedByWrapInTransaction - * @group DDC-1125 - */ + #[DataProvider('dataToBeReturnedByWrapInTransaction')] + #[Group('DDC-1125')] public function testWrapInTransactionAcceptsReturn(mixed $expectedValue): void { $return = $this->entityManager->wrapInTransaction( @@ -165,7 +165,7 @@ public function testWrapInTransactionAcceptsReturn(mixed $expectedValue): void $this->assertSame($expectedValue, $return); } - /** @group #5796 */ + #[Group('#5796')] public function testWrapInTransactionReThrowsThrowables(): void { try { diff --git a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php b/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php index 319b06c9780..59d413b4696 100644 --- a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php @@ -5,13 +5,13 @@ namespace Doctrine\Tests\ORM; use Doctrine\ORM\EntityNotFoundException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; /** * Tests for {@see \Doctrine\ORM\EntityNotFoundException} - * - * @covers \Doctrine\ORM\EntityNotFoundException */ +#[CoversClass(EntityNotFoundException::class)] class EntityNotFoundExceptionTest extends TestCase { public function testFromClassNameAndIdentifier(): void diff --git a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php b/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php index e80ba2ff75f..1412f6f0c78 100644 --- a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php +++ b/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php @@ -7,15 +7,15 @@ use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\ObjectManager; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use function assert; /** * Tests for {@see \Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs} - * - * @covers \Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs */ +#[CoversClass(OnClassMetadataNotFoundEventArgs::class)] class OnClassMetadataNotFoundEventArgsTest extends TestCase { public function testEventArgsMutability(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index a238dc7242f..0a0ad424eed 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -19,6 +19,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; class BasicFunctionalTest extends OrmFunctionalTestCase { @@ -145,7 +146,7 @@ public function testBasicOneToOne(): void self::assertNotInstanceOf(Proxy::class, $user2->address); } - /** @group DDC-1230 */ + #[Group('DDC-1230')] public function testRemove(): void { $user = new CmsUser(); @@ -334,7 +335,7 @@ public function testBasicRefresh(): void self::assertEquals('developer', $user->status); } - /** @group DDC-833 */ + #[Group('DDC-833')] public function testRefreshResetsCollection(): void { $user = new CmsUser(); @@ -364,7 +365,7 @@ public function testRefreshResetsCollection(): void self::assertCount(1, $user->phonenumbers); } - /** @group DDC-833 */ + #[Group('DDC-833')] public function testDqlRefreshResetsCollection(): void { $user = new CmsUser(); @@ -398,7 +399,7 @@ public function testDqlRefreshResetsCollection(): void self::assertCount(1, $user->phonenumbers); } - /** @group DDC-833 */ + #[Group('DDC-833')] public function testCreateEntityOfProxy(): void { $user = new CmsUser(); @@ -738,10 +739,8 @@ public function testOneToOneNullUpdate(): void self::assertNotEquals(1, $this->_em->getConnection()->fetchOne('select 1 from cms_addresses where user_id = ' . $user->id)); } - /** - * @group DDC-600 - * @group DDC-455 - */ + #[Group('DDC-600')] + #[Group('DDC-455')] public function testNewAssociatedEntityDuringFlushThrowsException(): void { $user = new CmsUser(); @@ -763,10 +762,8 @@ public function testNewAssociatedEntityDuringFlushThrowsException(): void $this->_em->flush(); } - /** - * @group DDC-600 - * @group DDC-455 - */ + #[Group('DDC-600')] + #[Group('DDC-455')] public function testNewAssociatedEntityDuringFlushThrowsException2(): void { $user = new CmsUser(); @@ -796,10 +793,8 @@ public function testNewAssociatedEntityDuringFlushThrowsException2(): void $this->_em->flush(); } - /** - * @group DDC-600 - * @group DDC-455 - */ + #[Group('DDC-600')] + #[Group('DDC-455')] public function testNewAssociatedEntityDuringFlushThrowsException3(): void { $art = new CmsArticle(); @@ -890,7 +885,7 @@ public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void self::assertEquals('Benjamin E.', $this->_em->find($user::class, $userId)->name); } - /** @group DDC-952 */ + #[Group('DDC-952')] public function testManyToOneFetchModeQuery(): void { $user = new CmsUser(); @@ -919,7 +914,7 @@ public function testManyToOneFetchModeQuery(): void $this->assertQueryCount(2); } - /** @group DDC-720 */ + #[Group('DDC-720')] public function testFlushSingleManagedEntity(): void { $user = new CmsUser(); @@ -938,7 +933,7 @@ public function testFlushSingleManagedEntity(): void self::assertEquals('administrator', $user->status); } - /** @group DDC-720 */ + #[Group('DDC-720')] public function testFlushAndCascadePersist(): void { $user = new CmsUser(); @@ -963,7 +958,7 @@ public function testFlushAndCascadePersist(): void self::assertTrue($address->id > 0, 'other user has an id'); } - /** @group DDC-720 */ + #[Group('DDC-720')] public function testFlushSingleAndNoCascade(): void { $user = new CmsUser(); @@ -986,11 +981,9 @@ public function testFlushSingleAndNoCascade(): void $this->_em->flush(); } - /** - * @group DDC-720 - * @group DDC-1612 - * @group DDC-2267 - */ + #[Group('DDC-720')] + #[Group('DDC-1612')] + #[Group('DDC-2267')] public function testFlushSingleNewEntityThenRemove(): void { $user = new CmsUser(); @@ -1010,7 +1003,7 @@ public function testFlushSingleNewEntityThenRemove(): void self::assertNull($this->_em->find($user::class, $userId)); } - /** @group DDC-1585 */ + #[Group('DDC-1585')] public function testWrongAssociationInstance(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php index f3b7a30e2f8..d64b398fa82 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php @@ -14,8 +14,9 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group CascadeRemoveOrderTest */ +#[Group('CascadeRemoveOrderTest')] class CascadeRemoveOrderTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index 04d4ea3a76a..5edbfa71322 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -17,6 +17,8 @@ use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\Company\CompanyRaffle; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; use function get_debug_type; use function sprintf; @@ -306,7 +308,7 @@ public function testLazyLoading2(): void IterableTester::assertResultsAreTheSame($q); } - /** @group DDC-368 */ + #[Group('DDC-368')] public function testBulkUpdateIssueDDC368(): void { $this->_em->createQuery('UPDATE ' . CompanyEmployee::class . ' AS p SET p.salary = 1') @@ -322,18 +324,17 @@ public function testBulkUpdateIssueDDC368(): void IterableTester::assertResultsAreTheSame($query); } - /** @group DDC-1341 */ + #[Group('DDC-1341')] + #[DoesNotPerformAssertions] public function testBulkUpdateNonScalarParameterDDC1341(): void { $this->_em->createQuery('UPDATE ' . CompanyEmployee::class . ' AS p SET p.startDate = ?0 WHERE p.department = ?1') ->setParameter(0, new DateTime()) ->setParameter(1, 'IT') ->execute(); - - $this->addToAssertionCount(1); } - /** @group DDC-130 */ + #[Group('DDC-130')] public function testDeleteJoinTableRecords(): void { $employee1 = new CompanyEmployee(); @@ -360,7 +361,7 @@ public function testDeleteJoinTableRecords(): void self::assertNull($this->_em->find($employee1::class, $employee1Id)); } - /** @group DDC-728 */ + #[Group('DDC-728')] public function testQueryForInheritedSingleValuedAssociation(): void { $manager = new CompanyManager(); @@ -387,7 +388,7 @@ public function testQueryForInheritedSingleValuedAssociation(): void self::assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); } - /** @group DDC-817 */ + #[Group('DDC-817')] public function testFindByAssociation(): void { $manager = new CompanyManager(); @@ -417,7 +418,7 @@ public function testFindByAssociation(): void self::assertEquals($manager->getId(), $pmanager->getId()); } - /** @group DDC-834 */ + #[Group('DDC-834')] public function testGetReferenceEntityWithSubclasses(): void { $manager = new CompanyManager(); @@ -440,7 +441,7 @@ public function testGetReferenceEntityWithSubclasses(): void self::assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); } - /** @group DDC-992 */ + #[Group('DDC-992')] public function testGetSubClassManyToManyCollection(): void { $manager = new CompanyManager(); @@ -464,7 +465,7 @@ public function testGetSubClassManyToManyCollection(): void self::assertCount(1, $manager->getFriends()); } - /** @group DDC-1777 */ + #[Group('DDC-1777')] public function testExistsSubclass(): void { $manager = new CompanyManager(); @@ -481,7 +482,7 @@ public function testExistsSubclass(): void self::assertTrue($this->_em->getUnitOfWork()->getEntityPersister($manager::class)->exists($manager)); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatching(): void { $manager = new CompanyManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php index c1dbc8f3aeb..0892c78d49e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -14,6 +14,7 @@ use Doctrine\Tests\Models\Navigation\NavTour; use Doctrine\Tests\Models\Navigation\NavUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class CompositePrimaryKeyTest extends OrmFunctionalTestCase { @@ -60,7 +61,7 @@ public function testPersistCompositePkEntity(): void self::assertEquals('Brandenburger Tor', $poi->getName()); } - /** @group DDC-1651 */ + #[Group('DDC-1651')] public function testSetParameterCompositeKeyObject(): void { $this->putGermanysBrandenburderTor(); @@ -167,7 +168,7 @@ public function testUnrecognizedIdentifierFieldsOnGetReference(): void $poi = $this->_em->getReference(NavPointOfInterest::class, ['lat' => 10, 'long' => 20, 'key1' => 100]); } - /** @group DDC-1939 */ + #[Group('DDC-1939')] public function testDeleteCompositePersistentCollection(): void { $this->putGermanysBrandenburderTor(); diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php index 742bc1f6af8..c5fbcc751b5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php @@ -10,6 +10,7 @@ use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild; use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class CustomIdObjectTypeTest extends OrmFunctionalTestCase { @@ -38,10 +39,8 @@ public function testFindByCustomIdObject(): void self::assertSame($parent, $result); } - /** - * @group DDC-3622 - * @group 1336 - */ + #[Group('DDC-3622')] + #[Group('1336')] public function testFetchJoinCustomIdObject(): void { $parent = new CustomIdObjectTypeParent(new CustomIdObject('foo')); @@ -64,10 +63,8 @@ public function testFetchJoinCustomIdObject(): void self::assertSame($parent, $result[0]); } - /** - * @group DDC-3622 - * @group 1336 - */ + #[Group('DDC-3622')] + #[Group('1336')] public function testFetchJoinWhereCustomIdObject(): void { $parent = new CustomIdObjectTypeParent(new CustomIdObject('foo')); diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index f18ababa303..66a1a3ab146 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Table; use Doctrine\ORM\Mapping\ClassMetadata; +use PHPUnit\Framework\Attributes\Group; use function array_change_key_case; use function count; @@ -31,7 +32,7 @@ protected function setUp(): void $this->schemaManager = $this->createSchemaManager(); } - /** @group DDC-2059 */ + #[Group('DDC-2059')] public function testIssue2059(): void { $user = new Table('ddc2059_user'); diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index 76d14ef0741..0ff79e9c7e0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Tests basic operations on entities with default values. @@ -28,7 +29,7 @@ protected function setUp(): void ); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testSimpleDetachMerge(): void { $user = new DefaultValueUser(); @@ -62,7 +63,7 @@ public function testSimpleDetachMerge(): void self::assertEquals('Poweruser', $a2->getUser()->type); } - /** @group DDC-1386 */ + #[Group('DDC-1386')] public function testGetPartialReferenceWithDefaultValueNotEvaluatedInFlush(): void { $user = new DefaultValueUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index aa4f47d8c41..b7fcb209d54 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -8,6 +8,7 @@ use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Description of DetachedEntityTest @@ -21,7 +22,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-203 */ + #[Group('DDC-203')] public function testDetachedEntityThrowsExceptionOnFlush(): void { $ph = new CmsPhonenumber(); @@ -38,7 +39,7 @@ public function testDetachedEntityThrowsExceptionOnFlush(): void $this->_em->flush(); } - /** @group DDC-822 */ + #[Group('DDC-822')] public function testUseDetachedEntityAsQueryParameter(): void { $user = new CmsUser(); @@ -61,7 +62,7 @@ public function testUseDetachedEntityAsQueryParameter(): void self::assertEquals('gblanco', $newUser->username); } - /** @group DDC-920 */ + #[Group('DDC-920')] public function testDetachManagedUnpersistedEntity(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php index 229047b720e..083d86321a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php @@ -10,8 +10,9 @@ use Doctrine\Tests\Models\Company\CompanyContractListener; use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1955 */ +#[Group('DDC-1955')] class EntityListenersTest extends OrmFunctionalTestCase { private CompanyContractListener $listener; diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 7ffbcabb3a1..38d78823e28 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -26,6 +26,7 @@ use Doctrine\Tests\Models\DDC753\DDC753EntityWithCustomRepository; use Doctrine\Tests\Models\DDC753\DDC753EntityWithDefaultCustomRepository; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_values; use function reset; @@ -307,10 +308,8 @@ public function testExceptionIsThrownWhenUsingInvalidFieldName(): void ->findByThisFieldDoesNotExist('testvalue'); } - /** - * @group locking - * @group DDC-178 - */ + #[Group('locking')] + #[Group('DDC-178')] public function testPessimisticReadLockWithoutTransactionThrowsException(): void { $this->expectException(TransactionRequiredException::class); @@ -319,10 +318,8 @@ public function testPessimisticReadLockWithoutTransactionThrowsException(): void ->find(1, LockMode::PESSIMISTIC_READ); } - /** - * @group locking - * @group DDC-178 - */ + #[Group('locking')] + #[Group('DDC-178')] public function testPessimisticWriteLockWithoutTransactionThrowsException(): void { $this->expectException(TransactionRequiredException::class); @@ -331,10 +328,8 @@ public function testPessimisticWriteLockWithoutTransactionThrowsException(): voi ->find(1, LockMode::PESSIMISTIC_WRITE); } - /** - * @group locking - * @group DDC-178 - */ + #[Group('locking')] + #[Group('DDC-178')] public function testOptimisticLockUnversionedEntityThrowsException(): void { $this->expectException(OptimisticLockException::class); @@ -343,10 +338,8 @@ public function testOptimisticLockUnversionedEntityThrowsException(): void ->find(1, LockMode::OPTIMISTIC); } - /** - * @group locking - * @group DDC-178 - */ + #[Group('locking')] + #[Group('DDC-178')] public function testIdentityMappedOptimisticLockUnversionedEntityThrowsException(): void { $user = new CmsUser(); @@ -365,7 +358,7 @@ public function testIdentityMappedOptimisticLockUnversionedEntityThrowsException $this->_em->find(CmsUser::class, $userId, LockMode::OPTIMISTIC); } - /** @group DDC-819 */ + #[Group('DDC-819')] public function testFindMagicCallByNullValue(): void { $this->loadFixture(); @@ -376,7 +369,7 @@ public function testFindMagicCallByNullValue(): void self::assertCount(1, $users); } - /** @group DDC-819 */ + #[Group('DDC-819')] public function testInvalidMagicCall(): void { $this->expectException(BadMethodCallException::class); @@ -385,7 +378,7 @@ public function testInvalidMagicCall(): void $repos->foo(); } - /** @group DDC-817 */ + #[Group('DDC-817')] public function testFindByAssociationKeyExceptionOnInverseSide(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -397,7 +390,7 @@ public function testFindByAssociationKeyExceptionOnInverseSide(): void $user = $repos->findBy(['address' => $addressId]); } - /** @group DDC-817 */ + #[Group('DDC-817')] public function testFindOneByAssociationKey(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -408,7 +401,7 @@ public function testFindOneByAssociationKey(): void self::assertEquals($addressId, $address->id); } - /** @group DDC-1241 */ + #[Group('DDC-1241')] public function testFindOneByOrderBy(): void { $this->loadFixture(); @@ -420,7 +413,7 @@ public function testFindOneByOrderBy(): void self::assertNotSame($userAsc, $userDesc); } - /** @group DDC-817 */ + #[Group('DDC-817')] public function testFindByAssociationKey(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -432,7 +425,7 @@ public function testFindByAssociationKey(): void self::assertEquals($addressId, $addresses[0]->id); } - /** @group DDC-817 */ + #[Group('DDC-817')] public function testFindAssociationByMagicCall(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -444,7 +437,7 @@ public function testFindAssociationByMagicCall(): void self::assertEquals($addressId, $addresses[0]->id); } - /** @group DDC-817 */ + #[Group('DDC-817')] public function testFindOneAssociationByMagicCall(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -455,7 +448,7 @@ public function testFindOneAssociationByMagicCall(): void self::assertEquals($addressId, $address->id); } - /** @group DDC-1087 */ + #[Group('DDC-1087')] public function testIsNullCriteriaDoesNotGenerateAParameter(): void { $repos = $this->_em->getRepository(CmsUser::class); @@ -476,7 +469,7 @@ public function testIsNullCriteria(): void self::assertCount(1, $users); } - /** @group DDC-1094 */ + #[Group('DDC-1094')] public function testFindByLimitOffset(): void { $this->loadFixture(); @@ -492,7 +485,7 @@ public function testFindByLimitOffset(): void self::assertNotSame($users1[0], $users2[0]); } - /** @group DDC-1094 */ + #[Group('DDC-1094')] public function testFindByOrderBy(): void { $this->loadFixture(); @@ -507,7 +500,7 @@ public function testFindByOrderBy(): void self::assertSame($usersAsc[3], $usersDesc[0]); } - /** @group DDC-1376 */ + #[Group('DDC-1376')] public function testFindByOrderByAssociation(): void { $this->loadFixtureUserEmail(); @@ -523,7 +516,7 @@ public function testFindByOrderByAssociation(): void self::assertEquals($resultAsc[2]->getEmail()->getId(), $resultDesc[0]->getEmail()->getId()); } - /** @group DDC-1426 */ + #[Group('DDC-1426')] public function testFindFieldByMagicCallOrderBy(): void { $this->loadFixture(); @@ -543,7 +536,7 @@ public function testFindFieldByMagicCallOrderBy(): void self::assertSame($usersAsc[1], $usersDesc[0]); } - /** @group DDC-1426 */ + #[Group('DDC-1426')] public function testFindFieldByMagicCallLimitOffset(): void { $this->loadFixture(); @@ -557,7 +550,7 @@ public function testFindFieldByMagicCallLimitOffset(): void self::assertNotSame($users1[0], $users2[0]); } - /** @group DDC-753 */ + #[Group('DDC-753')] public function testDefaultRepositoryClassName(): void { self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); @@ -577,7 +570,7 @@ public function testDefaultRepositoryClassName(): void self::assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), EntityRepository::class); } - /** @group DDC-3257 */ + #[Group('DDC-3257')] public function testCanRetrieveRepositoryFromClassNameWithLeadingBackslash(): void { self::assertSame( @@ -586,7 +579,7 @@ public function testCanRetrieveRepositoryFromClassNameWithLeadingBackslash(): vo ); } - /** @group DDC-1376 */ + #[Group('DDC-1376')] public function testInvalidOrderByAssociation(): void { $this->expectException(InvalidFindByCall::class); @@ -595,7 +588,7 @@ public function testInvalidOrderByAssociation(): void ->findBy(['status' => 'test'], ['address' => 'ASC']); } - /** @group DDC-1500 */ + #[Group('DDC-1500')] public function testInvalidOrientation(): void { $this->expectException(InvalidOrientation::class); @@ -605,7 +598,7 @@ public function testInvalidOrientation(): void $repo->findBy(['status' => 'test'], ['username' => 'INVALID']); } - /** @group DDC-1713 */ + #[Group('DDC-1713')] public function testFindByAssociationArray(): void { $address1 = new CmsAddress(); @@ -662,7 +655,7 @@ public function testFindByAssociationArray(): void } } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingEmptyCriteria(): void { $this->loadFixture(); @@ -673,7 +666,7 @@ public function testMatchingEmptyCriteria(): void self::assertCount(4, $users); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingCriteriaEqComparison(): void { $this->loadFixture(); @@ -686,7 +679,7 @@ public function testMatchingCriteriaEqComparison(): void self::assertCount(1, $users); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingCriteriaNeqComparison(): void { $this->loadFixture(); @@ -699,7 +692,7 @@ public function testMatchingCriteriaNeqComparison(): void self::assertCount(3, $users); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingCriteriaInComparison(): void { $this->loadFixture(); @@ -712,7 +705,7 @@ public function testMatchingCriteriaInComparison(): void self::assertCount(2, $users); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingCriteriaNotInComparison(): void { $this->loadFixture(); @@ -725,7 +718,7 @@ public function testMatchingCriteriaNotInComparison(): void self::assertCount(1, $users); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingCriteriaLtComparison(): void { $firstUserId = $this->loadFixture(); @@ -738,7 +731,7 @@ public function testMatchingCriteriaLtComparison(): void self::assertCount(1, $users); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingCriteriaLeComparison(): void { $firstUserId = $this->loadFixture(); @@ -751,7 +744,7 @@ public function testMatchingCriteriaLeComparison(): void self::assertCount(2, $users); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingCriteriaGtComparison(): void { $firstUserId = $this->loadFixture(); @@ -764,7 +757,7 @@ public function testMatchingCriteriaGtComparison(): void self::assertCount(3, $users); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatchingCriteriaGteComparison(): void { $firstUserId = $this->loadFixture(); @@ -777,7 +770,7 @@ public function testMatchingCriteriaGteComparison(): void self::assertCount(4, $users); } - /** @group DDC-2430 */ + #[Group('DDC-2430')] public function testMatchingCriteriaAssocationByObjectInMemory(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -798,7 +791,7 @@ public function testMatchingCriteriaAssocationByObjectInMemory(): void self::assertCount(1, $addresses->matching($criteria)); } - /** @group DDC-2430 */ + #[Group('DDC-2430')] public function testMatchingCriteriaAssocationInWithArray(): void { [$userId, $addressId] = $this->loadAssociatedFixture(); @@ -867,7 +860,7 @@ public function testMatchingCriteriaEndsWithComparison(): void self::assertCount(2, $users); } - /** @group DDC-2478 */ + #[Group('DDC-2478')] public function testMatchingCriteriaNullAssocComparison(): void { $fixtures = $this->loadFixtureUserEmail(); @@ -894,7 +887,7 @@ public function testMatchingCriteriaNullAssocComparison(): void self::assertNull($usersEqNull[0]->getEmail()); } - /** @group DDC-2055 */ + #[Group('DDC-2055')] public function testCreateResultSetMappingBuilder(): void { $repository = $this->_em->getRepository(CmsUser::class); @@ -904,7 +897,7 @@ public function testCreateResultSetMappingBuilder(): void self::assertEquals(['u' => CmsUser::class], $rsm->aliasMap); } - /** @group DDC-3045 */ + #[Group('DDC-3045')] public function testFindByFieldInjectionPrevented(): void { $this->expectException(UnrecognizedField::class); @@ -914,7 +907,7 @@ public function testFindByFieldInjectionPrevented(): void $repository->findBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']); } - /** @group DDC-3045 */ + #[Group('DDC-3045')] public function testFindOneByFieldInjectionPrevented(): void { $this->expectException(ORMException::class); @@ -924,7 +917,7 @@ public function testFindOneByFieldInjectionPrevented(): void $repository->findOneBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']); } - /** @group DDC-3045 */ + #[Group('DDC-3045')] public function testMatchingInjectionPrevented(): void { $this->expectException(UnrecognizedField::class); @@ -939,7 +932,7 @@ public function testMatchingInjectionPrevented(): void $result->toArray(); } - /** @group DDC-3045 */ + #[Group('DDC-3045')] public function testFindInjectionPrevented(): void { $this->expectException(UnrecognizedIdentifierFields::class); @@ -949,7 +942,7 @@ public function testFindInjectionPrevented(): void $repository->find(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test', 'id' => 1]); } - /** @group DDC-3056 */ + #[Group('DDC-3056')] public function testFindByNullValueInInCondition(): void { $user1 = new CmsUser(); @@ -972,7 +965,7 @@ public function testFindByNullValueInInCondition(): void self::assertSame($user1, reset($users)); } - /** @group DDC-3056 */ + #[Group('DDC-3056')] public function testFindByNullValueInMultipleInCriteriaValues(): void { $user1 = new CmsUser(); @@ -998,7 +991,7 @@ public function testFindByNullValueInMultipleInCriteriaValues(): void self::assertSame($user1, reset($users)); } - /** @group DDC-3056 */ + #[Group('DDC-3056')] public function testFindMultipleByNullValueInMultipleInCriteriaValues(): void { $user1 = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php index 07a5928349a..cc2dc2b8f1e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php @@ -22,12 +22,14 @@ use Doctrine\Tests\Models\Enums\TypedCard; use Doctrine\Tests\Models\Enums\Unit; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhp; use function dirname; use function sprintf; use function uniqid; -/** @requires PHP 8.1 */ +#[RequiresPhp('8.1')] class EnumTest extends OrmFunctionalTestCase { public function setUp(): void @@ -42,11 +44,8 @@ public function setUp(): void } } - /** - * @param class-string $cardClass - * - * @dataProvider provideCardClasses - */ + /** @param class-string $cardClass */ + #[DataProvider('provideCardClasses')] public function testEnumMapping(string $cardClass): void { $this->setUpEntitySchema([$cardClass]); @@ -344,11 +343,8 @@ public function testFindByEnum(): void } } - /** - * @param class-string $cardClass - * - * @dataProvider provideCardClasses - */ + /** @param class-string $cardClass */ + #[DataProvider('provideCardClasses')] public function testEnumWithNonMatchingDatabaseValueThrowsException(string $cardClass): void { $this->setUpEntitySchema([$cardClass]); diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index 8a879948986..1b6a872e9a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -12,6 +12,7 @@ use Doctrine\Tests\Models\DDC2504\DDC2504ChildClass; use Doctrine\Tests\Models\DDC2504\DDC2504OtherClass; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_shift; use function assert; @@ -102,10 +103,8 @@ public function tearDown(): void unset($class->associationMappings['users']['indexBy']); } - /** - * @group DDC-546 - * @group non-cacheable - */ + #[Group('DDC-546')] + #[Group('non-cacheable')] public function testCountNotInitializesCollection(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -121,7 +120,7 @@ public function testCountNotInitializesCollection(): void $this->assertQueryCount(2, 'Expecting two queries to be fired for count, then iteration.'); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testCountWhenNewEntityPresent(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -137,10 +136,8 @@ public function testCountWhenNewEntityPresent(): void self::assertFalse($user->groups->isInitialized()); } - /** - * @group DDC-546 - * @group non-cacheable - */ + #[Group('DDC-546')] + #[Group('non-cacheable')] public function testCountWhenInitialized(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -154,7 +151,7 @@ public function testCountWhenInitialized(): void $this->assertQueryCount(1, 'Should only execute one query to initialize collection, no extra query for count() more.'); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testCountInverseCollection(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); @@ -164,7 +161,7 @@ public function testCountInverseCollection(): void self::assertFalse($group->users->isInitialized(), 'Extra Lazy collection should not be initialized by counting the collection.'); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testCountOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -173,7 +170,7 @@ public function testCountOneToMany(): void self::assertCount(2, $user->articles); } - /** @group DDC-2504 */ + #[Group('DDC-2504')] public function testCountOneToManyJoinedInheritance(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -182,7 +179,7 @@ public function testCountOneToManyJoinedInheritance(): void self::assertCount(2, $otherClass->childClasses); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testFullSlice(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -192,10 +189,8 @@ public function testFullSlice(): void self::assertCount(3, $someGroups); } - /** - * @group DDC-546 - * @group non-cacheable - */ + #[Group('DDC-546')] + #[Group('non-cacheable')] public function testSlice(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -224,10 +219,8 @@ public function testSlice(): void $this->assertQueryCount(3); } - /** - * @group DDC-546 - * @group non-cacheable - */ + #[Group('DDC-546')] + #[Group('non-cacheable')] public function testSliceInitializedCollection(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -245,7 +238,7 @@ public function testSliceInitializedCollection(): void self::assertTrue($user->groups->contains(array_shift($someGroups))); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testSliceInverseCollection(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); @@ -264,7 +257,7 @@ public function testSliceInverseCollection(): void $this->assertQueryCount(2, 'Slicing two parts should only execute two additional queries.'); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testSliceOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -278,7 +271,7 @@ public function testSliceOneToMany(): void $this->assertQueryCount(2); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testContainsOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -324,7 +317,7 @@ public function testContainsOneToMany(): void self::assertFalse($user->articles->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** @group DDC-2504 */ + #[Group('DDC-2504')] public function testLazyOneToManyJoinedInheritanceIsLazilyInitialized(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -332,7 +325,7 @@ public function testLazyOneToManyJoinedInheritanceIsLazilyInitialized(): void self::assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); } - /** @group DDC-2504 */ + #[Group('DDC-2504')] public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWhenMatchingItemIsFound(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -346,7 +339,7 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect $this->assertQueryCount(1, 'Search operation was performed via SQL'); } - /** @group DDC-2504 */ + #[Group('DDC-2504')] public function testContainsOnOneToManyJoinedInheritanceWillNotCauseQueriesWhenNonPersistentItemIsMatched(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -356,7 +349,7 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotCauseQueriesWhenN $this->assertQueryCount(0, 'Checking for contains of new entity should cause no query to be executed.'); } - /** @group DDC-2504 */ + #[Group('DDC-2504')] public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithClearStateMatchingItem(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -372,7 +365,7 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect self::assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** @group DDC-2504 */ + #[Group('DDC-2504')] public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithNewStateNotMatchingItem(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -387,7 +380,7 @@ public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollect self::assertFalse($otherClass->childClasses->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** @group DDC-2504 */ + #[Group('DDC-2504')] public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollection(): void { $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -397,7 +390,7 @@ public function testCountingOnOneToManyJoinedInheritanceWillNotInitializeCollect self::assertFalse($otherClass->childClasses->isInitialized()); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testContainsManyToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -444,7 +437,7 @@ public function testContainsManyToMany(): void self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** @group DDC-546 */ + #[Group('DDC-546')] public function testContainsManyToManyInverse(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); @@ -466,7 +459,7 @@ public function testContainsManyToManyInverse(): void self::assertFalse($user->groups->isInitialized(), 'Post-Condition: Collection is not initialized.'); } - /** @group DDC-1399 */ + #[Group('DDC-1399')] public function testCountAfterAddThenFlush(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -486,10 +479,8 @@ public function testCountAfterAddThenFlush(): void self::assertCount(4, $user->groups); } - /** - * @group DDC-1462 - * @group non-cacheable - */ + #[Group('DDC-1462')] + #[Group('non-cacheable')] public function testSliceOnDirtyCollection(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -508,10 +499,8 @@ public function testSliceOnDirtyCollection(): void $this->assertQueryCount(1); } - /** - * @group DDC-1398 - * @group non-cacheable - */ + #[Group('DDC-1398')] + #[Group('non-cacheable')] public function testGetIndexByIdentifier(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -528,7 +517,7 @@ public function testGetIndexByIdentifier(): void $this->assertQueryCount(1, 'Getting the same entity should not cause an extra query to be executed'); } - /** @group DDC-1398 */ + #[Group('DDC-1398')] public function testGetIndexByOneToMany(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -543,7 +532,7 @@ public function testGetIndexByOneToMany(): void self::assertSame($article, $this->_em->find(CmsArticle::class, $this->articleId)); } - /** @group DDC-1398 */ + #[Group('DDC-1398')] public function testGetIndexByManyToManyInverseSide(): void { $group = $this->_em->find(CmsGroup::class, $this->groupId); @@ -558,7 +547,7 @@ public function testGetIndexByManyToManyInverseSide(): void self::assertSame($user, $this->_em->find(CmsUser::class, $this->userId)); } - /** @group DDC-1398 */ + #[Group('DDC-1398')] public function testGetIndexByManyToManyOwningSide(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -573,7 +562,7 @@ public function testGetIndexByManyToManyOwningSide(): void self::assertSame($group, $this->_em->find(CmsGroup::class, $this->groupId)); } - /** @group DDC-1398 */ + #[Group('DDC-1398')] public function testGetNonExistentIndexBy(): void { $user = $this->_em->find(CmsUser::class, $this->userId); diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php index e77b043f9f2..114fe3396b2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * FlushEventTest @@ -49,7 +50,7 @@ public function testPersistNewEntitiesOnPreFlush(): void //$this->_em->flush(); } - /** @group DDC-2173 */ + #[Group('DDC-2173')] public function testPreAndOnFlushCalledAlways(): void { $listener = new OnFlushCalledListener(); diff --git a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php index 690e0f25a68..6e6ed07f352 100644 --- a/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/GH5988Test.php @@ -15,14 +15,14 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\DbalTypes\CustomIdObject; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function str_replace; /** * Functional tests for the Class Table Inheritance mapping strategy with custom id object types. - * - * @group GH5988 */ +#[Group('GH5988')] final class GH5988Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php index 6171eab0564..5cd5b6cb906 100644 --- a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php @@ -7,9 +7,10 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\Tests\Models\Cms\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Cache\Adapter\ArrayAdapter; -/** @group DDC-1766 */ +#[Group('DDC-1766')] class HydrationCacheTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php index 349b168164d..de3b44e1f16 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * IdentityMapTest @@ -206,7 +207,7 @@ public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQue self::assertCount(4, $user3->getPhonenumbers()); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testCollectionValuedAssociationIdentityMapBehaviorWithRefresh(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php index a92856fc2a1..ab8a3eba74a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php @@ -8,10 +8,11 @@ use Doctrine\Tests\Models\StockExchange\Market; use Doctrine\Tests\Models\StockExchange\Stock; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** @group DDC-250 */ +#[Group('DDC-250')] class IndexByAssociationTest extends OrmFunctionalTestCase { private Market|null $market = null; diff --git a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php index 4daa9246ac6..9a27bd7efa6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php @@ -7,6 +7,7 @@ use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedChildClass; use Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class JoinedTableCompositeKeyTest extends OrmFunctionalTestCase { @@ -29,7 +30,7 @@ public function testInsertWithCompositeKey(): void self::assertEquals($childEntity, $entity); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testUpdateWithCompositeKey(): void { $childEntity = new JoinedChildClass(); diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index 733b8d35626..0a51b15b092 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -34,6 +34,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function count; use function current; @@ -119,7 +120,7 @@ public function testChangesDontGetLost(): void self::assertEquals('Hello World', $user2->getValue()); } - /** @group DDC-194 */ + #[Group('DDC-194')] public function testGetReferenceWithPostLoadEventIsDelayedUntilProxyTrigger(): void { $entity = new LifecycleCallbackTestEntity(); @@ -137,7 +138,7 @@ public function testGetReferenceWithPostLoadEventIsDelayedUntilProxyTrigger(): v self::assertTrue($reference->postLoadCallbackInvoked); } - /** @group DDC-958 */ + #[Group('DDC-958')] public function testPostLoadTriggeredOnRefresh(): void { $entity = new LifecycleCallbackTestEntity(); @@ -156,7 +157,7 @@ public function testPostLoadTriggeredOnRefresh(): void self::assertTrue($reference->postLoadCallbackInvoked, 'postLoad should be invoked when refresh() is called.'); } - /** @group DDC-113 */ + #[Group('DDC-113')] public function testCascadedEntitiesCallsPrePersist(): void { $e1 = new LifecycleCallbackTestEntity(); @@ -177,10 +178,8 @@ public function testCascadedEntitiesCallsPrePersist(): void self::assertTrue($e2->prePersistCallbackInvoked); } - /** - * @group DDC-54 - * @group DDC-3005 - */ + #[Group('DDC-54')] + #[Group('DDC-3005')] public function testCascadedEntitiesLoadedInPostLoad(): void { $e1 = new LifecycleCallbackTestEntity(); @@ -219,10 +218,8 @@ public function testCascadedEntitiesLoadedInPostLoad(): void self::assertEquals(current($entities)->cascader->postLoadEntitiesCount, 2); } - /** - * @group DDC-54 - * @group DDC-3005 - */ + #[Group('DDC-54')] + #[Group('DDC-3005')] public function testCascadedEntitiesNotLoadedInPostLoadDuringIteration(): void { $e1 = new LifecycleCallbackTestEntity(); @@ -262,10 +259,8 @@ public function testCascadedEntitiesNotLoadedInPostLoadDuringIteration(): void } } - /** - * @group DDC-54 - * @group DDC-3005 - */ + #[Group('DDC-54')] + #[Group('DDC-3005')] public function testCascadedEntitiesNotLoadedInPostLoadDuringIterationWithSimpleObjectHydrator(): void { $this->_em->persist(new LifecycleCallbackTestEntity()); @@ -361,7 +356,7 @@ public function testLifecycleListenerChangeUpdateChangeSet(): void self::assertEquals('Bob', $bob->getName()); } - /** @group DDC-1955 */ + #[Group('DDC-1955')] public function testLifecycleCallbackEventArgs(): void { $e = new LifecycleCallbackEventArgEntity(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php index e4dd9603522..e84f412e058 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php @@ -8,12 +8,13 @@ use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\OrmFunctionalTestCase; use GearmanClient; +use PHPUnit\Framework\Attributes\Group; use function class_exists; use function max; use function serialize; -/** @group locking_functional */ +#[Group('locking_functional')] class GearmanLockTest extends OrmFunctionalTestCase { private GearmanClient|null $gearman = null; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index d858e2a2e60..891cbf15542 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -13,8 +13,10 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Exception; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; -/** @group locking */ +#[Group('locking')] class LockTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -24,10 +26,9 @@ protected function setUp(): void parent::setUp(); } - /** - * @group DDC-178 - * @group locking - */ + #[Group('DDC-178')] + #[Group('locking')] + #[DoesNotPerformAssertions] public function testLockVersionedEntity(): void { $article = new CmsArticle(); @@ -38,14 +39,10 @@ public function testLockVersionedEntity(): void $this->_em->flush(); $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version); - - $this->addToAssertionCount(1); } - /** - * @group DDC-178 - * @group locking - */ + #[Group('DDC-178')] + #[Group('locking')] public function testLockVersionedEntityMismatchThrowsException(): void { $article = new CmsArticle(); @@ -59,10 +56,8 @@ public function testLockVersionedEntityMismatchThrowsException(): void $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); } - /** - * @group DDC-178 - * @group locking - */ + #[Group('DDC-178')] + #[Group('locking')] public function testLockUnversionedEntityThrowsException(): void { $user = new CmsUser(); @@ -78,10 +73,8 @@ public function testLockUnversionedEntityThrowsException(): void $this->_em->lock($user, LockMode::OPTIMISTIC); } - /** - * @group DDC-178 - * @group locking - */ + #[Group('DDC-178')] + #[Group('locking')] public function testLockUnmanagedEntityThrowsException(): void { $article = new CmsArticle(); @@ -92,10 +85,8 @@ public function testLockUnmanagedEntityThrowsException(): void $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); } - /** - * @group DDC-178 - * @group locking - */ + #[Group('DDC-178')] + #[Group('locking')] public function testLockPessimisticReadNoTransactionThrowsException(): void { $article = new CmsArticle(); @@ -110,10 +101,8 @@ public function testLockPessimisticReadNoTransactionThrowsException(): void $this->_em->lock($article, LockMode::PESSIMISTIC_READ); } - /** - * @group DDC-178 - * @group locking - */ + #[Group('DDC-178')] + #[Group('locking')] public function testLockPessimisticWriteNoTransactionThrowsException(): void { $article = new CmsArticle(); @@ -128,7 +117,7 @@ public function testLockPessimisticWriteNoTransactionThrowsException(): void $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); } - /** @group locking */ + #[Group('locking')] public function testRefreshWithLockPessimisticWriteNoTransactionThrowsException(): void { $article = new CmsArticle(); @@ -143,10 +132,8 @@ public function testRefreshWithLockPessimisticWriteNoTransactionThrowsException( $this->_em->refresh($article, LockMode::PESSIMISTIC_WRITE); } - /** - * @group DDC-178 - * @group locking - */ + #[Group('DDC-178')] + #[Group('locking')] public function testLockPessimisticWrite(): void { $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSQL(); @@ -179,7 +166,7 @@ public function testLockPessimisticWrite(): void self::assertStringContainsString($writeLockSql, $lastLoggedQuery); } - /** @group locking */ + #[Group('locking')] public function testRefreshWithLockPessimisticWrite(): void { $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSQL(); @@ -212,7 +199,7 @@ public function testRefreshWithLockPessimisticWrite(): void self::assertStringContainsString($writeLockSql, $lastLoggedQuery); } - /** @group DDC-178 */ + #[Group('DDC-178')] public function testLockPessimisticRead(): void { $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSQL(); @@ -246,7 +233,7 @@ public function testLockPessimisticRead(): void self::assertStringContainsString($readLockSql, $lastLoggedQuery); } - /** @group DDC-1693 */ + #[Group('DDC-1693')] public function testLockOptimisticNonVersionedThrowsExceptionInDQL(): void { $dql = 'SELECT u FROM ' . CmsUser::class . " u WHERE u.username = 'gblanco'"; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index 26b480c0d14..bb88657665b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -18,6 +18,8 @@ use Doctrine\ORM\Mapping\Version; use Doctrine\ORM\OptimisticLockException; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use function date; use function strtotime; @@ -59,7 +61,7 @@ public function testJoinedChildInsertSetsInitialVersionValue(): OptimisticJoined return $test; } - /** @depends testJoinedChildInsertSetsInitialVersionValue */ + #[Depends('testJoinedChildInsertSetsInitialVersionValue')] public function testJoinedChildFailureThrowsException(OptimisticJoinedChild $child): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild t WHERE t.id = :id'); @@ -98,7 +100,7 @@ public function testJoinedParentInsertSetsInitialVersionValue(): OptimisticJoine return $test; } - /** @depends testJoinedParentInsertSetsInitialVersionValue */ + #[Depends('testJoinedParentInsertSetsInitialVersionValue')] public function testJoinedParentFailureThrowsException(OptimisticJoinedParent $parent): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent t WHERE t.id = :id'); @@ -156,7 +158,7 @@ public function testStandardInsertSetsInitialVersionValue(): OptimisticStandard return $test; } - /** @depends testStandardInsertSetsInitialVersionValue */ + #[Depends('testStandardInsertSetsInitialVersionValue')] public function testStandardFailureThrowsException(OptimisticStandard $entity): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard t WHERE t.id = :id'); @@ -180,6 +182,7 @@ public function testStandardFailureThrowsException(OptimisticStandard $entity): } } + #[DoesNotPerformAssertions] public function testLockWorksWithProxy(): void { $this->createSchema(); @@ -193,8 +196,6 @@ public function testLockWorksWithProxy(): void $proxy = $this->_em->getReference(OptimisticStandard::class, $test->id); $this->_em->lock($proxy, LockMode::OPTIMISTIC, 1); - - $this->addToAssertionCount(1); } public function testOptimisticTimestampSetsDefaultValue(): OptimisticTimestamp @@ -214,7 +215,7 @@ public function testOptimisticTimestampSetsDefaultValue(): OptimisticTimestamp return $test; } - /** @depends testOptimisticTimestampSetsDefaultValue */ + #[Depends('testOptimisticTimestampSetsDefaultValue')] public function testOptimisticTimestampFailureThrowsException(OptimisticTimestamp $entity): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id'); @@ -244,7 +245,7 @@ public function testOptimisticTimestampFailureThrowsException(OptimisticTimestam self::assertSame($test, $caughtException->getEntity()); } - /** @depends testOptimisticTimestampSetsDefaultValue */ + #[Depends('testOptimisticTimestampSetsDefaultValue')] public function testOptimisticTimestampLockFailureThrowsException(OptimisticTimestamp $entity): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id'); diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php index af4d56bb5f7..d27697b510f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -12,6 +12,7 @@ use Doctrine\Tests\Models\CMS\CmsTag; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -208,7 +209,7 @@ public function testRetrieveManyToManyAndAddMore(): void self::assertCount(3, $freshUser->getGroups()); } - /** @group DDC-130 */ + #[Group('DDC-130')] public function testRemoveUserWithManyGroups(): void { $user = $this->addCmsUserGblancoWithGroups(2); @@ -221,7 +222,7 @@ public function testRemoveUserWithManyGroups(): void self::assertNull($newUser); } - /** @group DDC-130 */ + #[Group('DDC-130')] public function testRemoveGroupWithUser(): void { $user = $this->addCmsUserGblancoWithGroups(2); @@ -249,7 +250,7 @@ public function testDereferenceCollectionDelete(): void self::assertCount(0, $newUser->getGroups()); } - /** @group DDC-839 */ + #[Group('DDC-839')] public function testWorkWithDqlHydratedEmptyCollection(): void { $user = $this->addCmsUserGblancoWithGroups(0); @@ -296,7 +297,7 @@ public function addCmsUserGblancoWithGroups(int $groupCount = 1): CmsUser return $user; } - /** @group DDC-978 */ + #[Group('DDC-978')] public function testClearAndResetCollection(): void { $user = $this->addCmsUserGblancoWithGroups(2); @@ -330,7 +331,7 @@ public function testClearAndResetCollection(): void self::assertEquals('Developers_New2', $user->groups[1]->name); } - /** @group DDC-733 */ + #[Group('DDC-733')] public function testInitializePersistentCollection(): void { $user = $this->addCmsUserGblancoWithGroups(2); @@ -343,10 +344,8 @@ public function testInitializePersistentCollection(): void self::assertTrue($user->groups->isInitialized(), 'Collection should be initialized after calling UnitOfWork::initializeObject()'); } - /** - * @group DDC-1189 - * @group DDC-956 - */ + #[Group('DDC-1189')] + #[Group('DDC-956')] public function testClearBeforeLazyLoad(): void { $user = $this->addCmsUserGblancoWithGroups(4); @@ -363,7 +362,7 @@ public function testClearBeforeLazyLoad(): void self::assertCount(0, $user->groups); } - /** @group DDC-3952 */ + #[Group('DDC-3952')] public function testManyToManyOrderByIsNotIgnored(): void { $user = $this->addCmsUserGblancoWithGroups(1); @@ -400,7 +399,7 @@ public function testManyToManyOrderByIsNotIgnored(): void ); } - /** @group DDC-3952 */ + #[Group('DDC-3952')] public function testManyToManyOrderByHonorsFieldNameColumnNameAliases(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 752880d83f2..d3add5d7eb7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -25,6 +25,7 @@ use Doctrine\Tests\Models\DDC3899\DDC3899User; use Doctrine\Tests\OrmFunctionalTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; class NativeQueryTest extends OrmFunctionalTestCase { @@ -314,7 +315,7 @@ public function testJoinedOneToOneNativeQueryWithRSMBuilder(): void self::assertEquals($user->name, $address->getUser()->getName()); } - /** @group rsm-sti */ + #[Group('rsm-sti')] public function testConcreteClassInSingleTableInheritanceSchemaWithRSMBuilderIsFine(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -323,7 +324,7 @@ public function testConcreteClassInSingleTableInheritanceSchemaWithRSMBuilderIsF self::assertSame(CompanyFixContract::class, $rsm->getClassName('c')); } - /** @group rsm-sti */ + #[Group('rsm-sti')] public function testAbstractClassInSingleTableInheritanceSchemaWithRSMBuilderThrowsException(): void { $this->expectException(InvalidArgumentException::class); @@ -341,7 +342,7 @@ public function testRSMBuilderThrowsExceptionOnColumnConflict(): void $rsm->addJoinedEntityFromClassMetadata(CmsAddress::class, 'a', 'u', 'address'); } - /** @group PR-39 */ + #[Group('PR-39')] public function testUnknownParentAliasThrowsException(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -357,7 +358,7 @@ public function testUnknownParentAliasThrowsException(): void $users = $query->getResult(); } - /** @group DDC-2055 */ + #[Group('DDC-2055')] public function testGenerateSelectClauseNoRenameSingleEntity(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -368,7 +369,7 @@ public function testGenerateSelectClauseNoRenameSingleEntity(): void $this->assertSQLEquals('u.id AS id, u.status AS status, u.username AS username, u.name AS name, u.email_id AS email_id', $selectClause); } - /** @group DDC-2055 */ + #[Group('DDC-2055')] public function testGenerateSelectClauseCustomRenames(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -382,7 +383,7 @@ public function testGenerateSelectClauseCustomRenames(): void $this->assertSQLEquals('u.id AS id1, u.status AS status, u.username AS username2, u.name AS name, u.email_id AS email_id', $selectClause); } - /** @group DDC-2055 */ + #[Group('DDC-2055')] public function testGenerateSelectClauseRenameTableAlias(): void { $rsm = new ResultSetMappingBuilder($this->_em); @@ -393,7 +394,7 @@ public function testGenerateSelectClauseRenameTableAlias(): void $this->assertSQLEquals('u1.id AS id, u1.status AS status, u1.username AS username, u1.name AS name, u1.email_id AS email_id', $selectClause); } - /** @group DDC-2055 */ + #[Group('DDC-2055')] public function testGenerateSelectClauseIncrement(): void { $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); @@ -404,7 +405,7 @@ public function testGenerateSelectClauseIncrement(): void $this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', $selectClause); } - /** @group DDC-2055 */ + #[Group('DDC-2055')] public function testGenerateSelectClauseToString(): void { $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); @@ -413,7 +414,7 @@ public function testGenerateSelectClauseToString(): void $this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', (string) $rsm); } - /** @group DDC-3899 */ + #[Group('DDC-3899')] public function testGenerateSelectClauseWithDiscriminatorColumn(): void { $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT); diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php index a212acd6701..7f89a938e88 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php @@ -13,10 +13,12 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUserDTO; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function count; -/** @group DDC-1574 */ +#[Group('DDC-1574')] class NewOperatorTest extends OrmFunctionalTestCase { /** @var list */ @@ -101,7 +103,7 @@ private function loadFixtures(): void $this->fixtures = [$u1, $u2, $u3]; } - /** @dataProvider provideDataForHydrationMode */ + #[DataProvider('provideDataForHydrationMode')] public function testShouldSupportsBasicUsage($hydrationMode): void { $dql = ' @@ -142,7 +144,7 @@ public function testShouldSupportsBasicUsage($hydrationMode): void self::assertEquals($this->fixtures[2]->address->city, $result[2]->address); } - /** @dataProvider provideDataForHydrationMode */ + #[DataProvider('provideDataForHydrationMode')] public function testShouldIgnoreAliasesForSingleObject($hydrationMode): void { $dql = ' diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index df7645b6066..a36c0fa4f58 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -10,6 +10,7 @@ use Doctrine\Tests\Models\ECommerce\ECommerceFeature; use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Tests a bidirectional one-to-one association mapping (without inheritance). @@ -157,7 +158,7 @@ public function testJoinFromOwningSide(): void self::assertCount(0, $features); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testMatching(): void { $this->createFixture(); @@ -178,7 +179,7 @@ public function testMatching(): void self::assertCount(2, $results); } - /** @group DDC-2340 */ + #[Group('DDC-2340')] public function testMatchingOnDirtyCollection(): void { $this->createFixture(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php index 232946f5e94..807db4c753f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php @@ -7,6 +7,7 @@ use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Tests a bidirectional one-to-many association mapping with orphan removal. @@ -62,7 +63,7 @@ public function testOrphanRemoval(): void self::assertCount(0, $result, 'CmsPhonenumber should be removed by orphanRemoval'); } - /** @group DDC-3382 */ + #[Group('DDC-3382')] public function testOrphanRemovalRemoveFromCollection(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -78,7 +79,7 @@ public function testOrphanRemovalRemoveFromCollection(): void self::assertCount(1, $result, 'CmsPhonenumber should be removed by orphanRemoval'); } - /** @group DDC-3382 */ + #[Group('DDC-3382')] public function testOrphanRemovalClearCollectionAndReAdd(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -96,7 +97,7 @@ public function testOrphanRemovalClearCollectionAndReAdd(): void self::assertCount(1, $result, 'CmsPhonenumber should be removed by orphanRemoval'); } - /** @group DDC-2524 */ + #[Group('DDC-2524')] public function testOrphanRemovalClearCollectionAndAddNew(): void { $user = $this->_em->find(CmsUser::class, $this->userId); @@ -115,7 +116,7 @@ public function testOrphanRemovalClearCollectionAndAddNew(): void self::assertCount(1, $result, 'Old CmsPhonenumbers should be removed by orphanRemoval and new one added'); } - /** @group DDC-1496 */ + #[Group('DDC-1496')] public function testOrphanRemovalUnitializedCollection(): void { $user = $this->_em->find(CmsUser::class, $this->userId); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index 9bc658b8fd4..5692dad1697 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -16,8 +16,9 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-952 */ +#[Group('DDC-952')] class OneToOneEagerLoadingTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -33,7 +34,7 @@ protected function setUp(): void ); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testEagerLoadOneToOneOwningSide(): void { $train = new Train(new TrainOwner('Alexander')); @@ -56,7 +57,7 @@ public function testEagerLoadOneToOneOwningSide(): void $this->assertQueryCount(1); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testEagerLoadOneToOneNullOwningSide(): void { $train = new Train(new TrainOwner('Alexander')); @@ -74,7 +75,7 @@ public function testEagerLoadOneToOneNullOwningSide(): void $this->assertQueryCount(1); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testEagerLoadOneToOneInverseSide(): void { $owner = new TrainOwner('Alexander'); @@ -93,7 +94,7 @@ public function testEagerLoadOneToOneInverseSide(): void $this->assertQueryCount(1); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testEagerLoadOneToOneNullInverseSide(): void { $driver = new TrainDriver('Dagny Taggert'); @@ -128,7 +129,7 @@ public function testEagerLoadManyToOne(): void self::assertNotNull($waggon->train); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testEagerLoadWithNullableColumnsGeneratesLeftJoinOnBothSides(): void { $train = new Train(new TrainOwner('Alexander')); @@ -151,7 +152,7 @@ public function testEagerLoadWithNullableColumnsGeneratesLeftJoinOnBothSides(): self::assertSame($driverId, $driver->id); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testEagerLoadWithNonNullableColumnsGeneratesInnerJoinOnOwningSide(): void { $waggon = new Waggon(); @@ -179,7 +180,7 @@ public function testEagerLoadWithNonNullableColumnsGeneratesInnerJoinOnOwningSid ); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningSide(): void { $owner = new TrainOwner('Alexander'); @@ -191,7 +192,7 @@ public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningS self::assertNotNull($owner, 'An owner without a train should be able to exist.'); } - /** @group DDC-1946 */ + #[Group('DDC-1946')] public function testEagerLoadingDoesNotBreakRefresh(): void { $train = new Train(new TrainOwner('Johannes')); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php index 911a86f44c9..9a3ffbd6e9e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php @@ -7,6 +7,7 @@ use Doctrine\Tests\Models\OneToOneInverseSideLoad\InverseSide; use Doctrine\Tests\Models\OneToOneInverseSideLoad\OwningSide; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -19,7 +20,7 @@ protected function setUp(): void $this->createSchemaForModels(OwningSide::class, InverseSide::class); } - /** @group GH-6759 */ + #[Group('GH-6759')] public function testInverseSideOneToOneLoadedAfterDqlQuery(): void { $owner = new OwningSide(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index acc25505e97..3f5505459de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -14,6 +14,7 @@ use Doctrine\Persistence\Proxy; use Doctrine\Tests\Models\ECommerce\ECommerceCustomer; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Tests a self referential one-to-one association mapping (without inheritance). @@ -78,7 +79,7 @@ public function testEagerLoadsAssociation(): void $this->assertLoadingOfAssociation($customer); } - /** @group mine */ + #[Group('mine')] public function testLazyLoadsAssociation(): void { $this->createFixture(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php index 1eb8b62448a..50af4af656e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php @@ -8,6 +8,7 @@ use Doctrine\Tests\Models\OneToOneSingleTableInheritance\LitterBox; use Doctrine\Tests\Models\OneToOneSingleTableInheritance\Pet; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -26,10 +27,9 @@ protected function setUp(): void /** * Tests a unidirectional one-to-one association mapping from an inheritance child class - * - * @group DDC-3517 - * @group #1265 */ + #[Group('DDC-3517')] + #[Group('#1265')] public function testFindFromOneToOneOwningSideJoinedTableInheritance(): void { $cat = new Cat(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index 9b43a0ea81b..261a03acd38 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\Models\ECommerce\ECommerceShipping; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Tests a unidirectional one-to-one association mapping (without inheritance). @@ -114,7 +115,7 @@ public function assertForeignKeyIs($value): void self::assertEquals($value, $foreignKey); } - /** @group DDC-762 */ + #[Group('DDC-762')] public function testNullForeignKey(): void { $product = new ECommerceProduct(); diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index a1e95b04237..52d35d1a6f5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -28,6 +28,8 @@ use Doctrine\Tests\Models\Pagination\Logo; use Doctrine\Tests\Models\Pagination\User1; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use ReflectionMethod; use RuntimeException; @@ -35,7 +37,7 @@ use function iterator_to_array; use function sprintf; -/** @group DDC-1613 */ +#[Group('DDC-1613')] class PaginationTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -56,7 +58,7 @@ protected function setUp(): void $this->populate(); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testCountSimpleWithoutJoin($useOutputWalkers): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'; @@ -67,7 +69,7 @@ public function testCountSimpleWithoutJoin($useOutputWalkers): void self::assertCount(9, $paginator); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testCountWithFetchJoin($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'; @@ -102,7 +104,7 @@ public function testCountComplexWithoutOutputWalker(): void self::assertCount(3, $paginator); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testCountWithComplexScalarOrderBy($useOutputWalkers): void { $dql = 'SELECT l FROM Doctrine\Tests\Models\Pagination\Logo l ORDER BY l.imageWidth * l.imageHeight DESC'; @@ -113,7 +115,7 @@ public function testCountWithComplexScalarOrderBy($useOutputWalkers): void self::assertCount(9, $paginator); } - /** @dataProvider useOutputWalkersAndFetchJoinCollection */ + #[DataProvider('useOutputWalkersAndFetchJoinCollection')] public function testIterateSimpleWithoutJoin($useOutputWalkers, $fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'; @@ -225,7 +227,7 @@ private function iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetc self::assertEquals($checkField . '5', $result[0]->$checkField); } - /** @dataProvider useOutputWalkersAndFetchJoinCollection */ + #[DataProvider('useOutputWalkersAndFetchJoinCollection')] public function testIterateSimpleWithoutJoinWithOrder($useOutputWalkers, $fetchJoinCollection): void { // Ascending @@ -234,7 +236,7 @@ public function testIterateSimpleWithoutJoinWithOrder($useOutputWalkers, $fetchJ $this->iterateWithOrderDesc($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** @dataProvider useOutputWalkersAndFetchJoinCollection */ + #[DataProvider('useOutputWalkersAndFetchJoinCollection')] public function testIterateSimpleWithoutJoinWithOrderAndLimit($useOutputWalkers, $fetchJoinCollection): void { // Ascending @@ -243,7 +245,7 @@ public function testIterateSimpleWithoutJoinWithOrderAndLimit($useOutputWalkers, $this->iterateWithOrderDescWithLimit($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** @dataProvider useOutputWalkersAndFetchJoinCollection */ + #[DataProvider('useOutputWalkersAndFetchJoinCollection')] public function testIterateSimpleWithoutJoinWithOrderAndLimitAndOffset($useOutputWalkers, $fetchJoinCollection): void { // Ascending @@ -252,7 +254,7 @@ public function testIterateSimpleWithoutJoinWithOrderAndLimitAndOffset($useOutpu $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrder($fetchJoinCollection): void { // Ascending @@ -261,7 +263,7 @@ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrder($fe $this->iterateWithOrderDesc(true, $fetchJoinCollection, $dql, 'image'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrderAndLimit($fetchJoinCollection): void { // Ascending @@ -270,7 +272,7 @@ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrderAndL $this->iterateWithOrderDescWithLimit(true, $fetchJoinCollection, $dql, 'image'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrderAndLimitAndOffset($fetchJoinCollection): void { // Ascending @@ -279,7 +281,7 @@ public function testIterateSimpleWithOutputWalkerWithoutJoinWithComplexOrderAndL $this->iterateWithOrderDescWithLimitAndOffset(true, $fetchJoinCollection, $dql, 'image'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoin($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'; @@ -290,7 +292,7 @@ public function testIterateWithFetchJoin($useOutputWalkers): void self::assertCount(9, $paginator->getIterator()); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinWithOrder($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g ORDER BY u.username'; @@ -298,7 +300,7 @@ public function testIterateWithFetchJoinWithOrder($useOutputWalkers): void $this->iterateWithOrderDesc($useOutputWalkers, true, $dql, 'username'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinWithOrderAndLimit($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g ORDER BY u.username'; @@ -306,7 +308,7 @@ public function testIterateWithFetchJoinWithOrderAndLimit($useOutputWalkers): vo $this->iterateWithOrderDescWithLimit($useOutputWalkers, true, $dql, 'username'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinWithOrderAndLimitAndOffset($useOutputWalkers): void { $dql = 'SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g ORDER BY u.username'; @@ -314,7 +316,7 @@ public function testIterateWithFetchJoinWithOrderAndLimitAndOffset($useOutputWal $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, true, $dql, 'username'); } - /** @dataProvider useOutputWalkersAndFetchJoinCollection */ + #[DataProvider('useOutputWalkersAndFetchJoinCollection')] public function testIterateWithRegularJoinWithOrderByColumnFromJoined($useOutputWalkers, $fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e ORDER BY e.email'; @@ -322,7 +324,7 @@ public function testIterateWithRegularJoinWithOrderByColumnFromJoined($useOutput $this->iterateWithOrderDesc($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** @dataProvider useOutputWalkersAndFetchJoinCollection */ + #[DataProvider('useOutputWalkersAndFetchJoinCollection')] public function testIterateWithRegularJoinWithOrderByColumnFromJoinedWithLimit($useOutputWalkers, $fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e ORDER BY e.email'; @@ -330,7 +332,7 @@ public function testIterateWithRegularJoinWithOrderByColumnFromJoinedWithLimit($ $this->iterateWithOrderDescWithLimit($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** @dataProvider useOutputWalkersAndFetchJoinCollection */ + #[DataProvider('useOutputWalkersAndFetchJoinCollection')] public function testIterateWithRegularJoinWithOrderByColumnFromJoinedWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e ORDER BY e.email'; @@ -338,7 +340,7 @@ public function testIterateWithRegularJoinWithOrderByColumnFromJoinedWithLimitAn $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, $fetchJoinCollection, $dql, 'username'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByReferencingJoined($fetchJoinCollection): void { // long function name is loooooooooooong @@ -348,7 +350,7 @@ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByRef $this->iterateWithOrderDesc(true, $fetchJoinCollection, $dql, 'name'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByReferencingJoinedWithLimit($fetchJoinCollection): void { // long function name is loooooooooooong @@ -358,7 +360,7 @@ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByRef $this->iterateWithOrderDescWithLimit(true, $fetchJoinCollection, $dql, 'name'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByReferencingJoinedWithLimitAndOffset($fetchJoinCollection): void { // long function name is loooooooooooong @@ -368,7 +370,7 @@ public function testIterateWithOutputWalkersWithRegularJoinWithComplexOrderByRef $this->iterateWithOrderDescWithLimitAndOffset(true, $fetchJoinCollection, $dql, 'name'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinWithOrderByColumnFromJoined($useOutputWalkers): void { $dql = 'SELECT u,g,e FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g JOIN u.email e ORDER BY e.email'; @@ -376,7 +378,7 @@ public function testIterateWithFetchJoinWithOrderByColumnFromJoined($useOutputWa $this->iterateWithOrderDesc($useOutputWalkers, true, $dql, 'username'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinWithOrderByColumnFromJoinedWithLimit($useOutputWalkers): void { $dql = 'SELECT u,g,e FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g JOIN u.email e ORDER BY e.email'; @@ -384,7 +386,7 @@ public function testIterateWithFetchJoinWithOrderByColumnFromJoinedWithLimit($us $this->iterateWithOrderDescWithLimit($useOutputWalkers, true, $dql, 'username'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinWithOrderByColumnFromJoinedWithLimitAndOffset($useOutputWalkers): void { $dql = 'SELECT u,g,e FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g JOIN u.email e ORDER BY e.email'; @@ -392,7 +394,7 @@ public function testIterateWithFetchJoinWithOrderByColumnFromJoinedWithLimitAndO $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, true, $dql, 'username'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByReferencingJoined($fetchJoinCollection): void { $dql = 'SELECT c,l FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.logo l ORDER BY l.imageWidth * l.imageHeight'; @@ -400,7 +402,7 @@ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByRefer $this->iterateWithOrderDesc(true, $fetchJoinCollection, $dql, 'name'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByReferencingJoinedWithLimit($fetchJoinCollection): void { $dql = 'SELECT c,l FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.logo l ORDER BY l.imageWidth * l.imageHeight'; @@ -408,7 +410,7 @@ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByRefer $this->iterateWithOrderDescWithLimit(true, $fetchJoinCollection, $dql, 'name'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByReferencingJoinedWithLimitAndOffset($fetchJoinCollection): void { $dql = 'SELECT c,l FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.logo l ORDER BY l.imageWidth * l.imageHeight'; @@ -416,7 +418,7 @@ public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByRefer $this->iterateWithOrderDescWithLimitAndOffset(true, $fetchJoinCollection, $dql, 'name'); } - /** @dataProvider fetchJoinCollection */ + #[DataProvider('fetchJoinCollection')] public function testIterateWithOutputWalkersWithFetchJoinWithComplexOrderByReferencingJoinedWithLimitAndOffsetWithInheritanceType($fetchJoinCollection): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\Pagination\User u ORDER BY u.id'; @@ -443,7 +445,7 @@ public function testJoinedClassTableInheritance(): void self::assertCount(1, $paginator->getIterator()); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromBoth($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; @@ -474,7 +476,7 @@ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromBothWithLi $this->iterateWithOrderDescWithLimit(false, true, $dqlDesc, 'name'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRoot($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; @@ -482,7 +484,7 @@ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRoot($useO $this->iterateWithOrderDesc($useOutputWalkers, true, $dql, 'name'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRootWithLimit($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; @@ -490,7 +492,7 @@ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRootWithLi $this->iterateWithOrderDescWithLimit($useOutputWalkers, true, $dql, 'name'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRootWithLimitAndOffset($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; @@ -498,7 +500,7 @@ public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromRootWithLi $this->iterateWithOrderDescWithLimitAndOffset($useOutputWalkers, true, $dql, 'name'); } - /** @dataProvider useOutputWalkers */ + #[DataProvider('useOutputWalkers')] public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromJoined($useOutputWalkers): void { $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY d.name'; @@ -603,7 +605,7 @@ public function testQueryWalkerIsKept(): void self::assertEquals(1, $paginator->count()); } - /** @group GH-7890 */ + #[Group('GH-7890')] public function testCustomIdTypeWithoutOutputWalker(): void { $this->_em->persist(new CustomIdObjectTypeParent(new CustomIdObject('foo'))); @@ -651,7 +653,7 @@ public function testCountQueryStripsParametersInSelect(): void self::assertCount(9, $paginator); } - /** @dataProvider useOutputWalkersAndFetchJoinCollection */ + #[DataProvider('useOutputWalkersAndFetchJoinCollection')] public function testPaginationWithSubSelectOrderByExpression($useOutputWalker, $fetchJoinCollection): void { $query = $this->_em->createQuery( diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php index 43434f83d88..5191377524b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\Models\PersistentObject\PersistentCollectionContent; use Doctrine\Tests\Models\PersistentObject\PersistentCollectionHolder; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function class_exists; @@ -78,10 +79,8 @@ public function testExtraLazyIsEmptyDoesNotInitializeCollection(): void self::assertFalse($collection->isInitialized()); } - /** - * @group #1206 - * @group DDC-3430 - */ + #[Group('#1206')] + #[Group('DDC-3430')] public function testMatchingDoesNotModifyTheGivenCriteria(): void { $collectionHolder = new PersistentCollectionHolder(); diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php index 1bb7eead930..960cb359d44 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php @@ -12,6 +12,7 @@ use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; class PostLoadEventTest extends OrmFunctionalTestCase @@ -198,7 +199,7 @@ public function testLoadedProxyAssociationToManyShouldTriggerEvent(): void $phonenumbersCol->first(); } - /** @group DDC-3005 */ + #[Group('DDC-3005')] public function testAssociationsArePopulatedWhenEventIsFired(): void { $checkerListener = new PostLoadListenerCheckAssociationsArePopulated(); @@ -213,7 +214,7 @@ public function testAssociationsArePopulatedWhenEventIsFired(): void self::assertTrue($checkerListener->populated, 'Association of email is not populated in postLoad event'); } - /** @group DDC-3005 */ + #[Group('DDC-3005')] public function testEventRaisedCorrectTimesWhenOtherEntityLoadedInEventHandler(): void { $eventManager = $this->_em->getEventManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php index 4935c3d78ee..1c1bc13764e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; use Doctrine\ORM\Query\ParserResult; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -42,7 +43,7 @@ public function testQueryCacheDependsOnHints(): array return [$query, $cache]; } - /** @depends testQueryCacheDependsOnHints */ + #[Depends('testQueryCacheDependsOnHints')] public function testQueryCacheDependsOnFirstResult(array $previous): void { [$query, $cache] = $previous; @@ -58,7 +59,7 @@ public function testQueryCacheDependsOnFirstResult(array $previous): void self::assertCount($cacheCount + 1, $cache->getValues()); } - /** @depends testQueryCacheDependsOnHints */ + #[Depends('testQueryCacheDependsOnHints')] public function testQueryCacheDependsOnMaxResults(array $previous): void { [$query, $cache] = $previous; @@ -73,7 +74,7 @@ public function testQueryCacheDependsOnMaxResults(array $previous): void self::assertCount($cacheCount + 1, $cache->getValues()); } - /** @depends testQueryCacheDependsOnHints */ + #[Depends('testQueryCacheDependsOnHints')] public function testQueryCacheDependsOnHydrationMode(array $previous): void { [$query, $cache] = $previous; diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index 9d199c9314f..9fdc7d64516 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -9,6 +9,8 @@ use Doctrine\ORM\AbstractQuery; use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function round; use function sprintf; @@ -249,7 +251,7 @@ public function testOperatorMultiply(): void self::assertEquals(1_600_000, $result[3]['op']); } - /** @group test */ + #[Group('test')] public function testOperatorDiv(): void { $result = $this->_em->createQuery('SELECT m, (m.salary/0.5) AS op FROM Doctrine\Tests\Models\Company\CompanyManager m ORDER BY m.salary ASC') @@ -274,7 +276,7 @@ public function testConcatFunction(): void self::assertEquals('Benjamin E.HR', $arg[3]['namedep']); } - /** @group DDC-1014 */ + #[Group('DDC-1014')] public function testDateDiff(): void { $query = $this->_em->createQuery("SELECT DATE_DIFF(CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day')) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); @@ -288,11 +290,9 @@ public function testDateDiff(): void self::assertEqualsWithDelta(10, $arg[0]['diff'], 1, 'Should be roughly 10 (or 9)'); } - /** - * @group DDC-1014 - * @group DDC-2938 - * @dataProvider dateAddSubProvider - */ + #[DataProvider('dateAddSubProvider')] + #[Group('DDC-1014')] + #[Group('DDC-2938')] public function testDateAdd(string $unit, int $amount, int $delta = 0): void { $query = sprintf( @@ -326,11 +326,9 @@ public function testDateAdd(string $unit, int $amount, int $delta = 0): void ); } - /** - * @group DDC-1014 - * @group DDC-2938 - * @dataProvider dateAddSubProvider - */ + #[DataProvider('dateAddSubProvider')] + #[Group('DDC-1014')] + #[Group('DDC-2938')] public function testDateSub(string $unit, int $amount, int $delta = 0): void { $query = sprintf( @@ -379,7 +377,7 @@ public static function dateAddSubProvider(): array ]; } - /** @group DDC-1213 */ + #[Group('DDC-1213')] public function testBitOrComparison(): void { $dql = 'SELECT m, ' . @@ -401,7 +399,7 @@ public function testBitOrComparison(): void self::assertEquals($result[3][0]['salary'] / 100000 | 2, $result[3]['salary_bit_or']); } - /** @group DDC-1213 */ + #[Group('DDC-1213')] public function testBitAndComparison(): void { $dql = 'SELECT m, ' . diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index ca74b3acdf1..b53a850678c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -20,6 +20,8 @@ use Doctrine\Tests\Models\Enums\AccessLevel; use Doctrine\Tests\Models\Enums\UserStatus; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhp; use function count; use function iterator_to_array; @@ -166,7 +168,7 @@ public function testInvalidInputParameterThrowsException(): void ->getSingleResult(); } - /** @requires PHP 8.1 */ + #[RequiresPhp('8.1')] public function testUseStringEnumCaseAsParameter(): void { $user = new CmsUser(); @@ -194,7 +196,7 @@ public function testUseStringEnumCaseAsParameter(): void self::assertSame('jane', $result[0]->username); } - /** @requires PHP 8.1 */ + #[RequiresPhp('8.1')] public function testUseIntegerEnumCaseAsParameter(): void { $user = new CmsUser(); @@ -249,7 +251,7 @@ public function testSetParametersBackwardsCompatible(): void self::assertSame($parameters, $this->getLastLoggedQuery()['params']); } - /** @group DDC-1070 */ + #[Group('DDC-1070')] public function testIterateResultAsArrayAndParams(): void { $article1 = new CmsArticle(); @@ -491,7 +493,7 @@ public function testModifiedLimitQuery(): void ->getScalarResult(); } - /** @group DDC-604 */ + #[Group('DDC-604')] public function testEntityParameters(): void { $article = new CmsArticle(); @@ -519,7 +521,7 @@ public function testEntityParameters(): void self::assertFalse($result[0]->user->__isInitialized()); } - /** @group DDC-952 */ + #[Group('DDC-952')] public function testEnableFetchEagerMode(): void { for ($i = 0; $i < 10; $i++) { @@ -548,7 +550,7 @@ public function testEnableFetchEagerMode(): void } } - /** @group DDC-991 */ + #[Group('DDC-991')] public function testgetOneOrNullResult(): void { $user = new CmsUser(); @@ -570,7 +572,7 @@ public function testgetOneOrNullResult(): void self::assertEquals('gblanco', $fetchedUsername); } - /** @group DDC-991 */ + #[Group('DDC-991')] public function testgetOneOrNullResultSeveralRows(): void { $user = new CmsUser(); @@ -593,7 +595,7 @@ public function testgetOneOrNullResultSeveralRows(): void $fetchedUser = $query->getOneOrNullResult(); } - /** @group DDC-991 */ + #[Group('DDC-991')] public function testgetOneOrNullResultNoRows(): void { $query = $this->_em->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u'); @@ -603,7 +605,7 @@ public function testgetOneOrNullResultNoRows(): void self::assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR)); } - /** @group DBAL-171 */ + #[Group('DBAL-171')] public function testParameterOrder(): void { $user1 = new CmsUser(); @@ -746,7 +748,7 @@ public function testQueryWithHiddenAsSelectExpression(): void self::assertInstanceOf(CmsUser::class, $users[0]); } - /** @group DDC-1651 */ + #[Group('DDC-1651')] public function testSetParameterBindingSingleIdentifierObject(): void { $userC = new CmsUser(); @@ -767,7 +769,7 @@ public function testSetParameterBindingSingleIdentifierObject(): void $q->getResult(); } - /** @group DDC-2319 */ + #[Group('DDC-2319')] public function testSetCollectionParameterBindingSingleIdentifierObject(): void { $u1 = new CmsUser(); @@ -815,7 +817,7 @@ public function testSetCollectionParameterBindingSingleIdentifierObject(): void self::assertEquals($u3->username, $resultUser3->username); } - /** @group DDC-1822 */ + #[Group('DDC-1822')] public function testUnexpectedResultException(): void { $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'; diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index d7220909608..f566b316ff1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -10,12 +10,12 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Functional Query tests. - * - * @group DDC-692 */ +#[Group('DDC-692')] class ReadOnlyTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -42,7 +42,7 @@ public function testReadOnlyEntityNeverChangeTracked(): void self::assertEquals(1234, $dbReadOnly->numericValue); } - /** @group DDC-1659 */ + #[Group('DDC-1659')] public function testClearReadOnly(): void { $readOnly = new ReadOnlyEntity('Test1', 1234); @@ -55,7 +55,7 @@ public function testClearReadOnly(): void self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); } - /** @group DDC-1659 */ + #[Group('DDC-1659')] public function testClearEntitiesReadOnly(): void { $readOnly = new ReadOnlyEntity('Test1', 1234); diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php index 59bcbfc8348..6de8ba2f019 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php @@ -11,10 +11,11 @@ use Doctrine\Tests\Models\ReadonlyProperties\SimpleBook; use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\TestUtil; +use PHPUnit\Framework\Attributes\RequiresPhp; use function dirname; -/** @requires PHP 8.1 */ +#[RequiresPhp('8.1')] class ReadonlyPropertiesTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php index 1eb49d05b74..36537512ffa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php @@ -11,6 +11,7 @@ use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\Models\ECommerce\ECommerceShipping; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; use function file_exists; @@ -65,7 +66,7 @@ public function testLazyLoadsFieldValuesFromDatabase(): void self::assertEquals('Doctrine Cookbook', $productProxy->getName()); } - /** @group DDC-727 */ + #[Group('DDC-727')] public function testAccessMetatadaForProxy(): void { $id = $this->createProduct(); @@ -76,7 +77,7 @@ public function testAccessMetatadaForProxy(): void self::assertEquals(ECommerceProduct::class, $class->name); } - /** @group DDC-1033 */ + #[Group('DDC-1033')] public function testReferenceFind(): void { $id = $this->createProduct(); @@ -88,7 +89,7 @@ public function testReferenceFind(): void self::assertEquals('Doctrine Cookbook', $entity2->getName()); } - /** @group DDC-1033 */ + #[Group('DDC-1033')] public function testCloneProxy(): void { $id = $this->createProduct(); @@ -111,7 +112,7 @@ public function testCloneProxy(): void self::assertFalse($entity->isCloned); } - /** @group DDC-733 */ + #[Group('DDC-733')] public function testInitializeProxy(): void { $id = $this->createProduct(); @@ -124,7 +125,7 @@ public function testInitializeProxy(): void self::assertTrue($entity->__isInitialized(), 'Should be initialized after called UnitOfWork::initializeObject()'); } - /** @group DDC-1163 */ + #[Group('DDC-1163')] public function testInitializeChangeAndFlushProxy(): void { $id = $this->createProduct(); @@ -140,7 +141,7 @@ public function testInitializeChangeAndFlushProxy(): void self::assertEquals('Doctrine 2 Cookbook', $entity->getName()); } - /** @group DDC-1022 */ + #[Group('DDC-1022')] public function testWakeupOnProxy(): void { $id = $this->createProduct(); @@ -171,7 +172,7 @@ public function testDoNotInitializeProxyOnGettingTheIdentifier(): void self::assertFalse($entity->__isInitialized(), "Getting the identifier doesn't initialize the proxy."); } - /** @group DDC-1625 */ + #[Group('DDC-1625')] public function testDoNotInitializeProxyOnGettingTheIdentifierDDC1625(): void { $id = $this->createAuction(); @@ -219,7 +220,7 @@ public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier(): v self::assertTrue($entity->__isInitialized(), 'Getting something other than the identifier initializes the proxy.'); } - /** @group DDC-1604 */ + #[Group('DDC-1604')] public function testCommonPersistenceProxy(): void { $id = $this->createProduct(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php index 00af1ef7075..ce44c60a86f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php @@ -12,6 +12,8 @@ use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -83,7 +85,7 @@ public function testSetResultCacheId(): void self::assertCacheHasItem('testing_result_cache_id', $cache); } - /** @group DDC-1026 */ + #[Group('DDC-1026')] public function testUseResultCacheParams(): void { $cache = new ArrayAdapter(); @@ -151,7 +153,7 @@ public function testEnableResultCacheWithIterable(): void $this->resetCache(); } - /** @group DDC-1026 */ + #[Group('DDC-1026')] public function testEnableResultCacheParams(): void { $cache = new ArrayAdapter(); @@ -215,7 +217,7 @@ public function testNativeQueryResultCaching(): array return [$query, $cache]; } - /** @depends testNativeQueryResultCaching */ + #[Depends('testNativeQueryResultCaching')] public function testResultCacheNotDependsOnQueryHints(array $previous): void { [$query, $cache] = $previous; @@ -230,7 +232,7 @@ public function testResultCacheNotDependsOnQueryHints(array $previous): void self::assertCount($cacheCount, $cache->getValues()); } - /** @depends testNativeQueryResultCaching */ + #[Depends('testNativeQueryResultCaching')] public function testResultCacheDependsOnParameters(array $previous): void { [$query, $cache] = $previous; @@ -245,7 +247,7 @@ public function testResultCacheDependsOnParameters(array $previous): void self::assertCount($cacheCount + 1, $cache->getValues()); } - /** @depends testNativeQueryResultCaching */ + #[Depends('testNativeQueryResultCaching')] public function testResultCacheNotDependsOnHydrationMode(array $previous): void { [$query, $cache] = $previous; @@ -260,7 +262,7 @@ public function testResultCacheNotDependsOnHydrationMode(array $previous): void self::assertCount($cacheCount, $cache->getValues()); } - /** @group DDC-909 */ + #[Group('DDC-909')] public function testResultCacheWithObjectParameter(): void { $user1 = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index dccb67dbb0e..d4230df0234 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -27,6 +27,7 @@ use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmFunctionalTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use ReflectionMethod; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -38,9 +39,8 @@ /** * Tests SQLFilter functionality. - * - * @group non-cacheable */ +#[Group('non-cacheable')] class SQLFilterTest extends OrmFunctionalTestCase { private int $userId; @@ -178,7 +178,7 @@ public function testEntityManagerGetFilter(): void self::assertTrue($exceptionThrown); } - /** @group DDC-2203 */ + #[Group('DDC-2203')] public function testEntityManagerIsFilterEnabled(): void { $em = $this->getEntityManager(); @@ -257,10 +257,8 @@ public function testSQLFilterGetSetParameter(): void self::assertEquals("'en'", $filter->getParameter('locale')); } - /** - * @group DDC-3161 - * @group 1054 - */ + #[Group('DDC-3161')] + #[Group('1054')] public function testSQLFilterGetConnection(): void { // Setup mock connection diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php index 61d937b3fff..bcdcfddc03a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php @@ -6,6 +6,8 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * Functional tests for the Class Table Inheritance mapping strategy. @@ -19,7 +21,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-966 */ + #[Group('DDC-966')] public function testGeneratedSchema(): Schema { $schema = $this->createSchemaManager()->introspectSchema(); @@ -29,10 +31,8 @@ public function testGeneratedSchema(): Schema return $schema; } - /** - * @group DDC-966 - * @depends testGeneratedSchema - */ + #[Depends('testGeneratedSchema')] + #[Group('DDC-966')] public function testSingleTableInheritance(Schema $schema): void { $table = $schema->getTable('company_contracts'); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index b241d211d34..5abd59eb5a8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -9,13 +9,14 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_filter; use function str_contains; class DBAL483Test extends OrmFunctionalTestCase { - /** @group DBAL-483 */ + #[Group('DBAL-483')] public function testDefaultValueIsComparedCorrectly(): void { $class = DBAL483Default::class; diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 38914583487..8e9df91ca93 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_filter; use function implode; @@ -30,7 +31,7 @@ protected function setUp(): void } } - /** @group DDC-214 */ + #[Group('DDC-214')] public function testCmsAddressModel(): void { $this->assertCreatedSchemaNeedsNoUpdates( @@ -43,7 +44,7 @@ public function testCmsAddressModel(): void ); } - /** @group DDC-214 */ + #[Group('DDC-214')] public function testCompanyModel(): void { $this->assertCreatedSchemaNeedsNoUpdates( diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 6e01300237a..cbfc491d654 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -21,6 +21,7 @@ use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\Tests\Models\Generic\DecimalModel; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function class_exists; @@ -100,7 +101,7 @@ public function testGetCreateSchemaSql3(): void self::assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); } - /** @group DBAL-204 */ + #[Group('DBAL-204')] public function testGetCreateSchemaSql4(): void { if (! class_exists(Visitor::class)) { diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index c777c7f0db3..b13548560f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_filter; use function implode; @@ -38,7 +39,7 @@ public function testPostgresMetadataSequenceIncrementedBy10(): void self::assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); } - /** @group DDC-1657 */ + #[Group('DDC-1657')] public function testUpdateSchemaWithPostgreSQLSchema(): void { $sql = $this->getUpdateSchemaSqlForModels( diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php index 2e8ccae416a..b8888b6fefc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php @@ -11,6 +11,8 @@ use Doctrine\Tests\DbalTypes\NegativeToPositiveType; use Doctrine\Tests\DbalTypes\UpperCaseStringType; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function array_keys; use function constant; @@ -18,9 +20,8 @@ /** * Test the validity of all modelsets - * - * @group DDC-1601 */ +#[Group('DDC-1601')] class SchemaValidatorTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -57,7 +58,7 @@ public static function dataValidateModelSets(): array return $modelSets; } - /** @dataProvider dataValidateModelSets */ + #[DataProvider('dataValidateModelSets')] public function testValidateModelSets(string $modelSet): void { $validator = new SchemaValidator($this->_em); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php index af27215ce97..874cc79f231 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php @@ -7,8 +7,9 @@ use DateTime; use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\Flight; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheCompositePrimaryKeyTest extends SecondLevelCacheFunctionalTestCase { public function testPutAndLoadCompositPrimaryKeyEntities(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php index 8ba0eddb0b1..b8da952105d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php @@ -14,11 +14,12 @@ use Doctrine\Tests\Mocks\TimestampRegionMock; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemPoolInterface; use function assert; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheConcurrentTest extends SecondLevelCacheFunctionalTestCase { private CacheFactorySecondLevelCacheConcurrentTest $cacheFactory; diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php index 1806d2ad98f..0fe074dfd9f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php @@ -8,8 +8,9 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheCriteriaTest extends SecondLevelCacheFunctionalTestCase { public function testMatchingPut(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php index d8c14c33058..54502e795d1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php @@ -8,8 +8,9 @@ use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\Travel; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheExtraLazyCollectionTest extends SecondLevelCacheFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php index a26f3ecd3f3..16132c743dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php @@ -22,8 +22,9 @@ use Doctrine\Tests\Models\Cache\TravelerProfile; use Doctrine\Tests\Models\Cache\TravelerProfileInfo; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] abstract class SecondLevelCacheFunctionalTestCase extends OrmFunctionalTestCase { /** @psalm-var list */ diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php index 5a750e8c040..5ddfc1e3379 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php @@ -9,10 +9,11 @@ use Doctrine\Tests\Models\Cache\AttractionContactInfo; use Doctrine\Tests\Models\Cache\AttractionInfo; use Doctrine\Tests\Models\Cache\AttractionLocationInfo; +use PHPUnit\Framework\Attributes\Group; use function count; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheJoinTableInheritanceTest extends SecondLevelCacheFunctionalTestCase { public function testUseSameRegion(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php index abd821c0ba4..40ece2a011a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php @@ -9,8 +9,9 @@ use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\Travel; use Doctrine\Tests\Models\Cache\Traveler; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheManyToManyTest extends SecondLevelCacheFunctionalTestCase { public function testShouldPutManyToManyCollectionOwningSideOnPersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php index e06f1a5f4d3..0329a2b8151 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php @@ -12,8 +12,9 @@ use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\Token; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheManyToOneTest extends SecondLevelCacheFunctionalTestCase { public function testPutOnPersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php index aff29b6d9a4..53a5dbccb86 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php @@ -11,10 +11,11 @@ use Doctrine\Tests\Models\Cache\Token; use Doctrine\Tests\Models\Cache\Travel; use Doctrine\Tests\Models\Cache\Traveler; +use PHPUnit\Framework\Attributes\Group; use function sprintf; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheOneToManyTest extends SecondLevelCacheFunctionalTestCase { public function testShouldPutCollectionInverseSideOnPersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php index ac04b843891..bf667e6a197 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php @@ -12,8 +12,9 @@ use Doctrine\Tests\Models\Cache\Traveler; use Doctrine\Tests\Models\Cache\TravelerProfile; use Doctrine\Tests\Models\Cache\TravelerProfileInfo; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheOneToOneTest extends SecondLevelCacheFunctionalTestCase { public function testPutOneToOneOnUnidirectionalPersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 69aea548600..672495ba706 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -18,9 +18,10 @@ use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; +use PHPUnit\Framework\Attributes\Group; use ReflectionMethod; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheQueryCacheTest extends SecondLevelCacheFunctionalTestCase { public function testBasicQueryCache(): void @@ -288,7 +289,7 @@ public function testBasicQueryCachePutEntityCache(): void self::assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } - /** @group 5854 */ + #[Group('5854')] public function testMultipleNestedDQLAliases(): void { $this->loadFixturesCountries(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php index 6a1b5c142da..95c48b74bc6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php @@ -7,8 +7,9 @@ use Doctrine\Persistence\Proxy; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheRepositoryTest extends SecondLevelCacheFunctionalTestCase { public function testRepositoryCacheFind(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php index a7f5cd32468..43d130bd026 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php @@ -10,10 +10,11 @@ use Doctrine\Tests\Models\Cache\Beach; use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\Restaurant; +use PHPUnit\Framework\Attributes\Group; use function count; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheSingleTableInheritanceTest extends SecondLevelCacheFunctionalTestCase { public function testUseSameRegion(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php index 36ddeb88300..e23c98a2797 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php @@ -12,11 +12,12 @@ use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; use Exception; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; use function uniqid; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class SecondLevelCacheTest extends SecondLevelCacheFunctionalTestCase { public function testPutOnPersist(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php index e9ce797eb91..74ee6f2454e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php @@ -7,6 +7,7 @@ use Doctrine\Tests\Models\CompositeKeyInheritance\SingleChildClass; use Doctrine\Tests\Models\CompositeKeyInheritance\SingleRootClass; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class SingleTableCompositeKeyTest extends OrmFunctionalTestCase { @@ -29,7 +30,7 @@ public function testInsertWithCompositeKey(): void self::assertEquals($childEntity, $entity); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testUpdateWithCompositeKey(): void { $childEntity = new SingleChildClass(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php index 69b2ad97757..33648abb103 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -14,6 +14,7 @@ use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_map; use function sort; @@ -257,7 +258,7 @@ public function testQueryChildClassWithCondition(): void self::assertEquals(1000, $contract->getFixPrice()); } - /** @group non-cacheable */ + #[Group('non-cacheable')] public function testUpdateChildClassWithCondition(): void { $this->loadFullFixture(); @@ -314,7 +315,7 @@ public function testDeleteByBaseClassCondition(): void self::assertFalse($contracts[0]->isCompleted(), 'Only non completed contracts should be left.'); } - /** @group DDC-130 */ + #[Group('DDC-130')] public function testDeleteJoinTableRecords(): void { $this->loadFullFixture(); @@ -326,7 +327,7 @@ public function testDeleteJoinTableRecords(): void self::assertNull($this->_em->find($this->fix::class, $this->fix->getId()), 'Contract should not be present in the database anymore.'); } - /** @group DDC-817 */ + #[Group('DDC-817')] public function testFindByAssociation(): void { $this->loadFullFixture(); @@ -348,7 +349,7 @@ public function testFindByAssociation(): void self::assertCount(1, $contracts, 'There should be 1 entities related to ' . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'"); } - /** @group DDC-1637 */ + #[Group('DDC-1637')] public function testInheritanceMatching(): void { $this->loadFullFixture(); @@ -366,7 +367,7 @@ public function testInheritanceMatching(): void self::assertCount(1, $contracts); } - /** @group DDC-2430 */ + #[Group('DDC-2430')] public function testMatchingNonObjectOnAssocationThrowsException(): void { $this->loadFullFixture(); @@ -384,7 +385,7 @@ public function testMatchingNonObjectOnAssocationThrowsException(): void $contracts->toArray(); } - /** @group DDC-834 */ + #[Group('DDC-834')] public function testGetReferenceEntityWithSubclasses(): void { $this->loadFullFixture(); @@ -399,7 +400,7 @@ public function testGetReferenceEntityWithSubclasses(): void self::assertInstanceOf(Proxy::class, $ref, 'A proxy can be generated only if no subclasses exists for the requested reference.'); } - /** @group DDC-952 */ + #[Group('DDC-952')] public function testEagerLoadInheritanceHierarchy(): void { $this->loadFullFixture(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php index f59eb394bd8..277adf03405 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php @@ -7,8 +7,9 @@ use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1040 */ +#[Group('DDC-1040')] class DDC1040Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php index c4c77890ab0..07e41044a29 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -7,8 +7,9 @@ use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1041 */ +#[Group('DDC-1041')] class DDC1041Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php index 2bde56bc163..e391187da93 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php @@ -6,8 +6,9 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1043 */ +#[Group('DDC-1043')] class DDC1043Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index c2fae321557..fd319b59772 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -16,8 +16,9 @@ use Doctrine\ORM\Mapping\OrderBy; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1080 */ +#[Group('DDC-1080')] class DDC1080Test extends OrmFunctionalTestCase { public function testHydration(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php index 8f50698a4e2..8409aed66cf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php @@ -13,11 +13,10 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-1113 - * @group DDC-1306 - */ +#[Group('DDC-1113')] +#[Group('DDC-1306')] class DDC1113Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php index 4719bc12462..202b70d6563 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php @@ -6,8 +6,9 @@ use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1129 */ +#[Group('DDC-1129')] class DDC1129Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php index a71fbab733b..7a32c6bde08 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -16,10 +16,11 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** @group DDC-1163 */ +#[Group('DDC-1163')] class DDC1163Test extends OrmFunctionalTestCase { private int|null $productId = null; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php index 48aef2f659b..138d167d366 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -15,11 +15,12 @@ use Doctrine\Tests\Models\DDC117\DDC117Translation; use Doctrine\Tests\OrmFunctionalTestCase; use Exception; +use PHPUnit\Framework\Attributes\Group; use function assert; use function count; -/** @group DDC-117 */ +#[Group('DDC-117')] class DDC117Test extends OrmFunctionalTestCase { use VerifyDeprecations; @@ -63,7 +64,7 @@ protected function setUp(): void $this->_em->clear(); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testAssociationOnlyCompositeKey(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -100,7 +101,7 @@ public function testAssociationOnlyCompositeKey(): void $this->_em->contains($dqlRef); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testUpdateAssociationEntity(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -116,7 +117,7 @@ public function testUpdateAssociationEntity(): void self::assertEquals('New Description!!', $mapRef->getDescription()); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testFetchDql(): void { $dql = 'SELECT r, s FROM Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1'; @@ -130,7 +131,7 @@ public function testFetchDql(): void } } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testRemoveCompositeElement(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -144,10 +145,8 @@ public function testRemoveCompositeElement(): void self::assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); } - /** - * @group DDC-117 - * @group non-cacheable - */ + #[Group('DDC-117')] + #[Group('non-cacheable')] public function testDqlRemoveCompositeElement(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -161,7 +160,7 @@ public function testDqlRemoveCompositeElement(): void self::assertNull($this->_em->find(DDC117Reference::class, $idCriteria)); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testInverseSideAccess(): void { $this->article1 = $this->_em->find(DDC117Article::class, $this->article1->id()); @@ -188,7 +187,7 @@ public function testInverseSideAccess(): void } } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testMixedCompositeKey(): void { $idCriteria = ['article' => $this->article1->id(), 'language' => 'en']; @@ -209,7 +208,7 @@ public function testMixedCompositeKey(): void self::assertInstanceOf(DDC117Translation::class, $this->translation); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testMixedCompositeKeyViolateUniqueness(): void { $this->article1 = $this->_em->find(DDC117Article::class, $this->article1->id()); @@ -221,7 +220,7 @@ public function testMixedCompositeKeyViolateUniqueness(): void $this->_em->flush(); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testOneToOneForeignObjectId(): void { $this->article1 = new DDC117Article('Foo'); @@ -241,7 +240,7 @@ public function testOneToOneForeignObjectId(): void self::assertEquals('not so very long text!', $article->getText()); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testOneToOneCascadeRemove(): void { $article = $this->_em->find($this->article1::class, $this->article1->id()); @@ -251,7 +250,7 @@ public function testOneToOneCascadeRemove(): void self::assertFalse($this->_em->contains($article->getDetails())); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testOneToOneCascadePersist(): void { $this->article1 = new DDC117Article('Foo'); @@ -263,7 +262,7 @@ public function testOneToOneCascadePersist(): void self::assertSame($this->articleDetails, $this->_em->find(DDC117ArticleDetails::class, $this->article1)); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testReferencesToForeignKeyEntities(): void { $idCriteria = ['source' => $this->article1->id(), 'target' => $this->article2->id()]; @@ -284,7 +283,7 @@ public function testReferencesToForeignKeyEntities(): void self::assertInstanceOf(DDC117Translation::class, $approveChanges->getTranslation()); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testLoadOneToManyCollectionOfForeignKeyEntities(): void { $article = $this->_em->find($this->article1::class, $this->article1->id()); @@ -296,7 +295,7 @@ public function testLoadOneToManyCollectionOfForeignKeyEntities(): void self::assertTrue($translations->isInitialized()); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testLoadManyToManyCollectionOfForeignKeyEntities(): void { $editor = $this->loadEditorFixture(); @@ -313,7 +312,7 @@ public function testLoadManyToManyCollectionOfForeignKeyEntities(): void self::assertContainsOnly(DDC117Translation::class, $editor->reviewingTranslations); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testClearManyToManyCollectionOfForeignKeyEntities(): void { $editor = $this->loadEditorFixture(); @@ -327,7 +326,7 @@ public function testClearManyToManyCollectionOfForeignKeyEntities(): void self::assertCount(0, $editor->reviewingTranslations); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testLoadInverseManyToManyCollection(): void { $editor = $this->loadEditorFixture(); @@ -352,7 +351,7 @@ public function testLoadInverseManyToManyCollection(): void self::assertCount(1, $trans->reviewedByEditors); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testLoadOneToManyOfSourceEntityWithAssociationIdentifier(): void { $editor = $this->loadEditorFixture(); @@ -395,7 +394,7 @@ private function loadEditorFixture(): DDC117Editor return $this->_em->find($editor::class, $editor->id); } - /** @group DDC-1652 */ + #[Group('DDC-1652')] public function testArrayHydrationWithCompositeKey(): void { $dql = 'SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t'; @@ -421,7 +420,7 @@ public function testArrayHydrationWithCompositeKey(): void self::assertCount($before + 3, $data); } - /** @group DDC-2246 */ + #[Group('DDC-2246')] public function testGetEntityState(): void { if ($this->isSecondLevelCacheEnabled) { @@ -441,7 +440,7 @@ public function testGetEntityState(): void self::assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($reference)); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testIndexByOnCompositeKeyField(): void { $article = $this->_em->find(DDC117Article::class, $this->article1->id()); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php index 62017705607..77d3fe52ad7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC1181Test extends OrmFunctionalTestCase { @@ -26,7 +27,7 @@ protected function setUp(): void ); } - /** @group DDC-1181 */ + #[Group('DDC-1181')] public function testIssue(): void { $hotel = new DDC1181Hotel(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index f29d665082b..725e79e4d2b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC1193Test extends OrmFunctionalTestCase { @@ -24,7 +25,7 @@ protected function setUp(): void ); } - /** @group DDC-1193 */ + #[Group('DDC-1193')] public function testIssue(): void { $company = new DDC1193Company(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php index 067c6d2dbea..c8ed1302f32 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Stringable; class DDC1209Test extends OrmFunctionalTestCase @@ -27,7 +28,7 @@ protected function setUp(): void ); } - /** @group DDC-1209 */ + #[Group('DDC-1209')] public function testIdentifierCanHaveCustomType(): void { $entity = new DDC1209Three(); @@ -38,7 +39,7 @@ public function testIdentifierCanHaveCustomType(): void self::assertSame($entity, $this->_em->find(DDC1209Three::class, $entity->date)); } - /** @group DDC-1209 */ + #[Group('DDC-1209')] public function testCompositeIdentifierCanHaveCustomType(): void { $future1 = new DDC1209One(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php index 200c34d711b..a4e6efb69b0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -12,10 +12,11 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function strtolower; -/** @group DDC-1225 */ +#[Group('DDC-1225')] class DDC1225Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php index 4d7fa09dba3..ba48333ae5b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php @@ -10,11 +10,10 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-1228 - * @group DDC-1226 - */ +#[Group('DDC-1228')] +#[Group('DDC-1226')] class DDC1228Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php index a6a52885b5c..a1039770981 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -9,8 +9,9 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1238 */ +#[Group('DDC-1238')] class DDC1238Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php index 8f759a7c9cb..38b972654d8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -11,8 +11,9 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1250 */ +#[Group('DDC-1250')] class DDC1250Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php index a1aae45ab2b..d126abaa0d4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1300 */ +#[Group('DDC-1300')] class DDC1300Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php index 9f10dc30e2c..d5479c9d3d1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php @@ -10,11 +10,10 @@ use Doctrine\Tests\Models\Legacy\LegacyUser; use Doctrine\Tests\Models\Legacy\LegacyUserReference; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group non-cacheable - * @group DDC-1301 - */ +#[Group('non-cacheable')] +#[Group('DDC-1301')] class DDC1301Test extends OrmFunctionalTestCase { private int|null $userId = null; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php index 6af2cbd4e6c..0affa231990 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php @@ -8,8 +8,9 @@ use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1306 */ +#[Group('DDC-1306')] class DDC1306Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php index 9a81ebbed2d..8efad774b32 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -15,8 +15,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1335 */ +#[Group('DDC-1335')] class DDC1335Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php index af7f9a2c081..dd223cceebc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1400 */ +#[Group('DDC-1400')] class DDC1400Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php index 16806987ace..1f542f36039 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php @@ -7,11 +7,10 @@ use Doctrine\Tests\Models\Quote\Address; use Doctrine\Tests\Models\Quote\User; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-1845 - * @group DDC-142 - */ +#[Group('DDC-1845')] +#[Group('DDC-142')] class DDC142Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php index f82b447cd9a..8a1bf5b646a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -16,8 +16,9 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; use Exception; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1430 */ +#[Group('DDC-1430')] class DDC1430Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php index 813820e681f..b3cd965f413 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -11,8 +11,9 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1436 */ +#[Group('DDC-1436')] class DDC1436Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php index 4dd0fb39de5..593add03fbc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC144Test extends OrmFunctionalTestCase { @@ -26,7 +27,7 @@ protected function setUp(): void ); } - /** @group DDC-144 */ + #[Group('DDC-144')] public function testIssue(): void { $operand = new DDC144Operand(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php index 9d148bc29d0..885f82a024c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -16,8 +16,9 @@ use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1452 */ +#[Group('DDC-1452')] class DDC1452Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php index ee1a1ef5b6b..51629664dd7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -12,11 +12,12 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function mt_getrandmax; use function random_int; -/** @group DDC-1454 */ +#[Group('DDC-1454')] class DDC1454Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php index 501c1ffe205..47ad88b9eb5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1461 */ +#[Group('DDC-1461')] class DDC1461Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php index 2ed8c1bc37e..0e0a7078e57 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1514 */ +#[Group('DDC-1514')] class DDC1514Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php index 3d59c4ae0ee..7b3aa08974e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -10,8 +10,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1515 */ +#[Group('DDC-1515')] class DDC1515Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php index 02e05d26270..d7cb6e16b5f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1526 */ +#[Group('DDC-1526')] class DDC1526Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php index 867656765df..fdfaf740345 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php @@ -7,8 +7,9 @@ use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1545 */ +#[Group('DDC-1545')] class DDC1545Test extends OrmFunctionalTestCase { private int|null $articleId = null; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php index 3fea94e5ea2..ae07efd4791 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -10,8 +10,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1548 */ +#[Group('DDC-1548')] class DDC1548Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php index 5b89d190935..8a757b4ba73 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php @@ -18,12 +18,11 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-1595 - * @group DDC-1596 - * @group non-cacheable - */ +#[Group('DDC-1595')] +#[Group('DDC-1596')] +#[Group('non-cacheable')] class DDC1595Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php index 5cb354bebc0..6c0c7c94fe3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php @@ -6,6 +6,7 @@ use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC163Test extends OrmFunctionalTestCase { @@ -16,7 +17,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-163 */ + #[Group('DDC-163')] public function testQueryWithOrConditionUsingTwoRelationOnSameEntity(): void { $p1 = new CompanyPerson(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php index 458c68788d7..56bb9630de3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php @@ -7,8 +7,9 @@ use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1643 */ +#[Group('DDC-1643')] class DDC1643Test extends OrmFunctionalTestCase { private CmsUser|null $user1; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php index 83a7fe103e3..49063ad4ee3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php @@ -11,8 +11,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1654 */ +#[Group('DDC-1654')] class DDC1654Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -73,7 +74,7 @@ public function testManyToManyRemoveElementFromCollectionOrphanRemoval(): void self::assertCount(0, $comments); } - /** @group DDC-3382 */ + #[Group('DDC-3382')] public function testManyToManyRemoveElementFromReAddToCollectionOrphanRemoval(): void { $post = new DDC1654Post(); @@ -112,7 +113,7 @@ public function testManyToManyClearCollectionOrphanRemoval(): void self::assertCount(0, $comments); } - /** @group DDC-3382 */ + #[Group('DDC-3382')] public function testManyToManyClearCollectionReAddOrphanRemoval(): void { $post = new DDC1654Post(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php index dadd1e53438..a6452a5dbf5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -16,14 +16,13 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\PostLoad; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function get_debug_type; -/** - * @group DDC-1655 - * @group DDC-1640 - * @group DDC-1556 - */ +#[Group('DDC-1655')] +#[Group('DDC-1640')] +#[Group('DDC-1556')] class DDC1655Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php index 054831e01ce..3ff41210c23 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php @@ -7,8 +7,9 @@ use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1666 */ +#[Group('DDC-1666')] class DDC1666Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php index 1252965977a..9173f5e7865 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php @@ -8,9 +8,10 @@ use Doctrine\Tests\Models\DDC117\DDC117Article; use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; -/** @group DDC-1685 */ +#[Group('DDC-1685')] class DDC1685Test extends OrmFunctionalTestCase { private Paginator $paginator; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php index e480e6bcc0c..54147ba39c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php @@ -7,6 +7,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function ksort; @@ -35,7 +36,7 @@ public function tearDown(): void parent::tearDown(); } - /** @group DDC-168 */ + #[Group('DDC-168')] public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFieldsArray(): void { $spouse = new CompanyEmployee(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php index eaced3986d7..e5693313316 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1695 */ +#[Group('DDC-1695')] class DDC1695Test extends OrmFunctionalTestCase { public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index bc0dcf1223d..8d57644a752 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -14,8 +14,9 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\PostLoad; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1707 */ +#[Group('DDC-1707')] class DDC1707Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php index 1f96c78cf4b..212dac335ee 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php @@ -10,8 +10,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1719 */ +#[Group('DDC-1719')] class DDC1719Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php index c406490555e..b3bc4277193 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php @@ -7,8 +7,9 @@ use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1778 */ +#[Group('DDC-1778')] class DDC1778Test extends OrmFunctionalTestCase { private CmsUser|null $user; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php index 48088a15fd4..4cd7a886d73 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1787 */ +#[Group('DDC-1787')] class DDC1787Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php index cd037335bf2..b92d6408dbd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php @@ -6,11 +6,10 @@ use Doctrine\Tests\Models\Quote\Group; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group as TestGroup; -/** - * @group DDC-1845 - * @group DDC-1843 - */ +#[TestGroup('DDC-1845')] +#[TestGroup('DDC-1843')] class DDC1843Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php index 961b89333f4..dc5d17591d7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php @@ -9,8 +9,9 @@ use Doctrine\Tests\Models\Taxi\PaidRide; use Doctrine\Tests\Models\Taxi\Ride; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1884 */ +#[Group('DDC-1884')] class DDC1884Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php index f4cf9ce698f..9290345ee51 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php @@ -7,11 +7,10 @@ use Doctrine\Tests\Models\Quote\Group; use Doctrine\Tests\Models\Quote\User; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group as TestGroup; -/** - * @group DDC-1845 - * @group DDC-1885 - */ +#[TestGroup('DDC-1845')] +#[TestGroup('DDC-1885')] class DDC1885Test extends OrmFunctionalTestCase { private User $user; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php index 295ebb94a91..2fcc7546c27 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php @@ -8,10 +8,11 @@ use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function iterator_to_array; -/** @group DDC-1918 */ +#[Group('DDC-1918')] class DDC1918Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php index 078d7606b92..f64d8555aa9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php @@ -16,13 +16,12 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** - * @group DDC-1925 - * @group DDC-1210 - */ +#[Group('DDC-1925')] +#[Group('DDC-1210')] class DDC1925Test extends OrmFunctionalTestCase { public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php index 06f48d1d863..6ddff6a387d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-192 */ +#[Group('DDC-192')] class DDC192Test extends OrmFunctionalTestCase { public function testSchemaCreation(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php index 4a2639d82ce..205f592a3b9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php @@ -7,8 +7,9 @@ use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1995 */ +#[Group('DDC-1995')] class DDC1995Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php index 106f5f9806b..54c1d0c2756 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php @@ -11,9 +11,10 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Stringable; -/** @group DDC-1998 */ +#[Group('DDC-1998')] class DDC1998Test extends OrmFunctionalTestCase { public function testSqlConversionAsIdentifier(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index 13dc93b9f5c..4c347835ac8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -15,6 +15,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function explode; use function implode; @@ -22,10 +23,8 @@ use function sprintf; use function strtolower; -/** - * @group DDC-2012 - * @group non-cacheable - */ +#[Group('DDC-2012')] +#[Group('non-cacheable')] class DDC2012Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php index 37b51cb049b..5e47b5c6ed3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php @@ -9,8 +9,9 @@ use Doctrine\Tests\Models\ECommerce\ECommerceCategory; use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2074 */ +#[Group('DDC-2074')] class DDC2074Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php index 77c7ecbbdd6..dfa44bcd9bd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php @@ -8,8 +8,9 @@ use Doctrine\Tests\ORM\Functional\Ticket\DDC2084\MyEntity2; use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2084 */ +#[Group('DDC-2084')] class DDC2084Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php index a736313d7a5..3a76b05ca48 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php @@ -9,11 +9,10 @@ use Doctrine\ORM\Query\Parameter; use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-2090 - * @group non-cacheable - */ +#[Group('DDC-2090')] +#[Group('non-cacheable')] class DDC2090Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php index 5dcfaa95b53..0107bf8ca6a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php @@ -14,8 +14,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2106 */ +#[Group('DDC-2106')] class DDC2106Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php index 6cbe6e5178c..58d029b0100 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -20,13 +20,14 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\ORM\Functional\Ticket\Doctrine\Common\Collections\Collection; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; use function reset; class DDC2138Test extends OrmFunctionalTestCase { - /** @group DDC-2138 */ + #[Group('DDC-2138')] public function testForeignKeyOnSTIWithMultipleMapping(): void { $em = $this->_em; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php index 4910a6d5394..cde8fbb20bc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2175 */ +#[Group('DDC-2175')] class DDC2175Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php index 9f34c0025f9..316cb7669c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -18,9 +19,8 @@ * Verifies that the type of parameters being bound to an SQL query is the same * of the identifier of the entities used as parameters in the DQL query, even * if the bound objects are proxies. - * - * @group DDC-2214 */ +#[Group('DDC-2214')] class DDC2214Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php index 3e69262143a..2a6476eaf6b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php @@ -12,11 +12,13 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Cache\Adapter\ArrayAdapter; use function sprintf; -/** @group DDC-2224 */ +#[Group('DDC-2224')] class DDC2224Test extends OrmFunctionalTestCase { public static function setUpBeforeClass(): void @@ -36,7 +38,7 @@ public function testIssue(): Query return $query; } - /** @depends testIssue */ + #[Depends('testIssue')] public function testCacheMissWhenTypeChanges(Query $query): void { $query->setParameter('field', 'test', 'string'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php index b6a629e4ebc..013b3132841 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php @@ -14,10 +14,11 @@ use Doctrine\Persistence\PropertyChangedListener; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** @group DDC-2230 */ +#[Group('DDC-2230')] class DDC2230Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php index 8d24c1045e4..0e21c835be3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php @@ -19,8 +19,9 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2252 */ +#[Group('DDC-2252')] class DDC2252Test extends OrmFunctionalTestCase { /** @psalm-var DDC2252User */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index 4711a1c2c85..61a7ae45239 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -14,10 +14,11 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** @group DDC-2306 */ +#[Group('DDC-2306')] class DDC2306Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index eed0b693d43..97d331e63c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -16,8 +16,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2346 */ +#[Group('DDC-2346')] class DDC2346Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php index edaaa94cb03..c7fc322d2a4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php @@ -12,11 +12,10 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-2350 - * @group non-cacheable - */ +#[Group('DDC-2350')] +#[Group('non-cacheable')] class DDC2350Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index 3cd18559c76..b02a8dfe62f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -15,9 +15,10 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Persistence\Mapping\Driver\MappingDriver; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -/** @group DDC-2359 */ +#[Group('DDC-2359')] class DDC2359Test extends TestCase { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php index 0086cd3765e..997f7e5e49b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php @@ -7,10 +7,11 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\ORM\Functional\DatabaseDriverTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC2387Test extends DatabaseDriverTestCase { - /** @group DDC-2387 */ + #[Group('DDC-2387')] public function testCompositeAssociationKeyDetection(): void { $product = new Table('ddc2387_product'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php index 39c4cde555e..86897f81e47 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php @@ -9,10 +9,11 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Persistence\Mapping\Driver\StaticPHPDriver; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function md5; -/** @group DDC-2415 */ +#[Group('DDC-2415')] class DDC2415Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php index f16019a93bf..69762420976 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php @@ -17,11 +17,10 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-2494 - * @group non-cacheable - */ +#[Group('DDC-2494')] +#[Group('non-cacheable')] class DDC2494Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php index ee8bf3cfa08..89d02b56208 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php @@ -8,8 +8,9 @@ use Doctrine\Tests\Models\Legacy\LegacyUser; use Doctrine\Tests\Models\Legacy\LegacyUserReference; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2519 */ +#[Group('DDC-2519')] class DDC2519Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -21,7 +22,7 @@ protected function setUp(): void $this->loadFixture(); } - /** @group DDC-2519 */ + #[Group('DDC-2519')] public function testIssue(): void { $dql = 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l'; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php index 5048ba5151d..6fb5f45e882 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php @@ -11,8 +11,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2575 */ +#[Group('DDC-2575')] class DDC2575Test extends OrmFunctionalTestCase { /** @psalm-var list */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php index e610a806123..0be795e8bb4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php @@ -13,9 +13,10 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Stringable; -/** @group DDC-2579 */ +#[Group('DDC-2579')] class DDC2579Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php index 2dfd3bcfe25..1174cb27e27 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC258Test extends OrmFunctionalTestCase { @@ -28,7 +29,7 @@ protected function setUp(): void ); } - /** @group DDC-258 */ + #[Group('DDC-258')] public function testIssue(): void { $c1 = new DDC258Class1(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php index d95a68db72c..37a0bd1e9fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php @@ -16,13 +16,14 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function in_array; use function json_decode; use const JSON_THROW_ON_ERROR; -/** @group DDC-2602 */ +#[Group('DDC-2602')] class DDC2602Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php index ae70e7f8c18..e8732151209 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php @@ -6,8 +6,9 @@ use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2655 */ +#[Group('DDC-2655')] class DDC2655Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php index f5aaa2c7e50..8a7f48e36f9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\Tests\OrmFunctionalTestCase; use Exception; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2660 */ +#[Group('DDC-2660')] class DDC2660Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index a582a288cd1..f9164aa54c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2692 */ +#[Group('DDC-2692')] class DDC2692Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index 9cfa123c72b..de1efcade62 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -14,8 +14,9 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2759 */ +#[Group('DDC-2759')] class DDC2759Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php index 191d081cfda..47a6f548c68 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Functional tests for cascade remove with class table inheritance. @@ -36,7 +37,7 @@ protected function setUp(): void ); } - /** @group DDC-2775 */ + #[Group('DDC-2775')] public function testIssueCascadeRemove(): void { $role = new AdminRole(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php index 3022b6aab9c..b409a8bba98 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2780 */ +#[Group('DDC-2780')] class DDC2780Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php index 66d41bf4a81..a979ffd7903 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php @@ -8,11 +8,12 @@ use Doctrine\ORM\Events; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_intersect_key; use function intval; -/** @group DDC-2790 */ +#[Group('DDC-2790')] class DDC2790Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php index b58da8bccf4..340733c103c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC279Test extends OrmFunctionalTestCase { @@ -29,7 +30,7 @@ protected function setUp(): void ); } - /** @group DDC-279 */ + #[Group('DDC-279')] public function testDDC279(): void { $x = new DDC279EntityX(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index b967bd549eb..657a066c78f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -8,14 +8,15 @@ use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable; use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function sprintf; /** * This class makes tests on the correct use of a database schema when entities are stored - * - * @group DDC-2825 */ +#[Group('DDC-2825')] class DDC2825Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -29,7 +30,7 @@ protected function setUp(): void } } - /** @dataProvider getTestedClasses */ + #[DataProvider('getTestedClasses')] public function testClassSchemaMappingsValidity(string $className, string $expectedSchemaName, string $expectedTableName): void { $classMetadata = $this->_em->getClassMetadata($className); @@ -55,7 +56,7 @@ public function testClassSchemaMappingsValidity(string $className, string $expec ); } - /** @dataProvider getTestedClasses */ + #[DataProvider('getTestedClasses')] public function testPersistenceOfEntityWithSchemaMapping(string $className): void { $this->createSchemaForModels($className); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php index 933ed3fc259..ae7328f0b6c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php @@ -12,11 +12,10 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-2862 - * @group DDC-2183 - */ +#[Group('DDC-2862')] +#[Group('DDC-2183')] class DDC2862Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index de8ba511853..313caa45a05 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -11,8 +11,9 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2931 */ +#[Group('DDC-2931')] class DDC2931Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php index 264a56edf2d..f73d7748d71 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php @@ -8,8 +8,9 @@ use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2943 */ +#[Group('DDC-2943')] class DDC2943Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php index 02298504b63..485c9a755ea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php @@ -14,11 +14,12 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Stringable; use function is_string; -/** @group DDC-2984 */ +#[Group('DDC-2984')] class DDC2984Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index 873393f870a..a3c66e74d4d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\PreFlush; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2996 */ +#[Group('DDC-2996')] class DDC2996Test extends OrmFunctionalTestCase { public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index d8d8d62f497..e91198319a1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -21,8 +21,9 @@ use Doctrine\ORM\Mapping\PreUpdate; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-3033 */ +#[Group('DDC-3033')] class DDC3033Test extends OrmFunctionalTestCase { public function testIssue(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php index 0725e3cc767..c20799d56b6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php @@ -9,8 +9,9 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-3042 */ +#[Group('DDC-3042')] class DDC3042Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php index ecf93550fef..b9397f82aef 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php @@ -8,8 +8,9 @@ use Doctrine\Tests\Models\Taxi\Driver; use Doctrine\Tests\Models\Taxi\Ride; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-3068 */ +#[Group('DDC-3068')] class DDC3068Test extends OrmFunctionalTestCase { private Driver $foo; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php index 5672cd611f1..ec505c07741 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php @@ -8,14 +8,16 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Embeddable; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; use function serialize; use function unserialize; -/** @group DDC-3103 */ +#[CoversClass(ClassMetadata::class)] +#[Group('DDC-3103')] class DDC3103Test extends OrmFunctionalTestCase { - /** @covers \Doctrine\ORM\Mapping\ClassMetadata::__sleep */ public function testIssue(): void { $classMetadata = new ClassMetadata(DDC3103ArticleId::class); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php index 5c3a4a09490..a11fae45108 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php @@ -9,9 +9,10 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Assert; +use PHPUnit\Framework\Attributes\Group; use ReflectionProperty; -/** @group DDC-3123 */ +#[Group('DDC-3123')] class DDC3123Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php index b195f1a546d..d010e792662 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Events; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * FlushEventTest @@ -21,7 +22,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-3160 */ + #[Group('DDC-3160')] public function testNoUpdateOnInsert(): void { $listener = new DDC3160OnFlushListener(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php index 59d322d6936..d3248f25488 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-2306 */ +#[Group('DDC-2306')] class DDC3170Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php index 44c2d151bcc..46983dc5897 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php @@ -16,13 +16,12 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_search; -/** - * @group DDC-2494 - * @group non-cacheable - */ +#[Group('DDC-2494')] +#[Group('non-cacheable')] class DDC3192Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index 5fddbf20437..8cbc54cf081 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Tools\ResolveTargetEntityListener; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-3300 */ +#[Group('DDC-3300')] class DDC3300Test extends OrmFunctionalTestCase { public function testResolveTargetEntitiesChangesDiscriminatorMapValues(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php index 1c345e18956..c67872160bf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Mapping\MappedSuperclass; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC3303Test extends OrmFunctionalTestCase { @@ -24,12 +25,11 @@ protected function setUp(): void } /** - * @group GH-4097 - * @group GH-4277 - * @group GH-5867 - * * When using an embedded field in an inheritance, private properties should also be inherited. */ + #[Group('GH-4097')] + #[Group('GH-4277')] + #[Group('GH-5867')] public function testEmbeddedObjectsAreAlsoInherited(): void { $employee = new DDC3303Employee( diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php index 772ce40ef1b..48207b61208 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function strtolower; @@ -20,7 +21,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-331 */ + #[Group('DDC-331')] public function testSelectFieldOnRootEntity(): void { $q = $this->_em->createQuery('SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php index 71668124184..f9d4143f2d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php @@ -7,10 +7,11 @@ use Doctrine\Tests\Models\DDC3346\DDC3346Article; use Doctrine\Tests\Models\DDC3346\DDC3346Author; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** @group DDC-3346 */ +#[Group('DDC-3346')] class DDC3346Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php index 3b1b06f9cac..0503634f6e9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php @@ -8,8 +8,9 @@ use Doctrine\Tests\Models\DDC3597\DDC3597Media; use Doctrine\Tests\Models\DDC3597\DDC3597Root; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-117 */ +#[Group('DDC-117')] class DDC3597Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -23,7 +24,7 @@ protected function setUp(): void ); } - /** @group DDC-3597 */ + #[Group('DDC-3597')] public function testSaveImageEntity(): void { $imageEntity = new DDC3597Image('foobar'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php index f58ed6a5e8a..931cc0cae7d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php @@ -19,10 +19,11 @@ use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\TestUtil; +use PHPUnit\Framework\Attributes\Group; use const PHP_INT_MAX; -/** @group DDC-3634 */ +#[Group('DDC-3634')] class DDC3634Test extends OrmFunctionalTestCase { private LastInsertIdMocker $idMocker; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php index 4656059db69..892d3bed7c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Functional tests for orphan removal with one to many association. @@ -37,7 +38,7 @@ protected function setUp(): void ); } - /** @group DDC-3644 */ + #[Group('DDC-3644')] public function testIssueWithRegularEntity(): void { // Define initial dataset @@ -87,7 +88,7 @@ public function testIssueWithRegularEntity(): void self::assertCount(1, $addresses); } - /** @group DDC-3644 */ + #[Group('DDC-3644')] public function testIssueWithJoinedEntity(): void { // Define initial dataset diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php index 899c74b4d83..bdfd2078167 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php @@ -8,6 +8,7 @@ use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC3719Test extends OrmFunctionalTestCase { @@ -18,7 +19,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-3719 */ + #[Group('DDC-3719')] public function testCriteriaOnNotOwningSide(): void { $manager = new CompanyManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php index c59ddb7a7a7..942952c1610 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -16,8 +16,9 @@ use Doctrine\ORM\Query; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-371 */ +#[Group('DDC-371')] class DDC371Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php index ec8da8b95fc..d6c5f2aad5b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php @@ -19,6 +19,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Stringable; class DDC3785Test extends OrmFunctionalTestCase @@ -36,7 +37,7 @@ protected function setUp(): void ); } - /** @group DDC-3785 */ + #[Group('DDC-3785')] public function testOwningValueObjectIdIsCorrectlyTransformedWhenRemovingOrphanedChildEntities(): void { $id = new DDC3785AssetId('919609ba-57d9-4a13-be1d-d202521e858a'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php index 4cc73f0085c..3091a47c11f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php @@ -6,8 +6,9 @@ use Doctrine\ORM\NonUniqueResultException; use Doctrine\Tests\DoctrineTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC4024 */ +#[Group('DDC4024')] final class DDC4024Test extends DoctrineTestCase { public function testConstructorShouldUseProvidedMessage(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php index 7438c4c3db9..4910356d428 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -19,6 +19,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\PersistentCollection; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC422Test extends OrmFunctionalTestCase { @@ -33,7 +34,7 @@ protected function setUp(): void ); } - /** @group DDC-422 */ + #[Group('DDC-422')] public function testIssue(): void { $customer = new DDC422Customer(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php index 9654ace9741..230543b3a14 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC425Test extends OrmFunctionalTestCase { @@ -21,7 +22,7 @@ protected function setUp(): void $this->createSchemaForModels(DDC425Entity::class); } - /** @group DDC-425 */ + #[Group('DDC-425')] public function testIssue(): void { $num = $this->_em->createQuery('DELETE ' . __NAMESPACE__ . '\DDC425Entity e WHERE e.someDatetimeField > ?1') diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php index 502b1621452..b65819f3ebc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping\OrderBy; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC440Test extends OrmFunctionalTestCase { @@ -26,7 +27,7 @@ protected function setUp(): void $this->createSchemaForModels(DDC440Phone::class, DDC440Client::class); } - /** @group DDC-440 */ + #[Group('DDC-440')] public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations(): void { /* The key of the problem is that the first phone is fetched via two association, mainPhone and phones. diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php index 8b862b70ee0..836db507267 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Tests that join columns (foreign keys) can be named the same as the association @@ -30,7 +31,7 @@ protected function setUp(): void ); } - /** @group DDC-522 */ + #[Group('DDC-522')] public function testJoinColumnWithSameNameAsAssociationField(): void { $cust = new DDC522Customer(); @@ -66,10 +67,8 @@ public function testJoinColumnWithSameNameAsAssociationField(): void self::assertFalse($fkt2->cart->__isInitialized()); } - /** - * @group DDC-522 - * @group DDC-762 - */ + #[Group('DDC-522')] + #[Group('DDC-762')] public function testJoinColumnWithNullSameNameAssociationField(): void { $fkCust = new DDC522ForeignKeyTest(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php index 259025935b2..c9271a0bd74 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php @@ -12,15 +12,18 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Stringable; /** * This test verifies that custom post-insert identifiers respect type conversion semantics. * The generated identifier must be converted via DBAL types before populating the entity * identifier field. - * - * @group 5935 5684 6020 6152 */ +#[Group('5935')] +#[Group('5684')] +#[Group('6020')] +#[Group('6152')] class DDC5684Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php index 7bdd65d1adf..dde7063c210 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -9,6 +9,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; class DDC588Test extends OrmFunctionalTestCase { @@ -19,6 +20,7 @@ protected function setUp(): void $this->createSchemaForModels(DDC588Site::class); } + #[DoesNotPerformAssertions] public function testIssue(): void { $site = new DDC588Site('Foo'); @@ -27,8 +29,6 @@ public function testIssue(): void $this->_em->flush(); // Following should not result in exception $this->_em->refresh($site); - - $this->addToAssertionCount(1); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php index ad582167ce6..68a7abf5215 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -15,8 +15,9 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-618 */ +#[Group('DDC-618')] class DDC618Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -72,7 +73,7 @@ public function testIndexByHydrateArray(): void self::assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); } - /** @group DDC-1018 */ + #[Group('DDC-1018')] public function testIndexByJoin(): void { $dql = 'SELECT A, B FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A ' . @@ -94,7 +95,7 @@ public function testIndexByJoin(): void self::assertTrue(isset($result[0]['books']['Test']), 'Indexing by title should have books by title.'); } - /** @group DDC-1018 */ + #[Group('DDC-1018')] public function testIndexByToOneJoinSilentlyIgnored(): void { $dql = 'SELECT B, A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Book B ' . @@ -111,7 +112,7 @@ public function testIndexByToOneJoinSilentlyIgnored(): void self::assertEquals('Alice', $result[0]['author']['name']); } - /** @group DDC-1018 */ + #[Group('DDC-1018')] public function testCombineIndexBy(): void { $dql = 'SELECT A, B FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A INDEX BY A.id ' . diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php index 8a8fe37877d..f7c4dfa1c4b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php @@ -16,12 +16,13 @@ use Doctrine\ORM\OptimisticLockException; use Doctrine\Persistence\Mapping\MappingException; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_keys; use function array_walk; use function count; -/** @group #6303 */ +#[Group('#6303')] class DDC6303Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php index 73668fdac65..68d3671ec1b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC633Test extends OrmFunctionalTestCase { @@ -24,11 +25,9 @@ protected function setUp(): void ); } - /** - * @group DDC-633 - * @group DDC-952 - * @group DDC-914 - */ + #[Group('DDC-633')] + #[Group('DDC-952')] + #[Group('DDC-914')] public function testOneToOneEager(): void { $app = new DDC633Appointment(); @@ -48,10 +47,8 @@ public function testOneToOneEager(): void self::assertTrue($this->_em->contains($eagerAppointment->patient)); } - /** - * @group DDC-633 - * @group DDC-952 - */ + #[Group('DDC-633')] + #[Group('DDC-952')] public function testDQLDeferredEagerLoad(): void { for ($i = 0; $i < 10; $i++) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php index b9f3db68ea1..1ea108e4330 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC6460Test extends OrmFunctionalTestCase { @@ -32,7 +33,7 @@ protected function setUp(): void } } - /** @group DDC-6460 */ + #[Group('DDC-6460')] public function testInlineEmbeddable(): void { $isFieldMapped = $this->_em @@ -42,7 +43,7 @@ public function testInlineEmbeddable(): void self::assertTrue($isFieldMapped); } - /** @group DDC-6460 */ + #[Group('DDC-6460')] public function testInlineEmbeddableProxyInitialization(): void { $entity = new DDC6460Entity(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6558Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6558Test.php index c0fc7451a5d..a9c8c7e1f55 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6558Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6558Test.php @@ -6,8 +6,9 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-6558 */ +#[Group('DDC-6558')] class DDC6558Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php index 6d40a6c9a1b..9ca2ab9ccfd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php @@ -8,8 +8,9 @@ use DateTimeZone; use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-657 */ +#[Group('DDC-657')] class DDC657Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php index 38525a6a907..a13ce909739 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php @@ -12,6 +12,7 @@ use Doctrine\Tests\Models\ECommerce\ECommerceCart; use Doctrine\Tests\Models\ECommerce\ECommerceCustomer; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -24,7 +25,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-736 */ + #[Group('DDC-736')] public function testReorderEntityFetchJoinForHydration(): void { $cust = new ECommerceCustomer(); @@ -51,11 +52,9 @@ public function testReorderEntityFetchJoinForHydration(): void self::assertEquals(['name' => 'roman', 'payment' => 'cash'], $result); } - /** - * @group DDC-736 - * @group DDC-925 - * @group DDC-915 - */ + #[Group('DDC-736')] + #[Group('DDC-925')] + #[Group('DDC-915')] public function testDqlTreeWalkerReordering(): void { $cust = new ECommerceCustomer(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php index 31bb97cce93..033dd7199fa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php @@ -8,6 +8,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; use Exception; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -20,7 +21,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-767 */ + #[Group('DDC-767')] public function testCollectionChangesInsideTransaction(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php index 0fb7260ca2a..d36e2f520f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC809Test extends OrmFunctionalTestCase { @@ -48,7 +49,7 @@ protected function setUp(): void $conn->insert('var_spec_value_test', ['variant_id' => 545209, 'specification_value_id' => 94607]); } - /** @group DDC-809 */ + #[Group('DDC-809')] public function testIssue(): void { $result = $this->_em->createQueryBuilder() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php index 5d3cca7d069..1651600fa3a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php @@ -7,6 +7,7 @@ use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsComment; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC812Test extends OrmFunctionalTestCase { @@ -17,7 +18,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-812 */ + #[Group('DDC-812')] public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManagedEntity(): void { $article = new CmsArticle(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index e18e8aff159..d3b908fd561 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC832Test extends OrmFunctionalTestCase { @@ -49,7 +50,7 @@ public function tearDown(): void } } - /** @group DDC-832 */ + #[Group('DDC-832')] public function testQuotedTableBasicUpdate(): void { $like = new DDC832Like('test'); @@ -63,7 +64,7 @@ public function testQuotedTableBasicUpdate(): void self::assertEquals($like, $this->_em->find(DDC832Like::class, $like->id)); } - /** @group DDC-832 */ + #[Group('DDC-832')] public function testQuotedTableBasicRemove(): void { $like = new DDC832Like('test'); @@ -79,7 +80,7 @@ public function testQuotedTableBasicRemove(): void self::assertNull($this->_em->find(DDC832Like::class, $idToBeRemoved)); } - /** @group DDC-832 */ + #[Group('DDC-832')] public function testQuotedTableJoinedUpdate(): void { $index = new DDC832JoinedIndex('test'); @@ -93,7 +94,7 @@ public function testQuotedTableJoinedUpdate(): void self::assertEquals($index, $this->_em->find(DDC832JoinedIndex::class, $index->id)); } - /** @group DDC-832 */ + #[Group('DDC-832')] public function testQuotedTableJoinedRemove(): void { $index = new DDC832JoinedIndex('test'); @@ -109,7 +110,7 @@ public function testQuotedTableJoinedRemove(): void self::assertNull($this->_em->find(DDC832JoinedIndex::class, $idToBeRemoved)); } - /** @group DDC-832 */ + #[Group('DDC-832')] public function testQuotedTableJoinedChildUpdate(): void { $index = new DDC832JoinedTreeIndex('test', 1, 2); @@ -123,7 +124,7 @@ public function testQuotedTableJoinedChildUpdate(): void self::assertEquals($index, $this->_em->find(DDC832JoinedTreeIndex::class, $index->id)); } - /** @group DDC-832 */ + #[Group('DDC-832')] public function testQuotedTableJoinedChildRemove(): void { $index = new DDC832JoinedTreeIndex('test', 1, 2); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php index 9b9a9313144..3d02afd91f9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC837Test extends OrmFunctionalTestCase { @@ -30,7 +31,7 @@ protected function setUp(): void ); } - /** @group DDC-837 */ + #[Group('DDC-837')] public function testIssue(): void { $c1 = new DDC837Class1(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php index 8a4f0c67bb5..e0fa6212f2b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -16,6 +16,7 @@ use Doctrine\ORM\PersistentCollection; use Doctrine\Persistence\Proxy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC881Test extends OrmFunctionalTestCase { @@ -30,10 +31,8 @@ protected function setUp(): void ); } - /** - * @group DDC-117 - * @group DDC-881 - */ + #[Group('DDC-117')] + #[Group('DDC-881')] public function testIssue(): void { /* Create two test users: albert and alfons */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php index 915815a9dcb..416f9c68bf4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php @@ -13,6 +13,7 @@ use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\TestUtil; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -25,7 +26,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-933 */ + #[Group('DDC-933')] public function testLockCTIClass(): void { if ($this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php index 634a60575e5..d73d32ff56e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php @@ -6,6 +6,7 @@ use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC949Test extends OrmFunctionalTestCase { @@ -16,7 +17,7 @@ protected function setUp(): void parent::setUp(); } - /** @group DDC-949 */ + #[Group('DDC-949')] public function testBooleanThroughRepository(): void { $true = new BooleanModel(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php index c977c49a374..5bdaa6e801c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class DDC960Test extends OrmFunctionalTestCase { @@ -22,7 +23,7 @@ protected function setUp(): void $this->createSchemaForModels(DDC960Root::class, DDC960Child::class); } - /** @group DDC-960 */ + #[Group('DDC-960')] public function testUpdateRootVersion(): void { $child = new DDC960Child('Test'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php index da97740feb8..9649f573438 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -19,8 +19,9 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-992 */ +#[Group('DDC-992')] class DDC992Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php index a9b3443402d..27dc1a63448 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\Models\GH10288\GH10288People; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * This test makes sure that Discriminator columns can use both custom types using PHP enums as well as @@ -88,7 +89,7 @@ private function performEnumDiscriminatorTest( self::assertEquals($boss, $bossFetched); } - /** @group GH10288 */ + #[Group('GH10288')] public function testEnumDiscriminatorWithEnumType(): void { $boss = new GH10288BossWithEnumType('John'); @@ -97,7 +98,7 @@ public function testEnumDiscriminatorWithEnumType(): void $this->performEnumDiscriminatorTest($boss, $employee, GH10288PersonWithEnumType::class); } - /** @group GH10288 */ + #[Group('GH10288')] public function testEnumDiscriminatorWithCustomEnumType(): void { $boss = new GH10288BossCustomEnumType('John'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php index 06237df9b1f..b3066bb10f4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php @@ -7,8 +7,9 @@ use Doctrine\Tests\Models\GH10336\GH10336Entity; use Doctrine\Tests\Models\GH10336\GH10336Relation; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\RequiresPhp; -/** @requires PHP 7.4 */ +#[RequiresPhp('7.4')] final class GH10336Test extends OrmFunctionalTestCase { public function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10387Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10387Test.php index 77de81c5d17..ccf802a6b05 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10387Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10387Test.php @@ -8,13 +8,15 @@ use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\OrmTestCase; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function array_map; -/** @group GH-10387 */ +#[Group('GH-10387')] class GH10387Test extends OrmTestCase { - /** @dataProvider classHierachies */ + #[DataProvider('classHierachies')] public function testSchemaToolCreatesColumnForFieldInTheMiddleClass(array $classes): void { $em = $this->getTestEntityManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php index 7d0b77e52d9..9db15b1e0c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php @@ -11,10 +11,11 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\Query; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Stringable; use Symfony\Component\Cache\Adapter\ArrayAdapter; -/** @group GH-2947 */ +#[Group('GH-2947')] class GH2947Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php index 98a936e1bac..6169bed1486 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function mt_getrandmax; use function random_int; @@ -32,7 +33,7 @@ protected function setUp(): void ); } - /** @group GH-5562 */ + #[Group('GH-5562')] public function testCacheShouldBeUpdatedWhenAssociationChanges(): void { $manager = new GH5562Manager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index 6083f8b88af..522eba50f6e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -16,11 +16,12 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\ORM\PersistentCollection; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_unique; use function count; -/** @group GH-5762 */ +#[Group('GH-5762')] class GH5762Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index 172134b8ef5..d48963be4f1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -15,8 +15,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-5804 */ +#[Group('GH-5804')] final class GH5804Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php index 556fb58f022..d722e3698ac 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php @@ -14,11 +14,12 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Stringable; use function assert; -/** @group GH-5887 */ +#[Group('GH-5887')] class GH5887Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php index b8c831bc0ed..4db2800ed79 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php @@ -7,8 +7,9 @@ use Doctrine\DBAL\LockMode; use Doctrine\ORM\Mapping as ORM; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-5998 */ +#[Group('GH-5998')] class GH5998Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php index aaacc4f0128..fd42ff8b3c2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function sprintf; @@ -39,9 +40,8 @@ protected function setUp(): void /** * Verifies that when wrong entity is persisted via relationship field, the error message does not correctly state * the expected class name. - * - * @group GH-6029 */ + #[Group('GH-6029')] public function testManyToManyAssociation(): void { $user = new GH6029User(); @@ -64,9 +64,8 @@ public function testManyToManyAssociation(): void /** * Verifies that when wrong entity is persisted via relationship field, the error message does not correctly state * the expected class name. - * - * @group GH-6029 */ + #[Group('GH-6029')] public function testOneToManyAssociation(): void { $product = new GH6029Product(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php index b58a3b7a2fb..561141f89a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\OrmFunctionalTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; use Stringable; use function in_array; @@ -40,9 +41,8 @@ protected function setUp(): void * The intent of this test is to ensure that the ORM is capable * of using objects as discriminators (which makes things a bit * more dynamic as you can see on the mapping of `GH6141Person`) - * - * @group GH-6141 */ + #[Group('GH-6141')] public function testEnumDiscriminatorsShouldBeConvertedToString(): void { $boss = new GH6141Boss('John'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php index dd8516757a3..d23f5e68acd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php @@ -11,10 +11,11 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function uniqid; -/** @group #6217 */ +#[Group('#6217')] final class GH6217Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php index 4b9679c7ff5..c87c9cd9d86 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -21,6 +21,7 @@ use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; final class GH6362Test extends OrmFunctionalTestCase { @@ -37,14 +38,13 @@ protected function setUp(): void } /** - * @group GH-6362 - * * SELECT a as base, b, c, d * FROM Start a * LEFT JOIN a.bases b * LEFT JOIN Child c WITH b.id = c.id * LEFT JOIN c.joins d */ + #[Group('GH-6362')] public function testInheritanceJoinAlias(): void { $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php index 9eb673ddb34..1bcfe4a69b1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class GH6394Test extends OrmFunctionalTestCase { @@ -24,9 +25,8 @@ protected function setUp(): void /** * Test the the version of an entity can be fetched, when the id field and * the id column are different. - * - * @group 6393 */ + #[Group('6393')] public function testFetchVersionValueForDifferentIdFieldAndColumn(): void { $a = new A(1); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php index 74db31ebce8..7e302f9e52b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php @@ -9,8 +9,9 @@ use Doctrine\Tests\Models\Quote\FullAddress; use Doctrine\Tests\Models\Quote\User; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-6402 */ +#[Group('GH-6402')] class GH6402Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php index a6e629a5ae6..4a2b51a3170 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php @@ -12,8 +12,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-6464 */ +#[Group('GH-6464')] class GH6464Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php index c5265a9634a..f4a7f30934d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; final class GH6531Test extends OrmFunctionalTestCase { @@ -34,7 +35,7 @@ protected function setUp(): void ); } - /** @group GH-6531 */ + #[Group('GH-6531')] public function testSimpleDerivedIdentity(): void { $user = new GH6531User(); @@ -49,7 +50,7 @@ public function testSimpleDerivedIdentity(): void self::assertSame($address, $this->_em->find(GH6531Address::class, $user)); } - /** @group GH-6531 */ + #[Group('GH-6531')] public function testDynamicAttributes(): void { $article = new GH6531Article(); @@ -64,7 +65,7 @@ public function testDynamicAttributes(): void ); } - /** @group GH-6531 */ + #[Group('GH-6531')] public function testJoinTableWithMetadata(): void { $product = new GH6531Product(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php index 7af662be4a8..440441eb854 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php @@ -6,10 +6,11 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; final class GH6682Test extends OrmFunctionalTestCase { - /** @group GH-6682 */ + #[Group('GH-6682')] public function testIssue(): void { $parsedDefinition = [ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php index 70088a4b719..5944c1a879a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php @@ -6,8 +6,9 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-6699 */ +#[Group('GH-6699')] final class GH6699Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php index dd032941733..1eb82f85baf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php @@ -8,6 +8,7 @@ use Doctrine\Tests\Models\ECommerce\ECommerceCategory; use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; final class GH6740Test extends OrmFunctionalTestCase { @@ -44,7 +45,7 @@ protected function setUp(): void $this->secondCategoryId = $secondCategory->getId(); } - /** @group GH-6740 */ + #[Group('GH-6740')] public function testCollectionFilteringLteOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); @@ -53,7 +54,7 @@ public function testCollectionFilteringLteOperator(): void self::assertCount(2, $product->getCategories()->matching($criteria)); } - /** @group GH-6740 */ + #[Group('GH-6740')] public function testCollectionFilteringLtOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); @@ -62,7 +63,7 @@ public function testCollectionFilteringLtOperator(): void self::assertCount(1, $product->getCategories()->matching($criteria)); } - /** @group GH-6740 */ + #[Group('GH-6740')] public function testCollectionFilteringGteOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); @@ -71,7 +72,7 @@ public function testCollectionFilteringGteOperator(): void self::assertCount(2, $product->getCategories()->matching($criteria)); } - /** @group GH-6740 */ + #[Group('GH-6740')] public function testCollectionFilteringGtOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); @@ -80,7 +81,7 @@ public function testCollectionFilteringGtOperator(): void self::assertCount(1, $product->getCategories()->matching($criteria)); } - /** @group GH-6740 */ + #[Group('GH-6740')] public function testCollectionFilteringEqualsOperator(): void { $product = $this->_em->find(ECommerceProduct::class, $this->productId); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php index 1b0884be784..0c6dc146875 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-6937 */ +#[Group('GH-6937')] final class GH6937Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php index f4181bc8f32..6f24cc8bf60 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\Models\Quote\User as QuotedUser; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; final class GH7012Test extends OrmFunctionalTestCase { @@ -24,7 +25,7 @@ protected function setUp(): void $this->setUpEntitySchema([GH7012UserData::class]); } - /** @group GH-7012 */ + #[Group('GH-7012')] public function testUpdateEntityWithIdentifierAssociationWithQuotedJoinColumn(): void { $user = new QuotedUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php index 17a39e4ca0d..d16c204ba07 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php @@ -15,6 +15,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -37,7 +38,7 @@ protected function setUp(): void ); } - /** @group GH-7062 */ + #[Group('GH-7062')] public function testEntityWithAssociationKeyIdentityCanBeUpdated(): void { $this->createInitialRankingWithRelatedEntities(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php index 8409317e81d..b5c6345cfb8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Version; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -26,7 +27,7 @@ protected function setUp(): void $this->setUpEntitySchema([GH7067Entity::class]); } - /** @group GH-7067 */ + #[Group('GH-7067')] public function testSLCWithVersion(): void { $entity = new GH7067Entity(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php index d4f91806122..508d77ef14e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php @@ -16,8 +16,9 @@ use Doctrine\ORM\Mapping\Table; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH7079 */ +#[Group('GH7079')] final class GH7079Test extends OrmFunctionalTestCase { private DefaultQuoteStrategy $strategy; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php index daa2cdae65c..2945bcef595 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; final class GH7259Test extends OrmFunctionalTestCase { @@ -21,7 +22,7 @@ protected function setUp(): void $this->setUpEntitySchema([GH7259Space::class, GH7259File::class, GH7259FileVersion::class, GH7259Feed::class]); } - /** @group GH-7259 */ + #[Group('GH-7259')] public function testPersistFileBeforeVersion(): void { $space = new GH7259Space(); @@ -46,7 +47,7 @@ public function testPersistFileBeforeVersion(): void self::assertNotNull($fileVersion->id); } - /** @group GH-7259 */ + #[Group('GH-7259')] public function testPersistFileAfterVersion(): void { $space = new GH7259Space(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php index 52e3132b6d3..497f1d50143 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; final class GH7286Test extends OrmFunctionalTestCase { @@ -54,7 +55,7 @@ public function testAggregateExpressionInFunction(): void ); } - /** @group DDC-1091 */ + #[Group('DDC-1091')] public function testAggregateFunctionInCustomFunction(): void { $this->_em->getConfiguration()->addCustomStringFunction('CC', GH7286CustomConcat::class); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php index 566aab7a784..58bc559dad1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php @@ -13,10 +13,11 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** @group GH7505 */ +#[Group('GH7505')] final class GH7505Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php index 1c4f2175325..53133516bbe 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class GH7629Test extends OrmFunctionalTestCase { @@ -36,7 +37,7 @@ public function testClearScheduledForSynchronizationWhenCommitEmpty(): void self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDirtyCheck($entity)); } - /** @group GH-8231 */ + #[Group('GH-8231')] public function testPersistAfterRemoveSchedulesForSynchronization(): void { $entity = $this->_em->find(GH7629Entity::class, 1); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php index c75098654e9..a267cc6071d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php @@ -11,10 +11,11 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_keys; -/** @group GH-7661 */ +#[Group('GH-7661')] class GH7661Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php index 4a0466b0a92..99dc13b87d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php @@ -12,6 +12,8 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use function assert; @@ -34,10 +36,8 @@ protected function setUp(): void $this->_em->clear(); } - /** - * @test - * @group GH7735 - */ + #[Test] + #[Group('GH7735')] public function findByReturnsCachedEntity(): void { $this->_em->getCache()->evictEntityRegion(GH7735Power::class); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php index 5cee250913e..774820eb5d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php @@ -14,8 +14,10 @@ use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; -/** @group GH7737 */ +#[Group('GH7737')] class GH7737Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -35,7 +37,7 @@ protected function setUp(): void $this->_em->clear(); } - /** @test */ + #[Test] public function memberOfCriteriaShouldBeCompatibleWithQueryBuilder(): void { $query = $this->_em->createQueryBuilder() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php index 3495b4c1b9f..02cad1fee19 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -54,7 +55,7 @@ public function testCollectionClearDoesNotClearIfNotPersisted(): void self::assertCount(1, $entity->children); } - /** @group GH-7862 */ + #[Group('GH-7862')] public function testCollectionClearDoesClearIfPersisted(): void { $entity = $this->_em->find(GH7761Entity::class, 1); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php index cf983d8670f..d469e4332c0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php @@ -14,10 +14,11 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OrderBy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** @group GH7767 */ +#[Group('GH7767')] class GH7767Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php index 80ec50ce441..5e408625f3d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Assert; +use PHPUnit\Framework\Attributes\Group; use Psr\Cache\CacheItemInterface; use Stringable; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -24,8 +25,6 @@ use function iterator_to_array; /** - * @group GH7820 - * * When using a {@see \Doctrine\ORM\Tools\Pagination\Paginator} to iterate over a query * that has entities with a custom DBAL type used in the identifier, then `$id->__toString()` * is used implicitly by {@see \PDOStatement::bindValue()}, instead of being converted by the @@ -37,10 +36,10 @@ * * If `#__toString()` and the DBAL type conversions are asymmetric, then the paginator will fail * to find records. - * * Tricky situation, but this very much affects `ramsey/uuid-doctrine` and anyone relying on (for * example) the {@see \Ramsey\Uuid\Doctrine\UuidBinaryType} type. */ +#[Group('GH7820')] class GH7820Test extends OrmFunctionalTestCase { private const SONG = [ @@ -79,7 +78,7 @@ public function testWillFindSongsInPaginator(): void self::assertSame(self::SONG, $lines); } - /** @group GH7837 */ + #[Group('GH7837')] public function testWillFindSongsInPaginatorEvenWithCachedQueryParsing(): void { // Enable the query cache diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php index 58c14bb4a2c..abf121e7bb7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php @@ -7,8 +7,9 @@ use Doctrine\ORM\Tools\Pagination\Paginator; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH7829 */ +#[Group('GH7829')] final class GH7829Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php index 4003d1e7c82..6295de8a537 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php @@ -14,10 +14,11 @@ use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\OrderBy; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; -/** @group GH7836 */ +#[Group('GH7836')] class GH7836Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php index a9a0b52cd78..a21e59e2f1d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php @@ -13,10 +13,11 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function array_values; -/** @group gh7864 */ +#[Group('gh7864')] class GH7864Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php index 4f18fc17a13..3449fec5c9e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php @@ -17,10 +17,11 @@ use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use function method_exists; -/** @group GH7869 */ +#[Group('GH7869')] class GH7869Test extends OrmTestCase { public function testDQLDeferredEagerLoad(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php index 3b4fa7d0b96..b19f9fed601 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php @@ -11,6 +11,8 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\After; +use PHPUnit\Framework\Attributes\Group; use function array_filter; use function current; @@ -18,10 +20,10 @@ use function str_contains; use function str_starts_with; -/** @group GH7875 */ +#[Group('GH7875')] final class GH7875Test extends OrmFunctionalTestCase { - /** @after */ + #[After] public function cleanUpSchema(): void { $connection = $this->_em->getConnection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php index 6693828964b..68249de9897 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php @@ -11,11 +11,13 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use function ltrim; use function strlen; -/** @group GH7941 */ +#[Group('GH7941')] final class GH7941Test extends OrmFunctionalTestCase { private const PRODUCTS = [ @@ -41,7 +43,7 @@ protected function setUp(): void $this->_em->clear(); } - /** @test */ + #[Test] public function typesShouldBeConvertedForDQLFunctions(): void { $query = $this->_em->createQuery( diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php index a7283260255..6c6f4cd9a6d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH8055 */ +#[Group('GH8055')] final class GH8055Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php index 660840d3c92..9e02de58b70 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php @@ -11,10 +11,11 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use function sprintf; -/** @group GH8061 */ +#[Group('GH8061')] final class GH8061Test extends OrmTestCase { public static function setUpBeforeClass(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8127Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8127Test.php index 446c23a18de..c88053901c7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8127Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8127Test.php @@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; class GH8127Test extends OrmFunctionalTestCase { @@ -20,7 +21,7 @@ protected function setUp(): void ); } - /** @dataProvider queryClasses */ + #[DataProvider('queryClasses')] public function testLoadFieldsFromAllClassesInHierarchy(string $queryClass): void { $entity = new GH8127Leaf(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php index 4234c2546cd..21b4db18abb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; final class GH8217Test extends OrmFunctionalTestCase { @@ -29,7 +30,7 @@ protected function setUp(): void ); } - /** @group GH-8217 */ + #[Group('GH-8217')] public function testNoQueriesAfterSecondFlush(): void { $collection = new GH8217Collection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php index d2a27acd686..44695f1856e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php @@ -18,6 +18,7 @@ use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -32,7 +33,7 @@ protected function setUp(): void $this->createSchemaForModels(GH8443Foo::class); } - /** @group GH-8443 */ + #[Group('GH-8443')] public function testJoinRootEntityWithForcePartialLoad(): void { $person = new CompanyPerson(); @@ -61,7 +62,7 @@ public function testJoinRootEntityWithForcePartialLoad(): void $this->assertEquals('John', $manager->getSpouse()->getName()); } - /** @group GH-8443 */ + #[Group('GH-8443')] public function testJoinRootEntityWithOnlyOneEntityInHierarchy(): void { $bar = new GH8443Foo('bar'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php index deb6c43455b..9f6f3066caa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php @@ -16,6 +16,8 @@ use Doctrine\ORM\Mapping\Version; use Doctrine\ORM\OptimisticLockException; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use function date; use function strtotime; @@ -37,7 +39,7 @@ protected function createSchema(): void $this->createSchemaForModels(GH8499VersionableEntity::class); } - /** @group GH-8499 */ + #[Group('GH-8499')] public function testOptimisticTimestampSetsDefaultValue(): GH8499VersionableEntity { $this->createSchema(); @@ -54,10 +56,8 @@ public function testOptimisticTimestampSetsDefaultValue(): GH8499VersionableEnti return $entity; } - /** - * @group GH-8499 - * @depends testOptimisticTimestampSetsDefaultValue - */ + #[Depends('testOptimisticTimestampSetsDefaultValue')] + #[Group('GH-8499')] public function testOptimisticLockWithDateTimeForVersion(GH8499VersionableEntity $entity): void { $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Ticket\GH8499VersionableEntity t WHERE t.id = :id'); @@ -94,7 +94,7 @@ public function testOptimisticLockWithDateTimeForVersion(GH8499VersionableEntity ); } - /** @group GH-8499 */ + #[Group('GH-8499')] public function testOptimisticLockWithDateTimeForVersionThrowsException(): void { $this->createSchema(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php index 91141236e7a..328aadcdfaa 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php @@ -13,13 +13,13 @@ use Doctrine\ORM\Mapping\InheritanceType; use Doctrine\ORM\Mapping\MappedSuperclass; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; final class GH8914Test extends OrmTestCase { - /** - * @group GH-8914 - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] + #[Group('GH-8914')] public function testDiscriminatorMapWithSeveralLevelsIsSupported(): void { $entityManager = $this->getTestEntityManager(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php index 08a776de0ef..64a04535984 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class GH9027Test extends OrmFunctionalTestCase { @@ -23,7 +24,7 @@ protected function setUp(): void $this->createSchemaForModels(GH9027Cart::class, GH9027Customer::class); } - /** @group GH-9027 */ + #[Group('GH-9027')] public function testUnitOfWorkHandlesNullRelations(): void { $uow = new UnitOfWork($this->_em); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php index d75963c1f48..8bae1d8cc61 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php @@ -13,8 +13,9 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-9109 */ +#[Group('GH-9109')] class GH9109Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php index 7e3a2947198..3354982113d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php @@ -9,8 +9,10 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-9230 */ +#[Group('GH-9230')] class GH9230Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -81,10 +83,8 @@ public static function succeedingValuesBeforeFix(): array ]; } - /** - * @dataProvider failingValuesBeforeFix - * @dataProvider succeedingValuesBeforeFix - */ + #[DataProvider('failingValuesBeforeFix')] + #[DataProvider('succeedingValuesBeforeFix')] public function testIssue(string $property, $falsyValue, $truthyValue): void { $counter1 = new GH9230Entity(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php index ed199c33c50..44b082d4290 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php @@ -15,8 +15,9 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\Tests\Mocks\CompatibilityType; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH9335 */ +#[Group('GH9335')] final class GH9335Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php index 9d2b5714c1c..61b59e7f097 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php @@ -15,8 +15,9 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group GH-9579 */ +#[Group('GH-9579')] class GH9579Test extends OrmFunctionalTestCase { protected function setUp(): void @@ -47,7 +48,7 @@ protected function setUp(): void $this->_em->clear(); } - /** @group GH-9579 */ + #[Group('GH-9579')] public function testIssue(): void { $dql = <<<'DQL' diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php index d2eaa3d734e..b0ec1866b91 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php @@ -8,8 +8,9 @@ use Doctrine\Tests\Models\Issue5989\Issue5989Manager; use Doctrine\Tests\Models\Issue5989\Issue5989Person; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group issue-5989 */ +#[Group('issue-5989')] class Issue5989Test extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index 59f96542d9b..9743ebcfb17 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -14,6 +14,7 @@ use Doctrine\Tests\Models\Generic\DecimalModel; use Doctrine\Tests\Models\Generic\SerializationModel; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use stdClass; use function class_exists; @@ -44,7 +45,7 @@ public function testDecimal(): void self::assertSame('0.1515', $decimal->highScale); } - /** @group DDC-1394 */ + #[Group('DDC-1394')] public function testBoolean(): void { $bool = new BooleanModel(); diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php index 4eacbfcc6dc..c20f4dd0427 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php @@ -11,6 +11,7 @@ use Doctrine\Tests\Models\CustomType\CustomTypeParent; use Doctrine\Tests\Models\CustomType\CustomTypeUpperCase; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; class TypeValueSqlTest extends OrmFunctionalTestCase { @@ -51,7 +52,7 @@ public function testUpperCaseStringType(): void self::assertEquals('FOO', $this->_em->getConnection()->fetchOne('select lowerCaseString from customtype_uppercases where id=' . $entity->id . ''), 'Database holds uppercase string'); } - /** @group DDC-1642 */ + #[Group('DDC-1642')] public function testUpperCaseStringTypeWhenColumnNameIsDefined(): void { $entity = new CustomTypeUpperCase(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php index de934a8c8ce..8ce7163e3c8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php @@ -9,6 +9,8 @@ use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). @@ -16,9 +18,8 @@ * * Test that ManyToMany associations with composite id of which one is a * association itself work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class ManyToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -74,7 +75,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('tuv', $conn->fetchOne('SELECT owning_id FROM vct_xref_manytomany_compositeid_foreignkey LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( @@ -97,7 +98,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningManyToManyCompositeIdForeignKeyEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( @@ -121,7 +122,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id2); } - /** @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase')] public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( @@ -137,7 +138,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti self::assertInstanceOf(InversedManyToManyCompositeIdForeignKeyEntity::class, $inversed); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -148,7 +149,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void self::assertCount(1, $owning->associatedEntities); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( @@ -159,10 +160,8 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void self::assertCount(1, $inversed->associatedEntities); } - /** - * @depends testThatTheCollectionFromOwningToInversedIsLoaded - * @depends testThatTheCollectionFromInversedToOwningIsLoaded - */ + #[Depends('testThatTheCollectionFromOwningToInversedIsLoaded')] + #[Depends('testThatTheCollectionFromInversedToOwningIsLoaded')] public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): void { $conn = $this->_em->getConnection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php index 7ddd4b13a1f..9f9d5b28f53 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php @@ -8,15 +8,16 @@ use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). * {@see \Doctrine\Tests\DbalTypes\Rot13Type} * * Test that ManyToMany associations with composite id work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class ManyToManyCompositeIdTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -65,7 +66,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('tuv', $conn->fetchOne('SELECT owning_id FROM vct_xref_manytomany_compositeid LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -82,7 +83,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningManyToManyCompositeIdEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -100,7 +101,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id3); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -111,7 +112,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void self::assertCount(1, $owning->associatedEntities); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( @@ -122,10 +123,8 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void self::assertCount(1, $inversed->associatedEntities); } - /** - * @depends testThatTheCollectionFromOwningToInversedIsLoaded - * @depends testThatTheCollectionFromInversedToOwningIsLoaded - */ + #[Depends('testThatTheCollectionFromOwningToInversedIsLoaded')] + #[Depends('testThatTheCollectionFromInversedToOwningIsLoaded')] public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): void { $conn = $this->_em->getConnection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php index c241baff551..c1adbdf8e1b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php @@ -8,6 +8,7 @@ use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyExtraLazyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyExtraLazyEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). @@ -15,9 +16,8 @@ * * Test that ManyToMany associations work correctly, focusing on EXTRA_LAZY * functionality. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class ManyToManyExtraLazyTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php index 20349eb988d..f8370239d1a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php @@ -8,15 +8,16 @@ use Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). * {@see \Doctrine\Tests\DbalTypes\Rot13Type} * * Test that ManyToMany associations work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class ManyToManyTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -62,7 +63,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('qrs', $conn->fetchOne('SELECT owning_id FROM vct_xref_manytomany LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -79,7 +80,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningManyToManyEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -96,7 +97,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('def', $owning->id2); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -107,7 +108,7 @@ public function testThatTheCollectionFromOwningToInversedIsLoaded(): void self::assertCount(1, $owning->associatedEntities); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( @@ -118,10 +119,8 @@ public function testThatTheCollectionFromInversedToOwningIsLoaded(): void self::assertCount(1, $inversed->associatedEntities); } - /** - * @depends testThatTheCollectionFromOwningToInversedIsLoaded - * @depends testThatTheCollectionFromInversedToOwningIsLoaded - */ + #[Depends('testThatTheCollectionFromOwningToInversedIsLoaded')] + #[Depends('testThatTheCollectionFromInversedToOwningIsLoaded')] public function testThatTheJoinTableRowsAreRemovedWhenRemovingTheAssociation(): void { $conn = $this->_em->getConnection(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php index ce8291c32cf..a346881ed96 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php @@ -9,6 +9,8 @@ use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). @@ -16,9 +18,8 @@ * * Test that OneToMany associations with composite id of which one is a * association itself work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class OneToManyCompositeIdForeignKeyTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -72,7 +73,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('nop', $conn->fetchOne('SELECT associated_foreign_id FROM vct_owning_manytoone_compositeid_foreignkey LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( @@ -95,7 +96,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningManyToOneCompositeIdForeignKeyEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( @@ -119,7 +120,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id2); } - /** @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase')] public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( @@ -135,7 +136,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti self::assertInstanceOf(InversedOneToManyCompositeIdForeignKeyEntity::class, $inversed); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -150,7 +151,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php index d71cd1acaa9..8304e0c311e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php @@ -8,15 +8,16 @@ use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). * {@see \Doctrine\Tests\DbalTypes\Rot13Type} * * Test that OneToMany associations with composite id work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class OneToManyCompositeIdTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -63,7 +64,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('qrs', $conn->fetchOne('SELECT associated_id2 FROM vct_owning_manytoone_compositeid LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -80,7 +81,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningManyToOneCompositeIdEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -98,7 +99,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id3); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -111,7 +112,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php index 434e740f2bc..9b3e2fe929e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php @@ -8,6 +8,7 @@ use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). @@ -15,9 +16,8 @@ * * Test that OneToMany associations work correctly, focusing on EXTRA_LAZY * functionality. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class OneToManyExtraLazyTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php index ff87c7ae430..f91dae6ceda 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php @@ -8,15 +8,16 @@ use Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). * {@see \Doctrine\Tests\DbalTypes\Rot13Type} * * Test that OneToMany associations work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class OneToManyTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -60,7 +61,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('nop', $conn->fetchOne('SELECT associated_id FROM vct_owning_manytoone LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -77,7 +78,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningManyToOneEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -94,7 +95,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('def', $owning->id2); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -107,7 +108,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheCollectionFromInversedToOwningIsLoaded(): void { $inversed = $this->_em->find( diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php index f5418f945af..8f8ac3846a7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php @@ -9,6 +9,8 @@ use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity; use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). @@ -16,9 +18,8 @@ * * Test that OneToOne associations with composite id of which one is a * association itself work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class OneToOneCompositeIdForeignKeyTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -72,7 +73,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('nop', $conn->fetchOne('SELECT associated_foreign_id FROM vct_owning_onetoone_compositeid_foreignkey LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( @@ -95,7 +96,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningOneToOneCompositeIdForeignKeyEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $auxiliary = $this->_em->find( @@ -119,7 +120,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id2); } - /** @depends testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase')] public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEntityAsId(): void { $auxiliary = $this->_em->find( @@ -135,7 +136,7 @@ public function testThatInversedEntityIsFetchedFromTheDatabaseUsingAuxiliaryEnti self::assertInstanceOf(InversedOneToOneCompositeIdForeignKeyEntity::class, $inversed); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -148,7 +149,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php index 4dfa40c08e1..0a609e23966 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php @@ -8,15 +8,16 @@ use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity; use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). * {@see \Doctrine\Tests\DbalTypes\Rot13Type} * * Test that OneToOne associations with composite id work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class OneToOneCompositeIdTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -63,7 +64,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('qrs', $conn->fetchOne('SELECT associated_id2 FROM vct_owning_onetoone_compositeid LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -80,7 +81,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningOneToOneCompositeIdEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -98,7 +99,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('ghi', $owning->id3); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -111,7 +112,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php index eec2291db8c..f91f6caff06 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php @@ -8,15 +8,16 @@ use Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity; use Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; /** * The entities all use a custom type that converst the value as identifier(s). * {@see \Doctrine\Tests\DbalTypes\Rot13Type} * * Test that OneToOne associations work correctly. - * - * @group DDC-3380 */ +#[Group('DDC-3380')] class OneToOneTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -60,7 +61,7 @@ public function testThatTheValueOfIdentifiersAreConvertedInTheDatabase(): void self::assertEquals('nop', $conn->fetchOne('SELECT associated_id FROM vct_owning_onetoone LIMIT 1')); } - /** @depends testThatTheValueOfIdentifiersAreConvertedInTheDatabase */ + #[Depends('testThatTheValueOfIdentifiersAreConvertedInTheDatabase')] public function testThatEntitiesAreFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -77,7 +78,7 @@ public function testThatEntitiesAreFetchedFromTheDatabase(): void self::assertInstanceOf(OwningOneToOneEntity::class, $owning); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFromTheDatabase(): void { $inversed = $this->_em->find( @@ -94,7 +95,7 @@ public function testThatTheValueOfIdentifiersAreConvertedBackAfterBeingFetchedFr self::assertEquals('def', $owning->id2); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheProxyFromOwningToInversedIsLoaded(): void { $owning = $this->_em->find( @@ -107,7 +108,7 @@ public function testThatTheProxyFromOwningToInversedIsLoaded(): void self::assertEquals('some value to be loaded', $inversedProxy->someProperty); } - /** @depends testThatEntitiesAreFetchedFromTheDatabase */ + #[Depends('testThatEntitiesAreFetchedFromTheDatabase')] public function testThatTheEntityFromInversedToOwningIsEagerLoaded(): void { $inversed = $this->_em->find( diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 5dce79ef635..3186e71d357 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -21,12 +21,14 @@ use Doctrine\ORM\Query\QueryException; use Doctrine\Persistence\Reflection\RuntimeReflectionProperty; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use ReflectionProperty; use function class_exists; use function sprintf; -/** @group DDC-93 */ +#[Group('DDC-93')] class ValueObjectsTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -159,7 +161,7 @@ public function testLoadDql(): void } } - /** @group dql */ + #[Group('dql')] public function testDqlOnEmbeddedObjectsField(): void { if ($this->isSecondLevelCacheEnabled) { @@ -327,7 +329,7 @@ public function testInlineEmbeddableInMappedSuperClass(): void self::assertTrue($isFieldMapped); } - /** @dataProvider getInfiniteEmbeddableNestingData */ + #[DataProvider('getInfiniteEmbeddableNestingData')] public function testThrowsExceptionOnInfiniteEmbeddableNesting( string $embeddableClassName, string $declaredEmbeddableClassName, diff --git a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php index 5921eceaf0f..8029695f3b5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php @@ -7,12 +7,12 @@ use Doctrine\Tests\Models\VersionedOneToOne\FirstRelatedEntity; use Doctrine\Tests\Models\VersionedOneToOne\SecondRelatedEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Tests that an entity with a OneToOne relationship defined as the id, with a version field can be created. - * - * @group VersionedOneToOne */ +#[Group('VersionedOneToOne')] class VersionedOneToOneTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php index ad0d9c20cbc..a9b451e1c19 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php @@ -14,11 +14,13 @@ use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use function iterator_to_array; -/** @covers \Doctrine\ORM\Internal\Hydration\AbstractHydrator */ +#[CoversClass(AbstractHydrator::class)] class AbstractHydratorTest extends OrmFunctionalTestCase { private EventManager&MockObject $mockEventManager; @@ -56,12 +58,11 @@ protected function setUp(): void } /** - * @group DDC-3146 - * @group #1515 - * * Verify that the number of added events to the event listener from the abstract hydrator class is equal to the * number of removed events */ + #[Group('DDC-3146')] + #[Group('#1515')] public function testOnClearEventListenerIsDetachedOnCleanup(): void { $eventListenerHasBeenRegistered = false; @@ -88,7 +89,7 @@ public function testOnClearEventListenerIsDetachedOnCleanup(): void iterator_to_array($this->hydrator->toIterable($this->mockResult, $this->mockResultMapping)); } - /** @group #6623 */ + #[Group('#6623')] public function testHydrateAllRegistersAndClearsAllAttachedListeners(): void { $eventListenerHasBeenRegistered = false; @@ -115,7 +116,7 @@ public function testHydrateAllRegistersAndClearsAllAttachedListeners(): void $this->hydrator->hydrateAll($this->mockResult, $this->mockResultMapping); } - /** @group #8482 */ + #[Group('#8482')] public function testHydrateAllClearsAllAttachedListenersEvenOnError(): void { $eventListenerHasBeenRegistered = false; diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php index c1fd5c5daf3..33d08edf7d1 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php @@ -12,6 +12,8 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\Forum\ForumBoard; use Doctrine\Tests\Models\Forum\ForumCategory; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; class ArrayHydratorTest extends HydrationTestCase { @@ -67,9 +69,8 @@ public function testSimpleEntityQuery(): void /** * SELECT PARTIAL scalars.{id, name}, UPPER(scalars.name) AS nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser scalars - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testSimpleEntityWithScalarQuery(int|string $userEntityKey): void { $alias = $userEntityKey ?: 'u'; @@ -375,9 +376,8 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void * FROM Doctrine\Tests\Models\CMS\CmsUser u * JOIN u.phonenumbers p * GROUP BY u.status, u.id - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testMixedQueryNormalJoin(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); @@ -424,9 +424,8 @@ public function testMixedQueryNormalJoin(int|string $userEntityKey): void * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) AS nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u * JOIN u.phonenumbers p - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testMixedQueryFetchJoin(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); @@ -495,9 +494,8 @@ public function testMixedQueryFetchJoin(int|string $userEntityKey): void * INDEX BY u.id * JOIN u.phonenumbers p * INDEX BY p.phonenumber - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testMixedQueryFetchJoinCustomIndex(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); @@ -925,9 +923,8 @@ public function testEntityQueryCustomResultSetOrder(): void * FROM Doctrine\Tests\Models\CMS\CmsUser u * LEFT JOIN u.articles a * LEFT JOIN a.comments c - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testChainedJoinWithScalars(int|string $entityKey): void { $rsm = new ResultSetMapping(); @@ -1083,9 +1080,8 @@ public function testResultIterationWithAliasedUserEntity(): void /** * SELECT PARTIAL u.{id, name} * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-644 */ + #[Group('DDC-644')] public function testSkipUnknownColumns(): void { $rsm = new ResultSetMapping(); @@ -1116,10 +1112,9 @@ public function testSkipUnknownColumns(): void /** * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-1358 - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] + #[Group('DDC-1358')] public function testMissingIdForRootEntity(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); @@ -1175,10 +1170,9 @@ public function testMissingIdForRootEntity(int|string $userEntityKey): void * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u * INDEX BY u.id - * - * @group DDC-1385 - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] + #[Group('DDC-1385')] public function testIndexByAndMixedResult(int|string $userEntityKey): void { $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index 832d91427d1..e2d803cd48a 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -29,6 +29,8 @@ use Doctrine\Tests\Models\Forum\ForumCategory; use Doctrine\Tests\Models\Hydration\EntityWithArrayDefaultArrayValueM2M; use Doctrine\Tests\Models\Hydration\SimpleEntity; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function count; use function property_exists; @@ -387,9 +389,8 @@ public function testSimpleMultipleRootEntityQueryWithAliasedEntities(): void * FROM User u * JOIN u.phonenumbers p * GROUP BY u.id - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testMixedQueryNormalJoin($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -436,9 +437,8 @@ public function testMixedQueryNormalJoin($userEntityKey): void * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u * JOIN u.phonenumbers p - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testMixedQueryFetchJoin($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -514,9 +514,8 @@ public function testMixedQueryFetchJoin($userEntityKey): void * INDEX BY u.id * JOIN u.phonenumbers p * INDEX BY p.phonenumber - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -592,9 +591,8 @@ public function testMixedQueryFetchJoinCustomIndex($userEntityKey): void * FROM User u * JOIN u.phonenumbers p * JOIN u.articles a - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testMixedQueryMultipleFetchJoin($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -702,9 +700,8 @@ public function testMixedQueryMultipleFetchJoin($userEntityKey): void * JOIN u.phonenumbers p * JOIN u.articles a * LEFT JOIN a.comments c - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testMixedQueryMultipleDeepMixedFetchJoin($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -938,9 +935,8 @@ public function testEntityQueryCustomResultSetOrder(): void /** * SELECT PARTIAL u.{id,name} * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-644 */ + #[Group('DDC-644')] public function testSkipUnknownColumns(): void { $rsm = new ResultSetMapping(); @@ -968,9 +964,8 @@ public function testSkipUnknownColumns(): void /** * SELECT u.id, u.name * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] public function testScalarQueryWithoutResultVariables($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -1390,9 +1385,8 @@ public function testResultIterationWithAliasedUserEntity(): void * * SELECT PARTIAL u.{id, status}, PARTIAL g.{id, name}, PARTIAL p.{phonenumber} * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-809 */ + #[Group('DDC-809')] public function testManyToManyHydration(): void { $rsm = new ResultSetMapping(); @@ -1513,9 +1507,8 @@ public function testManyToManyHydration(): void * * SELECT PARTIAL u.{id, status} As user, PARTIAL g.{id, name}, PARTIAL p.{phonenumber} * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-809 */ + #[Group('DDC-809')] public function testManyToManyHydrationWithAliasedUserEntity(): void { $rsm = new ResultSetMapping(); @@ -1637,10 +1630,9 @@ public function testManyToManyHydrationWithAliasedUserEntity(): void /** * SELECT PARTIAL u.{id, status}, UPPER(u.name) as nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-1358 - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] + #[Group('DDC-1358')] public function testMissingIdForRootEntity($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -1696,10 +1688,9 @@ public function testMissingIdForRootEntity($userEntityKey): void * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) AS nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u * LEFT JOIN u.phonenumbers u - * - * @group DDC-1358 - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] + #[Group('DDC-1358')] public function testMissingIdForCollectionValuedChildEntity($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -1758,10 +1749,9 @@ public function testMissingIdForCollectionValuedChildEntity($userEntityKey): voi * SELECT PARTIAL u.{id, status}, PARTIAL a.{id, city}, UPPER(u.name) AS nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u * JOIN u.address a - * - * @group DDC-1358 - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] + #[Group('DDC-1358')] public function testMissingIdForSingleValuedChildEntity($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -1812,10 +1802,9 @@ public function testMissingIdForSingleValuedChildEntity($userEntityKey): void * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u * INDEX BY u.id - * - * @group DDC-1385 - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] + #[Group('DDC-1385')] public function testIndexByAndMixedResult($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -1856,10 +1845,9 @@ public function testIndexByAndMixedResult($userEntityKey): void /** * SELECT UPPER(u.name) AS nameUpper * FROM Doctrine\Tests\Models\CMS\CmsUser u - * - * @group DDC-1385 - * @dataProvider provideDataForUserEntityResult */ + #[DataProvider('provideDataForUserEntityResult')] + #[Group('DDC-1385')] public function testIndexByScalarsOnly($userEntityKey): void { $rsm = new ResultSetMapping(); @@ -1887,7 +1875,7 @@ public function testIndexByScalarsOnly($userEntityKey): void ); } - /** @group DDC-1470 */ + #[Group('DDC-1470')] public function testMissingMetaMappingException(): void { $this->expectException(HydrationException::class); @@ -1911,7 +1899,7 @@ public function testMissingMetaMappingException(): void $hydrator->hydrateAll($stmt, $rsm); } - /** @group DDC-1470 */ + #[Group('DDC-1470')] public function testMissingDiscriminatorColumnException(): void { $this->expectException(HydrationException::class); @@ -1942,7 +1930,7 @@ public function testMissingDiscriminatorColumnException(): void $hydrator->hydrateAll($stmt, $rsm); } - /** @group DDC-3076 */ + #[Group('DDC-3076')] public function testInvalidDiscriminatorValueException(): void { $this->expectException(HydrationException::class); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php index da8e2850705..0c20eab0866 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -11,6 +11,7 @@ use Doctrine\Tests\Models\Legacy\LegacyUser; use Doctrine\Tests\Models\Legacy\LegacyUserReference; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Description of ResultSetMappingTest @@ -63,10 +64,9 @@ public function testBasicResultSetMapping(): void } /** - * @group DDC-1057 - * * Fluent interface test, not a real result set mapping */ + #[Group('DDC-1057')] public function testFluentInterface(): void { $rms = $this->_rsm; @@ -91,7 +91,7 @@ public function testFluentInterface(): void self::assertTrue($rms->isMixedResult()); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testIndexByMetadataColumn(): void { $this->_rsm->addEntityResult(LegacyUser::class, 'u'); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php index fef42af6fb2..baa27f3bd08 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php @@ -7,6 +7,7 @@ use Doctrine\ORM\Internal\Hydration\ScalarHydrator; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\Models\CMS\CmsUser; +use PHPUnit\Framework\Attributes\Group; class ScalarHydratorTest extends HydrationTestCase { @@ -45,7 +46,7 @@ public function testNewHydrationSimpleEntityQuery(): void self::assertEquals(2, $result[1]['u_id']); } - /** @group DDC-407 */ + #[Group('DDC-407')] public function testHydrateScalarResults(): void { $rsm = new ResultSetMapping(); @@ -67,7 +68,7 @@ public function testHydrateScalarResults(): void self::assertCount(1, $hydrator->hydrateAll($stmt, $rsm)); } - /** @group DDC-644 */ + #[Group('DDC-644')] public function testSkipUnknownColumns(): void { $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php index 9078e52d929..59a667ab07e 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php @@ -18,10 +18,11 @@ use Doctrine\Tests\Models\Issue5989\Issue5989Employee; use Doctrine\Tests\Models\Issue5989\Issue5989Manager; use Doctrine\Tests\Models\Issue5989\Issue5989Person; +use PHPUnit\Framework\Attributes\Group; class SimpleObjectHydratorTest extends HydrationTestCase { - /** @group DDC-1470 */ + #[Group('DDC-1470')] public function testMissingDiscriminatorColumnException(): void { $this->expectException(HydrationException::class); @@ -68,7 +69,7 @@ public function testExtraFieldInResultSetShouldBeIgnore(): void self::assertEquals($result[0], $expectedEntity); } - /** @group DDC-3076 */ + #[Group('DDC-3076')] public function testInvalidDiscriminatorValueException(): void { $this->expectException(HydrationException::class); @@ -95,7 +96,7 @@ public function testInvalidDiscriminatorValueException(): void $hydrator->hydrateAll($stmt, $rsm); } - /** @group issue-5989 */ + #[Group('issue-5989')] public function testNullValueShouldNotOverwriteFieldWithSameNameInJoinedInheritance(): void { $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php index a8ab2ea819f..87d8edec9ac 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php @@ -9,6 +9,7 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\Models\CMS\CmsUser; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; class SingleScalarHydratorTest extends HydrationTestCase { @@ -47,11 +48,8 @@ public static function validResultSetProvider(): Generator ]; } - /** - * @param list> $resultSet - * - * @dataProvider validResultSetProvider - */ + /** @param list> $resultSet */ + #[DataProvider('validResultSetProvider')] public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array $resultSet, mixed $expectedResult): void { $rsm = new ResultSetMapping(); @@ -66,11 +64,8 @@ public function testHydrateSingleScalarFromFieldMappingWithValidResultSet(array $this->assertEquals($expectedResult, $result); } - /** - * @param list> $resultSet - * - * @dataProvider validResultSetProvider - */ + /** @param list> $resultSet */ + #[DataProvider('validResultSetProvider')] public function testHydrateSingleScalarFromScalarMappingWithValidResultSet(array $resultSet, mixed $expectedResult): void { $rsm = new ResultSetMapping(); @@ -135,11 +130,8 @@ public static function invalidResultSetProvider(): Generator ]; } - /** - * @param list> $resultSet - * - * @dataProvider invalidResultSetProvider - */ + /** @param list> $resultSet */ + #[DataProvider('invalidResultSetProvider')] public function testHydrateSingleScalarFromFieldMappingWithInvalidResultSet(array $resultSet): void { $rsm = new ResultSetMapping(); @@ -154,11 +146,8 @@ public function testHydrateSingleScalarFromFieldMappingWithInvalidResultSet(arra $hydrator->hydrateAll($stmt, $rsm); } - /** - * @param list> $resultSet - * - * @dataProvider invalidResultSetProvider - */ + /** @param list> $resultSet */ + #[DataProvider('invalidResultSetProvider')] public function testHydrateSingleScalarFromScalarMappingWithInvalidResultSet(array $resultSet): void { $rsm = new ResultSetMapping(); diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php index 4e838da0eaf..09755b2595d 100644 --- a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * AssignedGeneratorTest @@ -27,7 +28,7 @@ protected function setUp(): void $this->assignedGen = new AssignedGenerator(); } - /** @dataProvider entitiesWithoutId */ + #[DataProvider('entitiesWithoutId')] public function testThrowsExceptionIfIdNotAssigned($entity): void { $this->expectException(ORMException::class); diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index 08476ff6677..5275d980a54 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -10,6 +10,8 @@ use Doctrine\ORM\Internal\HydrationCompleteHandler; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Persistence\Event\LifecycleEventArgs; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use stdClass; @@ -19,9 +21,8 @@ /** * Tests for {@see \Doctrine\ORM\Internal\HydrationCompleteHandler} - * - * @covers \Doctrine\ORM\Internal\HydrationCompleteHandler */ +#[CoversClass(HydrationCompleteHandler::class)] class HydrationCompleteHandlerTest extends TestCase { private ListenersInvoker&MockObject $listenersInvoker; @@ -35,7 +36,7 @@ protected function setUp(): void $this->handler = new HydrationCompleteHandler($this->listenersInvoker, $this->entityManager); } - /** @dataProvider invocationFlagProvider */ + #[DataProvider('invocationFlagProvider')] public function testDefersPostLoadOfEntity(int $listenersFlag): void { $metadata = $this->createMock(ClassMetadata::class); @@ -67,7 +68,7 @@ public function testDefersPostLoadOfEntity(int $listenersFlag): void $this->handler->hydrationComplete(); } - /** @dataProvider invocationFlagProvider */ + #[DataProvider('invocationFlagProvider')] public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void { $metadata = $this->createMock(ClassMetadata::class); @@ -89,7 +90,7 @@ public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void $this->handler->hydrationComplete(); } - /** @dataProvider invocationFlagProvider */ + #[DataProvider('invocationFlagProvider')] public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void { $metadata1 = $this->createMock(ClassMetadata::class); diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 4b553e7f2ae..4a974972328 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -8,11 +8,12 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\LazyCriteriaCollection; use Doctrine\ORM\Persisters\Entity\EntityPersister; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use stdClass; -/** @covers \Doctrine\ORM\LazyCriteriaCollection */ +#[CoversClass(LazyCriteriaCollection::class)] class LazyCriteriaCollectionTest extends TestCase { private EntityPersister&MockObject $persister; diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index e76aff61948..8b8c813a537 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -13,11 +13,10 @@ use Doctrine\Tests\Models\DDC117\DDC117Article; use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; -/** - * @group DDC-1845 - * @group DDC-2459 - */ +#[Group('DDC-1845')] +#[Group('DDC-2459')] class AnsiQuoteStrategyTest extends OrmTestCase { private AnsiQuoteStrategy $strategy; diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 31d25091e99..88baac0df93 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -32,6 +32,8 @@ use Doctrine\Tests\Models\DDC869\DDC869PaymentRepository; use Doctrine\Tests\OrmTestCase; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function assert; use function serialize; @@ -87,7 +89,7 @@ public function testGetMetadataForSubclassWithMappedSuperclass(): void self::assertArrayHasKey('mappedRelated1', $class->associationMappings); } - /** @group DDC-869 */ + #[Group('DDC-869')] public function testGetMetadataForSubclassWithMappedSuperclassWithRepository(): void { $class = $this->cmf->getMetadataFor(DDC869CreditCardPayment::class); @@ -112,7 +114,7 @@ public function testGetMetadataForSubclassWithMappedSuperclassWithRepository(): self::assertEquals($class->customRepositoryClassName, EntityRepository::class); } - /** @group DDC-388 */ + #[Group('DDC-388')] public function testSerializationWithPrivateFieldsFromMappedSuperclass(): void { $class = $this->cmf->getMetadataFor(EntitySubClass2::class); @@ -125,7 +127,7 @@ public function testSerializationWithPrivateFieldsFromMappedSuperclass(): void self::assertArrayHasKey('mappedRelated1', $class2->reflFields); } - /** @group DDC-1203 */ + #[Group('DDC-1203')] public function testUnmappedSuperclassInHierarchy(): void { $class = $this->cmf->getMetadataFor(HierarchyD::class); @@ -135,7 +137,7 @@ public function testUnmappedSuperclassInHierarchy(): void self::assertArrayHasKey('d', $class->fieldMappings); } - /** @group DDC-1204 */ + #[Group('DDC-1204')] public function testUnmappedEntityInHierarchy(): void { $this->expectException(MappingException::class); @@ -149,10 +151,8 @@ public function testUnmappedEntityInHierarchy(): void $this->cmf->getMetadataFor(HierarchyE::class); } - /** - * @group DDC-1204 - * @group DDC-1203 - */ + #[Group('DDC-1204')] + #[Group('DDC-1203')] public function testMappedSuperclassWithId(): void { $class = $this->cmf->getMetadataFor(SuperclassEntity::class); @@ -160,10 +160,8 @@ public function testMappedSuperclassWithId(): void self::assertArrayHasKey('id', $class->fieldMappings); } - /** - * @group DDC-1156 - * @group DDC-1218 - */ + #[Group('DDC-1156')] + #[Group('DDC-1218')] public function testGeneratedValueFromMappedSuperclass(): void { $class = $this->cmf->getMetadataFor(SuperclassEntity::class); @@ -176,10 +174,8 @@ public function testGeneratedValueFromMappedSuperclass(): void ); } - /** - * @group DDC-1156 - * @group DDC-1218 - */ + #[Group('DDC-1156')] + #[Group('DDC-1218')] public function testSequenceDefinitionInHierarchyWithSandwichMappedSuperclass(): void { $class = $this->cmf->getMetadataFor(HierarchyD::class); @@ -192,10 +188,8 @@ public function testSequenceDefinitionInHierarchyWithSandwichMappedSuperclass(): ); } - /** - * @group DDC-1156 - * @group DDC-1218 - */ + #[Group('DDC-1156')] + #[Group('DDC-1218')] public function testMultipleMappedSuperclasses(): void { $class = $this->cmf->getMetadataFor(MediumSuperclassEntity::class); @@ -210,9 +204,8 @@ public function testMultipleMappedSuperclasses(): void /** * Ensure indexes are inherited from the mapped superclass. - * - * @group DDC-3418 */ + #[Group('DDC-3418')] public function testMappedSuperclassIndex(): void { $class = $this->cmf->getMetadataFor(EntityIndexSubClass::class); @@ -224,7 +217,7 @@ public function testMappedSuperclassIndex(): void self::assertArrayHasKey('IDX_MAPPED2_INDEX', $class->table['indexes']); } - /** @dataProvider invalidHierarchyDeclarationClasses */ + #[DataProvider('invalidHierarchyDeclarationClasses')] public function testUndeclaredHierarchyRejection(string $rootEntity, string $childClass): void { $this->expectException(MappingException::class); @@ -255,7 +248,7 @@ public static function invalidHierarchyDeclarationClasses(): Generator => [InvalidComplexRoot::class, InvalidComplexEntity::class]; } - /** @group DDC-964 */ + #[Group('DDC-964')] public function testInvalidOverrideFieldInheritedFromEntity(): void { $cm = $this->cmf->getMetadataFor(CompanyFixContract::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index d55e3827044..da29bd5c897 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -14,8 +14,9 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\ValueObjects\Name; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-659 */ +#[Group('DDC-659')] class ClassMetadataBuilderTest extends OrmTestCase { private ClassMetadata $cm; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 883d4921703..785b6080dad 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -153,7 +153,7 @@ public function testGetMetadataForThrowsExceptionOnMissingCustomGeneratorDefinit $actual = $cmf->getMetadataFor($cm1->name); } - /** @group DDC-1512 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-1512')] public function testIsTransient(): void { $cmf = new ClassMetadataFactory(); @@ -286,7 +286,7 @@ protected function createValidClassMetadata(): ClassMetadata return $cm1; } - /** @group DDC-1845 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-1845')] public function testQuoteMetadata(): void { $cmf = new ClassMetadataFactory(); @@ -356,11 +356,9 @@ public function testQuoteMetadata(): void self::assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); } - /** - * @group DDC-3385 - * @group 1181 - * @group 385 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-3385')] + #[\PHPUnit\Framework\Attributes\Group('1181')] + #[\PHPUnit\Framework\Attributes\Group('385')] public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMetadata(): void { $metadata = $this->createMock(ClassMetadata::class); @@ -397,7 +395,7 @@ public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args): self::assertSame($metadata, $cmf->getMetadataFor('Foo')); } - /** @group DDC-3427 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-3427')] public function testAcceptsEntityManagerInterfaceInstances(): void { $classMetadataFactory = new ClassMetadataFactory(); @@ -411,7 +409,7 @@ public function testAcceptsEntityManagerInterfaceInstances(): void self::assertSame($entityManager, $property->getValue($classMetadataFactory)); } - /** @group DDC-4006 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-4006')] public function testInheritsIdGeneratorMappingFromEmbeddable(): void { $cmf = new ClassMetadataFactory(); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index d4fc5afc5e3..294ac3d53b7 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -12,11 +12,12 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Table; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use ReflectionProperty; class ClassMetadataLoadEventTest extends OrmTestCase { - /** @group DDC-1610 */ + #[Group('DDC-1610')] public function testEvent(): void { $em = $this->getTestEntityManager(); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 472459b838f..cf3261fe4c5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -42,6 +42,8 @@ use Doctrine\Tests\ORM\Mapping\TypedFieldMapper\CustomIntAsStringTypedFieldMapper; use Doctrine\Tests\OrmTestCase; use DoctrineGlobalArticle; +use PHPUnit\Framework\Attributes\Group as TestGroup; +use PHPUnit\Framework\Attributes\RequiresPhp; use ReflectionClass; use stdClass; @@ -182,7 +184,7 @@ public function testFieldTypeFromReflection(): void self::assertEquals('float', $cm->getTypeOfField('float')); } - /** @group GH10313 */ + #[TestGroup('GH10313')] public function testFieldTypeFromReflectionDefaultTypedFieldMapper(): void { $cm = new ClassMetadata( @@ -203,7 +205,7 @@ public function testFieldTypeFromReflectionDefaultTypedFieldMapper(): void self::assertEquals(CustomIntType::class, $cm->getTypeOfField('customIntTypedField')); } - /** @group GH10313 */ + #[TestGroup('GH10313')] public function testFieldTypeFromReflectionChainTypedFieldMapper(): void { $cm = new ClassMetadata( @@ -222,7 +224,7 @@ public function testFieldTypeFromReflectionChainTypedFieldMapper(): void self::assertEquals(Types::STRING, $cm->getTypeOfField('username')); } - /** @group DDC-115 */ + #[TestGroup('DDC-115')] public function testMapAssociationInGlobalNamespace(): void { require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; @@ -284,7 +286,7 @@ public function testSerializeManyToManyJoinTableCascade(): void self::assertTrue($assoc['isOnDeleteCascade']); } - /** @group DDC-115 */ + #[TestGroup('DDC-115')] public function testSetDiscriminatorMapInGlobalNamespace(): void { require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; @@ -297,7 +299,7 @@ public function testSetDiscriminatorMapInGlobalNamespace(): void self::assertEquals('DoctrineGlobalUser', $cm->discriminatorMap['foo']); } - /** @group DDC-115 */ + #[TestGroup('DDC-115')] public function testSetSubClassesInGlobalNamespace(): void { require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; @@ -309,7 +311,7 @@ public function testSetSubClassesInGlobalNamespace(): void self::assertEquals('DoctrineGlobalArticle', $cm->subClasses[0]); } - /** @group DDC-268 */ + #[TestGroup('DDC-268')] public function testSetInvalidVersionMappingThrowsException(): void { $field = []; @@ -410,7 +412,7 @@ public function testDuplicateFieldAndAssociationMapping2ThrowsException(): void $cm->mapField(['fieldName' => 'name', 'columnName' => 'name']); } - /** @group DDC-1224 */ + #[TestGroup('DDC-1224')] public function testGetTemporaryTableNameSchema(): void { $cm = new ClassMetadata(CmsUser::class); @@ -484,7 +486,7 @@ public function testDefaultJoinColumnName(): void self::assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); } - /** @group DDC-559 */ + #[TestGroup('DDC-559')] public function testUnderscoreNamingStrategyDefaults(): void { $namingStrategy = new UnderscoreNamingStrategy(CASE_UPPER); @@ -529,7 +531,7 @@ public function testUnderscoreNamingStrategyDefaults(): void self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); } - /** @group DDC-886 */ + #[TestGroup('DDC-886')] public function testSetMultipleIdentifierSetsComposite(): void { $cm = new ClassMetadata(CmsUser::class); @@ -542,7 +544,7 @@ public function testSetMultipleIdentifierSetsComposite(): void self::assertTrue($cm->isIdentifierComposite); } - /** @group DDC-944 */ + #[TestGroup('DDC-944')] public function testMappingNotFound(): void { $cm = new ClassMetadata(CmsUser::class); @@ -554,7 +556,7 @@ public function testMappingNotFound(): void $cm->getFieldMapping('foo'); } - /** @group DDC-961 */ + #[TestGroup('DDC-961')] public function testJoinTableMappingDefaults(): void { $cm = new ClassMetadata('DoctrineGlobalArticle'); @@ -565,7 +567,7 @@ public function testJoinTableMappingDefaults(): void self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']['joinTable']['name']); } - /** @group DDC-117 */ + #[TestGroup('DDC-117')] public function testMapIdentifierAssociation(): void { $cm = new ClassMetadata(DDC117ArticleDetails::class); @@ -584,7 +586,7 @@ public function testMapIdentifierAssociation(): void self::assertEquals(['article'], $cm->identifier); } - /** @group DDC-117 */ + #[TestGroup('DDC-117')] public function testOrphanRemovalIdentifierAssociation(): void { $cm = new ClassMetadata(DDC117ArticleDetails::class); @@ -604,7 +606,7 @@ public function testOrphanRemovalIdentifierAssociation(): void ); } - /** @group DDC-117 */ + #[TestGroup('DDC-117')] public function testInverseIdentifierAssociation(): void { $cm = new ClassMetadata(DDC117ArticleDetails::class); @@ -624,7 +626,7 @@ public function testInverseIdentifierAssociation(): void ); } - /** @group DDC-117 */ + #[TestGroup('DDC-117')] public function testIdentifierAssociationManyToMany(): void { $cm = new ClassMetadata(DDC117ArticleDetails::class); @@ -643,7 +645,7 @@ public function testIdentifierAssociationManyToMany(): void ); } - /** @group DDC-996 */ + #[TestGroup('DDC-996')] public function testEmptyFieldNameThrowsException(): void { $this->expectException(MappingException::class); @@ -655,7 +657,7 @@ public function testEmptyFieldNameThrowsException(): void $cm->mapField(['fieldName' => '']); } - /** @group DDC-2451 */ + #[TestGroup('DDC-2451')] public function testSerializeEntityListeners(): void { $metadata = new ClassMetadata(CompanyContract::class); @@ -670,7 +672,7 @@ public function testSerializeEntityListeners(): void self::assertEquals($metadata->entityListeners, $unserialize->entityListeners); } - /** @group DDC-1068 */ + #[TestGroup('DDC-1068')] public function testClassCaseSensitivity(): void { $user = new CmsUser(); @@ -680,7 +682,7 @@ public function testClassCaseSensitivity(): void self::assertEquals(CmsUser::class, $cm->name); } - /** @group DDC-659 */ + #[TestGroup('DDC-659')] public function testLifecycleCallbackNotFound(): void { $cm = new ClassMetadata(CmsUser::class); @@ -693,7 +695,7 @@ public function testLifecycleCallbackNotFound(): void $cm->validateLifecycleCallbacks(new RuntimeReflectionService()); } - /** @group ImproveErrorMessages */ + #[TestGroup('ImproveErrorMessages')] public function testTargetEntityNotFound(): void { $cm = new ClassMetadata(CmsUser::class); @@ -715,11 +717,9 @@ public function testNameIsMandatoryForDiscriminatorColumnsMappingException(): vo $cm->setDiscriminatorColumn([]); } - /** - * @group DDC-984 - * @group DDC-559 - * @group DDC-1575 - */ + #[TestGroup('DDC-984')] + #[TestGroup('DDC-559')] + #[TestGroup('DDC-1575')] public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void { $namingStrategy = new MyNamespacedNamingStrategy(); @@ -750,10 +750,8 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void self::assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']['joinTable']['name']); } - /** - * @group DDC-984 - * @group DDC-559 - */ + #[TestGroup('DDC-984')] + #[TestGroup('DDC-559')] public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategyPropertyToColumnName(): void { $namingStrategy = new MyPrefixNamingStrategy(); @@ -770,7 +768,7 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategyProperty ]); } - /** @group DDC-1746 */ + #[TestGroup('DDC-1746')] public function testInvalidCascade(): void { $cm = new ClassMetadata(CmsUser::class); @@ -782,10 +780,8 @@ public function testInvalidCascade(): void $cm->mapManyToOne(['fieldName' => 'address', 'targetEntity' => 'UnknownClass', 'cascade' => ['invalid']]); } - /** - * @requires PHP 8.1 - * @group DDC-964 - */ + #[RequiresPhp('8.1')] + #[TestGroup('DDC-964')] public function testInvalidPropertyAssociationOverrideNameException(): void { $this->expectException(MappingException::class); @@ -797,10 +793,8 @@ public function testInvalidPropertyAssociationOverrideNameException(): void $cm->setAssociationOverride('invalidPropertyName', []); } - /** - * @requires PHP 8.1 - * @group DDC-964 - */ + #[RequiresPhp('8.1')] + #[TestGroup('DDC-964')] public function testInvalidPropertyAttributeOverrideNameException(): void { $this->expectException(MappingException::class); @@ -812,10 +806,8 @@ public function testInvalidPropertyAttributeOverrideNameException(): void $cm->setAttributeOverride('invalidPropertyName', []); } - /** - * @requires PHP 8.1 - * @group DDC-964 - */ + #[RequiresPhp('8.1')] + #[TestGroup('DDC-964')] public function testInvalidOverrideAttributeFieldTypeException(): void { $this->expectException(MappingException::class); @@ -827,7 +819,7 @@ public function testInvalidOverrideAttributeFieldTypeException(): void $cm->setAttributeOverride('name', ['type' => 'date']); } - /** @group DDC-1955 */ + #[TestGroup('DDC-1955')] public function testInvalidEntityListenerClassException(): void { $this->expectException(MappingException::class); @@ -838,7 +830,7 @@ public function testInvalidEntityListenerClassException(): void $cm->addEntityListener(Events::postLoad, '\InvalidClassName', 'postLoadHandler'); } - /** @group DDC-1955 */ + #[TestGroup('DDC-1955')] public function testInvalidEntityListenerMethodException(): void { $this->expectException(MappingException::class); @@ -873,7 +865,7 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void self::assertEquals(['customtypeparent_target' => 'id'], $cm->associationMappings['friendsWithMe']['relationToTargetKeyColumns']); } - /** @group DDC-2608 */ + #[TestGroup('DDC-2608')] public function testSetSequenceGeneratorThrowsExceptionWhenSequenceNameIsMissing(): void { $cm = new ClassMetadata(CmsUser::class); @@ -883,10 +875,8 @@ public function testSetSequenceGeneratorThrowsExceptionWhenSequenceNameIsMissing $cm->setSequenceGeneratorDefinition([]); } - /** - * @group DDC-2662 - * @group 6682 - */ + #[TestGroup('DDC-2662')] + #[TestGroup('6682')] public function testQuotedSequenceName(): void { $cm = new ClassMetadata(CmsUser::class); @@ -900,7 +890,7 @@ public function testQuotedSequenceName(): void ); } - /** @group DDC-2700 */ + #[TestGroup('DDC-2700')] public function testIsIdentifierMappedSuperClass(): void { $class = new ClassMetadata(DDC2700MappedSuperClass::class); @@ -908,7 +898,7 @@ public function testIsIdentifierMappedSuperClass(): void self::assertFalse($class->isIdentifier('foo')); } - /** @group DDC-3120 */ + #[TestGroup('DDC-3120')] public function testCanInstantiateInternalPhpClassSubclass(): void { $classMetadata = new ClassMetadata(MyArrayObjectEntity::class); @@ -916,7 +906,7 @@ public function testCanInstantiateInternalPhpClassSubclass(): void self::assertInstanceOf(MyArrayObjectEntity::class, $classMetadata->newInstance()); } - /** @group DDC-3120 */ + #[TestGroup('DDC-3120')] public function testCanInstantiateInternalPhpClassSubclassFromUnserializedMetadata(): void { $classMetadata = unserialize(serialize(new ClassMetadata(MyArrayObjectEntity::class))); @@ -965,7 +955,7 @@ public function testGetColumnNamesWithGivenFieldNames(): void self::assertSame(['foo', 'baz'], $metadata->getColumnNames(['status', 'name'])); } - /** @group DDC-6460 */ + #[TestGroup('DDC-6460')] public function testInlineEmbeddable(): void { $classMetadata = new ClassMetadata(TestEntity1::class); @@ -981,7 +971,7 @@ public function testInlineEmbeddable(): void self::assertTrue($classMetadata->hasField('test')); } - /** @group DDC-3305 */ + #[TestGroup('DDC-3305')] public function testRejectsEmbeddableWithoutValidClassName(): void { $metadata = new ClassMetadata(TestEntity1::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php index ff40bf05f58..949e668154e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping\DefaultQuoteStrategy; use Doctrine\Tests\Models\NonPublicSchemaJoins\User as NonPublicSchemaUser; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use function assert; @@ -16,10 +17,8 @@ */ class DefaultQuoteStrategyTest extends OrmTestCase { - /** - * @group DDC-3590 - * @group 1316 - */ + #[Group('DDC-3590')] + #[Group('DDC-1316')] public function testGetJoinTableName(): void { $em = $this->getTestEntityManager(); diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index b174a3e45d7..83be2f0368d 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -8,8 +8,9 @@ use Doctrine\Tests\Models\Company\CompanyContractListener; use Doctrine\Tests\Models\Company\CompanyFlexUltraContractListener; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1955 */ +#[Group('DDC-1955')] class EntityListenerResolverTest extends OrmTestCase { private DefaultEntityListenerResolver $resolver; diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index f706c70b792..e7a47d72455 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -62,6 +62,8 @@ use Doctrine\Tests\Models\Upsertable\Insertable; use Doctrine\Tests\Models\Upsertable\Updatable; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\RequiresPhp; use stdClass; use function assert; @@ -111,7 +113,7 @@ public function testEntityTableNameAndInheritance(): ClassMetadata return $class; } - /** @depends testEntityTableNameAndInheritance */ + #[Depends('testEntityTableNameAndInheritance')] public function testEntityIndexes(ClassMetadata $class): ClassMetadata { self::assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.'); @@ -149,7 +151,7 @@ public function testEntityIndexFlagsAndPartialIndexes(): void ); } - /** @depends testEntityTableNameAndInheritance */ + #[Depends('testEntityTableNameAndInheritance')] public function testEntityUniqueConstraints(ClassMetadata $class): ClassMetadata { self::assertArrayHasKey( @@ -175,7 +177,7 @@ public function testEntityIncorrectUniqueContraint(): void $this->createClassMetadata(UserIncorrectUniqueConstraint::class); } - /** @depends testEntityTableNameAndInheritance */ + #[Depends('testEntityTableNameAndInheritance')] public function testEntityOptions(ClassMetadata $class): ClassMetadata { self::assertArrayHasKey('options', $class->table, 'ClassMetadata should have options key in table property.'); @@ -191,7 +193,7 @@ public function testEntityOptions(ClassMetadata $class): ClassMetadata return $class; } - /** @depends testEntityOptions */ + #[Depends('testEntityOptions')] public function testEntitySequence(ClassMetadata $class): void { self::assertIsArray($class->sequenceGeneratorDefinition, 'No Sequence Definition set on this driver.'); @@ -221,7 +223,7 @@ public function testEntityCustomGenerator(): void ); } - /** @depends testEntityTableNameAndInheritance */ + #[Depends('testEntityTableNameAndInheritance')] public function testFieldMappings(ClassMetadata $class): ClassMetadata { self::assertEquals(4, count($class->fieldMappings)); @@ -233,7 +235,7 @@ public function testFieldMappings(ClassMetadata $class): ClassMetadata return $class; } - /** @depends testFieldMappings */ + #[Depends('testFieldMappings')] public function testVersionedField(ClassMetadata $class): void { self::assertTrue($class->isVersioned); @@ -242,7 +244,7 @@ public function testVersionedField(ClassMetadata $class): void self::assertFalse(isset($class->fieldMappings['version']['version'])); } - /** @depends testEntityTableNameAndInheritance */ + #[Depends('testEntityTableNameAndInheritance')] public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadata { self::assertEquals('id', $class->fieldMappings['id']['columnName']); @@ -252,7 +254,7 @@ public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadat return $class; } - /** @depends testEntityTableNameAndInheritance */ + #[Depends('testEntityTableNameAndInheritance')] public function testStringFieldMappings(ClassMetadata $class): ClassMetadata { self::assertEquals('string', $class->fieldMappings['name']['type']); @@ -281,7 +283,7 @@ public function testFieldTypeFromReflection(): void self::assertEquals(Contact::class, $class->embeddedClasses['contact']['class']); } - /** @group GH10313 */ + #[\PHPUnit\Framework\Attributes\Group('GH10313')] public function testCustomFieldTypeFromReflection(): void { $class = $this->createClassMetadata( @@ -299,7 +301,7 @@ public function testCustomFieldTypeFromReflection(): void self::assertEquals(CustomIntType::class, $class->getTypeOfField('customIntTypedField')); } - /** @depends testEntityTableNameAndInheritance */ + #[Depends('testEntityTableNameAndInheritance')] public function testFieldOptions(ClassMetadata $class): ClassMetadata { $expected = ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false]; @@ -308,7 +310,7 @@ public function testFieldOptions(ClassMetadata $class): ClassMetadata return $class; } - /** @depends testEntityTableNameAndInheritance */ + #[Depends('testEntityTableNameAndInheritance')] public function testIdFieldOptions(ClassMetadata $class): ClassMetadata { self::assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']['options']); @@ -316,7 +318,7 @@ public function testIdFieldOptions(ClassMetadata $class): ClassMetadata return $class; } - /** @depends testFieldMappings */ + #[Depends('testFieldMappings')] public function testIdentifier(ClassMetadata $class): ClassMetadata { self::assertEquals(['id'], $class->identifier); @@ -326,7 +328,7 @@ public function testIdentifier(ClassMetadata $class): ClassMetadata return $class; } - /** @group #6129 */ + #[\PHPUnit\Framework\Attributes\Group('#6129')] public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata { $class = $this->createClassMetadata(User::class); @@ -340,7 +342,7 @@ public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata return $class; } - /** @depends testIdentifier */ + #[Depends('testIdentifier')] public function testAssociations(ClassMetadata $class): ClassMetadata { self::assertEquals(3, count($class->associationMappings)); @@ -348,7 +350,7 @@ public function testAssociations(ClassMetadata $class): ClassMetadata return $class; } - /** @depends testAssociations */ + #[Depends('testAssociations')] public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['address'])); @@ -364,7 +366,7 @@ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetada return $class; } - /** @depends testOwningOneToOneAssociation */ + #[Depends('testOwningOneToOneAssociation')] public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['phonenumbers'])); @@ -382,7 +384,7 @@ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMeta return $class; } - /** @depends testInverseOneToManyAssociation */ + #[Depends('testInverseOneToManyAssociation')] public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['groups'])); @@ -399,7 +401,7 @@ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): C return $class; } - /** @depends testManyToManyAssociationWithCascadeAll */ + #[Depends('testManyToManyAssociationWithCascadeAll')] public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata { self::assertCount(2, $class->lifecycleCallbacks); @@ -409,7 +411,7 @@ public function testLifecycleCallbacks(ClassMetadata $class): ClassMetadata return $class; } - /** @depends testManyToManyAssociationWithCascadeAll */ + #[Depends('testManyToManyAssociationWithCascadeAll')] public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $class): ClassMetadata { self::assertCount(2, $class->lifecycleCallbacks['prePersist']); @@ -418,7 +420,7 @@ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $ return $class; } - /** @depends testLifecycleCallbacksSupportMultipleMethodNames */ + #[Depends('testLifecycleCallbacksSupportMultipleMethodNames')] public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMetadata { // Non-Nullability of Join Column @@ -428,7 +430,7 @@ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMeta return $class; } - /** @depends testJoinColumnUniqueAndNullable */ + #[Depends('testJoinColumnUniqueAndNullable')] public function testColumnDefinition(ClassMetadata $class): ClassMetadata { self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); @@ -437,7 +439,7 @@ public function testColumnDefinition(ClassMetadata $class): ClassMetadata return $class; } - /** @depends testColumnDefinition */ + #[Depends('testColumnDefinition')] public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata { self::assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); @@ -445,7 +447,7 @@ public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata return $class; } - /** @group DDC-514 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-514')] public function testDiscriminatorColumnDefaults(): void { if (str_contains(static::class, 'PHPMappingDriver')) { @@ -460,7 +462,7 @@ public function testDiscriminatorColumnDefaults(): void ); } - /** @group DDC-869 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-869')] public function testMappedSuperclassWithRepository(): void { $em = $this->getTestEntityManager(); @@ -485,7 +487,7 @@ public function testMappedSuperclassWithRepository(): void self::assertTrue($em->getRepository(DDC869ChequePayment::class)->isTrue()); } - /** @group DDC-1476 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-1476')] public function testDefaultFieldType(): void { $factory = $this->createClassMetadataFactory(); @@ -515,7 +517,7 @@ public function testDefaultFieldType(): void self::assertEquals(ClassMetadata::GENERATOR_TYPE_NONE, $class->generatorType); } - /** @group DDC-1170 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-1170')] public function testIdentifierColumnDefinition(): void { $class = $this->createClassMetadata(DDC1170Entity::class); @@ -530,7 +532,7 @@ public function testIdentifierColumnDefinition(): void self::assertEquals('varchar(255) not null', strtolower($class->fieldMappings['value']['columnDefinition'])); } - /** @group DDC-559 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-559')] public function testNamingStrategy(): void { $em = $this->getTestEntityManager(); @@ -547,10 +549,8 @@ public function testNamingStrategy(): void self::assertEquals('DDC1476_ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); } - /** - * @group DDC-807 - * @group DDC-553 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-807')] + #[\PHPUnit\Framework\Attributes\Group('DDC-553')] public function testDiscriminatorColumnDefinition(): void { $class = $this->createClassMetadata(DDC807Entity::class); @@ -562,7 +562,7 @@ public function testDiscriminatorColumnDefinition(): void self::assertEquals('dtype', $class->discriminatorColumn['name']); } - /** @group GH10288 */ + #[\PHPUnit\Framework\Attributes\Group('GH10288')] public function testDiscriminatorColumnEnumTypeDefinition(): void { $class = $this->createClassMetadata(GH10288EnumTypePerson::class); @@ -574,7 +574,7 @@ public function testDiscriminatorColumnEnumTypeDefinition(): void self::assertEquals('discr', $class->discriminatorColumn['name']); } - /** @group DDC-889 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-889')] public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses(): void { $this->expectException(MappingException::class); @@ -583,7 +583,7 @@ public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses(): $this->createClassMetadata(DDC889Class::class); } - /** @group DDC-889 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-889')] public function testIdentifierRequiredShouldMentionParentClasses(): void { $factory = $this->createClassMetadataFactory(); @@ -594,10 +594,34 @@ public function testIdentifierRequiredShouldMentionParentClasses(): void $factory->getMetadataFor(DDC889Entity::class); } - /** - * @requires PHP 8.1 - * @group DDC-964 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-3579')] + #[RequiresPhp('8.1')] + public function testInversedByOverrideMapping(): void + { + $factory = $this->createClassMetadataFactory(); + $adminMetadata = $factory->getMetadataFor(DDC3579Admin::class); + + // assert groups association mappings + self::assertArrayHasKey('groups', $adminMetadata->associationMappings); + $adminGroups = $adminMetadata->associationMappings['groups']; + + // assert override + self::assertEquals('admins', $adminGroups['inversedBy']); + } + + #[\PHPUnit\Framework\Attributes\Group('DDC-5934')] + #[RequiresPhp('8.1')] + public function testFetchOverrideMapping(): void + { + // check override metadata + $contractMetadata = $this->createClassMetadataFactory()->getMetadataFor(DDC5934Contract::class); + + self::assertArrayHasKey('members', $contractMetadata->associationMappings); + self::assertSame(ClassMetadata::FETCH_EXTRA_LAZY, $contractMetadata->associationMappings['members']['fetch']); + } + + #[\PHPUnit\Framework\Attributes\Group('DDC-964')] + #[RequiresPhp('8.1')] public function testAssociationOverridesMapping(): void { $factory = $this->createClassMetadataFactory(); @@ -624,7 +648,7 @@ public function testAssociationOverridesMapping(): void self::assertEquals($guestGroups['isCascadeMerge'], $adminGroups['isCascadeMerge']); self::assertEquals($guestGroups['isCascadeDetach'], $adminGroups['isCascadeDetach']); - // assert not override attributes + // assert not override attributes self::assertEquals('ddc964_users_groups', $guestGroups['joinTable']['name']); self::assertEquals('user_id', $guestGroups['joinTable']['joinColumns'][0]['name']); self::assertEquals('group_id', $guestGroups['joinTable']['inverseJoinColumns'][0]['name']); @@ -673,40 +697,8 @@ public function testAssociationOverridesMapping(): void self::assertEquals(['id' => 'adminaddress_id'], $adminAddress['targetToSourceKeyColumns']); } - /** - * @requires PHP 8.1 - * @group DDC-3579 - */ - public function testInversedByOverrideMapping(): void - { - $factory = $this->createClassMetadataFactory(); - $adminMetadata = $factory->getMetadataFor(DDC3579Admin::class); - - // assert groups association mappings - self::assertArrayHasKey('groups', $adminMetadata->associationMappings); - $adminGroups = $adminMetadata->associationMappings['groups']; - - // assert override - self::assertEquals('admins', $adminGroups['inversedBy']); - } - - /** - * @requires PHP 8.1 - * @group DDC-5934 - */ - public function testFetchOverrideMapping(): void - { - // check override metadata - $contractMetadata = $this->createClassMetadataFactory()->getMetadataFor(DDC5934Contract::class); - - self::assertArrayHasKey('members', $contractMetadata->associationMappings); - self::assertSame(ClassMetadata::FETCH_EXTRA_LAZY, $contractMetadata->associationMappings['members']['fetch']); - } - - /** - * @requires PHP 8.1 - * @group DDC-964 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-964')] + #[RequiresPhp('8.1')] public function testAttributeOverridesMapping(): void { $factory = $this->createClassMetadataFactory(); @@ -740,7 +732,7 @@ public function testAttributeOverridesMapping(): void self::assertTrue($guestMetadata->fieldMappings['name']['unique']); } - /** @group DDC-1955 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-1955')] public function testEntityListeners(): void { $em = $this->getTestEntityManager(); @@ -769,7 +761,7 @@ public function testEntityListeners(): void self::assertEquals($flexClass->entityListeners, $superClass->entityListeners); } - /** @group DDC-1955 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-1955')] public function testEntityListenersOverride(): void { $em = $this->getTestEntityManager(); @@ -800,7 +792,7 @@ public function testEntityListenersOverride(): void self::assertEquals('prePersistHandler2', $prePersist['method']); } - /** @group DDC-1955 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-1955')] public function testEntityListenersNamingConvention(): void { $em = $this->getTestEntityManager(); @@ -853,7 +845,7 @@ public function testEntityListenersNamingConvention(): void self::assertEquals(Events::preFlush, $preFlush['method']); } - /** @group DDC-2183 */ + #[\PHPUnit\Framework\Attributes\Group('DDC-2183')] public function testSecondLevelCacheMapping(): void { $em = $this->getTestEntityManager(); @@ -879,10 +871,8 @@ public function testSecondLevelCacheMapping(): void self::assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']['cache']['region']); } - /** - * @group DDC-2825 - * @group 881 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-2825')] + #[\PHPUnit\Framework\Attributes\Group('881')] public function testSchemaDefinitionViaExplicitTableSchemaAttributeProperty(): void { $metadata = $this->createClassMetadataFactory()->getMetadataFor(ExplicitSchemaAndTable::class); @@ -892,10 +882,8 @@ public function testSchemaDefinitionViaExplicitTableSchemaAttributeProperty(): v self::assertSame('explicit_table', $metadata->getTableName()); } - /** - * @group DDC-2825 - * @group 881 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-2825')] + #[\PHPUnit\Framework\Attributes\Group('881')] public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAttributeProperty(): void { $metadata = $this->createClassMetadataFactory()->getMetadataFor(SchemaAndTableInTableName::class); @@ -905,10 +893,8 @@ public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAttributeP self::assertSame('implicit_table', $metadata->getTableName()); } - /** - * @group DDC-514 - * @group DDC-1015 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-514')] + #[\PHPUnit\Framework\Attributes\Group('DDC-1015')] public function testDiscriminatorColumnDefaultLength(): void { if (str_contains(static::class, 'PHPMappingDriver')) { @@ -921,10 +907,8 @@ public function testDiscriminatorColumnDefaultLength(): void self::assertEquals(255, $class->discriminatorColumn['length']); } - /** - * @group DDC-514 - * @group DDC-1015 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-514')] + #[\PHPUnit\Framework\Attributes\Group('DDC-1015')] public function testDiscriminatorColumnDefaultType(): void { if (str_contains(static::class, 'PHPMappingDriver')) { @@ -937,10 +921,8 @@ public function testDiscriminatorColumnDefaultType(): void self::assertEquals('string', $class->discriminatorColumn['type']); } - /** - * @group DDC-514 - * @group DDC-1015 - */ + #[\PHPUnit\Framework\Attributes\Group('DDC-514')] + #[\PHPUnit\Framework\Attributes\Group('DDC-1015')] public function testDiscriminatorColumnDefaultName(): void { if (str_contains(static::class, 'PHPMappingDriver')) { @@ -984,7 +966,7 @@ public function testUpdatableColumn(): void self::assertArrayNotHasKey('notUpdatable', $metadata->getFieldMapping('updatableContent')); } - /** @requires PHP 8.1 */ + #[RequiresPhp('8.1')] public function testEnumType(): void { $metadata = $this->createClassMetadata(Card::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php index 12c62cc5f10..ecade647392 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php @@ -9,11 +9,13 @@ use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; use Doctrine\Tests\ORM\Mapping\NamingStrategy\JoinColumnClassNamingStrategy; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use const CASE_LOWER; use const CASE_UPPER; -/** @group DDC-559 */ +#[Group('DDC-559')] class NamingStrategyTest extends OrmTestCase { private static function defaultNaming(): DefaultNamingStrategy @@ -57,7 +59,7 @@ public static function dataClassToTableName(): array ]; } - /** @dataProvider dataClassToTableName */ + #[DataProvider('dataClassToTableName')] public function testClassToTableName(NamingStrategy $strategy, string $expected, string $className): void { self::assertSame($expected, $strategy->classToTableName($className)); @@ -90,7 +92,7 @@ public static function dataPropertyToColumnName(): array ]; } - /** @dataProvider dataPropertyToColumnName */ + #[DataProvider('dataPropertyToColumnName')] public function testPropertyToColumnName( NamingStrategy $strategy, string $expected, @@ -117,7 +119,7 @@ public static function dataReferenceColumnName(): array ]; } - /** @dataProvider dataReferenceColumnName */ + #[DataProvider('dataReferenceColumnName')] public function testReferenceColumnName(NamingStrategy $strategy, string $expected): void { self::assertSame($expected, $strategy->referenceColumnName()); @@ -151,7 +153,7 @@ public static function dataJoinColumnName(): array ]; } - /** @dataProvider dataJoinColumnName */ + #[DataProvider('dataJoinColumnName')] public function testJoinColumnName( UnderscoreNamingStrategy|DefaultNamingStrategy $strategy, string $expected, @@ -186,7 +188,7 @@ public static function dataJoinTableName(): array ]; } - /** @dataProvider dataJoinTableName */ + #[DataProvider('dataJoinTableName')] public function testJoinTableName( NamingStrategy $strategy, string $expected, @@ -221,7 +223,7 @@ public static function dataJoinKeyColumnName(): array ]; } - /** @dataProvider dataJoinKeyColumnName */ + #[DataProvider('dataJoinKeyColumnName')] public function testJoinKeyColumnName( NamingStrategy $strategy, string $expected, diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php index d2b7a31d8f0..2266ea828bf 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php @@ -14,8 +14,9 @@ use Doctrine\Tests\Models\DDC117\DDC117Article; use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1845 */ +#[Group('DDC-1845')] class QuoteStrategyTest extends OrmTestCase { private DefaultQuoteStrategy $strategy; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php index d884e226dd2..471f7a529f8 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php @@ -10,23 +10,23 @@ use Doctrine\Tests\Models\Reflection\AbstractEmbeddable; use Doctrine\Tests\Models\Reflection\ArrayObjectExtendingClass; use Doctrine\Tests\Models\Reflection\ConcreteEmbeddable; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use ReflectionProperty; /** * Tests for {@see \Doctrine\ORM\Mapping\ReflectionEmbeddedProperty} - * - * @covers \Doctrine\ORM\Mapping\ReflectionEmbeddedProperty */ +#[CoversClass(ReflectionEmbeddedProperty::class)] class ReflectionEmbeddedPropertyTest extends TestCase { /** * @param ReflectionProperty $parentProperty property of the embeddable/entity where to write the embeddable to * @param ReflectionProperty $childProperty property of the embeddable class where to write values to * @param string $embeddableClass name of the embeddable class to be instantiated - * - * @dataProvider getTestedReflectionProperties */ + #[DataProvider('getTestedReflectionProperties')] public function testCanSetAndGetEmbeddedProperty( ReflectionProperty $parentProperty, ReflectionProperty $childProperty, @@ -51,9 +51,8 @@ public function testCanSetAndGetEmbeddedProperty( * @param ReflectionProperty $parentProperty property of the embeddable/entity where to write the embeddable to * @param ReflectionProperty $childProperty property of the embeddable class where to write values to * @param string $embeddableClass name of the embeddable class to be instantiated - * - * @dataProvider getTestedReflectionProperties */ + #[DataProvider('getTestedReflectionProperties')] public function testWillSkipReadingPropertiesFromNullEmbeddable( ReflectionProperty $parentProperty, ReflectionProperty $childProperty, diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php index 976740867ad..ba2534a231e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php @@ -9,10 +9,11 @@ use Doctrine\Tests\Models\ReadonlyProperties\Author; use InvalidArgumentException; use LogicException; +use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\TestCase; use ReflectionProperty; -/** @requires PHP 8.1 */ +#[RequiresPhp('8.1')] class ReflectionReadonlyPropertyTest extends TestCase { public function testSecondWriteWithSameValue(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php index cad8b12108d..981fe141564 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php @@ -8,6 +8,7 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Persistence\Mapping\Driver\StaticPHPDriver; use Doctrine\Tests\Models\DDC889\DDC889Class; +use PHPUnit\Framework\Attributes\Group; use const DIRECTORY_SEPARATOR; @@ -20,27 +21,22 @@ protected function loadDriver(): MappingDriver /** * All class with static::loadMetadata are entities for php driver - * - * @group DDC-889 */ + #[Group('DDC-889')] public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses(): void { self::assertInstanceOf(ClassMetadata::class, $this->createClassMetadata(DDC889Class::class)); } - /** - * @group DDC-2825 - * @group 881 - */ + #[Group('DDC-2825')] + #[Group('881')] public function testSchemaDefinitionViaExplicitTableSchemaAttributeProperty(): void { self::markTestIncomplete(); } - /** - * @group DDC-2825 - * @group 881 - */ + #[Group('DDC-2825')] + #[Group('881')] public function testSchemaDefinitionViaSchemaDefinedInTableNameInTableAttributeProperty(): void { self::markTestIncomplete(); diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php index b563fa18462..065c207be1d 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php @@ -6,6 +6,7 @@ use Doctrine\Persistence\Mapping\Driver\FileDriver; use Doctrine\Persistence\Mapping\MappingException; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; @@ -16,7 +17,7 @@ use function touch; use function unlink; -/** @group DDC-1418 */ +#[Group('DDC-1418')] abstract class DriverTestCase extends TestCase { private string $dir; diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php index 93c07f58378..1ff559eb5dd 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php @@ -6,10 +6,11 @@ use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver; use Doctrine\Persistence\Mapping\Driver\FileDriver; +use PHPUnit\Framework\Attributes\Group; use function array_flip; -/** @group DDC-1418 */ +#[Group('DDC-1418')] class XmlDriverTest extends DriverTestCase { protected function getFileExtension(): string diff --git a/tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapperTest.php b/tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapperTest.php index 59e10bca65d..3f8c0863ca0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapperTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapperTest.php @@ -11,9 +11,11 @@ use Doctrine\Tests\Models\TypedProperties\UserTyped; use Doctrine\Tests\ORM\Mapping\TypedFieldMapper\CustomIntAsStringTypedFieldMapper; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use ReflectionClass; -/** @group GH10313 */ +#[Group('GH10313')] class TypedFieldMapperTest extends OrmTestCase { private static function defaultTypedFieldMapper(): DefaultTypedFieldMapper @@ -69,9 +71,8 @@ public static function dataFieldToMappedField(): array /** * @param array{fieldName: string, enumType?: string, type?: mixed} $mapping * @param array{fieldName: string, enumType?: string, type?: mixed} $finalMapping - * - * @dataProvider dataFieldToMappedField */ + #[DataProvider('dataFieldToMappedField')] public function testValidateAndComplete( TypedFieldMapper $typedFieldMapper, ReflectionClass $reflectionClass, diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 7a08a86228c..e38124cc1e2 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -24,6 +24,8 @@ use Doctrine\Tests\Models\GH7316\GH7316Article; use Doctrine\Tests\Models\ValueObjects\Name; use Doctrine\Tests\Models\ValueObjects\Person; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function substr_count; @@ -93,11 +95,9 @@ public function testEmbeddableMapping(): void self::assertTrue($class->isEmbeddedClass); } - /** - * @group DDC-3293 - * @group DDC-3477 - * @group 1238 - */ + #[Group('DDC-3293')] + #[Group('DDC-3477')] + #[Group('1238')] public function testEmbeddedMappingsWithUseColumnPrefix(): void { $factory = new ClassMetadataFactory(); @@ -113,11 +113,9 @@ public function testEmbeddedMappingsWithUseColumnPrefix(): void ); } - /** - * @group DDC-3293 - * @group DDC-3477 - * @group 1238 - */ + #[Group('DDC-3293')] + #[Group('DDC-3477')] + #[Group('1238')] public function testEmbeddedMappingsWithFalseUseColumnPrefix(): void { $factory = new ClassMetadataFactory(); @@ -149,7 +147,7 @@ public function testEmbeddedMapping(): void ); } - /** @group DDC-1468 */ + #[Group('DDC-1468')] public function testItMentionsFilenameAndEntityNameOnInvalidMapping(): void { $this->expectException(PersistenceMappingException::class); @@ -157,10 +155,8 @@ public function testItMentionsFilenameAndEntityNameOnInvalidMapping(): void $this->createClassMetadata(BooleanModel::class); } - /** - * @dataProvider dataValidSchema - * @group DDC-2429 - */ + #[Group('DDC-2429')] + #[DataProvider('dataValidSchema')] public function testValidateXmlSchema( string $class, string $tableName, @@ -203,9 +199,8 @@ public static function dataValidSchema(): array /** * @param class-string $class * @param non-empty-array $expectedExceptionOccurrences - * - * @dataProvider dataInvalidSchema */ + #[DataProvider('dataInvalidSchema')] public function testValidateIncorrectXmlSchema(string $class, array $expectedExceptionOccurrences): void { try { @@ -242,7 +237,7 @@ public static function dataInvalidSchema(): array ]; } - /** @group GH-7141 */ + #[Group('GH-7141')] public function testOneToManyDefaultOrderByAsc(): void { $driver = $this->loadDriver(); @@ -271,7 +266,7 @@ public function testManyToManyDefaultOrderByAsc(): void ); } - /** @group DDC-889 */ + #[Group('DDC-889')] public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses(): void { $this->expectException(MappingException::class); diff --git a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php index 8b1508500bf..d1f82e74cd9 100644 --- a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php @@ -5,12 +5,14 @@ namespace Doctrine\Tests\ORM; use Doctrine\ORM\ORMInvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; use function spl_object_id; -/** @covers \Doctrine\ORM\ORMInvalidArgumentException */ +#[CoversClass(ORMInvalidArgumentException::class)] class ORMInvalidArgumentExceptionTest extends TestCase { /** @psalm-return list */ @@ -25,7 +27,7 @@ public static function invalidEntityNames(): array ]; } - /** @dataProvider newEntitiesFoundThroughRelationshipsErrorMessages */ + #[DataProvider('newEntitiesFoundThroughRelationshipsErrorMessages')] public function testNewEntitiesFoundThroughRelationships(array $newEntities, string $expectedMessage): void { $exception = ORMInvalidArgumentException::newEntitiesFoundThroughRelationships($newEntities); diff --git a/tests/Doctrine/Tests/ORM/ORMSetupTest.php b/tests/Doctrine/Tests/ORM/ORMSetupTest.php index 3ff708ae030..1da12828147 100644 --- a/tests/Doctrine/Tests/ORM/ORMSetupTest.php +++ b/tests/Doctrine/Tests/ORM/ORMSetupTest.php @@ -9,6 +9,8 @@ use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\ORMSetup; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use ReflectionProperty; use Symfony\Component\Cache\Adapter\AbstractAdapter; @@ -37,7 +39,7 @@ public function testXMLConfiguration(): void self::assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); } - /** @requires extension apcu */ + #[RequiresPhpExtension('apcu')] public function testCacheNamespaceShouldBeGeneratedForApcu(): void { $config = ORMSetup::createConfiguration(false, '/foo'); @@ -49,14 +51,14 @@ public function testCacheNamespaceShouldBeGeneratedForApcu(): void self::assertSame('dc2_1effb2475fcfba4f9e8b8a1dbc8f3caf:', $namespaceProperty->getValue($cache)); } - /** @group DDC-1350 */ + #[Group('DDC-1350')] public function testConfigureProxyDir(): void { $config = ORMSetup::createAttributeMetadataConfiguration([], true, '/foo'); self::assertEquals('/foo', $config->getProxyDir()); } - /** @group DDC-1350 */ + #[Group('DDC-1350')] public function testConfigureCache(): void { $cache = new ArrayAdapter(); @@ -67,7 +69,7 @@ public function testConfigureCache(): void self::assertSame($cache, $config->getMetadataCache()); } - /** @group DDC-3190 */ + #[Group('DDC-3190')] public function testConfigureCacheCustomInstance(): void { $cache = new ArrayAdapter(); diff --git a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php index 00a621cfa5a..b8cd1dca2ba 100644 --- a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use function count; use function microtime; @@ -19,10 +20,8 @@ use const PHP_EOL; -/** - * @group DDC-2183 - * @group performance - */ +#[Group('DDC-2183')] +#[Group('performance')] class SecondLevelCacheTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index a99aa7f3b57..71a4c62e95a 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -15,6 +15,7 @@ use Doctrine\Tests\Models\ECommerce\ECommerceCart; use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use stdClass; @@ -105,7 +106,7 @@ public function testNextInitializesCollection(): void self::assertTrue($this->collection->isInitialized()); } - /** @group DDC-3382 */ + #[Group('DDC-3382')] public function testNonObjects(): void { self::assertEmpty($this->collection); @@ -125,7 +126,7 @@ public function testNonObjects(): void self::assertNull($this->collection->get(3)); } - /** @group 6110 */ + #[Group('6110')] public function testRemovingElementsAlsoRemovesKeys(): void { $dummy = new stdClass(); @@ -137,7 +138,7 @@ public function testRemovingElementsAlsoRemovesKeys(): void self::assertEquals([], array_keys($this->collection->toArray())); } - /** @group 6110 */ + #[Group('6110')] public function testClearWillAlsoClearKeys(): void { $this->collection->add(new stdClass()); @@ -145,7 +146,7 @@ public function testClearWillAlsoClearKeys(): void self::assertEquals([], array_keys($this->collection->toArray())); } - /** @group 6110 */ + #[Group('6110')] public function testClearWillAlsoResetKeyPositions(): void { $dummy = new stdClass(); @@ -157,11 +158,9 @@ public function testClearWillAlsoResetKeyPositions(): void self::assertEquals([0], array_keys($this->collection->toArray())); } - /** - * @group 6613 - * @group 6614 - * @group 6616 - */ + #[Group('6613')] + #[Group('6614')] + #[Group('6616')] public function testWillKeepNewItemsInDirtyCollectionAfterInitialization(): void { $unitOfWork = $this->createMock(UnitOfWork::class); @@ -192,11 +191,9 @@ public function testWillKeepNewItemsInDirtyCollectionAfterInitialization(): void self::assertTrue($this->collection->isDirty()); } - /** - * @group 6613 - * @group 6614 - * @group 6616 - */ + #[Group('6613')] + #[Group('6614')] + #[Group('6616')] public function testWillDeDuplicateNewItemsThatWerePreviouslyPersistedInDirtyCollectionAfterInitialization(): void { $unitOfWork = $this->createMock(UnitOfWork::class); @@ -236,11 +233,9 @@ public function testWillDeDuplicateNewItemsThatWerePreviouslyPersistedInDirtyCol self::assertTrue($this->collection->isDirty()); } - /** - * @group 6613 - * @group 6614 - * @group 6616 - */ + #[Group('6613')] + #[Group('6614')] + #[Group('6616')] public function testWillNotMarkCollectionAsDirtyAfterInitializationIfNoElementsWereAdded(): void { $unitOfWork = $this->createMock(UnitOfWork::class); diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index 7e46efab1ba..35d9482b909 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -18,6 +18,7 @@ use Doctrine\Tests\Models\CustomType\CustomTypeParent; use Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use ReflectionMethod; use function array_slice; @@ -106,7 +107,7 @@ public function testGetSelectConditionSQLUsesTypeValuesSQL(): void self::assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); } - /** @group DDC-1719 */ + #[Group('DDC-1719')] public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): void { $persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(NonAlphaColumnsEntity::class)); @@ -115,7 +116,7 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi self::assertEquals('t0."simple-entity-id" AS simpleentityid_1, t0."simple-entity-value" AS simpleentityvalue_2', $method->invoke($persister)); } - /** @group DDC-2073 */ + #[Group('DDC-2073')] public function testSelectConditionStatementIsNull(): void { $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::IS); @@ -134,7 +135,7 @@ public function testSelectConditionStatementNeqNull(): void self::assertEquals('test IS NOT NULL', $statement); } - /** @group DDC-3056 */ + #[Group('DDC-3056')] public function testSelectConditionStatementWithMultipleValuesContainingNull(): void { self::assertEquals( diff --git a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php index 5f2b55313ca..67f7b3214d9 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php @@ -8,12 +8,13 @@ use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\JoinedInheritanceType\RootClass; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; /** * Tests for {@see \Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister} - * - * @covers \Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister */ +#[CoversClass(JoinedSubclassPersister::class)] class JoinedSubclassPersisterTest extends OrmTestCase { protected JoinedSubclassPersister $persister; @@ -27,7 +28,7 @@ protected function setUp(): void $this->persister = new JoinedSubclassPersister($this->em, $this->em->getClassMetadata(RootClass::class)); } - /** @group DDC-3470 */ + #[Group('DDC-3470')] public function testExecuteInsertsWillReturnEmptySetWithNoQueuedInserts(): void { self::assertSame([], $this->persister->executeInserts()); diff --git a/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php index 640e79ec63c..c9db932c60f 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php @@ -12,14 +12,14 @@ use Doctrine\Tests\Models\ManyToManyPersister\OtherParentClass; use Doctrine\Tests\Models\ManyToManyPersister\ParentClass; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; -/** @covers \Doctrine\ORM\Persisters\Collection\ManyToManyPersister */ +#[CoversClass(ManyToManyPersister::class)] final class ManyToManyPersisterTest extends OrmTestCase { - /** - * @group GH-6991 - * @group ManyToManyPersister - */ + #[Group('GH-6991')] + #[Group('ManyToManyPersister')] public function testDeleteManyToManyCollection(): void { $driver = $this->createMock(Driver::class); diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index 210d1ba8e3b..f71dd2ba291 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -20,6 +20,7 @@ use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\ECommerce\ECommerceFeature; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; use ReflectionProperty; use stdClass; @@ -93,7 +94,7 @@ public function testSkipMappedSuperClassesOnGeneration(): void ); } - /** @group 6625 */ + #[Group('6625')] public function testSkipEmbeddableClassesOnGeneration(): void { $cm = new ClassMetadata(stdClass::class); @@ -106,7 +107,7 @@ public function testSkipEmbeddableClassesOnGeneration(): void ); } - /** @group DDC-1771 */ + #[Group('DDC-1771')] public function testSkipAbstractClassesOnGeneration(): void { $cm = new ClassMetadata(AbstractClass::class); @@ -118,7 +119,7 @@ public function testSkipAbstractClassesOnGeneration(): void self::assertEquals(0, $num, 'No proxies generated.'); } - /** @group DDC-2432 */ + #[Group('DDC-2432')] public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void { $persister = $this->getMockBuilder(BasicEntityPersister::class) @@ -144,7 +145,7 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void self::assertFalse($proxy->__isInitialized()); } - /** @group DDC-2432 */ + #[Group('DDC-2432')] public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void { $persister = $this->getMockBuilder(BasicEntityPersister::class) diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php index 4f5e40dbb83..dca376a784f 100644 --- a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php @@ -6,6 +6,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Test case for testing the saving and referencing of query identifiers. @@ -34,7 +35,7 @@ public function assertSqlGeneration(string $dqlToBeTested, string $sqlToBeConfir $query->free(); } - /** @group 6939 */ + #[Group('6939')] public function testSupportsDeleteWithoutWhereAndAlias(): void { $this->assertSqlGeneration( @@ -261,7 +262,7 @@ public function testSupportsNotInClause(): void ); } - /** @group DDC-980 */ + #[Group('DDC-980')] public function testSubselectTableAliasReferencing(): void { $this->assertSqlGeneration( diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index d15f24b4524..b3ff41f5d38 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -21,6 +21,8 @@ use Doctrine\Tests\OrmTestCase; use Generator; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * Test case for the DQL Expr class used for generating DQL snippets through @@ -195,10 +197,8 @@ public function testModExpr(): void self::assertEquals('MOD(10, 1)', (string) $this->expr->mod(10, 1)); } - /** - * @group regression - * @group DDC-612 - */ + #[Group('regression')] + #[Group('DDC-612')] public function testSubstringExprAcceptsTwoArguments(): void { self::assertEquals('SUBSTRING(a.title, 5)', (string) $this->expr->substring('a.title', 5)); @@ -239,10 +239,8 @@ public function testNumericLiteralExpr(): void self::assertEquals(5, (string) $this->expr->literal(5)); } - /** - * @group regression - * @group DDC-610 - */ + #[Group('regression')] + #[Group('DDC-610')] public function testLiteralExprProperlyQuotesStrings(): void { self::assertEquals("'00010001'", (string) $this->expr->literal('00010001')); @@ -308,25 +306,25 @@ public static function provideLiteralIterableValue(): Generator yield 'generator' => [$gen()]; } - /** @dataProvider provideIterableValue */ + #[DataProvider('provideIterableValue')] public function testInExpr(iterable $value): void { self::assertEquals('u.id IN(1, 2, 3)', (string) $this->expr->in('u.id', $value)); } - /** @dataProvider provideLiteralIterableValue */ + #[DataProvider('provideLiteralIterableValue')] public function testInLiteralExpr(iterable $value): void { self::assertEquals("u.type IN('foo', 'bar')", (string) $this->expr->in('u.type', $value)); } - /** @dataProvider provideIterableValue */ + #[DataProvider('provideIterableValue')] public function testNotInExpr(iterable $value): void { self::assertEquals('u.id NOT IN(1, 2, 3)', (string) $this->expr->notIn('u.id', $value)); } - /** @dataProvider provideLiteralIterableValue */ + #[DataProvider('provideLiteralIterableValue')] public function testNotInLiteralExpr(iterable $value): void { self::assertEquals("u.type NOT IN('foo', 'bar')", (string) $this->expr->notIn('u.type', $value)); @@ -381,14 +379,14 @@ public function testAddThrowsException(): void $orExpr->add($this->expr->quot(5, 2)); } - /** @group DDC-1683 */ + #[Group('DDC-1683')] public function testBooleanLiteral(): void { self::assertEquals('true', $this->expr->literal(true)); self::assertEquals('false', $this->expr->literal(false)); } - /** @group DDC-1686 */ + #[Group('DDC-1686')] public function testExpressionGetter(): void { // Andx diff --git a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php index e8129df6442..330b399cac9 100644 --- a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\OrmTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Depends; /** * Test case for FilterCollection @@ -48,7 +49,7 @@ public function testHasFilter(): void self::assertFalse($filterCollection->has('fakeFilter')); } - /** @depends testEnable */ + #[Depends('testEnable')] public function testIsEnabled(): void { $filterCollection = $this->em->getFilters(); diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index a5dc513a8c3..85c303ef4f2 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -17,6 +17,8 @@ use Doctrine\ORM\Query\QueryException; use Doctrine\Tests\Mocks\NullSqlWalker; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; class LanguageRecognitionTest extends OrmTestCase { @@ -73,7 +75,7 @@ public function testSelectSingleComponentWithAsterisk(): void $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); } - /** @dataProvider invalidDQL */ + #[DataProvider('invalidDQL')] public function testRejectsInvalidDQL(string $dql): void { $this->expectException(QueryException::class); @@ -258,13 +260,13 @@ public function testJoinClassPathUsingWITH(): void $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WITH a.user = u.id'); } - /** @group DDC-3701 */ + #[Group('DDC-3701')] public function testJoinClassPathUsingWHERE(): void { $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = u.id'); } - /** @group DDC-3701 */ + #[Group('DDC-3701')] public function testDDC3701WHEREIsNotWITH(): void { $this->assertInvalidDQL('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN Doctrine\Tests\Models\Company\CompanyEmployee e WHERE e.id = c.salesPerson WHERE c.completed = true'); @@ -315,14 +317,14 @@ public function testArithmeticExpressionWithParenthesisInSubselectPart(): void $this->assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); } - /** @group DDC-1079 */ + #[Group('DDC-1079')] public function testSelectLiteralInSubselect(): void { $this->assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u'); $this->assertValidDQL('SELECT (SELECT 0 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u'); } - /** @group DDC-1077 */ + #[Group('DDC-1077')] public function testConstantValueInSelect(): void { $this->assertValidDQL("SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u"); @@ -542,7 +544,7 @@ public function testInputParameterInSelect(): void $this->assertValidDQL('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u'); } - /** @group DDC-1091 */ + #[Group('DDC-1091')] public function testCustomFunctionsReturningStringInStringPrimary(): void { $this->entityManager->getConfiguration()->addCustomStringFunction('CC', ConcatFunction::class); @@ -550,13 +552,13 @@ public function testCustomFunctionsReturningStringInStringPrimary(): void $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'"); } - /** @group DDC-505 */ + #[Group('DDC-505')] public function testDQLKeywordInJoinIsAllowed(): void { $this->assertValidDQL('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g'); } - /** @group DDC-505 */ + #[Group('DDC-505')] public function testDQLKeywordInConditionIsAllowed(): void { $this->assertValidDQL('SELECT g FROM ' . __NAMESPACE__ . '\DQLKeywordsModelGroup g WHERE g.from=0'); @@ -568,43 +570,43 @@ public function testInverseSideSingleValuedAssociationPathNotAllowed(): void $this->assertInvalidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1'); } - /** @group DDC-617 */ + #[Group('DDC-617')] public function testSelectOnlyNonRootEntityAlias(): void { $this->assertInvalidDQL('SELECT g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'); } - /** @group DDC-1108 */ + #[Group('DDC-1108')] public function testInputParameterSingleChar(): void { $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :q'); } - /** @group DDC-1053 */ + #[Group('DDC-1053')] public function testGroupBy(): void { $this->assertValidDQL('SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id'); } - /** @group DDC-1053 */ + #[Group('DDC-1053')] public function testGroupByIdentificationVariable(): void { $this->assertValidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g'); } - /** @group DDC-1053 */ + #[Group('DDC-1053')] public function testGroupByUnknownIdentificationVariable(): void { $this->assertInvalidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY m'); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testSizeOfForeignKeyOneToManyPrimaryKeyEntity(): void { $this->assertValidDQL('SELECT a, t FROM Doctrine\Tests\Models\DDC117\DDC117Article a JOIN a.translations t WHERE SIZE(a.translations) > 0'); } - /** @group DDC-117 */ + #[Group('DDC-117')] public function testSizeOfForeignKeyManyToManyPrimaryKeyEntity(): void { $this->assertValidDQL('SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE SIZE(e.reviewingTranslations) > 0'); @@ -620,31 +622,31 @@ public function testCaseSupportContainingCoalesceExpression(): void $this->assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u"); } - /** @group DDC-1858 */ + #[Group('DDC-1858')] public function testHavingSupportIsNullExpression(): void { $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL'); } - /** @group DDC-3085 */ + #[Group('DDC-3085')] public function testHavingSupportResultVariableInNullComparisonExpression(): void { $this->assertValidDQL('SELECT u AS user, SUM(a.id) AS score FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN Doctrine\Tests\Models\CMS\CmsAddress a WITH a.user = u GROUP BY u HAVING score IS NOT NULL AND score >= 5'); } - /** @group DDC-1858 */ + #[Group('DDC-1858')] public function testHavingSupportLikeExpression(): void { $this->assertValidDQL("SELECT _u.id, count(_articles) as uuuu FROM Doctrine\Tests\Models\CMS\CmsUser _u LEFT JOIN _u.articles _articles GROUP BY _u HAVING uuuu LIKE '3'"); } - /** @group DDC-3018 */ + #[Group('DDC-3018')] public function testNewLiteralExpression(): void { $this->assertValidDQL('SELECT new ' . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', 1, true) FROM Doctrine\Tests\Models\CMS\CmsUser u"); } - /** @group DDC-3075 */ + #[Group('DDC-3075')] public function testNewLiteralWithSubselectExpression(): void { $this->assertValidDQL('SELECT new ' . __NAMESPACE__ . "\\DummyStruct(u.id, 'foo', (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser su), true) FROM Doctrine\Tests\Models\CMS\CmsUser u"); diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index 7b41970989a..9ddd2811a27 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -8,10 +8,11 @@ use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DataProvider; class LexerTest extends OrmTestCase { - /** @dataProvider provideTokens */ + #[DataProvider('provideTokens')] public function testScannerRecognizesTokens($type, $value): void { $lexer = new Lexer($value); diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index 48cea4486a0..3a983af42a9 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -15,6 +15,7 @@ use Doctrine\Tests\Models\Enums\UserStatus; use Doctrine\Tests\OrmTestCase; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; class ParameterTypeInfererTest extends OrmTestCase { @@ -38,7 +39,7 @@ public static function providerParameterTypeInferer(): Generator yield 'array_of_string_backed_enum' => [[UserStatus::Active], ArrayParameterType::STRING]; } - /** @dataProvider providerParameterTypeInferer */ + #[DataProvider('providerParameterTypeInferer')] public function testParameterTypeInferer(mixed $value, ParameterType|ArrayParameterType|int|string $expected): void { self::assertEquals($expected, ParameterTypeInferer::inferType($value)); diff --git a/tests/Doctrine/Tests/ORM/Query/ParserTest.php b/tests/Doctrine/Tests/ORM/Query/ParserTest.php index ca1716a84f8..430177b1fcc 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserTest.php @@ -10,14 +10,14 @@ use Doctrine\ORM\Query\TokenType; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; use stdClass; class ParserTest extends OrmTestCase { - /** - * @covers \Doctrine\ORM\Query\Parser::AbstractSchemaName - * @group DDC-3715 - */ + #[Group('DDC-3715')] public function testAbstractSchemaNameSupportsFQCN(): void { $parser = $this->createParser(CmsUser::class); @@ -25,10 +25,7 @@ public function testAbstractSchemaNameSupportsFQCN(): void self::assertEquals(CmsUser::class, $parser->AbstractSchemaName()); } - /** - * @covers Doctrine\ORM\Query\Parser::AbstractSchemaName - * @group DDC-3715 - */ + #[Group('DDC-3715')] public function testAbstractSchemaNameSupportsClassnamesWithLeadingBackslash(): void { $parser = $this->createParser('\\' . CmsUser::class); @@ -36,10 +33,7 @@ public function testAbstractSchemaNameSupportsClassnamesWithLeadingBackslash(): self::assertEquals('\\' . CmsUser::class, $parser->AbstractSchemaName()); } - /** - * @covers \Doctrine\ORM\Query\Parser::AbstractSchemaName - * @group DDC-3715 - */ + #[Group('DDC-3715')] public function testAbstractSchemaNameSupportsIdentifier(): void { $parser = $this->createParser(stdClass::class); @@ -47,25 +41,18 @@ public function testAbstractSchemaNameSupportsIdentifier(): void self::assertEquals(stdClass::class, $parser->AbstractSchemaName()); } - /** - * @dataProvider validMatches - * @covers Doctrine\ORM\Query\Parser::match - * @group DDC-3701 - */ + #[DataProvider('validMatches')] + #[Group('DDC-3701')] + #[DoesNotPerformAssertions] public function testMatch(TokenType $expectedToken, string $inputString): void { $parser = $this->createParser($inputString); $parser->match($expectedToken); // throws exception if not matched - - $this->addToAssertionCount(1); } - /** - * @dataProvider invalidMatches - * @covers Doctrine\ORM\Query\Parser::match - * @group DDC-3701 - */ + #[DataProvider('invalidMatches')] + #[Group('DDC-3701')] public function testMatchFailure(TokenType $expectedToken, string $inputString): void { $this->expectException(QueryException::class); @@ -115,9 +102,8 @@ public static function invalidMatches(): array * PHP 7.4 would fail with Notice: Trying to access array offset on value of type null. * * @see https://github.com/doctrine/orm/pull/7934 - * - * @group GH7934 */ + #[Group('GH7934')] public function testNullLookahead(): void { $query = new Query($this->getTestEntityManager()); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 54f4317888d..54cc54d5546 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Query\Expr as QueryBuilder; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\QueryExpressionVisitor; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; /** @@ -25,7 +26,7 @@ protected function setUp(): void $this->visitor = new QueryExpressionVisitor(['o', 'p']); } - /** @dataProvider comparisonData */ + #[DataProvider('comparisonData')] public function testWalkComparison(CriteriaComparison $criteriaExpr, QueryBuilder\Comparison|QueryBuilder\Func|string $queryExpr, Parameter|null $parameter = null): void { self::assertEquals($queryExpr, $this->visitor->walkComparison($criteriaExpr)); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index dd49309a21f..cda9b375c19 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -29,6 +29,9 @@ use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\OrmTestCase; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhp; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -139,7 +142,7 @@ public function testSettingNullFirstResultIsDeprecated(): void $q->setFirstResult(null); } - /** @group DDC-968 */ + #[Group('DDC-968')] public function testHints(): void { $q = $this->entityManager->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a'); @@ -186,7 +189,7 @@ public function testIterateEmptyResult(): void self::assertTrue(true); } - /** @group DDC-1697 */ + #[Group('DDC-1697')] public function testCollectionParameters(): void { $cities = [ @@ -225,7 +228,7 @@ public static function provideProcessParameterValueIterable(): Generator yield 'array_of_enum' => [array_map([City::class, 'from'], $baseArray)]; } - /** @dataProvider provideProcessParameterValueIterable */ + #[DataProvider('provideProcessParameterValueIterable')] public function testProcessParameterValueIterable(iterable $cities): void { $query = $this->entityManager->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)'); @@ -248,7 +251,7 @@ public function testProcessParameterValueWithIterableEntityShouldNotBeTreatedAsI self::assertEquals(1, $query->processParameterValue($group)); } - /** @group DDC-2224 */ + #[Group('DDC-2224')] public function testProcessParameterValueClassMetadata(): void { $query = $this->entityManager->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)'); @@ -290,7 +293,7 @@ public function testProcessParameterValueNull(): void self::assertNull($query->processParameterValue(null)); } - /** @requires PHP 8.1 */ + #[RequiresPhp('8.1')] public function testProcessParameterValueBackedEnum(): void { $query = $this->entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.status = :status'); @@ -299,7 +302,7 @@ public function testProcessParameterValueBackedEnum(): void self::assertSame([2], $query->processParameterValue([AccessLevel::User])); } - /** @requires PHP 8.1 */ + #[RequiresPhp('8.1')] public function testProcessParameterValueBackedEnumArray(): void { $query = $this->entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.status IN (:status)'); @@ -326,7 +329,7 @@ public function testDefaultQueryHints(): void self::assertSame($config->getDefaultQueryHints(), $q2->getHints()); } - /** @group DDC-3714 */ + #[Group('DDC-3714')] public function testResultCacheCaching(): void { $entityManager = $this->createTestEntityManagerWithConnection( @@ -356,7 +359,7 @@ public function testResultCacheCaching(): void self::assertCount(0, $res); } - /** @group DDC-3741 */ + #[Group('DDC-3741')] public function testSetHydrationCacheProfileNull(): void { $query = $this->entityManager->createQuery(); @@ -364,7 +367,7 @@ public function testSetHydrationCacheProfileNull(): void self::assertNull($query->getHydrationCacheProfile()); } - /** @group 2947 */ + #[Group('2947')] public function testResultCacheEviction(): void { $entityManager = $this->createTestEntityManagerWithConnection( @@ -400,7 +403,7 @@ public function testResultCacheEviction(): void self::assertCount(2, $query->expireResultCache(false)->getResult()); } - /** @group #6162 */ + #[Group('#6162')] public function testSelectJoinSubquery(): void { $query = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u JOIN (SELECT )'); @@ -410,7 +413,7 @@ public function testSelectJoinSubquery(): void $query->getSQL(); } - /** @group #6162 */ + #[Group('#6162')] public function testSelectFromSubquery(): void { $query = $this->entityManager->createQuery('select u from (select Doctrine\Tests\Models\CMS\CmsUser c) as u'); @@ -420,7 +423,7 @@ public function testSelectFromSubquery(): void $query->getSQL(); } - /** @group 6699 */ + #[Group('6699')] public function testGetParameterTypeJuggling(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.id = ?0'); @@ -432,7 +435,7 @@ public function testGetParameterTypeJuggling(): void self::assertSame(0, $query->getParameter('0')->getValue()); } - /** @group 6699 */ + #[Group('6699')] public function testSetParameterWithNameZeroIsNotOverridden(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.id != ?0 and u.username = :name'); @@ -445,7 +448,7 @@ public function testSetParameterWithNameZeroIsNotOverridden(): void self::assertSame('Doctrine', $query->getParameter('name')->getValue()); } - /** @group 6699 */ + #[Group('6699')] public function testSetParameterWithNameZeroDoesNotOverrideAnotherParameter(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.id != ?0 and u.username = :name'); @@ -458,7 +461,7 @@ public function testSetParameterWithNameZeroDoesNotOverrideAnotherParameter(): v self::assertSame('Doctrine', $query->getParameter('name')->getValue()); } - /** @group 6699 */ + #[Group('6699')] public function testSetParameterWithTypeJugglingWorks(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.id != ?0 and u.username = :name'); @@ -474,7 +477,7 @@ public function testSetParameterWithTypeJugglingWorks(): void self::assertSame('Doctrine', $query->getParameter('name')->getValue()); } - /** @group 6748 */ + #[Group('6748')] public function testResultCacheProfileCanBeRemovedViaSetter(): void { $this->entityManager->getConfiguration()->setResultCache(new ArrayAdapter()); @@ -486,7 +489,7 @@ public function testResultCacheProfileCanBeRemovedViaSetter(): void self::assertNull($query->getQueryCacheProfile()); } - /** @group 7527 */ + #[Group('7527')] public function testValuesAreNotBeingResolvedForSpecifiedParameterTypes(): void { $unitOfWork = $this->createMock(UnitOfWork::class); @@ -504,7 +507,7 @@ public function testValuesAreNotBeingResolvedForSpecifiedParameterTypes(): void self::assertEmpty($query->getResult()); } - /** @group 7982 */ + #[Group('7982')] public function testNonExistentExecutor(): void { $this->expectException(QueryException::class); @@ -513,7 +516,7 @@ public function testNonExistentExecutor(): void $this->entityManager->createQuery('0')->execute(); } - /** @group 8106 */ + #[Group('8106')] public function testGetParameterColonNormalize(): void { $query = $this->entityManager->createQuery('select u from ' . CmsUser::class . ' u where u.name = :name'); diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 81de7f14ec5..f5626ab81ce 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -29,6 +29,8 @@ use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmTestCase; use Exception; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use function class_exists; use function sprintf; @@ -109,7 +111,7 @@ public function assertInvalidSqlGeneration( self::fail($sql); } - /** @group DDC-3697 */ + #[Group('DDC-3697')] public function testJoinWithRangeVariablePutsConditionIntoSqlWhereClause(): void { $this->assertSqlGeneration( @@ -119,7 +121,7 @@ public function testJoinWithRangeVariablePutsConditionIntoSqlWhereClause(): void ); } - /** @group DDC-3697 */ + #[Group('DDC-3697')] public function testJoinWithRangeVariableAndInheritancePutsConditionIntoSqlWhereClause(): void { /* @@ -259,7 +261,7 @@ public function testSingleAssociationPathExpressionInSubselect(): void ); } - /** @group DDC-1077 */ + #[Group('DDC-1077')] public function testConstantValueInSelect(): void { $this->assertSqlGeneration( @@ -324,7 +326,7 @@ public function testSupportsAggregateFunctionWithSimpleArithmetic(): void ); } - /** @group DDC-3276 */ + #[Group('DDC-3276')] public function testSupportsAggregateCountFunctionWithSimpleArithmetic(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); @@ -420,7 +422,7 @@ public function testSupportsPlainJoinWithoutClause(): void ); } - /** @group DDC-135 */ + #[Group('DDC-135')] public function testSupportsJoinAndWithClauseRestriction(): void { $this->assertSqlGeneration( @@ -433,10 +435,8 @@ public function testSupportsJoinAndWithClauseRestriction(): void ); } - /** - * @group DDC-135 - * @group DDC-177 - */ + #[Group('DDC-135')] + #[Group('DDC-177')] public function testJoinOnClauseNotYetSupportedThrowsException(): void { $this->expectException(QueryException::class); @@ -462,7 +462,7 @@ public function testSupportsTrimFunction(): void ); } - /** @group DDC-2668 */ + #[Group('DDC-2668')] public function testSupportsTrimLeadingZeroString(): void { $this->assertSqlGeneration( @@ -480,7 +480,7 @@ public function testSupportsBetweenClauseWithPositionalParameters(): void ); } - /** @group DDC-1802 */ + #[Group('DDC-1802')] public function testSupportsNotBetweenForSizeFunction(): void { $this->assertSqlGeneration( @@ -516,7 +516,7 @@ public function testSupportsInstanceOfExpressionInWherePartWithMultipleValues(): ); } - /** @group DDC-1194 */ + #[Group('DDC-1194')] public function testSupportsInstanceOfExpressionsInWherePartPrefixedSlash(): void { $this->assertSqlGeneration( @@ -525,7 +525,7 @@ public function testSupportsInstanceOfExpressionsInWherePartPrefixedSlash(): voi ); } - /** @group DDC-1194 */ + #[Group('DDC-1194')] public function testSupportsInstanceOfExpressionsInWherePartWithUnrelatedClass(): void { $this->assertInvalidSqlGeneration( @@ -585,7 +585,7 @@ public function testSupportsNotInExpressionInWherePart(): void ); } - /** @group DDC-1802 */ + #[Group('DDC-1802')] public function testSupportsNotInExpressionForModFunction(): void { $this->assertSqlGeneration( @@ -657,7 +657,7 @@ public function testSupportsExistsExpressionInWherePartWithCorrelatedSubquery(): ); } - /** @group DDC-593 */ + #[Group('DDC-593')] public function testSubqueriesInComparisonExpression(): void { $this->assertSqlGeneration( @@ -966,10 +966,8 @@ public function testSingleValuedAssociationNullCheckOnInverseSide(): void ); } - /** - * @group DDC-339 - * @group DDC-1572 - */ + #[Group('DDC-339')] + #[Group('DDC-1572')] public function testStringFunctionLikeExpression(): void { $this->assertSqlGeneration( @@ -1000,7 +998,7 @@ public function testStringFunctionLikeExpression(): void ); } - /** @group DDC-1802 */ + #[Group('DDC-1802')] public function testStringFunctionNotLikeExpression(): void { $this->assertSqlGeneration( @@ -1018,7 +1016,7 @@ public function testStringFunctionNotLikeExpression(): void ); } - /** @group DDC-338 */ + #[Group('DDC-338')] public function testOrderedCollectionFetchJoined(): void { $this->assertSqlGeneration( @@ -1036,10 +1034,8 @@ public function testSubselectInSelect(): void ); } - /** - * @group locking - * @group DDC-178 - */ + #[Group('locking')] + #[Group('DDC-178')] public function testPessimisticWriteLockQueryHint(): void { if ($this->entityManager->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { @@ -1054,10 +1050,8 @@ public function testPessimisticWriteLockQueryHint(): void ); } - /** - * @group locking - * @group DDC-178 - */ + #[Group('locking')] + #[Group('DDC-178')] public function testPessimisticReadLockQueryHintPostgreSql(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); @@ -1070,10 +1064,8 @@ public function testPessimisticReadLockQueryHintPostgreSql(): void ); } - /** - * @group DDC-1693 - * @group locking - */ + #[Group('DDC-1693')] + #[Group('locking')] public function testLockModeNoneQueryHint(): void { $this->assertSqlGeneration( @@ -1084,7 +1076,7 @@ public function testLockModeNoneQueryHint(): void ); } - /** @group DDC-430 */ + #[Group('DDC-430')] public function testSupportSelectWithMoreThan10InputParameters(): void { $this->assertSqlGeneration( @@ -1093,10 +1085,8 @@ public function testSupportSelectWithMoreThan10InputParameters(): void ); } - /** - * @group locking - * @group DDC-178 - */ + #[Group('locking')] + #[Group('DDC-178')] public function testPessimisticReadLockQueryHintMySql(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); @@ -1109,10 +1099,8 @@ public function testPessimisticReadLockQueryHintMySql(): void ); } - /** - * @group locking - * @group DDC-178 - */ + #[Group('locking')] + #[Group('DDC-178')] public function testPessimisticReadLockQueryHintOracle(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); @@ -1125,7 +1113,7 @@ public function testPessimisticReadLockQueryHintOracle(): void ); } - /** @group DDC-431 */ + #[Group('DDC-431')] public function testSupportToCustomDQLFunctions(): void { $config = $this->entityManager->getConfiguration(); @@ -1139,7 +1127,7 @@ public function testSupportToCustomDQLFunctions(): void $config->setCustomNumericFunctions([]); } - /** @group DDC-826 */ + #[Group('DDC-826')] public function testMappedSuperclassAssociationJoin(): void { $this->assertSqlGeneration( @@ -1148,7 +1136,7 @@ public function testMappedSuperclassAssociationJoin(): void ); } - /** @group DDC-1053 */ + #[Group('DDC-1053')] public function testGroupBy(): void { $this->assertSqlGeneration( @@ -1157,7 +1145,7 @@ public function testGroupBy(): void ); } - /** @group DDC-1053 */ + #[Group('DDC-1053')] public function testGroupByIdentificationVariable(): void { $this->assertSqlGeneration( @@ -1232,7 +1220,7 @@ public function testSubSelectAliasesFromOuterQueryReuseInWhereClause(): void ); } - /** @group DDC-1298 */ + #[Group('DDC-1298')] public function testSelectForeignKeyPKWithoutFields(): void { $this->assertSqlGeneration( @@ -1305,7 +1293,7 @@ public function testSimpleCaseWithMultipleWhenClauseInSubselect(): void ); } - /** @group DDC-1696 */ + #[Group('DDC-1696')] public function testSimpleCaseWithStringPrimary(): void { $this->assertSqlGeneration( @@ -1314,7 +1302,7 @@ public function testSimpleCaseWithStringPrimary(): void ); } - /** @group DDC-2205 */ + #[Group('DDC-2205')] public function testCaseNegativeValuesInThenExpression(): void { $this->assertSqlGeneration( @@ -1366,7 +1354,7 @@ public function testIdentityFunctionWithCompositePrimaryKey(): void ); } - /** @group DDC-2519 */ + #[Group('DDC-2519')] public function testPartialWithAssociationIdentifier(): void { $this->assertSqlGeneration( @@ -1380,7 +1368,7 @@ public function testPartialWithAssociationIdentifier(): void ); } - /** @group DDC-1339 */ + #[Group('DDC-1339')] public function testIdentityFunctionInSelectClause(): void { $this->assertSqlGeneration( @@ -1404,7 +1392,7 @@ public function testIdentityFunctionInJoinedSubclass(): void ); } - /** @group DDC-1339 */ + #[Group('DDC-1339')] public function testIdentityFunctionDoesNotAcceptStateField(): void { $this->assertInvalidSqlGeneration( @@ -1413,7 +1401,7 @@ public function testIdentityFunctionDoesNotAcceptStateField(): void ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeJoinInRootClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1423,7 +1411,7 @@ public function testInheritanceTypeJoinInRootClassWithDisabledForcePartialLoad() ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeJoinInRootClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1433,7 +1421,7 @@ public function testInheritanceTypeJoinInRootClassWithEnabledForcePartialLoad(): ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeJoinInChildClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1443,7 +1431,7 @@ public function testInheritanceTypeJoinInChildClassWithDisabledForcePartialLoad( ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeJoinInChildClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1453,7 +1441,7 @@ public function testInheritanceTypeJoinInChildClassWithEnabledForcePartialLoad() ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeJoinInLeafClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1463,7 +1451,7 @@ public function testInheritanceTypeJoinInLeafClassWithDisabledForcePartialLoad() ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeJoinInLeafClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1473,7 +1461,7 @@ public function testInheritanceTypeJoinInLeafClassWithEnabledForcePartialLoad(): ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeSingleTableInRootClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1483,7 +1471,7 @@ public function testInheritanceTypeSingleTableInRootClassWithDisabledForcePartia ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeSingleTableInRootClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1493,7 +1481,7 @@ public function testInheritanceTypeSingleTableInRootClassWithEnabledForcePartial ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeSingleTableInChildClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1503,7 +1491,7 @@ public function testInheritanceTypeSingleTableInChildClassWithDisabledForceParti ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeSingleTableInChildClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1513,7 +1501,7 @@ public function testInheritanceTypeSingleTableInChildClassWithEnabledForcePartia ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeSingleTableInLeafClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1523,7 +1511,7 @@ public function testInheritanceTypeSingleTableInLeafClassWithDisabledForcePartia ); } - /** @group DDC-1389 */ + #[Group('DDC-1389')] public function testInheritanceTypeSingleTableInLeafClassWithEnabledForcePartialLoad(): void { $this->assertSqlGeneration( @@ -1533,7 +1521,7 @@ public function testInheritanceTypeSingleTableInLeafClassWithEnabledForcePartial ); } - /** @group DDC-1161 */ + #[Group('DDC-1161')] public function testSelfReferenceWithOneToOneDoesNotDuplicateAlias(): void { $this->assertSqlGeneration( @@ -1543,7 +1531,7 @@ public function testSelfReferenceWithOneToOneDoesNotDuplicateAlias(): void ); } - /** @group DDC-1384 */ + #[Group('DDC-1384')] public function testAliasDoesNotExceedPlatformDefinedLength(): void { $this->assertSqlGeneration( @@ -1552,10 +1540,8 @@ public function testAliasDoesNotExceedPlatformDefinedLength(): void ); } - /** - * @group DDC-331 - * @group DDC-1384 - */ + #[Group('DDC-331')] + #[Group('DDC-1384')] public function testIssue331(): void { $this->assertSqlGeneration( @@ -1564,7 +1550,7 @@ public function testIssue331(): void ); } - /** @group DDC-1435 */ + #[Group('DDC-1435')] public function testForeignKeyAsPrimaryKeySubselect(): void { $this->assertSqlGeneration( @@ -1573,7 +1559,7 @@ public function testForeignKeyAsPrimaryKeySubselect(): void ); } - /** @group DDC-1474 */ + #[Group('DDC-1474')] public function testSelectWithArithmeticExpressionBeforeField(): void { $this->assertSqlGeneration( @@ -1587,7 +1573,7 @@ public function testSelectWithArithmeticExpressionBeforeField(): void ); } - /** @group DDC-1430 */ + #[Group('DDC-1430')] public function testGroupByAllFieldsWhenObjectHasForeignKeys(): void { $this->assertSqlGeneration( @@ -1601,7 +1587,7 @@ public function testGroupByAllFieldsWhenObjectHasForeignKeys(): void ); } - /** @group DDC-1236 */ + #[Group('DDC-1236')] public function testGroupBySupportsResultVariable(): void { $this->assertSqlGeneration( @@ -1610,7 +1596,7 @@ public function testGroupBySupportsResultVariable(): void ); } - /** @group DDC-1236 */ + #[Group('DDC-1236')] public function testGroupBySupportsIdentificationVariable(): void { $this->assertSqlGeneration( @@ -1619,7 +1605,7 @@ public function testGroupBySupportsIdentificationVariable(): void ); } - /** @group DDC-1213 */ + #[Group('DDC-1213')] public function testSupportsBitComparison(): void { $this->assertSqlGeneration( @@ -1640,7 +1626,7 @@ public function testSupportsBitComparison(): void ); } - /** @group DDC-1539 */ + #[Group('DDC-1539')] public function testParenthesesOnTheLeftHandOfComparison(): void { $this->assertSqlGeneration( @@ -1665,7 +1651,7 @@ public function testSupportsParenthesisExpressionInSubSelect(): void ); } - /** @group DDC-1557 */ + #[Group('DDC-1557')] public function testSupportsSubSqlFunction(): void { $this->assertSqlGeneration( @@ -1694,7 +1680,7 @@ public function testSupportsSubSqlFunction(): void ); } - /** @group DDC-1574 */ + #[Group('DDC-1574')] public function testSupportsNewOperator(): void { $this->assertSqlGeneration( @@ -1728,7 +1714,7 @@ public function testSupportsNewOperator(): void ); } - /** @group DDC-2234 */ + #[Group('DDC-2234')] public function testWhereFunctionIsNullComparisonExpression(): void { $this->assertSqlGeneration( @@ -1823,7 +1809,7 @@ public function testCustomTypeValueSqlForPartialObject(): void ); } - /** @group DDC-1529 */ + #[Group('DDC-1529')] public function testMultipleFromAndInheritanceCondition(): void { $this->assertSqlGeneration( @@ -1832,7 +1818,7 @@ public function testMultipleFromAndInheritanceCondition(): void ); } - /** @group DDC-775 */ + #[Group('DDC-775')] public function testOrderByClauseSupportsSimpleArithmeticExpression(): void { $this->assertSqlGeneration( @@ -1857,7 +1843,7 @@ public function testOrderByClauseSupportsFunction(): void ); } - /** @group DDC-1719 */ + #[Group('DDC-1719')] public function testStripNonAlphanumericCharactersFromAlias(): void { $this->assertSqlGeneration( @@ -1876,7 +1862,7 @@ public function testStripNonAlphanumericCharactersFromAlias(): void ); } - /** @group DDC-2435 */ + #[Group('DDC-2435')] public function testColumnNameWithNumbersAndNonAlphanumericCharacters(): void { $this->assertSqlGeneration( @@ -1895,7 +1881,7 @@ public function testColumnNameWithNumbersAndNonAlphanumericCharacters(): void ); } - /** @group DDC-1845 */ + #[Group('DDC-1845')] public function testQuotedTableDeclaration(): void { $this->assertSqlGeneration( @@ -1904,7 +1890,7 @@ public function testQuotedTableDeclaration(): void ); } - /** @group DDC-1845 */ + #[Group('DDC-1845')] public function testQuotedWalkJoinVariableDeclaration(): void { $this->assertSqlGeneration( @@ -1938,7 +1924,7 @@ public function testQuotedWalkJoinVariableDeclaration(): void ); } - /** @group DDC-2208 */ + #[Group('DDC-2208')] public function testCaseThenParameterArithmeticExpression(): void { $this->assertSqlGeneration( @@ -1957,7 +1943,7 @@ public function testCaseThenParameterArithmeticExpression(): void ); } - /** @group DDC-2268 */ + #[Group('DDC-2268')] public function testCaseThenFunction(): void { $this->assertSqlGeneration( @@ -1976,7 +1962,7 @@ public function testCaseThenFunction(): void ); } - /** @group DDC-2268 */ + #[Group('DDC-2268')] public function testSupportsMoreThanTwoParametersInConcatFunction(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); @@ -1991,7 +1977,7 @@ public function testSupportsMoreThanTwoParametersInConcatFunction(): void ); } - /** @group DDC-2188 */ + #[Group('DDC-2188')] public function testArithmeticPriority(): void { $this->assertSqlGeneration( @@ -2010,7 +1996,7 @@ public function testArithmeticPriority(): void ); } - /** @group DDC-2475 */ + #[Group('DDC-2475')] public function testOrderByClauseShouldReplaceOrderByRelationMapping(): void { $this->assertSqlGeneration( @@ -2024,7 +2010,7 @@ public function testOrderByClauseShouldReplaceOrderByRelationMapping(): void ); } - /** @group DDC-1858 */ + #[Group('DDC-1858')] public function testHavingSupportIsNullExpression(): void { $this->assertSqlGeneration( @@ -2038,7 +2024,7 @@ public function testHavingSupportIsNullExpression(): void ); } - /** @group DDC-2506 */ + #[Group('DDC-2506')] public function testClassTableInheritanceJoinWithConditionAppliesToBaseTable(): void { $this->assertSqlGeneration( @@ -2048,7 +2034,7 @@ public function testClassTableInheritanceJoinWithConditionAppliesToBaseTable(): ); } - /** @group DDC-2235 */ + #[Group('DDC-2235')] public function testSingleTableInheritanceLeftJoinWithCondition(): void { // Regression test for the bug @@ -2058,7 +2044,7 @@ public function testSingleTableInheritanceLeftJoinWithCondition(): void ); } - /** @group DDC-2235 */ + #[Group('DDC-2235')] public function testSingleTableInheritanceLeftJoinWithConditionAndWhere(): void { // Ensure other WHERE predicates are passed through to the main WHERE clause @@ -2068,7 +2054,7 @@ public function testSingleTableInheritanceLeftJoinWithConditionAndWhere(): void ); } - /** @group DDC-2235 */ + #[Group('DDC-2235')] public function testSingleTableInheritanceInnerJoinWithCondition(): void { // Test inner joins too @@ -2078,7 +2064,7 @@ public function testSingleTableInheritanceInnerJoinWithCondition(): void ); } - /** @group DDC-2235 */ + #[Group('DDC-2235')] public function testSingleTableInheritanceLeftJoinNonAssociationWithConditionAndWhere(): void { // Test that the discriminator IN() predicate is still added into @@ -2089,7 +2075,7 @@ public function testSingleTableInheritanceLeftJoinNonAssociationWithConditionAnd ); } - /** @group DDC-2235 */ + #[Group('DDC-2235')] public function testSingleTableInheritanceJoinCreatesOnCondition(): void { // Test that the discriminator IN() predicate is still added @@ -2101,7 +2087,7 @@ public function testSingleTableInheritanceJoinCreatesOnCondition(): void ); } - /** @group DDC-2235 */ + #[Group('DDC-2235')] public function testSingleTableInheritanceCreatesOnConditionAndWhere(): void { // Test that when joining onto an entity using single table inheritance via @@ -2115,7 +2101,7 @@ public function testSingleTableInheritanceCreatesOnConditionAndWhere(): void ); } - /** @group DDC-1858 */ + #[Group('DDC-1858')] public function testHavingSupportResultVariableInExpression(): void { $this->assertSqlGeneration( @@ -2124,7 +2110,7 @@ public function testHavingSupportResultVariableInExpression(): void ); } - /** @group DDC-1858 */ + #[Group('DDC-1858')] public function testHavingSupportResultVariableLikeExpression(): void { $this->assertSqlGeneration( @@ -2133,7 +2119,7 @@ public function testHavingSupportResultVariableLikeExpression(): void ); } - /** @group DDC-3085 */ + #[Group('DDC-3085')] public function testHavingSupportResultVariableNullComparisonExpression(): void { $this->assertSqlGeneration( @@ -2142,7 +2128,7 @@ public function testHavingSupportResultVariableNullComparisonExpression(): void ); } - /** @group DDC-1858 */ + #[Group('DDC-1858')] public function testHavingSupportResultVariableInAggregateFunction(): void { $this->assertSqlGeneration( @@ -2153,10 +2139,9 @@ public function testHavingSupportResultVariableInAggregateFunction(): void /** * GitHub issue #4764: https://github.com/doctrine/orm/issues/4764 - * - * @group DDC-3907 - * @dataProvider mathematicOperatorsProvider */ + #[DataProvider('mathematicOperatorsProvider')] + #[Group('DDC-3907')] public function testHavingRegressionUsingVariableWithMathOperatorsExpression($operator): void { $this->assertSqlGeneration( diff --git a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php index 92674525376..87daa3eba2e 100644 --- a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php @@ -8,12 +8,13 @@ use Doctrine\ORM\Query\ParserResult; use Doctrine\ORM\Query\SqlWalker; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests for {@see \Doctrine\ORM\Query\SqlWalker} - * - * @covers \Doctrine\ORM\Query\SqlWalker */ +#[CoversClass(SqlWalker::class)] class SqlWalkerTest extends OrmTestCase { private SqlWalker $sqlWalker; @@ -23,13 +24,13 @@ protected function setUp(): void $this->sqlWalker = new SqlWalker(new Query($this->getTestEntityManager()), new ParserResult(), []); } - /** @dataProvider getColumnNamesAndSqlAliases */ + #[DataProvider('getColumnNamesAndSqlAliases')] public function testGetSQLTableAlias($tableName, $expectedAlias): void { self::assertSame($expectedAlias, $this->sqlWalker->getSQLTableAlias($tableName)); } - /** @dataProvider getColumnNamesAndSqlAliases */ + #[DataProvider('getColumnNamesAndSqlAliases')] public function testGetSQLTableAliasIsSameForMultipleCalls($tableName): void { self::assertSame( diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php index e404e05fcd8..88b3e0b4bb9 100644 --- a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\Tests\DbalTypes\NegativeToPositiveType; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; /** * Test case for testing the saving and referencing of query identifiers. @@ -162,7 +163,7 @@ public function testSingleValuedAssociationFieldInSetClause(): void ); } - /** @group DDC-980 */ + #[Group('DDC-980')] public function testSubselectTableAliasReferencing(): void { $this->assertSqlGeneration( diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index c1c5bd4eecd..fbd39a93f99 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -19,6 +19,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; use function array_filter; @@ -487,7 +488,7 @@ public function testAddMultipleSameCriteriaWhere(): void self::assertNotNull($qb->getParameter('field_1')); } - /** @group DDC-2844 */ + #[Group('DDC-2844')] public function testAddCriteriaWhereWithMultipleParametersWithSameField(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -504,7 +505,7 @@ public function testAddCriteriaWhereWithMultipleParametersWithSameField(): void self::assertSame('value2', $qb->getParameter('field_1')->getValue()); } - /** @group DDC-2844 */ + #[Group('DDC-2844')] public function testAddCriteriaWhereWithMultipleParametersWithDifferentFields(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -521,7 +522,7 @@ public function testAddCriteriaWhereWithMultipleParametersWithDifferentFields(): self::assertSame('value2', $qb->getParameter('field2')->getValue()); } - /** @group DDC-2844 */ + #[Group('DDC-2844')] public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndDifferentProperties(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -538,7 +539,7 @@ public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndDiffere self::assertSame('value2', $qb->getParameter('field2')->getValue()); } - /** @group DDC-2844 */ + #[Group('DDC-2844')] public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndSameProperty(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -570,7 +571,7 @@ public function testAddCriteriaOrder(): void self::assertEquals('u.field DESC', (string) $orderBy[0]); } - /** @group DDC-3108 */ + #[Group('DDC-3108')] public function testAddCriteriaOrderOnJoinAlias(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -876,7 +877,7 @@ public function testResetAllDQLParts(): void self::assertCount(0, $qb->getDQLPart('orderBy')); } - /** @group DDC-867 */ + #[Group('DDC-867')] public function testDeepClone(): void { $qb = $this->entityManager->createQueryBuilder() @@ -894,7 +895,7 @@ public function testDeepClone(): void self::assertEquals(2, $expr->count(), 'Modifying the second query should affect the first one.'); } - /** @group DDC-3108 */ + #[Group('DDC-3108')] public function testAddCriteriaWhereWithJoinAlias(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -912,7 +913,7 @@ public function testAddCriteriaWhereWithJoinAlias(): void self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); } - /** @group DDC-3108 */ + #[Group('DDC-3108')] public function testAddCriteriaWhereWithDefaultAndJoinAlias(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -930,7 +931,7 @@ public function testAddCriteriaWhereWithDefaultAndJoinAlias(): void self::assertSame('value2', $qb->getParameter('alias2_field')->getValue()); } - /** @group DDC-3108 */ + #[Group('DDC-3108')] public function testAddCriteriaWhereOnJoinAliasWithDuplicateFields(): void { $qb = $this->entityManager->createQueryBuilder(); @@ -950,7 +951,7 @@ public function testAddCriteriaWhereOnJoinAliasWithDuplicateFields(): void self::assertSame('value3', $qb->getParameter('alias2_field_2')->getValue()); } - /** @group DDC-1933 */ + #[Group('DDC-1933')] public function testParametersAreCloned(): void { $originalQb = new QueryBuilder($this->entityManager); @@ -1013,7 +1014,7 @@ public function testBCAddJoinWithoutRootAlias(): void self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL()); } - /** @group DDC-1211 */ + #[Group('DDC-1211')] public function testEmptyStringLiteral(): void { $expr = $this->entityManager->getExpressionBuilder(); @@ -1025,7 +1026,7 @@ public function testEmptyStringLiteral(): void self::assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL()); } - /** @group DDC-1211 */ + #[Group('DDC-1211')] public function testEmptyNumericLiteral(): void { $expr = $this->entityManager->getExpressionBuilder(); @@ -1037,7 +1038,7 @@ public function testEmptyNumericLiteral(): void self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL()); } - /** @group DDC-1227 */ + #[Group('DDC-1227')] public function testAddFromString(): void { $qb = $this->entityManager->createQueryBuilder() @@ -1047,7 +1048,7 @@ public function testAddFromString(): void self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); } - /** @group DDC-1619 */ + #[Group('DDC-1619')] public function testAddDistinct(): void { $qb = $this->entityManager->createQueryBuilder() @@ -1058,7 +1059,7 @@ public function testAddDistinct(): void self::assertEquals('SELECT DISTINCT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); } - /** @group DDC-2192 */ + #[Group('DDC-2192')] public function testWhereAppend(): void { $this->expectException(InvalidArgumentException::class); @@ -1108,7 +1109,7 @@ public function testSecondLevelCacheQueryBuilderOptions(): void self::assertEquals(Cache::MODE_REFRESH, $query->getCacheMode()); } - /** @group DDC-2253 */ + #[Group('DDC-2253')] public function testRebuildsFromParts(): void { $qb = $this->entityManager->createQueryBuilder() @@ -1151,7 +1152,7 @@ public function testGetAllAliasesWithJoins(): void self::assertEquals(['u', 'g'], $aliases); } - /** @group 6699 */ + #[Group('6699')] public function testGetParameterTypeJuggling(): void { $builder = $this->entityManager->createQueryBuilder() @@ -1166,7 +1167,7 @@ public function testGetParameterTypeJuggling(): void self::assertSame(0, $builder->getParameter('0')->getValue()); } - /** @group 6699 */ + #[Group('6699')] public function testSetParameterWithNameZeroIsNotOverridden(): void { $builder = $this->entityManager->createQueryBuilder() @@ -1183,7 +1184,7 @@ public function testSetParameterWithNameZeroIsNotOverridden(): void self::assertSame('Doctrine', $builder->getParameter('name')->getValue()); } - /** @group 6699 */ + #[Group('6699')] public function testSetParameterWithNameZeroDoesNotOverrideAnotherParameter(): void { $builder = $this->entityManager->createQueryBuilder() @@ -1200,7 +1201,7 @@ public function testSetParameterWithNameZeroDoesNotOverrideAnotherParameter(): v self::assertSame('Doctrine', $builder->getParameter('name')->getValue()); } - /** @group 6699 */ + #[Group('6699')] public function testSetParameterWithTypeJugglingWorks(): void { $builder = $this->entityManager->createQueryBuilder() diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index 4827ed33e8e..31abca36f83 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -11,14 +11,14 @@ use Doctrine\Tests\Models\DDC753\DDC753DefaultRepository; use Doctrine\Tests\Models\DDC753\DDC753EntityWithDefaultCustomRepository; use Doctrine\Tests\Models\DDC869\DDC869PaymentRepository; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** * Tests for {@see \Doctrine\ORM\Repository\DefaultRepositoryFactory} - * - * @covers \Doctrine\ORM\Repository\DefaultRepositoryFactory */ +#[CoversClass(DefaultRepositoryFactory::class)] class DefaultRepositoryFactoryTest extends TestCase { private EntityManagerInterface&MockObject $entityManager; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php index 0913bd2350b..f3992f68ef8 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php @@ -8,10 +8,11 @@ use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class ClearCacheCollectionRegionCommandTest extends OrmFunctionalTestCase { private Application $application; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php index c5df23ab400..ab138725572 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php @@ -8,13 +8,14 @@ use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use function preg_replace; use function trim; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class ClearCacheEntityRegionCommandTest extends OrmFunctionalTestCase { private Application $application; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php index a1215758305..c2b467fb2dd 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php @@ -7,10 +7,11 @@ use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** @group DDC-2183 */ +#[Group('DDC-2183')] class ClearCacheQueryRegionCommandTest extends OrmFunctionalTestCase { private Application $application; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php index 383509b5e7f..14174f4177d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php @@ -9,14 +9,14 @@ use Doctrine\Tests\Models\Cache\AttractionInfo; use Doctrine\Tests\OrmFunctionalTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; /** * Tests for {@see \Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand} - * - * @covers \Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand */ +#[CoversClass(MappingDescribeCommand::class)] class MappingDescribeCommandTest extends OrmFunctionalTestCase { private Application $application; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php index 9903ea422f9..28795c05254 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -15,9 +16,8 @@ /** * Tests for {@see \Doctrine\ORM\Tools\Console\Command\RunDqlCommand} - * - * @covers \Doctrine\ORM\Tools\Console\Command\RunDqlCommand */ +#[CoversClass(RunDqlCommand::class)] class RunDqlCommandTest extends OrmFunctionalTestCase { private Application $application; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php index 83c68b62a16..ac728a16658 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php @@ -5,10 +5,11 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command\SchemaTool; use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; class CreateCommandTest extends CommandTestCase { - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testItPrintsTheSql(): void { $tester = $this->getCommandTester(CreateCommand::class); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php index f032ae729b0..22fce5e9371 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php @@ -6,10 +6,11 @@ use Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand; use Doctrine\Tests\ORM\Tools\Console\Command\SchemaTool\Models\Keyboard; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; final class DropCommandTest extends CommandTestCase { - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testItPrintsTheSql(): void { $this->createSchemaForModels(Keyboard::class); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php index 701643cbe07..7b55129cf08 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php @@ -6,12 +6,14 @@ use Doctrine\DBAL\Schema\SchemaDiff; use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use function method_exists; class UpdateCommandTest extends CommandTestCase { - /** @doesNotPerformAssertions */ + #[DoesNotPerformAssertions] public function testItPrintsTheSql(): void { if (! method_exists(SchemaDiff::class, 'toSaveSql')) { @@ -27,7 +29,7 @@ public function testItPrintsTheSql(): void self::$sharedConn->executeStatement($tester->getDisplay()); } - /** @dataProvider getCasesForWarningMessageFromCompleteOption */ + #[DataProvider('getCasesForWarningMessageFromCompleteOption')] public function testWarningMessageFromCompleteOption(string|null $name, string $expectedMessage): void { if (! method_exists(SchemaDiff::class, 'toSaveSql')) { diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php index 2385e071c07..d17347b242d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php @@ -9,6 +9,7 @@ use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand; use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use Symfony\Component\Console\Application; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; @@ -17,9 +18,8 @@ /** * Tests for {@see \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand} - * - * @covers \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand */ +#[CoversClass(ValidateSchemaCommand::class)] class ValidateSchemaCommandTest extends OrmFunctionalTestCase { private ValidateSchemaCommand $command; diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php index 2bc179345f0..7d79068adbd 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php @@ -9,14 +9,14 @@ use Doctrine\ORM\Tools\Console\ConsoleRunner; use Doctrine\ORM\Tools\Console\EntityManagerProvider; use Doctrine\Tests\DoctrineTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\Console\Command\Command; use function class_exists; -/** - * @group DDC-3186 - * @covers \Doctrine\ORM\Tools\Console\ConsoleRunner - */ +#[CoversClass(ConsoleRunner::class)] +#[Group('DDC-3186')] final class ConsoleRunnerTest extends DoctrineTestCase { public function testCreateApplicationShouldReturnAnApplicationWithTheCorrectCommands(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php index f99db43463e..5db5f94bf5c 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php @@ -10,14 +10,14 @@ use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Tools\Console\MetadataFilter; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\CoversClass; use function count; /** * Tests for {@see \Doctrine\ORM\Tools\Console\MetadataFilter} - * - * @covers \Doctrine\ORM\Tools\Console\MetadataFilter */ +#[CoversClass(MetadataFilter::class)] class MetadataFilterTest extends OrmTestCase { private ClassMetadataFactory $cmf; diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index 99c3f647bc9..804cb54cf93 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -6,9 +6,10 @@ use Doctrine\ORM\Query; use Doctrine\ORM\Tools\Pagination\CountWalker; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; -/** @group DDC-1613 */ +#[Group('DDC-1613')] class CountWalkerTest extends PaginationTestCase { public function testCountQuery(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index dc59fe0d784..2b96e7f5b7f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\Query; use Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker; +use PHPUnit\Framework\Attributes\Group; final class LimitSubqueryOutputWalkerTest extends PaginationTestCase { @@ -180,7 +181,7 @@ public function testCountQueryMixedResultsWithName(): void ); } - /** @group DDC-3336 */ + #[Group('DDC-3336')] public function testCountQueryWithArithmeticOrderByCondition(): void { $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); @@ -261,7 +262,7 @@ public function testCountQueryWithComplexScalarOrderByItemOracle(): void ); } - /** @group DDC-3434 */ + #[Group('DDC-3434')] public function testLimitSubqueryWithHiddenSelectionInOrderBy(): void { $query = $this->entityManager->createQuery( diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php index 87fa03b5ca9..af8555a596e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php @@ -6,8 +6,9 @@ use Doctrine\ORM\Query; use Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1613 */ +#[Group('DDC-1613')] class LimitSubqueryWalkerTest extends PaginationTestCase { public function testLimitSubquery(): void @@ -94,7 +95,7 @@ public function testAggQueryMultipleMixedResultsWithSort(): void ); } - /** @group DDC-2890 */ + #[Group('DDC-2890')] public function testLimitSubqueryWithSortOnAssociation(): void { $dql = 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p ORDER BY p.author'; diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php index ae70e601f7b..11282b0b768 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php @@ -11,6 +11,7 @@ use Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity; use Doctrine\Tests\Models\ValueConversionType\OwningManyToOneIdForeignKeyEntity; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; class RootTypeWalkerTest extends PaginationTestCase { @@ -23,7 +24,7 @@ protected function setUp(): void } } - /** @dataProvider exampleQueries */ + #[DataProvider('exampleQueries')] public function testResolveTypeMapping(string $dqlQuery, string $expectedType): void { $query = $this->entityManager->createQuery($dqlQuery); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php index 3d5786ca43f..b017ba8de6e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php @@ -8,11 +8,13 @@ use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Tools\Pagination\WhereInWalker; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; -/** @group DDC-1613 */ +#[Group('DDC-1613')] class WhereInWalkerTest extends PaginationTestCase { - /** @dataProvider exampleQueries */ + #[DataProvider('exampleQueries')] public function testDqlQueryTransformation(string $dql, string $expectedSql): void { $query = $this->entityManager->createQuery($dql); diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index 7f045afdc32..0d9d959105d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -19,6 +19,8 @@ use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Tools\ResolveTargetEntityListener; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\CoversNothing; +use PHPUnit\Framework\Attributes\Group; class ResolveTargetEntityListenerTest extends OrmTestCase { @@ -36,7 +38,7 @@ protected function setUp(): void $this->listener = new ResolveTargetEntityListener(); } - /** @group DDC-1544 */ + #[Group('DDC-1544')] public function testResolveTargetEntityListenerCanResolveTargetEntity(): void { $evm = $this->em->getEventManager(); @@ -55,11 +57,9 @@ public function testResolveTargetEntityListenerCanResolveTargetEntity(): void self::assertSame($cm, $this->factory->getMetadataFor(ResolveTarget::class)); } - /** - * @group DDC-3385 - * @group 1181 - * @group 385 - */ + #[Group('DDC-3385')] + #[Group('1181')] + #[Group('385')] public function testResolveTargetEntityListenerCanRetrieveTargetEntityByInterfaceName(): void { $this->listener->addResolveTargetEntity(ResolveTarget::class, ResolveTargetEntity::class, []); @@ -71,7 +71,7 @@ public function testResolveTargetEntityListenerCanRetrieveTargetEntityByInterfac self::assertSame($this->factory->getMetadataFor(ResolveTargetEntity::class), $cm); } - /** @group DDC-2109 */ + #[Group('DDC-2109')] public function testAssertTableColumnsAreNotAddedInManyToMany(): void { $evm = $this->em->getEventManager(); @@ -86,11 +86,9 @@ public function testAssertTableColumnsAreNotAddedInManyToMany(): void self::assertEquals(['resolvetargetentity_id', 'target_id'], $meta['joinTableColumns']); } - /** - * @group 1572 - * @group functional - * @coversNothing - */ + #[CoversNothing] + #[Group('1572')] + #[Group('functional')] public function testDoesResolveTargetEntitiesInDQLAlsoWithInterfaces(): void { $evm = $this->em->getEventManager(); diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index d05274db6ec..c951f7316c0 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -40,6 +40,8 @@ use Doctrine\Tests\Models\Forum\ForumUser; use Doctrine\Tests\Models\NullDefault\NullDefaultColumn; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhp; use function count; use function current; @@ -85,7 +87,7 @@ public function testAttributeOptionsArgument(): void } } - /** @group DDC-200 */ + #[Group('DDC-200')] public function testPassColumnDefinitionToJoinColumn(): void { $customColumnDef = 'MEDIUMINT(6) UNSIGNED NOT NULL'; @@ -107,7 +109,7 @@ public function testPassColumnDefinitionToJoinColumn(): void self::assertEquals($customColumnDef, $table->getColumn('avatar_id')->getColumnDefinition()); } - /** @group 6830 */ + #[Group('6830')] public function testPassColumnOptionsToJoinColumn(): void { $em = $this->getTestEntityManager(); @@ -143,7 +145,7 @@ public function testPassColumnOptionsToJoinColumn(): void ); } - /** @group DDC-283 */ + #[Group('DDC-283')] public function testPostGenerateEvents(): void { $listener = new GenerateSchemaEventListener(); @@ -182,7 +184,7 @@ public function testNullDefaultNotAddedToPlatformOptions(): void ->getPlatformOptions()); } - /** @requires PHP 8.1 */ + #[RequiresPhp('8.1')] public function testEnumTypeAddedToCustomSchemaOptions(): void { $em = $this->getTestEntityManager(); @@ -197,7 +199,7 @@ public function testEnumTypeAddedToCustomSchemaOptions(): void self::assertSame(Suit::class, $platformOptions['enumType']); } - /** @group DDC-3671 */ + #[Group('DDC-3671')] public function testSchemaHasProperIndexesFromUniqueConstraintAttribute(): void { $em = $this->getTestEntityManager(); @@ -345,7 +347,7 @@ public function testIncorrectUniqueConstraintsBasedOnFields(): void $schemaTool->getSchemaFromMetadata([$class]); } - /** @group schema-configuration */ + #[Group('schema-configuration')] public function testConfigurationSchemaIgnoredEntity(): void { $em = $this->getTestEntityManager(); diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 92530dfbfe3..bca2305f8c1 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -27,6 +27,8 @@ use Doctrine\ORM\Tools\SchemaValidator; use Doctrine\Tests\Models\ECommerce\ECommerceCart; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; class SchemaValidatorTest extends OrmTestCase { @@ -40,7 +42,7 @@ protected function setUp(): void $this->validator = new SchemaValidator($this->em); } - /** @dataProvider modelSetProvider */ + #[DataProvider('modelSetProvider')] public function testCmsModelSet(string $path): void { $this->em->getConfiguration() @@ -62,7 +64,7 @@ public static function modelSetProvider(): array ]; } - /** @group DDC-1439 */ + #[Group('DDC-1439')] public function testInvalidManyToManyJoinColumnSchema(): void { $class1 = $this->em->getClassMetadata(InvalidEntity1::class); @@ -79,7 +81,7 @@ public function testInvalidManyToManyJoinColumnSchema(): void ); } - /** @group DDC-1439 */ + #[Group('DDC-1439')] public function testInvalidToOneJoinColumnSchema(): void { $class1 = $this->em->getClassMetadata(InvalidEntity1::class); @@ -96,7 +98,7 @@ public function testInvalidToOneJoinColumnSchema(): void ); } - /** @group DDC-1587 */ + #[Group('DDC-1587')] public function testValidOneToOneAsIdentifierSchema(): void { $class1 = $this->em->getClassMetadata(DDC1587ValidEntity2::class); @@ -107,7 +109,7 @@ public function testValidOneToOneAsIdentifierSchema(): void self::assertEquals([], $ce); } - /** @group DDC-1649 */ + #[Group('DDC-1649')] public function testInvalidTripleAssociationAsKeyMapping(): void { $classThree = $this->em->getClassMetadata(DDC1649Three::class); @@ -122,7 +124,7 @@ public function testInvalidTripleAssociationAsKeyMapping(): void ); } - /** @group DDC-3274 */ + #[Group('DDC-3274')] public function testInvalidBiDirectionalRelationMappingMissingInversedByAttribute(): void { $class = $this->em->getClassMetadata(DDC3274One::class); @@ -138,7 +140,7 @@ public function testInvalidBiDirectionalRelationMappingMissingInversedByAttribut ); } - /** @group 9536 */ + #[Group('9536')] public function testInvalidBiDirectionalRelationMappingMissingMappedByAttribute(): void { $class = $this->em->getClassMetadata(Issue9536Owner::class); @@ -155,7 +157,7 @@ public function testInvalidBiDirectionalRelationMappingMissingMappedByAttribute( ); } - /** @group DDC-3322 */ + #[Group('DDC-3322')] public function testInvalidOrderByInvalidField(): void { $class = $this->em->getClassMetadata(DDC3322One::class); @@ -170,7 +172,7 @@ public function testInvalidOrderByInvalidField(): void ); } - /** @group DDC-3322 */ + #[Group('DDC-3322')] public function testInvalidOrderByCollectionValuedAssociation(): void { $class = $this->em->getClassMetadata(DDC3322Two::class); @@ -185,7 +187,7 @@ public function testInvalidOrderByCollectionValuedAssociation(): void ); } - /** @group DDC-3322 */ + #[Group('DDC-3322')] public function testInvalidOrderByAssociationInverseSide(): void { $class = $this->em->getClassMetadata(DDC3322Three::class); @@ -200,7 +202,7 @@ public function testInvalidOrderByAssociationInverseSide(): void ); } - /** @group 8052 */ + #[Group('8052')] public function testInvalidAssociationInsideEmbeddable(): void { $class = $this->em->getClassMetadata(EmbeddableWithAssociation::class); @@ -212,7 +214,7 @@ public function testInvalidAssociationInsideEmbeddable(): void ); } - /** @group 8771 */ + #[Group('8771')] public function testMappedSuperclassNotPresentInDiscriminator(): void { $class1 = $this->em->getClassMetadata(MappedSuperclassEntity::class); diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 4d61c12444c..a2186b6638e 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -33,6 +33,8 @@ use Doctrine\Tests\Models\Forum\ForumAvatar; use Doctrine\Tests\Models\Forum\ForumUser; use Doctrine\Tests\OrmTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use stdClass; @@ -276,10 +278,8 @@ public function testNoUndefinedIndexNoticeOnScheduleForUpdateWithoutChanges(): v self::assertEmpty($this->_unitOfWork->getScheduledEntityUpdates()); } - /** - * @group DDC-3490 - * @dataProvider invalidAssociationValuesDataProvider - */ + #[DataProvider('invalidAssociationValuesDataProvider')] + #[Group('DDC-3490')] public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue(mixed $invalidValue): void { $this->_unitOfWork->setEntityPersister( @@ -299,10 +299,8 @@ public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue(mixed $this->_unitOfWork->persist($user); } - /** - * @group DDC-3490 - * @dataProvider invalidAssociationValuesDataProvider - */ + #[DataProvider('invalidAssociationValuesDataProvider')] + #[Group('DDC-3490')] public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationValue(mixed $invalidValue): void { $metadata = $this->_emMock->getClassMetadata(ForumUser::class); @@ -324,10 +322,8 @@ public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationV $this->_unitOfWork->computeChangeSet($metadata, $user); } - /** - * @group DDC-3619 - * @group 1338 - */ + #[Group('DDC-3619')] + #[Group('1338')] public function testRemovedAndRePersistedEntitiesAreInTheIdentityMapAndAreNotGarbageCollected(): void { $entity = new ForumUser(); @@ -360,7 +356,7 @@ public static function invalidAssociationValuesDataProvider(): array ]; } - /** @dataProvider entitiesWithValidIdentifiersProvider */ + #[DataProvider('entitiesWithValidIdentifiersProvider')] public function testAddToIdentityMapValidIdentifiers(object $entity, string $idHash): void { $this->_unitOfWork->persist($entity); @@ -415,11 +411,8 @@ public function testRegisteringAManagedInstanceRequiresANonEmptyIdentifier(): vo $this->_unitOfWork->registerManaged(new EntityWithBooleanIdentifier(), [], []); } - /** - * @param array $identifier - * - * @dataProvider entitiesWithInvalidIdentifiersProvider - */ + /** @param array $identifier */ + #[DataProvider('entitiesWithInvalidIdentifiersProvider')] public function testAddToIdentityMapInvalidIdentifiers(object $entity, array $identifier): void { $this->expectException(ORMInvalidArgumentException::class); @@ -449,10 +442,9 @@ public static function entitiesWithInvalidIdentifiersProvider(): array /** * Unlike next test, this one demonstrates that the problem does * not necessarily reproduce if all the pieces are being flushed together. - * - * @group DDC-2922 - * @group #1521 */ + #[Group('DDC-2922')] + #[Group('#1521')] public function testNewAssociatedEntityPersistenceOfNewEntitiesThroughCascadedAssociationsFirst(): void { $persister1 = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(CascadePersistedEntity::class)); @@ -486,10 +478,9 @@ public function testNewAssociatedEntityPersistenceOfNewEntitiesThroughCascadedAs /** * This test exhibits the bug describe in the ticket, where an object that * ought to be reachable causes errors. - * - * @group DDC-2922 - * @group #1521 */ + #[Group('DDC-2922')] + #[Group('#1521')] public function testNewAssociatedEntityPersistenceOfNewEntitiesThroughNonCascadedAssociationsFirst(): void { $persister1 = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(CascadePersistedEntity::class)); @@ -537,10 +528,9 @@ public function testNewAssociatedEntityPersistenceOfNewEntitiesThroughNonCascade /** * This test exhibits the bug describe in the ticket, where an object that * ought to be reachable causes errors. - * - * @group DDC-2922 - * @group #1521 */ + #[Group('DDC-2922')] + #[Group('#1521')] public function testPreviousDetectedIllegalNewNonCascadedEntitiesAreCleanedUpOnSubsequentCommits(): void { $persister1 = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(CascadePersistedEntity::class)); @@ -574,7 +564,7 @@ public function testPreviousDetectedIllegalNewNonCascadedEntitiesAreCleanedUpOnS self::assertCount(0, $persister2->getInserts()); } - /** @group #7946 Throw OptimisticLockException when connection::commit() returns false. */ + #[Group('#7946')] // Throw OptimisticLockException when connection::commit() returns false. public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails(): void { $platform = $this->getMockBuilder(AbstractPlatform::class) diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php index 150080fc37c..46532e571c5 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php @@ -4,18 +4,21 @@ namespace Doctrine\Tests\ORM\Utility; +use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\Tests\Models\Enums\Suit; use Doctrine\Tests\Models\Enums\TypedCardEnumCompositeId; use Doctrine\Tests\Models\Enums\TypedCardEnumId; use Doctrine\Tests\Models\Enums\Unit; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhp; /** * Test the IdentifierFlattener utility class - * - * @requires PHP 8.1 - * @covers \Doctrine\ORM\Utility\IdentifierFlattener */ +#[CoversClass(IdentifierFlattener::class)] +#[RequiresPhp('8.1')] class IdentifierFlattenerEnumIdTest extends OrmFunctionalTestCase { protected function setUp(): void @@ -28,7 +31,7 @@ protected function setUp(): void ); } - /** @group utilities */ + #[Group('utilities')] public function testFlattenIdentifierWithEnumId(): void { $typedCardEnumIdEntity = new TypedCardEnumId(); @@ -55,7 +58,7 @@ public function testFlattenIdentifierWithEnumId(): void self::assertEquals(Suit::Clubs, $findTypedCardEnumIdEntity->suit); } - /** @group utilities */ + #[Group('utilities')] public function testFlattenIdentifierWithCompositeEnumId(): void { $typedCardEnumCompositeIdEntity = new TypedCardEnumCompositeId(); diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php index 7f2041e59de..aa5f6b87c9c 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php @@ -10,12 +10,13 @@ use Doctrine\Tests\Models\VersionedOneToOne\FirstRelatedEntity; use Doctrine\Tests\Models\VersionedOneToOne\SecondRelatedEntity; use Doctrine\Tests\OrmFunctionalTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; /** * Test the IdentifierFlattener utility class - * - * @covers \Doctrine\ORM\Utility\IdentifierFlattener */ +#[CoversClass(IdentifierFlattener::class)] class IdentifierFlattenerTest extends OrmFunctionalTestCase { /** @@ -40,7 +41,7 @@ protected function setUp(): void ); } - /** @group utilities */ + #[Group('utilities')] public function testFlattenIdentifierWithOneToOneId(): void { $secondRelatedEntity = new SecondRelatedEntity(); @@ -82,7 +83,7 @@ public function testFlattenIdentifierWithOneToOneId(): void self::assertEquals($id['secondEntity']->id, $flatIds['secondEntity']); } - /** @group utilities */ + #[Group('utilities')] public function testFlattenIdentifierWithMutlipleIds(): void { $leeds = new City('Leeds'); From 7568328a6dc2e7ddd5fb72447a3f328f7d49c9f6 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 6 Mar 2023 12:02:16 +0100 Subject: [PATCH 233/475] Forbid PHPUnit annotations (#10567) --- phpcs.xml.dist | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index ae1e544ecd8..50055c191aa 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -116,6 +116,36 @@ lib/Doctrine/ORM/Cache/DefaultQueryCache.php + + + + + + + + + + + + + + + + + + + + + + + + + + + lib/Doctrine/ORM/EntityManagerInterface.php From cc72796fffb13a18e1316d0ce5df4627f53bba37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 17 Apr 2018 22:45:06 +0200 Subject: [PATCH 234/475] Inherit from homonym exception in parent package This means that a class implementing a doctrine/persistence interface or extending a class from that package can throw a specialized exception that will still be caught by code in the parent package. --- lib/Doctrine/ORM/Mapping/MappingException.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 3712a2d7a0d..d16c47b40a4 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -6,7 +6,7 @@ use BackedEnum; use Doctrine\ORM\Exception\ORMException; -use Exception; +use Doctrine\Persistence\Mapping\MappingException as PersistenceMappingException; use LibXMLError; use ReflectionException; use ValueError; @@ -24,7 +24,7 @@ /** * A MappingException indicates that something is wrong with the mapping setup. */ -class MappingException extends Exception implements ORMException +class MappingException extends PersistenceMappingException implements ORMException { /** @param class-string $entityName */ public static function identifierRequired(string $entityName): self From ebfab93d15eda693cad9b007bed12c399e44cad6 Mon Sep 17 00:00:00 2001 From: Claudio Zizza <859964+SenseException@users.noreply.github.com> Date: Fri, 24 Mar 2023 23:22:36 +0100 Subject: [PATCH 235/475] Remove contradictory comment ORMException is an interface in 3.0 already --- lib/Doctrine/ORM/Exception/ORMException.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/Doctrine/ORM/Exception/ORMException.php b/lib/Doctrine/ORM/Exception/ORMException.php index 4cd88eb9040..a59b48354eb 100644 --- a/lib/Doctrine/ORM/Exception/ORMException.php +++ b/lib/Doctrine/ORM/Exception/ORMException.php @@ -6,9 +6,6 @@ use Throwable; -/** - * Should become an interface in 3.0 - */ interface ORMException extends Throwable { } From e8376b399589f84c4cec19350f6fb5dec673d1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 7 Mar 2023 09:08:27 +0100 Subject: [PATCH 236/475] Create array access implementation We are going to have many DTOs, all of which will need an array access implementation as a backward compatibility layer. --- .../ORM/Mapping/ArrayAccessImplementation.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/Doctrine/ORM/Mapping/ArrayAccessImplementation.php diff --git a/lib/Doctrine/ORM/Mapping/ArrayAccessImplementation.php b/lib/Doctrine/ORM/Mapping/ArrayAccessImplementation.php new file mode 100644 index 00000000000..e740db8409e --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ArrayAccessImplementation.php @@ -0,0 +1,41 @@ +$offset); + } + + /** @param string $offset */ + public function offsetGet(mixed $offset): mixed + { + if (! property_exists($this, $offset)) { + throw new InvalidArgumentException('Undefined property: ' . $offset); + } + + return $this->$offset; + } + + /** @param string $offset */ + public function offsetSet(mixed $offset, mixed $value): void + { + $this->$offset = $value; + } + + /** @param string $offset */ + public function offsetUnset(mixed $offset): void + { + $this->$offset = null; + } +} From 175cdefd6753d91484476b60aad4d6b90f1fc013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 17 Jan 2023 19:49:53 +0100 Subject: [PATCH 237/475] Extract FieldMapping in its own DTO In the past, it has been decided to use arrays for this out of legitimate performance concerns. But PHP has evolved, and now, it is more performant and memory efficient to use objects. --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 104 ++----------- .../ORM/Mapping/ClassMetadataFactory.php | 8 +- lib/Doctrine/ORM/Mapping/FieldMapping.php | 142 ++++++++++++++++++ .../Entity/BasicEntityPersister.php | 2 +- .../Command/MappingDescribeCommand.php | 4 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 6 +- lib/Doctrine/ORM/Utility/PersisterHelper.php | 2 +- psalm-baseline.xml | 8 +- .../ORM/Mapping/ClassMetadataBuilderTest.php | 24 ++- .../Tests/ORM/Mapping/FieldMappingTest.php | 70 +++++++++ 10 files changed, 251 insertions(+), 119 deletions(-) create mode 100644 lib/Doctrine/ORM/Mapping/FieldMapping.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 1e00a89d456..84a94237886 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -40,6 +40,7 @@ use function in_array; use function interface_exists; use function is_array; +use function is_string; use function is_subclass_of; use function ltrim; use function method_exists; @@ -66,32 +67,6 @@ * * @template-covariant T of object * @template-implements PersistenceClassMetadata - * @psalm-type FieldMapping = array{ - * type: string, - * fieldName: string, - * columnName: string, - * length?: int, - * id?: bool, - * nullable?: bool, - * notInsertable?: bool, - * notUpdatable?: bool, - * generated?: int, - * enumType?: class-string, - * columnDefinition?: string, - * precision?: int, - * scale?: int, - * unique?: bool, - * inherited?: class-string, - * originalClass?: class-string, - * originalField?: string, - * quoted?: bool, - * requireSQLConversion?: bool, - * declared?: class-string, - * declaredField?: string, - * options?: array, - * version?: string, - * default?: string|int, - * } * @psalm-type JoinColumnData = array{ * name: string, * referencedColumnName: string, @@ -442,65 +417,9 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable /** * READ-ONLY: The field mappings of the class. - * Keys are field names and values are mapping definitions. - * - * The mapping definition array has the following values: - * - * - fieldName (string) - * The name of the field in the Entity. - * - * - type (string) - * The type name of the mapped field. Can be one of Doctrine's mapping types - * or a custom mapping type. - * - * - columnName (string, optional) - * The column name. Optional. Defaults to the field name. - * - * - length (integer, optional) - * The database length of the column. Optional. Default value taken from - * the type. - * - * - id (boolean, optional) - * Marks the field as the primary key of the entity. Multiple fields of an - * entity can have the id attribute, forming a composite key. + * Keys are field names and values are FieldMapping instances * - * - nullable (boolean, optional) - * Whether the column is nullable. Defaults to FALSE. - * - * - 'notInsertable' (boolean, optional) - * Whether the column is not insertable. Optional. Is only set if value is TRUE. - * - * - 'notUpdatable' (boolean, optional) - * Whether the column is updatable. Optional. Is only set if value is TRUE. - * - * - columnDefinition (string, optional, schema-only) - * The SQL fragment that is used when generating the DDL for the column. - * - * - precision (integer, optional, schema-only) - * The precision of a decimal column. Only valid if the column type is decimal. - * - * - scale (integer, optional, schema-only) - * The scale of a decimal column. Only valid if the column type is decimal. - * - * - 'unique' (boolean, optional, schema-only) - * Whether a unique constraint should be generated for the column. - * - * - 'inherited' (string, optional) - * This is set when the field is inherited by this class from another (inheritance) parent - * entity class. The value is the FQCN of the topmost entity class that contains - * mapping information for this field. (If there are transient classes in the - * class hierarchy, these are ignored, so the class property may in fact come - * from a class further up in the PHP class hierarchy.) - * Fields initially declared in mapped superclasses are - * not considered 'inherited' in the nearest entity subclasses. - * - * - 'declared' (string, optional) - * This is set when the field does not appear for the first time in this class, but is originally - * declared in another parent entity or mapped superclass. The value is the FQCN - * of the topmost non-transient class that contains mapping information for this field. - * - * @var mixed[] - * @psalm-var array + * @var array */ public array $fieldMappings = []; @@ -1283,12 +1202,9 @@ public function getColumnName(string $fieldName): string * Gets the mapping of a (regular) field that holds some data but not a * reference to another object. * - * @return mixed[] The field mapping. - * @psalm-return FieldMapping - * * @throws MappingException */ - public function getFieldMapping(string $fieldName): array + public function getFieldMapping(string $fieldName): FieldMapping { if (! isset($this->fieldMappings[$fieldName])) { throw MappingException::mappingNotFound($this->name, $fieldName); @@ -1403,7 +1319,7 @@ private function validateAndCompleteTypedAssociationMapping(array $mapping): arr * * @throws MappingException */ - protected function validateAndCompleteFieldMapping(array $mapping): array + protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping { // Check mandatory fields if (! isset($mapping['fieldName']) || ! $mapping['fieldName']) { @@ -1424,6 +1340,8 @@ protected function validateAndCompleteFieldMapping(array $mapping): array $mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name); } + $mapping = FieldMapping::fromMappingArray($mapping); + if ($mapping['columnName'][0] === '`') { $mapping['columnName'] = trim($mapping['columnName'], '`'); $mapping['quoted'] = true; @@ -1535,6 +1453,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping): array ); } + assert(is_string($mapping['fieldName'])); $this->identifier[] = $mapping['fieldName']; $this->containsForeignIdentifier = true; } @@ -2338,10 +2257,8 @@ public function addInheritedAssociationMapping(array $mapping/*, $owningClassNam * INTERNAL: * Adds a field mapping without completing/validating it. * This is mainly used to add inherited field mappings to derived classes. - * - * @psalm-param FieldMapping $fieldMapping */ - public function addInheritedFieldMapping(array $fieldMapping): void + public function addInheritedFieldMapping(FieldMapping $fieldMapping): void { $this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping; $this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName']; @@ -2942,7 +2859,8 @@ public function mapEmbedded(array $mapping): void */ public function inlineEmbeddable(string $property, ClassMetadata $embeddable): void { - foreach ($embeddable->fieldMappings as $fieldMapping) { + foreach ($embeddable->fieldMappings as $originalFieldMapping) { + $fieldMapping = (array) $originalFieldMapping; $fieldMapping['originalClass'] ??= $embeddable->name; $fieldMapping['declaredField'] = isset($fieldMapping['declaredField']) ? $property . '.' . $fieldMapping['declaredField'] diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 3bad362d868..001d29cb3ae 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -47,7 +47,6 @@ * @extends AbstractClassMetadataFactory * @psalm-import-type AssociationMapping from ClassMetadata * @psalm-import-type EmbeddedClassMapping from ClassMetadata - * @psalm-import-type FieldMapping from ClassMetadata */ class ClassMetadataFactory extends AbstractClassMetadataFactory { @@ -388,7 +387,7 @@ private function getShortName(string $className): string * * @param AssociationMapping|EmbeddedClassMapping|FieldMapping $mapping */ - private function addMappingInheritanceInformation(array &$mapping, ClassMetadata $parentClass): void + private function addMappingInheritanceInformation(array|FieldMapping &$mapping, ClassMetadata $parentClass): void { if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { $mapping['inherited'] = $parentClass->name; @@ -405,8 +404,9 @@ private function addMappingInheritanceInformation(array &$mapping, ClassMetadata private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->fieldMappings as $mapping) { - $this->addMappingInheritanceInformation($mapping, $parentClass); - $subClass->addInheritedFieldMapping($mapping); + $subClassMapping = clone $mapping; + $this->addMappingInheritanceInformation($subClassMapping, $parentClass); + $subClass->addInheritedFieldMapping($subClassMapping); } foreach ($parentClass->reflFields as $name => $field) { diff --git a/lib/Doctrine/ORM/Mapping/FieldMapping.php b/lib/Doctrine/ORM/Mapping/FieldMapping.php new file mode 100644 index 00000000000..3e05eba9ec2 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/FieldMapping.php @@ -0,0 +1,142 @@ + */ +final class FieldMapping implements ArrayAccess +{ + use ArrayAccessImplementation; + + /** The database length of the column. Optional. Default value taken from the type. */ + public int|null $length = null; + /** + * Marks the field as the primary key of the entity. Multiple + * fields of an entity can have the id attribute, forming a composite key. + */ + public bool|null $id = null; + public bool|null $nullable = null; + public bool|null $notInsertable = null; + public bool|null $notUpdatable = null; + public string|null $columnDefinition = null; + /** @psalm-var ClassMetadata::GENERATED_* */ + public int|null $generated = null; + /** @var class-string|null */ + public string|null $enumType = null; + /** + * The precision of a decimal column. + * Only valid if the column type is decimal + */ + public int|null $precision = null; + /** + * The scale of a decimal column. + * Only valid if the column type is decimal + */ + public int|null $scale = null; + /** Whether a unique constraint should be generated for the column. */ + public bool|null $unique = null; + /** + * @var class-string|null This is set when the field is inherited by this + * class from another (inheritance) parent entity class. The value + * is the FQCN of the topmost entity class that contains mapping information + * for this field. (If there are transient classes in the class hierarchy, + * these are ignored, so the class property may in fact come from a class + * further up in the PHP class hierarchy.) + * Fields initially declared in mapped superclasses are + * not considered 'inherited' in the nearest entity subclasses. + */ + public string|null $inherited = null; + + public string|null $originalClass = null; + public string|null $originalField = null; + public bool|null $quoted = null; + /** + * @var class-string|null This is set when the field does not appear for + * the first time in this class, but is originally declared in another + * parent entity or mapped superclass. The value is the FQCN of + * the topmost non-transient class that contains mapping information for + * this field. + */ + public string|null $declared = null; + public string|null $declaredField = null; + public array|null $options = null; + public bool|null $version = null; + public string|int|null $default = null; + + /** + * @param string $type The type name of the mapped field. Can be one of + * Doctrine's mapping types or a custom mapping type. + * @param string $fieldName The name of the field in the Entity. + * @param string $columnName The column name. Optional. Defaults to the field name. + */ + public function __construct( + public string $type, + public string $fieldName, + public string $columnName, + ) { + } + + /** @param array{type: string, fieldName: string, columnName: string} $mappingArray */ + public static function fromMappingArray(array $mappingArray): self + { + $mapping = new self( + $mappingArray['type'], + $mappingArray['fieldName'], + $mappingArray['columnName'], + ); + foreach ($mappingArray as $key => $value) { + if (in_array($key, ['type', 'fieldName', 'columnName'])) { + continue; + } + + if (property_exists($mapping, $key)) { + $mapping->$key = $value; + } + } + + return $mapping; + } + + /** @return list */ + public function __sleep(): array + { + $serialized = ['type', 'fieldName', 'columnName']; + + foreach (['nullable', 'notInsertable', 'notUpdatable', 'id', 'unique', 'version', 'quoted'] as $boolKey) { + if ($this->$boolKey) { + $serialized[] = $boolKey; + } + } + + foreach ( + [ + 'length', + 'columnDefinition', + 'generated', + 'enumType', + 'precision', + 'scale', + 'inherited', + 'originalClass', + 'originalField', + 'declared', + 'declaredField', + 'options', + 'default', + ] as $key + ) { + if ($this->$key !== null) { + $serialized[] = $key; + } + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 666c594e295..1b36a3d53f6 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -1847,7 +1847,7 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar switch (true) { case isset($class->fieldMappings[$field]): - $types = array_merge($types, [$class->fieldMappings[$field]['type']]); + $types = array_merge($types, [$class->fieldMappings[$field]->type]); break; case isset($class->associationMappings[$field]): diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index be27e141ba8..25ec627476e 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -6,6 +6,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\FieldMapping; use Doctrine\Persistence\Mapping\MappingException; use InvalidArgumentException; use Symfony\Component\Console\Input\InputArgument; @@ -42,7 +43,6 @@ * @link www.doctrine-project.org * * @psalm-import-type AssociationMapping from ClassMetadata - * @psalm-import-type FieldMapping from ClassMetadata */ final class MappingDescribeCommand extends AbstractEntityManagerCommand { @@ -257,7 +257,7 @@ private function formatMappings(array $propertyMappings): array foreach ($propertyMappings as $propertyName => $mapping) { $output[] = $this->formatField(sprintf(' %s', $propertyName), ''); - foreach ($mapping as $field => $value) { + foreach ((array) $mapping as $field => $value) { $output[] = $this->formatField(sprintf(' %s', $field), $this->formatValue($value)); } } diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index bd4a11859eb..3da586ebd1f 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -15,6 +15,7 @@ use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\FieldMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; @@ -48,7 +49,6 @@ * * @psalm-import-type AssociationMapping from ClassMetadata * @psalm-import-type DiscriminatorColumnMapping from ClassMetadata - * @psalm-import-type FieldMapping from ClassMetadata * @psalm-import-type JoinColumnData from ClassMetadata */ class SchemaTool @@ -457,7 +457,7 @@ private function gatherColumns(ClassMetadata $class, Table $table): void */ private function gatherColumn( ClassMetadata $class, - array $mapping, + FieldMapping $mapping, Table $table, ): void { $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); @@ -776,7 +776,7 @@ private function gatherRelationJoinColumns( * * @return mixed[] */ - private function gatherColumnOptions(array $mapping): array + private function gatherColumnOptions(FieldMapping|array $mapping): array { $mappingOptions = $mapping['options'] ?? []; diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index 9eca8aa6613..eff5fd2daea 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -27,7 +27,7 @@ class PersisterHelper public static function getTypeOfField(string $fieldName, ClassMetadata $class, EntityManagerInterface $em): array { if (isset($class->fieldMappings[$fieldName])) { - return [$class->fieldMappings[$fieldName]['type']]; + return [$class->fieldMappings[$fieldName]->type]; } if (! isset($class->associationMappings[$fieldName])) { diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c425d3824cd..19dd22a5433 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -329,6 +329,7 @@ + $mapping $mapping $mapping $overrideMapping @@ -343,11 +344,9 @@ $mapping - $mapping AssociationMapping - FieldMapping $cache @@ -388,9 +387,6 @@ setValue - - - associationMappings[$assocName]['joinColumns']]]> @@ -1579,8 +1575,6 @@ getAssociationMapping($fieldName)['joinColumns']]]> - - diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 902989818be..94ce894d103 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping\Builder\EmbeddedBuilder; use Doctrine\ORM\Mapping\Builder\FieldBuilder; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\FieldMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Tests\Models\CMS\CmsGroup; @@ -212,7 +213,10 @@ public function testChangeTrackingPolicyNotify(): void public function testAddField(): void { $this->assertIsFluent($this->builder->addField('name', 'string')); - self::assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); + $mapping = $this->cm->getFieldMapping('name'); + self::assertSame('name', $mapping['fieldName']); + self::assertSame('name', $mapping['columnName']); + self::assertSame('string', $mapping['type']); } public function testCreateField(): void @@ -222,14 +226,17 @@ public function testCreateField(): void self::assertFalse(isset($this->cm->fieldMappings['name'])); $this->assertIsFluent($fieldBuilder->build()); - self::assertEquals(['columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'], $this->cm->fieldMappings['name']); + $mapping = $this->cm->getFieldMapping('name'); + self::assertSame('name', $mapping['fieldName']); + self::assertSame('name', $mapping['columnName']); + self::assertSame('string', $mapping['type']); } public function testCreateVersionedField(): void { $this->builder->createField('name', 'integer')->columnName('username')->length(124)->nullable()->columnDefinition('foobar')->unique()->isVersionField()->build(); self::assertEquals( - [ + FieldMapping::fromMappingArray([ 'columnDefinition' => 'foobar', 'columnName' => 'username', 'default' => 1, @@ -238,7 +245,7 @@ public function testCreateVersionedField(): void 'type' => 'integer', 'nullable' => true, 'unique' => true, - ], + ]), $this->cm->fieldMappings['name'], ); } @@ -248,17 +255,18 @@ public function testCreatePrimaryField(): void $this->builder->createField('id', 'integer')->makePrimaryKey()->generatedValue()->build(); self::assertEquals(['id'], $this->cm->identifier); - self::assertEquals(['columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'], $this->cm->fieldMappings['id']); + self::assertEquals(FieldMapping::fromMappingArray( + ['columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'], + ), $this->cm->fieldMappings['id']); } public function testCreateUnsignedOptionField(): void { $this->builder->createField('state', 'integer')->option('unsigned', true)->build(); - self::assertEquals( + self::assertEquals(FieldMapping::fromMappingArray( ['fieldName' => 'state', 'type' => 'integer', 'options' => ['unsigned' => true], 'columnName' => 'state'], - $this->cm->fieldMappings['state'], - ); + ), $this->cm->fieldMappings['state']); } public function testAddLifecycleEvent(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php new file mode 100644 index 00000000000..c3339d6e3a1 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php @@ -0,0 +1,70 @@ +length = 255; + $mapping->id = true; + $mapping->nullable = true; + $mapping->notInsertable = true; + $mapping->notUpdatable = true; + $mapping->columnDefinition = 'VARCHAR(255)'; + $mapping->generated = ClassMetadata::GENERATOR_TYPE_AUTO; + $mapping->enumType = 'MyEnum'; + $mapping->precision = 10; + $mapping->scale = 2; + $mapping->unique = true; + $mapping->inherited = self::class; + $mapping->originalClass = self::class; + $mapping->originalField = 'id'; + $mapping->quoted = true; + $mapping->declared = self::class; + $mapping->declaredField = 'id'; + $mapping->options = ['foo' => 'bar']; + $mapping->version = true; + $mapping->default = 'foo'; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof FieldMapping); + + self::assertSame($resurrectedMapping->length, 255); + self::assertTrue($resurrectedMapping->id); + self::assertTrue($resurrectedMapping->nullable); + self::assertTrue($resurrectedMapping->notInsertable); + self::assertTrue($resurrectedMapping->notUpdatable); + self::assertSame($resurrectedMapping->columnDefinition, 'VARCHAR(255)'); + self::assertSame($resurrectedMapping->generated, ClassMetadata::GENERATOR_TYPE_AUTO); + self::assertSame($resurrectedMapping->enumType, 'MyEnum'); + self::assertSame($resurrectedMapping->precision, 10); + self::assertSame($resurrectedMapping->scale, 2); + self::assertTrue($resurrectedMapping->unique); + self::assertSame($resurrectedMapping->inherited, self::class); + self::assertSame($resurrectedMapping->originalClass, self::class); + self::assertSame($resurrectedMapping->originalField, 'id'); + self::assertTrue($resurrectedMapping->quoted); + self::assertSame($resurrectedMapping->declared, self::class); + self::assertSame($resurrectedMapping->declaredField, 'id'); + self::assertSame($resurrectedMapping->options, ['foo' => 'bar']); + self::assertTrue($resurrectedMapping->version); + self::assertSame($resurrectedMapping->default, 'foo'); + } +} From e22592f06b32e7612fae7930ff4aa3dff17792cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 2 Apr 2023 14:19:03 +0200 Subject: [PATCH 238/475] Extract discriminator column mapping into its own DTO (#10609) --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 43 +++++----- .../ORM/Mapping/ClassMetadataFactory.php | 2 +- .../Mapping/DiscriminatorColumnMapping.php | 83 +++++++++++++++++++ .../Entity/JoinedSubclassPersister.php | 2 +- .../Entity/SingleTablePersister.php | 2 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 5 +- psalm-baseline.xml | 4 + .../ORM/Mapping/ClassMetadataBuilderTest.php | 11 ++- .../Tests/ORM/Mapping/ClassMetadataTest.php | 7 +- .../DiscriminatorColumnMappingTest.php | 37 +++++++++ .../ORM/Mapping/MappingDriverTestCase.php | 10 ++- 11 files changed, 176 insertions(+), 30 deletions(-) create mode 100644 lib/Doctrine/ORM/Mapping/DiscriminatorColumnMapping.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 84a94237886..0c9ea57489c 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -112,15 +112,6 @@ * type: int, * unique?: bool, * } - * @psalm-type DiscriminatorColumnMapping = array{ - * name: string, - * fieldName: string, - * type: string, - * length?: int, - * columnDefinition?: string|null, - * enumType?: class-string|null, - * options?: array, - * } * @psalm-type EmbeddedClassMapping = array{ * class: class-string, * columnPrefix: string|null, @@ -469,11 +460,8 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable /** * READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE * inheritance mappings. - * - * @var array - * @psalm-var DiscriminatorColumnMapping|null */ - public array|null $discriminatorColumn = null; + public DiscriminatorColumnMapping|null $discriminatorColumn = null; /** * READ-ONLY: The primary table definition. The definition is an array with the @@ -2454,13 +2442,28 @@ public function addEntityListener(string $eventName, string $class, string $meth * * @see getDiscriminatorColumn() * - * @param mixed[]|null $columnDef - * @psalm-param array{name: string|null, fieldName?: string, type?: string, length?: int, columnDefinition?: string|null, enumType?: class-string|null, options?: array}|null $columnDef + * @param DiscriminatorColumnMapping|mixed[]|null $columnDef + * @psalm-param DiscriminatorColumnMapping|array{ + * name: string|null, + * fieldName?: string, + * type?: string, + * length?: int, + * columnDefinition?: string|null, + * enumType?: class-string|null, + * options?:array|null + * }|null $columnDef * * @throws MappingException */ - public function setDiscriminatorColumn(array|null $columnDef): void + public function setDiscriminatorColumn(DiscriminatorColumnMapping|array|null $columnDef): void { + if ($columnDef instanceof DiscriminatorColumnMapping) { + $this->discriminatorColumn = $columnDef; + + return; + } + if ($columnDef !== null) { if (! isset($columnDef['name'])) { throw MappingException::nameIsMandatoryForDiscriminatorColumns($this->name); @@ -2482,15 +2485,11 @@ public function setDiscriminatorColumn(array|null $columnDef): void throw MappingException::invalidDiscriminatorColumnType($this->name, $columnDef['type']); } - $this->discriminatorColumn = $columnDef; + $this->discriminatorColumn = DiscriminatorColumnMapping::fromMappingArray($columnDef); } } - /** - * @return array - * @psalm-return DiscriminatorColumnMapping - */ - final public function getDiscriminatorColumn(): array + final public function getDiscriminatorColumn(): DiscriminatorColumnMapping { if ($this->discriminatorColumn === null) { throw new LogicException('The discriminator column was not set.'); diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 001d29cb3ae..9ed65c52c6f 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -96,7 +96,7 @@ protected function doLoadMetadata( ): void { if ($parent) { $class->setInheritanceType($parent->inheritanceType); - $class->setDiscriminatorColumn($parent->discriminatorColumn); + $class->setDiscriminatorColumn($parent->discriminatorColumn === null ? null : clone $parent->discriminatorColumn); $class->setIdGeneratorType($parent->generatorType); $this->addInheritedFields($class, $parent); $this->addInheritedRelations($class, $parent); diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorColumnMapping.php b/lib/Doctrine/ORM/Mapping/DiscriminatorColumnMapping.php new file mode 100644 index 00000000000..cc23fdfdb3b --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/DiscriminatorColumnMapping.php @@ -0,0 +1,83 @@ + */ +final class DiscriminatorColumnMapping implements ArrayAccess +{ + use ArrayAccessImplementation; + + /** The database length of the column. Optional. Default value taken from the type. */ + public int|null $length = null; + + public string|null $columnDefinition = null; + + /** @var class-string|null */ + public string|null $enumType = null; + + /** @var array */ + public array $options = []; + + public function __construct( + public string $type, + public string $fieldName, + public string $name, + ) { + } + + /** + * @psalm-param array{ + * type: string, + * fieldName: string, + * name: string, + * length?: int, + * columnDefinition?: string, + * enumType?: class-string, + * options?: array, + * } $mappingArray + */ + public static function fromMappingArray(array $mappingArray): self + { + $mapping = new self( + $mappingArray['type'], + $mappingArray['fieldName'], + $mappingArray['name'], + ); + foreach ($mappingArray as $key => $value) { + if (in_array($key, ['type', 'fieldName', 'name'])) { + continue; + } + + if (property_exists($mapping, $key)) { + $mapping->$key = $value; + } else { + throw new Exception('Unknown property ' . $key . ' on class ' . static::class); + } + } + + return $mapping; + } + + /** @return list */ + public function __sleep(): array + { + $serialized = ['type', 'fieldName', 'name']; + + foreach (['length', 'columnDefinition', 'enumType', 'options'] as $stringOrArrayKey) { + if ($this->$stringOrArrayKey !== null) { + $serialized[] = $stringOrArrayKey; + } + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index b214cab9e11..f4dc5610814 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -487,7 +487,7 @@ protected function getInsertColumnList(): array // Add discriminator column if it is the topmost class. if ($this->class->name === $this->class->rootEntityName) { - $columns[] = $this->class->getDiscriminatorColumn()['name']; + $columns[] = $this->class->getDiscriminatorColumn()->name; } return $columns; diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index f98df63df27..68b1d9110e5 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -96,7 +96,7 @@ protected function getInsertColumnList(): array $columns = parent::getInsertColumnList(); // Add discriminator column to the INSERT SQL - $columns[] = $this->class->getDiscriminatorColumn()['name']; + $columns[] = $this->class->getDiscriminatorColumn()->name; return $columns; } diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 3da586ebd1f..a2c7486f330 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -15,6 +15,7 @@ use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; use Doctrine\ORM\Mapping\FieldMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\QuoteStrategy; @@ -48,7 +49,6 @@ * @link www.doctrine-project.org * * @psalm-import-type AssociationMapping from ClassMetadata - * @psalm-import-type DiscriminatorColumnMapping from ClassMetadata * @psalm-import-type JoinColumnData from ClassMetadata */ class SchemaTool @@ -406,6 +406,7 @@ public function getSchemaFromMetadata(array $classes): Schema private function addDiscriminatorColumnDefinition(ClassMetadata $class, Table $table): void { $discrColumn = $class->discriminatorColumn; + assert($discrColumn !== null); if ( ! isset($discrColumn['type']) || @@ -776,7 +777,7 @@ private function gatherRelationJoinColumns( * * @return mixed[] */ - private function gatherColumnOptions(FieldMapping|array $mapping): array + private function gatherColumnOptions(FieldMapping|DiscriminatorColumnMapping|array $mapping): array { $mappingOptions = $mapping['options'] ?? []; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 19dd22a5433..0d73187b68b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1566,6 +1566,10 @@ $classes + + + + $asset diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 94ce894d103..ce2f3dff78a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping\Builder\EmbeddedBuilder; use Doctrine\ORM\Mapping\Builder\FieldBuilder; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; use Doctrine\ORM\Mapping\FieldMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\RuntimeReflectionService; @@ -183,7 +184,15 @@ public function testSetInheritanceSingleTable(): void public function testSetDiscriminatorColumn(): void { $this->assertIsFluent($this->builder->setDiscriminatorColumn('discr', 'string', 124, null, null)); - self::assertEquals(['fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => '124', 'columnDefinition' => null, 'enumType' => null, 'options' => []], $this->cm->discriminatorColumn); + self::assertEquals(DiscriminatorColumnMapping::fromMappingArray([ + 'fieldName' => 'discr', + 'name' => 'discr', + 'type' => 'string', + 'length' => 124, + 'columnDefinition' => null, + 'enumType' => null, + 'options' => [], + ]), $this->cm->discriminatorColumn); } public function testAddDiscriminatorMapClass(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index cf3261fe4c5..948ba2d5a96 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DefaultNamingStrategy; use Doctrine\ORM\Mapping\DefaultTypedFieldMapper; +use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; use Doctrine\ORM\Mapping\MappedSuperclass; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; @@ -102,7 +103,11 @@ public function testClassMetadataInstanceSerialization(): void self::assertEquals([One::class, Two::class, Three::class], $cm->subClasses); self::assertEquals(['UserParent'], $cm->parentClasses); self::assertEquals(UserRepository::class, $cm->customRepositoryClassName); - self::assertEquals(['name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'], $cm->discriminatorColumn); + self::assertEquals(DiscriminatorColumnMapping::fromMappingArray([ + 'name' => 'disc', + 'type' => 'integer', + 'fieldName' => 'disc', + ]), $cm->discriminatorColumn); self::assertTrue($cm->associationMappings['phonenumbers']['type'] === ClassMetadata::ONE_TO_ONE); self::assertEquals(1, count($cm->associationMappings)); $oneOneMapping = $cm->getAssociationMapping('phonenumbers'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php new file mode 100644 index 00000000000..5ecb8a6fe72 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php @@ -0,0 +1,37 @@ +length = 255; + $mapping->columnDefinition = 'VARCHAR(255)'; + $mapping->enumType = 'MyEnum'; + $mapping->options = ['foo' => 'bar']; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof DiscriminatorColumnMapping); + + self::assertSame($resurrectedMapping->length, 255); + self::assertSame($resurrectedMapping->columnDefinition, 'VARCHAR(255)'); + self::assertSame($resurrectedMapping->enumType, 'MyEnum'); + self::assertSame($resurrectedMapping->options, ['foo' => 'bar']); + } +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index e7a47d72455..03466196df4 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\DefaultNamingStrategy; use Doctrine\ORM\Mapping\DefaultTypedFieldMapper; use Doctrine\ORM\Mapping\DiscriminatorColumn; +use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; use Doctrine\ORM\Mapping\DiscriminatorMap; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\GeneratedValue; @@ -457,7 +458,14 @@ public function testDiscriminatorColumnDefaults(): void $class = $this->createClassMetadata(Animal::class); self::assertEquals( - ['name' => 'discr', 'type' => 'string', 'length' => 32, 'fieldName' => 'discr', 'columnDefinition' => null, 'enumType' => null], + DiscriminatorColumnMapping::fromMappingArray([ + 'name' => 'discr', + 'type' => 'string', + 'length' => 32, + 'fieldName' => 'discr', + 'columnDefinition' => null, + 'enumType' => null, + ]), $class->discriminatorColumn, ); } From c2139742348abce728e563c653a2026b6f9db1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 3 Apr 2023 08:57:37 +0200 Subject: [PATCH 239/475] Use the correct argument order for PHPUnit's assertions --- .../DiscriminatorColumnMappingTest.php | 8 +++--- .../Tests/ORM/Mapping/FieldMappingTest.php | 26 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php index 5ecb8a6fe72..904fdab2b3a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php @@ -29,9 +29,9 @@ public function testItSurvivesSerialization(): void $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof DiscriminatorColumnMapping); - self::assertSame($resurrectedMapping->length, 255); - self::assertSame($resurrectedMapping->columnDefinition, 'VARCHAR(255)'); - self::assertSame($resurrectedMapping->enumType, 'MyEnum'); - self::assertSame($resurrectedMapping->options, ['foo' => 'bar']); + self::assertSame(255, $resurrectedMapping->length); + self::assertSame('VARCHAR(255)', $resurrectedMapping->columnDefinition); + self::assertSame('MyEnum', $resurrectedMapping->enumType); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->options); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php index c3339d6e3a1..cfbd89b8ca5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php @@ -46,25 +46,25 @@ public function testItSurvivesSerialization(): void $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof FieldMapping); - self::assertSame($resurrectedMapping->length, 255); + self::assertSame(255, $resurrectedMapping->length); self::assertTrue($resurrectedMapping->id); self::assertTrue($resurrectedMapping->nullable); self::assertTrue($resurrectedMapping->notInsertable); self::assertTrue($resurrectedMapping->notUpdatable); - self::assertSame($resurrectedMapping->columnDefinition, 'VARCHAR(255)'); - self::assertSame($resurrectedMapping->generated, ClassMetadata::GENERATOR_TYPE_AUTO); - self::assertSame($resurrectedMapping->enumType, 'MyEnum'); - self::assertSame($resurrectedMapping->precision, 10); - self::assertSame($resurrectedMapping->scale, 2); + self::assertSame('VARCHAR(255)', $resurrectedMapping->columnDefinition); + self::assertSame(ClassMetadata::GENERATOR_TYPE_AUTO, $resurrectedMapping->generated); + self::assertSame('MyEnum', $resurrectedMapping->enumType); + self::assertSame(10, $resurrectedMapping->precision); + self::assertSame(2, $resurrectedMapping->scale); self::assertTrue($resurrectedMapping->unique); - self::assertSame($resurrectedMapping->inherited, self::class); - self::assertSame($resurrectedMapping->originalClass, self::class); - self::assertSame($resurrectedMapping->originalField, 'id'); + self::assertSame(self::class, $resurrectedMapping->inherited); + self::assertSame(self::class, $resurrectedMapping->originalClass); + self::assertSame('id', $resurrectedMapping->originalField); self::assertTrue($resurrectedMapping->quoted); - self::assertSame($resurrectedMapping->declared, self::class); - self::assertSame($resurrectedMapping->declaredField, 'id'); - self::assertSame($resurrectedMapping->options, ['foo' => 'bar']); + self::assertSame(self::class, $resurrectedMapping->declared); + self::assertSame('id', $resurrectedMapping->declaredField); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->options); self::assertTrue($resurrectedMapping->version); - self::assertSame($resurrectedMapping->default, 'foo'); + self::assertSame('foo', $resurrectedMapping->default); } } From 9d3ae4a55ac59015ed58620a940e495301b7f62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 27 Jan 2023 19:49:18 +0100 Subject: [PATCH 240/475] Extract embedded class mapping into its own DTO --- .../Mapping/Builder/ClassMetadataBuilder.php | 2 + lib/Doctrine/ORM/Mapping/ClassMetadata.php | 36 ++------ .../ORM/Mapping/ClassMetadataFactory.php | 24 ++--- .../ORM/Mapping/EmbeddedClassMapping.php | 91 +++++++++++++++++++ psalm-baseline.xml | 2 + .../ORM/Mapping/ClassMetadataBuilderTest.php | 17 ++-- .../ORM/Mapping/EmbeddedClassMappingTest.php | 34 +++++++ .../ORM/Mapping/XmlMappingDriverTest.php | 5 +- 8 files changed, 162 insertions(+), 49 deletions(-) create mode 100644 lib/Doctrine/ORM/Mapping/EmbeddedClassMapping.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/EmbeddedClassMappingTest.php diff --git a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php index 908d4acbcfe..5ea96e384fe 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php @@ -53,6 +53,8 @@ public function setEmbeddable(): static /** * Adds and embedded class * + * @param class-string $class + * * @return $this */ public function addEmbedded(string $fieldName, string $class, string|false|null $columnPrefix = null): static diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 0c9ea57489c..a1f6b0dfcfc 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -112,14 +112,6 @@ * type: int, * unique?: bool, * } - * @psalm-type EmbeddedClassMapping = array{ - * class: class-string, - * columnPrefix: string|null, - * declaredField: string|null, - * originalField: string|null, - * inherited?: class-string, - * declared?: class-string, - * } */ class ClassMetadata implements PersistenceClassMetadata, Stringable { @@ -364,22 +356,6 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable /** * READ-ONLY: The names of all embedded classes based on properties. * - * The value (definition) array may contain, among others, the following values: - * - * - 'inherited' (string, optional) - * This is set when this embedded-class field is inherited by this class from another (inheritance) parent - * entity class. The value is the FQCN of the topmost entity class that contains - * mapping information for this field. (If there are transient classes in the - * class hierarchy, these are ignored, so the class property may in fact come - * from a class further up in the PHP class hierarchy.) - * Fields initially declared in mapped superclasses are - * not considered 'inherited' in the nearest entity subclasses. - * - * - 'declared' (string, optional) - * This is set when the embedded-class field does not appear for the first time in this class, but is originally - * declared in another parent entity or mapped superclass. The value is the FQCN - * of the topmost non-transient class that contains mapping information for this field. - * * @psalm-var array */ public array $embeddedClasses = []; @@ -2822,7 +2798,13 @@ public function getMetadataValue(string $name): mixed /** * Map Embedded Class * - * @psalm-param array $mapping + * @psalm-param array{ + * fieldName: string, + * class?: class-string, + * declaredField?: string, + * columnPrefix?: string|false|null, + * originalField?: string + * } $mapping * * @throws MappingException */ @@ -2845,12 +2827,12 @@ public function mapEmbedded(array $mapping): void assert($fqcn !== null); - $this->embeddedClasses[$mapping['fieldName']] = [ + $this->embeddedClasses[$mapping['fieldName']] = EmbeddedClassMapping::fromMappingArray([ 'class' => $fqcn, 'columnPrefix' => $mapping['columnPrefix'] ?? null, 'declaredField' => $mapping['declaredField'] ?? null, 'originalField' => $mapping['originalField'] ?? null, - ]; + ]); } /** diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 9ed65c52c6f..3b0a50e69a9 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -46,7 +46,6 @@ * * @extends AbstractClassMetadataFactory * @psalm-import-type AssociationMapping from ClassMetadata - * @psalm-import-type EmbeddedClassMapping from ClassMetadata */ class ClassMetadataFactory extends AbstractClassMetadataFactory { @@ -384,11 +383,11 @@ private function getShortName(string $className): string /** * Puts the `inherited` and `declared` values into mapping information for fields, associations * and embedded classes. - * - * @param AssociationMapping|EmbeddedClassMapping|FieldMapping $mapping */ - private function addMappingInheritanceInformation(array|FieldMapping &$mapping, ClassMetadata $parentClass): void - { + private function addMappingInheritanceInformation( + array|EmbeddedClassMapping|FieldMapping &$mapping, + ClassMetadata $parentClass, + ): void { if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { $mapping['inherited'] = $parentClass->name; } @@ -440,8 +439,9 @@ private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $p private function addInheritedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->embeddedClasses as $field => $embeddedClass) { - $this->addMappingInheritanceInformation($embeddedClass, $parentClass); - $subClass->embeddedClasses[$field] = $embeddedClass; + $subClassMapping = clone $embeddedClass; + $this->addMappingInheritanceInformation($subClassMapping, $parentClass); + $subClass->embeddedClasses[$field] = $subClassMapping; } } @@ -462,17 +462,17 @@ private function addNestedEmbeddedClasses( continue; } - $embeddableMetadata = $this->getMetadataFor($embeddableClass['class']); + $embeddableMetadata = $this->getMetadataFor($embeddableClass->class); $parentClass->mapEmbedded( [ 'fieldName' => $prefix . '.' . $property, 'class' => $embeddableMetadata->name, - 'columnPrefix' => $embeddableClass['columnPrefix'], - 'declaredField' => $embeddableClass['declaredField'] - ? $prefix . '.' . $embeddableClass['declaredField'] + 'columnPrefix' => $embeddableClass->columnPrefix, + 'declaredField' => $embeddableClass->declaredField + ? $prefix . '.' . $embeddableClass->declaredField : $prefix, - 'originalField' => $embeddableClass['originalField'] ?: $property, + 'originalField' => $embeddableClass->originalField ?: $property, ], ); } diff --git a/lib/Doctrine/ORM/Mapping/EmbeddedClassMapping.php b/lib/Doctrine/ORM/Mapping/EmbeddedClassMapping.php new file mode 100644 index 00000000000..c1d464568a8 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/EmbeddedClassMapping.php @@ -0,0 +1,91 @@ + */ +final class EmbeddedClassMapping implements ArrayAccess +{ + use ArrayAccessImplementation; + + public string|false|null $columnPrefix = null; + public string|null $declaredField = null; + public string|null $originalField = null; + + /** + * This is set when this embedded-class field is inherited by this class + * from another (inheritance) parent entity class. The value is + * the FQCN of the topmost entity class that contains mapping information + * for this field. (If there are transient classes in the class hierarchy, + * these are ignored, so the class property may in fact come from a class + * further up in the PHP class hierarchy.) Fields initially declared in + * mapped superclasses are not considered 'inherited' in the + * nearest entity subclasses. + * + * @var class-string|null + */ + public string|null $inherited = null; + + /** + * This is set when the embedded-class field does not appear for the first + * time in this class, but is originally declared in another parent + * entity or mapped superclass. The value is the FQCN of the + * topmost non-transient class that contains mapping information for this + * field. + * + * @var class-string|null + */ + public string|null $declared = null; + + /** @param class-string $class */ + public function __construct(public string $class) + { + } + + /** + * @psalm-param array{ + * class: class-string, + * columnPrefix?: false|string|null, + * declaredField?: string|null, + * originalField?: string|null + * } $mappingArray + */ + public static function fromMappingArray(array $mappingArray): self + { + $mapping = new self($mappingArray['class']); + foreach ($mappingArray as $key => $value) { + if ($key === 'class') { + continue; + } + + if (property_exists($mapping, $key)) { + $mapping->$key = $value; + } + } + + return $mapping; + } + + /** @return list */ + public function __sleep(): array + { + $serialized = ['class']; + + if ($this->columnPrefix) { + $serialized[] = 'columnPrefix'; + } + + foreach (['declaredField', 'originalField', 'inherited', 'declared'] as $property) { + if ($this->$property !== null) { + $serialized[] = $property; + } + } + + return $serialized; + } +} diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 0d73187b68b..275683eca87 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -480,6 +480,7 @@ + $mapping $seqGeneratorAttribute->sequenceName, 'allocationSize' => $seqGeneratorAttribute->allocationSize, @@ -553,6 +554,7 @@ $columnDef + $mapping cacheToArray($manyToManyElement->cache)]]> cacheToArray($manyToOneElement->cache)]]> cacheToArray($oneToManyElement->cache)]]> diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index ce2f3dff78a..a7dc1b69bbf 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -9,6 +9,7 @@ use Doctrine\ORM\Mapping\Builder\FieldBuilder; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; +use Doctrine\ORM\Mapping\EmbeddedClassMapping; use Doctrine\ORM\Mapping\FieldMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\RuntimeReflectionService; @@ -51,12 +52,12 @@ public function testAddEmbeddedWithOnlyRequiredParams(): void self::assertEquals( [ - 'name' => [ + 'name' => EmbeddedClassMapping::fromMappingArray([ 'class' => Name::class, 'columnPrefix' => null, 'declaredField' => null, 'originalField' => null, - ], + ]), ], $this->cm->embeddedClasses, ); @@ -74,12 +75,12 @@ public function testAddEmbeddedWithPrefix(): void self::assertEquals( [ - 'name' => [ + 'name' => EmbeddedClassMapping::fromMappingArray([ 'class' => Name::class, 'columnPrefix' => 'nm_', 'declaredField' => null, 'originalField' => null, - ], + ]), ], $this->cm->embeddedClasses, ); @@ -94,12 +95,12 @@ public function testCreateEmbeddedWithoutExtraParams(): void $this->assertIsFluent($embeddedBuilder->build()); self::assertEquals( - [ + EmbeddedClassMapping::fromMappingArray([ 'class' => Name::class, 'columnPrefix' => null, 'declaredField' => null, 'originalField' => null, - ], + ]), $this->cm->embeddedClasses['name'], ); } @@ -113,12 +114,12 @@ public function testCreateEmbeddedWithColumnPrefix(): void $this->assertIsFluent($embeddedBuilder->build()); self::assertEquals( - [ + EmbeddedClassMapping::fromMappingArray([ 'class' => Name::class, 'columnPrefix' => 'nm_', 'declaredField' => null, 'originalField' => null, - ], + ]), $this->cm->embeddedClasses['name'], ); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/EmbeddedClassMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/EmbeddedClassMappingTest.php new file mode 100644 index 00000000000..386cc94533b --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/EmbeddedClassMappingTest.php @@ -0,0 +1,34 @@ +columnPrefix = 'these'; + $mapping->declaredField = 'values'; + $mapping->originalField = 'make'; + $mapping->inherited = self::class; // no + $mapping->declared = self::class; // sense + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof EmbeddedClassMapping); + + self::assertSame('these', $resurrectedMapping->columnPrefix); + self::assertSame('values', $resurrectedMapping->declaredField); + self::assertSame('make', $resurrectedMapping->originalField); + self::assertSame(self::class, $resurrectedMapping->inherited); + self::assertSame(self::class, $resurrectedMapping->declared); + } +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index e38124cc1e2..cdfff2ec2a1 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -9,6 +9,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\Driver\XmlDriver; +use Doctrine\ORM\Mapping\EmbeddedClassMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Persistence\Mapping\MappingException as PersistenceMappingException; @@ -136,12 +137,12 @@ public function testEmbeddedMapping(): void self::assertEquals( [ - 'name' => [ + 'name' => EmbeddedClassMapping::fromMappingArray([ 'class' => Name::class, 'columnPrefix' => 'nm_', 'declaredField' => null, 'originalField' => null, - ], + ]), ], $class->embeddedClasses, ); From 14d615201ef4fd70de53d7de90193bcf4b881bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Feb 2023 21:25:12 +0100 Subject: [PATCH 241/475] Extract AssociationMapping in its own DTO --- lib/Doctrine/ORM/Cache/CacheFactory.php | 19 +- lib/Doctrine/ORM/Cache/DefaultCache.php | 2 +- .../ORM/Cache/DefaultCacheFactory.php | 17 +- .../ORM/Cache/DefaultEntityHydrator.php | 6 +- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 7 +- .../AbstractCollectionPersister.php | 5 +- .../ReadWriteCachedCollectionPersister.php | 12 +- .../Entity/AbstractEntityPersister.php | 31 +- .../ORM/Internal/Hydration/ArrayHydrator.php | 4 +- .../ORM/Internal/Hydration/ObjectHydrator.php | 6 +- .../ORM/Mapping/AnsiQuoteStrategy.php | 20 +- .../ORM/Mapping/AssociationMapping.php | 345 +++++++++++++ .../Mapping/AssociationOwningSideMapping.php | 9 + lib/Doctrine/ORM/Mapping/ClassMetadata.php | 439 +++-------------- .../ORM/Mapping/ClassMetadataFactory.php | 12 +- .../ORM/Mapping/DefaultQuoteStrategy.php | 22 +- .../ORM/Mapping/JoinColumnMapping.php | 67 +++ lib/Doctrine/ORM/Mapping/JoinTableMapping.php | 100 ++++ .../Mapping/ManyToManyAssociationMapping.php | 25 + .../Mapping/ManyToManyOwningSideMapping.php | 136 ++++++ .../Mapping/ManyToOneAssociationMapping.php | 24 + lib/Doctrine/ORM/Mapping/MappingException.php | 10 + .../Mapping/OneToManyAssociationMapping.php | 33 ++ .../Mapping/OneToOneAssociationMapping.php | 9 + .../ORM/Mapping/OneToOneOwningSideMapping.php | 21 + lib/Doctrine/ORM/Mapping/QuoteStrategy.php | 19 +- .../ORM/Mapping/ToManyAssociationMapping.php | 37 ++ .../ORM/Mapping/ToOneAssociationMapping.php | 190 ++++++++ .../ORM/ORMInvalidArgumentException.php | 20 +- lib/Doctrine/ORM/PersistentCollection.php | 44 +- .../Collection/ManyToManyPersister.php | 13 +- .../Entity/BasicEntityPersister.php | 80 ++- .../ORM/Persisters/Entity/EntityPersister.php | 39 +- .../Entity/JoinedSubclassPersister.php | 25 +- .../Entity/SingleTablePersister.php | 5 +- .../Query/AST/Functions/IdentityFunction.php | 4 +- .../ORM/Query/AST/Functions/SizeFunction.php | 4 +- lib/Doctrine/ORM/Query/Parser.php | 7 +- lib/Doctrine/ORM/Query/QueryException.php | 15 +- .../ORM/Query/ResultSetMappingBuilder.php | 4 +- lib/Doctrine/ORM/Query/SqlWalker.php | 20 +- .../Command/MappingDescribeCommand.php | 3 +- .../ORM/Tools/DebugUnitOfWorkListener.php | 3 +- .../Tools/Pagination/LimitSubqueryWalker.php | 3 +- .../ORM/Tools/ResolveTargetEntityListener.php | 11 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 28 +- lib/Doctrine/ORM/Tools/SchemaValidator.php | 4 +- lib/Doctrine/ORM/UnitOfWork.php | 43 +- lib/Doctrine/ORM/Utility/PersisterHelper.php | 8 +- phpstan-baseline.neon | 5 - phpstan.neon | 21 + psalm-baseline.xml | 458 ++---------------- .../Performance/Mock/NonLoadingPersister.php | 3 +- .../Tests/Models/DDC964/DDC964Admin.php | 4 +- .../Tests/Models/DDC964/DDC964User.php | 2 +- .../Models/TypedProperties/UserTyped.php | 2 +- .../ORM/Cache/DefaultCacheFactoryTest.php | 8 +- .../CollectionPersisterTestCase.php | 8 +- ...ReadWriteCachedCollectionPersisterTest.php | 9 +- .../ReadOnlyCachedCollectionPersisterTest.php | 9 +- ...ReadWriteCachedCollectionPersisterTest.php | 9 +- .../Entity/EntityPersisterTestCase.php | 47 +- .../ManyToManyBasicAssociationTest.php | 3 +- .../ORM/Mapping/AnsiQuoteStrategyTest.php | 4 +- .../ORM/Mapping/AssociationMappingTest.php | 104 ++++ .../ORM/Mapping/ClassMetadataBuilderTest.php | 93 +--- .../Tests/ORM/Mapping/ClassMetadataTest.php | 26 +- .../ORM/Mapping/JoinColumnMappingTest.php | 43 ++ .../ORM/Mapping/JoinTableMappingTest.php | 36 ++ .../ManyToManyAssociationMappingTest.php | 33 ++ .../ManyToManyOwningSideMappingTest.php | 33 ++ .../ManyToOneAssociationMappingTest.php | 32 ++ .../Mapping/OneToOneOwningSideMappingTest.php | 32 ++ .../Tests/ORM/Mapping/QuoteStrategyTest.php | 6 +- .../Mapping/ToManyAssociationMappingTest.php | 37 ++ .../Mapping/ToOneAssociationMappingTest.php | 37 ++ .../ORM/ORMInvalidArgumentExceptionTest.php | 13 +- ...sicEntityPersisterCompositeTypeSqlTest.php | 20 +- .../BasicEntityPersisterTypeValueSqlTest.php | 15 +- 79 files changed, 1902 insertions(+), 1260 deletions(-) create mode 100644 lib/Doctrine/ORM/Mapping/AssociationMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/AssociationOwningSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/JoinColumnMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/JoinTableMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/OneToOneOwningSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/ManyToManyAssociationMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/ToOneAssociationMappingTest.php diff --git a/lib/Doctrine/ORM/Cache/CacheFactory.php b/lib/Doctrine/ORM/Cache/CacheFactory.php index 8aa7388984c..b15c23e8df4 100644 --- a/lib/Doctrine/ORM/Cache/CacheFactory.php +++ b/lib/Doctrine/ORM/Cache/CacheFactory.php @@ -8,14 +8,13 @@ use Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister; use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\ORM\Persisters\Entity\EntityPersister; /** * Contract for building second level cache regions components. - * - * @psalm-import-type AssociationMapping from ClassMetadata */ interface CacheFactory { @@ -24,12 +23,12 @@ interface CacheFactory */ public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPersister $persister, ClassMetadata $metadata): CachedEntityPersister; - /** - * Build a collection persister for the given relation mapping. - * - * @param AssociationMapping $mapping The association mapping. - */ - public function buildCachedCollectionPersister(EntityManagerInterface $em, CollectionPersister $persister, array $mapping): CachedCollectionPersister; + /** Build a collection persister for the given relation mapping. */ + public function buildCachedCollectionPersister( + EntityManagerInterface $em, + CollectionPersister $persister, + AssociationMapping $mapping, + ): CachedCollectionPersister; /** * Build a query cache based on the given region name @@ -43,10 +42,8 @@ public function buildEntityHydrator(EntityManagerInterface $em, ClassMetadata $m /** * Build a collection hydrator - * - * @param mixed[] $mapping The association mapping. */ - public function buildCollectionHydrator(EntityManagerInterface $em, array $mapping): CollectionHydrator; + public function buildCollectionHydrator(EntityManagerInterface $em, AssociationMapping $mapping): CollectionHydrator; /** * Build a cache region diff --git a/lib/Doctrine/ORM/Cache/DefaultCache.php b/lib/Doctrine/ORM/Cache/DefaultCache.php index 04264e7eb94..ec7951f7931 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultCache.php @@ -157,7 +157,7 @@ public function evictCollectionRegions(): void foreach ($metadatas as $metadata) { foreach ($metadata->associationMappings as $association) { - if (! $association['type'] & ClassMetadata::TO_MANY) { + if (! $association->isToMany()) { continue; } diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index e770a107ac7..bc7c77188ab 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Cache\Region\FileLockRegion; use Doctrine\ORM\Cache\Region\UpdateTimestampCache; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\ORM\Persisters\Entity\EntityPersister; @@ -87,12 +88,11 @@ public function buildCachedEntityPersister(EntityManagerInterface $em, EntityPer throw new InvalidArgumentException(sprintf('Unrecognized access strategy type [%s]', $usage)); } - /** - * {@inheritdoc} - */ - public function buildCachedCollectionPersister(EntityManagerInterface $em, CollectionPersister $persister, array $mapping): CachedCollectionPersister - { - assert(isset($mapping['cache'])); + public function buildCachedCollectionPersister( + EntityManagerInterface $em, + CollectionPersister $persister, + AssociationMapping $mapping, + ): CachedCollectionPersister { $usage = $mapping['cache']['usage']; $region = $this->getRegion($mapping['cache']); @@ -128,10 +128,7 @@ public function buildQueryCache(EntityManagerInterface $em, string|null $regionN ); } - /** - * {@inheritdoc} - */ - public function buildCollectionHydrator(EntityManagerInterface $em, array $mapping): CollectionHydrator + public function buildCollectionHydrator(EntityManagerInterface $em, AssociationMapping $mapping): CollectionHydrator { return new DefaultCollectionHydrator($em); } diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index dba3eb219e4..0cbe377d6be 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -57,7 +57,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob continue; } - if (! ($assoc['type'] & ClassMetadata::TO_ONE)) { + if (! $assoc->isToOne()) { unset($data[$name]); continue; @@ -65,7 +65,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob if (! isset($assoc['cache'])) { $targetClassMetadata = $this->em->getClassMetadata($assoc['targetEntity']); - $owningAssociation = ! $assoc['isOwningSide'] + $owningAssociation = ! $assoc->isOwningSide() ? $targetClassMetadata->associationMappings[$assoc['mappedBy']] : $assoc; $associationIds = $this->identifierFlattener->flattenIdentifier( @@ -141,7 +141,7 @@ public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, Ent $assocClass = $data[$name]->class; $assocId = $data[$name]->identifier; - $isEagerLoad = ($assoc['fetch'] === ClassMetadata::FETCH_EAGER || ($assoc['type'] === ClassMetadata::ONE_TO_ONE && ! $assoc['isOwningSide'])); + $isEagerLoad = ($assoc['fetch'] === ClassMetadata::FETCH_EAGER || ($assoc->isOneToOne() && ! $assoc->isOwningSide())); if (! $isEagerLoad) { $data[$name] = $this->em->getReference($assocClass, $assocId); diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 66f4048215f..1e9f902f3a8 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Query; @@ -30,8 +31,6 @@ /** * Default query cache implementation. - * - * @psalm-import-type AssociationMapping from ClassMetadata */ class DefaultQueryCache implements QueryCache { @@ -298,12 +297,10 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, ar } /** - * @param AssociationMapping $assoc - * * @return mixed[]|null * @psalm-return array{targetEntity: class-string, type: mixed, list?: array[], identifier?: array}|null */ - private function storeAssociationCache(QueryCacheKey $key, array $assoc, mixed $assocValue): array|null + private function storeAssociationCache(QueryCacheKey $key, AssociationMapping $assoc, mixed $assocValue): array|null { $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); $assocMetadata = $assocPersister->getClassMetadata(); diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index a2072437ee8..c402991d740 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\PersistentCollection; @@ -23,7 +24,6 @@ use function assert; use function count; -/** @psalm-import-type AssociationMapping from ClassMetadata */ abstract class AbstractCollectionPersister implements CachedCollectionPersister { protected UnitOfWork $uow; @@ -38,12 +38,11 @@ abstract class AbstractCollectionPersister implements CachedCollectionPersister protected CollectionHydrator $hydrator; protected CacheLogger|null $cacheLogger; - /** @param AssociationMapping $association The association mapping. */ public function __construct( protected CollectionPersister $persister, protected Region $region, EntityManagerInterface $em, - protected array $association, + protected AssociationMapping $association, ) { $configuration = $em->getConfiguration(); $cacheConfig = $configuration->getSecondLevelCacheConfiguration(); diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php index 147d3e67b6b..e28b919d82d 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php @@ -7,18 +7,20 @@ use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\ConcurrentRegion; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use function spl_object_id; -/** @psalm-import-type AssociationMapping from ClassMetadata */ class ReadWriteCachedCollectionPersister extends AbstractCollectionPersister { - /** @param AssociationMapping $association The association mapping. */ - public function __construct(CollectionPersister $persister, ConcurrentRegion $region, EntityManagerInterface $em, array $association) - { + public function __construct( + CollectionPersister $persister, + ConcurrentRegion $region, + EntityManagerInterface $em, + AssociationMapping $association, + ) { parent::__construct($persister, $region, $em, $association); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 652b8113ba6..53404d9d895 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -18,6 +18,7 @@ use Doctrine\ORM\Cache\TimestampCacheKey; use Doctrine\ORM\Cache\TimestampRegion; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\PersistentCollection; @@ -86,7 +87,7 @@ public function getInserts(): array public function getSelectSQL( array|Criteria $criteria, - array|null $assoc = null, + AssociationMapping|null $assoc = null, LockMode|int|null $lockMode = null, int|null $limit = null, int|null $offset = null, @@ -113,7 +114,7 @@ public function getResultSetMapping(): ResultSetMapping public function getSelectConditionStatementSQL( string $field, mixed $value, - array|null $assoc = null, + AssociationMapping|null $assoc = null, string|null $comparison = null, ): string { return $this->persister->getSelectConditionStatementSQL($field, $value, $assoc, $comparison); @@ -169,8 +170,8 @@ private function storeJoinedAssociations(object $entity): void foreach ($this->class->associationMappings as $name => $assoc) { if ( isset($assoc['cache']) && - ($assoc['type'] & ClassMetadata::TO_ONE) && - ($assoc['fetch'] === ClassMetadata::FETCH_EAGER || ! $assoc['isOwningSide']) + ($assoc->isToOne()) && + ($assoc['fetch'] === ClassMetadata::FETCH_EAGER || ! $assoc->isOwningSide()) ) { $associations[] = $name; } @@ -241,7 +242,7 @@ public function getClassMetadata(): ClassMetadata * {@inheritdoc} */ public function getManyToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, @@ -253,7 +254,7 @@ public function getManyToManyCollection( * {@inheritdoc} */ public function getOneToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, @@ -282,7 +283,7 @@ public function executeInserts(): array public function load( array $criteria, object|null $entity = null, - array|null $assoc = null, + AssociationMapping|null $assoc = null, array $hints = [], LockMode|int|null $lockMode = null, int|null $limit = null, @@ -455,7 +456,7 @@ public function loadCriteria(Criteria $criteria): array * {@inheritdoc} */ public function loadManyToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, PersistentCollection $collection, ): array { @@ -485,11 +486,8 @@ public function loadManyToManyCollection( return $list; } - /** - * {@inheritdoc} - */ public function loadOneToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, PersistentCollection $collection, ): mixed { @@ -522,7 +520,7 @@ public function loadOneToManyCollection( /** * {@inheritdoc} */ - public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): object|null + public function loadOneToOneEntity(AssociationMapping $assoc, object $sourceEntity, array $identifier = []): object|null { return $this->persister->loadOneToOneEntity($assoc, $sourceEntity, $identifier); } @@ -543,11 +541,8 @@ public function refresh(array $id, object $entity, LockMode|int|null $lockMode = $this->persister->refresh($id, $entity, $lockMode); } - /** - * @param array $association - * @param array $ownerId - */ - protected function buildCollectionCacheKey(array $association, array $ownerId): CollectionCacheKey + /** @param array $ownerId */ + protected function buildCollectionCacheKey(AssociationMapping $association, array $ownerId): CollectionCacheKey { $metadata = $this->metadataFactory->getMetadataFor($association['sourceEntity']); assert($metadata instanceof ClassMetadata); diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index baf8a26cfa5..57015d4681c 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -4,8 +4,6 @@ namespace Doctrine\ORM\Internal\Hydration; -use Doctrine\ORM\Mapping\ClassMetadata; - use function array_key_last; use function count; use function is_array; @@ -103,7 +101,7 @@ protected function hydrateRowData(array $row, array &$result): void $relation = $parentClass->associationMappings[$relationAlias]; // Check the type of the relation (many or single-valued) - if (! ($relation['type'] & ClassMetadata::TO_ONE)) { + if (! $relation->isToOne()) { $oneToOne = false; if (! isset($baseElement[$relationAlias])) { diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 721ac80fb1e..e6b43fd9996 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -94,7 +94,7 @@ protected function prepare(): void $class = $this->getClassMetadata($className); $inverseAssoc = $class->associationMappings[$assoc['inversedBy']]; - if (! ($inverseAssoc['type'] & ClassMetadata::TO_ONE)) { + if (! $inverseAssoc->isToOne()) { continue; } @@ -364,7 +364,7 @@ protected function hydrateRowData(array $row, array &$result): void $oid = spl_object_id($parentObject); // Check the type of the relation (many or single-valued) - if (! ($relation['type'] & ClassMetadata::TO_ONE)) { + if (! $relation->isToOne()) { // PATH A: Collection-valued association $reflFieldValue = $reflField->getValue($parentObject); @@ -435,7 +435,7 @@ protected function hydrateRowData(array $row, array &$result): void // If there is an inverse mapping on the target class its bidirectional if ($relation['inversedBy']) { $inverseAssoc = $targetClass->associationMappings[$relation['inversedBy']]; - if ($inverseAssoc['type'] & ClassMetadata::TO_ONE) { + if ($inverseAssoc->isToOne()) { $targetClass->reflFields[$inverseAssoc['fieldName']]->setValue($element, $parentObject); $this->uow->setOriginalEntityProperty(spl_object_id($element), $inverseAssoc['fieldName'], $parentObject); } diff --git a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php index a9b953d650a..a911103ccfa 100644 --- a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php @@ -36,30 +36,24 @@ public function getSequenceName(array $definition, ClassMetadata $class, Abstrac return $definition['sequenceName']; } - /** - * {@inheritdoc} - */ - public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string + public function getJoinColumnName(JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string { return $joinColumn['name']; } - /** - * {@inheritdoc} - */ public function getReferencedJoinColumnName( - array $joinColumn, + JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform, ): string { return $joinColumn['referencedColumnName']; } - /** - * {@inheritdoc} - */ - public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform): string - { + public function getJoinTableName( + AssociationMapping $association, + ClassMetadata $class, + AbstractPlatform $platform, + ): string { return $association['joinTable']['name']; } diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php new file mode 100644 index 00000000000..96dd2647a96 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -0,0 +1,345 @@ + */ +abstract class AssociationMapping implements ArrayAccess +{ + /** + * required for bidirectional associations + * The name of the field that completes the bidirectional association on + * the owning side. This key must be specified on the inverse side of a + * bidirectional association. + */ + public string|null $mappedBy = null; + + /** + * required for bidirectional associations + * The name of the field that completes the bidirectional association on + * the inverse side. This key must be specified on the owning side of a + * bidirectional association. + */ + public string|null $inversedBy = null; + + /** + * The names of persistence operations to cascade on the association. + * + * @var list<'persist'|'remove'|'detach'|'merge'|'refresh'|'all'> + */ + public array $cascade = []; + + /** + * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. + * + * @var ClassMetadata::FETCH_EAGER|ClassMetadata::FETCH_LAZY + */ + public int|null $fetch = null; + + /** + * This is set when the association is inherited by this class from another + * (inheritance) parent entity class. The value is the FQCN of the + * topmost entity class that contains this association. (If there are + * transient classes in the class hierarchy, these are ignored, so the + * class property may in fact come from a class further up in the PHP class + * hierarchy.) To-many associations initially declared in mapped + * superclasses are not considered 'inherited' in the nearest + * entity subclasses. + * + * @var class-string|null + */ + public string|null $inherited = null; + + /** + * This is set when the association does not appear in the current class + * for the first time, but is initially declared in another parent + * entity or mapped superclass. The value is the FQCN of the + * topmost non-transient class that contains association information for + * this relationship. + * + * @var class-string|null + */ + public string|null $declared = null; + + public array|null $cache = null; + + public bool|null $id = null; + + public bool|null $isOnDeleteCascade = null; + + /** @var array|null */ + public array|null $joinColumnFieldNames = null; + + /** @var list|null */ + public array|null $joinTableColumns = null; + + /** @var class-string|null */ + public string|null $originalClass = null; + + public string|null $originalField = null; + + public bool $orphanRemoval = false; + + public bool|null $unique = null; + + /** + * @param string $fieldName The name of the field in the entity + * the association is mapped to. + * @param class-string $sourceEntity The class name of the source entity. + * In the case of to-many associations + * initially present in mapped + * superclasses, the nearest + * entity subclasses will be + * considered the respective source + * entities. + * @param class-string $targetEntity The class name of the target entity. + * If it is fully-qualified it is used as + * is. If it is a simple, unqualified + * class name the namespace is assumed to + * be the same as the namespace of the + * source entity. + */ + final public function __construct( + public readonly string $fieldName, + public string $sourceEntity, + public readonly string $targetEntity, + ) { + } + + /** + * @psalm-param array{ + * fieldName: string, + * sourceEntity: class-string, + * targetEntity: class-string, + * joinTable?: mixed[]|null, + * type?: int, + * isOwningSide: bool, ...} $mappingArray + */ + public static function fromMappingArray(array $mappingArray): static + { + unset($mappingArray['isOwningSide'], $mappingArray['type']); + $mapping = new static( + $mappingArray['fieldName'], + $mappingArray['sourceEntity'], + $mappingArray['targetEntity'], + ); + unset($mappingArray['fieldName'], $mappingArray['sourceEntity'], $mappingArray['targetEntity']); + + foreach ($mappingArray as $key => $value) { + if ($key === 'joinTable') { + assert($mapping instanceof ManyToManyAssociationMapping); + + if ($value === [] || $value === null) { + continue; + } + + assert($mapping instanceof ManyToManyOwningSideMapping); + + $mapping->joinTable = JoinTableMapping::fromMappingArray($value); + + continue; + } + + if (property_exists($mapping, $key)) { + $mapping->$key = $value; + } else { + throw new OutOfRangeException('Unknown property ' . $key . ' on class ' . static::class); + } + } + + return $mapping; + } + + /** @psalm-assert-if-true AssociationOwningSideMapping $this */ + final public function isOwningSide(): bool + { + return $this instanceof AssociationOwningSideMapping; + } + + /** @psalm-assert-if-true ToOneAssociationMapping $this */ + final public function isToOne(): bool + { + return $this instanceof ToOneAssociationMapping; + } + + /** @psalm-assert-if-true ToManyAssociationMapping $this */ + final public function isToMany(): bool + { + return $this instanceof ToManyAssociationMapping; + } + + /** @psalm-assert-if-true OneToOneOwningSideMapping|ManyToOneAssociationMapping $this */ + final public function isToOneOwningSide(): bool + { + return $this->isToOne() && $this->isOwningSide(); + } + + /** @psalm-assert-if-true ManyToManyOwningSideMapping $this */ + final public function isManyToManyOwningSide(): bool + { + return $this instanceof ManyToManyOwningSideMapping; + } + + /** @psalm-assert-if-true OneToOneAssociationMapping $this */ + final public function isOneToOne(): bool + { + return $this instanceof OneToOneAssociationMapping; + } + + /** @psalm-assert-if-true ManyToManyAssociationMapping $this */ + final public function isManyToMany(): bool + { + return $this instanceof ManyToManyAssociationMapping; + } + + final public function type(): int + { + return match (true) { + $this instanceof OneToOneAssociationMapping => ClassMetadata::ONE_TO_ONE, + $this instanceof OneToManyAssociationMapping => ClassMetadata::ONE_TO_MANY, + $this instanceof ManyToOneAssociationMapping => ClassMetadata::MANY_TO_ONE, + $this instanceof ManyToManyAssociationMapping => ClassMetadata::MANY_TO_MANY, + default => throw new Exception('Cannot determine type for ' . $this::class), + }; + } + + /** @param string $offset */ + public function offsetExists(mixed $offset): bool + { + return isset($this->$offset) || in_array($offset, ['isOwningSide', 'type'], true); + } + + final public function offsetGet($offset): mixed + { + return match ($offset) { + 'isOwningSide' => $this->isOwningSide(), + 'type' => $this->type(), + 'isCascadeRemove' => $this->isCascadeRemove(), + 'isCascadePersist' => $this->isCascadePersist(), + 'isCascadeRefresh' => $this->isCascadeRefresh(), + 'isCascadeDetach' => $this->isCascadeDetach(), + 'isCascadeMerge' => $this->isCascadeMerge(), + default => property_exists($this, $offset) ? $this->$offset : throw new OutOfRangeException(sprintf( + 'Unknown property "%s" on class %s', + $offset, + static::class, + )), + }; + } + + public function offsetSet(mixed $offset, mixed $value): void + { + assert($offset !== null); + if (! property_exists($this, $offset)) { + throw new OutOfRangeException(sprintf( + 'Unknown property "%s" on class %s', + $offset, + static::class, + )); + } + + if ($offset === 'joinTable') { + $value = JoinTableMapping::fromMappingArray($value); + } + + $this->$offset = $value; + } + + /** @param string $offset */ + public function offsetUnset(mixed $offset): void + { + if (! property_exists($this, $offset)) { + throw new OutOfRangeException(sprintf( + 'Unknown property "%s" on class %s', + $offset, + static::class, + )); + } + + $this->$offset = null; + } + + final public function isCascadeRemove(): bool + { + return in_array('remove', $this->cascade, true); + } + + final public function isCascadePersist(): bool + { + return in_array('persist', $this->cascade, true); + } + + final public function isCascadeRefresh(): bool + { + return in_array('refresh', $this->cascade, true); + } + + final public function isCascadeMerge(): bool + { + return in_array('merge', $this->cascade, true); + } + + final public function isCascadeDetach(): bool + { + return in_array('detach', $this->cascade, true); + } + + /** @return array */ + public function toArray(): array + { + $array = (array) $this; + + $array['isOwningSide'] = $this->isOwningSide(); + $array['type'] = $this->type(); + + return $array; + } + + /** @return list */ + public function __sleep(): array + { + $serialized = ['fieldName', 'sourceEntity', 'targetEntity']; + + if (count($this->cascade) > 0) { + $serialized[] = 'cascade'; + } + + foreach ( + [ + 'mappedBy', + 'inversedBy', + 'fetch', + 'inherited', + 'declared', + 'cache', + 'joinColumnFieldNames', + 'joinTableColumns', + 'originalClass', + 'originalField', + ] as $stringOrArrayProperty + ) { + if ($this->$stringOrArrayProperty !== null) { + $serialized[] = $stringOrArrayProperty; + } + } + + foreach (['id', 'orphanRemoval', 'isOnDeleteCascade', 'unique'] as $boolProperty) { + if ($this->$boolProperty) { + $serialized[] = $boolProperty; + } + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/AssociationOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/AssociationOwningSideMapping.php new file mode 100644 index 00000000000..6230e72dedf --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/AssociationOwningSideMapping.php @@ -0,0 +1,9 @@ + - * @psalm-type JoinColumnData = array{ - * name: string, - * referencedColumnName: string, - * unique?: bool, - * quoted?: bool, - * fieldName?: string, - * onDelete?: string, - * columnDefinition?: string, - * nullable?: bool, - * } - * @psalm-type AssociationMapping = array{ - * cache?: array, - * cascade: array, - * declared?: class-string, - * fetch: mixed, - * fieldName: string, - * id?: bool, - * inherited?: class-string, - * indexBy?: string, - * inversedBy: string|null, - * isCascadeRemove: bool, - * isCascadePersist: bool, - * isCascadeRefresh: bool, - * isCascadeMerge: bool, - * isCascadeDetach: bool, - * isOnDeleteCascade?: bool, - * isOwningSide: bool, - * joinColumns?: array, - * joinColumnFieldNames?: array, - * joinTable?: array, - * joinTableColumns?: list, - * mappedBy: string|null, - * orderBy?: array, - * originalClass?: class-string, - * originalField?: string, - * orphanRemoval?: bool, - * relationToSourceKeyColumns?: array, - * relationToTargetKeyColumns?: array, - * sourceEntity: class-string, - * sourceToTargetKeyColumns?: array, - * targetEntity: class-string, - * targetToSourceKeyColumns?: array, - * type: int, - * unique?: bool, * } */ class ClassMetadata implements PersistenceClassMetadata, Stringable @@ -477,66 +429,6 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable /** * READ-ONLY: The association mappings of this class. * - * The mapping definition array supports the following keys: - * - * - fieldName (string) - * The name of the field in the entity the association is mapped to. - * - * - sourceEntity (string) - * The class name of the source entity. In the case of to-many associations initially - * present in mapped superclasses, the nearest entity subclasses will be - * considered the respective source entities. - * - * - targetEntity (string) - * The class name of the target entity. If it is fully-qualified it is used as is. - * If it is a simple, unqualified class name the namespace is assumed to be the same - * as the namespace of the source entity. - * - * - mappedBy (string, required for bidirectional associations) - * The name of the field that completes the bidirectional association on the owning side. - * This key must be specified on the inverse side of a bidirectional association. - * - * - inversedBy (string, required for bidirectional associations) - * The name of the field that completes the bidirectional association on the inverse side. - * This key must be specified on the owning side of a bidirectional association. - * - * - cascade (array, optional) - * The names of persistence operations to cascade on the association. The set of possible - * values are: "persist", "remove", "detach", "merge", "refresh", "all" (implies all others). - * - * - orderBy (array, one-to-many/many-to-many only) - * A map of field names (of the target entity) to sorting directions (ASC/DESC). - * Example: array('priority' => 'desc') - * - * - fetch (integer, optional) - * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. - * Possible values are: ClassMetadata::FETCH_EAGER, ClassMetadata::FETCH_LAZY. - * - * - joinTable (array, optional, many-to-many only) - * Specification of the join table and its join columns (foreign keys). - * Only valid for many-to-many mappings. Note that one-to-many associations can be mapped - * through a join table by simply mapping the association as many-to-many with a unique - * constraint on the join table. - * - * - indexBy (string, optional, to-many only) - * Specification of a field on target-entity that is used to index the collection by. - * This field HAS to be either the primary key or a unique column. Otherwise the collection - * does not contain all the entities that are actually related. - * - * - 'inherited' (string, optional) - * This is set when the association is inherited by this class from another (inheritance) parent - * entity class. The value is the FQCN of the topmost entity class that contains - * this association. (If there are transient classes in the - * class hierarchy, these are ignored, so the class property may in fact come - * from a class further up in the PHP class hierarchy.) - * To-many associations initially declared in mapped superclasses are - * not considered 'inherited' in the nearest entity subclasses. - * - * - 'declared' (string, optional) - * This is set when the association does not appear in the current class for the first time, but - * is initially declared in another parent entity or mapped superclass. The value is the FQCN - * of the topmost non-transient class that contains association information for this relationship. - * * A join table definition has the following structure: *
      * array(
@@ -546,7 +438,7 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable
      * )
      * 
* - * @psalm-var array + * @psalm-var array */ public array $associationMappings = []; @@ -1185,12 +1077,9 @@ public function getFieldMapping(string $fieldName): FieldMapping * @param string $fieldName The field name that represents the association in * the object model. * - * @return mixed[] The mapping. - * @psalm-return AssociationMapping - * * @throws MappingException */ - public function getAssociationMapping(string $fieldName): array + public function getAssociationMapping(string $fieldName): AssociationMapping { if (! isset($this->associationMappings[$fieldName])) { throw MappingException::mappingNotFound($this->name, $fieldName); @@ -1364,12 +1253,9 @@ protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping * * @psalm-param array $mapping The mapping. * - * @return mixed[] The updated mapping. - * @psalm-return AssociationMapping - * * @throws MappingException If something is wrong with the mapping. */ - protected function _validateAndCompleteAssociationMapping(array $mapping): array + protected function _validateAndCompleteAssociationMapping(array $mapping): AssociationMapping { if (! isset($mapping['mappedBy'])) { $mapping['mappedBy'] = null; @@ -1447,7 +1333,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping): array // Mandatory and optional attributes for either side if (! $mapping['mappedBy']) { - if (isset($mapping['joinTable']) && $mapping['joinTable']) { + if (isset($mapping['joinTable'])) { if (isset($mapping['joinTable']['name']) && $mapping['joinTable']['name'][0] === '`') { $mapping['joinTable']['name'] = trim($mapping['joinTable']['name'], '`'); $mapping['joinTable']['quoted'] = true; @@ -1480,239 +1366,58 @@ protected function _validateAndCompleteAssociationMapping(array $mapping): array ); } - $mapping['cascade'] = $cascades; - $mapping['isCascadeRemove'] = in_array('remove', $cascades, true); - $mapping['isCascadePersist'] = in_array('persist', $cascades, true); - $mapping['isCascadeRefresh'] = in_array('refresh', $cascades, true); - $mapping['isCascadeMerge'] = in_array('merge', $cascades, true); - $mapping['isCascadeDetach'] = in_array('detach', $cascades, true); - - return $mapping; - } - - /** - * Validates & completes a one-to-one association mapping. - * - * @psalm-param array $mapping The mapping to validate & complete. - * - * @return mixed[] The validated & completed mapping. - * @psalm-return AssociationMapping - * - * @throws RuntimeException - * @throws MappingException - */ - protected function _validateAndCompleteOneToOneMapping(array $mapping): array - { - $mapping = $this->_validateAndCompleteAssociationMapping($mapping); - - if (isset($mapping['joinColumns']) && $mapping['joinColumns']) { - $mapping['isOwningSide'] = true; - } - - if ($mapping['isOwningSide']) { - if (empty($mapping['joinColumns'])) { - // Apply default join column - $mapping['joinColumns'] = [ - [ - 'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name), - 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), - ], - ]; - } - - $uniqueConstraintColumns = []; - - foreach ($mapping['joinColumns'] as &$joinColumn) { - if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { - if (count($mapping['joinColumns']) === 1) { - if (empty($mapping['id'])) { - $joinColumn['unique'] = true; - } - } else { - $uniqueConstraintColumns[] = $joinColumn['name']; - } - } - - if (empty($joinColumn['name'])) { - $joinColumn['name'] = $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name); - } - - if (empty($joinColumn['referencedColumnName'])) { - $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); - } - - if ($joinColumn['name'][0] === '`') { - $joinColumn['name'] = trim($joinColumn['name'], '`'); - $joinColumn['quoted'] = true; - } - - if ($joinColumn['referencedColumnName'][0] === '`') { - $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`'); - $joinColumn['quoted'] = true; - } - - $mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; - $mapping['joinColumnFieldNames'][$joinColumn['name']] = $joinColumn['fieldName'] ?? $joinColumn['name']; - } - - if ($uniqueConstraintColumns) { - if (! $this->table) { - throw new RuntimeException('ClassMetadata::setTable() has to be called before defining a one to one relationship.'); - } - - $this->table['uniqueConstraints'][$mapping['fieldName'] . '_uniq'] = ['columns' => $uniqueConstraintColumns]; - } - - $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']); - } - - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; - $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; - - if ($mapping['orphanRemoval']) { - unset($mapping['unique']); - } - - if (isset($mapping['id']) && $mapping['id'] === true && ! $mapping['isOwningSide']) { - throw MappingException::illegalInverseIdentifierAssociation($this->name, $mapping['fieldName']); - } - - return $mapping; - } - - /** - * Validates & completes a one-to-many association mapping. - * - * @psalm-param array $mapping The mapping to validate and complete. - * - * @return mixed[] The validated and completed mapping. - * @psalm-return AssociationMapping - * - * @throws MappingException - * @throws InvalidArgumentException - */ - protected function _validateAndCompleteOneToManyMapping(array $mapping): array - { - $mapping = $this->_validateAndCompleteAssociationMapping($mapping); - - // OneToMany-side MUST be inverse (must have mappedBy) - if (! isset($mapping['mappedBy'])) { - throw MappingException::oneToManyRequiresMappedBy($this->name, $mapping['fieldName']); - } - - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; - $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; - - $this->assertMappingOrderBy($mapping); - - return $mapping; - } - - /** - * Validates & completes a many-to-many association mapping. - * - * @psalm-param array $mapping The mapping to validate & complete. - * - * @return mixed[] The validated & completed mapping. - * @psalm-return AssociationMapping - * - * @throws InvalidArgumentException - */ - protected function _validateAndCompleteManyToManyMapping(array $mapping): array - { - $mapping = $this->_validateAndCompleteAssociationMapping($mapping); - - if ($mapping['isOwningSide']) { - // owning side MUST have a join table - if (! isset($mapping['joinTable']['name'])) { - $mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']); - } - - $selfReferencingEntityWithoutJoinColumns = $mapping['sourceEntity'] === $mapping['targetEntity'] - && (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns']))); - - if (! isset($mapping['joinTable']['joinColumns'])) { - $mapping['joinTable']['joinColumns'] = [ - [ - 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null), - 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), - 'onDelete' => 'CASCADE', - ], - ]; - } - - if (! isset($mapping['joinTable']['inverseJoinColumns'])) { - $mapping['joinTable']['inverseJoinColumns'] = [ - [ - 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null), - 'referencedColumnName' => $this->namingStrategy->referenceColumnName(), - 'onDelete' => 'CASCADE', - ], - ]; - } - - $mapping['joinTableColumns'] = []; - - foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) { - if (empty($joinColumn['name'])) { - $joinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $joinColumn['referencedColumnName']); - } - - if (empty($joinColumn['referencedColumnName'])) { - $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); - } - - if ($joinColumn['name'][0] === '`') { - $joinColumn['name'] = trim($joinColumn['name'], '`'); - $joinColumn['quoted'] = true; - } + $mapping['cascade'] = $cascades; - if ($joinColumn['referencedColumnName'][0] === '`') { - $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`'); - $joinColumn['quoted'] = true; - } - - if (isset($joinColumn['onDelete']) && strtolower($joinColumn['onDelete']) === 'cascade') { - $mapping['isOnDeleteCascade'] = true; + switch ($mapping['type']) { + case self::ONE_TO_ONE: + if (isset($mapping['joinColumns']) && $mapping['joinColumns']) { + $mapping['isOwningSide'] = true; } - $mapping['relationToSourceKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; - $mapping['joinTableColumns'][] = $joinColumn['name']; - } - - foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) { - if (empty($inverseJoinColumn['name'])) { - $inverseJoinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $inverseJoinColumn['referencedColumnName']); - } + return $mapping['isOwningSide'] ? + OneToOneOwningSideMapping::fromMappingArrayAndName( + $mapping, + $this->namingStrategy, + $this->name, + $this->table ?? null, + $this->isInheritanceTypeSingleTable(), + ) : + OneToOneAssociationMapping::fromMappingArrayAndName( + $mapping, + $this->namingStrategy, + $this->name, + $this->table, + $this->isInheritanceTypeSingleTable(), + ); - if (empty($inverseJoinColumn['referencedColumnName'])) { - $inverseJoinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName(); - } + case self::MANY_TO_ONE: + return ManyToOneAssociationMapping::fromMappingArrayAndName( + $mapping, + $this->namingStrategy, + $this->name, + $this->table, + $this->isInheritanceTypeSingleTable(), + ); - if ($inverseJoinColumn['name'][0] === '`') { - $inverseJoinColumn['name'] = trim($inverseJoinColumn['name'], '`'); - $inverseJoinColumn['quoted'] = true; - } + case self::ONE_TO_MANY: + return OneToManyAssociationMapping::fromMappingArrayAndName($mapping, $this->name); - if ($inverseJoinColumn['referencedColumnName'][0] === '`') { - $inverseJoinColumn['referencedColumnName'] = trim($inverseJoinColumn['referencedColumnName'], '`'); - $inverseJoinColumn['quoted'] = true; + case self::MANY_TO_MANY: + if (isset($mapping['joinColumns'])) { + unset($mapping['joinColumns']); } - if (isset($inverseJoinColumn['onDelete']) && strtolower($inverseJoinColumn['onDelete']) === 'cascade') { - $mapping['isOnDeleteCascade'] = true; - } + return $mapping['isOwningSide'] ? + ManyToManyOwningSideMapping::fromMappingArrayAndNamingStrategy($mapping, $this->namingStrategy) : + ManyToManyAssociationMapping::fromMappingArray($mapping); - $mapping['relationToTargetKeyColumns'][$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName']; - $mapping['joinTableColumns'][] = $inverseJoinColumn['name']; - } + default: + throw MappingException::invalidAssociationType( + $this->name, + $mapping['fieldName'], + $mapping['type'], + ); } - - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; - - $this->assertMappingOrderBy($mapping); - - return $mapping; } /** @@ -1814,7 +1519,7 @@ public function getIdentifierColumnNames(): array // Association defined as Id field $joinColumns = $this->associationMappings[$idProperty]['joinColumns']; - $assocColumnNames = array_map(static fn ($joinColumn) => $joinColumn['name'], $joinColumns); + $assocColumnNames = array_map(static fn (JoinColumnMapping $joinColumn): string => $joinColumn['name'], $joinColumns); $columnNames = array_merge($columnNames, $assocColumnNames); } @@ -1989,7 +1694,7 @@ public function setAssociationOverride(string $fieldName, array $overrideMapping throw MappingException::invalidOverrideFieldName($this->name, $fieldName); } - $mapping = $this->associationMappings[$fieldName]; + $mapping = $this->associationMappings[$fieldName]->toArray(); //if (isset($mapping['inherited']) && (count($overrideMapping) !== 1 || ! isset($overrideMapping['fetch']))) { // TODO: Deprecate overriding the fetch mode via association override for 3.0, @@ -2014,28 +1719,21 @@ public function setAssociationOverride(string $fieldName, array $overrideMapping $mapping['fetch'] = $overrideMapping['fetch']; } - $mapping['joinColumnFieldNames'] = null; - $mapping['joinTableColumns'] = null; - $mapping['sourceToTargetKeyColumns'] = null; - $mapping['relationToSourceKeyColumns'] = null; - $mapping['relationToTargetKeyColumns'] = null; + $mapping['joinColumnFieldNames'] = null; + $mapping['joinTableColumns'] = null; switch ($mapping['type']) { case self::ONE_TO_ONE: - $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); - break; - case self::ONE_TO_MANY: - $mapping = $this->_validateAndCompleteOneToManyMapping($mapping); - break; case self::MANY_TO_ONE: - $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); + $mapping['sourceToTargetKeyColumns'] = null; break; case self::MANY_TO_MANY: - $mapping = $this->_validateAndCompleteManyToManyMapping($mapping); + $mapping['relationToSourceKeyColumns'] = null; + $mapping['relationToTargetKeyColumns'] = null; break; } - $this->associationMappings[$fieldName] = $mapping; + $this->associationMappings[$fieldName] = $this->_validateAndCompleteAssociationMapping($mapping); } /** @@ -2204,11 +1902,9 @@ public function mapField(array $mapping): void * Adds an association mapping without completing/validating it. * This is mainly used to add inherited association mappings to derived classes. * - * @psalm-param AssociationMapping $mapping - * * @throws MappingException */ - public function addInheritedAssociationMapping(array $mapping/*, $owningClassName = null*/): void + public function addInheritedAssociationMapping(AssociationMapping $mapping/*, $owningClassName = null*/): void { if (isset($this->associationMappings[$mapping['fieldName']])) { throw MappingException::duplicateAssociationMapping($this->name, $mapping['fieldName']); @@ -2238,7 +1934,7 @@ public function mapOneToOne(array $mapping): void { $mapping['type'] = self::ONE_TO_ONE; - $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); + $mapping = $this->_validateAndCompleteAssociationMapping($mapping); $this->_storeAssociationMapping($mapping); } @@ -2252,7 +1948,7 @@ public function mapOneToMany(array $mapping): void { $mapping['type'] = self::ONE_TO_MANY; - $mapping = $this->_validateAndCompleteOneToManyMapping($mapping); + $mapping = $this->_validateAndCompleteAssociationMapping($mapping); $this->_storeAssociationMapping($mapping); } @@ -2266,8 +1962,7 @@ public function mapManyToOne(array $mapping): void { $mapping['type'] = self::MANY_TO_ONE; - // A many-to-one mapping is essentially a one-one backreference - $mapping = $this->_validateAndCompleteOneToOneMapping($mapping); + $mapping = $this->_validateAndCompleteAssociationMapping($mapping); $this->_storeAssociationMapping($mapping); } @@ -2281,7 +1976,7 @@ public function mapManyToMany(array $mapping): void { $mapping['type'] = self::MANY_TO_MANY; - $mapping = $this->_validateAndCompleteManyToManyMapping($mapping); + $mapping = $this->_validateAndCompleteAssociationMapping($mapping); $this->_storeAssociationMapping($mapping); } @@ -2289,11 +1984,9 @@ public function mapManyToMany(array $mapping): void /** * Stores the association mapping. * - * @psalm-param array $assocMapping - * * @throws MappingException */ - protected function _storeAssociationMapping(array $assocMapping): void + protected function _storeAssociationMapping(AssociationMapping $assocMapping): void { $sourceFieldName = $assocMapping['fieldName']; @@ -2538,13 +2231,13 @@ public function hasAssociation(string $fieldName): bool public function isSingleValuedAssociation(string $fieldName): bool { return isset($this->associationMappings[$fieldName]) - && ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); + && ($this->associationMappings[$fieldName]->isToOne()); } public function isCollectionValuedAssociation(string $fieldName): bool { return isset($this->associationMappings[$fieldName]) - && ! ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); + && ! $this->associationMappings[$fieldName]->isToOne(); } /** @@ -2911,14 +2604,6 @@ public function getSequencePrefix(AbstractPlatform $platform): string return $sequencePrefix; } - /** @psalm-param array $mapping */ - private function assertMappingOrderBy(array $mapping): void - { - if (isset($mapping['orderBy']) && ! is_array($mapping['orderBy'])) { - throw new InvalidArgumentException("'orderBy' is expected to be an array, not " . gettype($mapping['orderBy'])); - } - } - /** @psalm-param class-string $class */ private function getAccessibleProperty(ReflectionService $reflService, string $class, string $field): ReflectionProperty|null { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 3b0a50e69a9..63edd9df5a4 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -45,7 +45,6 @@ * to a relational database. * * @extends AbstractClassMetadataFactory - * @psalm-import-type AssociationMapping from ClassMetadata */ class ClassMetadataFactory extends AbstractClassMetadataFactory { @@ -385,7 +384,7 @@ private function getShortName(string $className): string * and embedded classes. */ private function addMappingInheritanceInformation( - array|EmbeddedClassMapping|FieldMapping &$mapping, + AssociationMapping|EmbeddedClassMapping|FieldMapping $mapping, ClassMetadata $parentClass, ): void { if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { @@ -421,18 +420,19 @@ private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $pare private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass): void { foreach ($parentClass->associationMappings as $field => $mapping) { - $this->addMappingInheritanceInformation($mapping, $parentClass); + $subClassMapping = clone $mapping; + $this->addMappingInheritanceInformation($subClassMapping, $parentClass); // When the class inheriting the relation ($subClass) is the first entity class since the // relation has been defined in a mapped superclass (or in a chain // of mapped superclasses) above, then declare this current entity class as the source of // the relationship. // According to the definitions given in https://github.com/doctrine/orm/pull/10396/, // this is the case <=> ! isset($mapping['inherited']). - if (! isset($mapping['inherited'])) { - $mapping['sourceEntity'] = $subClass->name; + if (! isset($subClassMapping['inherited'])) { + $subClassMapping['sourceEntity'] = $subClass->name; } - $subClass->addInheritedAssociationMapping($mapping); + $subClass->addInheritedAssociationMapping($subClassMapping); } } diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index 86df5209054..0b29cc95d3b 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -55,21 +55,15 @@ public function getSequenceName(array $definition, ClassMetadata $class, Abstrac : $definition['sequenceName']; } - /** - * {@inheritdoc} - */ - public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string + public function getJoinColumnName(JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string { return isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['name']) : $joinColumn['name']; } - /** - * {@inheritdoc} - */ public function getReferencedJoinColumnName( - array $joinColumn, + JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform, ): string { @@ -78,11 +72,11 @@ public function getReferencedJoinColumnName( : $joinColumn['referencedColumnName']; } - /** - * {@inheritdoc} - */ - public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform): string - { + public function getJoinTableName( + AssociationMapping $association, + ClassMetadata $class, + AbstractPlatform $platform, + ): string { $schema = ''; if (isset($association['joinTable']['schema'])) { @@ -115,7 +109,7 @@ public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform // Association defined as Id field $joinColumns = $class->associationMappings[$fieldName]['joinColumns']; $assocQuotedColumnNames = array_map( - static fn (array $joinColumn) => isset($joinColumn['quoted']) + static fn (JoinColumnMapping $joinColumn) => isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['name']) : $joinColumn['name'], $joinColumns, diff --git a/lib/Doctrine/ORM/Mapping/JoinColumnMapping.php b/lib/Doctrine/ORM/Mapping/JoinColumnMapping.php new file mode 100644 index 00000000000..37ea4728b61 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/JoinColumnMapping.php @@ -0,0 +1,67 @@ + */ +final class JoinColumnMapping implements ArrayAccess +{ + use ArrayAccessImplementation; + + public string|null $name = null; + public bool|null $unique = null; + public bool|null $quoted = null; + public string|null $fieldName = null; + public string|null $onDelete = null; + public string|null $columnDefinition = null; + public bool|null $nullable = null; + + /** @var array|null */ + public array|null $options = null; + + public function __construct( + public string $referencedColumnName, + ) { + } + + /** + * @param array $mappingArray + * @psalm-param array{name: string, referencedColumnName: string, ...} $mappingArray + */ + public static function fromMappingArray(array $mappingArray): self + { + $mapping = new self($mappingArray['referencedColumnName']); + foreach ($mappingArray as $key => $value) { + if (property_exists($mapping, $key) && $value !== null) { + $mapping->$key = $value; + } + } + + return $mapping; + } + + /** @return list */ + public function __sleep(): array + { + $serialized = []; + + foreach (['name', 'fieldName', 'onDelete', 'columnDefinition', 'referencedColumnName', 'options'] as $stringOrArrayKey) { + if ($this->$stringOrArrayKey !== null) { + $serialized[] = $stringOrArrayKey; + } + } + + foreach (['unique', 'quoted', 'nullable'] as $boolKey) { + if ($this->$boolKey !== null) { + $serialized[] = $boolKey; + } + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php new file mode 100644 index 00000000000..30283ee9c8a --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php @@ -0,0 +1,100 @@ + */ +final class JoinTableMapping implements ArrayAccess +{ + use ArrayAccessImplementation; + + public bool|null $quoted = null; + + /** @var list */ + public array $joinColumns = []; + + /** @var list */ + public array $inverseJoinColumns = []; + + public string|null $schema = null; + + public string|null $name = null; + + /** @param array{name?: string, quoted?: bool, joinColumns?: mixed[], inverseJoinColumns?: mixed[], schema?: string} $mappingArray */ + public static function fromMappingArray(array $mappingArray): self + { + $mapping = new self(); + + foreach (['name', 'quoted', 'schema'] as $key) { + if (isset($mappingArray[$key])) { + $mapping[$key] = $mappingArray[$key]; + } + } + + if (isset($mappingArray['joinColumns'])) { + foreach ($mappingArray['joinColumns'] as $column) { + $mapping->joinColumns[] = JoinColumnMapping::fromMappingArray($column); + } + } + + if (isset($mappingArray['inverseJoinColumns'])) { + foreach ($mappingArray['inverseJoinColumns'] as $column) { + $mapping->inverseJoinColumns[] = JoinColumnMapping::fromMappingArray($column); + } + } + + return $mapping; + } + + public function offsetSet(mixed $offset, mixed $value): void + { + if (in_array($offset, ['joinColumns', 'inverseJoinColumns'], true)) { + $joinColumns = []; + foreach ($value as $column) { + $joinColumns[] = JoinColumnMapping::fromMappingArray($column); + } + + $value = $joinColumns; + } + + $this->$offset = $value; + } + + /** @return mixed[] */ + public function toArray(): array + { + $array = (array) $this; + + $toArray = static fn (JoinColumnMapping $column): array => (array) $column; + $array['joinColumns'] = array_map($toArray, $array['joinColumns']); + $array['inverseJoinColumns'] = array_map($toArray, $array['inverseJoinColumns']); + + return $array; + } + + /** @return list */ + public function __sleep(): array + { + $serialized = []; + + foreach (['joinColumns', 'inverseJoinColumns', 'name', 'schema'] as $stringOrArrayKey) { + if ($this->$stringOrArrayKey !== null) { + $serialized[] = $stringOrArrayKey; + } + } + + foreach (['quoted'] as $boolKey) { + if ($this->$boolKey) { + $serialized[] = $boolKey; + } + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php new file mode 100644 index 00000000000..d2d2666e60f --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php @@ -0,0 +1,25 @@ + */ + public function __sleep(): array + { + $serialized = parent::__sleep(); + + foreach (['relationToSourceKeyColumns', 'relationToTargetKeyColumns'] as $arrayKey) { + if ($this->$arrayKey !== null) { + $serialized[] = $arrayKey; + } + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php new file mode 100644 index 00000000000..0c88018f239 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php @@ -0,0 +1,136 @@ + */ + public function toArray(): array + { + $array = parent::toArray(); + + $array['joinTable'] = $this->joinTable->toArray(); + + return $array; + } + + /** @param mixed[] $mappingArray */ + public static function fromMappingArrayAndNamingStrategy(array $mappingArray, NamingStrategy $namingStrategy): self + { + $mapping = parent::fromMappingArray($mappingArray); + + // owning side MUST have a join table + if (! isset($mapping->joinTable->name)) { + $mapping->joinTable ??= new JoinTableMapping(); + $mapping->joinTable->name = $namingStrategy->joinTableName( + $mapping->sourceEntity, + $mapping->targetEntity, + $mapping->fieldName, + ); + } + + $selfReferencingEntityWithoutJoinColumns = $mapping->sourceEntity === $mapping->targetEntity + && $mapping->joinTable->joinColumns === [] + && $mapping->joinTable->inverseJoinColumns === []; + + if ($mapping->joinTable->joinColumns === []) { + $mapping->joinTable->joinColumns = [ + JoinColumnMapping::fromMappingArray([ + 'name' => $namingStrategy->joinKeyColumnName($mapping->sourceEntity, $selfReferencingEntityWithoutJoinColumns ? 'source' : null), + 'referencedColumnName' => $namingStrategy->referenceColumnName(), + 'onDelete' => 'CASCADE', + ]), + ]; + } + + if ($mapping->joinTable->inverseJoinColumns === []) { + $mapping->joinTable->inverseJoinColumns = [ + JoinColumnMapping::fromMappingArray([ + 'name' => $namingStrategy->joinKeyColumnName($mapping->targetEntity, $selfReferencingEntityWithoutJoinColumns ? 'target' : null), + 'referencedColumnName' => $namingStrategy->referenceColumnName(), + 'onDelete' => 'CASCADE', + ]), + ]; + } + + $mapping->joinTableColumns = []; + + foreach ($mapping->joinTable->joinColumns as $joinColumn) { + if (empty($joinColumn->name)) { + $joinColumn->name = $namingStrategy->joinKeyColumnName($mapping->sourceEntity, $joinColumn->referencedColumnName); + } + + if (empty($joinColumn->referencedColumnName)) { + $joinColumn->referencedColumnName = $namingStrategy->referenceColumnName(); + } + + if ($joinColumn->name[0] === '`') { + $joinColumn->name = trim($joinColumn->name, '`'); + $joinColumn->quoted = true; + } + + if ($joinColumn->referencedColumnName[0] === '`') { + $joinColumn->referencedColumnName = trim($joinColumn->referencedColumnName, '`'); + $joinColumn->quoted = true; + } + + if (isset($joinColumn->onDelete) && strtolower($joinColumn->onDelete) === 'cascade') { + $mapping->isOnDeleteCascade = true; + } + + $mapping->relationToSourceKeyColumns[$joinColumn->name] = $joinColumn->referencedColumnName; + $mapping->joinTableColumns[] = $joinColumn->name; + } + + foreach ($mapping->joinTable->inverseJoinColumns as $inverseJoinColumn) { + if (empty($inverseJoinColumn->name)) { + $inverseJoinColumn->name = $namingStrategy->joinKeyColumnName($mapping->targetEntity, $inverseJoinColumn->referencedColumnName); + } + + if (empty($inverseJoinColumn->referencedColumnName)) { + $inverseJoinColumn->referencedColumnName = $namingStrategy->referenceColumnName(); + } + + if ($inverseJoinColumn->name[0] === '`') { + $inverseJoinColumn->name = trim($inverseJoinColumn->name, '`'); + $inverseJoinColumn->quoted = true; + } + + if ($inverseJoinColumn->referencedColumnName[0] === '`') { + $inverseJoinColumn->referencedColumnName = trim($inverseJoinColumn->referencedColumnName, '`'); + $inverseJoinColumn->quoted = true; + } + + if (isset($inverseJoinColumn->onDelete) && strtolower($inverseJoinColumn->onDelete) === 'cascade') { + $mapping->isOnDeleteCascade = true; + } + + $mapping->relationToTargetKeyColumns[$inverseJoinColumn->name] = $inverseJoinColumn->referencedColumnName; + $mapping->joinTableColumns[] = $inverseJoinColumn->name; + } + + return $mapping; + } + + /** @return list */ + public function __sleep(): array + { + $serialized = parent::__sleep(); + $serialized[] = 'joinTable'; + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php new file mode 100644 index 00000000000..501f66b5893 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php @@ -0,0 +1,24 @@ + */ + public array $joinColumns = []; + + /** @return list */ + public function __sleep(): array + { + $serialized = parent::__sleep(); + + $serialized[] = 'joinColumns'; + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 801ba83b272..b172c174c26 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -44,6 +44,16 @@ public static function identifierRequired(string $entityName): self )); } + public static function invalidAssociationType(string $entityName, string $fieldName, int $type): self + { + return new self(sprintf( + 'The association "%s#%s" must be of type "ClassMetadata::ONE_TO_MANY", "ClassMetadata::MANY_TO_MANY" or "ClassMetadata::MANY_TO_ONE", "%d" given.', + $entityName, + $fieldName, + $type, + )); + } + public static function invalidInheritanceType(string $entityName, int $type): self { return new self(sprintf("The inheritance type '%s' specified for '%s' does not exist.", $type, $entityName)); diff --git a/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php new file mode 100644 index 00000000000..6ff2bbf9909 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php @@ -0,0 +1,33 @@ +orphanRemoval && ! $mapping->isCascadeRemove()) { + $mapping->cascade[] = 'remove'; + } + + return $mapping; + } + + /** @param mixed[] $mappingArray */ + public static function fromMappingArrayAndName(array $mappingArray, string $name): static + { + $mapping = self::fromMappingArray($mappingArray); + + // OneToMany-side MUST be inverse (must have mappedBy) + if (! isset($mapping->mappedBy)) { + throw MappingException::oneToManyRequiresMappedBy($name, $mapping->fieldName); + } + + return $mapping; + } +} diff --git a/lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php b/lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php new file mode 100644 index 00000000000..6faafc3ee51 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php @@ -0,0 +1,9 @@ + */ + public array $joinColumns = []; + + /** @return list */ + public function __sleep(): array + { + $serialized = parent::__sleep(); + + $serialized[] = 'joinColumns'; + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php index 0edfd59dc90..7b553222c85 100644 --- a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php @@ -8,9 +8,6 @@ /** * A set of rules for determining the column, alias and table quotes. - * - * @psalm-import-type AssociationMapping from ClassMetadata - * @psalm-import-type JoinColumnData from ClassMetadata */ interface QuoteStrategy { @@ -31,27 +28,19 @@ public function getTableName(ClassMetadata $class, AbstractPlatform $platform): */ public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform): string; - /** - * Gets the (possibly quoted) name of the join table. - * - * @param AssociationMapping $association - */ - public function getJoinTableName(array $association, ClassMetadata $class, AbstractPlatform $platform): string; + /** Gets the (possibly quoted) name of the join table. */ + public function getJoinTableName(AssociationMapping $association, ClassMetadata $class, AbstractPlatform $platform): string; /** * Gets the (possibly quoted) join column name. - * - * @param JoinColumnData $joinColumn */ - public function getJoinColumnName(array $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string; + public function getJoinColumnName(JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string; /** * Gets the (possibly quoted) join column name. - * - * @param JoinColumnData $joinColumn */ public function getReferencedJoinColumnName( - array $joinColumn, + JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform, ): string; diff --git a/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php new file mode 100644 index 00000000000..1db301d0430 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php @@ -0,0 +1,37 @@ +|null + */ + public array|null $orderBy = null; + + /** @return list */ + public function __sleep(): array + { + $serialized = parent::__sleep(); + + foreach (['indexBy', 'orderBy'] as $stringOrArrayKey) { + if ($this->$stringOrArrayKey !== null) { + $serialized[] = $stringOrArrayKey; + } + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php new file mode 100644 index 00000000000..5e8b74e4315 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php @@ -0,0 +1,190 @@ +|null */ + public array|null $sourceToTargetKeyColumns = null; + + /** @var array|null */ + public array|null $targetToSourceKeyColumns = null; + + /** + * @param array $mappingArray + * @psalm-param array{ + * fieldName: string, + * sourceEntity: class-string, + * targetEntity: class-string, + * joinColumns?: mixed[]|null, + * isOwningSide: bool, ...} $mappingArray + */ + public static function fromMappingArray(array $mappingArray): static + { + $joinColumns = $mappingArray['joinColumns'] ?? []; + + if (isset($mappingArray['joinColumns'])) { + unset($mappingArray['joinColumns']); + } + + $instance = parent::fromMappingArray($mappingArray); + + foreach ($joinColumns as $column) { + assert($instance->isToOneOwningSide()); + $instance->joinColumns[] = JoinColumnMapping::fromMappingArray($column); + } + + if ($instance->orphanRemoval) { + if (! $instance->isCascadeRemove()) { + $instance->cascade[] = 'remove'; + } + + $instance->unique = null; + } + + return $instance; + } + + /** + * @param mixed[] $mappingArray + * @param class-string $name + * @psalm-param array{ + * fieldName: string, + * sourceEntity: class-string, + * targetEntity: class-string, + * joinColumns?: mixed[]|null, + * isOwningSide: bool, ...} $mappingArray + */ + public static function fromMappingArrayAndName( + array $mappingArray, + NamingStrategy $namingStrategy, + string $name, + array|null $table, + bool $isInheritanceTypeSingleTable, + ): OneToOneAssociationMapping|ManyToOneAssociationMapping { + $mapping = static::fromMappingArray($mappingArray); + + if ($mapping->isOwningSide()) { + assert($mapping instanceof OneToOneOwningSideMapping || $mapping instanceof ManyToOneAssociationMapping); + if (empty($mapping->joinColumns)) { + // Apply default join column + $mapping->joinColumns = [ + JoinColumnMapping::fromMappingArray([ + 'name' => $namingStrategy->joinColumnName($mapping['fieldName'], $name), + 'referencedColumnName' => $namingStrategy->referenceColumnName(), + ]), + ]; + } + + $uniqueConstraintColumns = []; + + foreach ($mapping->joinColumns as $joinColumn) { + if ($mapping->isOneToOne() && ! $isInheritanceTypeSingleTable) { + if (count($mapping->joinColumns) === 1) { + if (empty($mapping->id)) { + $joinColumn->unique = true; + } + } else { + $uniqueConstraintColumns[] = $joinColumn->name; + } + } + + if (empty($joinColumn->name)) { + $joinColumn->name = $namingStrategy->joinColumnName($mapping->fieldName, $name); + } + + if (empty($joinColumn->referencedColumnName)) { + $joinColumn->referencedColumnName = $namingStrategy->referenceColumnName(); + } + + if ($joinColumn->name[0] === '`') { + $joinColumn->name = trim($joinColumn->name, '`'); + $joinColumn->quoted = true; + } + + if ($joinColumn->referencedColumnName[0] === '`') { + $joinColumn->referencedColumnName = trim($joinColumn->referencedColumnName, '`'); + $joinColumn->quoted = true; + } + + $mapping->sourceToTargetKeyColumns[$joinColumn->name] = $joinColumn->referencedColumnName; + $mapping->joinColumnFieldNames[$joinColumn->name] = $joinColumn->fieldName ?? $joinColumn->name; + } + + if ($uniqueConstraintColumns) { + if (! $table) { + throw new RuntimeException('ClassMetadata::setTable() has to be called before defining a one to one relationship.'); + } + + $table['uniqueConstraints'][$mapping->fieldName . '_uniq'] = ['columns' => $uniqueConstraintColumns]; + } + + $mapping->targetToSourceKeyColumns = array_flip($mapping->sourceToTargetKeyColumns); + } + + if (isset($mapping->id) && $mapping->id === true && ! $mapping->isOwningSide()) { + throw MappingException::illegalInverseIdentifierAssociation($name, $mapping->fieldName); + } + + return $mapping; + } + + public function offsetSet(mixed $offset, mixed $value): void + { + if ($offset === 'joinColumns') { + assert($this->isToOneOwningSide()); + $joinColumns = []; + foreach ($value as $column) { + $joinColumns[] = JoinColumnMapping::fromMappingArray($column); + } + + $this->joinColumns = $joinColumns; + + return; + } + + parent::offsetSet($offset, $value); + } + + /** @return array */ + public function toArray(): array + { + $array = parent::toArray(); + + if ($array['joinColumns'] !== []) { + $joinColumns = []; + foreach ($array['joinColumns'] as $column) { + $joinColumns[] = (array) $column; + } + + $array['joinColumns'] = $joinColumns; + } + + return $array; + } + + /** @return list */ + public function __sleep(): array + { + $serialized = parent::__sleep(); + + if ($this->sourceToTargetKeyColumns !== null) { + $serialized[] = 'sourceToTargetKeyColumns'; + } + + if ($this->targetToSourceKeyColumns !== null) { + $serialized[] = 'targetToSourceKeyColumns'; + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index 9f9d8a48cfb..2b0b146f42a 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use InvalidArgumentException; use Stringable; @@ -19,8 +20,6 @@ /** * Contains exception messages for all invalid lifecycle state exceptions inside UnitOfWork - * - * @psalm-import-type AssociationMapping from ClassMetadata */ class ORMInvalidArgumentException extends InvalidArgumentException { @@ -52,10 +51,7 @@ public static function readOnlyRequiresManagedEntity(object $entity): self return new self('Only managed entities can be marked or checked as read only. But ' . self::objToStr($entity) . ' is not'); } - /** - * @psalm-param non-empty-list $newEntitiesWithAssociations non-empty an array - * of [array $associationMapping, object $entity] pairs - */ + /** @param non-empty-list $newEntitiesWithAssociations */ public static function newEntitiesFoundThroughRelationships(array $newEntitiesWithAssociations): self { $errorMessages = array_map( @@ -78,14 +74,12 @@ static function (array $newEntityWithAssociation): string { ); } - /** @psalm-param AssociationMapping $associationMapping */ - public static function newEntityFoundThroughRelationship(array $associationMapping, object $entry): self + public static function newEntityFoundThroughRelationship(AssociationMapping $associationMapping, object $entry): self { return new self(self::newEntityFoundThroughRelationshipMessage($associationMapping, $entry)); } - /** @psalm-param AssociationMapping $assoc */ - public static function detachedEntityFoundThroughRelationship(array $assoc, object $entry): self + public static function detachedEntityFoundThroughRelationship(AssociationMapping $assoc, object $entry): self { return new self('A detached entity of type ' . $assoc['targetEntity'] . ' (' . self::objToStr($entry) . ') ' . " was found through the relationship '" . $assoc['sourceEntity'] . '#' . $assoc['fieldName'] . "' " @@ -137,8 +131,7 @@ public static function invalidIdentifierBindingEntity(string $class): self )); } - /** @param AssociationMapping $assoc */ - public static function invalidAssociation(ClassMetadata $targetClass, array $assoc, mixed $actualValue): self + public static function invalidAssociation(ClassMetadata $targetClass, AssociationMapping $assoc, mixed $actualValue): self { $expectedType = $targetClass->getName(); @@ -159,8 +152,7 @@ private static function objToStr(object $obj): string return $obj instanceof Stringable ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj); } - /** @psalm-param AssociationMapping $associationMapping */ - private static function newEntityFoundThroughRelationshipMessage(array $associationMapping, object $entity): string + private static function newEntityFoundThroughRelationshipMessage(AssociationMapping $associationMapping, object $entity): string { return 'A new entity was found through the relationship \'' . $associationMapping['sourceEntity'] . '#' . $associationMapping['fieldName'] . '\' that was not' diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 041963e6b54..41e5a886e70 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -9,7 +9,9 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\ManyToManyOwningSideMapping; use RuntimeException; use function array_combine; @@ -34,7 +36,6 @@ * @psalm-template T * @template-extends AbstractLazyCollection * @template-implements Selectable - * @psalm-import-type AssociationMapping from ClassMetadata */ final class PersistentCollection extends AbstractLazyCollection implements Selectable { @@ -54,10 +55,8 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec /** * The association mapping the collection belongs to. * This is currently either a OneToManyMapping or a ManyToManyMapping. - * - * @psalm-var AssociationMapping|null */ - private array|null $association = null; + private AssociationMapping|null $association = null; /** * The EntityManager that manages the persistence of the collection. @@ -97,10 +96,8 @@ public function __construct( * INTERNAL: * Sets the collection's owning entity together with the AssociationMapping that * describes the association between the owner and the elements of the collection. - * - * @psalm-param AssociationMapping $assoc */ - public function setOwner(object $entity, array $assoc): void + public function setOwner(object $entity, AssociationMapping $assoc): void { $this->owner = $entity; $this->association = $assoc; @@ -137,6 +134,7 @@ private function getUnitOfWork(): UnitOfWork */ public function hydrateAdd(mixed $element): void { + assert($this->association !== null); $this->unwrap()->add($element); // If _backRefFieldName is set and its a one-to-many association, @@ -167,7 +165,7 @@ public function hydrateSet(mixed $key, mixed $element): void // If _backRefFieldName is set, then the association is bidirectional // and we need to set the back reference. - if ($this->backRefFieldName && $this->association['type'] === ClassMetadata::ONE_TO_MANY) { + if ($this->backRefFieldName && $this->association !== null && $this->association['type'] === ClassMetadata::ONE_TO_MANY) { assert($this->typeClass !== null); // Set back reference to owner $this->typeClass->reflFields[$this->backRefFieldName]->setValue( @@ -245,13 +243,11 @@ public function getInsertDiff(): array )); } - /** - * INTERNAL: Gets the association mapping of the collection. - * - * @psalm-return AssociationMapping|null - */ - public function getMapping(): array|null + /** INTERNAL: Gets the association mapping of the collection. */ + public function getMapping(): AssociationMapping { + assert($this->association !== null); + return $this->association; } @@ -268,8 +264,7 @@ private function changed(): void if ( $this->association !== null && - $this->association['isOwningSide'] && - $this->association['type'] === ClassMetadata::MANY_TO_MANY && + $this->association instanceof ManyToManyOwningSideMapping && $this->owner && $this->em !== null && $this->em->getClassMetadata($this->owner::class)->isChangeTrackingNotify() @@ -319,7 +314,7 @@ public function remove(string|int $key): mixed if ( $this->association !== null && - $this->association['type'] & ClassMetadata::TO_MANY && + $this->association->isToMany() && $this->owner && $this->association['orphanRemoval'] ) { @@ -341,7 +336,7 @@ public function removeElement(mixed $element): bool if ( $this->association !== null && - $this->association['type'] & ClassMetadata::TO_MANY && + $this->association->isToMany() && $this->owner && $this->association['orphanRemoval'] ) { @@ -354,7 +349,7 @@ public function removeElement(mixed $element): bool public function containsKey(mixed $key): bool { if ( - ! $this->initialized && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY + ! $this->initialized && $this->association !== null && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY && isset($this->association['indexBy']) ) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->association); @@ -372,7 +367,7 @@ public function containsKey(mixed $key): bool */ public function contains(mixed $element): bool { - if (! $this->initialized && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { + if (! $this->initialized && $this->association !== null && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->association); return $this->unwrap()->contains($element) || $persister->contains($this, $element); @@ -385,6 +380,7 @@ public function get(string|int $key): mixed { if ( ! $this->initialized + && $this->association !== null && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY && isset($this->association['indexBy']) ) { @@ -474,10 +470,12 @@ public function clear(): void return; } + assert($this->association !== null); + $uow = $this->getUnitOfWork(); if ( - $this->association['type'] & ClassMetadata::TO_MANY && + $this->association->isToMany() && $this->association['orphanRemoval'] && $this->owner ) { @@ -494,7 +492,7 @@ public function clear(): void $this->initialized = true; // direct call, {@link initialize()} is too expensive - if ($this->association['isOwningSide'] && $this->owner) { + if ($this->association->isOwningSide() && $this->owner) { $this->changed(); $uow->scheduleCollectionDeletion($this); @@ -535,6 +533,7 @@ public function __wakeup(): void */ public function slice(int $offset, int|null $length = null): array { + assert($this->association !== null); if (! $this->initialized && ! $this->isDirty && $this->association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->association); @@ -587,6 +586,7 @@ public function matching(Criteria $criteria): Collection return $this->unwrap()->matching($criteria); } + assert($this->association !== null); if ($this->association['type'] === ClassMetadata::MANY_TO_MANY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->association); diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 3dad9bd4336..f66757b10b4 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\LockMode; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\SqlValueVisitor; @@ -24,8 +25,6 @@ /** * Persister for many-to-many collections. - * - * @psalm-import-type AssociationMapping from ClassMetadata */ class ManyToManyPersister extends AbstractCollectionPersister { @@ -276,15 +275,14 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri * have to join in the actual entities table leading to additional * JOIN. * - * @param mixed[] $mapping Array containing mapping information. - * @psalm-param AssociationMapping $mapping + * @param AssociationMapping $mapping Array containing mapping information. * * @return string[] ordered tuple: * - JOIN condition to add to the SQL * - WHERE condition to add to the SQL * @psalm-return array{0: string, 1: string} */ - public function getFilterSql(array $mapping): array + public function getFilterSql(AssociationMapping $mapping): array { $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $rootClass = $this->em->getClassMetadata($targetClass->rootEntityName); @@ -329,13 +327,10 @@ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, strin /** * Generate ON condition * - * @param mixed[] $mapping - * @psalm-param AssociationMapping $mapping - * * @return string[] * @psalm-return list */ - protected function getOnConditionSQL(array $mapping): array + protected function getOnConditionSQL(AssociationMapping $mapping): array { $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $association = ! $mapping['isOwningSide'] diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 1b36a3d53f6..2c4e8ff6565 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -17,6 +17,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\QuoteStrategy; @@ -89,8 +90,6 @@ * * Subclasses can be created to provide custom persisting and querying strategies, * i.e. spanning multiple tables. - * - * @psalm-import-type AssociationMapping from ClassMetadata */ class BasicEntityPersister implements EntityPersister { @@ -626,7 +625,7 @@ protected function prepareUpdateData(object $entity, bool $isInsert = false): ar $assoc = $this->class->associationMappings[$field]; // Only owning side of x-1 associations can have a FK column. - if (! $assoc['isOwningSide'] || ! ($assoc['type'] & ClassMetadata::TO_ONE)) { + if (! $assoc->isToOneOwningSide()) { continue; } @@ -697,7 +696,7 @@ public function getOwningTable(string $fieldName): string public function load( array $criteria, object|null $entity = null, - array|null $assoc = null, + AssociationMapping|null $assoc = null, array $hints = [], LockMode|int|null $lockMode = null, int|null $limit = null, @@ -731,7 +730,7 @@ public function loadById(array $identifier, object|null $entity = null): object| /** * {@inheritdoc} */ - public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): object|null + public function loadOneToOneEntity(AssociationMapping $assoc, object $sourceEntity, array $identifier = []): object|null { $foundEntity = $this->em->getUnitOfWork()->tryGetById($identifier, $assoc['targetEntity']); if ($foundEntity !== false) { @@ -885,7 +884,7 @@ public function loadAll( * {@inheritdoc} */ public function getManyToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, @@ -900,11 +899,9 @@ public function getManyToManyCollection( /** * Loads an array of entities from a given DBAL statement. * - * @param mixed[] $assoc - * * @return mixed[] */ - private function loadArrayFromResult(array $assoc, Result $stmt): array + private function loadArrayFromResult(AssociationMapping $assoc, Result $stmt): array { $rsm = $this->currentPersisterContext->rsm; $hints = [UnitOfWork::HINT_DEFEREAGERLOAD => true]; @@ -920,12 +917,10 @@ private function loadArrayFromResult(array $assoc, Result $stmt): array /** * Hydrates a collection from a given DBAL statement. * - * @param mixed[] $assoc - * * @return mixed[] */ private function loadCollectionFromStatement( - array $assoc, + AssociationMapping $assoc, Result $stmt, PersistentCollection $coll, ): array { @@ -946,20 +941,16 @@ private function loadCollectionFromStatement( /** * {@inheritdoc} */ - public function loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $collection): array + public function loadManyToManyCollection(AssociationMapping $assoc, object $sourceEntity, PersistentCollection $collection): array { $stmt = $this->getManyToManyStatement($assoc, $sourceEntity); return $this->loadCollectionFromStatement($assoc, $stmt, $collection); } - /** - * @psalm-param array $assoc - * - * @throws MappingException - */ + /** @throws MappingException */ private function getManyToManyStatement( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, @@ -1028,7 +1019,7 @@ private function getManyToManyStatement( public function getSelectSQL( array|Criteria $criteria, - array|null $assoc = null, + AssociationMapping|null $assoc = null, LockMode|int|null $lockMode = null, int|null $limit = null, int|null $offset = null, @@ -1195,14 +1186,14 @@ protected function getSelectColumnsSQL(): string $columnList[] = $assocColumnSQL; } - $isAssocToOneInverseSide = $assoc['type'] & ClassMetadata::TO_ONE && ! $assoc['isOwningSide']; - $isAssocFromOneEager = $assoc['type'] !== ClassMetadata::MANY_TO_MANY && $assoc['fetch'] === ClassMetadata::FETCH_EAGER; + $isAssocToOneInverseSide = $assoc->isToOne() && ! $assoc['isOwningSide']; + $isAssocFromOneEager = ! $assoc->isManyToMany() && $assoc['fetch'] === ClassMetadata::FETCH_EAGER; if (! ($isAssocFromOneEager || $isAssocToOneInverseSide)) { continue; } - if ((($assoc['type'] & ClassMetadata::TO_MANY) > 0) && $this->currentPersisterContext->handlesLimits) { + if (($assoc->isToMany() > 0) && $this->currentPersisterContext->handlesLimits) { continue; } @@ -1284,18 +1275,14 @@ protected function getSelectColumnsSQL(): string return $this->currentPersisterContext->selectColumnListSql; } - /** - * Gets the SQL join fragment used when selecting entities from an association. - * - * @param AssociationMapping $assoc - */ + /** Gets the SQL join fragment used when selecting entities from an association. */ protected function getSelectColumnAssociationSQL( string $field, - array $assoc, + AssociationMapping $assoc, ClassMetadata $class, string $alias = 'r', ): string { - if (! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) { + if (! $assoc->isToOneOwningSide()) { return ''; } @@ -1320,10 +1307,8 @@ protected function getSelectColumnAssociationSQL( /** * Gets the SQL join fragment used when selecting entities from a * many-to-many association. - * - * @psalm-param AssociationMapping $manyToMany */ - protected function getSelectManyToManyJoinSQL(array $manyToMany): string + protected function getSelectManyToManyJoinSQL(AssociationMapping $manyToMany): string { $conditions = []; $association = $manyToMany; @@ -1414,7 +1399,7 @@ protected function getInsertColumnList(): array if (isset($this->class->associationMappings[$name])) { $assoc = $this->class->associationMappings[$name]; - if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { + if ($assoc->isToOneOwningSide()) { foreach ($assoc['joinColumns'] as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); } @@ -1542,7 +1527,7 @@ protected function getSelectConditionCriteriaSQL(Criteria $criteria): string public function getSelectConditionStatementSQL( string $field, mixed $value, - array|null $assoc = null, + AssociationMapping|null $assoc = null, string|null $comparison = null, ): string { $selectedColumns = []; @@ -1612,8 +1597,6 @@ public function getSelectConditionStatementSQL( /** * Builds the left-hand-side of a where condition statement. * - * @psalm-param AssociationMapping|null $assoc - * * @return string[] * @psalm-return list * @@ -1622,7 +1605,7 @@ public function getSelectConditionStatementSQL( */ private function getSelectConditionStatementColumnSQL( string $field, - array|null $assoc = null, + AssociationMapping|null $assoc = null, ): array { if (isset($this->class->fieldMappings[$field])) { $className = $this->class->fieldMappings[$field]['inherited'] ?? $this->class->name; @@ -1642,7 +1625,8 @@ private function getSelectConditionStatementColumnSQL( } $joinTableName = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); - $joinColumns = $assoc['isOwningSide'] + assert($assoc !== null); + $joinColumns = $assoc['isOwningSide'] ? $association['joinTable']['joinColumns'] : $association['joinTable']['inverseJoinColumns']; @@ -1686,9 +1670,8 @@ private function getSelectConditionStatementColumnSQL( * or alter the criteria by which entities are selected. * * @psalm-param array $criteria - * @psalm-param AssociationMapping|null $assoc */ - protected function getSelectConditionSQL(array $criteria, array|null $assoc = null): string + protected function getSelectConditionSQL(array $criteria, AssociationMapping|null $assoc = null): string { $conditions = []; @@ -1703,7 +1686,7 @@ protected function getSelectConditionSQL(array $criteria, array|null $assoc = nu * {@inheritdoc} */ public function getOneToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, @@ -1715,11 +1698,8 @@ public function getOneToManyCollection( return $this->loadArrayFromResult($assoc, $stmt); } - /** - * {@inheritdoc} - */ public function loadOneToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, PersistentCollection $collection, ): mixed { @@ -1728,13 +1708,9 @@ public function loadOneToManyCollection( return $this->loadCollectionFromStatement($assoc, $stmt, $collection); } - /** - * Builds criteria and execute SQL statement to fetch the one to many entities from. - * - * @psalm-param AssociationMapping $assoc - */ + /** Builds criteria and execute SQL statement to fetch the one to many entities from. */ private function getOneToManyStatement( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index 343f85611dc..d84cc992256 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\PersistentCollection; @@ -16,8 +17,6 @@ /** * Entity persister interface * Define the behavior that should be implemented by all entity persisters. - * - * @psalm-import-type AssociationMapping from ClassMetadata */ interface EntityPersister { @@ -47,14 +46,13 @@ public function getInsertSQL(): string; * Gets the SELECT SQL to select one or more entities by a set of field criteria. * * @param mixed[]|Criteria $criteria - * @param mixed[]|null $assoc * @param mixed[]|null $orderBy * @psalm-param AssociationMapping|null $assoc * @psalm-param LockMode::*|null $lockMode */ public function getSelectSQL( array|Criteria $criteria, - array|null $assoc = null, + AssociationMapping|null $assoc = null, LockMode|int|null $lockMode = null, int|null $limit = null, int|null $offset = null, @@ -84,15 +82,11 @@ public function expandParameters(array $criteria): array; */ public function expandCriteriaParameters(Criteria $criteria): array; - /** - * Gets the SQL WHERE condition for matching a field with a given value. - * - * @psalm-param AssociationMapping|null $assoc - */ + /** Gets the SQL WHERE condition for matching a field with a given value. */ public function getSelectConditionStatementSQL( string $field, mixed $value, - array|null $assoc = null, + AssociationMapping|null $assoc = null, string|null $comparison = null, ): string; @@ -158,7 +152,7 @@ public function getOwningTable(string $fieldName): string; * @param object|null $entity The entity to load the data into. If not specified, * a new entity is created. * @param AssociationMapping|null $assoc The association that connects the entity - * to load to another entity, if any. + * to load to another entity, if any. * @param mixed[] $hints Hints for entity creation. * @param LockMode|int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants * or NULL if no specific lock mode should be used @@ -177,7 +171,7 @@ public function getOwningTable(string $fieldName): string; public function load( array $criteria, object|null $entity = null, - array|null $assoc = null, + AssociationMapping|null $assoc = null, array $hints = [], LockMode|int|null $lockMode = null, int|null $limit = null, @@ -200,17 +194,17 @@ public function loadById(array $identifier, object|null $entity = null): object| * Loads an entity of this persister's mapped class as part of a single-valued * association from another entity. * - * @param object $sourceEntity The entity that owns the association (not necessarily the "owning side"). + * @param AssociationMapping $assoc The association to load. + * @param object $sourceEntity The entity that owns the association (not necessarily the "owning side"). * @psalm-param array $identifier The identifier of the entity to load. Must be provided if * the association to load represents the owning side, otherwise * the identifier is derived from the $sourceEntity. - * @psalm-param AssociationMapping $assoc The association to load. * * @return object|null The loaded and managed entity instance or NULL if the entity can not be found. * * @throws MappingException */ - public function loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = []): object|null; + public function loadOneToOneEntity(AssociationMapping $assoc, object $sourceEntity, array $identifier = []): object|null; /** * Refreshes a managed entity. @@ -250,12 +244,10 @@ public function loadAll( /** * Gets (sliced or full) elements of the given collection. * - * @psalm-param AssociationMapping $assoc - * * @return mixed[] */ public function getManyToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, @@ -264,14 +256,14 @@ public function getManyToManyCollection( /** * Loads a collection of entities of a many-to-many association. * + * @param AssociationMapping $assoc The association mapping of the association being loaded. * @param object $sourceEntity The entity that owns the collection. * @param PersistentCollection $collection The collection to fill. - * @psalm-param AssociationMapping $assoc The association mapping of the association being loaded. * * @return mixed[] */ public function loadManyToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, PersistentCollection $collection, ): array; @@ -280,10 +272,9 @@ public function loadManyToManyCollection( * Loads a collection of entities in a one-to-many association. * * @param PersistentCollection $collection The collection to load/fill. - * @psalm-param AssociationMapping $assoc */ public function loadOneToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, PersistentCollection $collection, ): mixed; @@ -299,12 +290,10 @@ public function lock(array $criteria, LockMode|int $lockMode): void; /** * Returns an array with (sliced or full list) of elements in the specified collection. * - * @psalm-param AssociationMapping $assoc - * * @return mixed[] */ public function getOneToManyCollection( - array $assoc, + AssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index f4dc5610814..ec8b925b9e5 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -9,10 +9,12 @@ use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Internal\SQLResultCasing; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Utility\PersisterHelper; use function array_combine; +use function assert; use function implode; /** @@ -236,8 +238,14 @@ public function delete(object $entity): bool return (bool) $this->conn->delete($rootTable, $id, $rootTypes); } - public function getSelectSQL(array|Criteria $criteria, array|null $assoc = null, LockMode|int|null $lockMode = null, int|null $limit = null, int|null $offset = null, array|null $orderBy = null): string - { + public function getSelectSQL( + array|Criteria $criteria, + AssociationMapping|null $assoc = null, + LockMode|int|null $lockMode = null, + int|null $limit = null, + int|null $offset = null, + array|null $orderBy = null, + ): string { $this->switchPersisterContext($offset, $limit); $baseTableAlias = $this->getSQLTableAlias($this->class->name); @@ -379,7 +387,7 @@ protected function getSelectColumnsSQL(): string // Add foreign key columns foreach ($this->class->associationMappings as $mapping) { - if (! $mapping['isOwningSide'] || ! ($mapping['type'] & ClassMetadata::TO_ONE)) { + if (! $mapping->isToOneOwningSide()) { continue; } @@ -422,11 +430,7 @@ protected function getSelectColumnsSQL(): string // Add join columns (foreign keys) foreach ($subClass->associationMappings as $mapping) { - if ( - ! $mapping['isOwningSide'] - || ! ($mapping['type'] & ClassMetadata::TO_ONE) - || isset($mapping['inherited']) - ) { + if (! $mapping->isToOneOwningSide() || isset($mapping['inherited'])) { continue; } @@ -471,8 +475,9 @@ protected function getInsertColumnList(): array if (isset($this->class->associationMappings[$name])) { $assoc = $this->class->associationMappings[$name]; - if ($assoc['type'] & ClassMetadata::TO_ONE && $assoc['isOwningSide']) { - foreach ($assoc['targetToSourceKeyColumns'] as $sourceCol) { + if ($assoc->isToOneOwningSide()) { + assert($assoc->targetToSourceKeyColumns !== null); + foreach ($assoc->targetToSourceKeyColumns as $sourceCol) { $columns[] = $sourceCol; } } diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index 68b1d9110e5..fe5f50f94c7 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Internal\SQLResultCasing; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Utility\PersisterHelper; @@ -66,7 +67,7 @@ protected function getSelectColumnsSQL(): string // Foreign key columns foreach ($subClass->associationMappings as $assoc) { - if (! $assoc['isOwningSide'] || ! ($assoc['type'] & ClassMetadata::TO_ONE) || isset($assoc['inherited'])) { + if (! $assoc->isToOneOwningSide() || isset($assoc['inherited'])) { continue; } @@ -109,7 +110,7 @@ protected function getSQLTableAlias(string $className, string $assocName = ''): /** * {@inheritdoc} */ - protected function getSelectConditionSQL(array $criteria, array|null $assoc = null): string + protected function getSelectConditionSQL(array $criteria, AssociationMapping|null $assoc = null): string { $conditionSql = parent::getSelectConditionSQL($criteria, $assoc); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 720f5d48fba..7b248d99e20 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -36,7 +36,9 @@ public function getSql(SqlWalker $sqlWalker): string $assocField = $this->pathExpression->field; $assoc = $sqlWalker->getMetadataForDqlAlias($dqlAlias)->associationMappings[$assocField]; $targetEntity = $entityManager->getClassMetadata($assoc['targetEntity']); - $joinColumn = reset($assoc['joinColumns']); + + assert($assoc->isToOneOwningSide()); + $joinColumn = reset($assoc->joinColumns); if ($this->fieldMapping !== null) { if (! isset($targetEntity->fieldMappings[$this->fieldMapping])) { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index f95eeefe2f0..924110e2fdd 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -64,7 +64,7 @@ public function getSql(SqlWalker $sqlWalker): string } else { // many-to-many $targetClass = $entityManager->getClassMetadata($assoc['targetEntity']); - $owningAssoc = $assoc['isOwningSide'] ? $assoc : $targetClass->associationMappings[$assoc['mappedBy']]; + $owningAssoc = $assoc->isOwningSide() ? $assoc : $targetClass->associationMappings[$assoc['mappedBy']]; $joinTable = $owningAssoc['joinTable']; // SQL table aliases @@ -74,7 +74,7 @@ public function getSql(SqlWalker $sqlWalker): string // join to target table $sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $platform) . ' ' . $joinTableAlias . ' WHERE '; - $joinColumns = $assoc['isOwningSide'] + $joinColumns = $assoc->isOwningSide() ? $joinTable['joinColumns'] : $joinTable['inverseJoinColumns']; diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index cca633eee41..dee03971a66 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -7,6 +7,7 @@ use Doctrine\Common\Lexer\Token; use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST\Functions; @@ -34,7 +35,6 @@ * An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language. * Parses a DQL query, reports any errors in it, and generates an AST. * - * @psalm-import-type AssociationMapping from ClassMetadata * @psalm-type DqlToken = Token * @psalm-type QueryComponent = array{ * metadata?: ClassMetadata, @@ -625,8 +625,7 @@ private function processDeferredPartialObjectExpressions(): void if ( isset($class->associationMappings[$field]) && - $class->associationMappings[$field]['isOwningSide'] && - $class->associationMappings[$field]['type'] & ClassMetadata::TO_ONE + $class->associationMappings[$field]->isToOneOwningSide() ) { continue; } @@ -718,7 +717,7 @@ private function processDeferredPathExpressions(): void if (isset($class->associationMappings[$field])) { $assoc = $class->associationMappings[$field]; - $fieldType = $assoc['type'] & ClassMetadata::TO_ONE + $fieldType = $assoc->isToOne() ? AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION : AST\PathExpression::TYPE_COLLECTION_VALUED_ASSOCIATION; } diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index f452f6f28a4..6a78783b906 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -5,13 +5,12 @@ namespace Doctrine\ORM\Query; use Doctrine\ORM\Exception\ORMException; -use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Query\AST\PathExpression; use Exception; use Stringable; use Throwable; -/** @psalm-import-type AssociationMapping from ClassMetadata */ class QueryException extends Exception implements ORMException { public static function dqlError(string $dql): self @@ -81,11 +80,7 @@ public static function invalidLiteral(string|Stringable $literal): self return new self("Invalid literal '" . $literal . "'"); } - /** - * @param string[] $assoc - * @psalm-param AssociationMapping $assoc - */ - public static function iterateWithFetchJoinCollectionNotAllowed(array $assoc): self + public static function iterateWithFetchJoinCollectionNotAllowed(AssociationMapping $assoc): self { return new self( 'Invalid query operation: Not allowed to iterate over fetch join collections ' . @@ -123,11 +118,7 @@ public static function associationPathInverseSideNotSupported(PathExpression $pa ); } - /** - * @param string[] $assoc - * @psalm-param AssociationMapping $assoc - */ - public static function iterateWithFetchJoinNotAllowed(array $assoc): self + public static function iterateWithFetchJoinNotAllowed(AssociationMapping $assoc): self { return new self( 'Iterate with fetch join in class ' . $assoc['sourceEntity'] . diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 073b8ec8639..92a99ed1624 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -136,7 +136,7 @@ protected function addAllClassFields(string $class, string $alias, array $column } foreach ($classMetadata->associationMappings as $associationMapping) { - if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadata::TO_ONE) { + if ($associationMapping->isToOneOwningSide()) { $targetClass = $this->em->getClassMetadata($associationMapping['targetEntity']); $isIdentifier = isset($associationMapping['id']) && $associationMapping['id'] === true; @@ -216,7 +216,7 @@ private function getColumnAliasMap( } foreach ($class->associationMappings as $associationMapping) { - if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadata::TO_ONE) { + if ($associationMapping->isToOneOwningSide()) { foreach ($associationMapping['joinColumns'] as $joinColumn) { $columnName = $joinColumn['name']; $columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns); diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index bc72b7fd7b4..5ba0cbacf83 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -597,8 +597,9 @@ public function walkPathExpression(AST\PathExpression $pathExpr): string } $assoc = $class->associationMappings[$fieldName]; + assert($assoc->isToOne()); - if (! $assoc['isOwningSide']) { + if (! $assoc->isOwningSide()) { throw QueryException::associationPathInverseSideNotSupported($pathExpr); } @@ -611,7 +612,8 @@ public function walkPathExpression(AST\PathExpression $pathExpr): string $sql .= $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.'; } - $sql .= reset($assoc['targetToSourceKeyColumns']); + assert($assoc->targetToSourceKeyColumns !== null); + $sql .= reset($assoc->targetToSourceKeyColumns); break; default: @@ -680,7 +682,7 @@ public function walkSelectClause(AST\SelectClause $selectClause): string // Add foreign key columns of class and also parent classes foreach ($class->associationMappings as $assoc) { if ( - ! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) + ! $assoc->isToOneOwningSide() || ( ! $addMetaColumns && ! isset($assoc['id'])) ) { continue; @@ -719,7 +721,7 @@ public function walkSelectClause(AST\SelectClause $selectClause): string continue; } - if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { + if ($assoc->isToOneOwningSide()) { $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); foreach ($assoc['joinColumns'] as $joinColumn) { @@ -797,8 +799,9 @@ public function walkIndexBy(AST\IndexBy $indexBy): void } $association = $class->associationMappings[$fieldName]; + assert($association->isToOne()); - if (! $association['isOwningSide']) { + if (! $association->isOwningSide()) { throw QueryException::associationPathInverseSideNotSupported($pathExpression); } @@ -806,7 +809,8 @@ public function walkIndexBy(AST\IndexBy $indexBy): void throw QueryException::associationPathCompositeKeyNotSupported(); } - $field = reset($association['targetToSourceKeyColumns']); + assert($association->targetToSourceKeyColumns !== null); + $field = reset($association->targetToSourceKeyColumns); break; default: @@ -905,7 +909,7 @@ public function walkJoinAssociationDeclaration( // be the owning side and previously we ensured that $assoc is always the owning side of the associations. // The owning side is necessary at this point because only it contains the JoinColumn information. switch (true) { - case $assoc['type'] & ClassMetadata::TO_ONE: + case $assoc->isToOne(): $conditions = []; foreach ($assoc['joinColumns'] as $joinColumn) { @@ -1639,7 +1643,7 @@ public function walkGroupByItem(AST\PathExpression|string $groupByItem): string } foreach ($this->getMetadataForDqlAlias($groupByItem)->associationMappings as $mapping) { - if ($mapping['isOwningSide'] && $mapping['type'] & ClassMetadata::TO_ONE) { + if ($mapping->isToOneOwningSide()) { $item = new AST\PathExpression(AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $groupByItem, $mapping['fieldName']); $item->type = AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 25ec627476e..41a177d9186 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Tools\Console\Command; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\FieldMapping; use Doctrine\Persistence\Mapping\MappingException; @@ -41,8 +42,6 @@ * Show information about mapped entities. * * @link www.doctrine-project.org - * - * @psalm-import-type AssociationMapping from ClassMetadata */ final class MappingDescribeCommand extends AbstractEntityManagerCommand { diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index 52bd953aaf6..8219620ef19 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -6,7 +6,6 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Event\OnFlushEventArgs; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\Proxy; @@ -71,7 +70,7 @@ public function dumpIdentityMap(EntityManagerInterface $em): void fwrite($fh, ' ' . $field . ' '); $value = $cm->getFieldValue($entity, $field); - if ($assoc['type'] & ClassMetadata::TO_ONE) { + if ($assoc->isToOne()) { if ($value === null) { fwrite($fh, " NULL\n"); } else { diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index 52e3c2841d0..0eaad9f17c5 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -5,7 +5,6 @@ namespace Doctrine\ORM\Tools\Pagination; use Doctrine\DBAL\Types\Type; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST\Functions\IdentityFunction; use Doctrine\ORM\Query\AST\Node; @@ -125,7 +124,7 @@ private function validate(SelectStatement $AST): void if ( isset($queryComponent['parent']) && isset($queryComponent['relation']) - && $queryComponent['relation']['type'] & ClassMetadata::TO_MANY + && $queryComponent['relation']->isToMany() ) { throw new RuntimeException('Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers.'); } diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php index 9fa30f8d957..0e4a44adc20 100644 --- a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Event\LoadClassMetadataEventArgs; use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; use Doctrine\ORM\Events; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use function array_key_exists; @@ -19,8 +20,6 @@ * * Mechanism to overwrite interfaces or classes specified as association * targets. - * - * @psalm-import-type AssociationMapping from ClassMetadata */ class ResolveTargetEntityListener implements EventSubscriber { @@ -89,11 +88,13 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $args): void } } - /** @param AssociationMapping $mapping */ - private function remapAssociation(ClassMetadata $classMetadata, array $mapping): void + private function remapAssociation(ClassMetadata $classMetadata, AssociationMapping $mapping): void { $newMapping = $this->resolveTargetEntities[$mapping['targetEntity']]; - $newMapping = array_replace_recursive($mapping, $newMapping); + $newMapping = array_replace_recursive( + $mapping->toArray(), + $newMapping, + ); $newMapping['fieldName'] = $mapping['fieldName']; unset($classMetadata->associationMappings[$mapping['fieldName']]); diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index a2c7486f330..467d8494d64 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -14,9 +14,12 @@ use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; use Doctrine\ORM\Mapping\FieldMapping; +use Doctrine\ORM\Mapping\JoinColumnMapping; +use Doctrine\ORM\Mapping\ManyToManyOwningSideMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; @@ -37,7 +40,6 @@ use function func_num_args; use function implode; use function in_array; -use function is_array; use function is_numeric; use function method_exists; use function strtolower; @@ -47,9 +49,6 @@ * ClassMetadata class descriptors. * * @link www.doctrine-project.org - * - * @psalm-import-type AssociationMapping from ClassMetadata - * @psalm-import-type JoinColumnData from ClassMetadata */ class SchemaTool { @@ -300,7 +299,6 @@ public function getSchemaFromMetadata(array $classes): Schema $pkColumns[] = $this->quoteStrategy->getColumnName($identifierField, $class, $this->platform); } elseif (isset($class->associationMappings[$identifierField])) { $assoc = $class->associationMappings[$identifierField]; - assert(is_array($assoc)); foreach ($assoc['joinColumns'] as $joinColumn) { $pkColumns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); @@ -544,7 +542,7 @@ private function gatherRelationsSql( $foreignClass = $this->em->getClassMetadata($mapping['targetEntity']); - if ($mapping['type'] & ClassMetadata::TO_ONE && $mapping['isOwningSide']) { + if ($mapping->isToOneOwningSide()) { $primaryKeyColumns = []; // PK is unnecessary for this relation-type $this->gatherRelationJoinColumns( @@ -556,10 +554,7 @@ private function gatherRelationsSql( $addedFks, $blacklistedFks, ); - } elseif ($mapping['type'] === ClassMetadata::ONE_TO_MANY && $mapping['isOwningSide']) { - //... create join table, one-many through join table supported later - throw NotSupported::create(); - } elseif ($mapping['type'] === ClassMetadata::MANY_TO_MANY && $mapping['isOwningSide']) { + } elseif ($mapping instanceof ManyToManyOwningSideMapping) { // create join table $joinTable = $mapping['joinTable']; @@ -642,8 +637,7 @@ private function getDefiningClass(ClassMetadata $class, string $referencedColumn /** * Gathers columns and fk constraints that are required for one part of relationship. * - * @psalm-param array $joinColumns - * @psalm-param AssociationMapping $mapping + * @psalm-param array $joinColumns * @psalm-param list $primaryKeyColumns * @psalm-param arrayisOwningSide()) { if ($assoc['type'] === ClassMetadata::MANY_TO_MANY) { $identifierColumns = $class->getIdentifierColumnNames(); foreach ($assoc['joinTable']['joinColumns'] as $joinColumn) { @@ -194,7 +194,7 @@ public function validateClass(ClassMetadata $class): array "however '" . implode(', ', array_diff($class->getIdentifierColumnNames(), array_values($assoc['relationToSourceKeyColumns']))) . "' are missing."; } - } elseif ($assoc['type'] & ClassMetadata::TO_ONE) { + } elseif ($assoc->isToOne()) { $identifierColumns = $targetMetadata->getIdentifierColumnNames(); foreach ($assoc['joinColumns'] as $joinColumn) { if (! in_array($joinColumn['referencedColumnName'], $identifierColumns, true)) { diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index a805666f9e8..f72091739de 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -30,6 +30,7 @@ use Doctrine\ORM\Id\AssignedGenerator; use Doctrine\ORM\Internal\CommitOrderCalculator; use Doctrine\ORM\Internal\HydrationCompleteHandler; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Persisters\Collection\CollectionPersister; @@ -76,8 +77,6 @@ * in the correct order. * * Internal note: This class contains highly performance-sensitive code. - * - * @psalm-import-type AssociationMapping from ClassMetadata */ class UnitOfWork implements PropertyChangedListener { @@ -613,7 +612,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void $assoc = $class->associationMappings[$propName]; - if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { + if ($assoc->isToOneOwningSide()) { $changeSet[$propName] = [null, $actualValue]; } } @@ -700,7 +699,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void continue; } - if ($assoc['type'] & ClassMetadata::TO_ONE) { + if ($assoc->isToOne()) { if ($assoc['isOwningSide']) { $changeSet[$propName] = [$orgValue, $actualValue]; } @@ -730,8 +729,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void if ( ! isset($this->entityChangeSets[$oid]) && - $assoc['isOwningSide'] && - $assoc['type'] === ClassMetadata::MANY_TO_MANY && + $assoc->isManyToManyOwningSide() && $val instanceof PersistentCollection && $val->isDirty() ) { @@ -787,12 +785,11 @@ public function computeChangeSets(): void * Computes the changes of an association. * * @param mixed $value The value of the association. - * @psalm-param AssociationMapping $assoc The association mapping. * * @throws ORMInvalidArgumentException * @throws ORMException */ - private function computeAssociationChanges(array $assoc, mixed $value): void + private function computeAssociationChanges(AssociationMapping $assoc, mixed $value): void { if ($value instanceof Proxy && ! $value->__isInitialized()) { return; @@ -808,7 +805,7 @@ private function computeAssociationChanges(array $assoc, mixed $value): void // Look through the entities, and in any of their associations, // for transient (new) entities, recursively. ("Persistence by reachability") // Unwrap. Uninitialized collections will simply be empty. - $unwrappedValue = $assoc['type'] & ClassMetadata::TO_ONE ? [$value] : $value->unwrap(); + $unwrappedValue = $assoc->isToOne() ? [$value] : $value->unwrap(); $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); foreach ($unwrappedValue as $key => $entry) { @@ -849,7 +846,7 @@ private function computeAssociationChanges(array $assoc, mixed $value): void case self::STATE_REMOVED: // Consume the $value as array (it's either an array or an ArrayAccess) // and remove the element from Collection. - if ($assoc['type'] & ClassMetadata::TO_MANY) { + if ($assoc->isToMany()) { unset($value[$key]); } @@ -1186,7 +1183,7 @@ private function getCommitOrder(): array // Calculate dependencies for new nodes while ($class = array_pop($newNodes)) { foreach ($class->associationMappings as $assoc) { - if (! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) { + if (! $assoc->isToOneOwningSide()) { continue; } @@ -1198,7 +1195,7 @@ private function getCommitOrder(): array $newNodes[] = $targetClass; } - $joinColumns = reset($assoc['joinColumns']); + $joinColumns = reset($assoc->joinColumns); $calc->addDependency($targetClass->name, $class->name, (int) empty($joinColumns['nullable'])); @@ -1856,7 +1853,7 @@ private function cascadeRefresh(object $entity, array &$visited, LockMode|int|nu $associationMappings = array_filter( $class->associationMappings, - static fn (array $assoc) => $assoc['isCascadeRefresh'] + static fn (AssociationMapping $assoc): bool => $assoc['isCascadeRefresh'] ); foreach ($associationMappings as $assoc) { @@ -1897,7 +1894,7 @@ private function cascadeDetach(object $entity, array &$visited): void $associationMappings = array_filter( $class->associationMappings, - static fn (array $assoc) => $assoc['isCascadeDetach'] + static fn (AssociationMapping $assoc): bool => $assoc['isCascadeDetach'] ); foreach ($associationMappings as $assoc) { @@ -1943,7 +1940,7 @@ private function cascadePersist(object $entity, array &$visited): void $associationMappings = array_filter( $class->associationMappings, - static fn (array $assoc) => $assoc['isCascadePersist'] + static fn (AssociationMapping $assoc): bool => $assoc['isCascadePersist'] ); foreach ($associationMappings as $assoc) { @@ -1957,7 +1954,7 @@ private function cascadePersist(object $entity, array &$visited): void case $relatedEntities instanceof Collection: case is_array($relatedEntities): - if (($assoc['type'] & ClassMetadata::TO_MANY) <= 0) { + if ($assoc->isToMany() <= 0) { throw ORMInvalidArgumentException::invalidAssociation( $this->em->getClassMetadata($assoc['targetEntity']), $assoc, @@ -2000,7 +1997,7 @@ private function cascadeRemove(object $entity, array &$visited): void $associationMappings = array_filter( $class->associationMappings, - static fn (array $assoc) => $assoc['isCascadeRemove'] + static fn (AssociationMapping $assoc): bool => $assoc['isCascadeRemove'] ); $entitiesToCascade = []; @@ -2285,7 +2282,7 @@ public function createEntity(string $className, array $data, array &$hints = []) $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); switch (true) { - case $assoc['type'] & ClassMetadata::TO_ONE: + case $assoc->isToOne(): if (! $assoc['isOwningSide']) { // use the given entity association if (isset($data[$field]) && is_object($data[$field]) && isset($this->entityStates[spl_object_id($data[$field])])) { @@ -2428,7 +2425,7 @@ public function createEntity(string $className, array $data, array &$hints = []) $this->originalEntityData[$oid][$field] = $newValue; $class->reflFields[$field]->setValue($entity, $newValue); - if ($assoc['inversedBy'] && $assoc['type'] & ClassMetadata::ONE_TO_ONE && $newValue !== null) { + if ($assoc['inversedBy'] && $assoc->isOneToOne() && $newValue !== null) { $inverseAssoc = $targetClass->associationMappings[$assoc['inversedBy']]; $targetClass->reflFields[$inverseAssoc['fieldName']]->setValue($newValue, $entity); } @@ -2680,12 +2677,8 @@ public function getEntityPersister(string $entityName): EntityPersister return $this->persisters[$entityName]; } - /** - * Gets a collection persister for a collection-valued association. - * - * @psalm-param AssociationMapping $association - */ - public function getCollectionPersister(array $association): CollectionPersister + /** Gets a collection persister for a collection-valued association. */ + public function getCollectionPersister(AssociationMapping $association): CollectionPersister { $role = isset($association['cache']) ? $association['sourceEntity'] . '::' . $association['fieldName'] diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index eff5fd2daea..0ea927877b6 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -36,11 +36,11 @@ public static function getTypeOfField(string $fieldName, ClassMetadata $class, E $assoc = $class->associationMappings[$fieldName]; - if (! $assoc['isOwningSide']) { + if (! $assoc->isOwningSide()) { return self::getTypeOfField($assoc['mappedBy'], $em->getClassMetadata($assoc['targetEntity']), $em); } - if ($assoc['type'] & ClassMetadata::MANY_TO_MANY) { + if ($assoc->isManyToMany()) { $joinData = $assoc['joinTable']; } else { $joinData = $assoc; @@ -69,7 +69,7 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, // iterate over to-one association mappings foreach ($class->associationMappings as $assoc) { - if (! isset($assoc['joinColumns'])) { + if (! $assoc->isToOne()) { continue; } @@ -85,7 +85,7 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, // iterate over to-many association mappings foreach ($class->associationMappings as $assoc) { - if (! (isset($assoc['joinTable']) && isset($assoc['joinTable']['joinColumns']))) { + if (! $assoc->isToMany()) { continue; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7e64ca75bb1..c65e2ab916e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -130,11 +130,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/ClassMetadata.php - - - message: "#^Negated boolean expression is always false\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadata.php - - message: "#^If condition is always true\\.$#" count: 2 diff --git a/phpstan.neon b/phpstan.neon index fd318f3530a..836e6c126bf 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -19,3 +19,24 @@ parameters: - message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + + - + message: '~^Unreachable statement \- code above always terminates\.$~' + path: lib/Doctrine/ORM/Mapping/AssociationMapping.php + + # https://github.com/phpstan/phpstan/issues/8904 + - + message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\:\\:\\$joinColumns\\.$#" + path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php + + - + message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\:\\:fromMappingArrayAndName\\(\\) should return Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneAssociationMapping but returns static\\(Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\)\\.$#" + path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php + + - + message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$associationMappings \\(array\\\\) does not accept array\\\\.$#" + path: lib/Doctrine/ORM/Mapping/ClassMetadata.php + + - + message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$associationMappings \\(array\\\\) does not accept array\\\\.$#" + path: lib/Doctrine/ORM/Mapping/ClassMetadata.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 275683eca87..091daee6fcd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -26,9 +26,6 @@ - - - getConfiguration() ->getSecondLevelCacheConfiguration() @@ -39,14 +36,6 @@ - - associationMappings]]> - - - - - - getCacheRegion @@ -236,10 +225,6 @@ - - associationMappings[$fieldName]['joinColumns']]]> - associationMappings[$fieldName]['joinColumns']]]> - return $rowData; return $rowData; @@ -283,12 +268,6 @@ $parentObject $parentObject - - - - - reflFields]]> - getValue getValue @@ -298,16 +277,9 @@ setValue - associationMappings[$class->identifier[0]]['joinColumns']]]> - associationMappings[$fieldName]['joinColumns']]]> - - - - - $repositoryClassName @@ -325,9 +297,6 @@ columnNames]]> columnNames]]> - - - $mapping $mapping @@ -336,18 +305,11 @@ ReflectionClass|null - string $definition subClasses]]> - - $mapping - - - AssociationMapping - $cache $className @@ -361,7 +323,6 @@ ]]> - associationMappings[$assocName]['mappedBy']]]> reflClass]]> @@ -387,12 +348,9 @@ setValue + - associationMappings[$assocName]['joinColumns']]]> - associationMappings[$fieldName]['joinColumns']]]> - associationMappings[$fieldName]['joinColumns']]]> - associationMappings[$idProperty]['joinColumns']]]> $idGenerator @@ -406,11 +364,18 @@ array_values - - - table]]> + table]]> - + null + + + namingStrategy, + $this->name, + $this->table, + $this->isInheritanceTypeSingleTable(), + )]]> @@ -462,10 +427,6 @@ array - - - associationMappings[$fieldName]['joinColumns']]]> - @@ -630,6 +591,25 @@ getName() === 'mapped-superclass']]> + + + $mappingArray + + + $joinTable + + + joinTable]]> + + + new JoinTableMapping() + + + + + $mappingArray + + $object @@ -654,6 +634,16 @@ ReflectionReadonlyProperty + + + $instance + $mapping + + + OneToOneAssociationMapping|ManyToOneAssociationMapping + static + + @@ -684,48 +674,18 @@ $value - association]]> - association]]> - association]]> - association['targetEntity']]]> backRefFieldName]]> - - association['fetch']]]> - association['fetch']]]> - association['fetch']]]> - association['fetch']]]> - association['fetch']]]> - association['isOwningSide']]]> - association['orphanRemoval']]]> - association['targetEntity']]]> - association['type']]]> - association['type']]]> - association['type']]]> - association['type']]]> - setValue setValue - - association['orphanRemoval']]]> - association['orphanRemoval']]]> - association['orphanRemoval']]]> - unwrap(), 'add']]]> - - $mapping - - - $collection->getOwner(), $mapping['indexBy'] => $index]]]> - - $association getOwner()]]> getOwner()]]> getOwner()]]> @@ -733,160 +693,14 @@ getOwner()]]> getOwner()]]> getOwner()]]> - $column - $filterMapping - $filterMapping - $indexBy - $mapping - $mapping - $mapping - $mapping - $mapping - $mapping - $mapping - $mapping - $mapping - - - - - - - - - - - - - - - - - - - - - - $owner - $targetColumn - - - - - - $mapping[$sourceRelationMode] - $mapping[$targetRelationMode] - $mapping[$targetRelationMode][$joinTableColumn] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - associationMappings]]> - associationMappings]]> - associationMappings]]> - associationMappings]]> - associationMappings]]> - - - $joinColumns - $joinColumns - $mapping[$sourceRelationMode] - - - - - - - - - - - getFieldForColumn getFieldForColumn - - - - - - $mapping[$sourceRelationMode] - $mapping[$targetRelationMode] - - - - - - - - - - - - - - - - - - $collection->getOwner(), - $mapping['indexBy'] => $index, - ]]]> - $numDeleted conn->executeStatement($statement, $parameters)]]> @@ -899,51 +713,13 @@ getOwner()]]> getOwner()]]> getOwner()]]> - $mapping - - - - - - - - - - - - - - - - - - - - - - - - - - - - associationMappings]]> - - - - associationMappings[$mapping['mappedBy']]['joinColumns']]]> - - - $association - $value === null - $assoc $hints $hints true]]]> @@ -963,27 +739,8 @@ ]]> - - - $association - - - - - - - - - associationMappings]]> - associationMappings]]> - associationMappings]]> - class->associationMappings]]> - - - $joinColumns - getValue getValue @@ -993,28 +750,6 @@ getValue setValue - - - - - - - - - - - - - - - - - - - - class->associationMappings[$fieldName]['joinColumns']]]> - class->associationMappings[$idField]['joinColumns']]]> - currentPersisterContext->sqlTableAliases]]> @@ -1031,16 +766,6 @@ array - - - - - - - - - - @@ -1127,26 +852,11 @@ $sqlWalker - - - - - simpleArithmeticExpression]]> - - - associationMappings]]> - associationMappings]]> - - - - - - walkJoinPathExpression @@ -1341,12 +1051,6 @@ Comparison::EQ - - - - - - conn->quote((string) $newValue)]]> @@ -1367,27 +1071,12 @@ elseScalarExpression]]> - associationMappings]]> - associationMappings]]> - associationMappings]]> scalarResultAliasMap]]> scalarResultAliasMap]]> dispatch - - - - - - - - - - - - @@ -1517,11 +1206,6 @@ $state === UnitOfWork::STATE_DETACHED - - - associationMappings[$property]['joinColumns']]]> - - @@ -1535,9 +1219,6 @@ orderByItems]]> - - associationMappings[$property]['joinColumns']]]> - @@ -1568,46 +1249,19 @@ $classes - - - - $asset $referencedFieldName - - - getAssociationMapping($fieldName)['joinColumns']]]> - - - - is_numeric($indexName) - - assert(is_array($assoc)) - is_array($assoc) - $indexName - - - - - - - - - - - - $collectionToDelete @@ -1628,23 +1282,11 @@ identityMap[$rootClassName]]]> - $assoc - $assoc - getTypeOfField($class->getSingleIdentifierFieldName())]]> getOwner()]]> getOwner()]]> - getMapping()]]> - getMapping()]]> $owner - - - - - - reflFields]]> - buildCachedCollectionPersister buildCachedEntityPersister @@ -1672,11 +1314,6 @@ setValue setValue - - - - - unwrap unwrap @@ -1696,17 +1333,4 @@ subClasses]]> - - - associationMappings[$field]['joinColumns']]]> - - - - - - - - - - diff --git a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php b/tests/Doctrine/Performance/Mock/NonLoadingPersister.php index 8fb8b06dffa..7058092bf68 100644 --- a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php +++ b/tests/Doctrine/Performance/Mock/NonLoadingPersister.php @@ -5,6 +5,7 @@ namespace Doctrine\Performance\Mock; use Doctrine\DBAL\LockMode; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; /** @@ -22,7 +23,7 @@ public function __construct() public function load( array $criteria, object|null $entity = null, - array|null $assoc = null, + AssociationMapping|null $assoc = null, array $hints = [], LockMode|int|null $lockMode = null, int|null $limit = null, diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php index 1d802dea597..3668828f052 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php @@ -35,10 +35,10 @@ public static function loadMetadata(ClassMetadata $metadata): void 'joinTable' => [ 'name' => 'ddc964_users_admingroups', 'joinColumns' => [ - ['name' => 'adminuser_id'], + ['name' => 'adminuser_id', 'referencedColumnName' => 'id'], ], 'inverseJoinColumns' => [ - ['name' => 'admingroup_id'], + ['name' => 'admingroup_id', 'referencedColumnName' => 'id'], ], ], ], diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php index d976a26be28..f2f17c14b97 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php @@ -111,7 +111,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'address', 'targetEntity' => 'DDC964Address', 'cascade' => ['persist','merge'], - 'joinColumns' => [['name' => 'address_id', 'referencedColumnMame' => 'id']], + 'joinColumns' => [['name' => 'address_id', 'referencedColumnName' => 'id']], ], ); diff --git a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php index 3e52945b1e6..22ac2127ac2 100644 --- a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php +++ b/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php @@ -109,7 +109,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'joinColumns' => [ 0 => - [], + ['referencedColumnName' => 'id'], ], 'orphanRemoval' => true, ], diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 6dd074527ae..2ceba5a411c 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -127,7 +127,7 @@ public function testBuildCachedCollectionPersisterReadOnly(): void $persister = new OneToManyPersister($em); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCache())); - $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_READ_ONLY; + $mapping->cache['usage'] = ClassMetadata::CACHE_USAGE_READ_ONLY; $this->factory->expects(self::once()) ->method('getRegion') @@ -148,7 +148,7 @@ public function testBuildCachedCollectionPersisterReadWrite(): void $persister = new OneToManyPersister($em); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCache())); - $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_READ_WRITE; + $mapping->cache['usage'] = ClassMetadata::CACHE_USAGE_READ_WRITE; $this->factory->expects(self::once()) ->method('getRegion') @@ -169,7 +169,7 @@ public function testBuildCachedCollectionPersisterNonStrictReadWrite(): void $persister = new OneToManyPersister($em); $region = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCache())); - $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE; + $mapping->cache['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE; $this->factory->expects(self::once()) ->method('getRegion') @@ -241,7 +241,7 @@ public function testBuildCachedCollectionPersisterException(): void $mapping = $metadata->associationMappings['cities']; $persister = new OneToManyPersister($em); - $mapping['cache']['usage'] = -1; + $mapping->cache['usage'] = -1; $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Unrecognized access strategy type [-1]'); diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php index d05f9268b1b..5318f96dff0 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Cache\Persister\Collection\CachedCollectionPersister; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\Tests\Mocks\EntityManagerMock; @@ -25,7 +26,12 @@ abstract class CollectionPersisterTestCase extends OrmTestCase protected CollectionPersister&MockObject $collectionPersister; protected EntityManagerMock $em; - abstract protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister; + abstract protected function createPersister( + EntityManagerInterface $em, + CollectionPersister $persister, + Region $region, + AssociationMapping $mapping, + ): AbstractCollectionPersister; protected function setUp(): void { diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php index c4c0d1e16dc..4b79d021000 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php @@ -8,14 +8,19 @@ use Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use PHPUnit\Framework\Attributes\Group; #[Group('DDC-2183')] class NonStrictReadWriteCachedCollectionPersisterTest extends CollectionPersisterTestCase { - protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister - { + protected function createPersister( + EntityManagerInterface $em, + CollectionPersister $persister, + Region $region, + AssociationMapping $mapping, + ): AbstractCollectionPersister { return new NonStrictReadWriteCachedCollectionPersister($persister, $region, $em, $mapping); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php index 5c55a1d8761..8fb07fa4b3e 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php @@ -8,14 +8,19 @@ use Doctrine\ORM\Cache\Persister\Collection\ReadOnlyCachedCollectionPersister; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use PHPUnit\Framework\Attributes\Group; #[Group('DDC-2183')] class ReadOnlyCachedCollectionPersisterTest extends CollectionPersisterTestCase { - protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister - { + protected function createPersister( + EntityManagerInterface $em, + CollectionPersister $persister, + Region $region, + AssociationMapping $mapping, + ): AbstractCollectionPersister { return new ReadOnlyCachedCollectionPersister($persister, $region, $em, $mapping); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index 107f24ac11c..2b87882fa60 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Persisters\Collection\CollectionPersister; use Doctrine\Tests\Models\Cache\State; use PHPUnit\Framework\Attributes\Group; @@ -20,8 +21,12 @@ #[Group('DDC-2183')] class ReadWriteCachedCollectionPersisterTest extends CollectionPersisterTestCase { - protected function createPersister(EntityManagerInterface $em, CollectionPersister $persister, Region $region, array $mapping): AbstractCollectionPersister - { + protected function createPersister( + EntityManagerInterface $em, + CollectionPersister $persister, + Region $region, + AssociationMapping $mapping, + ): AbstractCollectionPersister { return new ReadWriteCachedCollectionPersister($persister, $region, $em, $mapping); } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php index c357fe66ea1..ca67a5a8b61 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\OneToOneAssociationMapping; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\Entity\EntityPersister; use Doctrine\ORM\Query\ResultSetMappingBuilder; @@ -89,11 +90,13 @@ public function testInvokeGetSelectSQL(): void { $persister = $this->createPersisterDefault(); + $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $this->entityPersister->expects(self::once()) ->method('getSelectSQL') ->with( self::identicalTo(['name' => 'Foo']), - self::identicalTo([0]), + self::identicalTo($associationMapping), self::identicalTo(1), self::identicalTo(2), self::identicalTo(3), @@ -103,7 +106,7 @@ public function testInvokeGetSelectSQL(): void self::assertSame('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL( ['name' => 'Foo'], - [0], + $associationMapping, 1, 2, 3, @@ -151,12 +154,18 @@ public function testInvokeSelectConditionStatementSQL(): void { $persister = $this->createPersisterDefault(); + $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $this->entityPersister->expects(self::once()) ->method('getSelectConditionStatementSQL') - ->with(self::identicalTo('id'), self::identicalTo(1), self::identicalTo([]), self::identicalTo('=')) - ->willReturn('name = 1'); + ->with( + self::identicalTo('id'), + self::identicalTo(1), + self::identicalTo($associationMapping), + self::identicalTo('='), + )->willReturn('name = 1'); - self::assertSame('name = 1', $persister->getSelectConditionStatementSQL('id', 1, [], '=')); + self::assertSame('name = 1', $persister->getSelectConditionStatementSQL('id', 1, $associationMapping, '=')); } public function testInvokeExecuteInserts(): void @@ -216,12 +225,14 @@ public function testInvokeLoad(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); + $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $this->entityPersister->expects(self::once()) ->method('load') ->with( self::identicalTo(['id' => 1]), self::identicalTo($entity), - self::identicalTo([0]), + self::identicalTo($associationMapping), self::identicalTo([1]), self::identicalTo(2), self::identicalTo(3), @@ -229,7 +240,7 @@ public function testInvokeLoad(): void ) ->willReturn($entity); - self::assertSame($entity, $persister->load(['id' => 1], $entity, [0], [1], 2, 3, [4])); + self::assertSame($entity, $persister->load(['id' => 1], $entity, $associationMapping, [1], 2, 3, [4])); } public function testInvokeLoadAll(): void @@ -274,12 +285,14 @@ public function testInvokeLoadOneToOneEntity(): void $entity = new Country('Foo'); $owner = (object) []; + $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $this->entityPersister->expects(self::once()) ->method('loadOneToOneEntity') - ->with(self::identicalTo([]), self::identicalTo($owner), self::identicalTo(['id' => 11])) + ->with(self::identicalTo($associationMapping), self::identicalTo($owner), self::identicalTo(['id' => 11])) ->willReturn($entity); - self::assertSame($entity, $persister->loadOneToOneEntity([], $owner, ['id' => 11])); + self::assertSame($entity, $persister->loadOneToOneEntity($associationMapping, $owner, ['id' => 11])); } public function testInvokeRefresh(): void @@ -323,12 +336,14 @@ public function testInvokeGetManyToManyCollection(): void $entity = new Country('Foo'); $owner = (object) []; + $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $this->entityPersister->expects(self::once()) ->method('getManyToManyCollection') - ->with(self::identicalTo([]), self::identicalTo($owner), self::identicalTo(1), self::identicalTo(2)) + ->with(self::identicalTo($associationMapping), self::identicalTo($owner), self::identicalTo(1), self::identicalTo(2)) ->willReturn([$entity]); - self::assertSame([$entity], $persister->getManyToManyCollection([], $owner, 1, 2)); + self::assertSame([$entity], $persister->getManyToManyCollection($associationMapping, $owner, 1, 2)); } public function testInvokeGetOneToManyCollection(): void @@ -337,18 +352,20 @@ public function testInvokeGetOneToManyCollection(): void $entity = new Country('Foo'); $owner = (object) []; + $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $this->entityPersister->expects(self::once()) ->method('getOneToManyCollection') - ->with(self::identicalTo([]), self::identicalTo($owner), self::identicalTo(1), self::identicalTo(2)) + ->with(self::identicalTo($associationMapping), self::identicalTo($owner), self::identicalTo(1), self::identicalTo(2)) ->willReturn([$entity]); - self::assertSame([$entity], $persister->getOneToManyCollection([], $owner, 1, 2)); + self::assertSame([$entity], $persister->getOneToManyCollection($associationMapping, $owner, 1, 2)); } public function testInvokeLoadManyToManyCollection(): void { $mapping = $this->em->getClassMetadata(Country::class); - $assoc = ['type' => 1]; + $assoc = new OneToOneAssociationMapping('foo', 'bar', 'baz'); $coll = new PersistentCollection($this->em, $mapping, new ArrayCollection()); $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); @@ -365,7 +382,7 @@ public function testInvokeLoadManyToManyCollection(): void public function testInvokeLoadOneToManyCollection(): void { $mapping = $this->em->getClassMetadata(Country::class); - $assoc = ['type' => 1]; + $assoc = new OneToOneAssociationMapping('foo', 'bar', 'baz'); $coll = new PersistentCollection($this->em, $mapping, new ArrayCollection()); $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php index d27697b510f..f5f01625fa7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Models\CMS\CmsGroup; @@ -265,7 +266,7 @@ public function testWorkWithDqlHydratedEmptyCollection(): void ->setParameter(1, $user->getId()) ->getSingleResult(); self::assertCount(0, $newUser->groups); - self::assertIsArray($newUser->groups->getMapping()); + self::assertInstanceOf(AssociationMapping::class, $newUser->groups->getMapping()); $newUser->addGroup($group); diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index 8b8c813a537..5f3da208862 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -104,7 +104,7 @@ public function testJoinColumnName(): void 'fieldName' => 'article', 'targetEntity' => DDC117Article::class, 'joinColumns' => [ - ['name' => 'article'], + ['name' => 'article', 'referencedColumnName' => 'id'], ], ], ); @@ -123,7 +123,7 @@ public function testReferencedJoinColumnName(): void 'fieldName' => 'article', 'targetEntity' => DDC117Article::class, 'joinColumns' => [ - ['name' => 'article'], + ['name' => 'article', 'referencedColumnName' => 'id'], ], ], ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php new file mode 100644 index 00000000000..b129a2cb60e --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php @@ -0,0 +1,104 @@ +mappedBy = 'foo'; + $mapping->inversedBy = 'bar'; + $mapping->cascade = ['persist']; + $mapping->fetch = ClassMetadata::FETCH_EAGER; + $mapping->inherited = self::class; + $mapping->declared = self::class; + $mapping->cache = ['usage' => ClassMetadata::CACHE_USAGE_READ_ONLY]; + $mapping->id = true; + $mapping->isOnDeleteCascade = true; + $mapping->joinColumnFieldNames = ['foo' => 'bar']; + $mapping->joinTableColumns = ['foo', 'bar']; + $mapping->originalClass = self::class; + $mapping->originalField = 'foo'; + $mapping->orphanRemoval = true; + $mapping->unique = true; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof AssociationMapping); + + self::assertSame('foo', $resurrectedMapping->mappedBy); + self::assertSame('bar', $resurrectedMapping->inversedBy); + self::assertSame(['persist'], $resurrectedMapping->cascade); + self::assertSame(ClassMetadata::FETCH_EAGER, $resurrectedMapping->fetch); + self::assertSame(self::class, $resurrectedMapping->inherited); + self::assertSame(self::class, $resurrectedMapping->declared); + self::assertSame(['usage' => ClassMetadata::CACHE_USAGE_READ_ONLY], $resurrectedMapping->cache); + self::assertTrue($resurrectedMapping->id); + self::assertTrue($resurrectedMapping->isOnDeleteCascade); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->joinColumnFieldNames); + self::assertSame(['foo', 'bar'], $resurrectedMapping->joinTableColumns); + self::assertSame(self::class, $resurrectedMapping->originalClass); + self::assertSame('foo', $resurrectedMapping->originalField); + self::assertTrue($resurrectedMapping->orphanRemoval); + self::assertTrue($resurrectedMapping->unique); + } + + public function testItThrowsWhenAccessingUnknownProperty(): void + { + $mapping = new MyAssociationMapping( + fieldName: 'foo', + sourceEntity: self::class, + targetEntity: self::class, + ); + + $this->expectException(OutOfRangeException::class); + + $mapping['foo']; + } + + public function testItThrowsWhenSettingUnknownProperty(): void + { + $mapping = new MyAssociationMapping( + fieldName: 'foo', + sourceEntity: self::class, + targetEntity: self::class, + ); + + $this->expectException(OutOfRangeException::class); + + $mapping['foo'] = 'bar'; + } + + public function testItThrowsWhenUnsettingUnknownProperty(): void + { + $mapping = new MyAssociationMapping( + fieldName: 'foo', + sourceEntity: self::class, + targetEntity: self::class, + ); + + $this->expectException(OutOfRangeException::class); + + unset($mapping['foo']); + } +} + +class MyAssociationMapping extends AssociationMapping +{ +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index a7dc1b69bbf..5644da253f9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -11,7 +11,11 @@ use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; use Doctrine\ORM\Mapping\EmbeddedClassMapping; use Doctrine\ORM\Mapping\FieldMapping; +use Doctrine\ORM\Mapping\ManyToManyOwningSideMapping; +use Doctrine\ORM\Mapping\ManyToOneAssociationMapping; use Doctrine\ORM\Mapping\MappingException; +use Doctrine\ORM\Mapping\OneToManyAssociationMapping; +use Doctrine\ORM\Mapping\OneToOneOwningSideMapping; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsUser; @@ -298,7 +302,7 @@ public function testCreateManyToOne(): void self::assertEquals( [ - 'groups' => [ + 'groups' => ManyToOneAssociationMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'cascade' => [ @@ -325,11 +329,6 @@ public function testCreateManyToOne(): void 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, - 'isCascadeRemove' => true, - 'isCascadePersist' => true, - 'isCascadeRefresh' => true, - 'isCascadeMerge' => true, - 'isCascadeDetach' => true, 'sourceToTargetKeyColumns' => ['group_id' => 'id'], 'joinColumnFieldNames' => @@ -337,7 +336,7 @@ public function testCreateManyToOne(): void 'targetToSourceKeyColumns' => ['id' => 'group_id'], 'orphanRemoval' => false, - ], + ]), ], $this->cm->associationMappings, ); @@ -358,7 +357,7 @@ public function testCreateManyToOneWithIdentity(): void self::assertEquals( [ - 'groups' => [ + 'groups' => ManyToOneAssociationMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'cascade' => [ @@ -385,11 +384,6 @@ public function testCreateManyToOneWithIdentity(): void 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, - 'isCascadeRemove' => true, - 'isCascadePersist' => true, - 'isCascadeRefresh' => true, - 'isCascadeMerge' => true, - 'isCascadeDetach' => true, 'sourceToTargetKeyColumns' => ['group_id' => 'id'], 'joinColumnFieldNames' => @@ -398,7 +392,7 @@ public function testCreateManyToOneWithIdentity(): void ['id' => 'group_id'], 'orphanRemoval' => false, 'id' => true, - ], + ]), ], $this->cm->associationMappings, ); @@ -416,7 +410,7 @@ public function testCreateOneToOne(): void self::assertEquals( [ - 'groups' => [ + 'groups' => OneToOneOwningSideMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'cascade' => [ @@ -443,11 +437,6 @@ public function testCreateOneToOne(): void 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, - 'isCascadeRemove' => true, - 'isCascadePersist' => true, - 'isCascadeRefresh' => true, - 'isCascadeMerge' => true, - 'isCascadeDetach' => true, 'sourceToTargetKeyColumns' => ['group_id' => 'id'], 'joinColumnFieldNames' => @@ -455,7 +444,7 @@ public function testCreateOneToOne(): void 'targetToSourceKeyColumns' => ['id' => 'group_id'], 'orphanRemoval' => false, - ], + ]), ], $this->cm->associationMappings, ); @@ -476,7 +465,7 @@ public function testCreateOneToOneWithIdentity(): void self::assertEquals( [ - 'groups' => [ + 'groups' => OneToOneOwningSideMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'cascade' => [ @@ -504,11 +493,6 @@ public function testCreateOneToOneWithIdentity(): void 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, - 'isCascadeRemove' => true, - 'isCascadePersist' => true, - 'isCascadeRefresh' => true, - 'isCascadeMerge' => true, - 'isCascadeDetach' => true, 'sourceToTargetKeyColumns' => ['group_id' => 'id'], 'joinColumnFieldNames' => @@ -516,7 +500,7 @@ public function testCreateOneToOneWithIdentity(): void 'targetToSourceKeyColumns' => ['id' => 'group_id'], 'orphanRemoval' => false, - ], + ]), ], $this->cm->associationMappings, ); @@ -550,7 +534,7 @@ public function testCreateManyToMany(): void self::assertEquals( [ 'groups' => - [ + ManyToManyOwningSideMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'cascade' => @@ -594,13 +578,8 @@ public function testCreateManyToMany(): void 'mappedBy' => null, 'inversedBy' => null, 'isOwningSide' => true, - 'sourceEntity' => CmsUser::class, - 'isCascadeRemove' => true, - 'isCascadePersist' => true, - 'isCascadeRefresh' => true, - 'isCascadeMerge' => true, - 'isCascadeDetach' => true, 'isOnDeleteCascade' => true, + 'sourceEntity' => CmsUser::class, 'relationToSourceKeyColumns' => ['group_id' => 'id'], 'joinTableColumns' => @@ -611,7 +590,7 @@ public function testCreateManyToMany(): void 'relationToTargetKeyColumns' => ['user_id' => 'id'], 'orphanRemoval' => false, - ], + ]), ], $this->cm->associationMappings, ); @@ -644,27 +623,20 @@ public function testCreateOneToMany(): void self::assertEquals( [ 'groups' => - [ + OneToManyAssociationMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'mappedBy' => 'test', - 'orderBy' => - [0 => 'test'], + 'orderBy' => [0 => 'test'], 'indexBy' => 'test', 'type' => 4, 'inversedBy' => null, 'isOwningSide' => false, 'sourceEntity' => CmsUser::class, 'fetch' => 2, - 'cascade' => - [], - 'isCascadeRemove' => false, - 'isCascadePersist' => false, - 'isCascadeRefresh' => false, - 'isCascadeMerge' => false, - 'isCascadeDetach' => false, + 'cascade' => [], 'orphanRemoval' => false, - ], + ]), ], $this->cm->associationMappings, ); @@ -694,7 +666,7 @@ public function testOrphanRemovalOnCreateOneToOne(): void self::assertEquals( [ - 'groups' => [ + 'groups' => OneToOneOwningSideMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'cascade' => [], @@ -715,11 +687,6 @@ public function testOrphanRemovalOnCreateOneToOne(): void 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, - 'isCascadeRemove' => true, - 'isCascadePersist' => false, - 'isCascadeRefresh' => false, - 'isCascadeMerge' => false, - 'isCascadeDetach' => false, 'sourceToTargetKeyColumns' => ['group_id' => 'id'], 'joinColumnFieldNames' => @@ -727,7 +694,7 @@ public function testOrphanRemovalOnCreateOneToOne(): void 'targetToSourceKeyColumns' => ['id' => 'group_id'], 'orphanRemoval' => true, - ], + ]), ], $this->cm->associationMappings, ); @@ -746,7 +713,7 @@ public function testOrphanRemovalOnCreateOneToMany(): void self::assertEquals( [ 'groups' => - [ + OneToManyAssociationMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'mappedBy' => 'test', @@ -756,13 +723,8 @@ public function testOrphanRemovalOnCreateOneToMany(): void 'sourceEntity' => CmsUser::class, 'fetch' => 2, 'cascade' => [], - 'isCascadeRemove' => true, - 'isCascadePersist' => false, - 'isCascadeRefresh' => false, - 'isCascadeMerge' => false, - 'isCascadeDetach' => false, 'orphanRemoval' => true, - ], + ]), ], $this->cm->associationMappings, ); @@ -789,7 +751,7 @@ public function testOrphanRemovalOnManyToMany(): void self::assertEquals( [ - 'groups' => [ + 'groups' => ManyToManyOwningSideMapping::fromMappingArray([ 'fieldName' => 'groups', 'targetEntity' => CmsGroup::class, 'cascade' => [], @@ -819,11 +781,6 @@ public function testOrphanRemovalOnManyToMany(): void 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, - 'isCascadeRemove' => false, - 'isCascadePersist' => false, - 'isCascadeRefresh' => false, - 'isCascadeMerge' => false, - 'isCascadeDetach' => false, 'isOnDeleteCascade' => true, 'relationToSourceKeyColumns' => ['group_id' => 'id'], 'joinTableColumns' => [ @@ -832,7 +789,7 @@ public function testOrphanRemovalOnManyToMany(): void ], 'relationToTargetKeyColumns' => ['cmsgroup_id' => 'id'], 'orphanRemoval' => true, - ], + ]), ], $this->cm->associationMappings, ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 948ba2d5a96..149045095df 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -13,6 +13,8 @@ use Doctrine\ORM\Mapping\DefaultNamingStrategy; use Doctrine\ORM\Mapping\DefaultTypedFieldMapper; use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; +use Doctrine\ORM\Mapping\JoinTableMapping; +use Doctrine\ORM\Mapping\ManyToOneAssociationMapping; use Doctrine\ORM\Mapping\MappedSuperclass; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; @@ -141,7 +143,7 @@ public function testFieldIsNullableByType(): void $cm = new ClassMetadata(UserTyped::class); $cm->initializeReflection(new RuntimeReflectionService()); - $cm->mapOneToOne(['fieldName' => 'email', 'joinColumns' => [[]]]); + $cm->mapOneToOne(['fieldName' => 'email', 'joinColumns' => [['name' => 'email_id', 'referencedColumnName' => 'id']]]); self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('email')['targetEntity']); $cm->mapManyToOne(['fieldName' => 'mainEmail']); @@ -264,11 +266,11 @@ public function testMapManyToManyJoinTableDefaults(): void $assoc = $cm->associationMappings['groups']; self::assertEquals( - [ + JoinTableMapping::fromMappingArray([ 'name' => 'cmsuser_cmsgroup', 'joinColumns' => [['name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], 'inverseJoinColumns' => [['name' => 'cmsgroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], - ], + ]), $assoc['joinTable'], ); self::assertTrue($assoc['isOnDeleteCascade']); @@ -354,8 +356,18 @@ public function testDuplicateAssociationMappingException(): void $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $a1 = ['fieldName' => 'foo', 'sourceEntity' => stdClass::class, 'targetEntity' => stdClass::class, 'mappedBy' => 'foo']; - $a2 = ['fieldName' => 'foo', 'sourceEntity' => stdClass::class, 'targetEntity' => stdClass::class, 'mappedBy' => 'foo']; + $a1 = ManyToOneAssociationMapping::fromMappingArray([ + 'fieldName' => 'foo', + 'sourceEntity' => stdClass::class, + 'targetEntity' => stdClass::class, + 'mappedBy' => 'foo', + ]); + $a2 = ManyToOneAssociationMapping::fromMappingArray([ + 'fieldName' => 'foo', + 'sourceEntity' => stdClass::class, + 'targetEntity' => stdClass::class, + 'mappedBy' => 'foo', + ]); $cm->addInheritedAssociationMapping($a1); $this->expectException(MappingException::class); @@ -858,11 +870,11 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void ); self::assertEquals( - [ + JoinTableMapping::fromMappingArray([ 'name' => 'customtypeparent_customtypeparent', 'joinColumns' => [['name' => 'customtypeparent_source', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], 'inverseJoinColumns' => [['name' => 'customtypeparent_target', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], - ], + ]), $cm->associationMappings['friendsWithMe']['joinTable'], ); self::assertEquals(['customtypeparent_source', 'customtypeparent_target'], $cm->associationMappings['friendsWithMe']['joinTableColumns']); diff --git a/tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php new file mode 100644 index 00000000000..e79d1b44be5 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php @@ -0,0 +1,43 @@ +name = 'foo'; + $mapping->unique = true; + $mapping->quoted = true; + $mapping->fieldName = 'bar'; + $mapping->onDelete = 'CASCADE'; + $mapping->columnDefinition = 'VARCHAR(255)'; + $mapping->nullable = true; + $mapping->referencedColumnName = 'baz'; + $mapping->options = ['foo' => 'bar']; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof JoinColumnMapping); + + self::assertSame('foo', $resurrectedMapping->name); + self::assertTrue($resurrectedMapping->unique); + self::assertTrue($resurrectedMapping->quoted); + self::assertSame('bar', $resurrectedMapping->fieldName); + self::assertSame('CASCADE', $resurrectedMapping->onDelete); + self::assertSame('VARCHAR(255)', $resurrectedMapping->columnDefinition); + self::assertTrue($resurrectedMapping->nullable); + self::assertSame('baz', $resurrectedMapping->referencedColumnName); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->options); + } +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php new file mode 100644 index 00000000000..846605cf9fd --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php @@ -0,0 +1,36 @@ +quoted = true; + $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->inverseJoinColumns = [new JoinColumnMapping('id')]; + $mapping->schema = 'foo'; + $mapping->name = 'bar'; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof JoinTableMapping); + + self::assertTrue($resurrectedMapping->quoted); + self::assertCount(1, $resurrectedMapping->joinColumns); + self::assertCount(1, $resurrectedMapping->inverseJoinColumns); + self::assertSame('foo', $resurrectedMapping->schema); + self::assertSame('bar', $resurrectedMapping->name); + } +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyAssociationMappingTest.php new file mode 100644 index 00000000000..01b1ac22e8d --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyAssociationMappingTest.php @@ -0,0 +1,33 @@ +relationToSourceKeyColumns = ['foo' => 'bar']; + $mapping->relationToTargetKeyColumns = ['bar' => 'baz']; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof ManyToManyAssociationMapping); + + self::assertSame(['foo' => 'bar'], $resurrectedMapping->relationToSourceKeyColumns); + self::assertSame(['bar' => 'baz'], $resurrectedMapping->relationToTargetKeyColumns); + } +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php new file mode 100644 index 00000000000..77f44121448 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php @@ -0,0 +1,33 @@ +joinTable = new JoinTableMapping(); + $mapping->joinTable->name = 'bar'; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof ManyToManyOwningSideMapping); + + self::assertSame($resurrectedMapping->joinTable->name, 'bar'); + } +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php new file mode 100644 index 00000000000..02831a3b198 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php @@ -0,0 +1,32 @@ +joinColumns = [new JoinColumnMapping('id')]; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof ManyToOneAssociationMapping); + + self::assertCount(1, $resurrectedMapping->joinColumns); + } +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php new file mode 100644 index 00000000000..fb7c9cc461a --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php @@ -0,0 +1,32 @@ +joinColumns = [new JoinColumnMapping('id')]; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof OneToOneOwningSideMapping); + + self::assertCount(1, $resurrectedMapping->joinColumns); + } +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php index 2266ea828bf..74860086112 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php @@ -147,7 +147,7 @@ public function testQuoteIdentifierJoinColumns(): void 'fieldName' => 'article', 'targetEntity' => DDC117Article::class, 'joinColumns' => [ - ['name' => '`article`'], + ['name' => '`article`', 'referencedColumnName' => 'article'], ], ], ); @@ -165,7 +165,7 @@ public function testJoinColumnName(): void 'fieldName' => 'article', 'targetEntity' => DDC117Article::class, 'joinColumns' => [ - ['name' => '`article`'], + ['name' => '`article`', 'referencedColumnName' => 'article'], ], ], ); @@ -184,7 +184,7 @@ public function testReferencedJoinColumnName(): void 'fieldName' => 'article', 'targetEntity' => DDC117Article::class, 'joinColumns' => [ - ['name' => '`article`'], + ['name' => '`article`', 'referencedColumnName' => 'id'], ], ], ); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php new file mode 100644 index 00000000000..8befdde20f0 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php @@ -0,0 +1,37 @@ +indexBy = 'foo'; + $mapping->orderBy = ['foo' => 'asc']; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof ToManyAssociationMapping); + + self::assertSame('foo', $resurrectedMapping->fieldName); + self::assertSame(['foo' => 'asc'], $resurrectedMapping->orderBy); + } +} + +class MyToManyAssociationMapping extends ToManyAssociationMapping +{ +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ToOneAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ToOneAssociationMappingTest.php new file mode 100644 index 00000000000..32858ea577c --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/ToOneAssociationMappingTest.php @@ -0,0 +1,37 @@ +sourceToTargetKeyColumns = ['foo' => 'bar']; + $mapping->targetToSourceKeyColumns = ['bar' => 'foo']; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof ToOneAssociationMapping); + + self::assertSame(['foo' => 'bar'], $resurrectedMapping->sourceToTargetKeyColumns); + self::assertSame(['bar' => 'foo'], $resurrectedMapping->targetToSourceKeyColumns); + } +} + +class MyToOneAssociationMapping extends ToOneAssociationMapping +{ +} diff --git a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php index d1f82e74cd9..a4ce25192dc 100644 --- a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM; +use Doctrine\ORM\Mapping\OneToManyAssociationMapping; use Doctrine\ORM\ORMInvalidArgumentException; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -46,21 +47,21 @@ public function __toString(): string return 'ThisIsAStringRepresentationOfEntity3'; } }; - $association1 = [ + $association1 = OneToManyAssociationMapping::fromMappingArray([ 'sourceEntity' => 'foo1', 'fieldName' => 'bar1', 'targetEntity' => 'baz1', - ]; - $association2 = [ + ]); + $association2 = OneToManyAssociationMapping::fromMappingArray([ 'sourceEntity' => 'foo2', 'fieldName' => 'bar2', 'targetEntity' => 'baz2', - ]; - $association3 = [ + ]); + $association3 = OneToManyAssociationMapping::fromMappingArray([ 'sourceEntity' => 'foo3', 'fieldName' => 'bar3', 'targetEntity' => 'baz3', - ]; + ]); return [ 'one entity found' => [ diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php index 4dafeda7f8d..9ab9e32c86b 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php @@ -5,6 +5,8 @@ namespace Doctrine\Tests\ORM\Persisters; use Doctrine\Common\Collections\Expr\Comparison; +use Doctrine\ORM\Mapping\AssociationMapping; +use Doctrine\ORM\Mapping\ManyToOneAssociationMapping; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; use Doctrine\ORM\Persisters\Exception\CantUseInOperatorOnCompositeKeys; use Doctrine\Tests\Mocks\EntityManagerMock; @@ -15,36 +17,42 @@ class BasicEntityPersisterCompositeTypeSqlTest extends OrmTestCase { protected BasicEntityPersister $persister; protected EntityManagerMock $entityManager; + private AssociationMapping $associationMapping; protected function setUp(): void { parent::setUp(); - $this->entityManager = $this->getTestEntityManager(); - $this->persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(Admin1AlternateName::class)); + $this->entityManager = $this->getTestEntityManager(); + $this->persister = new BasicEntityPersister($this->entityManager, $this->entityManager->getClassMetadata(Admin1AlternateName::class)); + $this->associationMapping = new ManyToOneAssociationMapping( + fieldName: 'admin1', + sourceEntity: WhoCares::class, + targetEntity: Admin1AlternateName::class, + ); } public function testSelectConditionStatementEq(): void { - $statement = $this->persister->getSelectConditionStatementSQL('admin1', 1, [], Comparison::EQ); + $statement = $this->persister->getSelectConditionStatementSQL('admin1', 1, $this->associationMapping, Comparison::EQ); self::assertEquals('t0.admin1 = ? AND t0.country = ?', $statement); } public function testSelectConditionStatementEqNull(): void { - $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::IS); + $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, $this->associationMapping, Comparison::IS); self::assertEquals('t0.admin1 IS NULL AND t0.country IS NULL', $statement); } public function testSelectConditionStatementNeqNull(): void { - $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, [], Comparison::NEQ); + $statement = $this->persister->getSelectConditionStatementSQL('admin1', null, $this->associationMapping, Comparison::NEQ); self::assertEquals('t0.admin1 IS NOT NULL AND t0.country IS NOT NULL', $statement); } public function testSelectConditionStatementIn(): void { $this->expectException(CantUseInOperatorOnCompositeKeys::class); - $this->persister->getSelectConditionStatementSQL('admin1', [], [], Comparison::IN); + $this->persister->getSelectConditionStatementSQL('admin1', [], $this->associationMapping, Comparison::IN); } } diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index 35d9482b909..3bfbbeacdd5 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type as DBALType; +use Doctrine\ORM\Mapping\OneToManyAssociationMapping; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; use Doctrine\Tests\DbalTypes\NegativeToPositiveType; use Doctrine\Tests\DbalTypes\UpperCaseStringType; @@ -119,19 +120,27 @@ public function testStripNonAlphanumericCharactersFromSelectColumnListSQL(): voi #[Group('DDC-2073')] public function testSelectConditionStatementIsNull(): void { - $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::IS); + $associationMapping = new OneToManyAssociationMapping('foo', 'bar', 'baz'); + $statement = $this->persister->getSelectConditionStatementSQL('test', null, $associationMapping, Comparison::IS); self::assertEquals('test IS NULL', $statement); } public function testSelectConditionStatementEqNull(): void { - $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::EQ); + $associationMapping = new OneToManyAssociationMapping('foo', 'bar', 'baz'); + $statement = $this->persister->getSelectConditionStatementSQL('test', null, $associationMapping, Comparison::EQ); self::assertEquals('test IS NULL', $statement); } public function testSelectConditionStatementNeqNull(): void { - $statement = $this->persister->getSelectConditionStatementSQL('test', null, [], Comparison::NEQ); + $associationMapping = new OneToManyAssociationMapping('foo', 'bar', 'baz'); + $statement = $this->persister->getSelectConditionStatementSQL( + 'test', + null, + $associationMapping, + Comparison::NEQ, + ); self::assertEquals('test IS NOT NULL', $statement); } From 2acb298e7445b8bd70aef4bbff78652b28c4aad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 11 Apr 2023 09:06:02 +0200 Subject: [PATCH 242/475] Use Rector to migrate to the object API of FieldMapping This makes the array access implementation of FieldMapping useful only to consumers, it is no longer useful internally, and should be deprecated as of Doctrine 3.1.0 --- .../ORM/Cache/DefaultEntityHydrator.php | 4 +- .../Internal/Hydration/AbstractHydrator.php | 2 +- .../ORM/Mapping/AnsiQuoteStrategy.php | 2 +- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 104 ++++++++-------- .../ORM/Mapping/ClassMetadataFactory.php | 12 +- .../ORM/Mapping/DefaultQuoteStrategy.php | 6 +- .../AbstractEntityInheritancePersister.php | 4 +- .../Entity/BasicEntityPersister.php | 36 +++--- .../Entity/JoinedSubclassPersister.php | 22 ++-- .../Entity/SingleTablePersister.php | 2 +- .../Query/AST/Functions/IdentityFunction.php | 2 +- .../Query/Exec/MultiTableUpdateExecutor.php | 2 +- .../ORM/Query/ResultSetMappingBuilder.php | 4 +- lib/Doctrine/ORM/Query/SqlWalker.php | 38 +++--- .../Pagination/LimitSubqueryOutputWalker.php | 4 +- .../Tools/Pagination/LimitSubqueryWalker.php | 2 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 62 +++++----- lib/Doctrine/ORM/Tools/SchemaValidator.php | 4 +- lib/Doctrine/ORM/UnitOfWork.php | 2 +- lib/Doctrine/ORM/Utility/PersisterHelper.php | 2 +- psalm-baseline.xml | 1 - .../ORM/Functional/DatabaseDriverTest.php | 32 ++--- .../Tests/ORM/Functional/EnumTest.php | 4 +- .../Mapping/BasicInheritanceMappingTest.php | 4 +- .../ORM/Mapping/ClassMetadataBuilderTest.php | 12 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 28 ++--- .../ORM/Mapping/MappingDriverTestCase.php | 112 ++++++++---------- .../Tests/ORM/Tools/SchemaToolTest.php | 6 +- 28 files changed, 250 insertions(+), 265 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 0cbe377d6be..6afd8569300 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -46,7 +46,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob } foreach ($metadata->fieldMappings as $name => $fieldMapping) { - if (isset($fieldMapping['generated'])) { + if (isset($fieldMapping->generated)) { $data[$name] = $metadata->getFieldValue($entity, $name); } } @@ -79,7 +79,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob if (isset($targetClassMetadata->fieldMappings[$fieldName])) { $fieldMapping = $targetClassMetadata->fieldMappings[$fieldName]; - $data[$owningAssociation['targetToSourceKeyColumns'][$fieldMapping['columnName']]] = $fieldValue; + $data[$owningAssociation['targetToSourceKeyColumns'][$fieldMapping->columnName]] = $fieldValue; continue; } diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 99b636be9d4..b39b6234cd1 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -401,7 +401,7 @@ protected function hydrateColumnInfo(string $key): array|null $columnInfo = [ 'isIdentifier' => in_array($fieldName, $classMetadata->identifier, true), 'fieldName' => $fieldName, - 'type' => Type::getType($fieldMapping['type']), + 'type' => Type::getType($fieldMapping->type), 'dqlAlias' => $ownerMap, 'enumType' => $this->rsm->enumMappings[$key] ?? null, ]; diff --git a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php index a911103ccfa..a52cfbaf74d 100644 --- a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php @@ -20,7 +20,7 @@ public function getColumnName( ClassMetadata $class, AbstractPlatform $platform, ): string { - return $class->fieldMappings[$fieldName]['columnName']; + return $class->fieldMappings[$fieldName]->columnName; } public function getTableName(ClassMetadata $class, AbstractPlatform $platform): string diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 16daf2218f3..8a1635be326 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -822,33 +822,35 @@ public function wakeupReflection(ReflectionService $reflService): void } foreach ($this->fieldMappings as $field => $mapping) { - if (isset($mapping['declaredField']) && isset($parentReflFields[$mapping['declaredField']])) { - $childProperty = $this->getAccessibleProperty($reflService, $mapping['originalClass'], $mapping['originalField']); + if (isset($mapping->declaredField) && isset($parentReflFields[$mapping->declaredField])) { + assert($mapping->originalField !== null); + assert($mapping->originalClass !== null); + $childProperty = $this->getAccessibleProperty($reflService, $mapping->originalClass, $mapping->originalField); assert($childProperty !== null); - if (isset($mapping['enumType'])) { + if (isset($mapping->enumType)) { $childProperty = new ReflectionEnumProperty( $childProperty, - $mapping['enumType'], + $mapping->enumType, ); } $this->reflFields[$field] = new ReflectionEmbeddedProperty( - $parentReflFields[$mapping['declaredField']], + $parentReflFields[$mapping->declaredField], $childProperty, - $mapping['originalClass'], + $mapping->originalClass, ); continue; } - $this->reflFields[$field] = isset($mapping['declared']) - ? $this->getAccessibleProperty($reflService, $mapping['declared'], $field) + $this->reflFields[$field] = isset($mapping->declared) + ? $this->getAccessibleProperty($reflService, $mapping->declared, $field) : $this->getAccessibleProperty($reflService, $this->name, $field); - if (isset($mapping['enumType']) && $this->reflFields[$field] !== null) { + if (isset($mapping->enumType) && $this->reflFields[$field] !== null) { $this->reflFields[$field] = new ReflectionEnumProperty( $this->reflFields[$field], - $mapping['enumType'], + $mapping->enumType, ); } } @@ -1034,14 +1036,14 @@ public function isUniqueField(string $fieldName): bool { $mapping = $this->getFieldMapping($fieldName); - return $mapping !== false && isset($mapping['unique']) && $mapping['unique']; + return $mapping !== false && isset($mapping->unique) && $mapping->unique; } public function isNullable(string $fieldName): bool { $mapping = $this->getFieldMapping($fieldName); - return $mapping !== false && isset($mapping['nullable']) && $mapping['nullable']; + return $mapping !== false && isset($mapping->nullable) && $mapping->nullable; } /** @@ -1195,27 +1197,27 @@ protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping $mapping = FieldMapping::fromMappingArray($mapping); - if ($mapping['columnName'][0] === '`') { - $mapping['columnName'] = trim($mapping['columnName'], '`'); - $mapping['quoted'] = true; + if ($mapping->columnName[0] === '`') { + $mapping->columnName = trim($mapping->columnName, '`'); + $mapping->quoted = true; } - $this->columnNames[$mapping['fieldName']] = $mapping['columnName']; + $this->columnNames[$mapping->fieldName] = $mapping->columnName; - if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn && $this->discriminatorColumn['name'] === $mapping['columnName'])) { - throw MappingException::duplicateColumnName($this->name, $mapping['columnName']); + if (isset($this->fieldNames[$mapping->columnName]) || ($this->discriminatorColumn && $this->discriminatorColumn['name'] === $mapping->columnName)) { + throw MappingException::duplicateColumnName($this->name, $mapping->columnName); } - $this->fieldNames[$mapping['columnName']] = $mapping['fieldName']; + $this->fieldNames[$mapping->columnName] = $mapping->fieldName; // Complete id mapping - if (isset($mapping['id']) && $mapping['id'] === true) { - if ($this->versionField === $mapping['fieldName']) { - throw MappingException::cannotVersionIdField($this->name, $mapping['fieldName']); + if (isset($mapping->id) && $mapping->id === true) { + if ($this->versionField === $mapping->fieldName) { + throw MappingException::cannotVersionIdField($this->name, $mapping->fieldName); } - if (! in_array($mapping['fieldName'], $this->identifier, true)) { - $this->identifier[] = $mapping['fieldName']; + if (! in_array($mapping->fieldName, $this->identifier, true)) { + $this->identifier[] = $mapping->fieldName; } // Check for composite key @@ -1224,22 +1226,22 @@ protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping } } - if (isset($mapping['generated'])) { - if (! in_array($mapping['generated'], [self::GENERATED_NEVER, self::GENERATED_INSERT, self::GENERATED_ALWAYS])) { - throw MappingException::invalidGeneratedMode($mapping['generated']); + if (isset($mapping->generated)) { + if (! in_array($mapping->generated, [self::GENERATED_NEVER, self::GENERATED_INSERT, self::GENERATED_ALWAYS])) { + throw MappingException::invalidGeneratedMode($mapping->generated); } - if ($mapping['generated'] === self::GENERATED_NEVER) { - unset($mapping['generated']); + if ($mapping->generated === self::GENERATED_NEVER) { + unset($mapping->generated); } } - if (isset($mapping['enumType'])) { - if (! enum_exists($mapping['enumType'])) { - throw MappingException::nonEnumTypeMapped($this->name, $mapping['fieldName'], $mapping['enumType']); + if (isset($mapping->enumType)) { + if (! enum_exists($mapping->enumType)) { + throw MappingException::nonEnumTypeMapped($this->name, $mapping->fieldName, $mapping->enumType); } - if (! empty($mapping['id'])) { + if (! empty($mapping->id)) { $this->containsEnumIdentifier = true; } } @@ -1512,7 +1514,7 @@ public function getIdentifierColumnNames(): array foreach ($this->identifier as $idProperty) { if (isset($this->fieldMappings[$idProperty])) { - $columnNames[] = $this->fieldMappings[$idProperty]['columnName']; + $columnNames[] = $this->fieldMappings[$idProperty]->columnName; continue; } @@ -1607,7 +1609,7 @@ public function isIdentifierNatural(): bool public function getTypeOfField(string $fieldName): string|null { return isset($this->fieldMappings[$fieldName]) - ? $this->fieldMappings[$fieldName]['type'] + ? $this->fieldMappings[$fieldName]->type : null; } @@ -1751,29 +1753,29 @@ public function setAttributeOverride(string $fieldName, array $overrideMapping): $mapping = $this->fieldMappings[$fieldName]; - if (isset($mapping['inherited'])) { - throw MappingException::illegalOverrideOfInheritedProperty($this->name, $fieldName, $mapping['inherited']); + if (isset($mapping->inherited)) { + throw MappingException::illegalOverrideOfInheritedProperty($this->name, $fieldName, $mapping->inherited); } - if (isset($mapping['id'])) { - $overrideMapping['id'] = $mapping['id']; + if (isset($mapping->id)) { + $overrideMapping['id'] = $mapping->id; } if (! isset($overrideMapping['type'])) { - $overrideMapping['type'] = $mapping['type']; + $overrideMapping['type'] = $mapping->type; } if (! isset($overrideMapping['fieldName'])) { - $overrideMapping['fieldName'] = $mapping['fieldName']; + $overrideMapping['fieldName'] = $mapping->fieldName; } - if ($overrideMapping['type'] !== $mapping['type']) { + if ($overrideMapping['type'] !== $mapping->type) { throw MappingException::invalidOverrideFieldType($this->name, $fieldName); } unset($this->fieldMappings[$fieldName]); - unset($this->fieldNames[$mapping['columnName']]); - unset($this->columnNames[$mapping['fieldName']]); + unset($this->fieldNames[$mapping->columnName]); + unset($this->columnNames[$mapping->fieldName]); $overrideMapping = $this->validateAndCompleteFieldMapping($overrideMapping); @@ -1785,7 +1787,7 @@ public function setAttributeOverride(string $fieldName, array $overrideMapping): */ public function isInheritedField(string $fieldName): bool { - return isset($this->fieldMappings[$fieldName]['inherited']); + return isset($this->fieldMappings[$fieldName]->inherited); } /** @@ -1888,13 +1890,13 @@ private function isInheritanceType(int $type): bool public function mapField(array $mapping): void { $mapping = $this->validateAndCompleteFieldMapping($mapping); - $this->assertFieldNotMapped($mapping['fieldName']); + $this->assertFieldNotMapped($mapping->fieldName); - if (isset($mapping['generated'])) { + if (isset($mapping->generated)) { $this->requiresFetchAfterChange = true; } - $this->fieldMappings[$mapping['fieldName']] = $mapping; + $this->fieldMappings[$mapping->fieldName] = $mapping; } /** @@ -1920,9 +1922,9 @@ public function addInheritedAssociationMapping(AssociationMapping $mapping/*, $o */ public function addInheritedFieldMapping(FieldMapping $fieldMapping): void { - $this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping; - $this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName']; - $this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName']; + $this->fieldMappings[$fieldMapping->fieldName] = $fieldMapping; + $this->columnNames[$fieldMapping->fieldName] = $fieldMapping->columnName; + $this->fieldNames[$fieldMapping->columnName] = $fieldMapping->fieldName; } /** diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 63edd9df5a4..1d4e00aba2a 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -387,12 +387,12 @@ private function addMappingInheritanceInformation( AssociationMapping|EmbeddedClassMapping|FieldMapping $mapping, ClassMetadata $parentClass, ): void { - if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { - $mapping['inherited'] = $parentClass->name; + if (! isset($mapping->inherited) && ! $parentClass->isMappedSuperclass) { + $mapping->inherited = $parentClass->name; } - if (! isset($mapping['declared'])) { - $mapping['declared'] = $parentClass->name; + if (! isset($mapping->declared)) { + $mapping->declared = $parentClass->name; } } @@ -519,7 +519,7 @@ private function completeIdGeneratorMapping(ClassMetadata $class): void $sequenceName = null; $fieldName = $class->identifier ? $class->getSingleIdentifierFieldName() : null; - $generator = $fieldName && $class->fieldMappings[$fieldName]['type'] === 'bigint' + $generator = $fieldName && $class->fieldMappings[$fieldName]->type === 'bigint' ? new BigIntegerIdentityGenerator() : new IdentityGenerator(); @@ -534,7 +534,7 @@ private function completeIdGeneratorMapping(ClassMetadata $class): void if (! $definition) { $fieldName = $class->getSingleIdentifierFieldName(); $sequenceName = $class->getSequenceName($this->getTargetPlatform()); - $quoted = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']); + $quoted = isset($class->fieldMappings[$fieldName]->quoted) || isset($class->table['quoted']); $definition = [ 'sequenceName' => $this->truncateSequenceName($sequenceName), diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index 0b29cc95d3b..7d86c65efa7 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -22,9 +22,9 @@ class DefaultQuoteStrategy implements QuoteStrategy public function getColumnName(string $fieldName, ClassMetadata $class, AbstractPlatform $platform): string { - return isset($class->fieldMappings[$fieldName]['quoted']) - ? $platform->quoteIdentifier($class->fieldMappings[$fieldName]['columnName']) - : $class->fieldMappings[$fieldName]['columnName']; + return isset($class->fieldMappings[$fieldName]->quoted) + ? $platform->quoteIdentifier($class->fieldMappings[$fieldName]->columnName) + : $class->fieldMappings[$fieldName]->columnName; } /** diff --git a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php index 372c2bf25a5..62b75dbde33 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php @@ -40,7 +40,7 @@ protected function getSelectColumnSQL(string $field, ClassMetadata $class, strin { $tableAlias = $alias === 'r' ? '' : $alias; $fieldMapping = $class->fieldMappings[$field]; - $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']); + $columnAlias = $this->getSQLColumnAlias($fieldMapping->columnName); $sql = sprintf( '%s.%s', $this->getSQLTableAlias($class->name, $tableAlias), @@ -49,7 +49,7 @@ protected function getSelectColumnSQL(string $field, ClassMetadata $class, strin $this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field, $class->name); - $type = Type::getType($fieldMapping['type']); + $type = Type::getType($fieldMapping->type); $sql = $type->convertToPHPValueSQL($sql, $this->platform); return $sql . ' AS ' . $columnAlias; diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 2c4e8ff6565..870a6da3c8b 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -279,7 +279,7 @@ protected function assignDefaultVersionAndUpsertableValues(object $entity, array $values = $this->fetchVersionAndNotUpsertableValues($this->class, $id); foreach ($values as $field => $value) { - $value = Type::getType($this->class->fieldMappings[$field]['type'])->convertToPHPValue($value, $this->platform); + $value = Type::getType($this->class->fieldMappings[$field]->type)->convertToPHPValue($value, $this->platform); $this->class->setFieldValue($entity, $field, $value); } @@ -295,7 +295,7 @@ protected function fetchVersionAndNotUpsertableValues(ClassMetadata $versionedCl { $columnNames = []; foreach ($this->class->fieldMappings as $key => $column) { - if (isset($column['generated']) || ($this->class->isVersioned && $key === $versionedClass->versionField)) { + if (isset($column->generated) || ($this->class->isVersioned && $key === $versionedClass->versionField)) { $columnNames[$key] = $this->quoteStrategy->getColumnName($key, $versionedClass, $this->platform); } } @@ -428,7 +428,7 @@ final protected function updateTable( foreach ($this->class->identifier as $idField) { if (! isset($this->class->associationMappings[$idField])) { $params[] = $identifier[$idField]; - $types[] = $this->class->fieldMappings[$idField]['type']; + $types[] = $this->class->fieldMappings[$idField]->type; $where[] = $this->quoteStrategy->getColumnName($idField, $this->class, $this->platform); continue; @@ -454,11 +454,11 @@ final protected function updateTable( if ($versioned) { $versionField = $this->class->versionField; assert($versionField !== null); - $versionFieldType = $this->class->fieldMappings[$versionField]['type']; + $versionFieldType = $this->class->fieldMappings[$versionField]->type; $versionColumn = $this->quoteStrategy->getColumnName($versionField, $this->class, $this->platform); $where[] = $versionColumn; - $types[] = $this->class->fieldMappings[$versionField]['type']; + $types[] = $this->class->fieldMappings[$versionField]->type; $params[] = $this->class->reflFields[$versionField]->getValue($entity); switch ($versionFieldType) { @@ -605,17 +605,17 @@ protected function prepareUpdateData(object $entity, bool $isInsert = false): ar if (! isset($this->class->associationMappings[$field])) { $fieldMapping = $this->class->fieldMappings[$field]; - $columnName = $fieldMapping['columnName']; + $columnName = $fieldMapping->columnName; - if (! $isInsert && isset($fieldMapping['notUpdatable'])) { + if (! $isInsert && isset($fieldMapping->notUpdatable)) { continue; } - if ($isInsert && isset($fieldMapping['notInsertable'])) { + if ($isInsert && isset($fieldMapping->notInsertable)) { continue; } - $this->columnTypes[$columnName] = $fieldMapping['type']; + $this->columnTypes[$columnName] = $fieldMapping->type; $result[$this->getOwningTable($field)][$columnName] = $newVal; @@ -1120,7 +1120,7 @@ final protected function getOrderBySQL(array $orderBy, string $baseTableAlias): } if (isset($this->class->fieldMappings[$fieldName])) { - $tableAlias = isset($this->class->fieldMappings[$fieldName]['inherited']) + $tableAlias = isset($this->class->fieldMappings[$fieldName]->inherited) ? $this->getSQLTableAlias($this->class->fieldMappings[$fieldName]['inherited']) : $baseTableAlias; @@ -1409,12 +1409,12 @@ protected function getInsertColumnList(): array } if (! $this->class->isIdGeneratorIdentity() || $this->class->identifier[0] !== $name) { - if (isset($this->class->fieldMappings[$name]['notInsertable'])) { + if (isset($this->class->fieldMappings[$name]->notInsertable)) { continue; } $columns[] = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform); - $this->columnTypes[$name] = $this->class->fieldMappings[$name]['type']; + $this->columnTypes[$name] = $this->class->fieldMappings[$name]->type; } } @@ -1433,14 +1433,14 @@ protected function getSelectColumnSQL(string $field, ClassMetadata $class, strin $tableAlias = $this->getSQLTableAlias($class->name, $root); $fieldMapping = $class->fieldMappings[$field]; $sql = sprintf('%s.%s', $tableAlias, $this->quoteStrategy->getColumnName($field, $class, $this->platform)); - $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']); + $columnAlias = $this->getSQLColumnAlias($fieldMapping->columnName); $this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field); - if (! empty($fieldMapping['enumType'])) { - $this->currentPersisterContext->rsm->addEnumResult($columnAlias, $fieldMapping['enumType']); + if (! empty($fieldMapping->enumType)) { + $this->currentPersisterContext->rsm->addEnumResult($columnAlias, $fieldMapping->enumType); } - $type = Type::getType($fieldMapping['type']); + $type = Type::getType($fieldMapping->type); $sql = $type->convertToPHPValueSQL($sql, $this->platform); return $sql . ' AS ' . $columnAlias; @@ -1545,7 +1545,7 @@ public function getSelectConditionStatementSQL( $placeholder = '?'; if (isset($this->class->fieldMappings[$field])) { - $type = Type::getType($this->class->fieldMappings[$field]['type']); + $type = Type::getType($this->class->fieldMappings[$field]->type); $placeholder = $type->convertToDatabaseValueSQL($placeholder, $this->platform); } @@ -1608,7 +1608,7 @@ private function getSelectConditionStatementColumnSQL( AssociationMapping|null $assoc = null, ): array { if (isset($this->class->fieldMappings[$field])) { - $className = $this->class->fieldMappings[$field]['inherited'] ?? $this->class->name; + $className = $this->class->fieldMappings[$field]->inherited ?? $this->class->name; return [$this->getSQLTableAlias($className) . '.' . $this->quoteStrategy->getColumnName($field, $this->class, $this->platform)]; } diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index ec8b925b9e5..2824ece4a6f 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -57,8 +57,8 @@ protected function getDiscriminatorColumnTableName(): string */ private function getVersionedClassMetadata(): ClassMetadata { - if (isset($this->class->fieldMappings[$this->class->versionField]['inherited'])) { - $definingClassName = $this->class->fieldMappings[$this->class->versionField]['inherited']; + if (isset($this->class->fieldMappings[$this->class->versionField]->inherited)) { + $definingClassName = $this->class->fieldMappings[$this->class->versionField]->inherited; return $this->em->getClassMetadata($definingClassName); } @@ -78,8 +78,8 @@ public function getOwningTable(string $fieldName): string $cm = match (true) { isset($this->class->associationMappings[$fieldName]['inherited']) => $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']), - isset($this->class->fieldMappings[$fieldName]['inherited']) - => $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]['inherited']), + isset($this->class->fieldMappings[$fieldName]->inherited) + => $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]->inherited), default => $this->class, }; @@ -378,8 +378,8 @@ protected function getSelectColumnsSQL(): string // Add regular columns foreach ($this->class->fieldMappings as $fieldName => $mapping) { - $class = isset($mapping['inherited']) - ? $this->em->getClassMetadata($mapping['inherited']) + $class = isset($mapping->inherited) + ? $this->em->getClassMetadata($mapping->inherited) : $this->class; $columnList[] = $this->getSelectColumnSQL($fieldName, $class); @@ -421,7 +421,7 @@ protected function getSelectColumnsSQL(): string // Add subclass columns foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if (isset($mapping['inherited'])) { + if (isset($mapping->inherited)) { continue; } @@ -464,8 +464,8 @@ protected function getInsertColumnList(): array foreach ($this->class->reflFields as $name => $field) { if ( - isset($this->class->fieldMappings[$name]['inherited']) - && ! isset($this->class->fieldMappings[$name]['id']) + isset($this->class->fieldMappings[$name]->inherited) + && ! isset($this->class->fieldMappings[$name]->id) || isset($this->class->associationMappings[$name]['inherited']) || ($this->class->isVersioned && $this->class->versionField === $name) || isset($this->class->embeddedClasses[$name]) @@ -486,7 +486,7 @@ protected function getInsertColumnList(): array ! $this->class->isIdGeneratorIdentity() || $this->class->identifier[0] !== $name ) { $columns[] = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform); - $this->columnTypes[$name] = $this->class->fieldMappings[$name]['type']; + $this->columnTypes[$name] = $this->class->fieldMappings[$name]->type; } } @@ -506,7 +506,7 @@ protected function assignDefaultVersionAndUpsertableValues(object $entity, array $values = $this->fetchVersionAndNotUpsertableValues($this->getVersionedClassMetadata(), $id); foreach ($values as $field => $value) { - $value = Type::getType($this->class->fieldMappings[$field]['type'])->convertToPHPValue($value, $this->platform); + $value = Type::getType($this->class->fieldMappings[$field]->type)->convertToPHPValue($value, $this->platform); $this->class->setFieldValue($entity, $field, $value); } diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index fe5f50f94c7..0bed1c29ddb 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -58,7 +58,7 @@ protected function getSelectColumnsSQL(): string // Regular columns foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if (isset($mapping['inherited'])) { + if (isset($mapping->inherited)) { continue; } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 7b248d99e20..449a0ff65d0 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -49,7 +49,7 @@ public function getSql(SqlWalker $sqlWalker): string $joinColumn = null; foreach ($assoc['joinColumns'] as $mapping) { - if ($mapping['referencedColumnName'] === $field['columnName']) { + if ($mapping['referencedColumnName'] === $field->columnName) { $joinColumn = $mapping; break; diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php index dd5f3055d58..57d2aec49a7 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -88,7 +88,7 @@ public function __construct(AST\Node $AST, SqlWalker $sqlWalker) $field = $updateItem->pathExpression->field; if ( - (isset($class->fieldMappings[$field]) && ! isset($class->fieldMappings[$field]['inherited'])) || + (isset($class->fieldMappings[$field]) && ! isset($class->fieldMappings[$field]->inherited)) || (isset($class->associationMappings[$field]) && ! isset($class->associationMappings[$field]['inherited'])) ) { $newValue = $updateItem->newValue; diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 92a99ed1624..2f22d385ebe 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -251,9 +251,9 @@ public function generateSelectClause(array $tableAliases = []): string $class = $this->em->getClassMetadata($this->declaringClasses[$columnName]); $fieldName = $this->fieldMappings[$columnName]; $classFieldMapping = $class->fieldMappings[$fieldName]; - $columnSql = $tableAlias . '.' . $classFieldMapping['columnName']; + $columnSql = $tableAlias . '.' . $classFieldMapping->columnName; - $type = Type::getType($classFieldMapping['type']); + $type = Type::getType($classFieldMapping->type); $columnSql = $type->convertToPHPValueSQL($columnSql, $this->em->getConnection()->getDatabasePlatform()); $sql .= $columnSql; diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 5ba0cbacf83..e83ba262865 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -556,9 +556,9 @@ public function walkIdentificationVariable(string $identificationVariable, strin if ( $fieldName !== null && $class->isInheritanceTypeJoined() && - isset($class->fieldMappings[$fieldName]['inherited']) + isset($class->fieldMappings[$fieldName]->inherited) ) { - $class = $this->em->getClassMetadata($class->fieldMappings[$fieldName]['inherited']); + $class = $this->em->getClassMetadata($class->fieldMappings[$fieldName]->inherited); } return $this->getSQLTableAlias($class->getTableName(), $identificationVariable); @@ -1237,10 +1237,10 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias); $fieldMapping = $class->fieldMappings[$fieldName]; $columnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); - $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']); + $columnAlias = $this->getSQLColumnAlias($fieldMapping->columnName); $col = $sqlTableAlias . '.' . $columnName; - $type = Type::getType($fieldMapping['type']); + $type = Type::getType($fieldMapping->type); $col = $type->convertToPHPValueSQL($col, $this->conn->getDatabasePlatform()); $sql .= $col . ' AS ' . $columnAlias; @@ -1248,11 +1248,11 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st $this->scalarResultAliasMap[$resultAlias] = $columnAlias; if (! $hidden) { - $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldMapping['type']); + $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldMapping->type); $this->scalarFields[$dqlAlias][$fieldName] = $columnAlias; - if (! empty($fieldMapping['enumType'])) { - $this->rsm->addEnumResult($columnAlias, $fieldMapping['enumType']); + if (! empty($fieldMapping->enumType)) { + $this->rsm->addEnumResult($columnAlias, $fieldMapping->enumType); } } @@ -1342,17 +1342,17 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st continue; } - $tableName = isset($mapping['inherited']) - ? $this->em->getClassMetadata($mapping['inherited'])->getTableName() + $tableName = isset($mapping->inherited) + ? $this->em->getClassMetadata($mapping->inherited)->getTableName() : $class->getTableName(); $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias); - $columnAlias = $this->getSQLColumnAlias($mapping['columnName']); + $columnAlias = $this->getSQLColumnAlias($mapping->columnName); $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); $col = $sqlTableAlias . '.' . $quotedColumnName; - $type = Type::getType($mapping['type']); + $type = Type::getType($mapping->type); $col = $type->convertToPHPValueSQL($col, $this->platform); $sqlParts[] = $col . ' AS ' . $columnAlias; @@ -1361,8 +1361,8 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $class->name); - if (! empty($mapping['enumType'])) { - $this->rsm->addEnumResult($columnAlias, $mapping['enumType']); + if (! empty($mapping->enumType)) { + $this->rsm->addEnumResult($columnAlias, $mapping->enumType); } } @@ -1376,16 +1376,16 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if (isset($mapping['inherited']) || ($partialFieldSet && ! in_array($fieldName, $partialFieldSet, true))) { + if (isset($mapping->inherited) || ($partialFieldSet && ! in_array($fieldName, $partialFieldSet, true))) { continue; } - $columnAlias = $this->getSQLColumnAlias($mapping['columnName']); + $columnAlias = $this->getSQLColumnAlias($mapping->columnName); $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform); $col = $sqlTableAlias . '.' . $quotedColumnName; - $type = Type::getType($mapping['type']); + $type = Type::getType($mapping->type); $col = $type->convertToPHPValueSQL($col, $this->platform); $sqlParts[] = $col . ' AS ' . $columnAlias; @@ -1487,7 +1487,7 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri $class = $this->getMetadataForDqlAlias($dqlAlias); $fieldName = $e->field; $fieldMapping = $class->fieldMappings[$fieldName]; - $fieldType = $fieldMapping['type']; + $fieldType = $fieldMapping->type; $col = trim($e->dispatch($this)); $type = Type::getType($fieldType); @@ -1495,8 +1495,8 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri $sqlSelectExpressions[] = $col . ' AS ' . $columnAlias; - if (! empty($fieldMapping['enumType'])) { - $this->rsm->addEnumResult($columnAlias, $fieldMapping['enumType']); + if (! empty($fieldMapping->enumType)) { + $this->rsm->addEnumResult($columnAlias, $fieldMapping->enumType); } break; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index c6826b54739..c7ffd4d8dd1 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -413,10 +413,10 @@ private function generateSqlAliasReplacements(): array // Get the SQL table alias for the entity and field $sqlTableAliasForFieldAlias = $aliasMap[$dqlAliasForFieldAlias]; - if (isset($fieldMapping['declared']) && $fieldMapping['declared'] !== $class->name) { + if (isset($fieldMapping->declared) && $fieldMapping->declared !== $class->name) { // Field was declared in a parent class, so we need to get the proper SQL table alias // for the joined parent table. - $otherClassMetadata = $this->em->getClassMetadata($fieldMapping['declared']); + $otherClassMetadata = $this->em->getClassMetadata($fieldMapping->declared); if (! $otherClassMetadata->isMappedSuperclass) { $sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias); diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index 0eaad9f17c5..a05c16cb6c1 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -49,7 +49,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): void $this->_getQuery()->setHint( self::IDENTIFIER_TYPE, - Type::getType($rootClass->fieldMappings[$identifier]['type']), + Type::getType($rootClass->fieldMappings[$identifier]->type), ); $this->_getQuery()->setHint(self::FORCE_DBAL_TYPE_CONVERSION, true); diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 467d8494d64..e7a29ea16b9 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -212,7 +212,7 @@ public function getSchemaFromMetadata(array $classes): Schema } elseif ($class->isInheritanceTypeJoined()) { // Add all non-inherited fields as columns foreach ($class->fieldMappings as $fieldName => $mapping) { - if (! isset($mapping['inherited'])) { + if (! isset($mapping->inherited)) { $this->gatherColumn($class, $mapping, $table); } } @@ -228,7 +228,7 @@ public function getSchemaFromMetadata(array $classes): Schema $inheritedKeyColumns = []; foreach ($class->identifier as $identifierField) { - if (isset($class->fieldMappings[$identifierField]['inherited'])) { + if (isset($class->fieldMappings[$identifierField]->inherited)) { $idMapping = $class->fieldMappings[$identifierField]; $this->gatherColumn($class, $idMapping, $table); $columnName = $this->quoteStrategy->getColumnName( @@ -436,14 +436,14 @@ private function gatherColumns(ClassMetadata $class, Table $table): void $pkColumns = []; foreach ($class->fieldMappings as $mapping) { - if ($class->isInheritanceTypeSingleTable() && isset($mapping['inherited'])) { + if ($class->isInheritanceTypeSingleTable() && isset($mapping->inherited)) { continue; } $this->gatherColumn($class, $mapping, $table); - if ($class->isIdentifier($mapping['fieldName'])) { - $pkColumns[] = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); + if ($class->isIdentifier($mapping->fieldName)) { + $pkColumns[] = $this->quoteStrategy->getColumnName($mapping->fieldName, $class, $this->platform); } } } @@ -459,43 +459,43 @@ private function gatherColumn( FieldMapping $mapping, Table $table, ): void { - $columnName = $this->quoteStrategy->getColumnName($mapping['fieldName'], $class, $this->platform); - $columnType = $mapping['type']; + $columnName = $this->quoteStrategy->getColumnName($mapping->fieldName, $class, $this->platform); + $columnType = $mapping->type; $options = []; - $options['length'] = $mapping['length'] ?? null; - $options['notnull'] = isset($mapping['nullable']) ? ! $mapping['nullable'] : true; + $options['length'] = $mapping->length ?? null; + $options['notnull'] = isset($mapping->nullable) ? ! $mapping->nullable : true; if ($class->isInheritanceTypeSingleTable() && $class->parentClasses) { $options['notnull'] = false; } $options['platformOptions'] = []; - $options['platformOptions']['version'] = $class->isVersioned && $class->versionField === $mapping['fieldName']; + $options['platformOptions']['version'] = $class->isVersioned && $class->versionField === $mapping->fieldName; if (strtolower($columnType) === 'string' && $options['length'] === null) { $options['length'] = 255; } - if (isset($mapping['precision'])) { - $options['precision'] = $mapping['precision']; + if (isset($mapping->precision)) { + $options['precision'] = $mapping->precision; } - if (isset($mapping['scale'])) { - $options['scale'] = $mapping['scale']; + if (isset($mapping->scale)) { + $options['scale'] = $mapping->scale; } - if (isset($mapping['default'])) { - $options['default'] = $mapping['default']; + if (isset($mapping->default)) { + $options['default'] = $mapping->default; } - if (isset($mapping['columnDefinition'])) { - $options['columnDefinition'] = $mapping['columnDefinition']; + if (isset($mapping->columnDefinition)) { + $options['columnDefinition'] = $mapping->columnDefinition; } // the 'default' option can be overwritten here $options = $this->gatherColumnOptions($mapping) + $options; - if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() === [$mapping['fieldName']]) { + if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() === [$mapping->fieldName]) { $options['autoincrement'] = true; } @@ -510,7 +510,7 @@ private function gatherColumn( $table->addColumn($columnName, $columnType, $options); } - $isUnique = $mapping['unique'] ?? false; + $isUnique = $mapping->unique ?? false; if ($isUnique) { $table->addUniqueIndex([$columnName]); } @@ -698,8 +698,8 @@ private function gatherRelationJoinColumns( if (isset($joinColumn['columnDefinition'])) { $columnOptions['columnDefinition'] = $joinColumn['columnDefinition']; - } elseif (isset($fieldMapping['columnDefinition'])) { - $columnOptions['columnDefinition'] = $fieldMapping['columnDefinition']; + } elseif (isset($fieldMapping->columnDefinition)) { + $columnOptions['columnDefinition'] = $fieldMapping->columnDefinition; } if (isset($joinColumn['nullable'])) { @@ -708,18 +708,18 @@ private function gatherRelationJoinColumns( $columnOptions += $this->gatherColumnOptions($fieldMapping); - if (isset($fieldMapping['length'])) { - $columnOptions['length'] = $fieldMapping['length']; + if (isset($fieldMapping->length)) { + $columnOptions['length'] = $fieldMapping->length; } - if ($fieldMapping['type'] === 'decimal') { - $columnOptions['scale'] = $fieldMapping['scale']; - $columnOptions['precision'] = $fieldMapping['precision']; + if ($fieldMapping->type === 'decimal') { + $columnOptions['scale'] = $fieldMapping->scale; + $columnOptions['precision'] = $fieldMapping->precision; } $columnOptions = $this->gatherColumnOptions($joinColumn) + $columnOptions; - $theJoinTable->addColumn($quotedColumnName, $fieldMapping['type'], $columnOptions); + $theJoinTable->addColumn($quotedColumnName, $fieldMapping->type, $columnOptions); } if (isset($joinColumn['unique']) && $joinColumn['unique'] === true) { @@ -769,10 +769,10 @@ private function gatherRelationJoinColumns( /** @return mixed[] */ private function gatherColumnOptions(JoinColumnMapping|FieldMapping|DiscriminatorColumnMapping $mapping): array { - $mappingOptions = $mapping['options'] ?? []; + $mappingOptions = $mapping->options ?? []; - if (isset($mapping['enumType'])) { - $mappingOptions['enumType'] = $mapping['enumType']; + if (isset($mapping->enumType)) { + $mappingOptions['enumType'] = $mapping->enumType; } if (($mappingOptions['default'] ?? null) instanceof BackedEnum) { diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index a199dfb0586..5aaeec50053 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -69,8 +69,8 @@ public function validateClass(ClassMetadata $class): array $cmf = $this->em->getMetadataFactory(); foreach ($class->fieldMappings as $fieldName => $mapping) { - if (! Type::hasType($mapping['type'])) { - $ce[] = "The field '" . $class->name . '#' . $fieldName . "' uses a non-existent type '" . $mapping['type'] . "'."; + if (! Type::hasType($mapping->type)) { + $ce[] = "The field '" . $class->name . '#' . $fieldName . "' uses a non-existent type '" . $mapping->type . "'."; } } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index f72091739de..678905113a9 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -635,7 +635,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void $orgValue = $originalData[$propName]; - if (! empty($class->fieldMappings[$propName]['enumType'])) { + if (! empty($class->fieldMappings[$propName]->enumType)) { if (is_array($orgValue)) { foreach ($orgValue as $id => $val) { if ($val instanceof BackedEnum) { diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index 0ea927877b6..63109330688 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -63,7 +63,7 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, $fieldName = $class->fieldNames[$columnName]; if (isset($class->fieldMappings[$fieldName])) { - return $class->fieldMappings[$fieldName]['type']; + return $class->fieldMappings[$fieldName]->type; } } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 091daee6fcd..afe23fc2fc9 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -334,7 +334,6 @@ - getProperty diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index 66a1a3ab146..349ba14c69d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -66,16 +66,16 @@ public function testLoadMetadataFromDatabase(): void $metadata = $metadatas['DbdriverFoo']; self::assertArrayHasKey('id', $metadata->fieldMappings); - self::assertEquals('id', $metadata->fieldMappings['id']['fieldName']); - self::assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); - self::assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); + self::assertEquals('id', $metadata->fieldMappings['id']->fieldName); + self::assertEquals('id', strtolower($metadata->fieldMappings['id']->columnName)); + self::assertEquals('integer', (string) $metadata->fieldMappings['id']->type); self::assertArrayHasKey('bar', $metadata->fieldMappings); - self::assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']); - self::assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName'])); - self::assertEquals('string', (string) $metadata->fieldMappings['bar']['type']); - self::assertEquals(200, $metadata->fieldMappings['bar']['length']); - self::assertTrue($metadata->fieldMappings['bar']['nullable']); + self::assertEquals('bar', $metadata->fieldMappings['bar']->fieldName); + self::assertEquals('bar', strtolower($metadata->fieldMappings['bar']->columnName)); + self::assertEquals('string', (string) $metadata->fieldMappings['bar']->type); + self::assertEquals(200, $metadata->fieldMappings['bar']->length); + self::assertTrue($metadata->fieldMappings['bar']->nullable); } public function testLoadMetadataWithForeignKeyFromDatabase(): void @@ -172,24 +172,24 @@ public function testLoadMetadataFromDatabaseDetail(): void $metadata = $metadatas['DbdriverFoo']; self::assertArrayHasKey('id', $metadata->fieldMappings); - self::assertEquals('id', $metadata->fieldMappings['id']['fieldName']); - self::assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); - self::assertEquals('integer', (string) $metadata->fieldMappings['id']['type']); + self::assertEquals('id', $metadata->fieldMappings['id']->fieldName); + self::assertEquals('id', strtolower($metadata->fieldMappings['id']->columnName)); + self::assertEquals('integer', (string) $metadata->fieldMappings['id']->type); if (self::supportsUnsignedInteger($this->_em->getConnection()->getDatabasePlatform())) { self::assertArrayHasKey('columnUnsigned', $metadata->fieldMappings); - self::assertTrue($metadata->fieldMappings['columnUnsigned']['options']['unsigned']); + self::assertTrue($metadata->fieldMappings['columnUnsigned']->options['unsigned']); } self::assertArrayHasKey('columnComment', $metadata->fieldMappings); - self::assertEquals('test_comment', $metadata->fieldMappings['columnComment']['options']['comment']); + self::assertEquals('test_comment', $metadata->fieldMappings['columnComment']->options['comment']); self::assertArrayHasKey('columnDefault', $metadata->fieldMappings); - self::assertEquals('test_default', $metadata->fieldMappings['columnDefault']['options']['default']); + self::assertEquals('test_default', $metadata->fieldMappings['columnDefault']->options['default']); self::assertArrayHasKey('columnDecimal', $metadata->fieldMappings); - self::assertEquals(4, $metadata->fieldMappings['columnDecimal']['precision']); - self::assertEquals(3, $metadata->fieldMappings['columnDecimal']['scale']); + self::assertEquals(4, $metadata->fieldMappings['columnDecimal']->precision); + self::assertEquals(3, $metadata->fieldMappings['columnDecimal']->scale); self::assertNotEmpty($metadata->table['indexes']['index1']['columns']); self::assertEquals( diff --git a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php index cc2dc2b8f1e..57cdc07baea 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php @@ -359,8 +359,8 @@ public function testEnumWithNonMatchingDatabaseValueThrowsException(string $card $metadata = $this->_em->getClassMetadata($cardClass); $this->_em->getConnection()->update( $metadata->table['name'], - [$metadata->fieldMappings['suit']['columnName'] => 'invalid'], - [$metadata->fieldMappings['id']['columnName'] => $card->id], + [$metadata->fieldMappings['suit']->columnName => 'invalid'], + [$metadata->fieldMappings['id']->columnName => $card->id], ); $this->expectException(MappingException::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 88baac0df93..885ecafbc4f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -82,8 +82,8 @@ public function testGetMetadataForSubclassWithMappedSuperclass(): void self::assertArrayHasKey('id', $class->fieldMappings); self::assertArrayHasKey('name', $class->fieldMappings); - self::assertArrayNotHasKey('inherited', $class->fieldMappings['mapped1']); - self::assertArrayNotHasKey('inherited', $class->fieldMappings['mapped2']); + self::assertNull($class->fieldMappings['mapped1']->inherited); + self::assertNull($class->fieldMappings['mapped2']->inherited); self::assertArrayNotHasKey('transient', $class->fieldMappings); self::assertArrayHasKey('mappedRelated1', $class->associationMappings); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 5644da253f9..487c67c578d 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -228,9 +228,9 @@ public function testAddField(): void { $this->assertIsFluent($this->builder->addField('name', 'string')); $mapping = $this->cm->getFieldMapping('name'); - self::assertSame('name', $mapping['fieldName']); - self::assertSame('name', $mapping['columnName']); - self::assertSame('string', $mapping['type']); + self::assertSame('name', $mapping->fieldName); + self::assertSame('name', $mapping->columnName); + self::assertSame('string', $mapping->type); } public function testCreateField(): void @@ -241,9 +241,9 @@ public function testCreateField(): void self::assertFalse(isset($this->cm->fieldMappings['name'])); $this->assertIsFluent($fieldBuilder->build()); $mapping = $this->cm->getFieldMapping('name'); - self::assertSame('name', $mapping['fieldName']); - self::assertSame('name', $mapping['columnName']); - self::assertSame('string', $mapping['type']); + self::assertSame('name', $mapping->fieldName); + self::assertSame('name', $mapping->columnName); + self::assertSame('string', $mapping->type); } public function testCreateVersionedField(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 785b6080dad..ec05d62d12a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -300,8 +300,8 @@ public function testQuoteMetadata(): void $addressMetadata = $cmf->getMetadataFor(Address::class); // Phone Class Metadata - self::assertTrue($phoneMetadata->fieldMappings['number']['quoted']); - self::assertEquals('phone-number', $phoneMetadata->fieldMappings['number']['columnName']); + self::assertTrue($phoneMetadata->fieldMappings['number']->quoted); + self::assertEquals('phone-number', $phoneMetadata->fieldMappings['number']->columnName); $user = $phoneMetadata->associationMappings['user']; self::assertTrue($user['joinColumns'][0]['quoted']); @@ -309,11 +309,11 @@ public function testQuoteMetadata(): void self::assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); // User Group Metadata - self::assertTrue($groupMetadata->fieldMappings['id']['quoted']); - self::assertTrue($groupMetadata->fieldMappings['name']['quoted']); + self::assertTrue($groupMetadata->fieldMappings['id']->quoted); + self::assertTrue($groupMetadata->fieldMappings['name']->quoted); - self::assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); - self::assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); + self::assertEquals('user-id', $userMetadata->fieldMappings['id']->columnName); + self::assertEquals('user-name', $userMetadata->fieldMappings['name']->columnName); $user = $groupMetadata->associationMappings['parent']; self::assertTrue($user['joinColumns'][0]['quoted']); @@ -321,11 +321,11 @@ public function testQuoteMetadata(): void self::assertEquals('group-id', $user['joinColumns'][0]['referencedColumnName']); // Address Class Metadata - self::assertTrue($addressMetadata->fieldMappings['id']['quoted']); - self::assertTrue($addressMetadata->fieldMappings['zip']['quoted']); + self::assertTrue($addressMetadata->fieldMappings['id']->quoted); + self::assertTrue($addressMetadata->fieldMappings['zip']->quoted); - self::assertEquals('address-id', $addressMetadata->fieldMappings['id']['columnName']); - self::assertEquals('address-zip', $addressMetadata->fieldMappings['zip']['columnName']); + self::assertEquals('address-id', $addressMetadata->fieldMappings['id']->columnName); + self::assertEquals('address-zip', $addressMetadata->fieldMappings['zip']->columnName); $user = $addressMetadata->associationMappings['user']; self::assertTrue($user['joinColumns'][0]['quoted']); @@ -333,11 +333,11 @@ public function testQuoteMetadata(): void self::assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); // User Class Metadata - self::assertTrue($userMetadata->fieldMappings['id']['quoted']); - self::assertTrue($userMetadata->fieldMappings['name']['quoted']); + self::assertTrue($userMetadata->fieldMappings['id']->quoted); + self::assertTrue($userMetadata->fieldMappings['name']->quoted); - self::assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']); - self::assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']); + self::assertEquals('user-id', $userMetadata->fieldMappings['id']->columnName); + self::assertEquals('user-name', $userMetadata->fieldMappings['name']->columnName); $address = $userMetadata->associationMappings['address']; self::assertTrue($address['joinColumns'][0]['quoted']); diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 03466196df4..989bc16e4af 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -242,15 +242,15 @@ public function testVersionedField(ClassMetadata $class): void self::assertTrue($class->isVersioned); self::assertEquals('version', $class->versionField); - self::assertFalse(isset($class->fieldMappings['version']['version'])); + self::assertFalse(isset($class->fieldMappings['version']->version)); } #[Depends('testEntityTableNameAndInheritance')] public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadata { - self::assertEquals('id', $class->fieldMappings['id']['columnName']); - self::assertEquals('name', $class->fieldMappings['name']['columnName']); - self::assertEquals('user_email', $class->fieldMappings['email']['columnName']); + self::assertEquals('id', $class->fieldMappings['id']->columnName); + self::assertEquals('name', $class->fieldMappings['name']->columnName); + self::assertEquals('user_email', $class->fieldMappings['email']->columnName); return $class; } @@ -258,10 +258,10 @@ public function testFieldMappingsColumnNames(ClassMetadata $class): ClassMetadat #[Depends('testEntityTableNameAndInheritance')] public function testStringFieldMappings(ClassMetadata $class): ClassMetadata { - self::assertEquals('string', $class->fieldMappings['name']['type']); - self::assertEquals(50, $class->fieldMappings['name']['length']); - self::assertTrue($class->fieldMappings['name']['nullable']); - self::assertTrue($class->fieldMappings['name']['unique']); + self::assertEquals('string', $class->fieldMappings['name']->type); + self::assertEquals(50, $class->fieldMappings['name']->length); + self::assertTrue($class->fieldMappings['name']->nullable); + self::assertTrue($class->fieldMappings['name']->unique); return $class; } @@ -306,7 +306,7 @@ public function testCustomFieldTypeFromReflection(): void public function testFieldOptions(ClassMetadata $class): ClassMetadata { $expected = ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false]; - self::assertEquals($expected, $class->fieldMappings['name']['options']); + self::assertEquals($expected, $class->fieldMappings['name']->options); return $class; } @@ -314,7 +314,7 @@ public function testFieldOptions(ClassMetadata $class): ClassMetadata #[Depends('testEntityTableNameAndInheritance')] public function testIdFieldOptions(ClassMetadata $class): ClassMetadata { - self::assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']['options']); + self::assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']->options); return $class; } @@ -323,7 +323,7 @@ public function testIdFieldOptions(ClassMetadata $class): ClassMetadata public function testIdentifier(ClassMetadata $class): ClassMetadata { self::assertEquals(['id'], $class->identifier); - self::assertEquals('integer', $class->fieldMappings['id']['type']); + self::assertEquals('integer', $class->fieldMappings['id']->type); self::assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, 'ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO'); return $class; @@ -334,11 +334,11 @@ public function testBooleanValuesForOptionIsSetCorrectly(): ClassMetadata { $class = $this->createClassMetadata(User::class); - self::assertIsBool($class->fieldMappings['id']['options']['unsigned']); - self::assertFalse($class->fieldMappings['id']['options']['unsigned']); + self::assertIsBool($class->fieldMappings['id']->options['unsigned']); + self::assertFalse($class->fieldMappings['id']->options['unsigned']); - self::assertIsBool($class->fieldMappings['name']['options']['fixed']); - self::assertFalse($class->fieldMappings['name']['options']['fixed']); + self::assertIsBool($class->fieldMappings['name']->options['fixed']); + self::assertFalse($class->fieldMappings['name']->options['fixed']); return $class; } @@ -434,7 +434,7 @@ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMeta #[Depends('testJoinColumnUniqueAndNullable')] public function testColumnDefinition(ClassMetadata $class): ClassMetadata { - self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); + self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']->columnDefinition); self::assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); return $class; @@ -504,23 +504,14 @@ public function testDefaultFieldType(): void self::assertArrayHasKey('id', $class->fieldMappings); self::assertArrayHasKey('name', $class->fieldMappings); - self::assertArrayHasKey('type', $class->fieldMappings['id']); - self::assertArrayHasKey('type', $class->fieldMappings['name']); + self::assertEquals('string', $class->fieldMappings['id']->type); + self::assertEquals('string', $class->fieldMappings['name']->type); - self::assertEquals('string', $class->fieldMappings['id']['type']); - self::assertEquals('string', $class->fieldMappings['name']['type']); + self::assertEquals('id', $class->fieldMappings['id']->fieldName); + self::assertEquals('name', $class->fieldMappings['name']->fieldName); - self::assertArrayHasKey('fieldName', $class->fieldMappings['id']); - self::assertArrayHasKey('fieldName', $class->fieldMappings['name']); - - self::assertEquals('id', $class->fieldMappings['id']['fieldName']); - self::assertEquals('name', $class->fieldMappings['name']['fieldName']); - - self::assertArrayHasKey('columnName', $class->fieldMappings['id']); - self::assertArrayHasKey('columnName', $class->fieldMappings['name']); - - self::assertEquals('id', $class->fieldMappings['id']['columnName']); - self::assertEquals('name', $class->fieldMappings['name']['columnName']); + self::assertEquals('id', $class->fieldMappings['id']->columnName); + self::assertEquals('name', $class->fieldMappings['name']->columnName); self::assertEquals(ClassMetadata::GENERATOR_TYPE_NONE, $class->generatorType); } @@ -533,11 +524,8 @@ public function testIdentifierColumnDefinition(): void self::assertArrayHasKey('id', $class->fieldMappings); self::assertArrayHasKey('value', $class->fieldMappings); - self::assertArrayHasKey('columnDefinition', $class->fieldMappings['id']); - self::assertArrayHasKey('columnDefinition', $class->fieldMappings['value']); - - self::assertEquals('int unsigned not null', strtolower($class->fieldMappings['id']['columnDefinition'])); - self::assertEquals('varchar(255) not null', strtolower($class->fieldMappings['value']['columnDefinition'])); + self::assertEquals('int unsigned not null', strtolower($class->fieldMappings['id']->columnDefinition)); + self::assertEquals('varchar(255) not null', strtolower($class->fieldMappings['value']->columnDefinition)); } #[\PHPUnit\Framework\Attributes\Group('DDC-559')] @@ -713,31 +701,31 @@ public function testAttributeOverridesMapping(): void $guestMetadata = $factory->getMetadataFor(DDC964Guest::class); $adminMetadata = $factory->getMetadataFor(DDC964Admin::class); - self::assertTrue($adminMetadata->fieldMappings['id']['id']); - self::assertEquals('id', $adminMetadata->fieldMappings['id']['fieldName']); - self::assertEquals('user_id', $adminMetadata->fieldMappings['id']['columnName']); + self::assertTrue($adminMetadata->fieldMappings['id']->id); + self::assertEquals('id', $adminMetadata->fieldMappings['id']->fieldName); + self::assertEquals('user_id', $adminMetadata->fieldMappings['id']->columnName); self::assertEquals(['user_id' => 'id', 'user_name' => 'name'], $adminMetadata->fieldNames); self::assertEquals(['id' => 'user_id', 'name' => 'user_name'], $adminMetadata->columnNames); - self::assertEquals(150, $adminMetadata->fieldMappings['id']['length']); + self::assertEquals(150, $adminMetadata->fieldMappings['id']->length); - self::assertEquals('name', $adminMetadata->fieldMappings['name']['fieldName']); - self::assertEquals('user_name', $adminMetadata->fieldMappings['name']['columnName']); - self::assertEquals(250, $adminMetadata->fieldMappings['name']['length']); - self::assertTrue($adminMetadata->fieldMappings['name']['nullable']); - self::assertFalse($adminMetadata->fieldMappings['name']['unique']); + self::assertEquals('name', $adminMetadata->fieldMappings['name']->fieldName); + self::assertEquals('user_name', $adminMetadata->fieldMappings['name']->columnName); + self::assertEquals(250, $adminMetadata->fieldMappings['name']->length); + self::assertTrue($adminMetadata->fieldMappings['name']->nullable); + self::assertFalse($adminMetadata->fieldMappings['name']->unique); - self::assertTrue($guestMetadata->fieldMappings['id']['id']); - self::assertEquals('guest_id', $guestMetadata->fieldMappings['id']['columnName']); - self::assertEquals('id', $guestMetadata->fieldMappings['id']['fieldName']); + self::assertTrue($guestMetadata->fieldMappings['id']->id); + self::assertEquals('guest_id', $guestMetadata->fieldMappings['id']->columnName); + self::assertEquals('id', $guestMetadata->fieldMappings['id']->fieldName); self::assertEquals(['guest_id' => 'id', 'guest_name' => 'name'], $guestMetadata->fieldNames); self::assertEquals(['id' => 'guest_id', 'name' => 'guest_name'], $guestMetadata->columnNames); - self::assertEquals(140, $guestMetadata->fieldMappings['id']['length']); + self::assertEquals(140, $guestMetadata->fieldMappings['id']->length); - self::assertEquals('name', $guestMetadata->fieldMappings['name']['fieldName']); - self::assertEquals('guest_name', $guestMetadata->fieldMappings['name']['columnName']); - self::assertEquals(240, $guestMetadata->fieldMappings['name']['length']); - self::assertFalse($guestMetadata->fieldMappings['name']['nullable']); - self::assertTrue($guestMetadata->fieldMappings['name']['unique']); + self::assertEquals('name', $guestMetadata->fieldMappings['name']->fieldName); + self::assertEquals('guest_name', $guestMetadata->fieldMappings['name']->columnName); + self::assertEquals(240, $guestMetadata->fieldMappings['name']->length); + self::assertFalse($guestMetadata->fieldMappings['name']->nullable); + self::assertTrue($guestMetadata->fieldMappings['name']->unique); } #[\PHPUnit\Framework\Attributes\Group('DDC-1955')] @@ -947,7 +935,7 @@ public function testReservedWordInTableColumn(): void { $metadata = $this->createClassMetadata(ReservedWordInTableColumn::class); - self::assertSame('count', $metadata->getFieldMapping('count')['columnName']); + self::assertSame('count', $metadata->getFieldMapping('count')->columnName); } public function testInsertableColumn(): void @@ -956,10 +944,8 @@ public function testInsertableColumn(): void $mapping = $metadata->getFieldMapping('nonInsertableContent'); - self::assertArrayHasKey('notInsertable', $mapping); - self::assertArrayHasKey('generated', $mapping); - self::assertSame(ClassMetadata::GENERATED_INSERT, $mapping['generated']); - self::assertArrayNotHasKey('notInsertable', $metadata->getFieldMapping('insertableContent')); + self::assertSame(ClassMetadata::GENERATED_INSERT, $mapping->generated); + self::assertNull($metadata->getFieldMapping('insertableContent')->notInsertable); } public function testUpdatableColumn(): void @@ -968,10 +954,8 @@ public function testUpdatableColumn(): void $mapping = $metadata->getFieldMapping('nonUpdatableContent'); - self::assertArrayHasKey('notUpdatable', $mapping); - self::assertArrayHasKey('generated', $mapping); - self::assertSame(ClassMetadata::GENERATED_ALWAYS, $mapping['generated']); - self::assertArrayNotHasKey('notUpdatable', $metadata->getFieldMapping('updatableContent')); + self::assertSame(ClassMetadata::GENERATED_ALWAYS, $mapping->generated); + self::assertNull($metadata->getFieldMapping('updatableContent')->notUpdatable); } #[RequiresPhp('8.1')] @@ -979,7 +963,7 @@ public function testEnumType(): void { $metadata = $this->createClassMetadata(Card::class); - self::assertEquals(Suit::class, $metadata->fieldMappings['suit']['enumType']); + self::assertEquals(Suit::class, $metadata->fieldMappings['suit']->enumType); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index c951f7316c0..e3c85b881a2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -95,9 +95,9 @@ public function testPassColumnDefinitionToJoinColumn(): void $em = $this->getTestEntityManager(); $schemaTool = new SchemaTool($em); - $avatar = $em->getClassMetadata(ForumAvatar::class); - $avatar->fieldMappings['id']['columnDefinition'] = $customColumnDef; - $user = $em->getClassMetadata(ForumUser::class); + $avatar = $em->getClassMetadata(ForumAvatar::class); + $avatar->fieldMappings['id']->columnDefinition = $customColumnDef; + $user = $em->getClassMetadata(ForumUser::class); $classes = [$avatar, $user]; From 7df7503af6c041a773acb98c731a38a1256b9398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 11 Apr 2023 16:44:16 +0200 Subject: [PATCH 243/475] Migrate to DiscriminatorColumnMapping's object API Its array access implementation should stay for external consumers, but should be deprecated as of Doctrine 3.1.0 --- .../Hydration/SimpleObjectHydrator.php | 2 +- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 2 +- .../AbstractEntityInheritancePersister.php | 6 ++--- .../Entity/JoinedSubclassPersister.php | 4 +-- .../Entity/SingleTablePersister.php | 6 ++--- lib/Doctrine/ORM/Query/SqlWalker.php | 14 +++++----- lib/Doctrine/ORM/Tools/SchemaTool.php | 17 +++++------- .../ORM/Mapping/MappingDriverTestCase.php | 26 +++++++------------ 8 files changed, 34 insertions(+), 43 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 0c1e32aa149..6ccd3a35aad 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -77,7 +77,7 @@ protected function hydrateRowData(array $row, array &$result): void // We need to find the correct entity class name if we have inheritance in resultset if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { $discrColumn = $this->class->getDiscriminatorColumn(); - $discrColumnName = $this->getSQLResultCasing($this->platform, $discrColumn['name']); + $discrColumnName = $this->getSQLResultCasing($this->platform, $discrColumn->name); // Find mapped discriminator column from the result set. $metaMappingDiscrColumnName = array_search($discrColumnName, $this->resultSetMapping()->metaMappings, true); diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 8a1635be326..1ffeaa30cda 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1204,7 +1204,7 @@ protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping $this->columnNames[$mapping->fieldName] = $mapping->columnName; - if (isset($this->fieldNames[$mapping->columnName]) || ($this->discriminatorColumn && $this->discriminatorColumn['name'] === $mapping->columnName)) { + if (isset($this->fieldNames[$mapping->columnName]) || ($this->discriminatorColumn && $this->discriminatorColumn->name === $mapping->columnName)) { throw MappingException::duplicateColumnName($this->name, $mapping->columnName); } diff --git a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php index 62b75dbde33..64a5020277d 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php @@ -24,9 +24,9 @@ protected function prepareInsertData(object $entity): array $data = parent::prepareInsertData($entity); // Populate the discriminator column - $discColumn = $this->class->getDiscriminatorColumn(); - $this->columnTypes[$discColumn['name']] = $discColumn['type']; - $data[$this->getDiscriminatorColumnTableName()][$discColumn['name']] = $this->class->discriminatorValue; + $discColumn = $this->class->getDiscriminatorColumn(); + $this->columnTypes[$discColumn->name] = $discColumn->type; + $data[$this->getDiscriminatorColumnTableName()][$discColumn->name] = $this->class->discriminatorValue; return $data; } diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 2824ece4a6f..34f051eb83f 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -367,8 +367,8 @@ protected function getSelectColumnsSQL(): string $columnList = []; $discrColumn = $this->class->getDiscriminatorColumn(); - $discrColumnName = $discrColumn['name']; - $discrColumnType = $discrColumn['type']; + $discrColumnName = $discrColumn->name; + $discrColumnType = $discrColumn->type; $baseTableAlias = $this->getSQLTableAlias($this->class->name); $resultColumnName = $this->getSQLResultCasing($this->platform, $discrColumnName); diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index 0bed1c29ddb..3eeb4f0f592 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -42,8 +42,8 @@ protected function getSelectColumnsSQL(): string // Append discriminator column $discrColumn = $this->class->getDiscriminatorColumn(); - $discrColumnName = $discrColumn['name']; - $discrColumnType = $discrColumn['type']; + $discrColumnName = $discrColumn->name; + $discrColumnType = $discrColumn->type; $columnList[] = $tableAlias . '.' . $discrColumnName; @@ -146,7 +146,7 @@ protected function getSelectConditionDiscriminatorValueSQL(): string $values[] = $this->conn->quote((string) $discrValues[$subclassName]); } - $discColumnName = $this->class->getDiscriminatorColumn()['name']; + $discColumnName = $this->class->getDiscriminatorColumn()->name; $values = implode(', ', $values); $tableAlias = $this->getSQLTableAlias($this->class->name); diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index e83ba262865..b859d894945 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -399,7 +399,7 @@ private function generateDiscriminatorColumnConditionSQL(array $dqlAliases): str ? $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.' : ''; - $sqlParts[] = $sqlTableAlias . $class->getDiscriminatorColumn()['name'] . ' IN (' . implode(', ', $values) . ')'; + $sqlParts[] = $sqlTableAlias . $class->getDiscriminatorColumn()->name . ' IN (' . implode(', ', $values) . ')'; } $sql = implode(' AND ', $sqlParts); @@ -663,14 +663,14 @@ public function walkSelectClause(AST\SelectClause $selectClause): string $rootClass = $this->em->getClassMetadata($class->rootEntityName); $tblAlias = $this->getSQLTableAlias($rootClass->getTableName(), $dqlAlias); $discrColumn = $rootClass->getDiscriminatorColumn(); - $columnAlias = $this->getSQLColumnAlias($discrColumn['name']); + $columnAlias = $this->getSQLColumnAlias($discrColumn->name); - $sqlSelectExpressions[] = $tblAlias . '.' . $discrColumn['name'] . ' AS ' . $columnAlias; + $sqlSelectExpressions[] = $tblAlias . '.' . $discrColumn->name . ' AS ' . $columnAlias; $this->rsm->setDiscriminatorColumn($dqlAlias, $columnAlias); - $this->rsm->addMetaResult($dqlAlias, $columnAlias, $discrColumn['fieldName'], false, $discrColumn['type']); - if (! empty($discrColumn['enumType'])) { - $this->rsm->addEnumResult($columnAlias, $discrColumn['enumType']); + $this->rsm->addMetaResult($dqlAlias, $columnAlias, $discrColumn->fieldName, false, $discrColumn->type); + if (! empty($discrColumn->enumType)) { + $this->rsm->addEnumResult($columnAlias, $discrColumn->enumType); } } @@ -1994,7 +1994,7 @@ public function walkInstanceOfExpression(AST\InstanceOfExpression $instanceOfExp $sql .= $this->getSQLTableAlias($discrClass->getTableName(), $dqlAlias) . '.'; } - $sql .= $class->getDiscriminatorColumn()['name'] . ($instanceOfExpr->not ? ' NOT IN ' : ' IN '); + $sql .= $class->getDiscriminatorColumn()->name . ($instanceOfExpr->not ? ' NOT IN ' : ' IN '); $sql .= $this->getChildDiscriminatorsFromClassMetadata($discrClass, $instanceOfExpr); return $sql; diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index e7a29ea16b9..c25c02bed51 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -406,25 +406,22 @@ private function addDiscriminatorColumnDefinition(ClassMetadata $class, Table $t $discrColumn = $class->discriminatorColumn; assert($discrColumn !== null); - if ( - ! isset($discrColumn['type']) || - (strtolower($discrColumn['type']) === 'string' && ! isset($discrColumn['length'])) - ) { - $discrColumn['type'] = 'string'; - $discrColumn['length'] = 255; + if (strtolower($discrColumn->type) === 'string' && ! isset($discrColumn->length)) { + $discrColumn->type = 'string'; + $discrColumn->length = 255; } $options = [ - 'length' => $discrColumn['length'] ?? null, + 'length' => $discrColumn->length ?? null, 'notnull' => true, ]; - if (isset($discrColumn['columnDefinition'])) { - $options['columnDefinition'] = $discrColumn['columnDefinition']; + if (isset($discrColumn->columnDefinition)) { + $options['columnDefinition'] = $discrColumn->columnDefinition; } $options = $this->gatherColumnOptions($discrColumn) + $options; - $table->addColumn($discrColumn['name'], $discrColumn['type'], $options); + $table->addColumn($discrColumn->name, $discrColumn->type, $options); } /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 989bc16e4af..71e0acee8c9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -551,11 +551,8 @@ public function testDiscriminatorColumnDefinition(): void { $class = $this->createClassMetadata(DDC807Entity::class); - self::assertArrayHasKey('columnDefinition', $class->discriminatorColumn); - self::assertArrayHasKey('name', $class->discriminatorColumn); - - self::assertEquals("ENUM('ONE','TWO')", $class->discriminatorColumn['columnDefinition']); - self::assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals("ENUM('ONE','TWO')", $class->discriminatorColumn->columnDefinition); + self::assertEquals('dtype', $class->discriminatorColumn->name); } #[\PHPUnit\Framework\Attributes\Group('GH10288')] @@ -563,11 +560,8 @@ public function testDiscriminatorColumnEnumTypeDefinition(): void { $class = $this->createClassMetadata(GH10288EnumTypePerson::class); - self::assertArrayHasKey('enumType', $class->discriminatorColumn); - self::assertArrayHasKey('name', $class->discriminatorColumn); - - self::assertEquals(GH10288People::class, $class->discriminatorColumn['enumType']); - self::assertEquals('discr', $class->discriminatorColumn['name']); + self::assertEquals(GH10288People::class, $class->discriminatorColumn->enumType); + self::assertEquals('discr', $class->discriminatorColumn->name); } #[\PHPUnit\Framework\Attributes\Group('DDC-889')] @@ -898,9 +892,9 @@ public function testDiscriminatorColumnDefaultLength(): void } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - self::assertEquals(255, $class->discriminatorColumn['length']); + self::assertEquals(255, $class->discriminatorColumn->length); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - self::assertEquals(255, $class->discriminatorColumn['length']); + self::assertEquals(255, $class->discriminatorColumn->length); } #[\PHPUnit\Framework\Attributes\Group('DDC-514')] @@ -912,9 +906,9 @@ public function testDiscriminatorColumnDefaultType(): void } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - self::assertEquals('string', $class->discriminatorColumn['type']); + self::assertEquals('string', $class->discriminatorColumn->type); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - self::assertEquals('string', $class->discriminatorColumn['type']); + self::assertEquals('string', $class->discriminatorColumn->type); } #[\PHPUnit\Framework\Attributes\Group('DDC-514')] @@ -926,9 +920,9 @@ public function testDiscriminatorColumnDefaultName(): void } $class = $this->createClassMetadata(SingleTableEntityNoDiscriminatorColumnMapping::class); - self::assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals('dtype', $class->discriminatorColumn->name); $class = $this->createClassMetadata(SingleTableEntityIncompleteDiscriminatorColumnMapping::class); - self::assertEquals('dtype', $class->discriminatorColumn['name']); + self::assertEquals('dtype', $class->discriminatorColumn->name); } public function testReservedWordInTableColumn(): void From 118eb870324a8a6336e80ec4b44b1e4007a50403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 14 Apr 2023 15:38:17 +0200 Subject: [PATCH 244/475] Migrate to embedded class mapping object API --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 22 +++++++++---------- .../ORM/Mapping/ClassMetadataFactory.php | 8 +++---- psalm-baseline.xml | 2 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 2 +- .../ORM/Mapping/MappingDriverTestCase.php | 2 +- .../ORM/Mapping/XmlMappingDriverTest.php | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 8a1635be326..8a0eb466ff7 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -794,18 +794,18 @@ public function wakeupReflection(ReflectionService $reflService): void $parentReflFields = []; foreach ($this->embeddedClasses as $property => $embeddedClass) { - if (isset($embeddedClass['declaredField'])) { - assert($embeddedClass['originalField'] !== null); + if (isset($embeddedClass->declaredField)) { + assert($embeddedClass->originalField !== null); $childProperty = $this->getAccessibleProperty( $reflService, - $this->embeddedClasses[$embeddedClass['declaredField']]['class'], - $embeddedClass['originalField'], + $this->embeddedClasses[$embeddedClass->declaredField]->class, + $embeddedClass->originalField, ); assert($childProperty !== null); $parentReflFields[$property] = new ReflectionEmbeddedProperty( - $parentReflFields[$embeddedClass['declaredField']], + $parentReflFields[$embeddedClass->declaredField], $childProperty, - $this->embeddedClasses[$embeddedClass['declaredField']]['class'], + $this->embeddedClasses[$embeddedClass->declaredField]->class, ); continue; @@ -813,7 +813,7 @@ public function wakeupReflection(ReflectionService $reflService): void $fieldRefl = $this->getAccessibleProperty( $reflService, - $embeddedClass['declared'] ?? $this->name, + $embeddedClass->declared ?? $this->name, $property, ); @@ -1808,7 +1808,7 @@ public function isInheritedAssociation(string $fieldName): bool public function isInheritedEmbeddedClass(string $fieldName): bool { - return isset($this->embeddedClasses[$fieldName]['inherited']); + return isset($this->embeddedClasses[$fieldName]->inherited); } /** @@ -2544,9 +2544,9 @@ public function inlineEmbeddable(string $property, ClassMetadata $embeddable): v $fieldMapping['originalField'] ??= $fieldMapping['fieldName']; $fieldMapping['fieldName'] = $property . '.' . $fieldMapping['fieldName']; - if (! empty($this->embeddedClasses[$property]['columnPrefix'])) { - $fieldMapping['columnName'] = $this->embeddedClasses[$property]['columnPrefix'] . $fieldMapping['columnName']; - } elseif ($this->embeddedClasses[$property]['columnPrefix'] !== false) { + if (! empty($this->embeddedClasses[$property]->columnPrefix)) { + $fieldMapping['columnName'] = $this->embeddedClasses[$property]->columnPrefix . $fieldMapping['columnName']; + } elseif ($this->embeddedClasses[$property]->columnPrefix !== false) { assert($this->reflClass !== null); assert($embeddable->reflClass !== null); $fieldMapping['columnName'] = $this->namingStrategy diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 1d4e00aba2a..0137782533c 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -138,17 +138,17 @@ protected function doLoadMetadata( } foreach ($class->embeddedClasses as $property => $embeddableClass) { - if (isset($embeddableClass['inherited'])) { + if (isset($embeddableClass->inherited)) { continue; } - if (isset($this->embeddablesActiveNesting[$embeddableClass['class']])) { + if (isset($this->embeddablesActiveNesting[$embeddableClass->class])) { throw MappingException::infiniteEmbeddableNesting($class->name, $property); } $this->embeddablesActiveNesting[$class->name] = true; - $embeddableMetadata = $this->getMetadataFor($embeddableClass['class']); + $embeddableMetadata = $this->getMetadataFor($embeddableClass->class); if ($embeddableMetadata->isEmbeddedClass) { $this->addNestedEmbeddedClasses($embeddableMetadata, $class, $property); @@ -458,7 +458,7 @@ private function addNestedEmbeddedClasses( string $prefix, ): void { foreach ($subClass->embeddedClasses as $property => $embeddableClass) { - if (isset($embeddableClass['inherited'])) { + if (isset($embeddableClass->inherited)) { continue; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index afe23fc2fc9..bd73a88be25 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -333,7 +333,7 @@ $className - + declaredField]]]> getProperty diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 149045095df..66e2c3238b6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -150,7 +150,7 @@ public function testFieldIsNullableByType(): void self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('mainEmail')['targetEntity']); $cm->mapEmbedded(['fieldName' => 'contact']); - self::assertEquals(Contact::class, $cm->embeddedClasses['contact']['class']); + self::assertEquals(Contact::class, $cm->embeddedClasses['contact']->class); } public function testFieldTypeFromReflection(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 989bc16e4af..8363fe648ac 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -281,7 +281,7 @@ public function testFieldTypeFromReflection(): void self::assertEquals(CmsEmail::class, $class->getAssociationMapping('email')['targetEntity']); self::assertEquals(CmsEmail::class, $class->getAssociationMapping('mainEmail')['targetEntity']); - self::assertEquals(Contact::class, $class->embeddedClasses['contact']['class']); + self::assertEquals(Contact::class, $class->embeddedClasses['contact']->class); } #[\PHPUnit\Framework\Attributes\Group('GH10313')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index cdfff2ec2a1..97815be86c0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -110,7 +110,7 @@ public function testEmbeddedMappingsWithUseColumnPrefix(): void self::assertEquals( '__prefix__', $factory->getMetadataFor(DDC3293UserPrefixed::class) - ->embeddedClasses['address']['columnPrefix'], + ->embeddedClasses['address']->columnPrefix, ); } @@ -127,7 +127,7 @@ public function testEmbeddedMappingsWithFalseUseColumnPrefix(): void self::assertFalse( $factory->getMetadataFor(DDC3293User::class) - ->embeddedClasses['address']['columnPrefix'], + ->embeddedClasses['address']->columnPrefix, ); } From 2d3e89e2cbadb32868d173b557316388aacf8be6 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 14 Apr 2023 23:05:11 +0200 Subject: [PATCH 245/475] Remove obsolete RequiresPhp attributes (#10631) --- tests/Doctrine/Tests/ORM/Functional/EnumTest.php | 2 -- tests/Doctrine/Tests/ORM/Functional/QueryTest.php | 3 --- .../Tests/ORM/Functional/ReadonlyPropertiesTest.php | 2 -- tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php | 2 -- tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php | 4 ---- tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php | 6 ------ .../Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php | 2 -- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 3 --- tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php | 2 -- .../Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php | 2 -- 10 files changed, 28 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php index 57cdc07baea..0375bc7dda4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php @@ -23,13 +23,11 @@ use Doctrine\Tests\Models\Enums\Unit; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\RequiresPhp; use function dirname; use function sprintf; use function uniqid; -#[RequiresPhp('8.1')] class EnumTest extends OrmFunctionalTestCase { public function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index b53a850678c..a17fb3a3f0c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -21,7 +21,6 @@ use Doctrine\Tests\Models\Enums\UserStatus; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\RequiresPhp; use function count; use function iterator_to_array; @@ -168,7 +167,6 @@ public function testInvalidInputParameterThrowsException(): void ->getSingleResult(); } - #[RequiresPhp('8.1')] public function testUseStringEnumCaseAsParameter(): void { $user = new CmsUser(); @@ -196,7 +194,6 @@ public function testUseStringEnumCaseAsParameter(): void self::assertSame('jane', $result[0]->username); } - #[RequiresPhp('8.1')] public function testUseIntegerEnumCaseAsParameter(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php index 6de8ba2f019..31a61092469 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php @@ -11,11 +11,9 @@ use Doctrine\Tests\Models\ReadonlyProperties\SimpleBook; use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\TestUtil; -use PHPUnit\Framework\Attributes\RequiresPhp; use function dirname; -#[RequiresPhp('8.1')] class ReadonlyPropertiesTest extends OrmFunctionalTestCase { protected function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php index b3066bb10f4..ee020304533 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php @@ -7,9 +7,7 @@ use Doctrine\Tests\Models\GH10336\GH10336Entity; use Doctrine\Tests\Models\GH10336\GH10336Relation; use Doctrine\Tests\OrmFunctionalTestCase; -use PHPUnit\Framework\Attributes\RequiresPhp; -#[RequiresPhp('7.4')] final class GH10336Test extends OrmFunctionalTestCase { public function setUp(): void diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 66e2c3238b6..1b701d93cd7 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -46,7 +46,6 @@ use Doctrine\Tests\OrmTestCase; use DoctrineGlobalArticle; use PHPUnit\Framework\Attributes\Group as TestGroup; -use PHPUnit\Framework\Attributes\RequiresPhp; use ReflectionClass; use stdClass; @@ -797,7 +796,6 @@ public function testInvalidCascade(): void $cm->mapManyToOne(['fieldName' => 'address', 'targetEntity' => 'UnknownClass', 'cascade' => ['invalid']]); } - #[RequiresPhp('8.1')] #[TestGroup('DDC-964')] public function testInvalidPropertyAssociationOverrideNameException(): void { @@ -810,7 +808,6 @@ public function testInvalidPropertyAssociationOverrideNameException(): void $cm->setAssociationOverride('invalidPropertyName', []); } - #[RequiresPhp('8.1')] #[TestGroup('DDC-964')] public function testInvalidPropertyAttributeOverrideNameException(): void { @@ -823,7 +820,6 @@ public function testInvalidPropertyAttributeOverrideNameException(): void $cm->setAttributeOverride('invalidPropertyName', []); } - #[RequiresPhp('8.1')] #[TestGroup('DDC-964')] public function testInvalidOverrideAttributeFieldTypeException(): void { diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index ac9c6dff962..0f2a9e3934b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -64,7 +64,6 @@ use Doctrine\Tests\Models\Upsertable\Updatable; use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\Attributes\Depends; -use PHPUnit\Framework\Attributes\RequiresPhp; use stdClass; use function assert; @@ -585,7 +584,6 @@ public function testIdentifierRequiredShouldMentionParentClasses(): void } #[\PHPUnit\Framework\Attributes\Group('DDC-3579')] - #[RequiresPhp('8.1')] public function testInversedByOverrideMapping(): void { $factory = $this->createClassMetadataFactory(); @@ -600,7 +598,6 @@ public function testInversedByOverrideMapping(): void } #[\PHPUnit\Framework\Attributes\Group('DDC-5934')] - #[RequiresPhp('8.1')] public function testFetchOverrideMapping(): void { // check override metadata @@ -611,7 +608,6 @@ public function testFetchOverrideMapping(): void } #[\PHPUnit\Framework\Attributes\Group('DDC-964')] - #[RequiresPhp('8.1')] public function testAssociationOverridesMapping(): void { $factory = $this->createClassMetadataFactory(); @@ -688,7 +684,6 @@ public function testAssociationOverridesMapping(): void } #[\PHPUnit\Framework\Attributes\Group('DDC-964')] - #[RequiresPhp('8.1')] public function testAttributeOverridesMapping(): void { $factory = $this->createClassMetadataFactory(); @@ -952,7 +947,6 @@ public function testUpdatableColumn(): void self::assertNull($metadata->getFieldMapping('updatableContent')->notUpdatable); } - #[RequiresPhp('8.1')] public function testEnumType(): void { $metadata = $this->createClassMetadata(Card::class); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php b/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php index ba2534a231e..54e2a74534e 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php @@ -9,11 +9,9 @@ use Doctrine\Tests\Models\ReadonlyProperties\Author; use InvalidArgumentException; use LogicException; -use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\TestCase; use ReflectionProperty; -#[RequiresPhp('8.1')] class ReflectionReadonlyPropertyTest extends TestCase { public function testSecondWriteWithSameValue(): void diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index cda9b375c19..3e4c2840a81 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -31,7 +31,6 @@ use Generator; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\RequiresPhp; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -293,7 +292,6 @@ public function testProcessParameterValueNull(): void self::assertNull($query->processParameterValue(null)); } - #[RequiresPhp('8.1')] public function testProcessParameterValueBackedEnum(): void { $query = $this->entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.status = :status'); @@ -302,7 +300,6 @@ public function testProcessParameterValueBackedEnum(): void self::assertSame([2], $query->processParameterValue([AccessLevel::User])); } - #[RequiresPhp('8.1')] public function testProcessParameterValueBackedEnumArray(): void { $query = $this->entityManager->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.status IN (:status)'); diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index e3c85b881a2..d917254721e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -41,7 +41,6 @@ use Doctrine\Tests\Models\NullDefault\NullDefaultColumn; use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\RequiresPhp; use function count; use function current; @@ -184,7 +183,6 @@ public function testNullDefaultNotAddedToPlatformOptions(): void ->getPlatformOptions()); } - #[RequiresPhp('8.1')] public function testEnumTypeAddedToCustomSchemaOptions(): void { $em = $this->getTestEntityManager(); diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php index 46532e571c5..126195ea6db 100644 --- a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php +++ b/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php @@ -12,13 +12,11 @@ use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\RequiresPhp; /** * Test the IdentifierFlattener utility class */ #[CoversClass(IdentifierFlattener::class)] -#[RequiresPhp('8.1')] class IdentifierFlattenerEnumIdTest extends OrmFunctionalTestCase { protected function setUp(): void From ec9e79a35bee39ff4c427c61de3bb7eccdf6d9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 15 Apr 2023 11:25:39 +0200 Subject: [PATCH 246/475] Check only owning relationships The inverse side does not have access to join columns / join tables. --- lib/Doctrine/ORM/Utility/PersisterHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index 63109330688..8f061fe99c2 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -69,7 +69,7 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, // iterate over to-one association mappings foreach ($class->associationMappings as $assoc) { - if (! $assoc->isToOne()) { + if (! $assoc->isToOneOwningSide()) { continue; } @@ -85,7 +85,7 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, // iterate over to-many association mappings foreach ($class->associationMappings as $assoc) { - if (! $assoc->isToMany()) { + if (! $assoc->isManyToManyOwningSide()) { continue; } From 3e0451674070ec5c487d1969feb0da7800f0fdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 15 Apr 2023 13:06:57 +0200 Subject: [PATCH 247/475] Remove wrong comparison This is a remnant of when this was done with the type and the & operator. --- lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 870a6da3c8b..fba5c25e0c1 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -1193,7 +1193,7 @@ protected function getSelectColumnsSQL(): string continue; } - if (($assoc->isToMany() > 0) && $this->currentPersisterContext->handlesLimits) { + if ($assoc->isToMany() && $this->currentPersisterContext->handlesLimits) { continue; } From b6860328c089536a0b9c8e75eb8ca5d813f47121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 15 Apr 2023 14:33:01 +0200 Subject: [PATCH 248/475] Introduce and leverage more convenience methods --- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 4 +- .../ORM/Internal/Hydration/ObjectHydrator.php | 2 +- .../ORM/Mapping/AssociationMapping.php | 12 ++++++ lib/Doctrine/ORM/PersistentCollection.php | 6 +-- .../Entity/BasicEntityPersister.php | 6 +-- .../Entity/JoinedSubclassPersister.php | 2 +- .../ORM/Query/AST/Functions/SizeFunction.php | 8 ++-- lib/Doctrine/ORM/Query/SqlWalker.php | 11 ++--- lib/Doctrine/ORM/Tools/SchemaValidator.php | 18 ++++---- .../ORM/Functional/Ticket/GH10473Test.php | 41 +++++++++---------- 10 files changed, 61 insertions(+), 49 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 1e9f902f3a8..7b6fd4bd7bf 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -307,7 +307,7 @@ private function storeAssociationCache(QueryCacheKey $key, AssociationMapping $a $assocRegion = $assocPersister->getCacheRegion(); // Handle *-to-one associations - if ($assoc['type'] & ClassMetadata::TO_ONE) { + if ($assoc->isToOne()) { $assocIdentifier = $this->uow->getEntityIdentifier($assocValue); $entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier); @@ -395,7 +395,7 @@ private function getAssociationPathValue(mixed $value, array $path): array|objec } // Handle *-to-one associations - if ($assoc['type'] & ClassMetadata::TO_ONE) { + if ($assoc->isToOne()) { return $this->getAssociationPathValue($value, $path); } diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index e6b43fd9996..cd7fa4a840c 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -78,7 +78,7 @@ protected function prepare(): void $this->hints['fetched'][$parent][$assoc['fieldName']] = true; - if ($assoc['type'] === ClassMetadata::MANY_TO_MANY) { + if ($assoc->isManyToMany()) { continue; } diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index 96dd2647a96..d688a8831cf 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -197,6 +197,18 @@ final public function isOneToOne(): bool return $this instanceof OneToOneAssociationMapping; } + /** @psalm-assert-if-true OneToManyAssociationMapping $this */ + final public function isOneToMany(): bool + { + return $this instanceof OneToManyAssociationMapping; + } + + /** @psalm-assert-if-true ManyToOneAssociationMapping $this */ + final public function isManyToOne(): bool + { + return $this instanceof ManyToOneAssociationMapping; + } + /** @psalm-assert-if-true ManyToManyAssociationMapping $this */ final public function isManyToMany(): bool { diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 41e5a886e70..1d5ff15c724 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -139,7 +139,7 @@ public function hydrateAdd(mixed $element): void // If _backRefFieldName is set and its a one-to-many association, // we need to set the back reference. - if ($this->backRefFieldName && $this->association['type'] === ClassMetadata::ONE_TO_MANY) { + if ($this->backRefFieldName && $this->association->isOneToMany()) { assert($this->typeClass !== null); // Set back reference to owner $this->typeClass->reflFields[$this->backRefFieldName]->setValue( @@ -165,7 +165,7 @@ public function hydrateSet(mixed $key, mixed $element): void // If _backRefFieldName is set, then the association is bidirectional // and we need to set the back reference. - if ($this->backRefFieldName && $this->association !== null && $this->association['type'] === ClassMetadata::ONE_TO_MANY) { + if ($this->backRefFieldName && $this->association !== null && $this->association->isOneToMany()) { assert($this->typeClass !== null); // Set back reference to owner $this->typeClass->reflFields[$this->backRefFieldName]->setValue( @@ -587,7 +587,7 @@ public function matching(Criteria $criteria): Collection } assert($this->association !== null); - if ($this->association['type'] === ClassMetadata::MANY_TO_MANY) { + if ($this->association->isManyToMany()) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->association); return new ArrayCollection($persister->loadCriteria($this, $criteria)); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 870a6da3c8b..93acbd3dec2 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -1030,7 +1030,7 @@ public function getSelectSQL( $joinSql = ''; $orderBySql = ''; - if ($assoc !== null && $assoc['type'] === ClassMetadata::MANY_TO_MANY) { + if ($assoc !== null && $assoc->isManyToMany()) { $joinSql = $this->getSelectManyToManyJoinSQL($assoc); } @@ -1619,7 +1619,7 @@ private function getSelectConditionStatementColumnSQL( $columns = []; $class = $this->class; - if ($association['type'] === ClassMetadata::MANY_TO_MANY) { + if ($association->isManyToMany()) { if (! $association['isOwningSide']) { $association = $assoc; } @@ -1835,7 +1835,7 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar $class = $this->em->getClassMetadata($assoc['targetEntity']); } - $columns = $assoc['type'] === ClassMetadata::MANY_TO_MANY + $columns = $assoc->isManyToMany() ? $assoc['relationToTargetKeyColumns'] : $assoc['sourceToTargetKeyColumns']; diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 34f051eb83f..9edde38d8f3 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -251,7 +251,7 @@ public function getSelectSQL( $baseTableAlias = $this->getSQLTableAlias($this->class->name); $joinSql = $this->getJoinSql($baseTableAlias); - if ($assoc !== null && $assoc['type'] === ClassMetadata::MANY_TO_MANY) { + if ($assoc !== null && $assoc->isManyToMany()) { $joinSql .= $this->getSelectManyToManyJoinSQL($assoc); } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 924110e2fdd..436967fc0f6 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Query\AST\Functions; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\AST\PathExpression; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\SqlWalker; @@ -39,8 +38,8 @@ public function getSql(SqlWalker $sqlWalker): string $assoc = $class->associationMappings[$assocField]; $sql = 'SELECT COUNT(*) FROM '; - if ($assoc['type'] === ClassMetadata::ONE_TO_MANY) { - $targetClass = $entityManager->getClassMetadata($assoc['targetEntity']); + if ($assoc->isOneToMany()) { + $targetClass = $entityManager->getClassMetadata($assoc->targetEntity); $targetTableAlias = $sqlWalker->getSQLTableAlias($targetClass->getTableName()); $sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); @@ -62,7 +61,8 @@ public function getSql(SqlWalker $sqlWalker): string . $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $platform); } } else { // many-to-many - $targetClass = $entityManager->getClassMetadata($assoc['targetEntity']); + assert($assoc->isManyToMany()); + $targetClass = $entityManager->getClassMetadata($assoc->targetEntity); $owningAssoc = $assoc->isOwningSide() ? $assoc : $targetClass->associationMappings[$assoc['mappedBy']]; $joinTable = $owningAssoc['joinTable']; diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index b859d894945..f0183298688 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -898,7 +898,7 @@ public function walkJoinAssociationDeclaration( $assoc = ! $relation['isOwningSide'] ? $targetClass->associationMappings[$relation['mappedBy']] : $relation; if ($this->query->getHint(Query::HINT_INTERNAL_ITERATION) === true && (! $this->query->getHint(self::HINT_DISTINCT) || isset($this->selectedClasses[$joinedDqlAlias]))) { - if ($relation['type'] === ClassMetadata::ONE_TO_MANY || $relation['type'] === ClassMetadata::MANY_TO_MANY) { + if ($relation->isToMany()) { throw QueryException::iterateWithFetchJoinNotAllowed($assoc); } } @@ -945,7 +945,7 @@ public function walkJoinAssociationDeclaration( ]; break; - case $assoc['type'] === ClassMetadata::MANY_TO_MANY: + case $assoc->isManyToMany(): // Join relation table $joinTable = $assoc['joinTable']; $joinTableAlias = $this->getSQLTableAlias($joinTable['name'], $joinedDqlAlias); @@ -1856,8 +1856,8 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $assoc = $class->associationMappings[$fieldName]; - if ($assoc['type'] === ClassMetadata::ONE_TO_MANY) { - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + if ($assoc->isOneToMany()) { + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); $targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName()); $sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias); @@ -1882,7 +1882,8 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $sql .= implode(' AND ', $sqlParts); } else { // many-to-many - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + assert($assoc->isManyToMany()); + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); $owningAssoc = $assoc['isOwningSide'] ? $assoc : $targetClass->associationMappings[$assoc['mappedBy']]; $joinTable = $owningAssoc['joinTable']; diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 5aaeec50053..def56a47d83 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -125,7 +125,7 @@ public function validateClass(ClassMetadata $class): array } } - if ($assoc['inversedBy']) { + if ($assoc->inversedBy) { if ($targetMetadata->hasField($assoc['inversedBy'])) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the inverse side ' . 'field ' . $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' which is not defined as association.'; @@ -146,15 +146,15 @@ public function validateClass(ClassMetadata $class): array } // Verify inverse side/owning side match each other - if (array_key_exists($assoc['inversedBy'], $targetMetadata->associationMappings)) { - $targetAssoc = $targetMetadata->associationMappings[$assoc['inversedBy']]; - if ($assoc['type'] === ClassMetadata::ONE_TO_ONE && $targetAssoc['type'] !== ClassMetadata::ONE_TO_ONE) { + if (array_key_exists($assoc->inversedBy, $targetMetadata->associationMappings)) { + $targetAssoc = $targetMetadata->associationMappings[$assoc->inversedBy]; + if ($assoc->isOneToOne() && ! $targetAssoc->isOneToOne()) { $ce[] = 'If association ' . $class->name . '#' . $fieldName . ' is one-to-one, then the inversed ' . - 'side ' . $targetMetadata->name . '#' . $assoc['inversedBy'] . ' has to be one-to-one as well.'; - } elseif ($assoc['type'] === ClassMetadata::MANY_TO_ONE && $targetAssoc['type'] !== ClassMetadata::ONE_TO_MANY) { + 'side ' . $targetMetadata->name . '#' . $assoc->inversedBy . ' has to be one-to-one as well.'; + } elseif ($assoc->isManyToOne() && ! $targetAssoc->isOneToMany()) { $ce[] = 'If association ' . $class->name . '#' . $fieldName . ' is many-to-one, then the inversed ' . - 'side ' . $targetMetadata->name . '#' . $assoc['inversedBy'] . ' has to be one-to-many.'; - } elseif ($assoc['type'] === ClassMetadata::MANY_TO_MANY && $targetAssoc['type'] !== ClassMetadata::MANY_TO_MANY) { + 'side ' . $targetMetadata->name . '#' . $assoc->inversedBy . ' has to be one-to-many.'; + } elseif ($assoc->isManyToMany() && ! $targetAssoc->isManyToMany()) { $ce[] = 'If association ' . $class->name . '#' . $fieldName . ' is many-to-many, then the inversed ' . 'side ' . $targetMetadata->name . '#' . $assoc['inversedBy'] . ' has to be many-to-many as well.'; } @@ -162,7 +162,7 @@ public function validateClass(ClassMetadata $class): array } if ($assoc->isOwningSide()) { - if ($assoc['type'] === ClassMetadata::MANY_TO_MANY) { + if ($assoc->isManyToMany()) { $identifierColumns = $class->getIdentifierColumnNames(); foreach ($assoc['joinTable']['joinColumns'] as $joinColumn) { if (! in_array($joinColumn['referencedColumnName'], $identifierColumns, true)) { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10473Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10473Test.php index 09dd5ebbfcb..550080d61f6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10473Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10473Test.php @@ -6,7 +6,6 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Tools\ResolveTargetEntityListener; use Doctrine\Tests\OrmTestCase; @@ -32,25 +31,25 @@ public function testMappedSuperclassAssociationsCanBeResolvedToEntities(): void self::assertTrue($userMetadata->isInheritanceTypeNone()); $socialMediaAccountsMapping = $userMetadata->getAssociationMapping('socialMediaAccounts'); - self::assertArrayNotHasKey('inherited', $socialMediaAccountsMapping); - self::assertTrue((bool) ($socialMediaAccountsMapping['type'] & ClassMetadata::TO_MANY)); - self::assertFalse($socialMediaAccountsMapping['isOwningSide']); - self::assertSame(GH10473SocialMediaAccount::class, $socialMediaAccountsMapping['targetEntity']); - self::assertSame('user', $socialMediaAccountsMapping['mappedBy']); + self::assertNull($socialMediaAccountsMapping->inherited); + self::assertTrue($socialMediaAccountsMapping->isToMany()); + self::assertFalse($socialMediaAccountsMapping->isOwningSide()); + self::assertSame(GH10473SocialMediaAccount::class, $socialMediaAccountsMapping->targetEntity); + self::assertSame('user', $socialMediaAccountsMapping->mappedBy); $createdByMapping = $userMetadata->getAssociationMapping('createdBy'); - self::assertArrayNotHasKey('inherited', $createdByMapping); - self::assertTrue((bool) ($createdByMapping['type'] & ClassMetadata::TO_ONE)); - self::assertTrue($createdByMapping['isOwningSide']); - self::assertSame(GH10473UserImplementation::class, $createdByMapping['targetEntity']); - self::assertSame('createdUsers', $createdByMapping['inversedBy']); + self::assertNull($createdByMapping->inherited); + self::assertTrue($createdByMapping->isToOne()); + self::assertTrue($createdByMapping->isOwningSide()); + self::assertSame(GH10473UserImplementation::class, $createdByMapping->targetEntity); + self::assertSame('createdUsers', $createdByMapping->inversedBy); $createdUsersMapping = $userMetadata->getAssociationMapping('createdUsers'); - self::assertArrayNotHasKey('inherited', $createdUsersMapping); - self::assertTrue((bool) ($createdUsersMapping['type'] & ClassMetadata::TO_MANY)); - self::assertFalse($createdUsersMapping['isOwningSide']); - self::assertSame(GH10473UserImplementation::class, $createdUsersMapping['targetEntity']); - self::assertSame('createdBy', $createdUsersMapping['mappedBy']); + self::assertNull($createdUsersMapping->inherited); + self::assertTrue($createdUsersMapping->isToMany()); + self::assertFalse($createdUsersMapping->isOwningSide()); + self::assertSame(GH10473UserImplementation::class, $createdUsersMapping->targetEntity); + self::assertSame('createdBy', $createdUsersMapping->mappedBy); $socialMediaAccountMetadata = $em->getClassMetadata(GH10473SocialMediaAccount::class); @@ -58,11 +57,11 @@ public function testMappedSuperclassAssociationsCanBeResolvedToEntities(): void self::assertTrue($socialMediaAccountMetadata->isInheritanceTypeNone()); $userMapping = $socialMediaAccountMetadata->getAssociationMapping('user'); - self::assertArrayNotHasKey('inherited', $userMapping); - self::assertTrue((bool) ($userMapping['type'] & ClassMetadata::TO_ONE)); - self::assertTrue($userMapping['isOwningSide']); - self::assertSame(GH10473UserImplementation::class, $userMapping['targetEntity']); - self::assertSame('socialMediaAccounts', $userMapping['inversedBy']); + self::assertNull($userMapping->inherited); + self::assertTrue($userMapping->isToOne()); + self::assertTrue($userMapping->isOwningSide()); + self::assertSame(GH10473UserImplementation::class, $userMapping->targetEntity); + self::assertSame('socialMediaAccounts', $userMapping->inversedBy); } } From 49cc83d2737fcf2450035089946e7d6e53c012e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 17 Apr 2023 21:15:45 +0200 Subject: [PATCH 249/475] Move joinTableColumns down This field only makes sense for the owning side of many-to-many mappings. Moving it down allows us to make it non-nullable. --- lib/Doctrine/ORM/Mapping/AssociationMapping.php | 4 ---- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 1 - .../ORM/Mapping/ManyToManyOwningSideMapping.php | 4 ++++ .../Collection/ManyToManyPersister.php | 16 ++++++++++------ phpstan.neon | 4 ++++ .../Tests/ORM/Mapping/AssociationMappingTest.php | 2 -- .../Mapping/ManyToManyOwningSideMappingTest.php | 6 ++++-- 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index d688a8831cf..3e4a5fa22e3 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -81,9 +81,6 @@ abstract class AssociationMapping implements ArrayAccess /** @var array|null */ public array|null $joinColumnFieldNames = null; - /** @var list|null */ - public array|null $joinTableColumns = null; - /** @var class-string|null */ public string|null $originalClass = null; @@ -336,7 +333,6 @@ public function __sleep(): array 'declared', 'cache', 'joinColumnFieldNames', - 'joinTableColumns', 'originalClass', 'originalField', ] as $stringOrArrayProperty diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index e4e03563640..cd0c5a8ebae 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1722,7 +1722,6 @@ public function setAssociationOverride(string $fieldName, array $overrideMapping } $mapping['joinColumnFieldNames'] = null; - $mapping['joinTableColumns'] = null; switch ($mapping['type']) { case self::ONE_TO_ONE: diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php index 0c88018f239..2db1d6790a5 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php @@ -17,6 +17,9 @@ final class ManyToManyOwningSideMapping extends ManyToManyAssociationMapping imp */ public JoinTableMapping $joinTable; + /** @var list */ + public array $joinTableColumns = []; + /** @return array */ public function toArray(): array { @@ -130,6 +133,7 @@ public function __sleep(): array { $serialized = parent::__sleep(); $serialized[] = 'joinTable'; + $serialized[] = 'joinTableColumns'; return $serialized; } diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index f66757b10b4..794675ec1dd 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -17,6 +17,7 @@ use function array_fill; use function array_pop; +use function assert; use function count; use function implode; use function in_array; @@ -501,9 +502,10 @@ private function collectJoinTableColumnParameters( PersistentCollection $collection, object $element, ): array { - $params = []; - $mapping = $collection->getMapping(); - $isComposite = count($mapping['joinTableColumns']) > 2; + $params = []; + $mapping = $collection->getMapping(); + assert($mapping->isManyToManyOwningSide()); + $isComposite = count($mapping->joinTableColumns) > 2; $identifier1 = $this->uow->getEntityIdentifier($collection->getOwner()); $identifier2 = $this->uow->getEntityIdentifier($element); @@ -514,7 +516,7 @@ private function collectJoinTableColumnParameters( $class2 = $collection->getTypeClass(); } - foreach ($mapping['joinTableColumns'] as $joinTableColumn) { + foreach ($mapping->joinTableColumns as $joinTableColumn) { $isRelationToSource = isset($mapping['relationToSourceKeyColumns'][$joinTableColumn]); if (! $isComposite) { @@ -593,7 +595,8 @@ private function getJoinTableRestrictionsWithKey( $types[] = PersisterHelper::getTypeOfColumn($columnName, $targetClass, $this->em); } - foreach ($mapping['joinTableColumns'] as $joinTableColumn) { + assert($mapping->isManyToManyOwningSide()); + foreach ($mapping->joinTableColumns as $joinTableColumn) { if (isset($mapping[$sourceRelationMode][$joinTableColumn])) { $column = $mapping[$sourceRelationMode][$joinTableColumn]; $whereClauses[] = 't.' . $joinTableColumn . ' = ?'; @@ -659,7 +662,8 @@ private function getJoinTableRestrictions( $params = []; $types = []; - foreach ($mapping['joinTableColumns'] as $joinTableColumn) { + assert($mapping->isManyToManyOwningSide()); + foreach ($mapping->joinTableColumns as $joinTableColumn) { $whereClauses[] = ($addFilters ? 't.' : '') . $joinTableColumn . ' = ?'; if (isset($mapping['relationToTargetKeyColumns'][$joinTableColumn])) { diff --git a/phpstan.neon b/phpstan.neon index 836e6c126bf..84f3f5ebcc0 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -29,6 +29,10 @@ parameters: message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\:\\:\\$joinColumns\\.$#" path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php + - + message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping\\:\\:\\$joinTableColumns\\.$#" + path: lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php + - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\:\\:fromMappingArrayAndName\\(\\) should return Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneAssociationMapping but returns static\\(Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\)\\.$#" path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php index b129a2cb60e..b53e23e20a0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php @@ -33,7 +33,6 @@ public function testItSurvivesSerialization(): void $mapping->id = true; $mapping->isOnDeleteCascade = true; $mapping->joinColumnFieldNames = ['foo' => 'bar']; - $mapping->joinTableColumns = ['foo', 'bar']; $mapping->originalClass = self::class; $mapping->originalField = 'foo'; $mapping->orphanRemoval = true; @@ -52,7 +51,6 @@ public function testItSurvivesSerialization(): void self::assertTrue($resurrectedMapping->id); self::assertTrue($resurrectedMapping->isOnDeleteCascade); self::assertSame(['foo' => 'bar'], $resurrectedMapping->joinColumnFieldNames); - self::assertSame(['foo', 'bar'], $resurrectedMapping->joinTableColumns); self::assertSame(self::class, $resurrectedMapping->originalClass); self::assertSame('foo', $resurrectedMapping->originalField); self::assertTrue($resurrectedMapping->orphanRemoval); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php index 77f44121448..2f01d060aa7 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php @@ -22,12 +22,14 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->joinTable = new JoinTableMapping(); - $mapping->joinTable->name = 'bar'; + $mapping->joinTable = new JoinTableMapping(); + $mapping->joinTable->name = 'bar'; + $mapping->joinTableColumns = ['foo', 'bar']; $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof ManyToManyOwningSideMapping); self::assertSame($resurrectedMapping->joinTable->name, 'bar'); + self::assertSame(['foo', 'bar'], $resurrectedMapping->joinTableColumns); } } From 672ff01f44c482b50c5d12c5febbb5689f3a33cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 17 Apr 2023 22:38:27 +0200 Subject: [PATCH 250/475] Move properties down These properties only make sense for the owning side of a many-to-many relationship. Moving them down allows us simplify the serialization code, because the case when these properties are empty no longer happen. --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 4 +-- .../Mapping/ManyToManyAssociationMapping.php | 16 --------- .../Mapping/ManyToManyOwningSideMapping.php | 11 +++++++ .../ManyToManyAssociationMappingTest.php | 33 ------------------- .../ManyToManyOwningSideMappingTest.php | 10 ++++-- 5 files changed, 20 insertions(+), 54 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/ManyToManyAssociationMappingTest.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index cd0c5a8ebae..80eccdb24f9 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1729,8 +1729,8 @@ public function setAssociationOverride(string $fieldName, array $overrideMapping $mapping['sourceToTargetKeyColumns'] = null; break; case self::MANY_TO_MANY: - $mapping['relationToSourceKeyColumns'] = null; - $mapping['relationToTargetKeyColumns'] = null; + $mapping['relationToSourceKeyColumns'] = []; + $mapping['relationToTargetKeyColumns'] = []; break; } diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php index d2d2666e60f..92501efd575 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php @@ -6,20 +6,4 @@ class ManyToManyAssociationMapping extends ToManyAssociationMapping { - public array|null $relationToSourceKeyColumns = null; - public array|null $relationToTargetKeyColumns = null; - - /** @return list */ - public function __sleep(): array - { - $serialized = parent::__sleep(); - - foreach (['relationToSourceKeyColumns', 'relationToTargetKeyColumns'] as $arrayKey) { - if ($this->$arrayKey !== null) { - $serialized[] = $arrayKey; - } - } - - return $serialized; - } } diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php index 2db1d6790a5..f54493589d0 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php @@ -20,6 +20,11 @@ final class ManyToManyOwningSideMapping extends ManyToManyAssociationMapping imp /** @var list */ public array $joinTableColumns = []; + /** @var array */ + public array $relationToSourceKeyColumns = []; + /** @var array */ + public array $relationToTargetKeyColumns = []; + /** @return array */ public function toArray(): array { @@ -135,6 +140,12 @@ public function __sleep(): array $serialized[] = 'joinTable'; $serialized[] = 'joinTableColumns'; + foreach (['relationToSourceKeyColumns', 'relationToTargetKeyColumns'] as $arrayKey) { + if ($this->$arrayKey !== null) { + $serialized[] = $arrayKey; + } + } + return $serialized; } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyAssociationMappingTest.php deleted file mode 100644 index 01b1ac22e8d..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyAssociationMappingTest.php +++ /dev/null @@ -1,33 +0,0 @@ -relationToSourceKeyColumns = ['foo' => 'bar']; - $mapping->relationToTargetKeyColumns = ['bar' => 'baz']; - - $resurrectedMapping = unserialize(serialize($mapping)); - assert($resurrectedMapping instanceof ManyToManyAssociationMapping); - - self::assertSame(['foo' => 'bar'], $resurrectedMapping->relationToSourceKeyColumns); - self::assertSame(['bar' => 'baz'], $resurrectedMapping->relationToTargetKeyColumns); - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php index 2f01d060aa7..4c500decfab 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php @@ -22,14 +22,18 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->joinTable = new JoinTableMapping(); - $mapping->joinTable->name = 'bar'; - $mapping->joinTableColumns = ['foo', 'bar']; + $mapping->joinTable = new JoinTableMapping(); + $mapping->joinTable->name = 'bar'; + $mapping->joinTableColumns = ['foo', 'bar']; + $mapping->relationToSourceKeyColumns = ['foo' => 'bar']; + $mapping->relationToTargetKeyColumns = ['bar' => 'baz']; $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof ManyToManyOwningSideMapping); self::assertSame($resurrectedMapping->joinTable->name, 'bar'); self::assertSame(['foo', 'bar'], $resurrectedMapping->joinTableColumns); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->relationToSourceKeyColumns); + self::assertSame(['bar' => 'baz'], $resurrectedMapping->relationToTargetKeyColumns); } } From 01aa9a58700a700551b94537195797259526b5b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 17 Apr 2023 21:16:07 +0200 Subject: [PATCH 251/475] Add nice assertion for PHPStan --- lib/Doctrine/ORM/Mapping/AssociationMapping.php | 5 ++++- .../ORM/Persisters/Collection/ManyToManyPersister.php | 2 +- psalm.xml | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index 3e4a5fa22e3..bd6a1b77ace 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -158,7 +158,10 @@ public static function fromMappingArray(array $mappingArray): static return $mapping; } - /** @psalm-assert-if-true AssociationOwningSideMapping $this */ + /** + * @psalm-assert-if-true AssociationOwningSideMapping $this + * @psalm-assert-if-false string $this->mappedBy + */ final public function isOwningSide(): bool { return $this instanceof AssociationOwningSideMapping; diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 794675ec1dd..8bd068ff1ec 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -643,7 +643,7 @@ private function getJoinTableRestrictions( $filterMapping = $collection->getMapping(); $mapping = $filterMapping; - if (! $mapping['isOwningSide']) { + if (! $mapping->isOwningSide()) { $sourceClass = $this->em->getClassMetadata($mapping['targetEntity']); $targetClass = $this->em->getClassMetadata($mapping['sourceEntity']); $sourceId = $this->uow->getEntityIdentifier($element); diff --git a/psalm.xml b/psalm.xml index da0a9f41229..05c971b8ecd 100644 --- a/psalm.xml +++ b/psalm.xml @@ -124,6 +124,12 @@ + + + + + + From 8d1d32ce81271e177ae7a7dcc509be41e0d251a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 17 Apr 2023 22:28:51 +0200 Subject: [PATCH 252/475] Migrate ManyToManyPersister to the object API of association mappings --- .../Collection/ManyToManyPersister.php | 165 ++++++++++-------- phpstan.neon | 2 +- 2 files changed, 91 insertions(+), 76 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 8bd068ff1ec..ac1eb3468e6 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -33,14 +33,16 @@ public function delete(PersistentCollection $collection): void { $mapping = $collection->getMapping(); - if (! $mapping['isOwningSide']) { + if (! $mapping->isOwningSide()) { return; // ignore inverse side } + assert($mapping->isManyToManyOwningSide()); + $types = []; - $class = $this->em->getClassMetadata($mapping['sourceEntity']); + $class = $this->em->getClassMetadata($mapping->sourceEntity); - foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { + foreach ($mapping->joinTable['joinColumns'] as $joinColumn) { $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $class, $this->em); } @@ -51,7 +53,7 @@ public function update(PersistentCollection $collection): void { $mapping = $collection->getMapping(); - if (! $mapping['isOwningSide']) { + if (! $mapping->isOwningSide()) { return; // ignore inverse side } @@ -79,17 +81,19 @@ public function get(PersistentCollection $collection, mixed $index): object|null { $mapping = $collection->getMapping(); - if (! isset($mapping['indexBy'])) { + if (! isset($mapping->indexBy)) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); } - $persister = $this->uow->getEntityPersister($mapping['targetEntity']); - $mappedKey = $mapping['isOwningSide'] - ? $mapping['inversedBy'] - : $mapping['mappedBy']; + $persister = $this->uow->getEntityPersister($mapping->targetEntity); + $mappedKey = $mapping->isOwningSide() + ? $mapping->inversedBy + : $mapping->mappedBy; + + assert($mappedKey !== null); return $persister->load( - [$mappedKey => $collection->getOwner(), $mapping['indexBy'] => $index], + [$mappedKey => $collection->getOwner(), $mapping->indexBy => $index], null, $mapping, [], @@ -105,16 +109,18 @@ public function count(PersistentCollection $collection): int $types = []; $mapping = $collection->getMapping(); $id = $this->uow->getEntityIdentifier($collection->getOwner()); - $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); - $association = ! $mapping['isOwningSide'] - ? $targetClass->associationMappings[$mapping['mappedBy']] + $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); + $association = ! $mapping->isOwningSide() + ? $targetClass->associationMappings[$mapping->mappedBy] : $mapping; + assert($association->isManyToManyOwningSide()); + $joinTableName = $this->quoteStrategy->getJoinTableName($association, $sourceClass, $this->platform); - $joinColumns = ! $mapping['isOwningSide'] - ? $association['joinTable']['inverseJoinColumns'] - : $association['joinTable']['joinColumns']; + $joinColumns = ! $mapping->isOwningSide() + ? $association->joinTable['inverseJoinColumns'] + : $association->joinTable['joinColumns']; foreach ($joinColumns as $joinColumn) { $columnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $sourceClass, $this->platform); @@ -169,7 +175,7 @@ public function containsKey(PersistentCollection $collection, mixed $key): bool { $mapping = $collection->getMapping(); - if (! isset($mapping['indexBy'])) { + if (! isset($mapping->indexBy)) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); } @@ -210,21 +216,21 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri $owner = $collection->getOwner(); $ownerMetadata = $this->em->getClassMetadata($owner::class); $id = $this->uow->getEntityIdentifier($owner); - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); $onConditions = $this->getOnConditionSQL($mapping); $whereClauses = $params = []; $paramTypes = []; - if (! $mapping['isOwningSide']) { + if (! $mapping->isOwningSide()) { $associationSourceClass = $targetClass; - $mapping = $targetClass->associationMappings[$mapping['mappedBy']]; + $mapping = $targetClass->associationMappings[$mapping->mappedBy]; $sourceRelationMode = 'relationToTargetKeyColumns'; } else { $associationSourceClass = $ownerMetadata; $sourceRelationMode = 'relationToSourceKeyColumns'; } - foreach ($mapping[$sourceRelationMode] as $key => $value) { + foreach ($mapping->$sourceRelationMode as $key => $value) { $whereClauses[] = sprintf('t.%s = ?', $key); $params[] = $ownerMetadata->containsForeignIdentifier ? $id[$ownerMetadata->getFieldForColumn($value)] @@ -285,7 +291,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri */ public function getFilterSql(AssociationMapping $mapping): array { - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); $rootClass = $this->em->getClassMetadata($targetClass->rootEntityName); $filterSql = $this->generateFilterConditionSQL($rootClass, 'te'); @@ -333,14 +339,16 @@ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, strin */ protected function getOnConditionSQL(AssociationMapping $mapping): array { - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); - $association = ! $mapping['isOwningSide'] - ? $targetClass->associationMappings[$mapping['mappedBy']] + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); + $association = ! $mapping->isOwningSide() + ? $targetClass->associationMappings[$mapping->mappedBy] : $mapping; - $joinColumns = $mapping['isOwningSide'] - ? $association['joinTable']['inverseJoinColumns'] - : $association['joinTable']['joinColumns']; + assert($association->isManyToManyOwningSide()); + + $joinColumns = $mapping->isOwningSide() + ? $association->joinTable['inverseJoinColumns'] + : $association->joinTable['joinColumns']; $conditions = []; @@ -356,12 +364,13 @@ protected function getOnConditionSQL(AssociationMapping $mapping): array protected function getDeleteSQL(PersistentCollection $collection): string { - $columns = []; - $mapping = $collection->getMapping(); + $columns = []; + $mapping = $collection->getMapping(); + assert($mapping->isManyToManyOwningSide()); $class = $this->em->getClassMetadata($collection->getOwner()::class); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); - foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { + foreach ($mapping->joinTable['joinColumns'] as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } @@ -376,19 +385,20 @@ protected function getDeleteSQL(PersistentCollection $collection): string */ protected function getDeleteSQLParameters(PersistentCollection $collection): array { - $mapping = $collection->getMapping(); + $mapping = $collection->getMapping(); + assert($mapping->isManyToManyOwningSide()); $identifier = $this->uow->getEntityIdentifier($collection->getOwner()); // Optimization for single column identifier - if (count($mapping['relationToSourceKeyColumns']) === 1) { + if (count($mapping->relationToSourceKeyColumns) === 1) { return [reset($identifier)]; } // Composite identifier - $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); + $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); $params = []; - foreach ($mapping['relationToSourceKeyColumns'] as $columnName => $refColumnName) { + foreach ($mapping->relationToSourceKeyColumns as $columnName => $refColumnName) { $params[] = isset($sourceClass->fieldNames[$refColumnName]) ? $identifier[$sourceClass->fieldNames[$refColumnName]] : $identifier[$sourceClass->getFieldForColumn($refColumnName)]; @@ -406,18 +416,19 @@ protected function getDeleteSQLParameters(PersistentCollection $collection): arr */ protected function getDeleteRowSQL(PersistentCollection $collection): array { - $mapping = $collection->getMapping(); - $class = $this->em->getClassMetadata($mapping['sourceEntity']); - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $mapping = $collection->getMapping(); + assert($mapping->isManyToManyOwningSide()); + $class = $this->em->getClassMetadata($mapping->sourceEntity); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); $columns = []; $types = []; - foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { + foreach ($mapping->joinTable['joinColumns'] as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $class, $this->em); } - foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) { + foreach ($mapping->joinTable['inverseJoinColumns'] as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); } @@ -452,18 +463,19 @@ protected function getDeleteRowSQLParameters(PersistentCollection $collection, o */ protected function getInsertRowSQL(PersistentCollection $collection): array { - $columns = []; - $types = []; - $mapping = $collection->getMapping(); - $class = $this->em->getClassMetadata($mapping['sourceEntity']); - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $columns = []; + $types = []; + $mapping = $collection->getMapping(); + assert($mapping->isManyToManyOwningSide()); + $class = $this->em->getClassMetadata($mapping->sourceEntity); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); - foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { + foreach ($mapping->joinTable['joinColumns'] as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $class, $this->em); } - foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) { + foreach ($mapping->joinTable['inverseJoinColumns'] as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); } @@ -517,7 +529,7 @@ private function collectJoinTableColumnParameters( } foreach ($mapping->joinTableColumns as $joinTableColumn) { - $isRelationToSource = isset($mapping['relationToSourceKeyColumns'][$joinTableColumn]); + $isRelationToSource = isset($mapping->relationToSourceKeyColumns[$joinTableColumn]); if (! $isComposite) { $params[] = $isRelationToSource ? array_pop($identifier1) : array_pop($identifier2); @@ -526,12 +538,12 @@ private function collectJoinTableColumnParameters( } if ($isRelationToSource) { - $params[] = $identifier1[$class1->getFieldForColumn($mapping['relationToSourceKeyColumns'][$joinTableColumn])]; + $params[] = $identifier1[$class1->getFieldForColumn($mapping->relationToSourceKeyColumns[$joinTableColumn])]; continue; } - $params[] = $identifier2[$class2->getFieldForColumn($mapping['relationToTargetKeyColumns'][$joinTableColumn])]; + $params[] = $identifier2[$class2->getFieldForColumn($mapping->relationToTargetKeyColumns[$joinTableColumn])]; } return $params; @@ -554,20 +566,24 @@ private function getJoinTableRestrictionsWithKey( ): array { $filterMapping = $collection->getMapping(); $mapping = $filterMapping; - $indexBy = $mapping['indexBy']; - $id = $this->uow->getEntityIdentifier($collection->getOwner()); - $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); - - if (! $mapping['isOwningSide']) { - $associationSourceClass = $this->em->getClassMetadata($mapping['targetEntity']); - $mapping = $associationSourceClass->associationMappings[$mapping['mappedBy']]; - $joinColumns = $mapping['joinTable']['joinColumns']; - $sourceRelationMode = 'relationToTargetKeyColumns'; - $targetRelationMode = 'relationToSourceKeyColumns'; + assert($mapping->isManyToMany()); + $indexBy = $mapping->indexBy; + assert($indexBy !== null); + $id = $this->uow->getEntityIdentifier($collection->getOwner()); + $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); + + if (! $mapping->isOwningSide()) { + $associationSourceClass = $this->em->getClassMetadata($mapping->targetEntity); + $mapping = $associationSourceClass->associationMappings[$mapping->mappedBy]; + assert($mapping->isManyToManyOwningSide()); + $joinColumns = $mapping->joinTable['joinColumns']; + $sourceRelationMode = 'relationToTargetKeyColumns'; + $targetRelationMode = 'relationToSourceKeyColumns'; } else { - $associationSourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); - $joinColumns = $mapping['joinTable']['inverseJoinColumns']; + assert($mapping->isManyToManyOwningSide()); + $associationSourceClass = $this->em->getClassMetadata($mapping->sourceEntity); + $joinColumns = $mapping->joinTable['inverseJoinColumns']; $sourceRelationMode = 'relationToSourceKeyColumns'; $targetRelationMode = 'relationToTargetKeyColumns'; } @@ -595,17 +611,16 @@ private function getJoinTableRestrictionsWithKey( $types[] = PersisterHelper::getTypeOfColumn($columnName, $targetClass, $this->em); } - assert($mapping->isManyToManyOwningSide()); foreach ($mapping->joinTableColumns as $joinTableColumn) { - if (isset($mapping[$sourceRelationMode][$joinTableColumn])) { - $column = $mapping[$sourceRelationMode][$joinTableColumn]; + if (isset($mapping->{$sourceRelationMode}[$joinTableColumn])) { + $column = $mapping->{$sourceRelationMode}[$joinTableColumn]; $whereClauses[] = 't.' . $joinTableColumn . ' = ?'; $params[] = $sourceClass->containsForeignIdentifier ? $id[$sourceClass->getFieldForColumn($column)] : $id[$sourceClass->fieldNames[$column]]; $types[] = PersisterHelper::getTypeOfColumn($column, $sourceClass, $this->em); } elseif (! $joinNeeded) { - $column = $mapping[$targetRelationMode][$joinTableColumn]; + $column = $mapping->{$targetRelationMode}[$joinTableColumn]; $whereClauses[] = 't.' . $joinTableColumn . ' = ?'; $params[] = $key; @@ -644,15 +659,15 @@ private function getJoinTableRestrictions( $mapping = $filterMapping; if (! $mapping->isOwningSide()) { - $sourceClass = $this->em->getClassMetadata($mapping['targetEntity']); - $targetClass = $this->em->getClassMetadata($mapping['sourceEntity']); + $sourceClass = $this->em->getClassMetadata($mapping->targetEntity); + $targetClass = $this->em->getClassMetadata($mapping->sourceEntity); $sourceId = $this->uow->getEntityIdentifier($element); $targetId = $this->uow->getEntityIdentifier($collection->getOwner()); $mapping = $sourceClass->associationMappings[$mapping['mappedBy']]; } else { - $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); $sourceId = $this->uow->getEntityIdentifier($collection->getOwner()); $targetId = $this->uow->getEntityIdentifier($element); } @@ -666,8 +681,8 @@ private function getJoinTableRestrictions( foreach ($mapping->joinTableColumns as $joinTableColumn) { $whereClauses[] = ($addFilters ? 't.' : '') . $joinTableColumn . ' = ?'; - if (isset($mapping['relationToTargetKeyColumns'][$joinTableColumn])) { - $targetColumn = $mapping['relationToTargetKeyColumns'][$joinTableColumn]; + if (isset($mapping->relationToTargetKeyColumns[$joinTableColumn])) { + $targetColumn = $mapping->relationToTargetKeyColumns[$joinTableColumn]; $params[] = $targetId[$targetClass->getFieldForColumn($targetColumn)]; $types[] = PersisterHelper::getTypeOfColumn($targetColumn, $targetClass, $this->em); @@ -675,7 +690,7 @@ private function getJoinTableRestrictions( } // relationToSourceKeyColumns - $targetColumn = $mapping['relationToSourceKeyColumns'][$joinTableColumn]; + $targetColumn = $mapping->relationToSourceKeyColumns[$joinTableColumn]; $params[] = $sourceId[$sourceClass->getFieldForColumn($targetColumn)]; $types[] = PersisterHelper::getTypeOfColumn($targetColumn, $sourceClass, $this->em); } diff --git a/phpstan.neon b/phpstan.neon index 84f3f5ebcc0..834c32118b7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -30,7 +30,7 @@ parameters: path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php - - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping\\:\\:\\$joinTableColumns\\.$#" + message: "#^Access to an undefined property .*Mapping\\:\\:\\$(joinTableColumns|relationTo(Target|Source)KeyColumns|joinTable|indexBy)\\.$#" path: lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php - From f171d49dc06689193fc123ddffd47efe058b7793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 20 Apr 2023 09:06:17 +0200 Subject: [PATCH 253/475] Move $(sourceToTarget|targetToSource)KeyColumns down These properties can be made non nullable if we move them down to the 2 owning side classes that actually use them. --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 2 +- .../Mapping/ManyToOneAssociationMapping.php | 8 ++++ .../ORM/Mapping/OneToOneOwningSideMapping.php | 8 ++++ .../ORM/Mapping/ToOneAssociationMapping.php | 22 ----------- .../Entity/JoinedSubclassPersister.php | 2 - lib/Doctrine/ORM/Query/SqlWalker.php | 10 ++--- .../ManyToOneAssociationMappingTest.php | 6 ++- .../Mapping/OneToOneOwningSideMappingTest.php | 6 ++- .../Mapping/ToOneAssociationMappingTest.php | 37 ------------------- 9 files changed, 32 insertions(+), 69 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Mapping/ToOneAssociationMappingTest.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 80eccdb24f9..ca679e907e7 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1726,7 +1726,7 @@ public function setAssociationOverride(string $fieldName, array $overrideMapping switch ($mapping['type']) { case self::ONE_TO_ONE: case self::MANY_TO_ONE: - $mapping['sourceToTargetKeyColumns'] = null; + $mapping['sourceToTargetKeyColumns'] = []; break; case self::MANY_TO_MANY: $mapping['relationToSourceKeyColumns'] = []; diff --git a/lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php index 501f66b5893..fe95613d576 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php @@ -9,6 +9,12 @@ */ final class ManyToOneAssociationMapping extends ToOneAssociationMapping implements AssociationOwningSideMapping { + /** @var array */ + public array $sourceToTargetKeyColumns = []; + + /** @var array */ + public array $targetToSourceKeyColumns = []; + /** @var list */ public array $joinColumns = []; @@ -18,6 +24,8 @@ public function __sleep(): array $serialized = parent::__sleep(); $serialized[] = 'joinColumns'; + $serialized[] = 'sourceToTargetKeyColumns'; + $serialized[] = 'targetToSourceKeyColumns'; return $serialized; } diff --git a/lib/Doctrine/ORM/Mapping/OneToOneOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/OneToOneOwningSideMapping.php index 7b8f1b8bc93..b7e9f626bc4 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOneOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/OneToOneOwningSideMapping.php @@ -6,6 +6,12 @@ final class OneToOneOwningSideMapping extends OneToOneAssociationMapping implements AssociationOwningSideMapping { + /** @var array */ + public array $sourceToTargetKeyColumns = []; + + /** @var array */ + public array $targetToSourceKeyColumns = []; + /** @var list */ public array $joinColumns = []; @@ -15,6 +21,8 @@ public function __sleep(): array $serialized = parent::__sleep(); $serialized[] = 'joinColumns'; + $serialized[] = 'sourceToTargetKeyColumns'; + $serialized[] = 'targetToSourceKeyColumns'; return $serialized; } diff --git a/lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php index 5e8b74e4315..1dcf4768215 100644 --- a/lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php @@ -13,12 +13,6 @@ abstract class ToOneAssociationMapping extends AssociationMapping { - /** @var array|null */ - public array|null $sourceToTargetKeyColumns = null; - - /** @var array|null */ - public array|null $targetToSourceKeyColumns = null; - /** * @param array $mappingArray * @psalm-param array{ @@ -171,20 +165,4 @@ public function toArray(): array return $array; } - - /** @return list */ - public function __sleep(): array - { - $serialized = parent::__sleep(); - - if ($this->sourceToTargetKeyColumns !== null) { - $serialized[] = 'sourceToTargetKeyColumns'; - } - - if ($this->targetToSourceKeyColumns !== null) { - $serialized[] = 'targetToSourceKeyColumns'; - } - - return $serialized; - } } diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 9edde38d8f3..514fbd3c91f 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -14,7 +14,6 @@ use Doctrine\ORM\Utility\PersisterHelper; use function array_combine; -use function assert; use function implode; /** @@ -476,7 +475,6 @@ protected function getInsertColumnList(): array if (isset($this->class->associationMappings[$name])) { $assoc = $this->class->associationMappings[$name]; if ($assoc->isToOneOwningSide()) { - assert($assoc->targetToSourceKeyColumns !== null); foreach ($assoc->targetToSourceKeyColumns as $sourceCol) { $columns[] = $sourceCol; } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index f0183298688..05c76b31bdc 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -597,12 +597,13 @@ public function walkPathExpression(AST\PathExpression $pathExpr): string } $assoc = $class->associationMappings[$fieldName]; - assert($assoc->isToOne()); if (! $assoc->isOwningSide()) { throw QueryException::associationPathInverseSideNotSupported($pathExpr); } + assert($assoc->isToOneOwningSide()); + // COMPOSITE KEYS NOT (YET?) SUPPORTED if (count($assoc['sourceToTargetKeyColumns']) > 1) { throw QueryException::associationPathCompositeKeyNotSupported(); @@ -612,7 +613,6 @@ public function walkPathExpression(AST\PathExpression $pathExpr): string $sql .= $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.'; } - assert($assoc->targetToSourceKeyColumns !== null); $sql .= reset($assoc->targetToSourceKeyColumns); break; @@ -799,17 +799,17 @@ public function walkIndexBy(AST\IndexBy $indexBy): void } $association = $class->associationMappings[$fieldName]; - assert($association->isToOne()); if (! $association->isOwningSide()) { throw QueryException::associationPathInverseSideNotSupported($pathExpression); } - if (count($association['sourceToTargetKeyColumns']) > 1) { + assert($association->isToOneOwningSide()); + + if (count($association->sourceToTargetKeyColumns) > 1) { throw QueryException::associationPathCompositeKeyNotSupported(); } - assert($association->targetToSourceKeyColumns !== null); $field = reset($association->targetToSourceKeyColumns); break; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php index 02831a3b198..8e9260b1943 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php @@ -22,11 +22,15 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->sourceToTargetKeyColumns = ['foo' => 'bar']; + $mapping->targetToSourceKeyColumns = ['bar' => 'foo']; $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof ManyToOneAssociationMapping); self::assertCount(1, $resurrectedMapping->joinColumns); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->sourceToTargetKeyColumns); + self::assertSame(['bar' => 'foo'], $resurrectedMapping->targetToSourceKeyColumns); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php index fb7c9cc461a..eb246b99802 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php @@ -22,11 +22,15 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->sourceToTargetKeyColumns = ['foo' => 'bar']; + $mapping->targetToSourceKeyColumns = ['bar' => 'foo']; $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof OneToOneOwningSideMapping); self::assertCount(1, $resurrectedMapping->joinColumns); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->sourceToTargetKeyColumns); + self::assertSame(['bar' => 'foo'], $resurrectedMapping->targetToSourceKeyColumns); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ToOneAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ToOneAssociationMappingTest.php deleted file mode 100644 index 32858ea577c..00000000000 --- a/tests/Doctrine/Tests/ORM/Mapping/ToOneAssociationMappingTest.php +++ /dev/null @@ -1,37 +0,0 @@ -sourceToTargetKeyColumns = ['foo' => 'bar']; - $mapping->targetToSourceKeyColumns = ['bar' => 'foo']; - - $resurrectedMapping = unserialize(serialize($mapping)); - assert($resurrectedMapping instanceof ToOneAssociationMapping); - - self::assertSame(['foo' => 'bar'], $resurrectedMapping->sourceToTargetKeyColumns); - self::assertSame(['bar' => 'foo'], $resurrectedMapping->targetToSourceKeyColumns); - } -} - -class MyToOneAssociationMapping extends ToOneAssociationMapping -{ -} From 68571184caf857d765c17024348cf18ab7d3c4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 20 Apr 2023 20:53:30 +0200 Subject: [PATCH 254/475] Become strict about notices and warnings Since PHPUnit 10, it is possible to display details when notices and warnings happen, and to fail the test suite on notice. failOnWarning is older than that. --- phpunit.xml.dist | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index da3b72933c2..67776e6bb75 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,6 +14,10 @@ Date: Thu, 20 Apr 2023 00:02:50 +0200 Subject: [PATCH 255/475] Migrate basic entity persister to the object API of association mapping --- .../ORM/Mapping/AssociationMapping.php | 6 + lib/Doctrine/ORM/Mapping/ClassMetadata.php | 2 +- .../Entity/BasicEntityPersister.php | 226 ++++++++++-------- lib/Doctrine/ORM/Tools/SchemaValidator.php | 4 +- lib/Doctrine/ORM/Utility/PersisterHelper.php | 2 +- phpstan.neon | 18 +- psalm-baseline.xml | 4 +- 7 files changed, 149 insertions(+), 113 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index bd6a1b77ace..af0a48e993f 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -179,6 +179,12 @@ final public function isToMany(): bool return $this instanceof ToManyAssociationMapping; } + /** @psalm-assert-if-true OneToOneOwningSideMapping $this */ + final public function isOneToOneOwningSide(): bool + { + return $this->isOneToOne() && $this->isOwningSide(); + } + /** @psalm-assert-if-true OneToOneOwningSideMapping|ManyToOneAssociationMapping $this */ final public function isToOneOwningSide(): bool { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index ca679e907e7..435c5f66a77 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -438,7 +438,7 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable * ) * * - * @psalm-var array + * @psalm-var array */ public array $associationMappings = []; diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 56efbe8a4c1..02d9a6c481c 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -19,7 +19,9 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\JoinColumnMapping; use Doctrine\ORM\Mapping\MappingException; +use Doctrine\ORM\Mapping\OneToManyAssociationMapping; use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\PersistentCollection; @@ -434,14 +436,16 @@ final protected function updateTable( continue; } + assert($this->class->associationMappings[$idField]->isToOneOwningSide()); + $params[] = $identifier[$idField]; $where[] = $this->quoteStrategy->getJoinColumnName( - $this->class->associationMappings[$idField]['joinColumns'][0], + $this->class->associationMappings[$idField]->joinColumns[0], $this->class, $this->platform, ); - $targetMapping = $this->em->getClassMetadata($this->class->associationMappings[$idField]['targetEntity']); + $targetMapping = $this->em->getClassMetadata($this->class->associationMappings[$idField]->targetEntity); $targetType = PersisterHelper::getTypeOfField($targetMapping->identifier[0], $targetMapping, $this->em); if ($targetType === []) { @@ -494,32 +498,35 @@ final protected function updateTable( protected function deleteJoinTableRecords(array $identifier, array $types): void { foreach ($this->class->associationMappings as $mapping) { - if ($mapping['type'] !== ClassMetadata::MANY_TO_MANY) { + if (! $mapping->isManyToMany()) { continue; } // @Todo this only covers scenarios with no inheritance or of the same level. Is there something // like self-referential relationship between different levels of an inheritance hierarchy? I hope not! - $selfReferential = ($mapping['targetEntity'] === $mapping['sourceEntity']); + $selfReferential = ($mapping->targetEntity === $mapping->sourceEntity); $class = $this->class; $association = $mapping; $otherColumns = []; $otherKeys = []; $keys = []; - if (! $mapping['isOwningSide']) { - $class = $this->em->getClassMetadata($mapping['targetEntity']); - $association = $class->associationMappings[$mapping['mappedBy']]; + if (! $mapping->isOwningSide()) { + assert(isset($mapping->mappedBy)); + $class = $this->em->getClassMetadata($mapping->targetEntity); + $association = $class->associationMappings[$mapping->mappedBy]; } - $joinColumns = $mapping['isOwningSide'] - ? $association['joinTable']['joinColumns'] - : $association['joinTable']['inverseJoinColumns']; + assert($association->isManyToManyOwningSide()); + + $joinColumns = $mapping->isOwningSide() + ? $association->joinTable['joinColumns'] + : $association->joinTable['inverseJoinColumns']; if ($selfReferential) { - $otherColumns = ! $mapping['isOwningSide'] - ? $association['joinTable']['joinColumns'] - : $association['joinTable']['inverseJoinColumns']; + $otherColumns = ! $mapping->isOwningSide() + ? $association->joinTable['joinColumns'] + : $association->joinTable['inverseJoinColumns']; } foreach ($joinColumns as $joinColumn) { @@ -530,7 +537,7 @@ protected function deleteJoinTableRecords(array $identifier, array $types): void $otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } - if (isset($mapping['isOnDeleteCascade'])) { + if (isset($mapping->isOnDeleteCascade)) { continue; } @@ -648,10 +655,10 @@ protected function prepareUpdateData(object $entity, bool $isInsert = false): ar $newValId = $uow->getEntityIdentifier($newVal); } - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); $owningTable = $this->getOwningTable($field); - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $sourceColumn = $joinColumn['name']; $targetColumn = $joinColumn['referencedColumnName']; $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); @@ -732,41 +739,43 @@ public function loadById(array $identifier, object|null $entity = null): object| */ public function loadOneToOneEntity(AssociationMapping $assoc, object $sourceEntity, array $identifier = []): object|null { - $foundEntity = $this->em->getUnitOfWork()->tryGetById($identifier, $assoc['targetEntity']); + $foundEntity = $this->em->getUnitOfWork()->tryGetById($identifier, $assoc->targetEntity); if ($foundEntity !== false) { return $foundEntity; } - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); - if ($assoc['isOwningSide']) { - $isInverseSingleValued = $assoc['inversedBy'] && ! $targetClass->isCollectionValuedAssociation($assoc['inversedBy']); + if ($assoc->isOwningSide()) { + $isInverseSingleValued = $assoc->inversedBy && ! $targetClass->isCollectionValuedAssociation($assoc->inversedBy); // Mark inverse side as fetched in the hints, otherwise the UoW would // try to load it in a separate query (remember: to-one inverse sides can not be lazy). $hints = []; if ($isInverseSingleValued) { - $hints['fetched']['r'][$assoc['inversedBy']] = true; + $hints['fetched']['r'][$assoc->inversedBy] = true; } $targetEntity = $this->load($identifier, null, $assoc, $hints); // Complete bidirectional association, if necessary if ($targetEntity !== null && $isInverseSingleValued) { - $targetClass->reflFields[$assoc['inversedBy']]->setValue($targetEntity, $sourceEntity); + $targetClass->reflFields[$assoc->inversedBy]->setValue($targetEntity, $sourceEntity); } return $targetEntity; } - $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); - $owningAssoc = $targetClass->getAssociationMapping($assoc['mappedBy']); + assert(isset($assoc->mappedBy)); + $sourceClass = $this->em->getClassMetadata($assoc->sourceEntity); + $owningAssoc = $targetClass->getAssociationMapping($assoc->mappedBy); + assert($owningAssoc->isOneToOneOwningSide()); $computedIdentifier = []; // TRICKY: since the association is specular source and target are flipped - foreach ($owningAssoc['targetToSourceKeyColumns'] as $sourceKeyColumn => $targetKeyColumn) { + foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) { if (! isset($sourceClass->fieldNames[$sourceKeyColumn])) { throw MappingException::joinColumnMustPointToMappedField( $sourceClass->name, @@ -781,7 +790,7 @@ public function loadOneToOneEntity(AssociationMapping $assoc, object $sourceEnti $targetEntity = $this->load($computedIdentifier, null, $assoc); if ($targetEntity !== null) { - $targetClass->setFieldValue($targetEntity, $assoc['mappedBy'], $sourceEntity); + $targetClass->setFieldValue($targetEntity, $assoc->mappedBy, $sourceEntity); } return $targetEntity; @@ -906,9 +915,9 @@ private function loadArrayFromResult(AssociationMapping $assoc, Result $stmt): a $rsm = $this->currentPersisterContext->rsm; $hints = [UnitOfWork::HINT_DEFEREAGERLOAD => true]; - if (isset($assoc['indexBy'])) { + if (isset($assoc->indexBy)) { $rsm = clone $this->currentPersisterContext->rsm; // this is necessary because the "default rsm" should be changed. - $rsm->addIndexBy('r', $assoc['indexBy']); + $rsm->addIndexBy('r', $assoc->indexBy); } return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); @@ -930,9 +939,9 @@ private function loadCollectionFromStatement( 'collection' => $coll, ]; - if (isset($assoc['indexBy'])) { + if (isset($assoc->indexBy)) { $rsm = clone $this->currentPersisterContext->rsm; // this is necessary because the "default rsm" should be changed. - $rsm->addIndexBy('r', $assoc['indexBy']); + $rsm->addIndexBy('r', $assoc->indexBy); } return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); @@ -957,20 +966,23 @@ private function getManyToManyStatement( ): Result { $this->switchPersisterContext($offset, $limit); - $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); + $sourceClass = $this->em->getClassMetadata($assoc->sourceEntity); $class = $sourceClass; $association = $assoc; $criteria = []; $parameters = []; - if (! $assoc['isOwningSide']) { - $class = $this->em->getClassMetadata($assoc['targetEntity']); - $association = $class->associationMappings[$assoc['mappedBy']]; + if (! $assoc->isOwningSide()) { + assert(isset($assoc->mappedBy)); + $class = $this->em->getClassMetadata($assoc->targetEntity); + $association = $class->associationMappings[$assoc->mappedBy]; } - $joinColumns = $assoc['isOwningSide'] - ? $association['joinTable']['joinColumns'] - : $association['joinTable']['inverseJoinColumns']; + assert($association->isManyToManyOwningSide()); + + $joinColumns = $assoc->isOwningSide() + ? $association->joinTable['joinColumns'] + : $association->joinTable['inverseJoinColumns']; $quotedJoinTable = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); @@ -985,7 +997,7 @@ private function getManyToManyStatement( if (isset($sourceClass->associationMappings[$field])) { $value = $this->em->getUnitOfWork()->getEntityIdentifier($value); - $value = $value[$this->em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]]; + $value = $value[$this->em->getClassMetadata($sourceClass->associationMappings[$field]->targetEntity)->identifier[0]]; } break; @@ -1034,8 +1046,8 @@ public function getSelectSQL( $joinSql = $this->getSelectManyToManyJoinSQL($assoc); } - if (isset($assoc['orderBy'])) { - $orderBy = $assoc['orderBy']; + if ($assoc !== null && isset($assoc->orderBy)) { + $orderBy = $assoc->orderBy; } if ($orderBy) { @@ -1131,15 +1143,18 @@ final protected function getOrderBySQL(array $orderBy, string $baseTableAlias): } if (isset($this->class->associationMappings[$fieldName])) { - if (! $this->class->associationMappings[$fieldName]['isOwningSide']) { + $association = $this->class->associationMappings[$fieldName]; + if (! $association->isOwningSide()) { throw InvalidFindByCall::fromInverseSideUsage($this->class->name, $fieldName); } - $tableAlias = isset($this->class->associationMappings[$fieldName]['inherited']) - ? $this->getSQLTableAlias($this->class->associationMappings[$fieldName]['inherited']) + assert($association->isToOneOwningSide()); + + $tableAlias = isset($association->inherited) + ? $this->getSQLTableAlias($association->inherited) : $baseTableAlias; - foreach ($this->class->associationMappings[$fieldName]['joinColumns'] as $joinColumn) { + foreach ($association->joinColumns as $joinColumn) { $columnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); $orderByList[] = $tableAlias . '.' . $columnName . ' ' . $orientation; } @@ -1186,8 +1201,8 @@ protected function getSelectColumnsSQL(): string $columnList[] = $assocColumnSQL; } - $isAssocToOneInverseSide = $assoc->isToOne() && ! $assoc['isOwningSide']; - $isAssocFromOneEager = ! $assoc->isManyToMany() && $assoc['fetch'] === ClassMetadata::FETCH_EAGER; + $isAssocToOneInverseSide = $assoc->isToOne() && ! $assoc->isOwningSide(); + $isAssocFromOneEager = ! $assoc->isManyToMany() && $assoc->fetch === ClassMetadata::FETCH_EAGER; if (! ($isAssocFromOneEager || $isAssocToOneInverseSide)) { continue; @@ -1197,14 +1212,14 @@ protected function getSelectColumnsSQL(): string continue; } - $eagerEntity = $this->em->getClassMetadata($assoc['targetEntity']); + $eagerEntity = $this->em->getClassMetadata($assoc->targetEntity); if ($eagerEntity->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) { continue; // now this is why you shouldn't use inheritance } $assocAlias = 'e' . ($eagerAliasCounter++); - $this->currentPersisterContext->rsm->addJoinedEntityResult($assoc['targetEntity'], $assocAlias, 'r', $assocField); + $this->currentPersisterContext->rsm->addJoinedEntityResult($assoc->targetEntity, $assocAlias, 'r', $assocField); foreach ($eagerEntity->fieldNames as $field) { $columnList[] = $this->getSelectColumnSQL($field, $eagerEntity, $assocAlias); @@ -1226,26 +1241,29 @@ protected function getSelectColumnsSQL(): string $association = $assoc; $joinCondition = []; - if (isset($assoc['indexBy'])) { - $this->currentPersisterContext->rsm->addIndexBy($assocAlias, $assoc['indexBy']); + if (isset($assoc->indexBy)) { + $this->currentPersisterContext->rsm->addIndexBy($assocAlias, $assoc->indexBy); } - if (! $assoc['isOwningSide']) { - $eagerEntity = $this->em->getClassMetadata($assoc['targetEntity']); - $association = $eagerEntity->getAssociationMapping($assoc['mappedBy']); + if (! $assoc->isOwningSide()) { + assert(isset($assoc->mappedBy)); + $eagerEntity = $this->em->getClassMetadata($assoc->targetEntity); + $association = $eagerEntity->getAssociationMapping($assoc->mappedBy); } + assert($association->isToOneOwningSide()); + $joinTableAlias = $this->getSQLTableAlias($eagerEntity->name, $assocAlias); $joinTableName = $this->quoteStrategy->getTableName($eagerEntity, $this->platform); - if ($assoc['isOwningSide']) { - $tableAlias = $this->getSQLTableAlias($association['targetEntity'], $assocAlias); - $this->currentPersisterContext->selectJoinSql .= ' ' . $this->getJoinSQLForJoinColumns($association['joinColumns']); + if ($assoc->isOwningSide()) { + $tableAlias = $this->getSQLTableAlias($association->targetEntity, $assocAlias); + $this->currentPersisterContext->selectJoinSql .= ' ' . $this->getJoinSQLForJoinColumns($association->joinColumns); - foreach ($association['joinColumns'] as $joinColumn) { + foreach ($association->joinColumns as $joinColumn) { $sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); $targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->class, $this->platform); - $joinCondition[] = $this->getSQLTableAlias($association['sourceEntity']) + $joinCondition[] = $this->getSQLTableAlias($association->sourceEntity) . '.' . $sourceCol . ' = ' . $tableAlias . '.' . $targetCol; } @@ -1257,12 +1275,12 @@ protected function getSelectColumnsSQL(): string } else { $this->currentPersisterContext->selectJoinSql .= ' LEFT JOIN'; - foreach ($association['joinColumns'] as $joinColumn) { + foreach ($association->joinColumns as $joinColumn) { $sourceCol = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); $targetCol = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $this->class, $this->platform); - $joinCondition[] = $this->getSQLTableAlias($association['sourceEntity'], $assocAlias) . '.' . $sourceCol . ' = ' - . $this->getSQLTableAlias($association['targetEntity']) . '.' . $targetCol; + $joinCondition[] = $this->getSQLTableAlias($association->sourceEntity, $assocAlias) . '.' . $sourceCol . ' = ' + . $this->getSQLTableAlias($association->targetEntity) . '.' . $targetCol; } } @@ -1287,11 +1305,11 @@ protected function getSelectColumnAssociationSQL( } $columnList = []; - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); - $isIdentifier = isset($assoc['id']) && $assoc['id'] === true; + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); + $isIdentifier = isset($assoc->id) && $assoc->id === true; $sqlTableAlias = $this->getSQLTableAlias($class->name, ($alias === 'r' ? '' : $alias)); - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); $resultColumnName = $this->getSQLColumnAlias($joinColumn['name']); $type = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); @@ -1314,15 +1332,18 @@ protected function getSelectManyToManyJoinSQL(AssociationMapping $manyToMany): s $association = $manyToMany; $sourceTableAlias = $this->getSQLTableAlias($this->class->name); - if (! $manyToMany['isOwningSide']) { - $targetEntity = $this->em->getClassMetadata($manyToMany['targetEntity']); - $association = $targetEntity->associationMappings[$manyToMany['mappedBy']]; + if (! $manyToMany->isOwningSide()) { + assert(isset($manyToMany->mappedBy)); + $targetEntity = $this->em->getClassMetadata($manyToMany->targetEntity); + $association = $targetEntity->associationMappings[$manyToMany->mappedBy]; } + assert($association->isManyToManyOwningSide()); + $joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->class, $this->platform); - $joinColumns = $manyToMany['isOwningSide'] - ? $association['joinTable']['inverseJoinColumns'] - : $association['joinTable']['joinColumns']; + $joinColumns = $manyToMany->isOwningSide() + ? $association->joinTable['inverseJoinColumns'] + : $association->joinTable['joinColumns']; foreach ($joinColumns as $joinColumn) { $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); @@ -1400,7 +1421,7 @@ protected function getInsertColumnList(): array $assoc = $this->class->associationMappings[$name]; if ($assoc->isToOneOwningSide()) { - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); } } @@ -1620,30 +1641,34 @@ private function getSelectConditionStatementColumnSQL( $class = $this->class; if ($association->isManyToMany()) { - if (! $association['isOwningSide']) { + assert($assoc !== null); + if (! $association->isOwningSide()) { $association = $assoc; } + assert($association->isManyToManyOwningSide()); + $joinTableName = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); - assert($assoc !== null); - $joinColumns = $assoc['isOwningSide'] - ? $association['joinTable']['joinColumns'] - : $association['joinTable']['inverseJoinColumns']; + $joinColumns = $assoc->isOwningSide() + ? $association->joinTable['joinColumns'] + : $association->joinTable['inverseJoinColumns']; foreach ($joinColumns as $joinColumn) { $columns[] = $joinTableName . '.' . $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } } else { - if (! $association['isOwningSide']) { + if (! $association->isOwningSide()) { throw InvalidFindByCall::fromInverseSideUsage( $this->class->name, $field, ); } - $className = $association['inherited'] ?? $this->class->name; + assert($association->isToOneOwningSide()); + + $className = $association->inherited ?? $this->class->name; - foreach ($association['joinColumns'] as $joinColumn) { + foreach ($association->joinColumns as $joinColumn) { $columns[] = $this->getSQLTableAlias($className) . '.' . $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); } } @@ -1691,6 +1716,7 @@ public function getOneToManyCollection( int|null $offset = null, int|null $limit = null, ): array { + assert($assoc instanceof OneToManyAssociationMapping); $this->switchPersisterContext($offset, $limit); $stmt = $this->getOneToManyStatement($assoc, $sourceEntity, $offset, $limit); @@ -1703,6 +1729,7 @@ public function loadOneToManyCollection( object $sourceEntity, PersistentCollection $collection, ): mixed { + assert($assoc instanceof OneToManyAssociationMapping); $stmt = $this->getOneToManyStatement($assoc, $sourceEntity); return $this->loadCollectionFromStatement($assoc, $stmt, $collection); @@ -1710,27 +1737,29 @@ public function loadOneToManyCollection( /** Builds criteria and execute SQL statement to fetch the one to many entities from. */ private function getOneToManyStatement( - AssociationMapping $assoc, + OneToManyAssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, ): Result { $this->switchPersisterContext($offset, $limit); - $criteria = []; - $parameters = []; - $owningAssoc = $this->class->associationMappings[$assoc['mappedBy']]; - $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); - $tableAlias = $this->getSQLTableAlias($owningAssoc['inherited'] ?? $this->class->name); + $criteria = []; + $parameters = []; + assert(isset($assoc->mappedBy)); + $owningAssoc = $this->class->associationMappings[$assoc->mappedBy]; + $sourceClass = $this->em->getClassMetadata($assoc->sourceEntity); + $tableAlias = $this->getSQLTableAlias($owningAssoc->inherited ?? $this->class->name); + assert($owningAssoc->isManyToOne()); - foreach ($owningAssoc['targetToSourceKeyColumns'] as $sourceKeyColumn => $targetKeyColumn) { + foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) { if ($sourceClass->containsForeignIdentifier) { $field = $sourceClass->getFieldForColumn($sourceKeyColumn); $value = $sourceClass->reflFields[$field]->getValue($sourceEntity); if (isset($sourceClass->associationMappings[$field])) { $value = $this->em->getUnitOfWork()->getEntityIdentifier($value); - $value = $value[$this->em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]]; + $value = $value[$this->em->getClassMetadata($sourceClass->associationMappings[$field]->targetEntity)->identifier[0]]; } $criteria[$tableAlias . '.' . $targetKeyColumn] = $value; @@ -1828,16 +1857,22 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar case isset($class->associationMappings[$field]): $assoc = $class->associationMappings[$field]; - $class = $this->em->getClassMetadata($assoc['targetEntity']); + $class = $this->em->getClassMetadata($assoc->targetEntity); - if (! $assoc['isOwningSide']) { - $assoc = $class->associationMappings[$assoc['mappedBy']]; - $class = $this->em->getClassMetadata($assoc['targetEntity']); + if (! $assoc->isOwningSide()) { + assert(isset($assoc->mappedBy)); + $assoc = $class->associationMappings[$assoc->mappedBy]; + $class = $this->em->getClassMetadata($assoc->targetEntity); } - $columns = $assoc->isManyToMany() - ? $assoc['relationToTargetKeyColumns'] - : $assoc['sourceToTargetKeyColumns']; + assert($assoc->isOwningSide()); + + if ($assoc->isManyToManyOwningSide()) { + $columns = $assoc->relationToTargetKeyColumns; + } else { + assert($assoc->isToOneOwningSide() || $assoc->isManyToOne()); + $columns = $assoc->sourceToTargetKeyColumns; + } foreach ($columns as $column) { $types[] = PersisterHelper::getTypeOfColumn($column, $class, $this->em); @@ -1962,8 +1997,7 @@ public function exists(object $entity, Criteria|null $extraConditions = null): b /** * Generates the appropriate join SQL for the given join column. * - * @param array[] $joinColumns The join columns definition of an association. - * @psalm-param array> $joinColumns + * @param list $joinColumns The join columns definition of an association. * * @return string LEFT JOIN if one of the columns is nullable, INNER JOIN otherwise. */ diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index def56a47d83..9222f9ba8a4 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -162,7 +162,7 @@ public function validateClass(ClassMetadata $class): array } if ($assoc->isOwningSide()) { - if ($assoc->isManyToMany()) { + if ($assoc->isManyToManyOwningSide()) { $identifierColumns = $class->getIdentifierColumnNames(); foreach ($assoc['joinTable']['joinColumns'] as $joinColumn) { if (! in_array($joinColumn['referencedColumnName'], $identifierColumns, true)) { @@ -194,7 +194,7 @@ public function validateClass(ClassMetadata $class): array "however '" . implode(', ', array_diff($class->getIdentifierColumnNames(), array_values($assoc['relationToSourceKeyColumns']))) . "' are missing."; } - } elseif ($assoc->isToOne()) { + } elseif ($assoc->isToOneOwningSide()) { $identifierColumns = $targetMetadata->getIdentifierColumnNames(); foreach ($assoc['joinColumns'] as $joinColumn) { if (! in_array($joinColumn['referencedColumnName'], $identifierColumns, true)) { diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index 8f061fe99c2..fc7fe9b0702 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -40,7 +40,7 @@ public static function getTypeOfField(string $fieldName, ClassMetadata $class, E return self::getTypeOfField($assoc['mappedBy'], $em->getClassMetadata($assoc['targetEntity']), $em); } - if ($assoc->isManyToMany()) { + if ($assoc->isManyToManyOwningSide()) { $joinData = $assoc['joinTable']; } else { $joinData = $assoc; diff --git a/phpstan.neon b/phpstan.neon index 834c32118b7..d3bd7dee0cf 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -30,17 +30,15 @@ parameters: path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php - - message: "#^Access to an undefined property .*Mapping\\:\\:\\$(joinTableColumns|relationTo(Target|Source)KeyColumns|joinTable|indexBy)\\.$#" - path: lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php + message: "#^Access to an undefined property .*Mapping\\:\\:\\$(joinColumns|joinTableColumns|(relation|source|target)To(Target|Source)KeyColumns|joinTable|indexBy)\\.$#" + paths: + - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php + - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php + - lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php + - lib/Doctrine/ORM/Query/SqlWalker.php + - lib/Doctrine/ORM/UnitOfWork.php - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\:\\:fromMappingArrayAndName\\(\\) should return Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneAssociationMapping but returns static\\(Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\)\\.$#" path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php - - - - message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$associationMappings \\(array\\\\) does not accept array\\\\.$#" - path: lib/Doctrine/ORM/Mapping/ClassMetadata.php - - - - message: "#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\\\:\\:\\$associationMappings \\(array\\\\) does not accept array\\\\.$#" - path: lib/Doctrine/ORM/Mapping/ClassMetadata.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bd73a88be25..d69ad4504e0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -737,9 +737,7 @@ array ]]> - - $association - + getValue getValue From f7e49a53be4c057a01935b777ece7903c8b575f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 23 Apr 2023 10:34:12 +0200 Subject: [PATCH 256/475] Use valid relationships During a recent refactoring, I had to pick a relationship type for this piece of code, and I chose wrong, because a many-to-one cannot have a mappedBy field. --- tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 1b701d93cd7..d75ca619570 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -14,9 +14,9 @@ use Doctrine\ORM\Mapping\DefaultTypedFieldMapper; use Doctrine\ORM\Mapping\DiscriminatorColumnMapping; use Doctrine\ORM\Mapping\JoinTableMapping; -use Doctrine\ORM\Mapping\ManyToOneAssociationMapping; use Doctrine\ORM\Mapping\MappedSuperclass; use Doctrine\ORM\Mapping\MappingException; +use Doctrine\ORM\Mapping\OneToManyAssociationMapping; use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Persistence\Mapping\StaticReflectionService; @@ -355,13 +355,13 @@ public function testDuplicateAssociationMappingException(): void $cm = new ClassMetadata(CmsUser::class); $cm->initializeReflection(new RuntimeReflectionService()); - $a1 = ManyToOneAssociationMapping::fromMappingArray([ + $a1 = OneToManyAssociationMapping::fromMappingArray([ 'fieldName' => 'foo', 'sourceEntity' => stdClass::class, 'targetEntity' => stdClass::class, 'mappedBy' => 'foo', ]); - $a2 = ManyToOneAssociationMapping::fromMappingArray([ + $a2 = OneToManyAssociationMapping::fromMappingArray([ 'fieldName' => 'foo', 'sourceEntity' => stdClass::class, 'targetEntity' => stdClass::class, From 559e1d139a0cb317adce0670b81f833c2bbcf660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 24 Apr 2023 09:08:37 +0200 Subject: [PATCH 257/475] Improve named constructors' phpdoc They were inconsistently documented. --- lib/Doctrine/ORM/Mapping/JoinTableMapping.php | 11 +++++++++- .../Mapping/ManyToManyOwningSideMapping.php | 11 +++++++++- .../Mapping/OneToManyAssociationMapping.php | 22 +++++++++++++++++-- psalm-baseline.xml | 8 ------- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php index 30283ee9c8a..659b15fcbb7 100644 --- a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php +++ b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php @@ -26,7 +26,16 @@ final class JoinTableMapping implements ArrayAccess public string|null $name = null; - /** @param array{name?: string, quoted?: bool, joinColumns?: mixed[], inverseJoinColumns?: mixed[], schema?: string} $mappingArray */ + /** + * @param mixed[] $mappingArray + * @psalm-param array{ + * name?: string, + * quoted?: bool, + * joinColumns?: mixed[], + * inverseJoinColumns?: mixed[], + * schema?: string + * } $mappingArray + */ public static function fromMappingArray(array $mappingArray): self { $mapping = new self(); diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php index f54493589d0..58e8ee12ff3 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php @@ -35,7 +35,16 @@ public function toArray(): array return $array; } - /** @param mixed[] $mappingArray */ + /** + * @param mixed[] $mappingArray + * @psalm-param array{ + * fieldName: string, + * sourceEntity: class-string, + * targetEntity: class-string, + * joinTable?: mixed[]|null, + * type?: int, + * isOwningSide: bool, ...} $mappingArray + */ public static function fromMappingArrayAndNamingStrategy(array $mappingArray, NamingStrategy $namingStrategy): self { $mapping = parent::fromMappingArray($mappingArray); diff --git a/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php index 6ff2bbf9909..5849a3382b7 100644 --- a/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php @@ -6,7 +6,16 @@ final class OneToManyAssociationMapping extends ToManyAssociationMapping { - /** @param mixed[] $mappingArray */ + /** + * @param mixed[] $mappingArray + * @psalm-param array{ + * fieldName: string, + * sourceEntity: class-string, + * targetEntity: class-string, + * joinTable?: mixed[]|null, + * type?: int, + * isOwningSide: bool, ...} $mappingArray + */ public static function fromMappingArray(array $mappingArray): static { $mapping = parent::fromMappingArray($mappingArray); @@ -18,7 +27,16 @@ public static function fromMappingArray(array $mappingArray): static return $mapping; } - /** @param mixed[] $mappingArray */ + /** + * @param mixed[] $mappingArray + * @psalm-param array{ + * fieldName: string, + * sourceEntity: class-string, + * targetEntity: class-string, + * joinTable?: mixed[]|null, + * type?: int, + * isOwningSide: bool, ...} $mappingArray + */ public static function fromMappingArrayAndName(array $mappingArray, string $name): static { $mapping = self::fromMappingArray($mappingArray); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bd73a88be25..fd5808b66b9 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -591,9 +591,6 @@ - - $mappingArray - $joinTable @@ -604,11 +601,6 @@ new JoinTableMapping() - - - $mappingArray - - $object From fac8d84fdb371ae849246e2743885886606c9f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 2 May 2023 23:36:49 +0200 Subject: [PATCH 258/475] Throw on invalid one to one One to one relationships are not allowed to define a join column. That should be done on the owning side of the relationship. --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 11 +++-------- lib/Doctrine/ORM/Mapping/MappingException.php | 9 +++++++++ psalm-baseline.xml | 12 +----------- .../Tests/ORM/Mapping/ClassMetadataTest.php | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 4e05f48ba55..5a0c5e401c8 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1373,17 +1373,12 @@ protected function _validateAndCompleteAssociationMapping(array $mapping): Assoc switch ($mapping['type']) { case self::ONE_TO_ONE: if (isset($mapping['joinColumns']) && $mapping['joinColumns'] && ! $mapping['isOwningSide']) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10654', - 'JoinColumn configuration is not allowed on the inverse side of one-to-one associations, and will throw a MappingException in Doctrine ORM 3.0', + throw MappingException::joinColumnNotAllowedOnOneToOneInverseSide( + $this->name, + $mapping['fieldName'], ); } - if (isset($mapping['joinColumns']) && $mapping['joinColumns']) { - $mapping['isOwningSide'] = true; - } - return $mapping['isOwningSide'] ? OneToOneOwningSideMapping::fromMappingArrayAndName( $mapping, diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index b172c174c26..6dddeb0dc1d 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -230,6 +230,15 @@ public static function joinColumnMustPointToMappedField(string $className, strin )); } + public static function joinColumnNotAllowedOnOneToOneInverseSide(string $className, string $fieldName): self + { + return new self(sprintf( + '%s#%s is a OneToOne inverse side, which does not allow join columns.', + $className, + $fieldName, + )); + } + /** @param class-string $className */ public static function classIsNotAValidEntityOrMappedSuperClass(string $className): self { diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1ac354fb1c7..3c8268feb7c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -347,6 +347,7 @@ setValue + @@ -359,7 +360,6 @@ $mapping !== false $mapping !== false - array_values @@ -368,15 +368,6 @@ table]]> null - - namingStrategy, - $this->name, - $this->table, - $this->isInheritanceTypeSingleTable(), - )]]> - @@ -730,7 +721,6 @@ array ]]> - getValue getValue diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index d75ca619570..7b50ec54c7f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -331,6 +331,23 @@ public function testSetInvalidVersionMappingThrowsException(): void $cm->setVersionMapping($field); } + public function testItThrowsOnJoinColumnForInverseOneToOne(): void + { + $cm = new ClassMetadata(CmsUser::class); + $cm->initializeReflection(new RuntimeReflectionService()); + + $this->expectException(MappingException::class); + $this->expectExceptionMessage( + 'Doctrine\Tests\Models\CMS\CmsUser#address is a OneToOne inverse side, which does not allow join columns.', + ); + $cm->mapOneToOne([ + 'fieldName' => 'address', + 'targetEntity' => CmsAddress::class, + 'mappedBy' => 'user', + 'joinColumns' => ['non', 'empty', 'list'], + ]); + } + public function testGetSingleIdentifierFieldNameMultipleIdentifierEntityThrowsException(): void { $cm = new ClassMetadata(CmsUser::class); From 3ddb2a845c86310b8ffe656aede8ed39a41876b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 5 May 2023 20:53:34 +0200 Subject: [PATCH 259/475] Make sure unneeded fields are not present Instead of ensuring every mapping array has a mappedBy and an inversedBy field, let us do the opposite, and remove them when they are null. Likewise if there is a joinColumns field, it is useless if null or empty. --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 15 ++++++++++----- .../ORM/Mapping/ClassMetadataBuilderTest.php | 9 --------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 5a0c5e401c8..c4badaab8d0 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -24,6 +24,7 @@ use function array_diff; use function array_intersect; +use function array_key_exists; use function array_keys; use function array_map; use function array_merge; @@ -1259,12 +1260,16 @@ protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping */ protected function _validateAndCompleteAssociationMapping(array $mapping): AssociationMapping { - if (! isset($mapping['mappedBy'])) { - $mapping['mappedBy'] = null; + if (array_key_exists('mappedBy', $mapping) && $mapping['mappedBy'] === null) { + unset($mapping['mappedBy']); + } + + if (array_key_exists('inversedBy', $mapping) && $mapping['inversedBy'] === null) { + unset($mapping['inversedBy']); } - if (! isset($mapping['inversedBy'])) { - $mapping['inversedBy'] = null; + if (array_key_exists('joinColumns', $mapping) && in_array($mapping['joinColumns'], [null, []], true)) { + unset($mapping['joinColumns']); } $mapping['isOwningSide'] = true; // assume owning side until we hit mappedBy @@ -1334,7 +1339,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping): Assoc } // Mandatory and optional attributes for either side - if (! $mapping['mappedBy']) { + if (! isset($mapping['mappedBy'])) { if (isset($mapping['joinTable'])) { if (isset($mapping['joinTable']['name']) && $mapping['joinTable']['name'][0] === '`') { $mapping['joinTable']['name'] = trim($mapping['joinTable']['name'], '`'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 487c67c578d..0b7ba74cb5f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -325,7 +325,6 @@ public function testCreateManyToOne(): void ], ], 'type' => 2, - 'mappedBy' => null, 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, @@ -380,7 +379,6 @@ public function testCreateManyToOneWithIdentity(): void ], ], 'type' => 2, - 'mappedBy' => null, 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, @@ -433,7 +431,6 @@ public function testCreateOneToOne(): void ], ], 'type' => 1, - 'mappedBy' => null, 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, @@ -489,7 +486,6 @@ public function testCreateOneToOneWithIdentity(): void ], ], 'type' => 1, - 'mappedBy' => null, 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, @@ -575,7 +571,6 @@ public function testCreateManyToMany(): void 'name' => 'groups_users', ], 'type' => 8, - 'mappedBy' => null, 'inversedBy' => null, 'isOwningSide' => true, 'isOnDeleteCascade' => true, @@ -630,7 +625,6 @@ public function testCreateOneToMany(): void 'orderBy' => [0 => 'test'], 'indexBy' => 'test', 'type' => 4, - 'inversedBy' => null, 'isOwningSide' => false, 'sourceEntity' => CmsUser::class, 'fetch' => 2, @@ -683,7 +677,6 @@ public function testOrphanRemovalOnCreateOneToOne(): void ], ], 'type' => 1, - 'mappedBy' => null, 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, @@ -718,7 +711,6 @@ public function testOrphanRemovalOnCreateOneToMany(): void 'targetEntity' => CmsGroup::class, 'mappedBy' => 'test', 'type' => 4, - 'inversedBy' => null, 'isOwningSide' => false, 'sourceEntity' => CmsUser::class, 'fetch' => 2, @@ -777,7 +769,6 @@ public function testOrphanRemovalOnManyToMany(): void 'name' => 'cmsuser_cmsgroup', ], 'type' => 8, - 'mappedBy' => null, 'inversedBy' => null, 'isOwningSide' => true, 'sourceEntity' => CmsUser::class, From e18b80c1bfadb6b5fac90228a2464396e3e7578d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 22 Apr 2023 16:38:34 +0200 Subject: [PATCH 260/475] Rework association mapping hierarchy - Each type is now either final, abstract or an interface. - The mappedBy attribute is no longer nullable and moved down the hierarchy. - The inversedBy attribute is still nullable and also moved down the hierarchy. - Code common to ManyToOneAssociationMapping and OneToOneOwningSideMapping is de-duplicated and moved up the hierarchy - Code inside ToManyInverseSideMapping and ToManyOwningSideMapping comes from a trait to avoid duplication. --- .../ORM/Internal/Hydration/ObjectHydrator.php | 4 +- .../ORM/Mapping/AssociationMapping.php | 24 +-- .../Mapping/AssociationOwningSideMapping.php | 9 - lib/Doctrine/ORM/Mapping/ClassMetadata.php | 10 +- .../ORM/Mapping/InverseSideMapping.php | 30 +++ .../Mapping/ManyToManyAssociationMapping.php | 2 +- .../Mapping/ManyToManyInverseSideMapping.php | 9 + .../Mapping/ManyToManyOwningSideMapping.php | 2 +- .../Mapping/ManyToOneAssociationMapping.php | 22 +-- .../Mapping/OneToManyAssociationMapping.php | 2 +- .../Mapping/OneToOneAssociationMapping.php | 2 +- .../Mapping/OneToOneInverseSideMapping.php | 9 + .../ORM/Mapping/OneToOneOwningSideMapping.php | 22 +-- .../ORM/Mapping/OwningSideMapping.php | 28 +++ .../ORM/Mapping/ToManyAssociationMapping.php | 30 +-- ...ToManyAssociationMappingImplementation.php | 38 ++++ .../ORM/Mapping/ToManyInverseSideMapping.php | 10 + .../ORM/Mapping/ToManyOwningSideMapping.php | 10 + .../ORM/Mapping/ToOneAssociationMapping.php | 161 +--------------- .../ORM/Mapping/ToOneInverseSideMapping.php | 39 ++++ .../ORM/Mapping/ToOneOwningSideMapping.php | 176 ++++++++++++++++++ lib/Doctrine/ORM/PersistentCollection.php | 2 +- .../Collection/ManyToManyPersister.php | 8 +- .../Entity/BasicEntityPersister.php | 8 +- .../ORM/Query/AST/Functions/SizeFunction.php | 1 - lib/Doctrine/ORM/Tools/SchemaValidator.php | 10 +- phpstan.neon | 12 +- psalm-baseline.xml | 39 +++- psalm.xml | 7 + .../Entity/EntityPersisterTestCase.php | 18 +- .../ORM/Mapping/AssociationMappingTest.php | 4 - .../ORM/Mapping/InverseSideMappingTest.php | 35 ++++ .../ORM/Mapping/MappingDriverTestCase.php | 2 - .../ORM/Mapping/OwningSideMappingTest.php | 35 ++++ .../Mapping/ToManyAssociationMappingTest.php | 5 +- 35 files changed, 507 insertions(+), 318 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/AssociationOwningSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/InverseSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ManyToManyInverseSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/OneToOneInverseSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/OwningSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php create mode 100644 lib/Doctrine/ORM/Mapping/ToManyInverseSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ToManyOwningSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ToOneInverseSideMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/InverseSideMappingTest.php create mode 100644 tests/Doctrine/Tests/ORM/Mapping/OwningSideMappingTest.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 53ef78e5b13..ee45f8408f0 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -83,7 +83,7 @@ protected function prepare(): void } // Mark any non-collection opposite sides as fetched, too. - if ($assoc['mappedBy']) { + if (! $assoc->isOwningSide()) { $this->hints['fetched'][$dqlAlias][$assoc['mappedBy']] = true; continue; @@ -439,7 +439,7 @@ protected function hydrateRowData(array $row, array &$result): void $targetClass->reflFields[$inverseAssoc['fieldName']]->setValue($element, $parentObject); $this->uow->setOriginalEntityProperty(spl_object_id($element), $inverseAssoc['fieldName'], $parentObject); } - } elseif ($parentClass === $targetClass && $relation['mappedBy']) { + } elseif ($parentClass === $targetClass && ! $relation->isOwningSide()) { // Special case: bi-directional self-referencing one-one on the same class $targetClass->reflFields[$relationField]->setValue($element, $parentObject); } diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index af0a48e993f..0e9ea2282e4 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -17,22 +17,6 @@ /** @template-implements ArrayAccess */ abstract class AssociationMapping implements ArrayAccess { - /** - * required for bidirectional associations - * The name of the field that completes the bidirectional association on - * the owning side. This key must be specified on the inverse side of a - * bidirectional association. - */ - public string|null $mappedBy = null; - - /** - * required for bidirectional associations - * The name of the field that completes the bidirectional association on - * the inverse side. This key must be specified on the owning side of a - * bidirectional association. - */ - public string|null $inversedBy = null; - /** * The names of persistence operations to cascade on the association. * @@ -159,12 +143,12 @@ public static function fromMappingArray(array $mappingArray): static } /** - * @psalm-assert-if-true AssociationOwningSideMapping $this - * @psalm-assert-if-false string $this->mappedBy + * @psalm-assert-if-true OwningSideMapping $this + * @psalm-assert-if-false InverseSideMapping $this */ final public function isOwningSide(): bool { - return $this instanceof AssociationOwningSideMapping; + return $this instanceof OwningSideMapping; } /** @psalm-assert-if-true ToOneAssociationMapping $this */ @@ -335,8 +319,6 @@ public function __sleep(): array foreach ( [ - 'mappedBy', - 'inversedBy', 'fetch', 'inherited', 'declared', diff --git a/lib/Doctrine/ORM/Mapping/AssociationOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/AssociationOwningSideMapping.php deleted file mode 100644 index 6230e72dedf..00000000000 --- a/lib/Doctrine/ORM/Mapping/AssociationOwningSideMapping.php +++ /dev/null @@ -1,9 +0,0 @@ -table ?? null, $this->isInheritanceTypeSingleTable(), ) : - OneToOneAssociationMapping::fromMappingArrayAndName( - $mapping, - $this->namingStrategy, - $this->name, - $this->table, - $this->isInheritanceTypeSingleTable(), - ); + OneToOneInverseSideMapping::fromMappingArrayAndName($mapping, $this->name); case self::MANY_TO_ONE: return ManyToOneAssociationMapping::fromMappingArrayAndName( @@ -1419,7 +1413,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping): Assoc return $mapping['isOwningSide'] ? ManyToManyOwningSideMapping::fromMappingArrayAndNamingStrategy($mapping, $this->namingStrategy) : - ManyToManyAssociationMapping::fromMappingArray($mapping); + ManyToManyInverseSideMapping::fromMappingArray($mapping); default: throw MappingException::invalidAssociationType( diff --git a/lib/Doctrine/ORM/Mapping/InverseSideMapping.php b/lib/Doctrine/ORM/Mapping/InverseSideMapping.php new file mode 100644 index 00000000000..56dce9f27ec --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/InverseSideMapping.php @@ -0,0 +1,30 @@ +mappedBy; + } + + /** @return list */ + public function __sleep(): array + { + return [ + ...parent::__sleep(), + 'mappedBy', + ]; + } +} diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php index 92501efd575..8d963c29469 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php @@ -4,6 +4,6 @@ namespace Doctrine\ORM\Mapping; -class ManyToManyAssociationMapping extends ToManyAssociationMapping +interface ManyToManyAssociationMapping extends ToManyAssociationMapping { } diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyInverseSideMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyInverseSideMapping.php new file mode 100644 index 00000000000..8cd5cbddb3e --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ManyToManyInverseSideMapping.php @@ -0,0 +1,9 @@ + */ - public array $sourceToTargetKeyColumns = []; - - /** @var array */ - public array $targetToSourceKeyColumns = []; - - /** @var list */ - public array $joinColumns = []; - - /** @return list */ - public function __sleep(): array - { - $serialized = parent::__sleep(); - - $serialized[] = 'joinColumns'; - $serialized[] = 'sourceToTargetKeyColumns'; - $serialized[] = 'targetToSourceKeyColumns'; - - return $serialized; - } } diff --git a/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php index 5849a3382b7..804061a1a1d 100644 --- a/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php @@ -4,7 +4,7 @@ namespace Doctrine\ORM\Mapping; -final class OneToManyAssociationMapping extends ToManyAssociationMapping +final class OneToManyAssociationMapping extends ToManyInverseSideMapping { /** * @param mixed[] $mappingArray diff --git a/lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php b/lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php index 6faafc3ee51..89c6483e504 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php @@ -4,6 +4,6 @@ namespace Doctrine\ORM\Mapping; -class OneToOneAssociationMapping extends ToOneAssociationMapping +interface OneToOneAssociationMapping extends ToOneAssociationMapping { } diff --git a/lib/Doctrine/ORM/Mapping/OneToOneInverseSideMapping.php b/lib/Doctrine/ORM/Mapping/OneToOneInverseSideMapping.php new file mode 100644 index 00000000000..85e0f30dca0 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/OneToOneInverseSideMapping.php @@ -0,0 +1,9 @@ + */ - public array $sourceToTargetKeyColumns = []; - - /** @var array */ - public array $targetToSourceKeyColumns = []; - - /** @var list */ - public array $joinColumns = []; - - /** @return list */ - public function __sleep(): array - { - $serialized = parent::__sleep(); - - $serialized[] = 'joinColumns'; - $serialized[] = 'sourceToTargetKeyColumns'; - $serialized[] = 'targetToSourceKeyColumns'; - - return $serialized; - } } diff --git a/lib/Doctrine/ORM/Mapping/OwningSideMapping.php b/lib/Doctrine/ORM/Mapping/OwningSideMapping.php new file mode 100644 index 00000000000..ab8b7b2d7f1 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/OwningSideMapping.php @@ -0,0 +1,28 @@ + */ + public function __sleep(): array + { + $serialized = parent::__sleep(); + + if ($this->inversedBy !== null) { + $serialized[] = 'inversedBy'; + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php index 1db301d0430..0f360149cfc 100644 --- a/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php @@ -4,34 +4,6 @@ namespace Doctrine\ORM\Mapping; -abstract class ToManyAssociationMapping extends AssociationMapping +interface ToManyAssociationMapping { - /** - * Specification of a field on target-entity that is used to index the - * collection by. This field HAS to be either the primary key or a unique - * column. Otherwise the collection does not contain all the entities that - * are actually related. - */ - public string|null $indexBy = null; - - /** - * A map of field names (of the target entity) to sorting directions - * - * @var array|null - */ - public array|null $orderBy = null; - - /** @return list */ - public function __sleep(): array - { - $serialized = parent::__sleep(); - - foreach (['indexBy', 'orderBy'] as $stringOrArrayKey) { - if ($this->$stringOrArrayKey !== null) { - $serialized[] = $stringOrArrayKey; - } - } - - return $serialized; - } } diff --git a/lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php b/lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php new file mode 100644 index 00000000000..c7169894520 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php @@ -0,0 +1,38 @@ +|null + */ + public array|null $orderBy = null; + + /** @return list */ + public function __sleep(): array + { + $serialized = parent::__sleep(); + + foreach (['indexBy', 'orderBy'] as $stringOrArrayKey) { + if ($this->$stringOrArrayKey !== null) { + $serialized[] = $stringOrArrayKey; + } + } + + return $serialized; + } +} diff --git a/lib/Doctrine/ORM/Mapping/ToManyInverseSideMapping.php b/lib/Doctrine/ORM/Mapping/ToManyInverseSideMapping.php new file mode 100644 index 00000000000..a092ebe31aa --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ToManyInverseSideMapping.php @@ -0,0 +1,10 @@ + $mappingArray - * @psalm-param array{ - * fieldName: string, - * sourceEntity: class-string, - * targetEntity: class-string, - * joinColumns?: mixed[]|null, - * isOwningSide: bool, ...} $mappingArray - */ - public static function fromMappingArray(array $mappingArray): static - { - $joinColumns = $mappingArray['joinColumns'] ?? []; - - if (isset($mappingArray['joinColumns'])) { - unset($mappingArray['joinColumns']); - } - - $instance = parent::fromMappingArray($mappingArray); - - foreach ($joinColumns as $column) { - assert($instance->isToOneOwningSide()); - $instance->joinColumns[] = JoinColumnMapping::fromMappingArray($column); - } - - if ($instance->orphanRemoval) { - if (! $instance->isCascadeRemove()) { - $instance->cascade[] = 'remove'; - } - - $instance->unique = null; - } - - return $instance; - } - - /** - * @param mixed[] $mappingArray - * @param class-string $name - * @psalm-param array{ - * fieldName: string, - * sourceEntity: class-string, - * targetEntity: class-string, - * joinColumns?: mixed[]|null, - * isOwningSide: bool, ...} $mappingArray - */ - public static function fromMappingArrayAndName( - array $mappingArray, - NamingStrategy $namingStrategy, - string $name, - array|null $table, - bool $isInheritanceTypeSingleTable, - ): OneToOneAssociationMapping|ManyToOneAssociationMapping { - $mapping = static::fromMappingArray($mappingArray); - - if ($mapping->isOwningSide()) { - assert($mapping instanceof OneToOneOwningSideMapping || $mapping instanceof ManyToOneAssociationMapping); - if (empty($mapping->joinColumns)) { - // Apply default join column - $mapping->joinColumns = [ - JoinColumnMapping::fromMappingArray([ - 'name' => $namingStrategy->joinColumnName($mapping['fieldName'], $name), - 'referencedColumnName' => $namingStrategy->referenceColumnName(), - ]), - ]; - } - - $uniqueConstraintColumns = []; - - foreach ($mapping->joinColumns as $joinColumn) { - if ($mapping->isOneToOne() && ! $isInheritanceTypeSingleTable) { - if (count($mapping->joinColumns) === 1) { - if (empty($mapping->id)) { - $joinColumn->unique = true; - } - } else { - $uniqueConstraintColumns[] = $joinColumn->name; - } - } - - if (empty($joinColumn->name)) { - $joinColumn->name = $namingStrategy->joinColumnName($mapping->fieldName, $name); - } - - if (empty($joinColumn->referencedColumnName)) { - $joinColumn->referencedColumnName = $namingStrategy->referenceColumnName(); - } - - if ($joinColumn->name[0] === '`') { - $joinColumn->name = trim($joinColumn->name, '`'); - $joinColumn->quoted = true; - } - - if ($joinColumn->referencedColumnName[0] === '`') { - $joinColumn->referencedColumnName = trim($joinColumn->referencedColumnName, '`'); - $joinColumn->quoted = true; - } - - $mapping->sourceToTargetKeyColumns[$joinColumn->name] = $joinColumn->referencedColumnName; - $mapping->joinColumnFieldNames[$joinColumn->name] = $joinColumn->fieldName ?? $joinColumn->name; - } - - if ($uniqueConstraintColumns) { - if (! $table) { - throw new RuntimeException('ClassMetadata::setTable() has to be called before defining a one to one relationship.'); - } - - $table['uniqueConstraints'][$mapping->fieldName . '_uniq'] = ['columns' => $uniqueConstraintColumns]; - } - - $mapping->targetToSourceKeyColumns = array_flip($mapping->sourceToTargetKeyColumns); - } - - if (isset($mapping->id) && $mapping->id === true && ! $mapping->isOwningSide()) { - throw MappingException::illegalInverseIdentifierAssociation($name, $mapping->fieldName); - } - - return $mapping; - } - - public function offsetSet(mixed $offset, mixed $value): void - { - if ($offset === 'joinColumns') { - assert($this->isToOneOwningSide()); - $joinColumns = []; - foreach ($value as $column) { - $joinColumns[] = JoinColumnMapping::fromMappingArray($column); - } - - $this->joinColumns = $joinColumns; - - return; - } - - parent::offsetSet($offset, $value); - } - - /** @return array */ - public function toArray(): array - { - $array = parent::toArray(); - - if ($array['joinColumns'] !== []) { - $joinColumns = []; - foreach ($array['joinColumns'] as $column) { - $joinColumns[] = (array) $column; - } - - $array['joinColumns'] = $joinColumns; - } - - return $array; - } } diff --git a/lib/Doctrine/ORM/Mapping/ToOneInverseSideMapping.php b/lib/Doctrine/ORM/Mapping/ToOneInverseSideMapping.php new file mode 100644 index 00000000000..232952be438 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ToOneInverseSideMapping.php @@ -0,0 +1,39 @@ +id) && $mapping->id === true) { + throw MappingException::illegalInverseIdentifierAssociation($name, $mapping->fieldName); + } + + if ($mapping->orphanRemoval) { + if (! $mapping->isCascadeRemove()) { + $mapping->cascade[] = 'remove'; + } + + $mapping->unique = null; + } + + return $mapping; + } +} diff --git a/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php new file mode 100644 index 00000000000..f356860f833 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php @@ -0,0 +1,176 @@ + */ + public array $sourceToTargetKeyColumns = []; + + /** @var array */ + public array $targetToSourceKeyColumns = []; + + /** @var list */ + public array $joinColumns = []; + + /** + * @param array $mappingArray + * @psalm-param array{ + * fieldName: string, + * sourceEntity: class-string, + * targetEntity: class-string, + * joinColumns?: mixed[]|null, + * isOwningSide: bool, ...} $mappingArray + */ + public static function fromMappingArray(array $mappingArray): static + { + $joinColumns = $mappingArray['joinColumns'] ?? []; + unset($mappingArray['joinColumns']); + + $instance = parent::fromMappingArray($mappingArray); + assert($instance->isToOneOwningSide()); + + foreach ($joinColumns as $column) { + $instance->joinColumns[] = JoinColumnMapping::fromMappingArray($column); + } + + if ($instance->orphanRemoval) { + if (! $instance->isCascadeRemove()) { + $instance->cascade[] = 'remove'; + } + + $instance->unique = null; + } + + return $instance; + } + + /** + * @param mixed[] $mappingArray + * @param class-string $name + * @psalm-param array{ + * fieldName: string, + * sourceEntity: class-string, + * targetEntity: class-string, + * joinColumns?: mixed[]|null, + * isOwningSide: bool, ...} $mappingArray + */ + public static function fromMappingArrayAndName( + array $mappingArray, + NamingStrategy $namingStrategy, + string $name, + array|null $table, + bool $isInheritanceTypeSingleTable, + ): static { + $mapping = static::fromMappingArray($mappingArray); + + assert($mapping->isToOneOwningSide()); + if (empty($mapping->joinColumns)) { + // Apply default join column + $mapping->joinColumns = [ + JoinColumnMapping::fromMappingArray([ + 'name' => $namingStrategy->joinColumnName($mapping['fieldName'], $name), + 'referencedColumnName' => $namingStrategy->referenceColumnName(), + ]), + ]; + } + + $uniqueConstraintColumns = []; + + foreach ($mapping->joinColumns as $joinColumn) { + if ($mapping->isOneToOne() && ! $isInheritanceTypeSingleTable) { + if (count($mapping->joinColumns) === 1) { + if (empty($mapping->id)) { + $joinColumn->unique = true; + } + } else { + $uniqueConstraintColumns[] = $joinColumn->name; + } + } + + if (empty($joinColumn->name)) { + $joinColumn->name = $namingStrategy->joinColumnName($mapping->fieldName, $name); + } + + if (empty($joinColumn->referencedColumnName)) { + $joinColumn->referencedColumnName = $namingStrategy->referenceColumnName(); + } + + if ($joinColumn->name[0] === '`') { + $joinColumn->name = trim($joinColumn->name, '`'); + $joinColumn->quoted = true; + } + + if ($joinColumn->referencedColumnName[0] === '`') { + $joinColumn->referencedColumnName = trim($joinColumn->referencedColumnName, '`'); + $joinColumn->quoted = true; + } + + $mapping->sourceToTargetKeyColumns[$joinColumn->name] = $joinColumn->referencedColumnName; + $mapping->joinColumnFieldNames[$joinColumn->name] = $joinColumn->fieldName ?? $joinColumn->name; + } + + if ($uniqueConstraintColumns) { + if (! $table) { + throw new RuntimeException('ClassMetadata::setTable() has to be called before defining a one to one relationship.'); + } + + $table['uniqueConstraints'][$mapping->fieldName . '_uniq'] = ['columns' => $uniqueConstraintColumns]; + } + + $mapping->targetToSourceKeyColumns = array_flip($mapping->sourceToTargetKeyColumns); + + return $mapping; + } + + public function offsetSet(mixed $offset, mixed $value): void + { + if ($offset === 'joinColumns') { + $joinColumns = []; + foreach ($value as $column) { + $joinColumns[] = JoinColumnMapping::fromMappingArray($column); + } + + $this->joinColumns = $joinColumns; + + return; + } + + parent::offsetSet($offset, $value); + } + + /** @return array */ + public function toArray(): array + { + $array = parent::toArray(); + + $joinColumns = []; + foreach ($array['joinColumns'] as $column) { + $joinColumns[] = (array) $column; + } + + $array['joinColumns'] = $joinColumns; + + return $array; + } + + /** @return list */ + public function __sleep(): array + { + return [ + ...parent::__sleep(), + 'joinColumns', + 'sourceToTargetKeyColumns', + 'targetToSourceKeyColumns', + ]; + } +} diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 57a17079082..8634e54c809 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -102,7 +102,7 @@ public function setOwner(object $entity, AssociationMapping $assoc): void { $this->owner = $entity; $this->association = $assoc; - $this->backRefFieldName = $assoc['inversedBy'] ?: $assoc['mappedBy']; + $this->backRefFieldName = $assoc->isOwningSide() ? $assoc->inversedBy : $assoc->mappedBy; } /** diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index d70900662c5..c6e2fe3253d 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\LockMode; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\InverseSideMapping; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\SqlValueVisitor; use Doctrine\ORM\Query; @@ -223,6 +224,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri $paramTypes = []; if (! $mapping->isOwningSide()) { + assert($mapping instanceof InverseSideMapping); $associationSourceClass = $targetClass; $mapping = $targetClass->associationMappings[$mapping->mappedBy]; $sourceRelationMode = 'relationToTargetKeyColumns'; @@ -572,14 +574,14 @@ private function getJoinTableRestrictionsWithKey( ): array { $filterMapping = $collection->getMapping(); $mapping = $filterMapping; - assert($mapping->isManyToMany()); - $indexBy = $mapping->indexBy; - assert($indexBy !== null); + assert(isset($mapping->indexBy)); + $indexBy = $mapping->indexBy; $id = $this->uow->getEntityIdentifier($collection->getOwner()); $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); $targetClass = $this->em->getClassMetadata($mapping->targetEntity); if (! $mapping->isOwningSide()) { + assert($mapping instanceof InverseSideMapping); $associationSourceClass = $this->em->getClassMetadata($mapping->targetEntity); $mapping = $associationSourceClass->associationMappings[$mapping->mappedBy]; assert($mapping->isManyToManyOwningSide()); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 35e8429fb4a..46875005477 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\InverseSideMapping; use Doctrine\ORM\Mapping\JoinColumnMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\OneToManyAssociationMapping; @@ -512,7 +513,7 @@ protected function deleteJoinTableRecords(array $identifier, array $types): void $keys = []; if (! $mapping->isOwningSide()) { - assert(isset($mapping->mappedBy)); + assert($mapping instanceof InverseSideMapping); $class = $this->em->getClassMetadata($mapping->targetEntity); $association = $class->associationMappings[$mapping->mappedBy]; } @@ -1746,9 +1747,8 @@ private function getOneToManyStatement( ): Result { $this->switchPersisterContext($offset, $limit); - $criteria = []; - $parameters = []; - assert(isset($assoc->mappedBy)); + $criteria = []; + $parameters = []; $owningAssoc = $this->class->associationMappings[$assoc->mappedBy]; $sourceClass = $this->em->getClassMetadata($assoc->sourceEntity); $tableAlias = $this->getSQLTableAlias($owningAssoc->inherited ?? $this->class->name); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 436967fc0f6..272b90f6144 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -61,7 +61,6 @@ public function getSql(SqlWalker $sqlWalker): string . $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $platform); } } else { // many-to-many - assert($assoc->isManyToMany()); $targetClass = $entityManager->getClassMetadata($assoc->targetEntity); $owningAssoc = $assoc->isOwningSide() ? $assoc : $targetClass->associationMappings[$assoc['mappedBy']]; diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 9222f9ba8a4..6c9baf9a9a4 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -95,16 +95,12 @@ public function validateClass(ClassMetadata $class): array return $ce; } - if ($assoc['mappedBy'] && $assoc['inversedBy']) { - $ce[] = 'The association ' . $class . '#' . $fieldName . ' cannot be defined as both inverse and owning.'; - } - if (isset($assoc['id']) && $targetMetadata->containsForeignIdentifier) { $ce[] = "Cannot map association '" . $class->name . '#' . $fieldName . ' as identifier, because ' . "the target entity '" . $targetMetadata->name . "' also maps an association as identifier."; } - if ($assoc['mappedBy']) { + if (! $assoc->isOwningSide()) { if ($targetMetadata->hasField($assoc['mappedBy'])) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the owning side ' . 'field ' . $assoc['targetEntity'] . '#' . $assoc['mappedBy'] . ' which is not defined as association, but as field.'; @@ -125,7 +121,7 @@ public function validateClass(ClassMetadata $class): array } } - if ($assoc->inversedBy) { + if ($assoc->isOwningSide() && $assoc->inversedBy) { if ($targetMetadata->hasField($assoc['inversedBy'])) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the inverse side ' . 'field ' . $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' which is not defined as association.'; @@ -134,7 +130,7 @@ public function validateClass(ClassMetadata $class): array if (! $targetMetadata->hasAssociation($assoc['inversedBy'])) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the inverse side ' . 'field ' . $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' which does not exist.'; - } elseif ($targetMetadata->associationMappings[$assoc['inversedBy']]['mappedBy'] === null) { + } elseif ($targetMetadata->associationMappings[$assoc['inversedBy']]->isOwningSide()) { $ce[] = 'The field ' . $class->name . '#' . $fieldName . ' is on the owning side of a ' . 'bi-directional relationship, but the specified inversedBy association on the target-entity ' . $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' does not contain the required ' . diff --git a/phpstan.neon b/phpstan.neon index d3bd7dee0cf..cb11aefbd29 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -26,19 +26,13 @@ parameters: # https://github.com/phpstan/phpstan/issues/8904 - - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\:\\:\\$joinColumns\\.$#" - path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php - - - - message: "#^Access to an undefined property .*Mapping\\:\\:\\$(joinColumns|joinTableColumns|(relation|source|target)To(Target|Source)KeyColumns|joinTable|indexBy)\\.$#" + message: "#^Access to an undefined property .*Mapping\\:\\:\\$(inversedBy|mappedBy|joinColumns|joinTableColumns|(relation|source|target)To(Target|Source)KeyColumns|joinTable|indexBy)\\.$#" paths: - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php + - lib/Doctrine/ORM/PersistentCollection.php - lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php - lib/Doctrine/ORM/Query/SqlWalker.php + - lib/Doctrine/ORM/Tools/SchemaValidator.php - lib/Doctrine/ORM/UnitOfWork.php - - - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\:\\:fromMappingArrayAndName\\(\\) should return Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneAssociationMapping but returns static\\(Doctrine\\\\ORM\\\\Mapping\\\\ToOneAssociationMapping\\)\\.$#" - path: lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5a99e7563fe..a809e4fd06f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -283,6 +283,14 @@ + + + $mapping + + + static + + $repositoryClassName @@ -304,6 +312,7 @@ $mapping $mapping $mapping + $mapping $overrideMapping @@ -570,6 +579,11 @@ getName() === 'mapped-superclass']]> + + + ManyToManyInverseSideMapping + + $joinTable @@ -581,6 +595,19 @@ new JoinTableMapping() + + + OneToManyAssociationMapping + + + mappedBy)]]> + + + + + OneToOneInverseSideMapping + + $object @@ -605,13 +632,21 @@ ReflectionReadonlyProperty - + + + $mapping + + + static + + + $instance $mapping - OneToOneAssociationMapping|ManyToOneAssociationMapping + static static diff --git a/psalm.xml b/psalm.xml index 66ec1f169e5..fc0232ccdb0 100644 --- a/psalm.xml +++ b/psalm.xml @@ -202,6 +202,13 @@ + + + + + + + diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php index ca67a5a8b61..ab122fee553 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php @@ -12,7 +12,7 @@ use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\OneToOneAssociationMapping; +use Doctrine\ORM\Mapping\OneToOneInverseSideMapping; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\Entity\EntityPersister; use Doctrine\ORM\Query\ResultSetMappingBuilder; @@ -90,7 +90,7 @@ public function testInvokeGetSelectSQL(): void { $persister = $this->createPersisterDefault(); - $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $associationMapping = new OneToOneInverseSideMapping('foo', 'bar', 'baz'); $this->entityPersister->expects(self::once()) ->method('getSelectSQL') @@ -154,7 +154,7 @@ public function testInvokeSelectConditionStatementSQL(): void { $persister = $this->createPersisterDefault(); - $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $associationMapping = new OneToOneInverseSideMapping('foo', 'bar', 'baz'); $this->entityPersister->expects(self::once()) ->method('getSelectConditionStatementSQL') @@ -225,7 +225,7 @@ public function testInvokeLoad(): void $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); - $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $associationMapping = new OneToOneInverseSideMapping('foo', 'bar', 'baz'); $this->entityPersister->expects(self::once()) ->method('load') @@ -285,7 +285,7 @@ public function testInvokeLoadOneToOneEntity(): void $entity = new Country('Foo'); $owner = (object) []; - $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $associationMapping = new OneToOneInverseSideMapping('foo', 'bar', 'baz'); $this->entityPersister->expects(self::once()) ->method('loadOneToOneEntity') @@ -336,7 +336,7 @@ public function testInvokeGetManyToManyCollection(): void $entity = new Country('Foo'); $owner = (object) []; - $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $associationMapping = new OneToOneInverseSideMapping('foo', 'bar', 'baz'); $this->entityPersister->expects(self::once()) ->method('getManyToManyCollection') @@ -352,7 +352,7 @@ public function testInvokeGetOneToManyCollection(): void $entity = new Country('Foo'); $owner = (object) []; - $associationMapping = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $associationMapping = new OneToOneInverseSideMapping('foo', 'bar', 'baz'); $this->entityPersister->expects(self::once()) ->method('getOneToManyCollection') @@ -365,7 +365,7 @@ public function testInvokeGetOneToManyCollection(): void public function testInvokeLoadManyToManyCollection(): void { $mapping = $this->em->getClassMetadata(Country::class); - $assoc = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $assoc = new OneToOneInverseSideMapping('foo', 'bar', 'baz'); $coll = new PersistentCollection($this->em, $mapping, new ArrayCollection()); $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); @@ -382,7 +382,7 @@ public function testInvokeLoadManyToManyCollection(): void public function testInvokeLoadOneToManyCollection(): void { $mapping = $this->em->getClassMetadata(Country::class); - $assoc = new OneToOneAssociationMapping('foo', 'bar', 'baz'); + $assoc = new OneToOneInverseSideMapping('foo', 'bar', 'baz'); $coll = new PersistentCollection($this->em, $mapping, new ArrayCollection()); $persister = $this->createPersisterDefault(); $entity = new Country('Foo'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php index b53e23e20a0..facc680be32 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php @@ -23,8 +23,6 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->mappedBy = 'foo'; - $mapping->inversedBy = 'bar'; $mapping->cascade = ['persist']; $mapping->fetch = ClassMetadata::FETCH_EAGER; $mapping->inherited = self::class; @@ -41,8 +39,6 @@ public function testItSurvivesSerialization(): void $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof AssociationMapping); - self::assertSame('foo', $resurrectedMapping->mappedBy); - self::assertSame('bar', $resurrectedMapping->inversedBy); self::assertSame(['persist'], $resurrectedMapping->cascade); self::assertSame(ClassMetadata::FETCH_EAGER, $resurrectedMapping->fetch); self::assertSame(self::class, $resurrectedMapping->inherited); diff --git a/tests/Doctrine/Tests/ORM/Mapping/InverseSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/InverseSideMappingTest.php new file mode 100644 index 00000000000..b5a7cd74127 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/InverseSideMappingTest.php @@ -0,0 +1,35 @@ +mappedBy = 'bar'; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof InverseSideMapping); + + self::assertSame('bar', $resurrectedMapping->mappedBy); + } +} + +class MyInverseAssociationMapping extends InverseSideMapping +{ +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 0f2a9e3934b..e3abecf83e3 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -624,7 +624,6 @@ public function testAssociationOverridesMapping(): void // assert not override attributes self::assertEquals($guestGroups['fieldName'], $adminGroups['fieldName']); self::assertEquals($guestGroups['type'], $adminGroups['type']); - self::assertEquals($guestGroups['mappedBy'], $adminGroups['mappedBy']); self::assertEquals($guestGroups['inversedBy'], $adminGroups['inversedBy']); self::assertEquals($guestGroups['isOwningSide'], $adminGroups['isOwningSide']); self::assertEquals($guestGroups['fetch'], $adminGroups['fetch']); @@ -661,7 +660,6 @@ public function testAssociationOverridesMapping(): void // assert not override attributes self::assertEquals($guestAddress['fieldName'], $adminAddress['fieldName']); self::assertEquals($guestAddress['type'], $adminAddress['type']); - self::assertEquals($guestAddress['mappedBy'], $adminAddress['mappedBy']); self::assertEquals($guestAddress['inversedBy'], $adminAddress['inversedBy']); self::assertEquals($guestAddress['isOwningSide'], $adminAddress['isOwningSide']); self::assertEquals($guestAddress['fetch'], $adminAddress['fetch']); diff --git a/tests/Doctrine/Tests/ORM/Mapping/OwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/OwningSideMappingTest.php new file mode 100644 index 00000000000..21289db949a --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/OwningSideMappingTest.php @@ -0,0 +1,35 @@ +inversedBy = 'bar'; + + $resurrectedMapping = unserialize(serialize($mapping)); + assert($resurrectedMapping instanceof OwningSideMapping); + + self::assertSame('bar', $resurrectedMapping->inversedBy); + } +} + +class MyOwningAssociationMapping extends OwningSideMapping +{ +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php index 8befdde20f0..e435a944b7f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php @@ -4,7 +4,9 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ToManyAssociationMapping; +use Doctrine\ORM\Mapping\ToManyAssociationMappingImplementation; use PHPUnit\Framework\TestCase; use function assert; @@ -32,6 +34,7 @@ public function testItSurvivesSerialization(): void } } -class MyToManyAssociationMapping extends ToManyAssociationMapping +class MyToManyAssociationMapping extends AssociationMapping implements ToManyAssociationMapping { + use ToManyAssociationMappingImplementation; } From 05b5a64cb977910f1b09856cb5e9b3775401e200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 8 May 2023 15:24:10 +0200 Subject: [PATCH 261/475] Make indexBy/orderBy easier to understand for SA (#10687) Interfaces cannot have properties, and we do not have a concept of sealed classes available to us without installing third party packages. Interfaces can have methods however, which allows us to simplify calling code. I've been avoiding introducing getters for mapping properties because I do not know what the performance implications are, but here, I think it is sensible to make an exception, given the benefits. --- .../AbstractCollectionPersister.php | 2 +- ...rictReadWriteCachedCollectionPersister.php | 2 +- .../ORM/Internal/Hydration/ObjectHydrator.php | 2 + .../ORM/Mapping/AssociationMapping.php | 12 ++++++ .../ORM/Mapping/ToManyAssociationMapping.php | 7 +++ ...ToManyAssociationMappingImplementation.php | 43 ++++++++++++++++--- lib/Doctrine/ORM/PersistentCollection.php | 9 ++-- .../Collection/ManyToManyPersister.php | 15 +++---- .../Collection/OneToManyPersister.php | 13 +++--- .../Entity/BasicEntityPersister.php | 16 +++---- .../Entity/JoinedSubclassPersister.php | 4 +- lib/Doctrine/ORM/Query/SqlWalker.php | 4 +- lib/Doctrine/ORM/Tools/SchemaValidator.php | 4 +- lib/Doctrine/ORM/UnitOfWork.php | 3 ++ phpstan-baseline.neon | 15 +++++++ phpstan.neon | 9 ++++ psalm-baseline.xml | 3 ++ .../ORM/Mapping/MappingDriverTestCase.php | 4 +- 18 files changed, 126 insertions(+), 41 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index 68ae4241d20..84936d83535 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -92,7 +92,7 @@ public function storeCollectionCache(CollectionCacheKey $key, Collection|array $ $targetHydrator = $targetPersister->getEntityHydrator(); // Only preserve ordering if association configured it - if (! (isset($associationMapping['indexBy']) && $associationMapping['indexBy'])) { + if (! $associationMapping->isIndexed()) { // Elements may be an array or a Collection $elements = array_values($elements instanceof Collection ? $elements->getValues() : $elements); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php index 261048bc0ba..67e5cffbb7f 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php @@ -56,7 +56,7 @@ public function update(PersistentCollection $collection): void $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); // Invalidate non initialized collections OR ordered collection - if ($isDirty && ! $isInitialized || isset($this->association['orderBy'])) { + if ($isDirty && ! $isInitialized || $this->association->isOrdered()) { $this->persister->update($collection); $this->queuedCache['delete'][spl_object_id($collection)] = $key; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index ee45f8408f0..3db801375c8 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -14,6 +14,7 @@ use function array_fill_keys; use function array_keys; +use function assert; use function count; use function is_array; use function key; @@ -177,6 +178,7 @@ private function initRelatedCollection( } if (! $value instanceof PersistentCollection) { + assert($relation->isToMany()); $value = new PersistentCollection( $this->em, $this->metadataCache[$relation['targetEntity']], diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index 0e9ea2282e4..396f0e826dd 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -205,6 +205,18 @@ final public function isManyToMany(): bool return $this instanceof ManyToManyAssociationMapping; } + /** @psalm-assert-if-true ToManyAssociationMapping $this */ + final public function isOrdered(): bool + { + return $this->isToMany() && $this->orderBy() !== []; + } + + /** @psalm-assert-if-true ToManyAssociationMapping $this */ + public function isIndexed(): bool + { + return false; + } + final public function type(): int { return match (true) { diff --git a/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php b/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php index 0f360149cfc..2e4969c47c6 100644 --- a/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php @@ -6,4 +6,11 @@ interface ToManyAssociationMapping { + /** @psalm-assert-if-true string $this->indexBy() */ + public function isIndexed(): bool; + + public function indexBy(): string; + + /** @return array */ + public function orderBy(): array; } diff --git a/lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php b/lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php index c7169894520..306880dd511 100644 --- a/lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php +++ b/lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php @@ -4,6 +4,10 @@ namespace Doctrine\ORM\Mapping; +use LogicException; + +use function sprintf; + /** @internal */ trait ToManyAssociationMappingImplementation { @@ -18,19 +22,46 @@ trait ToManyAssociationMappingImplementation /** * A map of field names (of the target entity) to sorting directions * - * @var array|null + * @var array */ - public array|null $orderBy = null; + public array $orderBy = []; + + /** @return array */ + final public function orderBy(): array + { + return $this->orderBy; + } + + /** @psalm-assert-if-true !null $this->indexBy */ + final public function isIndexed(): bool + { + return $this->indexBy !== null; + } + + final public function indexBy(): string + { + if (! $this->isIndexed()) { + throw new LogicException(sprintf( + 'This mapping is not indexed. Use %s::isIndexed() to check that before calling %s.', + self::class, + __METHOD__, + )); + } + + return $this->indexBy; + } /** @return list */ public function __sleep(): array { $serialized = parent::__sleep(); - foreach (['indexBy', 'orderBy'] as $stringOrArrayKey) { - if ($this->$stringOrArrayKey !== null) { - $serialized[] = $stringOrArrayKey; - } + if ($this->indexBy !== null) { + $serialized[] = 'indexBy'; + } + + if ($this->orderBy !== []) { + $serialized[] = 'orderBy'; } return $serialized; diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 8634e54c809..d9b73399236 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ManyToManyOwningSideMapping; +use Doctrine\ORM\Mapping\ToManyAssociationMapping; use RuntimeException; use UnexpectedValueException; @@ -56,6 +57,8 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec /** * The association mapping the collection belongs to. * This is currently either a OneToManyMapping or a ManyToManyMapping. + * + * @var (AssociationMapping&ToManyAssociationMapping)|null */ private AssociationMapping|null $association = null; @@ -98,7 +101,7 @@ public function __construct( * Sets the collection's owning entity together with the AssociationMapping that * describes the association between the owner and the elements of the collection. */ - public function setOwner(object $entity, AssociationMapping $assoc): void + public function setOwner(object $entity, AssociationMapping&ToManyAssociationMapping $assoc): void { $this->owner = $entity; $this->association = $assoc; @@ -245,7 +248,7 @@ public function getInsertDiff(): array } /** INTERNAL: Gets the association mapping of the collection. */ - public function getMapping(): AssociationMapping + public function getMapping(): AssociationMapping&ToManyAssociationMapping { if ($this->association === null) { throw new UnexpectedValueException('The underlying association mapping is null although it should not be'); @@ -600,7 +603,7 @@ public function matching(Criteria $criteria): Collection $criteria = clone $criteria; $criteria->where($expression); - $criteria->orderBy($criteria->getOrderings() ?: $association['orderBy'] ?? []); + $criteria->orderBy($criteria->getOrderings() ?: $association->orderBy()); $persister = $this->getUnitOfWork()->getEntityPersister($association['targetEntity']); diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index c6e2fe3253d..e7d087cfcfe 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -83,7 +83,7 @@ public function get(PersistentCollection $collection, mixed $index): object|null { $mapping = $collection->getMapping(); - if (! isset($mapping->indexBy)) { + if (! $mapping->isIndexed()) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); } @@ -95,7 +95,7 @@ public function get(PersistentCollection $collection, mixed $index): object|null assert($mappedKey !== null); return $persister->load( - [$mappedKey => $collection->getOwner(), $mapping->indexBy => $index], + [$mappedKey => $collection->getOwner(), $mapping->indexBy() => $index], null, $mapping, [], @@ -177,7 +177,7 @@ public function containsKey(PersistentCollection $collection, mixed $key): bool { $mapping = $collection->getMapping(); - if (! isset($mapping->indexBy)) { + if (! $mapping->isIndexed()) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); } @@ -574,11 +574,10 @@ private function getJoinTableRestrictionsWithKey( ): array { $filterMapping = $collection->getMapping(); $mapping = $filterMapping; - assert(isset($mapping->indexBy)); - $indexBy = $mapping->indexBy; - $id = $this->uow->getEntityIdentifier($collection->getOwner()); - $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); - $targetClass = $this->em->getClassMetadata($mapping->targetEntity); + $indexBy = $mapping->indexBy(); + $id = $this->uow->getEntityIdentifier($collection->getOwner()); + $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); if (! $mapping->isOwningSide()) { assert($mapping instanceof InverseSideMapping); diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 42b419f2d8a..2391b24617e 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -54,8 +54,9 @@ public function update(PersistentCollection $collection): void public function get(PersistentCollection $collection, mixed $index): object|null { $mapping = $collection->getMapping(); + assert($mapping->isOneToMany()); - if (! isset($mapping['indexBy'])) { + if (! $mapping->isIndexed()) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); } @@ -63,8 +64,8 @@ public function get(PersistentCollection $collection, mixed $index): object|null return $persister->load( [ - $mapping['mappedBy'] => $collection->getOwner(), - $mapping['indexBy'] => $index, + $mapping->mappedBy => $collection->getOwner(), + $mapping->indexBy() => $index, ], null, $mapping, @@ -102,7 +103,7 @@ public function containsKey(PersistentCollection $collection, mixed $key): bool { $mapping = $collection->getMapping(); - if (! isset($mapping['indexBy'])) { + if (! $mapping->isIndexed()) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); } @@ -113,8 +114,8 @@ public function containsKey(PersistentCollection $collection, mixed $key): bool // 'mappedBy' field. $criteria = new Criteria(); - $criteria->andWhere(Criteria::expr()->eq($mapping['mappedBy'], $collection->getOwner())); - $criteria->andWhere(Criteria::expr()->eq($mapping['indexBy'], $key)); + $criteria->andWhere(Criteria::expr()->eq($mapping->mappedBy, $collection->getOwner())); + $criteria->andWhere(Criteria::expr()->eq($mapping->indexBy(), $key)); return (bool) $persister->count($criteria); } diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 46875005477..c29b7b2f60b 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -918,9 +918,9 @@ private function loadArrayFromResult(AssociationMapping $assoc, Result $stmt): a $rsm = $this->currentPersisterContext->rsm; $hints = [UnitOfWork::HINT_DEFEREAGERLOAD => true]; - if (isset($assoc->indexBy)) { + if ($assoc->isIndexed()) { $rsm = clone $this->currentPersisterContext->rsm; // this is necessary because the "default rsm" should be changed. - $rsm->addIndexBy('r', $assoc->indexBy); + $rsm->addIndexBy('r', $assoc->indexBy()); } return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); @@ -942,9 +942,9 @@ private function loadCollectionFromStatement( 'collection' => $coll, ]; - if (isset($assoc->indexBy)) { + if ($assoc->isIndexed()) { $rsm = clone $this->currentPersisterContext->rsm; // this is necessary because the "default rsm" should be changed. - $rsm->addIndexBy('r', $assoc->indexBy); + $rsm->addIndexBy('r', $assoc->indexBy()); } return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); @@ -1049,8 +1049,8 @@ public function getSelectSQL( $joinSql = $this->getSelectManyToManyJoinSQL($assoc); } - if ($assoc !== null && isset($assoc->orderBy)) { - $orderBy = $assoc->orderBy; + if ($assoc !== null && $assoc->isOrdered()) { + $orderBy = $assoc->orderBy(); } if ($orderBy) { @@ -1244,8 +1244,8 @@ protected function getSelectColumnsSQL(): string $association = $assoc; $joinCondition = []; - if (isset($assoc->indexBy)) { - $this->currentPersisterContext->rsm->addIndexBy($assocAlias, $assoc->indexBy); + if ($assoc->isIndexed()) { + $this->currentPersisterContext->rsm->addIndexBy($assocAlias, $assoc->indexBy()); } if (! $assoc->isOwningSide()) { diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index ca3f9405e5a..bd2c07bd534 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -271,8 +271,8 @@ public function getSelectSQL( $orderBySql = ''; - if ($assoc !== null && isset($assoc['orderBy'])) { - $orderBy = $assoc['orderBy']; + if ($assoc !== null && $assoc->isOrdered()) { + $orderBy = $assoc->orderBy(); } if ($orderBy) { diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 05c76b31bdc..c605c22862c 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1027,8 +1027,8 @@ public function walkJoinAssociationDeclaration( if ($indexBy) { // For Many-To-One or One-To-One associations this obviously makes no sense, but is ignored silently. $this->walkIndexBy($indexBy); - } elseif (isset($relation['indexBy'])) { - $this->rsm->addIndexBy($joinedDqlAlias, $relation['indexBy']); + } elseif ($relation->isIndexed()) { + $this->rsm->addIndexBy($joinedDqlAlias, $relation->indexBy()); } return $sql; diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 6c9baf9a9a4..e58d585bd1c 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -214,8 +214,8 @@ public function validateClass(ClassMetadata $class): array } } - if (isset($assoc['orderBy']) && $assoc['orderBy'] !== null) { - foreach ($assoc['orderBy'] as $orderField => $orientation) { + if ($assoc->isOrdered()) { + foreach ($assoc->orderBy() as $orderField => $orientation) { if (! $targetMetadata->hasField($orderField) && ! $targetMetadata->hasAssociation($orderField)) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' is ordered by a foreign field ' . $orderField . ' that is not a field on the target entity ' . $targetMetadata->name . '.'; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index a7f0caa2b8f..c6d104fda0f 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -575,6 +575,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void } $assoc = $class->associationMappings[$name]; + assert($assoc->isToMany()); // Inject PersistentCollection $value = new PersistentCollection( @@ -671,6 +672,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void // created one. This can only mean it was cloned and replaced // on another entity. if ($actualValue instanceof PersistentCollection) { + assert($assoc->isToMany()); $owner = $actualValue->getOwner(); if ($owner === null) { // cloned $actualValue->setOwner($entity, $assoc); @@ -2433,6 +2435,7 @@ public function createEntity(string $className, array $data, array &$hints = []) break; default: + assert($assoc->isToMany()); // Ignore if its a cached collection if (isset($hints[Query::HINT_CACHE_ENABLED]) && $class->getFieldValue($entity, $field) instanceof PersistentCollection) { break; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c65e2ab916e..293fe5d26c0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -125,6 +125,11 @@ parameters: count: 1 path: lib/Doctrine/ORM/EntityRepository.php + - + message: "#^Parameter \\#2 \\$assoc of method Doctrine\\\\ORM\\\\PersistentCollection\\<\\(int\\|string\\),mixed\\>\\:\\:setOwner\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping&Doctrine\\\\ORM\\\\Mapping\\\\ToManyAssociationMapping, Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping given\\.$#" + count: 1 + path: lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php + - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\:\\:fullyQualifiedClassName\\(\\) should return class\\-string\\|null but returns string\\|null\\.$#" count: 1 @@ -300,6 +305,16 @@ parameters: count: 1 path: lib/Doctrine/ORM/Tools/SchemaTool.php + - + message: "#^Parameter \\#2 \\$assoc of method Doctrine\\\\ORM\\\\PersistentCollection\\<\\(int\\|string\\),mixed\\>\\:\\:setOwner\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping&Doctrine\\\\ORM\\\\Mapping\\\\ToManyAssociationMapping, Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping given\\.$#" + count: 4 + path: lib/Doctrine/ORM/UnitOfWork.php + + - + message: "#^Parameter \\#2 \\$assoc of method Doctrine\\\\ORM\\\\PersistentCollection\\<\\*NEVER\\*,\\*NEVER\\*\\>\\:\\:setOwner\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping&Doctrine\\\\ORM\\\\Mapping\\\\ToManyAssociationMapping, Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping given\\.$#" + count: 1 + path: lib/Doctrine/ORM/UnitOfWork.php + - message: "#^Parameter \\#3 \\$changeSet of class Doctrine\\\\ORM\\\\Event\\\\PreUpdateEventArgs constructor is passed by reference, so it expects variables only$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index cb11aefbd29..1774b1f74d8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -28,6 +28,7 @@ parameters: - message: "#^Access to an undefined property .*Mapping\\:\\:\\$(inversedBy|mappedBy|joinColumns|joinTableColumns|(relation|source|target)To(Target|Source)KeyColumns|joinTable|indexBy)\\.$#" paths: + - lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -36,3 +37,11 @@ parameters: - lib/Doctrine/ORM/Query/SqlWalker.php - lib/Doctrine/ORM/Tools/SchemaValidator.php - lib/Doctrine/ORM/UnitOfWork.php + - + message: "#^Call to an undefined method .*Mapping\\:\\:(order|index)By\\(\\)\\.#" + paths: + - lib/Doctrine/ORM/Mapping/AssociationMapping.php + - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php + - lib/Doctrine/ORM/Query/SqlWalker.php + - lib/Doctrine/ORM/Tools/SchemaValidator.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a809e4fd06f..2a010d89f72 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -720,6 +720,9 @@ getOwner()]]> getOwner()]]> + + mappedBy]]> + diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index e3abecf83e3..8accb5b9ad4 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -396,7 +396,7 @@ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): C self::assertTrue($class->associationMappings['groups']['isCascadeDetach']); self::assertTrue($class->associationMappings['groups']['isCascadeMerge']); - self::assertFalse(isset($class->associationMappings['groups']['orderBy'])); + self::assertFalse($class->associationMappings['groups']->isOrdered()); return $class; } @@ -1128,7 +1128,7 @@ public static function loadMetadata(ClassMetadata $metadata): void ], ], ], - 'orderBy' => null, + 'orderBy' => [], ], ); $metadata->table['uniqueConstraints'] = [ From 380f8a42f35fe52065e3ab45d81d223d9268a3a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 8 May 2023 17:05:29 +0200 Subject: [PATCH 262/475] Introduce method to get to the owning side Throughout the codebase, there is this pattern where we ensure we have the owning side of an association. It involves accessing it from the associationMappings array. In the end, static analysis cannot know that the association is indeed owning. By introducing this convenience method, we make this clear, and also delegate the complexity to the class metadata factory. --- .../ORM/Cache/DefaultEntityHydrator.php | 4 +-- .../ORM/Mapping/ClassMetadataFactory.php | 16 +++++++++++ .../Collection/ManyToManyPersister.php | 18 +++++-------- .../Entity/BasicEntityPersister.php | 27 ++++++------------- .../ORM/Query/AST/Functions/SizeFunction.php | 7 +++-- lib/Doctrine/ORM/Query/SqlWalker.php | 4 +-- 6 files changed, 37 insertions(+), 39 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 6afd8569300..57b345b9455 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -65,9 +65,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob if (! isset($assoc['cache'])) { $targetClassMetadata = $this->em->getClassMetadata($assoc['targetEntity']); - $owningAssociation = ! $assoc->isOwningSide() - ? $targetClassMetadata->associationMappings[$assoc['mappedBy']] - : $assoc; + $owningAssociation = $this->em->getMetadataFactory()->getOwningSide($assoc); $associationIds = $this->identifierFlattener->flattenIdentifier( $targetClassMetadata, $targetClassMetadata->getIdentifierValues($data[$name]), diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 0137782533c..6a8aed1f42d 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -61,6 +61,22 @@ public function setEntityManager(EntityManagerInterface $em): void $this->em = $em; } + final public function getOwningSide(AssociationMapping $maybeOwningSide): OwningSideMapping + { + if ($maybeOwningSide instanceof OwningSideMapping) { + return $maybeOwningSide; + } + + assert($maybeOwningSide instanceof InverseSideMapping); + + $owningSide = $this->getMetadataFor($maybeOwningSide->targetEntity) + ->associationMappings[$maybeOwningSide->mappedBy]; + + assert($owningSide instanceof OwningSideMapping); + + return $owningSide; + } + protected function initialize(): void { $this->driver = $this->em->getConfiguration()->getMetadataDriverImpl(); diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index e7d087cfcfe..9f652292647 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -112,10 +112,7 @@ public function count(PersistentCollection $collection): int $mapping = $collection->getMapping(); $id = $this->uow->getEntityIdentifier($collection->getOwner()); $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); - $targetClass = $this->em->getClassMetadata($mapping->targetEntity); - $association = ! $mapping->isOwningSide() - ? $targetClass->associationMappings[$mapping->mappedBy] - : $mapping; + $association = $this->em->getMetadataFactory()->getOwningSide($mapping); assert($association->isManyToManyOwningSide()); @@ -226,13 +223,14 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri if (! $mapping->isOwningSide()) { assert($mapping instanceof InverseSideMapping); $associationSourceClass = $targetClass; - $mapping = $targetClass->associationMappings[$mapping->mappedBy]; $sourceRelationMode = 'relationToTargetKeyColumns'; } else { $associationSourceClass = $ownerMetadata; $sourceRelationMode = 'relationToSourceKeyColumns'; } + $mapping = $this->em->getMetadataFactory()->getOwningSide($mapping); + foreach ($mapping->$sourceRelationMode as $key => $value) { $whereClauses[] = sprintf('t.%s = ?', $key); $params[] = $ownerMetadata->containsForeignIdentifier @@ -347,10 +345,7 @@ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, strin */ protected function getOnConditionSQL(AssociationMapping $mapping): array { - $targetClass = $this->em->getClassMetadata($mapping->targetEntity); - $association = ! $mapping->isOwningSide() - ? $targetClass->associationMappings[$mapping->mappedBy] - : $mapping; + $association = $this->em->getMetadataFactory()->getOwningSide($mapping); assert($association->isManyToManyOwningSide()); @@ -360,6 +355,7 @@ protected function getOnConditionSQL(AssociationMapping $mapping): array $conditions = []; + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); foreach ($joinColumns as $joinColumn) { $joinColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $refColumnName = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $targetClass, $this->platform); @@ -670,8 +666,6 @@ private function getJoinTableRestrictions( $targetClass = $this->em->getClassMetadata($mapping->sourceEntity); $sourceId = $this->uow->getEntityIdentifier($element); $targetId = $this->uow->getEntityIdentifier($collection->getOwner()); - - $mapping = $sourceClass->associationMappings[$mapping['mappedBy']]; } else { $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); $targetClass = $this->em->getClassMetadata($mapping->targetEntity); @@ -679,6 +673,8 @@ private function getJoinTableRestrictions( $targetId = $this->uow->getEntityIdentifier($element); } + $mapping = $this->em->getMetadataFactory()->getOwningSide($mapping); + $quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $sourceClass, $this->platform); $whereClauses = []; $params = []; diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index c29b7b2f60b..d039f3627a7 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -514,10 +514,11 @@ protected function deleteJoinTableRecords(array $identifier, array $types): void if (! $mapping->isOwningSide()) { assert($mapping instanceof InverseSideMapping); - $class = $this->em->getClassMetadata($mapping->targetEntity); - $association = $class->associationMappings[$mapping->mappedBy]; + $class = $this->em->getClassMetadata($mapping->targetEntity); } + $association = $this->em->getMetadataFactory()->getOwningSide($association); + assert($association->isManyToManyOwningSide()); $joinColumns = $mapping->isOwningSide() @@ -977,10 +978,11 @@ private function getManyToManyStatement( if (! $assoc->isOwningSide()) { assert(isset($assoc->mappedBy)); - $class = $this->em->getClassMetadata($assoc->targetEntity); - $association = $class->associationMappings[$assoc->mappedBy]; + $class = $this->em->getClassMetadata($assoc->targetEntity); } + $association = $this->em->getMetadataFactory()->getOwningSide($assoc); + assert($association->isManyToManyOwningSide()); $joinColumns = $assoc->isOwningSide() @@ -1335,12 +1337,7 @@ protected function getSelectManyToManyJoinSQL(AssociationMapping $manyToMany): s $association = $manyToMany; $sourceTableAlias = $this->getSQLTableAlias($this->class->name); - if (! $manyToMany->isOwningSide()) { - assert(isset($manyToMany->mappedBy)); - $targetEntity = $this->em->getClassMetadata($manyToMany->targetEntity); - $association = $targetEntity->associationMappings[$manyToMany->mappedBy]; - } - + $association = $this->em->getMetadataFactory()->getOwningSide($manyToMany); assert($association->isManyToManyOwningSide()); $joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->class, $this->platform); @@ -1858,17 +1855,9 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar break; case isset($class->associationMappings[$field]): - $assoc = $class->associationMappings[$field]; + $assoc = $this->em->getMetadataFactory()->getOwningSide($class->associationMappings[$field]); $class = $this->em->getClassMetadata($assoc->targetEntity); - if (! $assoc->isOwningSide()) { - assert(isset($assoc->mappedBy)); - $assoc = $class->associationMappings[$assoc->mappedBy]; - $class = $this->em->getClassMetadata($assoc->targetEntity); - } - - assert($assoc->isOwningSide()); - if ($assoc->isManyToManyOwningSide()) { $columns = $assoc->relationToTargetKeyColumns; } else { diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 272b90f6144..fa1be985242 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -61,9 +61,7 @@ public function getSql(SqlWalker $sqlWalker): string . $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $platform); } } else { // many-to-many - $targetClass = $entityManager->getClassMetadata($assoc->targetEntity); - - $owningAssoc = $assoc->isOwningSide() ? $assoc : $targetClass->associationMappings[$assoc['mappedBy']]; + $owningAssoc = $entityManager->getMetadataFactory()->getOwningSide($assoc); $joinTable = $owningAssoc['joinTable']; // SQL table aliases @@ -71,7 +69,8 @@ public function getSql(SqlWalker $sqlWalker): string $sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); // join to target table - $sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $platform) . ' ' . $joinTableAlias . ' WHERE '; + $targetClass = $entityManager->getClassMetadata($assoc->targetEntity); + $sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $platform) . ' ' . $joinTableAlias . ' WHERE '; $joinColumns = $assoc->isOwningSide() ? $joinTable['joinColumns'] diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index c605c22862c..4cde0dbc00c 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -895,7 +895,7 @@ public function walkJoinAssociationDeclaration( $sourceTableAlias = $this->getSQLTableAlias($sourceClass->getTableName(), $associationPathExpression->identificationVariable); // Ensure we got the owning side, since it has all mapping info - $assoc = ! $relation['isOwningSide'] ? $targetClass->associationMappings[$relation['mappedBy']] : $relation; + $assoc = $this->em->getMetadataFactory()->getOwningSide($relation); if ($this->query->getHint(Query::HINT_INTERNAL_ITERATION) === true && (! $this->query->getHint(self::HINT_DISTINCT) || isset($this->selectedClasses[$joinedDqlAlias]))) { if ($relation->isToMany()) { @@ -1885,7 +1885,7 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c assert($assoc->isManyToMany()); $targetClass = $this->em->getClassMetadata($assoc->targetEntity); - $owningAssoc = $assoc['isOwningSide'] ? $assoc : $targetClass->associationMappings[$assoc['mappedBy']]; + $owningAssoc = $this->em->getMetadataFactory()->getOwningSide($assoc); $joinTable = $owningAssoc['joinTable']; // SQL table aliases From 1c8b5181b5e329f8dc01bfbe2d85d93af1e4a412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 11 May 2023 21:24:09 +0200 Subject: [PATCH 263/475] Add templating for getOwningSide It allows to remove many assertions. --- .../ORM/Mapping/ClassMetadataFactory.php | 19 +++++++++++++++++- .../Collection/ManyToManyPersister.php | 6 ------ .../Entity/BasicEntityPersister.php | 20 +++++++------------ phpstan.neon | 6 ++++++ psalm-baseline.xml | 5 +++++ 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 6a8aed1f42d..98aa7411952 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -61,9 +61,24 @@ public function setEntityManager(EntityManagerInterface $em): void $this->em = $em; } + /** + * @param A $maybeOwningSide + * + * @return (A is ManyToManyAssociationMapping ? ManyToManyOwningSideMapping : ( + * A is OneToOneAssociationMapping ? OneToOneOwningSideMapping : ( + * A is OneToManyAssociationMapping ? ManyToOneAssociationMapping : ( + * A is ManyToOneAssociationMapping ? ManyToOneAssociationMapping : OwningSideMapping + * )))) + * + * @template A of AssociationMapping + */ final public function getOwningSide(AssociationMapping $maybeOwningSide): OwningSideMapping { if ($maybeOwningSide instanceof OwningSideMapping) { + assert($maybeOwningSide instanceof ManyToManyOwningSideMapping || + $maybeOwningSide instanceof OneToOneOwningSideMapping || + $maybeOwningSide instanceof ManyToOneAssociationMapping); + return $maybeOwningSide; } @@ -72,7 +87,9 @@ final public function getOwningSide(AssociationMapping $maybeOwningSide): Owning $owningSide = $this->getMetadataFor($maybeOwningSide->targetEntity) ->associationMappings[$maybeOwningSide->mappedBy]; - assert($owningSide instanceof OwningSideMapping); + assert($owningSide instanceof ManyToManyOwningSideMapping || + $owningSide instanceof OneToOneOwningSideMapping || + $owningSide instanceof ManyToOneAssociationMapping); return $owningSide; } diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 9f652292647..64c8accadea 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -114,8 +114,6 @@ public function count(PersistentCollection $collection): int $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); $association = $this->em->getMetadataFactory()->getOwningSide($mapping); - assert($association->isManyToManyOwningSide()); - $joinTableName = $this->quoteStrategy->getJoinTableName($association, $sourceClass, $this->platform); $joinColumns = ! $mapping->isOwningSide() ? $association->joinTable['inverseJoinColumns'] @@ -346,9 +344,6 @@ protected function generateFilterConditionSQL(ClassMetadata $targetEntity, strin protected function getOnConditionSQL(AssociationMapping $mapping): array { $association = $this->em->getMetadataFactory()->getOwningSide($mapping); - - assert($association->isManyToManyOwningSide()); - $joinColumns = $mapping->isOwningSide() ? $association->joinTable['inverseJoinColumns'] : $association->joinTable['joinColumns']; @@ -680,7 +675,6 @@ private function getJoinTableRestrictions( $params = []; $types = []; - assert($mapping->isManyToManyOwningSide()); foreach ($mapping->joinTableColumns as $joinTableColumn) { $whereClauses[] = ($addFilters ? 't.' : '') . $joinTableColumn . ' = ?'; diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index d039f3627a7..0629e409edd 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -21,6 +21,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\InverseSideMapping; use Doctrine\ORM\Mapping\JoinColumnMapping; +use Doctrine\ORM\Mapping\ManyToManyAssociationMapping; use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\OneToManyAssociationMapping; use Doctrine\ORM\Mapping\QuoteStrategy; @@ -518,9 +519,6 @@ protected function deleteJoinTableRecords(array $identifier, array $types): void } $association = $this->em->getMetadataFactory()->getOwningSide($association); - - assert($association->isManyToManyOwningSide()); - $joinColumns = $mapping->isOwningSide() ? $association->joinTable['joinColumns'] : $association->joinTable['inverseJoinColumns']; @@ -902,6 +900,7 @@ public function getManyToManyCollection( int|null $offset = null, int|null $limit = null, ): array { + assert($assoc->isManyToMany()); $this->switchPersisterContext($offset, $limit); $stmt = $this->getManyToManyStatement($assoc, $sourceEntity, $offset, $limit); @@ -956,6 +955,7 @@ private function loadCollectionFromStatement( */ public function loadManyToManyCollection(AssociationMapping $assoc, object $sourceEntity, PersistentCollection $collection): array { + assert($assoc->isManyToMany()); $stmt = $this->getManyToManyStatement($assoc, $sourceEntity); return $this->loadCollectionFromStatement($assoc, $stmt, $collection); @@ -963,7 +963,7 @@ public function loadManyToManyCollection(AssociationMapping $assoc, object $sour /** @throws MappingException */ private function getManyToManyStatement( - AssociationMapping $assoc, + AssociationMapping&ManyToManyAssociationMapping $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null, @@ -977,14 +977,10 @@ private function getManyToManyStatement( $parameters = []; if (! $assoc->isOwningSide()) { - assert(isset($assoc->mappedBy)); $class = $this->em->getClassMetadata($assoc->targetEntity); } $association = $this->em->getMetadataFactory()->getOwningSide($assoc); - - assert($association->isManyToManyOwningSide()); - $joinColumns = $assoc->isOwningSide() ? $association->joinTable['joinColumns'] : $association->joinTable['inverseJoinColumns']; @@ -1331,15 +1327,13 @@ protected function getSelectColumnAssociationSQL( * Gets the SQL join fragment used when selecting entities from a * many-to-many association. */ - protected function getSelectManyToManyJoinSQL(AssociationMapping $manyToMany): string + protected function getSelectManyToManyJoinSQL(AssociationMapping&ManyToManyAssociationMapping $manyToMany): string { $conditions = []; $association = $manyToMany; $sourceTableAlias = $this->getSQLTableAlias($this->class->name); - $association = $this->em->getMetadataFactory()->getOwningSide($manyToMany); - assert($association->isManyToManyOwningSide()); - + $association = $this->em->getMetadataFactory()->getOwningSide($manyToMany); $joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->class, $this->platform); $joinColumns = $manyToMany->isOwningSide() ? $association->joinTable['inverseJoinColumns'] @@ -1861,7 +1855,7 @@ private function getTypes(string $field, mixed $value, ClassMetadata $class): ar if ($assoc->isManyToManyOwningSide()) { $columns = $assoc->relationToTargetKeyColumns; } else { - assert($assoc->isToOneOwningSide() || $assoc->isManyToOne()); + assert($assoc->isToOneOwningSide()); $columns = $assoc->sourceToTargetKeyColumns; } diff --git a/phpstan.neon b/phpstan.neon index 1774b1f74d8..d63c4b8b0fc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -45,3 +45,9 @@ parameters: - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php - lib/Doctrine/ORM/Query/SqlWalker.php - lib/Doctrine/ORM/Tools/SchemaValidator.php + + - + message: '#^.*Doctrine\\ORM\\Mapping\\AssociationMapping&Doctrine\\ORM\\Mapping\\ManyToManyAssociationMapping, Doctrine\\ORM\\Mapping\\AssociationMapping given\.#' + paths: + - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 2a010d89f72..78135a9cbb4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -407,6 +407,11 @@ generatorType]]> idGenerator]]> + + assert($owningSide instanceof ManyToManyOwningSideMapping || + $owningSide instanceof OneToOneOwningSideMapping || + $owningSide instanceof ManyToOneAssociationMapping) + From 63561fc382997b44896f1f61d9b4839920a31cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 11 May 2023 22:25:22 +0200 Subject: [PATCH 264/475] Narrow down ClassMetadata::associationMappings type --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 10 ++++++++-- .../Persisters/Entity/BasicEntityPersister.php | 4 +--- phpstan-baseline.neon | 15 --------------- phpstan.neon | 6 ------ 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 8210ba16482..0a2d62e2e94 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -62,9 +62,9 @@ * get the whole class name, namespace inclusive, prepended to every property in * the serialized representation). * + * @psalm-type ConcreteAssociationMapping = OneToOneOwningSideMapping|OneToOneInverseSideMapping|ManyToOneAssociationMapping|OneToManyAssociationMapping|ManyToManyOwningSideMapping|ManyToManyInverseSideMapping * @template-covariant T of object * @template-implements PersistenceClassMetadata - * } */ class ClassMetadata implements PersistenceClassMetadata, Stringable { @@ -439,7 +439,7 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable * ) * * - * @psalm-var array + * @psalm-var array */ public array $associationMappings = []; @@ -1256,6 +1256,8 @@ protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping * * @psalm-param array $mapping The mapping. * + * @return ConcreteAssociationMapping + * * @throws MappingException If something is wrong with the mapping. */ protected function _validateAndCompleteAssociationMapping(array $mapping): AssociationMapping @@ -1909,6 +1911,8 @@ public function mapField(array $mapping): void * Adds an association mapping without completing/validating it. * This is mainly used to add inherited association mappings to derived classes. * + * @param ConcreteAssociationMapping $mapping + * * @throws MappingException */ public function addInheritedAssociationMapping(AssociationMapping $mapping/*, $owningClassName = null*/): void @@ -1991,6 +1995,8 @@ public function mapManyToMany(array $mapping): void /** * Stores the association mapping. * + * @param ConcreteAssociationMapping $assocMapping + * * @throws MappingException */ protected function _storeAssociationMapping(AssociationMapping $assocMapping): void diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 0629e409edd..118393bc950 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -19,7 +19,6 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\InverseSideMapping; use Doctrine\ORM\Mapping\JoinColumnMapping; use Doctrine\ORM\Mapping\ManyToManyAssociationMapping; use Doctrine\ORM\Mapping\MappingException; @@ -514,7 +513,6 @@ protected function deleteJoinTableRecords(array $identifier, array $types): void $keys = []; if (! $mapping->isOwningSide()) { - assert($mapping instanceof InverseSideMapping); $class = $this->em->getClassMetadata($mapping->targetEntity); } @@ -1243,11 +1241,11 @@ protected function getSelectColumnsSQL(): string $joinCondition = []; if ($assoc->isIndexed()) { + assert($assoc->isToMany()); $this->currentPersisterContext->rsm->addIndexBy($assocAlias, $assoc->indexBy()); } if (! $assoc->isOwningSide()) { - assert(isset($assoc->mappedBy)); $eagerEntity = $this->em->getClassMetadata($assoc->targetEntity); $association = $eagerEntity->getAssociationMapping($assoc->mappedBy); } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 293fe5d26c0..c65e2ab916e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -125,11 +125,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/EntityRepository.php - - - message: "#^Parameter \\#2 \\$assoc of method Doctrine\\\\ORM\\\\PersistentCollection\\<\\(int\\|string\\),mixed\\>\\:\\:setOwner\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping&Doctrine\\\\ORM\\\\Mapping\\\\ToManyAssociationMapping, Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping given\\.$#" - count: 1 - path: lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\:\\:fullyQualifiedClassName\\(\\) should return class\\-string\\|null but returns string\\|null\\.$#" count: 1 @@ -305,16 +300,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Tools/SchemaTool.php - - - message: "#^Parameter \\#2 \\$assoc of method Doctrine\\\\ORM\\\\PersistentCollection\\<\\(int\\|string\\),mixed\\>\\:\\:setOwner\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping&Doctrine\\\\ORM\\\\Mapping\\\\ToManyAssociationMapping, Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping given\\.$#" - count: 4 - path: lib/Doctrine/ORM/UnitOfWork.php - - - - message: "#^Parameter \\#2 \\$assoc of method Doctrine\\\\ORM\\\\PersistentCollection\\<\\*NEVER\\*,\\*NEVER\\*\\>\\:\\:setOwner\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping&Doctrine\\\\ORM\\\\Mapping\\\\ToManyAssociationMapping, Doctrine\\\\ORM\\\\Mapping\\\\AssociationMapping given\\.$#" - count: 1 - path: lib/Doctrine/ORM/UnitOfWork.php - - message: "#^Parameter \\#3 \\$changeSet of class Doctrine\\\\ORM\\\\Event\\\\PreUpdateEventArgs constructor is passed by reference, so it expects variables only$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index d63c4b8b0fc..c16bec1c863 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -31,12 +31,7 @@ parameters: - lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php - lib/Doctrine/ORM/PersistentCollection.php - - lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php - - lib/Doctrine/ORM/Query/SqlWalker.php - - lib/Doctrine/ORM/Tools/SchemaValidator.php - - lib/Doctrine/ORM/UnitOfWork.php - message: "#^Call to an undefined method .*Mapping\\:\\:(order|index)By\\(\\)\\.#" paths: @@ -44,7 +39,6 @@ parameters: - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php - lib/Doctrine/ORM/Query/SqlWalker.php - - lib/Doctrine/ORM/Tools/SchemaValidator.php - message: '#^.*Doctrine\\ORM\\Mapping\\AssociationMapping&Doctrine\\ORM\\Mapping\\ManyToManyAssociationMapping, Doctrine\\ORM\\Mapping\\AssociationMapping given\.#' From 3b88e4844a368db8d75591aa3b0c651fe31fb567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 12 May 2023 21:06:20 +0200 Subject: [PATCH 265/475] Move joinColumnFieldNames down the class hierarchy It has only meaning for ToOneOwningSideMapping --- .../ORM/Mapping/AssociationMapping.php | 4 ---- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 3 +-- .../ORM/Mapping/ToOneOwningSideMapping.php | 4 ++++ .../ORM/Mapping/AssociationMappingTest.php | 24 +++++++++---------- .../ManyToOneAssociationMappingTest.php | 2 ++ .../Mapping/OneToOneOwningSideMappingTest.php | 2 ++ 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index 396f0e826dd..3e386ac4b1f 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -62,9 +62,6 @@ abstract class AssociationMapping implements ArrayAccess public bool|null $isOnDeleteCascade = null; - /** @var array|null */ - public array|null $joinColumnFieldNames = null; - /** @var class-string|null */ public string|null $originalClass = null; @@ -335,7 +332,6 @@ public function __sleep(): array 'inherited', 'declared', 'cache', - 'joinColumnFieldNames', 'originalClass', 'originalField', ] as $stringOrArrayProperty diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 8210ba16482..366caa727c2 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1727,11 +1727,10 @@ public function setAssociationOverride(string $fieldName, array $overrideMapping $mapping['fetch'] = $overrideMapping['fetch']; } - $mapping['joinColumnFieldNames'] = null; - switch ($mapping['type']) { case self::ONE_TO_ONE: case self::MANY_TO_ONE: + $mapping['joinColumnFieldNames'] = []; $mapping['sourceToTargetKeyColumns'] = []; break; case self::MANY_TO_MANY: diff --git a/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php index f356860f833..5c39abda67c 100644 --- a/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php @@ -22,6 +22,9 @@ abstract class ToOneOwningSideMapping extends OwningSideMapping implements ToOne /** @var list */ public array $joinColumns = []; + /** @var array */ + public array $joinColumnFieldNames = []; + /** * @param array $mappingArray * @psalm-param array{ @@ -169,6 +172,7 @@ public function __sleep(): array return [ ...parent::__sleep(), 'joinColumns', + 'joinColumnFieldNames', 'sourceToTargetKeyColumns', 'targetToSourceKeyColumns', ]; diff --git a/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php index facc680be32..22c329392bf 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php @@ -23,18 +23,17 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->cascade = ['persist']; - $mapping->fetch = ClassMetadata::FETCH_EAGER; - $mapping->inherited = self::class; - $mapping->declared = self::class; - $mapping->cache = ['usage' => ClassMetadata::CACHE_USAGE_READ_ONLY]; - $mapping->id = true; - $mapping->isOnDeleteCascade = true; - $mapping->joinColumnFieldNames = ['foo' => 'bar']; - $mapping->originalClass = self::class; - $mapping->originalField = 'foo'; - $mapping->orphanRemoval = true; - $mapping->unique = true; + $mapping->cascade = ['persist']; + $mapping->fetch = ClassMetadata::FETCH_EAGER; + $mapping->inherited = self::class; + $mapping->declared = self::class; + $mapping->cache = ['usage' => ClassMetadata::CACHE_USAGE_READ_ONLY]; + $mapping->id = true; + $mapping->isOnDeleteCascade = true; + $mapping->originalClass = self::class; + $mapping->originalField = 'foo'; + $mapping->orphanRemoval = true; + $mapping->unique = true; $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof AssociationMapping); @@ -46,7 +45,6 @@ public function testItSurvivesSerialization(): void self::assertSame(['usage' => ClassMetadata::CACHE_USAGE_READ_ONLY], $resurrectedMapping->cache); self::assertTrue($resurrectedMapping->id); self::assertTrue($resurrectedMapping->isOnDeleteCascade); - self::assertSame(['foo' => 'bar'], $resurrectedMapping->joinColumnFieldNames); self::assertSame(self::class, $resurrectedMapping->originalClass); self::assertSame('foo', $resurrectedMapping->originalField); self::assertTrue($resurrectedMapping->orphanRemoval); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php index 8e9260b1943..d183f9df158 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php @@ -23,6 +23,7 @@ public function testItSurvivesSerialization(): void ); $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->joinColumnFieldNames = ['foo' => 'bar']; $mapping->sourceToTargetKeyColumns = ['foo' => 'bar']; $mapping->targetToSourceKeyColumns = ['bar' => 'foo']; @@ -30,6 +31,7 @@ public function testItSurvivesSerialization(): void assert($resurrectedMapping instanceof ManyToOneAssociationMapping); self::assertCount(1, $resurrectedMapping->joinColumns); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->joinColumnFieldNames); self::assertSame(['foo' => 'bar'], $resurrectedMapping->sourceToTargetKeyColumns); self::assertSame(['bar' => 'foo'], $resurrectedMapping->targetToSourceKeyColumns); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php index eb246b99802..f8d3ea0e8c6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php @@ -23,6 +23,7 @@ public function testItSurvivesSerialization(): void ); $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->joinColumnFieldNames = ['foo' => 'bar']; $mapping->sourceToTargetKeyColumns = ['foo' => 'bar']; $mapping->targetToSourceKeyColumns = ['bar' => 'foo']; @@ -30,6 +31,7 @@ public function testItSurvivesSerialization(): void assert($resurrectedMapping instanceof OneToOneOwningSideMapping); self::assertCount(1, $resurrectedMapping->joinColumns); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->joinColumnFieldNames); self::assertSame(['foo' => 'bar'], $resurrectedMapping->sourceToTargetKeyColumns); self::assertSame(['bar' => 'foo'], $resurrectedMapping->targetToSourceKeyColumns); } From 00beecce7455000d36db1dbce940ce54cc94d9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 8 May 2023 16:35:41 +0200 Subject: [PATCH 266/475] fix wrong phpdoc The keys in the join columns array have no meaning, and are just sequential integers. --- lib/Doctrine/ORM/Tools/SchemaTool.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index c25c02bed51..fbc46e99970 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -634,7 +634,7 @@ private function getDefiningClass(ClassMetadata $class, string $referencedColumn /** * Gathers columns and fk constraints that are required for one part of relationship. * - * @psalm-param array $joinColumns + * @psalm-param list $joinColumns * @psalm-param list $primaryKeyColumns * @psalm-param array Date: Thu, 11 May 2023 21:14:37 +0200 Subject: [PATCH 267/475] Introduce convenience methods to narrow types These methods assert the type of the mapping provided by the collection according to the name of the class they are in: the one to many persister only ever deals with one to many associations, and the many to many persister only ever deals with many to many associations. --- .../Collection/ManyToManyPersister.php | 38 ++++++++++++------- .../Collection/OneToManyPersister.php | 19 +++++++--- phpstan.neon | 5 ++- psalm-baseline.xml | 4 +- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 64c8accadea..6934c2e215d 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\InverseSideMapping; +use Doctrine\ORM\Mapping\ManyToManyAssociationMapping; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Persisters\SqlValueVisitor; use Doctrine\ORM\Query; @@ -33,7 +34,7 @@ class ManyToManyPersister extends AbstractCollectionPersister { public function delete(PersistentCollection $collection): void { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); if (! $mapping->isOwningSide()) { return; // ignore inverse side @@ -53,7 +54,7 @@ public function delete(PersistentCollection $collection): void public function update(PersistentCollection $collection): void { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); if (! $mapping->isOwningSide()) { return; // ignore inverse side @@ -81,7 +82,7 @@ public function update(PersistentCollection $collection): void public function get(PersistentCollection $collection, mixed $index): object|null { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); if (! $mapping->isIndexed()) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); @@ -109,7 +110,7 @@ public function count(PersistentCollection $collection): int $conditions = []; $params = []; $types = []; - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); $id = $this->uow->getEntityIdentifier($collection->getOwner()); $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); $association = $this->em->getMetadataFactory()->getOwningSide($mapping); @@ -162,7 +163,7 @@ public function count(PersistentCollection $collection): int */ public function slice(PersistentCollection $collection, int $offset, int|null $length = null): array { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); return $persister->getManyToManyCollection($mapping, $collection->getOwner(), $offset, $length); @@ -170,7 +171,7 @@ public function slice(PersistentCollection $collection, int $offset, int|null $l public function containsKey(PersistentCollection $collection, mixed $key): bool { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); if (! $mapping->isIndexed()) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); @@ -209,7 +210,7 @@ public function contains(PersistentCollection $collection, object $element): boo */ public function loadCriteria(PersistentCollection $collection, Criteria $criteria): array { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); $owner = $collection->getOwner(); $ownerMetadata = $this->em->getClassMetadata($owner::class); $id = $this->uow->getEntityIdentifier($owner); @@ -364,7 +365,7 @@ protected function getOnConditionSQL(AssociationMapping $mapping): array protected function getDeleteSQL(PersistentCollection $collection): string { $columns = []; - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); assert($mapping->isManyToManyOwningSide()); $class = $this->em->getClassMetadata($collection->getOwner()::class); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); @@ -384,7 +385,7 @@ protected function getDeleteSQL(PersistentCollection $collection): string */ protected function getDeleteSQLParameters(PersistentCollection $collection): array { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); assert($mapping->isManyToManyOwningSide()); $identifier = $this->uow->getEntityIdentifier($collection->getOwner()); @@ -415,7 +416,7 @@ protected function getDeleteSQLParameters(PersistentCollection $collection): arr */ protected function getDeleteRowSQL(PersistentCollection $collection): array { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); assert($mapping->isManyToManyOwningSide()); $class = $this->em->getClassMetadata($mapping->sourceEntity); $targetClass = $this->em->getClassMetadata($mapping->targetEntity); @@ -464,7 +465,7 @@ protected function getInsertRowSQL(PersistentCollection $collection): array { $columns = []; $types = []; - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); assert($mapping->isManyToManyOwningSide()); $class = $this->em->getClassMetadata($mapping->sourceEntity); $targetClass = $this->em->getClassMetadata($mapping->targetEntity); @@ -514,7 +515,7 @@ private function collectJoinTableColumnParameters( object $element, ): array { $params = []; - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); assert($mapping->isManyToManyOwningSide()); $isComposite = count($mapping->joinTableColumns) > 2; @@ -563,7 +564,7 @@ private function getJoinTableRestrictionsWithKey( string $key, bool $addFilters, ): array { - $filterMapping = $collection->getMapping(); + $filterMapping = $this->getMapping($collection); $mapping = $filterMapping; $indexBy = $mapping->indexBy(); $id = $this->uow->getEntityIdentifier($collection->getOwner()); @@ -653,7 +654,7 @@ private function getJoinTableRestrictions( object $element, bool $addFilters, ): array { - $filterMapping = $collection->getMapping(); + $filterMapping = $this->getMapping($collection); $mapping = $filterMapping; if (! $mapping->isOwningSide()) { @@ -757,4 +758,13 @@ private function getLimitSql(Criteria $criteria): string return $this->platform->modifyLimitQuery('', $limit, $offset ?? 0); } + + private function getMapping(PersistentCollection $collection): AssociationMapping&ManyToManyAssociationMapping + { + $mapping = $collection->getMapping(); + + assert($mapping instanceof ManyToManyAssociationMapping); + + return $mapping; + } } diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 2391b24617e..8f24bafa959 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Mapping\OneToManyAssociationMapping; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Utility\PersisterHelper; @@ -27,7 +28,7 @@ public function delete(PersistentCollection $collection): void // The only valid case here is when you have weak entities. In this // scenario, you have @OneToMany with orphanRemoval=true, and replacing // the entire collection with a new would trigger this operation. - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); if (! $mapping['orphanRemoval']) { // Handling non-orphan removal should never happen, as @OneToMany @@ -53,8 +54,7 @@ public function update(PersistentCollection $collection): void public function get(PersistentCollection $collection, mixed $index): object|null { - $mapping = $collection->getMapping(); - assert($mapping->isOneToMany()); + $mapping = $this->getMapping($collection); if (! $mapping->isIndexed()) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); @@ -101,7 +101,7 @@ public function slice(PersistentCollection $collection, int $offset, int|null $l public function containsKey(PersistentCollection $collection, mixed $key): bool { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); if (! $mapping->isIndexed()) { throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); @@ -148,7 +148,7 @@ public function loadCriteria(PersistentCollection $collection, Criteria $criteri /** @throws DBALException */ private function deleteEntityCollection(PersistentCollection $collection): int { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); $identifier = $this->uow->getEntityIdentifier($collection->getOwner()); $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); @@ -230,4 +230,13 @@ private function deleteJoinedEntityCollection(PersistentCollection $collection): return $numDeleted; } + + private function getMapping(PersistentCollection $collection): OneToManyAssociationMapping + { + $mapping = $collection->getMapping(); + + assert($mapping->isOneToMany()); + + return $mapping; + } } diff --git a/phpstan.neon b/phpstan.neon index d63c4b8b0fc..846d43d211f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -28,7 +28,6 @@ parameters: - message: "#^Access to an undefined property .*Mapping\\:\\:\\$(inversedBy|mappedBy|joinColumns|joinTableColumns|(relation|source|target)To(Target|Source)KeyColumns|joinTable|indexBy)\\.$#" paths: - - lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -51,3 +50,7 @@ parameters: paths: - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php + + - + message: '#^.*OneToManyPersister::getMapping\(\) should return.*#' + path: lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 78135a9cbb4..05d1ad7e066 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -725,9 +725,7 @@ getOwner()]]> getOwner()]]> - - mappedBy]]> - + From dff40cf35156387becf9193765262450a74ba5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 13 May 2023 10:45:29 +0200 Subject: [PATCH 268/475] Narrow down templated method return type Maybe we do not know enough about the parameter to determine the type of the returned relationship, but we can at least narrow it down to 3 possibilites. --- lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 98aa7411952..13cfe2cb3ac 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -67,7 +67,8 @@ public function setEntityManager(EntityManagerInterface $em): void * @return (A is ManyToManyAssociationMapping ? ManyToManyOwningSideMapping : ( * A is OneToOneAssociationMapping ? OneToOneOwningSideMapping : ( * A is OneToManyAssociationMapping ? ManyToOneAssociationMapping : ( - * A is ManyToOneAssociationMapping ? ManyToOneAssociationMapping : OwningSideMapping + * A is ManyToOneAssociationMapping ? ManyToOneAssociationMapping : + * ManyToManyOwningSideMapping|OneToOneOwningSideMapping|ManyToOneAssociationMapping * )))) * * @template A of AssociationMapping From 1f9d1bf4cb63754ded2c74058995f7a1936ab223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 13 May 2023 10:48:05 +0200 Subject: [PATCH 269/475] Narrow down parameter type declarations for quote strategies --- lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php | 2 +- lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php | 2 +- lib/Doctrine/ORM/Mapping/QuoteStrategy.php | 6 +++++- lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php | 1 + phpstan.neon | 6 ++++++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php index 3565a7beaef..98d784e6bac 100644 --- a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php @@ -50,7 +50,7 @@ public function getReferencedJoinColumnName( } public function getJoinTableName( - AssociationMapping $association, + ManyToManyOwningSideMapping $association, ClassMetadata $class, AbstractPlatform $platform, ): string { diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index 7c3de837eba..940422f3fbb 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -73,7 +73,7 @@ public function getReferencedJoinColumnName( } public function getJoinTableName( - AssociationMapping $association, + ManyToManyOwningSideMapping $association, ClassMetadata $class, AbstractPlatform $platform, ): string { diff --git a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php index 7b553222c85..9eb3e536355 100644 --- a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/QuoteStrategy.php @@ -29,7 +29,11 @@ public function getTableName(ClassMetadata $class, AbstractPlatform $platform): public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform): string; /** Gets the (possibly quoted) name of the join table. */ - public function getJoinTableName(AssociationMapping $association, ClassMetadata $class, AbstractPlatform $platform): string; + public function getJoinTableName( + ManyToManyOwningSideMapping $association, + ClassMetadata $class, + AbstractPlatform $platform, + ): string; /** * Gets the (possibly quoted) join column name. diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index fa1be985242..fe21d1a1993 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -61,6 +61,7 @@ public function getSql(SqlWalker $sqlWalker): string . $sourceTableAlias . '.' . $quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $platform); } } else { // many-to-many + assert($assoc->isManyToMany()); $owningAssoc = $entityManager->getMetadataFactory()->getOwningSide($assoc); $joinTable = $owningAssoc['joinTable']; diff --git a/phpstan.neon b/phpstan.neon index 3e5c2c05424..14912473afe 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -48,3 +48,9 @@ parameters: - message: '#^.*OneToManyPersister::getMapping\(\) should return.*#' path: lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php + + - + message: '#^.*QuoteStrategy::getJoinTableName\(\) expects.*$#' + paths: + - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php From 6032a2ccf7f7919c1c7831ce75ab3f4d644daf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 15 May 2023 09:27:07 +0200 Subject: [PATCH 270/475] Use OneToManyPersister::getMapping() more Not sure how I forgot these. --- .../ORM/Persisters/Collection/OneToManyPersister.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 8f24bafa959..b2a77cc0d86 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -77,7 +77,7 @@ public function get(PersistentCollection $collection, mixed $index): object|null public function count(PersistentCollection $collection): int { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); // only works with single id identifier entities. Will throw an @@ -93,7 +93,7 @@ public function count(PersistentCollection $collection): int */ public function slice(PersistentCollection $collection, int $offset, int|null $length = null): array { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); return $persister->getOneToManyCollection($mapping, $collection->getOwner(), $offset, $length); @@ -126,7 +126,7 @@ public function contains(PersistentCollection $collection, object $element): boo return false; } - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); // only works with single id identifier entities. Will throw an @@ -176,7 +176,7 @@ private function deleteEntityCollection(PersistentCollection $collection): int */ private function deleteJoinedEntityCollection(PersistentCollection $collection): int { - $mapping = $collection->getMapping(); + $mapping = $this->getMapping($collection); $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); $rootClass = $this->em->getClassMetadata($targetClass->rootEntityName); From ea2362801018c6dbb9bca15931969df9cacc965a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 8 May 2023 11:44:48 +0200 Subject: [PATCH 271/475] Rectorify --- .../ORM/Cache/DefaultCacheFactory.php | 4 +- .../ORM/Cache/DefaultCollectionHydrator.php | 2 +- .../ORM/Cache/DefaultEntityHydrator.php | 26 +-- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 6 +- .../AbstractCollectionPersister.php | 6 +- ...rictReadWriteCachedCollectionPersister.php | 4 +- .../ReadOnlyCachedCollectionPersister.php | 2 +- .../ReadWriteCachedCollectionPersister.php | 4 +- .../Entity/AbstractEntityPersister.php | 12 +- .../Internal/Hydration/AbstractHydrator.php | 4 +- .../ORM/Internal/Hydration/ObjectHydrator.php | 32 ++-- .../ORM/Mapping/AnsiQuoteStrategy.php | 2 +- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 38 ++--- .../ORM/Mapping/ClassMetadataFactory.php | 4 +- .../ORM/Mapping/DefaultQuoteStrategy.php | 10 +- .../ORM/ORMInvalidArgumentException.php | 12 +- lib/Doctrine/ORM/PersistentCollection.php | 26 +-- .../Collection/ManyToManyPersister.php | 2 +- .../Collection/OneToManyPersister.php | 30 ++-- .../Entity/JoinedSubclassPersister.php | 18 +- .../Entity/SingleTablePersister.php | 6 +- .../Query/AST/Functions/IdentityFunction.php | 6 +- .../ORM/Query/AST/Functions/SizeFunction.php | 6 +- .../Query/Exec/MultiTableUpdateExecutor.php | 2 +- lib/Doctrine/ORM/Query/Parser.php | 2 +- lib/Doctrine/ORM/Query/QueryException.php | 6 +- .../ORM/Query/ResultSetMappingBuilder.php | 8 +- lib/Doctrine/ORM/Query/SqlWalker.php | 60 +++---- .../Tools/Pagination/CountOutputWalker.php | 2 +- .../Pagination/LimitSubqueryOutputWalker.php | 2 +- .../ORM/Tools/ResolveTargetEntityListener.php | 10 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 24 +-- lib/Doctrine/ORM/Tools/SchemaValidator.php | 68 ++++---- lib/Doctrine/ORM/UnitOfWork.php | 84 +++++----- .../ORM/Utility/IdentifierFlattener.php | 6 +- lib/Doctrine/ORM/Utility/PersisterHelper.php | 14 +- psalm-baseline.xml | 6 +- .../EventListener/CacheMetadataListener.php | 4 +- .../ORM/Cache/DefaultCacheFactoryTest.php | 6 +- .../Functional/ExtraLazyCollectionTest.php | 12 +- .../ORM/Functional/Ticket/DDC599Test.php | 2 +- .../ORM/Mapping/AnsiQuoteStrategyTest.php | 4 +- .../Tests/ORM/Mapping/AttributeDriverTest.php | 6 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 36 ++-- .../Tests/ORM/Mapping/ClassMetadataTest.php | 60 +++---- .../ORM/Mapping/MappingDriverTestCase.php | 154 +++++++++--------- .../Tests/ORM/Mapping/QuoteStrategyTest.php | 4 +- .../ORM/Mapping/XmlMappingDriverTest.php | 2 +- .../Tools/ResolveTargetEntityListenerTest.php | 12 +- 49 files changed, 427 insertions(+), 431 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 1fbff198b21..b330a3ab27d 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -93,8 +93,8 @@ public function buildCachedCollectionPersister( CollectionPersister $persister, AssociationMapping $mapping, ): CachedCollectionPersister { - $usage = $mapping['cache']['usage']; - $region = $this->getRegion($mapping['cache']); + $usage = $mapping->cache['usage']; + $region = $this->getRegion($mapping->cache); if ($usage === ClassMetadata::CACHE_USAGE_READ_ONLY) { return new ReadOnlyCachedCollectionPersister($persister, $region, $em, $mapping); diff --git a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php index 6f8b99c0c5c..249d48f7d4f 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php @@ -44,7 +44,7 @@ public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection): array|null { $assoc = $metadata->associationMappings[$key->association]; - $targetPersister = $this->uow->getEntityPersister($assoc['targetEntity']); + $targetPersister = $this->uow->getEntityPersister($assoc->targetEntity); assert($targetPersister instanceof CachedPersister); $targetRegion = $targetPersister->getCacheRegion(); $list = []; diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 57b345b9455..610fb70ef89 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -63,8 +63,8 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob continue; } - if (! isset($assoc['cache'])) { - $targetClassMetadata = $this->em->getClassMetadata($assoc['targetEntity']); + if (! isset($assoc->cache)) { + $targetClassMetadata = $this->em->getClassMetadata($assoc->targetEntity); $owningAssociation = $this->em->getMetadataFactory()->getOwningSide($assoc); $associationIds = $this->identifierFlattener->flattenIdentifier( $targetClassMetadata, @@ -77,15 +77,15 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob if (isset($targetClassMetadata->fieldMappings[$fieldName])) { $fieldMapping = $targetClassMetadata->fieldMappings[$fieldName]; - $data[$owningAssociation['targetToSourceKeyColumns'][$fieldMapping->columnName]] = $fieldValue; + $data[$owningAssociation->targetToSourceKeyColumns[$fieldMapping->columnName]] = $fieldValue; continue; } $targetAssoc = $targetClassMetadata->associationMappings[$fieldName]; - foreach ($assoc['targetToSourceKeyColumns'] as $referencedColumn => $localColumn) { - if (isset($targetAssoc['sourceToTargetKeyColumns'][$referencedColumn])) { + foreach ($assoc->targetToSourceKeyColumns as $referencedColumn => $localColumn) { + if (isset($targetAssoc->sourceToTargetKeyColumns[$referencedColumn])) { $data[$localColumn] = $fieldValue; } } @@ -94,7 +94,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob continue; } - if (! isset($assoc['id'])) { + if (! isset($assoc->id)) { $targetClass = ClassUtils::getClass($data[$name]); $targetId = $this->uow->getEntityIdentifier($data[$name]); $data[$name] = new AssociationCacheEntry($targetClass, $targetId); @@ -110,13 +110,13 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob // @TODO - fix it ! // handle UnitOfWork#createEntity hash generation if (! is_array($targetId)) { - $data[reset($assoc['joinColumnFieldNames'])] = $targetId; + $data[reset($assoc->joinColumnFieldNames)] = $targetId; - $targetEntity = $this->em->getClassMetadata($assoc['targetEntity']); + $targetEntity = $this->em->getClassMetadata($assoc->targetEntity); $targetId = [$targetEntity->identifier[0] => $targetId]; } - $data[$name] = new AssociationCacheEntry($assoc['targetEntity'], $targetId); + $data[$name] = new AssociationCacheEntry($assoc->targetEntity, $targetId); } return new EntityCacheEntry($metadata->name, $data); @@ -133,13 +133,13 @@ public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, Ent } foreach ($metadata->associationMappings as $name => $assoc) { - if (! isset($assoc['cache']) || ! isset($data[$name])) { + if (! isset($assoc->cache) || ! isset($data[$name])) { continue; } $assocClass = $data[$name]->class; $assocId = $data[$name]->identifier; - $isEagerLoad = ($assoc['fetch'] === ClassMetadata::FETCH_EAGER || ($assoc->isOneToOne() && ! $assoc->isOwningSide())); + $isEagerLoad = ($assoc->fetch === ClassMetadata::FETCH_EAGER || ($assoc->isOneToOne() && ! $assoc->isOwningSide())); if (! $isEagerLoad) { $data[$name] = $this->em->getReference($assocClass, $assocId); @@ -147,9 +147,9 @@ public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, Ent continue; } - $assocMetadata = $this->em->getClassMetadata($assoc['targetEntity']); + $assocMetadata = $this->em->getClassMetadata($assoc->targetEntity); $assocKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocId); - $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); + $assocPersister = $this->uow->getEntityPersister($assoc->targetEntity); $assocRegion = $assocPersister->getCacheRegion(); $assocEntry = $assocRegion->get($assocKey); diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index e9b590a88f5..d1d351e1e77 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -302,7 +302,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, ar */ private function storeAssociationCache(QueryCacheKey $key, AssociationMapping $assoc, mixed $assocValue): array|null { - $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); + $assocPersister = $this->uow->getEntityPersister($assoc->targetEntity); $assocMetadata = $assocPersister->getClassMetadata(); $assocRegion = $assocPersister->getCacheRegion(); @@ -321,7 +321,7 @@ private function storeAssociationCache(QueryCacheKey $key, AssociationMapping $a return [ 'targetEntity' => $assocMetadata->rootEntityName, 'identifier' => $assocIdentifier, - 'type' => $assoc['type'], + 'type' => $assoc->type(), ]; } @@ -344,7 +344,7 @@ private function storeAssociationCache(QueryCacheKey $key, AssociationMapping $a return [ 'targetEntity' => $assocMetadata->rootEntityName, - 'type' => $assoc['type'], + 'type' => $assoc->type(), 'list' => $list, ]; } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php index 84936d83535..19ac2039258 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php @@ -53,8 +53,8 @@ public function __construct( $this->metadataFactory = $em->getMetadataFactory(); $this->cacheLogger = $cacheConfig->getCacheLogger(); $this->hydrator = $cacheFactory->buildCollectionHydrator($em, $association); - $this->sourceEntity = $em->getClassMetadata($association['sourceEntity']); - $this->targetEntity = $em->getClassMetadata($association['targetEntity']); + $this->sourceEntity = $em->getClassMetadata($association->sourceEntity); + $this->targetEntity = $em->getClassMetadata($association->targetEntity); } public function getCacheRegion(): Region @@ -135,7 +135,7 @@ public function containsKey(PersistentCollection $collection, mixed $key): bool public function count(PersistentCollection $collection): int { $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); - $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); + $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association->fieldName, $ownerId); $entry = $this->region->get($key); if ($entry !== null) { diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php index 67e5cffbb7f..ac861f44031 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php @@ -36,7 +36,7 @@ public function afterTransactionRolledBack(): void public function delete(PersistentCollection $collection): void { $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); - $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); + $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association->fieldName, $ownerId); $this->persister->delete($collection); @@ -53,7 +53,7 @@ public function update(PersistentCollection $collection): void } $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); - $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); + $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association->fieldName, $ownerId); // Invalidate non initialized collections OR ordered collection if ($isDirty && ! $isInitialized || $this->association->isOrdered()) { diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php index f4ef8a73d56..d63348a6823 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php @@ -15,7 +15,7 @@ public function update(PersistentCollection $collection): void if ($collection->isDirty() && $collection->getSnapshot()) { throw CannotUpdateReadOnlyCollection::fromEntityAndField( ClassUtils::getClass($collection->getOwner()), - $this->association['fieldName'], + $this->association->fieldName, ); } diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php index e28b919d82d..347a065f2ce 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php @@ -61,7 +61,7 @@ public function afterTransactionRolledBack(): void public function delete(PersistentCollection $collection): void { $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); - $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); + $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association->fieldName, $ownerId); $lock = $this->region->lock($key); $this->persister->delete($collection); @@ -88,7 +88,7 @@ public function update(PersistentCollection $collection): void $this->persister->update($collection); $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); - $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); + $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association->fieldName, $ownerId); $lock = $this->region->lock($key); if ($lock === null) { diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 31f49c2e66e..1bb38268901 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -169,9 +169,9 @@ private function storeJoinedAssociations(object $entity): void foreach ($this->class->associationMappings as $name => $assoc) { if ( - isset($assoc['cache']) && + isset($assoc->cache) && ($assoc->isToOne()) && - ($assoc['fetch'] === ClassMetadata::FETCH_EAGER || ! $assoc->isOwningSide()) + ($assoc->fetch === ClassMetadata::FETCH_EAGER || ! $assoc->isOwningSide()) ) { $associations[] = $name; } @@ -189,9 +189,9 @@ private function storeJoinedAssociations(object $entity): void } $assocId = $this->uow->getEntityIdentifier($assocEntity); - $assocMetadata = $this->metadataFactory->getMetadataFor($assoc['targetEntity']); + $assocMetadata = $this->metadataFactory->getMetadataFor($assoc->targetEntity); $assocKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocId); - $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); + $assocPersister = $this->uow->getEntityPersister($assoc->targetEntity); $assocPersister->storeEntityCache($assocEntity, $assocKey); } @@ -544,9 +544,9 @@ public function refresh(array $id, object $entity, LockMode|int|null $lockMode = /** @param array $ownerId */ protected function buildCollectionCacheKey(AssociationMapping $association, array $ownerId): CollectionCacheKey { - $metadata = $this->metadataFactory->getMetadataFor($association['sourceEntity']); + $metadata = $this->metadataFactory->getMetadataFor($association->sourceEntity); assert($metadata instanceof ClassMetadata); - return new CollectionCacheKey($metadata->rootEntityName, $association['fieldName'], $ownerId); + return new CollectionCacheKey($metadata->rootEntityName, $association->fieldName, $ownerId); } } diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index b39b6234cd1..e167e7bc3f9 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -520,14 +520,14 @@ protected function registerManaged(ClassMetadata $class, object $entity, array $ foreach ($class->identifier as $fieldName) { $id[$fieldName] = isset($class->associationMappings[$fieldName]) - ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] + ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] : $data[$fieldName]; } } else { $fieldName = $class->identifier[0]; $id = [ $fieldName => isset($class->associationMappings[$fieldName]) - ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] + ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] : $data[$fieldName], ]; } diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 55245b7e190..231a83b8b83 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -78,7 +78,7 @@ protected function prepare(): void $sourceClass = $this->getClassMetadata($sourceClassName); $assoc = $sourceClass->associationMappings[$this->resultSetMapping()->relationMap[$dqlAlias]]; - $this->hints['fetched'][$parent][$assoc['fieldName']] = true; + $this->hints['fetched'][$parent][$assoc->fieldName] = true; if ($assoc->isManyToMany()) { continue; @@ -86,21 +86,21 @@ protected function prepare(): void // Mark any non-collection opposite sides as fetched, too. if (! $assoc->isOwningSide()) { - $this->hints['fetched'][$dqlAlias][$assoc['mappedBy']] = true; + $this->hints['fetched'][$dqlAlias][$assoc->mappedBy] = true; continue; } // handle fetch-joined owning side bi-directional one-to-one associations - if ($assoc['inversedBy']) { + if ($assoc->inversedBy) { $class = $this->getClassMetadata($className); - $inverseAssoc = $class->associationMappings[$assoc['inversedBy']]; + $inverseAssoc = $class->associationMappings[$assoc->inversedBy]; if (! $inverseAssoc->isToOne()) { continue; } - $this->hints['fetched'][$dqlAlias][$inverseAssoc['fieldName']] = true; + $this->hints['fetched'][$dqlAlias][$inverseAssoc->fieldName] = true; } } } @@ -182,7 +182,7 @@ private function initRelatedCollection( assert($relation->isToMany()); $value = new PersistentCollection( $this->em, - $this->metadataCache[$relation['targetEntity']], + $this->metadataCache[$relation->targetEntity], $value, ); $value->setOwner($entity, $relation); @@ -280,7 +280,7 @@ private function getEntityFromIdentityMap(string $className, array $data): objec /** @return mixed */ static function (string $fieldName) use ($data, $class) { return isset($class->associationMappings[$fieldName]) - ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] + ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] : $data[$fieldName]; }, $class->identifier, @@ -289,7 +289,7 @@ static function (string $fieldName) use ($data, $class) { return $this->uow->tryGetByIdHash(ltrim($idHash), $class->rootEntityName); } elseif (isset($class->associationMappings[$class->identifier[0]])) { - return $this->uow->tryGetByIdHash($data[$class->associationMappings[$class->identifier[0]]['joinColumns'][0]['name']], $class->rootEntityName); + return $this->uow->tryGetByIdHash($data[$class->associationMappings[$class->identifier[0]]->joinColumns[0]['name']], $class->rootEntityName); } return $this->uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName); @@ -435,22 +435,22 @@ protected function hydrateRowData(array $row, array &$result): void $element = $this->getEntity($data, $dqlAlias); $reflField->setValue($parentObject, $element); $this->uow->setOriginalEntityProperty($oid, $relationField, $element); - $targetClass = $this->metadataCache[$relation['targetEntity']]; + $targetClass = $this->metadataCache[$relation->targetEntity]; - if ($relation['isOwningSide']) { + if ($relation->isOwningSide()) { // TODO: Just check hints['fetched'] here? // If there is an inverse mapping on the target class its bidirectional - if ($relation['inversedBy']) { - $inverseAssoc = $targetClass->associationMappings[$relation['inversedBy']]; + if ($relation->inversedBy) { + $inverseAssoc = $targetClass->associationMappings[$relation->inversedBy]; if ($inverseAssoc->isToOne()) { - $targetClass->reflFields[$inverseAssoc['fieldName']]->setValue($element, $parentObject); - $this->uow->setOriginalEntityProperty(spl_object_id($element), $inverseAssoc['fieldName'], $parentObject); + $targetClass->reflFields[$inverseAssoc->fieldName]->setValue($element, $parentObject); + $this->uow->setOriginalEntityProperty(spl_object_id($element), $inverseAssoc->fieldName, $parentObject); } } } else { // For sure bidirectional, as there is no inverse side in unidirectional mappings - $targetClass->reflFields[$relation['mappedBy']]->setValue($element, $parentObject); - $this->uow->setOriginalEntityProperty(spl_object_id($element), $relation['mappedBy'], $parentObject); + $targetClass->reflFields[$relation->mappedBy]->setValue($element, $parentObject); + $this->uow->setOriginalEntityProperty(spl_object_id($element), $relation->mappedBy, $parentObject); } // Update result pointer diff --git a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php index 98d784e6bac..ef94c7e562e 100644 --- a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php @@ -54,7 +54,7 @@ public function getJoinTableName( ClassMetadata $class, AbstractPlatform $platform, ): string { - return $association['joinTable']['name']; + return $association->joinTable['name']; } /** diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 48f4f784b74..fbcfbdd0a11 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -857,8 +857,8 @@ public function wakeupReflection(ReflectionService $reflService): void } foreach ($this->associationMappings as $field => $mapping) { - $this->reflFields[$field] = isset($mapping['declared']) - ? $this->getAccessibleProperty($reflService, $mapping['declared'], $field) + $this->reflFields[$field] = isset($mapping->declared) + ? $this->getAccessibleProperty($reflService, $mapping->declared, $field) : $this->getAccessibleProperty($reflService, $this->name, $field); } } @@ -911,11 +911,11 @@ public function validateAssociations(): void { foreach ($this->associationMappings as $mapping) { if ( - ! class_exists($mapping['targetEntity']) - && ! interface_exists($mapping['targetEntity']) - && ! trait_exists($mapping['targetEntity']) + ! class_exists($mapping->targetEntity) + && ! interface_exists($mapping->targetEntity) + && ! trait_exists($mapping->targetEntity) ) { - throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']); + throw MappingException::invalidTargetEntityClass($mapping->targetEntity, $this->name, $mapping->fieldName); } } } @@ -1524,7 +1524,7 @@ public function getIdentifierColumnNames(): array } // Association defined as Id field - $joinColumns = $this->associationMappings[$idProperty]['joinColumns']; + $joinColumns = $this->associationMappings[$idProperty]->joinColumns; $assocColumnNames = array_map(static fn (JoinColumnMapping $joinColumn): string => $joinColumn['name'], $joinColumns); $columnNames = array_merge($columnNames, $assocColumnNames); @@ -1809,7 +1809,7 @@ public function isRootEntity(): bool */ public function isInheritedAssociation(string $fieldName): bool { - return isset($this->associationMappings[$fieldName]['inherited']); + return isset($this->associationMappings[$fieldName]->inherited); } public function isInheritedEmbeddedClass(string $fieldName): bool @@ -1916,11 +1916,11 @@ public function mapField(array $mapping): void */ public function addInheritedAssociationMapping(AssociationMapping $mapping/*, $owningClassName = null*/): void { - if (isset($this->associationMappings[$mapping['fieldName']])) { - throw MappingException::duplicateAssociationMapping($this->name, $mapping['fieldName']); + if (isset($this->associationMappings[$mapping->fieldName])) { + throw MappingException::duplicateAssociationMapping($this->name, $mapping->fieldName); } - $this->associationMappings[$mapping['fieldName']] = $mapping; + $this->associationMappings[$mapping->fieldName] = $mapping; } /** @@ -2000,7 +2000,7 @@ public function mapManyToMany(array $mapping): void */ protected function _storeAssociationMapping(AssociationMapping $assocMapping): void { - $sourceFieldName = $assocMapping['fieldName']; + $sourceFieldName = $assocMapping->fieldName; $this->assertFieldNotMapped($sourceFieldName); @@ -2258,7 +2258,7 @@ public function isCollectionValuedAssociation(string $fieldName): bool public function isAssociationWithSingleJoinColumn(string $fieldName): bool { return isset($this->associationMappings[$fieldName]) - && isset($this->associationMappings[$fieldName]['joinColumns'][0]) + && isset($this->associationMappings[$fieldName]->joinColumns[0]) && ! isset($this->associationMappings[$fieldName]['joinColumns'][1]); } @@ -2273,7 +2273,7 @@ public function getSingleAssociationJoinColumnName(string $fieldName): string throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); } - return $this->associationMappings[$fieldName]['joinColumns'][0]['name']; + return $this->associationMappings[$fieldName]->joinColumns[0]['name']; } /** @@ -2287,7 +2287,7 @@ public function getSingleAssociationReferencedJoinColumnName(string $fieldName): throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); } - return $this->associationMappings[$fieldName]['joinColumns'][0]['referencedColumnName']; + return $this->associationMappings[$fieldName]->joinColumns[0]['referencedColumnName']; } /** @@ -2306,7 +2306,7 @@ public function getFieldForColumn(string $columnName): string foreach ($this->associationMappings as $assocName => $mapping) { if ( $this->isAssociationWithSingleJoinColumn($assocName) && - $this->associationMappings[$assocName]['joinColumns'][0]['name'] === $columnName + $this->associationMappings[$assocName]->joinColumns[0]['name'] === $columnName ) { return $assocName; } @@ -2454,7 +2454,7 @@ public function getAssociationNames(): array */ public function getAssociationTargetClass(string $assocName): string { - return $this->associationMappings[$assocName]['targetEntity'] + return $this->associationMappings[$assocName]->targetEntity ?? throw new InvalidArgumentException("Association name expected, '" . $assocName . "' is not an association."); } @@ -2466,12 +2466,12 @@ public function getName(): string public function isAssociationInverseSide(string $assocName): bool { return isset($this->associationMappings[$assocName]) - && ! $this->associationMappings[$assocName]['isOwningSide']; + && ! $this->associationMappings[$assocName]->isOwningSide(); } public function getAssociationMappedByTargetField(string $assocName): string { - return $this->associationMappings[$assocName]['mappedBy']; + return $this->associationMappings[$assocName]->mappedBy; } /** diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 1c6e6fa76ab..e4a7ef419c2 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -458,8 +458,8 @@ private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $p // the relationship. // According to the definitions given in https://github.com/doctrine/orm/pull/10396/, // this is the case <=> ! isset($mapping['inherited']). - if (! isset($subClassMapping['inherited'])) { - $subClassMapping['sourceEntity'] = $subClass->name; + if (! isset($subClassMapping->inherited)) { + $subClassMapping->sourceEntity = $subClass->name; } $subClass->addInheritedAssociationMapping($subClassMapping); diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index 940422f3fbb..7865dbbcd3a 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -79,13 +79,13 @@ public function getJoinTableName( ): string { $schema = ''; - if (isset($association['joinTable']['schema'])) { - $schema = $association['joinTable']['schema'] . '.'; + if (isset($association->joinTable['schema'])) { + $schema = $association->joinTable['schema'] . '.'; } - $tableName = $association['joinTable']['name']; + $tableName = $association->joinTable['name']; - if (isset($association['joinTable']['quoted'])) { + if (isset($association->joinTable['quoted'])) { $tableName = $platform->quoteIdentifier($tableName); } @@ -107,7 +107,7 @@ public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform } // Association defined as Id field - $joinColumns = $class->associationMappings[$fieldName]['joinColumns']; + $joinColumns = $class->associationMappings[$fieldName]->joinColumns; $assocQuotedColumnNames = array_map( static fn (JoinColumnMapping $joinColumn) => isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['name']) diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index 2b0b146f42a..ff5d8487fed 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -81,8 +81,8 @@ public static function newEntityFoundThroughRelationship(AssociationMapping $ass public static function detachedEntityFoundThroughRelationship(AssociationMapping $assoc, object $entry): self { - return new self('A detached entity of type ' . $assoc['targetEntity'] . ' (' . self::objToStr($entry) . ') ' - . " was found through the relationship '" . $assoc['sourceEntity'] . '#' . $assoc['fieldName'] . "' " + return new self('A detached entity of type ' . $assoc->targetEntity . ' (' . self::objToStr($entry) . ') ' + . " was found through the relationship '" . $assoc->sourceEntity . '#' . $assoc->fieldName . "' " . 'during cascading a persist operation.'); } @@ -138,8 +138,8 @@ public static function invalidAssociation(ClassMetadata $targetClass, Associatio return new self(sprintf( 'Expected value of type "%s" for association field "%s#$%s", got "%s" instead.', $expectedType, - $assoc['sourceEntity'], - $assoc['fieldName'], + $assoc->sourceEntity, + $assoc->fieldName, get_debug_type($actualValue), )); } @@ -155,7 +155,7 @@ private static function objToStr(object $obj): string private static function newEntityFoundThroughRelationshipMessage(AssociationMapping $associationMapping, object $entity): string { return 'A new entity was found through the relationship \'' - . $associationMapping['sourceEntity'] . '#' . $associationMapping['fieldName'] . '\' that was not' + . $associationMapping->sourceEntity . '#' . $associationMapping->fieldName . '\' that was not' . ' configured to cascade persist operations for entity: ' . self::objToStr($entity) . '.' . ' To solve this issue: Either explicitly call EntityManager#persist()' . ' on this unknown entity or configure cascade persist' @@ -163,7 +163,7 @@ private static function newEntityFoundThroughRelationshipMessage(AssociationMapp . ($entity instanceof Stringable ? '' : ' If you cannot find out which entity causes the problem implement \'' - . $associationMapping['targetEntity'] . '#__toString()\' to get a clue.' + . $associationMapping->targetEntity . '#__toString()\' to get a clue.' ); } } diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index d9b73399236..4322ab768b8 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -322,7 +322,7 @@ public function remove(string|int $key): mixed $this->association !== null && $this->association->isToMany() && $this->owner && - $this->getMapping()['orphanRemoval'] + $this->getMapping()->orphanRemoval ) { $this->getUnitOfWork()->scheduleOrphanRemoval($removed); } @@ -344,7 +344,7 @@ public function removeElement(mixed $element): bool $this->association !== null && $this->association->isToMany() && $this->owner && - $this->getMapping()['orphanRemoval'] + $this->getMapping()->orphanRemoval ) { $this->getUnitOfWork()->scheduleOrphanRemoval($element); } @@ -355,8 +355,8 @@ public function removeElement(mixed $element): bool public function containsKey(mixed $key): bool { if ( - ! $this->initialized && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY - && isset($this->getMapping()['indexBy']) + ! $this->initialized && $this->getMapping()->fetch === ClassMetadata::FETCH_EXTRA_LAZY + && isset($this->getMapping()->indexBy) ) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->getMapping()); @@ -373,7 +373,7 @@ public function containsKey(mixed $key): bool */ public function contains(mixed $element): bool { - if (! $this->initialized && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { + if (! $this->initialized && $this->getMapping()->fetch === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->getMapping()); return $this->unwrap()->contains($element) || $persister->contains($this, $element); @@ -386,12 +386,12 @@ public function get(string|int $key): mixed { if ( ! $this->initialized - && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY - && isset($this->getMapping()['indexBy']) + && $this->getMapping()->fetch === ClassMetadata::FETCH_EXTRA_LAZY + && isset($this->getMapping()->indexBy) ) { assert($this->em !== null); assert($this->typeClass !== null); - if (! $this->typeClass->isIdentifierComposite && $this->typeClass->isIdentifier($this->getMapping()['indexBy'])) { + if (! $this->typeClass->isIdentifierComposite && $this->typeClass->isIdentifier($this->getMapping()->indexBy)) { return $this->em->find($this->typeClass->name, $key); } @@ -403,7 +403,7 @@ public function get(string|int $key): mixed public function count(): int { - if (! $this->initialized && $this->association !== null && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { + if (! $this->initialized && $this->association !== null && $this->getMapping()->fetch === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->association); return $persister->count($this) + ($this->isDirty ? $this->unwrap()->count() : 0); @@ -480,7 +480,7 @@ public function clear(): void if ( $association->isToMany() && - $association['orphanRemoval'] && + $association->orphanRemoval && $this->owner ) { // we need to initialize here, as orphan removal acts like implicit cascadeRemove, @@ -537,7 +537,7 @@ public function __wakeup(): void */ public function slice(int $offset, int|null $length = null): array { - if (! $this->initialized && ! $this->isDirty && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { + if (! $this->initialized && ! $this->isDirty && $this->getMapping()->fetch === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->getMapping()); return $persister->slice($this, $offset, $length); @@ -605,9 +605,9 @@ public function matching(Criteria $criteria): Collection $criteria->where($expression); $criteria->orderBy($criteria->getOrderings() ?: $association->orderBy()); - $persister = $this->getUnitOfWork()->getEntityPersister($association['targetEntity']); + $persister = $this->getUnitOfWork()->getEntityPersister($association->targetEntity); - return $association['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY + return $association->fetch === ClassMetadata::FETCH_EXTRA_LAZY ? new LazyCriteriaCollection($persister, $criteria) : new ArrayCollection($persister->loadCriteria($criteria)); } diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 6934c2e215d..1b8b46a150d 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -164,7 +164,7 @@ public function count(PersistentCollection $collection): int public function slice(PersistentCollection $collection, int $offset, int|null $length = null): array { $mapping = $this->getMapping($collection); - $persister = $this->uow->getEntityPersister($mapping['targetEntity']); + $persister = $this->uow->getEntityPersister($mapping->targetEntity); return $persister->getManyToManyCollection($mapping, $collection->getOwner(), $offset, $length); } diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index b2a77cc0d86..4e26c8ae889 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -30,14 +30,14 @@ public function delete(PersistentCollection $collection): void // the entire collection with a new would trigger this operation. $mapping = $this->getMapping($collection); - if (! $mapping['orphanRemoval']) { + if (! $mapping->orphanRemoval) { // Handling non-orphan removal should never happen, as @OneToMany // can only be inverse side. For owning side one to many, it is // required to have a join table, which would classify as a ManyToManyPersister. return; } - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); $targetClass->isInheritanceTypeJoined() ? $this->deleteJoinedEntityCollection($collection) @@ -60,7 +60,7 @@ public function get(PersistentCollection $collection, mixed $index): object|null throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); } - $persister = $this->uow->getEntityPersister($mapping['targetEntity']); + $persister = $this->uow->getEntityPersister($mapping->targetEntity); return $persister->load( [ @@ -78,12 +78,12 @@ public function get(PersistentCollection $collection, mixed $index): object|null public function count(PersistentCollection $collection): int { $mapping = $this->getMapping($collection); - $persister = $this->uow->getEntityPersister($mapping['targetEntity']); + $persister = $this->uow->getEntityPersister($mapping->targetEntity); // only works with single id identifier entities. Will throw an // exception in Entity Persisters if that is not the case for the // 'mappedBy' field. - $criteria = new Criteria(Criteria::expr()->eq($mapping['mappedBy'], $collection->getOwner())); + $criteria = new Criteria(Criteria::expr()->eq($mapping->mappedBy, $collection->getOwner())); return $persister->count($criteria); } @@ -94,7 +94,7 @@ public function count(PersistentCollection $collection): int public function slice(PersistentCollection $collection, int $offset, int|null $length = null): array { $mapping = $this->getMapping($collection); - $persister = $this->uow->getEntityPersister($mapping['targetEntity']); + $persister = $this->uow->getEntityPersister($mapping->targetEntity); return $persister->getOneToManyCollection($mapping, $collection->getOwner(), $offset, $length); } @@ -107,7 +107,7 @@ public function containsKey(PersistentCollection $collection, mixed $key): bool throw new BadMethodCallException('Selecting a collection by index is only supported on indexed collections.'); } - $persister = $this->uow->getEntityPersister($mapping['targetEntity']); + $persister = $this->uow->getEntityPersister($mapping->targetEntity); // only works with single id identifier entities. Will throw an // exception in Entity Persisters if that is not the case for the @@ -127,12 +127,12 @@ public function contains(PersistentCollection $collection, object $element): boo } $mapping = $this->getMapping($collection); - $persister = $this->uow->getEntityPersister($mapping['targetEntity']); + $persister = $this->uow->getEntityPersister($mapping->targetEntity); // only works with single id identifier entities. Will throw an // exception in Entity Persisters if that is not the case for the // 'mappedBy' field. - $criteria = new Criteria(Criteria::expr()->eq($mapping['mappedBy'], $collection->getOwner())); + $criteria = new Criteria(Criteria::expr()->eq($mapping->mappedBy, $collection->getOwner())); return $persister->exists($element, $criteria); } @@ -150,12 +150,12 @@ private function deleteEntityCollection(PersistentCollection $collection): int { $mapping = $this->getMapping($collection); $identifier = $this->uow->getEntityIdentifier($collection->getOwner()); - $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); $columns = []; $parameters = []; - foreach ($targetClass->associationMappings[$mapping['mappedBy']]['joinColumns'] as $joinColumn) { + foreach ($targetClass->associationMappings[$mapping->mappedBy]->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $parameters[] = $identifier[$sourceClass->getFieldForColumn($joinColumn['referencedColumnName'])]; } @@ -177,8 +177,8 @@ private function deleteEntityCollection(PersistentCollection $collection): int private function deleteJoinedEntityCollection(PersistentCollection $collection): int { $mapping = $this->getMapping($collection); - $sourceClass = $this->em->getClassMetadata($mapping['sourceEntity']); - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $sourceClass = $this->em->getClassMetadata($mapping->sourceEntity); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); $rootClass = $this->em->getClassMetadata($targetClass->rootEntityName); // 1) Build temporary table DDL @@ -203,7 +203,7 @@ private function deleteJoinedEntityCollection(PersistentCollection $collection): // 2) Build insert table records into temporary table $query = $this->em->createQuery( ' SELECT t0.' . implode(', t0.', $rootClass->getIdentifierFieldNames()) - . ' FROM ' . $targetClass->name . ' t0 WHERE t0.' . $mapping['mappedBy'] . ' = :owner', + . ' FROM ' . $targetClass->name . ' t0 WHERE t0.' . $mapping->mappedBy . ' = :owner', )->setParameter('owner', $collection->getOwner()); $sql = $query->getSQL(); diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index bd2c07bd534..cb7bf530160 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -75,7 +75,7 @@ public function getOwningTable(string $fieldName): string } $cm = match (true) { - isset($this->class->associationMappings[$fieldName]['inherited']) + isset($this->class->associationMappings[$fieldName]->inherited) => $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']), isset($this->class->fieldMappings[$fieldName]->inherited) => $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]->inherited), @@ -390,13 +390,13 @@ protected function getSelectColumnsSQL(): string continue; } - $tableAlias = isset($mapping['inherited']) - ? $this->getSQLTableAlias($mapping['inherited']) + $tableAlias = isset($mapping->inherited) + ? $this->getSQLTableAlias($mapping->inherited) : $baseTableAlias; - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); - foreach ($mapping['joinColumns'] as $joinColumn) { + foreach ($mapping->joinColumns as $joinColumn) { $columnList[] = $this->getSelectJoinColumnSQL( $tableAlias, $joinColumn['name'], @@ -429,13 +429,13 @@ protected function getSelectColumnsSQL(): string // Add join columns (foreign keys) foreach ($subClass->associationMappings as $mapping) { - if (! $mapping->isToOneOwningSide() || isset($mapping['inherited'])) { + if (! $mapping->isToOneOwningSide() || isset($mapping->inherited)) { continue; } - $targetClass = $this->em->getClassMetadata($mapping['targetEntity']); + $targetClass = $this->em->getClassMetadata($mapping->targetEntity); - foreach ($mapping['joinColumns'] as $joinColumn) { + foreach ($mapping->joinColumns as $joinColumn) { $columnList[] = $this->getSelectJoinColumnSQL( $tableAlias, $joinColumn['name'], @@ -465,7 +465,7 @@ protected function getInsertColumnList(): array if ( isset($this->class->fieldMappings[$name]->inherited) && ! isset($this->class->fieldMappings[$name]->id) - || isset($this->class->associationMappings[$name]['inherited']) + || isset($this->class->associationMappings[$name]->inherited) || ($this->class->isVersioned && $this->class->versionField === $name) || isset($this->class->embeddedClasses[$name]) ) { diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index 8cf36b8d3c0..3a5ddb646c9 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -67,13 +67,13 @@ protected function getSelectColumnsSQL(): string // Foreign key columns foreach ($subClass->associationMappings as $assoc) { - if (! $assoc->isToOneOwningSide() || isset($assoc['inherited'])) { + if (! $assoc->isToOneOwningSide() || isset($assoc->inherited)) { continue; } - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $columnList[] = $this->getSelectJoinColumnSQL( $tableAlias, $joinColumn['name'], diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 449a0ff65d0..34ee70284ae 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -35,7 +35,7 @@ public function getSql(SqlWalker $sqlWalker): string $dqlAlias = $this->pathExpression->identificationVariable; $assocField = $this->pathExpression->field; $assoc = $sqlWalker->getMetadataForDqlAlias($dqlAlias)->associationMappings[$assocField]; - $targetEntity = $entityManager->getClassMetadata($assoc['targetEntity']); + $targetEntity = $entityManager->getClassMetadata($assoc->targetEntity); assert($assoc->isToOneOwningSide()); $joinColumn = reset($assoc->joinColumns); @@ -48,7 +48,7 @@ public function getSql(SqlWalker $sqlWalker): string $field = $targetEntity->fieldMappings[$this->fieldMapping]; $joinColumn = null; - foreach ($assoc['joinColumns'] as $mapping) { + foreach ($assoc->joinColumns as $mapping) { if ($mapping['referencedColumnName'] === $field->columnName) { $joinColumn = $mapping; @@ -62,7 +62,7 @@ public function getSql(SqlWalker $sqlWalker): string } // The table with the relation may be a subclass, so get the table name from the association definition - $tableName = $entityManager->getClassMetadata($assoc['sourceEntity'])->getTableName(); + $tableName = $entityManager->getClassMetadata($assoc->sourceEntity)->getTableName(); $tableAlias = $sqlWalker->getSQLTableAlias($tableName, $dqlAlias); $columnName = $quoteStrategy->getJoinColumnName($joinColumn, $targetEntity, $platform); diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index fe21d1a1993..0471428a108 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -45,11 +45,11 @@ public function getSql(SqlWalker $sqlWalker): string $sql .= $quoteStrategy->getTableName($targetClass, $platform) . ' ' . $targetTableAlias . ' WHERE '; - $owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']]; + $owningAssoc = $targetClass->associationMappings[$assoc->mappedBy]; $first = true; - foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) { + foreach ($owningAssoc->targetToSourceKeyColumns as $targetColumn => $sourceColumn) { if ($first) { $first = false; } else { @@ -63,7 +63,7 @@ public function getSql(SqlWalker $sqlWalker): string } else { // many-to-many assert($assoc->isManyToMany()); $owningAssoc = $entityManager->getMetadataFactory()->getOwningSide($assoc); - $joinTable = $owningAssoc['joinTable']; + $joinTable = $owningAssoc->joinTable; // SQL table aliases $joinTableAlias = $sqlWalker->getSQLTableAlias($joinTable['name']); diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php index 57d2aec49a7..557b4d2ccf5 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -89,7 +89,7 @@ public function __construct(AST\Node $AST, SqlWalker $sqlWalker) if ( (isset($class->fieldMappings[$field]) && ! isset($class->fieldMappings[$field]->inherited)) || - (isset($class->associationMappings[$field]) && ! isset($class->associationMappings[$field]['inherited'])) + (isset($class->associationMappings[$field]) && ! isset($class->associationMappings[$field]->inherited)) ) { $newValue = $updateItem->newValue; diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index dee03971a66..be310824e68 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -1653,7 +1653,7 @@ public function JoinAssociationDeclaration(): AST\JoinAssociationDeclaration $field = $joinAssociationPathExpression->associationField; $class = $this->getMetadataForDqlAlias($identificationVariable); - $targetClass = $this->em->getClassMetadata($class->associationMappings[$field]['targetEntity']); + $targetClass = $this->em->getClassMetadata($class->associationMappings[$field]->targetEntity); // Building queryComponent $joinQueryComponent = [ diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index 6a78783b906..658ecb7a964 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -84,7 +84,7 @@ public static function iterateWithFetchJoinCollectionNotAllowed(AssociationMappi { return new self( 'Invalid query operation: Not allowed to iterate over fetch join collections ' . - 'in class ' . $assoc['sourceEntity'] . ' association ' . $assoc['fieldName'], + 'in class ' . $assoc->sourceEntity . ' association ' . $assoc->fieldName, ); } @@ -121,8 +121,8 @@ public static function associationPathInverseSideNotSupported(PathExpression $pa public static function iterateWithFetchJoinNotAllowed(AssociationMapping $assoc): self { return new self( - 'Iterate with fetch join in class ' . $assoc['sourceEntity'] . - ' using association ' . $assoc['fieldName'] . ' not allowed.', + 'Iterate with fetch join in class ' . $assoc->sourceEntity . + ' using association ' . $assoc->fieldName . ' not allowed.', ); } diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 2f22d385ebe..4863af59b1b 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -137,10 +137,10 @@ protected function addAllClassFields(string $class, string $alias, array $column foreach ($classMetadata->associationMappings as $associationMapping) { if ($associationMapping->isToOneOwningSide()) { - $targetClass = $this->em->getClassMetadata($associationMapping['targetEntity']); - $isIdentifier = isset($associationMapping['id']) && $associationMapping['id'] === true; + $targetClass = $this->em->getClassMetadata($associationMapping->targetEntity); + $isIdentifier = isset($associationMapping->id) && $associationMapping->id === true; - foreach ($associationMapping['joinColumns'] as $joinColumn) { + foreach ($associationMapping->joinColumns as $joinColumn) { $columnName = $joinColumn['name']; $columnAlias = $this->getSQLResultCasing($platform, $columnAliasMap[$columnName]); $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); @@ -217,7 +217,7 @@ private function getColumnAliasMap( foreach ($class->associationMappings as $associationMapping) { if ($associationMapping->isToOneOwningSide()) { - foreach ($associationMapping['joinColumns'] as $joinColumn) { + foreach ($associationMapping->joinColumns as $joinColumn) { $columnName = $joinColumn['name']; $columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns); } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 4cde0dbc00c..0cc856afc23 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -340,7 +340,7 @@ private function generateOrderedCollectionOrderByItems(): string $dqlAlias = $selectedClass['dqlAlias']; $qComp = $this->queryComponents[$dqlAlias]; - if (! isset($qComp['relation']['orderBy'])) { + if (! isset($qComp['relation']->orderBy)) { continue; } @@ -592,7 +592,7 @@ public function walkPathExpression(AST\PathExpression $pathExpr): string $dqlAlias = $pathExpr->identificationVariable; $class = $this->getMetadataForDqlAlias($dqlAlias); - if (isset($class->associationMappings[$fieldName]['inherited'])) { + if (isset($class->associationMappings[$fieldName]->inherited)) { $class = $this->em->getClassMetadata($class->associationMappings[$fieldName]['inherited']); } @@ -605,7 +605,7 @@ public function walkPathExpression(AST\PathExpression $pathExpr): string assert($assoc->isToOneOwningSide()); // COMPOSITE KEYS NOT (YET?) SUPPORTED - if (count($assoc['sourceToTargetKeyColumns']) > 1) { + if (count($assoc->sourceToTargetKeyColumns) > 1) { throw QueryException::associationPathCompositeKeyNotSupported(); } @@ -654,7 +654,7 @@ public function walkSelectClause(AST\SelectClause $selectClause): string $class->name, $dqlAlias, $this->queryComponents[$dqlAlias]['parent'], - $this->queryComponents[$dqlAlias]['relation']['fieldName'], + $this->queryComponents[$dqlAlias]['relation']->fieldName, ); } @@ -683,17 +683,17 @@ public function walkSelectClause(AST\SelectClause $selectClause): string foreach ($class->associationMappings as $assoc) { if ( ! $assoc->isToOneOwningSide() - || ( ! $addMetaColumns && ! isset($assoc['id'])) + || ( ! $addMetaColumns && ! isset($assoc->id)) ) { continue; } - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); - $isIdentifier = (isset($assoc['id']) && $assoc['id'] === true); - $owningClass = isset($assoc['inherited']) ? $this->em->getClassMetadata($assoc['inherited']) : $class; + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); + $isIdentifier = (isset($assoc->id) && $assoc->id === true); + $owningClass = isset($assoc->inherited) ? $this->em->getClassMetadata($assoc->inherited) : $class; $sqlTableAlias = $this->getSQLTableAlias($owningClass->getTableName(), $dqlAlias); - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $columnName = $joinColumn['name']; $columnAlias = $this->getSQLColumnAlias($columnName); $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); @@ -717,14 +717,14 @@ public function walkSelectClause(AST\SelectClause $selectClause): string foreach ($subClass->associationMappings as $assoc) { // Skip if association is inherited - if (isset($assoc['inherited'])) { + if (isset($assoc->inherited)) { continue; } if ($assoc->isToOneOwningSide()) { - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $columnName = $joinColumn['name']; $columnAlias = $this->getSQLColumnAlias($columnName); $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); @@ -794,7 +794,7 @@ public function walkIndexBy(AST\IndexBy $indexBy): void $fieldName = $pathExpression->field; $class = $this->getMetadataForDqlAlias($alias); - if (isset($class->associationMappings[$fieldName]['inherited'])) { + if (isset($class->associationMappings[$fieldName]->inherited)) { $class = $this->em->getClassMetadata($class->associationMappings[$fieldName]['inherited']); } @@ -887,8 +887,8 @@ public function walkJoinAssociationDeclaration( $relation = $this->queryComponents[$joinedDqlAlias]['relation'] ?? null; assert($relation !== null); - $targetClass = $this->em->getClassMetadata($relation['targetEntity']); - $sourceClass = $this->em->getClassMetadata($relation['sourceEntity']); + $targetClass = $this->em->getClassMetadata($relation->targetEntity); + $sourceClass = $this->em->getClassMetadata($relation->sourceEntity); $targetTableName = $this->quoteStrategy->getTableName($targetClass, $this->platform); $targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName(), $joinedDqlAlias); @@ -912,11 +912,11 @@ public function walkJoinAssociationDeclaration( case $assoc->isToOne(): $conditions = []; - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $quotedTargetColumn = $this->quoteStrategy->getReferencedJoinColumnName($joinColumn, $targetClass, $this->platform); - if ($relation['isOwningSide']) { + if ($relation->isOwningSide()) { $conditions[] = $sourceTableAlias . '.' . $quotedSourceColumn . ' = ' . $targetTableAlias . '.' . $quotedTargetColumn; continue; @@ -947,14 +947,14 @@ public function walkJoinAssociationDeclaration( case $assoc->isManyToMany(): // Join relation table - $joinTable = $assoc['joinTable']; + $joinTable = $assoc->joinTable; $joinTableAlias = $this->getSQLTableAlias($joinTable['name'], $joinedDqlAlias); $joinTableName = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->platform); $conditions = []; - $relationColumns = $relation['isOwningSide'] - ? $assoc['joinTable']['joinColumns'] - : $assoc['joinTable']['inverseJoinColumns']; + $relationColumns = $relation->isOwningSide() + ? $assoc->joinTable['joinColumns'] + : $assoc->joinTable['inverseJoinColumns']; foreach ($relationColumns as $joinColumn) { $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); @@ -969,9 +969,9 @@ public function walkJoinAssociationDeclaration( $sql .= $joinType === AST\Join::JOIN_TYPE_LEFT || $joinType === AST\Join::JOIN_TYPE_LEFTOUTER ? ' LEFT JOIN ' : ' INNER JOIN '; $conditions = []; - $relationColumns = $relation['isOwningSide'] - ? $assoc['joinTable']['inverseJoinColumns'] - : $assoc['joinTable']['joinColumns']; + $relationColumns = $relation->isOwningSide() + ? $assoc->joinTable['inverseJoinColumns'] + : $assoc->joinTable['joinColumns']; foreach ($relationColumns as $joinColumn) { $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); @@ -1644,7 +1644,7 @@ public function walkGroupByItem(AST\PathExpression|string $groupByItem): string foreach ($this->getMetadataForDqlAlias($groupByItem)->associationMappings as $mapping) { if ($mapping->isToOneOwningSide()) { - $item = new AST\PathExpression(AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $groupByItem, $mapping['fieldName']); + $item = new AST\PathExpression(AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $groupByItem, $mapping->fieldName); $item->type = AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION; $sqlParts[] = $this->walkPathExpression($item); @@ -1863,10 +1863,10 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $sql .= $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' WHERE '; - $owningAssoc = $targetClass->associationMappings[$assoc['mappedBy']]; + $owningAssoc = $targetClass->associationMappings[$assoc->mappedBy]; $sqlParts = []; - foreach ($owningAssoc['targetToSourceKeyColumns'] as $targetColumn => $sourceColumn) { + foreach ($owningAssoc->targetToSourceKeyColumns as $targetColumn => $sourceColumn) { $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $this->platform); $sqlParts[] = $sourceTableAlias . '.' . $targetColumn . ' = ' . $targetTableAlias . '.' . $sourceColumn; @@ -1886,7 +1886,7 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $targetClass = $this->em->getClassMetadata($assoc->targetEntity); $owningAssoc = $this->em->getMetadataFactory()->getOwningSide($assoc); - $joinTable = $owningAssoc['joinTable']; + $joinTable = $owningAssoc->joinTable; // SQL table aliases $joinTableAlias = $this->getSQLTableAlias($joinTable['name']); @@ -1894,7 +1894,7 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $sql .= $this->quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $this->platform) . ' ' . $joinTableAlias . ' WHERE '; - $joinColumns = $assoc['isOwningSide'] ? $joinTable['joinColumns'] : $joinTable['inverseJoinColumns']; + $joinColumns = $assoc->isOwningSide() ? $joinTable['joinColumns'] : $joinTable['inverseJoinColumns']; $sqlParts = []; foreach ($joinColumns as $joinColumn) { @@ -1903,7 +1903,7 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $sqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' = ' . $sourceTableAlias . '.' . $targetColumn; } - $joinColumns = $assoc['isOwningSide'] ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns']; + $joinColumns = $assoc->isOwningSide() ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns']; foreach ($joinColumns as $joinColumn) { if (isset($dqlParamKey)) { diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index bb68904ac1d..35b125851d3 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -95,7 +95,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): string } if (isset($rootClass->associationMappings[$property])) { - $joinColumn = $rootClass->associationMappings[$property]['joinColumns'][0]['name']; + $joinColumn = $rootClass->associationMappings[$property]->joinColumns[0]['name']; foreach (array_keys($this->rsm->metaMappings, $joinColumn, true) as $alias) { if ($this->rsm->columnOwnerMap[$alias] === $rootAlias) { diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index e0b81af8d35..2ab51693fd1 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -498,7 +498,7 @@ private function getSQLIdentifier(SelectStatement $AST): array } if (isset($rootClass->associationMappings[$property])) { - $joinColumn = $rootClass->associationMappings[$property]['joinColumns'][0]['name']; + $joinColumn = $rootClass->associationMappings[$property]->joinColumns[0]['name']; foreach (array_keys($this->rsm->metaMappings, $joinColumn, true) as $alias) { if ($this->rsm->columnOwnerMap[$alias] === $rootAlias) { diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php index 0e4a44adc20..9e485214ea5 100644 --- a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -70,7 +70,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $args): void $cm = $args->getClassMetadata(); foreach ($cm->associationMappings as $mapping) { - if (isset($this->resolveTargetEntities[$mapping['targetEntity']])) { + if (isset($this->resolveTargetEntities[$mapping->targetEntity])) { $this->remapAssociation($cm, $mapping); } } @@ -90,16 +90,16 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $args): void private function remapAssociation(ClassMetadata $classMetadata, AssociationMapping $mapping): void { - $newMapping = $this->resolveTargetEntities[$mapping['targetEntity']]; + $newMapping = $this->resolveTargetEntities[$mapping->targetEntity]; $newMapping = array_replace_recursive( $mapping->toArray(), $newMapping, ); - $newMapping['fieldName'] = $mapping['fieldName']; + $newMapping['fieldName'] = $mapping->fieldName; - unset($classMetadata->associationMappings[$mapping['fieldName']]); + unset($classMetadata->associationMappings[$mapping->fieldName]); - switch ($mapping['type']) { + switch ($mapping->type()) { case ClassMetadata::MANY_TO_MANY: $classMetadata->mapManyToMany($newMapping); break; diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index fbc46e99970..69f34188018 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -154,7 +154,7 @@ private function getIndexColumns(ClassMetadata $class, array $indexData): array if ($class->hasField($fieldName)) { $columns[] = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); } elseif ($class->hasAssociation($fieldName)) { - foreach ($class->getAssociationMapping($fieldName)['joinColumns'] as $joinColumn) { + foreach ($class->getAssociationMapping($fieldName)->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } } @@ -245,17 +245,17 @@ public function getSchemaFromMetadata(array $classes): Schema continue; } - if (isset($class->associationMappings[$identifierField]['inherited'])) { + if (isset($class->associationMappings[$identifierField]->inherited)) { $idMapping = $class->associationMappings[$identifierField]; $targetEntity = current( array_filter( $classes, - static fn (ClassMetadata $class): bool => $class->name === $idMapping['targetEntity'] + static fn (ClassMetadata $class): bool => $class->name === $idMapping->targetEntity, ), ); - foreach ($idMapping['joinColumns'] as $joinColumn) { + foreach ($idMapping->joinColumns as $joinColumn) { if (isset($targetEntity->fieldMappings[$joinColumn['referencedColumnName']])) { $columnName = $this->quoteStrategy->getJoinColumnName( $joinColumn, @@ -300,7 +300,7 @@ public function getSchemaFromMetadata(array $classes): Schema } elseif (isset($class->associationMappings[$identifierField])) { $assoc = $class->associationMappings[$identifierField]; - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $pkColumns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } } @@ -533,17 +533,17 @@ private function gatherRelationsSql( array &$blacklistedFks, ): void { foreach ($class->associationMappings as $id => $mapping) { - if (isset($mapping['inherited']) && ! in_array($id, $class->identifier, true)) { + if (isset($mapping->inherited) && ! in_array($id, $class->identifier, true)) { continue; } - $foreignClass = $this->em->getClassMetadata($mapping['targetEntity']); + $foreignClass = $this->em->getClassMetadata($mapping->targetEntity); if ($mapping->isToOneOwningSide()) { $primaryKeyColumns = []; // PK is unnecessary for this relation-type $this->gatherRelationJoinColumns( - $mapping['joinColumns'], + $mapping->joinColumns, $table, $foreignClass, $mapping, @@ -553,7 +553,7 @@ private function gatherRelationsSql( ); } elseif ($mapping instanceof ManyToManyOwningSideMapping) { // create join table - $joinTable = $mapping['joinTable']; + $joinTable = $mapping->joinTable; $theJoinTable = $schema->createTable( $this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform), @@ -621,7 +621,7 @@ private function getDefiningClass(ClassMetadata $class, string $referencedColumn && $class->getSingleAssociationJoinColumnName($fieldName) === $referencedColumnName ) { return $this->getDefiningClass( - $this->em->getClassMetadata($class->associationMappings[$fieldName]['targetEntity']), + $this->em->getClassMetadata($class->associationMappings[$fieldName]->targetEntity), $class->getSingleAssociationReferencedJoinColumnName($fieldName), ); } @@ -668,8 +668,8 @@ private function gatherRelationJoinColumns( if (! $definingClass) { throw MissingColumnException::fromColumnSourceAndTarget( $joinColumn['referencedColumnName'], - $mapping['sourceEntity'], - $mapping['targetEntity'], + $mapping->sourceEntity, + $mapping->targetEntity, ); } diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index e58d585bd1c..0f812b8f466 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -81,63 +81,63 @@ public function validateClass(ClassMetadata $class): array } foreach ($class->associationMappings as $fieldName => $assoc) { - if (! class_exists($assoc['targetEntity']) || $cmf->isTransient($assoc['targetEntity'])) { - $ce[] = "The target entity '" . $assoc['targetEntity'] . "' specified on " . $class->name . '#' . $fieldName . ' is unknown or not an entity.'; + if (! class_exists($assoc->targetEntity) || $cmf->isTransient($assoc->targetEntity)) { + $ce[] = "The target entity '" . $assoc->targetEntity . "' specified on " . $class->name . '#' . $fieldName . ' is unknown or not an entity.'; return $ce; } - $targetMetadata = $cmf->getMetadataFor($assoc['targetEntity']); + $targetMetadata = $cmf->getMetadataFor($assoc->targetEntity); if ($targetMetadata->isMappedSuperclass) { - $ce[] = "The target entity '" . $assoc['targetEntity'] . "' specified on " . $class->name . '#' . $fieldName . ' is a mapped superclass. This is not possible since there is no table that a foreign key could refer to.'; + $ce[] = "The target entity '" . $assoc->targetEntity . "' specified on " . $class->name . '#' . $fieldName . ' is a mapped superclass. This is not possible since there is no table that a foreign key could refer to.'; return $ce; } - if (isset($assoc['id']) && $targetMetadata->containsForeignIdentifier) { + if (isset($assoc->id) && $targetMetadata->containsForeignIdentifier) { $ce[] = "Cannot map association '" . $class->name . '#' . $fieldName . ' as identifier, because ' . "the target entity '" . $targetMetadata->name . "' also maps an association as identifier."; } if (! $assoc->isOwningSide()) { - if ($targetMetadata->hasField($assoc['mappedBy'])) { + if ($targetMetadata->hasField($assoc->mappedBy)) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the owning side ' . - 'field ' . $assoc['targetEntity'] . '#' . $assoc['mappedBy'] . ' which is not defined as association, but as field.'; + 'field ' . $assoc->targetEntity . '#' . $assoc->mappedBy . ' which is not defined as association, but as field.'; } - if (! $targetMetadata->hasAssociation($assoc['mappedBy'])) { + if (! $targetMetadata->hasAssociation($assoc->mappedBy)) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the owning side ' . - 'field ' . $assoc['targetEntity'] . '#' . $assoc['mappedBy'] . ' which does not exist.'; - } elseif ($targetMetadata->associationMappings[$assoc['mappedBy']]['inversedBy'] === null) { + 'field ' . $assoc->targetEntity . '#' . $assoc->mappedBy . ' which does not exist.'; + } elseif ($targetMetadata->associationMappings[$assoc->mappedBy]->inversedBy === null) { $ce[] = 'The field ' . $class->name . '#' . $fieldName . ' is on the inverse side of a ' . 'bi-directional relationship, but the specified mappedBy association on the target-entity ' . - $assoc['targetEntity'] . '#' . $assoc['mappedBy'] . ' does not contain the required ' . + $assoc->targetEntity . '#' . $assoc->mappedBy . ' does not contain the required ' . "'inversedBy=\"" . $fieldName . "\"' attribute."; - } elseif ($targetMetadata->associationMappings[$assoc['mappedBy']]['inversedBy'] !== $fieldName) { + } elseif ($targetMetadata->associationMappings[$assoc->mappedBy]->inversedBy !== $fieldName) { $ce[] = 'The mappings ' . $class->name . '#' . $fieldName . ' and ' . - $assoc['targetEntity'] . '#' . $assoc['mappedBy'] . ' are ' . + $assoc->targetEntity . '#' . $assoc->mappedBy . ' are ' . 'inconsistent with each other.'; } } if ($assoc->isOwningSide() && $assoc->inversedBy) { - if ($targetMetadata->hasField($assoc['inversedBy'])) { + if ($targetMetadata->hasField($assoc->inversedBy)) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the inverse side ' . - 'field ' . $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' which is not defined as association.'; + 'field ' . $assoc->targetEntity . '#' . $assoc->inversedBy . ' which is not defined as association.'; } - if (! $targetMetadata->hasAssociation($assoc['inversedBy'])) { + if (! $targetMetadata->hasAssociation($assoc->inversedBy)) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the inverse side ' . - 'field ' . $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' which does not exist.'; - } elseif ($targetMetadata->associationMappings[$assoc['inversedBy']]->isOwningSide()) { + 'field ' . $assoc->targetEntity . '#' . $assoc->inversedBy . ' which does not exist.'; + } elseif ($targetMetadata->associationMappings[$assoc->inversedBy]->isOwningSide()) { $ce[] = 'The field ' . $class->name . '#' . $fieldName . ' is on the owning side of a ' . 'bi-directional relationship, but the specified inversedBy association on the target-entity ' . - $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' does not contain the required ' . + $assoc->targetEntity . '#' . $assoc->inversedBy . ' does not contain the required ' . "'mappedBy=\"" . $fieldName . "\"' attribute."; - } elseif ($targetMetadata->associationMappings[$assoc['inversedBy']]['mappedBy'] !== $fieldName) { + } elseif ($targetMetadata->associationMappings[$assoc->inversedBy]->mappedBy !== $fieldName) { $ce[] = 'The mappings ' . $class->name . '#' . $fieldName . ' and ' . - $assoc['targetEntity'] . '#' . $assoc['inversedBy'] . ' are ' . + $assoc->targetEntity . '#' . $assoc->inversedBy . ' are ' . 'inconsistent with each other.'; } @@ -152,7 +152,7 @@ public function validateClass(ClassMetadata $class): array 'side ' . $targetMetadata->name . '#' . $assoc->inversedBy . ' has to be one-to-many.'; } elseif ($assoc->isManyToMany() && ! $targetAssoc->isManyToMany()) { $ce[] = 'If association ' . $class->name . '#' . $fieldName . ' is many-to-many, then the inversed ' . - 'side ' . $targetMetadata->name . '#' . $assoc['inversedBy'] . ' has to be many-to-many as well.'; + 'side ' . $targetMetadata->name . '#' . $assoc->inversedBy . ' has to be many-to-many as well.'; } } } @@ -160,7 +160,7 @@ public function validateClass(ClassMetadata $class): array if ($assoc->isOwningSide()) { if ($assoc->isManyToManyOwningSide()) { $identifierColumns = $class->getIdentifierColumnNames(); - foreach ($assoc['joinTable']['joinColumns'] as $joinColumn) { + foreach ($assoc->joinTable['joinColumns'] as $joinColumn) { if (! in_array($joinColumn['referencedColumnName'], $identifierColumns, true)) { $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " . "has to be a primary key column on the target entity class '" . $class->name . "'."; @@ -169,7 +169,7 @@ public function validateClass(ClassMetadata $class): array } $identifierColumns = $targetMetadata->getIdentifierColumnNames(); - foreach ($assoc['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) { + foreach ($assoc->joinTable['inverseJoinColumns'] as $inverseJoinColumn) { if (! in_array($inverseJoinColumn['referencedColumnName'], $identifierColumns, true)) { $ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' " . "has to be a primary key column on the target entity class '" . $targetMetadata->name . "'."; @@ -177,36 +177,36 @@ public function validateClass(ClassMetadata $class): array } } - if (count($targetMetadata->getIdentifierColumnNames()) !== count($assoc['joinTable']['inverseJoinColumns'])) { - $ce[] = "The inverse join columns of the many-to-many table '" . $assoc['joinTable']['name'] . "' " . + if (count($targetMetadata->getIdentifierColumnNames()) !== count($assoc->joinTable['inverseJoinColumns'])) { + $ce[] = "The inverse join columns of the many-to-many table '" . $assoc->joinTable['name'] . "' " . "have to contain to ALL identifier columns of the target entity '" . $targetMetadata->name . "', " . - "however '" . implode(', ', array_diff($targetMetadata->getIdentifierColumnNames(), array_values($assoc['relationToTargetKeyColumns']))) . + "however '" . implode(', ', array_diff($targetMetadata->getIdentifierColumnNames(), array_values($assoc->relationToTargetKeyColumns))) . "' are missing."; } - if (count($class->getIdentifierColumnNames()) !== count($assoc['joinTable']['joinColumns'])) { - $ce[] = "The join columns of the many-to-many table '" . $assoc['joinTable']['name'] . "' " . + if (count($class->getIdentifierColumnNames()) !== count($assoc->joinTable['joinColumns'])) { + $ce[] = "The join columns of the many-to-many table '" . $assoc->joinTable['name'] . "' " . "have to contain to ALL identifier columns of the source entity '" . $class->name . "', " . - "however '" . implode(', ', array_diff($class->getIdentifierColumnNames(), array_values($assoc['relationToSourceKeyColumns']))) . + "however '" . implode(', ', array_diff($class->getIdentifierColumnNames(), array_values($assoc->relationToSourceKeyColumns))) . "' are missing."; } } elseif ($assoc->isToOneOwningSide()) { $identifierColumns = $targetMetadata->getIdentifierColumnNames(); - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { if (! in_array($joinColumn['referencedColumnName'], $identifierColumns, true)) { $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " . "has to be a primary key column on the target entity class '" . $targetMetadata->name . "'."; } } - if (count($identifierColumns) !== count($assoc['joinColumns'])) { + if (count($identifierColumns) !== count($assoc->joinColumns)) { $ids = []; - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { $ids[] = $joinColumn['name']; } - $ce[] = "The join columns of the association '" . $assoc['fieldName'] . "' " . + $ce[] = "The join columns of the association '" . $assoc->fieldName . "' " . "have to match to ALL identifier columns of the target entity '" . $targetMetadata->name . "', " . "however '" . implode(', ', array_diff($targetMetadata->getIdentifierColumnNames(), $ids)) . "' are missing."; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 57b558c31cc..943aed5be55 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -581,7 +581,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void // Inject PersistentCollection $value = new PersistentCollection( $this->em, - $this->em->getClassMetadata($assoc['targetEntity']), + $this->em->getClassMetadata($assoc->targetEntity), $value, ); $value->setOwner($entity, $assoc); @@ -703,11 +703,11 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void } if ($assoc->isToOne()) { - if ($assoc['isOwningSide']) { + if ($assoc->isOwningSide()) { $changeSet[$propName] = [$orgValue, $actualValue]; } - if ($orgValue !== null && $assoc['orphanRemoval']) { + if ($orgValue !== null && $assoc->orphanRemoval) { assert(is_object($orgValue)); $this->scheduleOrphanRemoval($orgValue); } @@ -802,7 +802,7 @@ private function computeAssociationChanges(AssociationMapping $assoc, mixed $val // for transient (new) entities, recursively. ("Persistence by reachability") // Unwrap. Uninitialized collections will simply be empty. $unwrappedValue = $assoc->isToOne() ? [$value] : $value->unwrap(); - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); foreach ($unwrappedValue as $key => $entry) { if (! ($entry instanceof $targetClass->name)) { @@ -811,18 +811,18 @@ private function computeAssociationChanges(AssociationMapping $assoc, mixed $val $state = $this->getEntityState($entry, self::STATE_NEW); - if (! ($entry instanceof $assoc['targetEntity'])) { + if (! ($entry instanceof $assoc->targetEntity)) { throw UnexpectedAssociationValue::create( - $assoc['sourceEntity'], - $assoc['fieldName'], + $assoc->sourceEntity, + $assoc->fieldName, get_debug_type($entry), - $assoc['targetEntity'], + $assoc->targetEntity, ); } switch ($state) { case self::STATE_NEW: - if (! $assoc['isCascadePersist']) { + if (! $assoc->isCascadePersist()) { /* * For now just record the details, because this may * not be an issue if we later discover another pathway @@ -1190,7 +1190,7 @@ private function getCommitOrder(): array continue; } - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); if (! $calc->hasNode($targetClass->name)) { $calc->addNode($targetClass->name, $targetClass); @@ -1894,11 +1894,11 @@ private function cascadeRefresh(object $entity, array &$visited, LockMode|int|nu $associationMappings = array_filter( $class->associationMappings, - static fn (AssociationMapping $assoc): bool => $assoc['isCascadeRefresh'] + static fn (AssociationMapping $assoc): bool => $assoc->isCascadeRefresh() ); foreach ($associationMappings as $assoc) { - $relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); + $relatedEntities = $class->reflFields[$assoc->fieldName]->getValue($entity); switch (true) { case $relatedEntities instanceof PersistentCollection: @@ -1935,11 +1935,11 @@ private function cascadeDetach(object $entity, array &$visited): void $associationMappings = array_filter( $class->associationMappings, - static fn (AssociationMapping $assoc): bool => $assoc['isCascadeDetach'] + static fn (AssociationMapping $assoc): bool => $assoc->isCascadeDetach() ); foreach ($associationMappings as $assoc) { - $relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); + $relatedEntities = $class->reflFields[$assoc->fieldName]->getValue($entity); switch (true) { case $relatedEntities instanceof PersistentCollection: @@ -1981,11 +1981,11 @@ private function cascadePersist(object $entity, array &$visited): void $associationMappings = array_filter( $class->associationMappings, - static fn (AssociationMapping $assoc): bool => $assoc['isCascadePersist'] + static fn (AssociationMapping $assoc): bool => $assoc->isCascadePersist() ); foreach ($associationMappings as $assoc) { - $relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); + $relatedEntities = $class->reflFields[$assoc->fieldName]->getValue($entity); switch (true) { case $relatedEntities instanceof PersistentCollection: @@ -1997,7 +1997,7 @@ private function cascadePersist(object $entity, array &$visited): void case is_array($relatedEntities): if ($assoc->isToMany() <= 0) { throw ORMInvalidArgumentException::invalidAssociation( - $this->em->getClassMetadata($assoc['targetEntity']), + $this->em->getClassMetadata($assoc->targetEntity), $assoc, $relatedEntities, ); @@ -2010,9 +2010,9 @@ private function cascadePersist(object $entity, array &$visited): void break; case $relatedEntities !== null: - if (! $relatedEntities instanceof $assoc['targetEntity']) { + if (! $relatedEntities instanceof $assoc->targetEntity) { throw ORMInvalidArgumentException::invalidAssociation( - $this->em->getClassMetadata($assoc['targetEntity']), + $this->em->getClassMetadata($assoc->targetEntity), $assoc, $relatedEntities, ); @@ -2038,7 +2038,7 @@ private function cascadeRemove(object $entity, array &$visited): void $associationMappings = array_filter( $class->associationMappings, - static fn (AssociationMapping $assoc): bool => $assoc['isCascadeRemove'] + static fn (AssociationMapping $assoc): bool => $assoc->isCascadeRemove() ); $entitiesToCascade = []; @@ -2048,7 +2048,7 @@ private function cascadeRemove(object $entity, array &$visited): void $entity->__load(); } - $relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); + $relatedEntities = $class->reflFields[$assoc->fieldName]->getValue($entity); switch (true) { case $relatedEntities instanceof Collection: @@ -2320,23 +2320,23 @@ public function createEntity(string $className, array $data, array &$hints = []) continue; } - $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); + $targetClass = $this->em->getClassMetadata($assoc->targetEntity); switch (true) { case $assoc->isToOne(): - if (! $assoc['isOwningSide']) { + if (! $assoc->isOwningSide()) { // use the given entity association if (isset($data[$field]) && is_object($data[$field]) && isset($this->entityStates[spl_object_id($data[$field])])) { $this->originalEntityData[$oid][$field] = $data[$field]; $class->reflFields[$field]->setValue($entity, $data[$field]); - $targetClass->reflFields[$assoc['mappedBy']]->setValue($data[$field], $entity); + $targetClass->reflFields[$assoc->mappedBy]->setValue($data[$field], $entity); continue 2; } // Inverse side of x-to-one can never be lazy - $class->reflFields[$field]->setValue($entity, $this->getEntityPersister($assoc['targetEntity'])->loadOneToOneEntity($assoc, $entity)); + $class->reflFields[$field]->setValue($entity, $this->getEntityPersister($assoc->targetEntity)->loadOneToOneEntity($assoc, $entity)); continue 2; } @@ -2352,7 +2352,7 @@ public function createEntity(string $className, array $data, array &$hints = []) $associatedId = []; // TODO: Is this even computed right in all cases of composite keys? - foreach ($assoc['targetToSourceKeyColumns'] as $targetColumn => $srcColumn) { + foreach ($assoc->targetToSourceKeyColumns as $targetColumn => $srcColumn) { $joinColumnValue = $data[$srcColumn] ?? null; if ($joinColumnValue !== null) { @@ -2384,7 +2384,7 @@ public function createEntity(string $className, array $data, array &$hints = []) } if (! isset($hints['fetchMode'][$class->name][$field])) { - $hints['fetchMode'][$class->name][$field] = $assoc['fetch']; + $hints['fetchMode'][$class->name][$field] = $assoc->fetch; } // Foreign key is set @@ -2416,7 +2416,7 @@ public function createEntity(string $className, array $data, array &$hints = []) // If it might be a subtype, it can not be lazy. There isn't even // a way to solve this with deferred eager loading, which means putting // an entity with subclasses at a *-to-one location is really bad! (performance-wise) - $newValue = $this->getEntityPersister($assoc['targetEntity'])->loadOneToOneEntity($assoc, $entity, $associatedId); + $newValue = $this->getEntityPersister($assoc->targetEntity)->loadOneToOneEntity($assoc, $entity, $associatedId); break; default: @@ -2425,7 +2425,7 @@ public function createEntity(string $className, array $data, array &$hints = []) switch (true) { // We are negating the condition here. Other cases will assume it is valid! case $hints['fetchMode'][$class->name][$field] !== ClassMetadata::FETCH_EAGER: - $newValue = $this->em->getProxyFactory()->getProxy($assoc['targetEntity'], $normalizedAssociatedId); + $newValue = $this->em->getProxyFactory()->getProxy($assoc->targetEntity, $normalizedAssociatedId); break; // Deferred eager load only works for single identifier classes @@ -2433,12 +2433,12 @@ public function createEntity(string $className, array $data, array &$hints = []) // TODO: Is there a faster approach? $this->eagerLoadingEntities[$targetClass->rootEntityName][$relatedIdHash] = current($normalizedAssociatedId); - $newValue = $this->em->getProxyFactory()->getProxy($assoc['targetEntity'], $normalizedAssociatedId); + $newValue = $this->em->getProxyFactory()->getProxy($assoc->targetEntity, $normalizedAssociatedId); break; default: // TODO: This is very imperformant, ignore it? - $newValue = $this->em->find($assoc['targetEntity'], $normalizedAssociatedId); + $newValue = $this->em->find($assoc->targetEntity, $normalizedAssociatedId); break; } @@ -2466,9 +2466,9 @@ public function createEntity(string $className, array $data, array &$hints = []) $this->originalEntityData[$oid][$field] = $newValue; $class->reflFields[$field]->setValue($entity, $newValue); - if ($assoc['inversedBy'] && $assoc->isOneToOne() && $newValue !== null) { - $inverseAssoc = $targetClass->associationMappings[$assoc['inversedBy']]; - $targetClass->reflFields[$inverseAssoc['fieldName']]->setValue($newValue, $entity); + if ($assoc->inversedBy && $assoc->isOneToOne() && $newValue !== null) { + $inverseAssoc = $targetClass->associationMappings[$assoc->inversedBy]; + $targetClass->reflFields[$inverseAssoc->fieldName]->setValue($newValue, $entity); } break; @@ -2498,7 +2498,7 @@ public function createEntity(string $className, array $data, array &$hints = []) $reflField = $class->reflFields[$field]; $reflField->setValue($entity, $pColl); - if ($assoc['fetch'] === ClassMetadata::FETCH_EAGER) { + if ($assoc->fetch === ClassMetadata::FETCH_EAGER) { $this->loadCollection($pColl); $pColl->takeSnapshot(); } @@ -2545,9 +2545,9 @@ public function triggerEagerLoads(): void public function loadCollection(PersistentCollection $collection): void { $assoc = $collection->getMapping(); - $persister = $this->getEntityPersister($assoc['targetEntity']); + $persister = $this->getEntityPersister($assoc->targetEntity); - switch ($assoc['type']) { + switch ($assoc->type()) { case ClassMetadata::ONE_TO_MANY: $persister->loadOneToManyCollection($assoc, $collection->getOwner(), $collection); break; @@ -2722,19 +2722,19 @@ public function getEntityPersister(string $entityName): EntityPersister /** Gets a collection persister for a collection-valued association. */ public function getCollectionPersister(AssociationMapping $association): CollectionPersister { - $role = isset($association['cache']) - ? $association['sourceEntity'] . '::' . $association['fieldName'] - : $association['type']; + $role = isset($association->cache) + ? $association->sourceEntity . '::' . $association->fieldName + : $association->type(); if (isset($this->collectionPersisters[$role])) { return $this->collectionPersisters[$role]; } - $persister = $association['type'] === ClassMetadata::ONE_TO_MANY + $persister = $association->type() === ClassMetadata::ONE_TO_MANY ? new OneToManyPersister($this->em) : new ManyToManyPersister($this->em); - if ($this->hasCache && isset($association['cache'])) { + if ($this->hasCache && isset($association->cache)) { $persister = $this->em->getConfiguration() ->getSecondLevelCacheConfiguration() ->getCacheFactory() diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index 627f8daee8b..8ba793986ab 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -47,9 +47,9 @@ public function flattenIdentifier(ClassMetadata $class, array $id): array $flatId = []; foreach ($class->identifier as $field) { - if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_a($id[$field], $class->associationMappings[$field]['targetEntity'])) { + if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_a($id[$field], $class->associationMappings[$field]->targetEntity)) { $targetClassMetadata = $this->metadataFactory->getMetadataFor( - $class->associationMappings[$field]['targetEntity'], + $class->associationMappings[$field]->targetEntity, ); assert($targetClassMetadata instanceof ClassMetadata); @@ -63,7 +63,7 @@ public function flattenIdentifier(ClassMetadata $class, array $id): array } elseif (isset($class->associationMappings[$field])) { $associatedId = []; - foreach ($class->associationMappings[$field]['joinColumns'] as $joinColumn) { + foreach ($class->associationMappings[$field]->joinColumns as $joinColumn) { $associatedId[] = $id[$joinColumn['name']]; } diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index fc7fe9b0702..16699a7e0d5 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -37,17 +37,17 @@ public static function getTypeOfField(string $fieldName, ClassMetadata $class, E $assoc = $class->associationMappings[$fieldName]; if (! $assoc->isOwningSide()) { - return self::getTypeOfField($assoc['mappedBy'], $em->getClassMetadata($assoc['targetEntity']), $em); + return self::getTypeOfField($assoc->mappedBy, $em->getClassMetadata($assoc->targetEntity), $em); } if ($assoc->isManyToManyOwningSide()) { - $joinData = $assoc['joinTable']; + $joinData = $assoc->joinTable; } else { $joinData = $assoc; } $types = []; - $targetClass = $em->getClassMetadata($assoc['targetEntity']); + $targetClass = $em->getClassMetadata($assoc->targetEntity); foreach ($joinData['joinColumns'] as $joinColumn) { $types[] = self::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $em); @@ -73,10 +73,10 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, continue; } - foreach ($assoc['joinColumns'] as $joinColumn) { + foreach ($assoc->joinColumns as $joinColumn) { if ($joinColumn['name'] === $columnName) { $targetColumnName = $joinColumn['referencedColumnName']; - $targetClass = $em->getClassMetadata($assoc['targetEntity']); + $targetClass = $em->getClassMetadata($assoc->targetEntity); return self::getTypeOfColumn($targetColumnName, $targetClass, $em); } @@ -89,10 +89,10 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, continue; } - foreach ($assoc['joinTable']['joinColumns'] as $joinColumn) { + foreach ($assoc->joinTable['joinColumns'] as $joinColumn) { if ($joinColumn['name'] === $columnName) { $targetColumnName = $joinColumn['referencedColumnName']; - $targetClass = $em->getClassMetadata($assoc['targetEntity']); + $targetClass = $em->getClassMetadata($assoc->targetEntity); return self::getTypeOfColumn($targetColumnName, $targetClass, $em); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9c6dc4b6911..bf13d239497 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -668,11 +668,7 @@ ]]> - - loadCriteria($criteria))]]> - + ]]> diff --git a/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php b/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php index 72d59d995a2..c666b04d2f9 100644 --- a/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php +++ b/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php @@ -65,11 +65,11 @@ protected function enableCaching(ClassMetadata $metadata, EntityManagerInterface // only enable association-caching when the target has already been // given caching settings foreach ($metadata->associationMappings as $mapping) { - $targetMeta = $em->getClassMetadata($mapping['targetEntity']); + $targetMeta = $em->getClassMetadata($mapping->targetEntity); $this->enableCaching($targetMeta, $em); if ($this->isVisited($targetMeta)) { - $metadata->enableAssociationCache($mapping['fieldName'], $cache); + $metadata->enableAssociationCache($mapping->fieldName, $cache); } } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 2ceba5a411c..a25b3782160 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -131,7 +131,7 @@ public function testBuildCachedCollectionPersisterReadOnly(): void $this->factory->expects(self::once()) ->method('getRegion') - ->with(self::equalTo($mapping['cache'])) + ->with(self::equalTo($mapping->cache)) ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); @@ -152,7 +152,7 @@ public function testBuildCachedCollectionPersisterReadWrite(): void $this->factory->expects(self::once()) ->method('getRegion') - ->with(self::equalTo($mapping['cache'])) + ->with(self::equalTo($mapping->cache)) ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); @@ -173,7 +173,7 @@ public function testBuildCachedCollectionPersisterNonStrictReadWrite(): void $this->factory->expects(self::once()) ->method('getRegion') - ->with(self::equalTo($mapping['cache'])) + ->with(self::equalTo($mapping->cache)) ->will(self::returnValue($region)); $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping); diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index 1b6a872e9a6..9c4ec5670bd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -63,11 +63,11 @@ protected function setUp(): void $class->associationMappings['phonenumbers']['indexBy'] = 'phonenumber'; foreach (['phonenumbers', 'articles', 'users'] as $field) { - if (isset($class->associationMappings[$field]['cache'])) { + if (isset($class->associationMappings[$field]->cache)) { $this->previousCacheConfig[$field] = $class->associationMappings[$field]['cache']; } - unset($class->associationMappings[$field]['cache']); + unset($class->associationMappings[$field]->cache); } $class = $this->_em->getClassMetadata(CmsGroup::class); @@ -93,14 +93,14 @@ public function tearDown(): void } } - unset($class->associationMappings['groups']['indexBy']); - unset($class->associationMappings['articles']['indexBy']); - unset($class->associationMappings['phonenumbers']['indexBy']); + unset($class->associationMappings['groups']->indexBy); + unset($class->associationMappings['articles']->indexBy); + unset($class->associationMappings['phonenumbers']->indexBy); $class = $this->_em->getClassMetadata(CmsGroup::class); $class->associationMappings['users']['fetch'] = ClassMetadata::FETCH_LAZY; - unset($class->associationMappings['users']['indexBy']); + unset($class->associationMappings['users']->indexBy); } #[Group('DDC-546')] diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php index 354e71dd953..5d2adee5bfb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -78,7 +78,7 @@ public function testCascadeRemoveOnChildren(): void $class = $this->_em->getClassMetadata(DDC599Subitem::class); self::assertArrayHasKey('children', $class->associationMappings); - self::assertTrue($class->associationMappings['children']['isCascadeRemove']); + self::assertTrue($class->associationMappings['children']->isCascadeRemove()); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index 5f3da208862..522b0fcf634 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -109,7 +109,7 @@ public function testJoinColumnName(): void ], ); - $joinColumn = $class->associationMappings['article']['joinColumns'][0]; + $joinColumn = $class->associationMappings['article']->joinColumns[0]; self::assertEquals('article', $this->strategy->getJoinColumnName($joinColumn, $class, $this->platform)); } @@ -128,7 +128,7 @@ public function testReferencedJoinColumnName(): void ], ); - $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; + $joinColumn = $cm->associationMappings['article']->joinColumns[0]; self::assertEquals('id', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 04f51df278b..ef16896a14b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -37,7 +37,7 @@ public function testOriginallyNestedAttributesDeclaredWithoutOriginalParent(): v ], $metadata->table, ); - self::assertEquals(['assoz_id', 'assoz_id'], $metadata->associationMappings['assoc']['joinTableColumns']); + self::assertEquals(['assoz_id', 'assoz_id'], $metadata->associationMappings['assoc']->joinTableColumns); } public function testIsTransient(): void @@ -70,7 +70,7 @@ public function testManyToManyAssociationWithNestedJoinColumns(): void 'columnDefinition' => null, ]), ], - $metadata->associationMappings['assoc']['joinTable']['joinColumns'], + $metadata->associationMappings['assoc']->joinTable['joinColumns'], ); self::assertEquals( @@ -84,7 +84,7 @@ public function testManyToManyAssociationWithNestedJoinColumns(): void 'columnDefinition' => null, ]), ], - $metadata->associationMappings['assoc']['joinTable']['inverseJoinColumns'], + $metadata->associationMappings['assoc']->joinTable['inverseJoinColumns'], ); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 8bc3a510c65..4d8ce245bff 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -304,9 +304,9 @@ public function testQuoteMetadata(): void self::assertEquals('phone-number', $phoneMetadata->fieldMappings['number']->columnName); $user = $phoneMetadata->associationMappings['user']; - self::assertTrue($user['joinColumns'][0]['quoted']); - self::assertEquals('user-id', $user['joinColumns'][0]['name']); - self::assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user->joinColumns[0]['quoted']); + self::assertEquals('user-id', $user->joinColumns[0]['name']); + self::assertEquals('user-id', $user->joinColumns[0]['referencedColumnName']); // User Group Metadata self::assertTrue($groupMetadata->fieldMappings['id']->quoted); @@ -316,9 +316,9 @@ public function testQuoteMetadata(): void self::assertEquals('user-name', $userMetadata->fieldMappings['name']->columnName); $user = $groupMetadata->associationMappings['parent']; - self::assertTrue($user['joinColumns'][0]['quoted']); - self::assertEquals('parent-id', $user['joinColumns'][0]['name']); - self::assertEquals('group-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user->joinColumns[0]['quoted']); + self::assertEquals('parent-id', $user->joinColumns[0]['name']); + self::assertEquals('group-id', $user->joinColumns[0]['referencedColumnName']); // Address Class Metadata self::assertTrue($addressMetadata->fieldMappings['id']->quoted); @@ -328,9 +328,9 @@ public function testQuoteMetadata(): void self::assertEquals('address-zip', $addressMetadata->fieldMappings['zip']->columnName); $user = $addressMetadata->associationMappings['user']; - self::assertTrue($user['joinColumns'][0]['quoted']); - self::assertEquals('user-id', $user['joinColumns'][0]['name']); - self::assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']); + self::assertTrue($user->joinColumns[0]['quoted']); + self::assertEquals('user-id', $user->joinColumns[0]['name']); + self::assertEquals('user-id', $user->joinColumns[0]['referencedColumnName']); // User Class Metadata self::assertTrue($userMetadata->fieldMappings['id']->quoted); @@ -340,15 +340,15 @@ public function testQuoteMetadata(): void self::assertEquals('user-name', $userMetadata->fieldMappings['name']->columnName); $groups = $userMetadata->associationMappings['groups']; - self::assertTrue($groups['joinTable']['quoted']); - self::assertTrue($groups['joinTable']['joinColumns'][0]['quoted']); - self::assertEquals('quote-users-groups', $groups['joinTable']['name']); - self::assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['name']); - self::assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['referencedColumnName']); - - self::assertTrue($groups['joinTable']['inverseJoinColumns'][0]['quoted']); - self::assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['name']); - self::assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + self::assertTrue($groups->joinTable['quoted']); + self::assertTrue($groups->joinTable['joinColumns'][0]['quoted']); + self::assertEquals('quote-users-groups', $groups->joinTable['name']); + self::assertEquals('user-id', $groups->joinTable['joinColumns'][0]['name']); + self::assertEquals('user-id', $groups->joinTable['joinColumns'][0]['referencedColumnName']); + + self::assertTrue($groups->joinTable['inverseJoinColumns'][0]['quoted']); + self::assertEquals('group-id', $groups->joinTable['inverseJoinColumns'][0]['name']); + self::assertEquals('group-id', $groups->joinTable['inverseJoinColumns'][0]['referencedColumnName']); } #[\PHPUnit\Framework\Attributes\Group('DDC-3385')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 7b50ec54c7f..efe6fcbf936 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -143,10 +143,10 @@ public function testFieldIsNullableByType(): void $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapOneToOne(['fieldName' => 'email', 'joinColumns' => [['name' => 'email_id', 'referencedColumnName' => 'id']]]); - self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('email')['targetEntity']); + self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('email')->targetEntity); $cm->mapManyToOne(['fieldName' => 'mainEmail']); - self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('mainEmail')['targetEntity']); + self::assertEquals(CmsEmail::class, $cm->getAssociationMapping('mainEmail')->targetEntity); $cm->mapEmbedded(['fieldName' => 'contact']); self::assertEquals(Contact::class, $cm->embeddedClasses['contact']->class); @@ -249,7 +249,7 @@ public function testMapAssociationInGlobalNamespace(): void ], ); - self::assertEquals('DoctrineGlobalUser', $cm->associationMappings['author']['targetEntity']); + self::assertEquals('DoctrineGlobalUser', $cm->associationMappings['author']->targetEntity); } public function testMapManyToManyJoinTableDefaults(): void @@ -270,9 +270,9 @@ public function testMapManyToManyJoinTableDefaults(): void 'joinColumns' => [['name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], 'inverseJoinColumns' => [['name' => 'cmsgroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], ]), - $assoc['joinTable'], + $assoc->joinTable, ); - self::assertTrue($assoc['isOnDeleteCascade']); + self::assertTrue($assoc->isOnDeleteCascade); } public function testSerializeManyToManyJoinTableCascade(): void @@ -482,7 +482,7 @@ public function testDefaultTableName(): void ], ], ); - self::assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']); + self::assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']->joinTable['name']); } public function testDefaultJoinColumnName(): void @@ -499,7 +499,7 @@ public function testDefaultJoinColumnName(): void 'joinColumns' => [['referencedColumnName' => 'id']], ], ); - self::assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); + self::assertEquals('user_id', $cm->associationMappings['user']->joinColumns[0]['name']); $cm = new ClassMetadata(CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -515,8 +515,8 @@ public function testDefaultJoinColumnName(): void ], ], ); - self::assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']); - self::assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('cmsaddress_id', $cm->associationMappings['user']->joinTable['joinColumns'][0]['name']); + self::assertEquals('cmsuser_id', $cm->associationMappings['user']->joinTable['inverseJoinColumns'][0]['name']); } #[TestGroup('DDC-559')] @@ -540,28 +540,28 @@ public function testUnderscoreNamingStrategyDefaults(): void ], ); - self::assertEquals(['USER_ID' => 'ID'], $oneToOneMetadata->associationMappings['user']['sourceToTargetKeyColumns']); - self::assertEquals(['USER_ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['joinColumnFieldNames']); - self::assertEquals(['ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']['targetToSourceKeyColumns']); + self::assertEquals(['USER_ID' => 'ID'], $oneToOneMetadata->associationMappings['user']->sourceToTargetKeyColumns); + self::assertEquals(['USER_ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']->joinColumnFieldNames); + self::assertEquals(['ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']->targetToSourceKeyColumns); - self::assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['name']); - self::assertEquals('ID', $oneToOneMetadata->associationMappings['user']['joinColumns'][0]['referencedColumnName']); + self::assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']->joinColumns[0]['name']); + self::assertEquals('ID', $oneToOneMetadata->associationMappings['user']->joinColumns[0]['referencedColumnName']); - self::assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']['joinTable']['name']); + self::assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']->joinTable['name']); - self::assertEquals(['CMS_ADDRESS_ID', 'CMS_USER_ID'], $manyToManyMetadata->associationMappings['user']['joinTableColumns']); - self::assertEquals(['CMS_ADDRESS_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToSourceKeyColumns']); - self::assertEquals(['CMS_USER_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']['relationToTargetKeyColumns']); + self::assertEquals(['CMS_ADDRESS_ID', 'CMS_USER_ID'], $manyToManyMetadata->associationMappings['user']->joinTableColumns); + self::assertEquals(['CMS_ADDRESS_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']->relationToSourceKeyColumns); + self::assertEquals(['CMS_USER_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']->relationToTargetKeyColumns); - self::assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['name']); - self::assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']->joinTable['joinColumns'][0]['name']); + self::assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']->joinTable['inverseJoinColumns'][0]['name']); - self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['joinColumns'][0]['referencedColumnName']); - self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']->joinTable['joinColumns'][0]['referencedColumnName']); + self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']->joinTable['inverseJoinColumns'][0]['referencedColumnName']); $cm = new ClassMetadata('DoctrineGlobalArticle', $namingStrategy); $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CmsUser::class]); - self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']['joinTable']['name']); + self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']->joinTable['name']); } #[TestGroup('DDC-886')] @@ -597,7 +597,7 @@ public function testJoinTableMappingDefaults(): void $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CmsUser::class]); - self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']['joinTable']['name']); + self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']->joinTable['name']); } #[TestGroup('DDC-117')] @@ -779,8 +779,8 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void ); self::assertEquals('routing_routingleg', $routingMetadata->table['name']); - self::assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']['joinTable']['name']); - self::assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']['joinTable']['name']); + self::assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']->joinTable['name']); + self::assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']->joinTable['name']); } #[TestGroup('DDC-984')] @@ -888,11 +888,11 @@ public function testManyToManySelfReferencingNamingStrategyDefaults(): void 'joinColumns' => [['name' => 'customtypeparent_source', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], 'inverseJoinColumns' => [['name' => 'customtypeparent_target', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], ]), - $cm->associationMappings['friendsWithMe']['joinTable'], + $cm->associationMappings['friendsWithMe']->joinTable, ); - self::assertEquals(['customtypeparent_source', 'customtypeparent_target'], $cm->associationMappings['friendsWithMe']['joinTableColumns']); - self::assertEquals(['customtypeparent_source' => 'id'], $cm->associationMappings['friendsWithMe']['relationToSourceKeyColumns']); - self::assertEquals(['customtypeparent_target' => 'id'], $cm->associationMappings['friendsWithMe']['relationToTargetKeyColumns']); + self::assertEquals(['customtypeparent_source', 'customtypeparent_target'], $cm->associationMappings['friendsWithMe']->joinTableColumns); + self::assertEquals(['customtypeparent_source' => 'id'], $cm->associationMappings['friendsWithMe']->relationToSourceKeyColumns); + self::assertEquals(['customtypeparent_target' => 'id'], $cm->associationMappings['friendsWithMe']->relationToTargetKeyColumns); } #[TestGroup('DDC-2608')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 8accb5b9ad4..1cb667ca4b1 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -278,8 +278,8 @@ public function testFieldTypeFromReflection(): void self::assertEquals('boolean', $class->getTypeOfField('boolean')); self::assertEquals('float', $class->getTypeOfField('float')); - self::assertEquals(CmsEmail::class, $class->getAssociationMapping('email')['targetEntity']); - self::assertEquals(CmsEmail::class, $class->getAssociationMapping('mainEmail')['targetEntity']); + self::assertEquals(CmsEmail::class, $class->getAssociationMapping('email')->targetEntity); + self::assertEquals(CmsEmail::class, $class->getAssociationMapping('mainEmail')->targetEntity); self::assertEquals(Contact::class, $class->embeddedClasses['contact']->class); } @@ -354,14 +354,14 @@ public function testAssociations(ClassMetadata $class): ClassMetadata public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['address'])); - self::assertTrue($class->associationMappings['address']['isOwningSide']); - self::assertEquals('user', $class->associationMappings['address']['inversedBy']); + self::assertTrue($class->associationMappings['address']->isOwningSide()); + self::assertEquals('user', $class->associationMappings['address']->inversedBy); // Check cascading - self::assertTrue($class->associationMappings['address']['isCascadeRemove']); - self::assertFalse($class->associationMappings['address']['isCascadePersist']); - self::assertFalse($class->associationMappings['address']['isCascadeRefresh']); - self::assertFalse($class->associationMappings['address']['isCascadeDetach']); - self::assertFalse($class->associationMappings['address']['isCascadeMerge']); + self::assertTrue($class->associationMappings['address']->isCascadeRemove()); + self::assertFalse($class->associationMappings['address']->isCascadePersist()); + self::assertFalse($class->associationMappings['address']->isCascadeRefresh()); + self::assertFalse($class->associationMappings['address']->isCascadeDetach()); + self::assertFalse($class->associationMappings['address']->isCascadeMerge()); return $class; } @@ -370,16 +370,16 @@ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetada public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['phonenumbers'])); - self::assertFalse($class->associationMappings['phonenumbers']['isOwningSide']); - self::assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); - self::assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); - self::assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); - self::assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); - self::assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']); - self::assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + self::assertFalse($class->associationMappings['phonenumbers']->isOwningSide()); + self::assertTrue($class->associationMappings['phonenumbers']->isCascadePersist()); + self::assertTrue($class->associationMappings['phonenumbers']->isCascadeRemove()); + self::assertFalse($class->associationMappings['phonenumbers']->isCascadeRefresh()); + self::assertFalse($class->associationMappings['phonenumbers']->isCascadeDetach()); + self::assertFalse($class->associationMappings['phonenumbers']->isCascadeMerge()); + self::assertTrue($class->associationMappings['phonenumbers']->orphanRemoval); // Test Order By - self::assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']['orderBy']); + self::assertEquals(['number' => 'ASC'], $class->associationMappings['phonenumbers']->orderBy); return $class; } @@ -388,13 +388,13 @@ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMeta public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): ClassMetadata { self::assertTrue(isset($class->associationMappings['groups'])); - self::assertTrue($class->associationMappings['groups']['isOwningSide']); + self::assertTrue($class->associationMappings['groups']->isOwningSide()); // Make sure that cascade-all works as expected - self::assertTrue($class->associationMappings['groups']['isCascadeRemove']); - self::assertTrue($class->associationMappings['groups']['isCascadePersist']); - self::assertTrue($class->associationMappings['groups']['isCascadeRefresh']); - self::assertTrue($class->associationMappings['groups']['isCascadeDetach']); - self::assertTrue($class->associationMappings['groups']['isCascadeMerge']); + self::assertTrue($class->associationMappings['groups']->isCascadeRemove()); + self::assertTrue($class->associationMappings['groups']->isCascadePersist()); + self::assertTrue($class->associationMappings['groups']->isCascadeRefresh()); + self::assertTrue($class->associationMappings['groups']->isCascadeDetach()); + self::assertTrue($class->associationMappings['groups']->isCascadeMerge()); self::assertFalse($class->associationMappings['groups']->isOrdered()); @@ -424,8 +424,8 @@ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMetadata { // Non-Nullability of Join Column - self::assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['nullable']); - self::assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['unique']); + self::assertFalse($class->associationMappings['groups']->joinTable['joinColumns'][0]['nullable']); + self::assertFalse($class->associationMappings['groups']->joinTable['joinColumns'][0]['unique']); return $class; } @@ -434,7 +434,7 @@ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMeta public function testColumnDefinition(ClassMetadata $class): ClassMetadata { self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']->columnDefinition); - self::assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); + self::assertEquals('INT NULL', $class->associationMappings['groups']->joinTable['inverseJoinColumns'][0]['columnDefinition']); return $class; } @@ -442,7 +442,7 @@ public function testColumnDefinition(ClassMetadata $class): ClassMetadata #[Depends('testColumnDefinition')] public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata { - self::assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); + self::assertEquals('CASCADE', $class->associationMappings['address']->joinColumns[0]['onDelete']); return $class; } @@ -594,7 +594,7 @@ public function testInversedByOverrideMapping(): void $adminGroups = $adminMetadata->associationMappings['groups']; // assert override - self::assertEquals('admins', $adminGroups['inversedBy']); + self::assertEquals('admins', $adminGroups->inversedBy); } #[\PHPUnit\Framework\Attributes\Group('DDC-5934')] @@ -604,7 +604,7 @@ public function testFetchOverrideMapping(): void $contractMetadata = $this->createClassMetadataFactory()->getMetadataFor(DDC5934Contract::class); self::assertArrayHasKey('members', $contractMetadata->associationMappings); - self::assertSame(ClassMetadata::FETCH_EXTRA_LAZY, $contractMetadata->associationMappings['members']['fetch']); + self::assertSame(ClassMetadata::FETCH_EXTRA_LAZY, $contractMetadata->associationMappings['members']->fetch); } #[\PHPUnit\Framework\Attributes\Group('DDC-964')] @@ -622,33 +622,33 @@ public function testAssociationOverridesMapping(): void $adminGroups = $adminMetadata->associationMappings['groups']; // assert not override attributes - self::assertEquals($guestGroups['fieldName'], $adminGroups['fieldName']); - self::assertEquals($guestGroups['type'], $adminGroups['type']); - self::assertEquals($guestGroups['inversedBy'], $adminGroups['inversedBy']); - self::assertEquals($guestGroups['isOwningSide'], $adminGroups['isOwningSide']); - self::assertEquals($guestGroups['fetch'], $adminGroups['fetch']); - self::assertEquals($guestGroups['isCascadeRemove'], $adminGroups['isCascadeRemove']); - self::assertEquals($guestGroups['isCascadePersist'], $adminGroups['isCascadePersist']); - self::assertEquals($guestGroups['isCascadeRefresh'], $adminGroups['isCascadeRefresh']); - self::assertEquals($guestGroups['isCascadeMerge'], $adminGroups['isCascadeMerge']); - self::assertEquals($guestGroups['isCascadeDetach'], $adminGroups['isCascadeDetach']); + self::assertEquals($guestGroups->fieldName, $adminGroups->fieldName); + self::assertEquals($guestGroups->type(), $adminGroups->type()); + self::assertEquals($guestGroups->inversedBy, $adminGroups->inversedBy); + self::assertEquals($guestGroups->isOwningSide(), $adminGroups->isOwningSide()); + self::assertEquals($guestGroups->fetch, $adminGroups->fetch); + self::assertEquals($guestGroups->isCascadeRemove(), $adminGroups->isCascadeRemove()); + self::assertEquals($guestGroups->isCascadePersist(), $adminGroups->isCascadePersist()); + self::assertEquals($guestGroups->isCascadeRefresh(), $adminGroups->isCascadeRefresh()); + self::assertEquals($guestGroups->isCascadeMerge(), $adminGroups->isCascadeMerge()); + self::assertEquals($guestGroups->isCascadeDetach(), $adminGroups->isCascadeDetach()); // assert not override attributes - self::assertEquals('ddc964_users_groups', $guestGroups['joinTable']['name']); - self::assertEquals('user_id', $guestGroups['joinTable']['joinColumns'][0]['name']); - self::assertEquals('group_id', $guestGroups['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('ddc964_users_groups', $guestGroups->joinTable['name']); + self::assertEquals('user_id', $guestGroups->joinTable['joinColumns'][0]['name']); + self::assertEquals('group_id', $guestGroups->joinTable['inverseJoinColumns'][0]['name']); - self::assertEquals(['user_id' => 'id'], $guestGroups['relationToSourceKeyColumns']); - self::assertEquals(['group_id' => 'id'], $guestGroups['relationToTargetKeyColumns']); - self::assertEquals(['user_id', 'group_id'], $guestGroups['joinTableColumns']); + self::assertEquals(['user_id' => 'id'], $guestGroups->relationToSourceKeyColumns); + self::assertEquals(['group_id' => 'id'], $guestGroups->relationToTargetKeyColumns); + self::assertEquals(['user_id', 'group_id'], $guestGroups->joinTableColumns); - self::assertEquals('ddc964_users_admingroups', $adminGroups['joinTable']['name']); - self::assertEquals('adminuser_id', $adminGroups['joinTable']['joinColumns'][0]['name']); - self::assertEquals('admingroup_id', $adminGroups['joinTable']['inverseJoinColumns'][0]['name']); + self::assertEquals('ddc964_users_admingroups', $adminGroups->joinTable['name']); + self::assertEquals('adminuser_id', $adminGroups->joinTable['joinColumns'][0]['name']); + self::assertEquals('admingroup_id', $adminGroups->joinTable['inverseJoinColumns'][0]['name']); - self::assertEquals(['adminuser_id' => 'id'], $adminGroups['relationToSourceKeyColumns']); - self::assertEquals(['admingroup_id' => 'id'], $adminGroups['relationToTargetKeyColumns']); - self::assertEquals(['adminuser_id', 'admingroup_id'], $adminGroups['joinTableColumns']); + self::assertEquals(['adminuser_id' => 'id'], $adminGroups->relationToSourceKeyColumns); + self::assertEquals(['admingroup_id' => 'id'], $adminGroups->relationToTargetKeyColumns); + self::assertEquals(['adminuser_id', 'admingroup_id'], $adminGroups->joinTableColumns); // assert address association mappings self::assertArrayHasKey('address', $guestMetadata->associationMappings); @@ -658,27 +658,27 @@ public function testAssociationOverridesMapping(): void $adminAddress = $adminMetadata->associationMappings['address']; // assert not override attributes - self::assertEquals($guestAddress['fieldName'], $adminAddress['fieldName']); - self::assertEquals($guestAddress['type'], $adminAddress['type']); - self::assertEquals($guestAddress['inversedBy'], $adminAddress['inversedBy']); - self::assertEquals($guestAddress['isOwningSide'], $adminAddress['isOwningSide']); - self::assertEquals($guestAddress['fetch'], $adminAddress['fetch']); - self::assertEquals($guestAddress['isCascadeRemove'], $adminAddress['isCascadeRemove']); - self::assertEquals($guestAddress['isCascadePersist'], $adminAddress['isCascadePersist']); - self::assertEquals($guestAddress['isCascadeRefresh'], $adminAddress['isCascadeRefresh']); - self::assertEquals($guestAddress['isCascadeMerge'], $adminAddress['isCascadeMerge']); - self::assertEquals($guestAddress['isCascadeDetach'], $adminAddress['isCascadeDetach']); + self::assertEquals($guestAddress->fieldName, $adminAddress->fieldName); + self::assertEquals($guestAddress->type(), $adminAddress->type()); + self::assertEquals($guestAddress->inversedBy, $adminAddress->inversedBy); + self::assertEquals($guestAddress->isOwningSide(), $adminAddress->isOwningSide()); + self::assertEquals($guestAddress->fetch, $adminAddress->fetch); + self::assertEquals($guestAddress->isCascadeRemove(), $adminAddress->isCascadeRemove()); + self::assertEquals($guestAddress->isCascadePersist(), $adminAddress->isCascadePersist()); + self::assertEquals($guestAddress->isCascadeRefresh(), $adminAddress->isCascadeRefresh()); + self::assertEquals($guestAddress->isCascadeMerge(), $adminAddress->isCascadeMerge()); + self::assertEquals($guestAddress->isCascadeDetach(), $adminAddress->isCascadeDetach()); // assert override - self::assertEquals('address_id', $guestAddress['joinColumns'][0]['name']); - self::assertEquals(['address_id' => 'id'], $guestAddress['sourceToTargetKeyColumns']); - self::assertEquals(['address_id' => 'address_id'], $guestAddress['joinColumnFieldNames']); - self::assertEquals(['id' => 'address_id'], $guestAddress['targetToSourceKeyColumns']); + self::assertEquals('address_id', $guestAddress->joinColumns[0]['name']); + self::assertEquals(['address_id' => 'id'], $guestAddress->sourceToTargetKeyColumns); + self::assertEquals(['address_id' => 'address_id'], $guestAddress->joinColumnFieldNames); + self::assertEquals(['id' => 'address_id'], $guestAddress->targetToSourceKeyColumns); - self::assertEquals('adminaddress_id', $adminAddress['joinColumns'][0]['name']); - self::assertEquals(['adminaddress_id' => 'id'], $adminAddress['sourceToTargetKeyColumns']); - self::assertEquals(['adminaddress_id' => 'adminaddress_id'], $adminAddress['joinColumnFieldNames']); - self::assertEquals(['id' => 'adminaddress_id'], $adminAddress['targetToSourceKeyColumns']); + self::assertEquals('adminaddress_id', $adminAddress->joinColumns[0]['name']); + self::assertEquals(['adminaddress_id' => 'id'], $adminAddress->sourceToTargetKeyColumns); + self::assertEquals(['adminaddress_id' => 'adminaddress_id'], $adminAddress->joinColumnFieldNames); + self::assertEquals(['id' => 'adminaddress_id'], $adminAddress->targetToSourceKeyColumns); } #[\PHPUnit\Framework\Attributes\Group('DDC-964')] @@ -841,17 +841,17 @@ public function testSecondLevelCacheMapping(): void self::assertArrayHasKey('state', $class->associationMappings); self::assertArrayHasKey('cache', $class->associationMappings['state']); - self::assertArrayHasKey('usage', $class->associationMappings['state']['cache']); - self::assertArrayHasKey('region', $class->associationMappings['state']['cache']); - self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['state']['cache']['usage']); - self::assertEquals('doctrine_tests_models_cache_city__state', $class->associationMappings['state']['cache']['region']); + self::assertArrayHasKey('usage', $class->associationMappings['state']->cache); + self::assertArrayHasKey('region', $class->associationMappings['state']->cache); + self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['state']->cache['usage']); + self::assertEquals('doctrine_tests_models_cache_city__state', $class->associationMappings['state']->cache['region']); self::assertArrayHasKey('attractions', $class->associationMappings); self::assertArrayHasKey('cache', $class->associationMappings['attractions']); - self::assertArrayHasKey('usage', $class->associationMappings['attractions']['cache']); - self::assertArrayHasKey('region', $class->associationMappings['attractions']['cache']); - self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']['cache']['usage']); - self::assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']['cache']['region']); + self::assertArrayHasKey('usage', $class->associationMappings['attractions']->cache); + self::assertArrayHasKey('region', $class->associationMappings['attractions']->cache); + self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']->cache['usage']); + self::assertEquals('doctrine_tests_models_cache_city__attractions', $class->associationMappings['attractions']->cache['region']); } #[\PHPUnit\Framework\Attributes\Group('DDC-2825')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php index 74860086112..8a8eec6095a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php @@ -170,7 +170,7 @@ public function testJoinColumnName(): void ], ); - $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; + $joinColumn = $cm->associationMappings['article']->joinColumns[0]; self::assertEquals('"article"', $this->strategy->getJoinColumnName($joinColumn, $cm, $this->platform)); } @@ -189,7 +189,7 @@ public function testReferencedJoinColumnName(): void ], ); - $joinColumn = $cm->associationMappings['article']['joinColumns'][0]; + $joinColumn = $cm->associationMappings['article']->joinColumns[0]; self::assertEquals('"id"', $this->strategy->getReferencedJoinColumnName($joinColumn, $cm, $this->platform)); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 32f4a0c6a9e..10ea6c9705b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -90,7 +90,7 @@ public function testIdentifierWithAssociationKey(): void self::assertArrayHasKey('article', $class->associationMappings); self::assertArrayHasKey('id', $class->associationMappings['article']); - self::assertTrue($class->associationMappings['article']['id']); + self::assertTrue($class->associationMappings['article']->id); } public function testEmbeddableMapping(): void diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index 0d9d959105d..696f7927a15 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -49,10 +49,10 @@ public function testResolveTargetEntityListenerCanResolveTargetEntity(): void $cm = $this->factory->getMetadataFor(ResolveTargetEntity::class); $meta = $cm->associationMappings; - self::assertSame(TargetEntity::class, $meta['manyToMany']['targetEntity']); - self::assertSame(ResolveTargetEntity::class, $meta['manyToOne']['targetEntity']); - self::assertSame(ResolveTargetEntity::class, $meta['oneToMany']['targetEntity']); - self::assertSame(TargetEntity::class, $meta['oneToOne']['targetEntity']); + self::assertSame(TargetEntity::class, $meta['manyToMany']->targetEntity); + self::assertSame(ResolveTargetEntity::class, $meta['manyToOne']->targetEntity); + self::assertSame(ResolveTargetEntity::class, $meta['oneToMany']->targetEntity); + self::assertSame(TargetEntity::class, $meta['oneToOne']->targetEntity); self::assertSame($cm, $this->factory->getMetadataFor(ResolveTarget::class)); } @@ -82,8 +82,8 @@ public function testAssertTableColumnsAreNotAddedInManyToMany(): void $cm = $this->factory->getMetadataFor(ResolveTargetEntity::class); $meta = $cm->associationMappings['manyToMany']; - self::assertSame(TargetEntity::class, $meta['targetEntity']); - self::assertEquals(['resolvetargetentity_id', 'target_id'], $meta['joinTableColumns']); + self::assertSame(TargetEntity::class, $meta->targetEntity); + self::assertEquals(['resolvetargetentity_id', 'target_id'], $meta->joinTableColumns); } #[CoversNothing] From 535d8698354a1880450f711f0f836072e8b5b3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 8 May 2023 11:46:55 +0200 Subject: [PATCH 272/475] Ignore issue due to Psalm bug --- psalm.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/psalm.xml b/psalm.xml index fc0232ccdb0..dfceafbd703 100644 --- a/psalm.xml +++ b/psalm.xml @@ -207,6 +207,7 @@ + From 749947efe75238f7530f1f5002d3dc06d3999f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 8 May 2023 11:54:56 +0200 Subject: [PATCH 273/475] Clarify things for SA --- lib/Doctrine/ORM/UnitOfWork.php | 1 + lib/Doctrine/ORM/Utility/IdentifierFlattener.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 943aed5be55..347b4da9bdc 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2351,6 +2351,7 @@ public function createEntity(string $className, array $data, array &$hints = []) $associatedId = []; + assert($assoc->isToOneOwningSide()); // TODO: Is this even computed right in all cases of composite keys? foreach ($assoc->targetToSourceKeyColumns as $targetColumn => $srcColumn) { $joinColumnValue = $data[$srcColumn] ?? null; diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index 8ba793986ab..98fca2399ca 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -61,6 +61,7 @@ public function flattenIdentifier(ClassMetadata $class, array $id): array $flatId[$field] = implode(' ', $associatedId); } elseif (isset($class->associationMappings[$field])) { + assert($class->associationMappings[$field]->isToOneOwningSide()); $associatedId = []; foreach ($class->associationMappings[$field]->joinColumns as $joinColumn) { From d4915a8b3de9ca04f8993ee7e3c19f88a2ff9798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 8 May 2023 13:14:49 +0200 Subject: [PATCH 274/475] Ignore unfixable error --- psalm.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/psalm.xml b/psalm.xml index dfceafbd703..ebbd6c6d853 100644 --- a/psalm.xml +++ b/psalm.xml @@ -208,6 +208,7 @@ + From 6ce0cf4a3dd1cb6348c7b16979b01154e2be3f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 8 May 2023 16:40:43 +0200 Subject: [PATCH 275/475] Add assertions based on joinColumns access --- .../ORM/Cache/DefaultCacheFactory.php | 1 + .../ORM/Cache/DefaultEntityHydrator.php | 1 + .../Internal/Hydration/AbstractHydrator.php | 4 ++-- .../ORM/Internal/Hydration/ObjectHydrator.php | 7 ++++-- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 22 +++++++++++++++---- .../ORM/Mapping/DefaultQuoteStrategy.php | 5 ++++- .../Tools/Pagination/CountOutputWalker.php | 5 ++++- .../Pagination/LimitSubqueryOutputWalker.php | 4 +++- lib/Doctrine/ORM/Tools/SchemaTool.php | 6 ++++- psalm-baseline.xml | 11 ---------- 10 files changed, 43 insertions(+), 23 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index b330a3ab27d..84ea490f95f 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -93,6 +93,7 @@ public function buildCachedCollectionPersister( CollectionPersister $persister, AssociationMapping $mapping, ): CachedCollectionPersister { + assert(isset($mapping->cache)); $usage = $mapping->cache['usage']; $region = $this->getRegion($mapping->cache); diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 610fb70ef89..28798bd6c6d 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -75,6 +75,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob foreach ($associationIds as $fieldName => $fieldValue) { if (isset($targetClassMetadata->fieldMappings[$fieldName])) { + assert($owningAssociation->isToOneOwningSide()); $fieldMapping = $targetClassMetadata->fieldMappings[$fieldName]; $data[$owningAssociation->targetToSourceKeyColumns[$fieldMapping->columnName]] = $fieldValue; diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index e167e7bc3f9..edc2b227fd5 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -519,14 +519,14 @@ protected function registerManaged(ClassMetadata $class, object $entity, array $ $id = []; foreach ($class->identifier as $fieldName) { - $id[$fieldName] = isset($class->associationMappings[$fieldName]) + $id[$fieldName] = isset($class->associationMappings[$fieldName]) && $class->associationMappings[$fieldName]->isToOneOwningSide() ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] : $data[$fieldName]; } } else { $fieldName = $class->identifier[0]; $id = [ - $fieldName => isset($class->associationMappings[$fieldName]) + $fieldName => isset($class->associationMappings[$fieldName]) && $class->associationMappings[$fieldName]->isToOneOwningSide() ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] : $data[$fieldName], ]; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 231a83b8b83..55543799db2 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -279,7 +279,7 @@ private function getEntityFromIdentityMap(string $className, array $data): objec array_map( /** @return mixed */ static function (string $fieldName) use ($data, $class) { - return isset($class->associationMappings[$fieldName]) + return isset($class->associationMappings[$fieldName]) && assert($class->associationMappings[$fieldName]->isToOneOwningSide()) ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] : $data[$fieldName]; }, @@ -289,7 +289,10 @@ static function (string $fieldName) use ($data, $class) { return $this->uow->tryGetByIdHash(ltrim($idHash), $class->rootEntityName); } elseif (isset($class->associationMappings[$class->identifier[0]])) { - return $this->uow->tryGetByIdHash($data[$class->associationMappings[$class->identifier[0]]->joinColumns[0]['name']], $class->rootEntityName); + $association = $class->associationMappings[$class->identifier[0]]; + assert($association->isToOneOwningSide()); + + return $this->uow->tryGetByIdHash($data[$association->joinColumns[0]['name']], $class->rootEntityName); } return $this->uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName); diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index fbcfbdd0a11..597cbef24d0 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1524,6 +1524,7 @@ public function getIdentifierColumnNames(): array } // Association defined as Id field + assert($this->associationMappings[$idProperty]->isToOneOwningSide()); $joinColumns = $this->associationMappings[$idProperty]->joinColumns; $assocColumnNames = array_map(static fn (JoinColumnMapping $joinColumn): string => $joinColumn['name'], $joinColumns); @@ -2259,7 +2260,7 @@ public function isAssociationWithSingleJoinColumn(string $fieldName): bool { return isset($this->associationMappings[$fieldName]) && isset($this->associationMappings[$fieldName]->joinColumns[0]) - && ! isset($this->associationMappings[$fieldName]['joinColumns'][1]); + && ! isset($this->associationMappings[$fieldName]->joinColumns[1]); } /** @@ -2273,7 +2274,11 @@ public function getSingleAssociationJoinColumnName(string $fieldName): string throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); } - return $this->associationMappings[$fieldName]->joinColumns[0]['name']; + $assoc = $this->associationMappings[$fieldName]; + + assert($assoc->isToOneOwningSide()); + + return $assoc->joinColumns[0]['name']; } /** @@ -2287,7 +2292,11 @@ public function getSingleAssociationReferencedJoinColumnName(string $fieldName): throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); } - return $this->associationMappings[$fieldName]->joinColumns[0]['referencedColumnName']; + $assoc = $this->associationMappings[$fieldName]; + + assert($assoc->isToOneOwningSide()); + + return $assoc->joinColumns[0]['referencedColumnName']; } /** @@ -2306,6 +2315,7 @@ public function getFieldForColumn(string $columnName): string foreach ($this->associationMappings as $assocName => $mapping) { if ( $this->isAssociationWithSingleJoinColumn($assocName) && + assert($this->associationMappings[$assocName]->isToOneOwningSide()) && $this->associationMappings[$assocName]->joinColumns[0]['name'] === $columnName ) { return $assocName; @@ -2471,7 +2481,11 @@ public function isAssociationInverseSide(string $assocName): bool public function getAssociationMappedByTargetField(string $assocName): string { - return $this->associationMappings[$assocName]->mappedBy; + $assoc = $this->associationMappings[$assocName]; + + assert($assoc instanceof InverseSideMapping); + + return $assoc->mappedBy; } /** diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index 7865dbbcd3a..5e8c7d73f7b 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -9,6 +9,7 @@ use function array_map; use function array_merge; +use function assert; use function is_numeric; use function preg_replace; use function substr; @@ -107,7 +108,9 @@ public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform } // Association defined as Id field - $joinColumns = $class->associationMappings[$fieldName]->joinColumns; + $assoc = $class->associationMappings[$fieldName]; + assert($assoc->isToOneOwningSide()); + $joinColumns = $assoc->joinColumns; $assocQuotedColumnNames = array_map( static fn (JoinColumnMapping $joinColumn) => isset($joinColumn['quoted']) ? $platform->quoteIdentifier($joinColumn['name']) diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index 35b125851d3..acbabe5441b 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -16,6 +16,7 @@ use function array_diff; use function array_keys; +use function assert; use function count; use function implode; use function reset; @@ -95,7 +96,9 @@ public function walkSelectStatement(SelectStatement $selectStatement): string } if (isset($rootClass->associationMappings[$property])) { - $joinColumn = $rootClass->associationMappings[$property]->joinColumns[0]['name']; + $association = $rootClass->associationMappings[$property]; + assert($association->isToOneOwningSide()); + $joinColumn = $association->joinColumns[0]['name']; foreach (array_keys($this->rsm->metaMappings, $joinColumn, true) as $alias) { if ($this->rsm->columnOwnerMap[$alias] === $rootAlias) { diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 2ab51693fd1..8eb623114c2 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -498,7 +498,9 @@ private function getSQLIdentifier(SelectStatement $AST): array } if (isset($rootClass->associationMappings[$property])) { - $joinColumn = $rootClass->associationMappings[$property]->joinColumns[0]['name']; + $association = $rootClass->associationMappings[$property]; + assert($association->isToOneOwningSide()); + $joinColumn = $association->joinColumns[0]['name']; foreach (array_keys($this->rsm->metaMappings, $joinColumn, true) as $alias) { if ($this->rsm->columnOwnerMap[$alias] === $rootAlias) { diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 69f34188018..c805e3df1ac 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -154,7 +154,9 @@ private function getIndexColumns(ClassMetadata $class, array $indexData): array if ($class->hasField($fieldName)) { $columns[] = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); } elseif ($class->hasAssociation($fieldName)) { - foreach ($class->getAssociationMapping($fieldName)->joinColumns as $joinColumn) { + $assoc = $class->getAssociationMapping($fieldName); + assert($assoc->isToOneOwningSide()); + foreach ($assoc->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } } @@ -247,6 +249,7 @@ public function getSchemaFromMetadata(array $classes): Schema if (isset($class->associationMappings[$identifierField]->inherited)) { $idMapping = $class->associationMappings[$identifierField]; + assert($idMapping->isToOneOwningSide()); $targetEntity = current( array_filter( @@ -299,6 +302,7 @@ public function getSchemaFromMetadata(array $classes): Schema $pkColumns[] = $this->quoteStrategy->getColumnName($identifierField, $class, $this->platform); } elseif (isset($class->associationMappings[$identifierField])) { $assoc = $class->associationMappings[$identifierField]; + assert($assoc->isToOneOwningSide()); foreach ($assoc->joinColumns as $joinColumn) { $pkColumns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bf13d239497..ca06037eeee 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -324,12 +324,10 @@ $className $className - $columnNames namespace . '\\' . $className]]> class-string|null - ]]> reflClass]]> @@ -425,14 +423,6 @@ - - - $quotedColumnNames - - - array - - $mapping @@ -720,7 +710,6 @@ getOwner()]]> getOwner()]]> - From 917e0cff39fb8494f2457faa9195378d8db798fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 9 May 2023 19:20:47 +0200 Subject: [PATCH 276/475] Move assertion --- lib/Doctrine/ORM/Query/SqlWalker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 0cc856afc23..4f5bbdd6d66 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1882,11 +1882,11 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $sql .= implode(' AND ', $sqlParts); } else { // many-to-many - assert($assoc->isManyToMany()); $targetClass = $this->em->getClassMetadata($assoc->targetEntity); $owningAssoc = $this->em->getMetadataFactory()->getOwningSide($assoc); - $joinTable = $owningAssoc->joinTable; + assert($owningAssoc->isManyToManyOwningSide()); + $joinTable = $owningAssoc->joinTable; // SQL table aliases $joinTableAlias = $this->getSQLTableAlias($joinTable['name']); From 2987e9956f123b304500df7bfb36193c578f71be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 9 May 2023 19:22:21 +0200 Subject: [PATCH 277/475] Add assertion --- lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php | 1 + lib/Doctrine/ORM/Query/SqlWalker.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 0471428a108..8b09f4dff92 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -46,6 +46,7 @@ public function getSql(SqlWalker $sqlWalker): string $sql .= $quoteStrategy->getTableName($targetClass, $platform) . ' ' . $targetTableAlias . ' WHERE '; $owningAssoc = $targetClass->associationMappings[$assoc->mappedBy]; + assert($owningAssoc->isManyToOne()); $first = true; diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 4f5bbdd6d66..8ae206c4a82 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -910,6 +910,7 @@ public function walkJoinAssociationDeclaration( // The owning side is necessary at this point because only it contains the JoinColumn information. switch (true) { case $assoc->isToOne(): + assert($assoc->isToOneOwningSide()); $conditions = []; foreach ($assoc->joinColumns as $joinColumn) { @@ -1864,7 +1865,8 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $sql .= $this->quoteStrategy->getTableName($targetClass, $this->platform) . ' ' . $targetTableAlias . ' WHERE '; $owningAssoc = $targetClass->associationMappings[$assoc->mappedBy]; - $sqlParts = []; + assert($owningAssoc->isManyToOne()); + $sqlParts = []; foreach ($owningAssoc->targetToSourceKeyColumns as $targetColumn => $sourceColumn) { $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$targetColumn], $class, $this->platform); From ca8ee914675b81da82d9dab99bba300dce2d7966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 12 May 2023 08:30:06 +0200 Subject: [PATCH 278/475] Leverage ClassMetadataFactory::getOwningSide() --- lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 4e26c8ae889..2b1a2fad6f7 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -155,7 +155,7 @@ private function deleteEntityCollection(PersistentCollection $collection): int $columns = []; $parameters = []; - foreach ($targetClass->associationMappings[$mapping->mappedBy]->joinColumns as $joinColumn) { + foreach ($this->em->getMetadataFactory()->getOwningSide($mapping)->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); $parameters[] = $identifier[$sourceClass->getFieldForColumn($joinColumn['referencedColumnName'])]; } From 61f2c4d53b9936d61189f67c1c7f344e92a6b8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 12 May 2023 08:32:09 +0200 Subject: [PATCH 279/475] Allow ClassMetadata::FETCH_EXTRA_LAZY as a value for ClassMetadata->$fetch --- lib/Doctrine/ORM/Mapping/AssociationMapping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index 3e386ac4b1f..3fbeecbc23c 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -27,7 +27,7 @@ abstract class AssociationMapping implements ArrayAccess /** * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. * - * @var ClassMetadata::FETCH_EAGER|ClassMetadata::FETCH_LAZY + * @var ClassMetadata::FETCH_* */ public int|null $fetch = null; From 647712649b74bf56029ff6d2914ecbb0406d76e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 12 May 2023 21:01:45 +0200 Subject: [PATCH 280/475] Add assertions --- lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php | 2 ++ phpstan.neon | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php index 28798bd6c6d..ecb2bfc8ceb 100644 --- a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php +++ b/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php @@ -85,6 +85,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob $targetAssoc = $targetClassMetadata->associationMappings[$fieldName]; + assert($assoc->isToOneOwningSide()); foreach ($assoc->targetToSourceKeyColumns as $referencedColumn => $localColumn) { if (isset($targetAssoc->sourceToTargetKeyColumns[$referencedColumn])) { $data[$localColumn] = $fieldValue; @@ -111,6 +112,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, ob // @TODO - fix it ! // handle UnitOfWork#createEntity hash generation if (! is_array($targetId)) { + assert($assoc->isToOneOwningSide()); $data[reset($assoc->joinColumnFieldNames)] = $targetId; $targetEntity = $this->em->getClassMetadata($assoc->targetEntity); diff --git a/phpstan.neon b/phpstan.neon index 14912473afe..64ba5330a14 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -31,6 +31,8 @@ parameters: - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - lib/Doctrine/ORM/PersistentCollection.php + - lib/Doctrine/ORM/Tools/SchemaTool.php + - message: "#^Call to an undefined method .*Mapping\\:\\:(order|index)By\\(\\)\\.#" paths: @@ -40,7 +42,7 @@ parameters: - lib/Doctrine/ORM/Query/SqlWalker.php - - message: '#^.*Doctrine\\ORM\\Mapping\\AssociationMapping&Doctrine\\ORM\\Mapping\\ManyToManyAssociationMapping, Doctrine\\ORM\\Mapping\\AssociationMapping given\.#' + message: '#^.*Doctrine\\ORM\\Mapping\\(Association|OwningSide)Mapping given\.#' paths: - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -52,5 +54,4 @@ parameters: - message: '#^.*QuoteStrategy::getJoinTableName\(\) expects.*$#' paths: - - lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php From bbc56aaec6dccedc0fc4502a9606fd350f893c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 22 May 2023 23:02:37 +0200 Subject: [PATCH 281/475] Ignore issue about collections --- psalm-baseline.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ca06037eeee..3313f7999a5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -658,7 +658,11 @@ ]]> - + + fetch === ClassMetadata::FETCH_EXTRA_LAZY + ? new LazyCriteriaCollection($persister, $criteria) + : new ArrayCollection($persister->loadCriteria($criteria))]]> + ]]> From 8a762f04f136838911f2b0783c1a0db2728ce771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 23 May 2023 13:13:39 +0200 Subject: [PATCH 282/475] Manually fix remaining issues --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 2 +- .../Mapping/Driver/ReflectionBasedDriver.php | 12 ++--- .../ORM/Mapping/ToOneOwningSideMapping.php | 2 +- .../Entity/JoinedSubclassPersister.php | 2 +- lib/Doctrine/ORM/Query/SqlWalker.php | 4 +- lib/Doctrine/ORM/Utility/PersisterHelper.php | 2 +- .../ORM/Functional/DatabaseDriverTest.php | 3 +- .../Functional/ExtraLazyCollectionTest.php | 48 +++++++++---------- ...nyToManySelfReferentialAssociationTest.php | 4 +- ...anyToManyUnidirectionalAssociationTest.php | 4 +- ...neToManySelfReferentialAssociationTest.php | 4 +- .../OneToOneBidirectionalAssociationTest.php | 8 ++-- ...OneToOneSelfReferentialAssociationTest.php | 4 +- .../OneToOneUnidirectionalAssociationTest.php | 4 +- .../Tests/ORM/Functional/SQLFilterTest.php | 12 ++--- ...econdLevelCacheExtraLazyCollectionTest.php | 8 ++-- .../ORM/Functional/Ticket/DDC1301Test.php | 16 +++---- .../ORM/Hydration/ObjectHydratorTest.php | 8 ++-- .../Tests/ORM/Mapping/ClassMetadataTest.php | 10 ++-- .../ORM/Mapping/MappingDriverTestCase.php | 4 +- .../ORM/Mapping/XmlMappingDriverTest.php | 5 +- 21 files changed, 82 insertions(+), 84 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 597cbef24d0..3ce81698671 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -963,7 +963,7 @@ public function enableCache(array $cache): void /** @psalm-param array{usage?: int, region?: string} $cache */ public function enableAssociationCache(string $fieldName, array $cache): void { - $this->associationMappings[$fieldName]['cache'] = $this->getAssociationCacheDefaults($fieldName, $cache); + $this->associationMappings[$fieldName]->cache = $this->getAssociationCacheDefaults($fieldName, $cache); } /** diff --git a/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php b/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php index e42aab7b9cc..6ac89026bd3 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php @@ -35,20 +35,20 @@ private function isRepeatedPropertyDeclaration(ReflectionProperty $property, Cla $declaringClass = $property->getDeclaringClass()->getName(); if ( - isset($metadata->fieldMappings[$property->name]['declared']) - && $metadata->fieldMappings[$property->name]['declared'] === $declaringClass + isset($metadata->fieldMappings[$property->name]->declared) + && $metadata->fieldMappings[$property->name]->declared === $declaringClass ) { return true; } if ( - isset($metadata->associationMappings[$property->name]['declared']) - && $metadata->associationMappings[$property->name]['declared'] === $declaringClass + isset($metadata->associationMappings[$property->name]->declared) + && $metadata->associationMappings[$property->name]->declared === $declaringClass ) { return true; } - return isset($metadata->embeddedClasses[$property->name]['declared']) - && $metadata->embeddedClasses[$property->name]['declared'] === $declaringClass; + return isset($metadata->embeddedClasses[$property->name]->declared) + && $metadata->embeddedClasses[$property->name]->declared === $declaringClass; } } diff --git a/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php index 5c39abda67c..b77e8e61ee5 100644 --- a/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php @@ -81,7 +81,7 @@ public static function fromMappingArrayAndName( // Apply default join column $mapping->joinColumns = [ JoinColumnMapping::fromMappingArray([ - 'name' => $namingStrategy->joinColumnName($mapping['fieldName'], $name), + 'name' => $namingStrategy->joinColumnName($mapping->fieldName, $name), 'referencedColumnName' => $namingStrategy->referenceColumnName(), ]), ]; diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index cb7bf530160..9d7151fd1ef 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -76,7 +76,7 @@ public function getOwningTable(string $fieldName): string $cm = match (true) { isset($this->class->associationMappings[$fieldName]->inherited) - => $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']), + => $this->em->getClassMetadata($this->class->associationMappings[$fieldName]->inherited), isset($this->class->fieldMappings[$fieldName]->inherited) => $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]->inherited), default => $this->class, diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 8ae206c4a82..4063307a11d 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -347,7 +347,7 @@ private function generateOrderedCollectionOrderByItems(): string assert(isset($qComp['metadata'])); $persister = $this->em->getUnitOfWork()->getEntityPersister($qComp['metadata']->name); - foreach ($qComp['relation']['orderBy'] as $fieldName => $orientation) { + foreach ($qComp['relation']->orderBy as $fieldName => $orientation) { $columnName = $this->quoteStrategy->getColumnName($fieldName, $qComp['metadata'], $this->platform); $tableName = $qComp['metadata']->isInheritanceTypeJoined() ? $persister->getOwningTable($fieldName) @@ -593,7 +593,7 @@ public function walkPathExpression(AST\PathExpression $pathExpr): string $class = $this->getMetadataForDqlAlias($dqlAlias); if (isset($class->associationMappings[$fieldName]->inherited)) { - $class = $this->em->getClassMetadata($class->associationMappings[$fieldName]['inherited']); + $class = $this->em->getClassMetadata($class->associationMappings[$fieldName]->inherited); } $assoc = $class->associationMappings[$fieldName]; diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index 16699a7e0d5..bad942b6acd 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -49,7 +49,7 @@ public static function getTypeOfField(string $fieldName, ClassMetadata $class, E $types = []; $targetClass = $em->getClassMetadata($assoc->targetEntity); - foreach ($joinData['joinColumns'] as $joinColumn) { + foreach ($joinData->joinColumns as $joinColumn) { $types[] = self::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $em); } diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index 349ba14c69d..f2ef9e58f62 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -9,7 +9,6 @@ use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Table; -use Doctrine\ORM\Mapping\ClassMetadata; use PHPUnit\Framework\Attributes\Group; use function array_change_key_case; @@ -105,7 +104,7 @@ public function testLoadMetadataWithForeignKeyFromDatabase(): void $bazMetadata->associationMappings = array_change_key_case($bazMetadata->associationMappings, CASE_LOWER); self::assertArrayHasKey('bar', $bazMetadata->associationMappings); - self::assertEquals(ClassMetadata::MANY_TO_ONE, $bazMetadata->associationMappings['bar']['type']); + self::assertTrue($bazMetadata->associationMappings['bar']->isManyToOne()); } public function testDetectManyToManyTables(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index 9c4ec5670bd..a092f6555cd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -54,25 +54,25 @@ protected function setUp(): void parent::setUp(); - $class = $this->_em->getClassMetadata(CmsUser::class); - $class->associationMappings['groups']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; - $class->associationMappings['groups']['indexBy'] = 'name'; - $class->associationMappings['articles']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; - $class->associationMappings['articles']['indexBy'] = 'topic'; - $class->associationMappings['phonenumbers']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; - $class->associationMappings['phonenumbers']['indexBy'] = 'phonenumber'; + $class = $this->_em->getClassMetadata(CmsUser::class); + $class->associationMappings['groups']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; + $class->associationMappings['groups']->indexBy = 'name'; + $class->associationMappings['articles']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; + $class->associationMappings['articles']->indexBy = 'topic'; + $class->associationMappings['phonenumbers']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; + $class->associationMappings['phonenumbers']->indexBy = 'phonenumber'; foreach (['phonenumbers', 'articles', 'users'] as $field) { if (isset($class->associationMappings[$field]->cache)) { - $this->previousCacheConfig[$field] = $class->associationMappings[$field]['cache']; + $this->previousCacheConfig[$field] = $class->associationMappings[$field]->cache; } unset($class->associationMappings[$field]->cache); } - $class = $this->_em->getClassMetadata(CmsGroup::class); - $class->associationMappings['users']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; - $class->associationMappings['users']['indexBy'] = 'username'; + $class = $this->_em->getClassMetadata(CmsGroup::class); + $class->associationMappings['users']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; + $class->associationMappings['users']->indexBy = 'username'; $this->loadFixture(); } @@ -81,14 +81,14 @@ public function tearDown(): void { parent::tearDown(); - $class = $this->_em->getClassMetadata(CmsUser::class); - $class->associationMappings['groups']['fetch'] = ClassMetadata::FETCH_LAZY; - $class->associationMappings['articles']['fetch'] = ClassMetadata::FETCH_LAZY; - $class->associationMappings['phonenumbers']['fetch'] = ClassMetadata::FETCH_LAZY; + $class = $this->_em->getClassMetadata(CmsUser::class); + $class->associationMappings['groups']->fetch = ClassMetadata::FETCH_LAZY; + $class->associationMappings['articles']->fetch = ClassMetadata::FETCH_LAZY; + $class->associationMappings['phonenumbers']->fetch = ClassMetadata::FETCH_LAZY; foreach (['phonenumbers', 'articles', 'users'] as $field) { if (isset($this->previousCacheConfig[$field])) { - $class->associationMappings[$field]['cache'] = $this->previousCacheConfig[$field]; + $class->associationMappings[$field]->cache = $this->previousCacheConfig[$field]; unset($this->previousCacheConfig[$field]); } } @@ -97,8 +97,8 @@ public function tearDown(): void unset($class->associationMappings['articles']->indexBy); unset($class->associationMappings['phonenumbers']->indexBy); - $class = $this->_em->getClassMetadata(CmsGroup::class); - $class->associationMappings['users']['fetch'] = ClassMetadata::FETCH_LAZY; + $class = $this->_em->getClassMetadata(CmsGroup::class); + $class->associationMappings['users']->fetch = ClassMetadata::FETCH_LAZY; unset($class->associationMappings['users']->indexBy); } @@ -586,8 +586,8 @@ public function testContainsKeyIndexByOneToMany(): void public function testContainsKeyIndexByOneToManyJoinedInheritance(): void { - $class = $this->_em->getClassMetadata(DDC2504OtherClass::class); - $class->associationMappings['childClasses']['indexBy'] = 'id'; + $class = $this->_em->getClassMetadata(DDC2504OtherClass::class); + $class->associationMappings['childClasses']->indexBy = 'id'; $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); @@ -631,8 +631,8 @@ public function testContainsKeyIndexByManyToManyNonOwning(): void public function testContainsKeyIndexByWithPkManyToMany(): void { - $class = $this->_em->getClassMetadata(CmsUser::class); - $class->associationMappings['groups']['indexBy'] = 'id'; + $class = $this->_em->getClassMetadata(CmsUser::class); + $class->associationMappings['groups']->indexBy = 'id'; $user = $this->_em->find(CmsUser::class, $this->userId2); @@ -647,8 +647,8 @@ public function testContainsKeyIndexByWithPkManyToMany(): void public function testContainsKeyIndexByWithPkManyToManyNonOwning(): void { - $class = $this->_em->getClassMetadata(CmsGroup::class); - $class->associationMappings['users']['indexBy'] = 'id'; + $class = $this->_em->getClassMetadata(CmsGroup::class); + $class->associationMappings['users']->indexBy = 'id'; $group = $this->_em->find(CmsGroup::class, $this->groupId); diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php index bb96b22ecee..2717fb66ada 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php @@ -92,8 +92,8 @@ public function testLazyLoadsOwningSide(): void { $this->createLoadingFixture(); - $metadata = $this->_em->getClassMetadata(ECommerceProduct::class); - $metadata->associationMappings['related']['fetch'] = ClassMetadata::FETCH_LAZY; + $metadata = $this->_em->getClassMetadata(ECommerceProduct::class); + $metadata->associationMappings['related']->fetch = ClassMetadata::FETCH_LAZY; $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); $products = $query->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php index c36d0bcf4cc..6f210a7c815 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php @@ -89,8 +89,8 @@ public function testEagerLoad(): void public function testLazyLoadsCollection(): void { $this->createFixture(); - $metadata = $this->_em->getClassMetadata(ECommerceCart::class); - $metadata->associationMappings['products']['fetch'] = ClassMetadata::FETCH_LAZY; + $metadata = $this->_em->getClassMetadata(ECommerceCart::class); + $metadata->associationMappings['products']->fetch = ClassMetadata::FETCH_LAZY; $query = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\ECommerce\ECommerceCart c'); $result = $query->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php index 58d2c564396..66983656506 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php @@ -98,8 +98,8 @@ public function testEagerLoadsOneToManyAssociation(): void public function testLazyLoadsOneToManyAssociation(): void { $this->createFixture(); - $metadata = $this->_em->getClassMetadata(ECommerceCategory::class); - $metadata->associationMappings['children']['fetch'] = ClassMetadata::FETCH_LAZY; + $metadata = $this->_em->getClassMetadata(ECommerceCategory::class); + $metadata->associationMappings['children']->fetch = ClassMetadata::FETCH_LAZY; $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCategory c order by c.id asc'); $result = $query->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php index c6049093bd0..74cc08c5a39 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php @@ -75,8 +75,8 @@ public function testEagerLoad(): void public function testLazyLoadsObjectsOnTheOwningSide(): void { $this->createFixture(); - $metadata = $this->_em->getClassMetadata(ECommerceCart::class); - $metadata->associationMappings['customer']['fetch'] = ClassMetadata::FETCH_LAZY; + $metadata = $this->_em->getClassMetadata(ECommerceCart::class); + $metadata->associationMappings['customer']->fetch = ClassMetadata::FETCH_LAZY; $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCart c'); $result = $query->getResult(); @@ -89,8 +89,8 @@ public function testLazyLoadsObjectsOnTheOwningSide(): void public function testInverseSideIsNeverLazy(): void { $this->createFixture(); - $metadata = $this->_em->getClassMetadata(ECommerceCustomer::class); - $metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_EAGER; + $metadata = $this->_em->getClassMetadata(ECommerceCustomer::class); + $metadata->associationMappings['mentor']->fetch = ClassMetadata::FETCH_EAGER; $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c'); $result = $query->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index 3f5505459de..2cc0c153032 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -84,8 +84,8 @@ public function testLazyLoadsAssociation(): void { $this->createFixture(); - $metadata = $this->_em->getClassMetadata(ECommerceCustomer::class); - $metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_LAZY; + $metadata = $this->_em->getClassMetadata(ECommerceCustomer::class); + $metadata->associationMappings['mentor']->fetch = ClassMetadata::FETCH_LAZY; $query = $this->_em->createQuery("select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c where c.name='Luke Skywalker'"); $result = $query->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index 261a03acd38..b2baaaa254e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -68,8 +68,8 @@ public function testEagerLoad(): void public function testLazyLoadsObjects(): void { $this->createFixture(); - $metadata = $this->_em->getClassMetadata(ECommerceProduct::class); - $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; + $metadata = $this->_em->getClassMetadata(ECommerceProduct::class); + $metadata->associationMappings['shipping']->fetch = ClassMetadata::FETCH_LAZY; $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); $result = $query->getResult(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index d4230df0234..3f12f4db069 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -69,9 +69,9 @@ public function tearDown(): void { parent::tearDown(); - $class = $this->_em->getClassMetadata(CmsUser::class); - $class->associationMappings['groups']['fetch'] = ClassMetadata::FETCH_LAZY; - $class->associationMappings['articles']['fetch'] = ClassMetadata::FETCH_LAZY; + $class = $this->_em->getClassMetadata(CmsUser::class); + $class->associationMappings['groups']->fetch = ClassMetadata::FETCH_LAZY; + $class->associationMappings['articles']->fetch = ClassMetadata::FETCH_LAZY; } public function testConfigureFilter(): void @@ -553,9 +553,9 @@ public function testWhereOrFilter(): void private function loadLazyFixtureData(): void { - $class = $this->_em->getClassMetadata(CmsUser::class); - $class->associationMappings['articles']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; - $class->associationMappings['groups']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; + $class = $this->_em->getClassMetadata(CmsUser::class); + $class->associationMappings['articles']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; + $class->associationMappings['groups']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; $this->loadFixtureData(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php index 54502e795d1..97fa3640614 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php @@ -20,8 +20,8 @@ protected function setUp(): void $sourceEntity = $this->_em->getClassMetadata(Travel::class); $targetEntity = $this->_em->getClassMetadata(City::class); - $sourceEntity->associationMappings['visitedCities']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; - $targetEntity->associationMappings['travels']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; + $sourceEntity->associationMappings['visitedCities']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; + $targetEntity->associationMappings['travels']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; } public function tearDown(): void @@ -31,8 +31,8 @@ public function tearDown(): void $sourceEntity = $this->_em->getClassMetadata(Travel::class); $targetEntity = $this->_em->getClassMetadata(City::class); - $sourceEntity->associationMappings['visitedCities']['fetch'] = ClassMetadata::FETCH_LAZY; - $targetEntity->associationMappings['travels']['fetch'] = ClassMetadata::FETCH_LAZY; + $sourceEntity->associationMappings['visitedCities']->fetch = ClassMetadata::FETCH_LAZY; + $targetEntity->associationMappings['travels']->fetch = ClassMetadata::FETCH_LAZY; } public function testCacheCountAfterAddThenFlush(): void diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php index d5479c9d3d1..746250e2acd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php @@ -24,10 +24,10 @@ protected function setUp(): void parent::setUp(); - $class = $this->_em->getClassMetadata(LegacyUser::class); - $class->associationMappings['articles']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; - $class->associationMappings['references']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; - $class->associationMappings['cars']['fetch'] = ClassMetadata::FETCH_EXTRA_LAZY; + $class = $this->_em->getClassMetadata(LegacyUser::class); + $class->associationMappings['articles']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; + $class->associationMappings['references']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; + $class->associationMappings['cars']->fetch = ClassMetadata::FETCH_EXTRA_LAZY; $this->loadFixture(); } @@ -36,10 +36,10 @@ public function tearDown(): void { parent::tearDown(); - $class = $this->_em->getClassMetadata(LegacyUser::class); - $class->associationMappings['articles']['fetch'] = ClassMetadata::FETCH_LAZY; - $class->associationMappings['references']['fetch'] = ClassMetadata::FETCH_LAZY; - $class->associationMappings['cars']['fetch'] = ClassMetadata::FETCH_LAZY; + $class = $this->_em->getClassMetadata(LegacyUser::class); + $class->associationMappings['articles']->fetch = ClassMetadata::FETCH_LAZY; + $class->associationMappings['references']->fetch = ClassMetadata::FETCH_LAZY; + $class->associationMappings['cars']->fetch = ClassMetadata::FETCH_LAZY; } public function testCountNotInitializesLegacyCollection(): void diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index e2d803cd48a..d78bbf14894 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -1038,8 +1038,8 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void $this->entityManager->setProxyFactory($proxyFactory); // configuring lazy loading - $metadata = $this->entityManager->getClassMetadata(ECommerceProduct::class); - $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; + $metadata = $this->entityManager->getClassMetadata(ECommerceProduct::class); + $metadata->associationMappings['shipping']->fetch = ClassMetadata::FETCH_LAZY; $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); @@ -1087,8 +1087,8 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE $this->entityManager->setProxyFactory($proxyFactory); // configuring lazy loading - $metadata = $this->entityManager->getClassMetadata(ECommerceProduct::class); - $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; + $metadata = $this->entityManager->getClassMetadata(ECommerceProduct::class); + $metadata->associationMappings['shipping']->fetch = ClassMetadata::FETCH_LAZY; $stmt = $this->createResultMock($resultSet); $hydrator = new ObjectHydrator($this->entityManager); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index efe6fcbf936..bfb8f81be10 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -109,12 +109,12 @@ public function testClassMetadataInstanceSerialization(): void 'type' => 'integer', 'fieldName' => 'disc', ]), $cm->discriminatorColumn); - self::assertTrue($cm->associationMappings['phonenumbers']['type'] === ClassMetadata::ONE_TO_ONE); + self::assertTrue($cm->associationMappings['phonenumbers']->isOneToOne()); self::assertEquals(1, count($cm->associationMappings)); $oneOneMapping = $cm->getAssociationMapping('phonenumbers'); - self::assertTrue($oneOneMapping['fetch'] === ClassMetadata::FETCH_LAZY); - self::assertEquals('phonenumbers', $oneOneMapping['fieldName']); - self::assertEquals(CmsAddress::class, $oneOneMapping['targetEntity']); + self::assertTrue($oneOneMapping->fetch === ClassMetadata::FETCH_LAZY); + self::assertEquals('phonenumbers', $oneOneMapping->fieldName); + self::assertEquals(CmsAddress::class, $oneOneMapping->targetEntity); self::assertTrue($cm->isReadOnly); self::assertTrue($cm->requiresFetchAfterChange); } @@ -289,7 +289,7 @@ public function testSerializeManyToManyJoinTableCascade(): void $assoc = $cm->associationMappings['groups']; $assoc = unserialize(serialize($assoc)); - self::assertTrue($assoc['isOnDeleteCascade']); + self::assertTrue($assoc->isOnDeleteCascade); } #[TestGroup('DDC-115')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 1cb667ca4b1..78260e84928 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -840,14 +840,14 @@ public function testSecondLevelCacheMapping(): void self::assertEquals('doctrine_tests_models_cache_city', $class->cache['region']); self::assertArrayHasKey('state', $class->associationMappings); - self::assertArrayHasKey('cache', $class->associationMappings['state']); + self::assertNotNull($class->associationMappings['state']->cache); self::assertArrayHasKey('usage', $class->associationMappings['state']->cache); self::assertArrayHasKey('region', $class->associationMappings['state']->cache); self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['state']->cache['usage']); self::assertEquals('doctrine_tests_models_cache_city__state', $class->associationMappings['state']->cache['region']); self::assertArrayHasKey('attractions', $class->associationMappings); - self::assertArrayHasKey('cache', $class->associationMappings['attractions']); + self::assertNotNull($class->associationMappings['attractions']->cache); self::assertArrayHasKey('usage', $class->associationMappings['attractions']->cache); self::assertArrayHasKey('region', $class->associationMappings['attractions']->cache); self::assertEquals(ClassMetadata::CACHE_USAGE_READ_ONLY, $class->associationMappings['attractions']->cache['usage']); diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 10ea6c9705b..6d439ca658c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -89,7 +89,6 @@ public function testIdentifierWithAssociationKey(): void self::assertEquals(['language', 'article'], $class->identifier); self::assertArrayHasKey('article', $class->associationMappings); - self::assertArrayHasKey('id', $class->associationMappings['article']); self::assertTrue($class->associationMappings['article']->id); } @@ -257,7 +256,7 @@ public function testOneToManyDefaultOrderByAsc(): void self::assertEquals( Criteria::ASC, - $class->getMetadataValue('associationMappings')['tags']['orderBy']['position'], + $class->getMetadataValue('associationMappings')['tags']->orderBy['position'], ); } @@ -271,7 +270,7 @@ public function testManyToManyDefaultOrderByAsc(): void self::assertEquals( Criteria::ASC, - $class->getMetadataValue('associationMappings')['tags']['orderBy']['position'], + $class->getMetadataValue('associationMappings')['tags']->orderBy['position'], ); } From 2b038587172ae7c60aaf37312563764bcaa8ba4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 25 May 2023 17:27:17 +0200 Subject: [PATCH 283/475] Declare options property This must have been lost when merging up d7d6b9d2c7fcfc16a6a706c78161b441aed39ffb --- lib/Doctrine/ORM/Mapping/JoinTableMapping.php | 7 +++++-- lib/Doctrine/ORM/Tools/SchemaTool.php | 6 ++---- tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php index 659b15fcbb7..68d64bedbf2 100644 --- a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php +++ b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php @@ -22,6 +22,9 @@ final class JoinTableMapping implements ArrayAccess /** @var list */ public array $inverseJoinColumns = []; + /** @var array */ + public array $options = []; + public string|null $schema = null; public string|null $name = null; @@ -40,7 +43,7 @@ public static function fromMappingArray(array $mappingArray): self { $mapping = new self(); - foreach (['name', 'quoted', 'schema'] as $key) { + foreach (['name', 'quoted', 'schema', 'options'] as $key) { if (isset($mappingArray[$key])) { $mapping[$key] = $mappingArray[$key]; } @@ -92,7 +95,7 @@ public function __sleep(): array { $serialized = []; - foreach (['joinColumns', 'inverseJoinColumns', 'name', 'schema'] as $stringOrArrayKey) { + foreach (['joinColumns', 'inverseJoinColumns', 'name', 'schema', 'options'] as $stringOrArrayKey) { if ($this->$stringOrArrayKey !== null) { $serialized[] = $stringOrArrayKey; } diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index c805e3df1ac..143f63ccbd6 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -563,10 +563,8 @@ private function gatherRelationsSql( $this->quoteStrategy->getJoinTableName($mapping, $foreignClass, $this->platform), ); - if (isset($joinTable['options'])) { - foreach ($joinTable['options'] as $key => $val) { - $theJoinTable->addOption($key, $val); - } + foreach ($joinTable->options as $key => $val) { + $theJoinTable->addOption($key, $val); } $primaryKeyColumns = []; diff --git a/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php index 846605cf9fd..c3c16d7c447 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php @@ -23,6 +23,7 @@ public function testItSurvivesSerialization(): void $mapping->inverseJoinColumns = [new JoinColumnMapping('id')]; $mapping->schema = 'foo'; $mapping->name = 'bar'; + $mapping->options = ['foo' => 'bar']; $resurrectedMapping = unserialize(serialize($mapping)); assert($resurrectedMapping instanceof JoinTableMapping); @@ -32,5 +33,6 @@ public function testItSurvivesSerialization(): void self::assertCount(1, $resurrectedMapping->inverseJoinColumns); self::assertSame('foo', $resurrectedMapping->schema); self::assertSame('bar', $resurrectedMapping->name); + self::assertSame(['foo' => 'bar'], $resurrectedMapping->options); } } From 8a6dbb4ae201cd18a6fe0e4bee1a26edd80e7260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 26 May 2023 00:04:35 +0200 Subject: [PATCH 284/475] Make the join table name mandatory It does not seem to ever be empty --- lib/Doctrine/ORM/Mapping/JoinTableMapping.php | 10 ++++++---- .../ORM/Mapping/ManyToManyOwningSideMapping.php | 15 +++++++-------- psalm-baseline.xml | 6 ------ .../Tests/ORM/Mapping/JoinTableMappingTest.php | 3 +-- .../Mapping/ManyToManyOwningSideMappingTest.php | 3 +-- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php index 68d64bedbf2..a27dce84a8d 100644 --- a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php +++ b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php @@ -27,12 +27,14 @@ final class JoinTableMapping implements ArrayAccess public string|null $schema = null; - public string|null $name = null; + public function __construct(public string $name) + { + } /** * @param mixed[] $mappingArray * @psalm-param array{ - * name?: string, + * name: string, * quoted?: bool, * joinColumns?: mixed[], * inverseJoinColumns?: mixed[], @@ -41,9 +43,9 @@ final class JoinTableMapping implements ArrayAccess */ public static function fromMappingArray(array $mappingArray): self { - $mapping = new self(); + $mapping = new self($mappingArray['name']); - foreach (['name', 'quoted', 'schema', 'options'] as $key) { + foreach (['quoted', 'schema', 'options'] as $key) { if (isset($mappingArray[$key])) { $mapping[$key] = $mappingArray[$key]; } diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php index b761185e0ae..4a4f3e0112e 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php @@ -47,18 +47,17 @@ public function toArray(): array */ public static function fromMappingArrayAndNamingStrategy(array $mappingArray, NamingStrategy $namingStrategy): self { - $mapping = parent::fromMappingArray($mappingArray); - // owning side MUST have a join table - if (! isset($mapping->joinTable->name)) { - $mapping->joinTable ??= new JoinTableMapping(); - $mapping->joinTable->name = $namingStrategy->joinTableName( - $mapping->sourceEntity, - $mapping->targetEntity, - $mapping->fieldName, + if (! isset($mappingArray['joinTable']['name'])) { + $mappingArray['joinTable']['name'] = $namingStrategy->joinTableName( + $mappingArray['sourceEntity'], + $mappingArray['targetEntity'], + $mappingArray['fieldName'], ); } + $mapping = parent::fromMappingArray($mappingArray); + $selfReferencingEntityWithoutJoinColumns = $mapping->sourceEntity === $mapping->targetEntity && $mapping->joinTable->joinColumns === [] && $mapping->joinTable->inverseJoinColumns === []; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 3313f7999a5..5e05a6738c0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -582,12 +582,6 @@ $joinTable - - joinTable]]> - - - new JoinTableMapping() - diff --git a/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php index c3c16d7c447..8077c15f3e0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php @@ -16,13 +16,12 @@ final class JoinTableMappingTest extends TestCase { public function testItSurvivesSerialization(): void { - $mapping = new JoinTableMapping(); + $mapping = new JoinTableMapping('bar'); $mapping->quoted = true; $mapping->joinColumns = [new JoinColumnMapping('id')]; $mapping->inverseJoinColumns = [new JoinColumnMapping('id')]; $mapping->schema = 'foo'; - $mapping->name = 'bar'; $mapping->options = ['foo' => 'bar']; $resurrectedMapping = unserialize(serialize($mapping)); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php index 4c500decfab..cc2e2e74cab 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php @@ -22,8 +22,7 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->joinTable = new JoinTableMapping(); - $mapping->joinTable->name = 'bar'; + $mapping->joinTable = new JoinTableMapping('bar'); $mapping->joinTableColumns = ['foo', 'bar']; $mapping->relationToSourceKeyColumns = ['foo' => 'bar']; $mapping->relationToTargetKeyColumns = ['bar' => 'baz']; From ee629349110da83f5aabf504a0d5b3e8d08898fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 26 May 2023 18:54:17 +0200 Subject: [PATCH 285/475] Make the join column name mandatory --- .../ORM/Mapping/JoinColumnMapping.php | 4 +-- .../Mapping/ManyToManyOwningSideMapping.php | 32 +++++++++++++------ .../ORM/Mapping/ToOneOwningSideMapping.php | 12 ++++--- .../ORM/Mapping/JoinColumnMappingTest.php | 3 +- .../ORM/Mapping/JoinTableMappingTest.php | 4 +-- .../ManyToOneAssociationMappingTest.php | 2 +- .../Mapping/OneToOneOwningSideMappingTest.php | 2 +- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/JoinColumnMapping.php b/lib/Doctrine/ORM/Mapping/JoinColumnMapping.php index 37ea4728b61..bc469bb6494 100644 --- a/lib/Doctrine/ORM/Mapping/JoinColumnMapping.php +++ b/lib/Doctrine/ORM/Mapping/JoinColumnMapping.php @@ -13,7 +13,6 @@ final class JoinColumnMapping implements ArrayAccess { use ArrayAccessImplementation; - public string|null $name = null; public bool|null $unique = null; public bool|null $quoted = null; public string|null $fieldName = null; @@ -25,6 +24,7 @@ final class JoinColumnMapping implements ArrayAccess public array|null $options = null; public function __construct( + public string $name, public string $referencedColumnName, ) { } @@ -35,7 +35,7 @@ public function __construct( */ public static function fromMappingArray(array $mappingArray): self { - $mapping = new self($mappingArray['referencedColumnName']); + $mapping = new self($mappingArray['name'], $mappingArray['referencedColumnName']); foreach ($mappingArray as $key => $value) { if (property_exists($mapping, $key) && $value !== null) { $mapping->$key = $value; diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php index 4a4f3e0112e..c7a0eb4ad58 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php @@ -47,8 +47,30 @@ public function toArray(): array */ public static function fromMappingArrayAndNamingStrategy(array $mappingArray, NamingStrategy $namingStrategy): self { + if (isset($mappingArray['joinTable']['joinColumns'])) { + foreach ($mappingArray['joinTable']['joinColumns'] as $key => $joinColumn) { + if (empty($joinColumn['name'])) { + $mappingArray['joinTable']['joinColumns'][$key]['name'] = $namingStrategy->joinKeyColumnName( + $mappingArray['sourceEntity'], + $joinColumn['referencedColumnName'] ?? null, + ); + } + } + } + + if (isset($mappingArray['joinTable']['inverseJoinColumns'])) { + foreach ($mappingArray['joinTable']['inverseJoinColumns'] as $key => $joinColumn) { + if (empty($joinColumn['name'])) { + $mappingArray['joinTable']['inverseJoinColumns'][$key]['name'] = $namingStrategy->joinKeyColumnName( + $mappingArray['targetEntity'], + $joinColumn['referencedColumnName'] ?? null, + ); + } + } + } + // owning side MUST have a join table - if (! isset($mappingArray['joinTable']['name'])) { + if (! isset($mappingArray['joinTable']) || ! isset($mappingArray['joinTable']['name'])) { $mappingArray['joinTable']['name'] = $namingStrategy->joinTableName( $mappingArray['sourceEntity'], $mappingArray['targetEntity'], @@ -85,10 +107,6 @@ public static function fromMappingArrayAndNamingStrategy(array $mappingArray, Na $mapping->joinTableColumns = []; foreach ($mapping->joinTable->joinColumns as $joinColumn) { - if (empty($joinColumn->name)) { - $joinColumn->name = $namingStrategy->joinKeyColumnName($mapping->sourceEntity, $joinColumn->referencedColumnName); - } - if (empty($joinColumn->referencedColumnName)) { $joinColumn->referencedColumnName = $namingStrategy->referenceColumnName(); } @@ -112,10 +130,6 @@ public static function fromMappingArrayAndNamingStrategy(array $mappingArray, Na } foreach ($mapping->joinTable->inverseJoinColumns as $inverseJoinColumn) { - if (empty($inverseJoinColumn->name)) { - $inverseJoinColumn->name = $namingStrategy->joinKeyColumnName($mapping->targetEntity, $inverseJoinColumn->referencedColumnName); - } - if (empty($inverseJoinColumn->referencedColumnName)) { $inverseJoinColumn->referencedColumnName = $namingStrategy->referenceColumnName(); } diff --git a/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php b/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php index b77e8e61ee5..d28074bb03e 100644 --- a/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php +++ b/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php @@ -74,6 +74,14 @@ public static function fromMappingArrayAndName( array|null $table, bool $isInheritanceTypeSingleTable, ): static { + if (isset($mappingArray['joinColumns'])) { + foreach ($mappingArray['joinColumns'] as $index => $joinColumn) { + if (empty($joinColumn['name'])) { + $mappingArray['joinColumns'][$index]['name'] = $namingStrategy->joinColumnName($mappingArray['fieldName'], $name); + } + } + } + $mapping = static::fromMappingArray($mappingArray); assert($mapping->isToOneOwningSide()); @@ -100,10 +108,6 @@ public static function fromMappingArrayAndName( } } - if (empty($joinColumn->name)) { - $joinColumn->name = $namingStrategy->joinColumnName($mapping->fieldName, $name); - } - if (empty($joinColumn->referencedColumnName)) { $joinColumn->referencedColumnName = $namingStrategy->referenceColumnName(); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php index e79d1b44be5..b5459db7f76 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php @@ -15,9 +15,8 @@ final class JoinColumnMappingTest extends TestCase { public function testItSurvivesSerialization(): void { - $mapping = new JoinColumnMapping('id'); + $mapping = new JoinColumnMapping('foo', 'id'); - $mapping->name = 'foo'; $mapping->unique = true; $mapping->quoted = true; $mapping->fieldName = 'bar'; diff --git a/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php index 8077c15f3e0..65c00ed0fe6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php @@ -19,8 +19,8 @@ public function testItSurvivesSerialization(): void $mapping = new JoinTableMapping('bar'); $mapping->quoted = true; - $mapping->joinColumns = [new JoinColumnMapping('id')]; - $mapping->inverseJoinColumns = [new JoinColumnMapping('id')]; + $mapping->joinColumns = [new JoinColumnMapping('foo_id', 'id')]; + $mapping->inverseJoinColumns = [new JoinColumnMapping('bar_id', 'id')]; $mapping->schema = 'foo'; $mapping->options = ['foo' => 'bar']; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php index d183f9df158..3833e51ef53 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php @@ -22,7 +22,7 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->joinColumns = [new JoinColumnMapping('foo_id', 'id')]; $mapping->joinColumnFieldNames = ['foo' => 'bar']; $mapping->sourceToTargetKeyColumns = ['foo' => 'bar']; $mapping->targetToSourceKeyColumns = ['bar' => 'foo']; diff --git a/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php index f8d3ea0e8c6..73875653da2 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php @@ -22,7 +22,7 @@ public function testItSurvivesSerialization(): void targetEntity: self::class, ); - $mapping->joinColumns = [new JoinColumnMapping('id')]; + $mapping->joinColumns = [new JoinColumnMapping('foo_id', 'id')]; $mapping->joinColumnFieldNames = ['foo' => 'bar']; $mapping->sourceToTargetKeyColumns = ['foo' => 'bar']; $mapping->targetToSourceKeyColumns = ['bar' => 'foo']; From 07674b18879610e64debde9835aa876a4aa2482d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 25 May 2023 14:35:16 +0200 Subject: [PATCH 286/475] Migrate to the object API of Join{Column,Table}Mapping --- .../Internal/Hydration/AbstractHydrator.php | 4 +- .../ORM/Internal/Hydration/ObjectHydrator.php | 4 +- .../ORM/Mapping/AnsiQuoteStrategy.php | 6 +-- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 8 ++-- .../ORM/Mapping/DefaultQuoteStrategy.php | 26 ++++++------- lib/Doctrine/ORM/Mapping/JoinTableMapping.php | 5 ++- .../Collection/ManyToManyPersister.php | 38 +++++++++---------- .../Collection/OneToManyPersister.php | 2 +- .../Entity/BasicEntityPersister.php | 34 ++++++++--------- .../Entity/JoinedSubclassPersister.php | 8 ++-- .../Entity/SingleTablePersister.php | 4 +- .../Query/AST/Functions/IdentityFunction.php | 2 +- .../ORM/Query/AST/Functions/SizeFunction.php | 10 ++--- .../ORM/Query/ResultSetMappingBuilder.php | 6 +-- lib/Doctrine/ORM/Query/SqlWalker.php | 30 +++++++-------- .../Tools/Pagination/CountOutputWalker.php | 2 +- .../Pagination/LimitSubqueryOutputWalker.php | 2 +- lib/Doctrine/ORM/Tools/SchemaTool.php | 24 ++++++------ lib/Doctrine/ORM/Tools/SchemaValidator.php | 26 ++++++------- lib/Doctrine/ORM/UnitOfWork.php | 2 +- .../ORM/Utility/IdentifierFlattener.php | 2 +- lib/Doctrine/ORM/Utility/PersisterHelper.php | 12 +++--- .../Tests/ORM/Mapping/AttributeDriverTest.php | 4 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 36 +++++++++--------- .../Tests/ORM/Mapping/ClassMetadataTest.php | 30 +++++++-------- .../ORM/Mapping/MappingDriverTestCase.php | 24 ++++++------ 26 files changed, 176 insertions(+), 175 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index edc2b227fd5..232b9c3ae9a 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -520,14 +520,14 @@ protected function registerManaged(ClassMetadata $class, object $entity, array $ foreach ($class->identifier as $fieldName) { $id[$fieldName] = isset($class->associationMappings[$fieldName]) && $class->associationMappings[$fieldName]->isToOneOwningSide() - ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] + ? $data[$class->associationMappings[$fieldName]->joinColumns[0]->name] : $data[$fieldName]; } } else { $fieldName = $class->identifier[0]; $id = [ $fieldName => isset($class->associationMappings[$fieldName]) && $class->associationMappings[$fieldName]->isToOneOwningSide() - ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] + ? $data[$class->associationMappings[$fieldName]->joinColumns[0]->name] : $data[$fieldName], ]; } diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 55543799db2..345b3af391b 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -280,7 +280,7 @@ private function getEntityFromIdentityMap(string $className, array $data): objec /** @return mixed */ static function (string $fieldName) use ($data, $class) { return isset($class->associationMappings[$fieldName]) && assert($class->associationMappings[$fieldName]->isToOneOwningSide()) - ? $data[$class->associationMappings[$fieldName]->joinColumns[0]['name']] + ? $data[$class->associationMappings[$fieldName]->joinColumns[0]->name] : $data[$fieldName]; }, $class->identifier, @@ -292,7 +292,7 @@ static function (string $fieldName) use ($data, $class) { $association = $class->associationMappings[$class->identifier[0]]; assert($association->isToOneOwningSide()); - return $this->uow->tryGetByIdHash($data[$association->joinColumns[0]['name']], $class->rootEntityName); + return $this->uow->tryGetByIdHash($data[$association->joinColumns[0]->name], $class->rootEntityName); } return $this->uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName); diff --git a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php index ef94c7e562e..872d4d665e3 100644 --- a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php @@ -38,7 +38,7 @@ public function getSequenceName(array $definition, ClassMetadata $class, Abstrac public function getJoinColumnName(JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string { - return $joinColumn['name']; + return $joinColumn->name; } public function getReferencedJoinColumnName( @@ -46,7 +46,7 @@ public function getReferencedJoinColumnName( ClassMetadata $class, AbstractPlatform $platform, ): string { - return $joinColumn['referencedColumnName']; + return $joinColumn->referencedColumnName; } public function getJoinTableName( @@ -54,7 +54,7 @@ public function getJoinTableName( ClassMetadata $class, AbstractPlatform $platform, ): string { - return $association->joinTable['name']; + return $association->joinTable->name; } /** diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 3ce81698671..5de587efa2e 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1526,7 +1526,7 @@ public function getIdentifierColumnNames(): array // Association defined as Id field assert($this->associationMappings[$idProperty]->isToOneOwningSide()); $joinColumns = $this->associationMappings[$idProperty]->joinColumns; - $assocColumnNames = array_map(static fn (JoinColumnMapping $joinColumn): string => $joinColumn['name'], $joinColumns); + $assocColumnNames = array_map(static fn (JoinColumnMapping $joinColumn): string => $joinColumn->name, $joinColumns); $columnNames = array_merge($columnNames, $assocColumnNames); } @@ -2278,7 +2278,7 @@ public function getSingleAssociationJoinColumnName(string $fieldName): string assert($assoc->isToOneOwningSide()); - return $assoc->joinColumns[0]['name']; + return $assoc->joinColumns[0]->name; } /** @@ -2296,7 +2296,7 @@ public function getSingleAssociationReferencedJoinColumnName(string $fieldName): assert($assoc->isToOneOwningSide()); - return $assoc->joinColumns[0]['referencedColumnName']; + return $assoc->joinColumns[0]->referencedColumnName; } /** @@ -2316,7 +2316,7 @@ public function getFieldForColumn(string $columnName): string if ( $this->isAssociationWithSingleJoinColumn($assocName) && assert($this->associationMappings[$assocName]->isToOneOwningSide()) && - $this->associationMappings[$assocName]->joinColumns[0]['name'] === $columnName + $this->associationMappings[$assocName]->joinColumns[0]->name === $columnName ) { return $assocName; } diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php index 5e8c7d73f7b..6260336c027 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php +++ b/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php @@ -58,9 +58,9 @@ public function getSequenceName(array $definition, ClassMetadata $class, Abstrac public function getJoinColumnName(JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string { - return isset($joinColumn['quoted']) - ? $platform->quoteIdentifier($joinColumn['name']) - : $joinColumn['name']; + return isset($joinColumn->quoted) + ? $platform->quoteIdentifier($joinColumn->name) + : $joinColumn->name; } public function getReferencedJoinColumnName( @@ -68,9 +68,9 @@ public function getReferencedJoinColumnName( ClassMetadata $class, AbstractPlatform $platform, ): string { - return isset($joinColumn['quoted']) - ? $platform->quoteIdentifier($joinColumn['referencedColumnName']) - : $joinColumn['referencedColumnName']; + return isset($joinColumn->quoted) + ? $platform->quoteIdentifier($joinColumn->referencedColumnName) + : $joinColumn->referencedColumnName; } public function getJoinTableName( @@ -80,13 +80,13 @@ public function getJoinTableName( ): string { $schema = ''; - if (isset($association->joinTable['schema'])) { - $schema = $association->joinTable['schema'] . '.'; + if (isset($association->joinTable->schema)) { + $schema = $association->joinTable->schema . '.'; } - $tableName = $association->joinTable['name']; + $tableName = $association->joinTable->name; - if (isset($association->joinTable['quoted'])) { + if (isset($association->joinTable->quoted)) { $tableName = $platform->quoteIdentifier($tableName); } @@ -112,9 +112,9 @@ public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform assert($assoc->isToOneOwningSide()); $joinColumns = $assoc->joinColumns; $assocQuotedColumnNames = array_map( - static fn (JoinColumnMapping $joinColumn) => isset($joinColumn['quoted']) - ? $platform->quoteIdentifier($joinColumn['name']) - : $joinColumn['name'], + static fn (JoinColumnMapping $joinColumn) => isset($joinColumn->quoted) + ? $platform->quoteIdentifier($joinColumn->name) + : $joinColumn->name, $joinColumns, ); diff --git a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php index a27dce84a8d..df46f9722a9 100644 --- a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php +++ b/lib/Doctrine/ORM/Mapping/JoinTableMapping.php @@ -38,7 +38,8 @@ public function __construct(public string $name) * quoted?: bool, * joinColumns?: mixed[], * inverseJoinColumns?: mixed[], - * schema?: string + * schema?: string, + * options?: array * } $mappingArray */ public static function fromMappingArray(array $mappingArray): self @@ -47,7 +48,7 @@ public static function fromMappingArray(array $mappingArray): self foreach (['quoted', 'schema', 'options'] as $key) { if (isset($mappingArray[$key])) { - $mapping[$key] = $mappingArray[$key]; + $mapping->$key = $mappingArray[$key]; } } diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 1b8b46a150d..d2626e40992 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -45,8 +45,8 @@ public function delete(PersistentCollection $collection): void $types = []; $class = $this->em->getClassMetadata($mapping->sourceEntity); - foreach ($mapping->joinTable['joinColumns'] as $joinColumn) { - $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $class, $this->em); + foreach ($mapping->joinTable->joinColumns as $joinColumn) { + $types[] = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $class, $this->em); } $this->conn->executeStatement($this->getDeleteSQL($collection), $this->getDeleteSQLParameters($collection), $types); @@ -117,12 +117,12 @@ public function count(PersistentCollection $collection): int $joinTableName = $this->quoteStrategy->getJoinTableName($association, $sourceClass, $this->platform); $joinColumns = ! $mapping->isOwningSide() - ? $association->joinTable['inverseJoinColumns'] - : $association->joinTable['joinColumns']; + ? $association->joinTable->inverseJoinColumns + : $association->joinTable->joinColumns; foreach ($joinColumns as $joinColumn) { $columnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $sourceClass, $this->platform); - $referencedName = $joinColumn['referencedColumnName']; + $referencedName = $joinColumn->referencedColumnName; $conditions[] = 't.' . $columnName . ' = ?'; $params[] = $id[$sourceClass->getFieldForColumn($referencedName)]; $types[] = PersisterHelper::getTypeOfColumn($referencedName, $sourceClass, $this->em); @@ -346,8 +346,8 @@ protected function getOnConditionSQL(AssociationMapping $mapping): array { $association = $this->em->getMetadataFactory()->getOwningSide($mapping); $joinColumns = $mapping->isOwningSide() - ? $association->joinTable['inverseJoinColumns'] - : $association->joinTable['joinColumns']; + ? $association->joinTable->inverseJoinColumns + : $association->joinTable->joinColumns; $conditions = []; @@ -370,7 +370,7 @@ protected function getDeleteSQL(PersistentCollection $collection): string $class = $this->em->getClassMetadata($collection->getOwner()::class); $joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class, $this->platform); - foreach ($mapping->joinTable['joinColumns'] as $joinColumn) { + foreach ($mapping->joinTable->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } @@ -423,14 +423,14 @@ protected function getDeleteRowSQL(PersistentCollection $collection): array $columns = []; $types = []; - foreach ($mapping->joinTable['joinColumns'] as $joinColumn) { + foreach ($mapping->joinTable->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); - $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $class, $this->em); + $types[] = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $class, $this->em); } - foreach ($mapping->joinTable['inverseJoinColumns'] as $joinColumn) { + foreach ($mapping->joinTable->inverseJoinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); - $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); + $types[] = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em); } return [ @@ -470,14 +470,14 @@ protected function getInsertRowSQL(PersistentCollection $collection): array $class = $this->em->getClassMetadata($mapping->sourceEntity); $targetClass = $this->em->getClassMetadata($mapping->targetEntity); - foreach ($mapping->joinTable['joinColumns'] as $joinColumn) { + foreach ($mapping->joinTable->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); - $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $class, $this->em); + $types[] = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $class, $this->em); } - foreach ($mapping->joinTable['inverseJoinColumns'] as $joinColumn) { + foreach ($mapping->joinTable->inverseJoinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); - $types[] = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); + $types[] = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em); } return [ @@ -576,13 +576,13 @@ private function getJoinTableRestrictionsWithKey( $associationSourceClass = $this->em->getClassMetadata($mapping->targetEntity); $mapping = $associationSourceClass->associationMappings[$mapping->mappedBy]; assert($mapping->isManyToManyOwningSide()); - $joinColumns = $mapping->joinTable['joinColumns']; + $joinColumns = $mapping->joinTable->joinColumns; $sourceRelationMode = 'relationToTargetKeyColumns'; $targetRelationMode = 'relationToSourceKeyColumns'; } else { assert($mapping->isManyToManyOwningSide()); $associationSourceClass = $this->em->getClassMetadata($mapping->sourceEntity); - $joinColumns = $mapping->joinTable['inverseJoinColumns']; + $joinColumns = $mapping->joinTable->inverseJoinColumns; $sourceRelationMode = 'relationToSourceKeyColumns'; $targetRelationMode = 'relationToTargetKeyColumns'; } @@ -598,7 +598,7 @@ private function getJoinTableRestrictionsWithKey( $joinConditions = []; foreach ($joinColumns as $joinTableColumn) { - $joinConditions[] = 't.' . $joinTableColumn['name'] . ' = tr.' . $joinTableColumn['referencedColumnName']; + $joinConditions[] = 't.' . $joinTableColumn->name . ' = tr.' . $joinTableColumn->referencedColumnName; } $tableName = $this->quoteStrategy->getTableName($targetClass, $this->platform); diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 2b1a2fad6f7..648c8f8e53d 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -157,7 +157,7 @@ private function deleteEntityCollection(PersistentCollection $collection): int foreach ($this->em->getMetadataFactory()->getOwningSide($mapping)->joinColumns as $joinColumn) { $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); - $parameters[] = $identifier[$sourceClass->getFieldForColumn($joinColumn['referencedColumnName'])]; + $parameters[] = $identifier[$sourceClass->getFieldForColumn($joinColumn->referencedColumnName)]; } $statement = 'DELETE FROM ' . $this->quoteStrategy->getTableName($targetClass, $this->platform) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 2ff2451f297..7fc717da08b 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -522,13 +522,13 @@ protected function deleteJoinTableRecords(array $identifier, array $types): void $association = $this->em->getMetadataFactory()->getOwningSide($association); $joinColumns = $mapping->isOwningSide() - ? $association->joinTable['joinColumns'] - : $association->joinTable['inverseJoinColumns']; + ? $association->joinTable->joinColumns + : $association->joinTable->inverseJoinColumns; if ($selfReferential) { $otherColumns = ! $mapping->isOwningSide() - ? $association->joinTable['joinColumns'] - : $association->joinTable['inverseJoinColumns']; + ? $association->joinTable->joinColumns + : $association->joinTable->inverseJoinColumns; } foreach ($joinColumns as $joinColumn) { @@ -661,8 +661,8 @@ protected function prepareUpdateData(object $entity, bool $isInsert = false): ar $owningTable = $this->getOwningTable($field); foreach ($assoc->joinColumns as $joinColumn) { - $sourceColumn = $joinColumn['name']; - $targetColumn = $joinColumn['referencedColumnName']; + $sourceColumn = $joinColumn->name; + $targetColumn = $joinColumn->referencedColumnName; $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); $this->quotedColumns[$sourceColumn] = $quotedColumn; @@ -984,13 +984,13 @@ private function getManyToManyStatement( $association = $this->em->getMetadataFactory()->getOwningSide($assoc); $joinColumns = $assoc->isOwningSide() - ? $association->joinTable['joinColumns'] - : $association->joinTable['inverseJoinColumns']; + ? $association->joinTable->joinColumns + : $association->joinTable->inverseJoinColumns; $quotedJoinTable = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); foreach ($joinColumns as $joinColumn) { - $sourceKeyColumn = $joinColumn['referencedColumnName']; + $sourceKeyColumn = $joinColumn->referencedColumnName; $quotedKeyColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); switch (true) { @@ -1314,10 +1314,10 @@ protected function getSelectColumnAssociationSQL( foreach ($assoc->joinColumns as $joinColumn) { $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); - $resultColumnName = $this->getSQLColumnAlias($joinColumn['name']); - $type = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); + $resultColumnName = $this->getSQLColumnAlias($joinColumn->name); + $type = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em); - $this->currentPersisterContext->rsm->addMetaResult($alias, $resultColumnName, $joinColumn['name'], $isIdentifier, $type); + $this->currentPersisterContext->rsm->addMetaResult($alias, $resultColumnName, $joinColumn->name, $isIdentifier, $type); $columnList[] = sprintf('%s.%s AS %s', $sqlTableAlias, $quotedColumn, $resultColumnName); } @@ -1338,8 +1338,8 @@ protected function getSelectManyToManyJoinSQL(AssociationMapping&ManyToManyAssoc $association = $this->em->getMetadataFactory()->getOwningSide($manyToMany); $joinTableName = $this->quoteStrategy->getJoinTableName($association, $this->class, $this->platform); $joinColumns = $manyToMany->isOwningSide() - ? $association->joinTable['inverseJoinColumns'] - : $association->joinTable['joinColumns']; + ? $association->joinTable->inverseJoinColumns + : $association->joinTable->joinColumns; foreach ($joinColumns as $joinColumn) { $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); @@ -1646,8 +1646,8 @@ private function getSelectConditionStatementColumnSQL( $joinTableName = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); $joinColumns = $assoc->isOwningSide() - ? $association->joinTable['joinColumns'] - : $association->joinTable['inverseJoinColumns']; + ? $association->joinTable->joinColumns + : $association->joinTable->inverseJoinColumns; foreach ($joinColumns as $joinColumn) { $columns[] = $joinTableName . '.' . $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); @@ -1992,7 +1992,7 @@ protected function getJoinSQLForJoinColumns(array $joinColumns): string { // if one of the join columns is nullable, return left join foreach ($joinColumns as $joinColumn) { - if (! isset($joinColumn['nullable']) || $joinColumn['nullable']) { + if (! isset($joinColumn->nullable) || $joinColumn->nullable) { return 'LEFT JOIN'; } } diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 9d7151fd1ef..1b850353443 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -399,9 +399,9 @@ protected function getSelectColumnsSQL(): string foreach ($mapping->joinColumns as $joinColumn) { $columnList[] = $this->getSelectJoinColumnSQL( $tableAlias, - $joinColumn['name'], + $joinColumn->name, $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform), - PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em), + PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em), ); } } @@ -438,9 +438,9 @@ protected function getSelectColumnsSQL(): string foreach ($mapping->joinColumns as $joinColumn) { $columnList[] = $this->getSelectJoinColumnSQL( $tableAlias, - $joinColumn['name'], + $joinColumn->name, $this->quoteStrategy->getJoinColumnName($joinColumn, $subClass, $this->platform), - PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em), + PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em), ); } } diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php index 3a5ddb646c9..11281880b3a 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php @@ -76,9 +76,9 @@ protected function getSelectColumnsSQL(): string foreach ($assoc->joinColumns as $joinColumn) { $columnList[] = $this->getSelectJoinColumnSQL( $tableAlias, - $joinColumn['name'], + $joinColumn->name, $this->quoteStrategy->getJoinColumnName($joinColumn, $subClass, $this->platform), - PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em), + PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em), ); } } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 34ee70284ae..22f4744defa 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -49,7 +49,7 @@ public function getSql(SqlWalker $sqlWalker): string $joinColumn = null; foreach ($assoc->joinColumns as $mapping) { - if ($mapping['referencedColumnName'] === $field->columnName) { + if ($mapping->referencedColumnName === $field->columnName) { $joinColumn = $mapping; break; diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 8b09f4dff92..9ca9a0ed7ef 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -67,7 +67,7 @@ public function getSql(SqlWalker $sqlWalker): string $joinTable = $owningAssoc->joinTable; // SQL table aliases - $joinTableAlias = $sqlWalker->getSQLTableAlias($joinTable['name']); + $joinTableAlias = $sqlWalker->getSQLTableAlias($joinTable->name); $sourceTableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); // join to target table @@ -75,8 +75,8 @@ public function getSql(SqlWalker $sqlWalker): string $sql .= $quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $platform) . ' ' . $joinTableAlias . ' WHERE '; $joinColumns = $assoc->isOwningSide() - ? $joinTable['joinColumns'] - : $joinTable['inverseJoinColumns']; + ? $joinTable->joinColumns + : $joinTable->inverseJoinColumns; $first = true; @@ -88,12 +88,12 @@ public function getSql(SqlWalker $sqlWalker): string } $sourceColumnName = $quoteStrategy->getColumnName( - $class->fieldNames[$joinColumn['referencedColumnName']], + $class->fieldNames[$joinColumn->referencedColumnName], $class, $platform, ); - $sql .= $joinTableAlias . '.' . $joinColumn['name'] + $sql .= $joinTableAlias . '.' . $joinColumn->name . ' = ' . $sourceTableAlias . '.' . $sourceColumnName; } diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 4863af59b1b..85ca699f8f5 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -141,9 +141,9 @@ protected function addAllClassFields(string $class, string $alias, array $column $isIdentifier = isset($associationMapping->id) && $associationMapping->id === true; foreach ($associationMapping->joinColumns as $joinColumn) { - $columnName = $joinColumn['name']; + $columnName = $joinColumn->name; $columnAlias = $this->getSQLResultCasing($platform, $columnAliasMap[$columnName]); - $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); + $columnType = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em); if (isset($this->metaMappings[$columnAlias])) { throw new InvalidArgumentException(sprintf( @@ -218,7 +218,7 @@ private function getColumnAliasMap( foreach ($class->associationMappings as $associationMapping) { if ($associationMapping->isToOneOwningSide()) { foreach ($associationMapping->joinColumns as $joinColumn) { - $columnName = $joinColumn['name']; + $columnName = $joinColumn->name; $columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns); } } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 4063307a11d..3f2cd06cb1d 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -694,9 +694,9 @@ public function walkSelectClause(AST\SelectClause $selectClause): string $sqlTableAlias = $this->getSQLTableAlias($owningClass->getTableName(), $dqlAlias); foreach ($assoc->joinColumns as $joinColumn) { - $columnName = $joinColumn['name']; + $columnName = $joinColumn->name; $columnAlias = $this->getSQLColumnAlias($columnName); - $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); + $columnType = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em); $quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); $sqlSelectExpressions[] = $sqlTableAlias . '.' . $quotedColumnName . ' AS ' . $columnAlias; @@ -725,9 +725,9 @@ public function walkSelectClause(AST\SelectClause $selectClause): string $targetClass = $this->em->getClassMetadata($assoc->targetEntity); foreach ($assoc->joinColumns as $joinColumn) { - $columnName = $joinColumn['name']; + $columnName = $joinColumn->name; $columnAlias = $this->getSQLColumnAlias($columnName); - $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); + $columnType = PersisterHelper::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $this->em); $quotedColumnName = $this->quoteStrategy->getJoinColumnName($joinColumn, $subClass, $this->platform); $sqlSelectExpressions[] = $sqlTableAlias . '.' . $quotedColumnName . ' AS ' . $columnAlias; @@ -949,13 +949,13 @@ public function walkJoinAssociationDeclaration( case $assoc->isManyToMany(): // Join relation table $joinTable = $assoc->joinTable; - $joinTableAlias = $this->getSQLTableAlias($joinTable['name'], $joinedDqlAlias); + $joinTableAlias = $this->getSQLTableAlias($joinTable->name, $joinedDqlAlias); $joinTableName = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->platform); $conditions = []; $relationColumns = $relation->isOwningSide() - ? $assoc->joinTable['joinColumns'] - : $assoc->joinTable['inverseJoinColumns']; + ? $assoc->joinTable->joinColumns + : $assoc->joinTable->inverseJoinColumns; foreach ($relationColumns as $joinColumn) { $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); @@ -971,8 +971,8 @@ public function walkJoinAssociationDeclaration( $conditions = []; $relationColumns = $relation->isOwningSide() - ? $assoc->joinTable['inverseJoinColumns'] - : $assoc->joinTable['joinColumns']; + ? $assoc->joinTable->inverseJoinColumns + : $assoc->joinTable->joinColumns; foreach ($relationColumns as $joinColumn) { $quotedSourceColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $targetClass, $this->platform); @@ -1891,28 +1891,28 @@ public function walkCollectionMemberExpression(AST\CollectionMemberExpression $c $joinTable = $owningAssoc->joinTable; // SQL table aliases - $joinTableAlias = $this->getSQLTableAlias($joinTable['name']); + $joinTableAlias = $this->getSQLTableAlias($joinTable->name); $sourceTableAlias = $this->getSQLTableAlias($class->getTableName(), $dqlAlias); $sql .= $this->quoteStrategy->getJoinTableName($owningAssoc, $targetClass, $this->platform) . ' ' . $joinTableAlias . ' WHERE '; - $joinColumns = $assoc->isOwningSide() ? $joinTable['joinColumns'] : $joinTable['inverseJoinColumns']; + $joinColumns = $assoc->isOwningSide() ? $joinTable->joinColumns : $joinTable->inverseJoinColumns; $sqlParts = []; foreach ($joinColumns as $joinColumn) { - $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$joinColumn['referencedColumnName']], $class, $this->platform); + $targetColumn = $this->quoteStrategy->getColumnName($class->fieldNames[$joinColumn->referencedColumnName], $class, $this->platform); - $sqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' = ' . $sourceTableAlias . '.' . $targetColumn; + $sqlParts[] = $joinTableAlias . '.' . $joinColumn->name . ' = ' . $sourceTableAlias . '.' . $targetColumn; } - $joinColumns = $assoc->isOwningSide() ? $joinTable['inverseJoinColumns'] : $joinTable['joinColumns']; + $joinColumns = $assoc->isOwningSide() ? $joinTable->inverseJoinColumns : $joinTable->joinColumns; foreach ($joinColumns as $joinColumn) { if (isset($dqlParamKey)) { $this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++); } - $sqlParts[] = $joinTableAlias . '.' . $joinColumn['name'] . ' IN (' . $entitySql . ')'; + $sqlParts[] = $joinTableAlias . '.' . $joinColumn->name . ' IN (' . $entitySql . ')'; } $sql .= implode(' AND ', $sqlParts); diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index acbabe5441b..c7f31dbf628 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -98,7 +98,7 @@ public function walkSelectStatement(SelectStatement $selectStatement): string if (isset($rootClass->associationMappings[$property])) { $association = $rootClass->associationMappings[$property]; assert($association->isToOneOwningSide()); - $joinColumn = $association->joinColumns[0]['name']; + $joinColumn = $association->joinColumns[0]->name; foreach (array_keys($this->rsm->metaMappings, $joinColumn, true) as $alias) { if ($this->rsm->columnOwnerMap[$alias] === $rootAlias) { diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 8eb623114c2..bcd560bbfef 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -500,7 +500,7 @@ private function getSQLIdentifier(SelectStatement $AST): array if (isset($rootClass->associationMappings[$property])) { $association = $rootClass->associationMappings[$property]; assert($association->isToOneOwningSide()); - $joinColumn = $association->joinColumns[0]['name']; + $joinColumn = $association->joinColumns[0]->name; foreach (array_keys($this->rsm->metaMappings, $joinColumn, true) as $alias) { if ($this->rsm->columnOwnerMap[$alias] === $rootAlias) { diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 143f63ccbd6..d676a51d5a1 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -259,7 +259,7 @@ public function getSchemaFromMetadata(array $classes): Schema ); foreach ($idMapping->joinColumns as $joinColumn) { - if (isset($targetEntity->fieldMappings[$joinColumn['referencedColumnName']])) { + if (isset($targetEntity->fieldMappings[$joinColumn->referencedColumnName])) { $columnName = $this->quoteStrategy->getJoinColumnName( $joinColumn, $class, @@ -571,7 +571,7 @@ private function gatherRelationsSql( // Build first FK constraint (relation table => source table) $this->gatherRelationJoinColumns( - $joinTable['joinColumns'], + $joinTable->joinColumns, $theJoinTable, $class, $mapping, @@ -582,7 +582,7 @@ private function gatherRelationsSql( // Build second FK constraint (relation table => target table) $this->gatherRelationJoinColumns( - $joinTable['inverseJoinColumns'], + $joinTable->inverseJoinColumns, $theJoinTable, $foreignClass, $mapping, @@ -664,12 +664,12 @@ private function gatherRelationJoinColumns( foreach ($joinColumns as $joinColumn) { [$definingClass, $referencedFieldName] = $this->getDefiningClass( $class, - $joinColumn['referencedColumnName'], + $joinColumn->referencedColumnName, ); if (! $definingClass) { throw MissingColumnException::fromColumnSourceAndTarget( - $joinColumn['referencedColumnName'], + $joinColumn->referencedColumnName, $mapping->sourceEntity, $mapping->targetEntity, ); @@ -695,14 +695,14 @@ private function gatherRelationJoinColumns( $columnOptions = ['notnull' => false]; - if (isset($joinColumn['columnDefinition'])) { - $columnOptions['columnDefinition'] = $joinColumn['columnDefinition']; + if (isset($joinColumn->columnDefinition)) { + $columnOptions['columnDefinition'] = $joinColumn->columnDefinition; } elseif (isset($fieldMapping->columnDefinition)) { $columnOptions['columnDefinition'] = $fieldMapping->columnDefinition; } - if (isset($joinColumn['nullable'])) { - $columnOptions['notnull'] = ! $joinColumn['nullable']; + if (isset($joinColumn->nullable)) { + $columnOptions['notnull'] = ! $joinColumn->nullable; } $columnOptions += $this->gatherColumnOptions($fieldMapping); @@ -721,12 +721,12 @@ private function gatherRelationJoinColumns( $theJoinTable->addColumn($quotedColumnName, $fieldMapping->type, $columnOptions); } - if (isset($joinColumn['unique']) && $joinColumn['unique'] === true) { + if (isset($joinColumn->unique) && $joinColumn->unique === true) { $uniqueConstraints[] = ['columns' => [$quotedColumnName]]; } - if (isset($joinColumn['onDelete'])) { - $fkOptions['onDelete'] = $joinColumn['onDelete']; + if (isset($joinColumn->onDelete)) { + $fkOptions['onDelete'] = $joinColumn->onDelete; } } diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 0f812b8f466..b24b3b45f5d 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -160,32 +160,32 @@ public function validateClass(ClassMetadata $class): array if ($assoc->isOwningSide()) { if ($assoc->isManyToManyOwningSide()) { $identifierColumns = $class->getIdentifierColumnNames(); - foreach ($assoc->joinTable['joinColumns'] as $joinColumn) { - if (! in_array($joinColumn['referencedColumnName'], $identifierColumns, true)) { - $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " . + foreach ($assoc->joinTable->joinColumns as $joinColumn) { + if (! in_array($joinColumn->referencedColumnName, $identifierColumns, true)) { + $ce[] = "The referenced column name '" . $joinColumn->referencedColumnName . "' " . "has to be a primary key column on the target entity class '" . $class->name . "'."; break; } } $identifierColumns = $targetMetadata->getIdentifierColumnNames(); - foreach ($assoc->joinTable['inverseJoinColumns'] as $inverseJoinColumn) { - if (! in_array($inverseJoinColumn['referencedColumnName'], $identifierColumns, true)) { - $ce[] = "The referenced column name '" . $inverseJoinColumn['referencedColumnName'] . "' " . + foreach ($assoc->joinTable->inverseJoinColumns as $inverseJoinColumn) { + if (! in_array($inverseJoinColumn->referencedColumnName, $identifierColumns, true)) { + $ce[] = "The referenced column name '" . $inverseJoinColumn->referencedColumnName . "' " . "has to be a primary key column on the target entity class '" . $targetMetadata->name . "'."; break; } } - if (count($targetMetadata->getIdentifierColumnNames()) !== count($assoc->joinTable['inverseJoinColumns'])) { - $ce[] = "The inverse join columns of the many-to-many table '" . $assoc->joinTable['name'] . "' " . + if (count($targetMetadata->getIdentifierColumnNames()) !== count($assoc->joinTable->inverseJoinColumns)) { + $ce[] = "The inverse join columns of the many-to-many table '" . $assoc->joinTable->name . "' " . "have to contain to ALL identifier columns of the target entity '" . $targetMetadata->name . "', " . "however '" . implode(', ', array_diff($targetMetadata->getIdentifierColumnNames(), array_values($assoc->relationToTargetKeyColumns))) . "' are missing."; } - if (count($class->getIdentifierColumnNames()) !== count($assoc->joinTable['joinColumns'])) { - $ce[] = "The join columns of the many-to-many table '" . $assoc->joinTable['name'] . "' " . + if (count($class->getIdentifierColumnNames()) !== count($assoc->joinTable->joinColumns)) { + $ce[] = "The join columns of the many-to-many table '" . $assoc->joinTable->name . "' " . "have to contain to ALL identifier columns of the source entity '" . $class->name . "', " . "however '" . implode(', ', array_diff($class->getIdentifierColumnNames(), array_values($assoc->relationToSourceKeyColumns))) . "' are missing."; @@ -193,8 +193,8 @@ public function validateClass(ClassMetadata $class): array } elseif ($assoc->isToOneOwningSide()) { $identifierColumns = $targetMetadata->getIdentifierColumnNames(); foreach ($assoc->joinColumns as $joinColumn) { - if (! in_array($joinColumn['referencedColumnName'], $identifierColumns, true)) { - $ce[] = "The referenced column name '" . $joinColumn['referencedColumnName'] . "' " . + if (! in_array($joinColumn->referencedColumnName, $identifierColumns, true)) { + $ce[] = "The referenced column name '" . $joinColumn->referencedColumnName . "' " . "has to be a primary key column on the target entity class '" . $targetMetadata->name . "'."; } } @@ -203,7 +203,7 @@ public function validateClass(ClassMetadata $class): array $ids = []; foreach ($assoc->joinColumns as $joinColumn) { - $ids[] = $joinColumn['name']; + $ids[] = $joinColumn->name; } $ce[] = "The join columns of the association '" . $assoc->fieldName . "' " . diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 347b4da9bdc..0092f9ffe45 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1200,7 +1200,7 @@ private function getCommitOrder(): array $joinColumns = reset($assoc->joinColumns); - $calc->addDependency($targetClass->name, $class->name, (int) empty($joinColumns['nullable'])); + $calc->addDependency($targetClass->name, $class->name, (int) empty($joinColumns->nullable)); // If the target class has mapped subclasses, these share the same dependency. if (! $targetClass->subClasses) { diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index 98fca2399ca..3792d334bba 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -65,7 +65,7 @@ public function flattenIdentifier(ClassMetadata $class, array $id): array $associatedId = []; foreach ($class->associationMappings[$field]->joinColumns as $joinColumn) { - $associatedId[] = $id[$joinColumn['name']]; + $associatedId[] = $id[$joinColumn->name]; } $flatId[$field] = implode(' ', $associatedId); diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index bad942b6acd..76e92427828 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -50,7 +50,7 @@ public static function getTypeOfField(string $fieldName, ClassMetadata $class, E $targetClass = $em->getClassMetadata($assoc->targetEntity); foreach ($joinData->joinColumns as $joinColumn) { - $types[] = self::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $em); + $types[] = self::getTypeOfColumn($joinColumn->referencedColumnName, $targetClass, $em); } return $types; @@ -74,8 +74,8 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, } foreach ($assoc->joinColumns as $joinColumn) { - if ($joinColumn['name'] === $columnName) { - $targetColumnName = $joinColumn['referencedColumnName']; + if ($joinColumn->name === $columnName) { + $targetColumnName = $joinColumn->referencedColumnName; $targetClass = $em->getClassMetadata($assoc->targetEntity); return self::getTypeOfColumn($targetColumnName, $targetClass, $em); @@ -89,9 +89,9 @@ public static function getTypeOfColumn(string $columnName, ClassMetadata $class, continue; } - foreach ($assoc->joinTable['joinColumns'] as $joinColumn) { - if ($joinColumn['name'] === $columnName) { - $targetColumnName = $joinColumn['referencedColumnName']; + foreach ($assoc->joinTable->joinColumns as $joinColumn) { + if ($joinColumn->name === $columnName) { + $targetColumnName = $joinColumn->referencedColumnName; $targetClass = $em->getClassMetadata($assoc->targetEntity); return self::getTypeOfColumn($targetColumnName, $targetClass, $em); diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index ef16896a14b..880f20c7100 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -70,7 +70,7 @@ public function testManyToManyAssociationWithNestedJoinColumns(): void 'columnDefinition' => null, ]), ], - $metadata->associationMappings['assoc']->joinTable['joinColumns'], + $metadata->associationMappings['assoc']->joinTable->joinColumns, ); self::assertEquals( @@ -84,7 +84,7 @@ public function testManyToManyAssociationWithNestedJoinColumns(): void 'columnDefinition' => null, ]), ], - $metadata->associationMappings['assoc']->joinTable['inverseJoinColumns'], + $metadata->associationMappings['assoc']->joinTable->inverseJoinColumns, ); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 4d8ce245bff..ec7dea7a835 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -304,9 +304,9 @@ public function testQuoteMetadata(): void self::assertEquals('phone-number', $phoneMetadata->fieldMappings['number']->columnName); $user = $phoneMetadata->associationMappings['user']; - self::assertTrue($user->joinColumns[0]['quoted']); - self::assertEquals('user-id', $user->joinColumns[0]['name']); - self::assertEquals('user-id', $user->joinColumns[0]['referencedColumnName']); + self::assertTrue($user->joinColumns[0]->quoted); + self::assertEquals('user-id', $user->joinColumns[0]->name); + self::assertEquals('user-id', $user->joinColumns[0]->referencedColumnName); // User Group Metadata self::assertTrue($groupMetadata->fieldMappings['id']->quoted); @@ -316,9 +316,9 @@ public function testQuoteMetadata(): void self::assertEquals('user-name', $userMetadata->fieldMappings['name']->columnName); $user = $groupMetadata->associationMappings['parent']; - self::assertTrue($user->joinColumns[0]['quoted']); - self::assertEquals('parent-id', $user->joinColumns[0]['name']); - self::assertEquals('group-id', $user->joinColumns[0]['referencedColumnName']); + self::assertTrue($user->joinColumns[0]->quoted); + self::assertEquals('parent-id', $user->joinColumns[0]->name); + self::assertEquals('group-id', $user->joinColumns[0]->referencedColumnName); // Address Class Metadata self::assertTrue($addressMetadata->fieldMappings['id']->quoted); @@ -328,9 +328,9 @@ public function testQuoteMetadata(): void self::assertEquals('address-zip', $addressMetadata->fieldMappings['zip']->columnName); $user = $addressMetadata->associationMappings['user']; - self::assertTrue($user->joinColumns[0]['quoted']); - self::assertEquals('user-id', $user->joinColumns[0]['name']); - self::assertEquals('user-id', $user->joinColumns[0]['referencedColumnName']); + self::assertTrue($user->joinColumns[0]->quoted); + self::assertEquals('user-id', $user->joinColumns[0]->name); + self::assertEquals('user-id', $user->joinColumns[0]->referencedColumnName); // User Class Metadata self::assertTrue($userMetadata->fieldMappings['id']->quoted); @@ -340,15 +340,15 @@ public function testQuoteMetadata(): void self::assertEquals('user-name', $userMetadata->fieldMappings['name']->columnName); $groups = $userMetadata->associationMappings['groups']; - self::assertTrue($groups->joinTable['quoted']); - self::assertTrue($groups->joinTable['joinColumns'][0]['quoted']); - self::assertEquals('quote-users-groups', $groups->joinTable['name']); - self::assertEquals('user-id', $groups->joinTable['joinColumns'][0]['name']); - self::assertEquals('user-id', $groups->joinTable['joinColumns'][0]['referencedColumnName']); - - self::assertTrue($groups->joinTable['inverseJoinColumns'][0]['quoted']); - self::assertEquals('group-id', $groups->joinTable['inverseJoinColumns'][0]['name']); - self::assertEquals('group-id', $groups->joinTable['inverseJoinColumns'][0]['referencedColumnName']); + self::assertTrue($groups->joinTable->quoted); + self::assertTrue($groups->joinTable->joinColumns[0]->quoted); + self::assertEquals('quote-users-groups', $groups->joinTable->name); + self::assertEquals('user-id', $groups->joinTable->joinColumns[0]->name); + self::assertEquals('user-id', $groups->joinTable->joinColumns[0]->referencedColumnName); + + self::assertTrue($groups->joinTable->inverseJoinColumns[0]->quoted); + self::assertEquals('group-id', $groups->joinTable->inverseJoinColumns[0]->name); + self::assertEquals('group-id', $groups->joinTable->inverseJoinColumns[0]->referencedColumnName); } #[\PHPUnit\Framework\Attributes\Group('DDC-3385')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index bfb8f81be10..2b761ec6d8d 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -482,7 +482,7 @@ public function testDefaultTableName(): void ], ], ); - self::assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']->joinTable['name']); + self::assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']->joinTable->name); } public function testDefaultJoinColumnName(): void @@ -499,7 +499,7 @@ public function testDefaultJoinColumnName(): void 'joinColumns' => [['referencedColumnName' => 'id']], ], ); - self::assertEquals('user_id', $cm->associationMappings['user']->joinColumns[0]['name']); + self::assertEquals('user_id', $cm->associationMappings['user']->joinColumns[0]->name); $cm = new ClassMetadata(CmsAddress::class); $cm->initializeReflection(new RuntimeReflectionService()); @@ -515,8 +515,8 @@ public function testDefaultJoinColumnName(): void ], ], ); - self::assertEquals('cmsaddress_id', $cm->associationMappings['user']->joinTable['joinColumns'][0]['name']); - self::assertEquals('cmsuser_id', $cm->associationMappings['user']->joinTable['inverseJoinColumns'][0]['name']); + self::assertEquals('cmsaddress_id', $cm->associationMappings['user']->joinTable->joinColumns[0]->name); + self::assertEquals('cmsuser_id', $cm->associationMappings['user']->joinTable->inverseJoinColumns[0]->name); } #[TestGroup('DDC-559')] @@ -544,24 +544,24 @@ public function testUnderscoreNamingStrategyDefaults(): void self::assertEquals(['USER_ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']->joinColumnFieldNames); self::assertEquals(['ID' => 'USER_ID'], $oneToOneMetadata->associationMappings['user']->targetToSourceKeyColumns); - self::assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']->joinColumns[0]['name']); - self::assertEquals('ID', $oneToOneMetadata->associationMappings['user']->joinColumns[0]['referencedColumnName']); + self::assertEquals('USER_ID', $oneToOneMetadata->associationMappings['user']->joinColumns[0]->name); + self::assertEquals('ID', $oneToOneMetadata->associationMappings['user']->joinColumns[0]->referencedColumnName); - self::assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']->joinTable['name']); + self::assertEquals('CMS_ADDRESS_CMS_USER', $manyToManyMetadata->associationMappings['user']->joinTable->name); self::assertEquals(['CMS_ADDRESS_ID', 'CMS_USER_ID'], $manyToManyMetadata->associationMappings['user']->joinTableColumns); self::assertEquals(['CMS_ADDRESS_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']->relationToSourceKeyColumns); self::assertEquals(['CMS_USER_ID' => 'ID'], $manyToManyMetadata->associationMappings['user']->relationToTargetKeyColumns); - self::assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']->joinTable['joinColumns'][0]['name']); - self::assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']->joinTable['inverseJoinColumns'][0]['name']); + self::assertEquals('CMS_ADDRESS_ID', $manyToManyMetadata->associationMappings['user']->joinTable->joinColumns[0]->name); + self::assertEquals('CMS_USER_ID', $manyToManyMetadata->associationMappings['user']->joinTable->inverseJoinColumns[0]->name); - self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']->joinTable['joinColumns'][0]['referencedColumnName']); - self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']->joinTable['inverseJoinColumns'][0]['referencedColumnName']); + self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']->joinTable->joinColumns[0]->referencedColumnName); + self::assertEquals('ID', $manyToManyMetadata->associationMappings['user']->joinTable->inverseJoinColumns[0]->referencedColumnName); $cm = new ClassMetadata('DoctrineGlobalArticle', $namingStrategy); $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CmsUser::class]); - self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']->joinTable['name']); + self::assertEquals('DOCTRINE_GLOBAL_ARTICLE_CMS_USER', $cm->associationMappings['author']->joinTable->name); } #[TestGroup('DDC-886')] @@ -597,7 +597,7 @@ public function testJoinTableMappingDefaults(): void $cm->mapManyToMany(['fieldName' => 'author', 'targetEntity' => CmsUser::class]); - self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']->joinTable['name']); + self::assertEquals('doctrineglobalarticle_cmsuser', $cm->associationMappings['author']->joinTable->name); } #[TestGroup('DDC-117')] @@ -779,8 +779,8 @@ public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategy(): void ); self::assertEquals('routing_routingleg', $routingMetadata->table['name']); - self::assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']->joinTable['name']); - self::assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']->joinTable['name']); + self::assertEquals('cms_cmsaddress_cms_cmsuser', $addressMetadata->associationMappings['user']->joinTable->name); + self::assertEquals('doctrineglobalarticle_cms_cmsuser', $articleMetadata->associationMappings['author']->joinTable->name); } #[TestGroup('DDC-984')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 78260e84928..40c39827ee9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -424,8 +424,8 @@ public function testLifecycleCallbacksSupportMultipleMethodNames(ClassMetadata $ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMetadata { // Non-Nullability of Join Column - self::assertFalse($class->associationMappings['groups']->joinTable['joinColumns'][0]['nullable']); - self::assertFalse($class->associationMappings['groups']->joinTable['joinColumns'][0]['unique']); + self::assertFalse($class->associationMappings['groups']->joinTable->joinColumns[0]->nullable); + self::assertFalse($class->associationMappings['groups']->joinTable->joinColumns[0]->unique); return $class; } @@ -434,7 +434,7 @@ public function testJoinColumnUniqueAndNullable(ClassMetadata $class): ClassMeta public function testColumnDefinition(ClassMetadata $class): ClassMetadata { self::assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']->columnDefinition); - self::assertEquals('INT NULL', $class->associationMappings['groups']->joinTable['inverseJoinColumns'][0]['columnDefinition']); + self::assertEquals('INT NULL', $class->associationMappings['groups']->joinTable->inverseJoinColumns[0]->columnDefinition); return $class; } @@ -442,7 +442,7 @@ public function testColumnDefinition(ClassMetadata $class): ClassMetadata #[Depends('testColumnDefinition')] public function testJoinColumnOnDelete(ClassMetadata $class): ClassMetadata { - self::assertEquals('CASCADE', $class->associationMappings['address']->joinColumns[0]['onDelete']); + self::assertEquals('CASCADE', $class->associationMappings['address']->joinColumns[0]->onDelete); return $class; } @@ -634,17 +634,17 @@ public function testAssociationOverridesMapping(): void self::assertEquals($guestGroups->isCascadeDetach(), $adminGroups->isCascadeDetach()); // assert not override attributes - self::assertEquals('ddc964_users_groups', $guestGroups->joinTable['name']); - self::assertEquals('user_id', $guestGroups->joinTable['joinColumns'][0]['name']); - self::assertEquals('group_id', $guestGroups->joinTable['inverseJoinColumns'][0]['name']); + self::assertEquals('ddc964_users_groups', $guestGroups->joinTable->name); + self::assertEquals('user_id', $guestGroups->joinTable->joinColumns[0]->name); + self::assertEquals('group_id', $guestGroups->joinTable->inverseJoinColumns[0]->name); self::assertEquals(['user_id' => 'id'], $guestGroups->relationToSourceKeyColumns); self::assertEquals(['group_id' => 'id'], $guestGroups->relationToTargetKeyColumns); self::assertEquals(['user_id', 'group_id'], $guestGroups->joinTableColumns); - self::assertEquals('ddc964_users_admingroups', $adminGroups->joinTable['name']); - self::assertEquals('adminuser_id', $adminGroups->joinTable['joinColumns'][0]['name']); - self::assertEquals('admingroup_id', $adminGroups->joinTable['inverseJoinColumns'][0]['name']); + self::assertEquals('ddc964_users_admingroups', $adminGroups->joinTable->name); + self::assertEquals('adminuser_id', $adminGroups->joinTable->joinColumns[0]->name); + self::assertEquals('admingroup_id', $adminGroups->joinTable->inverseJoinColumns[0]->name); self::assertEquals(['adminuser_id' => 'id'], $adminGroups->relationToSourceKeyColumns); self::assertEquals(['admingroup_id' => 'id'], $adminGroups->relationToTargetKeyColumns); @@ -670,12 +670,12 @@ public function testAssociationOverridesMapping(): void self::assertEquals($guestAddress->isCascadeDetach(), $adminAddress->isCascadeDetach()); // assert override - self::assertEquals('address_id', $guestAddress->joinColumns[0]['name']); + self::assertEquals('address_id', $guestAddress->joinColumns[0]->name); self::assertEquals(['address_id' => 'id'], $guestAddress->sourceToTargetKeyColumns); self::assertEquals(['address_id' => 'address_id'], $guestAddress->joinColumnFieldNames); self::assertEquals(['id' => 'address_id'], $guestAddress->targetToSourceKeyColumns); - self::assertEquals('adminaddress_id', $adminAddress->joinColumns[0]['name']); + self::assertEquals('adminaddress_id', $adminAddress->joinColumns[0]->name); self::assertEquals(['adminaddress_id' => 'id'], $adminAddress->sourceToTargetKeyColumns); self::assertEquals(['adminaddress_id' => 'adminaddress_id'], $adminAddress->joinColumnFieldNames); self::assertEquals(['id' => 'adminaddress_id'], $adminAddress->targetToSourceKeyColumns); From 63e9ad9e9aa1101e2393809ba5e2dc02c29ad68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 1 Jun 2023 22:01:10 +0200 Subject: [PATCH 287/475] Remove unneeded ignore rule The linked issue has been addressed, this rules should have been removed during a merge up, as it is no longer present on 2.x --- psalm.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/psalm.xml b/psalm.xml index 3e2e94e0acb..3e3e8630ccd 100644 --- a/psalm.xml +++ b/psalm.xml @@ -28,8 +28,6 @@ - - From f38922944ed40ff01e81c6666e1f313608d18f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 1 Jun 2023 22:02:52 +0200 Subject: [PATCH 288/475] Remove unneeded DeprecatedProperty rule That property has been removed from 3.0.x --- psalm.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/psalm.xml b/psalm.xml index 3e3e8630ccd..98ba9239184 100644 --- a/psalm.xml +++ b/psalm.xml @@ -40,11 +40,6 @@ - - - - - From 0945f60484fa34a786d844aa047793b19dd11993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 1 Jun 2023 21:51:53 +0200 Subject: [PATCH 289/475] Remove backward-compatibility layer Note that we also remove UpdateCommandTest::testItPrintsTheSql() because it relied on not passing --complete to work. --- .../Command/SchemaTool/UpdateCommand.php | 25 +++----- lib/Doctrine/ORM/Tools/SchemaTool.php | 39 ++---------- lib/Doctrine/ORM/Tools/SchemaValidator.php | 2 +- phpstan-dbal4.neon | 6 -- psalm.xml | 2 - .../Command/SchemaTool/UpdateCommandTest.php | 60 ------------------- 6 files changed, 13 insertions(+), 121 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php index 33ee7ceb5f9..ed5bd5ede23 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -29,7 +29,7 @@ protected function configure(): void $this->setName($this->name) ->setDescription('Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata') ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') - ->addOption('complete', null, InputOption::VALUE_NONE, 'If defined, all assets of the database which are not relevant to the current metadata will be dropped.') + ->addOption('complete', null, InputOption::VALUE_NONE, 'This option is a no-op and will be removed in 4.0') ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Dumps the generated SQL statements to the screen (does not execute them).') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Causes the generated SQL statements to be physically executed against your database.') ->setHelp(<<<'EOT' @@ -50,11 +50,10 @@ protected function configure(): void %command.name% --dump-sql --force -Finally, be aware that if the --complete option is passed, this -task will drop all database assets (e.g. tables, etc) that are *not* described -by the current metadata. In other words, without this option, this task leaves -untouched any "extra" tables that exist in the database, but which aren't -described by any metadata. Not passing that option is deprecated. +Finally, be aware that this task will drop all database assets (e.g. tables, +etc) that are *not* described by the current metadata. In other words, without +this option, this task leaves untouched any "extra" tables that exist in the +database, but which aren't described by any metadata. Hint: If you have a database with tables that should not be managed by the ORM, you can use a DBAL functionality to filter the tables and sequences down @@ -71,17 +70,7 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $ { $notificationUi = $ui->getErrorStyle(); - // Defining if update is complete or not (--complete not defined means $saveMode = true) - $saveMode = ! $input->getOption('complete'); - - if ($saveMode) { - $notificationUi->warning(sprintf( - 'Not passing the "--complete" option to "%s" is deprecated and will not be supported when using doctrine/dbal 4', - $this->getName() ?? $this->name, - )); - } - - $sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode); + $sqls = $schemaTool->getUpdateSchemaSql($metadatas); if (empty($sqls)) { $notificationUi->success('Nothing to update - your database is already in sync with the current entity metadata.'); @@ -106,7 +95,7 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $ $notificationUi->text('Updating database schema...'); $notificationUi->newLine(); - $schemaTool->updateSchema($metadatas, $saveMode); + $schemaTool->updateSchema($metadatas); $pluralization = count($sqls) === 1 ? 'query was' : 'queries were'; diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index d676a51d5a1..a9fcc469590 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -12,7 +12,6 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; @@ -37,7 +36,6 @@ use function class_exists; use function count; use function current; -use function func_num_args; use function implode; use function in_array; use function is_numeric; @@ -885,24 +883,12 @@ public function getDropSchemaSQL(array $classes): array * instances to the current database schema that is inspected. * * @param mixed[] $classes - * @param bool $saveMode If TRUE, only performs a partial update - * without dropping assets which are scheduled for deletion. */ - public function updateSchema(array $classes, bool $saveMode = false): void + public function updateSchema(array $classes): void { - if (func_num_args() > 1) { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10153', - 'Passing $saveMode to %s() is deprecated and will not be possible in Doctrine ORM 3.0.', - __METHOD__, - ); - } + $conn = $this->em->getConnection(); - $updateSchemaSql = $this->getUpdateSchemaSql($classes, $saveMode); - $conn = $this->em->getConnection(); - - foreach ($updateSchemaSql as $sql) { + foreach ($this->getUpdateSchemaSql($classes) as $sql) { $conn->executeStatement($sql); } } @@ -911,32 +897,17 @@ public function updateSchema(array $classes, bool $saveMode = false): void * Gets the sequence of SQL statements that need to be performed in order * to bring the given class mappings in-synch with the relational schema. * - * @param bool $saveMode If TRUE, only generates SQL for a partial update - * that does not include SQL for dropping assets which are scheduled for deletion. - * @param list $classes The classes to consider. + * @param list $classes The classes to consider. * * @return list The sequence of SQL statements. */ - public function getUpdateSchemaSql(array $classes, bool $saveMode = false): array + public function getUpdateSchemaSql(array $classes): array { - if (func_num_args() > 1) { - Deprecation::triggerIfCalledFromOutside( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10153', - 'Passing $saveMode to %s() is deprecated and will not be possible in Doctrine ORM 3.0.', - __METHOD__, - ); - } - $toSchema = $this->getSchemaFromMetadata($classes); $fromSchema = $this->createSchemaForComparison($toSchema); $comparator = $this->schemaManager->createComparator(); $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); - if ($saveMode) { - return $schemaDiff->toSaveSql($this->platform); - } - return $this->platform->getAlterSchemaSQL($schemaDiff); } diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index b24b3b45f5d..207bc42d4ef 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -278,6 +278,6 @@ public function getUpdateSchemaList(): array $allMetadata = $this->em->getMetadataFactory()->getAllMetadata(); - return $schemaTool->getUpdateSchemaSql($allMetadata, true); + return $schemaTool->getUpdateSchemaSql($allMetadata); } } diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon index c8a65adb258..fa8291b8612 100644 --- a/phpstan-dbal4.neon +++ b/phpstan-dbal4.neon @@ -22,9 +22,3 @@ parameters: - message: '~Strict comparison using \=\=\= between callable\(\)\: mixed and null will always evaluate to false\.~' path: lib/Doctrine/ORM/Tools/SchemaTool.php - - # FIXME - - - message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Schema\\\\SchemaDiff\\:\\:toSaveSql\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Tools/SchemaTool.php diff --git a/psalm.xml b/psalm.xml index 98ba9239184..8e3f6f67f93 100644 --- a/psalm.xml +++ b/psalm.xml @@ -36,8 +36,6 @@ - - diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php deleted file mode 100644 index 7b55129cf08..00000000000 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/UpdateCommandTest.php +++ /dev/null @@ -1,60 +0,0 @@ -getCommandTester(UpdateCommand::class); - $tester->execute( - ['--dump-sql' => true], - ['capture_stderr_separately' => true], - ); - - self::$sharedConn->executeStatement($tester->getDisplay()); - } - - #[DataProvider('getCasesForWarningMessageFromCompleteOption')] - public function testWarningMessageFromCompleteOption(string|null $name, string $expectedMessage): void - { - if (! method_exists(SchemaDiff::class, 'toSaveSql')) { - self::markTestSkipped('This test requires DBAL 3'); - } - - $tester = $this->getCommandTester(UpdateCommand::class, $name); - $tester->execute( - [], - ['capture_stderr_separately' => true], - ); - - self::assertStringContainsString($expectedMessage, $tester->getErrorOutput()); - } - - public static function getCasesForWarningMessageFromCompleteOption(): iterable - { - yield 'default_name' => [ - null, - '[WARNING] Not passing the "--complete" option to "orm:schema-tool:update" is deprecated', - ]; - - yield 'custom_name' => [ - 'doctrine:schema:update', - '[WARNING] Not passing the "--complete" option to "doctrine:schema:update" is deprecated', - ]; - } -} From 0872d1429dc85c14c43dcc6a481924e1f0913d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 5 Jun 2023 23:37:00 +0200 Subject: [PATCH 290/475] Add missing upgrade notes --- UPGRADE.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 977ebc4dc58..de438b49484 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: `orm:schema-tool:update` option `--complete` is now a no-op + +`orm:schema-tool:update` now behaves as if `--complete` was provided, +regardless of whether it is provided or not. + ## BC BREAK: Removed `Doctrine\ORM\Proxy\Proxy` interface. Use `Doctrine\Persistence\Proxy` instead to check whether proxies are initialized. From f1d6ba8919018366421dadcc877020b858bcd06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 5 Jun 2023 23:39:08 +0200 Subject: [PATCH 291/475] Narrow types --- UPGRADE.md | 8 +++++ lib/Doctrine/ORM/Query.php | 31 ++----------------- .../Tests/ORM/Functional/PaginationTest.php | 2 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 14 --------- .../Pagination/CountOutputWalkerTest.php | 10 +++--- .../ORM/Tools/Pagination/CountWalkerTest.php | 14 ++++----- 6 files changed, 24 insertions(+), 55 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index de438b49484..a78a48cd024 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,13 @@ # Upgrade to 3.0 +## BC BREAK: `Query::setDQL()` and `Query::setFirstResult()` no longer accept `null` + +The `$dqlQuery` argument of `Doctrine\ORM\Query::setDQL()` must always be a +string. + +The `$firstResult` argument of `Doctrine\ORM\Query::setFirstResult()` must +always be an integer. + ## BC BREAK: `orm:schema-tool:update` option `--complete` is now a no-op `orm:schema-tool:update` now behaves as if `--complete` was provided, diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 5a2bc0f0533..0c8397e58ff 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Result; use Doctrine\DBAL\Types\Type; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query\AST\DeleteStatement; use Doctrine\ORM\Query\AST\SelectStatement; @@ -28,7 +27,6 @@ use function count; use function get_debug_type; use function in_array; -use function is_int; use function ksort; use function md5; use function reset; @@ -502,19 +500,8 @@ public function free(): void /** * Sets a DQL query string. */ - public function setDQL(string|null $dqlQuery): self + public function setDQL(string $dqlQuery): self { - if ($dqlQuery === null) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9784', - 'Calling %s with null is deprecated and will result in a TypeError in Doctrine 3.0', - __METHOD__, - ); - - return $this; - } - $this->dql = $dqlQuery; $this->state = self::STATE_DIRTY; @@ -558,24 +545,12 @@ public function contains(string $dql): bool /** * Sets the position of the first result to retrieve (the "offset"). * - * @param int|null $firstResult The first result to return. + * @param int $firstResult The first result to return. * * @return $this */ - public function setFirstResult(int|null $firstResult): self + public function setFirstResult(int $firstResult): self { - if (! is_int($firstResult)) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/9809', - 'Calling %s with %s is deprecated and will result in a TypeError in Doctrine 3.0. Pass an integer.', - __METHOD__, - get_debug_type($firstResult), - ); - - $firstResult = (int) $firstResult; - } - $this->firstResult = $firstResult; $this->state = self::STATE_DIRTY; diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index 52d35d1a6f5..db89c353d45 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -634,7 +634,7 @@ public function testCountQueryStripsParametersInSelect(): void ); $query->setParameter('vipMaxId', 10); $query->setParameter('id', 100); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); $paginator = new Paginator($query); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 3e4c2840a81..67039461394 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -127,20 +127,6 @@ public function testFluentQueryInterface(): void self::assertSame($q2, $q); } - public function testSettingNullDqlIsDeprecated(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9784'); - $q = $this->entityManager->createQuery(); - $q->setDQL(null); - } - - public function testSettingNullFirstResultIsDeprecated(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/9809'); - $q = $this->entityManager->createQuery(); - $q->setFirstResult(null); - } - #[Group('DDC-968')] public function testHints(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php index 0f0611bf4bb..0b64126628e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php @@ -16,7 +16,7 @@ public function testCountQuery(): void 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, c1_.id AS id_1, a2_.id AS id_2, a2_.name AS name_3, b0_.author_id AS author_id_4, b0_.category_id AS category_id_5 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id) dctrn_result) dctrn_table', @@ -30,7 +30,7 @@ public function testCountQueryMixedResultsWithName(): void 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result) dctrn_table', @@ -44,7 +44,7 @@ public function testCountQueryGroupBy(): void 'SELECT p.name FROM Doctrine\Tests\ORM\Tools\Pagination\Person p GROUP BY p.name', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertSame( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT p0_.name AS name_0 FROM Person p0_ GROUP BY p0_.name) dctrn_table', @@ -58,7 +58,7 @@ public function testCountQueryHaving(): void 'SELECT g, u, count(u.id) AS userCount FROM Doctrine\Tests\ORM\Tools\Pagination\Group g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertSame( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT count(u0_.id) AS sclr_0, g1_.id AS id_1, u0_.id AS id_2 FROM groups g1_ LEFT JOIN user_group u2_ ON g1_.id = u2_.group_id LEFT JOIN User u0_ ON u0_.id = u2_.user_id GROUP BY g1_.id HAVING sclr_0 > 0) dctrn_table', @@ -77,7 +77,7 @@ public function testCountQueryOrderBySqlServer(): void 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p ORDER BY p.id', ); $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, CountOutputWalker::class); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_) dctrn_result) dctrn_table', diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index 804cb54cf93..5af90e87949 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -19,7 +19,7 @@ public function testCountQuery(): void ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', @@ -34,7 +34,7 @@ public function testCountQueryMixedResultsWithName(): void ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT count(DISTINCT a0_.id) AS sclr_0 FROM Author a0_', @@ -49,7 +49,7 @@ public function testCountQueryKeepsGroupBy(): void ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ GROUP BY b0_.id', @@ -64,7 +64,7 @@ public function testCountQueryRemovesOrderBy(): void ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', @@ -79,7 +79,7 @@ public function testCountQueryRemovesLimits(): void ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', @@ -93,7 +93,7 @@ public function testCountQueryHavingException(): void 'SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0', ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); @@ -111,7 +111,7 @@ public function testCountQueryWithArbitraryJoin(): void ); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); $query->setHint(CountWalker::HINT_DISTINCT, true); - $query->setFirstResult(null)->setMaxResults(null); + $query->setFirstResult(0)->setMaxResults(null); self::assertEquals( 'SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ LEFT JOIN Category c1_ ON (b0_.category_id = c1_.id)', From a2a4f73b306d417a4d0d5ef47c7b3735223dd8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 5 Jun 2023 23:49:44 +0200 Subject: [PATCH 292/475] Enforce reporting fields where declared --- UPGRADE.md | 7 +++++ .../ORM/Mapping/Driver/AttributeDriver.php | 26 +++++++++---------- .../Mapping/Driver/ReflectionBasedDriver.php | 10 ------- phpstan.neon | 5 ++++ psalm.xml | 2 ++ .../Tests/ORM/Mapping/AttributeDriverTest.php | 8 ++++++ 6 files changed, 35 insertions(+), 23 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index a78a48cd024..b273948af96 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,12 @@ # Upgrade to 3.0 +## BC BREAK: `Mapping\Driver\AttributeDriver::__construct()` second argument is now a no-op + +The second argument to +`Doctrine\ORM\Mapping\Driver\AttributeDriver::__construct()` was introduced to +let users opt-in to a new behavior, that is now always enforced, regardless of +the value of that argument. + ## BC BREAK: `Query::setDQL()` and `Query::setFirstResult()` no longer accept `null` The `$dqlQuery` argument of `Doctrine\ORM\Query::setDQL()` must always be a diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php index 4ee57688bbb..db0fd7a6fa9 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Mapping\Driver; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping; use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; @@ -13,6 +12,7 @@ use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; use Doctrine\Persistence\Mapping\Driver\ColocatedMappingDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriver; +use InvalidArgumentException; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; @@ -21,6 +21,7 @@ use function class_exists; use function constant; use function defined; +use function sprintf; class AttributeDriver implements MappingDriver { @@ -34,22 +35,21 @@ class AttributeDriver implements MappingDriver private readonly AttributeReader $reader; - /** @param array $paths */ - public function __construct(array $paths, bool $reportFieldsWhereDeclared = false) + /** + * @param array $paths + * @param true $reportFieldsWhereDeclared no-op, to be removed in 4.0 + */ + public function __construct(array $paths, bool $reportFieldsWhereDeclared = true) { - $this->reader = new AttributeReader(); - $this->addPaths($paths); - if (! $reportFieldsWhereDeclared) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10455', - 'In ORM 3.0, the AttributeDriver will report fields for the classes where they are declared. This may uncover invalid mapping configurations. To opt into the new mode today, set the "reportFieldsWhereDeclared" constructor parameter to true.', - self::class, - ); + throw new InvalidArgumentException(sprintf( + 'The $reportFieldsWhereDeclared argument is no longer supported, make sure to omit it when calling %s.', + __METHOD__, + )); } - $this->reportFieldsWhereDeclared = $reportFieldsWhereDeclared; + $this->reader = new AttributeReader(); + $this->addPaths($paths); } public function isTransient(string $className): bool diff --git a/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php b/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php index 6ac89026bd3..2e8ce049acf 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php @@ -10,9 +10,6 @@ /** @internal */ trait ReflectionBasedDriver { - /** @var bool */ - private $reportFieldsWhereDeclared = false; - /** * Helps to deal with the case that reflection may report properties inherited from parent classes. * When we know about the fields already (inheritance has been anticipated in ClassMetadataFactory), @@ -25,13 +22,6 @@ trait ReflectionBasedDriver */ private function isRepeatedPropertyDeclaration(ReflectionProperty $property, ClassMetadata $metadata): bool { - if (! $this->reportFieldsWhereDeclared) { - return $metadata->isMappedSuperclass && ! $property->isPrivate() - || $metadata->isInheritedField($property->name) - || $metadata->isInheritedAssociation($property->name) - || $metadata->isInheritedEmbeddedClass($property->name); - } - $declaringClass = $property->getDeclaringClass()->getName(); if ( diff --git a/phpstan.neon b/phpstan.neon index 64ba5330a14..7d179fcde76 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -55,3 +55,8 @@ parameters: message: '#^.*QuoteStrategy::getJoinTableName\(\) expects.*$#' paths: - lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php + + # To be removed in 4.0 + - + message: '#Negated boolean expression is always false\.#' + path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php diff --git a/psalm.xml b/psalm.xml index 8e3f6f67f93..95efc019f07 100644 --- a/psalm.xml +++ b/psalm.xml @@ -48,6 +48,8 @@ + + diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index 880f20c7100..b16ec788d33 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\MappingAttribute; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Tests\ORM\Mapping\Fixtures\AttributeEntityWithNestedJoinColumns; +use InvalidArgumentException; use stdClass; class AttributeDriverTest extends MappingDriverTestCase @@ -87,6 +88,13 @@ public function testManyToManyAssociationWithNestedJoinColumns(): void $metadata->associationMappings['assoc']->joinTable->inverseJoinColumns, ); } + + public function testItThrowsWhenSettingReportFieldsWhereDeclaredToFalse(): void + { + $this->expectException(InvalidArgumentException::class); + + new AttributeDriver([], false); + } } #[ORM\Entity] From 575d0c03eeb120bd63f78df1903064450a6e7cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 5 Jun 2023 23:55:32 +0200 Subject: [PATCH 293/475] Reject non instances of ORM\ClassMetadata --- lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index c3f75aea58e..49e2e93520c 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -10,7 +10,6 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; -use Doctrine\Deprecations\Deprecation; use Doctrine\Inflector\Inflector; use Doctrine\Inflector\InflectorFactory; use Doctrine\ORM\Mapping\ClassMetadata; @@ -18,6 +17,7 @@ use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; use Doctrine\Persistence\Mapping\Driver\MappingDriver; use InvalidArgumentException; +use TypeError; use function array_diff; use function array_keys; @@ -25,9 +25,11 @@ use function assert; use function count; use function current; +use function get_debug_type; use function in_array; use function preg_replace; use function sort; +use function sprintf; use function strtolower; /** @@ -157,14 +159,12 @@ public function setInflector(Inflector $inflector): void public function loadMetadataForClass(string $className, PersistenceClassMetadata $metadata): void { if (! $metadata instanceof ClassMetadata) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/249', - 'Passing an instance of %s to %s is deprecated, please pass a %s instance instead.', - $metadata::class, + throw new TypeError(sprintf( + 'Argument #2 passed to %s() must be an instance of %s, %s given.', __METHOD__, ClassMetadata::class, - ); + get_debug_type($metadata), + )); } $this->reverseEngineerMappingFromDatabase(); From 0dad2daf2cc201baa58a496101acb1d404bd78b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 6 Jun 2023 23:10:09 +0200 Subject: [PATCH 294/475] Enable XML validation unconditionally Note that this makes ext-dom a hard requirement when using the XML driver. --- UPGRADE.md | 11 +++ docs/en/reference/xml-mapping.rst | 3 +- .../Mapping/Driver/SimplifiedXmlDriver.php | 14 ++- lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 23 ++--- lib/Doctrine/ORM/ORMSetup.php | 12 ++- phpstan.neon | 6 +- psalm.xml | 2 + .../Models/OrnementalOrphanRemoval/Person.php | 11 --- .../OrnementalOrphanRemoval/PhoneNumber.php | 17 ---- .../Functional/ManyToOneOrphanRemovalTest.php | 94 ------------------- ...els.OrnementalOrphanRemoval.Person.dcm.xml | 12 --- ...rnementalOrphanRemoval.PhoneNumber.dcm.xml | 15 --- .../ORM/Mapping/XmlMappingDriverTest.php | 12 +++ tests/Doctrine/Tests/ORM/ORMSetupTest.php | 8 ++ 14 files changed, 71 insertions(+), 169 deletions(-) delete mode 100644 tests/Doctrine/Tests/Models/OrnementalOrphanRemoval/Person.php delete mode 100644 tests/Doctrine/Tests/Models/OrnementalOrphanRemoval/PhoneNumber.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/ManyToOneOrphanRemovalTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/xml/Doctrine.Tests.Models.OrnementalOrphanRemoval.Person.dcm.xml delete mode 100644 tests/Doctrine/Tests/ORM/Functional/xml/Doctrine.Tests.Models.OrnementalOrphanRemoval.PhoneNumber.dcm.xml diff --git a/UPGRADE.md b/UPGRADE.md index b273948af96..ec667393cfc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,16 @@ # Upgrade to 3.0 +## BC BREAK: `Mapping\Driver\XmlDriver::__construct()` third argument is now a no-op + +The third argument to +`Doctrine\ORM\Mapping\Driver\XmlDriver::__construct()` was introduced to +let users opt-in to XML validation, that is now always enabled, regardless of +the value of that argument. + +As a consequence, the same goes for +`Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver`, and for +`Doctrine\ORM\ORMSetup::createXMLMetadataConfiguration()`. + ## BC BREAK: `Mapping\Driver\AttributeDriver::__construct()` second argument is now a no-op The second argument to diff --git a/docs/en/reference/xml-mapping.rst b/docs/en/reference/xml-mapping.rst index 67edc4a4965..12930597b85 100644 --- a/docs/en/reference/xml-mapping.rst +++ b/docs/en/reference/xml-mapping.rst @@ -2,7 +2,8 @@ XML Mapping =========== The XML mapping driver enables you to provide the ORM metadata in -form of XML documents. +form of XML documents. It requires the ``dom`` extension in order to be +able to validate your mapping documents against its XML Schema. The XML driver is backed by an XML Schema document that describes the structure of a mapping document. The most recent version of the diff --git a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php index 4ea9e556aa8..24b29eaf770 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php @@ -5,6 +5,9 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator; +use InvalidArgumentException; + +use function sprintf; /** * XmlDriver that additionally looks for mapping information in a global file. @@ -16,10 +19,17 @@ class SimplifiedXmlDriver extends XmlDriver /** * {@inheritDoc} */ - public function __construct($prefixes, $fileExtension = self::DEFAULT_FILE_EXTENSION, bool $isXsdValidationEnabled = false) + public function __construct($prefixes, $fileExtension = self::DEFAULT_FILE_EXTENSION, bool $isXsdValidationEnabled = true) { + if (! $isXsdValidationEnabled) { + throw new InvalidArgumentException(sprintf( + 'The $isXsdValidationEnabled argument is no longer supported, make sure to omit it when calling %s.', + __METHOD__, + )); + } + $locator = new SymfonyFileLocator((array) $prefixes, $fileExtension); - parent::__construct($locator, $fileExtension, $isXsdValidationEnabled); + parent::__construct($locator, $fileExtension); } } diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 31677cb4d7e..3e0c0228822 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -5,7 +5,6 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Common\Collections\Criteria; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\MappingException; @@ -44,11 +43,13 @@ class XmlDriver extends FileDriver /** * {@inheritDoc} + * + * @param true $isXsdValidationEnabled no-op, will be removed in 4.0 */ public function __construct( string|array|FileLocator $locator, string $fileExtension = self::DEFAULT_FILE_EXTENSION, - private readonly bool $isXsdValidationEnabled = false, + bool $isXsdValidationEnabled = true, ) { if (! extension_loaded('simplexml')) { throw new LogicException(sprintf( @@ -58,17 +59,13 @@ public function __construct( } if (! $isXsdValidationEnabled) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/6728', - sprintf( - 'Using XML mapping driver with XSD validation disabled is deprecated' - . ' and will not be supported in Doctrine ORM 3.0.', - ), - ); + throw new InvalidArgumentException(sprintf( + 'The $isXsdValidationEnabled argument is no longer supported, make sure to omit it when calling %s.', + __METHOD__, + )); } - if ($isXsdValidationEnabled && ! extension_loaded('dom')) { + if (! extension_loaded('dom')) { throw new LogicException(sprintf( 'XSD validation cannot be enabled because the DOM extension is missing.', )); @@ -947,10 +944,6 @@ protected function loadMappingFile($file) private function validateMapping(string $file): void { - if (! $this->isXsdValidationEnabled) { - return; - } - $backedUpErrorSetting = libxml_use_internal_errors(true); try { diff --git a/lib/Doctrine/ORM/ORMSetup.php b/lib/Doctrine/ORM/ORMSetup.php index dfa98243c17..8a456f15a0c 100644 --- a/lib/Doctrine/ORM/ORMSetup.php +++ b/lib/Doctrine/ORM/ORMSetup.php @@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; +use InvalidArgumentException; use Psr\Cache\CacheItemPoolInterface; use Redis; use RuntimeException; @@ -18,6 +19,7 @@ use function class_exists; use function extension_loaded; use function md5; +use function sprintf; use function sys_get_temp_dir; final class ORMSetup @@ -43,14 +45,22 @@ public static function createAttributeMetadataConfiguration( * Creates a configuration with an XML metadata driver. * * @param string[] $paths + * @param true $isXsdValidationEnabled */ public static function createXMLMetadataConfiguration( array $paths, bool $isDevMode = false, string|null $proxyDir = null, CacheItemPoolInterface|null $cache = null, - bool $isXsdValidationEnabled = false, + bool $isXsdValidationEnabled = true, ): Configuration { + if (! $isXsdValidationEnabled) { + throw new InvalidArgumentException(sprintf( + 'The $isXsdValidationEnabled argument is no longer supported, make sure to omit it when calling %s.', + __METHOD__, + )); + } + $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new XmlDriver($paths, XmlDriver::DEFAULT_FILE_EXTENSION, $isXsdValidationEnabled)); diff --git a/phpstan.neon b/phpstan.neon index 7d179fcde76..b69b689fb6e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -59,4 +59,8 @@ parameters: # To be removed in 4.0 - message: '#Negated boolean expression is always false\.#' - path: lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php + paths: + - lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php + - lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php + - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php + - lib/Doctrine/ORM/ORMSetup.php diff --git a/psalm.xml b/psalm.xml index 95efc019f07..6c75f508e53 100644 --- a/psalm.xml +++ b/psalm.xml @@ -50,6 +50,8 @@ + + diff --git a/tests/Doctrine/Tests/Models/OrnementalOrphanRemoval/Person.php b/tests/Doctrine/Tests/Models/OrnementalOrphanRemoval/Person.php deleted file mode 100644 index fcf7cc7891a..00000000000 --- a/tests/Doctrine/Tests/Models/OrnementalOrphanRemoval/Person.php +++ /dev/null @@ -1,11 +0,0 @@ -> */ - protected static $modelSets = [ - 'ornemental_orphan_removal' => [ - Person::class, - PhoneNumber::class, - ], - ]; - - protected function setUp(): void - { - $this->useModelSet('ornemental_orphan_removal'); - - parent::setUp(); - - $person = new Person(); - $person->id = 'ca41a293-799f-4d68-bf79-626c3ad223ec'; - - $phone1 = new PhoneNumber(); - $phone1->id = 'f4132478-c492-4dfe-aab5-a5b79ae129e7'; - $phone1->phonenumber = '123456'; - - $phone2 = new PhoneNumber(); - $phone2->id = '7faa4cd3-a155-4fbf-bc42-aa4269a4454d'; - $phone2->phonenumber = '234567'; - - $phone1->person = $person; - $phone2->person = $person; - - $this->_em->persist($phone1); - $this->_em->persist($phone2); - $this->_em->persist($person); - $this->_em->flush(); - - $this->personId = $person->id; - $this->_em->clear(); - } - - public function testOrphanRemovalIsPurelyOrnemental(): void - { - $person = $this->_em->getReference(Person::class, $this->personId); - - $this->_em->remove($person); - $this->_em->flush(); - $this->_em->clear(); - - $query = $this->_em->createQuery( - 'SELECT u FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\Person u', - ); - $result = $query->getResult(); - - self::assertEquals(0, count($result), 'Person should be removed by EntityManager'); - - $query = $this->_em->createQuery( - 'SELECT p FROM Doctrine\Tests\Models\OrnementalOrphanRemoval\PhoneNumber p', - ); - $result = $query->getResult(); - - self::assertEquals(2, count($result), 'Orphan removal should not kick in'); - } - - protected function getEntityManager( - Connection|null $connection = null, - MappingDriver|null $mappingDriver = null, - ): EntityManagerInterface { - return parent::getEntityManager($connection, new XmlDriver( - __DIR__ . DIRECTORY_SEPARATOR . 'xml', - )); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/xml/Doctrine.Tests.Models.OrnementalOrphanRemoval.Person.dcm.xml b/tests/Doctrine/Tests/ORM/Functional/xml/Doctrine.Tests.Models.OrnementalOrphanRemoval.Person.dcm.xml deleted file mode 100644 index 661061c1c4c..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/xml/Doctrine.Tests.Models.OrnementalOrphanRemoval.Person.dcm.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Functional/xml/Doctrine.Tests.Models.OrnementalOrphanRemoval.PhoneNumber.dcm.xml b/tests/Doctrine/Tests/ORM/Functional/xml/Doctrine.Tests.Models.OrnementalOrphanRemoval.PhoneNumber.dcm.xml deleted file mode 100644 index 7b19b1a62a2..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/xml/Doctrine.Tests.Models.OrnementalOrphanRemoval.PhoneNumber.dcm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 6d439ca658c..6de53be45c8 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -29,6 +29,7 @@ use Doctrine\Tests\Models\Project\ProjectName; use Doctrine\Tests\Models\ValueObjects\Name; use Doctrine\Tests\Models\ValueObjects\Person; +use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -299,6 +300,17 @@ public function testClassNameInFieldOrId(): void self::assertEquals(ProjectId::class, $id['type']); self::assertEquals(ProjectName::class, $name['type']); } + + public function testDisablingXmlValidationIsNotPossible(): void + { + $this->expectException(InvalidArgumentException::class); + + new XmlDriver( + __DIR__ . DIRECTORY_SEPARATOR . 'xml', + XmlDriver::DEFAULT_FILE_EXTENSION, + false, + ); + } } class CTI diff --git a/tests/Doctrine/Tests/ORM/ORMSetupTest.php b/tests/Doctrine/Tests/ORM/ORMSetupTest.php index 1da12828147..fc950699c59 100644 --- a/tests/Doctrine/Tests/ORM/ORMSetupTest.php +++ b/tests/Doctrine/Tests/ORM/ORMSetupTest.php @@ -9,6 +9,7 @@ use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\ORMSetup; +use InvalidArgumentException; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; @@ -39,6 +40,13 @@ public function testXMLConfiguration(): void self::assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); } + public function testDisablingXmlValidationIsNotPossible(): void + { + $this->expectException(InvalidArgumentException::class); + + ORMSetup::createXMLMetadataConfiguration(paths: [], isXsdValidationEnabled: false); + } + #[RequiresPhpExtension('apcu')] public function testCacheNamespaceShouldBeGeneratedForApcu(): void { From 716139c168e1e5b214aa6b6fb6393cbc2b615f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 7 Jun 2023 21:15:07 +0200 Subject: [PATCH 295/475] Remove Notify change tracking policy --- UPGRADE.md | 4 + ...nting-the-notify-changetracking-policy.rst | 75 ------- docs/en/index.rst | 1 - docs/en/reference/attributes-reference.rst | 1 - .../en/reference/change-tracking-policies.rst | 121 +---------- docs/en/reference/php-mapping.rst | 2 - docs/en/sidebar.rst | 1 - docs/en/toc.rst | 1 - doctrine-mapping.xsd | 1 - .../Mapping/Builder/ClassMetadataBuilder.php | 12 -- .../ORM/Mapping/ChangeTrackingPolicy.php | 2 +- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 15 -- .../ORM/Mapping/ClassMetadataFactory.php | 10 - lib/Doctrine/ORM/PersistentCollection.php | 11 - lib/Doctrine/ORM/UnitOfWork.php | 36 +--- .../Tests/ORM/Functional/NotifyPolicyTest.php | 202 ------------------ .../ORM/Functional/Ticket/DDC1690Test.php | 184 ---------------- .../ORM/Functional/Ticket/DDC2230Test.php | 86 -------- .../ORM/Mapping/ClassMetadataBuilderTest.php | 6 - tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 144 ------------- 20 files changed, 8 insertions(+), 907 deletions(-) delete mode 100644 docs/en/cookbook/implementing-the-notify-changetracking-policy.rst delete mode 100644 tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php diff --git a/UPGRADE.md b/UPGRADE.md index ec667393cfc..ecc71453253 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: The `NOTIFY` change tracking policy is removed + +You should use `DEFERRED_EXPLICIT` instead. + ## BC BREAK: `Mapping\Driver\XmlDriver::__construct()` third argument is now a no-op The third argument to diff --git a/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst b/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst deleted file mode 100644 index a47be84762d..00000000000 --- a/docs/en/cookbook/implementing-the-notify-changetracking-policy.rst +++ /dev/null @@ -1,75 +0,0 @@ -Implementing the Notify ChangeTracking Policy -============================================= - -.. sectionauthor:: Roman Borschel (roman@code-factory.org) - -The NOTIFY change-tracking policy is the most effective -change-tracking policy provided by Doctrine but it requires some -boilerplate code. This recipe will show you how this boilerplate -code should look like. We will implement it on a -`Layer Supertype `_ -for all our domain objects. - -.. note:: - - The notify change tracking policy is deprecated and will be removed in ORM 3.0. - (`Details `_) - -Implementing NotifyPropertyChanged ----------------------------------- - -The NOTIFY policy is based on the assumption that the entities -notify interested listeners of changes to their properties. For -that purpose, a class that wants to use this policy needs to -implement the ``NotifyPropertyChanged`` interface from the -``Doctrine\Common`` namespace. - -.. code-block:: php - - listeners[] = $listener; - } - - /** Notifies listeners of a change. */ - protected function onPropertyChanged($propName, $oldValue, $newValue) { - if ($this->listeners) { - foreach ($this->listeners as $listener) { - $listener->propertyChanged($this, $propName, $oldValue, $newValue); - } - } - } - } - -Then, in each property setter of concrete, derived domain classes, -you need to invoke onPropertyChanged as follows to notify -listeners: - -.. code-block:: php - - data) { // check: is it actually modified? - $this->onPropertyChanged('data', $this->data, $data); - $this->data = $data; - } - } - } - -The check whether the new value is different from the old one is -not mandatory but recommended. That way you can avoid unnecessary -updates and also have full control over when you consider a -property changed. diff --git a/docs/en/index.rst b/docs/en/index.rst index 856d5b0a28a..fdbe3793d46 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -110,7 +110,6 @@ Cookbook * **Implementation**: :doc:`Array Access ` | - :doc:`Notify ChangeTracking Example ` | :doc:`Working with DateTime ` | :doc:`Validation ` | :doc:`Entities in the Session ` | diff --git a/docs/en/reference/attributes-reference.rst b/docs/en/reference/attributes-reference.rst index 93ad3c69152..d537a119ab0 100644 --- a/docs/en/reference/attributes-reference.rst +++ b/docs/en/reference/attributes-reference.rst @@ -311,7 +311,6 @@ Example: Entity, ChangeTrackingPolicy("DEFERRED_IMPLICIT"), ChangeTrackingPolicy("DEFERRED_EXPLICIT"), - ChangeTrackingPolicy("NOTIFY") ] class User {} diff --git a/docs/en/reference/change-tracking-policies.rst b/docs/en/reference/change-tracking-policies.rst index 2f72ec80705..3d2c2183065 100644 --- a/docs/en/reference/change-tracking-policies.rst +++ b/docs/en/reference/change-tracking-policies.rst @@ -5,7 +5,7 @@ Change tracking is the process of determining what has changed in managed entities since the last time they were synchronized with the database. -Doctrine provides 3 different change tracking policies, each having +Doctrine provides 2 different change tracking policies, each having its particular advantages and disadvantages. The change tracking policy can be defined on a per-class basis (or more precisely, per-hierarchy). @@ -56,122 +56,3 @@ This policy can be configured as follows: { // ... } - -Notify -~~~~~~ - -.. note:: - - The notify change tracking policy is deprecated and will be removed in ORM 3.0. - (`Details `_) - -This policy is based on the assumption that the entities notify -interested listeners of changes to their properties. For that -purpose, a class that wants to use this policy needs to implement -the ``NotifyPropertyChanged`` interface from the Doctrine -namespace. As a guideline, such an implementation can look as -follows: - -.. code-block:: php - - _listeners[] = $listener; - } - } - -Then, in each property setter of this class or derived classes, you -need to notify all the ``PropertyChangedListener`` instances. As an -example we add a convenience method on ``MyEntity`` that shows this -behaviour: - -.. code-block:: php - - _listeners) { - foreach ($this->_listeners as $listener) { - $listener->propertyChanged($this, $propName, $oldValue, $newValue); - } - } - } - - public function setData($data): void - { - if ($data != $this->data) { - $this->_onPropertyChanged('data', $this->data, $data); - $this->data = $data; - } - } - } - -You have to invoke ``_onPropertyChanged`` inside every method that -changes the persistent state of ``MyEntity``. - -The check whether the new value is different from the old one is -not mandatory but recommended. That way you also have full control -over when you consider a property changed. - -If your entity contains an embeddable, you will need to notify -separately for each property in the embeddable when it changes -for example: - -.. code-block:: php - - equals($this->embeddable)) { - // notice the entityField.embeddableField notation for referencing the property - $this->_onPropertyChanged('embeddable.prop1', $this->embeddable->getProp1(), $embeddable->getProp1()); - $this->_onPropertyChanged('embeddable.prop2', $this->embeddable->getProp2(), $embeddable->getProp2()); - $this->embeddable = $embeddable; - } - } - } - -This would update all the fields of the embeddable, you may wish to -implement a diff method on your embedded object which returns only -the changed fields. - -The negative point of this policy is obvious: You need implement an -interface and write some plumbing code. But also note that we tried -hard to keep this notification functionality abstract. Strictly -speaking, it has nothing to do with the persistence layer and the -Doctrine ORM or DBAL. You may find that property notification -events come in handy in many other scenarios as well. As mentioned -earlier, the ``Doctrine\Common`` namespace is not that evil and -consists solely of very small classes and interfaces that have -almost no external dependencies (none to the DBAL and none to the -ORM) and that you can easily take with you should you want to swap -out the persistence layer. This change tracking policy does not -introduce a dependency on the Doctrine DBAL/ORM or the persistence -layer. - -The positive point and main advantage of this policy is its -effectiveness. It has the best performance characteristics of the 3 -policies with larger units of work and a flush() operation is very -cheap when nothing has changed. diff --git a/docs/en/reference/php-mapping.rst b/docs/en/reference/php-mapping.rst index d4de32a1386..e869dcda964 100644 --- a/docs/en/reference/php-mapping.rst +++ b/docs/en/reference/php-mapping.rst @@ -92,7 +92,6 @@ The API of the ClassMetadataBuilder has the following methods with a fluent inte - ``setDiscriminatorColumn($name, $type = 'string', $length = 255, $columnDefinition = null, $enumType = null, $options = [])`` - ``addDiscriminatorMapClass($name, $class)`` - ``setChangeTrackingPolicyDeferredExplicit()`` -- ``setChangeTrackingPolicyNotify()`` - ``addLifecycleEvent($methodName, $event)`` - ``addManyToOne($name, $targetEntity, $inversedBy = null)`` - ``addInverseOneToOne($name, $targetEntity, $mappedBy)`` @@ -203,7 +202,6 @@ Change Tracking Getters - ``isChangeTrackingDeferredExplicit()`` - ``isChangeTrackingDeferredImplicit()`` -- ``isChangeTrackingNotify()`` Field & Association Getters ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/en/sidebar.rst b/docs/en/sidebar.rst index 345dd8634e4..460e4236948 100644 --- a/docs/en/sidebar.rst +++ b/docs/en/sidebar.rst @@ -70,7 +70,6 @@ cookbook/dql-custom-walkers cookbook/dql-user-defined-functions cookbook/implementing-arrayaccess-for-domain-objects - cookbook/implementing-the-notify-changetracking-policy cookbook/resolve-target-entity-listener cookbook/sql-table-prefixes cookbook/strategy-cookbook-introduction diff --git a/docs/en/toc.rst b/docs/en/toc.rst index 46ee053ef86..c529bc5b63d 100644 --- a/docs/en/toc.rst +++ b/docs/en/toc.rst @@ -72,7 +72,6 @@ Cookbook cookbook/dql-custom-walkers cookbook/dql-user-defined-functions cookbook/implementing-arrayaccess-for-domain-objects - cookbook/implementing-the-notify-changetracking-policy cookbook/resolve-target-entity-listener cookbook/sql-table-prefixes cookbook/strategy-cookbook-introduction diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index 9be212da18f..058825b11aa 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -198,7 +198,6 @@ - diff --git a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php index 5ea96e384fe..0f208f29139 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php @@ -220,18 +220,6 @@ public function setChangeTrackingPolicyDeferredExplicit(): static return $this; } - /** - * Sets notify change tracking policy. - * - * @return $this - */ - public function setChangeTrackingPolicyNotify(): static - { - $this->cm->setChangeTrackingPolicy(ClassMetadata::CHANGETRACKING_NOTIFY); - - return $this; - } - /** * Adds lifecycle event. * diff --git a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php index fb02c4339e6..7181d9f6f1c 100644 --- a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php +++ b/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php @@ -9,7 +9,7 @@ #[Attribute(Attribute::TARGET_CLASS)] final class ChangeTrackingPolicy implements MappingAttribute { - /** @psalm-param 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT'|'NOTIFY' $value */ + /** @psalm-param 'DEFERRED_IMPLICIT'|'DEFERRED_EXPLICIT' $value */ public function __construct( public readonly string $value, ) { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 5de587efa2e..f774fa90853 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -136,13 +136,6 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable */ public const CHANGETRACKING_DEFERRED_EXPLICIT = 2; - /** - * NOTIFY means that Doctrine relies on the entities sending out notifications - * when their properties change. Such entity classes must implement - * the NotifyPropertyChanged interface. - */ - public const CHANGETRACKING_NOTIFY = 3; - /** * Specifies that an association is to be fetched when it is first accessed. */ @@ -1009,14 +1002,6 @@ public function isChangeTrackingDeferredImplicit(): bool return $this->changeTrackingPolicy === self::CHANGETRACKING_DEFERRED_IMPLICIT; } - /** - * Whether the change tracking policy of this class is "notify". - */ - public function isChangeTrackingNotify(): bool - { - return $this->changeTrackingPolicy === self::CHANGETRACKING_NOTIFY; - } - /** * Checks whether a field is part of the identifier/primary key field(s). */ diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index e4a7ef419c2..591fcfb4fe0 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -7,7 +7,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Platforms; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Event\LoadClassMetadataEventArgs; use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; @@ -236,15 +235,6 @@ protected function doLoadMetadata( $this->findAbstractEntityClassesNotListedInDiscriminatorMap($class); - if ($class->changeTrackingPolicy === ClassMetadata::CHANGETRACKING_NOTIFY) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8383', - 'NOTIFY Change Tracking policy used in "%s" is deprecated, use deferred explicit instead.', - $class->name, - ); - } - $this->validateRuntimeMetadata($class, $parent); } diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 4322ab768b8..c42807537ef 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -11,7 +11,6 @@ use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Mapping\ManyToManyOwningSideMapping; use Doctrine\ORM\Mapping\ToManyAssociationMapping; use RuntimeException; use UnexpectedValueException; @@ -267,16 +266,6 @@ private function changed(): void } $this->isDirty = true; - - if ( - $this->association !== null && - $this->association instanceof ManyToManyOwningSideMapping && - $this->owner && - $this->em !== null && - $this->em->getClassMetadata($this->owner::class)->isChangeTrackingNotify() - ) { - $this->getUnitOfWork()->scheduleForDirtyCheck($this->owner); - } } /** diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 0092f9ffe45..ff06980d7ab 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -41,7 +41,6 @@ use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister; use Doctrine\ORM\Persisters\Entity\SingleTablePersister; use Doctrine\ORM\Utility\IdentifierFlattener; -use Doctrine\Persistence\NotifyPropertyChanged; use Doctrine\Persistence\PropertyChangedListener; use Doctrine\Persistence\Proxy; use Exception; @@ -623,11 +622,8 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void } else { // Entity is "fully" MANAGED: it was already fully persisted before // and we have a copy of the original data - $originalData = $this->originalEntityData[$oid]; - $isChangeTrackingNotify = $class->isChangeTrackingNotify(); - $changeSet = $isChangeTrackingNotify && isset($this->entityChangeSets[$oid]) - ? $this->entityChangeSets[$oid] - : []; + $originalData = $this->originalEntityData[$oid]; + $changeSet = []; foreach ($actualData as $propName => $actualValue) { // skip field, its a partially omitted one! @@ -658,10 +654,6 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void // if regular field if (! isset($class->associationMappings[$propName])) { - if ($isChangeTrackingNotify) { - continue; - } - $changeSet[$propName] = [$orgValue, $actualValue]; continue; @@ -944,11 +936,6 @@ public function recomputeSingleEntityChangeSet(ClassMetadata $class, object $ent throw ORMInvalidArgumentException::entityNotManaged($entity); } - // skip if change tracking is "NOTIFY" - if ($class->isChangeTrackingNotify()) { - return; - } - if (! $class->isInheritanceTypeNone()) { $class = $this->em->getClassMetadata($entity::class); } @@ -1256,10 +1243,6 @@ public function scheduleForInsert(object $entity): void if (isset($this->entityIdentifiers[$oid])) { $this->addToIdentityMap($entity); } - - if ($entity instanceof NotifyPropertyChanged) { - $entity->addPropertyChangedListener($this); - } } /** @@ -2285,10 +2268,6 @@ public function createEntity(string $className, array $data, array &$hints = []) } } - if ($entity instanceof NotifyPropertyChanged) { - $entity->addPropertyChangedListener($this); - } - foreach ($data as $field => $value) { if (isset($class->fieldMappings[$field])) { $class->reflFields[$field]->setValue($entity, $value); @@ -2452,13 +2431,6 @@ public function createEntity(string $className, array $data, array &$hints = []) $this->entityIdentifiers[$newValueOid] = $associatedId; $this->identityMap[$targetClass->rootEntityName][$relatedIdHash] = $newValue; - if ( - $newValue instanceof NotifyPropertyChanged && - ( ! $newValue instanceof Proxy || $newValue->__isInitialized()) - ) { - $newValue->addPropertyChangedListener($this); - } - $this->entityStates[$newValueOid] = self::STATE_MANAGED; // make sure that when an proxy is then finally loaded, $this->originalEntityData is set also! break; @@ -2763,10 +2735,6 @@ public function registerManaged(object $entity, array $id, array $data): void $this->originalEntityData[$oid] = $data; $this->addToIdentityMap($entity); - - if ($entity instanceof NotifyPropertyChanged && ( ! $entity instanceof Proxy || $entity->__isInitialized())) { - $entity->addPropertyChangedListener($this); - } } /* PropertyChangedListener implementation */ diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php deleted file mode 100644 index b3e57e369bc..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ /dev/null @@ -1,202 +0,0 @@ -expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8383'); - - $this->createSchemaForModels(NotifyUser::class, NotifyGroup::class); - } - - public function testChangeTracking(): void - { - $user = new NotifyUser(); - $group = new NotifyGroup(); - $user->setName('roman'); - $group->setName('dev'); - - $user->getGroups()->add($group); - $group->getUsers()->add($user); - - $this->_em->persist($user); - $this->_em->persist($group); - - self::assertCount(1, $user->listeners); - self::assertCount(1, $group->listeners); - - $this->_em->flush(); - $this->_em->clear(); - - self::assertCount(1, $user->listeners); - self::assertCount(1, $group->listeners); - - $userId = $user->getId(); - $groupId = $group->getId(); - unset($user, $group); - - $user = $this->_em->find(NotifyUser::class, $userId); - self::assertEquals(1, $user->getGroups()->count()); - $group = $this->_em->find(NotifyGroup::class, $groupId); - self::assertEquals(1, $group->getUsers()->count()); - - self::assertCount(1, $user->listeners); - self::assertCount(1, $group->listeners); - - $group2 = new NotifyGroup(); - $group2->setName('nerds'); - $this->_em->persist($group2); - $user->getGroups()->add($group2); - $group2->getUsers()->add($user); - - $group->setName('geeks'); - - $this->_em->flush(); - $this->_em->clear(); - - self::assertCount(1, $user->listeners); - self::assertCount(1, $group->listeners); - - $group2Id = $group2->getId(); - unset($group2, $user); - - $user = $this->_em->find(NotifyUser::class, $userId); - self::assertEquals(2, $user->getGroups()->count()); - $group2 = $this->_em->find(NotifyGroup::class, $group2Id); - self::assertEquals(1, $group2->getUsers()->count()); - $group = $this->_em->find(NotifyGroup::class, $groupId); - self::assertEquals(1, $group->getUsers()->count()); - self::assertEquals('geeks', $group->getName()); - } -} - -class NotifyBaseEntity implements NotifyPropertyChanged -{ - /** @psalm-var list */ - public $listeners = []; - - public function addPropertyChangedListener(PropertyChangedListener $listener): void - { - $this->listeners[] = $listener; - } - - protected function onPropertyChanged($propName, $oldValue, $newValue): void - { - if ($this->listeners) { - foreach ($this->listeners as $listener) { - $listener->propertyChanged($this, $propName, $oldValue, $newValue); - } - } - } -} - -#[Entity] -#[ChangeTrackingPolicy('NOTIFY')] -class NotifyUser extends NotifyBaseEntity -{ - #[Id] - #[Column(type: 'integer')] - #[GeneratedValue] - private int $id; - - #[Column] - private string|null $name = null; - - /** @psalm-var Collection */ - #[ManyToMany(targetEntity: 'NotifyGroup')] - private $groups; - - public function __construct() - { - $this->groups = new ArrayCollection(); - } - - public function getId(): int - { - return $this->id; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): void - { - $this->onPropertyChanged('name', $this->name, $name); - $this->name = $name; - } - - /** @psalm-return Collection */ - public function getGroups(): Collection - { - return $this->groups; - } -} - -#[Entity] -class NotifyGroup extends NotifyBaseEntity -{ - #[Id] - #[Column(type: 'integer')] - #[GeneratedValue] - private int $id; - - #[Column] - private string|null $name = null; - - /** @psalm-var Collection */ - #[ManyToMany(targetEntity: 'NotifyUser', mappedBy: 'groups')] - private $users; - - public function __construct() - { - $this->users = new ArrayCollection(); - } - - public function getId(): int - { - return $this->id; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): void - { - $this->onPropertyChanged('name', $this->name, $name); - $this->name = $name; - } - - /** @psalm-return Collection */ - public function getUsers(): Collection - { - return $this->users; - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php deleted file mode 100644 index 256b8c276c3..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1690Test.php +++ /dev/null @@ -1,184 +0,0 @@ -createSchemaForModels(DDC1690Parent::class, DDC1690Child::class); - } - - public function testChangeTracking(): void - { - $parent = new DDC1690Parent(); - $child = new DDC1690Child(); - $parent->setName('parent'); - $child->setName('child'); - - $parent->setChild($child); - $child->setParent($parent); - - $this->_em->persist($parent); - $this->_em->persist($child); - - self::assertEquals(1, count($parent->listeners)); - self::assertEquals(1, count($child->listeners)); - - $this->_em->flush(); - $this->_em->clear(); - - self::assertEquals(1, count($parent->listeners)); - self::assertEquals(1, count($child->listeners)); - - $parentId = $parent->getId(); - $childId = $child->getId(); - unset($parent, $child); - - $parent = $this->_em->find(DDC1690Parent::class, $parentId); - $child = $this->_em->find(DDC1690Child::class, $childId); - - self::assertEquals(1, count($parent->listeners)); - self::assertInstanceOf(Proxy::class, $child, 'Verifying that $child is a proxy before using proxy API'); - self::assertCount(0, $child->listeners); - $child->__load(); - self::assertCount(1, $child->listeners); - unset($parent, $child); - - $parent = $this->_em->find(DDC1690Parent::class, $parentId); - $child = $parent->getChild(); - - self::assertEquals(1, count($parent->listeners)); - self::assertEquals(1, count($child->listeners)); - unset($parent, $child); - - $child = $this->_em->find(DDC1690Child::class, $childId); - $parent = $child->getParent(); - - self::assertEquals(1, count($parent->listeners)); - self::assertEquals(1, count($child->listeners)); - } -} - -class NotifyBaseEntity implements NotifyPropertyChanged -{ - /** @psalm-var list */ - public $listeners = []; - - public function addPropertyChangedListener(PropertyChangedListener $listener): void - { - if (! in_array($listener, $this->listeners, true)) { - $this->listeners[] = $listener; - } - } - - protected function onPropertyChanged($propName, $oldValue, $newValue): void - { - if ($this->listeners) { - foreach ($this->listeners as $listener) { - $listener->propertyChanged($this, $propName, $oldValue, $newValue); - } - } - } -} - -#[Entity] -#[ChangeTrackingPolicy('NOTIFY')] -class DDC1690Parent extends NotifyBaseEntity -{ - #[Id] - #[Column(type: 'integer')] - #[GeneratedValue] - private int $id; - - #[Column] - private string|null $name = null; - - #[OneToOne(targetEntity: 'DDC1690Child')] - private DDC1690Child|null $child = null; - - public function getId(): int - { - return $this->id; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): void - { - $this->onPropertyChanged('name', $this->name, $name); - $this->name = $name; - } - - public function setChild(DDC1690Child $child): void - { - $this->child = $child; - } - - public function getChild(): DDC1690Child - { - return $this->child; - } -} - -#[Entity] -class DDC1690Child extends NotifyBaseEntity -{ - #[Id] - #[Column(type: 'integer')] - #[GeneratedValue] - private int $id; - - #[Column] - private string|null $name = null; - - #[OneToOne(targetEntity: 'DDC1690Parent', mappedBy: 'child')] - private DDC1690Parent|null $parent = null; - - public function getId(): int - { - return $this->id; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): void - { - $this->onPropertyChanged('name', $this->name, $name); - $this->name = $name; - } - - public function setParent(DDC1690Parent $parent): void - { - $this->parent = $parent; - } - - public function getParent(): DDC1690Parent - { - return $this->parent; - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php deleted file mode 100644 index 013b3132841..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2230Test.php +++ /dev/null @@ -1,86 +0,0 @@ -createSchemaForModels( - DDC2230User::class, - DDC2230Address::class, - ); - } - - public function testNotifyTrackingCalledOnProxyInitialization(): void - { - $insertedAddress = new DDC2230Address(); - - $this->_em->persist($insertedAddress); - $this->_em->flush(); - $this->_em->clear(); - - $addressProxy = $this->_em->getReference(DDC2230Address::class, $insertedAddress->id); - assert($addressProxy instanceof Proxy || $addressProxy instanceof DDC2230Address); - - self::assertFalse($addressProxy->__isInitialized()); - self::assertNull($addressProxy->listener); - - $addressProxy->__load(); - - self::assertSame($this->_em->getUnitOfWork(), $addressProxy->listener); - } -} - -#[Entity] -class DDC2230User -{ - /** @var int */ - #[Id] - #[Column(type: 'integer')] - #[GeneratedValue(strategy: 'AUTO')] - public $id; - - /** @var DDC2230Address */ - #[OneToOne(targetEntity: 'DDC2230Address')] - public $address; -} - -#[Entity] -#[ChangeTrackingPolicy('NOTIFY')] -class DDC2230Address implements NotifyPropertyChanged -{ - /** @var int */ - #[Id] - #[Column(type: 'integer')] - #[GeneratedValue(strategy: 'AUTO')] - public $id; - - /** @var \Doctrine\Common\PropertyChangedListener */ - public $listener; - - /** {@inheritDoc} */ - public function addPropertyChangedListener(PropertyChangedListener $listener) - { - $this->listener = $listener; - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 0b7ba74cb5f..4dd6b62e0e3 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -218,12 +218,6 @@ public function testChangeTrackingPolicyExplicit(): void self::assertEquals(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT, $this->cm->changeTrackingPolicy); } - public function testChangeTrackingPolicyNotify(): void - { - $this->assertIsFluent($this->builder->setChangeTrackingPolicyNotify()); - self::assertEquals(ClassMetadata::CHANGETRACKING_NOTIFY, $this->cm->changeTrackingPolicy); - } - public function testAddField(): void { $this->assertIsFluent($this->builder->addField('name', 'string')); diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index ab754c78ac0..11321398904 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Collections\Collection; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; @@ -19,13 +18,10 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\ManyToOne; -use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\Version; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\UnitOfWork; -use Doctrine\Persistence\NotifyPropertyChanged; -use Doctrine\Persistence\PropertyChangedListener; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\EntityPersisterMock; use Doctrine\Tests\Mocks\UnitOfWorkMock; @@ -176,49 +172,6 @@ public function testCascadedIdentityColumnInsert(): void self::assertCount(0, $avatarPersister->getDeletes()); } - public function testChangeTrackingNotify(): void - { - $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(NotifyChangedEntity::class)); - $this->_unitOfWork->setEntityPersister(NotifyChangedEntity::class, $persister); - $itemPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(NotifyChangedRelatedItem::class)); - $this->_unitOfWork->setEntityPersister(NotifyChangedRelatedItem::class, $itemPersister); - - $entity = new NotifyChangedEntity(); - $entity->setData('thedata'); - $this->_unitOfWork->persist($entity); - - $this->_unitOfWork->commit(); - self::assertCount(1, $persister->getInserts()); - $persister->reset(); - - self::assertTrue($this->_unitOfWork->isInIdentityMap($entity)); - - $entity->setData('newdata'); - $entity->setTransient('newtransientvalue'); - - self::assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity)); - - self::assertEquals(['data' => ['thedata', 'newdata']], $this->_unitOfWork->getEntityChangeSet($entity)); - - $item = new NotifyChangedRelatedItem(); - $entity->getItems()->add($item); - $item->setOwner($entity); - $this->_unitOfWork->persist($item); - - $this->_unitOfWork->commit(); - self::assertCount(1, $itemPersister->getInserts()); - $persister->reset(); - $itemPersister->reset(); - - $entity->getItems()->removeElement($item); - $item->setOwner(null); - self::assertTrue($entity->getItems()->isDirty()); - $this->_unitOfWork->commit(); - $updates = $itemPersister->getUpdates(); - self::assertCount(1, $updates); - self::assertSame($updates[0], $item); - } - public function testGetEntityStateOnVersionedEntityWithAssignedIdentifier(): void { $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata(VersionedAssignedIdentifierEntity::class)); @@ -670,103 +623,6 @@ public function testRemovedEntityIsRemovedFromOneToManyCollection(): void } } -#[Entity] -class NotifyChangedEntity implements NotifyPropertyChanged -{ - /** @psalm-var list */ - private array $_listeners = []; - - #[Id] - #[Column(type: 'integer')] - #[GeneratedValue] - private int $id; - - /** @var string */ - #[Column(type: 'string', length: 255)] - private $data; - - private mixed $transient = null; // not persisted - /** @psalm-var Collection */ - #[OneToMany(targetEntity: 'NotifyChangedRelatedItem', mappedBy: 'owner')] - private $items; - - public function __construct() - { - $this->items = new ArrayCollection(); - } - - public function getId(): int - { - return $this->id; - } - - public function getItems(): Collection - { - return $this->items; - } - - public function setTransient($value): void - { - if ($value !== $this->transient) { - $this->onPropertyChanged('transient', $this->transient, $value); - $this->transient = $value; - } - } - - public function getData(): mixed - { - return $this->data; - } - - public function setData(mixed $data): void - { - if ($data !== $this->data) { - $this->onPropertyChanged('data', $this->data, $data); - $this->data = $data; - } - } - - public function addPropertyChangedListener(PropertyChangedListener $listener): void - { - $this->_listeners[] = $listener; - } - - protected function onPropertyChanged(mixed $propName, mixed $oldValue, mixed $newValue): void - { - if ($this->_listeners) { - foreach ($this->_listeners as $listener) { - $listener->propertyChanged($this, $propName, $oldValue, $newValue); - } - } - } -} - -#[Entity] -class NotifyChangedRelatedItem -{ - #[Id] - #[Column(type: 'integer')] - #[GeneratedValue] - private int $id; - - #[ManyToOne(targetEntity: 'NotifyChangedEntity', inversedBy: 'items')] - private NotifyChangedEntity|null $owner = null; - - public function getId(): int - { - return $this->id; - } - - public function getOwner(): NotifyChangedEntity|null - { - return $this->owner; - } - - public function setOwner(NotifyChangedEntity|null $owner): void - { - $this->owner = $owner; - } -} #[Entity] class VersionedAssignedIdentifierEntity From 2a8f22c521683bfd8368e403be8c2caa0c2bd6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 17 Jun 2023 15:41:23 +0200 Subject: [PATCH 296/475] Turn deprecation into an exception --- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 5 +---- .../Tests/ORM/Mapping/BasicInheritanceMappingTest.php | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index f774fa90853..f84b69f090d 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1689,10 +1689,7 @@ public function setAssociationOverride(string $fieldName, array $overrideMapping $mapping = $this->associationMappings[$fieldName]->toArray(); if (isset($mapping['inherited'])) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10470', - 'Overrides are only allowed for fields or associations declared in mapped superclasses or traits. This is not the case for %s::%s, which was inherited from %s. This is a misconfiguration and will be an error in Doctrine ORM 3.0.', + throw MappingException::illegalOverrideOfInheritedProperty( $this->name, $fieldName, $mapping['inherited'], diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 59a3349b41d..1e4f2ff7f60 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -263,7 +263,8 @@ public function testInvalidOverrideAssociationInheritedFromEntity(): void { $cm = $this->cmf->getMetadataFor(CompanyFixContract::class); - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/10470'); + $this->expectException(MappingException::class); + $this->expectExceptionMessage('Overrides are only allowed for fields or associations declared in mapped superclasses or traits. This is not the case for Doctrine\Tests\Models\Company\CompanyFixContract::salesPerson, which was inherited from Doctrine\Tests\Models\Company\CompanyContract.'); $cm->setAssociationOverride('salesPerson', ['inversedBy' => 'other_inversed_by_name']); } From 663763ab1ad11058cd102bf1aafc6109b162876f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 17 Jun 2023 16:16:25 +0200 Subject: [PATCH 297/475] Disallow lifecycle callbacks on embedded classes --- UPGRADE.md | 5 +++++ lib/Doctrine/ORM/Mapping/ClassMetadata.php | 8 +------- lib/Doctrine/ORM/Mapping/MappingException.php | 13 +++++++++++++ .../Tests/ORM/Mapping/ClassMetadataTest.php | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index ecc71453253..4946a9302d7 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## BC BREAK: Lifecycle callback mapping on embedded classes is now explicitly forbidden + +Lifecycle callback mapping on embedded classes produced no effect, and is now +explicitly forbidden to point out mistakes. + ## BC BREAK: The `NOTIFY` change tracking policy is removed You should use `DEFERRED_EXPLICIT` instead. diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index f774fa90853..93dd965ca1c 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -2044,13 +2044,7 @@ public function getLifecycleCallbacks(string $event): array public function addLifecycleCallback(string $callback, string $event): void { if ($this->isEmbeddedClass) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/8381', - 'Registering lifecycle callback %s on Embedded class %s is not doing anything and will throw exception in 3.0', - $event, - $this->name, - ); + throw MappingException::illegalLifecycleCallbackOnEmbeddedClass($callback, $this->name); } if (isset($this->lifecycleCallbacks[$event]) && in_array($callback, $this->lifecycleCallbacks[$event], true)) { diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 6dddeb0dc1d..1b45aab32dc 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -498,6 +498,19 @@ public static function lifecycleCallbackMethodNotFound(string $className, string return new self("Entity '" . $className . "' has no method '" . $methodName . "' to be registered as lifecycle callback."); } + /** @param class-string $className */ + public static function illegalLifecycleCallbackOnEmbeddedClass(string $event, string $className): self + { + return new self(sprintf( + <<<'EXCEPTION' + Context: Attempt to register lifecycle callback "%s" on embedded class "%s". + Problem: Registering lifecycle callbacks on embedded classes is not allowed. + EXCEPTION, + $event, + $className, + )); + } + public static function entityListenerClassNotFound(string $listenerName, string $className): self { return new self(sprintf('Entity Listener "%s" declared on "%s" not found.', $listenerName, $className)); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 2b761ec6d8d..170f95bee6c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -1014,6 +1014,20 @@ public function testRejectsEmbeddableWithoutValidClassName(): void 'columnPrefix' => false, ]); } + + public function testItAddingLifecycleCallbackOnEmbeddedClassIsIllegal(): void + { + $metadata = new ClassMetadata(self::class); + $metadata->isEmbeddedClass = true; + + $this->expectException(MappingException::class); + $this->expectExceptionMessage(<<<'EXCEPTION' + Context: Attempt to register lifecycle callback "foo" on embedded class "Doctrine\Tests\ORM\Mapping\ClassMetadataTest". + Problem: Registering lifecycle callbacks on embedded classes is not allowed. + EXCEPTION); + + $metadata->addLifecycleCallback('foo', 'bar'); + } } #[MappedSuperclass] From 1bd3066b9fa3bc4249fe2eeb1ab9acca088b3a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anderson=20M=C3=BCller?= Date: Mon, 19 Jun 2023 11:21:17 +0200 Subject: [PATCH 298/475] Remove missed note about deprecated drivers --- docs/en/reference/metadata-drivers.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/en/reference/metadata-drivers.rst b/docs/en/reference/metadata-drivers.rst index cfa6e641bc4..1b4faadb3ce 100644 --- a/docs/en/reference/metadata-drivers.rst +++ b/docs/en/reference/metadata-drivers.rst @@ -16,8 +16,6 @@ metadata: - **Attributes** (AttributeDriver) - **PHP Code in files or static functions** (PhpDriver) -They will be removed in 3.0, make sure to avoid them. - Something important to note about the above drivers is they are all an intermediate step to the same end result. The mapping information is populated to ``Doctrine\ORM\Mapping\ClassMetadata`` From 1733bf8678e79d6c871ec7abcbf024497e3c2f13 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Tue, 27 Jun 2023 10:27:39 +0200 Subject: [PATCH 299/475] Remove remaining references to the `merge()` operation (#10793) `EntityManager::merge()` has been deprecated in #8461 and removed in #9488. This PR removes a few remaining references and artefacts that - to my understanding - refer to it. --- docs/en/reference/attributes-reference.rst | 2 +- docs/en/reference/best-practices.rst | 2 +- docs/en/reference/inheritance-mapping.rst | 2 - .../limitations-and-known-issues.rst | 9 - .../reference/working-with-associations.rst | 2 +- docs/en/reference/working-with-objects.rst | 73 +------ docs/en/reference/xml-mapping.rst | 1 - ...eld-association-mappings-in-subclasses.rst | 2 +- doctrine-mapping.xsd | 1 - .../ORM/Mapping/AssociationMapping.php | 8 +- .../Mapping/Builder/AssociationBuilder.php | 8 - lib/Doctrine/ORM/Mapping/ClassMetadata.php | 2 +- lib/Doctrine/ORM/Mapping/MappingException.php | 2 +- .../Tests/Models/CMS/CmsPhonenumber.php | 2 +- tests/Doctrine/Tests/Models/CMS/CmsUser.php | 4 +- .../Models/DDC1872/DDC1872ExampleTrait.php | 2 +- .../Tests/Models/DDC964/DDC964User.php | 8 +- .../Tests/Models/Legacy/LegacyUser.php | 2 +- .../CompositeToOneKeyState.php | 2 +- .../Models/VersionedManyToOne/Article.php | 2 +- .../ORM/Functional/Ticket/DDC2602Test.php | 6 +- .../ORM/Functional/Ticket/DDC758Test.php | 186 ------------------ .../ORM/Mapping/ClassMetadataBuilderTest.php | 15 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 2 +- .../ORM/Mapping/MappingDriverTestCase.php | 8 +- .../Doctrine.Tests.Models.CMS.CmsUser.dcm.xml | 2 - ...ine.Tests.Models.DDC964.DDC964User.dcm.xml | 2 - 27 files changed, 29 insertions(+), 328 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php diff --git a/docs/en/reference/attributes-reference.rst b/docs/en/reference/attributes-reference.rst index d537a119ab0..64f15ddbba5 100644 --- a/docs/en/reference/attributes-reference.rst +++ b/docs/en/reference/attributes-reference.rst @@ -926,7 +926,7 @@ Example: #[OneToMany( targetEntity: "Phonenumber", mappedBy: "user", - cascade: ["persist", "remove", "merge"], + cascade: ["persist", "remove"], orphanRemoval: true) ] public $phonenumbers; diff --git a/docs/en/reference/best-practices.rst b/docs/en/reference/best-practices.rst index 002c130d5ce..b6f63a61b7b 100644 --- a/docs/en/reference/best-practices.rst +++ b/docs/en/reference/best-practices.rst @@ -43,7 +43,7 @@ should use events judiciously. Use cascades judiciously ------------------------ -Automatic cascades of the persist/remove/merge/etc. operations are +Automatic cascades of the persist/remove/etc. operations are very handy but should be used wisely. Do NOT simply add all cascades to all associations. Think about which cascades actually do make sense for you for a particular association, given the diff --git a/docs/en/reference/inheritance-mapping.rst b/docs/en/reference/inheritance-mapping.rst index 2bdfd708b8c..7852e6533eb 100644 --- a/docs/en/reference/inheritance-mapping.rst +++ b/docs/en/reference/inheritance-mapping.rst @@ -410,7 +410,6 @@ Example: - @@ -522,7 +521,6 @@ Could be used by an entity that extends a mapped superclass to override a field - diff --git a/docs/en/reference/limitations-and-known-issues.rst b/docs/en/reference/limitations-and-known-issues.rst index cf67c67e3a2..d8b7f19ada8 100644 --- a/docs/en/reference/limitations-and-known-issues.rst +++ b/docs/en/reference/limitations-and-known-issues.rst @@ -65,15 +65,6 @@ Where the ``attribute_name`` column contains the key and The feature request for persistence of primitive value arrays `is described in the DDC-298 ticket `_. -Cascade Merge with Bi-directional Associations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -There are two bugs now that concern the use of cascade merge in combination with bi-directional associations. -Make sure to study the behavior of cascade merge if you are using it: - -- `DDC-875 `_ Merge can sometimes add the same entity twice into a collection -- `DDC-763 `_ Cascade merge on associated entities can insert too many rows through "Persistence by Reachability" - Custom Persisters ~~~~~~~~~~~~~~~~~ diff --git a/docs/en/reference/working-with-associations.rst b/docs/en/reference/working-with-associations.rst index 2c265679fa1..b5ca716ad07 100644 --- a/docs/en/reference/working-with-associations.rst +++ b/docs/en/reference/working-with-associations.rst @@ -415,7 +415,7 @@ Transitive persistence / Cascade Operations Doctrine ORM provides a mechanism for transitive persistence through cascading of certain operations. Each association to another entity or a collection of entities can be configured to automatically cascade the following operations to the associated entities: -``persist``, ``remove``, ``merge``, ``detach``, ``refresh`` or ``all``. +``persist``, ``remove``, ``detach``, ``refresh`` or ``all``. The main use case for ``cascade: persist`` is to avoid "exposing" associated entities to your PHP application. Continuing with the User-Comment example of this chapter, this is how the creation of a new user and a new diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index 5fa200376b0..a36dad50853 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -408,77 +408,6 @@ automatically without invoking the ``detach`` method: The ``detach`` operation is usually not as frequently needed and used as ``persist`` and ``remove``. -Merging entities ----------------- - -Merging entities refers to the merging of (usually detached) -entities into the context of an EntityManager so that they become -managed again. To merge the state of an entity into an -EntityManager use the ``EntityManager#merge($entity)`` method. The -state of the passed entity will be merged into a managed copy of -this entity and this copy will subsequently be returned. - -Example: - -.. code-block:: php - - merge($detachedEntity); - // $entity now refers to the fully managed copy returned by the merge operation. - // The EntityManager $em now manages the persistence of $entity as usual. - - -The semantics of the merge operation, applied to an entity X, are -as follows: - - -- If X is a detached entity, the state of X is copied onto a - pre-existing managed entity instance X' of the same identity. -- If X is a new entity instance, a new managed copy X' will be - created and the state of X is copied onto this managed instance. -- If X is a removed entity instance, an InvalidArgumentException - will be thrown. -- If X is a managed entity, it is ignored by the merge operation, - however, the merge operation is cascaded to entities referenced by - relationships from X if these relationships have been mapped with - the cascade element value MERGE or ALL (see ":ref:`transitive-persistence`"). -- For all entities Y referenced by relationships from X having the - cascade element value MERGE or ALL, Y is merged recursively as Y'. - For all such Y referenced by X, X' is set to reference Y'. (Note - that if X is managed then X is the same object as X'.) -- If X is an entity merged to X', with a reference to another - entity Y, where cascade=MERGE or cascade=ALL is not specified, then - navigation of the same association from X' yields a reference to a - managed object Y' with the same persistent identity as Y. - -The ``merge`` operation will throw an ``OptimisticLockException`` -if the entity being merged uses optimistic locking through a -version field and the versions of the entity being merged and the -managed copy don't match. This usually means that the entity has -been modified while being detached. - -The ``merge`` operation is usually not as frequently needed and -used as ``persist`` and ``remove``. The most common scenario for -the ``merge`` operation is to reattach entities to an EntityManager -that come from some cache (and are therefore detached) and you want -to modify and persist such an entity. - -.. warning:: - - If you need to perform multiple merges of entities that share certain subparts - of their object-graphs and cascade merge, then you have to call ``EntityManager#clear()`` between the - successive calls to ``EntityManager#merge()``. Otherwise you might end up with - multiple copies of the "same" object in the database, however with different ids. - -.. note:: - - If you load some detached entities from a cache and you do - not need to persist or delete them or otherwise make use of them - without the need for persistence services there is no need to use - ``merge``. I.e. you can simply pass detached objects from a cache - directly to the view. - Synchronization with the Database --------------------------------- @@ -589,7 +518,7 @@ during development. .. note:: Do not invoke ``flush`` after every change to an entity - or every single invocation of persist/remove/merge/... This is an + or every single invocation of persist/remove/... This is an anti-pattern and unnecessarily reduces the performance of your application. Instead, form units of work that operate on your objects and call ``flush`` when you are done. While serving a diff --git a/docs/en/reference/xml-mapping.rst b/docs/en/reference/xml-mapping.rst index 12930597b85..bb2eed19d1c 100644 --- a/docs/en/reference/xml-mapping.rst +++ b/docs/en/reference/xml-mapping.rst @@ -692,7 +692,6 @@ specified by their respective tags: - ```` -- ```` - ```` - ```` - ```` diff --git a/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst b/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst index 8d36b30ef66..cd5e19cbd80 100644 --- a/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst +++ b/docs/en/tutorials/override-field-association-mappings-in-subclasses.rst @@ -66,7 +66,7 @@ which has mapping metadata that is overridden by the attribute above: #[Column(name: 'trait_foo', type: 'integer', length: 100, nullable: true, unique: true)] protected int $foo; - #[OneToOne(targetEntity: Bar::class, cascade: ['persist', 'merge'])] + #[OneToOne(targetEntity: Bar::class, cascade: ['persist'])] #[JoinColumn(name: 'example_trait_bar_id', referencedColumnName: 'id')] protected Bar|null $bar = null; } diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index 058825b11aa..5d6dfc812fa 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -35,7 +35,6 @@ - diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index 3fbeecbc23c..e3a899661dc 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -20,7 +20,7 @@ abstract class AssociationMapping implements ArrayAccess /** * The names of persistence operations to cascade on the association. * - * @var list<'persist'|'remove'|'detach'|'merge'|'refresh'|'all'> + * @var list<'persist'|'remove'|'detach'|'refresh'|'all'> */ public array $cascade = []; @@ -240,7 +240,6 @@ final public function offsetGet($offset): mixed 'isCascadePersist' => $this->isCascadePersist(), 'isCascadeRefresh' => $this->isCascadeRefresh(), 'isCascadeDetach' => $this->isCascadeDetach(), - 'isCascadeMerge' => $this->isCascadeMerge(), default => property_exists($this, $offset) ? $this->$offset : throw new OutOfRangeException(sprintf( 'Unknown property "%s" on class %s', $offset, @@ -296,11 +295,6 @@ final public function isCascadeRefresh(): bool return in_array('refresh', $this->cascade, true); } - final public function isCascadeMerge(): bool - { - return in_array('merge', $this->cascade, true); - } - final public function isCascadeDetach(): bool { return in_array('detach', $this->cascade, true); diff --git a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php index 50817b4c39b..ea9e13c53b1 100644 --- a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php +++ b/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php @@ -60,14 +60,6 @@ public function cascadeRemove(): static return $this; } - /** @return $this */ - public function cascadeMerge(): static - { - $this->mapping['cascade'][] = 'merge'; - - return $this; - } - /** @return $this */ public function cascadeDetach(): static { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index d148394489d..0a0babd6323 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -1348,7 +1348,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping): Assoc // Cascades $cascades = isset($mapping['cascade']) ? array_map('strtolower', $mapping['cascade']) : []; - $allCascades = ['remove', 'persist', 'refresh', 'merge', 'detach']; + $allCascades = ['remove', 'persist', 'refresh', 'detach']; if (in_array('all', $cascades, true)) { $cascades = $allCascades; } elseif (count($cascades) !== count(array_intersect($cascades, $allCascades))) { diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 1b45aab32dc..48fc9a6654e 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -553,7 +553,7 @@ public static function invalidCascadeOption(array $cascades, string $className, $cascades = implode(', ', array_map(static fn (string $e): string => "'" . $e . "'", $cascades)); return new self(sprintf( - "You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'", + "You have specified invalid cascade options for %s::$%s: %s; available options: 'remove', 'persist', 'refresh', and 'detach'", $className, $propertyName, $cascades, diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php b/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php index 7bfe373cb3d..1f23e4e0b60 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php @@ -21,7 +21,7 @@ class CmsPhonenumber public $phonenumber; /** @var CmsUser */ - #[ManyToOne(targetEntity: 'CmsUser', inversedBy: 'phonenumbers', cascade: ['merge'])] + #[ManyToOne(targetEntity: 'CmsUser', inversedBy: 'phonenumbers', cascade: [])] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] public $user; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Doctrine/Tests/Models/CMS/CmsUser.php index 335525fb366..c0fa4bb76b5 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -42,7 +42,7 @@ class CmsUser public $name; /** @psalm-var Collection */ - #[OneToMany(targetEntity: 'CmsPhonenumber', mappedBy: 'user', cascade: ['persist', 'merge'], orphanRemoval: true)] + #[OneToMany(targetEntity: 'CmsPhonenumber', mappedBy: 'user', cascade: ['persist'], orphanRemoval: true)] public $phonenumbers; /** @psalm-var Collection */ @@ -62,7 +62,7 @@ class CmsUser #[JoinTable(name: 'cms_users_groups')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] - #[ManyToMany(targetEntity: 'CmsGroup', inversedBy: 'users', cascade: ['persist', 'merge', 'detach'])] + #[ManyToMany(targetEntity: 'CmsGroup', inversedBy: 'users', cascade: ['persist', 'detach'])] public $groups; /** @var Collection */ diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php index 735d014eb69..fdad6f4182b 100644 --- a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php +++ b/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php @@ -21,7 +21,7 @@ trait DDC1872ExampleTrait protected $foo; /** @var DDC1872Bar */ - #[OneToOne(targetEntity: 'DDC1872Bar', cascade: ['persist', 'merge'])] + #[OneToOne(targetEntity: 'DDC1872Bar', cascade: ['persist'])] #[JoinColumn(name: 'example_trait_bar_id', referencedColumnName: 'id')] protected $bar; } diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php index f2f17c14b97..9adcca23dd6 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964User.php @@ -27,14 +27,14 @@ class DDC964User protected $id; /** @psalm-var Collection */ - #[ManyToMany(targetEntity: DDC964Group::class, inversedBy: 'users', cascade: ['persist', 'merge', 'detach'])] + #[ManyToMany(targetEntity: DDC964Group::class, inversedBy: 'users', cascade: ['persist', 'detach'])] #[JoinTable(name: 'ddc964_users_groups')] #[JoinColumn(name: 'user_id', referencedColumnName: 'id')] #[InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')] protected $groups; /** @var DDC964Address */ - #[ManyToOne(targetEntity: DDC964Address::class, cascade: ['persist', 'merge'])] + #[ManyToOne(targetEntity: DDC964Address::class, cascade: ['persist'])] #[JoinColumn(name: 'address_id', referencedColumnName: 'id')] protected $address; @@ -110,7 +110,7 @@ public static function loadMetadata(ClassMetadata $metadata): void [ 'fieldName' => 'address', 'targetEntity' => 'DDC964Address', - 'cascade' => ['persist','merge'], + 'cascade' => ['persist'], 'joinColumns' => [['name' => 'address_id', 'referencedColumnName' => 'id']], ], ); @@ -120,7 +120,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 'fieldName' => 'groups', 'targetEntity' => 'DDC964Group', 'inversedBy' => 'users', - 'cascade' => ['persist','merge','detach'], + 'cascade' => ['persist','detach'], 'joinTable' => [ 'name' => 'ddc964_users_groups', 'joinColumns' => [ diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php b/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php index 50e1231a596..e43bc6828bc 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php @@ -47,7 +47,7 @@ class LegacyUser #[JoinTable(name: 'legacy_users_cars')] #[JoinColumn(name: 'iUserId', referencedColumnName: 'iUserId')] #[InverseJoinColumn(name: 'iCarId', referencedColumnName: 'iCarId')] - #[ManyToMany(targetEntity: 'LegacyCar', inversedBy: 'users', cascade: ['persist', 'merge'])] + #[ManyToMany(targetEntity: 'LegacyCar', inversedBy: 'users', cascade: ['persist'])] public $cars; public function __construct() diff --git a/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php b/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php index f3372e96763..f3f0d9a1289 100644 --- a/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php +++ b/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php @@ -22,7 +22,7 @@ class CompositeToOneKeyState /** @var Country */ #[Id] - #[ManyToOne(targetEntity: 'Country', cascade: ['MERGE'])] + #[ManyToOne(targetEntity: 'Country', cascade: [])] #[JoinColumn(referencedColumnName: 'country')] public $country; } diff --git a/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php b/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php index 41468abc189..8c57945ca7c 100644 --- a/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php +++ b/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php @@ -27,7 +27,7 @@ class Article public $name; /** @var Category */ - #[ManyToOne(targetEntity: 'Category', cascade: ['merge', 'persist'])] + #[ManyToOne(targetEntity: 'Category', cascade: ['persist'])] public $category; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php index 37a0bd1e9fc..fc1d74c5a57 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php @@ -173,7 +173,7 @@ class DDC2602User public $name; /** @var DDC2602Biography */ - #[OneToOne(targetEntity: 'DDC2602Biography', inversedBy: 'user', cascade: ['persist', 'merge', 'refresh', 'remove'])] + #[OneToOne(targetEntity: 'DDC2602Biography', inversedBy: 'user', cascade: ['persist', 'refresh', 'remove'])] #[JoinColumn(nullable: false)] public $biography; } @@ -188,7 +188,7 @@ class DDC2602Biography public $id; /** @var DDC2602User */ - #[OneToOne(targetEntity: 'DDC2602User', mappedBy: 'biography', cascade: ['persist', 'merge', 'refresh'])] + #[OneToOne(targetEntity: 'DDC2602User', mappedBy: 'biography', cascade: ['persist', 'refresh'])] public $user; /** @var string */ @@ -217,7 +217,7 @@ class DDC2602BiographyField public $label; /** @var ArrayCollection */ - #[OneToMany(targetEntity: 'DDC2602BiographyFieldChoice', mappedBy: 'field', cascade: ['persist', 'merge', 'refresh'])] + #[OneToMany(targetEntity: 'DDC2602BiographyFieldChoice', mappedBy: 'field', cascade: ['persist', 'refresh'])] public $choiceList; public function __construct() diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php deleted file mode 100644 index 461cf116d90..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php +++ /dev/null @@ -1,186 +0,0 @@ -useModelSet('cms'); - - parent::setUp(); - } - - /** - * Helper method to set cascade to merge only - */ - private function setCascadeMergeFor($class): void - { - $metadata = $this->_em->getMetadataFactory()->getMetadataFor($class); - foreach ($metadata->associationMappings as $key => $associationMapping) { - $metadata->associationMappings[$key]['isCascadePersist'] = false; - $metadata->associationMappings[$key]['isCascadeMerge'] = true; - $metadata->associationMappings[$key]['isCascadeRemove'] = false; - $metadata->associationMappings[$key]['isCascadeDetach'] = false; - } - } - - /** - * Test that changing associations on detached entities and then cascade merging them - * causes the database to be updated with the new associations. - * This specifically tests adding new associations. - */ - public function testManyToManyMergeAssociationAdds(): void - { - $this->setCascadeMergeFor(CmsUser::class); - $this->setCascadeMergeFor(CmsGroup::class); - - // Put entities in the database - $cmsUser = new CmsUser(); - $cmsUser->username = 'dave'; - $cmsUser->name = 'Dave Keen'; - $cmsUser->status = 'testing'; - - $group1 = new CmsGroup(); - $group1->name = 'Group 1'; - - $group2 = new CmsGroup(); - $group2->name = 'Group 2'; - - $this->_em->persist($cmsUser); - $this->_em->persist($group1); - $this->_em->persist($group2); - $this->_em->flush(); - - $cmsUserId = $cmsUser->id; - $group1Id = $group1->id; - $group2Id = $group2->id; - - $this->_em->clear(); - - // Now create detached versions of the entities with some new associations. - $cmsUser = new CmsUser(); - $cmsUser->id = $cmsUserId; - $cmsUser->username = 'dave'; - $cmsUser->name = 'Dave Keen'; - $cmsUser->status = 'testing'; - $cmsUser->groups = new ArrayCollection(); - - $group1 = new CmsGroup(); - $group1->id = $group1Id; - $group1->name = 'Group 1'; - $group1->users = new ArrayCollection(); - - $group2 = new CmsGroup(); - $group2->id = $group2Id; - $group2->name = 'Group 2'; - $group2->users = new ArrayCollection(); - - $cmsUser->addGroup($group1); - $cmsUser->addGroup($group2); - - // Cascade merge of cmsUser followed by a flush should add in the bidirectional new many-to-many associations between the user and the groups - $this->_em->merge($cmsUser); - $this->_em->flush(); - - $this->_em->clear(); - - $cmsUsers = $this->_em->getRepository(CmsUser::class)->findAll(); - $cmsGroups = $this->_em->getRepository(CmsGroup::class)->findAll(); - - // Check the entities are in the database - self::assertEquals(1, count($cmsUsers)); - self::assertEquals(2, count($cmsGroups)); - - // Check the associations between the entities are now in the database - self::assertEquals(2, count($cmsUsers[0]->groups)); - self::assertEquals(1, count($cmsGroups[0]->users)); - self::assertEquals(1, count($cmsGroups[1]->users)); - - self::assertSame($cmsUsers[0]->groups[0], $cmsGroups[0]); - self::assertSame($cmsUsers[0]->groups[1], $cmsGroups[1]); - self::assertSame($cmsGroups[0]->users[0], $cmsUsers[0]); - self::assertSame($cmsGroups[1]->users[0], $cmsUsers[0]); - } - - /** - * Test that changing associations on detached entities and then cascade merging them causes the - * database to be updated with the new associations. - */ - public function testManyToManyMergeAssociationRemoves(): void - { - $this->setCascadeMergeFor(CmsUser::class); - $this->setCascadeMergeFor(CmsGroup::class); - - $cmsUser = new CmsUser(); - $cmsUser->username = 'dave'; - $cmsUser->name = 'Dave Keen'; - $cmsUser->status = 'testing'; - - $group1 = new CmsGroup(); - $group1->name = 'Group 1'; - - $group2 = new CmsGroup(); - $group2->name = 'Group 2'; - - $cmsUser->addGroup($group1); - $cmsUser->addGroup($group2); - - $this->_em->persist($cmsUser); - $this->_em->persist($group1); - $this->_em->persist($group2); - $this->_em->flush(); - - $cmsUserId = $cmsUser->id; - $group1Id = $group1->id; - $group2Id = $group2->id; - - $this->_em->clear(); - - // Now create detached versions of the entities with NO associations. - $cmsUser = new CmsUser(); - $cmsUser->id = $cmsUserId; - $cmsUser->username = 'dave'; - $cmsUser->name = 'Dave Keen'; - $cmsUser->status = 'testing'; - $cmsUser->groups = new ArrayCollection(); - - $group1 = new CmsGroup(); - $group1->id = $group1Id; - $group1->name = 'Group 1'; - $group1->users = new ArrayCollection(); - - $group2 = new CmsGroup(); - $group2->id = $group2Id; - $group2->name = 'Group 2'; - $group2->users = new ArrayCollection(); - - // Cascade merge of cmsUser followed by a flush should result in the association array collection being empty - $this->_em->merge($cmsUser); - $this->_em->flush(); - - $this->_em->clear(); - - $cmsUsers = $this->_em->getRepository(CmsUser::class)->findAll(); - $cmsGroups = $this->_em->getRepository(CmsGroup::class)->findAll(); - - // Check the entities are in the database - self::assertEquals(1, count($cmsUsers)); - self::assertEquals(2, count($cmsGroups)); - - // Check the associations between the entities are now in the database - self::assertEquals(0, count($cmsUsers[0]->groups)); - self::assertEquals(0, count($cmsGroups[0]->users)); - self::assertEquals(0, count($cmsGroups[1]->users)); - } -} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 4dd6b62e0e3..58ea2202ef1 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -303,8 +303,7 @@ public function testCreateManyToOne(): void 0 => 'remove', 1 => 'persist', 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', + 3 => 'detach', ], 'fetch' => 4, 'joinColumns' => [ @@ -357,8 +356,7 @@ public function testCreateManyToOneWithIdentity(): void 0 => 'remove', 1 => 'persist', 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', + 3 => 'detach', ], 'fetch' => 4, 'joinColumns' => [ @@ -409,8 +407,7 @@ public function testCreateOneToOne(): void 0 => 'remove', 1 => 'persist', 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', + 3 => 'detach', ], 'fetch' => 4, 'joinColumns' => [ @@ -463,8 +460,7 @@ public function testCreateOneToOneWithIdentity(): void 0 => 'remove', 1 => 'persist', 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', + 3 => 'detach', ], 'fetch' => 4, 'id' => true, @@ -532,8 +528,7 @@ public function testCreateManyToMany(): void 0 => 'remove', 1 => 'persist', 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', + 3 => 'detach', ], 'fetch' => 4, 'joinTable' => diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 170f95bee6c..28b69ff08a5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -808,7 +808,7 @@ public function testInvalidCascade(): void $cm->initializeReflection(new RuntimeReflectionService()); $this->expectException(MappingException::class); - $this->expectExceptionMessage('You have specified invalid cascade options for ' . CmsUser::class . "::\$address: 'invalid'; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'"); + $this->expectExceptionMessage('You have specified invalid cascade options for ' . CmsUser::class . "::\$address: 'invalid'; available options: 'remove', 'persist', 'refresh', and 'detach'"); $cm->mapManyToOne(['fieldName' => 'address', 'targetEntity' => 'UnknownClass', 'cascade' => ['invalid']]); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php index 40c39827ee9..09bddea9859 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php @@ -361,7 +361,6 @@ public function testOwningOneToOneAssociation(ClassMetadata $class): ClassMetada self::assertFalse($class->associationMappings['address']->isCascadePersist()); self::assertFalse($class->associationMappings['address']->isCascadeRefresh()); self::assertFalse($class->associationMappings['address']->isCascadeDetach()); - self::assertFalse($class->associationMappings['address']->isCascadeMerge()); return $class; } @@ -375,7 +374,6 @@ public function testInverseOneToManyAssociation(ClassMetadata $class): ClassMeta self::assertTrue($class->associationMappings['phonenumbers']->isCascadeRemove()); self::assertFalse($class->associationMappings['phonenumbers']->isCascadeRefresh()); self::assertFalse($class->associationMappings['phonenumbers']->isCascadeDetach()); - self::assertFalse($class->associationMappings['phonenumbers']->isCascadeMerge()); self::assertTrue($class->associationMappings['phonenumbers']->orphanRemoval); // Test Order By @@ -394,7 +392,6 @@ public function testManyToManyAssociationWithCascadeAll(ClassMetadata $class): C self::assertTrue($class->associationMappings['groups']->isCascadePersist()); self::assertTrue($class->associationMappings['groups']->isCascadeRefresh()); self::assertTrue($class->associationMappings['groups']->isCascadeDetach()); - self::assertTrue($class->associationMappings['groups']->isCascadeMerge()); self::assertFalse($class->associationMappings['groups']->isOrdered()); @@ -630,7 +627,6 @@ public function testAssociationOverridesMapping(): void self::assertEquals($guestGroups->isCascadeRemove(), $adminGroups->isCascadeRemove()); self::assertEquals($guestGroups->isCascadePersist(), $adminGroups->isCascadePersist()); self::assertEquals($guestGroups->isCascadeRefresh(), $adminGroups->isCascadeRefresh()); - self::assertEquals($guestGroups->isCascadeMerge(), $adminGroups->isCascadeMerge()); self::assertEquals($guestGroups->isCascadeDetach(), $adminGroups->isCascadeDetach()); // assert not override attributes @@ -666,7 +662,6 @@ public function testAssociationOverridesMapping(): void self::assertEquals($guestAddress->isCascadeRemove(), $adminAddress->isCascadeRemove()); self::assertEquals($guestAddress->isCascadePersist(), $adminAddress->isCascadePersist()); self::assertEquals($guestAddress->isCascadeRefresh(), $adminAddress->isCascadeRefresh()); - self::assertEquals($guestAddress->isCascadeMerge(), $adminAddress->isCascadeMerge()); self::assertEquals($guestAddress->isCascadeDetach(), $adminAddress->isCascadeDetach()); // assert override @@ -1101,8 +1096,7 @@ public static function loadMetadata(ClassMetadata $metadata): void 0 => 'remove', 1 => 'persist', 2 => 'refresh', - 3 => 'merge', - 4 => 'detach', + 3 => 'detach', ], 'mappedBy' => null, 'joinTable' => diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml index 5e9bb53580b..104ef15a567 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml @@ -31,7 +31,6 @@ - @@ -44,7 +43,6 @@ - diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml index 3e6a91f39e1..cc4764b1b57 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml @@ -14,7 +14,6 @@ - @@ -22,7 +21,6 @@ - From 3ffd3f65099f3a107bc01c47053274c36df75f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 27 Jun 2023 23:10:06 +0200 Subject: [PATCH 300/475] Validate phpunit.xml against PHPUnit 10 schema The previous syntax was a PHPUnit 9 syntax. --- ci/github/phpunit/mysqli.xml | 4 ++-- ci/github/phpunit/pdo_mysql.xml | 4 ++-- ci/github/phpunit/pdo_pgsql.xml | 4 ++-- ci/github/phpunit/pdo_sqlite.xml | 4 ++-- ci/github/phpunit/pgsql.xml | 4 ++-- ci/github/phpunit/sqlite3.xml | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ci/github/phpunit/mysqli.xml b/ci/github/phpunit/mysqli.xml index 9e806f3ed04..a0cf8fa2682 100644 --- a/ci/github/phpunit/mysqli.xml +++ b/ci/github/phpunit/mysqli.xml @@ -27,11 +27,11 @@ - + ../../../lib/Doctrine - + diff --git a/ci/github/phpunit/pdo_mysql.xml b/ci/github/phpunit/pdo_mysql.xml index 7fae48df0a6..701114bb471 100644 --- a/ci/github/phpunit/pdo_mysql.xml +++ b/ci/github/phpunit/pdo_mysql.xml @@ -27,11 +27,11 @@ - + ../../../lib/Doctrine - + diff --git a/ci/github/phpunit/pdo_pgsql.xml b/ci/github/phpunit/pdo_pgsql.xml index 4bf3d290a54..1152d90d7c3 100644 --- a/ci/github/phpunit/pdo_pgsql.xml +++ b/ci/github/phpunit/pdo_pgsql.xml @@ -24,11 +24,11 @@ - + ../../../lib/Doctrine - + diff --git a/ci/github/phpunit/pdo_sqlite.xml b/ci/github/phpunit/pdo_sqlite.xml index ff282a35ed7..b21059c3910 100644 --- a/ci/github/phpunit/pdo_sqlite.xml +++ b/ci/github/phpunit/pdo_sqlite.xml @@ -22,11 +22,11 @@ - + ../../../lib/Doctrine - + diff --git a/ci/github/phpunit/pgsql.xml b/ci/github/phpunit/pgsql.xml index c4a5c5f207c..8425d03c1eb 100644 --- a/ci/github/phpunit/pgsql.xml +++ b/ci/github/phpunit/pgsql.xml @@ -24,11 +24,11 @@ - + ../../../lib/Doctrine - + diff --git a/ci/github/phpunit/sqlite3.xml b/ci/github/phpunit/sqlite3.xml index c180a20c618..29f1fcbe006 100644 --- a/ci/github/phpunit/sqlite3.xml +++ b/ci/github/phpunit/sqlite3.xml @@ -22,11 +22,11 @@ - + ../../../lib/Doctrine - + From b68cab1b3d4ab52d1945ca3a6b77c574011bbc96 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 17 Jul 2023 00:30:09 +0200 Subject: [PATCH 301/475] Declare compatibility with DBAL 4 (#10843) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e91a420a024..1b5ce482887 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-ctype": "*", "doctrine/collections": "^2.1", "doctrine/common": "^3.3", - "doctrine/dbal": "^3.6", + "doctrine/dbal": "^3.6 || ^4", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.2 || ^2", "doctrine/inflector": "^1.4 || ^2.0", From 2dc19e691909a7a9ee55860117ff47ccadbef4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 25 Jul 2023 00:31:57 +0200 Subject: [PATCH 302/475] Remove outdated comment (#10853) Since support for persistence 2 has been dropped, this method may no longer acces an aliased class name. Besides, providing an FQCN with a leading backslash should work since removing it is the first thing that happens inside AbstractClassMetadataFactory::getMetadataFor(). --- lib/Doctrine/ORM/EntityManager.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index fcc54a27bbe..fdabf133b5d 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -207,13 +207,6 @@ public function rollback(): void /** * Returns the ORM metadata descriptor for a class. * - * The class name must be the fully-qualified class name without a leading backslash - * (as it is returned by get_class($obj)) or an aliased class name. - * - * Examples: - * MyProject\Domain\User - * sales:PriceRequest - * * Internal note: Performance-sensitive method. * * {@inheritDoc} From 2c39b3f118fad3c35bd07a18f6312308e23a6695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 15 Aug 2023 15:44:34 +0200 Subject: [PATCH 303/475] Remove base test case class (#10910) We are using PHPUnit 10, so none of the polyfills in that class are needed now. --- tests/Doctrine/Tests/DoctrineTestCase.php | 59 ------------------- .../Tests/ORM/Cache/CacheConfigTest.php | 4 +- .../Doctrine/Tests/ORM/Cache/CacheKeyTest.php | 4 +- .../Tests/ORM/Cache/CacheLoggerChainTest.php | 4 +- .../ORM/Cache/StatisticsCacheLoggerTest.php | 4 +- .../Doctrine/Tests/ORM/ConfigurationTest.php | 4 +- .../ORM/Functional/Ticket/DDC4024Test.php | 4 +- .../ORM/Tools/Console/ConsoleRunnerTest.php | 4 +- tests/Doctrine/Tests/OrmTestCase.php | 3 +- 9 files changed, 16 insertions(+), 74 deletions(-) delete mode 100644 tests/Doctrine/Tests/DoctrineTestCase.php diff --git a/tests/Doctrine/Tests/DoctrineTestCase.php b/tests/Doctrine/Tests/DoctrineTestCase.php deleted file mode 100644 index b6679a93787..00000000000 --- a/tests/Doctrine/Tests/DoctrineTestCase.php +++ /dev/null @@ -1,59 +0,0 @@ - */ - private static array $phpunitMethodRenames = [ - 'assertMatchesRegularExpression' => 'assertRegExp', // can be removed when PHPUnit 9 is minimum - 'assertDoesNotMatchRegularExpression' => 'assertNotRegExp', // can be removed when PHPUnit 9 is minimum - 'assertFileDoesNotExist' => 'assertFileNotExists', // can be removed PHPUnit 9 is minimum - 'expectExceptionMessageMatches' => 'expectExceptionMessageRegExp', // can be removed when PHPUnit 8 is minimum - ]; - - /** @param array $arguments */ - public static function __callStatic(string $method, array $arguments): mixed - { - if (isset(self::$phpunitMethodRenames[$method])) { - $method = self::$phpunitMethodRenames[$method]; - - return self::$method(...$arguments); - } - - throw new BadMethodCallException(sprintf('%s::%s does not exist', static::class, $method)); - } - - /** @param array $arguments */ - public function __call(string $method, array $arguments): mixed - { - if ($method === 'createStub') { - return $this->getMockBuilder(...$arguments) - ->disableOriginalConstructor() - ->disableOriginalClone() - ->disableArgumentCloning() - ->disallowMockingUnknownTypes() - ->getMock(); - } - - if (isset(self::$phpunitMethodRenames[$method])) { - $method = self::$phpunitMethodRenames[$method]; - - return self::$method(...$arguments); - } - - throw new BadMethodCallException(sprintf('%s::%s does not exist', static::class, $method)); - } -} diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php index b36dad4b409..453f828000c 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php @@ -10,13 +10,13 @@ use Doctrine\ORM\Cache\QueryCacheValidator; use Doctrine\ORM\Cache\TimestampQueryCacheValidator; use Doctrine\ORM\Cache\TimestampRegion; -use Doctrine\Tests\DoctrineTestCase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; #[CoversClass(CacheConfiguration::class)] #[Group('DDC-2183')] -class CacheConfigTest extends DoctrineTestCase +class CacheConfigTest extends TestCase { private CacheConfiguration $config; diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php index 3f8d4465753..ee51e3fc9b5 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php @@ -7,11 +7,11 @@ use Doctrine\ORM\Cache\CacheKey; use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\EntityCacheKey; -use Doctrine\Tests\DoctrineTestCase; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; #[Group('DDC-2183')] -class CacheKeyTest extends DoctrineTestCase +class CacheKeyTest extends TestCase { public function testEntityCacheKeyIdentifierCollision(): void { diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index 685247bcf4a..0edb3faf5f7 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -9,13 +9,13 @@ use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\Logging\CacheLoggerChain; use Doctrine\ORM\Cache\QueryCacheKey; -use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\Cache\State; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; #[Group('DDC-2183')] -class CacheLoggerChainTest extends DoctrineTestCase +class CacheLoggerChainTest extends TestCase { private CacheLoggerChain $logger; private CacheLogger&MockObject $mock; diff --git a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php index 0e9ca861780..e0a6b2922a4 100644 --- a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php @@ -8,12 +8,12 @@ use Doctrine\ORM\Cache\EntityCacheKey; use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger; use Doctrine\ORM\Cache\QueryCacheKey; -use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\Cache\State; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; #[Group('DDC-2183')] -class StatisticsCacheLoggerTest extends DoctrineTestCase +class StatisticsCacheLoggerTest extends TestCase { private StatisticsCacheLogger $logger; diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 568a8709ee4..3e61fa89add 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -16,15 +16,15 @@ use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\Persistence\Mapping\Driver\MappingDriver; -use Doctrine\Tests\DoctrineTestCase; use Doctrine\Tests\Models\DDC753\DDC753CustomRepository; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemPoolInterface; /** * Tests for the Configuration object */ -class ConfigurationTest extends DoctrineTestCase +class ConfigurationTest extends TestCase { use VerifyDeprecations; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php index 3091a47c11f..418254e1d07 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php @@ -5,11 +5,11 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\ORM\NonUniqueResultException; -use Doctrine\Tests\DoctrineTestCase; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; #[Group('DDC4024')] -final class DDC4024Test extends DoctrineTestCase +final class DDC4024Test extends TestCase { public function testConstructorShouldUseProvidedMessage(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php index 7d79068adbd..3d3d89f4b4b 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php @@ -8,16 +8,16 @@ use DBALConsole\Command\ReservedWordsCommand; use Doctrine\ORM\Tools\Console\ConsoleRunner; use Doctrine\ORM\Tools\Console\EntityManagerProvider; -use Doctrine\Tests\DoctrineTestCase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Command\Command; use function class_exists; #[CoversClass(ConsoleRunner::class)] #[Group('DDC-3186')] -final class ConsoleRunnerTest extends DoctrineTestCase +final class ConsoleRunnerTest extends TestCase { public function testCreateApplicationShouldReturnAnApplicationWithTheCorrectCommands(): void { diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 29ec9c09f39..52d0a4d2781 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Configuration; use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\Tests\Mocks\EntityManagerMock; +use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -27,7 +28,7 @@ /** * Base testcase class for all ORM testcases. */ -abstract class OrmTestCase extends DoctrineTestCase +abstract class OrmTestCase extends TestCase { /** * The metadata cache that is shared between all ORM tests (except functional tests). From 501226b90b08c5de07deda30f25454eac647502c Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Thu, 28 Sep 2023 11:02:28 +0200 Subject: [PATCH 304/475] remove reference to removed yaml configuration option --- docs/en/tutorials/getting-started.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index efdba8fd28a..816af0bc89c 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -484,7 +484,7 @@ persisted and what constraints should be applied to them. Metadata for an Entity can be configured using attributes directly in the Entity class itself, or in an external XML file. This -Getting Started guide will demonstrate metadata mappings using all three +Getting Started guide will demonstrate metadata mappings using both methods, but you only need to choose one. .. configuration-block:: From c69044bc9b23f2b2b3daceb6c24ed86867c02164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 3 Oct 2023 12:22:17 +0200 Subject: [PATCH 305/475] Implement InternalProxy as well --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 5ba78cf75ad..dc7eaa0e576 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -99,7 +99,7 @@ public function __construct( $proxyGenerator->setPlaceholder('serializeImpl', $this->generateSerializeImpl(...)); $proxyGenerator->setProxyClassTemplate(self::PROXY_CLASS_TEMPLATE); } else { - $proxyGenerator->setPlaceholder('baseProxyInterface', CommonProxy::class); + $proxyGenerator->setPlaceholder('baseProxyInterface', CommonProxy::class . ', \\' . InternalProxy::class); } parent::__construct($proxyGenerator, $em->getMetadataFactory(), $autoGenerate); From 46ef989f381e64909d008e33cc4d006cced8f670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 6 Oct 2023 23:55:34 +0200 Subject: [PATCH 306/475] Update reference --- docs/en/reference/basic-mapping.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/basic-mapping.rst b/docs/en/reference/basic-mapping.rst index 9e5610aa616..0e3f0210ee6 100644 --- a/docs/en/reference/basic-mapping.rst +++ b/docs/en/reference/basic-mapping.rst @@ -359,7 +359,7 @@ Here is the list of possible generation strategies: a new entity is passed to ``EntityManager#persist``. NONE is the same as leaving off the ``#[GeneratedValue]`` entirely. - ``CUSTOM``: With this option, you can use the ``#[CustomIdGenerator]`` attribute. - It will allow you to pass a :ref:`class of your own to generate the identifiers.` + It will allow you to pass a :ref:`class of your own to generate the identifiers.` Sequence Generator ^^^^^^^^^^^^^^^^^^ From 795e7735d895eb2868533f89b8e0f3b03a8b4a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 Oct 2023 12:07:30 +0200 Subject: [PATCH 307/475] Reject ID collisions in identity map unconditionally --- UPGRADE.md | 6 ++++ lib/Doctrine/ORM/Configuration.php | 15 +++++++-- lib/Doctrine/ORM/UnitOfWork.php | 33 +------------------ .../ORM/Functional/BasicFunctionalTest.php | 2 -- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 20 ----------- 5 files changed, 20 insertions(+), 56 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index c2f5e153d1e..e6b53eb228e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 3.0 +## BC BREAK: collisions in identity map are unconditionally rejected + +`Doctrine\ORM\Configuration::setRejectIdCollisionInIdentityMap()` and +`Doctrine\ORM\Configuration::isRejectIdCollisionInIdentityMapEnabled()` are now +no-ops and will be deprecated in 3.1.0. + ## BC BREAK: Lifecycle callback mapping on embedded classes is now explicitly forbidden Lifecycle callback mapping on embedded classes produced no effect, and is now diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 75e7ea4d5a5..74ce79ec7c0 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -605,13 +605,24 @@ public function setLazyGhostObjectEnabled(bool $flag): void $this->attributes['isLazyGhostObjectEnabled'] = $flag; } + /** To be deprecated in 3.1.0 */ public function setRejectIdCollisionInIdentityMap(bool $flag): void { - $this->attributes['rejectIdCollisionInIdentityMap'] = $flag; + if (! $flag) { + throw new LogicException(<<<'EXCEPTION' + Rejecting ID collisions in the identity map cannot be disabled anymore. + Please remove the call to setRejectIdCollisionInIdentityMap(false). + EXCEPTION); + } } + /** + * To be deprecated in 3.1.0 + * + * @return true + */ public function isRejectIdCollisionInIdentityMapEnabled(): bool { - return $this->attributes['rejectIdCollisionInIdentityMap'] ?? false; + return true; } } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index a69685cf827..0e9ce2c1559 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1485,38 +1485,7 @@ public function addToIdentityMap(object $entity): bool if (isset($this->identityMap[$className][$idHash])) { if ($this->identityMap[$className][$idHash] !== $entity) { - if ($this->em->getConfiguration()->isRejectIdCollisionInIdentityMapEnabled()) { - throw EntityIdentityCollisionException::create($this->identityMap[$className][$idHash], $entity, $idHash); - } - - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10785', - <<<'EXCEPTION' -While adding an entity of class %s with an ID hash of "%s" to the identity map, -another object of class %s was already present for the same ID. This will trigger -an exception in ORM 3.0. - -IDs should uniquely map to entity object instances. This problem may occur if: - -- you use application-provided IDs and reuse ID values; -- database-provided IDs are reassigned after truncating the database without -clearing the EntityManager; -- you might have been using EntityManager#getReference() to create a reference -for a nonexistent ID that was subsequently (by the RDBMS) assigned to another -entity. - -Otherwise, it might be an ORM-internal inconsistency, please report it. - -To opt-in to the new exception, call -\Doctrine\ORM\Configuration::setRejectIdCollisionInIdentityMap on the entity -manager's configuration. -EXCEPTION - , - get_class($entity), - $idHash, - get_class($this->identityMap[$className][$idHash]), - ); + throw EntityIdentityCollisionException::create($this->identityMap[$className][$idHash], $entity, $idHash); } return false; diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index b8354a85b49..10ed85a2bd5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -1079,8 +1079,6 @@ public function testWrongAssociationInstance(): void public function testItThrowsWhenReferenceUsesIdAssignedByDatabase(): void { - $this->_em->getConfiguration()->setRejectIdCollisionInIdentityMap(true); - $user = new CmsUser(); $user->name = 'test'; $user->username = 'test'; diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index ecc93388da6..63e13c319b1 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -628,28 +628,8 @@ public function testRemovedEntityIsRemovedFromOneToManyCollection(): void self::assertEmpty($user->phonenumbers->getSnapshot()); } - public function testItTriggersADeprecationNoticeWhenApplicationProvidedIdsCollide(): void - { - // We're using application-provided IDs and assign the same ID twice - // Note this is about colliding IDs in the identity map in memory. - // Duplicate database-level IDs would be spotted when the EM is flushed. - - $phone1 = new CmsPhonenumber(); - $phone1->phonenumber = '1234'; - $this->_unitOfWork->persist($phone1); - - $phone2 = new CmsPhonenumber(); - $phone2->phonenumber = '1234'; - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/10785'); - - $this->_unitOfWork->persist($phone2); - } - public function testItThrowsWhenApplicationProvidedIdsCollide(): void { - $this->_emMock->getConfiguration()->setRejectIdCollisionInIdentityMap(true); - // We're using application-provided IDs and assign the same ID twice // Note this is about colliding IDs in the identity map in memory. // Duplicate database-level IDs would be spotted when the EM is flushed. From 27009986d789f9e8a0976dc24afffbf83201e1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 Oct 2023 21:49:29 +0200 Subject: [PATCH 308/475] Restore job with --prefer-lowest It is useful to catch misconfigured dependency constraints. It was removed in 413c33274d02ca4d320a6ec95dff8c3951c9ca5c. This implies configuring mocks so as to support psr/cache 1 psr/cache 1 does not use native return types, and phpdoc is not enough to obtain a mock that has typed methods. --- .github/workflows/continuous-integration.yml | 8 +++++++- composer.json | 4 ++-- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 14 ++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 0b1f9c10ddf..dfba1d56b5f 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -41,6 +41,8 @@ jobs: - "pdo_sqlite" proxy: - "common" + deps: + - "highest" include: - php-version: "8.2" dbal-version: "3@dev" @@ -55,6 +57,10 @@ jobs: dbal-version: "default" proxy: "lazy-ghost" extension: "pdo_sqlite" + - php-version: "8.1" + dbal-version: "default" + deps: "lowest" + extension: "pdo_sqlite" steps: - name: "Checkout" @@ -78,6 +84,7 @@ jobs: uses: "ramsey/composer-install@v2" with: composer-options: "--ignore-platform-req=php+" + dependency-versions: "${{ matrix.deps }}" - name: "Run PHPUnit" run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage-no-cache.xml" @@ -314,7 +321,6 @@ jobs: name: "${{ github.job }}-${{ matrix.mysql-version }}-${{ matrix.extension }}-${{ matrix.php-version }}-${{ matrix.dbal-version }}-coverage" path: "coverage*.xml" - upload_coverage: name: "Upload coverage to Codecov" runs-on: "ubuntu-22.04" diff --git a/composer.json b/composer.json index 4f2b29e1aa7..a87a9251146 100644 --- a/composer.json +++ b/composer.json @@ -39,11 +39,11 @@ "doctrine/coding-standard": "^12.0", "phpbench/phpbench": "^1.0", "phpstan/phpstan": "1.10.35", - "phpunit/phpunit": "^10.0.14", + "phpunit/phpunit": "^10.4.0", "psr/log": "^1 || ^2 || ^3", "squizlabs/php_codesniffer": "3.7.2", "symfony/cache": "^5.4 || ^6.2", - "symfony/var-exporter": "^5.4 || ^6.2", + "symfony/var-exporter": "^6.2.13", "vimeo/psalm": "5.15.0" }, "suggest": { diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 67039461394..b04621af004 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -514,11 +514,14 @@ public function testGetParameterColonNormalize(): void public function testGetQueryCacheDriverWithDefaults(): void { - $cache = $this->createMock(CacheItemPoolInterface::class); + $cache = $this->createMock(CacheItemPoolInterface::class); + $cacheItemMock = $this->createMock(CacheItemInterface::class); + $cacheItemMock->method('set')->willReturnSelf(); + $cacheItemMock->method('expiresAfter')->willReturnSelf(); $cache ->expects(self::atLeastOnce()) ->method('getItem') - ->willReturn($this->createMock(CacheItemInterface::class)); + ->willReturn($cacheItemMock); $this->entityManager->getConfiguration()->setQueryCache($cache); $this->entityManager @@ -528,11 +531,14 @@ public function testGetQueryCacheDriverWithDefaults(): void public function testGetQueryCacheDriverWithCacheExplicitlySet(): void { - $cache = $this->createMock(CacheItemPoolInterface::class); + $cache = $this->createMock(CacheItemPoolInterface::class); + $cacheItemMock = $this->createMock(CacheItemInterface::class); + $cacheItemMock->method('set')->willReturnSelf(); + $cacheItemMock->method('expiresAfter')->willReturnSelf(); $cache ->expects(self::atLeastOnce()) ->method('getItem') - ->willReturn($this->createMock(CacheItemInterface::class)); + ->willReturn($cacheItemMock); $this->entityManager ->createQuery('select u from ' . CmsUser::class . ' u') From f3b6c4b3562dcd739362807b6e25e562cb97dadf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 8 Oct 2023 23:18:35 +0200 Subject: [PATCH 309/475] Use lazy ghosts unconditionally (#10969) * Use lazy ghosts unconditionally * Stop extending proxy factory from doctrine/common Extending it no longer serves any purpose. * Transform annotation into actual method --- .github/workflows/continuous-integration.yml | 8 - UPGRADE.md | 14 ++ composer.json | 4 +- lib/Doctrine/ORM/Configuration.php | 30 ++- lib/Doctrine/ORM/Proxy/InternalProxy.php | 3 +- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 181 +------------------ phpstan-baseline.neon | 7 +- psalm-baseline.xml | 22 --- tests/Doctrine/Tests/TestUtil.php | 21 --- 9 files changed, 37 insertions(+), 253 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index dfba1d56b5f..21d212a509e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -39,8 +39,6 @@ jobs: - "default" extension: - "pdo_sqlite" - proxy: - - "common" deps: - "highest" include: @@ -53,10 +51,6 @@ jobs: - php-version: "8.2" dbal-version: "default" extension: "sqlite3" - - php-version: "8.1" - dbal-version: "default" - proxy: "lazy-ghost" - extension: "pdo_sqlite" - php-version: "8.1" dbal-version: "default" deps: "lowest" @@ -90,13 +84,11 @@ jobs: run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage-no-cache.xml" env: ENABLE_SECOND_LEVEL_CACHE: 0 - ORM_PROXY_IMPLEMENTATION: "${{ matrix.proxy }}" - name: "Run PHPUnit with Second Level Cache" run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --exclude-group performance,non-cacheable,locking_functional --coverage-clover=coverage-cache.xml" env: ENABLE_SECOND_LEVEL_CACHE: 1 - ORM_PROXY_IMPLEMENTATION: "${{ matrix.proxy }}" - name: "Upload coverage file" uses: "actions/upload-artifact@v3" diff --git a/UPGRADE.md b/UPGRADE.md index e6b53eb228e..8e57362503b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,19 @@ # Upgrade to 3.0 +## BC BREAK: `Doctrine\ORM\Proxy\ProxyFactory` no longer extends abstract factory from `doctrine/common` + +It is no longer possible to call methods, constants or properties inherited +from that class on a `ProxyFactory` instance. + +`Doctrine\ORM\Proxy\ProxyFactory::createProxyDefinition()` and +`Doctrine\ORM\Proxy\ProxyFactory::resetUninitializedProxy()` are removed as well. + +## BC BREAK: lazy ghosts are enabled unconditionally + +`Doctrine\ORM\Configuration::setLazyGhostObjectEnabled()` and +`Doctrine\ORM\Configuration::isLazyGhostObjectEnabled()` are now no-ops and +will be deprecated in 3.1.0 + ## BC BREAK: collisions in identity map are unconditionally rejected `Doctrine\ORM\Configuration::setRejectIdCollisionInIdentityMap()` and diff --git a/composer.json b/composer.json index a87a9251146..2328a798c58 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,8 @@ "doctrine/lexer": "^2.1 || ^3", "doctrine/persistence": "^3.1.1", "psr/cache": "^1 || ^2 || ^3", - "symfony/console": "^5.4 || ^6.0 || ^7.0" + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/var-exporter": "~6.2.13 || ^6.3.2" }, "require-dev": { "doctrine/coding-standard": "^12.0", @@ -43,7 +44,6 @@ "psr/log": "^1 || ^2 || ^3", "squizlabs/php_codesniffer": "3.7.2", "symfony/cache": "^5.4 || ^6.2", - "symfony/var-exporter": "^6.2.13", "vimeo/psalm": "5.15.0" }, "suggest": { diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 74ce79ec7c0..2bf45006d76 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -21,15 +21,12 @@ use Doctrine\ORM\Repository\DefaultRepositoryFactory; use Doctrine\ORM\Repository\RepositoryFactory; use Doctrine\Persistence\Mapping\Driver\MappingDriver; -use Doctrine\Persistence\Reflection\RuntimeReflectionProperty; use LogicException; use Psr\Cache\CacheItemPoolInterface; -use Symfony\Component\VarExporter\LazyGhostTrait; use function class_exists; use function is_a; use function strtolower; -use function trait_exists; /** * Configuration container for all configuration options of Doctrine. @@ -581,28 +578,25 @@ public function setSchemaIgnoreClasses(array $schemaIgnoreClasses): void $this->attributes['schemaIgnoreClasses'] = $schemaIgnoreClasses; } + /** + * To be deprecated in 3.1.0 + * + * @return true + */ public function isLazyGhostObjectEnabled(): bool { - return $this->attributes['isLazyGhostObjectEnabled'] ?? false; + return true; } + /** To be deprecated in 3.1.0 */ public function setLazyGhostObjectEnabled(bool $flag): void { - if ($flag && ! trait_exists(LazyGhostTrait::class)) { - throw new LogicException( - 'Lazy ghost objects cannot be enabled because the "symfony/var-exporter" library' - . ' version 6.2 or higher is not installed. Please run "composer require symfony/var-exporter:^6.2".', - ); - } - - if ($flag && ! class_exists(RuntimeReflectionProperty::class)) { - throw new LogicException( - 'Lazy ghost objects cannot be enabled because the "doctrine/persistence" library' - . ' version 3.1 or higher is not installed. Please run "composer update doctrine/persistence".', - ); + if (! $flag) { + throw new LogicException(<<<'EXCEPTION' + The lazy ghost object feature cannot be disabled anymore. + Please remove the call to setLazyGhostObjectEnabled(false). + EXCEPTION); } - - $this->attributes['isLazyGhostObjectEnabled'] = $flag; } /** To be deprecated in 3.1.0 */ diff --git a/lib/Doctrine/ORM/Proxy/InternalProxy.php b/lib/Doctrine/ORM/Proxy/InternalProxy.php index baa5703f2a3..7c1d8339bd3 100644 --- a/lib/Doctrine/ORM/Proxy/InternalProxy.php +++ b/lib/Doctrine/ORM/Proxy/InternalProxy.php @@ -11,9 +11,8 @@ * * @template T of object * @template-extends Proxy - * - * @method void __setInitialized(bool $initialized) */ interface InternalProxy extends Proxy { + public function __setInitialized(bool $initialized): void; } diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 2a583488863..f04bd8c6625 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -5,11 +5,6 @@ namespace Doctrine\ORM\Proxy; use Closure; -use Doctrine\Common\Proxy\AbstractProxyFactory; -use Doctrine\Common\Proxy\Proxy as CommonProxy; -use Doctrine\Common\Proxy\ProxyDefinition; -use Doctrine\Common\Proxy\ProxyGenerator; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\ORMInvalidArgumentException; @@ -20,7 +15,6 @@ use Doctrine\Persistence\Proxy; use ReflectionProperty; use Symfony\Component\VarExporter\ProxyHelper; -use Throwable; use function array_combine; use function array_flip; @@ -51,12 +45,11 @@ use function ucfirst; use const DIRECTORY_SEPARATOR; -use const PHP_VERSION_ID; /** * This factory is used to create proxy objects for entities at runtime. */ -class ProxyFactory extends AbstractProxyFactory +class ProxyFactory { /** * Never autogenerate a proxy and rely that it was generated by some @@ -137,9 +130,6 @@ public function __serialize(): array /** @var array */ private $proxyFactories = []; - /** @var bool */ - private $isLazyGhostObjectEnabled = true; - /** * Initializes a new instance of the ProxyFactory class that is * connected to the given EntityManager. @@ -155,23 +145,6 @@ public function __construct( private readonly string $proxyNs, bool|int $autoGenerate = self::AUTOGENERATE_NEVER, ) { - if (! $em->getConfiguration()->isLazyGhostObjectEnabled()) { - if (PHP_VERSION_ID >= 80100) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10837/', - 'Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\ORM\Configuration::setLazyGhostObjectEnabled(true) is called to enable them.', - ); - } - - $this->isLazyGhostObjectEnabled = false; - - $proxyGenerator = new ProxyGenerator($proxyDir, $proxyNs); - $proxyGenerator->setPlaceholder('baseProxyInterface', CommonProxy::class . ', \\' . InternalProxy::class); - - parent::__construct($proxyGenerator, $em->getMetadataFactory(), $autoGenerate); - } - if (! $proxyDir) { throw ORMInvalidArgumentException::proxyDirectoryRequired(); } @@ -191,14 +164,13 @@ public function __construct( } /** - * {@inheritDoc} + * @param class-string $className + * @param array $identifier + * + * @return InternalProxy */ - public function getProxy($className, array $identifier) + public function getProxy(string $className, array $identifier) { - if (! $this->isLazyGhostObjectEnabled) { - return parent::getProxy($className, $identifier); - } - $proxyFactory = $this->proxyFactories[$className] ?? $this->getProxyFactory($className); return $proxyFactory($identifier); @@ -214,12 +186,8 @@ public function getProxy($className, array $identifier) * * @return int Number of generated proxies. */ - public function generateProxyClasses(array $classes, $proxyDir = null) + public function generateProxyClasses(array $classes, $proxyDir = null): int { - if (! $this->isLazyGhostObjectEnabled) { - return parent::generateProxyClasses($classes, $proxyDir); - } - $generated = 0; foreach ($classes as $class) { @@ -238,16 +206,6 @@ public function generateProxyClasses(array $classes, $proxyDir = null) return $generated; } - /** - * {@inheritDoc} - * - * @deprecated ProxyFactory::resetUninitializedProxy() is deprecated and will be removed in version 3.0 of doctrine/orm. - */ - public function resetUninitializedProxy(CommonProxy $proxy) - { - return parent::resetUninitializedProxy($proxy); - } - protected function skipClass(ClassMetadata $metadata): bool { return $metadata->isMappedSuperclass @@ -255,91 +213,6 @@ protected function skipClass(ClassMetadata $metadata): bool || $metadata->getReflectionClass()->isAbstract(); } - /** - * {@inheritDoc} - * - * @deprecated ProxyFactory::createProxyDefinition() is deprecated and will be removed in version 3.0 of doctrine/orm. - */ - protected function createProxyDefinition($className): ProxyDefinition - { - $classMetadata = $this->em->getClassMetadata($className); - $entityPersister = $this->uow->getEntityPersister($className); - - $initializer = $this->createInitializer($classMetadata, $entityPersister); - $cloner = $this->createCloner($classMetadata, $entityPersister); - - return new ProxyDefinition( - self::generateProxyClassName($className, $this->proxyNs), - $classMetadata->getIdentifierFieldNames(), - $classMetadata->getReflectionProperties(), - $initializer, - $cloner, - ); - } - - /** - * Creates a closure capable of initializing a proxy - * - * @deprecated ProxyFactory::createInitializer() is deprecated and will be removed in version 3.0 of doctrine/orm. - * - * @psalm-return Closure(CommonProxy):void - * - * @throws EntityNotFoundException - */ - private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister): Closure - { - $wakeupProxy = $classMetadata->getReflectionClass()->hasMethod('__wakeup'); - - return function (CommonProxy $proxy) use ($entityPersister, $classMetadata, $wakeupProxy): void { - $initializer = $proxy->__getInitializer(); - $cloner = $proxy->__getCloner(); - - $proxy->__setInitializer(null); - $proxy->__setCloner(null); - - if ($proxy->__isInitialized()) { - return; - } - - $properties = $proxy->__getLazyProperties(); - - foreach ($properties as $propertyName => $property) { - if (! isset($proxy->$propertyName)) { - $proxy->$propertyName = $properties[$propertyName]; - } - } - - $proxy->__setInitialized(true); - - if ($wakeupProxy) { - $proxy->__wakeup(); - } - - $identifier = $classMetadata->getIdentifierValues($proxy); - - try { - $entity = $entityPersister->loadById($identifier, $proxy); - } catch (Throwable $exception) { - $proxy->__setInitializer($initializer); - $proxy->__setCloner($cloner); - $proxy->__setInitialized(false); - - throw $exception; - } - - if ($entity === null) { - $proxy->__setInitializer($initializer); - $proxy->__setCloner($cloner); - $proxy->__setInitialized(false); - - throw EntityNotFoundException::fromClassNameAndIdentifier( - $classMetadata->getName(), - $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier), - ); - } - }; - } - /** * Creates a closure capable of initializing a proxy * @@ -376,46 +249,6 @@ private function createLazyInitializer(ClassMetadata $classMetadata, EntityPersi }; } - /** - * Creates a closure capable of finalizing state a cloned proxy - * - * @deprecated ProxyFactory::createCloner() is deprecated and will be removed in version 3.0 of doctrine/orm. - * - * @psalm-return Closure(CommonProxy):void - * - * @throws EntityNotFoundException - */ - private function createCloner(ClassMetadata $classMetadata, EntityPersister $entityPersister): Closure - { - return function (CommonProxy $proxy) use ($entityPersister, $classMetadata): void { - if ($proxy->__isInitialized()) { - return; - } - - $proxy->__setInitialized(true); - $proxy->__setInitializer(null); - - $class = $entityPersister->getClassMetadata(); - $identifier = $classMetadata->getIdentifierValues($proxy); - $original = $entityPersister->loadById($identifier); - - if ($original === null) { - throw EntityNotFoundException::fromClassNameAndIdentifier( - $classMetadata->getName(), - $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier), - ); - } - - foreach ($class->getReflectionProperties() as $property) { - if (! $class->hasField($property->name) && ! $class->hasAssociation($property->name)) { - continue; - } - - $property->setValue($proxy, $property->getValue($original)); - } - }; - } - private function getProxyFileName(string $className, string $baseDirectory): string { $baseDirectory = $baseDirectory ?: $this->proxyDir; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 31b43e55fc0..e76366ac6fc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -190,11 +190,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Proxy/ProxyFactory.php - - - message: "#^Call to an undefined method Doctrine\\\\Common\\\\Proxy\\\\Proxy\\:\\:__wakeup\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Proxy/ProxyFactory.php - - message: "#^Call to an undefined static method Doctrine\\\\ORM\\\\Proxy\\\\ProxyFactory\\:\\:createLazyGhost\\(\\)\\.$#" count: 1 @@ -212,7 +207,7 @@ parameters: - message: "#^Parameter \\#1 \\$class of method Doctrine\\\\ORM\\\\Utility\\\\IdentifierFlattener\\:\\:flattenIdentifier\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" - count: 3 + count: 1 path: lib/Doctrine/ORM/Proxy/ProxyFactory.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 6f4c80c5c96..6ea5468a0fa 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -738,16 +738,7 @@ $classMetadata - $classMetadata - $classMetadata - - createCloner - createInitializer - - - getReflectionProperties()]]> - Closure @@ -758,9 +749,6 @@ isEmbeddedClass]]> isMappedSuperclass]]> - - name]]> - proxyFactories[$className] = $proxyFactory]]> @@ -770,20 +758,10 @@ $i - - name]]> - - - getValue - setValue - 4]]> - - __wakeup - setProxyDir(__DIR__ . '/Proxies'); $configuration->setProxyNamespace('Doctrine\Tests\Proxies'); - - $proxyImplementation = getenv('ORM_PROXY_IMPLEMENTATION') - ?: (trait_exists(LazyGhostTrait::class) ? 'lazy-ghost' : 'common'); - - switch ($proxyImplementation) { - case 'lazy-ghost': - $configuration->setLazyGhostObjectEnabled(true); - - return; - - case 'common': - $configuration->setLazyGhostObjectEnabled(false); - - return; - } - - throw new LogicException(sprintf('Unknown proxy implementation: %s.', $proxyImplementation)); } private static function initializeDatabase(): void From 83d46d7cf988c2dba4c750eff1974365615c7c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 9 Oct 2023 16:13:29 +0200 Subject: [PATCH 310/475] Change EntityPersister return type Calling UnitOfWork::assignPostInsertId() is now the way to go. --- UPGRADE.md | 6 ++++++ .../Persister/Entity/AbstractEntityPersister.php | 7 ++----- .../Persisters/Entity/BasicEntityPersister.php | 5 +---- .../ORM/Persisters/Entity/EntityPersister.php | 8 +------- .../Persisters/Entity/JoinedSubclassPersister.php | 5 +---- lib/Doctrine/ORM/UnitOfWork.php | 15 +-------------- .../Doctrine/Tests/Mocks/EntityPersisterMock.php | 7 ++++--- .../Persister/Entity/EntityPersisterTestCase.php | 5 ++--- 8 files changed, 18 insertions(+), 40 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 8e57362503b..4b221af187f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 3.0 +## BC BREAK: `Doctrine\ORM\Persister\Entity\EntityPersister::executeInserts()` return type changed to `void` + +Implementors should adapt to the new signature, and should call +`UnitOfWork::assignPostInsertId()` for each entry in the previously returned +array. + ## BC BREAK: `Doctrine\ORM\Proxy\ProxyFactory` no longer extends abstract factory from `doctrine/common` It is no longer possible to call methods, constants or properties inherited diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 87230476db9..1f442728902 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -268,10 +268,7 @@ public function getOwningTable(string $fieldName): string return $this->persister->getOwningTable($fieldName); } - /** - * {@inheritDoc} - */ - public function executeInserts() + public function executeInserts(): void { // The commit order/foreign key relationships may make it necessary that multiple calls to executeInsert() // are performed, so collect all the new entities. @@ -281,7 +278,7 @@ public function executeInserts() $this->queuedCache['insert'] = array_merge($this->queuedCache['insert'] ?? [], $newInserts); } - return $this->persister->executeInserts(); + $this->persister->executeInserts(); } /** diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 613854f925c..380f3937eee 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -218,10 +218,7 @@ public function getInserts(): array return $this->queuedInserts; } - /** - * {@inheritDoc} - */ - public function executeInserts() + public function executeInserts(): void { if (! $this->queuedInserts) { return; diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php index 28d5ae317ad..6b278a711d0 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php @@ -100,14 +100,8 @@ public function addInsert(object $entity): void; * Executes all queued entity insertions. * * If no inserts are queued, invoking this method is a NOOP. - * - * @psalm-return void|list Returning an array of generated post-insert IDs is deprecated, implementations - * should call UnitOfWork::assignPostInsertId() and return void. */ - public function executeInserts(); + public function executeInserts(): void; /** * Updates a managed entity. The entity is updated according to its current changeset diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index b439cd284b1..51520eb17bd 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -94,10 +94,7 @@ public function getOwningTable(string $fieldName): string return $tableName; } - /** - * {@inheritDoc} - */ - public function executeInserts() + public function executeInserts(): void { if (! $this->queuedInserts) { return; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 0e9ce2c1559..7f9e3dc1e1d 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1042,20 +1042,7 @@ private function executeInserts(): void unset($this->entityInsertions[$oid]); - $postInsertIds = $persister->executeInserts(); - - if (is_array($postInsertIds)) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10743/', - 'Returning post insert IDs from \Doctrine\ORM\Persisters\Entity\EntityPersister::executeInserts() is deprecated and will not be supported in Doctrine ORM 3.0. Make the persister call Doctrine\ORM\UnitOfWork::assignPostInsertId() instead.', - ); - - // Persister returned post-insert IDs - foreach ($postInsertIds as $postInsertId) { - $this->assignPostInsertId($postInsertId['entity'], $postInsertId['generatedId']); - } - } + $persister->executeInserts(); if (! isset($this->entityIdentifiers[$oid])) { //entity was not added to identity map because some identifiers are foreign keys to new entities. diff --git a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php index 95dfc9c94b0..fbc8d072d13 100644 --- a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php @@ -38,10 +38,11 @@ public function addInsert(object $entity): void ]; } - /** @psalm-return list */ - public function executeInserts(): array + public function executeInserts(): void { - return $this->postInsertIds; + foreach ($this->postInsertIds as $item) { + $this->em->getUnitOfWork()->assignPostInsertId($item['entity'], $item['generatedId']); + } } public function setMockIdGeneratorType(int $genType): void diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php index ab122fee553..dbb4788496d 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php @@ -173,10 +173,9 @@ public function testInvokeExecuteInserts(): void $persister = $this->createPersisterDefault(); $this->entityPersister->expects(self::once()) - ->method('executeInserts') - ->willReturn(['id' => 1]); + ->method('executeInserts'); - self::assertSame(['id' => 1], $persister->executeInserts()); + $persister->executeInserts(); } public function testInvokeUpdate(): void From 7e51a09347d8ab395c5bd6b3dbe2958fca6b0577 Mon Sep 17 00:00:00 2001 From: Mariusz Soltys Date: Tue, 10 Oct 2023 11:15:33 +0100 Subject: [PATCH 311/475] Updated order of mapping attribute parameters --- UPGRADE.md | 5 +++++ lib/Doctrine/ORM/Mapping/Index.php | 2 +- lib/Doctrine/ORM/Mapping/OneToMany.php | 2 +- lib/Doctrine/ORM/Mapping/OneToOne.php | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index b8680f7ed89..0b618631303 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.0 +## Minor BC BREAK: Changed order of arguments passed to `OneToOne`, `ManyToOne` and `Index` mapping PHP attributes + +To keep PHP mapping attributes consistent, order of arguments passed to above attributes has been changed +so `$targetEntity` is a first argument now. This change affects only non-named arguments usage. + ## BC BREAK: `Doctrine\ORM\Persister\Entity\EntityPersister::executeInserts()` return type changed to `void` Implementors should adapt to the new signature, and should call diff --git a/lib/Doctrine/ORM/Mapping/Index.php b/lib/Doctrine/ORM/Mapping/Index.php index f58adfb1340..1de939e506e 100644 --- a/lib/Doctrine/ORM/Mapping/Index.php +++ b/lib/Doctrine/ORM/Mapping/Index.php @@ -16,9 +16,9 @@ final class Index implements MappingAttribute * @param array|null $options */ public function __construct( + public readonly string|null $name = null, public readonly array|null $columns = null, public readonly array|null $fields = null, - public readonly string|null $name = null, public readonly array|null $flags = null, public readonly array|null $options = null, ) { diff --git a/lib/Doctrine/ORM/Mapping/OneToMany.php b/lib/Doctrine/ORM/Mapping/OneToMany.php index 4eac8842ee6..d71c4f93416 100644 --- a/lib/Doctrine/ORM/Mapping/OneToMany.php +++ b/lib/Doctrine/ORM/Mapping/OneToMany.php @@ -15,8 +15,8 @@ final class OneToMany implements MappingAttribute * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch */ public function __construct( - public readonly string|null $mappedBy = null, public readonly string|null $targetEntity = null, + public readonly string|null $mappedBy = null, public readonly array|null $cascade = null, public readonly string $fetch = 'LAZY', public readonly bool $orphanRemoval = false, diff --git a/lib/Doctrine/ORM/Mapping/OneToOne.php b/lib/Doctrine/ORM/Mapping/OneToOne.php index e3e64559a6f..1ddf21c8fe6 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOne.php +++ b/lib/Doctrine/ORM/Mapping/OneToOne.php @@ -15,9 +15,9 @@ final class OneToOne implements MappingAttribute * @psalm-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch */ public function __construct( + public readonly string|null $targetEntity = null, public readonly string|null $mappedBy = null, public readonly string|null $inversedBy = null, - public readonly string|null $targetEntity = null, public readonly array|null $cascade = null, public readonly string $fetch = 'LAZY', public readonly bool $orphanRemoval = false, From 2cf0c59f7aaf8203ec5ebc3ebc32a81da4a6ebc8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 10 Oct 2023 12:42:04 +0200 Subject: [PATCH 312/475] Allow VarExporter 7 (#10984) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2328a798c58..11d64a69776 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "doctrine/persistence": "^3.1.1", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^5.4 || ^6.0 || ^7.0", - "symfony/var-exporter": "~6.2.13 || ^6.3.2" + "symfony/var-exporter": "~6.2.13 || ^6.3.2 || ^7.0" }, "require-dev": { "doctrine/coding-standard": "^12.0", From 99fe3b5c5bcf4f1355282fe3507d886159f8b178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 9 Oct 2023 17:12:45 +0200 Subject: [PATCH 313/475] Remove partial syntax in DQL It is no longer possible to use the "PARTIAL" keyword in a DQL query, or to artificially build an AST with a partial object expression. It is still possible to use the result set mapping API to build partial objects. --- UPGRADE.md | 7 + docs/en/index.rst | 1 - .../reference/dql-doctrine-query-language.rst | 40 +----- docs/en/reference/partial-objects.rst | 98 -------------- docs/en/sidebar.rst | 1 - lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 5 - .../Cache/Exception/FeatureNotImplemented.php | 5 - .../ORM/Decorator/EntityManagerDecorator.php | 1 - lib/Doctrine/ORM/EntityManager.php | 1 - lib/Doctrine/ORM/Query.php | 8 -- .../ORM/Query/AST/PartialObjectExpression.php | 15 --- lib/Doctrine/ORM/Query/Parser.php | 120 +----------------- lib/Doctrine/ORM/Query/SqlWalker.php | 67 +++------- lib/Doctrine/ORM/Query/TokenType.php | 1 - lib/Doctrine/ORM/UnitOfWork.php | 13 -- ...PartialObjectHydrationPerformanceBench.php | 84 ------------ ...PartialObjectHydrationPerformanceBench.php | 72 ----------- .../OneToOneUnidirectionalAssociationTest.php | 14 -- .../ORM/Functional/PostLoadEventTest.php | 21 --- .../SecondLevelCacheQueryCacheTest.php | 25 ---- .../ORM/Functional/Ticket/DDC163Test.php | 2 +- .../ORM/Functional/Ticket/DDC2519Test.php | 76 ----------- .../ORM/Functional/Ticket/GH8443Test.php | 32 ----- .../Tests/ORM/Functional/ValueObjectsTest.php | 61 --------- .../ORM/Query/LanguageRecognitionTest.php | 10 -- .../ORM/Query/SelectSqlGenerationTest.php | 106 +--------------- .../LimitSubqueryOutputWalkerTest.php | 18 +-- 27 files changed, 37 insertions(+), 867 deletions(-) delete mode 100644 docs/en/reference/partial-objects.rst delete mode 100644 lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php delete mode 100644 tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php delete mode 100644 tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php delete mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php diff --git a/UPGRADE.md b/UPGRADE.md index 66220382f44..10826e83229 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,12 @@ # Upgrade to 3.0 +## BC BREAK: Partial objects are removed + +- The `PARTIAL` keyword in DQL no longer exists. +- `Doctrine\ORM\Query\AST\PartialObjectExpression`is removed. +- `Doctrine\ORM\Query\SqlWalker::HINT_PARTIAL` and + `Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD` are removed. + ## BC BREAK: `Doctrine\ORM\Persister\Entity\EntityPersister::executeInserts()` return type changed to `void` Implementors should adapt to the new signature, and should call diff --git a/docs/en/index.rst b/docs/en/index.rst index 4977670291a..91d2df8ca89 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -73,7 +73,6 @@ Advanced Topics * :doc:`TypedFieldMapper ` * :doc:`Improving Performance ` * :doc:`Caching ` -* :doc:`Partial Objects ` * :doc:`Change Tracking Policies ` * :doc:`Best Practices ` * :doc:`Metadata Drivers ` diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index d84c4b00efe..d3ad8bca845 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -518,33 +518,6 @@ when the DQL is switched to an arbitrary join. - HAVING is applied to the results of a query after aggregation (GROUP BY) - -Partial Object Syntax -^^^^^^^^^^^^^^^^^^^^^ - -By default when you run a DQL query in Doctrine and select only a -subset of the fields for a given entity, you do not receive objects -back. Instead, you receive only arrays as a flat rectangular result -set, similar to how you would if you were just using SQL directly -and joining some data. - -If you want to select partial objects you can use the ``partial`` -DQL keyword: - -.. code-block:: php - - createQuery('SELECT partial u.{id, username} FROM CmsUser u'); - $users = $query->getResult(); // array of partially loaded CmsUser objects - -You use the partial syntax when joining as well: - -.. code-block:: php - - createQuery('SELECT partial u.{id, username}, partial a.{id, name} FROM CmsUser u JOIN u.articles a'); - $users = $query->getResult(); // array of partially loaded CmsUser objects - "NEW" Operator Syntax ^^^^^^^^^^^^^^^^^^^^^ @@ -1417,15 +1390,6 @@ exist mostly internal query hints that are not be consumed in userland. However the following few hints are to be used in userland: - -- ``Query::HINT_FORCE_PARTIAL_LOAD`` - Allows to hydrate objects - although not all their columns are fetched. This query hint can be - used to handle memory consumption problems with large result-sets - that contain char or binary data. Doctrine has no way of implicitly - reloading this data. Partially loaded objects have to be passed to - ``EntityManager::refresh()`` if they are to be reloaded fully from - the database. This query hint is deprecated and will be removed - in the future (\ `Details `_) - ``Query::HINT_REFRESH`` - This query is used internally by ``EntityManager::refresh()`` and can be used in userland as well. If you specify this hint and a query returns the data for an entity @@ -1678,10 +1642,8 @@ Select Expressions .. code-block:: php - SelectExpression ::= (IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression | NewObjectExpression) [["AS"] ["HIDDEN"] AliasResultVariable] + SelectExpression ::= (IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | "(" Subselect ")" | CaseExpression | NewObjectExpression) [["AS"] ["HIDDEN"] AliasResultVariable] SimpleSelectExpression ::= (StateFieldPathExpression | IdentificationVariable | FunctionDeclaration | AggregateExpression | "(" Subselect ")" | ScalarExpression) [["AS"] AliasResultVariable] - PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet - PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}" NewObjectExpression ::= "NEW" AbstractSchemaName "(" NewObjectArg {"," NewObjectArg}* ")" NewObjectArg ::= ScalarExpression | "(" Subselect ")" diff --git a/docs/en/reference/partial-objects.rst b/docs/en/reference/partial-objects.rst deleted file mode 100644 index 51f173adf6c..00000000000 --- a/docs/en/reference/partial-objects.rst +++ /dev/null @@ -1,98 +0,0 @@ -Partial Objects -=============== - - -.. note:: - - Creating Partial Objects through DQL is deprecated and - will be removed in the future, use data transfer object - support in DQL instead. (\ `Details - `_) - -A partial object is an object whose state is not fully initialized -after being reconstituted from the database and that is -disconnected from the rest of its data. The following section will -describe why partial objects are problematic and what the approach -of Doctrine2 to this problem is. - -.. note:: - - The partial object problem in general does not apply to - methods or queries where you do not retrieve the query result as - objects. Examples are: ``Query#getArrayResult()``, - ``Query#getScalarResult()``, ``Query#getSingleScalarResult()``, - etc. - -.. warning:: - - Use of partial objects is tricky. Fields that are not retrieved - from the database will not be updated by the UnitOfWork even if they - get changed in your objects. You can only promote a partial object - to a fully-loaded object by calling ``EntityManager#refresh()`` - or a DQL query with the refresh flag. - - -What is the problem? --------------------- - -In short, partial objects are problematic because they are usually -objects with broken invariants. As such, code that uses these -partial objects tends to be very fragile and either needs to "know" -which fields or methods can be safely accessed or add checks around -every field access or method invocation. The same holds true for -the internals, i.e. the method implementations, of such objects. -You usually simply assume the state you need in the method is -available, after all you properly constructed this object before -you pushed it into the database, right? These blind assumptions can -quickly lead to null reference errors when working with such -partial objects. - -It gets worse with the scenario of an optional association (0..1 to -1). When the associated field is NULL, you don't know whether this -object does not have an associated object or whether it was simply -not loaded when the owning object was loaded from the database. - -These are reasons why many ORMs do not allow partial objects at all -and instead you always have to load an object with all its fields -(associations being proxied). One secure way to allow partial -objects is if the programming language/platform allows the ORM tool -to hook deeply into the object and instrument it in such a way that -individual fields (not only associations) can be loaded lazily on -first access. This is possible in Java, for example, through -bytecode instrumentation. In PHP though this is not possible, so -there is no way to have "secure" partial objects in an ORM with -transparent persistence. - -Doctrine, by default, does not allow partial objects. That means, -any query that only selects partial object data and wants to -retrieve the result as objects (i.e. ``Query#getResult()``) will -raise an exception telling you that partial objects are dangerous. -If you want to force a query to return you partial objects, -possibly as a performance tweak, you can use the ``partial`` -keyword as follows: - -.. code-block:: php - - createQuery("select partial u.{id,name} from MyApp\Domain\User u"); - -You can also get a partial reference instead of a proxy reference by -calling: - -.. code-block:: php - - getPartialReference('MyApp\Domain\User', 1); - -Partial references are objects with only the identifiers set as they -are passed to the second argument of the ``getPartialReference()`` method. -All other fields are null. - -When should I force partial objects? ------------------------------------- - -Mainly for optimization purposes, but be careful of premature -optimization as partial objects lead to potentially more fragile -code. - - diff --git a/docs/en/sidebar.rst b/docs/en/sidebar.rst index 460e4236948..4dfc08c4540 100644 --- a/docs/en/sidebar.rst +++ b/docs/en/sidebar.rst @@ -40,7 +40,6 @@ reference/query-builder reference/native-sql reference/change-tracking-policies - reference/partial-objects reference/attributes-reference reference/xml-mapping reference/php-mapping diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 08e703cd4b0..f3bb8ac95c8 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -16,7 +16,6 @@ use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\UnitOfWork; use function array_map; @@ -211,10 +210,6 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, ar throw FeatureNotImplemented::nonSelectStatements(); } - if (($hints[SqlWalker::HINT_PARTIAL] ?? false) === true || ($hints[Query::HINT_FORCE_PARTIAL_LOAD] ?? false) === true) { - throw FeatureNotImplemented::partialEntities(); - } - if (! ($key->cacheMode & Cache::MODE_PUT)) { return false; } diff --git a/lib/Doctrine/ORM/Cache/Exception/FeatureNotImplemented.php b/lib/Doctrine/ORM/Cache/Exception/FeatureNotImplemented.php index 7bae90b775d..8767d574190 100644 --- a/lib/Doctrine/ORM/Cache/Exception/FeatureNotImplemented.php +++ b/lib/Doctrine/ORM/Cache/Exception/FeatureNotImplemented.php @@ -20,9 +20,4 @@ public static function nonSelectStatements(): self { return new self('Second-level cache query supports only select statements.'); } - - public static function partialEntities(): self - { - return new self('Second level cache does not support partial entities.'); - } } diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index 19f70b94b29..9cac7df7a20 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -8,7 +8,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 49f902bea54..d42a1d6b648 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -10,7 +10,6 @@ use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Exception\InvalidHydrationMode; use Doctrine\ORM\Exception\MissingIdentifierField; diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 8c44eba8afa..5b0ceb7a97c 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -70,14 +70,6 @@ class Query extends AbstractQuery */ public const HINT_REFRESH_ENTITY = 'doctrine.refresh.entity'; - /** - * The forcePartialLoad query hint forces a particular query to return - * partial objects. - * - * @todo Rename: HINT_OPTIMIZE - */ - public const HINT_FORCE_PARTIAL_LOAD = 'doctrine.forcePartialLoad'; - /** * The includeMetaColumns query hint causes meta columns like foreign keys and * discriminator columns to be selected and returned as part of the query result. diff --git a/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php b/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php deleted file mode 100644 index 875f4453fe1..00000000000 --- a/lib/Doctrine/ORM/Query/AST/PartialObjectExpression.php +++ /dev/null @@ -1,15 +0,0 @@ - */ private array $deferredIdentificationVariables = []; - /** @psalm-var list */ - private array $deferredPartialObjectExpressions = []; - /** @psalm-var list */ private array $deferredPathExpressions = []; @@ -229,10 +224,6 @@ public function getAST(): AST\SelectStatement|AST\UpdateStatement|AST\DeleteStat // This also allows post-processing of the AST for modification purposes. $this->processDeferredIdentificationVariables(); - if ($this->deferredPartialObjectExpressions) { - $this->processDeferredPartialObjectExpressions(); - } - if ($this->deferredPathExpressions) { $this->processDeferredPathExpressions(); } @@ -608,44 +599,6 @@ private function processDeferredNewObjectExpressions(AST\SelectStatement $AST): } } - /** - * Validates that the given PartialObjectExpression is semantically correct. - * It must exist in query components list. - */ - private function processDeferredPartialObjectExpressions(): void - { - foreach ($this->deferredPartialObjectExpressions as $deferredItem) { - $expr = $deferredItem['expression']; - $class = $this->getMetadataForDqlAlias($expr->identificationVariable); - - foreach ($expr->partialFieldSet as $field) { - if (isset($class->fieldMappings[$field])) { - continue; - } - - if ( - isset($class->associationMappings[$field]) && - $class->associationMappings[$field]->isToOneOwningSide() - ) { - continue; - } - - $this->semanticalError(sprintf( - "There is no mapped field named '%s' on class %s.", - $field, - $class->name, - ), $deferredItem['token']); - } - - if (array_intersect($class->identifier, $expr->partialFieldSet) !== $class->identifier) { - $this->semanticalError( - 'The partial field selection of class ' . $class->name . ' must contain the identifier.', - $deferredItem['token'], - ); - } - } - } - /** * Validates that the given ResultVariable is semantically correct. * It must exist in query components list. @@ -1670,69 +1623,6 @@ public function JoinAssociationDeclaration(): AST\JoinAssociationDeclaration return new AST\JoinAssociationDeclaration($joinAssociationPathExpression, $aliasIdentificationVariable, $indexBy); } - /** - * PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet - * PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}" - */ - public function PartialObjectExpression(): AST\PartialObjectExpression - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8471', - 'PARTIAL syntax in DQL is deprecated.', - ); - - $this->match(TokenType::T_PARTIAL); - - $partialFieldSet = []; - - $identificationVariable = $this->IdentificationVariable(); - - $this->match(TokenType::T_DOT); - $this->match(TokenType::T_OPEN_CURLY_BRACE); - $this->match(TokenType::T_IDENTIFIER); - - assert($this->lexer->token !== null); - $field = $this->lexer->token->value; - - // First field in partial expression might be embeddable property - while ($this->lexer->isNextToken(TokenType::T_DOT)) { - $this->match(TokenType::T_DOT); - $this->match(TokenType::T_IDENTIFIER); - $field .= '.' . $this->lexer->token->value; - } - - $partialFieldSet[] = $field; - - while ($this->lexer->isNextToken(TokenType::T_COMMA)) { - $this->match(TokenType::T_COMMA); - $this->match(TokenType::T_IDENTIFIER); - - $field = $this->lexer->token->value; - - while ($this->lexer->isNextToken(TokenType::T_DOT)) { - $this->match(TokenType::T_DOT); - $this->match(TokenType::T_IDENTIFIER); - $field .= '.' . $this->lexer->token->value; - } - - $partialFieldSet[] = $field; - } - - $this->match(TokenType::T_CLOSE_CURLY_BRACE); - - $partialObjectExpression = new AST\PartialObjectExpression($identificationVariable, $partialFieldSet); - - // Defer PartialObjectExpression validation - $this->deferredPartialObjectExpressions[] = [ - 'expression' => $partialObjectExpression, - 'nestingLevel' => $this->nestingLevel, - 'token' => $this->lexer->token, - ]; - - return $partialObjectExpression; - } - /** * NewObjectExpression ::= "NEW" AbstractSchemaName "(" NewObjectArg {"," NewObjectArg}* ")" */ @@ -2034,7 +1924,7 @@ public function SimpleWhenClause(): AST\SimpleWhenClause /** * SelectExpression ::= ( * IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | - * PartialObjectExpression | "(" Subselect ")" | CaseExpression | NewObjectExpression + * "(" Subselect ")" | CaseExpression | NewObjectExpression * ) [["AS"] ["HIDDEN"] AliasResultVariable] */ public function SelectExpression(): AST\SelectExpression @@ -2075,12 +1965,6 @@ public function SelectExpression(): AST\SelectExpression break; - // PartialObjectExpression (PARTIAL u.{id, name}) - case $lookaheadType === TokenType::T_PARTIAL: - $expression = $this->PartialObjectExpression(); - $identVariable = $expression->identificationVariable; - break; - // Subselect case $lookaheadType === TokenType::T_OPEN_PARENTHESIS && $peek->type === TokenType::T_SELECT: $this->match(TokenType::T_OPEN_PARENTHESIS); @@ -2106,7 +1990,7 @@ public function SelectExpression(): AST\SelectExpression default: $this->syntaxError( - 'IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression', + 'IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | "(" Subselect ")" | CaseExpression', $this->lexer->lookahead, ); } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 3f2cd06cb1d..66a4f45525f 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -27,7 +27,6 @@ use function assert; use function count; use function implode; -use function in_array; use function is_array; use function is_float; use function is_numeric; @@ -49,11 +48,6 @@ class SqlWalker { public const HINT_DISTINCT = 'doctrine.distinct'; - /** - * Used to mark a query as containing a PARTIAL expression, which needs to be known by SLC. - */ - public const HINT_PARTIAL = 'doctrine.partial'; - private readonly ResultSetMapping $rsm; /** @@ -308,11 +302,6 @@ private function generateClassTableInheritanceJoins( $sql .= implode(' AND ', array_filter($sqlParts)); } - // Ignore subclassing inclusion if partial objects is disallowed - if ($this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { - return $sql; - } - // LEFT JOIN child class tables foreach ($class->subClasses as $subClassName) { $subClass = $this->em->getClassMetadata($subClassName); @@ -635,8 +624,7 @@ public function walkSelectClause(AST\SelectClause $selectClause): string $this->query->setHint(self::HINT_DISTINCT, true); } - $addMetaColumns = ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD) && - $this->query->getHydrationMode() === Query::HYDRATE_OBJECT + $addMetaColumns = $this->query->getHydrationMode() === Query::HYDRATE_OBJECT || $this->query->getHint(Query::HINT_INCLUDE_META_COLUMNS); foreach ($this->selectedClasses as $selectedClass) { @@ -1313,17 +1301,7 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st break; default: - // IdentificationVariable or PartialObjectExpression - if ($expr instanceof AST\PartialObjectExpression) { - $this->query->setHint(self::HINT_PARTIAL, true); - - $dqlAlias = $expr->identificationVariable; - $partialFieldSet = $expr->partialFieldSet; - } else { - $dqlAlias = $expr; - $partialFieldSet = []; - } - + $dqlAlias = $expr; $class = $this->getMetadataForDqlAlias($dqlAlias); $resultAlias = $selectExpression->fieldIdentificationVariable ?: null; @@ -1339,10 +1317,6 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st // Select all fields from the queried class foreach ($class->fieldMappings as $fieldName => $mapping) { - if ($partialFieldSet && ! in_array($fieldName, $partialFieldSet, true)) { - continue; - } - $tableName = isset($mapping->inherited) ? $this->em->getClassMetadata($mapping->inherited)->getTableName() : $class->getTableName(); @@ -1369,32 +1343,29 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st // Add any additional fields of subclasses (excluding inherited fields) // 1) on Single Table Inheritance: always, since its marginal overhead - // 2) on Class Table Inheritance only if partial objects are disallowed, - // since it requires outer joining subtables. - if ($class->isInheritanceTypeSingleTable() || ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { - foreach ($class->subClasses as $subClassName) { - $subClass = $this->em->getClassMetadata($subClassName); - $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); - - foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if (isset($mapping->inherited) || ($partialFieldSet && ! in_array($fieldName, $partialFieldSet, true))) { - continue; - } + // 2) on Class Table Inheritance + foreach ($class->subClasses as $subClassName) { + $subClass = $this->em->getClassMetadata($subClassName); + $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); + + foreach ($subClass->fieldMappings as $fieldName => $mapping) { + if (isset($mapping->inherited)) { + continue; + } - $columnAlias = $this->getSQLColumnAlias($mapping->columnName); - $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform); + $columnAlias = $this->getSQLColumnAlias($mapping->columnName); + $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform); - $col = $sqlTableAlias . '.' . $quotedColumnName; + $col = $sqlTableAlias . '.' . $quotedColumnName; - $type = Type::getType($mapping->type); - $col = $type->convertToPHPValueSQL($col, $this->platform); + $type = Type::getType($mapping->type); + $col = $type->convertToPHPValueSQL($col, $this->platform); - $sqlParts[] = $col . ' AS ' . $columnAlias; + $sqlParts[] = $col . ' AS ' . $columnAlias; - $this->scalarResultAliasMap[$resultAlias][] = $columnAlias; + $this->scalarResultAliasMap[$resultAlias][] = $columnAlias; - $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $subClassName); - } + $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $subClassName); } } diff --git a/lib/Doctrine/ORM/Query/TokenType.php b/lib/Doctrine/ORM/Query/TokenType.php index bf1c351c2a6..e745e4a1da3 100644 --- a/lib/Doctrine/ORM/Query/TokenType.php +++ b/lib/Doctrine/ORM/Query/TokenType.php @@ -77,7 +77,6 @@ enum TokenType: int case T_OR = 242; case T_ORDER = 243; case T_OUTER = 244; - case T_PARTIAL = 245; case T_SELECT = 246; case T_SET = 247; case T_SOME = 248; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 0881c072019..ed38cb8faf0 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -12,7 +12,6 @@ use Doctrine\DBAL; use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\Persister\CachedPersister; use Doctrine\ORM\Event\ListenersInvoker; use Doctrine\ORM\Event\OnClearEventArgs; @@ -2347,18 +2346,6 @@ public function createEntity(string $className, array $data, array &$hints = []) unset($this->eagerLoadingEntities[$class->rootEntityName]); } - // Properly initialize any unfetched associations, if partial objects are not allowed. - if (isset($hints[Query::HINT_FORCE_PARTIAL_LOAD])) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8471', - 'Partial Objects are deprecated (here entity %s)', - $className, - ); - - return $entity; - } - foreach ($class->associationMappings as $field => $assoc) { // Check if the association is not among the fetch-joined associations already. if (isset($hints['fetchAlias'], $hints['fetched'][$hints['fetchAlias']][$field])) { diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php deleted file mode 100644 index 6a1638afcf5..00000000000 --- a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php +++ /dev/null @@ -1,84 +0,0 @@ - '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '42', - ], - [ - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'ROMANB', - 'p__phonenumber' => '43', - ], - [ - 'u__id' => '2', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - 'sclr0' => 'JWAGE', - 'p__phonenumber' => '91', - ], - ]; - - for ($i = 4; $i < 2000; ++$i) { - $resultSet[] = [ - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - 'sclr0' => 'JWAGE' . $i, - 'p__phonenumber' => '91', - ]; - } - - $this->result = ArrayResultFactory::createFromArray($resultSet); - $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([])); - $this->rsm = new ResultSetMapping(); - - $this->rsm->addEntityResult(CmsUser::class, 'u'); - $this->rsm->addJoinedEntityResult(CmsPhonenumber::class, 'p', 'u', 'phonenumbers'); - $this->rsm->addFieldResult('u', 'u__id', 'id'); - $this->rsm->addFieldResult('u', 'u__status', 'status'); - $this->rsm->addFieldResult('u', 'u__username', 'username'); - $this->rsm->addFieldResult('u', 'u__name', 'name'); - $this->rsm->addScalarResult('sclr0', 'nameUpper'); - $this->rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); - } - - public function benchHydration(): void - { - $this->hydrator->hydrateAll($this->result, $this->rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - } -} diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php deleted file mode 100644 index b894068eb2c..00000000000 --- a/tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php +++ /dev/null @@ -1,72 +0,0 @@ - '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ], - [ - 'u__id' => '1', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ], - [ - 'u__id' => '2', - 'u__status' => 'developer', - 'u__username' => 'romanb', - 'u__name' => 'Roman', - ], - ]; - - for ($i = 4; $i < 10000; ++$i) { - $resultSet[] = [ - 'u__id' => $i, - 'u__status' => 'developer', - 'u__username' => 'jwage', - 'u__name' => 'Jonathan', - ]; - } - - $this->result = ArrayResultFactory::createFromArray($resultSet); - $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([])); - $this->rsm = new ResultSetMapping(); - - $this->rsm->addEntityResult(CmsUser::class, 'u'); - $this->rsm->addFieldResult('u', 'u__id', 'id'); - $this->rsm->addFieldResult('u', 'u__status', 'status'); - $this->rsm->addFieldResult('u', 'u__username', 'username'); - $this->rsm->addFieldResult('u', 'u__name', 'name'); - } - - public function benchHydration(): void - { - $this->hydrator->hydrateAll($this->result, $this->rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index b2baaaa254e..cdb34bfcdbf 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Query; use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\Models\ECommerce\ECommerceShipping; use Doctrine\Tests\OrmFunctionalTestCase; @@ -79,19 +78,6 @@ public function testLazyLoadsObjects(): void self::assertEquals(1, $product->getShipping()->getDays()); } - public function testDoesNotLazyLoadObjectsIfConfigurationDoesNotAllowIt(): void - { - $this->createFixture(); - - $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); - $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - - $result = $query->getResult(); - $product = $result[0]; - - self::assertNull($product->getShipping()); - } - protected function createFixture(): void { $product = new ECommerceProduct(); diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php index 960cb359d44..dc51472cb52 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php @@ -136,27 +136,6 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void $userProxy->getName(); } - public function testLoadedProxyPartialShouldTriggerEvent(): void - { - $eventManager = $this->_em->getEventManager(); - - // Should not be invoked during getReference call - $mockListener = $this->createMock(PostLoadListener::class); - - // CmsUser (partially loaded), CmsAddress (inverse ToOne), 2 CmsPhonenumber - $mockListener - ->expects(self::exactly(4)) - ->method('postLoad') - ->will(self::returnValue(true)); - - $eventManager->addEventListener([Events::postLoad], $mockListener); - - $query = $this->_em->createQuery('SELECT PARTIAL u.{id, name}, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p WHERE u.id = :id'); - - $query->setParameter('id', $this->userId); - $query->getResult(); - } - public function testLoadedProxyAssociationToOneShouldTriggerEvent(): void { $user = $this->_em->find(CmsUser::class, $this->userId); diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index e2dec649342..a3350aa5e6c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -1086,31 +1086,6 @@ public function testHintClearEntityRegionDeleteStatement(): void self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } - public function testCacheablePartialQueryException(): void - { - $this->expectException(CacheException::class); - $this->expectExceptionMessage('Second level cache does not support partial entities.'); - $this->evictRegions(); - $this->loadFixturesCountries(); - - $this->_em->createQuery('SELECT PARTIAL c.{id} FROM Doctrine\Tests\Models\Cache\Country c') - ->setCacheable(true) - ->getResult(); - } - - public function testCacheableForcePartialLoadHintQueryException(): void - { - $this->expectException(CacheException::class); - $this->expectExceptionMessage('Second level cache does not support partial entities.'); - $this->evictRegions(); - $this->loadFixturesCountries(); - - $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Cache\Country c') - ->setCacheable(true) - ->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) - ->getResult(); - } - public function testNonCacheableQueryDeleteStatementException(): void { $this->expectException(CacheException::class); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php index 6c0c7c94fe3..83aebb4dcae 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php @@ -46,7 +46,7 @@ public function testQueryWithOrConditionUsingTwoRelationOnSameEntity(): void $this->_em->flush(); $this->_em->clear(); - $dql = 'SELECT PARTIAL person.{id,name}, PARTIAL spouse.{id,name}, PARTIAL friend.{id,name} + $dql = 'SELECT person.name as person_name, spouse.name as spouse_name,friend.name as friend_name FROM Doctrine\Tests\Models\Company\CompanyPerson person LEFT JOIN person.spouse spouse LEFT JOIN person.friends friend diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php deleted file mode 100644 index b8dfba13b9c..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2519Test.php +++ /dev/null @@ -1,76 +0,0 @@ -useModelSet('legacy'); - - parent::setUp(); - - $this->loadFixture(); - } - - #[Group('DDC-2519')] - public function testIssue(): void - { - $dql = 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l'; - $result = $this->_em->createQuery($dql)->getResult(); - - self::assertCount(2, $result); - self::assertInstanceOf(LegacyUserReference::class, $result[0]); - self::assertInstanceOf(LegacyUserReference::class, $result[1]); - - self::assertInstanceOf(LegacyUser::class, $result[0]->source()); - self::assertInstanceOf(LegacyUser::class, $result[0]->target()); - self::assertInstanceOf(LegacyUser::class, $result[1]->source()); - self::assertInstanceOf(LegacyUser::class, $result[1]->target()); - - self::assertTrue($this->isUninitializedObject($result[0]->target())); - self::assertTrue($this->isUninitializedObject($result[0]->source())); - self::assertTrue($this->isUninitializedObject($result[1]->target())); - self::assertTrue($this->isUninitializedObject($result[1]->source())); - - self::assertNotNull($result[0]->source()->getId()); - self::assertNotNull($result[0]->target()->getId()); - self::assertNotNull($result[1]->source()->getId()); - self::assertNotNull($result[1]->target()->getId()); - } - - public function loadFixture(): void - { - $user1 = new LegacyUser(); - $user1->username = 'FabioBatSilva'; - $user1->name = 'Fabio B. Silva'; - - $user2 = new LegacyUser(); - $user2->username = 'doctrinebot'; - $user2->name = 'Doctrine Bot'; - - $user3 = new LegacyUser(); - $user3->username = 'test'; - $user3->name = 'Tester'; - - $this->_em->persist($user1); - $this->_em->persist($user2); - $this->_em->persist($user3); - - $this->_em->flush(); - - $this->_em->persist(new LegacyUserReference($user1, $user2, 'foo')); - $this->_em->persist(new LegacyUserReference($user1, $user3, 'bar')); - - $this->_em->flush(); - $this->_em->clear(); - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php index 44695f1856e..0b5352a6ea8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php @@ -14,9 +14,6 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; -use Doctrine\ORM\Query; -use Doctrine\Tests\Models\Company\CompanyManager; -use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\Group; @@ -33,35 +30,6 @@ protected function setUp(): void $this->createSchemaForModels(GH8443Foo::class); } - #[Group('GH-8443')] - public function testJoinRootEntityWithForcePartialLoad(): void - { - $person = new CompanyPerson(); - $person->setName('John'); - - $manager = new CompanyManager(); - $manager->setName('Adam'); - $manager->setSalary(1000); - $manager->setDepartment('IT'); - $manager->setTitle('manager'); - - $manager->setSpouse($person); - - $this->_em->persist($person); - $this->_em->persist($manager); - $this->_em->flush(); - $this->_em->clear(); - - $manager = $this->_em->createQuery( - "SELECT m from Doctrine\Tests\Models\Company\CompanyManager m - JOIN m.spouse s - WITH s.name = 'John'", - )->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true)->getSingleResult(); - $this->_em->refresh($manager); - - $this->assertEquals('John', $manager->getSpouse()->getName()); - } - #[Group('GH-8443')] public function testJoinRootEntityWithOnlyOneEntityInHierarchy(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 3186e71d357..08ce4b17d89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -209,58 +209,6 @@ public function testDqlOnEmbeddedObjectsField(): void self::assertNull($this->_em->find(DDC93Person::class, $person->id)); } - public function testPartialDqlOnEmbeddedObjectsField(): void - { - $person = new DDC93Person('Karl', new DDC93Address('Foo', '12345', 'Gosport', new DDC93Country('England'))); - $this->_em->persist($person); - $this->_em->flush(); - $this->_em->clear(); - - // Prove that the entity was persisted correctly. - $dql = 'SELECT p FROM ' . __NAMESPACE__ . '\\DDC93Person p WHERE p.name = :name'; - - $person = $this->_em->createQuery($dql) - ->setParameter('name', 'Karl') - ->getSingleResult(); - - self::assertEquals('Gosport', $person->address->city); - self::assertEquals('Foo', $person->address->street); - self::assertEquals('12345', $person->address->zip); - self::assertEquals('England', $person->address->country->name); - - // Clear the EM and prove that the embeddable can be the subject of a partial query. - $this->_em->clear(); - - $dql = 'SELECT PARTIAL p.{id,address.city} FROM ' . __NAMESPACE__ . '\\DDC93Person p WHERE p.name = :name'; - - $person = $this->_em->createQuery($dql) - ->setParameter('name', 'Karl') - ->getSingleResult(); - - // Selected field must be equal, all other fields must be null. - self::assertEquals('Gosport', $person->address->city); - self::assertNull($person->address->street); - self::assertNull($person->address->zip); - self::assertNull($person->address->country); - self::assertNull($person->name); - - // Clear the EM and prove that the embeddable can be the subject of a partial query regardless of attributes positions. - $this->_em->clear(); - - $dql = 'SELECT PARTIAL p.{address.city, id} FROM ' . __NAMESPACE__ . '\\DDC93Person p WHERE p.name = :name'; - - $person = $this->_em->createQuery($dql) - ->setParameter('name', 'Karl') - ->getSingleResult(); - - // Selected field must be equal, all other fields must be null. - self::assertEquals('Gosport', $person->address->city); - self::assertNull($person->address->street); - self::assertNull($person->address->zip); - self::assertNull($person->address->country); - self::assertNull($person->name); - } - public function testDqlWithNonExistentEmbeddableField(): void { $this->expectException(QueryException::class); @@ -270,15 +218,6 @@ public function testDqlWithNonExistentEmbeddableField(): void ->execute(); } - public function testPartialDqlWithNonExistentEmbeddableField(): void - { - $this->expectException(QueryException::class); - $this->expectExceptionMessage("no mapped field named 'address.asdfasdf'"); - - $this->_em->createQuery('SELECT PARTIAL p.{id,address.asdfasdf} FROM ' . __NAMESPACE__ . '\\DDC93Person p') - ->execute(); - } - public function testEmbeddableWithInheritance(): void { $car = new DDC93Car(new DDC93Address('Foo', '12345', 'Asdf')); diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index df27bf907c5..72fc2a8d451 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -522,16 +522,6 @@ public function testUnknownAbstractSchemaName(): void $this->assertInvalidDQL('SELECT u FROM UnknownClassName u'); } - public function testCorrectPartialObjectLoad(): void - { - $this->assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - - public function testIncorrectPartialObjectLoadBecauseOfMissingIdentifier(): void - { - $this->assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); - } - public function testScalarExpressionInSelect(): void { $this->assertValidDQL('SELECT u, 42 + u.id AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u'); diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index af1b475c585..681562c1dd8 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -1330,20 +1330,6 @@ public function testIdentityFunctionWithCompositePrimaryKey(): void ); } - #[Group('DDC-2519')] - public function testPartialWithAssociationIdentifier(): void - { - $this->assertSqlGeneration( - 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l', - 'SELECT l0_.iUserIdSource AS iUserIdSource_0, l0_.iUserIdTarget AS iUserIdTarget_1 FROM legacy_users_reference l0_', - ); - - $this->assertSqlGeneration( - 'SELECT PARTIAL l.{_description, _source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l', - 'SELECT l0_.description AS description_0, l0_.iUserIdSource AS iUserIdSource_1, l0_.iUserIdTarget AS iUserIdTarget_2 FROM legacy_users_reference l0_', - ); - } - #[Group('DDC-1339')] public function testIdentityFunctionInSelectClause(): void { @@ -1378,122 +1364,56 @@ public function testIdentityFunctionDoesNotAcceptStateField(): void } #[Group('DDC-1389')] - public function testInheritanceTypeJoinInRootClassWithDisabledForcePartialLoad(): void + public function testInheritanceTypeJoinInRootClass(): void { $this->assertSqlGeneration( 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c1_.car_id AS car_id_8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } #[Group('DDC-1389')] - public function testInheritanceTypeJoinInRootClassWithEnabledForcePartialLoad(): void - { - $this->assertSqlGeneration( - 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', - 'SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], - ); - } - - #[Group('DDC-1389')] - public function testInheritanceTypeJoinInChildClassWithDisabledForcePartialLoad(): void + public function testInheritanceTypeJoinInChildClass(): void { $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } #[Group('DDC-1389')] - public function testInheritanceTypeJoinInChildClassWithEnabledForcePartialLoad(): void - { - $this->assertSqlGeneration( - 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', - 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], - ); - } - - #[Group('DDC-1389')] - public function testInheritanceTypeJoinInLeafClassWithDisabledForcePartialLoad(): void + public function testInheritanceTypeJoinInLeafClass(): void { $this->assertSqlGeneration( 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } #[Group('DDC-1389')] - public function testInheritanceTypeJoinInLeafClassWithEnabledForcePartialLoad(): void - { - $this->assertSqlGeneration( - 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', - 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], - ); - } - - #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInRootClassWithDisabledForcePartialLoad(): void + public function testInheritanceTypeSingleTableInRootClass(): void { $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6, c0_.salesPerson_id AS salesPerson_id_7 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], - ); - } - - #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInRootClassWithEnabledForcePartialLoad(): void - { - $this->assertSqlGeneration( - 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInChildClassWithDisabledForcePartialLoad(): void + public function testInheritanceTypeSingleTableInChildClass(): void { $this->assertSqlGeneration( 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], - ); - } - - #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInChildClassWithEnabledForcePartialLoad(): void - { - $this->assertSqlGeneration( - 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInLeafClassWithDisabledForcePartialLoad(): void + public function testInheritanceTypeSingleTableInLeafClass(): void { $this->assertSqlGeneration( 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], - ); - } - - #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInLeafClassWithEnabledForcePartialLoad(): void - { - $this->assertSqlGeneration( - 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", - [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } @@ -1770,20 +1690,6 @@ public function testCustomTypeValueSqlForAllFields(): void ); } - public function testCustomTypeValueSqlForPartialObject(): void - { - if (DBALType::hasType('negative_to_positive')) { - DBALType::overrideType('negative_to_positive', NegativeToPositiveType::class); - } else { - DBALType::addType('negative_to_positive', NegativeToPositiveType::class); - } - - $this->assertSqlGeneration( - 'SELECT partial p.{id, customInteger} FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', - 'SELECT c0_.id AS id_0, -(c0_.customInteger) AS customInteger_1, c0_.child_id AS child_id_2 FROM customtype_parents c0_', - ); - } - #[Group('DDC-1529')] public function testMultipleFromAndInheritanceCondition(): void { diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 3193c03367f..04b286eb9cf 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -214,7 +214,7 @@ public function testCountQueryWithComplexScalarOrderByItemWithoutJoin(): void ); } - public function testCountQueryWithComplexScalarOrderByItemJoinedWithoutPartial(): void + public function testCountQueryWithComplexScalarOrderByItemJoined(): void { $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); @@ -230,22 +230,6 @@ public function testCountQueryWithComplexScalarOrderByItemJoinedWithoutPartial() ); } - public function testCountQueryWithComplexScalarOrderByItemJoinedWithPartial(): void - { - $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - - $query = $entityManager->createQuery( - 'SELECT u, partial a.{id, imageAltDesc} FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC', - ); - - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_5 * imageWidth_6 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.imageAltDesc AS imageAltDesc_2, a1_.id AS id_3, a1_.image AS image_4, a1_.imageHeight AS imageHeight_5, a1_.imageWidth AS imageWidth_6, a1_.imageAltDesc AS imageAltDesc_7, a1_.user_id AS user_id_8 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_5 * imageWidth_6 DESC) dctrn_result', - $query->getSQL(), - ); - } - public function testCountQueryWithComplexScalarOrderByItemOracle(): void { $entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); From 5c250063b824f233bf8feac4c4f88cfeb054140e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 10 Oct 2023 12:30:13 +0200 Subject: [PATCH 314/475] Remove EntityManager::getPartialReference() --- UPGRADE.md | 1 + .../ORM/Decorator/EntityManagerDecorator.php | 12 ----- lib/Doctrine/ORM/EntityManager.php | 31 ------------ lib/Doctrine/ORM/EntityManagerInterface.php | 27 ----------- psalm-baseline.xml | 2 - psalm.xml | 1 - .../Mock/NonProxyLoadingEntityManager.php | 5 -- .../Decorator/EntityManagerDecoratorTest.php | 47 ------------------- .../Doctrine/Tests/ORM/EntityManagerTest.php | 9 ---- .../ORM/Functional/BasicFunctionalTest.php | 23 --------- .../ORM/Functional/DefaultValuesTest.php | 22 --------- .../ORM/Functional/Ticket/DDC1041Test.php | 1 - 12 files changed, 1 insertion(+), 180 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 10826e83229..ba124d65723 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -6,6 +6,7 @@ - `Doctrine\ORM\Query\AST\PartialObjectExpression`is removed. - `Doctrine\ORM\Query\SqlWalker::HINT_PARTIAL` and `Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD` are removed. +- `Doctrine\ORM\EntityManager*::getPartialReference()` is removed. ## BC BREAK: `Doctrine\ORM\Persister\Entity\EntityPersister::executeInserts()` return type changed to `void` diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index 9cac7df7a20..6f1b0419686 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -102,18 +102,6 @@ public function getReference(string $entityName, mixed $id): object|null return $this->wrapped->getReference($entityName, $id); } - public function getPartialReference(string $entityName, mixed $identifier): object|null - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10987', - 'Method %s is deprecated and will be removed in 3.0.', - __METHOD__, - ); - - return $this->wrapped->getPartialReference($entityName, $identifier); - } - public function close(): void { $this->wrapped->close(); diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index d42a1d6b648..28ba1d15c7f 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -400,37 +400,6 @@ public function getReference(string $entityName, mixed $id): object|null return $entity; } - public function getPartialReference(string $entityName, mixed $identifier): object|null - { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/pull/10987', - 'Method %s is deprecated and will be removed in 3.0.', - __METHOD__, - ); - $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); - - $entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName); - - // Check identity map first, if its already in there just return it. - if ($entity !== false) { - return $entity instanceof $class->name ? $entity : null; - } - - if (! is_array($identifier)) { - $identifier = [$class->identifier[0] => $identifier]; - } - - $entity = $class->newInstance(); - - $class->setIdentifierValues($entity, $identifier); - - $this->unitOfWork->registerManaged($entity, $identifier, []); - $this->unitOfWork->markReadOnly($entity); - - return $entity; - } - /** * Clears the EntityManager. All entities that are currently managed * by this EntityManager become detached. diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index ac6e3ba8d77..3f5535233f9 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -163,33 +163,6 @@ public function refresh(object $object, LockMode|int|null $lockMode = null): voi */ public function getReference(string $entityName, mixed $id): object|null; - /** - * Gets a partial reference to the entity identified by the given type and identifier - * without actually loading it, if the entity is not yet loaded. - * - * The returned reference may be a partial object if the entity is not yet loaded/managed. - * If it is a partial object it will not initialize the rest of the entity state on access. - * Thus you can only ever safely access the identifier of an entity obtained through - * this method. - * - * The use-cases for partial references involve maintaining bidirectional associations - * without loading one side of the association or to update an entity without loading it. - * Note, however, that in the latter case the original (persistent) entity data will - * never be visible to the application (especially not event listeners) as it will - * never be loaded in the first place. - * - * @deprecated 2.7 This method is being removed from the ORM and won't have any replacement - * - * @param string $entityName The name of the entity type. - * @param mixed $identifier The entity identifier. - * @psalm-param class-string $entityName - * - * @psalm-return T|null - * - * @template T of object - */ - public function getPartialReference(string $entityName, mixed $identifier): object|null; - /** * Closes the EntityManager. All entities that are currently managed * by this EntityManager become detached. The EntityManager may no longer diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 961f217ecb7..81827bacf53 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -170,8 +170,6 @@ $entity $entity $entity - $entity - name ? $entity : null]]> name ? $entity : null]]> load($sortedId, null, null, [], $lockMode)]]> loadById($sortedId)]]> diff --git a/psalm.xml b/psalm.xml index 946291f09fd..87769df2ecc 100644 --- a/psalm.xml +++ b/psalm.xml @@ -48,7 +48,6 @@ - diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php index 815f7e4eec3..e60e476c408 100644 --- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php @@ -115,11 +115,6 @@ public function getReference(string $entityName, mixed $id): object|null return $this->realEntityManager->getReference($entityName, $id); } - public function getPartialReference(string $entityName, mixed $identifier): object|null - { - return $this->realEntityManager->getPartialReference($entityName, $identifier); - } - public function close(): void { $this->realEntityManager->close(); diff --git a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php deleted file mode 100644 index 10d8636da31..00000000000 --- a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php +++ /dev/null @@ -1,47 +0,0 @@ -wrapped = $this->createMock(EntityManagerInterface::class); - } - - public function testGetPartialReferenceIsDeprecated(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/10987'); - $decorator = new class ($this->wrapped) extends EntityManagerDecorator { - }; - $decorator->getPartialReference(stdClass::class, 1); - } -} diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index e15f30390ac..5abcffc67d6 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -108,15 +108,6 @@ public function testCreateQueryDqlIsOptional(): void self::assertInstanceOf(Query::class, $this->entityManager->createQuery()); } - public function testGetPartialReference(): void - { - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/10987'); - $user = $this->entityManager->getPartialReference(CmsUser::class, 42); - self::assertTrue($this->entityManager->contains($user)); - self::assertEquals(42, $user->id); - self::assertNull($user->getName()); - } - public function testCreateQuery(): void { $q = $this->entityManager->createQuery('SELECT 1'); diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 10ed85a2bd5..fe03a864060 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -916,29 +916,6 @@ public function testOneToOneOrphanRemoval(): void self::assertEquals(1, $this->_em->getConnection()->fetchOne('select count(*) from cms_addresses')); } - public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt(): void - { - $user = new CmsUser(); - $user->username = 'beberlei'; - $user->name = 'Benjamin E.'; - $user->status = 'active'; - $this->_em->persist($user); - $this->_em->flush(); - $userId = $user->id; - $this->_em->clear(); - - $user = $this->_em->getPartialReference(CmsUser::class, $userId); - self::assertTrue($this->_em->contains($user)); - self::assertNull($user->getName()); - self::assertEquals($userId, $user->id); - - $user->name = 'Stephan'; - $this->_em->flush(); - $this->_em->clear(); - - self::assertEquals('Benjamin E.', $this->_em->find($user::class, $userId)->name); - } - #[Group('DDC-952')] public function testManyToOneFetchModeQuery(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index 9b9469ffa62..3a46b00a406 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -62,28 +62,6 @@ public function testSimpleDetachMerge(): void self::assertEquals($userId, $a2->getUser()->getId()); self::assertEquals('Poweruser', $a2->getUser()->type); } - - #[Group('DDC-1386')] - public function testGetPartialReferenceWithDefaultValueNotEvaluatedInFlush(): void - { - $user = new DefaultValueUser(); - $user->name = 'romanb'; - $user->type = 'Normaluser'; - - $this->_em->persist($user); - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->getPartialReference(DefaultValueUser::class, $user->id); - self::assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); - - $this->_em->flush(); - $this->_em->clear(); - - $user = $this->_em->find(DefaultValueUser::class, $user->id); - - self::assertEquals('Normaluser', $user->type); - } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php index 07e41044a29..69e1fac0dc7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -31,6 +31,5 @@ public function testGrabWrongSubtypeReturnsNull(): void self::assertNull($this->_em->find(CompanyFlexContract::class, $id)); self::assertNull($this->_em->getReference(CompanyFlexContract::class, $id)); - self::assertNull($this->_em->getPartialReference(CompanyFlexContract::class, $id)); } } From 689da1f251957f49f1126b92bcaf8fb12df6f56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 10 Oct 2023 12:32:16 +0200 Subject: [PATCH 315/475] Remove unused exception --- lib/Doctrine/ORM/Query/QueryException.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index 658ecb7a964..1f0e4728936 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -88,15 +88,6 @@ public static function iterateWithFetchJoinCollectionNotAllowed(AssociationMappi ); } - public static function partialObjectsAreDangerous(): self - { - return new self( - 'Loading partial objects is dangerous. Fetch full objects or consider ' . - 'using a different fetch mode. If you really want partial objects, ' . - 'set the doctrine.forcePartialLoad query hint to TRUE.', - ); - } - /** * @param string[] $assoc * @psalm-param array $assoc From 22e7c02cf7a671eefb0536e8e92e86181111155f Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 11 Oct 2023 11:05:24 +0200 Subject: [PATCH 316/475] Throw exceptions for cases where attributes are illegal on Embeddables. (#10992) * Throw exceptions for cases where attributes are illegal on Embeddables. * Embedded is allowed on Embeddable, update SchemaValidator. --- .../ORM/Mapping/Driver/AttributeDriver.php | 52 +++++++++++++++++++ lib/Doctrine/ORM/Mapping/MappingException.php | 9 ++++ lib/Doctrine/ORM/Tools/SchemaValidator.php | 6 --- .../Tests/ORM/Tools/SchemaValidatorTest.php | 13 ----- 4 files changed, 61 insertions(+), 19 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php index 03f31d177ff..6fed1a24e67 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php @@ -117,6 +117,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata } if (isset($classAttributes[Mapping\Index::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\Index::class); + } + foreach ($classAttributes[Mapping\Index::class] as $idx => $indexAnnot) { $index = []; @@ -158,6 +162,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata } if (isset($classAttributes[Mapping\UniqueConstraint::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\UniqueConstraint::class); + } + foreach ($classAttributes[Mapping\UniqueConstraint::class] as $idx => $uniqueConstraintAnnot) { $uniqueConstraint = []; @@ -198,6 +206,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata // Evaluate #[Cache] attribute if (isset($classAttributes[Mapping\Cache::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\Cache::class); + } + $cacheAttribute = $classAttributes[Mapping\Cache::class]; $cacheMap = [ 'region' => $cacheAttribute->region, @@ -209,6 +221,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata // Evaluate InheritanceType attribute if (isset($classAttributes[Mapping\InheritanceType::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\InheritanceType::class); + } + $inheritanceTypeAttribute = $classAttributes[Mapping\InheritanceType::class]; $metadata->setInheritanceType( @@ -248,6 +264,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata // Evaluate DoctrineChangeTrackingPolicy attribute if (isset($classAttributes[Mapping\ChangeTrackingPolicy::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\ChangeTrackingPolicy::class); + } + $changeTrackingAttribute = $classAttributes[Mapping\ChangeTrackingPolicy::class]; $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAttribute->value)); } @@ -333,6 +353,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata ); } } elseif ($oneToOneAttribute !== null) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\OneToOne::class); + } + if ($this->reader->getPropertyAttribute($property, Mapping\Id::class)) { $mapping['id'] = true; } @@ -346,6 +370,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata $mapping['fetch'] = $this->getFetchMode($className, $oneToOneAttribute->fetch); $metadata->mapOneToOne($mapping); } elseif ($oneToManyAttribute !== null) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\OneToMany::class); + } + $mapping['mappedBy'] = $oneToManyAttribute->mappedBy; $mapping['targetEntity'] = $oneToManyAttribute->targetEntity; $mapping['cascade'] = $oneToManyAttribute->cascade; @@ -361,6 +389,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata $metadata->mapOneToMany($mapping); } elseif ($manyToOneAttribute !== null) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\OneToMany::class); + } + $idAttribute = $this->reader->getPropertyAttribute($property, Mapping\Id::class); if ($idAttribute !== null) { @@ -374,6 +406,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata $mapping['fetch'] = $this->getFetchMode($className, $manyToOneAttribute->fetch); $metadata->mapManyToOne($mapping); } elseif ($manyToManyAttribute !== null) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\ManyToMany::class); + } + $joinTable = []; $joinTableAttribute = $this->reader->getPropertyAttribute($property, Mapping\JoinTable::class); @@ -430,6 +466,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata // Evaluate AssociationOverrides attribute if (isset($classAttributes[Mapping\AssociationOverrides::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\AssociationOverride::class); + } + $associationOverride = $classAttributes[Mapping\AssociationOverrides::class]; foreach ($associationOverride->overrides as $associationOverride) { @@ -488,6 +528,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata // Evaluate AttributeOverrides attribute if (isset($classAttributes[Mapping\AttributeOverrides::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\AttributeOverrides::class); + } + $attributeOverridesAnnot = $classAttributes[Mapping\AttributeOverrides::class]; foreach ($attributeOverridesAnnot->overrides as $attributeOverride) { @@ -499,6 +543,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata // Evaluate EntityListeners attribute if (isset($classAttributes[Mapping\EntityListeners::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\EntityListeners::class); + } + $entityListenersAttribute = $classAttributes[Mapping\EntityListeners::class]; foreach ($entityListenersAttribute->value as $item) { @@ -531,6 +579,10 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata // Evaluate #[HasLifecycleCallbacks] attribute if (isset($classAttributes[Mapping\HasLifecycleCallbacks::class])) { + if ($metadata->isEmbeddedClass) { + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\HasLifecycleCallbacks::class); + } + foreach ($reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { assert($method instanceof ReflectionMethod); foreach ($this->getMethodCallbacks($method) as $value) { diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 48fc9a6654e..99eab1b1056 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -669,4 +669,13 @@ public static function fromLibXmlErrors(array $errors): self return new self(implode(PHP_EOL, array_map($formatter, $errors))); } + + public static function invalidAttributeOnEmbeddable(string $entityName, string $attributeName): self + { + return new self(sprintf( + 'Attribute "%s" on embeddable "%s" is not allowed.', + $attributeName, + $entityName + )); + } } diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 280a42b04c7..345427d2dab 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -119,12 +119,6 @@ public function validateClass(ClassMetadata $class): array array_push($ce, ...$this->validatePropertiesTypes($class)); } - if ($class->isEmbeddedClass && count($class->associationMappings) > 0) { - $ce[] = "Embeddable '" . $class->name . "' does not support associations"; - - return $ce; - } - foreach ($class->associationMappings as $fieldName => $assoc) { if (! class_exists($assoc->targetEntity) || $cmf->isTransient($assoc->targetEntity)) { $ce[] = "The target entity '" . $assoc->targetEntity . "' specified on " . $class->name . '#' . $fieldName . ' is unknown or not an entity.'; diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 25fb6209555..b7141b0d99d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -202,19 +202,6 @@ public function testInvalidOrderByAssociationInverseSide(): void ); } - #[Group('8052')] - public function testInvalidAssociationInsideEmbeddable(): void - { - $class = $this->em->getClassMetadata(EmbeddableWithAssociation::class); - $ce = $this->validator->validateClass($class); - - self::assertEquals( - ["Embeddable 'Doctrine\Tests\ORM\Tools\EmbeddableWithAssociation' does not support associations"], - $ce, - ); - } - - #[Group('8771')] public function testMappedSuperclassNotPresentInDiscriminator(): void { $class1 = $this->em->getClassMetadata(MappedSuperclassEntity::class); From 6e61571edc7dd20b3f35b3252a50697ac238fb0a Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 11 Oct 2023 11:09:21 +0200 Subject: [PATCH 317/475] Housekeeping: phpcs --- lib/Doctrine/ORM/Mapping/MappingException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 99eab1b1056..bd50bb25111 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -675,7 +675,7 @@ public static function invalidAttributeOnEmbeddable(string $entityName, string $ return new self(sprintf( 'Attribute "%s" on embeddable "%s" is not allowed.', $attributeName, - $entityName + $entityName, )); } } From 2db1f76dee92961b76bf3ea747b0b958bd2c2329 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 11 Oct 2023 11:56:11 +0200 Subject: [PATCH 318/475] Rework AUTO keyword deafults to be IDENTITY always, except Oracle SEQUENCE. --- .../ORM/Mapping/ClassMetadataFactory.php | 56 +------------------ .../Mapping/Exception/CannotGenerateIds.php | 23 -------- .../ORM/Mapping/ClassMetadataFactoryTest.php | 46 --------------- 3 files changed, 3 insertions(+), 122 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 67d660b61fc..733e84093e6 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -7,7 +7,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Platforms; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Event\LoadClassMetadataEventArgs; use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; @@ -29,7 +28,6 @@ use function assert; use function class_exists; -use function constant; use function count; use function end; use function explode; @@ -58,26 +56,8 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory /** @var mixed[] */ private array $embeddablesActiveNesting = []; - private const LEGACY_DEFAULTS_FOR_ID_GENERATION = [ - 'Doctrine\DBAL\Platforms\MySqlPlatform' => ClassMetadata::GENERATOR_TYPE_IDENTITY, - 'Doctrine\DBAL\Platforms\PostgreSqlPlatform' => ClassMetadata::GENERATOR_TYPE_SEQUENCE, - Platforms\DB2Platform::class => ClassMetadata::GENERATOR_TYPE_IDENTITY, - Platforms\MySQLPlatform::class => ClassMetadata::GENERATOR_TYPE_IDENTITY, + private const NON_IDENTITY_DEFAULT_STRATEGY = [ Platforms\OraclePlatform::class => ClassMetadata::GENERATOR_TYPE_SEQUENCE, - Platforms\PostgreSQLPlatform::class => ClassMetadata::GENERATOR_TYPE_SEQUENCE, - Platforms\SQLServerPlatform::class => ClassMetadata::GENERATOR_TYPE_IDENTITY, - Platforms\SqlitePlatform::class => ClassMetadata::GENERATOR_TYPE_IDENTITY, - ]; - - private const RECOMMENDED_STRATEGY = [ - 'Doctrine\DBAL\Platforms\MySqlPlatform' => 'IDENTITY', - 'Doctrine\DBAL\Platforms\PostgreSqlPlatform' => 'IDENTITY', - Platforms\DB2Platform::class => 'IDENTITY', - Platforms\MySQLPlatform::class => 'IDENTITY', - Platforms\OraclePlatform::class => 'SEQUENCE', - Platforms\PostgreSQLPlatform::class => 'IDENTITY', - Platforms\SQLServerPlatform::class => 'IDENTITY', - Platforms\SqlitePlatform::class => 'IDENTITY', ]; public function setEntityManager(EntityManagerInterface $em): void @@ -634,43 +614,13 @@ private function determineIdGeneratorStrategy(AbstractPlatform $platform): int } } - foreach (self::LEGACY_DEFAULTS_FOR_ID_GENERATION as $platformFamily => $strategy) { + foreach (self::NON_IDENTITY_DEFAULT_STRATEGY as $platformFamily => $strategy) { if (is_a($platform, $platformFamily)) { - $recommendedStrategyName = self::RECOMMENDED_STRATEGY[$platformFamily]; - if ($strategy !== constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $recommendedStrategyName)) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8893', - <<<'DEPRECATION' -Relying on non-optimal defaults for ID generation is deprecated. -Instead, configure identifier generation strategies explicitly through -configuration. -We currently recommend "%s" for "%s", so you should use -$configuration->setIdentityGenerationPreferences([ - "%s" => ClassMetadata::GENERATOR_TYPE_%s, -]); -DEPRECATION - , - $recommendedStrategyName, - $platformFamily, - $platformFamily, - $recommendedStrategyName, - ); - } - return $strategy; } } - if ($platform->supportsIdentityColumns()) { - return ClassMetadata::GENERATOR_TYPE_IDENTITY; - } - - if ($platform->supportsSequences()) { - return ClassMetadata::GENERATOR_TYPE_SEQUENCE; - } - - throw CannotGenerateIds::withPlatform($platform); + return ClassMetadata::GENERATOR_TYPE_IDENTITY; } private function truncateSequenceName(string $schemaElementName): string diff --git a/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php b/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php deleted file mode 100644 index a9895ceb218..00000000000 --- a/lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php +++ /dev/null @@ -1,23 +0,0 @@ -hasField('name')); } - public function testItThrowsWhenUsingAutoWithIncompatiblePlatform(): void - { - $cm1 = $this->createValidClassMetadata(); - $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); - - $driver = $this->createMock(Driver::class); - $driver->method('getDatabasePlatform') - ->willReturn($this->createMock(AbstractPlatform::class)); - - $connection = new Connection([], $driver); - $entityManager = $this->createEntityManager(new MetadataDriverMock(), $connection); - $cmf = new ClassMetadataFactoryTestSubject(); - $cmf->setEntityManager($entityManager); - $cmf->setMetadataForClass($cm1->name, $cm1); - $this->expectException(CannotGenerateIds::class); - - $actual = $cmf->getMetadataFor($cm1->name); - } - public function testGetMetadataForReturnsLoadedCustomIdGenerator(): void { $cm1 = $this->createValidClassMetadata(); @@ -149,32 +129,6 @@ private function setUpCmfForPlatform(AbstractPlatform $platform, array $preferen return $cmf; } - public function testRelyingOnLegacyIdGenerationDefaultsIsDeprecatedIfItResultsInASuboptimalDefault(): void - { - $cm = $this->createValidClassMetadata(); - $cm->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); - - $cmf = $this->setUpCmfForPlatform(new PostgreSQLPlatform()); - $cmf->setMetadataForClass($cm->name, $cm); - - $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8893'); - $cmf->getMetadataFor($cm->name); - } - - public function testSpecifyingIdGenerationStrategyThroughConfigurationFixesTheDeprecation(): void - { - $cm = $this->createValidClassMetadata(); - $cm->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); - - $cmf = $this->setUpCmfForPlatform(new PostgreSQLPlatform(), [ - PostgreSQLPlatform::class => ClassMetadata::GENERATOR_TYPE_IDENTITY, - ]); - $cmf->setMetadataForClass($cm->name, $cm); - - $this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8893'); - $cmf->getMetadataFor($cm->name); - } - public function testRelyingOnLegacyIdGenerationDefaultsIsOKIfItResultsInTheCurrentlyRecommendedStrategyBeingUsed(): void { $cm = $this->createValidClassMetadata(); From 2d31d7196111c82afb14c0111d3a78912874aedb Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 11 Oct 2023 12:06:00 +0200 Subject: [PATCH 319/475] Adapt tests, upgrade cs and fix static coding violations and baseline --- .../ORM/Mapping/ClassMetadataFactory.php | 1 - psalm-baseline.xml | 76 ++++++++++++++++++- .../SchemaTool/PostgreSqlSchemaToolTest.php | 8 -- .../ORM/Functional/Ticket/DDC832Test.php | 6 -- .../ORM/Mapping/ClassMetadataFactoryTest.php | 1 - 5 files changed, 75 insertions(+), 17 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 733e84093e6..ad782108a0b 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -16,7 +16,6 @@ use Doctrine\ORM\Id\BigIntegerIdentityGenerator; use Doctrine\ORM\Id\IdentityGenerator; use Doctrine\ORM\Id\SequenceGenerator; -use Doctrine\ORM\Mapping\Exception\CannotGenerateIds; use Doctrine\ORM\Mapping\Exception\InvalidCustomGenerator; use Doctrine\ORM\Mapping\Exception\UnknownGeneratorType; use Doctrine\Persistence\Mapping\AbstractClassMetadataFactory; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index cf0387199b6..f6bbde11a6c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -296,10 +296,84 @@ - + + columnNames]]> + columnNames]]> + columnNames]]> + columnNames]]> + + + $mapping + $mapping + $mapping + $mapping + $overrideMapping + + + ReflectionClass|null + + + $definition + subClasses]]> + + + $className + $className + namespace . '\\' . $className]]> + + + class-string|null + + + reflClass]]> + + + $entity + + + $class + $className + + + declaredField]]]> + + + getProperty + getProperty + getProperty + getValue + getValue + getValue + instantiate + setValue + setValue + + + + + + + + + + $idGenerator + $table + + + $mapping !== false + $mapping !== false + + + array_values + + + table]]> + null + + $platformFamily diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index b13548560f3..61aef5d4040 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\Group; @@ -32,13 +31,6 @@ protected function setUp(): void } } - public function testPostgresMetadataSequenceIncrementedBy10(): void - { - $address = $this->_em->getClassMetadata(CmsAddress::class); - - self::assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); - } - #[Group('DDC-1657')] public function testUpdateSchemaWithPostgreSQLSchema(): void { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php index d3b908fd561..5cf9fb9d9c4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\DBAL\Platforms\OraclePlatform; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorColumn; use Doctrine\ORM\Mapping\DiscriminatorMap; @@ -43,11 +42,6 @@ public function tearDown(): void $sm->dropTable($platform->quoteIdentifier('TREE_INDEX')); $sm->dropTable($platform->quoteIdentifier('INDEX')); $sm->dropTable($platform->quoteIdentifier('LIKE')); - - if ($platform instanceof PostgreSQLPlatform) { - $sm->dropSequence($platform->quoteIdentifier('INDEX_id_seq')); - $sm->dropSequence($platform->quoteIdentifier('LIKE_id_seq')); - } } #[Group('DDC-832')] diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 6b8fa4813d8..752ad559b18 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -9,7 +9,6 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; From 7827453b94b974bf8d568bf616e0a08bf733d2d7 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 11 Oct 2023 13:48:34 +0200 Subject: [PATCH 320/475] UPGRADE.md is missing two latest merges. --- UPGRADE.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 16a976f5188..27adbd48f30 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,29 @@ # Upgrade to 3.0 +## BC BREAK: AUTO keyword for identity generation defaults to IDENTITY for PostgreSQL now + +When using the AUTO strategy to let Doctrine determine the identity generation mecehanism for +an entity, PostgreSQL now uses IDENTITY instead of SEQUENCE. When upgrading from ORM 2.x +and preference is on keeping the SEQUENCE based identity generation, then configure the ORM +this way: + +```php +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\Mapping\ClassMetadata; + +assert($configuration instanceof Configuration); +$configuration->setIdentityGenerationPreferences([ + PostgreSQLPlatform::CLASS => ClassMetadata::GENERATOR_TYPE_SEQUENCE, +]); +``` + +## BC BREAK: Throw exceptions when using illegal attributes on Embeddable + +There are only a few attributes allowed on an embeddable such as `#[Column]` or +`#[Embedded]`. Previously all others that target entity classes where ignored, +now they throw an exception. + ## BC BREAK: Partial objects are removed - The `PARTIAL` keyword in DQL no longer exists. From 06eb00d68710877ea8f7f02250d8f0f37eec7350 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 11 Oct 2023 15:27:18 +0200 Subject: [PATCH 321/475] Fix array parameters with DBAL 4 (#10995) --- lib/Doctrine/ORM/AbstractQuery.php | 14 ++++--- .../Tests/ORM/Functional/NativeQueryTest.php | 38 +++++++++++++++++++ tests/Doctrine/Tests/ORM/Query/QueryTest.php | 21 ++++++++++ 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index e87813d4377..e0245d44e15 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Util\ClassUtils; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Result; @@ -320,15 +321,16 @@ public function setParameters(ArrayCollection|array $parameters): static /** * Sets a query parameter. * - * @param string|int $key The parameter position or name. - * @param mixed $value The parameter value. - * @param ParameterType|string|int|null $type The parameter type. If specified, the given value will be run through - * the type conversion of this type. This is usually not needed for - * strings and numeric types. + * @param string|int $key The parameter position or name. + * @param mixed $value The parameter value. + * @param ParameterType|ArrayParameterType|string|int|null $type The parameter type. If specified, the given value + * will be run through the type conversion of this + * type. This is usually not needed for strings and + * numeric types. * * @return $this */ - public function setParameter(string|int $key, mixed $value, ParameterType|string|int|null $type = null): static + public function setParameter(string|int $key, mixed $value, ParameterType|ArrayParameterType|string|int|null $type = null): static { $existingParameter = $this->getParameter($key); diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 1565bc6f3f8..6b8f883f418 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; @@ -72,6 +73,43 @@ public function testBasicNativeQuery(): void self::assertEquals('Roman', $users[0]->name); } + public function testNativeQueryWithArrayParameter(): void + { + $user = new CmsUser(); + $user->name = 'William Shatner'; + $user->username = 'wshatner'; + $user->status = 'dev'; + $this->_em->persist($user); + $user = new CmsUser(); + $user->name = 'Leonard Nimoy'; + $user->username = 'lnimoy'; + $user->status = 'dev'; + $this->_em->persist($user); + $user = new CmsUser(); + $user->name = 'DeForest Kelly'; + $user->username = 'dkelly'; + $user->status = 'dev'; + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->clear(); + + $rsm = new ResultSetMapping(); + $rsm->addEntityResult(CmsUser::class, 'u'); + $rsm->addFieldResult('u', $this->getSQLResultCasing($this->platform, 'id'), 'id'); + $rsm->addFieldResult('u', $this->getSQLResultCasing($this->platform, 'name'), 'name'); + + $query = $this->_em->createNativeQuery('SELECT id, name FROM cms_users WHERE username IN (?) ORDER BY username', $rsm); + $query->setParameter(1, ['wshatner', 'lnimoy'], ArrayParameterType::STRING); + + $users = $query->getResult(); + + self::assertCount(2, $users); + self::assertInstanceOf(CmsUser::class, $users[0]); + self::assertEquals('Leonard Nimoy', $users[0]->name); + self::assertEquals('William Shatner', $users[1]->name); + } + public function testBasicNativeQueryWithMetaResult(): void { $user = new CmsUser(); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index b04621af004..d24d9292ca9 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -7,6 +7,7 @@ use DateTime; use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; @@ -194,6 +195,26 @@ public function testCollectionParameters(): void self::assertEquals($cities, $parameter->getValue()); } + #[Group('DDC-1697')] + public function testExplicitCollectionParameters(): void + { + $cities = [ + 0 => 'Paris', + 3 => 'Cannes', + 9 => 'St Julien', + ]; + + $query = $this->entityManager + ->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.city IN (:cities)') + ->setParameter('cities', $cities, ArrayParameterType::STRING); + + $parameters = $query->getParameters(); + $parameter = $parameters->first(); + + self::assertEquals('cities', $parameter->getName()); + self::assertEquals($cities, $parameter->getValue()); + } + /** @psalm-return Generator */ public static function provideProcessParameterValueIterable(): Generator { From e997c6688c1ab653f1b9426e34259f01333d1d44 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 12 Oct 2023 20:23:35 +0200 Subject: [PATCH 322/475] Remove schema visitors (#11001) --- lib/Doctrine/ORM/Tools/SchemaTool.php | 11 ----------- psalm.xml | 5 ----- 2 files changed, 16 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index a9fcc469590..13ce5ed6993 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -11,7 +11,6 @@ use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; -use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; @@ -33,13 +32,11 @@ use function array_flip; use function array_intersect_key; use function assert; -use function class_exists; use function count; use function current; use function implode; use function in_array; use function is_numeric; -use function method_exists; use function strtolower; /** @@ -381,14 +378,6 @@ public function getSchemaFromMetadata(array $classes): Schema } } - if ( - ! $this->platform->supportsSchemas() - && class_exists(RemoveNamespacedAssets::class) - && method_exists($schema, 'visit') - ) { - $schema->visit(new RemoveNamespacedAssets()); - } - if ($eventManager->hasListeners(ToolEvents::postGenerateSchema)) { $eventManager->dispatchEvent( ToolEvents::postGenerateSchema, diff --git a/psalm.xml b/psalm.xml index 87769df2ecc..13eeb8f5429 100644 --- a/psalm.xml +++ b/psalm.xml @@ -27,7 +27,6 @@ - @@ -47,7 +46,6 @@ - @@ -196,9 +194,6 @@ - - - From e280b2df265656dff194ef92809ace73827bc2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 15 Oct 2023 13:56:52 +0200 Subject: [PATCH 323/475] Use native return type declarations in Debug class (#11012) --- lib/Doctrine/ORM/Tools/Debug.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Debug.php b/lib/Doctrine/ORM/Tools/Debug.php index 153abac4a44..ec27065b3dd 100644 --- a/lib/Doctrine/ORM/Tools/Debug.php +++ b/lib/Doctrine/ORM/Tools/Debug.php @@ -53,7 +53,7 @@ private function __construct() * @param mixed $var The variable to dump. * @param int $maxDepth The maximum nesting level for object properties. */ - public static function dump($var, int $maxDepth = 2): string + public static function dump(mixed $var, int $maxDepth = 2): string { $html = ini_get('html_errors'); @@ -88,12 +88,7 @@ public static function dump($var, int $maxDepth = 2): string return $dumpText; } - /** - * @param mixed $var - * - * @return mixed - */ - public static function export($var, int $maxDepth) + public static function export(mixed $var, int $maxDepth): mixed { if ($var instanceof Collection) { $var = $var->toArray(); @@ -144,12 +139,8 @@ public static function export($var, int $maxDepth) /** * Fill the $return variable with class attributes * Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075} - * - * @param object $var - * - * @return mixed */ - private static function fillReturnWithClassAttributes($var, stdClass $return, int $maxDepth) + private static function fillReturnWithClassAttributes(object $var, stdClass $return, int $maxDepth): stdClass { $clone = (array) $var; From 444406553146b44e718b264305cc936024d4c9e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 15 Oct 2023 21:30:26 +0200 Subject: [PATCH 324/475] Remove dependency on doctrine/common (#10998) We were only relying on it for functionality related to proxies, which is very little code. --- UPGRADE.md | 8 +- composer.json | 1 - lib/Doctrine/ORM/Proxy/Autoloader.php | 86 +++++++++++++++++++ lib/Doctrine/ORM/Proxy/NotAProxyClass.php | 22 +++++ psalm-baseline.xml | 14 +++ tests/Doctrine/Tests/Proxy/AutoloaderTest.php | 57 ++++++++++++ 6 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 lib/Doctrine/ORM/Proxy/Autoloader.php create mode 100644 lib/Doctrine/ORM/Proxy/NotAProxyClass.php create mode 100644 tests/Doctrine/Tests/Proxy/AutoloaderTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 0673dc70bf1..24d699e1371 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: `Doctrine\ORM\Proxy\Autoloader` no longer extends `Doctrine\Common\Proxy\Autoloader` + +Make sure to use the former when writing a type declaration or an `instanceof` check. + ## Minor BC BREAK: Changed order of arguments passed to `OneToOne`, `ManyToOne` and `Index` mapping PHP attributes To keep PHP mapping attributes consistent, order of arguments passed to above attributes has been changed @@ -328,10 +332,6 @@ Use `Doctrine\Persistence\Mapping\Driver\StaticPHPDriver` and The second argument to `UnderscoreNamingStrategy::__construct()` was dropped, the strategy can no longer be unaware of numbers. -## BC BREAK: Remove `Doctrine\ORM\Proxy\Autoloader` - -Use `Doctrine\Common\Proxy\Autoloader` instead. - ## BC BREAK: Remove `Doctrine\ORM\Tools\DisconnectedClassMetadataFactory` No replacement is provided. diff --git a/composer.json b/composer.json index ceae5193171..1064ebadeaf 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,6 @@ "composer-runtime-api": "^2", "ext-ctype": "*", "doctrine/collections": "^2.1", - "doctrine/common": "^3.3", "doctrine/dbal": "^3.6 || ^4", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.2 || ^2", diff --git a/lib/Doctrine/ORM/Proxy/Autoloader.php b/lib/Doctrine/ORM/Proxy/Autoloader.php new file mode 100644 index 00000000000..d30477a80e8 --- /dev/null +++ b/lib/Doctrine/ORM/Proxy/Autoloader.php @@ -0,0 +1,86 @@ +string + + + $autoloader + + + $autoloader + + + Closure(string): void + + + require $file + + $classMetadata diff --git a/tests/Doctrine/Tests/Proxy/AutoloaderTest.php b/tests/Doctrine/Tests/Proxy/AutoloaderTest.php new file mode 100644 index 00000000000..1bcf37910a2 --- /dev/null +++ b/tests/Doctrine/Tests/Proxy/AutoloaderTest.php @@ -0,0 +1,57 @@ + */ + public static function dataResolveFile(): iterable + { + return [ + ['/tmp', 'MyProxy', 'MyProxy\RealClass', '/tmp' . DIRECTORY_SEPARATOR . 'RealClass.php'], + ['/tmp', 'MyProxy', 'MyProxy\__CG__\RealClass', '/tmp' . DIRECTORY_SEPARATOR . '__CG__RealClass.php'], + ['/tmp', 'MyProxy\Subdir', 'MyProxy\Subdir\__CG__\RealClass', '/tmp' . DIRECTORY_SEPARATOR . '__CG__RealClass.php'], + ['/tmp', 'MyProxy', 'MyProxy\__CG__\Other\RealClass', '/tmp' . DIRECTORY_SEPARATOR . '__CG__OtherRealClass.php'], + ]; + } + + /** @param class-string $className */ + #[DataProvider('dataResolveFile')] + public function testResolveFile( + string $proxyDir, + string $proxyNamespace, + string $className, + string $expectedProxyFile, + ): void { + $actualProxyFile = Autoloader::resolveFile($proxyDir, $proxyNamespace, $className); + self::assertEquals($expectedProxyFile, $actualProxyFile); + } + + public function testAutoload(): void + { + if (file_exists(sys_get_temp_dir() . '/AutoloaderTestClass.php')) { + unlink(sys_get_temp_dir() . '/AutoloaderTestClass.php'); + } + + $autoloader = Autoloader::register(sys_get_temp_dir(), 'ProxyAutoloaderTest', static function ($proxyDir, $proxyNamespace, $className): void { + file_put_contents(sys_get_temp_dir() . '/AutoloaderTestClass.php', ' Date: Mon, 16 Oct 2023 08:41:34 +0200 Subject: [PATCH 325/475] Prepare CI for stable DBAL 4 (#11011) --- .github/workflows/continuous-integration.yml | 19 ++++++----- .github/workflows/static-analysis.yml | 6 ++-- composer.json | 1 + phpstan-dbal3.neon | 34 ++++++++++++++++++++ phpstan-dbal4.neon | 24 -------------- phpstan.neon | 20 ++++++++++++ 6 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 phpstan-dbal3.neon delete mode 100644 phpstan-dbal4.neon diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index be3591446e6..6af2ac37939 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -38,19 +38,18 @@ jobs: - "8.3" dbal-version: - "default" + - "3.7" extension: + - "sqlite3" - "pdo_sqlite" deps: - "highest" include: - php-version: "8.2" - dbal-version: "3@dev" - extension: "pdo_sqlite" - - php-version: "8.1" dbal-version: "4@dev" extension: "pdo_sqlite" - php-version: "8.2" - dbal-version: "default" + dbal-version: "4@dev" extension: "sqlite3" - php-version: "8.1" dbal-version: "default" @@ -110,7 +109,7 @@ jobs: - "8.3" dbal-version: - "default" - - "3@dev" + - "3.7" postgres-version: - "15" extension: @@ -122,7 +121,7 @@ jobs: postgres-version: "14" extension: pdo_pgsql - php-version: "8.2" - dbal-version: "default" + dbal-version: "3.7" postgres-version: "9.6" extension: pdo_pgsql @@ -183,7 +182,7 @@ jobs: - "8.3" dbal-version: - "default" - - "3@dev" + - "3.7" - "4@dev" mariadb-version: - "10.9" @@ -249,7 +248,7 @@ jobs: - "8.3" dbal-version: - "default" - - "3@dev" + - "3.7" mysql-version: - "5.7" - "8.0" @@ -257,11 +256,11 @@ jobs: - "mysqli" - "pdo_mysql" include: - - php-version: "8.1" + - php-version: "8.2" dbal-version: "4@dev" mysql-version: "8.0" extension: "mysqli" - - php-version: "8.1" + - php-version: "8.2" dbal-version: "4@dev" mysql-version: "8.0" extension: "pdo_mysql" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 83fae56f2f6..921ccf8115c 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -32,8 +32,8 @@ jobs: include: - dbal-version: default config: phpstan.neon - - dbal-version: 4@dev - config: phpstan-dbal4.neon + - dbal-version: 3.7 + config: phpstan-dbal3.neon steps: - name: "Checkout code" @@ -65,7 +65,7 @@ jobs: matrix: dbal-version: - default - - 4@dev + - 3.7 steps: - name: "Checkout code" diff --git a/composer.json b/composer.json index 1064ebadeaf..117ce895086 100644 --- a/composer.json +++ b/composer.json @@ -45,6 +45,7 @@ "symfony/cache": "^5.4 || ^6.2", "vimeo/psalm": "5.15.0" }, + "minimum-stability": "RC", "suggest": { "ext-dom": "Provides support for XSD validation for XML mapping files", "symfony/cache": "Provides cache support for Setup Tool with doctrine/cache 2.0" diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon new file mode 100644 index 00000000000..772fb0298b5 --- /dev/null +++ b/phpstan-dbal3.neon @@ -0,0 +1,34 @@ +includes: + - phpstan-baseline.neon + - phpstan-params.neon + +parameters: + ignoreErrors: + # Symfony cache supports passing a key prefix to the clear method. + - '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/' + + # We can be certain that those values are not matched. + - + message: '~^Match expression does not handle remaining values:~' + path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + + # DBAL 4 compatibility + - + message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' + path: lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php + - + message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' + path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + + - + message: '~^Unreachable statement \- code above always terminates\.$~' + path: lib/Doctrine/ORM/Mapping/AssociationMapping.php + + # To be removed in 4.0 + - + message: '#Negated boolean expression is always false\.#' + paths: + - lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php + - lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php + - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php + - lib/Doctrine/ORM/ORMSetup.php diff --git a/phpstan-dbal4.neon b/phpstan-dbal4.neon deleted file mode 100644 index fa8291b8612..00000000000 --- a/phpstan-dbal4.neon +++ /dev/null @@ -1,24 +0,0 @@ -includes: - - phpstan.neon - -parameters: - ignoreErrors: - # Compatibility with DBAL 3 - # See https://github.com/doctrine/dbal/pull/3480 - - - message: '~^Result of method Doctrine\\DBAL\\Connection::commit\(\) \(void\) is used\.$~' - path: lib/Doctrine/ORM/UnitOfWork.php - - - message: '~^Strict comparison using === between void and false will always evaluate to false\.$~' - path: lib/Doctrine/ORM/UnitOfWork.php - - - message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~' - path: lib/Doctrine/ORM/UnitOfWork.php - - - - message: '~^Parameter #1 \$command of method Symfony\\Component\\Console\\Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command, Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand given\.$~' - path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php - - - - message: '~Strict comparison using \=\=\= between callable\(\)\: mixed and null will always evaluate to false\.~' - path: lib/Doctrine/ORM/Tools/SchemaTool.php diff --git a/phpstan.neon b/phpstan.neon index 772fb0298b5..20d621ccdf9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -24,6 +24,26 @@ parameters: message: '~^Unreachable statement \- code above always terminates\.$~' path: lib/Doctrine/ORM/Mapping/AssociationMapping.php + # Compatibility with DBAL 3 + # See https://github.com/doctrine/dbal/pull/3480 + - + message: '~^Result of method Doctrine\\DBAL\\Connection::commit\(\) \(void\) is used\.$~' + path: lib/Doctrine/ORM/UnitOfWork.php + - + message: '~^Strict comparison using === between void and false will always evaluate to false\.$~' + path: lib/Doctrine/ORM/UnitOfWork.php + - + message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~' + path: lib/Doctrine/ORM/UnitOfWork.php + + - + message: '~^Parameter #1 \$command of method Symfony\\Component\\Console\\Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command, Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand given\.$~' + path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php + + - + message: '~Strict comparison using \=\=\= between callable\(\)\: mixed and null will always evaluate to false\.~' + path: lib/Doctrine/ORM/Tools/SchemaTool.php + # To be removed in 4.0 - message: '#Negated boolean expression is always false\.#' From 82f4a177b2ee63a12701149a88a7021c4aae6b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 22 Oct 2023 15:40:16 +0200 Subject: [PATCH 326/475] Use native type hint for ProxyFactory::getProxy This requires heavily adapting tests, because the proxy instance must: - be an instance of InternalProxy (easy) - be a valid entity (hard, especially for PHPUnit) --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 4 +- .../ORM/Hydration/ObjectHydratorTest.php | 55 +++++++++++-------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index f04bd8c6625..d05f49b7025 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -166,10 +166,8 @@ public function __construct( /** * @param class-string $className * @param array $identifier - * - * @return InternalProxy */ - public function getProxy(string $className, array $identifier) + public function getProxy(string $className, array $identifier): InternalProxy { $proxyFactory = $this->proxyFactories[$className] ?? $this->getProxyFactory($className); diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index 2d3d7fffad5..977028da875 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -11,6 +11,7 @@ use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; +use Doctrine\ORM\Proxy\InternalProxy; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\Models\CMS\CmsAddress; @@ -30,9 +31,11 @@ use Doctrine\Tests\Models\Hydration\SimpleEntity; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\TestCase; use function count; use function property_exists; +use function sys_get_temp_dir; class ObjectHydratorTest extends HydrationTestCase { @@ -1021,18 +1024,21 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void ], ]; - $proxyInstance = new ECommerceShipping(); - - // mocking the proxy factory - $proxyFactory = $this->getMockBuilder(ProxyFactory::class) - ->onlyMethods(['getProxy']) - ->disableOriginalConstructor() - ->getMock(); - - $proxyFactory->expects(self::once()) - ->method('getProxy') - ->with(self::equalTo(ECommerceShipping::class), ['id' => 42]) - ->will(self::returnValue($proxyInstance)); + // extending the proxy factory to spy on getProxy() + $proxyFactory = new class ( + $this->entityManager, + sys_get_temp_dir(), + 'Proxies', + ProxyFactory::AUTOGENERATE_ALWAYS, + ) extends ProxyFactory { + public function getProxy(string $className, array $identifier): InternalProxy + { + TestCase::assertSame(ECommerceShipping::class, $className); + TestCase::assertSame(['id' => 42], $identifier); + + return parent::getProxy($className, $identifier); + } + }; $this->entityManager->setProxyFactory($proxyFactory); @@ -1072,16 +1078,21 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE $proxyInstance = new ECommerceShipping(); - // mocking the proxy factory - $proxyFactory = $this->getMockBuilder(ProxyFactory::class) - ->onlyMethods(['getProxy']) - ->disableOriginalConstructor() - ->getMock(); - - $proxyFactory->expects(self::once()) - ->method('getProxy') - ->with(self::equalTo(ECommerceShipping::class), ['id' => 42]) - ->will(self::returnValue($proxyInstance)); + // extending the proxy factory to spy on getProxy() + $proxyFactory = new class ( + $this->entityManager, + sys_get_temp_dir(), + 'Proxies', + ProxyFactory::AUTOGENERATE_ALWAYS, + ) extends ProxyFactory { + public function getProxy(string $className, array $identifier): InternalProxy + { + TestCase::assertSame(ECommerceShipping::class, $className); + TestCase::assertSame(['id' => 42], $identifier); + + return parent::getProxy($className, $identifier); + } + }; $this->entityManager->setProxyFactory($proxyFactory); From 8ab0af3d30c7c80a34f533efc1380b954d91d8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 21 Oct 2023 21:36:19 +0200 Subject: [PATCH 327/475] Enforce native type declarations I tried to avoid changes in tests, so as to not unnecessarily widen the gap between 2.x and 3.x. --- lib/Doctrine/ORM/Event/PreUpdateEventArgs.php | 11 ++------ .../EntityIdentityCollisionException.php | 6 +--- lib/Doctrine/ORM/Internal/TopologicalSort.php | 20 ++++++------- .../CycleDetectedException.php | 12 +++----- .../ORM/Mapping/AssociationMapping.php | 2 +- lib/Doctrine/ORM/Mapping/ClassMetadata.php | 8 ++---- .../ORM/ORMInvalidArgumentException.php | 3 +- .../Entity/CachedPersisterContext.php | 14 +++------- .../ORM/Persisters/PersisterException.php | 3 +- .../ORM/Persisters/SqlValueVisitor.php | 4 +-- .../Proxy/DefaultProxyClassNameResolver.php | 8 ++---- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 10 ++----- .../ORM/Query/AST/ArithmeticExpression.php | 3 +- .../ORM/Query/AST/BetweenExpression.php | 11 ++------ .../Query/AST/CollectionMemberExpression.php | 3 +- .../ORM/Query/AST/ComparisonExpression.php | 8 ++---- .../ORM/Query/AST/ConditionalFactor.php | 3 +- .../ORM/Query/AST/ConditionalPrimary.php | 6 ++-- .../ORM/Query/AST/DeleteStatement.php | 6 ++-- .../EmptyCollectionComparisonExpression.php | 3 +- .../ORM/Query/AST/ExistsExpression.php | 3 +- .../Query/AST/Functions/IdentityFunction.php | 3 +- .../ORM/Query/AST/Functions/SizeFunction.php | 3 +- lib/Doctrine/ORM/Query/AST/HavingClause.php | 3 +- .../AST/IdentificationVariableDeclaration.php | 10 ++----- .../ORM/Query/AST/InstanceOfExpression.php | 7 ++--- lib/Doctrine/ORM/Query/AST/Join.php | 10 ++----- .../Query/AST/JoinAssociationDeclaration.php | 8 ++---- .../ORM/Query/AST/JoinVariableDeclaration.php | 6 +--- lib/Doctrine/ORM/Query/AST/LikeExpression.php | 11 ++------ .../ORM/Query/AST/QuantifiedExpression.php | 3 +- .../ORM/Query/AST/SelectStatement.php | 18 ++++-------- .../ORM/Query/AST/SimpleCaseExpression.php | 7 ++--- .../ORM/Query/AST/SimpleSelectClause.php | 3 +- .../ORM/Query/AST/SimpleSelectExpression.php | 3 +- lib/Doctrine/ORM/Query/AST/Subselect.php | 18 ++++-------- ...electIdentificationVariableDeclaration.php | 3 +- lib/Doctrine/ORM/Query/AST/UpdateItem.php | 6 +--- .../ORM/Query/AST/UpdateStatement.php | 6 ++-- lib/Doctrine/ORM/Query/AST/WhenClause.php | 3 +- lib/Doctrine/ORM/Query/AST/WhereClause.php | 3 +- .../Exec/SingleTableDeleteUpdateExecutor.php | 3 +- lib/Doctrine/ORM/Query/Expr.php | 2 +- lib/Doctrine/ORM/Query/Expr/Base.php | 2 +- lib/Doctrine/ORM/Query/Expr/Func.php | 3 +- lib/Doctrine/ORM/Query/Parser.php | 28 ++++++------------- lib/Doctrine/ORM/Query/SqlWalker.php | 1 - .../Command/SchemaTool/UpdateCommand.php | 3 +- lib/Doctrine/ORM/UnitOfWork.php | 15 ++++------ phpcs.xml.dist | 12 ++++---- phpstan-baseline.neon | 2 +- psalm-baseline.xml | 6 ---- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 2 +- 53 files changed, 110 insertions(+), 250 deletions(-) diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php index 7d6b203baf9..090487b8605 100644 --- a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php @@ -23,11 +23,10 @@ class PreUpdateEventArgs extends LifecycleEventArgs private array $entityChangeSet; /** - * @param object $entity * @param mixed[][] $changeSet * @psalm-param array $changeSet */ - public function __construct($entity, EntityManagerInterface $em, array &$changeSet) + public function __construct(object $entity, EntityManagerInterface $em, array &$changeSet) { parent::__construct($entity, $em); @@ -55,10 +54,8 @@ public function hasChangedField(string $field): bool /** * Gets the old value of the changeset of the changed field. - * - * @return mixed */ - public function getOldValue(string $field) + public function getOldValue(string $field): mixed { $this->assertValidField($field); @@ -67,10 +64,8 @@ public function getOldValue(string $field) /** * Gets the new value of the changeset of the changed field. - * - * @return mixed */ - public function getNewValue(string $field) + public function getNewValue(string $field): mixed { $this->assertValidField($field); diff --git a/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php b/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php index 8c244cac78f..06ddd5dce20 100644 --- a/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php +++ b/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php @@ -11,11 +11,7 @@ final class EntityIdentityCollisionException extends Exception implements ORMException { - /** - * @param object $existingEntity - * @param object $newEntity - */ - public static function create($existingEntity, $newEntity, string $idHash): self + public static function create(object $existingEntity, object $newEntity, string $idHash): self { return new self( sprintf( diff --git a/lib/Doctrine/ORM/Internal/TopologicalSort.php b/lib/Doctrine/ORM/Internal/TopologicalSort.php index 2bf1624ced8..798d9202779 100644 --- a/lib/Doctrine/ORM/Internal/TopologicalSort.php +++ b/lib/Doctrine/ORM/Internal/TopologicalSort.php @@ -31,7 +31,7 @@ final class TopologicalSort * * @var array */ - private $nodes = []; + private array $nodes = []; /** * DFS state for the different nodes, indexed by node object id and using one of @@ -39,7 +39,7 @@ final class TopologicalSort * * @var array */ - private $states = []; + private array $states = []; /** * Edges between the nodes. The first-level key is the object id of the outgoing @@ -48,17 +48,16 @@ final class TopologicalSort * * @var array> */ - private $edges = []; + private array $edges = []; /** * Builds up the result during the DFS. * * @var list */ - private $sortResult = []; + private array $sortResult = []; - /** @param object $node */ - public function addNode($node): void + public function addNode(object $node): void { $id = spl_object_id($node); $this->nodes[$id] = $node; @@ -66,8 +65,7 @@ public function addNode($node): void $this->edges[$id] = []; } - /** @param object $node */ - public function hasNode($node): bool + public function hasNode(object $node): bool { return isset($this->nodes[spl_object_id($node)]); } @@ -75,11 +73,9 @@ public function hasNode($node): bool /** * Adds a new edge between two nodes to the graph * - * @param object $from - * @param object $to - * @param bool $optional This indicates whether the edge may be ignored during the topological sort if it is necessary to break cycles. + * @param bool $optional This indicates whether the edge may be ignored during the topological sort if it is necessary to break cycles. */ - public function addEdge($from, $to, bool $optional): void + public function addEdge(object $from, object $to, bool $optional): void { $fromId = spl_object_id($from); $toId = spl_object_id($to); diff --git a/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php b/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php index a2d93b954bf..c28ce561dce 100644 --- a/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php +++ b/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php @@ -11,17 +11,14 @@ class CycleDetectedException extends RuntimeException { /** @var list */ - private $cycle; + private array $cycle; /** * Do we have the complete cycle collected? - * - * @var bool */ - private $cycleCollected = false; + private bool $cycleCollected = false; - /** @param object $startNode */ - public function __construct(private $startNode) + public function __construct(private object $startNode) { parent::__construct('A cycle has been detected, so a topological sort is not possible. The getCycle() method provides the list of nodes that form the cycle.'); @@ -34,8 +31,7 @@ public function getCycle(): array return $this->cycle; } - /** @param object $node */ - public function addToCycle($node): void + public function addToCycle(object $node): void { array_unshift($this->cycle, $node); diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/lib/Doctrine/ORM/Mapping/AssociationMapping.php index e3a899661dc..ea78bbd6764 100644 --- a/lib/Doctrine/ORM/Mapping/AssociationMapping.php +++ b/lib/Doctrine/ORM/Mapping/AssociationMapping.php @@ -231,7 +231,7 @@ public function offsetExists(mixed $offset): bool return isset($this->$offset) || in_array($offset, ['isOwningSide', 'type'], true); } - final public function offsetGet($offset): mixed + final public function offsetGet(mixed $offset): mixed { return match ($offset) { 'isOwningSide' => $this->isOwningSide(), diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index 9dd91851a7e..5a80fa67893 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -544,7 +544,7 @@ class ClassMetadata implements PersistenceClassMetadata, Stringable * @param string $name The name of the entity class the new instance is used for. * @psalm-param class-string $name */ - public function __construct(public $name, NamingStrategy|null $namingStrategy = null, TypedFieldMapper|null $typedFieldMapper = null) + public function __construct(public string $name, NamingStrategy|null $namingStrategy = null, TypedFieldMapper|null $typedFieldMapper = null) { $this->rootEntityName = $name; $this->namingStrategy = $namingStrategy ?? new DefaultNamingStrategy(); @@ -591,11 +591,9 @@ public function getSingleIdReflectionProperty(): ReflectionProperty|null * For composite identifiers, the identifier values are returned as an array * with the same order as the field order in {@link identifier}. * - * @param object $entity - * * @return array */ - public function getIdentifierValues($entity): array + public function getIdentifierValues(object $entity): array { if ($this->isIdentifierComposite) { $id = []; @@ -676,7 +674,7 @@ public function __toString(): string * * @return string[] The names of all the fields that should be serialized. */ - public function __sleep() + public function __sleep(): array { // This metadata is always serialized/cached. $serialized = [ diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/lib/Doctrine/ORM/ORMInvalidArgumentException.php index 810eb1a020e..fe07a2ad464 100644 --- a/lib/Doctrine/ORM/ORMInvalidArgumentException.php +++ b/lib/Doctrine/ORM/ORMInvalidArgumentException.php @@ -145,8 +145,7 @@ public static function invalidAssociation(ClassMetadata $targetClass, Associatio )); } - /** @param mixed $value */ - public static function invalidAutoGenerateMode($value): self + public static function invalidAutoGenerateMode(mixed $value): self { return new self(sprintf('Invalid auto generate mode "%s" given.', is_scalar($value) ? (string) $value : get_debug_type($value))); } diff --git a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php index cd42340ff2b..03d053b220c 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php +++ b/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php @@ -21,32 +21,26 @@ class CachedPersisterContext /** * The SELECT column list SQL fragment used for querying entities by this persister. * This SQL fragment is only generated once per request, if at all. - * - * @var string|null */ - public $selectColumnListSql; + public string|null $selectColumnListSql = null; /** * The JOIN SQL fragment used to eagerly load all many-to-one and one-to-one * associations configured as FETCH_EAGER, as well as all inverse one-to-one associations. - * - * @var string */ - public $selectJoinSql; + public string|null $selectJoinSql = null; /** * Counter for creating unique SQL table and column aliases. - * - * @var int */ - public $sqlAliasCounter = 0; + public int $sqlAliasCounter = 0; /** * Map from class names (FQCN) to the corresponding generated SQL table aliases. * * @var array */ - public $sqlTableAliases = []; + public array $sqlTableAliases = []; public function __construct( /** diff --git a/lib/Doctrine/ORM/Persisters/PersisterException.php b/lib/Doctrine/ORM/Persisters/PersisterException.php index 0f8fe84f54c..00164720d06 100644 --- a/lib/Doctrine/ORM/Persisters/PersisterException.php +++ b/lib/Doctrine/ORM/Persisters/PersisterException.php @@ -11,8 +11,7 @@ class PersisterException extends Exception implements ORMException { - /** @return PersisterException */ - public static function matchingAssocationFieldRequiresObject(string $class, string $associationName) + public static function matchingAssocationFieldRequiresObject(string $class, string $associationName): PersisterException { return new self(sprintf( 'Cannot match on %s::%s with a non-object value. Matching objects by id is ' . diff --git a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php index 79c495b87cc..7f987ad9815 100644 --- a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php @@ -73,10 +73,8 @@ public function getParamsAndTypes(): array /** * Returns the value from a Comparison. In case of a CONTAINS comparison, * the value is wrapped in %-signs, because it will be used in a LIKE clause. - * - * @return mixed */ - protected function getValueFromComparison(Comparison $comparison) + protected function getValueFromComparison(Comparison $comparison): mixed { $value = $comparison->getValue()->getValue(); diff --git a/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php b/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php index a9d0a3dba93..6a6fd1c9579 100644 --- a/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php +++ b/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php @@ -28,12 +28,8 @@ public function resolveClassName(string $className): string return substr($className, $pos + Proxy::MARKER_LENGTH + 2); } - /** - * @param object $object - * - * @return class-string - */ - public static function getClass($object): string + /** @return class-string */ + public static function getClass(object $object): string { return (new self())->resolveClassName(get_class($object)); } diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index d05f49b7025..2a8e70f5bbc 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -118,9 +118,6 @@ public function __serialize(): array /** The UnitOfWork this factory uses to retrieve persisters */ private readonly UnitOfWork $uow; - /** @var string */ - private $proxyDir; - /** @var self::AUTOGENERATE_* */ private $autoGenerate; @@ -128,7 +125,7 @@ public function __serialize(): array private readonly IdentifierFlattener $identifierFlattener; /** @var array */ - private $proxyFactories = []; + private array $proxyFactories = []; /** * Initializes a new instance of the ProxyFactory class that is @@ -141,7 +138,7 @@ public function __serialize(): array */ public function __construct( private readonly EntityManagerInterface $em, - string $proxyDir, + private string $proxyDir, private readonly string $proxyNs, bool|int $autoGenerate = self::AUTOGENERATE_NEVER, ) { @@ -158,7 +155,6 @@ public function __construct( } $this->uow = $em->getUnitOfWork(); - $this->proxyDir = $proxyDir; $this->autoGenerate = (int) $autoGenerate; $this->identifierFlattener = new IdentifierFlattener($this->uow, $em->getMetadataFactory()); } @@ -184,7 +180,7 @@ public function getProxy(string $className, array $identifier): InternalProxy * * @return int Number of generated proxies. */ - public function generateProxyClasses(array $classes, $proxyDir = null): int + public function generateProxyClasses(array $classes, string|null $proxyDir = null): int { $generated = 0; diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php index 9268414e85f..a819e058282 100644 --- a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php @@ -15,8 +15,7 @@ class ArithmeticExpression extends Node { public Node|string|null $simpleArithmeticExpression = null; - /** @var Subselect|null */ - public $subselect; + public Subselect|null $subselect = null; public function isSimpleArithmeticExpression(): bool { diff --git a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php b/lib/Doctrine/ORM/Query/AST/BetweenExpression.php index 24f351cbc25..c13292b741f 100644 --- a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php +++ b/lib/Doctrine/ORM/Query/AST/BetweenExpression.php @@ -8,15 +8,10 @@ class BetweenExpression extends Node { - /** - * @param ArithmeticExpression $expression - * @param ArithmeticExpression $leftBetweenExpression - * @param ArithmeticExpression $rightBetweenExpression - */ public function __construct( - public $expression, - public $leftBetweenExpression, - public $rightBetweenExpression, + public ArithmeticExpression $expression, + public ArithmeticExpression $leftBetweenExpression, + public ArithmeticExpression $rightBetweenExpression, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php b/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php index b926003e21c..a62a191a712 100644 --- a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php +++ b/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php @@ -13,10 +13,9 @@ */ class CollectionMemberExpression extends Node { - /** @param PathExpression $collectionValuedPathExpression */ public function __construct( public mixed $entityExpression, - public $collectionValuedPathExpression, + public PathExpression $collectionValuedPathExpression, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php index 2c28c461b92..a7d91f94a85 100644 --- a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php @@ -18,14 +18,10 @@ */ class ComparisonExpression extends Node { - /** - * @param Node|string $leftExpression - * @param Node|string $rightExpression - */ public function __construct( - public $leftExpression, + public Node|string $leftExpression, public string $operator, - public $rightExpression, + public Node|string $rightExpression, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php b/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php index af662cc09b2..788174340ab 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php @@ -13,9 +13,8 @@ */ class ConditionalFactor extends Node implements Phase2OptimizableConditional { - /** @param ConditionalPrimary $conditionalPrimary */ public function __construct( - public $conditionalPrimary, + public ConditionalPrimary $conditionalPrimary, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php index 2a2664bd40f..9344cd9c6e9 100644 --- a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php +++ b/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php @@ -13,11 +13,9 @@ */ class ConditionalPrimary extends Node implements Phase2OptimizableConditional { - /** @var Node|null */ - public $simpleConditionalExpression; + public Node|null $simpleConditionalExpression = null; - /** @var ConditionalExpression|Phase2OptimizableConditional|null */ - public $conditionalExpression; + public ConditionalExpression|Phase2OptimizableConditional|null $conditionalExpression = null; public function isSimpleConditionalExpression(): bool { diff --git a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php b/lib/Doctrine/ORM/Query/AST/DeleteStatement.php index ff3b8869c40..f367d097c7a 100644 --- a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php +++ b/lib/Doctrine/ORM/Query/AST/DeleteStatement.php @@ -13,11 +13,9 @@ */ class DeleteStatement extends Node { - /** @var WhereClause|null */ - public $whereClause; + public WhereClause|null $whereClause = null; - /** @param DeleteClause $deleteClause */ - public function __construct(public $deleteClause) + public function __construct(public DeleteClause $deleteClause) { } diff --git a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php b/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php index 6f3b5cd050b..99788007e20 100644 --- a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php +++ b/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php @@ -13,9 +13,8 @@ */ class EmptyCollectionComparisonExpression extends Node { - /** @param PathExpression $expression */ public function __construct( - public $expression, + public PathExpression $expression, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php b/lib/Doctrine/ORM/Query/AST/ExistsExpression.php index d93f5ce52a5..72757f45263 100644 --- a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php +++ b/lib/Doctrine/ORM/Query/AST/ExistsExpression.php @@ -13,9 +13,8 @@ */ class ExistsExpression extends Node { - /** @param Subselect $subselect */ public function __construct( - public $subselect, + public Subselect $subselect, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 22f4744defa..1dd1bf5e621 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -21,8 +21,7 @@ */ class IdentityFunction extends FunctionNode { - /** @var PathExpression */ - public $pathExpression; + public PathExpression $pathExpression; public string|null $fieldMapping = null; diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php index 9ca9a0ed7ef..87ee7133b4b 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php @@ -18,8 +18,7 @@ */ class SizeFunction extends FunctionNode { - /** @var PathExpression */ - public $collectionPathExpression; + public PathExpression $collectionPathExpression; /** * @inheritdoc diff --git a/lib/Doctrine/ORM/Query/AST/HavingClause.php b/lib/Doctrine/ORM/Query/AST/HavingClause.php index 5e5de5caa2a..0d4d821f87d 100644 --- a/lib/Doctrine/ORM/Query/AST/HavingClause.php +++ b/lib/Doctrine/ORM/Query/AST/HavingClause.php @@ -8,8 +8,7 @@ class HavingClause extends Node { - /** @param ConditionalExpression|Phase2OptimizableConditional $conditionalExpression */ - public function __construct(public $conditionalExpression) + public function __construct(public ConditionalExpression|Phase2OptimizableConditional $conditionalExpression) { } diff --git a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php index 5fbc67d88ba..c4c7cca3b56 100644 --- a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php @@ -13,14 +13,10 @@ */ class IdentificationVariableDeclaration extends Node { - /** - * @param RangeVariableDeclaration|null $rangeVariableDeclaration - * @param IndexBy|null $indexBy - * @param mixed[] $joins - */ + /** @param mixed[] $joins */ public function __construct( - public $rangeVariableDeclaration = null, - public $indexBy = null, + public RangeVariableDeclaration|null $rangeVariableDeclaration = null, + public IndexBy|null $indexBy = null, public array $joins = [], ) { } diff --git a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php index ae988224f75..3a4e75f7cb8 100644 --- a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php +++ b/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php @@ -14,12 +14,9 @@ */ class InstanceOfExpression extends Node { - /** - * @param string $identificationVariable - * @param non-empty-list $value - */ + /** @param non-empty-list $value */ public function __construct( - public $identificationVariable, + public string $identificationVariable, public array $value, public bool $not = false, ) { diff --git a/lib/Doctrine/ORM/Query/AST/Join.php b/lib/Doctrine/ORM/Query/AST/Join.php index dad8b88ea5a..34ce83088de 100644 --- a/lib/Doctrine/ORM/Query/AST/Join.php +++ b/lib/Doctrine/ORM/Query/AST/Join.php @@ -18,16 +18,12 @@ class Join extends Node final public const JOIN_TYPE_LEFTOUTER = 2; final public const JOIN_TYPE_INNER = 3; - /** @var ConditionalExpression|Phase2OptimizableConditional|null */ - public $conditionalExpression = null; + public ConditionalExpression|Phase2OptimizableConditional|null $conditionalExpression = null; - /** - * @param Node $joinAssociationDeclaration - * @psalm-param self::JOIN_TYPE_* $joinType - */ + /** @psalm-param self::JOIN_TYPE_* $joinType */ public function __construct( public int $joinType, - public $joinAssociationDeclaration = null, + public Node|null $joinAssociationDeclaration = null, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php index 1ac8b863a07..e08d7f51514 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php @@ -13,14 +13,10 @@ */ class JoinAssociationDeclaration extends Node { - /** - * @param JoinAssociationPathExpression $joinAssociationPathExpression - * @param IndexBy|null $indexBy - */ public function __construct( - public $joinAssociationPathExpression, + public JoinAssociationPathExpression $joinAssociationPathExpression, public string $aliasIdentificationVariable, - public $indexBy, + public IndexBy|null $indexBy, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php index 6ac08090f3a..bf766955c5e 100644 --- a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php @@ -13,11 +13,7 @@ */ class JoinVariableDeclaration extends Node { - /** - * @param Join $join - * @param IndexBy|null $indexBy - */ - public function __construct(public $join, public $indexBy) + public function __construct(public Join $join, public IndexBy|null $indexBy) { } diff --git a/lib/Doctrine/ORM/Query/AST/LikeExpression.php b/lib/Doctrine/ORM/Query/AST/LikeExpression.php index 4206f0f1758..e3f67f8c39c 100644 --- a/lib/Doctrine/ORM/Query/AST/LikeExpression.php +++ b/lib/Doctrine/ORM/Query/AST/LikeExpression.php @@ -14,15 +14,10 @@ */ class LikeExpression extends Node { - /** - * @param Node|string $stringExpression - * @param InputParameter|FunctionNode|PathExpression|Literal $stringPattern - * @param Literal|null $escapeChar - */ public function __construct( - public $stringExpression, - public $stringPattern, - public $escapeChar = null, + public Node|string $stringExpression, + public InputParameter|FunctionNode|PathExpression|Literal $stringPattern, + public Literal|null $escapeChar = null, public bool $not = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php index 7994666f741..90331cdd35f 100644 --- a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php +++ b/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php @@ -17,8 +17,7 @@ class QuantifiedExpression extends Node { public string $type; - /** @param Subselect $subselect */ - public function __construct(public $subselect) + public function __construct(public Subselect $subselect) { } diff --git a/lib/Doctrine/ORM/Query/AST/SelectStatement.php b/lib/Doctrine/ORM/Query/AST/SelectStatement.php index 5f47ebe262c..399462f2c25 100644 --- a/lib/Doctrine/ORM/Query/AST/SelectStatement.php +++ b/lib/Doctrine/ORM/Query/AST/SelectStatement.php @@ -13,23 +13,15 @@ */ class SelectStatement extends Node { - /** @var WhereClause|null */ - public $whereClause; + public WhereClause|null $whereClause = null; - /** @var GroupByClause|null */ - public $groupByClause; + public GroupByClause|null $groupByClause = null; - /** @var HavingClause|null */ - public $havingClause; + public HavingClause|null $havingClause = null; - /** @var OrderByClause|null */ - public $orderByClause; + public OrderByClause|null $orderByClause = null; - /** - * @param SelectClause $selectClause - * @param FromClause $fromClause - */ - public function __construct(public $selectClause, public $fromClause) + public function __construct(public SelectClause $selectClause, public FromClause $fromClause) { } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php index 5fa21716de2..b3764ba1545 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php @@ -13,12 +13,9 @@ */ class SimpleCaseExpression extends Node { - /** - * @param PathExpression $caseOperand - * @param mixed[] $simpleWhenClauses - */ + /** @param mixed[] $simpleWhenClauses */ public function __construct( - public $caseOperand = null, + public PathExpression|null $caseOperand = null, public array $simpleWhenClauses = [], public mixed $elseScalarExpression = null, ) { diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php index 3631994beb6..0259e3bd162 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php @@ -13,9 +13,8 @@ */ class SimpleSelectClause extends Node { - /** @param SimpleSelectExpression $simpleSelectExpression */ public function __construct( - public $simpleSelectExpression, + public SimpleSelectExpression $simpleSelectExpression, public bool $isDistinct = false, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php index 9491612f39d..97e8f087e5c 100644 --- a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php @@ -16,8 +16,7 @@ class SimpleSelectExpression extends Node { public string|null $fieldIdentificationVariable = null; - /** @param Node|string $expression */ - public function __construct(public $expression) + public function __construct(public Node|string $expression) { } diff --git a/lib/Doctrine/ORM/Query/AST/Subselect.php b/lib/Doctrine/ORM/Query/AST/Subselect.php index 9a237004c1b..8ff85954fd7 100644 --- a/lib/Doctrine/ORM/Query/AST/Subselect.php +++ b/lib/Doctrine/ORM/Query/AST/Subselect.php @@ -13,23 +13,15 @@ */ class Subselect extends Node { - /** @var WhereClause|null */ - public $whereClause; + public WhereClause|null $whereClause = null; - /** @var GroupByClause|null */ - public $groupByClause; + public GroupByClause|null $groupByClause = null; - /** @var HavingClause|null */ - public $havingClause; + public HavingClause|null $havingClause = null; - /** @var OrderByClause|null */ - public $orderByClause; + public OrderByClause|null $orderByClause = null; - /** - * @param SimpleSelectClause $simpleSelectClause - * @param SubselectFromClause $subselectFromClause - */ - public function __construct(public $simpleSelectClause, public $subselectFromClause) + public function __construct(public SimpleSelectClause $simpleSelectClause, public SubselectFromClause $subselectFromClause) { } diff --git a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php index 051eccee889..eadf6bc41f7 100644 --- a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php +++ b/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php @@ -11,9 +11,8 @@ */ class SubselectIdentificationVariableDeclaration { - /** @param PathExpression $associationPathExpression */ public function __construct( - public $associationPathExpression, + public PathExpression $associationPathExpression, public string $aliasIdentificationVariable, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateItem.php b/lib/Doctrine/ORM/Query/AST/UpdateItem.php index 793603607f9..b540593c724 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateItem.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateItem.php @@ -15,11 +15,7 @@ */ class UpdateItem extends Node { - /** - * @param PathExpression $pathExpression - * @param InputParameter|ArithmeticExpression|null $newValue - */ - public function __construct(public $pathExpression, public $newValue) + public function __construct(public PathExpression $pathExpression, public InputParameter|ArithmeticExpression|null $newValue) { } diff --git a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php b/lib/Doctrine/ORM/Query/AST/UpdateStatement.php index 0f1645e0c4a..7ea50766b70 100644 --- a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php +++ b/lib/Doctrine/ORM/Query/AST/UpdateStatement.php @@ -13,11 +13,9 @@ */ class UpdateStatement extends Node { - /** @var WhereClause|null */ - public $whereClause; + public WhereClause|null $whereClause = null; - /** @param UpdateClause $updateClause */ - public function __construct(public $updateClause) + public function __construct(public UpdateClause $updateClause) { } diff --git a/lib/Doctrine/ORM/Query/AST/WhenClause.php b/lib/Doctrine/ORM/Query/AST/WhenClause.php index 71c7147b39e..9bf194e300d 100644 --- a/lib/Doctrine/ORM/Query/AST/WhenClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhenClause.php @@ -13,9 +13,8 @@ */ class WhenClause extends Node { - /** @param ConditionalExpression|Phase2OptimizableConditional $caseConditionExpression */ public function __construct( - public $caseConditionExpression, + public ConditionalExpression|Phase2OptimizableConditional $caseConditionExpression, public mixed $thenScalarExpression = null, ) { } diff --git a/lib/Doctrine/ORM/Query/AST/WhereClause.php b/lib/Doctrine/ORM/Query/AST/WhereClause.php index 25de9fd6594..e4d7b66cc20 100644 --- a/lib/Doctrine/ORM/Query/AST/WhereClause.php +++ b/lib/Doctrine/ORM/Query/AST/WhereClause.php @@ -13,8 +13,7 @@ */ class WhereClause extends Node { - /** @param ConditionalExpression|Phase2OptimizableConditional $conditionalExpression */ - public function __construct(public $conditionalExpression) + public function __construct(public ConditionalExpression|Phase2OptimizableConditional $conditionalExpression) { } diff --git a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php index 7252684f280..66696dbde52 100644 --- a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php @@ -19,8 +19,7 @@ */ class SingleTableDeleteUpdateExecutor extends AbstractSqlExecutor { - /** @param SqlWalker $sqlWalker */ - public function __construct(AST\Node $AST, $sqlWalker) + public function __construct(AST\Node $AST, SqlWalker $sqlWalker) { if ($AST instanceof AST\UpdateStatement) { $this->sqlStatements = $sqlWalker->walkUpdateStatement($AST); diff --git a/lib/Doctrine/ORM/Query/Expr.php b/lib/Doctrine/ORM/Query/Expr.php index beaec30fca6..0629156d837 100644 --- a/lib/Doctrine/ORM/Query/Expr.php +++ b/lib/Doctrine/ORM/Query/Expr.php @@ -480,7 +480,7 @@ public function concat(mixed ...$x): Expr\Func * @param int $from Initial offset to start cropping string. May accept negative values. * @param int|null $len Length of crop. May accept negative values. */ - public function substring(mixed $x, int $from, $len = null): Expr\Func + public function substring(mixed $x, int $from, int|null $len = null): Expr\Func { $args = [$x, $from]; if ($len !== null) { diff --git a/lib/Doctrine/ORM/Query/Expr/Base.php b/lib/Doctrine/ORM/Query/Expr/Base.php index 6fd5b82b923..a98ea3b8cb3 100644 --- a/lib/Doctrine/ORM/Query/Expr/Base.php +++ b/lib/Doctrine/ORM/Query/Expr/Base.php @@ -42,7 +42,7 @@ public function __construct(mixed $args = []) * * @return $this */ - public function addMultiple($args = []): static + public function addMultiple(array|string|object $args = []): static { foreach ((array) $args as $arg) { $this->add($arg); diff --git a/lib/Doctrine/ORM/Query/Expr/Func.php b/lib/Doctrine/ORM/Query/Expr/Func.php index 1ecb8e25fae..cd9e8e012a9 100644 --- a/lib/Doctrine/ORM/Query/Expr/Func.php +++ b/lib/Doctrine/ORM/Query/Expr/Func.php @@ -21,12 +21,11 @@ class Func implements Stringable /** * Creates a function, with the given argument. * - * @param mixed[]|mixed $arguments * @psalm-param list|mixed $arguments */ public function __construct( protected string $name, - $arguments, + mixed $arguments, ) { $this->arguments = (array) $arguments; } diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 6450badd45f..ade4bf347fe 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -1386,10 +1386,8 @@ public function OrderByItem(): AST\OrderByItem * NewValue ::= SimpleArithmeticExpression | "NULL" * * SimpleArithmeticExpression covers all *Primary grammar rules and also SimpleEntityExpression - * - * @return AST\ArithmeticExpression|AST\InputParameter|null */ - public function NewValue() + public function NewValue(): AST\ArithmeticExpression|AST\InputParameter|null { if ($this->lexer->isNextToken(TokenType::T_NULL)) { $this->match(TokenType::T_NULL); @@ -1660,10 +1658,8 @@ public function NewObjectExpression(): AST\NewObjectExpression /** * NewObjectArg ::= ScalarExpression | "(" Subselect ")" - * - * @return mixed */ - public function NewObjectArg() + public function NewObjectArg(): mixed { assert($this->lexer->lookahead !== null); $token = $this->lexer->lookahead; @@ -1703,7 +1699,7 @@ public function IndexBy(): AST\IndexBy * * @return mixed One of the possible expressions or subexpressions. */ - public function ScalarExpression() + public function ScalarExpression(): mixed { assert($this->lexer->token !== null); assert($this->lexer->lookahead !== null); @@ -1782,7 +1778,7 @@ public function ScalarExpression() * * @return mixed One of the possible expressions or subexpressions. */ - public function CaseExpression() + public function CaseExpression(): mixed { assert($this->lexer->lookahead !== null); $lookahead = $this->lexer->lookahead->type; @@ -2394,10 +2390,8 @@ public function CollectionMemberExpression(): AST\CollectionMemberExpression /** * Literal ::= string | char | integer | float | boolean - * - * @return AST\Literal */ - public function Literal() + public function Literal(): AST\Literal { assert($this->lexer->lookahead !== null); assert($this->lexer->token !== null); @@ -2638,10 +2632,8 @@ public function StringExpression(): AST\Subselect|AST\Node|string /** * StringPrimary ::= StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression | CaseExpression - * - * @return AST\Node */ - public function StringPrimary() + public function StringPrimary(): AST\Node { assert($this->lexer->lookahead !== null); $lookaheadType = $this->lexer->lookahead->type; @@ -3048,10 +3040,8 @@ public function ExistsExpression(): AST\ExistsExpression /** * ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!=" - * - * @return string */ - public function ComparisonOperator() + public function ComparisonOperator(): string { assert($this->lexer->lookahead !== null); switch ($this->lexer->lookahead->value) { @@ -3098,10 +3088,8 @@ public function ComparisonOperator() /** * FunctionDeclaration ::= FunctionsReturningStrings | FunctionsReturningNumerics | FunctionsReturningDatetime - * - * @return Functions\FunctionNode */ - public function FunctionDeclaration() + public function FunctionDeclaration(): Functions\FunctionNode { assert($this->lexer->lookahead !== null); $token = $this->lexer->lookahead; diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 849672f8ea8..351d9617ee8 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1670,7 +1670,6 @@ public function walkUpdateItem(AST\UpdateItem $updateItem): string $sql .= match (true) { $newValue instanceof AST\Node => $newValue->dispatch($this), $newValue === null => 'NULL', - default => $this->conn->quote((string) $newValue), }; $this->useSqlTableAliases = $useTableAliasesBefore; diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php index a8583c6e0c5..9d490b4cb59 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -21,8 +21,7 @@ */ class UpdateCommand extends AbstractCommand { - /** @var string */ - protected $name = 'orm:schema-tool:update'; + protected string $name = 'orm:schema-tool:update'; protected function configure(): void { diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index ed38cb8faf0..d626b7210ca 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1512,7 +1512,7 @@ static function ($value) { * * @return string The entity id hash. */ - public function getIdHashByEntity($entity): string + public function getIdHashByEntity(object $entity): string { $identifier = $this->entityIdentifiers[spl_object_id($entity)]; @@ -2875,11 +2875,9 @@ public function initializeObject(object $obj): void /** * Tests if a value is an uninitialized entity. * - * @param mixed $obj - * * @psalm-assert-if-true InternalProxy $obj */ - public function isUninitializedObject($obj): bool + public function isUninitializedObject(mixed $obj): bool { return $obj instanceof InternalProxy && ! $obj->__isInitialized(); } @@ -2924,7 +2922,7 @@ public function isReadOnly(object $object): bool */ private function afterTransactionComplete(): void { - $this->performCallbackOnCachedPersister(static function (CachedPersister $persister) { + $this->performCallbackOnCachedPersister(static function (CachedPersister $persister): void { $persister->afterTransactionComplete(); }); } @@ -2934,7 +2932,7 @@ private function afterTransactionComplete(): void */ private function afterTransactionRolledBack(): void { - $this->performCallbackOnCachedPersister(static function (CachedPersister $persister) { + $this->performCallbackOnCachedPersister(static function (CachedPersister $persister): void { $persister->afterTransactionRolledBack(); }); } @@ -3071,11 +3069,8 @@ private function normalizeIdentifier(ClassMetadata $targetClass, array $flatIden * This is used by EntityPersisters after they inserted entities into the database. * It will place the assigned ID values in the entity's fields and start tracking * the entity in the identity map. - * - * @param object $entity - * @param mixed $generatedId */ - final public function assignPostInsertId($entity, $generatedId): void + final public function assignPostInsertId(object $entity, mixed $generatedId): void { $class = $this->em->getClassMetadata(get_class($entity)); $idField = $class->getSingleIdentifierFieldName(); diff --git a/phpcs.xml.dist b/phpcs.xml.dist index a096eb099c6..2327993ddf2 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -19,9 +19,6 @@ */tests/Doctrine/Tests/ORM/Tools/Export/export/* - - - @@ -30,7 +27,6 @@ - */lib/* + - - + + diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index 891cbf15542..63e3799d4ec 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional\Locking; use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\Query; use Doctrine\ORM\TransactionRequiredException; @@ -136,9 +137,7 @@ public function testRefreshWithLockPessimisticWriteNoTransactionThrowsException( #[Group('locking')] public function testLockPessimisticWrite(): void { - $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSQL(); - - if (! $writeLockSql) { + if ($this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('Database Driver has no Write Lock support.'); } @@ -163,15 +162,13 @@ public function testLockPessimisticWrite(): void $lastLoggedQuery = $this->getLastLoggedQuery(1)['sql']; } - self::assertStringContainsString($writeLockSql, $lastLoggedQuery); + self::assertStringContainsString('FOR UPDATE', $lastLoggedQuery); } #[Group('locking')] public function testRefreshWithLockPessimisticWrite(): void { - $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSQL(); - - if (! $writeLockSql) { + if ($this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('Database Driver has no Write Lock support.'); } @@ -196,15 +193,13 @@ public function testRefreshWithLockPessimisticWrite(): void $lastLoggedQuery = $this->getLastLoggedQuery(1)['sql']; } - self::assertStringContainsString($writeLockSql, $lastLoggedQuery); + self::assertStringContainsString('FOR UPDATE', $lastLoggedQuery); } #[Group('DDC-178')] public function testLockPessimisticRead(): void { - $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSQL(); - - if (! $readLockSql) { + if ($this->_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { self::markTestSkipped('Database Driver has no Write Lock support.'); } @@ -230,7 +225,11 @@ public function testLockPessimisticRead(): void $lastLoggedQuery = $this->getLastLoggedQuery(1)['sql']; } - self::assertStringContainsString($readLockSql, $lastLoggedQuery); + self::assertThat($lastLoggedQuery, self::logicalOr( + self::stringContains('FOR UPDATE'), + self::stringContains('FOR SHARE'), + self::stringContains('LOCK IN SHARE MODE'), + )); } #[Group('DDC-1693')] From 9a281f54de2de5128d0c9a2192e8cf8a9d95133e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 19 Nov 2023 21:29:56 +0100 Subject: [PATCH 332/475] Remove wrong assertion It is useless in that particular method, and wrong. --- lib/Doctrine/ORM/PersistentCollection.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index c42807537ef..60cbacb34e2 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -137,7 +137,6 @@ private function getUnitOfWork(): UnitOfWork */ public function hydrateAdd(mixed $element): void { - assert($this->association !== null); $this->unwrap()->add($element); // If _backRefFieldName is set and its a one-to-many association, From f8ced516879a7583cb0b167bb5df0e1b04f32fa5 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 25 Nov 2023 09:16:23 +0100 Subject: [PATCH 333/475] XmlDriver: remove dead code (#11085) --- lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 9 --------- phpstan-baseline.neon | 10 ---------- 2 files changed, 19 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index bc5ebe06c8a..dafd468176a 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -255,7 +255,6 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad // The mapping assignment is done in 2 times as a bug might occurs on some php/xml lib versions // The internal SimpleXmlIterator get resetted, to this generate a duplicate field exception - $mappings = []; // Evaluate mappings if (isset($xmlRoot->field)) { foreach ($xmlRoot->field as $fieldMapping) { @@ -290,14 +289,6 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad } } - foreach ($mappings as $mapping) { - if (isset($mapping['version'])) { - $metadata->setVersionMapping($mapping); - } - - $metadata->mapField($mapping); - } - // Evaluate mappings $associationIds = []; foreach ($xmlRoot->id ?? [] as $idElement) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e5df635e545..b7d3dfbb4a9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -135,16 +135,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php - - - message: "#^Empty array passed to foreach\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php - - - - message: "#^Offset 'version' on \\*NEVER\\* in isset\\(\\) always exists and is always null\\.$#" - count: 1 - path: lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php - - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ToOneOwningSideMapping\\:\\:fromMappingArray\\(\\) should return static\\(Doctrine\\\\ORM\\\\Mapping\\\\ToOneOwningSideMapping\\) but returns Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneOwningSideMapping\\.$#" count: 1 From 64e4a2129c87261c61018a461e16de73bcbc1ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 2 Jan 2024 08:59:39 +0100 Subject: [PATCH 334/475] Remove irrelevant PHP version checks --- lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php | 4 +--- lib/Doctrine/ORM/Tools/SchemaValidator.php | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php b/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php index 4374f9679cf..7a9aadc9254 100644 --- a/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php +++ b/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php @@ -17,8 +17,6 @@ use function assert; use function enum_exists; -use const PHP_VERSION_ID; - /** @psalm-type ScalarName = 'array'|'bool'|'float'|'int'|'string' */ final class DefaultTypedFieldMapper implements TypedFieldMapper { @@ -53,7 +51,7 @@ public function validateAndComplete(array $mapping, ReflectionProperty $field): ! isset($mapping['type']) && ($type instanceof ReflectionNamedType) ) { - if (PHP_VERSION_ID >= 80100 && ! $type->isBuiltin() && enum_exists($type->getName())) { + if (! $type->isBuiltin() && enum_exists($type->getName())) { $mapping['enumType'] = $type->getName(); $reflection = new ReflectionEnum($type->getName()); diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 0e77e59fff8..71a2db44974 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -42,8 +42,6 @@ use function is_a; use function sprintf; -use const PHP_VERSION_ID; - /** * Performs strict validation of the mapping schema * @@ -120,8 +118,7 @@ public function validateClass(ClassMetadata $class): array } } - // PHP 7.4 introduces the ability to type properties, so we can't validate them in previous versions - if (PHP_VERSION_ID >= 70400 && $this->validatePropertyTypes) { + if ($this->validatePropertyTypes) { array_push($ce, ...$this->validatePropertiesTypes($class)); } From 0a3fbac8af27751e548de3788aee0f057f6dcf71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 2 Jan 2024 19:15:04 +0100 Subject: [PATCH 335/475] Flatten directory tree It will make fuzzy matchers more efficient, and configuration files more readable. --- CONTRIBUTING.md | 4 +- UPGRADE.md | 2 +- ci/github/phpunit/mysqli.xml | 2 +- ci/github/phpunit/pdo_mysql.xml | 2 +- ci/github/phpunit/pdo_pgsql.xml | 2 +- ci/github/phpunit/pdo_sqlite.xml | 2 +- ci/github/phpunit/pgsql.xml | 2 +- ci/github/phpunit/sqlite3.xml | 2 +- composer.json | 8 +- docs/en/reference/events.rst | 26 +-- phpbench.json | 4 +- phpcs.xml.dist | 192 +++++++++--------- phpstan-baseline.neon | 126 ++++++------ phpstan-dbal3.neon | 16 +- phpstan-params.neon | 6 +- phpstan.neon | 26 +-- phpunit.xml.dist | 4 +- psalm-baseline.xml | 190 ++++++++--------- psalm.xml | 82 ++++---- {lib/Doctrine/ORM => src}/AbstractQuery.php | 0 {lib/Doctrine/ORM => src}/Cache.php | 0 .../Cache/AssociationCacheEntry.php | 0 .../ORM => src}/Cache/CacheConfiguration.php | 0 .../Doctrine/ORM => src}/Cache/CacheEntry.php | 0 .../ORM => src}/Cache/CacheException.php | 0 .../ORM => src}/Cache/CacheFactory.php | 0 {lib/Doctrine/ORM => src}/Cache/CacheKey.php | 0 .../Cache/CollectionCacheEntry.php | 0 .../ORM => src}/Cache/CollectionCacheKey.php | 0 .../ORM => src}/Cache/CollectionHydrator.php | 0 .../ORM => src}/Cache/ConcurrentRegion.php | 0 .../ORM => src}/Cache/DefaultCache.php | 0 .../ORM => src}/Cache/DefaultCacheFactory.php | 0 .../Cache/DefaultCollectionHydrator.php | 0 .../Cache/DefaultEntityHydrator.php | 0 .../ORM => src}/Cache/DefaultQueryCache.php | 0 .../ORM => src}/Cache/EntityCacheEntry.php | 0 .../ORM => src}/Cache/EntityCacheKey.php | 0 .../ORM => src}/Cache/EntityHydrator.php | 0 .../Cache/Exception/CacheException.php | 0 .../CannotUpdateReadOnlyCollection.php | 0 .../Exception/CannotUpdateReadOnlyEntity.php | 0 .../Cache/Exception/FeatureNotImplemented.php | 0 .../Cache/Exception/NonCacheableEntity.php | 0 .../NonCacheableEntityAssociation.php | 0 {lib/Doctrine/ORM => src}/Cache/Lock.php | 0 .../ORM => src}/Cache/LockException.php | 0 .../ORM => src}/Cache/Logging/CacheLogger.php | 0 .../Cache/Logging/CacheLoggerChain.php | 0 .../Cache/Logging/StatisticsCacheLogger.php | 0 .../Cache/Persister/CachedPersister.php | 0 .../AbstractCollectionPersister.php | 0 .../Collection/CachedCollectionPersister.php | 0 ...rictReadWriteCachedCollectionPersister.php | 0 .../ReadOnlyCachedCollectionPersister.php | 0 .../ReadWriteCachedCollectionPersister.php | 0 .../Entity/AbstractEntityPersister.php | 0 .../Entity/CachedEntityPersister.php | 0 ...onStrictReadWriteCachedEntityPersister.php | 0 .../Entity/ReadOnlyCachedEntityPersister.php | 0 .../Entity/ReadWriteCachedEntityPersister.php | 0 .../Doctrine/ORM => src}/Cache/QueryCache.php | 0 .../ORM => src}/Cache/QueryCacheEntry.php | 0 .../ORM => src}/Cache/QueryCacheKey.php | 0 .../ORM => src}/Cache/QueryCacheValidator.php | 0 {lib/Doctrine/ORM => src}/Cache/Region.php | 0 .../Cache/Region/DefaultRegion.php | 0 .../Cache/Region/FileLockRegion.php | 0 .../Cache/Region/UpdateTimestampCache.php | 0 .../Cache/RegionsConfiguration.php | 0 .../ORM => src}/Cache/TimestampCacheEntry.php | 0 .../ORM => src}/Cache/TimestampCacheKey.php | 0 .../Cache/TimestampQueryCacheValidator.php | 0 .../ORM => src}/Cache/TimestampRegion.php | 0 {lib/Doctrine/ORM => src}/Configuration.php | 0 .../Decorator/EntityManagerDecorator.php | 0 {lib/Doctrine/ORM => src}/EntityManager.php | 0 .../ORM => src}/EntityManagerInterface.php | 0 .../ORM => src}/EntityNotFoundException.php | 0 .../Doctrine/ORM => src}/EntityRepository.php | 0 .../ORM => src}/Event/ListenersInvoker.php | 0 .../Event/LoadClassMetadataEventArgs.php | 0 .../OnClassMetadataNotFoundEventArgs.php | 0 .../ORM => src}/Event/OnClearEventArgs.php | 0 .../ORM => src}/Event/OnFlushEventArgs.php | 0 .../ORM => src}/Event/PostFlushEventArgs.php | 0 .../ORM => src}/Event/PostLoadEventArgs.php | 0 .../Event/PostPersistEventArgs.php | 0 .../ORM => src}/Event/PostRemoveEventArgs.php | 0 .../ORM => src}/Event/PostUpdateEventArgs.php | 0 .../ORM => src}/Event/PreFlushEventArgs.php | 0 .../ORM => src}/Event/PrePersistEventArgs.php | 0 .../ORM => src}/Event/PreRemoveEventArgs.php | 0 .../ORM => src}/Event/PreUpdateEventArgs.php | 0 {lib/Doctrine/ORM => src}/Events.php | 0 .../Exception/ConfigurationException.php | 0 .../EntityIdentityCollisionException.php | 0 .../Exception/EntityManagerClosed.php | 0 .../Exception/EntityMissingAssignedId.php | 0 .../Exception/InvalidEntityRepository.php | 0 .../Exception/InvalidHydrationMode.php | 0 .../Exception/ManagerException.php | 0 .../Exception/MissingIdentifierField.php | 0 .../MissingMappingDriverImplementation.php | 0 .../MultipleSelectorsFoundException.php | 0 .../ORM => src}/Exception/NotSupported.php | 0 .../ORM => src}/Exception/ORMException.php | 0 .../Exception/PersisterException.php | 0 .../Exception/RepositoryException.php | 0 .../Exception/SchemaToolException.php | 0 .../Exception/UnexpectedAssociationValue.php | 0 .../UnrecognizedIdentifierFields.php | 0 .../ORM => src}/Id/AbstractIdGenerator.php | 0 .../ORM => src}/Id/AssignedGenerator.php | 0 .../Id/BigIntegerIdentityGenerator.php | 0 .../ORM => src}/Id/IdentityGenerator.php | 0 .../ORM => src}/Id/SequenceGenerator.php | 0 .../Internal/Hydration/AbstractHydrator.php | 0 .../Internal/Hydration/ArrayHydrator.php | 0 .../Internal/Hydration/HydrationException.php | 0 .../Internal/Hydration/ObjectHydrator.php | 0 .../Hydration/ScalarColumnHydrator.php | 0 .../Internal/Hydration/ScalarHydrator.php | 0 .../Hydration/SimpleObjectHydrator.php | 0 .../Hydration/SingleScalarHydrator.php | 0 .../Internal/HydrationCompleteHandler.php | 0 .../ORM => src}/Internal/QueryType.php | 0 .../ORM => src}/Internal/SQLResultCasing.php | 0 .../ORM => src}/Internal/TopologicalSort.php | 0 .../CycleDetectedException.php | 0 .../ORM => src}/LazyCriteriaCollection.php | 0 .../ORM => src}/Mapping/AnsiQuoteStrategy.php | 0 .../Mapping/ArrayAccessImplementation.php | 0 .../Mapping/AssociationMapping.php | 0 .../Mapping/AssociationOverride.php | 0 .../Mapping/AssociationOverrides.php | 0 .../ORM => src}/Mapping/AttributeOverride.php | 0 .../Mapping/AttributeOverrides.php | 0 .../Mapping/Builder/AssociationBuilder.php | 0 .../Mapping/Builder/ClassMetadataBuilder.php | 0 .../Mapping/Builder/EmbeddedBuilder.php | 0 .../Mapping/Builder/EntityListenerBuilder.php | 0 .../Mapping/Builder/FieldBuilder.php | 0 .../Builder/ManyToManyAssociationBuilder.php | 0 .../Builder/OneToManyAssociationBuilder.php | 0 {lib/Doctrine/ORM => src}/Mapping/Cache.php | 0 .../Mapping/ChainTypedFieldMapper.php | 0 .../Mapping/ChangeTrackingPolicy.php | 0 .../ORM => src}/Mapping/ClassMetadata.php | 0 .../Mapping/ClassMetadataFactory.php | 0 {lib/Doctrine/ORM => src}/Mapping/Column.php | 0 .../ORM => src}/Mapping/CustomIdGenerator.php | 0 .../Mapping/DefaultEntityListenerResolver.php | 0 .../Mapping/DefaultNamingStrategy.php | 0 .../Mapping/DefaultQuoteStrategy.php | 0 .../Mapping/DefaultTypedFieldMapper.php | 0 .../Mapping/DiscriminatorColumn.php | 0 .../Mapping/DiscriminatorColumnMapping.php | 0 .../ORM => src}/Mapping/DiscriminatorMap.php | 0 .../Mapping/Driver/AttributeDriver.php | 0 .../Mapping/Driver/AttributeReader.php | 0 .../Mapping/Driver/DatabaseDriver.php | 0 .../Mapping/Driver/ReflectionBasedDriver.php | 0 .../Driver/RepeatableAttributeCollection.php | 0 .../Mapping/Driver/SimplifiedXmlDriver.php | 0 .../ORM => src}/Mapping/Driver/XmlDriver.php | 2 +- .../ORM => src}/Mapping/Embeddable.php | 0 .../Doctrine/ORM => src}/Mapping/Embedded.php | 0 .../Mapping/EmbeddedClassMapping.php | 0 {lib/Doctrine/ORM => src}/Mapping/Entity.php | 0 .../Mapping/EntityListenerResolver.php | 0 .../ORM => src}/Mapping/EntityListeners.php | 0 .../Exception/InvalidCustomGenerator.php | 0 .../Exception/UnknownGeneratorType.php | 0 .../ORM => src}/Mapping/FieldMapping.php | 0 .../ORM => src}/Mapping/GeneratedValue.php | 0 .../Mapping/HasLifecycleCallbacks.php | 0 {lib/Doctrine/ORM => src}/Mapping/Id.php | 0 {lib/Doctrine/ORM => src}/Mapping/Index.php | 0 .../ORM => src}/Mapping/InheritanceType.php | 0 .../ORM => src}/Mapping/InverseJoinColumn.php | 0 .../Mapping/InverseSideMapping.php | 0 .../ORM => src}/Mapping/JoinColumn.php | 0 .../ORM => src}/Mapping/JoinColumnMapping.php | 0 .../Mapping/JoinColumnProperties.php | 0 .../ORM => src}/Mapping/JoinColumns.php | 0 .../ORM => src}/Mapping/JoinTable.php | 0 .../ORM => src}/Mapping/JoinTableMapping.php | 0 .../ORM => src}/Mapping/ManyToMany.php | 0 .../Mapping/ManyToManyAssociationMapping.php | 0 .../Mapping/ManyToManyInverseSideMapping.php | 0 .../Mapping/ManyToManyOwningSideMapping.php | 0 .../ORM => src}/Mapping/ManyToOne.php | 0 .../Mapping/ManyToOneAssociationMapping.php | 0 .../ORM => src}/Mapping/MappedSuperclass.php | 0 .../ORM => src}/Mapping/MappingAttribute.php | 0 .../ORM => src}/Mapping/MappingException.php | 0 .../ORM => src}/Mapping/NamingStrategy.php | 0 .../ORM => src}/Mapping/OneToMany.php | 0 .../Mapping/OneToManyAssociationMapping.php | 0 .../Doctrine/ORM => src}/Mapping/OneToOne.php | 0 .../Mapping/OneToOneAssociationMapping.php | 0 .../Mapping/OneToOneInverseSideMapping.php | 0 .../Mapping/OneToOneOwningSideMapping.php | 0 {lib/Doctrine/ORM => src}/Mapping/OrderBy.php | 0 .../ORM => src}/Mapping/OwningSideMapping.php | 0 .../Doctrine/ORM => src}/Mapping/PostLoad.php | 0 .../ORM => src}/Mapping/PostPersist.php | 0 .../ORM => src}/Mapping/PostRemove.php | 0 .../ORM => src}/Mapping/PostUpdate.php | 0 .../Doctrine/ORM => src}/Mapping/PreFlush.php | 0 .../ORM => src}/Mapping/PrePersist.php | 0 .../ORM => src}/Mapping/PreRemove.php | 0 .../ORM => src}/Mapping/PreUpdate.php | 0 .../ORM => src}/Mapping/QuoteStrategy.php | 0 .../Mapping/ReflectionEmbeddedProperty.php | 0 .../Mapping/ReflectionEnumProperty.php | 0 .../Mapping/ReflectionReadonlyProperty.php | 0 .../ORM => src}/Mapping/SequenceGenerator.php | 0 {lib/Doctrine/ORM => src}/Mapping/Table.php | 0 .../Mapping/ToManyAssociationMapping.php | 0 ...ToManyAssociationMappingImplementation.php | 0 .../Mapping/ToManyInverseSideMapping.php | 0 .../Mapping/ToManyOwningSideMapping.php | 0 .../Mapping/ToOneAssociationMapping.php | 0 .../Mapping/ToOneInverseSideMapping.php | 0 .../Mapping/ToOneOwningSideMapping.php | 0 .../ORM => src}/Mapping/TypedFieldMapper.php | 0 .../Mapping/UnderscoreNamingStrategy.php | 0 .../ORM => src}/Mapping/UniqueConstraint.php | 0 {lib/Doctrine/ORM => src}/Mapping/Version.php | 0 {lib/Doctrine/ORM => src}/NativeQuery.php | 0 .../ORM => src}/NoResultException.php | 0 .../ORM => src}/NonUniqueResultException.php | 0 .../ORMInvalidArgumentException.php | 0 {lib/Doctrine/ORM => src}/ORMSetup.php | 0 .../ORM => src}/OptimisticLockException.php | 0 .../ORM => src}/PersistentCollection.php | 0 .../AbstractCollectionPersister.php | 0 .../Collection/CollectionPersister.php | 0 .../Collection/ManyToManyPersister.php | 0 .../Collection/OneToManyPersister.php | 0 .../AbstractEntityInheritancePersister.php | 0 .../Entity/BasicEntityPersister.php | 0 .../Entity/CachedPersisterContext.php | 0 .../Persisters/Entity/EntityPersister.php | 0 .../Entity/JoinedSubclassPersister.php | 0 .../Entity/SingleTablePersister.php | 0 .../CantUseInOperatorOnCompositeKeys.php | 0 .../Exception/InvalidOrientation.php | 0 .../Exception/UnrecognizedField.php | 0 ...MatchingAssociationFieldRequiresObject.php | 0 .../Persisters/PersisterException.php | 0 .../Persisters/SqlExpressionVisitor.php | 0 .../Persisters/SqlValueVisitor.php | 0 .../ORM => src}/PessimisticLockException.php | 0 .../Doctrine/ORM => src}/Proxy/Autoloader.php | 0 .../Proxy/DefaultProxyClassNameResolver.php | 0 .../ORM => src}/Proxy/InternalProxy.php | 0 .../ORM => src}/Proxy/NotAProxyClass.php | 0 .../ORM => src}/Proxy/ProxyFactory.php | 0 {lib/Doctrine/ORM => src}/Query.php | 0 .../ORM => src}/Query/AST/ASTException.php | 0 .../Query/AST/AggregateExpression.php | 0 .../Query/AST/ArithmeticExpression.php | 0 .../Query/AST/ArithmeticFactor.php | 0 .../ORM => src}/Query/AST/ArithmeticTerm.php | 0 .../Query/AST/BetweenExpression.php | 0 .../Query/AST/CoalesceExpression.php | 0 .../Query/AST/CollectionMemberExpression.php | 0 .../Query/AST/ComparisonExpression.php | 0 .../Query/AST/ConditionalExpression.php | 0 .../Query/AST/ConditionalFactor.php | 0 .../Query/AST/ConditionalPrimary.php | 0 .../ORM => src}/Query/AST/ConditionalTerm.php | 0 .../ORM => src}/Query/AST/DeleteClause.php | 0 .../ORM => src}/Query/AST/DeleteStatement.php | 0 .../EmptyCollectionComparisonExpression.php | 0 .../Query/AST/ExistsExpression.php | 0 .../ORM => src}/Query/AST/FromClause.php | 0 .../Query/AST/Functions/AbsFunction.php | 0 .../Query/AST/Functions/AvgFunction.php | 0 .../Query/AST/Functions/BitAndFunction.php | 0 .../Query/AST/Functions/BitOrFunction.php | 0 .../Query/AST/Functions/ConcatFunction.php | 0 .../Query/AST/Functions/CountFunction.php | 0 .../AST/Functions/CurrentDateFunction.php | 0 .../AST/Functions/CurrentTimeFunction.php | 0 .../Functions/CurrentTimestampFunction.php | 0 .../Query/AST/Functions/DateAddFunction.php | 0 .../Query/AST/Functions/DateDiffFunction.php | 0 .../Query/AST/Functions/DateSubFunction.php | 0 .../Query/AST/Functions/FunctionNode.php | 0 .../Query/AST/Functions/IdentityFunction.php | 0 .../Query/AST/Functions/LengthFunction.php | 0 .../Query/AST/Functions/LocateFunction.php | 0 .../Query/AST/Functions/LowerFunction.php | 0 .../Query/AST/Functions/MaxFunction.php | 0 .../Query/AST/Functions/MinFunction.php | 0 .../Query/AST/Functions/ModFunction.php | 0 .../Query/AST/Functions/SizeFunction.php | 0 .../Query/AST/Functions/SqrtFunction.php | 0 .../Query/AST/Functions/SubstringFunction.php | 0 .../Query/AST/Functions/SumFunction.php | 0 .../Query/AST/Functions/TrimFunction.php | 0 .../Query/AST/Functions/UpperFunction.php | 0 .../Query/AST/GeneralCaseExpression.php | 0 .../ORM => src}/Query/AST/GroupByClause.php | 0 .../ORM => src}/Query/AST/HavingClause.php | 0 .../AST/IdentificationVariableDeclaration.php | 0 .../Query/AST/InListExpression.php | 0 .../Query/AST/InSubselectExpression.php | 0 .../ORM => src}/Query/AST/IndexBy.php | 0 .../ORM => src}/Query/AST/InputParameter.php | 0 .../Query/AST/InstanceOfExpression.php | 0 {lib/Doctrine/ORM => src}/Query/AST/Join.php | 0 .../Query/AST/JoinAssociationDeclaration.php | 0 .../AST/JoinAssociationPathExpression.php | 0 .../Query/AST/JoinClassPathExpression.php | 0 .../Query/AST/JoinVariableDeclaration.php | 0 .../ORM => src}/Query/AST/LikeExpression.php | 0 .../ORM => src}/Query/AST/Literal.php | 0 .../Query/AST/NewObjectExpression.php | 0 {lib/Doctrine/ORM => src}/Query/AST/Node.php | 0 .../Query/AST/NullComparisonExpression.php | 0 .../Query/AST/NullIfExpression.php | 0 .../ORM => src}/Query/AST/OrderByClause.php | 0 .../ORM => src}/Query/AST/OrderByItem.php | 0 .../Query/AST/ParenthesisExpression.php | 0 .../ORM => src}/Query/AST/PathExpression.php | 0 .../AST/Phase2OptimizableConditional.php | 0 .../Query/AST/QuantifiedExpression.php | 0 .../Query/AST/RangeVariableDeclaration.php | 0 .../ORM => src}/Query/AST/SelectClause.php | 0 .../Query/AST/SelectExpression.php | 0 .../ORM => src}/Query/AST/SelectStatement.php | 0 .../Query/AST/SimpleArithmeticExpression.php | 0 .../Query/AST/SimpleCaseExpression.php | 0 .../Query/AST/SimpleSelectClause.php | 0 .../Query/AST/SimpleSelectExpression.php | 0 .../Query/AST/SimpleWhenClause.php | 0 .../ORM => src}/Query/AST/Subselect.php | 0 .../Query/AST/SubselectFromClause.php | 0 ...electIdentificationVariableDeclaration.php | 0 .../ORM => src}/Query/AST/TypedExpression.php | 0 .../ORM => src}/Query/AST/UpdateClause.php | 0 .../ORM => src}/Query/AST/UpdateItem.php | 0 .../ORM => src}/Query/AST/UpdateStatement.php | 0 .../ORM => src}/Query/AST/WhenClause.php | 0 .../ORM => src}/Query/AST/WhereClause.php | 0 .../Query/Exec/AbstractSqlExecutor.php | 0 .../Query/Exec/MultiTableDeleteExecutor.php | 0 .../Query/Exec/MultiTableUpdateExecutor.php | 0 .../Query/Exec/SingleSelectExecutor.php | 0 .../Exec/SingleTableDeleteUpdateExecutor.php | 0 {lib/Doctrine/ORM => src}/Query/Expr.php | 0 {lib/Doctrine/ORM => src}/Query/Expr/Andx.php | 0 {lib/Doctrine/ORM => src}/Query/Expr/Base.php | 0 .../ORM => src}/Query/Expr/Comparison.php | 0 .../ORM => src}/Query/Expr/Composite.php | 0 {lib/Doctrine/ORM => src}/Query/Expr/From.php | 0 {lib/Doctrine/ORM => src}/Query/Expr/Func.php | 0 .../ORM => src}/Query/Expr/GroupBy.php | 0 {lib/Doctrine/ORM => src}/Query/Expr/Join.php | 0 .../ORM => src}/Query/Expr/Literal.php | 0 {lib/Doctrine/ORM => src}/Query/Expr/Math.php | 0 .../ORM => src}/Query/Expr/OrderBy.php | 0 {lib/Doctrine/ORM => src}/Query/Expr/Orx.php | 0 .../ORM => src}/Query/Expr/Select.php | 0 .../Query/Filter/FilterException.php | 0 .../ORM => src}/Query/Filter/SQLFilter.php | 0 .../ORM => src}/Query/FilterCollection.php | 0 {lib/Doctrine/ORM => src}/Query/Lexer.php | 0 {lib/Doctrine/ORM => src}/Query/Parameter.php | 0 .../Query/ParameterTypeInferer.php | 0 {lib/Doctrine/ORM => src}/Query/Parser.php | 0 .../ORM => src}/Query/ParserResult.php | 0 {lib/Doctrine/ORM => src}/Query/Printer.php | 0 .../ORM => src}/Query/QueryException.php | 0 .../Query/QueryExpressionVisitor.php | 0 .../ORM => src}/Query/ResultSetMapping.php | 0 .../Query/ResultSetMappingBuilder.php | 0 {lib/Doctrine/ORM => src}/Query/SqlWalker.php | 0 {lib/Doctrine/ORM => src}/Query/TokenType.php | 0 .../Doctrine/ORM => src}/Query/TreeWalker.php | 0 .../ORM => src}/Query/TreeWalkerAdapter.php | 0 .../ORM => src}/Query/TreeWalkerChain.php | 0 {lib/Doctrine/ORM => src}/QueryBuilder.php | 0 .../Repository/DefaultRepositoryFactory.php | 0 .../Exception/InvalidFindByCall.php | 0 .../Exception/InvalidMagicMethodCall.php | 0 .../Repository/RepositoryFactory.php | 0 .../Tools/AttachEntityListenersListener.php | 0 .../Command/AbstractEntityManagerCommand.php | 0 .../ClearCache/CollectionRegionCommand.php | 0 .../ClearCache/EntityRegionCommand.php | 0 .../Command/ClearCache/MetadataCommand.php | 0 .../Command/ClearCache/QueryCommand.php | 0 .../Command/ClearCache/QueryRegionCommand.php | 0 .../Command/ClearCache/ResultCommand.php | 0 .../Command/GenerateProxiesCommand.php | 0 .../Tools/Console/Command/InfoCommand.php | 0 .../Command/MappingDescribeCommand.php | 0 .../Tools/Console/Command/RunDqlCommand.php | 0 .../Command/SchemaTool/AbstractCommand.php | 0 .../Command/SchemaTool/CreateCommand.php | 0 .../Command/SchemaTool/DropCommand.php | 0 .../Command/SchemaTool/UpdateCommand.php | 0 .../Console/Command/ValidateSchemaCommand.php | 0 .../Tools/Console/ConsoleRunner.php | 0 .../Tools/Console/EntityManagerProvider.php | 0 .../ConnectionFromManagerProvider.php | 0 .../SingleManagerProvider.php | 0 .../UnknownManagerException.php | 0 .../Tools/Console/MetadataFilter.php | 0 {lib/Doctrine/ORM => src}/Tools/Debug.php | 0 .../Tools/DebugUnitOfWorkListener.php | 0 .../Tools/Event/GenerateSchemaEventArgs.php | 0 .../Event/GenerateSchemaTableEventArgs.php | 0 .../Exception/MissingColumnException.php | 0 .../Tools/Exception/NotSupported.php | 0 .../Tools/Pagination/CountOutputWalker.php | 0 .../Tools/Pagination/CountWalker.php | 0 .../RowNumberOverFunctionNotEnabled.php | 0 .../Pagination/LimitSubqueryOutputWalker.php | 0 .../Tools/Pagination/LimitSubqueryWalker.php | 0 .../Tools/Pagination/Paginator.php | 0 .../Tools/Pagination/RootTypeWalker.php | 0 .../Pagination/RowNumberOverFunction.php | 0 .../Tools/Pagination/WhereInWalker.php | 0 .../Tools/ResolveTargetEntityListener.php | 0 .../Doctrine/ORM => src}/Tools/SchemaTool.php | 0 .../ORM => src}/Tools/SchemaValidator.php | 0 .../Doctrine/ORM => src}/Tools/ToolEvents.php | 0 .../ORM => src}/Tools/ToolsException.php | 0 .../TransactionRequiredException.php | 0 .../ORM => src}/UnexpectedResultException.php | 0 {lib/Doctrine/ORM => src}/UnitOfWork.php | 0 .../HierarchyDiscriminatorResolver.php | 0 .../Utility/IdentifierFlattener.php | 0 .../ORM => src}/Utility/LockSqlHelper.php | 0 .../ORM => src}/Utility/PersisterHelper.php | 0 tests/.gitignore | 6 +- .../Performance/ArrayResultFactory.php | 0 .../UnitOfWorkComputeChangesBench.php | 0 .../Performance/EntityManagerFactory.php | 0 ...etchJoinArrayHydrationPerformanceBench.php | 0 ...oinFullObjectHydrationPerformanceBench.php | 0 .../Hydration/SimpleHydrationBench.php | 0 .../SimpleInsertPerformanceBench.php | 0 ...pleQueryArrayHydrationPerformanceBench.php | 0 ...eryFullObjectHydrationPerformanceBench.php | 0 ...leQueryScalarHydrationPerformanceBench.php | 0 ...leInheritanceHydrationPerformanceBench.php | 0 ...TableInheritanceInsertPerformanceBench.php | 0 .../ProxyInitializationTimeBench.php | 0 .../ProxyInstantiationTimeBench.php | 0 .../Performance/Mock/NonLoadingPersister.php | 0 .../Mock/NonProxyLoadingEntityManager.php | 0 .../Mock/NonProxyLoadingUnitOfWork.php | 0 .../QueryBoundParameterProcessingBench.php | 0 .../Mapping/class-metadata-constructor.php | 0 .../Tools/Pagination/paginator-covariant.php | 0 .../StaticAnalysis/get-metadata.php | 0 .../Tests/DbalExtensions/Connection.php | 0 .../Tests/DbalExtensions/QueryLog.php | 0 .../Tests/DbalExtensions/SqlLogger.php | 0 .../Tests/DbalTypes/CustomIdObject.php | 0 .../Tests/DbalTypes/CustomIdObjectType.php | 0 .../Tests/DbalTypes/CustomIntType.php | 0 .../DbalTypes/GH8565EmployeePayloadType.php | 0 .../DbalTypes/GH8565ManagerPayloadType.php | 0 .../DbalTypes/NegativeToPositiveType.php | 0 .../Tests/DbalTypes/Rot13Type.php | 0 .../Tests/DbalTypes/UpperCaseStringType.php | 0 .../EventListener/CacheMetadataListener.php | 0 tests/{Doctrine => }/Tests/IterableTester.php | 0 .../Tests/Mocks/CacheEntryMock.php | 0 .../Tests/Mocks/CacheKeyMock.php | 0 .../Tests/Mocks/CacheRegionMock.php | 0 .../Tests/Mocks/CompatibilityType.php | 0 .../Tests/Mocks/ConcurrentRegionMock.php | 0 .../Tests/Mocks/CustomTreeWalkerJoin.php | 0 .../Tests/Mocks/EntityManagerMock.php | 0 .../Tests/Mocks/EntityPersisterMock.php | 0 .../Tests/Mocks/ExceptionConverterMock.php | 0 .../Tests/Mocks/MetadataDriverMock.php | 0 .../Tests/Mocks/NullSqlWalker.php | 0 .../Tests/Mocks/SchemaManagerMock.php | 0 .../Tests/Mocks/TimestampRegionMock.php | 0 .../Tests/Mocks/UnitOfWorkMock.php | 0 .../Tests/Models/CMS/CmsAddress.php | 0 .../Tests/Models/CMS/CmsAddressDTO.php | 0 .../Tests/Models/CMS/CmsAddressListener.php | 0 .../Tests/Models/CMS/CmsArticle.php | 0 .../Tests/Models/CMS/CmsComment.php | 0 .../Tests/Models/CMS/CmsEmail.php | 0 .../Tests/Models/CMS/CmsEmployee.php | 0 .../Tests/Models/CMS/CmsGroup.php | 0 .../Tests/Models/CMS/CmsPhonenumber.php | 0 .../Tests/Models/CMS/CmsTag.php | 0 .../Tests/Models/CMS/CmsUser.php | 0 .../Tests/Models/CMS/CmsUserDTO.php | 0 .../Tests/Models/Cache/Action.php | 0 .../Tests/Models/Cache/Address.php | 0 .../Tests/Models/Cache/Attraction.php | 0 .../Models/Cache/AttractionContactInfo.php | 0 .../Tests/Models/Cache/AttractionInfo.php | 0 .../Models/Cache/AttractionLocationInfo.php | 0 .../{Doctrine => }/Tests/Models/Cache/Bar.php | 0 .../Tests/Models/Cache/Beach.php | 0 .../Tests/Models/Cache/City.php | 0 .../Tests/Models/Cache/Client.php | 0 .../Tests/Models/Cache/ComplexAction.php | 0 .../Tests/Models/Cache/Country.php | 0 .../Tests/Models/Cache/Flight.php | 0 .../Tests/Models/Cache/Login.php | 0 .../Tests/Models/Cache/Person.php | 0 .../Tests/Models/Cache/Restaurant.php | 0 .../Tests/Models/Cache/State.php | 0 .../Tests/Models/Cache/Token.php | 0 .../Tests/Models/Cache/Travel.php | 0 .../Tests/Models/Cache/Traveler.php | 0 .../Tests/Models/Cache/TravelerProfile.php | 0 .../Models/Cache/TravelerProfileInfo.php | 0 .../Tests/Models/Company/CompanyAuction.php | 0 .../Tests/Models/Company/CompanyCar.php | 0 .../Tests/Models/Company/CompanyContract.php | 0 .../Company/CompanyContractListener.php | 0 .../Tests/Models/Company/CompanyEmployee.php | 0 .../Tests/Models/Company/CompanyEvent.php | 0 .../Models/Company/CompanyFixContract.php | 0 .../Models/Company/CompanyFlexContract.php | 0 .../Company/CompanyFlexUltraContract.php | 0 .../CompanyFlexUltraContractListener.php | 0 .../Tests/Models/Company/CompanyManager.php | 0 .../Models/Company/CompanyOrganization.php | 0 .../Tests/Models/Company/CompanyPerson.php | 0 .../Tests/Models/Company/CompanyRaffle.php | 0 .../JoinedChildClass.php | 0 .../JoinedDerivedChildClass.php | 0 .../JoinedDerivedIdentityClass.php | 0 .../JoinedDerivedRootClass.php | 0 .../JoinedRootClass.php | 0 .../SingleChildClass.php | 0 .../SingleRootClass.php | 0 .../CustomType/CustomIdObjectTypeChild.php | 0 .../CustomType/CustomIdObjectTypeParent.php | 0 .../Models/CustomType/CustomTypeChild.php | 0 .../Models/CustomType/CustomTypeParent.php | 0 .../Models/CustomType/CustomTypeUpperCase.php | 0 .../Models/DDC117/DDC117ApproveChanges.php | 0 .../Tests/Models/DDC117/DDC117Article.php | 0 .../Models/DDC117/DDC117ArticleDetails.php | 0 .../Tests/Models/DDC117/DDC117Editor.php | 0 .../Tests/Models/DDC117/DDC117Link.php | 0 .../Tests/Models/DDC117/DDC117Reference.php | 0 .../Tests/Models/DDC117/DDC117Translation.php | 0 .../DDC1476EntityWithDefaultFieldType.php | 0 .../Tests/Models/DDC1590/DDC1590Entity.php | 0 .../Tests/Models/DDC1590/DDC1590User.php | 0 .../Tests/Models/DDC1872/DDC1872Bar.php | 0 .../DDC1872ExampleEntityWithOverride.php | 0 .../DDC1872ExampleEntityWithoutOverride.php | 0 .../Models/DDC1872/DDC1872ExampleTrait.php | 0 .../Tests/Models/DDC2372/DDC2372Address.php | 0 .../Tests/Models/DDC2372/DDC2372Admin.php | 0 .../Tests/Models/DDC2372/DDC2372User.php | 0 .../Traits/DDC2372AddressAndAccessors.php | 0 .../Models/DDC2504/DDC2504ChildClass.php | 0 .../Models/DDC2504/DDC2504OtherClass.php | 0 .../Tests/Models/DDC2504/DDC2504RootClass.php | 0 .../Models/DDC2825/ExplicitSchemaAndTable.php | 0 .../DDC2825/SchemaAndTableInTableName.php | 0 .../DDC3231/DDC3231EntityRepository.php | 0 .../Tests/Models/DDC3231/DDC3231User1.php | 0 .../DDC3231/DDC3231User1NoNamespace.php | 0 .../Tests/Models/DDC3231/DDC3231User2.php | 0 .../DDC3231/DDC3231User2NoNamespace.php | 0 .../Tests/Models/DDC3293/DDC3293Address.php | 0 .../Tests/Models/DDC3293/DDC3293User.php | 0 .../Models/DDC3293/DDC3293UserPrefixed.php | 0 .../Tests/Models/DDC3346/DDC3346Article.php | 0 .../Tests/Models/DDC3346/DDC3346Author.php | 0 .../Tests/Models/DDC3579/DDC3579Admin.php | 0 .../Tests/Models/DDC3579/DDC3579Group.php | 0 .../Tests/Models/DDC3579/DDC3579User.php | 0 .../Tests/Models/DDC3597/DDC3597Image.php | 0 .../Tests/Models/DDC3597/DDC3597Media.php | 0 .../Tests/Models/DDC3597/DDC3597Root.php | 0 .../DDC3597/Embeddable/DDC3597Dimension.php | 0 .../Tests/Models/DDC3699/DDC3699Child.php | 0 .../Tests/Models/DDC3699/DDC3699Parent.php | 0 .../Models/DDC3699/DDC3699RelationMany.php | 0 .../Models/DDC3699/DDC3699RelationOne.php | 0 .../Tests/Models/DDC3711/DDC3711EntityA.php | 0 .../Tests/Models/DDC3711/DDC3711EntityB.php | 0 .../Tests/Models/DDC3899/DDC3899Contract.php | 0 .../Models/DDC3899/DDC3899FixContract.php | 0 .../Models/DDC3899/DDC3899FlexContract.php | 0 .../Tests/Models/DDC3899/DDC3899User.php | 0 .../Tests/Models/DDC4006/DDC4006User.php | 0 .../Tests/Models/DDC4006/DDC4006UserId.php | 0 .../Models/DDC5934/DDC5934BaseContract.php | 0 .../Tests/Models/DDC5934/DDC5934Contract.php | 0 .../Tests/Models/DDC5934/DDC5934Member.php | 0 .../Tests/Models/DDC6412/DDC6412File.php | 0 .../Models/DDC753/DDC753CustomRepository.php | 0 .../Models/DDC753/DDC753DefaultRepository.php | 0 .../DDC753EntityWithCustomRepository.php | 0 ...DC753EntityWithDefaultCustomRepository.php | 0 .../DDC753EntityWithInvalidRepository.php | 0 .../Models/DDC753/DDC753InvalidRepository.php | 0 .../Models/DDC869/DDC869ChequePayment.php | 0 .../Models/DDC869/DDC869CreditCardPayment.php | 0 .../Tests/Models/DDC869/DDC869Payment.php | 0 .../Models/DDC869/DDC869PaymentRepository.php | 0 .../Tests/Models/DDC889/DDC889Class.php | 0 .../Tests/Models/DDC889/DDC889Entity.php | 0 .../Tests/Models/DDC889/DDC889SuperClass.php | 0 .../Tests/Models/DDC964/DDC964Address.php | 0 .../Tests/Models/DDC964/DDC964Admin.php | 0 .../Tests/Models/DDC964/DDC964Group.php | 0 .../Tests/Models/DDC964/DDC964Guest.php | 0 .../Tests/Models/DDC964/DDC964User.php | 0 .../DtoWithArrayOfEnums.php | 0 .../DataTransferObjects/DtoWithEnum.php | 0 .../DirectoryTree/AbstractContentItem.php | 0 .../Tests/Models/DirectoryTree/Directory.php | 0 .../Tests/Models/DirectoryTree/File.php | 0 .../Tests/Models/ECommerce/ECommerceCart.php | 0 .../Models/ECommerce/ECommerceCategory.php | 0 .../Models/ECommerce/ECommerceCustomer.php | 0 .../Models/ECommerce/ECommerceFeature.php | 0 .../Models/ECommerce/ECommerceProduct.php | 0 .../Models/ECommerce/ECommerceShipping.php | 0 .../Tests/Models/Enums/AccessLevel.php | 0 .../Tests/Models/Enums/Card.php | 0 .../Tests/Models/Enums/CardWithDefault.php | 0 .../Tests/Models/Enums/CardWithNullable.php | 0 .../Tests/Models/Enums/City.php | 0 .../Tests/Models/Enums/Product.php | 0 .../Tests/Models/Enums/Quantity.php | 0 .../Tests/Models/Enums/Scale.php | 0 .../Tests/Models/Enums/Suit.php | 0 .../Tests/Models/Enums/TypedCard.php | 0 .../Models/Enums/TypedCardEnumCompositeId.php | 0 .../Tests/Models/Enums/TypedCardEnumId.php | 0 .../Tests/Models/Enums/Unit.php | 0 .../Tests/Models/Enums/UserStatus.php | 0 .../Tests/Models/Forum/ForumAvatar.php | 0 .../Tests/Models/Forum/ForumBoard.php | 0 .../Tests/Models/Forum/ForumCategory.php | 0 .../Tests/Models/Forum/ForumEntry.php | 0 .../Tests/Models/Forum/ForumUser.php | 0 .../Tests/Models/GH10132/Complex.php | 0 .../Tests/Models/GH10132/ComplexChild.php | 0 .../Tests/Models/GH10288/GH10288People.php | 0 .../Tests/Models/GH10334/GH10334Foo.php | 0 .../Models/GH10334/GH10334FooCollection.php | 0 .../Tests/Models/GH10334/GH10334Product.php | 0 .../Models/GH10334/GH10334ProductType.php | 0 .../Models/GH10334/GH10334ProductTypeId.php | 0 .../Tests/Models/GH10336/GH10336Entity.php | 0 .../Tests/Models/GH10336/GH10336Relation.php | 0 .../Tests/Models/GH7141/GH7141Article.php | 0 .../Tests/Models/GH7316/GH7316Article.php | 0 .../Tests/Models/GH7717/GH7717Child.php | 0 .../Tests/Models/GH7717/GH7717Parent.php | 0 .../Tests/Models/GH8565/GH8565Employee.php | 0 .../Tests/Models/GH8565/GH8565Manager.php | 0 .../Tests/Models/GH8565/GH8565Person.php | 0 .../Tests/Models/Generic/BooleanModel.php | 0 .../Tests/Models/Generic/DateTimeModel.php | 0 .../Tests/Models/Generic/DecimalModel.php | 0 .../Models/Generic/NonAlphaColumnsEntity.php | 0 .../Models/Generic/SerializationModel.php | 0 .../Tests/Models/GeoNames/Admin1.php | 0 .../Models/GeoNames/Admin1AlternateName.php | 0 .../Tests/Models/GeoNames/City.php | 0 .../Tests/Models/GeoNames/Country.php | 0 .../Models/Global/GlobalNamespaceModel.php | 0 .../EntityWithArrayDefaultArrayValueM2M.php | 0 .../Tests/Models/Hydration/SimpleEntity.php | 0 .../Models/Issue5989/Issue5989Employee.php | 0 .../Models/Issue5989/Issue5989Manager.php | 0 .../Models/Issue5989/Issue5989Person.php | 0 .../Tests/Models/Issue9300/Issue9300Child.php | 0 .../Models/Issue9300/Issue9300Parent.php | 0 .../AnotherChildClass.php | 0 .../JoinedInheritanceType/ChildClass.php | 0 .../JoinedInheritanceType/RootClass.php | 0 .../Tests/Models/Legacy/LegacyArticle.php | 0 .../Tests/Models/Legacy/LegacyCar.php | 0 .../Tests/Models/Legacy/LegacyUser.php | 0 .../Models/Legacy/LegacyUserReference.php | 0 .../Models/ManyToManyPersister/ChildClass.php | 0 .../ManyToManyPersister/OtherParentClass.php | 0 .../ManyToManyPersister/ParentClass.php | 0 .../CompositeToOneKeyState.php | 0 .../Models/MixedToOneIdentity/Country.php | 0 .../Tests/Models/Navigation/NavCountry.php | 0 .../Tests/Models/Navigation/NavPhotos.php | 0 .../Models/Navigation/NavPointOfInterest.php | 0 .../Tests/Models/Navigation/NavTour.php | 0 .../Tests/Models/Navigation/NavUser.php | 0 .../Models/NonPublicSchemaJoins/User.php | 0 .../Models/NullDefault/NullDefaultColumn.php | 0 .../OneToOneInverseSideLoad/InverseSide.php | 0 .../OneToOneInverseSideLoad/OwningSide.php | 0 .../OneToOneSingleTableInheritance/Cat.php | 0 .../LitterBox.php | 0 .../OneToOneSingleTableInheritance/Pet.php | 0 .../Tests/Models/Pagination/Company.php | 0 .../Tests/Models/Pagination/Department.php | 0 .../Tests/Models/Pagination/Logo.php | 0 .../Tests/Models/Pagination/User.php | 0 .../Tests/Models/Pagination/User1.php | 0 .../PersistentCollectionContent.php | 0 .../PersistentCollectionHolder.php | 0 .../PersistentObject/PersistentEntity.php | 0 .../Tests/Models/Project/Project.php | 0 .../Tests/Models/Project/ProjectId.php | 0 .../Models/Project/ProjectInvalidMapping.php | 0 .../Tests/Models/Project/ProjectName.php | 0 .../Tests/Models/Quote/Address.php | 0 .../Tests/Models/Quote/City.php | 0 .../Tests/Models/Quote/FullAddress.php | 0 .../Tests/Models/Quote/Group.php | 0 .../Tests/Models/Quote/NumericEntity.php | 0 .../Tests/Models/Quote/Phone.php | 0 .../Tests/Models/Quote/User.php | 0 .../Models/ReadonlyProperties/Author.php | 0 .../Tests/Models/ReadonlyProperties/Book.php | 0 .../Models/ReadonlyProperties/SimpleBook.php | 0 .../Models/Reflection/AbstractEmbeddable.php | 0 .../Reflection/ArrayObjectExtendingClass.php | 0 .../Reflection/ClassWithMixedProperties.php | 0 .../Models/Reflection/ConcreteEmbeddable.php | 0 .../Tests/Models/Reflection/ParentClass.php | 0 .../Tests/Models/Routing/RoutingLeg.php | 0 .../Tests/Models/Routing/RoutingLocation.php | 0 .../Tests/Models/Routing/RoutingRoute.php | 0 .../Models/Routing/RoutingRouteBooking.php | 0 .../Tests/Models/StockExchange/Bond.php | 0 .../Tests/Models/StockExchange/Market.php | 0 .../Tests/Models/StockExchange/Stock.php | 0 .../{Doctrine => }/Tests/Models/Taxi/Car.php | 0 .../Tests/Models/Taxi/Driver.php | 0 .../Tests/Models/Taxi/PaidRide.php | 0 .../{Doctrine => }/Tests/Models/Taxi/Ride.php | 0 .../Tests/Models/Tweet/Tweet.php | 0 .../Tests/Models/Tweet/User.php | 0 .../Tests/Models/Tweet/UserList.php | 0 .../Tests/Models/TypedProperties/Contact.php | 0 .../Models/TypedProperties/UserTyped.php | 0 .../UserTypedWithCustomTypedField.php | 0 .../Tests/Models/Upsertable/Insertable.php | 0 .../Tests/Models/Upsertable/Updatable.php | 0 .../ValueConversionType/AuxiliaryEntity.php | 0 .../InversedManyToManyCompositeIdEntity.php | 0 ...dManyToManyCompositeIdForeignKeyEntity.php | 0 .../InversedManyToManyEntity.php | 0 .../InversedManyToManyExtraLazyEntity.php | 0 .../InversedOneToManyCompositeIdEntity.php | 0 ...edOneToManyCompositeIdForeignKeyEntity.php | 0 .../InversedOneToManyEntity.php | 0 .../InversedOneToManyExtraLazyEntity.php | 0 .../InversedOneToOneCompositeIdEntity.php | 0 ...sedOneToOneCompositeIdForeignKeyEntity.php | 0 .../InversedOneToOneEntity.php | 0 .../OwningManyToManyCompositeIdEntity.php | 0 ...gManyToManyCompositeIdForeignKeyEntity.php | 0 .../OwningManyToManyEntity.php | 0 .../OwningManyToManyExtraLazyEntity.php | 0 .../OwningManyToOneCompositeIdEntity.php | 0 ...ngManyToOneCompositeIdForeignKeyEntity.php | 0 .../OwningManyToOneEntity.php | 0 .../OwningManyToOneExtraLazyEntity.php | 0 .../OwningManyToOneIdForeignKeyEntity.php | 0 .../OwningOneToOneCompositeIdEntity.php | 0 ...ingOneToOneCompositeIdForeignKeyEntity.php | 0 .../OwningOneToOneEntity.php | 0 .../Tests/Models/ValueObjects/Name.php | 0 .../Tests/Models/ValueObjects/Person.php | 0 .../Models/VersionedManyToOne/Article.php | 0 .../Models/VersionedManyToOne/Category.php | 0 .../VersionedOneToOne/FirstRelatedEntity.php | 0 .../VersionedOneToOne/SecondRelatedEntity.php | 0 .../Tests/ORM/AbstractQueryTest.php | 0 .../Tests/ORM/Cache/CacheConfigTest.php | 0 .../Tests/ORM/Cache/CacheKeyTest.php | 0 .../Tests/ORM/Cache/CacheLoggerChainTest.php | 0 .../ORM/Cache/DefaultCacheFactoryTest.php | 0 .../Tests/ORM/Cache/DefaultCacheTest.php | 0 .../Cache/DefaultCollectionHydratorTest.php | 0 .../ORM/Cache/DefaultEntityHydratorTest.php | 0 .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 0 .../Tests/ORM/Cache/DefaultRegionTest.php | 0 .../Tests/ORM/Cache/FileLockRegionTest.php | 0 .../CollectionPersisterTestCase.php | 0 ...ReadWriteCachedCollectionPersisterTest.php | 0 .../ReadOnlyCachedCollectionPersisterTest.php | 0 ...ReadWriteCachedCollectionPersisterTest.php | 0 .../Entity/EntityPersisterTestCase.php | 0 ...rictReadWriteCachedEntityPersisterTest.php | 0 .../ReadOnlyCachedEntityPersisterTest.php | 0 .../ReadWriteCachedEntityPersisterTest.php | 0 .../Tests/ORM/Cache/RegionTestCase.php | 0 .../ORM/Cache/StatisticsCacheLoggerTest.php | 0 .../Tests/ORM/ConfigurationTest.php | 0 .../Tests/ORM/Entity/ConstructorTest.php | 0 .../Tests/ORM/EntityManagerTest.php | 0 .../Tests/ORM/EntityNotFoundExceptionTest.php | 0 .../OnClassMetadataNotFoundEventArgsTest.php | 0 .../AbstractManyToManyAssociationTestCase.php | 0 .../Functional/AdvancedAssociationTest.php | 0 .../ORM/Functional/AdvancedDqlQueryTest.php | 0 .../ORM/Functional/BasicFunctionalTest.php | 0 .../ORM/Functional/CascadeRemoveOrderTest.php | 0 .../ClassTableInheritanceSecondTest.php | 0 .../Functional/ClassTableInheritanceTest.php | 0 .../Tests/ORM/Functional/ClearEventTest.php | 0 .../Functional/CompositePrimaryKeyTest.php | 0 ...ompositePrimaryKeyWithAssociationsTest.php | 0 .../ORM/Functional/CustomFunctionsTest.php | 0 .../ORM/Functional/CustomIdObjectTypeTest.php | 0 .../ORM/Functional/DatabaseDriverTest.php | 0 .../ORM/Functional/DatabaseDriverTestCase.php | 0 .../ORM/Functional/DefaultValuesTest.php | 0 .../ORM/Functional/DetachedEntityTest.php | 0 .../Functional/EagerFetchCollectionTest.php | 0 .../ORM/Functional/EntityListenersTest.php | 0 .../EntityRepositoryCriteriaTest.php | 0 .../ORM/Functional/EntityRepositoryTest.php | 0 .../Tests/ORM/Functional/EnumTest.php | 0 .../Functional/ExtraLazyCollectionTest.php | 0 .../Tests/ORM/Functional/FlushEventTest.php | 0 .../Tests/ORM/Functional/GH7877Test.php | 0 .../ORM/Functional/HydrationCacheTest.php | 0 .../Tests/ORM/Functional/IdentityMapTest.php | 0 .../ORM/Functional/IndexByAssociationTest.php | 0 .../Functional/InsertableUpdatableTest.php | 0 .../JoinedTableCompositeKeyTest.php | 0 .../ORM/Functional/LifecycleCallbackTest.php | 0 .../Functional/Locking/GearmanLockTest.php | 0 .../Functional/Locking/LockAgentWorker.php | 0 .../Tests/ORM/Functional/Locking/LockTest.php | 0 .../ORM/Functional/Locking/OptimisticTest.php | 0 .../ManyToManyBasicAssociationTest.php | 0 ...ManyToManyBidirectionalAssociationTest.php | 0 .../ORM/Functional/ManyToManyEventTest.php | 0 ...nyToManySelfReferentialAssociationTest.php | 0 ...anyToManyUnidirectionalAssociationTest.php | 0 .../ORM/Functional/MappedSuperclassTest.php | 0 .../Tests/ORM/Functional/NativeQueryTest.php | 0 .../Tests/ORM/Functional/NewOperatorTest.php | 0 .../OneToManyBidirectionalAssociationTest.php | 0 .../Functional/OneToManyOrphanRemovalTest.php | 0 ...neToManySelfReferentialAssociationTest.php | 0 ...OneToManyUnidirectionalAssociationTest.php | 0 .../OneToOneBidirectionalAssociationTest.php | 0 .../Functional/OneToOneEagerLoadingTest.php | 0 ...eToOneInverseSideLoadAfterDqlQueryTest.php | 0 .../Functional/OneToOneOrphanRemovalTest.php | 0 ...OneToOneSelfReferentialAssociationTest.php | 0 .../OneToOneSingleTableInheritanceTest.php | 0 .../OneToOneUnidirectionalAssociationTest.php | 0 .../ORM/Functional/OrderedCollectionTest.php | 0 ...edJoinedTableInheritanceCollectionTest.php | 0 .../Tests/ORM/Functional/PaginationTest.php | 0 .../ParserResultSerializationTest.php | 0 .../ParserResults/single_select_2_17_0.txt | Bin .../PersistentCollectionCriteriaTest.php | 0 .../Functional/PersistentCollectionTest.php | 0 .../ORM/Functional/PostFlushEventTest.php | 0 .../ORM/Functional/PostLoadEventTest.php | 0 .../Functional/ProxiesLikeEntitiesTest.php | 0 .../QueryBuilderParenthesisTest.php | 0 .../Tests/ORM/Functional/QueryCacheTest.php | 0 .../ORM/Functional/QueryDqlFunctionTest.php | 0 .../ORM/Functional/QueryIterableTest.php | 0 .../Tests/ORM/Functional/QueryTest.php | 0 .../Tests/ORM/Functional/ReadOnlyTest.php | 0 .../ORM/Functional/ReadonlyPropertiesTest.php | 0 .../ORM/Functional/ReferenceProxyTest.php | 0 .../Tests/ORM/Functional/ResultCacheTest.php | 0 .../Tests/ORM/Functional/SQLFilterTest.php | 0 .../SchemaTool/CompanySchemaTest.php | 0 .../ORM/Functional/SchemaTool/DBAL483Test.php | 0 .../ORM/Functional/SchemaTool/DDC214Test.php | 0 .../SchemaTool/MySqlSchemaToolTest.php | 0 .../SchemaTool/PostgreSqlSchemaToolTest.php | 0 .../ORM/Functional/SchemaValidatorTest.php | 0 ...econdLevelCacheCompositePrimaryKeyTest.php | 0 ...ompositePrimaryKeyWithAssociationsTest.php | 0 .../SecondLevelCacheConcurrentTest.php | 0 .../SecondLevelCacheCriteriaTest.php | 0 ...econdLevelCacheExtraLazyCollectionTest.php | 0 .../SecondLevelCacheFunctionalTestCase.php | 0 ...condLevelCacheJoinTableInheritanceTest.php | 0 .../SecondLevelCacheManyToManyTest.php | 0 .../SecondLevelCacheManyToOneTest.php | 0 .../SecondLevelCacheOneToManyTest.php | 0 .../SecondLevelCacheOneToOneTest.php | 0 .../SecondLevelCacheQueryCacheTest.php | 0 .../SecondLevelCacheRepositoryTest.php | 0 ...ndLevelCacheSingleTableInheritanceTest.php | 0 .../ORM/Functional/SecondLevelCacheTest.php | 0 .../ORM/Functional/SequenceGeneratorTest.php | 0 .../SingleTableCompositeKeyTest.php | 0 .../Functional/SingleTableInheritanceTest.php | 0 .../StandardEntityPersisterTest.php | 0 .../ORM/Functional/Ticket/DDC1040Test.php | 0 .../ORM/Functional/Ticket/DDC1041Test.php | 0 .../ORM/Functional/Ticket/DDC1043Test.php | 0 .../ORM/Functional/Ticket/DDC1080Test.php | 0 .../ORM/Functional/Ticket/DDC1113Test.php | 0 .../ORM/Functional/Ticket/DDC1129Test.php | 0 .../ORM/Functional/Ticket/DDC1163Test.php | 0 .../ORM/Functional/Ticket/DDC117Test.php | 0 .../ORM/Functional/Ticket/DDC1181Test.php | 0 .../ORM/Functional/Ticket/DDC1193Test.php | 0 .../ORM/Functional/Ticket/DDC1209Test.php | 0 .../ORM/Functional/Ticket/DDC1225Test.php | 0 .../ORM/Functional/Ticket/DDC1228Test.php | 0 .../ORM/Functional/Ticket/DDC1238Test.php | 0 .../ORM/Functional/Ticket/DDC1250Test.php | 0 .../ORM/Functional/Ticket/DDC1300Test.php | 0 .../ORM/Functional/Ticket/DDC1301Test.php | 0 .../ORM/Functional/Ticket/DDC1306Test.php | 0 .../ORM/Functional/Ticket/DDC1335Test.php | 0 .../ORM/Functional/Ticket/DDC1400Test.php | 0 .../ORM/Functional/Ticket/DDC142Test.php | 0 .../ORM/Functional/Ticket/DDC1430Test.php | 0 .../ORM/Functional/Ticket/DDC1436Test.php | 0 .../ORM/Functional/Ticket/DDC144Test.php | 0 .../ORM/Functional/Ticket/DDC1452Test.php | 0 .../ORM/Functional/Ticket/DDC1454Test.php | 0 .../ORM/Functional/Ticket/DDC1458Test.php | 0 .../ORM/Functional/Ticket/DDC1461Test.php | 0 .../ORM/Functional/Ticket/DDC1514Test.php | 0 .../ORM/Functional/Ticket/DDC1515Test.php | 0 .../ORM/Functional/Ticket/DDC1526Test.php | 0 .../ORM/Functional/Ticket/DDC1545Test.php | 0 .../ORM/Functional/Ticket/DDC1548Test.php | 0 .../ORM/Functional/Ticket/DDC1595Test.php | 0 .../ORM/Functional/Ticket/DDC163Test.php | 0 .../ORM/Functional/Ticket/DDC1643Test.php | 0 .../ORM/Functional/Ticket/DDC1654Test.php | 0 .../ORM/Functional/Ticket/DDC1655Test.php | 0 .../ORM/Functional/Ticket/DDC1666Test.php | 0 .../ORM/Functional/Ticket/DDC1685Test.php | 0 .../ORM/Functional/Ticket/DDC168Test.php | 0 .../ORM/Functional/Ticket/DDC1695Test.php | 0 .../ORM/Functional/Ticket/DDC1707Test.php | 0 .../ORM/Functional/Ticket/DDC1719Test.php | 0 .../ORM/Functional/Ticket/DDC1757Test.php | 0 .../ORM/Functional/Ticket/DDC1778Test.php | 0 .../ORM/Functional/Ticket/DDC1787Test.php | 0 .../ORM/Functional/Ticket/DDC1843Test.php | 0 .../ORM/Functional/Ticket/DDC1884Test.php | 0 .../ORM/Functional/Ticket/DDC1885Test.php | 0 .../ORM/Functional/Ticket/DDC1918Test.php | 0 .../ORM/Functional/Ticket/DDC1925Test.php | 0 .../ORM/Functional/Ticket/DDC192Test.php | 0 .../ORM/Functional/Ticket/DDC1995Test.php | 0 .../ORM/Functional/Ticket/DDC1998Test.php | 0 .../ORM/Functional/Ticket/DDC199Test.php | 0 .../ORM/Functional/Ticket/DDC2012Test.php | 0 .../ORM/Functional/Ticket/DDC2074Test.php | 0 .../ORM/Functional/Ticket/DDC2084Test.php | 0 .../ORM/Functional/Ticket/DDC2090Test.php | 0 .../ORM/Functional/Ticket/DDC2106Test.php | 0 .../ORM/Functional/Ticket/DDC211Test.php | 0 .../ORM/Functional/Ticket/DDC2138Test.php | 0 .../ORM/Functional/Ticket/DDC2175Test.php | 0 .../ORM/Functional/Ticket/DDC2182Test.php | 0 .../ORM/Functional/Ticket/DDC2214Test.php | 0 .../ORM/Functional/Ticket/DDC2224Test.php | 0 .../ORM/Functional/Ticket/DDC2252Test.php | 0 .../ORM/Functional/Ticket/DDC2306Test.php | 0 .../ORM/Functional/Ticket/DDC2346Test.php | 0 .../ORM/Functional/Ticket/DDC2350Test.php | 0 .../ORM/Functional/Ticket/DDC2359Test.php | 0 .../ORM/Functional/Ticket/DDC237Test.php | 0 .../ORM/Functional/Ticket/DDC2387Test.php | 0 .../ORM/Functional/Ticket/DDC2415Test.php | 0 .../ORM/Functional/Ticket/DDC2494Test.php | 0 .../ORM/Functional/Ticket/DDC2575Test.php | 0 .../ORM/Functional/Ticket/DDC2579Test.php | 0 .../ORM/Functional/Ticket/DDC258Test.php | 0 .../ORM/Functional/Ticket/DDC2602Test.php | 0 .../ORM/Functional/Ticket/DDC2655Test.php | 0 .../ORM/Functional/Ticket/DDC2660Test.php | 0 .../ORM/Functional/Ticket/DDC2692Test.php | 0 .../ORM/Functional/Ticket/DDC2759Test.php | 0 .../ORM/Functional/Ticket/DDC2775Test.php | 0 .../ORM/Functional/Ticket/DDC2780Test.php | 0 .../ORM/Functional/Ticket/DDC2790Test.php | 0 .../ORM/Functional/Ticket/DDC279Test.php | 0 .../ORM/Functional/Ticket/DDC2825Test.php | 0 .../ORM/Functional/Ticket/DDC2862Test.php | 0 .../ORM/Functional/Ticket/DDC2895Test.php | 0 .../ORM/Functional/Ticket/DDC2931Test.php | 0 .../ORM/Functional/Ticket/DDC2943Test.php | 0 .../ORM/Functional/Ticket/DDC2984Test.php | 0 .../ORM/Functional/Ticket/DDC2996Test.php | 0 .../ORM/Functional/Ticket/DDC3033Test.php | 0 .../ORM/Functional/Ticket/DDC3042Test.php | 0 .../ORM/Functional/Ticket/DDC3068Test.php | 0 .../ORM/Functional/Ticket/DDC309Test.php | 0 .../ORM/Functional/Ticket/DDC3103Test.php | 0 .../ORM/Functional/Ticket/DDC3123Test.php | 0 .../ORM/Functional/Ticket/DDC3160Test.php | 0 .../ORM/Functional/Ticket/DDC3170Test.php | 0 .../ORM/Functional/Ticket/DDC3192Test.php | 0 .../ORM/Functional/Ticket/DDC3223Test.php | 0 .../ORM/Functional/Ticket/DDC3300Test.php | 0 .../ORM/Functional/Ticket/DDC3303Test.php | 0 .../ORM/Functional/Ticket/DDC331Test.php | 0 .../ORM/Functional/Ticket/DDC3330Test.php | 0 .../ORM/Functional/Ticket/DDC3346Test.php | 0 .../ORM/Functional/Ticket/DDC345Test.php | 0 .../ORM/Functional/Ticket/DDC353Test.php | 0 .../ORM/Functional/Ticket/DDC3582Test.php | 0 .../ORM/Functional/Ticket/DDC3597Test.php | 0 .../ORM/Functional/Ticket/DDC3634Test.php | 0 .../ORM/Functional/Ticket/DDC3644Test.php | 0 .../ORM/Functional/Ticket/DDC3719Test.php | 0 .../ORM/Functional/Ticket/DDC371Test.php | 0 .../ORM/Functional/Ticket/DDC3785Test.php | 0 .../ORM/Functional/Ticket/DDC381Test.php | 0 .../ORM/Functional/Ticket/DDC3967Test.php | 0 .../ORM/Functional/Ticket/DDC4003Test.php | 0 .../ORM/Functional/Ticket/DDC4024Test.php | 0 .../ORM/Functional/Ticket/DDC422Test.php | 0 .../ORM/Functional/Ticket/DDC425Test.php | 0 .../ORM/Functional/Ticket/DDC440Test.php | 0 .../ORM/Functional/Ticket/DDC444Test.php | 0 .../ORM/Functional/Ticket/DDC448Test.php | 0 .../ORM/Functional/Ticket/DDC493Test.php | 0 .../ORM/Functional/Ticket/DDC512Test.php | 0 .../ORM/Functional/Ticket/DDC513Test.php | 0 .../ORM/Functional/Ticket/DDC522Test.php | 0 .../ORM/Functional/Ticket/DDC531Test.php | 0 .../ORM/Functional/Ticket/DDC5684Test.php | 0 .../ORM/Functional/Ticket/DDC588Test.php | 0 .../ORM/Functional/Ticket/DDC599Test.php | 0 .../ORM/Functional/Ticket/DDC618Test.php | 0 .../ORM/Functional/Ticket/DDC6303Test.php | 0 .../ORM/Functional/Ticket/DDC633Test.php | 0 .../ORM/Functional/Ticket/DDC6460Test.php | 0 .../ORM/Functional/Ticket/DDC6558Test.php | 0 .../ORM/Functional/Ticket/DDC656Test.php | 0 .../ORM/Functional/Ticket/DDC657Test.php | 0 .../ORM/Functional/Ticket/DDC698Test.php | 0 .../Tests/ORM/Functional/Ticket/DDC69Test.php | 0 .../ORM/Functional/Ticket/DDC719Test.php | 0 .../ORM/Functional/Ticket/DDC735Test.php | 0 .../ORM/Functional/Ticket/DDC736Test.php | 0 .../ORM/Functional/Ticket/DDC748Test.php | 0 .../ORM/Functional/Ticket/DDC767Test.php | 0 .../ORM/Functional/Ticket/DDC7969Test.php | 0 .../ORM/Functional/Ticket/DDC809Test.php | 0 .../ORM/Functional/Ticket/DDC812Test.php | 0 .../ORM/Functional/Ticket/DDC832Test.php | 0 .../ORM/Functional/Ticket/DDC837Test.php | 0 .../ORM/Functional/Ticket/DDC849Test.php | 0 .../ORM/Functional/Ticket/DDC881Test.php | 0 .../ORM/Functional/Ticket/DDC933Test.php | 0 .../ORM/Functional/Ticket/DDC949Test.php | 0 .../ORM/Functional/Ticket/DDC960Test.php | 0 .../ORM/Functional/Ticket/DDC992Test.php | 0 .../Functional/Ticket/GH10049/GH10049Test.php | 0 .../GH10049/ReadOnlyPropertyInheritor.php | 0 .../Ticket/GH10049/ReadOnlyPropertyOwner.php | 0 .../ORM/Functional/Ticket/GH10132Test.php | 0 .../ORM/Functional/Ticket/GH10288Test.php | 0 .../ORM/Functional/Ticket/GH10334Test.php | 0 .../ORM/Functional/Ticket/GH10336Test.php | 0 .../ORM/Functional/Ticket/GH10348Test.php | 0 .../ORM/Functional/Ticket/GH10387Test.php | 0 .../ORM/Functional/Ticket/GH10450Test.php | 0 .../ORM/Functional/Ticket/GH10454Test.php | 0 .../ORM/Functional/Ticket/GH10462Test.php | 0 .../ORM/Functional/Ticket/GH10473Test.php | 0 .../ORM/Functional/Ticket/GH10531Test.php | 0 .../ORM/Functional/Ticket/GH10532Test.php | 0 .../ORM/Functional/Ticket/GH10566Test.php | 0 .../ORM/Functional/Ticket/GH10625Test.php | 0 .../Functional/Ticket/GH10661/GH10661Test.php | 0 .../Ticket/GH10661/InvalidChildEntity.php | 0 .../Ticket/GH10661/InvalidEntity.php | 0 .../ORM/Functional/Ticket/GH10747Test.php | 0 .../ORM/Functional/Ticket/GH10752Test.php | 0 .../ORM/Functional/Ticket/GH10808Test.php | 0 .../ORM/Functional/Ticket/GH10869Test.php | 0 .../ORM/Functional/Ticket/GH10880Test.php | 0 .../Ticket/GH11017/GH11017Entity.php | 0 .../Functional/Ticket/GH11017/GH11017Enum.php | 0 .../Functional/Ticket/GH11017/GH11017Test.php | 0 .../Ticket/GH11037/EntityStatus.php | 0 .../Functional/Ticket/GH11037/GH11037Test.php | 0 .../Ticket/GH11037/IntEntityStatus.php | 0 .../GH11037/InvalidEntityWithTypedEnum.php | 0 .../Ticket/GH11037/StringEntityStatus.php | 0 .../GH11037/ValidEntityWithTypedEnum.php | 0 .../ORM/Functional/Ticket/GH11058Test.php | 0 .../Ticket/GH11072/GH11072EntityAdvanced.php | 0 .../Ticket/GH11072/GH11072EntityBasic.php | 0 .../Functional/Ticket/GH11072/GH11072Test.php | 0 .../ORM/Functional/Ticket/GH2947Test.php | 0 .../ORM/Functional/Ticket/GH5562Test.php | 0 .../ORM/Functional/Ticket/GH5742Test.php | 0 .../ORM/Functional/Ticket/GH5762Test.php | 0 .../ORM/Functional/Ticket/GH5804Test.php | 0 .../ORM/Functional/Ticket/GH5887Test.php | 0 .../ORM/Functional/Ticket/GH5988Test.php | 0 .../ORM/Functional/Ticket/GH5998Test.php | 0 .../ORM/Functional/Ticket/GH6029Test.php | 0 .../ORM/Functional/Ticket/GH6141Test.php | 0 .../ORM/Functional/Ticket/GH6217Test.php | 0 .../ORM/Functional/Ticket/GH6362Test.php | 0 .../ORM/Functional/Ticket/GH6394Test.php | 0 .../ORM/Functional/Ticket/GH6402Test.php | 0 .../ORM/Functional/Ticket/GH6464Test.php | 0 .../GH6499OneToManyRelationshipTest.php | 0 .../Ticket/GH6499OneToOneRelationshipTest.php | 0 .../ORM/Functional/Ticket/GH6499Test.php | 0 .../ORM/Functional/Ticket/GH6531Test.php | 0 .../ORM/Functional/Ticket/GH6682Test.php | 0 .../ORM/Functional/Ticket/GH6699Test.php | 0 .../ORM/Functional/Ticket/GH6740Test.php | 0 .../ORM/Functional/Ticket/GH6823Test.php | 0 .../ORM/Functional/Ticket/GH6937Test.php | 0 .../ORM/Functional/Ticket/GH7006Test.php | 0 .../ORM/Functional/Ticket/GH7012Test.php | 0 .../ORM/Functional/Ticket/GH7062Test.php | 0 .../ORM/Functional/Ticket/GH7067Test.php | 0 .../ORM/Functional/Ticket/GH7068Test.php | 0 .../ORM/Functional/Ticket/GH7079Test.php | 0 .../ORM/Functional/Ticket/GH7180Test.php | 0 .../ORM/Functional/Ticket/GH7259Test.php | 0 .../ORM/Functional/Ticket/GH7286Test.php | 0 .../ORM/Functional/Ticket/GH7366Test.php | 0 .../Ticket/GH7496WithToIterableTest.php | 0 .../ORM/Functional/Ticket/GH7505Test.php | 0 .../ORM/Functional/Ticket/GH7512Test.php | 0 .../ORM/Functional/Ticket/GH7629Test.php | 0 .../ORM/Functional/Ticket/GH7661Test.php | 0 .../ORM/Functional/Ticket/GH7684Test.php | 0 .../ORM/Functional/Ticket/GH7717Test.php | 0 .../ORM/Functional/Ticket/GH7735Test.php | 0 .../ORM/Functional/Ticket/GH7737Test.php | 0 .../ORM/Functional/Ticket/GH7761Test.php | 0 .../ORM/Functional/Ticket/GH7767Test.php | 0 .../ORM/Functional/Ticket/GH7820Test.php | 0 .../ORM/Functional/Ticket/GH7829Test.php | 0 .../ORM/Functional/Ticket/GH7836Test.php | 0 .../ORM/Functional/Ticket/GH7864Test.php | 0 .../ORM/Functional/Ticket/GH7869Test.php | 0 .../ORM/Functional/Ticket/GH7875Test.php | 0 .../ORM/Functional/Ticket/GH7941Test.php | 0 .../ORM/Functional/Ticket/GH8055Test.php | 0 .../ORM/Functional/Ticket/GH8061Test.php | 0 .../ORM/Functional/Ticket/GH8127Test.php | 0 .../ORM/Functional/Ticket/GH8217Test.php | 0 .../ORM/Functional/Ticket/GH8415Test.php | 0 .../Ticket/GH8415ToManyAssociationTest.php | 0 .../ORM/Functional/Ticket/GH8443Test.php | 0 .../ORM/Functional/Ticket/GH8499Test.php | 0 .../ORM/Functional/Ticket/GH8663Test.php | 0 .../ORM/Functional/Ticket/GH8914Test.php | 0 .../ORM/Functional/Ticket/GH9027Test.php | 0 .../ORM/Functional/Ticket/GH9109Test.php | 0 .../ORM/Functional/Ticket/GH9192Test.php | 0 .../ORM/Functional/Ticket/GH9230Test.php | 0 .../ORM/Functional/Ticket/GH9335Test.php | 0 .../Functional/Ticket/GH9467/GH9467Test.php | 0 .../Ticket/GH9467/JoinedInheritanceChild.php | 0 .../JoinedInheritanceNonInsertableColumn.php | 0 .../JoinedInheritanceNonUpdatableColumn.php | 0 .../JoinedInheritanceNonWritableColumn.php | 0 .../Ticket/GH9467/JoinedInheritanceRoot.php | 0 .../JoinedInheritanceWritableColumn.php | 0 .../ORM/Functional/Ticket/GH9516Test.php | 0 .../ORM/Functional/Ticket/GH9579Test.php | 0 .../ORM/Functional/Ticket/GH9807Test.php | 0 .../ORM/Functional/Ticket/Issue5989Test.php | 0 .../ORM/Functional/Ticket/Issue9300Test.php | 0 .../ORM/Functional/Ticket/Ticket2481Test.php | 0 .../Ticket4646InstanceOfAbstractTest.php | 0 .../Ticket4646InstanceOfMultiLevelTest.php | 0 .../Ticket4646InstanceOfParametricTest.php | 0 .../Ticket/Ticket4646InstanceOfTest.php | 0 ...46InstanceOfWithMultipleParametersTest.php | 0 .../Tests/ORM/Functional/TypeTest.php | 0 .../Tests/ORM/Functional/TypeValueSqlTest.php | 0 .../Functional/UnitOfWorkLifecycleTest.php | 0 .../ManyToManyCompositeIdForeignKeyTest.php | 0 .../ManyToManyCompositeIdTest.php | 0 .../ManyToManyExtraLazyTest.php | 0 .../ValueConversionType/ManyToManyTest.php | 0 .../OneToManyCompositeIdForeignKeyTest.php | 0 .../OneToManyCompositeIdTest.php | 0 .../OneToManyExtraLazyTest.php | 0 .../ValueConversionType/OneToManyTest.php | 0 .../OneToOneCompositeIdForeignKeyTest.php | 0 .../OneToOneCompositeIdTest.php | 0 .../ValueConversionType/OneToOneTest.php | 0 .../Tests/ORM/Functional/ValueObjectsTest.php | 0 .../ORM/Functional/VersionedOneToOneTest.php | 0 .../ORM/Hydration/AbstractHydratorTest.php | 0 .../Tests/ORM/Hydration/ArrayHydratorTest.php | 0 .../ORM/Hydration/CustomHydratorTest.php | 0 .../Tests/ORM/Hydration/HydrationTestCase.php | 0 .../ORM/Hydration/ObjectHydratorTest.php | 0 .../ORM/Hydration/ResultSetMappingTest.php | 0 .../Hydration/ScalarColumnHydratorTest.php | 0 .../ORM/Hydration/ScalarHydratorTest.php | 0 .../Hydration/SimpleObjectHydratorTest.php | 0 .../Hydration/SingleScalarHydratorTest.php | 0 .../Tests/ORM/Id/AssignedGeneratorTest.php | 0 .../Tests/ORM/Id/SequenceGeneratorTest.php | 0 .../Internal/HydrationCompleteHandlerTest.php | 0 .../ORM/Internal/TopologicalSortTest.php | 0 .../Tests/ORM/LazyCriteriaCollectionTest.php | 0 .../ORM/Mapping/AnsiQuoteStrategyTest.php | 0 .../ORM/Mapping/AssociationMappingTest.php | 0 .../Tests/ORM/Mapping/AttributeDriverTest.php | 0 .../Tests/ORM/Mapping/AttributeReaderTest.php | 0 .../Mapping/BasicInheritanceMappingTest.php | 0 .../ORM/Mapping/ClassMetadataBuilderTest.php | 0 .../ORM/Mapping/ClassMetadataFactoryTest.php | 0 .../Mapping/ClassMetadataLoadEventTest.php | 0 .../Tests/ORM/Mapping/ClassMetadataTest.php | 0 .../ORM/Mapping/DefaultQuoteStrategyTest.php | 0 .../DiscriminatorColumnMappingTest.php | 0 .../ORM/Mapping/EmbeddedClassMappingTest.php | 0 .../Mapping/EntityListenerResolverTest.php | 0 .../Tests/ORM/Mapping/FieldBuilderTest.php | 0 .../Tests/ORM/Mapping/FieldMappingTest.php | 0 .../AttributeEntityWithNestedJoinColumns.php | 0 .../ORM/Mapping/InverseSideMappingTest.php | 0 .../ORM/Mapping/JoinColumnMappingTest.php | 0 .../ORM/Mapping/JoinTableMappingTest.php | 0 .../ManyToManyOwningSideMappingTest.php | 0 .../ManyToOneAssociationMappingTest.php | 0 .../ORM/Mapping/MappingDriverTestCase.php | 0 .../JoinColumnClassNamingStrategy.php | 0 .../Tests/ORM/Mapping/NamingStrategyTest.php | 0 .../Mapping/OneToOneOwningSideMappingTest.php | 0 .../ORM/Mapping/OwningSideMappingTest.php | 0 .../Tests/ORM/Mapping/QuoteStrategyTest.php | 0 .../ReflectionEmbeddedPropertyTest.php | 0 .../ReflectionReadonlyPropertyTest.php | 0 .../Mapping/StaticPHPMappingDriverTest.php | 0 .../ORM/Mapping/Symfony/DriverTestCase.php | 0 .../ORM/Mapping/Symfony/XmlDriverTest.php | 0 .../Mapping/ToManyAssociationMappingTest.php | 0 .../CustomIntAsStringTypedFieldMapper.php | 0 .../ORM/Mapping/TypedFieldMapperTest.php | 0 .../ORM/Mapping/XmlMappingDriverTest.php | 0 .../php/Doctrine.Tests.Models.Enums.Card.php | 0 ...operties.UserTypedWithCustomTypedField.php | 0 ...ine.Tests.Models.Upsertable.Insertable.php | 0 ...rine.Tests.Models.Upsertable.Updatable.php | 0 ...ests.ORM.Mapping.GH10288EnumTypePerson.php | 0 .../Tests/ORM/Mapping/xml/CatNoId.dcm.xml | 0 .../Tests/ORM/Mapping/xml/DDC2429Book.orm.xml | 0 .../ORM/Mapping/xml/DDC2429Novel.orm.xml | 0 ...ctrine.Tests.Models.CMS.CmsAddress.dcm.xml | 0 .../Doctrine.Tests.Models.CMS.CmsUser.dcm.xml | 0 .../Doctrine.Tests.Models.Cache.City.dcm.xml | 0 ...sts.Models.Company.CompanyContract.dcm.xml | 0 ....Models.Company.CompanyFixContract.dcm.xml | 0 ...Models.Company.CompanyFlexContract.dcm.xml | 0 ...s.Company.CompanyFlexUltraContract.dcm.xml | 0 ...Tests.Models.Company.CompanyPerson.dcm.xml | 0 ...ts.Models.DDC117.DDC117Translation.dcm.xml | 0 ....DDC1476EntityWithDefaultFieldType.dcm.xml | 0 ...els.DDC2825.ExplicitSchemaAndTable.dcm.xml | 0 ....DDC2825.SchemaAndTableInTableName.dcm.xml | 0 ...ests.Models.DDC3293.DDC3293Address.dcm.xml | 0 ...e.Tests.Models.DDC3293.DDC3293User.dcm.xml | 0 ...Models.DDC3293.DDC3293UserPrefixed.dcm.xml | 0 ....Tests.Models.DDC3579.DDC3579Admin.dcm.xml | 0 ...e.Tests.Models.DDC3579.DDC3579User.dcm.xml | 0 ...Models.DDC5934.DDC5934BaseContract.dcm.xml | 0 ...sts.Models.DDC5934.DDC5934Contract.dcm.xml | 0 ....Models.DDC869.DDC869ChequePayment.dcm.xml | 0 ...els.DDC869.DDC869CreditCardPayment.dcm.xml | 0 ....Tests.Models.DDC869.DDC869Payment.dcm.xml | 0 ...ne.Tests.Models.DDC889.DDC889Class.dcm.xml | 0 ...e.Tests.Models.DDC889.DDC889Entity.dcm.xml | 0 ...sts.Models.DDC889.DDC889SuperClass.dcm.xml | 0 ...ne.Tests.Models.DDC964.DDC964Admin.dcm.xml | 0 ...ne.Tests.Models.DDC964.DDC964Guest.dcm.xml | 0 ...ine.Tests.Models.DDC964.DDC964User.dcm.xml | 0 .../Doctrine.Tests.Models.Enums.Card.dcm.xml | 0 ....Tests.Models.GH7141.GH7141Article.dcm.xml | 0 ....Tests.Models.GH7316.GH7316Article.dcm.xml | 0 ....Tests.Models.Generic.BooleanModel.dcm.xml | 0 ...trine.Tests.Models.Project.Project.dcm.xml | 0 ...dels.Project.ProjectInvalidMapping.dcm.xml | 0 ...s.Models.TypedProperties.UserTyped.dcm.xml | 0 ...ties.UserTypedWithCustomTypedField.dcm.xml | 0 ...Tests.Models.Upsertable.Insertable.dcm.xml | 0 ....Tests.Models.Upsertable.Updatable.dcm.xml | 0 ...ine.Tests.Models.ValueObjects.Name.dcm.xml | 0 ...e.Tests.Models.ValueObjects.Person.dcm.xml | 0 .../Doctrine.Tests.ORM.Mapping.Animal.dcm.xml | 0 .../Doctrine.Tests.ORM.Mapping.CTI.dcm.xml | 0 ...Doctrine.Tests.ORM.Mapping.Comment.dcm.xml | 0 ...ne.Tests.ORM.Mapping.DDC1170Entity.dcm.xml | 0 ...ine.Tests.ORM.Mapping.DDC807Entity.dcm.xml | 0 ....ORM.Mapping.GH10288EnumTypePerson.dcm.xml | 0 ....Mapping.ReservedWordInTableColumn.dcm.xml | 0 ...completeDiscriminatorColumnMapping.dcm.xml | 0 ...EntityNoDiscriminatorColumnMapping.dcm.xml | 0 .../Doctrine.Tests.ORM.Mapping.User.dcm.xml | 0 ...RM.Mapping.UserIncorrectAttributes.dcm.xml | 0 ...sts.ORM.Mapping.UserIncorrectIndex.dcm.xml | 0 ...ping.UserIncorrectUniqueConstraint.dcm.xml | 0 ....ORM.Mapping.UserMissingAttributes.dcm.xml | 0 .../Doctrine.Tests.ORM.Mapping.XMLSLC.dcm.xml | 0 ...ties.UserTypedWithCustomTypedField.dcm.yml | 0 ....ORM.Mapping.GH10288EnumTypePerson.dcm.yml | 0 .../ORM/ORMInvalidArgumentExceptionTest.php | 0 .../{Doctrine => }/Tests/ORM/ORMSetupTest.php | 0 .../ORM/Performance/SecondLevelCacheTest.php | 0 .../Tests/ORM/PersistentCollectionTest.php | 0 ...tyPersisterCompositeTypeParametersTest.php | 0 ...sicEntityPersisterCompositeTypeSqlTest.php | 0 .../BasicEntityPersisterTypeValueSqlTest.php | 0 .../Exception/UnrecognizedFieldTest.php | 0 .../Persisters/ManyToManyPersisterTest.php | 0 .../Tests/ORM/Proxy/ProxyFactoryTest.php | 0 .../ORM/Query/CustomTreeWalkersJoinTest.php | 0 .../Tests/ORM/Query/CustomTreeWalkersTest.php | 0 .../ORM/Query/DeleteSqlGenerationTest.php | 0 .../Tests/ORM/Query/ExprTest.php | 0 .../Tests/ORM/Query/FilterCollectionTest.php | 0 .../ORM/Query/LanguageRecognitionTest.php | 0 .../Tests/ORM/Query/LexerTest.php | 0 .../ORM/Query/ParameterTypeInfererTest.php | 0 .../Tests/ORM/Query/ParserResultTest.php | 0 .../Tests/ORM/Query/ParserTest.php | 0 .../ORM/Query/QueryExpressionVisitorTest.php | 0 .../Tests/ORM/Query/QueryTest.php | 0 .../ORM/Query/SelectSqlGenerationTest.php | 0 .../ORM/Query/SqlExpressionVisitorTest.php | 0 .../Tests/ORM/Query/SqlWalkerTest.php | 0 .../ORM/Query/UpdateSqlGenerationTest.php | 0 .../Tests/ORM/QueryBuilderTest.php | 0 .../DefaultRepositoryFactoryTest.php | 0 .../AttachEntityListenersListenerTest.php | 0 .../ClearCacheCollectionRegionCommandTest.php | 0 .../ClearCacheEntityRegionCommandTest.php | 0 .../ClearCacheQueryRegionCommandTest.php | 0 .../Tools/Console/Command/InfoCommandTest.php | 0 .../Command/MappingDescribeCommandTest.php | 0 .../Console/Command/RunDqlCommandTest.php | 0 .../Command/SchemaTool/CommandTestCase.php | 0 .../Command/SchemaTool/CreateCommandTest.php | 0 .../Command/SchemaTool/DropCommandTest.php | 0 .../Command/SchemaTool/Models/Keyboard.php | 0 .../Command/ValidateSchemaCommandTest.php | 0 .../ORM/Tools/Console/ConsoleRunnerTest.php | 0 .../ORM/Tools/Console/MetadataFilterTest.php | 0 .../Tests/ORM/Tools/DebugTest.php | 0 .../Pagination/CountOutputWalkerTest.php | 0 .../ORM/Tools/Pagination/CountWalkerTest.php | 0 .../LimitSubqueryOutputWalkerTest.php | 0 .../Pagination/LimitSubqueryWalkerTest.php | 0 .../Tools/Pagination/PaginationTestCase.php | 0 .../ORM/Tools/Pagination/PaginatorTest.php | 0 .../Tools/Pagination/RootTypeWalkerTest.php | 0 .../Tools/Pagination/WhereInWalkerTest.php | 0 .../Tools/ResolveTargetEntityListenerTest.php | 0 .../Tests/ORM/Tools/SchemaToolTest.php | 0 .../Tests/ORM/Tools/SchemaValidatorTest.php | 0 .../Tests/ORM/Tools/TestAsset/ChildClass.php | 0 .../ChildWithSameAttributesClass.php | 0 .../Tests/ORM/Tools/TestAsset/ParentClass.php | 0 .../Tests/ORM/UnitOfWorkTest.php | 0 .../HierarchyDiscriminatorResolverTest.php | 0 .../Utility/IdentifierFlattenerEnumIdTest.php | 0 .../ORM/Utility/IdentifierFlattenerTest.php | 0 .../Tests/OrmFunctionalTestCase.php | 0 tests/{Doctrine => }/Tests/OrmTestCase.php | 0 .../Tests/Proxy/AutoloaderTest.php | 0 tests/{Doctrine => }/Tests/TestInit.php | 8 +- tests/{Doctrine => }/Tests/TestUtil.php | 0 1395 files changed, 357 insertions(+), 357 deletions(-) rename {lib/Doctrine/ORM => src}/AbstractQuery.php (100%) rename {lib/Doctrine/ORM => src}/Cache.php (100%) rename {lib/Doctrine/ORM => src}/Cache/AssociationCacheEntry.php (100%) rename {lib/Doctrine/ORM => src}/Cache/CacheConfiguration.php (100%) rename {lib/Doctrine/ORM => src}/Cache/CacheEntry.php (100%) rename {lib/Doctrine/ORM => src}/Cache/CacheException.php (100%) rename {lib/Doctrine/ORM => src}/Cache/CacheFactory.php (100%) rename {lib/Doctrine/ORM => src}/Cache/CacheKey.php (100%) rename {lib/Doctrine/ORM => src}/Cache/CollectionCacheEntry.php (100%) rename {lib/Doctrine/ORM => src}/Cache/CollectionCacheKey.php (100%) rename {lib/Doctrine/ORM => src}/Cache/CollectionHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Cache/ConcurrentRegion.php (100%) rename {lib/Doctrine/ORM => src}/Cache/DefaultCache.php (100%) rename {lib/Doctrine/ORM => src}/Cache/DefaultCacheFactory.php (100%) rename {lib/Doctrine/ORM => src}/Cache/DefaultCollectionHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Cache/DefaultEntityHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Cache/DefaultQueryCache.php (100%) rename {lib/Doctrine/ORM => src}/Cache/EntityCacheEntry.php (100%) rename {lib/Doctrine/ORM => src}/Cache/EntityCacheKey.php (100%) rename {lib/Doctrine/ORM => src}/Cache/EntityHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Exception/CacheException.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Exception/CannotUpdateReadOnlyCollection.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Exception/CannotUpdateReadOnlyEntity.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Exception/FeatureNotImplemented.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Exception/NonCacheableEntity.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Exception/NonCacheableEntityAssociation.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Lock.php (100%) rename {lib/Doctrine/ORM => src}/Cache/LockException.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Logging/CacheLogger.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Logging/CacheLoggerChain.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Logging/StatisticsCacheLogger.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/CachedPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Collection/AbstractCollectionPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Collection/CachedCollectionPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Entity/AbstractEntityPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Entity/CachedEntityPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php (100%) rename {lib/Doctrine/ORM => src}/Cache/QueryCache.php (100%) rename {lib/Doctrine/ORM => src}/Cache/QueryCacheEntry.php (100%) rename {lib/Doctrine/ORM => src}/Cache/QueryCacheKey.php (100%) rename {lib/Doctrine/ORM => src}/Cache/QueryCacheValidator.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Region.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Region/DefaultRegion.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Region/FileLockRegion.php (100%) rename {lib/Doctrine/ORM => src}/Cache/Region/UpdateTimestampCache.php (100%) rename {lib/Doctrine/ORM => src}/Cache/RegionsConfiguration.php (100%) rename {lib/Doctrine/ORM => src}/Cache/TimestampCacheEntry.php (100%) rename {lib/Doctrine/ORM => src}/Cache/TimestampCacheKey.php (100%) rename {lib/Doctrine/ORM => src}/Cache/TimestampQueryCacheValidator.php (100%) rename {lib/Doctrine/ORM => src}/Cache/TimestampRegion.php (100%) rename {lib/Doctrine/ORM => src}/Configuration.php (100%) rename {lib/Doctrine/ORM => src}/Decorator/EntityManagerDecorator.php (100%) rename {lib/Doctrine/ORM => src}/EntityManager.php (100%) rename {lib/Doctrine/ORM => src}/EntityManagerInterface.php (100%) rename {lib/Doctrine/ORM => src}/EntityNotFoundException.php (100%) rename {lib/Doctrine/ORM => src}/EntityRepository.php (100%) rename {lib/Doctrine/ORM => src}/Event/ListenersInvoker.php (100%) rename {lib/Doctrine/ORM => src}/Event/LoadClassMetadataEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/OnClassMetadataNotFoundEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/OnClearEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/OnFlushEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PostFlushEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PostLoadEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PostPersistEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PostRemoveEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PostUpdateEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PreFlushEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PrePersistEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PreRemoveEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Event/PreUpdateEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Events.php (100%) rename {lib/Doctrine/ORM => src}/Exception/ConfigurationException.php (100%) rename {lib/Doctrine/ORM => src}/Exception/EntityIdentityCollisionException.php (100%) rename {lib/Doctrine/ORM => src}/Exception/EntityManagerClosed.php (100%) rename {lib/Doctrine/ORM => src}/Exception/EntityMissingAssignedId.php (100%) rename {lib/Doctrine/ORM => src}/Exception/InvalidEntityRepository.php (100%) rename {lib/Doctrine/ORM => src}/Exception/InvalidHydrationMode.php (100%) rename {lib/Doctrine/ORM => src}/Exception/ManagerException.php (100%) rename {lib/Doctrine/ORM => src}/Exception/MissingIdentifierField.php (100%) rename {lib/Doctrine/ORM => src}/Exception/MissingMappingDriverImplementation.php (100%) rename {lib/Doctrine/ORM => src}/Exception/MultipleSelectorsFoundException.php (100%) rename {lib/Doctrine/ORM => src}/Exception/NotSupported.php (100%) rename {lib/Doctrine/ORM => src}/Exception/ORMException.php (100%) rename {lib/Doctrine/ORM => src}/Exception/PersisterException.php (100%) rename {lib/Doctrine/ORM => src}/Exception/RepositoryException.php (100%) rename {lib/Doctrine/ORM => src}/Exception/SchemaToolException.php (100%) rename {lib/Doctrine/ORM => src}/Exception/UnexpectedAssociationValue.php (100%) rename {lib/Doctrine/ORM => src}/Exception/UnrecognizedIdentifierFields.php (100%) rename {lib/Doctrine/ORM => src}/Id/AbstractIdGenerator.php (100%) rename {lib/Doctrine/ORM => src}/Id/AssignedGenerator.php (100%) rename {lib/Doctrine/ORM => src}/Id/BigIntegerIdentityGenerator.php (100%) rename {lib/Doctrine/ORM => src}/Id/IdentityGenerator.php (100%) rename {lib/Doctrine/ORM => src}/Id/SequenceGenerator.php (100%) rename {lib/Doctrine/ORM => src}/Internal/Hydration/AbstractHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Internal/Hydration/ArrayHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Internal/Hydration/HydrationException.php (100%) rename {lib/Doctrine/ORM => src}/Internal/Hydration/ObjectHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Internal/Hydration/ScalarColumnHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Internal/Hydration/ScalarHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Internal/Hydration/SimpleObjectHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Internal/Hydration/SingleScalarHydrator.php (100%) rename {lib/Doctrine/ORM => src}/Internal/HydrationCompleteHandler.php (100%) rename {lib/Doctrine/ORM => src}/Internal/QueryType.php (100%) rename {lib/Doctrine/ORM => src}/Internal/SQLResultCasing.php (100%) rename {lib/Doctrine/ORM => src}/Internal/TopologicalSort.php (100%) rename {lib/Doctrine/ORM => src}/Internal/TopologicalSort/CycleDetectedException.php (100%) rename {lib/Doctrine/ORM => src}/LazyCriteriaCollection.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/AnsiQuoteStrategy.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ArrayAccessImplementation.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/AssociationMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/AssociationOverride.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/AssociationOverrides.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/AttributeOverride.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/AttributeOverrides.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Builder/AssociationBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Builder/ClassMetadataBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Builder/EmbeddedBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Builder/EntityListenerBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Builder/FieldBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Builder/ManyToManyAssociationBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Builder/OneToManyAssociationBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Cache.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ChainTypedFieldMapper.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ChangeTrackingPolicy.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ClassMetadata.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ClassMetadataFactory.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Column.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/CustomIdGenerator.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/DefaultEntityListenerResolver.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/DefaultNamingStrategy.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/DefaultQuoteStrategy.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/DefaultTypedFieldMapper.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/DiscriminatorColumn.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/DiscriminatorColumnMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/DiscriminatorMap.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Driver/AttributeDriver.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Driver/AttributeReader.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Driver/DatabaseDriver.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Driver/ReflectionBasedDriver.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Driver/RepeatableAttributeCollection.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Driver/SimplifiedXmlDriver.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Driver/XmlDriver.php (99%) rename {lib/Doctrine/ORM => src}/Mapping/Embeddable.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Embedded.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/EmbeddedClassMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Entity.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/EntityListenerResolver.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/EntityListeners.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Exception/InvalidCustomGenerator.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Exception/UnknownGeneratorType.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/FieldMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/GeneratedValue.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/HasLifecycleCallbacks.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Id.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Index.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/InheritanceType.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/InverseJoinColumn.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/InverseSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/JoinColumn.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/JoinColumnMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/JoinColumnProperties.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/JoinColumns.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/JoinTable.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/JoinTableMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ManyToMany.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ManyToManyAssociationMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ManyToManyInverseSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ManyToManyOwningSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ManyToOne.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ManyToOneAssociationMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/MappedSuperclass.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/MappingAttribute.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/MappingException.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/NamingStrategy.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/OneToMany.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/OneToManyAssociationMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/OneToOne.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/OneToOneAssociationMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/OneToOneInverseSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/OneToOneOwningSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/OrderBy.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/OwningSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/PostLoad.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/PostPersist.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/PostRemove.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/PostUpdate.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/PreFlush.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/PrePersist.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/PreRemove.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/PreUpdate.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/QuoteStrategy.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ReflectionEmbeddedProperty.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ReflectionEnumProperty.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ReflectionReadonlyProperty.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/SequenceGenerator.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Table.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ToManyAssociationMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ToManyAssociationMappingImplementation.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ToManyInverseSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ToManyOwningSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ToOneAssociationMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ToOneInverseSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/ToOneOwningSideMapping.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/TypedFieldMapper.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/UnderscoreNamingStrategy.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/UniqueConstraint.php (100%) rename {lib/Doctrine/ORM => src}/Mapping/Version.php (100%) rename {lib/Doctrine/ORM => src}/NativeQuery.php (100%) rename {lib/Doctrine/ORM => src}/NoResultException.php (100%) rename {lib/Doctrine/ORM => src}/NonUniqueResultException.php (100%) rename {lib/Doctrine/ORM => src}/ORMInvalidArgumentException.php (100%) rename {lib/Doctrine/ORM => src}/ORMSetup.php (100%) rename {lib/Doctrine/ORM => src}/OptimisticLockException.php (100%) rename {lib/Doctrine/ORM => src}/PersistentCollection.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Collection/AbstractCollectionPersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Collection/CollectionPersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Collection/ManyToManyPersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Collection/OneToManyPersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Entity/AbstractEntityInheritancePersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Entity/BasicEntityPersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Entity/CachedPersisterContext.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Entity/EntityPersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Entity/JoinedSubclassPersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Entity/SingleTablePersister.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Exception/CantUseInOperatorOnCompositeKeys.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Exception/InvalidOrientation.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/Exception/UnrecognizedField.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/MatchingAssociationFieldRequiresObject.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/PersisterException.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/SqlExpressionVisitor.php (100%) rename {lib/Doctrine/ORM => src}/Persisters/SqlValueVisitor.php (100%) rename {lib/Doctrine/ORM => src}/PessimisticLockException.php (100%) rename {lib/Doctrine/ORM => src}/Proxy/Autoloader.php (100%) rename {lib/Doctrine/ORM => src}/Proxy/DefaultProxyClassNameResolver.php (100%) rename {lib/Doctrine/ORM => src}/Proxy/InternalProxy.php (100%) rename {lib/Doctrine/ORM => src}/Proxy/NotAProxyClass.php (100%) rename {lib/Doctrine/ORM => src}/Proxy/ProxyFactory.php (100%) rename {lib/Doctrine/ORM => src}/Query.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ASTException.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/AggregateExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ArithmeticExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ArithmeticFactor.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ArithmeticTerm.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/BetweenExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/CoalesceExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/CollectionMemberExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ComparisonExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ConditionalExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ConditionalFactor.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ConditionalPrimary.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ConditionalTerm.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/DeleteClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/DeleteStatement.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/EmptyCollectionComparisonExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ExistsExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/FromClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/AbsFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/AvgFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/BitAndFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/BitOrFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/ConcatFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/CountFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/CurrentDateFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/CurrentTimeFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/CurrentTimestampFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/DateAddFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/DateDiffFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/DateSubFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/FunctionNode.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/IdentityFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/LengthFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/LocateFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/LowerFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/MaxFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/MinFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/ModFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/SizeFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/SqrtFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/SubstringFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/SumFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/TrimFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Functions/UpperFunction.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/GeneralCaseExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/GroupByClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/HavingClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/IdentificationVariableDeclaration.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/InListExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/InSubselectExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/IndexBy.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/InputParameter.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/InstanceOfExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Join.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/JoinAssociationDeclaration.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/JoinAssociationPathExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/JoinClassPathExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/JoinVariableDeclaration.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/LikeExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Literal.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/NewObjectExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Node.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/NullComparisonExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/NullIfExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/OrderByClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/OrderByItem.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/ParenthesisExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/PathExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Phase2OptimizableConditional.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/QuantifiedExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/RangeVariableDeclaration.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SelectClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SelectExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SelectStatement.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SimpleArithmeticExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SimpleCaseExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SimpleSelectClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SimpleSelectExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SimpleWhenClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/Subselect.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SubselectFromClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/SubselectIdentificationVariableDeclaration.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/TypedExpression.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/UpdateClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/UpdateItem.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/UpdateStatement.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/WhenClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/AST/WhereClause.php (100%) rename {lib/Doctrine/ORM => src}/Query/Exec/AbstractSqlExecutor.php (100%) rename {lib/Doctrine/ORM => src}/Query/Exec/MultiTableDeleteExecutor.php (100%) rename {lib/Doctrine/ORM => src}/Query/Exec/MultiTableUpdateExecutor.php (100%) rename {lib/Doctrine/ORM => src}/Query/Exec/SingleSelectExecutor.php (100%) rename {lib/Doctrine/ORM => src}/Query/Exec/SingleTableDeleteUpdateExecutor.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Andx.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Base.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Comparison.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Composite.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/From.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Func.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/GroupBy.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Join.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Literal.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Math.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/OrderBy.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Orx.php (100%) rename {lib/Doctrine/ORM => src}/Query/Expr/Select.php (100%) rename {lib/Doctrine/ORM => src}/Query/Filter/FilterException.php (100%) rename {lib/Doctrine/ORM => src}/Query/Filter/SQLFilter.php (100%) rename {lib/Doctrine/ORM => src}/Query/FilterCollection.php (100%) rename {lib/Doctrine/ORM => src}/Query/Lexer.php (100%) rename {lib/Doctrine/ORM => src}/Query/Parameter.php (100%) rename {lib/Doctrine/ORM => src}/Query/ParameterTypeInferer.php (100%) rename {lib/Doctrine/ORM => src}/Query/Parser.php (100%) rename {lib/Doctrine/ORM => src}/Query/ParserResult.php (100%) rename {lib/Doctrine/ORM => src}/Query/Printer.php (100%) rename {lib/Doctrine/ORM => src}/Query/QueryException.php (100%) rename {lib/Doctrine/ORM => src}/Query/QueryExpressionVisitor.php (100%) rename {lib/Doctrine/ORM => src}/Query/ResultSetMapping.php (100%) rename {lib/Doctrine/ORM => src}/Query/ResultSetMappingBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Query/SqlWalker.php (100%) rename {lib/Doctrine/ORM => src}/Query/TokenType.php (100%) rename {lib/Doctrine/ORM => src}/Query/TreeWalker.php (100%) rename {lib/Doctrine/ORM => src}/Query/TreeWalkerAdapter.php (100%) rename {lib/Doctrine/ORM => src}/Query/TreeWalkerChain.php (100%) rename {lib/Doctrine/ORM => src}/QueryBuilder.php (100%) rename {lib/Doctrine/ORM => src}/Repository/DefaultRepositoryFactory.php (100%) rename {lib/Doctrine/ORM => src}/Repository/Exception/InvalidFindByCall.php (100%) rename {lib/Doctrine/ORM => src}/Repository/Exception/InvalidMagicMethodCall.php (100%) rename {lib/Doctrine/ORM => src}/Repository/RepositoryFactory.php (100%) rename {lib/Doctrine/ORM => src}/Tools/AttachEntityListenersListener.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/AbstractEntityManagerCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/ClearCache/CollectionRegionCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/ClearCache/EntityRegionCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/ClearCache/MetadataCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/ClearCache/QueryCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/ClearCache/QueryRegionCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/ClearCache/ResultCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/GenerateProxiesCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/InfoCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/MappingDescribeCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/RunDqlCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/SchemaTool/AbstractCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/SchemaTool/CreateCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/SchemaTool/DropCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/SchemaTool/UpdateCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/Command/ValidateSchemaCommand.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/ConsoleRunner.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/EntityManagerProvider.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/EntityManagerProvider/SingleManagerProvider.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/EntityManagerProvider/UnknownManagerException.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Console/MetadataFilter.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Debug.php (100%) rename {lib/Doctrine/ORM => src}/Tools/DebugUnitOfWorkListener.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Event/GenerateSchemaEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Event/GenerateSchemaTableEventArgs.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Exception/MissingColumnException.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Exception/NotSupported.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/CountOutputWalker.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/CountWalker.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/Exception/RowNumberOverFunctionNotEnabled.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/LimitSubqueryOutputWalker.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/LimitSubqueryWalker.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/Paginator.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/RootTypeWalker.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/RowNumberOverFunction.php (100%) rename {lib/Doctrine/ORM => src}/Tools/Pagination/WhereInWalker.php (100%) rename {lib/Doctrine/ORM => src}/Tools/ResolveTargetEntityListener.php (100%) rename {lib/Doctrine/ORM => src}/Tools/SchemaTool.php (100%) rename {lib/Doctrine/ORM => src}/Tools/SchemaValidator.php (100%) rename {lib/Doctrine/ORM => src}/Tools/ToolEvents.php (100%) rename {lib/Doctrine/ORM => src}/Tools/ToolsException.php (100%) rename {lib/Doctrine/ORM => src}/TransactionRequiredException.php (100%) rename {lib/Doctrine/ORM => src}/UnexpectedResultException.php (100%) rename {lib/Doctrine/ORM => src}/UnitOfWork.php (100%) rename {lib/Doctrine/ORM => src}/Utility/HierarchyDiscriminatorResolver.php (100%) rename {lib/Doctrine/ORM => src}/Utility/IdentifierFlattener.php (100%) rename {lib/Doctrine/ORM => src}/Utility/LockSqlHelper.php (100%) rename {lib/Doctrine/ORM => src}/Utility/PersisterHelper.php (100%) rename tests/{Doctrine => }/Performance/ArrayResultFactory.php (100%) rename tests/{Doctrine => }/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php (100%) rename tests/{Doctrine => }/Performance/EntityManagerFactory.php (100%) rename tests/{Doctrine => }/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php (100%) rename tests/{Doctrine => }/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php (100%) rename tests/{Doctrine => }/Performance/Hydration/SimpleHydrationBench.php (100%) rename tests/{Doctrine => }/Performance/Hydration/SimpleInsertPerformanceBench.php (100%) rename tests/{Doctrine => }/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php (100%) rename tests/{Doctrine => }/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php (100%) rename tests/{Doctrine => }/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php (100%) rename tests/{Doctrine => }/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php (100%) rename tests/{Doctrine => }/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php (100%) rename tests/{Doctrine => }/Performance/LazyLoading/ProxyInitializationTimeBench.php (100%) rename tests/{Doctrine => }/Performance/LazyLoading/ProxyInstantiationTimeBench.php (100%) rename tests/{Doctrine => }/Performance/Mock/NonLoadingPersister.php (100%) rename tests/{Doctrine => }/Performance/Mock/NonProxyLoadingEntityManager.php (100%) rename tests/{Doctrine => }/Performance/Mock/NonProxyLoadingUnitOfWork.php (100%) rename tests/{Doctrine => }/Performance/Query/QueryBoundParameterProcessingBench.php (100%) rename tests/{Doctrine => }/StaticAnalysis/Mapping/class-metadata-constructor.php (100%) rename tests/{Doctrine => }/StaticAnalysis/Tools/Pagination/paginator-covariant.php (100%) rename tests/{Doctrine => }/StaticAnalysis/get-metadata.php (100%) rename tests/{Doctrine => }/Tests/DbalExtensions/Connection.php (100%) rename tests/{Doctrine => }/Tests/DbalExtensions/QueryLog.php (100%) rename tests/{Doctrine => }/Tests/DbalExtensions/SqlLogger.php (100%) rename tests/{Doctrine => }/Tests/DbalTypes/CustomIdObject.php (100%) rename tests/{Doctrine => }/Tests/DbalTypes/CustomIdObjectType.php (100%) rename tests/{Doctrine => }/Tests/DbalTypes/CustomIntType.php (100%) rename tests/{Doctrine => }/Tests/DbalTypes/GH8565EmployeePayloadType.php (100%) rename tests/{Doctrine => }/Tests/DbalTypes/GH8565ManagerPayloadType.php (100%) rename tests/{Doctrine => }/Tests/DbalTypes/NegativeToPositiveType.php (100%) rename tests/{Doctrine => }/Tests/DbalTypes/Rot13Type.php (100%) rename tests/{Doctrine => }/Tests/DbalTypes/UpperCaseStringType.php (100%) rename tests/{Doctrine => }/Tests/EventListener/CacheMetadataListener.php (100%) rename tests/{Doctrine => }/Tests/IterableTester.php (100%) rename tests/{Doctrine => }/Tests/Mocks/CacheEntryMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/CacheKeyMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/CacheRegionMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/CompatibilityType.php (100%) rename tests/{Doctrine => }/Tests/Mocks/ConcurrentRegionMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/CustomTreeWalkerJoin.php (100%) rename tests/{Doctrine => }/Tests/Mocks/EntityManagerMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/EntityPersisterMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/ExceptionConverterMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/MetadataDriverMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/NullSqlWalker.php (100%) rename tests/{Doctrine => }/Tests/Mocks/SchemaManagerMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/TimestampRegionMock.php (100%) rename tests/{Doctrine => }/Tests/Mocks/UnitOfWorkMock.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsAddress.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsAddressDTO.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsAddressListener.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsArticle.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsComment.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsEmail.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsEmployee.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsGroup.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsPhonenumber.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsTag.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsUser.php (100%) rename tests/{Doctrine => }/Tests/Models/CMS/CmsUserDTO.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Action.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Address.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Attraction.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/AttractionContactInfo.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/AttractionInfo.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/AttractionLocationInfo.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Bar.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Beach.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/City.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Client.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/ComplexAction.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Country.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Flight.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Login.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Person.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Restaurant.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/State.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Token.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Travel.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/Traveler.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/TravelerProfile.php (100%) rename tests/{Doctrine => }/Tests/Models/Cache/TravelerProfileInfo.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyAuction.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyCar.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyContract.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyContractListener.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyEmployee.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyEvent.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyFixContract.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyFlexContract.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyFlexUltraContract.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyFlexUltraContractListener.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyManager.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyOrganization.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyPerson.php (100%) rename tests/{Doctrine => }/Tests/Models/Company/CompanyRaffle.php (100%) rename tests/{Doctrine => }/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php (100%) rename tests/{Doctrine => }/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php (100%) rename tests/{Doctrine => }/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php (100%) rename tests/{Doctrine => }/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php (100%) rename tests/{Doctrine => }/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php (100%) rename tests/{Doctrine => }/Tests/Models/CompositeKeyInheritance/SingleChildClass.php (100%) rename tests/{Doctrine => }/Tests/Models/CompositeKeyInheritance/SingleRootClass.php (100%) rename tests/{Doctrine => }/Tests/Models/CustomType/CustomIdObjectTypeChild.php (100%) rename tests/{Doctrine => }/Tests/Models/CustomType/CustomIdObjectTypeParent.php (100%) rename tests/{Doctrine => }/Tests/Models/CustomType/CustomTypeChild.php (100%) rename tests/{Doctrine => }/Tests/Models/CustomType/CustomTypeParent.php (100%) rename tests/{Doctrine => }/Tests/Models/CustomType/CustomTypeUpperCase.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC117/DDC117ApproveChanges.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC117/DDC117Article.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC117/DDC117ArticleDetails.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC117/DDC117Editor.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC117/DDC117Link.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC117/DDC117Reference.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC117/DDC117Translation.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC1590/DDC1590Entity.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC1590/DDC1590User.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC1872/DDC1872Bar.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC1872/DDC1872ExampleTrait.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2372/DDC2372Address.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2372/DDC2372Admin.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2372/DDC2372User.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2504/DDC2504ChildClass.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2504/DDC2504OtherClass.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2504/DDC2504RootClass.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2825/ExplicitSchemaAndTable.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC2825/SchemaAndTableInTableName.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3231/DDC3231EntityRepository.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3231/DDC3231User1.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3231/DDC3231User1NoNamespace.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3231/DDC3231User2.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3231/DDC3231User2NoNamespace.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3293/DDC3293Address.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3293/DDC3293User.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3293/DDC3293UserPrefixed.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3346/DDC3346Article.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3346/DDC3346Author.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3579/DDC3579Admin.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3579/DDC3579Group.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3579/DDC3579User.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3597/DDC3597Image.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3597/DDC3597Media.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3597/DDC3597Root.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3699/DDC3699Child.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3699/DDC3699Parent.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3699/DDC3699RelationMany.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3699/DDC3699RelationOne.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3711/DDC3711EntityA.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3711/DDC3711EntityB.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3899/DDC3899Contract.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3899/DDC3899FixContract.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3899/DDC3899FlexContract.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC3899/DDC3899User.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC4006/DDC4006User.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC4006/DDC4006UserId.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC5934/DDC5934BaseContract.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC5934/DDC5934Contract.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC5934/DDC5934Member.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC6412/DDC6412File.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC753/DDC753CustomRepository.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC753/DDC753DefaultRepository.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC753/DDC753InvalidRepository.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC869/DDC869ChequePayment.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC869/DDC869CreditCardPayment.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC869/DDC869Payment.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC869/DDC869PaymentRepository.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC889/DDC889Class.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC889/DDC889Entity.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC889/DDC889SuperClass.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC964/DDC964Address.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC964/DDC964Admin.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC964/DDC964Group.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC964/DDC964Guest.php (100%) rename tests/{Doctrine => }/Tests/Models/DDC964/DDC964User.php (100%) rename tests/{Doctrine => }/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php (100%) rename tests/{Doctrine => }/Tests/Models/DataTransferObjects/DtoWithEnum.php (100%) rename tests/{Doctrine => }/Tests/Models/DirectoryTree/AbstractContentItem.php (100%) rename tests/{Doctrine => }/Tests/Models/DirectoryTree/Directory.php (100%) rename tests/{Doctrine => }/Tests/Models/DirectoryTree/File.php (100%) rename tests/{Doctrine => }/Tests/Models/ECommerce/ECommerceCart.php (100%) rename tests/{Doctrine => }/Tests/Models/ECommerce/ECommerceCategory.php (100%) rename tests/{Doctrine => }/Tests/Models/ECommerce/ECommerceCustomer.php (100%) rename tests/{Doctrine => }/Tests/Models/ECommerce/ECommerceFeature.php (100%) rename tests/{Doctrine => }/Tests/Models/ECommerce/ECommerceProduct.php (100%) rename tests/{Doctrine => }/Tests/Models/ECommerce/ECommerceShipping.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/AccessLevel.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/Card.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/CardWithDefault.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/CardWithNullable.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/City.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/Product.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/Quantity.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/Scale.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/Suit.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/TypedCard.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/TypedCardEnumCompositeId.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/TypedCardEnumId.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/Unit.php (100%) rename tests/{Doctrine => }/Tests/Models/Enums/UserStatus.php (100%) rename tests/{Doctrine => }/Tests/Models/Forum/ForumAvatar.php (100%) rename tests/{Doctrine => }/Tests/Models/Forum/ForumBoard.php (100%) rename tests/{Doctrine => }/Tests/Models/Forum/ForumCategory.php (100%) rename tests/{Doctrine => }/Tests/Models/Forum/ForumEntry.php (100%) rename tests/{Doctrine => }/Tests/Models/Forum/ForumUser.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10132/Complex.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10132/ComplexChild.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10288/GH10288People.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10334/GH10334Foo.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10334/GH10334FooCollection.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10334/GH10334Product.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10334/GH10334ProductType.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10334/GH10334ProductTypeId.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10336/GH10336Entity.php (100%) rename tests/{Doctrine => }/Tests/Models/GH10336/GH10336Relation.php (100%) rename tests/{Doctrine => }/Tests/Models/GH7141/GH7141Article.php (100%) rename tests/{Doctrine => }/Tests/Models/GH7316/GH7316Article.php (100%) rename tests/{Doctrine => }/Tests/Models/GH7717/GH7717Child.php (100%) rename tests/{Doctrine => }/Tests/Models/GH7717/GH7717Parent.php (100%) rename tests/{Doctrine => }/Tests/Models/GH8565/GH8565Employee.php (100%) rename tests/{Doctrine => }/Tests/Models/GH8565/GH8565Manager.php (100%) rename tests/{Doctrine => }/Tests/Models/GH8565/GH8565Person.php (100%) rename tests/{Doctrine => }/Tests/Models/Generic/BooleanModel.php (100%) rename tests/{Doctrine => }/Tests/Models/Generic/DateTimeModel.php (100%) rename tests/{Doctrine => }/Tests/Models/Generic/DecimalModel.php (100%) rename tests/{Doctrine => }/Tests/Models/Generic/NonAlphaColumnsEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/Generic/SerializationModel.php (100%) rename tests/{Doctrine => }/Tests/Models/GeoNames/Admin1.php (100%) rename tests/{Doctrine => }/Tests/Models/GeoNames/Admin1AlternateName.php (100%) rename tests/{Doctrine => }/Tests/Models/GeoNames/City.php (100%) rename tests/{Doctrine => }/Tests/Models/GeoNames/Country.php (100%) rename tests/{Doctrine => }/Tests/Models/Global/GlobalNamespaceModel.php (100%) rename tests/{Doctrine => }/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php (100%) rename tests/{Doctrine => }/Tests/Models/Hydration/SimpleEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/Issue5989/Issue5989Employee.php (100%) rename tests/{Doctrine => }/Tests/Models/Issue5989/Issue5989Manager.php (100%) rename tests/{Doctrine => }/Tests/Models/Issue5989/Issue5989Person.php (100%) rename tests/{Doctrine => }/Tests/Models/Issue9300/Issue9300Child.php (100%) rename tests/{Doctrine => }/Tests/Models/Issue9300/Issue9300Parent.php (100%) rename tests/{Doctrine => }/Tests/Models/JoinedInheritanceType/AnotherChildClass.php (100%) rename tests/{Doctrine => }/Tests/Models/JoinedInheritanceType/ChildClass.php (100%) rename tests/{Doctrine => }/Tests/Models/JoinedInheritanceType/RootClass.php (100%) rename tests/{Doctrine => }/Tests/Models/Legacy/LegacyArticle.php (100%) rename tests/{Doctrine => }/Tests/Models/Legacy/LegacyCar.php (100%) rename tests/{Doctrine => }/Tests/Models/Legacy/LegacyUser.php (100%) rename tests/{Doctrine => }/Tests/Models/Legacy/LegacyUserReference.php (100%) rename tests/{Doctrine => }/Tests/Models/ManyToManyPersister/ChildClass.php (100%) rename tests/{Doctrine => }/Tests/Models/ManyToManyPersister/OtherParentClass.php (100%) rename tests/{Doctrine => }/Tests/Models/ManyToManyPersister/ParentClass.php (100%) rename tests/{Doctrine => }/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php (100%) rename tests/{Doctrine => }/Tests/Models/MixedToOneIdentity/Country.php (100%) rename tests/{Doctrine => }/Tests/Models/Navigation/NavCountry.php (100%) rename tests/{Doctrine => }/Tests/Models/Navigation/NavPhotos.php (100%) rename tests/{Doctrine => }/Tests/Models/Navigation/NavPointOfInterest.php (100%) rename tests/{Doctrine => }/Tests/Models/Navigation/NavTour.php (100%) rename tests/{Doctrine => }/Tests/Models/Navigation/NavUser.php (100%) rename tests/{Doctrine => }/Tests/Models/NonPublicSchemaJoins/User.php (100%) rename tests/{Doctrine => }/Tests/Models/NullDefault/NullDefaultColumn.php (100%) rename tests/{Doctrine => }/Tests/Models/OneToOneInverseSideLoad/InverseSide.php (100%) rename tests/{Doctrine => }/Tests/Models/OneToOneInverseSideLoad/OwningSide.php (100%) rename tests/{Doctrine => }/Tests/Models/OneToOneSingleTableInheritance/Cat.php (100%) rename tests/{Doctrine => }/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php (100%) rename tests/{Doctrine => }/Tests/Models/OneToOneSingleTableInheritance/Pet.php (100%) rename tests/{Doctrine => }/Tests/Models/Pagination/Company.php (100%) rename tests/{Doctrine => }/Tests/Models/Pagination/Department.php (100%) rename tests/{Doctrine => }/Tests/Models/Pagination/Logo.php (100%) rename tests/{Doctrine => }/Tests/Models/Pagination/User.php (100%) rename tests/{Doctrine => }/Tests/Models/Pagination/User1.php (100%) rename tests/{Doctrine => }/Tests/Models/PersistentObject/PersistentCollectionContent.php (100%) rename tests/{Doctrine => }/Tests/Models/PersistentObject/PersistentCollectionHolder.php (100%) rename tests/{Doctrine => }/Tests/Models/PersistentObject/PersistentEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/Project/Project.php (100%) rename tests/{Doctrine => }/Tests/Models/Project/ProjectId.php (100%) rename tests/{Doctrine => }/Tests/Models/Project/ProjectInvalidMapping.php (100%) rename tests/{Doctrine => }/Tests/Models/Project/ProjectName.php (100%) rename tests/{Doctrine => }/Tests/Models/Quote/Address.php (100%) rename tests/{Doctrine => }/Tests/Models/Quote/City.php (100%) rename tests/{Doctrine => }/Tests/Models/Quote/FullAddress.php (100%) rename tests/{Doctrine => }/Tests/Models/Quote/Group.php (100%) rename tests/{Doctrine => }/Tests/Models/Quote/NumericEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/Quote/Phone.php (100%) rename tests/{Doctrine => }/Tests/Models/Quote/User.php (100%) rename tests/{Doctrine => }/Tests/Models/ReadonlyProperties/Author.php (100%) rename tests/{Doctrine => }/Tests/Models/ReadonlyProperties/Book.php (100%) rename tests/{Doctrine => }/Tests/Models/ReadonlyProperties/SimpleBook.php (100%) rename tests/{Doctrine => }/Tests/Models/Reflection/AbstractEmbeddable.php (100%) rename tests/{Doctrine => }/Tests/Models/Reflection/ArrayObjectExtendingClass.php (100%) rename tests/{Doctrine => }/Tests/Models/Reflection/ClassWithMixedProperties.php (100%) rename tests/{Doctrine => }/Tests/Models/Reflection/ConcreteEmbeddable.php (100%) rename tests/{Doctrine => }/Tests/Models/Reflection/ParentClass.php (100%) rename tests/{Doctrine => }/Tests/Models/Routing/RoutingLeg.php (100%) rename tests/{Doctrine => }/Tests/Models/Routing/RoutingLocation.php (100%) rename tests/{Doctrine => }/Tests/Models/Routing/RoutingRoute.php (100%) rename tests/{Doctrine => }/Tests/Models/Routing/RoutingRouteBooking.php (100%) rename tests/{Doctrine => }/Tests/Models/StockExchange/Bond.php (100%) rename tests/{Doctrine => }/Tests/Models/StockExchange/Market.php (100%) rename tests/{Doctrine => }/Tests/Models/StockExchange/Stock.php (100%) rename tests/{Doctrine => }/Tests/Models/Taxi/Car.php (100%) rename tests/{Doctrine => }/Tests/Models/Taxi/Driver.php (100%) rename tests/{Doctrine => }/Tests/Models/Taxi/PaidRide.php (100%) rename tests/{Doctrine => }/Tests/Models/Taxi/Ride.php (100%) rename tests/{Doctrine => }/Tests/Models/Tweet/Tweet.php (100%) rename tests/{Doctrine => }/Tests/Models/Tweet/User.php (100%) rename tests/{Doctrine => }/Tests/Models/Tweet/UserList.php (100%) rename tests/{Doctrine => }/Tests/Models/TypedProperties/Contact.php (100%) rename tests/{Doctrine => }/Tests/Models/TypedProperties/UserTyped.php (100%) rename tests/{Doctrine => }/Tests/Models/TypedProperties/UserTypedWithCustomTypedField.php (100%) rename tests/{Doctrine => }/Tests/Models/Upsertable/Insertable.php (100%) rename tests/{Doctrine => }/Tests/Models/Upsertable/Updatable.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/AuxiliaryEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedManyToManyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedOneToManyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/InversedOneToOneEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToManyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToOneEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueConversionType/OwningOneToOneEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueObjects/Name.php (100%) rename tests/{Doctrine => }/Tests/Models/ValueObjects/Person.php (100%) rename tests/{Doctrine => }/Tests/Models/VersionedManyToOne/Article.php (100%) rename tests/{Doctrine => }/Tests/Models/VersionedManyToOne/Category.php (100%) rename tests/{Doctrine => }/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php (100%) rename tests/{Doctrine => }/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php (100%) rename tests/{Doctrine => }/Tests/ORM/AbstractQueryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/CacheConfigTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/CacheKeyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/CacheLoggerChainTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/DefaultCacheFactoryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/DefaultCacheTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/DefaultCollectionHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/DefaultEntityHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/DefaultQueryCacheTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/DefaultRegionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/FileLockRegionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/RegionTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Cache/StatisticsCacheLoggerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/ConfigurationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Entity/ConstructorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/EntityManagerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/EntityNotFoundExceptionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/AdvancedAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/AdvancedDqlQueryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/BasicFunctionalTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/CascadeRemoveOrderTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ClassTableInheritanceTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ClearEventTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/CompositePrimaryKeyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/CustomFunctionsTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/CustomIdObjectTypeTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/DatabaseDriverTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/DatabaseDriverTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/DefaultValuesTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/DetachedEntityTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/EagerFetchCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/EntityListenersTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/EntityRepositoryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/EnumTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ExtraLazyCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/FlushEventTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/GH7877Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/HydrationCacheTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/IdentityMapTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/IndexByAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/InsertableUpdatableTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/LifecycleCallbackTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Locking/GearmanLockTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Locking/LockAgentWorker.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Locking/LockTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Locking/OptimisticTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ManyToManyEventTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/MappedSuperclassTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/NativeQueryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/NewOperatorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToOneEagerLoadingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OrderedCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/PaginationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ParserResultSerializationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ParserResults/single_select_2_17_0.txt (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/PersistentCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/PostFlushEventTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/PostLoadEventTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/QueryBuilderParenthesisTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/QueryCacheTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/QueryDqlFunctionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/QueryIterableTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/QueryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ReadOnlyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ReadonlyPropertiesTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ReferenceProxyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ResultCacheTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SQLFilterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SchemaTool/DBAL483Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SchemaTool/DDC214Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SchemaValidatorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SecondLevelCacheTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SequenceGeneratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SingleTableCompositeKeyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/SingleTableInheritanceTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/StandardEntityPersisterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1040Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1041Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1043Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1080Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1113Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1129Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1163Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC117Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1181Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1193Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1209Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1225Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1228Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1238Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1250Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1300Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1301Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1306Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1335Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1400Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC142Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1430Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1436Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC144Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1452Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1454Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1458Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1461Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1514Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1515Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1526Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1545Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1548Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1595Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC163Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1643Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1654Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1655Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1666Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1685Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC168Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1695Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1707Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1719Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1757Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1778Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1787Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1843Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1884Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1885Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1918Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1925Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC192Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1995Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC1998Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC199Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2012Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2074Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2084Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2090Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2106Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC211Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2138Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2175Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2182Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2214Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2224Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2252Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2306Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2346Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2350Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2359Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC237Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2387Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2415Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2494Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2575Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2579Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC258Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2602Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2655Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2660Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2692Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2759Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2775Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2780Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2790Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC279Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2825Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2862Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2895Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2931Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2943Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2984Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC2996Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3033Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3042Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3068Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC309Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3103Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3123Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3160Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3170Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3192Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3223Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3300Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3303Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC331Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3330Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3346Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC345Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC353Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3582Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3597Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3634Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3644Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3719Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC371Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3785Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC381Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC3967Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC4003Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC4024Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC422Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC425Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC440Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC444Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC448Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC493Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC512Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC513Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC522Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC531Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC5684Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC588Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC599Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC618Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC6303Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC633Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC6460Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC6558Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC656Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC657Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC698Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC69Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC719Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC735Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC736Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC748Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC767Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC7969Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC809Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC812Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC832Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC837Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC849Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC881Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC933Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC949Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC960Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/DDC992Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyInheritor.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyOwner.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10132Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10288Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10334Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10336Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10348Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10387Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10450Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10454Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10462Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10473Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10531Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10532Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10566Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10625Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10661/InvalidChildEntity.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10661/InvalidEntity.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10747Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10752Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10808Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10869Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH10880Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11017/GH11017Entity.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11017/GH11017Enum.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11017/GH11017Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11037/EntityStatus.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11037/IntEntityStatus.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11037/InvalidEntityWithTypedEnum.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11037/StringEntityStatus.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11037/ValidEntityWithTypedEnum.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11058Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityAdvanced.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityBasic.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH11072/GH11072Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH2947Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH5562Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH5742Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH5762Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH5804Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH5887Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH5988Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH5998Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6029Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6141Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6217Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6362Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6394Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6402Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6464Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6499OneToManyRelationshipTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6499OneToOneRelationshipTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6499Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6531Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6682Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6699Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6740Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6823Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH6937Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7006Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7012Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7062Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7067Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7068Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7079Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7180Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7259Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7286Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7366Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7505Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7512Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7629Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7661Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7684Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7717Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7735Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7737Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7761Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7767Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7820Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7829Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7836Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7864Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7869Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7875Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH7941Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8055Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8061Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8127Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8217Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8415Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8443Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8499Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8663Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH8914Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9027Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9109Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9192Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9230Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9335Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9467/GH9467Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceChild.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonInsertableColumn.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonUpdatableColumn.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonWritableColumn.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceRoot.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceWritableColumn.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9516Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9579Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/GH9807Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/Issue5989Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/Issue9300Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/Ticket2481Test.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/TypeTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/TypeValueSqlTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/ValueObjectsTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Functional/VersionedOneToOneTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/AbstractHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/ArrayHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/CustomHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/HydrationTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/ObjectHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/ResultSetMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/ScalarColumnHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/ScalarHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/SimpleObjectHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Hydration/SingleScalarHydratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Id/AssignedGeneratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Id/SequenceGeneratorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Internal/HydrationCompleteHandlerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Internal/TopologicalSortTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/LazyCriteriaCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/AssociationMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/AttributeDriverTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/AttributeReaderTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/BasicInheritanceMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ClassMetadataBuilderTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ClassMetadataFactoryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ClassMetadataTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/EmbeddedClassMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/EntityListenerResolverTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/FieldBuilderTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/FieldMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/Fixtures/AttributeEntityWithNestedJoinColumns.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/InverseSideMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/JoinColumnMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/JoinTableMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/MappingDriverTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/NamingStrategyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/OwningSideMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/QuoteStrategyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/Symfony/DriverTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/Symfony/XmlDriverTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/ToManyAssociationMappingTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/TypedFieldMapper/CustomIntAsStringTypedFieldMapper.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/TypedFieldMapperTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/XmlMappingDriverTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.php (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/CatNoId.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/DDC2429Book.orm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/DDC2429Novel.orm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Cache.City.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293Address.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293User.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293UserPrefixed.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Enums.Card.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7141.GH7141Article.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7316.GH7316Article.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.Project.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.ProjectInvalidMapping.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Name.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Person.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Comment.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserMissingAttributes.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.XMLSLC.dcm.xml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.yml (100%) rename tests/{Doctrine => }/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.yml (100%) rename tests/{Doctrine => }/Tests/ORM/ORMInvalidArgumentExceptionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/ORMSetupTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Performance/SecondLevelCacheTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/PersistentCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Persisters/Exception/UnrecognizedFieldTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Persisters/ManyToManyPersisterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Proxy/ProxyFactoryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/CustomTreeWalkersJoinTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/CustomTreeWalkersTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/DeleteSqlGenerationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/ExprTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/FilterCollectionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/LanguageRecognitionTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/LexerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/ParameterTypeInfererTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/ParserResultTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/ParserTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/QueryExpressionVisitorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/QueryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/SelectSqlGenerationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/SqlExpressionVisitorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/SqlWalkerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Query/UpdateSqlGenerationTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/QueryBuilderTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/AttachEntityListenersListenerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/InfoCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/SchemaTool/CommandTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/ConsoleRunnerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Console/MetadataFilterTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/DebugTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Pagination/CountWalkerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Pagination/PaginationTestCase.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Pagination/PaginatorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/SchemaToolTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/SchemaValidatorTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/TestAsset/ChildClass.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/TestAsset/ChildWithSameAttributesClass.php (100%) rename tests/{Doctrine => }/Tests/ORM/Tools/TestAsset/ParentClass.php (100%) rename tests/{Doctrine => }/Tests/ORM/UnitOfWorkTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php (100%) rename tests/{Doctrine => }/Tests/ORM/Utility/IdentifierFlattenerTest.php (100%) rename tests/{Doctrine => }/Tests/OrmFunctionalTestCase.php (100%) rename tests/{Doctrine => }/Tests/OrmTestCase.php (100%) rename tests/{Doctrine => }/Tests/Proxy/AutoloaderTest.php (100%) rename tests/{Doctrine => }/Tests/TestInit.php (79%) rename tests/{Doctrine => }/Tests/TestUtil.php (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30f5fb5c6ad..06364814b45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,7 @@ You may fix many some of the issues with `vendor/bin/phpcbf`. Please try to add a test for your pull-request. * If you want to fix a bug or provide a reproduce case, create a test file in - ``tests/Doctrine/Tests/ORM/Functional/Ticket`` with the name of the ticket, + ``tests/Tests/ORM/Functional/Ticket`` with the name of the ticket, ``DDC1234Test.php`` for example. * If you want to contribute new functionality add unit- or functional tests depending on the scope of the feature. @@ -57,7 +57,7 @@ sqlite database. Tips for creating unit tests: 1. If you put a test into the `Ticket` namespace as described above, put the testcase and all entities into the same class. - See `https://github.com/doctrine/orm/tree/2.8.x/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php` for an + See `https://github.com/doctrine/orm/tree/3.0.x/tests/Tests/ORM/Functional/Ticket/DDC2306Test.php` for an example. ## Getting merged diff --git a/UPGRADE.md b/UPGRADE.md index 8dcf4108a4a..5249576cbee 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1901,7 +1901,7 @@ The EntityRepository now has an interface Doctrine\Persistence\ObjectRepository. The annotation reader was heavily refactored between 2.0 and 2.1-RC1. In theory the operation of the new reader should be backwards compatible, but it has to be setup differently to work that way: // new call to the AnnotationRegistry - \Doctrine\Common\Annotations\AnnotationRegistry::registerFile('/doctrine-src/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); + \Doctrine\Common\Annotations\AnnotationRegistry::registerFile('/doctrine-src/src/Mapping/Driver/DoctrineAnnotations.php'); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); diff --git a/ci/github/phpunit/mysqli.xml b/ci/github/phpunit/mysqli.xml index a0cf8fa2682..23a44eb5fca 100644 --- a/ci/github/phpunit/mysqli.xml +++ b/ci/github/phpunit/mysqli.xml @@ -29,7 +29,7 @@ - ../../../lib/Doctrine + ../../../src diff --git a/ci/github/phpunit/pdo_mysql.xml b/ci/github/phpunit/pdo_mysql.xml index 701114bb471..1db2cd4fb06 100644 --- a/ci/github/phpunit/pdo_mysql.xml +++ b/ci/github/phpunit/pdo_mysql.xml @@ -29,7 +29,7 @@ - ../../../lib/Doctrine + ../../../src diff --git a/ci/github/phpunit/pdo_pgsql.xml b/ci/github/phpunit/pdo_pgsql.xml index 1152d90d7c3..53f270152b3 100644 --- a/ci/github/phpunit/pdo_pgsql.xml +++ b/ci/github/phpunit/pdo_pgsql.xml @@ -26,7 +26,7 @@ - ../../../lib/Doctrine + ../../../src diff --git a/ci/github/phpunit/pdo_sqlite.xml b/ci/github/phpunit/pdo_sqlite.xml index b21059c3910..385026dc732 100644 --- a/ci/github/phpunit/pdo_sqlite.xml +++ b/ci/github/phpunit/pdo_sqlite.xml @@ -24,7 +24,7 @@ - ../../../lib/Doctrine + ../../../src diff --git a/ci/github/phpunit/pgsql.xml b/ci/github/phpunit/pgsql.xml index 8425d03c1eb..58225decbe2 100644 --- a/ci/github/phpunit/pgsql.xml +++ b/ci/github/phpunit/pgsql.xml @@ -26,7 +26,7 @@ - ../../../lib/Doctrine + ../../../src diff --git a/ci/github/phpunit/sqlite3.xml b/ci/github/phpunit/sqlite3.xml index 29f1fcbe006..a4f313b2e81 100644 --- a/ci/github/phpunit/sqlite3.xml +++ b/ci/github/phpunit/sqlite3.xml @@ -24,7 +24,7 @@ - ../../../lib/Doctrine + ../../../src diff --git a/composer.json b/composer.json index d9b8937127f..c7ee4f9ec9f 100644 --- a/composer.json +++ b/composer.json @@ -51,13 +51,13 @@ "symfony/cache": "Provides cache support for Setup Tool with doctrine/cache 2.0" }, "autoload": { - "psr-4": { "Doctrine\\ORM\\": "lib/Doctrine/ORM" } + "psr-4": { "Doctrine\\ORM\\": "src" } }, "autoload-dev": { "psr-4": { - "Doctrine\\Tests\\": "tests/Doctrine/Tests", - "Doctrine\\StaticAnalysis\\": "tests/Doctrine/StaticAnalysis", - "Doctrine\\Performance\\": "tests/Doctrine/Performance" + "Doctrine\\Tests\\": "tests/Tests", + "Doctrine\\StaticAnalysis\\": "tests/StaticAnalysis", + "Doctrine\\Performance\\": "tests/Performance" } }, "archive": { diff --git a/docs/en/reference/events.rst b/docs/en/reference/events.rst index 094f0bf717a..6f19876ea0e 100644 --- a/docs/en/reference/events.rst +++ b/docs/en/reference/events.rst @@ -1022,16 +1022,16 @@ and the EntityManager. } } -.. _PrePersistEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PrePersistEventArgs.php -.. _PreRemoveEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreRemoveEventArgs.php -.. _PreUpdateEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php -.. _PostPersistEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PostPersistEventArgs.php -.. _PostRemoveEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PostRemoveEventArgs.php -.. _PostUpdateEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PostUpdateEventArgs.php -.. _PostLoadEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PostLoadEventArgs.php -.. _PreFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreFlushEventArgs.php -.. _PostFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PostFlushEventArgs.php -.. _OnFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnFlushEventArgs.php -.. _OnClearEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnClearEventArgs.php -.. _LoadClassMetadataEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php -.. _OnClassMetadataNotFoundEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php +.. _PrePersistEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PrePersistEventArgs.php +.. _PreRemoveEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PreRemoveEventArgs.php +.. _PreUpdateEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PreUpdateEventArgs.php +.. _PostPersistEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PostPersistEventArgs.php +.. _PostRemoveEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PostRemoveEventArgs.php +.. _PostUpdateEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PostUpdateEventArgs.php +.. _PostLoadEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PostLoadEventArgs.php +.. _PreFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PreFlushEventArgs.php +.. _PostFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/PostFlushEventArgs.php +.. _OnFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/OnFlushEventArgs.php +.. _OnClearEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/OnClearEventArgs.php +.. _LoadClassMetadataEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/LoadClassMetadataEventArgs.php +.. _OnClassMetadataNotFoundEventArgs: https://github.com/doctrine/orm/blob/HEAD/src/Event/OnClassMetadataNotFoundEventArgs.php diff --git a/phpbench.json b/phpbench.json index 64989be5d6f..c6de1cebaaf 100644 --- a/phpbench.json +++ b/phpbench.json @@ -1,6 +1,6 @@ { - "runner.bootstrap": "tests/Doctrine/Tests/TestInit.php", - "runner.path": "tests/Doctrine/Performance", + "runner.bootstrap": "tests/Tests/TestInit.php", + "runner.path": "tests/Performance", "runner.file_pattern": "*Bench.php", "core.extensions": [ diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 2327993ddf2..7ead84a96fa 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -11,12 +11,12 @@ - lib + src tests - */lib/Doctrine/ORM/Mapping/InverseJoinColumn.php - */tests/Doctrine/Tests/Proxies/__CG__* - */tests/Doctrine/Tests/ORM/Tools/Export/export/* + */src/Mapping/InverseJoinColumn.php + */tests/Tests/Proxies/__CG__* + */tests/Tests/ORM/Tools/Export/export/* @@ -28,16 +28,16 @@ - tests/Doctrine/Tests/Mocks/HydratorMockStatement.php - tests/Doctrine/Tests/Models/Cache/ComplexAction.php - tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php - tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php - tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php - tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php + tests/Tests/Mocks/HydratorMockStatement.php + tests/Tests/Models/Cache/ComplexAction.php + tests/Tests/Models/DDC117/DDC117ArticleDetails.php + tests/Tests/Models/DDC117/DDC117Translation.php + tests/Tests/ORM/Functional/Ticket/DDC2579Test.php + tests/Tests/ORM/Functional/ValueObjectsTest.php @@ -53,73 +53,73 @@ - lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php + src/Tools/Console/Helper/EntityManagerHelper.php tests/* - lib/Doctrine/ORM/Tools/Debug.php - tests/Doctrine/Tests/ORM/Tools/DebugTest.php + src/Tools/Debug.php + tests/Tests/ORM/Tools/DebugTest.php - lib/Doctrine/ORM/Events.php - lib/Doctrine/ORM/Tools/ToolEvents.php + src/Events.php + src/Tools/ToolEvents.php - lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php + src/Internal/Hydration/AbstractHydrator.php - lib/Doctrine/ORM/Query/Parser.php + src/Query/Parser.php - lib/Doctrine/ORM/Mapping/AssociationOverride.php - lib/Doctrine/ORM/Mapping/AssociationOverrides.php - lib/Doctrine/ORM/Mapping/AttributeOverride.php - lib/Doctrine/ORM/Mapping/AttributeOverrides.php - lib/Doctrine/ORM/Mapping/Cache.php - lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php - lib/Doctrine/ORM/Mapping/Column.php - lib/Doctrine/ORM/Mapping/CustomIdGenerator.php - lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php - lib/Doctrine/ORM/Mapping/DiscriminatorMap.php - lib/Doctrine/ORM/Mapping/Embeddable.php - lib/Doctrine/ORM/Mapping/Embedded.php - lib/Doctrine/ORM/Mapping/Entity.php - lib/Doctrine/ORM/Mapping/EntityListeners.php - lib/Doctrine/ORM/Mapping/GeneratedValue.php - lib/Doctrine/ORM/Mapping/HasLifecycleCallbacks.php - lib/Doctrine/ORM/Mapping/Id.php - lib/Doctrine/ORM/Mapping/Index.php - lib/Doctrine/ORM/Mapping/InheritanceType.php - lib/Doctrine/ORM/Mapping/JoinColumn.php - lib/Doctrine/ORM/Mapping/JoinColumns.php - lib/Doctrine/ORM/Mapping/JoinTable.php - lib/Doctrine/ORM/Mapping/ManyToMany.php - lib/Doctrine/ORM/Mapping/ManyToOne.php - lib/Doctrine/ORM/Mapping/MappedSuperclass.php - lib/Doctrine/ORM/Mapping/OneToMany.php - lib/Doctrine/ORM/Mapping/OneToOne.php - lib/Doctrine/ORM/Mapping/OrderBy.php - lib/Doctrine/ORM/Mapping/PostLoad.php - lib/Doctrine/ORM/Mapping/PostPersist.php - lib/Doctrine/ORM/Mapping/PostRemove.php - lib/Doctrine/ORM/Mapping/PostUpdate.php - lib/Doctrine/ORM/Mapping/PreFlush.php - lib/Doctrine/ORM/Mapping/PrePersist.php - lib/Doctrine/ORM/Mapping/PreRemove.php - lib/Doctrine/ORM/Mapping/PreUpdate.php - lib/Doctrine/ORM/Mapping/SequenceGenerator.php - lib/Doctrine/ORM/Mapping/Table.php - lib/Doctrine/ORM/Mapping/UniqueConstraint.php - lib/Doctrine/ORM/Mapping/Version.php + src/Mapping/AssociationOverride.php + src/Mapping/AssociationOverrides.php + src/Mapping/AttributeOverride.php + src/Mapping/AttributeOverrides.php + src/Mapping/Cache.php + src/Mapping/ChangeTrackingPolicy.php + src/Mapping/Column.php + src/Mapping/CustomIdGenerator.php + src/Mapping/DiscriminatorColumn.php + src/Mapping/DiscriminatorMap.php + src/Mapping/Embeddable.php + src/Mapping/Embedded.php + src/Mapping/Entity.php + src/Mapping/EntityListeners.php + src/Mapping/GeneratedValue.php + src/Mapping/HasLifecycleCallbacks.php + src/Mapping/Id.php + src/Mapping/Index.php + src/Mapping/InheritanceType.php + src/Mapping/JoinColumn.php + src/Mapping/JoinColumns.php + src/Mapping/JoinTable.php + src/Mapping/ManyToMany.php + src/Mapping/ManyToOne.php + src/Mapping/MappedSuperclass.php + src/Mapping/OneToMany.php + src/Mapping/OneToOne.php + src/Mapping/OrderBy.php + src/Mapping/PostLoad.php + src/Mapping/PostPersist.php + src/Mapping/PostRemove.php + src/Mapping/PostUpdate.php + src/Mapping/PreFlush.php + src/Mapping/PrePersist.php + src/Mapping/PreRemove.php + src/Mapping/PreUpdate.php + src/Mapping/SequenceGenerator.php + src/Mapping/Table.php + src/Mapping/UniqueConstraint.php + src/Mapping/Version.php - lib/Doctrine/ORM/Cache/DefaultQueryCache.php + src/Cache/DefaultQueryCache.php @@ -153,11 +153,11 @@ - lib/Doctrine/ORM/EntityManagerInterface.php + src/EntityManagerInterface.php - tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php + tests/Tests/Models/DDC1872/DDC1872ExampleTrait.php @@ -178,25 +178,25 @@ - tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php - tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php - tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php + tests/Tests/Models/Global/GlobalNamespaceModel.php + tests/Tests/Models/DDC3231/DDC3231User1NoNamespace.php + tests/Tests/Models/DDC3231/DDC3231User2NoNamespace.php - tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php + tests/Tests/ORM/Functional/Ticket/DDC2084Test.php - tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php + tests/Tests/ORM/Functional/Ticket/DDC2084Test.php - tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php - tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php + tests/Tests/ORM/Functional/Ticket/DDC1301Test.php + tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php - tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php + tests/Tests/Models/DDC1590/DDC1590User.php - tests/Doctrine/Tests/Proxy/DefaultProxyClassNameResolverTest.php + tests/Tests/Proxy/DefaultProxyClassNameResolverTest.php - tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php - tests/Doctrine/Tests/Mocks/DriverMock.php - tests/Doctrine/Tests/ORM/UnitOfWorkTest.php - tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php + tests/Tests/Mocks/DatabasePlatformMock.php + tests/Tests/Mocks/DriverMock.php + tests/Tests/ORM/UnitOfWorkTest.php + tests/Tests/ORM/Query/DeleteSqlGenerationTest.php - lib/Doctrine/ORM/Query/AST/Node.php + src/Query/AST/Node.php - tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests* + tests/Tests/ORM/Mapping/php/Doctrine.Tests* - lib/Doctrine/ORM/AbstractQuery.php - lib/Doctrine/ORM/Mapping/ClassMetadata.php - lib/Doctrine/ORM/NativeQuery.php - lib/Doctrine/ORM/Query.php - lib/Doctrine/ORM/Query/TreeWalkerAdapter.php - lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php - lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php + src/AbstractQuery.php + src/Mapping/ClassMetadata.php + src/NativeQuery.php + src/Query.php + src/Query/TreeWalkerAdapter.php + src/Tools/Export/Driver/AbstractExporter.php + src/Tools/Export/Driver/PhpExporter.php - tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php - tests/Doctrine/Tests/Mocks/SchemaManagerMock.php - tests/Doctrine/Tests/ORM/AbstractQueryTest.php - tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php + tests/Tests/Mocks/DatabasePlatformMock.php + tests/Tests/Mocks/SchemaManagerMock.php + tests/Tests/ORM/AbstractQueryTest.php + tests/Tests/ORM/Functional/Ticket/DDC3634Test.php - tests/Doctrine/Tests/OrmFunctionalTestCase.php + tests/Tests/OrmFunctionalTestCase.php - lib/Doctrine/ORM/Proxy/ProxyFactory.php + src/Proxy/ProxyFactory.php - tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php + tests/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php - tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php - tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php - tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php + tests/Tests/ORM/Functional/Ticket/DDC1885Test.php + tests/Tests/ORM/Functional/Ticket/DDC1843Test.php + tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php - lib/Doctrine/ORM/Id/TableGenerator.php + src/Id/TableGenerator.php - lib/Doctrine/ORM/Id/TableGenerator.php + src/Id/TableGenerator.php - lib/Doctrine/ORM/QueryBuilder.php + src/QueryBuilder.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b7d3dfbb4a9..c1b0af26bfa 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3,314 +3,314 @@ parameters: - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\EntityPersister\\:\\:getCacheRegion\\(\\)\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php + path: src/Cache/DefaultEntityHydrator.php - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Cache\\\\CacheEntry\\:\\:\\$class\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/DefaultQueryCache.php + path: src/Cache/DefaultQueryCache.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Cache\\\\CacheEntry\\:\\:resolveAssociationEntries\\(\\)\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/DefaultQueryCache.php + path: src/Cache/DefaultQueryCache.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\EntityPersister\\:\\:getCacheRegion\\(\\)\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/DefaultQueryCache.php + path: src/Cache/DefaultQueryCache.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\EntityPersister\\:\\:storeEntityCache\\(\\)\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/DefaultQueryCache.php + path: src/Cache/DefaultQueryCache.php - message: "#^Parameter \\#2 \\$key of method Doctrine\\\\ORM\\\\Cache\\\\Logging\\\\CacheLogger\\:\\:entityCacheHit\\(\\) expects Doctrine\\\\ORM\\\\Cache\\\\EntityCacheKey, Doctrine\\\\ORM\\\\Cache\\\\CacheKey given\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/DefaultQueryCache.php + path: src/Cache/DefaultQueryCache.php - message: "#^Parameter \\#2 \\$key of method Doctrine\\\\ORM\\\\Cache\\\\Logging\\\\CacheLogger\\:\\:entityCacheMiss\\(\\) expects Doctrine\\\\ORM\\\\Cache\\\\EntityCacheKey, Doctrine\\\\ORM\\\\Cache\\\\CacheKey given\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/DefaultQueryCache.php + path: src/Cache/DefaultQueryCache.php - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Cache\\\\CacheEntry\\:\\:\\$identifiers\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php + path: src/Cache/Persister/Collection/AbstractCollectionPersister.php - message: "#^Parameter \\#2 \\$key of method Doctrine\\\\ORM\\\\Cache\\\\EntityHydrator\\:\\:buildCacheEntry\\(\\) expects Doctrine\\\\ORM\\\\Cache\\\\EntityCacheKey, Doctrine\\\\ORM\\\\Cache\\\\CacheKey given\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php + path: src/Cache/Persister/Collection/AbstractCollectionPersister.php - message: "#^Parameter \\#3 \\$entry of method Doctrine\\\\ORM\\\\Cache\\\\CollectionHydrator\\:\\:loadCacheEntry\\(\\) expects Doctrine\\\\ORM\\\\Cache\\\\CollectionCacheEntry, Doctrine\\\\ORM\\\\Cache\\\\CacheEntry given\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php + path: src/Cache/Persister/Collection/AbstractCollectionPersister.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Cache\\\\Region\\:\\:lock\\(\\)\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php + path: src/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Cache\\\\CacheEntry\\:\\:\\$class\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php + path: src/Cache/Persister/Entity/AbstractEntityPersister.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Cache\\\\Persister\\\\CachedPersister&Doctrine\\\\ORM\\\\Persisters\\\\Collection\\\\CollectionPersister\\:\\:loadCollectionCache\\(\\)\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php + path: src/Cache/Persister/Entity/AbstractEntityPersister.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Cache\\\\Persister\\\\CachedPersister&Doctrine\\\\ORM\\\\Persisters\\\\Collection\\\\CollectionPersister\\:\\:storeCollectionCache\\(\\)\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php + path: src/Cache/Persister/Entity/AbstractEntityPersister.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Persisters\\\\Entity\\\\EntityPersister\\:\\:storeEntityCache\\(\\)\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php + path: src/Cache/Persister/Entity/AbstractEntityPersister.php - message: "#^Parameter \\#3 \\$entry of method Doctrine\\\\ORM\\\\Cache\\\\EntityHydrator\\:\\:loadCacheEntry\\(\\) expects Doctrine\\\\ORM\\\\Cache\\\\EntityCacheEntry, Doctrine\\\\ORM\\\\Cache\\\\CacheEntry given\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php + path: src/Cache/Persister/Entity/AbstractEntityPersister.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Cache\\\\Region\\:\\:lock\\(\\)\\.$#" count: 2 - path: lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php + path: src/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php - message: "#^If condition is always true\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php + path: src/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Cache\\\\CacheEntry\\:\\:\\$time\\.$#" count: 1 - path: lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php + path: src/Cache/TimestampQueryCacheValidator.php - message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\Decorator\\\\EntityManagerDecorator\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getMetadataFactory\\(\\)$#" count: 1 - path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php + path: src/Decorator/EntityManagerDecorator.php - message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\Decorator\\\\EntityManagerDecorator\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManagerDecorator\\\\:\\:getMetadataFactory\\(\\)$#" count: 1 - path: lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php + path: src/Decorator/EntityManagerDecorator.php - message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\EntityManager\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getMetadataFactory\\(\\)$#" count: 1 - path: lib/Doctrine/ORM/EntityManager.php + path: src/EntityManager.php - message: "#^Return type \\(Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataFactory\\) of method Doctrine\\\\ORM\\\\EntityManagerInterface\\:\\:getMetadataFactory\\(\\) should be compatible with return type \\(Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadataFactory\\\\>\\) of method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getMetadataFactory\\(\\)$#" count: 1 - path: lib/Doctrine/ORM/EntityManagerInterface.php + path: src/EntityManagerInterface.php - message: "#^Template type T of method Doctrine\\\\ORM\\\\EntityManagerInterface\\:\\:getClassMetadata\\(\\) is not referenced in a parameter\\.$#" count: 1 - path: lib/Doctrine/ORM/EntityManagerInterface.php + path: src/EntityManagerInterface.php - message: "#^Method Doctrine\\\\ORM\\\\EntityRepository\\:\\:matching\\(\\) should return Doctrine\\\\Common\\\\Collections\\\\AbstractLazyCollection\\&Doctrine\\\\Common\\\\Collections\\\\Selectable\\ but returns Doctrine\\\\ORM\\\\LazyCriteriaCollection\\<\\(int\\|string\\), object\\>\\.$#" count: 1 - path: lib/Doctrine/ORM/EntityRepository.php + path: src/EntityRepository.php - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata\\:\\:fullyQualifiedClassName\\(\\) should return class\\-string\\|null but returns string\\|null\\.$#" count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadata.php + path: src/Mapping/ClassMetadata.php - message: "#^If condition is always true\\.$#" count: 1 - path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php + path: src/Mapping/ClassMetadataFactory.php - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ToOneOwningSideMapping\\:\\:fromMappingArray\\(\\) should return static\\(Doctrine\\\\ORM\\\\Mapping\\\\ToOneOwningSideMapping\\) but returns Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneOwningSideMapping\\.$#" count: 1 - path: lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php + path: src/Mapping/ToOneOwningSideMapping.php - message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ToOneOwningSideMapping\\:\\:fromMappingArrayAndName\\(\\) should return static\\(Doctrine\\\\ORM\\\\Mapping\\\\ToOneOwningSideMapping\\) but returns Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneOwningSideMapping\\.$#" count: 1 - path: lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php + path: src/Mapping/ToOneOwningSideMapping.php - message: "#^Call to function is_int\\(\\) with string will always evaluate to false\\.$#" count: 1 - path: lib/Doctrine/ORM/NativeQuery.php + path: src/NativeQuery.php - message: "#^Result of && is always false\\.$#" count: 1 - path: lib/Doctrine/ORM/NativeQuery.php + path: src/NativeQuery.php - message: "#^Parameter \\#3 \\$hints of method Doctrine\\\\ORM\\\\Internal\\\\Hydration\\\\AbstractHydrator\\:\\:hydrateAll\\(\\) expects array\\, array\\ given\\.$#" count: 1 - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + path: src/Persisters/Entity/BasicEntityPersister.php - message: "#^Parameter \\#3 \\$hints of method Doctrine\\\\ORM\\\\Internal\\\\Hydration\\\\AbstractHydrator\\:\\:hydrateAll\\(\\) expects array\\, array\\ given\\.$#" count: 4 - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + path: src/Persisters/Entity/BasicEntityPersister.php - message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" count: 1 - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + path: src/Persisters/Entity/BasicEntityPersister.php - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$isEmbeddedClass\\.$#" count: 1 - path: lib/Doctrine/ORM/Proxy/ProxyFactory.php + path: src/Proxy/ProxyFactory.php - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$isMappedSuperclass\\.$#" count: 1 - path: lib/Doctrine/ORM/Proxy/ProxyFactory.php + path: src/Proxy/ProxyFactory.php - message: "#^Call to an undefined static method Doctrine\\\\ORM\\\\Proxy\\\\ProxyFactory\\:\\:createLazyGhost\\(\\)\\.$#" count: 1 - path: lib/Doctrine/ORM/Proxy/ProxyFactory.php + path: src/Proxy/ProxyFactory.php - message: "#^Comparison operation \"\\<\" between 0\\|1\\|2\\|3\\|4 and 0 is always false\\.$#" count: 1 - path: lib/Doctrine/ORM/Proxy/ProxyFactory.php + path: src/Proxy/ProxyFactory.php - message: "#^Comparison operation \"\\>\" between 0\\|1\\|2\\|3\\|4 and 4 is always false\\.$#" count: 1 - path: lib/Doctrine/ORM/Proxy/ProxyFactory.php + path: src/Proxy/ProxyFactory.php - message: "#^Parameter \\#1 \\$class of method Doctrine\\\\ORM\\\\Utility\\\\IdentifierFlattener\\:\\:flattenIdentifier\\(\\) expects Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata, Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata given\\.$#" count: 1 - path: lib/Doctrine/ORM/Proxy/ProxyFactory.php + path: src/Proxy/ProxyFactory.php - message: "#^Result of \\|\\| is always false\\.$#" count: 1 - path: lib/Doctrine/ORM/Proxy/ProxyFactory.php + path: src/Proxy/ProxyFactory.php - message: "#^Parameter \\#2 \\$sqlParams of method Doctrine\\\\ORM\\\\Query\\:\\:evictResultSetCache\\(\\) expects array\\, array\\ given\\.$#" count: 1 - path: lib/Doctrine/ORM/Query.php + path: src/Query.php - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\:\\:\\$value\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php + path: src/Query/AST/Functions/DateAddFunction.php - message: "#^Access to an undefined property Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node\\:\\:\\$value\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php + path: src/Query/AST/Functions/DateSubFunction.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkJoinPathExpression\\(\\)\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php + path: src/Query/AST/JoinClassPathExpression.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkJoinVariableDeclaration\\(\\)\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php + path: src/Query/AST/JoinVariableDeclaration.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkWhenClauseExpression\\(\\)\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php + path: src/Query/AST/SimpleWhenClause.php - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkWhenClauseExpression\\(\\)\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/AST/WhenClause.php + path: src/Query/AST/WhenClause.php - message: "#^PHPDoc type array\\ of property Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Andx\\:\\:\\$allowedClasses is not covariant with PHPDoc type array\\ of overridden property Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Base\\:\\:\\$allowedClasses\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/Expr/Andx.php + path: src/Query/Expr/Andx.php - message: "#^PHPDoc type array\\ of property Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Orx\\:\\:\\$allowedClasses is not covariant with PHPDoc type array\\ of overridden property Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Base\\:\\:\\$allowedClasses\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/Expr/Orx.php + path: src/Query/Expr/Orx.php - message: "#^PHPDoc type array\\ of property Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Select\\:\\:\\$allowedClasses is not covariant with PHPDoc type array\\ of overridden property Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Base\\:\\:\\$allowedClasses\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/Expr/Select.php + path: src/Query/Expr/Select.php - message: "#^Parameter \\#2 \\$stringPattern of class Doctrine\\\\ORM\\\\Query\\\\AST\\\\LikeExpression constructor expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\Functions\\\\FunctionNode\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\InputParameter\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\Literal\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\PathExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/Parser.php + path: src/Query/Parser.php - message: "#^Unreachable statement \\- code above always terminates\\.$#" count: 2 - path: lib/Doctrine/ORM/Query/Parser.php + path: src/Query/Parser.php - message: "#^Match arm is unreachable because previous comparison is always true\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/SqlWalker.php + path: src/Query/SqlWalker.php - message: "#^Parameter \\#1 \\$condTerm of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkConditionalTerm\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalFactor\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalPrimary\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalTerm, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Phase2OptimizableConditional given\\.$#" count: 1 - path: lib/Doctrine/ORM/Query/SqlWalker.php + path: src/Query/SqlWalker.php - message: "#^Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder\\:\\:add\\(\\) expects array\\<'join'\\|int, array\\\\|string\\>\\|object\\|string, non\\-empty\\-array\\ given\\.$#" count: 2 - path: lib/Doctrine/ORM/QueryBuilder.php + path: src/QueryBuilder.php - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$name\\.$#" count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php + path: src/Tools/Console/Command/GenerateProxiesCommand.php - message: "#^Parameter \\#1 \\$entityListeners of method Doctrine\\\\ORM\\\\Tools\\\\Console\\\\Command\\\\MappingDescribeCommand\\:\\:formatEntityListeners\\(\\) expects array\\, array\\\\>\\> given\\.$#" count: 1 - path: lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php + path: src/Tools/Console/Command/MappingDescribeCommand.php - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" count: 1 - path: lib/Doctrine/ORM/Tools/SchemaTool.php + path: src/Tools/SchemaTool.php - message: "#^Negated boolean expression is always false\\.$#" count: 1 - path: lib/Doctrine/ORM/Tools/SchemaTool.php + path: src/Tools/SchemaTool.php - message: "#^Parameter \\#3 \\$changeSet of class Doctrine\\\\ORM\\\\Event\\\\PreUpdateEventArgs constructor is passed by reference, so it expects variables only$#" count: 1 - path: lib/Doctrine/ORM/UnitOfWork.php + path: src/UnitOfWork.php - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$name\\.$#" count: 1 - path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php + path: src/Utility/HierarchyDiscriminatorResolver.php - message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#" count: 1 - path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php + path: src/Utility/HierarchyDiscriminatorResolver.php diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index e771133101b..cb6fb45261c 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -10,19 +10,19 @@ parameters: # We can be certain that those values are not matched. - message: '~^Match expression does not handle remaining values:~' - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + path: src/Persisters/Entity/BasicEntityPersister.php # DBAL 4 compatibility - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' - path: lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php + path: src/Query/AST/Functions/TrimFunction.php - message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + path: src/Persisters/Entity/BasicEntityPersister.php - message: '~^Unreachable statement \- code above always terminates\.$~' - path: lib/Doctrine/ORM/Mapping/AssociationMapping.php + path: src/Mapping/AssociationMapping.php - '~^Class Doctrine\\DBAL\\Platforms\\SQLitePlatform not found\.$~' @@ -30,7 +30,7 @@ parameters: - message: '#Negated boolean expression is always false\.#' paths: - - lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php - - lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php - - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php - - lib/Doctrine/ORM/ORMSetup.php + - src/Mapping/Driver/AttributeDriver.php + - src/Mapping/Driver/SimplifiedXmlDriver.php + - src/Mapping/Driver/XmlDriver.php + - src/ORMSetup.php diff --git a/phpstan-params.neon b/phpstan-params.neon index 60abffb720f..a7d3556b84a 100644 --- a/phpstan-params.neon +++ b/phpstan-params.neon @@ -1,10 +1,10 @@ parameters: level: 5 paths: - - lib - - tests/Doctrine/StaticAnalysis + - src + - tests/StaticAnalysis excludePaths: - - lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php + - src/Mapping/Driver/AttributeReader.php earlyTerminatingMethodCalls: Doctrine\ORM\Query\Parser: - syntaxError diff --git a/phpstan.neon b/phpstan.neon index 20d621ccdf9..90fda7be9f1 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,45 +10,45 @@ parameters: # We can be certain that those values are not matched. - message: '~^Match expression does not handle remaining values:~' - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + path: src/Persisters/Entity/BasicEntityPersister.php # DBAL 4 compatibility - message: '~^Method Doctrine\\ORM\\Query\\AST\\Functions\\TrimFunction::getTrimMode\(\) never returns .* so it can be removed from the return type\.$~' - path: lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php + path: src/Query/AST/Functions/TrimFunction.php - message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' - path: lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php + path: src/Persisters/Entity/BasicEntityPersister.php - message: '~^Unreachable statement \- code above always terminates\.$~' - path: lib/Doctrine/ORM/Mapping/AssociationMapping.php + path: src/Mapping/AssociationMapping.php # Compatibility with DBAL 3 # See https://github.com/doctrine/dbal/pull/3480 - message: '~^Result of method Doctrine\\DBAL\\Connection::commit\(\) \(void\) is used\.$~' - path: lib/Doctrine/ORM/UnitOfWork.php + path: src/UnitOfWork.php - message: '~^Strict comparison using === between void and false will always evaluate to false\.$~' - path: lib/Doctrine/ORM/UnitOfWork.php + path: src/UnitOfWork.php - message: '~^Variable \$e on left side of \?\? always exists and is not nullable\.$~' - path: lib/Doctrine/ORM/UnitOfWork.php + path: src/UnitOfWork.php - message: '~^Parameter #1 \$command of method Symfony\\Component\\Console\\Application::add\(\) expects Symfony\\Component\\Console\\Command\\Command, Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand given\.$~' - path: lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php + path: src/Tools/Console/ConsoleRunner.php - message: '~Strict comparison using \=\=\= between callable\(\)\: mixed and null will always evaluate to false\.~' - path: lib/Doctrine/ORM/Tools/SchemaTool.php + path: src/Tools/SchemaTool.php # To be removed in 4.0 - message: '#Negated boolean expression is always false\.#' paths: - - lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php - - lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php - - lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php - - lib/Doctrine/ORM/ORMSetup.php + - src/Mapping/Driver/AttributeDriver.php + - src/Mapping/Driver/SimplifiedXmlDriver.php + - src/Mapping/Driver/XmlDriver.php + - src/ORMSetup.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 67776e6bb75..48d4a0f116f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,12 +19,12 @@ failOnNotice="true" failOnWarning="true" failOnRisky="true" - bootstrap="./tests/Doctrine/Tests/TestInit.php" + bootstrap="./tests/Tests/TestInit.php" cacheDirectory=".phpunit.cache" > - ./tests/Doctrine/Tests/ORM + ./tests/Tests/ORM diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 22df9a67070..23d3dbaa804 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,6 +1,6 @@ - + isEmpty() ? $filteredParameters->first() : null]]> @@ -20,12 +20,12 @@ getQueryCache - + getTimestampRegion - + getConfiguration() ->getSecondLevelCacheConfiguration() @@ -35,12 +35,12 @@ getCacheFactory - + getCacheRegion - + identifiers[$assocIndex]]]> identifiers[$assocIndex]]]> @@ -65,7 +65,7 @@ storeEntityCache - + $cache $entityKey @@ -81,18 +81,18 @@ getCacheFactory - + getOwner()]]> getOwner()]]> - + getOwner()]]> - + getOwner()]]> getOwner()]]> @@ -102,7 +102,7 @@ lock - + $cacheEntry @@ -135,7 +135,7 @@ storeEntityCache - + $isChanged @@ -144,17 +144,17 @@ lock - + time]]> - + $className - + wrapped->getClassMetadata($className)]]> @@ -162,7 +162,7 @@ ClassMetadata - + $className @@ -195,7 +195,7 @@ (string) $hydrationMode - + load($criteria, null, null, [], null, 1, $orderBy)]]> new LazyCriteriaCollection($persister, $criteria) @@ -211,18 +211,18 @@ ]]> - + $entity - + return $rowData; return $rowData; - + $index @@ -250,7 +250,7 @@ resultPointers[$dqlAlias] =& $coll[array_key_last($coll)]]]> - + $element @@ -277,7 +277,7 @@ - + $mapping @@ -285,17 +285,17 @@ static - + $repositoryClassName - + $class - + columnNames]]> columnNames]]> @@ -371,7 +371,7 @@ null - + $platformFamily @@ -406,7 +406,7 @@ $owningSide instanceof ManyToOneAssociationMapping) - + new $className() @@ -414,12 +414,12 @@ instances]]> - + - + $mapping @@ -430,7 +430,7 @@ array_merge(self::DEFAULT_TYPED_FIELD_MAPPINGS, $typedFieldMappings) - + $mapping name)]]> - + $metadata instanceof ClassMetadata @@ -493,13 +493,13 @@ getIndexes - + $fileExtension $prefixes - + $mapping @@ -560,17 +560,17 @@ getName() === 'mapped-superclass']]> - + ManyToManyInverseSideMapping - + $joinTable - + OneToManyAssociationMapping @@ -578,12 +578,12 @@ mappedBy)]]> - + OneToOneInverseSideMapping - + $object @@ -592,7 +592,7 @@ ReflectionEmbeddedProperty - + $object @@ -601,13 +601,13 @@ ReflectionEnumProperty - + ReflectionReadonlyProperty ReflectionReadonlyProperty - + $mapping @@ -615,7 +615,7 @@ static - + $instance $mapping @@ -625,17 +625,17 @@ static - + - + $sql - + ]]> @@ -666,7 +666,7 @@ unwrap(), 'add']]]> - + getOwner()]]> getOwner()]]> @@ -682,14 +682,14 @@ getFieldForColumn - + getOwner()]]> getOwner()]]> getOwner()]]> - + $value === null @@ -723,7 +723,7 @@ currentPersisterContext->sqlTableAliases]]> - + $autoloader @@ -737,7 +737,7 @@ require $file - + $className substr($className, $pos + Proxy::MARKER_LENGTH + 2) @@ -746,7 +746,7 @@ string - + $classMetadata @@ -782,7 +782,7 @@ require $fileName - + $sqlParams @@ -802,19 +802,19 @@ $parserResult - + ArithmeticPrimary()]]> ArithmeticPrimary()]]> - + ArithmeticPrimary()]]> ArithmeticPrimary()]]> - + ArithmeticPrimary()]]> ArithmeticPrimary()]]> @@ -823,48 +823,48 @@ unit->value]]> - + ArithmeticPrimary()]]> ArithmeticPrimary()]]> - + unit->value]]> - + $sqlWalker - + simpleArithmeticExpression]]> - + walkJoinPathExpression - + walkJoinVariableDeclaration - + walkWhenClauseExpression - + walkWhenClauseExpression - + $numDeleted @@ -881,7 +881,7 @@ sqlStatements]]> - + $paramTypes @@ -904,12 +904,12 @@ sqlStatements]]> - + sqlStatements]]> - + executeStatement($this->sqlStatements, $params, $types)]]> @@ -923,13 +923,13 @@ SingleTableDeleteUpdateExecutor - + $allowedClasses $parts - + arguments]]> @@ -937,39 +937,39 @@ ]]> - + $parts - + conditionType]]> - + $parts - + $allowedClasses $parts - + $allowedClasses $parts - + parameters]]> - + $stringPattern @@ -1018,7 +1018,7 @@ value === TokenType::T_IDENTIFIER->value]]> - + parameters)]]> @@ -1029,7 +1029,7 @@ Comparison::EQ - + throw QueryException::invalidLiteral($literal) @@ -1053,7 +1053,7 @@ dispatch - + $having $having @@ -1087,7 +1087,7 @@ $dqlPart - + repositoryList[$repositoryHash] ??= $this->createRepository($entityManager, $entityName)]]> @@ -1098,17 +1098,17 @@ new $repositoryClassName($entityManager, $metadata) - + evictAll - + evictAll - + name]]> @@ -1116,12 +1116,12 @@ getConfiguration()->getProxyDir()]]> - + getAllClassNames - + entityListeners]]> @@ -1129,13 +1129,13 @@ getAllClassNames - + $metadatas $metadatas - + $metadatas $metadatas @@ -1146,7 +1146,7 @@ getName()]]> - + $metadatas @@ -1155,7 +1155,7 @@ getName()]]> - + new ArrayIterator($metadatas) @@ -1163,12 +1163,12 @@ MetadataFilter - + $state === UnitOfWork::STATE_DETACHED - + @@ -1182,17 +1182,17 @@ orderByItems]]> - + $parameters - + $orderByClause - + $classes @@ -1209,7 +1209,7 @@ $indexName - + $collectionToDelete $collectionToUpdate @@ -1270,7 +1270,7 @@ $visited - + name]]> subClasses]]> diff --git a/psalm.xml b/psalm.xml index b2e7b723e42..6036c3a1017 100644 --- a/psalm.xml +++ b/psalm.xml @@ -11,11 +11,11 @@ errorBaseline="psalm-baseline.xml" > - - + + - + @@ -50,28 +50,28 @@ - + - + - - + + - + - - - + + + - + @@ -82,92 +82,92 @@ - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - - + + - + @@ -188,16 +188,16 @@ - + - - + + - - + + @@ -217,22 +217,22 @@ - - - - + + + + - + - + diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/src/AbstractQuery.php similarity index 100% rename from lib/Doctrine/ORM/AbstractQuery.php rename to src/AbstractQuery.php diff --git a/lib/Doctrine/ORM/Cache.php b/src/Cache.php similarity index 100% rename from lib/Doctrine/ORM/Cache.php rename to src/Cache.php diff --git a/lib/Doctrine/ORM/Cache/AssociationCacheEntry.php b/src/Cache/AssociationCacheEntry.php similarity index 100% rename from lib/Doctrine/ORM/Cache/AssociationCacheEntry.php rename to src/Cache/AssociationCacheEntry.php diff --git a/lib/Doctrine/ORM/Cache/CacheConfiguration.php b/src/Cache/CacheConfiguration.php similarity index 100% rename from lib/Doctrine/ORM/Cache/CacheConfiguration.php rename to src/Cache/CacheConfiguration.php diff --git a/lib/Doctrine/ORM/Cache/CacheEntry.php b/src/Cache/CacheEntry.php similarity index 100% rename from lib/Doctrine/ORM/Cache/CacheEntry.php rename to src/Cache/CacheEntry.php diff --git a/lib/Doctrine/ORM/Cache/CacheException.php b/src/Cache/CacheException.php similarity index 100% rename from lib/Doctrine/ORM/Cache/CacheException.php rename to src/Cache/CacheException.php diff --git a/lib/Doctrine/ORM/Cache/CacheFactory.php b/src/Cache/CacheFactory.php similarity index 100% rename from lib/Doctrine/ORM/Cache/CacheFactory.php rename to src/Cache/CacheFactory.php diff --git a/lib/Doctrine/ORM/Cache/CacheKey.php b/src/Cache/CacheKey.php similarity index 100% rename from lib/Doctrine/ORM/Cache/CacheKey.php rename to src/Cache/CacheKey.php diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheEntry.php b/src/Cache/CollectionCacheEntry.php similarity index 100% rename from lib/Doctrine/ORM/Cache/CollectionCacheEntry.php rename to src/Cache/CollectionCacheEntry.php diff --git a/lib/Doctrine/ORM/Cache/CollectionCacheKey.php b/src/Cache/CollectionCacheKey.php similarity index 100% rename from lib/Doctrine/ORM/Cache/CollectionCacheKey.php rename to src/Cache/CollectionCacheKey.php diff --git a/lib/Doctrine/ORM/Cache/CollectionHydrator.php b/src/Cache/CollectionHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Cache/CollectionHydrator.php rename to src/Cache/CollectionHydrator.php diff --git a/lib/Doctrine/ORM/Cache/ConcurrentRegion.php b/src/Cache/ConcurrentRegion.php similarity index 100% rename from lib/Doctrine/ORM/Cache/ConcurrentRegion.php rename to src/Cache/ConcurrentRegion.php diff --git a/lib/Doctrine/ORM/Cache/DefaultCache.php b/src/Cache/DefaultCache.php similarity index 100% rename from lib/Doctrine/ORM/Cache/DefaultCache.php rename to src/Cache/DefaultCache.php diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/src/Cache/DefaultCacheFactory.php similarity index 100% rename from lib/Doctrine/ORM/Cache/DefaultCacheFactory.php rename to src/Cache/DefaultCacheFactory.php diff --git a/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php b/src/Cache/DefaultCollectionHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php rename to src/Cache/DefaultCollectionHydrator.php diff --git a/lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php b/src/Cache/DefaultEntityHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php rename to src/Cache/DefaultEntityHydrator.php diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/src/Cache/DefaultQueryCache.php similarity index 100% rename from lib/Doctrine/ORM/Cache/DefaultQueryCache.php rename to src/Cache/DefaultQueryCache.php diff --git a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php b/src/Cache/EntityCacheEntry.php similarity index 100% rename from lib/Doctrine/ORM/Cache/EntityCacheEntry.php rename to src/Cache/EntityCacheEntry.php diff --git a/lib/Doctrine/ORM/Cache/EntityCacheKey.php b/src/Cache/EntityCacheKey.php similarity index 100% rename from lib/Doctrine/ORM/Cache/EntityCacheKey.php rename to src/Cache/EntityCacheKey.php diff --git a/lib/Doctrine/ORM/Cache/EntityHydrator.php b/src/Cache/EntityHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Cache/EntityHydrator.php rename to src/Cache/EntityHydrator.php diff --git a/lib/Doctrine/ORM/Cache/Exception/CacheException.php b/src/Cache/Exception/CacheException.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Exception/CacheException.php rename to src/Cache/Exception/CacheException.php diff --git a/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyCollection.php b/src/Cache/Exception/CannotUpdateReadOnlyCollection.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyCollection.php rename to src/Cache/Exception/CannotUpdateReadOnlyCollection.php diff --git a/lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyEntity.php b/src/Cache/Exception/CannotUpdateReadOnlyEntity.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Exception/CannotUpdateReadOnlyEntity.php rename to src/Cache/Exception/CannotUpdateReadOnlyEntity.php diff --git a/lib/Doctrine/ORM/Cache/Exception/FeatureNotImplemented.php b/src/Cache/Exception/FeatureNotImplemented.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Exception/FeatureNotImplemented.php rename to src/Cache/Exception/FeatureNotImplemented.php diff --git a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php b/src/Cache/Exception/NonCacheableEntity.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Exception/NonCacheableEntity.php rename to src/Cache/Exception/NonCacheableEntity.php diff --git a/lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php b/src/Cache/Exception/NonCacheableEntityAssociation.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Exception/NonCacheableEntityAssociation.php rename to src/Cache/Exception/NonCacheableEntityAssociation.php diff --git a/lib/Doctrine/ORM/Cache/Lock.php b/src/Cache/Lock.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Lock.php rename to src/Cache/Lock.php diff --git a/lib/Doctrine/ORM/Cache/LockException.php b/src/Cache/LockException.php similarity index 100% rename from lib/Doctrine/ORM/Cache/LockException.php rename to src/Cache/LockException.php diff --git a/lib/Doctrine/ORM/Cache/Logging/CacheLogger.php b/src/Cache/Logging/CacheLogger.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Logging/CacheLogger.php rename to src/Cache/Logging/CacheLogger.php diff --git a/lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php b/src/Cache/Logging/CacheLoggerChain.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Logging/CacheLoggerChain.php rename to src/Cache/Logging/CacheLoggerChain.php diff --git a/lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php b/src/Cache/Logging/StatisticsCacheLogger.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php rename to src/Cache/Logging/StatisticsCacheLogger.php diff --git a/lib/Doctrine/ORM/Cache/Persister/CachedPersister.php b/src/Cache/Persister/CachedPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/CachedPersister.php rename to src/Cache/Persister/CachedPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php b/src/Cache/Persister/Collection/AbstractCollectionPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Collection/AbstractCollectionPersister.php rename to src/Cache/Persister/Collection/AbstractCollectionPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php b/src/Cache/Persister/Collection/CachedCollectionPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Collection/CachedCollectionPersister.php rename to src/Cache/Persister/Collection/CachedCollectionPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php b/src/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php rename to src/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php b/src/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php rename to src/Cache/Persister/Collection/ReadOnlyCachedCollectionPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php b/src/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php rename to src/Cache/Persister/Collection/ReadWriteCachedCollectionPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/src/Cache/Persister/Entity/AbstractEntityPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php rename to src/Cache/Persister/Entity/AbstractEntityPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php b/src/Cache/Persister/Entity/CachedEntityPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Entity/CachedEntityPersister.php rename to src/Cache/Persister/Entity/CachedEntityPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php b/src/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php rename to src/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php b/src/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php rename to src/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php b/src/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php rename to src/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php diff --git a/lib/Doctrine/ORM/Cache/QueryCache.php b/src/Cache/QueryCache.php similarity index 100% rename from lib/Doctrine/ORM/Cache/QueryCache.php rename to src/Cache/QueryCache.php diff --git a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php b/src/Cache/QueryCacheEntry.php similarity index 100% rename from lib/Doctrine/ORM/Cache/QueryCacheEntry.php rename to src/Cache/QueryCacheEntry.php diff --git a/lib/Doctrine/ORM/Cache/QueryCacheKey.php b/src/Cache/QueryCacheKey.php similarity index 100% rename from lib/Doctrine/ORM/Cache/QueryCacheKey.php rename to src/Cache/QueryCacheKey.php diff --git a/lib/Doctrine/ORM/Cache/QueryCacheValidator.php b/src/Cache/QueryCacheValidator.php similarity index 100% rename from lib/Doctrine/ORM/Cache/QueryCacheValidator.php rename to src/Cache/QueryCacheValidator.php diff --git a/lib/Doctrine/ORM/Cache/Region.php b/src/Cache/Region.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Region.php rename to src/Cache/Region.php diff --git a/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php b/src/Cache/Region/DefaultRegion.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Region/DefaultRegion.php rename to src/Cache/Region/DefaultRegion.php diff --git a/lib/Doctrine/ORM/Cache/Region/FileLockRegion.php b/src/Cache/Region/FileLockRegion.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Region/FileLockRegion.php rename to src/Cache/Region/FileLockRegion.php diff --git a/lib/Doctrine/ORM/Cache/Region/UpdateTimestampCache.php b/src/Cache/Region/UpdateTimestampCache.php similarity index 100% rename from lib/Doctrine/ORM/Cache/Region/UpdateTimestampCache.php rename to src/Cache/Region/UpdateTimestampCache.php diff --git a/lib/Doctrine/ORM/Cache/RegionsConfiguration.php b/src/Cache/RegionsConfiguration.php similarity index 100% rename from lib/Doctrine/ORM/Cache/RegionsConfiguration.php rename to src/Cache/RegionsConfiguration.php diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheEntry.php b/src/Cache/TimestampCacheEntry.php similarity index 100% rename from lib/Doctrine/ORM/Cache/TimestampCacheEntry.php rename to src/Cache/TimestampCacheEntry.php diff --git a/lib/Doctrine/ORM/Cache/TimestampCacheKey.php b/src/Cache/TimestampCacheKey.php similarity index 100% rename from lib/Doctrine/ORM/Cache/TimestampCacheKey.php rename to src/Cache/TimestampCacheKey.php diff --git a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php b/src/Cache/TimestampQueryCacheValidator.php similarity index 100% rename from lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php rename to src/Cache/TimestampQueryCacheValidator.php diff --git a/lib/Doctrine/ORM/Cache/TimestampRegion.php b/src/Cache/TimestampRegion.php similarity index 100% rename from lib/Doctrine/ORM/Cache/TimestampRegion.php rename to src/Cache/TimestampRegion.php diff --git a/lib/Doctrine/ORM/Configuration.php b/src/Configuration.php similarity index 100% rename from lib/Doctrine/ORM/Configuration.php rename to src/Configuration.php diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/src/Decorator/EntityManagerDecorator.php similarity index 100% rename from lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php rename to src/Decorator/EntityManagerDecorator.php diff --git a/lib/Doctrine/ORM/EntityManager.php b/src/EntityManager.php similarity index 100% rename from lib/Doctrine/ORM/EntityManager.php rename to src/EntityManager.php diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/src/EntityManagerInterface.php similarity index 100% rename from lib/Doctrine/ORM/EntityManagerInterface.php rename to src/EntityManagerInterface.php diff --git a/lib/Doctrine/ORM/EntityNotFoundException.php b/src/EntityNotFoundException.php similarity index 100% rename from lib/Doctrine/ORM/EntityNotFoundException.php rename to src/EntityNotFoundException.php diff --git a/lib/Doctrine/ORM/EntityRepository.php b/src/EntityRepository.php similarity index 100% rename from lib/Doctrine/ORM/EntityRepository.php rename to src/EntityRepository.php diff --git a/lib/Doctrine/ORM/Event/ListenersInvoker.php b/src/Event/ListenersInvoker.php similarity index 100% rename from lib/Doctrine/ORM/Event/ListenersInvoker.php rename to src/Event/ListenersInvoker.php diff --git a/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php b/src/Event/LoadClassMetadataEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php rename to src/Event/LoadClassMetadataEventArgs.php diff --git a/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php b/src/Event/OnClassMetadataNotFoundEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php rename to src/Event/OnClassMetadataNotFoundEventArgs.php diff --git a/lib/Doctrine/ORM/Event/OnClearEventArgs.php b/src/Event/OnClearEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/OnClearEventArgs.php rename to src/Event/OnClearEventArgs.php diff --git a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php b/src/Event/OnFlushEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/OnFlushEventArgs.php rename to src/Event/OnFlushEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PostFlushEventArgs.php b/src/Event/PostFlushEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PostFlushEventArgs.php rename to src/Event/PostFlushEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PostLoadEventArgs.php b/src/Event/PostLoadEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PostLoadEventArgs.php rename to src/Event/PostLoadEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PostPersistEventArgs.php b/src/Event/PostPersistEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PostPersistEventArgs.php rename to src/Event/PostPersistEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PostRemoveEventArgs.php b/src/Event/PostRemoveEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PostRemoveEventArgs.php rename to src/Event/PostRemoveEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PostUpdateEventArgs.php b/src/Event/PostUpdateEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PostUpdateEventArgs.php rename to src/Event/PostUpdateEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php b/src/Event/PreFlushEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PreFlushEventArgs.php rename to src/Event/PreFlushEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PrePersistEventArgs.php b/src/Event/PrePersistEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PrePersistEventArgs.php rename to src/Event/PrePersistEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PreRemoveEventArgs.php b/src/Event/PreRemoveEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PreRemoveEventArgs.php rename to src/Event/PreRemoveEventArgs.php diff --git a/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php b/src/Event/PreUpdateEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Event/PreUpdateEventArgs.php rename to src/Event/PreUpdateEventArgs.php diff --git a/lib/Doctrine/ORM/Events.php b/src/Events.php similarity index 100% rename from lib/Doctrine/ORM/Events.php rename to src/Events.php diff --git a/lib/Doctrine/ORM/Exception/ConfigurationException.php b/src/Exception/ConfigurationException.php similarity index 100% rename from lib/Doctrine/ORM/Exception/ConfigurationException.php rename to src/Exception/ConfigurationException.php diff --git a/lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php b/src/Exception/EntityIdentityCollisionException.php similarity index 100% rename from lib/Doctrine/ORM/Exception/EntityIdentityCollisionException.php rename to src/Exception/EntityIdentityCollisionException.php diff --git a/lib/Doctrine/ORM/Exception/EntityManagerClosed.php b/src/Exception/EntityManagerClosed.php similarity index 100% rename from lib/Doctrine/ORM/Exception/EntityManagerClosed.php rename to src/Exception/EntityManagerClosed.php diff --git a/lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php b/src/Exception/EntityMissingAssignedId.php similarity index 100% rename from lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php rename to src/Exception/EntityMissingAssignedId.php diff --git a/lib/Doctrine/ORM/Exception/InvalidEntityRepository.php b/src/Exception/InvalidEntityRepository.php similarity index 100% rename from lib/Doctrine/ORM/Exception/InvalidEntityRepository.php rename to src/Exception/InvalidEntityRepository.php diff --git a/lib/Doctrine/ORM/Exception/InvalidHydrationMode.php b/src/Exception/InvalidHydrationMode.php similarity index 100% rename from lib/Doctrine/ORM/Exception/InvalidHydrationMode.php rename to src/Exception/InvalidHydrationMode.php diff --git a/lib/Doctrine/ORM/Exception/ManagerException.php b/src/Exception/ManagerException.php similarity index 100% rename from lib/Doctrine/ORM/Exception/ManagerException.php rename to src/Exception/ManagerException.php diff --git a/lib/Doctrine/ORM/Exception/MissingIdentifierField.php b/src/Exception/MissingIdentifierField.php similarity index 100% rename from lib/Doctrine/ORM/Exception/MissingIdentifierField.php rename to src/Exception/MissingIdentifierField.php diff --git a/lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php b/src/Exception/MissingMappingDriverImplementation.php similarity index 100% rename from lib/Doctrine/ORM/Exception/MissingMappingDriverImplementation.php rename to src/Exception/MissingMappingDriverImplementation.php diff --git a/lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php b/src/Exception/MultipleSelectorsFoundException.php similarity index 100% rename from lib/Doctrine/ORM/Exception/MultipleSelectorsFoundException.php rename to src/Exception/MultipleSelectorsFoundException.php diff --git a/lib/Doctrine/ORM/Exception/NotSupported.php b/src/Exception/NotSupported.php similarity index 100% rename from lib/Doctrine/ORM/Exception/NotSupported.php rename to src/Exception/NotSupported.php diff --git a/lib/Doctrine/ORM/Exception/ORMException.php b/src/Exception/ORMException.php similarity index 100% rename from lib/Doctrine/ORM/Exception/ORMException.php rename to src/Exception/ORMException.php diff --git a/lib/Doctrine/ORM/Exception/PersisterException.php b/src/Exception/PersisterException.php similarity index 100% rename from lib/Doctrine/ORM/Exception/PersisterException.php rename to src/Exception/PersisterException.php diff --git a/lib/Doctrine/ORM/Exception/RepositoryException.php b/src/Exception/RepositoryException.php similarity index 100% rename from lib/Doctrine/ORM/Exception/RepositoryException.php rename to src/Exception/RepositoryException.php diff --git a/lib/Doctrine/ORM/Exception/SchemaToolException.php b/src/Exception/SchemaToolException.php similarity index 100% rename from lib/Doctrine/ORM/Exception/SchemaToolException.php rename to src/Exception/SchemaToolException.php diff --git a/lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php b/src/Exception/UnexpectedAssociationValue.php similarity index 100% rename from lib/Doctrine/ORM/Exception/UnexpectedAssociationValue.php rename to src/Exception/UnexpectedAssociationValue.php diff --git a/lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php b/src/Exception/UnrecognizedIdentifierFields.php similarity index 100% rename from lib/Doctrine/ORM/Exception/UnrecognizedIdentifierFields.php rename to src/Exception/UnrecognizedIdentifierFields.php diff --git a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php b/src/Id/AbstractIdGenerator.php similarity index 100% rename from lib/Doctrine/ORM/Id/AbstractIdGenerator.php rename to src/Id/AbstractIdGenerator.php diff --git a/lib/Doctrine/ORM/Id/AssignedGenerator.php b/src/Id/AssignedGenerator.php similarity index 100% rename from lib/Doctrine/ORM/Id/AssignedGenerator.php rename to src/Id/AssignedGenerator.php diff --git a/lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php b/src/Id/BigIntegerIdentityGenerator.php similarity index 100% rename from lib/Doctrine/ORM/Id/BigIntegerIdentityGenerator.php rename to src/Id/BigIntegerIdentityGenerator.php diff --git a/lib/Doctrine/ORM/Id/IdentityGenerator.php b/src/Id/IdentityGenerator.php similarity index 100% rename from lib/Doctrine/ORM/Id/IdentityGenerator.php rename to src/Id/IdentityGenerator.php diff --git a/lib/Doctrine/ORM/Id/SequenceGenerator.php b/src/Id/SequenceGenerator.php similarity index 100% rename from lib/Doctrine/ORM/Id/SequenceGenerator.php rename to src/Id/SequenceGenerator.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/src/Internal/Hydration/AbstractHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php rename to src/Internal/Hydration/AbstractHydrator.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/src/Internal/Hydration/ArrayHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php rename to src/Internal/Hydration/ArrayHydrator.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/HydrationException.php b/src/Internal/Hydration/HydrationException.php similarity index 100% rename from lib/Doctrine/ORM/Internal/Hydration/HydrationException.php rename to src/Internal/Hydration/HydrationException.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/src/Internal/Hydration/ObjectHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php rename to src/Internal/Hydration/ObjectHydrator.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/ScalarColumnHydrator.php b/src/Internal/Hydration/ScalarColumnHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Internal/Hydration/ScalarColumnHydrator.php rename to src/Internal/Hydration/ScalarColumnHydrator.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php b/src/Internal/Hydration/ScalarHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php rename to src/Internal/Hydration/ScalarHydrator.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/src/Internal/Hydration/SimpleObjectHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php rename to src/Internal/Hydration/SimpleObjectHydrator.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php b/src/Internal/Hydration/SingleScalarHydrator.php similarity index 100% rename from lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php rename to src/Internal/Hydration/SingleScalarHydrator.php diff --git a/lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php b/src/Internal/HydrationCompleteHandler.php similarity index 100% rename from lib/Doctrine/ORM/Internal/HydrationCompleteHandler.php rename to src/Internal/HydrationCompleteHandler.php diff --git a/lib/Doctrine/ORM/Internal/QueryType.php b/src/Internal/QueryType.php similarity index 100% rename from lib/Doctrine/ORM/Internal/QueryType.php rename to src/Internal/QueryType.php diff --git a/lib/Doctrine/ORM/Internal/SQLResultCasing.php b/src/Internal/SQLResultCasing.php similarity index 100% rename from lib/Doctrine/ORM/Internal/SQLResultCasing.php rename to src/Internal/SQLResultCasing.php diff --git a/lib/Doctrine/ORM/Internal/TopologicalSort.php b/src/Internal/TopologicalSort.php similarity index 100% rename from lib/Doctrine/ORM/Internal/TopologicalSort.php rename to src/Internal/TopologicalSort.php diff --git a/lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php b/src/Internal/TopologicalSort/CycleDetectedException.php similarity index 100% rename from lib/Doctrine/ORM/Internal/TopologicalSort/CycleDetectedException.php rename to src/Internal/TopologicalSort/CycleDetectedException.php diff --git a/lib/Doctrine/ORM/LazyCriteriaCollection.php b/src/LazyCriteriaCollection.php similarity index 100% rename from lib/Doctrine/ORM/LazyCriteriaCollection.php rename to src/LazyCriteriaCollection.php diff --git a/lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php b/src/Mapping/AnsiQuoteStrategy.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/AnsiQuoteStrategy.php rename to src/Mapping/AnsiQuoteStrategy.php diff --git a/lib/Doctrine/ORM/Mapping/ArrayAccessImplementation.php b/src/Mapping/ArrayAccessImplementation.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ArrayAccessImplementation.php rename to src/Mapping/ArrayAccessImplementation.php diff --git a/lib/Doctrine/ORM/Mapping/AssociationMapping.php b/src/Mapping/AssociationMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/AssociationMapping.php rename to src/Mapping/AssociationMapping.php diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverride.php b/src/Mapping/AssociationOverride.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/AssociationOverride.php rename to src/Mapping/AssociationOverride.php diff --git a/lib/Doctrine/ORM/Mapping/AssociationOverrides.php b/src/Mapping/AssociationOverrides.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/AssociationOverrides.php rename to src/Mapping/AssociationOverrides.php diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverride.php b/src/Mapping/AttributeOverride.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/AttributeOverride.php rename to src/Mapping/AttributeOverride.php diff --git a/lib/Doctrine/ORM/Mapping/AttributeOverrides.php b/src/Mapping/AttributeOverrides.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/AttributeOverrides.php rename to src/Mapping/AttributeOverrides.php diff --git a/lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php b/src/Mapping/Builder/AssociationBuilder.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Builder/AssociationBuilder.php rename to src/Mapping/Builder/AssociationBuilder.php diff --git a/lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php b/src/Mapping/Builder/ClassMetadataBuilder.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Builder/ClassMetadataBuilder.php rename to src/Mapping/Builder/ClassMetadataBuilder.php diff --git a/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php b/src/Mapping/Builder/EmbeddedBuilder.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php rename to src/Mapping/Builder/EmbeddedBuilder.php diff --git a/lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php b/src/Mapping/Builder/EntityListenerBuilder.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Builder/EntityListenerBuilder.php rename to src/Mapping/Builder/EntityListenerBuilder.php diff --git a/lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php b/src/Mapping/Builder/FieldBuilder.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Builder/FieldBuilder.php rename to src/Mapping/Builder/FieldBuilder.php diff --git a/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php b/src/Mapping/Builder/ManyToManyAssociationBuilder.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php rename to src/Mapping/Builder/ManyToManyAssociationBuilder.php diff --git a/lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php b/src/Mapping/Builder/OneToManyAssociationBuilder.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Builder/OneToManyAssociationBuilder.php rename to src/Mapping/Builder/OneToManyAssociationBuilder.php diff --git a/lib/Doctrine/ORM/Mapping/Cache.php b/src/Mapping/Cache.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Cache.php rename to src/Mapping/Cache.php diff --git a/lib/Doctrine/ORM/Mapping/ChainTypedFieldMapper.php b/src/Mapping/ChainTypedFieldMapper.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ChainTypedFieldMapper.php rename to src/Mapping/ChainTypedFieldMapper.php diff --git a/lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php b/src/Mapping/ChangeTrackingPolicy.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ChangeTrackingPolicy.php rename to src/Mapping/ChangeTrackingPolicy.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ClassMetadata.php rename to src/Mapping/ClassMetadata.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/src/Mapping/ClassMetadataFactory.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php rename to src/Mapping/ClassMetadataFactory.php diff --git a/lib/Doctrine/ORM/Mapping/Column.php b/src/Mapping/Column.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Column.php rename to src/Mapping/Column.php diff --git a/lib/Doctrine/ORM/Mapping/CustomIdGenerator.php b/src/Mapping/CustomIdGenerator.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/CustomIdGenerator.php rename to src/Mapping/CustomIdGenerator.php diff --git a/lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php b/src/Mapping/DefaultEntityListenerResolver.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php rename to src/Mapping/DefaultEntityListenerResolver.php diff --git a/lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php b/src/Mapping/DefaultNamingStrategy.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/DefaultNamingStrategy.php rename to src/Mapping/DefaultNamingStrategy.php diff --git a/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php b/src/Mapping/DefaultQuoteStrategy.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php rename to src/Mapping/DefaultQuoteStrategy.php diff --git a/lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php b/src/Mapping/DefaultTypedFieldMapper.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/DefaultTypedFieldMapper.php rename to src/Mapping/DefaultTypedFieldMapper.php diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php b/src/Mapping/DiscriminatorColumn.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/DiscriminatorColumn.php rename to src/Mapping/DiscriminatorColumn.php diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorColumnMapping.php b/src/Mapping/DiscriminatorColumnMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/DiscriminatorColumnMapping.php rename to src/Mapping/DiscriminatorColumnMapping.php diff --git a/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php b/src/Mapping/DiscriminatorMap.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/DiscriminatorMap.php rename to src/Mapping/DiscriminatorMap.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/src/Mapping/Driver/AttributeDriver.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php rename to src/Mapping/Driver/AttributeDriver.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php b/src/Mapping/Driver/AttributeReader.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Driver/AttributeReader.php rename to src/Mapping/Driver/AttributeReader.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/src/Mapping/Driver/DatabaseDriver.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php rename to src/Mapping/Driver/DatabaseDriver.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php b/src/Mapping/Driver/ReflectionBasedDriver.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php rename to src/Mapping/Driver/ReflectionBasedDriver.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/RepeatableAttributeCollection.php b/src/Mapping/Driver/RepeatableAttributeCollection.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Driver/RepeatableAttributeCollection.php rename to src/Mapping/Driver/RepeatableAttributeCollection.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php b/src/Mapping/Driver/SimplifiedXmlDriver.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php rename to src/Mapping/Driver/SimplifiedXmlDriver.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/src/Mapping/Driver/XmlDriver.php similarity index 99% rename from lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php rename to src/Mapping/Driver/XmlDriver.php index dafd468176a..6da790955d1 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/src/Mapping/Driver/XmlDriver.php @@ -920,7 +920,7 @@ private function validateMapping(string $file): void $document = new DOMDocument(); $document->load($file); - if (! $document->schemaValidate(__DIR__ . '/../../../../../doctrine-mapping.xsd')) { + if (! $document->schemaValidate(__DIR__ . '/../../../doctrine-mapping.xsd')) { throw MappingException::fromLibXmlErrors(libxml_get_errors()); } } finally { diff --git a/lib/Doctrine/ORM/Mapping/Embeddable.php b/src/Mapping/Embeddable.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Embeddable.php rename to src/Mapping/Embeddable.php diff --git a/lib/Doctrine/ORM/Mapping/Embedded.php b/src/Mapping/Embedded.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Embedded.php rename to src/Mapping/Embedded.php diff --git a/lib/Doctrine/ORM/Mapping/EmbeddedClassMapping.php b/src/Mapping/EmbeddedClassMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/EmbeddedClassMapping.php rename to src/Mapping/EmbeddedClassMapping.php diff --git a/lib/Doctrine/ORM/Mapping/Entity.php b/src/Mapping/Entity.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Entity.php rename to src/Mapping/Entity.php diff --git a/lib/Doctrine/ORM/Mapping/EntityListenerResolver.php b/src/Mapping/EntityListenerResolver.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/EntityListenerResolver.php rename to src/Mapping/EntityListenerResolver.php diff --git a/lib/Doctrine/ORM/Mapping/EntityListeners.php b/src/Mapping/EntityListeners.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/EntityListeners.php rename to src/Mapping/EntityListeners.php diff --git a/lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php b/src/Mapping/Exception/InvalidCustomGenerator.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Exception/InvalidCustomGenerator.php rename to src/Mapping/Exception/InvalidCustomGenerator.php diff --git a/lib/Doctrine/ORM/Mapping/Exception/UnknownGeneratorType.php b/src/Mapping/Exception/UnknownGeneratorType.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Exception/UnknownGeneratorType.php rename to src/Mapping/Exception/UnknownGeneratorType.php diff --git a/lib/Doctrine/ORM/Mapping/FieldMapping.php b/src/Mapping/FieldMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/FieldMapping.php rename to src/Mapping/FieldMapping.php diff --git a/lib/Doctrine/ORM/Mapping/GeneratedValue.php b/src/Mapping/GeneratedValue.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/GeneratedValue.php rename to src/Mapping/GeneratedValue.php diff --git a/lib/Doctrine/ORM/Mapping/HasLifecycleCallbacks.php b/src/Mapping/HasLifecycleCallbacks.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/HasLifecycleCallbacks.php rename to src/Mapping/HasLifecycleCallbacks.php diff --git a/lib/Doctrine/ORM/Mapping/Id.php b/src/Mapping/Id.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Id.php rename to src/Mapping/Id.php diff --git a/lib/Doctrine/ORM/Mapping/Index.php b/src/Mapping/Index.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Index.php rename to src/Mapping/Index.php diff --git a/lib/Doctrine/ORM/Mapping/InheritanceType.php b/src/Mapping/InheritanceType.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/InheritanceType.php rename to src/Mapping/InheritanceType.php diff --git a/lib/Doctrine/ORM/Mapping/InverseJoinColumn.php b/src/Mapping/InverseJoinColumn.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/InverseJoinColumn.php rename to src/Mapping/InverseJoinColumn.php diff --git a/lib/Doctrine/ORM/Mapping/InverseSideMapping.php b/src/Mapping/InverseSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/InverseSideMapping.php rename to src/Mapping/InverseSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/JoinColumn.php b/src/Mapping/JoinColumn.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/JoinColumn.php rename to src/Mapping/JoinColumn.php diff --git a/lib/Doctrine/ORM/Mapping/JoinColumnMapping.php b/src/Mapping/JoinColumnMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/JoinColumnMapping.php rename to src/Mapping/JoinColumnMapping.php diff --git a/lib/Doctrine/ORM/Mapping/JoinColumnProperties.php b/src/Mapping/JoinColumnProperties.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/JoinColumnProperties.php rename to src/Mapping/JoinColumnProperties.php diff --git a/lib/Doctrine/ORM/Mapping/JoinColumns.php b/src/Mapping/JoinColumns.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/JoinColumns.php rename to src/Mapping/JoinColumns.php diff --git a/lib/Doctrine/ORM/Mapping/JoinTable.php b/src/Mapping/JoinTable.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/JoinTable.php rename to src/Mapping/JoinTable.php diff --git a/lib/Doctrine/ORM/Mapping/JoinTableMapping.php b/src/Mapping/JoinTableMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/JoinTableMapping.php rename to src/Mapping/JoinTableMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ManyToMany.php b/src/Mapping/ManyToMany.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ManyToMany.php rename to src/Mapping/ManyToMany.php diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php b/src/Mapping/ManyToManyAssociationMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ManyToManyAssociationMapping.php rename to src/Mapping/ManyToManyAssociationMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyInverseSideMapping.php b/src/Mapping/ManyToManyInverseSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ManyToManyInverseSideMapping.php rename to src/Mapping/ManyToManyInverseSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php b/src/Mapping/ManyToManyOwningSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ManyToManyOwningSideMapping.php rename to src/Mapping/ManyToManyOwningSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ManyToOne.php b/src/Mapping/ManyToOne.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ManyToOne.php rename to src/Mapping/ManyToOne.php diff --git a/lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php b/src/Mapping/ManyToOneAssociationMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ManyToOneAssociationMapping.php rename to src/Mapping/ManyToOneAssociationMapping.php diff --git a/lib/Doctrine/ORM/Mapping/MappedSuperclass.php b/src/Mapping/MappedSuperclass.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/MappedSuperclass.php rename to src/Mapping/MappedSuperclass.php diff --git a/lib/Doctrine/ORM/Mapping/MappingAttribute.php b/src/Mapping/MappingAttribute.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/MappingAttribute.php rename to src/Mapping/MappingAttribute.php diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/src/Mapping/MappingException.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/MappingException.php rename to src/Mapping/MappingException.php diff --git a/lib/Doctrine/ORM/Mapping/NamingStrategy.php b/src/Mapping/NamingStrategy.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/NamingStrategy.php rename to src/Mapping/NamingStrategy.php diff --git a/lib/Doctrine/ORM/Mapping/OneToMany.php b/src/Mapping/OneToMany.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/OneToMany.php rename to src/Mapping/OneToMany.php diff --git a/lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php b/src/Mapping/OneToManyAssociationMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/OneToManyAssociationMapping.php rename to src/Mapping/OneToManyAssociationMapping.php diff --git a/lib/Doctrine/ORM/Mapping/OneToOne.php b/src/Mapping/OneToOne.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/OneToOne.php rename to src/Mapping/OneToOne.php diff --git a/lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php b/src/Mapping/OneToOneAssociationMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/OneToOneAssociationMapping.php rename to src/Mapping/OneToOneAssociationMapping.php diff --git a/lib/Doctrine/ORM/Mapping/OneToOneInverseSideMapping.php b/src/Mapping/OneToOneInverseSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/OneToOneInverseSideMapping.php rename to src/Mapping/OneToOneInverseSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/OneToOneOwningSideMapping.php b/src/Mapping/OneToOneOwningSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/OneToOneOwningSideMapping.php rename to src/Mapping/OneToOneOwningSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/OrderBy.php b/src/Mapping/OrderBy.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/OrderBy.php rename to src/Mapping/OrderBy.php diff --git a/lib/Doctrine/ORM/Mapping/OwningSideMapping.php b/src/Mapping/OwningSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/OwningSideMapping.php rename to src/Mapping/OwningSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/PostLoad.php b/src/Mapping/PostLoad.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/PostLoad.php rename to src/Mapping/PostLoad.php diff --git a/lib/Doctrine/ORM/Mapping/PostPersist.php b/src/Mapping/PostPersist.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/PostPersist.php rename to src/Mapping/PostPersist.php diff --git a/lib/Doctrine/ORM/Mapping/PostRemove.php b/src/Mapping/PostRemove.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/PostRemove.php rename to src/Mapping/PostRemove.php diff --git a/lib/Doctrine/ORM/Mapping/PostUpdate.php b/src/Mapping/PostUpdate.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/PostUpdate.php rename to src/Mapping/PostUpdate.php diff --git a/lib/Doctrine/ORM/Mapping/PreFlush.php b/src/Mapping/PreFlush.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/PreFlush.php rename to src/Mapping/PreFlush.php diff --git a/lib/Doctrine/ORM/Mapping/PrePersist.php b/src/Mapping/PrePersist.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/PrePersist.php rename to src/Mapping/PrePersist.php diff --git a/lib/Doctrine/ORM/Mapping/PreRemove.php b/src/Mapping/PreRemove.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/PreRemove.php rename to src/Mapping/PreRemove.php diff --git a/lib/Doctrine/ORM/Mapping/PreUpdate.php b/src/Mapping/PreUpdate.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/PreUpdate.php rename to src/Mapping/PreUpdate.php diff --git a/lib/Doctrine/ORM/Mapping/QuoteStrategy.php b/src/Mapping/QuoteStrategy.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/QuoteStrategy.php rename to src/Mapping/QuoteStrategy.php diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php b/src/Mapping/ReflectionEmbeddedProperty.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php rename to src/Mapping/ReflectionEmbeddedProperty.php diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php b/src/Mapping/ReflectionEnumProperty.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ReflectionEnumProperty.php rename to src/Mapping/ReflectionEnumProperty.php diff --git a/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php b/src/Mapping/ReflectionReadonlyProperty.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php rename to src/Mapping/ReflectionReadonlyProperty.php diff --git a/lib/Doctrine/ORM/Mapping/SequenceGenerator.php b/src/Mapping/SequenceGenerator.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/SequenceGenerator.php rename to src/Mapping/SequenceGenerator.php diff --git a/lib/Doctrine/ORM/Mapping/Table.php b/src/Mapping/Table.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Table.php rename to src/Mapping/Table.php diff --git a/lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php b/src/Mapping/ToManyAssociationMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ToManyAssociationMapping.php rename to src/Mapping/ToManyAssociationMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php b/src/Mapping/ToManyAssociationMappingImplementation.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ToManyAssociationMappingImplementation.php rename to src/Mapping/ToManyAssociationMappingImplementation.php diff --git a/lib/Doctrine/ORM/Mapping/ToManyInverseSideMapping.php b/src/Mapping/ToManyInverseSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ToManyInverseSideMapping.php rename to src/Mapping/ToManyInverseSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ToManyOwningSideMapping.php b/src/Mapping/ToManyOwningSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ToManyOwningSideMapping.php rename to src/Mapping/ToManyOwningSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php b/src/Mapping/ToOneAssociationMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php rename to src/Mapping/ToOneAssociationMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ToOneInverseSideMapping.php b/src/Mapping/ToOneInverseSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ToOneInverseSideMapping.php rename to src/Mapping/ToOneInverseSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php b/src/Mapping/ToOneOwningSideMapping.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/ToOneOwningSideMapping.php rename to src/Mapping/ToOneOwningSideMapping.php diff --git a/lib/Doctrine/ORM/Mapping/TypedFieldMapper.php b/src/Mapping/TypedFieldMapper.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/TypedFieldMapper.php rename to src/Mapping/TypedFieldMapper.php diff --git a/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php b/src/Mapping/UnderscoreNamingStrategy.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php rename to src/Mapping/UnderscoreNamingStrategy.php diff --git a/lib/Doctrine/ORM/Mapping/UniqueConstraint.php b/src/Mapping/UniqueConstraint.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/UniqueConstraint.php rename to src/Mapping/UniqueConstraint.php diff --git a/lib/Doctrine/ORM/Mapping/Version.php b/src/Mapping/Version.php similarity index 100% rename from lib/Doctrine/ORM/Mapping/Version.php rename to src/Mapping/Version.php diff --git a/lib/Doctrine/ORM/NativeQuery.php b/src/NativeQuery.php similarity index 100% rename from lib/Doctrine/ORM/NativeQuery.php rename to src/NativeQuery.php diff --git a/lib/Doctrine/ORM/NoResultException.php b/src/NoResultException.php similarity index 100% rename from lib/Doctrine/ORM/NoResultException.php rename to src/NoResultException.php diff --git a/lib/Doctrine/ORM/NonUniqueResultException.php b/src/NonUniqueResultException.php similarity index 100% rename from lib/Doctrine/ORM/NonUniqueResultException.php rename to src/NonUniqueResultException.php diff --git a/lib/Doctrine/ORM/ORMInvalidArgumentException.php b/src/ORMInvalidArgumentException.php similarity index 100% rename from lib/Doctrine/ORM/ORMInvalidArgumentException.php rename to src/ORMInvalidArgumentException.php diff --git a/lib/Doctrine/ORM/ORMSetup.php b/src/ORMSetup.php similarity index 100% rename from lib/Doctrine/ORM/ORMSetup.php rename to src/ORMSetup.php diff --git a/lib/Doctrine/ORM/OptimisticLockException.php b/src/OptimisticLockException.php similarity index 100% rename from lib/Doctrine/ORM/OptimisticLockException.php rename to src/OptimisticLockException.php diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/src/PersistentCollection.php similarity index 100% rename from lib/Doctrine/ORM/PersistentCollection.php rename to src/PersistentCollection.php diff --git a/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php b/src/Persisters/Collection/AbstractCollectionPersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php rename to src/Persisters/Collection/AbstractCollectionPersister.php diff --git a/lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php b/src/Persisters/Collection/CollectionPersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Collection/CollectionPersister.php rename to src/Persisters/Collection/CollectionPersister.php diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/src/Persisters/Collection/ManyToManyPersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php rename to src/Persisters/Collection/ManyToManyPersister.php diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/src/Persisters/Collection/OneToManyPersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php rename to src/Persisters/Collection/OneToManyPersister.php diff --git a/lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php b/src/Persisters/Entity/AbstractEntityInheritancePersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Entity/AbstractEntityInheritancePersister.php rename to src/Persisters/Entity/AbstractEntityInheritancePersister.php diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php rename to src/Persisters/Entity/BasicEntityPersister.php diff --git a/lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php b/src/Persisters/Entity/CachedPersisterContext.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Entity/CachedPersisterContext.php rename to src/Persisters/Entity/CachedPersisterContext.php diff --git a/lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php b/src/Persisters/Entity/EntityPersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php rename to src/Persisters/Entity/EntityPersister.php diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/src/Persisters/Entity/JoinedSubclassPersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php rename to src/Persisters/Entity/JoinedSubclassPersister.php diff --git a/lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php b/src/Persisters/Entity/SingleTablePersister.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Entity/SingleTablePersister.php rename to src/Persisters/Entity/SingleTablePersister.php diff --git a/lib/Doctrine/ORM/Persisters/Exception/CantUseInOperatorOnCompositeKeys.php b/src/Persisters/Exception/CantUseInOperatorOnCompositeKeys.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Exception/CantUseInOperatorOnCompositeKeys.php rename to src/Persisters/Exception/CantUseInOperatorOnCompositeKeys.php diff --git a/lib/Doctrine/ORM/Persisters/Exception/InvalidOrientation.php b/src/Persisters/Exception/InvalidOrientation.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Exception/InvalidOrientation.php rename to src/Persisters/Exception/InvalidOrientation.php diff --git a/lib/Doctrine/ORM/Persisters/Exception/UnrecognizedField.php b/src/Persisters/Exception/UnrecognizedField.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/Exception/UnrecognizedField.php rename to src/Persisters/Exception/UnrecognizedField.php diff --git a/lib/Doctrine/ORM/Persisters/MatchingAssociationFieldRequiresObject.php b/src/Persisters/MatchingAssociationFieldRequiresObject.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/MatchingAssociationFieldRequiresObject.php rename to src/Persisters/MatchingAssociationFieldRequiresObject.php diff --git a/lib/Doctrine/ORM/Persisters/PersisterException.php b/src/Persisters/PersisterException.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/PersisterException.php rename to src/Persisters/PersisterException.php diff --git a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php b/src/Persisters/SqlExpressionVisitor.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php rename to src/Persisters/SqlExpressionVisitor.php diff --git a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php b/src/Persisters/SqlValueVisitor.php similarity index 100% rename from lib/Doctrine/ORM/Persisters/SqlValueVisitor.php rename to src/Persisters/SqlValueVisitor.php diff --git a/lib/Doctrine/ORM/PessimisticLockException.php b/src/PessimisticLockException.php similarity index 100% rename from lib/Doctrine/ORM/PessimisticLockException.php rename to src/PessimisticLockException.php diff --git a/lib/Doctrine/ORM/Proxy/Autoloader.php b/src/Proxy/Autoloader.php similarity index 100% rename from lib/Doctrine/ORM/Proxy/Autoloader.php rename to src/Proxy/Autoloader.php diff --git a/lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php b/src/Proxy/DefaultProxyClassNameResolver.php similarity index 100% rename from lib/Doctrine/ORM/Proxy/DefaultProxyClassNameResolver.php rename to src/Proxy/DefaultProxyClassNameResolver.php diff --git a/lib/Doctrine/ORM/Proxy/InternalProxy.php b/src/Proxy/InternalProxy.php similarity index 100% rename from lib/Doctrine/ORM/Proxy/InternalProxy.php rename to src/Proxy/InternalProxy.php diff --git a/lib/Doctrine/ORM/Proxy/NotAProxyClass.php b/src/Proxy/NotAProxyClass.php similarity index 100% rename from lib/Doctrine/ORM/Proxy/NotAProxyClass.php rename to src/Proxy/NotAProxyClass.php diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/src/Proxy/ProxyFactory.php similarity index 100% rename from lib/Doctrine/ORM/Proxy/ProxyFactory.php rename to src/Proxy/ProxyFactory.php diff --git a/lib/Doctrine/ORM/Query.php b/src/Query.php similarity index 100% rename from lib/Doctrine/ORM/Query.php rename to src/Query.php diff --git a/lib/Doctrine/ORM/Query/AST/ASTException.php b/src/Query/AST/ASTException.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ASTException.php rename to src/Query/AST/ASTException.php diff --git a/lib/Doctrine/ORM/Query/AST/AggregateExpression.php b/src/Query/AST/AggregateExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/AggregateExpression.php rename to src/Query/AST/AggregateExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php b/src/Query/AST/ArithmeticExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ArithmeticExpression.php rename to src/Query/AST/ArithmeticExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php b/src/Query/AST/ArithmeticFactor.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ArithmeticFactor.php rename to src/Query/AST/ArithmeticFactor.php diff --git a/lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php b/src/Query/AST/ArithmeticTerm.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ArithmeticTerm.php rename to src/Query/AST/ArithmeticTerm.php diff --git a/lib/Doctrine/ORM/Query/AST/BetweenExpression.php b/src/Query/AST/BetweenExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/BetweenExpression.php rename to src/Query/AST/BetweenExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/CoalesceExpression.php b/src/Query/AST/CoalesceExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/CoalesceExpression.php rename to src/Query/AST/CoalesceExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php b/src/Query/AST/CollectionMemberExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/CollectionMemberExpression.php rename to src/Query/AST/CollectionMemberExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/ComparisonExpression.php b/src/Query/AST/ComparisonExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ComparisonExpression.php rename to src/Query/AST/ComparisonExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalExpression.php b/src/Query/AST/ConditionalExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ConditionalExpression.php rename to src/Query/AST/ConditionalExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalFactor.php b/src/Query/AST/ConditionalFactor.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ConditionalFactor.php rename to src/Query/AST/ConditionalFactor.php diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php b/src/Query/AST/ConditionalPrimary.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ConditionalPrimary.php rename to src/Query/AST/ConditionalPrimary.php diff --git a/lib/Doctrine/ORM/Query/AST/ConditionalTerm.php b/src/Query/AST/ConditionalTerm.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ConditionalTerm.php rename to src/Query/AST/ConditionalTerm.php diff --git a/lib/Doctrine/ORM/Query/AST/DeleteClause.php b/src/Query/AST/DeleteClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/DeleteClause.php rename to src/Query/AST/DeleteClause.php diff --git a/lib/Doctrine/ORM/Query/AST/DeleteStatement.php b/src/Query/AST/DeleteStatement.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/DeleteStatement.php rename to src/Query/AST/DeleteStatement.php diff --git a/lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php b/src/Query/AST/EmptyCollectionComparisonExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/EmptyCollectionComparisonExpression.php rename to src/Query/AST/EmptyCollectionComparisonExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/ExistsExpression.php b/src/Query/AST/ExistsExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ExistsExpression.php rename to src/Query/AST/ExistsExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/FromClause.php b/src/Query/AST/FromClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/FromClause.php rename to src/Query/AST/FromClause.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php b/src/Query/AST/Functions/AbsFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/AbsFunction.php rename to src/Query/AST/Functions/AbsFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php b/src/Query/AST/Functions/AvgFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/AvgFunction.php rename to src/Query/AST/Functions/AvgFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php b/src/Query/AST/Functions/BitAndFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/BitAndFunction.php rename to src/Query/AST/Functions/BitAndFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php b/src/Query/AST/Functions/BitOrFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/BitOrFunction.php rename to src/Query/AST/Functions/BitOrFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php b/src/Query/AST/Functions/ConcatFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/ConcatFunction.php rename to src/Query/AST/Functions/ConcatFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php b/src/Query/AST/Functions/CountFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/CountFunction.php rename to src/Query/AST/Functions/CountFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php b/src/Query/AST/Functions/CurrentDateFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/CurrentDateFunction.php rename to src/Query/AST/Functions/CurrentDateFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php b/src/Query/AST/Functions/CurrentTimeFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/CurrentTimeFunction.php rename to src/Query/AST/Functions/CurrentTimeFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php b/src/Query/AST/Functions/CurrentTimestampFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/CurrentTimestampFunction.php rename to src/Query/AST/Functions/CurrentTimestampFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php b/src/Query/AST/Functions/DateAddFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php rename to src/Query/AST/Functions/DateAddFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php b/src/Query/AST/Functions/DateDiffFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/DateDiffFunction.php rename to src/Query/AST/Functions/DateDiffFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php b/src/Query/AST/Functions/DateSubFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php rename to src/Query/AST/Functions/DateSubFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php b/src/Query/AST/Functions/FunctionNode.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/FunctionNode.php rename to src/Query/AST/Functions/FunctionNode.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/src/Query/AST/Functions/IdentityFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php rename to src/Query/AST/Functions/IdentityFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php b/src/Query/AST/Functions/LengthFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/LengthFunction.php rename to src/Query/AST/Functions/LengthFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php b/src/Query/AST/Functions/LocateFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php rename to src/Query/AST/Functions/LocateFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php b/src/Query/AST/Functions/LowerFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/LowerFunction.php rename to src/Query/AST/Functions/LowerFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php b/src/Query/AST/Functions/MaxFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/MaxFunction.php rename to src/Query/AST/Functions/MaxFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php b/src/Query/AST/Functions/MinFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/MinFunction.php rename to src/Query/AST/Functions/MinFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php b/src/Query/AST/Functions/ModFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/ModFunction.php rename to src/Query/AST/Functions/ModFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php b/src/Query/AST/Functions/SizeFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/SizeFunction.php rename to src/Query/AST/Functions/SizeFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php b/src/Query/AST/Functions/SqrtFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/SqrtFunction.php rename to src/Query/AST/Functions/SqrtFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php b/src/Query/AST/Functions/SubstringFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php rename to src/Query/AST/Functions/SubstringFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php b/src/Query/AST/Functions/SumFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/SumFunction.php rename to src/Query/AST/Functions/SumFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php b/src/Query/AST/Functions/TrimFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/TrimFunction.php rename to src/Query/AST/Functions/TrimFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php b/src/Query/AST/Functions/UpperFunction.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Functions/UpperFunction.php rename to src/Query/AST/Functions/UpperFunction.php diff --git a/lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php b/src/Query/AST/GeneralCaseExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/GeneralCaseExpression.php rename to src/Query/AST/GeneralCaseExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/GroupByClause.php b/src/Query/AST/GroupByClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/GroupByClause.php rename to src/Query/AST/GroupByClause.php diff --git a/lib/Doctrine/ORM/Query/AST/HavingClause.php b/src/Query/AST/HavingClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/HavingClause.php rename to src/Query/AST/HavingClause.php diff --git a/lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php b/src/Query/AST/IdentificationVariableDeclaration.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/IdentificationVariableDeclaration.php rename to src/Query/AST/IdentificationVariableDeclaration.php diff --git a/lib/Doctrine/ORM/Query/AST/InListExpression.php b/src/Query/AST/InListExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/InListExpression.php rename to src/Query/AST/InListExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/InSubselectExpression.php b/src/Query/AST/InSubselectExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/InSubselectExpression.php rename to src/Query/AST/InSubselectExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/IndexBy.php b/src/Query/AST/IndexBy.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/IndexBy.php rename to src/Query/AST/IndexBy.php diff --git a/lib/Doctrine/ORM/Query/AST/InputParameter.php b/src/Query/AST/InputParameter.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/InputParameter.php rename to src/Query/AST/InputParameter.php diff --git a/lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php b/src/Query/AST/InstanceOfExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/InstanceOfExpression.php rename to src/Query/AST/InstanceOfExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/Join.php b/src/Query/AST/Join.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Join.php rename to src/Query/AST/Join.php diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php b/src/Query/AST/JoinAssociationDeclaration.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/JoinAssociationDeclaration.php rename to src/Query/AST/JoinAssociationDeclaration.php diff --git a/lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php b/src/Query/AST/JoinAssociationPathExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/JoinAssociationPathExpression.php rename to src/Query/AST/JoinAssociationPathExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php b/src/Query/AST/JoinClassPathExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/JoinClassPathExpression.php rename to src/Query/AST/JoinClassPathExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php b/src/Query/AST/JoinVariableDeclaration.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/JoinVariableDeclaration.php rename to src/Query/AST/JoinVariableDeclaration.php diff --git a/lib/Doctrine/ORM/Query/AST/LikeExpression.php b/src/Query/AST/LikeExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/LikeExpression.php rename to src/Query/AST/LikeExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/Literal.php b/src/Query/AST/Literal.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Literal.php rename to src/Query/AST/Literal.php diff --git a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php b/src/Query/AST/NewObjectExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/NewObjectExpression.php rename to src/Query/AST/NewObjectExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/Node.php b/src/Query/AST/Node.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Node.php rename to src/Query/AST/Node.php diff --git a/lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php b/src/Query/AST/NullComparisonExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/NullComparisonExpression.php rename to src/Query/AST/NullComparisonExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/NullIfExpression.php b/src/Query/AST/NullIfExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/NullIfExpression.php rename to src/Query/AST/NullIfExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/OrderByClause.php b/src/Query/AST/OrderByClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/OrderByClause.php rename to src/Query/AST/OrderByClause.php diff --git a/lib/Doctrine/ORM/Query/AST/OrderByItem.php b/src/Query/AST/OrderByItem.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/OrderByItem.php rename to src/Query/AST/OrderByItem.php diff --git a/lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php b/src/Query/AST/ParenthesisExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/ParenthesisExpression.php rename to src/Query/AST/ParenthesisExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/PathExpression.php b/src/Query/AST/PathExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/PathExpression.php rename to src/Query/AST/PathExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/Phase2OptimizableConditional.php b/src/Query/AST/Phase2OptimizableConditional.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Phase2OptimizableConditional.php rename to src/Query/AST/Phase2OptimizableConditional.php diff --git a/lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php b/src/Query/AST/QuantifiedExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/QuantifiedExpression.php rename to src/Query/AST/QuantifiedExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php b/src/Query/AST/RangeVariableDeclaration.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/RangeVariableDeclaration.php rename to src/Query/AST/RangeVariableDeclaration.php diff --git a/lib/Doctrine/ORM/Query/AST/SelectClause.php b/src/Query/AST/SelectClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SelectClause.php rename to src/Query/AST/SelectClause.php diff --git a/lib/Doctrine/ORM/Query/AST/SelectExpression.php b/src/Query/AST/SelectExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SelectExpression.php rename to src/Query/AST/SelectExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/SelectStatement.php b/src/Query/AST/SelectStatement.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SelectStatement.php rename to src/Query/AST/SelectStatement.php diff --git a/lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php b/src/Query/AST/SimpleArithmeticExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SimpleArithmeticExpression.php rename to src/Query/AST/SimpleArithmeticExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php b/src/Query/AST/SimpleCaseExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SimpleCaseExpression.php rename to src/Query/AST/SimpleCaseExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php b/src/Query/AST/SimpleSelectClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SimpleSelectClause.php rename to src/Query/AST/SimpleSelectClause.php diff --git a/lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php b/src/Query/AST/SimpleSelectExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SimpleSelectExpression.php rename to src/Query/AST/SimpleSelectExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php b/src/Query/AST/SimpleWhenClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SimpleWhenClause.php rename to src/Query/AST/SimpleWhenClause.php diff --git a/lib/Doctrine/ORM/Query/AST/Subselect.php b/src/Query/AST/Subselect.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/Subselect.php rename to src/Query/AST/Subselect.php diff --git a/lib/Doctrine/ORM/Query/AST/SubselectFromClause.php b/src/Query/AST/SubselectFromClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SubselectFromClause.php rename to src/Query/AST/SubselectFromClause.php diff --git a/lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php b/src/Query/AST/SubselectIdentificationVariableDeclaration.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/SubselectIdentificationVariableDeclaration.php rename to src/Query/AST/SubselectIdentificationVariableDeclaration.php diff --git a/lib/Doctrine/ORM/Query/AST/TypedExpression.php b/src/Query/AST/TypedExpression.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/TypedExpression.php rename to src/Query/AST/TypedExpression.php diff --git a/lib/Doctrine/ORM/Query/AST/UpdateClause.php b/src/Query/AST/UpdateClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/UpdateClause.php rename to src/Query/AST/UpdateClause.php diff --git a/lib/Doctrine/ORM/Query/AST/UpdateItem.php b/src/Query/AST/UpdateItem.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/UpdateItem.php rename to src/Query/AST/UpdateItem.php diff --git a/lib/Doctrine/ORM/Query/AST/UpdateStatement.php b/src/Query/AST/UpdateStatement.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/UpdateStatement.php rename to src/Query/AST/UpdateStatement.php diff --git a/lib/Doctrine/ORM/Query/AST/WhenClause.php b/src/Query/AST/WhenClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/WhenClause.php rename to src/Query/AST/WhenClause.php diff --git a/lib/Doctrine/ORM/Query/AST/WhereClause.php b/src/Query/AST/WhereClause.php similarity index 100% rename from lib/Doctrine/ORM/Query/AST/WhereClause.php rename to src/Query/AST/WhereClause.php diff --git a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php b/src/Query/Exec/AbstractSqlExecutor.php similarity index 100% rename from lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php rename to src/Query/Exec/AbstractSqlExecutor.php diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php b/src/Query/Exec/MultiTableDeleteExecutor.php similarity index 100% rename from lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php rename to src/Query/Exec/MultiTableDeleteExecutor.php diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/src/Query/Exec/MultiTableUpdateExecutor.php similarity index 100% rename from lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php rename to src/Query/Exec/MultiTableUpdateExecutor.php diff --git a/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php b/src/Query/Exec/SingleSelectExecutor.php similarity index 100% rename from lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php rename to src/Query/Exec/SingleSelectExecutor.php diff --git a/lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php b/src/Query/Exec/SingleTableDeleteUpdateExecutor.php similarity index 100% rename from lib/Doctrine/ORM/Query/Exec/SingleTableDeleteUpdateExecutor.php rename to src/Query/Exec/SingleTableDeleteUpdateExecutor.php diff --git a/lib/Doctrine/ORM/Query/Expr.php b/src/Query/Expr.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr.php rename to src/Query/Expr.php diff --git a/lib/Doctrine/ORM/Query/Expr/Andx.php b/src/Query/Expr/Andx.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Andx.php rename to src/Query/Expr/Andx.php diff --git a/lib/Doctrine/ORM/Query/Expr/Base.php b/src/Query/Expr/Base.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Base.php rename to src/Query/Expr/Base.php diff --git a/lib/Doctrine/ORM/Query/Expr/Comparison.php b/src/Query/Expr/Comparison.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Comparison.php rename to src/Query/Expr/Comparison.php diff --git a/lib/Doctrine/ORM/Query/Expr/Composite.php b/src/Query/Expr/Composite.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Composite.php rename to src/Query/Expr/Composite.php diff --git a/lib/Doctrine/ORM/Query/Expr/From.php b/src/Query/Expr/From.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/From.php rename to src/Query/Expr/From.php diff --git a/lib/Doctrine/ORM/Query/Expr/Func.php b/src/Query/Expr/Func.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Func.php rename to src/Query/Expr/Func.php diff --git a/lib/Doctrine/ORM/Query/Expr/GroupBy.php b/src/Query/Expr/GroupBy.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/GroupBy.php rename to src/Query/Expr/GroupBy.php diff --git a/lib/Doctrine/ORM/Query/Expr/Join.php b/src/Query/Expr/Join.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Join.php rename to src/Query/Expr/Join.php diff --git a/lib/Doctrine/ORM/Query/Expr/Literal.php b/src/Query/Expr/Literal.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Literal.php rename to src/Query/Expr/Literal.php diff --git a/lib/Doctrine/ORM/Query/Expr/Math.php b/src/Query/Expr/Math.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Math.php rename to src/Query/Expr/Math.php diff --git a/lib/Doctrine/ORM/Query/Expr/OrderBy.php b/src/Query/Expr/OrderBy.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/OrderBy.php rename to src/Query/Expr/OrderBy.php diff --git a/lib/Doctrine/ORM/Query/Expr/Orx.php b/src/Query/Expr/Orx.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Orx.php rename to src/Query/Expr/Orx.php diff --git a/lib/Doctrine/ORM/Query/Expr/Select.php b/src/Query/Expr/Select.php similarity index 100% rename from lib/Doctrine/ORM/Query/Expr/Select.php rename to src/Query/Expr/Select.php diff --git a/lib/Doctrine/ORM/Query/Filter/FilterException.php b/src/Query/Filter/FilterException.php similarity index 100% rename from lib/Doctrine/ORM/Query/Filter/FilterException.php rename to src/Query/Filter/FilterException.php diff --git a/lib/Doctrine/ORM/Query/Filter/SQLFilter.php b/src/Query/Filter/SQLFilter.php similarity index 100% rename from lib/Doctrine/ORM/Query/Filter/SQLFilter.php rename to src/Query/Filter/SQLFilter.php diff --git a/lib/Doctrine/ORM/Query/FilterCollection.php b/src/Query/FilterCollection.php similarity index 100% rename from lib/Doctrine/ORM/Query/FilterCollection.php rename to src/Query/FilterCollection.php diff --git a/lib/Doctrine/ORM/Query/Lexer.php b/src/Query/Lexer.php similarity index 100% rename from lib/Doctrine/ORM/Query/Lexer.php rename to src/Query/Lexer.php diff --git a/lib/Doctrine/ORM/Query/Parameter.php b/src/Query/Parameter.php similarity index 100% rename from lib/Doctrine/ORM/Query/Parameter.php rename to src/Query/Parameter.php diff --git a/lib/Doctrine/ORM/Query/ParameterTypeInferer.php b/src/Query/ParameterTypeInferer.php similarity index 100% rename from lib/Doctrine/ORM/Query/ParameterTypeInferer.php rename to src/Query/ParameterTypeInferer.php diff --git a/lib/Doctrine/ORM/Query/Parser.php b/src/Query/Parser.php similarity index 100% rename from lib/Doctrine/ORM/Query/Parser.php rename to src/Query/Parser.php diff --git a/lib/Doctrine/ORM/Query/ParserResult.php b/src/Query/ParserResult.php similarity index 100% rename from lib/Doctrine/ORM/Query/ParserResult.php rename to src/Query/ParserResult.php diff --git a/lib/Doctrine/ORM/Query/Printer.php b/src/Query/Printer.php similarity index 100% rename from lib/Doctrine/ORM/Query/Printer.php rename to src/Query/Printer.php diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/src/Query/QueryException.php similarity index 100% rename from lib/Doctrine/ORM/Query/QueryException.php rename to src/Query/QueryException.php diff --git a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php b/src/Query/QueryExpressionVisitor.php similarity index 100% rename from lib/Doctrine/ORM/Query/QueryExpressionVisitor.php rename to src/Query/QueryExpressionVisitor.php diff --git a/lib/Doctrine/ORM/Query/ResultSetMapping.php b/src/Query/ResultSetMapping.php similarity index 100% rename from lib/Doctrine/ORM/Query/ResultSetMapping.php rename to src/Query/ResultSetMapping.php diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/src/Query/ResultSetMappingBuilder.php similarity index 100% rename from lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php rename to src/Query/ResultSetMappingBuilder.php diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/src/Query/SqlWalker.php similarity index 100% rename from lib/Doctrine/ORM/Query/SqlWalker.php rename to src/Query/SqlWalker.php diff --git a/lib/Doctrine/ORM/Query/TokenType.php b/src/Query/TokenType.php similarity index 100% rename from lib/Doctrine/ORM/Query/TokenType.php rename to src/Query/TokenType.php diff --git a/lib/Doctrine/ORM/Query/TreeWalker.php b/src/Query/TreeWalker.php similarity index 100% rename from lib/Doctrine/ORM/Query/TreeWalker.php rename to src/Query/TreeWalker.php diff --git a/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php b/src/Query/TreeWalkerAdapter.php similarity index 100% rename from lib/Doctrine/ORM/Query/TreeWalkerAdapter.php rename to src/Query/TreeWalkerAdapter.php diff --git a/lib/Doctrine/ORM/Query/TreeWalkerChain.php b/src/Query/TreeWalkerChain.php similarity index 100% rename from lib/Doctrine/ORM/Query/TreeWalkerChain.php rename to src/Query/TreeWalkerChain.php diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/src/QueryBuilder.php similarity index 100% rename from lib/Doctrine/ORM/QueryBuilder.php rename to src/QueryBuilder.php diff --git a/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php b/src/Repository/DefaultRepositoryFactory.php similarity index 100% rename from lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php rename to src/Repository/DefaultRepositoryFactory.php diff --git a/lib/Doctrine/ORM/Repository/Exception/InvalidFindByCall.php b/src/Repository/Exception/InvalidFindByCall.php similarity index 100% rename from lib/Doctrine/ORM/Repository/Exception/InvalidFindByCall.php rename to src/Repository/Exception/InvalidFindByCall.php diff --git a/lib/Doctrine/ORM/Repository/Exception/InvalidMagicMethodCall.php b/src/Repository/Exception/InvalidMagicMethodCall.php similarity index 100% rename from lib/Doctrine/ORM/Repository/Exception/InvalidMagicMethodCall.php rename to src/Repository/Exception/InvalidMagicMethodCall.php diff --git a/lib/Doctrine/ORM/Repository/RepositoryFactory.php b/src/Repository/RepositoryFactory.php similarity index 100% rename from lib/Doctrine/ORM/Repository/RepositoryFactory.php rename to src/Repository/RepositoryFactory.php diff --git a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php b/src/Tools/AttachEntityListenersListener.php similarity index 100% rename from lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php rename to src/Tools/AttachEntityListenersListener.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php b/src/Tools/Console/Command/AbstractEntityManagerCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/AbstractEntityManagerCommand.php rename to src/Tools/Console/Command/AbstractEntityManagerCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php b/src/Tools/Console/Command/ClearCache/CollectionRegionCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php rename to src/Tools/Console/Command/ClearCache/CollectionRegionCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php b/src/Tools/Console/Command/ClearCache/EntityRegionCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php rename to src/Tools/Console/Command/ClearCache/EntityRegionCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php b/src/Tools/Console/Command/ClearCache/MetadataCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php rename to src/Tools/Console/Command/ClearCache/MetadataCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php b/src/Tools/Console/Command/ClearCache/QueryCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryCommand.php rename to src/Tools/Console/Command/ClearCache/QueryCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php b/src/Tools/Console/Command/ClearCache/QueryRegionCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php rename to src/Tools/Console/Command/ClearCache/QueryRegionCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php b/src/Tools/Console/Command/ClearCache/ResultCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php rename to src/Tools/Console/Command/ClearCache/ResultCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php b/src/Tools/Console/Command/GenerateProxiesCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php rename to src/Tools/Console/Command/GenerateProxiesCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php b/src/Tools/Console/Command/InfoCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/InfoCommand.php rename to src/Tools/Console/Command/InfoCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/src/Tools/Console/Command/MappingDescribeCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php rename to src/Tools/Console/Command/MappingDescribeCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php b/src/Tools/Console/Command/RunDqlCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php rename to src/Tools/Console/Command/RunDqlCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php b/src/Tools/Console/Command/SchemaTool/AbstractCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php rename to src/Tools/Console/Command/SchemaTool/AbstractCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php b/src/Tools/Console/Command/SchemaTool/CreateCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/CreateCommand.php rename to src/Tools/Console/Command/SchemaTool/CreateCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php b/src/Tools/Console/Command/SchemaTool/DropCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/DropCommand.php rename to src/Tools/Console/Command/SchemaTool/DropCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/src/Tools/Console/Command/SchemaTool/UpdateCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php rename to src/Tools/Console/Command/SchemaTool/UpdateCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php b/src/Tools/Console/Command/ValidateSchemaCommand.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php rename to src/Tools/Console/Command/ValidateSchemaCommand.php diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/src/Tools/Console/ConsoleRunner.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php rename to src/Tools/Console/ConsoleRunner.php diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider.php b/src/Tools/Console/EntityManagerProvider.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/EntityManagerProvider.php rename to src/Tools/Console/EntityManagerProvider.php diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php b/src/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php rename to src/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php b/src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/SingleManagerProvider.php rename to src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php diff --git a/lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/UnknownManagerException.php b/src/Tools/Console/EntityManagerProvider/UnknownManagerException.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/EntityManagerProvider/UnknownManagerException.php rename to src/Tools/Console/EntityManagerProvider/UnknownManagerException.php diff --git a/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php b/src/Tools/Console/MetadataFilter.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Console/MetadataFilter.php rename to src/Tools/Console/MetadataFilter.php diff --git a/lib/Doctrine/ORM/Tools/Debug.php b/src/Tools/Debug.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Debug.php rename to src/Tools/Debug.php diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/src/Tools/DebugUnitOfWorkListener.php similarity index 100% rename from lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php rename to src/Tools/DebugUnitOfWorkListener.php diff --git a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php b/src/Tools/Event/GenerateSchemaEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Event/GenerateSchemaEventArgs.php rename to src/Tools/Event/GenerateSchemaEventArgs.php diff --git a/lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php b/src/Tools/Event/GenerateSchemaTableEventArgs.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Event/GenerateSchemaTableEventArgs.php rename to src/Tools/Event/GenerateSchemaTableEventArgs.php diff --git a/lib/Doctrine/ORM/Tools/Exception/MissingColumnException.php b/src/Tools/Exception/MissingColumnException.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Exception/MissingColumnException.php rename to src/Tools/Exception/MissingColumnException.php diff --git a/lib/Doctrine/ORM/Tools/Exception/NotSupported.php b/src/Tools/Exception/NotSupported.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Exception/NotSupported.php rename to src/Tools/Exception/NotSupported.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/src/Tools/Pagination/CountOutputWalker.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php rename to src/Tools/Pagination/CountOutputWalker.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/src/Tools/Pagination/CountWalker.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/CountWalker.php rename to src/Tools/Pagination/CountWalker.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/Exception/RowNumberOverFunctionNotEnabled.php b/src/Tools/Pagination/Exception/RowNumberOverFunctionNotEnabled.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/Exception/RowNumberOverFunctionNotEnabled.php rename to src/Tools/Pagination/Exception/RowNumberOverFunctionNotEnabled.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/src/Tools/Pagination/LimitSubqueryOutputWalker.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php rename to src/Tools/Pagination/LimitSubqueryOutputWalker.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/src/Tools/Pagination/LimitSubqueryWalker.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php rename to src/Tools/Pagination/LimitSubqueryWalker.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/src/Tools/Pagination/Paginator.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/Paginator.php rename to src/Tools/Pagination/Paginator.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/RootTypeWalker.php b/src/Tools/Pagination/RootTypeWalker.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/RootTypeWalker.php rename to src/Tools/Pagination/RootTypeWalker.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php b/src/Tools/Pagination/RowNumberOverFunction.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/RowNumberOverFunction.php rename to src/Tools/Pagination/RowNumberOverFunction.php diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/src/Tools/Pagination/WhereInWalker.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php rename to src/Tools/Pagination/WhereInWalker.php diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/src/Tools/ResolveTargetEntityListener.php similarity index 100% rename from lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php rename to src/Tools/ResolveTargetEntityListener.php diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/src/Tools/SchemaTool.php similarity index 100% rename from lib/Doctrine/ORM/Tools/SchemaTool.php rename to src/Tools/SchemaTool.php diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/src/Tools/SchemaValidator.php similarity index 100% rename from lib/Doctrine/ORM/Tools/SchemaValidator.php rename to src/Tools/SchemaValidator.php diff --git a/lib/Doctrine/ORM/Tools/ToolEvents.php b/src/Tools/ToolEvents.php similarity index 100% rename from lib/Doctrine/ORM/Tools/ToolEvents.php rename to src/Tools/ToolEvents.php diff --git a/lib/Doctrine/ORM/Tools/ToolsException.php b/src/Tools/ToolsException.php similarity index 100% rename from lib/Doctrine/ORM/Tools/ToolsException.php rename to src/Tools/ToolsException.php diff --git a/lib/Doctrine/ORM/TransactionRequiredException.php b/src/TransactionRequiredException.php similarity index 100% rename from lib/Doctrine/ORM/TransactionRequiredException.php rename to src/TransactionRequiredException.php diff --git a/lib/Doctrine/ORM/UnexpectedResultException.php b/src/UnexpectedResultException.php similarity index 100% rename from lib/Doctrine/ORM/UnexpectedResultException.php rename to src/UnexpectedResultException.php diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/src/UnitOfWork.php similarity index 100% rename from lib/Doctrine/ORM/UnitOfWork.php rename to src/UnitOfWork.php diff --git a/lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php b/src/Utility/HierarchyDiscriminatorResolver.php similarity index 100% rename from lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php rename to src/Utility/HierarchyDiscriminatorResolver.php diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/src/Utility/IdentifierFlattener.php similarity index 100% rename from lib/Doctrine/ORM/Utility/IdentifierFlattener.php rename to src/Utility/IdentifierFlattener.php diff --git a/lib/Doctrine/ORM/Utility/LockSqlHelper.php b/src/Utility/LockSqlHelper.php similarity index 100% rename from lib/Doctrine/ORM/Utility/LockSqlHelper.php rename to src/Utility/LockSqlHelper.php diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/src/Utility/PersisterHelper.php similarity index 100% rename from lib/Doctrine/ORM/Utility/PersisterHelper.php rename to src/Utility/PersisterHelper.php diff --git a/tests/.gitignore b/tests/.gitignore index 7210405266d..7575448eba5 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,3 +1,3 @@ -Doctrine/Tests/Proxies/ -Doctrine/Tests/ORM/Proxy/generated/ -Doctrine/Tests/ORM/Tools/Export/export +Tests/Proxies/ +Tests/ORM/Proxy/generated/ +Tests/ORM/Tools/Export/export diff --git a/tests/Doctrine/Performance/ArrayResultFactory.php b/tests/Performance/ArrayResultFactory.php similarity index 100% rename from tests/Doctrine/Performance/ArrayResultFactory.php rename to tests/Performance/ArrayResultFactory.php diff --git a/tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php b/tests/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php similarity index 100% rename from tests/Doctrine/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php rename to tests/Performance/ChangeSet/UnitOfWorkComputeChangesBench.php diff --git a/tests/Doctrine/Performance/EntityManagerFactory.php b/tests/Performance/EntityManagerFactory.php similarity index 100% rename from tests/Doctrine/Performance/EntityManagerFactory.php rename to tests/Performance/EntityManagerFactory.php diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php b/tests/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php rename to tests/Performance/Hydration/MixedQueryFetchJoinArrayHydrationPerformanceBench.php diff --git a/tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php rename to tests/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php diff --git a/tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php b/tests/Performance/Hydration/SimpleHydrationBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/SimpleHydrationBench.php rename to tests/Performance/Hydration/SimpleHydrationBench.php diff --git a/tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php b/tests/Performance/Hydration/SimpleInsertPerformanceBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/SimpleInsertPerformanceBench.php rename to tests/Performance/Hydration/SimpleInsertPerformanceBench.php diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php rename to tests/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php rename to tests/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php diff --git a/tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php rename to tests/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php diff --git a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php b/tests/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php rename to tests/Performance/Hydration/SingleTableInheritanceHydrationPerformanceBench.php diff --git a/tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php b/tests/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php similarity index 100% rename from tests/Doctrine/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php rename to tests/Performance/Hydration/SingleTableInheritanceInsertPerformanceBench.php diff --git a/tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php b/tests/Performance/LazyLoading/ProxyInitializationTimeBench.php similarity index 100% rename from tests/Doctrine/Performance/LazyLoading/ProxyInitializationTimeBench.php rename to tests/Performance/LazyLoading/ProxyInitializationTimeBench.php diff --git a/tests/Doctrine/Performance/LazyLoading/ProxyInstantiationTimeBench.php b/tests/Performance/LazyLoading/ProxyInstantiationTimeBench.php similarity index 100% rename from tests/Doctrine/Performance/LazyLoading/ProxyInstantiationTimeBench.php rename to tests/Performance/LazyLoading/ProxyInstantiationTimeBench.php diff --git a/tests/Doctrine/Performance/Mock/NonLoadingPersister.php b/tests/Performance/Mock/NonLoadingPersister.php similarity index 100% rename from tests/Doctrine/Performance/Mock/NonLoadingPersister.php rename to tests/Performance/Mock/NonLoadingPersister.php diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Performance/Mock/NonProxyLoadingEntityManager.php similarity index 100% rename from tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php rename to tests/Performance/Mock/NonProxyLoadingEntityManager.php diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingUnitOfWork.php b/tests/Performance/Mock/NonProxyLoadingUnitOfWork.php similarity index 100% rename from tests/Doctrine/Performance/Mock/NonProxyLoadingUnitOfWork.php rename to tests/Performance/Mock/NonProxyLoadingUnitOfWork.php diff --git a/tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php b/tests/Performance/Query/QueryBoundParameterProcessingBench.php similarity index 100% rename from tests/Doctrine/Performance/Query/QueryBoundParameterProcessingBench.php rename to tests/Performance/Query/QueryBoundParameterProcessingBench.php diff --git a/tests/Doctrine/StaticAnalysis/Mapping/class-metadata-constructor.php b/tests/StaticAnalysis/Mapping/class-metadata-constructor.php similarity index 100% rename from tests/Doctrine/StaticAnalysis/Mapping/class-metadata-constructor.php rename to tests/StaticAnalysis/Mapping/class-metadata-constructor.php diff --git a/tests/Doctrine/StaticAnalysis/Tools/Pagination/paginator-covariant.php b/tests/StaticAnalysis/Tools/Pagination/paginator-covariant.php similarity index 100% rename from tests/Doctrine/StaticAnalysis/Tools/Pagination/paginator-covariant.php rename to tests/StaticAnalysis/Tools/Pagination/paginator-covariant.php diff --git a/tests/Doctrine/StaticAnalysis/get-metadata.php b/tests/StaticAnalysis/get-metadata.php similarity index 100% rename from tests/Doctrine/StaticAnalysis/get-metadata.php rename to tests/StaticAnalysis/get-metadata.php diff --git a/tests/Doctrine/Tests/DbalExtensions/Connection.php b/tests/Tests/DbalExtensions/Connection.php similarity index 100% rename from tests/Doctrine/Tests/DbalExtensions/Connection.php rename to tests/Tests/DbalExtensions/Connection.php diff --git a/tests/Doctrine/Tests/DbalExtensions/QueryLog.php b/tests/Tests/DbalExtensions/QueryLog.php similarity index 100% rename from tests/Doctrine/Tests/DbalExtensions/QueryLog.php rename to tests/Tests/DbalExtensions/QueryLog.php diff --git a/tests/Doctrine/Tests/DbalExtensions/SqlLogger.php b/tests/Tests/DbalExtensions/SqlLogger.php similarity index 100% rename from tests/Doctrine/Tests/DbalExtensions/SqlLogger.php rename to tests/Tests/DbalExtensions/SqlLogger.php diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php b/tests/Tests/DbalTypes/CustomIdObject.php similarity index 100% rename from tests/Doctrine/Tests/DbalTypes/CustomIdObject.php rename to tests/Tests/DbalTypes/CustomIdObject.php diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php b/tests/Tests/DbalTypes/CustomIdObjectType.php similarity index 100% rename from tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php rename to tests/Tests/DbalTypes/CustomIdObjectType.php diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIntType.php b/tests/Tests/DbalTypes/CustomIntType.php similarity index 100% rename from tests/Doctrine/Tests/DbalTypes/CustomIntType.php rename to tests/Tests/DbalTypes/CustomIntType.php diff --git a/tests/Doctrine/Tests/DbalTypes/GH8565EmployeePayloadType.php b/tests/Tests/DbalTypes/GH8565EmployeePayloadType.php similarity index 100% rename from tests/Doctrine/Tests/DbalTypes/GH8565EmployeePayloadType.php rename to tests/Tests/DbalTypes/GH8565EmployeePayloadType.php diff --git a/tests/Doctrine/Tests/DbalTypes/GH8565ManagerPayloadType.php b/tests/Tests/DbalTypes/GH8565ManagerPayloadType.php similarity index 100% rename from tests/Doctrine/Tests/DbalTypes/GH8565ManagerPayloadType.php rename to tests/Tests/DbalTypes/GH8565ManagerPayloadType.php diff --git a/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php b/tests/Tests/DbalTypes/NegativeToPositiveType.php similarity index 100% rename from tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php rename to tests/Tests/DbalTypes/NegativeToPositiveType.php diff --git a/tests/Doctrine/Tests/DbalTypes/Rot13Type.php b/tests/Tests/DbalTypes/Rot13Type.php similarity index 100% rename from tests/Doctrine/Tests/DbalTypes/Rot13Type.php rename to tests/Tests/DbalTypes/Rot13Type.php diff --git a/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php b/tests/Tests/DbalTypes/UpperCaseStringType.php similarity index 100% rename from tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php rename to tests/Tests/DbalTypes/UpperCaseStringType.php diff --git a/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php b/tests/Tests/EventListener/CacheMetadataListener.php similarity index 100% rename from tests/Doctrine/Tests/EventListener/CacheMetadataListener.php rename to tests/Tests/EventListener/CacheMetadataListener.php diff --git a/tests/Doctrine/Tests/IterableTester.php b/tests/Tests/IterableTester.php similarity index 100% rename from tests/Doctrine/Tests/IterableTester.php rename to tests/Tests/IterableTester.php diff --git a/tests/Doctrine/Tests/Mocks/CacheEntryMock.php b/tests/Tests/Mocks/CacheEntryMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/CacheEntryMock.php rename to tests/Tests/Mocks/CacheEntryMock.php diff --git a/tests/Doctrine/Tests/Mocks/CacheKeyMock.php b/tests/Tests/Mocks/CacheKeyMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/CacheKeyMock.php rename to tests/Tests/Mocks/CacheKeyMock.php diff --git a/tests/Doctrine/Tests/Mocks/CacheRegionMock.php b/tests/Tests/Mocks/CacheRegionMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/CacheRegionMock.php rename to tests/Tests/Mocks/CacheRegionMock.php diff --git a/tests/Doctrine/Tests/Mocks/CompatibilityType.php b/tests/Tests/Mocks/CompatibilityType.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/CompatibilityType.php rename to tests/Tests/Mocks/CompatibilityType.php diff --git a/tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php b/tests/Tests/Mocks/ConcurrentRegionMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/ConcurrentRegionMock.php rename to tests/Tests/Mocks/ConcurrentRegionMock.php diff --git a/tests/Doctrine/Tests/Mocks/CustomTreeWalkerJoin.php b/tests/Tests/Mocks/CustomTreeWalkerJoin.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/CustomTreeWalkerJoin.php rename to tests/Tests/Mocks/CustomTreeWalkerJoin.php diff --git a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/tests/Tests/Mocks/EntityManagerMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/EntityManagerMock.php rename to tests/Tests/Mocks/EntityManagerMock.php diff --git a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php b/tests/Tests/Mocks/EntityPersisterMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/EntityPersisterMock.php rename to tests/Tests/Mocks/EntityPersisterMock.php diff --git a/tests/Doctrine/Tests/Mocks/ExceptionConverterMock.php b/tests/Tests/Mocks/ExceptionConverterMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/ExceptionConverterMock.php rename to tests/Tests/Mocks/ExceptionConverterMock.php diff --git a/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php b/tests/Tests/Mocks/MetadataDriverMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/MetadataDriverMock.php rename to tests/Tests/Mocks/MetadataDriverMock.php diff --git a/tests/Doctrine/Tests/Mocks/NullSqlWalker.php b/tests/Tests/Mocks/NullSqlWalker.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/NullSqlWalker.php rename to tests/Tests/Mocks/NullSqlWalker.php diff --git a/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php b/tests/Tests/Mocks/SchemaManagerMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/SchemaManagerMock.php rename to tests/Tests/Mocks/SchemaManagerMock.php diff --git a/tests/Doctrine/Tests/Mocks/TimestampRegionMock.php b/tests/Tests/Mocks/TimestampRegionMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/TimestampRegionMock.php rename to tests/Tests/Mocks/TimestampRegionMock.php diff --git a/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php b/tests/Tests/Mocks/UnitOfWorkMock.php similarity index 100% rename from tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php rename to tests/Tests/Mocks/UnitOfWorkMock.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Tests/Models/CMS/CmsAddress.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsAddress.php rename to tests/Tests/Models/CMS/CmsAddress.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php b/tests/Tests/Models/CMS/CmsAddressDTO.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsAddressDTO.php rename to tests/Tests/Models/CMS/CmsAddressDTO.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddressListener.php b/tests/Tests/Models/CMS/CmsAddressListener.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsAddressListener.php rename to tests/Tests/Models/CMS/CmsAddressListener.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsArticle.php b/tests/Tests/Models/CMS/CmsArticle.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsArticle.php rename to tests/Tests/Models/CMS/CmsArticle.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsComment.php b/tests/Tests/Models/CMS/CmsComment.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsComment.php rename to tests/Tests/Models/CMS/CmsComment.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsEmail.php b/tests/Tests/Models/CMS/CmsEmail.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsEmail.php rename to tests/Tests/Models/CMS/CmsEmail.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php b/tests/Tests/Models/CMS/CmsEmployee.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsEmployee.php rename to tests/Tests/Models/CMS/CmsEmployee.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php b/tests/Tests/Models/CMS/CmsGroup.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsGroup.php rename to tests/Tests/Models/CMS/CmsGroup.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php b/tests/Tests/Models/CMS/CmsPhonenumber.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php rename to tests/Tests/Models/CMS/CmsPhonenumber.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsTag.php b/tests/Tests/Models/CMS/CmsTag.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsTag.php rename to tests/Tests/Models/CMS/CmsTag.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Tests/Models/CMS/CmsUser.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsUser.php rename to tests/Tests/Models/CMS/CmsUser.php diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php b/tests/Tests/Models/CMS/CmsUserDTO.php similarity index 100% rename from tests/Doctrine/Tests/Models/CMS/CmsUserDTO.php rename to tests/Tests/Models/CMS/CmsUserDTO.php diff --git a/tests/Doctrine/Tests/Models/Cache/Action.php b/tests/Tests/Models/Cache/Action.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Action.php rename to tests/Tests/Models/Cache/Action.php diff --git a/tests/Doctrine/Tests/Models/Cache/Address.php b/tests/Tests/Models/Cache/Address.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Address.php rename to tests/Tests/Models/Cache/Address.php diff --git a/tests/Doctrine/Tests/Models/Cache/Attraction.php b/tests/Tests/Models/Cache/Attraction.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Attraction.php rename to tests/Tests/Models/Cache/Attraction.php diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php b/tests/Tests/Models/Cache/AttractionContactInfo.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/AttractionContactInfo.php rename to tests/Tests/Models/Cache/AttractionContactInfo.php diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionInfo.php b/tests/Tests/Models/Cache/AttractionInfo.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/AttractionInfo.php rename to tests/Tests/Models/Cache/AttractionInfo.php diff --git a/tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php b/tests/Tests/Models/Cache/AttractionLocationInfo.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/AttractionLocationInfo.php rename to tests/Tests/Models/Cache/AttractionLocationInfo.php diff --git a/tests/Doctrine/Tests/Models/Cache/Bar.php b/tests/Tests/Models/Cache/Bar.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Bar.php rename to tests/Tests/Models/Cache/Bar.php diff --git a/tests/Doctrine/Tests/Models/Cache/Beach.php b/tests/Tests/Models/Cache/Beach.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Beach.php rename to tests/Tests/Models/Cache/Beach.php diff --git a/tests/Doctrine/Tests/Models/Cache/City.php b/tests/Tests/Models/Cache/City.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/City.php rename to tests/Tests/Models/Cache/City.php diff --git a/tests/Doctrine/Tests/Models/Cache/Client.php b/tests/Tests/Models/Cache/Client.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Client.php rename to tests/Tests/Models/Cache/Client.php diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Tests/Models/Cache/ComplexAction.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/ComplexAction.php rename to tests/Tests/Models/Cache/ComplexAction.php diff --git a/tests/Doctrine/Tests/Models/Cache/Country.php b/tests/Tests/Models/Cache/Country.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Country.php rename to tests/Tests/Models/Cache/Country.php diff --git a/tests/Doctrine/Tests/Models/Cache/Flight.php b/tests/Tests/Models/Cache/Flight.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Flight.php rename to tests/Tests/Models/Cache/Flight.php diff --git a/tests/Doctrine/Tests/Models/Cache/Login.php b/tests/Tests/Models/Cache/Login.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Login.php rename to tests/Tests/Models/Cache/Login.php diff --git a/tests/Doctrine/Tests/Models/Cache/Person.php b/tests/Tests/Models/Cache/Person.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Person.php rename to tests/Tests/Models/Cache/Person.php diff --git a/tests/Doctrine/Tests/Models/Cache/Restaurant.php b/tests/Tests/Models/Cache/Restaurant.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Restaurant.php rename to tests/Tests/Models/Cache/Restaurant.php diff --git a/tests/Doctrine/Tests/Models/Cache/State.php b/tests/Tests/Models/Cache/State.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/State.php rename to tests/Tests/Models/Cache/State.php diff --git a/tests/Doctrine/Tests/Models/Cache/Token.php b/tests/Tests/Models/Cache/Token.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Token.php rename to tests/Tests/Models/Cache/Token.php diff --git a/tests/Doctrine/Tests/Models/Cache/Travel.php b/tests/Tests/Models/Cache/Travel.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Travel.php rename to tests/Tests/Models/Cache/Travel.php diff --git a/tests/Doctrine/Tests/Models/Cache/Traveler.php b/tests/Tests/Models/Cache/Traveler.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/Traveler.php rename to tests/Tests/Models/Cache/Traveler.php diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfile.php b/tests/Tests/Models/Cache/TravelerProfile.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/TravelerProfile.php rename to tests/Tests/Models/Cache/TravelerProfile.php diff --git a/tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php b/tests/Tests/Models/Cache/TravelerProfileInfo.php similarity index 100% rename from tests/Doctrine/Tests/Models/Cache/TravelerProfileInfo.php rename to tests/Tests/Models/Cache/TravelerProfileInfo.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyAuction.php b/tests/Tests/Models/Company/CompanyAuction.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyAuction.php rename to tests/Tests/Models/Company/CompanyAuction.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyCar.php b/tests/Tests/Models/Company/CompanyCar.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyCar.php rename to tests/Tests/Models/Company/CompanyCar.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/tests/Tests/Models/Company/CompanyContract.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyContract.php rename to tests/Tests/Models/Company/CompanyContract.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyContractListener.php b/tests/Tests/Models/Company/CompanyContractListener.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyContractListener.php rename to tests/Tests/Models/Company/CompanyContractListener.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php b/tests/Tests/Models/Company/CompanyEmployee.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyEmployee.php rename to tests/Tests/Models/Company/CompanyEmployee.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyEvent.php b/tests/Tests/Models/Company/CompanyEvent.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyEvent.php rename to tests/Tests/Models/Company/CompanyEvent.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/tests/Tests/Models/Company/CompanyFixContract.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyFixContract.php rename to tests/Tests/Models/Company/CompanyFixContract.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Tests/Models/Company/CompanyFlexContract.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php rename to tests/Tests/Models/Company/CompanyFlexContract.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/tests/Tests/Models/Company/CompanyFlexUltraContract.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php rename to tests/Tests/Models/Company/CompanyFlexUltraContract.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php b/tests/Tests/Models/Company/CompanyFlexUltraContractListener.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContractListener.php rename to tests/Tests/Models/Company/CompanyFlexUltraContractListener.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/tests/Tests/Models/Company/CompanyManager.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyManager.php rename to tests/Tests/Models/Company/CompanyManager.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php b/tests/Tests/Models/Company/CompanyOrganization.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyOrganization.php rename to tests/Tests/Models/Company/CompanyOrganization.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/tests/Tests/Models/Company/CompanyPerson.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyPerson.php rename to tests/Tests/Models/Company/CompanyPerson.php diff --git a/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php b/tests/Tests/Models/Company/CompanyRaffle.php similarity index 100% rename from tests/Doctrine/Tests/Models/Company/CompanyRaffle.php rename to tests/Tests/Models/Company/CompanyRaffle.php diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php b/tests/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php rename to tests/Tests/Models/CompositeKeyInheritance/JoinedChildClass.php diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php b/tests/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php rename to tests/Tests/Models/CompositeKeyInheritance/JoinedDerivedChildClass.php diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php b/tests/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php rename to tests/Tests/Models/CompositeKeyInheritance/JoinedDerivedIdentityClass.php diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php b/tests/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php rename to tests/Tests/Models/CompositeKeyInheritance/JoinedDerivedRootClass.php diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php b/tests/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php rename to tests/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php b/tests/Tests/Models/CompositeKeyInheritance/SingleChildClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleChildClass.php rename to tests/Tests/Models/CompositeKeyInheritance/SingleChildClass.php diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php b/tests/Tests/Models/CompositeKeyInheritance/SingleRootClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php rename to tests/Tests/Models/CompositeKeyInheritance/SingleRootClass.php diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php b/tests/Tests/Models/CustomType/CustomIdObjectTypeChild.php similarity index 100% rename from tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeChild.php rename to tests/Tests/Models/CustomType/CustomIdObjectTypeChild.php diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Tests/Models/CustomType/CustomIdObjectTypeParent.php similarity index 100% rename from tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php rename to tests/Tests/Models/CustomType/CustomIdObjectTypeParent.php diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php b/tests/Tests/Models/CustomType/CustomTypeChild.php similarity index 100% rename from tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php rename to tests/Tests/Models/CustomType/CustomTypeChild.php diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php b/tests/Tests/Models/CustomType/CustomTypeParent.php similarity index 100% rename from tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php rename to tests/Tests/Models/CustomType/CustomTypeParent.php diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php b/tests/Tests/Models/CustomType/CustomTypeUpperCase.php similarity index 100% rename from tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php rename to tests/Tests/Models/CustomType/CustomTypeUpperCase.php diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php b/tests/Tests/Models/DDC117/DDC117ApproveChanges.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php rename to tests/Tests/Models/DDC117/DDC117ApproveChanges.php diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php b/tests/Tests/Models/DDC117/DDC117Article.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC117/DDC117Article.php rename to tests/Tests/Models/DDC117/DDC117Article.php diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/tests/Tests/Models/DDC117/DDC117ArticleDetails.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php rename to tests/Tests/Models/DDC117/DDC117ArticleDetails.php diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/tests/Tests/Models/DDC117/DDC117Editor.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php rename to tests/Tests/Models/DDC117/DDC117Editor.php diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php b/tests/Tests/Models/DDC117/DDC117Link.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC117/DDC117Link.php rename to tests/Tests/Models/DDC117/DDC117Link.php diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/tests/Tests/Models/DDC117/DDC117Reference.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php rename to tests/Tests/Models/DDC117/DDC117Reference.php diff --git a/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/tests/Tests/Models/DDC117/DDC117Translation.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php rename to tests/Tests/Models/DDC117/DDC117Translation.php diff --git a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php b/tests/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php rename to tests/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php diff --git a/tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php b/tests/Tests/Models/DDC1590/DDC1590Entity.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC1590/DDC1590Entity.php rename to tests/Tests/Models/DDC1590/DDC1590Entity.php diff --git a/tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php b/tests/Tests/Models/DDC1590/DDC1590User.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC1590/DDC1590User.php rename to tests/Tests/Models/DDC1590/DDC1590User.php diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php b/tests/Tests/Models/DDC1872/DDC1872Bar.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC1872/DDC1872Bar.php rename to tests/Tests/Models/DDC1872/DDC1872Bar.php diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php b/tests/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php rename to tests/Tests/Models/DDC1872/DDC1872ExampleEntityWithOverride.php diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php b/tests/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php rename to tests/Tests/Models/DDC1872/DDC1872ExampleEntityWithoutOverride.php diff --git a/tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php b/tests/Tests/Models/DDC1872/DDC1872ExampleTrait.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC1872/DDC1872ExampleTrait.php rename to tests/Tests/Models/DDC1872/DDC1872ExampleTrait.php diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php b/tests/Tests/Models/DDC2372/DDC2372Address.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2372/DDC2372Address.php rename to tests/Tests/Models/DDC2372/DDC2372Address.php diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372Admin.php b/tests/Tests/Models/DDC2372/DDC2372Admin.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2372/DDC2372Admin.php rename to tests/Tests/Models/DDC2372/DDC2372Admin.php diff --git a/tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php b/tests/Tests/Models/DDC2372/DDC2372User.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2372/DDC2372User.php rename to tests/Tests/Models/DDC2372/DDC2372User.php diff --git a/tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php b/tests/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php rename to tests/Tests/Models/DDC2372/Traits/DDC2372AddressAndAccessors.php diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php b/tests/Tests/Models/DDC2504/DDC2504ChildClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2504/DDC2504ChildClass.php rename to tests/Tests/Models/DDC2504/DDC2504ChildClass.php diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php b/tests/Tests/Models/DDC2504/DDC2504OtherClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2504/DDC2504OtherClass.php rename to tests/Tests/Models/DDC2504/DDC2504OtherClass.php diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php b/tests/Tests/Models/DDC2504/DDC2504RootClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php rename to tests/Tests/Models/DDC2504/DDC2504RootClass.php diff --git a/tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php b/tests/Tests/Models/DDC2825/ExplicitSchemaAndTable.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2825/ExplicitSchemaAndTable.php rename to tests/Tests/Models/DDC2825/ExplicitSchemaAndTable.php diff --git a/tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php b/tests/Tests/Models/DDC2825/SchemaAndTableInTableName.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC2825/SchemaAndTableInTableName.php rename to tests/Tests/Models/DDC2825/SchemaAndTableInTableName.php diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231EntityRepository.php b/tests/Tests/Models/DDC3231/DDC3231EntityRepository.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3231/DDC3231EntityRepository.php rename to tests/Tests/Models/DDC3231/DDC3231EntityRepository.php diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php b/tests/Tests/Models/DDC3231/DDC3231User1.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3231/DDC3231User1.php rename to tests/Tests/Models/DDC3231/DDC3231User1.php diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php b/tests/Tests/Models/DDC3231/DDC3231User1NoNamespace.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3231/DDC3231User1NoNamespace.php rename to tests/Tests/Models/DDC3231/DDC3231User1NoNamespace.php diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php b/tests/Tests/Models/DDC3231/DDC3231User2.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3231/DDC3231User2.php rename to tests/Tests/Models/DDC3231/DDC3231User2.php diff --git a/tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php b/tests/Tests/Models/DDC3231/DDC3231User2NoNamespace.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3231/DDC3231User2NoNamespace.php rename to tests/Tests/Models/DDC3231/DDC3231User2NoNamespace.php diff --git a/tests/Doctrine/Tests/Models/DDC3293/DDC3293Address.php b/tests/Tests/Models/DDC3293/DDC3293Address.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3293/DDC3293Address.php rename to tests/Tests/Models/DDC3293/DDC3293Address.php diff --git a/tests/Doctrine/Tests/Models/DDC3293/DDC3293User.php b/tests/Tests/Models/DDC3293/DDC3293User.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3293/DDC3293User.php rename to tests/Tests/Models/DDC3293/DDC3293User.php diff --git a/tests/Doctrine/Tests/Models/DDC3293/DDC3293UserPrefixed.php b/tests/Tests/Models/DDC3293/DDC3293UserPrefixed.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3293/DDC3293UserPrefixed.php rename to tests/Tests/Models/DDC3293/DDC3293UserPrefixed.php diff --git a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php b/tests/Tests/Models/DDC3346/DDC3346Article.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3346/DDC3346Article.php rename to tests/Tests/Models/DDC3346/DDC3346Article.php diff --git a/tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php b/tests/Tests/Models/DDC3346/DDC3346Author.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3346/DDC3346Author.php rename to tests/Tests/Models/DDC3346/DDC3346Author.php diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php b/tests/Tests/Models/DDC3579/DDC3579Admin.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php rename to tests/Tests/Models/DDC3579/DDC3579Admin.php diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php b/tests/Tests/Models/DDC3579/DDC3579Group.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3579/DDC3579Group.php rename to tests/Tests/Models/DDC3579/DDC3579Group.php diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php b/tests/Tests/Models/DDC3579/DDC3579User.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3579/DDC3579User.php rename to tests/Tests/Models/DDC3579/DDC3579User.php diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php b/tests/Tests/Models/DDC3597/DDC3597Image.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3597/DDC3597Image.php rename to tests/Tests/Models/DDC3597/DDC3597Image.php diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php b/tests/Tests/Models/DDC3597/DDC3597Media.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3597/DDC3597Media.php rename to tests/Tests/Models/DDC3597/DDC3597Media.php diff --git a/tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php b/tests/Tests/Models/DDC3597/DDC3597Root.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3597/DDC3597Root.php rename to tests/Tests/Models/DDC3597/DDC3597Root.php diff --git a/tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php b/tests/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php rename to tests/Tests/Models/DDC3597/Embeddable/DDC3597Dimension.php diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php b/tests/Tests/Models/DDC3699/DDC3699Child.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3699/DDC3699Child.php rename to tests/Tests/Models/DDC3699/DDC3699Child.php diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php b/tests/Tests/Models/DDC3699/DDC3699Parent.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3699/DDC3699Parent.php rename to tests/Tests/Models/DDC3699/DDC3699Parent.php diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php b/tests/Tests/Models/DDC3699/DDC3699RelationMany.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationMany.php rename to tests/Tests/Models/DDC3699/DDC3699RelationMany.php diff --git a/tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php b/tests/Tests/Models/DDC3699/DDC3699RelationOne.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3699/DDC3699RelationOne.php rename to tests/Tests/Models/DDC3699/DDC3699RelationOne.php diff --git a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php b/tests/Tests/Models/DDC3711/DDC3711EntityA.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php rename to tests/Tests/Models/DDC3711/DDC3711EntityA.php diff --git a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php b/tests/Tests/Models/DDC3711/DDC3711EntityB.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php rename to tests/Tests/Models/DDC3711/DDC3711EntityB.php diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php b/tests/Tests/Models/DDC3899/DDC3899Contract.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3899/DDC3899Contract.php rename to tests/Tests/Models/DDC3899/DDC3899Contract.php diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php b/tests/Tests/Models/DDC3899/DDC3899FixContract.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3899/DDC3899FixContract.php rename to tests/Tests/Models/DDC3899/DDC3899FixContract.php diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php b/tests/Tests/Models/DDC3899/DDC3899FlexContract.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3899/DDC3899FlexContract.php rename to tests/Tests/Models/DDC3899/DDC3899FlexContract.php diff --git a/tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php b/tests/Tests/Models/DDC3899/DDC3899User.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC3899/DDC3899User.php rename to tests/Tests/Models/DDC3899/DDC3899User.php diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php b/tests/Tests/Models/DDC4006/DDC4006User.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC4006/DDC4006User.php rename to tests/Tests/Models/DDC4006/DDC4006User.php diff --git a/tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php b/tests/Tests/Models/DDC4006/DDC4006UserId.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC4006/DDC4006UserId.php rename to tests/Tests/Models/DDC4006/DDC4006UserId.php diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php b/tests/Tests/Models/DDC5934/DDC5934BaseContract.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC5934/DDC5934BaseContract.php rename to tests/Tests/Models/DDC5934/DDC5934BaseContract.php diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934Contract.php b/tests/Tests/Models/DDC5934/DDC5934Contract.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC5934/DDC5934Contract.php rename to tests/Tests/Models/DDC5934/DDC5934Contract.php diff --git a/tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php b/tests/Tests/Models/DDC5934/DDC5934Member.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC5934/DDC5934Member.php rename to tests/Tests/Models/DDC5934/DDC5934Member.php diff --git a/tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php b/tests/Tests/Models/DDC6412/DDC6412File.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC6412/DDC6412File.php rename to tests/Tests/Models/DDC6412/DDC6412File.php diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php b/tests/Tests/Models/DDC753/DDC753CustomRepository.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php rename to tests/Tests/Models/DDC753/DDC753CustomRepository.php diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php b/tests/Tests/Models/DDC753/DDC753DefaultRepository.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php rename to tests/Tests/Models/DDC753/DDC753DefaultRepository.php diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php b/tests/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php rename to tests/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php b/tests/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php rename to tests/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php b/tests/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php rename to tests/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php b/tests/Tests/Models/DDC753/DDC753InvalidRepository.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php rename to tests/Tests/Models/DDC753/DDC753InvalidRepository.php diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php b/tests/Tests/Models/DDC869/DDC869ChequePayment.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php rename to tests/Tests/Models/DDC869/DDC869ChequePayment.php diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php b/tests/Tests/Models/DDC869/DDC869CreditCardPayment.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php rename to tests/Tests/Models/DDC869/DDC869CreditCardPayment.php diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php b/tests/Tests/Models/DDC869/DDC869Payment.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php rename to tests/Tests/Models/DDC869/DDC869Payment.php diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php b/tests/Tests/Models/DDC869/DDC869PaymentRepository.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php rename to tests/Tests/Models/DDC869/DDC869PaymentRepository.php diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php b/tests/Tests/Models/DDC889/DDC889Class.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC889/DDC889Class.php rename to tests/Tests/Models/DDC889/DDC889Class.php diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php b/tests/Tests/Models/DDC889/DDC889Entity.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php rename to tests/Tests/Models/DDC889/DDC889Entity.php diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php b/tests/Tests/Models/DDC889/DDC889SuperClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php rename to tests/Tests/Models/DDC889/DDC889SuperClass.php diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Address.php b/tests/Tests/Models/DDC964/DDC964Address.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC964/DDC964Address.php rename to tests/Tests/Models/DDC964/DDC964Address.php diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php b/tests/Tests/Models/DDC964/DDC964Admin.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php rename to tests/Tests/Models/DDC964/DDC964Admin.php diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Group.php b/tests/Tests/Models/DDC964/DDC964Group.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC964/DDC964Group.php rename to tests/Tests/Models/DDC964/DDC964Group.php diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php b/tests/Tests/Models/DDC964/DDC964Guest.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php rename to tests/Tests/Models/DDC964/DDC964Guest.php diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964User.php b/tests/Tests/Models/DDC964/DDC964User.php similarity index 100% rename from tests/Doctrine/Tests/Models/DDC964/DDC964User.php rename to tests/Tests/Models/DDC964/DDC964User.php diff --git a/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php b/tests/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php similarity index 100% rename from tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php rename to tests/Tests/Models/DataTransferObjects/DtoWithArrayOfEnums.php diff --git a/tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithEnum.php b/tests/Tests/Models/DataTransferObjects/DtoWithEnum.php similarity index 100% rename from tests/Doctrine/Tests/Models/DataTransferObjects/DtoWithEnum.php rename to tests/Tests/Models/DataTransferObjects/DtoWithEnum.php diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/tests/Tests/Models/DirectoryTree/AbstractContentItem.php similarity index 100% rename from tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php rename to tests/Tests/Models/DirectoryTree/AbstractContentItem.php diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php b/tests/Tests/Models/DirectoryTree/Directory.php similarity index 100% rename from tests/Doctrine/Tests/Models/DirectoryTree/Directory.php rename to tests/Tests/Models/DirectoryTree/Directory.php diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/File.php b/tests/Tests/Models/DirectoryTree/File.php similarity index 100% rename from tests/Doctrine/Tests/Models/DirectoryTree/File.php rename to tests/Tests/Models/DirectoryTree/File.php diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/tests/Tests/Models/ECommerce/ECommerceCart.php similarity index 100% rename from tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php rename to tests/Tests/Models/ECommerce/ECommerceCart.php diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/tests/Tests/Models/ECommerce/ECommerceCategory.php similarity index 100% rename from tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php rename to tests/Tests/Models/ECommerce/ECommerceCategory.php diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php b/tests/Tests/Models/ECommerce/ECommerceCustomer.php similarity index 100% rename from tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php rename to tests/Tests/Models/ECommerce/ECommerceCustomer.php diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php b/tests/Tests/Models/ECommerce/ECommerceFeature.php similarity index 100% rename from tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php rename to tests/Tests/Models/ECommerce/ECommerceFeature.php diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/tests/Tests/Models/ECommerce/ECommerceProduct.php similarity index 100% rename from tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php rename to tests/Tests/Models/ECommerce/ECommerceProduct.php diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php b/tests/Tests/Models/ECommerce/ECommerceShipping.php similarity index 100% rename from tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php rename to tests/Tests/Models/ECommerce/ECommerceShipping.php diff --git a/tests/Doctrine/Tests/Models/Enums/AccessLevel.php b/tests/Tests/Models/Enums/AccessLevel.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/AccessLevel.php rename to tests/Tests/Models/Enums/AccessLevel.php diff --git a/tests/Doctrine/Tests/Models/Enums/Card.php b/tests/Tests/Models/Enums/Card.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/Card.php rename to tests/Tests/Models/Enums/Card.php diff --git a/tests/Doctrine/Tests/Models/Enums/CardWithDefault.php b/tests/Tests/Models/Enums/CardWithDefault.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/CardWithDefault.php rename to tests/Tests/Models/Enums/CardWithDefault.php diff --git a/tests/Doctrine/Tests/Models/Enums/CardWithNullable.php b/tests/Tests/Models/Enums/CardWithNullable.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/CardWithNullable.php rename to tests/Tests/Models/Enums/CardWithNullable.php diff --git a/tests/Doctrine/Tests/Models/Enums/City.php b/tests/Tests/Models/Enums/City.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/City.php rename to tests/Tests/Models/Enums/City.php diff --git a/tests/Doctrine/Tests/Models/Enums/Product.php b/tests/Tests/Models/Enums/Product.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/Product.php rename to tests/Tests/Models/Enums/Product.php diff --git a/tests/Doctrine/Tests/Models/Enums/Quantity.php b/tests/Tests/Models/Enums/Quantity.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/Quantity.php rename to tests/Tests/Models/Enums/Quantity.php diff --git a/tests/Doctrine/Tests/Models/Enums/Scale.php b/tests/Tests/Models/Enums/Scale.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/Scale.php rename to tests/Tests/Models/Enums/Scale.php diff --git a/tests/Doctrine/Tests/Models/Enums/Suit.php b/tests/Tests/Models/Enums/Suit.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/Suit.php rename to tests/Tests/Models/Enums/Suit.php diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCard.php b/tests/Tests/Models/Enums/TypedCard.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/TypedCard.php rename to tests/Tests/Models/Enums/TypedCard.php diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php b/tests/Tests/Models/Enums/TypedCardEnumCompositeId.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/TypedCardEnumCompositeId.php rename to tests/Tests/Models/Enums/TypedCardEnumCompositeId.php diff --git a/tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php b/tests/Tests/Models/Enums/TypedCardEnumId.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/TypedCardEnumId.php rename to tests/Tests/Models/Enums/TypedCardEnumId.php diff --git a/tests/Doctrine/Tests/Models/Enums/Unit.php b/tests/Tests/Models/Enums/Unit.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/Unit.php rename to tests/Tests/Models/Enums/Unit.php diff --git a/tests/Doctrine/Tests/Models/Enums/UserStatus.php b/tests/Tests/Models/Enums/UserStatus.php similarity index 100% rename from tests/Doctrine/Tests/Models/Enums/UserStatus.php rename to tests/Tests/Models/Enums/UserStatus.php diff --git a/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php b/tests/Tests/Models/Forum/ForumAvatar.php similarity index 100% rename from tests/Doctrine/Tests/Models/Forum/ForumAvatar.php rename to tests/Tests/Models/Forum/ForumAvatar.php diff --git a/tests/Doctrine/Tests/Models/Forum/ForumBoard.php b/tests/Tests/Models/Forum/ForumBoard.php similarity index 100% rename from tests/Doctrine/Tests/Models/Forum/ForumBoard.php rename to tests/Tests/Models/Forum/ForumBoard.php diff --git a/tests/Doctrine/Tests/Models/Forum/ForumCategory.php b/tests/Tests/Models/Forum/ForumCategory.php similarity index 100% rename from tests/Doctrine/Tests/Models/Forum/ForumCategory.php rename to tests/Tests/Models/Forum/ForumCategory.php diff --git a/tests/Doctrine/Tests/Models/Forum/ForumEntry.php b/tests/Tests/Models/Forum/ForumEntry.php similarity index 100% rename from tests/Doctrine/Tests/Models/Forum/ForumEntry.php rename to tests/Tests/Models/Forum/ForumEntry.php diff --git a/tests/Doctrine/Tests/Models/Forum/ForumUser.php b/tests/Tests/Models/Forum/ForumUser.php similarity index 100% rename from tests/Doctrine/Tests/Models/Forum/ForumUser.php rename to tests/Tests/Models/Forum/ForumUser.php diff --git a/tests/Doctrine/Tests/Models/GH10132/Complex.php b/tests/Tests/Models/GH10132/Complex.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10132/Complex.php rename to tests/Tests/Models/GH10132/Complex.php diff --git a/tests/Doctrine/Tests/Models/GH10132/ComplexChild.php b/tests/Tests/Models/GH10132/ComplexChild.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10132/ComplexChild.php rename to tests/Tests/Models/GH10132/ComplexChild.php diff --git a/tests/Doctrine/Tests/Models/GH10288/GH10288People.php b/tests/Tests/Models/GH10288/GH10288People.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10288/GH10288People.php rename to tests/Tests/Models/GH10288/GH10288People.php diff --git a/tests/Doctrine/Tests/Models/GH10334/GH10334Foo.php b/tests/Tests/Models/GH10334/GH10334Foo.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10334/GH10334Foo.php rename to tests/Tests/Models/GH10334/GH10334Foo.php diff --git a/tests/Doctrine/Tests/Models/GH10334/GH10334FooCollection.php b/tests/Tests/Models/GH10334/GH10334FooCollection.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10334/GH10334FooCollection.php rename to tests/Tests/Models/GH10334/GH10334FooCollection.php diff --git a/tests/Doctrine/Tests/Models/GH10334/GH10334Product.php b/tests/Tests/Models/GH10334/GH10334Product.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10334/GH10334Product.php rename to tests/Tests/Models/GH10334/GH10334Product.php diff --git a/tests/Doctrine/Tests/Models/GH10334/GH10334ProductType.php b/tests/Tests/Models/GH10334/GH10334ProductType.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10334/GH10334ProductType.php rename to tests/Tests/Models/GH10334/GH10334ProductType.php diff --git a/tests/Doctrine/Tests/Models/GH10334/GH10334ProductTypeId.php b/tests/Tests/Models/GH10334/GH10334ProductTypeId.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10334/GH10334ProductTypeId.php rename to tests/Tests/Models/GH10334/GH10334ProductTypeId.php diff --git a/tests/Doctrine/Tests/Models/GH10336/GH10336Entity.php b/tests/Tests/Models/GH10336/GH10336Entity.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10336/GH10336Entity.php rename to tests/Tests/Models/GH10336/GH10336Entity.php diff --git a/tests/Doctrine/Tests/Models/GH10336/GH10336Relation.php b/tests/Tests/Models/GH10336/GH10336Relation.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH10336/GH10336Relation.php rename to tests/Tests/Models/GH10336/GH10336Relation.php diff --git a/tests/Doctrine/Tests/Models/GH7141/GH7141Article.php b/tests/Tests/Models/GH7141/GH7141Article.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH7141/GH7141Article.php rename to tests/Tests/Models/GH7141/GH7141Article.php diff --git a/tests/Doctrine/Tests/Models/GH7316/GH7316Article.php b/tests/Tests/Models/GH7316/GH7316Article.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH7316/GH7316Article.php rename to tests/Tests/Models/GH7316/GH7316Article.php diff --git a/tests/Doctrine/Tests/Models/GH7717/GH7717Child.php b/tests/Tests/Models/GH7717/GH7717Child.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH7717/GH7717Child.php rename to tests/Tests/Models/GH7717/GH7717Child.php diff --git a/tests/Doctrine/Tests/Models/GH7717/GH7717Parent.php b/tests/Tests/Models/GH7717/GH7717Parent.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH7717/GH7717Parent.php rename to tests/Tests/Models/GH7717/GH7717Parent.php diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php b/tests/Tests/Models/GH8565/GH8565Employee.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH8565/GH8565Employee.php rename to tests/Tests/Models/GH8565/GH8565Employee.php diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php b/tests/Tests/Models/GH8565/GH8565Manager.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH8565/GH8565Manager.php rename to tests/Tests/Models/GH8565/GH8565Manager.php diff --git a/tests/Doctrine/Tests/Models/GH8565/GH8565Person.php b/tests/Tests/Models/GH8565/GH8565Person.php similarity index 100% rename from tests/Doctrine/Tests/Models/GH8565/GH8565Person.php rename to tests/Tests/Models/GH8565/GH8565Person.php diff --git a/tests/Doctrine/Tests/Models/Generic/BooleanModel.php b/tests/Tests/Models/Generic/BooleanModel.php similarity index 100% rename from tests/Doctrine/Tests/Models/Generic/BooleanModel.php rename to tests/Tests/Models/Generic/BooleanModel.php diff --git a/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php b/tests/Tests/Models/Generic/DateTimeModel.php similarity index 100% rename from tests/Doctrine/Tests/Models/Generic/DateTimeModel.php rename to tests/Tests/Models/Generic/DateTimeModel.php diff --git a/tests/Doctrine/Tests/Models/Generic/DecimalModel.php b/tests/Tests/Models/Generic/DecimalModel.php similarity index 100% rename from tests/Doctrine/Tests/Models/Generic/DecimalModel.php rename to tests/Tests/Models/Generic/DecimalModel.php diff --git a/tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php b/tests/Tests/Models/Generic/NonAlphaColumnsEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/Generic/NonAlphaColumnsEntity.php rename to tests/Tests/Models/Generic/NonAlphaColumnsEntity.php diff --git a/tests/Doctrine/Tests/Models/Generic/SerializationModel.php b/tests/Tests/Models/Generic/SerializationModel.php similarity index 100% rename from tests/Doctrine/Tests/Models/Generic/SerializationModel.php rename to tests/Tests/Models/Generic/SerializationModel.php diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1.php b/tests/Tests/Models/GeoNames/Admin1.php similarity index 100% rename from tests/Doctrine/Tests/Models/GeoNames/Admin1.php rename to tests/Tests/Models/GeoNames/Admin1.php diff --git a/tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php b/tests/Tests/Models/GeoNames/Admin1AlternateName.php similarity index 100% rename from tests/Doctrine/Tests/Models/GeoNames/Admin1AlternateName.php rename to tests/Tests/Models/GeoNames/Admin1AlternateName.php diff --git a/tests/Doctrine/Tests/Models/GeoNames/City.php b/tests/Tests/Models/GeoNames/City.php similarity index 100% rename from tests/Doctrine/Tests/Models/GeoNames/City.php rename to tests/Tests/Models/GeoNames/City.php diff --git a/tests/Doctrine/Tests/Models/GeoNames/Country.php b/tests/Tests/Models/GeoNames/Country.php similarity index 100% rename from tests/Doctrine/Tests/Models/GeoNames/Country.php rename to tests/Tests/Models/GeoNames/Country.php diff --git a/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php b/tests/Tests/Models/Global/GlobalNamespaceModel.php similarity index 100% rename from tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php rename to tests/Tests/Models/Global/GlobalNamespaceModel.php diff --git a/tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php b/tests/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php similarity index 100% rename from tests/Doctrine/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php rename to tests/Tests/Models/Hydration/EntityWithArrayDefaultArrayValueM2M.php diff --git a/tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php b/tests/Tests/Models/Hydration/SimpleEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/Hydration/SimpleEntity.php rename to tests/Tests/Models/Hydration/SimpleEntity.php diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php b/tests/Tests/Models/Issue5989/Issue5989Employee.php similarity index 100% rename from tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php rename to tests/Tests/Models/Issue5989/Issue5989Employee.php diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php b/tests/Tests/Models/Issue5989/Issue5989Manager.php similarity index 100% rename from tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php rename to tests/Tests/Models/Issue5989/Issue5989Manager.php diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php b/tests/Tests/Models/Issue5989/Issue5989Person.php similarity index 100% rename from tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php rename to tests/Tests/Models/Issue5989/Issue5989Person.php diff --git a/tests/Doctrine/Tests/Models/Issue9300/Issue9300Child.php b/tests/Tests/Models/Issue9300/Issue9300Child.php similarity index 100% rename from tests/Doctrine/Tests/Models/Issue9300/Issue9300Child.php rename to tests/Tests/Models/Issue9300/Issue9300Child.php diff --git a/tests/Doctrine/Tests/Models/Issue9300/Issue9300Parent.php b/tests/Tests/Models/Issue9300/Issue9300Parent.php similarity index 100% rename from tests/Doctrine/Tests/Models/Issue9300/Issue9300Parent.php rename to tests/Tests/Models/Issue9300/Issue9300Parent.php diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php b/tests/Tests/Models/JoinedInheritanceType/AnotherChildClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php rename to tests/Tests/Models/JoinedInheritanceType/AnotherChildClass.php diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php b/tests/Tests/Models/JoinedInheritanceType/ChildClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php rename to tests/Tests/Models/JoinedInheritanceType/ChildClass.php diff --git a/tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php b/tests/Tests/Models/JoinedInheritanceType/RootClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php rename to tests/Tests/Models/JoinedInheritanceType/RootClass.php diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php b/tests/Tests/Models/Legacy/LegacyArticle.php similarity index 100% rename from tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php rename to tests/Tests/Models/Legacy/LegacyArticle.php diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php b/tests/Tests/Models/Legacy/LegacyCar.php similarity index 100% rename from tests/Doctrine/Tests/Models/Legacy/LegacyCar.php rename to tests/Tests/Models/Legacy/LegacyCar.php diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php b/tests/Tests/Models/Legacy/LegacyUser.php similarity index 100% rename from tests/Doctrine/Tests/Models/Legacy/LegacyUser.php rename to tests/Tests/Models/Legacy/LegacyUser.php diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php b/tests/Tests/Models/Legacy/LegacyUserReference.php similarity index 100% rename from tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php rename to tests/Tests/Models/Legacy/LegacyUserReference.php diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php b/tests/Tests/Models/ManyToManyPersister/ChildClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/ManyToManyPersister/ChildClass.php rename to tests/Tests/Models/ManyToManyPersister/ChildClass.php diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php b/tests/Tests/Models/ManyToManyPersister/OtherParentClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/ManyToManyPersister/OtherParentClass.php rename to tests/Tests/Models/ManyToManyPersister/OtherParentClass.php diff --git a/tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php b/tests/Tests/Models/ManyToManyPersister/ParentClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/ManyToManyPersister/ParentClass.php rename to tests/Tests/Models/ManyToManyPersister/ParentClass.php diff --git a/tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php b/tests/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php similarity index 100% rename from tests/Doctrine/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php rename to tests/Tests/Models/MixedToOneIdentity/CompositeToOneKeyState.php diff --git a/tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php b/tests/Tests/Models/MixedToOneIdentity/Country.php similarity index 100% rename from tests/Doctrine/Tests/Models/MixedToOneIdentity/Country.php rename to tests/Tests/Models/MixedToOneIdentity/Country.php diff --git a/tests/Doctrine/Tests/Models/Navigation/NavCountry.php b/tests/Tests/Models/Navigation/NavCountry.php similarity index 100% rename from tests/Doctrine/Tests/Models/Navigation/NavCountry.php rename to tests/Tests/Models/Navigation/NavCountry.php diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php b/tests/Tests/Models/Navigation/NavPhotos.php similarity index 100% rename from tests/Doctrine/Tests/Models/Navigation/NavPhotos.php rename to tests/Tests/Models/Navigation/NavPhotos.php diff --git a/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/tests/Tests/Models/Navigation/NavPointOfInterest.php similarity index 100% rename from tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php rename to tests/Tests/Models/Navigation/NavPointOfInterest.php diff --git a/tests/Doctrine/Tests/Models/Navigation/NavTour.php b/tests/Tests/Models/Navigation/NavTour.php similarity index 100% rename from tests/Doctrine/Tests/Models/Navigation/NavTour.php rename to tests/Tests/Models/Navigation/NavTour.php diff --git a/tests/Doctrine/Tests/Models/Navigation/NavUser.php b/tests/Tests/Models/Navigation/NavUser.php similarity index 100% rename from tests/Doctrine/Tests/Models/Navigation/NavUser.php rename to tests/Tests/Models/Navigation/NavUser.php diff --git a/tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php b/tests/Tests/Models/NonPublicSchemaJoins/User.php similarity index 100% rename from tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php rename to tests/Tests/Models/NonPublicSchemaJoins/User.php diff --git a/tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php b/tests/Tests/Models/NullDefault/NullDefaultColumn.php similarity index 100% rename from tests/Doctrine/Tests/Models/NullDefault/NullDefaultColumn.php rename to tests/Tests/Models/NullDefault/NullDefaultColumn.php diff --git a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php b/tests/Tests/Models/OneToOneInverseSideLoad/InverseSide.php similarity index 100% rename from tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/InverseSide.php rename to tests/Tests/Models/OneToOneInverseSideLoad/InverseSide.php diff --git a/tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php b/tests/Tests/Models/OneToOneInverseSideLoad/OwningSide.php similarity index 100% rename from tests/Doctrine/Tests/Models/OneToOneInverseSideLoad/OwningSide.php rename to tests/Tests/Models/OneToOneInverseSideLoad/OwningSide.php diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php b/tests/Tests/Models/OneToOneSingleTableInheritance/Cat.php similarity index 100% rename from tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Cat.php rename to tests/Tests/Models/OneToOneSingleTableInheritance/Cat.php diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php b/tests/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php similarity index 100% rename from tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php rename to tests/Tests/Models/OneToOneSingleTableInheritance/LitterBox.php diff --git a/tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php b/tests/Tests/Models/OneToOneSingleTableInheritance/Pet.php similarity index 100% rename from tests/Doctrine/Tests/Models/OneToOneSingleTableInheritance/Pet.php rename to tests/Tests/Models/OneToOneSingleTableInheritance/Pet.php diff --git a/tests/Doctrine/Tests/Models/Pagination/Company.php b/tests/Tests/Models/Pagination/Company.php similarity index 100% rename from tests/Doctrine/Tests/Models/Pagination/Company.php rename to tests/Tests/Models/Pagination/Company.php diff --git a/tests/Doctrine/Tests/Models/Pagination/Department.php b/tests/Tests/Models/Pagination/Department.php similarity index 100% rename from tests/Doctrine/Tests/Models/Pagination/Department.php rename to tests/Tests/Models/Pagination/Department.php diff --git a/tests/Doctrine/Tests/Models/Pagination/Logo.php b/tests/Tests/Models/Pagination/Logo.php similarity index 100% rename from tests/Doctrine/Tests/Models/Pagination/Logo.php rename to tests/Tests/Models/Pagination/Logo.php diff --git a/tests/Doctrine/Tests/Models/Pagination/User.php b/tests/Tests/Models/Pagination/User.php similarity index 100% rename from tests/Doctrine/Tests/Models/Pagination/User.php rename to tests/Tests/Models/Pagination/User.php diff --git a/tests/Doctrine/Tests/Models/Pagination/User1.php b/tests/Tests/Models/Pagination/User1.php similarity index 100% rename from tests/Doctrine/Tests/Models/Pagination/User1.php rename to tests/Tests/Models/Pagination/User1.php diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php b/tests/Tests/Models/PersistentObject/PersistentCollectionContent.php similarity index 100% rename from tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionContent.php rename to tests/Tests/Models/PersistentObject/PersistentCollectionContent.php diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php b/tests/Tests/Models/PersistentObject/PersistentCollectionHolder.php similarity index 100% rename from tests/Doctrine/Tests/Models/PersistentObject/PersistentCollectionHolder.php rename to tests/Tests/Models/PersistentObject/PersistentCollectionHolder.php diff --git a/tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php b/tests/Tests/Models/PersistentObject/PersistentEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/PersistentObject/PersistentEntity.php rename to tests/Tests/Models/PersistentObject/PersistentEntity.php diff --git a/tests/Doctrine/Tests/Models/Project/Project.php b/tests/Tests/Models/Project/Project.php similarity index 100% rename from tests/Doctrine/Tests/Models/Project/Project.php rename to tests/Tests/Models/Project/Project.php diff --git a/tests/Doctrine/Tests/Models/Project/ProjectId.php b/tests/Tests/Models/Project/ProjectId.php similarity index 100% rename from tests/Doctrine/Tests/Models/Project/ProjectId.php rename to tests/Tests/Models/Project/ProjectId.php diff --git a/tests/Doctrine/Tests/Models/Project/ProjectInvalidMapping.php b/tests/Tests/Models/Project/ProjectInvalidMapping.php similarity index 100% rename from tests/Doctrine/Tests/Models/Project/ProjectInvalidMapping.php rename to tests/Tests/Models/Project/ProjectInvalidMapping.php diff --git a/tests/Doctrine/Tests/Models/Project/ProjectName.php b/tests/Tests/Models/Project/ProjectName.php similarity index 100% rename from tests/Doctrine/Tests/Models/Project/ProjectName.php rename to tests/Tests/Models/Project/ProjectName.php diff --git a/tests/Doctrine/Tests/Models/Quote/Address.php b/tests/Tests/Models/Quote/Address.php similarity index 100% rename from tests/Doctrine/Tests/Models/Quote/Address.php rename to tests/Tests/Models/Quote/Address.php diff --git a/tests/Doctrine/Tests/Models/Quote/City.php b/tests/Tests/Models/Quote/City.php similarity index 100% rename from tests/Doctrine/Tests/Models/Quote/City.php rename to tests/Tests/Models/Quote/City.php diff --git a/tests/Doctrine/Tests/Models/Quote/FullAddress.php b/tests/Tests/Models/Quote/FullAddress.php similarity index 100% rename from tests/Doctrine/Tests/Models/Quote/FullAddress.php rename to tests/Tests/Models/Quote/FullAddress.php diff --git a/tests/Doctrine/Tests/Models/Quote/Group.php b/tests/Tests/Models/Quote/Group.php similarity index 100% rename from tests/Doctrine/Tests/Models/Quote/Group.php rename to tests/Tests/Models/Quote/Group.php diff --git a/tests/Doctrine/Tests/Models/Quote/NumericEntity.php b/tests/Tests/Models/Quote/NumericEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/Quote/NumericEntity.php rename to tests/Tests/Models/Quote/NumericEntity.php diff --git a/tests/Doctrine/Tests/Models/Quote/Phone.php b/tests/Tests/Models/Quote/Phone.php similarity index 100% rename from tests/Doctrine/Tests/Models/Quote/Phone.php rename to tests/Tests/Models/Quote/Phone.php diff --git a/tests/Doctrine/Tests/Models/Quote/User.php b/tests/Tests/Models/Quote/User.php similarity index 100% rename from tests/Doctrine/Tests/Models/Quote/User.php rename to tests/Tests/Models/Quote/User.php diff --git a/tests/Doctrine/Tests/Models/ReadonlyProperties/Author.php b/tests/Tests/Models/ReadonlyProperties/Author.php similarity index 100% rename from tests/Doctrine/Tests/Models/ReadonlyProperties/Author.php rename to tests/Tests/Models/ReadonlyProperties/Author.php diff --git a/tests/Doctrine/Tests/Models/ReadonlyProperties/Book.php b/tests/Tests/Models/ReadonlyProperties/Book.php similarity index 100% rename from tests/Doctrine/Tests/Models/ReadonlyProperties/Book.php rename to tests/Tests/Models/ReadonlyProperties/Book.php diff --git a/tests/Doctrine/Tests/Models/ReadonlyProperties/SimpleBook.php b/tests/Tests/Models/ReadonlyProperties/SimpleBook.php similarity index 100% rename from tests/Doctrine/Tests/Models/ReadonlyProperties/SimpleBook.php rename to tests/Tests/Models/ReadonlyProperties/SimpleBook.php diff --git a/tests/Doctrine/Tests/Models/Reflection/AbstractEmbeddable.php b/tests/Tests/Models/Reflection/AbstractEmbeddable.php similarity index 100% rename from tests/Doctrine/Tests/Models/Reflection/AbstractEmbeddable.php rename to tests/Tests/Models/Reflection/AbstractEmbeddable.php diff --git a/tests/Doctrine/Tests/Models/Reflection/ArrayObjectExtendingClass.php b/tests/Tests/Models/Reflection/ArrayObjectExtendingClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/Reflection/ArrayObjectExtendingClass.php rename to tests/Tests/Models/Reflection/ArrayObjectExtendingClass.php diff --git a/tests/Doctrine/Tests/Models/Reflection/ClassWithMixedProperties.php b/tests/Tests/Models/Reflection/ClassWithMixedProperties.php similarity index 100% rename from tests/Doctrine/Tests/Models/Reflection/ClassWithMixedProperties.php rename to tests/Tests/Models/Reflection/ClassWithMixedProperties.php diff --git a/tests/Doctrine/Tests/Models/Reflection/ConcreteEmbeddable.php b/tests/Tests/Models/Reflection/ConcreteEmbeddable.php similarity index 100% rename from tests/Doctrine/Tests/Models/Reflection/ConcreteEmbeddable.php rename to tests/Tests/Models/Reflection/ConcreteEmbeddable.php diff --git a/tests/Doctrine/Tests/Models/Reflection/ParentClass.php b/tests/Tests/Models/Reflection/ParentClass.php similarity index 100% rename from tests/Doctrine/Tests/Models/Reflection/ParentClass.php rename to tests/Tests/Models/Reflection/ParentClass.php diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php b/tests/Tests/Models/Routing/RoutingLeg.php similarity index 100% rename from tests/Doctrine/Tests/Models/Routing/RoutingLeg.php rename to tests/Tests/Models/Routing/RoutingLeg.php diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php b/tests/Tests/Models/Routing/RoutingLocation.php similarity index 100% rename from tests/Doctrine/Tests/Models/Routing/RoutingLocation.php rename to tests/Tests/Models/Routing/RoutingLocation.php diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php b/tests/Tests/Models/Routing/RoutingRoute.php similarity index 100% rename from tests/Doctrine/Tests/Models/Routing/RoutingRoute.php rename to tests/Tests/Models/Routing/RoutingRoute.php diff --git a/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php b/tests/Tests/Models/Routing/RoutingRouteBooking.php similarity index 100% rename from tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php rename to tests/Tests/Models/Routing/RoutingRouteBooking.php diff --git a/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/tests/Tests/Models/StockExchange/Bond.php similarity index 100% rename from tests/Doctrine/Tests/Models/StockExchange/Bond.php rename to tests/Tests/Models/StockExchange/Bond.php diff --git a/tests/Doctrine/Tests/Models/StockExchange/Market.php b/tests/Tests/Models/StockExchange/Market.php similarity index 100% rename from tests/Doctrine/Tests/Models/StockExchange/Market.php rename to tests/Tests/Models/StockExchange/Market.php diff --git a/tests/Doctrine/Tests/Models/StockExchange/Stock.php b/tests/Tests/Models/StockExchange/Stock.php similarity index 100% rename from tests/Doctrine/Tests/Models/StockExchange/Stock.php rename to tests/Tests/Models/StockExchange/Stock.php diff --git a/tests/Doctrine/Tests/Models/Taxi/Car.php b/tests/Tests/Models/Taxi/Car.php similarity index 100% rename from tests/Doctrine/Tests/Models/Taxi/Car.php rename to tests/Tests/Models/Taxi/Car.php diff --git a/tests/Doctrine/Tests/Models/Taxi/Driver.php b/tests/Tests/Models/Taxi/Driver.php similarity index 100% rename from tests/Doctrine/Tests/Models/Taxi/Driver.php rename to tests/Tests/Models/Taxi/Driver.php diff --git a/tests/Doctrine/Tests/Models/Taxi/PaidRide.php b/tests/Tests/Models/Taxi/PaidRide.php similarity index 100% rename from tests/Doctrine/Tests/Models/Taxi/PaidRide.php rename to tests/Tests/Models/Taxi/PaidRide.php diff --git a/tests/Doctrine/Tests/Models/Taxi/Ride.php b/tests/Tests/Models/Taxi/Ride.php similarity index 100% rename from tests/Doctrine/Tests/Models/Taxi/Ride.php rename to tests/Tests/Models/Taxi/Ride.php diff --git a/tests/Doctrine/Tests/Models/Tweet/Tweet.php b/tests/Tests/Models/Tweet/Tweet.php similarity index 100% rename from tests/Doctrine/Tests/Models/Tweet/Tweet.php rename to tests/Tests/Models/Tweet/Tweet.php diff --git a/tests/Doctrine/Tests/Models/Tweet/User.php b/tests/Tests/Models/Tweet/User.php similarity index 100% rename from tests/Doctrine/Tests/Models/Tweet/User.php rename to tests/Tests/Models/Tweet/User.php diff --git a/tests/Doctrine/Tests/Models/Tweet/UserList.php b/tests/Tests/Models/Tweet/UserList.php similarity index 100% rename from tests/Doctrine/Tests/Models/Tweet/UserList.php rename to tests/Tests/Models/Tweet/UserList.php diff --git a/tests/Doctrine/Tests/Models/TypedProperties/Contact.php b/tests/Tests/Models/TypedProperties/Contact.php similarity index 100% rename from tests/Doctrine/Tests/Models/TypedProperties/Contact.php rename to tests/Tests/Models/TypedProperties/Contact.php diff --git a/tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php b/tests/Tests/Models/TypedProperties/UserTyped.php similarity index 100% rename from tests/Doctrine/Tests/Models/TypedProperties/UserTyped.php rename to tests/Tests/Models/TypedProperties/UserTyped.php diff --git a/tests/Doctrine/Tests/Models/TypedProperties/UserTypedWithCustomTypedField.php b/tests/Tests/Models/TypedProperties/UserTypedWithCustomTypedField.php similarity index 100% rename from tests/Doctrine/Tests/Models/TypedProperties/UserTypedWithCustomTypedField.php rename to tests/Tests/Models/TypedProperties/UserTypedWithCustomTypedField.php diff --git a/tests/Doctrine/Tests/Models/Upsertable/Insertable.php b/tests/Tests/Models/Upsertable/Insertable.php similarity index 100% rename from tests/Doctrine/Tests/Models/Upsertable/Insertable.php rename to tests/Tests/Models/Upsertable/Insertable.php diff --git a/tests/Doctrine/Tests/Models/Upsertable/Updatable.php b/tests/Tests/Models/Upsertable/Updatable.php similarity index 100% rename from tests/Doctrine/Tests/Models/Upsertable/Updatable.php rename to tests/Tests/Models/Upsertable/Updatable.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php b/tests/Tests/Models/ValueConversionType/AuxiliaryEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/AuxiliaryEntity.php rename to tests/Tests/Models/ValueConversionType/AuxiliaryEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php b/tests/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php rename to tests/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php b/tests/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php rename to tests/Tests/Models/ValueConversionType/InversedManyToManyCompositeIdForeignKeyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php b/tests/Tests/Models/ValueConversionType/InversedManyToManyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyEntity.php rename to tests/Tests/Models/ValueConversionType/InversedManyToManyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php b/tests/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php rename to tests/Tests/Models/ValueConversionType/InversedManyToManyExtraLazyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php b/tests/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php rename to tests/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php b/tests/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php rename to tests/Tests/Models/ValueConversionType/InversedOneToManyCompositeIdForeignKeyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php b/tests/Tests/Models/ValueConversionType/InversedOneToManyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyEntity.php rename to tests/Tests/Models/ValueConversionType/InversedOneToManyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php b/tests/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php rename to tests/Tests/Models/ValueConversionType/InversedOneToManyExtraLazyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php b/tests/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php rename to tests/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php b/tests/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php rename to tests/Tests/Models/ValueConversionType/InversedOneToOneCompositeIdForeignKeyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php b/tests/Tests/Models/ValueConversionType/InversedOneToOneEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/InversedOneToOneEntity.php rename to tests/Tests/Models/ValueConversionType/InversedOneToOneEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToManyCompositeIdForeignKeyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToManyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToManyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToManyExtraLazyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToOneCompositeIdForeignKeyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToOneEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToOneEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToOneExtraLazyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php b/tests/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php rename to tests/Tests/Models/ValueConversionType/OwningManyToOneIdForeignKeyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php b/tests/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php rename to tests/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php b/tests/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php rename to tests/Tests/Models/ValueConversionType/OwningOneToOneCompositeIdForeignKeyEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php b/tests/Tests/Models/ValueConversionType/OwningOneToOneEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueConversionType/OwningOneToOneEntity.php rename to tests/Tests/Models/ValueConversionType/OwningOneToOneEntity.php diff --git a/tests/Doctrine/Tests/Models/ValueObjects/Name.php b/tests/Tests/Models/ValueObjects/Name.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueObjects/Name.php rename to tests/Tests/Models/ValueObjects/Name.php diff --git a/tests/Doctrine/Tests/Models/ValueObjects/Person.php b/tests/Tests/Models/ValueObjects/Person.php similarity index 100% rename from tests/Doctrine/Tests/Models/ValueObjects/Person.php rename to tests/Tests/Models/ValueObjects/Person.php diff --git a/tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php b/tests/Tests/Models/VersionedManyToOne/Article.php similarity index 100% rename from tests/Doctrine/Tests/Models/VersionedManyToOne/Article.php rename to tests/Tests/Models/VersionedManyToOne/Article.php diff --git a/tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php b/tests/Tests/Models/VersionedManyToOne/Category.php similarity index 100% rename from tests/Doctrine/Tests/Models/VersionedManyToOne/Category.php rename to tests/Tests/Models/VersionedManyToOne/Category.php diff --git a/tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php b/tests/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php rename to tests/Tests/Models/VersionedOneToOne/FirstRelatedEntity.php diff --git a/tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php b/tests/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php similarity index 100% rename from tests/Doctrine/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php rename to tests/Tests/Models/VersionedOneToOne/SecondRelatedEntity.php diff --git a/tests/Doctrine/Tests/ORM/AbstractQueryTest.php b/tests/Tests/ORM/AbstractQueryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/AbstractQueryTest.php rename to tests/Tests/ORM/AbstractQueryTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Tests/ORM/Cache/CacheConfigTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php rename to tests/Tests/ORM/Cache/CacheConfigTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php b/tests/Tests/ORM/Cache/CacheKeyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/CacheKeyTest.php rename to tests/Tests/ORM/Cache/CacheKeyTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Tests/ORM/Cache/CacheLoggerChainTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php rename to tests/Tests/ORM/Cache/CacheLoggerChainTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php rename to tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php b/tests/Tests/ORM/Cache/DefaultCacheTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/DefaultCacheTest.php rename to tests/Tests/ORM/Cache/DefaultCacheTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php b/tests/Tests/ORM/Cache/DefaultCollectionHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/DefaultCollectionHydratorTest.php rename to tests/Tests/ORM/Cache/DefaultCollectionHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php b/tests/Tests/ORM/Cache/DefaultEntityHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/DefaultEntityHydratorTest.php rename to tests/Tests/ORM/Cache/DefaultEntityHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Tests/ORM/Cache/DefaultQueryCacheTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php rename to tests/Tests/ORM/Cache/DefaultQueryCacheTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Tests/ORM/Cache/DefaultRegionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php rename to tests/Tests/ORM/Cache/DefaultRegionTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php b/tests/Tests/ORM/Cache/FileLockRegionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php rename to tests/Tests/ORM/Cache/FileLockRegionTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php b/tests/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php rename to tests/Tests/ORM/Cache/Persister/Collection/CollectionPersisterTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php rename to tests/Tests/ORM/Cache/Persister/Collection/NonStrictReadWriteCachedCollectionPersisterTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php rename to tests/Tests/ORM/Cache/Persister/Collection/ReadOnlyCachedCollectionPersisterTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php rename to tests/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php b/tests/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php rename to tests/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php rename to tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php rename to tests/Tests/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersisterTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php rename to tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php diff --git a/tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php b/tests/Tests/ORM/Cache/RegionTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/RegionTestCase.php rename to tests/Tests/ORM/Cache/RegionTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php b/tests/Tests/ORM/Cache/StatisticsCacheLoggerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Cache/StatisticsCacheLoggerTest.php rename to tests/Tests/ORM/Cache/StatisticsCacheLoggerTest.php diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Tests/ORM/ConfigurationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/ConfigurationTest.php rename to tests/Tests/ORM/ConfigurationTest.php diff --git a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php b/tests/Tests/ORM/Entity/ConstructorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php rename to tests/Tests/ORM/Entity/ConstructorTest.php diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Tests/ORM/EntityManagerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/EntityManagerTest.php rename to tests/Tests/ORM/EntityManagerTest.php diff --git a/tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php b/tests/Tests/ORM/EntityNotFoundExceptionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/EntityNotFoundExceptionTest.php rename to tests/Tests/ORM/EntityNotFoundExceptionTest.php diff --git a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php b/tests/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php rename to tests/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/tests/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php rename to tests/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Tests/ORM/Functional/AdvancedAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php rename to tests/Tests/ORM/Functional/AdvancedAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/tests/Tests/ORM/Functional/AdvancedDqlQueryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php rename to tests/Tests/ORM/Functional/AdvancedDqlQueryTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Tests/ORM/Functional/BasicFunctionalTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php rename to tests/Tests/ORM/Functional/BasicFunctionalTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php b/tests/Tests/ORM/Functional/CascadeRemoveOrderTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php rename to tests/Tests/ORM/Functional/CascadeRemoveOrderTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php b/tests/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php rename to tests/Tests/ORM/Functional/ClassTableInheritanceSecondTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Tests/ORM/Functional/ClassTableInheritanceTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php rename to tests/Tests/ORM/Functional/ClassTableInheritanceTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php b/tests/Tests/ORM/Functional/ClearEventTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php rename to tests/Tests/ORM/Functional/ClearEventTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Tests/ORM/Functional/CompositePrimaryKeyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php rename to tests/Tests/ORM/Functional/CompositePrimaryKeyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php b/tests/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php rename to tests/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php b/tests/Tests/ORM/Functional/CustomFunctionsTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php rename to tests/Tests/ORM/Functional/CustomFunctionsTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php b/tests/Tests/ORM/Functional/CustomIdObjectTypeTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php rename to tests/Tests/ORM/Functional/CustomIdObjectTypeTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Tests/ORM/Functional/DatabaseDriverTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php rename to tests/Tests/ORM/Functional/DatabaseDriverTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php b/tests/Tests/ORM/Functional/DatabaseDriverTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php rename to tests/Tests/ORM/Functional/DatabaseDriverTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Tests/ORM/Functional/DefaultValuesTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php rename to tests/Tests/ORM/Functional/DefaultValuesTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Tests/ORM/Functional/DetachedEntityTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php rename to tests/Tests/ORM/Functional/DetachedEntityTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/EagerFetchCollectionTest.php b/tests/Tests/ORM/Functional/EagerFetchCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/EagerFetchCollectionTest.php rename to tests/Tests/ORM/Functional/EagerFetchCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php b/tests/Tests/ORM/Functional/EntityListenersTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php rename to tests/Tests/ORM/Functional/EntityListenersTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php b/tests/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php rename to tests/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Tests/ORM/Functional/EntityRepositoryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php rename to tests/Tests/ORM/Functional/EntityRepositoryTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php b/tests/Tests/ORM/Functional/EnumTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/EnumTest.php rename to tests/Tests/ORM/Functional/EnumTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php rename to tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Tests/ORM/Functional/FlushEventTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php rename to tests/Tests/ORM/Functional/FlushEventTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/GH7877Test.php b/tests/Tests/ORM/Functional/GH7877Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/GH7877Test.php rename to tests/Tests/ORM/Functional/GH7877Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/tests/Tests/ORM/Functional/HydrationCacheTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php rename to tests/Tests/ORM/Functional/HydrationCacheTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/tests/Tests/ORM/Functional/IdentityMapTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php rename to tests/Tests/ORM/Functional/IdentityMapTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/tests/Tests/ORM/Functional/IndexByAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php rename to tests/Tests/ORM/Functional/IndexByAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php b/tests/Tests/ORM/Functional/InsertableUpdatableTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/InsertableUpdatableTest.php rename to tests/Tests/ORM/Functional/InsertableUpdatableTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php b/tests/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php rename to tests/Tests/ORM/Functional/JoinedTableCompositeKeyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Tests/ORM/Functional/LifecycleCallbackTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php rename to tests/Tests/ORM/Functional/LifecycleCallbackTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/tests/Tests/ORM/Functional/Locking/GearmanLockTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php rename to tests/Tests/ORM/Functional/Locking/GearmanLockTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/tests/Tests/ORM/Functional/Locking/LockAgentWorker.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php rename to tests/Tests/ORM/Functional/Locking/LockAgentWorker.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Tests/ORM/Functional/Locking/LockTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php rename to tests/Tests/ORM/Functional/Locking/LockTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Tests/ORM/Functional/Locking/OptimisticTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php rename to tests/Tests/ORM/Functional/Locking/OptimisticTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php rename to tests/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php b/tests/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php rename to tests/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php b/tests/Tests/ORM/Functional/ManyToManyEventTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php rename to tests/Tests/ORM/Functional/ManyToManyEventTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php b/tests/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php rename to tests/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php b/tests/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php rename to tests/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/tests/Tests/ORM/Functional/MappedSuperclassTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php rename to tests/Tests/ORM/Functional/MappedSuperclassTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Tests/ORM/Functional/NativeQueryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php rename to tests/Tests/ORM/Functional/NativeQueryTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Tests/ORM/Functional/NewOperatorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php rename to tests/Tests/ORM/Functional/NewOperatorTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php rename to tests/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/tests/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php rename to tests/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php b/tests/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php rename to tests/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php b/tests/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php rename to tests/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php b/tests/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php rename to tests/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Tests/ORM/Functional/OneToOneEagerLoadingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php rename to tests/Tests/ORM/Functional/OneToOneEagerLoadingTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php b/tests/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php rename to tests/Tests/ORM/Functional/OneToOneInverseSideLoadAfterDqlQueryTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php b/tests/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php rename to tests/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php rename to tests/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php b/tests/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php rename to tests/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php rename to tests/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php b/tests/Tests/ORM/Functional/OrderedCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php rename to tests/Tests/ORM/Functional/OrderedCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/tests/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php rename to tests/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Tests/ORM/Functional/PaginationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/PaginationTest.php rename to tests/Tests/ORM/Functional/PaginationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ParserResultSerializationTest.php b/tests/Tests/ORM/Functional/ParserResultSerializationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ParserResultSerializationTest.php rename to tests/Tests/ORM/Functional/ParserResultSerializationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ParserResults/single_select_2_17_0.txt b/tests/Tests/ORM/Functional/ParserResults/single_select_2_17_0.txt similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ParserResults/single_select_2_17_0.txt rename to tests/Tests/ORM/Functional/ParserResults/single_select_2_17_0.txt diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php b/tests/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php rename to tests/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/tests/Tests/ORM/Functional/PersistentCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php rename to tests/Tests/ORM/Functional/PersistentCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/tests/Tests/ORM/Functional/PostFlushEventTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php rename to tests/Tests/ORM/Functional/PostFlushEventTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Tests/ORM/Functional/PostLoadEventTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php rename to tests/Tests/ORM/Functional/PostLoadEventTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php b/tests/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php rename to tests/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php b/tests/Tests/ORM/Functional/QueryBuilderParenthesisTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/QueryBuilderParenthesisTest.php rename to tests/Tests/ORM/Functional/QueryBuilderParenthesisTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/tests/Tests/ORM/Functional/QueryCacheTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php rename to tests/Tests/ORM/Functional/QueryCacheTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Tests/ORM/Functional/QueryDqlFunctionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php rename to tests/Tests/ORM/Functional/QueryDqlFunctionTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php b/tests/Tests/ORM/Functional/QueryIterableTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/QueryIterableTest.php rename to tests/Tests/ORM/Functional/QueryIterableTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Tests/ORM/Functional/QueryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/QueryTest.php rename to tests/Tests/ORM/Functional/QueryTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Tests/ORM/Functional/ReadOnlyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php rename to tests/Tests/ORM/Functional/ReadOnlyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php b/tests/Tests/ORM/Functional/ReadonlyPropertiesTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php rename to tests/Tests/ORM/Functional/ReadonlyPropertiesTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/tests/Tests/ORM/Functional/ReferenceProxyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php rename to tests/Tests/ORM/Functional/ReferenceProxyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/tests/Tests/ORM/Functional/ResultCacheTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php rename to tests/Tests/ORM/Functional/ResultCacheTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Tests/ORM/Functional/SQLFilterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php rename to tests/Tests/ORM/Functional/SQLFilterTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/tests/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php rename to tests/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Tests/ORM/Functional/SchemaTool/DBAL483Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php rename to tests/Tests/ORM/Functional/SchemaTool/DBAL483Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Tests/ORM/Functional/SchemaTool/DDC214Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php rename to tests/Tests/ORM/Functional/SchemaTool/DDC214Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php rename to tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php rename to tests/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/tests/Tests/ORM/Functional/SchemaValidatorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php rename to tests/Tests/ORM/Functional/SchemaValidatorTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheCriteriaTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheExtraLazyCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php b/tests/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php rename to tests/Tests/ORM/Functional/SecondLevelCacheFunctionalTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheJoinTableInheritanceTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheManyToManyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheRepositoryTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheSingleTableInheritanceTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheTest.php rename to tests/Tests/ORM/Functional/SecondLevelCacheTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/tests/Tests/ORM/Functional/SequenceGeneratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php rename to tests/Tests/ORM/Functional/SequenceGeneratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php b/tests/Tests/ORM/Functional/SingleTableCompositeKeyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SingleTableCompositeKeyTest.php rename to tests/Tests/ORM/Functional/SingleTableCompositeKeyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Tests/ORM/Functional/SingleTableInheritanceTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php rename to tests/Tests/ORM/Functional/SingleTableInheritanceTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php b/tests/Tests/ORM/Functional/StandardEntityPersisterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php rename to tests/Tests/ORM/Functional/StandardEntityPersisterTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1040Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1040Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1041Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1041Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1043Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1043Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1080Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1080Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1113Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1113Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1129Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1129Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1163Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1163Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Tests/ORM/Functional/Ticket/DDC117Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC117Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1181Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1181Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1193Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1193Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1209Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1209Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1225Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1225Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1228Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1228Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1238Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1238Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1250Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1250Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1300Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1300Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1301Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1301Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1306Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1306Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1335Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1335Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1400Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1400Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php b/tests/Tests/ORM/Functional/Ticket/DDC142Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC142Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC142Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1430Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1430Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1436Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1436Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/tests/Tests/ORM/Functional/Ticket/DDC144Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC144Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1452Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1452Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1454Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1454Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1458Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1458Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1461Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1461Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1514Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1514Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1515Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1515Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1526Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1526Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1545Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1545Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1548Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1548Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1595Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1595Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php b/tests/Tests/ORM/Functional/Ticket/DDC163Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC163Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1643Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1643Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1654Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1654Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1655Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1655Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1666Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1666Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1666Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1685Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1685Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php b/tests/Tests/ORM/Functional/Ticket/DDC168Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC168Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1695Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1695Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1707Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1707Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1719Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1719Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1719Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1757Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1757Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1757Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1778Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1778Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1787Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1787Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1843Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1843Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1843Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1884Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1884Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1884Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1885Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1885Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1885Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1918Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1918Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1925Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1925Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1925Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php b/tests/Tests/ORM/Functional/Ticket/DDC192Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC192Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1995Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1995Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1995Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php b/tests/Tests/ORM/Functional/Ticket/DDC1998Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1998Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC1998Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/tests/Tests/ORM/Functional/Ticket/DDC199Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC199Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2012Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2012Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2074Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2074Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2084Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2084Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2084Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2090Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2090Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2090Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2106Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2106Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2106Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/tests/Tests/ORM/Functional/Ticket/DDC211Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC211Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2138Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2138Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2175Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2175Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2175Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2182Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2182Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2214Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2214Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2214Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2224Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2224Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2224Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2252Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2252Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2306Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2306Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2346Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2346Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2350Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2350Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2350Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2359Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/tests/Tests/ORM/Functional/Ticket/DDC237Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC237Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2387Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2387Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2387Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2415Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2415Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2415Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2494Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2494Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2494Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2575Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2575Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2575Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2579Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2579Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2579Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Tests/ORM/Functional/Ticket/DDC258Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC258Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2602Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2602Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2602Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2655Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2655Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2655Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2660Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2660Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2660Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2692Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2692Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2759Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2759Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2775Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2775Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2780Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2780Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2780Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2790Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2790Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2790Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/tests/Tests/ORM/Functional/Ticket/DDC279Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC279Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2825Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2825Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2862Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2862Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2862Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2895Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2895Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2895Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2931Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2931Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2943Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2943Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2943Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2984Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2984Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2984Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2996Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC2996Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3033Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3033Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3042Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3042Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3042Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3068Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3068Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3068Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/tests/Tests/ORM/Functional/Ticket/DDC309Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC309Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3103Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3103Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3103Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3123Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3123Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3160Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3160Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3160Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3170Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3170Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3170Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3192Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3192Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3192Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3223Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3223Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3223Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3300Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3300Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3303Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3303Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/tests/Tests/ORM/Functional/Ticket/DDC331Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC331Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3330Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3330Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3330Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3346Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3346Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/tests/Tests/ORM/Functional/Ticket/DDC345Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC345Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/tests/Tests/ORM/Functional/Ticket/DDC353Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC353Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3582Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3582Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3582Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3597Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3597Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3597Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3634Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3634Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3644Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3644Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3719Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3719Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3719Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/tests/Tests/ORM/Functional/Ticket/DDC371Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC371Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3785Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3785Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3785Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/tests/Tests/ORM/Functional/Ticket/DDC381Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC381Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3967Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3967Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC3967Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php b/tests/Tests/ORM/Functional/Ticket/DDC4003Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4003Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC4003Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php b/tests/Tests/ORM/Functional/Ticket/DDC4024Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC4024Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC4024Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/tests/Tests/ORM/Functional/Ticket/DDC422Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC422Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/tests/Tests/ORM/Functional/Ticket/DDC425Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC425Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/tests/Tests/ORM/Functional/Ticket/DDC440Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC440Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php b/tests/Tests/ORM/Functional/Ticket/DDC444Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC444Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/tests/Tests/ORM/Functional/Ticket/DDC448Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC448Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/tests/Tests/ORM/Functional/Ticket/DDC493Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC493Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/tests/Tests/ORM/Functional/Ticket/DDC512Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC512Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/tests/Tests/ORM/Functional/Ticket/DDC513Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC513Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/tests/Tests/ORM/Functional/Ticket/DDC522Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC522Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/tests/Tests/ORM/Functional/Ticket/DDC531Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC531Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php b/tests/Tests/ORM/Functional/Ticket/DDC5684Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC5684Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC5684Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/tests/Tests/ORM/Functional/Ticket/DDC588Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC588Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/tests/Tests/ORM/Functional/Ticket/DDC599Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC599Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/tests/Tests/ORM/Functional/Ticket/DDC618Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC618Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php b/tests/Tests/ORM/Functional/Ticket/DDC6303Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC6303Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/tests/Tests/ORM/Functional/Ticket/DDC633Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC633Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php b/tests/Tests/ORM/Functional/Ticket/DDC6460Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6460Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC6460Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6558Test.php b/tests/Tests/ORM/Functional/Ticket/DDC6558Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6558Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC6558Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Tests/ORM/Functional/Ticket/DDC656Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC656Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/tests/Tests/ORM/Functional/Ticket/DDC657Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC657Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/tests/Tests/ORM/Functional/Ticket/DDC698Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC698Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php b/tests/Tests/ORM/Functional/Ticket/DDC69Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC69Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC69Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Tests/ORM/Functional/Ticket/DDC719Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC719Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/tests/Tests/ORM/Functional/Ticket/DDC735Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC735Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/tests/Tests/ORM/Functional/Ticket/DDC736Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC736Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php b/tests/Tests/ORM/Functional/Ticket/DDC748Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC748Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/tests/Tests/ORM/Functional/Ticket/DDC767Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC767Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php b/tests/Tests/ORM/Functional/Ticket/DDC7969Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC7969Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC7969Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/tests/Tests/ORM/Functional/Ticket/DDC809Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC809Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/tests/Tests/ORM/Functional/Ticket/DDC812Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC812Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Tests/ORM/Functional/Ticket/DDC832Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC832Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/tests/Tests/ORM/Functional/Ticket/DDC837Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC837Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php b/tests/Tests/ORM/Functional/Ticket/DDC849Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC849Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/tests/Tests/ORM/Functional/Ticket/DDC881Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC881Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php b/tests/Tests/ORM/Functional/Ticket/DDC933Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC933Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php b/tests/Tests/ORM/Functional/Ticket/DDC949Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC949Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/tests/Tests/ORM/Functional/Ticket/DDC960Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC960Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/tests/Tests/ORM/Functional/Ticket/DDC992Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php rename to tests/Tests/ORM/Functional/Ticket/DDC992Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php b/tests/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10049/GH10049Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyInheritor.php b/tests/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyInheritor.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyInheritor.php rename to tests/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyInheritor.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyOwner.php b/tests/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyOwner.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyOwner.php rename to tests/Tests/ORM/Functional/Ticket/GH10049/ReadOnlyPropertyOwner.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10132Test.php b/tests/Tests/ORM/Functional/Ticket/GH10132Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10132Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10132Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php b/tests/Tests/ORM/Functional/Ticket/GH10288Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10288Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10288Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10334Test.php b/tests/Tests/ORM/Functional/Ticket/GH10334Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10334Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10334Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php b/tests/Tests/ORM/Functional/Ticket/GH10336Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10336Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10336Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10348Test.php b/tests/Tests/ORM/Functional/Ticket/GH10348Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10348Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10348Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10387Test.php b/tests/Tests/ORM/Functional/Ticket/GH10387Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10387Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10387Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10450Test.php b/tests/Tests/ORM/Functional/Ticket/GH10450Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10450Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10450Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10454Test.php b/tests/Tests/ORM/Functional/Ticket/GH10454Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10454Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10454Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10462Test.php b/tests/Tests/ORM/Functional/Ticket/GH10462Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10462Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10462Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10473Test.php b/tests/Tests/ORM/Functional/Ticket/GH10473Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10473Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10473Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10531Test.php b/tests/Tests/ORM/Functional/Ticket/GH10531Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10531Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10531Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10532Test.php b/tests/Tests/ORM/Functional/Ticket/GH10532Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10532Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10532Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10566Test.php b/tests/Tests/ORM/Functional/Ticket/GH10566Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10566Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10566Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10625Test.php b/tests/Tests/ORM/Functional/Ticket/GH10625Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10625Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10625Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php b/tests/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10661/GH10661Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10661/InvalidChildEntity.php b/tests/Tests/ORM/Functional/Ticket/GH10661/InvalidChildEntity.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10661/InvalidChildEntity.php rename to tests/Tests/ORM/Functional/Ticket/GH10661/InvalidChildEntity.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10661/InvalidEntity.php b/tests/Tests/ORM/Functional/Ticket/GH10661/InvalidEntity.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10661/InvalidEntity.php rename to tests/Tests/ORM/Functional/Ticket/GH10661/InvalidEntity.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10747Test.php b/tests/Tests/ORM/Functional/Ticket/GH10747Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10747Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10747Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10752Test.php b/tests/Tests/ORM/Functional/Ticket/GH10752Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10752Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10752Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10808Test.php b/tests/Tests/ORM/Functional/Ticket/GH10808Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10808Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10808Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10869Test.php b/tests/Tests/ORM/Functional/Ticket/GH10869Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10869Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10869Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10880Test.php b/tests/Tests/ORM/Functional/Ticket/GH10880Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH10880Test.php rename to tests/Tests/ORM/Functional/Ticket/GH10880Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11017/GH11017Entity.php b/tests/Tests/ORM/Functional/Ticket/GH11017/GH11017Entity.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11017/GH11017Entity.php rename to tests/Tests/ORM/Functional/Ticket/GH11017/GH11017Entity.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11017/GH11017Enum.php b/tests/Tests/ORM/Functional/Ticket/GH11017/GH11017Enum.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11017/GH11017Enum.php rename to tests/Tests/ORM/Functional/Ticket/GH11017/GH11017Enum.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11017/GH11017Test.php b/tests/Tests/ORM/Functional/Ticket/GH11017/GH11017Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11017/GH11017Test.php rename to tests/Tests/ORM/Functional/Ticket/GH11017/GH11017Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/EntityStatus.php b/tests/Tests/ORM/Functional/Ticket/GH11037/EntityStatus.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/EntityStatus.php rename to tests/Tests/ORM/Functional/Ticket/GH11037/EntityStatus.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php b/tests/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php rename to tests/Tests/ORM/Functional/Ticket/GH11037/GH11037Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/IntEntityStatus.php b/tests/Tests/ORM/Functional/Ticket/GH11037/IntEntityStatus.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/IntEntityStatus.php rename to tests/Tests/ORM/Functional/Ticket/GH11037/IntEntityStatus.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/InvalidEntityWithTypedEnum.php b/tests/Tests/ORM/Functional/Ticket/GH11037/InvalidEntityWithTypedEnum.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/InvalidEntityWithTypedEnum.php rename to tests/Tests/ORM/Functional/Ticket/GH11037/InvalidEntityWithTypedEnum.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/StringEntityStatus.php b/tests/Tests/ORM/Functional/Ticket/GH11037/StringEntityStatus.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/StringEntityStatus.php rename to tests/Tests/ORM/Functional/Ticket/GH11037/StringEntityStatus.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/ValidEntityWithTypedEnum.php b/tests/Tests/ORM/Functional/Ticket/GH11037/ValidEntityWithTypedEnum.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11037/ValidEntityWithTypedEnum.php rename to tests/Tests/ORM/Functional/Ticket/GH11037/ValidEntityWithTypedEnum.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11058Test.php b/tests/Tests/ORM/Functional/Ticket/GH11058Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11058Test.php rename to tests/Tests/ORM/Functional/Ticket/GH11058Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityAdvanced.php b/tests/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityAdvanced.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityAdvanced.php rename to tests/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityAdvanced.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityBasic.php b/tests/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityBasic.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityBasic.php rename to tests/Tests/ORM/Functional/Ticket/GH11072/GH11072EntityBasic.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072Test.php b/tests/Tests/ORM/Functional/Ticket/GH11072/GH11072Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH11072/GH11072Test.php rename to tests/Tests/ORM/Functional/Ticket/GH11072/GH11072Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php b/tests/Tests/ORM/Functional/Ticket/GH2947Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH2947Test.php rename to tests/Tests/ORM/Functional/Ticket/GH2947Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php b/tests/Tests/ORM/Functional/Ticket/GH5562Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH5562Test.php rename to tests/Tests/ORM/Functional/Ticket/GH5562Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5742Test.php b/tests/Tests/ORM/Functional/Ticket/GH5742Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH5742Test.php rename to tests/Tests/ORM/Functional/Ticket/GH5742Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Tests/ORM/Functional/Ticket/GH5762Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php rename to tests/Tests/ORM/Functional/Ticket/GH5762Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Tests/ORM/Functional/Ticket/GH5804Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php rename to tests/Tests/ORM/Functional/Ticket/GH5804Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Tests/ORM/Functional/Ticket/GH5887Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php rename to tests/Tests/ORM/Functional/Ticket/GH5887Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5988Test.php b/tests/Tests/ORM/Functional/Ticket/GH5988Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH5988Test.php rename to tests/Tests/ORM/Functional/Ticket/GH5988Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php b/tests/Tests/ORM/Functional/Ticket/GH5998Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php rename to tests/Tests/ORM/Functional/Ticket/GH5998Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php b/tests/Tests/ORM/Functional/Ticket/GH6029Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6029Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6029Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php b/tests/Tests/ORM/Functional/Ticket/GH6141Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6141Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6141Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php b/tests/Tests/ORM/Functional/Ticket/GH6217Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6217Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6217Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Tests/ORM/Functional/Ticket/GH6362Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6362Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6362Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php b/tests/Tests/ORM/Functional/Ticket/GH6394Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6394Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6394Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php b/tests/Tests/ORM/Functional/Ticket/GH6402Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6402Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6402Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php b/tests/Tests/ORM/Functional/Ticket/GH6464Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6464Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6499OneToManyRelationshipTest.php b/tests/Tests/ORM/Functional/Ticket/GH6499OneToManyRelationshipTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6499OneToManyRelationshipTest.php rename to tests/Tests/ORM/Functional/Ticket/GH6499OneToManyRelationshipTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6499OneToOneRelationshipTest.php b/tests/Tests/ORM/Functional/Ticket/GH6499OneToOneRelationshipTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6499OneToOneRelationshipTest.php rename to tests/Tests/ORM/Functional/Ticket/GH6499OneToOneRelationshipTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6499Test.php b/tests/Tests/ORM/Functional/Ticket/GH6499Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6499Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6499Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php b/tests/Tests/ORM/Functional/Ticket/GH6531Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6531Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php b/tests/Tests/ORM/Functional/Ticket/GH6682Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6682Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php b/tests/Tests/ORM/Functional/Ticket/GH6699Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6699Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6699Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php b/tests/Tests/ORM/Functional/Ticket/GH6740Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6740Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6740Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php b/tests/Tests/ORM/Functional/Ticket/GH6823Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6823Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6823Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php b/tests/Tests/ORM/Functional/Ticket/GH6937Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH6937Test.php rename to tests/Tests/ORM/Functional/Ticket/GH6937Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7006Test.php b/tests/Tests/ORM/Functional/Ticket/GH7006Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7006Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7006Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php b/tests/Tests/ORM/Functional/Ticket/GH7012Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7012Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7012Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php b/tests/Tests/ORM/Functional/Ticket/GH7062Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7062Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php b/tests/Tests/ORM/Functional/Ticket/GH7067Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7067Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7067Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php b/tests/Tests/ORM/Functional/Ticket/GH7068Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7068Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7068Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php b/tests/Tests/ORM/Functional/Ticket/GH7079Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7079Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7079Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7180Test.php b/tests/Tests/ORM/Functional/Ticket/GH7180Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7180Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7180Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php b/tests/Tests/ORM/Functional/Ticket/GH7259Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7259Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php b/tests/Tests/ORM/Functional/Ticket/GH7286Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7286Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7286Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php b/tests/Tests/ORM/Functional/Ticket/GH7366Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7366Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7366Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php b/tests/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php rename to tests/Tests/ORM/Functional/Ticket/GH7496WithToIterableTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php b/tests/Tests/ORM/Functional/Ticket/GH7505Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7505Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7505Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php b/tests/Tests/ORM/Functional/Ticket/GH7512Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7512Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7512Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php b/tests/Tests/ORM/Functional/Ticket/GH7629Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7629Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php b/tests/Tests/ORM/Functional/Ticket/GH7661Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7661Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7661Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php b/tests/Tests/ORM/Functional/Ticket/GH7684Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7684Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7684Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7717Test.php b/tests/Tests/ORM/Functional/Ticket/GH7717Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7717Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7717Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php b/tests/Tests/ORM/Functional/Ticket/GH7735Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7735Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7735Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php b/tests/Tests/ORM/Functional/Ticket/GH7737Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7737Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7737Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php b/tests/Tests/ORM/Functional/Ticket/GH7761Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7761Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7761Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php b/tests/Tests/ORM/Functional/Ticket/GH7767Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7767Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7767Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php b/tests/Tests/ORM/Functional/Ticket/GH7820Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7820Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7820Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php b/tests/Tests/ORM/Functional/Ticket/GH7829Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7829Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7829Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php b/tests/Tests/ORM/Functional/Ticket/GH7836Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7836Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7836Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php b/tests/Tests/ORM/Functional/Ticket/GH7864Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7864Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7864Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php b/tests/Tests/ORM/Functional/Ticket/GH7869Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7869Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7869Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php b/tests/Tests/ORM/Functional/Ticket/GH7875Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7875Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7875Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php b/tests/Tests/ORM/Functional/Ticket/GH7941Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php rename to tests/Tests/ORM/Functional/Ticket/GH7941Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php b/tests/Tests/ORM/Functional/Ticket/GH8055Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8055Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8055Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php b/tests/Tests/ORM/Functional/Ticket/GH8061Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8061Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8061Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8127Test.php b/tests/Tests/ORM/Functional/Ticket/GH8127Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8127Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8127Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php b/tests/Tests/ORM/Functional/Ticket/GH8217Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8217Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8217Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8415Test.php b/tests/Tests/ORM/Functional/Ticket/GH8415Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8415Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8415Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php b/tests/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php rename to tests/Tests/ORM/Functional/Ticket/GH8415ToManyAssociationTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Tests/ORM/Functional/Ticket/GH8443Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8443Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8443Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php b/tests/Tests/ORM/Functional/Ticket/GH8499Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8499Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8499Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php b/tests/Tests/ORM/Functional/Ticket/GH8663Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8663Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8663Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php b/tests/Tests/ORM/Functional/Ticket/GH8914Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH8914Test.php rename to tests/Tests/ORM/Functional/Ticket/GH8914Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php b/tests/Tests/ORM/Functional/Ticket/GH9027Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9027Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9027Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php b/tests/Tests/ORM/Functional/Ticket/GH9109Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9109Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9109Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9192Test.php b/tests/Tests/ORM/Functional/Ticket/GH9192Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9192Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9192Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php b/tests/Tests/ORM/Functional/Ticket/GH9230Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9230Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9230Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php b/tests/Tests/ORM/Functional/Ticket/GH9335Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9335Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9335Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/GH9467Test.php b/tests/Tests/ORM/Functional/Ticket/GH9467/GH9467Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/GH9467Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9467/GH9467Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceChild.php b/tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceChild.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceChild.php rename to tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceChild.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonInsertableColumn.php b/tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonInsertableColumn.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonInsertableColumn.php rename to tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonInsertableColumn.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonUpdatableColumn.php b/tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonUpdatableColumn.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonUpdatableColumn.php rename to tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonUpdatableColumn.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonWritableColumn.php b/tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonWritableColumn.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonWritableColumn.php rename to tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceNonWritableColumn.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceRoot.php b/tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceRoot.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceRoot.php rename to tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceRoot.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceWritableColumn.php b/tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceWritableColumn.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceWritableColumn.php rename to tests/Tests/ORM/Functional/Ticket/GH9467/JoinedInheritanceWritableColumn.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9516Test.php b/tests/Tests/ORM/Functional/Ticket/GH9516Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9516Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9516Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php b/tests/Tests/ORM/Functional/Ticket/GH9579Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9579Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9579Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php b/tests/Tests/ORM/Functional/Ticket/GH9807Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/GH9807Test.php rename to tests/Tests/ORM/Functional/Ticket/GH9807Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php b/tests/Tests/ORM/Functional/Ticket/Issue5989Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php rename to tests/Tests/ORM/Functional/Ticket/Issue5989Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue9300Test.php b/tests/Tests/ORM/Functional/Ticket/Issue9300Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/Issue9300Test.php rename to tests/Tests/ORM/Functional/Ticket/Issue9300Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/tests/Tests/ORM/Functional/Ticket/Ticket2481Test.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php rename to tests/Tests/ORM/Functional/Ticket/Ticket2481Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php b/tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php rename to tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfAbstractTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php b/tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php rename to tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfMultiLevelTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php b/tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php rename to tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfParametricTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php b/tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php rename to tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php b/tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php rename to tests/Tests/ORM/Functional/Ticket/Ticket4646InstanceOfWithMultipleParametersTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Tests/ORM/Functional/TypeTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/TypeTest.php rename to tests/Tests/ORM/Functional/TypeTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/tests/Tests/ORM/Functional/TypeValueSqlTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php rename to tests/Tests/ORM/Functional/TypeValueSqlTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php b/tests/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php rename to tests/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php b/tests/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdForeignKeyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php b/tests/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/ManyToManyCompositeIdTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php b/tests/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/ManyToManyExtraLazyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php b/tests/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/ManyToManyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php b/tests/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdForeignKeyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php b/tests/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/OneToManyCompositeIdTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php b/tests/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/OneToManyExtraLazyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php b/tests/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/OneToManyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php b/tests/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdForeignKeyTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php b/tests/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/OneToOneCompositeIdTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php b/tests/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php rename to tests/Tests/ORM/Functional/ValueConversionType/OneToOneTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Tests/ORM/Functional/ValueObjectsTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php rename to tests/Tests/ORM/Functional/ValueObjectsTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php b/tests/Tests/ORM/Functional/VersionedOneToOneTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Functional/VersionedOneToOneTest.php rename to tests/Tests/ORM/Functional/VersionedOneToOneTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php b/tests/Tests/ORM/Hydration/AbstractHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/AbstractHydratorTest.php rename to tests/Tests/ORM/Hydration/AbstractHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/tests/Tests/ORM/Hydration/ArrayHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php rename to tests/Tests/ORM/Hydration/ArrayHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php b/tests/Tests/ORM/Hydration/CustomHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php rename to tests/Tests/ORM/Hydration/CustomHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php b/tests/Tests/ORM/Hydration/HydrationTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php rename to tests/Tests/ORM/Hydration/HydrationTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Tests/ORM/Hydration/ObjectHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php rename to tests/Tests/ORM/Hydration/ObjectHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Tests/ORM/Hydration/ResultSetMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php rename to tests/Tests/ORM/Hydration/ResultSetMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php b/tests/Tests/ORM/Hydration/ScalarColumnHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/ScalarColumnHydratorTest.php rename to tests/Tests/ORM/Hydration/ScalarColumnHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/tests/Tests/ORM/Hydration/ScalarHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php rename to tests/Tests/ORM/Hydration/ScalarHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Tests/ORM/Hydration/SimpleObjectHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php rename to tests/Tests/ORM/Hydration/SimpleObjectHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/tests/Tests/ORM/Hydration/SingleScalarHydratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php rename to tests/Tests/ORM/Hydration/SingleScalarHydratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/tests/Tests/ORM/Id/AssignedGeneratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php rename to tests/Tests/ORM/Id/AssignedGeneratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php b/tests/Tests/ORM/Id/SequenceGeneratorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php rename to tests/Tests/ORM/Id/SequenceGeneratorTest.php diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php rename to tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php diff --git a/tests/Doctrine/Tests/ORM/Internal/TopologicalSortTest.php b/tests/Tests/ORM/Internal/TopologicalSortTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Internal/TopologicalSortTest.php rename to tests/Tests/ORM/Internal/TopologicalSortTest.php diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Tests/ORM/LazyCriteriaCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php rename to tests/Tests/ORM/LazyCriteriaCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php rename to tests/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php b/tests/Tests/ORM/Mapping/AssociationMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/AssociationMappingTest.php rename to tests/Tests/ORM/Mapping/AssociationMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Tests/ORM/Mapping/AttributeDriverTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php rename to tests/Tests/ORM/Mapping/AttributeDriverTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeReaderTest.php b/tests/Tests/ORM/Mapping/AttributeReaderTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/AttributeReaderTest.php rename to tests/Tests/ORM/Mapping/AttributeReaderTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php rename to tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Tests/ORM/Mapping/ClassMetadataBuilderTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php rename to tests/Tests/ORM/Mapping/ClassMetadataBuilderTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php rename to tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php rename to tests/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php rename to tests/Tests/ORM/Mapping/ClassMetadataTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php b/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php rename to tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php b/tests/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php rename to tests/Tests/ORM/Mapping/DiscriminatorColumnMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/EmbeddedClassMappingTest.php b/tests/Tests/ORM/Mapping/EmbeddedClassMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/EmbeddedClassMappingTest.php rename to tests/Tests/ORM/Mapping/EmbeddedClassMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Tests/ORM/Mapping/EntityListenerResolverTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php rename to tests/Tests/ORM/Mapping/EntityListenerResolverTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php b/tests/Tests/ORM/Mapping/FieldBuilderTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php rename to tests/Tests/ORM/Mapping/FieldBuilderTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php b/tests/Tests/ORM/Mapping/FieldMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/FieldMappingTest.php rename to tests/Tests/ORM/Mapping/FieldMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/Fixtures/AttributeEntityWithNestedJoinColumns.php b/tests/Tests/ORM/Mapping/Fixtures/AttributeEntityWithNestedJoinColumns.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/Fixtures/AttributeEntityWithNestedJoinColumns.php rename to tests/Tests/ORM/Mapping/Fixtures/AttributeEntityWithNestedJoinColumns.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/InverseSideMappingTest.php b/tests/Tests/ORM/Mapping/InverseSideMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/InverseSideMappingTest.php rename to tests/Tests/ORM/Mapping/InverseSideMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php b/tests/Tests/ORM/Mapping/JoinColumnMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/JoinColumnMappingTest.php rename to tests/Tests/ORM/Mapping/JoinColumnMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php b/tests/Tests/ORM/Mapping/JoinTableMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/JoinTableMappingTest.php rename to tests/Tests/ORM/Mapping/JoinTableMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php b/tests/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php rename to tests/Tests/ORM/Mapping/ManyToManyOwningSideMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php b/tests/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php rename to tests/Tests/ORM/Mapping/ManyToOneAssociationMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php b/tests/Tests/ORM/Mapping/MappingDriverTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php rename to tests/Tests/ORM/Mapping/MappingDriverTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php b/tests/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php rename to tests/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php b/tests/Tests/ORM/Mapping/NamingStrategyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php rename to tests/Tests/ORM/Mapping/NamingStrategyTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php b/tests/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php rename to tests/Tests/ORM/Mapping/OneToOneOwningSideMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/OwningSideMappingTest.php b/tests/Tests/ORM/Mapping/OwningSideMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/OwningSideMappingTest.php rename to tests/Tests/ORM/Mapping/OwningSideMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Tests/ORM/Mapping/QuoteStrategyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php rename to tests/Tests/ORM/Mapping/QuoteStrategyTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php b/tests/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php rename to tests/Tests/ORM/Mapping/ReflectionEmbeddedPropertyTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php b/tests/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php rename to tests/Tests/ORM/Mapping/ReflectionReadonlyPropertyTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/tests/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php rename to tests/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php b/tests/Tests/ORM/Mapping/Symfony/DriverTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/Symfony/DriverTestCase.php rename to tests/Tests/ORM/Mapping/Symfony/DriverTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php b/tests/Tests/ORM/Mapping/Symfony/XmlDriverTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php rename to tests/Tests/ORM/Mapping/Symfony/XmlDriverTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php b/tests/Tests/ORM/Mapping/ToManyAssociationMappingTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/ToManyAssociationMappingTest.php rename to tests/Tests/ORM/Mapping/ToManyAssociationMappingTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapper/CustomIntAsStringTypedFieldMapper.php b/tests/Tests/ORM/Mapping/TypedFieldMapper/CustomIntAsStringTypedFieldMapper.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapper/CustomIntAsStringTypedFieldMapper.php rename to tests/Tests/ORM/Mapping/TypedFieldMapper/CustomIntAsStringTypedFieldMapper.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapperTest.php b/tests/Tests/ORM/Mapping/TypedFieldMapperTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/TypedFieldMapperTest.php rename to tests/Tests/ORM/Mapping/TypedFieldMapperTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php rename to tests/Tests/ORM/Mapping/XmlMappingDriverTest.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php b/tests/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php rename to tests/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Enums.Card.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.php b/tests/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.php rename to tests/Tests/ORM/Mapping/php/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php b/tests/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php rename to tests/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Insertable.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php b/tests/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php rename to tests/Tests/ORM/Mapping/php/Doctrine.Tests.Models.Upsertable.Updatable.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.php b/tests/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.php rename to tests/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.php diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml b/tests/Tests/ORM/Mapping/xml/CatNoId.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml rename to tests/Tests/ORM/Mapping/xml/CatNoId.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/DDC2429Book.orm.xml b/tests/Tests/ORM/Mapping/xml/DDC2429Book.orm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/DDC2429Book.orm.xml rename to tests/Tests/ORM/Mapping/xml/DDC2429Book.orm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/DDC2429Novel.orm.xml b/tests/Tests/ORM/Mapping/xml/DDC2429Novel.orm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/DDC2429Novel.orm.xml rename to tests/Tests/ORM/Mapping/xml/DDC2429Novel.orm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsAddress.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.CMS.CmsUser.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Cache.City.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Cache.City.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Cache.City.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Cache.City.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyContract.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFixContract.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexContract.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyFlexUltraContract.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Company.CompanyPerson.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.ExplicitSchemaAndTable.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC2825.SchemaAndTableInTableName.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293Address.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293Address.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293Address.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293Address.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293User.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293User.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293User.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293User.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293UserPrefixed.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293UserPrefixed.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293UserPrefixed.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3293.DDC3293UserPrefixed.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579Admin.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC3579.DDC3579User.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934BaseContract.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC5934.DDC5934Contract.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Class.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889Entity.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC889.DDC889SuperClass.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Admin.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964Guest.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC964.DDC964User.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Enums.Card.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Enums.Card.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Enums.Card.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Enums.Card.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7141.GH7141Article.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7141.GH7141Article.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7141.GH7141Article.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7141.GH7141Article.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7316.GH7316Article.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7316.GH7316Article.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7316.GH7316Article.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.GH7316.GH7316Article.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.BooleanModel.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.Project.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.Project.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.Project.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.Project.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.ProjectInvalidMapping.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.ProjectInvalidMapping.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.ProjectInvalidMapping.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.ProjectInvalidMapping.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTyped.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Insertable.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Upsertable.Updatable.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Name.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Name.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Name.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Name.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Person.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Person.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Person.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.ValueObjects.Person.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Comment.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Comment.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Comment.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Comment.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC807Entity.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.ReservedWordInTableColumn.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityIncompleteDiscriminatorColumnMapping.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.SingleTableEntityNoDiscriminatorColumnMapping.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectAttributes.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectIndex.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserIncorrectUniqueConstraint.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserMissingAttributes.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserMissingAttributes.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserMissingAttributes.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.UserMissingAttributes.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.XMLSLC.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.XMLSLC.dcm.xml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.XMLSLC.dcm.xml rename to tests/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.XMLSLC.dcm.xml diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.yml b/tests/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.yml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.yml rename to tests/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.TypedProperties.UserTypedWithCustomTypedField.dcm.yml diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.yml b/tests/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.yml similarity index 100% rename from tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.yml rename to tests/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.GH10288EnumTypePerson.dcm.yml diff --git a/tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php b/tests/Tests/ORM/ORMInvalidArgumentExceptionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/ORMInvalidArgumentExceptionTest.php rename to tests/Tests/ORM/ORMInvalidArgumentExceptionTest.php diff --git a/tests/Doctrine/Tests/ORM/ORMSetupTest.php b/tests/Tests/ORM/ORMSetupTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/ORMSetupTest.php rename to tests/Tests/ORM/ORMSetupTest.php diff --git a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php b/tests/Tests/ORM/Performance/SecondLevelCacheTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php rename to tests/Tests/ORM/Performance/SecondLevelCacheTest.php diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Tests/ORM/PersistentCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/PersistentCollectionTest.php rename to tests/Tests/ORM/PersistentCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php b/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php rename to tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php b/tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php rename to tests/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php rename to tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php diff --git a/tests/Doctrine/Tests/ORM/Persisters/Exception/UnrecognizedFieldTest.php b/tests/Tests/ORM/Persisters/Exception/UnrecognizedFieldTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Persisters/Exception/UnrecognizedFieldTest.php rename to tests/Tests/ORM/Persisters/Exception/UnrecognizedFieldTest.php diff --git a/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php b/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php rename to tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Tests/ORM/Proxy/ProxyFactoryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php rename to tests/Tests/ORM/Proxy/ProxyFactoryTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php rename to tests/Tests/ORM/Query/CustomTreeWalkersJoinTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Tests/ORM/Query/CustomTreeWalkersTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php rename to tests/Tests/ORM/Query/CustomTreeWalkersTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Tests/ORM/Query/DeleteSqlGenerationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php rename to tests/Tests/ORM/Query/DeleteSqlGenerationTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Tests/ORM/Query/ExprTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/ExprTest.php rename to tests/Tests/ORM/Query/ExprTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php b/tests/Tests/ORM/Query/FilterCollectionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php rename to tests/Tests/ORM/Query/FilterCollectionTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Tests/ORM/Query/LanguageRecognitionTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php rename to tests/Tests/ORM/Query/LanguageRecognitionTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Tests/ORM/Query/LexerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/LexerTest.php rename to tests/Tests/ORM/Query/LexerTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Tests/ORM/Query/ParameterTypeInfererTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php rename to tests/Tests/ORM/Query/ParameterTypeInfererTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php b/tests/Tests/ORM/Query/ParserResultTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/ParserResultTest.php rename to tests/Tests/ORM/Query/ParserResultTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/ParserTest.php b/tests/Tests/ORM/Query/ParserTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/ParserTest.php rename to tests/Tests/ORM/Query/ParserTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Tests/ORM/Query/QueryExpressionVisitorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php rename to tests/Tests/ORM/Query/QueryExpressionVisitorTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Tests/ORM/Query/QueryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/QueryTest.php rename to tests/Tests/ORM/Query/QueryTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php rename to tests/Tests/ORM/Query/SelectSqlGenerationTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/SqlExpressionVisitorTest.php b/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/SqlExpressionVisitorTest.php rename to tests/Tests/ORM/Query/SqlExpressionVisitorTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php b/tests/Tests/ORM/Query/SqlWalkerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/SqlWalkerTest.php rename to tests/Tests/ORM/Query/SqlWalkerTest.php diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Tests/ORM/Query/UpdateSqlGenerationTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php rename to tests/Tests/ORM/Query/UpdateSqlGenerationTest.php diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Tests/ORM/QueryBuilderTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/QueryBuilderTest.php rename to tests/Tests/ORM/QueryBuilderTest.php diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php rename to tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php b/tests/Tests/ORM/Tools/AttachEntityListenersListenerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/AttachEntityListenersListenerTest.php rename to tests/Tests/ORM/Tools/AttachEntityListenersListenerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/ClearCacheCollectionRegionCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/ClearCacheEntityRegionCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/ClearCacheQueryRegionCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/InfoCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/InfoCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/InfoCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/RunDqlCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CommandTestCase.php b/tests/Tests/ORM/Tools/Console/Command/SchemaTool/CommandTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CommandTestCase.php rename to tests/Tests/ORM/Tools/Console/Command/SchemaTool/CommandTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/SchemaTool/CreateCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/SchemaTool/DropCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php b/tests/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php rename to tests/Tests/ORM/Tools/Console/Command/SchemaTool/Models/Keyboard.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php b/tests/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php rename to tests/Tests/ORM/Tools/Console/Command/ValidateSchemaCommandTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php b/tests/Tests/ORM/Tools/Console/ConsoleRunnerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php rename to tests/Tests/ORM/Tools/Console/ConsoleRunnerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php b/tests/Tests/ORM/Tools/Console/MetadataFilterTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Console/MetadataFilterTest.php rename to tests/Tests/ORM/Tools/Console/MetadataFilterTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/DebugTest.php b/tests/Tests/ORM/Tools/DebugTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/DebugTest.php rename to tests/Tests/ORM/Tools/DebugTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php rename to tests/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php rename to tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php rename to tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php rename to tests/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php b/tests/Tests/ORM/Tools/Pagination/PaginationTestCase.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php rename to tests/Tests/ORM/Tools/Pagination/PaginationTestCase.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/PaginatorTest.php rename to tests/Tests/ORM/Tools/Pagination/PaginatorTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php rename to tests/Tests/ORM/Tools/Pagination/RootTypeWalkerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php rename to tests/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php rename to tests/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php rename to tests/Tests/ORM/Tools/SchemaToolTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Tests/ORM/Tools/SchemaValidatorTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php rename to tests/Tests/ORM/Tools/SchemaValidatorTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/TestAsset/ChildClass.php b/tests/Tests/ORM/Tools/TestAsset/ChildClass.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/TestAsset/ChildClass.php rename to tests/Tests/ORM/Tools/TestAsset/ChildClass.php diff --git a/tests/Doctrine/Tests/ORM/Tools/TestAsset/ChildWithSameAttributesClass.php b/tests/Tests/ORM/Tools/TestAsset/ChildWithSameAttributesClass.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/TestAsset/ChildWithSameAttributesClass.php rename to tests/Tests/ORM/Tools/TestAsset/ChildWithSameAttributesClass.php diff --git a/tests/Doctrine/Tests/ORM/Tools/TestAsset/ParentClass.php b/tests/Tests/ORM/Tools/TestAsset/ParentClass.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Tools/TestAsset/ParentClass.php rename to tests/Tests/ORM/Tools/TestAsset/ParentClass.php diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Tests/ORM/UnitOfWorkTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/UnitOfWorkTest.php rename to tests/Tests/ORM/UnitOfWorkTest.php diff --git a/tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php b/tests/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php rename to tests/Tests/ORM/Utility/HierarchyDiscriminatorResolverTest.php diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php b/tests/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php rename to tests/Tests/ORM/Utility/IdentifierFlattenerEnumIdTest.php diff --git a/tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php b/tests/Tests/ORM/Utility/IdentifierFlattenerTest.php similarity index 100% rename from tests/Doctrine/Tests/ORM/Utility/IdentifierFlattenerTest.php rename to tests/Tests/ORM/Utility/IdentifierFlattenerTest.php diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Tests/OrmFunctionalTestCase.php similarity index 100% rename from tests/Doctrine/Tests/OrmFunctionalTestCase.php rename to tests/Tests/OrmFunctionalTestCase.php diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Tests/OrmTestCase.php similarity index 100% rename from tests/Doctrine/Tests/OrmTestCase.php rename to tests/Tests/OrmTestCase.php diff --git a/tests/Doctrine/Tests/Proxy/AutoloaderTest.php b/tests/Tests/Proxy/AutoloaderTest.php similarity index 100% rename from tests/Doctrine/Tests/Proxy/AutoloaderTest.php rename to tests/Tests/Proxy/AutoloaderTest.php diff --git a/tests/Doctrine/Tests/TestInit.php b/tests/Tests/TestInit.php similarity index 79% rename from tests/Doctrine/Tests/TestInit.php rename to tests/Tests/TestInit.php index 2cfe1761b0d..eb2db606747 100644 --- a/tests/Doctrine/Tests/TestInit.php +++ b/tests/Tests/TestInit.php @@ -21,12 +21,12 @@ error_reporting(E_ALL | E_STRICT); date_default_timezone_set('UTC'); -if (file_exists(__DIR__ . '/../../../vendor/autoload.php')) { +if (file_exists(__DIR__ . '/../../vendor/autoload.php')) { // dependencies were installed via composer - this is the main project - require __DIR__ . '/../../../vendor/autoload.php'; -} elseif (file_exists(__DIR__ . '/../../../../../autoload.php')) { + require __DIR__ . '/../../vendor/autoload.php'; +} elseif (file_exists(__DIR__ . '/../../../../autoload.php')) { // installed as a dependency in `vendor` - require __DIR__ . '/../../../../../autoload.php'; + require __DIR__ . '/../../../../autoload.php'; } else { throw new Exception('Can\'t find autoload.php. Did you install dependencies via composer?'); } diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Tests/TestUtil.php similarity index 100% rename from tests/Doctrine/Tests/TestUtil.php rename to tests/Tests/TestUtil.php From 289339467316c9efd1c6505df637c7356c0decaf Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Wed, 17 Jan 2024 13:13:39 -0600 Subject: [PATCH 336/475] Allow XML validation to be disabled but keep it enabled by default. --- UPGRADE.md | 5 ++--- src/Mapping/Driver/SimplifiedXmlDriver.php | 12 +----------- src/Mapping/Driver/XmlDriver.php | 15 +++++---------- src/ORMSetup.php | 9 --------- tests/Tests/ORM/Mapping/XmlMappingDriverTest.php | 5 ++--- tests/Tests/ORM/ORMSetupTest.php | 5 ++--- 6 files changed, 12 insertions(+), 39 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 5249576cbee..b99c034c8cd 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -76,12 +76,11 @@ explicitly forbidden to point out mistakes. You should use `DEFERRED_EXPLICIT` instead. -## BC BREAK: `Mapping\Driver\XmlDriver::__construct()` third argument is now a no-op +## BC BREAK: `Mapping\Driver\XmlDriver::__construct()` third argument is now enabled by default The third argument to `Doctrine\ORM\Mapping\Driver\XmlDriver::__construct()` was introduced to -let users opt-in to XML validation, that is now always enabled, regardless of -the value of that argument. +let users opt-in to XML validation, that is now always enabled by default. As a consequence, the same goes for `Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver`, and for diff --git a/src/Mapping/Driver/SimplifiedXmlDriver.php b/src/Mapping/Driver/SimplifiedXmlDriver.php index 24b29eaf770..486185fead9 100644 --- a/src/Mapping/Driver/SimplifiedXmlDriver.php +++ b/src/Mapping/Driver/SimplifiedXmlDriver.php @@ -5,9 +5,6 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator; -use InvalidArgumentException; - -use function sprintf; /** * XmlDriver that additionally looks for mapping information in a global file. @@ -21,15 +18,8 @@ class SimplifiedXmlDriver extends XmlDriver */ public function __construct($prefixes, $fileExtension = self::DEFAULT_FILE_EXTENSION, bool $isXsdValidationEnabled = true) { - if (! $isXsdValidationEnabled) { - throw new InvalidArgumentException(sprintf( - 'The $isXsdValidationEnabled argument is no longer supported, make sure to omit it when calling %s.', - __METHOD__, - )); - } - $locator = new SymfonyFileLocator((array) $prefixes, $fileExtension); - parent::__construct($locator, $fileExtension); + parent::__construct($locator, $fileExtension, $isXsdValidationEnabled); } } diff --git a/src/Mapping/Driver/XmlDriver.php b/src/Mapping/Driver/XmlDriver.php index 6da790955d1..fb18dd879a7 100644 --- a/src/Mapping/Driver/XmlDriver.php +++ b/src/Mapping/Driver/XmlDriver.php @@ -43,13 +43,11 @@ class XmlDriver extends FileDriver /** * {@inheritDoc} - * - * @param true $isXsdValidationEnabled no-op, will be removed in 4.0 */ public function __construct( string|array|FileLocator $locator, string $fileExtension = self::DEFAULT_FILE_EXTENSION, - bool $isXsdValidationEnabled = true, + private readonly bool $isXsdValidationEnabled = true, ) { if (! extension_loaded('simplexml')) { throw new LogicException( @@ -58,13 +56,6 @@ public function __construct( ); } - if (! $isXsdValidationEnabled) { - throw new InvalidArgumentException(sprintf( - 'The $isXsdValidationEnabled argument is no longer supported, make sure to omit it when calling %s.', - __METHOD__, - )); - } - if (! extension_loaded('dom')) { throw new LogicException( 'XSD validation cannot be enabled because the DOM extension is missing.', @@ -914,6 +905,10 @@ protected function loadMappingFile($file) private function validateMapping(string $file): void { + if (! $this->isXsdValidationEnabled) { + return; + } + $backedUpErrorSetting = libxml_use_internal_errors(true); try { diff --git a/src/ORMSetup.php b/src/ORMSetup.php index 8a456f15a0c..0dae92fda42 100644 --- a/src/ORMSetup.php +++ b/src/ORMSetup.php @@ -6,7 +6,6 @@ use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; -use InvalidArgumentException; use Psr\Cache\CacheItemPoolInterface; use Redis; use RuntimeException; @@ -19,7 +18,6 @@ use function class_exists; use function extension_loaded; use function md5; -use function sprintf; use function sys_get_temp_dir; final class ORMSetup @@ -54,13 +52,6 @@ public static function createXMLMetadataConfiguration( CacheItemPoolInterface|null $cache = null, bool $isXsdValidationEnabled = true, ): Configuration { - if (! $isXsdValidationEnabled) { - throw new InvalidArgumentException(sprintf( - 'The $isXsdValidationEnabled argument is no longer supported, make sure to omit it when calling %s.', - __METHOD__, - )); - } - $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new XmlDriver($paths, XmlDriver::DEFAULT_FILE_EXTENSION, $isXsdValidationEnabled)); diff --git a/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php index 6de53be45c8..3fa7e43b987 100644 --- a/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -29,7 +29,6 @@ use Doctrine\Tests\Models\Project\ProjectName; use Doctrine\Tests\Models\ValueObjects\Name; use Doctrine\Tests\Models\ValueObjects\Person; -use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -301,9 +300,9 @@ public function testClassNameInFieldOrId(): void self::assertEquals(ProjectName::class, $name['type']); } - public function testDisablingXmlValidationIsNotPossible(): void + public function testDisablingXmlValidationIsPossible(): void { - $this->expectException(InvalidArgumentException::class); + $this->expectNotToPerformAssertions(); new XmlDriver( __DIR__ . DIRECTORY_SEPARATOR . 'xml', diff --git a/tests/Tests/ORM/ORMSetupTest.php b/tests/Tests/ORM/ORMSetupTest.php index cc7aa0fc63b..e2139504f71 100644 --- a/tests/Tests/ORM/ORMSetupTest.php +++ b/tests/Tests/ORM/ORMSetupTest.php @@ -9,7 +9,6 @@ use Doctrine\ORM\Mapping\Driver\AttributeDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\ORMSetup; -use InvalidArgumentException; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\Attributes\RequiresSetting; @@ -41,9 +40,9 @@ public function testXMLConfiguration(): void self::assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); } - public function testDisablingXmlValidationIsNotPossible(): void + public function testDisablingXmlValidationIsPossible(): void { - $this->expectException(InvalidArgumentException::class); + $this->expectNotToPerformAssertions(); ORMSetup::createXMLMetadataConfiguration(paths: [], isXsdValidationEnabled: false); } From cf7757e090dd222eb001da41b45f6b436e8cb470 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Fri, 26 Jan 2024 09:33:17 -0600 Subject: [PATCH 337/475] Add back check that was reverted. --- src/Mapping/Driver/XmlDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mapping/Driver/XmlDriver.php b/src/Mapping/Driver/XmlDriver.php index fb18dd879a7..4f829c70cc5 100644 --- a/src/Mapping/Driver/XmlDriver.php +++ b/src/Mapping/Driver/XmlDriver.php @@ -56,7 +56,7 @@ public function __construct( ); } - if (! extension_loaded('dom')) { + if ($isXsdValidationEnabled && ! extension_loaded('dom')) { throw new LogicException( 'XSD validation cannot be enabled because the DOM extension is missing.', ); From 537a27d27785039ee0baa08d13e30c9572efeaf5 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Fri, 26 Jan 2024 09:48:08 -0600 Subject: [PATCH 338/475] Add test verifying that xml validation disabling/enabling works as expected. --- tests/Tests/Models/InvalidXml.php | 9 +++++ .../ORM/Mapping/XmlMappingDriverTest.php | 34 +++++++++++++++++++ .../Doctrine.Tests.Models.InvalidXml.dcm.xml | 11 ++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/Tests/Models/InvalidXml.php create mode 100644 tests/Tests/ORM/Mapping/invalid_xml/Doctrine.Tests.Models.InvalidXml.dcm.xml diff --git a/tests/Tests/Models/InvalidXml.php b/tests/Tests/Models/InvalidXml.php new file mode 100644 index 00000000000..8c3f7fe7c39 --- /dev/null +++ b/tests/Tests/Models/InvalidXml.php @@ -0,0 +1,9 @@ +initializeReflection(new RuntimeReflectionService()); + + $driver->loadMetadataForClass(InvalidXml::class, $class); + } + + public function testXmlValidationDisabled(): void + { + $driver = new XmlDriver( + __DIR__ . DIRECTORY_SEPARATOR . 'invalid_xml', + XmlDriver::DEFAULT_FILE_EXTENSION, + false, + ); + + $class = new ClassMetadata(InvalidXml::class); + $class->initializeReflection(new RuntimeReflectionService()); + + $driver->loadMetadataForClass(InvalidXml::class, $class); + + self::assertCount(1, $class->fieldMappings); + } } class CTI diff --git a/tests/Tests/ORM/Mapping/invalid_xml/Doctrine.Tests.Models.InvalidXml.dcm.xml b/tests/Tests/ORM/Mapping/invalid_xml/Doctrine.Tests.Models.InvalidXml.dcm.xml new file mode 100644 index 00000000000..859bf4a70d1 --- /dev/null +++ b/tests/Tests/ORM/Mapping/invalid_xml/Doctrine.Tests.Models.InvalidXml.dcm.xml @@ -0,0 +1,11 @@ + + + + + + + + From 282b8fbfe87fab8233e4935300b0d3428963c2dc Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Fri, 26 Jan 2024 10:00:16 -0600 Subject: [PATCH 339/475] Move expectException call before line that triggers exception (best practice) --- tests/Tests/ORM/Mapping/XmlMappingDriverTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php index 2dd411f3cc7..86e6fde2cf5 100644 --- a/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -314,9 +314,6 @@ public function testDisablingXmlValidationIsPossible(): void public function testXmlValidationEnabled(): void { - self::expectException(MappingException::class); - self::expectExceptionMessage("libxml error: Element '{http://doctrine-project.org/schemas/orm/doctrine-mapping}field', attribute 'invalid': The attribute 'invalid' is not allowed."); - $driver = new XmlDriver( __DIR__ . DIRECTORY_SEPARATOR . 'invalid_xml', XmlDriver::DEFAULT_FILE_EXTENSION, @@ -326,6 +323,9 @@ public function testXmlValidationEnabled(): void $class = new ClassMetadata(InvalidXml::class); $class->initializeReflection(new RuntimeReflectionService()); + self::expectException(MappingException::class); + self::expectExceptionMessage("libxml error: Element '{http://doctrine-project.org/schemas/orm/doctrine-mapping}field', attribute 'invalid': The attribute 'invalid' is not allowed."); + $driver->loadMetadataForClass(InvalidXml::class, $class); } From 09f0966ad63f11f7f8c43c3e435cb369cc150164 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 31 Jan 2024 22:34:35 +0100 Subject: [PATCH 340/475] Fix CS after merge-up --- .../LimitSubqueryOutputWalkerTest.php | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index f7b5eff5763..b8c04dab212 100644 --- a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -19,7 +19,7 @@ public function testLimitSubquery(): void self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, m0_.author_id AS author_id_5, m0_.category_id AS category_id_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -31,7 +31,7 @@ public function testLimitSubqueryWithSortPg(): void self::assertSame( 'SELECT DISTINCT id_0, MIN(sclr_5) AS dctrn_minrownum FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS sclr_5, m0_.author_id AS author_id_6, m0_.category_id AS category_id_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -43,7 +43,7 @@ public function testLimitSubqueryWithScalarSortPg(): void self::assertSame( 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -55,7 +55,7 @@ public function testLimitSubqueryWithMixedSortPg(): void self::assertSame( 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -67,7 +67,7 @@ public function testLimitSubqueryWithHiddenScalarSortPg(): void self::assertSame( 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -86,7 +86,7 @@ public function testLimitSubqueryWithSortOracle(): void self::assertSame( 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS SCLR_5, m0_.author_id AS AUTHOR_ID_6, m0_.category_id AS CATEGORY_ID_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL() + $query->getSQL(), ); } @@ -98,7 +98,7 @@ public function testLimitSubqueryWithScalarSortOracle(): void self::assertSame( 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL() + $query->getSQL(), ); } @@ -110,7 +110,7 @@ public function testLimitSubqueryWithMixedSortOracle(): void self::assertSame( 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL() + $query->getSQL(), ); } @@ -122,7 +122,7 @@ public function testLimitSubqueryOracle(): void self::assertSame( 'SELECT DISTINCT ID_0 FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, m0_.author_id AS AUTHOR_ID_5, m0_.category_id AS CATEGORY_ID_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL() + $query->getSQL(), ); } @@ -132,7 +132,7 @@ public function testCountQueryMixedResultsWithName(): void self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -145,7 +145,7 @@ public function testCountQueryWithArithmeticOrderByCondition(): void self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, (1 - 1000) * 1 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1 FROM Author a0_) dctrn_result_inner ORDER BY (1 - 1000) * 1 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -157,7 +157,7 @@ public function testCountQueryWithComplexScalarOrderByItemWithoutJoin(): void self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_2 * imageWidth_3 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageHeight_2 * imageWidth_3 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -169,7 +169,7 @@ public function testCountQueryWithComplexScalarOrderByItemJoined(): void self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_3 * imageWidth_4 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.image AS image_2, a1_.imageHeight AS imageHeight_3, a1_.imageWidth AS imageWidth_4, a1_.imageAltDesc AS imageAltDesc_5, a1_.user_id AS user_id_6 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_3 * imageWidth_4 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -181,7 +181,7 @@ public function testCountQueryWithComplexScalarOrderByItemOracle(): void self::assertSame( 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.image AS IMAGE_1, a0_.imageHeight AS IMAGEHEIGHT_2, a0_.imageWidth AS IMAGEWIDTH_3, a0_.imageAltDesc AS IMAGEALTDESC_4, ROW_NUMBER() OVER(ORDER BY a0_.imageHeight * a0_.imageWidth DESC) AS SCLR_5, a0_.user_id AS USER_ID_6 FROM Avatar a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL() + $query->getSQL(), ); } @@ -189,23 +189,26 @@ public function testCountQueryWithComplexScalarOrderByItemOracle(): void public function testLimitSubqueryWithHiddenSelectionInOrderBy(): void { $query = $this->createQuery( - 'SELECT a, a.name AS HIDDEN ord FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY ord DESC' + 'SELECT a, a.name AS HIDDEN ord FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY ord DESC', ); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_) dctrn_result_inner ORDER BY name_2 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } public function testLimitSubqueryWithColumnWithSortDirectionInName(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $query = $this->createQuery('SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageAltDesc DESC'); + + $query = $this->createQuery( + 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageAltDesc DESC', + ); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageAltDesc_4 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageAltDesc_4 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -215,7 +218,7 @@ public function testLimitSubqueryWithOrderByInnerJoined(): void self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_2 FROM (SELECT b0_.id AS id_0, a1_.id AS id_1, a1_.name AS name_2, b0_.author_id AS author_id_3, b0_.category_id AS category_id_4 FROM BlogPost b0_ INNER JOIN Author a1_ ON b0_.author_id = a1_.id) dctrn_result_inner ORDER BY name_2 ASC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -231,7 +234,7 @@ public function testLimitSubqueryWithOrderByAndSubSelectInWhereClauseMySql(): vo self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ WHERE ((SELECT COUNT(b1_.id) AS sclr_3 FROM BlogPost b1_) = 1)) dctrn_result_inner ORDER BY id_0 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -247,7 +250,7 @@ public function testLimitSubqueryWithOrderByAndSubSelectInWhereClausePgSql(): vo self::assertSame( 'SELECT DISTINCT id_0, MIN(sclr_1) AS dctrn_minrownum FROM (SELECT b0_.id AS id_0, ROW_NUMBER() OVER(ORDER BY b0_.id DESC) AS sclr_1, b0_.author_id AS author_id_2, b0_.category_id AS category_id_3 FROM BlogPost b0_ WHERE ((SELECT COUNT(b1_.id) AS sclr_4 FROM BlogPost b1_) = 1)) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -260,12 +263,12 @@ public function testLimitSubqueryOrderByFieldFromMappedSuperclass(): void // now use the third one in query $query = $this->createQuery( - 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC' + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC', ); self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.name AS name_1 FROM Banner b0_) dctrn_result_inner ORDER BY id_0 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -289,7 +292,7 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpression(): void self::assertSame( 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, sclr_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, (SELECT MIN(m1_.title) AS sclr_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS sclr_2 FROM Author a0_) dctrn_result_inner ORDER BY sclr_2 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -313,7 +316,7 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpressionPg(): void self::assertSame( 'SELECT DISTINCT id_0, MIN(sclr_4) AS dctrn_minrownum FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, (SELECT MIN(m1_.title) AS sclr_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS sclr_2, ROW_NUMBER() OVER(ORDER BY (SELECT MIN(m1_.title) AS sclr_5 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) DESC) AS sclr_4 FROM Author a0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL() + $query->getSQL(), ); } @@ -337,7 +340,7 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpressionOracle(): void self::assertSame( 'SELECT DISTINCT ID_0, MIN(SCLR_4) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.name AS NAME_1, (SELECT MIN(m1_.title) AS SCLR_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS SCLR_2, ROW_NUMBER() OVER(ORDER BY (SELECT MIN(m1_.title) AS SCLR_5 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) DESC) AS SCLR_4 FROM Author a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL() + $query->getSQL(), ); } From 1df03f21e671b93868071aae9ed5795511f11488 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 1 Feb 2024 09:40:04 +0100 Subject: [PATCH 341/475] Write LimitSubqueryOutputWalkerTest in a way that is portable between DBAL 3 and 4 --- .../LimitSubqueryOutputWalkerTest.php | 228 ++++++------------ 1 file changed, 74 insertions(+), 154 deletions(-) diff --git a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index b8c04dab212..65d0dbabf23 100644 --- a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -15,11 +15,9 @@ final class LimitSubqueryOutputWalkerTest extends PaginationTestCase { public function testLimitSubquery(): void { - $query = $this->createQuery('SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a'); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, m0_.author_id AS author_id_5, m0_.category_id AS category_id_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, m0_.author_id AS author_id_5, m0_.category_id AS category_id_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result', + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a', ); } @@ -27,11 +25,9 @@ public function testLimitSubqueryWithSortPg(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->createQuery('SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title'); - - self::assertSame( - 'SELECT DISTINCT id_0, MIN(sclr_5) AS dctrn_minrownum FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS sclr_5, m0_.author_id AS author_id_6, m0_.category_id AS category_id_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0, MIN(sclr_5) AS dctrn_minrownum FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS sclr_5, m0_.author_id AS author_id_6, m0_.category_id AS category_id_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title', ); } @@ -39,11 +35,9 @@ public function testLimitSubqueryWithScalarSortPg(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->createQuery('SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity'); - - self::assertSame( - 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', + 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity', ); } @@ -51,11 +45,9 @@ public function testLimitSubqueryWithMixedSortPg(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->createQuery('SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC'); - - self::assertSame( - 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', + 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC', ); } @@ -63,11 +55,9 @@ public function testLimitSubqueryWithHiddenScalarSortPg(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->createQuery('SELECT u, g, COUNT(g.id) AS hidden g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC'); - - self::assertSame( - 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC', + 'SELECT u, g, COUNT(g.id) AS hidden g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC', ); } @@ -82,11 +72,9 @@ public function testLimitSubqueryWithSortOracle(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->createQuery('SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title'); - - self::assertSame( - 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS SCLR_5, m0_.author_id AS AUTHOR_ID_6, m0_.category_id AS CATEGORY_ID_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS SCLR_5, m0_.author_id AS AUTHOR_ID_6, m0_.category_id AS CATEGORY_ID_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title', ); } @@ -94,11 +82,9 @@ public function testLimitSubqueryWithScalarSortOracle(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->createQuery('SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity'); - - self::assertSame( - 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC', + 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity', ); } @@ -106,11 +92,9 @@ public function testLimitSubqueryWithMixedSortOracle(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->createQuery('SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC'); - - self::assertSame( - 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC', + 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity, u.id DESC', ); } @@ -118,21 +102,17 @@ public function testLimitSubqueryOracle(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->createQuery('SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a'); - - self::assertSame( - 'SELECT DISTINCT ID_0 FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, m0_.author_id AS AUTHOR_ID_5, m0_.category_id AS CATEGORY_ID_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT ID_0 FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, m0_.author_id AS AUTHOR_ID_5, m0_.category_id AS CATEGORY_ID_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result', + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a', ); } public function testCountQueryMixedResultsWithName(): void { - $query = $this->createQuery('SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a'); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result', + 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a', ); } @@ -141,11 +121,9 @@ public function testCountQueryWithArithmeticOrderByCondition(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $query = $this->createQuery('SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY (1 - 1000) * 1 DESC'); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, (1 - 1000) * 1 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1 FROM Author a0_) dctrn_result_inner ORDER BY (1 - 1000) * 1 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, (1 - 1000) * 1 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1 FROM Author a0_) dctrn_result_inner ORDER BY (1 - 1000) * 1 DESC) dctrn_result', + 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY (1 - 1000) * 1 DESC', ); } @@ -153,11 +131,9 @@ public function testCountQueryWithComplexScalarOrderByItemWithoutJoin(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $query = $this->createQuery('SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC'); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_2 * imageWidth_3 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageHeight_2 * imageWidth_3 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_2 * imageWidth_3 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageHeight_2 * imageWidth_3 DESC) dctrn_result', + 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC', ); } @@ -165,11 +141,9 @@ public function testCountQueryWithComplexScalarOrderByItemJoined(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $query = $this->createQuery('SELECT u FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC'); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_3 * imageWidth_4 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.image AS image_2, a1_.imageHeight AS imageHeight_3, a1_.imageWidth AS imageWidth_4, a1_.imageAltDesc AS imageAltDesc_5, a1_.user_id AS user_id_6 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_3 * imageWidth_4 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_3 * imageWidth_4 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.image AS image_2, a1_.imageHeight AS imageHeight_3, a1_.imageWidth AS imageWidth_4, a1_.imageAltDesc AS imageAltDesc_5, a1_.user_id AS user_id_6 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_3 * imageWidth_4 DESC) dctrn_result', + 'SELECT u FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC', ); } @@ -177,48 +151,36 @@ public function testCountQueryWithComplexScalarOrderByItemOracle(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->createQuery('SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC'); - - self::assertSame( - 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.image AS IMAGE_1, a0_.imageHeight AS IMAGEHEIGHT_2, a0_.imageWidth AS IMAGEWIDTH_3, a0_.imageAltDesc AS IMAGEALTDESC_4, ROW_NUMBER() OVER(ORDER BY a0_.imageHeight * a0_.imageWidth DESC) AS SCLR_5, a0_.user_id AS USER_ID_6 FROM Avatar a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.image AS IMAGE_1, a0_.imageHeight AS IMAGEHEIGHT_2, a0_.imageWidth AS IMAGEWIDTH_3, a0_.imageAltDesc AS IMAGEALTDESC_4, ROW_NUMBER() OVER(ORDER BY a0_.imageHeight * a0_.imageWidth DESC) AS SCLR_5, a0_.user_id AS USER_ID_6 FROM Avatar a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', + 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC', ); } #[Group('DDC-3434')] public function testLimitSubqueryWithHiddenSelectionInOrderBy(): void { - $query = $this->createQuery( + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_) dctrn_result_inner ORDER BY name_2 DESC) dctrn_result', 'SELECT a, a.name AS HIDDEN ord FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY ord DESC', ); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_) dctrn_result_inner ORDER BY name_2 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), - ); } public function testLimitSubqueryWithColumnWithSortDirectionInName(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $query = $this->createQuery( + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageAltDesc_4 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageAltDesc_4 DESC) dctrn_result', 'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageAltDesc DESC', ); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageAltDesc_4 FROM (SELECT a0_.id AS id_0, a0_.image AS image_1, a0_.imageHeight AS imageHeight_2, a0_.imageWidth AS imageWidth_3, a0_.imageAltDesc AS imageAltDesc_4, a0_.user_id AS user_id_5 FROM Avatar a0_) dctrn_result_inner ORDER BY imageAltDesc_4 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), - ); } public function testLimitSubqueryWithOrderByInnerJoined(): void { - $query = $this->createQuery('SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b JOIN b.author a ORDER BY a.name ASC'); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_2 FROM (SELECT b0_.id AS id_0, a1_.id AS id_1, a1_.name AS name_2, b0_.author_id AS author_id_3, b0_.category_id AS category_id_4 FROM BlogPost b0_ INNER JOIN Author a1_ ON b0_.author_id = a1_.id) dctrn_result_inner ORDER BY name_2 ASC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_2 FROM (SELECT b0_.id AS id_0, a1_.id AS id_1, a1_.name AS name_2, b0_.author_id AS author_id_3, b0_.category_id AS category_id_4 FROM BlogPost b0_ INNER JOIN Author a1_ ON b0_.author_id = a1_.id) dctrn_result_inner ORDER BY name_2 ASC) dctrn_result', + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b JOIN b.author a ORDER BY a.name ASC', ); } @@ -226,15 +188,9 @@ public function testLimitSubqueryWithOrderByAndSubSelectInWhereClauseMySql(): vo { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $query = $this->createQuery( - 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b -WHERE ((SELECT COUNT(simple.id) FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost simple) = 1) -ORDER BY b.id DESC', - ); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ WHERE ((SELECT COUNT(b1_.id) AS sclr_3 FROM BlogPost b1_) = 1)) dctrn_result_inner ORDER BY id_0 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ WHERE ((SELECT COUNT(b1_.id) AS sclr_3 FROM BlogPost b1_) = 1)) dctrn_result_inner ORDER BY id_0 DESC) dctrn_result', + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b WHERE ((SELECT COUNT(simple.id) FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost simple) = 1) ORDER BY b.id DESC', ); } @@ -242,15 +198,9 @@ public function testLimitSubqueryWithOrderByAndSubSelectInWhereClausePgSql(): vo { $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->createQuery( - 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b -WHERE ((SELECT COUNT(simple.id) FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost simple) = 1) -ORDER BY b.id DESC', - ); - - self::assertSame( - 'SELECT DISTINCT id_0, MIN(sclr_1) AS dctrn_minrownum FROM (SELECT b0_.id AS id_0, ROW_NUMBER() OVER(ORDER BY b0_.id DESC) AS sclr_1, b0_.author_id AS author_id_2, b0_.category_id AS category_id_3 FROM BlogPost b0_ WHERE ((SELECT COUNT(b1_.id) AS sclr_4 FROM BlogPost b1_) = 1)) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0, MIN(sclr_1) AS dctrn_minrownum FROM (SELECT b0_.id AS id_0, ROW_NUMBER() OVER(ORDER BY b0_.id DESC) AS sclr_1, b0_.author_id AS author_id_2, b0_.category_id AS category_id_3 FROM BlogPost b0_ WHERE ((SELECT COUNT(b1_.id) AS sclr_4 FROM BlogPost b1_) = 1)) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b WHERE ((SELECT COUNT(simple.id) FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost simple) = 1) ORDER BY b.id DESC', ); } @@ -261,15 +211,10 @@ public function testLimitSubqueryOrderByFieldFromMappedSuperclass(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - // now use the third one in query - $query = $this->createQuery( + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.name AS name_1 FROM Banner b0_) dctrn_result_inner ORDER BY id_0 DESC) dctrn_result', 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC', ); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.name AS name_1 FROM Banner b0_) dctrn_result_inner ORDER BY id_0 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), - ); } /** @@ -279,20 +224,9 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpression(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); - $query = $this->createQuery( - 'SELECT a, - ( - SELECT MIN(bp.title) - FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost bp - WHERE bp.author = a - ) AS HIDDEN first_blog_post - FROM Doctrine\Tests\ORM\Tools\Pagination\Author a - ORDER BY first_blog_post DESC', - ); - - self::assertSame( - 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, sclr_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, (SELECT MIN(m1_.title) AS sclr_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS sclr_2 FROM Author a0_) dctrn_result_inner ORDER BY sclr_2 DESC) dctrn_result LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, sclr_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, (SELECT MIN(m1_.title) AS sclr_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS sclr_2 FROM Author a0_) dctrn_result_inner ORDER BY sclr_2 DESC) dctrn_result', + 'SELECT a, ( SELECT MIN(bp.title) FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost bp WHERE bp.author = a ) AS HIDDEN first_blog_post FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY first_blog_post DESC', ); } @@ -303,20 +237,9 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpressionPg(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new PostgreSQLPlatform()); - $query = $this->createQuery( - 'SELECT a, - ( - SELECT MIN(bp.title) - FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost bp - WHERE bp.author = a - ) AS HIDDEN first_blog_post - FROM Doctrine\Tests\ORM\Tools\Pagination\Author a - ORDER BY first_blog_post DESC', - ); - - self::assertSame( - 'SELECT DISTINCT id_0, MIN(sclr_4) AS dctrn_minrownum FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, (SELECT MIN(m1_.title) AS sclr_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS sclr_2, ROW_NUMBER() OVER(ORDER BY (SELECT MIN(m1_.title) AS sclr_5 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) DESC) AS sclr_4 FROM Author a0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC LIMIT 20 OFFSET 10', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT id_0, MIN(sclr_4) AS dctrn_minrownum FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, (SELECT MIN(m1_.title) AS sclr_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS sclr_2, ROW_NUMBER() OVER(ORDER BY (SELECT MIN(m1_.title) AS sclr_5 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) DESC) AS sclr_4 FROM Author a0_) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC', + 'SELECT a, ( SELECT MIN(bp.title) FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost bp WHERE bp.author = a ) AS HIDDEN first_blog_post FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY first_blog_post DESC', ); } @@ -327,20 +250,9 @@ public function testLimitSubqueryOrderBySubSelectOrderByExpressionOracle(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); - $query = $this->createQuery( - 'SELECT a, - ( - SELECT MIN(bp.title) - FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost bp - WHERE bp.author = a - ) AS HIDDEN first_blog_post - FROM Doctrine\Tests\ORM\Tools\Pagination\Author a - ORDER BY first_blog_post DESC', - ); - - self::assertSame( - 'SELECT DISTINCT ID_0, MIN(SCLR_4) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.name AS NAME_1, (SELECT MIN(m1_.title) AS SCLR_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS SCLR_2, ROW_NUMBER() OVER(ORDER BY (SELECT MIN(m1_.title) AS SCLR_5 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) DESC) AS SCLR_4 FROM Author a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC OFFSET 10 ROWS FETCH NEXT 20 ROWS ONLY', - $query->getSQL(), + $this->assertQuerySql( + 'SELECT DISTINCT ID_0, MIN(SCLR_4) AS dctrn_minrownum FROM (SELECT a0_.id AS ID_0, a0_.name AS NAME_1, (SELECT MIN(m1_.title) AS SCLR_3 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) AS SCLR_2, ROW_NUMBER() OVER(ORDER BY (SELECT MIN(m1_.title) AS SCLR_5 FROM MyBlogPost m1_ WHERE m1_.author_id = a0_.id) DESC) AS SCLR_4 FROM Author a0_) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC', + 'SELECT a, ( SELECT MIN(bp.title) FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost bp WHERE bp.author = a ) AS HIDDEN first_blog_post FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY first_blog_post DESC', ); } @@ -353,4 +265,12 @@ private function createQuery(string $dql): Query return $query; } + + private function assertQuerySql(string $expectedSql, string $dql): void + { + $sql = $this->entityManager->getConnection()->getDatabasePlatform()->modifyLimitQuery($expectedSql, 20, 10); + $query = $this->createQuery($dql); + + self::assertSame($sql, $query->getSQL()); + } } From c7a91a459cf4367d39b73df043da180b7594d370 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 1 Feb 2024 09:49:15 +0100 Subject: [PATCH 342/475] Fix Psalm complaints after merge-up --- psalm-baseline.xml | 3 --- psalm.xml | 1 - src/Query/Exec/MultiTableUpdateExecutor.php | 9 +++++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e4bc4192390..17a090f3a2c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -890,9 +890,6 @@ sqlStatements]]> - - MultiTableUpdateExecutor - diff --git a/psalm.xml b/psalm.xml index af7cf3b78c8..6036c3a1017 100644 --- a/psalm.xml +++ b/psalm.xml @@ -107,7 +107,6 @@ - diff --git a/src/Query/Exec/MultiTableUpdateExecutor.php b/src/Query/Exec/MultiTableUpdateExecutor.php index cf25d3f468a..dab1b6172f9 100644 --- a/src/Query/Exec/MultiTableUpdateExecutor.php +++ b/src/Query/Exec/MultiTableUpdateExecutor.php @@ -42,10 +42,11 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor */ public function __construct(AST\Node $AST, SqlWalker $sqlWalker) { - $em = $sqlWalker->getEntityManager(); - $conn = $em->getConnection(); - $platform = $conn->getDatabasePlatform(); - $quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); + $em = $sqlWalker->getEntityManager(); + $conn = $em->getConnection(); + $platform = $conn->getDatabasePlatform(); + $quoteStrategy = $em->getConfiguration()->getQuoteStrategy(); + $this->sqlStatements = []; if ($conn instanceof PrimaryReadReplicaConnection) { $conn->ensureConnectedToPrimary(); From 5b8b5f28f535e1f03b54dcfb0427407ed92f5b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 3 Feb 2024 17:50:09 +0100 Subject: [PATCH 343/475] Run Rector on the source code (#11205) --- .../EntityIdentityCollisionException.php | 5 ++--- src/Internal/Hydration/ObjectHydrator.php | 8 +++----- .../TopologicalSort/CycleDetectedException.php | 2 +- src/Mapping/AssociationMapping.php | 2 +- src/Mapping/ClassMetadata.php | 6 +----- src/ORMSetup.php | 1 - src/PersistentCollection.php | 8 +------- src/Persisters/Entity/SingleTablePersister.php | 2 +- src/Proxy/Autoloader.php | 6 +++--- src/Proxy/DefaultProxyClassNameResolver.php | 3 +-- src/Proxy/ProxyFactory.php | 2 +- src/Tools/Debug.php | 5 ++--- src/Tools/Pagination/Paginator.php | 4 +--- src/Tools/SchemaValidator.php | 3 +-- src/UnitOfWork.php | 17 ++++++++--------- 15 files changed, 27 insertions(+), 47 deletions(-) diff --git a/src/Exception/EntityIdentityCollisionException.php b/src/Exception/EntityIdentityCollisionException.php index 06ddd5dce20..0af3162f605 100644 --- a/src/Exception/EntityIdentityCollisionException.php +++ b/src/Exception/EntityIdentityCollisionException.php @@ -6,7 +6,6 @@ use Exception; -use function get_class; use function sprintf; final class EntityIdentityCollisionException extends Exception implements ORMException @@ -31,9 +30,9 @@ public static function create(object $existingEntity, object $newEntity, string Otherwise, it might be an ORM-internal inconsistency, please report it. EXCEPTION , - get_class($newEntity), + $newEntity::class, $idHash, - get_class($existingEntity), + $existingEntity::class, ), ); } diff --git a/src/Internal/Hydration/ObjectHydrator.php b/src/Internal/Hydration/ObjectHydrator.php index 774100b6e5f..c83c1e4701e 100644 --- a/src/Internal/Hydration/ObjectHydrator.php +++ b/src/Internal/Hydration/ObjectHydrator.php @@ -277,11 +277,9 @@ private function getEntityFromIdentityMap(string $className, array $data): objec $idHash = UnitOfWork::getIdHashByIdentifier( array_map( /** @return mixed */ - static function (string $fieldName) use ($data, $class) { - return isset($class->associationMappings[$fieldName]) && assert($class->associationMappings[$fieldName]->isToOneOwningSide()) - ? $data[$class->associationMappings[$fieldName]->joinColumns[0]->name] - : $data[$fieldName]; - }, + static fn (string $fieldName) => isset($class->associationMappings[$fieldName]) && assert($class->associationMappings[$fieldName]->isToOneOwningSide()) + ? $data[$class->associationMappings[$fieldName]->joinColumns[0]->name] + : $data[$fieldName], $class->identifier, ), ); diff --git a/src/Internal/TopologicalSort/CycleDetectedException.php b/src/Internal/TopologicalSort/CycleDetectedException.php index c28ce561dce..3af5329fcb0 100644 --- a/src/Internal/TopologicalSort/CycleDetectedException.php +++ b/src/Internal/TopologicalSort/CycleDetectedException.php @@ -18,7 +18,7 @@ class CycleDetectedException extends RuntimeException */ private bool $cycleCollected = false; - public function __construct(private object $startNode) + public function __construct(private readonly object $startNode) { parent::__construct('A cycle has been detected, so a topological sort is not possible. The getCycle() method provides the list of nodes that form the cycle.'); diff --git a/src/Mapping/AssociationMapping.php b/src/Mapping/AssociationMapping.php index ea78bbd6764..0253413e8d8 100644 --- a/src/Mapping/AssociationMapping.php +++ b/src/Mapping/AssociationMapping.php @@ -221,7 +221,7 @@ final public function type(): int $this instanceof OneToManyAssociationMapping => ClassMetadata::ONE_TO_MANY, $this instanceof ManyToOneAssociationMapping => ClassMetadata::MANY_TO_ONE, $this instanceof ManyToManyAssociationMapping => ClassMetadata::MANY_TO_MANY, - default => throw new Exception('Cannot determine type for ' . $this::class), + default => throw new Exception('Cannot determine type for ' . static::class), }; } diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index 1ac54a40b4e..0d9889b6e77 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -2488,11 +2488,7 @@ public function fullyQualifiedClassName(string|null $className): string|null public function getMetadataValue(string $name): mixed { - if (isset($this->$name)) { - return $this->$name; - } - - return null; + return $this->$name ?? null; } /** diff --git a/src/ORMSetup.php b/src/ORMSetup.php index 0dae92fda42..7354c710fe9 100644 --- a/src/ORMSetup.php +++ b/src/ORMSetup.php @@ -43,7 +43,6 @@ public static function createAttributeMetadataConfiguration( * Creates a configuration with an XML metadata driver. * * @param string[] $paths - * @param true $isXsdValidationEnabled */ public static function createXMLMetadataConfiguration( array $paths, diff --git a/src/PersistentCollection.php b/src/PersistentCollection.php index 60cbacb34e2..1fcc61da2e9 100644 --- a/src/PersistentCollection.php +++ b/src/PersistentCollection.php @@ -61,11 +61,6 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec */ private AssociationMapping|null $association = null; - /** - * The EntityManager that manages the persistence of the collection. - */ - private EntityManagerInterface|null $em = null; - /** * The name of the field on the target entities that points to the owner * of the collection. This is only set if the association is bi-directional. @@ -86,12 +81,11 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec * @psalm-param Collection&Selectable $collection The collection elements. */ public function __construct( - EntityManagerInterface $em, + private EntityManagerInterface|null $em, private readonly ClassMetadata|null $typeClass, Collection $collection, ) { $this->collection = $collection; - $this->em = $em; $this->initialized = true; } diff --git a/src/Persisters/Entity/SingleTablePersister.php b/src/Persisters/Entity/SingleTablePersister.php index bd12f50f16a..4a4d9998266 100644 --- a/src/Persisters/Entity/SingleTablePersister.php +++ b/src/Persisters/Entity/SingleTablePersister.php @@ -138,7 +138,7 @@ protected function getSelectConditionCriteriaSQL(Criteria $criteria): string protected function getSelectConditionDiscriminatorValueSQL(): string { - $values = array_map([$this->conn, 'quote'], array_map( + $values = array_map($this->conn->quote(...), array_map( strval(...), array_flip(array_intersect($this->class->discriminatorMap, $this->class->subClasses)), )); diff --git a/src/Proxy/Autoloader.php b/src/Proxy/Autoloader.php index d30477a80e8..1013e735d32 100644 --- a/src/Proxy/Autoloader.php +++ b/src/Proxy/Autoloader.php @@ -10,8 +10,8 @@ use function ltrim; use function spl_autoload_register; use function str_replace; +use function str_starts_with; use function strlen; -use function strpos; use function substr; use const DIRECTORY_SEPARATOR; @@ -34,7 +34,7 @@ final class Autoloader */ public static function resolveFile(string $proxyDir, string $proxyNamespace, string $className): string { - if (strpos($className, $proxyNamespace) !== 0) { + if (! str_starts_with($className, $proxyNamespace)) { throw new NotAProxyClass($className, $proxyNamespace); } @@ -66,7 +66,7 @@ public static function register( return; } - if (strpos($className, $proxyNamespace) !== 0) { + if (! str_starts_with($className, $proxyNamespace)) { return; } diff --git a/src/Proxy/DefaultProxyClassNameResolver.php b/src/Proxy/DefaultProxyClassNameResolver.php index 6a6fd1c9579..1345f2e3122 100644 --- a/src/Proxy/DefaultProxyClassNameResolver.php +++ b/src/Proxy/DefaultProxyClassNameResolver.php @@ -7,7 +7,6 @@ use Doctrine\Persistence\Mapping\ProxyClassNameResolver; use Doctrine\Persistence\Proxy; -use function get_class; use function strrpos; use function substr; @@ -31,6 +30,6 @@ public function resolveClassName(string $className): string /** @return class-string */ public static function getClass(object $object): string { - return (new self())->resolveClassName(get_class($object)); + return (new self())->resolveClassName($object::class); } } diff --git a/src/Proxy/ProxyFactory.php b/src/Proxy/ProxyFactory.php index 2a8e70f5bbc..f784cefa651 100644 --- a/src/Proxy/ProxyFactory.php +++ b/src/Proxy/ProxyFactory.php @@ -138,7 +138,7 @@ public function __serialize(): array */ public function __construct( private readonly EntityManagerInterface $em, - private string $proxyDir, + private readonly string $proxyDir, private readonly string $proxyNs, bool|int $autoGenerate = self::AUTOGENERATE_NEVER, ) { diff --git a/src/Tools/Debug.php b/src/Tools/Debug.php index ec27065b3dd..8521e53decc 100644 --- a/src/Tools/Debug.php +++ b/src/Tools/Debug.php @@ -17,7 +17,6 @@ use function end; use function explode; use function extension_loaded; -use function get_class; use function html_entity_decode; use function ini_get; use function ini_set; @@ -95,7 +94,7 @@ public static function export(mixed $var, int $maxDepth): mixed } if (! $maxDepth) { - return is_object($var) ? get_class($var) + return is_object($var) ? $var::class : (is_array($var) ? 'Array(' . count($var) . ')' : $var); } @@ -115,7 +114,7 @@ public static function export(mixed $var, int $maxDepth): mixed $return = new stdClass(); if ($var instanceof DateTimeInterface) { - $return->__CLASS__ = get_class($var); + $return->__CLASS__ = $var::class; $return->date = $var->format('c'); $return->timezone = $var->getTimezone()->getName(); diff --git a/src/Tools/Pagination/Paginator.php b/src/Tools/Pagination/Paginator.php index 01f97501484..db1b34db715 100644 --- a/src/Tools/Pagination/Paginator.php +++ b/src/Tools/Pagination/Paginator.php @@ -258,8 +258,6 @@ private function convertWhereInIdentifiersToDatabaseValues(array $identifiers): $type = $query->getSQL(); assert(is_string($type)); - return array_map(static function ($id) use ($connection, $type): mixed { - return $connection->convertToDatabaseValue($id, $type); - }, $identifiers); + return array_map(static fn ($id): mixed => $connection->convertToDatabaseValue($id, $type), $identifiers); } } diff --git a/src/Tools/SchemaValidator.php b/src/Tools/SchemaValidator.php index 71a2db44974..687fd1d36ba 100644 --- a/src/Tools/SchemaValidator.php +++ b/src/Tools/SchemaValidator.php @@ -35,7 +35,6 @@ use function class_exists; use function class_parents; use function count; -use function get_class; use function implode; use function in_array; use function interface_exists; @@ -435,7 +434,7 @@ function (FieldMapping $fieldMapping) use ($class): string|null { */ private function findBuiltInType(Type $type): string|null { - $typeName = get_class($type); + $typeName = $type::class; return self::BUILTIN_TYPES_MAP[$typeName] ?? null; } diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 708f23ff80c..37fcf71253c 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -62,7 +62,6 @@ use function array_values; use function assert; use function current; -use function get_class; use function get_debug_type; use function implode; use function in_array; @@ -1039,7 +1038,7 @@ private function executeInserts(): void foreach ($entities as $entity) { $oid = spl_object_id($entity); - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $persister = $this->getEntityPersister($class->name); $persister->addInsert($entity); @@ -1112,7 +1111,7 @@ private function addToEntityIdentifiersAndEntityMap( private function executeUpdates(): void { foreach ($this->entityUpdates as $oid => $entity) { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $persister = $this->getEntityPersister($class->name); $preUpdateInvoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preUpdate); $postUpdateInvoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postUpdate); @@ -1145,7 +1144,7 @@ private function executeDeletions(): void foreach ($entities as $entity) { $oid = spl_object_id($entity); - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $persister = $this->getEntityPersister($class->name); $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postRemove); @@ -1194,7 +1193,7 @@ private function computeInsertExecutionOrder(): array // Now add edges foreach ($this->entityInsertions as $entity) { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); foreach ($class->associationMappings as $assoc) { // We only need to consider the owning sides of to-one associations, @@ -1257,7 +1256,7 @@ private function computeDeleteExecutionOrder(): array // we need to treat those groups like a single entity when performing delete // order topological sorting. foreach ($this->entityDeletions as $entity) { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); foreach ($class->associationMappings as $assoc) { // We only need to consider the owning sides of to-one associations, @@ -1294,7 +1293,7 @@ private function computeDeleteExecutionOrder(): array // Now do the actual topological sorting to find the delete order. foreach ($this->entityDeletions as $entity) { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); // Get the entities representing the SCC $entityComponent = $stronglyConnectedComponents->getNodeRepresentingStronglyConnectedComponent($entity); @@ -1585,7 +1584,7 @@ public function getIdHashByEntity(object $entity): string $identifier = $this->entityIdentifiers[spl_object_id($entity)]; if (empty($identifier) || in_array(null, $identifier, true)) { - $classMetadata = $this->em->getClassMetadata(get_class($entity)); + $classMetadata = $this->em->getClassMetadata($entity::class); throw ORMInvalidArgumentException::entityWithoutIdentity($classMetadata->name, $entity); } @@ -3231,7 +3230,7 @@ private function normalizeIdentifier(ClassMetadata $targetClass, array $flatIden */ final public function assignPostInsertId(object $entity, mixed $generatedId): void { - $class = $this->em->getClassMetadata(get_class($entity)); + $class = $this->em->getClassMetadata($entity::class); $idField = $class->getSingleIdentifierFieldName(); $idValue = $this->convertSingleFieldIdentifierToPHPValue($class, $generatedId); $oid = spl_object_id($entity); From f259754b7c5cc5f935cf8b2fdcaf16f39e700fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 3 Feb 2024 19:40:21 +0100 Subject: [PATCH 344/475] Update branch metadata --- .doctrine-project.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.doctrine-project.json b/.doctrine-project.json index 577fd732682..e3557713071 100644 --- a/.doctrine-project.json +++ b/.doctrine-project.json @@ -6,11 +6,23 @@ "docsSlug": "doctrine-orm", "versions": [ { - "name": "3.0", - "branchName": "3.0.x", + "name": "4.0", + "branchName": "4.0.x", "slug": "latest", "upcoming": true }, + { + "name": "3.1", + "branchName": "3.1.x", + "slug": "3.1", + "upcoming": true + }, + { + "name": "3.0", + "branchName": "3.0.x", + "slug": "3.0", + "current": true + }, { "name": "2.19", "branchName": "2.19.x", @@ -21,7 +33,7 @@ "name": "2.18", "branchName": "2.18.x", "slug": "2.18", - "current": true + "maintained": true }, { "name": "2.17", From 7527b788dec9b9003e75004ed65c0dcb3753c70e Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 3 Feb 2024 21:24:40 +0100 Subject: [PATCH 345/475] Switch back to stable dependencies (#11210) --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index c7ee4f9ec9f..6aefbec39e4 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,6 @@ "symfony/cache": "^5.4 || ^6.2 || ^7.0", "vimeo/psalm": "5.16.0" }, - "minimum-stability": "RC", "suggest": { "ext-dom": "Provides support for XSD validation for XML mapping files", "symfony/cache": "Provides cache support for Setup Tool with doctrine/cache 2.0" From f5dea25b6cda62e29c89099414e112c955853776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 3 Feb 2024 21:55:58 +0100 Subject: [PATCH 346/475] Deprecate array access We now have proper value objects with properties for everything we need. --- UPGRADE.md | 12 ++++++++ src/Mapping/ArrayAccessImplementation.php | 29 +++++++++++++++++++ .../Entity/JoinedSubclassPersister.php | 8 ++--- src/Query/ResultSetMappingBuilder.php | 2 +- src/Tools/SchemaValidator.php | 20 ++++++------- src/UnitOfWork.php | 8 ++--- .../ORM/Functional/Ticket/GH11135Test.php | 4 +-- tests/Tests/ORM/Mapping/ClassMetadataTest.php | 3 +- .../ORM/Mapping/XmlMappingDriverTest.php | 4 +-- 9 files changed, 65 insertions(+), 25 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index b99c034c8cd..339886657a9 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,15 @@ +# Upgrade to 3.1 + +## Deprecate array access + +Use array access on instances of the following classes is deprecated: + +- `Doctrine\ORM\Mapping\DiscriminatorColumnMapping` +- `Doctrine\ORM\Mapping\EmbedClassMapping` +- `Doctrine\ORM\Mapping\FieldMapping` +- `Doctrine\ORM\Mapping\JoinColumnMapping` +- `Doctrine\ORM\Mapping\JoinTableMapping` + # Upgrade to 3.0 ## BC BREAK: `Doctrine\ORM\Proxy\Autoloader` no longer extends `Doctrine\Common\Proxy\Autoloader` diff --git a/src/Mapping/ArrayAccessImplementation.php b/src/Mapping/ArrayAccessImplementation.php index e740db8409e..3fd0988cf1b 100644 --- a/src/Mapping/ArrayAccessImplementation.php +++ b/src/Mapping/ArrayAccessImplementation.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Deprecations\Deprecation; use InvalidArgumentException; use function property_exists; @@ -14,12 +15,26 @@ trait ArrayAccessImplementation /** @param string $offset */ public function offsetExists(mixed $offset): bool { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11211', + 'Using ArrayAccess on %s is deprecated and will not be possible in Doctrine ORM 4.0. Use the corresponding property instead.', + static::class, + ); + return isset($this->$offset); } /** @param string $offset */ public function offsetGet(mixed $offset): mixed { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11211', + 'Using ArrayAccess on %s is deprecated and will not be possible in Doctrine ORM 4.0. Use the corresponding property instead.', + static::class, + ); + if (! property_exists($this, $offset)) { throw new InvalidArgumentException('Undefined property: ' . $offset); } @@ -30,12 +45,26 @@ public function offsetGet(mixed $offset): mixed /** @param string $offset */ public function offsetSet(mixed $offset, mixed $value): void { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11211', + 'Using ArrayAccess on %s is deprecated and will not be possible in Doctrine ORM 4.0. Use the corresponding property instead.', + static::class, + ); + $this->$offset = $value; } /** @param string $offset */ public function offsetUnset(mixed $offset): void { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11211', + 'Using ArrayAccess on %s is deprecated and will not be possible in Doctrine ORM 4.0. Use the corresponding property instead.', + static::class, + ); + $this->$offset = null; } } diff --git a/src/Persisters/Entity/JoinedSubclassPersister.php b/src/Persisters/Entity/JoinedSubclassPersister.php index 10eb31ec50b..76719a2c275 100644 --- a/src/Persisters/Entity/JoinedSubclassPersister.php +++ b/src/Persisters/Entity/JoinedSubclassPersister.php @@ -466,7 +466,7 @@ protected function getInsertColumnList(): array || isset($this->class->associationMappings[$name]->inherited) || ($this->class->isVersioned && $this->class->versionField === $name) || isset($this->class->embeddedClasses[$name]) - || isset($this->class->fieldMappings[$name]['notInsertable']) + || isset($this->class->fieldMappings[$name]->notInsertable) ) { continue; } @@ -519,9 +519,9 @@ protected function fetchVersionAndNotUpsertableValues(ClassMetadata $versionedCl $class = null; if ($this->class->isVersioned && $key === $versionedClass->versionField) { $class = $versionedClass; - } elseif (isset($column['generated'])) { - $class = isset($column['inherited']) - ? $this->em->getClassMetadata($column['inherited']) + } elseif (isset($column->generated)) { + $class = isset($column->inherited) + ? $this->em->getClassMetadata($column->inherited) : $this->class; } else { continue; diff --git a/src/Query/ResultSetMappingBuilder.php b/src/Query/ResultSetMappingBuilder.php index 2e81db7d71b..f28f3a9c005 100644 --- a/src/Query/ResultSetMappingBuilder.php +++ b/src/Query/ResultSetMappingBuilder.php @@ -134,7 +134,7 @@ protected function addAllClassFields(string $class, string $alias, array $column $this->addFieldResult($alias, $columnAlias, $propertyName); - $enumType = $classMetadata->getFieldMapping($propertyName)['enumType'] ?? null; + $enumType = $classMetadata->getFieldMapping($propertyName)->enumType ?? null; if (! empty($enumType)) { $this->addEnumResult($columnAlias, $enumType); } diff --git a/src/Tools/SchemaValidator.php b/src/Tools/SchemaValidator.php index 687fd1d36ba..43b10ee3983 100644 --- a/src/Tools/SchemaValidator.php +++ b/src/Tools/SchemaValidator.php @@ -343,7 +343,7 @@ function (FieldMapping $fieldMapping) use ($class): string|null { return null; } - $metadataFieldType = $this->findBuiltInType(Type::getType($fieldMapping['type'])); + $metadataFieldType = $this->findBuiltInType(Type::getType($fieldMapping->type)); //If the metadata field type is not a mapped built-in type, we cannot check it if ($metadataFieldType === null) { @@ -371,7 +371,7 @@ function (FieldMapping $fieldMapping) use ($class): string|null { ); } - if (! isset($fieldMapping['enumType']) || $propertyType === $fieldMapping['enumType']) { + if (! isset($fieldMapping->enumType) || $propertyType === $fieldMapping->enumType) { return null; } @@ -380,17 +380,17 @@ function (FieldMapping $fieldMapping) use ($class): string|null { $class->name, $fieldName, $propertyType, - $fieldMapping['enumType'], + $fieldMapping->enumType, ); } if ( - isset($fieldMapping['enumType']) - && $propertyType !== $fieldMapping['enumType'] + isset($fieldMapping->enumType) + && $propertyType !== $fieldMapping->enumType && interface_exists($propertyType) - && is_a($fieldMapping['enumType'], $propertyType, true) + && is_a($fieldMapping->enumType, $propertyType, true) ) { - $backingType = (string) (new ReflectionEnum($fieldMapping['enumType']))->getBackingType(); + $backingType = (string) (new ReflectionEnum($fieldMapping->enumType))->getBackingType(); if ($metadataFieldType === $backingType) { return null; @@ -400,14 +400,14 @@ function (FieldMapping $fieldMapping) use ($class): string|null { "The field '%s#%s' has the metadata enumType '%s' with a backing type of '%s' that differs from the metadata field type '%s'.", $class->name, $fieldName, - $fieldMapping['enumType'], + $fieldMapping->enumType, $backingType, $metadataFieldType, ); } if ( - $fieldMapping['type'] === 'json' + $fieldMapping->type === 'json' && in_array($propertyType, ['string', 'int', 'float', 'bool', 'true', 'false', 'null'], true) ) { return null; @@ -419,7 +419,7 @@ function (FieldMapping $fieldMapping) use ($class): string|null { $fieldName, $propertyType, $metadataFieldType, - $fieldMapping['type'], + $fieldMapping->type, ); }, $class->fieldMappings, diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 37fcf71253c..f82a9afc055 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -997,7 +997,7 @@ public function recomputeSingleEntityChangeSet(ClassMetadata $class, object $ent foreach ($actualData as $propName => $actualValue) { $orgValue = $originalData[$propName] ?? null; - if (isset($class->fieldMappings[$propName]['enumType'])) { + if (isset($class->fieldMappings[$propName]->enumType)) { if (is_array($orgValue)) { foreach ($orgValue as $id => $val) { if ($val instanceof BackedEnum) { @@ -1267,16 +1267,16 @@ private function computeDeleteExecutionOrder(): array } $joinColumns = reset($assoc->joinColumns); - if (! isset($joinColumns['onDelete'])) { + if (! isset($joinColumns->onDelete)) { continue; } - $onDeleteOption = strtolower($joinColumns['onDelete']); + $onDeleteOption = strtolower($joinColumns->onDelete); if ($onDeleteOption !== 'cascade') { continue; } - $targetEntity = $class->getFieldValue($entity, $assoc['fieldName']); + $targetEntity = $class->getFieldValue($entity, $assoc->fieldName); // If the association does not refer to another entity or that entity // is not to be deleted, there is no ordering problem and we can diff --git a/tests/Tests/ORM/Functional/Ticket/GH11135Test.php b/tests/Tests/ORM/Functional/Ticket/GH11135Test.php index 1afc872fd2d..ae514cfaa4f 100644 --- a/tests/Tests/ORM/Functional/Ticket/GH11135Test.php +++ b/tests/Tests/ORM/Functional/Ticket/GH11135Test.php @@ -25,8 +25,8 @@ public function testOverrideInheritsDeclaringClass(): void $cm1 = $this->_em->getClassMetadata(GH11135EntityWithOverride::class); $cm2 = $this->_em->getClassMetadata(GH11135EntityWithoutOverride::class); - self::assertSame($cm1->getFieldMapping('id')['declared'], $cm2->getFieldMapping('id')['declared']); - self::assertSame($cm1->getAssociationMapping('ref')['declared'], $cm2->getAssociationMapping('ref')['declared']); + self::assertSame($cm1->getFieldMapping('id')->declared, $cm2->getFieldMapping('id')->declared); + self::assertSame($cm1->getAssociationMapping('ref')->declared, $cm2->getAssociationMapping('ref')->declared); } } diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index edd05959408..1ce384b5249 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -859,8 +859,7 @@ public function testAttributeOverrideKeepsDeclaringClass(): void $mapping = $cm->getFieldMapping('id'); - self::assertArrayHasKey('declared', $mapping); - self::assertSame(AbstractContentItem::class, $mapping['declared']); + self::assertSame(AbstractContentItem::class, $mapping->declared); } public function testAssociationOverrideKeepsDeclaringClass(): void diff --git a/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php index 86e6fde2cf5..5426da45c91 100644 --- a/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -297,8 +297,8 @@ public function testClassNameInFieldOrId(): void /** @var array{type: string} $name */ $name = $class->getFieldMapping('name'); - self::assertEquals(ProjectId::class, $id['type']); - self::assertEquals(ProjectName::class, $name['type']); + self::assertEquals(ProjectId::class, $id->type); + self::assertEquals(ProjectName::class, $name->type); } public function testDisablingXmlValidationIsPossible(): void From 6f507c322a796c8c4655ffa1e54109592650e001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 3 Feb 2024 23:01:56 +0100 Subject: [PATCH 347/475] Fix grammar issue in upgrade guide --- UPGRADE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 339886657a9..bd404450c3e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -2,7 +2,7 @@ ## Deprecate array access -Use array access on instances of the following classes is deprecated: +Using array access on instances of the following classes is deprecated: - `Doctrine\ORM\Mapping\DiscriminatorColumnMapping` - `Doctrine\ORM\Mapping\EmbedClassMapping` From a7d5adb3cea98302182bd9afdc4286786278e79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 3 Feb 2024 23:07:27 +0100 Subject: [PATCH 348/475] Migrate more occurrences of array access --- src/Persisters/Entity/BasicEntityPersister.php | 2 +- src/Query/SqlWalker.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index 5a2fc92a315..e6b09774408 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -1151,7 +1151,7 @@ final protected function getOrderBySQL(array $orderBy, string $baseTableAlias): if (isset($this->class->fieldMappings[$fieldName])) { $tableAlias = isset($this->class->fieldMappings[$fieldName]->inherited) - ? $this->getSQLTableAlias($this->class->fieldMappings[$fieldName]['inherited']) + ? $this->getSQLTableAlias($this->class->fieldMappings[$fieldName]->inherited) : $baseTableAlias; $columnName = $this->quoteStrategy->getColumnName($fieldName, $this->class, $this->platform); diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index f6f94347e36..00b180fd4c9 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -786,7 +786,7 @@ public function walkIndexBy(AST\IndexBy $indexBy): void $class = $this->getMetadataForDqlAlias($alias); if (isset($class->associationMappings[$fieldName]->inherited)) { - $class = $this->em->getClassMetadata($class->associationMappings[$fieldName]['inherited']); + $class = $this->em->getClassMetadata($class->associationMappings[$fieldName]->inherited); } $association = $class->associationMappings[$fieldName]; From a2faeb9a26cdd342c8e8d455a16c9200f7279596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 3 Feb 2024 23:56:59 +0100 Subject: [PATCH 349/475] Replace more occurrences of array access Not sure how I missed those. --- src/UnitOfWork.php | 2 +- tests/Tests/ORM/Mapping/ClassMetadataTest.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index f82a9afc055..3b020c955f2 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2713,7 +2713,7 @@ public function loadCollection(PersistentCollection $collection): void private function scheduleCollectionForBatchLoading(PersistentCollection $collection, ClassMetadata $sourceClass): void { $mapping = $collection->getMapping(); - $name = $mapping['sourceEntity'] . '#' . $mapping['fieldName']; + $name = $mapping->sourceEntity . '#' . $mapping->fieldName; if (! isset($this->eagerLoadingCollections[$name])) { $this->eagerLoadingCollections[$name] = [ diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index 1ce384b5249..be44c416aea 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -870,8 +870,7 @@ public function testAssociationOverrideKeepsDeclaringClass(): void $mapping = $cm->getAssociationMapping('parentDirectory'); - self::assertArrayHasKey('declared', $mapping); - self::assertSame(Directory::class, $mapping['declared']); + self::assertSame(Directory::class, $mapping->declared); } #[TestGroup('DDC-1955')] From 54b7ad2073fa0825c5dcdcfa1f2d8c0df3d3deb2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 4 Feb 2024 17:40:04 +0100 Subject: [PATCH 350/475] DoctrineSetup was renamed to ORMSetup (#11218) --- UPGRADE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index b99c034c8cd..09ce079e7b9 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -495,8 +495,8 @@ The methods have been replaced by PSR-6 compatible counterparts ## BC BREAK: Remove `Doctrine\ORM\Configuration::newDefaultAnnotationDriver` -This functionality has been moved to the new `DoctrineSetup` class. Call -`Doctrine\ORM\Tools\DoctrineSetup::createDefaultAnnotationDriver()` to create +This functionality has been moved to the new `ORMSetup` class. Call +`Doctrine\ORM\ORMSetup::createDefaultAnnotationDriver()` to create a new annotation driver. ## BC BREAK: Remove `Doctrine\ORM\Tools\Setup` @@ -504,7 +504,7 @@ a new annotation driver. In our effort to migrate from Doctrine Cache to PSR-6, the `Setup` class which accepted a Doctrine Cache instance in each method has been removed. -The replacement is `Doctrine\ORM\Tools\DoctrineSetup` which accepts a PSR-6 +The replacement is `Doctrine\ORM\ORMSetup` which accepts a PSR-6 cache instead. ## BC BREAK: Removed named queries From 00ed2ca991d04d45e908cecc8c967db664baa0a0 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 4 Feb 2024 17:40:24 +0100 Subject: [PATCH 351/475] Bump dependencies in the "getting started" docs page (#11219) --- docs/en/tutorials/getting-started.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index a1c9d2915ac..5e405618bf4 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -82,9 +82,9 @@ that directory with the following contents: { "require": { - "doctrine/orm": "^2.11.0", - "doctrine/dbal": "^3.2", - "symfony/cache": "^5.4" + "doctrine/orm": "^3", + "doctrine/dbal": "^4", + "symfony/cache": "^7" }, "autoload": { "psr-0": {"": "src/"} From 27c9e9cab3e081b3f1b7d2a553ca39a89f33f36d Mon Sep 17 00:00:00 2001 From: Andrey Bolonin Date: Mon, 5 Feb 2024 09:31:22 +0300 Subject: [PATCH 352/475] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a128c1f1e9c..68ea9c2d310 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [

🇺🇦 UKRAINE NEEDS YOUR HELP NOW!

](https://www.doctrine-project.org/stop-war.html) -Doctrine ORM is an object-relational mapper for PHP 7.1+ that provides transparent persistence +Doctrine ORM is an object-relational mapper for PHP 8.1+ that provides transparent persistence for PHP objects. It sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernate's HQL. This provides developers with a powerful alternative to SQL that maintains flexibility From b00f0c258ec2a8cce8715e2ca96953c1897f3cd0 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Mon, 5 Feb 2024 22:58:19 +0100 Subject: [PATCH 353/475] Clean up outdated sentence (#11224) The static create() method is gone in version 3 --- src/EntityManager.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/EntityManager.php b/src/EntityManager.php index 4904f458922..bb9e2ad2ced 100644 --- a/src/EntityManager.php +++ b/src/EntityManager.php @@ -36,8 +36,7 @@ * The EntityManager is the central access point to ORM functionality. * * It is a facade to all different ORM subsystems such as UnitOfWork, - * Query Language and Repository API. Instantiation is done through - * the static create() method. The quickest way to obtain a fully + * Query Language and Repository API. The quickest way to obtain a fully * configured EntityManager is: * * use Doctrine\ORM\Tools\ORMSetup; From 1854ce2d32ff577c0fadf76d9e12c6b6346a2dc0 Mon Sep 17 00:00:00 2001 From: Andrey Bolonin Date: Tue, 6 Feb 2024 09:09:30 +0300 Subject: [PATCH 354/475] Update version ORM from 2 to 3 in docs (#11221) --- docs/en/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/index.rst b/docs/en/index.rst index 91d2df8ca89..641709b5dec 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -1,4 +1,4 @@ -Welcome to Doctrine 2 ORM's documentation! +Welcome to Doctrine ORM's documentation! ========================================== The Doctrine documentation is comprised of tutorials, a reference section and From aff543a4ffb538026748a64ca014ebe24f787730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 6 Feb 2024 23:12:13 +0100 Subject: [PATCH 355/475] Add columns for 3.1.x and 4.0x --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 68ea9c2d310..f44f4d47085 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -| [3.0.x][3.0] | [2.19.x][2.19] | [2.18.x][2.18] | -|:----------------:|:----------------:|:----------:| -| [![Build status][3.0 image]][3.0] | [![Build status][2.19 image]][2.19] | [![Build status][2.18 image]][2.18] | -| [![Coverage Status][3.0 coverage image]][3.0 coverage]| [![Coverage Status][2.19 coverage image]][2.19 coverage] | [![Coverage Status][2.18 coverage image]][2.18 coverage] | +| [4.0.x][4.0] | [3.1.x][3.1] | [3.0.x][3.0] | [2.19.x][2.19] | [2.18.x][2.18] | +|:------------------------------------------------------:|:------------------------------------------------------:|:------------------------------------------------------:|:--------------------------------------------------------:|:--------------------------------------------------------:| +| [![Build status][4.0 image]][4.0] | [![Build status][3.1 image]][3.1] | [![Build status][3.0 image]][3.0] | [![Build status][2.19 image]][2.19] | [![Build status][2.18 image]][2.18] | +| [![Coverage Status][4.0 coverage image]][4.0 coverage] | [![Coverage Status][3.1 coverage image]][3.1 coverage] | [![Coverage Status][3.0 coverage image]][3.0 coverage] | [![Coverage Status][2.19 coverage image]][2.19 coverage] | [![Coverage Status][2.18 coverage image]][2.18 coverage] | [

🇺🇦 UKRAINE NEEDS YOUR HELP NOW!

](https://www.doctrine-project.org/stop-war.html) @@ -17,15 +17,26 @@ without requiring unnecessary code duplication. * [Website](http://www.doctrine-project.org) * [Documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/stable/index.html) + [4.0 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0.x + [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.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.0 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0.x [3.0]: https://github.com/doctrine/orm/tree/3.0.x [3.0 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.0.x/graph/badge.svg [3.0 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.0.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 + [2.18 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.18.x [2.18]: https://github.com/doctrine/orm/tree/2.18.x [2.18 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.18.x/graph/badge.svg From 94144e122779098c156098fc9bb6791e53192086 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 7 Feb 2024 09:36:32 +0100 Subject: [PATCH 356/475] Revert "Merge pull request #11229 from greg0ire/add-columns" This reverts commit 599dd58fe102b664e538acdc73ea059576a1dde0, reversing changes made to 1854ce2d32ff577c0fadf76d9e12c6b6346a2dc0. --- README.md | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f44f4d47085..68ea9c2d310 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -| [4.0.x][4.0] | [3.1.x][3.1] | [3.0.x][3.0] | [2.19.x][2.19] | [2.18.x][2.18] | -|:------------------------------------------------------:|:------------------------------------------------------:|:------------------------------------------------------:|:--------------------------------------------------------:|:--------------------------------------------------------:| -| [![Build status][4.0 image]][4.0] | [![Build status][3.1 image]][3.1] | [![Build status][3.0 image]][3.0] | [![Build status][2.19 image]][2.19] | [![Build status][2.18 image]][2.18] | -| [![Coverage Status][4.0 coverage image]][4.0 coverage] | [![Coverage Status][3.1 coverage image]][3.1 coverage] | [![Coverage Status][3.0 coverage image]][3.0 coverage] | [![Coverage Status][2.19 coverage image]][2.19 coverage] | [![Coverage Status][2.18 coverage image]][2.18 coverage] | +| [3.0.x][3.0] | [2.19.x][2.19] | [2.18.x][2.18] | +|:----------------:|:----------------:|:----------:| +| [![Build status][3.0 image]][3.0] | [![Build status][2.19 image]][2.19] | [![Build status][2.18 image]][2.18] | +| [![Coverage Status][3.0 coverage image]][3.0 coverage]| [![Coverage Status][2.19 coverage image]][2.19 coverage] | [![Coverage Status][2.18 coverage image]][2.18 coverage] | [

🇺🇦 UKRAINE NEEDS YOUR HELP NOW!

](https://www.doctrine-project.org/stop-war.html) @@ -17,26 +17,15 @@ without requiring unnecessary code duplication. * [Website](http://www.doctrine-project.org) * [Documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/stable/index.html) - [4.0 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0.x - [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.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.0 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0.x [3.0]: https://github.com/doctrine/orm/tree/3.0.x [3.0 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.0.x/graph/badge.svg [3.0 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.0.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 - [2.18 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.18.x [2.18]: https://github.com/doctrine/orm/tree/2.18.x [2.18 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.18.x/graph/badge.svg From 9acc70d5b8be55a6ac33e5c7313a124fa90dbe21 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Fri, 9 Feb 2024 15:23:22 +0100 Subject: [PATCH 357/475] fix: support array-type arg in QB variadic calls (#11242) --- src/Query/Expr/Base.php | 6 ++++++ tests/Tests/ORM/QueryBuilderTest.php | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Query/Expr/Base.php b/src/Query/Expr/Base.php index a98ea3b8cb3..e0f257277df 100644 --- a/src/Query/Expr/Base.php +++ b/src/Query/Expr/Base.php @@ -7,10 +7,12 @@ use InvalidArgumentException; use Stringable; +use function array_key_exists; use function count; use function get_debug_type; use function implode; use function in_array; +use function is_array; use function is_string; use function sprintf; @@ -33,6 +35,10 @@ abstract class Base implements Stringable public function __construct(mixed $args = []) { + if (is_array($args) && array_key_exists(0, $args) && is_array($args[0])) { + $args = $args[0]; + } + $this->addMultiple($args); } diff --git a/tests/Tests/ORM/QueryBuilderTest.php b/tests/Tests/ORM/QueryBuilderTest.php index 3c3f05ba4db..e7025395bbc 100644 --- a/tests/Tests/ORM/QueryBuilderTest.php +++ b/tests/Tests/ORM/QueryBuilderTest.php @@ -80,6 +80,15 @@ public function testSimpleSelect(): void $this->assertValidQueryBuilder($qb, 'SELECT u.id, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u'); } + public function testSimpleSelectArray(): void + { + $qb = $this->entityManager->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select(['u.id', 'u.username']); + + $this->assertValidQueryBuilder($qb, 'SELECT u.id, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + public function testSimpleDelete(): void { $qb = $this->entityManager->createQueryBuilder() From b6f4220493579b88cafdf2331423ccbffa54effe Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 13 Feb 2024 18:28:17 +0100 Subject: [PATCH 358/475] Throw if a variadic parameter contains unexpected named arguments (#11260) --- psalm-baseline.xml | 4 -- src/Internal/NoUnknownNamedArguments.php | 55 ++++++++++++++++++++++++ src/QueryBuilder.php | 23 ++++++++++ tests/Tests/ORM/QueryBuilderTest.php | 13 ++++++ 4 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 src/Internal/NoUnknownNamedArguments.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 17a090f3a2c..688463b1bb2 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1042,10 +1042,6 @@
- $having - $having - $where - $where $join]]]> $join]]]> diff --git a/src/Internal/NoUnknownNamedArguments.php b/src/Internal/NoUnknownNamedArguments.php new file mode 100644 index 00000000000..7584744c162 --- /dev/null +++ b/src/Internal/NoUnknownNamedArguments.php @@ -0,0 +1,55 @@ + $parameter + */ + private static function validateVariadicParameter(array $parameter): void + { + if (array_is_list($parameter)) { + return; + } + + [, $trace] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + assert(isset($trace['class'])); + + $additionalArguments = array_values(array_filter( + array_keys($parameter), + is_string(...), + )); + + throw new BadMethodCallException(sprintf( + 'Invalid call to %s::%s(), unknown named arguments: %s', + $trace['class'], + $trace['function'], + implode(', ', $additionalArguments), + )); + } +} diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 115dea0187d..f79e2fe83f0 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; +use Doctrine\ORM\Internal\NoUnknownNamedArguments; use Doctrine\ORM\Internal\QueryType; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Parameter; @@ -38,6 +39,8 @@ */ class QueryBuilder implements Stringable { + use NoUnknownNamedArguments; + /** * The array of DQL parts collected. * @@ -611,6 +614,8 @@ public function add(string $dqlPartName, string|object|array $dqlPart, bool $app */ public function select(mixed ...$select): static { + self::validateVariadicParameter($select); + $this->type = QueryType::Select; if ($select === []) { @@ -657,6 +662,8 @@ public function distinct(bool $flag = true): static */ public function addSelect(mixed ...$select): static { + self::validateVariadicParameter($select); + $this->type = QueryType::Select; if ($select === []) { @@ -951,6 +958,8 @@ public function set(string $key, mixed $value): static */ public function where(mixed ...$predicates): static { + self::validateVariadicParameter($predicates); + if (! (count($predicates) === 1 && $predicates[0] instanceof Expr\Composite)) { $predicates = new Expr\Andx($predicates); } @@ -976,6 +985,8 @@ public function where(mixed ...$predicates): static */ public function andWhere(mixed ...$where): static { + self::validateVariadicParameter($where); + $dql = $this->getDQLPart('where'); if ($dql instanceof Expr\Andx) { @@ -1006,6 +1017,8 @@ public function andWhere(mixed ...$where): static */ public function orWhere(mixed ...$where): static { + self::validateVariadicParameter($where); + $dql = $this->getDQLPart('where'); if ($dql instanceof Expr\Orx) { @@ -1033,6 +1046,8 @@ public function orWhere(mixed ...$where): static */ public function groupBy(string ...$groupBy): static { + self::validateVariadicParameter($groupBy); + return $this->add('groupBy', new Expr\GroupBy($groupBy)); } @@ -1051,6 +1066,8 @@ public function groupBy(string ...$groupBy): static */ public function addGroupBy(string ...$groupBy): static { + self::validateVariadicParameter($groupBy); + return $this->add('groupBy', new Expr\GroupBy($groupBy), true); } @@ -1062,6 +1079,8 @@ public function addGroupBy(string ...$groupBy): static */ public function having(mixed ...$having): static { + self::validateVariadicParameter($having); + if (! (count($having) === 1 && ($having[0] instanceof Expr\Andx || $having[0] instanceof Expr\Orx))) { $having = new Expr\Andx($having); } @@ -1077,6 +1096,8 @@ public function having(mixed ...$having): static */ public function andHaving(mixed ...$having): static { + self::validateVariadicParameter($having); + $dql = $this->getDQLPart('having'); if ($dql instanceof Expr\Andx) { @@ -1097,6 +1118,8 @@ public function andHaving(mixed ...$having): static */ public function orHaving(mixed ...$having): static { + self::validateVariadicParameter($having); + $dql = $this->getDQLPart('having'); if ($dql instanceof Expr\Orx) { diff --git a/tests/Tests/ORM/QueryBuilderTest.php b/tests/Tests/ORM/QueryBuilderTest.php index 3c3f05ba4db..96927bbbf92 100644 --- a/tests/Tests/ORM/QueryBuilderTest.php +++ b/tests/Tests/ORM/QueryBuilderTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM; +use BadMethodCallException; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Cache; @@ -275,6 +276,18 @@ public function testWhere(): void $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid'); } + public function testWhereWithUnexpectedNamedArguments(): void + { + $qb = $this->entityManager->createQueryBuilder() + ->select('u') + ->from(CmsUser::class, 'u'); + + $this->expectException(BadMethodCallException::class); + $this->expectExceptionMessage('Invalid call to Doctrine\ORM\QueryBuilder::where(), unknown named arguments: foo, bar'); + + $qb->where(foo: 'u.id = :uid', bar: 'u.name = :name'); + } + public function testComplexAndWhere(): void { $qb = $this->entityManager->createQueryBuilder() From 6290747bf9a2538316b88bc12478fd078557e5ec Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 14 Feb 2024 00:33:12 +0100 Subject: [PATCH 359/475] Validate more variadic parameters (#11261) --- src/Mapping/ChainTypedFieldMapper.php | 10 ++++++---- src/Query/Expr.php | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Mapping/ChainTypedFieldMapper.php b/src/Mapping/ChainTypedFieldMapper.php index 85e7faa6e4c..ed1ba93706c 100644 --- a/src/Mapping/ChainTypedFieldMapper.php +++ b/src/Mapping/ChainTypedFieldMapper.php @@ -4,18 +4,20 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\ORM\Internal\NoUnknownNamedArguments; use ReflectionProperty; final class ChainTypedFieldMapper implements TypedFieldMapper { - /** - * @readonly - * @var TypedFieldMapper[] $typedFieldMappers - */ + use NoUnknownNamedArguments; + + /** @var list $typedFieldMappers */ private readonly array $typedFieldMappers; public function __construct(TypedFieldMapper ...$typedFieldMappers) { + self::validateVariadicParameter($typedFieldMappers); + $this->typedFieldMappers = $typedFieldMappers; } diff --git a/src/Query/Expr.php b/src/Query/Expr.php index 0629156d837..65f30827f24 100644 --- a/src/Query/Expr.php +++ b/src/Query/Expr.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Query; +use Doctrine\ORM\Internal\NoUnknownNamedArguments; use Traversable; use function implode; @@ -23,6 +24,8 @@ */ class Expr { + use NoUnknownNamedArguments; + /** * Creates a conjunction of the given boolean expressions. * @@ -38,6 +41,8 @@ class Expr */ public function andX(Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x): Expr\Andx { + self::validateVariadicParameter($x); + return new Expr\Andx($x); } @@ -56,6 +61,8 @@ public function andX(Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x): */ public function orX(Expr\Comparison|Expr\Func|Expr\Andx|Expr\Orx|string ...$x): Expr\Orx { + self::validateVariadicParameter($x); + return new Expr\Orx($x); } @@ -225,6 +232,8 @@ public function count(mixed $x): Expr\Func */ public function countDistinct(mixed ...$x): string { + self::validateVariadicParameter($x); + return 'COUNT(DISTINCT ' . implode(', ', $x) . ')'; } @@ -470,6 +479,8 @@ public function notLike(string $x, mixed $y): Expr\Comparison */ public function concat(mixed ...$x): Expr\Func { + self::validateVariadicParameter($x); + return new Expr\Func('CONCAT', $x); } From 3918dcfb42912492a06d753e2ebc77b65a93f278 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 15 Feb 2024 22:12:57 +0100 Subject: [PATCH 360/475] [Documentation] Adding link to Postgres upgrade article (#11257) * [Documentation] Adding link to Postgres upgrade article * Update UPGRADE.md * Update UPGRADE.md --- UPGRADE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 09ce079e7b9..e6a61238a89 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -13,9 +13,9 @@ so `$targetEntity` is a first argument now. This change affects only non-named a When using the `AUTO` strategy to let Doctrine determine the identity generation mechanism for an entity, and when using `doctrine/dbal` 4, PostgreSQL now uses `IDENTITY` -instead of `SEQUENCE`. When upgrading from ORM 2.x and preference is on keeping -the `SEQUENCE` based identity generation, then configure the ORM this way: - +instead of `SEQUENCE` or `SERIAL`. +* If you want to upgrade your existing tables to identity columns, you will need to follow [migration to identity columns on PostgreSQL](https://www.doctrine-project.org/projects/doctrine-dbal/en/4.0/how-to/postgresql-identity-migration.html) +* If you want to keep using SQL sequences, you need to configure the ORM this way: ```php use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\Configuration; From aa3b331cae5e9881ca690fc345b3f1411eaf8bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 17 Feb 2024 11:14:47 +0100 Subject: [PATCH 361/475] Remove unused trait --- tests/Tests/ORM/ConfigurationTest.php | 3 --- tests/Tests/ORM/EntityManagerTest.php | 3 --- tests/Tests/ORM/Functional/NativeQueryTest.php | 2 -- tests/Tests/ORM/Functional/Ticket/DDC117Test.php | 3 --- tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php | 3 --- tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php | 3 --- tests/Tests/ORM/Query/QueryTest.php | 3 --- tests/Tests/ORM/UnitOfWorkTest.php | 3 --- 8 files changed, 23 deletions(-) diff --git a/tests/Tests/ORM/ConfigurationTest.php b/tests/Tests/ORM/ConfigurationTest.php index 3e61fa89add..269228e72ea 100644 --- a/tests/Tests/ORM/ConfigurationTest.php +++ b/tests/Tests/ORM/ConfigurationTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityRepository; @@ -26,8 +25,6 @@ */ class ConfigurationTest extends TestCase { - use VerifyDeprecations; - private Configuration $configuration; protected function setUp(): void diff --git a/tests/Tests/ORM/EntityManagerTest.php b/tests/Tests/ORM/EntityManagerTest.php index 5abcffc67d6..067b1c6874b 100644 --- a/tests/Tests/ORM/EntityManagerTest.php +++ b/tests/Tests/ORM/EntityManagerTest.php @@ -6,7 +6,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\EntityManagerClosed; @@ -27,8 +26,6 @@ class EntityManagerTest extends OrmTestCase { - use VerifyDeprecations; - private EntityManagerMock $entityManager; protected function setUp(): void diff --git a/tests/Tests/ORM/Functional/NativeQueryTest.php b/tests/Tests/ORM/Functional/NativeQueryTest.php index 6b8f883f418..c9f665387b7 100644 --- a/tests/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Tests/ORM/Functional/NativeQueryTest.php @@ -8,7 +8,6 @@ use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type as DBALType; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Internal\SQLResultCasing; use Doctrine\ORM\PersistentCollection; @@ -33,7 +32,6 @@ class NativeQueryTest extends OrmFunctionalTestCase { use SQLResultCasing; - use VerifyDeprecations; private AbstractPlatform|null $platform = null; diff --git a/tests/Tests/ORM/Functional/Ticket/DDC117Test.php b/tests/Tests/ORM/Functional/Ticket/DDC117Test.php index 138d167d366..dba78b9afd7 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC117Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Models\DDC117\DDC117ApproveChanges; use Doctrine\Tests\Models\DDC117\DDC117Article; @@ -23,8 +22,6 @@ #[Group('DDC-117')] class DDC117Test extends OrmFunctionalTestCase { - use VerifyDeprecations; - private DDC117Article|null $article1; private DDC117Article|null $article2; diff --git a/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index cade45f5a91..28642118e01 100644 --- a/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Mapping; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Id\SequenceGenerator as IdSequenceGenerator; use Doctrine\ORM\Mapping\ClassMetadata; @@ -42,8 +41,6 @@ class BasicInheritanceMappingTest extends OrmTestCase { - use VerifyDeprecations; - private ClassMetadataFactory $cmf; protected function setUp(): void diff --git a/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 315dd203600..23054d4899e 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -9,7 +9,6 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; @@ -55,8 +54,6 @@ class ClassMetadataFactoryTest extends OrmTestCase { - use VerifyDeprecations; - public function testGetMetadataForSingleClass(): void { $platform = $this->createMock(AbstractPlatform::class); diff --git a/tests/Tests/ORM/Query/QueryTest.php b/tests/Tests/ORM/Query/QueryTest.php index d24d9292ca9..0336c3da6c8 100644 --- a/tests/Tests/ORM/Query/QueryTest.php +++ b/tests/Tests/ORM/Query/QueryTest.php @@ -15,7 +15,6 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Types; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\UnitOfWork; @@ -40,8 +39,6 @@ class QueryTest extends OrmTestCase { - use VerifyDeprecations; - /** @var EntityManagerMock */ protected $entityManager; diff --git a/tests/Tests/ORM/UnitOfWorkTest.php b/tests/Tests/ORM/UnitOfWorkTest.php index 63e13c319b1..550b1cfe1c8 100644 --- a/tests/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Tests/ORM/UnitOfWorkTest.php @@ -11,7 +11,6 @@ use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Exception\EntityIdentityCollisionException; use Doctrine\ORM\Mapping\ClassMetadata; @@ -46,8 +45,6 @@ */ class UnitOfWorkTest extends OrmTestCase { - use VerifyDeprecations; - /** * SUT */ From 4bd574daee7d617a4394eaffd37c284a4925284b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 19 Feb 2024 09:26:32 +0100 Subject: [PATCH 362/475] Improve static analysis on AttachEntityListenersListener $listenerCallback is supposed to be a method name, so it is safe to require it is not a falsy string. --- src/Tools/AttachEntityListenersListener.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Tools/AttachEntityListenersListener.php b/src/Tools/AttachEntityListenersListener.php index 63e8f7b5a13..9203cfe782c 100644 --- a/src/Tools/AttachEntityListenersListener.php +++ b/src/Tools/AttachEntityListenersListener.php @@ -5,8 +5,10 @@ namespace Doctrine\ORM\Tools; use Doctrine\ORM\Event\LoadClassMetadataEventArgs; +use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; +use function assert; use function ltrim; /** @@ -14,16 +16,22 @@ */ class AttachEntityListenersListener { - /** @var mixed[][] */ + /** + * @var array> + */ private array $entityListeners = []; /** * Adds an entity listener for a specific entity. * - * @param string $entityClass The entity to attach the listener. - * @param string $listenerClass The listener class. - * @param string|null $eventName The entity lifecycle event. - * @param string|null $listenerCallback The listener callback method or NULL to use $eventName. + * @param class-string $entityClass The entity to attach the listener. + * @param class-string $listenerClass The listener class. + * @param Events::*|null $eventName The entity lifecycle event. + * @param non-falsy-string|null $listenerCallback The listener callback method or NULL to use $eventName. */ public function addEntityListener( string $entityClass, @@ -34,7 +42,7 @@ public function addEntityListener( $this->entityListeners[ltrim($entityClass, '\\')][] = [ 'event' => $eventName, 'class' => $listenerClass, - 'method' => $listenerCallback ?: $eventName, + 'method' => $listenerCallback ?? $eventName, ]; } @@ -53,6 +61,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void if ($listener['event'] === null) { EntityListenerBuilder::bindEntityListener($metadata, $listener['class']); } else { + assert($listener['method'] !== null); $metadata->addEntityListener($listener['event'], $listener['class'], $listener['method']); } } From e0081b59beb7e82e6c918694ecbbaca38e090026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 19 Feb 2024 22:17:51 +0100 Subject: [PATCH 363/475] Account for inversedBy being a non-falsy-string or null It is supposed to hold the name of a PHP property, and those cannot be falsy strings. --- src/Internal/Hydration/ObjectHydrator.php | 4 ++-- src/Mapping/Builder/ClassMetadataBuilder.php | 6 +++--- src/Persisters/Entity/BasicEntityPersister.php | 2 +- src/Tools/SchemaValidator.php | 2 +- src/UnitOfWork.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Internal/Hydration/ObjectHydrator.php b/src/Internal/Hydration/ObjectHydrator.php index c83c1e4701e..d24323d8689 100644 --- a/src/Internal/Hydration/ObjectHydrator.php +++ b/src/Internal/Hydration/ObjectHydrator.php @@ -91,7 +91,7 @@ protected function prepare(): void } // handle fetch-joined owning side bi-directional one-to-one associations - if ($assoc->inversedBy) { + if ($assoc->inversedBy !== null) { $class = $this->getClassMetadata($className); $inverseAssoc = $class->associationMappings[$assoc->inversedBy]; @@ -439,7 +439,7 @@ protected function hydrateRowData(array $row, array &$result): void if ($relation->isOwningSide()) { // TODO: Just check hints['fetched'] here? // If there is an inverse mapping on the target class its bidirectional - if ($relation->inversedBy) { + if ($relation->inversedBy !== null) { $inverseAssoc = $targetClass->associationMappings[$relation->inversedBy]; if ($inverseAssoc->isToOne()) { $targetClass->reflFields[$inverseAssoc->fieldName]->setValue($element, $parentObject); diff --git a/src/Mapping/Builder/ClassMetadataBuilder.php b/src/Mapping/Builder/ClassMetadataBuilder.php index 0f208f29139..b9d3cc81f5e 100644 --- a/src/Mapping/Builder/ClassMetadataBuilder.php +++ b/src/Mapping/Builder/ClassMetadataBuilder.php @@ -288,7 +288,7 @@ public function addManyToOne( ): ClassMetadataBuilder { $builder = $this->createManyToOne($name, $targetEntity); - if ($inversedBy) { + if ($inversedBy !== null) { $builder->inversedBy($inversedBy); } @@ -348,7 +348,7 @@ public function addOwningOneToOne( ): ClassMetadataBuilder { $builder = $this->createOneToOne($name, $targetEntity); - if ($inversedBy) { + if ($inversedBy !== null) { $builder->inversedBy($inversedBy); } @@ -380,7 +380,7 @@ public function addOwningManyToMany( ): ClassMetadataBuilder { $builder = $this->createManyToMany($name, $targetEntity); - if ($inversedBy) { + if ($inversedBy !== null) { $builder->inversedBy($inversedBy); } diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index e6b09774408..679e8a17069 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -764,7 +764,7 @@ public function loadOneToOneEntity(AssociationMapping $assoc, object $sourceEnti $targetClass = $this->em->getClassMetadata($assoc->targetEntity); if ($assoc->isOwningSide()) { - $isInverseSingleValued = $assoc->inversedBy && ! $targetClass->isCollectionValuedAssociation($assoc->inversedBy); + $isInverseSingleValued = $assoc->inversedBy !== null && ! $targetClass->isCollectionValuedAssociation($assoc->inversedBy); // Mark inverse side as fetched in the hints, otherwise the UoW would // try to load it in a separate query (remember: to-one inverse sides can not be lazy). diff --git a/src/Tools/SchemaValidator.php b/src/Tools/SchemaValidator.php index 43b10ee3983..6ebe991876c 100644 --- a/src/Tools/SchemaValidator.php +++ b/src/Tools/SchemaValidator.php @@ -162,7 +162,7 @@ public function validateClass(ClassMetadata $class): array } } - if ($assoc->isOwningSide() && $assoc->inversedBy) { + if ($assoc->isOwningSide() && $assoc->inversedBy !== null) { if ($targetMetadata->hasField($assoc->inversedBy)) { $ce[] = 'The association ' . $class->name . '#' . $fieldName . ' refers to the inverse side ' . 'field ' . $assoc->targetEntity . '#' . $assoc->inversedBy . ' which is not defined as association.'; diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 3b020c955f2..5c16c511ce1 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2550,7 +2550,7 @@ public function createEntity(string $className, array $data, array &$hints = []) $this->originalEntityData[$oid][$field] = $newValue; $class->reflFields[$field]->setValue($entity, $newValue); - if ($assoc->inversedBy && $assoc->isOneToOne() && $newValue !== null) { + if ($assoc->inversedBy !== null && $assoc->isOneToOne() && $newValue !== null) { $inverseAssoc = $targetClass->associationMappings[$assoc->inversedBy]; $targetClass->reflFields[$inverseAssoc->fieldName]->setValue($newValue, $entity); } From b6b4cbcb939d5ccff7c244604939d97b8d49438b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Mirtes?= Date: Tue, 20 Feb 2024 20:29:56 +0100 Subject: [PATCH 364/475] Remove broken assertion from DateAddFunction and DateSubFunction (#11243) * Remove wrong asserts in DATE_ADD and DATE_SUB query AST function handlers * Require DBAL 3.8.2 --- .github/workflows/static-analysis.yml | 4 +-- composer.json | 2 +- src/Query/AST/Functions/DateAddFunction.php | 13 ++------ src/Query/AST/Functions/DateSubFunction.php | 13 ++------ .../ORM/Functional/QueryDqlFunctionTest.php | 31 +++++++++++++++++++ 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 025f29ea02d..75f46a70e60 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -32,7 +32,7 @@ jobs: include: - dbal-version: default config: phpstan.neon - - dbal-version: 3.7 + - dbal-version: 3.8.2 config: phpstan-dbal3.neon steps: @@ -65,7 +65,7 @@ jobs: matrix: dbal-version: - default - - 3.7 + - 3.8.2 steps: - name: "Checkout code" diff --git a/composer.json b/composer.json index 6aefbec39e4..2a002989c21 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "composer-runtime-api": "^2", "ext-ctype": "*", "doctrine/collections": "^2.1", - "doctrine/dbal": "^3.6 || ^4", + "doctrine/dbal": "^3.8.2 || ^4", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.2 || ^2", "doctrine/inflector": "^1.4 || ^2.0", diff --git a/src/Query/AST/Functions/DateAddFunction.php b/src/Query/AST/Functions/DateAddFunction.php index 385ebac99c9..12920dcbd0f 100644 --- a/src/Query/AST/Functions/DateAddFunction.php +++ b/src/Query/AST/Functions/DateAddFunction.php @@ -11,8 +11,6 @@ use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TokenType; -use function assert; -use function is_numeric; use function strtolower; /** @@ -63,17 +61,10 @@ public function getSql(SqlWalker $sqlWalker): string }; } - /** - * @return numeric-string - * - * @throws ASTException - */ + /** @throws ASTException */ private function dispatchIntervalExpression(SqlWalker $sqlWalker): string { - $sql = $this->intervalExpression->dispatch($sqlWalker); - assert(is_numeric($sql)); - - return $sql; + return $this->intervalExpression->dispatch($sqlWalker); } public function parse(Parser $parser): void diff --git a/src/Query/AST/Functions/DateSubFunction.php b/src/Query/AST/Functions/DateSubFunction.php index 254f1219277..5363680e2a4 100644 --- a/src/Query/AST/Functions/DateSubFunction.php +++ b/src/Query/AST/Functions/DateSubFunction.php @@ -8,8 +8,6 @@ use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; -use function assert; -use function is_numeric; use function strtolower; /** @@ -56,16 +54,9 @@ public function getSql(SqlWalker $sqlWalker): string }; } - /** - * @return numeric-string - * - * @throws ASTException - */ + /** @throws ASTException */ private function dispatchIntervalExpression(SqlWalker $sqlWalker): string { - $sql = $this->intervalExpression->dispatch($sqlWalker); - assert(is_numeric($sql)); - - return $sql; + return $this->intervalExpression->dispatch($sqlWalker); } } diff --git a/tests/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Tests/ORM/Functional/QueryDqlFunctionTest.php index 9fdc7d64516..5a6aa5da3ab 100644 --- a/tests/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -7,6 +7,7 @@ use DateTimeImmutable; use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\ORM\AbstractQuery; +use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\DataProvider; @@ -487,4 +488,34 @@ protected function generateFixture(): void $this->_em->flush(); $this->_em->clear(); } + + #[Group('GH-11240')] + public function testDateAddWithColumnInterval(): void + { + $query = sprintf( + 'SELECT DATE_ADD(CURRENT_TIMESTAMP(), m.salary, \'day\') AS add FROM %s m', + CompanyEmployee::class, + ); + + $result = $this->_em->createQuery($query) + ->setMaxResults(1) + ->getSingleResult(AbstractQuery::HYDRATE_ARRAY); + + self::assertArrayHasKey('add', $result); + } + + #[Group('GH-11240')] + public function testDateSubWithColumnInterval(): void + { + $query = sprintf( + 'SELECT DATE_SUB(CURRENT_TIMESTAMP(), m.salary, \'day\') AS add FROM %s m', + CompanyEmployee::class, + ); + + $result = $this->_em->createQuery($query) + ->setMaxResults(1) + ->getSingleResult(AbstractQuery::HYDRATE_ARRAY); + + self::assertArrayHasKey('add', $result); + } } From fb6c0c1d8b1bb45913ea39bef757613673eb560f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 20 Feb 2024 08:35:33 +0100 Subject: [PATCH 365/475] Do not implicitly cast getLockContent()'s return value Lock files are supposed to contain uniqid()-generated values, so they cannot be falsy strings, but if they did, this would fix a bug. --- src/Cache/Region/FileLockRegion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cache/Region/FileLockRegion.php b/src/Cache/Region/FileLockRegion.php index dfc2535c32b..8b07f9b60a7 100644 --- a/src/Cache/Region/FileLockRegion.php +++ b/src/Cache/Region/FileLockRegion.php @@ -67,7 +67,7 @@ private function isLocked(CacheKey $key, Lock|null $lock = null): bool $time = $this->getLockTime($filename); $content = $this->getLockContent($filename); - if (! $content || ! $time) { + if ($content === false || $time) { @unlink($filename); return false; From a0e7a59572e2ea02ba5689d7c6f1ef1e4c0995b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 20 Feb 2024 08:36:33 +0100 Subject: [PATCH 366/475] Do not implicitly cast getLockTime()'s return type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a bug for files last modified on 1970-01-01 00:00:00, so… not worth backporting IMO. --- src/Cache/Region/FileLockRegion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cache/Region/FileLockRegion.php b/src/Cache/Region/FileLockRegion.php index 8b07f9b60a7..1efd0d75405 100644 --- a/src/Cache/Region/FileLockRegion.php +++ b/src/Cache/Region/FileLockRegion.php @@ -67,7 +67,7 @@ private function isLocked(CacheKey $key, Lock|null $lock = null): bool $time = $this->getLockTime($filename); $content = $this->getLockContent($filename); - if ($content === false || $time) { + if ($content === false || $time === false) { @unlink($filename); return false; From 380b5b62efa742578f0dcd9f39347c156a4254e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 20 Feb 2024 08:39:31 +0100 Subject: [PATCH 367/475] Do not cast file_put_contents's return type If $lock->value was an empty string, this would fix a bug, but it never is, it is a uniqid-generated string. --- src/Cache/Region/FileLockRegion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cache/Region/FileLockRegion.php b/src/Cache/Region/FileLockRegion.php index 1efd0d75405..85184a0c7ce 100644 --- a/src/Cache/Region/FileLockRegion.php +++ b/src/Cache/Region/FileLockRegion.php @@ -176,7 +176,7 @@ public function lock(CacheKey $key): Lock|null $lock = Lock::createLockRead(); $filename = $this->getLockFileName($key); - if (! @file_put_contents($filename, $lock->value, LOCK_EX)) { + if (@file_put_contents($filename, $lock->value, LOCK_EX) === false) { return null; } From adadf1fb90b3ccc194ae3963cc8e19dbc1f5b8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 20 Feb 2024 08:37:48 +0100 Subject: [PATCH 368/475] Do not implicitly cast glob's return type The comment above mentions that on some platforms, it might return false, and this is why there is a check in the first place. Let us do exactly what is mentioned in the comment. --- src/Cache/Region/FileLockRegion.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Cache/Region/FileLockRegion.php b/src/Cache/Region/FileLockRegion.php index 85184a0c7ce..bedd6a68e1a 100644 --- a/src/Cache/Region/FileLockRegion.php +++ b/src/Cache/Region/FileLockRegion.php @@ -156,12 +156,10 @@ public function evictAll(): bool { // The check below is necessary because on some platforms glob returns false // when nothing matched (even though no errors occurred) - $filenames = glob(sprintf('%s/*.%s', $this->directory, self::LOCK_EXTENSION)); + $filenames = glob(sprintf('%s/*.%s', $this->directory, self::LOCK_EXTENSION)) ?: []; - if ($filenames) { - foreach ($filenames as $filename) { - @unlink($filename); - } + foreach ($filenames as $filename) { + @unlink($filename); } return $this->region->evictAll(); From 3eace16e8533e3846d9c7dbc7809fc8c487600f7 Mon Sep 17 00:00:00 2001 From: Hanish Singla Date: Tue, 20 Feb 2024 13:36:20 +0530 Subject: [PATCH 369/475] Allow (Array)ParameterType in QueryBuilder --- src/QueryBuilder.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 115dea0187d..f03951d2092 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -6,6 +6,8 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; +use Doctrine\DBAL\ArrayParameterType; +use Doctrine\DBAL\ParameterType; use Doctrine\ORM\Internal\QueryType; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Parameter; @@ -428,12 +430,12 @@ public function getRootEntities(): array * ->setParameter('user_id', 1); * * - * @param string|int $key The parameter position or name. - * @param string|int|null $type ParameterType::* or \Doctrine\DBAL\Types\Type::* constant + * @param string|int $key The parameter position or name. + * @param ParameterType|ArrayParameterType|string|int|null $type ParameterType::*, ArrayParameterType::* or \Doctrine\DBAL\Types\Type::* constant * * @return $this */ - public function setParameter(string|int $key, mixed $value, string|int|null $type = null): static + public function setParameter(string|int $key, mixed $value, ParameterType|ArrayParameterType|string|int|null $type = null): static { $existingParameter = $this->getParameter($key); From a5bf9bb96a0b2edbefd8355a61fb799fae03cec8 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 22 Feb 2024 09:12:39 +0100 Subject: [PATCH 370/475] Be less restrictive in DiscriminatorColumnMapping phpdoc (#11226) * Be less restrictive in params * Allow null options * Simplify expression * Fix ci * Add support for null --- src/Mapping/ClassMetadata.php | 19 +++++++------------ src/Mapping/DiscriminatorColumnMapping.php | 10 +++++----- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index 0d9889b6e77..3f5b1c77732 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -2108,13 +2108,12 @@ public function addEntityListener(string $eventName, string $class, string $meth * @param DiscriminatorColumnMapping|mixed[]|null $columnDef * @psalm-param DiscriminatorColumnMapping|array{ * name: string|null, - * fieldName?: string, - * type?: string, - * length?: int, + * fieldName?: string|null, + * type?: string|null, + * length?: int|null, * columnDefinition?: string|null, * enumType?: class-string|null, - * options?:array|null + * options?: array|null * }|null $columnDef * * @throws MappingException @@ -2136,13 +2135,9 @@ public function setDiscriminatorColumn(DiscriminatorColumnMapping|array|null $co throw MappingException::duplicateColumnName($this->name, $columnDef['name']); } - if (! isset($columnDef['fieldName'])) { - $columnDef['fieldName'] = $columnDef['name']; - } - - if (! isset($columnDef['type'])) { - $columnDef['type'] = 'string'; - } + $columnDef['fieldName'] ??= $columnDef['name']; + $columnDef['type'] ??= 'string'; + $columnDef['options'] ??= []; if (in_array($columnDef['type'], ['boolean', 'array', 'object', 'datetime', 'time', 'date'], true)) { throw MappingException::invalidDiscriminatorColumnType($this->name, $columnDef['type']); diff --git a/src/Mapping/DiscriminatorColumnMapping.php b/src/Mapping/DiscriminatorColumnMapping.php index cc23fdfdb3b..4ccb71c4b36 100644 --- a/src/Mapping/DiscriminatorColumnMapping.php +++ b/src/Mapping/DiscriminatorColumnMapping.php @@ -39,10 +39,10 @@ public function __construct( * type: string, * fieldName: string, * name: string, - * length?: int, - * columnDefinition?: string, - * enumType?: class-string, - * options?: array, + * length?: int|null, + * columnDefinition?: string|null, + * enumType?: class-string|null, + * options?: array|null, * } $mappingArray */ public static function fromMappingArray(array $mappingArray): self @@ -58,7 +58,7 @@ public static function fromMappingArray(array $mappingArray): self } if (property_exists($mapping, $key)) { - $mapping->$key = $value; + $mapping->$key = $value ?? $mapping->$key; } else { throw new Exception('Unknown property ' . $key . ' on class ' . static::class); } From 708146bbbc08651d8d2ec4eaa144b3ce96a57cf7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 22 Feb 2024 00:00:19 +0100 Subject: [PATCH 371/475] Test different ways of settings query parameters --- .../ORM/Functional/QueryParameterTest.php | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 tests/Tests/ORM/Functional/QueryParameterTest.php diff --git a/tests/Tests/ORM/Functional/QueryParameterTest.php b/tests/Tests/ORM/Functional/QueryParameterTest.php new file mode 100644 index 00000000000..e7599cea5ea --- /dev/null +++ b/tests/Tests/ORM/Functional/QueryParameterTest.php @@ -0,0 +1,124 @@ +useModelSet('cms'); + + parent::setUp(); + + $user = new CmsUser(); + $user->name = 'John Doe'; + $user->username = 'john'; + $user2 = new CmsUser(); + $user2->name = 'Jane Doe'; + $user2->username = 'jane'; + $user3 = new CmsUser(); + $user3->name = 'Just Bill'; + $user3->username = 'bill'; + + $this->_em->persist($user); + $this->_em->persist($user2); + $this->_em->persist($user3); + $this->_em->flush(); + + $this->userId = $user->id; + + $this->_em->clear(); + } + + public function testParameterTypeInBuilder(): void + { + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.id = :id') + ->setParameter('id', $this->userId, ParameterType::INTEGER) + ->getQuery() + ->getArrayResult(); + + self::assertSame([['name' => 'John Doe']], $result); + } + + public function testParameterTypeInQuery(): void + { + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.id = :id') + ->getQuery() + ->setParameter('id', $this->userId, ParameterType::INTEGER) + ->getArrayResult(); + + self::assertSame([['name' => 'John Doe']], $result); + } + + public function testDbalTypeStringInBuilder(): void + { + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.id = :id') + ->setParameter('id', $this->userId, Types::INTEGER) + ->getQuery() + ->getArrayResult(); + + self::assertSame([['name' => 'John Doe']], $result); + } + + public function testDbalTypeStringInQuery(): void + { + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.id = :id') + ->getQuery() + ->setParameter('id', $this->userId, Types::INTEGER) + ->getArrayResult(); + + self::assertSame([['name' => 'John Doe']], $result); + } + + public function testArrayParameterTypeInBuilder(): void + { + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.username IN (:usernames)') + ->orderBy('u.username') + ->setParameter('usernames', ['john', 'jane'], ArrayParameterType::STRING) + ->getQuery() + ->getArrayResult(); + + self::assertSame([['name' => 'Jane Doe'], ['name' => 'John Doe']], $result); + } + + public function testArrayParameterTypeInQuery(): void + { + $result = $this->_em->createQueryBuilder() + ->from(CmsUser::class, 'u') + ->select('u.name') + ->where('u.username IN (:usernames)') + ->orderBy('u.username') + ->getQuery() + ->setParameter('usernames', ['john', 'jane'], ArrayParameterType::STRING) + ->getArrayResult(); + + self::assertSame([['name' => 'Jane Doe'], ['name' => 'John Doe']], $result); + } +} From 859e6af972983e8bb79203b04bade295ad805049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 22 Feb 2024 21:47:57 +0100 Subject: [PATCH 372/475] Translate comment into code and annotations The phpdoc comment for the return type of ClassMetadata::fullyQualifiedClassName() says that the return type will be null if the input value is null. I have made it more precise by using "if and only if", made the null check more strict and translated that into template annotations. Also, since we say we return a class-string, I've asserted that. --- psalm-baseline.xml | 7 ------- src/Mapping/ClassMetadata.php | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b024e68334a..bf54038d816 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -290,11 +290,6 @@ $repositoryClassName - - - $class - - columnNames]]> @@ -322,8 +317,6 @@ $entity - $class - $className declaredField]]]> diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index b3d7838cce6..9d887be8325 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -2464,11 +2464,18 @@ public function getAssociationMappedByTargetField(string $assocName): string return $assoc->mappedBy; } - /** @return string|null null if the input value is null */ + /** + * @param C $className + * + * @return string|null null if and only if the input value is null + * @psalm-return (C is class-string ? class-string : (C is string ? string : null)) + * + * @template C of string|null + */ public function fullyQualifiedClassName(string|null $className): string|null { - if (empty($className)) { - return $className; + if ($className === null) { + return null; } if (! str_contains($className, '\\') && $this->namespace) { @@ -2511,12 +2518,8 @@ public function mapEmbedded(array $mapping): void throw MappingException::missingEmbeddedClass($mapping['fieldName']); } - $fqcn = $this->fullyQualifiedClassName($mapping['class']); - - assert($fqcn !== null); - $this->embeddedClasses[$mapping['fieldName']] = EmbeddedClassMapping::fromMappingArray([ - 'class' => $fqcn, + 'class' => $this->fullyQualifiedClassName($mapping['class']), 'columnPrefix' => $mapping['columnPrefix'] ?? null, 'declaredField' => $mapping['declaredField'] ?? null, 'originalField' => $mapping['originalField'] ?? null, From d54c9678d06d2d8586cbd2c8e64fa37d54235f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 24 Feb 2024 22:07:41 +0100 Subject: [PATCH 373/475] Deprecate passing null to ClassMetadata::fullyQualifiedClassName() It can easily be avoided by the only caller. --- UPGRADE.md | 5 +++++ src/Mapping/ClassMetadata.php | 14 ++++++++++++++ tests/Tests/ORM/Mapping/ClassMetadataTest.php | 12 ++++++++++++ 3 files changed, 31 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 09100433fe0..6d40bf48078 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 3.1 +## Deprecate passing null to `ClassMetadata::fullyQualifiedClassName()` + +Passing `null` to `Doctrine\ORM\ClassMetadata::fullyQualifiedClassName()` is +deprecated and will no longer be possible in 4.0. + ## Deprecate array access Using array access on instances of the following classes is deprecated: diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index 9d887be8325..1314cad28f9 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -7,6 +7,7 @@ use BackedEnum; use BadMethodCallException; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\Deprecations\Deprecation; use Doctrine\Instantiator\Instantiator; use Doctrine\Instantiator\InstantiatorInterface; use Doctrine\ORM\Cache\Exception\NonCacheableEntityAssociation; @@ -2003,6 +2004,12 @@ protected function _storeAssociationMapping(AssociationMapping $assocMapping): v */ public function setCustomRepositoryClass(string|null $repositoryClassName): void { + if ($repositoryClassName === null) { + $this->customRepositoryClassName = null; + + return; + } + $this->customRepositoryClassName = $this->fullyQualifiedClassName($repositoryClassName); } @@ -2475,6 +2482,13 @@ public function getAssociationMappedByTargetField(string $assocName): string public function fullyQualifiedClassName(string|null $className): string|null { if ($className === null) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11294', + 'Passing null to %s is deprecated and will not be supported in Doctrine ORM 4.0', + __METHOD__, + ); + return null; } diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index be44c416aea..acbedcc584c 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -6,6 +6,7 @@ use ArrayObject; use Doctrine\DBAL\Types\Types; +use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ChainTypedFieldMapper; use Doctrine\ORM\Mapping\ClassMetadata; @@ -66,6 +67,8 @@ class ClassMetadataTest extends OrmTestCase { + use VerifyDeprecations; + public function testClassMetadataInstanceSerialization(): void { $cm = new ClassMetadata(CmsUser::class); @@ -1052,6 +1055,15 @@ public function testItAddingLifecycleCallbackOnEmbeddedClassIsIllegal(): void $metadata->addLifecycleCallback('foo', 'bar'); } + + public function testGettingAnFQCNForNullIsDeprecated(): void + { + $metadata = new ClassMetadata(self::class); + + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/11294'); + + $metadata->fullyQualifiedClassName(null); + } } #[MappedSuperclass] From 9cc11d2541d1ef6728abbc8c94b6ff7325d2ab86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 25 Feb 2024 11:20:44 +0100 Subject: [PATCH 374/475] Remove extra word --- src/Mapping/ClassMetadataFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mapping/ClassMetadataFactory.php b/src/Mapping/ClassMetadataFactory.php index e18b2daa1c5..a3a47018081 100644 --- a/src/Mapping/ClassMetadataFactory.php +++ b/src/Mapping/ClassMetadataFactory.php @@ -642,7 +642,7 @@ private function determineIdGeneratorStrategy(AbstractPlatform $platform): int configuration. We currently recommend "SEQUENCE" for "%s", when using DBAL 3, and "IDENTITY" when using DBAL 4, - so you should use probably use the following configuration before upgrading to DBAL 4, + so you should probably use the following configuration before upgrading to DBAL 4, and remove it after deploying that upgrade: $configuration->setIdentityGenerationPreferences([ From 3f7a3333ad5386488e6c6f5ee72608448cec17a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 25 Feb 2024 21:42:46 +0100 Subject: [PATCH 375/475] Throw a full-fledged exception on invalid call In 2.x, getAssociationMappedByTargetField() used to return null when called with the owning side of an association. That was undocumented and wrong because the phpdoc advertises a string as a return type. In 6ce0cf4a3dd1cb6348c7b16979b01154e2be3f72, I wrongly assumed that nobody would be calling this method with the owning side of an association. Let us throw a full fledged exception and advertise the proper way of avoiding this situation. Closes #11250 --- UPGRADE.md | 11 +++++++++++ src/Mapping/ClassMetadata.php | 16 ++++++++++++++-- tests/Tests/ORM/Mapping/ClassMetadataTest.php | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index e6a61238a89..71c2fc9a7b2 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,16 @@ # Upgrade to 3.0 +## BC BREAK: Calling `ClassMetadata::getAssociationMappedByTargetField()` with the owning side of an association now throws an exception + +Previously, calling +`Doctrine\ORM\Mapping\ClassMetadata::getAssociationMappedByTargetField()` with +the owning side of an association returned `null`, which was undocumented, and +wrong according to the phpdoc of the parent method. + +If you do not know whether you are on the owning or inverse side of an association, +you can use `Doctrine\ORM\Mapping\ClassMetadata::isAssociationInverseSide()` +to find out. + ## BC BREAK: `Doctrine\ORM\Proxy\Autoloader` no longer extends `Doctrine\Common\Proxy\Autoloader` Make sure to use the former when writing a type declaration or an `instanceof` check. diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index b3d7838cce6..8cd2767889e 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -41,6 +41,7 @@ use function ltrim; use function method_exists; use function spl_object_id; +use function sprintf; use function str_contains; use function str_replace; use function strtolower; @@ -2457,9 +2458,20 @@ public function isAssociationInverseSide(string $assocName): bool public function getAssociationMappedByTargetField(string $assocName): string { - $assoc = $this->associationMappings[$assocName]; + $assoc = $this->getAssociationMapping($assocName); - assert($assoc instanceof InverseSideMapping); + if (! $assoc instanceof InverseSideMapping) { + throw new LogicException(sprintf( + <<<'EXCEPTION' + Context: Calling %s() with "%s", which is the owning side of an association. + Problem: The owning side of an association has no "mappedBy" field. + Solution: Call %s::isAssociationInverseSide() to check first. + EXCEPTION, + __METHOD__, + $assocName, + self::class, + )); + } return $assoc->mappedBy; } diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index edd05959408..c83960daf83 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -47,6 +47,7 @@ use Doctrine\Tests\ORM\Mapping\TypedFieldMapper\CustomIntAsStringTypedFieldMapper; use Doctrine\Tests\OrmTestCase; use DoctrineGlobalArticle; +use LogicException; use PHPUnit\Framework\Attributes\Group as TestGroup; use ReflectionClass; use stdClass; @@ -1054,6 +1055,21 @@ public function testItAddingLifecycleCallbackOnEmbeddedClassIsIllegal(): void $metadata->addLifecycleCallback('foo', 'bar'); } + + public function testItThrowsOnInvalidCallToGetAssociationMappedByTargetField(): void + { + $metadata = new ClassMetadata(self::class); + $metadata->mapOneToOne(['fieldName' => 'foo', 'targetEntity' => 'bar']); + + $this->expectException(LogicException::class); + $this->expectExceptionMessage(<<<'EXCEPTION' + Context: Calling Doctrine\ORM\Mapping\ClassMetadata::getAssociationMappedByTargetField() with "foo", which is the owning side of an association. + Problem: The owning side of an association has no "mappedBy" field. + Solution: Call Doctrine\ORM\Mapping\ClassMetadata::isAssociationInverseSide() to check first. + EXCEPTION); + + $metadata->getAssociationMappedByTargetField('foo'); + } } #[MappedSuperclass] From 694413a8883cb4e21db02320f1c5b36bc5af86c1 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 1 Mar 2024 08:51:21 +0100 Subject: [PATCH 376/475] Remove PHP 7 workarounds (#11324) --- phpcs.xml.dist | 5 ----- src/Internal/CriteriaOrderings.php | 8 ++------ src/Mapping/Driver/XmlDriver.php | 6 +++--- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 6bf448060dc..7ead84a96fa 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -274,9 +274,4 @@ src/QueryBuilder.php
- - - - src/Mapping/Driver/XmlDriver.php - diff --git a/src/Internal/CriteriaOrderings.php b/src/Internal/CriteriaOrderings.php index a6e60073643..1132fa387cf 100644 --- a/src/Internal/CriteriaOrderings.php +++ b/src/Internal/CriteriaOrderings.php @@ -26,9 +26,7 @@ private static function getCriteriaOrderings(Criteria $criteria): array } return array_map( - static function (Order $order): string { - return $order->value; - }, + static fn (Order $order): string => $order->value, $criteria->orderings(), ); } @@ -45,9 +43,7 @@ private static function mapToOrderEnumIfAvailable(array $orderings): array } return array_map( - static function (string $order): Order { - return Order::from(strtoupper($order)); - }, + static fn (string $order): Order => Order::from(strtoupper($order)), $orderings, ); } diff --git a/src/Mapping/Driver/XmlDriver.php b/src/Mapping/Driver/XmlDriver.php index a442ad906dc..000512a8d63 100644 --- a/src/Mapping/Driver/XmlDriver.php +++ b/src/Mapping/Driver/XmlDriver.php @@ -18,10 +18,10 @@ use SimpleXMLElement; use function assert; -use function class_exists; use function constant; use function count; use function defined; +use function enum_exists; use function explode; use function extension_loaded; use function file_get_contents; @@ -408,7 +408,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad /** @psalm-suppress DeprecatedConstant */ $orderBy[(string) $orderByField['name']] = isset($orderByField['direction']) ? (string) $orderByField['direction'] - : (class_exists(Order::class) ? (Order::Ascending)->value : Criteria::ASC); + : (enum_exists(Order::class) ? Order::Ascending->value : Criteria::ASC); } $mapping['orderBy'] = $orderBy; @@ -537,7 +537,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad /** @psalm-suppress DeprecatedConstant */ $orderBy[(string) $orderByField['name']] = isset($orderByField['direction']) ? (string) $orderByField['direction'] - : (class_exists(Order::class) ? (Order::Ascending)->value : Criteria::ASC); + : (enum_exists(Order::class) ? Order::Ascending->value : Criteria::ASC); } $mapping['orderBy'] = $orderBy; From bf49055a1ff10b904d62b152cabf21f1e0dc8d15 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 1 Mar 2024 08:56:07 +0100 Subject: [PATCH 377/475] Use enum_exists() for enums --- src/Internal/CriteriaOrderings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Internal/CriteriaOrderings.php b/src/Internal/CriteriaOrderings.php index 1132fa387cf..88ab2a35a43 100644 --- a/src/Internal/CriteriaOrderings.php +++ b/src/Internal/CriteriaOrderings.php @@ -8,7 +8,7 @@ use Doctrine\Common\Collections\Order; use function array_map; -use function class_exists; +use function enum_exists; use function method_exists; use function strtoupper; @@ -38,7 +38,7 @@ private static function getCriteriaOrderings(Criteria $criteria): array */ private static function mapToOrderEnumIfAvailable(array $orderings): array { - if (! class_exists(Order::class)) { + if (! enum_exists(Order::class)) { return $orderings; } From cb497826be0ac090bb3e03118a6b05e78b3732c2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 1 Mar 2024 09:27:30 +0100 Subject: [PATCH 378/475] Bump Doctrine Collections to 2.2 (#11325) --- composer.json | 2 +- .../Entity/AbstractEntityPersister.php | 10 ++-- src/Internal/CriteriaOrderings.php | 50 ------------------- src/PersistentCollection.php | 14 +++--- .../Collection/ManyToManyPersister.php | 7 +-- .../Entity/BasicEntityPersister.php | 8 +-- src/QueryBuilder.php | 6 +-- 7 files changed, 22 insertions(+), 75 deletions(-) delete mode 100644 src/Internal/CriteriaOrderings.php diff --git a/composer.json b/composer.json index c65c03b959d..59950ba165c 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "php": "^8.1", "composer-runtime-api": "^2", "ext-ctype": "*", - "doctrine/collections": "^2.1", + "doctrine/collections": "^2.2", "doctrine/dbal": "^3.8.2 || ^4", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.2 || ^2", diff --git a/src/Cache/Persister/Entity/AbstractEntityPersister.php b/src/Cache/Persister/Entity/AbstractEntityPersister.php index fddc3d26303..9f371d8b205 100644 --- a/src/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/src/Cache/Persister/Entity/AbstractEntityPersister.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Cache\Persister\Entity; use Doctrine\Common\Collections\Criteria; +use Doctrine\Common\Collections\Order; use Doctrine\DBAL\LockMode; use Doctrine\ORM\Cache; use Doctrine\ORM\Cache\CollectionCacheKey; @@ -17,7 +18,6 @@ use Doctrine\ORM\Cache\TimestampCacheKey; use Doctrine\ORM\Cache\TimestampRegion; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Internal\CriteriaOrderings; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; @@ -34,8 +34,6 @@ abstract class AbstractEntityPersister implements CachedEntityPersister { - use CriteriaOrderings; - protected UnitOfWork $uow; protected ClassMetadataFactory $metadataFactory; @@ -204,8 +202,8 @@ private function storeJoinedAssociations(object $entity): void /** * Generates a string of currently query * - * @param string[]|Criteria $criteria - * @param string[]|null $orderBy + * @param string[]|Criteria $criteria + * @param array|null $orderBy */ protected function getHash( string $query, @@ -429,7 +427,7 @@ public function count(array|Criteria $criteria = []): int */ public function loadCriteria(Criteria $criteria): array { - $orderBy = self::getCriteriaOrderings($criteria); + $orderBy = $criteria->orderings(); $limit = $criteria->getMaxResults(); $offset = $criteria->getFirstResult(); $query = $this->persister->getSelectSQL($criteria); diff --git a/src/Internal/CriteriaOrderings.php b/src/Internal/CriteriaOrderings.php deleted file mode 100644 index 88ab2a35a43..00000000000 --- a/src/Internal/CriteriaOrderings.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * @psalm-suppress DeprecatedMethod We need to call the deprecated API if the new one does not exist yet. - */ - private static function getCriteriaOrderings(Criteria $criteria): array - { - if (! method_exists(Criteria::class, 'orderings')) { - return $criteria->getOrderings(); - } - - return array_map( - static fn (Order $order): string => $order->value, - $criteria->orderings(), - ); - } - - /** - * @param array $orderings - * - * @return array|array - */ - private static function mapToOrderEnumIfAvailable(array $orderings): array - { - if (! enum_exists(Order::class)) { - return $orderings; - } - - return array_map( - static fn (string $order): Order => Order::from(strtoupper($order)), - $orderings, - ); - } -} diff --git a/src/PersistentCollection.php b/src/PersistentCollection.php index 3dcaee0ecf9..24cdef0a5de 100644 --- a/src/PersistentCollection.php +++ b/src/PersistentCollection.php @@ -8,8 +8,8 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; +use Doctrine\Common\Collections\Order; use Doctrine\Common\Collections\Selectable; -use Doctrine\ORM\Internal\CriteriaOrderings; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ToManyAssociationMapping; @@ -24,6 +24,7 @@ use function assert; use function is_object; use function spl_object_id; +use function strtoupper; /** * A PersistentCollection represents a collection of elements that have persistent state. @@ -41,8 +42,6 @@ */ final class PersistentCollection extends AbstractLazyCollection implements Selectable { - use CriteriaOrderings; - /** * A snapshot of the collection at the moment it was fetched from the database. * This is used to create a diff of the collection at commit time. @@ -588,9 +587,12 @@ public function matching(Criteria $criteria): Collection $criteria = clone $criteria; $criteria->where($expression); - $criteria->orderBy(self::mapToOrderEnumIfAvailable( - self::getCriteriaOrderings($criteria) ?: $association->orderBy(), - )); + $criteria->orderBy( + $criteria->orderings() ?: array_map( + static fn (string $order): Order => Order::from(strtoupper($order)), + $association->orderBy(), + ), + ); $persister = $this->getUnitOfWork()->getEntityPersister($association->targetEntity); diff --git a/src/Persisters/Collection/ManyToManyPersister.php b/src/Persisters/Collection/ManyToManyPersister.php index 4843271e107..7cf993d5997 100644 --- a/src/Persisters/Collection/ManyToManyPersister.php +++ b/src/Persisters/Collection/ManyToManyPersister.php @@ -9,7 +9,6 @@ use Doctrine\Common\Collections\Expr\Comparison; use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\LockMode; -use Doctrine\ORM\Internal\CriteriaOrderings; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\InverseSideMapping; @@ -33,8 +32,6 @@ */ class ManyToManyPersister extends AbstractCollectionPersister { - use CriteriaOrderings; - public function delete(PersistentCollection $collection): void { $mapping = $this->getMapping($collection); @@ -735,7 +732,7 @@ private function expandCriteriaParameters(Criteria $criteria): array private function getOrderingSql(Criteria $criteria, ClassMetadata $targetClass): string { - $orderings = self::getCriteriaOrderings($criteria); + $orderings = $criteria->orderings(); if ($orderings) { $orderBy = []; foreach ($orderings as $name => $direction) { @@ -744,7 +741,7 @@ private function getOrderingSql(Criteria $criteria, ClassMetadata $targetClass): $targetClass, $this->platform, ); - $orderBy[] = $field . ' ' . $direction; + $orderBy[] = $field . ' ' . $direction->value; } return ' ORDER BY ' . implode(', ', $orderBy); diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index fc16c669e9f..377e03ce274 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -7,6 +7,7 @@ use BackedEnum; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Expr\Comparison; +use Doctrine\Common\Collections\Order; use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; @@ -16,7 +17,6 @@ use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Internal\CriteriaOrderings; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\JoinColumnMapping; @@ -98,7 +98,6 @@ */ class BasicEntityPersister implements EntityPersister { - use CriteriaOrderings; use LockSqlHelper; /** @var array */ @@ -844,7 +843,10 @@ public function count(array|Criteria $criteria = []): int */ public function loadCriteria(Criteria $criteria): array { - $orderBy = self::getCriteriaOrderings($criteria); + $orderBy = array_map( + static fn (Order $order): string => $order->value, + $criteria->orderings(), + ); $limit = $criteria->getMaxResults(); $offset = $criteria->getFirstResult(); $query = $this->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy); diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 3c41590e7b0..a6a39a964b8 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -8,7 +8,6 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\DBAL\ArrayParameterType; use Doctrine\DBAL\ParameterType; -use Doctrine\ORM\Internal\CriteriaOrderings; use Doctrine\ORM\Internal\NoUnknownNamedArguments; use Doctrine\ORM\Internal\QueryType; use Doctrine\ORM\Query\Expr; @@ -42,7 +41,6 @@ */ class QueryBuilder implements Stringable { - use CriteriaOrderings; use NoUnknownNamedArguments; /** @@ -1189,7 +1187,7 @@ public function addCriteria(Criteria $criteria): static } } - foreach (self::getCriteriaOrderings($criteria) as $sort => $order) { + foreach ($criteria->orderings() as $sort => $order) { $hasValidAlias = false; foreach ($allAliases as $alias) { if (str_starts_with($sort . '.', $alias . '.')) { @@ -1202,7 +1200,7 @@ public function addCriteria(Criteria $criteria): static $sort = $allAliases[0] . '.' . $sort; } - $this->addOrderBy($sort, $order); + $this->addOrderBy($sort, $order->value); } // Overwrite limits only if they was set in criteria From ba0ea8953beba94d4fa71207bcc4803d2f96d11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 3 Mar 2024 13:08:37 +0100 Subject: [PATCH 379/475] Use class from persistence package (#11330) * Use class from persistence package It is meant to remove duplication between the ORM and the ODM. * Update UPGRADE.md Co-authored-by: Steve Todd --------- Co-authored-by: Alexander M. Turek Co-authored-by: Steve Todd --- UPGRADE.md | 6 ++++++ composer.json | 2 +- src/Mapping/ClassMetadata.php | 5 +++-- src/Mapping/ReflectionEmbeddedProperty.php | 2 +- src/Mapping/ReflectionEnumProperty.php | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 3dd84679ed2..01020b90a9a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 3.1 +## Deprecate `Doctrine\ORM\Mapping\ReflectionEnumProperty` + +This class is deprecated and will be removed in 4.0. +Instead, use `Doctrine\Persistence\Reflection\EnumReflectionProperty` from +`doctrine/persistence`. + ## Deprecate passing null to `ClassMetadata::fullyQualifiedClassName()` Passing `null` to `Doctrine\ORM\ClassMetadata::fullyQualifiedClassName()` is diff --git a/composer.json b/composer.json index e435f8addc2..1a42c2c3ab8 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "doctrine/inflector": "^1.4 || ^2.0", "doctrine/instantiator": "^1.3 || ^2", "doctrine/lexer": "^3", - "doctrine/persistence": "^3.1.1", + "doctrine/persistence": "^3.3.1", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^5.4 || ^6.0 || ^7.0", "symfony/var-exporter": "~6.2.13 || ^6.3.2 || ^7.0" diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index fd547e92589..85079ed049d 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -15,6 +15,7 @@ use Doctrine\ORM\Id\AbstractIdGenerator; use Doctrine\Persistence\Mapping\ClassMetadata as PersistenceClassMetadata; use Doctrine\Persistence\Mapping\ReflectionService; +use Doctrine\Persistence\Reflection\EnumReflectionProperty; use InvalidArgumentException; use LogicException; use ReflectionClass; @@ -822,7 +823,7 @@ public function wakeupReflection(ReflectionService $reflService): void assert($childProperty !== null); if (isset($mapping->enumType)) { - $childProperty = new ReflectionEnumProperty( + $childProperty = new EnumReflectionProperty( $childProperty, $mapping->enumType, ); @@ -841,7 +842,7 @@ public function wakeupReflection(ReflectionService $reflService): void : $this->getAccessibleProperty($reflService, $this->name, $field); if (isset($mapping->enumType) && $this->reflFields[$field] !== null) { - $this->reflFields[$field] = new ReflectionEnumProperty( + $this->reflFields[$field] = new EnumReflectionProperty( $this->reflFields[$field], $mapping->enumType, ); diff --git a/src/Mapping/ReflectionEmbeddedProperty.php b/src/Mapping/ReflectionEmbeddedProperty.php index 6f818f89773..da3d09749b4 100644 --- a/src/Mapping/ReflectionEmbeddedProperty.php +++ b/src/Mapping/ReflectionEmbeddedProperty.php @@ -30,7 +30,7 @@ public function __construct( private readonly ReflectionProperty $childProperty, private readonly string $embeddedClass, ) { - parent::__construct($childProperty->class, $childProperty->name); + parent::__construct($childProperty->getDeclaringClass()->name, $childProperty->getName()); } public function getValue(object|null $object = null): mixed diff --git a/src/Mapping/ReflectionEnumProperty.php b/src/Mapping/ReflectionEnumProperty.php index 9b4ff0e8f34..0ebd978f412 100644 --- a/src/Mapping/ReflectionEnumProperty.php +++ b/src/Mapping/ReflectionEnumProperty.php @@ -11,6 +11,7 @@ use function array_map; use function is_array; +/** @deprecated use Doctrine\Persistence\Reflection\EnumReflectionProperty instead */ final class ReflectionEnumProperty extends ReflectionProperty { /** @param class-string $enumType */ From 0a49274f9b92426e17dd4a5fdf3aae41dd24c59f Mon Sep 17 00:00:00 2001 From: d-ph <4347095+d-ph@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:36:42 +0000 Subject: [PATCH 380/475] Update aggregate-fields.rst Change `PESSIMISTIC_READ` to `PESSIMISTIC_WRITE`. Otherwise, the solution to the race condition at the bottom of the article would allow concurrent reads, which would not solve the presented race condition problem. --- docs/en/cookbook/aggregate-fields.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/cookbook/aggregate-fields.rst b/docs/en/cookbook/aggregate-fields.rst index 001d70d34b4..20bfa32896f 100644 --- a/docs/en/cookbook/aggregate-fields.rst +++ b/docs/en/cookbook/aggregate-fields.rst @@ -352,7 +352,7 @@ the database using a FOR UPDATE. use Bank\Entities\Account; use Doctrine\DBAL\LockMode; - $account = $em->find(Account::class, $accId, LockMode::PESSIMISTIC_READ); + $account = $em->find(Account::class, $accId, LockMode::PESSIMISTIC_WRITE); Keeping Updates and Deletes in Sync ----------------------------------- From 68f9bf5dfabad15dd41eba6192c3e01509cb3b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 14 Mar 2024 13:14:55 +0100 Subject: [PATCH 381/475] Deprecate --complete option of orm:schema-tool:update It achieves nothing anymore. --- UPGRADE.md | 6 ++++++ .../Console/Command/SchemaTool/UpdateCommand.php | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 01020b90a9a..7d49322ca8e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,9 @@ +# Upgrade to 3.2 + +## `orm:schema-tool:update` option `--complete` is deprecated + +That option behaves as a no-op, and is deprecated. It will be removed in 4.0. + # Upgrade to 3.1 ## Deprecate `Doctrine\ORM\Mapping\ReflectionEnumProperty` diff --git a/src/Tools/Console/Command/SchemaTool/UpdateCommand.php b/src/Tools/Console/Command/SchemaTool/UpdateCommand.php index 9d490b4cb59..f35fc384536 100644 --- a/src/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/src/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Tools\Console\Command\SchemaTool; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Tools\SchemaTool; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -28,7 +29,7 @@ protected function configure(): void $this->setName($this->name) ->setDescription('Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata') ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') - ->addOption('complete', null, InputOption::VALUE_NONE, 'This option is a no-op and will be removed in 4.0') + ->addOption('complete', null, InputOption::VALUE_NONE, 'This option is a no-op, is deprecated and will be removed in 4.0') ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Dumps the generated SQL statements to the screen (does not execute them).') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Causes the generated SQL statements to be physically executed against your database.') ->setHelp(<<<'EOT' @@ -75,6 +76,15 @@ protected function executeSchemaCommand(InputInterface $input, OutputInterface $ { $notificationUi = $ui->getErrorStyle(); + if ($input->getOption('complete') === true) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11354', + 'The --complete option is a no-op, is deprecated and will be removed in Doctrine ORM 4.0.', + ); + $notificationUi->warning('The --complete option is a no-op, is deprecated and will be removed in Doctrine ORM 4.0.'); + } + $sqls = $schemaTool->getUpdateSchemaSql($metadatas); if (empty($sqls)) { From 7d1444e5b699071134f9ae52c0b1e0b7bc1d3338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismail=20=C3=96zg=C3=BCn=20Turan?= Date: Fri, 15 Mar 2024 09:19:35 +0100 Subject: [PATCH 382/475] Deprecate obsolete and unnecessary properties from Table attribute (#11351) The properties `indexes` and `uniqueConstraints` were used by the `AnnotationDriver` but were never implemented for the `AttributeDriver`. Since the `AnnotationDriver` doesn't exist anymore these can become deprecated and will then be removed afterwards. --- UPGRADE.md | 6 +++++ src/Mapping/Table.php | 20 ++++++++++++++ tests/Tests/ORM/Mapping/TableMappingTest.php | 28 ++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/Tests/ORM/Mapping/TableMappingTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 7d49322ca8e..d80970a7056 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -4,6 +4,12 @@ That option behaves as a no-op, and is deprecated. It will be removed in 4.0. +## Deprecate properties `$indexes` and `$uniqueConstraints` of `Doctrine\ORM\Mapping\Table` + +The properties `$indexes` and `$uniqueConstraints` have been deprecated since they had no effect at all. +The preferred way of defining indices and unique constraints is by +using the `\Doctrine\ORM\Mapping\UniqueConstraint` and `\Doctrine\ORM\Mapping\Index` attributes. + # Upgrade to 3.1 ## Deprecate `Doctrine\ORM\Mapping\ReflectionEnumProperty` diff --git a/src/Mapping/Table.php b/src/Mapping/Table.php index 8a06deebc42..ac1e8edfa35 100644 --- a/src/Mapping/Table.php +++ b/src/Mapping/Table.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Mapping; use Attribute; +use Doctrine\Deprecations\Deprecation; #[Attribute(Attribute::TARGET_CLASS)] final class Table implements MappingAttribute @@ -21,5 +22,24 @@ public function __construct( public readonly array|null $uniqueConstraints = null, public readonly array $options = [], ) { + if ($this->indexes !== null) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11357', + 'Providing the property $indexes on %s does not have any effect and will be removed in Doctrine ORM 4.0. Please use the %s attribute instead.', + self::class, + Index::class, + ); + } + + if ($this->uniqueConstraints !== null) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11357', + 'Providing the property $uniqueConstraints on %s does not have any effect and will be removed in Doctrine ORM 4.0. Please use the %s attribute instead.', + self::class, + UniqueConstraint::class, + ); + } } } diff --git a/tests/Tests/ORM/Mapping/TableMappingTest.php b/tests/Tests/ORM/Mapping/TableMappingTest.php new file mode 100644 index 00000000000..24031eafa41 --- /dev/null +++ b/tests/Tests/ORM/Mapping/TableMappingTest.php @@ -0,0 +1,28 @@ +expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/11357'); + + new Table(indexes: []); + } + + public function testDeprecationOnUniqueConstraintsPropertyIsTriggered(): void + { + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/11357'); + + new Table(uniqueConstraints: []); + } +} From d5fdd676f4a807b6be37d5e18f9a9e3adea48850 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 16 Mar 2024 22:20:34 +0100 Subject: [PATCH 383/475] Reintroduce PARTIAL, but only for non-object hydration. --- UPGRADE.md | 8 +- docs/en/index.rst | 1 + .../reference/dql-doctrine-query-language.rst | 23 +++- docs/en/reference/partial-hydration.rst | 20 +++ docs/en/sidebar.rst | 1 + src/Internal/Hydration/HydrationException.php | 5 + src/Query.php | 8 ++ src/Query/AST/PartialObjectExpression.php | 15 +++ src/Query/Parser.php | 118 +++++++++++++++++- src/Query/SqlWalker.php | 27 +++- src/Query/TokenType.php | 1 + src/UnitOfWork.php | 6 + .../Tests/ORM/Functional/ValueObjectsTest.php | 9 ++ .../ORM/Query/LanguageRecognitionTest.php | 15 +++ .../ORM/Query/SelectSqlGenerationTest.php | 40 +++++- .../LimitSubqueryOutputWalkerTest.php | 17 +++ 16 files changed, 303 insertions(+), 11 deletions(-) create mode 100644 docs/en/reference/partial-hydration.rst create mode 100644 src/Query/AST/PartialObjectExpression.php diff --git a/UPGRADE.md b/UPGRADE.md index 7d49322ca8e..85a492d7758 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -75,9 +75,11 @@ now they throw an exception. ## BC BREAK: Partial objects are removed -- The `PARTIAL` keyword in DQL no longer exists. -- `Doctrine\ORM\Query\AST\PartialObjectExpression`is removed. -- `Doctrine\ORM\Query\SqlWalker::HINT_PARTIAL` and +WARNING: This was relaxed in ORM 3.2 when partial was re-allowed for array-hydration. + +- The `PARTIAL` keyword in DQL no longer exists (reintroduced in ORM 3.2) +- `Doctrine\ORM\Query\AST\PartialObjectExpression` is removed. (reintroduced in ORM 3.2) +- `Doctrine\ORM\Query\SqlWalker::HINT_PARTIAL` (reintroduced in ORM 3.2) and `Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD` are removed. - `Doctrine\ORM\EntityManager*::getPartialReference()` is removed. diff --git a/docs/en/index.rst b/docs/en/index.rst index 83071ad9597..4d23062cd0d 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -73,6 +73,7 @@ Advanced Topics * :doc:`TypedFieldMapper ` * :doc:`Improving Performance ` * :doc:`Caching ` +* :doc:`Partial Hydration ` * :doc:`Change Tracking Policies ` * :doc:`Best Practices ` * :doc:`Metadata Drivers ` diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index 80d41f17002..b9adecd27b8 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -523,6 +523,25 @@ when the DQL is switched to an arbitrary join. - HAVING is applied to the results of a query after aggregation (GROUP BY) + +Partial Hydration Syntax +^^^^^^^^^^^^^^^^^^^^^^^^ + +By default when you run a DQL query in Doctrine and select only a +subset of the fields for a given entity, you do not receive objects +back. Instead, you receive only arrays as a flat rectangular result +set, similar to how you would if you were just using SQL directly +and joining some data. + +If you want to select a partial number of fields for hydration entity in +the context of array hydration and joins you can use the ``partial`` DQL keyword: + +.. code-block:: php + + createQuery('SELECT partial u.{id, username}, partial a.{id, name} FROM CmsUser u JOIN u.articles a'); + $users = $query->getArrayResult(); // array of partially loaded CmsUser and CmsArticle fields + "NEW" Operator Syntax ^^^^^^^^^^^^^^^^^^^^^ @@ -1647,8 +1666,10 @@ Select Expressions .. code-block:: php - SelectExpression ::= (IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | "(" Subselect ")" | CaseExpression | NewObjectExpression) [["AS"] ["HIDDEN"] AliasResultVariable] + SelectExpression ::= (IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression | NewObjectExpression) [["AS"] ["HIDDEN"] AliasResultVariable] SimpleSelectExpression ::= (StateFieldPathExpression | IdentificationVariable | FunctionDeclaration | AggregateExpression | "(" Subselect ")" | ScalarExpression) [["AS"] AliasResultVariable] + PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet + PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}" NewObjectExpression ::= "NEW" AbstractSchemaName "(" NewObjectArg {"," NewObjectArg}* ")" NewObjectArg ::= ScalarExpression | "(" Subselect ")" diff --git a/docs/en/reference/partial-hydration.rst b/docs/en/reference/partial-hydration.rst new file mode 100644 index 00000000000..a2cca3d186a --- /dev/null +++ b/docs/en/reference/partial-hydration.rst @@ -0,0 +1,20 @@ +Partial Hydration +================= + +.. note:: + + Creating Partial Objects through DQL was possible in ORM 2, + but is only supported for array hydration as of ORM 3 anymore. + +Partial hydration of entities is allowed in the array hydrator, when +only a subset of the fields of an entity are loaded from the database +and the nested results are still created based on the entity relationship structure. + +.. code-block:: php + + createQuery("SELECT PARTIAL u.{id,name}, partial a.{id,street} FROM MyApp\Domain\User u JOIN u.addresses a") + ->getArrayResult(); + +This is a useful optimization when you are not interested in all fields of an entity +for performance reasons, for example in use-cases for exporting or rendering lots of data. diff --git a/docs/en/sidebar.rst b/docs/en/sidebar.rst index 619c6e2511a..628aecfceab 100644 --- a/docs/en/sidebar.rst +++ b/docs/en/sidebar.rst @@ -43,6 +43,7 @@ reference/query-builder reference/native-sql reference/change-tracking-policies + reference/partial-hydration reference/attributes-reference reference/xml-mapping reference/php-mapping diff --git a/src/Internal/Hydration/HydrationException.php b/src/Internal/Hydration/HydrationException.php index 710114f7e6b..a59644300b4 100644 --- a/src/Internal/Hydration/HydrationException.php +++ b/src/Internal/Hydration/HydrationException.php @@ -64,4 +64,9 @@ public static function invalidDiscriminatorValue(string $discrValue, array $disc implode('", "', $discrValues), )); } + + public static function partialObjectHydrationDisallowed(): self + { + return new self('Hydration of entity objects is not allowed when DQL PARTIAL keyword is used.'); + } } diff --git a/src/Query.php b/src/Query.php index 5b0ceb7a97c..8c44eba8afa 100644 --- a/src/Query.php +++ b/src/Query.php @@ -70,6 +70,14 @@ class Query extends AbstractQuery */ public const HINT_REFRESH_ENTITY = 'doctrine.refresh.entity'; + /** + * The forcePartialLoad query hint forces a particular query to return + * partial objects. + * + * @todo Rename: HINT_OPTIMIZE + */ + public const HINT_FORCE_PARTIAL_LOAD = 'doctrine.forcePartialLoad'; + /** * The includeMetaColumns query hint causes meta columns like foreign keys and * discriminator columns to be selected and returned as part of the query result. diff --git a/src/Query/AST/PartialObjectExpression.php b/src/Query/AST/PartialObjectExpression.php new file mode 100644 index 00000000000..875f4453fe1 --- /dev/null +++ b/src/Query/AST/PartialObjectExpression.php @@ -0,0 +1,15 @@ + */ private array $deferredIdentificationVariables = []; + /** @psalm-var list */ + private array $deferredPartialObjectExpressions = []; + /** @psalm-var list */ private array $deferredPathExpressions = []; @@ -224,6 +229,10 @@ public function getAST(): AST\SelectStatement|AST\UpdateStatement|AST\DeleteStat // This also allows post-processing of the AST for modification purposes. $this->processDeferredIdentificationVariables(); + if ($this->deferredPartialObjectExpressions) { + $this->processDeferredPartialObjectExpressions(); + } + if ($this->deferredPathExpressions) { $this->processDeferredPathExpressions(); } @@ -599,6 +608,44 @@ private function processDeferredNewObjectExpressions(AST\SelectStatement $AST): } } + /** + * Validates that the given PartialObjectExpression is semantically correct. + * It must exist in query components list. + */ + private function processDeferredPartialObjectExpressions(): void + { + foreach ($this->deferredPartialObjectExpressions as $deferredItem) { + $expr = $deferredItem['expression']; + $class = $this->getMetadataForDqlAlias($expr->identificationVariable); + + foreach ($expr->partialFieldSet as $field) { + if (isset($class->fieldMappings[$field])) { + continue; + } + + if ( + isset($class->associationMappings[$field]) && + $class->associationMappings[$field]->isToOneOwningSide() + ) { + continue; + } + + $this->semanticalError(sprintf( + "There is no mapped field named '%s' on class %s.", + $field, + $class->name, + ), $deferredItem['token']); + } + + if (array_intersect($class->identifier, $expr->partialFieldSet) !== $class->identifier) { + $this->semanticalError( + 'The partial field selection of class ' . $class->name . ' must contain the identifier.', + $deferredItem['token'], + ); + } + } + } + /** * Validates that the given ResultVariable is semantically correct. * It must exist in query components list. @@ -1621,6 +1668,67 @@ public function JoinAssociationDeclaration(): AST\JoinAssociationDeclaration return new AST\JoinAssociationDeclaration($joinAssociationPathExpression, $aliasIdentificationVariable, $indexBy); } + /** + * PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet + * PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}" + */ + public function PartialObjectExpression(): AST\PartialObjectExpression + { + if ($this->query->getHydrationMode() === Query::HYDRATE_OBJECT) { + throw HydrationException::partialObjectHydrationDisallowed(); + } + + $this->match(TokenType::T_PARTIAL); + + $partialFieldSet = []; + + $identificationVariable = $this->IdentificationVariable(); + + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_OPEN_CURLY_BRACE); + $this->match(TokenType::T_IDENTIFIER); + + assert($this->lexer->token !== null); + $field = $this->lexer->token->value; + + // First field in partial expression might be embeddable property + while ($this->lexer->isNextToken(TokenType::T_DOT)) { + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_IDENTIFIER); + $field .= '.' . $this->lexer->token->value; + } + + $partialFieldSet[] = $field; + + while ($this->lexer->isNextToken(TokenType::T_COMMA)) { + $this->match(TokenType::T_COMMA); + $this->match(TokenType::T_IDENTIFIER); + + $field = $this->lexer->token->value; + + while ($this->lexer->isNextToken(TokenType::T_DOT)) { + $this->match(TokenType::T_DOT); + $this->match(TokenType::T_IDENTIFIER); + $field .= '.' . $this->lexer->token->value; + } + + $partialFieldSet[] = $field; + } + + $this->match(TokenType::T_CLOSE_CURLY_BRACE); + + $partialObjectExpression = new AST\PartialObjectExpression($identificationVariable, $partialFieldSet); + + // Defer PartialObjectExpression validation + $this->deferredPartialObjectExpressions[] = [ + 'expression' => $partialObjectExpression, + 'nestingLevel' => $this->nestingLevel, + 'token' => $this->lexer->token, + ]; + + return $partialObjectExpression; + } + /** * NewObjectExpression ::= "NEW" AbstractSchemaName "(" NewObjectArg {"," NewObjectArg}* ")" */ @@ -1920,7 +2028,7 @@ public function SimpleWhenClause(): AST\SimpleWhenClause /** * SelectExpression ::= ( * IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | - * "(" Subselect ")" | CaseExpression | NewObjectExpression + * PartialObjectExpression | "(" Subselect ")" | CaseExpression | NewObjectExpression * ) [["AS"] ["HIDDEN"] AliasResultVariable] */ public function SelectExpression(): AST\SelectExpression @@ -1961,6 +2069,12 @@ public function SelectExpression(): AST\SelectExpression break; + // PartialObjectExpression (PARTIAL u.{id, name}) + case $lookaheadType === TokenType::T_PARTIAL: + $expression = $this->PartialObjectExpression(); + $identVariable = $expression->identificationVariable; + break; + // Subselect case $lookaheadType === TokenType::T_OPEN_PARENTHESIS && $peek->type === TokenType::T_SELECT: $this->match(TokenType::T_OPEN_PARENTHESIS); @@ -1986,7 +2100,7 @@ public function SelectExpression(): AST\SelectExpression default: $this->syntaxError( - 'IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | "(" Subselect ")" | CaseExpression', + 'IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression', $this->lexer->lookahead, ); } diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index 018c2455e49..b70e37a03b3 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -28,6 +28,7 @@ use function assert; use function count; use function implode; +use function in_array; use function is_array; use function is_float; use function is_numeric; @@ -51,6 +52,11 @@ class SqlWalker public const HINT_DISTINCT = 'doctrine.distinct'; + /** + * Used to mark a query as containing a PARTIAL expression, which needs to be known by SLC. + */ + public const HINT_PARTIAL = 'doctrine.partial'; + private readonly ResultSetMapping $rsm; /** @@ -1318,7 +1324,17 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st break; default: - $dqlAlias = $expr; + // IdentificationVariable or PartialObjectExpression + if ($expr instanceof AST\PartialObjectExpression) { + $this->query->setHint(self::HINT_PARTIAL, true); + + $dqlAlias = $expr->identificationVariable; + $partialFieldSet = $expr->partialFieldSet; + } else { + $dqlAlias = $expr; + $partialFieldSet = []; + } + $class = $this->getMetadataForDqlAlias($dqlAlias); $resultAlias = $selectExpression->fieldIdentificationVariable ?: null; @@ -1334,6 +1350,10 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st // Select all fields from the queried class foreach ($class->fieldMappings as $fieldName => $mapping) { + if ($partialFieldSet && ! in_array($fieldName, $partialFieldSet, true)) { + continue; + } + $tableName = isset($mapping->inherited) ? $this->em->getClassMetadata($mapping->inherited)->getTableName() : $class->getTableName(); @@ -1360,13 +1380,14 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st // Add any additional fields of subclasses (excluding inherited fields) // 1) on Single Table Inheritance: always, since its marginal overhead - // 2) on Class Table Inheritance + // 2) on Class Table Inheritance only if partial objects are disallowed, + // since it requires outer joining subtables. foreach ($class->subClasses as $subClassName) { $subClass = $this->em->getClassMetadata($subClassName); $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if (isset($mapping->inherited)) { + if (isset($mapping->inherited) || ($partialFieldSet && ! in_array($fieldName, $partialFieldSet, true))) { continue; } diff --git a/src/Query/TokenType.php b/src/Query/TokenType.php index e745e4a1da3..bf1c351c2a6 100644 --- a/src/Query/TokenType.php +++ b/src/Query/TokenType.php @@ -77,6 +77,7 @@ enum TokenType: int case T_OR = 242; case T_ORDER = 243; case T_OUTER = 244; + case T_PARTIAL = 245; case T_SELECT = 246; case T_SET = 247; case T_SOME = 248; diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index e1336140640..ec7175c5df4 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -28,6 +28,7 @@ use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Exception\UnexpectedAssociationValue; use Doctrine\ORM\Id\AssignedGenerator; +use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Internal\HydrationCompleteHandler; use Doctrine\ORM\Internal\StronglyConnectedComponents; use Doctrine\ORM\Internal\TopologicalSort; @@ -43,6 +44,7 @@ use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister; use Doctrine\ORM\Persisters\Entity\SingleTablePersister; use Doctrine\ORM\Proxy\InternalProxy; +use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\Persistence\PropertyChangedListener; use Exception; @@ -2353,6 +2355,10 @@ public function isCollectionScheduledForDeletion(PersistentCollection $coll): bo */ public function createEntity(string $className, array $data, array &$hints = []): object { + if (isset($hints[SqlWalker::HINT_PARTIAL])) { + throw HydrationException::partialObjectHydrationDisallowed(); + } + $class = $this->em->getClassMetadata($className); $id = $this->identifierFlattener->flattenIdentifier($class, $data); diff --git a/tests/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Tests/ORM/Functional/ValueObjectsTest.php index 08ce4b17d89..6656d916ee0 100644 --- a/tests/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Tests/ORM/Functional/ValueObjectsTest.php @@ -218,6 +218,15 @@ public function testDqlWithNonExistentEmbeddableField(): void ->execute(); } + public function testPartialDqlWithNonExistentEmbeddableField(): void + { + $this->expectException(QueryException::class); + $this->expectExceptionMessage("no mapped field named 'address.asdfasdf'"); + + $this->_em->createQuery('SELECT PARTIAL p.{id,address.asdfasdf} FROM ' . __NAMESPACE__ . '\\DDC93Person p') + ->getArrayResult(); + } + public function testEmbeddableWithInheritance(): void { $car = new DDC93Car(new DDC93Address('Foo', '12345', 'Asdf')); diff --git a/tests/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Tests/ORM/Query/LanguageRecognitionTest.php index 0bdf2f37b38..ec57b1f1382 100644 --- a/tests/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Tests/ORM/Query/LanguageRecognitionTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -22,6 +23,7 @@ class LanguageRecognitionTest extends OrmTestCase { private EntityManagerInterface $entityManager; + private int $hydrationMode = AbstractQuery::HYDRATE_OBJECT; protected function setUp(): void { @@ -45,6 +47,7 @@ public function parseDql(string $dql, array $hints = []): ParserResult { $query = $this->entityManager->createQuery($dql); $query->setDQL($dql); + $query->setHydrationMode($this->hydrationMode); foreach ($hints as $key => $value) { $query->setHint($key, $value); @@ -527,6 +530,18 @@ public function testUnknownAbstractSchemaName(): void $this->assertInvalidDQL('SELECT u FROM UnknownClassName u'); } + public function testCorrectPartialObjectLoad(): void + { + $this->hydrationMode = AbstractQuery::HYDRATE_ARRAY; + $this->assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testIncorrectPartialObjectLoadBecauseOfMissingIdentifier(): void + { + $this->hydrationMode = AbstractQuery::HYDRATE_ARRAY; + $this->assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + public function testScalarExpressionInSelect(): void { $this->assertValidDQL('SELECT u, 42 + u.id AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u'); diff --git a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php index 681562c1dd8..3969fe51636 100644 --- a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -40,6 +40,7 @@ class_exists('Doctrine\\DBAL\\Platforms\\SqlitePlatform'); class SelectSqlGenerationTest extends OrmTestCase { private EntityManagerInterface $entityManager; + private int $hydrationMode = ORMQuery::HYDRATE_OBJECT; protected function setUp(): void { @@ -56,6 +57,7 @@ public function assertSqlGeneration( array $queryParams = [], ): void { $query = $this->entityManager->createQuery($dqlToBeTested); + $query->setHydrationMode($this->hydrationMode); foreach ($queryParams as $name => $value) { $query->setParameter($name, $value); @@ -1330,6 +1332,22 @@ public function testIdentityFunctionWithCompositePrimaryKey(): void ); } + #[Group('DDC-2519')] + public function testPartialWithAssociationIdentifier(): void + { + $this->hydrationMode = ORMQuery::HYDRATE_ARRAY; + + $this->assertSqlGeneration( + 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l', + 'SELECT l0_.iUserIdSource AS iUserIdSource_0, l0_.iUserIdTarget AS iUserIdTarget_1 FROM legacy_users_reference l0_', + ); + + $this->assertSqlGeneration( + 'SELECT PARTIAL l.{_description, _source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l', + 'SELECT l0_.description AS description_0, l0_.iUserIdSource AS iUserIdSource_1, l0_.iUserIdTarget AS iUserIdTarget_2 FROM legacy_users_reference l0_', + ); + } + #[Group('DDC-1339')] public function testIdentityFunctionInSelectClause(): void { @@ -1400,11 +1418,13 @@ public function testInheritanceTypeSingleTableInRootClass(): void } #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInChildClass(): void + public function testInheritanceTypeSingleTableInChildClassWithDisabledForcePartialLoad(): void { + $this->hydrationMode = ORMQuery::HYDRATE_ARRAY; + $this->assertSqlGeneration( 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', - "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", ); } @@ -1690,6 +1710,22 @@ public function testCustomTypeValueSqlForAllFields(): void ); } + public function testCustomTypeValueSqlForPartialObject(): void + { + $this->hydrationMode = ORMQuery::HYDRATE_ARRAY; + + if (DBALType::hasType('negative_to_positive')) { + DBALType::overrideType('negative_to_positive', NegativeToPositiveType::class); + } else { + DBALType::addType('negative_to_positive', NegativeToPositiveType::class); + } + + $this->assertSqlGeneration( + 'SELECT partial p.{id, customInteger} FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', + 'SELECT c0_.id AS id_0, -(c0_.customInteger) AS customInteger_1 FROM customtype_parents c0_', + ); + } + #[Group('DDC-1529')] public function testMultipleFromAndInheritanceCondition(): void { diff --git a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 65d0dbabf23..0f5bac25b72 100644 --- a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -147,6 +147,23 @@ public function testCountQueryWithComplexScalarOrderByItemJoined(): void ); } + public function testCountQueryWithComplexScalarOrderByItemJoinedWithPartial(): void + { + $entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); + + $query = $entityManager->createQuery( + 'SELECT u, partial a.{id, imageAltDesc} FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC', + ); + + $query->setHydrationMode(Query::HYDRATE_ARRAY); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class); + + self::assertSame( + 'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_5 * imageWidth_6 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.imageAltDesc AS imageAltDesc_2, a1_.id AS id_3, a1_.image AS image_4, a1_.imageHeight AS imageHeight_5, a1_.imageWidth AS imageWidth_6, a1_.imageAltDesc AS imageAltDesc_7 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_5 * imageWidth_6 DESC) dctrn_result', + $query->getSQL(), + ); + } + public function testCountQueryWithComplexScalarOrderByItemOracle(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new OraclePlatform()); From eb8510ff5c7c4ca508556b135ed194a0e3318e1e Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 16 Mar 2024 22:34:54 +0100 Subject: [PATCH 384/475] Add tests for adjusted functionality. --- tests/Tests/ORM/Functional/QueryTest.php | 46 ++++++++++++++++++++++++ tests/Tests/ORM/Query/ParserTest.php | 10 ++++++ tests/Tests/ORM/UnitOfWorkTest.php | 11 ++++++ 3 files changed, 67 insertions(+) diff --git a/tests/Tests/ORM/Functional/QueryTest.php b/tests/Tests/ORM/Functional/QueryTest.php index 00efce3f080..01d876fbbd1 100644 --- a/tests/Tests/ORM/Functional/QueryTest.php +++ b/tests/Tests/ORM/Functional/QueryTest.php @@ -109,6 +109,52 @@ public function testJoinQueries(): void self::assertEquals('Symfony 2', $users[0]->articles[1]->topic); } + public function testJoinPartialArrayHydration(): void + { + $user = new CmsUser(); + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $article1 = new CmsArticle(); + $article1->topic = 'Doctrine 2'; + $article1->text = 'This is an introduction to Doctrine 2.'; + $user->addArticle($article1); + + $article2 = new CmsArticle(); + $article2->topic = 'Symfony 2'; + $article2->text = 'This is an introduction to Symfony 2.'; + $user->addArticle($article2); + + $this->_em->persist($user); + $this->_em->persist($article1); + $this->_em->persist($article2); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('select partial u.{id, username}, partial a.{id, topic} from ' . CmsUser::class . ' u join u.articles a ORDER BY a.topic'); + $users = $query->getArrayResult(); + + $this->assertEquals([ + [ + 'id' => 13, + 'username' => 'gblanco', + 'articles' => + [ + [ + 'id' => 3, + 'topic' => 'Doctrine 2', + ], + [ + 'id' => 4, + 'topic' => 'Symfony 2', + ], + ], + ], + ], $users); + } + public function testUsingZeroBasedQueryParameterShouldWork(): void { $user = new CmsUser(); diff --git a/tests/Tests/ORM/Query/ParserTest.php b/tests/Tests/ORM/Query/ParserTest.php index 430177b1fcc..6290bbc4dab 100644 --- a/tests/Tests/ORM/Query/ParserTest.php +++ b/tests/Tests/ORM/Query/ParserTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Query; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; @@ -115,6 +116,15 @@ public function testNullLookahead(): void $parser->match(TokenType::T_SELECT); } + public function testPartialExpressionWithObjectHydratorThrows(): void + { + $this->expectException(HydrationException::class); + $this->expectExceptionMessage('Hydration of entity objects is not allowed when DQL PARTIAL keyword is used.'); + + $parser = $this->createParser(CmsUser::class); + $parser->PartialObjectExpression(); + } + private function createParser(string $dql): Parser { $query = new Query($this->getTestEntityManager()); diff --git a/tests/Tests/ORM/UnitOfWorkTest.php b/tests/Tests/ORM/UnitOfWorkTest.php index 550b1cfe1c8..ff5bab7895e 100644 --- a/tests/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Tests/ORM/UnitOfWorkTest.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Exception\EntityIdentityCollisionException; +use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -22,6 +23,7 @@ use Doctrine\ORM\Mapping\Version; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMInvalidArgumentException; +use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\EntityPersisterMock; @@ -643,6 +645,15 @@ public function testItThrowsWhenApplicationProvidedIdsCollide(): void $this->_unitOfWork->persist($phone2); } + + public function testItThrowsWhenCreateEntityWithSqlWalkerPartialQueryHint(): void + { + $this->expectException(HydrationException::class); + $this->expectExceptionMessage('Hydration of entity objects is not allowed when DQL PARTIAL keyword is used.'); + + $hints = [SqlWalker::HINT_PARTIAL => true]; + $this->_unitOfWork->createEntity(VersionedAssignedIdentifierEntity::class, ['id' => 1], $hints); + } } From 758f0d7605132869c4713dcf487e7adb2b655c0c Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 16 Mar 2024 22:36:21 +0100 Subject: [PATCH 385/475] Remove Query::HINT_FORCE_PARTIAL_LOAD constant, not needed to be reintroduced. --- src/Query.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Query.php b/src/Query.php index 8c44eba8afa..5b0ceb7a97c 100644 --- a/src/Query.php +++ b/src/Query.php @@ -70,14 +70,6 @@ class Query extends AbstractQuery */ public const HINT_REFRESH_ENTITY = 'doctrine.refresh.entity'; - /** - * The forcePartialLoad query hint forces a particular query to return - * partial objects. - * - * @todo Rename: HINT_OPTIMIZE - */ - public const HINT_FORCE_PARTIAL_LOAD = 'doctrine.forcePartialLoad'; - /** * The includeMetaColumns query hint causes meta columns like foreign keys and * discriminator columns to be selected and returned as part of the query result. From 90962f060a39bedc541d199f7196705297b10e2a Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 16 Mar 2024 22:39:38 +0100 Subject: [PATCH 386/475] Use id dynamically in array hydration test. --- tests/Tests/ORM/Functional/QueryTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Tests/ORM/Functional/QueryTest.php b/tests/Tests/ORM/Functional/QueryTest.php index 01d876fbbd1..10e26df023f 100644 --- a/tests/Tests/ORM/Functional/QueryTest.php +++ b/tests/Tests/ORM/Functional/QueryTest.php @@ -138,16 +138,16 @@ public function testJoinPartialArrayHydration(): void $this->assertEquals([ [ - 'id' => 13, + 'id' => $user->id, 'username' => 'gblanco', 'articles' => [ [ - 'id' => 3, + 'id' => $article1->id, 'topic' => 'Doctrine 2', ], [ - 'id' => 4, + 'id' => $article2->id, 'topic' => 'Symfony 2', ], ], From 80278c545eb2679184ef549c1040bb93545c920b Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 16 Mar 2024 23:36:13 +0100 Subject: [PATCH 387/475] Update docs/en/reference/partial-hydration.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégoire Paris --- docs/en/reference/partial-hydration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/partial-hydration.rst b/docs/en/reference/partial-hydration.rst index a2cca3d186a..16879c45c52 100644 --- a/docs/en/reference/partial-hydration.rst +++ b/docs/en/reference/partial-hydration.rst @@ -4,7 +4,7 @@ Partial Hydration .. note:: Creating Partial Objects through DQL was possible in ORM 2, - but is only supported for array hydration as of ORM 3 anymore. + but is only supported for array hydration as of ORM 3. Partial hydration of entities is allowed in the array hydrator, when only a subset of the fields of an entity are loaded from the database From 5820bb8f49f746c3fd4e5d7716a7511fa9858b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 16 Mar 2024 23:34:34 +0100 Subject: [PATCH 388/475] Avoid array access It is deprecated. --- src/UnitOfWork.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 4577ccb6648..48354b8ddab 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2662,13 +2662,13 @@ private function eagerLoadCollections(array $collections, ToManyInverseSideMappi foreach ($found as $targetValue) { $sourceEntity = $targetProperty->getValue($targetValue); - if ($sourceEntity === null && isset($targetClass->associationMappings[$mappedBy]['joinColumns'])) { + if ($sourceEntity === null && isset($targetClass->associationMappings[$mappedBy]->joinColumns)) { // case where the hydration $targetValue itself has not yet fully completed, for example // in case a bi-directional association is being hydrated and deferring eager loading is // not possible due to subclassing. $data = $this->getOriginalEntityData($targetValue); $id = []; - foreach ($targetClass->associationMappings[$mappedBy]['joinColumns'] as $joinColumn) { + foreach ($targetClass->associationMappings[$mappedBy]->joinColumns as $joinColumn) { $id[] = $data[$joinColumn['name']]; } } else { From 8a14eee67a4b841fed50575fc7371afb3753d38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 17 Mar 2024 09:38:54 +0100 Subject: [PATCH 389/475] Avoid another occurrence of ArrayAccess --- src/UnitOfWork.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 48354b8ddab..018c1e788fb 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2669,7 +2669,7 @@ private function eagerLoadCollections(array $collections, ToManyInverseSideMappi $data = $this->getOriginalEntityData($targetValue); $id = []; foreach ($targetClass->associationMappings[$mappedBy]->joinColumns as $joinColumn) { - $id[] = $data[$joinColumn['name']]; + $id[] = $data[$joinColumn->name]; } } else { $id = $this->identifierFlattener->flattenIdentifier($class, $class->getIdentifierValues($sourceEntity)); From e384978e0bd1bdced06755ee190adf7f713dd006 Mon Sep 17 00:00:00 2001 From: Claudio Zizza <859964+SenseException@users.noreply.github.com> Date: Wed, 20 Mar 2024 23:35:25 +0100 Subject: [PATCH 390/475] Remove older versions from the docs (#11383) To reduce Algolia operations and indexes older versions get removed --- .doctrine-project.json | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/.doctrine-project.json b/.doctrine-project.json index e761549298c..0eeb48f5899 100644 --- a/.doctrine-project.json +++ b/.doctrine-project.json @@ -94,42 +94,6 @@ "branchName": "2.10.x", "slug": "2.10", "maintained": false - }, - { - "name": "2.9", - "branchName": "2.9.x", - "slug": "2.9", - "maintained": false - }, - { - "name": "2.8", - "branchName": "2.8.x", - "slug": "2.8", - "maintained": false - }, - { - "name": "2.7", - "branchName": "2.7", - "slug": "2.7", - "maintained": false - }, - { - "name": "2.6", - "branchName": "2.6", - "slug": "2.6", - "maintained": false - }, - { - "name": "2.5", - "branchName": "2.5", - "slug": "2.5", - "maintained": false - }, - { - "name": "2.4", - "branchName": "2.4", - "slug": "2.4", - "maintained": false } ] } From 67ac5a82dab0b76764fedb469202006f3c80b60b Mon Sep 17 00:00:00 2001 From: Valentin Karnauhov Date: Wed, 20 Mar 2024 17:59:34 +0200 Subject: [PATCH 391/475] Fixed proxy initialization for EnumReflectionProperty --- src/Proxy/ProxyFactory.php | 2 +- .../Ticket/GH11386/GH11386EntityCart.php | 55 +++++++++++++ .../Ticket/GH11386/GH11386EntityCustomer.php | 80 +++++++++++++++++++ .../Ticket/GH11386/GH11386EnumType.php | 11 +++ .../Functional/Ticket/GH11386/GH11386Test.php | 39 +++++++++ 5 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EntityCart.php create mode 100644 tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EntityCustomer.php create mode 100644 tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EnumType.php create mode 100644 tests/Tests/ORM/Functional/Ticket/GH11386/GH11386Test.php diff --git a/src/Proxy/ProxyFactory.php b/src/Proxy/ProxyFactory.php index f784cefa651..8dd39ddd868 100644 --- a/src/Proxy/ProxyFactory.php +++ b/src/Proxy/ProxyFactory.php @@ -234,7 +234,7 @@ private function createLazyInitializer(ClassMetadata $classMetadata, EntityPersi $class = $entityPersister->getClassMetadata(); foreach ($class->getReflectionProperties() as $property) { - if (! $property || ! $class->hasField($property->name) && ! $class->hasAssociation($property->name)) { + if (! $property || ! $class->hasField($property->getName()) && ! $class->hasAssociation($property->getName())) { continue; } diff --git a/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EntityCart.php b/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EntityCart.php new file mode 100644 index 00000000000..032171aac52 --- /dev/null +++ b/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EntityCart.php @@ -0,0 +1,55 @@ +id; + } + + public function getAmount(): int|null + { + return $this->amount; + } + + public function setAmount(int $amount): static + { + $this->amount = $amount; + + return $this; + } + + public function getCustomer(): GH11386EntityCustomer|null + { + return $this->customer; + } + + public function setCustomer(GH11386EntityCustomer|null $customer): self + { + $this->customer = $customer; + + return $this; + } +} diff --git a/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EntityCustomer.php b/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EntityCustomer.php new file mode 100644 index 00000000000..3290a6f99bf --- /dev/null +++ b/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EntityCustomer.php @@ -0,0 +1,80 @@ + true])] + private GH11386EnumType|null $type = null; + + #[OneToOne(mappedBy: 'customer')] + private GH11386EntityCart|null $cart = null; + + public function getId(): int|null + { + return $this->id; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getType(): GH11386EnumType|null + { + return $this->type; + } + + public function setType(GH11386EnumType $type): static + { + $this->type = $type; + + return $this; + } + + public function getCart(): GH11386EntityCart|null + { + return $this->cart; + } + + public function setCart(GH11386EntityCart|null $cart): self + { + // unset the owning side of the relation if necessary + if ($cart === null && $this->cart !== null) { + $this->cart->setCustomer(null); + } + + // set the owning side of the relation if necessary + if ($cart !== null && $cart->getCustomer() !== $this) { + $cart->setCustomer($this); + } + + $this->cart = $cart; + + return $this; + } +} diff --git a/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EnumType.php b/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EnumType.php new file mode 100644 index 00000000000..c07da865b95 --- /dev/null +++ b/tests/Tests/ORM/Functional/Ticket/GH11386/GH11386EnumType.php @@ -0,0 +1,11 @@ +createSchemaForModels( + GH11386EntityCart::class, + GH11386EntityCustomer::class, + ); + } + + public function testInitializeClonedProxy(): void + { + $cart = new GH11386EntityCart(); + $cart->setAmount(1000); + + $customer = new GH11386EntityCustomer(); + $customer->setName('John Doe') + ->setType(GH11386EnumType::MALE) + ->setCart($cart); + + $this->_em->persist($cart); + $this->_em->flush(); + $this->_em->clear(); + + $cart = $this->_em->find(GH11386EntityCart::class, 1); + $customer = clone $cart->getCustomer(); + self::assertEquals('John Doe', $customer->getName()); + } +} From 9c560713925ac5859342e6ff370c4c997acf2fd4 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 Mar 2024 12:37:52 +0100 Subject: [PATCH 392/475] Adjust PHPBench mocks --- .../Performance/Mock/NonLoadingPersister.php | 25 ++++++------------- .../Mock/NonProxyLoadingEntityManager.php | 2 +- .../Mock/NonProxyLoadingUnitOfWork.php | 13 ++++++---- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/tests/Performance/Mock/NonLoadingPersister.php b/tests/Performance/Mock/NonLoadingPersister.php index 7058092bf68..bf487978c9f 100644 --- a/tests/Performance/Mock/NonLoadingPersister.php +++ b/tests/Performance/Mock/NonLoadingPersister.php @@ -4,8 +4,7 @@ namespace Doctrine\Performance\Mock; -use Doctrine\DBAL\LockMode; -use Doctrine\ORM\Mapping\AssociationMapping; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; /** @@ -13,22 +12,14 @@ */ class NonLoadingPersister extends BasicEntityPersister { - public function __construct() - { + public function __construct( + ClassMetadata $class, + ) { + $this->class = $class; } - /** - * {@inheritDoc} - */ - public function load( - array $criteria, - object|null $entity = null, - AssociationMapping|null $assoc = null, - array $hints = [], - LockMode|int|null $lockMode = null, - int|null $limit = null, - array|null $orderBy = null, - ): object|null { - return $entity; + public function loadById(array $identifier, object|null $entity = null): object|null + { + return $entity ?? new ($this->class->name)(); } } diff --git a/tests/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Performance/Mock/NonProxyLoadingEntityManager.php index e60e476c408..20f233e0089 100644 --- a/tests/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Performance/Mock/NonProxyLoadingEntityManager.php @@ -57,7 +57,7 @@ public function getClassMetadata(string $className): ClassMetadata public function getUnitOfWork(): UnitOfWork { - return new NonProxyLoadingUnitOfWork(); + return new NonProxyLoadingUnitOfWork($this); } public function getCache(): Cache|null diff --git a/tests/Performance/Mock/NonProxyLoadingUnitOfWork.php b/tests/Performance/Mock/NonProxyLoadingUnitOfWork.php index d9ca05c6879..68884a3f232 100644 --- a/tests/Performance/Mock/NonProxyLoadingUnitOfWork.php +++ b/tests/Performance/Mock/NonProxyLoadingUnitOfWork.php @@ -4,6 +4,7 @@ namespace Doctrine\Performance\Mock; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\UnitOfWork; /** @@ -11,15 +12,17 @@ */ class NonProxyLoadingUnitOfWork extends UnitOfWork { - private NonLoadingPersister $entityPersister; + /** @var array */ + private array $entityPersisters = []; - public function __construct() - { - $this->entityPersister = new NonLoadingPersister(); + public function __construct( + private EntityManagerInterface $entityManager, + ) { } public function getEntityPersister(string $entityName): NonLoadingPersister { - return $this->entityPersister; + return $this->entityPersisters[$entityName] + ??= new NonLoadingPersister($this->entityManager->getClassMetadata($entityName)); } } From 753bc16c0b0535b7493628dfb87244aa43dc5483 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 22 Mar 2024 15:26:43 +0100 Subject: [PATCH 393/475] SchemaValidator: Changing mapping of BIGINT to string|int --- src/Tools/SchemaValidator.php | 29 ++++++- tests/Tests/ORM/Tools/SchemaValidatorTest.php | 81 +++++++++++++++++++ 2 files changed, 107 insertions(+), 3 deletions(-) diff --git a/src/Tools/SchemaValidator.php b/src/Tools/SchemaValidator.php index 6ebe991876c..7b4e6176a41 100644 --- a/src/Tools/SchemaValidator.php +++ b/src/Tools/SchemaValidator.php @@ -39,6 +39,7 @@ use function in_array; use function interface_exists; use function is_a; +use function method_exists; use function sprintf; /** @@ -49,9 +50,9 @@ class SchemaValidator { /** - * It maps built-in Doctrine types to PHP types + * Map built-in Doctrine DBAL 3 types to PHP types */ - private const BUILTIN_TYPES_MAP = [ + private const BUILTIN_TYPES_MAP_DBAL3 = [ AsciiStringType::class => 'string', BigIntType::class => 'string', BooleanType::class => 'bool', @@ -66,6 +67,24 @@ class SchemaValidator TextType::class => 'string', ]; + /** + * Map built-in Doctrine DBAL 4+ types to PHP types + */ + private const BUILTIN_TYPES_MAP = [ + AsciiStringType::class => 'string', + BigIntType::class => 'string|int', + BooleanType::class => 'bool', + DecimalType::class => 'string', + FloatType::class => 'float', + GuidType::class => 'string', + IntegerType::class => 'int', + JsonType::class => 'array', + SimpleArrayType::class => 'array', + SmallIntType::class => 'int', + StringType::class => 'string', + TextType::class => 'string', + ]; + public function __construct( private readonly EntityManagerInterface $em, private readonly bool $validatePropertyTypes = true, @@ -436,6 +455,10 @@ private function findBuiltInType(Type $type): string|null { $typeName = $type::class; - return self::BUILTIN_TYPES_MAP[$typeName] ?? null; + if (method_exists(BigIntType::class, 'getName')) { // DBAL 3 + return self::BUILTIN_TYPES_MAP_DBAL3[$typeName] ?? null; + } else { // DBAL 4+ + return self::BUILTIN_TYPES_MAP[$typeName] ?? null; + } } } diff --git a/tests/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Tests/ORM/Tools/SchemaValidatorTest.php index b7141b0d99d..a153e4e77b6 100644 --- a/tests/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Tests/ORM/Tools/SchemaValidatorTest.php @@ -6,6 +6,8 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; +use Doctrine\DBAL\Types\BigIntType; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorMap; @@ -30,6 +32,8 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use function method_exists; + class SchemaValidatorTest extends OrmTestCase { private EntityManagerInterface|null $em = null; @@ -228,6 +232,47 @@ public function testInvalidAssociationTowardsMappedSuperclass(): void $ce, ); } + + public function testBigintMappedToStringInt(): void + { + $class = $this->em->getClassMetadata(BigintMappedToStringInt::class); + $ce = $this->validator->validateClass($class); + + $this->assertEquals([], $ce); // Same for DBAL 3 and 4+ + } + + public function testBigintMappedToInt(): void + { + $class = $this->em->getClassMetadata(BigintMappedToInt::class); + $ce = $this->validator->validateClass($class); + + if (method_exists(BigIntType::class, 'getName')) { // DBAL 3 + $this->assertEquals( + ["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToInt#bigint' has the property type 'int' that differs from the metadata field type 'string' returned by the 'bigint' DBAL type."], + $ce, + ); + } else { // DBAL 4+ + $this->assertEquals( + ["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToInt#bigint' has the property type 'int' that differs from the metadata field type 'string|int' returned by the 'bigint' DBAL type."], + $ce, + ); + } + } + + public function testBigintMappedToString(): void + { + $class = $this->em->getClassMetadata(BigintMappedToString::class); + $ce = $this->validator->validateClass($class); + + if (method_exists(BigIntType::class, 'getName')) { // DBAL 3 + $this->assertEquals([], $ce); + } else { // DBAL 4+ + $this->assertEquals( + ["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToString#bigint' has the property type 'string' that differs from the metadata field type 'string|int' returned by the 'bigint' DBAL type."], + $ce, + ); + } + } } #[MappedSuperclass] @@ -547,3 +592,39 @@ class InvalidMappedSuperClass #[ManyToMany(targetEntity: 'InvalidMappedSuperClass', mappedBy: 'invalid')] private $selfWhatever; } + +#[Entity] +class BigintMappedToStringInt +{ + #[Id] + #[Column] + #[GeneratedValue] + private int $id; + + #[Column(type: Types::BIGINT)] + private string|int $bigint; +} + +#[Entity] +class BigintMappedToInt +{ + #[Id] + #[Column] + #[GeneratedValue] + private int $id; + + #[Column(type: Types::BIGINT)] + private int $bigint; +} + +#[Entity] +class BigintMappedToString +{ + #[Id] + #[Column] + #[GeneratedValue] + private int $id; + + #[Column(type: Types::BIGINT)] + private string $bigint; +} From 146482722072acb52a9a3f32e3020787efffd5ac Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 3 Apr 2024 19:28:24 +0200 Subject: [PATCH 394/475] Fix fromMappingArray definition --- phpstan-dbal3.neon | 4 --- phpstan.neon | 4 --- psalm-baseline.xml | 4 +++ src/Mapping/AssociationMapping.php | 17 +++++++++-- src/Mapping/ClassMetadata.php | 2 +- src/Mapping/EmbeddedClassMapping.php | 10 ++++--- src/Mapping/FieldMapping.php | 31 ++++++++++++++++++-- src/Mapping/JoinColumnMapping.php | 12 +++++++- src/Mapping/JoinTableMapping.php | 4 +-- src/Mapping/ManyToManyOwningSideMapping.php | 14 ++++++++- src/Mapping/OneToManyAssociationMapping.php | 28 ++++++++++++++++-- src/Mapping/ToOneInverseSideMapping.php | 15 +++++++++- src/Mapping/ToOneOwningSideMapping.php | 32 +++++++++++++++++++-- 13 files changed, 151 insertions(+), 26 deletions(-) diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index a223cd4b792..b9ef942c965 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -20,10 +20,6 @@ parameters: message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' path: src/Persisters/Entity/BasicEntityPersister.php - - - message: '~^Unreachable statement \- code above always terminates\.$~' - path: src/Mapping/AssociationMapping.php - - '~^Class Doctrine\\DBAL\\Platforms\\SQLitePlatform not found\.$~' # To be removed in 4.0 diff --git a/phpstan.neon b/phpstan.neon index 4ea0a3630a2..d90ec9fe41f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -20,10 +20,6 @@ parameters: message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' path: src/Persisters/Entity/BasicEntityPersister.php - - - message: '~^Unreachable statement \- code above always terminates\.$~' - path: src/Mapping/AssociationMapping.php - # Compatibility with DBAL 3 # See https://github.com/doctrine/dbal/pull/3480 - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4faaf8ce91d..a54dfbd0954 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -298,6 +298,10 @@ columnNames]]> + + + + diff --git a/src/Mapping/AssociationMapping.php b/src/Mapping/AssociationMapping.php index 0253413e8d8..ce7bdb40ab4 100644 --- a/src/Mapping/AssociationMapping.php +++ b/src/Mapping/AssociationMapping.php @@ -27,7 +27,7 @@ abstract class AssociationMapping implements ArrayAccess /** * The fetching strategy to use for the association, usually defaults to FETCH_LAZY. * - * @var ClassMetadata::FETCH_* + * @var ClassMetadata::FETCH_*|null */ public int|null $fetch = null; @@ -96,13 +96,26 @@ final public function __construct( } /** + * @param mixed[] $mappingArray * @psalm-param array{ * fieldName: string, * sourceEntity: class-string, * targetEntity: class-string, + * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, + * fetch?: ClassMetadata::FETCH_*|null, + * inherited?: class-string|null, + * declared?: class-string|null, + * cache?: array|null, + * id?: bool|null, + * isOnDeleteCascade?: bool|null, + * originalClass?: class-string|null, + * originalField?: string|null, + * orphanRemoval?: bool, + * unique?: bool|null, * joinTable?: mixed[]|null, * type?: int, - * isOwningSide: bool, ...} $mappingArray + * isOwningSide: bool, + * } $mappingArray */ public static function fromMappingArray(array $mappingArray): static { diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index 85079ed049d..f58e00e72fe 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -1152,7 +1152,7 @@ private function validateAndCompleteTypedAssociationMapping(array $mapping): arr * fieldName?: string, * columnName?: string, * id?: bool, - * generated?: int, + * generated?: self::GENERATED_*, * enumType?: class-string, * } $mapping The field mapping to validate & complete. * diff --git a/src/Mapping/EmbeddedClassMapping.php b/src/Mapping/EmbeddedClassMapping.php index c1d464568a8..8fd02c9232c 100644 --- a/src/Mapping/EmbeddedClassMapping.php +++ b/src/Mapping/EmbeddedClassMapping.php @@ -49,10 +49,12 @@ public function __construct(public string $class) /** * @psalm-param array{ - * class: class-string, - * columnPrefix?: false|string|null, - * declaredField?: string|null, - * originalField?: string|null + * class: class-string, + * columnPrefix?: false|string|null, + * declaredField?: string|null, + * originalField?: string|null, + * inherited?: class-string|null, + * declared?: class-string|null, * } $mappingArray */ public static function fromMappingArray(array $mappingArray): self diff --git a/src/Mapping/FieldMapping.php b/src/Mapping/FieldMapping.php index 3e05eba9ec2..4c09196fd8b 100644 --- a/src/Mapping/FieldMapping.php +++ b/src/Mapping/FieldMapping.php @@ -26,7 +26,7 @@ final class FieldMapping implements ArrayAccess public bool|null $notInsertable = null; public bool|null $notUpdatable = null; public string|null $columnDefinition = null; - /** @psalm-var ClassMetadata::GENERATED_* */ + /** @psalm-var ClassMetadata::GENERATED_*|null */ public int|null $generated = null; /** @var class-string|null */ public string|null $enumType = null; @@ -83,7 +83,34 @@ public function __construct( ) { } - /** @param array{type: string, fieldName: string, columnName: string} $mappingArray */ + /** + * @param array $mappingArray + * @psalm-param array{ + * type: string, + * fieldName: string, + * columnName: string, + * length?: int|null, + * id?: bool|null, + * nullable?: bool|null, + * notInsertable?: bool|null, + * notUpdatable?: bool|null, + * columnDefinition?: string|null, + * generated?: ClassMetadata::GENERATED_*|null, + * enumType?: string|null, + * precision?: int|null, + * scale?: int|null, + * unique?: bool|null, + * inherited?: string|null, + * originalClass?: string|null, + * originalField?: string|null, + * quoted?: bool|null, + * declared?: string|null, + * declaredField?: string|null, + * options?: array|null, + * version?: bool|null, + * default?: string|int|null, + * } $mappingArray + */ public static function fromMappingArray(array $mappingArray): self { $mapping = new self( diff --git a/src/Mapping/JoinColumnMapping.php b/src/Mapping/JoinColumnMapping.php index bc469bb6494..172c25699c9 100644 --- a/src/Mapping/JoinColumnMapping.php +++ b/src/Mapping/JoinColumnMapping.php @@ -31,7 +31,17 @@ public function __construct( /** * @param array $mappingArray - * @psalm-param array{name: string, referencedColumnName: string, ...} $mappingArray + * @psalm-param array{ + * name: string, + * referencedColumnName: string, + * unique?: bool|null, + * quoted?: bool|null, + * fieldName?: string|null, + * onDelete?: string|null, + * columnDefinition?: string|null, + * nullable?: bool|null, + * options?: array|null, + * } $mappingArray */ public static function fromMappingArray(array $mappingArray): self { diff --git a/src/Mapping/JoinTableMapping.php b/src/Mapping/JoinTableMapping.php index df46f9722a9..c8b49681e51 100644 --- a/src/Mapping/JoinTableMapping.php +++ b/src/Mapping/JoinTableMapping.php @@ -35,10 +35,10 @@ public function __construct(public string $name) * @param mixed[] $mappingArray * @psalm-param array{ * name: string, - * quoted?: bool, + * quoted?: bool|null, * joinColumns?: mixed[], * inverseJoinColumns?: mixed[], - * schema?: string, + * schema?: string|null, * options?: array * } $mappingArray */ diff --git a/src/Mapping/ManyToManyOwningSideMapping.php b/src/Mapping/ManyToManyOwningSideMapping.php index c7a0eb4ad58..b09d56c7e30 100644 --- a/src/Mapping/ManyToManyOwningSideMapping.php +++ b/src/Mapping/ManyToManyOwningSideMapping.php @@ -41,9 +41,21 @@ public function toArray(): array * fieldName: string, * sourceEntity: class-string, * targetEntity: class-string, + * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, + * fetch?: ClassMetadata::FETCH_*|null, + * inherited?: class-string|null, + * declared?: class-string|null, + * cache?: array|null, + * id?: bool|null, + * isOnDeleteCascade?: bool|null, + * originalClass?: class-string|null, + * originalField?: string|null, + * orphanRemoval?: bool, + * unique?: bool|null, * joinTable?: mixed[]|null, * type?: int, - * isOwningSide: bool, ...} $mappingArray + * isOwningSide: bool, + * } $mappingArray */ public static function fromMappingArrayAndNamingStrategy(array $mappingArray, NamingStrategy $namingStrategy): self { diff --git a/src/Mapping/OneToManyAssociationMapping.php b/src/Mapping/OneToManyAssociationMapping.php index 804061a1a1d..786e9812774 100644 --- a/src/Mapping/OneToManyAssociationMapping.php +++ b/src/Mapping/OneToManyAssociationMapping.php @@ -12,9 +12,21 @@ final class OneToManyAssociationMapping extends ToManyInverseSideMapping * fieldName: string, * sourceEntity: class-string, * targetEntity: class-string, + * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, + * fetch?: ClassMetadata::FETCH_*|null, + * inherited?: class-string|null, + * declared?: class-string|null, + * cache?: array|null, + * id?: bool|null, + * isOnDeleteCascade?: bool|null, + * originalClass?: class-string|null, + * originalField?: string|null, + * orphanRemoval?: bool, + * unique?: bool|null, * joinTable?: mixed[]|null, * type?: int, - * isOwningSide: bool, ...} $mappingArray + * isOwningSide: bool, + * } $mappingArray */ public static function fromMappingArray(array $mappingArray): static { @@ -33,9 +45,21 @@ public static function fromMappingArray(array $mappingArray): static * fieldName: string, * sourceEntity: class-string, * targetEntity: class-string, + * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, + * fetch?: ClassMetadata::FETCH_*|null, + * inherited?: class-string|null, + * declared?: class-string|null, + * cache?: array|null, + * id?: bool|null, + * isOnDeleteCascade?: bool|null, + * originalClass?: class-string|null, + * originalField?: string|null, + * orphanRemoval?: bool, + * unique?: bool|null, * joinTable?: mixed[]|null, * type?: int, - * isOwningSide: bool, ...} $mappingArray + * isOwningSide: bool, + * } $mappingArray */ public static function fromMappingArrayAndName(array $mappingArray, string $name): static { diff --git a/src/Mapping/ToOneInverseSideMapping.php b/src/Mapping/ToOneInverseSideMapping.php index 232952be438..5be89e6db53 100644 --- a/src/Mapping/ToOneInverseSideMapping.php +++ b/src/Mapping/ToOneInverseSideMapping.php @@ -13,8 +13,21 @@ abstract class ToOneInverseSideMapping extends InverseSideMapping * fieldName: string, * sourceEntity: class-string, * targetEntity: class-string, + * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, + * fetch?: ClassMetadata::FETCH_*|null, + * inherited?: class-string|null, + * declared?: class-string|null, + * cache?: array|null, + * id?: bool|null, + * isOnDeleteCascade?: bool|null, + * originalClass?: class-string|null, + * originalField?: string|null, + * orphanRemoval?: bool, + * unique?: bool|null, + * joinTable?: mixed[]|null, + * type?: int, * isOwningSide: bool, - * } $mappingArray + * } $mappingArray */ public static function fromMappingArrayAndName( array $mappingArray, diff --git a/src/Mapping/ToOneOwningSideMapping.php b/src/Mapping/ToOneOwningSideMapping.php index d28074bb03e..cb85afbde10 100644 --- a/src/Mapping/ToOneOwningSideMapping.php +++ b/src/Mapping/ToOneOwningSideMapping.php @@ -31,8 +31,22 @@ abstract class ToOneOwningSideMapping extends OwningSideMapping implements ToOne * fieldName: string, * sourceEntity: class-string, * targetEntity: class-string, + * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, + * fetch?: ClassMetadata::FETCH_*|null, + * inherited?: class-string|null, + * declared?: class-string|null, + * cache?: array|null, + * id?: bool|null, + * isOnDeleteCascade?: bool|null, + * originalClass?: class-string|null, + * originalField?: string|null, + * orphanRemoval?: bool, + * unique?: bool|null, + * joinTable?: mixed[]|null, + * type?: int, + * isOwningSide: bool, * joinColumns?: mixed[]|null, - * isOwningSide: bool, ...} $mappingArray + * } $mappingArray */ public static function fromMappingArray(array $mappingArray): static { @@ -64,8 +78,22 @@ public static function fromMappingArray(array $mappingArray): static * fieldName: string, * sourceEntity: class-string, * targetEntity: class-string, + * cascade?: list<'persist'|'remove'|'detach'|'refresh'|'all'>, + * fetch?: ClassMetadata::FETCH_*|null, + * inherited?: class-string|null, + * declared?: class-string|null, + * cache?: array|null, + * id?: bool|null, + * isOnDeleteCascade?: bool|null, + * originalClass?: class-string|null, + * originalField?: string|null, + * orphanRemoval?: bool, + * unique?: bool|null, + * joinTable?: mixed[]|null, + * type?: int, + * isOwningSide: bool, * joinColumns?: mixed[]|null, - * isOwningSide: bool, ...} $mappingArray + * } $mappingArray */ public static function fromMappingArrayAndName( array $mappingArray, From 010b1e0886929e0da207aa44cd823c23270a3aab Mon Sep 17 00:00:00 2001 From: Nayte Date: Mon, 15 Apr 2024 09:38:43 +0200 Subject: [PATCH 395/475] docs: update PHP version in doc --- docs/en/reference/architecture.rst | 2 +- docs/en/tutorials/getting-started.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/reference/architecture.rst b/docs/en/reference/architecture.rst index 00d1c419734..7ba2ef774d7 100644 --- a/docs/en/reference/architecture.rst +++ b/docs/en/reference/architecture.rst @@ -18,7 +18,7 @@ well. Requirements ------------ -Doctrine ORM requires a minimum of PHP 7.1. For greatly improved +Doctrine ORM requires a minimum of PHP 8.1. For greatly improved performance it is also recommended that you use APC with PHP. Doctrine ORM Packages diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index 5e405618bf4..3550daecf78 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -27,7 +27,7 @@ What is Doctrine? ----------------- Doctrine ORM is an `object-relational mapper (ORM) `_ -for PHP 7.1+ that provides transparent persistence for PHP objects. It uses the Data Mapper +for PHP that provides transparent persistence for PHP objects. It uses the Data Mapper pattern at the heart, aiming for a complete separation of your domain/business logic from the persistence in a relational database management system. From 9c22814cfa5b9e45a81d318770e2d712470c4770 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 15 Apr 2024 16:03:33 +0200 Subject: [PATCH 396/475] Revert "Merge pull request #11399 from ThomasLandauer/issue-11377" (#11415) This reverts commit cbb6c897de4dd4e215c7005505b381c5927e5f4a, reversing changes made to 9c560713925ac5859342e6ff370c4c997acf2fd4. --- src/Tools/SchemaValidator.php | 29 +------ tests/Tests/ORM/Tools/SchemaValidatorTest.php | 81 ------------------- 2 files changed, 3 insertions(+), 107 deletions(-) diff --git a/src/Tools/SchemaValidator.php b/src/Tools/SchemaValidator.php index 7b4e6176a41..6ebe991876c 100644 --- a/src/Tools/SchemaValidator.php +++ b/src/Tools/SchemaValidator.php @@ -39,7 +39,6 @@ use function in_array; use function interface_exists; use function is_a; -use function method_exists; use function sprintf; /** @@ -50,29 +49,11 @@ class SchemaValidator { /** - * Map built-in Doctrine DBAL 3 types to PHP types - */ - private const BUILTIN_TYPES_MAP_DBAL3 = [ - AsciiStringType::class => 'string', - BigIntType::class => 'string', - BooleanType::class => 'bool', - DecimalType::class => 'string', - FloatType::class => 'float', - GuidType::class => 'string', - IntegerType::class => 'int', - JsonType::class => 'array', - SimpleArrayType::class => 'array', - SmallIntType::class => 'int', - StringType::class => 'string', - TextType::class => 'string', - ]; - - /** - * Map built-in Doctrine DBAL 4+ types to PHP types + * It maps built-in Doctrine types to PHP types */ private const BUILTIN_TYPES_MAP = [ AsciiStringType::class => 'string', - BigIntType::class => 'string|int', + BigIntType::class => 'string', BooleanType::class => 'bool', DecimalType::class => 'string', FloatType::class => 'float', @@ -455,10 +436,6 @@ private function findBuiltInType(Type $type): string|null { $typeName = $type::class; - if (method_exists(BigIntType::class, 'getName')) { // DBAL 3 - return self::BUILTIN_TYPES_MAP_DBAL3[$typeName] ?? null; - } else { // DBAL 4+ - return self::BUILTIN_TYPES_MAP[$typeName] ?? null; - } + return self::BUILTIN_TYPES_MAP[$typeName] ?? null; } } diff --git a/tests/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Tests/ORM/Tools/SchemaValidatorTest.php index a153e4e77b6..b7141b0d99d 100644 --- a/tests/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Tests/ORM/Tools/SchemaValidatorTest.php @@ -6,8 +6,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\DBAL\Types\BigIntType; -use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorMap; @@ -32,8 +30,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; -use function method_exists; - class SchemaValidatorTest extends OrmTestCase { private EntityManagerInterface|null $em = null; @@ -232,47 +228,6 @@ public function testInvalidAssociationTowardsMappedSuperclass(): void $ce, ); } - - public function testBigintMappedToStringInt(): void - { - $class = $this->em->getClassMetadata(BigintMappedToStringInt::class); - $ce = $this->validator->validateClass($class); - - $this->assertEquals([], $ce); // Same for DBAL 3 and 4+ - } - - public function testBigintMappedToInt(): void - { - $class = $this->em->getClassMetadata(BigintMappedToInt::class); - $ce = $this->validator->validateClass($class); - - if (method_exists(BigIntType::class, 'getName')) { // DBAL 3 - $this->assertEquals( - ["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToInt#bigint' has the property type 'int' that differs from the metadata field type 'string' returned by the 'bigint' DBAL type."], - $ce, - ); - } else { // DBAL 4+ - $this->assertEquals( - ["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToInt#bigint' has the property type 'int' that differs from the metadata field type 'string|int' returned by the 'bigint' DBAL type."], - $ce, - ); - } - } - - public function testBigintMappedToString(): void - { - $class = $this->em->getClassMetadata(BigintMappedToString::class); - $ce = $this->validator->validateClass($class); - - if (method_exists(BigIntType::class, 'getName')) { // DBAL 3 - $this->assertEquals([], $ce); - } else { // DBAL 4+ - $this->assertEquals( - ["The field 'Doctrine\Tests\ORM\Tools\BigintMappedToString#bigint' has the property type 'string' that differs from the metadata field type 'string|int' returned by the 'bigint' DBAL type."], - $ce, - ); - } - } } #[MappedSuperclass] @@ -592,39 +547,3 @@ class InvalidMappedSuperClass #[ManyToMany(targetEntity: 'InvalidMappedSuperClass', mappedBy: 'invalid')] private $selfWhatever; } - -#[Entity] -class BigintMappedToStringInt -{ - #[Id] - #[Column] - #[GeneratedValue] - private int $id; - - #[Column(type: Types::BIGINT)] - private string|int $bigint; -} - -#[Entity] -class BigintMappedToInt -{ - #[Id] - #[Column] - #[GeneratedValue] - private int $id; - - #[Column(type: Types::BIGINT)] - private int $bigint; -} - -#[Entity] -class BigintMappedToString -{ - #[Id] - #[Column] - #[GeneratedValue] - private int $id; - - #[Column(type: Types::BIGINT)] - private string $bigint; -} From 0e26e3ed503e773b05e445557b80508538d9b215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 5 May 2024 22:39:45 +0200 Subject: [PATCH 397/475] Setup Dependabot Targeting 2.19.x, since we want the updates to bubble up. Since Dependabot has had no effect on doctrine/dbal yet, I suppose that means that "dependabot.yml" must be present on the default branch. --- .github/dependabot.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..c704d7d05b4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "CI" + target-branch: "2.19.x" From 029ca611f0d06c9eccacc2874d3b138c005fb2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 5 May 2024 23:38:41 +0200 Subject: [PATCH 398/475] Use ramsey/composer-install in PHPBench workflow (#11444) It will handle caching for us. --- .github/workflows/phpbench.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/phpbench.yml b/.github/workflows/phpbench.yml index d98e7fa2158..2a09ec3b18f 100644 --- a/.github/workflows/phpbench.yml +++ b/.github/workflows/phpbench.yml @@ -47,15 +47,8 @@ jobs: coverage: "pcov" ini-values: "zend.assertions=1, apc.enable_cli=1" - - name: "Cache dependencies installed with composer" - uses: "actions/cache@v3" - with: - path: "~/.composer/cache" - key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: "php-${{ matrix.php-version }}-composer-locked-" - - - name: "Install dependencies with composer" - run: "composer update --no-interaction --no-progress" + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v3" - name: "Run PHPBench" run: "vendor/bin/phpbench run --report=default" From e83d8a80baa917a2018efa93f5fc70f4529c8a7e Mon Sep 17 00:00:00 2001 From: Alexey Prohorov Date: Wed, 15 May 2024 10:42:04 +0300 Subject: [PATCH 399/475] Using an integer as discriminator value with ORM v3 This fixes a bug that occurred when configuring integers as discriminator values. Doctrine throws a type error whenever the application generates queries. --- src/Query/SqlWalker.php | 9 +- .../ORM/Functional/Ticket/GH11341Test.php | 131 ++++++++++++++++++ 2 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 tests/Tests/ORM/Functional/Ticket/GH11341Test.php diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index 018c2455e49..7fdc9a6f9c1 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -30,6 +30,7 @@ use function implode; use function is_array; use function is_float; +use function is_int; use function is_numeric; use function is_string; use function preg_match; @@ -384,7 +385,9 @@ private function generateDiscriminatorColumnConditionSQL(array $dqlAliases): str $values = []; if ($class->discriminatorValue !== null) { // discriminators can be 0 - $values[] = $conn->quote($class->discriminatorValue); + $values[] = $class->getDiscriminatorColumn()->type === 'integer' && is_int($class->discriminatorValue) + ? $class->discriminatorValue + : $conn->quote((string) $class->discriminatorValue); } foreach ($class->subClasses as $subclassName) { @@ -396,7 +399,9 @@ private function generateDiscriminatorColumnConditionSQL(array $dqlAliases): str continue; } - $values[] = $conn->quote((string) $subclassMetadata->discriminatorValue); + $values[] = $subclassMetadata->getDiscriminatorColumn()->type === 'integer' && is_int($subclassMetadata->discriminatorValue) + ? $subclassMetadata->discriminatorValue + : $conn->quote((string) $subclassMetadata->discriminatorValue); } if ($values !== []) { diff --git a/tests/Tests/ORM/Functional/Ticket/GH11341Test.php b/tests/Tests/ORM/Functional/Ticket/GH11341Test.php new file mode 100644 index 00000000000..16853418ccf --- /dev/null +++ b/tests/Tests/ORM/Functional/Ticket/GH11341Test.php @@ -0,0 +1,131 @@ +setUpEntitySchema([ + IntegerBaseClass::class, + IntegerFooEntity::class, + IntegerBarEntity::class, + StringAsIntBaseClass::class, + StringAsIntFooEntity::class, + StringAsIntBarEntity::class, + StringBaseClass::class, + StringFooEntity::class, + StringBarEntity::class, + ]); + } + + public static function dqlStatements(): Generator + { + yield ['SELECT e FROM ' . IntegerBaseClass::class . ' e', '/WHERE [a-z]0_.type IN \(1, 2\)$/']; + yield ['SELECT e FROM ' . IntegerFooEntity::class . ' e', '/WHERE [a-z]0_.type IN \(1\)$/']; + yield ['SELECT e FROM ' . IntegerBarEntity::class . ' e', '/WHERE [a-z]0_.type IN \(2\)$/']; + yield ['SELECT e FROM ' . StringAsIntBaseClass::class . ' e', '/WHERE [a-z]0_.type IN \(\'1\', \'2\'\)$/']; + yield ['SELECT e FROM ' . StringAsIntFooEntity::class . ' e', '/WHERE [a-z]0_.type IN \(\'1\'\)$/']; + yield ['SELECT e FROM ' . StringAsIntBarEntity::class . ' e', '/WHERE [a-z]0_.type IN \(\'2\'\)$/']; + yield ['SELECT e FROM ' . StringBaseClass::class . ' e', '/WHERE [a-z]0_.type IN \(\'1\', \'2\'\)$/']; + yield ['SELECT e FROM ' . StringFooEntity::class . ' e', '/WHERE [a-z]0_.type IN \(\'1\'\)$/']; + yield ['SELECT e FROM ' . StringBarEntity::class . ' e', '/WHERE [a-z]0_.type IN \(\'2\'\)$/']; + } + + #[DataProvider('dqlStatements')] + public function testDiscriminatorValue(string $dql, string $expectedDiscriminatorValues): void + { + $query = $this->_em->createQuery($dql); + $sql = $query->getSQL(); + + self::assertMatchesRegularExpression($expectedDiscriminatorValues, $sql); + } +} + +#[ORM\Entity] +#[ORM\Table(name: 'integer_discriminator')] +#[ORM\InheritanceType('SINGLE_TABLE')] +#[ORM\DiscriminatorColumn(name: 'type', type: 'integer')] +#[ORM\DiscriminatorMap([ + 1 => IntegerFooEntity::class, + 2 => IntegerBarEntity::class, +])] +class IntegerBaseClass +{ + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'IDENTITY')] + #[ORM\Column(type: 'integer')] + private int|null $id = null; +} + +#[ORM\Entity] +class IntegerFooEntity extends IntegerBaseClass +{ +} + +#[ORM\Entity] +class IntegerBarEntity extends IntegerBaseClass +{ +} + +#[ORM\Entity] +#[ORM\Table(name: 'string_as_int_discriminator')] +#[ORM\InheritanceType('SINGLE_TABLE')] +#[ORM\DiscriminatorColumn(name: 'type', type: 'string')] +#[ORM\DiscriminatorMap([ + 1 => StringAsIntFooEntity::class, + 2 => StringAsIntBarEntity::class, +])] +class StringAsIntBaseClass +{ + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'IDENTITY')] + #[ORM\Column(type: 'integer')] + private int|null $id = null; +} + +#[ORM\Entity] +class StringAsIntFooEntity extends StringAsIntBaseClass +{ +} + +#[ORM\Entity] +class StringAsIntBarEntity extends StringAsIntBaseClass +{ +} + + +#[ORM\Entity] +#[ORM\Table(name: 'string_discriminator')] +#[ORM\InheritanceType('SINGLE_TABLE')] +#[ORM\DiscriminatorColumn(name: 'type', type: 'string')] +#[ORM\DiscriminatorMap([ + '1' => StringFooEntity::class, + '2' => StringBarEntity::class, +])] +class StringBaseClass +{ + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'IDENTITY')] + #[ORM\Column(type: 'integer')] + private int|null $id = null; +} + +#[ORM\Entity] +class StringFooEntity extends StringBaseClass +{ +} + +#[ORM\Entity] +class StringBarEntity extends StringBaseClass +{ +} From 2b04cc2e3f7a1ca8a2e8fa4701c3b3d9b5cfc942 Mon Sep 17 00:00:00 2001 From: Alexey Prohorov Date: Thu, 16 May 2024 11:53:29 +0300 Subject: [PATCH 400/475] Using an integer as discriminator value with ORM v3 This fixes a bug that occurred when configuring integers as discriminator values and using DQL instanceOf function in the queries. Doctrine throws a type error whenever the application generates these queries. --- src/Query/SqlWalker.php | 6 +++-- .../ORM/Functional/Ticket/GH11341Test.php | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index 7fdc9a6f9c1..004d29e773c 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -2251,8 +2251,10 @@ private function getChildDiscriminatorsFromClassMetadata( $discriminators += HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($metadata, $this->em); } - foreach (array_keys($discriminators) as $dis) { - $sqlParameterList[] = $this->conn->quote($dis); + foreach (array_keys($discriminators) as $discriminatorValue) { + $sqlParameterList[] = $rootClass->getDiscriminatorColumn()->type === 'integer' && is_int($discriminatorValue) + ? $discriminatorValue + : $this->conn->quote((string) $discriminatorValue); } return '(' . implode(', ', $sqlParameterList) . ')'; diff --git a/tests/Tests/ORM/Functional/Ticket/GH11341Test.php b/tests/Tests/ORM/Functional/Ticket/GH11341Test.php index 16853418ccf..5c35dfe86c3 100644 --- a/tests/Tests/ORM/Functional/Ticket/GH11341Test.php +++ b/tests/Tests/ORM/Functional/Ticket/GH11341Test.php @@ -49,6 +49,32 @@ public function testDiscriminatorValue(string $dql, string $expectedDiscriminato self::assertMatchesRegularExpression($expectedDiscriminatorValues, $sql); } + + public static function dqlStatementsForInstanceOf(): Generator + { + yield [IntegerBaseClass::class, IntegerFooEntity::class]; + yield [StringBaseClass::class, StringFooEntity::class]; + yield [StringAsIntBaseClass::class, StringAsIntFooEntity::class]; + } + + /** + * @psalm-param class-string $baseClass + * @psalm-param class-string $inheritedClass + */ + #[DataProvider('dqlStatementsForInstanceOf')] + public function testInstanceOf(string $baseClass, string $inheritedClass): void + { + $this->_em->persist(new $inheritedClass()); + $this->_em->flush(); + + $dql = 'SELECT p FROM ' . $baseClass . ' p WHERE p INSTANCE OF ' . $baseClass; + + $query = $this->_em->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(1, $result); + self::assertContainsOnlyInstancesOf($baseClass, $result); + } } #[ORM\Entity] From f1246d57c2509886152cc715ba5e913beb1566be Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 21 May 2024 12:30:01 +0200 Subject: [PATCH 401/475] Fix return type of Query::getLockMode() (#11462) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … for DBAL 4 --- src/Query.php | 5 +++-- tests/Tests/ORM/Query/QueryTest.php | 30 +++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Query.php b/src/Query.php index 5b0ceb7a97c..a869316d3e7 100644 --- a/src/Query.php +++ b/src/Query.php @@ -635,9 +635,10 @@ public function setLockMode(LockMode|int $lockMode): self /** * Get the current lock mode for this query. * - * @return int|null The current lock mode of this query or NULL if no specific lock mode is set. + * @return LockMode|int|null The current lock mode of this query or NULL if no specific lock mode is set. + * @psalm-return LockMode::*|null */ - public function getLockMode(): int|null + public function getLockMode(): LockMode|int|null { $lockMode = $this->getHint(self::HINT_LOCK_MODE); diff --git a/tests/Tests/ORM/Query/QueryTest.php b/tests/Tests/ORM/Query/QueryTest.php index 0336c3da6c8..961aafd32ed 100644 --- a/tests/Tests/ORM/Query/QueryTest.php +++ b/tests/Tests/ORM/Query/QueryTest.php @@ -12,9 +12,12 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Result; +use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Types; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Query; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\UnitOfWork; @@ -39,8 +42,7 @@ class QueryTest extends OrmTestCase { - /** @var EntityManagerMock */ - protected $entityManager; + private EntityManagerMock $entityManager; protected function setUp(): void { @@ -80,6 +82,30 @@ public function testSetParameters(): void self::assertEquals($parameters, $query->getParameters()); } + /** @psalm-param LockMode::* $lockMode */ + #[DataProvider('provideLockModes')] + public function testSetLockMode(LockMode|int $lockMode): void + { + $query = $this->entityManager->wrapInTransaction(static function (EntityManagerInterface $em) use ($lockMode): Query { + $query = $em->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1'); + $query->setLockMode($lockMode); + + return $query; + }); + + self::assertSame($lockMode, $query->getLockMode()); + self::assertSame($lockMode, $query->getHint(Query::HINT_LOCK_MODE)); + } + + /** @psalm-return list */ + public static function provideLockModes(): array + { + return [ + [LockMode::PESSIMISTIC_READ], + [LockMode::PESSIMISTIC_WRITE], + ]; + } + public function testFree(): void { $query = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1'); From 11270425e5f00f30faf8d54a09d56b8d79bf41e9 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 21 May 2024 12:30:56 +0200 Subject: [PATCH 402/475] Fix failed merge (#11464) --- src/UnitOfWork.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index d1659de272b..4ec0906843b 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2653,7 +2653,7 @@ private function eagerLoadCollections(array $collections, ToManyInverseSideMappi $entities[] = $collection->getOwner(); } - $found = $this->getEntityPersister($targetEntity)->loadAll([$mappedBy => $entities], $mapping['orderBy'] ?? null); + $found = $this->getEntityPersister($targetEntity)->loadAll([$mappedBy => $entities], $mapping->orderBy); $targetClass = $this->em->getClassMetadata($targetEntity); $targetProperty = $targetClass->getReflectionProperty($mappedBy); From ae659fe650ca86acecdc265018490b4e1821aa30 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 22 May 2024 10:48:46 +0200 Subject: [PATCH 403/475] Deprecate SequenceGenerator implementing Serializable (#11468) --- UPGRADE.md | 10 ++++++++++ src/Id/SequenceGenerator.php | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index d80970a7056..14dfc24e5bc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade to 3.2 +## Deprecate remaining `Serializable` implementation + +Relying on `SequenceGenerator` implementing the `Serializable` is deprecated +because that interface won't be implemented in ORM 4 anymore. + +The following methods are deprecated: + +* `SequenceGenerator::serialize()` +* `SequenceGenerator::unserialize()` + ## `orm:schema-tool:update` option `--complete` is deprecated That option behaves as a no-op, and is deprecated. It will be removed in 4.0. diff --git a/src/Id/SequenceGenerator.php b/src/Id/SequenceGenerator.php index 45d43f57154..659bb58b9e4 100644 --- a/src/Id/SequenceGenerator.php +++ b/src/Id/SequenceGenerator.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Id; use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Serializable; @@ -65,8 +66,17 @@ public function getNextValue(): int return $this->nextValue; } + /** @deprecated without replacement. */ final public function serialize(): string { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11468', + '%s() is deprecated, use __serialize() instead. %s won\'t implement the Serializable interface anymore in ORM 4.', + __METHOD__, + self::class, + ); + return serialize($this->__serialize()); } @@ -79,8 +89,17 @@ public function __serialize(): array ]; } + /** @deprecated without replacement. */ final public function unserialize(string $serialized): void { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11468', + '%s() is deprecated, use __unserialize() instead. %s won\'t implement the Serializable interface anymore in ORM 4.', + __METHOD__, + self::class, + ); + $this->__unserialize(unserialize($serialized)); } From ce09c96427300f02eebdafda4e975ec2eab86790 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 22 May 2024 21:53:12 +0200 Subject: [PATCH 404/475] Deprecate the NotSupported exception (#11470) --- UPGRADE.md | 4 ++++ src/Exception/NotSupported.php | 1 + 2 files changed, 5 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 14dfc24e5bc..1869e9f28ff 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.2 +## Deprecate the `NotSupported` exception + +The class `Doctrine\ORM\Exception\NotSupported` is deprecated without replacement. + ## Deprecate remaining `Serializable` implementation Relying on `SequenceGenerator` implementing the `Serializable` is deprecated diff --git a/src/Exception/NotSupported.php b/src/Exception/NotSupported.php index a061aebb0dd..9192f87520e 100644 --- a/src/Exception/NotSupported.php +++ b/src/Exception/NotSupported.php @@ -8,6 +8,7 @@ use function sprintf; +/** @deprecated */ final class NotSupported extends LogicException implements ORMException { public static function create(): self From baf96cdad45d44e68dcd6400cdd4969e954ec524 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 23 May 2024 10:24:49 +0200 Subject: [PATCH 405/475] Remove readonly modifier from EntityManager --- src/EntityManager.php | 14 +++++------ tests/Tests/ORM/EntityManagerTest.php | 35 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/EntityManager.php b/src/EntityManager.php index bb9e2ad2ced..8045ac2f5e3 100644 --- a/src/EntityManager.php +++ b/src/EntityManager.php @@ -63,27 +63,27 @@ class EntityManager implements EntityManagerInterface /** * The metadata factory, used to retrieve the ORM metadata of entity classes. */ - private readonly ClassMetadataFactory $metadataFactory; + private ClassMetadataFactory $metadataFactory; /** * The UnitOfWork used to coordinate object-level transactions. */ - private readonly UnitOfWork $unitOfWork; + private UnitOfWork $unitOfWork; /** * The event manager that is the central point of the event system. */ - private readonly EventManager $eventManager; + private EventManager $eventManager; /** * The proxy factory used to create dynamic proxies. */ - private readonly ProxyFactory $proxyFactory; + private ProxyFactory $proxyFactory; /** * The repository factory used to create dynamic repositories. */ - private readonly RepositoryFactory $repositoryFactory; + private RepositoryFactory $repositoryFactory; /** * The expression builder instance used to generate query expressions. @@ -112,8 +112,8 @@ class EntityManager implements EntityManagerInterface * @param Connection $conn The database connection used by the EntityManager. */ public function __construct( - private readonly Connection $conn, - private readonly Configuration $config, + private Connection $conn, + private Configuration $config, EventManager|null $eventManager = null, ) { if (! $config->getMetadataDriverImpl()) { diff --git a/tests/Tests/ORM/EntityManagerTest.php b/tests/Tests/ORM/EntityManagerTest.php index 067b1c6874b..501f86550ce 100644 --- a/tests/Tests/ORM/EntityManagerTest.php +++ b/tests/Tests/ORM/EntityManagerTest.php @@ -7,6 +7,7 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Mapping\ClassMetadataFactory; @@ -21,7 +22,9 @@ use Generator; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use ReflectionProperty; use stdClass; +use Symfony\Component\VarExporter\LazyGhostTrait; use TypeError; class EntityManagerTest extends OrmTestCase @@ -172,4 +175,36 @@ public function testWrapInTransactionReThrowsThrowables(): void self::assertFalse($this->entityManager->isOpen()); } } + + /** Resetting the EntityManager relies on lazy objects until https://github.com/doctrine/orm/issues/5933 is resolved */ + public function testLazyGhostEntityManager(): void + { + $em = new class () extends EntityManager { + use LazyGhostTrait; + + public function __construct() + { + } + }; + + $em = $em::createLazyGhost(static function ($em): void { + $r = new ReflectionProperty(EntityManager::class, 'unitOfWork'); + $r->setValue($em, new class () extends UnitOfWork { + public function __construct() + { + } + + public function clear(): void + { + } + }); + }); + + $this->assertTrue($em->isOpen()); + $em->close(); + $this->assertFalse($em->isOpen()); + + $em->resetLazyObject(); + $this->assertTrue($em->isOpen()); + } } From 9d4f54b9a476f13479c3845350b12c466873fc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 24 May 2024 00:25:01 +0200 Subject: [PATCH 406/475] Update branch metadata (#11474) --- .doctrine-project.json | 10 ++++++++-- README.md | 14 +++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.doctrine-project.json b/.doctrine-project.json index 0eeb48f5899..f3a38fb4bdd 100644 --- a/.doctrine-project.json +++ b/.doctrine-project.json @@ -11,17 +11,23 @@ "slug": "latest", "upcoming": true }, + { + "name": "3.3", + "branchName": "3.3.x", + "slug": "3.3", + "upcoming": true + }, { "name": "3.2", "branchName": "3.2.x", "slug": "3.2", - "upcoming": true + "current": true }, { "name": "3.1", "branchName": "3.1.x", "slug": "3.1", - "current": true + "maintained": false }, { "name": "3.0", diff --git a/README.md b/README.md index 70dceea1faa..1df322cf7e8 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.3.x][3.3] | [3.2.x][3.2] | [2.20.x][2.20] | [2.19.x][2.19] | |:------------------------------------------------------:|:------------------------------------------------------:|:------------------------------------------------------:|:--------------------------------------------------------:|:--------------------------------------------------------:| -| [![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.3 image]][3.3] | [![Build status][3.2 image]][3.2] | [![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.3 coverage image]][3.3 coverage] | [![Coverage Status][3.2 coverage image]][3.2 coverage] | [![Coverage Status][2.20 coverage image]][2.20 coverage] | [![Coverage Status][2.19 coverage image]][2.19 coverage] | [

🇺🇦 UKRAINE NEEDS YOUR HELP NOW!

](https://www.doctrine-project.org/stop-war.html) @@ -22,14 +22,14 @@ 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.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 [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 [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 From ed53defaa17bb8fb420b88d47a49d373338de534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 19 Jun 2024 21:59:29 +0200 Subject: [PATCH 407/475] Deprecate DatabaseDriver It was used for the reverse engineering feature, which has been removed. --- UPGRADE.md | 6 ++++++ src/Mapping/Driver/DatabaseDriver.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 1869e9f28ff..189d8d0a1bf 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,9 @@ +# Upgrade to 3.3 + +## Deprecate `DatabaseDriver` + +The class `Doctrine\ORM\Mapping\Driver\DatabaseDriver` is deprecated without replacement. + # Upgrade to 3.2 ## Deprecate the `NotSupported` exception diff --git a/src/Mapping/Driver/DatabaseDriver.php b/src/Mapping/Driver/DatabaseDriver.php index 49e2e93520c..301e44a97e2 100644 --- a/src/Mapping/Driver/DatabaseDriver.php +++ b/src/Mapping/Driver/DatabaseDriver.php @@ -35,6 +35,8 @@ /** * The DatabaseDriver reverse engineers the mapping metadata from a database. * + * @deprecated No replacement planned + * * @link www.doctrine-project.org */ class DatabaseDriver implements MappingDriver From c06f6b93761a12380e57d5d241eb0d6e22a0d3df Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 20 Jun 2024 09:08:10 +0200 Subject: [PATCH 408/475] Add the propoer void return type on the __load method of proxies When using ghost objects, the method was leaking a `static` return type due to the way it was implemented, which is incompatible with the native return type that will be added in doctrine/persistence v4. --- src/Proxy/ProxyFactory.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Proxy/ProxyFactory.php b/src/Proxy/ProxyFactory.php index b5426a014e4..b2d114a6698 100644 --- a/src/Proxy/ProxyFactory.php +++ b/src/Proxy/ProxyFactory.php @@ -387,12 +387,18 @@ private function generateUseLazyGhostTrait(ClassMetadata $class): string $code = substr($code, 7 + (int) strpos($code, "\n{")); $code = substr($code, 0, (int) strpos($code, "\n}")); $code = str_replace('LazyGhostTrait;', str_replace("\n ", "\n", 'LazyGhostTrait { - initializeLazyObject as __load; + initializeLazyObject as private; setLazyObjectAsInitialized as public __setInitialized; isLazyObjectInitialized as private; createLazyGhost as private; resetLazyObject as private; - }'), $code); + } + + public function __load(): void + { + $this->initializeLazyObject(); + } + '), $code); return $code; } From 1153b9468ccfef452625064c66b4a135d0ea8a46 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 21 Jun 2024 13:31:45 +0200 Subject: [PATCH 409/475] Fix deprecated array access usage (#11517) --- src/Persisters/Collection/OneToManyPersister.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Persisters/Collection/OneToManyPersister.php b/src/Persisters/Collection/OneToManyPersister.php index 7354daa5627..0727b1f8a7e 100644 --- a/src/Persisters/Collection/OneToManyPersister.php +++ b/src/Persisters/Collection/OneToManyPersister.php @@ -174,9 +174,9 @@ private function deleteEntityCollection(PersistentCollection $collection): int if ($targetClass->isInheritanceTypeSingleTable()) { $discriminatorColumn = $targetClass->getDiscriminatorColumn(); - $statement .= ' AND ' . $discriminatorColumn['name'] . ' = ?'; + $statement .= ' AND ' . $discriminatorColumn->name . ' = ?'; $parameters[] = $targetClass->discriminatorValue; - $types[] = $discriminatorColumn['type']; + $types[] = $discriminatorColumn->type; } $numAffected = $this->conn->executeStatement($statement, $parameters, $types); From 1fe1a6a048dd420d06704f72b296a463237d7603 Mon Sep 17 00:00:00 2001 From: Xesau Date: Mon, 1 Jul 2024 21:57:36 +0200 Subject: [PATCH 410/475] Fix incorrect exception message for ManyToOne attribute in embeddable class (#11536) When a ManyToOne attribute is encountered on an Embeddable class, the exception message reads "Attribute "Doctrine\ORM\Mapping\OneToMany" on embeddable [class] is not allowed.". This should be "Doctrine\ORM\Mapping\ManyToOne" on embeddable [class] is not allowed.". --- src/Mapping/Driver/AttributeDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mapping/Driver/AttributeDriver.php b/src/Mapping/Driver/AttributeDriver.php index 6fed1a24e67..9ba3481e3ba 100644 --- a/src/Mapping/Driver/AttributeDriver.php +++ b/src/Mapping/Driver/AttributeDriver.php @@ -390,7 +390,7 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata $metadata->mapOneToMany($mapping); } elseif ($manyToOneAttribute !== null) { if ($metadata->isEmbeddedClass) { - throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\OneToMany::class); + throw MappingException::invalidAttributeOnEmbeddable($metadata->name, Mapping\ManyToOne::class); } $idAttribute = $this->reader->getPropertyAttribute($property, Mapping\Id::class); From 0983d3a4af20124cc9f884727c555be34efdf34b Mon Sep 17 00:00:00 2001 From: Tomas Date: Thu, 27 Jun 2024 09:48:45 +0300 Subject: [PATCH 411/475] Add `createNamedParameter` to `QueryBuilder` --- docs/en/reference/query-builder.rst | 18 ++++++++++++ src/QueryBuilder.php | 42 ++++++++++++++++++++++++++++ tests/Tests/ORM/QueryBuilderTest.php | 41 +++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) diff --git a/docs/en/reference/query-builder.rst b/docs/en/reference/query-builder.rst index 3070cc234df..41ef31420ae 100644 --- a/docs/en/reference/query-builder.rst +++ b/docs/en/reference/query-builder.rst @@ -611,3 +611,21 @@ same query of example 6 written using ->add('from', new Expr\From('User', 'u')) ->add('where', new Expr\Comparison('u.id', '=', '?1')) ->add('orderBy', new Expr\OrderBy('u.name', 'ASC')); + +Binding Parameters to Placeholders +---------------------------------- + +It is often not necessary to know about the exact placeholder names when +building a query. You can use a helper method to bind a value to a placeholder +and directly use that placeholder in your query as a return value: + +.. code-block:: php + + select('u') + ->from('User', 'u') + ->where('u.email = ' . $qb->createNamedParameter($userInputEmail)) + ; + // SELECT u FROM User u WHERE email = :dcValue1 diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index a6a39a964b8..fe2d750e338 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -110,6 +110,13 @@ class QueryBuilder implements Stringable protected int $lifetime = 0; + /** + * The counter of bound parameters. + * + * @var int<0, max> + */ + private int $boundCounter = 0; + /** * Initializes a new QueryBuilder that uses the given EntityManager. * @@ -1336,6 +1343,41 @@ public function resetDQLPart(string $part): static return $this; } + /** + * Creates a new named parameter and bind the value $value to it. + * + * The parameter $value specifies the value that you want to bind. If + * $placeholder is not provided createNamedParameter() will automatically + * create a placeholder for you. An automatic placeholder will be of the + * name ':dcValue1', ':dcValue2' etc. + * + * Example: + * + * $qb = $em->createQueryBuilder(); + * $qb + * ->select('u') + * ->from('User', 'u') + * ->where('u.username = ' . $qb->createNamedParameter('Foo', Types::STRING)) + * ->orWhere('u.username = ' . $qb->createNamedParameter('Bar', Types::STRING)) + * + * + * @param ParameterType|ArrayParameterType|string|int|null $type ParameterType::*, ArrayParameterType::* or \Doctrine\DBAL\Types\Type::* constant + * @param non-empty-string|null $placeholder The name to bind with. The string must start with a colon ':'. + * + * @return non-empty-string the placeholder name used. + */ + public function createNamedParameter(mixed $value, ParameterType|ArrayParameterType|string|int|null $type = null, string|null $placeholder = null): string + { + if ($placeholder === null) { + $this->boundCounter++; + $placeholder = ':dcValue' . $this->boundCounter; + } + + $this->setParameter(substr($placeholder, 1), $value, $type); + + return $placeholder; + } + /** * Gets a string representation of this QueryBuilder which corresponds to * the final DQL query being constructed. diff --git a/tests/Tests/ORM/QueryBuilderTest.php b/tests/Tests/ORM/QueryBuilderTest.php index 577c86581bf..fd610bced44 100644 --- a/tests/Tests/ORM/QueryBuilderTest.php +++ b/tests/Tests/ORM/QueryBuilderTest.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Order; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Cache; use Doctrine\ORM\Query; use Doctrine\ORM\Query\Expr\Join; @@ -1285,4 +1286,44 @@ public function testDeleteWithoutAlias(): void $this->expectExceptionMessage('Doctrine\ORM\QueryBuilder::delete(): The alias for entity Doctrine\Tests\Models\CMS\CmsUser u must not be omitted.'); $qb->delete(CmsUser::class . ' u'); } + + public function testCreateNamedParameter(): void + { + $qb = $this->entityManager->createQueryBuilder(); + + $qb->select('u') + ->from(CmsUser::class, 'u') + ->where( + $qb->expr()->eq('u.name', $qb->createNamedParameter('john doe', Types::STRING)), + ) + ->orWhere( + $qb->expr()->eq('u.rank', $qb->createNamedParameter(100, Types::INTEGER)), + ); + + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :dcValue1 OR u.rank = :dcValue2', $qb->getDQL()); + self::assertEquals('john doe', $qb->getParameter('dcValue1')->getValue()); + self::assertEquals(Types::STRING, $qb->getParameter('dcValue1')->getType()); + self::assertEquals(100, $qb->getParameter('dcValue2')->getValue()); + self::assertEquals(Types::INTEGER, $qb->getParameter('dcValue2')->getType()); + } + + public function testCreateNamedParameterCustomPlaceholder(): void + { + $qb = $this->entityManager->createQueryBuilder(); + + $qb->select('u') + ->from(CmsUser::class, 'u') + ->where( + $qb->expr()->eq('u.name', $qb->createNamedParameter('john doe', Types::STRING, ':test')), + ) + ->andWhere( + $qb->expr()->eq('u.rank', $qb->createNamedParameter(100, Types::INTEGER)), + ); + + self::assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :test AND u.rank = :dcValue1', $qb->getDQL()); + self::assertEquals('john doe', $qb->getParameter('test')->getValue()); + self::assertEquals(Types::STRING, $qb->getParameter('test')->getType()); + self::assertEquals(100, $qb->getParameter('dcValue1')->getValue()); + self::assertEquals(Types::INTEGER, $qb->getParameter('dcValue1')->getType()); + } } From 129553da906ee98f4b517dd1a0f6edc519bb29c3 Mon Sep 17 00:00:00 2001 From: Maciej Malarz Date: Thu, 11 Jul 2024 11:50:04 +0200 Subject: [PATCH 412/475] Allow overriding association's cascade --- src/Mapping/ClassMetadata.php | 6 +++++- tests/Tests/ORM/Mapping/ClassMetadataTest.php | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index f58e00e72fe..9c2ca97f637 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -1676,7 +1676,7 @@ public function setInheritanceType(int $type): void /** * Sets the association to override association mapping of property for an entity relationship. * - * @psalm-param array $overrideMapping + * @psalm-param array{joinColumns?: array, inversedBy?: ?string, joinTable?: array, fetch?: ?string, cascade?: string[]} $overrideMapping * * @throws MappingException */ @@ -1712,6 +1712,10 @@ public function setAssociationOverride(string $fieldName, array $overrideMapping $mapping['fetch'] = $overrideMapping['fetch']; } + if (isset($overrideMapping['cascade'])) { + $mapping['cascade'] = $overrideMapping['cascade']; + } + switch ($mapping['type']) { case self::ONE_TO_ONE: case self::MANY_TO_ONE: diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index a7fb88b2e03..71fb210021c 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -870,13 +870,23 @@ public function testAssociationOverrideKeepsDeclaringClass(): void { $cm = new ClassMetadata(Directory::class); $cm->mapManyToOne(['fieldName' => 'parentDirectory', 'targetEntity' => Directory::class, 'cascade' => ['remove'], 'declared' => Directory::class]); - $cm->setAssociationOverride('parentDirectory', ['cascade' => '']); + $cm->setAssociationOverride('parentDirectory', ['cascade' => ['remove']]); $mapping = $cm->getAssociationMapping('parentDirectory'); self::assertSame(Directory::class, $mapping->declared); } + public function testAssociationOverrideCanOverrideCascade(): void + { + $cm = new ClassMetadata(Directory::class); + $cm->mapManyToOne(['fieldName' => 'parentDirectory', 'targetEntity' => Directory::class, 'cascade' => ['remove'], 'declared' => Directory::class]); + $cm->setAssociationOverride('parentDirectory', ['cascade' => ['all']]); + + $mapping = $cm->getAssociationMapping('parentDirectory'); + self::assertSame(['remove', 'persist', 'refresh', 'detach'], $mapping['cascade']); + } + #[TestGroup('DDC-1955')] public function testInvalidEntityListenerClassException(): void { From 57247ed6ca1a61d19f26912be3ab1e19528996f2 Mon Sep 17 00:00:00 2001 From: d-ph Date: Mon, 22 Jul 2024 10:06:18 +0100 Subject: [PATCH 413/475] Make CountWalker use COUNT(*) when $distinct is explicitly set to false (#11552) This change makes CountWalker use COUNT(*) instead of COUNT(tbl.id), when the user declared that their query does not need to use (SELECT) DISTINCT, which is commonly the case when there are no JOINs in the query, or when the JOINs are only *ToOne. Research showed that COUNT(*) allows databases to use index(-only) scans more eagerly from any of the indexed columns, especially when the query is using a WHERE-condition that filters on an indexed column. --- src/Tools/Pagination/CountWalker.php | 36 ++++++++++--------- .../ORM/Tools/Pagination/CountWalkerTest.php | 14 ++++++++ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/Tools/Pagination/CountWalker.php b/src/Tools/Pagination/CountWalker.php index d2129435558..f11b25d6821 100644 --- a/src/Tools/Pagination/CountWalker.php +++ b/src/Tools/Pagination/CountWalker.php @@ -37,27 +37,31 @@ public function walkSelectStatement(SelectStatement $selectStatement): void throw new RuntimeException('Cannot count query which selects two FROM components, cannot make distinction'); } - $fromRoot = reset($from); - $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; - $rootClass = $this->getMetadataForDqlAlias($rootAlias); - $identifierFieldName = $rootClass->getSingleIdentifierFieldName(); + $distinct = $this->_getQuery()->getHint(self::HINT_DISTINCT); - $pathType = PathExpression::TYPE_STATE_FIELD; - if (isset($rootClass->associationMappings[$identifierFieldName])) { - $pathType = PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION; - } + $countPathExpressionOrLiteral = '*'; + if ($distinct) { + $fromRoot = reset($from); + $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable; + $rootClass = $this->getMetadataForDqlAlias($rootAlias); + $identifierFieldName = $rootClass->getSingleIdentifierFieldName(); + + $pathType = PathExpression::TYPE_STATE_FIELD; + if (isset($rootClass->associationMappings[$identifierFieldName])) { + $pathType = PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION; + } - $pathExpression = new PathExpression( - PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, - $rootAlias, - $identifierFieldName, - ); - $pathExpression->type = $pathType; + $countPathExpressionOrLiteral = new PathExpression( + PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, + $rootAlias, + $identifierFieldName, + ); + $countPathExpressionOrLiteral->type = $pathType; + } - $distinct = $this->_getQuery()->getHint(self::HINT_DISTINCT); $selectStatement->selectClause->selectExpressions = [ new SelectExpression( - new AggregateExpression('count', $pathExpression, $distinct), + new AggregateExpression('count', $countPathExpressionOrLiteral, $distinct), null, ), ]; diff --git a/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php index 5af90e87949..6a223e67f50 100644 --- a/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -27,6 +27,20 @@ public function testCountQuery(): void ); } + public function testCountQueryWithoutDistinctUsesCountStar(): void + { + $query = $this->entityManager->createQuery( + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a', + ); + $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [CountWalker::class]); + $query->setHint(CountWalker::HINT_DISTINCT, false); + + self::assertEquals( + 'SELECT count(*) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id', + $query->getSQL(), + ); + } + public function testCountQueryMixedResultsWithName(): void { $query = $this->entityManager->createQuery( From 56cd688c4a74ba5dfa732bfdc5baa159ccb92328 Mon Sep 17 00:00:00 2001 From: Marc Eichenseher Date: Fri, 2 Aug 2024 01:01:23 +0200 Subject: [PATCH 414/475] Remove unused $pkColumns when gathering columns (#11560) --- src/Tools/SchemaTool.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index 42b52df8c71..cff59aecdd8 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -421,18 +421,12 @@ private function addDiscriminatorColumnDefinition(ClassMetadata $class, Table $t */ private function gatherColumns(ClassMetadata $class, Table $table): void { - $pkColumns = []; - foreach ($class->fieldMappings as $mapping) { if ($class->isInheritanceTypeSingleTable() && isset($mapping->inherited)) { continue; } $this->gatherColumn($class, $mapping, $table); - - if ($class->isIdentifier($mapping->fieldName)) { - $pkColumns[] = $this->quoteStrategy->getColumnName($mapping->fieldName, $class, $this->platform); - } } } From 3f550c19e3cbdb5d5a13be10182eb3d52d69b604 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Thu, 11 Jul 2024 14:41:28 +0200 Subject: [PATCH 415/475] DQL custom functions: document TypedExpression Partially related to https://github.com/doctrine/orm/issues/11537 Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com> --- .../cookbook/dql-user-defined-functions.rst | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/en/cookbook/dql-user-defined-functions.rst b/docs/en/cookbook/dql-user-defined-functions.rst index b189ed59fcd..e1782e05669 100644 --- a/docs/en/cookbook/dql-user-defined-functions.rst +++ b/docs/en/cookbook/dql-user-defined-functions.rst @@ -232,6 +232,33 @@ vendors SQL parser to show us further errors in the parsing process, for example if the Unit would not be one of the supported values by MySql. +Typed functions +--------------- +By default, result of custom functions is fetched as-is from the database driver. +If you want to be sure that the type is always the same, then your custom function needs to +implement ``Doctrine\ORM\Query\AST\TypedExpression``. Then, the result is wired +through ``Doctrine\DBAL\Types\Type::convertToPhpValue()`` of the ``Type`` returned in ``getReturnType()``. + +.. code-block:: php + + Date: Mon, 12 Aug 2024 09:12:53 +0200 Subject: [PATCH 416/475] Add support for using nested DTOs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This feature allow use of nested new operators Co-authored-by: Tomas Norkūnas Co-authored-by: Sergey Protko Co-authored-by: Łukasz Zakrzewski Update docs/en/reference/dql-doctrine-query-language.rst Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com> --- .../reference/dql-doctrine-query-language.rst | 29 ++++- psalm-baseline.xml | 10 +- src/Internal/Hydration/AbstractHydrator.php | 34 +++++- src/Internal/Hydration/ArrayHydrator.php | 5 +- src/Internal/Hydration/ObjectHydrator.php | 4 +- src/Query/Parser.php | 4 + src/Query/ResultSetMapping.php | 29 +++++ src/Query/SqlWalker.php | 24 +++- tests/Tests/Models/CMS/CmsAddressDTO.php | 2 +- tests/Tests/Models/CMS/CmsUserDTO.php | 2 +- .../Tests/Models/DDC6573/DDC6573Currency.php | 17 +++ tests/Tests/Models/DDC6573/DDC6573Item.php | 44 +++++++ tests/Tests/Models/DDC6573/DDC6573Money.php | 24 ++++ .../Tests/ORM/Functional/NewOperatorTest.php | 67 +++++++++++ .../ORM/Functional/Ticket/DDC6573Test.php | 108 ++++++++++++++++++ .../ORM/Hydration/ResultSetMappingTest.php | 17 +++ 16 files changed, 402 insertions(+), 18 deletions(-) create mode 100644 tests/Tests/Models/DDC6573/DDC6573Currency.php create mode 100644 tests/Tests/Models/DDC6573/DDC6573Item.php create mode 100644 tests/Tests/Models/DDC6573/DDC6573Money.php create mode 100644 tests/Tests/ORM/Functional/Ticket/DDC6573Test.php diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index 12b08823811..c2b31cd326d 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -579,7 +579,34 @@ And then use the ``NEW`` DQL keyword : $query = $em->createQuery('SELECT NEW CustomerDTO(c.name, e.email, a.city, SUM(o.value)) FROM Customer c JOIN c.email e JOIN c.address a JOIN c.orders o GROUP BY c'); $users = $query->getResult(); // array of CustomerDTO -Note that you can only pass scalar expressions to the constructor. +You can also nest several DTO : + +.. code-block:: php + + createQuery('SELECT NEW CustomerDTO(c.name, e.email, NEW AddressDTO(a.street, a.city, a.zip)) FROM Customer c JOIN c.email e JOIN c.address a'); + $users = $query->getResult(); // array of CustomerDTO + +Note that you can only pass scalar expressions or other Data Transfer Objects to the constructor. Using INDEX BY ~~~~~~~~~~~~~~ diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7a84afd4f83..b83ae43a889 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -216,6 +216,10 @@ + + + + @@ -228,9 +232,6 @@ - - - @@ -265,9 +266,6 @@ - - - diff --git a/src/Internal/Hydration/AbstractHydrator.php b/src/Internal/Hydration/AbstractHydrator.php index d8bffe4ad39..c8186171466 100644 --- a/src/Internal/Hydration/AbstractHydrator.php +++ b/src/Internal/Hydration/AbstractHydrator.php @@ -252,8 +252,9 @@ abstract protected function hydrateAllData(): mixed; * @psalm-return array{ * data: array, * newObjects?: array, * scalars?: array * } @@ -281,6 +282,10 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon $value = $this->buildEnum($value, $cacheKeyInfo['enumType']); } + if (! isset($rowData['newObjects'])) { + $rowData['newObjects'] = []; + } + $rowData['newObjects'][$objIndex]['class'] = $cacheKeyInfo['class']; $rowData['newObjects'][$objIndex]['args'][$argIndex] = $value; break; @@ -335,6 +340,31 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon } } + foreach ($this->resultSetMapping()->nestedNewObjectArguments as $objIndex => ['ownerIndex' => $ownerIndex, 'argIndex' => $argIndex]) { + if (! isset($rowData['newObjects'][$objIndex])) { + continue; + } + + $newObject = $rowData['newObjects'][$objIndex]; + unset($rowData['newObjects'][$objIndex]); + + $class = $newObject['class']; + $args = $newObject['args']; + $obj = $class->newInstanceArgs($args); + + $rowData['newObjects'][$ownerIndex]['args'][$argIndex] = $obj; + } + + if (isset($rowData['newObjects'])) { + foreach ($rowData['newObjects'] as $objIndex => $newObject) { + $class = $newObject['class']; + $args = $newObject['args']; + $obj = $class->newInstanceArgs($args); + + $rowData['newObjects'][$objIndex]['obj'] = $obj; + } + } + return $rowData; } diff --git a/src/Internal/Hydration/ArrayHydrator.php b/src/Internal/Hydration/ArrayHydrator.php index 7115c16c47b..576b89174d3 100644 --- a/src/Internal/Hydration/ArrayHydrator.php +++ b/src/Internal/Hydration/ArrayHydrator.php @@ -214,9 +214,8 @@ protected function hydrateRowData(array $row, array &$result): void $scalarCount = (isset($rowData['scalars']) ? count($rowData['scalars']) : 0); foreach ($rowData['newObjects'] as $objIndex => $newObject) { - $class = $newObject['class']; - $args = $newObject['args']; - $obj = $class->newInstanceArgs($args); + $args = $newObject['args']; + $obj = $newObject['obj']; if (count($args) === $scalarCount || ($scalarCount === 0 && count($rowData['newObjects']) === 1)) { $result[$resultKey] = $obj; diff --git a/src/Internal/Hydration/ObjectHydrator.php b/src/Internal/Hydration/ObjectHydrator.php index d0fc101f215..f151fb813ca 100644 --- a/src/Internal/Hydration/ObjectHydrator.php +++ b/src/Internal/Hydration/ObjectHydrator.php @@ -556,9 +556,7 @@ protected function hydrateRowData(array $row, array &$result): void $scalarCount = (isset($rowData['scalars']) ? count($rowData['scalars']) : 0); foreach ($rowData['newObjects'] as $objIndex => $newObject) { - $class = $newObject['class']; - $args = $newObject['args']; - $obj = $class->newInstanceArgs($args); + $obj = $newObject['obj']; if ($scalarCount === 0 && count($rowData['newObjects']) === 1) { $result[$resultKey] = $obj; diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 42b0027f579..38858cbf876 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -1782,6 +1782,10 @@ public function NewObjectArg(): mixed return $expression; } + if ($token->type === TokenType::T_NEW) { + return $this->NewObjectExpression(); + } + return $this->ScalarExpression(); } diff --git a/src/Query/ResultSetMapping.php b/src/Query/ResultSetMapping.php index 612474db1d2..c95b089a73b 100644 --- a/src/Query/ResultSetMapping.php +++ b/src/Query/ResultSetMapping.php @@ -4,6 +4,7 @@ namespace Doctrine\ORM\Query; +use function array_merge; use function count; /** @@ -152,6 +153,13 @@ class ResultSetMapping */ public array $newObjectMappings = []; + /** + * Maps last argument for new objects in order to initiate object construction + * + * @psalm-var array + */ + public array $nestedNewObjectArguments = []; + /** * Maps metadata parameter names to the metadata attribute. * @@ -544,4 +552,25 @@ public function addMetaResult( return $this; } + + public function addNewObjectAsArgument(string|int $alias, string|int $objOwner, int $objOwnerIdx): static + { + $owner = [ + 'ownerIndex' => $objOwner, + 'argIndex' => $objOwnerIdx, + ]; + + if (! isset($this->nestedNewObjectArguments[$owner['ownerIndex']])) { + $this->nestedNewObjectArguments[$alias] = $owner; + + return $this; + } + + $this->nestedNewObjectArguments = array_merge( + [$alias => $owner], + $this->nestedNewObjectArguments, + ); + + return $this; + } } diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index 7f9bb110cac..46296e719e7 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -25,8 +25,10 @@ use function array_keys; use function array_map; use function array_merge; +use function array_pop; use function assert; use function count; +use function end; use function implode; use function in_array; use function is_array; @@ -85,6 +87,13 @@ class SqlWalker */ private int $newObjectCounter = 0; + /** + * Contains nesting levels of new objects arguments + * + * @psalm-var array + */ + private array $newObjectStack = []; + private readonly EntityManagerInterface $em; private readonly Connection $conn; @@ -1482,7 +1491,14 @@ public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesis public function walkNewObject(AST\NewObjectExpression $newObjectExpression, string|null $newObjectResultAlias = null): string { $sqlSelectExpressions = []; - $objIndex = $newObjectResultAlias ?: $this->newObjectCounter++; + $objOwner = $objOwnerIdx = null; + + if ($this->newObjectStack !== []) { + [$objOwner, $objOwnerIdx] = end($this->newObjectStack); + $objIndex = $objOwner . ':' . $objOwnerIdx; + } else { + $objIndex = $newObjectResultAlias ?: $this->newObjectCounter++; + } foreach ($newObjectExpression->args as $argIndex => $e) { $resultAlias = $this->scalarResultCounter++; @@ -1491,7 +1507,9 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri switch (true) { case $e instanceof AST\NewObjectExpression: + $this->newObjectStack[] = [$objIndex, $argIndex]; $sqlSelectExpressions[] = $e->dispatch($this); + array_pop($this->newObjectStack); break; case $e instanceof AST\Subselect: @@ -1545,6 +1563,10 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri 'objIndex' => $objIndex, 'argIndex' => $argIndex, ]; + + if ($objOwner !== null && $objOwnerIdx !== null) { + $this->rsm->addNewObjectAsArgument($objIndex, $objOwner, $objOwnerIdx); + } } return implode(', ', $sqlSelectExpressions); diff --git a/tests/Tests/Models/CMS/CmsAddressDTO.php b/tests/Tests/Models/CMS/CmsAddressDTO.php index cfe1579aaf9..502644ed25e 100644 --- a/tests/Tests/Models/CMS/CmsAddressDTO.php +++ b/tests/Tests/Models/CMS/CmsAddressDTO.php @@ -6,7 +6,7 @@ class CmsAddressDTO { - public function __construct(public string|null $country = null, public string|null $city = null, public string|null $zip = null) + public function __construct(public string|null $country = null, public string|null $city = null, public string|null $zip = null, public CmsAddressDTO|string|null $address = null) { } } diff --git a/tests/Tests/Models/CMS/CmsUserDTO.php b/tests/Tests/Models/CMS/CmsUserDTO.php index 36b639aeb73..f2dc43114db 100644 --- a/tests/Tests/Models/CMS/CmsUserDTO.php +++ b/tests/Tests/Models/CMS/CmsUserDTO.php @@ -6,7 +6,7 @@ class CmsUserDTO { - public function __construct(public string|null $name = null, public string|null $email = null, public string|null $address = null, public int|null $phonenumbers = null) + public function __construct(public string|null $name = null, public string|null $email = null, public CmsAddressDTO|string|null $address = null, public int|null $phonenumbers = null) { } } diff --git a/tests/Tests/Models/DDC6573/DDC6573Currency.php b/tests/Tests/Models/DDC6573/DDC6573Currency.php new file mode 100644 index 00000000000..9aa5b0eb9e1 --- /dev/null +++ b/tests/Tests/Models/DDC6573/DDC6573Currency.php @@ -0,0 +1,17 @@ +code; + } +} diff --git a/tests/Tests/Models/DDC6573/DDC6573Item.php b/tests/Tests/Models/DDC6573/DDC6573Item.php new file mode 100644 index 00000000000..29b99a2d6fb --- /dev/null +++ b/tests/Tests/Models/DDC6573/DDC6573Item.php @@ -0,0 +1,44 @@ +name = $name; + $this->priceAmount = $price->getAmount(); + $this->priceCurrency = $price->getCurrency()->getCode(); + } + + public function getPrice(): DDC6573Money + { + return new DDC6573Money($this->priceAmount, new DDC6573Currency($this->priceCurrency)); + } +} diff --git a/tests/Tests/Models/DDC6573/DDC6573Money.php b/tests/Tests/Models/DDC6573/DDC6573Money.php new file mode 100644 index 00000000000..f0d0d59ea48 --- /dev/null +++ b/tests/Tests/Models/DDC6573/DDC6573Money.php @@ -0,0 +1,24 @@ +amount; + } + + public function getCurrency(): DDC6573Currency + { + return $this->currency; + } +} diff --git a/tests/Tests/ORM/Functional/NewOperatorTest.php b/tests/Tests/ORM/Functional/NewOperatorTest.php index 7f89a938e88..4497af517bf 100644 --- a/tests/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Tests/ORM/Functional/NewOperatorTest.php @@ -1013,6 +1013,73 @@ public function testClassCantBeInstantiatedException(): void $dql = 'SELECT new Doctrine\Tests\ORM\Functional\ClassWithPrivateConstructor(u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u'; $this->_em->createQuery($dql)->getResult(); } + + public function testShouldSupportNestedNewOperators(): void + { + $dql = ' + SELECT + new CmsUserDTO( + u.name, + e.email, + new CmsAddressDTO( + a.country, + a.city, + a.zip, + new CmsAddressDTO( + a.country, + a.city, + a.zip + ) + ) + ) as user, + u.status, + u.username as cmsUserUsername + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e + JOIN + u.address a + ORDER BY + u.name'; + + $query = $this->getEntityManager()->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(3, $result); + + self::assertInstanceOf(CmsUserDTO::class, $result[0]['user']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['user']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['user']); + + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['user']->address); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['user']->address); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['user']->address); + + self::assertSame($this->fixtures[0]->name, $result[0]['user']->name); + self::assertSame($this->fixtures[1]->name, $result[1]['user']->name); + self::assertSame($this->fixtures[2]->name, $result[2]['user']->name); + + self::assertSame($this->fixtures[0]->email->email, $result[0]['user']->email); + self::assertSame($this->fixtures[1]->email->email, $result[1]['user']->email); + self::assertSame($this->fixtures[2]->email->email, $result[2]['user']->email); + + self::assertSame($this->fixtures[0]->address->city, $result[0]['user']->address->city); + self::assertSame($this->fixtures[1]->address->city, $result[1]['user']->address->city); + self::assertSame($this->fixtures[2]->address->city, $result[2]['user']->address->city); + + self::assertSame($this->fixtures[0]->address->country, $result[0]['user']->address->country); + self::assertSame($this->fixtures[1]->address->country, $result[1]['user']->address->country); + self::assertSame($this->fixtures[2]->address->country, $result[2]['user']->address->country); + + self::assertSame($this->fixtures[0]->status, $result[0]['status']); + self::assertSame($this->fixtures[1]->status, $result[1]['status']); + self::assertSame($this->fixtures[2]->status, $result[2]['status']); + + self::assertSame($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertSame($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + } } class ClassWithTooMuchArgs diff --git a/tests/Tests/ORM/Functional/Ticket/DDC6573Test.php b/tests/Tests/ORM/Functional/Ticket/DDC6573Test.php new file mode 100644 index 00000000000..4802e596bfb --- /dev/null +++ b/tests/Tests/ORM/Functional/Ticket/DDC6573Test.php @@ -0,0 +1,108 @@ + */ + private $fixtures; + + protected function setUp(): void + { + parent::setUp(); + + $this->createSchemaForModels( + DDC6573Item::class, + ); + + $item1 = new DDC6573Item('Plate', new DDC6573Money(5, new DDC6573Currency('GBP'))); + $item2 = new DDC6573Item('Iron', new DDC6573Money(50, new DDC6573Currency('EUR'))); + $item3 = new DDC6573Item('Teapot', new DDC6573Money(10, new DDC6573Currency('GBP'))); + + $this->_em->persist($item1); + $this->_em->persist($item2); + $this->_em->persist($item3); + + $this->_em->flush(); + $this->_em->clear(); + + $this->fixtures = [$item1, $item2, $item3]; + } + + protected function tearDown(): void + { + $this->_em->createQuery('DELETE FROM Doctrine\Tests\Models\DDC6573\DDC6573Item i')->execute(); + } + + public static function provideDataForHydrationMode(): iterable + { + yield [AbstractQuery::HYDRATE_ARRAY]; + yield [AbstractQuery::HYDRATE_OBJECT]; + } + + #[DataProvider('provideDataForHydrationMode')] + public function testShouldSupportsMultipleNewOperator(int $hydrationMode): void + { + $dql = ' + SELECT + new Doctrine\Tests\Models\DDC6573\DDC6573Money( + i.priceAmount, + new Doctrine\Tests\Models\DDC6573\DDC6573Currency(i.priceCurrency) + ) + FROM + Doctrine\Tests\Models\DDC6573\DDC6573Item i + ORDER BY + i.priceAmount ASC'; + + $query = $this->_em->createQuery($dql); + $result = $query->getResult($hydrationMode); + + self::assertCount(3, $result); + + self::assertInstanceOf(DDC6573Money::class, $result[0]); + self::assertInstanceOf(DDC6573Money::class, $result[1]); + self::assertInstanceOf(DDC6573Money::class, $result[2]); + + self::assertEquals($this->fixtures[0]->getPrice(), $result[0]); + self::assertEquals($this->fixtures[2]->getPrice(), $result[1]); + self::assertEquals($this->fixtures[1]->getPrice(), $result[2]); + } + + #[DataProvider('provideDataForHydrationMode')] + public function testShouldSupportsBasicUsage(int $hydrationMode): void + { + $dql = ' + SELECT + new Doctrine\Tests\Models\DDC6573\DDC6573Currency( + i.priceCurrency + ) + FROM + Doctrine\Tests\Models\DDC6573\DDC6573Item i + ORDER BY + i.priceAmount'; + + $query = $this->_em->createQuery($dql); + $result = $query->getResult($hydrationMode); + + self::assertCount(3, $result); + + self::assertInstanceOf(DDC6573Currency::class, $result[0]); + self::assertInstanceOf(DDC6573Currency::class, $result[1]); + self::assertInstanceOf(DDC6573Currency::class, $result[2]); + + self::assertEquals($this->fixtures[0]->getPrice()->getCurrency(), $result[0]); + self::assertEquals($this->fixtures[1]->getPrice()->getCurrency(), $result[2]); + self::assertEquals($this->fixtures[2]->getPrice()->getCurrency(), $result[1]); + } +} diff --git a/tests/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Tests/ORM/Hydration/ResultSetMappingTest.php index 0c20eab0866..14b9205abfe 100644 --- a/tests/Tests/ORM/Hydration/ResultSetMappingTest.php +++ b/tests/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -102,4 +102,21 @@ public function testIndexByMetadataColumn(): void self::assertTrue($this->_rsm->hasIndexBy('lu')); } + + public function testNewObjectNestedArgumentsDeepestLeavesShouldComeFirst(): void + { + $this->_rsm->addNewObjectAsArgument('objALevel2', 'objALevel1', 0); + $this->_rsm->addNewObjectAsArgument('objALevel3', 'objALevel2', 1); + $this->_rsm->addNewObjectAsArgument('objBLevel3', 'objBLevel2', 0); + $this->_rsm->addNewObjectAsArgument('objBLevel2', 'objBLevel1', 1); + + $expectedArgumentMapping = [ + 'objALevel3' => ['ownerIndex' => 'objALevel2', 'argIndex' => 1], + 'objALevel2' => ['ownerIndex' => 'objALevel1', 'argIndex' => 0], + 'objBLevel3' => ['ownerIndex' => 'objBLevel2', 'argIndex' => 0], + 'objBLevel2' => ['ownerIndex' => 'objBLevel1', 'argIndex' => 1], + ]; + + self::assertSame($expectedArgumentMapping, $this->_rsm->nestedNewObjectArguments); + } } From c6b2d897489d535536de435bdef48f2783366ffb Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 24 Aug 2024 07:29:36 +0200 Subject: [PATCH 417/475] Precise EntityRepository::count (#11579) --- src/EntityRepository.php | 1 + src/Persisters/Entity/BasicEntityPersister.php | 5 ++++- src/Persisters/Entity/EntityPersister.php | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/EntityRepository.php b/src/EntityRepository.php index a53c5284881..ad472315398 100644 --- a/src/EntityRepository.php +++ b/src/EntityRepository.php @@ -131,6 +131,7 @@ public function findOneBy(array $criteria, array|null $orderBy = null): object|n * @psalm-param array $criteria * * @return int The cardinality of the objects that match the given criteria. + * @psalm-return 0|positive-int * * @todo Add this method to `ObjectRepository` interface in the next major release */ diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php index abaf8f4c87b..1bb54ed4410 100644 --- a/src/Persisters/Entity/BasicEntityPersister.php +++ b/src/Persisters/Entity/BasicEntityPersister.php @@ -860,7 +860,10 @@ public function count(array|Criteria $criteria = []): int ? $this->expandCriteriaParameters($criteria) : $this->expandParameters($criteria); - return (int) $this->conn->executeQuery($sql, $params, $types)->fetchOne(); + $count = (int) $this->conn->executeQuery($sql, $params, $types)->fetchOne(); + assert($count >= 0); + + return $count; } /** diff --git a/src/Persisters/Entity/EntityPersister.php b/src/Persisters/Entity/EntityPersister.php index 6b278a711d0..ad1c81147ce 100644 --- a/src/Persisters/Entity/EntityPersister.php +++ b/src/Persisters/Entity/EntityPersister.php @@ -125,6 +125,8 @@ public function delete(object $entity): bool; * Count entities (optionally filtered by a criteria) * * @param mixed[]|Criteria $criteria + * + * @psalm-return 0|positive-int */ public function count(array|Criteria $criteria = []): int; From cfc0655a1c9b5ffd5506172cb7642b6090aa5f7e Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 3 Sep 2024 18:44:06 +0200 Subject: [PATCH 418/475] Fix compatibility with DBAL 4.2 (#11592) --- tests/Performance/ArrayResultFactory.php | 18 -------- tests/Performance/EntityManagerFactory.php | 4 +- ...etchJoinArrayHydrationPerformanceBench.php | 4 +- ...oinFullObjectHydrationPerformanceBench.php | 4 +- ...pleQueryArrayHydrationPerformanceBench.php | 4 +- ...eryFullObjectHydrationPerformanceBench.php | 4 +- ...leQueryScalarHydrationPerformanceBench.php | 4 +- tests/Tests/Mocks/ArrayResultFactory.php | 42 +++++++++++++++++++ .../ORM/Functional/Ticket/GH6362Test.php | 5 +-- .../ORM/Functional/Ticket/GH9807Test.php | 5 +-- .../Tests/ORM/Hydration/HydrationTestCase.php | 4 +- .../ORM/Hydration/ObjectHydratorTest.php | 5 +-- tests/Tests/ORM/Query/QueryTest.php | 12 +++--- 13 files changed, 68 insertions(+), 47 deletions(-) delete mode 100644 tests/Performance/ArrayResultFactory.php create mode 100644 tests/Tests/Mocks/ArrayResultFactory.php diff --git a/tests/Performance/ArrayResultFactory.php b/tests/Performance/ArrayResultFactory.php deleted file mode 100644 index 72a2fad7ea6..00000000000 --- a/tests/Performance/ArrayResultFactory.php +++ /dev/null @@ -1,18 +0,0 @@ -result = ArrayResultFactory::createFromArray($resultSet); + $this->result = ArrayResultFactory::createWrapperResultFromArray($resultSet); $this->hydrator = new ArrayHydrator(EntityManagerFactory::getEntityManager([])); $this->rsm = new ResultSetMapping(); diff --git a/tests/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php index fad34c0521f..21fce4f4dff 100644 --- a/tests/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/MixedQueryFetchJoinFullObjectHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; @@ -49,7 +49,7 @@ public function init(): void ]; } - $this->result = ArrayResultFactory::createFromArray($resultSet); + $this->result = ArrayResultFactory::createWrapperResultFromArray($resultSet); $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([])); $this->rsm = new ResultSetMapping(); diff --git a/tests/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php index c51bac44a6f..e863107edf6 100644 --- a/tests/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ArrayHydrator; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; @@ -53,7 +53,7 @@ public function init(): void ]; } - $this->result = ArrayResultFactory::createFromArray($resultSet); + $this->result = ArrayResultFactory::createWrapperResultFromArray($resultSet); $this->hydrator = new ArrayHydrator(EntityManagerFactory::getEntityManager([])); $this->rsm = new ResultSetMapping(); diff --git a/tests/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php index 3b158c30373..8c1114ca07e 100644 --- a/tests/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/SimpleQueryFullObjectHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; @@ -44,7 +44,7 @@ public function init(): void ]; } - $this->result = ArrayResultFactory::createFromArray($resultSet); + $this->result = ArrayResultFactory::createWrapperResultFromArray($resultSet); $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([])); $this->rsm = new ResultSetMapping(); diff --git a/tests/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php index 0ed9fda0892..1761b9d3f80 100644 --- a/tests/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ScalarHydrator; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; @@ -53,7 +53,7 @@ public function init(): void ]; } - $this->result = ArrayResultFactory::createFromArray($resultSet); + $this->result = ArrayResultFactory::createWrapperResultFromArray($resultSet); $this->hydrator = new ScalarHydrator(EntityManagerFactory::getEntityManager([])); $this->rsm = new ResultSetMapping(); diff --git a/tests/Tests/Mocks/ArrayResultFactory.php b/tests/Tests/Mocks/ArrayResultFactory.php new file mode 100644 index 00000000000..56a8110c613 --- /dev/null +++ b/tests/Tests/Mocks/ArrayResultFactory.php @@ -0,0 +1,42 @@ +> $resultSet */ + public static function createDriverResultFromArray(array $resultSet): ArrayResult + { + if ((new ReflectionMethod(ArrayResult::class, '__construct'))->getNumberOfRequiredParameters() < 2) { + // DBAL < 4.2 + return new ArrayResult($resultSet); + } + + // DBAL 4.2+ + return new ArrayResult( + array_keys($resultSet[0] ?? []), + array_map(array_values(...), $resultSet), + ); + } + + /** @param list> $resultSet */ + public static function createWrapperResultFromArray(array $resultSet, Connection|null $connection = null): Result + { + return new Result( + self::createDriverResultFromArray($resultSet), + $connection ?? new Connection([], new Driver()), + ); + } +} diff --git a/tests/Tests/ORM/Functional/Ticket/GH6362Test.php b/tests/Tests/ORM/Functional/Ticket/GH6362Test.php index 9c45cc9885f..11f8f5ec632 100644 --- a/tests/Tests/ORM/Functional/Ticket/GH6362Test.php +++ b/tests/Tests/ORM/Functional/Ticket/GH6362Test.php @@ -5,9 +5,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\Common\Collections\Collection; -use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorColumn; @@ -19,6 +17,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\Group; @@ -78,7 +77,7 @@ public function testInheritanceJoinAlias(): void ], ]; - $stmt = new Result(new ArrayResult($resultSet), $this->createMock(Connection::class)); + $stmt = ArrayResultFactory::createWrapperResultFromArray($resultSet, $this->createMock(Connection::class)); $hydrator = new ObjectHydrator($this->_em); $result = $hydrator->hydrateAll($stmt, $rsm); diff --git a/tests/Tests/ORM/Functional/Ticket/GH9807Test.php b/tests/Tests/ORM/Functional/Ticket/GH9807Test.php index 9d8e8f1c51b..17b43256662 100644 --- a/tests/Tests/ORM/Functional/Ticket/GH9807Test.php +++ b/tests/Tests/ORM/Functional/Ticket/GH9807Test.php @@ -5,9 +5,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\Common\Collections\Collection; -use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\Column; @@ -15,6 +13,7 @@ use Doctrine\ORM\Mapping\GeneratedValue; use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\OrmFunctionalTestCase; final class GH9807Test extends OrmFunctionalTestCase @@ -63,7 +62,7 @@ public function testHydrateJoinedCollectionWithFirstNullishRow(): void ], ]; - $stmt = new Result(new ArrayResult($resultSet), $this->createMock(Connection::class)); + $stmt = ArrayResultFactory::createWrapperResultFromArray($resultSet, $this->createMock(Connection::class)); /** @var GH9807Main[] $result */ $result = $hydrator->hydrateAll($stmt, $rsm); diff --git a/tests/Tests/ORM/Hydration/HydrationTestCase.php b/tests/Tests/ORM/Hydration/HydrationTestCase.php index fdad779d060..4e8e9709257 100644 --- a/tests/Tests/ORM/Hydration/HydrationTestCase.php +++ b/tests/Tests/ORM/Hydration/HydrationTestCase.php @@ -4,9 +4,9 @@ namespace Doctrine\Tests\ORM\Hydration; -use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Result; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\OrmTestCase; class HydrationTestCase extends OrmTestCase @@ -22,6 +22,6 @@ protected function setUp(): void protected function createResultMock(array $resultSet): Result { - return new Result(new ArrayResult($resultSet), $this->entityManager->getConnection()); + return ArrayResultFactory::createWrapperResultFromArray($resultSet, $this->entityManager->getConnection()); } } diff --git a/tests/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Tests/ORM/Hydration/ObjectHydratorTest.php index 977028da875..0a1f369bd1f 100644 --- a/tests/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -4,9 +4,7 @@ namespace Doctrine\Tests\ORM\Hydration; -use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Result; use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Mapping\ClassMetadata; @@ -14,6 +12,7 @@ use Doctrine\ORM\Proxy\InternalProxy; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsComment; @@ -1337,7 +1336,7 @@ public function testResultIterationWithAliasedUserEntity(): void $hydrator = new ObjectHydrator($this->entityManager); $rowNum = 0; $iterableResult = $hydrator->toIterable( - new Result(new ArrayResult($resultSet), $this->createMock(Connection::class)), + ArrayResultFactory::createWrapperResultFromArray($resultSet, $this->createMock(Connection::class)), $rsm, ); diff --git a/tests/Tests/ORM/Query/QueryTest.php b/tests/Tests/ORM/Query/QueryTest.php index 961aafd32ed..03acc8ce0d0 100644 --- a/tests/Tests/ORM/Query/QueryTest.php +++ b/tests/Tests/ORM/Query/QueryTest.php @@ -8,7 +8,6 @@ use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\ArrayParameterType; -use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Result; @@ -22,6 +21,7 @@ use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\UnitOfWork; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsGroup; @@ -361,10 +361,10 @@ public function testResultCacheCaching(): void { $entityManager = $this->createTestEntityManagerWithConnection( $this->createConnection( - new ArrayResult([ + ArrayResultFactory::createDriverResultFromArray([ ['id_0' => 1], ]), - new ArrayResult([]), + ArrayResultFactory::createDriverResultFromArray([]), ), ); @@ -399,14 +399,14 @@ public function testResultCacheEviction(): void { $entityManager = $this->createTestEntityManagerWithConnection( $this->createConnection( - new ArrayResult([ + ArrayResultFactory::createDriverResultFromArray([ ['id_0' => 1], ]), - new ArrayResult([ + ArrayResultFactory::createDriverResultFromArray([ ['id_0' => 1], ['id_0' => 2], ]), - new ArrayResult([ + ArrayResultFactory::createDriverResultFromArray([ ['id_0' => 1], ]), ), From e6961bd9684048bd98ef6c8011f56c5096a9a614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 27 Sep 2024 19:19:05 +0200 Subject: [PATCH 419/475] Install guides-cli as a dev requirement It is better if contributors can check the docs by themselves. --- .github/workflows/documentation.yml | 11 ----------- composer.json | 1 + 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 65cbad613b2..cccf523278b 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -29,17 +29,6 @@ jobs: coverage: "none" php-version: "8.3" - - name: "Remove existing composer file" - run: "rm composer.json" - - - name: "Require phpdocumentor/guides-cli" - run: "composer require --dev phpdocumentor/guides-cli --no-update" - - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v3" - with: - dependency-versions: "highest" - - name: "Add orphan metadata where needed" run: | printf '%s\n\n%s\n' ":orphan:" "$(cat docs/en/sidebar.rst)" > docs/en/sidebar.rst diff --git a/composer.json b/composer.json index 2a751261861..e904efe6f9c 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "require-dev": { "doctrine/coding-standard": "^12.0", "phpbench/phpbench": "^1.0", + "phpdocumentor/guides-cli": "^1.4", "phpstan/phpstan": "1.11.1", "phpunit/phpunit": "^10.4.0", "psr/log": "^1 || ^2 || ^3", From 7f0a181e39175788b513cf2d69e315d24da08dc4 Mon Sep 17 00:00:00 2001 From: eltharin Date: Wed, 2 Oct 2024 09:48:03 +0200 Subject: [PATCH 420/475] add nested new in EBNF documentation --- docs/en/reference/dql-doctrine-query-language.rst | 2 +- src/Query/Parser.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index c2b31cd326d..ab3cb138889 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -1627,7 +1627,7 @@ Select Expressions PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}" NewObjectExpression ::= "NEW" AbstractSchemaName "(" NewObjectArg {"," NewObjectArg}* ")" - NewObjectArg ::= ScalarExpression | "(" Subselect ")" + NewObjectArg ::= ScalarExpression | "(" Subselect ")" | NewObjectExpression Conditional Expressions ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 38858cbf876..875783c87d4 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -1765,7 +1765,7 @@ public function NewObjectExpression(): AST\NewObjectExpression } /** - * NewObjectArg ::= ScalarExpression | "(" Subselect ")" + * NewObjectArg ::= ScalarExpression | "(" Subselect ")" | NewObjectExpression */ public function NewObjectArg(): mixed { From 4a3c7f05bf4319e17f355dcea2fdfa19d232ed5a Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 9 Oct 2024 17:13:58 +0200 Subject: [PATCH 421/475] Revert "Remove unused exception" This reverts commit 689da1f251957f49f1126b92bcaf8fb12df6f56e. --- src/Query/QueryException.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Query/QueryException.php b/src/Query/QueryException.php index ae945b167fe..5c82b20a7a4 100644 --- a/src/Query/QueryException.php +++ b/src/Query/QueryException.php @@ -88,6 +88,15 @@ public static function iterateWithFetchJoinCollectionNotAllowed(AssociationMappi ); } + public static function partialObjectsAreDangerous(): self + { + return new self( + 'Loading partial objects is dangerous. Fetch full objects or consider ' . + 'using a different fetch mode. If you really want partial objects, ' . + 'set the doctrine.forcePartialLoad query hint to TRUE.', + ); + } + /** * @param string[] $assoc * @psalm-param array $assoc From f71725575c605cb77ecc29c7131d5b39ab9e03ef Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 9 Oct 2024 17:34:59 +0200 Subject: [PATCH 422/475] Revert undprecate PARTIAL for objects in DQL. --- docs/en/index.rst | 1 + .../reference/dql-doctrine-query-language.rst | 24 ++++- docs/en/reference/partial-objects.rst | 98 +++++++++++++++++++ docs/en/sidebar.rst | 1 + src/Cache/DefaultQueryCache.php | 5 + src/Cache/Exception/FeatureNotImplemented.php | 5 + src/Decorator/EntityManagerDecorator.php | 1 + src/EntityManager.php | 1 + src/Query.php | 8 ++ src/Query/Parser.php | 5 +- src/Query/SqlWalker.php | 40 +++++--- src/UnitOfWork.php | 17 +++- ...PartialObjectHydrationPerformanceBench.php | 84 ++++++++++++++++ ...PartialObjectHydrationPerformanceBench.php | 72 ++++++++++++++ .../OneToOneUnidirectionalAssociationTest.php | 14 +++ .../ORM/Functional/PostLoadEventTest.php | 21 ++++ .../SecondLevelCacheQueryCacheTest.php | 25 +++++ .../ORM/Functional/Ticket/DDC163Test.php | 2 +- .../ORM/Functional/Ticket/DDC2519Test.php | 76 ++++++++++++++ .../ORM/Functional/Ticket/GH8443Test.php | 32 ++++++ .../Tests/ORM/Functional/ValueObjectsTest.php | 54 +++++++++- .../ORM/Query/LanguageRecognitionTest.php | 2 - tests/Tests/ORM/Query/ParserTest.php | 9 -- .../ORM/Query/SelectSqlGenerationTest.php | 82 +++++++++++++--- .../LimitSubqueryOutputWalkerTest.php | 2 +- tests/Tests/ORM/UnitOfWorkTest.php | 9 -- 26 files changed, 629 insertions(+), 61 deletions(-) create mode 100644 docs/en/reference/partial-objects.rst create mode 100644 tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php create mode 100644 tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php create mode 100644 tests/Tests/ORM/Functional/Ticket/DDC2519Test.php diff --git a/docs/en/index.rst b/docs/en/index.rst index 4d23062cd0d..32f8c070175 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -74,6 +74,7 @@ Advanced Topics * :doc:`Improving Performance ` * :doc:`Caching ` * :doc:`Partial Hydration ` +* :doc:`Partial Objects ` * :doc:`Change Tracking Policies ` * :doc:`Best Practices ` * :doc:`Metadata Drivers ` diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index ab3cb138889..29d1a163d78 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -533,14 +533,23 @@ back. Instead, you receive only arrays as a flat rectangular result set, similar to how you would if you were just using SQL directly and joining some data. -If you want to select a partial number of fields for hydration entity in -the context of array hydration and joins you can use the ``partial`` DQL keyword: +If you want to select partial objects or fields in array hydration you can use the ``partial`` +DQL keyword: + +.. code-block:: php + + createQuery('SELECT partial u.{id, username} FROM CmsUser u'); + $users = $query->getResult(); // array of partially loaded CmsUser objects + +You use the partial syntax when joining as well: .. code-block:: php createQuery('SELECT partial u.{id, username}, partial a.{id, name} FROM CmsUser u JOIN u.articles a'); - $users = $query->getArrayResult(); // array of partially loaded CmsUser and CmsArticle fields + $usersArray = $query->getArrayResult(); // array of partially loaded CmsUser and CmsArticle fields + $users = $query->getResult(); // array of partially loaded CmsUser objects "NEW" Operator Syntax ^^^^^^^^^^^^^^^^^^^^^ @@ -1370,6 +1379,15 @@ exist mostly internal query hints that are not be consumed in userland. However the following few hints are to be used in userland: + +- ``Query::HINT_FORCE_PARTIAL_LOAD`` - Allows to hydrate objects + although not all their columns are fetched. This query hint can be + used to handle memory consumption problems with large result-sets + that contain char or binary data. Doctrine has no way of implicitly + reloading this data. Partially loaded objects have to be passed to + ``EntityManager::refresh()`` if they are to be reloaded fully from + the database. This query hint is deprecated and will be removed + in the future (\ `Details `_) - ``Query::HINT_REFRESH`` - This query is used internally by ``EntityManager::refresh()`` and can be used in userland as well. If you specify this hint and a query returns the data for an entity diff --git a/docs/en/reference/partial-objects.rst b/docs/en/reference/partial-objects.rst new file mode 100644 index 00000000000..51f173adf6c --- /dev/null +++ b/docs/en/reference/partial-objects.rst @@ -0,0 +1,98 @@ +Partial Objects +=============== + + +.. note:: + + Creating Partial Objects through DQL is deprecated and + will be removed in the future, use data transfer object + support in DQL instead. (\ `Details + `_) + +A partial object is an object whose state is not fully initialized +after being reconstituted from the database and that is +disconnected from the rest of its data. The following section will +describe why partial objects are problematic and what the approach +of Doctrine2 to this problem is. + +.. note:: + + The partial object problem in general does not apply to + methods or queries where you do not retrieve the query result as + objects. Examples are: ``Query#getArrayResult()``, + ``Query#getScalarResult()``, ``Query#getSingleScalarResult()``, + etc. + +.. warning:: + + Use of partial objects is tricky. Fields that are not retrieved + from the database will not be updated by the UnitOfWork even if they + get changed in your objects. You can only promote a partial object + to a fully-loaded object by calling ``EntityManager#refresh()`` + or a DQL query with the refresh flag. + + +What is the problem? +-------------------- + +In short, partial objects are problematic because they are usually +objects with broken invariants. As such, code that uses these +partial objects tends to be very fragile and either needs to "know" +which fields or methods can be safely accessed or add checks around +every field access or method invocation. The same holds true for +the internals, i.e. the method implementations, of such objects. +You usually simply assume the state you need in the method is +available, after all you properly constructed this object before +you pushed it into the database, right? These blind assumptions can +quickly lead to null reference errors when working with such +partial objects. + +It gets worse with the scenario of an optional association (0..1 to +1). When the associated field is NULL, you don't know whether this +object does not have an associated object or whether it was simply +not loaded when the owning object was loaded from the database. + +These are reasons why many ORMs do not allow partial objects at all +and instead you always have to load an object with all its fields +(associations being proxied). One secure way to allow partial +objects is if the programming language/platform allows the ORM tool +to hook deeply into the object and instrument it in such a way that +individual fields (not only associations) can be loaded lazily on +first access. This is possible in Java, for example, through +bytecode instrumentation. In PHP though this is not possible, so +there is no way to have "secure" partial objects in an ORM with +transparent persistence. + +Doctrine, by default, does not allow partial objects. That means, +any query that only selects partial object data and wants to +retrieve the result as objects (i.e. ``Query#getResult()``) will +raise an exception telling you that partial objects are dangerous. +If you want to force a query to return you partial objects, +possibly as a performance tweak, you can use the ``partial`` +keyword as follows: + +.. code-block:: php + + createQuery("select partial u.{id,name} from MyApp\Domain\User u"); + +You can also get a partial reference instead of a proxy reference by +calling: + +.. code-block:: php + + getPartialReference('MyApp\Domain\User', 1); + +Partial references are objects with only the identifiers set as they +are passed to the second argument of the ``getPartialReference()`` method. +All other fields are null. + +When should I force partial objects? +------------------------------------ + +Mainly for optimization purposes, but be careful of premature +optimization as partial objects lead to potentially more fragile +code. + + diff --git a/docs/en/sidebar.rst b/docs/en/sidebar.rst index 7ccdfb3a054..f52801c6b37 100644 --- a/docs/en/sidebar.rst +++ b/docs/en/sidebar.rst @@ -38,6 +38,7 @@ reference/native-sql reference/change-tracking-policies reference/partial-hydration + reference/partial-objects reference/attributes-reference reference/xml-mapping reference/php-mapping diff --git a/src/Cache/DefaultQueryCache.php b/src/Cache/DefaultQueryCache.php index f3bb8ac95c8..08e703cd4b0 100644 --- a/src/Cache/DefaultQueryCache.php +++ b/src/Cache/DefaultQueryCache.php @@ -16,6 +16,7 @@ use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\UnitOfWork; use function array_map; @@ -210,6 +211,10 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, mixed $result, ar throw FeatureNotImplemented::nonSelectStatements(); } + if (($hints[SqlWalker::HINT_PARTIAL] ?? false) === true || ($hints[Query::HINT_FORCE_PARTIAL_LOAD] ?? false) === true) { + throw FeatureNotImplemented::partialEntities(); + } + if (! ($key->cacheMode & Cache::MODE_PUT)) { return false; } diff --git a/src/Cache/Exception/FeatureNotImplemented.php b/src/Cache/Exception/FeatureNotImplemented.php index 8767d574190..7bae90b775d 100644 --- a/src/Cache/Exception/FeatureNotImplemented.php +++ b/src/Cache/Exception/FeatureNotImplemented.php @@ -20,4 +20,9 @@ public static function nonSelectStatements(): self { return new self('Second-level cache query supports only select statements.'); } + + public static function partialEntities(): self + { + return new self('Second level cache does not support partial entities.'); + } } diff --git a/src/Decorator/EntityManagerDecorator.php b/src/Decorator/EntityManagerDecorator.php index 6f1b0419686..212e01e511b 100644 --- a/src/Decorator/EntityManagerDecorator.php +++ b/src/Decorator/EntityManagerDecorator.php @@ -8,6 +8,7 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/EntityManager.php b/src/EntityManager.php index 8045ac2f5e3..9de636e5b75 100644 --- a/src/EntityManager.php +++ b/src/EntityManager.php @@ -9,6 +9,7 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Exception\InvalidHydrationMode; use Doctrine\ORM\Exception\MissingIdentifierField; diff --git a/src/Query.php b/src/Query.php index a869316d3e7..d8a88e8fe83 100644 --- a/src/Query.php +++ b/src/Query.php @@ -70,6 +70,14 @@ class Query extends AbstractQuery */ public const HINT_REFRESH_ENTITY = 'doctrine.refresh.entity'; + /** + * The forcePartialLoad query hint forces a particular query to return + * partial objects. + * + * @todo Rename: HINT_OPTIMIZE + */ + public const HINT_FORCE_PARTIAL_LOAD = 'doctrine.forcePartialLoad'; + /** * The includeMetaColumns query hint causes meta columns like foreign keys and * discriminator columns to be selected and returned as part of the query result. diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 875783c87d4..12fe0c97691 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -5,6 +5,7 @@ namespace Doctrine\ORM\Query; use Doctrine\Common\Lexer\Token; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Mapping\AssociationMapping; @@ -1674,10 +1675,6 @@ public function JoinAssociationDeclaration(): AST\JoinAssociationDeclaration */ public function PartialObjectExpression(): AST\PartialObjectExpression { - if ($this->query->getHydrationMode() === Query::HYDRATE_OBJECT) { - throw HydrationException::partialObjectHydrationDisallowed(); - } - $this->match(TokenType::T_PARTIAL); $partialFieldSet = []; diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index 46296e719e7..9beeff337be 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -321,6 +321,11 @@ private function generateClassTableInheritanceJoins( $sql .= implode(' AND ', array_filter($sqlParts)); } + // Ignore subclassing inclusion if partial objects is disallowed + if ($this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { + return $sql; + } + // LEFT JOIN child class tables foreach ($class->subClasses as $subClassName) { $subClass = $this->em->getClassMetadata($subClassName); @@ -659,7 +664,8 @@ public function walkSelectClause(AST\SelectClause $selectClause): string $this->query->setHint(self::HINT_DISTINCT, true); } - $addMetaColumns = $this->query->getHydrationMode() === Query::HYDRATE_OBJECT + $addMetaColumns = ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD) && + $this->query->getHydrationMode() === Query::HYDRATE_OBJECT || $this->query->getHint(Query::HINT_INCLUDE_META_COLUMNS); foreach ($this->selectedClasses as $selectedClass) { @@ -1398,28 +1404,30 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st // 1) on Single Table Inheritance: always, since its marginal overhead // 2) on Class Table Inheritance only if partial objects are disallowed, // since it requires outer joining subtables. - foreach ($class->subClasses as $subClassName) { - $subClass = $this->em->getClassMetadata($subClassName); - $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); + if ($class->isInheritanceTypeSingleTable() || ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { + foreach ($class->subClasses as $subClassName) { + $subClass = $this->em->getClassMetadata($subClassName); + $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); - foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if (isset($mapping->inherited) || ($partialFieldSet && ! in_array($fieldName, $partialFieldSet, true))) { - continue; - } + foreach ($subClass->fieldMappings as $fieldName => $mapping) { + if (isset($mapping->inherited) || ($partialFieldSet && !in_array($fieldName, $partialFieldSet, true))) { + continue; + } - $columnAlias = $this->getSQLColumnAlias($mapping->columnName); - $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform); + $columnAlias = $this->getSQLColumnAlias($mapping->columnName); + $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform); - $col = $sqlTableAlias . '.' . $quotedColumnName; + $col = $sqlTableAlias . '.' . $quotedColumnName; - $type = Type::getType($mapping->type); - $col = $type->convertToPHPValueSQL($col, $this->platform); + $type = Type::getType($mapping->type); + $col = $type->convertToPHPValueSQL($col, $this->platform); - $sqlParts[] = $col . ' AS ' . $columnAlias; + $sqlParts[] = $col . ' AS ' . $columnAlias; - $this->scalarResultAliasMap[$resultAlias][] = $columnAlias; + $this->scalarResultAliasMap[$resultAlias][] = $columnAlias; - $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $subClassName); + $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $subClassName); + } } } diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 85a33620aa8..811aa895b42 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -12,6 +12,7 @@ use Doctrine\DBAL; use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; use Doctrine\DBAL\LockMode; +use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\Persister\CachedPersister; use Doctrine\ORM\Event\ListenersInvoker; use Doctrine\ORM\Event\OnClearEventArgs; @@ -2355,10 +2356,6 @@ public function isCollectionScheduledForDeletion(PersistentCollection $coll): bo */ public function createEntity(string $className, array $data, array &$hints = []): object { - if (isset($hints[SqlWalker::HINT_PARTIAL])) { - throw HydrationException::partialObjectHydrationDisallowed(); - } - $class = $this->em->getClassMetadata($className); $id = $this->identifierFlattener->flattenIdentifier($class, $data); @@ -2417,6 +2414,18 @@ public function createEntity(string $className, array $data, array &$hints = []) unset($this->eagerLoadingEntities[$class->rootEntityName]); } + // Properly initialize any unfetched associations, if partial objects are not allowed. + if (isset($hints[Query::HINT_FORCE_PARTIAL_LOAD])) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/8471', + 'Partial Objects are deprecated (here entity %s)', + $className, + ); + + return $entity; + } + foreach ($class->associationMappings as $field => $assoc) { // Check if the association is not among the fetch-joined associations already. if (isset($hints['fetchAlias'], $hints['fetched'][$hints['fetchAlias']][$field])) { diff --git a/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php new file mode 100644 index 00000000000..6a1638afcf5 --- /dev/null +++ b/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php @@ -0,0 +1,84 @@ + '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + ], + [ + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + ], + [ + 'u__id' => '2', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + ], + ]; + + for ($i = 4; $i < 2000; ++$i) { + $resultSet[] = [ + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + 'sclr0' => 'JWAGE' . $i, + 'p__phonenumber' => '91', + ]; + } + + $this->result = ArrayResultFactory::createFromArray($resultSet); + $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([])); + $this->rsm = new ResultSetMapping(); + + $this->rsm->addEntityResult(CmsUser::class, 'u'); + $this->rsm->addJoinedEntityResult(CmsPhonenumber::class, 'p', 'u', 'phonenumbers'); + $this->rsm->addFieldResult('u', 'u__id', 'id'); + $this->rsm->addFieldResult('u', 'u__status', 'status'); + $this->rsm->addFieldResult('u', 'u__username', 'username'); + $this->rsm->addFieldResult('u', 'u__name', 'name'); + $this->rsm->addScalarResult('sclr0', 'nameUpper'); + $this->rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + } + + public function benchHydration(): void + { + $this->hydrator->hydrateAll($this->result, $this->rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); + } +} diff --git a/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php new file mode 100644 index 00000000000..b894068eb2c --- /dev/null +++ b/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php @@ -0,0 +1,72 @@ + '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ], + [ + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ], + [ + 'u__id' => '2', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ], + ]; + + for ($i = 4; $i < 10000; ++$i) { + $resultSet[] = [ + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + ]; + } + + $this->result = ArrayResultFactory::createFromArray($resultSet); + $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([])); + $this->rsm = new ResultSetMapping(); + + $this->rsm->addEntityResult(CmsUser::class, 'u'); + $this->rsm->addFieldResult('u', 'u__id', 'id'); + $this->rsm->addFieldResult('u', 'u__status', 'status'); + $this->rsm->addFieldResult('u', 'u__username', 'username'); + $this->rsm->addFieldResult('u', 'u__name', 'name'); + } + + public function benchHydration(): void + { + $this->hydrator->hydrateAll($this->result, $this->rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]); + } +} diff --git a/tests/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index cdb34bfcdbf..b2baaaa254e 100644 --- a/tests/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Query; use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\Models\ECommerce\ECommerceShipping; use Doctrine\Tests\OrmFunctionalTestCase; @@ -78,6 +79,19 @@ public function testLazyLoadsObjects(): void self::assertEquals(1, $product->getShipping()->getDays()); } + public function testDoesNotLazyLoadObjectsIfConfigurationDoesNotAllowIt(): void + { + $this->createFixture(); + + $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); + $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + + $result = $query->getResult(); + $product = $result[0]; + + self::assertNull($product->getShipping()); + } + protected function createFixture(): void { $product = new ECommerceProduct(); diff --git a/tests/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Tests/ORM/Functional/PostLoadEventTest.php index 839a8313983..d76a044fd05 100644 --- a/tests/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Tests/ORM/Functional/PostLoadEventTest.php @@ -136,6 +136,27 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void $userProxy->getName(); } + public function testLoadedProxyPartialShouldTriggerEvent(): void + { + $eventManager = $this->_em->getEventManager(); + + // Should not be invoked during getReference call + $mockListener = $this->createMock(PostLoadListener::class); + + // CmsUser (partially loaded), CmsAddress (inverse ToOne), 2 CmsPhonenumber + $mockListener + ->expects(self::exactly(4)) + ->method('postLoad') + ->will(self::returnValue(true)); + + $eventManager->addEventListener([Events::postLoad], $mockListener); + + $query = $this->_em->createQuery('SELECT PARTIAL u.{id, name}, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p WHERE u.id = :id'); + + $query->setParameter('id', $this->userId); + $query->getResult(); + } + public function testLoadedProxyAssociationToOneShouldTriggerEvent(): void { $user = $this->_em->find(CmsUser::class, $this->userId); diff --git a/tests/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index a3350aa5e6c..e2dec649342 100644 --- a/tests/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -1086,6 +1086,31 @@ public function testHintClearEntityRegionDeleteStatement(): void self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId())); } + public function testCacheablePartialQueryException(): void + { + $this->expectException(CacheException::class); + $this->expectExceptionMessage('Second level cache does not support partial entities.'); + $this->evictRegions(); + $this->loadFixturesCountries(); + + $this->_em->createQuery('SELECT PARTIAL c.{id} FROM Doctrine\Tests\Models\Cache\Country c') + ->setCacheable(true) + ->getResult(); + } + + public function testCacheableForcePartialLoadHintQueryException(): void + { + $this->expectException(CacheException::class); + $this->expectExceptionMessage('Second level cache does not support partial entities.'); + $this->evictRegions(); + $this->loadFixturesCountries(); + + $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Cache\Country c') + ->setCacheable(true) + ->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) + ->getResult(); + } + public function testNonCacheableQueryDeleteStatementException(): void { $this->expectException(CacheException::class); diff --git a/tests/Tests/ORM/Functional/Ticket/DDC163Test.php b/tests/Tests/ORM/Functional/Ticket/DDC163Test.php index 83aebb4dcae..6c0c7c94fe3 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC163Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC163Test.php @@ -46,7 +46,7 @@ public function testQueryWithOrConditionUsingTwoRelationOnSameEntity(): void $this->_em->flush(); $this->_em->clear(); - $dql = 'SELECT person.name as person_name, spouse.name as spouse_name,friend.name as friend_name + $dql = 'SELECT PARTIAL person.{id,name}, PARTIAL spouse.{id,name}, PARTIAL friend.{id,name} FROM Doctrine\Tests\Models\Company\CompanyPerson person LEFT JOIN person.spouse spouse LEFT JOIN person.friends friend diff --git a/tests/Tests/ORM/Functional/Ticket/DDC2519Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2519Test.php new file mode 100644 index 00000000000..b8dfba13b9c --- /dev/null +++ b/tests/Tests/ORM/Functional/Ticket/DDC2519Test.php @@ -0,0 +1,76 @@ +useModelSet('legacy'); + + parent::setUp(); + + $this->loadFixture(); + } + + #[Group('DDC-2519')] + public function testIssue(): void + { + $dql = 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l'; + $result = $this->_em->createQuery($dql)->getResult(); + + self::assertCount(2, $result); + self::assertInstanceOf(LegacyUserReference::class, $result[0]); + self::assertInstanceOf(LegacyUserReference::class, $result[1]); + + self::assertInstanceOf(LegacyUser::class, $result[0]->source()); + self::assertInstanceOf(LegacyUser::class, $result[0]->target()); + self::assertInstanceOf(LegacyUser::class, $result[1]->source()); + self::assertInstanceOf(LegacyUser::class, $result[1]->target()); + + self::assertTrue($this->isUninitializedObject($result[0]->target())); + self::assertTrue($this->isUninitializedObject($result[0]->source())); + self::assertTrue($this->isUninitializedObject($result[1]->target())); + self::assertTrue($this->isUninitializedObject($result[1]->source())); + + self::assertNotNull($result[0]->source()->getId()); + self::assertNotNull($result[0]->target()->getId()); + self::assertNotNull($result[1]->source()->getId()); + self::assertNotNull($result[1]->target()->getId()); + } + + public function loadFixture(): void + { + $user1 = new LegacyUser(); + $user1->username = 'FabioBatSilva'; + $user1->name = 'Fabio B. Silva'; + + $user2 = new LegacyUser(); + $user2->username = 'doctrinebot'; + $user2->name = 'Doctrine Bot'; + + $user3 = new LegacyUser(); + $user3->username = 'test'; + $user3->name = 'Tester'; + + $this->_em->persist($user1); + $this->_em->persist($user2); + $this->_em->persist($user3); + + $this->_em->flush(); + + $this->_em->persist(new LegacyUserReference($user1, $user2, 'foo')); + $this->_em->persist(new LegacyUserReference($user1, $user3, 'bar')); + + $this->_em->flush(); + $this->_em->clear(); + } +} diff --git a/tests/Tests/ORM/Functional/Ticket/GH8443Test.php b/tests/Tests/ORM/Functional/Ticket/GH8443Test.php index 0b5352a6ea8..44695f1856e 100644 --- a/tests/Tests/ORM/Functional/Ticket/GH8443Test.php +++ b/tests/Tests/ORM/Functional/Ticket/GH8443Test.php @@ -14,6 +14,9 @@ use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; use Doctrine\ORM\Mapping\Table; +use Doctrine\ORM\Query; +use Doctrine\Tests\Models\Company\CompanyManager; +use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\Group; @@ -30,6 +33,35 @@ protected function setUp(): void $this->createSchemaForModels(GH8443Foo::class); } + #[Group('GH-8443')] + public function testJoinRootEntityWithForcePartialLoad(): void + { + $person = new CompanyPerson(); + $person->setName('John'); + + $manager = new CompanyManager(); + $manager->setName('Adam'); + $manager->setSalary(1000); + $manager->setDepartment('IT'); + $manager->setTitle('manager'); + + $manager->setSpouse($person); + + $this->_em->persist($person); + $this->_em->persist($manager); + $this->_em->flush(); + $this->_em->clear(); + + $manager = $this->_em->createQuery( + "SELECT m from Doctrine\Tests\Models\Company\CompanyManager m + JOIN m.spouse s + WITH s.name = 'John'", + )->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true)->getSingleResult(); + $this->_em->refresh($manager); + + $this->assertEquals('John', $manager->getSpouse()->getName()); + } + #[Group('GH-8443')] public function testJoinRootEntityWithOnlyOneEntityInHierarchy(): void { diff --git a/tests/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Tests/ORM/Functional/ValueObjectsTest.php index 6656d916ee0..3186e71d357 100644 --- a/tests/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Tests/ORM/Functional/ValueObjectsTest.php @@ -209,6 +209,58 @@ public function testDqlOnEmbeddedObjectsField(): void self::assertNull($this->_em->find(DDC93Person::class, $person->id)); } + public function testPartialDqlOnEmbeddedObjectsField(): void + { + $person = new DDC93Person('Karl', new DDC93Address('Foo', '12345', 'Gosport', new DDC93Country('England'))); + $this->_em->persist($person); + $this->_em->flush(); + $this->_em->clear(); + + // Prove that the entity was persisted correctly. + $dql = 'SELECT p FROM ' . __NAMESPACE__ . '\\DDC93Person p WHERE p.name = :name'; + + $person = $this->_em->createQuery($dql) + ->setParameter('name', 'Karl') + ->getSingleResult(); + + self::assertEquals('Gosport', $person->address->city); + self::assertEquals('Foo', $person->address->street); + self::assertEquals('12345', $person->address->zip); + self::assertEquals('England', $person->address->country->name); + + // Clear the EM and prove that the embeddable can be the subject of a partial query. + $this->_em->clear(); + + $dql = 'SELECT PARTIAL p.{id,address.city} FROM ' . __NAMESPACE__ . '\\DDC93Person p WHERE p.name = :name'; + + $person = $this->_em->createQuery($dql) + ->setParameter('name', 'Karl') + ->getSingleResult(); + + // Selected field must be equal, all other fields must be null. + self::assertEquals('Gosport', $person->address->city); + self::assertNull($person->address->street); + self::assertNull($person->address->zip); + self::assertNull($person->address->country); + self::assertNull($person->name); + + // Clear the EM and prove that the embeddable can be the subject of a partial query regardless of attributes positions. + $this->_em->clear(); + + $dql = 'SELECT PARTIAL p.{address.city, id} FROM ' . __NAMESPACE__ . '\\DDC93Person p WHERE p.name = :name'; + + $person = $this->_em->createQuery($dql) + ->setParameter('name', 'Karl') + ->getSingleResult(); + + // Selected field must be equal, all other fields must be null. + self::assertEquals('Gosport', $person->address->city); + self::assertNull($person->address->street); + self::assertNull($person->address->zip); + self::assertNull($person->address->country); + self::assertNull($person->name); + } + public function testDqlWithNonExistentEmbeddableField(): void { $this->expectException(QueryException::class); @@ -224,7 +276,7 @@ public function testPartialDqlWithNonExistentEmbeddableField(): void $this->expectExceptionMessage("no mapped field named 'address.asdfasdf'"); $this->_em->createQuery('SELECT PARTIAL p.{id,address.asdfasdf} FROM ' . __NAMESPACE__ . '\\DDC93Person p') - ->getArrayResult(); + ->execute(); } public function testEmbeddableWithInheritance(): void diff --git a/tests/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Tests/ORM/Query/LanguageRecognitionTest.php index ec57b1f1382..de212ebdda5 100644 --- a/tests/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Tests/ORM/Query/LanguageRecognitionTest.php @@ -532,13 +532,11 @@ public function testUnknownAbstractSchemaName(): void public function testCorrectPartialObjectLoad(): void { - $this->hydrationMode = AbstractQuery::HYDRATE_ARRAY; $this->assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); } public function testIncorrectPartialObjectLoadBecauseOfMissingIdentifier(): void { - $this->hydrationMode = AbstractQuery::HYDRATE_ARRAY; $this->assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); } diff --git a/tests/Tests/ORM/Query/ParserTest.php b/tests/Tests/ORM/Query/ParserTest.php index 6290bbc4dab..ed75be517b0 100644 --- a/tests/Tests/ORM/Query/ParserTest.php +++ b/tests/Tests/ORM/Query/ParserTest.php @@ -116,15 +116,6 @@ public function testNullLookahead(): void $parser->match(TokenType::T_SELECT); } - public function testPartialExpressionWithObjectHydratorThrows(): void - { - $this->expectException(HydrationException::class); - $this->expectExceptionMessage('Hydration of entity objects is not allowed when DQL PARTIAL keyword is used.'); - - $parser = $this->createParser(CmsUser::class); - $parser->PartialObjectExpression(); - } - private function createParser(string $dql): Parser { $query = new Query($this->getTestEntityManager()); diff --git a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php index 3969fe51636..6b7d9585462 100644 --- a/tests/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -1335,8 +1335,6 @@ public function testIdentityFunctionWithCompositePrimaryKey(): void #[Group('DDC-2519')] public function testPartialWithAssociationIdentifier(): void { - $this->hydrationMode = ORMQuery::HYDRATE_ARRAY; - $this->assertSqlGeneration( 'SELECT PARTIAL l.{_source, _target} FROM Doctrine\Tests\Models\Legacy\LegacyUserReference l', 'SELECT l0_.iUserIdSource AS iUserIdSource_0, l0_.iUserIdTarget AS iUserIdTarget_1 FROM legacy_users_reference l0_', @@ -1382,58 +1380,122 @@ public function testIdentityFunctionDoesNotAcceptStateField(): void } #[Group('DDC-1389')] - public function testInheritanceTypeJoinInRootClass(): void + public function testInheritanceTypeJoinInRootClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c1_.car_id AS car_id_8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id', + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], ); } #[Group('DDC-1389')] - public function testInheritanceTypeJoinInChildClass(): void + public function testInheritanceTypeJoinInRootClassWithEnabledForcePartialLoad(): void + { + $this->assertSqlGeneration( + 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', + 'SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_', + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], + ); + } + + #[Group('DDC-1389')] + public function testInheritanceTypeJoinInChildClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id', + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], + ); + } + + #[Group('DDC-1389')] + public function testInheritanceTypeJoinInChildClassWithEnabledForcePartialLoad(): void + { + $this->assertSqlGeneration( + 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', + 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id', + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } #[Group('DDC-1389')] - public function testInheritanceTypeJoinInLeafClass(): void + public function testInheritanceTypeJoinInLeafClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], + ); + } + + #[Group('DDC-1389')] + public function testInheritanceTypeJoinInLeafClassWithEnabledForcePartialLoad(): void + { + $this->assertSqlGeneration( + 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', + 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInRootClass(): void + public function testInheritanceTypeSingleTableInRootClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6, c0_.salesPerson_id AS salesPerson_id_7 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], + ); + } + + #[Group('DDC-1389')] + public function testInheritanceTypeSingleTableInRootClassWithEnabledForcePartialLoad(): void + { + $this->assertSqlGeneration( + 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } #[Group('DDC-1389')] public function testInheritanceTypeSingleTableInChildClassWithDisabledForcePartialLoad(): void { - $this->hydrationMode = ORMQuery::HYDRATE_ARRAY; + $this->assertSqlGeneration( + 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], + ); + } + #[Group('DDC-1389')] + public function testInheritanceTypeSingleTableInChildClassWithEnabledForcePartialLoad(): void + { $this->assertSqlGeneration( 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } #[Group('DDC-1389')] - public function testInheritanceTypeSingleTableInLeafClass(): void + public function testInheritanceTypeSingleTableInLeafClassWithDisabledForcePartialLoad(): void { $this->assertSqlGeneration( 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => false], + ); + } + + #[Group('DDC-1389')] + public function testInheritanceTypeSingleTableInLeafClassWithEnabledForcePartialLoad(): void + { + $this->assertSqlGeneration( + 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', + "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", + [ORMQuery::HINT_FORCE_PARTIAL_LOAD => true], ); } @@ -1712,8 +1774,6 @@ public function testCustomTypeValueSqlForAllFields(): void public function testCustomTypeValueSqlForPartialObject(): void { - $this->hydrationMode = ORMQuery::HYDRATE_ARRAY; - if (DBALType::hasType('negative_to_positive')) { DBALType::overrideType('negative_to_positive', NegativeToPositiveType::class); } else { @@ -1722,7 +1782,7 @@ public function testCustomTypeValueSqlForPartialObject(): void $this->assertSqlGeneration( 'SELECT partial p.{id, customInteger} FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', - 'SELECT c0_.id AS id_0, -(c0_.customInteger) AS customInteger_1 FROM customtype_parents c0_', + 'SELECT c0_.id AS id_0, -(c0_.customInteger) AS customInteger_1, c0_.child_id AS child_id_2 FROM customtype_parents c0_', ); } diff --git a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 0f5bac25b72..0e14402b5a0 100644 --- a/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -137,7 +137,7 @@ public function testCountQueryWithComplexScalarOrderByItemWithoutJoin(): void ); } - public function testCountQueryWithComplexScalarOrderByItemJoined(): void + public function testCountQueryWithComplexScalarOrderByItemJoinedWithoutPartial(): void { $this->entityManager = $this->createTestEntityManagerWithPlatform(new MySQLPlatform()); diff --git a/tests/Tests/ORM/UnitOfWorkTest.php b/tests/Tests/ORM/UnitOfWorkTest.php index 8de0eb03e25..dba967fe87f 100644 --- a/tests/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Tests/ORM/UnitOfWorkTest.php @@ -651,15 +651,6 @@ public function testItThrowsWhenApplicationProvidedIdsCollide(): void $this->_unitOfWork->persist($phone2); } - - public function testItThrowsWhenCreateEntityWithSqlWalkerPartialQueryHint(): void - { - $this->expectException(HydrationException::class); - $this->expectExceptionMessage('Hydration of entity objects is not allowed when DQL PARTIAL keyword is used.'); - - $hints = [SqlWalker::HINT_PARTIAL => true]; - $this->_unitOfWork->createEntity(VersionedAssignedIdentifierEntity::class, ['id' => 1], $hints); - } } From 7ef1f0a379dc122a252fe90aba5d556199025831 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 9 Oct 2024 22:14:01 +0200 Subject: [PATCH 423/475] Phpcs fixes --- src/Decorator/EntityManagerDecorator.php | 1 - src/EntityManager.php | 1 - src/Query/Parser.php | 2 -- src/Query/SqlWalker.php | 8 ++++---- src/UnitOfWork.php | 2 -- tests/Tests/ORM/Query/ParserTest.php | 1 - tests/Tests/ORM/UnitOfWorkTest.php | 2 -- 7 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Decorator/EntityManagerDecorator.php b/src/Decorator/EntityManagerDecorator.php index 212e01e511b..6f1b0419686 100644 --- a/src/Decorator/EntityManagerDecorator.php +++ b/src/Decorator/EntityManagerDecorator.php @@ -8,7 +8,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/EntityManager.php b/src/EntityManager.php index 9de636e5b75..8045ac2f5e3 100644 --- a/src/EntityManager.php +++ b/src/EntityManager.php @@ -9,7 +9,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Exception\EntityManagerClosed; use Doctrine\ORM\Exception\InvalidHydrationMode; use Doctrine\ORM\Exception\MissingIdentifierField; diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 12fe0c97691..76e6757052d 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -5,9 +5,7 @@ namespace Doctrine\ORM\Query; use Doctrine\Common\Lexer\Token; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index 9beeff337be..155461ab2dd 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -1406,21 +1406,21 @@ public function walkSelectExpression(AST\SelectExpression $selectExpression): st // since it requires outer joining subtables. if ($class->isInheritanceTypeSingleTable() || ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { foreach ($class->subClasses as $subClassName) { - $subClass = $this->em->getClassMetadata($subClassName); + $subClass = $this->em->getClassMetadata($subClassName); $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); foreach ($subClass->fieldMappings as $fieldName => $mapping) { - if (isset($mapping->inherited) || ($partialFieldSet && !in_array($fieldName, $partialFieldSet, true))) { + if (isset($mapping->inherited) || ($partialFieldSet && ! in_array($fieldName, $partialFieldSet, true))) { continue; } - $columnAlias = $this->getSQLColumnAlias($mapping->columnName); + $columnAlias = $this->getSQLColumnAlias($mapping->columnName); $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform); $col = $sqlTableAlias . '.' . $quotedColumnName; $type = Type::getType($mapping->type); - $col = $type->convertToPHPValueSQL($col, $this->platform); + $col = $type->convertToPHPValueSQL($col, $this->platform); $sqlParts[] = $col . ' AS ' . $columnAlias; diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index 811aa895b42..ef31a6bbcd6 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -29,7 +29,6 @@ use Doctrine\ORM\Exception\ORMException; use Doctrine\ORM\Exception\UnexpectedAssociationValue; use Doctrine\ORM\Id\AssignedGenerator; -use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Internal\HydrationCompleteHandler; use Doctrine\ORM\Internal\StronglyConnectedComponents; use Doctrine\ORM\Internal\TopologicalSort; @@ -45,7 +44,6 @@ use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister; use Doctrine\ORM\Persisters\Entity\SingleTablePersister; use Doctrine\ORM\Proxy\InternalProxy; -use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\Persistence\PropertyChangedListener; use Exception; diff --git a/tests/Tests/ORM/Query/ParserTest.php b/tests/Tests/ORM/Query/ParserTest.php index ed75be517b0..430177b1fcc 100644 --- a/tests/Tests/ORM/Query/ParserTest.php +++ b/tests/Tests/ORM/Query/ParserTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Query; -use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Query; use Doctrine\ORM\Query\Parser; use Doctrine\ORM\Query\QueryException; diff --git a/tests/Tests/ORM/UnitOfWorkTest.php b/tests/Tests/ORM/UnitOfWorkTest.php index dba967fe87f..a9112fa5d51 100644 --- a/tests/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Tests/ORM/UnitOfWorkTest.php @@ -13,7 +13,6 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Exception\EntityIdentityCollisionException; -use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -23,7 +22,6 @@ use Doctrine\ORM\Mapping\Version; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMInvalidArgumentException; -use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\EntityPersisterMock; From 5f4ecfd1d8a03522b3742d2c12f4403e55320a22 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 10 Oct 2024 10:38:33 +0200 Subject: [PATCH 424/475] Fix imports --- ...ixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php | 2 +- .../SimpleQueryPartialObjectHydrationPerformanceBench.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php index 6a1638afcf5..822a019c7d7 100644 --- a/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php @@ -8,8 +8,8 @@ use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; diff --git a/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php index b894068eb2c..72c2ec73d98 100644 --- a/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php @@ -8,8 +8,8 @@ use Doctrine\ORM\Internal\Hydration\ObjectHydrator; use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Performance\ArrayResultFactory; use Doctrine\Performance\EntityManagerFactory; +use Doctrine\Tests\Mocks\ArrayResultFactory; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; From da7854f586507872e6db421d7273e7666ecd71bf Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 10 Oct 2024 10:41:04 +0200 Subject: [PATCH 425/475] Fix imports --- ...ixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php | 2 +- .../SimpleQueryPartialObjectHydrationPerformanceBench.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php index 822a019c7d7..ef1d1b4bdca 100644 --- a/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php @@ -63,7 +63,7 @@ public function init(): void ]; } - $this->result = ArrayResultFactory::createFromArray($resultSet); + $this->result = ArrayResultFactory::createWrapperResultFromArray($resultSet); $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([])); $this->rsm = new ResultSetMapping(); diff --git a/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php index 72c2ec73d98..a5c78670727 100644 --- a/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php @@ -54,7 +54,7 @@ public function init(): void ]; } - $this->result = ArrayResultFactory::createFromArray($resultSet); + $this->result = ArrayResultFactory::createWrapperResultFromArray($resultSet); $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([])); $this->rsm = new ResultSetMapping(); From c223b8f635c6a65c4349a8651e7683ce0e93bccb Mon Sep 17 00:00:00 2001 From: eltharin Date: Thu, 10 Oct 2024 14:33:12 +0200 Subject: [PATCH 426/475] Allow named Arguments to be passed to Dto Allow to change argument order or use variadic argument in dto constructor using new named keyword --- .../reference/dql-doctrine-query-language.rst | 65 +++- src/Exception/DuplicateFieldException.php | 17 + src/Exception/NoMatchingPropertyException.php | 17 + src/Internal/Hydration/AbstractHydrator.php | 26 +- src/Query/Parser.php | 74 +++- src/Query/ResultSetMapping.php | 22 -- src/Query/SqlWalker.php | 5 +- src/Query/TokenType.php | 1 + .../Models/CMS/CmsAddressDTONamedArgs.php | 16 + .../Tests/Models/CMS/CmsUserDTONamedArgs.php | 18 + .../Models/CMS/CmsUserDTOVariadicArg.php | 21 ++ .../Tests/ORM/Functional/NewOperatorTest.php | 327 ++++++++++++++++++ .../ORM/Hydration/ResultSetMappingTest.php | 17 - 13 files changed, 550 insertions(+), 76 deletions(-) create mode 100644 src/Exception/DuplicateFieldException.php create mode 100644 src/Exception/NoMatchingPropertyException.php create mode 100644 tests/Tests/Models/CMS/CmsAddressDTONamedArgs.php create mode 100644 tests/Tests/Models/CMS/CmsUserDTONamedArgs.php create mode 100644 tests/Tests/Models/CMS/CmsUserDTOVariadicArg.php diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index ab3cb138889..8608049d1fc 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -591,7 +591,7 @@ You can also nest several DTO : // Bind values to the object properties. } } - + class AddressDTO { public function __construct(string $street, string $city, string $zip) @@ -599,15 +599,72 @@ You can also nest several DTO : // Bind values to the object properties. } } - + .. code-block:: php createQuery('SELECT NEW CustomerDTO(c.name, e.email, NEW AddressDTO(a.street, a.city, a.zip)) FROM Customer c JOIN c.email e JOIN c.address a'); $users = $query->getResult(); // array of CustomerDTO - + Note that you can only pass scalar expressions or other Data Transfer Objects to the constructor. +If you use your data transfer objects for multiple queries, and you would rather not have to +specify arguments that precede the ones you are really interested in, you can use named arguments. + +Consider the following DTO, which uses optional arguments: + +.. code-block:: php + + createQuery('SELECT NEW NAMED CustomerDTO(a.city, c.name) FROM Customer c JOIN c.address a'); + $users = $query->getResult(); // array of CustomerDTO + + // CustomerDTO => {name : 'SMITH', email: null, city: 'London', value: null} + +ORM will also give precedence to column aliases over column names : + +.. code-block:: php + + createQuery('SELECT NEW NAMED CustomerDTO(c.name, CONCAT(a.city, ' ' , a.zip) AS value) FROM Customer c JOIN c.address a'); + $users = $query->getResult(); // array of CustomerDTO + + // CustomerDTO => {name : 'DOE', email: null, city: null, value: 'New York 10011'} + +To define a custom name for a DTO constructor argument, you can either alias the column with the ``AS`` keyword. + +The ``NAMED`` keyword must precede all DTO you want to instantiate : + +.. code-block:: php + + createQuery('SELECT NEW NAMED CustomerDTO(c.name, NEW NAMED AddressDTO(a.street, a.city, a.zip) AS address) FROM Customer c JOIN c.address a'); + $users = $query->getResult(); // array of CustomerDTO + + // CustomerDTO => {name : 'DOE', email: null, city: null, value: 'New York 10011'} + +If two arguments have the same name, a ``DuplicateFieldException`` is thrown. +If a field cannot be matched with a property name, a ``NoMatchingPropertyException`` is thrown. This typically happens when using functions without aliasing them. + Using INDEX BY ~~~~~~~~~~~~~~ @@ -1627,7 +1684,7 @@ Select Expressions PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}" NewObjectExpression ::= "NEW" AbstractSchemaName "(" NewObjectArg {"," NewObjectArg}* ")" - NewObjectArg ::= ScalarExpression | "(" Subselect ")" | NewObjectExpression + NewObjectArg ::= (ScalarExpression | "(" Subselect ")" | NewObjectExpression) ["AS" AliasResultVariable] Conditional Expressions ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/Exception/DuplicateFieldException.php b/src/Exception/DuplicateFieldException.php new file mode 100644 index 00000000000..ec7cb00593e --- /dev/null +++ b/src/Exception/DuplicateFieldException.php @@ -0,0 +1,17 @@ + []]; + $rowData = ['data' => [], 'newObjects' => []]; foreach ($data as $key => $value) { $cacheKeyInfo = $this->hydrateColumnInfo($key); @@ -282,10 +282,6 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon $value = $this->buildEnum($value, $cacheKeyInfo['enumType']); } - if (! isset($rowData['newObjects'])) { - $rowData['newObjects'] = []; - } - $rowData['newObjects'][$objIndex]['class'] = $cacheKeyInfo['class']; $rowData['newObjects'][$objIndex]['args'][$argIndex] = $value; break; @@ -341,28 +337,22 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon } foreach ($this->resultSetMapping()->nestedNewObjectArguments as $objIndex => ['ownerIndex' => $ownerIndex, 'argIndex' => $argIndex]) { - if (! isset($rowData['newObjects'][$objIndex])) { + if (! isset($rowData['newObjects'][$ownerIndex . ':' . $argIndex])) { continue; } - $newObject = $rowData['newObjects'][$objIndex]; - unset($rowData['newObjects'][$objIndex]); + $newObject = $rowData['newObjects'][$ownerIndex . ':' . $argIndex]; + unset($rowData['newObjects'][$ownerIndex . ':' . $argIndex]); - $class = $newObject['class']; - $args = $newObject['args']; - $obj = $class->newInstanceArgs($args); + $obj = $newObject['class']->newInstanceArgs($newObject['args']); $rowData['newObjects'][$ownerIndex]['args'][$argIndex] = $obj; } - if (isset($rowData['newObjects'])) { - foreach ($rowData['newObjects'] as $objIndex => $newObject) { - $class = $newObject['class']; - $args = $newObject['args']; - $obj = $class->newInstanceArgs($args); + foreach ($rowData['newObjects'] as $objIndex => $newObject) { + $obj = $newObject['class']->newInstanceArgs($newObject['args']); - $rowData['newObjects'][$objIndex]['obj'] = $obj; - } + $rowData['newObjects'][$objIndex]['obj'] = $obj; } return $rowData; diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 875783c87d4..febbca2f5e8 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -6,6 +6,8 @@ use Doctrine\Common\Lexer\Token; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Exception\DuplicateFieldException; +use Doctrine\ORM\Exception\NoMatchingPropertyException; use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; @@ -15,6 +17,7 @@ use ReflectionClass; use function array_intersect; +use function array_key_exists; use function array_search; use function assert; use function class_exists; @@ -30,6 +33,7 @@ use function strrpos; use function strtolower; use function substr; +use function trim; /** * An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language. @@ -1734,20 +1738,26 @@ public function PartialObjectExpression(): AST\PartialObjectExpression */ public function NewObjectExpression(): AST\NewObjectExpression { - $args = []; + $useNamedArguments = false; + $args = []; + $argFieldAlias = []; $this->match(TokenType::T_NEW); + if ($this->lexer->isNextToken(TokenType::T_NAMED)) { + $this->match(TokenType::T_NAMED); + $useNamedArguments = true; + } + $className = $this->AbstractSchemaName(); // note that this is not yet validated $token = $this->lexer->token; $this->match(TokenType::T_OPEN_PARENTHESIS); - $args[] = $this->NewObjectArg(); + $this->addArgument($args, $useNamedArguments); while ($this->lexer->isNextToken(TokenType::T_COMMA)) { $this->match(TokenType::T_COMMA); - - $args[] = $this->NewObjectArg(); + $this->addArgument($args, $useNamedArguments); } $this->match(TokenType::T_CLOSE_PARENTHESIS); @@ -1764,29 +1774,71 @@ public function NewObjectExpression(): AST\NewObjectExpression return $expression; } + /** @param array $args */ + public function addArgument(array &$args, bool $useNamedArguments): void + { + $fieldAlias = null; + + if ($useNamedArguments) { + $startToken = $this->lexer->lookahead?->position ?? 0; + + $newArg = $this->NewObjectArg($fieldAlias); + + $key = $fieldAlias ?? $newArg->field ?? null; + + if ($key === null) { + throw NoMatchingPropertyException::create(trim(substr( + ($this->query->getDQL() ?? ''), + $startToken, + ($this->lexer->lookahead->position ?? 0) - $startToken, + ))); + } + + if (array_key_exists($key, $args)) { + throw DuplicateFieldException::create($key, trim(substr( + ($this->query->getDQL() ?? ''), + $startToken, + ($this->lexer->lookahead->position ?? 0) - $startToken, + ))); + } + + $args[$key] = $newArg; + } else { + $args[] = $this->NewObjectArg($fieldAlias); + } + } + /** - * NewObjectArg ::= ScalarExpression | "(" Subselect ")" | NewObjectExpression + * NewObjectArg ::= (ScalarExpression | "(" Subselect ")" | NewObjectExpression) ["AS" AliasResultVariable] */ - public function NewObjectArg(): mixed + public function NewObjectArg(string|null &$fieldAlias = null): mixed { + $fieldAlias = null; + assert($this->lexer->lookahead !== null); $token = $this->lexer->lookahead; $peek = $this->lexer->glimpse(); assert($peek !== null); + + $expression = null; + if ($token->type === TokenType::T_OPEN_PARENTHESIS && $peek->type === TokenType::T_SELECT) { $this->match(TokenType::T_OPEN_PARENTHESIS); $expression = $this->Subselect(); $this->match(TokenType::T_CLOSE_PARENTHESIS); - - return $expression; + } elseif ($token->type === TokenType::T_NEW) { + $expression = $this->NewObjectExpression(); + } else { + $expression = $this->ScalarExpression(); } - if ($token->type === TokenType::T_NEW) { - return $this->NewObjectExpression(); + if ($this->lexer->isNextToken(TokenType::T_AS)) { + $this->match(TokenType::T_AS); + $fieldAlias = $this->AliasIdentificationVariable(); } - return $this->ScalarExpression(); + return $expression; } /** diff --git a/src/Query/ResultSetMapping.php b/src/Query/ResultSetMapping.php index c95b089a73b..38ed1bf6416 100644 --- a/src/Query/ResultSetMapping.php +++ b/src/Query/ResultSetMapping.php @@ -4,7 +4,6 @@ namespace Doctrine\ORM\Query; -use function array_merge; use function count; /** @@ -552,25 +551,4 @@ public function addMetaResult( return $this; } - - public function addNewObjectAsArgument(string|int $alias, string|int $objOwner, int $objOwnerIdx): static - { - $owner = [ - 'ownerIndex' => $objOwner, - 'argIndex' => $objOwnerIdx, - ]; - - if (! isset($this->nestedNewObjectArguments[$owner['ownerIndex']])) { - $this->nestedNewObjectArguments[$alias] = $owner; - - return $this; - } - - $this->nestedNewObjectArguments = array_merge( - [$alias => $owner], - $this->nestedNewObjectArguments, - ); - - return $this; - } } diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index 46296e719e7..04d7d953ab4 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -1510,6 +1510,7 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri $this->newObjectStack[] = [$objIndex, $argIndex]; $sqlSelectExpressions[] = $e->dispatch($this); array_pop($this->newObjectStack); + $this->rsm->nestedNewObjectArguments[$columnAlias] = ['ownerIndex' => $objIndex, 'argIndex' => $argIndex]; break; case $e instanceof AST\Subselect: @@ -1563,10 +1564,6 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri 'objIndex' => $objIndex, 'argIndex' => $argIndex, ]; - - if ($objOwner !== null && $objOwnerIdx !== null) { - $this->rsm->addNewObjectAsArgument($objIndex, $objOwner, $objOwnerIdx); - } } return implode(', ', $sqlSelectExpressions); diff --git a/src/Query/TokenType.php b/src/Query/TokenType.php index bf1c351c2a6..47cc7912711 100644 --- a/src/Query/TokenType.php +++ b/src/Query/TokenType.php @@ -89,4 +89,5 @@ enum TokenType: int case T_WHEN = 254; case T_WHERE = 255; case T_WITH = 256; + case T_NAMED = 257; } diff --git a/tests/Tests/Models/CMS/CmsAddressDTONamedArgs.php b/tests/Tests/Models/CMS/CmsAddressDTONamedArgs.php new file mode 100644 index 00000000000..547c7fb0c31 --- /dev/null +++ b/tests/Tests/Models/CMS/CmsAddressDTONamedArgs.php @@ -0,0 +1,16 @@ +name = $args['name'] ?? null; + $this->email = $args['email'] ?? null; + $this->phonenumbers = $args['phonenumbers'] ?? null; + $this->address = $args['address'] ?? null; + } +} diff --git a/tests/Tests/ORM/Functional/NewOperatorTest.php b/tests/Tests/ORM/Functional/NewOperatorTest.php index 4497af517bf..5a742c1b3a9 100644 --- a/tests/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Tests/ORM/Functional/NewOperatorTest.php @@ -4,19 +4,25 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Exception\DuplicateFieldException; +use Doctrine\ORM\Exception\NoMatchingPropertyException; use Doctrine\ORM\Query; use Doctrine\ORM\Query\QueryException; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddressDTO; +use Doctrine\Tests\Models\CMS\CmsAddressDTONamedArgs; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUserDTO; +use Doctrine\Tests\Models\CMS\CmsUserDTONamedArgs; +use Doctrine\Tests\Models\CMS\CmsUserDTOVariadicArg; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use function count; +use function sprintf; #[Group('DDC-1574')] class NewOperatorTest extends OrmFunctionalTestCase @@ -1080,6 +1086,327 @@ public function testShouldSupportNestedNewOperators(): void self::assertSame($this->fixtures[1]->username, $result[1]['cmsUserUsername']); self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); } + + public function testNamedArguments(): void + { + $dql = <<<'SQL' + SELECT + new named CmsUserDTONamedArgs( + e.email, + u.name, + CONCAT(a.country, ' ', a.city, ' ', a.zip) AS address + ) as user, + u.status, + u.username as cmsUserUsername + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e + JOIN + u.address a + ORDER BY + u.name + SQL; + + $query = $this->getEntityManager()->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(3, $result); + + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[0]['user']); + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[1]['user']); + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[2]['user']); + + self::assertSame($this->fixtures[0]->name, $result[0]['user']->name); + self::assertSame($this->fixtures[1]->name, $result[1]['user']->name); + self::assertSame($this->fixtures[2]->name, $result[2]['user']->name); + + self::assertSame($this->fixtures[0]->email->email, $result[0]['user']->email); + self::assertSame($this->fixtures[1]->email->email, $result[1]['user']->email); + self::assertSame($this->fixtures[2]->email->email, $result[2]['user']->email); + + self::assertSame(sprintf( + '%s %s %s', + $this->fixtures[0]->address->country, + $this->fixtures[0]->address->city, + $this->fixtures[0]->address->zip, + ), $result[0]['user']->address); + self::assertSame( + sprintf( + '%s %s %s', + $this->fixtures[1]->address->country, + $this->fixtures[1]->address->city, + $this->fixtures[1]->address->zip, + ), + $result[1]['user']->address, + ); + self::assertSame( + sprintf( + '%s %s %s', + $this->fixtures[2]->address->country, + $this->fixtures[2]->address->city, + $this->fixtures[2]->address->zip, + ), + $result[2]['user']->address, + ); + + self::assertSame($this->fixtures[0]->status, $result[0]['status']); + self::assertSame($this->fixtures[1]->status, $result[1]['status']); + self::assertSame($this->fixtures[2]->status, $result[2]['status']); + + self::assertSame($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertSame($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + } + + public function testVariadicArgument(): void + { + $dql = <<<'SQL' + SELECT + new named CmsUserDTOVariadicArg( + CONCAT(a.country, ' ', a.city, ' ', a.zip) AS address, + e.email, + u.name + ) as user, + u.status, + u.username as cmsUserUsername + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e + JOIN + u.address a + ORDER BY + u.name + SQL; + + $query = $this->getEntityManager()->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(3, $result); + + self::assertInstanceOf(CmsUserDTOVariadicArg::class, $result[0]['user']); + self::assertInstanceOf(CmsUserDTOVariadicArg::class, $result[1]['user']); + self::assertInstanceOf(CmsUserDTOVariadicArg::class, $result[2]['user']); + + self::assertSame($this->fixtures[0]->name, $result[0]['user']->name); + self::assertSame($this->fixtures[1]->name, $result[1]['user']->name); + self::assertSame($this->fixtures[2]->name, $result[2]['user']->name); + + self::assertSame($this->fixtures[0]->email->email, $result[0]['user']->email); + self::assertSame($this->fixtures[1]->email->email, $result[1]['user']->email); + self::assertSame($this->fixtures[2]->email->email, $result[2]['user']->email); + + self::assertSame( + sprintf( + '%s %s %s', + $this->fixtures[0]->address->country, + $this->fixtures[0]->address->city, + $this->fixtures[0]->address->zip, + ), + $result[0]['user']->address, + ); + self::assertSame( + sprintf( + '%s %s %s', + $this->fixtures[1]->address->country, + $this->fixtures[1]->address->city, + $this->fixtures[1]->address->zip, + ), + $result[1]['user']->address, + ); + self::assertSame( + sprintf( + '%s %s %s', + $this->fixtures[2]->address->country, + $this->fixtures[2]->address->city, + $this->fixtures[2]->address->zip, + ), + $result[2]['user']->address, + ); + + self::assertSame($this->fixtures[0]->status, $result[0]['status']); + self::assertSame($this->fixtures[1]->status, $result[1]['status']); + self::assertSame($this->fixtures[2]->status, $result[2]['status']); + + self::assertSame($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertSame($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + } + + public function testShouldSupportNestedNewOperatorsAndNamedArguments(): void + { + $dql = ' + SELECT + new named CmsUserDTONamedArgs( + e.email, + u.name as name, + new CmsAddressDTO( + a.country, + a.city, + a.zip + ) as addressDto + ) as user, + u.status, + u.username as cmsUserUsername + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e + JOIN + u.address a + ORDER BY + u.name'; + + $query = $this->getEntityManager()->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(3, $result); + + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[0]['user']); + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[1]['user']); + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[2]['user']); + + self::assertNull($result[0]['user']->address); + self::assertNull($result[1]['user']->address); + self::assertNull($result[2]['user']->address); + + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['user']->addressDto); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['user']->addressDto); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['user']->addressDto); + + self::assertSame($this->fixtures[0]->name, $result[0]['user']->name); + self::assertSame($this->fixtures[1]->name, $result[1]['user']->name); + self::assertSame($this->fixtures[2]->name, $result[2]['user']->name); + + self::assertSame($this->fixtures[0]->email->email, $result[0]['user']->email); + self::assertSame($this->fixtures[1]->email->email, $result[1]['user']->email); + self::assertSame($this->fixtures[2]->email->email, $result[2]['user']->email); + + self::assertSame($this->fixtures[0]->address->city, $result[0]['user']->addressDto->city); + self::assertSame($this->fixtures[1]->address->city, $result[1]['user']->addressDto->city); + self::assertSame($this->fixtures[2]->address->city, $result[2]['user']->addressDto->city); + + self::assertSame($this->fixtures[0]->address->country, $result[0]['user']->addressDto->country); + self::assertSame($this->fixtures[1]->address->country, $result[1]['user']->addressDto->country); + self::assertSame($this->fixtures[2]->address->country, $result[2]['user']->addressDto->country); + + self::assertSame($this->fixtures[0]->status, $result[0]['status']); + self::assertSame($this->fixtures[1]->status, $result[1]['status']); + self::assertSame($this->fixtures[2]->status, $result[2]['status']); + + self::assertSame($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertSame($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + } + + public function testShouldSupportNestedNamedArguments(): void + { + $dql = ' + SELECT + new named CmsUserDTONamedArgs( + e.email, + u.name as name, + new named CmsAddressDTONamedArgs( + a.zip, + a.city, + a.country + ) as addressDtoNamedArgs + ) as user, + u.status, + u.username as cmsUserUsername + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e + JOIN + u.address a + ORDER BY + u.name'; + + $query = $this->getEntityManager()->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(3, $result); + + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[0]['user']); + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[1]['user']); + self::assertInstanceOf(CmsUserDTONamedArgs::class, $result[2]['user']); + + self::assertNull($result[0]['user']->address); + self::assertNull($result[1]['user']->address); + self::assertNull($result[2]['user']->address); + + self::assertNull($result[0]['user']->addressDto); + self::assertNull($result[1]['user']->addressDto); + self::assertNull($result[2]['user']->addressDto); + + self::assertInstanceOf(CmsAddressDTONamedArgs::class, $result[0]['user']->addressDtoNamedArgs); + self::assertInstanceOf(CmsAddressDTONamedArgs::class, $result[1]['user']->addressDtoNamedArgs); + self::assertInstanceOf(CmsAddressDTONamedArgs::class, $result[2]['user']->addressDtoNamedArgs); + + self::assertSame($this->fixtures[0]->name, $result[0]['user']->name); + self::assertSame($this->fixtures[1]->name, $result[1]['user']->name); + self::assertSame($this->fixtures[2]->name, $result[2]['user']->name); + + self::assertSame($this->fixtures[0]->email->email, $result[0]['user']->email); + self::assertSame($this->fixtures[1]->email->email, $result[1]['user']->email); + self::assertSame($this->fixtures[2]->email->email, $result[2]['user']->email); + + self::assertSame($this->fixtures[0]->address->city, $result[0]['user']->addressDtoNamedArgs->city); + self::assertSame($this->fixtures[1]->address->city, $result[1]['user']->addressDtoNamedArgs->city); + self::assertSame($this->fixtures[2]->address->city, $result[2]['user']->addressDtoNamedArgs->city); + + self::assertSame($this->fixtures[0]->address->country, $result[0]['user']->addressDtoNamedArgs->country); + self::assertSame($this->fixtures[1]->address->country, $result[1]['user']->addressDtoNamedArgs->country); + self::assertSame($this->fixtures[2]->address->country, $result[2]['user']->addressDtoNamedArgs->country); + + self::assertSame($this->fixtures[0]->status, $result[0]['status']); + self::assertSame($this->fixtures[1]->status, $result[1]['status']); + self::assertSame($this->fixtures[2]->status, $result[2]['status']); + + self::assertSame($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertSame($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + } + + public function testExceptionIfTwoAliases(): void + { + $dql = ' + SELECT + new named Doctrine\Tests\Models\CMS\CmsUserDTO( + u.name, + u.username AS name + ) + FROM + Doctrine\Tests\Models\CMS\CmsUser u'; + + $this->expectException(DuplicateFieldException::class); + $this->expectExceptionMessage('Name "name" for "u.username AS name" already in use.'); + + $query = $this->_em->createQuery($dql); + $result = $query->getResult(); + } + + public function testExceptionIfFunctionHasNoAlias(): void + { + $dql = " + SELECT + new named Doctrine\Tests\Models\CMS\CmsUserDTO( + u.name, + CASE WHEN (e.email = 'email@test1.com') THEN 'TEST1' ELSE 'OTHER_TEST' END + ) + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e"; + + $this->expectException(NoMatchingPropertyException::class); + $this->expectExceptionMessage('Column name "CASE WHEN (e.email = \'email@test1.com\') THEN \'TEST1\' ELSE \'OTHER_TEST\' END" does not match any property name. Consider aliasing it to the name of an existing property.'); + + $query = $this->_em->createQuery($dql); + $result = $query->getResult(); + } } class ClassWithTooMuchArgs diff --git a/tests/Tests/ORM/Hydration/ResultSetMappingTest.php b/tests/Tests/ORM/Hydration/ResultSetMappingTest.php index 14b9205abfe..0c20eab0866 100644 --- a/tests/Tests/ORM/Hydration/ResultSetMappingTest.php +++ b/tests/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -102,21 +102,4 @@ public function testIndexByMetadataColumn(): void self::assertTrue($this->_rsm->hasIndexBy('lu')); } - - public function testNewObjectNestedArgumentsDeepestLeavesShouldComeFirst(): void - { - $this->_rsm->addNewObjectAsArgument('objALevel2', 'objALevel1', 0); - $this->_rsm->addNewObjectAsArgument('objALevel3', 'objALevel2', 1); - $this->_rsm->addNewObjectAsArgument('objBLevel3', 'objBLevel2', 0); - $this->_rsm->addNewObjectAsArgument('objBLevel2', 'objBLevel1', 1); - - $expectedArgumentMapping = [ - 'objALevel3' => ['ownerIndex' => 'objALevel2', 'argIndex' => 1], - 'objALevel2' => ['ownerIndex' => 'objALevel1', 'argIndex' => 0], - 'objBLevel3' => ['ownerIndex' => 'objBLevel2', 'argIndex' => 0], - 'objBLevel2' => ['ownerIndex' => 'objBLevel1', 'argIndex' => 1], - ]; - - self::assertSame($expectedArgumentMapping, $this->_rsm->nestedNewObjectArguments); - } } From 5bfb7449671a392242477c5ba63331076e936597 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Fri, 11 Oct 2024 15:29:19 +0200 Subject: [PATCH 427/475] The MySQL/Maria EnumType added in DBAL 4.2 has a new known option "values". (#11657) --- src/Tools/SchemaTool.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index cff59aecdd8..e0a24d9459d 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -47,7 +47,7 @@ */ class SchemaTool { - private const KNOWN_COLUMN_OPTIONS = ['comment', 'unsigned', 'fixed', 'default']; + private const KNOWN_COLUMN_OPTIONS = ['comment', 'unsigned', 'fixed', 'default', 'values']; private readonly AbstractPlatform $platform; private readonly QuoteStrategy $quoteStrategy; From 522863116a245c7bfcf6f5f2458755601b1d1909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 11 Oct 2024 20:23:33 +0200 Subject: [PATCH 428/475] Update branch metadata (#11663) 2.20.0 just got released --- .doctrine-project.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.doctrine-project.json b/.doctrine-project.json index f3a38fb4bdd..7865e2dd1a6 100644 --- a/.doctrine-project.json +++ b/.doctrine-project.json @@ -35,17 +35,23 @@ "slug": "3.0", "maintained": false }, + { + "name": "2.21", + "branchName": "2.21.x", + "slug": "2.21", + "upcoming": true + }, { "name": "2.20", "branchName": "2.20.x", "slug": "2.20", - "upcoming": true + "maintained": true }, { "name": "2.19", "branchName": "2.19.x", "slug": "2.19", - "maintained": true + "maintained": false }, { "name": "2.18", From f5fb400d0f13fc58431ac06185e53edac4bea704 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 12 Oct 2024 02:32:15 +0200 Subject: [PATCH 429/475] Address review comments. --- docs/en/reference/partial-hydration.rst | 5 ----- docs/en/reference/partial-objects.rst | 10 ---------- src/UnitOfWork.php | 12 ------------ 3 files changed, 27 deletions(-) diff --git a/docs/en/reference/partial-hydration.rst b/docs/en/reference/partial-hydration.rst index 16879c45c52..fda14b98efa 100644 --- a/docs/en/reference/partial-hydration.rst +++ b/docs/en/reference/partial-hydration.rst @@ -1,11 +1,6 @@ Partial Hydration ================= -.. note:: - - Creating Partial Objects through DQL was possible in ORM 2, - but is only supported for array hydration as of ORM 3. - Partial hydration of entities is allowed in the array hydrator, when only a subset of the fields of an entity are loaded from the database and the nested results are still created based on the entity relationship structure. diff --git a/docs/en/reference/partial-objects.rst b/docs/en/reference/partial-objects.rst index 51f173adf6c..3835123257a 100644 --- a/docs/en/reference/partial-objects.rst +++ b/docs/en/reference/partial-objects.rst @@ -1,14 +1,6 @@ Partial Objects =============== - -.. note:: - - Creating Partial Objects through DQL is deprecated and - will be removed in the future, use data transfer object - support in DQL instead. (\ `Details - `_) - A partial object is an object whose state is not fully initialized after being reconstituted from the database and that is disconnected from the rest of its data. The following section will @@ -94,5 +86,3 @@ When should I force partial objects? Mainly for optimization purposes, but be careful of premature optimization as partial objects lead to potentially more fragile code. - - diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index ef31a6bbcd6..751d36ee21a 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2412,18 +2412,6 @@ public function createEntity(string $className, array $data, array &$hints = []) unset($this->eagerLoadingEntities[$class->rootEntityName]); } - // Properly initialize any unfetched associations, if partial objects are not allowed. - if (isset($hints[Query::HINT_FORCE_PARTIAL_LOAD])) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8471', - 'Partial Objects are deprecated (here entity %s)', - $className, - ); - - return $entity; - } - foreach ($class->associationMappings as $field => $assoc) { // Check if the association is not among the fetch-joined associations already. if (isset($hints['fetchAlias'], $hints['fetched'][$hints['fetchAlias']][$field])) { From 516b5931934a07d3071bb2cd4b833f1d0729a22c Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 12 Oct 2024 15:41:31 +0200 Subject: [PATCH 430/475] Fix phpcs --- src/UnitOfWork.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index df2996ce3bd..4cf3e9e2d9f 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -12,7 +12,6 @@ use Doctrine\DBAL; use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; use Doctrine\DBAL\LockMode; -use Doctrine\Deprecations\Deprecation; use Doctrine\ORM\Cache\Persister\CachedPersister; use Doctrine\ORM\Event\ListenersInvoker; use Doctrine\ORM\Event\OnClearEventArgs; From c7e5605d116cca2229db3ee012eb78a420cd174c Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 12 Oct 2024 15:43:46 +0200 Subject: [PATCH 431/475] Fix test --- src/Query/Parser.php | 1 - tests/Tests/ORM/UnitOfWorkTest.php | 9 --------- 2 files changed, 10 deletions(-) diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 3b1779e4307..bcfad85c422 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -9,7 +9,6 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Exception\DuplicateFieldException; use Doctrine\ORM\Exception\NoMatchingPropertyException; -use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; diff --git a/tests/Tests/ORM/UnitOfWorkTest.php b/tests/Tests/ORM/UnitOfWorkTest.php index 900ee218300..2a421c6687d 100644 --- a/tests/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Tests/ORM/UnitOfWorkTest.php @@ -691,15 +691,6 @@ public function rollBack(): void self::assertSame('Commit failed', $e->getPrevious()->getMessage()); } } - - public function testItThrowsWhenCreateEntityWithSqlWalkerPartialQueryHint(): void - { - $this->expectException(HydrationException::class); - $this->expectExceptionMessage('Hydration of entity objects is not allowed when DQL PARTIAL keyword is used.'); - - $hints = [SqlWalker::HINT_PARTIAL => true]; - $this->_unitOfWork->createEntity(VersionedAssignedIdentifierEntity::class, ['id' => 1], $hints); - } } From 7c9b74221fd2c0e3245fb43a607a0ec113dd037e Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 12 Oct 2024 16:31:02 +0200 Subject: [PATCH 432/475] fix phpbench tests. --- ...ueryFetchJoinPartialObjectHydrationPerformanceBench.php | 7 +++++++ .../SimpleQueryPartialObjectHydrationPerformanceBench.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php index ef1d1b4bdca..0694e8fff6a 100644 --- a/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/MixedQueryFetchJoinPartialObjectHydrationPerformanceBench.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Performance\EntityManagerFactory; use Doctrine\Tests\Mocks\ArrayResultFactory; +use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; @@ -33,6 +34,7 @@ public function init(): void 'u__name' => 'Roman', 'sclr0' => 'ROMANB', 'p__phonenumber' => '42', + 'a__id' => '1', ], [ 'u__id' => '1', @@ -41,6 +43,7 @@ public function init(): void 'u__name' => 'Roman', 'sclr0' => 'ROMANB', 'p__phonenumber' => '43', + 'a__id' => '1', ], [ 'u__id' => '2', @@ -49,6 +52,7 @@ public function init(): void 'u__name' => 'Roman', 'sclr0' => 'JWAGE', 'p__phonenumber' => '91', + 'a__id' => '1', ], ]; @@ -60,6 +64,7 @@ public function init(): void 'u__name' => 'Jonathan', 'sclr0' => 'JWAGE' . $i, 'p__phonenumber' => '91', + 'a__id' => '1', ]; } @@ -75,6 +80,8 @@ public function init(): void $this->rsm->addFieldResult('u', 'u__name', 'name'); $this->rsm->addScalarResult('sclr0', 'nameUpper'); $this->rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $this->rsm->addJoinedEntityResult(CmsAddress::class, 'a', 'u', 'address'); + $this->rsm->addFieldResult('a', 'a__id', 'id'); } public function benchHydration(): void diff --git a/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php b/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php index a5c78670727..14ed606508c 100644 --- a/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php +++ b/tests/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php @@ -10,6 +10,7 @@ use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Performance\EntityManagerFactory; use Doctrine\Tests\Mocks\ArrayResultFactory; +use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsUser; use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; @@ -30,18 +31,21 @@ public function init(): void 'u__status' => 'developer', 'u__username' => 'romanb', 'u__name' => 'Roman', + 'a__id' => '1', ], [ 'u__id' => '1', 'u__status' => 'developer', 'u__username' => 'romanb', 'u__name' => 'Roman', + 'a__id' => '1', ], [ 'u__id' => '2', 'u__status' => 'developer', 'u__username' => 'romanb', 'u__name' => 'Roman', + 'a__id' => '1', ], ]; @@ -51,6 +55,7 @@ public function init(): void 'u__status' => 'developer', 'u__username' => 'jwage', 'u__name' => 'Jonathan', + 'a__id' => '1', ]; } @@ -63,6 +68,8 @@ public function init(): void $this->rsm->addFieldResult('u', 'u__status', 'status'); $this->rsm->addFieldResult('u', 'u__username', 'username'); $this->rsm->addFieldResult('u', 'u__name', 'name'); + $this->rsm->addJoinedEntityResult(CmsAddress::class, 'a', 'u', 'address'); + $this->rsm->addFieldResult('a', 'a__id', 'id'); } public function benchHydration(): void From 60c245413dbff6710786f2dbd091c69407e972ee Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 12 Oct 2024 17:35:44 +0200 Subject: [PATCH 433/475] Auto-detect values for EnumType columns (#11666) --- psalm-baseline.xml | 1 + src/Mapping/ClassMetadata.php | 15 ++++-- src/Mapping/DefaultTypedFieldMapper.php | 49 ++++++++++++------- tests/Tests/Models/Enums/CardNativeEnum.php | 25 ++++++++++ .../Models/Enums/TypedCardNativeEnum.php | 23 +++++++++ tests/Tests/ORM/Functional/EnumTest.php | 29 +++++++---- 6 files changed, 111 insertions(+), 31 deletions(-) create mode 100644 tests/Tests/Models/Enums/CardNativeEnum.php create mode 100644 tests/Tests/Models/Enums/TypedCardNativeEnum.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 886493223c9..807db27145e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -402,6 +402,7 @@ + diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index 70d3ea7042f..7c9020805a5 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -7,6 +7,7 @@ use BackedEnum; use BadMethodCallException; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\Types; use Doctrine\Deprecations\Deprecation; use Doctrine\Instantiator\Instantiator; use Doctrine\Instantiator\InstantiatorInterface; @@ -23,6 +24,7 @@ use ReflectionProperty; use Stringable; +use function array_column; use function array_diff; use function array_intersect; use function array_key_exists; @@ -34,6 +36,7 @@ use function assert; use function class_exists; use function count; +use function defined; use function enum_exists; use function explode; use function in_array; @@ -1119,9 +1122,7 @@ private function validateAndCompleteTypedFieldMapping(array $mapping): array { $field = $this->reflClass->getProperty($mapping['fieldName']); - $mapping = $this->typedFieldMapper->validateAndComplete($mapping, $field); - - return $mapping; + return $this->typedFieldMapper->validateAndComplete($mapping, $field); } /** @@ -1232,6 +1233,14 @@ protected function validateAndCompleteFieldMapping(array $mapping): FieldMapping if (! empty($mapping->id)) { $this->containsEnumIdentifier = true; } + + if ( + defined('Doctrine\DBAL\Types\Types::ENUM') + && $mapping->type === Types::ENUM + && ! isset($mapping->options['values']) + ) { + $mapping->options['values'] = array_column($mapping->enumType::cases(), 'value'); + } } return $mapping; diff --git a/src/Mapping/DefaultTypedFieldMapper.php b/src/Mapping/DefaultTypedFieldMapper.php index 49144b8b7c8..40b37b8c426 100644 --- a/src/Mapping/DefaultTypedFieldMapper.php +++ b/src/Mapping/DefaultTypedFieldMapper.php @@ -16,6 +16,7 @@ use function array_merge; use function assert; +use function defined; use function enum_exists; use function is_a; @@ -49,30 +50,40 @@ public function validateAndComplete(array $mapping, ReflectionProperty $field): { $type = $field->getType(); + if (! $type instanceof ReflectionNamedType) { + return $mapping; + } + if ( - ! isset($mapping['type']) - && ($type instanceof ReflectionNamedType) + ! $type->isBuiltin() + && enum_exists($type->getName()) + && (! isset($mapping['type']) || ( + defined('Doctrine\DBAL\Types\Types::ENUM') + && $mapping['type'] === Types::ENUM + )) ) { - if (! $type->isBuiltin() && enum_exists($type->getName())) { - $reflection = new ReflectionEnum($type->getName()); - if (! $reflection->isBacked()) { - throw MappingException::backedEnumTypeRequired( - $field->class, - $mapping['fieldName'], - $type->getName(), - ); - } + $reflection = new ReflectionEnum($type->getName()); + if (! $reflection->isBacked()) { + throw MappingException::backedEnumTypeRequired( + $field->class, + $mapping['fieldName'], + $type->getName(), + ); + } - assert(is_a($type->getName(), BackedEnum::class, true)); - $mapping['enumType'] = $type->getName(); - $type = $reflection->getBackingType(); + assert(is_a($type->getName(), BackedEnum::class, true)); + $mapping['enumType'] = $type->getName(); + $type = $reflection->getBackingType(); - assert($type instanceof ReflectionNamedType); - } + assert($type instanceof ReflectionNamedType); + } - if (isset($this->typedFieldMappings[$type->getName()])) { - $mapping['type'] = $this->typedFieldMappings[$type->getName()]; - } + if (isset($mapping['type'])) { + return $mapping; + } + + if (isset($this->typedFieldMappings[$type->getName()])) { + $mapping['type'] = $this->typedFieldMappings[$type->getName()]; } return $mapping; diff --git a/tests/Tests/Models/Enums/CardNativeEnum.php b/tests/Tests/Models/Enums/CardNativeEnum.php new file mode 100644 index 00000000000..83d4d59a778 --- /dev/null +++ b/tests/Tests/Models/Enums/CardNativeEnum.php @@ -0,0 +1,25 @@ + ['H', 'D', 'C', 'S', 'Z']])] + public $suit; +} diff --git a/tests/Tests/Models/Enums/TypedCardNativeEnum.php b/tests/Tests/Models/Enums/TypedCardNativeEnum.php new file mode 100644 index 00000000000..59e4eb00e55 --- /dev/null +++ b/tests/Tests/Models/Enums/TypedCardNativeEnum.php @@ -0,0 +1,23 @@ +_em->flush(); $this->_em->clear(); - $fetchedCard = $this->_em->find(Card::class, $card->id); + $fetchedCard = $this->_em->find($cardClass, $card->id); $this->assertInstanceOf(Suit::class, $fetchedCard->suit); $this->assertEquals(Suit::Clubs, $fetchedCard->suit); @@ -417,6 +421,10 @@ public function testFindByEnum(): void #[DataProvider('provideCardClasses')] public function testEnumWithNonMatchingDatabaseValueThrowsException(string $cardClass): void { + if ($cardClass === TypedCardNativeEnum::class) { + self::markTestSkipped('MySQL won\'t allow us to insert invalid values in this case.'); + } + $this->setUpEntitySchema([$cardClass]); $card = new $cardClass(); @@ -429,7 +437,7 @@ public function testEnumWithNonMatchingDatabaseValueThrowsException(string $card $metadata = $this->_em->getClassMetadata($cardClass); $this->_em->getConnection()->update( $metadata->table['name'], - [$metadata->fieldMappings['suit']->columnName => 'invalid'], + [$metadata->fieldMappings['suit']->columnName => 'Z'], [$metadata->fieldMappings['id']->columnName => $card->id], ); @@ -437,7 +445,7 @@ public function testEnumWithNonMatchingDatabaseValueThrowsException(string $card $this->expectExceptionMessage(sprintf( <<<'EXCEPTION' Context: Trying to hydrate enum property "%s::$suit" -Problem: Case "invalid" is not listed in enum "Doctrine\Tests\Models\Enums\Suit" +Problem: Case "Z" is not listed in enum "Doctrine\Tests\Models\Enums\Suit" Solution: Either add the case to the enum type or migrate the database column to use another case of the enum EXCEPTION , @@ -447,13 +455,16 @@ public function testEnumWithNonMatchingDatabaseValueThrowsException(string $card $this->_em->find($cardClass, $card->id); } - /** @return array */ - public static function provideCardClasses(): array + /** @return iterable */ + public static function provideCardClasses(): iterable { - return [ - Card::class => [Card::class], - TypedCard::class => [TypedCard::class], - ]; + yield Card::class => [Card::class]; + yield TypedCard::class => [TypedCard::class]; + + if (class_exists(EnumType::class)) { + yield CardNativeEnum::class => [CardNativeEnum::class]; + yield TypedCardNativeEnum::class => [TypedCardNativeEnum::class]; + } } public function testItAllowsReadingAttributes(): void From cf8f5f9f935455976f637051dacdcc7f5b5d42e1 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 12 Oct 2024 21:01:04 +0200 Subject: [PATCH 434/475] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégoire Paris --- docs/en/reference/dql-doctrine-query-language.rst | 2 +- docs/en/reference/partial-objects.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index 889013a3ba5..e668c08fd82 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -542,7 +542,7 @@ DQL keyword: $query = $em->createQuery('SELECT partial u.{id, username} FROM CmsUser u'); $users = $query->getResult(); // array of partially loaded CmsUser objects -You use the partial syntax when joining as well: +You can use the partial syntax when joining as well: .. code-block:: php diff --git a/docs/en/reference/partial-objects.rst b/docs/en/reference/partial-objects.rst index 3835123257a..3123c083f3f 100644 --- a/docs/en/reference/partial-objects.rst +++ b/docs/en/reference/partial-objects.rst @@ -5,7 +5,7 @@ A partial object is an object whose state is not fully initialized after being reconstituted from the database and that is disconnected from the rest of its data. The following section will describe why partial objects are problematic and what the approach -of Doctrine2 to this problem is. +of Doctrine to this problem is. .. note:: From 737aee7d9832fc3603f8b017596a5d9f5ce37044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 13 Oct 2024 20:47:57 +0200 Subject: [PATCH 435/475] Update branch metadata (#11672) 3.3.0 was just released. --- .doctrine-project.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.doctrine-project.json b/.doctrine-project.json index 7865e2dd1a6..8dfa2ed2450 100644 --- a/.doctrine-project.json +++ b/.doctrine-project.json @@ -11,17 +11,23 @@ "slug": "latest", "upcoming": true }, + { + "name": "3.4", + "branchName": "3.4.x", + "slug": "3.4", + "upcoming": true + }, { "name": "3.3", "branchName": "3.3.x", "slug": "3.3", - "upcoming": true + "current": true }, { "name": "3.2", "branchName": "3.2.x", "slug": "3.2", - "current": true + "maintained": false }, { "name": "3.1", From e9f3ca2a45678e17f03cb46ab48dba0b59b4edac Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 13 Oct 2024 20:48:11 +0200 Subject: [PATCH 436/475] Drop DBAL 2 compat code (#11674) --- tests/Tests/ORM/Functional/Ticket/GH10747Test.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/Tests/ORM/Functional/Ticket/GH10747Test.php b/tests/Tests/ORM/Functional/Ticket/GH10747Test.php index bbe15501e94..90caec353bd 100644 --- a/tests/Tests/ORM/Functional/Ticket/GH10747Test.php +++ b/tests/Tests/ORM/Functional/Ticket/GH10747Test.php @@ -17,7 +17,6 @@ use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\Group; -use function method_exists; use function str_replace; /** @@ -135,23 +134,19 @@ public function __construct(GH10747Article $article, public string $name) class GH10747CustomIdObjectHashType extends DBALType { - public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): mixed + public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): string { return $value->id . '_test'; } - public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed + public function convertToPHPValue(mixed $value, AbstractPlatform $platform): CustomIdObject { return new CustomIdObject(str_replace('_test', '', $value)); } - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string + public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { - if (method_exists($platform, 'getStringTypeDeclarationSQL')) { - return $platform->getStringTypeDeclarationSQL($fieldDeclaration); - } - - return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + return $platform->getStringTypeDeclarationSQL($column); } public function getName(): string From efaba02ef5a28a8f07c2cc75fc9bb1f17bc78981 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 13 Oct 2024 21:55:29 +0200 Subject: [PATCH 437/475] CI: Close stale pull requests --- .github/workflows/stale.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 00000000000..08a88527759 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,24 @@ +name: 'Close stale pull requests' +on: + schedule: + - cron: '0 3 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + stale-pr-message: > + There hasn't been any activity on this pull request in the past 90 days, so + it has been marked as stale and it will be closed automatically if no + further activity occurs in the next 7 days. + + If you want to continue working on it, please leave a comment. + + close-pr-message: > + This pull request was closed due to inactivity. + + days-before-stale: -1 + days-before-pr-stale: 90 + days-before-pr-close: 7 From d5c400e8d1f0ea5eca00789d6d076762f82763a1 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 14 Oct 2024 09:32:55 +0200 Subject: [PATCH 438/475] Remove annotations example --- .../working-with-indexed-associations.rst | 3 - .../Market-annotations.php | 74 ------------------- 2 files changed, 77 deletions(-) delete mode 100644 docs/en/tutorials/working-with-indexed-associations/Market-annotations.php diff --git a/docs/en/tutorials/working-with-indexed-associations.rst b/docs/en/tutorials/working-with-indexed-associations.rst index 1b120a2ae40..ac326c4181f 100644 --- a/docs/en/tutorials/working-with-indexed-associations.rst +++ b/docs/en/tutorials/working-with-indexed-associations.rst @@ -32,9 +32,6 @@ The code and mappings for the Market entity looks like this: .. literalinclude:: working-with-indexed-associations/Market.php :language: attribute - .. literalinclude:: working-with-indexed-associations/Market-annotations.php - :language: annotation - .. literalinclude:: working-with-indexed-associations/market.xml :language: xml diff --git a/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php b/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php deleted file mode 100644 index 798b49d1d02..00000000000 --- a/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php +++ /dev/null @@ -1,74 +0,0 @@ - - */ - 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(); - } -} From fac0899ef7cf5ea43faaa8501da9bae63eae54c4 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 14 Oct 2024 09:52:23 +0200 Subject: [PATCH 439/475] Tell dependabot to target 2.20.x (#11681) --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c704d7d05b4..54e72673914 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,4 +6,4 @@ updates: interval: "weekly" labels: - "CI" - target-branch: "2.19.x" + target-branch: "2.20.x" From 0893d8511ebdee5816a428d77b487e6501e42ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 16 Oct 2024 22:58:27 +0200 Subject: [PATCH 440/475] Remove YAML doc example It was wrongly added during a merge up --- .../working-with-indexed-associations.rst | 4 ---- .../working-with-indexed-associations/market.yaml | 15 --------------- 2 files changed, 19 deletions(-) delete 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 ac326c4181f..e15cae87aa4 100644 --- a/docs/en/tutorials/working-with-indexed-associations.rst +++ b/docs/en/tutorials/working-with-indexed-associations.rst @@ -35,10 +35,6 @@ The code and mappings for the Market entity looks like this: .. literalinclude:: working-with-indexed-associations/market.xml :language: xml - .. literalinclude:: working-with-indexed-associations/market.xml - :language: yaml - - 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)`` we pick a stock traded on the particular market by symbol. If this stock doesn't exist an exception is thrown. diff --git a/docs/en/tutorials/working-with-indexed-associations/market.yaml b/docs/en/tutorials/working-with-indexed-associations/market.yaml deleted file mode 100644 index b7c8132e090..00000000000 --- a/docs/en/tutorials/working-with-indexed-associations/market.yaml +++ /dev/null @@ -1,15 +0,0 @@ -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 e7efdede15e572cf7950b0372391cac01a51152b Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Fri, 18 Oct 2024 09:13:20 +0200 Subject: [PATCH 441/475] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index daef3b0c0e7..47a36ddb27e 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ | [![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) - Doctrine ORM is an object-relational mapper for PHP 8.1+ that provides transparent persistence for PHP objects. It sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), From 039b03255a80dc68ea6f04339c6e781f009ddfa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 20 Oct 2024 11:57:45 +0200 Subject: [PATCH 442/475] Inherit issue templates --- .github/ISSUE_TEMPLATE/BC_Break.md | 37 ---------------------- .github/ISSUE_TEMPLATE/Bug.md | 34 -------------------- .github/ISSUE_TEMPLATE/Feature_Request.md | 18 ----------- .github/ISSUE_TEMPLATE/Support_Question.md | 6 ---- .github/ISSUE_TEMPLATE/config.yml | 13 ++++++++ 5 files changed, 13 insertions(+), 95 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/BC_Break.md delete mode 100644 .github/ISSUE_TEMPLATE/Bug.md delete mode 100644 .github/ISSUE_TEMPLATE/Feature_Request.md delete mode 100644 .github/ISSUE_TEMPLATE/Support_Question.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/BC_Break.md b/.github/ISSUE_TEMPLATE/BC_Break.md deleted file mode 100644 index 9fdd4dd9229..00000000000 --- a/.github/ISSUE_TEMPLATE/BC_Break.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: 💥 BC Break -about: Have you encountered an issue during upgrade? 💣 ---- - - - -### BC Break Report - - - -| Q | A -|------------ | ------ -| BC Break | yes -| Version | x.y.z - -#### Summary - - - -#### Previous behavior - - - -#### Current behavior - - - -#### How to reproduce - - diff --git a/.github/ISSUE_TEMPLATE/Bug.md b/.github/ISSUE_TEMPLATE/Bug.md deleted file mode 100644 index c65ac467ac7..00000000000 --- a/.github/ISSUE_TEMPLATE/Bug.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -name: 🐞 Bug Report -about: Something is broken? 🔨 ---- - -### Bug Report - - - -| Q | A -|------------ | ------ -| BC Break | yes/no -| Version | x.y.z - -#### Summary - - - -#### Current behavior - - - -#### How to reproduce - - - -#### Expected behavior - - - diff --git a/.github/ISSUE_TEMPLATE/Feature_Request.md b/.github/ISSUE_TEMPLATE/Feature_Request.md deleted file mode 100644 index 2620581d684..00000000000 --- a/.github/ISSUE_TEMPLATE/Feature_Request.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: 🎉 Feature Request -about: You have a neat idea that should be implemented? 🎩 ---- - -### Feature Request - - - -| Q | A -|------------ | ------ -| New Feature | yes -| RFC | yes/no -| BC Break | yes/no - -#### Summary - - diff --git a/.github/ISSUE_TEMPLATE/Support_Question.md b/.github/ISSUE_TEMPLATE/Support_Question.md deleted file mode 100644 index e584c3994c2..00000000000 --- a/.github/ISSUE_TEMPLATE/Support_Question.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -name: ❓ Support Question -about: Have a problem that you can't figure out? 🤔 ---- - -Please use https://github.com/doctrine/orm/discussions instead. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000000..8842420d9af --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,13 @@ +contact_links: + - name: Github Discussions + url: https://github.com/doctrine/orm/discussions + about: ORM-specific support discussions. + - name: Doctrine Slack + url: https://www.doctrine-project.org/slack + about: Join the Doctrine Slack to chat with other Doctrine users and contributors. + - name: Doctrine channel on Symfony Slack + url: https://symfony-devs.slack.com/messages/C3FQPE6LE/ + about: 'Communicate with other Symfony developers that use Doctrine in the #doctrine slack channel in the Symfony Devs slack instance.' + - name: Laravel Slack + url: http://slack.laraveldoctrine.org/ + about: Communicate with other Laravel developers that use Doctrine in the Laravel Doctrine slack instance. From 4d821cb13963cf06f2266d5379827d8e5c92b2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 20 Oct 2024 12:15:32 +0200 Subject: [PATCH 443/475] Remove config.yml It causes the template inheritance to fail. --- .github/ISSUE_TEMPLATE/config.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 8842420d9af..00000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -contact_links: - - name: Github Discussions - url: https://github.com/doctrine/orm/discussions - about: ORM-specific support discussions. - - name: Doctrine Slack - url: https://www.doctrine-project.org/slack - about: Join the Doctrine Slack to chat with other Doctrine users and contributors. - - name: Doctrine channel on Symfony Slack - url: https://symfony-devs.slack.com/messages/C3FQPE6LE/ - about: 'Communicate with other Symfony developers that use Doctrine in the #doctrine slack channel in the Symfony Devs slack instance.' - - name: Laravel Slack - url: http://slack.laraveldoctrine.org/ - about: Communicate with other Laravel developers that use Doctrine in the Laravel Doctrine slack instance. From c9253ef64b60cdee969cef2476439fed4db31fbc Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Thu, 2 Nov 2023 13:46:15 -0400 Subject: [PATCH 444/475] feat: make `PersistentCollection::first()` "extra" lazy --- docs/en/tutorials/extra-lazy-associations.rst | 1 + src/PersistentCollection.php | 14 +++++ .../Functional/ExtraLazyCollectionTest.php | 57 +++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/docs/en/tutorials/extra-lazy-associations.rst b/docs/en/tutorials/extra-lazy-associations.rst index 4c31357eecc..1dae001a36c 100644 --- a/docs/en/tutorials/extra-lazy-associations.rst +++ b/docs/en/tutorials/extra-lazy-associations.rst @@ -17,6 +17,7 @@ can be called without triggering a full load of the collection: - ``Collection#contains($entity)`` - ``Collection#containsKey($key)`` - ``Collection#count()`` +- ``Collection#first()`` - ``Collection#get($key)`` - ``Collection#slice($offset, $length = null)`` diff --git a/src/PersistentCollection.php b/src/PersistentCollection.php index d54d3d1b997..ef5f28c3cb3 100644 --- a/src/PersistentCollection.php +++ b/src/PersistentCollection.php @@ -504,6 +504,20 @@ public function __wakeup(): void $this->em = null; } + /** + * {@inheritDoc} + */ + public function first() + { + if (! $this->initialized && ! $this->isDirty && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { + $persister = $this->getUnitOfWork()->getCollectionPersister($this->getMapping()); + + return array_values($persister->slice($this, 0, 1))[0] ?? false; + } + + return parent::first(); + } + /** * Extracts a slice of $length elements starting at position $offset from the Collection. * diff --git a/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php index a092f6555cd..569ea135009 100644 --- a/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -179,6 +179,63 @@ public function testCountOneToManyJoinedInheritance(): void self::assertCount(2, $otherClass->childClasses); } + #[Group('non-cacheable')] + public function testFirstWhenInitialized(): void + { + $user = $this->_em->find(CmsUser::class, $this->userId); + $this->getQueryLog()->reset()->enable(); + $user->groups->toArray(); + + self::assertTrue($user->groups->isInitialized()); + self::assertInstanceOf(CmsGroup::class, $user->groups->first()); + $this->assertQueryCount(1, 'Should only execute one query to initialize collection, no extra query for first().'); + } + + public function testFirstOnEmptyCollectionWhenInitialized(): void + { + foreach ($this->_em->getRepository(CmsGroup::class)->findAll() as $group) { + $this->_em->remove($group); + } + + $this->_em->flush(); + + $user = $this->_em->find(CmsUser::class, $this->userId); + $this->getQueryLog()->reset()->enable(); + $user->groups->toArray(); + + self::assertTrue($user->groups->isInitialized()); + self::assertFalse($user->groups->first()); + $this->assertQueryCount(1, 'Should only execute one query to initialize collection, no extra query for first().'); + } + + public function testFirstWhenNotInitialized(): void + { + $user = $this->_em->find(CmsUser::class, $this->userId); + $this->getQueryLog()->reset()->enable(); + + self::assertFalse($user->groups->isInitialized()); + self::assertInstanceOf(CmsGroup::class, $user->groups->first()); + self::assertFalse($user->groups->isInitialized()); + $this->assertQueryCount(1, 'Should only execute one query for first().'); + } + + public function testFirstOnEmptyCollectionWhenNotInitialized(): void + { + foreach ($this->_em->getRepository(CmsGroup::class)->findAll() as $group) { + $this->_em->remove($group); + } + + $this->_em->flush(); + + $user = $this->_em->find(CmsUser::class, $this->userId); + $this->getQueryLog()->reset()->enable(); + + self::assertFalse($user->groups->isInitialized()); + self::assertFalse($user->groups->first()); + self::assertFalse($user->groups->isInitialized()); + $this->assertQueryCount(1, 'Should only execute one query for first().'); + } + #[Group('DDC-546')] public function testFullSlice(): void { From 021a9cce3d751833a7188f2b8f74ed2ca9814161 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Tue, 22 Oct 2024 15:54:18 +0200 Subject: [PATCH 445/475] UPGRADE: mention `SqlWalker` deprecations in 3.3 (#11693) --- UPGRADE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 6da5e0be57c..6b52e2d767f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -4,6 +4,16 @@ The class `Doctrine\ORM\Mapping\Driver\DatabaseDriver` is deprecated without replacement. +## Add `Doctrine\ORM\Query\OutputWalker` interface, deprecate `Doctrine\ORM\Query\SqlWalker::getExecutor()` + +Output walkers should implement the new `\Doctrine\ORM\Query\OutputWalker` interface and create +`Doctrine\ORM\Query\Exec\SqlFinalizer` instances instead of `Doctrine\ORM\Query\Exec\AbstractSqlExecutor`s. +The output walker must not base its workings on the query `firstResult`/`maxResult` values, so that the +`SqlFinalizer` can be kept in the query cache and used regardless of the actual `firstResult`/`maxResult` values. +Any operation dependent on `firstResult`/`maxResult` should take place within the `SqlFinalizer::createExecutor()` +method. Details can be found at https://github.com/doctrine/orm/pull/11188. + + # Upgrade to 3.2 ## Deprecate the `NotSupported` exception From 81c0d599c956071e974f9ba4134a8cab9d07565c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 27 Jun 2024 23:22:59 +0200 Subject: [PATCH 446/475] Implement compatibility with Persistence 4 --- composer.json | 2 +- phpcs.xml.dist | 2 ++ phpstan-baseline.neon | 5 +++ phpstan-dbal3.neon | 5 +++ phpstan.neon | 5 +++ psalm-baseline.xml | 23 ++++++++---- src/EntityManager.php | 4 +-- src/Mapping/ClassMetadata.php | 12 ++----- .../Driver/LoadMappingFileImplementation.php | 35 +++++++++++++++++++ src/Mapping/Driver/XmlDriver.php | 8 ++--- .../GetReflectionClassImplementation.php | 33 +++++++++++++++++ .../Mock/NonProxyLoadingEntityManager.php | 8 +++++ tests/Tests/Mocks/MetadataDriverMock.php | 6 ++-- .../ORM/Functional/Ticket/DDC3103Test.php | 14 ++++++-- tests/Tests/ORM/Mapping/ClassMetadataTest.php | 5 +++ 15 files changed, 139 insertions(+), 28 deletions(-) create mode 100644 src/Mapping/Driver/LoadMappingFileImplementation.php create mode 100644 src/Mapping/GetReflectionClassImplementation.php diff --git a/composer.json b/composer.json index ec2ff1fd5a7..7269a3c08a1 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "doctrine/inflector": "^1.4 || ^2.0", "doctrine/instantiator": "^1.3 || ^2", "doctrine/lexer": "^3", - "doctrine/persistence": "^3.3.1", + "doctrine/persistence": "^3.3.1 || ^4", "psr/cache": "^1 || ^2 || ^3", "symfony/console": "^5.4 || ^6.0 || ^7.0", "symfony/var-exporter": "^6.3.9 || ^7.0" diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 4fde4cbf5e5..b14bbc6c1d8 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -48,6 +48,8 @@ + src/Mapping/Driver/LoadMappingFileImplementation.php + src/Mapping/GetReflectionClassImplementation.php tests/* diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7c8ec81ae84..1b6362a6d8e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -120,6 +120,11 @@ parameters: count: 1 path: src/EntityRepository.php + - + message: "#^If condition is always true\\.$#" + count: 1 + path: src/Mapping/ClassMetadata.php + - message: "#^If condition is always true\\.$#" count: 1 diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index 724fe2003f7..889d94c1df3 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -34,3 +34,8 @@ parameters: - message: '~deprecated class Doctrine\\DBAL\\Tools\\Console\\Command\\ReservedWordsCommand\:~' path: src/Tools/Console/ConsoleRunner.php + + # Compatibility with Persistence 3 + - + message: '#Expression on left side of \?\? is not nullable.#' + path: src/Mapping/Driver/AttributeDriver.php diff --git a/phpstan.neon b/phpstan.neon index d90ec9fe41f..f98eb8d00b8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -45,3 +45,8 @@ parameters: message: '#Negated boolean expression is always false\.#' paths: - src/Mapping/Driver/AttributeDriver.php + + # Compatibility with Persistence 3 + - + message: '#Expression on left side of \?\? is not nullable.#' + path: src/Mapping/Driver/AttributeDriver.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c7897f4d614..cef61546b74 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -298,15 +298,9 @@
- - - - - reflClass]]> - @@ -340,6 +334,7 @@ + reflClass]]> @@ -474,6 +469,14 @@ + + + + + + + + @@ -526,6 +529,14 @@ + + + + + + + + diff --git a/src/EntityManager.php b/src/EntityManager.php index eb5a123d0b6..5324d9cac7b 100644 --- a/src/EntityManager.php +++ b/src/EntityManager.php @@ -565,9 +565,9 @@ public function initializeObject(object $obj): void /** * {@inheritDoc} */ - public function isUninitializedObject($obj): bool + public function isUninitializedObject($value): bool { - return $this->unitOfWork->isUninitializedObject($obj); + return $this->unitOfWork->isUninitializedObject($value); } public function getFilters(): FilterCollection diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index 7c9020805a5..b91bd9b5ac1 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -73,6 +73,8 @@ */ class ClassMetadata implements PersistenceClassMetadata, Stringable { + use GetReflectionClassImplementation; + /* The inheritance mapping types */ /** * NONE means the class does not participate in an inheritance hierarchy @@ -932,16 +934,6 @@ public function validateLifecycleCallbacks(ReflectionService $reflService): void } } - /** - * {@inheritDoc} - * - * Can return null when using static reflection, in violation of the LSP - */ - public function getReflectionClass(): ReflectionClass|null - { - return $this->reflClass; - } - /** @psalm-param array{usage?: mixed, region?: mixed} $cache */ public function enableCache(array $cache): void { diff --git a/src/Mapping/Driver/LoadMappingFileImplementation.php b/src/Mapping/Driver/LoadMappingFileImplementation.php new file mode 100644 index 00000000000..df351889ba2 --- /dev/null +++ b/src/Mapping/Driver/LoadMappingFileImplementation.php @@ -0,0 +1,35 @@ +doLoadMappingFile($file); + } + } +} else { + /** @internal */ + trait LoadMappingFileImplementation + { + /** + * {@inheritDoc} + */ + protected function loadMappingFile($file) + { + return $this->doLoadMappingFile($file); + } + } +} diff --git a/src/Mapping/Driver/XmlDriver.php b/src/Mapping/Driver/XmlDriver.php index 30e85900e2e..e11b6b61d6f 100644 --- a/src/Mapping/Driver/XmlDriver.php +++ b/src/Mapping/Driver/XmlDriver.php @@ -43,6 +43,8 @@ */ class XmlDriver extends FileDriver { + use LoadMappingFileImplementation; + public const DEFAULT_FILE_EXTENSION = '.dcm.xml'; /** @@ -878,10 +880,8 @@ private function getCascadeMappings(SimpleXMLElement $cascadeElement): array return $cascades; } - /** - * {@inheritDoc} - */ - protected function loadMappingFile($file) + /** @return array */ + private function doLoadMappingFile(string $file): array { $this->validateMapping($file); $result = []; diff --git a/src/Mapping/GetReflectionClassImplementation.php b/src/Mapping/GetReflectionClassImplementation.php new file mode 100644 index 00000000000..780015c3680 --- /dev/null +++ b/src/Mapping/GetReflectionClassImplementation.php @@ -0,0 +1,33 @@ +reflClass; + } + } +} else { + trait GetReflectionClassImplementation + { + /** + * {@inheritDoc} + * + * Can return null when using static reflection, in violation of the LSP + */ + public function getReflectionClass(): ReflectionClass|null + { + return $this->reflClass; + } + } +} diff --git a/tests/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Performance/Mock/NonProxyLoadingEntityManager.php index 20f233e0089..bff330ab9be 100644 --- a/tests/Performance/Mock/NonProxyLoadingEntityManager.php +++ b/tests/Performance/Mock/NonProxyLoadingEntityManager.php @@ -212,4 +212,12 @@ public function contains(object $object): bool { return $this->realEntityManager->contains($object); } + + /** + * {@inheritDoc} + */ + public function isUninitializedObject($value): bool + { + return $this->realEntityManager->isUninitializedObject($value); + } } diff --git a/tests/Tests/Mocks/MetadataDriverMock.php b/tests/Tests/Mocks/MetadataDriverMock.php index b3be873c596..a2472cf8c46 100644 --- a/tests/Tests/Mocks/MetadataDriverMock.php +++ b/tests/Tests/Mocks/MetadataDriverMock.php @@ -15,14 +15,14 @@ class MetadataDriverMock implements MappingDriver /** * {@inheritDoc} */ - public function loadMetadataForClass($className, ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadata $metadata): void { } /** * {@inheritDoc} */ - public function isTransient($className) + public function isTransient($className): bool { return false; } @@ -30,7 +30,7 @@ public function isTransient($className) /** * {@inheritDoc} */ - public function getAllClassNames() + public function getAllClassNames(): array { return []; } diff --git a/tests/Tests/ORM/Functional/Ticket/DDC3103Test.php b/tests/Tests/ORM/Functional/Ticket/DDC3103Test.php index ec505c07741..5ead8d58698 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC3103Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC3103Test.php @@ -7,10 +7,12 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Embeddable; +use Doctrine\Persistence\Mapping\StaticReflectionService; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; +use function class_exists; use function serialize; use function unserialize; @@ -18,6 +20,15 @@ #[Group('DDC-3103')] class DDC3103Test extends OrmFunctionalTestCase { + protected function setUp(): void + { + if (! class_exists(StaticReflectionService::class)) { + self::markTestSkipped('This test is not supported by the current installed doctrine/persistence version'); + } + + parent::setUp(); + } + public function testIssue(): void { $classMetadata = new ClassMetadata(DDC3103ArticleId::class); @@ -39,7 +50,6 @@ public function testIssue(): void #[Embeddable] class DDC3103ArticleId { - /** @var string */ #[Column(name: 'name', type: 'string', length: 255)] - protected $nameValue; + protected string $nameValue; } diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index 38b2bde7ca9..60b1bc1822f 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -56,6 +56,7 @@ use stdClass; use function assert; +use function class_exists; use function count; use function serialize; use function str_contains; @@ -979,6 +980,10 @@ public function testCanInstantiateInternalPhpClassSubclassFromUnserializedMetada public function testWakeupReflectionWithEmbeddableAndStaticReflectionService(): void { + if (! class_exists(StaticReflectionService::class)) { + self::markTestSkipped('This test is not supported by the current installed doctrine/persistence version'); + } + $classMetadata = new ClassMetadata(TestEntity1::class); $classMetadata->mapEmbedded( From 4b03ec778995322e8b8c2dcd35bc52d0d2949ceb Mon Sep 17 00:00:00 2001 From: Mohamed Attia <92581654+Speelwolf@users.noreply.github.com> Date: Tue, 12 Nov 2024 00:02:38 +0100 Subject: [PATCH 447/475] Refine Explanations of Doctrine orm Package Structure (#11710) * Update architecture.rst * Update architecture.rst --- docs/en/reference/architecture.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/en/reference/architecture.rst b/docs/en/reference/architecture.rst index 7ba2ef774d7..5dabd259972 100644 --- a/docs/en/reference/architecture.rst +++ b/docs/en/reference/architecture.rst @@ -33,14 +33,13 @@ Doctrine ORM is divided into four main packages. - ORM (depends on DBAL+Persistence+Collections) This manual mainly covers the ORM package, sometimes touching parts -of the underlying DBAL and Persistence packages. The Doctrine code base -is split in to these packages for a few reasons and they are to... +of the underlying DBAL and Persistence packages. The Doctrine codebase +is split into these packages for a few reasons: -- ...make things more maintainable and decoupled -- ...allow you to use the code in Doctrine Persistence and Collections - without the ORM or DBAL -- ...allow you to use the DBAL without the ORM +- to make things more maintainable and decoupled +- to allow you to use the code in Doctrine Persistence and Collections without the ORM or DBAL +- to allow you to use the DBAL without the ORM Collection, Event Manager and Persistence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From da51234d5aaba3901e91461982c07e54d97cce9c Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 12 May 2022 22:26:34 +0200 Subject: [PATCH 448/475] [GH-3519] Deprecate passing the same class with different discriminator values. --- UPGRADE.md | 9 +++++++-- src/Mapping/ClassMetadata.php | 20 +++++++++++++++++++ tests/Tests/ORM/Mapping/ClassMetadataTest.php | 8 ++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 6da5e0be57c..12e67dee2cd 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,8 @@ +# Upgrade to 3.4 + +Using the same class several times in a discriminator map is deprecated. +In 4.0, this will be an error. + # Upgrade to 3.3 ## Deprecate `DatabaseDriver` @@ -737,7 +742,7 @@ Use `toIterable()` instead. Output walkers should implement the new `\Doctrine\ORM\Query\OutputWalker` interface and create `Doctrine\ORM\Query\Exec\SqlFinalizer` instances instead of `Doctrine\ORM\Query\Exec\AbstractSqlExecutor`s. -The output walker must not base its workings on the query `firstResult`/`maxResult` values, so that the +The output walker must not base its workings on the query `firstResult`/`maxResult` values, so that the `SqlFinalizer` can be kept in the query cache and used regardless of the actual `firstResult`/`maxResult` values. Any operation dependent on `firstResult`/`maxResult` should take place within the `SqlFinalizer::createExecutor()` method. Details can be found at https://github.com/doctrine/orm/pull/11188. @@ -750,7 +755,7 @@ change in behavior. Progress on this is tracked at https://github.com/doctrine/orm/issues/11624 . -## PARTIAL DQL syntax is undeprecated +## PARTIAL DQL syntax is undeprecated Use of the PARTIAL keyword is not deprecated anymore in DQL, because we will be able to support PARTIAL objects with PHP 8.4 Lazy Objects and diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index b91bd9b5ac1..a72099bd4d8 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -25,7 +25,10 @@ use Stringable; use function array_column; +use function array_count_values; use function array_diff; +use function array_filter; +use function array_flip; use function array_intersect; use function array_key_exists; use function array_keys; @@ -39,6 +42,7 @@ use function defined; use function enum_exists; use function explode; +use function implode; use function in_array; use function interface_exists; use function is_string; @@ -2178,6 +2182,22 @@ final public function getDiscriminatorColumn(): DiscriminatorColumnMapping */ public function setDiscriminatorMap(array $map): void { + if (count(array_flip($map)) !== count($map)) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/issues/3519', + <<<'DEPRECATION' + Mapping a class to multiple discriminator values is deprecated, + and the discriminator mapping of %s contains duplicate values + for the following discriminator values: %s. + DEPRECATION, + $this->name, + implode(', ', array_keys(array_filter(array_count_values($map), static function (int $value): bool { + return $value > 1; + }))), + ); + } + foreach ($map as $value => $className) { $this->addDiscriminatorMapClass($value, $className); } diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index 60b1bc1822f..57736cc68a8 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -1101,6 +1101,14 @@ public function testClassNameMappingDiscriminatorValue(): void $xmlElement->children()->{'discriminator-map'}->{'discriminator-mapping'}[0]->attributes()['value'], ); } + + public function testDiscriminatorMapWithSameClassMultipleTimesDeprecated(): void + { + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/3519'); + + $cm = new ClassMetadata(CMS\CmsUser::class); + $cm->setDiscriminatorMap(['foo' => CMS\CmsUser::class, 'bar' => CMS\CmsUser::class]); + } } #[MappedSuperclass] From 65e9f607e5d4888a05542d3ccf0f978bc43709a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 23 Nov 2024 21:05:10 +0100 Subject: [PATCH 449/475] Use properties over array keys Using array access is deprecated. --- .../Ticket/SwitchContextWithFilter/CompanySQLFilter.php | 4 ++-- tests/Tests/ORM/Mapping/ClassMetadataTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Tests/ORM/Functional/Ticket/SwitchContextWithFilter/CompanySQLFilter.php b/tests/Tests/ORM/Functional/Ticket/SwitchContextWithFilter/CompanySQLFilter.php index e65188334ac..d1e38528bf1 100644 --- a/tests/Tests/ORM/Functional/Ticket/SwitchContextWithFilter/CompanySQLFilter.php +++ b/tests/Tests/ORM/Functional/Ticket/SwitchContextWithFilter/CompanySQLFilter.php @@ -14,11 +14,11 @@ class CompanySQLFilter extends SQLFilter public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias): string { if ($targetEntity->getName() === User::class) { - return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']['fieldName'], $this->getParameter('company')); + return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']->fieldName, $this->getParameter('company')); } if ($targetEntity->getName() === Order::class) { - return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']['fieldName'], $this->getParameter('company')); + return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']->fieldName, $this->getParameter('company')); } return ''; diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index f187371dfd0..4c57891c2d8 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -886,7 +886,7 @@ public function testAssociationOverrideCanOverrideCascade(): void $cm->setAssociationOverride('parentDirectory', ['cascade' => ['all']]); $mapping = $cm->getAssociationMapping('parentDirectory'); - self::assertSame(['remove', 'persist', 'refresh', 'detach'], $mapping['cascade']); + self::assertSame(['remove', 'persist', 'refresh', 'detach'], $mapping->cascade); } #[TestGroup('DDC-1955')] From dd3604f523cc35283f0c4f4c36329b322845e57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 23 Nov 2024 21:06:56 +0100 Subject: [PATCH 450/475] Use properties over array keys Using array access is deprecated. --- src/PersistentCollection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PersistentCollection.php b/src/PersistentCollection.php index ef5f28c3cb3..876a92a261a 100644 --- a/src/PersistentCollection.php +++ b/src/PersistentCollection.php @@ -509,7 +509,7 @@ public function __wakeup(): void */ public function first() { - if (! $this->initialized && ! $this->isDirty && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) { + if (! $this->initialized && ! $this->isDirty && $this->getMapping()->fetch === ClassMetadata::FETCH_EXTRA_LAZY) { $persister = $this->getUnitOfWork()->getCollectionPersister($this->getMapping()); return array_values($persister->slice($this, 0, 1))[0] ?? false; From 4e01567816a0ed2ea3f8d83e151226faceb021d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 8 Dec 2024 12:47:41 +0100 Subject: [PATCH 451/475] Run tests with PHP 8.4 This change was accidentally dropped during a merge up. --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 0370ddd009a..ed36fd3675d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -41,7 +41,7 @@ jobs: uses: shivammathur/setup-php@v2 with: coverage: none - php-version: "8.3" + php-version: "8.4" tools: cs2pr - name: Require specific DBAL version From 7b9c0d91f667f4a82b58babad024b20e0744503c Mon Sep 17 00:00:00 2001 From: Claudio Zizza <859964+SenseException@users.noreply.github.com> Date: Thu, 12 Dec 2024 23:43:08 +0100 Subject: [PATCH 452/475] Create website schema validation workflow (#11763) --- .github/workflows/website-schema.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/website-schema.yml diff --git a/.github/workflows/website-schema.yml b/.github/workflows/website-schema.yml new file mode 100644 index 00000000000..e251588e5de --- /dev/null +++ b/.github/workflows/website-schema.yml @@ -0,0 +1,21 @@ + +name: "Website config validation" + +on: + pull_request: + branches: + - "*.x" + paths: + - ".doctrine-project.json" + - ".github/workflows/website-schema.yml" + push: + branches: + - "*.x" + paths: + - ".doctrine-project.json" + - ".github/workflows/website-schema.yml" + +jobs: + json-validate: + name: "Validate JSON schema" + uses: "doctrine/.github/.github/workflows/website-schema.yml@7.1.0" From 55dc02c39f540aaee5c8dee0e5908b5b21e3bf56 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Tue, 31 Dec 2024 00:09:28 +0100 Subject: [PATCH 453/475] changed confusing negative wording (#11775) --- docs/en/reference/inheritance-mapping.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/inheritance-mapping.rst b/docs/en/reference/inheritance-mapping.rst index 38696dd22a0..f06341810c0 100644 --- a/docs/en/reference/inheritance-mapping.rst +++ b/docs/en/reference/inheritance-mapping.rst @@ -16,7 +16,7 @@ is common to multiple entity classes. Mapped superclasses, just as regular, non-mapped classes, can appear in the middle of an otherwise mapped inheritance hierarchy (through Single Table Inheritance or Class Table Inheritance). They -are not query-able, and need not have an ``#[Id]`` property. +are not query-able, and do not require an ``#[Id]`` property. No database table will be created for a mapped superclass itself, only for entity classes inheriting from it. That implies that a From 68c87740aa07d547a60818a288b2ce44ee74aba0 Mon Sep 17 00:00:00 2001 From: Jamie Purchase Date: Wed, 1 Jan 2025 23:25:25 +0000 Subject: [PATCH 454/475] Update working-with-objects.rst (#7553) Spelling. --- docs/en/reference/working-with-objects.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index eded99a29ec..d780b553941 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -166,7 +166,7 @@ your code. See the following code: Traversing the object graph for parts that are lazy-loaded will easily trigger lots of SQL queries and will perform badly if used - to heavily. Make sure to use DQL to fetch-join all the parts of the + too heavily. Make sure to use DQL to fetch-join all the parts of the object-graph that you need as efficiently as possible. From 596da353c225ed0200599c9de637f29a967afb0e Mon Sep 17 00:00:00 2001 From: Jonny Eom Date: Thu, 16 Jan 2025 11:05:42 -0500 Subject: [PATCH 455/475] UPGRADE: Document QueryBuilder::setParameters() Type enforcement --- UPGRADE.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 817d1f0e004..73ae9d9a3cd 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -124,6 +124,36 @@ WARNING: This was relaxed in ORM 3.2 when partial was re-allowed for array-hydra `Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD` are removed. - `Doctrine\ORM\EntityManager*::getPartialReference()` is removed. +## BC BREAK: Enforce ArrayCollection Type on `\Doctrine\ORM\QueryBuilder::setParameters(ArrayCollection $parameters)` + +The argument $parameters can no longer be a key=>value array. Only ArrayCollection types are allowed. + +### Before + +```php +$qb = $em->createQueryBuilder() + ->select('u') + ->from('User', 'u') + ->where('u.id = :user_id1 OR u.id = :user_id2') + ->setParameter(array( + 'user_id1' => 1, + 'user_id2' => 2 + )); +``` + +### After + +```php +$qb = $em->createQueryBuilder() + ->select('u') + ->from('User', 'u') + ->where('u.id = :user_id1 OR u.id = :user_id2') + ->setParameter(new ArrayCollection(array( + new Parameter('user_id1', 1), + new Parameter('user_id2', 2) + ))); +``` + ## BC BREAK: `Doctrine\ORM\Persister\Entity\EntityPersister::executeInserts()` return type changed to `void` Implementors should adapt to the new signature, and should call From 27b47841be9995d122a34c70db8f1d6d55e0c4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 25 Jan 2025 10:44:53 +0100 Subject: [PATCH 456/475] Display Doctrine deprecations when running PHPUnit This will give a signal that there is work to be done without blocking other contributions by failing the build. --- phpunit.xml.dist | 8 ++++++++ tests/Tests/ORM/Functional/PaginationTest.php | 3 ++- .../ORM/Functional/ParserResultSerializationTest.php | 2 ++ tests/Tests/ORM/Mapping/ClassMetadataTest.php | 3 +++ tests/Tests/ORM/Mapping/TableMappingTest.php | 3 +++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 48d4a0f116f..5e26bd5898a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,6 +14,7 @@ --> + + + + + src + + diff --git a/tests/Tests/ORM/Functional/PaginationTest.php b/tests/Tests/ORM/Functional/PaginationTest.php index af7b83394ce..b8ea24e7fef 100644 --- a/tests/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Tests/ORM/Functional/PaginationTest.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Query\AST\PathExpression; use Doctrine\ORM\Query\AST\SelectStatement; use Doctrine\ORM\Query\AST\WhereClause; +use Doctrine\ORM\Query\SqlOutputWalker; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\TreeWalkerAdapter; use Doctrine\ORM\Tools\Pagination\Paginator; @@ -643,7 +644,7 @@ public function testCountQueryStripsParametersInSelect(): void self::assertCount(2, $getCountQuery->invoke($paginator)->getParameters()); self::assertCount(9, $paginator); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, SqlWalker::class); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, SqlOutputWalker::class); $paginator = new Paginator($query); diff --git a/tests/Tests/ORM/Functional/ParserResultSerializationTest.php b/tests/Tests/ORM/Functional/ParserResultSerializationTest.php index 6918bd8e50b..af247a35b87 100644 --- a/tests/Tests/ORM/Functional/ParserResultSerializationTest.php +++ b/tests/Tests/ORM/Functional/ParserResultSerializationTest.php @@ -14,6 +14,7 @@ use Doctrine\Tests\OrmFunctionalTestCase; use Generator; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\WithoutErrorHandler; use ReflectionMethod; use Symfony\Component\VarExporter\Instantiator; use Symfony\Component\VarExporter\VarExporter; @@ -34,6 +35,7 @@ protected function setUp(): void /** @param Closure(ParserResult): ParserResult $toSerializedAndBack */ #[DataProvider('provideToSerializedAndBack')] + #[WithoutErrorHandler] public function testSerializeParserResultForQueryWithSqlWalker(Closure $toSerializedAndBack): void { $query = $this->_em diff --git a/tests/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Tests/ORM/Mapping/ClassMetadataTest.php index 296c655d743..52e5853c8a1 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataTest.php @@ -52,6 +52,7 @@ use DoctrineGlobalArticle; use LogicException; use PHPUnit\Framework\Attributes\Group as TestGroup; +use PHPUnit\Framework\Attributes\WithoutErrorHandler; use ReflectionClass; use stdClass; @@ -1074,6 +1075,7 @@ public function testItAddingLifecycleCallbackOnEmbeddedClassIsIllegal(): void $metadata->addLifecycleCallback('foo', 'bar'); } + #[WithoutErrorHandler] public function testGettingAnFQCNForNullIsDeprecated(): void { $metadata = new ClassMetadata(self::class); @@ -1112,6 +1114,7 @@ public function testClassNameMappingDiscriminatorValue(): void ); } + #[WithoutErrorHandler] public function testDiscriminatorMapWithSameClassMultipleTimesDeprecated(): void { $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/3519'); diff --git a/tests/Tests/ORM/Mapping/TableMappingTest.php b/tests/Tests/ORM/Mapping/TableMappingTest.php index 24031eafa41..50ceaa5fce5 100644 --- a/tests/Tests/ORM/Mapping/TableMappingTest.php +++ b/tests/Tests/ORM/Mapping/TableMappingTest.php @@ -6,12 +6,14 @@ use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; use Doctrine\ORM\Mapping\Table; +use PHPUnit\Framework\Attributes\WithoutErrorHandler; use PHPUnit\Framework\TestCase; final class TableMappingTest extends TestCase { use VerifyDeprecations; + #[WithoutErrorHandler] public function testDeprecationOnIndexesPropertyIsTriggered(): void { $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/11357'); @@ -19,6 +21,7 @@ public function testDeprecationOnIndexesPropertyIsTriggered(): void new Table(indexes: []); } + #[WithoutErrorHandler] public function testDeprecationOnUniqueConstraintsPropertyIsTriggered(): void { $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/11357'); From aa141bf001588ab43e126db4152ec9b14e282f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 25 Jan 2025 12:17:06 +0100 Subject: [PATCH 457/475] Address quoteIdentifier() deprecation We should be using quoteSingleIdentifier(), assuming we only ever pass single identifiers here. See https://github.com/doctrine/dbal/pull/6590 --- src/Mapping/DefaultQuoteStrategy.php | 14 +++++++------- .../Tests/ORM/Functional/Ticket/DDC832Test.php | 10 +++++----- tests/Tests/OrmFunctionalTestCase.php | 18 +++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Mapping/DefaultQuoteStrategy.php b/src/Mapping/DefaultQuoteStrategy.php index 6260336c027..b42de4e862b 100644 --- a/src/Mapping/DefaultQuoteStrategy.php +++ b/src/Mapping/DefaultQuoteStrategy.php @@ -24,7 +24,7 @@ class DefaultQuoteStrategy implements QuoteStrategy public function getColumnName(string $fieldName, ClassMetadata $class, AbstractPlatform $platform): string { return isset($class->fieldMappings[$fieldName]->quoted) - ? $platform->quoteIdentifier($class->fieldMappings[$fieldName]->columnName) + ? $platform->quoteSingleIdentifier($class->fieldMappings[$fieldName]->columnName) : $class->fieldMappings[$fieldName]->columnName; } @@ -42,7 +42,7 @@ public function getTableName(ClassMetadata $class, AbstractPlatform $platform): } return isset($class->table['quoted']) - ? $platform->quoteIdentifier($tableName) + ? $platform->quoteSingleIdentifier($tableName) : $tableName; } @@ -52,14 +52,14 @@ public function getTableName(ClassMetadata $class, AbstractPlatform $platform): public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform): string { return isset($definition['quoted']) - ? $platform->quoteIdentifier($definition['sequenceName']) + ? $platform->quoteSingleIdentifier($definition['sequenceName']) : $definition['sequenceName']; } public function getJoinColumnName(JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string { return isset($joinColumn->quoted) - ? $platform->quoteIdentifier($joinColumn->name) + ? $platform->quoteSingleIdentifier($joinColumn->name) : $joinColumn->name; } @@ -69,7 +69,7 @@ public function getReferencedJoinColumnName( AbstractPlatform $platform, ): string { return isset($joinColumn->quoted) - ? $platform->quoteIdentifier($joinColumn->referencedColumnName) + ? $platform->quoteSingleIdentifier($joinColumn->referencedColumnName) : $joinColumn->referencedColumnName; } @@ -87,7 +87,7 @@ public function getJoinTableName( $tableName = $association->joinTable->name; if (isset($association->joinTable->quoted)) { - $tableName = $platform->quoteIdentifier($tableName); + $tableName = $platform->quoteSingleIdentifier($tableName); } return $schema . $tableName; @@ -113,7 +113,7 @@ public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $joinColumns = $assoc->joinColumns; $assocQuotedColumnNames = array_map( static fn (JoinColumnMapping $joinColumn) => isset($joinColumn->quoted) - ? $platform->quoteIdentifier($joinColumn->name) + ? $platform->quoteSingleIdentifier($joinColumn->name) : $joinColumn->name, $joinColumns, ); diff --git a/tests/Tests/ORM/Functional/Ticket/DDC832Test.php b/tests/Tests/ORM/Functional/Ticket/DDC832Test.php index ca7f948518e..834c7a5cf5a 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC832Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -42,14 +42,14 @@ public function tearDown(): void $platform = $this->_em->getConnection()->getDatabasePlatform(); $sm = $this->createSchemaManager(); - $sm->dropTable($platform->quoteIdentifier('TREE_INDEX')); - $sm->dropTable($platform->quoteIdentifier('INDEX')); - $sm->dropTable($platform->quoteIdentifier('LIKE')); + $sm->dropTable($platform->quoteSingleIdentifier('TREE_INDEX')); + $sm->dropTable($platform->quoteSingleIdentifier('INDEX')); + $sm->dropTable($platform->quoteSingleIdentifier('LIKE')); // DBAL 3 if ($platform instanceof PostgreSQLPlatform && method_exists($platform, 'getIdentitySequenceName')) { - $sm->dropSequence($platform->quoteIdentifier('INDEX_id_seq')); - $sm->dropSequence($platform->quoteIdentifier('LIKE_id_seq')); + $sm->dropSequence($platform->quoteSingleIdentifier('INDEX_id_seq')); + $sm->dropSequence($platform->quoteSingleIdentifier('LIKE_id_seq')); } } diff --git a/tests/Tests/OrmFunctionalTestCase.php b/tests/Tests/OrmFunctionalTestCase.php index f2cf5f81f18..efd380dc1de 100644 --- a/tests/Tests/OrmFunctionalTestCase.php +++ b/tests/Tests/OrmFunctionalTestCase.php @@ -614,7 +614,7 @@ protected function tearDown(): void } if (isset($this->_usedModelSets['directorytree'])) { - $conn->executeStatement('DELETE FROM ' . $platform->quoteIdentifier('file')); + $conn->executeStatement('DELETE FROM ' . $platform->quoteSingleIdentifier('file')); // MySQL doesn't know deferred deletions therefore only executing the second query gives errors. $conn->executeStatement('DELETE FROM Directory WHERE parentDirectory_id IS NOT NULL'); $conn->executeStatement('DELETE FROM Directory'); @@ -707,17 +707,17 @@ protected function tearDown(): void $conn->executeStatement( sprintf( 'UPDATE %s SET %s = NULL', - $platform->quoteIdentifier('quote-address'), - $platform->quoteIdentifier('user-id'), + $platform->quoteSingleIdentifier('quote-address'), + $platform->quoteSingleIdentifier('user-id'), ), ); - $conn->executeStatement('DELETE FROM ' . $platform->quoteIdentifier('quote-users-groups')); - $conn->executeStatement('DELETE FROM ' . $platform->quoteIdentifier('quote-group')); - $conn->executeStatement('DELETE FROM ' . $platform->quoteIdentifier('quote-phone')); - $conn->executeStatement('DELETE FROM ' . $platform->quoteIdentifier('quote-user')); - $conn->executeStatement('DELETE FROM ' . $platform->quoteIdentifier('quote-address')); - $conn->executeStatement('DELETE FROM ' . $platform->quoteIdentifier('quote-city')); + $conn->executeStatement('DELETE FROM ' . $platform->quoteSingleIdentifier('quote-users-groups')); + $conn->executeStatement('DELETE FROM ' . $platform->quoteSingleIdentifier('quote-group')); + $conn->executeStatement('DELETE FROM ' . $platform->quoteSingleIdentifier('quote-phone')); + $conn->executeStatement('DELETE FROM ' . $platform->quoteSingleIdentifier('quote-user')); + $conn->executeStatement('DELETE FROM ' . $platform->quoteSingleIdentifier('quote-address')); + $conn->executeStatement('DELETE FROM ' . $platform->quoteSingleIdentifier('quote-city')); } if (isset($this->_usedModelSets['vct_onetoone'])) { From f8fdeaf41eec0aa8882c7d62aa31ea4732b0ce7b Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Wed, 12 Feb 2025 00:10:14 +0100 Subject: [PATCH 458/475] UPGRADE.md: fix typo (#11832) --- UPGRADE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 73ae9d9a3cd..085f645c3f5 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -135,7 +135,7 @@ $qb = $em->createQueryBuilder() ->select('u') ->from('User', 'u') ->where('u.id = :user_id1 OR u.id = :user_id2') - ->setParameter(array( + ->setParameters(array( 'user_id1' => 1, 'user_id2' => 2 )); @@ -148,7 +148,7 @@ $qb = $em->createQueryBuilder() ->select('u') ->from('User', 'u') ->where('u.id = :user_id1 OR u.id = :user_id2') - ->setParameter(new ArrayCollection(array( + ->setParameters(new ArrayCollection(array( new Parameter('user_id1', 1), new Parameter('user_id2', 2) ))); From 1aed318b7b85eefa280580cea3734831a1697b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 17 Feb 2025 19:16:25 +0100 Subject: [PATCH 459/475] Restore logic exception This exception was dropped by mistake during a merge-up, and should be present until Doctrine officially supports property hooks. --- src/Mapping/ClassMetadata.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php index 7351d09bce0..e1cbd6306a5 100644 --- a/src/Mapping/ClassMetadata.php +++ b/src/Mapping/ClassMetadata.php @@ -57,6 +57,8 @@ use function trait_exists; use function trim; +use const PHP_VERSION_ID; + /** * A ClassMetadata instance holds all the object-relational mapping metadata * of an entity and its associations. @@ -2673,6 +2675,10 @@ private function getAccessibleProperty(ReflectionService $reflService, string $c } } + if (PHP_VERSION_ID >= 80400 && $reflectionProperty !== null && count($reflectionProperty->getHooks()) > 0) { + throw new LogicException('Doctrine ORM does not support property hooks in this version. Check https://github.com/doctrine/orm/issues/11624 for details of versions that support property hooks.'); + } + return $reflectionProperty; } } From 708bd84fe222cf4793dda81cbc5a6e79e5bbc435 Mon Sep 17 00:00:00 2001 From: eltharin Date: Fri, 21 Feb 2025 10:35:12 +0100 Subject: [PATCH 460/475] fix bugs nested dto are not in good argument order dto with only dto does'nt work --- src/Internal/Hydration/AbstractHydrator.php | 33 ++- src/Query/AST/NewObjectExpression.php | 14 +- src/Query/Parser.php | 7 +- src/Query/ResultSetMapping.php | 7 + src/Query/SqlWalker.php | 27 +- tests/Tests/Models/CMS/CmsAddressDTO.php | 2 +- tests/Tests/Models/CMS/CmsDumbDTO.php | 17 ++ .../Tests/ORM/Functional/NewOperatorTest.php | 250 +++++++++++++++++- 8 files changed, 316 insertions(+), 41 deletions(-) create mode 100644 tests/Tests/Models/CMS/CmsDumbDTO.php diff --git a/src/Internal/Hydration/AbstractHydrator.php b/src/Internal/Hydration/AbstractHydrator.php index 0a44d3a02b5..140ccb6b685 100644 --- a/src/Internal/Hydration/AbstractHydrator.php +++ b/src/Internal/Hydration/AbstractHydrator.php @@ -18,12 +18,14 @@ use LogicException; use ReflectionClass; +use function array_key_exists; use function array_map; use function array_merge; use function count; use function end; use function in_array; use function is_array; +use function ksort; /** * Base class for all hydrators. A hydrator is a class that provides some form @@ -263,6 +265,17 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon { $rowData = ['data' => [], 'newObjects' => []]; + foreach ($this->rsm->newObjectMappings as $mapping) { + if (! array_key_exists($mapping['objIndex'], $this->rsm->newObject)) { + $this->rsm->newObject[$mapping['objIndex']] = $mapping['className']; + } + } + + foreach ($this->rsm->newObject as $objIndex => $newObject) { + $rowData['newObjects'][$objIndex]['class'] = new ReflectionClass($newObject); + $rowData['newObjects'][$objIndex]['args'] = []; + } + foreach ($data as $key => $value) { $cacheKeyInfo = $this->hydrateColumnInfo($key); if ($cacheKeyInfo === null) { @@ -282,7 +295,6 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon $value = $this->buildEnum($value, $cacheKeyInfo['enumType']); } - $rowData['newObjects'][$objIndex]['class'] = $cacheKeyInfo['class']; $rowData['newObjects'][$objIndex]['args'][$argIndex] = $value; break; @@ -336,21 +348,17 @@ protected function gatherRowData(array $data, array &$id, array &$nonemptyCompon } } - foreach ($this->resultSetMapping()->nestedNewObjectArguments as $objIndex => ['ownerIndex' => $ownerIndex, 'argIndex' => $argIndex]) { - if (! isset($rowData['newObjects'][$ownerIndex . ':' . $argIndex])) { - continue; + foreach ($this->resultSetMapping()->nestedNewObjectArguments as ['ownerIndex' => $ownerIndex, 'argIndex' => $argIndex, 'argAlias' => $argAlias]) { + if (array_key_exists($argAlias, $rowData['newObjects'])) { + ksort($rowData['newObjects'][$argAlias]['args']); + $rowData['newObjects'][$ownerIndex]['args'][$argIndex] = $rowData['newObjects'][$argAlias]['class']->newInstanceArgs($rowData['newObjects'][$argAlias]['args']); + unset($rowData['newObjects'][$argAlias]); } - - $newObject = $rowData['newObjects'][$ownerIndex . ':' . $argIndex]; - unset($rowData['newObjects'][$ownerIndex . ':' . $argIndex]); - - $obj = $newObject['class']->newInstanceArgs($newObject['args']); - - $rowData['newObjects'][$ownerIndex]['args'][$argIndex] = $obj; } foreach ($rowData['newObjects'] as $objIndex => $newObject) { - $obj = $newObject['class']->newInstanceArgs($newObject['args']); + ksort($rowData['newObjects'][$objIndex]['args']); + $obj = $rowData['newObjects'][$objIndex]['class']->newInstanceArgs($rowData['newObjects'][$objIndex]['args']); $rowData['newObjects'][$objIndex]['obj'] = $obj; } @@ -454,7 +462,6 @@ protected function hydrateColumnInfo(string $key): array|null 'type' => Type::getType($this->rsm->typeMappings[$key]), 'argIndex' => $mapping['argIndex'], 'objIndex' => $mapping['objIndex'], - 'class' => new ReflectionClass($mapping['className']), 'enumType' => $this->rsm->enumMappings[$key] ?? null, ]; diff --git a/src/Query/AST/NewObjectExpression.php b/src/Query/AST/NewObjectExpression.php index 7383c487234..1d46722676e 100644 --- a/src/Query/AST/NewObjectExpression.php +++ b/src/Query/AST/NewObjectExpression.php @@ -6,6 +6,9 @@ use Doctrine\ORM\Query\SqlWalker; +use function func_get_arg; +use function func_num_args; + /** * NewObjectExpression ::= "NEW" IdentificationVariable "(" NewObjectArg {"," NewObjectArg}* ")" * @@ -13,13 +16,18 @@ */ class NewObjectExpression extends Node { - /** @param mixed[] $args */ + /** + * @param class-string $className + * @param mixed[] $args + */ public function __construct(public string $className, public array $args) { } - public function dispatch(SqlWalker $walker): string + public function dispatch(SqlWalker $walker /*, string|null $parentAlias = null */): string { - return $walker->walkNewObject($this); + $parentAlias = func_num_args() > 1 ? func_get_arg(1) : null; + + return $walker->walkNewObject($this, $parentAlias); } } diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 86fb8243b49..1b7c9fc6490 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -1767,6 +1767,7 @@ public function NewObjectExpression(): AST\NewObjectExpression $useNamedArguments = true; } + /** @var class-string $className */ $className = $this->AbstractSchemaName(); // note that this is not yet validated $token = $this->lexer->token; @@ -1854,7 +1855,11 @@ public function NewObjectArg(string|null &$fieldAlias = null): mixed if ($this->lexer->isNextToken(TokenType::T_AS)) { $this->match(TokenType::T_AS); - $fieldAlias = $this->AliasIdentificationVariable(); + $this->match(TokenType::T_IDENTIFIER); + + assert($this->lexer->token !== null); + + $fieldAlias = $this->lexer->token->value; } return $expression; diff --git a/src/Query/ResultSetMapping.php b/src/Query/ResultSetMapping.php index c0ccc127fd5..d8f4bc76693 100644 --- a/src/Query/ResultSetMapping.php +++ b/src/Query/ResultSetMapping.php @@ -159,6 +159,13 @@ class ResultSetMapping */ public array $newObjectMappings = []; + /** + * Maps object Ids in the result set to classnames. + * + * @phpstan-var array + */ + public array $newObject = []; + /** * Maps last argument for new objects in order to initiate object construction * diff --git a/src/Query/SqlWalker.php b/src/Query/SqlWalker.php index 9089995e432..9113cbc7080 100644 --- a/src/Query/SqlWalker.php +++ b/src/Query/SqlWalker.php @@ -24,10 +24,8 @@ use function array_keys; use function array_map; use function array_merge; -use function array_pop; use function assert; use function count; -use function end; use function implode; use function in_array; use function is_array; @@ -84,13 +82,6 @@ class SqlWalker */ private int $newObjectCounter = 0; - /** - * Contains nesting levels of new objects arguments - * - * @phpstan-var array - */ - private array $newObjectStack = []; - private readonly EntityManagerInterface $em; private readonly Connection $conn; @@ -1507,14 +1498,7 @@ public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesis public function walkNewObject(AST\NewObjectExpression $newObjectExpression, string|null $newObjectResultAlias = null): string { $sqlSelectExpressions = []; - $objOwner = $objOwnerIdx = null; - - if ($this->newObjectStack !== []) { - [$objOwner, $objOwnerIdx] = end($this->newObjectStack); - $objIndex = $objOwner . ':' . $objOwnerIdx; - } else { - $objIndex = $newObjectResultAlias ?: $this->newObjectCounter++; - } + $objIndex = $newObjectResultAlias ?: $this->newObjectCounter++; foreach ($newObjectExpression->args as $argIndex => $e) { $resultAlias = $this->scalarResultCounter++; @@ -1523,10 +1507,8 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri switch (true) { case $e instanceof AST\NewObjectExpression: - $this->newObjectStack[] = [$objIndex, $argIndex]; - $sqlSelectExpressions[] = $e->dispatch($this); - array_pop($this->newObjectStack); - $this->rsm->nestedNewObjectArguments[$columnAlias] = ['ownerIndex' => $objIndex, 'argIndex' => $argIndex]; + $sqlSelectExpressions[] = $e->dispatch($this, $columnAlias); + $this->rsm->nestedNewObjectArguments[$columnAlias] = ['ownerIndex' => $objIndex, 'argIndex' => $argIndex, 'argAlias' => $columnAlias]; break; case $e instanceof AST\Subselect: @@ -1576,12 +1558,13 @@ public function walkNewObject(AST\NewObjectExpression $newObjectExpression, stri $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldType); $this->rsm->newObjectMappings[$columnAlias] = [ - 'className' => $newObjectExpression->className, 'objIndex' => $objIndex, 'argIndex' => $argIndex, ]; } + $this->rsm->newObject[$objIndex] = $newObjectExpression->className; + return implode(', ', $sqlSelectExpressions); } diff --git a/tests/Tests/Models/CMS/CmsAddressDTO.php b/tests/Tests/Models/CMS/CmsAddressDTO.php index 502644ed25e..0d615aadbb9 100644 --- a/tests/Tests/Models/CMS/CmsAddressDTO.php +++ b/tests/Tests/Models/CMS/CmsAddressDTO.php @@ -6,7 +6,7 @@ class CmsAddressDTO { - public function __construct(public string|null $country = null, public string|null $city = null, public string|null $zip = null, public CmsAddressDTO|string|null $address = null) + public function __construct(public string|null $country = null, public string|null $city = null, public string|null $zip = null, public string|null $address = null, public CmsDumbDTO|null $other = null) { } } diff --git a/tests/Tests/Models/CMS/CmsDumbDTO.php b/tests/Tests/Models/CMS/CmsDumbDTO.php new file mode 100644 index 00000000000..8891436fad6 --- /dev/null +++ b/tests/Tests/Models/CMS/CmsDumbDTO.php @@ -0,0 +1,17 @@ +fixtures[1]->address->country, $result[1]['user']->address->country); self::assertSame($this->fixtures[2]->address->country, $result[2]['user']->address->country); + self::assertInstanceOf(CmsDumbDTO::class, $result[0]['user']->address->other); + self::assertInstanceOf(CmsDumbDTO::class, $result[1]['user']->address->other); + self::assertInstanceOf(CmsDumbDTO::class, $result[2]['user']->address->other); + + self::assertSame($this->fixtures[0]->address->country, $result[0]['user']->address->other->val1); + self::assertSame($this->fixtures[1]->address->country, $result[1]['user']->address->other->val1); + self::assertSame($this->fixtures[2]->address->country, $result[2]['user']->address->other->val1); + + self::assertSame($this->fixtures[0]->address->city, $result[0]['user']->address->other->val2); + self::assertSame($this->fixtures[1]->address->city, $result[1]['user']->address->other->val2); + self::assertSame($this->fixtures[2]->address->city, $result[2]['user']->address->other->val2); + + self::assertSame($this->fixtures[0]->status, $result[0]['status']); + self::assertSame($this->fixtures[1]->status, $result[1]['status']); + self::assertSame($this->fixtures[2]->status, $result[2]['status']); + + self::assertSame($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertSame($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + } + + public function testShouldSupportNestedNewOperatorsWithDtoFirst(): void + { + $dql = ' + SELECT + new CmsUserDTO( + u.name, + e.email, + new CmsAddressDTO( + a.country, + a.city, + a.zip + ), + 555812452 + ) as user, + u.status, + u.username as cmsUserUsername + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e + JOIN + u.address a + ORDER BY + u.name'; + + $query = $this->getEntityManager()->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(3, $result); + + self::assertInstanceOf(CmsUserDTO::class, $result[0]['user']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['user']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['user']); + + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['user']->address); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['user']->address); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['user']->address); + + self::assertSame($this->fixtures[0]->name, $result[0]['user']->name); + self::assertSame($this->fixtures[1]->name, $result[1]['user']->name); + self::assertSame($this->fixtures[2]->name, $result[2]['user']->name); + + self::assertSame($this->fixtures[0]->email->email, $result[0]['user']->email); + self::assertSame($this->fixtures[1]->email->email, $result[1]['user']->email); + self::assertSame($this->fixtures[2]->email->email, $result[2]['user']->email); + + self::assertSame($this->fixtures[0]->address->city, $result[0]['user']->address->city); + self::assertSame($this->fixtures[1]->address->city, $result[1]['user']->address->city); + self::assertSame($this->fixtures[2]->address->city, $result[2]['user']->address->city); + + self::assertSame($this->fixtures[0]->address->country, $result[0]['user']->address->country); + self::assertSame($this->fixtures[1]->address->country, $result[1]['user']->address->country); + self::assertSame($this->fixtures[2]->address->country, $result[2]['user']->address->country); + + self::assertSame(555812452, $result[0]['user']->phonenumbers); + self::assertSame(555812452, $result[1]['user']->phonenumbers); + self::assertSame(555812452, $result[2]['user']->phonenumbers); + self::assertSame($this->fixtures[0]->status, $result[0]['status']); self::assertSame($this->fixtures[1]->status, $result[1]['status']); self::assertSame($this->fixtures[2]->status, $result[2]['status']); @@ -1087,6 +1168,68 @@ public function testShouldSupportNestedNewOperators(): void self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); } + public function testOnlyObjectInObject(): void + { + $dql = ' + SELECT + new CmsDumbDTO( + new CmsDumbDTO( + u.name, + e.email + ), + new CmsAddressDTO( + a.country, + a.city, + a.zip + ) + ) as user + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e + JOIN + u.address a + ORDER BY + u.name'; + + $query = $this->getEntityManager()->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(3, $result); + + self::assertInstanceOf(CmsDumbDTO::class, $result[0]); + self::assertInstanceOf(CmsDumbDTO::class, $result[1]); + self::assertInstanceOf(CmsDumbDTO::class, $result[2]); + + self::assertInstanceOf(CmsDumbDTO::class, $result[0]->val1); + self::assertInstanceOf(CmsDumbDTO::class, $result[1]->val1); + self::assertInstanceOf(CmsDumbDTO::class, $result[2]->val1); + + self::assertSame($this->fixtures[0]->name, $result[0]->val1->val1); + self::assertSame($this->fixtures[1]->name, $result[1]->val1->val1); + self::assertSame($this->fixtures[2]->name, $result[2]->val1->val1); + + self::assertSame($this->fixtures[0]->email->email, $result[0]->val1->val2); + self::assertSame($this->fixtures[1]->email->email, $result[1]->val1->val2); + self::assertSame($this->fixtures[2]->email->email, $result[2]->val1->val2); + + self::assertInstanceOf(CmsAddressDTO::class, $result[0]->val2); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]->val2); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]->val2); + + self::assertSame($this->fixtures[0]->address->country, $result[0]->val2->country); + self::assertSame($this->fixtures[1]->address->country, $result[1]->val2->country); + self::assertSame($this->fixtures[2]->address->country, $result[2]->val2->country); + + self::assertSame($this->fixtures[0]->address->city, $result[0]->val2->city); + self::assertSame($this->fixtures[1]->address->city, $result[1]->val2->city); + self::assertSame($this->fixtures[2]->address->city, $result[2]->val2->city); + + self::assertSame($this->fixtures[0]->address->zip, $result[0]->val2->zip); + self::assertSame($this->fixtures[1]->address->zip, $result[1]->val2->zip); + self::assertSame($this->fixtures[2]->address->zip, $result[2]->val2->zip); + } + public function testNamedArguments(): void { $dql = <<<'SQL' @@ -1159,6 +1302,111 @@ public function testNamedArguments(): void self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); } + public function testShouldSupportNestedNewOperatorsWithNestedDtoNotLast(): void + { + $dql = ' + SELECT + new CmsUserDTO( + u.name, + e.email, + new CmsAddressDTO( + a.country, + a.city, + a.zip, + \'Abbey Road\', + new CmsDumbDTO( + a.country, + a.city, + new CmsDumbDTO( + a.zip, + 456 + ), + a.zip + ) + ), + 555812452 + ) as user, + u.status, + u.username as cmsUserUsername + FROM + Doctrine\Tests\Models\CMS\CmsUser u + JOIN + u.email e + JOIN + u.address a + ORDER BY + u.name'; + + $query = $this->getEntityManager()->createQuery($dql); + $result = $query->getResult(); + + self::assertCount(3, $result); + + self::assertInstanceOf(CmsUserDTO::class, $result[0]['user']); + self::assertInstanceOf(CmsUserDTO::class, $result[1]['user']); + self::assertInstanceOf(CmsUserDTO::class, $result[2]['user']); + + self::assertSame($this->fixtures[0]->name, $result[0]['user']->name); + self::assertSame($this->fixtures[1]->name, $result[1]['user']->name); + self::assertSame($this->fixtures[2]->name, $result[2]['user']->name); + + self::assertSame($this->fixtures[0]->email->email, $result[0]['user']->email); + self::assertSame($this->fixtures[1]->email->email, $result[1]['user']->email); + self::assertSame($this->fixtures[2]->email->email, $result[2]['user']->email); + + self::assertInstanceOf(CmsAddressDTO::class, $result[0]['user']->address); + self::assertInstanceOf(CmsAddressDTO::class, $result[1]['user']->address); + self::assertInstanceOf(CmsAddressDTO::class, $result[2]['user']->address); + + self::assertSame($this->fixtures[0]->address->country, $result[0]['user']->address->country); + self::assertSame($this->fixtures[1]->address->country, $result[1]['user']->address->country); + self::assertSame($this->fixtures[2]->address->country, $result[2]['user']->address->country); + + self::assertSame($this->fixtures[2]->address->city, $result[2]['user']->address->city); + self::assertSame($this->fixtures[0]->address->city, $result[0]['user']->address->city); + self::assertSame($this->fixtures[1]->address->city, $result[1]['user']->address->city); + + self::assertInstanceOf(CmsDumbDTO::class, $result[0]['user']->address->other); + self::assertInstanceOf(CmsDumbDTO::class, $result[1]['user']->address->other); + self::assertInstanceOf(CmsDumbDTO::class, $result[2]['user']->address->other); + + self::assertSame($this->fixtures[0]->address->country, $result[0]['user']->address->other->val1); + self::assertSame($this->fixtures[1]->address->country, $result[1]['user']->address->other->val1); + self::assertSame($this->fixtures[2]->address->country, $result[2]['user']->address->other->val1); + + self::assertSame($this->fixtures[0]->address->city, $result[0]['user']->address->other->val2); + self::assertSame($this->fixtures[1]->address->city, $result[1]['user']->address->other->val2); + self::assertSame($this->fixtures[2]->address->city, $result[2]['user']->address->other->val2); + + self::assertInstanceOf(CmsDumbDTO::class, $result[0]['user']->address->other->val3); + self::assertInstanceOf(CmsDumbDTO::class, $result[1]['user']->address->other->val3); + self::assertInstanceOf(CmsDumbDTO::class, $result[2]['user']->address->other->val3); + + self::assertSame($this->fixtures[0]->address->zip, $result[0]['user']->address->other->val3->val1); + self::assertSame($this->fixtures[1]->address->zip, $result[1]['user']->address->other->val3->val1); + self::assertSame($this->fixtures[2]->address->zip, $result[2]['user']->address->other->val3->val1); + + self::assertSame(456, $result[0]['user']->address->other->val3->val2); + self::assertSame(456, $result[1]['user']->address->other->val3->val2); + self::assertSame(456, $result[2]['user']->address->other->val3->val2); + + self::assertSame($this->fixtures[0]->address->zip, $result[0]['user']->address->other->val4); + self::assertSame($this->fixtures[1]->address->zip, $result[1]['user']->address->other->val4); + self::assertSame($this->fixtures[2]->address->zip, $result[2]['user']->address->other->val4); + + self::assertSame(555812452, $result[0]['user']->phonenumbers); + self::assertSame(555812452, $result[1]['user']->phonenumbers); + self::assertSame(555812452, $result[2]['user']->phonenumbers); + + self::assertSame($this->fixtures[0]->status, $result[0]['status']); + self::assertSame($this->fixtures[1]->status, $result[1]['status']); + self::assertSame($this->fixtures[2]->status, $result[2]['status']); + + self::assertSame($this->fixtures[0]->username, $result[0]['cmsUserUsername']); + self::assertSame($this->fixtures[1]->username, $result[1]['cmsUserUsername']); + self::assertSame($this->fixtures[2]->username, $result[2]['cmsUserUsername']); + } + public function testVariadicArgument(): void { $dql = <<<'SQL' From 8e620cad40a78151047cb3bdfdf4618672a58b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 18 Mar 2025 19:52:28 +0100 Subject: [PATCH 461/475] Do not run CI jobs when changing dev PHPUnit file This file is never used in the CI. --- .github/workflows/continuous-integration.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 252c9ff5ca0..f7837683447 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -9,7 +9,6 @@ on: - ci/** - composer.* - src/** - - phpunit.xml.dist - tests/** push: branches: @@ -19,7 +18,6 @@ on: - ci/** - composer.* - src/** - - phpunit.xml.dist - tests/** env: From baf2c60cc4be3721af2c963b55348750d6e8f395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 18 Mar 2025 19:50:46 +0100 Subject: [PATCH 462/475] Use more similar PHPUnit configurations The dev configuration and CI configuration should not diverge this much. I do not think the current situation was intended. A difference that remains after my changes is the bootstrap file, which in dev seems aimed at helping contributors setup their environment. --- ci/github/phpunit/mysqli.xml | 8 +++++++- ci/github/phpunit/pdo_mysql.xml | 8 +++++++- ci/github/phpunit/pdo_pgsql.xml | 8 +++++++- ci/github/phpunit/pdo_sqlite.xml | 8 +++++++- ci/github/phpunit/pgsql.xml | 8 +++++++- ci/github/phpunit/sqlite3.xml | 8 +++++++- phpunit.xml.dist | 1 + 7 files changed, 43 insertions(+), 6 deletions(-) diff --git a/ci/github/phpunit/mysqli.xml b/ci/github/phpunit/mysqli.xml index 23a44eb5fca..b128eccbdb7 100644 --- a/ci/github/phpunit/mysqli.xml +++ b/ci/github/phpunit/mysqli.xml @@ -3,6 +3,11 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" + failOnNotice="true" + failOnWarning="true" failOnRisky="true" cacheDirectory=".phpunit.cache" > @@ -19,6 +24,7 @@ + @@ -27,7 +33,7 @@ - + ../../../src diff --git a/ci/github/phpunit/pdo_mysql.xml b/ci/github/phpunit/pdo_mysql.xml index 1db2cd4fb06..e04e96eb66b 100644 --- a/ci/github/phpunit/pdo_mysql.xml +++ b/ci/github/phpunit/pdo_mysql.xml @@ -3,6 +3,11 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" + failOnNotice="true" + failOnWarning="true" failOnRisky="true" cacheDirectory=".phpunit.cache" > @@ -19,6 +24,7 @@ + @@ -27,7 +33,7 @@ - + ../../../src diff --git a/ci/github/phpunit/pdo_pgsql.xml b/ci/github/phpunit/pdo_pgsql.xml index 53f270152b3..f087ce58edf 100644 --- a/ci/github/phpunit/pdo_pgsql.xml +++ b/ci/github/phpunit/pdo_pgsql.xml @@ -3,6 +3,11 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" + failOnNotice="true" + failOnWarning="true" failOnRisky="true" cacheDirectory=".phpunit.cache" > @@ -16,6 +21,7 @@ + @@ -24,7 +30,7 @@ - + ../../../src diff --git a/ci/github/phpunit/pdo_sqlite.xml b/ci/github/phpunit/pdo_sqlite.xml index 385026dc732..ad4eaa84498 100644 --- a/ci/github/phpunit/pdo_sqlite.xml +++ b/ci/github/phpunit/pdo_sqlite.xml @@ -3,6 +3,11 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" + failOnNotice="true" + failOnWarning="true" failOnRisky="true" cacheDirectory=".phpunit.cache" > @@ -14,6 +19,7 @@ + @@ -22,7 +28,7 @@ - + ../../../src diff --git a/ci/github/phpunit/pgsql.xml b/ci/github/phpunit/pgsql.xml index 58225decbe2..98c238ef8a0 100644 --- a/ci/github/phpunit/pgsql.xml +++ b/ci/github/phpunit/pgsql.xml @@ -3,6 +3,11 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" + failOnNotice="true" + failOnWarning="true" failOnRisky="true" cacheDirectory=".phpunit.cache" > @@ -16,6 +21,7 @@ + @@ -24,7 +30,7 @@ - + ../../../src diff --git a/ci/github/phpunit/sqlite3.xml b/ci/github/phpunit/sqlite3.xml index a4f313b2e81..5a1afa87195 100644 --- a/ci/github/phpunit/sqlite3.xml +++ b/ci/github/phpunit/sqlite3.xml @@ -3,6 +3,11 @@ xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" + failOnNotice="true" + failOnWarning="true" failOnRisky="true" cacheDirectory=".phpunit.cache" > @@ -14,6 +19,7 @@ + @@ -22,7 +28,7 @@ - + ../../../src diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5e26bd5898a..8b7b9c95399 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,6 +14,7 @@ Date: Mon, 24 Mar 2025 11:34:25 +0100 Subject: [PATCH 463/475] adapt assertions for new consistent PRIMARY KEY formatting --- .../SchemaTool/MySqlSchemaToolTest.php | 60 ++++++++++++++++--- .../ORM/Functional/Ticket/DDC2182Test.php | 14 ++++- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index cbfc491d654..5f8ec2b8bc9 100644 --- a/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -50,24 +50,58 @@ public function testGetCreateSchemaSql(): void $tool = new SchemaTool($this->_em); $sql = $tool->getCreateSchemaSql($classes); - self::assertEquals('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); + self::assertThat($sql[0], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); self::assertThat($sql[1], self::logicalOr( // DBAL 3 self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); + self::assertThat($sql[2], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY (user_id, group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); + self::assertThat($sql[3], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY (user_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); + self::assertThat($sql[4], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), )); - self::assertEquals('CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[2]); - self::assertEquals('CREATE TABLE cms_users_tags (user_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_93F5A1ADA76ED395 (user_id), INDEX IDX_93F5A1ADBAD26311 (tag_id), PRIMARY KEY(user_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[3]); - self::assertEquals('CREATE TABLE cms_tags (id INT AUTO_INCREMENT NOT NULL, tag_name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[4]); self::assertThat($sql[5], self::logicalOr( // DBAL 3 self::equalTo('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), // DBAL 4 (see https://github.com/doctrine/dbal/pull/4777) self::equalTo('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); + self::assertThat($sql[6], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); + self::assertThat($sql[7], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY (phonenumber)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), )); - self::assertEquals('CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[6]); - self::assertEquals('CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[7]); self::assertEquals('ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)', $sql[8]); self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)', $sql[9]); self::assertEquals('ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id)', $sql[10]); @@ -87,7 +121,12 @@ public function testGetCreateSchemaSql2(): void $sql = $tool->getCreateSchemaSql($classes); self::assertCount(1, $sql); - self::assertEquals('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); + self::assertThat($sql[0], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); } public function testGetCreateSchemaSql3(): void @@ -98,7 +137,12 @@ public function testGetCreateSchemaSql3(): void $sql = $tool->getCreateSchemaSql($classes); self::assertCount(1, $sql); - self::assertEquals('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); + self::assertThat($sql[0], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); } #[Group('DBAL-204')] diff --git a/tests/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2182Test.php index d804be0caef..3354b39db25 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC2182Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -27,8 +27,18 @@ public function testPassColumnOptionsToJoinColumns(): void $this->_em->getClassMetadata(DDC2182OptionChild::class), ], ); - self::assertEquals('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[0]); - self::assertEquals('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB', $sql[1]); + self::assertThat($sql[0], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); + self::assertThat($sql[1], self::logicalOr( + // DBAL < 4.3 + self::equalTo('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + // DBAL 4.3 (see https://github.com/doctrine/dbal/pull/6864) + self::equalTo('CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'), + )); self::assertEquals('ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)', $sql[2]); } } From c55f10e5018864d888447e35799901106ef1f51a Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 24 Mar 2025 11:10:31 +0100 Subject: [PATCH 464/475] favor Table::addPrimaryKeyConstraint() over Table::setPrimaryKey() --- phpstan-dbal3.neon | 12 ++++ phpstan.neon | 12 ++++ src/Tools/SchemaTool.php | 26 +++++++- .../ORM/Functional/DatabaseDriverTest.php | 65 ++++++++++++++++--- .../ORM/Functional/Ticket/DDC2387Test.php | 20 +++++- .../ORM/Functional/Ticket/GH7684Test.php | 20 +++++- 6 files changed, 140 insertions(+), 15 deletions(-) diff --git a/phpstan-dbal3.neon b/phpstan-dbal3.neon index ea39e2c3a0b..d53e03530c6 100644 --- a/phpstan-dbal3.neon +++ b/phpstan-dbal3.neon @@ -22,6 +22,18 @@ parameters: message: '~.*getTrimExpression.*expects int.*~' path: src/Query/AST/Functions/TrimFunction.php + - + message: '~^Call to static method unquoted\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\Identifier\.$~' + path: src/Tools/SchemaTool.php + + - + message: '~^Instantiated class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName not found\.$~' + path: src/Tools/SchemaTool.php + + - + message: '~^Call to an undefined method Doctrine\\DBAL\\Schema\\Table::addPrimaryKeyConstraint\(\)\.$~' + path: src/Tools/SchemaTool.php + - '~^Class Doctrine\\DBAL\\Platforms\\SQLitePlatform not found\.$~' # To be removed in 4.0 diff --git a/phpstan.neon b/phpstan.neon index f98eb8d00b8..0002fb5af8d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -20,6 +20,18 @@ parameters: message: '~^Method Doctrine\\ORM\\Persisters\\Entity\\BasicEntityPersister\:\:getArrayBindingType\(\) never returns .* so it can be removed from the return type\.$~' path: src/Persisters/Entity/BasicEntityPersister.php + - + message: '~^Call to static method unquoted\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\Identifier\.$~' + path: src/Tools/SchemaTool.php + + - + message: '~^Instantiated class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName not found\.$~' + path: src/Tools/SchemaTool.php + + - + message: '~^Call to an undefined method Doctrine\\DBAL\\Schema\\Table::addPrimaryKeyConstraint\(\)\.$~' + path: src/Tools/SchemaTool.php + # Compatibility with DBAL 3 # See https://github.com/doctrine/dbal/pull/3480 - diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index 5057d1866a8..abb46131e28 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -9,6 +9,9 @@ use Doctrine\DBAL\Schema\AbstractAsset; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\Name\Identifier; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; use Doctrine\ORM\EntityManagerInterface; @@ -32,6 +35,7 @@ use function array_flip; use function array_intersect_key; use function assert; +use function class_exists; use function count; use function current; use function implode; @@ -282,7 +286,7 @@ public function getSchemaFromMetadata(array $classes): Schema } if ($pkColumns !== []) { - $table->setPrimaryKey($pkColumns); + self::addPrimaryKeyConstraint($table, $pkColumns); } } } else { @@ -306,7 +310,7 @@ public function getSchemaFromMetadata(array $classes): Schema } if (! $table->hasIndex('primary')) { - $table->setPrimaryKey($pkColumns); + self::addPrimaryKeyConstraint($table, $pkColumns); } // there can be unique indexes automatically created for join column @@ -572,7 +576,7 @@ private function gatherRelationsSql( $blacklistedFks, ); - $theJoinTable->setPrimaryKey($primaryKeyColumns); + self::addPrimaryKeyConstraint($theJoinTable, $primaryKeyColumns); } } } @@ -923,4 +927,20 @@ private function createSchemaForComparison(Schema $toSchema): Schema $config->setSchemaAssetsFilter($previousFilter); } } + + /** @param string[] $primaryKeyColumns */ + private function addPrimaryKeyConstraint(Table $table, array $primaryKeyColumns): void + { + if (class_exists(PrimaryKeyConstraint::class)) { + $primaryKeyColumnNames = []; + + foreach ($primaryKeyColumns as $primaryKeyColumn) { + $primaryKeyColumnNames[] = new UnqualifiedName(Identifier::unquoted($primaryKeyColumn)); + } + + $table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, $primaryKeyColumnNames, true)); + } else { + $table->setPrimaryKey($primaryKeyColumns); + } + } } diff --git a/tests/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Tests/ORM/Functional/DatabaseDriverTest.php index f2ef9e58f62..7c91bfb7ceb 100644 --- a/tests/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Tests/ORM/Functional/DatabaseDriverTest.php @@ -8,10 +8,14 @@ use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\Name\Identifier; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\Table; use PHPUnit\Framework\Attributes\Group; use function array_change_key_case; +use function class_exists; use function count; use function strtolower; @@ -36,12 +40,24 @@ public function testIssue2059(): void { $user = new Table('ddc2059_user'); $user->addColumn('id', 'integer'); - $user->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $user->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $user->setPrimaryKey(['id']); + } + $project = new Table('ddc2059_project'); $project->addColumn('id', 'integer'); $project->addColumn('user_id', 'integer'); $project->addColumn('user', 'string'); - $project->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $project->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $project->setPrimaryKey(['id']); + } + $project->addForeignKeyConstraint('ddc2059_user', ['user_id'], ['id']); $metadata = $this->convertToClassMetadata([$project, $user], []); @@ -54,7 +70,13 @@ public function testLoadMetadataFromDatabase(): void { $table = new Table('dbdriver_foo'); $table->addColumn('id', 'integer'); - $table->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $table->setPrimaryKey(['id']); + } + $table->addColumn('bar', 'string', ['notnull' => false, 'length' => 200]); $this->dropAndCreateTable($table); @@ -81,13 +103,24 @@ public function testLoadMetadataWithForeignKeyFromDatabase(): void { $tableB = new Table('dbdriver_bar'); $tableB->addColumn('id', 'integer'); - $tableB->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $tableB->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $tableB->setPrimaryKey(['id']); + } $this->dropAndCreateTable($tableB); $tableA = new Table('dbdriver_baz'); $tableA->addColumn('id', 'integer'); - $tableA->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $tableA->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $tableA->setPrimaryKey(['id']); + } + $tableA->addColumn('bar_id', 'integer'); $tableA->addForeignKeyConstraint('dbdriver_bar', ['bar_id'], ['id']); @@ -127,11 +160,21 @@ public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails(): void { $tableB = new Table('dbdriver_bar'); $tableB->addColumn('id', 'integer'); - $tableB->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $tableB->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $tableB->setPrimaryKey(['id']); + } $tableA = new Table('dbdriver_baz'); $tableA->addColumn('id', 'integer'); - $tableA->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $tableA->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $tableA->setPrimaryKey(['id']); + } $tableMany = new Table('dbdriver_bar_baz'); $tableMany->addColumn('bar_id', 'integer'); @@ -148,7 +191,13 @@ public function testLoadMetadataFromDatabaseDetail(): void $table = new Table('dbdriver_foo'); $table->addColumn('id', 'integer', ['unsigned' => true]); - $table->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $table->setPrimaryKey(['id']); + } + $table->addColumn('column_unsigned', 'integer', ['unsigned' => true]); $table->addColumn('column_comment', 'string', ['length' => 16, 'comment' => 'test_comment']); $table->addColumn('column_default', 'string', ['length' => 16, 'default' => 'test_default']); diff --git a/tests/Tests/ORM/Functional/Ticket/DDC2387Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2387Test.php index 997f7e5e49b..1958be65561 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC2387Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC2387Test.php @@ -4,11 +4,16 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\DBAL\Schema\Name\Identifier; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\Table; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\ORM\Functional\DatabaseDriverTestCase; use PHPUnit\Framework\Attributes\Group; +use function class_exists; + class DDC2387Test extends DatabaseDriverTestCase { #[Group('DDC-2387')] @@ -16,12 +21,23 @@ public function testCompositeAssociationKeyDetection(): void { $product = new Table('ddc2387_product'); $product->addColumn('id', 'integer'); - $product->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $product->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $product->setPrimaryKey(['id']); + } $attributes = new Table('ddc2387_attributes'); $attributes->addColumn('product_id', 'integer'); $attributes->addColumn('attribute_name', 'string'); - $attributes->setPrimaryKey(['product_id', 'attribute_name']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $attributes->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('product_id')), new UnqualifiedName(Identifier::unquoted('attribute_name'))], true)); + } else { + $attributes->setPrimaryKey(['product_id', 'attribute_name']); + } + $attributes->addForeignKeyConstraint('ddc2387_product', ['product_id'], ['product_id']); $metadata = $this->convertToClassMetadata([$product, $attributes], []); diff --git a/tests/Tests/ORM/Functional/Ticket/GH7684Test.php b/tests/Tests/ORM/Functional/Ticket/GH7684Test.php index 654b1cd8655..628bd1ba244 100644 --- a/tests/Tests/ORM/Functional/Ticket/GH7684Test.php +++ b/tests/Tests/ORM/Functional/Ticket/GH7684Test.php @@ -4,9 +4,14 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\DBAL\Schema\Name\Identifier; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\ORM\Functional\DatabaseDriverTestCase; +use function class_exists; + /** * Verifies that associations/columns with an inline '_id' get named properly * @@ -18,12 +23,23 @@ public function testIssue(): void { $table1 = new Table('GH7684_identity_test_table'); $table1->addColumn('id', 'integer'); - $table1->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $table1->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $table1->setPrimaryKey(['id']); + } $table2 = new Table('GH7684_identity_test_assoc_table'); $table2->addColumn('id', 'integer'); $table2->addColumn('gh7684_identity_test_id', 'integer'); - $table2->setPrimaryKey(['id']); + + if (class_exists(PrimaryKeyConstraint::class)) { + $table2->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true)); + } else { + $table2->setPrimaryKey(['id']); + } + $table2->addForeignKeyConstraint('GH7684_identity_test', ['gh7684_identity_test_id'], ['id']); $metadatas = $this->convertToClassMetadata([$table1, $table2]); From 36b9064dbe0199879e8c531d0286332126cf0a0f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 7 Apr 2025 08:38:30 +0200 Subject: [PATCH 465/475] replace Index::overrules() with custom checks --- src/Tools/SchemaTool.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index abb46131e28..22ccd41e428 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -319,7 +319,7 @@ public function getSchemaFromMetadata(array $classes): Schema $primaryKey = $table->getIndex('primary'); foreach ($table->getIndexes() as $idxKey => $existingIndex) { - if ($primaryKey->overrules($existingIndex)) { + if (! $existingIndex->isPrimary() && $primaryKey->spansColumns($existingIndex->getColumns())) { $table->dropIndex($idxKey); } } From e2430ac9a78f5d17c61f200f5374bf482d7b998f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 15 Apr 2025 11:58:22 +0200 Subject: [PATCH 466/475] no longer use Table::columnsAreIndexed() --- tests/Tests/ORM/Functional/Ticket/DDC2138Test.php | 15 +++++++++++++-- tests/Tests/ORM/Tools/SchemaToolTest.php | 14 +++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php index 58d029b0100..95923582e75 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -42,8 +42,8 @@ public function testForeignKeyOnSTIWithMultipleMapping(): void $table = $schema->getTable('users_followed_objects'); assert($table instanceof DbalTable); - self::assertTrue($table->columnsAreIndexed(['object_id'])); - self::assertTrue($table->columnsAreIndexed(['user_id'])); + self::assertTrue(self::columnIsIndexed($table, 'object_id')); + self::assertTrue(self::columnIsIndexed($table, 'user_id')); $foreignKeys = $table->getForeignKeys(); self::assertCount(1, $foreignKeys, 'user_id column has to have FK, but not object_id'); @@ -55,6 +55,17 @@ public function testForeignKeyOnSTIWithMultipleMapping(): void self::assertContains('user_id', $localColumns); self::assertCount(1, $localColumns); } + + private static function columnIsIndexed(DbalTable $table, string $column): bool + { + foreach ($table->getIndexes() as $index) { + if ($index->spansColumns([$column])) { + return true; + } + } + + return false; + } } diff --git a/tests/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php index 36037fcf569..5786bbd440f 100644 --- a/tests/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Tests/ORM/Tools/SchemaToolTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\Common\Collections\Collection; +use Doctrine\DBAL\Schema\Table as DbalTable; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -65,7 +66,7 @@ public function testAddUniqueIndexForUniqueFieldAttribute(): void $schema = $schemaTool->getSchemaFromMetadata($classes); self::assertTrue($schema->hasTable('cms_users'), 'Table cms_users should exist.'); - self::assertTrue($schema->getTable('cms_users')->columnsAreIndexed(['username']), 'username column should be indexed.'); + self::assertTrue(self::columnIsIndexed($schema->getTable('cms_users'), 'username'), 'username column should be indexed.'); } public function testAttributeOptionsArgument(): void @@ -391,6 +392,17 @@ public function testLoadUniqueConstraintWithoutName(): void self::assertTrue($tableIndex->isUnique()); self::assertSame(['field', 'anotherField'], $tableIndex->getColumns()); } + + private static function columnIsIndexed(DbalTable $table, string $column): bool + { + foreach ($table->getIndexes() as $index) { + if ($index->spansColumns([$column])) { + return true; + } + } + + return false; + } } #[Table(options: ['foo' => 'bar', 'baz' => ['key' => 'val']])] From d659591b6c20d88ab19eee21bb35bd10c7d490ae Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 15 Apr 2025 11:34:09 +0200 Subject: [PATCH 467/475] use the platform to quote table names --- tests/Tests/OrmFunctionalTestCase.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/Tests/OrmFunctionalTestCase.php b/tests/Tests/OrmFunctionalTestCase.php index 15396634076..c74abb42f12 100644 --- a/tests/Tests/OrmFunctionalTestCase.php +++ b/tests/Tests/OrmFunctionalTestCase.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\NamedObject; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; @@ -1104,7 +1105,12 @@ protected function dropAndCreateTable(Table $table): void { $schemaManager = $this->createSchemaManager(); $platform = $this->_em->getConnection()->getDatabasePlatform(); - $tableName = $table->getQuotedName($platform); + + if ($table instanceof NamedObject) { + $tableName = $table->getObjectName()->toSQL($platform); + } else { + $tableName = $table->getQuotedName($platform); + } $this->dropTableIfExists($tableName); $schemaManager->createTable($table); From a9f9202c00e9b1ef45c4a44c1668d74fe4e2d768 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 15 Apr 2025 10:37:59 +0200 Subject: [PATCH 468/475] do not use deprecated foreign key constraint features --- phpstan-baseline.neon | 66 +++++++++++++++++++ src/Mapping/Driver/DatabaseDriver.php | 63 +++++++++++++----- src/Tools/SchemaTool.php | 15 ++++- .../ORM/Functional/Ticket/DDC2138Test.php | 16 ++++- tests/Tests/ORM/Tools/SchemaToolTest.php | 21 ++++-- 5 files changed, 159 insertions(+), 22 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 44cb4153e21..ffefa53dc69 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1350,6 +1350,30 @@ parameters: count: 1 path: src/Mapping/Driver/AttributeDriver.php + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\:\:getReferencedColumnNames\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\:\:getReferencedTableName\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\:\:getReferencingColumnNames\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + + - + message: '#^Call to method toString\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' + identifier: class.notFound + count: 2 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Cannot call method getName\(\) on Doctrine\\DBAL\\Schema\\Column\|false\.$#' identifier: method.nonObject @@ -1398,6 +1422,12 @@ parameters: count: 4 path: src/Mapping/Driver/DatabaseDriver.php + - + message: '#^Parameter \$name of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' + identifier: class.notFound + count: 2 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Method Doctrine\\ORM\\Mapping\\Driver\\SimplifiedXmlDriver\:\:__construct\(\) has parameter \$fileExtension with no type specified\.$#' identifier: missingType.parameter @@ -3048,12 +3078,42 @@ parameters: count: 3 path: src/Tools/SchemaTool.php + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\:\:getReferencedColumnNames\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Tools/SchemaTool.php + + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\:\:getReferencedTableName\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Tools/SchemaTool.php + + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint\:\:getReferencingColumnNames\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Tools/SchemaTool.php + + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\Table\:\:dropForeignKey\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Tools/SchemaTool.php + - message: '#^Call to function is_numeric\(\) with int\<0, max\> will always evaluate to true\.$#' identifier: function.alreadyNarrowedType count: 1 path: src/Tools/SchemaTool.php + - + message: '#^Call to method toString\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' + identifier: class.notFound + count: 2 + path: src/Tools/SchemaTool.php + - message: '#^Method Doctrine\\ORM\\Tools\\SchemaTool\:\:addDiscriminatorColumnDefinition\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics @@ -3156,6 +3216,12 @@ parameters: count: 1 path: src/Tools/SchemaTool.php + - + message: '#^Parameter \$name of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' + identifier: class.notFound + count: 2 + path: src/Tools/SchemaTool.php + - message: '#^Property Doctrine\\ORM\\Tools\\SchemaTool\:\:\$schemaManager with generic class Doctrine\\DBAL\\Schema\\AbstractSchemaManager does not specify its types\: T$#' identifier: missingType.generics diff --git a/src/Mapping/Driver/DatabaseDriver.php b/src/Mapping/Driver/DatabaseDriver.php index fd5ff5fc8e8..723cb41f315 100644 --- a/src/Mapping/Driver/DatabaseDriver.php +++ b/src/Mapping/Driver/DatabaseDriver.php @@ -6,6 +6,8 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; @@ -21,12 +23,14 @@ use function array_diff; use function array_keys; +use function array_map; use function array_merge; use function assert; use function count; use function current; use function get_debug_type; use function in_array; +use function method_exists; use function preg_replace; use function sort; use function sprintf; @@ -187,7 +191,7 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata foreach ($this->manyToManyTables as $manyTable) { foreach ($manyTable->getForeignKeys() as $foreignKey) { // foreign key maps to the table of the current entity, many to many association probably exists - if (! (strtolower($tableName) === strtolower($foreignKey->getForeignTableName()))) { + if (! (strtolower($tableName) === strtolower(self::getReferencedTableName($foreignKey)))) { continue; } @@ -207,22 +211,22 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata continue; } - $localColumn = current($myFk->getLocalColumns()); + $localColumn = current(self::getReferencingColumnNames($myFk)); $associationMapping = []; - $associationMapping['fieldName'] = $this->getFieldNameForColumn($manyTable->getName(), current($otherFk->getLocalColumns()), true); - $associationMapping['targetEntity'] = $this->getClassNameForTable($otherFk->getForeignTableName()); + $associationMapping['fieldName'] = $this->getFieldNameForColumn($manyTable->getName(), current(self::getReferencingColumnNames($otherFk)), true); + $associationMapping['targetEntity'] = $this->getClassNameForTable(self::getReferencedTableName($otherFk)); if (current($manyTable->getColumns())->getName() === $localColumn) { - $associationMapping['inversedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getLocalColumns()), true); + $associationMapping['inversedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current(self::getReferencingColumnNames($myFk)), true); $associationMapping['joinTable'] = [ 'name' => strtolower($manyTable->getName()), 'joinColumns' => [], 'inverseJoinColumns' => [], ]; - $fkCols = $myFk->getForeignColumns(); - $cols = $myFk->getLocalColumns(); + $fkCols = self::getReferencedColumnNames($myFk); + $cols = self::getReferencingColumnNames($myFk); for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) { $associationMapping['joinTable']['joinColumns'][] = [ @@ -231,8 +235,8 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata ]; } - $fkCols = $otherFk->getForeignColumns(); - $cols = $otherFk->getLocalColumns(); + $fkCols = self::getReferencedColumnNames($otherFk); + $cols = self::getReferencingColumnNames($otherFk); for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) { $associationMapping['joinTable']['inverseJoinColumns'][] = [ @@ -241,7 +245,7 @@ public function loadMetadataForClass(string $className, PersistenceClassMetadata ]; } } else { - $associationMapping['mappedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current($myFk->getLocalColumns()), true); + $associationMapping['mappedBy'] = $this->getFieldNameForColumn($manyTable->getName(), current(self::getReferencingColumnNames($myFk)), true); } $metadata->mapManyToMany($associationMapping); @@ -267,7 +271,7 @@ private function reverseEngineerMappingFromDatabase(): void $allForeignKeyColumns = []; foreach ($foreignKeys as $foreignKey) { - $allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns()); + $allForeignKeyColumns = array_merge($allForeignKeyColumns, self::getReferencingColumnNames($foreignKey)); } $primaryKey = $table->getPrimaryKey(); @@ -331,7 +335,7 @@ private function buildFieldMappings(ClassMetadata $metadata): void $allForeignKeys = []; foreach ($foreignKeys as $foreignKey) { - $allForeignKeys = array_merge($allForeignKeys, $foreignKey->getLocalColumns()); + $allForeignKeys = array_merge($allForeignKeys, self::getReferencingColumnNames($foreignKey)); } $ids = []; @@ -441,9 +445,9 @@ private function buildToOneAssociationMappings(ClassMetadata $metadata): void $foreignKeys = $this->tables[$tableName]->getForeignKeys(); foreach ($foreignKeys as $foreignKey) { - $foreignTableName = $foreignKey->getForeignTableName(); - $fkColumns = $foreignKey->getLocalColumns(); - $fkForeignColumns = $foreignKey->getForeignColumns(); + $foreignTableName = self::getReferencedTableName($foreignKey); + $fkColumns = self::getReferencingColumnNames($foreignKey); + $fkForeignColumns = self::getReferencedColumnNames($foreignKey); $localColumn = current($fkColumns); $associationMapping = [ 'fieldName' => $this->getFieldNameForColumn($tableName, $localColumn, true), @@ -527,4 +531,33 @@ private function getFieldNameForColumn( return $this->inflector->camelize($columnName); } + + private static function getReferencedTableName(ForeignKeyConstraint $foreignKey): string + { + if (method_exists(ForeignKeyConstraint::class, 'getReferencedTableName')) { + return $foreignKey->getReferencedTableName()->toString(); + } + + return $foreignKey->getForeignTableName(); + } + + /** @return string[] */ + private static function getReferencingColumnNames(ForeignKeyConstraint $foreignKey): array + { + if (method_exists(ForeignKeyConstraint::class, 'getReferencingColumnNames')) { + return array_map(static fn (UnqualifiedName $name) => $name->toString(), $foreignKey->getReferencingColumnNames()); + } + + return $foreignKey->getLocalColumns(); + } + + /** @return string[] */ + private static function getReferencedColumnNames(ForeignKeyConstraint $foreignKey): array + { + if (method_exists(ForeignKeyConstraint::class, 'getReferencedColumnNames')) { + return array_map(static fn (UnqualifiedName $name) => $name->toString(), $foreignKey->getReferencedColumnNames()); + } + + return $foreignKey->getForeignColumns(); + } } diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index 22ccd41e428..27d9c727d71 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractAsset; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor; use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Name\Identifier; use Doctrine\DBAL\Schema\Name\UnqualifiedName; @@ -34,6 +35,7 @@ use function array_filter; use function array_flip; use function array_intersect_key; +use function array_map; use function assert; use function class_exists; use function count; @@ -729,7 +731,18 @@ private function gatherRelationJoinColumns( ) { foreach ($theJoinTable->getForeignKeys() as $fkName => $key) { if ( - count(array_diff($key->getLocalColumns(), $localColumns)) === 0 + class_exists(ForeignKeyConstraintEditor::class) + && count(array_diff(array_map(static fn (UnqualifiedName $name) => $name->toString(), $key->getReferencingColumnNames()), $localColumns)) === 0 + && (($key->getReferencedTableName()->toString() !== $foreignTableName) + || 0 < count(array_diff(array_map(static fn (UnqualifiedName $name) => $name->toString(), $key->getReferencedColumnNames()), $foreignColumns))) + ) { + $theJoinTable->dropForeignKey($fkName); + break; + } + + if ( + ! class_exists(ForeignKeyConstraintEditor::class) + && count(array_diff($key->getLocalColumns(), $localColumns)) === 0 && (($key->getForeignTableName() !== $foreignTableName) || 0 < count(array_diff($key->getForeignColumns(), $foreignColumns))) ) { diff --git a/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php index 95923582e75..a2b3ebb82c2 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC2138Test.php @@ -6,6 +6,8 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; use Doctrine\DBAL\Schema\Table as DbalTable; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorColumn; @@ -22,7 +24,9 @@ use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\Group; +use function array_map; use function assert; +use function class_exists; use function reset; class DDC2138Test extends OrmFunctionalTestCase @@ -49,9 +53,17 @@ public function testForeignKeyOnSTIWithMultipleMapping(): void $fk = reset($foreignKeys); assert($fk instanceof ForeignKeyConstraint); - self::assertEquals('users', $fk->getForeignTableName()); - $localColumns = $fk->getLocalColumns(); + if (class_exists(ForeignKeyConstraintEditor::class)) { + self::assertEquals('users', $fk->getReferencedTableName()->toString()); + + $localColumns = array_map(static fn (UnqualifiedName $name) => $name->toString(), $fk->getReferencingColumnNames()); + } else { + self::assertEquals('users', $fk->getForeignTableName()); + + $localColumns = $fk->getLocalColumns(); + } + self::assertContains('user_id', $localColumns); self::assertCount(1, $localColumns); } diff --git a/tests/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php index 5786bbd440f..31e8af16c7e 100644 --- a/tests/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Tests/ORM/Tools/SchemaToolTest.php @@ -5,6 +5,8 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\Common\Collections\Collection; +use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor; +use Doctrine\DBAL\Schema\Name\UnqualifiedName; use Doctrine\DBAL\Schema\Table as DbalTable; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; @@ -43,6 +45,8 @@ use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\Attributes\Group; +use function array_map; +use function class_exists; use function count; use function current; @@ -291,12 +295,21 @@ public function testDerivedCompositeKey(): void ]; foreach ($childTableForeignKeys as $foreignKey) { - self::assertArrayHasKey($foreignKey->getForeignTableName(), $expectedColumns); + if (class_exists(ForeignKeyConstraintEditor::class)) { + self::assertArrayHasKey($foreignKey->getReferencedTableName()->toString(), $expectedColumns); - [$localColumns, $foreignColumns] = $expectedColumns[$foreignKey->getForeignTableName()]; + [$localColumns, $foreignColumns] = $expectedColumns[$foreignKey->getReferencedTableName()->toString()]; - self::assertSame($localColumns, $foreignKey->getLocalColumns()); - self::assertSame($foreignColumns, $foreignKey->getForeignColumns()); + self::assertSame($localColumns, array_map(static fn (UnqualifiedName $name) => $name->toString(), $foreignKey->getReferencingColumnNames())); + self::assertSame($foreignColumns, array_map(static fn (UnqualifiedName $name) => $name->toString(), $foreignKey->getReferencedColumnNames())); + } else { + self::assertArrayHasKey($foreignKey->getForeignTableName(), $expectedColumns); + + [$localColumns, $foreignColumns] = $expectedColumns[$foreignKey->getForeignTableName()]; + + self::assertSame($localColumns, $foreignKey->getLocalColumns()); + self::assertSame($foreignColumns, $foreignKey->getForeignColumns()); + } } } From 65d27207641790f6dc8f8fe5dfbb36a20e1bd3c3 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 15 Apr 2025 10:18:11 +0200 Subject: [PATCH 469/475] [#6823] pass unquoted identifier folding to AbstractPlatform --- tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php | 4 +++- .../ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php | 3 +++ tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php | 5 ++++- tests/Tests/ORM/Query/QueryTest.php | 3 +++ tests/Tests/ORM/Tools/Pagination/PaginatorTest.php | 4 ++++ tests/Tests/ORM/UnitOfWorkTest.php | 3 +++ tests/Tests/OrmTestCase.php | 3 +++ 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php b/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php index 949e668154e..b808f31d67b 100644 --- a/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php +++ b/tests/Tests/ORM/Mapping/DefaultQuoteStrategyTest.php @@ -5,12 +5,14 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding; use Doctrine\ORM\Mapping\DefaultQuoteStrategy; use Doctrine\Tests\Models\NonPublicSchemaJoins\User as NonPublicSchemaUser; use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\Attributes\Group; use function assert; +use function enum_exists; /** * Doctrine\Tests\ORM\Mapping\DefaultQuoteStrategyTest @@ -24,7 +26,7 @@ public function testGetJoinTableName(): void $em = $this->getTestEntityManager(); $metadata = $em->getClassMetadata(NonPublicSchemaUser::class); $strategy = new DefaultQuoteStrategy(); - $platform = $this->getMockForAbstractClass(AbstractPlatform::class); + $platform = $this->getMockForAbstractClass(AbstractPlatform::class, enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : []); assert($platform instanceof AbstractPlatform); self::assertSame( diff --git a/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index 3bfbbeacdd5..f0ab8a0ac66 100644 --- a/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\Mapping\OneToManyAssociationMapping; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; @@ -23,6 +24,7 @@ use ReflectionMethod; use function array_slice; +use function enum_exists; class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase { @@ -65,6 +67,7 @@ public function testUpdateUsesTypeValuesSQL(): void ->willReturn($this->createMock(Driver\Connection::class)); $platform = $this->getMockBuilder(AbstractPlatform::class) + ->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : []) ->onlyMethods(['supportsIdentityColumns']) ->getMockForAbstractClass(); $platform->method('supportsIdentityColumns') diff --git a/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php b/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php index c9db932c60f..e3a78dba89d 100644 --- a/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php +++ b/tests/Tests/ORM/Persisters/ManyToManyPersisterTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding; use Doctrine\ORM\Persisters\Collection\ManyToManyPersister; use Doctrine\Tests\Models\ManyToManyPersister\ChildClass; use Doctrine\Tests\Models\ManyToManyPersister\OtherParentClass; @@ -15,6 +16,8 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; +use function enum_exists; + #[CoversClass(ManyToManyPersister::class)] final class ManyToManyPersisterTest extends OrmTestCase { @@ -31,7 +34,7 @@ public function testDeleteManyToManyCollection(): void ->onlyMethods(['executeStatement', 'getDatabasePlatform']) ->getMock(); $connection->method('getDatabasePlatform') - ->willReturn($this->getMockForAbstractClass(AbstractPlatform::class)); + ->willReturn($this->getMockForAbstractClass(AbstractPlatform::class, enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : [])); $parent = new ParentClass(1); $otherParent = new OtherParentClass(42); diff --git a/tests/Tests/ORM/Query/QueryTest.php b/tests/Tests/ORM/Query/QueryTest.php index 5e0bf0685f9..a2bfed19a64 100644 --- a/tests/Tests/ORM/Query/QueryTest.php +++ b/tests/Tests/ORM/Query/QueryTest.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\LockMode; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query; @@ -39,6 +40,7 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter; use function array_map; +use function enum_exists; class QueryTest extends OrmTestCase { @@ -597,6 +599,7 @@ private function createConnection(Result ...$results): Connection ->will($this->onConsecutiveCalls(...$results)); $platform = $this->getMockBuilder(AbstractPlatform::class) + ->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : []) ->onlyMethods(['supportsIdentityColumns']) ->getMockForAbstractClass(); $platform->method('supportsIdentityColumns') diff --git a/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php b/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php index fcd8a9b2aa7..16f0c28e12a 100644 --- a/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php +++ b/tests/Tests/ORM/Tools/Pagination/PaginatorTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Result; +use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding; use Doctrine\ORM\Decorator\EntityManagerDecorator; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; @@ -17,6 +18,8 @@ use Doctrine\Tests\OrmTestCase; use PHPUnit\Framework\MockObject\MockObject; +use function enum_exists; + class PaginatorTest extends OrmTestCase { private Connection&MockObject $connection; @@ -26,6 +29,7 @@ class PaginatorTest extends OrmTestCase protected function setUp(): void { $platform = $this->getMockBuilder(AbstractPlatform::class) + ->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : []) ->onlyMethods(['supportsIdentityColumns']) ->getMockForAbstractClass(); $platform->method('supportsIdentityColumns') diff --git a/tests/Tests/ORM/UnitOfWorkTest.php b/tests/Tests/ORM/UnitOfWorkTest.php index 238848696c3..7faad81bfa1 100644 --- a/tests/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Tests/ORM/UnitOfWorkTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Exception\EntityIdentityCollisionException; use Doctrine\ORM\Mapping\ClassMetadata; @@ -38,6 +39,7 @@ use PHPUnit\Framework\MockObject\MockObject; use stdClass; +use function enum_exists; use function random_int; use function uniqid; @@ -533,6 +535,7 @@ public function testPreviousDetectedIllegalNewNonCascadedEntitiesAreCleanedUpOnS public function testCommitThrowOptimisticLockExceptionWhenConnectionCommitFails(): void { $platform = $this->getMockBuilder(AbstractPlatform::class) + ->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : []) ->onlyMethods(['supportsIdentityColumns']) ->getMockForAbstractClass(); $platform->method('supportsIdentityColumns') diff --git a/tests/Tests/OrmTestCase.php b/tests/Tests/OrmTestCase.php index 52d0a4d2781..9349e83d88b 100644 --- a/tests/Tests/OrmTestCase.php +++ b/tests/Tests/OrmTestCase.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\Name\UnquotedIdentifierFolding; use Doctrine\DBAL\Schema\SchemaConfig; use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Cache\CacheFactory; @@ -21,6 +22,7 @@ use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; +use function enum_exists; use function method_exists; use function realpath; use function sprintf; @@ -158,6 +160,7 @@ private function createPlatformMock(): AbstractPlatform ->willReturn(new SchemaConfig()); $platform = $this->getMockBuilder(AbstractPlatform::class) + ->setConstructorArgs(enum_exists(UnquotedIdentifierFolding::class) ? [UnquotedIdentifierFolding::UPPER] : []) ->onlyMethods(['supportsIdentityColumns', 'createSchemaManager']) ->getMockForAbstractClass(); $platform->method('supportsIdentityColumns') From a2516b67dc102343cc3079f90dc0ce3738fe77bf Mon Sep 17 00:00:00 2001 From: Yevhen Sidelnyk <41589422+rela589n@users.noreply.github.com> Date: Mon, 21 Apr 2025 23:21:43 +0300 Subject: [PATCH 470/475] [DOC]: fix setFileExtension() xml mapping documentation (#11905) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc: fix setFileExtension() xml mapping documentation * Update docs/en/reference/xml-mapping.rst Co-authored-by: Grégoire Paris --------- Co-authored-by: Grégoire Paris --- docs/en/reference/xml-mapping.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/xml-mapping.rst b/docs/en/reference/xml-mapping.rst index e010c93690b..4ee50b7ceb0 100644 --- a/docs/en/reference/xml-mapping.rst +++ b/docs/en/reference/xml-mapping.rst @@ -46,7 +46,7 @@ In order to work, this requires certain conventions: .. code-block:: php setFileExtension('.xml'); + $driver->getLocator()->setFileExtension('.xml'); It is recommended to put all XML mapping documents in a single folder but you can spread the documents over several folders if you From 5d01c66c84bcd09a9407e88cdcc733fb183bfabd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 15 Apr 2025 12:23:35 +0200 Subject: [PATCH 471/475] disable detecting modified indexes with DBAL 4.3 --- phpstan-baseline.neon | 6 ++++++ src/Tools/SchemaTool.php | 9 ++++++++- tests/Tests/ORM/Functional/SchemaTool/DDC214Test.php | 10 +++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ffefa53dc69..1df5363c72c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3114,6 +3114,12 @@ parameters: count: 2 path: src/Tools/SchemaTool.php + - + message: '#^Method Doctrine\\DBAL\\Schema\\AbstractSchemaManager\\:\:createComparator\(\) invoked with 1 parameter, 0 required\.$#' + identifier: arguments.count + count: 1 + path: src/Tools/SchemaTool.php + - message: '#^Method Doctrine\\ORM\\Tools\\SchemaTool\:\:addDiscriminatorColumnDefinition\(\) has parameter \$class with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#' identifier: missingType.generics diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index 27d9c727d71..a26215980ec 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractAsset; use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Doctrine\DBAL\Schema\ComparatorConfig; use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor; use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Name\Identifier; @@ -905,7 +906,13 @@ public function getUpdateSchemaSql(array $classes): array { $toSchema = $this->getSchemaFromMetadata($classes); $fromSchema = $this->createSchemaForComparison($toSchema); - $comparator = $this->schemaManager->createComparator(); + + if (class_exists(ComparatorConfig::class)) { + $comparator = $this->schemaManager->createComparator((new ComparatorConfig())->withReportModifiedIndexes(false)); + } else { + $comparator = $this->schemaManager->createComparator(); + } + $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); return $this->platform->getAlterSchemaSQL($schemaDiff); diff --git a/tests/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 8e9df91ca93..49dd48eac8f 100644 --- a/tests/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -5,11 +5,13 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; use Doctrine\DBAL\Platforms\SQLitePlatform; +use Doctrine\DBAL\Schema\ComparatorConfig; use Doctrine\Tests\Models; use Doctrine\Tests\OrmFunctionalTestCase; use PHPUnit\Framework\Attributes\Group; use function array_filter; +use function class_exists; use function implode; use function str_contains; @@ -68,7 +70,13 @@ public function assertCreatedSchemaNeedsNoUpdates(string ...$classes): void $fromSchema = $sm->introspectSchema(); $toSchema = $this->getSchemaForModels(...$classes); - $comparator = $sm->createComparator(); + + if (class_exists(ComparatorConfig::class)) { + $comparator = $sm->createComparator((new ComparatorConfig())->withReportModifiedIndexes(false)); + } else { + $comparator = $sm->createComparator(); + } + $schemaDiff = $comparator->compareSchemas($fromSchema, $toSchema); $sql = $this->_em->getConnection()->getDatabasePlatform()->getAlterSchemaSQL($schemaDiff); From 457d2d2841a068e6d9433615f899745910aa1b78 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 22 Apr 2025 11:30:42 +0200 Subject: [PATCH 472/475] do not use deprecated primary key constraint features --- phpstan-baseline.neon | 38 +++++++++++++++++++++--- src/Mapping/Driver/DatabaseDriver.php | 18 +++++++++-- src/Tools/SchemaTool.php | 17 +++++++++-- tests/Tests/ORM/Tools/SchemaToolTest.php | 34 +++++++++++++++------ 4 files changed, 89 insertions(+), 18 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ffefa53dc69..9ed21180976 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1368,10 +1368,22 @@ parameters: count: 1 path: src/Mapping/Driver/DatabaseDriver.php + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\Table\:\:getPrimaryKeyConstraint\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + + - + message: '#^Call to method getColumnNames\(\) on an unknown class Doctrine\\DBAL\\Schema\\PrimaryKeyConstraint\.$#' + identifier: class.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Call to method toString\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' identifier: class.notFound - count: 2 + count: 4 path: src/Mapping/Driver/DatabaseDriver.php - @@ -1380,6 +1392,12 @@ parameters: count: 1 path: src/Mapping/Driver/DatabaseDriver.php + - + message: '#^Class Doctrine\\DBAL\\Schema\\PrimaryKeyConstraint not found\.$#' + identifier: class.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Instanceof between Doctrine\\ORM\\Mapping\\ClassMetadata\ and Doctrine\\ORM\\Mapping\\ClassMetadata will always evaluate to true\.$#' identifier: instanceof.alwaysTrue @@ -1425,7 +1443,7 @@ parameters: - message: '#^Parameter \$name of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' identifier: class.notFound - count: 2 + count: 4 path: src/Mapping/Driver/DatabaseDriver.php - @@ -3108,10 +3126,22 @@ parameters: count: 1 path: src/Tools/SchemaTool.php + - + message: '#^Call to method getColumnNames\(\) on an unknown class Doctrine\\DBAL\\Schema\\PrimaryKeyConstraint\.$#' + identifier: class.notFound + count: 1 + path: src/Tools/SchemaTool.php + - message: '#^Call to method toString\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' identifier: class.notFound - count: 2 + count: 3 + path: src/Tools/SchemaTool.php + + - + message: '#^Class Doctrine\\DBAL\\Schema\\PrimaryKeyConstraint not found\.$#' + identifier: class.notFound + count: 1 path: src/Tools/SchemaTool.php - @@ -3219,7 +3249,7 @@ parameters: - message: '#^Parameter \$name of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' identifier: class.notFound - count: 2 + count: 3 path: src/Tools/SchemaTool.php - diff --git a/src/Mapping/Driver/DatabaseDriver.php b/src/Mapping/Driver/DatabaseDriver.php index 723cb41f315..bba0c9423eb 100644 --- a/src/Mapping/Driver/DatabaseDriver.php +++ b/src/Mapping/Driver/DatabaseDriver.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; @@ -274,7 +275,12 @@ private function reverseEngineerMappingFromDatabase(): void $allForeignKeyColumns = array_merge($allForeignKeyColumns, self::getReferencingColumnNames($foreignKey)); } - $primaryKey = $table->getPrimaryKey(); + if (method_exists($table, 'getPrimaryKeyConstraint')) { + $primaryKey = $table->getPrimaryKeyConstraint(); + } else { + $primaryKey = $table->getPrimaryKey(); + } + if ($primaryKey === null) { throw new MappingException( 'Table ' . $tableName . ' has no primary key. Doctrine does not ' . @@ -282,7 +288,11 @@ private function reverseEngineerMappingFromDatabase(): void ); } - $pkColumns = $primaryKey->getColumns(); + if ($primaryKey instanceof PrimaryKeyConstraint) { + $pkColumns = array_map(static fn (UnqualifiedName $name) => $name->toString(), $primaryKey->getColumnNames()); + } else { + $pkColumns = $primaryKey->getColumns(); + } sort($pkColumns); sort($allForeignKeyColumns); @@ -486,6 +496,10 @@ private function buildToOneAssociationMappings(ClassMetadata $metadata): void private function getTablePrimaryKeys(Table $table): array { try { + if (method_exists($table, 'getPrimaryKeyConstraints')) { + return array_map(static fn (UnqualifiedName $name) => $name->toString(), $table->getPrimaryKeyConstraint()->getColumnNames()); + } + return $table->getPrimaryKey()->getColumns(); } catch (SchemaException) { // Do nothing diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index 27d9c727d71..ea61e8e57b0 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -43,6 +43,7 @@ use function implode; use function in_array; use function is_numeric; +use function method_exists; use function strtolower; /** @@ -321,7 +322,7 @@ public function getSchemaFromMetadata(array $classes): Schema $primaryKey = $table->getIndex('primary'); foreach ($table->getIndexes() as $idxKey => $existingIndex) { - if (! $existingIndex->isPrimary() && $primaryKey->spansColumns($existingIndex->getColumns())) { + if ($existingIndex !== $primaryKey && $primaryKey->spansColumns($existingIndex->getColumns())) { $table->dropIndex($idxKey); } } @@ -860,12 +861,22 @@ public function getDropSchemaSQL(array $classes): array } foreach ($schema->getTables() as $table) { - $primaryKey = $table->getPrimaryKey(); + if (method_exists($table, 'getPrimaryKeyConstraint')) { + $primaryKey = $table->getPrimaryKeyConstraint(); + } else { + $primaryKey = $table->getPrimaryKey(); + } + if ($primaryKey === null) { continue; } - $columns = $primaryKey->getColumns(); + if ($primaryKey instanceof PrimaryKeyConstraint) { + $columns = array_map(static fn (UnqualifiedName $name) => $name->toString(), $primaryKey->getColumnNames()); + } else { + $columns = $primaryKey->getColumns(); + } + if (count($columns) === 1) { $checkSequence = $table->getName() . '_' . $columns[0] . '_seq'; if ($deployedSchema->hasSequence($checkSequence) && ! $schema->hasSequence($checkSequence)) { diff --git a/tests/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php index 31e8af16c7e..bfba67f37db 100644 --- a/tests/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Tests/ORM/Tools/SchemaToolTest.php @@ -7,6 +7,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor; use Doctrine\DBAL\Schema\Name\UnqualifiedName; +use Doctrine\DBAL\Schema\PrimaryKeyConstraintEditor; use Doctrine\DBAL\Schema\Table as DbalTable; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; @@ -234,10 +235,15 @@ public function testRemoveUniqueIndexOverruledByPrimaryKey(): void self::assertTrue($schema->hasTable('first_entity'), 'Table first_entity should exist.'); - $indexes = $schema->getTable('first_entity')->getIndexes(); + $table = $schema->getTable('first_entity'); + + self::assertTrue($table->hasIndex('primary'), 'Table should have a primary key.'); + + $primaryKey = $table->getIndex('primary'); + $indexes = $table->getIndexes(); self::assertCount(1, $indexes, 'there should be only one index'); - self::assertTrue(current($indexes)->isPrimary(), 'index should be primary'); + self::assertSame($primaryKey, current($indexes), 'index should be primary'); } public function testSetDiscriminatorColumnWithoutLength(): void @@ -277,13 +283,23 @@ public function testDerivedCompositeKey(): void self::assertTrue($schema->hasTable('joined_derived_root')); self::assertTrue($schema->hasTable('joined_derived_child')); - $rootTable = $schema->getTable('joined_derived_root'); - self::assertNotNull($rootTable->getPrimaryKey()); - self::assertSame(['keyPart1_id', 'keyPart2'], $rootTable->getPrimaryKey()->getColumns()); - - $childTable = $schema->getTable('joined_derived_child'); - self::assertNotNull($childTable->getPrimaryKey()); - self::assertSame(['keyPart1_id', 'keyPart2'], $childTable->getPrimaryKey()->getColumns()); + if (class_exists(PrimaryKeyConstraintEditor::class)) { + $rootTable = $schema->getTable('joined_derived_root'); + self::assertNotNull($rootTable->getPrimaryKeyConstraint()); + self::assertSame(['keyPart1_id', 'keyPart2'], array_map(static fn (UnqualifiedName $name) => $name->toString(), $rootTable->getPrimaryKeyConstraint()->getColumnNames())); + + $childTable = $schema->getTable('joined_derived_child'); + self::assertNotNull($childTable->getPrimaryKeyConstraint()); + self::assertSame(['keyPart1_id', 'keyPart2'], array_map(static fn (UnqualifiedName $name) => $name->toString(), $childTable->getPrimaryKeyConstraint()->getColumnNames())); + } else { + $rootTable = $schema->getTable('joined_derived_root'); + self::assertNotNull($rootTable->getPrimaryKey()); + self::assertSame(['keyPart1_id', 'keyPart2'], $rootTable->getPrimaryKey()->getColumns()); + + $childTable = $schema->getTable('joined_derived_child'); + self::assertNotNull($childTable->getPrimaryKey()); + self::assertSame(['keyPart1_id', 'keyPart2'], $childTable->getPrimaryKey()->getColumns()); + } $childTableForeignKeys = $childTable->getForeignKeys(); From 5eb0255f4752d7547cb99e68fab92be8b046d905 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 15 Apr 2025 09:51:18 +0200 Subject: [PATCH 473/475] do not use deprecated index features --- phpstan-baseline.neon | 48 ++++++++++++++++++++++++ src/Mapping/Driver/DatabaseDriver.php | 28 ++++++++++++-- src/Tools/SchemaTool.php | 17 +++++++-- tests/Tests/ORM/Tools/SchemaToolTest.php | 32 +++++++++++++--- 4 files changed, 112 insertions(+), 13 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9ed21180976..a63d369bc0d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1368,12 +1368,24 @@ parameters: count: 1 path: src/Mapping/Driver/DatabaseDriver.php + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\Index\:\:getIndexedColumns\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\Table\:\:getPrimaryKeyConstraint\(\)\.$#' identifier: method.notFound count: 1 path: src/Mapping/Driver/DatabaseDriver.php + - + message: '#^Call to method getColumnName\(\) on an unknown class Doctrine\\DBAL\\Schema\\Index\\IndexedColumn\.$#' + identifier: class.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Call to method getColumnNames\(\) on an unknown class Doctrine\\DBAL\\Schema\\PrimaryKeyConstraint\.$#' identifier: class.notFound @@ -1392,6 +1404,12 @@ parameters: count: 1 path: src/Mapping/Driver/DatabaseDriver.php + - + message: '#^Class Doctrine\\DBAL\\Schema\\Index\\IndexType not found\.$#' + identifier: class.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Class Doctrine\\DBAL\\Schema\\PrimaryKeyConstraint not found\.$#' identifier: class.notFound @@ -1434,12 +1452,24 @@ parameters: count: 2 path: src/Mapping/Driver/DatabaseDriver.php + - + message: '#^Parameter \#1 \$array of function sort contains unresolvable type\.$#' + identifier: argument.unresolvableType + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Parameter \#2 \$columnName of method Doctrine\\ORM\\Mapping\\Driver\\DatabaseDriver\:\:getFieldNameForColumn\(\) expects string, string\|false given\.$#' identifier: argument.type count: 4 path: src/Mapping/Driver/DatabaseDriver.php + - + message: '#^Parameter \$indexedColumn of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Index\\IndexedColumn\.$#' + identifier: class.notFound + count: 1 + path: src/Mapping/Driver/DatabaseDriver.php + - message: '#^Parameter \$name of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' identifier: class.notFound @@ -3114,6 +3144,12 @@ parameters: count: 1 path: src/Tools/SchemaTool.php + - + message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\Index\:\:getIndexedColumns\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Tools/SchemaTool.php + - message: '#^Call to an undefined method Doctrine\\DBAL\\Schema\\Table\:\:dropForeignKey\(\)\.$#' identifier: method.notFound @@ -3126,6 +3162,12 @@ parameters: count: 1 path: src/Tools/SchemaTool.php + - + message: '#^Call to method getColumnName\(\) on an unknown class Doctrine\\DBAL\\Schema\\Index\\IndexedColumn\.$#' + identifier: class.notFound + count: 1 + path: src/Tools/SchemaTool.php + - message: '#^Call to method getColumnNames\(\) on an unknown class Doctrine\\DBAL\\Schema\\PrimaryKeyConstraint\.$#' identifier: class.notFound @@ -3246,6 +3288,12 @@ parameters: count: 1 path: src/Tools/SchemaTool.php + - + message: '#^Parameter \$indexedColumn of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Index\\IndexedColumn\.$#' + identifier: class.notFound + count: 1 + path: src/Tools/SchemaTool.php + - message: '#^Parameter \$name of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' identifier: class.notFound diff --git a/src/Mapping/Driver/DatabaseDriver.php b/src/Mapping/Driver/DatabaseDriver.php index bba0c9423eb..e2d0713c5c5 100644 --- a/src/Mapping/Driver/DatabaseDriver.php +++ b/src/Mapping/Driver/DatabaseDriver.php @@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\Index\IndexedColumn; +use Doctrine\DBAL\Schema\Index\IndexType; use Doctrine\DBAL\Schema\Name\UnqualifiedName; use Doctrine\DBAL\Schema\PrimaryKeyConstraint; use Doctrine\DBAL\Schema\SchemaException; @@ -29,6 +32,7 @@ use function assert; use function count; use function current; +use function enum_exists; use function get_debug_type; use function in_array; use function method_exists; @@ -291,7 +295,7 @@ private function reverseEngineerMappingFromDatabase(): void if ($primaryKey instanceof PrimaryKeyConstraint) { $pkColumns = array_map(static fn (UnqualifiedName $name) => $name->toString(), $primaryKey->getColumnNames()); } else { - $pkColumns = $primaryKey->getColumns(); + $pkColumns = self::getIndexedColumns($primaryKey); } sort($pkColumns); @@ -323,9 +327,15 @@ private function buildIndexes(ClassMetadata $metadata): void continue; } + if (enum_exists(IndexType::class) && method_exists($index, 'getType')) { + $isUnique = $index->getType() === IndexType::UNIQUE; + } else { + $isUnique = $index->isUnique(); + } + $indexName = $index->getName(); - $indexColumns = $index->getColumns(); - $constraintType = $index->isUnique() + $indexColumns = self::getIndexedColumns($index); + $constraintType = $isUnique ? 'uniqueConstraints' : 'indexes'; @@ -500,7 +510,7 @@ private function getTablePrimaryKeys(Table $table): array return array_map(static fn (UnqualifiedName $name) => $name->toString(), $table->getPrimaryKeyConstraint()->getColumnNames()); } - return $table->getPrimaryKey()->getColumns(); + return self::getIndexedColumns($table->getPrimaryKey()); } catch (SchemaException) { // Do nothing } @@ -574,4 +584,14 @@ private static function getReferencedColumnNames(ForeignKeyConstraint $foreignKe return $foreignKey->getForeignColumns(); } + + /** @return string[] */ + private static function getIndexedColumns(Index $index): array + { + if (method_exists(Index::class, 'getIndexedColumns')) { + return array_map(static fn (IndexedColumn $indexedColumn) => $indexedColumn->getColumnName()->toString(), $index->getIndexedColumns()); + } + + return $index->getColumns(); + } } diff --git a/src/Tools/SchemaTool.php b/src/Tools/SchemaTool.php index ea61e8e57b0..9ea73943e9b 100644 --- a/src/Tools/SchemaTool.php +++ b/src/Tools/SchemaTool.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor; use Doctrine\DBAL\Schema\Index; +use Doctrine\DBAL\Schema\Index\IndexedColumn; use Doctrine\DBAL\Schema\Name\Identifier; use Doctrine\DBAL\Schema\Name\UnqualifiedName; use Doctrine\DBAL\Schema\PrimaryKeyConstraint; @@ -322,7 +323,7 @@ public function getSchemaFromMetadata(array $classes): Schema $primaryKey = $table->getIndex('primary'); foreach ($table->getIndexes() as $idxKey => $existingIndex) { - if ($existingIndex !== $primaryKey && $primaryKey->spansColumns($existingIndex->getColumns())) { + if ($existingIndex !== $primaryKey && $primaryKey->spansColumns(self::getIndexedColumns($existingIndex))) { $table->dropIndex($idxKey); } } @@ -353,7 +354,7 @@ public function getSchemaFromMetadata(array $classes): Schema } } - $table->addUniqueIndex($uniqIndex->getColumns(), is_numeric($indexName) ? null : $indexName, $indexData['options'] ?? []); + $table->addUniqueIndex(self::getIndexedColumns($uniqIndex), is_numeric($indexName) ? null : $indexName, $indexData['options'] ?? []); } } @@ -874,7 +875,7 @@ public function getDropSchemaSQL(array $classes): array if ($primaryKey instanceof PrimaryKeyConstraint) { $columns = array_map(static fn (UnqualifiedName $name) => $name->toString(), $primaryKey->getColumnNames()); } else { - $columns = $primaryKey->getColumns(); + $columns = self::getIndexedColumns($primaryKey); } if (count($columns) === 1) { @@ -967,4 +968,14 @@ private function addPrimaryKeyConstraint(Table $table, array $primaryKeyColumns) $table->setPrimaryKey($primaryKeyColumns); } } + + /** @return string[] */ + private static function getIndexedColumns(Index $index): array + { + if (method_exists(Index::class, 'getIndexedColumns')) { + return array_map(static fn (IndexedColumn $indexedColumn) => $indexedColumn->getColumnName()->toString(), $index->getIndexedColumns()); + } + + return $index->getColumns(); + } } diff --git a/tests/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php index bfba67f37db..0a11c8fea68 100644 --- a/tests/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Tests/ORM/Tools/SchemaToolTest.php @@ -6,6 +6,9 @@ use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Schema\ForeignKeyConstraintEditor; +use Doctrine\DBAL\Schema\Index as DbalIndex; +use Doctrine\DBAL\Schema\Index\IndexedColumn; +use Doctrine\DBAL\Schema\Index\IndexType; use Doctrine\DBAL\Schema\Name\UnqualifiedName; use Doctrine\DBAL\Schema\PrimaryKeyConstraintEditor; use Doctrine\DBAL\Schema\Table as DbalTable; @@ -50,6 +53,8 @@ use function class_exists; use function count; use function current; +use function enum_exists; +use function method_exists; class SchemaToolTest extends OrmTestCase { @@ -294,11 +299,11 @@ public function testDerivedCompositeKey(): void } else { $rootTable = $schema->getTable('joined_derived_root'); self::assertNotNull($rootTable->getPrimaryKey()); - self::assertSame(['keyPart1_id', 'keyPart2'], $rootTable->getPrimaryKey()->getColumns()); + self::assertSame(['keyPart1_id', 'keyPart2'], self::getIndexedColumns($rootTable->getPrimaryKey())); $childTable = $schema->getTable('joined_derived_child'); self::assertNotNull($childTable->getPrimaryKey()); - self::assertSame(['keyPart1_id', 'keyPart2'], $childTable->getPrimaryKey()->getColumns()); + self::assertSame(['keyPart1_id', 'keyPart2'], self::getIndexedColumns($childTable->getPrimaryKey())); } $childTableForeignKeys = $childTable->getForeignKeys(); @@ -339,8 +344,8 @@ public function testIndexesBasedOnFields(): void $schema = $schemaTool->getSchemaFromMetadata([$metadata]); $table = $schema->getTable('field_index'); - self::assertEquals(['index', 'field_name'], $table->getIndex('index')->getColumns()); - self::assertEquals(['index', 'table'], $table->getIndex('uniq')->getColumns()); + self::assertEquals(['index', 'field_name'], self::getIndexedColumns($table->getIndex('index'))); + self::assertEquals(['index', 'table'], self::getIndexedColumns($table->getIndex('uniq'))); } public function testIncorrectIndexesBasedOnFields(): void @@ -418,8 +423,23 @@ public function testLoadUniqueConstraintWithoutName(): void $tableIndex = $tableEntity->getIndex('uniq_2d81a3ed5bf54558875f7fd5'); - self::assertTrue($tableIndex->isUnique()); - self::assertSame(['field', 'anotherField'], $tableIndex->getColumns()); + if (enum_exists(IndexType::class)) { + self::assertSame(IndexType::UNIQUE, $tableIndex->getType()); + } else { + self::assertTrue($tableIndex->isUnique()); + } + + self::assertSame(['field', 'anotherField'], self::getIndexedColumns($tableIndex)); + } + + /** @return string[] */ + private static function getIndexedColumns(DbalIndex $index): array + { + if (method_exists(DbalIndex::class, 'getIndexedColumns')) { + return array_map(static fn (IndexedColumn $indexedColumn) => $indexedColumn->getColumnName()->toString(), $index->getIndexedColumns()); + } + + return $index->getColumns(); } private static function columnIsIndexed(DbalTable $table, string $column): bool From 5a1e560f87c54a9c32805d035ba5219b30a60252 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 25 Apr 2025 14:20:08 +0200 Subject: [PATCH 474/475] prefer primary key constraints over Index::isPrimary() --- phpstan-baseline.neon | 4 ++-- src/Mapping/Driver/DatabaseDriver.php | 33 +++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b1a5582b8f6..a6a0445dde4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1395,7 +1395,7 @@ parameters: - message: '#^Call to method toString\(\) on an unknown class Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' identifier: class.notFound - count: 4 + count: 5 path: src/Mapping/Driver/DatabaseDriver.php - @@ -1473,7 +1473,7 @@ parameters: - message: '#^Parameter \$name of anonymous function has invalid type Doctrine\\DBAL\\Schema\\Name\\UnqualifiedName\.$#' identifier: class.notFound - count: 4 + count: 5 path: src/Mapping/Driver/DatabaseDriver.php - diff --git a/src/Mapping/Driver/DatabaseDriver.php b/src/Mapping/Driver/DatabaseDriver.php index e2d0713c5c5..69f875d9909 100644 --- a/src/Mapping/Driver/DatabaseDriver.php +++ b/src/Mapping/Driver/DatabaseDriver.php @@ -319,11 +319,13 @@ private function reverseEngineerMappingFromDatabase(): void */ private function buildIndexes(ClassMetadata $metadata): void { - $tableName = $metadata->table['name']; - $indexes = $this->tables[$tableName]->getIndexes(); + $tableName = $metadata->table['name']; + $table = $this->tables[$tableName]; + $primaryKey = self::getPrimaryKey($table); + $indexes = $table->getIndexes(); foreach ($indexes as $index) { - if ($index->isPrimary()) { + if ($index === $primaryKey) { continue; } @@ -506,7 +508,7 @@ private function buildToOneAssociationMappings(ClassMetadata $metadata): void private function getTablePrimaryKeys(Table $table): array { try { - if (method_exists($table, 'getPrimaryKeyConstraints')) { + if (method_exists($table, 'getPrimaryKeyConstraint')) { return array_map(static fn (UnqualifiedName $name) => $name->toString(), $table->getPrimaryKeyConstraint()->getColumnNames()); } @@ -594,4 +596,27 @@ private static function getIndexedColumns(Index $index): array return $index->getColumns(); } + + private static function getPrimaryKey(Table $table): Index|null + { + $primaryKeyConstraint = null; + + if (method_exists(Table::class, 'getPrimaryKeyConstraint')) { + $primaryKeyConstraint = $table->getPrimaryKeyConstraint(); + } + + foreach ($table->getIndexes() as $index) { + if ($primaryKeyConstraint !== null) { + $primaryKeyConstraintColumns = array_map(static fn (UnqualifiedName $name) => $name->toString(), $primaryKeyConstraint->getColumnNames()); + + if ($primaryKeyConstraintColumns === self::getIndexedColumns($index)) { + return $index; + } + } elseif ($index->isPrimary()) { + return $index; + } + } + + return null; + } } From 0e3cff0c6a64e5832ed0b00ac4528a4a4592a6f3 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 2 May 2025 00:56:00 +0300 Subject: [PATCH 475/475] Update composite-primary-keys.rst (#11919) Fix examples --- docs/en/tutorials/composite-primary-keys.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/en/tutorials/composite-primary-keys.rst b/docs/en/tutorials/composite-primary-keys.rst index f8cae53d91e..65f04fd3066 100644 --- a/docs/en/tutorials/composite-primary-keys.rst +++ b/docs/en/tutorials/composite-primary-keys.rst @@ -250,7 +250,7 @@ of products purchased and maybe even the current price. public function __construct( #[ManyToOne(targetEntity: Customer::class)] - private Customer $customer, + private Customer $customer ) { $this->items = new ArrayCollection(); $this->created = new DateTime("now"); @@ -295,6 +295,7 @@ of products purchased and maybe even the current price. $this->order = $order; $this->product = $product; $this->offeredPrice = $product->getCurrentPrice(); + $this->amount = $amount; } }